@vbotma/bridge 2.2.7 → 2.2.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dts/env/{isVBMA.d.ts → isVBma.d.ts} +7 -7
- package/dist/dts/env/setLaunchParams.d.ts +63 -0
- package/dist/dts/index.d.ts +2 -1
- package/dist/index.cjs +3 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.iife.js +3 -3
- package/dist/index.iife.js.map +1 -1
- package/dist/index.js +263 -210
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.iife.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
this.tapps=this.tapps||{};this.tapps.bridge=(function(f){"use strict";let A;function Ve(e){return{lang:(e==null?void 0:e.lang)??(A==null?void 0:A.lang),message:e==null?void 0:e.message,abortEarly:(e==null?void 0:e.abortEarly)??(A==null?void 0:A.abortEarly),abortPipeEarly:(e==null?void 0:e.abortPipeEarly)??(A==null?void 0:A.abortPipeEarly)}}let ue;function Gt(e){return ue==null?void 0:ue.get(e)}let ce;function Ht(e){return ce==null?void 0:ce.get(e)}let le;function Kt(e,t){var n;return(n=le==null?void 0:le.get(e))==null?void 0:n.get(t)}function Qt(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 w(e,t,n,r,s){const i=s&&"input"in s?s.input:n.value,o=(s==null?void 0:s.expected)??e.expects??null,u=(s==null?void 0:s.received)??Qt(i),c={kind:e.kind,type:e.type,input:i,expected:o,received:u,message:`Invalid ${t}: ${o?`Expected ${o} 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},a=e.kind==="schema",l=(s==null?void 0:s.message)??e.message??Kt(e.reference,c.lang)??(a?Ht(c.lang):null)??r.message??Gt(c.lang);l!==void 0&&(c.message=typeof l=="function"?l(c):l),a&&(n.typed=!1),n.issues?n.issues.push(c):n.issues=[c]}function E(e){return{version:1,vendor:"valibot",validate(t){return e["~run"]({value:t},Ve())}}}function De(e,t){return Object.hasOwn(e,t)&&t!=="__proto__"&&t!=="prototype"&&t!=="constructor"}function Yt(e,t){const n=[...new Set(e)];return n.length>1?`(${n.join(` ${t} `)})`:n[0]??"never"}var Zt=class extends Error{constructor(e){super(e[0].message),this.name="ValiError",this.issues=e}};function Y(e,t){return{kind:"validation",type:"check",reference:Y,async:!1,expects:null,requirement:e,message:t,"~run"(n,r){return n.typed&&!this.requirement(n.value)&&w(this,"input",n,r),n}}}function Te(e){return{kind:"validation",type:"integer",reference:Te,async:!1,expects:null,requirement:Number.isInteger,message:e,"~run"(t,n){return t.typed&&!this.requirement(t.value)&&w(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 Xt(e,t,n){return typeof e.fallback=="function"?e.fallback(t,n):e.fallback}function fe(e,t,n){return typeof e.default=="function"?e.default(t,n):e.default}function pe(e,t){return!e["~run"]({value:t},{abortEarly:!0}).issues}function Ue(){return{kind:"schema",type:"any",reference:Ue,expects:"any",async:!1,get"~standard"(){return E(this)},"~run"(e){return e.typed=!0,e}}}function F(e){return{kind:"schema",type:"boolean",reference:F,expects:"boolean",async:!1,message:e,get"~standard"(){return E(this)},"~run"(t,n){return typeof t.value=="boolean"?t.typed=!0:w(this,"type",t,n),t}}}function Ne(e){return{kind:"schema",type:"date",reference:Ne,expects:"Date",async:!1,message:e,get"~standard"(){return E(this)},"~run"(t,n){return t.value instanceof Date?isNaN(t.value)?w(this,"type",t,n,{received:'"Invalid Date"'}):t.typed=!0:w(this,"type",t,n),t}}}function de(e){return{kind:"schema",type:"function",reference:de,expects:"Function",async:!1,message:e,get"~standard"(){return E(this)},"~run"(t,n){return typeof t.value=="function"?t.typed=!0:w(this,"type",t,n),t}}}function _e(e,t){return{kind:"schema",type:"instance",reference:_e,expects:e.name,async:!1,class:e,message:t,get"~standard"(){return E(this)},"~run"(n,r){return n.value instanceof this.class?n.typed=!0:w(this,"type",n,r),n}}}function b(e,t){return{kind:"schema",type:"loose_object",reference:b,expects:"Object",async:!1,entries:e,message:t,get"~standard"(){return E(this)},"~run"(n,r){var i;const s=n.value;if(s&&typeof s=="object"){n.typed=!0,n.value={};for(const o in this.entries){const u=this.entries[o];if(o in s||(u.type==="exact_optional"||u.type==="optional"||u.type==="nullish")&&u.default!==void 0){const c=o in s?s[o]:fe(u),a=u["~run"]({value:c},r);if(a.issues){const l={type:"object",origin:"value",input:s,key:o,value:c};for(const p of a.issues)p.path?p.path.unshift(l):p.path=[l],(i=n.issues)==null||i.push(p);if(n.issues||(n.issues=a.issues),r.abortEarly){n.typed=!1;break}}a.typed||(n.typed=!1),n.value[o]=a.value}else if(u.fallback!==void 0)n.value[o]=Xt(u);else if(u.type!=="exact_optional"&&u.type!=="optional"&&u.type!=="nullish"&&(w(this,"key",n,r,{input:void 0,expected:`"${o}"`,path:[{type:"object",origin:"key",input:s,key:o,value:s[o]}]}),r.abortEarly))break}if(!n.issues||!r.abortEarly)for(const o in s)De(s,o)&&!(o in this.entries)&&(n.value[o]=s[o])}else w(this,"type",n,r);return n}}}function q(e,t){return{kind:"schema",type:"nullish",reference:q,expects:`(${e.expects} | null | undefined)`,async:!1,wrapped:e,default:t,get"~standard"(){return E(this)},"~run"(n,r){return(n.value===null||n.value===void 0)&&(this.default!==void 0&&(n.value=fe(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 E(this)},"~run"(t,n){return typeof t.value=="number"&&!isNaN(t.value)?t.typed=!0:w(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 E(this)},"~run"(n,r){return n.value===void 0&&(this.default!==void 0&&(n.value=fe(this,n,r)),n.value===void 0)?(n.typed=!0,n):this.wrapped["~run"](n,r)}}}function xe(e,t,n){return{kind:"schema",type:"record",reference:xe,expects:"Object",async:!1,key:e,value:t,message:n,get"~standard"(){return E(this)},"~run"(r,s){var o,u;const i=r.value;if(i&&typeof i=="object"){r.typed=!0,r.value={};for(const c in i)if(De(i,c)){const a=i[c],l=this.key["~run"]({value:c},s);if(l.issues){const h={type:"object",origin:"key",input:i,key:c,value:a};for(const v of l.issues)v.path=[h],(o=r.issues)==null||o.push(v);if(r.issues||(r.issues=l.issues),s.abortEarly){r.typed=!1;break}}const p=this.value["~run"]({value:a},s);if(p.issues){const h={type:"object",origin:"value",input:i,key:c,value:a};for(const v of p.issues)v.path?v.path.unshift(h):v.path=[h],(u=r.issues)==null||u.push(v);if(r.issues||(r.issues=p.issues),s.abortEarly){r.typed=!1;break}}(!l.typed||!p.typed)&&(r.typed=!1),l.typed&&(r.value[l.value]=p.value)}}else w(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 E(this)},"~run"(t,n){return typeof t.value=="string"?t.typed=!0:w(this,"type",t,n),t}}}function Je(e){let t;if(e)for(const n of e)t?t.push(...n.issues):t=n.issues;return t}function Z(e,t){return{kind:"schema",type:"union",reference:Z,expects:Yt(e.map(n=>n.expects),"|"),async:!1,options:e,message:t,get"~standard"(){return E(this)},"~run"(n,r){let s,i,o;for(const u of this.options){const c=u["~run"]({value:n.value},r);if(c.typed)if(c.issues)i?i.push(c):i=[c];else{s=c;break}else o?o.push(c):o=[c]}if(s)return s;if(i){if(i.length===1)return i[0];w(this,"type",n,r,{issues:Je(i)}),n.typed=!0}else{if((o==null?void 0:o.length)===1)return o[0];w(this,"type",n,r,{issues:Je(o)})}return n}}}function he(){return{kind:"schema",type:"unknown",reference:he,expects:"unknown",async:!1,get"~standard"(){return E(this)},"~run"(e){return e.typed=!0,e}}}function x(e,t,n){const r=e["~run"]({value:t},Ve(n));if(r.issues)throw new Zt(r.issues);return r.value}function O(...e){return{...e[0],pipe:e,get"~standard"(){return E(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 ve(e){return pe(b({VBotWebviewProxy:b({postEvent:de()})}),e)}function me(){try{return window.self!==window.top}catch{return!0}}var en=Object.defineProperty,tn=(e,t,n)=>t in e?en(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,ze=(e,t,n)=>tn(e,typeof t!="symbol"?t+"":t,n),nn=Object.defineProperty,rn=(e,t,n)=>t in e?nn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,ye=(e,t,n)=>rn(e,typeof t!="symbol"?t+"":t,n);function Ge(e){return t=>t instanceof e}function He(e,t){const n=class extends Error{constructor(...s){const i=typeof t=="function"?t(...s):typeof t=="string"?[t]:t||[];super(...i),this.name=e}};ye(n,"is",Ge(n));let r=n;return Object.defineProperty(r,"name",{value:e}),r}function sn(e,t,n){const r=class extends He(e,n){constructor(...i){super(...i),ye(this,"data"),this.data=t(...i)}};ye(r,"is",Ge(r));let s=r;return Object.defineProperty(s,"name",{value:e}),s}let Ke=class extends He("CancelledError","Promise was canceled"){},be=class extends sn("TimeoutError",t=>({timeout:t}),(t,n)=>[`Timeout reached: ${t}ms`,{cause:n}]){};const on=Symbol("resolved");function an(e){return{tag:on,value:e}}function Qe(e,t){return e.reject=t.reject,e.resolve=t.resolve,e}class L extends Promise{constructor(t,n){let r,s,i,o;typeof t=="function"?(i=t,o=n||{}):o=t||{};let u,c;const a=()=>!!c,l=()=>!!u;let p={};const h=[],v=()=>{h.forEach(qe=>qe()),h.splice(0,h.length),p={}},S=new AbortController,I=()=>l()||a();super((qe,Lr)=>{const{abortOnResolve:Wr=!0,abortOnReject:qr=!0}=o;s=m=>{var C,k;I()||(qe(m),u=[m],(C=p.resolved)==null||C.forEach(P=>P(m)),(k=p.finalized)==null||k.forEach(P=>P({kind:"resolved",result:m})),v(),Wr&&S.abort(an(m)))},r=m=>{var C,k;I()||(Lr(m),c=[m],(C=p.rejected)==null||C.forEach(P=>P(m)),(k=p.finalized)==null||k.forEach(P=>P({kind:"rejected",reason:m})),v(),qr&&S.abort(m))};const{abortSignal:N}=o;if(N){if(N.aborted)return r(N.reason);const m=()=>{r(N.reason)};N.addEventListener("abort",m,!0),h.push(()=>{N.removeEventListener("abort",m,!0)})}const{timeout:Be}=o;if(Be){const m=setTimeout(()=>{r(new be(Be))},Be);h.push(()=>{clearTimeout(m)})}try{const m=()=>{},C=i&&i(s,r,{abortSignal:S.signal,get isRejected(){return a()},get isResolved(){return l()},on(k,P){if(u||c){if(k==="finalized"){const ae=u?{kind:"resolved",result:u[0]}:{kind:"rejected",reason:c[0]};P(ae)}else k==="resolved"&&u?P(u[0]):k==="rejected"&&c&&P(c[0]);return m}return p[k]||(p[k]=[]),p[k].push(P),()=>{const ae=p[k]||[],zt=ae.indexOf(P);zt>=0&&ae.splice(zt,1)}},get result(){return u==null?void 0:u[0]},get rejectReason(){return c==null?void 0:c[0]},throwIfRejected(){if(c)throw c[0]}});C instanceof Promise&&C.catch(r)}catch(m){r(m)}}),ze(this,"reject"),ze(this,"resolve"),this.reject=r,this.resolve=s}static fn(t,n){return new L(async(r,s,i)=>{try{r(await t(i))}catch(o){s(o)}},n)}static resolve(t){return this.fn(()=>t)}static reject(t){return new L((n,r)=>{r(t)})}cancel(){this.reject(new Ke)}catch(t){return this.then(void 0,t)}finally(t){return Qe(super.finally(t),this)}then(t,n){return Qe(super.then(t,n),this)}}var un=function(e,t,n){if(n||arguments.length===2)for(var r=0,s=t.length,i;r<s;r++)(i||!(r in t))&&(i||(i=Array.prototype.slice.call(t,0,r)),i[r]=t[r]);return e.concat(i||Array.prototype.slice.call(t))};function cn(e){return e}function Ye(e,t,n,r,s,i,o,u,c){switch(arguments.length){case 1:return e;case 2:return function(){return t(e.apply(this,arguments))};case 3:return function(){return n(t(e.apply(this,arguments)))};case 4:return function(){return r(n(t(e.apply(this,arguments))))};case 5:return function(){return s(r(n(t(e.apply(this,arguments)))))};case 6:return function(){return i(s(r(n(t(e.apply(this,arguments))))))};case 7:return function(){return o(i(s(r(n(t(e.apply(this,arguments)))))))};case 8:return function(){return u(o(i(s(r(n(t(e.apply(this,arguments))))))))};case 9:return function(){return c(u(o(i(s(r(n(t(e.apply(this,arguments)))))))))}}}function y(e,t,n,r,s,i,o,u,c){switch(arguments.length){case 1:return e;case 2:return t(e);case 3:return n(t(e));case 4:return r(n(t(e)));case 5:return s(r(n(t(e))));case 6:return i(s(r(n(t(e)))));case 7:return o(i(s(r(n(t(e))))));case 8:return u(o(i(s(r(n(t(e)))))));case 9:return c(u(o(i(s(r(n(t(e))))))));default:{for(var a=arguments[0],l=1;l<arguments.length;l++)a=arguments[l](a);return a}}}var X=function(e,t){var n=typeof e=="number"?function(r){return r.length>=e}:e;return function(){var r=Array.from(arguments);return n(arguments)?t.apply(this,r):function(s){return t.apply(void 0,un([s],r,!1))}}},ln={_tag:"None"},fn=function(e){return{_tag:"Some",value:e}},pn=function(e){return e._tag==="Left"},Ze=function(e){return{_tag:"Left",left:e}},Xe=function(e){return{_tag:"Right",right:e}},dn=ln,_n=fn,hn=function(e){return e._tag==="None"},vn=function(e,t){return function(n){return hn(n)?e():t(n.value)}},mn=vn,j=Ze,g=Xe,et=X(2,function(e,t){return V(e)?e:t(e.right)}),yn=function(e){return function(t){return V(t)?t:g(e(t.right))}},bn=function(e,t){return function(n){return V(n)?j(e(n.left)):g(t(n.right))}},gn=function(e){return function(t){return V(t)?j(e(t.left)):t}},V=pn,tt=function(e,t){return function(n){return V(n)?e(n.left):t(n.right)}},wn=tt,J=tt,En=J,ee=function(e,t){try{return g(e())}catch(n){return j(t(n))}},kn=et,Pn=et;function Sn(e){return Ye(g,e.of)}function jn(e){return Ye(j,e.of)}function An(e){return function(t,n){return e.chain(t,function(r){return V(r)?e.of(r):n(r.right)})}}function On(e){return function(t,n,r){return e.map(t,bn(n,r))}}function Mn(e){return function(t,n){return function(r){return e.map(r,J(t,n))}}}var Rn=function(e){return ee(function(){return JSON.parse(e)},cn)},nt=function(e,t){return y(e,Cn(t))},In=function(e,t){return y(e,$n(t))},Cn=function(e){return function(t){return function(){return Promise.resolve().then(t).then(e)}}},$n=function(e){return function(t){return function(){return Promise.all([Promise.resolve().then(t),Promise.resolve().then(e)]).then(function(n){var r=n[0],s=n[1];return r(s)})}}},ge=function(e){return function(){return Promise.resolve(e)}},Fn=X(2,function(e,t){return function(){return Promise.resolve().then(e).then(function(n){return t(n)()})}}),rt="Task",st={URI:rt,map:nt},it={of:ge},Ln={URI:rt,map:nt,of:ge,ap:In,chain:Fn},Wn=function(e,t,n,r){function s(i){return i instanceof n?i:new n(function(o){o(i)})}return new(n||(n=Promise))(function(i,o){function u(l){try{a(r.next(l))}catch(p){o(p)}}function c(l){try{a(r.throw(l))}catch(p){o(p)}}function a(l){l.done?i(l.value):s(l.value).then(u,c)}a((r=r.apply(e,t||[])).next())})},qn=function(e,t){var n={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},r,s,i,o;return o={next:u(0),throw:u(1),return:u(2)},typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function u(a){return function(l){return c([a,l])}}function c(a){if(r)throw new TypeError("Generator is already executing.");for(;o&&(o=0,a[0]&&(n=0)),n;)try{if(r=1,s&&(i=a[0]&2?s.return:a[0]?s.throw||((i=s.return)&&i.call(s),0):s.next)&&!(i=i.call(s,a[1])).done)return i;switch(s=0,i&&(a=[a[0]&2,i.value]),a[0]){case 0:case 1:i=a;break;case 4:return n.label++,{value:a[1],done:!1};case 5:n.label++,s=a[1],a=[0];continue;case 7:a=n.ops.pop(),n.trys.pop();continue;default:if(i=n.trys,!(i=i.length>0&&i[i.length-1])&&(a[0]===6||a[0]===2)){n=0;continue}if(a[0]===3&&(!i||a[1]>i[0]&&a[1]<i[3])){n.label=a[1];break}if(a[0]===6&&n.label<i[1]){n.label=i[1],i=a;break}if(i&&n.label<i[2]){n.label=i[2],n.ops.push(a);break}i[2]&&n.ops.pop(),n.trys.pop();continue}a=t.call(e,n)}catch(l){a=[6,l],s=0}finally{r=i=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}},ot=jn(it),we=Sn(it),Bn=ge,te=Mn(st),Vn=te,Dn=function(e,t){return function(){return Wn(void 0,void 0,void 0,function(){var n;return qn(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,e().then(Xe)];case 1:return[2,r.sent()];case 2:return n=r.sent(),[2,Ze(t(n))];case 3:return[2]}})})}},at=X(3,On(st)),ut=X(2,An(Ln)),Tn=ut,Ee=ut;function Un(e){return e.replace(/_[a-z]/g,t=>t[1].toUpperCase())}function Nn(e){return Object.entries(e).reduce((t,[n,r])=>(t[Un(n)]=r,t),{})}function ke(e){const t=Nn(e);for(const n in t){const r=t[n];r&&typeof r=="object"&&!(r instanceof Date)&&(t[n]=Array.isArray(r)?r.map(ke):ke(r))}return t}function ct(e){return`tapps/${e}`}function lt(e,t){sessionStorage.setItem(ct(e),JSON.stringify(t))}function xn(e){const t=sessionStorage.getItem(ct(e));try{return t?JSON.parse(t):void 0}catch{}}function ft(...e){const t=e.flat(1);return[t.push.bind(t),()=>{t.forEach(n=>{n()})}]}function pt(e,t){t||(t={});const{textColor:n,bgColor:r,shouldLog:s}=t,i=s===void 0?!0:s,o=typeof i=="boolean"?()=>i:i,u=(c,a,...l)=>{if(a||o()){const p="font-weight:bold;padding:0 5px;border-radius:100px",[h,v,S]={log:["#0089c3","white","INFO"],error:["#ff0000F0","white","ERR"],warn:["#D38E15","white","WARN"]}[c];console[c](`%c${S} ${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:${h};color:${v}`,"",`${p};${n?`color:${n};`:""}${r?`background-color:${r}`:""}`,...l)}};return[["log","forceLog"],["warn","forceWarn"],["error","forceError"]].reduce((c,[a,l])=>(c[a]=u.bind(void 0,a,!1),c[l]=u.bind(void 0,a,!0),c),{})}function z(e){const t=n=>{throw n};return typeof e=="function"?L.resolve(y(e,te(t,n=>n))()):y(e,J(t,n=>n))}function G(e){return Object.assign((...t)=>z(e(...t)),e)}const Pe=Object.assign((e,t)=>y(Dn(()=>new L((n,r,s)=>e(i=>n(g(i)),i=>n(j(i)),s),t),n=>n),Ee(J(ot,we))),{fn:(e,t)=>Pe((n,r,s)=>{const i=e(s);y(typeof i=="function"?i:Bn(i),Vn(r,n))()},t)});var Jn=Object.defineProperty,zn=(e,t,n)=>t in e?Jn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Se=(e,t,n)=>zn(e,typeof t!="symbol"?t+"":t,n);function dt(e){return t=>t instanceof e}function D(e,t){const n=class extends Error{constructor(...i){const o=typeof t=="function"?t(...i):typeof t=="string"?[t]:t||[];super(...o),this.name=e}};Se(n,"is",dt(n));let r=n;return Object.defineProperty(r,"name",{value:e}),r}function Gn(e,t,n){const r=class extends D(e,n){constructor(...o){super(...o),Se(this,"data"),this.data=t(...o)}};Se(r,"is",dt(r));let s=r;return Object.defineProperty(s,"name",{value:e}),s}class _t extends D("MethodUnsupportedError",(t,n)=>[`Method "${t}" is unsupported in Mini Apps version ${n}`]){}class ht extends D("MethodParameterUnsupportedError",(t,n,r)=>[`Parameter "${n}" of "${t}" method is unsupported in Mini Apps version ${r}`]){}class vt extends Gn("LaunchParamsRetrieveError",t=>({errors:t}),t=>[["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.vbot-mini-apps.com/packages/tma-js-bridge/environment","","Collected errors:",...t.map(({source:n,error:r})=>`Source: ${n} / ${r instanceof Error?r.message:String(r)}`)].join(`
|
|
2
|
-
`)]){}class
|
|
3
|
-
`),t,o)}wr(n,
|
|
1
|
+
this.tapps=this.tapps||{};this.tapps.bridge=(function(f){"use strict";let A;function Te(e){return{lang:(e==null?void 0:e.lang)??(A==null?void 0:A.lang),message:e==null?void 0:e.message,abortEarly:(e==null?void 0:e.abortEarly)??(A==null?void 0:A.abortEarly),abortPipeEarly:(e==null?void 0:e.abortPipeEarly)??(A==null?void 0:A.abortPipeEarly)}}let ce;function Kt(e){return ce==null?void 0:ce.get(e)}let le;function Qt(e){return le==null?void 0:le.get(e)}let fe;function Yt(e,t){var n;return(n=fe==null?void 0:fe.get(e))==null?void 0:n.get(t)}function Zt(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 w(e,t,n,r,i){const s=i&&"input"in i?i.input:n.value,o=(i==null?void 0:i.expected)??e.expects??null,u=(i==null?void 0:i.received)??Zt(s),c={kind:e.kind,type:e.type,input:s,expected:o,received:u,message:`Invalid ${t}: ${o?`Expected ${o} but r`:"R"}eceived ${u}`,requirement:e.requirement,path:i==null?void 0:i.path,issues:i==null?void 0:i.issues,lang:r.lang,abortEarly:r.abortEarly,abortPipeEarly:r.abortPipeEarly},a=e.kind==="schema",l=(i==null?void 0:i.message)??e.message??Yt(e.reference,c.lang)??(a?Qt(c.lang):null)??r.message??Kt(c.lang);l!==void 0&&(c.message=typeof l=="function"?l(c):l),a&&(n.typed=!1),n.issues?n.issues.push(c):n.issues=[c]}function E(e){return{version:1,vendor:"valibot",validate(t){return e["~run"]({value:t},Te())}}}function Ne(e,t){return Object.hasOwn(e,t)&&t!=="__proto__"&&t!=="prototype"&&t!=="constructor"}function Xt(e,t){const n=[...new Set(e)];return n.length>1?`(${n.join(` ${t} `)})`:n[0]??"never"}var en=class extends Error{constructor(e){super(e[0].message),this.name="ValiError",this.issues=e}};function Y(e,t){return{kind:"validation",type:"check",reference:Y,async:!1,expects:null,requirement:e,message:t,"~run"(n,r){return n.typed&&!this.requirement(n.value)&&w(this,"input",n,r),n}}}function xe(e){return{kind:"validation",type:"integer",reference:xe,async:!1,expects:null,requirement:Number.isInteger,message:e,"~run"(t,n){return t.typed&&!this.requirement(t.value)&&w(this,"integer",t,n),t}}}function C(e){return{kind:"transformation",type:"transform",reference:C,async:!1,operation:e,"~run"(t){return t.value=this.operation(t.value),t}}}function tn(e,t,n){return typeof e.fallback=="function"?e.fallback(t,n):e.fallback}function pe(e,t,n){return typeof e.default=="function"?e.default(t,n):e.default}function de(e,t){return!e["~run"]({value:t},{abortEarly:!0}).issues}function Je(){return{kind:"schema",type:"any",reference:Je,expects:"any",async:!1,get"~standard"(){return E(this)},"~run"(e){return e.typed=!0,e}}}function $(e){return{kind:"schema",type:"boolean",reference:$,expects:"boolean",async:!1,message:e,get"~standard"(){return E(this)},"~run"(t,n){return typeof t.value=="boolean"?t.typed=!0:w(this,"type",t,n),t}}}function ze(e){return{kind:"schema",type:"date",reference:ze,expects:"Date",async:!1,message:e,get"~standard"(){return E(this)},"~run"(t,n){return t.value instanceof Date?isNaN(t.value)?w(this,"type",t,n,{received:'"Invalid Date"'}):t.typed=!0:w(this,"type",t,n),t}}}function _e(e){return{kind:"schema",type:"function",reference:_e,expects:"Function",async:!1,message:e,get"~standard"(){return E(this)},"~run"(t,n){return typeof t.value=="function"?t.typed=!0:w(this,"type",t,n),t}}}function he(e,t){return{kind:"schema",type:"instance",reference:he,expects:e.name,async:!1,class:e,message:t,get"~standard"(){return E(this)},"~run"(n,r){return n.value instanceof this.class?n.typed=!0:w(this,"type",n,r),n}}}function b(e,t){return{kind:"schema",type:"loose_object",reference:b,expects:"Object",async:!1,entries:e,message:t,get"~standard"(){return E(this)},"~run"(n,r){var s;const i=n.value;if(i&&typeof i=="object"){n.typed=!0,n.value={};for(const o in this.entries){const u=this.entries[o];if(o in i||(u.type==="exact_optional"||u.type==="optional"||u.type==="nullish")&&u.default!==void 0){const c=o in i?i[o]:pe(u),a=u["~run"]({value:c},r);if(a.issues){const l={type:"object",origin:"value",input:i,key:o,value:c};for(const p of a.issues)p.path?p.path.unshift(l):p.path=[l],(s=n.issues)==null||s.push(p);if(n.issues||(n.issues=a.issues),r.abortEarly){n.typed=!1;break}}a.typed||(n.typed=!1),n.value[o]=a.value}else if(u.fallback!==void 0)n.value[o]=tn(u);else if(u.type!=="exact_optional"&&u.type!=="optional"&&u.type!=="nullish"&&(w(this,"key",n,r,{input:void 0,expected:`"${o}"`,path:[{type:"object",origin:"key",input:i,key:o,value:i[o]}]}),r.abortEarly))break}if(!n.issues||!r.abortEarly)for(const o in i)Ne(i,o)&&!(o in this.entries)&&(n.value[o]=i[o])}else w(this,"type",n,r);return n}}}function q(e,t){return{kind:"schema",type:"nullish",reference:q,expects:`(${e.expects} | null | undefined)`,async:!1,wrapped:e,default:t,get"~standard"(){return E(this)},"~run"(n,r){return(n.value===null||n.value===void 0)&&(this.default!==void 0&&(n.value=pe(this,n,r)),n.value===null||n.value===void 0)?(n.typed=!0,n):this.wrapped["~run"](n,r)}}}function D(e){return{kind:"schema",type:"number",reference:D,expects:"number",async:!1,message:e,get"~standard"(){return E(this)},"~run"(t,n){return typeof t.value=="number"&&!isNaN(t.value)?t.typed=!0:w(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 E(this)},"~run"(n,r){return n.value===void 0&&(this.default!==void 0&&(n.value=pe(this,n,r)),n.value===void 0)?(n.typed=!0,n):this.wrapped["~run"](n,r)}}}function Ge(e,t,n){return{kind:"schema",type:"record",reference:Ge,expects:"Object",async:!1,key:e,value:t,message:n,get"~standard"(){return E(this)},"~run"(r,i){var o,u;const s=r.value;if(s&&typeof s=="object"){r.typed=!0,r.value={};for(const c in s)if(Ne(s,c)){const a=s[c],l=this.key["~run"]({value:c},i);if(l.issues){const h={type:"object",origin:"key",input:s,key:c,value:a};for(const v of l.issues)v.path=[h],(o=r.issues)==null||o.push(v);if(r.issues||(r.issues=l.issues),i.abortEarly){r.typed=!1;break}}const p=this.value["~run"]({value:a},i);if(p.issues){const h={type:"object",origin:"value",input:s,key:c,value:a};for(const v of p.issues)v.path?v.path.unshift(h):v.path=[h],(u=r.issues)==null||u.push(v);if(r.issues||(r.issues=p.issues),i.abortEarly){r.typed=!1;break}}(!l.typed||!p.typed)&&(r.typed=!1),l.typed&&(r.value[l.value]=p.value)}}else w(this,"type",r,i);return r}}}function d(e){return{kind:"schema",type:"string",reference:d,expects:"string",async:!1,message:e,get"~standard"(){return E(this)},"~run"(t,n){return typeof t.value=="string"?t.typed=!0:w(this,"type",t,n),t}}}function He(e){let t;if(e)for(const n of e)t?t.push(...n.issues):t=n.issues;return t}function Z(e,t){return{kind:"schema",type:"union",reference:Z,expects:Xt(e.map(n=>n.expects),"|"),async:!1,options:e,message:t,get"~standard"(){return E(this)},"~run"(n,r){let i,s,o;for(const u of this.options){const c=u["~run"]({value:n.value},r);if(c.typed)if(c.issues)s?s.push(c):s=[c];else{i=c;break}else o?o.push(c):o=[c]}if(i)return i;if(s){if(s.length===1)return s[0];w(this,"type",n,r,{issues:He(s)}),n.typed=!0}else{if((o==null?void 0:o.length)===1)return o[0];w(this,"type",n,r,{issues:He(o)})}return n}}}function ve(){return{kind:"schema",type:"unknown",reference:ve,expects:"unknown",async:!1,get"~standard"(){return E(this)},"~run"(e){return e.typed=!0,e}}}function V(e,t,n){const r=e["~run"]({value:t},Te(n));if(r.issues)throw new en(r.issues);return r.value}function R(...e){return{...e[0],pipe:e,get"~standard"(){return E(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 me(e){return de(b({VBotWebviewProxy:b({postEvent:_e()})}),e)}function X(){try{return window.self!==window.top}catch{return!0}}var nn=Object.defineProperty,rn=(e,t,n)=>t in e?nn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Ke=(e,t,n)=>rn(e,typeof t!="symbol"?t+"":t,n),sn=Object.defineProperty,on=(e,t,n)=>t in e?sn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,ye=(e,t,n)=>on(e,typeof t!="symbol"?t+"":t,n);function Qe(e){return t=>t instanceof e}function Ye(e,t){const n=class extends Error{constructor(...i){const s=typeof t=="function"?t(...i):typeof t=="string"?[t]:t||[];super(...s),this.name=e}};ye(n,"is",Qe(n));let r=n;return Object.defineProperty(r,"name",{value:e}),r}function an(e,t,n){const r=class extends Ye(e,n){constructor(...s){super(...s),ye(this,"data"),this.data=t(...s)}};ye(r,"is",Qe(r));let i=r;return Object.defineProperty(i,"name",{value:e}),i}let Ze=class extends Ye("CancelledError","Promise was canceled"){},be=class extends an("TimeoutError",t=>({timeout:t}),(t,n)=>[`Timeout reached: ${t}ms`,{cause:n}]){};const un=Symbol("resolved");function cn(e){return{tag:un,value:e}}function Xe(e,t){return e.reject=t.reject,e.resolve=t.resolve,e}class B extends Promise{constructor(t,n){let r,i,s,o;typeof t=="function"?(s=t,o=n||{}):o=t||{};let u,c;const a=()=>!!c,l=()=>!!u;let p={};const h=[],v=()=>{h.forEach(Ve=>Ve()),h.splice(0,h.length),p={}},S=new AbortController,M=()=>l()||a();super((Ve,Br)=>{const{abortOnResolve:Fr=!0,abortOnReject:qr=!0}=o;i=m=>{var I,k;M()||(Ve(m),u=[m],(I=p.resolved)==null||I.forEach(P=>P(m)),(k=p.finalized)==null||k.forEach(P=>P({kind:"resolved",result:m})),v(),Fr&&S.abort(cn(m)))},r=m=>{var I,k;M()||(Br(m),c=[m],(I=p.rejected)==null||I.forEach(P=>P(m)),(k=p.finalized)==null||k.forEach(P=>P({kind:"rejected",reason:m})),v(),qr&&S.abort(m))};const{abortSignal:x}=o;if(x){if(x.aborted)return r(x.reason);const m=()=>{r(x.reason)};x.addEventListener("abort",m,!0),h.push(()=>{x.removeEventListener("abort",m,!0)})}const{timeout:Ue}=o;if(Ue){const m=setTimeout(()=>{r(new be(Ue))},Ue);h.push(()=>{clearTimeout(m)})}try{const m=()=>{},I=s&&s(i,r,{abortSignal:S.signal,get isRejected(){return a()},get isResolved(){return l()},on(k,P){if(u||c){if(k==="finalized"){const ue=u?{kind:"resolved",result:u[0]}:{kind:"rejected",reason:c[0]};P(ue)}else k==="resolved"&&u?P(u[0]):k==="rejected"&&c&&P(c[0]);return m}return p[k]||(p[k]=[]),p[k].push(P),()=>{const ue=p[k]||[],Ht=ue.indexOf(P);Ht>=0&&ue.splice(Ht,1)}},get result(){return u==null?void 0:u[0]},get rejectReason(){return c==null?void 0:c[0]},throwIfRejected(){if(c)throw c[0]}});I instanceof Promise&&I.catch(r)}catch(m){r(m)}}),Ke(this,"reject"),Ke(this,"resolve"),this.reject=r,this.resolve=i}static fn(t,n){return new B(async(r,i,s)=>{try{r(await t(s))}catch(o){i(o)}},n)}static resolve(t){return this.fn(()=>t)}static reject(t){return new B((n,r)=>{r(t)})}cancel(){this.reject(new Ze)}catch(t){return this.then(void 0,t)}finally(t){return Xe(super.finally(t),this)}then(t,n){return Xe(super.then(t,n),this)}}var ln=function(e,t,n){if(n||arguments.length===2)for(var r=0,i=t.length,s;r<i;r++)(s||!(r in t))&&(s||(s=Array.prototype.slice.call(t,0,r)),s[r]=t[r]);return e.concat(s||Array.prototype.slice.call(t))};function fn(e){return e}function et(e,t,n,r,i,s,o,u,c){switch(arguments.length){case 1:return e;case 2:return function(){return t(e.apply(this,arguments))};case 3:return function(){return n(t(e.apply(this,arguments)))};case 4:return function(){return r(n(t(e.apply(this,arguments))))};case 5:return function(){return i(r(n(t(e.apply(this,arguments)))))};case 6:return function(){return s(i(r(n(t(e.apply(this,arguments))))))};case 7:return function(){return o(s(i(r(n(t(e.apply(this,arguments)))))))};case 8:return function(){return u(o(s(i(r(n(t(e.apply(this,arguments))))))))};case 9:return function(){return c(u(o(s(i(r(n(t(e.apply(this,arguments)))))))))}}}function y(e,t,n,r,i,s,o,u,c){switch(arguments.length){case 1:return e;case 2:return t(e);case 3:return n(t(e));case 4:return r(n(t(e)));case 5:return i(r(n(t(e))));case 6:return s(i(r(n(t(e)))));case 7:return o(s(i(r(n(t(e))))));case 8:return u(o(s(i(r(n(t(e)))))));case 9:return c(u(o(s(i(r(n(t(e))))))));default:{for(var a=arguments[0],l=1;l<arguments.length;l++)a=arguments[l](a);return a}}}var ee=function(e,t){var n=typeof e=="number"?function(r){return r.length>=e}:e;return function(){var r=Array.from(arguments);return n(arguments)?t.apply(this,r):function(i){return t.apply(void 0,ln([i],r,!1))}}},pn={_tag:"None"},dn=function(e){return{_tag:"Some",value:e}},_n=function(e){return e._tag==="Left"},tt=function(e){return{_tag:"Left",left:e}},nt=function(e){return{_tag:"Right",right:e}},hn=pn,vn=dn,mn=function(e){return e._tag==="None"},yn=function(e,t){return function(n){return mn(n)?e():t(n.value)}},bn=yn,j=tt,g=nt,rt=ee(2,function(e,t){return U(e)?e:t(e.right)}),gn=function(e){return function(t){return U(t)?t:g(e(t.right))}},wn=function(e,t){return function(n){return U(n)?j(e(n.left)):g(t(n.right))}},En=function(e){return function(t){return U(t)?j(e(t.left)):t}},U=_n,st=function(e,t){return function(n){return U(n)?e(n.left):t(n.right)}},kn=st,J=st,Pn=J,te=function(e,t){try{return g(e())}catch(n){return j(t(n))}},Sn=rt,jn=rt;function An(e){return et(g,e.of)}function On(e){return et(j,e.of)}function Wn(e){return function(t,n){return e.chain(t,function(r){return U(r)?e.of(r):n(r.right)})}}function Ln(e){return function(t,n,r){return e.map(t,wn(n,r))}}function Rn(e){return function(t,n){return function(r){return e.map(r,J(t,n))}}}var Mn=function(e){return te(function(){return JSON.parse(e)},fn)},it=function(e,t){return y(e,Cn(t))},In=function(e,t){return y(e,$n(t))},Cn=function(e){return function(t){return function(){return Promise.resolve().then(t).then(e)}}},$n=function(e){return function(t){return function(){return Promise.all([Promise.resolve().then(t),Promise.resolve().then(e)]).then(function(n){var r=n[0],i=n[1];return r(i)})}}},ge=function(e){return function(){return Promise.resolve(e)}},Bn=ee(2,function(e,t){return function(){return Promise.resolve().then(e).then(function(n){return t(n)()})}}),ot="Task",at={URI:ot,map:it},ut={of:ge},Fn={URI:ot,map:it,of:ge,ap:In,chain:Bn},qn=function(e,t,n,r){function i(s){return s instanceof n?s:new n(function(o){o(s)})}return new(n||(n=Promise))(function(s,o){function u(l){try{a(r.next(l))}catch(p){o(p)}}function c(l){try{a(r.throw(l))}catch(p){o(p)}}function a(l){l.done?s(l.value):i(l.value).then(u,c)}a((r=r.apply(e,t||[])).next())})},Dn=function(e,t){var n={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},r,i,s,o;return o={next:u(0),throw:u(1),return:u(2)},typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function u(a){return function(l){return c([a,l])}}function c(a){if(r)throw new TypeError("Generator is already executing.");for(;o&&(o=0,a[0]&&(n=0)),n;)try{if(r=1,i&&(s=a[0]&2?i.return:a[0]?i.throw||((s=i.return)&&s.call(i),0):i.next)&&!(s=s.call(i,a[1])).done)return s;switch(i=0,s&&(a=[a[0]&2,s.value]),a[0]){case 0:case 1:s=a;break;case 4:return n.label++,{value:a[1],done:!1};case 5:n.label++,i=a[1],a=[0];continue;case 7:a=n.ops.pop(),n.trys.pop();continue;default:if(s=n.trys,!(s=s.length>0&&s[s.length-1])&&(a[0]===6||a[0]===2)){n=0;continue}if(a[0]===3&&(!s||a[1]>s[0]&&a[1]<s[3])){n.label=a[1];break}if(a[0]===6&&n.label<s[1]){n.label=s[1],s=a;break}if(s&&n.label<s[2]){n.label=s[2],n.ops.push(a);break}s[2]&&n.ops.pop(),n.trys.pop();continue}a=t.call(e,n)}catch(l){a=[6,l],i=0}finally{r=s=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}},ct=On(ut),we=An(ut),Vn=ge,ne=Rn(at),Un=ne,Tn=function(e,t){return function(){return qn(void 0,void 0,void 0,function(){var n;return Dn(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,e().then(nt)];case 1:return[2,r.sent()];case 2:return n=r.sent(),[2,tt(t(n))];case 3:return[2]}})})}},lt=ee(3,Ln(at)),ft=ee(2,Wn(Fn)),Nn=ft,Ee=ft;function xn(e){return e.replace(/_[a-z]/g,t=>t[1].toUpperCase())}function Jn(e){return Object.entries(e).reduce((t,[n,r])=>(t[xn(n)]=r,t),{})}function ke(e){const t=Jn(e);for(const n in t){const r=t[n];r&&typeof r=="object"&&!(r instanceof Date)&&(t[n]=Array.isArray(r)?r.map(ke):ke(r))}return t}function pt(e){return`tapps/${e}`}function Pe(e,t){sessionStorage.setItem(pt(e),JSON.stringify(t))}function zn(e){const t=sessionStorage.getItem(pt(e));try{return t?JSON.parse(t):void 0}catch{}}function dt(...e){const t=e.flat(1);return[t.push.bind(t),()=>{t.forEach(n=>{n()})}]}function _t(e,t){t||(t={});const{textColor:n,bgColor:r,shouldLog:i}=t,s=i===void 0?!0:i,o=typeof s=="boolean"?()=>s:s,u=(c,a,...l)=>{if(a||o()){const p="font-weight:bold;padding:0 5px;border-radius:100px",[h,v,S]={log:["#0089c3","white","INFO"],error:["#ff0000F0","white","ERR"],warn:["#D38E15","white","WARN"]}[c];console[c](`%c${S} ${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:${h};color:${v}`,"",`${p};${n?`color:${n};`:""}${r?`background-color:${r}`:""}`,...l)}};return[["log","forceLog"],["warn","forceWarn"],["error","forceError"]].reduce((c,[a,l])=>(c[a]=u.bind(void 0,a,!1),c[l]=u.bind(void 0,a,!0),c),{})}function z(e){const t=n=>{throw n};return typeof e=="function"?B.resolve(y(e,ne(t,n=>n))()):y(e,J(t,n=>n))}function G(e){return Object.assign((...t)=>z(e(...t)),e)}const Se=Object.assign((e,t)=>y(Tn(()=>new B((n,r,i)=>e(s=>n(g(s)),s=>n(j(s)),i),t),n=>n),Ee(J(ct,we))),{fn:(e,t)=>Se((n,r,i)=>{const s=e(i);y(typeof s=="function"?s:Vn(s),Un(r,n))()},t)});var Gn=Object.defineProperty,Hn=(e,t,n)=>t in e?Gn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,je=(e,t,n)=>Hn(e,typeof t!="symbol"?t+"":t,n);function ht(e){return t=>t instanceof e}function T(e,t){const n=class extends Error{constructor(...s){const o=typeof t=="function"?t(...s):typeof t=="string"?[t]:t||[];super(...o),this.name=e}};je(n,"is",ht(n));let r=n;return Object.defineProperty(r,"name",{value:e}),r}function Kn(e,t,n){const r=class extends T(e,n){constructor(...o){super(...o),je(this,"data"),this.data=t(...o)}};je(r,"is",ht(r));let i=r;return Object.defineProperty(i,"name",{value:e}),i}class vt extends T("MethodUnsupportedError",(t,n)=>[`Method "${t}" is unsupported in Mini Apps version ${n}`]){}class mt extends T("MethodParameterUnsupportedError",(t,n,r)=>[`Parameter "${n}" of "${t}" method is unsupported in Mini Apps version ${r}`]){}class yt extends Kn("LaunchParamsRetrieveError",t=>({errors:t}),t=>[["Unable to retrieve launch parameters from any known source. You should pass correct parameters to Mini App","","Collected errors:",...t.map(({source:n,error:r})=>`Source: ${n} / ${r instanceof Error?r.message:String(r)}`)].join(`
|
|
2
|
+
`)]){}class Ae extends T("InvalidLaunchParamsError",(t,n)=>[`Invalid value for launch params: ${t}`,{cause:n}]){}class Oe extends T("UnknownEnvError"){}class bt extends T("InvokeCustomMethodError",t=>[`Server returned error: ${t}`]){}function Qn(e){const t=n=>{const r={};return new URLSearchParams(n).forEach((i,s)=>{const o=r[s];Array.isArray(o)?o.push(i):o===void 0?r[s]=i:r[s]=[o,i]}),V(e,r)};return R(Z([d(),he(URLSearchParams)]),Y(n=>{try{return t(n),!0}catch{return!1}},"The value doesn't match required schema"),C(t))}function Yn(e){return R(d(),Y(t=>{try{return JSON.parse(t),!0}catch{return!1}},"Input is not a valid JSON value"),C(JSON.parse),e)}function O(e){return R(d(),Yn(e))}function gt(e){return R(Z([d(),he(URLSearchParams)]),Qn(e))}function re(e){return t=>e.test(t)}const Zn=re(/^#[\da-f]{3}$/i),Xn=re(/^#[\da-f]{4}$/i),er=re(/^#[\da-f]{6}$/i),tr=re(/^#[\da-f]{8}$/i);function nr(e){return[er,tr,Zn,Xn].some(t=>t(e))}function rr(){return b({id:D(),photo_url:_(d()),type:d(),title:d(),username:_(d())})}function wt(){return b({added_to_attachment_menu:_($()),allows_write_to_pm:_($()),first_name:d(),id:D(),is_bot:_($()),is_premium:_($()),last_name:_(d()),language_code:_(d()),photo_url:_(d()),username:_(d())})}function sr(){return b({projectCode:d(),uid:d(),sessionId:d(),rootToken:d()})}function ir(){return b({auth_date:R(d(),C(e=>new Date(Number(e)*1e3)),ze()),can_send_after:_(R(d(),C(Number),xe())),chat:_(O(rr())),chat_type:_(d()),chat_instance:_(d()),hash:_(d()),query_id:_(d()),receiver:_(O(wt())),start_param:_(d()),signature:_(d()),user:_(O(wt())),auth:_(O(sr()))})}function or(){return gt(ir())}function We(){return Ge(d(),R(Z([d(),D()]),C(e=>typeof e=="number"?`#${(e&16777215).toString(16).padStart(6,"0")}`:e),Y(nr)))}function ar(){const e=_(R(d(),C(t=>t==="1")));return b({vbWebAppBotInline:e,vbWebAppData:_(or()),vbWebAppDefaultColors:_(O(We())),vbWebAppFullscreen:e,vbWebAppPlatform:d(),vbWebAppShowSettings:e,vbWebAppStartParam:_(d()),vbWebAppThemeParams:O(We()),vbWebAppVersion:d()})}function ur(){return gt(ar())}function Le(){return b({eventType:d(),eventData:_(ve())})}function Re(e){return te(()=>V(ur(),e),t=>t)}const Et=G(Re);function kt(e,t){return t||(t=(n,r)=>JSON.stringify(r)),new URLSearchParams(Object.entries(e).reduce((n,[r,i])=>(Array.isArray(i)?n.push(...i.map(s=>[r,String(s)])):i!=null&&n.push([r,i instanceof Date?(i.getTime()/1e3|0).toString():typeof i=="string"||typeof i=="number"?String(i):typeof i=="boolean"?i?"1":"0":t(r,i)]),n),[])).toString()}function cr(e){return kt(e)}function Pt(e){return kt(e,(t,n)=>t==="vbWebAppData"?cr(n):JSON.stringify(n))}const St="launchParams";function jt(e){return e.replace(/^[^?#]*[?#]/,"").replace(/[?#]/g,"&")}function At(){return y(H(),Sn(Re))}const lr=G(At);function Ot(){return y(H(),gn(e=>{const t=new URLSearchParams(e).get("vbWebAppData");return t?vn(t):hn}))}function fr(){return y(Ot(),Pn(e=>{throw e},e=>e),bn(()=>{},e=>e))}function H(){const e=[];for(const[t,n]of[[()=>jt(window.location.href),"window.location.href"],[()=>{const r=performance.getEntriesByType("navigation")[0];return r&&jt(r.name)},"performance navigation entries"],[()=>zn(St),"local storage"]]){const r=t();if(!r){e.push({source:n,error:new Error("Source is empty")});continue}const i=y(Re(r),kn(s=>s,()=>!0));if(typeof i!="boolean"){e.push({source:n,error:i});continue}return Pe(St,r),g(r)}return j(new yt(e))}const pr=G(H);function dr(e,t){t()}function F(e,t){t||(t={});const n=t.equals||Object.is;let r=[],i=e;const s=a=>{if(!n(i,a)){const l=i;i=a,dr(c,()=>{[...r].forEach(([p,h])=>{p(a,l),h&&u(p,!0)})})}};function o(a){const l=typeof a!="object"?{once:a}:a;return{once:l.once||!1,signal:l.signal||!1}}const u=(a,l)=>{const p=o(l),h=r.findIndex(([v,S])=>v===a&&S.once===p.once&&S.signal===p.signal);h>=0&&r.splice(h,1)},c=Object.assign(function(){return _r(c),i},{destroy(){r=[]},set:s,reset(){s(e)},sub(a,l){return r.push([a,o(l)]),()=>u(a,l)},unsub:u,unsubAll(){r=r.filter(a=>a[1].signal)}});return c}const K=[];function _r(e){K.length&&K[K.length-1].add(e)}function Wt(e,t){let n=new Set,r;function i(){return r||(r=F(o(),t))}function s(){i().set(o())}function o(){n.forEach(a=>{a.unsub(s,{signal:!0})});const u=new Set;let c;K.push(u);try{c=e()}finally{K.pop()}return u.forEach(a=>{a.sub(s,{signal:!0})}),n=u,c}return Object.assign(function(){return i()()},{destroy(){i().destroy()},sub(...u){return i().sub(...u)},unsub(...u){i().unsub(...u)},unsubAll(...u){i().unsubAll(...u)}})}function hr(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(i){i(n)}),(r=e.get("*"))&&r.slice().map(function(i){i(t,n)})}}}function Lt(e,t){const n=new Map,r=hr(),i=(s,o,u=!1)=>{const c=n.get(s)||new Map;n.set(s,c);const a=c.get(o)||[];c.set(o,a);const l=a.findIndex(p=>p[1]===u);if(l>=0&&(r.off(s,a[l][0]),a.splice(l,1),!a.length&&(c.delete(o),!c.size))){const p=n.size;n.delete(s),p&&!n.size&&t()}};return{on(s,o,u){!n.size&&e();const c=()=>{i(s,o,u)},a=(...h)=>{u&&c(),s==="*"?o({name:h[0],payload:h[1]}):o(...h)};r.on(s,a);const l=n.get(s)||new Map;n.set(s,l);const p=l.get(o)||[];return l.set(o,p),p.push([a,u||!1]),c},off:i,emit:r.emit,clear(){const s=n.size;r.all.clear(),n.clear(),s&&t()}}}function se(e,t){window.dispatchEvent(new MessageEvent("message",{data:JSON.stringify({eventType:e,eventData:t}),source:window.parent}))}const ie=F(!1),Me=F("https://web.telegram.org"),vr=e=>{L().log("Event received:",e)},Ie=Wt(ie);function mr(e){e!==ie()&&(ie.set(e),(e?oe:$t)("*",vr))}const Ce=Wt(Me);function yr(e){Me.set(e),L().log("New target origin set",e)}const W=F((...e)=>{window.parent.postMessage(...e)}),L=F(_t("Bridge",{bgColor:"#9147ff",textColor:"white",shouldLog:Ie}));function br(){Bt(),[W,Me,Ce,ie,Ie,L].forEach(e=>{e.unsubAll(),"reset"in e&&e.reset()})}function $e(e,t,n){const r=[n],i=e[t];typeof i=="function"&&r.push(i);const s=(...u)=>{r.forEach(c=>c(...u))},o=Object.assign((...u)=>{s(...u)},{unwrap(){const{length:u}=r;if(u===1){delete e[t];return}if(u===2){It(e,t,r[1]);return}r.unshift(1),It(e,t,s)}});Mt(e,t,()=>o,u=>r.push(u))}function Rt(e,t){const n=e[t];Mt(e,t,()=>n,r=>{Object.entries(r).forEach(([i,s])=>{n[i]=s})})}function Mt(e,t,n,r){Object.defineProperty(e,t,{enumerable:!0,configurable:!0,get:n,set:r})}function It(e,t,n){Object.defineProperty(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n})}const gr={clipboard_text_received:b({req_id:d(),data:q(d())}),custom_method_invoked:b({req_id:d(),result:_(ve()),error:_(d())}),popup_closed:q(b({button_id:q(d(),()=>{})}),{}),viewport_changed:q(b({height:D(),width:q(D(),()=>window.innerWidth),is_state_stable:$(),is_expanded:$()}),()=>({height:window.innerHeight,is_state_stable:!0,is_expanded:!0})),theme_changed:b({theme_params:We()})};function Ct(e){if(e.source!==window.parent)return;let t;try{t=V(O(Le()),e.data)}catch{return}const{eventType:n,eventData:r}=t,i=gr[n];let s;try{s=i?V(i,r):r}catch(o){return L().forceError([`An error occurred processing the "${n}" event from the VBot application.`,"Please, file an issue here:","https://github.com/Telegram-Mini-Apps/tma.js/issues/new/choose"].join(`
|
|
3
|
+
`),t,o)}wr(n,s)}const{on:oe,off:$t,emit:wr,clear:Bt}=Lt(()=>{const e=window;!e.TelegramGameProxy&&(e.TelegramGameProxy={}),$e(e.TelegramGameProxy,"receiveEvent",se),Rt(e,"TelegramGameProxy"),!e.VBot&&(e.VBot={}),!e.VBot.WebView&&(e.VBot.WebView={}),$e(e.VBot.WebView,"receiveEvent",se),Rt(e.VBot,"WebView"),$e(e,"TelegramGameProxy_receiveEvent",se),window.addEventListener("message",Ct)},()=>{[["TelegramGameProxy_receiveEvent"],["TelegramGameProxy","receiveEvent"],["VBot","WebView","receiveEvent"]].forEach(e=>{const t=window;let n=[void 0,t];for(const s of e)if(n=[n[1],n[1][s]],!n[1])return;const[r,i]=n;"unwrap"in i&&(i.unwrap(),r&&r!==t&&!Object.keys(r).length&&delete t[e[0]])}),window.removeEventListener("message",Ct)}),Ft=(...e)=>W()(...e);function qt(e,t){y(N(e,t),En(n=>{throw n}))}function N(e,t){L().log("Posting event:",t?{eventType:e,eventData:t}:{eventType:e});const n=window,r=JSON.stringify({eventType:e,eventData:t});return X()?(Ft(r,Ce()),g(void 0)):me(n)?(n.VBotWebviewProxy.postEvent(e,JSON.stringify(t)),g(void 0)):de(b({external:b({notify:_e()})}),n)?(n.external.notify(r),g(void 0)):j(new Oe)}function ae(e,t,n={}){const{capture:r=()=>!0,postEvent:i=N}=n,s=F(),[o,u]=dt();(Array.isArray(t)?t:[t]).forEach(a=>{o(oe(a,l=>{const p=Array.isArray(t);r(p?{event:a,payload:l}:l)&&s.set([p?{event:a,payload:l}:l])}))});const c=a=>(u(),a);return y(async()=>i(e,n.params),Ee(()=>Se((a,l,p)=>{const h=s();if(h)return a(h[0]);const v=M=>{M&&a(M[0])},S=()=>{s.unsub(v)};s.sub(v),p.on("finalized",S)},n)),lt(c,c))}function Er(e,t,n){const{postEvent:r}=n||{};return z(ae(e,t,{...n,postEvent:r?(...i)=>{try{return r(...i),g(void 0)}catch(s){return j(s)}}:N}))}function kr(e,t){const n=Dt(e,t);return typeof n=="function"?B.fn(()=>z(n)):n}function Dt(e,t){const n=me(window);if(!e)return n||y(H(),J(()=>!1,()=>!0));if(n)return we(!0);const{timeout:r=100}=t||{};return y(ae("web_app_request_theme","theme_changed",{...t,timeout:r}),ne(i=>be.is(i)||Oe.is(i)?g(!1):j(i),()=>g(!0)))}function Pr({launchParams:e,onEvent:t,resetPostMessage:n}={}){if(e){const s=typeof e=="string"||e instanceof URLSearchParams?e.toString():Pt({...e,vbWebAppData:void 0})+(e.vbWebAppData?`&vbWebAppData=${encodeURIComponent(e.vbWebAppData.toString())}`:"");try{Et(s)}catch(o){throw new Ae(s,o)}Pe("launchParams",s)}if(X()){if(!t)return;n&&W.reset();const s=W();W.set((...o)=>{const[u]=o,c=()=>{s(...o)};try{const a=V(O(Le()),u);t({name:a.eventType,params:a.eventData},c)}catch{c()}});return}const r=window.VBotWebviewProxy||{},i=r.postEvent||(()=>{});window.VBotWebviewProxy={...r,postEvent(s,o){const u=()=>{i(s,o)};t?t({name:s,params:o?JSON.parse(o):void 0},u):u()}},L().log("Environment was mocked by the mockVBotEnv function")}function Sr({launchParams:e,onEvent:t,resetPostMessage:n}={}){if(e){const s=typeof e=="string"||e instanceof URLSearchParams?e.toString():Pt({...e,vbWebAppData:void 0})+(e.vbWebAppData?`&vbWebAppData=${encodeURIComponent(e.vbWebAppData.toString())}`:"");try{Et(s)}catch(o){throw new Ae(s,o)}Pe("launchParams",s)}if(X()){if(!t)return;n&&W.reset();const s=W();W.set((...o)=>{const[u]=o,c=()=>{s(...o)};try{const a=V(O(Le()),u);t({name:a.eventType,params:a.eventData},c)}catch{c()}});return}const r=window.VBotWebviewProxy||{},i=r.postEvent||(()=>{});window.VBotWebviewProxy={...r,postEvent(s,o){const u=()=>{i(s,o)};t?t({name:s,params:o?JSON.parse(o):void 0},u):u()}},L().log("Launch params are injected by the setLaunchParams function")}function jr(e,t="*"){const n=s=>{if(s.source===e.contentWindow)try{const o=JSON.parse(s.data),{eventType:u,eventData:c}=o;r.emit(u,c)}catch{}},r=Lt(()=>{window.addEventListener("message",n)},()=>{window.removeEventListener("message",n)}),i={...r,send:(s,o)=>{if(e.contentWindow){const u=JSON.stringify({eventType:s,eventData:o});e.contentWindow.postMessage(u,t)}},clear:()=>{r.clear(),Q===i&&(Q=void 0)}};return Q=i,i}let Q;function Ar(){if(!Q)throw new Error("HostBridge not initialized. Call defineHostBridge() first.");return Q}function Vt(e){return({req_id:t})=>t===e}const Ut={"6.0":["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"],6.1:["web_app_open_tg_link","web_app_open_invoice","web_app_setup_back_button","web_app_set_background_color","web_app_set_header_color","web_app_trigger_haptic_feedback"],6.2:["web_app_open_popup"],6.4:["web_app_close_scan_qr_popup","web_app_open_scan_qr_popup","web_app_read_text_from_clipboard",{method:"web_app_open_link",param:"try_instant_view"}],6.7:["web_app_switch_inline_query"],6.9:["web_app_invoke_custom_method","web_app_request_write_access","web_app_request_phone",{method:"web_app_set_header_color",param:"color"}],"6.10":["web_app_setup_settings_button"],7.2:["web_app_biometry_get_info","web_app_biometry_open_settings","web_app_biometry_request_access","web_app_biometry_request_auth","web_app_biometry_update_token"],7.6:[{method:"web_app_open_link",param:"try_browser"},{method:"web_app_close",param:"return_back"}],7.7:["web_app_setup_swipe_behavior"],7.8:["web_app_share_to_story"],"7.10":["web_app_setup_secondary_button","web_app_set_bottom_bar_color",{method:"web_app_setup_main_button",param:"has_shine_effect"}],"8.0":["web_app_request_safe_area","web_app_request_content_safe_area","web_app_request_fullscreen","web_app_exit_fullscreen","web_app_set_emoji_status","web_app_add_to_home_screen","web_app_check_home_screen","web_app_request_emoji_status_access","web_app_check_location","web_app_open_location_settings","web_app_request_file_download","web_app_request_location","web_app_send_prepared_message","web_app_start_accelerometer","web_app_start_device_orientation","web_app_start_gyroscope","web_app_stop_accelerometer","web_app_stop_device_orientation","web_app_stop_gyroscope","web_app_toggle_orientation_lock"],"9.0":["web_app_device_storage_clear","web_app_device_storage_get_key","web_app_device_storage_save_key","web_app_secure_storage_clear","web_app_secure_storage_get_key","web_app_secure_storage_restore_key","web_app_secure_storage_save_key"],9.1:["web_app_hide_keyboard"],9.2:["web_app_send_notification","web_app_finish_refresh"]};function Be(e,t){return Object.keys(Ut).find(r=>Ut[r].some(i=>t?typeof i=="object"&&i.method===e&&i.param===t:i===e))||null}function Tt(e){return e.split(".").map(Number)}function Nt(e,t){const n=Tt(e),r=Tt(t),i=Math.max(n.length,r.length);for(let s=0;s<i;s+=1){const o=n[s]||0,u=r[s]||0;if(o!==u)return o>u?1:-1}return 0}function Fe(e,t,n){const r=n?Be(e,t):Be(e);return r?Nt(r,n||t)<=0:!1}function Or(e,t="strict"){const n=typeof t=="function"?t:r=>{const{method:i,version:s}=r,o="param"in r?new mt(i,r.param,s):new vt(i,s);if(t==="strict")throw o;return L().forceWarn(o.message)};return((r,i)=>Fe(r,e)?r==="web_app_set_header_color"&&de(b({color:Je()}),i)&&!Fe(r,"color",e)?n({version:e,method:r,param:"color"}):qt(r,i):n({version:e,method:r}))}function xt(e,t,n,r){return y(ae("web_app_invoke_custom_method","custom_method_invoked",{...r||{},params:{method:e,params:t,req_id:n},capture:Vt(n)}),Nn(({result:i,error:s})=>s?ct(new bt(s)):we(i)))}function Wr(e,t,n,r){return B.fn(()=>y(xt(e,t,n,r),ne(i=>{throw i},i=>i))())}function Jt(e,t,n={}){const{capture:r=()=>!0,postEvent:i=N}=n,s=F(),[o,u]=dt();(Array.isArray(t)?t:[t]).forEach(a=>{o(oe(a,l=>{(Array.isArray(t)?r({event:a,payload:l}):r(l))&&s.set([l])}))});const c=a=>(u(),a);return y(async()=>i(e,n.params),Ee(()=>Se((a,l,p)=>{const h=s();if(h)return a(h[0]);const v=M=>{M&&a(M[0])},S=()=>{s.unsub(v)};s.sub(v),p.on("finalized",S)},n)),lt(c,c))}function Lr(e,t,n){const{postEvent:r}=n||{};return z(Jt(e,t,{...n,postEvent:r?(...i)=>{try{return r(...i),g(void 0)}catch(s){return j(s)}}:N}))}function Rr(){Object.hasOwn||(Object.hasOwn=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)})}function qe(e){return te(()=>decodeURIComponent(atob(e.replace(/-/g,"+").replace(/_/g,"/")).split("").map(t=>"%"+("00"+t.charCodeAt(0).toString(16)).slice(-2)).join("")),t=>t)}const Mr=G(qe);function De(e){return btoa(encodeURIComponent(e).replace(/%([0-9A-F]{2})/g,(t,n)=>String.fromCharCode(parseInt(`0x${n}`)))).replace(/\+/g,"-").replace(/\//g,"_")}function zt(e){const t=De(typeof e=="string"?e:JSON.stringify(e));return t.length>512?j(new Error("Value is too long for start parameter")):g(t)}const Ir=G(zt);function Cr(e,t){return z(Gt(e,typeof t=="function"?n=>te(()=>t(n),r=>r):t))}function Gt(e,t){return y(qe(e),jn(n=>t?typeof t=="function"?t(n):Mn(n):g(n)))}function $r(e){return De(e).length<=512}return f.CancelledError=Ze,f.InvalidLaunchParamsError=Ae,f.InvokeCustomMethodFailedError=bt,f.LaunchParamsRetrieveError=yt,f.MethodParameterUnsupportedError=mt,f.MethodUnsupportedError=vt,f.TimeoutError=be,f.UnknownEnvError=Oe,f.applyPolyfills=Rr,f.captureSameReq=Vt,f.compareVersions=Nt,f.createLogger=_t,f.createPostEvent=Or,f.createStartParam=Ir,f.createStartParamFp=zt,f.debug=Ie,f.decodeBase64Url=Mr,f.decodeBase64UrlFp=qe,f.decodeStartParam=Cr,f.decodeStartParamFp=Gt,f.deepSnakeToCamelObjKeys=ke,f.defineHostBridge=jr,f.emitEvent=se,f.encodeBase64Url=De,f.getHostBridge=Ar,f.getReleaseVersion=Be,f.hasWebviewProxy=me,f.invokeCustomMethod=Wr,f.invokeCustomMethodFp=xt,f.isIframe=X,f.isSafeToCreateStartParam=$r,f.isVBma=kr,f.isVBmaFp=Dt,f.logger=L,f.mockVBotEnv=Pr,f.off=$t,f.offAll=Bt,f.on=oe,f.postEvent=qt,f.postEventFp=N,f.postMessage=Ft,f.postMessageImpl=W,f.request=Lr,f.request2=Er,f.request2Fp=ae,f.requestFp=Jt,f.resetGlobals=br,f.retrieveLaunchParams=lr,f.retrieveLaunchParamsFp=At,f.retrieveRawInitData=fr,f.retrieveRawInitDataFp=Ot,f.retrieveRawLaunchParams=pr,f.retrieveRawLaunchParamsFp=H,f.setDebug=mr,f.setLaunchParams=Sr,f.setTargetOrigin=yr,f.supports=Fe,f.targetOrigin=Ce,Object.defineProperty(f,Symbol.toStringTag,{value:"Module"}),f})({});
|
|
4
4
|
//# sourceMappingURL=index.iife.js.map
|