1import{d as ae,a3 as ge,a4 as ye,D as me,g as h,w as d,a as o,u as e,a5 as oe,a6 as pe,M as se,a7 as be,o as i,a8 as we,Y as xe,j as ve,a2 as le,r as v,i as p,C as ke,a9 as _e,c as u,f as s,t as y,h as b,H as te,aa as re,n as w,R as Ce,e as R,ab as de,ac as Le,ad as $e}from"./index-CYPoTM9a.js";import{p as ze,P as ue,L as Te,_ as Ue,a as Pe,b as Re,c as Ie,v as Se}from"./useAssetLibrary-D64rVkXs.js";import{_ as Ae}from"./FileTypeBadge.vue_vue_type_script_setup_true_lang-CILkm7BX.js";import{u as je}from"./useClipboardCopy-BNYi9rO7.js";import{u as Ee}from"./useDocumentTitle-EWDdssuh.js";import{f as Be,h as Oe,a as Ve,s as De,b as Me,v as Ne}from"./files-BUAjSKCJ.js";import{f as ce}from"./format-C0_KLEwl.js";import{_ as We}from"./Logo.vue_vue_type_script_setup_true_lang-DURdZWue.js";import{D as He}from"./download-DYvBKeD9.js";import{C as Fe}from"./check-DHEdr5f7.js";import{I as qe}from"./info-KAXReYAr.js";import{_ as fe}from"./Separator.vue_vue_type_script_setup_true_lang-D5DV7BM5.js";import{i as Xe,_ as Ye,a as Ke}from"./PopoverContent.vue_vue_type_script_setup_true_lang-CuP0IYbw.js";import{A as Ge}from"./arrow-left-CanXbGjw.js";import{L as Je}from"./lock-USEusKhV.js";import{L as Qe}from"./link-2-C6xMfmTZ.js";import{U as Ze}from"./users-CFapEMne.js";import"./markdown-BPhG52kO.js";import"./CopyButton.vue_vue_type_script_setup_true_lang-mKd4v1We.js";import"./copy-BTwhIxF0.js";import"./plus-B9wCogzE.js";import"./minus-DCl-Wyoq.js";import"./rotate-ccw-C6i9Qcoj.js";import"./SelectItem.vue_vue_type_script_setup_true_lang-Cha0asBu.js";import"./useTypeahead-CbIZGmNm.js";import"./Collection-mNWYi8LI.js";import"./chevron-down-CgP1jFIe.js";import"./ohash.D__AXeF1-C-E83dC9.js";import"./useFormControl-BbPmVLA4.js";import"./useFocusGuards-DY3p7F8S.js";var et=ae({__name:"PopoverTrigger",props:{asChild:{type:Boolean,required:!1},as:{type:null,required:!1,default:"button"}},setup(B){const C=B,r=Xe(),{forwardRef:f,currentElement:a}=ge();return r.triggerId||=ye(void 0,"reka-popover-trigger"),me(()=>{r.triggerElement.value=a.value}),(T,G)=>(i(),h(se(e(r).hasCustomAnchor.value?e(oe):e(be)),{"as-child":""},{default:d(()=>[o(e(oe),{id:e(r).triggerId,ref:e(f),type:T.as==="button"?"button":void 0,"aria-haspopup":"dialog","aria-expanded":e(r).open.value,"aria-controls":e(r).contentId,"data-state":e(r).open.value?"open":"closed",as:T.as,"as-child":C.asChild,onClick:e(r).onOpenToggle},{default:d(()=>[pe(T.$slots,"default")]),_:3},8,["id","type","aria-expanded","aria-controls","data-state","as","as-child","onClick"])]),_:3}))}}),tt=et;const st=ae({__name:"PopoverTrigger",props:{asChild:{type:Boolean},as:{}},setup(B){const C=B;return(r,f)=>(i(),h(e(tt),we({"data-slot":"popover-trigger"},C),{default:d(()=>[pe(r.$slots,"default")]),_:3},16))}}),at={mode:"none",channel:"none",blobType:null,reason:null};function nt(B){const C=encodeURIComponent(B),r=xe(),f=ve(),a=`/shared-assets/${C}/meta`,T=`/shared-assets/${C}`,G=`/shared-assets/${C}/thumbnail`,I=v("loading"),c=v(null),L=v(null),O=v(null),F=v(!1),V=v(!1),$=v(null),x=v(null),S=v(!1),D=v(!1);let M=null,g=!1;const U=new Set,A=new Map,q=p(()=>c.value===null?at:ze(c.value.kind,c.value.content_type));function X(n){const l=URL.createObjectURL(n);return U.add(l),l}function N(n){n!==null&&(U.delete(n),URL.revokeObjectURL(n))}function W(){return M??=r.blob(T),M}async function Z(){const n=q.value;if(N(L.value),L.value=null,O.value=null,F.value=!1,$.value=null,n.channel!=="none"){V.value=!0;try{const l=await W();if(g)return;if(n.channel==="text"){const m=await l.text();if(g)return;F.value=m.length>ue,O.value=m.slice(0,ue);return}L.value=X(new Blob([l],{type:n.blobType??"application/octet-stream"}))}catch(l){if(g)return;$.value=l instanceof Error?l:new Error(String(l))}finally{g||(V.value=!1)}}}async function Y(){if(N(x.value),x.value=null,!(c.value?.thumbnail_status!=="ready"||q.value.mode!=="none"))try{const n=await r.blob(G);if(g||n.size===0)return;x.value=X(new Blob([n],{type:"image/webp"}))}catch{}}let j=!1,k=!1;async function E(){try{return await r.get(a)}catch(n){if(!(!j&&n instanceof le&&n.status===404&&f.token.trim()!==""&&f.refreshToken.trim()!=="")||(j=!0,!await f.tryRefresh())
1)throw n;return await r.get(a)}}async function K(){M=null,I.value="loading";try{c.value=await E()}catch(n){if(g)return;if(c.value=null,N(L.value),L.value=null,O.value=null,$.value=null,x.value=null,!(n instanceof le&&n.status===404)){I.value="error";return}I.value=!k&&!f.isAuthenticated?"sign-in":"gone";return}g||(k=!0,I.value="ready",await Promise.all([Z(),Y()]))}async function ee(){if(!(c.value===null||S.value)){S.value=!0;try{const n=await W(),l=URL.createObjectURL(n),m=document.createElement("a");m.href=l,m.download=c.value.name,m.style.display="none",document.body.append(m),m.click(),m.remove();const J=setTimeout(()=>{A.delete(J),URL.revokeObjectURL(l)},6e4);A.set(J,l)}catch{g||await K()}finally{S.value=!1}}}async function H(n){const l=c.value?.asset_id;if(!(!l||D.value)){D.value=!0;try{const m=await r.put(`/assets/${encodeURIComponent(l)}/visibility`,{level:n});!g&&c.value?.asset_id===l&&(c.value={...c.value,visibility:m.visibility})}finally{D.value=!1}}}function P(){g=!0,M=null;for(const n of U)URL.revokeObjectURL(n);U.clear();for(const[n,l]of A)clearTimeout(n),URL.revokeObjectURL(l);A.clear(),L.value=null,x.value=null}return{state:I,asset:c,plan:q,previewUrl:L,previewText:O,previewTruncated:F,previewLoading:V,previewError:$,pagePreviewUrl:x,downloading:S,savingVisibility:D,load:K,download:ee,setVisibility:H,dispose:P}}const it={class:"flex h-dvh flex-col overflow-hidden bg-background text-foreground"},ot={class:"flex h-14 shrink-0 items-center gap-3 border-b border-border px-3 sm:px-4","data-testid":"shared-asset-bar"},lt={href:"https://console.patricia.app",rel:"noreferrer",class:"shrink-0 rounded-md focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","data-testid":"shared-asset-home"},rt={key:0,class:"sr-only sm:not-sr-only sm:min-w-0 sm:truncate sm:text-sm sm:font-medium sm:text-muted-foreground","data-testid":"shared-asset-name"},dt={class:"ml-auto flex shrink-0 items-center gap-1 sm:gap-2"},ut={class:"hidden sm:inline"},ct={class:"flex shrink-0 items-center","data-testid":"shared-asset-visibility"},ft={"aria-hidden":"true",class:"hidden sm:inline"},mt={key:1,class:"inline-flex items-center gap-1.5 px-2 text-sm text-muted-foreground","data-testid":"shared-asset-visibility-state"},pt={class:"sr-only"},vt={"aria-hidden":"true",class:"hidden sm:inline"},ht={class:"relative flex min-h-0 flex-1"},gt={class:"flex min-h-0 min-w-0 flex-1 flex-col"},yt={key:0,class:"border-b border-border bg-muted/50 px-4 py-3 sm:px-6",role:"status","aria-live":"polite","data-testid":"shared-asset-link-off"},bt={key:1,class:"flex min-h-0 flex-1 flex-col gap-4 p-4 sm:p-6","data-testid":"shared-asset-loading"},wt={key:2,class:"flex min-h-0 flex-1 items-center justify-center p-4 sm:p-6"},xt={class:"w-full max-w-md rounded-xl border border-border bg-card p-6 text-center shadow-sm sm:p-8",role:"status","aria-live":"polite","data-testid":"shared-asset-sign-in"},kt={key:3,class:"flex min-h-0 flex-1 items-center justify-center p-4 sm:p-6"},_t={class:"w-full max-w-md rounded-xl border border-border bg-card p-6 text-center shadow-sm sm:p-8",role:"status","aria-live":"polite","data-testid":"shared-asset-gone"},Ct={key:4,class:"flex min-h-0 flex-1 items-center justify-center p-4 sm:p-6"},Lt={class:"w-full max-w-md rounded-xl border border-border bg-card p-6 text-center shadow-sm sm:p-8",role:"alert","aria-live":"assertive","data-testid":"shared-asset-error"},$t={key:5,class:"flex min-h-0 flex-1","data-testid":"shared-asset-stage"},zt={key:0,id:"shared-asset-details",class:"absolute inset-y-0 right-0 z-20 flex w-full shrink-0 flex-col overflow-y-auto border-l border-border bg-card p-5 shadow-lg sm:w-80 lg:static lg:z-auto lg:shadow-none","data-testid":"shared-asset-details"},Tt={class:"flex items-start justify-between gap-2"},Ut={class:"mt-4 wrap-anywhere text-sm font-medium text-foreground"},Pt={class:"mt-1 text-xs text-muted-foreground"},Rt={class:"mt-6 space-y-3 text-sm"},It={class:"wrap-anywhere text-foreground","data-testid":"shared-asset-author"},St={class:"text-foreground"},At={key:0,"data-testid":"shared-asset-updated"},jt={class:"text-foreground"},Et={key:0,class:"mt-6 text-xs text-muted-foreground","data-testid":"shared-asset-expiry"},Bt={key:1,class:"mt-6 rounded-lg border border-border bg-background p-4","data-testid":"shared-asset-join-panel"},ps=ae({__name:"SharedAssetView",setup(B){const C=ke(),r=String(C.params.token??""),{state:f,asset:a,plan:T,previewUrl:G,previewText:I,previewTruncated:c,previewLoading:L,previewError:O,pagePreviewUrl:F,downloading:V,savingVisibility:$,load:x,download:S,setVisibility:D,dispose:M}=nt(r);Ee(()=>a.value?.name);const g=ve(),U=p(()=>g.isAuthenticated),A=p(()=>a.value?Oe(a.value.byte_size):null),q=p(()=>Ve(a.value?.author)),X=p(()=>a.value?De(a.value.expires_at):null),N=p(()=>a.value?ce(a.value.created_at):null),W=p(()=>a.value?ce(a.value.updated_at):null),Z=p(()=>W.value!==null&&W.value!==N.value),Y=v(null),j=p(()=>Y.value??T.value.mode==="none"),k=p(()=>a.value?.visibility??null),E=p(()=>k.value?Me(k.value):null),K=p(()=>k.value==="private"?Je:k.value==="external"?Qe:Ze),ee=p(()=>a.value?.can_change_visibility===!0&&!!a.value?.asset_id),H=v(!1),P=v(null);function n(z){const t=Ne(z,null);if(t===null){m(z);return}H.value=!1,P.value={level:z,warning:t}}const l=v(!1);async function m(z){try{await D(z),k.value==="private"&&(l.value=!0)}catch(t){$e.error("That file's visibility didn't change",{description:Se(t)})}finally{H.value=!1,P.value=null}}function J(){const z=P.value;z&&m(z.level)}const Q=je();function he(){Q.copy(()=>window.location.href)}const ne=p(()=>Q.copied.value?"Link copied":Q.failed.value?"Could not copy":"Copy link"),ie=`/login?redirect=${encodeURIComponent(`/shared/${r}`)}`;return me(()=>{x()}),_e(()=>M()),(z,t)=>(i(),u("div",it,[s("header",ot,[s("a",lt,[o(e(We),{class:"gap-2","mark-class":"size-6","wordmark-class":"sr-only sm:not-sr-only"})]),e(a)?(i(),u("h1",rt,y(e(a).name),1)):b("",!0),s("div",dt,[e(a)?(i(),u(te,{key:0},[o(e(w),{variant:"ghost",size:"sm",class:"h-11 min-w-11","aria-label":"Download",disabled:e(V),"data-testid":"shared-asset-download",onClick:t[0]||(t[0]=_=>e(S)())},{default:d(()=>[e(V)?(i(),h(e(re),{key:0,class:"size-4 animate-spin"})):(i(),h(e(He),{key:1,class:"size-4"})),t[10]||(t[10]=s("span",{class:"hidden sm:inline"},"Download",-1))]),_:1},8,["disabled"]),o(e(w),{variant:"ghost",size:"sm",class:"h-11 min-w-11","aria-label":ne.value,"data-testid":"shared-asset-copy",onClick:t[1]||(t[1]=_=>he())},{default:d(()=>[e(Q).copied.value?(i(),h(e(Fe),{key:0,class:"size-4 text-success"})):(i(),h(e(Te),{key:1,class:"size-4"})),s("span",ut,y(ne.value),1)]),_:1},8,["aria-label"]),o(e(w),{variant:"ghost",size:"icon","aria-label":j.value?"Hide file details":"Show file details","aria-expanded":j.value,"aria-controls":"shared-asset-details","data-testid":"shared-asset-details-toggle",onClick:t[2]||(t[2]=_=>Y.value=!j.value)},{default:d(()=>[o(e(qe),{class:"size-4"})]),_:1},8,["aria-label","aria-expanded"]),o(e(fe),{orientation:"vertical",class:"hidden h-6 sm:block"})],64)):b("",!0),k.value&&E.value?(i(),u(te,{key:1},[s("div",ct,[ee.value?(i(),h(e(Ke),{key:0,open:H.value,"onUpdate:open":t[3]||(t[3]=_=>H.value=_)},{default:d(()=>[o(e(st),{"as-child":""},{default:d(()=>[o(e(w),{variant:"ghost",size:"sm",class:"h-11 min-w-11",disabled:e($),"aria-label":`Who can see this file: ${E.value}. Change it.`,"data-testid":"shared-asset-visibility-change"},{default:d(()=>[e($)?(i(),h(e(re),{key:0,class:"size-4 animate-spin"})):(i(),h(se(K.value),{key:1,class:"size-4"})),s("span",ft,y(E.value),1)]),_:1},8,["disabled","aria-label"])]),_:1}),o(e(Ye),{align:"end",class:"w-80 space-y-2"},{default:d(()=>[o(Ue,{text:"Who can see this"}),o(Pe,{visibility:k.value,"can-change":"",busy:e($),onChange:n},null,8,["visibility","busy"])]),_:1})]),_:1},8,["open"])):(i(),u("span",mt,[(i(),h(se(K.value),{class:"size-4","aria-hidden":"true"})),s("span",pt,"Who can see this file: "+y(E.value),1),s("span",vt,y(E.value),1)]))]),o(e(fe),{orientation:"vertical",class:"hidden h-6 sm:block"})],64)):b("",!0),U.value?(i(),h(e(w),{key:2,"as-child":"",variant:"outline",size:"sm",class:"h-11 min-w-11","data-testid":"shared-asset-workspace"},{default:d(()=>[o(e(Ce),{to:"/home","aria-label":"Back to workspace"},{default:d(()=>[o(e(Ge),{class:"size-4"}),t[11]||(t[11]=s("span",{class:"hidden sm:inline"},"Back to workspace",-1))]),_:1})]),_:1})):e(f)!=="sign-in"&&e(f)!=="gone"?(i(),h(e(w),{key:3,as:"a",href:"/login",target:"_blank",rel:"noopener noreferrer",size:"sm",class:"h-11 min-w-11","data-testid":"shared-asset-join"},{default:d(()=>[...t[12]||(t[12]=[R(" Start free ",-1)])]),_:1})):b("",!0)])]),s("div",ht,[s("main",gt,[l.value?(i(),u("div",yt,[...t[13]||(t[13]=[s("p",{class:"text-sm text-foreground"}," This link is off now. Only me turns off every link to a file, including this one, so reloading this page will not open it again. ",-1),s("p",{class:"mt-1 text-sm text-muted-foreground"}," To share the file later, open it in Patricia and send a new link. ",-1)])])):b("",!0),e(f)==="loading"?(i(),u("div",bt,[o(e(de),{class:"h-6 w-64"}),o(e(de),{class:"min-h-0 w-full flex-1"})])):e(f)==="sign-in"?(i(),u("div",wt,[s("div",xt,[t[15]||(t[15]=s("h1",{class:"font-display text-lg font-semibold tracking-tight"}
1," Is this file from your workspace? ",-1)),t[16]||(t[16]=s("p",{class:"mt-3 text-sm text-muted-foreground"}," If you are in the workspace this file came from, sign in with that account and we will try the link again. ",-1)),t[17]||(t[17]=s("p",{class:"mt-2 text-sm text-muted-foreground"}," If you are not, a new account will not open it. Ask the person who sent you the link to share the file with you. ",-1)),o(e(w),{as:"a",href:ie,class:"mt-6","data-testid":"shared-asset-sign-in-link"},{default:d(()=>[...t[14]||(t[14]=[R(" Sign in ",-1)])]),_:1}),t[18]||(t[18]=s("p",{class:"mt-6 text-xs text-muted-foreground","data-testid":"shared-asset-sign-in-join"},[R(" Want your own Patricia? "),s("a",{href:"/login",target:"_blank",rel:"noopener noreferrer",class:"font-medium text-foreground underline-offset-4 hover:underline","data-testid":"shared-asset-sign-in-join-link"}," Start free ")],-1))])])):e(f)==="gone"?(i(),u("div",kt,[s("div",_t,[t[20]||(t[20]=s("h1",{class:"font-display text-lg font-semibold tracking-tight"}," You cannot open this file with this link ",-1)),t[21]||(t[21]=s("p",{class:"mt-3 text-sm text-muted-foreground"}," It may be open only to people in the workspace it came from, or the link may have closed. ",-1)),t[22]||(t[22]=s("p",{class:"mt-2 text-sm text-muted-foreground"}," Ask the person who sent it to share the file with you. ",-1)),U.value?b("",!0):(i(),h(e(w),{key:0,as:"a",href:ie,class:"mt-6","data-testid":"shared-asset-gone-sign-in-link"},{default:d(()=>[...t[19]||(t[19]=[R(" Sign in ",-1)])]),_:1}))])])):e(f)==="error"?(i(),u("div",Ct,[s("div",Lt,[t[24]||(t[24]=s("h1",{class:"font-display text-lg font-semibold tracking-tight"}," This page would not load ",-1)),t[25]||(t[25]=s("p",{class:"mt-3 text-sm text-muted-foreground"}," Something went wrong on the way to this file. Check your connection and try again. ",-1)),o(e(w),{class:"mt-6","data-testid":"shared-asset-retry",onClick:t[4]||(t[4]=_=>e(x)())},{default:d(()=>[...t[23]||(t[23]=[R(" Try again ",-1)])]),_:1})])])):e(a)?(i(),u("div",$t,[o(Re,{plan:e(T),url:e(G),text:e(I),truncated:e(c),name:e(a).name,kind:e(a).kind,"content-type":e(a).content_type,"byte-size":e(a).byte_size,loading:e(L),error:e(O),"page-preview-url":e(F),onDownload:t[5]||(t[5]=_=>e(S)()),onRetry:t[6]||(t[6]=_=>e(x)())},null,8,["plan","url","text","truncated","name","kind","content-type","byte-size","loading","error","page-preview-url"])])):b("",!0)]),e(a)&&j.value?(i(),u("aside",zt,[s("div",Tt,[o(Ae,{kind:e(a).kind,"content-type":e(a).content_type,size:"md"},null,8,["kind","content-type"]),o(e(w),{variant:"ghost",size:"icon","aria-label":"Hide file details","data-testid":"shared-asset-details-close",onClick:t[7]||(t[7]=_=>Y.value=!1)},{default:d(()=>[o(e(Le),{class:"size-4"})]),_:1})]),s("p",Ut,y(e(a).name),1),s("p",Pt,[R(y(e(Be)(e(a).kind)),1),A.value?(i(),u(te,{key:0},[R(" · "+y(A.value),1)],64)):b("",!0)]),s("dl",Rt,[s("div",null,[t[26]||(t[26]=s("dt",{class:"text-xs text-muted-foreground"},"Made by",-1)),s("dd",It,y(q.value),1)]),s("div",null,[t[27]||(t[27]=s("dt",{class:"text-xs text-muted-foreground"},"Made",-1)),s("dd",St,y(N.value),1)]),Z.value?(i(),u("div",At,[t[28]||(t[28]=s("dt",{class:"text-xs text-muted-foreground"},"Last updated",-1)),s("dd",jt,y(W.value),1)])):b("",!0)]),X.value?(i(),u("p",Et,y(X.value),1)):b("",!0),t[32]||(t[32]=s("p",{class:"mt-6 text-xs text-muted-foreground","data-testid":"shared-asset-intro"}," Someone shared this file with you through Patricia, and you do not need an account to open it. ",-1)),U.value?b("",!0):(i(),u("div",Bt,[t[30]||(t[30]=s("p",{class:"text-sm font-medium text-foreground"},"Want a teammate like this?",-1)),t[31]||(t[31]=s("p",{class:"mt-1 text-xs text-muted-foreground"}," Patricia is an AI teammate who works in Slack and Microsoft Teams. She does the research, writes the work up, and shares it with a link like this one. ",-1)),o(e(w),{as:"a",href:"/login",target:"_blank",rel:"noopener noreferrer",size:"sm",class:"mt-4 w-full","data-testid":"shared-asset-join-panel-link"},{default:d(()=>[...t[29]||(t[29]=[R(" Start free ",-1)])]),_:1})]))])):b("",!0)]),o(Ie,{open:P.value!==null,warning:P.value?.warning??"",busy:e($),onConfirm:t[8]||(t[8]=_=>J()),onCancel:t[9]||(t[9]=_=>P.value=null)},null,8,["open","warning","busy"])]))}});
1export{ps 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.