PageSourceSearch

https://localpdf.online/app/assets/WizardShell-BWt57YAP.js

js localpdf.online collected 2026-10-02 01:07:17 UTC 32,207 bytes, 1 lines download raw bytes

1var ge=Object.defineProperty;var me=(t,n,s)=>n in t?ge(t,n,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[n]=s;var H=(t,n,s)=>me(t,typeof n!="symbol"?n+"":n,s);import{r as i,j as e,i as xe,u as we}from"./vendor-react-C_xdI0Ng.js";import{g as re,c as ve,r as ye,u as ce}from"./index-DbFRh42P.js";import{L as je}from"./linear-icon-BS_Bu1OG.js";import{i as be,h as Ie,a as Ne,g as ze}from"./canvas-tools-D-8v7jH3.js";import{d as de}from"./preview-service-CUDLI67J.js";import"./vendor-icons-CmfhFn4k.js";const te={step:"upload",fileIds:[],outputIds:[],progress:0,isValidating:!1,isProcessing:!1,currentRunId:null,error:null,toast:null,upsellReason:null};function X(t,n){return t instanceof Error&&t.message.trim().length>0?t.message:n}function Ce(t){return be(t)}function Pe(t){const n=t.find(s=>typeof s.type=="string"&&s.type.trim().length>0);return n?n.type==="application/pdf"?"pdf":n.type.startsWith("image/")?"image":n.type.split("/")[0]||"unknown":"unknown"}async function K(t,n){await Promise.all(t.map(async s=>n(s)))}class ke{constructor(n){H(this,"state",{...te});H(this,"abortController",null);this.deps=n}getState(){return this.state}dismissToast(){return this.state={...this.state,toast:null},this.state}dismissUpsell(){return this.state={...this.state,upsellReason:null},this.state}cancelProcessing(n="cancel"){var s;this.state.currentRunId&&(this.deps.runtime.telemetry.track({type:"TOOL_RUN_ABANDONED",flowId:re(),runId:this.state.currentRunId,toolId:this.deps.toolId,reason:n}),this.state={...this.state,currentRunId:null}),(s=this.abortController)==null||s.abort()}async resetFlow(n=!0){var s;return(s=this.abortController)==null||s.abort(),this.abortController=null,n&&this.state.fileIds.length>0&&await K(this.state.fileIds,async d=>{await this.deps.runtime.vfs.delete(d)}),this.state={...te},this.state}async handleFilesAdded(n){var d,r;if(n.length===0)return this.state;if(!ve(this.deps.runtime.telemetry,this.deps.context.plan,n.length))return this.state;this.state={...this.state,isValidating:!0,error:null,toast:null,upsellReason:null};const s=[];try{for(const o of n){const c=await this.deps.runtime.vfs.write(o);s.push(c.id)}this.deps.context.plan==="basic"&&ye(s.length)}catch(o){if(s.length>0&&await K(s,async c=>{await this.deps.runtime.vfs.delete(c)}),Ce(o)){const c="Storage quota exceeded. Free some space and retry.";return(r=(d=this.deps).onToast)==null||r.call(d,c),this.state={...this.state,step:"upload",isValidating:!1,toast:c},this.state}return this.state={...this.state,step:"upload",isValidating:!1,error:X(o,"Failed to upload files")},this.state}try{const o=this.deps.runtime.registry.get(this.deps.toolId),c=await this.deps.limitService.check({runtime:this.deps.runtime,toolId:this.deps.toolId,toolLimits:o.limits,fileIds:s,context:this.deps.context});return c.allowed?(this.state={...this.state,step:"config",fileIds:s,outputIds:[],progress:0,isValidating:!1,error:null},this.deps.runtime.telemetry.track({type:"APP_FILE_UPLOADED",flowId:re(),toolId:this.deps.toolId,fileCount:s.length,mimeCategory:Pe(n),totalBytes:n.reduce((x,p)=>x+p.size,0),source:"wizard"}),this.state):(await K(s,async x=>{await this.deps.runtime.vfs.delete(x)}),this.state={...this.state,step:"upload",fileIds:[],isValidating:!1,upsellReason:c.reason??"Plan limit reached"},this.state)}catch(o){return await K(s,async c=>{await this.deps.runtime.vfs.delete(c)}),this.state={...this.state,step:"upload",fileIds:[],isValidating:!1,error:X(o,"Validation failed")},this.state}}async hydrateFromFileIds(n){const s=Array.from(new Set(n.filter(d=>typeof d=="string"&&d.length>0)));if(s.length===0)return this.state;if(this.state.fileIds.length===s.length&&this.state.fileIds.every((d,r)=>d===s[r])&&this.state.step!=="upload")return this.state;this.state={...this.state,isValidating:!0,error:null,toast:null,upsellReason:null};try{await Promise.all(s.map(async o=>this.deps.runtime.vfs.read(o)));const d=this.deps.runtime.registry.get(this.deps.toolId),r=await this.deps.limitService.check({runtime:this.deps.runtime,toolId:this.deps.toolId,toolLimits:d.limits,fileIds:s,context:this.deps.context});return r.allowed?(this.state={...this.state,step:"config",fileIds:s,outputIds:[],progress:0,isValidating:!1,isProcessing:!1,error:null},this.state):(this.state={...this.state,step:"upload",fileIds:[],outputIds:[],progress:0,isValidating:!1,upsellReason:r.reason??"Plan limit reached"},this.state)}catch(d){return this.state={...this.state,step:"upload",fileIds:[],outputIds:[],progress:0,isValidating:!1,error:X(d,"Failed to open selected files")},this.state}}async startProcessing(n){if(this.state.fileIds.length===0)return this.state={...this.state,step:"upload",error:"No files selected"},this.state;const s=Array.isArray(n==null?void 0:n.inputIds)?n.inputIds.filter(w=>typeof w=="string"):null,d=s&&s.length>0?s:this.state.fileIds,r=new AbortController,o=crypto.randomUUID();this.abortController=r,this.state={...this.state,step:"processing",progress:0,isProcessing:!0,currentRunId:o,error:null};const c={id:o,type:"COMMAND",payload:{type:"PROCESS_TOOL",payload:{toolId:this.deps.toolId,inputIds:d,options:n}}},p=(await this.deps.runtime.workerOrchestrator.dispatch(c,w=>
1{if(r.signal.aborted)return;const u=w.payload;u.type==="PROGRESS"&&(this.state={...this.state,progress:u.payload.progress})},r.signal)).payload;return r.signal.aborted||p.type==="ERROR"&&p.payload.code==="WORKER_ABORTED"?(this.state={...this.state,step:"config",isProcessing:!1,progress:0,currentRunId:null,error:"Processing canceled"},this.state):p.type==="ERROR"?(this.state={...this.state,step:"config",isProcessing:!1,progress:0,currentRunId:null,error:p.payload.message},this.state):p.type!=="RESULT"?(this.state={...this.state,step:"config",isProcessing:!1,progress:0,currentRunId:null,error:"Unexpected worker event"},this.state):(this.state={...this.state,step:"result",outputIds:p.payload.outputIds,isProcessing:!1,progress:100,currentRunId:null,error:null},this.state)}}function Se(t,n){const{runtime:s}=ce(),[d,r]=i.useState(()=>s.billing.getContext()),[o,c]=i.useState(te),[x,p]=i.useState(0);i.useEffect(()=>s.billing.subscribe(m=>{r(m)}),[s.billing]);const w=i.useMemo(()=>n.limitService??{check:async({runtime:g,fileIds:m,toolId:z,context:D})=>{const L=await g.runner.validateAccess(z,m,D);return L?{allowed:!1,reason:L.details??L.reason}:{allowed:!0}}},[n.limitService]),u=i.useMemo(()=>new ke({runtime:s,toolId:t,context:n.context??d,limitService:w,onToast:n.onToast}),[s,t,n.context,d,w,n.onToast]);i.useEffect(()=>(c(u.getState()),()=>{u.cancelProcessing("navigation")}),[u]),i.useEffect(()=>{if(typeof window>"u"||!o.isProcessing||!o.currentRunId)return;const g=()=>{u.cancelProcessing("pagehide")},m=()=>{document.visibilityState==="hidden"&&u.cancelProcessing("visibility_hidden")};return window.addEventListener("pagehide",g),document.addEventListener("visibilitychange",m),()=>{window.removeEventListener("pagehide",g),document.removeEventListener("visibilitychange",m)}},[u,o.currentRunId,o.isProcessing]);const a=i.useMemo(()=>{const g=s.registry.get(t);return i.lazy(g.uiLoader)},[s.registry,t,x]),b=i.useCallback(async g=>{const m=await u.handleFilesAdded(g);c({...m})},[u]),R=i.useCallback(async g=>{const m=await u.startProcessing(g);c({...m})},[u]),F=i.useCallback(async g=>{const m=await u.hydrateFromFileIds(g);c({...m})},[u]),h=i.useCallback(async(g=!0)=>{const m=await u.resetFlow(g);c({...m})},[u]),C=i.useCallback((g="cancel")=>{u.cancelProcessing(g)},[u]),j=i.useCallback(()=>{const g=u.dismissToast();c({...g})},[u]),N=i.useCallback(()=>{const g=u.dismissUpsell();c({...g})},[u]),B=i.useCallback(()=>{p(g=>g+1)},[]);return{state:o,configComponent:a,handleFilesAdded:b,hydrateFromFileIds:F,startProcessing:R,cancelProcessing:C,resetFlow:h,retryConfigLoad:B,dismissToast:j,dismissUpsell:N}}function oe(t){return t instanceof Error&&t.message.trim().length>0?t.message:"Preview is unavailable for this file"}function Re(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?`preview-${crypto.randomUUID()}`:`preview-${Math.random().toString(16).slice(2)}`}function Fe(t,n,s){const d=i.useMemo(()=>[...s],[s]),r=i.useMemo(()=>Re(),[]),[o,c]=i.useState([]),[x,p]=i.useState(!1);return i.useEffect(()=>{if(d.length===0){c([]),p(!1);return}const w=new AbortController;return p(!0),Promise.all(d.map(async u=>{const a=performance.now();try{const b=await de.getPreview(t,u,w.signal);return t.telemetry.track({type:"UI_PREVIEW_RENDERED",runId:r,toolId:n,fileId:u,durationMs:Math.max(0,Math.round(performance.now()-a)),pageCount:b.pageCount}),{...b,status:"ready"}}catch(b){return w.signal.aborted?null:(t.telemetry.track({type:"UI_PREVIEW_ERROR",runId:r,toolId:n,fileId:u,message:oe(b)}),{fileId:u,name:u,mimeType:"application/octet-stream",sizeBytes:0,kind:"file",thumbnailUrl:null,status:"error",errorMessage:oe(b)})}})).then(u=>{if(w.signal.aborted)return;const a=[];for(const b of u)b&&a.push(b);c(a),p(!1)}),()=>{w.abort()}},[r,t,d,n]),{previews:o,isLoading:x}}const Z=6,T=40;function Ee(t){if(t<=0)return"0 B";const n=["B","KB","MB","GB"];let s=t,d=0;for(;s>=1024&&d<n.length-1;)s/=1024,d+=1;return`${s.toFixed(s>=10||d===0?0:1)} ${n[d]}`}function le(t){return t==="application/pdf"?"PDF":t.startsWith("image/")?"Image":"File"}function Le({src:t,alt:n}){const[s,d]=i.useState(!1),r=i.useRef(null);return i.useEffect(()=>{const o=r.current;if(!o)return;if(typeof IntersectionObserver>"u"){d(!0);return}const c=new IntersectionObserver(x=>{const p=x[0];p!=null&&p.isIntersecting&&(d(!0),c.disconnect())},{rootMargin:"80px"});return c.observe(o),()=>c.disconnect()},[]),e.jsx("div",{ref:r,className:"preview-image-host",children:s?e.jsx("img",{src:t,alt:n,className:"preview-image",loading:"lazy"}):e.jsx("div",{className:"preview-fallback",children:"Loading"})})}function ee({runtime:t,previews:n,isLoading:s,toolId:d,title:r="Preview"}){var L;const[o,c]=i.useState(1),[x,p]=i.useState({}),[w,u]=i.useState({}),[a,b]=i.useState({}),[R,F]=i.useState({}),[h,C]=i.useState(null),j=Math.max(1,Math.ceil(n.length/Z));i.useEffect(()=>{c(l=>l>j?j:l)},[j]);const N=i.useMemo(()=>{const l=(o-1)*Z;return n.slice(l,l+Z)},[o,n]),B=N.length===1,g=((L=N[0])==null?void 0:L.kind)==="pdf",m=B&&g,z=d==="compress-pdf"&&B,D=z?3.2:m?2.6:1.15;return i.useEffect(()=>{const l=v=>{v.key==="Escape"&&C(null)};return window.addEventListener("keydown",l),()=>window.removeEventListener("keydown",l)},[]),i.useEffect(()=>{const l=new AbortController;return Promise.all(N.map(async v=>{if(v.kind!=="pdf")return;const P=x[v.fileId]??1,E=await de.getPdfPagePreview(t,v.fileId,P,{scale:D},l.signal);l.signal.aborted||(b(y=>({...y,[v.fileId]:E.thumbnailUrl})),E.pageCount!==void 0&&F(y=>({...y,[v.fileId]:E.pageCount})))})),()=>{l.abort()}},[N,x,D,t]),n.length===0&&!s?null:e.jsxs("section",{className:`preview-panel${z?" preview-panel-full-page":""}`,"aria-label":"File preview",children:[e.jsxs("div",{className:"preview-panel-header",children:[e.jsx("h3",{className:"preview-panel-title",children:r}),e.jsxs("div",{className:"preview-panel-meta",children:[s&&e.jsx("span",{className:"preview-panel-status",children:"Loading preview..."}),n.length>Z&&e.jsxs("div",{className:"preview-pagination",children:[e.jsx("button",{className:"btn-ghost preview-page-btn",onClick:()=>c(l=>Math.max(1,l-1)),disabled:o===1,children:"Prev"}),e.jsxs("span",{className:"preview-page-copy",children:[o,"/",j]}),e.jsx("button",{className:"btn-ghost preview-page-btn",onClick:()=>c(l=>Math.min(j,l+1)),disabled:o===j,children:"Next"})]})]})]}),e.jsx("div",{className:`preview-grid${m?" focus":""}${z?" full-page":""}`,children:N.map(l=>{const v=Math.max(1,l.pageCount??R[l.fileId]??1),P=Math.min(v,x[l.fileId]??1),E=a[l.fileId]??l.thumbnailUrl;return e.jsxs("article",{className:`preview-card${m?" preview-card-focus":""}${z?" preview-card-full-page":""}`,style:{contentVisibility:"auto",containIntrinsicSize:"280px 200px"},children:[e.jsxs("div",{className:`preview-thumb${m?" preview-thumb-focus":""}${z?" preview-thumb-full-page":""}`,children:[E?e.jsx("button",{type:"button",className:"preview-open-btn",onClick:()=>C({src:E,alt:`Preview of ${l.name}`}),title:"Open large preview","aria-label":"Open large preview",children:e.jsx(Le,{src:E,alt:`Preview of ${l.name}`})}):e.jsx("div",{className:"preview-fallback","aria-hidden":"true",children:le(l.mimeType)}),l.kind==="pdf"&&v>
11&&e.jsxs("div",{className:`preview-thumb-controls${z?" preview-thumb-controls-inline":""}`,children:[e.jsx("button",{className:"btn-ghost preview-page-btn","aria-label":"Prev page",title:"Prev page",onClick:()=>p(y=>({...y,[l.fileId]:Math.max(1,P-1)})),disabled:P<=1,children:"Prev"}),e.jsxs("span",{className:"preview-thumb-page",children:[P,"/",v]}),e.jsx("button",{className:"btn-ghost preview-page-btn","aria-label":"Next page",title:"Next page",onClick:()=>p(y=>({...y,[l.fileId]:Math.min(v,P+1)})),disabled:P>=v,children:"Next"})]})]}),e.jsxs("div",{className:"preview-meta",children:[e.jsx("p",{className:"preview-name",title:l.name,children:l.name}),e.jsxs("p",{className:"preview-copy",children:[le(l.mimeType)," · ",Ee(l.sizeBytes)]}),l.kind==="pdf"&&e.jsxs("p",{className:"preview-copy",children:["Pages: ",v]}),l.kind==="pdf"&&v>1&&e.jsxs("div",{className:"preview-page-grid-wrap",children:[e.jsxs("div",{className:"preview-page-grid-header",children:[e.jsx("span",{className:"preview-copy",children:"Page grid"}),v>T&&e.jsxs("div",{className:"preview-pagination",children:[e.jsx("button",{className:"btn-ghost preview-page-btn",onClick:()=>u(y=>{const k=Math.max(1,(y[l.fileId]??1)-T);return{...y,[l.fileId]:k}}),disabled:(w[l.fileId]??1)<=1,children:"Prev pages"}),e.jsx("button",{className:"btn-ghost preview-page-btn",onClick:()=>u(y=>{const k=y[l.fileId]??1,q=Math.min(Math.max(1,v-T+1),k+T);return{...y,[l.fileId]:q}}),disabled:(w[l.fileId]??1)+T>v,children:"Next pages"})]})]}),e.jsx("div",{className:"preview-page-grid",role:"grid","aria-label":"PDF pages grid",children:Array.from({length:Math.max(0,Math.min(T,v-((w[l.fileId]??1)-1)))},(y,k)=>(w[l.fileId]??1)+k).map(y=>e.jsx("button",{type:"button",className:`preview-page-tile${y===P?" active":""}`,style:{contentVisibility:"auto",containIntrinsicSize:"48px 48px"},onClick:()=>p(k=>({...k,[l.fileId]:y})),"aria-label":`Go to page ${y}`,children:y},`${l.fileId}-page-${y}`))})]}),l.status==="error"&&l.errorMessage&&e.jsx("p",{className:"preview-error",children:l.errorMessage})]})]},l.fileId)})}),h&&e.jsx("div",{className:"preview-lightbox",role:"dialog","aria-modal":"true","aria-label":"Large page preview",onClick:()=>C(null),children:e.jsx("img",{src:h.src,alt:h.alt,className:"preview-lightbox-image",onClick:l=>l.stopPropagation()})})]})}const Me=new Set(["word-to-pdf","excel-to-pdf"]);function Be(t){return Me.has(t)}function ue(...t){return t.filter(Boolean).join(" ")}function De({children:t}){return e.jsx(e.Fragment,{children:t})}class Y extends i.Component{constructor(s){super(s);H(this,"handleRetry",()=>{this.setState({hasError:!1}),this.props.onRetry()});this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}render(){return this.state.hasError?e.jsxs("div",{className:"wz-card wz-card-body",style:{borderColor:"rgba(224,62,62,0.25)",background:"rgba(224,62,62,0.06)",color:"var(--red)"},children:[e.jsx("p",{style:{fontSize:13,marginBottom:12},children:"Failed to load tool settings."}),e.jsx("button",{className:"wz-btn wz-btn-ghost",onClick:this.handleRetry,children:"Retry"})]}):this.props.children}}function Ae({disabled:t,accept:n="application/pdf",multiple:s=!0,autoOpen:d=!1,onFilesAdded:r}){const o=i.useRef(null),c=i.useRef(null),[x,p]=i.useState(!1),[w,u]=i.useState(!1),a=i.useRef(!1);i.useEffect(()=>{var h,C,j,N;if(!(!d||a.current||t)){if(a.current=!0,(h=navigator.userActivation)!=null&&h.isActive){(C=o.current)==null||C.click();return}u(!0),(j=c.current)==null||j.focus(),(N=c.current)==null||N.scrollIntoView({block:"center",behavior:"smooth"})}},[d,t]);const b=async h=>{!h||h.length===0||t||await r(Array.from(h))},R=async h=>{h.preventDefault(),p(!1),await b(h.dataTransfer.files)},F=async h=>{await b(h.target.files),h.target.value=""};return e.jsxs("div",{ref:c,className:ue("wz-upload-zone",x&&"wz-upload-zone--dragging",t&&"wz-upload-zone--disabled",w&&"wz-upload-zone--attention"),onClick:()=>{var h;return(h=o.current)==null?void 0:h.click()},onKeyDown:h=>{var C;(h.key==="Enter"||h.key===" ")&&(h.preventDefault(),(C=o.current)==null||C.click())},onDragOver:h=>{h.preventDefault(),p(!0)},onDragLeave:()=>p(!1),onDrop:R,role:"button",tabIndex:0,"aria-label":"Upload files",title:"Upload files",children:[e.jsx("div",{className:"wz-upload-icon",children:e.jsx(je,{name:"upload",className:"linear-icon icon-md"})}),e.jsx("p",{className:"wz-upload-title",children:w?"Choose your PDF to continue":"Drop files here or click to upload"}),e.jsx("p",{className:"wz-upload-hint",children:w?"Click here or press Enter — your file never leaves your device":`Supports ${n.includes("image")?"PDF and images":"PDF files"}`}),e.jsx("input",{ref:o,type:"file",accept:n,multiple:s,className:"hidden",onChange:F,disabled:t})]})}function Oe(t){return{async save(n){const s=await t.vfs.read(n),d=await s.getBlob(),r=URL.createObjectURL(d),o=document.createElement("a");o.href=r,o.download=s.getName(),o.click(),URL.revokeObjectURL(r)}}}const Ue={"merge-pdf":"Merging","split-pdf":"Splitting","rotate-pdf":"Rotating","delete-pages-pdf":"Deleting pages","pdf-editor":"Applying edits","compress-pdf":"Compressing","ocr-pdf":"Scanning","pdf-to-jpg":"Converting","word-to-pdf":"Converting","excel-to-pdf":"Converting","encrypt-pdf":"Encrypting","protect-pdf":"Protecting","unlock-pdf":"Unlocking","share-pdf":"Preparing share"},Te={"merge-pdf":"Merge complete","split-pdf":"Split complete","rotate-pdf":"Rotation complete","delete-pages-pdf":"Delete pages complete","pdf-editor":"Edits applied","compress-pdf":"Compression complete","ocr-pdf":"OCR complete","pdf-to-jpg":"Conversion complete","word-to-pdf":"Conversion complete","excel-to-pdf":"Conversion complete","encrypt-pdf":"Encryption complete","protect-pdf":"Protection complete","unlock-pdf":"Unlock complete","share-pdf":"Share ready"};function Ve(t){return Ue[t]??"Processing"}function _e(t){return Te[t]??"Action complete"}async function $e(t,n){const s=new Map,d=[];for(const r of n){if(!Number.isInteger(r.pageIndex)||r.pageIndex<0)continue;let o=s.get(r.fileId);if(!o){const F=await(await t.vfs.read(r.fileId)).getBlob();o=new Uint8Array(await F.arrayBuffer()),s.set(r.fileId,o)}const{PDFDocument:c}=await ze(),x=await c.load(o,{ignoreEncryption:!0}
1);if(r.pageIndex>=x.getPageCount())continue;const p=await c.create(),[w]=await p.copyPages(x,[r.pageIndex]);p.addPage(w);const u=new Uint8Array(await p.save()),a=new File([u],`studio-page-${r.pageIndex+1}.pdf`,{type:"application/pdf"}),b=await t.vfs.write(a);d.push(b.id)}return d}function We({step:t}){const n=["Configure","Processing","Result"],s=t==="upload"||t==="config"?0:t==="processing"?1:2;return e.jsx("div",{className:"wz-steps",children:n.map((d,r)=>{const o=r<s,c=r===s;return e.jsxs("div",{style:{display:"flex",alignItems:"center"},children:[e.jsxs("div",{className:`wz-step${c?" wz-step--active":o?" wz-step--done":""}`,children:[e.jsx("div",{className:"wz-step-num",children:o?"✓":r+1}),e.jsx("span",{className:"wz-step-label",children:d})]}),r<n.length-1&&e.jsx("div",{className:`wz-step-line${o?" wz-step-line--done":""}`})]},d)})})}const Ge=[{label:"Compress PDF",path:"/compress-pdf"},{label:"PDF to JPG",path:"/pdf-to-jpg"},{label:"Merge PDF",path:"/merge-pdf"},{label:"Protect PDF",path:"/protect-pdf"},{label:"Auto-TOC",path:"/auto-toc"}];function et({toolId:t,context:n,ioAdapter:s,limitService:d}){const{runtime:r}=ce(),o=xe(),c=we(),[x,p]=i.useState(0),w=n??r.billing.getContext(),u=i.useMemo(()=>new URLSearchParams(c.search).get("upload")==="1",[c.search]),{state:a,configComponent:b,handleFilesAdded:R,hydrateFromFileIds:F,startProcessing:h,cancelProcessing:C,resetFlow:j,retryConfigLoad:N,dismissToast:B,dismissUpsell:g}=Se(t,{context:w,limitService:d}),m=r.registry.get(t),z=b,D=z,L=a.step==="result"?a.outputIds:a.fileIds,{previews:l,isLoading:v}=Fe(r,t,L),P=(a.step==="config"||a.step==="result")&&m.layout==="split",E=i.useMemo(()=>`wizard-ui-${crypto.randomUUID()}`,[]),y=i.useMemo(()=>s??Oe(r),[s,r]),k=i.useCallback(async()=>{await Promise.all(a.outputIds.map(async f=>y.save(f)))},[y,a.outputIds]),q=i.useMemo(()=>t==="word-to-pdf"?".docx,application/vnd.openxmlformats-officedocument.wordprocessingml.document":t==="excel-to-pdf"?".xls,.xlsx,application/vnd.ms-excel,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":t==="ocr-pdf"?"application/pdf,image/*":"application/pdf",[t]),pe=i.useMemo(()=>!["pdf-to-jpg","split-pdf"].includes(t),[t]),I=c.state??null,S=(I==null?void 0:I.source)==="studio",M=I==null?void 0:I.studioContext,he=I==null?void 0:I.studioReturnContext,V=t==="word-to-pdf"||t==="excel-to-pdf"||t==="pdf-to-jpg"||t==="pdf-editor",A=t==="word-to-pdf"||t==="excel-to-pdf"||t==="pdf-to-jpg"&&!S||t==="pdf-editor",se=!Be(t),fe=()=>he,_=f=>
1{o("/studio",{state:{source:"studio",studioReturnContext:fe(),...f?{studioToolResult:{toolId:t,outputIds:a.outputIds,studioContext:M}}:{}}})},U=()=>{if(S){_(!1);return}j(!0)},$=i.useCallback(async f=>{f.length!==0&&(a.fileIds.length>0&&await j(!0),await R(f))},[R,j,a.fileIds.length]);i.useEffect(()=>{let f=!1;return(async()=>{const G=Array.isArray(I==null?void 0:I.preloadedFileIds)?I.preloadedFileIds.filter(O=>typeof O=="string"&&O.length>0):[],ae=(M==null?void 0:M.mode)==="page-selection"?M.selectedPages:[];let J=G;if(ae.length>0)try{const O=await $e(r,ae);O.length>0&&(J=O)}catch(O){console.error("Failed to prepare selected Studio pages for tool input:",O)}f||J.length===0||await F(J)})(),()=>{f=!0}},[F,c.key,I==null?void 0:I.preloadedFileIds,M,r]);const W=f=>h(M?{...f??{},studioContext:M}:f);i.useEffect(()=>{a.toast&&(r.telemetry.track({type:"UI_TOAST_SHOWN",runId:E,toolId:t,message:a.toast,level:"error"}),B())},[B,r.telemetry,a.toast,t,E]),i.useEffect(()=>{a.upsellReason&&g()},[g,a.upsellReason]);const Q=se&&!S&&Ie(t);if(i.useEffect(()=>{if(!Q)return;const f=new URLSearchParams;Ne(t)&&f.set("tool",t),new URLSearchParams(c.search).get("upload")==="1"&&f.set("upload","1");const G=f.toString();o(G?`/studio?${G}`:"/studio",{replace:!0,state:c.state})},[Q,c.search,c.state,o,t]),se&&!S)return e.jsxs("div",{className:"wz-page",children:[e.jsxs("div",{className:"wz-tool-header",children:[e.jsx("div",{className:"wz-tool-icon","aria-hidden":"true",children:e.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"var(--accent)",strokeWidth:"2",children:[e.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),e.jsx("polyline",{points:"14 2 14 8 20 8"})]})}),e.jsxs("div",{children:[e.jsx("div",{className:"wz-tool-title",children:m.name}),e.jsx("div",{className:"wz-tool-desc",children:m.description})]})]}),e.jsxs("div",{className:"wz-card wz-card-body",children:[e.jsx("p",{style:{fontSize:13,color:"var(--text-muted)",marginBottom:16},children:Q?"Opening this tool in the Studio canvas…":"This workflow is Studio-first. Select a document in Studio and launch the tool from there."}),e.jsx("button",{className:"wz-btn wz-btn-primary",onClick:()=>o("/studio"),children:"Go to Studio"})]})]});const ne=Ve(t),ie=_e(t);return e.jsxs("div",{className:ue("wz-page",P&&"wz-page--split",(t==="word-to-pdf"||t==="excel-to-pdf")&&"wz-page--fullwidth"),children:[e.jsxs("div",{className:"wz-tool-header",children:[e.jsx("div",{className:"wz-tool-icon","aria-hidden":"true",children:e.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"var(--accent)",strokeWidth:"2",children:[e.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),e.jsx("polyline",{points:"14 2 14 8 20 8"}),e.jsx("line",{x1:"16",y1:"13",x2:"8",y2:"13"}),e.jsx("line",{x1:"16",y1:"17",x2:"8",y2:"17"})]})}),e.jsxs("div",{children:[e.jsx("div",{className:"wz-tool-title",children:m.name}),e.jsx("div",{className:"wz-tool-desc",children:m.description}),e.jsxs("div",{className:"wz-tool-privacy",children:[e.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:e.jsx("path",{d:"M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z"})}),"Processed locally · files never leave your device"]})]})]}),!A&&e.jsx(We,{step:a.step}),a.error&&e.jsxs("div",{className:"wz-error",children:[e.jsx("strong",{children:"Error:"})," ",a.error]}),!A&&!P&&t!=="excel-to-pdf"&&t!=="pdf-editor"&&e.jsx(ee,{runtime:r,previews:l,isLoading:v,toolId:t,title:a.step==="result"?"Result Preview":"Preview"}),e.jsxs(De,{children:[A&&D&&e.jsx("div",{className:"wz-stage-fade",children:e.jsx(Y,{onRetry:()=>{N(),p(f=>f+1)},children:e.jsx(i.Suspense,{fallback:e.jsx("p",{style:{color:"var(--text-muted)",fontSize:13},children:"Loading configuration…"}),children:e.jsx(D,{inputFiles:a.fileIds,onStart:W,onBack:U,onPickFiles:a.isProcessing?void 0:$,onClearFiles:()=>void j(!0),currentStep:a.step,progress:a.progress,outputCount:a.outputIds.length,onDownload:S?void 0:()=>{k()}})})},x)}),!A&&a.step==="upload"&&(V&&z?e.jsx("div",{className:"wz-stage-fade",children:e.jsx(Y,{onRetry:()=>{N(),p(f=>f+1)},children:e.jsx(i.Suspense,{fallback:e.jsx("p",{style:{color:"var(--text-muted)",fontSize:13},children:"Loading configuration…"}),children:e.jsx(z,{inputFiles:a.fileIds,onStart:W,onBack:U,onPickFiles:$,onClearFiles:()=>void j(!0)})})},x)}):e.jsxs("div",{className:"wz-stage-fade",children:[e.jsx(Ae,{onFilesAdded:R,disabled:a.isValidating,multiple:pe,accept:q,autoOpen:u}),a.isValidating&&e.jsx("p",{style:{marginTop:12,fontSize:13,color:"var(--text-muted)"},children:"Validating access limits…"}),S&&e.jsx("div",{style:{marginTop:12},children:e.jsx("button",{className:"wz-btn wz-btn-ghost",onClick:U,children:"Back to Studio"})})]})),!A&&a.step==="config"&&z&&e.jsx("div",{className:"wz-stage-fade",children:P?e.jsxs("div",{className:"wizard-config-split",children:[e.jsx("div",{className:"wizard-config-preview-pane",children:e.jsx(ee,{runtime:r,previews:l,isLoading:v,toolId:t,title:"Preview"})}
1),e.jsx("div",{className:"wizard-config-controls-pane",children:e.jsx(Y,{onRetry:()=>{N(),p(f=>f+1)},children:e.jsx(i.Suspense,{fallback:e.jsx("p",{style:{color:"var(--text-muted)",fontSize:13},children:"Loading configuration…"}),children:e.jsx(z,{inputFiles:a.fileIds,onStart:W,onBack:U,onPickFiles:V?$:void 0,onClearFiles:V?(()=>void j(!0)):void 0})})},x)})]}):e.jsx(Y,{onRetry:()=>{N(),p(f=>f+1)},children:e.jsx(i.Suspense,{fallback:e.jsx("p",{style:{color:"var(--text-muted)",fontSize:13},children:"Loading configuration…"}),children:e.jsx(z,{inputFiles:a.fileIds,onStart:W,onBack:U,onPickFiles:V?$:void 0,onClearFiles:V?(()=>void j(!0)):void 0})})},x)}),!A&&a.step==="processing"&&e.jsx("div",{className:"wz-stage-fade",children:e.jsx("div",{className:"wz-card",children:e.jsxs("div",{className:"wz-card-body",style:{padding:"24px 20px"},children:[e.jsxs("div",{style:{marginBottom:20},children:[e.jsxs("div",{style:{fontSize:14,fontWeight:600,marginBottom:5,color:"var(--text)"},children:[ne,"…"]}),e.jsx("div",{style:{fontSize:13,color:"var(--text-muted)"},children:"Processing in your browser. Your file stays on your device."})]}),e.jsx("div",{className:"wz-progress-track",children:e.jsx("div",{className:"wz-progress-fill",style:{width:`${Math.max(2,a.progress)}%`}})}),e.jsxs("div",{className:"wz-progress-labels",children:[e.jsxs("span",{children:[ne,"…"]}),e.jsxs("span",{className:"wz-progress-pct",children:[Math.round(a.progress),"%"]})]}),e.jsxs("div",{className:"wz-processing-note",children:[e.jsx("div",{className:"wz-spinner"}),"Worker executing in private sandbox · 0 bytes sent to server"]}),e.jsx("div",{style:{marginTop:18},children:e.jsx("button",{className:"wz-btn wz-btn-ghost wz-btn-danger",onClick:()=>C(),children:"Cancel"})})]})})}),!A&&a.step==="result"&&e.jsx("div",{className:"wz-stage-fade",children:P?e.jsxs("div",{className:"wizard-result-split",children:[e.jsx("div",{className:"wizard-result-preview-pane",children:e.jsx(ee,{runtime:r,previews:l,isLoading:v,toolId:t,title:"Result Preview"})}),e.jsxs("div",{className:"wizard-result-controls-pane",children:[e.jsxs("div",{className:"wz-result-hero",style:{padding:"20px 0 16px"},children:[e.jsx("div",{className:"wz-result-check",children:"✓"}),e.jsx("div",{className:"wz-result-title",children:"Done"}),e.jsxs("div",{className:"wz-result-sub",children:[ie," · ",a.outputIds.length," file",a.outputIds.length!==1?"s":""," generated"]})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[!S&&e.jsxs("button",{className:"wz-btn wz-btn-primary",style:{width:"100%",justifyContent:"center"},onClick:()=>{k()},children:[e.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:[e.jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),e.jsx("polyline",{points:"7 10 12 15 17 10"}),e.jsx("line",{x1:"12",y1:"15",x2:"12",y2:"3"})]}),a.outputIds.length>1?"Download ZIP":"Download File"]}),e.jsx("button",{className:"wz-btn wz-btn-ghost",style:{justifyContent:"center"},onClick:()=>void j(!0),children:"Run again"}),S&&e.jsx("button",{className:"wz-btn wz-btn-primary",style:{justifyContent:"center"},onClick:()=>_(!0),children:"Save to Studio"}),S&&e.jsx("button",{className:"wz-btn wz-btn-ghost",style:{justifyContent:"center"},onClick:()=>_(!1),children:"Discard and Return"})]})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"wz-card",children:[e.jsxs("div",{className:"wz-result-hero",children:[e.jsx("div",{className:"wz-result-check",children:"✓"}),e.jsx("div",{className:"wz-result-title",children:"Done"}),e.jsxs("div",{className:"wz-result-sub",children:[ie," · ",a.outputIds.length," file",a.outputIds.length!==1?"s":""," generated"]})]}),e.jsxs("div",{className:"wz-output-row",children:[e.jsx("div",{className:"wz-output-icon",children:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"#0f7b6c",strokeWidth:"2",children:[e.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),e.jsx("polyline",{points:"14 2 14 8 20 8"})]})}),e.jsxs("div",{children:[e.jsxs("div",{className:"wz-output-name",children:[a.outputIds.length," file",a.outputIds.length!==1?"s":""," generated"]}),e.jsx("div",{className:"wz-output-meta",children:"Ready for download"})]}),!S&&e.jsxs("button",{className:"wz-btn-download",onClick:()=>{k()},children:[e.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:[e.jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),e.jsx("polyline",{points:"7 10 12 15 17 10"}),e.jsx("line",{x1:"12",y1:"15",x2:"12",y2:"3"})]}),"Download"]})]}),e.jsxs("div",{className:"wz-result-actions",children:[e.jsxs("button",{className:"wz-btn wz-btn-ghost",onClick:()=>void j(!0),children:[e.jsxs("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.2",children:[e.jsx("polyline",{points:"1 4 1 10 7 10"}),e.jsx("path",{d:"M3.51 15a9 9 0 1 0 .49-4.5"})]}),"Run again"]}),S?e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"wz-btn wz-btn-primary",onClick:()=>_(!0),children:"Save to Studio"}),e.jsx("button",{className:"wz-btn wz-btn-ghost",style:{marginLeft:"auto"},onClick:()=>_(!1),children:"← Back to Studio"})]}):e.jsx("button",{className:"wz-btn wz-btn-ghost",style:{marginLeft:"auto"},onClick:U,children:"← Back to Studio"})]})]}),e.jsxs("div",{className:"wz-also-try",children:[e.jsx("div",{className:"wz-also-try-label",children:"Also try"}),e.jsx("div",{className:"wz-also-try-list",children:Ge.filter(f=>!f.path.includes(t)).slice(0,4).map(f=>e.jsxs("div",{className:"wz-also-try-item",onClick:()=>o(f.path),children:[e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:e.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"})}),f.label]},f.label))})]})]})})]})]})}export{Ae as SmartUploadZone,et as WizardShell};

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.