var e=`xyxp-goofish`,t=`GOOFISH_HOOK_READY`,n=`GOOFISH_PC_SEARCH`,r=`GOOFISH_PC_SEARCH_SUGGEST`,i=`GOOFISH_HOOK_STATUS_REQUEST`,a=`xyxp-goofish-isolated`;function o(e,t){if(!e||typeof e!=`string`)return null;let n=``;try{let t=new URL(e,location.href);n=t.searchParams.get(`api`)??``,n||=t.searchParams.get(`type`)??``}catch{return null}let r=null;for(let i of t){let t=!1;(n&&n===i.api||e.includes(i.api))&&(t=!0),t&&(!r||i.api.length>r.api.length)&&(r=i)}return r?.type??null}function s(e,n){try{window.postMessage({source:n,type:t,payload:{apis:e.map(e=>e.api)}},`*`)}catch{}}var c=!1;function l(t,n=e){c||(c=!0,window.addEventListener(`message`,e=>{if(e.source!==window)return;let r=e.data;r?.source!==`xyxp-goofish-isolated`||r?.type!==`GOOFISH_HOOK_STATUS_REQUEST`||window.__xyxpMtopResponseHooked&&s(t,n)}))}function u(t,n=e){let r=window;if(r.__xyxpMtopResponseHooked){s(t,n);return}r.__xyxpMtopResponseHooked=!0,s(t,n);function i(e,t){try{window.postMessage({source:n,type:t,payload:e},`*`)}catch{}}let a=window.fetch.bind(window);window.fetch=function(e,n){return a(e,n).then(n=>{try{let r=``;typeof e==`string`?r=e:typeof Request<`u`&&e instanceof Request?r=e.url:e&&typeof e==`object`&&`url`in e&&(r=String(e.url));let a=r?o(r,t):null;a&&n.clone().json().then(e=>i(e,a)).catch(()=>{})}catch{}return n})};let c=XMLHttpRequest.prototype.open,l=XMLHttpRequest.prototype.send,u=XMLHttpRequest.prototype;u.open=function(...e){let t=e[1];this.__xyxp_url=typeof t==`string`?t:String(t??``),c.apply(this,e)},u.send=function(...e){let n=this;n.addEventListener(`load`,function(){try{let e=o(n.__xyxp_url??``,t);e&&n.responseText&&i(JSON.parse(n.responseText),e)}catch{}}),l.apply(n,e)}}var d=[{api:`mtop.taobao.idle.pc.detail`,type:`IDLE_PC_DETAIL`},{api:`mtop.taobao.idlemtopsearch.pc.search.suggest`,type:r},{api:`mtop.taobao.idlemtopsearch.pc.search`,type:n}];function f(){u(d),l(d)}export{a,u as c,r as i,i as n,e as o,n as r,f as s,t};