1import{d as O,E as U,a as G}from"./ui-1491e31a.js";import{_ as q,D as b,P as I,a as z}from"./PDFCoreLoader-9907d2e9.js";import{d as M,P as W,aP as $,y,aQ as R,m as w,p as B,V as A,o as k,e as T,T as f,Y as S,q as h,f as L,a2 as C,a1 as j,am as H}from"./vendor-4a1bf3a7.js";import{m as K,n as d,o as Q,q as Y,_ as J,u as X}from"./index-6bbd9216.js";import{i as Z}from"./FileUploadComponent-6729e46e.js";const ee={class:"ai-pdf-ocr"},oe={key:0,class:"ocr"},te={class:"description"},ae={key:1,class:"analyze"},se={class:"percentage-value"},ne={class:"text"},le=M({__name:"AIPDFOcr",props:{dialogVisible:{type:Boolean,default:!1}},emits:["close","complete"],setup(g,{emit:v}){const r=g,{dialogVisible:D}=W(r),{t:n}=$(),a=y(!1),s=R(),u=y(""),i=w(()=>s.getters.convertProgress),P=w(()=>s.getters.isTaskDone&&i.value===100),_=w(()=>s.getters.fileList);let F=null;const l=v,p=async()=>{const t=_.value[0].ossInfo.file_id;if(!t)return;a.value=!0;try{await s.dispatch("getMultipleId")}catch(e){d(e.code),c();return}const o={multi_id:s.getters.multipleId,output_format:"pdf",languages:s.getters.languageId.join(","),file_id:t,passwd:"",using_ocr:1,ocr_type:2};await Q(o).then(e=>{u.value=e.task_id,s.dispatch("getTaskResult",{id:e.task_id,taskResultType:"single",isNeedSetStatus:!1}).catch(m=>{d(m.code),c()})}).catch(e=>{d(e.code),c()})},E=t=>{Y(t).then(o=>{const e=new Blob([o],{type:"application/pdf"}),m=new File([e],_.value[0].name,{type:"application/pdf"});l("complete",m),s.commit("UPDATE_IS_TASK_DONE",!1)}).catch(o=>{d(o.code),c()}).finally(()=>{})},c=()=>{l("close")};return B(()=>P.value,t=>{t&&K({task_id:u.value}).then(o=>{let{download_url:e}=o;e||(e=o),E(e)}).catch(o=>{d(o.code)}).finally(()=>{})}),B(()=>D.value,t=>{t?A(()=>{document.querySelector(".language-select-title").innerHTML=n("aiPDFTool.ocrLanguageSelectTitle")}):(clearTimeout(F),F=setTimeout(()=>{a.value=!1,s.commit("UPDATE_CONVERT_PROGRESS",{progress:0})},500))}),(t,o)=>{const e=q,m=O,x=U,V=G;return k(),T("div",ee,[f(V,{"model-value":h(D),"align-center":"","close-on-click-modal":!1,"show-close":!1},{default:S(()=>[a.value?(k(),T("div",ae,[f(x,{type:"circle",percentage:i.value,"stroke-width":18,color:"#4D64FD"},{default:S(({percentage:N})=>[L("span",se,C(N)+"%",1)]),_:1},8,["percentage"]),L("div",ne,C(t.$t("VIEW.chatPDFV2.Analyzing")),1)])):(k(),T("div",oe,[f(h(Z),{class:"close",onClick:c}),L("div",te,C(h(n)("aiPDFTool.ocrDescription")),1),f(e),f(m,{class:"btn",onClick:p},{default:S(()=>[j(C(h(n)("aiPDFTool.ocrBtnText")),1)]),_:1})]))]),_:1},8,["model-value"])])}}});const _e=J(le,[["__scopeId","data-v-b0e4590e"]]);function pe(){const{$sensorsApi:g}=X(),v=R(),r=y(!1),D=y(null);let n=null,a=null;return{loadPDFCore:async(u,i,P=!1)=>(r.value=!0,D.value=null,new Promise((_,F)=>{if(u)A(()=>{const{PDFCore:l,PDFFactory:p}=H(u);a=new b(l,p,window.document),i&&(n=new I(a,i.getBoundingClientRect(),P),r.value=!1,_({pdfDoc:n,docGlobals:a}))});else{performance.mark("pdfCoreLoadStart");const l=new z,p=l.loadPDFCore().then(l.loadPDFCoreModule).then(E=>{performance.mark("pdfCoreLoadEnd"),performance.measure("measure_load_PDFCore_duration","pdfCoreLoadStart","pdfCoreLoadEnd");const c=(performance.getEntriesByName("measure_load_PDFCore_duration")[0].duration/1e3).toFixed(3)+"s",{PDFCore:t,PDFFactory:o}=E;a=new b(t,o,window.document),n=new I(a,i.getBoundingClientRect(),P),g.track("EditPDF_WebAssembly",{ExactDuration:c,Result:"Success"}),performance.clearMarks("pdfCoreLoadStart"),performance.clearMarks("pdfCoreLoadEnd"),performance.clearMeasures("measure_load_PDFCore_duration"),_({pdfDoc:n,docGlobals:a})}).catch(()=>{d({code:3999}),g.track("EditPDF_WebAssembly",{Result:"Fail"}),F()}).finally(()=>{v.commit("DELETE_EDIT_BASIC_RESOURCE",p),r.value=!1})}})),isCoreLoading:r}}export{_e as _,pe as u};
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.