(function () { 'use strict'; const configuration=document.querySelector('script[data-vault-site]'); if(!configuration)return; const site=configuration.dataset.vaultSite; if(!['brawnyai','brwnyxxx'].includes(site))return; const endpoint='/bridge/downloads/'+site; const vault=site==='brwnyxxx'?'/secret-vault/':'/mightypros-secret-vault/'; const guide=document.querySelector('[data-vault-guide]'); const helpOnly=configuration.dataset.vaultMode==='help'; const pending=new Set(); let selected=null; const codes={ sign_in_required:'Your sign-in has expired or is missing. Sign in on this website, then return to this file.', access_required:'This collection needs 💪MightyPro access. If you already have a membership, check the account you are signed in with.', session_service_unavailable:'We could not check your membership right now. Please try again; you do not need to create another account.', download_service_unavailable:'The download service is temporarily unavailable. Your collection is still here. Please try again shortly.', diagnostics_unavailable:'The download service could not finish preparing this request. Please try again shortly.', file_unavailable:'This file is currently unavailable. You can report it below or keep browsing online.', file_updated:'This file has changed and needs to be checked. Please try again later or send us its details.', rate_limited:'Several requests arrived close together. Please wait before trying this file again.', request_in_progress:'An earlier request for this file is still being checked. Please wait a moment.', request_already_used:'This request has already been handled. Choose Try again to request a fresh download link.', request_conflict:'The selected file changed during this request. Choose Try again to start a fresh request.', authorization_expired:'This download authorization has expired. Choose Try again for a fresh link to this file.', network_unconfirmed:'We could not confirm whether the download request finished. Check your browser’s downloads, then try again if needed.', preview_ready:'Preview only. Your selected download is ready in this simulation; no file has been downloaded.', link_ready:'Download requested. Check your browser’s downloads for progress. When it finishes, extract the ZIP or open the PDF.' }; function identifier(){return window.crypto&&crypto.randomUUID?crypto.randomUUID():'request-'+Date.now()+'-'+Math.random().toString(16).slice(2);} function text(tag,value,className){const node=document.createElement(tag);node.textContent=value;if(className)node.className=className;return node;} function isFile(value){return /^f[a-f0-9]{24}$/.test(value||'');} async function stableId(value,prefix='f'){ const digest=await crypto.subtle.digest('SHA-256',new TextEncoder().encode(site+':'+value)); return prefix+Array.from(new Uint8Array(digest),b=>b.toString(16).padStart(2,'0')).join('').slice(0,24); } async function bindExistingDownloads(){ // Keep Ghost's original buttons and content. The verified August block // carries its own mapping; older object keys retain their stable IDs. const mapped=new Map(),seen=new Map(); for(const script of document.querySelectorAll('script[data-vault-legacy-bindings]')){ for(const record of JSON.parse(script.textContent))mapped.set(record.object_key,record); } let release=document.querySelector('.gh-article-title')?.textContent.trim()||'',part=''; const scope=document.querySelector('.gh-content.gh-canvas'); if(!scope)return; for(const node of scope.querySelectorAll('h2,h3,a.secure-dl[data-file]')){ if(node.matches('h2,h3')){ if(node.matches('h2')||/^[🔒🤫]/u.test(node.textContent.trim())){release=node.textContent;part='';} else part=node.textContent.trim(); continue; } if(node.closest('[data-vault-file]'))continue; const key=node.dataset.file,known=mapped.get(key),fid=known?.file_id||await stableId(key); const rid=known?.release_id||await stableId(release,'r'); if(!isFile(fid)||!/^r[a-f0-9]{24}$/.test(rid))throw Error('Invalid vault mapping'); const count=(seen.get(fid)||0)+1;seen.set(fid,count); let card=node.closest('.kg-button-card'); if(!card){card=document.createElement('div');node.before(card);card.append(node);} card.classList.add('vault-legacy-file'); // An ID on the native card changes Ghost's heading-spacing rules. // Put the return anchor on its existing link instead. node.id='download-'+fid+(count>1?'-'+count:''); Object.assign(card.dataset,{vaultFile:fid,vaultRelease:rid,vaultReleaseTitle:known?.release_title||release, vaultFilename:known?.filename||key.split('/').pop(),vaultLabel:known?.label||release+' · '+part,vaultAnchor:node.id}); node.dataset.vaultDownload=''; const box=text('div','','vault-file-feedback');box.dataset.vaultFeedback='';box.hidden=true;box.setAttribute('aria-live','polite');card.append(box); } } const controlsReady=helpOnly?Promise.resolve():bindExistingDownloads(); function currentContext(card){ return {file_id:card.dataset.vaultFile,release_id:card.dataset.vaultRelease, release_title:card.dataset.vaultReleaseTitle||'', filename:card.dataset.vaultFilename||card.querySelector('[data-vault-filename]')?.textContent||'', label:card.dataset.vaultLabel||card.querySelector('h3')?.textContent||'',request_id:card.dataset.vaultRequest||'', result_code:card.dataset.vaultOutcome||'not_requested',return_to:vault+'#'+(card.dataset.vaultAnchor||card.id)}; } function remember(context){ selected=context; const url=new URL(location.href); url.searchParams.set('view',context.file_id); if(context.release_id)url.searchParams.set('collection',context.release_id); if(!guide)url.hash=context.return_to.split('#')[1]||'download-'+context.file_id; history.replaceState({},'',url.pathname+url.search+url.hash); try {sessionStorage.setItem('brawny_vault_selection_'+site,JSON.stringify({file_id:context.file_id, release_id:context.release_id,request_id:context.request_id,result_code:context.result_code,at:Date.now()}));} catch(_){/* Navigation still preserves safe file identifiers. */} } function track(context,event){ if(helpOnly)return; if(!context||!isFile(context.file_id))return; fetch(endpoint+'/event',{method:'POST',credentials:'same-origin',headers:{'Content-Type':'application/json'}, body:JSON.stringify({file_id:context.file_id,request_id:context.request_id||identifier(),event}),keepalive:true}).catch(()=>{}); } function helpDetails(context=selected){ const description=document.querySelector('#vault-error-description')?.value.trim()||''; return ["Download help — "+(site==='brwnyxxx'?'BrwnyXXX':'BrawnyAi'), 'File: '+(context?.filename||'Please add the filename'), 'Release: '+(context?.release_title||context?.release_id||'Please add the release'), 'Request reference: '+(context?.request_id||'Not available'), 'Observed result: '+(context?.result_code||'Not available'), 'Browser/device: '+navigator.userAgent.slice(0,300), 'What happened: '+(description||'Please describe the message your device shows.'), 'A website request does not confirm a completed download or an opened archive.'].join('\n'); } function mailto(context){return 'mailto:support@brawny.ai?subject='+encodeURIComponent('Download help — '+(context?.filename||'Secret Vault'))+'&body='+encodeURIComponent(helpDetails(context));} async function copy(value,status,selectable){ try {await navigator.clipboard.writeText(value);status.textContent='Copied.';} catch(_){ selectable.hidden=false;selectable.textContent=value;selectable.focus(); const range=document.createRange();range.selectNodeContents(selectable); const selection=window.getSelection();selection.removeAllRanges();selection.addRange(range); status.textContent='Select the text and copy it.'; } } function actionLink(label,href,portal){const link=text('a',label);link.href=href;if(portal)link.dataset.memberPortal=portal;return link;} function feedback(card,code,retry=0){ card.dataset.vaultOutcome=code; const context=currentContext(card);remember(context); const box=card.querySelector('[data-vault-feedback]');box.hidden=false;box.replaceChildren(text('p',codes[code]||codes.download_service_unavailable)); if(code==='link_ready'||code==='preview_ready')return; const actions=text('div','','vault-feedback-actions'); if(code==='sign_in_required')actions.append(actionLink('Sign in again','#/portal/signin','signin')); if(code==='access_required'||code==='sign_in_required') { if(site==='brwnyxxx') { const claim=new URL('https://brawny.ai/claim-side-door/');claim.searchParams.set('source','brwnyxxx'); claim.searchParams.set('return_to',location.pathname+location.search+location.hash); actions.append(actionLink('Connect my membership',claim.href)); }else if(code==='access_required')actions.append(actionLink('See 💪MightyPro membership','/become-a-mightypro-today/')); } if(code!=='access_required') { const button=text('button','Try again');button.type='button';button.dataset.vaultRetry=''; let left=Math.min(120,Math.max(0,Number(retry)||0)); if(left){button.disabled=true;button.textContent='Try again in '+left+'s';const timer=setInterval(()=>{ if(!button.isConnected){clearInterval(timer);return;}left--;button.textContent=left?'Try again in '+left+'s':'Try again';button.disabled=left>0;if(!left)clearInterval(timer); },1000);} actions.append(button); } const email=actionLink('Email support',mailto(context));email.dataset.vaultSupportEmail='';actions.append(email); const copyButton=text('button','Copy help details');copyButton.type='button';copyButton.dataset.vaultCopyHelp='';actions.append(copyButton); const status=text('span','','vault-copy-status');status.dataset.vaultCopyStatus='';status.setAttribute('role','status'); const details=text('pre','','vault-help-details');details.dataset.vaultHelpDetails='';details.hidden=true;details.tabIndex=0; box.append(actions,status,details); } async function download(card){ const fid=card.dataset.vaultFile; if(!isFile(fid)||pending.has(fid))return; pending.add(fid);card.dataset.vaultRequest=identifier();card.dataset.vaultOutcome='checking'; const button=card.querySelector('[data-vault-download]'),originalLabel=button.textContent; button.setAttribute('aria-disabled','true');button.textContent='Checking access…'; const box=card.querySelector('[data-vault-feedback]');box.hidden=false;box.replaceChildren(text('p','Checking your membership and preparing this file…')); remember(currentContext(card)); const abort=new AbortController();const timer=setTimeout(()=>abort.abort(),30000); try { const response=await fetch(endpoint+'/authorize',{method:'POST',credentials:'same-origin',signal:abort.signal, headers:{'Content-Type':'application/json'},body:JSON.stringify({file_id:fid,request_id:card.dataset.vaultRequest,collection:card.dataset.vaultRelease})}); const data=await response.json(); if(!data||typeof data.result_code!=='string')throw Error('invalid_response'); if(data.request_id&&/^[A-Za-z0-9_-]{8,80}$/.test(data.request_id))card.dataset.vaultRequest=data.request_id; if(response.ok&&data.result_code==='link_ready') { const url=new URL(data.download_url); if(url.protocol!=='https:'||url.hostname!=='cryogenics.tor1.digitaloceanspaces.com')throw Error('invalid_destination'); if(configuration.dataset.vaultPreview==='true'){feedback(card,'preview_ready');return;} feedback(card,'link_ready');track(currentContext(card),'download_handoff'); location.assign(url.href); }else feedback(card,data.result_code,data.retry_after_seconds); }catch(_){feedback(card,'network_unconfirmed');} finally {clearTimeout(timer);pending.delete(fid);button.removeAttribute('aria-disabled');button.textContent=originalLabel;} } document.addEventListener('click',async function(event){ const downloadButton=event.target.closest('[data-vault-download], [data-vault-retry], a.secure-dl[data-file]'); if(downloadButton&&!helpOnly){event.preventDefault();event.stopImmediatePropagation(); try{await controlsReady;}catch(_){downloadButton.after(text('p','We could not prepare this download. Reload the page or contact support@brawny.ai.'));return;} const card=downloadButton.closest('[data-vault-file]');if(!card)return; if(downloadButton.hasAttribute('data-vault-retry'))track(currentContext(card),'retry_clicked');download(card);return;} const passwordButton=event.target.closest('[data-vault-copy-password]'); if(passwordButton){const box=passwordButton.closest('[data-vault-password-group]');const value=box.querySelector('[data-vault-password]');value.tabIndex=0;copy(value.textContent,box.querySelector('[role="status"]'),value);return;} const help=event.target.closest('[data-vault-help]'); if(help){ const rid=help.closest('[data-vault-release-tools]')?.dataset.vaultReleaseTools; const card=help.closest('[data-vault-file]')||Array.from(document.querySelectorAll('[data-vault-file]')).find(c=>c.dataset.vaultRelease===rid); const context=selected?.release_id===rid?selected:card?currentContext(card):null; if(context){remember(context);track(context,'help_opened');const url=new URL(help.href);url.searchParams.set('view',context.file_id);url.searchParams.set('collection',context.release_id);url.hash=context.return_to.split('#')[1];help.href=url.href;} return; } const copyHelp=event.target.closest('[data-vault-copy-help]'); if(copyHelp){const card=copyHelp.closest('[data-vault-file]');const scope=card||guide;const context=card?currentContext(card):selected; track(context,'help_details_copied');copy(helpDetails(context),scope.querySelector('[data-vault-copy-status]'),scope.querySelector('[data-vault-help-details]'));return;} const email=event.target.closest('[data-vault-support-email]');if(email){const card=email.closest('[data-vault-file]');const context=card?currentContext(card):selected;email.href=mailto(context);track(context,'support_draft_prepared');} },true); const query=new URLSearchParams(location.search); const month=query.get('month'); if(guide&&/^20\d{2}-(?:0[1-9]|1[0-2])$/.test(month||'')){ const label=new Intl.DateTimeFormat('en',{month:'long',year:'numeric',timeZone:'UTC'}).format(new Date(month+'-01T12:00:00Z')); selected={release_title:label,result_code:'help_opened'}; for(const back of guide.querySelectorAll('[data-vault-back]')){back.href=vault+'#megadrop-'+month+'-help';back.textContent='← Back to downloads';} } const fileId=isFile(query.get('view'))?query.get('view'):/^#download-(f[a-f0-9]{24})(?:-\d+)?$/.exec(location.hash)?.[1]; controlsReady.then(()=>{if(fileId&&!guide){ const cards=Array.from(document.querySelectorAll('[data-vault-file]')).filter(card=>card.dataset.vaultFile===fileId); const card=cards.find(item=>item.dataset.vaultRelease===query.get('collection'))||cards[0]; if(card){ card.classList.add('is-selected'); try { const saved=JSON.parse(sessionStorage.getItem('brawny_vault_selection_'+site)||'null'); if(saved?.file_id===fileId&&Date.now()-saved.at<3600000){ if(/^[A-Za-z0-9_-]{8,80}$/.test(saved.request_id||''))card.dataset.vaultRequest=saved.request_id; if(Object.hasOwn(codes,saved.result_code))card.dataset.vaultOutcome=saved.result_code; } }catch(_){} remember(currentContext(card));requestAnimationFrame(()=>card.scrollIntoView({block:'center'})); } } if(configuration.dataset.vaultPreview==='true'&&!guide&&Object.hasOwn(codes,query.get('outcome'))){ const card=document.querySelector('[data-vault-file]'); if(card){card.dataset.vaultRequest='preview-'+identifier();feedback(card,query.get('outcome'));requestAnimationFrame(()=>card.scrollIntoView({block:'center'}));} }}).catch(()=>{/* A click provides an actionable recovery message. */}); function updateBackLinks(destination){ if(!new RegExp('^'+vault+'#download-f[a-f0-9]{24}(?:-\\d+)?$').test(destination))return; for(const back of guide.querySelectorAll('[data-vault-back]')){back.href=destination;back.textContent='← Back to downloads';} } async function guideContext(){ if(helpOnly||!guide||!fileId)return; const box=guide.querySelector('[data-vault-selected]');box.hidden=false;box.append(text('p','Checking the selected file…')); const baseContext={file_id:fileId,release_id:query.get('collection')||'',return_to:vault+'#download-'+fileId}; updateBackLinks(baseContext.return_to); let savedContext=null; try {savedContext=JSON.parse(sessionStorage.getItem('brawny_vault_selection_'+site)||'null');}catch(_){} remember(baseContext); const abort=new AbortController();const timer=setTimeout(()=>abort.abort(),15000); try { const response=await fetch(endpoint+'/files/'+fileId+'?collection='+encodeURIComponent(baseContext.release_id),{credentials:'same-origin',signal:abort.signal}); const data=await response.json(); if(!response.ok||!data.file){ box.replaceChildren(text('p',codes[data.result_code]||codes.download_service_unavailable)); if(data.result_code==='sign_in_required')box.append(actionLink('Sign in to see the selected file','#/portal/signin','signin')); return; } selected={...data.file,return_to:data.return_to||baseContext.return_to,result_code:'help_opened'}; try {const saved=savedContext; if(saved?.file_id===fileId&&Date.now()-saved.at<3600000)Object.assign(selected,{request_id:saved.request_id,result_code:saved.result_code});}catch(_){} box.replaceChildren(text('h2',selected.label),text('p',selected.filename)); if(selected.expanded_bytes)guide.querySelector('[data-vault-space]').textContent='For this file, allow space for the '+(selected.size_bytes/1e9).toFixed(2)+' GB ZIP and approximately '+(selected.expanded_bytes/1e9).toFixed(2)+' GB of extracted files.'; guide.querySelector('[data-vault-zip-guide]').hidden=selected.format==='pdf'; guide.querySelector('[data-vault-pdf-guide]').hidden=selected.format==='zip'; updateBackLinks(selected.return_to); for(const example of guide.querySelectorAll('[data-vault-example-filename]'))example.textContent=selected.filename; guide.querySelector('[data-vault-support-email]').href=mailto(selected); }catch(_){box.replaceChildren(text('p',codes.download_service_unavailable));} finally{clearTimeout(timer);} } // Public sample images are independent of protected member archives. async function practice(){ const path=configuration.dataset.vaultPracticeSource; if(!guide||!path)return; const manifest=new URL(path,location.href); if(manifest.origin!==location.origin||!manifest.pathname.includes('/download-practice/'))return; try{ const response=await fetch(manifest.href,{signal:AbortSignal.timeout(10000)});if(!response.ok)return; const sample=await response.json(),box=guide.querySelector('[data-vault-practice]'); const local=value=>typeof value==='string'&&/^[a-zA-Z0-9._-]+$/.test(value)&&!value.includes('..'); if(!box||!local(sample.zip)||!sample.images?.every(f=>local(f.url)))return; const link=box.querySelector('[data-vault-practice-download]');link.href=new URL(sample.zip,manifest).href;link.download=sample.filename;link.textContent='Download practice ZIP · '+(sample.size_label||sample.size_kb+' KB'); for(const name of box.querySelectorAll('[data-vault-practice-filename]'))name.textContent=sample.filename; const password=box.querySelector('[data-vault-practice-password]');password.hidden=!sample.password; if(sample.password)password.querySelector('code').textContent=sample.password; const images=box.querySelector('[data-vault-practice-images]'); images.replaceChildren(); for(const f of sample.images){const figure=document.createElement('figure'),img=document.createElement('img');img.src=new URL(f.url,manifest).href;img.alt=f.label;img.width=f.width||480;img.height=f.height||320;figure.append(img,text('figcaption',f.filename));images.append(figure);} box.hidden=false; box.querySelector('[data-vault-preview-note]').hidden=configuration.dataset.vaultPreview!=='true'; const practiceContext=result=>{selected={filename:sample.filename,release_title:'Practice ZIP',result_code:result};}; for(const button of box.querySelectorAll('[data-vault-practice-done],[data-vault-practice-stuck]'))button.hidden=false; link.addEventListener('click',()=>{practiceContext('practice_download_requested');box.querySelector('[data-vault-practice-status]').textContent='Practice download requested. Check your browser’s downloads, then try step 2.';}); box.querySelector('[data-vault-practice-done]').addEventListener('click',()=>{practiceContext('member_reported_opened');box.querySelector('[data-vault-practice-result]').textContent='You’ve confirmed that both images opened. Use the same steps for a collection, with its own password if shown.';}); box.querySelector('[data-vault-practice-stuck]').addEventListener('click',()=>{practiceContext('member_reported_problem');guide.querySelector('[data-vault-troubleshooting]').scrollIntoView({block:'start'});guide.querySelector('#vault-error-description').value='I tried the practice ZIP ('+sample.filename+'). My device shows: ';}); }catch(_){/* The normal opening instructions and return link remain available. */} } guideContext(); practice(); }());