PageSourceSearch

https://10mailbox.com/build/assets/mailbox-tool-BXk1MESv.js

js 10mailbox.com collected 2026-10-04 02:42:00 UTC 25,779 bytes, 3 lines download raw bytes

1const b="modulepreload",w=function(f){return"/build/"+f},M={},T=function(i,a,l){let n=Promise.resolve();if(a&&a.length>0){let o=function(r){return Promise.all(r.map(h=>Promise.resolve(h).then(m=>({status:"fulfilled",value:m}),m=>({status:"rejected",reason:m}))))};var e=o;document.getElementsByTagName("link");const t=document.querySelector("meta[property=csp-nonce]"),s=t?.nonce||t?.getAttribute("nonce");n=o(a.map(r=>{if(r=w(r),r in M)return;M[r]=!0;const h=r.endsWith(".css"),m=h?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${r}"]${m}`))return;const d=document.createElement("link");if(d.rel=h?"stylesheet":b,h||(d.as="script"),d.crossOrigin="",d.href=r,s&&d.setAttribute("nonce",s),document.head.appendChild(d),h)return new Promise((u,y)=>{d.addEventListener("load",u),d.addEventListener("error",()=>y(new Error(`Unable to preload CSS for ${r}`)))})}))}function c(t){const s=new Event("vite:preloadError",{cancelable:!0});if(s.payload=t,window.dispatchEvent(s),!s.defaultPrevented)throw t}return n.then(t=>{for(const s of t||[])s.status==="rejected"&&c(s.reason);return i().catch(c)})};window.tenMailboxApp=function(i,a={}){arguments.length===1&&(a=i||{},i=null);const l={storageKey:"10mailbox_state",pollStorageKey:"10mailbox_last_poll",tenMinutes:600,maxMailboxes:10,maxExtendedSeconds:600,pollIntervalMs:1e4,defaultRequestTimeoutMs:15e3,createRequestTimeoutMs:8e3,...a||{}},n=new E(l,i),c=new S(l),e=new A,t=l.demoMode?()=>T(()=>import("./mailbox-demo-data-_VLzCyjW.js"),[]):null;return C.create({api:n,storage:c,features:e,settings:l,demoModuleLoader:t})};class E{constructor(i,a=null){this.server=a,this.domainsUrl=i.domainsUrl,this.payloadUrl=i.payloadUrl,this.endpoints=i.endpoints,this.defaultTimeoutMs=i.defaultRequestTimeoutMs,this.createTimeoutMs=i.createRequestTimeoutMs,this.payloadCache={}}async getCachedPayload(i,a,l=12e4){const n=this.payloadCache[i],c=Date.now();if(n&&c-n.timestamp<l)return n.payload;const e=await a();return this.payloadCache[i]={payload:e,timestamp:c},e}async loadDomains(){if(this.server?.getDomains)return this.normalizeDomains(await this.server.getDomains());if(!this.domainsUrl)throw new Error("Temporary email domains are not configured.");const i=await this.fetchWithRetry(this.domainsUrl,{headers:{Accept:"application/json"}}),a=await this.parseResponse(i),l=this.normalizeDomains(a?.data?.domains);if(a?.status!=="success"||l.length===0)throw new Error(a?.message||"Unable to load temporary email domains.");return l}normalizeDomains(i){const a=(Array.isArray(i)?i:[]).map(l=>String(l).trim().toLowerCase()).filter(l=>/^[a-z0-9.-]+\.[a-z]{2,}$/.test(l));if(a.length===0)throw new Error("No usable temporary email domains were returned.");return a}async createMailbox(i,a,l=null,n={}){const c=await this.createMailboxPayload(i,a,l);if(c&&c.error){const t=new Error(c.message||c.type);throw t.type=c.type,t}const e=await this.fetchWithRetry(c.url,{method:c.method||"GET",headers:{Accept:"application/json"}},{timeoutMs:this.createTimeoutMs,...n});return this.parseResponse(e)}async fetchInbox(i,a=!1,l={}){typeof a=="object"&&(l=a,a=!1);const n=await this.inboxPayload(i);let c=n.url;a&&(c+=(c.includes("?")?"&":"?")+"reload=true");const e=await this.fetchWithRetry(c,{method:n.method||"GET",headers:{Accept:"application/json"}},l);return this.parseResponse(e)}async fetchInboxes(i,a=!1,l={}){typeof a=="object"&&(l=a,a=!1);const n=await this.inboxsPayload(i);let c=n.url;a&&(c+=(c.includes("?")?"&":"?")+"reload=true");const e=await this.fetchWithRetry(c,{method:n.method||"GET",headers:{Accept:"application/json"}},l);return this.parseResponse(e)}async fetchMessage(i,a,l={}){const n=await this.messagePayload(i,a),c=await this.fetchWithRetry(n.url,{method:n.method||"GET",headers:{Accept:"application/json"}},l);return this.parseResponse(c)}async createAttachmentPayload(i){return this.getCachedPayload(`attachment:${i}`,async()=>this.server?.attachmentPayload?this.server.attachmentPayload(i):this.createSignedPayload(this.endpoints?.attachments,{file_id:i}),3e4)}async createMailboxPayload(i,a,l=null){return this.server?.createMailboxPayload?this.server.createMailboxPayload(i,a,l):this.createSignedPayload(this.endpoints?.create,{email:i,expiry_minutes:a,token:l})}async inboxPayload(i){return this.getCachedPayload(`inbox:${i}`,async()=>this.server?.inboxPayload?this.server.inboxPayload(i):this.createSignedPayload(this.endpoints?.inbox,{email:i}),3e4)}async inboxsPayload(i){return this.getCachedPayload(`inboxs:${i}`,async()=>this.server?.inboxsPayload?this.server.inboxsPayload(i):this.createSignedPayload(this.endpoints?.inboxs,{emails:i}),3e4)}async messagePayload(i,a){return this.getCachedPayload(`message:${i}:${a}`,async()=>this.server?.messagePayload?this.server.messagePayload(i,a):this.createSignedPayload(this.endpoints?.message,{email:i,mid:a}),3e4)}async callSignedApi(i,a,l={}){const n=await this.createSignedPayload(i,a),c=await this.fetchWithRetry(n.url,{method:n.method||"GET",headers:{Accept:"application/json"}},l);return this.parseResponse(c)}async createSignedPayload(i,a){if(!i||!this.payloadUrl)throw new Error("Signed API payload generation is not configured.");const l=await this.fetchWithRetry(this.payloadUrl,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({endpoint:i,params:a})}),n=await this.parseResponse(l);if(n?.status!=="success"||!n?.data)throw new Error(n?.message||"Cannot create signed API payload.");return n.data}async fetchWithRetry(i,a={},l={}){const n=typeof l=="number"?{retries:l}:l,c=n.retries??1,e=n.timeoutMs??this.defaultTimeoutMs;for(let t=0;t<=c;t++){const s=new AbortController,o=setTimeout(()=>s.abort(),e);try{const r=await fetch(i,{...a,signal:s.signal});return clearTimeout(o),r}catch(r){if(clearTimeout(o),t<c&&this.isNetworkError(r)){await new Promise(h=>setTimeout(h,1500*(t+1)));continue}throw r}}}isNetworkError(i){if(i?.name==="AbortError"||i instanceof TypeError)return!0;const a=String(i?.message||"").toLowerCase();return a.includes("networkerror")||a.includes("network")||a.includes("failed to fetch")||a.includes("load failed")}async parseResponse(i){const l=(i.headers.get("content-type")||"").includes("application/json")?await i.json():await i.text();if(!i.ok){const n=typeof l=="string"?l:l?.message;throw new Error(n||`Request failed with status ${i.status}.`)}return l}errorMessage(i,a){return i?.name==="AbortError"?"Request timed out. Please try again.":i instanceof TypeError?"Network request failed. Please try again.":i?.message||a}}class S{constructor(i){this.stateKey=i.storageKey,this.pollKey=i.pollStorageKey}save({mailboxes:i,activeBox:a}){try{const l=i.map(n=>({email:n.email,expiresAt:n._expiresAt||0,duration:n.duration||600,messages:(n.messages||[]).map(c=>({id:c.id,sender:c.sender,subject:c.subject,snippet:c.snippet,date:c.date,body:c.body||"",bodyLoaded:c.bodyLoaded||!1,otp:c.otp||null,verifyLink:c.verifyLink||null,attachments:c.attachments||[]}))}));localStorage.setItem(this.stateKey,JSON.stringify({version:1,activeBox:a,mailboxes:l}))}catch{}}load(){try{const i=localStorage.getItem(this.stateKey);if(!i)return null;const a=JSON.parse(i);return!a||a.version!==1||!Array.isArray(a.mailboxes)?null:a}catch{return null}}getLastPollAt(){try{const i=parseInt(localStorage.getItem(this.pollKey)||"0",10);return Number.isFinite(i)?i:0}catch{return 0}}
1touchLastPoll(i=Date.now()){try{localStorage.setItem(this.pollKey,i.toString())}catch{}}}class A{detect(i){const a=this.parseContent(i);return this.detectFrom(a.text,a.links)}detectFrom(i,a=[]){const n=[/(?:verification|security|login|one[-\s]?time|otp|passcode|code)[^\d]{0,50}(\d{4,8})/i,/(\d{4,8})[^\d]{0,50}(?:verification|security|login|one[-\s]?time|otp|passcode|code)/i].map(e=>i.match(e)?.[1]).find(Boolean)||null,c=a.find(e=>/(verify|confirm|activate|login|magic|reset|auth)/i.test(e))||a[0]||null;return{otp:n,link:c}}parseContent(i){const a=String(i||""),l=new Set,n=new DOMParser().parseFromString(a,"text/html"),c=(n.body.textContent||a).replace(/\s+/g," ").trim();return n.querySelectorAll("a[href]").forEach(e=>{const t=e.getAttribute("href");t&&/^https?:\/\//i.test(t)&&l.add(t)}),a.match(/https?:\/\/[^\s"'<>]+/gi)?.forEach(e=>l.add(e)),{text:c,links:[...l]}}relativeTime(i){if(!i)return"";const a=new Date(i).getTime();if(Number.isNaN(a))return"";const l=Math.max(0,Math.floor((Date.now()-a)/1e3));if(l<60)return"Just now";const n=Math.floor(l/60);if(n<60)return`${n} min${n===1?"":"s"} ago`;const c=Math.floor(n/60);return`${c} hour${c===1?"":"s"} ago`}srcdoc(i){const a=i?.body||"<p>No message body.</p>";return'<!doctype html><meta charset="utf-8"><base target="_blank"><style>'+'body{color:#111827;font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;line-height:1.5;margin:16px}img{max-width:100%;height:auto}a{color:#2563eb}
1'+"</style>"+a}}class C{static create({api:i,storage:a,features:l,settings:n,demoModuleLoader:c=null}){return{api:i,storage:a,features:l,settings:n,demoMode:!!n.demoMode,demoModuleLoader:c,demoStateFactory:null,maxMailboxes:n.maxMailboxes,tenMinutes:n.tenMinutes,maxExtendedSeconds:n.maxExtendedSeconds,pollIntervalMs:n.pollIntervalMs,createRequestTimeoutMs:n.createRequestTimeoutMs,cfCaptchaSiteKey:n.cfCaptchaSiteKey,hasCreatedMailbox:n.hasCreatedMailbox||!1,pendingMailboxAction:null,mailboxes:[],domains:[],activeBox:0,emailCopied:!1,copiedStates:{},selectedMessage:null,globalError:"",inboxFilter:null,hasInitialized:!1,countdownTimer:null,pollTimer:null,storageHandler:null,get currentMailbox(){return this.mailboxes[this.activeBox]||this.emptyMailbox()},get allMessages(){return this.sortMessages(this.mailboxes.flatMap((e,t)=>this.messagesForBox(t)))},get totalMessageCount(){return this.mailboxes.reduce((e,t,s)=>e+this.messageCountForBox(s),0)},get anyInboxError(){return this.mailboxes.find(e=>e.error)?.error||""},get isAnyRefreshing(){return this.mailboxes.some(e=>e.isRefreshing)},get filteredMessageCount(){return this.inboxFilter===null?this.totalMessageCount:this.messageCountForBox(this.inboxFilter)},get filteredMessages(){return this.inboxFilter===null?this.allMessages:this.sortMessages(this.messagesForBox(this.inboxFilter))},get isBusy(){return this.mailboxes.some(e=>e.isCreating)},messageCountForBox(e){return this.mailboxes[e]?.messages?.length||0},mailboxStatusText(e){return e?.email?e.email:e?.isCreating?"Creating inbox...":e?.error?"Inbox creation failed":"No inbox selected"},mailboxStatusClass(e){return e?.error&&!e?.isCreating&&!e?.email?"text-red-600":"text-gray-900"},messagesForBox(e){const t=this.mailboxes[e];return t?(t.messages||[]).map(s=>this.decorateMessage(s,t,e)):[]},decorateMessage(e,t,s){return e._boxIndex=s,e._boxLabel="Inbox "+(s+1),e._boxEmail=t.email,e},sortMessages(e){return[...e].sort((t,s)=>this.messageTimestamp(s)-this.messageTimestamp(t))},messageTimestamp(e){const t=new Date(e?.date||0).getTime();return Number.isNaN(t)?0:t},saveState(){this.storage.save({mailboxes:this.mailboxes,activeBox:this.activeBox})},loadState(){return this.storage.load()},restoreMailbox(e){const t=Date.now(),s=Math.max(0,Math.floor((e.expiresAt-t)/1e3)),o=this.newMailbox();return o.email=e.email||"",o.timeLeft=s,o._expiresAt=e.expiresAt||0,o.duration=e.duration||this.tenMinutes,o.messages=(e.messages||[]).map(r=>({id:r.id,sender:r.sender||"Unknown sender",subject:r.subject||"(No subject)",snippet:r.snippet||"",time:this.relativeTime(r.date),date:r.date||"",body:r.body||"",bodyLoaded:r.bodyLoaded||!1,otp:r.otp||null,verifyLink:r.verifyLink||null,attachments:r.attachments||[],isLoadingBody:!1,error:""})),o},syncFromStorage(e){if(!e||!Array.isArray(e.mailboxes))return;if(this.mailboxes.length!==e.mailboxes.length||e.mailboxes.some((s,o)=>!this.mailboxes[o]||this.mailboxes[o].email!==s.email)){this.mailboxes=e.mailboxes.map(s=>this.restoreMailbox(s)),this.activeBox=Math.min(this.activeBox,Math.max(0,this.mailboxes.length-1)),this.inboxFilter!==null&&this.inboxFilter>=this.mailboxes.length&&(this.inboxFilter=null),this.selectedMessage&&!this.mailboxes.some(s=>s.messages.some(o=>o.id===this.selectedMessage.id))&&(this.selectedMessage=null);return}e.mailboxes.forEach((s,o)=>{const r=this.mailboxes[o];r._expiresAt=s.expiresAt||0;const h=new Map(r.messages.map(m=>[m.id,m]));if(r.messages=(s.messages||[]).map(m=>{const d=h.get(m.id)||{};return{id:m.id,sender:m.sender||"Unknown sender",subject:m.subject||"(No subject)",snippet:m.snippet||"",time:this.relativeTime(m.date),date:m.date||"",body:m.body||d.body||"",bodyLoaded:m.bodyLoaded||d.bodyLoaded||!1,otp:m.otp||d.otp||null,verifyLink:m.verifyLink||d.verifyLink||null,attachments:m.attachments||d.attachments||[],isLoadingBody:d.isLoadingBody||!1,error:d.error||"",_boxIndex:o,_boxLabel:"Inbox "+(o+1),_boxEmail:r.email}}),this.selectedMessage&&this.selectedMessage._boxIndex===o){const m=r.messages.find(d=>d.id===this.selectedMessage.id);m&&(this.selectedMessage=m)}})},async init(){if(this.hasInitialized)return;if(this.hasInitialized=!0,this.demoMode){await this.resetDemoState(),this.startTimer(),this.startPolling();return}this.storageHandler=t=>{if(t.key===this.storage.stateKey){const s=this.loadState();s&&this.syncFromStorage(s)}},window.addEventListener("storage",this.storageHandler);const e=this.loadState();if(e&&e.mailboxes.length>0){const t=Date.now(),s=e.mailboxes.filter(o=>o.email&&o.expiresAt-t>0);if(s.length>0){this.mailboxes=s.map(o=>this.restoreMailbox(o)),this.activeBox=Math.min(e.activeBox||0,this.mailboxes.length-1),this.startTimer(),this.startPolling(),await this.refreshAllInboxes(!0);return}}this.startTimer(),await this.addMailbox(),this.startPolling()}
1,async loadDemoModule(){if(!(this.demoStateFactory||!this.demoModuleLoader))try{const e=await this.demoModuleLoader();this.api=new e.TenMailboxDemoApi(this.settings),this.demoStateFactory=e.createTenMailboxDemoState}catch(e){console.error("Failed to load mailbox demo data:",e),this.globalError="Unable to load screenshot data."}},async resetDemoState(){if(await this.loadDemoModule(),!this.demoStateFactory)return;typeof this.api.resetState=="function"&&this.api.resetState();const e=this.demoStateFactory({now:Date.now(),tenMinutes:this.tenMinutes});this.mailboxes=e.mailboxes.map(t=>this.restoreMailbox(t)),this.activeBox=Math.min(e.activeBox||0,Math.max(0,this.mailboxes.length-1)),this.inboxFilter=e.inboxFilter??null,this.selectedMessage=null,this.globalError="",this.emailCopied=!1,this.copiedStates={},this.saveState()},destroy(){this.countdownTimer&&(clearInterval(this.countdownTimer),this.countdownTimer=null),this.pollTimer&&(clearInterval(this.pollTimer),this.pollTimer=null),this.storageHandler&&(window.removeEventListener("storage",this.storageHandler),this.storageHandler=null)},startTimer(){this.countdownTimer&&clearInterval(this.countdownTimer);const e=()=>this.mailboxes.forEach(t=>this.syncMailboxTime(t));e(),this.countdownTimer=setInterval(e,1e3)},startPolling(){this.pollTimer&&clearInterval(this.pollTimer),this.pollTimer=setInterval(()=>this.refreshAllInboxes(!0),this.pollIntervalMs)},syncMailboxTime(e){if(e._expiresAt){e.timeLeft=Math.max(0,Math.ceil((e._expiresAt-Date.now())/1e3));return}e.timeLeft>0&&e.timeLeft--},formatTime(e){const t=Math.floor(e/60),s=e%60;return`${t.toString().padStart(2,"0")}:${s.toString().padStart(2,"0")}`},async extendMailboxTime(e,t="reset"){if(!(!e||!e.email||e.isCreating)){e.isCreating=!0,e.error="";try{if(t==="reset"){await this.api.createMailbox(e.email,0,null,{retries:0,timeoutMs:this.createRequestTimeoutMs});const s=e.duration||600;e.timeLeft=s,e._expiresAt=Date.now()+s*1e3}else{const s=Math.ceil(t/60);await this.api.createMailbox(e.email,s,null,{retries:0,timeoutMs:this.createRequestTimeoutMs});const r=Math.max(0,Math.ceil((e._expiresAt-Date.now())/1e3))+t;e.timeLeft=r,e._expiresAt=Date.now()+r*1e3}this.saveState()}catch(s){e.error=this.errorMessage(s,"Unable to extend this mailbox.")}finally{e.isCreating=!1}}},async extendTime(e="reset"){await this.extendMailboxTime(this.currentMailbox,e)},async changeEmail(){const e=this.activeBox,t=this.mailboxes[e]||this.currentMailbox;await this.executeChangeEmail(t,e)},async executeChangeEmail(e,t,s=null){const o=await this.createMailbox(e,t,s);o?.email&&await this.refreshInbox(o,!0)},async addMailbox(){this.mailboxes.length>=this.maxMailboxes||this.isBusy||await this.executeAddMailbox()},async executeAddMailbox(e=null){const t=this.mailboxes.length,s=this.newMailbox();this.mailboxes.push(s),this.activeBox=t,this.inboxFilter=t;const o=await this.createMailbox(s,t,e);o?.email&&await this.refreshInbox(o,!0)},selectMailbox(e){this.activeBox=e,this.inboxFilter=e,this.saveState()},async deleteMailbox(){const e=this.activeBox,t=this.mailboxes[e];if(t){if(t.email){t.isCreating=!0;try{await this.api.createMailbox(t.email,-1,null,{retries:0,timeoutMs:this.createRequestTimeoutMs})}catch(s){console.error("Failed to delete mailbox on server:",s)}finally{t.isCreating=!1}}if(this.selectedMessage&&this.selectedMessage._boxIndex===e&&(this.selectedMessage=null),this.mailboxes.splice(e,1),this.mailboxes.length===0){this.activeBox=0,this.inboxFilter=null,await this.addMailbox();return}this.activeBox=Math.min(this.activeBox,this.mailboxes.length-1),this.inboxFilter=null,this.saveState()}},emptyMailbox(){return{email:"",timeLeft:this.tenMinutes,messages:[],isCreating:!0,isRefreshing:!1,error:""}},newMailbox(){return{email:"",timeLeft:this.tenMinutes,_expiresAt:0,duration:this.tenMinutes,messages:[],isCreating:!1,isRefreshing:!1,error:""}},updateMailbox(e,t,s=null){const o=Number.isInteger(s)?s:this.mailboxes.indexOf(e);return o<0||o>=this.mailboxes.length?(Object.assign(e,t),e):(this.mailboxes.splice(o,1,{...e,...t}),this.mailboxes[o])},async createMailbox(e,t=null,s=null){e=this.updateMailbox(e,{isCreating:!0,error:"",messages:[]},t),this.selectedMessage=null;try{await this.loadDomains();const o=this.generateEmail();return await this.api.createMailbox(o,10,s,{retries:0,timeoutMs:this.createRequestTimeoutMs}),e=this.updateMailbox(e,{email:o,timeLeft:this.tenMinutes,_expiresAt:Date.now()+this.tenMinutes*1e3,isCreating:!1,error:""},t),this.globalError="",this.saveState(),e}catch(o){const r=String(o?.message||"").toUpperCase(),h=String(o?.type||"").toUpperCase();if(r.includes("CAPTCHA_REQUIRED")||r.includes("RATE_LIMIT_EXCEEDED")||r.includes("429")||r.includes("400")||r.includes("LIMIT")||r.includes("TOO MANY")||h.includes("CAPTCHA_REQUIRED")||h.includes("RATE_LIMIT_EXCEEDED")){if(r.includes("RATE_LIMIT_EXCEEDED")||r.includes("LIMIT")||r.includes("TOO MANY")||h.includes("RATE_LIMIT_EXCEEDED")){const u="Too many email creations. Please try again in 10 minutes.";return e=this.updateMailbox(e,{isCreating:!1,error:u},t),this.globalError=u,e}return t!==null&&!e.email&&this.mailboxes.splice(t,1),this.pendingMailboxAction=e.email?{type:"change",box:e,index:t}:{type:"add"},this.openCaptchaModal(),e.isCreating=!1,e}const d=this.errorMessage(o,"Unable to create a real mailbox.");return e=this.updateMailbox(e,{isCreating:!1,error:d},t),this.globalError=d,e}},async loadDomains(){this.domains.length>0||(this.domains=await this.api.loadDomains())},generateEmail(){const e=this.domains[Math.floor(Math.random()*this.domains.length)];return`mail${this.randomToken(10)}@${e}`},randomToken(e){const t="abcdefghijklmnopqrstuvwxyz0123456789",s=new Uint8Array(e);return crypto.getRandomValues(s),Array.from(s,o=>t[o%t.length]).join("")},async refreshAllInboxes(e=!0){if(e){const r=this.storage.getLastPollAt();if(Date.now()-r<this.pollIntervalMs-2e3)return}
1this.storage.touchLastPoll();const t=this.mailboxes.filter(r=>r.email&&r.timeLeft>0&&!r.isRefreshing);if(t.length===0)return;t.forEach(r=>{r.isRefreshing=!0,e||(r.error="")});const s=t.map(r=>r.email).join(","),o=!e;try{const r=await this.api.fetchInboxes(s,o);t.forEach(h=>{const m=r?.[h.email]||r?.inboxes?.[h.email]||r?.messages?.[h.email],d=Array.isArray(m)?m:Array.isArray(m?.messages)?m.messages:[],u=new Map(h.messages.map(p=>[p.id,p])),y=d.map(p=>this.normalizeMessage(p,u.get(p.mid)));if(h.messages=this.sortMessages(y),o){const p=h.duration||600;h.timeLeft=p,h._expiresAt=Date.now()+p*1e3}if(this.selectedMessage){const p=this.mailboxes.indexOf(h);if(this.selectedMessage._boxIndex===p){const g=h.messages.find(x=>x.id===this.selectedMessage.id);g&&(g._boxIndex=p,g._boxLabel="Inbox "+(p+1),g._boxEmail=h.email,this.selectedMessage=g)}}this.hydrateNewMessages(h),h.error=""}),this.saveState()}catch(r){t.forEach(h=>{e&&this.isNetworkError(r)||(!e||h.messages.length===0)&&(h.error=this.errorMessage(r,"Unable to refresh this inbox."))})}finally{t.forEach(r=>{r.isRefreshing=!1})}},async refreshInbox(e,t=!0){if(!e.email||e.timeLeft<=0||e.isRefreshing)return;e.isRefreshing=!0,t||(e.error="");const s=!t;try{const o=await this.api.fetchInbox(e.email,s),r=Array.isArray(o?.messages)?o.messages:[],h=new Map(e.messages.map(d=>[d.id,d])),m=r.map(d=>this.normalizeMessage(d,h.get(d.mid)));if(e.messages=this.sortMessages(m),s){const d=e.duration||600;e.timeLeft=d,e._expiresAt=Date.now()+d*1e3}if(this.selectedMessage){const d=this.mailboxes.indexOf(e);if(this.selectedMessage._boxIndex===d){const u=e.messages.find(y=>y.id===this.selectedMessage.id);u&&(u._boxIndex=d,u._boxLabel="Inbox "+(d+1),u._boxEmail=e.email,this.selectedMessage=u)}}await this.hydrateNewMessages(e),e.error="",this.saveState()}catch(o){if(t&&this.isNetworkError(o))return;(!t||e.messages.length===0)&&(e.error=this.errorMessage(o,"Unable to refresh this inbox."))}finally{e.isRefreshing=!1}},normalizeMessage(e,t={}){const s=String(e.mid||t.id||this.randomToken(12)),o=t.body||"",r=this.detectUsefulParts(String(e.textSubject||"")+`
2`+o);return{id:s,sender:e.textFrom||t.sender||"Unknown sender",subject:e.textSubject||t.subject||"(No subject)",snippet:t.snippet||"Click to read this email.",time:this.relativeTime(e.textDate||t.date),date:e.textDate||t.date||"",attachments:e.attachments||t.attachments||[],body:o,bodyLoaded:t.bodyLoaded||!1,otp:t.otp||r.otp,verifyLink:t.verifyLink||r.link,isLoadingBody:!1,error:""}},async hydrateNewMessages(e){const t=e.messages.filter(s=>!s.bodyLoaded&&!s.isLoadingBody).slice(0,5);await Promise.allSettled(t.map(s=>this.loadMessageBody(e,s)))},async openMessage(e){this.selectedMessage=e,this.openMailboxMessageModal();const t=this.mailboxes[e._boxIndex];t&&await this.loadMessageBody(t,e)},closeMessage(){this.selectedMessage=null,this.closeMailboxMessageModal()},openCaptchaModal(){const e=this.modalStore();e&&e.open("mailboxCaptchaModal"),this.$nextTick(async()=>{try{const t=await this.loadTurnstile(),s=document.getElementById("mailbox-create-turnstile-widget");if(s){s.innerHTML="";const o=document.createElement("div");s.appendChild(o),t.render(o,{sitekey:this.cfCaptchaSiteKey,callback:r=>{this.closeCaptchaModal(),this.handleCaptchaSuccess(r)},"error-callback":()=>{this.closeCaptchaModal(),this.globalError="Verification failed. Please try again."}})}}catch(t){console.error("Failed to load Turnstile:",t),this.closeCaptchaModal(),this.globalError="Failed to load CAPTCHA widget. Please try again."}})},closeCaptchaModal(){const e=this.modalStore();e&&e.close("mailboxCaptchaModal");const t=document.getElementById("mailbox-create-turnstile-widget");t&&(t.innerHTML="")},async handleCaptchaSuccess(e){if(!this.pendingMailboxAction)return;const t=this.pendingMailboxAction;this.pendingMailboxAction=null,t.type==="add"?await this.executeAddMailbox(e):t.type==="change"&&await this.executeChangeEmail(t.box,t.index,e)},async loadTurnstile(){return window.turnstile?window.turnstile:this._turnstilePromise?this._turnstilePromise:(this._turnstilePromise=new Promise((e,t)=>
2{const s=document.createElement("script");s.src="https://challenges.cloudflare.com/turnstile/v0/api.js?render=explicit",s.async=!0,s.defer=!0,s.onload=()=>e(window.turnstile),s.onerror=o=>{this._turnstilePromise=null,t(o)},document.head.appendChild(s)}),this._turnstilePromise)},modalStore(){return this.$store?.modals||window.Alpine?.store?.("modals")||null},openMailboxMessageModal(){const e=this.modalStore();e&&e.open("mailboxMessageModal")},closeMailboxMessageModal(){const e=this.modalStore();e&&e.close("mailboxMessageModal")},async loadMessageBody(e,t){if(!(!e.email||!t?.id||t.isLoadingBody||t.bodyLoaded)){t.isLoadingBody=!0,t.error="";try{const s=await this.api.fetchMessage(e.email,t.id),o=typeof s?.body=="string"?s.body:"",r=this.parseMessageContent(o),h=this.detectUsefulPartsFrom(String(t.subject||"")+`
3`+r.text,r.links);t.body=o,t.bodyLoaded=!0,t.attachments=Array.isArray(s?.attachments)?s.attachments:t.attachments,t.snippet=r.text.slice(0,160)||t.snippet,t.otp=h.otp,t.verifyLink=h.link,this.saveState()}catch(s){t.error=this.errorMessage(s,"Unable to load this message.")}finally{t.isLoadingBody=!1}}},async downloadAttachment(e){if(!e?.id)return;const t=await this.api.createAttachmentPayload(e.id);window.open(t.url,"_blank","noopener")},isNetworkError(e){return this.api.isNetworkError(e)},detectUsefulParts(e){return this.features.detect(e)},detectUsefulPartsFrom(e,t=[]){return this.features.detectFrom(e,t)},parseMessageContent(e){return this.features.parseContent(e)},relativeTime(e){return this.features.relativeTime(e)},messageSrcdoc(e){return this.features.srcdoc(e)},async copyText(e,t){if(e){if(navigator.clipboard?.writeText)await navigator.clipboard.writeText(e);else{const s=document.createElement("textarea");s.value=e,s.setAttribute("readonly",""),s.style.position="absolute",s.style.left="-9999px",document.body.appendChild(s),s.select(),document.execCommand("copy"),s.remove()}t==="emailCopied"?(this.emailCopied=!0,setTimeout(()=>this.emailCopied=!1,2e3)):(this.copiedStates[t]=!0,setTimeout(()=>this.copiedStates[t]=!1,2e3))}},errorMessage(e,t){return this.api.errorMessage(e,t)}}}}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.