Files
securebit-chat/dist/app-boot.js
T

130 lines
581 KiB
JavaScript
Raw Normal View History

var Jn=Object.create;var dr=Object.defineProperty;var Zn=Object.getOwnPropertyDescriptor;var es=Object.getOwnPropertyNames;var ts=Object.getPrototypeOf,is=Object.prototype.hasOwnProperty;var ur=(s,e)=>()=>{try{return e||s((e={exports:{}}).exports,e),e.exports}catch(t){throw e=0,t}};var rs=(s,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of es(e))!is.call(s,r)&&r!==t&&dr(s,r,{get:()=>e[r],enumerable:!(i=Zn(e,r))||i.enumerable});return s};var hr=(s,e,t)=>(t=s!=null?Jn(ts(s)):{},rs(e||!s||!s.__esModule?dr(t,"default",{value:s,enumerable:!0}):t,s));var Tn=ur((vo,Gt)=>{var wt=class{constructor(e={}){this.permission=typeof Notification<"u"&&Notification&&typeof Notification.permission=="string"?Notification.permission:"denied",this.isTabActive=this.checkTabActive(),this.unreadCount=0,this.originalTitle=document.title,this.notificationQueue=[],this.maxQueueSize=e.maxQueueSize||5,this.rateLimitMs=e.rateLimitMs||2e3,this.lastNotificationTime=0,this.trustedOrigins=e.trustedOrigins||[],this.isSecureContext=window.isSecureContext,this.hidden=this.getHiddenProperty(),this.visibilityChange=this.getVisibilityChangeEvent(),this.initVisibilityTracking(),this.initSecurityChecks()}initSecurityChecks(){}getHiddenProperty(){return typeof document.hidden<"u"?"hidden":typeof document.msHidden<"u"?"msHidden":typeof document.webkitHidden<"u"?"webkitHidden":"hidden"}getVisibilityChangeEvent(){return typeof document.hidden<"u"?"visibilitychange":typeof document.msHidden<"u"?"msvisibilitychange":typeof document.webkitHidden<"u"?"webkitvisibilitychange":"visibilitychange"}checkTabActive(){return this.hidden&&typeof document[this.hidden]<"u"?!document[this.hidden]:typeof document.hasFocus=="function"?document.hasFocus():!0}initVisibilityTracking(){typeof document.addEventListener<"u"&&typeof document[this.hidden]<"u"&&document.addEventListener(this.visibilityChange,()=>{this.isTabActive=this.checkTabActive(),this.isTabActive&&(this.resetUnreadCount(),this.clearNotificationQueue())}),window.addEventListener("focus",()=>{this.isTabActive=this.checkTabActive(),this.isTabActive&&this.resetUnreadCount()}),window.addEventListener("blur",()=>{this.isTabActive=this.checkTabActive()}),window.addEventListener("beforeunload",()=>{this.clearNotificationQueue()})}async requestPermission(){if(!this.isSecureContext||!("Notification"in window))return!1;if(this.permission==="granted")return!0;if(this.permission==="denied")return!1;try{return this.permission=await Notification.requestPermission(),this.permission==="granted"}catch{return!1}}updateTitle(){this.unreadCount>0?document.title=`(${this.unreadCount}) ${this.originalTitle}`:document.title=this.originalTitle}sanitizeText(e){if(typeof e!="string")return"";let t=document.createElement("div");return t.textContent=e,t.innerHTML.replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#x27;").substring(0,500)}validateIconUrl(e){if(!e)return null;try{let t=new URL(e,window.location.origin);return t.protocol==="https:"||t.protocol==="data:"?this.trustedOrigins.length>0?this.trustedOrigins.some(r=>t.origin===r)?t.href:null:t.href:null}catch{return null}}checkRateLimit(){let e=Date.now();return e-this.lastNotificationTime<this.rateLimitMs?!1:(this.lastNotificationTime=e,!0)}notify(e,t,i={}){if(typeof Notification>"u"||(this.isTabActive=this.checkTabActive(),this.isTabActive)||this.permission!=="granted"||!this.checkRateLimit())return null;let r=this.sanitizeText(e||"Unknown"),n=this.sanitizeText(t||""),a=this.validateIconUrl(i.icon)||"/logo/icon-192x192.png";this.notificationQueue.length>=this.maxQueueSize&&this.clearNotificationQueue();try{let o=new Notification(`${r}`,{body:n.substring(0,200),icon:a,badge:a,tag:`chat-${i.senderId||"unknown"}`,requireInteraction:!1,silent:i.silent||!1,vibrate:navigator.vibrate?[200,100,200]:void 0,data:{senderId:this.sanitizeText(i.senderId),timestamp:Date.now()}});this.unreadCount++,this.updateTitle(),this.notificationQueue.push(o),o.onclick=l=>{if(l.preventDefault(),window.focus(),o.close(),typeof i.onClick=="function")try{i.onClick(i.sende
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function os(s,e){return ns(s)||ss(s,e)||cs(s,e)||as()}function cs(s,e){if(s){if(typeof s=="string")return fr(s,e);var t={}.toString.call(s).slice(8,-1);return t==="Object"&&s.constructor&&(t=s.constructor.name),t==="Map"||t==="Set"?Array.from(s):t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?fr(s,e):void 0}}var Ar=Object.entries,pr=Object.setPrototypeOf,ls=Object.isFrozen,ds=Object.getPrototypeOf,us=Object.getOwnPropertyDescriptor,oe=Object.freeze,ce=Object.seal,it=Object.create,Ir=typeof Reflect<"u"&&Reflect,Si=Ir.apply,_i=Ir.construct;oe||(oe=function(e){return e});ce||(ce=function(e){return e});Si||(Si=function(e,t){for(var i=arguments.length,r=new Array(i>2?i-2:0),n=2;n<i;n++)r[n-2]=arguments[n];return e.apply(t,r)});_i||(_i=function(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),r=1;r<t;r++)i[r-1]=arguments[r];return new e(...i)});var ut=re(Array.prototype.forEach),hs=re(Array.prototype.lastIndexOf),yr=re(Array.prototype.pop),tt=re(Array.prototype.push),fs=re(Array.prototype.splice),Fe=Array.isArray,pt=re(String.prototype.toLowerCase),fi=re(String.prototype.toString),gr=re(String.prototype.match),ht=re(String.prototype.replace),mr=re(String.prototype.indexOf),ps=re(String.prototype.trim),ys=re(Number.prototype.toString),gs=re(Boolean.prototype.toString),Sr=typeof BigInt>"u"?null:re(BigInt.prototype.toString),_r=typeof Symbol>"u"?null:re(Symbol.prototype.toString),pe=re(Object.prototype.hasOwnProperty),ft=re(Object.prototype.toString),ae=re(RegExp.prototype.test),$e=ms(TypeError);function re(s){return function(e){e instanceof RegExp&&(e.lastIndex=0);for(var t=arguments.length,i=new Array(t>1?t-1:0),r=1;r<t;r++)i[r-1]=arguments[r];return Si(s,e,i)}}function ms(s){return function(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];return _i(s,t)}}function V(s,e){let t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:pt;if(pr&&pr(s,null),!Fe(e))return s;let i=e.length;for(;i--;){let r=e[i];if(typeof r=="string"){let n=t(r);n!==r&&(ls(e)||(e[i]=n),r=n)}s[r]=!0}return s}function Ss(s){for(let e=0;e<s.length;e++)pe(s,e)||(s[e]=null);return s}function fe(s){let e=it(null);for(let i of Ar(s)){var t=os(i,2);let r=t[0],n=t[1];pe(s,r)&&(Fe(n)?e[r]=Ss(n):n&&typeof n=="object"&&n.constructor===Object?e[r]=fe(n):e[r]=n)}return e}function _s(s){switch(typeof s){case"string":return s;case"number":return ys(s);case"boolean":return gs(s);case"bigint":return Sr?Sr(s):"0";case"symbol":return _r?_r(s):"Symbol()";case"undefined":return ft(s);case"function":case"object":{if(s===null)return ft(s);let e=s,t=ke(e,"toString");if(typeof t=="function"){let i=t(e);return typeof i=="string"?i:ft(i)}return ft(s)}default:return ft(s)}}function ke(s,e){for(;s!==null;){let i=us(s,e);if(i){if(i.get)return re(i.get);if(typeof i.value=="function")return re(i.value)}s=ds(s)}function t(){return null}return t}function ws(s){try{return ae(s,""),!0}catch{return!1}}var wr=oe(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),pi=oe(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts",
`+ie),Le&&(ie=vt(ie)),E&&bt?x(ie):ie},e.setConfig=function(){let k=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};li(k),Zt=!0},e.clearConfig=function(){Ze=null,Zt=!1,E=M,C=""},e.isValidAttribute=function(k,d,y){Ze||li({});let T=Z(k),L=Z(d);return or(T,L,y)},e.addHook=function(k,d){typeof d=="function"&&tt(A[k],d)},e.removeHook=function(k,d){if(d!==void 0){let y=hs(A[k],d);return y===-1?void 0:fs(A[k],y,1)[0]}return yr(A[k])},e.removeHooks=function(k){A[k]=[]},e.removeAllHooks=function(){A=kr()},e}var Rr=xr();var xt=class s{static _keyMetadata=new WeakMap;static _messageSanitizer=null;static sortObjectKeys(e){if(typeof e!="object"||e===null)return e;if(Array.isArray(e))return e.map(s.sortObjectKeys);let t={};return Object.keys(e).sort().forEach(i=>{t[i]=s.sortObjectKeys(e[i])}),t}static assertCryptoKey(e,t=null,i=[]){if(!(e instanceof CryptoKey))throw new Error("Expected CryptoKey");if(t&&e.algorithm?.name!==t)throw new Error(`Expected algorithm ${t}, got ${e.algorithm?.name}`);for(let r of i)if(!e.usages||!e.usages.includes(r))throw new Error(`Missing required key usage: ${r}`)}static arrayBufferToBase64(e){let t="",i=new Uint8Array(e),r=i.byteLength;for(let n=0;n<r;n++)t+=String.fromCharCode(i[n]);return btoa(t)}static base64ToArrayBuffer(e){try{if(typeof e!="string"||!e)throw new Error("Invalid base64 input: must be a non-empty string");let t=e.trim();if(!/^[A-Za-z0-9+/]*={0,2}$/.test(t))throw new Error("Invalid base64 format");if(t==="")return new ArrayBuffer(0);let i=atob(t),r=i.length,n=new Uint8Array(r);for(let a=0;a<r;a++)n[a]=i.charCodeAt(a);return n.buffer}catch(t){throw console.error("Base64 to ArrayBuffer conversion failed:",t.message),new Error(`Base64 conversion error: ${t.message}`)}}static hexToUint8Array(e){try{if(!e||typeof e!="string")throw new Error("Invalid hex string input: must be a non-empty string");let t=e.replace(/:/g,"").replace(/\s/g,"");if(!/^[0-9a-fA-F]*$/.test(t))throw new Error("Invalid hex format: contains non-hex characters");if(t.length%2!==0)throw new Error("Invalid hex format: odd length");let i=new Uint8Array(t.length/2);for(let r=0;r<t.length;r+=2)i[r/2]=parseInt(t.substr(r,2),16);return i}catch(t){throw console.error("Hex to Uint8Array conversion failed:",t.message),new Error(`Hex conversion error: ${t.message}`)}}static zeroizeBuffer(e){try{if(!e)return;let t=e instanceof Uint8Array?e:e instanceof ArrayBuffer?new Uint8Array(e):null;if(!t||t.length===0)return;crypto.getRandomValues(t),t.fill(0)}catch{}}static async encryptData(e,t){try{let i=typeof e=="string"?e:JSON.stringify(e),r=crypto.getRandomValues(new Uint8Array(16)),n=new TextEncoder,a=n.encode(t),o=await crypto.subtle.importKey("raw",a,{name:"PBKDF2"},!1,["deriveKey"]),c=await crypto.subtle.deriveKey({name:"PBKDF2",salt:r,iterations:31e4,hash:"SHA-256"},o,{name:"AES-GCM",length:256},!1,["encrypt"]),l=crypto.getRandomValues(new Uint8Array(12)),h=n.encode(i),u=await crypto.subtle.encrypt({name:"AES-GCM",iv:l},c,h),p={version:"1.0",salt:Array.from(r),iv:Array.from(l),data:Array.from(new Uint8Array(u)),timestamp:Date.now()},S=JSON.stringify(p);return s.arrayBufferToBase64(new TextEncoder().encode(S).buffer)}catch(i){throw console.error("Encryption failed:",i.message),new Error(`Encryption error: ${i.message}`)}}static async decryptData(e,t){try{let i=s.base64ToArrayBuffer(e),r=new TextDecoder().decode(i),n=JSON.parse(r);if(!n.version||!n.salt||!n.iv||!n.data)throw new Error("Invalid encrypted data format");let a=new Uint8Array(n.salt),o=new Uint8Array(n.iv),c=new Uint8Array(n.data),h=new TextEncoder().encode(t),u=await crypto.subtle.importKey("raw",h,{name:"PBKDF2"},!1,["deriveKey"]),p=await crypto.subtle.deriveKey({name:"PBKDF2",salt:a,iterations:31e4,hash:"SHA-256"},u,{name:"AES-GCM",length:256},!1,["decrypt"]),S=await crypto.subtle.decrypt({name:"AES-GCM",iv:o},p,c),w=new TextDecoder().decode(S);try{return JSON.parse(w)}catch{return w}}catch(i){throw console.error("Decryption failed:",i.message),new Error(`Decryption error: ${i.message}`)}}static generateSecurePassword(){let e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefgh
Please wait for real-time cryptographic verification to complete.`,"sec.verificationUnavailable":"Security verification not available","chat.placeholder":"Type an encrypted message\u2026","chat.send":"Send message","chat.sendFiles":"Send files","chat.hideFiles":"Hide files","chat.recordVoice":"Record voice message","chat.sendVoice":"Send voice message","chat.discard":"Discard","chat.codeBlock":"Send as a code block (expands the input)","chat.codeHint":"Code snippet \xB7 formatting preserved \xB7 \u2318\u21B5 to send","chat.viewOnce":"View once","chat.viewOnceTitle":"View once - vanishes after the peer reads it","chat.viewOncePrefix":"View once \xB7 ","chat.viewOnceTap":"View once \xB7 tap to reveal","chat.viewedOnce":"Viewed once","chat.disappearing":"Disappearing message - deletes on both sides","chat.disappearAfter":"Disappear after","chat.visibleFor":"Visible for","chat.timerPrefix":"Timer \xB7 ","chat.expired":"This message has expired","chat.deleteForEveryone":"Delete for everyone","chat.sending":"Sending","chat.delivered":"Delivered","chat.notSent":"Not sent","chat.notSentReason":"Not sent - the secure channel is not ready. Reconnect to continue.","chat.encrypted":"Encrypted","chat.decrypted":"Decrypted","chat.encryptedOnDevice":"Encrypted on your device","chat.uploading":"Uploading","chat.downloading":"Downloading","chat.transferring":"Transferring\u2026","chat.copied":"Copied!","chat.collapse":"Collapse","chat.closeMenu":"Close menu","chat.newChat":"New chat","chat.newGroup":"New group","chat.createGroup":"Create a group","chat.groupChats":"Group chats","chat.secureChat":"Secure chat","chat.nameThis":"Name this chat","chat.rename":"Rename chat (local only)","chat.renameHint":"Double-click to rename","chat.localLabel":"Local label \xB7 stored only on this device","chat.setStatus":"Set your status","chat.yourStatusPrefix":"Your status - ","chat.meshHint":"Up to 8 peers \xB7 P2P mesh","chat.offline":"Offline","chat.noNetwork":"No network \xB7 reconnecting","chat.startVoiceCall":"Start encrypted voice call","chat.startVideoCall":"Start encrypted video call","chat.verifyForCalls":"Verify the session to enable calls","chat.e2eeNote":"Every message is end-to-end encrypted on your device before it leaves.","chat.peersOnly":"Sent end-to-end to connected peers only - never stored on a server.","flow.invitationCreated":"Secure invitation created","flow.invitationCreatedBang":"Secure invitation created and encrypted!","flow.responseCreated":"Secure response created","flow.responseCreatedBang":"Secure response created!","flow.sendInvitation":"Send the invitation code to your interlocutor via a secure channel (voice call, SMS, etc.).","flow.sendResponse":"Send the response code to the initiator via a secure channel or let them scan the QR code below.","flow.sendEncryptedCode":"Send the encrypted code","flow.sendTheResponse":"Send the response","flow.pasteOrWrite":"Paste or write code\u2026","flow.processingInvitation":"Processing the secure invitation...","flow.processingResponse":"Processing the secure response...","flow.finalizing":"Finalizing the secure connection...","flow.channelEstablished":"Secure channel established","flow.channelReady":"Secure channel is ready","flow.restoring":"Restoring connection\u2026","flow.invitationCaptured":"Invitation captured.","err.needInvitation":"You need to insert the invitation code from your interlocutor.","err.needResponse":"You need to insert the response code from your interlocutor.","err.responseFormat":"Invalid response format - please check the code","err.responseNoKey":"Invalid response code - missing or corrupted cryptographic key. Please check the code and try again.","err.responseNoSignKey":"Invalid response code - missing signature verification key. Please check the code and try again.","err.responseOutdated":"Response data is outdated - please use a fresh invitation","err.setupError":"Connection setup error","err.notReady":"Connection not ready","err.securityBreach":"Security breach detected - connection rejected","err.securityValidation":"Security validation failed - poss
`)!==-1?`\r
`:`
`}function Ur(s){let e=js(s),t=s.split(/\r\n|\n/),i=[],r=[],n=null;for(let a of t)a.startsWith("m=")?(n={lines:[a]},r.push(n)):n?n.lines.push(a):i.push(a);return{eol:e,session:i,media:r}}function zr(s){let e=[...s.session];for(let t of s.media)e.push(...t.lines);return e.join(s.eol)}function Vr(s){let e=s.lines[0].match(/^m=(\w+)/);return e?e[1]:null}function Ws(s,e){let t=new RegExp("^a=rtpmap:(\\d+)\\s+"+e+"\\/","i"),i=[];for(let r of s.lines){let n=r.match(t);n&&i.push(n[1])}return i}function Ys(s){let e=new Map;for(let t of s.split(";")){let i=t.trim();if(!i)continue;let r=i.indexOf("=");r===-1?e.set(i,void 0):e.set(i.slice(0,r).trim(),i.slice(r+1).trim())}return e}function Or(s){let e=[];for(let[t,i]of s)e.push(i===void 0?t:`${t}=${i}`);return e.join(";")}function Xs(s,e,t){let i=s.lines.findIndex(o=>o.startsWith(`a=fmtp:${e} `)||o===`a=fmtp:${e}`);if(i!==-1){let o=s.lines[i].slice(`a=fmtp:${e} `.length),c=Ys(o);for(let[l,h]of Object.entries(t))c.set(l,String(h));s.lines[i]=`a=fmtp:${e} ${Or(c)}`;return}let r=new Map;for(let[o,c]of Object.entries(t))r.set(o,String(c));let n=`a=fmtp:${e} ${Or(r)}`,a=s.lines.findIndex(o=>o.startsWith(`a=rtpmap:${e} `));a!==-1?s.lines.splice(a+1,0,n):s.lines.push(n)}function bi(s,e){if(!s||typeof s!="string")return s;let t=Ur(s),i=!1;for(let r of t.media)if(Vr(r)==="audio")for(let n of Ws(r,"opus"))Xs(r,n,e),i=!0;return i?zr(t):s}var Qs=/^(rtx|red|ulpfec|flexfec-03|telephone-event|CN)$/i;function Js(s){let e=[];for(let t of s.lines){let i=t.match(/^a=rtpmap:(\d+)\s+([^/]+)\//);i&&!Qs.test(i[2])&&e.push(i[1])}return e}function Zs(s,e){for(let t of Js(s))for(let i of e){let r=`a=rtcp-fb:${t} ${i}`;if(s.lines.includes(r))continue;let n=-1;for(let a=0;a<s.lines.length;a++){let o=s.lines[a];(o.startsWith(`a=rtpmap:${t} `)||o.startsWith(`a=fmtp:${t} `)||o.startsWith(`a=rtcp-fb:${t} `))&&(n=a)}n===-1&&(n=s.lines.length-1),s.lines.splice(n+1,0,r)}}function ea(s,e){if(s.lines.some(r=>r.startsWith("a=extmap:")&&r.includes(e)))return;let t=0,i=-1;for(let r=0;r<s.lines.length;r++){let n=s.lines[r].match(/^a=extmap:(\d+)/);n&&(t=Math.max(t,Number(n[1])),i=r)}i===-1&&(i=s.lines.findIndex(r=>r.startsWith("a=mid:")),i===-1&&(i=s.lines.length-1)),s.lines.splice(i+1,0,`a=extmap:${t+1} ${e}`)}function Br(s,e){if(!s||typeof s!="string"||!e)return s;let t=Ur(s),i=!1;for(let r of t.media){let n=Vr(r),a=n==="video"?e.video:n==="audio"?e.audio:null;a&&(Array.isArray(a.rtcpFb)&&(Zs(r,a.rtcpFb),i=!0),a.twcc&&e.twccUri&&(ea(r,e.twccUri),i=!0))}return i?zr(t):s}function Hr(s){try{if(Ue||!s||typeof s.setCodecPreferences!="function"||!st.preferRed)return!1;let e=typeof RTCRtpSender<"u"&&RTCRtpSender.getCapabilities?RTCRtpSender.getCapabilities("audio"):null;if(!e||!Array.isArray(e.codecs))return!1;let t=o=>/red$/i.test(o.mimeType),i=o=>/opus$/i.test(o.mimeType);if(!e.codecs.some(t))return!1;let r=e.codecs.filter(t),n=e.codecs.filter(i),a=e.codecs.filter(o=>!t(o)&&!i(o));return s.setCodecPreferences([...r,...n,...a]),!0}catch{return!1}}async function $r(s,e={}){try{if(Ue||!s||typeof s.getParameters!="function")return!1;let t={...st.sender,...e},i=s.getParameters();(!i.encodings||i.encodings.length===0)&&(i.encodings=[{}]);for(let r of i.encodings)r.maxBitrate=t.maxBitrate,r.priority=t.priority,r.networkPriority=t.networkPriority;return await s.setParameters(i),!0}catch{return!1}}var Gr={VP9:0,AV1:1,H264:2,VP8:3};function qr(s){return(String(s||"").split("/")[1]||"").toUpperCase()}function ta(s){let e=t=>{let i=qr(t.mimeType);return Object.prototype.hasOwnProperty.call(Gr,i)?Gr[i]:99};return s.map((t,i)=>({c:t,i})).sort((t,i)=>e(t.c)-e(i.c)||t.i-i.i).map(t=>t.c)}function jr(s){if(!s||!Array.isArray(s.codecs))return null;let e=new Set(s.codecs.map(t=>qr(t.mimeType)));for(let t of xe.codecPreferenceOrder)if(e.has(t))return t;return null}function Wr(){return typeof RTCRtpSender<"u"&&RTCRtpSender.getCapabilities?RTCRtpSender.getCapabilities("video"):null}function Yr(s){try{if(Ue||!s||typeof s.setCodecPreferences!="function")return!1;let e=Wr();return!e||!Array.isArray(e.codecs)?!1:(s.setCodecPreferences(ta(e.codecs)),jr
`)+`\r
`}}var Pi=new TextEncoder;function Ut(...s){let e=s.reduce((r,n)=>r+n.length,0),t=new Uint8Array(e),i=0;for(let r of s)t.set(r,i),i+=r.length;return t}async function Fi(s,e){return(await s(Ut(Pi.encode("sbq2/bind\0"),e))).slice(0,G.BINDING_BYTES)}async function zt(s,e){return(await s(Ut(Pi.encode("sbq2/blob\0"),e))).slice(0,G.COMMITMENT_BYTES)}function fn(s,e,t,i){let r=n=>{let a=new Uint8Array(4);return new DataView(a.buffer).setUint32(0,n.length),Ut(a,n)};return Ut(Pi.encode("sbq2/sas/v1\0"),r(s),r(e),r(t),r(i))}var gt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";function wa(s){let e="";for(let t=0;t<s.length;t+=3){let i=s[t],r=s[t+1],n=s[t+2];if(e+=gt[i>>2],e+=gt[(i&3)<<4|(r??0)>>4],r===void 0||(e+=gt[(r&15)<<2|(n??0)>>6],n===void 0))break;e+=gt[n&63]}return e}function Ea(s){typeof s!="string"&&P("payload must be a string");let e=s.replace(/\s+/g,"");e.length>Math.ceil(G.MAX_PAYLOAD_BYTES*4/3)+4&&P("payload is too long"),/^[A-Za-z0-9_-]*$/.test(e)||P("payload contains characters outside base64url"),e.length%4===1&&P("payload has an impossible length");let t=new Uint8Array(Math.floor(e.length*3/4)),i=0,r=0,n=0;for(let a of e)r=r<<6|gt.indexOf(a),n+=6,n>=8&&(n-=8,t[i++]=r>>n&255);return r&(1<<n)-1&&P("payload has non-zero padding bits"),t.subarray(0,i)}var Ii="SB2:";function pn(s){return Ii+wa(s)}function Ki(s){typeof s!="string"&&P("payload must be a string");let e=s.trim();return e.startsWith(Ii)||P("not an SB2 descriptor"),Ea(e.slice(Ii.length))}var yn=2,be=Object.freeze({OFFER:0,ANSWER:1}),We=Object.freeze({MAX_SPKI:256,MIN_SPKI:40,MAX_SIG:160,MIN_SIG:48,MAX_BLOB_BYTES:1024}),Ni=class extends Error{constructor(e,t="key_exchange"){super(e),this.name="KeyExchangeError",this.code=t}},de=(s,e)=>{throw new Ni(s,e)};function gn({role:s,ecdhSpki:e,ecdsaSpki:t}){s!==be.OFFER&&s!==be.ANSWER&&de("invalid role");for(let[a,o]of[["ecdh",e],["ecdsa",t]])o instanceof Uint8Array||de(`${a} SPKI must be a Uint8Array`),(o.length<We.MIN_SPKI||o.length>We.MAX_SPKI)&&de(`${a} SPKI length out of range`);let i=new Uint8Array(4+e.length+2+t.length),r=new DataView(i.buffer),n=0;return i[n++]=yn,i[n++]=s,r.setUint16(n,e.length),n+=2,i.set(e,n),n+=e.length,r.setUint16(n,t.length),n+=2,i.set(t,n),i}function mn(s){s instanceof Uint8Array||de("key blob must be a Uint8Array"),s.length===0&&de("key blob is empty"),s.length>We.MAX_BLOB_BYTES&&de("key blob exceeds the size limit");let e=new DataView(s.buffer,s.byteOffset,s.byteLength),t=0,i=h=>{t+h>s.length&&de("key blob is truncated")};i(1);let r=s[t++];r!==yn&&de(`unsupported key blob version 0x${r.toString(16)}`,"version"),i(1);let n=s[t++];n!==be.OFFER&&n!==be.ANSWER&&de("reserved key blob role"),i(2);let a=e.getUint16(t);t+=2,(a<We.MIN_SPKI||a>We.MAX_SPKI)&&de("ECDH SPKI length out of range"),i(a);let o=s.slice(t,t+a);t+=a,i(2);let c=e.getUint16(t);t+=2,(c<We.MIN_SPKI||c>We.MAX_SPKI)&&de("ECDSA SPKI length out of range"),i(c);let l=s.slice(t,t+c);return t+=c,t!==s.length&&de(`${s.length-t} trailing byte(s) after the key blob`),{version:r,role:n,ecdhSpki:o,ecdsaSpki:l}}function Sn({offerDescriptor:s,answerDescriptor:e,offerBlob:t,answerBlob:i}){for(let[r,n]of Object.entries({offerDescriptor:s,answerDescriptor:e,offerBlob:t,answerBlob:i}))(!(n instanceof Uint8Array)||n.length===0)&&de(`transcript component ${r} is missing`);return fn(s,e,t,i)}async function _n(s,e){let t=await s.digest("SHA-512",e);return Array.from(new Uint8Array(t))}var wn=new TextEncoder;function Oi(s){let e=wn.encode("sbq2/proof/v1\0"),t=new Uint8Array(e.length+s.length);return t.set(e,0),t.set(s,e.length),t}async function En(s,{ecdhPrivateKey:e,peerEcdhPublicKey:t,transcript:i,digits:r=7}){let n=await s.deriveBits({name:"ECDH",public:t},e,256),a=null;try{a=await s.importKey("raw",n,"HKDF",!1,["deriveBits"]);let o=new Uint8Array(await s.digest("SHA-256",i)),c=await s.deriveBits({name:"HKDF",hash:"SHA-256",salt:o,info:wn.encode("sbq2-sas-v1")},a,64),l=new DataView(c),h=(l.getUint32(0)^l.getUint32(4))>>>0,u=10**r;return String(h%u).padStart(r,"0")}finally{try{new Uint8Array(n).fill(0)}catch{}}}async functi
self.onmessage = function(e) {
const { type, data } = e.data;
try {
switch (type) {
case 'cleanup_arrays':
// Simulate heavy array cleanup
let processed = 0;
for (let i = 0; i < data.count; i++) {
// Simulate work
processed++;
if (processed % 1000 === 0) {
// Yield control periodically
setTimeout(() => {}, 0);
}
}
self.postMessage({ success: true, processed });
break;
case 'cleanup_objects':
// Simulate object cleanup
const cleaned = data.objects.map(() => null);
self.postMessage({ success: true, cleaned: cleaned.length });
break;
default:
self.postMessage({ success: true, message: 'Unknown cleanup type' });
}
} catch (error) {
self.postMessage({ success: false, error: error.message });
}
};
`,n=new Blob([r],{type:"application/javascript"}),a=new Worker(URL.createObjectURL(n)),o=setTimeout(()=>{a.terminate(),i(new Error("Worker cleanup timeout"))},5e3);a.onmessage=c=>{clearTimeout(o),a.terminate(),URL.revokeObjectURL(n),c.data.success?t(c.data):i(new Error(c.data.error))},a.onerror=c=>{clearTimeout(o),a.terminate(),URL.revokeObjectURL(n),i(c)},a.postMessage(e)})}async _cleanupInMainThread(e){let{type:t,data:i}=e;switch(t){case"cleanup_arrays":let r=0,n=100;for(;r<i.count;){let l=Math.min(r+n,i.count);for(let h=r;h<l;h++);r=l,await this._asyncSleep(1)}return{success:!0,processed:r};case"cleanup_objects":let a=i.objects||[],o=[];for(let l=0;l<a.length;l+=50)o.push(a.slice(l,l+50));let c=0;for(let l of o)l.forEach(()=>c++),await this._asyncSleep(1);return{success:!0,cleaned:c};default:return{success:!0,message:"Unknown cleanup type"}}}_initializeMutexSystem(){this._keyOperationMutex={locked:!1,queue:[],lockId:null,lockTimeout:null,lockTime:null,operationCount:0},this._cryptoOperationMutex={locked:!1,queue:[],lockId:null,lockTimeout:null,lockTime:null,operationCount:0},this._connectionOperationMutex={locked:!1,queue:[],lockId:null,lockTimeout:null,lockTime:null,operationCount:0},this._keySystemState={isInitializing:!1,isRotating:!1,isDestroying:!1,lastOperation:null,lastOperationTime:Date.now(),operationId:null,concurrentOperations:0,maxConcurrentOperations:1},this._operationCounters={keyOperations:0,cryptoOperations:0,connectionOperations:0,totalOperations:0,failedOperations:0},this._secureLog("info","\u{1F512} Enhanced mutex system initialized with atomic protection",{mutexes:["keyOperation","cryptoOperation","connectionOperation"],timestamp:Date.now(),features:["atomic_operations","race_condition_protection","enhanced_state_tracking"]})}_hardenDebugModeReferences(){this._secureLog("info","\u{1F512} XSS Hardening: Debug mode references already replaced")}_initializeUnifiedScheduler(){this._maintenanceScheduler=setInterval(()=>{this._executeMaintenanceCycle()},3e5),this._secureLog("info","\u{1F527} Unified maintenance scheduler initialized (5-minute cycle)"),this._activeTimers=new Set([this._maintenanceScheduler])}_trackActiveTimer(e){return e&&(this._activeTimers||(this._activeTimers=new Set),this._activeTimers.add(e),e)}_untrackActiveTimer(e){e&&this._activeTimers&&this._activeTimers.delete(e)}_setSASMaterialReady(e,t){this._sasLocalFingerprint=e,this._sasRemoteFingerprint=t}_isVerificationReady(){let e=!!(this.peerConnection?.localDescription&&this.peerConnection?.remoteDescription),t=this.dataChannel?.readyState==="open",i=typeof this.verificationCode=="string"&&this.verificationCode.trim().length>0,r=typeof this._sasLocalFingerprint=="string"&&this._sasLocalFingerprint.trim().length>0&&typeof this._sasRemoteFingerprint=="string"&&this._sasRemoteFingerprint.trim().length>0;return e&&t&&i&&r}_notifyVerificationReadyIfPossible(){return this._isVerificationReady()?(this._verificationUiOpened||(this._verificationUiOpened=!0,this.onStatusChange?.("verifying"),this.onVerificationRequired?.(this.verificationCode)),!0):!1}_countIceCandidatesInSDP(e){return typeof e!="string"?0:(e.match(/^a=candidate:/gm)||[]).length}_summarizeIceCandidatesInSDP(e){let t={total:0,host:0,srflx:0,relay:0,prflx:0,unknown:0};if(typeof e!="string")return t;for(let i of e.match(/^a=candidate:.*$/gm)||[]){t.total+=1;let n=i.match(/\btyp\s+(host|srflx|relay|prflx)\b/i)?.[1]?.toLowerCase();n&&Object.prototype.hasOwnProperty.call(t,n)?t[n]+=1:t.unknown+=1}return t}_describeIceCandidatesInSDP(e){return typeof e!="string"?[]:(e.match(/^a=candidate:.*$/gm)||[]).map(t=>{let i=t.slice(12).trim().split(/\s+/),r=i.findIndex(h=>h.toLowerCase()==="typ"),n=i[4]||"",a=i[5]||"",o=r>=0&&i[r+1]||"unknown",c=(i[2]||"unknown").toLowerCase(),l="unknown";return/\.local$/i.test(n)?l="mdns":/^(10\.|192\.168\.|172\.(1[6-9]|2\d|3[0-1])\.)/.test(n)?l="private-ipv4":/^\d{1,3}(\.\d{1,3}){3}$/.test(n)?l="public-ipv4":n.includes(":")&&(l="ipv6"),{candidateType:o,protocol:c,addressKind:l,portPresent:!!a,tcpType:(()=>{let h=i.findIndex(u=>u.toLowerCase()
`),e=e.replace(/\n{3,}/g,`
`),e=e.trim()),e}_sanitizeInputObject(e){if(e===null||typeof e!="object")return e;if(Array.isArray(e))return e.map(i=>this._sanitizeInputObject(i));let t={};for(let i in e)if(e.hasOwnProperty(i)){let r=e[i];typeof r=="string"?t[i]=this._sanitizeInputString(r):typeof r=="object"?t[i]=this._sanitizeInputObject(r):t[i]=r}return t}_checkRateLimit(e="message"){let t=Date.now();return this._rateLimiter||(this._rateLimiter={messageCount:0,lastReset:t,burstCount:0,lastBurstReset:t}),t-this._rateLimiter.lastReset>6e4&&(this._rateLimiter.messageCount=0,this._rateLimiter.lastReset=t),t-this._rateLimiter.lastBurstReset>1e3&&(this._rateLimiter.burstCount=0,this._rateLimiter.lastBurstReset=t),this._rateLimiter.burstCount>=this._inputValidationLimits.rateLimitBurstSize?(this._secureLog("warn","\u26A0\uFE0F Rate limit burst exceeded",{context:e}),!1):this._rateLimiter.messageCount>=this._inputValidationLimits.rateLimitMessagesPerMinute?(this._secureLog("warn","\u26A0\uFE0F Rate limit exceeded",{context:e}),!1):(this._rateLimiter.messageCount++,this._rateLimiter.burstCount++,!0)}_checkInboundRateLimit(e="incoming_message"){let t=Date.now();return this._inboundRateLimiter||(this._inboundRateLimiter={messageCount:0,lastReset:t,burstCount:0,lastBurstReset:t}),t-this._inboundRateLimiter.lastReset>6e4&&(this._inboundRateLimiter.messageCount=0,this._inboundRateLimiter.lastReset=t),t-this._inboundRateLimiter.lastBurstReset>1e3&&(this._inboundRateLimiter.burstCount=0,this._inboundRateLimiter.lastBurstReset=t),this._inboundRateLimiter.burstCount>=this._inputValidationLimits.rateLimitBurstSize?(this._secureLog("warn","\u26A0\uFE0F Inbound message burst limit exceeded; dropping message",{context:e}),!1):this._inboundRateLimiter.messageCount>=this._inputValidationLimits.rateLimitMessagesPerMinute?(this._secureLog("warn","\u26A0\uFE0F Inbound message rate limit exceeded; dropping message",{context:e}),!1):(this._inboundRateLimiter.messageCount++,this._inboundRateLimiter.burstCount++,!0)}_initializeSecureKeyStorage(){this._masterKeyManager=new $t,this._secureKeyStorage=new Bt(this._masterKeyManager),this._keyStorageStats={totalKeys:0,activeKeys:0,lastAccess:null,lastRotation:null},this._secureLog("info","\u{1F510} Enhanced secure key storage initialized")}setMasterKeyPasswordCallback(e){this._masterKeyManager&&this._masterKeyManager.setPasswordRequiredCallback(e)}setMasterKeySessionExpiredCallback(e){this._masterKeyManager&&this._masterKeyManager.setSessionExpiredCallback(e)}lockMasterKey(){this._masterKeyManager&&this._masterKeyManager.lock()}isMasterKeyUnlocked(){return this._masterKeyManager?this._masterKeyManager.isUnlocked():!1}getMasterKeySessionStatus(){return this._masterKeyManager?this._masterKeyManager.getSessionStatus():null}async _ensureFileTransferReady(){try{if(this.fileTransferSystem)return!0;if(!this.dataChannel||this.dataChannel.readyState!=="open")throw new Error("Data channel not open");if(!this.isVerified)throw new Error("Connection not verified");this.initializeFileTransfer();let e=0,t=50;for(;!this.fileTransferSystem&&e<t;)await new Promise(i=>setTimeout(i,100)),e++;if(!this.fileTransferSystem)throw new Error("File transfer system initialization timeout");return!0}catch(e){return this._secureLog("error","\u274C _ensureFileTransferReady failed",{errorType:e?.constructor?.name||"Unknown",hasMessage:!!e?.message}),!1}}_getSecureKey(e){return this._secureKeyStorage.retrieveKey(e)}async _setSecureKey(e,t){if(!(t instanceof CryptoKey))return this._secureLog("error","\u274C Attempt to store non-CryptoKey"),!1;let i=await this._secureKeyStorage.storeKey(e,t,{version:this.currentKeyVersion,type:t.algorithm.name});return i&&this._secureLog("info",`\u{1F511} Key ${e} stored securely with encryption`),i}_validateKeyValue(e){return e instanceof CryptoKey&&e.algorithm&&e.usages&&e.usages.length>0}_secureWipeKeys(){this._secureKeyStorage.secureWipeAll(),this._masterKeyManager&&this._masterKeyManager.lock(),this._secureLog("info","\u{1F9F9} All keys securely wiped and encrypted storage cleared")}_validateKeyStorage(){return this._secureKeyStora
`;if(F+=`Security Level: ${A.level} (${A.score}%)
`,F+=`Verification Time: ${new Date(A.timestamp).toLocaleTimeString()}
`,F+=`Data Source: ${A.isRealData?f("sec.realTests"):f("sec.simulatedData")}
`,A.verificationResults){F+=`DETAILED CRYPTOGRAPHIC TESTS:
`,F+="="+"=".repeat(40)+`
`;let X=Object.entries(A.verificationResults).filter(([_e,ge])=>ge.passed),Se=Object.entries(A.verificationResults).filter(([_e,ge])=>!ge.passed);X.length>0&&(F+=`PASSED TESTS:
`,X.forEach(([_e,ge])=>{let Ye=_e.replace(/([A-Z])/g," $1").replace(/^./,Y=>Y.toUpperCase());F+=` ${Ye}: ${ge.details||f("sec.testPassed")}
`}),F+=`
`),Se.length>0&&(F+=`FAILED/UNAVAILABLE TESTS:
`,Se.forEach(([_e,ge])=>{let Ye=_e.replace(/([A-Z])/g," $1").replace(/^./,Y=>Y.toUpperCase());F+=` ${Ye}: ${ge.details||f("sec.testFailed")}
`}),F+=`
`),F+=`SUMMARY:
`,F+=`Passed: ${A.passedChecks}/${A.totalChecks} tests
`,F+=`Score: ${A.score}/${A.maxPossibleScore||100} points
`}if(F+=`SECURITY FEATURES STATUS:
`,F+="="+"=".repeat(40)+`
`,A.verificationResults){let X={"ECDSA Digital Signatures":A.verificationResults.verifyECDSASignatures?.passed||!1,"ECDH Key Exchange":A.verificationResults.verifyECDHKeyExchange?.passed||!1,"AES-GCM Encryption":A.verificationResults.verifyEncryption?.passed||!1,[f("sec.messageIntegrity")]:A.verificationResults.verifyMessageIntegrity?.passed||!1,[f("sec.forwardSecrecy")]:A.verificationResults.verifyPerfectForwardSecrecy?.passed||!1,[f("sec.replayProtection")]:A.verificationResults.verifyReplayProtection?.passed||!1,"DTLS Fingerprint":A.verificationResults.verifyDTLSFingerprint?.passed||!1,"SAS Verification":A.verificationResults.verifySASVerification?.passed||!1,[f("sec.metadataProtection")]:A.verificationResults.verifyMetadataProtection?.passed||!1,[f("sec.trafficObfuscation")]:A.verificationResults.verifyTrafficObfuscation?.passed||!1};Object.entries(X).forEach(([Se,_e])=>{F+=`${_e?"\u2705":"\u274C"} ${Se}
`})}else F+=`\u2705 ECDSA Digital Signatures
`,F+=`\u2705 ECDH Key Exchange
`,F+=`\u2705 AES-GCM Encryption
`,F+=`\u2705 Message Integrity (HMAC)
`,F+=`\u2705 Perfect Forward Secrecy
`,F+=`\u2705 Replay Protection
`,F+=`\u2705 DTLS Fingerprint
`,F+=`\u2705 SAS Verification
`,F+=`\u2705 Metadata Protection
`,F+=`\u2705 Traffic Obfuscation
`;F+=`
${A.details||f("sec.verificationDone")}`,A.isRealData?F+=`
\u2705 This is REAL-TIME verification using actual cryptographic functions.`:F+=`
\u26A0\uFE0F Warning: This data may be simulated. Connection may not be fully established.`;let K=document.createElement("div");K.style.cssText=`
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: rgba(0,0,0,0.8);
z-index: 10000;
display: flex;
align-items: center;
justify-content: center;
font-family: monospace;
`;let z=document.createElement("div");z.style.cssText=`
background: #1a1a1a;
color: #fff;
padding: 20px;
border-radius: 8px;
max-width: 80%;
max-height: 80%;
overflow-y: auto;
white-space: pre-line;
border: 1px solid #333;
`,z.textContent=F,K.appendChild(z),K.addEventListener("click",X=>{X.target===K&&document.body.removeChild(K)});let W=X=>{X.key==="Escape"&&(document.body.removeChild(K),document.removeEventListener("keydown",W))};document.addEventListener("keydown",W),document.body.appendChild(K)},D=(()=>{switch(s){case"connected":return{text:f("status.connected"),className:"status-connected",badgeClass:"bg-green-500/10 text-green-400 border-green-500/20"};case"verifying":return{text:f("status.verifying"),className:"status-verifying",badgeClass:"bg-purple-500/10 text-purple-400 border-purple-500/20"};case"connecting":return{text:f("status.connecting"),className:"status-connecting",badgeClass:"bg-blue-500/10 text-blue-400 border-blue-500/20"};case"retrying":return{text:f("status.retrying"),className:"status-connecting",badgeClass:"bg-yellow-500/10 text-yellow-400 border-yellow-500/20"};case"failed":return{text:f("status.error"),className:"status-failed",badgeClass:"bg-red-500/10 text-red-400 border-red-500/20"};case"reconnecting":return{text:f("status.reconnecting"),className:"status-connecting",badgeClass:"bg-yellow-500/10 text-yellow-400 border-yellow-500/20"};case"peer_disconnected":return{text:f("status.peerDisconnected"),className:"status-failed",badgeClass:"bg-orange-500/10 text-orange-400 border-orange-500/20"};default:return{text:f("status.notConnected"),className:"status-disconnected",badgeClass:"bg-gray-500/10 text-gray-400 border-gray-500/20"}}})(),_=r?o||n:null,E=(()=>{if(!_)return{tooltip:f("sec.verificationInProgress"),isVerified:!1,dataSource:"loading"};let U=_.isRealData!==!1,H=`${_.level} (${_.score}%)`;return U?{tooltip:`${H} - Real-time verification \u2705
Right-click or Ctrl+click to disconnect`,isVerified:!0,dataSource:"real"}:{tooltip:`${H} - Estimated (connection establishing...)
Right-click or Ctrl+click to disconnect`,isVerified:!1,dataSource:"estimated"}})();React.useEffect(()=>(window.debugHeaderSecurity=void 0,()=>{delete window.debugHeaderSecurity}),[o,l,r,a,_,E]);let C=_?_.color==="green"?"#3ecf8e":_.color==="orange"?"#f0892a":_.color==="yellow"?"#e3c84e":"#e5727a":"#3ecf8e",M=r?"#3ecf8e":["connecting","verifying","retrying","reconnecting"].includes(s)?"#e3c84e":s==="failed"?"#e5727a":"#6b6b73",v=M==="#3ecf8e"?"rgba(62,207,142,0.16)":M==="#e3c84e"?"rgba(227,200,78,0.16)":M==="#e5727a"?"rgba(229,114,122,0.16)":"rgba(107,107,115,0.16)",q="'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace",O=!r,[x,ue]=React.useState(!1);React.useEffect(()=>{let U=()=>ue((window.scrollY||window.pageYOffset||0)>8);return U(),window.addEventListener("scroll",U,{passive:!0}),()=>window.removeEventListener("scroll",U)},[]);let ne="blur(20px) saturate(180%)",te="background .25s ease, backdrop-filter .25s ease, -webkit-backdrop-filter .25s ease, border-color .25s ease",ye={paddingTop:"var(--sb-safe-top, 0px)",paddingBottom:"var(--sb-bar-extra, 0px)"},Re={position:"fixed",top:0,left:0,right:0,...ye},j=O?x?{...Re,background:"rgba(15,15,17,0.72)",backdropFilter:ne,WebkitBackdropFilter:ne,borderBottom:"1px solid rgba(255,255,255,0.06)",transition:te}:{...Re,background:"transparent",backdropFilter:"blur(0px) saturate(100%)",WebkitBackdropFilter:"blur(0px) saturate(100%)",borderBottom:"1px solid transparent",transition:te}:{...ye,background:"rgba(18,18,20,0.72)",backdropFilter:ne,WebkitBackdropFilter:ne,borderBottom:"1px solid rgba(255,255,255,0.06)"};return React.createElement("header",{className:O?"header-minimal z-50":"header-minimal sticky top-0 z-50",style:j},[React.createElement("div",{key:"container",className:"max-w-7xl mx-auto",style:{padding:"0 20px"}},[React.createElement("div",{key:"content",className:"flex items-center justify-between",style:{height:"var(--sb-bar-h, 64px)",gap:"16px"}},[React.createElement("div",{key:"left",style:{display:"flex",alignItems:"center",gap:"12px",minWidth:0}},[React.createElement("div",{key:"logo",style:{width:"36px",height:"36px",flex:"none",display:"grid",placeItems:"center"}},React.createElement("img",{src:"/logo/securebit-mark.svg",alt:"SecureBit",style:{width:"100%",height:"100%",objectFit:"contain",display:"block"}})),React.createElement("div",{key:"txt",style:{lineHeight:1.2,minWidth:0}},[React.createElement("div",{key:"r1",style:{display:"flex",alignItems:"baseline",gap:"7px"}},[React.createElement("span",{key:"n",style:{fontSize:"16px",fontWeight:800,letterSpacing:"-0.3px",color:"#e8e8eb"}},"SecureBit"),React.createElement("span",{key:"v",style:{fontFamily:q,fontSize:"10px",fontWeight:500,color:"#56565e"}},Ta)]),React.createElement("div",{key:"r2",className:"hidden sm:block",style:{fontSize:"11px",color:"#6b6b73",fontWeight:500}},f("hdr.tagline"))])]),React.createElement("div",{key:"right",style:{display:"flex",alignItems:"center",gap:"9px"}},[O&&React.createElement(zi,{key:"lang"}),!O&&React.createElement("button",{key:"net",type:"button",onClick:()=>window.dispatchEvent(new CustomEvent("securebit:open-network-settings")),title:f("hdr.netSettingsTitle"),"aria-label":f("hdr.netSettings"),className:"sb-disconnect",style:{display:"grid",placeItems:"center",width:"38px",height:"38px",borderRadius:"9px",border:"1px solid rgba(255,255,255,0.07)",background:"rgba(255,255,255,0.02)",color:"#9a9aa2",cursor:"pointer",transition:"all .15s"}},React.createElement("i",{className:"fas fa-network-wired",style:{fontSize:"13px"}})),!O&&_&&React.createElement("div",{key:"sec",onClick:I,onContextMenu:U=>{U.preventDefault(),typeof i=="function"&&i()},title:E.tooltip,className:"sb-secpill",style:{display:"flex",alignItems:"center",gap:"8px",padding:"7px 12px",borderRadius:"9px",border:"1px solid rgba(255,255,255,0.07)",background:"rgba(255,255,255,0.02)",cursor:"pointer"}},[React.createElement("i",{key:"i",className:"fas fa-shield-halved",style:{fontSize:"13px",color:C}}),React.createElement("span",{key:"l",className:"hidden sm:inline",style:{fontSize:"12.5px",fontWeight:600,
`).map(i=>i.trim()).filter(Boolean).map(i=>({urls:i}));return In(t)}function Ln(s){return Array.isArray(s)?s.some(e=>(Array.isArray(e?.urls)?e.urls:[e?.urls]).some(Rn)):!1}var Ve=window.React,Fa=["# One URL per line, e.g.:","stun:stun.example.com:3478","turn:turn.example.com:3478?transport=udp","","# Or paste JSON for servers with credentials:",'[{"urls":"turns:turn.example.com:5349","username":"user","credential":"secret"}]'].join(`
`);async function Ka(s,e=6e3){let t={host:0,srflx:0,relay:0};if(typeof RTCPeerConnection>"u")return{...t,error:f("ice.errUnavailable")};let i;try{i=new RTCPeerConnection({iceServers:s})}catch(r){return{...t,error:r.message||f("ice.errInvalid")}}return new Promise(r=>{let n=!1,a=()=>{if(!n){n=!0,clearTimeout(o);try{i.close()}catch{}r(t)}},o=setTimeout(a,e);i.onicecandidate=c=>{if(!c.candidate){a();return}let l=c.candidate.candidate||"";/ typ host/.test(l)?t.host++:/ typ srflx/.test(l)?t.srflx++:/ typ relay/.test(l)&&t.relay++};try{i.createDataChannel("securebit-ice-test"),i.createOffer().then(c=>i.setLocalDescription(c)).catch(()=>a())}catch{a()}})}var Na=({isOpen:s,onClose:e,initial:t,hasSaved:i,onApply:r,onForget:n,embedded:a})=>{if(!s)return null;let[o,c]=Ve.useState(t?.useCustom||!1),[l,h]=Ve.useState(t?.serversText||""),[u,p]=Ve.useState(t?.privacyMode==="relay-only"),[S,w]=Ve.useState(t?.persisted||!1),[g,m]=Ve.useState("idle"),[I,b]=Ve.useState(null),D=o?Mn(l):{servers:[],errors:[],warnings:[]},_=Ln(D.servers),R=!o||D.servers.length>0&&D.errors.length===0,E=async()=>{m("running"),b(null);let j=await Ka(D.servers);b(j),m("done")},C=()=>{R&&r({useCustom:o,servers:o?D.servers:[],privacyMode:u?"relay-only":"standard",serversText:l},S)},M=async()=>{n&&await n(),w(!1)},v=Ve.createElement,q="#f0892a",O="#3ecf8e",x="'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace",ue=(j,U,H,A,F)=>v("button",{type:"button",onClick:U,style:Object.assign({width:"100%",textAlign:"start",display:"flex",alignItems:"flex-start",gap:"12px",padding:"14px 15px",borderRadius:"13px",border:`1px solid ${j?"rgba(240,137,42,0.45)":"rgba(255,255,255,0.07)"}`,background:j?"rgba(240,137,42,0.06)":"#141416",color:"inherit",fontFamily:"inherit",cursor:"pointer",transition:"all .15s",marginBottom:"10px"},F||{})},[v("span",{key:"ring",style:{flex:"none",width:"18px",height:"18px",marginTop:"1px",borderRadius:"50%",border:`1.5px solid ${j?q:"rgba(255,255,255,0.22)"}`,display:"grid",placeItems:"center"}},v("span",{style:{width:"8px",height:"8px",borderRadius:"50%",background:j?q:"transparent"}})),v("span",{key:"tx",style:{flex:1}},[v("span",{key:"t",style:{display:"block",fontSize:"14px",fontWeight:700,color:"#f4f4f6"}},H),v("span",{key:"d",style:{display:"block",fontSize:"12.5px",color:"#8a8a92",marginTop:"2px"}},A)])]),ne=(j,U,H,A,F,K)=>v("button",{type:"button",onClick:U,style:{width:"100%",textAlign:"start",display:"flex",alignItems:"flex-start",gap:"12px",padding:"14px 15px",borderRadius:"13px",border:`1px solid ${j?"rgba(62,207,142,0.3)":"rgba(255,255,255,0.07)"}`,background:j?"rgba(62,207,142,0.05)":"#141416",color:"inherit",fontFamily:"inherit",cursor:"pointer",transition:"all .15s",marginBottom:"10px"}},[v("span",{key:"tx",style:{flex:1}},[v("span",{key:"r1",style:{display:"flex",alignItems:"center",gap:"8px"}},[v("span",{key:"t",style:{fontSize:"14px",fontWeight:700,color:"#f4f4f6"}},H),K&&v("span",{key:"b",style:{fontSize:"10px",fontWeight:700,color:O,padding:"2px 7px",borderRadius:"5px",background:"rgba(62,207,142,0.1)",border:"1px solid rgba(62,207,142,0.22)"}},K)]),v("span",{key:"d",style:{display:"block",fontSize:"12.5px",lineHeight:1.5,color:"#8a8a92",marginTop:"3px"}},A)]),v("span",{key:"tr",style:{flex:"none",width:"42px",height:"24px",borderRadius:"99px",background:j?F||O:"rgba(255,255,255,0.08)",border:`1px solid ${j?F||O:"rgba(255,255,255,0.12)"}`,position:"relative",transition:"all .18s",marginTop:"1px"}},v("span",{style:{position:"absolute",top:"2px",insetInlineStart:"2px",width:"18px",height:"18px",borderRadius:"50%",background:"#fff",transform:j?`translateX(${18*Fr()}px)`:"translateX(0)",transition:"transform .18s"}}))]),te=[];if(te.push(v("p",{key:"intro",style:{margin:"0 0 18px",fontSize:"13.5px",lineHeight:1.6,color:"#9a9aa2"}},f("ice.intro"))),te.push(ue(!o,()=>c(!1),f("ice.publicTitle"),f("ice.publicDesc"))),te.push(ue(o,()=>c(!0),f("ice.customTitle"),f("ice.customDesc",{max:ze.MAX_SERVERS}),o?{marginBottom:"14px"}:null)),o){let j=[];j.push(v("div",{key:"ta",style:{borderRadius:"13px",border:"1px solid rgba(255,255,
/**
* Secure and Reliable Notification Manager for P2P WebRTC Chat
* Follows best practices: OWASP, MDN, Chrome DevRel
*
* @version 1.0.0
* @author SecureBit Team
* @license MIT
*/
/**
* Notification Integration Module for SecureBit WebRTC Chat
* Integrates secure notifications with existing WebRTC architecture
*
* @version 1.0.0
* @author SecureBit Team
* @license MIT
*/
/*! Bundled license information:
dompurify/dist/purify.es.mjs:
2026-06-15 15:08:03 -04:00
(*! @license DOMPurify 3.4.10 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.4.10/LICENSE *)
*/
//# sourceMappingURL=app-boot.js.map