PageSourceSearch

https://kaboodu.org/assets/cutoutQueue-fu8ebAy0.js

js kaboodu.org collected 2026-09-24 15:08:58 UTC 3,293 bytes, 3 lines download raw bytes

1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-CjZWxLwH.js","assets/index-ZY1lJleC.js","assets/index-DDza9H9M.css"])))=>i.map(i=>d[i]);
2import{b as B,i as x,_,z as M}from"./index-ZY1lJleC.js";const y="kaboodu.bgRemovalShown";let w=!1,p=!1,d=null;const I=new Set,h=new Map,k=3;let g=typeof navigator<"u"&&navigator.gpu?"gpu":"cpu";const v=1024;async function C(o){var i,e;try{if(typeof createImageBitmap!="function")return o;const t=await createImageBitmap(o),a=Math.max(t.width,t.height);if(a<=v)return(i=t.close)==null||i.call(t),o;const n=v/a,c=Math.round(t.width*n),r=Math.round(t.height*n),u=document.createElement("canvas");return u.width=c,u.height=r,u.getContext("2d").drawImage(t,0,0,c,r),(e=t.close)==null||e.call(t),await new Promise(l=>u.toBlob(l,"image/png"))||o}catch{return o}}function E(){typeof window>"u"||window.localStorage.getItem(y)||(window.localStorage.setItem(y,"1"),M("Preparing your closet — the first cutout downloads a background-remover (~80 MB). One time only; later pieces are quick.",{duration:6500}))}async function R(){return d||(E(),d=(await _(()=>import("./index-CjZWxLwH.js"),__vite__mapDeps([0,1,2]))).removeBackground,d)}async function b(o,i){const e=localStorage.getItem("authToken"),t=await fetch(`${B.defaults.baseURL}/items/${o}/proxy-image`,{headers:e?{Authorization:`Bearer ${e}`}:{}});if(!t.ok)throw new Error(`proxy ${t.status}`);const a=await C(await t.blob()),n=await R(),r=await(await $(n,a)).arrayBuffer(),u=A(r),{data:s}=await x.setCutout(o,u);i==null||i(s)}async function S(o,{minFraction:i=.02}={}){var e;try{if(typeof createImageBitmap!="function")return!0;const t=await createImageBitmap(o),a=Math.max(1,Math.min(t.width,128)),n=Math.max(1,Math.min(t.height,128)),c=document.createElement("canvas");c.width=a,c.height=n;const r=c.getContext("2d",{willReadFrequently:!0});r.drawImage(t,0,0,a,n),(e=t.close)==null||e.call(t);const{data:u}=r.getImageData(0,0,a,n);let s=0,m=0;for(let f=3;f<u.length;f+=4)u[f]<16?s++:u[f]>240&&m++;const l=u.length/4;return s/l>=i&&m/l>=i}catch{return!0}}async function $(o,i){const e={device:g,output:{format:"image/png",quality:.85}};if(g==="gpu"){try{const t=await o(i,e);if(await S(t))return t;console.warn("cutout: WebGPU produced an empty mask, falling back to CPU")}catch(t){console.warn("cutout: WebGPU failed, falling back to CPU",(t==null?void 0:t.message)||t)}g="cpu"}return o(i,{...e,device:"cpu"})}function A(o){const i=new Uint8Array(o);let e="";const t=32768;for(let a=0;a<i.length;a+=t)e+=String.fromCharCode.apply(null,i.subarray(a,a+t));return btoa(e)}function q({getPending:o,onUpdated:i,onProgress:e}){w||(w=!0,p=!1,(async()=>{try{for(;!p;){const t=o().filter(n=>I.has(n.id)?!1:(h.get(n.id)||0)<k);if(t.length===0)break;const a=t[0];e==null||e({phase:"start",itemId:a.id});try{await b(a.id,i),I.add(a.id),e==null||e({phase:"done",itemId:a.id})}catch(n){const c=(h.get(a.id)||0)+1;h.set(a.id,c),console.warn(`cutout failed for ${a.id} (attempt ${c}/${k})`,(n==null?void 0:n.message)||n),e==null||e({phase:"fail",itemId:a.id,error:n==null?void 0:n.message})}}}finally{w=!1}})())}function F(){p=!0}function L(){h.clear()}export{S as looksLikeCutout,L as resetCutoutQueue,q as startCutoutQueue,F as stopCutoutQueue};
3//# sourceMappingURL=cutoutQueue-fu8ebAy0.js.map

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.