import{t as e}from"./toUploadableImageUrl-BHsjY_kh.js";var t;function n(){let e=[[161,169,161,254],[176,247,161,254],[129,160,64,254],[170,254,64,160],[168,169,64,160],[170,175,161,254],[248,254,161,254],[161,167,64,160]],n=new Uint16Array(23940),r=0;for(let[t,i,a,o]of e)for(let e=a;e<=o;e++)if(e!==127)for(let a=t;a<=i;a++)n[r++]=e<<8|a;t=new Uint16Array(65536),t.fill(65535);let i=new TextDecoder(`gbk`).decode(n);for(let e=0;e<i.length;e++)t[i.charCodeAt(e)]=n[e]}var r=typeof Buffer==`function`&&Buffer.allocUnsafe,i=r?e=>r(e):e=>new Uint8Array(e),a=()=>63;function o(e,r={}){t||n();let o=r.onAlloc||i,s=r.onError||a,c=o(e.length*2),l=0;for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);if(r<128){c[l++]=r;continue}let i=t[r];if(i!==65535)c[l++]=i,c[l++]=i>>8;else if(r===8364)c[l++]=128;else{let t=s(n,e);if(t===-1)break;t>255?(c[l++]=t,c[l++]=t>>8):c[l++]=t}}return c.subarray(0,l)}function s(e){let t=o(e),n=``;for(let e=0;e<t.length;e++){let r=t[e];n+=`%${r.toString(16).toUpperCase().padStart(2,`0`)}`}return n}function c(e){return/^https?:\/\//i.test(e)}function l(t){let n=t.trim();if(!n)return null;let r=e((n.startsWith(`//`),n));for(let e of r){let t=e.startsWith(`//`)?`https:${e}`:e;if(c(t))return t}return null}function u(e){let t=e.trim().replace(/\s+/g,` `);return t.length<=60?t:t.slice(0,60)}function d(e,t,n){if(e===`title`){let e=u(t);return e?`https://s.1688.com/selloffer/offer_search.htm?keywords=${s(e)}`:null}let r=l(n);return r?`https://s.1688.com/youyuan/index.htm?tab=imageSearch&imageAddress=${encodeURIComponent(r)}`:null}function f(e,t){if(e===`image`)return null;let n=u(t);return n?`https://mobile.yangkeduo.com/search_result.html?search_key=${encodeURIComponent(n)}`:null}function p(e){let t=e.title?.trim()??``,n=e.imageUrl?.trim()??``;return e.platform===`1688`?e.mode===`title`&&!t||e.mode===`image`&&!n?null:d(e.mode,t,n):e.platform===`pdd`?e.mode===`image`?null:f(e.mode,t):null}function m(e){return e.mode===`image`&&e.platform===`pdd`?`拼多多暂不支持网页图搜`:e.mode===`title`&&!e.title?.trim()?`缺少商品标题`:e.mode===`image`&&!e.imageUrl?.trim()?`缺少商品主图`:`无法生成搜索链接`}export{p as buildFindSimilarUrl,m as buildFindSimilarUrlError};