PageSourceSearch

https://web.staply.app/assets/ExtImportResult-Dur9Jb0k.js

js staply.app collected 2026-10-02 01:16:04 UTC 3,033 bytes, 1 lines download raw bytes

1import{a as d,j as n,M as E}from"./index-BXljhCL3.js";import{f as j,u as I,r as m}from"./react-vendor-B3qmT6ny.js";import"./icons-vendor-DeqUZskh.js";const t=(o,l)=>{var e,p;return(((p=(e=E).getLanguage)==null?void 0:p.call(e))||"ru")==="ru"?o:l},_={"image-to-text":{operationType:"ocr",fallbackTitle:"OCR",extension:"txt",mime:"text/plain",textResult:!0},"photo-to-pdf":{operationType:"images_to_pdf",fallbackTitle:"Photo to PDF",extension:"pdf",mime:"application/pdf"},"pdf-to-images":{operationType:"pdf_to_images",fallbackTitle:"PDF to Images",extension:"zip",mime:"application/zip"}};function F(){const[o]=j(),l=I(),[e,p]=m.useState(""),u=m.useRef(!1);return m.useEffect(()=>{if(u.current)return;u.current=!0;const c=o.get("task")||"",R=o.get("kind")||"",a=_[R],w=(o.get("title")||"").trim().slice(0,120);if(!c||!a){p(t("Некорректная ссылка на результат","Invalid result link"));return}(async()=>{var f,g,x,h,y,b,T,S;try{const s=await d.get(`/api/ext/task/${encodeURIComponent(c)}/status`);if(((f=s.data)==null?void 0:f.state)!=="SUCCESS")throw new Error(t("Результат ещё не готов или уже недоступен","The result is not ready or is no longer available"));const k=w||a.fallbackTitle,i=new FormData;if(i.append("operation_type",a.operationType),i.append("title",k),i.append("collection_name",t("Результаты с сайта","Website Results")),a.textResult){const r=String(((g=s.data)==null?void 0:g.text)||"").trim();if(!r)throw new Error(t("Распознанный текст пуст","Recognized text is empty"));i.append("text",r)}else{const r=await d.get(`/api/ext/task/${encodeURIComponent(c)}/download`,{responseType:"blob"}),C=r.data instanceof Blob?r.data:new Blob([r.data],{type:a.mime});i.append("file",C,`${k.replace(/[\\/:*?"<>|]/g,"").trim()||a.fallbackTitle}.${a.extension}`)}const v=(x=(await d.post("/api/ext/save",i,{headers:{"Content-Type":"multipart/form-data"}})).data)==null?void 0:x.collection_id;l(v?`/collections/${v}`:"/history",{replace:!0})}catch(s){p(((b=(y=(h=s.response)==null?void 0:h.data)==null?void 0:y.detail)==null?void 0:b.message)||((S=(T=s.response)==null?void 0:T.data)==null?void 0:S.detail)||s.message||t("Не удалось сохранить результат","Could not save the result"))}})()},[o,l]),n.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",minHeight:"70vh",flexDirection:"column",gap:14,padding:24,textAlign:"center"},children:[n.jsx("div",{style:{fontSize:38},children:e?"⚠️":"📥"}),n.jsx("h1",{style:{margin:0,fontSize:24},children:e?t("Не удалось перенести результат","Could not import the result"):t("Сохраняем результат в Staply…","Saving the result to Staply…")}),e&&n.jsxs(n.Fragment,{children:[n.jsx("p",{style:{maxWidth:520,margin:0},children:String(e)}),n.jsx("button",{className:"btn-primary",onClick:()=>l("/",{replace:!0}),children:t("На главную","Go home")})]})]})}export{F as default};

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.