New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@telegram-apps/bridge

Package Overview
Dependencies
Maintainers
4
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@telegram-apps/bridge - npm Package Compare versions

Comparing version 2.1.0 to 2.2.0

214

dist/dts/events/types/events.d.ts

@@ -10,2 +10,44 @@ import { RGB } from '@telegram-apps/types';

/**
* Accelerometer data changed.
* @since 8.0
* @see https://docs.telegram-mini-apps.com/platform/events#accelerometer-changed
*/
accelerometer_changed: {
/**
* The current acceleration in the X-axis, measured in m/s².
*/
x: number;
/**
* The current acceleration in the Y-axis, measured in m/s².
*/
y: number;
/**
* The current acceleration in the Z-axis, measured in m/s².
*/
z: number;
};
/**
* Failed to start accelerometer data tracking.
* @since 8.0
* @see https://docs.telegram-mini-apps.com/platform/events#accelerometer-failed
*/
accelerometer_failed: {
/**
* Occurred error.
*/
error: string;
};
/**
* Accelerometer data tracking started.
* @since 8.0
* @see https://docs.telegram-mini-apps.com/platform/events#accelerometer-started
*/
accelerometer_started: never;
/**
* Accelerometer data tracking stopped.
* @since 8.0
* @see https://docs.telegram-mini-apps.com/platform/events#accelerometer-stopped
*/
accelerometer_stopped: never;
/**
* User clicked the BackButton.

@@ -143,2 +185,49 @@ * @since v6.1

/**
* Device orientation data changed.
* @since 8.0
* @see https://docs.telegram-mini-apps.com/platform/events#device-orientation-changed
*/
device_orientation_changed: {
/**
* A boolean that indicates whether the device is providing orientation data in
* absolute values.
*/
absolute?: Maybe<boolean>;
/**
* The rotation around the Z-axis, measured in radians.
*/
alpha: number;
/**
* The rotation around the X-axis, measured in radians.
*/
beta: number;
/**
* The rotation around the Y-axis, measured in radians.
*/
gamma: number;
};
/**
* Device orientation data tracking failed to start.
* @since 8.0
* @see https://docs.telegram-mini-apps.com/platform/events#device-orientation-failed
*/
device_orientation_failed: {
/**
* Occurred error.
*/
error: string;
};
/**
* Device orientation data tracking started.
* @since 8.0
* @see https://docs.telegram-mini-apps.com/platform/events#device-orientation-started
*/
device_orientation_started: never;
/**
* Device orientation data tracking stopped.
* @since 8.0
* @see https://docs.telegram-mini-apps.com/platform/events#device-orientation-stopped
*/
device_orientation_stopped: never;
/**
* Request to set custom emoji status was requested.

@@ -169,2 +258,10 @@ * @see https://docs.telegram-mini-apps.com/platform/events#emoji-status-access-requested

/**
* Application received file download request status.
* @since 8.0
* @see https://docs.telegram-mini-apps.com/platform/events#file-download-requested
*/
file_download_requested: {
status?: Maybe<'downloading' | string>;
};
/**
* App entered or exited fullscreen mode.

@@ -192,2 +289,44 @@ * @since v8.0

/**
* Gyroscope data changed.
* @since 8.0
* @see https://docs.telegram-mini-apps.com/platform/events#gyroscope-changed
*/
gyroscope_changed: {
/**
* The current rotation rate around the X-axis, measured in rad/s.
*/
x: number;
/**
* The current rotation rate around the Y-axis, measured in rad/s.
*/
y: number;
/**
* The current rotation rate around the Z-axis, measured in rad/s.
*/
z: number;
};
/**
* Gyroscope data tracking failed to run.
* @since 8.0
* @see https://docs.telegram-mini-apps.com/platform/events#gyroscope-failed
*/
gyroscope_failed: {
/**
* Occurred error.
*/
error: string;
};
/**
* Gyroscope data tracking started.
* @since 8.0
* @see https://docs.telegram-mini-apps.com/platform/events#gyroscope-started
*/
gyroscope_started: never;
/**
* Gyroscope data tracking stopped.
* @since 8.0
* @see https://docs.telegram-mini-apps.com/platform/events#gyroscope-stopped
*/
gyroscope_stopped: never;
/**
* The mini application was added to the device's home screen.

@@ -238,2 +377,60 @@ * @since v8.0

/**
* Checks the location-related functionality availability state.
* @since 8.0
* @see https://docs.telegram-mini-apps.com/platform/events#location-checked
*/
location_checked: {
available: false;
} | {
available: true;
access_requested?: Maybe<boolean>;
access_granted?: Maybe<boolean>;
};
/**
* Location-related functionality availability status was retrieved.
* @since 8.0
* @see https://docs.telegram-mini-apps.com/platform/events#location-requested
*/
location_requested: {
available: false;
} | {
available: true;
/**
* Latitude in degrees.
*/
latitude: number;
/**
* Longitude in degrees.
*/
longitude: number;
/**
* Altitude above sea level in meters.
*/
altitude?: Maybe<number>;
/**
* The direction the device is moving in degrees.
*/
course?: Maybe<number>;
/**
* The speed of the device in m/s.
*/
speed?: Maybe<number>;
/**
* Accuracy of the latitude and longitude values in meters.
*/
horizontal_accuracy?: Maybe<number>;
/**
* Accuracy of the altitude value in meters.
*/
vertical_accuracy?: Maybe<number>;
/**
* Accuracy of the course value in degrees.
*/
course_accuracy?: Maybe<number>;
/**
* Accuracy of the speed value in m/s.
*/
speed_accuracy?: Maybe<number>;
};
/**
* A user clicked the Main Button.

@@ -266,2 +463,19 @@ * @see https://docs.telegram-mini-apps.com/platform/events#main-button-pressed

/**
* Failed to send a prepared message.
* @since 8.0
* @see https://docs.telegram-mini-apps.com/platform/events#prepare-message-failed
*/
prepared_message_failed: {
/**
* Occurred error.
*/
error: string;
};
/**
* A prepared message was sent.
* @since 8.0
* @see https://docs.telegram-mini-apps.com/platform/events#prepare-message-sent
*/
prepared_message_sent: never;
/**
* The QR scanner scanned some QR and extracted its content.

@@ -268,0 +482,0 @@ * @param payload - event payload.

@@ -157,2 +157,8 @@ import { If, IsNever } from '@telegram-apps/toolkit';

/**
* Requests location-related functionality availability state.
* @since v8.0
* @see https://docs.telegram-mini-apps.com/platform/methods#web-app-check-location
*/
web_app_check_location: CreateMethodParams;
/**
* Closes Mini App.

@@ -240,2 +246,12 @@ * @see https://docs.telegram-mini-apps.com/platform/methods#web-app-close

/**
* Opens the location access settings for bots. Useful when you need to request location access
* from users who haven't granted it yet.
*
* Note that this method can be called only in response to user interaction with the Mini App
* interface (e.g., a click inside the Mini App or on the main button).
* @since v8.0
* @see https://docs.telegram-mini-apps.com/platform/methods#web-app-open-location-settings
*/
web_app_open_location_settings: CreateMethodParams;
/**
* Opens a new popup. When a user closes the popup, Telegram creates the `popup_closed` event.

@@ -304,2 +320,17 @@ * @since v6.2

/**
* Displays a native popup prompting the user to download a file.
* @since v8.0
* @see https://docs.telegram-mini-apps.com/platform/methods#web-app-request-file-download
*/
web_app_request_file_download: CreateMethodParams<{
/**
* The HTTPS URL of the file to be downloaded.
*/
url: string;
/**
* The suggested name for the downloaded file.
*/
file_name: string;
}>;
/**
* Requests to open the mini app in fullscreen.

@@ -311,2 +342,8 @@ * @since v8.0

/**
* Requests location data.
* @since v8.0
* @see https://docs.telegram-mini-apps.com/platform/methods#web-app-request-location
*/
web_app_request_location: CreateMethodParams;
/**
* Requests access to current user's phone.

@@ -341,2 +378,15 @@ * @since v6.9

/**
* Opens a dialog allowing the user to share a message provided by the bot.
* @since v8.0
* @see https://docs.telegram-mini-apps.com/platform/methods#web-app-send-prepared-message
*/
web_app_send_prepared_message: CreateMethodParams<{
/**
* Identifier of the message
* ([PreparedInlineMessage](https://core.telegram.org/bots/api#preparedinlinemessage)) previously obtained via the Bot API method
* [savePreparedInlineMessage](https://core.telegram.org/bots/api#savepreparedinlinemessage).
*/
id: string;
}>;
/**
* Updates the Mini App background color.

@@ -490,2 +540,68 @@ * @since v6.1

/**
* Starts tracking accelerometer data.
* @since v8.0
* @see https://docs.telegram-mini-apps.com/platform/methods#web-app-start-accelerometer
*/
web_app_start_accelerometer: CreateMethodParams<{
/**
* The refresh rate in milliseconds, with acceptable values ranging from 20 to 1000.
* Note that refresh_rate may not be supported on all platforms, so the actual tracking
* frequency may differ from the specified value.
*/
refresh_rate: number;
}>;
/**
* Starts tracking device orientation data.
* @since v8.0
* @see https://docs.telegram-mini-apps.com/platform/methods#web-app-start-device-orientation
*/
web_app_start_device_orientation: CreateMethodParams<{
/**
* The refresh rate in milliseconds, with acceptable values ranging from 20 to 1000.
* Note that refresh_rate may not be supported on all platforms, so the actual tracking
* frequency may differ from the specified value.
*/
refresh_rate: number;
/**
* Pass true to receive absolute orientation data, allowing you to determine the device's
* attitude relative to magnetic north. Use this option if implementing features like a
* compass in your app. If relative data is sufficient, pass false.
*
* Keep in mind that some devices may not support absolute orientation data. In such cases,
* you will receive relative data even if need_absolute=true is passed.
*/
need_absolute?: boolean;
}>;
/**
* Starts tracking gyroscope data.
* @since v8.0
* @see https://docs.telegram-mini-apps.com/platform/methods#web-app-start-gyroscope
*/
web_app_start_gyroscope: CreateMethodParams<{
/**
* The refresh rate in milliseconds, with acceptable values ranging from 20 to 1000.
* Note that refresh_rate may not be supported on all platforms, so the actual tracking
* frequency may differ from the specified value.
*/
refresh_rate: number;
}>;
/**
* Stops tracking accelerometer data.
* @since v8.0
* @see https://docs.telegram-mini-apps.com/platform/methods#web-app-stop-accelerometer
*/
web_app_stop_accelerometer: CreateMethodParams;
/**
* Stops tracking device orientation data.
* @since v8.0
* @see https://docs.telegram-mini-apps.com/platform/methods#web-app-stop-device-orientation
*/
web_app_stop_device_orientation: CreateMethodParams;
/**
* Stops tracking gyroscope data.
* @since v8.0
* @see https://docs.telegram-mini-apps.com/platform/methods#web-app-stop-gyroscope
*/
web_app_stop_gyroscope: CreateMethodParams;
/**
* Inserts the bot's username and the specified inline query in the current chat's input field.

@@ -510,2 +626,12 @@ * Query may be empty, in which case only the bot's username will be inserted. The client prompts

/**
* Locks the Mini App’s orientation to its current mode (either portrait or landscape). Once
* locked, the orientation remains fixed, regardless of device rotation. This is useful if a
* stable orientation is needed during specific interactions.
* @since v8.0
* @see https://docs.telegram-mini-apps.com/platform/methods#web-app-toggle-orientation-lock
*/
web_app_toggle_orientation_lock: CreateMethodParams<{
locked: boolean;
}>;
/**
* Generates haptic feedback event.

@@ -512,0 +638,0 @@ * @since v6.1

6

dist/index.iife.js

@@ -1,4 +0,4 @@

this.tapps=this.tapps||{};this.tapps.bridge=function(l){"use strict";var k;function ye(e){return{lang:(e==null?void 0:e.lang)??(k==null?void 0:k.lang),message:e==null?void 0:e.message,abortEarly:(e==null?void 0:e.abortEarly)??(k==null?void 0:k.abortEarly),abortPipeEarly:(e==null?void 0:e.abortPipeEarly)??(k==null?void 0:k.abortPipeEarly)}}var C;function ht(e){return C==null?void 0:C.get(e)}var N;function bt(e){return N==null?void 0:N.get(e)}var O;function mt(e,t){var n;return(n=O==null?void 0:O.get(e))==null?void 0:n.get(t)}function vt(e){var n,r;const t=typeof e;return t==="string"?`"${e}"`:t==="number"||t==="bigint"||t==="boolean"?`${e}`:t==="object"||t==="function"?(e&&((r=(n=Object.getPrototypeOf(e))==null?void 0:n.constructor)==null?void 0:r.name))??"null":t}function A(e,t,n,r,s){const i=s&&"input"in s?s.input:n.value,a=(s==null?void 0:s.expected)??e.expects??null,u=(s==null?void 0:s.received)??vt(i),o={kind:e.kind,type:e.type,input:i,expected:a,received:u,message:`Invalid ${t}: ${a?`Expected ${a} but r`:"R"}eceived ${u}`,requirement:e.requirement,path:s==null?void 0:s.path,issues:s==null?void 0:s.issues,lang:r.lang,abortEarly:r.abortEarly,abortPipeEarly:r.abortPipeEarly},c=e.kind==="schema",p=(s==null?void 0:s.message)??e.message??mt(e.reference,o.lang)??(c?bt(o.lang):null)??r.message??ht(o.lang);p&&(o.message=typeof p=="function"?p(o):p),c&&(n.typed=!1),n.issues?n.issues.push(o):n.issues=[o]}function w(e){return{version:1,vendor:"valibot",validate(t){return e["~run"]({value:t},ye())}}}function _t(e,t){return Object.hasOwn(e,t)&&t!=="__proto__"&&t!=="prototype"&&t!=="constructor"}var gt=class extends Error{constructor(e){super(e[0].message),this.name="ValiError",this.issues=e}};function J(e,t,n){return typeof e.default=="function"?e.default(t,n):e.default}function T(e,t){return!e["~run"]({value:t},{abortEarly:!0}).issues}function he(){return{kind:"schema",type:"any",reference:he,expects:"any",async:!1,get"~standard"(){return w(this)},"~run"(e){return e.typed=!0,e}}}function z(e){return{kind:"schema",type:"boolean",reference:z,expects:"boolean",async:!1,message:e,get"~standard"(){return w(this)},"~run"(t,n){return typeof t.value=="boolean"?t.typed=!0:A(this,"type",t,n),t}}}function G(e){return{kind:"schema",type:"function",reference:G,expects:"Function",async:!1,message:e,get"~standard"(){return w(this)},"~run"(t,n){return typeof t.value=="function"?t.typed=!0:A(this,"type",t,n),t}}}function E(e,t){return{kind:"schema",type:"loose_object",reference:E,expects:"Object",async:!1,entries:e,message:t,get"~standard"(){return w(this)},"~run"(n,r){var i;const s=n.value;if(s&&typeof s=="object"){n.typed=!0,n.value={};for(const a in this.entries){const u=this.entries[a];if(a in s||(u.type==="exact_optional"||u.type==="optional"||u.type==="nullish")&&u.default!==void 0){const o=a in s?s[a]:J(u),c=u["~run"]({value:o},r);if(c.issues){const p={type:"object",origin:"value",input:s,key:a,value:o};for(const f of c.issues)f.path?f.path.unshift(p):f.path=[p],(i=n.issues)==null||i.push(f);if(n.issues||(n.issues=c.issues),r.abortEarly){n.typed=!1;break}}c.typed||(n.typed=!1),n.value[a]=c.value}else if(u.type!=="exact_optional"&&u.type!=="optional"&&u.type!=="nullish"&&(A(this,"key",n,r,{input:void 0,expected:`"${a}"`,path:[{type:"object",origin:"key",input:s,key:a,value:s[a]}]}),r.abortEarly))break}if(!n.issues||!r.abortEarly)for(const a in s)_t(s,a)&&!(a in this.entries)&&(n.value[a]=s[a])}else A(this,"type",n,r);return n}}}function L(e,t){return{kind:"schema",type:"nullish",reference:L,expects:`(${e.expects} | null | undefined)`,async:!1,wrapped:e,default:t,get"~standard"(){return w(this)},"~run"(n,r){return(n.value===null||n.value===void 0)&&(this.default!==void 0&&(n.value=J(this,n,r)),n.value===null||n.value===void 0)?(n.typed=!0,n):this.wrapped["~run"](n,r)}}}function B(e){return{kind:"schema",type:"number",reference:B,expects:"number",async:!1,message:e,get"~standard"(){return w(this)},"~run"(t,n){return typeof t.value=="number"&&!isNaN(t.value)?t.typed=!0:A(this,"type",t,n),t}}}function F(e,t){return{kind:"schema",type:"optional",reference:F,expects:`(${e.expects} | undefined)`,async:!1,wrapped:e,default:t,get"~standard"(){return w(this)},"~run"(n,r){return n.value===void 0&&(this.default!==void 0&&(n.value=J(this,n,r)),n.value===void 0)?(n.typed=!0,n):this.wrapped["~run"](n,r)}}}function P(e){return{kind:"schema",type:"string",reference:P,expects:"string",async:!1,message:e,get"~standard"(){return w(this)},"~run"(t,n){return typeof t.value=="string"?t.typed=!0:A(this,"type",t,n),t}}}function be(){return{kind:"schema",type:"unknown",reference:be,expects:"unknown",async:!1,get"~standard"(){return w(this)},"~run"(e){return e.typed=!0,e}}}function H(e,t,n){const r=e["~run"]({value:t},ye(n));if(r.issues)throw new gt(r.issues);return r.value}function me(...e){return{...e[0],pipe:e,get"~standard"(){return w(this)},"~run"(t,n){for(const r of e)if(r.kind!=="metadata"){if(t.issues&&(r.kind==="schema"||r.kind==="transformation")){t.typed=!1;break}(!t.issues||!n.abortEarly&&!n.abortPipeEarly)&&(t=r["~run"](t,n))}return t}}}function K(e){return T(E({TelegramWebviewProxy:E({postEvent:G()})}),e)}function Q(){try{return window.self!==window.top}catch{return!0}}var wt=Object.defineProperty,Et=(e,t,n)=>t in e?wt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,ve=(e,t,n)=>Et(e,typeof t!="symbol"?t+"":t,n);function kt(e){return t=>t instanceof e}function _e(e,t){t||(t=[]);class n extends Error{constructor(...s){const i=typeof t=="function"?t(...s):typeof t=="string"?[t]:t||[];super(...i),this.name=e}}return Object.defineProperty(n,"name",{value:e}),[n,kt(n)]}const[Pt,Sn]=_e("CancelledError","Promise was canceled"),[$t,An]=_e("TimeoutError",(e,t)=>[`Timeout reached: ${e}ms`,{cause:t}]),ge=Symbol("Resolved");function we(e){return Array.isArray(e)&&e[0]===ge}function jt(e){return[ge,e]}function Ee(e,t){return e.reject=t.reject,e.abort=t.abort,e}let ke=class de extends Promise{constructor(t,n){let r,s;super((i,a)=>{let u,o;typeof t=="function"?(u=t,o=n):o=t;const c=[],p=y=>(...q)=>{const W=y(...q);return c.forEach(jn=>jn()),W},f=new AbortController,{signal:b}=f;s=y=>{!b.aborted&&f.abort(y)};const m=()=>b.reason,x=y=>{const q=()=>{y(m())};b.addEventListener("abort",q,!0);const W=()=>{b.removeEventListener("abort",q,!0)};return c.push(W),W},$n=p(y=>{i(y),s(jt(y))});r=p(y=>{a(y),s(y)}),o||(o={});const{abortSignal:I,rejectOnAbort:lt=!0}=o;if(I)if(I.aborted){const{reason:y}=I;if(lt)return r(y);s(y)}else{const y=()=>{s(I.reason)};I.addEventListener("abort",y),c.push(()=>{I.removeEventListener("abort",y)})}lt&&x(a);const{timeout:fe}=o;if(fe){const y=setTimeout(()=>{s(new $t(fe))},fe);c.push(()=>{clearTimeout(y)})}const ft=()=>b.aborted,dt=()=>we(m()),yt=()=>{const y=m();return we(y)?y[1]:void 0};try{const y=u&&u($n,r,{abortReason:m,abortSignal:b,isAborted:ft,isResolved:dt,onAborted:x,onResolved:q=>x(()=>{dt()&&q(yt())}),resolved:yt,throwIfAborted(){if(ft())throw m()}});y instanceof Promise&&y.catch(r)}catch(y){r(y)}}),ve(this,"abort"),ve(this,"reject"),this.abort=s,this.reject=r}static fn(t,n){return new de(async(r,s,i)=>{try{r(await t(i))}catch(a){s(a)}},n)}static resolve(t){return this.fn(()=>t)}static reject(t){return new de((n,r)=>{r(t)})}cancel(){this.abort(new Pt)}catch(t){return this.then(void 0,t)}finally(t){return Ee(super.finally(t),this)}then(t,n){return Ee(super.then(t,n),this)}};function St(e){return e.replace(/_[a-z]/g,t=>t[1].toUpperCase())}function At(e){return Object.entries(e).reduce((t,[n,r])=>(t[St(n)]=r,t),{})}function Y(e){const t=At(e);for(const n in t){const r=t[n];r&&typeof r=="object"&&!(r instanceof Date)&&(t[n]=Array.isArray(r)?r.map(Y):Y(r))}return t}function Pe(e){return`tapps/${e}`}function $e(e,t){sessionStorage.setItem(Pe(e),JSON.stringify(t))}function Mt(e){const t=sessionStorage.getItem(Pe(e));try{return t?JSON.parse(t):void 0}catch{}}function xt(...e){const t=e.flat(1);return[t.push.bind(t),()=>{t.forEach(n=>{n()})}]}function It(e,t){t||(t={});const{textColor:n,bgColor:r,shouldLog:s}=t,i=s===void 0?!0:s,a=typeof i=="boolean"?()=>i:i;function u(o,c,...p){if(c||a()){const f="font-weight:bold;padding:0 5px;border-radius:5px";console[o](`%c${Intl.DateTimeFormat("en-GB",{hour:"2-digit",minute:"2-digit",second:"2-digit",fractionalSecondDigits:3,timeZone:"UTC"}).format(new Date)}%c / %c${e}`,`${f};background-color: lightblue;color:black`,"",`${f};${n?`color:${n};`:""}${r?`background-color:${r}`:""}`,...p)}}return[u.bind(void 0,"log"),u.bind(void 0,"error")]}function je(e){return{lang:(e==null?void 0:e.lang)??void 0,message:e==null?void 0:e.message,abortEarly:(e==null?void 0:e.abortEarly)??void 0,abortPipeEarly:(e==null?void 0:e.abortPipeEarly)??void 0}}function Mn(e){}function xn(e){}function qt(e,t){var n;return(n=void 0)==null?void 0:n.get(t)}function Lt(e){var t,n;const r=typeof e;return r==="string"?`"${e}"`:r==="number"||r==="bigint"||r==="boolean"?`${e}`:r==="object"||r==="function"?(e&&((n=(t=Object.getPrototypeOf(e))==null?void 0:t.constructor)==null?void 0:n.name))??"null":r}function _(e,t,n,r,s){const i=s&&"input"in s?s.input:n.value,a=(s==null?void 0:s.expected)??e.expects??null,u=(s==null?void 0:s.received)??Lt(i),o={kind:e.kind,type:e.type,input:i,expected:a,received:u,message:`Invalid ${t}: ${a?`Expected ${a} but r`:"R"}eceived ${u}`,requirement:e.requirement,path:s==null?void 0:s.path,issues:s==null?void 0:s.issues,lang:r.lang,abortEarly:r.abortEarly,abortPipeEarly:r.abortPipeEarly},c=e.kind==="schema",p=(s==null?void 0:s.message)??e.message??qt(e.reference,o.lang)??(c?(o.lang,void 0):null)??r.message??(o.lang,void 0);p&&(o.message=typeof p=="function"?p(o):p),c&&(n.typed=!1),n.issues?n.issues.push(o):n.issues=[o]}function g(e){return{version:1,vendor:"valibot",validate(t){return e["~run"]({value:t},je())}}}function Se(e,t){return Object.hasOwn(e,t)&&t!=="__proto__"&&t!=="prototype"&&t!=="constructor"}function Dt(e,t){const n=[...new Set(e)];return n.length>1?`(${n.join(` ${t} `)})`:n[0]??"never"}var Tt=class extends Error{constructor(e){super(e[0].message),this.name="ValiError",this.issues=e}};function Ae(e,t){return{kind:"validation",type:"check",reference:Ae,async:!1,expects:null,requirement:e,message:t,"~run"(n,r){return n.typed&&!this.requirement(n.value)&&_(this,"input",n,r),n}}}function Me(e){return{kind:"validation",type:"integer",reference:Me,async:!1,expects:null,requirement:Number.isInteger,message:e,"~run"(t,n){return t.typed&&!this.requirement(t.value)&&_(this,"integer",t,n),t}}}function $(e){return{kind:"transformation",type:"transform",reference:$,async:!1,operation:e,"~run"(t){return t.value=this.operation(t.value),t}}}function xe(e,t,n){return typeof e.default=="function"?e.default(t,n):e.default}function Rt(e,t){return!e["~run"]({value:t},{abortEarly:!0}).issues}function D(e){return{kind:"schema",type:"boolean",reference:D,expects:"boolean",async:!1,message:e,get"~standard"(){return g(this)},"~run"(t,n){return typeof t.value=="boolean"?t.typed=!0:_(this,"type",t,n),t}}}function Ie(e){return{kind:"schema",type:"date",reference:Ie,expects:"Date",async:!1,message:e,get"~standard"(){return g(this)},"~run"(t,n){return t.value instanceof Date?isNaN(t.value)?_(this,"type",t,n,{received:'"Invalid Date"'}):t.typed=!0:_(this,"type",t,n),t}}}function qe(e,t){return{kind:"schema",type:"instance",reference:qe,expects:e.name,async:!1,class:e,message:t,get"~standard"(){return g(this)},"~run"(n,r){return n.value instanceof this.class?n.typed=!0:_(this,"type",n,r),n}}}function Z(e){return{kind:"schema",type:"lazy",reference:Z,expects:"unknown",async:!1,getter:e,get"~standard"(){return g(this)},"~run"(t,n){return this.getter(t.value)["~run"](t,n)}}}function M(e,t){return{kind:"schema",type:"loose_object",reference:M,expects:"Object",async:!1,entries:e,message:t,get"~standard"(){return g(this)},"~run"(n,r){var s;const i=n.value;if(i&&typeof i=="object"){n.typed=!0,n.value={};for(const a in this.entries){const u=this.entries[a];if(a in i||(u.type==="exact_optional"||u.type==="optional"||u.type==="nullish")&&u.default!==void 0){const o=a in i?i[a]:xe(u),c=u["~run"]({value:o},r);if(c.issues){const p={type:"object",origin:"value",input:i,key:a,value:o};for(const f of c.issues)f.path?f.path.unshift(p):f.path=[p],(s=n.issues)==null||s.push(f);if(n.issues||(n.issues=c.issues),r.abortEarly){n.typed=!1;break}}c.typed||(n.typed=!1),n.value[a]=c.value}else if(u.type!=="exact_optional"&&u.type!=="optional"&&u.type!=="nullish"&&(_(this,"key",n,r,{input:void 0,expected:`"${a}"`,path:[{type:"object",origin:"key",input:i,key:a,value:i[a]}]}),r.abortEarly))break}if(!n.issues||!r.abortEarly)for(const a in i)Se(i,a)&&!(a in this.entries)&&(n.value[a]=i[a])}else _(this,"type",n,r);return n}}}function X(e){return{kind:"schema",type:"number",reference:X,expects:"number",async:!1,message:e,get"~standard"(){return g(this)},"~run"(t,n){return typeof t.value=="number"&&!isNaN(t.value)?t.typed=!0:_(this,"type",t,n),t}}}function h(e,t){return{kind:"schema",type:"optional",reference:h,expects:`(${e.expects} | undefined)`,async:!1,wrapped:e,default:t,get"~standard"(){return g(this)},"~run"(n,r){return n.value===void 0&&(this.default!==void 0&&(n.value=xe(this,n,r)),n.value===void 0)?(n.typed=!0,n):this.wrapped["~run"](n,r)}}}function Le(e,t,n){return{kind:"schema",type:"record",reference:Le,expects:"Object",async:!1,key:e,value:t,message:n,get"~standard"(){return g(this)},"~run"(r,s){var i,a;const u=r.value;if(u&&typeof u=="object"){r.typed=!0,r.value={};for(const o in u)if(Se(u,o)){const c=u[o],p=this.key["~run"]({value:o},s);if(p.issues){const b={type:"object",origin:"key",input:u,key:o,value:c};for(const m of p.issues)m.path=[b],(i=r.issues)==null||i.push(m);if(r.issues||(r.issues=p.issues),s.abortEarly){r.typed=!1;break}}const f=this.value["~run"]({value:c},s);if(f.issues){const b={type:"object",origin:"value",input:u,key:o,value:c};for(const m of f.issues)m.path?m.path.unshift(b):m.path=[b],(a=r.issues)==null||a.push(m);if(r.issues||(r.issues=f.issues),s.abortEarly){r.typed=!1;break}}(!p.typed||!f.typed)&&(r.typed=!1),p.typed&&(r.value[p.value]=f.value)}}else _(this,"type",r,s);return r}}}function d(e){return{kind:"schema",type:"string",reference:d,expects:"string",async:!1,message:e,get"~standard"(){return g(this)},"~run"(t,n){return typeof t.value=="string"?t.typed=!0:_(this,"type",t,n),t}}}function De(e){let t;if(e)for(const n of e)t?t.push(...n.issues):t=n.issues;return t}function Te(e,t){return{kind:"schema",type:"union",reference:Te,expects:Dt(e.map(n=>n.expects),"|"),async:!1,options:e,message:t,get"~standard"(){return g(this)},"~run"(n,r){let s,i,a;for(const u of this.options){const o=u["~run"]({value:n.value},r);if(o.typed)if(o.issues)i?i.push(o):i=[o];else{s=o;break}else a?a.push(o):a=[o]}if(s)return s;if(i){if(i.length===1)return i[0];_(this,"type",n,r,{issues:De(i)}),n.typed=!0}else{if((a==null?void 0:a.length)===1)return a[0];_(this,"type",n,r,{issues:De(a)})}return n}}}function Re(){return{kind:"schema",type:"unknown",reference:Re,expects:"unknown",async:!1,get"~standard"(){return g(this)},"~run"(e){return e.typed=!0,e}}}function Ue(e,t,n){const r=e["~run"]({value:t},je(n));if(r.issues)throw new Tt(r.issues);return r.value}function j(...e){return{...e[0],pipe:e,get"~standard"(){return g(this)},"~run"(t,n){for(const r of e)if(r.kind!=="metadata"){if(t.issues&&(r.kind==="schema"||r.kind==="transformation")){t.typed=!1;break}(!t.issues||!n.abortEarly&&!n.abortPipeEarly)&&(t=r["~run"](t,n))}return t}}}function Ut(e){return e.replace(/_[a-z]/g,t=>t[1].toUpperCase())}function Wt(e){return Object.entries(e).reduce((t,[n,r])=>(t[Ut(n)]=r,t),{})}function V(e){const t=Wt(e);for(const n in t){const r=t[n];r&&typeof r=="object"&&!(r instanceof Date)&&(t[n]=Array.isArray(r)?r.map(V):V(r))}return t}function ee(e){return $(t=>e?V(t):t)}function We(e){return t=>j(e,ee(t))}function Ct(e){return(t,n)=>Ue(j(e,ee(n)),t)}function te(){return $(JSON.parse)}function ne(e){const t=We(e);return n=>j(d(),te(),t(n))}function Nt(e){return $(t=>{const n={};return new URLSearchParams(t).forEach((r,s)=>{const i=n[s];Array.isArray(i)?i.push(r):i===void 0?n[s]=r:n[s]=[i,r]}),Ue(e,n)})}function Ce(e){return t=>j(Te([d(),qe(URLSearchParams)]),Nt(e),ee(t))}const Ne=h(Z(()=>Bt())),Ot=M({id:X(),photo_url:h(d()),type:d(),title:d(),username:h(d())}),Jt=M({added_to_attachment_menu:h(D()),allows_write_to_pm:h(D()),first_name:d(),id:X(),is_bot:h(D()),is_premium:h(D()),last_name:h(d()),language_code:h(d()),photo_url:h(d()),username:h(d())}),zt=M({auth_date:j(d(),$(e=>new Date(Number(e)*1e3)),Ie()),can_send_after:h(j(d(),$(Number),Me())),chat:h(Z(()=>Gt())),chat_type:h(d()),chat_instance:h(d()),hash:d(),query_id:h(d()),receiver:Ne,start_param:h(d()),signature:d(),user:Ne}),Gt=ne(Ot),Bt=ne(Jt),Ft=Ce(zt);function Ht(e){return/^#[\da-f]{6}$/i.test(e)}const Kt=We(Le(d(),j(d(),Ae(Ht),$(e=>e)))),re=h(j(d(),$(e=>e==="1"))),Oe=ne(Kt()),Qt=M({tgWebAppBotInline:re,tgWebAppData:h(Ft()),tgWebAppDefaultColors:h(Oe()),tgWebAppFullscreen:re,tgWebAppPlatform:d(),tgWebAppShowSettings:re,tgWebAppStartParam:h(d()),tgWebAppThemeParams:Oe(),tgWebAppVersion:d()}),Je=Ce(Qt),Yt=Ct(Je()),ze=M({eventType:d(),eventData:h(Re())});function Ge(e,t){return t||(t=(n,r)=>JSON.stringify(r)),new URLSearchParams(Object.entries(e).reduce((n,[r,s])=>(Array.isArray(s)?n.push(...s.map(i=>[r,String(i)])):s!=null&&n.push([r,s instanceof Date?(s.getTime()/1e3|0).toString():typeof s=="string"||typeof s=="number"?String(s):typeof s=="boolean"?s?"1":"0":t(r,s)]),n),[])).toString()}function Zt(e){return Ge(e)}function Xt(e){return Ge(e,(t,n)=>t==="tgWebAppData"?Zt(n):JSON.stringify(n))}function Be(e){try{return Rt(Je(),e)}catch{return!1}}function Vt(e){return{all:e=e||new Map,on:function(t,n){var r=e.get(t);r?r.push(n):e.set(t,[n])},off:function(t,n){var r=e.get(t);r&&(n?r.splice(r.indexOf(n)>>>0,1):e.set(t,[]))},emit:function(t,n){var r=e.get(t);r&&r.slice().map(function(s){s(n)}),(r=e.get("*"))&&r.slice().map(function(s){s(t,n)})}}}function en(e,t){const n=Vt(),r=new Map,s=(i,a,u)=>{u||(u=!1);const o=r.get(i)||new Map;r.set(i,o);const c=o.get(a)||[];o.set(a,c);const p=c.findIndex(f=>f[1]===u);p>=0&&(n.off(i,c[p][0]),c.splice(p,1),!c.length&&o.delete(a),o.size||(r.delete(i),!r.size&&t()))};return[function(a,u,o){!r.size&&e();function c(){s(a,u,o)}function p(...m){o&&c(),a==="*"?u(m):u(...m)}n.on(a,p);const f=r.get(a)||new Map;r.set(a,f);const b=f.get(u)||[];return f.set(u,b),b.push([p,o||!1]),c},s,n.emit,function(){const a=n.all.size;n.all.clear(),r.clear(),a&&t()}]}function se(e,t){window.dispatchEvent(new MessageEvent("message",{data:JSON.stringify({eventType:e,eventData:t}),source:window.parent}))}let R=!1;const[ie,tn]=It("Bridge",{bgColor:"#9147ff",textColor:"white",shouldLog(){return R}}),Fe=e=>{ie(!1,"Event received:",e)};function He(e){e!==R&&(R=e,R?ae("*",Fe):Qe("*",Fe))}const nn={clipboard_text_received:E({req_id:P(),data:L(P())}),custom_method_invoked:E({req_id:P(),result:F(be()),error:F(P())}),popup_closed:L(E({button_id:L(P(),()=>{})}),{}),viewport_changed:E({height:B(),width:L(B(),()=>window.innerWidth),is_state_stable:z(),is_expanded:z()})};function Ke(e){if(e.source!==window.parent)return;let t;try{t=H(me(P(),te(),ze),e.data)}catch{return}const{eventType:n,eventData:r}=t,s=nn[n];try{const i=s?H(s,r):r;rn(n,i)}catch(i){tn(!0,[`An error occurred processing the "${n}" event from the Telegram application.`,"Please, file an issue here:","https://github.com/Telegram-Mini-Apps/telegram-apps/issues/new/choose"].join(`
`),t,i)}}const[ae,Qe,rn,Ye]=en(()=>{const e=window,t={receiveEvent:se};e.TelegramGameProxy_receiveEvent=se,e.TelegramGameProxy=t,e.Telegram={WebView:t},window.addEventListener("message",Ke)},()=>{["TelegramGameProxy_receiveEvent","TelegramGameProxy","Telegram"].forEach(e=>{delete window[e]}),window.removeEventListener("message",Ke)});var sn=Object.defineProperty,an=(e,t,n)=>t in e?sn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,on=(e,t,n)=>an(e,t+"",n);function Ze(e){return t=>t instanceof e}function S(e,t){t||(t=[]);class n extends Error{constructor(...s){const i=typeof t=="function"?t(...s):typeof t=="string"?[t]:t||[];super(...i),this.name=e}}return Object.defineProperty(n,"name",{value:e}),[n,Ze(n)]}function un(e,t,n){class r extends S(e,n)[0]{constructor(...i){super(...i),on(this,"data"),this.data=t(...i)}}return Object.defineProperty(r,"name",{value:e}),[r,Ze(r)]}const[Xe,cn]=S("MethodUnsupportedError",(e,t)=>[`Method "${e}" is unsupported in Mini Apps version ${t}`]),[Ve,pn]=S("MethodParameterUnsupportedError",(e,t,n)=>[`Parameter "${t}" of "${e}" method is unsupported in Mini Apps version ${n}`]),et=["Unable to retrieve launch parameters from any known source. Perhaps, you have opened your app outside Telegram?","📖 Refer to docs for more information:","https://docs.telegram-mini-apps.com/packages/telegram-apps-bridge/environment"].join(`
`),[tt,ln]=un("LaunchParamsRetrieveError",e=>e,et),[nt,fn]=S("InvalidLaunchParamsError",e=>[`Invalid value for launch params: ${e}`]),[rt,dn]=S("InitDataRetrieveError",et),[st,yn]=S("UnknownEnvError"),[it,hn]=S("InvokeCustomMethodError",e=>[`Server returned error: ${e}`]);function bn(e,t){t()}function mn(e,t){t||(t={});const n=t.equals||Object.is;let r=[],s=e;const i=c=>{if(!n(s,c)){const p=s;s=c,bn(o,()=>{[...r].forEach(([f,b])=>{f(c,p),b&&u(f,!0)})})}};function a(c){const p=typeof c!="object"?{once:c}:c;return{once:p.once||!1,signal:p.signal||!1}}const u=(c,p)=>{const f=a(p),b=r.findIndex(([m,x])=>m===c&&x.once===f.once&&x.signal===f.signal);b>=0&&r.splice(b,1)},o=Object.assign(function(){return vn(o),s},{destroy(){r=[]},set:i,reset(){i(e)},sub(c,p){return r.push([c,a(p)]),()=>u(c,p)},unsub:u,unsubAll(){r=r.filter(c=>c[1].signal)}});return o}const oe=[];function vn(e){oe.length&&oe[oe.length-1].add(e)}const U=mn("https://web.telegram.org");function ue(e,t){ie(!1,"Posting event:",t?{eventType:e,eventData:t}:{eventType:e});const n=window,r=JSON.stringify({eventType:e,eventData:t});if(Q())return n.parent.postMessage(r,U());if(K(n)){n.TelegramWebviewProxy.postEvent(e,JSON.stringify(t));return}if(T(E({external:E({notify:G()})}),n)){n.external.notify(r);return}throw new st}function ce(e,t,n){n||(n={});const{capture:r}=n,[s,i]=xt();return new ke(a=>{(Array.isArray(t)?t:[t]).forEach(u=>{s(ae(u,o=>{(!r||(Array.isArray(t)?r({event:u,payload:o}):r(o)))&&a(o)}))}),(n.postEvent||ue)(e,n.params)},n).finally(i)}function at(e){return e.replace(/^[^?#]*[?#]/,"").replace(/[?#]/g,"&")}function ot(e){for(const t of[()=>at(window.location.href),()=>{const n=performance.getEntriesByType("navigation")[0];return n?at(n.name):void 0},()=>Mt("launchParams")||""]){const n=t();if(n&&!e(n))return}}function pe(e){const t=[];let n;if(ot(r=>{try{return n=Yt(r),$e("launchParams",r),!1}catch(s){return t.push(s),!0}}),!n)throw new tt(t);return e?Y(n):n}function _n(e,t){if(!e)try{return pe(),!0}catch{return!1}return ke.fn(async n=>{if(K(window))return!0;try{return await ce("web_app_request_theme","theme_changed",n),!0}catch{return!1}},t||{timeout:100})}function gn({launchParams:e,onEvent:t}={}){if(e){const s=typeof e=="string"||e instanceof URLSearchParams?e.toString():Xt({...e,tgWebAppData:void 0})+(e.tgWebAppData?`&tgWebAppData=${encodeURIComponent(e.tgWebAppData.toString())}`:"");if(!Be(s))throw new nt(s);$e("launchParams",s)}if(Q()){const s=me(P(),te(),ze),i=window.parent.postMessage.bind(window.parent);window.parent.postMessage=(...a)=>{const[u]=a,o=()=>{i(...a)};if(T(s,u)&&t){const c=H(s,u);t([c.eventType,c.eventData],o)}else o()};return}const n=window.TelegramWebviewProxy||{},{postEvent:r}=n;window.TelegramWebviewProxy={...n,postEvent(s,i){const a=()=>{r&&r(s,i)};t?t([s,i?JSON.parse(i):void 0],a):a()}},ie(!1,"Environment was mocked by the mockTelegramEnv function")}function wn(){try{pe()}catch{throw new rt}let e;return ot(t=>Be(t)?(e=new URLSearchParams(t).get("tgWebAppData")||void 0,!1):!0),e}function ut(e){return({req_id:t})=>t===e}function ct(e){return e.split(".").map(Number)}function pt(e,t){const n=ct(e),r=ct(t),s=Math.max(n.length,r.length);for(let i=0;i<s;i+=1){const a=n[i]||0,u=r[i]||0;if(a!==u)return a>u?1:-1}return 0}function v(e,t){return pt(e,t)<=0}function le(e,t,n){if(typeof n=="string"){if(e==="web_app_open_link"){if(t==="try_instant_view")return v("6.4",n);if(t==="try_browser")return v("7.6",n)}if(e==="web_app_set_header_color"&&t==="color")return v("6.9",n);if(e==="web_app_close"&&t==="return_back")return v("7.6",n);if(e==="web_app_setup_main_button"&&t==="has_shine_effect")return v("7.10",n)}switch(e){case"web_app_open_tg_link":case"web_app_open_invoice":case"web_app_setup_back_button":case"web_app_set_background_color":case"web_app_set_header_color":case"web_app_trigger_haptic_feedback":return v("6.1",t);case"web_app_open_popup":return v("6.2",t);case"web_app_close_scan_qr_popup":case"web_app_open_scan_qr_popup":case"web_app_read_text_from_clipboard":return v("6.4",t);case"web_app_switch_inline_query":return v("6.7",t);case"web_app_invoke_custom_method":case"web_app_request_write_access":case"web_app_request_phone":return v("6.9",t);case"web_app_setup_settings_button":return v("6.10",t);case"web_app_biometry_get_info":case"web_app_biometry_open_settings":case"web_app_biometry_request_access":case"web_app_biometry_request_auth":case"web_app_biometry_update_token":return v("7.2",t);case"web_app_setup_swipe_behavior":return v("7.7",t);case"web_app_share_to_story":return v("7.8",t);case"web_app_setup_secondary_button":case"web_app_set_bottom_bar_color":return v("7.10",t);case"web_app_request_safe_area":case"web_app_request_content_safe_area":case"web_app_request_fullscreen":case"web_app_exit_fullscreen":case"web_app_set_emoji_status":case"web_app_add_to_home_screen":case"web_app_check_home_screen":case"web_app_request_emoji_status_access":return v("8.0",t);default:return["iframe_ready","iframe_will_reload","web_app_close","web_app_data_send","web_app_expand","web_app_open_link","web_app_ready","web_app_request_theme","web_app_request_viewport","web_app_setup_main_button","web_app_setup_closing_behavior"].includes(e)}}function En(e,t){t||(t="strict");const n=typeof t=="function"?t:r=>{const{method:s,version:i}=r,a="param"in r?new Ve(s,r.param,i):new Xe(s,i);if(t==="strict")throw a;return console.warn(a.message)};return(r,s)=>le(r,e)?r==="web_app_set_header_color"&&T(E({color:he()}),s)&&!le(r,"color",e)?n({version:e,method:r,param:"color"}):ue(r,s):n({version:e,method:r})}function kn(e,t,n,r){return ce("web_app_invoke_custom_method","custom_method_invoked",{...r||{},params:{method:e,params:t,req_id:n},capture:ut(n)}).then(({result:s,error:i})=>{if(i)throw new it(i);return s})}function Pn(){Ye(),He(!1),U.unsubAll(),U.reset()}return l.InitDataRetrieveError=rt,l.InvalidLaunchParamsError=nt,l.InvokeCustomMethodError=it,l.LaunchParamsRetrieveError=tt,l.MethodParameterUnsupportedError=Ve,l.MethodUnsupportedError=Xe,l.UnknownEnvError=st,l.captureSameReq=ut,l.compareVersions=pt,l.createPostEvent=En,l.emitEvent=se,l.hasWebviewProxy=K,l.invokeCustomMethod=kn,l.isIframe=Q,l.isInitDataRetrieveError=dn,l.isInvalidLaunchParamsError=fn,l.isInvokeCustomMethodError=hn,l.isLaunchParamsRetrieveError=ln,l.isMethodMethodParameterUnsupportedError=pn,l.isMethodUnsupportedError=cn,l.isTMA=_n,l.isUnknownEnvError=yn,l.mockTelegramEnv=gn,l.off=Qe,l.offAll=Ye,l.on=ae,l.postEvent=ue,l.request=ce,l.resetPackageState=Pn,l.retrieveLaunchParams=pe,l.retrieveRawInitData=wn,l.setDebug=He,l.supports=le,l.targetOrigin=U,Object.defineProperty(l,Symbol.toStringTag,{value:"Module"}),l}({});
this.tapps=this.tapps||{};this.tapps.bridge=function(l){"use strict";var k;function ye(e){return{lang:(e==null?void 0:e.lang)??(k==null?void 0:k.lang),message:e==null?void 0:e.message,abortEarly:(e==null?void 0:e.abortEarly)??(k==null?void 0:k.abortEarly),abortPipeEarly:(e==null?void 0:e.abortPipeEarly)??(k==null?void 0:k.abortPipeEarly)}}var C;function _t(e){return C==null?void 0:C.get(e)}var N;function bt(e){return N==null?void 0:N.get(e)}var O;function ht(e,t){var n;return(n=O==null?void 0:O.get(e))==null?void 0:n.get(t)}function mt(e){var n,r;const t=typeof e;return t==="string"?`"${e}"`:t==="number"||t==="bigint"||t==="boolean"?`${e}`:t==="object"||t==="function"?(e&&((r=(n=Object.getPrototypeOf(e))==null?void 0:n.constructor)==null?void 0:r.name))??"null":t}function A(e,t,n,r,s){const a=s&&"input"in s?s.input:n.value,i=(s==null?void 0:s.expected)??e.expects??null,u=(s==null?void 0:s.received)??mt(a),o={kind:e.kind,type:e.type,input:a,expected:i,received:u,message:`Invalid ${t}: ${i?`Expected ${i} but r`:"R"}eceived ${u}`,requirement:e.requirement,path:s==null?void 0:s.path,issues:s==null?void 0:s.issues,lang:r.lang,abortEarly:r.abortEarly,abortPipeEarly:r.abortPipeEarly},c=e.kind==="schema",p=(s==null?void 0:s.message)??e.message??ht(e.reference,o.lang)??(c?bt(o.lang):null)??r.message??_t(o.lang);p&&(o.message=typeof p=="function"?p(o):p),c&&(n.typed=!1),n.issues?n.issues.push(o):n.issues=[o]}function w(e){return{version:1,vendor:"valibot",validate(t){return e["~run"]({value:t},ye())}}}function vt(e,t){return Object.hasOwn(e,t)&&t!=="__proto__"&&t!=="prototype"&&t!=="constructor"}var gt=class extends Error{constructor(e){super(e[0].message),this.name="ValiError",this.issues=e}};function J(e,t,n){return typeof e.default=="function"?e.default(t,n):e.default}function T(e,t){return!e["~run"]({value:t},{abortEarly:!0}).issues}function _e(){return{kind:"schema",type:"any",reference:_e,expects:"any",async:!1,get"~standard"(){return w(this)},"~run"(e){return e.typed=!0,e}}}function z(e){return{kind:"schema",type:"boolean",reference:z,expects:"boolean",async:!1,message:e,get"~standard"(){return w(this)},"~run"(t,n){return typeof t.value=="boolean"?t.typed=!0:A(this,"type",t,n),t}}}function G(e){return{kind:"schema",type:"function",reference:G,expects:"Function",async:!1,message:e,get"~standard"(){return w(this)},"~run"(t,n){return typeof t.value=="function"?t.typed=!0:A(this,"type",t,n),t}}}function E(e,t){return{kind:"schema",type:"loose_object",reference:E,expects:"Object",async:!1,entries:e,message:t,get"~standard"(){return w(this)},"~run"(n,r){var a;const s=n.value;if(s&&typeof s=="object"){n.typed=!0,n.value={};for(const i in this.entries){const u=this.entries[i];if(i in s||(u.type==="exact_optional"||u.type==="optional"||u.type==="nullish")&&u.default!==void 0){const o=i in s?s[i]:J(u),c=u["~run"]({value:o},r);if(c.issues){const p={type:"object",origin:"value",input:s,key:i,value:o};for(const f of c.issues)f.path?f.path.unshift(p):f.path=[p],(a=n.issues)==null||a.push(f);if(n.issues||(n.issues=c.issues),r.abortEarly){n.typed=!1;break}}c.typed||(n.typed=!1),n.value[i]=c.value}else if(u.type!=="exact_optional"&&u.type!=="optional"&&u.type!=="nullish"&&(A(this,"key",n,r,{input:void 0,expected:`"${i}"`,path:[{type:"object",origin:"key",input:s,key:i,value:s[i]}]}),r.abortEarly))break}if(!n.issues||!r.abortEarly)for(const i in s)vt(s,i)&&!(i in this.entries)&&(n.value[i]=s[i])}else A(this,"type",n,r);return n}}}function L(e,t){return{kind:"schema",type:"nullish",reference:L,expects:`(${e.expects} | null | undefined)`,async:!1,wrapped:e,default:t,get"~standard"(){return w(this)},"~run"(n,r){return(n.value===null||n.value===void 0)&&(this.default!==void 0&&(n.value=J(this,n,r)),n.value===null||n.value===void 0)?(n.typed=!0,n):this.wrapped["~run"](n,r)}}}function B(e){return{kind:"schema",type:"number",reference:B,expects:"number",async:!1,message:e,get"~standard"(){return w(this)},"~run"(t,n){return typeof t.value=="number"&&!isNaN(t.value)?t.typed=!0:A(this,"type",t,n),t}}}function F(e,t){return{kind:"schema",type:"optional",reference:F,expects:`(${e.expects} | undefined)`,async:!1,wrapped:e,default:t,get"~standard"(){return w(this)},"~run"(n,r){return n.value===void 0&&(this.default!==void 0&&(n.value=J(this,n,r)),n.value===void 0)?(n.typed=!0,n):this.wrapped["~run"](n,r)}}}function P(e){return{kind:"schema",type:"string",reference:P,expects:"string",async:!1,message:e,get"~standard"(){return w(this)},"~run"(t,n){return typeof t.value=="string"?t.typed=!0:A(this,"type",t,n),t}}}function be(){return{kind:"schema",type:"unknown",reference:be,expects:"unknown",async:!1,get"~standard"(){return w(this)},"~run"(e){return e.typed=!0,e}}}function H(e,t,n){const r=e["~run"]({value:t},ye(n));if(r.issues)throw new gt(r.issues);return r.value}function he(...e){return{...e[0],pipe:e,get"~standard"(){return w(this)},"~run"(t,n){for(const r of e)if(r.kind!=="metadata"){if(t.issues&&(r.kind==="schema"||r.kind==="transformation")){t.typed=!1;break}(!t.issues||!n.abortEarly&&!n.abortPipeEarly)&&(t=r["~run"](t,n))}return t}}}function K(e){return T(E({TelegramWebviewProxy:E({postEvent:G()})}),e)}function Q(){try{return window.self!==window.top}catch{return!0}}var wt=Object.defineProperty,Et=(e,t,n)=>t in e?wt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,me=(e,t,n)=>Et(e,typeof t!="symbol"?t+"":t,n);function kt(e){return t=>t instanceof e}function ve(e,t){t||(t=[]);class n extends Error{constructor(...s){const a=typeof t=="function"?t(...s):typeof t=="string"?[t]:t||[];super(...a),this.name=e}}return Object.defineProperty(n,"name",{value:e}),[n,kt(n)]}const[Pt,Sn]=ve("CancelledError","Promise was canceled"),[$t,An]=ve("TimeoutError",(e,t)=>[`Timeout reached: ${e}ms`,{cause:t}]),ge=Symbol("Resolved");function we(e){return Array.isArray(e)&&e[0]===ge}function jt(e){return[ge,e]}function Ee(e,t){return e.reject=t.reject,e.abort=t.abort,e}let ke=class de extends Promise{constructor(t,n){let r,s;super((a,i)=>{let u,o;typeof t=="function"?(u=t,o=n):o=t;const c=[],p=y=>(...I)=>{const W=y(...I);return c.forEach(jn=>jn()),W},f=new AbortController,{signal:b}=f;s=y=>{!b.aborted&&f.abort(y)};const h=()=>b.reason,x=y=>{const I=()=>{y(h())};b.addEventListener("abort",I,!0);const W=()=>{b.removeEventListener("abort",I,!0)};return c.push(W),W},$n=p(y=>{a(y),s(jt(y))});r=p(y=>{i(y),s(y)}),o||(o={});const{abortSignal:q,rejectOnAbort:lt=!0}=o;if(q)if(q.aborted){const{reason:y}=q;if(lt)return r(y);s(y)}else{const y=()=>{s(q.reason)};q.addEventListener("abort",y),c.push(()=>{q.removeEventListener("abort",y)})}lt&&x(i);const{timeout:fe}=o;if(fe){const y=setTimeout(()=>{s(new $t(fe))},fe);c.push(()=>{clearTimeout(y)})}const ft=()=>b.aborted,dt=()=>we(h()),yt=()=>{const y=h();return we(y)?y[1]:void 0};try{const y=u&&u($n,r,{abortReason:h,abortSignal:b,isAborted:ft,isResolved:dt,onAborted:x,onResolved:I=>x(()=>{dt()&&I(yt())}),resolved:yt,throwIfAborted(){if(ft())throw h()}});y instanceof Promise&&y.catch(r)}catch(y){r(y)}}),me(this,"abort"),me(this,"reject"),this.abort=s,this.reject=r}static fn(t,n){return new de(async(r,s,a)=>{try{r(await t(a))}catch(i){s(i)}},n)}static resolve(t){return this.fn(()=>t)}static reject(t){return new de((n,r)=>{r(t)})}cancel(){this.abort(new Pt)}catch(t){return this.then(void 0,t)}finally(t){return Ee(super.finally(t),this)}then(t,n){return Ee(super.then(t,n),this)}};function St(e){return e.replace(/_[a-z]/g,t=>t[1].toUpperCase())}function At(e){return Object.entries(e).reduce((t,[n,r])=>(t[St(n)]=r,t),{})}function Y(e){const t=At(e);for(const n in t){const r=t[n];r&&typeof r=="object"&&!(r instanceof Date)&&(t[n]=Array.isArray(r)?r.map(Y):Y(r))}return t}function Pe(e){return`tapps/${e}`}function $e(e,t){sessionStorage.setItem(Pe(e),JSON.stringify(t))}function Mt(e){const t=sessionStorage.getItem(Pe(e));try{return t?JSON.parse(t):void 0}catch{}}function xt(...e){const t=e.flat(1);return[t.push.bind(t),()=>{t.forEach(n=>{n()})}]}function qt(e,t){t||(t={});const{textColor:n,bgColor:r,shouldLog:s}=t,a=s===void 0?!0:s,i=typeof a=="boolean"?()=>a:a;function u(o,c,...p){if(c||i()){const f="font-weight:bold;padding:0 5px;border-radius:5px";console[o](`%c${Intl.DateTimeFormat("en-GB",{hour:"2-digit",minute:"2-digit",second:"2-digit",fractionalSecondDigits:3,timeZone:"UTC"}).format(new Date)}%c / %c${e}`,`${f};background-color: lightblue;color:black`,"",`${f};${n?`color:${n};`:""}${r?`background-color:${r}`:""}`,...p)}}return[u.bind(void 0,"log"),u.bind(void 0,"error")]}function je(e){return{lang:(e==null?void 0:e.lang)??void 0,message:e==null?void 0:e.message,abortEarly:(e==null?void 0:e.abortEarly)??void 0,abortPipeEarly:(e==null?void 0:e.abortPipeEarly)??void 0}}function Mn(e){}function xn(e){}function It(e,t){var n;return(n=void 0)==null?void 0:n.get(t)}function Lt(e){var t,n;const r=typeof e;return r==="string"?`"${e}"`:r==="number"||r==="bigint"||r==="boolean"?`${e}`:r==="object"||r==="function"?(e&&((n=(t=Object.getPrototypeOf(e))==null?void 0:t.constructor)==null?void 0:n.name))??"null":r}function v(e,t,n,r,s){const a=s&&"input"in s?s.input:n.value,i=(s==null?void 0:s.expected)??e.expects??null,u=(s==null?void 0:s.received)??Lt(a),o={kind:e.kind,type:e.type,input:a,expected:i,received:u,message:`Invalid ${t}: ${i?`Expected ${i} but r`:"R"}eceived ${u}`,requirement:e.requirement,path:s==null?void 0:s.path,issues:s==null?void 0:s.issues,lang:r.lang,abortEarly:r.abortEarly,abortPipeEarly:r.abortPipeEarly},c=e.kind==="schema",p=(s==null?void 0:s.message)??e.message??It(e.reference,o.lang)??(c?(o.lang,void 0):null)??r.message??(o.lang,void 0);p&&(o.message=typeof p=="function"?p(o):p),c&&(n.typed=!1),n.issues?n.issues.push(o):n.issues=[o]}function g(e){return{version:1,vendor:"valibot",validate(t){return e["~run"]({value:t},je())}}}function Se(e,t){return Object.hasOwn(e,t)&&t!=="__proto__"&&t!=="prototype"&&t!=="constructor"}function Dt(e,t){const n=[...new Set(e)];return n.length>1?`(${n.join(` ${t} `)})`:n[0]??"never"}var Tt=class extends Error{constructor(e){super(e[0].message),this.name="ValiError",this.issues=e}};function Ae(e,t){return{kind:"validation",type:"check",reference:Ae,async:!1,expects:null,requirement:e,message:t,"~run"(n,r){return n.typed&&!this.requirement(n.value)&&v(this,"input",n,r),n}}}function Me(e){return{kind:"validation",type:"integer",reference:Me,async:!1,expects:null,requirement:Number.isInteger,message:e,"~run"(t,n){return t.typed&&!this.requirement(t.value)&&v(this,"integer",t,n),t}}}function $(e){return{kind:"transformation",type:"transform",reference:$,async:!1,operation:e,"~run"(t){return t.value=this.operation(t.value),t}}}function xe(e,t,n){return typeof e.default=="function"?e.default(t,n):e.default}function Rt(e,t){return!e["~run"]({value:t},{abortEarly:!0}).issues}function D(e){return{kind:"schema",type:"boolean",reference:D,expects:"boolean",async:!1,message:e,get"~standard"(){return g(this)},"~run"(t,n){return typeof t.value=="boolean"?t.typed=!0:v(this,"type",t,n),t}}}function qe(e){return{kind:"schema",type:"date",reference:qe,expects:"Date",async:!1,message:e,get"~standard"(){return g(this)},"~run"(t,n){return t.value instanceof Date?isNaN(t.value)?v(this,"type",t,n,{received:'"Invalid Date"'}):t.typed=!0:v(this,"type",t,n),t}}}function Ie(e,t){return{kind:"schema",type:"instance",reference:Ie,expects:e.name,async:!1,class:e,message:t,get"~standard"(){return g(this)},"~run"(n,r){return n.value instanceof this.class?n.typed=!0:v(this,"type",n,r),n}}}function Z(e){return{kind:"schema",type:"lazy",reference:Z,expects:"unknown",async:!1,getter:e,get"~standard"(){return g(this)},"~run"(t,n){return this.getter(t.value)["~run"](t,n)}}}function M(e,t){return{kind:"schema",type:"loose_object",reference:M,expects:"Object",async:!1,entries:e,message:t,get"~standard"(){return g(this)},"~run"(n,r){var s;const a=n.value;if(a&&typeof a=="object"){n.typed=!0,n.value={};for(const i in this.entries){const u=this.entries[i];if(i in a||(u.type==="exact_optional"||u.type==="optional"||u.type==="nullish")&&u.default!==void 0){const o=i in a?a[i]:xe(u),c=u["~run"]({value:o},r);if(c.issues){const p={type:"object",origin:"value",input:a,key:i,value:o};for(const f of c.issues)f.path?f.path.unshift(p):f.path=[p],(s=n.issues)==null||s.push(f);if(n.issues||(n.issues=c.issues),r.abortEarly){n.typed=!1;break}}c.typed||(n.typed=!1),n.value[i]=c.value}else if(u.type!=="exact_optional"&&u.type!=="optional"&&u.type!=="nullish"&&(v(this,"key",n,r,{input:void 0,expected:`"${i}"`,path:[{type:"object",origin:"key",input:a,key:i,value:a[i]}]}),r.abortEarly))break}if(!n.issues||!r.abortEarly)for(const i in a)Se(a,i)&&!(i in this.entries)&&(n.value[i]=a[i])}else v(this,"type",n,r);return n}}}function X(e){return{kind:"schema",type:"number",reference:X,expects:"number",async:!1,message:e,get"~standard"(){return g(this)},"~run"(t,n){return typeof t.value=="number"&&!isNaN(t.value)?t.typed=!0:v(this,"type",t,n),t}}}function _(e,t){return{kind:"schema",type:"optional",reference:_,expects:`(${e.expects} | undefined)`,async:!1,wrapped:e,default:t,get"~standard"(){return g(this)},"~run"(n,r){return n.value===void 0&&(this.default!==void 0&&(n.value=xe(this,n,r)),n.value===void 0)?(n.typed=!0,n):this.wrapped["~run"](n,r)}}}function Le(e,t,n){return{kind:"schema",type:"record",reference:Le,expects:"Object",async:!1,key:e,value:t,message:n,get"~standard"(){return g(this)},"~run"(r,s){var a,i;const u=r.value;if(u&&typeof u=="object"){r.typed=!0,r.value={};for(const o in u)if(Se(u,o)){const c=u[o],p=this.key["~run"]({value:o},s);if(p.issues){const b={type:"object",origin:"key",input:u,key:o,value:c};for(const h of p.issues)h.path=[b],(a=r.issues)==null||a.push(h);if(r.issues||(r.issues=p.issues),s.abortEarly){r.typed=!1;break}}const f=this.value["~run"]({value:c},s);if(f.issues){const b={type:"object",origin:"value",input:u,key:o,value:c};for(const h of f.issues)h.path?h.path.unshift(b):h.path=[b],(i=r.issues)==null||i.push(h);if(r.issues||(r.issues=f.issues),s.abortEarly){r.typed=!1;break}}(!p.typed||!f.typed)&&(r.typed=!1),p.typed&&(r.value[p.value]=f.value)}}else v(this,"type",r,s);return r}}}function d(e){return{kind:"schema",type:"string",reference:d,expects:"string",async:!1,message:e,get"~standard"(){return g(this)},"~run"(t,n){return typeof t.value=="string"?t.typed=!0:v(this,"type",t,n),t}}}function De(e){let t;if(e)for(const n of e)t?t.push(...n.issues):t=n.issues;return t}function Te(e,t){return{kind:"schema",type:"union",reference:Te,expects:Dt(e.map(n=>n.expects),"|"),async:!1,options:e,message:t,get"~standard"(){return g(this)},"~run"(n,r){let s,a,i;for(const u of this.options){const o=u["~run"]({value:n.value},r);if(o.typed)if(o.issues)a?a.push(o):a=[o];else{s=o;break}else i?i.push(o):i=[o]}if(s)return s;if(a){if(a.length===1)return a[0];v(this,"type",n,r,{issues:De(a)}),n.typed=!0}else{if((i==null?void 0:i.length)===1)return i[0];v(this,"type",n,r,{issues:De(i)})}return n}}}function Re(){return{kind:"schema",type:"unknown",reference:Re,expects:"unknown",async:!1,get"~standard"(){return g(this)},"~run"(e){return e.typed=!0,e}}}function Ue(e,t,n){const r=e["~run"]({value:t},je(n));if(r.issues)throw new Tt(r.issues);return r.value}function j(...e){return{...e[0],pipe:e,get"~standard"(){return g(this)},"~run"(t,n){for(const r of e)if(r.kind!=="metadata"){if(t.issues&&(r.kind==="schema"||r.kind==="transformation")){t.typed=!1;break}(!t.issues||!n.abortEarly&&!n.abortPipeEarly)&&(t=r["~run"](t,n))}return t}}}function Ut(e){return e.replace(/_[a-z]/g,t=>t[1].toUpperCase())}function Wt(e){return Object.entries(e).reduce((t,[n,r])=>(t[Ut(n)]=r,t),{})}function V(e){const t=Wt(e);for(const n in t){const r=t[n];r&&typeof r=="object"&&!(r instanceof Date)&&(t[n]=Array.isArray(r)?r.map(V):V(r))}return t}function ee(e){return $(t=>e?V(t):t)}function We(e){return t=>j(e,ee(t))}function Ct(e){return(t,n)=>Ue(j(e,ee(n)),t)}function te(){return $(JSON.parse)}function ne(e){const t=We(e);return n=>j(d(),te(),t(n))}function Nt(e){return $(t=>{const n={};return new URLSearchParams(t).forEach((r,s)=>{const a=n[s];Array.isArray(a)?a.push(r):a===void 0?n[s]=r:n[s]=[a,r]}),Ue(e,n)})}function Ce(e){return t=>j(Te([d(),Ie(URLSearchParams)]),Nt(e),ee(t))}const Ne=_(Z(()=>Bt())),Ot=M({id:X(),photo_url:_(d()),type:d(),title:d(),username:_(d())}),Jt=M({added_to_attachment_menu:_(D()),allows_write_to_pm:_(D()),first_name:d(),id:X(),is_bot:_(D()),is_premium:_(D()),last_name:_(d()),language_code:_(d()),photo_url:_(d()),username:_(d())}),zt=M({auth_date:j(d(),$(e=>new Date(Number(e)*1e3)),qe()),can_send_after:_(j(d(),$(Number),Me())),chat:_(Z(()=>Gt())),chat_type:_(d()),chat_instance:_(d()),hash:d(),query_id:_(d()),receiver:Ne,start_param:_(d()),signature:d(),user:Ne}),Gt=ne(Ot),Bt=ne(Jt),Ft=Ce(zt);function Ht(e){return/^#[\da-f]{6}$/i.test(e)}const Kt=We(Le(d(),j(d(),Ae(Ht),$(e=>e)))),re=_(j(d(),$(e=>e==="1"))),Oe=ne(Kt()),Qt=M({tgWebAppBotInline:re,tgWebAppData:_(Ft()),tgWebAppDefaultColors:_(Oe()),tgWebAppFullscreen:re,tgWebAppPlatform:d(),tgWebAppShowSettings:re,tgWebAppStartParam:_(d()),tgWebAppThemeParams:Oe(),tgWebAppVersion:d()}),Je=Ce(Qt),Yt=Ct(Je()),ze=M({eventType:d(),eventData:_(Re())});function Ge(e,t){return t||(t=(n,r)=>JSON.stringify(r)),new URLSearchParams(Object.entries(e).reduce((n,[r,s])=>(Array.isArray(s)?n.push(...s.map(a=>[r,String(a)])):s!=null&&n.push([r,s instanceof Date?(s.getTime()/1e3|0).toString():typeof s=="string"||typeof s=="number"?String(s):typeof s=="boolean"?s?"1":"0":t(r,s)]),n),[])).toString()}function Zt(e){return Ge(e)}function Xt(e){return Ge(e,(t,n)=>t==="tgWebAppData"?Zt(n):JSON.stringify(n))}function Be(e){try{return Rt(Je(),e)}catch{return!1}}function Vt(e){return{all:e=e||new Map,on:function(t,n){var r=e.get(t);r?r.push(n):e.set(t,[n])},off:function(t,n){var r=e.get(t);r&&(n?r.splice(r.indexOf(n)>>>0,1):e.set(t,[]))},emit:function(t,n){var r=e.get(t);r&&r.slice().map(function(s){s(n)}),(r=e.get("*"))&&r.slice().map(function(s){s(t,n)})}}}function en(e,t){const n=Vt(),r=new Map,s=(a,i,u)=>{u||(u=!1);const o=r.get(a)||new Map;r.set(a,o);const c=o.get(i)||[];o.set(i,c);const p=c.findIndex(f=>f[1]===u);p>=0&&(n.off(a,c[p][0]),c.splice(p,1),!c.length&&o.delete(i),o.size||(r.delete(a),!r.size&&t()))};return[function(i,u,o){!r.size&&e();function c(){s(i,u,o)}function p(...h){o&&c(),i==="*"?u(h):u(...h)}n.on(i,p);const f=r.get(i)||new Map;r.set(i,f);const b=f.get(u)||[];return f.set(u,b),b.push([p,o||!1]),c},s,n.emit,function(){const i=n.all.size;n.all.clear(),r.clear(),i&&t()}]}function se(e,t){window.dispatchEvent(new MessageEvent("message",{data:JSON.stringify({eventType:e,eventData:t}),source:window.parent}))}let R=!1;const[ae,tn]=qt("Bridge",{bgColor:"#9147ff",textColor:"white",shouldLog(){return R}}),Fe=e=>{ae(!1,"Event received:",e)};function He(e){e!==R&&(R=e,R?ie("*",Fe):Qe("*",Fe))}const nn={clipboard_text_received:E({req_id:P(),data:L(P())}),custom_method_invoked:E({req_id:P(),result:F(be()),error:F(P())}),popup_closed:L(E({button_id:L(P(),()=>{})}),{}),viewport_changed:E({height:B(),width:L(B(),()=>window.innerWidth),is_state_stable:z(),is_expanded:z()})};function Ke(e){if(e.source!==window.parent)return;let t;try{t=H(he(P(),te(),ze),e.data)}catch{return}const{eventType:n,eventData:r}=t,s=nn[n];try{const a=s?H(s,r):r;rn(n,a)}catch(a){tn(!0,[`An error occurred processing the "${n}" event from the Telegram application.`,"Please, file an issue here:","https://github.com/Telegram-Mini-Apps/telegram-apps/issues/new/choose"].join(`
`),t,a)}}const[ie,Qe,rn,Ye]=en(()=>{const e=window,t={receiveEvent:se};e.TelegramGameProxy_receiveEvent=se,e.TelegramGameProxy=t,e.Telegram={WebView:t},window.addEventListener("message",Ke)},()=>{["TelegramGameProxy_receiveEvent","TelegramGameProxy","Telegram"].forEach(e=>{delete window[e]}),window.removeEventListener("message",Ke)});var sn=Object.defineProperty,an=(e,t,n)=>t in e?sn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,on=(e,t,n)=>an(e,t+"",n);function Ze(e){return t=>t instanceof e}function S(e,t){t||(t=[]);class n extends Error{constructor(...s){const a=typeof t=="function"?t(...s):typeof t=="string"?[t]:t||[];super(...a),this.name=e}}return Object.defineProperty(n,"name",{value:e}),[n,Ze(n)]}function un(e,t,n){class r extends S(e,n)[0]{constructor(...a){super(...a),on(this,"data"),this.data=t(...a)}}return Object.defineProperty(r,"name",{value:e}),[r,Ze(r)]}const[Xe,cn]=S("MethodUnsupportedError",(e,t)=>[`Method "${e}" is unsupported in Mini Apps version ${t}`]),[Ve,pn]=S("MethodParameterUnsupportedError",(e,t,n)=>[`Parameter "${t}" of "${e}" method is unsupported in Mini Apps version ${n}`]),et=["Unable to retrieve launch parameters from any known source. Perhaps, you have opened your app outside Telegram?","📖 Refer to docs for more information:","https://docs.telegram-mini-apps.com/packages/telegram-apps-bridge/environment"].join(`
`),[tt,ln]=un("LaunchParamsRetrieveError",e=>e,et),[nt,fn]=S("InvalidLaunchParamsError",e=>[`Invalid value for launch params: ${e}`]),[rt,dn]=S("InitDataRetrieveError",et),[st,yn]=S("UnknownEnvError"),[at,_n]=S("InvokeCustomMethodError",e=>[`Server returned error: ${e}`]);function bn(e,t){t()}function hn(e,t){t||(t={});const n=t.equals||Object.is;let r=[],s=e;const a=c=>{if(!n(s,c)){const p=s;s=c,bn(o,()=>{[...r].forEach(([f,b])=>{f(c,p),b&&u(f,!0)})})}};function i(c){const p=typeof c!="object"?{once:c}:c;return{once:p.once||!1,signal:p.signal||!1}}const u=(c,p)=>{const f=i(p),b=r.findIndex(([h,x])=>h===c&&x.once===f.once&&x.signal===f.signal);b>=0&&r.splice(b,1)},o=Object.assign(function(){return mn(o),s},{destroy(){r=[]},set:a,reset(){a(e)},sub(c,p){return r.push([c,i(p)]),()=>u(c,p)},unsub:u,unsubAll(){r=r.filter(c=>c[1].signal)}});return o}const oe=[];function mn(e){oe.length&&oe[oe.length-1].add(e)}const U=hn("https://web.telegram.org");function ue(e,t){ae(!1,"Posting event:",t?{eventType:e,eventData:t}:{eventType:e});const n=window,r=JSON.stringify({eventType:e,eventData:t});if(Q())return n.parent.postMessage(r,U());if(K(n)){n.TelegramWebviewProxy.postEvent(e,JSON.stringify(t));return}if(T(E({external:E({notify:G()})}),n)){n.external.notify(r);return}throw new st}function ce(e,t,n){n||(n={});const{capture:r}=n,[s,a]=xt();return new ke(i=>{(Array.isArray(t)?t:[t]).forEach(u=>{s(ie(u,o=>{(!r||(Array.isArray(t)?r({event:u,payload:o}):r(o)))&&i(o)}))}),(n.postEvent||ue)(e,n.params)},n).finally(a)}function it(e){return e.replace(/^[^?#]*[?#]/,"").replace(/[?#]/g,"&")}function ot(e){for(const t of[()=>it(window.location.href),()=>{const n=performance.getEntriesByType("navigation")[0];return n?it(n.name):void 0},()=>Mt("launchParams")||""]){const n=t();if(n&&!e(n))return}}function pe(e){const t=[];let n;if(ot(r=>{try{return n=Yt(r),$e("launchParams",r),!1}catch(s){return t.push(s),!0}}),!n)throw new tt(t);return e?Y(n):n}function vn(e,t){if(!e)try{return pe(),!0}catch{return!1}return ke.fn(async n=>{if(K(window))return!0;try{return await ce("web_app_request_theme","theme_changed",n),!0}catch{return!1}},t||{timeout:100})}function gn({launchParams:e,onEvent:t}={}){if(e){const s=typeof e=="string"||e instanceof URLSearchParams?e.toString():Xt({...e,tgWebAppData:void 0})+(e.tgWebAppData?`&tgWebAppData=${encodeURIComponent(e.tgWebAppData.toString())}`:"");if(!Be(s))throw new nt(s);$e("launchParams",s)}if(Q()){const s=he(P(),te(),ze),a=window.parent.postMessage.bind(window.parent);window.parent.postMessage=(...i)=>{const[u]=i,o=()=>{a(...i)};if(T(s,u)&&t){const c=H(s,u);t([c.eventType,c.eventData],o)}else o()};return}const n=window.TelegramWebviewProxy||{},{postEvent:r}=n;window.TelegramWebviewProxy={...n,postEvent(s,a){const i=()=>{r&&r(s,a)};t?t([s,a?JSON.parse(a):void 0],i):i()}},ae(!1,"Environment was mocked by the mockTelegramEnv function")}function wn(){try{pe()}catch{throw new rt}let e;return ot(t=>Be(t)?(e=new URLSearchParams(t).get("tgWebAppData")||void 0,!1):!0),e}function ut(e){return({req_id:t})=>t===e}function ct(e){return e.split(".").map(Number)}function pt(e,t){const n=ct(e),r=ct(t),s=Math.max(n.length,r.length);for(let a=0;a<s;a+=1){const i=n[a]||0,u=r[a]||0;if(i!==u)return i>u?1:-1}return 0}function m(e,t){return pt(e,t)<=0}function le(e,t,n){if(typeof n=="string"){if(e==="web_app_open_link"){if(t==="try_instant_view")return m("6.4",n);if(t==="try_browser")return m("7.6",n)}if(e==="web_app_set_header_color"&&t==="color")return m("6.9",n);if(e==="web_app_close"&&t==="return_back")return m("7.6",n);if(e==="web_app_setup_main_button"&&t==="has_shine_effect")return m("7.10",n)}switch(e){case"web_app_open_tg_link":case"web_app_open_invoice":case"web_app_setup_back_button":case"web_app_set_background_color":case"web_app_set_header_color":case"web_app_trigger_haptic_feedback":return m("6.1",t);case"web_app_open_popup":return m("6.2",t);case"web_app_close_scan_qr_popup":case"web_app_open_scan_qr_popup":case"web_app_read_text_from_clipboard":return m("6.4",t);case"web_app_switch_inline_query":return m("6.7",t);case"web_app_invoke_custom_method":case"web_app_request_write_access":case"web_app_request_phone":return m("6.9",t);case"web_app_setup_settings_button":return m("6.10",t);case"web_app_biometry_get_info":case"web_app_biometry_open_settings":case"web_app_biometry_request_access":case"web_app_biometry_request_auth":case"web_app_biometry_update_token":return m("7.2",t);case"web_app_setup_swipe_behavior":return m("7.7",t);case"web_app_share_to_story":return m("7.8",t);case"web_app_setup_secondary_button":case"web_app_set_bottom_bar_color":return m("7.10",t);case"web_app_request_safe_area":case"web_app_request_content_safe_area":case"web_app_request_fullscreen":case"web_app_exit_fullscreen":case"web_app_set_emoji_status":case"web_app_add_to_home_screen":case"web_app_check_home_screen":case"web_app_request_emoji_status_access":case"web_app_check_location":case"web_app_open_location_settings":case"web_app_request_file_download":case"web_app_request_location":case"web_app_send_prepared_message":case"web_app_start_accelerometer":case"web_app_start_device_orientation":case"web_app_start_gyroscope":case"web_app_stop_accelerometer":case"web_app_stop_device_orientation":case"web_app_stop_gyroscope":case"web_app_toggle_orientation_lock":return m("8.0",t);default:return["iframe_ready","iframe_will_reload","web_app_close","web_app_data_send","web_app_expand","web_app_open_link","web_app_ready","web_app_request_theme","web_app_request_viewport","web_app_setup_main_button","web_app_setup_closing_behavior"].includes(e)}}function En(e,t){t||(t="strict");const n=typeof t=="function"?t:r=>{const{method:s,version:a}=r,i="param"in r?new Ve(s,r.param,a):new Xe(s,a);if(t==="strict")throw i;return console.warn(i.message)};return(r,s)=>le(r,e)?r==="web_app_set_header_color"&&T(E({color:_e()}),s)&&!le(r,"color",e)?n({version:e,method:r,param:"color"}):ue(r,s):n({version:e,method:r})}function kn(e,t,n,r){return ce("web_app_invoke_custom_method","custom_method_invoked",{...r||{},params:{method:e,params:t,req_id:n},capture:ut(n)}).then(({result:s,error:a})=>{if(a)throw new at(a);return s})}function Pn(){Ye(),He(!1),U.unsubAll(),U.reset()}return l.InitDataRetrieveError=rt,l.InvalidLaunchParamsError=nt,l.InvokeCustomMethodError=at,l.LaunchParamsRetrieveError=tt,l.MethodParameterUnsupportedError=Ve,l.MethodUnsupportedError=Xe,l.UnknownEnvError=st,l.captureSameReq=ut,l.compareVersions=pt,l.createPostEvent=En,l.emitEvent=se,l.hasWebviewProxy=K,l.invokeCustomMethod=kn,l.isIframe=Q,l.isInitDataRetrieveError=dn,l.isInvalidLaunchParamsError=fn,l.isInvokeCustomMethodError=_n,l.isLaunchParamsRetrieveError=ln,l.isMethodMethodParameterUnsupportedError=pn,l.isMethodUnsupportedError=cn,l.isTMA=vn,l.isUnknownEnvError=yn,l.mockTelegramEnv=gn,l.off=Qe,l.offAll=Ye,l.on=ie,l.postEvent=ue,l.request=ce,l.resetPackageState=Pn,l.retrieveLaunchParams=pe,l.retrieveRawInitData=wn,l.setDebug=He,l.supports=le,l.targetOrigin=U,Object.defineProperty(l,Symbol.toStringTag,{value:"Module"}),l}({});
//# sourceMappingURL=index.iife.js.map

@@ -355,3 +355,3 @@ var E;

}
function bt(t) {
function _t(t) {
return [Ae, t];

@@ -371,17 +371,17 @@ }

return c.forEach((rt) => rt()), D;
}, l = new AbortController(), { signal: b } = l;
}, l = new AbortController(), { signal: _ } = l;
s = (f) => {
!b.aborted && l.abort(f);
!_.aborted && l.abort(f);
};
const h = () => b.reason, j = (f) => {
const b = () => _.reason, j = (f) => {
const S = () => {
f(h());
f(b());
};
b.addEventListener("abort", S, !0);
_.addEventListener("abort", S, !0);
const D = () => {
b.removeEventListener("abort", S, !0);
_.removeEventListener("abort", S, !0);
};
return c.push(D), D;
}, nt = p((f) => {
i(f), s(bt(f));
i(f), s(_t(f));
});

@@ -416,4 +416,4 @@ r = p((f) => {

}
const ae = () => b.aborted, oe = () => pe(h()), ue = () => {
const f = h();
const ae = () => _.aborted, oe = () => pe(b()), ue = () => {
const f = b();
return pe(f) ? f[1] : void 0;

@@ -423,4 +423,4 @@ };

const f = u && u(nt, r, {
abortReason: h,
abortSignal: b,
abortReason: b,
abortSignal: _,
isAborted: ae,

@@ -435,3 +435,3 @@ isResolved: oe,

if (ae())
throw h();
throw b();
}

@@ -496,10 +496,10 @@ });

};
function ht(t) {
function bt(t) {
return t.replace(/_[a-z]/g, (e) => e[1].toUpperCase());
}
function _t(t) {
return Object.entries(t).reduce((e, [n, r]) => (e[ht(n)] = r, e), {});
function ht(t) {
return Object.entries(t).reduce((e, [n, r]) => (e[bt(n)] = r, e), {});
}
function K(t) {
const e = _t(t);
const e = ht(t);
for (const n in e) {

@@ -885,3 +885,3 @@ const r = e[n];

if (p.issues) {
const b = {
const _ = {
type: "object",

@@ -893,4 +893,4 @@ origin: "key",

};
for (const h of p.issues)
h.path = [b], (i = r.issues) == null || i.push(h);
for (const b of p.issues)
b.path = [_], (i = r.issues) == null || i.push(b);
if (r.issues || (r.issues = p.issues), s.abortEarly) {

@@ -906,3 +906,3 @@ r.typed = !1;

if (l.issues) {
const b = {
const _ = {
type: "object",

@@ -914,4 +914,4 @@ origin: "value",

};
for (const h of l.issues)
h.path ? h.path.unshift(b) : h.path = [b], (a = r.issues) == null || a.push(h);
for (const b of l.issues)
b.path ? b.path.unshift(_) : b.path = [_], (a = r.issues) == null || a.push(b);
if (r.issues || (r.issues = l.issues), s.abortEarly) {

@@ -1214,4 +1214,4 @@ r.typed = !1;

}
function p(...h) {
o && c(), a === "*" ? u(h) : u(...h);
function p(...b) {
o && c(), a === "*" ? u(b) : u(...b);
}

@@ -1221,4 +1221,4 @@ n.on(a, p);

r.set(a, l);
const b = l.get(u) || [];
return l.set(u, b), b.push([p, o || !1]), c;
const _ = l.get(u) || [];
return l.set(u, _), _.push([p, o || !1]), c;
},

@@ -1234,3 +1234,3 @@ s,

}
function be(t, e) {
function _e(t, e) {
window.dispatchEvent(new MessageEvent("message", {

@@ -1249,7 +1249,7 @@ data: JSON.stringify({ eventType: t, eventData: e }),

}
}), he = (t) => {
}), be = (t) => {
se(!1, "Event received:", t);
};
function Bt(t) {
t !== L && (L = t, L ? Qe("*", he) : Ht("*", he));
t !== L && (L = t, L ? Qe("*", be) : Ht("*", be));
}

@@ -1278,3 +1278,3 @@ const Ft = {

};
function _e(t) {
function he(t) {
if (t.source !== window.parent)

@@ -1313,4 +1313,4 @@ return;

() => {
const t = window, e = { receiveEvent: be };
t.TelegramGameProxy_receiveEvent = be, t.TelegramGameProxy = e, t.Telegram = { WebView: e }, window.addEventListener("message", _e);
const t = window, e = { receiveEvent: _e };
t.TelegramGameProxy_receiveEvent = _e, t.TelegramGameProxy = e, t.Telegram = { WebView: e }, window.addEventListener("message", he);
},

@@ -1320,3 +1320,3 @@ () => {

delete window[t];
}), window.removeEventListener("message", _e);
}), window.removeEventListener("message", he);
}

@@ -1348,3 +1348,3 @@ );

en,
bn
_n
] = P(

@@ -1357,3 +1357,3 @@ "MethodUnsupportedError",

tn,
hn
bn
] = P(

@@ -1371,3 +1371,3 @@ "MethodParameterUnsupportedError",

nn,
_n
hn
] = Vt(

@@ -1404,4 +1404,4 @@ "LaunchParamsRetrieveError",

s = c, un(o, () => {
[...r].forEach(([l, b]) => {
l(c, p), b && u(l, !0);
[...r].forEach(([l, _]) => {
l(c, p), _ && u(l, !0);
});

@@ -1419,4 +1419,4 @@ });

const u = (c, p) => {
const l = a(p), b = r.findIndex(([h, j]) => h === c && j.once === l.once && j.signal === l.signal);
b >= 0 && r.splice(b, 1);
const l = a(p), _ = r.findIndex(([b, j]) => b === c && j.once === l.once && j.signal === l.signal);
_ >= 0 && r.splice(_, 1);
}, o = Object.assign(

@@ -1596,3 +1596,3 @@ function() {

}
function _(t, e) {
function h(t, e) {
return fn(t, e) <= 0;

@@ -1604,12 +1604,12 @@ }

if (e === "try_instant_view")
return _("6.4", n);
return h("6.4", n);
if (e === "try_browser")
return _("7.6", n);
return h("7.6", n);
}
if (t === "web_app_set_header_color" && e === "color")
return _("6.9", n);
return h("6.9", n);
if (t === "web_app_close" && e === "return_back")
return _("7.6", n);
return h("7.6", n);
if (t === "web_app_setup_main_button" && e === "has_shine_effect")
return _("7.10", n);
return h("7.10", n);
}

@@ -1623,17 +1623,17 @@ switch (t) {

case "web_app_trigger_haptic_feedback":
return _("6.1", e);
return h("6.1", e);
case "web_app_open_popup":
return _("6.2", e);
return h("6.2", e);
case "web_app_close_scan_qr_popup":
case "web_app_open_scan_qr_popup":
case "web_app_read_text_from_clipboard":
return _("6.4", e);
return h("6.4", e);
case "web_app_switch_inline_query":
return _("6.7", e);
return h("6.7", e);
case "web_app_invoke_custom_method":
case "web_app_request_write_access":
case "web_app_request_phone":
return _("6.9", e);
return h("6.9", e);
case "web_app_setup_settings_button":
return _("6.10", e);
return h("6.10", e);
case "web_app_biometry_get_info":

@@ -1644,10 +1644,10 @@ case "web_app_biometry_open_settings":

case "web_app_biometry_update_token":
return _("7.2", e);
return h("7.2", e);
case "web_app_setup_swipe_behavior":
return _("7.7", e);
return h("7.7", e);
case "web_app_share_to_story":
return _("7.8", e);
return h("7.8", e);
case "web_app_setup_secondary_button":
case "web_app_set_bottom_bar_color":
return _("7.10", e);
return h("7.10", e);
case "web_app_request_safe_area":

@@ -1661,3 +1661,15 @@ case "web_app_request_content_safe_area":

case "web_app_request_emoji_status_access":
return _("8.0", e);
case "web_app_check_location":
case "web_app_open_location_settings":
case "web_app_request_file_download":
case "web_app_request_location":
case "web_app_send_prepared_message":
case "web_app_start_accelerometer":
case "web_app_start_device_orientation":
case "web_app_start_gyroscope":
case "web_app_stop_accelerometer":
case "web_app_stop_device_orientation":
case "web_app_stop_gyroscope":
case "web_app_toggle_orientation_lock":
return h("8.0", e);
default:

@@ -1714,3 +1726,3 @@ return [

$n as createPostEvent,
be as emitEvent,
_e as emitEvent,
$e as hasWebviewProxy,

@@ -1722,5 +1734,5 @@ Pn as invokeCustomMethod,

wn as isInvokeCustomMethodError,
_n as isLaunchParamsRetrieveError,
hn as isMethodMethodParameterUnsupportedError,
bn as isMethodUnsupportedError,
hn as isLaunchParamsRetrieveError,
bn as isMethodMethodParameterUnsupportedError,
_n as isMethodUnsupportedError,
En as isTMA,

@@ -1727,0 +1739,0 @@ gn as isUnknownEnvError,

{
"name": "@telegram-apps/bridge",
"version": "2.1.0",
"version": "2.2.0",
"description": "TypeScript package to provide communication layer between Mini App and Telegram application.",

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

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc