"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Qn=require("react");let Re=class Kn extends Error{constructor(t,n,o){super(typeof n=="object"?n.message:n||t,{cause:typeof n=="object"?n.cause:o}),this.type=t,Object.setPrototypeOf(this,Kn.prototype)}};function Zn(e){return e.replace(/[A-Z]/g,t=>`_${t.toLowerCase()}`)}function Es(e){return e.replace(/_[a-z]/g,t=>t[1].toUpperCase())}const Xn="ERR_INVALID_VALUE",eo="ERR_UNEXPECTED_VALUE",to="ERR_UNEXPECTED_TYPE",Ut="ERR_PARSE";function no(e,t){const n={};for(const o in e){const r=e[o];if(!r)continue;let i,s;typeof r=="function"?(i=o,s=r):[i,s]=r;try{const a=s(t(i));a!==void 0&&(n[o]=a)}catch(a){throw new Re(Ut,`Parser for "${o}" property failed${i===o?"":`. Source field: "${i}"`}`,a)}}return n}function qt(e){let t=e;if(typeof t=="string")try{t=JSON.parse(t)}catch(n){throw new Re(Xn,{cause:n})}if(typeof t!="object"||!t||Array.isArray(t))throw new Re(eo);return t}function U(e,t){return n=>{const o=r=>{if(!(n&&r===void 0))try{return t(r)}catch(i){throw new Re(Ut,{message:`"${e}" transformer failed to parse the value`,cause:i})}};return Object.assign(o,{isValid(r){try{return o(r),!0}catch{return!1}}})}}function Ue(e,t){return U(t||"object",n=>{const o=qt(n);return no(e,r=>o[r])})}function ke(e){throw new Re(to,`Unexpected value received: ${JSON.stringify(e)}`)}const vs=U("boolean",e=>{if(typeof e=="boolean")return e;const t=String(e);if(t==="1"||t==="true")return!0;if(t==="0"||t==="false")return!1;ke(e)}),j=U("string",e=>{if(typeof e=="string"||typeof e=="number")return e.toString();ke(e)}),qe=U("number",e=>{if(typeof e=="number")return e;if(typeof e=="string"){const t=Number(e);if(!Number.isNaN(t))return t}ke(e)}),Ht=U("date",e=>e instanceof Date?e:new Date(qe()(e)*1e3));function oo(e,t){return U(t||"searchParams",n=>{typeof n!="string"&&!(n instanceof URLSearchParams)&&ke(n);const o=typeof n=="string"?new URLSearchParams(n):n;return no(e,r=>{const i=o.get(r);return i===null?void 0:i})})}function Tt(e){for(const t in e)e[t]=[Zn(t),e[t]];return e}const Cs=e=>{const t=qe(),n=qe(!0),o=j(),r=j(!0),i=vs(!0),s=Ue(Tt({addedToAttachmentMenu:i,allowsWriteToPm:i,firstName:o,id:t,isBot:i,isPremium:i,languageCode:r,lastName:r,photoUrl:r,username:r}),"User")(!0);return oo(Tt({authDate:Ht(),canSendAfter:n,chat:Ue(Tt({id:t,type:o,title:o,photoUrl:r,username:r}),"Chat")(!0),chatInstance:r,chatType:r,hash:o,queryId:r,receiver:s,startParam:r,user:s}),"initData")(e)};function Z(e){return/^#[\da-f]{6}$/i.test(e)}function ro(e){return/^#[\da-f]{3}$/i.test(e)}function Wt(e){const t=e.replace(/\s/g,"").toLowerCase();if(Z(t))return t;if(ro(t)){let o="#";for(let r=0;r<3;r+=1)o+=t[1+r].repeat(2);return o}const n=t.match(/^rgb\((\d{1,3}),(\d{1,3}),(\d{1,3})\)$/)||t.match(/^rgba\((\d{1,3}),(\d{1,3}),(\d{1,3}),\d{1,3}\)$/);if(!n)throw new Error(`Value "${e}" does not satisfy any of known RGB formats.`);return n.slice(1).reduce((o,r)=>{const i=parseInt(r,10).toString(16);return o+(i.length===1?"0":"")+i},"#")}const As=U("rgb",e=>Wt(j()(e))),Rs=U("themeParams",e=>{const t=As(!0);return Object.entries(qt(e)).reduce((n,[o,r])=>(n[Es(o)]=t(r),n),{})});function io(e){return JSON.stringify(Object.fromEntries(Object.entries(e).map(([t,n])=>[Zn(t),n])))}function Bs(e){const{initDataRaw:t,startParam:n,showSettings:o,botInline:r}=e,i=new URLSearchParams;return i.set("tgWebAppPlatform",e.platform),i.set("tgWebAppThemeParams",io(e.themeParams)),i.set("tgWebAppVersion",e.version),t&&i.set("tgWebAppData",t),n&&i.set("tgWebAppStartParam",n),typeof o=="boolean"&&i.set("tgWebAppShowSettings",o?"1":"0"),typeof r=="boolean"&&i.set("tgWebAppBotInline",r?"1":"0"),i.toString()}function Ps(e,t){return U("array",n=>{let o;if(Array.isArray(n))o=n;else if(typeof n=="string")try{const r=JSON.parse(n);Array.isArray(r)&&(o=r)}catch{}return o||ke(n),o.map(e)})}function zt(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function He(...e){return e.map(t=>{if(typeof t=="string")return t;if(zt(t))return He(Object.entries(t).map(n=>n[1]&&n[0]));if(Array.isArray(t))return He(...t)}).filter(Boolean).join(" ")}function Ts(...e){return e.reduce((t,n)=>(zt(n)&&Object.entries(n).forEach(([o,r])=>{const i=He(t[o],r);i&&(t[o]=i)}),t),{})}let Be=class so extends Error{constructor(t,n,o){super(typeof n=="object"?n.message:n||t,{cause:typeof n=="object"?n.cause:o}),this.type=t,Object.setPrototypeOf(this,so.prototype)}};function ao(e){return e.replace(/[A-Z]/g,t=>`_${t.toLowerCase()}`)}function ks(e){return e.replace(/_[a-z]/g,t=>t[1].toUpperCase())}const Os="ERR_INVALID_VALUE",Ds="ERR_UNEXPECTED_VALUE",xs="ERR_UNEXPECTED_TYPE",co="ERR_PARSE";function uo(e,t){const n={};for(const o in e){const r=e[o];if(!r)continue;let i,s;typeof r=="function"?(i=o,s=r):[i,s]=r;try{const a=s(t(i));a!==void 0&&(n[o]=a)}catch(a){throw new Be(co,`Parser for "${o}" property failed${i===o?"":`. Source field: "${i}"`}`,a)}}return n}function po(e){let t=e;if(typeof t=="string")try{t=JSON.parse(t)}catch(n){throw new Be(Os,{cause:n})}if(typeof t!="object"||!t||Array.isArray(t))throw new Be(Ds);return t}function D(e,t){return n=>{const o=r=>{if(!(n&&r===void 0))try{return t(r)}catch(i){throw new Be(co,{message:`"${e}" transformer failed to parse the value`,cause:i})}};return Object.assign(o,{isValid(r){try{return o(r),!0}catch{return!1}}})}}function O(e,t){return D(t||"object",n=>{const o=po(n);return uo(e,r=>o[r])})}function Oe(e){throw new Be(xs,`Unexpected value received: ${JSON.stringify(e)}`)}const We=D("boolean",e=>{if(typeof e=="boolean")return e;const t=String(e);if(t==="1"||t==="true")return!0;if(t==="0"||t==="false")return!1;Oe(e)}),A=D("string",e=>{if(typeof e=="string"||typeof e=="number")return e.toString();Oe(e)}),Pe=D("number",e=>{if(typeof e=="number")return e;if(typeof e=="string"){const t=Number(e);if(!Number.isNaN(t))return t}Oe(e)}),Ms=D("date",e=>e instanceof Date?e:new Date(Pe()(e)*1e3));function lo(e,t){return D(t||"searchParams",n=>{typeof n!="string"&&!(n instanceof URLSearchParams)&&Oe(n);const o=typeof n=="string"?new URLSearchParams(n):n;return uo(e,r=>{const i=o.get(r);return i===null?void 0:i})})}function kt(e){for(const t in e)e[t]=[ao(t),e[t]];return e}const Vs=e=>{const t=Pe(),n=Pe(!0),o=A(),r=A(!0),i=We(!0),s=O(kt({addedToAttachmentMenu:i,allowsWriteToPm:i,firstName:o,id:t,isBot:i,isPremium:i,languageCode:r,lastName:r,photoUrl:r,username:r}),"User")(!0);return lo(kt({authDate:Ms(),canSendAfter:n,chat:O(kt({id:t,type:o,title:o,photoUrl:r,username:r}),"Chat")(!0),chatInstance:r,chatType:r,hash:o,queryId:r,receiver:s,startParam:r,user:s}),"initData")(e)};function Is(e){return/^#[\da-f]{6}$/i.test(e)}function Ns(e){return/^#[\da-f]{3}$/i.test(e)}function Ls(e){const t=e.replace(/\s/g,"").toLowerCase();if(Is(t))return t;if(Ns(t)){let o="#";for(let r=0;r<3;r+=1)o+=t[1+r].repeat(2);return o}const n=t.match(/^rgb\((\d{1,3}),(\d{1,3}),(\d{1,3})\)$/)||t.match(/^rgba\((\d{1,3}),(\d{1,3}),(\d{1,3}),\d{1,3}\)$/);if(!n)throw new Error(`Value "${e}" does not satisfy any of known RGB formats.`);return n.slice(1).reduce((o,r)=>{const i=parseInt(r,10).toString(16);return o+(i.length===1?"0":"")+i},"#")}const js=D("rgb",e=>Ls(A()(e))),$s=D("themeParams",e=>{const t=js(!0);return Object.entries(po(e)).reduce((n,[o,r])=>(n[ks(o)]=t(r),n),{})});function _o(e){return JSON.stringify(Object.fromEntries(Object.entries(e).map(([t,n])=>[ao(t),n])))}const Us=e=>{const t=A(),n=A(!0),o=We(!0);return lo({botInline:["tgWebAppBotInline",o],initData:["tgWebAppData",Vs(!0)],initDataRaw:["tgWebAppData",n],platform:["tgWebAppPlatform",t],showSettings:["tgWebAppShowSettings",o],startParam:["tgWebAppStartParam",n],themeParams:["tgWebAppThemeParams",$s()],version:["tgWebAppVersion",t]},"launchParams")(e)};function qs(e){const{initDataRaw:t,startParam:n,showSettings:o,botInline:r}=e,i=new URLSearchParams;return i.set("tgWebAppPlatform",e.platform),i.set("tgWebAppThemeParams",_o(e.themeParams)),i.set("tgWebAppVersion",e.version),t&&i.set("tgWebAppData",t),n&&i.set("tgWebAppStartParam",n),typeof o=="boolean"&&i.set("tgWebAppShowSettings",o?"1":"0"),typeof r=="boolean"&&i.set("tgWebAppBotInline",r?"1":"0"),i.toString()}const fo=O({eventType:A(),eventData:e=>e},"miniAppsMessage"),ho=D("fn",e=>{if(typeof e=="function")return e;Oe(e)});function Hs(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}const Ws=O({TelegramWebviewProxy:O({postEvent:ho()})()});function mo(e){return Ws().isValid(e)}function bo(){try{return window.self!==window.top}catch{return!0}}var zs=Object.defineProperty,Gs=(e,t,n)=>t in e?zs(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,go=(e,t,n)=>Gs(e,typeof t!="symbol"?t+"":t,n);let l=class wo extends Error{constructor(t,n,o){super(typeof n=="object"?n.message:n||t,{cause:typeof n=="object"?n.cause:o}),this.type=t,Object.setPrototypeOf(this,wo.prototype)}};function ze(e,t,n){return e.addEventListener(t,n),()=>e.removeEventListener(t,n)}function le(...e){const t=e.flat(1);return[t.push.bind(t),()=>{t.forEach(n=>{n()})}]}function Fs(e,t){return e instanceof l&&e.type===t}function Gt(e){return t=>Fs(t,e)}const Ft="ERR_ABORTED",Jt="ERR_CANCELED",Yt="ERR_TIMED_OUT";function Ln(e){return new l(Ft,{cause:e})}const Js=Gt(Yt),Ys=Gt(Ft),Qs=Gt(Jt);function jn(e,t){return e.reject=t.reject,e}class b extends Promise{constructor(t,n){let o,r;typeof t=="function"?(o=t,r=n):r=t;let i,s;super((a,p)=>{r||(r={});const{abortSignal:c}=r;if(c&&c.aborted)return p(Ln(c.reason));const[_,g]=le(),w=f=>(...F)=>(g(),f(...F)),L=new AbortController,{signal:v}=L;s=w(f=>{L.abort(f),p(f)}),i=w(a),c&&_(ze(c,"abort",()=>{s(Ln(c.reason))}));const{timeout:m}=r;if(m){const f=setTimeout(()=>{s(new l(Yt,`Timeout reached: ${m}ms`))},m);_(()=>{clearTimeout(f)})}o&&o(i,s,v)}),go(this,"reject"),this.reject=s}static withFn(t,n){return new b((o,r,i)=>{try{const s=t(i);return s instanceof Promise?s.then(o,r):o(s)}catch(s){r(s)}},n)}static resolve(t){return new b(n=>{n(t)})}static reject(t){return new b((n,o)=>{o(t)})}cancel(){this.reject(new l(Jt))}catch(t){return this.then(void 0,t)}finally(t){return jn(super.finally(t),this)}then(t,n){return jn(super.then(t,n),this)}}function $n(e,t){return e.resolve=t.resolve,e}class he extends b{constructor(t,n){let o,r;typeof t=="function"?(o=t,r=n):r=t;let i;super((s,a,p)=>{i=s,o&&o(s,a,p)},r),go(this,"resolve"),this.resolve=i}static withFn(t,n){return new he((o,r,i)=>b.withFn(t,{abortSignal:i}).then(o,r),n)}static resolve(t){return new he(n=>{n(t)})}static reject(t){return new he((n,o)=>{o(t)})}catch(t){return this.then(void 0,t)}finally(t){return $n(super.finally(t),this)}then(t,n){return $n(super.then(t,n),this)}}function Ks(e,t){return new b(n=>{setTimeout(n,e)},{abortSignal:t})}function yo(e){return`tapps/${e}`}function B(e,t){sessionStorage.setItem(yo(e),JSON.stringify(t))}function P(e){const t=sessionStorage.getItem(yo(e));try{return t?JSON.parse(t):void 0}catch{}}function Qt(e){return e.replace(/[A-Z]/g,t=>`-${t.toLowerCase()}`)}function Zs(e,t){t||(t={});const{textColor:n,bgColor:o,shouldLog:r=!0}=t;function i(s,...a){if(!r||typeof r=="function"&&!r())return;const p="font-weight:bold;padding:0 5px;border-radius:5px";console[s](`%c${Intl.DateTimeFormat("en-GB",{hour:"2-digit",minute:"2-digit",second:"2-digit",fractionalSecondDigits:3,timeZone:"UTC"}).format(new Date)}%c / %c${e}`,`${p};background-color: lightblue;color:black`,"",`${p};${n?`color:${n};`:""}${o?`background-color:${o}`:""}`,...a)}return[function(...s){i("log",...s)},function(...s){i("error",...s)}]}function Xe(e,t){document.documentElement.style.setProperty(e,t)}function et(e){document.documentElement.style.removeProperty(e)}function Xs(e,t){t()}function de(e,t){t||(t={});const n=t.equals||Object.is;let o=[],r=e;const i=c=>{if(!n(r,c)){const _=r;r=c,Xs(p,()=>{[...o].forEach(([g,w])=>{g(c,_),w&&a(g,!0)})})}};function s(c){const _=typeof c!="object"?{once:c}:c;return{once:_.once||!1,signal:_.signal||!1}}const a=(c,_)=>{const g=s(_),w=o.findIndex(([L,v])=>L===c&&v.once===g.once&&v.signal===g.signal);w>=0&&o.splice(w,1)},p=Object.assign(function(){return ea(p),r},{destroy(){o=[]},set:i,reset(){i(e)},sub(c,_){return o.push([c,s(_)]),()=>a(c,_)},unsub:a,unsubAll(){o=o.filter(c=>c[1].signal)}});return p}const Ot=[];function ea(e){Ot.length&&Ot[Ot.length-1].add(e)}const So=de(!1),[Kt,ta]=Zs("Bridge",{bgColor:"#9147ff",textColor:"white",shouldLog:So}),na={clipboard_text_received:O({req_id:A(),data:e=>e===null?e:A(!0)(e)},"clipboard_text_received"),custom_method_invoked:O({req_id:A(),result:e=>e,error:A(!0)},"custom_method_invoked"),popup_closed:D("popup_closed",e=>e?O({button_id:t=>t==null?void 0:A()(t)})()(e):{}),viewport_changed:O({height:Pe(),width:e=>e==null?window.innerWidth:Pe()(e),is_state_stable:We(),is_expanded:We()},"viewport_changed")};function oa(e){const t=window,[,n]=le(ze(t,"resize",()=>{e(["viewport_changed",{width:window.innerWidth,height:window.innerHeight,is_state_stable:!0,is_expanded:!0}])}),ze(t,"message",o=>{if(o.source!==t.parent)return;let r;try{r=fo()(o.data)}catch{return}const{eventType:i,eventData:s}=r,a=na[i];try{const p=a?a()(s):s;Kt("Event received:",p?{eventType:i,eventData:p}:{eventType:i}),e([i,p])}catch(p){ta([`An error occurred processing the "${i}" event from the Telegram application.`,"Please, file an issue here:","https://github.com/Telegram-Mini-Apps/telegram-apps/issues/new/choose"].join(` `),r,p)}}));return n}const Mt=de(),Un=de();function Eo(){return Un()||Un.set(oa(Mt.set)),Mt}const Dt=de({});function vo(e){let t=Dt()[e];return t||(t=de(void 0,{equals(){return!1}}),Eo().sub(n=>{n&&n[0]===e&&t.set(n[1])}),Dt.set({...Dt(),[e]:t})),t}function E(e,t,n){return vo(e).sub(t,n)}const Co="ERR_METHOD_UNSUPPORTED",Ao="ERR_RETRIEVE_LP_FAILED",Ro="ERR_METHOD_PARAMETER_UNSUPPORTED",Zt="ERR_UNKNOWN_ENV",Bo="ERR_INVOKE_CUSTOM_METHOD_RESPONSE",Po=de("https://web.telegram.org");function tt(e,t){Kt("Posting event:",t?{eventType:e,eventData:t}:{eventType:e});const n=window;if(mo(n)){n.TelegramWebviewProxy.postEvent(e,JSON.stringify(t));return}const o=JSON.stringify({eventType:e,eventData:t});if(bo())return n.parent.postMessage(o,Po());const{external:r}=n;if(O({notify:ho()})().isValid(r)){r.notify(o);return}throw new l(Zt)}function nt(e,t,n){n||(n={});const{capture:o}=n,[r,i]=le();return new b(s=>{(Array.isArray(t)?t:[t]).forEach(a=>{r(E(a,p=>{(!o||(Array.isArray(t)?o({event:a,payload:p}):o(p)))&&s(p)}))}),(n.postEvent||tt)(e,n.params)},n).finally(i)}function Xt(e){return Us()(e)}function To(e){return Xt(e.replace(/^[^?#]*[?#]/,"").replace(/[?#]/g,"&"))}function ra(){return To(window.location.href)}function ia(){const e=performance.getEntriesByType("navigation")[0];if(!e)throw new Error("Unable to get first navigation entry.");return To(e.name)}const sa="launchParams";function aa(){return Xt(P(sa)||"")}function ko(e){B("launchParams",qs(e))}function Oo(e){return e instanceof Error?e.message+(e.cause?` ${Oo(e.cause)}`:""):JSON.stringify(e)}function W(){const e=[];for(const t of[ra,ia,aa])try{const n=t();return ko(n),n}catch(n){e.push(n)}throw new l(Ao,["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-sdk/environment","Collected errors:",...e.map(t=>`— ${Oo(t)}`)].join(` `))}function Vt(e){if(e==="simple")try{return W(),!0}catch{return!1}return b.withFn(async()=>{if(mo(window))return!0;try{return await nt("web_app_request_theme","theme_changed",{timeout:100}),!0}catch{return!1}},e)}function Ge(e,t){window.dispatchEvent(new MessageEvent("message",{data:JSON.stringify({eventType:e,eventData:t}),source:window.parent}))}function ca(e,t){if(typeof t=="string")try{const{eventType:n}=fo()(t);n==="web_app_request_theme"&&Ge("theme_changed",{theme_params:JSON.parse(_o(e))}),n==="web_app_request_viewport"&&Ge("viewport_changed",{width:window.innerWidth,height:window.innerHeight,is_state_stable:!0,is_expanded:!0})}catch{}}function ua(e){var t;const n=typeof e=="string"?Xt(e):e;ko(n);const o=(t=window.TelegramWebviewProxy)==null?void 0:t.postEvent;window.TelegramWebviewProxy={postEvent(r,i){ca(n.themeParams,JSON.stringify({eventType:r,eventData:i})),o==null||o(r,i)}},Kt("Environment was mocked by the mockTelegramEnv function")}function Do(){[["TelegramGameProxy_receiveEvent"],["TelegramGameProxy","receiveEvent"],["Telegram","WebView","receiveEvent"]].forEach(e=>{let t=window;e.forEach((n,o,r)=>{if(o===r.length-1){t[n]=Ge;return}n in t||(t[n]={}),t=t[n]})})}function xo(){["TelegramGameProxy_receiveEvent","TelegramGameProxy","Telegram"].forEach(e=>{delete window[e]})}function z(e,t,n){vo(e).unsub(t,n)}function pa(e,t){return Eo().sub(e,t)}function la(e,t){Mt.unsub(e,t)}function Mo(e){return({req_id:t})=>t===e}function qn(e){return e.split(".").map(Number)}function Vo(e,t){const n=qn(e),o=qn(t),r=Math.max(n.length,o.length);for(let i=0;ia?1:-1}return 0}function y(e,t){return Vo(e,t)<=0}function H(e,t,n){if(typeof n=="string"){if(e==="web_app_open_link"){if(t==="try_instant_view")return y("6.4",n);if(t==="try_browser")return y("7.6",n)}if(e==="web_app_set_header_color"&&t==="color")return y("6.9",n);if(e==="web_app_close"&&t==="return_back")return y("7.6",n);if(e==="web_app_setup_main_button"&&t==="has_shine_effect")return y("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 y("6.1",t);case"web_app_open_popup":return y("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 y("6.4",t);case"web_app_switch_inline_query":return y("6.7",t);case"web_app_invoke_custom_method":case"web_app_request_write_access":case"web_app_request_phone":return y("6.9",t);case"web_app_setup_settings_button":return y("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 y("7.2",t);case"web_app_setup_swipe_behavior":return y("7.7",t);case"web_app_share_to_story":return y("7.8",t);case"web_app_setup_secondary_button":case"web_app_set_bottom_bar_color":return y("7.10",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 Io(e,t){t||(t="strict");const n=typeof t=="function"?t:o=>{const{method:r,version:i}=o;let s,a;if("param"in o?(s=`Parameter "${o.param}" of "${r}" method is unsupported in Mini Apps version ${i}`,a=Ro):(s=`Method "${r}" is unsupported in Mini Apps version ${i}`,a=Co),t==="strict")throw new l(a,s);return console.warn(s)};return(o,r)=>H(o,e)?Hs(r)&&o==="web_app_set_header_color"&&"color"in r&&!H(o,"color",e)?n({version:e,method:o,param:"color"}):tt(o,r):n({version:e,method:o})}function No(e,t,n,o){return nt("web_app_invoke_custom_method","custom_method_invoked",{...o||{},params:{method:e,params:t,req_id:n},capture:Mo(n)}).then(({result:r,error:i})=>{if(i)throw new l(Bo,i);return r})}function da(){return performance.getEntriesByType("navigation")[0]}function x(){const e=da();return!!e&&e.type==="reload"}let K;function _a(e,t){K&&K.set(e,t)||t()}function fa(e){if(K)return e();K=new Map;try{e()}finally{K.forEach(t=>t()),K=void 0}}function u(e,t){t||(t={});const n=t.equals||Object.is;let o=[],r=e;const i=c=>{if(!n(r,c)){const _=r;r=c,_a(p,()=>{[...o].forEach(([g,w])=>{g(c,_),w&&a(g,!0)})})}};function s(c){const _=typeof c!="object"?{once:c}:c;return{once:_.once||!1,signal:_.signal||!1}}const a=(c,_)=>{const g=s(_),w=o.findIndex(([L,v])=>L===c&&v.once===g.once&&v.signal===g.signal);w>=0&&o.splice(w,1)},p=Object.assign(function(){return ha(p),r},{destroy(){o=[]},set:i,reset(){i(e)},sub(c,_){return o.push([c,s(_)]),()=>a(c,_)},unsub:a,unsubAll(){o=o.filter(c=>c[1].signal)}});return p}const me=[];function ha(e){me.length&&me[me.length-1].add(e)}function h(e,t){let n=new Set,o;function r(){return o||(o=u(s(),t))}function i(){r().set(s())}function s(){n.forEach(c=>{c.unsub(i,{signal:!0})});const a=new Set;let p;me.push(a);try{p=e()}finally{me.pop()}return a.forEach(c=>{c.sub(i,{signal:!0})}),n=a,p}return Object.assign(function(){return r()()},{destroy(){r().destroy()},sub(...a){return r().sub(...a)},unsub(...a){r().unsub(...a)},unsubAll(...a){r().unsubAll(...a)}})}const Lo=u((()=>{let e=0;return()=>(e+=1).toString()})()),en=u(tt),k=u("0.0");function ma(e){e||(e={});const{postEvent:t}=e,n=e.version||W().version;k.set(n),en.set(typeof t=="function"?t:Io(n))}function jo(){return Lo()()}function _e(e,t,n){return No(e,t,jo(),{...n||{},postEvent:d})}const M=(e,t,n)=>(n||(n={}),n.postEvent||(n.postEvent=d),nt(e,t,n)),d=(e,t)=>en()(e,t);function V(e){return h(()=>H(e,k()))}const Q="ERR_POPUP_INVALID_PARAMS",ot="ERR_INVALID_URL",$o="ERR_INVALID_SLUG",Uo="ERR_DATA_INVALID_SIZE",qo="ERR_ACCESS_DENIED",De="ERR_ALREADY_REQUESTING",rt="ERR_ALREADY_OPENED",Ho="ERR_ALREADY_MOUNTING",Wo="ERR_VARS_ALREADY_BOUND",zo="ERR_NOT_AVAILABLE",Go="ERR_NOT_INITIALIZED",It="ERR_NOT_SUPPORTED",Fo="ERR_NOT_MOUNTED";function Nt(){return typeof window>"u"}function I(e,t,{isSupported:n,isMounted:o,component:r,supports:i}={}){const s=`${r?`${r}.`:""}${e}()`;n=n?Array.isArray(n)||typeof n=="object"&&"any"in n?n:[n]:void 0;function a(m){if(i){const f=i[m];return H(f[0],f[1],k())}return!0}const p=()=>{if(!n)return;const m=`it is unsupported in Mini Apps version ${k()}`;function f(C){return typeof C=="string"?H(C,k())?void 0:m:C.fn()?void 0:C.error}if(Array.isArray(n)){for(const C of n){const Nn=f(C);if(Nn)return Nn}return}let F;for(const C of n.any)if(F=f(C),!F)return;return m},c=(...m)=>{if(i){for(const f in i)if(i[f][2](...m)&&!a(f))return`option ${f} is not supported in Mini Apps version ${k()}`}},_=h(()=>!p()),g=h(()=>k()!=="0.0"),w=h(()=>!o||o()),L=h(()=>Vt("simple")&&!Nt()&&g()&&_()&&w());let v;if(i){v={};for(const m in i)v[m]=h(()=>a(m))}return Object.assign((...m)=>{const f=`Unable to call the ${s} ${r?"method":"function"}:`;if(Nt()||!Vt("simple"))throw new l(Zt,`${f} it can't be called outside Mini Apps`);if(!g())throw new l(Go,`${f} the SDK was not initialized. Use the SDK init() function`);const F=p();if(F)throw new l(It,`${f} ${F}`);const C=c(...m);if(C)throw new l(It,`${f} ${C}`);if(!w())throw new l(Fo,`${f} the component is not mounted. Use the ${r}.mount() method`);return t(...m)},t,{isAvailable:L,ifAvailable(...m){return L()?t(...m):void 0}},n?{isSupported:_}:{},v?{supports:v}:{})}function it(e,t){return t||(t={}),(n,o,r,i)=>I(n,o,{...t,isSupported:r||t.isSupported,supports:i,component:e})}function fe(e,t,n){return it(e,{isSupported:n,isMounted:t})}function T(e,t){return it(e,{isSupported:t})}const st="web_app_setup_back_button",Jo="back_button_pressed",at="backButton",Fe=u(!1),X=u(!1),Yo=V(st),Qo=fe(at,X,st),tn=T(at,st),Ko=Qo("hide",()=>{nn(!1)}),Zo=tn("mount",()=>{X()||(nn(x()&&P(at)||!1),X.set(!0))});function nn(e){e!==Fe()&&(d(st,{is_visible:e}),B(at,e),Fe.set(e))}const Xo=tn("onClick",e=>E(Jo,e)),er=tn("offClick",e=>{z(Jo,e)}),tr=Qo("show",()=>{nn(!0)});function nr(){X.set(!1)}const ba=Object.freeze(Object.defineProperty({__proto__:null,hide:Ko,isMounted:X,isSupported:Yo,isVisible:Fe,mount:Zo,offClick:er,onClick:Xo,show:tr,unmount:nr},Symbol.toStringTag,{value:"Module"}));function or(e,t,n,{isMounting:o,isMounted:r,mountError:i}){return s=>b.withFn(async a=>{if(r())return;if(o())throw new l(Ho,`The ${e} component is already mounting`);o.set(!0);let p;try{p=[!0,await t({abortSignal:a})]}catch(c){p=[!1,c]}fa(()=>{if(o.set(!1),r.set(!0),p[0])n(p[1]);else{const c=p[1];throw i.set(c),c}})},s)}const q=it,xe=u(),be=u(!1),ge=u(!1),Me=u(!1),on=u(!1),rn=u(void 0),ga=h(()=>{const e=xe();return e&&e.available});function sn(e){return e.available?{available:!0,tokenSaved:e.token_saved,deviceId:e.device_id,accessRequested:e.access_requested,type:e.type,accessGranted:e.access_granted}:{available:!1}}const Hn="web_app_biometry_get_info",rr=I("requestBiometry",e=>M(Hn,"biometry_info_received",e).then(sn),{isSupported:Hn}),ct="web_app_biometry_request_auth",wa="web_app_biometry_request_access",ya="web_app_biometry_open_settings",Sa="web_app_biometry_update_token",an="biometry_info_received",ee="biometry",ir=V(ct),Ea=q(ee),va=T(ee,ct),cn=fe(ee,Me,ct);function sr(){throw new l(zo,"Biometry is not available")}const ar=cn("authenticate",e=>b.withFn(async t=>{if(be())throw new l(De,"Authentication is already in progress");const n=xe();(!n||!n.available)&&sr(),be.set(!0);try{const o=await M(ct,"biometry_auth_requested",{abortSignal:t,params:{reason:((e||{}).reason||"").trim()}}),{token:r}=o;return typeof r=="string"&&ut({...n,token:r}),o}finally{be.set(!1)}},e)),cr=va("openSettings",()=>{d(ya)}),ur=cn("requestAccess",e=>b.withFn(async t=>{if(ge())throw new l(De,"Access request is already in progress");ge.set(!0);try{const n=await M(wa,an,{abortSignal:t,params:{reason:(e||{}).reason||""}}).then(sn);return n.available||sr(),ut(n),n.accessGranted}finally{ge.set(!1)}},e)),pr=Ea("mount",or(ee,e=>x()&&P(ee)||rr(e),e=>{E(an,lr),ut(e)},{isMounted:Me,mountError:rn,isMounting:on})),lr=e=>{ut(sn(e))};function ut(e){xe.set(e),B(ee,e)}function dr(){z(an,lr),Me.set(!1)}const _r=cn("updateToken",e=>(e||(e={}),M(Sa,"biometry_token_updated",{...e,params:{token:e.token||"",reason:e.reason}}).then(t=>t.status))),Ca=Object.freeze(Object.defineProperty({__proto__:null,authenticate:ar,isAuthenticating:be,isAvailable:ga,isMounted:Me,isMounting:on,isRequestingAccess:ge,isSupported:ir,mount:pr,mountError:rn,openSettings:cr,requestAccess:ur,state:xe,unmount:dr,updateToken:_r},Symbol.toStringTag,{value:"Module"}));function pt(e,t){return it(e,{isMounted:t})}const lt="closingBehavior",Je=u(!1),te=u(!1),fr=pt(lt,te),Aa=q(lt),hr=fr("disableConfirmation",()=>{un(!1)}),mr=fr("enableConfirmation",()=>{un(!0)}),br=Aa("mount",()=>{te()||(un(x()&&P(lt)||!1),te.set(!0))});function un(e){e!==Je()&&(d("web_app_setup_closing_behavior",{need_confirmation:e}),B(lt,e),Je.set(e))}function gr(){te.set(!1)}const Ra=Object.freeze(Object.defineProperty({__proto__:null,disableConfirmation:hr,enableConfirmation:mr,isConfirmationEnabled:Je,isMounted:te,mount:br,unmount:gr},Symbol.toStringTag,{value:"Module"})),wr="web_app_invoke_custom_method",dt=T("cloudStorage",wr),yr=V(wr),Sr=dt("deleteItem",(e,t)=>{const n=Array.isArray(e)?e:[e];return n.length?_e("deleteStorageValues",{keys:n},t).then():b.resolve()});function Ba(e,t){const n=Array.isArray(e)?e:[e];return n.length?_e("getStorageValues",{keys:n},t).then(o=>{const r=Ue(Object.fromEntries(n.map(i=>[i,j()])))()(o);return Array.isArray(e)?r:r[e]}):b.resolve(typeof e=="string"?"":{})}const Er=dt("getItem",Ba),vr=dt("getKeys",e=>_e("getStorageKeys",{},e).then(Ps(j())())),Cr=dt("setItem",(e,t,n)=>_e("saveStorageValue",{key:e,value:t},n).then()),Pa=Object.freeze(Object.defineProperty({__proto__:null,deleteItem:Sr,getItem:Er,getKeys:vr,isSupported:yr,setItem:Cr},Symbol.toStringTag,{value:"Module"})),Ve="web_app_trigger_haptic_feedback",pn=T("hapticFeedback",Ve),Ar=V(Ve),Rr=pn("impactOccurred",e=>{d(Ve,{type:"impact",impact_style:e})}),Br=pn("notificationOccurred",e=>{d(Ve,{type:"notification",notification_type:e})}),Pr=pn("selectionChanged",()=>{d(Ve,{type:"selection_change"})}),Ta=Object.freeze(Object.defineProperty({__proto__:null,impactOccurred:Rr,isSupported:Ar,notificationOccurred:Br,selectionChanged:Pr},Symbol.toStringTag,{value:"Module"})),_t=u(void 0);function N(e){return h(()=>{const t=_t();return t?t[e]:void 0})}const ln=N("authDate"),dn=N("canSendAfter"),Tr=h(()=>{const e=ln(),t=dn();return t&&e?new Date(e.getTime()+t*1e3):void 0}),kr=N("chat"),Or=N("chatType"),Dr=N("chatInstance"),xr=N("hash"),Mr=N("queryId"),_n=u(),Vr=N("receiver");function Ir(){const e=W();_t.set(e.initData),_n.set(e.initDataRaw)}const Nr=N("startParam"),Lr=N("user"),ka=Object.freeze(Object.defineProperty({__proto__:null,authDate:ln,canSendAfter:dn,canSendAfterDate:Tr,chat:kr,chatInstance:Dr,chatType:Or,hash:xr,queryId:Mr,raw:_n,receiver:Vr,restore:Ir,startParam:Nr,state:_t,user:Lr},Symbol.toStringTag,{value:"Module"}));function Oa(e){return Cs()(e)}const fn="web_app_open_invoice",Da=T("invoice",fn),we=u(!1),jr=V(fn);async function $r(e,t,n){if(we())throw new l(rt,"An invoice is already opened");let o;if(t==="url"){const{hostname:r,pathname:i}=new URL(e,window.location.href);if(r!=="t.me")throw new l(ot,`Link has unexpected hostname: ${r}`);const s=i.match(/^\/(\$|invoice\/)([A-Za-z0-9\-_=]+)$/);if(!s)throw new l($o,'Expected to receive a link with a pathname in format "/invoice/{slug}" or "/${slug}"');[,,o]=s}else o=e,n=t;return we.set(!0),M(fn,"invoice_closed",{...n,params:{slug:o},capture:r=>o===r.slug}).then(r=>r.status).finally(()=>{we.set(!1)})}const Ur=Da("open",$r),xa=Object.freeze(Object.defineProperty({__proto__:null,_open:$r,isOpened:we,isSupported:jr,open:Ur},Symbol.toStringTag,{value:"Module"}));function hn(e){const t=Wt(e);return Math.sqrt([.299,.587,.114].reduce((n,o,r)=>{const i=parseInt(t.slice(1+r*2,1+(r+1)*2),16);return n+i*i*o},0))<120}const ne=u(!1),ye=u(!1),$=u({});function S(e){return h(()=>$()[e])}const qr=S("accentTextColor"),ft=S("bgColor"),ht=S("buttonColor"),mn=S("buttonTextColor"),bn=S("bottomBarBgColor"),Hr=S("destructiveTextColor"),Wr=S("headerBgColor"),zr=S("hintColor"),Gr=h(()=>{const{bgColor:e}=$();return!e||hn(e)}),Fr=S("linkColor"),Te=S("secondaryBgColor"),Jr=S("sectionBgColor"),Yr=S("sectionHeaderTextColor"),Qr=S("sectionSeparatorColor"),Kr=S("subtitleTextColor"),Zr=S("textColor");function Y(e){return h(()=>mt()[e])}const Se=u({hasShineEffect:!1,isEnabled:!0,isLoaderVisible:!1,isVisible:!1,text:"Continue"}),mt=h(()=>{const e=Se();return{...e,backgroundColor:e.backgroundColor||ht()||"#2481cc",textColor:e.textColor||mn()||"#ffffff"}}),oe=u(!1),Xr=Y("backgroundColor"),ei=Y("hasShineEffect"),ti=Y("isEnabled"),ni=Y("isLoaderVisible"),oi=Y("isVisible"),ri=Y("text"),ii=Y("textColor"),Ma="web_app_setup_main_button",si="main_button_pressed",bt="mainButton",gn=q(bt),Va=pt(bt,oe),ai=gn("mount",()=>{if(!oe()){const e=x()&&P(bt);e&&Se.set(e),oe.set(!0)}}),ci=gn("onClick",e=>E(si,e)),ui=gn("offClick",e=>{z(si,e)}),pi=Va("setParams",e=>{Se.set({...Se(),...Object.fromEntries(Object.entries(e).filter(([,n])=>n!==void 0))}),B(bt,Se());const t=mt();t.text&&d(Ma,{color:t.backgroundColor,has_shine_effect:t.hasShineEffect,is_active:t.isEnabled,is_progress_visible:t.isLoaderVisible,is_visible:t.isVisible,text:t.text,text_color:t.textColor})});function li(){oe.set(!1)}const Ia=Object.freeze(Object.defineProperty({__proto__:null,backgroundColor:Xr,hasShineEffect:ei,isEnabled:ti,isLoaderVisible:ni,isMounted:oe,isVisible:oi,mount:ai,offClick:ui,onClick:ci,setParams:pi,state:mt,text:ri,textColor:ii,unmount:li},Symbol.toStringTag,{value:"Module"}));function wn(){throw new l(Wo,"CSS variables are already bound")}function di(e){return Rs()(e)}const gt="themeParams",_i="theme_changed",Na=q(gt),La=pt(gt,ne),fi=La("bindCssVars",e=>{ye()&&wn(),e||(e=o=>`--tg-theme-${Qt(o)}`);function t(o){Object.entries($()).forEach(([r,i])=>{i&&o(r,i)})}function n(){t((o,r)=>{Xe(e(o),r)})}return n(),$.sub(n),ye.set(!0),()=>{t(et),$.unsub(n),ye.set(!1)}}),yn=Na("mount",()=>{ne()||(E(_i,hi),$.set(x()&&P(gt)||W().themeParams),ne.set(!0))}),hi=e=>{const t=di(e.theme_params);$.set(t),B(gt,t)};function mi(){z(_i,hi),ne.set(!1)}function bi(e){return h(()=>{const t=e();return Z(t)?t:t==="bg_color"?ft():Te()})}const re=u("bg_color"),Sn=bi(re),ie=u("bottom_bar_bg_color"),wt=h(()=>{const e=ie();return Z(e)?e:e==="bottom_bar_bg_color"?bn()||Te():e==="secondary_bg_color"?Te():ft()}),se=u("bg_color"),En=bi(se),ae=u(!1),Ee=u(!1),gi=h(()=>{const e=Sn();return e?hn(e):!1}),vn=h(()=>({backgroundColor:re(),bottomBarColor:ie(),headerColor:se()})),Lt="web_app_set_background_color",jt="web_app_set_bottom_bar_color",Le="web_app_set_header_color",Ie="miniApp",Cn={any:[Lt,jt,Le]},wi=h(()=>Cn.any.some(e=>H(e,k()))),yi=q(Ie),ja=T(Ie,Cn),yt=fe(Ie,ae,Cn),Si=yt("bindCssVars",e=>{Ee()&&wn();const[t,n]=le();function o(r,i){function s(){Xe(r,i()||null)}s(),t(i.sub(s),et.bind(null,r))}return e||(e=r=>`--tg-${Qt(r)}`),o(e("bgColor"),Sn),o(e("bottomBarColor"),wt),o(e("headerColor"),En),t(()=>{Ee.set(!1)}),Ee.set(!0),n}),Ei=yi("close",e=>{d("web_app_close",{return_back:e})}),vi=ja("mount",()=>{if(!ae()){const e=x()&&P(Ie);yn(),Rn.ifAvailable(e?e.backgroundColor:"bg_color"),Bn.ifAvailable(e?e.bottomBarColor:"bottom_bar_bg_color"),Pn.ifAvailable(e?e.headerColor:"bg_color"),ae.set(!0)}}),Ci=yi("ready",()=>{d("web_app_ready")});function An(){B(Ie,vn())}const Rn=yt("setBackgroundColor",e=>{e!==re()&&(d(Lt,{color:e}),re.set(e),An())},Lt),Bn=yt("setBottomBarColor",e=>{e!==ie()&&(d(jt,{color:e}),ie.set(e),An())},jt),Pn=yt("setHeaderColor",e=>{e!==se()&&(d(Le,Z(e)?{color:e}:{color_key:e}),se.set(e),An())},Le,{rgb:[Le,"color",Z]});function Ai(){ae.set(!1)}const $a=Object.freeze(Object.defineProperty({__proto__:null,backgroundColor:re,backgroundColorRGB:Sn,bindCssVars:Si,bottomBarColor:ie,bottomBarColorRGB:wt,close:Ei,headerColor:se,headerColorRGB:En,isCssVarsBound:Ee,isDark:gi,isMounted:ae,isSupported:wi,mount:vi,ready:Ci,setBackgroundColor:Rn,setBottomBarColor:Bn,setHeaderColor:Pn,state:vn,unmount:Ai},Symbol.toStringTag,{value:"Module"}));function Ua(e){const t=e.message.trim(),n=(e.title||"").trim(),o=e.buttons||[];if(n.length>64)throw new l(Q,`Invalid title: ${n}`);if(!t||t.length>256)throw new l(Q,`Invalid message: ${t}`);if(o.length>3)throw new l(Q,`Invalid buttons count: ${o.length}`);return{title:n,message:t,buttons:o.length?o.map((r,i)=>{const s=r.id||"";if(s.length>64)throw new l(Q,`Button with index ${i} has invalid id: ${s}`);if(!r.type||r.type==="default"||r.type==="destructive"){const a=r.text.trim();if(!a||a.length>64)throw new l(Q,`Button with index ${i} has invalid text: ${a}`);return{type:r.type,text:a,id:s}}return{type:r.type,id:s}}):[{type:"close",id:""}]}}const Tn="web_app_open_popup",qa=T("popup",Tn),ve=u(!1),Ri=V(Tn),Bi=qa("open",async e=>{if(ve())throw new l(rt,"A popup is already opened");ve.set(!0);try{const{button_id:t=null}=await M(Tn,"popup_closed",{...e,params:Ua(e)});return t}finally{ve.set(!1)}}),Ha=Object.freeze(Object.defineProperty({__proto__:null,isOpened:ve,isSupported:Ri,open:Bi},Symbol.toStringTag,{value:"Module"})),Wa="web_app_close_scan_qr_popup",kn="web_app_open_scan_qr_popup",za="scan_qr_popup_closed",Ga="qr_text_received",Pi=T("qrScanner",kn),Ye=Pi("close",()=>{J.set(!1),d(Wa)}),J=u(!1),Ti=V(kn);function Fa(e){return b.withFn(t=>{if(J())throw new l(rt,"The QR Scanner is already opened");J.set(!0),e||(e={});const{onCaptured:n,text:o,capture:r}=e,[,i]=le(J.sub(()=>{s.resolve()}),E(za,()=>{J.set(!1)}),E(Ga,a=>{n?n(a.data):(!r||r(a.data))&&(s.resolve(a.data),Ye())})),s=new he({abortSignal:t}).catch(Ye).finally(i);return(e.postEvent||d)(kn,{text:o}),s},e)}const ki=Pi("open",Fa),Ja=Object.freeze(Object.defineProperty({__proto__:null,close:Ye,isOpened:J,isSupported:Ti,open:ki},Symbol.toStringTag,{value:"Module"}));function G(e){return h(()=>St()[e])}const Ce=u({hasShineEffect:!1,isEnabled:!0,isLoaderVisible:!1,isVisible:!1,position:"left",text:"Cancel"}),St=h(()=>{const e=Ce();return{...e,backgroundColor:e.backgroundColor||wt()||"#000000",textColor:e.textColor||ht()||"#2481cc"}}),ce=u(!1),Oi=G("backgroundColor"),Di=G("hasShineEffect"),xi=G("isEnabled"),Mi=G("isLoaderVisible"),Vi=G("isVisible"),Ii=G("position"),Ni=G("text"),Li=G("textColor"),Et="web_app_setup_secondary_button",ji="secondary_button_pressed",vt="secondaryButton",On=T(vt,Et),Ya=fe(vt,ce,Et),$i=V(Et),Ui=On("mount",()=>{if(!ce()){const e=x()&&P(vt);e&&Ce.set(e),ce.set(!0)}}),qi=On("onClick",e=>E(ji,e)),Hi=On("offClick",e=>{z(ji,e)}),Wi=Ya("setParams",e=>{Ce.set({...Ce(),...Object.fromEntries(Object.entries(e).filter(([,n])=>n!==void 0))}),B(vt,Ce());const t=St();t.text&&d(Et,{color:t.backgroundColor,has_shine_effect:t.hasShineEffect,is_active:t.isEnabled,is_progress_visible:t.isLoaderVisible,is_visible:t.isVisible,position:t.position,text:t.text,text_color:t.textColor})});function zi(){ce.set(!1)}const Qa=Object.freeze(Object.defineProperty({__proto__:null,backgroundColor:Oi,hasShineEffect:Di,isEnabled:xi,isLoaderVisible:Mi,isMounted:ce,isSupported:$i,isVisible:Vi,mount:Ui,offClick:Hi,onClick:qi,position:Ii,setParams:Wi,state:St,text:Ni,textColor:Li,unmount:zi},Symbol.toStringTag,{value:"Module"})),Ct="web_app_setup_settings_button",Gi="settings_button_pressed",At="settingsButton",Qe=u(!1),ue=u(!1),Fi=V(Ct),Dn=T(At,Ct),Ji=fe(At,ue,Ct),Yi=Ji("hide",()=>{xn(!1)}),Qi=Dn("mount",()=>{ue()||(xn(x()&&P(At)||!1),ue.set(!0))});function xn(e){e!==Qe()&&(d(Ct,{is_visible:e}),B(At,e),Qe.set(e))}const Ki=Dn("onClick",e=>E(Gi,e)),Zi=Dn("offClick",e=>{z(Gi,e)}),Xi=Ji("show",()=>{xn(!0)});function es(){ue.set(!1)}const Ka=Object.freeze(Object.defineProperty({__proto__:null,hide:Yi,isMounted:ue,isSupported:Fi,isVisible:Qe,mount:Qi,offClick:Zi,onClick:Ki,show:Xi,unmount:es},Symbol.toStringTag,{value:"Module"})),Rt="web_app_setup_swipe_behavior",Bt="swipeBehavior",pe=u(!1),ts=V(Rt),Ke=u(!0),Za=T(Bt,Rt),ns=fe(Bt,pe,Rt),os=ns("disableVertical",()=>{Mn(!1)}),rs=ns("enableVertical",()=>{Mn(!0)}),is=Za("mount",()=>{pe()||(Mn(x()&&P(Bt)||!1,!0),pe.set(!0))});function Mn(e,t){(e!==Ke()||t)&&(d(Rt,{allow_vertical_swipe:e}),B(Bt,e),Ke.set(e))}function ss(){pe.set(!1)}const Xa=Object.freeze(Object.defineProperty({__proto__:null,disableVertical:os,enableVertical:rs,isMounted:pe,isSupported:ts,isVerticalEnabled:Ke,mount:is,unmount:ss},Symbol.toStringTag,{value:"Module"})),ec=Object.freeze(Object.defineProperty({__proto__:null,accentTextColor:qr,backgroundColor:ft,bindCssVars:fi,bottomBarBgColor:bn,buttonColor:ht,buttonTextColor:mn,destructiveTextColor:Hr,headerBackgroundColor:Wr,hintColor:zr,isCssVarsBound:ye,isDark:Gr,isMounted:ne,linkColor:Fr,mount:yn,secondaryBackgroundColor:Te,sectionBackgroundColor:Jr,sectionHeaderTextColor:Yr,sectionSeparatorColor:Qr,state:$,subtitleTextColor:Kr,textColor:Zr,unmount:mi},Symbol.toStringTag,{value:"Module"})),R=u({height:0,width:0,isExpanded:!1,stableHeight:0}),Ne=u(!1),Ae=u(!1),Vn=u(!1),In=u(void 0);function Pt(e){return h(()=>R()[e])}const as=Pt("height"),cs=Pt("isExpanded"),us=h(()=>{const e=R();return e.height===e.stableHeight}),ps=Pt("stableHeight"),ls=Pt("width");function ds(e){return M("web_app_request_viewport","viewport_changed",e).then(t=>({height:t.height,width:t.width,isExpanded:t.is_expanded,isStable:t.is_state_stable}))}const Ze="viewport",_s=q(Ze),tc=pt(Ze,Ne),fs=tc("bindCssVars",e=>{Ae()&&wn(),e||(e=o=>`--tg-viewport-${Qt(o)}`);const t=["height","width","stableHeight"];function n(){t.forEach(o=>{Xe(e(o),`${R()[o]}px`)})}return n(),R.sub(n),Ae.set(!0),()=>{t.forEach(et),R.unsub(n),Ae.set(!1)}}),hs=_s("expand",()=>{d("web_app_expand")}),ms=_s("mount",or(Ze,e=>{const t=x()&&P(Ze);if(t)return t;if(["macos","tdesktop","unigram","webk","weba","web"].includes(W().platform)){const n=window;return{isExpanded:!0,height:n.innerHeight,width:n.innerWidth,stableHeight:n.innerHeight}}return e.timeout||(e.timeout=1e3),ds(e).then(n=>({height:n.height,isExpanded:n.isExpanded,stableHeight:n.isStable?n.height:R().stableHeight,width:n.width}))},e=>{E("viewport_changed",bs),gs(e)},{isMounted:Ne,isMounting:Vn,mountError:In})),bs=e=>{gs({height:e.height,isExpanded:e.is_expanded,stableHeight:e.is_state_stable?e.height:R().stableHeight,width:e.width})};function gs(e){R.set({isExpanded:e.isExpanded,height:xt(e.height),width:xt(e.width),stableHeight:xt(e.stableHeight)}),B("viewport",R())}function xt(e){return Math.max(e,0)}function ws(){z("viewport_changed",bs),Ne.set(!1)}const nc=Object.freeze(Object.defineProperty({__proto__:null,bindCssVars:fs,expand:hs,height:as,isCssVarsBound:Ae,isExpanded:cs,isMounted:Ne,isMounting:Vn,isStable:us,mount:ms,mountError:In,stableHeight:ps,state:R,unmount:ws,width:ls},Symbol.toStringTag,{value:"Module"})),oc=q(),rc=oc("openLink",(e,t)=>{if(typeof e=="string")try{e=new URL(e)}catch(n){throw new l(ot,`"${e.toString()}" is invalid URL`,n)}t||(t={}),d("web_app_open_link",{url:e.toString(),try_browser:t.tryBrowser,try_instant_view:t.tryInstantView})}),Wn="web_app_open_tg_link",ic=q(),ys=ic("openTelegramLink",e=>{const t=e.toString();if(!t.match(/^https:\/\/t.me\/.+/))throw new l(ot,`"${t}" is invalid URL`);if(!H(Wn,k())){window.location.href=t;return}e=new URL(e),d(Wn,{path_full:e.pathname+e.search})}),sc=q(),ac=sc("shareURL",(e,t)=>{ys("https://t.me/share/url?"+new URLSearchParams({url:e,text:t||""}).toString().replace(/\+/g,"%20"))}),$t="web_app_request_phone",je=u(!1),Ss=I("requestPhoneAccess",e=>{if(je())throw new l(De,"Phone access request is currently in progress");return je.set(!0),M($t,"phone_requested",e).then(t=>t.status).finally(()=>{je.set(!1)})},{isSupported:$t});function zn(e){return e||(e={}),_e("getRequestedContact",{},{...e,timeout:e.timeout||5e3}).then(oo({contact:Ue({userId:["user_id",qe()],phoneNumber:["phone_number",j()],firstName:["first_name",j()],lastName:["last_name",j(!0)]})(),authDate:["auth_date",Ht()],hash:j()})())}const cc=I("requestContact",e=>b.withFn(async t=>{const n={abortSignal:t};try{return await zn(n)}catch{}if(await Ss(n)!=="sent")throw new l(qo,"User denied access");let o=50;for(;!t.aborted;){try{return await zn(n)}catch{}await Ks(o),o+=50}return null},e),{isSupported:$t}),Gn="web_app_request_write_access",$e=u(!1),uc=I("requestWriteAccess",e=>{if($e())throw new l(De,"Write access request is currently in progress");return $e.set(!0),M(Gn,"write_access_requested",e).then(t=>t.status).finally(()=>{$e.set(!1)})},{isSupported:Gn}),pc=I("getCurrentTime",e=>_e("getCurrentTime",{},e).then(Ht()),{isSupported:"web_app_invoke_custom_method"}),Fn="web_app_read_text_from_clipboard",lc=I("readTextFromClipboard",e=>{const t=jo();return M(Fn,"clipboard_text_received",{...e,params:{req_id:t},capture:Mo(t)}).then(({data:n=null})=>n)},{isSupported:Fn}),dc=I("sendData",e=>{const{size:t}=new Blob([e]);if(!t||t>4096)throw new l(Uo,t?"Maximum size of data to send is 4096 bytes":"Attempted to send empty data");d("web_app_data_send",{data:e})}),Jn="web_app_share_to_story",_c=I("shareStory",(e,t)=>{t||(t={}),d(Jn,{text:t.text,media_url:e,widget_link:t.widgetLink})},{isSupported:Jn}),Yn="web_app_switch_inline_query",fc=I("switchInlineQuery",(e,t)=>{d(Yn,{query:e,chat_types:t||[]})},{isSupported:[Yn,{fn:()=>!!W().botInline,error:"Mini App should be ran in Bot inline mode"}]});function hc(e){try{return{result:e()}}catch(t){return{error:t}}}function mc(e){ma(e),Do();const[t,n]=le(E("reload_iframe",()=>{d("iframe_will_reload"),window.location.reload()}),xo),{acceptCustomStyles:o=!0}=e||{};if(o){const r=document.createElement("style");r.id="telegram-custom-styles",document.head.appendChild(r),t(E("set_custom_style",i=>{r.innerHTML=i}),()=>{document.head.removeChild(r)})}return d("iframe_ready",{reload_supported:!0}),n}function bc(){return Qn.useMemo(W,[])}function gc(e){return Qn.useSyncExternalStore(t=>e.sub(t),e)}exports.$createRequestId=Lo;exports.$debug=So;exports.$postEvent=en;exports.$targetOrigin=Po;exports.$version=k;exports.CancelablePromise=b;exports.ERR_ABORTED=Ft;exports.ERR_ACCESS_DENIED=qo;exports.ERR_ALREADY_MOUNTING=Ho;exports.ERR_ALREADY_OPENED=rt;exports.ERR_ALREADY_REQUESTING=De;exports.ERR_CANCELED=Jt;exports.ERR_CSS_VARS_ALREADY_BOUND=Wo;exports.ERR_CUSTOM_METHOD_ERR_RESPONSE=Bo;exports.ERR_DATA_INVALID_SIZE=Uo;exports.ERR_INVALID_SLUG=$o;exports.ERR_INVALID_URL=ot;exports.ERR_INVALID_VALUE=Xn;exports.ERR_METHOD_PARAMETER_UNSUPPORTED=Ro;exports.ERR_METHOD_UNSUPPORTED=Co;exports.ERR_NOT_AVAILABLE=zo;exports.ERR_NOT_INITIALIZED=Go;exports.ERR_NOT_MOUNTED=Fo;exports.ERR_NOT_SUPPORTED=It;exports.ERR_PARSE=Ut;exports.ERR_POPUP_INVALID_PARAMS=Q;exports.ERR_RETRIEVE_LP_FAILED=Ao;exports.ERR_TIMED_OUT=Yt;exports.ERR_UNEXPECTED_TYPE=to;exports.ERR_UNEXPECTED_VALUE=eo;exports.ERR_UNKNOWN_ENV=Zt;exports.TypedError=l;exports.addEventListener=ze;exports.authenticateBiometry=ar;exports.backButton=ba;exports.bindMiniAppCssVars=Si;exports.bindThemeParamsCssVars=fi;exports.bindViewportCssVars=fs;exports.biometry=Ca;exports.biometryMountError=rn;exports.biometryState=xe;exports.classNames=He;exports.closeMiniApp=Ei;exports.closeQrScanner=Ye;exports.closingBehavior=Ra;exports.cloudStorage=Pa;exports.compareVersions=Vo;exports.createPostEvent=Io;exports.defineEventHandlers=Do;exports.deleteCloudStorageItem=Sr;exports.deleteCssVar=et;exports.disableClosingConfirmation=hr;exports.disableVerticalSwipes=os;exports.emitMiniAppsEvent=Ge;exports.enableClosingConfirmation=mr;exports.enableVerticalSwipes=rs;exports.expandViewport=hs;exports.getCloudStorageItem=Er;exports.getCloudStorageKeys=vr;exports.getCurrentTime=pc;exports.hapticFeedback=Ta;exports.hapticFeedbackImpactOccurred=Rr;exports.hapticFeedbackNotificationOccurred=Br;exports.hapticFeedbackSelectionChanged=Pr;exports.hideBackButton=Ko;exports.hideSettingsButton=Yi;exports.init=mc;exports.initData=ka;exports.initDataAuthDate=ln;exports.initDataCanSendAfter=dn;exports.initDataCanSendAfterDate=Tr;exports.initDataChat=kr;exports.initDataChatInstance=Dr;exports.initDataChatType=Or;exports.initDataHash=xr;exports.initDataQueryId=Mr;exports.initDataRaw=_n;exports.initDataReceiver=Vr;exports.initDataStartParam=Nr;exports.initDataState=_t;exports.initDataUser=Lr;exports.invoice=xa;exports.invokeCustomMethod=No;exports.isAbortError=Ys;exports.isAuthenticatingBiometry=be;exports.isBackButtonMounted=X;exports.isBackButtonSupported=Yo;exports.isBackButtonVisible=Fe;exports.isBiometryMounted=Me;exports.isBiometryMounting=on;exports.isBiometrySupported=ir;exports.isCanceledError=Qs;exports.isClosingBehaviorMounted=te;exports.isClosingConfirmationEnabled=Je;exports.isCloudStorageSupported=yr;exports.isColorDark=hn;exports.isHapticFeedbackSupported=Ar;exports.isIframe=bo;exports.isInvoiceOpened=we;exports.isInvoiceSupported=jr;exports.isMainButtonEnabled=ti;exports.isMainButtonLoaderVisible=ni;exports.isMainButtonMounted=oe;exports.isMainButtonVisible=oi;exports.isMiniAppCssVarsBound=Ee;exports.isMiniAppDark=gi;exports.isMiniAppMounted=ae;exports.isMiniAppSupported=wi;exports.isPopupOpened=ve;exports.isPopupSupported=Ri;exports.isQrScannerOpened=J;exports.isQrScannerSupported=Ti;exports.isRGB=Z;exports.isRGBShort=ro;exports.isRecord=zt;exports.isRequestingBiometryAccess=ge;exports.isRequestingPhoneAccess=je;exports.isRequestingWriteAccess=$e;exports.isSSR=Nt;exports.isSecondaryButtonEnabled=xi;exports.isSecondaryButtonLoaderVisible=Mi;exports.isSecondaryButtonMounted=ce;exports.isSecondaryButtonSupported=$i;exports.isSecondaryButtonVisible=Vi;exports.isSettingsButtonMounted=ue;exports.isSettingsButtonSupported=Fi;exports.isSettingsButtonVisible=Qe;exports.isSwipeBehaviorMounted=pe;exports.isSwipeBehaviorSupported=ts;exports.isTMA=Vt;exports.isThemeParamsCssVarsBound=ye;exports.isThemeParamsDark=Gr;exports.isThemeParamsMounted=ne;exports.isTimeoutError=Js;exports.isVerticalSwipesEnabled=Ke;exports.isViewportCssVarsBound=Ae;exports.isViewportExpanded=cs;exports.isViewportMounted=Ne;exports.isViewportMounting=Vn;exports.isViewportStable=us;exports.mainButton=Ia;exports.mainButtonBackgroundColor=Xr;exports.mainButtonHasShineEffect=ei;exports.mainButtonState=mt;exports.mainButtonText=ri;exports.mainButtonTextColor=ii;exports.mergeClassNames=Ts;exports.miniApp=$a;exports.miniAppBackgroundColor=re;exports.miniAppBottomBarColor=ie;exports.miniAppBottomBarColorRGB=wt;exports.miniAppHeaderColor=se;exports.miniAppHeaderColorRGB=En;exports.miniAppReady=Ci;exports.miniAppState=vn;exports.mockTelegramEnv=ua;exports.mountBackButton=Zo;exports.mountBiometry=pr;exports.mountClosingBehavior=br;exports.mountMainButton=ai;exports.mountMiniApp=vi;exports.mountSecondaryButton=Ui;exports.mountSettingsButton=Qi;exports.mountSwipeBehavior=is;exports.mountThemeParams=yn;exports.mountViewport=ms;exports.off=z;exports.offBackButtonClick=er;exports.offMainButtonClick=ui;exports.offSecondaryButtonClick=Hi;exports.offSettingsButtonClick=Zi;exports.on=E;exports.onBackButtonClick=Xo;exports.onMainButtonClick=ci;exports.onSecondaryButtonClick=qi;exports.onSettingsButtonClick=Ki;exports.openBiometrySettings=cr;exports.openInvoice=Ur;exports.openLink=rc;exports.openPopup=Bi;exports.openQrScanner=ki;exports.openTelegramLink=ys;exports.parseInitData=Oa;exports.parseThemeParams=di;exports.popup=Ha;exports.postEvent=tt;exports.qrScanner=Ja;exports.readTextFromClipboard=lc;exports.removeEventHandlers=xo;exports.request=nt;exports.requestBiometry=rr;exports.requestBiometryAccess=ur;exports.requestContact=cc;exports.requestPhoneAccess=Ss;exports.requestViewport=ds;exports.requestWriteAccess=uc;exports.restoreInitData=Ir;exports.retrieveLaunchParams=W;exports.safeCall=hc;exports.secondaryButton=Qa;exports.secondaryButtonBackgroundColor=Oi;exports.secondaryButtonHasShineEffect=Di;exports.secondaryButtonPosition=Ii;exports.secondaryButtonState=St;exports.secondaryButtonText=Ni;exports.secondaryButtonTextColor=Li;exports.sendData=dc;exports.serializeLaunchParams=Bs;exports.serializeThemeParams=io;exports.setCloudStorageItem=Cr;exports.setCssVar=Xe;exports.setMainButtonParams=pi;exports.setMiniAppBackgroundColor=Rn;exports.setMiniAppBottomBarColor=Bn;exports.setMiniAppHeaderColor=Pn;exports.setSecondaryButtonParams=Wi;exports.settingsButton=Ka;exports.shareStory=_c;exports.shareURL=ac;exports.showBackButton=tr;exports.showSettingsButton=Xi;exports.subscribe=pa;exports.supports=H;exports.swipeBehavior=Xa;exports.switchInlineQuery=fc;exports.themeParams=ec;exports.themeParamsAccentTextColor=qr;exports.themeParamsBackgroundColor=ft;exports.themeParamsBottomBarBgColor=bn;exports.themeParamsButtonColor=ht;exports.themeParamsButtonTextColor=mn;exports.themeParamsDestructiveTextColor=Hr;exports.themeParamsHeaderBackgroundColor=Wr;exports.themeParamsHintColor=zr;exports.themeParamsLinkColor=Fr;exports.themeParamsSecondaryBackgroundColor=Te;exports.themeParamsSectionBackgroundColor=Jr;exports.themeParamsSectionHeaderTextColor=Yr;exports.themeParamsSectionSeparatorColor=Qr;exports.themeParamsState=$;exports.themeParamsSubtitleTextColor=Kr;exports.themeParamsTextColor=Zr;exports.toRGB=Wt;exports.toRecord=qt;exports.unmountBackButton=nr;exports.unmountBiometry=dr;exports.unmountClosingBehavior=gr;exports.unmountMainButton=li;exports.unmountMiniApp=Ai;exports.unmountSecondaryButton=zi;exports.unmountSettingsButton=es;exports.unmountSwipeBehavior=ss;exports.unmountThemeParams=mi;exports.unmountViewport=ws;exports.unsubscribe=la;exports.updateBiometryToken=_r;exports.useLaunchParams=bc;exports.useSignal=gc;exports.viewport=nc;exports.viewportHeight=as;exports.viewportMountError=In;exports.viewportStableHeight=ps;exports.viewportState=R;exports.viewportWidth=ls; //# sourceMappingURL=index.cjs.map