@apiteam/twa-bridge 8.0.7 → 8.0.9

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