(function(){function a(n,i){if(n===null)return"null";switch(typeof n){case"string":return JSON.stringify(n.length>200?`${n.slice(0,200)}…`:n);case"number":case"boolean":return String(n);case"bigint":return`${n}n`;case"undefined":return"undefined";case"function":return"[function]";case"symbol":return n.toString()}if(Array.isArray(n)){if(i>=2)return"[…]";const r=n.slice(0,20).map(c=>a(c,i+1));return n.length>20&&r.push('"…"'),`[${r.join(",")}]`}if(i>=2)return"{…}";try{const r=Object.keys(n),c=[];for(const s of r.slice(0,20)){let l;try{l=n[s]}catch{l="[throws]"}c.push(`${JSON.stringify(s)}:${a(l,i+1)}`)}return r.length>20&&c.push('"…"'),`{${c.join(",")}}`}catch{return"[unserializable]"}}function d(n){return n.length>2e3?`${n.slice(0,2e3)}…`:n}function E(n){const i=n.map(r=>{if(r===null)return"null";if(r===void 0)return"undefined";if(r instanceof Error)return`${r.name}: ${r.message}
${r.stack||""}`;if(typeof r=="object")return a(r,0);try{return String(r)}catch{return"[unserializable]"}}).join(" ");return d(i)}(()=>{const n=window;if(n.__yankConsoleBridge)return;n.__yankConsoleBridge=!0;const i=500,r=[];let c=0;function s(t,e){const o={id:++c,level:t,message:E(e),timestamp:Date.now(),url:location.href};r.push(o),r.length>i&&r.shift()}const l=console.error,f=console.warn,g=console.log;console.error=function(...e){return s("error",e),l.apply(this,e)},console.warn=function(...e){return s("warn",e),f.apply(this,e)},console.log=function(...e){return s("log",e),g.apply(this,e)},window.addEventListener("error",t=>{var e,o;s("error",[`Uncaught ${((e=t.error)==null?void 0:e.name)||"Error"}: ${t.message}`,`at ${t.filename}:${t.lineno}:${t.colno}`,((o=t.error)==null?void 0:o.stack)||""])}),window.addEventListener("unhandledrejection",t=>{const e=t.reason;s("error",["Unhandled Promise Rejection:",e instanceof Error?`${e.message}
${e.stack}`:String(e)])}),window.addEventListener("message",t=>{if(t.source!==window)return;const e=t.data;if(!(!e||e.source!=="yank-content")&&e.type==="GET_CONSOLE"){let o=r.slice();e.level&&e.level!=="all"&&(o=o.filter(u=>u.level===e.level)),e.grep&&(o=o.filter(u=>u.message.includes(e.grep))),e.limit&&(o=o.slice(-e.limit)),e.clear&&(r.length=0),window.postMessage({source:"yank-console-bridge",type:"CONSOLE_RESULT",requestId:e.requestId,entries:o,total:r.length},"*")}})})();
})()
