1import{r as t}from"./vendor-react-C9yDzYQD.js";import{supabase as e}from"./supabase-client-_h80EYw_.js";import{d as r,b as a,e as i}from"./image-utils-AdRSPECl.js";import{a as n}from"./useAuth-Dz3EPsxs.js";import{i as o,a as s,s as u}from"./perfConfig-DEgIskwG.js";import{a as l}from"./idleStorage-BGANA5qp.js";import{a as c}from"./startup-platform-OWIpYyjW.js";import{s as m}from"./documentVisibilitySubscriptions-CqVNm4Da.js";const f="echo_dims_backfill_last",d="echo_dims_backfill_done_at",h=(h=!0)=>{const{user:g}=n(),b=null==g?void 0:g.id,p=t.useRef(!1),_=t.useRef(null),w=t.useRef(new Set);t.useEffect(()=>{if(!h)return;if(c())return;if(!b)return;if("undefined"!=typeof navigator&&!navigator.onLine)return;if(!o()||s())return;if("slow"===r())return;const t=Number(localStorage.getItem(f)||0),n=Number(localStorage.getItem(d)||0),g=Date.now();if(n&&g-n<864e5)return;if(t&&g-t<216e5)return;const j=async()=>{if(p.current)return;if(!o()||s())return;p.current=!0,l(f,String(Date.now())),w.current.clear();let t=0,r=!1;for(;t<60&&!r&&o()&&!s();){const{data:n,error:u}=await e.from("memories").select("id, image_url, metadata").not("image_url","is",null).neq("image_url","").is("deleted_at",null).filter("metadata->>width","is",null).order("created_at",{ascending:!1}).limit(12);if(u||!n||0===n.length){r=!0;break}const l=n.filter(t=>!w.current.has(t.id));if(0===l.length){r=!0;break}let c=0;for(const r of l){if(t>=60)break;if(!o()||s())break;w.current.add(r.id);const n=r.metadata&&"object"==typeof r.metadata?r.metadata:{},u=n.thumbnail_url,l=u?a(u,"thumbnail")||u:a(r.image_url,"thumbnail");if(l)try{const a=await i(l);if(!a||!a.width||!a.height){t+=1;continue}const{error:o}=await e.from("memories").update({metadata:{...n,width:a.width,height:a.height,aspect_ratio:a.width/a.height}}).eq("id",r.id);t+=1,o||(c+=1)}catch{t+=1}else t+=1}0===c&&(r=!0)}r&&l(d,String(Date.now())),p.current=!1};_.current=u(()=>{j()},2500);const v=m(()=>{var t;"visible"!==document.visibilityState||p.current||(null==(t=_.current)||t.call(_),_.current=u(()=>{j()},2500))});return()=>{var t;v(),null==(t=_.current)||t.call(_)}},[h,b])};function g(){return h(!0),null}export{g as MemoryDimensionsBackfill,h as useMemoryDimensionsBackfill};
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.