function transformBracketValues(t,e=[]){if(Array.isArray(t))return t.map(t=>transformBracketValues(t,e));if("object"==typeof t&&null!==t)for(let s in t){if(!t.hasOwnProperty(s))continue;let r=t[s];if("string"==typeof r&&r.startsWith("[")&&(r=r.slice(3)),"string"==typeof r&&r.includes("[")){let a=r.split("[");a.length>1&&(t[s]=a[1].replace("]",""),e.push(a[0]))}else(Array.isArray(r)||"object"==typeof r&&null!==r)&&(t[s]=transformBracketValues(r,e))}return t}function translateBody(t){let e;let s=[];try{e=transformBracketValues(JSON.parse(t),s)}catch{return{bodyStr:t,replaceList:s}}return{bodyStr:JSON.stringify(e||{}),replaceList:s}}(()=>{let t=XMLHttpRequest.prototype.open,e=XMLHttpRequest.prototype.send;XMLHttpRequest.prototype.open=function(e,s,...r){if(e?.toUpperCase?.()==="POST"&&(/\/api\/trade2?\/search(?:\/[^\/]+)*\/[^/?]+$/.test(s)?(this.__ptc_seach_type="search",this.__poeTarget__=!0):/\/api\/trade2?\/exchange(?:\/[^\/]+)*\/[^/?]+$/.test(s)&&(this.__ptc_seach_type="exchange",this.__poeTarget__=!0)),this.__poeTarget__&&this.__ptc_seach_type){let t=s.split("/");this.__poe_info__={league:t[t.length-1],type:this.__ptc_seach_type}}return t.call(this,e,s,...r)},XMLHttpRequest.prototype.send=function(t){if(this.__poeTarget__&&"string"==typeof t){let s=translateBody(t);return this.addEventListener("readystatechange",function(){if(4===this.readyState&&200===this.status)try{let t=JSON.parse(this.responseText);t.id&&window.postMessage({source:"ptc-extension",type:"add_history",data:{dataId:t.id,...this.__poe_info__||{},name:s.replaceList.join(" ")}},"*")}catch(t){}}),e.call(this,s.bodyStr)}return e.call(this,t)}})();