1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-9Zdhllc6.js","assets/_commonjsHelpers-BosuxZz1.js","assets/_commonjs-dynamic-modules-TDtrdbi3.js"])))=>i.map(i=>d[i]); 2import{_ as L,e as k,T as A}from"./app-gOHIPY12.js";import{bindHashStyleCopy as M}from"./hashStyleCopy-B7l2OPhl.js";import{maybeShowFullscreenAd as P}from"./ctFullscreenAd-CL-AA_Ul.js";import{saveResultFile as z}from"./ctResultAccessAd-Dk9whJZs.js";import{a as j,c as U}from"./fileDropzone-CA_uaFcV.js";import"./FileSaver.min-BR20wtAe.js";import"./_commonjsHelpers-BosuxZz1.js";import"./transientNotice-Ds_di7lD.js";const R=40,V=50*1024*1024;function m(g){const e=document.getElementById("ctOcrToastBody"),r=document.getElementById("ctOcrToast");if(!e||!r||typeof k>"u"){window.alert(g);return}e.textContent=g,A.getOrCreateInstance(r).show()}function W(g){const e=[];for(const r of g.selectedOptions){const h=r.getAttribute("data-code");h&&e.push(h)}return e}function N(){if(!document.getElementById("ct-ocr-root"))return;const e=document.getElementById("ctOcrFile"),r=document.getElementById("ctOcrFileZone"),h=document.getElementById("ctOcrFileDropCaption"),v=document.getElementById("ctOcrLangs"),f=document.getElementById("ctOcrRun"),l=document.getElementById("ctOcrOut"),S=document.getElementById("ctOcrCopy"),p=document.getElementById("ctOcrOutClear"),a=document.getElementById("ctOcrFileName"),y=document.getElementById("ctOcrDl"),n=document.getElementById("ctOcrStatus"),B=document.getElementById("ctOcrProg"),C=document.getElementById("ctOcrProgressWrap");if(!e||!v||!f||!l)return;const I=M(S,()=>l.value,t=>m(t)),d=t=>{const o=Math.min(100,Math.max(0,t));B&&(B.style.width=`${o}%`),C==null||C.setAttribute("aria-valuenow",String(Math.round(o)))},x=()=>String(l.value||"").trim(),E=()=>{const t=x().length>0;y&&(y.disabled=!t),p&&(p.disabled=!t),a&&(a.disabled=!t),!t&&a&&(a.value="ocr_result")},O=()=>{var o;const t=((o=e.files)==null?void 0:o.length)??0;f.disabled=t===0};e&&r?j({input:e,drop:r,dragContainer:r.closest(".card-body"),captionEl:h,onChange:()=>{var o;const t=((o=e.files)==null?void 0:o.length)??0;n&&t>0&&(n.textContent=`${t} image${t===1?"":"s"} selected.`),O()},onInvalidFile:t=>m(t)}):e.addEventListener("change",O),y==null||y.addEventListener("click",()=>{const t=x();if(!t)return;const o=String((a==null?void 0:a.value)||"ocr_result").trim().replace(/[^\w.-]+/g,"_")||"ocr_result";z(new Blob([t],{type:"text/plain;charset=utf-8"}),`${o}.txt`)}),p==null||p.addEventListener("click",()=>{l.value="",U(e),n&&(n.textContent=""),d(0),I(),O(),E()}),f.addEventListener("click",async()=>{var b;const t=e.files?Array.from(e.files):[];if(t.length===0)return;if(t.length>R){m(`Choose at most ${R} images per run.`);return}for(let s=0;s<t.length;s++)if(t[s].size>V){m(`"${t[s].name}" is over 50 MB.`);return}const o=W(v);if(!o.length){m("Select at least one language.");return}f.disabled=!0,d(0),n&&(n.textContent=t.length===1?"Running OCRâ¦":`Running OCR (0 of ${t.length} images done)â¦`),l.value="",I(),E();try{const{createWorker:s}=await L(async()=>{const{createWorker:c}=await import("./index-9Zdhllc6.js").then(u=>u.i);return{createWorker:c}},__vite__mapDeps([0,1,2])),w=o.join("+");n&&(n.textContent=`Loading OCR (${w})â¦`);let $=0;const i=t.length,_=await s(w,void 0,{logger:c=>{c.status==="recognizing text"&&typeof c.progress=="number"&&d(($+c.progress)/i*100)}}),F=[];for(let c=0;c<t.length;c++){const u=t[c];$=c,d(c/i*100),n&&(n.textContent=i===1?`Processing: ${u.name}`:`Image ${c+1} of ${i}: ${u.name}`);const{data:{text:T}}=await _.recognize(u),D=(T||"").trim();F.push(`=== ${u.name} === 3${D||"(no text detected)"}`),n&&i>1&&(n.textContent=`Done ${c+1} of ${i} images.`)}await _.terminate(),l.value=F.join(` 4 5`),P("conversion-success"),I(),E(),n&&(n.textContent=i===1?"Done.":`Done â ${i} images processed.`),d(100),setTimeout(()=>d(0),400)}catch(s){m(s instanceof Error?s.message:"OCR failed."),n&&(n.textContent="")}finally{f.disabled=(((b=e.files)==null?void 0:b.length)??0)===0}}),O(),E()}export{N as initOcrPage};
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.