PageSourceSearch

https://app.modulaw.ai/assets/SharedLinkPage-CN0uM04J.js

js modulaw.ai collected 2026-10-05 12:23:50 UTC 6,267 bytes, 1 lines download raw bytes

1import{r,j as e,d as O}from"./react-vendor--6IG9Yi5.js";import{ae as B,aE as M,ac as z,n as A,L as K}from"./index-Bys9v8Oy.js";import{R as X}from"./ReadOnlyFile-DtBkv-KK.js";/* empty css               *//* empty css              */import{D as P}from"./download-CTaCJdWk.js";import{L as q}from"./loader-circle-BoEmSqWb.js";import{F as Y}from"./folder-MNe-5vvC.js";import{F as _}from"./file-text-CkVZzARM.js";import{b as G,d as H}from"./react-router-CEJpt0Xm.js";import"./redux-vendor-C8ygHAw9.js";import"./markdown-vendor-DxXj1xPu.js";import"./radix-vendor-Bx9qoP74.js";import"./tiptap-vendor-rePe3wTF.js";import"./recharts-vendor-DbKwtSaD.js";import"./query-vendor-B3TfXRMZ.js";import"./pdf.worker.min-CJdvD5t5.js";import"./warning-BR4MpAgC.js";const $=i=>i?i<1024*1024?`${Math.max(1,Math.round(i/1024))} KB`:`${(i/1024/1024).toFixed(1)} MB`:"",fe=()=>{const{token:i=""}=G(),R=B(),[p,S]=H(),h=p.get("folder"),w=p.get("file"),d=`${M.API_URL}/api/public/share-link/${encodeURIComponent(i)}`,[D,b]=r.useState(!0),[E,v]=r.useState(!1),[y,F]=r.useState(""),[u,U]=r.useState(null),[c,m]=r.useState(""),[T,k]=r.useState(null),[l,N]=r.useState(null),j=r.useMemo(()=>u?{"X-Link-Password":u}:{},[u]),g=r.useCallback(async s=>{b(!0),m("");try{const a=await fetch(`${d}${h?`?folder=${encodeURIComponent(h)}`:""}`,{method:"POST",headers:{"Content-Type":"application/json",...s?{"X-Link-Password":s}:{}},body:"{}"}),n=await a.json().catch(()=>({}));if(a.status===401&&(n!=null&&n.requiresPassword)){v(!0),s&&m("That password is not right.");return}if(!a.ok){m((n==null?void 0:n.message)||"This link is not available.");return}v(!1),U(s);const o=n==null?void 0:n.data;(o==null?void 0:o.kind)==="folder"?(N(o),k(null)):(k((o==null?void 0:o.file)||null),N(null))}catch{m("Could not reach the server. Please try again.")}finally{b(!1)}},[d,h]);r.useEffect(()=>{g(u)},[h]);const I=r.useCallback(async s=>{var n;const a=await fetch(`${d}/file${l&&s?`?doc=${encodeURIComponent(s)}`:""}`,{headers:j});if(!a.ok)throw new Error(((n=await a.json().catch(()=>({})))==null?void 0:n.message)||"This file could not be shown.");return a.blob()},[d,l,j]),L=async s=>{var C;const a=await fetch(`${d}/download${l?`?doc=${encodeURIComponent(s.id)}`:""}`,{headers:j});if(!a.ok){m(((C=await a.json().catch(()=>({})))==null?void 0:C.message)||"Download failed.");return}const n=URL.createObjectURL(await a.blob()),o=document.createElement("a");o.href=n,o.download=s.name,document.body.appendChild(o),o.click(),o.remove(),setTimeout(()=>URL.revokeObjectURL(n),1e3)},t=l&&w?l.files.find(s=>s.id===w)||null:T,x=!!t&&!t.canDownload;r.useEffect(()=>{if(!x)return;const s=n=>{(n.metaKey||n.ctrlKey)&&["p","s","c"].includes(n.key.toLowerCase())&&n.preventDefault()},a=n=>n.preventDefault();return window.addEventListener("keydown",s,!0),document.addEventListener("contextmenu",a,!0),document.addEventListener("copy",a,!0),()=>{window.removeEventListener("keydown",s,!0),document.removeEventListener("contextmenu",a,!0),document.removeEventListener("copy",a,!0)}},[x]);const f=s=>{const a=new URLSearchParams(p);s.folder!==void 0&&(s.folder?a.set("folder",s.folder):a.delete("folder"),a.delete("file")),s.file!==void 0&&(s.file?a.set("file",s.file):a.delete("file")),S(a)};return e.jsxs("div",{className:`sl-root${R?" pb-page":""}${x?" is-no-copy":""}`,children:[e.jsxs("header",{className:"sl-head",children:[t&&l?e.jsx("button",{type:"button",className:"sl-icon","aria-label":`Back to ${l.folder.name}`,onClick:()=>f({file:null}),children:e.jsx(z,{className:"h-5 w-5"})}):e.jsx("span",{className:"sl-brand",children:"ModulawAI"}),e.jsx("div",{className:"sl-title",children:t?e.jsxs(e.Fragment,{children:[e.jsx("b",{title:t.name,children:t.name}),e.jsx("small",{children:[t.type,$(t.size)].filter(Boolean).join(" · ")||"Shared file"})]}):l?e.jsx("nav",{className:"sl-trail","aria-label":"Folder",children:l.folder.trail.map((s,a)=>e.jsxs(O.Fragment,{children:[a>0&&e.jsx(A,{className:"h-3.5 w-3.5","aria-hidden":!0}),a<l.folder.trail.length-1?e.jsx("button",{type:"button",onClick:()=>f({folder:a===0?null:s.id}),children:s.name}):e.jsx("b",{children:s.name})]},s.id))}):e.jsx("b",{children:"Shared with you"})}),t&&t.canDownload&&e.jsxs("button",{type:"button",className:"sl-btn",onClick:()=>{L(t)},children:[e.jsx(P,{className:"h-4 w-4"})," Download"]})]}),e.jsxs("main",{className:"sl-main",children:[D?e.jsx("div",{className:"sl-center",children:e.jsx(q,{className:"h-5 w-5 animate-spin"})}):E?e.jsxs("form",{className:"sl-card",onSubmit:s=>{s.preventDefault(),g(y)},children:[e.jsx(K,{className:"h-6 w-6","aria-hidden":!0}),e.jsx("h1",{children:"This link has a password"}),e.jsx("input",{type:"password",value:y,onChange:s=>F(s.target.value),placeholder:"Password","aria-label":"Password",autoFocus:!0,className:"sl-input"}),c&&e.jsx("p",{className:"sl-error",children:c}
1),e.jsx("button",{type:"submit",className:"sl-btn is-primary",children:"Open"})]}):c&&!t&&!l?e.jsxs("div",{className:"sl-card",children:[e.jsx("h1",{children:"This link isn’t available"}),e.jsx("p",{className:"sl-muted",children:c})]}):t?e.jsxs(e.Fragment,{children:[!t.canDownload&&e.jsx("p",{className:"sl-banner",children:"You can view this file here. Downloading, printing and copying are turned off."}),e.jsx(X,{file:t,fetchBytes:I})]}):l?e.jsxs("ul",{className:"sl-list","aria-label":`In ${l.folder.name}`,children:[!l.folders.length&&!l.files.length&&e.jsx("li",{className:"sl-empty",children:"This folder is empty."}),l.folders.map(s=>e.jsx("li",{children:e.jsxs("button",{type:"button",onClick:()=>f({folder:s.id}),children:[e.jsx(Y,{className:"h-5 w-5","aria-hidden":!0}),e.jsx("span",{children:s.name})]})},s.id)),l.files.map(s=>e.jsxs("li",{children:[e.jsxs("button",{type:"button",onClick:()=>f({file:s.id}),children:[e.jsx(_,{className:"h-5 w-5","aria-hidden":!0}),e.jsx("span",{children:s.name}),e.jsx("small",{children:$(s.size)})]}),s.canDownload&&e.jsx("button",{type:"button",className:"sl-icon","aria-label":`Download ${s.name}`,title:"Download",onClick:()=>{L(s)},children:e.jsx(P,{className:"h-4 w-4"})})]},s.id))]}):e.jsx("div",{className:"sl-card",children:e.jsx("h1",{children:"This link isn’t available"})}),c&&(t||l)&&e.jsx("p",{className:"sl-error sl-float",children:c})]})]})};export{fe 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.