export function toBase64(r){if("undefined"!=typeof Buffer)return Buffer.from(r).toString("base64");const e=String.fromCharCode(...r);return btoa(e)}export function fromBase64(r){if("undefined"!=typeof Buffer)return new Uint8Array(Buffer.from(r,"base64"));const e=atob(r),t=new Uint8Array(e.length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t}export function toBase64Url(r){return toBase64(r).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}export function fromBase64Url(r){let e=r.replace(/-/g,"+").replace(/_/g,"/");for(;e.length%4;)e+="=";return fromBase64(e)}export function generateUUID(){if("undefined"!=typeof crypto&&crypto.randomUUID)return crypto.randomUUID();const r=new Uint8Array(16);crypto.getRandomValues(r),r[6]=15&r[6]|64,r[8]=63&r[8]|128;const e=Array.from(r).map(r=>r.toString(16).padStart(2,"0")).join("");return`${e.substring(0,8)}-${e.substring(8,12)}-${e.substring(12,16)}-${e.substring(16,20)}-${e.substring(20)}`}const START_MARKER="Encrypted://",END_MARKER="=> Generated by Xecret (TM)",BRAND_PREFIX="Xecret (TM) -> PRIVATE .ME (R) -> IDA5 -> ";export function formatShareHeader(r){return`${BRAND_PREFIX}${START_MARKER} ${r} ${END_MARKER}`}export function parseShareHeader(r){const e=r.indexOf(START_MARKER);if(e<0)return r.trim();const t=e+12,n=r.indexOf(END_MARKER,t);return n<0?r.trim():r.substring(t,n).trim()}export function hasShareHeader(r){return r.includes(START_MARKER)&&r.includes(END_MARKER)}import{splitXorIDA as _splitXorIDA,reconstructXorIDA as _reconstructXorIDA,nextOddPrime as _nextOddPrime,pkcs7Pad as _pkcs7Pad,pkcs7Unpad as _pkcs7Unpad,generateHMAC as _generateHMAC,verifyHMAC as _verifyHMAC}from"./_deps/crypto/index.js";export const splitXorIDA=_splitXorIDA;export const reconstructXorIDA=_reconstructXorIDA;export const nextOddPrime=_nextOddPrime;export const pkcs7Pad=_pkcs7Pad;export const pkcs7Unpad=_pkcs7Unpad;export const generateHMAC=_generateHMAC;export const verifyHMAC=_verifyHMAC;