gramstax 0.5.12 → 0.5.13

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.
@@ -1,4 +1,4 @@
1
- "use strict";var gt=Object.create;var D=Object.defineProperty;var ut=Object.getOwnPropertyDescriptor;var yt=Object.getOwnPropertyNames;var ft=Object.getPrototypeOf,Ct=Object.prototype.hasOwnProperty;var p=(g,t)=>D(g,"name",{value:t,configurable:!0});var St=(g,t)=>{for(var e in t)D(g,e,{get:t[e],enumerable:!0})},Z=(g,t,e,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of yt(t))!Ct.call(g,n)&&n!==e&&D(g,n,{get:()=>t[n],enumerable:!(s=ut(t,n))||s.enumerable});return g};var tt=(g,t,e)=>(e=g!=null?gt(ft(g)):{},Z(t||!g||!g.__esModule?D(e,"default",{value:g,enumerable:!0}):e,g)),bt=g=>Z(D({},"__esModule",{value:!0}),g);var wt={};St(wt,{BlockKeyboard:()=>J,CacheExternal:()=>O,Ctx:()=>V,Gramstax:()=>U,LabelKeyboard:()=>Q,LoggingUtil:()=>E,TemplateEngine:()=>k,TemplateManager:()=>B,WorkerThreadExport:()=>H,WorkerThreadGatewayClient:()=>K,WorkerThreadGatewayServer:()=>L,WorkerThreadInit:()=>z,WorkerThreadLaunch:()=>$,WorkerThreadPool:()=>X,WorkerThreadRpc:()=>T,log:()=>q});module.exports=bt(wt);var Pt=p(()=>typeof document>"u"?new URL(`file:${__filename}`).href:document.currentScript&&document.currentScript.tagName.toUpperCase()==="SCRIPT"?document.currentScript.src:new URL("main.js",document.baseURI).href,"getImportMetaUrl"),S=Pt();var et=require("logging-pretty");var E=class extends et.LoggingPretty{static{p(this,"LoggingUtil")}constructor(t){super(t)}errorMake(t,e,s){this.error(`[${e?`${e}:${s}`:s}] ${this._formatErrorObj(t)}`)}_formatErrorObj(t){return JSON.stringify(t instanceof Error?{message:t.message,stack:t.stack,name:t.name}:t,null,2)}},q=new E;var st=require("keyv"),nt=tt(require("@keyv/redis"),1);var O=class extends st.Keyv{constructor(e="memory",s,n,o){let a;e.startsWith("redis")&&(a=new nt.default(e)),e==="memory"&&(a=new Map),o?.forceStore&&(a=o.forceStore);super({store:a,namespace:n,ttl:s});this.url=e}static{p(this,"CacheExternal")}refreshLruCache(e){let s=this.store,n=this.opts.namespace?this.opts.namespace?.length+1:null,o=s.keys().toArray();for(let a=0;a<o.length;a++){let i=o[a];if(a==e)return;this.get(n?i.slice(n):i)}}};var it=require("timers/promises"),R=require("grammy");var V=class{static{p(this,"Ctx")}static template;static data;data=this.constructor.data;get userIsPremium(){return this.ct.from?.is_premium??!1}get userIsBot(){return this.ct.from?.is_bot??!1}get userId(){return this.ct.from?.id}get userName(){return this.ct.from?.username}get userFullName(){return`${this.ct.from?.first_name} ${this.ct.from?.last_name||""}`}get userFirstName(){return this.ct.from?.first_name}get userLastName(){return this.ct.from?.last_name}get userLanguage(){return this.ct.from?.language_code}set userLanguage(t){this.ct.from.language_code=t}get msgText(){return this.ct.message?.text}get msgTextPayloads(){return this.getPayloads(this.msgText,"space",this.data?._positionPayloadText||this.temp?.data?._positionPayloadText)}get msgTextPayload(){return this.msgTextPayloads[0]}get msgTextCommandPayloads(){return this.getPayloads(this.msgText,"space")}get msgTextCommandPayload(){return this.msgTextCommandPayloads[0]}get msgCaption(){return this.ct.message?.caption}get msgCaptionPayloads(){return this.getPayloads(this.msgCaption,"space")}get msgCaptionPayload(){return this.msgCaptionPayloads[0]}get msgCaptionCommandPayloads(){return this.getPayloads(this.msgCaption,"space")}get msgCaptionCommandPayload(){return this.msgCaptionCommandPayloads[0]}get msgPhoto(){return this.ct.message?.photo}get msgVideo(){return this.ct.message?.video}get msgAudio(){return this.ct.message?.audio}get msgDocument(){return this.ct.message?.document}get msgAnimation(){return this.ct.message?.animation}get msgVoice(){return this.ct.message?.voice}get msgVideoNote(){return this.ct.message?.video_note}get msgSticker(){return this.ct.message?.sticker}get msgLocation(){return this.ct.message?.location}get msgContact(){return this.ct.message?.contact}get msgWebAppData(){return this.ct.message?.web_app_data}get msgGift(){return this.ct.message?.gift}get callbackData(){return this.ct.callbackQuery?.data}get callbackDataPayloads(){return this.getPayloads(this.callbackData,"colon")}get callbackDataPayload(){return this.callbackDataPayloads?.[0]}set session(t){this.temp.session=t}get session(){return this.temp.session}ct;cacheSession;cacheKeyboard;templateManager;temp;constructor(t){this.ct=t.ct,this.cacheSession=t.cacheSession,this.cacheKeyboard=t.cacheKeyboard,this.templateManager=t.templateManager,this.temp=t.temp}async broadcast(t,e,s,n,o,a,i=!1){try{this.temp.isAnswer=!0;let r=30,c=e.map(h=>this.templateManager.getMessage(this.data.name,o,h,n));for(let h=0;h<t.length;h++){let d=t[h],l=c[h];await this.ct.api.sendMessage(d,l,{parse_mode:"HTML",reply_markup:s,...a}),h+1==r&&await(0,it.setTimeout)(1200)}}catch(r){if(i)throw r}}async reply(t,e,s,n){this.temp.isAnswer=!0;let o=this.templateManager.getMessage(this.data.name,s,this.userLanguage,e);return await this.ct.reply(o,{parse_mode:"HTML",reply_markup:t,...n})}async replyMedia(t,e,s,n,o){this.temp.isAnswer=!0;let a=this.templateManager.getMedia(this.data.name,n,this.userLanguage,s),i={parse_mode:"HTML",reply_markup:e,...o};if(t=="photo")return await this.ct.replyWithPhoto(a.src,{caption:a.caption,...i});if(t=="video")return await this.ct.replyWithVideo(a.src,{caption:a.caption,...i});if(t=="audio")return await this.ct.replyWithAudio(a.src,{caption:a.caption,...i});if(t=="document")return await this.ct.replyWithDocument(a.src,{caption:a.caption,...i});if(t=="animation")return await this.ct.replyWithAnimation(a.src,{caption:a.caption,...i});if(t=="voice")return await this.ct.replyWithVoice(a.src,i);if(t=="video_note")return await this.ct.replyWithVideoNote(a.src,i);if(t=="sticker")return await this.ct.replyWithSticker(a.src,i);if(t=="location")return await this.ct.replyWithLocation(parseInt(a.latitude),parseInt(a.longitude),i);if(t=="contact")return await this.ct.replyWithContact(a.phone,a.first_name,{vcard:a.vcard,...i})}async replyPhoto(t,e,s,n){return this.replyMedia("photo",t,e,s,n)}async replyVideo(t,e,s,n){return this.replyMedia("video",t,e,s,n)}async replyAudio(t,e,s,n){return this.replyMedia("audio",t,e,s,n)}async replyDocument(t,e,s,n){return this.replyMedia("document",t,e,s,n)}async replyAnimation(t,e,s,n){return this.replyMedia("animation",t,e,s,n)}async replyVoice(t,e,s,n){return this.replyMedia("voice",t,e,s,n)}async replyVideoNote(t,e,s,n){return this.replyMedia("video_note",t,e,s,n)}async replySticker(t,e,s,n){return this.replyMedia("sticker",t,e,s,n)}async replyLocation(t,e,s,n){return this.replyMedia("location",t,e,s,n)}async replyContact(t,e,s,n){return this.replyMedia("contact",t,e,s,n)}async replyAction(t){return await this.ct.replyWithChatAction(t)}async edit(t,e,s,n,o=!0){try{this.temp.isAnswer=!0;let a=this.templateManager.getMessage(this.data.name,s,this.userLanguage,e);return await this.ct.editMessageText(a,{parse_mode:"HTML",reply_markup:t,...n})}catch(a){if(o)await this.reply(t,e,s,n);else throw a}}async editMedia(t,e,s,n,o,a,i=!0){try{this.temp.isAnswer=!0;let{src:r,caption:c}=this.templateManager.getMedia(this.data.name,n,this.userLanguage,s);return t=="voice"?(await this.delete(),await this.replyVoice(e,s,n,o)):t=="video_note"?(await this.delete(),await this.replyVoice(e,s,n,o)):t=="sticker"?(await this.delete(),await this.replySticker(e,s,n,o)):t=="location"?(await this.delete(),await this.replyLocation(e,s,n,o)):t=="contact"?(await this.delete(),await this.replyContact(e,s,n,o)):await this.ct.editMessageMedia({media:r,caption:c,type:t,parse_mode:"HTML",...o},{reply_markup:e,...a})}catch(r){if(i===!0)await this.reply(e,s,n,a);else throw r}}async editPhoto(t,e,s,n,o){return await this.editMedia("photo",t,e,s,n,o)}async editVideo(t,e,s,n,o){return await this.editMedia("video",t,e,s,n,o)}async editAudio(t,e,s,n,o){return await this.editMedia("audio",t,e,s,n,o)}async editDocument(t,e,s,n,o){return await this.editMedia("document",t,e,s,n,o)}async editAnimation(t,e,s,n,o){return await this.editMedia("animation",t,e,s,n,o)}async editVoice(t,e,s,n){return await this.editMedia("voice",t,e,s,n)}async editVideoNote(t,e,s,n){return await this.editMedia("video_note",t,e,s,n)}async editSticker(t,e,s,n){return await this.editMedia("sticker",t,e,s,n)}async editLocation(t,e,s,n){return await this.editMedia("location",t,e,s,n)}async editContact(t,e,s,n){return await this.editMedia("contact",t,e,s,n)}async delete(){return await this.ct.deleteMessage()}async callbackQueryAnswer(t){try{return this.temp.isAnswer=!0,await this.ct.answerCallbackQuery(t)}catch{return null}}async sessionSet(t,e,s){try{let n={method:t,params:e,...s},o=await this.cacheSession.set(`${this.userId}`,n);return o&&(this.session=n),o}catch{return null}}async sessionGet(){try{let t=await this.cacheSession.get(`${this.userId}`);return t&&(this.session=t),t||null}catch{return null}}async sessionClear(){try{let t=await this.cacheSession.delete(`${this.userId}`);return t&&(this.session={}),t}catch{return null}}static buildData(t){let s=typeof t=="function"?{callback:t}:t||{},n=s.callback,o=this.prototype.addPayloads.bind(this.prototype),a=s.name||"";return{name:a,intentText:s.intentText||a,intentTextCommand:s.intentTextCommand||a,intentCallback:a,callback:n?function(...r){return o(this.intentCallback,"colon",n(...r))}:function(){return this?.intentCallback},_positionPayloadText:s.intentText?s.intentText.split(this.prototype.getSeperatorTag("space")).length:void 0}}keyboardCols(t,e,s,n){let[o,a]=s.split("-"),i=parseInt(o),r=a?parseInt(a):null,c=e.length,h=t;for(let d=0;d<c;d++){let l=e[d];if(n(l,d),r===null)(d+1)%i===0&&d<c-1&&h.row();else{let m=c-(d+1);(m===r||m>r&&(d+1)%i===0)&&h.row()}}return t}bottomKeyboardT(t="1",e,s){return this.bottomKeyboard((n,o)=>this.keyboardCols(n,o,t,a=>n.text(a)),{baseId:e??void 0,data:s})}inlineKeyboardT(t,e="1",s,n){return this.inlineKeyboard((o,a)=>this.keyboardCols(o,a,e,(i,r)=>{let c=t[r],h=typeof c=="string"?c:c.data.callback();o.text(i,h)}),{baseId:s??void 0,data:n})}inlineKeyboard(t,e){let s=this.data.name;if(e?.cache===!0){let i=`${s}:${this.userLanguage}:i`,r=this.cacheKeyboard.get(i);if(!r){let c=new R.InlineKeyboard,h=this.templateManager.getKeyboard(s,e?.baseId,this.userLanguage,"inline",e?.data),d=t(c,h);return this.cacheKeyboard.set(i,d),d}return r}let n=new R.InlineKeyboard,o=this.templateManager.getKeyboard(s,e?.baseId,this.userLanguage,"inline",e?.data);return t(n,o)}bottomKeyboard(t,e){let s=this.data.name;if(e?.cache===!0){let i=`${s}:${this.userLanguage}:b`,r=this.cacheKeyboard.get(i);if(!r){let c=new R.Keyboard,h=this.templateManager.getKeyboard(s,e?.baseId,this.userLanguage,"bottom",e?.data),d=t(c,h);return d.resized(!0),this.cacheKeyboard.set(i,d),d}return r}let n=new R.Keyboard,o=this.templateManager.getKeyboard(s,e?.baseId,this.userLanguage,"bottom",e?.data),a=t(n,o);return a.resized(),a}getSeperatorTag(t="space"){return t=="space"?" ":":"}havePayloads(t="",e){return t.includes(this.getSeperatorTag(e))}addPayloads(t="",e,s){let n=this.getSeperatorTag(e),o="";for(let a=0;a<s.length;a++){let i=s[a];i!=null&&i!==""&&(o+=n+i)}return t+o}getPayloads(t="",e,s=1){if(!t)return[];let n=this.getSeperatorTag(e);return t.split(n).slice(s)}getIntent(t="",e,s=1){if(!t)return"";let n=this.getSeperatorTag(e),o=t.split(n);return s==1?o[0]:o.slice(0,s).join(n)}validateSessionCallback(t,e){return(t??this.session.method)===this.methodSessionCallback(e)}validateSessionCallbackPayload(t,e){return(t??this.session.method)===this.methodSessionCallbackPayload(e)}validateSessionText(t,e){return(t??this.session.method)===this.methodSessionText(e)}validateSessionTextPayload(t,e){return(t??this.session.method)===this.methodSessionTextPayload(e)}validateSessionTextCommand(t,e){return(t??this.session.method)===this.methodSessionTextCommand(e)}validateSessionTextCommandPayload(t,e){return(t??this.session.method)===this.methodSessionTextCommandPayload(e)}validateSessionTextFree(t,e){return(t??this.session.method)===this.methodSessionTextFree(e)}validateSessionPhotoCaption(t,e){return(t??this.session.method)===this.methodSessionPhotoCaption(e)}validateSessionPhotoCaptionPayload(t,e){return(t??this.session.method)===this.methodSessionPhotoCaptionPayload(e)}validateSessionPhotoCaptionCommand(t,e){return(t??this.session.method)===this.methodSessionPhotoCaptionCommand(e)}validateSessionPhotoCaptionCommandPayload(t,e){return(t??this.session.method)===this.methodSessionPhotoCaptionCommandPayload(e)}validateSessionPhotoFree(t,e){return(t??this.session.method)===this.methodSessionPhotoFree(e)}validateSessionVideoCaption(t,e){return(t??this.session.method)===this.methodSessionVideoCaption(e)}validateSessionVideoCaptionPayload(t,e){return(t??this.session.method)===this.methodSessionVideoCaptionPayload(e)}validateSessionVideoCaptionCommand(t,e){return(t??this.session.method)===this.methodSessionVideoCaptionCommand(e)}validateSessionVideoCaptionCommandPayload(t,e){return(t??this.session.method)===this.methodSessionVideoCaptionCommandPayload(e)}validateSessionVideoFree(t,e){return(t??this.session.method)===this.methodSessionVideoFree(e)}validateSessionAudioCaption(t,e){return(t??this.session.method)===this.methodSessionAudioCaption(e)}validateSessionAudioCaptionPayload(t,e){return(t??this.session.method)===this.methodSessionAudioCaptionPayload(e)}validateSessionAudioCaptionCommand(t,e){return(t??this.session.method)===this.methodSessionAudioCaptionCommand(e)}validateSessionAudioCaptionCommandPayload(t,e){return(t??this.session.method)===this.methodSessionAudioCaptionCommandPayload(e)}validateSessionAudioFree(t,e){return(t??this.session.method)===this.methodSessionAudioFree(e)}validateSessionDocumentCaption(t,e){return(t??this.session.method)===this.methodSessionDocumentCaption(e)}validateSessionDocumentCaptionPayload(t,e){return(t??this.session.method)===this.methodSessionDocumentCaptionPayload(e)}validateSessionDocumentCaptionCommand(t,e){return(t??this.session.method)===this.methodSessionDocumentCaptionCommand(e)}validateSessionDocumentCaptionCommandPayload(t,e){return(t??this.session.method)===this.methodSessionDocumentCaptionCommandPayload(e)}validateSessionDocumentFree(t,e){return(t??this.session.method)===this.methodSessionDocumentFree(e)}validateSessionAnimationCaption(t,e){return(t??this.session.method)===this.methodSessionAnimationCaption(e)}validateSessionAnimationCaptionPayload(t,e){return(t??this.session.method)===this.methodSessionAnimationCaptionPayload(e)}validateSessionAnimationCaptionCommand(t,e){return(t??this.session.method)===this.methodSessionAnimationCaptionCommand(e)}validateSessionAnimationCaptionCommandPayload(t,e){return(t??this.session.method)===this.methodSessionAnimationCaptionCommandPayload(e)}validateSessionAnimationFree(t,e){return(t??this.session.method)===this.methodSessionAnimationFree(e)}validateSessionVoiceCaption(t,e){return(t??this.session.method)===this.methodSessionVoiceCaption(e)}validateSessionVoiceCaptionPayload(t,e){return(t??this.session.method)===this.methodSessionVoiceCaptionPayload(e)}validateSessionVoiceCaptionCommand(t,e){return(t??this.session.method)===this.methodSessionVoiceCaptionCommand(e)}validateSessionVoiceCaptionCommandPayload(t,e){return(t??this.session.method)===this.methodSessionVoiceCaptionCommandPayload(e)}validateSessionVoiceFree(t,e){return(t??this.session.method)===this.methodSessionVoiceFree(e)}validateSessionVideoNoteFree(t,e){return(t??this.session.method)===this.methodSessionVideoNoteFree(e)}validateSessionStickerFree(t,e){return(t??this.session.method)===this.methodSessionStickerFree(e)}validateSessionLocationFree(t,e){return(t??this.session.method)===this.methodSessionLocationFree(e)}validateSessionContactFree(t,e){return(t??this.session.method)===this.methodSessionContactFree(e)}sessionCallback(t,e){return this.sessionSet(this.methodSessionCallback(e),t)}sessionCallbackPayload(t,e){return this.sessionSet(this.methodSessionCallbackPayload(e),t)}sessionText(t,e){return this.sessionSet(this.methodSessionText(e),t)}sessionTextPayload(t,e){return this.sessionSet(this.methodSessionTextPayload(e),t)}sessionTextCommand(t,e){return this.sessionSet(this.methodSessionTextCommand(e),t)}sessionTextCommandPayload(t,e){return this.sessionSet(this.methodSessionTextCommandPayload(e),t)}sessionTextFree(t,e){return this.sessionSet(this.methodSessionTextFree(e),t)}sessionPhotoCaption(t,e){return this.sessionSet(this.methodSessionPhotoCaption(e),t)}sessionPhotoCaptionPayload(t,e){return this.sessionSet(this.methodSessionPhotoCaptionPayload(e),t)}sessionPhotoCaptionCommand(t,e){return this.sessionSet(this.methodSessionPhotoCaptionCommand(e),t)}sessionPhotoCaptionCommandPayload(t,e){return this.sessionSet(this.methodSessionPhotoCaptionCommandPayload(e),t)}sessionPhotoFree(t,e){return this.sessionSet(this.methodSessionPhotoFree(e),t)}sessionVideoCaption(t,e){return this.sessionSet(this.methodSessionVideoCaption(e),t)}sessionVideoCaptionPayload(t,e){return this.sessionSet(this.methodSessionVideoCaptionPayload(e),t)}sessionVideoCaptionCommand(t,e){return this.sessionSet(this.methodSessionVideoCaptionCommand(e),t)}sessionVideoCaptionCommandPayload(t,e){return this.sessionSet(this.methodSessionVideoCaptionCommandPayload(e),t)}sessionVideoFree(t,e){return this.sessionSet(this.methodSessionVideoFree(e),t)}sessionAudioCaption(t,e){return this.sessionSet(this.methodSessionAudioCaption(e),t)}sessionAudioCaptionPayload(t,e){return this.sessionSet(this.methodSessionAudioCaptionPayload(e),t)}sessionAudioCaptionCommand(t,e){return this.sessionSet(this.methodSessionAudioCaptionCommand(e),t)}sessionAudioCaptionCommandPayload(t,e){return this.sessionSet(this.methodSessionAudioCaptionCommandPayload(e),t)}sessionAudioFree(t,e){return this.sessionSet(this.methodSessionAudioFree(e),t)}sessionDocumentCaption(t,e){return this.sessionSet(this.methodSessionDocumentCaption(e),t)}sessionDocumentCaptionPayload(t,e){return this.sessionSet(this.methodSessionDocumentCaptionPayload(e),t)}sessionDocumentCaptionCommand(t,e){return this.sessionSet(this.methodSessionDocumentCaptionCommand(e),t)}sessionDocumentCaptionCommandPayload(t,e){return this.sessionSet(this.methodSessionDocumentCaptionCommandPayload(e),t)}sessionDocumentFree(t,e){return this.sessionSet(this.methodSessionDocumentFree(e),t)}sessionAnimationCaption(t,e){return this.sessionSet(this.methodSessionAnimationCaption(e),t)}sessionAnimationCaptionPayload(t,e){return this.sessionSet(this.methodSessionAnimationCaptionPayload(e),t)}sessionAnimationCaptionCommand(t,e){return this.sessionSet(this.methodSessionAnimationCaptionCommand(e),t)}sessionAnimationCaptionCommandPayload(t,e){return this.sessionSet(this.methodSessionAnimationCaptionCommandPayload(e),t)}sessionAnimationFree(t,e){return this.sessionSet(this.methodSessionAnimationFree(e),t)}sessionVoiceCaption(t,e){return this.sessionSet(this.methodSessionVoiceCaption(e),t)}sessionVoiceCaptionPayload(t,e){return this.sessionSet(this.methodSessionVoiceCaptionPayload(e),t)}sessionVoiceCaptionCommand(t,e){return this.sessionSet(this.methodSessionVoiceCaptionCommand(e),t)}sessionVoiceCaptionCommandPayload(t,e){return this.sessionSet(this.methodSessionVoiceCaptionCommandPayload(e),t)}sessionVoiceFree(t,e){return this.sessionSet(this.methodSessionVoiceFree(e),t)}sessionVideoNoteFree(t,e){return this.sessionSet(this.methodSessionVideoNoteFree(e),t)}sessionStickerFree(t,e){return this.sessionSet(this.methodSessionStickerFree(e),t)}sessionLocationFree(t,e){return this.sessionSet(this.methodSessionLocationFree(e),t)}sessionContactFree(t,e){return this.sessionSet(this.methodSessionContactFree(e),t)}sessionToCallback(t,e){return this.sessionCallback({...this.session.params,...t},e)}sessionToCallbackPayload(t,e){return this.sessionCallbackPayload({...this.session.params,...t},e)}sessionToText(t,e){return this.sessionText({...this.session.params,...t},e)}sessionToTextPayload(t,e){return this.sessionTextPayload({...this.session.params,...t},e)}sessionToTextCommand(t,e){return this.sessionTextCommand({...this.session.params,...t},e)}sessionToTextCommandPayload(t,e){return this.sessionTextCommandPayload({...this.session.params,...t},e)}sessionToTextFree(t,e){return this.sessionTextFree({...this.session.params,...t},e)}sessionToPhotoCaption(t,e){return this.sessionPhotoCaption({...this.session.params,...t},e)}sessionToPhotoCaptionPayload(t,e){return this.sessionPhotoCaptionPayload({...this.session.params,...t},e)}sessionToPhotoCaptionCommand(t,e){return this.sessionPhotoCaptionCommand({...this.session.params,...t},e)}sessionToPhotoCaptionCommandPayload(t,e){return this.sessionPhotoCaptionCommandPayload({...this.session.params,...t},e)}sessionToPhotoFree(t,e){return this.sessionPhotoFree({...this.session.params,...t},e)}sessionToVideoCaption(t,e){return this.sessionVideoCaption({...this.session.params,...t},e)}sessionToVideoCaptionPayload(t,e){return this.sessionVideoCaptionPayload({...this.session.params,...t},e)}sessionToVideoCaptionCommand(t,e){return this.sessionVideoCaptionCommand({...this.session.params,...t},e)}sessionToVideoCaptionCommandPayload(t,e){return this.sessionVideoCaptionCommandPayload({...this.session.params,...t},e)}sessionToVideoFree(t,e){return this.sessionVideoFree({...this.session.params,...t},e)}sessionToAudioCaption(t,e){return this.sessionAudioCaption({...this.session.params,...t},e)}sessionToAudioCaptionPayload(t,e){return this.sessionAudioCaptionPayload({...this.session.params,...t},e)}sessionToAudioCaptionCommand(t,e){return this.sessionAudioCaptionCommand({...this.session.params,...t},e)}sessionToAudioCaptionCommandPayload(t,e){return this.sessionAudioCaptionCommandPayload({...this.session.params,...t},e)}sessionToAudioFree(t,e){return this.sessionAudioFree({...this.session.params,...t},e)}sessionToDocumentCaption(t,e){return this.sessionDocumentCaption({...this.session.params,...t},e)}sessionToDocumentCaptionPayload(t,e){return this.sessionDocumentCaptionPayload({...this.session.params,...t},e)}sessionToDocumentCaptionCommand(t,e){return this.sessionDocumentCaptionCommand({...this.session.params,...t},e)}sessionToDocumentCaptionCommandPayload(t,e){return this.sessionDocumentCaptionCommandPayload({...this.session.params,...t},e)}sessionToDocumentFree(t,e){return this.sessionDocumentFree({...this.session.params,...t},e)}sessionToAnimationCaption(t,e){return this.sessionAnimationCaption({...this.session.params,...t},e)}sessionToAnimationCaptionPayload(t,e){return this.sessionAnimationCaptionPayload({...this.session.params,...t},e)}sessionToAnimationCaptionCommand(t,e){return this.sessionAnimationCaptionCommand({...this.session.params,...t},e)}sessionToAnimationCaptionCommandPayload(t,e){return this.sessionAnimationCaptionCommandPayload({...this.session.params,...t},e)}sessionToAnimationFree(t,e){return this.sessionAnimationFree({...this.session.params,...t},e)}sessionToVoiceCaption(t,e){return this.sessionVoiceCaption({...this.session.params,...t},e)}sessionToVoiceCaptionPayload(t,e){return this.sessionVoiceCaptionPayload({...this.session.params,...t},e)}sessionToVoiceCaptionCommand(t,e){return this.sessionVoiceCaptionCommand({...this.session.params,...t},e)}sessionToVoiceCaptionCommandPayload(t,e){return this.sessionVoiceCaptionCommandPayload({...this.session.params,...t},e)}sessionToVoiceFree(t,e){return this.sessionVoiceFree({...this.session.params,...t},e)}sessionToVideoNoteFree(t,e){return this.sessionVideoNoteFree({...this.session.params,...t},e)}sessionToStickerFree(t,e){return this.sessionStickerFree({...this.session.params,...t},e)}sessionToLocationFree(t,e){return this.sessionLocationFree({...this.session.params,...t},e)}sessionToContactFree(t,e){return this.sessionContactFree({...this.session.params,...t},e)}methodSession(t,e){return`${t}-${e||this.data.name}`}methodSessionCallback(t){return this.methodSession("1",t)}methodSessionCallbackPayload(t){return this.methodSession("2",t)}methodSessionText(t){return this.methodSession("3",t)}methodSessionTextPayload(t){return this.methodSession("4",t)}methodSessionTextCommand(t){return this.methodSession("5",t)}methodSessionTextCommandPayload(t){return this.methodSession("6",t)}methodSessionTextFree(t){return this.methodSession("7",t)}methodSessionPhotoCaption(t){return this.methodSession("8",t)}methodSessionPhotoCaptionPayload(t){return this.methodSession("9",t)}methodSessionPhotoCaptionCommand(t){return this.methodSession("10",t)}methodSessionPhotoCaptionCommandPayload(t){return this.methodSession("11",t)}methodSessionPhotoFree(t){return this.methodSession("12",t)}methodSessionVideoCaption(t){return this.methodSession("13",t)}methodSessionVideoCaptionPayload(t){return this.methodSession("14",t)}methodSessionVideoCaptionCommand(t){return this.methodSession("15",t)}methodSessionVideoCaptionCommandPayload(t){return this.methodSession("16",t)}methodSessionVideoFree(t){return this.methodSession("17",t)}methodSessionAudioCaption(t){return this.methodSession("18",t)}methodSessionAudioCaptionPayload(t){return this.methodSession("19",t)}methodSessionAudioCaptionCommand(t){return this.methodSession("20",t)}methodSessionAudioCaptionCommandPayload(t){return this.methodSession("21",t)}methodSessionAudioFree(t){return this.methodSession("22",t)}methodSessionDocumentCaption(t){return this.methodSession("23",t)}methodSessionDocumentCaptionPayload(t){return this.methodSession("24",t)}methodSessionDocumentCaptionCommand(t){return this.methodSession("25",t)}methodSessionDocumentCaptionCommandPayload(t){return this.methodSession("26",t)}methodSessionDocumentFree(t){return this.methodSession("27",t)}methodSessionAnimationCaption(t){return this.methodSession("28",t)}methodSessionAnimationCaptionPayload(t){return this.methodSession("29",t)}methodSessionAnimationCaptionCommand(t){return this.methodSession("30",t)}methodSessionAnimationCaptionCommandPayload(t){return this.methodSession("31",t)}methodSessionAnimationFree(t){return this.methodSession("32",t)}methodSessionVoiceCaption(t){return this.methodSession("33",t)}methodSessionVoiceCaptionPayload(t){return this.methodSession("34",t)}methodSessionVoiceCaptionCommand(t){return this.methodSession("35",t)}methodSessionVoiceCaptionCommandPayload(t){return this.methodSession("36",t)}methodSessionVoiceFree(t){return this.methodSession("37",t)}methodSessionVideoNoteFree(t){return this.methodSession("38",t)}methodSessionStickerFree(t){return this.methodSession("39",t)}methodSessionLocationFree(t){return this.methodSession("40",t)}methodSessionContactFree(t){return this.methodSession("41",t)}};var j=require("path"),F=require("fs"),ot=require("module");var P=class{static{p(this,"PageManager")}static _getFile(t,e,s=0){let o=Object.values(t)[s];if(o===void 0)throw new Error(`File ${e} must have export (not default) class page`);return o}static getFilePath(){return(0,j.join)(process.cwd(),"src","pages")}static getFileSync(t,e=0){t||(t=this.getFilePath());let n=(0,ot.createRequire)(t)(t);return this._getFile(n,t,e)}static async getFile(t,e=0){t||(t=this.getFilePath());let s=await import(`${t}?t=${Date.now()}`);return this._getFile(s,t,e)}static getFileManySync(t,e=0){if(t||(t=this.getFilePath()),!(0,F.existsSync)(t))throw new Error(`Directory ${t} is not found, please make it manually`);return(0,F.readdirSync)(t).map(n=>{let o=(0,j.join)(t,n);return{path:o,page:this.getFileSync(o,e)}})}static clearCacheRequire(t){if(t||(t=this.getFilePath()),!(0,F.existsSync)(t))throw new Error(`Directory ${t} is not found, please make it manually`);return(0,F.readdirSync)(t).forEach(s=>{let n=(0,j.join)(t,s);delete require.cache[require.resolve(n)]}),!0}};var rt=require("fs"),ct=require("url"),M=require("path");var b=require("path"),f=require("fs"),at=require("chokidar");var k=class{static{p(this,"TemplateEngine")}static _escape(t){return t.replace(/\\/g,"\\\\").replace(/`/g,"\\`")}static _processVariables(t){return t.replace(/\{\{(\w+)\}\}/g,(e,s)=>`\${(data && data["${s}"]) ?? ""}`)}static _processBaseBlocks(t){let e=/<base\b[^>]*?(?:\sid=(["']?)([^"'\s>]+)\1)?[^>]*?>([\s\S]*?)<\/base>/g,s={};for(let n of t.matchAll(e)){let o=n[2]??"default",i=(n[3]??"").replace(/^[\t ]+/gm,"").replace(/^\n+/,"").replace(/\n+$/,"").trim();s[o]=i}return s}static _processScriptBlocks(t){return t.replace(/<script\b[^>]*>([\s\S]*?)<\/script>/gi,(e,s)=>{let n=s.trim();return n?`\${(() => { if (!data) return ''; try { with(data) { ${n} } } catch(e) { return '' } })()}`:""})}static _processSpaceBlocks(t){return t.replace(/^[ \t]*<space\s*\/>[ \t]*$/gim,"")}static _processDivBlocks(t){return t.replace(/<div>([\s\S]*?)<\/div>/gi,(e,s)=>s.replace(/^[\t ]+/gm,"").replace(/^\n+/,"").replace(/\n+$/,""))}static _processSwitchBlocks(t){let e=/<switch\b(?:\s+value="([^"]+)")?>([\s\S]*?)<\/switch>/gi;return t.replace(e,(s,n,o)=>{if(!n)return"";let a="",i=/<case\b(?:\s+is="([^"]+)")?>([\s\S]*?)<\/case>/gi,r=/<default>([\s\S]*?)<\/default>/gi,c;for(;(c=i.exec(o))!==null;){let d=(c[1]||"").split(",").map(m=>m.trim()),l=(c[2]||"").replace(/^[\t ]+/gm,"").replace(/^\n+/,"").replace(/\n+$/,"").trim().replace(/`/g,"\\`");d.forEach(m=>{a+=`case "${m}": `}),a+=`return \`${l}\`; `}let h=r.exec(o);if(h){let d=(h[1]||"").replace(/^[\t ]+/gm,"").replace(/^\n+/,"").replace(/\n+$/,"").trim();a+=`default: return \`${d}\`; `}else a+="default: return ''; ";return`\${(() => { switch((data && data["${n}"])) { ${a} } })()}`})}static _processExec(t){return t.replace(/{~\s*([\s\S]*?)\s*~}/g,(e,s)=>`\${(() => { try { return ${s} } catch(e) { try { with(data || {}) { return ${s} } } catch(ee) { return '' } } })()}`)}static _processMapBlocks(t){let e=/<map(?:\s+([^>]*))?>([\s\S]*?)<\/map>/gi;return t.replace(e,(s,n,o)=>{let a={},i=/(\w+)="([^"]*)"/g;if(n)for(let l of n.matchAll(i))a[l[1]]=l[2];let r=a.src;if(!r)return"";let c=a.join??"\\n",h=o.replace(/^[\t ]+/gm,"").replace(/^\n+/,"").replace(/\n+$/,"").replace(/`/g,"\\`");h=h.replace(/\{\{([\w.]+)\}\}/g,(l,m)=>m==="e"||m.startsWith("e.")?`\${${m}}`:m==="i"?"${i}":l);let d=c.replace(/"/g,'\\"');return`\${(data && data["${r}"] || []).map((e, i) => \`${h}\`).join("${d}")}`})}static _processMediaBlocks(t){let e=/<media(?:\s+([^>]*))?>([\s\S]*?)<\/media>/gi,s={};for(let n of t.matchAll(e)){let o=n[1],a=n[2],i={},r=/(\w+)="([^"]*)"/g;if(o)for(let m of o.matchAll(r))i[m[1]]=m[2];let c=i.lang||"default",h=i.type,d=a.replace(/^[\t ]+/gm,"").replace(/^\n+/,"").replace(/\n+$/,"").trim(),l={type:h};i.src&&(l.src=i.src),d&&h!=="video_note"&&h!=="sticker"&&(l.caption=d),h==="location"&&(i.latitude&&(l.latitude=i.latitude),i.longitude&&(l.longitude=i.longitude),d&&(l.caption=d)),h==="contact"&&(i.phone&&(l.phone=i.phone),i.first_name&&(l.first_name=i.first_name),i.last_name&&(l.last_name=i.last_name),i.vcard&&(l.vcard=i.vcard),d&&(l.caption=d)),s[c]=l}return s}static _processMessageBlocks(t){let e=/<message(?:\s+([^>]*))?>([\s\S]*?)<\/message>/gi,s={};for(let[,n,o]of t.matchAll(e)){let a={},i=/(\w+)="([^"]*)"/g;if(n)for(let h of n.matchAll(i))a[h[1]]=h[2];let r=a.lang||"default",c=o.replace(/^[\t ]+/gm,"").replace(/^\n+/,"").replace(/\n+$/,"").trim();s[r]=c}return s}static _processDescriptionBlocks(t){let e=/<description(?:\s+([^>]*))?>([\s\S]*?)<\/description>/gi,s={};for(let[,n,o]of t.matchAll(e)){let a={},i=/(\w+)="([^"]*)"/g;if(n)for(let d of n.matchAll(i))a[d[1]]=d[2];let r=a.lang||"default",c=a.scope||"default",h=o.replace(/^[\t ]+/gm,"").replace(/^\n+/,"").replace(/\n+$/,"").trim();s[r]||(s[r]={}),s[r][c]=h}return s}static _processKeyboardBlocks(t){let e=/<keyboard(?:\s+([^>]*))?>([\s\S]*?)<\/keyboard>/gi,s={};for(let[,n,o]of t.matchAll(e)){let a={},i=/(\w+)="([^"]*)"/g;if(n)for(let d of n.matchAll(i))a[d[1]]=d[2];let r=a.lang||"default",c=a.type==="bottom"?"bottom":"inline",h=o.trim();s[r]||(s[r]={}),s[r][c]=h}return s}static _compileToFunction(t,e){let s;e?s=t.map(a=>`\`${a}\``).join(","):s=`\`${t}\``;let n=s;if(n=this._processScriptBlocks(this._processDivBlocks(this._processSpaceBlocks(n))),e){let o=`return [${n}]`;return new Function("data",o)}else{let o=`return ${n}`;return new Function("data",o)}}static compileMedia(t,e){let s=e||this._processBaseBlocks(t),n={};for(let[o,a]of Object.entries(s)){let i=this._processMediaBlocks(a);n[o]={};for(let[r,c]of Object.entries(i)){let h={};for(let[d,l]of Object.entries(c)){if(d==="type"||typeof l!="string")continue;let m=this._processVariables(this._processExec(this._processSwitchBlocks(this._processMapBlocks(this._processScriptBlocks(l)))));h[d]=this._compileToFunction(m,!1)}n[o][r]=d=>{let l={...c};for(let[m,y]of Object.entries(h))l[m]=y(d);return l}}}return n}static compileMessages(t,e){let s=e||this._processBaseBlocks(t),n={};for(let[o,a]of Object.entries(s)){let i=this._processMessageBlocks(a);n[o]={};for(let[r,c]of Object.entries(i)){let h=this._processVariables(this._processExec(this._processSwitchBlocks(this._processMapBlocks(this._processScriptBlocks(c)))));n[o][r]=this._compileToFunction(h,!1)}}return n}static compileDescription(t,e){let s=e||this._processBaseBlocks(t),n={};for(let[o,a]of Object.entries(s)){let i=this._processDescriptionBlocks(a);n[o]={};for(let[r,c]of Object.entries(i))for(let[h,d]of Object.entries(c)){n[o][h]||(n[o][h]={});let l=this._processVariables(this._processExec(this._processSwitchBlocks(this._processMapBlocks(this._processScriptBlocks(d)))));n[o][h][r]=this._compileToFunction(l,!1)}}return n}static compileKeyboards(t,e){let s=e||this._processBaseBlocks(t),n={};for(let[o,a]of Object.entries(s)){let i=this._processKeyboardBlocks(a);n[o]={};for(let[r,c]of Object.entries(i)){n[o][r]={};for(let[h,d]of Object.entries(c)){let m=d.split(/(?<!\\),\s*/).map(y=>y.replace(/\\,/g,",").trim()).map(y=>this._processVariables(this._processExec(this._processSwitchBlocks(this._processMapBlocks(this._processScriptBlocks(y))))));n[o][r][h]=this._compileToFunction(m,!0)}}}return n}static _extractBlock(t,e,s="default",n="all",o){let a=/<base\b[^>]*?(?:\sid=(["']?)([^"'\s>]+)\1)?[^>]*?>([\s\S]*?)<\/base>/g,i=t,r=!1;for(let c of t.matchAll(a))if((c[2]??"default")===s){i=c[3]??"",r=!0;break}if(!r){let c=/<base\b/.test(t);if(!(s==="default"&&!c))return""}if(e){if(e==="all")return i;let c=Array.isArray(e)?e:[e],h=[];for(let l of c){let m=new RegExp(`([ \\t]*)<${l}(?:\\s+([^>]*))?>([\\s\\S]*?)<\\/${l}>`,"gi");for(let y of i.matchAll(m)){let C=y[2];if(o){let u=/lang="([^"]*)"/i,w=C?.match(u);if(((w?w[1]:void 0)||"default")!==o)continue}h.push({start:y.index,content:y[0],innerContent:y[3]??""})}}h.sort((l,m)=>l.start-m.start);let d=p(l=>{let m=l.split(`
1
+ "use strict";var gt=Object.create;var D=Object.defineProperty;var ut=Object.getOwnPropertyDescriptor;var yt=Object.getOwnPropertyNames;var ft=Object.getPrototypeOf,Ct=Object.prototype.hasOwnProperty;var p=(g,t)=>D(g,"name",{value:t,configurable:!0});var St=(g,t)=>{for(var e in t)D(g,e,{get:t[e],enumerable:!0})},Z=(g,t,e,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of yt(t))!Ct.call(g,n)&&n!==e&&D(g,n,{get:()=>t[n],enumerable:!(s=ut(t,n))||s.enumerable});return g};var tt=(g,t,e)=>(e=g!=null?gt(ft(g)):{},Z(t||!g||!g.__esModule?D(e,"default",{value:g,enumerable:!0}):e,g)),bt=g=>Z(D({},"__esModule",{value:!0}),g);var wt={};St(wt,{BlockKeyboard:()=>J,CacheExternal:()=>O,Ctx:()=>V,Gramstax:()=>U,LabelKeyboard:()=>Q,LoggingUtil:()=>E,TemplateEngine:()=>k,TemplateManager:()=>B,WorkerThreadExport:()=>H,WorkerThreadGatewayClient:()=>K,WorkerThreadGatewayServer:()=>L,WorkerThreadInit:()=>z,WorkerThreadLaunch:()=>$,WorkerThreadPool:()=>X,WorkerThreadRpc:()=>T,log:()=>q});module.exports=bt(wt);var Pt=p(()=>typeof document>"u"?new URL(`file:${__filename}`).href:document.currentScript&&document.currentScript.tagName.toUpperCase()==="SCRIPT"?document.currentScript.src:new URL("main.js",document.baseURI).href,"getImportMetaUrl"),S=Pt();var et=require("logging-pretty");var E=class extends et.LoggingPretty{static{p(this,"LoggingUtil")}constructor(t){super(t)}errorMake(t,e,s){this.error(`[${e?`${e}:${s}`:s}] ${this._formatErrorObj(t)}`)}_formatErrorObj(t){return JSON.stringify(t instanceof Error?{message:t.message,stack:t.stack,name:t.name}:t,null,2)}},q=new E;var st=require("keyv"),nt=tt(require("@keyv/redis"),1);var O=class extends st.Keyv{constructor(e="memory",s,n,o){let a;e.startsWith("redis")&&(a=new nt.default(e)),e==="memory"&&(a=new Map),o?.forceStore&&(a=o.forceStore);super({store:a,namespace:n,ttl:s});this.url=e}static{p(this,"CacheExternal")}refreshLruCache(e){let s=this.store,n=this.opts.namespace?this.opts.namespace?.length+1:null,o=s.keys().toArray();for(let a=0;a<o.length;a++){let i=o[a];if(a==e)return;this.get(n?i.slice(n):i)}}};var it=require("timers/promises"),R=require("grammy");var V=class{static{p(this,"Ctx")}static template;static data;data=this.constructor.data;get userIsPremium(){return this.ct.from?.is_premium??!1}get userIsBot(){return this.ct.from?.is_bot??!1}get userId(){return this.ct.from?.id}get userName(){return this.ct.from?.username}get userFullName(){return`${this.ct.from?.first_name} ${this.ct.from?.last_name||""}`}get userFirstName(){return this.ct.from?.first_name}get userLastName(){return this.ct.from?.last_name}get userLanguage(){return this.ct.from?.language_code}set userLanguage(t){this.ct.from.language_code=t}get msgText(){return this.ct.message?.text}get msgTextPayloads(){return this.getPayloads(this.msgText,"space",this.data?._positionPayloadText||this.temp?.data?._positionPayloadText)}get msgTextPayload(){return this.msgTextPayloads[0]}get msgTextCommandPayloads(){return this.getPayloads(this.msgText,"space")}get msgTextCommandPayload(){return this.msgTextCommandPayloads[0]}get msgCaption(){return this.ct.message?.caption}get msgCaptionPayloads(){return this.getPayloads(this.msgCaption,"space")}get msgCaptionPayload(){return this.msgCaptionPayloads[0]}get msgCaptionCommandPayloads(){return this.getPayloads(this.msgCaption,"space")}get msgCaptionCommandPayload(){return this.msgCaptionCommandPayloads[0]}get msgPhoto(){return this.ct.message?.photo}get msgVideo(){return this.ct.message?.video}get msgAudio(){return this.ct.message?.audio}get msgDocument(){return this.ct.message?.document}get msgAnimation(){return this.ct.message?.animation}get msgVoice(){return this.ct.message?.voice}get msgVideoNote(){return this.ct.message?.video_note}get msgSticker(){return this.ct.message?.sticker}get msgLocation(){return this.ct.message?.location}get msgContact(){return this.ct.message?.contact}get msgWebAppData(){return this.ct.message?.web_app_data}get msgGift(){return this.ct.message?.gift}get callbackData(){return this.ct.callbackQuery?.data}get callbackDataPayloads(){return this.getPayloads(this.callbackData,"colon")}get callbackDataPayload(){return this.callbackDataPayloads?.[0]}get session(){return this.temp.session}set session(t){this.temp.session=t}ct;cacheSession;cacheKeyboard;templateManager;temp;constructor(t){this.ct=t.ct,this.cacheSession=t.cacheSession,this.cacheKeyboard=t.cacheKeyboard,this.templateManager=t.templateManager,this.temp=t.temp}async broadcast(t,e,s,n,o,a,i=!1){try{this.temp.isAnswer=!0;let r=30,c=e.map(h=>this.templateManager.getMessage(this.data.name,o,h,n));for(let h=0;h<t.length;h++){let d=t[h],l=c[h];await this.ct.api.sendMessage(d,l,{parse_mode:"HTML",reply_markup:s,...a}),h+1==r&&await(0,it.setTimeout)(1200)}}catch(r){if(i)throw r}}async reply(t,e,s,n){this.temp.isAnswer=!0;let o=this.templateManager.getMessage(this.data.name,s,this.userLanguage,e);return await this.ct.reply(o,{parse_mode:"HTML",reply_markup:t,...n})}async replyMedia(t,e,s,n,o){this.temp.isAnswer=!0;let a=this.templateManager.getMedia(this.data.name,n,this.userLanguage,s),i={parse_mode:"HTML",reply_markup:e,...o};if(t=="photo")return await this.ct.replyWithPhoto(a.src,{caption:a.caption,...i});if(t=="video")return await this.ct.replyWithVideo(a.src,{caption:a.caption,...i});if(t=="audio")return await this.ct.replyWithAudio(a.src,{caption:a.caption,...i});if(t=="document")return await this.ct.replyWithDocument(a.src,{caption:a.caption,...i});if(t=="animation")return await this.ct.replyWithAnimation(a.src,{caption:a.caption,...i});if(t=="voice")return await this.ct.replyWithVoice(a.src,i);if(t=="video_note")return await this.ct.replyWithVideoNote(a.src,i);if(t=="sticker")return await this.ct.replyWithSticker(a.src,i);if(t=="location")return await this.ct.replyWithLocation(parseInt(a.latitude),parseInt(a.longitude),i);if(t=="contact")return await this.ct.replyWithContact(a.phone,a.first_name,{vcard:a.vcard,...i})}async replyPhoto(t,e,s,n){return this.replyMedia("photo",t,e,s,n)}async replyVideo(t,e,s,n){return this.replyMedia("video",t,e,s,n)}async replyAudio(t,e,s,n){return this.replyMedia("audio",t,e,s,n)}async replyDocument(t,e,s,n){return this.replyMedia("document",t,e,s,n)}async replyAnimation(t,e,s,n){return this.replyMedia("animation",t,e,s,n)}async replyVoice(t,e,s,n){return this.replyMedia("voice",t,e,s,n)}async replyVideoNote(t,e,s,n){return this.replyMedia("video_note",t,e,s,n)}async replySticker(t,e,s,n){return this.replyMedia("sticker",t,e,s,n)}async replyLocation(t,e,s,n){return this.replyMedia("location",t,e,s,n)}async replyContact(t,e,s,n){return this.replyMedia("contact",t,e,s,n)}async replyAction(t){return await this.ct.replyWithChatAction(t)}async edit(t,e,s,n,o=!0){try{this.temp.isAnswer=!0;let a=this.templateManager.getMessage(this.data.name,s,this.userLanguage,e);return await this.ct.editMessageText(a,{parse_mode:"HTML",reply_markup:t,...n})}catch(a){if(o)await this.reply(t,e,s,n);else throw a}}async editMedia(t,e,s,n,o,a,i=!0){try{this.temp.isAnswer=!0;let{src:r,caption:c}=this.templateManager.getMedia(this.data.name,n,this.userLanguage,s);return t=="voice"?(await this.delete(),await this.replyVoice(e,s,n,o)):t=="video_note"?(await this.delete(),await this.replyVoice(e,s,n,o)):t=="sticker"?(await this.delete(),await this.replySticker(e,s,n,o)):t=="location"?(await this.delete(),await this.replyLocation(e,s,n,o)):t=="contact"?(await this.delete(),await this.replyContact(e,s,n,o)):await this.ct.editMessageMedia({media:r,caption:c,type:t,parse_mode:"HTML",...o},{reply_markup:e,...a})}catch(r){if(i===!0)await this.reply(e,s,n,a);else throw r}}async editPhoto(t,e,s,n,o){return await this.editMedia("photo",t,e,s,n,o)}async editVideo(t,e,s,n,o){return await this.editMedia("video",t,e,s,n,o)}async editAudio(t,e,s,n,o){return await this.editMedia("audio",t,e,s,n,o)}async editDocument(t,e,s,n,o){return await this.editMedia("document",t,e,s,n,o)}async editAnimation(t,e,s,n,o){return await this.editMedia("animation",t,e,s,n,o)}async editVoice(t,e,s,n){return await this.editMedia("voice",t,e,s,n)}async editVideoNote(t,e,s,n){return await this.editMedia("video_note",t,e,s,n)}async editSticker(t,e,s,n){return await this.editMedia("sticker",t,e,s,n)}async editLocation(t,e,s,n){return await this.editMedia("location",t,e,s,n)}async editContact(t,e,s,n){return await this.editMedia("contact",t,e,s,n)}async delete(){return await this.ct.deleteMessage()}async callbackQueryAnswer(t){try{return this.temp.isAnswer=!0,await this.ct.answerCallbackQuery(t)}catch{return null}}async sessionSet(t,e,s){try{let n={method:t,params:e,...s},o=await this.cacheSession.set(`${this.userId}`,n);return o&&(this.session=n),o}catch{return null}}async sessionGet(){try{let t=await this.cacheSession.get(`${this.userId}`);return t&&(this.session=t),t||null}catch{return null}}async sessionClear(){try{let t=await this.cacheSession.delete(`${this.userId}`);return t&&(this.session={}),t}catch{return null}}static buildData(t){let s=typeof t=="function"?{callback:t}:t||{},n=s.callback,o=this.prototype.addPayloads.bind(this.prototype),a=s.name||"";return{name:a,intentText:s.intentText||a,intentTextCommand:s.intentTextCommand||a,intentCallback:a,callback:n?function(...r){return o(this.intentCallback,"colon",n(...r))}:function(){return this?.intentCallback},_positionPayloadText:s.intentText?s.intentText.split(this.prototype.getSeperatorTag("space")).length:void 0}}keyboardCols(t,e,s,n){let[o,a]=s.split("-"),i=parseInt(o),r=a?parseInt(a):null,c=e.length,h=t;for(let d=0;d<c;d++){let l=e[d];if(n(l,d),r===null)(d+1)%i===0&&d<c-1&&h.row();else{let m=c-(d+1);(m===r||m>r&&(d+1)%i===0)&&h.row()}}return t}bottomKeyboardT(t="1",e,s){return this.bottomKeyboard((n,o)=>this.keyboardCols(n,o,t,a=>n.text(a)),{baseId:e??void 0,data:s})}inlineKeyboardT(t,e="1",s,n){return this.inlineKeyboard((o,a)=>this.keyboardCols(o,a,e,(i,r)=>{let c=t[r],h=typeof c=="string"?c:c.data.callback();o.text(i,h)}),{baseId:s??void 0,data:n})}inlineKeyboard(t,e){let s=this.data.name;if(e?.cache===!0){let i=`${s}:${this.userLanguage}:i`,r=this.cacheKeyboard.get(i);if(!r){let c=new R.InlineKeyboard,h=this.templateManager.getKeyboard(s,e?.baseId,this.userLanguage,"inline",e?.data),d=t(c,h);return this.cacheKeyboard.set(i,d),d}return r}let n=new R.InlineKeyboard,o=this.templateManager.getKeyboard(s,e?.baseId,this.userLanguage,"inline",e?.data);return t(n,o)}bottomKeyboard(t,e){let s=this.data.name;if(e?.cache===!0){let i=`${s}:${this.userLanguage}:b`,r=this.cacheKeyboard.get(i);if(!r){let c=new R.Keyboard,h=this.templateManager.getKeyboard(s,e?.baseId,this.userLanguage,"bottom",e?.data),d=t(c,h);return d.resized(!0),this.cacheKeyboard.set(i,d),d}return r}let n=new R.Keyboard,o=this.templateManager.getKeyboard(s,e?.baseId,this.userLanguage,"bottom",e?.data),a=t(n,o);return a.resized(),a}getSeperatorTag(t="space"){return t=="space"?" ":":"}havePayloads(t="",e){return t.includes(this.getSeperatorTag(e))}addPayloads(t="",e,s){let n=this.getSeperatorTag(e),o="";for(let a=0;a<s.length;a++){let i=s[a];i!=null&&i!==""&&(o+=n+i)}return t+o}getPayloads(t="",e,s=1){if(!t)return[];let n=this.getSeperatorTag(e);return t.split(n).slice(s)}getIntent(t="",e,s=1){if(!t)return"";let n=this.getSeperatorTag(e),o=t.split(n);return s==1?o[0]:o.slice(0,s).join(n)}validateSessionCallback(t,e){return(t??this.session.method)===this.methodSessionCallback(e)}validateSessionCallbackPayload(t,e){return(t??this.session.method)===this.methodSessionCallbackPayload(e)}validateSessionText(t,e){return(t??this.session.method)===this.methodSessionText(e)}validateSessionTextPayload(t,e){return(t??this.session.method)===this.methodSessionTextPayload(e)}validateSessionTextCommand(t,e){return(t??this.session.method)===this.methodSessionTextCommand(e)}validateSessionTextCommandPayload(t,e){return(t??this.session.method)===this.methodSessionTextCommandPayload(e)}validateSessionTextFree(t,e){return(t??this.session.method)===this.methodSessionTextFree(e)}validateSessionPhotoCaption(t,e){return(t??this.session.method)===this.methodSessionPhotoCaption(e)}validateSessionPhotoCaptionPayload(t,e){return(t??this.session.method)===this.methodSessionPhotoCaptionPayload(e)}validateSessionPhotoCaptionCommand(t,e){return(t??this.session.method)===this.methodSessionPhotoCaptionCommand(e)}validateSessionPhotoCaptionCommandPayload(t,e){return(t??this.session.method)===this.methodSessionPhotoCaptionCommandPayload(e)}validateSessionPhotoFree(t,e){return(t??this.session.method)===this.methodSessionPhotoFree(e)}validateSessionVideoCaption(t,e){return(t??this.session.method)===this.methodSessionVideoCaption(e)}validateSessionVideoCaptionPayload(t,e){return(t??this.session.method)===this.methodSessionVideoCaptionPayload(e)}validateSessionVideoCaptionCommand(t,e){return(t??this.session.method)===this.methodSessionVideoCaptionCommand(e)}validateSessionVideoCaptionCommandPayload(t,e){return(t??this.session.method)===this.methodSessionVideoCaptionCommandPayload(e)}validateSessionVideoFree(t,e){return(t??this.session.method)===this.methodSessionVideoFree(e)}validateSessionAudioCaption(t,e){return(t??this.session.method)===this.methodSessionAudioCaption(e)}validateSessionAudioCaptionPayload(t,e){return(t??this.session.method)===this.methodSessionAudioCaptionPayload(e)}validateSessionAudioCaptionCommand(t,e){return(t??this.session.method)===this.methodSessionAudioCaptionCommand(e)}validateSessionAudioCaptionCommandPayload(t,e){return(t??this.session.method)===this.methodSessionAudioCaptionCommandPayload(e)}validateSessionAudioFree(t,e){return(t??this.session.method)===this.methodSessionAudioFree(e)}validateSessionDocumentCaption(t,e){return(t??this.session.method)===this.methodSessionDocumentCaption(e)}validateSessionDocumentCaptionPayload(t,e){return(t??this.session.method)===this.methodSessionDocumentCaptionPayload(e)}validateSessionDocumentCaptionCommand(t,e){return(t??this.session.method)===this.methodSessionDocumentCaptionCommand(e)}validateSessionDocumentCaptionCommandPayload(t,e){return(t??this.session.method)===this.methodSessionDocumentCaptionCommandPayload(e)}validateSessionDocumentFree(t,e){return(t??this.session.method)===this.methodSessionDocumentFree(e)}validateSessionAnimationCaption(t,e){return(t??this.session.method)===this.methodSessionAnimationCaption(e)}validateSessionAnimationCaptionPayload(t,e){return(t??this.session.method)===this.methodSessionAnimationCaptionPayload(e)}validateSessionAnimationCaptionCommand(t,e){return(t??this.session.method)===this.methodSessionAnimationCaptionCommand(e)}validateSessionAnimationCaptionCommandPayload(t,e){return(t??this.session.method)===this.methodSessionAnimationCaptionCommandPayload(e)}validateSessionAnimationFree(t,e){return(t??this.session.method)===this.methodSessionAnimationFree(e)}validateSessionVoiceCaption(t,e){return(t??this.session.method)===this.methodSessionVoiceCaption(e)}validateSessionVoiceCaptionPayload(t,e){return(t??this.session.method)===this.methodSessionVoiceCaptionPayload(e)}validateSessionVoiceCaptionCommand(t,e){return(t??this.session.method)===this.methodSessionVoiceCaptionCommand(e)}validateSessionVoiceCaptionCommandPayload(t,e){return(t??this.session.method)===this.methodSessionVoiceCaptionCommandPayload(e)}validateSessionVoiceFree(t,e){return(t??this.session.method)===this.methodSessionVoiceFree(e)}validateSessionVideoNoteFree(t,e){return(t??this.session.method)===this.methodSessionVideoNoteFree(e)}validateSessionStickerFree(t,e){return(t??this.session.method)===this.methodSessionStickerFree(e)}validateSessionLocationFree(t,e){return(t??this.session.method)===this.methodSessionLocationFree(e)}validateSessionContactFree(t,e){return(t??this.session.method)===this.methodSessionContactFree(e)}sessionCallback(t,e){return this.sessionSet(this.methodSessionCallback(e),t)}sessionCallbackPayload(t,e){return this.sessionSet(this.methodSessionCallbackPayload(e),t)}sessionText(t,e){return this.sessionSet(this.methodSessionText(e),t)}sessionTextPayload(t,e){return this.sessionSet(this.methodSessionTextPayload(e),t)}sessionTextCommand(t,e){return this.sessionSet(this.methodSessionTextCommand(e),t)}sessionTextCommandPayload(t,e){return this.sessionSet(this.methodSessionTextCommandPayload(e),t)}sessionTextFree(t,e){return this.sessionSet(this.methodSessionTextFree(e),t)}sessionPhotoCaption(t,e){return this.sessionSet(this.methodSessionPhotoCaption(e),t)}sessionPhotoCaptionPayload(t,e){return this.sessionSet(this.methodSessionPhotoCaptionPayload(e),t)}sessionPhotoCaptionCommand(t,e){return this.sessionSet(this.methodSessionPhotoCaptionCommand(e),t)}sessionPhotoCaptionCommandPayload(t,e){return this.sessionSet(this.methodSessionPhotoCaptionCommandPayload(e),t)}sessionPhotoFree(t,e){return this.sessionSet(this.methodSessionPhotoFree(e),t)}sessionVideoCaption(t,e){return this.sessionSet(this.methodSessionVideoCaption(e),t)}sessionVideoCaptionPayload(t,e){return this.sessionSet(this.methodSessionVideoCaptionPayload(e),t)}sessionVideoCaptionCommand(t,e){return this.sessionSet(this.methodSessionVideoCaptionCommand(e),t)}sessionVideoCaptionCommandPayload(t,e){return this.sessionSet(this.methodSessionVideoCaptionCommandPayload(e),t)}sessionVideoFree(t,e){return this.sessionSet(this.methodSessionVideoFree(e),t)}sessionAudioCaption(t,e){return this.sessionSet(this.methodSessionAudioCaption(e),t)}sessionAudioCaptionPayload(t,e){return this.sessionSet(this.methodSessionAudioCaptionPayload(e),t)}sessionAudioCaptionCommand(t,e){return this.sessionSet(this.methodSessionAudioCaptionCommand(e),t)}sessionAudioCaptionCommandPayload(t,e){return this.sessionSet(this.methodSessionAudioCaptionCommandPayload(e),t)}sessionAudioFree(t,e){return this.sessionSet(this.methodSessionAudioFree(e),t)}sessionDocumentCaption(t,e){return this.sessionSet(this.methodSessionDocumentCaption(e),t)}sessionDocumentCaptionPayload(t,e){return this.sessionSet(this.methodSessionDocumentCaptionPayload(e),t)}sessionDocumentCaptionCommand(t,e){return this.sessionSet(this.methodSessionDocumentCaptionCommand(e),t)}sessionDocumentCaptionCommandPayload(t,e){return this.sessionSet(this.methodSessionDocumentCaptionCommandPayload(e),t)}sessionDocumentFree(t,e){return this.sessionSet(this.methodSessionDocumentFree(e),t)}sessionAnimationCaption(t,e){return this.sessionSet(this.methodSessionAnimationCaption(e),t)}sessionAnimationCaptionPayload(t,e){return this.sessionSet(this.methodSessionAnimationCaptionPayload(e),t)}sessionAnimationCaptionCommand(t,e){return this.sessionSet(this.methodSessionAnimationCaptionCommand(e),t)}sessionAnimationCaptionCommandPayload(t,e){return this.sessionSet(this.methodSessionAnimationCaptionCommandPayload(e),t)}sessionAnimationFree(t,e){return this.sessionSet(this.methodSessionAnimationFree(e),t)}sessionVoiceCaption(t,e){return this.sessionSet(this.methodSessionVoiceCaption(e),t)}sessionVoiceCaptionPayload(t,e){return this.sessionSet(this.methodSessionVoiceCaptionPayload(e),t)}sessionVoiceCaptionCommand(t,e){return this.sessionSet(this.methodSessionVoiceCaptionCommand(e),t)}sessionVoiceCaptionCommandPayload(t,e){return this.sessionSet(this.methodSessionVoiceCaptionCommandPayload(e),t)}sessionVoiceFree(t,e){return this.sessionSet(this.methodSessionVoiceFree(e),t)}sessionVideoNoteFree(t,e){return this.sessionSet(this.methodSessionVideoNoteFree(e),t)}sessionStickerFree(t,e){return this.sessionSet(this.methodSessionStickerFree(e),t)}sessionLocationFree(t,e){return this.sessionSet(this.methodSessionLocationFree(e),t)}sessionContactFree(t,e){return this.sessionSet(this.methodSessionContactFree(e),t)}sessionToCallback(t,e){return this.sessionCallback({...this.session.params,...t},e)}sessionToCallbackPayload(t,e){return this.sessionCallbackPayload({...this.session.params,...t},e)}sessionToText(t,e){return this.sessionText({...this.session.params,...t},e)}sessionToTextPayload(t,e){return this.sessionTextPayload({...this.session.params,...t},e)}sessionToTextCommand(t,e){return this.sessionTextCommand({...this.session.params,...t},e)}sessionToTextCommandPayload(t,e){return this.sessionTextCommandPayload({...this.session.params,...t},e)}sessionToTextFree(t,e){return this.sessionTextFree({...this.session.params,...t},e)}sessionToPhotoCaption(t,e){return this.sessionPhotoCaption({...this.session.params,...t},e)}sessionToPhotoCaptionPayload(t,e){return this.sessionPhotoCaptionPayload({...this.session.params,...t},e)}sessionToPhotoCaptionCommand(t,e){return this.sessionPhotoCaptionCommand({...this.session.params,...t},e)}sessionToPhotoCaptionCommandPayload(t,e){return this.sessionPhotoCaptionCommandPayload({...this.session.params,...t},e)}sessionToPhotoFree(t,e){return this.sessionPhotoFree({...this.session.params,...t},e)}sessionToVideoCaption(t,e){return this.sessionVideoCaption({...this.session.params,...t},e)}sessionToVideoCaptionPayload(t,e){return this.sessionVideoCaptionPayload({...this.session.params,...t},e)}sessionToVideoCaptionCommand(t,e){return this.sessionVideoCaptionCommand({...this.session.params,...t},e)}sessionToVideoCaptionCommandPayload(t,e){return this.sessionVideoCaptionCommandPayload({...this.session.params,...t},e)}sessionToVideoFree(t,e){return this.sessionVideoFree({...this.session.params,...t},e)}sessionToAudioCaption(t,e){return this.sessionAudioCaption({...this.session.params,...t},e)}sessionToAudioCaptionPayload(t,e){return this.sessionAudioCaptionPayload({...this.session.params,...t},e)}sessionToAudioCaptionCommand(t,e){return this.sessionAudioCaptionCommand({...this.session.params,...t},e)}sessionToAudioCaptionCommandPayload(t,e){return this.sessionAudioCaptionCommandPayload({...this.session.params,...t},e)}sessionToAudioFree(t,e){return this.sessionAudioFree({...this.session.params,...t},e)}sessionToDocumentCaption(t,e){return this.sessionDocumentCaption({...this.session.params,...t},e)}sessionToDocumentCaptionPayload(t,e){return this.sessionDocumentCaptionPayload({...this.session.params,...t},e)}sessionToDocumentCaptionCommand(t,e){return this.sessionDocumentCaptionCommand({...this.session.params,...t},e)}sessionToDocumentCaptionCommandPayload(t,e){return this.sessionDocumentCaptionCommandPayload({...this.session.params,...t},e)}sessionToDocumentFree(t,e){return this.sessionDocumentFree({...this.session.params,...t},e)}sessionToAnimationCaption(t,e){return this.sessionAnimationCaption({...this.session.params,...t},e)}sessionToAnimationCaptionPayload(t,e){return this.sessionAnimationCaptionPayload({...this.session.params,...t},e)}sessionToAnimationCaptionCommand(t,e){return this.sessionAnimationCaptionCommand({...this.session.params,...t},e)}sessionToAnimationCaptionCommandPayload(t,e){return this.sessionAnimationCaptionCommandPayload({...this.session.params,...t},e)}sessionToAnimationFree(t,e){return this.sessionAnimationFree({...this.session.params,...t},e)}sessionToVoiceCaption(t,e){return this.sessionVoiceCaption({...this.session.params,...t},e)}sessionToVoiceCaptionPayload(t,e){return this.sessionVoiceCaptionPayload({...this.session.params,...t},e)}sessionToVoiceCaptionCommand(t,e){return this.sessionVoiceCaptionCommand({...this.session.params,...t},e)}sessionToVoiceCaptionCommandPayload(t,e){return this.sessionVoiceCaptionCommandPayload({...this.session.params,...t},e)}sessionToVoiceFree(t,e){return this.sessionVoiceFree({...this.session.params,...t},e)}sessionToVideoNoteFree(t,e){return this.sessionVideoNoteFree({...this.session.params,...t},e)}sessionToStickerFree(t,e){return this.sessionStickerFree({...this.session.params,...t},e)}sessionToLocationFree(t,e){return this.sessionLocationFree({...this.session.params,...t},e)}sessionToContactFree(t,e){return this.sessionContactFree({...this.session.params,...t},e)}methodSession(t,e){return`${t}-${e||this.data.name}`}methodSessionCallback(t){return this.methodSession("1",t)}methodSessionCallbackPayload(t){return this.methodSession("2",t)}methodSessionText(t){return this.methodSession("3",t)}methodSessionTextPayload(t){return this.methodSession("4",t)}methodSessionTextCommand(t){return this.methodSession("5",t)}methodSessionTextCommandPayload(t){return this.methodSession("6",t)}methodSessionTextFree(t){return this.methodSession("7",t)}methodSessionPhotoCaption(t){return this.methodSession("8",t)}methodSessionPhotoCaptionPayload(t){return this.methodSession("9",t)}methodSessionPhotoCaptionCommand(t){return this.methodSession("10",t)}methodSessionPhotoCaptionCommandPayload(t){return this.methodSession("11",t)}methodSessionPhotoFree(t){return this.methodSession("12",t)}methodSessionVideoCaption(t){return this.methodSession("13",t)}methodSessionVideoCaptionPayload(t){return this.methodSession("14",t)}methodSessionVideoCaptionCommand(t){return this.methodSession("15",t)}methodSessionVideoCaptionCommandPayload(t){return this.methodSession("16",t)}methodSessionVideoFree(t){return this.methodSession("17",t)}methodSessionAudioCaption(t){return this.methodSession("18",t)}methodSessionAudioCaptionPayload(t){return this.methodSession("19",t)}methodSessionAudioCaptionCommand(t){return this.methodSession("20",t)}methodSessionAudioCaptionCommandPayload(t){return this.methodSession("21",t)}methodSessionAudioFree(t){return this.methodSession("22",t)}methodSessionDocumentCaption(t){return this.methodSession("23",t)}methodSessionDocumentCaptionPayload(t){return this.methodSession("24",t)}methodSessionDocumentCaptionCommand(t){return this.methodSession("25",t)}methodSessionDocumentCaptionCommandPayload(t){return this.methodSession("26",t)}methodSessionDocumentFree(t){return this.methodSession("27",t)}methodSessionAnimationCaption(t){return this.methodSession("28",t)}methodSessionAnimationCaptionPayload(t){return this.methodSession("29",t)}methodSessionAnimationCaptionCommand(t){return this.methodSession("30",t)}methodSessionAnimationCaptionCommandPayload(t){return this.methodSession("31",t)}methodSessionAnimationFree(t){return this.methodSession("32",t)}methodSessionVoiceCaption(t){return this.methodSession("33",t)}methodSessionVoiceCaptionPayload(t){return this.methodSession("34",t)}methodSessionVoiceCaptionCommand(t){return this.methodSession("35",t)}methodSessionVoiceCaptionCommandPayload(t){return this.methodSession("36",t)}methodSessionVoiceFree(t){return this.methodSession("37",t)}methodSessionVideoNoteFree(t){return this.methodSession("38",t)}methodSessionStickerFree(t){return this.methodSession("39",t)}methodSessionLocationFree(t){return this.methodSession("40",t)}methodSessionContactFree(t){return this.methodSession("41",t)}};var j=require("path"),F=require("fs"),ot=require("module");var P=class{static{p(this,"PageManager")}static _getFile(t,e,s=0){let o=Object.values(t)[s];if(o===void 0)throw new Error(`File ${e} must have export (not default) class page`);return o}static getFilePath(){return(0,j.join)(process.cwd(),"src","pages")}static getFileSync(t,e=0){t||(t=this.getFilePath());let n=(0,ot.createRequire)(t)(t);return this._getFile(n,t,e)}static async getFile(t,e=0){t||(t=this.getFilePath());let s=await import(`${t}?t=${Date.now()}`);return this._getFile(s,t,e)}static getFileManySync(t,e=0){if(t||(t=this.getFilePath()),!(0,F.existsSync)(t))throw new Error(`Directory ${t} is not found, please make it manually`);return(0,F.readdirSync)(t).map(n=>{let o=(0,j.join)(t,n);return{path:o,page:this.getFileSync(o,e)}})}static clearCacheRequire(t){if(t||(t=this.getFilePath()),!(0,F.existsSync)(t))throw new Error(`Directory ${t} is not found, please make it manually`);return(0,F.readdirSync)(t).forEach(s=>{let n=(0,j.join)(t,s);delete require.cache[require.resolve(n)]}),!0}};var rt=require("fs"),ct=require("url"),M=require("path");var b=require("path"),f=require("fs"),at=require("chokidar");var k=class{static{p(this,"TemplateEngine")}static _escape(t){return t.replace(/\\/g,"\\\\").replace(/`/g,"\\`")}static _processVariables(t){return t.replace(/\{\{(\w+)\}\}/g,(e,s)=>`\${(data && data["${s}"]) ?? ""}`)}static _processBaseBlocks(t){let e=/<base\b[^>]*?(?:\sid=(["']?)([^"'\s>]+)\1)?[^>]*?>([\s\S]*?)<\/base>/g,s={};for(let n of t.matchAll(e)){let o=n[2]??"default",i=(n[3]??"").replace(/^[\t ]+/gm,"").replace(/^\n+/,"").replace(/\n+$/,"").trim();s[o]=i}return s}static _processScriptBlocks(t){return t.replace(/<script\b[^>]*>([\s\S]*?)<\/script>/gi,(e,s)=>{let n=s.trim();return n?`\${(() => { if (!data) return ''; try { with(data) { ${n} } } catch(e) { return '' } })()}`:""})}static _processSpaceBlocks(t){return t.replace(/^[ \t]*<space\s*\/>[ \t]*$/gim,"")}static _processDivBlocks(t){return t.replace(/<div>([\s\S]*?)<\/div>/gi,(e,s)=>s.replace(/^[\t ]+/gm,"").replace(/^\n+/,"").replace(/\n+$/,""))}static _processSwitchBlocks(t){let e=/<switch\b(?:\s+value="([^"]+)")?>([\s\S]*?)<\/switch>/gi;return t.replace(e,(s,n,o)=>{if(!n)return"";let a="",i=/<case\b(?:\s+is="([^"]+)")?>([\s\S]*?)<\/case>/gi,r=/<default>([\s\S]*?)<\/default>/gi,c;for(;(c=i.exec(o))!==null;){let d=(c[1]||"").split(",").map(m=>m.trim()),l=(c[2]||"").replace(/^[\t ]+/gm,"").replace(/^\n+/,"").replace(/\n+$/,"").trim().replace(/`/g,"\\`");d.forEach(m=>{a+=`case "${m}": `}),a+=`return \`${l}\`; `}let h=r.exec(o);if(h){let d=(h[1]||"").replace(/^[\t ]+/gm,"").replace(/^\n+/,"").replace(/\n+$/,"").trim();a+=`default: return \`${d}\`; `}else a+="default: return ''; ";return`\${(() => { switch((data && data["${n}"])) { ${a} } })()}`})}static _processExec(t){return t.replace(/{~\s*([\s\S]*?)\s*~}/g,(e,s)=>`\${(() => { try { return ${s} } catch(e) { try { with(data || {}) { return ${s} } } catch(ee) { return '' } } })()}`)}static _processMapBlocks(t){let e=/<map(?:\s+([^>]*))?>([\s\S]*?)<\/map>/gi;return t.replace(e,(s,n,o)=>{let a={},i=/(\w+)="([^"]*)"/g;if(n)for(let l of n.matchAll(i))a[l[1]]=l[2];let r=a.src;if(!r)return"";let c=a.join??"\\n",h=o.replace(/^[\t ]+/gm,"").replace(/^\n+/,"").replace(/\n+$/,"").replace(/`/g,"\\`");h=h.replace(/\{\{([\w.]+)\}\}/g,(l,m)=>m==="e"||m.startsWith("e.")?`\${${m}}`:m==="i"?"${i}":l);let d=c.replace(/"/g,'\\"');return`\${(data && data["${r}"] || []).map((e, i) => \`${h}\`).join("${d}")}`})}static _processMediaBlocks(t){let e=/<media(?:\s+([^>]*))?>([\s\S]*?)<\/media>/gi,s={};for(let n of t.matchAll(e)){let o=n[1],a=n[2],i={},r=/(\w+)="([^"]*)"/g;if(o)for(let m of o.matchAll(r))i[m[1]]=m[2];let c=i.lang||"default",h=i.type,d=a.replace(/^[\t ]+/gm,"").replace(/^\n+/,"").replace(/\n+$/,"").trim(),l={type:h};i.src&&(l.src=i.src),d&&h!=="video_note"&&h!=="sticker"&&(l.caption=d),h==="location"&&(i.latitude&&(l.latitude=i.latitude),i.longitude&&(l.longitude=i.longitude),d&&(l.caption=d)),h==="contact"&&(i.phone&&(l.phone=i.phone),i.first_name&&(l.first_name=i.first_name),i.last_name&&(l.last_name=i.last_name),i.vcard&&(l.vcard=i.vcard),d&&(l.caption=d)),s[c]=l}return s}static _processMessageBlocks(t){let e=/<message(?:\s+([^>]*))?>([\s\S]*?)<\/message>/gi,s={};for(let[,n,o]of t.matchAll(e)){let a={},i=/(\w+)="([^"]*)"/g;if(n)for(let h of n.matchAll(i))a[h[1]]=h[2];let r=a.lang||"default",c=o.replace(/^[\t ]+/gm,"").replace(/^\n+/,"").replace(/\n+$/,"").trim();s[r]=c}return s}static _processDescriptionBlocks(t){let e=/<description(?:\s+([^>]*))?>([\s\S]*?)<\/description>/gi,s={};for(let[,n,o]of t.matchAll(e)){let a={},i=/(\w+)="([^"]*)"/g;if(n)for(let d of n.matchAll(i))a[d[1]]=d[2];let r=a.lang||"default",c=a.scope||"default",h=o.replace(/^[\t ]+/gm,"").replace(/^\n+/,"").replace(/\n+$/,"").trim();s[r]||(s[r]={}),s[r][c]=h}return s}static _processKeyboardBlocks(t){let e=/<keyboard(?:\s+([^>]*))?>([\s\S]*?)<\/keyboard>/gi,s={};for(let[,n,o]of t.matchAll(e)){let a={},i=/(\w+)="([^"]*)"/g;if(n)for(let d of n.matchAll(i))a[d[1]]=d[2];let r=a.lang||"default",c=a.type==="bottom"?"bottom":"inline",h=o.trim();s[r]||(s[r]={}),s[r][c]=h}return s}static _compileToFunction(t,e){let s;e?s=t.map(a=>`\`${a}\``).join(","):s=`\`${t}\``;let n=s;if(n=this._processScriptBlocks(this._processDivBlocks(this._processSpaceBlocks(n))),e){let o=`return [${n}]`;return new Function("data",o)}else{let o=`return ${n}`;return new Function("data",o)}}static compileMedia(t,e){let s=e||this._processBaseBlocks(t),n={};for(let[o,a]of Object.entries(s)){let i=this._processMediaBlocks(a);n[o]={};for(let[r,c]of Object.entries(i)){let h={};for(let[d,l]of Object.entries(c)){if(d==="type"||typeof l!="string")continue;let m=this._processVariables(this._processExec(this._processSwitchBlocks(this._processMapBlocks(this._processScriptBlocks(l)))));h[d]=this._compileToFunction(m,!1)}n[o][r]=d=>{let l={...c};for(let[m,y]of Object.entries(h))l[m]=y(d);return l}}}return n}static compileMessages(t,e){let s=e||this._processBaseBlocks(t),n={};for(let[o,a]of Object.entries(s)){let i=this._processMessageBlocks(a);n[o]={};for(let[r,c]of Object.entries(i)){let h=this._processVariables(this._processExec(this._processSwitchBlocks(this._processMapBlocks(this._processScriptBlocks(c)))));n[o][r]=this._compileToFunction(h,!1)}}return n}static compileDescription(t,e){let s=e||this._processBaseBlocks(t),n={};for(let[o,a]of Object.entries(s)){let i=this._processDescriptionBlocks(a);n[o]={};for(let[r,c]of Object.entries(i))for(let[h,d]of Object.entries(c)){n[o][h]||(n[o][h]={});let l=this._processVariables(this._processExec(this._processSwitchBlocks(this._processMapBlocks(this._processScriptBlocks(d)))));n[o][h][r]=this._compileToFunction(l,!1)}}return n}static compileKeyboards(t,e){let s=e||this._processBaseBlocks(t),n={};for(let[o,a]of Object.entries(s)){let i=this._processKeyboardBlocks(a);n[o]={};for(let[r,c]of Object.entries(i)){n[o][r]={};for(let[h,d]of Object.entries(c)){let m=d.split(/(?<!\\),\s*/).map(y=>y.replace(/\\,/g,",").trim()).map(y=>this._processVariables(this._processExec(this._processSwitchBlocks(this._processMapBlocks(this._processScriptBlocks(y))))));n[o][r][h]=this._compileToFunction(m,!0)}}}return n}static _extractBlock(t,e,s="default",n="all",o){let a=/<base\b[^>]*?(?:\sid=(["']?)([^"'\s>]+)\1)?[^>]*?>([\s\S]*?)<\/base>/g,i=t,r=!1;for(let c of t.matchAll(a))if((c[2]??"default")===s){i=c[3]??"",r=!0;break}if(!r){let c=/<base\b/.test(t);if(!(s==="default"&&!c))return""}if(e){if(e==="all")return i;let c=Array.isArray(e)?e:[e],h=[];for(let l of c){let m=new RegExp(`([ \\t]*)<${l}(?:\\s+([^>]*))?>([\\s\\S]*?)<\\/${l}>`,"gi");for(let y of i.matchAll(m)){let C=y[2];if(o){let u=/lang="([^"]*)"/i,w=C?.match(u);if(((w?w[1]:void 0)||"default")!==o)continue}h.push({start:y.index,content:y[0],innerContent:y[3]??""})}}h.sort((l,m)=>l.start-m.start);let d=p(l=>{let m=l.split(`
2
2
  `);if(m.length<=1)return l.trim();let y=m.filter(u=>u.trim().length>0);if(y.length===0)return"";let C=y.reduce((u,w)=>{let I=w.match(/^([ \t]*)/),x=I?I[1].length:0;return x<u?x:u},1/0);return m.map(u=>u.length>=C?u.slice(C):u.trimStart()).join(`
3
3
  `).trim()},"processResult");return n==="all"?h.map(m=>d(m.content)).join(`
4
4
  `):h.map(m=>d(m.innerContent)).join(`
@@ -2,11 +2,11 @@ import { LoggingPretty } from 'logging-pretty';
2
2
  import { Keyv } from 'keyv';
3
3
  import * as grammy from 'grammy';
4
4
  import { Context, Keyboard, InlineKeyboard, Bot, BotError } from 'grammy';
5
- import * as _grammyjs_types from '@grammyjs/types';
6
- import { FSWatcher } from 'chokidar';
5
+ import * as grammy_types from 'grammy/types';
7
6
  import { UserFromGetMe } from 'grammy/types';
7
+ import { FSWatcher } from 'chokidar';
8
+ import * as node_worker_threads from 'node:worker_threads';
8
9
  import { Worker } from 'node:worker_threads';
9
- import * as worker_threads from 'worker_threads';
10
10
  import { Server, Client } from 'net-ipc';
11
11
 
12
12
  declare class LoggingUtil extends LoggingPretty {
@@ -230,23 +230,23 @@ declare class Ctx {
230
230
  get msgCaptionPayload(): string;
231
231
  get msgCaptionCommandPayloads(): string[];
232
232
  get msgCaptionCommandPayload(): string;
233
- get msgPhoto(): _grammyjs_types.PhotoSize[] | undefined;
234
- get msgVideo(): _grammyjs_types.Video | undefined;
235
- get msgAudio(): _grammyjs_types.Audio | undefined;
236
- get msgDocument(): _grammyjs_types.Document | undefined;
237
- get msgAnimation(): _grammyjs_types.Animation | undefined;
238
- get msgVoice(): _grammyjs_types.Voice | undefined;
239
- get msgVideoNote(): _grammyjs_types.VideoNote | undefined;
240
- get msgSticker(): _grammyjs_types.Sticker | undefined;
241
- get msgLocation(): _grammyjs_types.Location | undefined;
242
- get msgContact(): _grammyjs_types.Contact | undefined;
243
- get msgWebAppData(): _grammyjs_types.WebAppData | undefined;
244
- get msgGift(): _grammyjs_types.GiftInfo | undefined;
233
+ get msgPhoto(): grammy_types.PhotoSize[] | undefined;
234
+ get msgVideo(): grammy_types.Video | undefined;
235
+ get msgAudio(): grammy_types.Audio | undefined;
236
+ get msgDocument(): grammy_types.Document | undefined;
237
+ get msgAnimation(): grammy_types.Animation | undefined;
238
+ get msgVoice(): grammy_types.Voice | undefined;
239
+ get msgVideoNote(): grammy_types.VideoNote | undefined;
240
+ get msgSticker(): grammy_types.Sticker | undefined;
241
+ get msgLocation(): grammy_types.Location | undefined;
242
+ get msgContact(): grammy_types.Contact | undefined;
243
+ get msgWebAppData(): grammy_types.WebAppData | undefined;
244
+ get msgGift(): grammy_types.GiftInfo | undefined;
245
245
  get callbackData(): string;
246
246
  get callbackDataPayloads(): string[];
247
247
  get callbackDataPayload(): string;
248
- set session(v: ITemp[`session`]);
249
248
  get session(): ITemp[`session`];
249
+ set session(v: ITemp[`session`]);
250
250
  ct: ICt;
251
251
  cacheSession: CacheExternal<ICacheRpc>;
252
252
  cacheKeyboard: Map<any, any>;
@@ -260,35 +260,35 @@ declare class Ctx {
260
260
  temp: ITemp;
261
261
  });
262
262
  broadcast(ids: number[], languageCode: string[], keyboard?: IInBoKb, data?: IData, baseId?: string, options?: IOptReply, throwError?: boolean): Promise<void>;
263
- reply(keyboard?: IInBoKb, data?: IData, baseId?: string, options?: IOptReply): Promise<_grammyjs_types.Message.TextMessage>;
264
- replyMedia<T extends IMediaBlock[`type`]>(type: T, keyboard?: IInBoKb, data?: IData, baseId?: string, options?: T extends `photo` ? IOptReplyPhoto : T extends `video` ? IOptReplyVideo : T extends `audio` ? IOptReplyAudio : T extends `document` ? IOptReplyDocument : T extends `animation` ? IOptReplyAnimation : T extends `voice` ? IOptReplyVoice : T extends `video_note` ? IOptReplyVideoNote : T extends `sticker` ? IOptReplySticker : T extends `location` ? IOptReplyLocation : T extends `contact` ? IOptReplyContact : undefined): Promise<_grammyjs_types.Message.LocationMessage | _grammyjs_types.Message.ContactMessage | _grammyjs_types.Message.PhotoMessage | _grammyjs_types.Message.VideoMessage | _grammyjs_types.Message.AudioMessage | _grammyjs_types.Message.DocumentMessage | _grammyjs_types.Message.VoiceMessage | _grammyjs_types.Message.VideoNoteMessage | _grammyjs_types.Message.StickerMessage | undefined>;
265
- replyPhoto(keyboard?: IInBoKb, data?: IData, baseId?: string, options?: IOptReplyPhoto): Promise<_grammyjs_types.Message.LocationMessage | _grammyjs_types.Message.ContactMessage | _grammyjs_types.Message.PhotoMessage | _grammyjs_types.Message.VideoMessage | _grammyjs_types.Message.AudioMessage | _grammyjs_types.Message.DocumentMessage | _grammyjs_types.Message.VoiceMessage | _grammyjs_types.Message.VideoNoteMessage | _grammyjs_types.Message.StickerMessage | undefined>;
266
- replyVideo(keyboard?: IInBoKb, data?: IData, baseId?: string, options?: IOptReplyVideo): Promise<_grammyjs_types.Message.LocationMessage | _grammyjs_types.Message.ContactMessage | _grammyjs_types.Message.PhotoMessage | _grammyjs_types.Message.VideoMessage | _grammyjs_types.Message.AudioMessage | _grammyjs_types.Message.DocumentMessage | _grammyjs_types.Message.VoiceMessage | _grammyjs_types.Message.VideoNoteMessage | _grammyjs_types.Message.StickerMessage | undefined>;
267
- replyAudio(keyboard?: IInBoKb, data?: IData, baseId?: string, options?: IOptReplyAudio): Promise<_grammyjs_types.Message.LocationMessage | _grammyjs_types.Message.ContactMessage | _grammyjs_types.Message.PhotoMessage | _grammyjs_types.Message.VideoMessage | _grammyjs_types.Message.AudioMessage | _grammyjs_types.Message.DocumentMessage | _grammyjs_types.Message.VoiceMessage | _grammyjs_types.Message.VideoNoteMessage | _grammyjs_types.Message.StickerMessage | undefined>;
268
- replyDocument(keyboard?: IInBoKb, data?: IData, baseId?: string, options?: IOptReplyDocument): Promise<_grammyjs_types.Message.LocationMessage | _grammyjs_types.Message.ContactMessage | _grammyjs_types.Message.PhotoMessage | _grammyjs_types.Message.VideoMessage | _grammyjs_types.Message.AudioMessage | _grammyjs_types.Message.DocumentMessage | _grammyjs_types.Message.VoiceMessage | _grammyjs_types.Message.VideoNoteMessage | _grammyjs_types.Message.StickerMessage | undefined>;
269
- replyAnimation(keyboard?: IInBoKb, data?: IData, baseId?: string, options?: IOptReplyAnimation): Promise<_grammyjs_types.Message.LocationMessage | _grammyjs_types.Message.ContactMessage | _grammyjs_types.Message.PhotoMessage | _grammyjs_types.Message.VideoMessage | _grammyjs_types.Message.AudioMessage | _grammyjs_types.Message.DocumentMessage | _grammyjs_types.Message.VoiceMessage | _grammyjs_types.Message.VideoNoteMessage | _grammyjs_types.Message.StickerMessage | undefined>;
270
- replyVoice(keyboard?: IInBoKb, data?: IData, baseId?: string, options?: IOptReplyVoice): Promise<_grammyjs_types.Message.LocationMessage | _grammyjs_types.Message.ContactMessage | _grammyjs_types.Message.PhotoMessage | _grammyjs_types.Message.VideoMessage | _grammyjs_types.Message.AudioMessage | _grammyjs_types.Message.DocumentMessage | _grammyjs_types.Message.VoiceMessage | _grammyjs_types.Message.VideoNoteMessage | _grammyjs_types.Message.StickerMessage | undefined>;
271
- replyVideoNote(keyboard?: IInBoKb, data?: IData, baseId?: string, options?: IOptReplyVideoNote): Promise<_grammyjs_types.Message.LocationMessage | _grammyjs_types.Message.ContactMessage | _grammyjs_types.Message.PhotoMessage | _grammyjs_types.Message.VideoMessage | _grammyjs_types.Message.AudioMessage | _grammyjs_types.Message.DocumentMessage | _grammyjs_types.Message.VoiceMessage | _grammyjs_types.Message.VideoNoteMessage | _grammyjs_types.Message.StickerMessage | undefined>;
272
- replySticker(keyboard?: IInBoKb, data?: IData, baseId?: string, options?: IOptReplySticker): Promise<_grammyjs_types.Message.LocationMessage | _grammyjs_types.Message.ContactMessage | _grammyjs_types.Message.PhotoMessage | _grammyjs_types.Message.VideoMessage | _grammyjs_types.Message.AudioMessage | _grammyjs_types.Message.DocumentMessage | _grammyjs_types.Message.VoiceMessage | _grammyjs_types.Message.VideoNoteMessage | _grammyjs_types.Message.StickerMessage | undefined>;
273
- replyLocation(keyboard?: IInBoKb, data?: IData, baseId?: string, options?: IOptReplyLocation): Promise<_grammyjs_types.Message.LocationMessage | _grammyjs_types.Message.ContactMessage | _grammyjs_types.Message.PhotoMessage | _grammyjs_types.Message.VideoMessage | _grammyjs_types.Message.AudioMessage | _grammyjs_types.Message.DocumentMessage | _grammyjs_types.Message.VoiceMessage | _grammyjs_types.Message.VideoNoteMessage | _grammyjs_types.Message.StickerMessage | undefined>;
274
- replyContact(keyboard?: IInBoKb, data?: IData, baseId?: string, options?: IOptReplyContact): Promise<_grammyjs_types.Message.LocationMessage | _grammyjs_types.Message.ContactMessage | _grammyjs_types.Message.PhotoMessage | _grammyjs_types.Message.VideoMessage | _grammyjs_types.Message.AudioMessage | _grammyjs_types.Message.DocumentMessage | _grammyjs_types.Message.VoiceMessage | _grammyjs_types.Message.VideoNoteMessage | _grammyjs_types.Message.StickerMessage | undefined>;
263
+ reply(keyboard?: IInBoKb, data?: IData, baseId?: string, options?: IOptReply): Promise<grammy_types.Message.TextMessage>;
264
+ replyMedia<T extends IMediaBlock[`type`]>(type: T, keyboard?: IInBoKb, data?: IData, baseId?: string, options?: T extends `photo` ? IOptReplyPhoto : T extends `video` ? IOptReplyVideo : T extends `audio` ? IOptReplyAudio : T extends `document` ? IOptReplyDocument : T extends `animation` ? IOptReplyAnimation : T extends `voice` ? IOptReplyVoice : T extends `video_note` ? IOptReplyVideoNote : T extends `sticker` ? IOptReplySticker : T extends `location` ? IOptReplyLocation : T extends `contact` ? IOptReplyContact : undefined): Promise<grammy_types.Message.LocationMessage | grammy_types.Message.ContactMessage | grammy_types.Message.PhotoMessage | grammy_types.Message.VideoMessage | grammy_types.Message.AudioMessage | grammy_types.Message.DocumentMessage | grammy_types.Message.VoiceMessage | grammy_types.Message.VideoNoteMessage | grammy_types.Message.StickerMessage | undefined>;
265
+ replyPhoto(keyboard?: IInBoKb, data?: IData, baseId?: string, options?: IOptReplyPhoto): Promise<grammy_types.Message.LocationMessage | grammy_types.Message.ContactMessage | grammy_types.Message.PhotoMessage | grammy_types.Message.VideoMessage | grammy_types.Message.AudioMessage | grammy_types.Message.DocumentMessage | grammy_types.Message.VoiceMessage | grammy_types.Message.VideoNoteMessage | grammy_types.Message.StickerMessage | undefined>;
266
+ replyVideo(keyboard?: IInBoKb, data?: IData, baseId?: string, options?: IOptReplyVideo): Promise<grammy_types.Message.LocationMessage | grammy_types.Message.ContactMessage | grammy_types.Message.PhotoMessage | grammy_types.Message.VideoMessage | grammy_types.Message.AudioMessage | grammy_types.Message.DocumentMessage | grammy_types.Message.VoiceMessage | grammy_types.Message.VideoNoteMessage | grammy_types.Message.StickerMessage | undefined>;
267
+ replyAudio(keyboard?: IInBoKb, data?: IData, baseId?: string, options?: IOptReplyAudio): Promise<grammy_types.Message.LocationMessage | grammy_types.Message.ContactMessage | grammy_types.Message.PhotoMessage | grammy_types.Message.VideoMessage | grammy_types.Message.AudioMessage | grammy_types.Message.DocumentMessage | grammy_types.Message.VoiceMessage | grammy_types.Message.VideoNoteMessage | grammy_types.Message.StickerMessage | undefined>;
268
+ replyDocument(keyboard?: IInBoKb, data?: IData, baseId?: string, options?: IOptReplyDocument): Promise<grammy_types.Message.LocationMessage | grammy_types.Message.ContactMessage | grammy_types.Message.PhotoMessage | grammy_types.Message.VideoMessage | grammy_types.Message.AudioMessage | grammy_types.Message.DocumentMessage | grammy_types.Message.VoiceMessage | grammy_types.Message.VideoNoteMessage | grammy_types.Message.StickerMessage | undefined>;
269
+ replyAnimation(keyboard?: IInBoKb, data?: IData, baseId?: string, options?: IOptReplyAnimation): Promise<grammy_types.Message.LocationMessage | grammy_types.Message.ContactMessage | grammy_types.Message.PhotoMessage | grammy_types.Message.VideoMessage | grammy_types.Message.AudioMessage | grammy_types.Message.DocumentMessage | grammy_types.Message.VoiceMessage | grammy_types.Message.VideoNoteMessage | grammy_types.Message.StickerMessage | undefined>;
270
+ replyVoice(keyboard?: IInBoKb, data?: IData, baseId?: string, options?: IOptReplyVoice): Promise<grammy_types.Message.LocationMessage | grammy_types.Message.ContactMessage | grammy_types.Message.PhotoMessage | grammy_types.Message.VideoMessage | grammy_types.Message.AudioMessage | grammy_types.Message.DocumentMessage | grammy_types.Message.VoiceMessage | grammy_types.Message.VideoNoteMessage | grammy_types.Message.StickerMessage | undefined>;
271
+ replyVideoNote(keyboard?: IInBoKb, data?: IData, baseId?: string, options?: IOptReplyVideoNote): Promise<grammy_types.Message.LocationMessage | grammy_types.Message.ContactMessage | grammy_types.Message.PhotoMessage | grammy_types.Message.VideoMessage | grammy_types.Message.AudioMessage | grammy_types.Message.DocumentMessage | grammy_types.Message.VoiceMessage | grammy_types.Message.VideoNoteMessage | grammy_types.Message.StickerMessage | undefined>;
272
+ replySticker(keyboard?: IInBoKb, data?: IData, baseId?: string, options?: IOptReplySticker): Promise<grammy_types.Message.LocationMessage | grammy_types.Message.ContactMessage | grammy_types.Message.PhotoMessage | grammy_types.Message.VideoMessage | grammy_types.Message.AudioMessage | grammy_types.Message.DocumentMessage | grammy_types.Message.VoiceMessage | grammy_types.Message.VideoNoteMessage | grammy_types.Message.StickerMessage | undefined>;
273
+ replyLocation(keyboard?: IInBoKb, data?: IData, baseId?: string, options?: IOptReplyLocation): Promise<grammy_types.Message.LocationMessage | grammy_types.Message.ContactMessage | grammy_types.Message.PhotoMessage | grammy_types.Message.VideoMessage | grammy_types.Message.AudioMessage | grammy_types.Message.DocumentMessage | grammy_types.Message.VoiceMessage | grammy_types.Message.VideoNoteMessage | grammy_types.Message.StickerMessage | undefined>;
274
+ replyContact(keyboard?: IInBoKb, data?: IData, baseId?: string, options?: IOptReplyContact): Promise<grammy_types.Message.LocationMessage | grammy_types.Message.ContactMessage | grammy_types.Message.PhotoMessage | grammy_types.Message.VideoMessage | grammy_types.Message.AudioMessage | grammy_types.Message.DocumentMessage | grammy_types.Message.VoiceMessage | grammy_types.Message.VideoNoteMessage | grammy_types.Message.StickerMessage | undefined>;
275
275
  replyAction(type: ITypeReplyAction): Promise<true>;
276
- edit(keyboardInline?: IInlineKb, data?: IData, baseId?: string, options?: IOptEdit, fallbackReply?: boolean): Promise<true | (_grammyjs_types.Update.Edited & _grammyjs_types.Message.CommonMessage & {
276
+ edit(keyboardInline?: IInlineKb, data?: IData, baseId?: string, options?: IOptEdit, fallbackReply?: boolean): Promise<true | (grammy_types.Update.Edited & grammy_types.Message.CommonMessage & {
277
277
  text: string;
278
278
  } & Partial<{
279
- entities: _grammyjs_types.MessageEntity[];
279
+ entities: grammy_types.MessageEntity[];
280
280
  }>) | undefined>;
281
- editMedia<T extends IMediaBlock[`type`]>(type: T, keyboardInline?: IInlineKb, data?: IData, baseId?: string, options1?: T extends `voice` ? IOptReplyVoice : T extends `video_note` ? IOptReplyVideoNote : T extends `sticker` ? IOptReplySticker : T extends `location` ? IOptReplyLocation : T extends `contact` ? IOptReplyContact : IOptEditMedia1, options2?: IOptEditMedia2, fallbackReply?: boolean): Promise<true | _grammyjs_types.Message.LocationMessage | _grammyjs_types.Message.ContactMessage | _grammyjs_types.Message.PhotoMessage | _grammyjs_types.Message.VideoMessage | _grammyjs_types.Message.AudioMessage | _grammyjs_types.Message.DocumentMessage | _grammyjs_types.Message.VoiceMessage | _grammyjs_types.Message.VideoNoteMessage | _grammyjs_types.Message.StickerMessage | (_grammyjs_types.Update.Edited & _grammyjs_types.Message) | undefined>;
282
- editPhoto(keyboardInline?: IInlineKb, data?: IData, baseId?: string, options1?: IOptEditMedia1, options2?: IOptEditMedia2): Promise<true | _grammyjs_types.Message.LocationMessage | _grammyjs_types.Message.ContactMessage | _grammyjs_types.Message.PhotoMessage | _grammyjs_types.Message.VideoMessage | _grammyjs_types.Message.AudioMessage | _grammyjs_types.Message.DocumentMessage | _grammyjs_types.Message.VoiceMessage | _grammyjs_types.Message.VideoNoteMessage | _grammyjs_types.Message.StickerMessage | (_grammyjs_types.Update.Edited & _grammyjs_types.Message) | undefined>;
283
- editVideo(keyboardInline?: IInlineKb, data?: IData, baseId?: string, options1?: IOptEditMedia1, options2?: IOptEditMedia2): Promise<true | _grammyjs_types.Message.LocationMessage | _grammyjs_types.Message.ContactMessage | _grammyjs_types.Message.PhotoMessage | _grammyjs_types.Message.VideoMessage | _grammyjs_types.Message.AudioMessage | _grammyjs_types.Message.DocumentMessage | _grammyjs_types.Message.VoiceMessage | _grammyjs_types.Message.VideoNoteMessage | _grammyjs_types.Message.StickerMessage | (_grammyjs_types.Update.Edited & _grammyjs_types.Message) | undefined>;
284
- editAudio(keyboardInline?: IInlineKb, data?: IData, baseId?: string, options1?: IOptEditMedia1, options2?: IOptEditMedia2): Promise<true | _grammyjs_types.Message.LocationMessage | _grammyjs_types.Message.ContactMessage | _grammyjs_types.Message.PhotoMessage | _grammyjs_types.Message.VideoMessage | _grammyjs_types.Message.AudioMessage | _grammyjs_types.Message.DocumentMessage | _grammyjs_types.Message.VoiceMessage | _grammyjs_types.Message.VideoNoteMessage | _grammyjs_types.Message.StickerMessage | (_grammyjs_types.Update.Edited & _grammyjs_types.Message) | undefined>;
285
- editDocument(keyboardInline?: IInlineKb, data?: IData, baseId?: string, options1?: IOptEditMedia1, options2?: IOptEditMedia2): Promise<true | _grammyjs_types.Message.LocationMessage | _grammyjs_types.Message.ContactMessage | _grammyjs_types.Message.PhotoMessage | _grammyjs_types.Message.VideoMessage | _grammyjs_types.Message.AudioMessage | _grammyjs_types.Message.DocumentMessage | _grammyjs_types.Message.VoiceMessage | _grammyjs_types.Message.VideoNoteMessage | _grammyjs_types.Message.StickerMessage | (_grammyjs_types.Update.Edited & _grammyjs_types.Message) | undefined>;
286
- editAnimation(keyboardInline?: IInlineKb, data?: IData, baseId?: string, options1?: IOptEditMedia1, options2?: IOptEditMedia2): Promise<true | _grammyjs_types.Message.LocationMessage | _grammyjs_types.Message.ContactMessage | _grammyjs_types.Message.PhotoMessage | _grammyjs_types.Message.VideoMessage | _grammyjs_types.Message.AudioMessage | _grammyjs_types.Message.DocumentMessage | _grammyjs_types.Message.VoiceMessage | _grammyjs_types.Message.VideoNoteMessage | _grammyjs_types.Message.StickerMessage | (_grammyjs_types.Update.Edited & _grammyjs_types.Message) | undefined>;
287
- editVoice(keyboardInline?: IInlineKb, data?: IData, baseId?: string, options?: IOptEditMedia2): Promise<true | _grammyjs_types.Message.LocationMessage | _grammyjs_types.Message.ContactMessage | _grammyjs_types.Message.PhotoMessage | _grammyjs_types.Message.VideoMessage | _grammyjs_types.Message.AudioMessage | _grammyjs_types.Message.DocumentMessage | _grammyjs_types.Message.VoiceMessage | _grammyjs_types.Message.VideoNoteMessage | _grammyjs_types.Message.StickerMessage | (_grammyjs_types.Update.Edited & _grammyjs_types.Message) | undefined>;
288
- editVideoNote(keyboardInline?: IInlineKb, data?: IData, baseId?: string, options?: IOptEditMedia2): Promise<true | _grammyjs_types.Message.LocationMessage | _grammyjs_types.Message.ContactMessage | _grammyjs_types.Message.PhotoMessage | _grammyjs_types.Message.VideoMessage | _grammyjs_types.Message.AudioMessage | _grammyjs_types.Message.DocumentMessage | _grammyjs_types.Message.VoiceMessage | _grammyjs_types.Message.VideoNoteMessage | _grammyjs_types.Message.StickerMessage | (_grammyjs_types.Update.Edited & _grammyjs_types.Message) | undefined>;
289
- editSticker(keyboardInline?: IInlineKb, data?: IData, baseId?: string, options?: IOptEditMedia2): Promise<true | _grammyjs_types.Message.LocationMessage | _grammyjs_types.Message.ContactMessage | _grammyjs_types.Message.PhotoMessage | _grammyjs_types.Message.VideoMessage | _grammyjs_types.Message.AudioMessage | _grammyjs_types.Message.DocumentMessage | _grammyjs_types.Message.VoiceMessage | _grammyjs_types.Message.VideoNoteMessage | _grammyjs_types.Message.StickerMessage | (_grammyjs_types.Update.Edited & _grammyjs_types.Message) | undefined>;
290
- editLocation(keyboardInline?: IInlineKb, data?: IData, baseId?: string, options?: IOptEditMedia2): Promise<true | _grammyjs_types.Message.LocationMessage | _grammyjs_types.Message.ContactMessage | _grammyjs_types.Message.PhotoMessage | _grammyjs_types.Message.VideoMessage | _grammyjs_types.Message.AudioMessage | _grammyjs_types.Message.DocumentMessage | _grammyjs_types.Message.VoiceMessage | _grammyjs_types.Message.VideoNoteMessage | _grammyjs_types.Message.StickerMessage | (_grammyjs_types.Update.Edited & _grammyjs_types.Message) | undefined>;
291
- editContact(keyboardInline?: IInlineKb, data?: IData, baseId?: string, options?: IOptEditMedia2): Promise<true | _grammyjs_types.Message.LocationMessage | _grammyjs_types.Message.ContactMessage | _grammyjs_types.Message.PhotoMessage | _grammyjs_types.Message.VideoMessage | _grammyjs_types.Message.AudioMessage | _grammyjs_types.Message.DocumentMessage | _grammyjs_types.Message.VoiceMessage | _grammyjs_types.Message.VideoNoteMessage | _grammyjs_types.Message.StickerMessage | (_grammyjs_types.Update.Edited & _grammyjs_types.Message) | undefined>;
281
+ editMedia<T extends IMediaBlock[`type`]>(type: T, keyboardInline?: IInlineKb, data?: IData, baseId?: string, options1?: T extends `voice` ? IOptReplyVoice : T extends `video_note` ? IOptReplyVideoNote : T extends `sticker` ? IOptReplySticker : T extends `location` ? IOptReplyLocation : T extends `contact` ? IOptReplyContact : IOptEditMedia1, options2?: IOptEditMedia2, fallbackReply?: boolean): Promise<true | grammy_types.Message.LocationMessage | grammy_types.Message.ContactMessage | grammy_types.Message.PhotoMessage | grammy_types.Message.VideoMessage | grammy_types.Message.AudioMessage | grammy_types.Message.DocumentMessage | grammy_types.Message.VoiceMessage | grammy_types.Message.VideoNoteMessage | grammy_types.Message.StickerMessage | (grammy_types.Update.Edited & grammy_types.Message) | undefined>;
282
+ editPhoto(keyboardInline?: IInlineKb, data?: IData, baseId?: string, options1?: IOptEditMedia1, options2?: IOptEditMedia2): Promise<true | grammy_types.Message.LocationMessage | grammy_types.Message.ContactMessage | grammy_types.Message.PhotoMessage | grammy_types.Message.VideoMessage | grammy_types.Message.AudioMessage | grammy_types.Message.DocumentMessage | grammy_types.Message.VoiceMessage | grammy_types.Message.VideoNoteMessage | grammy_types.Message.StickerMessage | (grammy_types.Update.Edited & grammy_types.Message) | undefined>;
283
+ editVideo(keyboardInline?: IInlineKb, data?: IData, baseId?: string, options1?: IOptEditMedia1, options2?: IOptEditMedia2): Promise<true | grammy_types.Message.LocationMessage | grammy_types.Message.ContactMessage | grammy_types.Message.PhotoMessage | grammy_types.Message.VideoMessage | grammy_types.Message.AudioMessage | grammy_types.Message.DocumentMessage | grammy_types.Message.VoiceMessage | grammy_types.Message.VideoNoteMessage | grammy_types.Message.StickerMessage | (grammy_types.Update.Edited & grammy_types.Message) | undefined>;
284
+ editAudio(keyboardInline?: IInlineKb, data?: IData, baseId?: string, options1?: IOptEditMedia1, options2?: IOptEditMedia2): Promise<true | grammy_types.Message.LocationMessage | grammy_types.Message.ContactMessage | grammy_types.Message.PhotoMessage | grammy_types.Message.VideoMessage | grammy_types.Message.AudioMessage | grammy_types.Message.DocumentMessage | grammy_types.Message.VoiceMessage | grammy_types.Message.VideoNoteMessage | grammy_types.Message.StickerMessage | (grammy_types.Update.Edited & grammy_types.Message) | undefined>;
285
+ editDocument(keyboardInline?: IInlineKb, data?: IData, baseId?: string, options1?: IOptEditMedia1, options2?: IOptEditMedia2): Promise<true | grammy_types.Message.LocationMessage | grammy_types.Message.ContactMessage | grammy_types.Message.PhotoMessage | grammy_types.Message.VideoMessage | grammy_types.Message.AudioMessage | grammy_types.Message.DocumentMessage | grammy_types.Message.VoiceMessage | grammy_types.Message.VideoNoteMessage | grammy_types.Message.StickerMessage | (grammy_types.Update.Edited & grammy_types.Message) | undefined>;
286
+ editAnimation(keyboardInline?: IInlineKb, data?: IData, baseId?: string, options1?: IOptEditMedia1, options2?: IOptEditMedia2): Promise<true | grammy_types.Message.LocationMessage | grammy_types.Message.ContactMessage | grammy_types.Message.PhotoMessage | grammy_types.Message.VideoMessage | grammy_types.Message.AudioMessage | grammy_types.Message.DocumentMessage | grammy_types.Message.VoiceMessage | grammy_types.Message.VideoNoteMessage | grammy_types.Message.StickerMessage | (grammy_types.Update.Edited & grammy_types.Message) | undefined>;
287
+ editVoice(keyboardInline?: IInlineKb, data?: IData, baseId?: string, options?: IOptEditMedia2): Promise<true | grammy_types.Message.LocationMessage | grammy_types.Message.ContactMessage | grammy_types.Message.PhotoMessage | grammy_types.Message.VideoMessage | grammy_types.Message.AudioMessage | grammy_types.Message.DocumentMessage | grammy_types.Message.VoiceMessage | grammy_types.Message.VideoNoteMessage | grammy_types.Message.StickerMessage | (grammy_types.Update.Edited & grammy_types.Message) | undefined>;
288
+ editVideoNote(keyboardInline?: IInlineKb, data?: IData, baseId?: string, options?: IOptEditMedia2): Promise<true | grammy_types.Message.LocationMessage | grammy_types.Message.ContactMessage | grammy_types.Message.PhotoMessage | grammy_types.Message.VideoMessage | grammy_types.Message.AudioMessage | grammy_types.Message.DocumentMessage | grammy_types.Message.VoiceMessage | grammy_types.Message.VideoNoteMessage | grammy_types.Message.StickerMessage | (grammy_types.Update.Edited & grammy_types.Message) | undefined>;
289
+ editSticker(keyboardInline?: IInlineKb, data?: IData, baseId?: string, options?: IOptEditMedia2): Promise<true | grammy_types.Message.LocationMessage | grammy_types.Message.ContactMessage | grammy_types.Message.PhotoMessage | grammy_types.Message.VideoMessage | grammy_types.Message.AudioMessage | grammy_types.Message.DocumentMessage | grammy_types.Message.VoiceMessage | grammy_types.Message.VideoNoteMessage | grammy_types.Message.StickerMessage | (grammy_types.Update.Edited & grammy_types.Message) | undefined>;
290
+ editLocation(keyboardInline?: IInlineKb, data?: IData, baseId?: string, options?: IOptEditMedia2): Promise<true | grammy_types.Message.LocationMessage | grammy_types.Message.ContactMessage | grammy_types.Message.PhotoMessage | grammy_types.Message.VideoMessage | grammy_types.Message.AudioMessage | grammy_types.Message.DocumentMessage | grammy_types.Message.VoiceMessage | grammy_types.Message.VideoNoteMessage | grammy_types.Message.StickerMessage | (grammy_types.Update.Edited & grammy_types.Message) | undefined>;
291
+ editContact(keyboardInline?: IInlineKb, data?: IData, baseId?: string, options?: IOptEditMedia2): Promise<true | grammy_types.Message.LocationMessage | grammy_types.Message.ContactMessage | grammy_types.Message.PhotoMessage | grammy_types.Message.VideoMessage | grammy_types.Message.AudioMessage | grammy_types.Message.DocumentMessage | grammy_types.Message.VoiceMessage | grammy_types.Message.VideoNoteMessage | grammy_types.Message.StickerMessage | (grammy_types.Update.Edited & grammy_types.Message) | undefined>;
292
292
  delete(): Promise<true>;
293
293
  callbackQueryAnswer(options?: Parameters<typeof Ctx.prototype.ct.answerCallbackQuery>[0]): Promise<true | null>;
294
294
  sessionSet(method: string, params: any, moreRoot?: Record<any, any>): Promise<boolean | null>;
@@ -1013,7 +1013,7 @@ declare class WorkerThreadInit {
1013
1013
  id: number;
1014
1014
  pid: number;
1015
1015
  rpc: WorkerThreadRpc;
1016
- parentPort: worker_threads.MessagePort | null;
1016
+ parentPort: node_worker_threads.MessagePort | null;
1017
1017
  gatewayServer?: WorkerThreadGatewayServer;
1018
1018
  gatewayClients: Map<string, WorkerThreadGatewayClient>;
1019
1019
  gatewayClientLatest?: WorkerThreadGatewayClient;
@@ -2,11 +2,11 @@ import { LoggingPretty } from 'logging-pretty';
2
2
  import { Keyv } from 'keyv';
3
3
  import * as grammy from 'grammy';
4
4
  import { Context, Keyboard, InlineKeyboard, Bot, BotError } from 'grammy';
5
- import * as _grammyjs_types from '@grammyjs/types';
6
- import { FSWatcher } from 'chokidar';
5
+ import * as grammy_types from 'grammy/types';
7
6
  import { UserFromGetMe } from 'grammy/types';
7
+ import { FSWatcher } from 'chokidar';
8
+ import * as node_worker_threads from 'node:worker_threads';
8
9
  import { Worker } from 'node:worker_threads';
9
- import * as worker_threads from 'worker_threads';
10
10
  import { Server, Client } from 'net-ipc';
11
11
 
12
12
  declare class LoggingUtil extends LoggingPretty {
@@ -230,23 +230,23 @@ declare class Ctx {
230
230
  get msgCaptionPayload(): string;
231
231
  get msgCaptionCommandPayloads(): string[];
232
232
  get msgCaptionCommandPayload(): string;
233
- get msgPhoto(): _grammyjs_types.PhotoSize[] | undefined;
234
- get msgVideo(): _grammyjs_types.Video | undefined;
235
- get msgAudio(): _grammyjs_types.Audio | undefined;
236
- get msgDocument(): _grammyjs_types.Document | undefined;
237
- get msgAnimation(): _grammyjs_types.Animation | undefined;
238
- get msgVoice(): _grammyjs_types.Voice | undefined;
239
- get msgVideoNote(): _grammyjs_types.VideoNote | undefined;
240
- get msgSticker(): _grammyjs_types.Sticker | undefined;
241
- get msgLocation(): _grammyjs_types.Location | undefined;
242
- get msgContact(): _grammyjs_types.Contact | undefined;
243
- get msgWebAppData(): _grammyjs_types.WebAppData | undefined;
244
- get msgGift(): _grammyjs_types.GiftInfo | undefined;
233
+ get msgPhoto(): grammy_types.PhotoSize[] | undefined;
234
+ get msgVideo(): grammy_types.Video | undefined;
235
+ get msgAudio(): grammy_types.Audio | undefined;
236
+ get msgDocument(): grammy_types.Document | undefined;
237
+ get msgAnimation(): grammy_types.Animation | undefined;
238
+ get msgVoice(): grammy_types.Voice | undefined;
239
+ get msgVideoNote(): grammy_types.VideoNote | undefined;
240
+ get msgSticker(): grammy_types.Sticker | undefined;
241
+ get msgLocation(): grammy_types.Location | undefined;
242
+ get msgContact(): grammy_types.Contact | undefined;
243
+ get msgWebAppData(): grammy_types.WebAppData | undefined;
244
+ get msgGift(): grammy_types.GiftInfo | undefined;
245
245
  get callbackData(): string;
246
246
  get callbackDataPayloads(): string[];
247
247
  get callbackDataPayload(): string;
248
- set session(v: ITemp[`session`]);
249
248
  get session(): ITemp[`session`];
249
+ set session(v: ITemp[`session`]);
250
250
  ct: ICt;
251
251
  cacheSession: CacheExternal<ICacheRpc>;
252
252
  cacheKeyboard: Map<any, any>;
@@ -260,35 +260,35 @@ declare class Ctx {
260
260
  temp: ITemp;
261
261
  });
262
262
  broadcast(ids: number[], languageCode: string[], keyboard?: IInBoKb, data?: IData, baseId?: string, options?: IOptReply, throwError?: boolean): Promise<void>;
263
- reply(keyboard?: IInBoKb, data?: IData, baseId?: string, options?: IOptReply): Promise<_grammyjs_types.Message.TextMessage>;
264
- replyMedia<T extends IMediaBlock[`type`]>(type: T, keyboard?: IInBoKb, data?: IData, baseId?: string, options?: T extends `photo` ? IOptReplyPhoto : T extends `video` ? IOptReplyVideo : T extends `audio` ? IOptReplyAudio : T extends `document` ? IOptReplyDocument : T extends `animation` ? IOptReplyAnimation : T extends `voice` ? IOptReplyVoice : T extends `video_note` ? IOptReplyVideoNote : T extends `sticker` ? IOptReplySticker : T extends `location` ? IOptReplyLocation : T extends `contact` ? IOptReplyContact : undefined): Promise<_grammyjs_types.Message.LocationMessage | _grammyjs_types.Message.ContactMessage | _grammyjs_types.Message.PhotoMessage | _grammyjs_types.Message.VideoMessage | _grammyjs_types.Message.AudioMessage | _grammyjs_types.Message.DocumentMessage | _grammyjs_types.Message.VoiceMessage | _grammyjs_types.Message.VideoNoteMessage | _grammyjs_types.Message.StickerMessage | undefined>;
265
- replyPhoto(keyboard?: IInBoKb, data?: IData, baseId?: string, options?: IOptReplyPhoto): Promise<_grammyjs_types.Message.LocationMessage | _grammyjs_types.Message.ContactMessage | _grammyjs_types.Message.PhotoMessage | _grammyjs_types.Message.VideoMessage | _grammyjs_types.Message.AudioMessage | _grammyjs_types.Message.DocumentMessage | _grammyjs_types.Message.VoiceMessage | _grammyjs_types.Message.VideoNoteMessage | _grammyjs_types.Message.StickerMessage | undefined>;
266
- replyVideo(keyboard?: IInBoKb, data?: IData, baseId?: string, options?: IOptReplyVideo): Promise<_grammyjs_types.Message.LocationMessage | _grammyjs_types.Message.ContactMessage | _grammyjs_types.Message.PhotoMessage | _grammyjs_types.Message.VideoMessage | _grammyjs_types.Message.AudioMessage | _grammyjs_types.Message.DocumentMessage | _grammyjs_types.Message.VoiceMessage | _grammyjs_types.Message.VideoNoteMessage | _grammyjs_types.Message.StickerMessage | undefined>;
267
- replyAudio(keyboard?: IInBoKb, data?: IData, baseId?: string, options?: IOptReplyAudio): Promise<_grammyjs_types.Message.LocationMessage | _grammyjs_types.Message.ContactMessage | _grammyjs_types.Message.PhotoMessage | _grammyjs_types.Message.VideoMessage | _grammyjs_types.Message.AudioMessage | _grammyjs_types.Message.DocumentMessage | _grammyjs_types.Message.VoiceMessage | _grammyjs_types.Message.VideoNoteMessage | _grammyjs_types.Message.StickerMessage | undefined>;
268
- replyDocument(keyboard?: IInBoKb, data?: IData, baseId?: string, options?: IOptReplyDocument): Promise<_grammyjs_types.Message.LocationMessage | _grammyjs_types.Message.ContactMessage | _grammyjs_types.Message.PhotoMessage | _grammyjs_types.Message.VideoMessage | _grammyjs_types.Message.AudioMessage | _grammyjs_types.Message.DocumentMessage | _grammyjs_types.Message.VoiceMessage | _grammyjs_types.Message.VideoNoteMessage | _grammyjs_types.Message.StickerMessage | undefined>;
269
- replyAnimation(keyboard?: IInBoKb, data?: IData, baseId?: string, options?: IOptReplyAnimation): Promise<_grammyjs_types.Message.LocationMessage | _grammyjs_types.Message.ContactMessage | _grammyjs_types.Message.PhotoMessage | _grammyjs_types.Message.VideoMessage | _grammyjs_types.Message.AudioMessage | _grammyjs_types.Message.DocumentMessage | _grammyjs_types.Message.VoiceMessage | _grammyjs_types.Message.VideoNoteMessage | _grammyjs_types.Message.StickerMessage | undefined>;
270
- replyVoice(keyboard?: IInBoKb, data?: IData, baseId?: string, options?: IOptReplyVoice): Promise<_grammyjs_types.Message.LocationMessage | _grammyjs_types.Message.ContactMessage | _grammyjs_types.Message.PhotoMessage | _grammyjs_types.Message.VideoMessage | _grammyjs_types.Message.AudioMessage | _grammyjs_types.Message.DocumentMessage | _grammyjs_types.Message.VoiceMessage | _grammyjs_types.Message.VideoNoteMessage | _grammyjs_types.Message.StickerMessage | undefined>;
271
- replyVideoNote(keyboard?: IInBoKb, data?: IData, baseId?: string, options?: IOptReplyVideoNote): Promise<_grammyjs_types.Message.LocationMessage | _grammyjs_types.Message.ContactMessage | _grammyjs_types.Message.PhotoMessage | _grammyjs_types.Message.VideoMessage | _grammyjs_types.Message.AudioMessage | _grammyjs_types.Message.DocumentMessage | _grammyjs_types.Message.VoiceMessage | _grammyjs_types.Message.VideoNoteMessage | _grammyjs_types.Message.StickerMessage | undefined>;
272
- replySticker(keyboard?: IInBoKb, data?: IData, baseId?: string, options?: IOptReplySticker): Promise<_grammyjs_types.Message.LocationMessage | _grammyjs_types.Message.ContactMessage | _grammyjs_types.Message.PhotoMessage | _grammyjs_types.Message.VideoMessage | _grammyjs_types.Message.AudioMessage | _grammyjs_types.Message.DocumentMessage | _grammyjs_types.Message.VoiceMessage | _grammyjs_types.Message.VideoNoteMessage | _grammyjs_types.Message.StickerMessage | undefined>;
273
- replyLocation(keyboard?: IInBoKb, data?: IData, baseId?: string, options?: IOptReplyLocation): Promise<_grammyjs_types.Message.LocationMessage | _grammyjs_types.Message.ContactMessage | _grammyjs_types.Message.PhotoMessage | _grammyjs_types.Message.VideoMessage | _grammyjs_types.Message.AudioMessage | _grammyjs_types.Message.DocumentMessage | _grammyjs_types.Message.VoiceMessage | _grammyjs_types.Message.VideoNoteMessage | _grammyjs_types.Message.StickerMessage | undefined>;
274
- replyContact(keyboard?: IInBoKb, data?: IData, baseId?: string, options?: IOptReplyContact): Promise<_grammyjs_types.Message.LocationMessage | _grammyjs_types.Message.ContactMessage | _grammyjs_types.Message.PhotoMessage | _grammyjs_types.Message.VideoMessage | _grammyjs_types.Message.AudioMessage | _grammyjs_types.Message.DocumentMessage | _grammyjs_types.Message.VoiceMessage | _grammyjs_types.Message.VideoNoteMessage | _grammyjs_types.Message.StickerMessage | undefined>;
263
+ reply(keyboard?: IInBoKb, data?: IData, baseId?: string, options?: IOptReply): Promise<grammy_types.Message.TextMessage>;
264
+ replyMedia<T extends IMediaBlock[`type`]>(type: T, keyboard?: IInBoKb, data?: IData, baseId?: string, options?: T extends `photo` ? IOptReplyPhoto : T extends `video` ? IOptReplyVideo : T extends `audio` ? IOptReplyAudio : T extends `document` ? IOptReplyDocument : T extends `animation` ? IOptReplyAnimation : T extends `voice` ? IOptReplyVoice : T extends `video_note` ? IOptReplyVideoNote : T extends `sticker` ? IOptReplySticker : T extends `location` ? IOptReplyLocation : T extends `contact` ? IOptReplyContact : undefined): Promise<grammy_types.Message.LocationMessage | grammy_types.Message.ContactMessage | grammy_types.Message.PhotoMessage | grammy_types.Message.VideoMessage | grammy_types.Message.AudioMessage | grammy_types.Message.DocumentMessage | grammy_types.Message.VoiceMessage | grammy_types.Message.VideoNoteMessage | grammy_types.Message.StickerMessage | undefined>;
265
+ replyPhoto(keyboard?: IInBoKb, data?: IData, baseId?: string, options?: IOptReplyPhoto): Promise<grammy_types.Message.LocationMessage | grammy_types.Message.ContactMessage | grammy_types.Message.PhotoMessage | grammy_types.Message.VideoMessage | grammy_types.Message.AudioMessage | grammy_types.Message.DocumentMessage | grammy_types.Message.VoiceMessage | grammy_types.Message.VideoNoteMessage | grammy_types.Message.StickerMessage | undefined>;
266
+ replyVideo(keyboard?: IInBoKb, data?: IData, baseId?: string, options?: IOptReplyVideo): Promise<grammy_types.Message.LocationMessage | grammy_types.Message.ContactMessage | grammy_types.Message.PhotoMessage | grammy_types.Message.VideoMessage | grammy_types.Message.AudioMessage | grammy_types.Message.DocumentMessage | grammy_types.Message.VoiceMessage | grammy_types.Message.VideoNoteMessage | grammy_types.Message.StickerMessage | undefined>;
267
+ replyAudio(keyboard?: IInBoKb, data?: IData, baseId?: string, options?: IOptReplyAudio): Promise<grammy_types.Message.LocationMessage | grammy_types.Message.ContactMessage | grammy_types.Message.PhotoMessage | grammy_types.Message.VideoMessage | grammy_types.Message.AudioMessage | grammy_types.Message.DocumentMessage | grammy_types.Message.VoiceMessage | grammy_types.Message.VideoNoteMessage | grammy_types.Message.StickerMessage | undefined>;
268
+ replyDocument(keyboard?: IInBoKb, data?: IData, baseId?: string, options?: IOptReplyDocument): Promise<grammy_types.Message.LocationMessage | grammy_types.Message.ContactMessage | grammy_types.Message.PhotoMessage | grammy_types.Message.VideoMessage | grammy_types.Message.AudioMessage | grammy_types.Message.DocumentMessage | grammy_types.Message.VoiceMessage | grammy_types.Message.VideoNoteMessage | grammy_types.Message.StickerMessage | undefined>;
269
+ replyAnimation(keyboard?: IInBoKb, data?: IData, baseId?: string, options?: IOptReplyAnimation): Promise<grammy_types.Message.LocationMessage | grammy_types.Message.ContactMessage | grammy_types.Message.PhotoMessage | grammy_types.Message.VideoMessage | grammy_types.Message.AudioMessage | grammy_types.Message.DocumentMessage | grammy_types.Message.VoiceMessage | grammy_types.Message.VideoNoteMessage | grammy_types.Message.StickerMessage | undefined>;
270
+ replyVoice(keyboard?: IInBoKb, data?: IData, baseId?: string, options?: IOptReplyVoice): Promise<grammy_types.Message.LocationMessage | grammy_types.Message.ContactMessage | grammy_types.Message.PhotoMessage | grammy_types.Message.VideoMessage | grammy_types.Message.AudioMessage | grammy_types.Message.DocumentMessage | grammy_types.Message.VoiceMessage | grammy_types.Message.VideoNoteMessage | grammy_types.Message.StickerMessage | undefined>;
271
+ replyVideoNote(keyboard?: IInBoKb, data?: IData, baseId?: string, options?: IOptReplyVideoNote): Promise<grammy_types.Message.LocationMessage | grammy_types.Message.ContactMessage | grammy_types.Message.PhotoMessage | grammy_types.Message.VideoMessage | grammy_types.Message.AudioMessage | grammy_types.Message.DocumentMessage | grammy_types.Message.VoiceMessage | grammy_types.Message.VideoNoteMessage | grammy_types.Message.StickerMessage | undefined>;
272
+ replySticker(keyboard?: IInBoKb, data?: IData, baseId?: string, options?: IOptReplySticker): Promise<grammy_types.Message.LocationMessage | grammy_types.Message.ContactMessage | grammy_types.Message.PhotoMessage | grammy_types.Message.VideoMessage | grammy_types.Message.AudioMessage | grammy_types.Message.DocumentMessage | grammy_types.Message.VoiceMessage | grammy_types.Message.VideoNoteMessage | grammy_types.Message.StickerMessage | undefined>;
273
+ replyLocation(keyboard?: IInBoKb, data?: IData, baseId?: string, options?: IOptReplyLocation): Promise<grammy_types.Message.LocationMessage | grammy_types.Message.ContactMessage | grammy_types.Message.PhotoMessage | grammy_types.Message.VideoMessage | grammy_types.Message.AudioMessage | grammy_types.Message.DocumentMessage | grammy_types.Message.VoiceMessage | grammy_types.Message.VideoNoteMessage | grammy_types.Message.StickerMessage | undefined>;
274
+ replyContact(keyboard?: IInBoKb, data?: IData, baseId?: string, options?: IOptReplyContact): Promise<grammy_types.Message.LocationMessage | grammy_types.Message.ContactMessage | grammy_types.Message.PhotoMessage | grammy_types.Message.VideoMessage | grammy_types.Message.AudioMessage | grammy_types.Message.DocumentMessage | grammy_types.Message.VoiceMessage | grammy_types.Message.VideoNoteMessage | grammy_types.Message.StickerMessage | undefined>;
275
275
  replyAction(type: ITypeReplyAction): Promise<true>;
276
- edit(keyboardInline?: IInlineKb, data?: IData, baseId?: string, options?: IOptEdit, fallbackReply?: boolean): Promise<true | (_grammyjs_types.Update.Edited & _grammyjs_types.Message.CommonMessage & {
276
+ edit(keyboardInline?: IInlineKb, data?: IData, baseId?: string, options?: IOptEdit, fallbackReply?: boolean): Promise<true | (grammy_types.Update.Edited & grammy_types.Message.CommonMessage & {
277
277
  text: string;
278
278
  } & Partial<{
279
- entities: _grammyjs_types.MessageEntity[];
279
+ entities: grammy_types.MessageEntity[];
280
280
  }>) | undefined>;
281
- editMedia<T extends IMediaBlock[`type`]>(type: T, keyboardInline?: IInlineKb, data?: IData, baseId?: string, options1?: T extends `voice` ? IOptReplyVoice : T extends `video_note` ? IOptReplyVideoNote : T extends `sticker` ? IOptReplySticker : T extends `location` ? IOptReplyLocation : T extends `contact` ? IOptReplyContact : IOptEditMedia1, options2?: IOptEditMedia2, fallbackReply?: boolean): Promise<true | _grammyjs_types.Message.LocationMessage | _grammyjs_types.Message.ContactMessage | _grammyjs_types.Message.PhotoMessage | _grammyjs_types.Message.VideoMessage | _grammyjs_types.Message.AudioMessage | _grammyjs_types.Message.DocumentMessage | _grammyjs_types.Message.VoiceMessage | _grammyjs_types.Message.VideoNoteMessage | _grammyjs_types.Message.StickerMessage | (_grammyjs_types.Update.Edited & _grammyjs_types.Message) | undefined>;
282
- editPhoto(keyboardInline?: IInlineKb, data?: IData, baseId?: string, options1?: IOptEditMedia1, options2?: IOptEditMedia2): Promise<true | _grammyjs_types.Message.LocationMessage | _grammyjs_types.Message.ContactMessage | _grammyjs_types.Message.PhotoMessage | _grammyjs_types.Message.VideoMessage | _grammyjs_types.Message.AudioMessage | _grammyjs_types.Message.DocumentMessage | _grammyjs_types.Message.VoiceMessage | _grammyjs_types.Message.VideoNoteMessage | _grammyjs_types.Message.StickerMessage | (_grammyjs_types.Update.Edited & _grammyjs_types.Message) | undefined>;
283
- editVideo(keyboardInline?: IInlineKb, data?: IData, baseId?: string, options1?: IOptEditMedia1, options2?: IOptEditMedia2): Promise<true | _grammyjs_types.Message.LocationMessage | _grammyjs_types.Message.ContactMessage | _grammyjs_types.Message.PhotoMessage | _grammyjs_types.Message.VideoMessage | _grammyjs_types.Message.AudioMessage | _grammyjs_types.Message.DocumentMessage | _grammyjs_types.Message.VoiceMessage | _grammyjs_types.Message.VideoNoteMessage | _grammyjs_types.Message.StickerMessage | (_grammyjs_types.Update.Edited & _grammyjs_types.Message) | undefined>;
284
- editAudio(keyboardInline?: IInlineKb, data?: IData, baseId?: string, options1?: IOptEditMedia1, options2?: IOptEditMedia2): Promise<true | _grammyjs_types.Message.LocationMessage | _grammyjs_types.Message.ContactMessage | _grammyjs_types.Message.PhotoMessage | _grammyjs_types.Message.VideoMessage | _grammyjs_types.Message.AudioMessage | _grammyjs_types.Message.DocumentMessage | _grammyjs_types.Message.VoiceMessage | _grammyjs_types.Message.VideoNoteMessage | _grammyjs_types.Message.StickerMessage | (_grammyjs_types.Update.Edited & _grammyjs_types.Message) | undefined>;
285
- editDocument(keyboardInline?: IInlineKb, data?: IData, baseId?: string, options1?: IOptEditMedia1, options2?: IOptEditMedia2): Promise<true | _grammyjs_types.Message.LocationMessage | _grammyjs_types.Message.ContactMessage | _grammyjs_types.Message.PhotoMessage | _grammyjs_types.Message.VideoMessage | _grammyjs_types.Message.AudioMessage | _grammyjs_types.Message.DocumentMessage | _grammyjs_types.Message.VoiceMessage | _grammyjs_types.Message.VideoNoteMessage | _grammyjs_types.Message.StickerMessage | (_grammyjs_types.Update.Edited & _grammyjs_types.Message) | undefined>;
286
- editAnimation(keyboardInline?: IInlineKb, data?: IData, baseId?: string, options1?: IOptEditMedia1, options2?: IOptEditMedia2): Promise<true | _grammyjs_types.Message.LocationMessage | _grammyjs_types.Message.ContactMessage | _grammyjs_types.Message.PhotoMessage | _grammyjs_types.Message.VideoMessage | _grammyjs_types.Message.AudioMessage | _grammyjs_types.Message.DocumentMessage | _grammyjs_types.Message.VoiceMessage | _grammyjs_types.Message.VideoNoteMessage | _grammyjs_types.Message.StickerMessage | (_grammyjs_types.Update.Edited & _grammyjs_types.Message) | undefined>;
287
- editVoice(keyboardInline?: IInlineKb, data?: IData, baseId?: string, options?: IOptEditMedia2): Promise<true | _grammyjs_types.Message.LocationMessage | _grammyjs_types.Message.ContactMessage | _grammyjs_types.Message.PhotoMessage | _grammyjs_types.Message.VideoMessage | _grammyjs_types.Message.AudioMessage | _grammyjs_types.Message.DocumentMessage | _grammyjs_types.Message.VoiceMessage | _grammyjs_types.Message.VideoNoteMessage | _grammyjs_types.Message.StickerMessage | (_grammyjs_types.Update.Edited & _grammyjs_types.Message) | undefined>;
288
- editVideoNote(keyboardInline?: IInlineKb, data?: IData, baseId?: string, options?: IOptEditMedia2): Promise<true | _grammyjs_types.Message.LocationMessage | _grammyjs_types.Message.ContactMessage | _grammyjs_types.Message.PhotoMessage | _grammyjs_types.Message.VideoMessage | _grammyjs_types.Message.AudioMessage | _grammyjs_types.Message.DocumentMessage | _grammyjs_types.Message.VoiceMessage | _grammyjs_types.Message.VideoNoteMessage | _grammyjs_types.Message.StickerMessage | (_grammyjs_types.Update.Edited & _grammyjs_types.Message) | undefined>;
289
- editSticker(keyboardInline?: IInlineKb, data?: IData, baseId?: string, options?: IOptEditMedia2): Promise<true | _grammyjs_types.Message.LocationMessage | _grammyjs_types.Message.ContactMessage | _grammyjs_types.Message.PhotoMessage | _grammyjs_types.Message.VideoMessage | _grammyjs_types.Message.AudioMessage | _grammyjs_types.Message.DocumentMessage | _grammyjs_types.Message.VoiceMessage | _grammyjs_types.Message.VideoNoteMessage | _grammyjs_types.Message.StickerMessage | (_grammyjs_types.Update.Edited & _grammyjs_types.Message) | undefined>;
290
- editLocation(keyboardInline?: IInlineKb, data?: IData, baseId?: string, options?: IOptEditMedia2): Promise<true | _grammyjs_types.Message.LocationMessage | _grammyjs_types.Message.ContactMessage | _grammyjs_types.Message.PhotoMessage | _grammyjs_types.Message.VideoMessage | _grammyjs_types.Message.AudioMessage | _grammyjs_types.Message.DocumentMessage | _grammyjs_types.Message.VoiceMessage | _grammyjs_types.Message.VideoNoteMessage | _grammyjs_types.Message.StickerMessage | (_grammyjs_types.Update.Edited & _grammyjs_types.Message) | undefined>;
291
- editContact(keyboardInline?: IInlineKb, data?: IData, baseId?: string, options?: IOptEditMedia2): Promise<true | _grammyjs_types.Message.LocationMessage | _grammyjs_types.Message.ContactMessage | _grammyjs_types.Message.PhotoMessage | _grammyjs_types.Message.VideoMessage | _grammyjs_types.Message.AudioMessage | _grammyjs_types.Message.DocumentMessage | _grammyjs_types.Message.VoiceMessage | _grammyjs_types.Message.VideoNoteMessage | _grammyjs_types.Message.StickerMessage | (_grammyjs_types.Update.Edited & _grammyjs_types.Message) | undefined>;
281
+ editMedia<T extends IMediaBlock[`type`]>(type: T, keyboardInline?: IInlineKb, data?: IData, baseId?: string, options1?: T extends `voice` ? IOptReplyVoice : T extends `video_note` ? IOptReplyVideoNote : T extends `sticker` ? IOptReplySticker : T extends `location` ? IOptReplyLocation : T extends `contact` ? IOptReplyContact : IOptEditMedia1, options2?: IOptEditMedia2, fallbackReply?: boolean): Promise<true | grammy_types.Message.LocationMessage | grammy_types.Message.ContactMessage | grammy_types.Message.PhotoMessage | grammy_types.Message.VideoMessage | grammy_types.Message.AudioMessage | grammy_types.Message.DocumentMessage | grammy_types.Message.VoiceMessage | grammy_types.Message.VideoNoteMessage | grammy_types.Message.StickerMessage | (grammy_types.Update.Edited & grammy_types.Message) | undefined>;
282
+ editPhoto(keyboardInline?: IInlineKb, data?: IData, baseId?: string, options1?: IOptEditMedia1, options2?: IOptEditMedia2): Promise<true | grammy_types.Message.LocationMessage | grammy_types.Message.ContactMessage | grammy_types.Message.PhotoMessage | grammy_types.Message.VideoMessage | grammy_types.Message.AudioMessage | grammy_types.Message.DocumentMessage | grammy_types.Message.VoiceMessage | grammy_types.Message.VideoNoteMessage | grammy_types.Message.StickerMessage | (grammy_types.Update.Edited & grammy_types.Message) | undefined>;
283
+ editVideo(keyboardInline?: IInlineKb, data?: IData, baseId?: string, options1?: IOptEditMedia1, options2?: IOptEditMedia2): Promise<true | grammy_types.Message.LocationMessage | grammy_types.Message.ContactMessage | grammy_types.Message.PhotoMessage | grammy_types.Message.VideoMessage | grammy_types.Message.AudioMessage | grammy_types.Message.DocumentMessage | grammy_types.Message.VoiceMessage | grammy_types.Message.VideoNoteMessage | grammy_types.Message.StickerMessage | (grammy_types.Update.Edited & grammy_types.Message) | undefined>;
284
+ editAudio(keyboardInline?: IInlineKb, data?: IData, baseId?: string, options1?: IOptEditMedia1, options2?: IOptEditMedia2): Promise<true | grammy_types.Message.LocationMessage | grammy_types.Message.ContactMessage | grammy_types.Message.PhotoMessage | grammy_types.Message.VideoMessage | grammy_types.Message.AudioMessage | grammy_types.Message.DocumentMessage | grammy_types.Message.VoiceMessage | grammy_types.Message.VideoNoteMessage | grammy_types.Message.StickerMessage | (grammy_types.Update.Edited & grammy_types.Message) | undefined>;
285
+ editDocument(keyboardInline?: IInlineKb, data?: IData, baseId?: string, options1?: IOptEditMedia1, options2?: IOptEditMedia2): Promise<true | grammy_types.Message.LocationMessage | grammy_types.Message.ContactMessage | grammy_types.Message.PhotoMessage | grammy_types.Message.VideoMessage | grammy_types.Message.AudioMessage | grammy_types.Message.DocumentMessage | grammy_types.Message.VoiceMessage | grammy_types.Message.VideoNoteMessage | grammy_types.Message.StickerMessage | (grammy_types.Update.Edited & grammy_types.Message) | undefined>;
286
+ editAnimation(keyboardInline?: IInlineKb, data?: IData, baseId?: string, options1?: IOptEditMedia1, options2?: IOptEditMedia2): Promise<true | grammy_types.Message.LocationMessage | grammy_types.Message.ContactMessage | grammy_types.Message.PhotoMessage | grammy_types.Message.VideoMessage | grammy_types.Message.AudioMessage | grammy_types.Message.DocumentMessage | grammy_types.Message.VoiceMessage | grammy_types.Message.VideoNoteMessage | grammy_types.Message.StickerMessage | (grammy_types.Update.Edited & grammy_types.Message) | undefined>;
287
+ editVoice(keyboardInline?: IInlineKb, data?: IData, baseId?: string, options?: IOptEditMedia2): Promise<true | grammy_types.Message.LocationMessage | grammy_types.Message.ContactMessage | grammy_types.Message.PhotoMessage | grammy_types.Message.VideoMessage | grammy_types.Message.AudioMessage | grammy_types.Message.DocumentMessage | grammy_types.Message.VoiceMessage | grammy_types.Message.VideoNoteMessage | grammy_types.Message.StickerMessage | (grammy_types.Update.Edited & grammy_types.Message) | undefined>;
288
+ editVideoNote(keyboardInline?: IInlineKb, data?: IData, baseId?: string, options?: IOptEditMedia2): Promise<true | grammy_types.Message.LocationMessage | grammy_types.Message.ContactMessage | grammy_types.Message.PhotoMessage | grammy_types.Message.VideoMessage | grammy_types.Message.AudioMessage | grammy_types.Message.DocumentMessage | grammy_types.Message.VoiceMessage | grammy_types.Message.VideoNoteMessage | grammy_types.Message.StickerMessage | (grammy_types.Update.Edited & grammy_types.Message) | undefined>;
289
+ editSticker(keyboardInline?: IInlineKb, data?: IData, baseId?: string, options?: IOptEditMedia2): Promise<true | grammy_types.Message.LocationMessage | grammy_types.Message.ContactMessage | grammy_types.Message.PhotoMessage | grammy_types.Message.VideoMessage | grammy_types.Message.AudioMessage | grammy_types.Message.DocumentMessage | grammy_types.Message.VoiceMessage | grammy_types.Message.VideoNoteMessage | grammy_types.Message.StickerMessage | (grammy_types.Update.Edited & grammy_types.Message) | undefined>;
290
+ editLocation(keyboardInline?: IInlineKb, data?: IData, baseId?: string, options?: IOptEditMedia2): Promise<true | grammy_types.Message.LocationMessage | grammy_types.Message.ContactMessage | grammy_types.Message.PhotoMessage | grammy_types.Message.VideoMessage | grammy_types.Message.AudioMessage | grammy_types.Message.DocumentMessage | grammy_types.Message.VoiceMessage | grammy_types.Message.VideoNoteMessage | grammy_types.Message.StickerMessage | (grammy_types.Update.Edited & grammy_types.Message) | undefined>;
291
+ editContact(keyboardInline?: IInlineKb, data?: IData, baseId?: string, options?: IOptEditMedia2): Promise<true | grammy_types.Message.LocationMessage | grammy_types.Message.ContactMessage | grammy_types.Message.PhotoMessage | grammy_types.Message.VideoMessage | grammy_types.Message.AudioMessage | grammy_types.Message.DocumentMessage | grammy_types.Message.VoiceMessage | grammy_types.Message.VideoNoteMessage | grammy_types.Message.StickerMessage | (grammy_types.Update.Edited & grammy_types.Message) | undefined>;
292
292
  delete(): Promise<true>;
293
293
  callbackQueryAnswer(options?: Parameters<typeof Ctx.prototype.ct.answerCallbackQuery>[0]): Promise<true | null>;
294
294
  sessionSet(method: string, params: any, moreRoot?: Record<any, any>): Promise<boolean | null>;
@@ -1013,7 +1013,7 @@ declare class WorkerThreadInit {
1013
1013
  id: number;
1014
1014
  pid: number;
1015
1015
  rpc: WorkerThreadRpc;
1016
- parentPort: worker_threads.MessagePort | null;
1016
+ parentPort: node_worker_threads.MessagePort | null;
1017
1017
  gatewayServer?: WorkerThreadGatewayServer;
1018
1018
  gatewayClients: Map<string, WorkerThreadGatewayClient>;
1019
1019
  gatewayClientLatest?: WorkerThreadGatewayClient;
package/dist/src/index.js CHANGED
@@ -1,4 +1,4 @@
1
- var rt=Object.defineProperty;var p=(u,t)=>rt(u,"name",{value:t,configurable:!0}),K=(u=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(u,{get:(t,e)=>(typeof require<"u"?require:t)[e]}):u)(function(u){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+u+'" is not supported')});import Ot from"path";import{fileURLToPath as ct}from"url";var dt=p(()=>ct(import.meta.url),"getFilename");var C=dt();import{LoggingPretty as ht}from"logging-pretty";var E=class extends ht{static{p(this,"LoggingUtil")}constructor(t){super(t)}errorMake(t,e,s){this.error(`[${e?`${e}:${s}`:s}] ${this._formatErrorObj(t)}`)}_formatErrorObj(t){return JSON.stringify(t instanceof Error?{message:t.message,stack:t.stack,name:t.name}:t,null,2)}},G=new E;import{Keyv as lt}from"keyv";import mt from"@keyv/redis";var F=class extends lt{constructor(e="memory",s,n,o){let a;e.startsWith("redis")&&(a=new mt(e)),e==="memory"&&(a=new Map),o?.forceStore&&(a=o.forceStore);super({store:a,namespace:n,ttl:s});this.url=e}static{p(this,"CacheExternal")}refreshLruCache(e){let s=this.store,n=this.opts.namespace?this.opts.namespace?.length+1:null,o=s.keys().toArray();for(let a=0;a<o.length;a++){let i=o[a];if(a==e)return;this.get(n?i.slice(n):i)}}};import{setTimeout as pt}from"timers/promises";import{InlineKeyboard as q,Keyboard as J}from"grammy";var A=class{static{p(this,"Ctx")}static template;static data;data=this.constructor.data;get userIsPremium(){return this.ct.from?.is_premium??!1}get userIsBot(){return this.ct.from?.is_bot??!1}get userId(){return this.ct.from?.id}get userName(){return this.ct.from?.username}get userFullName(){return`${this.ct.from?.first_name} ${this.ct.from?.last_name||""}`}get userFirstName(){return this.ct.from?.first_name}get userLastName(){return this.ct.from?.last_name}get userLanguage(){return this.ct.from?.language_code}set userLanguage(t){this.ct.from.language_code=t}get msgText(){return this.ct.message?.text}get msgTextPayloads(){return this.getPayloads(this.msgText,"space",this.data?._positionPayloadText||this.temp?.data?._positionPayloadText)}get msgTextPayload(){return this.msgTextPayloads[0]}get msgTextCommandPayloads(){return this.getPayloads(this.msgText,"space")}get msgTextCommandPayload(){return this.msgTextCommandPayloads[0]}get msgCaption(){return this.ct.message?.caption}get msgCaptionPayloads(){return this.getPayloads(this.msgCaption,"space")}get msgCaptionPayload(){return this.msgCaptionPayloads[0]}get msgCaptionCommandPayloads(){return this.getPayloads(this.msgCaption,"space")}get msgCaptionCommandPayload(){return this.msgCaptionCommandPayloads[0]}get msgPhoto(){return this.ct.message?.photo}get msgVideo(){return this.ct.message?.video}get msgAudio(){return this.ct.message?.audio}get msgDocument(){return this.ct.message?.document}get msgAnimation(){return this.ct.message?.animation}get msgVoice(){return this.ct.message?.voice}get msgVideoNote(){return this.ct.message?.video_note}get msgSticker(){return this.ct.message?.sticker}get msgLocation(){return this.ct.message?.location}get msgContact(){return this.ct.message?.contact}get msgWebAppData(){return this.ct.message?.web_app_data}get msgGift(){return this.ct.message?.gift}get callbackData(){return this.ct.callbackQuery?.data}get callbackDataPayloads(){return this.getPayloads(this.callbackData,"colon")}get callbackDataPayload(){return this.callbackDataPayloads?.[0]}set session(t){this.temp.session=t}get session(){return this.temp.session}ct;cacheSession;cacheKeyboard;templateManager;temp;constructor(t){this.ct=t.ct,this.cacheSession=t.cacheSession,this.cacheKeyboard=t.cacheKeyboard,this.templateManager=t.templateManager,this.temp=t.temp}async broadcast(t,e,s,n,o,a,i=!1){try{this.temp.isAnswer=!0;let r=30,c=e.map(h=>this.templateManager.getMessage(this.data.name,o,h,n));for(let h=0;h<t.length;h++){let d=t[h],l=c[h];await this.ct.api.sendMessage(d,l,{parse_mode:"HTML",reply_markup:s,...a}),h+1==r&&await pt(1200)}}catch(r){if(i)throw r}}async reply(t,e,s,n){this.temp.isAnswer=!0;let o=this.templateManager.getMessage(this.data.name,s,this.userLanguage,e);return await this.ct.reply(o,{parse_mode:"HTML",reply_markup:t,...n})}async replyMedia(t,e,s,n,o){this.temp.isAnswer=!0;let a=this.templateManager.getMedia(this.data.name,n,this.userLanguage,s),i={parse_mode:"HTML",reply_markup:e,...o};if(t=="photo")return await this.ct.replyWithPhoto(a.src,{caption:a.caption,...i});if(t=="video")return await this.ct.replyWithVideo(a.src,{caption:a.caption,...i});if(t=="audio")return await this.ct.replyWithAudio(a.src,{caption:a.caption,...i});if(t=="document")return await this.ct.replyWithDocument(a.src,{caption:a.caption,...i});if(t=="animation")return await this.ct.replyWithAnimation(a.src,{caption:a.caption,...i});if(t=="voice")return await this.ct.replyWithVoice(a.src,i);if(t=="video_note")return await this.ct.replyWithVideoNote(a.src,i);if(t=="sticker")return await this.ct.replyWithSticker(a.src,i);if(t=="location")return await this.ct.replyWithLocation(parseInt(a.latitude),parseInt(a.longitude),i);if(t=="contact")return await this.ct.replyWithContact(a.phone,a.first_name,{vcard:a.vcard,...i})}async replyPhoto(t,e,s,n){return this.replyMedia("photo",t,e,s,n)}async replyVideo(t,e,s,n){return this.replyMedia("video",t,e,s,n)}async replyAudio(t,e,s,n){return this.replyMedia("audio",t,e,s,n)}async replyDocument(t,e,s,n){return this.replyMedia("document",t,e,s,n)}async replyAnimation(t,e,s,n){return this.replyMedia("animation",t,e,s,n)}async replyVoice(t,e,s,n){return this.replyMedia("voice",t,e,s,n)}async replyVideoNote(t,e,s,n){return this.replyMedia("video_note",t,e,s,n)}async replySticker(t,e,s,n){return this.replyMedia("sticker",t,e,s,n)}async replyLocation(t,e,s,n){return this.replyMedia("location",t,e,s,n)}async replyContact(t,e,s,n){return this.replyMedia("contact",t,e,s,n)}async replyAction(t){return await this.ct.replyWithChatAction(t)}async edit(t,e,s,n,o=!0){try{this.temp.isAnswer=!0;let a=this.templateManager.getMessage(this.data.name,s,this.userLanguage,e);return await this.ct.editMessageText(a,{parse_mode:"HTML",reply_markup:t,...n})}catch(a){if(o)await this.reply(t,e,s,n);else throw a}}async editMedia(t,e,s,n,o,a,i=!0){try{this.temp.isAnswer=!0;let{src:r,caption:c}=this.templateManager.getMedia(this.data.name,n,this.userLanguage,s);return t=="voice"?(await this.delete(),await this.replyVoice(e,s,n,o)):t=="video_note"?(await this.delete(),await this.replyVoice(e,s,n,o)):t=="sticker"?(await this.delete(),await this.replySticker(e,s,n,o)):t=="location"?(await this.delete(),await this.replyLocation(e,s,n,o)):t=="contact"?(await this.delete(),await this.replyContact(e,s,n,o)):await this.ct.editMessageMedia({media:r,caption:c,type:t,parse_mode:"HTML",...o},{reply_markup:e,...a})}catch(r){if(i===!0)await this.reply(e,s,n,a);else throw r}}async editPhoto(t,e,s,n,o){return await this.editMedia("photo",t,e,s,n,o)}async editVideo(t,e,s,n,o){return await this.editMedia("video",t,e,s,n,o)}async editAudio(t,e,s,n,o){return await this.editMedia("audio",t,e,s,n,o)}async editDocument(t,e,s,n,o){return await this.editMedia("document",t,e,s,n,o)}async editAnimation(t,e,s,n,o){return await this.editMedia("animation",t,e,s,n,o)}async editVoice(t,e,s,n){return await this.editMedia("voice",t,e,s,n)}async editVideoNote(t,e,s,n){return await this.editMedia("video_note",t,e,s,n)}async editSticker(t,e,s,n){return await this.editMedia("sticker",t,e,s,n)}async editLocation(t,e,s,n){return await this.editMedia("location",t,e,s,n)}async editContact(t,e,s,n){return await this.editMedia("contact",t,e,s,n)}async delete(){return await this.ct.deleteMessage()}async callbackQueryAnswer(t){try{return this.temp.isAnswer=!0,await this.ct.answerCallbackQuery(t)}catch{return null}}async sessionSet(t,e,s){try{let n={method:t,params:e,...s},o=await this.cacheSession.set(`${this.userId}`,n);return o&&(this.session=n),o}catch{return null}}async sessionGet(){try{let t=await this.cacheSession.get(`${this.userId}`);return t&&(this.session=t),t||null}catch{return null}}async sessionClear(){try{let t=await this.cacheSession.delete(`${this.userId}`);return t&&(this.session={}),t}catch{return null}}static buildData(t){let s=typeof t=="function"?{callback:t}:t||{},n=s.callback,o=this.prototype.addPayloads.bind(this.prototype),a=s.name||"";return{name:a,intentText:s.intentText||a,intentTextCommand:s.intentTextCommand||a,intentCallback:a,callback:n?function(...r){return o(this.intentCallback,"colon",n(...r))}:function(){return this?.intentCallback},_positionPayloadText:s.intentText?s.intentText.split(this.prototype.getSeperatorTag("space")).length:void 0}}keyboardCols(t,e,s,n){let[o,a]=s.split("-"),i=parseInt(o),r=a?parseInt(a):null,c=e.length,h=t;for(let d=0;d<c;d++){let l=e[d];if(n(l,d),r===null)(d+1)%i===0&&d<c-1&&h.row();else{let m=c-(d+1);(m===r||m>r&&(d+1)%i===0)&&h.row()}}return t}bottomKeyboardT(t="1",e,s){return this.bottomKeyboard((n,o)=>this.keyboardCols(n,o,t,a=>n.text(a)),{baseId:e??void 0,data:s})}inlineKeyboardT(t,e="1",s,n){return this.inlineKeyboard((o,a)=>this.keyboardCols(o,a,e,(i,r)=>{let c=t[r],h=typeof c=="string"?c:c.data.callback();o.text(i,h)}),{baseId:s??void 0,data:n})}inlineKeyboard(t,e){let s=this.data.name;if(e?.cache===!0){let i=`${s}:${this.userLanguage}:i`,r=this.cacheKeyboard.get(i);if(!r){let c=new q,h=this.templateManager.getKeyboard(s,e?.baseId,this.userLanguage,"inline",e?.data),d=t(c,h);return this.cacheKeyboard.set(i,d),d}return r}let n=new q,o=this.templateManager.getKeyboard(s,e?.baseId,this.userLanguage,"inline",e?.data);return t(n,o)}bottomKeyboard(t,e){let s=this.data.name;if(e?.cache===!0){let i=`${s}:${this.userLanguage}:b`,r=this.cacheKeyboard.get(i);if(!r){let c=new J,h=this.templateManager.getKeyboard(s,e?.baseId,this.userLanguage,"bottom",e?.data),d=t(c,h);return d.resized(!0),this.cacheKeyboard.set(i,d),d}return r}let n=new J,o=this.templateManager.getKeyboard(s,e?.baseId,this.userLanguage,"bottom",e?.data),a=t(n,o);return a.resized(),a}getSeperatorTag(t="space"){return t=="space"?" ":":"}havePayloads(t="",e){return t.includes(this.getSeperatorTag(e))}addPayloads(t="",e,s){let n=this.getSeperatorTag(e),o="";for(let a=0;a<s.length;a++){let i=s[a];i!=null&&i!==""&&(o+=n+i)}return t+o}getPayloads(t="",e,s=1){if(!t)return[];let n=this.getSeperatorTag(e);return t.split(n).slice(s)}getIntent(t="",e,s=1){if(!t)return"";let n=this.getSeperatorTag(e),o=t.split(n);return s==1?o[0]:o.slice(0,s).join(n)}validateSessionCallback(t,e){return(t??this.session.method)===this.methodSessionCallback(e)}validateSessionCallbackPayload(t,e){return(t??this.session.method)===this.methodSessionCallbackPayload(e)}validateSessionText(t,e){return(t??this.session.method)===this.methodSessionText(e)}validateSessionTextPayload(t,e){return(t??this.session.method)===this.methodSessionTextPayload(e)}validateSessionTextCommand(t,e){return(t??this.session.method)===this.methodSessionTextCommand(e)}validateSessionTextCommandPayload(t,e){return(t??this.session.method)===this.methodSessionTextCommandPayload(e)}validateSessionTextFree(t,e){return(t??this.session.method)===this.methodSessionTextFree(e)}validateSessionPhotoCaption(t,e){return(t??this.session.method)===this.methodSessionPhotoCaption(e)}validateSessionPhotoCaptionPayload(t,e){return(t??this.session.method)===this.methodSessionPhotoCaptionPayload(e)}validateSessionPhotoCaptionCommand(t,e){return(t??this.session.method)===this.methodSessionPhotoCaptionCommand(e)}validateSessionPhotoCaptionCommandPayload(t,e){return(t??this.session.method)===this.methodSessionPhotoCaptionCommandPayload(e)}validateSessionPhotoFree(t,e){return(t??this.session.method)===this.methodSessionPhotoFree(e)}validateSessionVideoCaption(t,e){return(t??this.session.method)===this.methodSessionVideoCaption(e)}validateSessionVideoCaptionPayload(t,e){return(t??this.session.method)===this.methodSessionVideoCaptionPayload(e)}validateSessionVideoCaptionCommand(t,e){return(t??this.session.method)===this.methodSessionVideoCaptionCommand(e)}validateSessionVideoCaptionCommandPayload(t,e){return(t??this.session.method)===this.methodSessionVideoCaptionCommandPayload(e)}validateSessionVideoFree(t,e){return(t??this.session.method)===this.methodSessionVideoFree(e)}validateSessionAudioCaption(t,e){return(t??this.session.method)===this.methodSessionAudioCaption(e)}validateSessionAudioCaptionPayload(t,e){return(t??this.session.method)===this.methodSessionAudioCaptionPayload(e)}validateSessionAudioCaptionCommand(t,e){return(t??this.session.method)===this.methodSessionAudioCaptionCommand(e)}validateSessionAudioCaptionCommandPayload(t,e){return(t??this.session.method)===this.methodSessionAudioCaptionCommandPayload(e)}validateSessionAudioFree(t,e){return(t??this.session.method)===this.methodSessionAudioFree(e)}validateSessionDocumentCaption(t,e){return(t??this.session.method)===this.methodSessionDocumentCaption(e)}validateSessionDocumentCaptionPayload(t,e){return(t??this.session.method)===this.methodSessionDocumentCaptionPayload(e)}validateSessionDocumentCaptionCommand(t,e){return(t??this.session.method)===this.methodSessionDocumentCaptionCommand(e)}validateSessionDocumentCaptionCommandPayload(t,e){return(t??this.session.method)===this.methodSessionDocumentCaptionCommandPayload(e)}validateSessionDocumentFree(t,e){return(t??this.session.method)===this.methodSessionDocumentFree(e)}validateSessionAnimationCaption(t,e){return(t??this.session.method)===this.methodSessionAnimationCaption(e)}validateSessionAnimationCaptionPayload(t,e){return(t??this.session.method)===this.methodSessionAnimationCaptionPayload(e)}validateSessionAnimationCaptionCommand(t,e){return(t??this.session.method)===this.methodSessionAnimationCaptionCommand(e)}validateSessionAnimationCaptionCommandPayload(t,e){return(t??this.session.method)===this.methodSessionAnimationCaptionCommandPayload(e)}validateSessionAnimationFree(t,e){return(t??this.session.method)===this.methodSessionAnimationFree(e)}validateSessionVoiceCaption(t,e){return(t??this.session.method)===this.methodSessionVoiceCaption(e)}validateSessionVoiceCaptionPayload(t,e){return(t??this.session.method)===this.methodSessionVoiceCaptionPayload(e)}validateSessionVoiceCaptionCommand(t,e){return(t??this.session.method)===this.methodSessionVoiceCaptionCommand(e)}validateSessionVoiceCaptionCommandPayload(t,e){return(t??this.session.method)===this.methodSessionVoiceCaptionCommandPayload(e)}validateSessionVoiceFree(t,e){return(t??this.session.method)===this.methodSessionVoiceFree(e)}validateSessionVideoNoteFree(t,e){return(t??this.session.method)===this.methodSessionVideoNoteFree(e)}validateSessionStickerFree(t,e){return(t??this.session.method)===this.methodSessionStickerFree(e)}validateSessionLocationFree(t,e){return(t??this.session.method)===this.methodSessionLocationFree(e)}validateSessionContactFree(t,e){return(t??this.session.method)===this.methodSessionContactFree(e)}sessionCallback(t,e){return this.sessionSet(this.methodSessionCallback(e),t)}sessionCallbackPayload(t,e){return this.sessionSet(this.methodSessionCallbackPayload(e),t)}sessionText(t,e){return this.sessionSet(this.methodSessionText(e),t)}sessionTextPayload(t,e){return this.sessionSet(this.methodSessionTextPayload(e),t)}sessionTextCommand(t,e){return this.sessionSet(this.methodSessionTextCommand(e),t)}sessionTextCommandPayload(t,e){return this.sessionSet(this.methodSessionTextCommandPayload(e),t)}sessionTextFree(t,e){return this.sessionSet(this.methodSessionTextFree(e),t)}sessionPhotoCaption(t,e){return this.sessionSet(this.methodSessionPhotoCaption(e),t)}sessionPhotoCaptionPayload(t,e){return this.sessionSet(this.methodSessionPhotoCaptionPayload(e),t)}sessionPhotoCaptionCommand(t,e){return this.sessionSet(this.methodSessionPhotoCaptionCommand(e),t)}sessionPhotoCaptionCommandPayload(t,e){return this.sessionSet(this.methodSessionPhotoCaptionCommandPayload(e),t)}sessionPhotoFree(t,e){return this.sessionSet(this.methodSessionPhotoFree(e),t)}sessionVideoCaption(t,e){return this.sessionSet(this.methodSessionVideoCaption(e),t)}sessionVideoCaptionPayload(t,e){return this.sessionSet(this.methodSessionVideoCaptionPayload(e),t)}sessionVideoCaptionCommand(t,e){return this.sessionSet(this.methodSessionVideoCaptionCommand(e),t)}sessionVideoCaptionCommandPayload(t,e){return this.sessionSet(this.methodSessionVideoCaptionCommandPayload(e),t)}sessionVideoFree(t,e){return this.sessionSet(this.methodSessionVideoFree(e),t)}sessionAudioCaption(t,e){return this.sessionSet(this.methodSessionAudioCaption(e),t)}sessionAudioCaptionPayload(t,e){return this.sessionSet(this.methodSessionAudioCaptionPayload(e),t)}sessionAudioCaptionCommand(t,e){return this.sessionSet(this.methodSessionAudioCaptionCommand(e),t)}sessionAudioCaptionCommandPayload(t,e){return this.sessionSet(this.methodSessionAudioCaptionCommandPayload(e),t)}sessionAudioFree(t,e){return this.sessionSet(this.methodSessionAudioFree(e),t)}sessionDocumentCaption(t,e){return this.sessionSet(this.methodSessionDocumentCaption(e),t)}sessionDocumentCaptionPayload(t,e){return this.sessionSet(this.methodSessionDocumentCaptionPayload(e),t)}sessionDocumentCaptionCommand(t,e){return this.sessionSet(this.methodSessionDocumentCaptionCommand(e),t)}sessionDocumentCaptionCommandPayload(t,e){return this.sessionSet(this.methodSessionDocumentCaptionCommandPayload(e),t)}sessionDocumentFree(t,e){return this.sessionSet(this.methodSessionDocumentFree(e),t)}sessionAnimationCaption(t,e){return this.sessionSet(this.methodSessionAnimationCaption(e),t)}sessionAnimationCaptionPayload(t,e){return this.sessionSet(this.methodSessionAnimationCaptionPayload(e),t)}sessionAnimationCaptionCommand(t,e){return this.sessionSet(this.methodSessionAnimationCaptionCommand(e),t)}sessionAnimationCaptionCommandPayload(t,e){return this.sessionSet(this.methodSessionAnimationCaptionCommandPayload(e),t)}sessionAnimationFree(t,e){return this.sessionSet(this.methodSessionAnimationFree(e),t)}sessionVoiceCaption(t,e){return this.sessionSet(this.methodSessionVoiceCaption(e),t)}sessionVoiceCaptionPayload(t,e){return this.sessionSet(this.methodSessionVoiceCaptionPayload(e),t)}sessionVoiceCaptionCommand(t,e){return this.sessionSet(this.methodSessionVoiceCaptionCommand(e),t)}sessionVoiceCaptionCommandPayload(t,e){return this.sessionSet(this.methodSessionVoiceCaptionCommandPayload(e),t)}sessionVoiceFree(t,e){return this.sessionSet(this.methodSessionVoiceFree(e),t)}sessionVideoNoteFree(t,e){return this.sessionSet(this.methodSessionVideoNoteFree(e),t)}sessionStickerFree(t,e){return this.sessionSet(this.methodSessionStickerFree(e),t)}sessionLocationFree(t,e){return this.sessionSet(this.methodSessionLocationFree(e),t)}sessionContactFree(t,e){return this.sessionSet(this.methodSessionContactFree(e),t)}sessionToCallback(t,e){return this.sessionCallback({...this.session.params,...t},e)}sessionToCallbackPayload(t,e){return this.sessionCallbackPayload({...this.session.params,...t},e)}sessionToText(t,e){return this.sessionText({...this.session.params,...t},e)}sessionToTextPayload(t,e){return this.sessionTextPayload({...this.session.params,...t},e)}sessionToTextCommand(t,e){return this.sessionTextCommand({...this.session.params,...t},e)}sessionToTextCommandPayload(t,e){return this.sessionTextCommandPayload({...this.session.params,...t},e)}sessionToTextFree(t,e){return this.sessionTextFree({...this.session.params,...t},e)}sessionToPhotoCaption(t,e){return this.sessionPhotoCaption({...this.session.params,...t},e)}sessionToPhotoCaptionPayload(t,e){return this.sessionPhotoCaptionPayload({...this.session.params,...t},e)}sessionToPhotoCaptionCommand(t,e){return this.sessionPhotoCaptionCommand({...this.session.params,...t},e)}sessionToPhotoCaptionCommandPayload(t,e){return this.sessionPhotoCaptionCommandPayload({...this.session.params,...t},e)}sessionToPhotoFree(t,e){return this.sessionPhotoFree({...this.session.params,...t},e)}sessionToVideoCaption(t,e){return this.sessionVideoCaption({...this.session.params,...t},e)}sessionToVideoCaptionPayload(t,e){return this.sessionVideoCaptionPayload({...this.session.params,...t},e)}sessionToVideoCaptionCommand(t,e){return this.sessionVideoCaptionCommand({...this.session.params,...t},e)}sessionToVideoCaptionCommandPayload(t,e){return this.sessionVideoCaptionCommandPayload({...this.session.params,...t},e)}sessionToVideoFree(t,e){return this.sessionVideoFree({...this.session.params,...t},e)}sessionToAudioCaption(t,e){return this.sessionAudioCaption({...this.session.params,...t},e)}sessionToAudioCaptionPayload(t,e){return this.sessionAudioCaptionPayload({...this.session.params,...t},e)}sessionToAudioCaptionCommand(t,e){return this.sessionAudioCaptionCommand({...this.session.params,...t},e)}sessionToAudioCaptionCommandPayload(t,e){return this.sessionAudioCaptionCommandPayload({...this.session.params,...t},e)}sessionToAudioFree(t,e){return this.sessionAudioFree({...this.session.params,...t},e)}sessionToDocumentCaption(t,e){return this.sessionDocumentCaption({...this.session.params,...t},e)}sessionToDocumentCaptionPayload(t,e){return this.sessionDocumentCaptionPayload({...this.session.params,...t},e)}sessionToDocumentCaptionCommand(t,e){return this.sessionDocumentCaptionCommand({...this.session.params,...t},e)}sessionToDocumentCaptionCommandPayload(t,e){return this.sessionDocumentCaptionCommandPayload({...this.session.params,...t},e)}sessionToDocumentFree(t,e){return this.sessionDocumentFree({...this.session.params,...t},e)}sessionToAnimationCaption(t,e){return this.sessionAnimationCaption({...this.session.params,...t},e)}sessionToAnimationCaptionPayload(t,e){return this.sessionAnimationCaptionPayload({...this.session.params,...t},e)}sessionToAnimationCaptionCommand(t,e){return this.sessionAnimationCaptionCommand({...this.session.params,...t},e)}sessionToAnimationCaptionCommandPayload(t,e){return this.sessionAnimationCaptionCommandPayload({...this.session.params,...t},e)}sessionToAnimationFree(t,e){return this.sessionAnimationFree({...this.session.params,...t},e)}sessionToVoiceCaption(t,e){return this.sessionVoiceCaption({...this.session.params,...t},e)}sessionToVoiceCaptionPayload(t,e){return this.sessionVoiceCaptionPayload({...this.session.params,...t},e)}sessionToVoiceCaptionCommand(t,e){return this.sessionVoiceCaptionCommand({...this.session.params,...t},e)}sessionToVoiceCaptionCommandPayload(t,e){return this.sessionVoiceCaptionCommandPayload({...this.session.params,...t},e)}sessionToVoiceFree(t,e){return this.sessionVoiceFree({...this.session.params,...t},e)}sessionToVideoNoteFree(t,e){return this.sessionVideoNoteFree({...this.session.params,...t},e)}sessionToStickerFree(t,e){return this.sessionStickerFree({...this.session.params,...t},e)}sessionToLocationFree(t,e){return this.sessionLocationFree({...this.session.params,...t},e)}sessionToContactFree(t,e){return this.sessionContactFree({...this.session.params,...t},e)}methodSession(t,e){return`${t}-${e||this.data.name}`}methodSessionCallback(t){return this.methodSession("1",t)}methodSessionCallbackPayload(t){return this.methodSession("2",t)}methodSessionText(t){return this.methodSession("3",t)}methodSessionTextPayload(t){return this.methodSession("4",t)}methodSessionTextCommand(t){return this.methodSession("5",t)}methodSessionTextCommandPayload(t){return this.methodSession("6",t)}methodSessionTextFree(t){return this.methodSession("7",t)}methodSessionPhotoCaption(t){return this.methodSession("8",t)}methodSessionPhotoCaptionPayload(t){return this.methodSession("9",t)}methodSessionPhotoCaptionCommand(t){return this.methodSession("10",t)}methodSessionPhotoCaptionCommandPayload(t){return this.methodSession("11",t)}methodSessionPhotoFree(t){return this.methodSession("12",t)}methodSessionVideoCaption(t){return this.methodSession("13",t)}methodSessionVideoCaptionPayload(t){return this.methodSession("14",t)}methodSessionVideoCaptionCommand(t){return this.methodSession("15",t)}methodSessionVideoCaptionCommandPayload(t){return this.methodSession("16",t)}methodSessionVideoFree(t){return this.methodSession("17",t)}methodSessionAudioCaption(t){return this.methodSession("18",t)}methodSessionAudioCaptionPayload(t){return this.methodSession("19",t)}methodSessionAudioCaptionCommand(t){return this.methodSession("20",t)}methodSessionAudioCaptionCommandPayload(t){return this.methodSession("21",t)}methodSessionAudioFree(t){return this.methodSession("22",t)}methodSessionDocumentCaption(t){return this.methodSession("23",t)}methodSessionDocumentCaptionPayload(t){return this.methodSession("24",t)}methodSessionDocumentCaptionCommand(t){return this.methodSession("25",t)}methodSessionDocumentCaptionCommandPayload(t){return this.methodSession("26",t)}methodSessionDocumentFree(t){return this.methodSession("27",t)}methodSessionAnimationCaption(t){return this.methodSession("28",t)}methodSessionAnimationCaptionPayload(t){return this.methodSession("29",t)}methodSessionAnimationCaptionCommand(t){return this.methodSession("30",t)}methodSessionAnimationCaptionCommandPayload(t){return this.methodSession("31",t)}methodSessionAnimationFree(t){return this.methodSession("32",t)}methodSessionVoiceCaption(t){return this.methodSession("33",t)}methodSessionVoiceCaptionPayload(t){return this.methodSession("34",t)}methodSessionVoiceCaptionCommand(t){return this.methodSession("35",t)}methodSessionVoiceCaptionCommandPayload(t){return this.methodSession("36",t)}methodSessionVoiceFree(t){return this.methodSession("37",t)}methodSessionVideoNoteFree(t){return this.methodSession("38",t)}methodSessionStickerFree(t){return this.methodSession("39",t)}methodSessionLocationFree(t){return this.methodSession("40",t)}methodSessionContactFree(t){return this.methodSession("41",t)}};import{join as L}from"path";import{existsSync as Q,readdirSync as U}from"fs";import{createRequire as gt}from"module";var b=class{static{p(this,"PageManager")}static _getFile(t,e,s=0){let o=Object.values(t)[s];if(o===void 0)throw new Error(`File ${e} must have export (not default) class page`);return o}static getFilePath(){return L(process.cwd(),"src","pages")}static getFileSync(t,e=0){t||(t=this.getFilePath());let n=gt(t)(t);return this._getFile(n,t,e)}static async getFile(t,e=0){t||(t=this.getFilePath());let s=await import(`${t}?t=${Date.now()}`);return this._getFile(s,t,e)}static getFileManySync(t,e=0){if(t||(t=this.getFilePath()),!Q(t))throw new Error(`Directory ${t} is not found, please make it manually`);return U(t).map(n=>{let o=L(t,n);return{path:o,page:this.getFileSync(o,e)}})}static clearCacheRequire(t){if(t||(t=this.getFilePath()),!Q(t))throw new Error(`Directory ${t} is not found, please make it manually`);return U(t).forEach(s=>{let n=L(t,s);delete K.cache[K.resolve(n)]}),!0}};import{readFileSync as Ct}from"fs";import{fileURLToPath as St}from"url";import{dirname as bt,join as Y,parse as Pt}from"path";import{basename as j,join as I,extname as H}from"path";import{readdirSync as ut,readFileSync as D,existsSync as _,statSync as R,writeFileSync as yt}from"fs";import{watch as ft}from"chokidar";var w=class{static{p(this,"TemplateEngine")}static _escape(t){return t.replace(/\\/g,"\\\\").replace(/`/g,"\\`")}static _processVariables(t){return t.replace(/\{\{(\w+)\}\}/g,(e,s)=>`\${(data && data["${s}"]) ?? ""}`)}static _processBaseBlocks(t){let e=/<base\b[^>]*?(?:\sid=(["']?)([^"'\s>]+)\1)?[^>]*?>([\s\S]*?)<\/base>/g,s={};for(let n of t.matchAll(e)){let o=n[2]??"default",i=(n[3]??"").replace(/^[\t ]+/gm,"").replace(/^\n+/,"").replace(/\n+$/,"").trim();s[o]=i}return s}static _processScriptBlocks(t){return t.replace(/<script\b[^>]*>([\s\S]*?)<\/script>/gi,(e,s)=>{let n=s.trim();return n?`\${(() => { if (!data) return ''; try { with(data) { ${n} } } catch(e) { return '' } })()}`:""})}static _processSpaceBlocks(t){return t.replace(/^[ \t]*<space\s*\/>[ \t]*$/gim,"")}static _processDivBlocks(t){return t.replace(/<div>([\s\S]*?)<\/div>/gi,(e,s)=>s.replace(/^[\t ]+/gm,"").replace(/^\n+/,"").replace(/\n+$/,""))}static _processSwitchBlocks(t){let e=/<switch\b(?:\s+value="([^"]+)")?>([\s\S]*?)<\/switch>/gi;return t.replace(e,(s,n,o)=>{if(!n)return"";let a="",i=/<case\b(?:\s+is="([^"]+)")?>([\s\S]*?)<\/case>/gi,r=/<default>([\s\S]*?)<\/default>/gi,c;for(;(c=i.exec(o))!==null;){let d=(c[1]||"").split(",").map(m=>m.trim()),l=(c[2]||"").replace(/^[\t ]+/gm,"").replace(/^\n+/,"").replace(/\n+$/,"").trim().replace(/`/g,"\\`");d.forEach(m=>{a+=`case "${m}": `}),a+=`return \`${l}\`; `}let h=r.exec(o);if(h){let d=(h[1]||"").replace(/^[\t ]+/gm,"").replace(/^\n+/,"").replace(/\n+$/,"").trim();a+=`default: return \`${d}\`; `}else a+="default: return ''; ";return`\${(() => { switch((data && data["${n}"])) { ${a} } })()}`})}static _processExec(t){return t.replace(/{~\s*([\s\S]*?)\s*~}/g,(e,s)=>`\${(() => { try { return ${s} } catch(e) { try { with(data || {}) { return ${s} } } catch(ee) { return '' } } })()}`)}static _processMapBlocks(t){let e=/<map(?:\s+([^>]*))?>([\s\S]*?)<\/map>/gi;return t.replace(e,(s,n,o)=>{let a={},i=/(\w+)="([^"]*)"/g;if(n)for(let l of n.matchAll(i))a[l[1]]=l[2];let r=a.src;if(!r)return"";let c=a.join??"\\n",h=o.replace(/^[\t ]+/gm,"").replace(/^\n+/,"").replace(/\n+$/,"").replace(/`/g,"\\`");h=h.replace(/\{\{([\w.]+)\}\}/g,(l,m)=>m==="e"||m.startsWith("e.")?`\${${m}}`:m==="i"?"${i}":l);let d=c.replace(/"/g,'\\"');return`\${(data && data["${r}"] || []).map((e, i) => \`${h}\`).join("${d}")}`})}static _processMediaBlocks(t){let e=/<media(?:\s+([^>]*))?>([\s\S]*?)<\/media>/gi,s={};for(let n of t.matchAll(e)){let o=n[1],a=n[2],i={},r=/(\w+)="([^"]*)"/g;if(o)for(let m of o.matchAll(r))i[m[1]]=m[2];let c=i.lang||"default",h=i.type,d=a.replace(/^[\t ]+/gm,"").replace(/^\n+/,"").replace(/\n+$/,"").trim(),l={type:h};i.src&&(l.src=i.src),d&&h!=="video_note"&&h!=="sticker"&&(l.caption=d),h==="location"&&(i.latitude&&(l.latitude=i.latitude),i.longitude&&(l.longitude=i.longitude),d&&(l.caption=d)),h==="contact"&&(i.phone&&(l.phone=i.phone),i.first_name&&(l.first_name=i.first_name),i.last_name&&(l.last_name=i.last_name),i.vcard&&(l.vcard=i.vcard),d&&(l.caption=d)),s[c]=l}return s}static _processMessageBlocks(t){let e=/<message(?:\s+([^>]*))?>([\s\S]*?)<\/message>/gi,s={};for(let[,n,o]of t.matchAll(e)){let a={},i=/(\w+)="([^"]*)"/g;if(n)for(let h of n.matchAll(i))a[h[1]]=h[2];let r=a.lang||"default",c=o.replace(/^[\t ]+/gm,"").replace(/^\n+/,"").replace(/\n+$/,"").trim();s[r]=c}return s}static _processDescriptionBlocks(t){let e=/<description(?:\s+([^>]*))?>([\s\S]*?)<\/description>/gi,s={};for(let[,n,o]of t.matchAll(e)){let a={},i=/(\w+)="([^"]*)"/g;if(n)for(let d of n.matchAll(i))a[d[1]]=d[2];let r=a.lang||"default",c=a.scope||"default",h=o.replace(/^[\t ]+/gm,"").replace(/^\n+/,"").replace(/\n+$/,"").trim();s[r]||(s[r]={}),s[r][c]=h}return s}static _processKeyboardBlocks(t){let e=/<keyboard(?:\s+([^>]*))?>([\s\S]*?)<\/keyboard>/gi,s={};for(let[,n,o]of t.matchAll(e)){let a={},i=/(\w+)="([^"]*)"/g;if(n)for(let d of n.matchAll(i))a[d[1]]=d[2];let r=a.lang||"default",c=a.type==="bottom"?"bottom":"inline",h=o.trim();s[r]||(s[r]={}),s[r][c]=h}return s}static _compileToFunction(t,e){let s;e?s=t.map(a=>`\`${a}\``).join(","):s=`\`${t}\``;let n=s;if(n=this._processScriptBlocks(this._processDivBlocks(this._processSpaceBlocks(n))),e){let o=`return [${n}]`;return new Function("data",o)}else{let o=`return ${n}`;return new Function("data",o)}}static compileMedia(t,e){let s=e||this._processBaseBlocks(t),n={};for(let[o,a]of Object.entries(s)){let i=this._processMediaBlocks(a);n[o]={};for(let[r,c]of Object.entries(i)){let h={};for(let[d,l]of Object.entries(c)){if(d==="type"||typeof l!="string")continue;let m=this._processVariables(this._processExec(this._processSwitchBlocks(this._processMapBlocks(this._processScriptBlocks(l)))));h[d]=this._compileToFunction(m,!1)}n[o][r]=d=>{let l={...c};for(let[m,y]of Object.entries(h))l[m]=y(d);return l}}}return n}static compileMessages(t,e){let s=e||this._processBaseBlocks(t),n={};for(let[o,a]of Object.entries(s)){let i=this._processMessageBlocks(a);n[o]={};for(let[r,c]of Object.entries(i)){let h=this._processVariables(this._processExec(this._processSwitchBlocks(this._processMapBlocks(this._processScriptBlocks(c)))));n[o][r]=this._compileToFunction(h,!1)}}return n}static compileDescription(t,e){let s=e||this._processBaseBlocks(t),n={};for(let[o,a]of Object.entries(s)){let i=this._processDescriptionBlocks(a);n[o]={};for(let[r,c]of Object.entries(i))for(let[h,d]of Object.entries(c)){n[o][h]||(n[o][h]={});let l=this._processVariables(this._processExec(this._processSwitchBlocks(this._processMapBlocks(this._processScriptBlocks(d)))));n[o][h][r]=this._compileToFunction(l,!1)}}return n}static compileKeyboards(t,e){let s=e||this._processBaseBlocks(t),n={};for(let[o,a]of Object.entries(s)){let i=this._processKeyboardBlocks(a);n[o]={};for(let[r,c]of Object.entries(i)){n[o][r]={};for(let[h,d]of Object.entries(c)){let m=d.split(/(?<!\\),\s*/).map(y=>y.replace(/\\,/g,",").trim()).map(y=>this._processVariables(this._processExec(this._processSwitchBlocks(this._processMapBlocks(this._processScriptBlocks(y))))));n[o][r][h]=this._compileToFunction(m,!0)}}}return n}static _extractBlock(t,e,s="default",n="all",o){let a=/<base\b[^>]*?(?:\sid=(["']?)([^"'\s>]+)\1)?[^>]*?>([\s\S]*?)<\/base>/g,i=t,r=!1;for(let c of t.matchAll(a))if((c[2]??"default")===s){i=c[3]??"",r=!0;break}if(!r){let c=/<base\b/.test(t);if(!(s==="default"&&!c))return""}if(e){if(e==="all")return i;let c=Array.isArray(e)?e:[e],h=[];for(let l of c){let m=new RegExp(`([ \\t]*)<${l}(?:\\s+([^>]*))?>([\\s\\S]*?)<\\/${l}>`,"gi");for(let y of i.matchAll(m)){let f=y[2];if(o){let g=/lang="([^"]*)"/i,P=f?.match(g);if(((P?P[1]:void 0)||"default")!==o)continue}h.push({start:y.index,content:y[0],innerContent:y[3]??""})}}h.sort((l,m)=>l.start-m.start);let d=p(l=>{let m=l.split(`
1
+ var rt=Object.defineProperty;var p=(u,t)=>rt(u,"name",{value:t,configurable:!0}),K=(u=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(u,{get:(t,e)=>(typeof require<"u"?require:t)[e]}):u)(function(u){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+u+'" is not supported')});import Ot from"path";import{fileURLToPath as ct}from"url";var dt=p(()=>ct(import.meta.url),"getFilename");var C=dt();import{LoggingPretty as ht}from"logging-pretty";var E=class extends ht{static{p(this,"LoggingUtil")}constructor(t){super(t)}errorMake(t,e,s){this.error(`[${e?`${e}:${s}`:s}] ${this._formatErrorObj(t)}`)}_formatErrorObj(t){return JSON.stringify(t instanceof Error?{message:t.message,stack:t.stack,name:t.name}:t,null,2)}},G=new E;import{Keyv as lt}from"keyv";import mt from"@keyv/redis";var F=class extends lt{constructor(e="memory",s,n,o){let a;e.startsWith("redis")&&(a=new mt(e)),e==="memory"&&(a=new Map),o?.forceStore&&(a=o.forceStore);super({store:a,namespace:n,ttl:s});this.url=e}static{p(this,"CacheExternal")}refreshLruCache(e){let s=this.store,n=this.opts.namespace?this.opts.namespace?.length+1:null,o=s.keys().toArray();for(let a=0;a<o.length;a++){let i=o[a];if(a==e)return;this.get(n?i.slice(n):i)}}};import{setTimeout as pt}from"timers/promises";import{InlineKeyboard as q,Keyboard as J}from"grammy";var A=class{static{p(this,"Ctx")}static template;static data;data=this.constructor.data;get userIsPremium(){return this.ct.from?.is_premium??!1}get userIsBot(){return this.ct.from?.is_bot??!1}get userId(){return this.ct.from?.id}get userName(){return this.ct.from?.username}get userFullName(){return`${this.ct.from?.first_name} ${this.ct.from?.last_name||""}`}get userFirstName(){return this.ct.from?.first_name}get userLastName(){return this.ct.from?.last_name}get userLanguage(){return this.ct.from?.language_code}set userLanguage(t){this.ct.from.language_code=t}get msgText(){return this.ct.message?.text}get msgTextPayloads(){return this.getPayloads(this.msgText,"space",this.data?._positionPayloadText||this.temp?.data?._positionPayloadText)}get msgTextPayload(){return this.msgTextPayloads[0]}get msgTextCommandPayloads(){return this.getPayloads(this.msgText,"space")}get msgTextCommandPayload(){return this.msgTextCommandPayloads[0]}get msgCaption(){return this.ct.message?.caption}get msgCaptionPayloads(){return this.getPayloads(this.msgCaption,"space")}get msgCaptionPayload(){return this.msgCaptionPayloads[0]}get msgCaptionCommandPayloads(){return this.getPayloads(this.msgCaption,"space")}get msgCaptionCommandPayload(){return this.msgCaptionCommandPayloads[0]}get msgPhoto(){return this.ct.message?.photo}get msgVideo(){return this.ct.message?.video}get msgAudio(){return this.ct.message?.audio}get msgDocument(){return this.ct.message?.document}get msgAnimation(){return this.ct.message?.animation}get msgVoice(){return this.ct.message?.voice}get msgVideoNote(){return this.ct.message?.video_note}get msgSticker(){return this.ct.message?.sticker}get msgLocation(){return this.ct.message?.location}get msgContact(){return this.ct.message?.contact}get msgWebAppData(){return this.ct.message?.web_app_data}get msgGift(){return this.ct.message?.gift}get callbackData(){return this.ct.callbackQuery?.data}get callbackDataPayloads(){return this.getPayloads(this.callbackData,"colon")}get callbackDataPayload(){return this.callbackDataPayloads?.[0]}get session(){return this.temp.session}set session(t){this.temp.session=t}ct;cacheSession;cacheKeyboard;templateManager;temp;constructor(t){this.ct=t.ct,this.cacheSession=t.cacheSession,this.cacheKeyboard=t.cacheKeyboard,this.templateManager=t.templateManager,this.temp=t.temp}async broadcast(t,e,s,n,o,a,i=!1){try{this.temp.isAnswer=!0;let r=30,c=e.map(h=>this.templateManager.getMessage(this.data.name,o,h,n));for(let h=0;h<t.length;h++){let d=t[h],l=c[h];await this.ct.api.sendMessage(d,l,{parse_mode:"HTML",reply_markup:s,...a}),h+1==r&&await pt(1200)}}catch(r){if(i)throw r}}async reply(t,e,s,n){this.temp.isAnswer=!0;let o=this.templateManager.getMessage(this.data.name,s,this.userLanguage,e);return await this.ct.reply(o,{parse_mode:"HTML",reply_markup:t,...n})}async replyMedia(t,e,s,n,o){this.temp.isAnswer=!0;let a=this.templateManager.getMedia(this.data.name,n,this.userLanguage,s),i={parse_mode:"HTML",reply_markup:e,...o};if(t=="photo")return await this.ct.replyWithPhoto(a.src,{caption:a.caption,...i});if(t=="video")return await this.ct.replyWithVideo(a.src,{caption:a.caption,...i});if(t=="audio")return await this.ct.replyWithAudio(a.src,{caption:a.caption,...i});if(t=="document")return await this.ct.replyWithDocument(a.src,{caption:a.caption,...i});if(t=="animation")return await this.ct.replyWithAnimation(a.src,{caption:a.caption,...i});if(t=="voice")return await this.ct.replyWithVoice(a.src,i);if(t=="video_note")return await this.ct.replyWithVideoNote(a.src,i);if(t=="sticker")return await this.ct.replyWithSticker(a.src,i);if(t=="location")return await this.ct.replyWithLocation(parseInt(a.latitude),parseInt(a.longitude),i);if(t=="contact")return await this.ct.replyWithContact(a.phone,a.first_name,{vcard:a.vcard,...i})}async replyPhoto(t,e,s,n){return this.replyMedia("photo",t,e,s,n)}async replyVideo(t,e,s,n){return this.replyMedia("video",t,e,s,n)}async replyAudio(t,e,s,n){return this.replyMedia("audio",t,e,s,n)}async replyDocument(t,e,s,n){return this.replyMedia("document",t,e,s,n)}async replyAnimation(t,e,s,n){return this.replyMedia("animation",t,e,s,n)}async replyVoice(t,e,s,n){return this.replyMedia("voice",t,e,s,n)}async replyVideoNote(t,e,s,n){return this.replyMedia("video_note",t,e,s,n)}async replySticker(t,e,s,n){return this.replyMedia("sticker",t,e,s,n)}async replyLocation(t,e,s,n){return this.replyMedia("location",t,e,s,n)}async replyContact(t,e,s,n){return this.replyMedia("contact",t,e,s,n)}async replyAction(t){return await this.ct.replyWithChatAction(t)}async edit(t,e,s,n,o=!0){try{this.temp.isAnswer=!0;let a=this.templateManager.getMessage(this.data.name,s,this.userLanguage,e);return await this.ct.editMessageText(a,{parse_mode:"HTML",reply_markup:t,...n})}catch(a){if(o)await this.reply(t,e,s,n);else throw a}}async editMedia(t,e,s,n,o,a,i=!0){try{this.temp.isAnswer=!0;let{src:r,caption:c}=this.templateManager.getMedia(this.data.name,n,this.userLanguage,s);return t=="voice"?(await this.delete(),await this.replyVoice(e,s,n,o)):t=="video_note"?(await this.delete(),await this.replyVoice(e,s,n,o)):t=="sticker"?(await this.delete(),await this.replySticker(e,s,n,o)):t=="location"?(await this.delete(),await this.replyLocation(e,s,n,o)):t=="contact"?(await this.delete(),await this.replyContact(e,s,n,o)):await this.ct.editMessageMedia({media:r,caption:c,type:t,parse_mode:"HTML",...o},{reply_markup:e,...a})}catch(r){if(i===!0)await this.reply(e,s,n,a);else throw r}}async editPhoto(t,e,s,n,o){return await this.editMedia("photo",t,e,s,n,o)}async editVideo(t,e,s,n,o){return await this.editMedia("video",t,e,s,n,o)}async editAudio(t,e,s,n,o){return await this.editMedia("audio",t,e,s,n,o)}async editDocument(t,e,s,n,o){return await this.editMedia("document",t,e,s,n,o)}async editAnimation(t,e,s,n,o){return await this.editMedia("animation",t,e,s,n,o)}async editVoice(t,e,s,n){return await this.editMedia("voice",t,e,s,n)}async editVideoNote(t,e,s,n){return await this.editMedia("video_note",t,e,s,n)}async editSticker(t,e,s,n){return await this.editMedia("sticker",t,e,s,n)}async editLocation(t,e,s,n){return await this.editMedia("location",t,e,s,n)}async editContact(t,e,s,n){return await this.editMedia("contact",t,e,s,n)}async delete(){return await this.ct.deleteMessage()}async callbackQueryAnswer(t){try{return this.temp.isAnswer=!0,await this.ct.answerCallbackQuery(t)}catch{return null}}async sessionSet(t,e,s){try{let n={method:t,params:e,...s},o=await this.cacheSession.set(`${this.userId}`,n);return o&&(this.session=n),o}catch{return null}}async sessionGet(){try{let t=await this.cacheSession.get(`${this.userId}`);return t&&(this.session=t),t||null}catch{return null}}async sessionClear(){try{let t=await this.cacheSession.delete(`${this.userId}`);return t&&(this.session={}),t}catch{return null}}static buildData(t){let s=typeof t=="function"?{callback:t}:t||{},n=s.callback,o=this.prototype.addPayloads.bind(this.prototype),a=s.name||"";return{name:a,intentText:s.intentText||a,intentTextCommand:s.intentTextCommand||a,intentCallback:a,callback:n?function(...r){return o(this.intentCallback,"colon",n(...r))}:function(){return this?.intentCallback},_positionPayloadText:s.intentText?s.intentText.split(this.prototype.getSeperatorTag("space")).length:void 0}}keyboardCols(t,e,s,n){let[o,a]=s.split("-"),i=parseInt(o),r=a?parseInt(a):null,c=e.length,h=t;for(let d=0;d<c;d++){let l=e[d];if(n(l,d),r===null)(d+1)%i===0&&d<c-1&&h.row();else{let m=c-(d+1);(m===r||m>r&&(d+1)%i===0)&&h.row()}}return t}bottomKeyboardT(t="1",e,s){return this.bottomKeyboard((n,o)=>this.keyboardCols(n,o,t,a=>n.text(a)),{baseId:e??void 0,data:s})}inlineKeyboardT(t,e="1",s,n){return this.inlineKeyboard((o,a)=>this.keyboardCols(o,a,e,(i,r)=>{let c=t[r],h=typeof c=="string"?c:c.data.callback();o.text(i,h)}),{baseId:s??void 0,data:n})}inlineKeyboard(t,e){let s=this.data.name;if(e?.cache===!0){let i=`${s}:${this.userLanguage}:i`,r=this.cacheKeyboard.get(i);if(!r){let c=new q,h=this.templateManager.getKeyboard(s,e?.baseId,this.userLanguage,"inline",e?.data),d=t(c,h);return this.cacheKeyboard.set(i,d),d}return r}let n=new q,o=this.templateManager.getKeyboard(s,e?.baseId,this.userLanguage,"inline",e?.data);return t(n,o)}bottomKeyboard(t,e){let s=this.data.name;if(e?.cache===!0){let i=`${s}:${this.userLanguage}:b`,r=this.cacheKeyboard.get(i);if(!r){let c=new J,h=this.templateManager.getKeyboard(s,e?.baseId,this.userLanguage,"bottom",e?.data),d=t(c,h);return d.resized(!0),this.cacheKeyboard.set(i,d),d}return r}let n=new J,o=this.templateManager.getKeyboard(s,e?.baseId,this.userLanguage,"bottom",e?.data),a=t(n,o);return a.resized(),a}getSeperatorTag(t="space"){return t=="space"?" ":":"}havePayloads(t="",e){return t.includes(this.getSeperatorTag(e))}addPayloads(t="",e,s){let n=this.getSeperatorTag(e),o="";for(let a=0;a<s.length;a++){let i=s[a];i!=null&&i!==""&&(o+=n+i)}return t+o}getPayloads(t="",e,s=1){if(!t)return[];let n=this.getSeperatorTag(e);return t.split(n).slice(s)}getIntent(t="",e,s=1){if(!t)return"";let n=this.getSeperatorTag(e),o=t.split(n);return s==1?o[0]:o.slice(0,s).join(n)}validateSessionCallback(t,e){return(t??this.session.method)===this.methodSessionCallback(e)}validateSessionCallbackPayload(t,e){return(t??this.session.method)===this.methodSessionCallbackPayload(e)}validateSessionText(t,e){return(t??this.session.method)===this.methodSessionText(e)}validateSessionTextPayload(t,e){return(t??this.session.method)===this.methodSessionTextPayload(e)}validateSessionTextCommand(t,e){return(t??this.session.method)===this.methodSessionTextCommand(e)}validateSessionTextCommandPayload(t,e){return(t??this.session.method)===this.methodSessionTextCommandPayload(e)}validateSessionTextFree(t,e){return(t??this.session.method)===this.methodSessionTextFree(e)}validateSessionPhotoCaption(t,e){return(t??this.session.method)===this.methodSessionPhotoCaption(e)}validateSessionPhotoCaptionPayload(t,e){return(t??this.session.method)===this.methodSessionPhotoCaptionPayload(e)}validateSessionPhotoCaptionCommand(t,e){return(t??this.session.method)===this.methodSessionPhotoCaptionCommand(e)}validateSessionPhotoCaptionCommandPayload(t,e){return(t??this.session.method)===this.methodSessionPhotoCaptionCommandPayload(e)}validateSessionPhotoFree(t,e){return(t??this.session.method)===this.methodSessionPhotoFree(e)}validateSessionVideoCaption(t,e){return(t??this.session.method)===this.methodSessionVideoCaption(e)}validateSessionVideoCaptionPayload(t,e){return(t??this.session.method)===this.methodSessionVideoCaptionPayload(e)}validateSessionVideoCaptionCommand(t,e){return(t??this.session.method)===this.methodSessionVideoCaptionCommand(e)}validateSessionVideoCaptionCommandPayload(t,e){return(t??this.session.method)===this.methodSessionVideoCaptionCommandPayload(e)}validateSessionVideoFree(t,e){return(t??this.session.method)===this.methodSessionVideoFree(e)}validateSessionAudioCaption(t,e){return(t??this.session.method)===this.methodSessionAudioCaption(e)}validateSessionAudioCaptionPayload(t,e){return(t??this.session.method)===this.methodSessionAudioCaptionPayload(e)}validateSessionAudioCaptionCommand(t,e){return(t??this.session.method)===this.methodSessionAudioCaptionCommand(e)}validateSessionAudioCaptionCommandPayload(t,e){return(t??this.session.method)===this.methodSessionAudioCaptionCommandPayload(e)}validateSessionAudioFree(t,e){return(t??this.session.method)===this.methodSessionAudioFree(e)}validateSessionDocumentCaption(t,e){return(t??this.session.method)===this.methodSessionDocumentCaption(e)}validateSessionDocumentCaptionPayload(t,e){return(t??this.session.method)===this.methodSessionDocumentCaptionPayload(e)}validateSessionDocumentCaptionCommand(t,e){return(t??this.session.method)===this.methodSessionDocumentCaptionCommand(e)}validateSessionDocumentCaptionCommandPayload(t,e){return(t??this.session.method)===this.methodSessionDocumentCaptionCommandPayload(e)}validateSessionDocumentFree(t,e){return(t??this.session.method)===this.methodSessionDocumentFree(e)}validateSessionAnimationCaption(t,e){return(t??this.session.method)===this.methodSessionAnimationCaption(e)}validateSessionAnimationCaptionPayload(t,e){return(t??this.session.method)===this.methodSessionAnimationCaptionPayload(e)}validateSessionAnimationCaptionCommand(t,e){return(t??this.session.method)===this.methodSessionAnimationCaptionCommand(e)}validateSessionAnimationCaptionCommandPayload(t,e){return(t??this.session.method)===this.methodSessionAnimationCaptionCommandPayload(e)}validateSessionAnimationFree(t,e){return(t??this.session.method)===this.methodSessionAnimationFree(e)}validateSessionVoiceCaption(t,e){return(t??this.session.method)===this.methodSessionVoiceCaption(e)}validateSessionVoiceCaptionPayload(t,e){return(t??this.session.method)===this.methodSessionVoiceCaptionPayload(e)}validateSessionVoiceCaptionCommand(t,e){return(t??this.session.method)===this.methodSessionVoiceCaptionCommand(e)}validateSessionVoiceCaptionCommandPayload(t,e){return(t??this.session.method)===this.methodSessionVoiceCaptionCommandPayload(e)}validateSessionVoiceFree(t,e){return(t??this.session.method)===this.methodSessionVoiceFree(e)}validateSessionVideoNoteFree(t,e){return(t??this.session.method)===this.methodSessionVideoNoteFree(e)}validateSessionStickerFree(t,e){return(t??this.session.method)===this.methodSessionStickerFree(e)}validateSessionLocationFree(t,e){return(t??this.session.method)===this.methodSessionLocationFree(e)}validateSessionContactFree(t,e){return(t??this.session.method)===this.methodSessionContactFree(e)}sessionCallback(t,e){return this.sessionSet(this.methodSessionCallback(e),t)}sessionCallbackPayload(t,e){return this.sessionSet(this.methodSessionCallbackPayload(e),t)}sessionText(t,e){return this.sessionSet(this.methodSessionText(e),t)}sessionTextPayload(t,e){return this.sessionSet(this.methodSessionTextPayload(e),t)}sessionTextCommand(t,e){return this.sessionSet(this.methodSessionTextCommand(e),t)}sessionTextCommandPayload(t,e){return this.sessionSet(this.methodSessionTextCommandPayload(e),t)}sessionTextFree(t,e){return this.sessionSet(this.methodSessionTextFree(e),t)}sessionPhotoCaption(t,e){return this.sessionSet(this.methodSessionPhotoCaption(e),t)}sessionPhotoCaptionPayload(t,e){return this.sessionSet(this.methodSessionPhotoCaptionPayload(e),t)}sessionPhotoCaptionCommand(t,e){return this.sessionSet(this.methodSessionPhotoCaptionCommand(e),t)}sessionPhotoCaptionCommandPayload(t,e){return this.sessionSet(this.methodSessionPhotoCaptionCommandPayload(e),t)}sessionPhotoFree(t,e){return this.sessionSet(this.methodSessionPhotoFree(e),t)}sessionVideoCaption(t,e){return this.sessionSet(this.methodSessionVideoCaption(e),t)}sessionVideoCaptionPayload(t,e){return this.sessionSet(this.methodSessionVideoCaptionPayload(e),t)}sessionVideoCaptionCommand(t,e){return this.sessionSet(this.methodSessionVideoCaptionCommand(e),t)}sessionVideoCaptionCommandPayload(t,e){return this.sessionSet(this.methodSessionVideoCaptionCommandPayload(e),t)}sessionVideoFree(t,e){return this.sessionSet(this.methodSessionVideoFree(e),t)}sessionAudioCaption(t,e){return this.sessionSet(this.methodSessionAudioCaption(e),t)}sessionAudioCaptionPayload(t,e){return this.sessionSet(this.methodSessionAudioCaptionPayload(e),t)}sessionAudioCaptionCommand(t,e){return this.sessionSet(this.methodSessionAudioCaptionCommand(e),t)}sessionAudioCaptionCommandPayload(t,e){return this.sessionSet(this.methodSessionAudioCaptionCommandPayload(e),t)}sessionAudioFree(t,e){return this.sessionSet(this.methodSessionAudioFree(e),t)}sessionDocumentCaption(t,e){return this.sessionSet(this.methodSessionDocumentCaption(e),t)}sessionDocumentCaptionPayload(t,e){return this.sessionSet(this.methodSessionDocumentCaptionPayload(e),t)}sessionDocumentCaptionCommand(t,e){return this.sessionSet(this.methodSessionDocumentCaptionCommand(e),t)}sessionDocumentCaptionCommandPayload(t,e){return this.sessionSet(this.methodSessionDocumentCaptionCommandPayload(e),t)}sessionDocumentFree(t,e){return this.sessionSet(this.methodSessionDocumentFree(e),t)}sessionAnimationCaption(t,e){return this.sessionSet(this.methodSessionAnimationCaption(e),t)}sessionAnimationCaptionPayload(t,e){return this.sessionSet(this.methodSessionAnimationCaptionPayload(e),t)}sessionAnimationCaptionCommand(t,e){return this.sessionSet(this.methodSessionAnimationCaptionCommand(e),t)}sessionAnimationCaptionCommandPayload(t,e){return this.sessionSet(this.methodSessionAnimationCaptionCommandPayload(e),t)}sessionAnimationFree(t,e){return this.sessionSet(this.methodSessionAnimationFree(e),t)}sessionVoiceCaption(t,e){return this.sessionSet(this.methodSessionVoiceCaption(e),t)}sessionVoiceCaptionPayload(t,e){return this.sessionSet(this.methodSessionVoiceCaptionPayload(e),t)}sessionVoiceCaptionCommand(t,e){return this.sessionSet(this.methodSessionVoiceCaptionCommand(e),t)}sessionVoiceCaptionCommandPayload(t,e){return this.sessionSet(this.methodSessionVoiceCaptionCommandPayload(e),t)}sessionVoiceFree(t,e){return this.sessionSet(this.methodSessionVoiceFree(e),t)}sessionVideoNoteFree(t,e){return this.sessionSet(this.methodSessionVideoNoteFree(e),t)}sessionStickerFree(t,e){return this.sessionSet(this.methodSessionStickerFree(e),t)}sessionLocationFree(t,e){return this.sessionSet(this.methodSessionLocationFree(e),t)}sessionContactFree(t,e){return this.sessionSet(this.methodSessionContactFree(e),t)}sessionToCallback(t,e){return this.sessionCallback({...this.session.params,...t},e)}sessionToCallbackPayload(t,e){return this.sessionCallbackPayload({...this.session.params,...t},e)}sessionToText(t,e){return this.sessionText({...this.session.params,...t},e)}sessionToTextPayload(t,e){return this.sessionTextPayload({...this.session.params,...t},e)}sessionToTextCommand(t,e){return this.sessionTextCommand({...this.session.params,...t},e)}sessionToTextCommandPayload(t,e){return this.sessionTextCommandPayload({...this.session.params,...t},e)}sessionToTextFree(t,e){return this.sessionTextFree({...this.session.params,...t},e)}sessionToPhotoCaption(t,e){return this.sessionPhotoCaption({...this.session.params,...t},e)}sessionToPhotoCaptionPayload(t,e){return this.sessionPhotoCaptionPayload({...this.session.params,...t},e)}sessionToPhotoCaptionCommand(t,e){return this.sessionPhotoCaptionCommand({...this.session.params,...t},e)}sessionToPhotoCaptionCommandPayload(t,e){return this.sessionPhotoCaptionCommandPayload({...this.session.params,...t},e)}sessionToPhotoFree(t,e){return this.sessionPhotoFree({...this.session.params,...t},e)}sessionToVideoCaption(t,e){return this.sessionVideoCaption({...this.session.params,...t},e)}sessionToVideoCaptionPayload(t,e){return this.sessionVideoCaptionPayload({...this.session.params,...t},e)}sessionToVideoCaptionCommand(t,e){return this.sessionVideoCaptionCommand({...this.session.params,...t},e)}sessionToVideoCaptionCommandPayload(t,e){return this.sessionVideoCaptionCommandPayload({...this.session.params,...t},e)}sessionToVideoFree(t,e){return this.sessionVideoFree({...this.session.params,...t},e)}sessionToAudioCaption(t,e){return this.sessionAudioCaption({...this.session.params,...t},e)}sessionToAudioCaptionPayload(t,e){return this.sessionAudioCaptionPayload({...this.session.params,...t},e)}sessionToAudioCaptionCommand(t,e){return this.sessionAudioCaptionCommand({...this.session.params,...t},e)}sessionToAudioCaptionCommandPayload(t,e){return this.sessionAudioCaptionCommandPayload({...this.session.params,...t},e)}sessionToAudioFree(t,e){return this.sessionAudioFree({...this.session.params,...t},e)}sessionToDocumentCaption(t,e){return this.sessionDocumentCaption({...this.session.params,...t},e)}sessionToDocumentCaptionPayload(t,e){return this.sessionDocumentCaptionPayload({...this.session.params,...t},e)}sessionToDocumentCaptionCommand(t,e){return this.sessionDocumentCaptionCommand({...this.session.params,...t},e)}sessionToDocumentCaptionCommandPayload(t,e){return this.sessionDocumentCaptionCommandPayload({...this.session.params,...t},e)}sessionToDocumentFree(t,e){return this.sessionDocumentFree({...this.session.params,...t},e)}sessionToAnimationCaption(t,e){return this.sessionAnimationCaption({...this.session.params,...t},e)}sessionToAnimationCaptionPayload(t,e){return this.sessionAnimationCaptionPayload({...this.session.params,...t},e)}sessionToAnimationCaptionCommand(t,e){return this.sessionAnimationCaptionCommand({...this.session.params,...t},e)}sessionToAnimationCaptionCommandPayload(t,e){return this.sessionAnimationCaptionCommandPayload({...this.session.params,...t},e)}sessionToAnimationFree(t,e){return this.sessionAnimationFree({...this.session.params,...t},e)}sessionToVoiceCaption(t,e){return this.sessionVoiceCaption({...this.session.params,...t},e)}sessionToVoiceCaptionPayload(t,e){return this.sessionVoiceCaptionPayload({...this.session.params,...t},e)}sessionToVoiceCaptionCommand(t,e){return this.sessionVoiceCaptionCommand({...this.session.params,...t},e)}sessionToVoiceCaptionCommandPayload(t,e){return this.sessionVoiceCaptionCommandPayload({...this.session.params,...t},e)}sessionToVoiceFree(t,e){return this.sessionVoiceFree({...this.session.params,...t},e)}sessionToVideoNoteFree(t,e){return this.sessionVideoNoteFree({...this.session.params,...t},e)}sessionToStickerFree(t,e){return this.sessionStickerFree({...this.session.params,...t},e)}sessionToLocationFree(t,e){return this.sessionLocationFree({...this.session.params,...t},e)}sessionToContactFree(t,e){return this.sessionContactFree({...this.session.params,...t},e)}methodSession(t,e){return`${t}-${e||this.data.name}`}methodSessionCallback(t){return this.methodSession("1",t)}methodSessionCallbackPayload(t){return this.methodSession("2",t)}methodSessionText(t){return this.methodSession("3",t)}methodSessionTextPayload(t){return this.methodSession("4",t)}methodSessionTextCommand(t){return this.methodSession("5",t)}methodSessionTextCommandPayload(t){return this.methodSession("6",t)}methodSessionTextFree(t){return this.methodSession("7",t)}methodSessionPhotoCaption(t){return this.methodSession("8",t)}methodSessionPhotoCaptionPayload(t){return this.methodSession("9",t)}methodSessionPhotoCaptionCommand(t){return this.methodSession("10",t)}methodSessionPhotoCaptionCommandPayload(t){return this.methodSession("11",t)}methodSessionPhotoFree(t){return this.methodSession("12",t)}methodSessionVideoCaption(t){return this.methodSession("13",t)}methodSessionVideoCaptionPayload(t){return this.methodSession("14",t)}methodSessionVideoCaptionCommand(t){return this.methodSession("15",t)}methodSessionVideoCaptionCommandPayload(t){return this.methodSession("16",t)}methodSessionVideoFree(t){return this.methodSession("17",t)}methodSessionAudioCaption(t){return this.methodSession("18",t)}methodSessionAudioCaptionPayload(t){return this.methodSession("19",t)}methodSessionAudioCaptionCommand(t){return this.methodSession("20",t)}methodSessionAudioCaptionCommandPayload(t){return this.methodSession("21",t)}methodSessionAudioFree(t){return this.methodSession("22",t)}methodSessionDocumentCaption(t){return this.methodSession("23",t)}methodSessionDocumentCaptionPayload(t){return this.methodSession("24",t)}methodSessionDocumentCaptionCommand(t){return this.methodSession("25",t)}methodSessionDocumentCaptionCommandPayload(t){return this.methodSession("26",t)}methodSessionDocumentFree(t){return this.methodSession("27",t)}methodSessionAnimationCaption(t){return this.methodSession("28",t)}methodSessionAnimationCaptionPayload(t){return this.methodSession("29",t)}methodSessionAnimationCaptionCommand(t){return this.methodSession("30",t)}methodSessionAnimationCaptionCommandPayload(t){return this.methodSession("31",t)}methodSessionAnimationFree(t){return this.methodSession("32",t)}methodSessionVoiceCaption(t){return this.methodSession("33",t)}methodSessionVoiceCaptionPayload(t){return this.methodSession("34",t)}methodSessionVoiceCaptionCommand(t){return this.methodSession("35",t)}methodSessionVoiceCaptionCommandPayload(t){return this.methodSession("36",t)}methodSessionVoiceFree(t){return this.methodSession("37",t)}methodSessionVideoNoteFree(t){return this.methodSession("38",t)}methodSessionStickerFree(t){return this.methodSession("39",t)}methodSessionLocationFree(t){return this.methodSession("40",t)}methodSessionContactFree(t){return this.methodSession("41",t)}};import{join as L}from"path";import{existsSync as Q,readdirSync as U}from"fs";import{createRequire as gt}from"module";var b=class{static{p(this,"PageManager")}static _getFile(t,e,s=0){let o=Object.values(t)[s];if(o===void 0)throw new Error(`File ${e} must have export (not default) class page`);return o}static getFilePath(){return L(process.cwd(),"src","pages")}static getFileSync(t,e=0){t||(t=this.getFilePath());let n=gt(t)(t);return this._getFile(n,t,e)}static async getFile(t,e=0){t||(t=this.getFilePath());let s=await import(`${t}?t=${Date.now()}`);return this._getFile(s,t,e)}static getFileManySync(t,e=0){if(t||(t=this.getFilePath()),!Q(t))throw new Error(`Directory ${t} is not found, please make it manually`);return U(t).map(n=>{let o=L(t,n);return{path:o,page:this.getFileSync(o,e)}})}static clearCacheRequire(t){if(t||(t=this.getFilePath()),!Q(t))throw new Error(`Directory ${t} is not found, please make it manually`);return U(t).forEach(s=>{let n=L(t,s);delete K.cache[K.resolve(n)]}),!0}};import{readFileSync as Ct}from"fs";import{fileURLToPath as St}from"url";import{dirname as bt,join as Y,parse as Pt}from"path";import{basename as j,join as I,extname as H}from"path";import{readdirSync as ut,readFileSync as D,existsSync as _,statSync as R,writeFileSync as yt}from"fs";import{watch as ft}from"chokidar";var w=class{static{p(this,"TemplateEngine")}static _escape(t){return t.replace(/\\/g,"\\\\").replace(/`/g,"\\`")}static _processVariables(t){return t.replace(/\{\{(\w+)\}\}/g,(e,s)=>`\${(data && data["${s}"]) ?? ""}`)}static _processBaseBlocks(t){let e=/<base\b[^>]*?(?:\sid=(["']?)([^"'\s>]+)\1)?[^>]*?>([\s\S]*?)<\/base>/g,s={};for(let n of t.matchAll(e)){let o=n[2]??"default",i=(n[3]??"").replace(/^[\t ]+/gm,"").replace(/^\n+/,"").replace(/\n+$/,"").trim();s[o]=i}return s}static _processScriptBlocks(t){return t.replace(/<script\b[^>]*>([\s\S]*?)<\/script>/gi,(e,s)=>{let n=s.trim();return n?`\${(() => { if (!data) return ''; try { with(data) { ${n} } } catch(e) { return '' } })()}`:""})}static _processSpaceBlocks(t){return t.replace(/^[ \t]*<space\s*\/>[ \t]*$/gim,"")}static _processDivBlocks(t){return t.replace(/<div>([\s\S]*?)<\/div>/gi,(e,s)=>s.replace(/^[\t ]+/gm,"").replace(/^\n+/,"").replace(/\n+$/,""))}static _processSwitchBlocks(t){let e=/<switch\b(?:\s+value="([^"]+)")?>([\s\S]*?)<\/switch>/gi;return t.replace(e,(s,n,o)=>{if(!n)return"";let a="",i=/<case\b(?:\s+is="([^"]+)")?>([\s\S]*?)<\/case>/gi,r=/<default>([\s\S]*?)<\/default>/gi,c;for(;(c=i.exec(o))!==null;){let d=(c[1]||"").split(",").map(m=>m.trim()),l=(c[2]||"").replace(/^[\t ]+/gm,"").replace(/^\n+/,"").replace(/\n+$/,"").trim().replace(/`/g,"\\`");d.forEach(m=>{a+=`case "${m}": `}),a+=`return \`${l}\`; `}let h=r.exec(o);if(h){let d=(h[1]||"").replace(/^[\t ]+/gm,"").replace(/^\n+/,"").replace(/\n+$/,"").trim();a+=`default: return \`${d}\`; `}else a+="default: return ''; ";return`\${(() => { switch((data && data["${n}"])) { ${a} } })()}`})}static _processExec(t){return t.replace(/{~\s*([\s\S]*?)\s*~}/g,(e,s)=>`\${(() => { try { return ${s} } catch(e) { try { with(data || {}) { return ${s} } } catch(ee) { return '' } } })()}`)}static _processMapBlocks(t){let e=/<map(?:\s+([^>]*))?>([\s\S]*?)<\/map>/gi;return t.replace(e,(s,n,o)=>{let a={},i=/(\w+)="([^"]*)"/g;if(n)for(let l of n.matchAll(i))a[l[1]]=l[2];let r=a.src;if(!r)return"";let c=a.join??"\\n",h=o.replace(/^[\t ]+/gm,"").replace(/^\n+/,"").replace(/\n+$/,"").replace(/`/g,"\\`");h=h.replace(/\{\{([\w.]+)\}\}/g,(l,m)=>m==="e"||m.startsWith("e.")?`\${${m}}`:m==="i"?"${i}":l);let d=c.replace(/"/g,'\\"');return`\${(data && data["${r}"] || []).map((e, i) => \`${h}\`).join("${d}")}`})}static _processMediaBlocks(t){let e=/<media(?:\s+([^>]*))?>([\s\S]*?)<\/media>/gi,s={};for(let n of t.matchAll(e)){let o=n[1],a=n[2],i={},r=/(\w+)="([^"]*)"/g;if(o)for(let m of o.matchAll(r))i[m[1]]=m[2];let c=i.lang||"default",h=i.type,d=a.replace(/^[\t ]+/gm,"").replace(/^\n+/,"").replace(/\n+$/,"").trim(),l={type:h};i.src&&(l.src=i.src),d&&h!=="video_note"&&h!=="sticker"&&(l.caption=d),h==="location"&&(i.latitude&&(l.latitude=i.latitude),i.longitude&&(l.longitude=i.longitude),d&&(l.caption=d)),h==="contact"&&(i.phone&&(l.phone=i.phone),i.first_name&&(l.first_name=i.first_name),i.last_name&&(l.last_name=i.last_name),i.vcard&&(l.vcard=i.vcard),d&&(l.caption=d)),s[c]=l}return s}static _processMessageBlocks(t){let e=/<message(?:\s+([^>]*))?>([\s\S]*?)<\/message>/gi,s={};for(let[,n,o]of t.matchAll(e)){let a={},i=/(\w+)="([^"]*)"/g;if(n)for(let h of n.matchAll(i))a[h[1]]=h[2];let r=a.lang||"default",c=o.replace(/^[\t ]+/gm,"").replace(/^\n+/,"").replace(/\n+$/,"").trim();s[r]=c}return s}static _processDescriptionBlocks(t){let e=/<description(?:\s+([^>]*))?>([\s\S]*?)<\/description>/gi,s={};for(let[,n,o]of t.matchAll(e)){let a={},i=/(\w+)="([^"]*)"/g;if(n)for(let d of n.matchAll(i))a[d[1]]=d[2];let r=a.lang||"default",c=a.scope||"default",h=o.replace(/^[\t ]+/gm,"").replace(/^\n+/,"").replace(/\n+$/,"").trim();s[r]||(s[r]={}),s[r][c]=h}return s}static _processKeyboardBlocks(t){let e=/<keyboard(?:\s+([^>]*))?>([\s\S]*?)<\/keyboard>/gi,s={};for(let[,n,o]of t.matchAll(e)){let a={},i=/(\w+)="([^"]*)"/g;if(n)for(let d of n.matchAll(i))a[d[1]]=d[2];let r=a.lang||"default",c=a.type==="bottom"?"bottom":"inline",h=o.trim();s[r]||(s[r]={}),s[r][c]=h}return s}static _compileToFunction(t,e){let s;e?s=t.map(a=>`\`${a}\``).join(","):s=`\`${t}\``;let n=s;if(n=this._processScriptBlocks(this._processDivBlocks(this._processSpaceBlocks(n))),e){let o=`return [${n}]`;return new Function("data",o)}else{let o=`return ${n}`;return new Function("data",o)}}static compileMedia(t,e){let s=e||this._processBaseBlocks(t),n={};for(let[o,a]of Object.entries(s)){let i=this._processMediaBlocks(a);n[o]={};for(let[r,c]of Object.entries(i)){let h={};for(let[d,l]of Object.entries(c)){if(d==="type"||typeof l!="string")continue;let m=this._processVariables(this._processExec(this._processSwitchBlocks(this._processMapBlocks(this._processScriptBlocks(l)))));h[d]=this._compileToFunction(m,!1)}n[o][r]=d=>{let l={...c};for(let[m,y]of Object.entries(h))l[m]=y(d);return l}}}return n}static compileMessages(t,e){let s=e||this._processBaseBlocks(t),n={};for(let[o,a]of Object.entries(s)){let i=this._processMessageBlocks(a);n[o]={};for(let[r,c]of Object.entries(i)){let h=this._processVariables(this._processExec(this._processSwitchBlocks(this._processMapBlocks(this._processScriptBlocks(c)))));n[o][r]=this._compileToFunction(h,!1)}}return n}static compileDescription(t,e){let s=e||this._processBaseBlocks(t),n={};for(let[o,a]of Object.entries(s)){let i=this._processDescriptionBlocks(a);n[o]={};for(let[r,c]of Object.entries(i))for(let[h,d]of Object.entries(c)){n[o][h]||(n[o][h]={});let l=this._processVariables(this._processExec(this._processSwitchBlocks(this._processMapBlocks(this._processScriptBlocks(d)))));n[o][h][r]=this._compileToFunction(l,!1)}}return n}static compileKeyboards(t,e){let s=e||this._processBaseBlocks(t),n={};for(let[o,a]of Object.entries(s)){let i=this._processKeyboardBlocks(a);n[o]={};for(let[r,c]of Object.entries(i)){n[o][r]={};for(let[h,d]of Object.entries(c)){let m=d.split(/(?<!\\),\s*/).map(y=>y.replace(/\\,/g,",").trim()).map(y=>this._processVariables(this._processExec(this._processSwitchBlocks(this._processMapBlocks(this._processScriptBlocks(y))))));n[o][r][h]=this._compileToFunction(m,!0)}}}return n}static _extractBlock(t,e,s="default",n="all",o){let a=/<base\b[^>]*?(?:\sid=(["']?)([^"'\s>]+)\1)?[^>]*?>([\s\S]*?)<\/base>/g,i=t,r=!1;for(let c of t.matchAll(a))if((c[2]??"default")===s){i=c[3]??"",r=!0;break}if(!r){let c=/<base\b/.test(t);if(!(s==="default"&&!c))return""}if(e){if(e==="all")return i;let c=Array.isArray(e)?e:[e],h=[];for(let l of c){let m=new RegExp(`([ \\t]*)<${l}(?:\\s+([^>]*))?>([\\s\\S]*?)<\\/${l}>`,"gi");for(let y of i.matchAll(m)){let f=y[2];if(o){let g=/lang="([^"]*)"/i,P=f?.match(g);if(((P?P[1]:void 0)||"default")!==o)continue}h.push({start:y.index,content:y[0],innerContent:y[3]??""})}}h.sort((l,m)=>l.start-m.start);let d=p(l=>{let m=l.split(`
2
2
  `);if(m.length<=1)return l.trim();let y=m.filter(g=>g.trim().length>0);if(y.length===0)return"";let f=y.reduce((g,P)=>{let k=P.match(/^([ \t]*)/),T=k?k[1].length:0;return T<g?T:g},1/0);return m.map(g=>g.length>=f?g.slice(f):g.trimStart()).join(`
3
3
  `).trim()},"processResult");return n==="all"?h.map(m=>d(m.content)).join(`
4
4
  `):h.map(m=>d(m.innerContent)).join(`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gramstax",
3
- "version": "0.5.12",
3
+ "version": "0.5.13",
4
4
  "private": false,
5
5
  "publishConfig": {
6
6
  "access": "public",
@@ -10,7 +10,7 @@
10
10
  "keywords": [],
11
11
  "scripts": {
12
12
  "build": "tsup",
13
- "build:docs": "bun run build --tsconfig tsconfig.build.docs.json && api-extractor run --local --verbose && api-documenter markdown -i ./docs/extractor/temp -o ./docs/markdown && api-documenter yaml -i ./docs/extractor/temp -o ./docs/yaml && rm -irf ./dist/gramstax.d.ts",
13
+ "build:docs": "bun run build --dts-only --tsconfig tsconfig.build.docs.json && api-extractor run --local --verbose && api-documenter markdown -i ./docs/extractor/temp -o ./docs/markdown && api-documenter yaml -i ./docs/extractor/temp -o ./docs/yaml && rm -irf ./dist/gramstax.d.ts",
14
14
  "nx-release-publish": "npm publish --access public"
15
15
  },
16
16
  "repository": {