@apiteam/twa-bridge 8.0.8 → 8.0.10
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/package.json +1 -1
- package/solid/index.d.ts +457 -457
- package/solid/index.js +1 -1
- package/solid/index.mjs +1 -1
package/package.json
CHANGED
package/solid/index.d.ts
CHANGED
|
@@ -1,271 +1,200 @@
|
|
|
1
1
|
import * as solid_js from 'solid-js';
|
|
2
2
|
import { Context, JSX, Component } from 'solid-js';
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
width?: number;
|
|
7
|
-
is_expanded: boolean;
|
|
8
|
-
is_state_stable: boolean;
|
|
9
|
-
}>;
|
|
10
|
-
|
|
11
|
-
type Close = (eventData?: SenderData[typeof MethodClose]) => {
|
|
12
|
-
status: boolean | typeof NOT_SUPPORTED;
|
|
13
|
-
};
|
|
14
|
-
declare const close: Close;
|
|
15
|
-
declare const supportClose: () => boolean;
|
|
16
|
-
|
|
17
|
-
type CloseScanQrPopup = (eventData?: SenderData[typeof MethodCloseScanQrPopup]) => {
|
|
18
|
-
status: boolean | typeof NOT_SUPPORTED;
|
|
19
|
-
};
|
|
20
|
-
declare const closeScanQrPopup: CloseScanQrPopup;
|
|
21
|
-
declare const supportCloseScanQrPopup: () => boolean;
|
|
22
|
-
|
|
23
|
-
type DataSend = (eventData: SenderData[typeof MethodDataSend]) => {
|
|
24
|
-
status: boolean | typeof NOT_SUPPORTED;
|
|
25
|
-
};
|
|
26
|
-
declare const dataSend: DataSend;
|
|
27
|
-
declare const supportDataSend: () => boolean;
|
|
28
|
-
|
|
29
|
-
type Expand = (props?: SenderData[typeof MethodExpand]) => {
|
|
30
|
-
status: boolean | typeof NOT_SUPPORTED;
|
|
31
|
-
};
|
|
32
|
-
declare const expand: Expand;
|
|
33
|
-
declare const supportExpand: () => boolean;
|
|
34
|
-
|
|
35
|
-
type IframeReady = (eventData: SenderData[typeof MethodIframeReady]) => {
|
|
36
|
-
status: boolean | typeof NOT_SUPPORTED;
|
|
37
|
-
};
|
|
38
|
-
declare const iframeReady: IframeReady;
|
|
39
|
-
declare const supportIframeReady: () => boolean;
|
|
40
|
-
|
|
41
|
-
type IframeWillReload = (eventData: SenderData[typeof MethodIframeReady]) => {
|
|
42
|
-
status: boolean | typeof NOT_SUPPORTED;
|
|
43
|
-
};
|
|
44
|
-
declare const iframeWillReload: IframeWillReload;
|
|
45
|
-
declare const supportIframeWillReload: () => boolean;
|
|
46
|
-
|
|
47
|
-
type InvokeCustomMethod = (eventData: SenderData[typeof MethodInvokeCustomMethod]) => Promise<{
|
|
48
|
-
status: boolean | typeof NOT_SUPPORTED;
|
|
49
|
-
data?: EventsData[typeof EventCustomMethodInvoked];
|
|
50
|
-
}>;
|
|
51
|
-
declare const invokeCustomMethod: InvokeCustomMethod;
|
|
52
|
-
declare const supportInvokeCustomMethod: () => boolean;
|
|
53
|
-
|
|
54
|
-
type OpenInvoice = (eventData: SenderData[typeof MethodOpenInvoice]) => {
|
|
55
|
-
status: boolean | typeof NOT_SUPPORTED;
|
|
56
|
-
};
|
|
57
|
-
declare const openInvoice: OpenInvoice;
|
|
58
|
-
declare const supportOpenInvoice: () => boolean;
|
|
59
|
-
|
|
60
|
-
type OpenLink = (eventData: SenderData[typeof MethodOpenLink]) => {
|
|
61
|
-
status: boolean | typeof NOT_SUPPORTED;
|
|
62
|
-
};
|
|
63
|
-
declare const openLink: OpenLink;
|
|
64
|
-
declare const supportOpenLink: () => boolean;
|
|
65
|
-
|
|
66
|
-
type OpenPopup = (eventData: SenderData[typeof MethodOpenPopup]) => Promise<{
|
|
67
|
-
status: boolean | typeof NOT_SUPPORTED;
|
|
68
|
-
data?: EventsData['popup_closed'];
|
|
69
|
-
}>;
|
|
70
|
-
declare const openPopup: OpenPopup;
|
|
71
|
-
declare const supportOpenPopup: () => boolean;
|
|
72
|
-
|
|
73
|
-
type OpenScanQrPopup = (eventData: SenderData[typeof MethodOpenScanQrPopup]) => Promise<{
|
|
74
|
-
status: boolean | typeof NOT_SUPPORTED | 'closed';
|
|
75
|
-
data?: EventsData[typeof EventQrTextReceived];
|
|
76
|
-
}>;
|
|
77
|
-
declare const openScanQrPopup: OpenScanQrPopup;
|
|
78
|
-
declare const supportOpenScanQrPopup: () => boolean;
|
|
79
|
-
|
|
80
|
-
type OpenTgLink = (eventData: SenderData[typeof MethodOpenTgLink]) => {
|
|
81
|
-
status: boolean | typeof NOT_SUPPORTED;
|
|
82
|
-
};
|
|
83
|
-
declare const openTgLink: OpenTgLink;
|
|
84
|
-
declare const supportOpenTgLink: () => boolean;
|
|
85
|
-
|
|
86
|
-
type ReadTextFromClipboard = (eventData?: SenderData[typeof MethodReadTextFromClipboard]) => Promise<{
|
|
87
|
-
status: boolean | typeof NOT_SUPPORTED;
|
|
88
|
-
data?: EventsData[typeof EventClipboardTextReceived];
|
|
89
|
-
}>;
|
|
90
|
-
declare const readTextFromClipboard: ReadTextFromClipboard;
|
|
91
|
-
declare const supportReadTextFromClipboard: () => boolean;
|
|
92
|
-
|
|
93
|
-
type Ready = (eventData?: SenderData[typeof MethodReady]) => {
|
|
94
|
-
status: boolean | typeof NOT_SUPPORTED;
|
|
95
|
-
};
|
|
96
|
-
declare const ready: Ready;
|
|
97
|
-
declare const supportReady: () => boolean;
|
|
98
|
-
|
|
99
|
-
type RequestPhone = (eventData?: SenderData[typeof MethodRequestPhone]) => Promise<{
|
|
100
|
-
status: boolean | typeof NOT_SUPPORTED;
|
|
101
|
-
}>;
|
|
102
|
-
declare const requestPhone: RequestPhone;
|
|
103
|
-
declare const supportRequestPhone: () => boolean;
|
|
104
|
-
|
|
105
|
-
type RequestTheme = (eventData?: SenderData[typeof MethodRequestTheme]) => {
|
|
106
|
-
status: boolean | typeof NOT_SUPPORTED;
|
|
107
|
-
};
|
|
108
|
-
declare const requestTheme: RequestTheme;
|
|
109
|
-
declare const supportRequestTheme: () => boolean;
|
|
110
|
-
|
|
111
|
-
type RequestViewport = (eventData?: SenderData[typeof MethodRequestViewport]) => {
|
|
112
|
-
status: boolean | typeof NOT_SUPPORTED;
|
|
113
|
-
};
|
|
114
|
-
declare const requestViewport: RequestViewport;
|
|
115
|
-
declare const supportRequestViewport: () => boolean;
|
|
116
|
-
|
|
117
|
-
type RequestWriteAccess = (eventData?: SenderData[typeof MethodRequestWriteAccess]) => Promise<{
|
|
118
|
-
status: boolean | typeof NOT_SUPPORTED;
|
|
119
|
-
}>;
|
|
120
|
-
declare const requestWriteAccess: RequestWriteAccess;
|
|
121
|
-
declare const supportRequestWriteAccess: () => boolean;
|
|
122
|
-
|
|
123
|
-
type SetBackgroundColor = (eventData: SenderData[typeof MethodSetBackgroundColor]) => {
|
|
124
|
-
status: boolean | typeof NOT_SUPPORTED;
|
|
125
|
-
};
|
|
126
|
-
declare const setBackgroundColor: SetBackgroundColor;
|
|
127
|
-
declare const supportSetBackgroundColor: () => boolean;
|
|
128
|
-
|
|
129
|
-
type SetHeaderColor = (eventData: SenderData[typeof MethodSetHeaderColor]) => {
|
|
130
|
-
status: boolean | typeof NOT_SUPPORTED;
|
|
131
|
-
};
|
|
132
|
-
declare const setHeaderColor: SetHeaderColor;
|
|
133
|
-
declare const supportSetHeaderColor: () => boolean;
|
|
134
|
-
|
|
135
|
-
type SetBottomBarColor = (eventData: SenderData[typeof MethodSetBottomBarColor]) => {
|
|
136
|
-
status: boolean | typeof NOT_SUPPORTED;
|
|
137
|
-
};
|
|
138
|
-
declare const setBottomBarColor: SetBottomBarColor;
|
|
139
|
-
declare const supportSetBottomBarColor: () => boolean;
|
|
140
|
-
|
|
141
|
-
type SetupBackButton = (eventData: SenderData[typeof MethodSetupBackButton]) => {
|
|
142
|
-
status: boolean | typeof NOT_SUPPORTED;
|
|
143
|
-
};
|
|
144
|
-
declare const setupBackButton: SetupBackButton;
|
|
145
|
-
declare const supportSetupBackButton: () => boolean;
|
|
146
|
-
|
|
147
|
-
type SetupClosingBehavior = (eventData: SenderData[typeof MethodSetupClosingBehavior]) => {
|
|
148
|
-
status: boolean | typeof NOT_SUPPORTED;
|
|
149
|
-
};
|
|
150
|
-
declare const setupClosingBehavior: SetupClosingBehavior;
|
|
151
|
-
declare const supportSetupClosingBehavior: () => boolean;
|
|
152
|
-
|
|
153
|
-
type SetupMainButton = (eventData: SenderData[typeof MethodSetupMainButton]) => {
|
|
154
|
-
status: boolean | typeof NOT_SUPPORTED;
|
|
155
|
-
};
|
|
156
|
-
declare const setupMainButton: SetupMainButton;
|
|
157
|
-
declare const supportSetupMainButton: () => boolean;
|
|
158
|
-
|
|
159
|
-
type SetupSettingsButton = (eventData: SenderData[typeof MethodSetupSettingsButton]) => {
|
|
160
|
-
status: boolean | typeof NOT_SUPPORTED;
|
|
161
|
-
};
|
|
162
|
-
declare const setupSettingsButton: SetupSettingsButton;
|
|
163
|
-
declare const supportSetupSettingsButton: () => boolean;
|
|
164
|
-
|
|
165
|
-
type SwitchInlineQuery = (eventData: SenderData[typeof MethodSwitchInlineQuery]) => {
|
|
166
|
-
status: boolean | typeof NOT_SUPPORTED;
|
|
167
|
-
};
|
|
168
|
-
declare const switchInlineQuery: SwitchInlineQuery;
|
|
169
|
-
declare const supportSwitchInlineQuery: () => boolean;
|
|
170
|
-
|
|
171
|
-
type TriggerHapticFeedback = (eventData: SenderData[typeof MethodTriggerHapticFeedback]) => {
|
|
172
|
-
status: boolean | typeof NOT_SUPPORTED;
|
|
173
|
-
};
|
|
174
|
-
declare const triggerHapticFeedback: TriggerHapticFeedback;
|
|
175
|
-
declare const supportTriggerHapticFeedback: () => boolean;
|
|
176
|
-
|
|
177
|
-
type SessionStorageSet = ({ key, value }: {
|
|
178
|
-
key: string;
|
|
179
|
-
value: any;
|
|
180
|
-
}) => {
|
|
181
|
-
status: boolean | typeof NOT_SUPPORTED;
|
|
182
|
-
};
|
|
183
|
-
declare const sessionStorageSet: SessionStorageSet;
|
|
184
|
-
declare const supportSessionStorageSet: () => boolean;
|
|
185
|
-
|
|
186
|
-
type SessionStorageGet = ({ key }: {
|
|
187
|
-
key: string;
|
|
188
|
-
}) => {
|
|
189
|
-
is_json: boolean;
|
|
190
|
-
status: boolean | typeof NOT_SUPPORTED;
|
|
191
|
-
value?: any;
|
|
192
|
-
};
|
|
193
|
-
declare const sessionStorageGet: SessionStorageGet;
|
|
194
|
-
declare const supportSessionStorageGet: () => boolean;
|
|
195
|
-
|
|
196
|
-
type SetupSwipeBehavior = (eventData: SenderData[typeof MethodSetupSwipeBehavior]) => {
|
|
197
|
-
status: boolean | typeof NOT_SUPPORTED;
|
|
198
|
-
};
|
|
199
|
-
declare const setupSwipeBehavior: SetupSwipeBehavior;
|
|
200
|
-
declare const supportSetupSwipeBehavior: () => boolean;
|
|
201
|
-
|
|
202
|
-
type ShareToStory = (eventData?: SenderData[typeof MethodShareToStory]) => {
|
|
203
|
-
status: boolean | typeof NOT_SUPPORTED;
|
|
204
|
-
error_id?: number;
|
|
205
|
-
};
|
|
206
|
-
declare const shareToStory: ShareToStory;
|
|
207
|
-
declare const supportShareToStory: () => boolean;
|
|
208
|
-
|
|
209
|
-
type CheckHomeScreen = (eventData: SenderData[typeof MethodCheckHomeScreen]) => Promise<{
|
|
210
|
-
status: boolean | typeof NOT_SUPPORTED;
|
|
211
|
-
data?: EventsData[typeof EventHomeScreenChecked];
|
|
212
|
-
}>;
|
|
213
|
-
declare const checkHomeScreen: CheckHomeScreen;
|
|
214
|
-
declare const supportCheckHomeScreen: () => boolean;
|
|
215
|
-
|
|
216
|
-
type AddToHomeScreen = (eventData?: SenderData[typeof MethodAddToHomeScreen]) => {
|
|
217
|
-
status: boolean | typeof NOT_SUPPORTED;
|
|
218
|
-
};
|
|
219
|
-
declare const addToHomeScreen: AddToHomeScreen;
|
|
220
|
-
declare const supportAddToHomeScreen: () => boolean;
|
|
4
|
+
type Sender = (eventType: string, eventData?: any) => void;
|
|
5
|
+
declare const sender: Sender;
|
|
221
6
|
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
declare const
|
|
226
|
-
declare const
|
|
7
|
+
declare const EventBackButtonPressed = "back_button_pressed";
|
|
8
|
+
declare const EventClipboardTextReceived = "clipboard_text_received";
|
|
9
|
+
declare const EventCustomMethodInvoked = "custom_method_invoked";
|
|
10
|
+
declare const EventInvoiceClosed = "invoice_closed";
|
|
11
|
+
declare const EventMainButtonPressed = "main_button_pressed";
|
|
12
|
+
declare const EventPhoneRequested = "phone_requested";
|
|
13
|
+
declare const EventPopupClosed = "popup_closed";
|
|
14
|
+
declare const EventReloadIframe = "reload_iframe";
|
|
15
|
+
declare const EventQrTextReceived = "qr_text_received";
|
|
16
|
+
declare const EventScanQrPopupClosed = "scan_qr_popup_closed";
|
|
17
|
+
declare const EventSetCustomStyle = "set_custom_style";
|
|
18
|
+
declare const EventSettingsButtonPressed = "settings_button_pressed";
|
|
19
|
+
declare const EventThemeChanged = "theme_changed";
|
|
20
|
+
declare const EventViewportChanged = "viewport_changed";
|
|
21
|
+
declare const EventWriteAccessRequested = "write_access_requested";
|
|
22
|
+
declare const EventSafeAreaChanged = "safe_area_changed";
|
|
23
|
+
declare const EventContentSafeAreaChanged = "content_safe_area_changed";
|
|
24
|
+
declare const EventPreparedMessageSent = "prepared_message_sent";
|
|
25
|
+
declare const EventPreparedMessageFailed = "prepared_message_failed";
|
|
26
|
+
declare const EventEmojiStatusSet = "emoji_status_set";
|
|
27
|
+
declare const EventEmojiStatusFailed = "emoji_status_failed";
|
|
28
|
+
declare const EventEmojiStatusAccessRequested = "emoji_status_access_requested";
|
|
29
|
+
declare const EventFileDownloadRequested = "file_download_requested";
|
|
30
|
+
declare const EventAccelerometerChanged = "accelerometer_changed";
|
|
31
|
+
declare const EventAccelerometerFailed = "accelerometer_failed";
|
|
32
|
+
declare const EventAccelerometerStarted = "accelerometer_started";
|
|
33
|
+
declare const EventAccelerometerStopped = "accelerometer_stopped";
|
|
34
|
+
declare const EventBiometryAuthRequested = "biometry_auth_requested";
|
|
35
|
+
declare const EventBiometryInfoReceived = "biometry_info_received";
|
|
36
|
+
declare const EventBiometryTokenUpdated = "biometry_token_updated";
|
|
37
|
+
declare const EventDeviceOrientationChanged = "device_orientation_changed";
|
|
38
|
+
declare const EventDeviceOrientationFailed = "device_orientation_failed";
|
|
39
|
+
declare const EventDeviceOrientationStarted = "device_orientation_started";
|
|
40
|
+
declare const EventDeviceOrientationStopped = "device_orientation_stopped";
|
|
41
|
+
declare const EventFullscreenChanged = "fullscreen_changed";
|
|
42
|
+
declare const EventFullscreenFailed = "fullscreen_failed";
|
|
43
|
+
declare const EventGyroscopeChanged = "gyroscope_changed";
|
|
44
|
+
declare const EventGyroscopeFailed = "gyroscope_failed";
|
|
45
|
+
declare const EventGyroscopeStarted = "gyroscope_started";
|
|
46
|
+
declare const EventGyroscopeStopped = "gyroscope_stopped";
|
|
47
|
+
declare const EventHomeScreenAdded = "home_screen_added";
|
|
48
|
+
declare const EventHomeScreenChecked = "home_screen_checked";
|
|
49
|
+
declare const EventHomeScreenFailed = "home_screen_failed";
|
|
50
|
+
declare const EventLocationChecked = "location_checked";
|
|
51
|
+
declare const EventLocationRequested = "location_requested";
|
|
52
|
+
declare const EventSecondaryButtonPressed = "secondary_button_pressed";
|
|
53
|
+
declare const EventVisibilityChanged = "visibility_changed";
|
|
227
54
|
|
|
228
|
-
type
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
declare const
|
|
232
|
-
declare const
|
|
55
|
+
type GetPlatform = () => 'phone' | 'web' | 'desktop';
|
|
56
|
+
declare const TG_WEB = "web";
|
|
57
|
+
declare const TG_PHONE = "phone";
|
|
58
|
+
declare const TG_DESKTOP = "desktop";
|
|
59
|
+
declare const getPlatform: GetPlatform;
|
|
233
60
|
|
|
234
|
-
|
|
235
|
-
status: boolean | typeof NOT_SUPPORTED;
|
|
236
|
-
};
|
|
237
|
-
declare const setupFullScreen: SetupFullScreen;
|
|
238
|
-
declare const supportSetupFullScreen: () => boolean;
|
|
61
|
+
declare const NOT_SUPPORTED = "not_supported";
|
|
239
62
|
|
|
240
|
-
type
|
|
241
|
-
|
|
63
|
+
type ThemeParams = {
|
|
64
|
+
bg_color: string;
|
|
65
|
+
text_color: string;
|
|
66
|
+
hint_color: string;
|
|
67
|
+
link_color: string;
|
|
68
|
+
button_color: string;
|
|
69
|
+
button_text_color: string;
|
|
70
|
+
secondary_bg_color: string;
|
|
71
|
+
header_bg_color: string;
|
|
72
|
+
bottom_bar_bg_color: string;
|
|
73
|
+
accent_text_color: string;
|
|
74
|
+
section_bg_color: string;
|
|
75
|
+
section_header_text_color: string;
|
|
76
|
+
section_separator_color: string;
|
|
77
|
+
subtitle_text_color: string;
|
|
78
|
+
destructive_text_color: string;
|
|
242
79
|
};
|
|
243
|
-
declare const
|
|
244
|
-
declare const supportSetupOrientation: () => boolean;
|
|
245
|
-
|
|
246
|
-
type RequestEmojiStatus = (eventData?: SenderData[typeof MethodRequestEmojiStatusAccess]) => Promise<{
|
|
247
|
-
status: boolean | typeof NOT_SUPPORTED;
|
|
248
|
-
}>;
|
|
249
|
-
declare const requestEmojiStatus: RequestEmojiStatus;
|
|
250
|
-
declare const supportRequestEmojiStatus: () => boolean;
|
|
251
|
-
|
|
252
|
-
type SetEmojiStatus = (eventData?: SenderData[typeof MethodSetEmojiStatus]) => Promise<{
|
|
253
|
-
status: boolean | typeof NOT_SUPPORTED;
|
|
254
|
-
}>;
|
|
255
|
-
declare const setEmojiStatus: SetEmojiStatus;
|
|
256
|
-
declare const supportSetEmojiStatus: () => boolean;
|
|
80
|
+
declare const getThemeParams: (theme_params?: ThemeParams) => ThemeParams;
|
|
257
81
|
|
|
258
|
-
type
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
82
|
+
type EventsData = {
|
|
83
|
+
back_button_pressed: undefined;
|
|
84
|
+
clipboard_text_received: {
|
|
85
|
+
req_id: string;
|
|
86
|
+
data?: string | null;
|
|
87
|
+
};
|
|
88
|
+
custom_method_invoked: {
|
|
89
|
+
req_id: string;
|
|
90
|
+
result?: unknown;
|
|
91
|
+
error?: string;
|
|
92
|
+
};
|
|
93
|
+
invoice_closed: {
|
|
94
|
+
slug: string;
|
|
95
|
+
status: 'paid' | 'failed' | 'pending' | 'cancelled';
|
|
96
|
+
};
|
|
97
|
+
main_button_pressed: undefined;
|
|
98
|
+
phone_requested: {
|
|
99
|
+
status: 'sent';
|
|
100
|
+
};
|
|
101
|
+
popup_closed: {
|
|
102
|
+
button_id?: string;
|
|
103
|
+
};
|
|
104
|
+
reload_iframe: undefined;
|
|
105
|
+
qr_text_received: {
|
|
106
|
+
data?: string;
|
|
107
|
+
};
|
|
108
|
+
scan_qr_popup_closed: undefined;
|
|
109
|
+
set_custom_style: undefined;
|
|
110
|
+
settings_button_pressed: undefined;
|
|
111
|
+
theme_changed: {
|
|
112
|
+
theme_params: ThemeParams;
|
|
113
|
+
};
|
|
114
|
+
viewport_changed: {
|
|
115
|
+
height: number;
|
|
116
|
+
width?: number;
|
|
117
|
+
is_expanded: boolean;
|
|
118
|
+
is_state_stable: boolean;
|
|
119
|
+
};
|
|
120
|
+
[EventHomeScreenChecked]: {
|
|
121
|
+
status: 'unsupported' | 'unknown' | 'added' | 'missed';
|
|
122
|
+
};
|
|
123
|
+
[EventSafeAreaChanged]: {
|
|
124
|
+
top: number;
|
|
125
|
+
bottom: number;
|
|
126
|
+
left: number;
|
|
127
|
+
right: number;
|
|
128
|
+
};
|
|
129
|
+
[EventContentSafeAreaChanged]: {
|
|
130
|
+
top: number;
|
|
131
|
+
bottom: number;
|
|
132
|
+
left: number;
|
|
133
|
+
right: number;
|
|
134
|
+
};
|
|
135
|
+
[EventPreparedMessageSent]: undefined;
|
|
136
|
+
[EventPreparedMessageFailed]: undefined;
|
|
137
|
+
[EventEmojiStatusSet]: undefined;
|
|
138
|
+
[EventEmojiStatusFailed]: undefined;
|
|
139
|
+
[EventEmojiStatusAccessRequested]: {
|
|
140
|
+
status: 'allowed';
|
|
141
|
+
};
|
|
142
|
+
[EventFileDownloadRequested]: {
|
|
143
|
+
status: 'downloading';
|
|
144
|
+
};
|
|
145
|
+
[EventWriteAccessRequested]: {
|
|
146
|
+
status: 'allowed';
|
|
147
|
+
};
|
|
148
|
+
[EventBiometryInfoReceived]: {
|
|
149
|
+
available: boolean;
|
|
150
|
+
access_requested: boolean;
|
|
151
|
+
access_granted: boolean;
|
|
152
|
+
device_id: string;
|
|
153
|
+
token_saved: boolean;
|
|
154
|
+
type: 'face' | 'finger' | 'unknown';
|
|
155
|
+
};
|
|
156
|
+
[EventBiometryTokenUpdated]: {
|
|
157
|
+
status: 'updated' | 'removed';
|
|
158
|
+
};
|
|
159
|
+
[EventBiometryAuthRequested]: {
|
|
160
|
+
status: 'failed';
|
|
161
|
+
token: undefined;
|
|
162
|
+
} | {
|
|
163
|
+
status: 'authorized';
|
|
164
|
+
token: string;
|
|
165
|
+
};
|
|
166
|
+
};
|
|
167
|
+
interface TelegramGameProxy {
|
|
168
|
+
receiveEvent: (event: string, data: string) => void;
|
|
169
|
+
}
|
|
170
|
+
interface TelegramWebviewProxy {
|
|
171
|
+
postEvent: (event: string, data: string) => void;
|
|
172
|
+
}
|
|
173
|
+
declare global {
|
|
174
|
+
interface External {
|
|
175
|
+
notify: (event: string) => void;
|
|
176
|
+
}
|
|
177
|
+
interface Window {
|
|
178
|
+
TelegramWebviewProxy: TelegramWebviewProxy;
|
|
179
|
+
TelegramGameProxy: TelegramGameProxy;
|
|
180
|
+
TelegramGameProxy_receiveEvent: TelegramGameProxy['receiveEvent'];
|
|
181
|
+
Telegram: {
|
|
182
|
+
WebView: TelegramGameProxy;
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
type Listened = <T extends EventsData, E extends keyof T, D extends T[E]>(eventName: E, callback: (eventData: D) => void) => void;
|
|
187
|
+
declare const on: Listened;
|
|
188
|
+
declare const off: Listened;
|
|
189
|
+
declare const once: Listened;
|
|
263
190
|
|
|
264
|
-
type
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
declare const
|
|
268
|
-
declare
|
|
191
|
+
type listener_EventsData = EventsData;
|
|
192
|
+
declare const listener_off: typeof off;
|
|
193
|
+
declare const listener_on: typeof on;
|
|
194
|
+
declare const listener_once: typeof once;
|
|
195
|
+
declare namespace listener {
|
|
196
|
+
export { type listener_EventsData as EventsData, listener_off as off, listener_on as on, listener_once as once };
|
|
197
|
+
}
|
|
269
198
|
|
|
270
199
|
declare const MethodInvokeCustomMethod = "web_app_invoke_custom_method";
|
|
271
200
|
declare const MethodOpenScanQrPopup = "web_app_open_scan_qr_popup";
|
|
@@ -500,6 +429,275 @@ type SenderData = {
|
|
|
500
429
|
[MethodBiometryOpenSettings]: undefined;
|
|
501
430
|
};
|
|
502
431
|
|
|
432
|
+
type Debug = (methondName: string, errorId: number) => void;
|
|
433
|
+
declare const debug: Debug;
|
|
434
|
+
|
|
435
|
+
declare const createIsViewportChanged: () => solid_js.Accessor<{
|
|
436
|
+
height: number;
|
|
437
|
+
width?: number;
|
|
438
|
+
is_expanded: boolean;
|
|
439
|
+
is_state_stable: boolean;
|
|
440
|
+
}>;
|
|
441
|
+
|
|
442
|
+
type Close = (eventData?: SenderData[typeof MethodClose]) => {
|
|
443
|
+
status: boolean | typeof NOT_SUPPORTED;
|
|
444
|
+
};
|
|
445
|
+
declare const close: Close;
|
|
446
|
+
declare const supportClose: () => boolean;
|
|
447
|
+
|
|
448
|
+
type CloseScanQrPopup = (eventData?: SenderData[typeof MethodCloseScanQrPopup]) => {
|
|
449
|
+
status: boolean | typeof NOT_SUPPORTED;
|
|
450
|
+
};
|
|
451
|
+
declare const closeScanQrPopup: CloseScanQrPopup;
|
|
452
|
+
declare const supportCloseScanQrPopup: () => boolean;
|
|
453
|
+
|
|
454
|
+
type DataSend = (eventData: SenderData[typeof MethodDataSend]) => {
|
|
455
|
+
status: boolean | typeof NOT_SUPPORTED;
|
|
456
|
+
};
|
|
457
|
+
declare const dataSend: DataSend;
|
|
458
|
+
declare const supportDataSend: () => boolean;
|
|
459
|
+
|
|
460
|
+
type Expand = (props?: SenderData[typeof MethodExpand]) => {
|
|
461
|
+
status: boolean | typeof NOT_SUPPORTED;
|
|
462
|
+
};
|
|
463
|
+
declare const expand: Expand;
|
|
464
|
+
declare const supportExpand: () => boolean;
|
|
465
|
+
|
|
466
|
+
type IframeReady = (eventData: SenderData[typeof MethodIframeReady]) => {
|
|
467
|
+
status: boolean | typeof NOT_SUPPORTED;
|
|
468
|
+
};
|
|
469
|
+
declare const iframeReady: IframeReady;
|
|
470
|
+
declare const supportIframeReady: () => boolean;
|
|
471
|
+
|
|
472
|
+
type IframeWillReload = (eventData: SenderData[typeof MethodIframeReady]) => {
|
|
473
|
+
status: boolean | typeof NOT_SUPPORTED;
|
|
474
|
+
};
|
|
475
|
+
declare const iframeWillReload: IframeWillReload;
|
|
476
|
+
declare const supportIframeWillReload: () => boolean;
|
|
477
|
+
|
|
478
|
+
type InvokeCustomMethod = (eventData: SenderData[typeof MethodInvokeCustomMethod]) => Promise<{
|
|
479
|
+
status: boolean | typeof NOT_SUPPORTED;
|
|
480
|
+
data?: EventsData[typeof EventCustomMethodInvoked];
|
|
481
|
+
}>;
|
|
482
|
+
declare const invokeCustomMethod: InvokeCustomMethod;
|
|
483
|
+
declare const supportInvokeCustomMethod: () => boolean;
|
|
484
|
+
|
|
485
|
+
type OpenInvoice = (eventData: SenderData[typeof MethodOpenInvoice]) => {
|
|
486
|
+
status: boolean | typeof NOT_SUPPORTED;
|
|
487
|
+
};
|
|
488
|
+
declare const openInvoice: OpenInvoice;
|
|
489
|
+
declare const supportOpenInvoice: () => boolean;
|
|
490
|
+
|
|
491
|
+
type OpenLink = (eventData: SenderData[typeof MethodOpenLink]) => {
|
|
492
|
+
status: boolean | typeof NOT_SUPPORTED;
|
|
493
|
+
};
|
|
494
|
+
declare const openLink: OpenLink;
|
|
495
|
+
declare const supportOpenLink: () => boolean;
|
|
496
|
+
|
|
497
|
+
type OpenPopup = (eventData: SenderData[typeof MethodOpenPopup]) => Promise<{
|
|
498
|
+
status: boolean | typeof NOT_SUPPORTED;
|
|
499
|
+
data?: EventsData['popup_closed'];
|
|
500
|
+
}>;
|
|
501
|
+
declare const openPopup: OpenPopup;
|
|
502
|
+
declare const supportOpenPopup: () => boolean;
|
|
503
|
+
|
|
504
|
+
type OpenScanQrPopup = (eventData: SenderData[typeof MethodOpenScanQrPopup]) => Promise<{
|
|
505
|
+
status: boolean | typeof NOT_SUPPORTED | 'closed';
|
|
506
|
+
data?: EventsData[typeof EventQrTextReceived];
|
|
507
|
+
}>;
|
|
508
|
+
declare const openScanQrPopup: OpenScanQrPopup;
|
|
509
|
+
declare const supportOpenScanQrPopup: () => boolean;
|
|
510
|
+
|
|
511
|
+
type OpenTgLink = (eventData: SenderData[typeof MethodOpenTgLink]) => {
|
|
512
|
+
status: boolean | typeof NOT_SUPPORTED;
|
|
513
|
+
};
|
|
514
|
+
declare const openTgLink: OpenTgLink;
|
|
515
|
+
declare const supportOpenTgLink: () => boolean;
|
|
516
|
+
|
|
517
|
+
type ReadTextFromClipboard = (eventData?: SenderData[typeof MethodReadTextFromClipboard]) => Promise<{
|
|
518
|
+
status: boolean | typeof NOT_SUPPORTED;
|
|
519
|
+
data?: EventsData[typeof EventClipboardTextReceived];
|
|
520
|
+
}>;
|
|
521
|
+
declare const readTextFromClipboard: ReadTextFromClipboard;
|
|
522
|
+
declare const supportReadTextFromClipboard: () => boolean;
|
|
523
|
+
|
|
524
|
+
type Ready = (eventData?: SenderData[typeof MethodReady]) => {
|
|
525
|
+
status: boolean | typeof NOT_SUPPORTED;
|
|
526
|
+
};
|
|
527
|
+
declare const ready: Ready;
|
|
528
|
+
declare const supportReady: () => boolean;
|
|
529
|
+
|
|
530
|
+
type RequestPhone = (eventData?: SenderData[typeof MethodRequestPhone]) => Promise<{
|
|
531
|
+
status: boolean | typeof NOT_SUPPORTED;
|
|
532
|
+
}>;
|
|
533
|
+
declare const requestPhone: RequestPhone;
|
|
534
|
+
declare const supportRequestPhone: () => boolean;
|
|
535
|
+
|
|
536
|
+
type RequestTheme = (eventData?: SenderData[typeof MethodRequestTheme]) => {
|
|
537
|
+
status: boolean | typeof NOT_SUPPORTED;
|
|
538
|
+
};
|
|
539
|
+
declare const requestTheme: RequestTheme;
|
|
540
|
+
declare const supportRequestTheme: () => boolean;
|
|
541
|
+
|
|
542
|
+
type RequestViewport = (eventData?: SenderData[typeof MethodRequestViewport]) => {
|
|
543
|
+
status: boolean | typeof NOT_SUPPORTED;
|
|
544
|
+
};
|
|
545
|
+
declare const requestViewport: RequestViewport;
|
|
546
|
+
declare const supportRequestViewport: () => boolean;
|
|
547
|
+
|
|
548
|
+
type RequestWriteAccess = (eventData?: SenderData[typeof MethodRequestWriteAccess]) => Promise<{
|
|
549
|
+
status: boolean | typeof NOT_SUPPORTED;
|
|
550
|
+
}>;
|
|
551
|
+
declare const requestWriteAccess: RequestWriteAccess;
|
|
552
|
+
declare const supportRequestWriteAccess: () => boolean;
|
|
553
|
+
|
|
554
|
+
type SetBackgroundColor = (eventData: SenderData[typeof MethodSetBackgroundColor]) => {
|
|
555
|
+
status: boolean | typeof NOT_SUPPORTED;
|
|
556
|
+
};
|
|
557
|
+
declare const setBackgroundColor: SetBackgroundColor;
|
|
558
|
+
declare const supportSetBackgroundColor: () => boolean;
|
|
559
|
+
|
|
560
|
+
type SetHeaderColor = (eventData: SenderData[typeof MethodSetHeaderColor]) => {
|
|
561
|
+
status: boolean | typeof NOT_SUPPORTED;
|
|
562
|
+
};
|
|
563
|
+
declare const setHeaderColor: SetHeaderColor;
|
|
564
|
+
declare const supportSetHeaderColor: () => boolean;
|
|
565
|
+
|
|
566
|
+
type SetBottomBarColor = (eventData: SenderData[typeof MethodSetBottomBarColor]) => {
|
|
567
|
+
status: boolean | typeof NOT_SUPPORTED;
|
|
568
|
+
};
|
|
569
|
+
declare const setBottomBarColor: SetBottomBarColor;
|
|
570
|
+
declare const supportSetBottomBarColor: () => boolean;
|
|
571
|
+
|
|
572
|
+
type SetupBackButton = (eventData: SenderData[typeof MethodSetupBackButton]) => {
|
|
573
|
+
status: boolean | typeof NOT_SUPPORTED;
|
|
574
|
+
};
|
|
575
|
+
declare const setupBackButton: SetupBackButton;
|
|
576
|
+
declare const supportSetupBackButton: () => boolean;
|
|
577
|
+
|
|
578
|
+
type SetupClosingBehavior = (eventData: SenderData[typeof MethodSetupClosingBehavior]) => {
|
|
579
|
+
status: boolean | typeof NOT_SUPPORTED;
|
|
580
|
+
};
|
|
581
|
+
declare const setupClosingBehavior: SetupClosingBehavior;
|
|
582
|
+
declare const supportSetupClosingBehavior: () => boolean;
|
|
583
|
+
|
|
584
|
+
type SetupMainButton = (eventData: SenderData[typeof MethodSetupMainButton]) => {
|
|
585
|
+
status: boolean | typeof NOT_SUPPORTED;
|
|
586
|
+
};
|
|
587
|
+
declare const setupMainButton: SetupMainButton;
|
|
588
|
+
declare const supportSetupMainButton: () => boolean;
|
|
589
|
+
|
|
590
|
+
type SetupSettingsButton = (eventData: SenderData[typeof MethodSetupSettingsButton]) => {
|
|
591
|
+
status: boolean | typeof NOT_SUPPORTED;
|
|
592
|
+
};
|
|
593
|
+
declare const setupSettingsButton: SetupSettingsButton;
|
|
594
|
+
declare const supportSetupSettingsButton: () => boolean;
|
|
595
|
+
|
|
596
|
+
type SwitchInlineQuery = (eventData: SenderData[typeof MethodSwitchInlineQuery]) => {
|
|
597
|
+
status: boolean | typeof NOT_SUPPORTED;
|
|
598
|
+
};
|
|
599
|
+
declare const switchInlineQuery: SwitchInlineQuery;
|
|
600
|
+
declare const supportSwitchInlineQuery: () => boolean;
|
|
601
|
+
|
|
602
|
+
type TriggerHapticFeedback = (eventData: SenderData[typeof MethodTriggerHapticFeedback]) => {
|
|
603
|
+
status: boolean | typeof NOT_SUPPORTED;
|
|
604
|
+
};
|
|
605
|
+
declare const triggerHapticFeedback: TriggerHapticFeedback;
|
|
606
|
+
declare const supportTriggerHapticFeedback: () => boolean;
|
|
607
|
+
|
|
608
|
+
type SessionStorageSet = ({ key, value }: {
|
|
609
|
+
key: string;
|
|
610
|
+
value: any;
|
|
611
|
+
}) => {
|
|
612
|
+
status: boolean | typeof NOT_SUPPORTED;
|
|
613
|
+
};
|
|
614
|
+
declare const sessionStorageSet: SessionStorageSet;
|
|
615
|
+
declare const supportSessionStorageSet: () => boolean;
|
|
616
|
+
|
|
617
|
+
type SessionStorageGet = ({ key }: {
|
|
618
|
+
key: string;
|
|
619
|
+
}) => {
|
|
620
|
+
is_json: boolean;
|
|
621
|
+
status: boolean | typeof NOT_SUPPORTED;
|
|
622
|
+
value?: any;
|
|
623
|
+
};
|
|
624
|
+
declare const sessionStorageGet: SessionStorageGet;
|
|
625
|
+
declare const supportSessionStorageGet: () => boolean;
|
|
626
|
+
|
|
627
|
+
type SetupSwipeBehavior = (eventData: SenderData[typeof MethodSetupSwipeBehavior]) => {
|
|
628
|
+
status: boolean | typeof NOT_SUPPORTED;
|
|
629
|
+
};
|
|
630
|
+
declare const setupSwipeBehavior: SetupSwipeBehavior;
|
|
631
|
+
declare const supportSetupSwipeBehavior: () => boolean;
|
|
632
|
+
|
|
633
|
+
type ShareToStory = (eventData?: SenderData[typeof MethodShareToStory]) => {
|
|
634
|
+
status: boolean | typeof NOT_SUPPORTED;
|
|
635
|
+
error_id?: number;
|
|
636
|
+
};
|
|
637
|
+
declare const shareToStory: ShareToStory;
|
|
638
|
+
declare const supportShareToStory: () => boolean;
|
|
639
|
+
|
|
640
|
+
type CheckHomeScreen = (eventData: SenderData[typeof MethodCheckHomeScreen]) => Promise<{
|
|
641
|
+
status: boolean | typeof NOT_SUPPORTED;
|
|
642
|
+
data?: EventsData[typeof EventHomeScreenChecked];
|
|
643
|
+
}>;
|
|
644
|
+
declare const checkHomeScreen: CheckHomeScreen;
|
|
645
|
+
declare const supportCheckHomeScreen: () => boolean;
|
|
646
|
+
|
|
647
|
+
type AddToHomeScreen = (eventData?: SenderData[typeof MethodAddToHomeScreen]) => {
|
|
648
|
+
status: boolean | typeof NOT_SUPPORTED;
|
|
649
|
+
};
|
|
650
|
+
declare const addToHomeScreen: AddToHomeScreen;
|
|
651
|
+
declare const supportAddToHomeScreen: () => boolean;
|
|
652
|
+
|
|
653
|
+
type RequestSafeAreaInset = (eventData?: SenderData[typeof MethodRequestSafeArea]) => {
|
|
654
|
+
status: boolean | typeof NOT_SUPPORTED;
|
|
655
|
+
};
|
|
656
|
+
declare const requestSafeAreaInset: RequestSafeAreaInset;
|
|
657
|
+
declare const supportRequestSafeAreaInset: () => boolean;
|
|
658
|
+
|
|
659
|
+
type RequestContentSafeAreaInset = (eventData?: SenderData[typeof MethodRequestContentSafeArea]) => {
|
|
660
|
+
status: boolean | typeof NOT_SUPPORTED;
|
|
661
|
+
};
|
|
662
|
+
declare const requestContentSafeAreaInset: RequestContentSafeAreaInset;
|
|
663
|
+
declare const supportRequestContentSafeAreaInset: () => boolean;
|
|
664
|
+
|
|
665
|
+
type SetupFullScreen = (eventData?: SenderData[typeof MethodRequestFullscreen]) => {
|
|
666
|
+
status: boolean | typeof NOT_SUPPORTED;
|
|
667
|
+
};
|
|
668
|
+
declare const setupFullScreen: SetupFullScreen;
|
|
669
|
+
declare const supportSetupFullScreen: () => boolean;
|
|
670
|
+
|
|
671
|
+
type SetupOrientation = (eventData?: SenderData[typeof MethodToggleOrientationLock]) => {
|
|
672
|
+
status: boolean | typeof NOT_SUPPORTED;
|
|
673
|
+
};
|
|
674
|
+
declare const setupOrientation: SetupOrientation;
|
|
675
|
+
declare const supportSetupOrientation: () => boolean;
|
|
676
|
+
|
|
677
|
+
type RequestEmojiStatus = (eventData?: SenderData[typeof MethodRequestEmojiStatusAccess]) => Promise<{
|
|
678
|
+
status: boolean | typeof NOT_SUPPORTED;
|
|
679
|
+
}>;
|
|
680
|
+
declare const requestEmojiStatus: RequestEmojiStatus;
|
|
681
|
+
declare const supportRequestEmojiStatus: () => boolean;
|
|
682
|
+
|
|
683
|
+
type SetEmojiStatus = (eventData?: SenderData[typeof MethodSetEmojiStatus]) => Promise<{
|
|
684
|
+
status: boolean | typeof NOT_SUPPORTED;
|
|
685
|
+
}>;
|
|
686
|
+
declare const setEmojiStatus: SetEmojiStatus;
|
|
687
|
+
declare const supportSetEmojiStatus: () => boolean;
|
|
688
|
+
|
|
689
|
+
type ShareMessage = (eventData?: SenderData[typeof MethodSendPreparedMessage]) => Promise<{
|
|
690
|
+
status: boolean | typeof NOT_SUPPORTED;
|
|
691
|
+
}>;
|
|
692
|
+
declare const shareMessage: ShareMessage;
|
|
693
|
+
declare const supportShareMessage: () => boolean;
|
|
694
|
+
|
|
695
|
+
type DownloadFile = (eventData?: SenderData[typeof MethodRequestFileDownload]) => Promise<{
|
|
696
|
+
status: boolean | typeof NOT_SUPPORTED;
|
|
697
|
+
}>;
|
|
698
|
+
declare const downloadFile: DownloadFile;
|
|
699
|
+
declare const supportDownloadFile: () => boolean;
|
|
700
|
+
|
|
503
701
|
type Store = {
|
|
504
702
|
isInited: boolean;
|
|
505
703
|
isBiometricAvailable: boolean;
|
|
@@ -574,204 +772,6 @@ type GetInitData = {
|
|
|
574
772
|
} | undefined;
|
|
575
773
|
declare const getInitData: () => GetInitData;
|
|
576
774
|
|
|
577
|
-
type ThemeParams = {
|
|
578
|
-
bg_color: string;
|
|
579
|
-
text_color: string;
|
|
580
|
-
hint_color: string;
|
|
581
|
-
link_color: string;
|
|
582
|
-
button_color: string;
|
|
583
|
-
button_text_color: string;
|
|
584
|
-
secondary_bg_color: string;
|
|
585
|
-
header_bg_color: string;
|
|
586
|
-
bottom_bar_bg_color: string;
|
|
587
|
-
accent_text_color: string;
|
|
588
|
-
section_bg_color: string;
|
|
589
|
-
section_header_text_color: string;
|
|
590
|
-
section_separator_color: string;
|
|
591
|
-
subtitle_text_color: string;
|
|
592
|
-
destructive_text_color: string;
|
|
593
|
-
};
|
|
594
|
-
declare const getThemeParams: (theme_params?: ThemeParams) => ThemeParams;
|
|
595
|
-
|
|
596
|
-
type Sender = (eventType: string, eventData?: any) => void;
|
|
597
|
-
declare const sender: Sender;
|
|
598
|
-
|
|
599
|
-
declare const EventBackButtonPressed = "back_button_pressed";
|
|
600
|
-
declare const EventClipboardTextReceived = "clipboard_text_received";
|
|
601
|
-
declare const EventCustomMethodInvoked = "custom_method_invoked";
|
|
602
|
-
declare const EventInvoiceClosed = "invoice_closed";
|
|
603
|
-
declare const EventMainButtonPressed = "main_button_pressed";
|
|
604
|
-
declare const EventPhoneRequested = "phone_requested";
|
|
605
|
-
declare const EventPopupClosed = "popup_closed";
|
|
606
|
-
declare const EventReloadIframe = "reload_iframe";
|
|
607
|
-
declare const EventQrTextReceived = "qr_text_received";
|
|
608
|
-
declare const EventScanQrPopupClosed = "scan_qr_popup_closed";
|
|
609
|
-
declare const EventSetCustomStyle = "set_custom_style";
|
|
610
|
-
declare const EventSettingsButtonPressed = "settings_button_pressed";
|
|
611
|
-
declare const EventThemeChanged = "theme_changed";
|
|
612
|
-
declare const EventViewportChanged = "viewport_changed";
|
|
613
|
-
declare const EventWriteAccessRequested = "write_access_requested";
|
|
614
|
-
declare const EventSafeAreaChanged = "safe_area_changed";
|
|
615
|
-
declare const EventContentSafeAreaChanged = "content_safe_area_changed";
|
|
616
|
-
declare const EventPreparedMessageSent = "prepared_message_sent";
|
|
617
|
-
declare const EventPreparedMessageFailed = "prepared_message_failed";
|
|
618
|
-
declare const EventEmojiStatusSet = "emoji_status_set";
|
|
619
|
-
declare const EventEmojiStatusFailed = "emoji_status_failed";
|
|
620
|
-
declare const EventEmojiStatusAccessRequested = "emoji_status_access_requested";
|
|
621
|
-
declare const EventFileDownloadRequested = "file_download_requested";
|
|
622
|
-
declare const EventAccelerometerChanged = "accelerometer_changed";
|
|
623
|
-
declare const EventAccelerometerFailed = "accelerometer_failed";
|
|
624
|
-
declare const EventAccelerometerStarted = "accelerometer_started";
|
|
625
|
-
declare const EventAccelerometerStopped = "accelerometer_stopped";
|
|
626
|
-
declare const EventBiometryAuthRequested = "biometry_auth_requested";
|
|
627
|
-
declare const EventBiometryInfoReceived = "biometry_info_received";
|
|
628
|
-
declare const EventBiometryTokenUpdated = "biometry_token_updated";
|
|
629
|
-
declare const EventDeviceOrientationChanged = "device_orientation_changed";
|
|
630
|
-
declare const EventDeviceOrientationFailed = "device_orientation_failed";
|
|
631
|
-
declare const EventDeviceOrientationStarted = "device_orientation_started";
|
|
632
|
-
declare const EventDeviceOrientationStopped = "device_orientation_stopped";
|
|
633
|
-
declare const EventFullscreenChanged = "fullscreen_changed";
|
|
634
|
-
declare const EventFullscreenFailed = "fullscreen_failed";
|
|
635
|
-
declare const EventGyroscopeChanged = "gyroscope_changed";
|
|
636
|
-
declare const EventGyroscopeFailed = "gyroscope_failed";
|
|
637
|
-
declare const EventGyroscopeStarted = "gyroscope_started";
|
|
638
|
-
declare const EventGyroscopeStopped = "gyroscope_stopped";
|
|
639
|
-
declare const EventHomeScreenAdded = "home_screen_added";
|
|
640
|
-
declare const EventHomeScreenChecked = "home_screen_checked";
|
|
641
|
-
declare const EventHomeScreenFailed = "home_screen_failed";
|
|
642
|
-
declare const EventLocationChecked = "location_checked";
|
|
643
|
-
declare const EventLocationRequested = "location_requested";
|
|
644
|
-
declare const EventSecondaryButtonPressed = "secondary_button_pressed";
|
|
645
|
-
declare const EventVisibilityChanged = "visibility_changed";
|
|
646
|
-
|
|
647
|
-
type GetPlatform = () => 'phone' | 'web' | 'desktop';
|
|
648
|
-
declare const TG_WEB = "web";
|
|
649
|
-
declare const TG_PHONE = "phone";
|
|
650
|
-
declare const TG_DESKTOP = "desktop";
|
|
651
|
-
declare const getPlatform: GetPlatform;
|
|
652
|
-
|
|
653
|
-
declare const NOT_SUPPORTED = "not_supported";
|
|
654
|
-
|
|
655
|
-
type EventsData = {
|
|
656
|
-
back_button_pressed: undefined;
|
|
657
|
-
clipboard_text_received: {
|
|
658
|
-
req_id: string;
|
|
659
|
-
data?: string | null;
|
|
660
|
-
};
|
|
661
|
-
custom_method_invoked: {
|
|
662
|
-
req_id: string;
|
|
663
|
-
result?: unknown;
|
|
664
|
-
error?: string;
|
|
665
|
-
};
|
|
666
|
-
invoice_closed: {
|
|
667
|
-
slug: string;
|
|
668
|
-
status: 'paid' | 'failed' | 'pending' | 'cancelled';
|
|
669
|
-
};
|
|
670
|
-
main_button_pressed: undefined;
|
|
671
|
-
phone_requested: {
|
|
672
|
-
status: 'sent';
|
|
673
|
-
};
|
|
674
|
-
popup_closed: {
|
|
675
|
-
button_id?: string;
|
|
676
|
-
};
|
|
677
|
-
reload_iframe: undefined;
|
|
678
|
-
qr_text_received: {
|
|
679
|
-
data?: string;
|
|
680
|
-
};
|
|
681
|
-
scan_qr_popup_closed: undefined;
|
|
682
|
-
set_custom_style: undefined;
|
|
683
|
-
settings_button_pressed: undefined;
|
|
684
|
-
theme_changed: {
|
|
685
|
-
theme_params: ThemeParams;
|
|
686
|
-
};
|
|
687
|
-
viewport_changed: {
|
|
688
|
-
height: number;
|
|
689
|
-
width?: number;
|
|
690
|
-
is_expanded: boolean;
|
|
691
|
-
is_state_stable: boolean;
|
|
692
|
-
};
|
|
693
|
-
[EventHomeScreenChecked]: {
|
|
694
|
-
status: 'unsupported' | 'unknown' | 'added' | 'missed';
|
|
695
|
-
};
|
|
696
|
-
[EventSafeAreaChanged]: {
|
|
697
|
-
top: number;
|
|
698
|
-
bottom: number;
|
|
699
|
-
left: number;
|
|
700
|
-
right: number;
|
|
701
|
-
};
|
|
702
|
-
[EventContentSafeAreaChanged]: {
|
|
703
|
-
top: number;
|
|
704
|
-
bottom: number;
|
|
705
|
-
left: number;
|
|
706
|
-
right: number;
|
|
707
|
-
};
|
|
708
|
-
[EventPreparedMessageSent]: undefined;
|
|
709
|
-
[EventPreparedMessageFailed]: undefined;
|
|
710
|
-
[EventEmojiStatusSet]: undefined;
|
|
711
|
-
[EventEmojiStatusFailed]: undefined;
|
|
712
|
-
[EventEmojiStatusAccessRequested]: {
|
|
713
|
-
status: 'allowed';
|
|
714
|
-
};
|
|
715
|
-
[EventFileDownloadRequested]: {
|
|
716
|
-
status: 'downloading';
|
|
717
|
-
};
|
|
718
|
-
[EventWriteAccessRequested]: {
|
|
719
|
-
status: 'allowed';
|
|
720
|
-
};
|
|
721
|
-
[EventBiometryInfoReceived]: {
|
|
722
|
-
available: boolean;
|
|
723
|
-
access_requested: boolean;
|
|
724
|
-
access_granted: boolean;
|
|
725
|
-
device_id: string;
|
|
726
|
-
token_saved: boolean;
|
|
727
|
-
type: 'face' | 'finger' | 'unknown';
|
|
728
|
-
};
|
|
729
|
-
[EventBiometryTokenUpdated]: {
|
|
730
|
-
status: 'updated' | 'removed';
|
|
731
|
-
};
|
|
732
|
-
[EventBiometryAuthRequested]: {
|
|
733
|
-
status: 'failed';
|
|
734
|
-
token: undefined;
|
|
735
|
-
} | {
|
|
736
|
-
status: 'authorized';
|
|
737
|
-
token: string;
|
|
738
|
-
};
|
|
739
|
-
};
|
|
740
|
-
interface TelegramGameProxy {
|
|
741
|
-
receiveEvent: (event: string, data: string) => void;
|
|
742
|
-
}
|
|
743
|
-
interface TelegramWebviewProxy {
|
|
744
|
-
postEvent: (event: string, data: string) => void;
|
|
745
|
-
}
|
|
746
|
-
declare global {
|
|
747
|
-
interface External {
|
|
748
|
-
notify: (event: string) => void;
|
|
749
|
-
}
|
|
750
|
-
interface Window {
|
|
751
|
-
TelegramWebviewProxy: TelegramWebviewProxy;
|
|
752
|
-
TelegramGameProxy: TelegramGameProxy;
|
|
753
|
-
TelegramGameProxy_receiveEvent: TelegramGameProxy['receiveEvent'];
|
|
754
|
-
Telegram: {
|
|
755
|
-
WebView: TelegramGameProxy;
|
|
756
|
-
};
|
|
757
|
-
}
|
|
758
|
-
}
|
|
759
|
-
type Listened = <T extends EventsData, E extends keyof T, D extends T[E]>(eventName: E, callback: (eventData: D) => void) => void;
|
|
760
|
-
declare const on: Listened;
|
|
761
|
-
declare const off: Listened;
|
|
762
|
-
declare const once: Listened;
|
|
763
|
-
|
|
764
|
-
type listener_EventsData = EventsData;
|
|
765
|
-
declare const listener_off: typeof off;
|
|
766
|
-
declare const listener_on: typeof on;
|
|
767
|
-
declare const listener_once: typeof once;
|
|
768
|
-
declare namespace listener {
|
|
769
|
-
export { type listener_EventsData as EventsData, listener_off as off, listener_on as on, listener_once as once };
|
|
770
|
-
}
|
|
771
|
-
|
|
772
|
-
type Debug = (methondName: string, errorId: number) => void;
|
|
773
|
-
declare const debug: Debug;
|
|
774
|
-
|
|
775
775
|
declare const getAppData: () => string | null;
|
|
776
776
|
|
|
777
777
|
type Value = {
|
|
@@ -786,4 +786,4 @@ interface ProviderTWA extends JSX.HTMLAttributes<HTMLDivElement> {
|
|
|
786
786
|
}
|
|
787
787
|
declare const ProviderTWA: Component<ProviderTWA>;
|
|
788
788
|
|
|
789
|
-
export {
|
|
789
|
+
export { ContextTwa, EventAccelerometerChanged, EventAccelerometerFailed, EventAccelerometerStarted, EventAccelerometerStopped, EventBackButtonPressed, EventBiometryAuthRequested, EventBiometryInfoReceived, EventBiometryTokenUpdated, EventClipboardTextReceived, EventContentSafeAreaChanged, EventCustomMethodInvoked, EventDeviceOrientationChanged, EventDeviceOrientationFailed, EventDeviceOrientationStarted, EventDeviceOrientationStopped, EventEmojiStatusAccessRequested, EventEmojiStatusFailed, EventEmojiStatusSet, EventFileDownloadRequested, EventFullscreenChanged, EventFullscreenFailed, EventGyroscopeChanged, EventGyroscopeFailed, EventGyroscopeStarted, EventGyroscopeStopped, EventHomeScreenAdded, EventHomeScreenChecked, EventHomeScreenFailed, EventInvoiceClosed, EventLocationChecked, EventLocationRequested, EventMainButtonPressed, EventPhoneRequested, EventPopupClosed, EventPreparedMessageFailed, EventPreparedMessageSent, EventQrTextReceived, EventReloadIframe, EventSafeAreaChanged, EventScanQrPopupClosed, EventSecondaryButtonPressed, EventSetCustomStyle, EventSettingsButtonPressed, EventThemeChanged, EventViewportChanged, EventVisibilityChanged, EventWriteAccessRequested, type EventsData, type GetInitData, Method, MethodAddToHomeScreen, MethodCheckHomeScreen, MethodClose, MethodCloseScanQrPopup, MethodDataSend, MethodExitFullscreen, MethodExpand, MethodIframeReady, MethodIframeWillReload, MethodInvokeCustomMethod, MethodOpenInvoice, MethodOpenLink, MethodOpenPopup, MethodOpenScanQrPopup, MethodOpenTgLink, MethodReadTextFromClipboard, MethodReady, MethodRequestContentSafeArea, MethodRequestEmojiStatusAccess, MethodRequestFileDownload, MethodRequestFullscreen, MethodRequestPhone, MethodRequestSafeArea, MethodRequestTheme, MethodRequestViewport, MethodRequestWriteAccess, MethodSendPreparedMessage, MethodSetBackgroundColor, MethodSetBottomBarColor, MethodSetEmojiStatus, MethodSetHeaderColor, MethodSetupBackButton, MethodSetupClosingBehavior, MethodSetupMainButton, MethodSetupSettingsButton, MethodSetupSwipeBehavior, MethodShareToStory, MethodSwitchInlineQuery, MethodToggleOrientationLock, MethodTriggerHapticFeedback, NOT_SUPPORTED, type PopupButton, ProviderTWA, type SenderData, TG_DESKTOP, TG_PHONE, TG_WEB, type ThemeParams, addToHomeScreen as bridgeAddToHomeScreen, BiometricManager as bridgeBiometricManager, checkHomeScreen as bridgeCheckHomeScreen, close as bridgeClose, closeScanQrPopup as bridgeCloseScanQrPopup, dataSend as bridgeDataSend, downloadFile as bridgeDownloadFile, expand as bridgeExpand, getInitData as bridgeGetInitData, getThemeParams as bridgeGetThemeParams, iframeReady as bridgeIframeReady, iframeWillReload as bridgeIframeWillReload, invokeCustomMethod as bridgeInvokeCustomMethod, openInvoice as bridgeOpenInvoice, openLink as bridgeOpenLink, openPopup as bridgeOpenPopup, openScanQrPopup as bridgeOpenScanQrPopup, openTgLink as bridgeOpenTgLink, readTextFromClipboard as bridgeReadTextFromClipboard, ready as bridgeReady, requestContentSafeAreaInset as bridgeRequestContentSafeAreaInset, requestEmojiStatus as bridgeRequestEmojiStatus, requestPhone as bridgeRequestPhone, requestSafeAreaInset as bridgeRequestSafeAreaInset, requestTheme as bridgeRequestTheme, requestViewport as bridgeRequestViewport, requestWriteAccess as bridgeRequestWriteAccess, sender as bridgeSend, sessionStorageGet as bridgeSessionStorageGet, sessionStorageSet as bridgeSessionStorageSet, setBackgroundColor as bridgeSetBackgroundColor, setBottomBarColor as bridgeSetBottomBarColor, setEmojiStatus as bridgeSetEmojiStatus, setHeaderColor as bridgeSetHeaderColor, setupBackButton as bridgeSetupBackButton, setupClosingBehavior as bridgeSetupClosingBehavior, setupFullScreen as bridgeSetupFullScreen, setupMainButton as bridgeSetupMainButton, setupOrientation as bridgeSetupOrientation, setupSettingsButton as bridgeSetupSettingsButton, setupSwipeBehavior as bridgeSetupSwipeBehavior, shareMessage as bridgeShareMessage, shareToStory as bridgeShareToStory, switchInlineQuery as bridgeSwitchInlineQuery, triggerHapticFeedback as bridgeTriggerHapticFeedback, createIsViewportChanged, debug, getAppData, getPlatform, listener, sender, supportAddToHomeScreen, supportBiometricManager, supportCheckHomeScreen, supportClose, supportCloseScanQrPopup, supportDataSend, supportDownloadFile, supportExpand, supportIframeReady, supportIframeWillReload, supportInvokeCustomMethod, supportOpenInvoice, supportOpenLink, supportOpenPopup, supportOpenScanQrPopup, supportOpenTgLink, supportReadTextFromClipboard, supportReady, supportRequestContentSafeAreaInset, supportRequestEmojiStatus, supportRequestPhone, supportRequestSafeAreaInset, supportRequestTheme, supportRequestViewport, supportRequestWriteAccess, supportSessionStorageGet, supportSessionStorageSet, supportSetBackgroundColor, supportSetBottomBarColor, supportSetEmojiStatus, supportSetHeaderColor, supportSetupBackButton, supportSetupClosingBehavior, supportSetupFullScreen, supportSetupMainButton, supportSetupOrientation, supportSetupSettingsButton, supportSetupSwipeBehavior, supportShareMessage, supportShareToStory, supportSwitchInlineQuery, supportTriggerHapticFeedback };
|
package/solid/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e=require("solid-js"),t=require("solid-js/store");const s="web",o="phone",r="desktop",a=()=>{const e=window.location.hash.slice(1),t=new URLSearchParams(e).get("tgWebAppPlatform")??"ios";return["android","ios"].includes(t)?o:["tdesktop","macos"].includes(t)?r:s},n="not_supported",p=(e,t)=>{const s=new URLSearchParams(window.location.hash.slice(1)).get("tgWebAppVersion");return Number(s?.replace(".",""))>=Number(String(e)?.replace(".",""))&&-1!==t.indexOf(a())},i=()=>Math.random().toString(36).substring(3,9),d=e=>{var t;if(t=/^\s*#([0-9a-f]{6})\s*$/i.exec(e+=""))return"#"+t[1].toLowerCase();if(t=/^\s*#([0-9a-f])([0-9a-f])([0-9a-f])\s*$/i.exec(e))return("#"+t[1]+t[1]+t[2]+t[2]+t[3]+t[3]).toLowerCase();if(t=/^\s*rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*(\d+\.{0,1}\d*))?\)\s*$/.exec(e)){var s=parseInt(t[1]),o=parseInt(t[2]),r=parseInt(t[3]);return"#"+((s<16?"0":"")+s.toString(16))+((o<16?"0":"")+o.toString(16))+((r<16?"0":"")+r.toString(16))}return!1},u=e=>{const t=window.location.hash.slice(1),s=new URLSearchParams(t),o=JSON.parse(s.get("tgWebAppThemeParams")??""),r=e||o;for(var a of Object.keys(r)){var n=d(r[a]);"string"==typeof n&&(r[a]=n)}return"#1c1c1d"==r?.bg_color&&r?.bg_color==r?.secondary_bg_color&&(r.secondary_bg_color="#2c2c2e"),r},c=e=>_()?(qt(Ee,e),{status:!0}):(ft(Ee,1),{status:n}),_=()=>p(0,[s,r,o]),l=e=>x()?(qt(Ce,e),{status:!0}):(ft(Ce,1),{status:n}),x=()=>p(6.4,[o]),g=e=>m()?(qt(Te,e),{status:!0}):(ft(Te,1),{status:n}),m=()=>p(0,[s,r,o]),h=e=>S()?(qt(Ae,e),{status:!0}):(ft(Ae,1),{status:n}),S=()=>p(0,[o]),v=e=>b()?(qt(Me,e),{status:!0}):(ft(Me,1),{status:n}),b=()=>p(0,[s]),w=()=>f()?(qt(Me),{status:!0}):(ft(Me,1),{status:n}),f=()=>p(0,[s]),y=async e=>q()?(void 0===e.req_id&&(e.req_id=i()),qt(qe,e),new Promise(((t,s)=>{const o=s=>{s.req_id===e.req_id&&(t({status:!0,data:s}),Vt(Bt,o))};Ut(Bt,o)}))):(ft(qe,1),{status:n}),q=()=>p(6.9,[s,r,o]),R=e=>B()?(qt(Ie,e),{status:!0}):(ft(Ie,1),{status:n}),B=()=>p(6.1,[s,r,o]),k=e=>E()?(qt(Oe,e),{status:!0}):(ft(Oe,1),{status:n}),E=()=>p(6.4,[s,r,o]),C=async e=>T()?(e.title.length>64&&ft(Fe,3),e.message.length<1&&ft(Fe,4),e.message.length>256&&ft(Fe,5),e.buttons.length<1&&ft(Fe,6),e.buttons.length>3&&ft(Fe,7),void 0!==e.buttons.find((e=>e.text?.match(/^(ok|close|cancel)$/g)))&&ft(Fe,8),qt(Fe,e),new Promise(((t,s)=>{const o=s=>{t({status:!!e.buttons.find((e=>e.id===s?.button_id)),data:s}),Vt(Et,o)};Ut(Et,o)}))):(ft(Fe,1),{status:n}),T=()=>p(6.2,[s,r,o]),A=async e=>M()?(qt(Re,e),new Promise(((t,s)=>{$t(Ct,(s=>{e.is_close&&l(),t({status:!0,data:s})})),$t(Tt,(()=>{t({status:"closed"})}))}))):(ft(Re,1),{status:n}),M=()=>p(6.4,[o]),P=e=>{const t=function(e){try{return new URL(e)}catch(t){try{return new URL(e,"https://t.me")}catch(t){return e.startsWith("/")||(e="/"+e),new URL(e,"https://t.me")}}}(e.path_full);return e.path_full=t.pathname=t.search,I()?(qt(We,e),{status:!0}):(ft(We,1),{status:n})},I=()=>p(7,[s,r,o]);const O=async e=>F()?(e||(e={req_id:void 0}),void 0===e.req_id&&(e.req_id=i()),qt(Be,e),new Promise(((t,s)=>{const o=s=>{s.req_id===e?.req_id&&(t({status:!0,data:s}),Vt(Rt,o))};Ut(Rt,o)}))):(ft(Be,1),{status:n}),F=()=>p(6.4,[s,r,o]),W=e=>L()?(qt(Le,e),{status:!0}):(ft(Le,1),{status:n}),L=()=>p(6.9,[s,r,o]),D=async()=>j()?(qt(ke),new Promise(((e,t)=>{$t(kt,(t=>{"sent"===t.status&&e({status:!0}),e({status:!1})}))}))):(ft(ke,1),{status:n}),j=()=>p(6.9,[s,r,o]),H=e=>G()?(qt(De,e),{status:!0}):(ft(De,1),{status:n}),G=()=>p(0,[s,r,o]),Q=e=>N()?(qt(je,e),{status:!0}):(ft(je,1),{status:n}),N=()=>p(0,[s,r,o]),U=()=>new Promise(((e,t)=>{if(!V())return ft(He,1),void e({status:n});const s=t=>{e({status:"allowed"===t.status}),Vt(Pt,s)};Ut(Pt,s),qt(He)})),V=()=>p(6.9,[s,r,o]),$=e=>J()?(qt(Ge,e),{status:!0}):(ft(Ge,1),{status:n}),J=()=>p(6.1,[s,r,o]),z=e=>K()?(qt(Qe,e),{status:!0}):(ft(Qe,1),{status:n}),K=()=>p(6.1,[s,r,o]),X=e=>Y()?(qt(Ne,{color:e?.color||e?.color_key}),{status:!0}):(ft(Ne,1),{status:n}),Y=()=>p(7.1,[s,r,o]),Z=e=>ee()?(qt(Ue,e),{status:!0}):(ft(Ue,1),{status:n}),ee=()=>p(6.1,[s,r,o]),te=e=>se()?(qt(Ve,e),{status:!0}):(ft(Ve,1),{status:n}),se=()=>p(6.2,[s,r,o]),oe=e=>re()?(qt($e,e),{status:!0}):(ft($e,1),{status:n}),re=()=>p(0,[s,r,o]),ae=e=>ne()?(qt(Je,e),{status:!0}):(ft(Je,1),{status:n}),ne=()=>p(6.1,[s,r,o]),pe=e=>ie()?(e.query.length>256&&ft(ze,9),qt(ze,e),{status:!0}):(ft(ze,1),{status:n}),ie=()=>p(6.7,[s,r,o]),de=e=>ue()?(qt(Ke,e),{status:!0}):(ft(Ke,1),{status:n}),ue=()=>p(6.1,[o]),ce=e=>_e()?(qt(Xe,e),{status:!0}):(ft(Xe,1),{status:n}),_e=()=>p(7.7,[s,r,o]),le=()=>p(7.8,[s,r,o]),xe=()=>p(8,[r,o]),ge=()=>p(8,[r,o]),me=()=>p(8,[s,r,o]),he=()=>p(8,[s,r,o]),Se=()=>p(8,[s,r,o]),ve=()=>p(8,[s,r,o]),be=()=>p(8,[s,r,o]),we=()=>p(8,[s,r,o]),fe=()=>p(8,[s,r,o]),ye=()=>p(8,[s,r,o]),qe="web_app_invoke_custom_method",Re="web_app_open_scan_qr_popup",Be="web_app_read_text_from_clipboard",ke="web_app_request_phone",Ee="web_app_close",Ce="web_app_close_scan_qr_popup",Te="web_app_data_send",Ae="web_app_expand",Me="iframe_ready",Pe="iframe_will_reload",Ie="web_app_open_invoice",Oe="web_app_open_link",Fe="web_app_open_popup",We="web_app_open_tg_link",Le="web_app_ready",De="web_app_request_theme",je="web_app_request_viewport",He="web_app_request_write_access",Ge="web_app_set_background_color",Qe="web_app_set_header_color",Ne="web_app_set_bottom_bar_color",Ue="web_app_setup_back_button",Ve="web_app_setup_closing_behavior",$e="web_app_setup_main_button",Je="web_app_setup_settings_button",ze="web_app_switch_inline_query",Ke="web_app_trigger_haptic_feedback",Xe="web_app_setup_swipe_behavior",Ye="web_app_share_to_story",Ze="web_app_request_safe_area",et="web_app_request_content_safe_area",tt="web_app_request_fullscreen",st="web_app_exit_fullscreen",ot="web_app_toggle_orientation_lock",rt="web_app_add_to_home_screen",at="web_app_check_home_screen",nt="web_app_send_prepared_message",pt="web_app_set_emoji_status",it="web_app_request_emoji_status_access",dt="web_app_request_file_download",ut="web_app_biometry_get_info",ct="web_app_biometry_open_settings",_t="web_app_biometry_request_access",lt="web_app_biometry_request_auth",xt="web_app_biometry_update_token";var gt=(e=>(e[e.InvokeCustomMethod=qe]="InvokeCustomMethod",e[e.OpenScanQrPopup=Re]="OpenScanQrPopup",e[e.ReadTextFromClipboard=Be]="ReadTextFromClipboard",e[e.RequestPhone=ke]="RequestPhone",e[e.Close=Ee]="Close",e[e.CloseScanQrPopup=Ce]="CloseScanQrPopup",e[e.DataSend=Te]="DataSend",e[e.Expand=Ae]="Expand",e[e.IframeReady=Me]="IframeReady",e[e.IframeWillReload=Pe]="IframeWillReload",e[e.OpenInvoice=Ie]="OpenInvoice",e[e.OpenLink=Oe]="OpenLink",e[e.OpenPopup=Fe]="OpenPopup",e[e.OpenTgLink=We]="OpenTgLink",e[e.Ready=Le]="Ready",e[e.RequestTheme=De]="RequestTheme",e[e.RequestViewport=je]="RequestViewport",e[e.RequestWriteAccess=He]="RequestWriteAccess",e[e.SetBackgroundColor=Ge]="SetBackgroundColor",e[e.SetHeaderColor=Qe]="SetHeaderColor",e[e.SetBottomBarColor=Ne]="SetBottomBarColor",e[e.SetupBackButton=Ue]="SetupBackButton",e[e.SetupClosingBehavior=Ve]="SetupClosingBehavior",e[e.SetupMainButton=$e]="SetupMainButton",e[e.SetupSettingsButton=Je]="SetupSettingsButton",e[e.SwitchInlineQuery=ze]="SwitchInlineQuery",e[e.TriggerHapticFeedback=Ke]="TriggerHapticFeedback",e[e.SetupSwipeBehavior=Xe]="SetupSwipeBehavior",e[e.ShareToStory=Ye]="ShareToStory",e[e.RequestSafeArea=Ze]="RequestSafeArea",e[e.RequestContentSafeArea=et]="RequestContentSafeArea",e[e.RequestFullscreen=tt]="RequestFullscreen",e[e.ExitFullscreen=st]="ExitFullscreen",e[e.ToggleOrientationLock=ot]="ToggleOrientationLock",e[e.AddToHomeScreen=rt]="AddToHomeScreen",e[e.CheckHomeScreen=at]="CheckHomeScreen",e[e.SendPreparedMessage=nt]="SendPreparedMessage",e[e.SetEmojiStatus=pt]="SetEmojiStatus",e[e.RequestEmojiStatusAccess=it]="RequestEmojiStatusAccess",e[e.RequestFileDownload=dt]="RequestFileDownload",e))(gt||{});const[mt,ht]=t.createStore({isInited:!1,isBiometricAvailable:!1,isAccessGranted:!1,isAccessRequested:!1,isBiometricTokenSaved:!1,biometricType:"unknown",deviceId:""}),St={isInited:mt.isInited,isBiometricAvailable:mt.isBiometricAvailable,isAccessGranted:mt.isAccessGranted,isAccessRequested:mt.isAccessRequested,isBiometricTokenSaved:mt.isBiometricTokenSaved,biometricType:mt.biometricType,deviceId:mt.deviceId,init:()=>new Promise(((e,t)=>{if(!vt())return ft(ut,1),void e({status:n,data:void 0});const s=t=>{bt(t),e({status:!0,data:mt}),Vt(Ht,s)};Ut(Ht,s),qt(ut)})),requestAccess:e=>new Promise(((t,s)=>{if(!vt())return ft(_t,1),void t({status:n,data:void 0});if(e.reason&&e.reason.length>128)return console.error(`[${_t}] Biometric reason is too long`,e.reason),void t({status:!1,data:void 0});const o=e=>{bt(e),t({status:!0,data:mt}),Vt(Ht,o)};Ut(Ht,o),qt(_t,e)})),authenticate:e=>new Promise(((t,s)=>{if(!vt())return ft(lt,1),void t({status:n,data:void 0});if(!mt.isBiometricAvailable)return console.error("[Telegram.WebApp] Biometrics is not available on this device."),void t({status:!1,data:void 0});if(!mt.isAccessGranted)return console.error("[Telegram.WebApp] Biometric access was not granted by the user."),void t({status:!1,data:void 0});const o=e=>{t({status:!0,data:e}),Vt(jt,o)};Ut(jt,o),qt(lt,e)})),updateToken:e=>new Promise(((t,s)=>{if(!vt())return ft(xt,1),void t({status:n,data:void 0});if(!mt.isBiometricAvailable)return console.error("[Telegram.WebApp] Biometrics is not available on this device."),void t({status:!1,data:void 0});if(!mt.isAccessGranted)return console.error("[Telegram.WebApp] Biometric access was not granted by the user."),void t({status:!1,data:void 0});const o=e=>{t({status:!0,data:e}),Vt(Gt,o)};Ut(Gt,o),qt(xt,e)})),openSettings:e=>vt()?mt.isBiometricAvailable?mt.isAccessRequested?mt.isAccessGranted?(console.warn("[Telegram.WebApp] Biometric access was granted by the user, no need to go to settings."),{status:!1}):(qt(ct,e),{status:!0}):(console.error("[Telegram.WebApp] Biometric access was not granted by the user."),{status:!1}):(console.error("[Telegram.WebApp] Biometrics is not available on this device."),{status:!1}):(ft(ct,1),{status:n})},vt=()=>p(7.2,[r,o,s]),bt=e=>{ht(t.produce((t=>(e.available?(t.isBiometricAvailable=!0,t.biometricType=e.type||"",e.access_requested?(t.isAccessRequested=!0,t.isAccessGranted=!!e.access_granted,t.isBiometricTokenSaved=!!e.token_saved):(t.isAccessRequested=!1,t.isAccessGranted=!1,t.isBiometricTokenSaved=!1)):(t.isBiometricAvailable=!1,t.biometricType="unknown",t.isAccessRequested=!1,t.isAccessGranted=!1,t.isBiometricTokenSaved=!1),t.deviceId=e.device_id||"",t.isInited=!0,t))))},wt=e=>{ht(t.produce((t=>(t.isBiometricAvailable&&t.isAccessRequested&&("updated"===e.status?t.isBiometricTokenSaved=!0:"removed"===e.status&&(t.isBiometricTokenSaved=!1)),t))))};e.onMount((()=>{Ut(Ht,bt),Ut(Gt,wt),e.onCleanup((()=>{Vt(Ht,bt),Vt(Gt,wt)}))}));const ft=(e,t)=>{"development"===process.env.NODE_ENV&&console.error(`[@apiteam/twa-bridge](${e}) = ${t}`)},yt=()=>{const e=window.location.hash.slice(1),t=new URLSearchParams(e).get("tgWebAppData");if(!t)return void ft("getInitData",2);const s=new URLSearchParams(t);let o={};return s.forEach(((e,t)=>{if(o[t]=e,void 0!==t.match(/^(chat|receiver|user)$/g))try{o[t]=JSON.parse(e)}catch{}})),o},qt=(e,t)=>{if(window.TelegramWebviewProxy)window.TelegramWebviewProxy.postEvent(e,JSON.stringify(t));else if(window.external&&"notify"in window.external)window.external.notify(JSON.stringify({eventType:e,eventData:t}));else try{window.parent.postMessage(JSON.stringify({eventType:e,eventData:t}),"*")}catch(e){ft("postMessage Iframe",10)}},Rt="clipboard_text_received",Bt="custom_method_invoked",kt="phone_requested",Et="popup_closed",Ct="qr_text_received",Tt="scan_qr_popup_closed",At="theme_changed",Mt="viewport_changed",Pt="write_access_requested",It="prepared_message_sent",Ot="prepared_message_failed",Ft="emoji_status_set",Wt="emoji_status_failed",Lt="emoji_status_access_requested",Dt="file_download_requested",jt="biometry_auth_requested",Ht="biometry_info_received",Gt="biometry_token_updated",Qt="home_screen_checked",Nt=((e=new Map)=>({once:(t,s,o=e.get(t),r=e=>{s(e),o&&o.splice(o.indexOf(s)>>>0,1)})=>o?o.push(r):e.set(t,[r]),on:(t,s,o=e.get(t))=>o?o.push(s):e.set(t,[s]),off:(t,s,o=e.get(t))=>o&&s?o.splice(o.indexOf(s)>>>0,1):e.set(t,[]),emit:(t,s,o=e.get(t)||[])=>{for(const e of o)e(s)}}))();(()=>{function e(e,t){e===At&&(t.theme_params=u(t.theme_params)),Nt.emit(e,t),Nt.emit("*",{name:e,data:t})}window.TelegramGameProxy_receiveEvent=e,window.Telegram={WebView:{receiveEvent:e}},window.TelegramGameProxy={receiveEvent:e}})();const Ut=(e,t)=>{Nt.on(e,t)},Vt=(e,t)=>{Nt.off(e,t)},$t=(e,t)=>{Nt.once(e,t)};var Jt=Object.freeze({__proto__:null,off:Vt,on:Ut,once:$t});const zt=e.createContext({viewport:void 0,theme:void 0,init:void 0});exports.BiometricManager=St,exports.ContextTwa=zt,exports.EventAccelerometerChanged="accelerometer_changed",exports.EventAccelerometerFailed="accelerometer_failed",exports.EventAccelerometerStarted="accelerometer_started",exports.EventAccelerometerStopped="accelerometer_stopped",exports.EventBackButtonPressed="back_button_pressed",exports.EventBiometryAuthRequested=jt,exports.EventBiometryInfoReceived=Ht,exports.EventBiometryTokenUpdated=Gt,exports.EventClipboardTextReceived=Rt,exports.EventContentSafeAreaChanged="content_safe_area_changed",exports.EventCustomMethodInvoked=Bt,exports.EventDeviceOrientationChanged="device_orientation_changed",exports.EventDeviceOrientationFailed="device_orientation_failed",exports.EventDeviceOrientationStarted="device_orientation_started",exports.EventDeviceOrientationStopped="device_orientation_stopped",exports.EventEmojiStatusAccessRequested=Lt,exports.EventEmojiStatusFailed=Wt,exports.EventEmojiStatusSet=Ft,exports.EventFileDownloadRequested=Dt,exports.EventFullscreenChanged="fullscreen_changed",exports.EventFullscreenFailed="fullscreen_failed",exports.EventGyroscopeChanged="gyroscope_changed",exports.EventGyroscopeFailed="gyroscope_failed",exports.EventGyroscopeStarted="gyroscope_started",exports.EventGyroscopeStopped="gyroscope_stopped",exports.EventHomeScreenAdded="home_screen_added",exports.EventHomeScreenChecked=Qt,exports.EventHomeScreenFailed="home_screen_failed",exports.EventInvoiceClosed="invoice_closed",exports.EventLocationChecked="location_checked",exports.EventLocationRequested="location_requested",exports.EventMainButtonPressed="main_button_pressed",exports.EventPhoneRequested=kt,exports.EventPopupClosed=Et,exports.EventPreparedMessageFailed=Ot,exports.EventPreparedMessageSent=It,exports.EventQrTextReceived=Ct,exports.EventReloadIframe="reload_iframe",exports.EventSafeAreaChanged="safe_area_changed",exports.EventScanQrPopupClosed=Tt,exports.EventSecondaryButtonPressed="secondary_button_pressed",exports.EventSetCustomStyle="set_custom_style",exports.EventSettingsButtonPressed="settings_button_pressed",exports.EventThemeChanged=At,exports.EventViewportChanged=Mt,exports.EventVisibilityChanged="visibility_changed",exports.EventWriteAccessRequested=Pt,exports.Method=gt,exports.MethodAddToHomeScreen=rt,exports.MethodCheckHomeScreen=at,exports.MethodClose=Ee,exports.MethodCloseScanQrPopup=Ce,exports.MethodDataSend=Te,exports.MethodExitFullscreen=st,exports.MethodExpand=Ae,exports.MethodIframeReady=Me,exports.MethodIframeWillReload=Pe,exports.MethodInvokeCustomMethod=qe,exports.MethodOpenInvoice=Ie,exports.MethodOpenLink=Oe,exports.MethodOpenPopup=Fe,exports.MethodOpenScanQrPopup=Re,exports.MethodOpenTgLink=We,exports.MethodReadTextFromClipboard=Be,exports.MethodReady=Le,exports.MethodRequestContentSafeArea=et,exports.MethodRequestEmojiStatusAccess=it,exports.MethodRequestFileDownload=dt,exports.MethodRequestFullscreen=tt,exports.MethodRequestPhone=ke,exports.MethodRequestSafeArea=Ze,exports.MethodRequestTheme=De,exports.MethodRequestViewport=je,exports.MethodRequestWriteAccess=He,exports.MethodSendPreparedMessage=nt,exports.MethodSetBackgroundColor=Ge,exports.MethodSetBottomBarColor=Ne,exports.MethodSetEmojiStatus=pt,exports.MethodSetHeaderColor=Qe,exports.MethodSetupBackButton=Ue,exports.MethodSetupClosingBehavior=Ve,exports.MethodSetupMainButton=$e,exports.MethodSetupSettingsButton=Je,exports.MethodSetupSwipeBehavior=Xe,exports.MethodShareToStory=Ye,exports.MethodSwitchInlineQuery=ze,exports.MethodToggleOrientationLock=ot,exports.MethodTriggerHapticFeedback=Ke,exports.NOT_SUPPORTED=n,exports.ProviderTWA=s=>{const[o,r]=t.createStore({viewport:void 0,theme:void 0,init:void 0});return e.createEffect((()=>{const t=()=>{r("init",yt())};t();const s=e=>{t(),r("viewport",e)};Ut(Mt,s),Q();const o=e=>{t(),r("theme",e)};return Ut(At,o),Q(),e.onCleanup((()=>{Vt(Mt,s),Vt(At,o)})),()=>{Vt(Mt,s),Vt(At,o)}})),zt.Provider({value:o,children:s.children})},exports.TG_DESKTOP=r,exports.TG_PHONE=o,exports.TG_WEB=s,exports.bridgeAddToHomeScreen=()=>ge()?(qt(rt),{status:!0}):(ft(rt,1),{status:n}),exports.bridgeCheckHomeScreen=async e=>new Promise(((t,s)=>{if(!xe())return ft(at,1),void t({status:n,data:void 0});const o=e=>{e.status=e.status||"unknown",t({status:!0,data:e}),Vt(Qt,o)};Ut(Qt,o),qt(at,e)})),exports.bridgeClose=c,exports.bridgeCloseScanQrPopup=l,exports.bridgeDataSend=g,exports.bridgeDownloadFile=async e=>ye()?new Promise(((t,s)=>{$t(Dt,(function(e){t({status:"downloading"===e.status})})),qt(dt,e)})):(ft(dt,1),{status:n}),exports.bridgeExpand=h,exports.bridgeGetInitData=yt,exports.bridgeGetThemeParams=u,exports.bridgeIframeReady=v,exports.bridgeIframeWillReload=w,exports.bridgeInvokeCustomMethod=y,exports.bridgeOpenInvoice=R,exports.bridgeOpenLink=k,exports.bridgeOpenPopup=C,exports.bridgeOpenScanQrPopup=A,exports.bridgeOpenTgLink=P,exports.bridgeReadTextFromClipboard=O,exports.bridgeReady=W,exports.bridgeRequestContentSafeAreaInset=()=>he()?(qt(et),{status:!0}):(ft(et,1),{status:n}),exports.bridgeRequestEmojiStatus=async e=>be()?new Promise(((t,s)=>{$t(Lt,(function(e){t({status:"allowed"===e.status})})),qt(it,e)})):(ft(it,1),{status:n}),exports.bridgeRequestPhone=D,exports.bridgeRequestSafeAreaInset=()=>me()?(qt(Ze),{status:!0}):(ft(Ze,1),{status:n}),exports.bridgeRequestTheme=H,exports.bridgeRequestViewport=Q,exports.bridgeRequestWriteAccess=U,exports.bridgeSend=qt,exports.bridgeSessionStorageGet=({key:e})=>{try{return{is_json:!0,value:JSON.parse(window.sessionStorage.getItem("__telegram__"+e)??""),status:!0}}catch(t){return{is_json:!1,value:window.sessionStorage.getItem("__telegram__"+e)??"",status:!0}}},exports.bridgeSessionStorageSet=({key:e,value:t})=>{try{return window.sessionStorage.setItem("__telegram__"+e,JSON.stringify(t)),{status:!0}}catch(s){return window.sessionStorage.setItem("__telegram__"+e,t),{status:!0}}},exports.bridgeSetBackgroundColor=$,exports.bridgeSetBottomBarColor=X,exports.bridgeSetEmojiStatus=async e=>we()?new Promise(((t,s)=>{$t(Ft,(()=>t({status:!0}))),$t(Wt,(()=>t({status:!1}))),qt(pt,e)})):(ft(pt,1),{status:n}),exports.bridgeSetHeaderColor=z,exports.bridgeSetupBackButton=Z,exports.bridgeSetupClosingBehavior=te,exports.bridgeSetupFullScreen=e=>{const t=e?.is_full||!1;return Se()?(qt(t?tt:st),{status:!0}):(ft(t?tt:st,1),{status:n})},exports.bridgeSetupMainButton=oe,exports.bridgeSetupOrientation=e=>ve()?(qt(ot,e),{status:!0}):(ft(ot,1),{status:n}),exports.bridgeSetupSettingsButton=ae,exports.bridgeSetupSwipeBehavior=ce,exports.bridgeShareMessage=async e=>fe()?new Promise(((t,s)=>{$t(It,(()=>t({status:!0}))),$t(Ot,(()=>t({status:!1}))),qt(nt,e)})):(ft(nt,1),{status:n}),exports.bridgeShareToStory=e=>le()?e?.text&&e?.text.length>2048?(console.warn(`[@apiteam/twa-bridge](${Ye}) | Text is too long`),{status:!1,error_id:1}):e?.widget_link?.name&&e?.widget_link.name.length>48?(console.warn(`[@apiteam/twa-bridge](${Ye}) | Link name is too long`),{status:!1,error_id:2}):(qt(Ye,e),{status:!0}):(ft(Ye,1),{status:n}),exports.bridgeSwitchInlineQuery=pe,exports.bridgeTriggerHapticFeedback=de,exports.createIsViewportChanged=()=>{const[t,s]=e.createSignal({height:0,is_expanded:!1,is_state_stable:!1}),o=e=>s(e);return e.onMount((()=>{Ut(Mt,o),qt(je)})),e.onCleanup((()=>{Vt(Mt,o)})),t},exports.debug=ft,exports.getAppData=()=>{const e=window.location.hash.slice(1);return new URLSearchParams(e).get("tgWebAppData")},exports.getPlatform=a,exports.listener=Jt,exports.sender=qt,exports.supportAddToHomeScreen=ge,exports.supportBiometricManager=vt,exports.supportCheckHomeScreen=xe,exports.supportClose=_,exports.supportCloseScanQrPopup=x,exports.supportDataSend=m,exports.supportDownloadFile=ye,exports.supportExpand=S,exports.supportIframeReady=b,exports.supportIframeWillReload=f,exports.supportInvokeCustomMethod=q,exports.supportOpenInvoice=B,exports.supportOpenLink=E,exports.supportOpenPopup=T,exports.supportOpenScanQrPopup=M,exports.supportOpenTgLink=I,exports.supportReadTextFromClipboard=F,exports.supportReady=L,exports.supportRequestContentSafeAreaInset=he,exports.supportRequestEmojiStatus=be,exports.supportRequestPhone=j,exports.supportRequestSafeAreaInset=me,exports.supportRequestTheme=G,exports.supportRequestViewport=N,exports.supportRequestWriteAccess=V,exports.supportSessionStorageGet=()=>!0,exports.supportSessionStorageSet=()=>!0,exports.supportSetBackgroundColor=J,exports.supportSetBottomBarColor=Y,exports.supportSetEmojiStatus=we,exports.supportSetHeaderColor=K,exports.supportSetupBackButton=ee,exports.supportSetupClosingBehavior=se,exports.supportSetupFullScreen=Se,exports.supportSetupMainButton=re,exports.supportSetupOrientation=ve,exports.supportSetupSettingsButton=ne,exports.supportSetupSwipeBehavior=_e,exports.supportShareMessage=fe,exports.supportShareToStory=le,exports.supportSwitchInlineQuery=ie,exports.supportTriggerHapticFeedback=ue;
|
|
1
|
+
"use strict";var e=require("solid-js"),t=require("solid-js/store");const s=(e,t)=>{"development"===process.env.NODE_ENV&&console.error(`[@apiteam/twa-bridge](${e}) = ${t}`)},o=(e,t)=>{if(window.TelegramWebviewProxy)window.TelegramWebviewProxy.postEvent(e,JSON.stringify(t));else if(window.external&&"notify"in window.external)window.external.notify(JSON.stringify({eventType:e,eventData:t}));else try{window.parent.postMessage(JSON.stringify({eventType:e,eventData:t}),"*")}catch(e){s("postMessage Iframe",10)}},r="web_app_invoke_custom_method",a="web_app_open_scan_qr_popup",n="web_app_read_text_from_clipboard",p="web_app_request_phone",i="web_app_close",d="web_app_close_scan_qr_popup",u="web_app_data_send",c="web_app_expand",_="iframe_ready",l="iframe_will_reload",x="web_app_open_invoice",g="web_app_open_link",m="web_app_open_popup",h="web_app_open_tg_link",S="web_app_ready",v="web_app_request_theme",b="web_app_request_viewport",w="web_app_request_write_access",f="web_app_set_background_color",y="web_app_set_header_color",q="web_app_set_bottom_bar_color",R="web_app_setup_back_button",B="web_app_setup_closing_behavior",k="web_app_setup_main_button",E="web_app_setup_settings_button",C="web_app_switch_inline_query",T="web_app_trigger_haptic_feedback",A="web_app_setup_swipe_behavior",M="web_app_share_to_story",P="web_app_request_safe_area",I="web_app_request_content_safe_area",O="web_app_request_fullscreen",F="web_app_exit_fullscreen",W="web_app_toggle_orientation_lock",L="web_app_add_to_home_screen",D="web_app_check_home_screen",j="web_app_send_prepared_message",H="web_app_set_emoji_status",G="web_app_request_emoji_status_access",Q="web_app_request_file_download",N="web_app_biometry_get_info",U="web_app_biometry_open_settings",V="web_app_biometry_request_access",$="web_app_biometry_request_auth",J="web_app_biometry_update_token";var z=(e=>(e[e.InvokeCustomMethod=r]="InvokeCustomMethod",e[e.OpenScanQrPopup=a]="OpenScanQrPopup",e[e.ReadTextFromClipboard=n]="ReadTextFromClipboard",e[e.RequestPhone=p]="RequestPhone",e[e.Close=i]="Close",e[e.CloseScanQrPopup=d]="CloseScanQrPopup",e[e.DataSend=u]="DataSend",e[e.Expand=c]="Expand",e[e.IframeReady=_]="IframeReady",e[e.IframeWillReload=l]="IframeWillReload",e[e.OpenInvoice=x]="OpenInvoice",e[e.OpenLink=g]="OpenLink",e[e.OpenPopup=m]="OpenPopup",e[e.OpenTgLink=h]="OpenTgLink",e[e.Ready=S]="Ready",e[e.RequestTheme=v]="RequestTheme",e[e.RequestViewport=b]="RequestViewport",e[e.RequestWriteAccess=w]="RequestWriteAccess",e[e.SetBackgroundColor=f]="SetBackgroundColor",e[e.SetHeaderColor=y]="SetHeaderColor",e[e.SetBottomBarColor=q]="SetBottomBarColor",e[e.SetupBackButton=R]="SetupBackButton",e[e.SetupClosingBehavior=B]="SetupClosingBehavior",e[e.SetupMainButton=k]="SetupMainButton",e[e.SetupSettingsButton=E]="SetupSettingsButton",e[e.SwitchInlineQuery=C]="SwitchInlineQuery",e[e.TriggerHapticFeedback=T]="TriggerHapticFeedback",e[e.SetupSwipeBehavior=A]="SetupSwipeBehavior",e[e.ShareToStory=M]="ShareToStory",e[e.RequestSafeArea=P]="RequestSafeArea",e[e.RequestContentSafeArea=I]="RequestContentSafeArea",e[e.RequestFullscreen=O]="RequestFullscreen",e[e.ExitFullscreen=F]="ExitFullscreen",e[e.ToggleOrientationLock=W]="ToggleOrientationLock",e[e.AddToHomeScreen=L]="AddToHomeScreen",e[e.CheckHomeScreen=D]="CheckHomeScreen",e[e.SendPreparedMessage=j]="SendPreparedMessage",e[e.SetEmojiStatus=H]="SetEmojiStatus",e[e.RequestEmojiStatusAccess=G]="RequestEmojiStatusAccess",e[e.RequestFileDownload=Q]="RequestFileDownload",e))(z||{});const K="clipboard_text_received",X="custom_method_invoked",Y="phone_requested",Z="popup_closed",ee="qr_text_received",te="scan_qr_popup_closed",se="theme_changed",oe="viewport_changed",re="write_access_requested",ae="prepared_message_sent",ne="prepared_message_failed",pe="emoji_status_set",ie="emoji_status_failed",de="emoji_status_access_requested",ue="file_download_requested",ce="biometry_auth_requested",_e="biometry_info_received",le="biometry_token_updated",xe="home_screen_checked",ge="web",me="phone",he="desktop",Se=()=>{const e=window.location.hash.slice(1),t=new URLSearchParams(e).get("tgWebAppPlatform")??"ios";return["android","ios"].includes(t)?me:["tdesktop","macos"].includes(t)?he:ge},ve="not_supported",be=(e,t)=>{const s=new URLSearchParams(window.location.hash.slice(1)).get("tgWebAppVersion");return Number(s?.replace(".",""))>=Number(String(e)?.replace(".",""))&&-1!==t.indexOf(Se())},we=()=>Math.random().toString(36).substring(3,9),fe=e=>{var t;if(t=/^\s*#([0-9a-f]{6})\s*$/i.exec(e+=""))return"#"+t[1].toLowerCase();if(t=/^\s*#([0-9a-f])([0-9a-f])([0-9a-f])\s*$/i.exec(e))return("#"+t[1]+t[1]+t[2]+t[2]+t[3]+t[3]).toLowerCase();if(t=/^\s*rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*(\d+\.{0,1}\d*))?\)\s*$/.exec(e)){var s=parseInt(t[1]),o=parseInt(t[2]),r=parseInt(t[3]);return"#"+((s<16?"0":"")+s.toString(16))+((o<16?"0":"")+o.toString(16))+((r<16?"0":"")+r.toString(16))}return!1},ye=e=>{const t=window.location.hash.slice(1),s=new URLSearchParams(t),o=JSON.parse(s.get("tgWebAppThemeParams")??""),r=e||o;for(var a of Object.keys(r)){var n=fe(r[a]);"string"==typeof n&&(r[a]=n)}return"#1c1c1d"==r?.bg_color&&r?.bg_color==r?.secondary_bg_color&&(r.secondary_bg_color="#2c2c2e"),r},qe=((e=new Map)=>({once:(t,s,o=e.get(t),r=e=>{s(e),o&&o.splice(o.indexOf(s)>>>0,1)})=>o?o.push(r):e.set(t,[r]),on:(t,s,o=e.get(t))=>o?o.push(s):e.set(t,[s]),off:(t,s,o=e.get(t))=>o&&s?o.splice(o.indexOf(s)>>>0,1):e.set(t,[]),emit:(t,s,o=e.get(t)||[])=>{for(const e of o)e(s)}}))();(()=>{function e(e,t){e===se&&(t.theme_params=ye(t.theme_params)),qe.emit(e,t),qe.emit("*",{name:e,data:t})}window.TelegramGameProxy_receiveEvent=e,window.Telegram={WebView:{receiveEvent:e}},window.TelegramGameProxy={receiveEvent:e}})();const Re=(e,t)=>{qe.on(e,t)},Be=(e,t)=>{qe.off(e,t)},ke=(e,t)=>{qe.once(e,t)};var Ee=Object.freeze({__proto__:null,off:Be,on:Re,once:ke});const Ce=e=>Te()?(o(i,e),{status:!0}):(s(i,1),{status:ve}),Te=()=>be(0,[ge,he,me]),Ae=e=>Me()?(o(d,e),{status:!0}):(s(d,1),{status:ve}),Me=()=>be(6.4,[me]),Pe=e=>Ie()?(o(u,e),{status:!0}):(s(u,1),{status:ve}),Ie=()=>be(0,[ge,he,me]),Oe=e=>Fe()?(o(c,e),{status:!0}):(s(c,1),{status:ve}),Fe=()=>be(0,[me]),We=e=>Le()?(o(_,e),{status:!0}):(s(_,1),{status:ve}),Le=()=>be(0,[ge]),De=()=>je()?(o(_),{status:!0}):(s(_,1),{status:ve}),je=()=>be(0,[ge]),He=async e=>Ge()?(void 0===e.req_id&&(e.req_id=we()),o(r,e),new Promise(((t,s)=>{const o=s=>{s.req_id===e.req_id&&(t({status:!0,data:s}),Be(X,o))};Re(X,o)}))):(s(r,1),{status:ve}),Ge=()=>be(6.9,[ge,he,me]),Qe=e=>Ne()?(o(x,e),{status:!0}):(s(x,1),{status:ve}),Ne=()=>be(6.1,[ge,he,me]),Ue=e=>Ve()?(o(g,e),{status:!0}):(s(g,1),{status:ve}),Ve=()=>be(6.4,[ge,he,me]),$e=async e=>Je()?(e.title.length>64&&s(m,3),e.message.length<1&&s(m,4),e.message.length>256&&s(m,5),e.buttons.length<1&&s(m,6),e.buttons.length>3&&s(m,7),void 0!==e.buttons.find((e=>e.text?.match(/^(ok|close|cancel)$/g)))&&s(m,8),o(m,e),new Promise(((t,s)=>{const o=s=>{t({status:!!e.buttons.find((e=>e.id===s?.button_id)),data:s}),Be(Z,o)};Re(Z,o)}))):(s(m,1),{status:ve}),Je=()=>be(6.2,[ge,he,me]),ze=async e=>Ke()?(o(a,e),new Promise(((t,s)=>{ke(ee,(s=>{e.is_close&&Ae(),t({status:!0,data:s})})),ke(te,(()=>{t({status:"closed"})}))}))):(s(a,1),{status:ve}),Ke=()=>be(6.4,[me]),Xe=e=>{const t=function(e){try{return new URL(e)}catch(t){try{return new URL(e,"https://t.me")}catch(t){return e.startsWith("/")||(e="/"+e),new URL(e,"https://t.me")}}}(e.path_full);return e.path_full=t.pathname=t.search,Ye()?(o(h,e),{status:!0}):(s(h,1),{status:ve})},Ye=()=>be(7,[ge,he,me]);const Ze=async e=>et()?(e||(e={req_id:void 0}),void 0===e.req_id&&(e.req_id=we()),o(n,e),new Promise(((t,s)=>{const o=s=>{s.req_id===e?.req_id&&(t({status:!0,data:s}),Be(K,o))};Re(K,o)}))):(s(n,1),{status:ve}),et=()=>be(6.4,[ge,he,me]),tt=e=>st()?(o(S,e),{status:!0}):(s(S,1),{status:ve}),st=()=>be(6.9,[ge,he,me]),ot=async()=>rt()?(o(p),new Promise(((e,t)=>{ke(Y,(t=>{"sent"===t.status&&e({status:!0}),e({status:!1})}))}))):(s(p,1),{status:ve}),rt=()=>be(6.9,[ge,he,me]),at=e=>nt()?(o(v,e),{status:!0}):(s(v,1),{status:ve}),nt=()=>be(0,[ge,he,me]),pt=e=>it()?(o(b,e),{status:!0}):(s(b,1),{status:ve}),it=()=>be(0,[ge,he,me]),dt=()=>new Promise(((e,t)=>{if(!ut())return s(w,1),void e({status:ve});const r=t=>{e({status:"allowed"===t.status}),Be(re,r)};Re(re,r),o(w)})),ut=()=>be(6.9,[ge,he,me]),ct=e=>_t()?(o(f,e),{status:!0}):(s(f,1),{status:ve}),_t=()=>be(6.1,[ge,he,me]),lt=e=>xt()?(o(y,e),{status:!0}):(s(y,1),{status:ve}),xt=()=>be(6.1,[ge,he,me]),gt=e=>mt()?(o(q,{color:e?.color||e?.color_key}),{status:!0}):(s(q,1),{status:ve}),mt=()=>be(7.1,[ge,he,me]),ht=e=>St()?(o(R,e),{status:!0}):(s(R,1),{status:ve}),St=()=>be(6.1,[ge,he,me]),vt=e=>bt()?(o(B,e),{status:!0}):(s(B,1),{status:ve}),bt=()=>be(6.2,[ge,he,me]),wt=e=>ft()?(o(k,e),{status:!0}):(s(k,1),{status:ve}),ft=()=>be(0,[ge,he,me]),yt=e=>qt()?(o(E,e),{status:!0}):(s(E,1),{status:ve}),qt=()=>be(6.1,[ge,he,me]),Rt=e=>Bt()?(e.query.length>256&&s(C,9),o(C,e),{status:!0}):(s(C,1),{status:ve}),Bt=()=>be(6.7,[ge,he,me]),kt=e=>Et()?(o(T,e),{status:!0}):(s(T,1),{status:ve}),Et=()=>be(6.1,[me]),Ct=e=>Tt()?(o(A,e),{status:!0}):(s(A,1),{status:ve}),Tt=()=>be(7.7,[ge,he,me]),At=()=>be(7.8,[ge,he,me]),Mt=()=>be(8,[he,me]),Pt=()=>be(8,[he,me]),It=()=>be(8,[ge,he,me]),Ot=()=>be(8,[ge,he,me]),Ft=()=>be(8,[ge,he,me]),Wt=()=>be(8,[ge,he,me]),Lt=()=>be(8,[ge,he,me]),Dt=()=>be(8,[ge,he,me]),jt=()=>be(8,[ge,he,me]),Ht=()=>be(8,[ge,he,me]),[Gt,Qt]=t.createStore({isInited:!1,isBiometricAvailable:!1,isAccessGranted:!1,isAccessRequested:!1,isBiometricTokenSaved:!1,biometricType:"unknown",deviceId:""}),Nt={isInited:Gt.isInited,isBiometricAvailable:Gt.isBiometricAvailable,isAccessGranted:Gt.isAccessGranted,isAccessRequested:Gt.isAccessRequested,isBiometricTokenSaved:Gt.isBiometricTokenSaved,biometricType:Gt.biometricType,deviceId:Gt.deviceId,init:()=>new Promise(((e,t)=>{if(!Ut())return s(N,1),void e({status:ve,data:void 0});const r=t=>{Vt(t),e({status:!0,data:Gt}),Be(_e,r)};Re(_e,r),o(N)})),requestAccess:e=>new Promise(((t,r)=>{if(!Ut())return s(V,1),void t({status:ve,data:void 0});if(e.reason&&e.reason.length>128)return console.error(`[${V}] Biometric reason is too long`,e.reason),void t({status:!1,data:void 0});const a=e=>{Vt(e),t({status:!0,data:Gt}),Be(_e,a)};Re(_e,a),o(V,e)})),authenticate:e=>new Promise(((t,r)=>{if(!Ut())return s($,1),void t({status:ve,data:void 0});if(!Gt.isBiometricAvailable)return console.error("[Telegram.WebApp] Biometrics is not available on this device."),void t({status:!1,data:void 0});if(!Gt.isAccessGranted)return console.error("[Telegram.WebApp] Biometric access was not granted by the user."),void t({status:!1,data:void 0});const a=e=>{t({status:!0,data:e}),Be(ce,a)};Re(ce,a),o($,e)})),updateToken:e=>new Promise(((t,r)=>{if(!Ut())return s(J,1),void t({status:ve,data:void 0});if(!Gt.isBiometricAvailable)return console.error("[Telegram.WebApp] Biometrics is not available on this device."),void t({status:!1,data:void 0});if(!Gt.isAccessGranted)return console.error("[Telegram.WebApp] Biometric access was not granted by the user."),void t({status:!1,data:void 0});const a=e=>{t({status:!0,data:e}),Be(le,a)};Re(le,a),o(J,e)})),openSettings:e=>Ut()?Gt.isBiometricAvailable?Gt.isAccessRequested?Gt.isAccessGranted?(console.warn("[Telegram.WebApp] Biometric access was granted by the user, no need to go to settings."),{status:!1}):(o(U,e),{status:!0}):(console.error("[Telegram.WebApp] Biometric access was not granted by the user."),{status:!1}):(console.error("[Telegram.WebApp] Biometrics is not available on this device."),{status:!1}):(s(U,1),{status:ve})},Ut=()=>be(7.2,[he,me,ge]),Vt=e=>{Qt(t.produce((t=>(e.available?(t.isBiometricAvailable=!0,t.biometricType=e.type||"",e.access_requested?(t.isAccessRequested=!0,t.isAccessGranted=!!e.access_granted,t.isBiometricTokenSaved=!!e.token_saved):(t.isAccessRequested=!1,t.isAccessGranted=!1,t.isBiometricTokenSaved=!1)):(t.isBiometricAvailable=!1,t.biometricType="unknown",t.isAccessRequested=!1,t.isAccessGranted=!1,t.isBiometricTokenSaved=!1),t.deviceId=e.device_id||"",t.isInited=!0,t))))},$t=e=>{Qt(t.produce((t=>(t.isBiometricAvailable&&t.isAccessRequested&&("updated"===e.status?t.isBiometricTokenSaved=!0:"removed"===e.status&&(t.isBiometricTokenSaved=!1)),t))))};e.onMount((()=>{Re(_e,Vt),Re(le,$t),e.onCleanup((()=>{Be(_e,Vt),Be(le,$t)}))}));const Jt=()=>{const e=window.location.hash.slice(1),t=new URLSearchParams(e).get("tgWebAppData");if(!t)return void s("getInitData",2);const o=new URLSearchParams(t);let r={};return o.forEach(((e,t)=>{if(r[t]=e,void 0!==t.match(/^(chat|receiver|user)$/g))try{r[t]=JSON.parse(e)}catch{}})),r},zt=e.createContext({viewport:void 0,theme:void 0,init:void 0});exports.ContextTwa=zt,exports.EventAccelerometerChanged="accelerometer_changed",exports.EventAccelerometerFailed="accelerometer_failed",exports.EventAccelerometerStarted="accelerometer_started",exports.EventAccelerometerStopped="accelerometer_stopped",exports.EventBackButtonPressed="back_button_pressed",exports.EventBiometryAuthRequested=ce,exports.EventBiometryInfoReceived=_e,exports.EventBiometryTokenUpdated=le,exports.EventClipboardTextReceived=K,exports.EventContentSafeAreaChanged="content_safe_area_changed",exports.EventCustomMethodInvoked=X,exports.EventDeviceOrientationChanged="device_orientation_changed",exports.EventDeviceOrientationFailed="device_orientation_failed",exports.EventDeviceOrientationStarted="device_orientation_started",exports.EventDeviceOrientationStopped="device_orientation_stopped",exports.EventEmojiStatusAccessRequested=de,exports.EventEmojiStatusFailed=ie,exports.EventEmojiStatusSet=pe,exports.EventFileDownloadRequested=ue,exports.EventFullscreenChanged="fullscreen_changed",exports.EventFullscreenFailed="fullscreen_failed",exports.EventGyroscopeChanged="gyroscope_changed",exports.EventGyroscopeFailed="gyroscope_failed",exports.EventGyroscopeStarted="gyroscope_started",exports.EventGyroscopeStopped="gyroscope_stopped",exports.EventHomeScreenAdded="home_screen_added",exports.EventHomeScreenChecked=xe,exports.EventHomeScreenFailed="home_screen_failed",exports.EventInvoiceClosed="invoice_closed",exports.EventLocationChecked="location_checked",exports.EventLocationRequested="location_requested",exports.EventMainButtonPressed="main_button_pressed",exports.EventPhoneRequested=Y,exports.EventPopupClosed=Z,exports.EventPreparedMessageFailed=ne,exports.EventPreparedMessageSent=ae,exports.EventQrTextReceived=ee,exports.EventReloadIframe="reload_iframe",exports.EventSafeAreaChanged="safe_area_changed",exports.EventScanQrPopupClosed=te,exports.EventSecondaryButtonPressed="secondary_button_pressed",exports.EventSetCustomStyle="set_custom_style",exports.EventSettingsButtonPressed="settings_button_pressed",exports.EventThemeChanged=se,exports.EventViewportChanged=oe,exports.EventVisibilityChanged="visibility_changed",exports.EventWriteAccessRequested=re,exports.Method=z,exports.MethodAddToHomeScreen=L,exports.MethodCheckHomeScreen=D,exports.MethodClose=i,exports.MethodCloseScanQrPopup=d,exports.MethodDataSend=u,exports.MethodExitFullscreen=F,exports.MethodExpand=c,exports.MethodIframeReady=_,exports.MethodIframeWillReload=l,exports.MethodInvokeCustomMethod=r,exports.MethodOpenInvoice=x,exports.MethodOpenLink=g,exports.MethodOpenPopup=m,exports.MethodOpenScanQrPopup=a,exports.MethodOpenTgLink=h,exports.MethodReadTextFromClipboard=n,exports.MethodReady=S,exports.MethodRequestContentSafeArea=I,exports.MethodRequestEmojiStatusAccess=G,exports.MethodRequestFileDownload=Q,exports.MethodRequestFullscreen=O,exports.MethodRequestPhone=p,exports.MethodRequestSafeArea=P,exports.MethodRequestTheme=v,exports.MethodRequestViewport=b,exports.MethodRequestWriteAccess=w,exports.MethodSendPreparedMessage=j,exports.MethodSetBackgroundColor=f,exports.MethodSetBottomBarColor=q,exports.MethodSetEmojiStatus=H,exports.MethodSetHeaderColor=y,exports.MethodSetupBackButton=R,exports.MethodSetupClosingBehavior=B,exports.MethodSetupMainButton=k,exports.MethodSetupSettingsButton=E,exports.MethodSetupSwipeBehavior=A,exports.MethodShareToStory=M,exports.MethodSwitchInlineQuery=C,exports.MethodToggleOrientationLock=W,exports.MethodTriggerHapticFeedback=T,exports.NOT_SUPPORTED=ve,exports.ProviderTWA=s=>{const[o,r]=t.createStore({viewport:void 0,theme:void 0,init:void 0});return e.createEffect((()=>{const t=()=>{r("init",Jt())};t();const s=e=>{t(),r("viewport",e)};Re(oe,s),pt();const o=e=>{t(),r("theme",e)};return Re(se,o),pt(),e.onCleanup((()=>{Be(oe,s),Be(se,o)})),()=>{Be(oe,s),Be(se,o)}})),zt.Provider({value:o,children:s.children})},exports.TG_DESKTOP=he,exports.TG_PHONE=me,exports.TG_WEB=ge,exports.bridgeAddToHomeScreen=()=>Pt()?(o(L),{status:!0}):(s(L,1),{status:ve}),exports.bridgeBiometricManager=Nt,exports.bridgeCheckHomeScreen=async e=>new Promise(((t,r)=>{if(!Mt())return s(D,1),void t({status:ve,data:void 0});const a=e=>{e.status=e.status||"unknown",t({status:!0,data:e}),Be(xe,a)};Re(xe,a),o(D,e)})),exports.bridgeClose=Ce,exports.bridgeCloseScanQrPopup=Ae,exports.bridgeDataSend=Pe,exports.bridgeDownloadFile=async e=>Ht()?new Promise(((t,s)=>{ke(ue,(function(e){t({status:"downloading"===e.status})})),o(Q,e)})):(s(Q,1),{status:ve}),exports.bridgeExpand=Oe,exports.bridgeGetInitData=Jt,exports.bridgeGetThemeParams=ye,exports.bridgeIframeReady=We,exports.bridgeIframeWillReload=De,exports.bridgeInvokeCustomMethod=He,exports.bridgeOpenInvoice=Qe,exports.bridgeOpenLink=Ue,exports.bridgeOpenPopup=$e,exports.bridgeOpenScanQrPopup=ze,exports.bridgeOpenTgLink=Xe,exports.bridgeReadTextFromClipboard=Ze,exports.bridgeReady=tt,exports.bridgeRequestContentSafeAreaInset=()=>Ot()?(o(I),{status:!0}):(s(I,1),{status:ve}),exports.bridgeRequestEmojiStatus=async e=>Lt()?new Promise(((t,s)=>{ke(de,(function(e){t({status:"allowed"===e.status})})),o(G,e)})):(s(G,1),{status:ve}),exports.bridgeRequestPhone=ot,exports.bridgeRequestSafeAreaInset=()=>It()?(o(P),{status:!0}):(s(P,1),{status:ve}),exports.bridgeRequestTheme=at,exports.bridgeRequestViewport=pt,exports.bridgeRequestWriteAccess=dt,exports.bridgeSend=o,exports.bridgeSessionStorageGet=({key:e})=>{try{return{is_json:!0,value:JSON.parse(window.sessionStorage.getItem("__telegram__"+e)??""),status:!0}}catch(t){return{is_json:!1,value:window.sessionStorage.getItem("__telegram__"+e)??"",status:!0}}},exports.bridgeSessionStorageSet=({key:e,value:t})=>{try{return window.sessionStorage.setItem("__telegram__"+e,JSON.stringify(t)),{status:!0}}catch(s){return window.sessionStorage.setItem("__telegram__"+e,t),{status:!0}}},exports.bridgeSetBackgroundColor=ct,exports.bridgeSetBottomBarColor=gt,exports.bridgeSetEmojiStatus=async e=>Dt()?new Promise(((t,s)=>{ke(pe,(()=>t({status:!0}))),ke(ie,(()=>t({status:!1}))),o(H,e)})):(s(H,1),{status:ve}),exports.bridgeSetHeaderColor=lt,exports.bridgeSetupBackButton=ht,exports.bridgeSetupClosingBehavior=vt,exports.bridgeSetupFullScreen=e=>{const t=e?.is_full||!1;return Ft()?(o(t?O:F),{status:!0}):(s(t?O:F,1),{status:ve})},exports.bridgeSetupMainButton=wt,exports.bridgeSetupOrientation=e=>Wt()?(o(W,e),{status:!0}):(s(W,1),{status:ve}),exports.bridgeSetupSettingsButton=yt,exports.bridgeSetupSwipeBehavior=Ct,exports.bridgeShareMessage=async e=>jt()?new Promise(((t,s)=>{ke(ae,(()=>t({status:!0}))),ke(ne,(()=>t({status:!1}))),o(j,e)})):(s(j,1),{status:ve}),exports.bridgeShareToStory=e=>At()?e?.text&&e?.text.length>2048?(console.warn(`[@apiteam/twa-bridge](${M}) | Text is too long`),{status:!1,error_id:1}):e?.widget_link?.name&&e?.widget_link.name.length>48?(console.warn(`[@apiteam/twa-bridge](${M}) | Link name is too long`),{status:!1,error_id:2}):(o(M,e),{status:!0}):(s(M,1),{status:ve}),exports.bridgeSwitchInlineQuery=Rt,exports.bridgeTriggerHapticFeedback=kt,exports.createIsViewportChanged=()=>{const[t,s]=e.createSignal({height:0,is_expanded:!1,is_state_stable:!1}),r=e=>s(e);return e.onMount((()=>{Re(oe,r),o(b)})),e.onCleanup((()=>{Be(oe,r)})),t},exports.debug=s,exports.getAppData=()=>{const e=window.location.hash.slice(1);return new URLSearchParams(e).get("tgWebAppData")},exports.getPlatform=Se,exports.listener=Ee,exports.sender=o,exports.supportAddToHomeScreen=Pt,exports.supportBiometricManager=Ut,exports.supportCheckHomeScreen=Mt,exports.supportClose=Te,exports.supportCloseScanQrPopup=Me,exports.supportDataSend=Ie,exports.supportDownloadFile=Ht,exports.supportExpand=Fe,exports.supportIframeReady=Le,exports.supportIframeWillReload=je,exports.supportInvokeCustomMethod=Ge,exports.supportOpenInvoice=Ne,exports.supportOpenLink=Ve,exports.supportOpenPopup=Je,exports.supportOpenScanQrPopup=Ke,exports.supportOpenTgLink=Ye,exports.supportReadTextFromClipboard=et,exports.supportReady=st,exports.supportRequestContentSafeAreaInset=Ot,exports.supportRequestEmojiStatus=Lt,exports.supportRequestPhone=rt,exports.supportRequestSafeAreaInset=It,exports.supportRequestTheme=nt,exports.supportRequestViewport=it,exports.supportRequestWriteAccess=ut,exports.supportSessionStorageGet=()=>!0,exports.supportSessionStorageSet=()=>!0,exports.supportSetBackgroundColor=_t,exports.supportSetBottomBarColor=mt,exports.supportSetEmojiStatus=Dt,exports.supportSetHeaderColor=xt,exports.supportSetupBackButton=St,exports.supportSetupClosingBehavior=bt,exports.supportSetupFullScreen=Ft,exports.supportSetupMainButton=ft,exports.supportSetupOrientation=Wt,exports.supportSetupSettingsButton=qt,exports.supportSetupSwipeBehavior=Tt,exports.supportShareMessage=jt,exports.supportShareToStory=At,exports.supportSwitchInlineQuery=Bt,exports.supportTriggerHapticFeedback=Et;
|
package/solid/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createSignal as e,onMount as t,onCleanup as s,createContext as a,createEffect as o}from"solid-js";import{createStore as r,produce as i}from"solid-js/store";const n=()=>{const[a,o]=e({height:0,is_expanded:!1,is_state_stable:!1}),r=e=>o(e);return t((()=>{Ds(rs,r),Qt(nt)})),s((()=>{Ms(rs,r)})),a},c="web",d="phone",u="desktop",_=()=>{const e=window.location.hash.slice(1),t=new URLSearchParams(e).get("tgWebAppPlatform")??"ios";return["android","ios"].includes(t)?d:["tdesktop","macos"].includes(t)?u:c},p="not_supported",l=(e,t)=>{const s=new URLSearchParams(window.location.hash.slice(1)).get("tgWebAppVersion");return Number(s?.replace(".",""))>=Number(String(e)?.replace(".",""))&&-1!==t.indexOf(_())},g=()=>Math.random().toString(36).substring(3,9),m=e=>{var t;if(t=/^\s*#([0-9a-f]{6})\s*$/i.exec(e+=""))return"#"+t[1].toLowerCase();if(t=/^\s*#([0-9a-f])([0-9a-f])([0-9a-f])\s*$/i.exec(e))return("#"+t[1]+t[1]+t[2]+t[2]+t[3]+t[3]).toLowerCase();if(t=/^\s*rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*(\d+\.{0,1}\d*))?\)\s*$/.exec(e)){var s=parseInt(t[1]),a=parseInt(t[2]),o=parseInt(t[3]);return"#"+((s<16?"0":"")+s.toString(16))+((a<16?"0":"")+a.toString(16))+((o<16?"0":"")+o.toString(16))}return!1},b=e=>{const t=window.location.hash.slice(1),s=new URLSearchParams(t),a=JSON.parse(s.get("tgWebAppThemeParams")??""),o=e||a;for(var r of Object.keys(o)){var i=m(o[r]);"string"==typeof i&&(o[r]=i)}return"#1c1c1d"==o?.bg_color&&o?.bg_color==o?.secondary_bg_color&&(o.secondary_bg_color="#2c2c2e"),o},w=e=>v()?(Qt(ze,e),{status:!0}):(Nt(ze,1),{status:p}),v=()=>l(0,[c,u,d]),h=e=>S()?(Qt(Ke,e),{status:!0}):(Nt(Ke,1),{status:p}),S=()=>l(6.4,[d]),f=e=>y()?(Qt(Xe,e),{status:!0}):(Nt(Xe,1),{status:p}),y=()=>l(0,[c,u,d]),q=e=>k()?(Qt(Ye,e),{status:!0}):(Nt(Ye,1),{status:p}),k=()=>l(0,[d]),R=e=>A()?(Qt(Ze,e),{status:!0}):(Nt(Ze,1),{status:p}),A=()=>l(0,[c]),B=()=>T()?(Qt(Ze),{status:!0}):(Nt(Ze,1),{status:p}),T=()=>l(0,[c]),P=async e=>I()?(void 0===e.req_id&&(e.req_id=g()),Qt(Qe,e),new Promise(((t,s)=>{const a=s=>{s.req_id===e.req_id&&(t({status:!0,data:s}),Ms(Vt,a))};Ds(Vt,a)}))):(Nt(Qe,1),{status:p}),I=()=>l(6.9,[c,u,d]),x=e=>C()?(Qt(tt,e),{status:!0}):(Nt(tt,1),{status:p}),C=()=>l(6.1,[c,u,d]),O=e=>W()?(Qt(st,e),{status:!0}):(Nt(st,1),{status:p}),W=()=>l(6.4,[c,u,d]),L=async e=>E()?(e.title.length>64&&Nt(at,3),e.message.length<1&&Nt(at,4),e.message.length>256&&Nt(at,5),e.buttons.length<1&&Nt(at,6),e.buttons.length>3&&Nt(at,7),void 0!==e.buttons.find((e=>e.text?.match(/^(ok|close|cancel)$/g)))&&Nt(at,8),Qt(at,e),new Promise(((t,s)=>{const a=s=>{t({status:!!e.buttons.find((e=>e.id===s?.button_id)),data:s}),Ms(Yt,a)};Ds(Yt,a)}))):(Nt(at,1),{status:p}),E=()=>l(6.2,[c,u,d]),j=async e=>F()?(Qt(Ue,e),new Promise(((t,s)=>{Hs(es,(s=>{e.is_close&&h(),t({status:!0,data:s})})),Hs(ts,(()=>{t({status:"closed"})}))}))):(Nt(Ue,1),{status:p}),F=()=>l(6.4,[d]),G=e=>{const t=function(e){try{return new URL(e)}catch(t){try{return new URL(e,"https://t.me")}catch(t){return e.startsWith("/")||(e="/"+e),new URL(e,"https://t.me")}}}(e.path_full);return e.path_full=t.pathname=t.search,D()?(Qt(ot,e),{status:!0}):(Nt(ot,1),{status:p})},D=()=>l(7,[c,u,d]);const M=async e=>H()?(e||(e={req_id:void 0}),void 0===e.req_id&&(e.req_id=g()),Qt(Je,e),new Promise(((t,s)=>{const a=s=>{s.req_id===e?.req_id&&(t({status:!0,data:s}),Ms(Jt,a))};Ds(Jt,a)}))):(Nt(Je,1),{status:p}),H=()=>l(6.4,[c,u,d]),N=e=>$()?(Qt(rt,e),{status:!0}):(Nt(rt,1),{status:p}),$=()=>l(6.9,[c,u,d]),Q=async()=>U()?(Qt(Ve),new Promise(((e,t)=>{Hs(Xt,(t=>{"sent"===t.status&&e({status:!0}),e({status:!1})}))}))):(Nt(Ve,1),{status:p}),U=()=>l(6.9,[c,u,d]),J=e=>V()?(Qt(it,e),{status:!0}):(Nt(it,1),{status:p}),V=()=>l(0,[c,u,d]),z=e=>K()?(Qt(nt,e),{status:!0}):(Nt(nt,1),{status:p}),K=()=>l(0,[c,u,d]),X=()=>new Promise(((e,t)=>{if(!Y())return Nt(ct,1),void e({status:p});const s=t=>{e({status:"allowed"===t.status}),Ms(is,s)};Ds(is,s),Qt(ct)})),Y=()=>l(6.9,[c,u,d]),Z=e=>ee()?(Qt(dt,e),{status:!0}):(Nt(dt,1),{status:p}),ee=()=>l(6.1,[c,u,d]),te=e=>se()?(Qt(ut,e),{status:!0}):(Nt(ut,1),{status:p}),se=()=>l(6.1,[c,u,d]),ae=e=>oe()?(Qt(_t,{color:e?.color||e?.color_key}),{status:!0}):(Nt(_t,1),{status:p}),oe=()=>l(7.1,[c,u,d]),re=e=>ie()?(Qt(pt,e),{status:!0}):(Nt(pt,1),{status:p}),ie=()=>l(6.1,[c,u,d]),ne=e=>ce()?(Qt(lt,e),{status:!0}):(Nt(lt,1),{status:p}),ce=()=>l(6.2,[c,u,d]),de=e=>ue()?(Qt(gt,e),{status:!0}):(Nt(gt,1),{status:p}),ue=()=>l(0,[c,u,d]),_e=e=>pe()?(Qt(mt,e),{status:!0}):(Nt(mt,1),{status:p}),pe=()=>l(6.1,[c,u,d]),le=e=>ge()?(e.query.length>256&&Nt(bt,9),Qt(bt,e),{status:!0}):(Nt(bt,1),{status:p}),ge=()=>l(6.7,[c,u,d]),me=e=>be()?(Qt(wt,e),{status:!0}):(Nt(wt,1),{status:p}),be=()=>l(6.1,[d]),we=({key:e,value:t})=>{try{return window.sessionStorage.setItem("__telegram__"+e,JSON.stringify(t)),{status:!0}}catch(s){return window.sessionStorage.setItem("__telegram__"+e,t),{status:!0}}},ve=()=>!0,he=({key:e})=>{try{return{is_json:!0,value:JSON.parse(window.sessionStorage.getItem("__telegram__"+e)??""),status:!0}}catch(t){return{is_json:!1,value:window.sessionStorage.getItem("__telegram__"+e)??"",status:!0}}},Se=()=>!0,fe=e=>ye()?(Qt(vt,e),{status:!0}):(Nt(vt,1),{status:p}),ye=()=>l(7.7,[c,u,d]),qe=e=>ke()?e?.text&&e?.text.length>2048?(console.warn(`[@apiteam/twa-bridge](${ht}) | Text is too long`),{status:!1,error_id:1}):e?.widget_link?.name&&e?.widget_link.name.length>48?(console.warn(`[@apiteam/twa-bridge](${ht}) | Link name is too long`),{status:!1,error_id:2}):(Qt(ht,e),{status:!0}):(Nt(ht,1),{status:p}),ke=()=>l(7.8,[c,u,d]),Re=async e=>new Promise(((t,s)=>{if(!Ae())return Nt(At,1),void t({status:p,data:void 0});const a=e=>{e.status=e.status||"unknown",t({status:!0,data:e}),Ms(Os,a)};Ds(Os,a),Qt(At,e)})),Ae=()=>l(8,[u,d]),Be=()=>Te()?(Qt(Rt),{status:!0}):(Nt(Rt,1),{status:p}),Te=()=>l(8,[u,d]),Pe=()=>Ie()?(Qt(St),{status:!0}):(Nt(St,1),{status:p}),Ie=()=>l(8,[c,u,d]),xe=()=>Ce()?(Qt(ft),{status:!0}):(Nt(ft,1),{status:p}),Ce=()=>l(8,[c,u,d]),Oe=e=>{const t=e?.is_full||!1;return We()?(Qt(t?yt:qt),{status:!0}):(Nt(t?yt:qt,1),{status:p})},We=()=>l(8,[c,u,d]),Le=e=>Ee()?(Qt(kt,e),{status:!0}):(Nt(kt,1),{status:p}),Ee=()=>l(8,[c,u,d]),je=async e=>Fe()?new Promise(((t,s)=>{Hs(ls,(function(e){t({status:"allowed"===e.status})})),Qt(Pt,e)})):(Nt(Pt,1),{status:p}),Fe=()=>l(8,[c,u,d]),Ge=async e=>De()?new Promise(((t,s)=>{Hs(_s,(()=>t({status:!0}))),Hs(ps,(()=>t({status:!1}))),Qt(Tt,e)})):(Nt(Tt,1),{status:p}),De=()=>l(8,[c,u,d]),Me=async e=>He()?new Promise(((t,s)=>{Hs(ds,(()=>t({status:!0}))),Hs(us,(()=>t({status:!1}))),Qt(Bt,e)})):(Nt(Bt,1),{status:p}),He=()=>l(8,[c,u,d]),Ne=async e=>$e()?new Promise(((t,s)=>{Hs(gs,(function(e){t({status:"downloading"===e.status})})),Qt(It,e)})):(Nt(It,1),{status:p}),$e=()=>l(8,[c,u,d]),Qe="web_app_invoke_custom_method",Ue="web_app_open_scan_qr_popup",Je="web_app_read_text_from_clipboard",Ve="web_app_request_phone",ze="web_app_close",Ke="web_app_close_scan_qr_popup",Xe="web_app_data_send",Ye="web_app_expand",Ze="iframe_ready",et="iframe_will_reload",tt="web_app_open_invoice",st="web_app_open_link",at="web_app_open_popup",ot="web_app_open_tg_link",rt="web_app_ready",it="web_app_request_theme",nt="web_app_request_viewport",ct="web_app_request_write_access",dt="web_app_set_background_color",ut="web_app_set_header_color",_t="web_app_set_bottom_bar_color",pt="web_app_setup_back_button",lt="web_app_setup_closing_behavior",gt="web_app_setup_main_button",mt="web_app_setup_settings_button",bt="web_app_switch_inline_query",wt="web_app_trigger_haptic_feedback",vt="web_app_setup_swipe_behavior",ht="web_app_share_to_story",St="web_app_request_safe_area",ft="web_app_request_content_safe_area",yt="web_app_request_fullscreen",qt="web_app_exit_fullscreen",kt="web_app_toggle_orientation_lock",Rt="web_app_add_to_home_screen",At="web_app_check_home_screen",Bt="web_app_send_prepared_message",Tt="web_app_set_emoji_status",Pt="web_app_request_emoji_status_access",It="web_app_request_file_download",xt="web_app_biometry_get_info",Ct="web_app_biometry_open_settings",Ot="web_app_biometry_request_access",Wt="web_app_biometry_request_auth",Lt="web_app_biometry_update_token";var Et=(e=>(e[e.InvokeCustomMethod=Qe]="InvokeCustomMethod",e[e.OpenScanQrPopup=Ue]="OpenScanQrPopup",e[e.ReadTextFromClipboard=Je]="ReadTextFromClipboard",e[e.RequestPhone=Ve]="RequestPhone",e[e.Close=ze]="Close",e[e.CloseScanQrPopup=Ke]="CloseScanQrPopup",e[e.DataSend=Xe]="DataSend",e[e.Expand=Ye]="Expand",e[e.IframeReady=Ze]="IframeReady",e[e.IframeWillReload=et]="IframeWillReload",e[e.OpenInvoice=tt]="OpenInvoice",e[e.OpenLink=st]="OpenLink",e[e.OpenPopup=at]="OpenPopup",e[e.OpenTgLink=ot]="OpenTgLink",e[e.Ready=rt]="Ready",e[e.RequestTheme=it]="RequestTheme",e[e.RequestViewport=nt]="RequestViewport",e[e.RequestWriteAccess=ct]="RequestWriteAccess",e[e.SetBackgroundColor=dt]="SetBackgroundColor",e[e.SetHeaderColor=ut]="SetHeaderColor",e[e.SetBottomBarColor=_t]="SetBottomBarColor",e[e.SetupBackButton=pt]="SetupBackButton",e[e.SetupClosingBehavior=lt]="SetupClosingBehavior",e[e.SetupMainButton=gt]="SetupMainButton",e[e.SetupSettingsButton=mt]="SetupSettingsButton",e[e.SwitchInlineQuery=bt]="SwitchInlineQuery",e[e.TriggerHapticFeedback=wt]="TriggerHapticFeedback",e[e.SetupSwipeBehavior=vt]="SetupSwipeBehavior",e[e.ShareToStory=ht]="ShareToStory",e[e.RequestSafeArea=St]="RequestSafeArea",e[e.RequestContentSafeArea=ft]="RequestContentSafeArea",e[e.RequestFullscreen=yt]="RequestFullscreen",e[e.ExitFullscreen=qt]="ExitFullscreen",e[e.ToggleOrientationLock=kt]="ToggleOrientationLock",e[e.AddToHomeScreen=Rt]="AddToHomeScreen",e[e.CheckHomeScreen=At]="CheckHomeScreen",e[e.SendPreparedMessage=Bt]="SendPreparedMessage",e[e.SetEmojiStatus=Tt]="SetEmojiStatus",e[e.RequestEmojiStatusAccess=Pt]="RequestEmojiStatusAccess",e[e.RequestFileDownload=It]="RequestFileDownload",e))(Et||{});const[jt,Ft]=r({isInited:!1,isBiometricAvailable:!1,isAccessGranted:!1,isAccessRequested:!1,isBiometricTokenSaved:!1,biometricType:"unknown",deviceId:""}),Gt={isInited:jt.isInited,isBiometricAvailable:jt.isBiometricAvailable,isAccessGranted:jt.isAccessGranted,isAccessRequested:jt.isAccessRequested,isBiometricTokenSaved:jt.isBiometricTokenSaved,biometricType:jt.biometricType,deviceId:jt.deviceId,init:()=>new Promise(((e,t)=>{if(!Dt())return Nt(xt,1),void e({status:p,data:void 0});const s=t=>{Mt(t),e({status:!0,data:jt}),Ms(Ss,s)};Ds(Ss,s),Qt(xt)})),requestAccess:e=>new Promise(((t,s)=>{if(!Dt())return Nt(Ot,1),void t({status:p,data:void 0});if(e.reason&&e.reason.length>128)return console.error(`[${Ot}] Biometric reason is too long`,e.reason),void t({status:!1,data:void 0});const a=e=>{Mt(e),t({status:!0,data:jt}),Ms(Ss,a)};Ds(Ss,a),Qt(Ot,e)})),authenticate:e=>new Promise(((t,s)=>{if(!Dt())return Nt(Wt,1),void t({status:p,data:void 0});if(!jt.isBiometricAvailable)return console.error("[Telegram.WebApp] Biometrics is not available on this device."),void t({status:!1,data:void 0});if(!jt.isAccessGranted)return console.error("[Telegram.WebApp] Biometric access was not granted by the user."),void t({status:!1,data:void 0});const a=e=>{t({status:!0,data:e}),Ms(hs,a)};Ds(hs,a),Qt(Wt,e)})),updateToken:e=>new Promise(((t,s)=>{if(!Dt())return Nt(Lt,1),void t({status:p,data:void 0});if(!jt.isBiometricAvailable)return console.error("[Telegram.WebApp] Biometrics is not available on this device."),void t({status:!1,data:void 0});if(!jt.isAccessGranted)return console.error("[Telegram.WebApp] Biometric access was not granted by the user."),void t({status:!1,data:void 0});const a=e=>{t({status:!0,data:e}),Ms(fs,a)};Ds(fs,a),Qt(Lt,e)})),openSettings:e=>Dt()?jt.isBiometricAvailable?jt.isAccessRequested?jt.isAccessGranted?(console.warn("[Telegram.WebApp] Biometric access was granted by the user, no need to go to settings."),{status:!1}):(Qt(Ct,e),{status:!0}):(console.error("[Telegram.WebApp] Biometric access was not granted by the user."),{status:!1}):(console.error("[Telegram.WebApp] Biometrics is not available on this device."),{status:!1}):(Nt(Ct,1),{status:p})},Dt=()=>l(7.2,[u,d,c]),Mt=e=>{Ft(i((t=>(e.available?(t.isBiometricAvailable=!0,t.biometricType=e.type||"",e.access_requested?(t.isAccessRequested=!0,t.isAccessGranted=!!e.access_granted,t.isBiometricTokenSaved=!!e.token_saved):(t.isAccessRequested=!1,t.isAccessGranted=!1,t.isBiometricTokenSaved=!1)):(t.isBiometricAvailable=!1,t.biometricType="unknown",t.isAccessRequested=!1,t.isAccessGranted=!1,t.isBiometricTokenSaved=!1),t.deviceId=e.device_id||"",t.isInited=!0,t))))},Ht=e=>{Ft(i((t=>(t.isBiometricAvailable&&t.isAccessRequested&&("updated"===e.status?t.isBiometricTokenSaved=!0:"removed"===e.status&&(t.isBiometricTokenSaved=!1)),t))))};t((()=>{Ds(Ss,Mt),Ds(fs,Ht),s((()=>{Ms(Ss,Mt),Ms(fs,Ht)}))}));const Nt=(e,t)=>{"development"===process.env.NODE_ENV&&console.error(`[@apiteam/twa-bridge](${e}) = ${t}`)},$t=()=>{const e=window.location.hash.slice(1),t=new URLSearchParams(e).get("tgWebAppData");if(!t)return void Nt("getInitData",2);const s=new URLSearchParams(t);let a={};return s.forEach(((e,t)=>{if(a[t]=e,void 0!==t.match(/^(chat|receiver|user)$/g))try{a[t]=JSON.parse(e)}catch{}})),a},Qt=(e,t)=>{if(window.TelegramWebviewProxy)window.TelegramWebviewProxy.postEvent(e,JSON.stringify(t));else if(window.external&&"notify"in window.external)window.external.notify(JSON.stringify({eventType:e,eventData:t}));else try{window.parent.postMessage(JSON.stringify({eventType:e,eventData:t}),"*")}catch(e){Nt("postMessage Iframe",10)}},Ut="back_button_pressed",Jt="clipboard_text_received",Vt="custom_method_invoked",zt="invoice_closed",Kt="main_button_pressed",Xt="phone_requested",Yt="popup_closed",Zt="reload_iframe",es="qr_text_received",ts="scan_qr_popup_closed",ss="set_custom_style",as="settings_button_pressed",os="theme_changed",rs="viewport_changed",is="write_access_requested",ns="safe_area_changed",cs="content_safe_area_changed",ds="prepared_message_sent",us="prepared_message_failed",_s="emoji_status_set",ps="emoji_status_failed",ls="emoji_status_access_requested",gs="file_download_requested",ms="accelerometer_changed",bs="accelerometer_failed",ws="accelerometer_started",vs="accelerometer_stopped",hs="biometry_auth_requested",Ss="biometry_info_received",fs="biometry_token_updated",ys="device_orientation_changed",qs="device_orientation_failed",ks="device_orientation_started",Rs="device_orientation_stopped",As="fullscreen_changed",Bs="fullscreen_failed",Ts="gyroscope_changed",Ps="gyroscope_failed",Is="gyroscope_started",xs="gyroscope_stopped",Cs="home_screen_added",Os="home_screen_checked",Ws="home_screen_failed",Ls="location_checked",Es="location_requested",js="secondary_button_pressed",Fs="visibility_changed",Gs=((e=new Map)=>({once:(t,s,a=e.get(t),o=e=>{s(e),a&&a.splice(a.indexOf(s)>>>0,1)})=>a?a.push(o):e.set(t,[o]),on:(t,s,a=e.get(t))=>a?a.push(s):e.set(t,[s]),off:(t,s,a=e.get(t))=>a&&s?a.splice(a.indexOf(s)>>>0,1):e.set(t,[]),emit:(t,s,a=e.get(t)||[])=>{for(const e of a)e(s)}}))();(()=>{function e(e,t){e===os&&(t.theme_params=b(t.theme_params)),Gs.emit(e,t),Gs.emit("*",{name:e,data:t})}window.TelegramGameProxy_receiveEvent=e,window.Telegram={WebView:{receiveEvent:e}},window.TelegramGameProxy={receiveEvent:e}})();const Ds=(e,t)=>{Gs.on(e,t)},Ms=(e,t)=>{Gs.off(e,t)},Hs=(e,t)=>{Gs.once(e,t)};var Ns=Object.freeze({__proto__:null,off:Ms,on:Ds,once:Hs});const $s=()=>{const e=window.location.hash.slice(1);return new URLSearchParams(e).get("tgWebAppData")},Qs=a({viewport:void 0,theme:void 0,init:void 0}),Us=e=>{const[t,a]=r({viewport:void 0,theme:void 0,init:void 0});return o((()=>{const e=()=>{a("init",$t())};e();const t=t=>{e(),a("viewport",t)};Ds(rs,t),z();const o=t=>{e(),a("theme",t)};return Ds(os,o),z(),s((()=>{Ms(rs,t),Ms(os,o)})),()=>{Ms(rs,t),Ms(os,o)}})),Qs.Provider({value:t,children:e.children})};export{Gt as BiometricManager,Qs as ContextTwa,ms as EventAccelerometerChanged,bs as EventAccelerometerFailed,ws as EventAccelerometerStarted,vs as EventAccelerometerStopped,Ut as EventBackButtonPressed,hs as EventBiometryAuthRequested,Ss as EventBiometryInfoReceived,fs as EventBiometryTokenUpdated,Jt as EventClipboardTextReceived,cs as EventContentSafeAreaChanged,Vt as EventCustomMethodInvoked,ys as EventDeviceOrientationChanged,qs as EventDeviceOrientationFailed,ks as EventDeviceOrientationStarted,Rs as EventDeviceOrientationStopped,ls as EventEmojiStatusAccessRequested,ps as EventEmojiStatusFailed,_s as EventEmojiStatusSet,gs as EventFileDownloadRequested,As as EventFullscreenChanged,Bs as EventFullscreenFailed,Ts as EventGyroscopeChanged,Ps as EventGyroscopeFailed,Is as EventGyroscopeStarted,xs as EventGyroscopeStopped,Cs as EventHomeScreenAdded,Os as EventHomeScreenChecked,Ws as EventHomeScreenFailed,zt as EventInvoiceClosed,Ls as EventLocationChecked,Es as EventLocationRequested,Kt as EventMainButtonPressed,Xt as EventPhoneRequested,Yt as EventPopupClosed,us as EventPreparedMessageFailed,ds as EventPreparedMessageSent,es as EventQrTextReceived,Zt as EventReloadIframe,ns as EventSafeAreaChanged,ts as EventScanQrPopupClosed,js as EventSecondaryButtonPressed,ss as EventSetCustomStyle,as as EventSettingsButtonPressed,os as EventThemeChanged,rs as EventViewportChanged,Fs as EventVisibilityChanged,is as EventWriteAccessRequested,Et as Method,Rt as MethodAddToHomeScreen,At as MethodCheckHomeScreen,ze as MethodClose,Ke as MethodCloseScanQrPopup,Xe as MethodDataSend,qt as MethodExitFullscreen,Ye as MethodExpand,Ze as MethodIframeReady,et as MethodIframeWillReload,Qe as MethodInvokeCustomMethod,tt as MethodOpenInvoice,st as MethodOpenLink,at as MethodOpenPopup,Ue as MethodOpenScanQrPopup,ot as MethodOpenTgLink,Je as MethodReadTextFromClipboard,rt as MethodReady,ft as MethodRequestContentSafeArea,Pt as MethodRequestEmojiStatusAccess,It as MethodRequestFileDownload,yt as MethodRequestFullscreen,Ve as MethodRequestPhone,St as MethodRequestSafeArea,it as MethodRequestTheme,nt as MethodRequestViewport,ct as MethodRequestWriteAccess,Bt as MethodSendPreparedMessage,dt as MethodSetBackgroundColor,_t as MethodSetBottomBarColor,Tt as MethodSetEmojiStatus,ut as MethodSetHeaderColor,pt as MethodSetupBackButton,lt as MethodSetupClosingBehavior,gt as MethodSetupMainButton,mt as MethodSetupSettingsButton,vt as MethodSetupSwipeBehavior,ht as MethodShareToStory,bt as MethodSwitchInlineQuery,kt as MethodToggleOrientationLock,wt as MethodTriggerHapticFeedback,p as NOT_SUPPORTED,Us as ProviderTWA,u as TG_DESKTOP,d as TG_PHONE,c as TG_WEB,Be as bridgeAddToHomeScreen,Re as bridgeCheckHomeScreen,w as bridgeClose,h as bridgeCloseScanQrPopup,f as bridgeDataSend,Ne as bridgeDownloadFile,q as bridgeExpand,$t as bridgeGetInitData,b as bridgeGetThemeParams,R as bridgeIframeReady,B as bridgeIframeWillReload,P as bridgeInvokeCustomMethod,x as bridgeOpenInvoice,O as bridgeOpenLink,L as bridgeOpenPopup,j as bridgeOpenScanQrPopup,G as bridgeOpenTgLink,M as bridgeReadTextFromClipboard,N as bridgeReady,xe as bridgeRequestContentSafeAreaInset,je as bridgeRequestEmojiStatus,Q as bridgeRequestPhone,Pe as bridgeRequestSafeAreaInset,J as bridgeRequestTheme,z as bridgeRequestViewport,X as bridgeRequestWriteAccess,Qt as bridgeSend,he as bridgeSessionStorageGet,we as bridgeSessionStorageSet,Z as bridgeSetBackgroundColor,ae as bridgeSetBottomBarColor,Ge as bridgeSetEmojiStatus,te as bridgeSetHeaderColor,re as bridgeSetupBackButton,ne as bridgeSetupClosingBehavior,Oe as bridgeSetupFullScreen,de as bridgeSetupMainButton,Le as bridgeSetupOrientation,_e as bridgeSetupSettingsButton,fe as bridgeSetupSwipeBehavior,Me as bridgeShareMessage,qe as bridgeShareToStory,le as bridgeSwitchInlineQuery,me as bridgeTriggerHapticFeedback,n as createIsViewportChanged,Nt as debug,$s as getAppData,_ as getPlatform,Ns as listener,Qt as sender,Te as supportAddToHomeScreen,Dt as supportBiometricManager,Ae as supportCheckHomeScreen,v as supportClose,S as supportCloseScanQrPopup,y as supportDataSend,$e as supportDownloadFile,k as supportExpand,A as supportIframeReady,T as supportIframeWillReload,I as supportInvokeCustomMethod,C as supportOpenInvoice,W as supportOpenLink,E as supportOpenPopup,F as supportOpenScanQrPopup,D as supportOpenTgLink,H as supportReadTextFromClipboard,$ as supportReady,Ce as supportRequestContentSafeAreaInset,Fe as supportRequestEmojiStatus,U as supportRequestPhone,Ie as supportRequestSafeAreaInset,V as supportRequestTheme,K as supportRequestViewport,Y as supportRequestWriteAccess,Se as supportSessionStorageGet,ve as supportSessionStorageSet,ee as supportSetBackgroundColor,oe as supportSetBottomBarColor,De as supportSetEmojiStatus,se as supportSetHeaderColor,ie as supportSetupBackButton,ce as supportSetupClosingBehavior,We as supportSetupFullScreen,ue as supportSetupMainButton,Ee as supportSetupOrientation,pe as supportSetupSettingsButton,ye as supportSetupSwipeBehavior,He as supportShareMessage,ke as supportShareToStory,ge as supportSwitchInlineQuery,be as supportTriggerHapticFeedback};
|
|
1
|
+
import{createSignal as e,onMount as t,onCleanup as s,createContext as a,createEffect as o}from"solid-js";import{createStore as r,produce as i}from"solid-js/store";const n=(e,t)=>{"development"===process.env.NODE_ENV&&console.error(`[@apiteam/twa-bridge](${e}) = ${t}`)},c=(e,t)=>{if(window.TelegramWebviewProxy)window.TelegramWebviewProxy.postEvent(e,JSON.stringify(t));else if(window.external&&"notify"in window.external)window.external.notify(JSON.stringify({eventType:e,eventData:t}));else try{window.parent.postMessage(JSON.stringify({eventType:e,eventData:t}),"*")}catch(e){n("postMessage Iframe",10)}},d="web_app_invoke_custom_method",u="web_app_open_scan_qr_popup",_="web_app_read_text_from_clipboard",p="web_app_request_phone",l="web_app_close",g="web_app_close_scan_qr_popup",m="web_app_data_send",b="web_app_expand",w="iframe_ready",v="iframe_will_reload",h="web_app_open_invoice",S="web_app_open_link",f="web_app_open_popup",y="web_app_open_tg_link",q="web_app_ready",k="web_app_request_theme",R="web_app_request_viewport",A="web_app_request_write_access",B="web_app_set_background_color",T="web_app_set_header_color",P="web_app_set_bottom_bar_color",I="web_app_setup_back_button",x="web_app_setup_closing_behavior",C="web_app_setup_main_button",O="web_app_setup_settings_button",W="web_app_switch_inline_query",L="web_app_trigger_haptic_feedback",E="web_app_setup_swipe_behavior",j="web_app_share_to_story",F="web_app_request_safe_area",G="web_app_request_content_safe_area",M="web_app_request_fullscreen",D="web_app_exit_fullscreen",H="web_app_toggle_orientation_lock",N="web_app_add_to_home_screen",$="web_app_check_home_screen",Q="web_app_send_prepared_message",U="web_app_set_emoji_status",J="web_app_request_emoji_status_access",V="web_app_request_file_download",z="web_app_biometry_get_info",K="web_app_biometry_open_settings",X="web_app_biometry_request_access",Y="web_app_biometry_request_auth",Z="web_app_biometry_update_token";var ee=(e=>(e[e.InvokeCustomMethod=d]="InvokeCustomMethod",e[e.OpenScanQrPopup=u]="OpenScanQrPopup",e[e.ReadTextFromClipboard=_]="ReadTextFromClipboard",e[e.RequestPhone=p]="RequestPhone",e[e.Close=l]="Close",e[e.CloseScanQrPopup=g]="CloseScanQrPopup",e[e.DataSend=m]="DataSend",e[e.Expand=b]="Expand",e[e.IframeReady=w]="IframeReady",e[e.IframeWillReload=v]="IframeWillReload",e[e.OpenInvoice=h]="OpenInvoice",e[e.OpenLink=S]="OpenLink",e[e.OpenPopup=f]="OpenPopup",e[e.OpenTgLink=y]="OpenTgLink",e[e.Ready=q]="Ready",e[e.RequestTheme=k]="RequestTheme",e[e.RequestViewport=R]="RequestViewport",e[e.RequestWriteAccess=A]="RequestWriteAccess",e[e.SetBackgroundColor=B]="SetBackgroundColor",e[e.SetHeaderColor=T]="SetHeaderColor",e[e.SetBottomBarColor=P]="SetBottomBarColor",e[e.SetupBackButton=I]="SetupBackButton",e[e.SetupClosingBehavior=x]="SetupClosingBehavior",e[e.SetupMainButton=C]="SetupMainButton",e[e.SetupSettingsButton=O]="SetupSettingsButton",e[e.SwitchInlineQuery=W]="SwitchInlineQuery",e[e.TriggerHapticFeedback=L]="TriggerHapticFeedback",e[e.SetupSwipeBehavior=E]="SetupSwipeBehavior",e[e.ShareToStory=j]="ShareToStory",e[e.RequestSafeArea=F]="RequestSafeArea",e[e.RequestContentSafeArea=G]="RequestContentSafeArea",e[e.RequestFullscreen=M]="RequestFullscreen",e[e.ExitFullscreen=D]="ExitFullscreen",e[e.ToggleOrientationLock=H]="ToggleOrientationLock",e[e.AddToHomeScreen=N]="AddToHomeScreen",e[e.CheckHomeScreen=$]="CheckHomeScreen",e[e.SendPreparedMessage=Q]="SendPreparedMessage",e[e.SetEmojiStatus=U]="SetEmojiStatus",e[e.RequestEmojiStatusAccess=J]="RequestEmojiStatusAccess",e[e.RequestFileDownload=V]="RequestFileDownload",e))(ee||{});const te="back_button_pressed",se="clipboard_text_received",ae="custom_method_invoked",oe="invoice_closed",re="main_button_pressed",ie="phone_requested",ne="popup_closed",ce="reload_iframe",de="qr_text_received",ue="scan_qr_popup_closed",_e="set_custom_style",pe="settings_button_pressed",le="theme_changed",ge="viewport_changed",me="write_access_requested",be="safe_area_changed",we="content_safe_area_changed",ve="prepared_message_sent",he="prepared_message_failed",Se="emoji_status_set",fe="emoji_status_failed",ye="emoji_status_access_requested",qe="file_download_requested",ke="accelerometer_changed",Re="accelerometer_failed",Ae="accelerometer_started",Be="accelerometer_stopped",Te="biometry_auth_requested",Pe="biometry_info_received",Ie="biometry_token_updated",xe="device_orientation_changed",Ce="device_orientation_failed",Oe="device_orientation_started",We="device_orientation_stopped",Le="fullscreen_changed",Ee="fullscreen_failed",je="gyroscope_changed",Fe="gyroscope_failed",Ge="gyroscope_started",Me="gyroscope_stopped",De="home_screen_added",He="home_screen_checked",Ne="home_screen_failed",$e="location_checked",Qe="location_requested",Ue="secondary_button_pressed",Je="visibility_changed",Ve="web",ze="phone",Ke="desktop",Xe=()=>{const e=window.location.hash.slice(1),t=new URLSearchParams(e).get("tgWebAppPlatform")??"ios";return["android","ios"].includes(t)?ze:["tdesktop","macos"].includes(t)?Ke:Ve},Ye="not_supported",Ze=(e,t)=>{const s=new URLSearchParams(window.location.hash.slice(1)).get("tgWebAppVersion");return Number(s?.replace(".",""))>=Number(String(e)?.replace(".",""))&&-1!==t.indexOf(Xe())},et=()=>Math.random().toString(36).substring(3,9),tt=e=>{var t;if(t=/^\s*#([0-9a-f]{6})\s*$/i.exec(e+=""))return"#"+t[1].toLowerCase();if(t=/^\s*#([0-9a-f])([0-9a-f])([0-9a-f])\s*$/i.exec(e))return("#"+t[1]+t[1]+t[2]+t[2]+t[3]+t[3]).toLowerCase();if(t=/^\s*rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*(\d+\.{0,1}\d*))?\)\s*$/.exec(e)){var s=parseInt(t[1]),a=parseInt(t[2]),o=parseInt(t[3]);return"#"+((s<16?"0":"")+s.toString(16))+((a<16?"0":"")+a.toString(16))+((o<16?"0":"")+o.toString(16))}return!1},st=e=>{const t=window.location.hash.slice(1),s=new URLSearchParams(t),a=JSON.parse(s.get("tgWebAppThemeParams")??""),o=e||a;for(var r of Object.keys(o)){var i=tt(o[r]);"string"==typeof i&&(o[r]=i)}return"#1c1c1d"==o?.bg_color&&o?.bg_color==o?.secondary_bg_color&&(o.secondary_bg_color="#2c2c2e"),o},at=((e=new Map)=>({once:(t,s,a=e.get(t),o=e=>{s(e),a&&a.splice(a.indexOf(s)>>>0,1)})=>a?a.push(o):e.set(t,[o]),on:(t,s,a=e.get(t))=>a?a.push(s):e.set(t,[s]),off:(t,s,a=e.get(t))=>a&&s?a.splice(a.indexOf(s)>>>0,1):e.set(t,[]),emit:(t,s,a=e.get(t)||[])=>{for(const e of a)e(s)}}))();(()=>{function e(e,t){e===le&&(t.theme_params=st(t.theme_params)),at.emit(e,t),at.emit("*",{name:e,data:t})}window.TelegramGameProxy_receiveEvent=e,window.Telegram={WebView:{receiveEvent:e}},window.TelegramGameProxy={receiveEvent:e}})();const ot=(e,t)=>{at.on(e,t)},rt=(e,t)=>{at.off(e,t)},it=(e,t)=>{at.once(e,t)};var nt=Object.freeze({__proto__:null,off:rt,on:ot,once:it});const ct=()=>{const[a,o]=e({height:0,is_expanded:!1,is_state_stable:!1}),r=e=>o(e);return t((()=>{ot(ge,r),c(R)})),s((()=>{rt(ge,r)})),a},dt=e=>ut()?(c(l,e),{status:!0}):(n(l,1),{status:Ye}),ut=()=>Ze(0,[Ve,Ke,ze]),_t=e=>pt()?(c(g,e),{status:!0}):(n(g,1),{status:Ye}),pt=()=>Ze(6.4,[ze]),lt=e=>gt()?(c(m,e),{status:!0}):(n(m,1),{status:Ye}),gt=()=>Ze(0,[Ve,Ke,ze]),mt=e=>bt()?(c(b,e),{status:!0}):(n(b,1),{status:Ye}),bt=()=>Ze(0,[ze]),wt=e=>vt()?(c(w,e),{status:!0}):(n(w,1),{status:Ye}),vt=()=>Ze(0,[Ve]),ht=()=>St()?(c(w),{status:!0}):(n(w,1),{status:Ye}),St=()=>Ze(0,[Ve]),ft=async e=>yt()?(void 0===e.req_id&&(e.req_id=et()),c(d,e),new Promise(((t,s)=>{const a=s=>{s.req_id===e.req_id&&(t({status:!0,data:s}),rt(ae,a))};ot(ae,a)}))):(n(d,1),{status:Ye}),yt=()=>Ze(6.9,[Ve,Ke,ze]),qt=e=>kt()?(c(h,e),{status:!0}):(n(h,1),{status:Ye}),kt=()=>Ze(6.1,[Ve,Ke,ze]),Rt=e=>At()?(c(S,e),{status:!0}):(n(S,1),{status:Ye}),At=()=>Ze(6.4,[Ve,Ke,ze]),Bt=async e=>Tt()?(e.title.length>64&&n(f,3),e.message.length<1&&n(f,4),e.message.length>256&&n(f,5),e.buttons.length<1&&n(f,6),e.buttons.length>3&&n(f,7),void 0!==e.buttons.find((e=>e.text?.match(/^(ok|close|cancel)$/g)))&&n(f,8),c(f,e),new Promise(((t,s)=>{const a=s=>{t({status:!!e.buttons.find((e=>e.id===s?.button_id)),data:s}),rt(ne,a)};ot(ne,a)}))):(n(f,1),{status:Ye}),Tt=()=>Ze(6.2,[Ve,Ke,ze]),Pt=async e=>It()?(c(u,e),new Promise(((t,s)=>{it(de,(s=>{e.is_close&&_t(),t({status:!0,data:s})})),it(ue,(()=>{t({status:"closed"})}))}))):(n(u,1),{status:Ye}),It=()=>Ze(6.4,[ze]),xt=e=>{const t=function(e){try{return new URL(e)}catch(t){try{return new URL(e,"https://t.me")}catch(t){return e.startsWith("/")||(e="/"+e),new URL(e,"https://t.me")}}}(e.path_full);return e.path_full=t.pathname=t.search,Ct()?(c(y,e),{status:!0}):(n(y,1),{status:Ye})},Ct=()=>Ze(7,[Ve,Ke,ze]);const Ot=async e=>Wt()?(e||(e={req_id:void 0}),void 0===e.req_id&&(e.req_id=et()),c(_,e),new Promise(((t,s)=>{const a=s=>{s.req_id===e?.req_id&&(t({status:!0,data:s}),rt(se,a))};ot(se,a)}))):(n(_,1),{status:Ye}),Wt=()=>Ze(6.4,[Ve,Ke,ze]),Lt=e=>Et()?(c(q,e),{status:!0}):(n(q,1),{status:Ye}),Et=()=>Ze(6.9,[Ve,Ke,ze]),jt=async()=>Ft()?(c(p),new Promise(((e,t)=>{it(ie,(t=>{"sent"===t.status&&e({status:!0}),e({status:!1})}))}))):(n(p,1),{status:Ye}),Ft=()=>Ze(6.9,[Ve,Ke,ze]),Gt=e=>Mt()?(c(k,e),{status:!0}):(n(k,1),{status:Ye}),Mt=()=>Ze(0,[Ve,Ke,ze]),Dt=e=>Ht()?(c(R,e),{status:!0}):(n(R,1),{status:Ye}),Ht=()=>Ze(0,[Ve,Ke,ze]),Nt=()=>new Promise(((e,t)=>{if(!$t())return n(A,1),void e({status:Ye});const s=t=>{e({status:"allowed"===t.status}),rt(me,s)};ot(me,s),c(A)})),$t=()=>Ze(6.9,[Ve,Ke,ze]),Qt=e=>Ut()?(c(B,e),{status:!0}):(n(B,1),{status:Ye}),Ut=()=>Ze(6.1,[Ve,Ke,ze]),Jt=e=>Vt()?(c(T,e),{status:!0}):(n(T,1),{status:Ye}),Vt=()=>Ze(6.1,[Ve,Ke,ze]),zt=e=>Kt()?(c(P,{color:e?.color||e?.color_key}),{status:!0}):(n(P,1),{status:Ye}),Kt=()=>Ze(7.1,[Ve,Ke,ze]),Xt=e=>Yt()?(c(I,e),{status:!0}):(n(I,1),{status:Ye}),Yt=()=>Ze(6.1,[Ve,Ke,ze]),Zt=e=>es()?(c(x,e),{status:!0}):(n(x,1),{status:Ye}),es=()=>Ze(6.2,[Ve,Ke,ze]),ts=e=>ss()?(c(C,e),{status:!0}):(n(C,1),{status:Ye}),ss=()=>Ze(0,[Ve,Ke,ze]),as=e=>os()?(c(O,e),{status:!0}):(n(O,1),{status:Ye}),os=()=>Ze(6.1,[Ve,Ke,ze]),rs=e=>is()?(e.query.length>256&&n(W,9),c(W,e),{status:!0}):(n(W,1),{status:Ye}),is=()=>Ze(6.7,[Ve,Ke,ze]),ns=e=>cs()?(c(L,e),{status:!0}):(n(L,1),{status:Ye}),cs=()=>Ze(6.1,[ze]),ds=({key:e,value:t})=>{try{return window.sessionStorage.setItem("__telegram__"+e,JSON.stringify(t)),{status:!0}}catch(s){return window.sessionStorage.setItem("__telegram__"+e,t),{status:!0}}},us=()=>!0,_s=({key:e})=>{try{return{is_json:!0,value:JSON.parse(window.sessionStorage.getItem("__telegram__"+e)??""),status:!0}}catch(t){return{is_json:!1,value:window.sessionStorage.getItem("__telegram__"+e)??"",status:!0}}},ps=()=>!0,ls=e=>gs()?(c(E,e),{status:!0}):(n(E,1),{status:Ye}),gs=()=>Ze(7.7,[Ve,Ke,ze]),ms=e=>bs()?e?.text&&e?.text.length>2048?(console.warn(`[@apiteam/twa-bridge](${j}) | Text is too long`),{status:!1,error_id:1}):e?.widget_link?.name&&e?.widget_link.name.length>48?(console.warn(`[@apiteam/twa-bridge](${j}) | Link name is too long`),{status:!1,error_id:2}):(c(j,e),{status:!0}):(n(j,1),{status:Ye}),bs=()=>Ze(7.8,[Ve,Ke,ze]),ws=async e=>new Promise(((t,s)=>{if(!vs())return n($,1),void t({status:Ye,data:void 0});const a=e=>{e.status=e.status||"unknown",t({status:!0,data:e}),rt(He,a)};ot(He,a),c($,e)})),vs=()=>Ze(8,[Ke,ze]),hs=()=>Ss()?(c(N),{status:!0}):(n(N,1),{status:Ye}),Ss=()=>Ze(8,[Ke,ze]),fs=()=>ys()?(c(F),{status:!0}):(n(F,1),{status:Ye}),ys=()=>Ze(8,[Ve,Ke,ze]),qs=()=>ks()?(c(G),{status:!0}):(n(G,1),{status:Ye}),ks=()=>Ze(8,[Ve,Ke,ze]),Rs=e=>{const t=e?.is_full||!1;return As()?(c(t?M:D),{status:!0}):(n(t?M:D,1),{status:Ye})},As=()=>Ze(8,[Ve,Ke,ze]),Bs=e=>Ts()?(c(H,e),{status:!0}):(n(H,1),{status:Ye}),Ts=()=>Ze(8,[Ve,Ke,ze]),Ps=async e=>Is()?new Promise(((t,s)=>{it(ye,(function(e){t({status:"allowed"===e.status})})),c(J,e)})):(n(J,1),{status:Ye}),Is=()=>Ze(8,[Ve,Ke,ze]),xs=async e=>Cs()?new Promise(((t,s)=>{it(Se,(()=>t({status:!0}))),it(fe,(()=>t({status:!1}))),c(U,e)})):(n(U,1),{status:Ye}),Cs=()=>Ze(8,[Ve,Ke,ze]),Os=async e=>Ws()?new Promise(((t,s)=>{it(ve,(()=>t({status:!0}))),it(he,(()=>t({status:!1}))),c(Q,e)})):(n(Q,1),{status:Ye}),Ws=()=>Ze(8,[Ve,Ke,ze]),Ls=async e=>Es()?new Promise(((t,s)=>{it(qe,(function(e){t({status:"downloading"===e.status})})),c(V,e)})):(n(V,1),{status:Ye}),Es=()=>Ze(8,[Ve,Ke,ze]),[js,Fs]=r({isInited:!1,isBiometricAvailable:!1,isAccessGranted:!1,isAccessRequested:!1,isBiometricTokenSaved:!1,biometricType:"unknown",deviceId:""}),Gs={isInited:js.isInited,isBiometricAvailable:js.isBiometricAvailable,isAccessGranted:js.isAccessGranted,isAccessRequested:js.isAccessRequested,isBiometricTokenSaved:js.isBiometricTokenSaved,biometricType:js.biometricType,deviceId:js.deviceId,init:()=>new Promise(((e,t)=>{if(!Ms())return n(z,1),void e({status:Ye,data:void 0});const s=t=>{Ds(t),e({status:!0,data:js}),rt(Pe,s)};ot(Pe,s),c(z)})),requestAccess:e=>new Promise(((t,s)=>{if(!Ms())return n(X,1),void t({status:Ye,data:void 0});if(e.reason&&e.reason.length>128)return console.error(`[${X}] Biometric reason is too long`,e.reason),void t({status:!1,data:void 0});const a=e=>{Ds(e),t({status:!0,data:js}),rt(Pe,a)};ot(Pe,a),c(X,e)})),authenticate:e=>new Promise(((t,s)=>{if(!Ms())return n(Y,1),void t({status:Ye,data:void 0});if(!js.isBiometricAvailable)return console.error("[Telegram.WebApp] Biometrics is not available on this device."),void t({status:!1,data:void 0});if(!js.isAccessGranted)return console.error("[Telegram.WebApp] Biometric access was not granted by the user."),void t({status:!1,data:void 0});const a=e=>{t({status:!0,data:e}),rt(Te,a)};ot(Te,a),c(Y,e)})),updateToken:e=>new Promise(((t,s)=>{if(!Ms())return n(Z,1),void t({status:Ye,data:void 0});if(!js.isBiometricAvailable)return console.error("[Telegram.WebApp] Biometrics is not available on this device."),void t({status:!1,data:void 0});if(!js.isAccessGranted)return console.error("[Telegram.WebApp] Biometric access was not granted by the user."),void t({status:!1,data:void 0});const a=e=>{t({status:!0,data:e}),rt(Ie,a)};ot(Ie,a),c(Z,e)})),openSettings:e=>Ms()?js.isBiometricAvailable?js.isAccessRequested?js.isAccessGranted?(console.warn("[Telegram.WebApp] Biometric access was granted by the user, no need to go to settings."),{status:!1}):(c(K,e),{status:!0}):(console.error("[Telegram.WebApp] Biometric access was not granted by the user."),{status:!1}):(console.error("[Telegram.WebApp] Biometrics is not available on this device."),{status:!1}):(n(K,1),{status:Ye})},Ms=()=>Ze(7.2,[Ke,ze,Ve]),Ds=e=>{Fs(i((t=>(e.available?(t.isBiometricAvailable=!0,t.biometricType=e.type||"",e.access_requested?(t.isAccessRequested=!0,t.isAccessGranted=!!e.access_granted,t.isBiometricTokenSaved=!!e.token_saved):(t.isAccessRequested=!1,t.isAccessGranted=!1,t.isBiometricTokenSaved=!1)):(t.isBiometricAvailable=!1,t.biometricType="unknown",t.isAccessRequested=!1,t.isAccessGranted=!1,t.isBiometricTokenSaved=!1),t.deviceId=e.device_id||"",t.isInited=!0,t))))},Hs=e=>{Fs(i((t=>(t.isBiometricAvailable&&t.isAccessRequested&&("updated"===e.status?t.isBiometricTokenSaved=!0:"removed"===e.status&&(t.isBiometricTokenSaved=!1)),t))))};t((()=>{ot(Pe,Ds),ot(Ie,Hs),s((()=>{rt(Pe,Ds),rt(Ie,Hs)}))}));const Ns=()=>{const e=window.location.hash.slice(1),t=new URLSearchParams(e).get("tgWebAppData");if(!t)return void n("getInitData",2);const s=new URLSearchParams(t);let a={};return s.forEach(((e,t)=>{if(a[t]=e,void 0!==t.match(/^(chat|receiver|user)$/g))try{a[t]=JSON.parse(e)}catch{}})),a},$s=()=>{const e=window.location.hash.slice(1);return new URLSearchParams(e).get("tgWebAppData")},Qs=a({viewport:void 0,theme:void 0,init:void 0}),Us=e=>{const[t,a]=r({viewport:void 0,theme:void 0,init:void 0});return o((()=>{const e=()=>{a("init",Ns())};e();const t=t=>{e(),a("viewport",t)};ot(ge,t),Dt();const o=t=>{e(),a("theme",t)};return ot(le,o),Dt(),s((()=>{rt(ge,t),rt(le,o)})),()=>{rt(ge,t),rt(le,o)}})),Qs.Provider({value:t,children:e.children})};export{Qs as ContextTwa,ke as EventAccelerometerChanged,Re as EventAccelerometerFailed,Ae as EventAccelerometerStarted,Be as EventAccelerometerStopped,te as EventBackButtonPressed,Te as EventBiometryAuthRequested,Pe as EventBiometryInfoReceived,Ie as EventBiometryTokenUpdated,se as EventClipboardTextReceived,we as EventContentSafeAreaChanged,ae as EventCustomMethodInvoked,xe as EventDeviceOrientationChanged,Ce as EventDeviceOrientationFailed,Oe as EventDeviceOrientationStarted,We as EventDeviceOrientationStopped,ye as EventEmojiStatusAccessRequested,fe as EventEmojiStatusFailed,Se as EventEmojiStatusSet,qe as EventFileDownloadRequested,Le as EventFullscreenChanged,Ee as EventFullscreenFailed,je as EventGyroscopeChanged,Fe as EventGyroscopeFailed,Ge as EventGyroscopeStarted,Me as EventGyroscopeStopped,De as EventHomeScreenAdded,He as EventHomeScreenChecked,Ne as EventHomeScreenFailed,oe as EventInvoiceClosed,$e as EventLocationChecked,Qe as EventLocationRequested,re as EventMainButtonPressed,ie as EventPhoneRequested,ne as EventPopupClosed,he as EventPreparedMessageFailed,ve as EventPreparedMessageSent,de as EventQrTextReceived,ce as EventReloadIframe,be as EventSafeAreaChanged,ue as EventScanQrPopupClosed,Ue as EventSecondaryButtonPressed,_e as EventSetCustomStyle,pe as EventSettingsButtonPressed,le as EventThemeChanged,ge as EventViewportChanged,Je as EventVisibilityChanged,me as EventWriteAccessRequested,ee as Method,N as MethodAddToHomeScreen,$ as MethodCheckHomeScreen,l as MethodClose,g as MethodCloseScanQrPopup,m as MethodDataSend,D as MethodExitFullscreen,b as MethodExpand,w as MethodIframeReady,v as MethodIframeWillReload,d as MethodInvokeCustomMethod,h as MethodOpenInvoice,S as MethodOpenLink,f as MethodOpenPopup,u as MethodOpenScanQrPopup,y as MethodOpenTgLink,_ as MethodReadTextFromClipboard,q as MethodReady,G as MethodRequestContentSafeArea,J as MethodRequestEmojiStatusAccess,V as MethodRequestFileDownload,M as MethodRequestFullscreen,p as MethodRequestPhone,F as MethodRequestSafeArea,k as MethodRequestTheme,R as MethodRequestViewport,A as MethodRequestWriteAccess,Q as MethodSendPreparedMessage,B as MethodSetBackgroundColor,P as MethodSetBottomBarColor,U as MethodSetEmojiStatus,T as MethodSetHeaderColor,I as MethodSetupBackButton,x as MethodSetupClosingBehavior,C as MethodSetupMainButton,O as MethodSetupSettingsButton,E as MethodSetupSwipeBehavior,j as MethodShareToStory,W as MethodSwitchInlineQuery,H as MethodToggleOrientationLock,L as MethodTriggerHapticFeedback,Ye as NOT_SUPPORTED,Us as ProviderTWA,Ke as TG_DESKTOP,ze as TG_PHONE,Ve as TG_WEB,hs as bridgeAddToHomeScreen,Gs as bridgeBiometricManager,ws as bridgeCheckHomeScreen,dt as bridgeClose,_t as bridgeCloseScanQrPopup,lt as bridgeDataSend,Ls as bridgeDownloadFile,mt as bridgeExpand,Ns as bridgeGetInitData,st as bridgeGetThemeParams,wt as bridgeIframeReady,ht as bridgeIframeWillReload,ft as bridgeInvokeCustomMethod,qt as bridgeOpenInvoice,Rt as bridgeOpenLink,Bt as bridgeOpenPopup,Pt as bridgeOpenScanQrPopup,xt as bridgeOpenTgLink,Ot as bridgeReadTextFromClipboard,Lt as bridgeReady,qs as bridgeRequestContentSafeAreaInset,Ps as bridgeRequestEmojiStatus,jt as bridgeRequestPhone,fs as bridgeRequestSafeAreaInset,Gt as bridgeRequestTheme,Dt as bridgeRequestViewport,Nt as bridgeRequestWriteAccess,c as bridgeSend,_s as bridgeSessionStorageGet,ds as bridgeSessionStorageSet,Qt as bridgeSetBackgroundColor,zt as bridgeSetBottomBarColor,xs as bridgeSetEmojiStatus,Jt as bridgeSetHeaderColor,Xt as bridgeSetupBackButton,Zt as bridgeSetupClosingBehavior,Rs as bridgeSetupFullScreen,ts as bridgeSetupMainButton,Bs as bridgeSetupOrientation,as as bridgeSetupSettingsButton,ls as bridgeSetupSwipeBehavior,Os as bridgeShareMessage,ms as bridgeShareToStory,rs as bridgeSwitchInlineQuery,ns as bridgeTriggerHapticFeedback,ct as createIsViewportChanged,n as debug,$s as getAppData,Xe as getPlatform,nt as listener,c as sender,Ss as supportAddToHomeScreen,Ms as supportBiometricManager,vs as supportCheckHomeScreen,ut as supportClose,pt as supportCloseScanQrPopup,gt as supportDataSend,Es as supportDownloadFile,bt as supportExpand,vt as supportIframeReady,St as supportIframeWillReload,yt as supportInvokeCustomMethod,kt as supportOpenInvoice,At as supportOpenLink,Tt as supportOpenPopup,It as supportOpenScanQrPopup,Ct as supportOpenTgLink,Wt as supportReadTextFromClipboard,Et as supportReady,ks as supportRequestContentSafeAreaInset,Is as supportRequestEmojiStatus,Ft as supportRequestPhone,ys as supportRequestSafeAreaInset,Mt as supportRequestTheme,Ht as supportRequestViewport,$t as supportRequestWriteAccess,ps as supportSessionStorageGet,us as supportSessionStorageSet,Ut as supportSetBackgroundColor,Kt as supportSetBottomBarColor,Cs as supportSetEmojiStatus,Vt as supportSetHeaderColor,Yt as supportSetupBackButton,es as supportSetupClosingBehavior,As as supportSetupFullScreen,ss as supportSetupMainButton,Ts as supportSetupOrientation,os as supportSetupSettingsButton,gs as supportSetupSwipeBehavior,Ws as supportShareMessage,bs as supportShareToStory,is as supportSwitchInlineQuery,cs as supportTriggerHapticFeedback};
|