1(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,553926,e=>{"use strict";var r=e.i(391610),t=e.i(138415);let i={workspaceLocked:!1,blockedDocumentIds:new Set,isAtDocumentLimit:!1},n=(0,t.createContext)(i),a=(0,t.createContext)(null);function o({children:e,initialStatus:o}){let[d,s]=(0,t.useState)(()=>({...i,...o,blockedDocumentIds:o?.blockedDocumentIds??i.blockedDocumentIds}));return(0,r.jsx)(n.Provider,{value:d,children:(0,r.jsx)(a.Provider,{value:s,children:e})})}function d(){return(0,t.useContext)(n)}function s(){let e=(0,t.useContext)(a);if(!e)throw Error("useBillingStatusSetter must be used inside BillingStatusProvider");return e}e.s(["BillingStatusProvider",()=>o,"useBillingStatus",()=>d,"useBillingStatusSetter",()=>s])},980513,e=>{"use strict";var r=e.i(138415),t=e.i(553926);function i({workspaceLocked:e,blockedDocumentIds:i,isAtDocumentLimit:n}){let a=(0,t.useBillingStatusSetter)();return(0,r.useEffect)(()=>{a({workspaceLocked:e,blockedDocumentIds:new Set(i),isAtDocumentLimit:n})},[a,e,i,n]),null}e.s(["BillingStatusUpdater",()=>i])},393638,e=>{"use strict";var r=e.i(391610),t=e.i(138415),i=e.i(638437),n=e.i(770203),a=e.i(59663),o=e.i(558084);e.i(577630);var d=e.i(455852),s=e.i(7205),l=e.i(875487),c=e.i(687123),u=e.i(917397),m=e.i(353407),p=e.i(160283),f=e.i(69187),g=e.i(827764),w=e.i(739351),h=e.i(502916),k=e.i(236610),v=e.i(455231),y=e.i(781052),x=e.i(368531),I=e.i(873693),b=e.i(313759);function C({drawingId:e}){let{entry:t,pendingCount:i}=(0,I.useOfflineDrawingState)(e);return(0,r.jsx)(y.OfflineStatusIcon,{entry:t,pendingCount:i})}function S(e){let{drawingId:i,accountId:n,versionId:a,versionNumber:o,pageCount:s,title:u,workspaceName:m}=e,{t:p}=(0,d.useTranslation)("drawings"),y=(0,h.useSupabase)(),{entry:C,pendingCount:S,online:j}=(0,I.useOfflineDrawingState)(i),[D,F]=(0,t.useState)(),N=(0,t.useCallback)(async()=>{l.notify.message(p("offlineCardControl.downloading"),{id:`offline-add-${i}`,icon:(0,r.jsx)(g.Loader2,{className:"size-4 animate-spin"}),duration:1/0,closeButton:!0});let e=await (0,x.addDrawingOffline)({supabase:y,accountId:n,drawingId:i,versionId:a,versionNumber:o,pageCount:s,title:u,workspaceName:m});l.notify.dismiss(`offline-add-${i}`),e.ok?l.notify.success(p("offlineCardControl.availableOffline")):"insufficient_storage"===e.reason?l.notify.error(p("offlineCardControl.insufficientStorage")):"render_failed"===e.reason?l.notify.error(p("offlineCardControl.renderFailed")):l.notify.error(p("offlineCardControl.addFailed"))},[y,n,i,a,o,s,u,m,p]);return null===C||C?.prepState==="preparing"?null:C&&"stale"!==C.prepState?"none"!==C.visitState||S>0?null:(0,r.jsxs)(k.DropdownMenuItem,{className:"text-destructive focus:text-destructive",onSelect:()=>void(0,x.removeDrawingOffline)(i).then(e=>{e.ok||l.notify.error(p("offlineCardControl.syncPendingBeforeRemove"))}),children:[(0,r.jsx)(w.X,{className:"mr-2 h-4 w-4"}),(0,r.jsx)(c.Trans,{i18nKey:"drawings:offlineCardControl.removeFromDevice"})]}):j?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)(k.DropdownMenuItem,{onSelect:e=>{let r=(0,b.resolveSiteVisitGate)();if(!r.ready){e.preventDefault(),F(r.reason);return}N()},children:[(0,r.jsx)(f.HardDriveDownload,{className:"mr-2 h-4 w-4"}),(0,r.jsx)(c.Trans,{i18nKey:C?"drawings:offlineAvailabilityIcon.updateOfflineCopy":"drawings:offlineCardControl.makeAvailableOffline"})]}),D?(0,r.jsx)(v.IosInstallGateDialog,{open:!0,onOpenChange:e=>!e&&F(void 0),reason:D}):null]}):null}var j=e.i(879691),D=e.i(562830),F=e.i(978502),N=(0,F.createServerReference)("7fb0fd0d573008c1c83884542ad9b28b8e5846d565",F.callServer,void 0,F.findSourceMapURL,"loadViewerConnectionsAction"),P=e.i(443886),R=e.i(420136);function A({target:e,onRelinked:n}){let{t:a}=(0,d.useTranslation)("drawings"),o=(0,i.useRouter)(),[s,c]=(0,t.useState)({kind:"idle"}),u="dropbox"===e.provider?"dropbox":"google_drive",m=(0,t.useCallback)(async()=>{c({kind:"loading"});let r=await N({provider:u});if(!r.ok){l.notify.error(r.error,{fallback:a("relinkSource.loadFailed")}),c({kind:"idle"});return}let t=r.data.connections;c(e.userIntegrationId&&t.some(r=>r.id===e.userIntegrationId)?{kind:"picking",viaIntegrationId:e.userIntegrationId}:{kind:"choosing",accounts:t})},[u,a,e.userIntegrationId]),p=(0,t.useCallback)(e=>{c({kind:"handoff",viaIntegrationId:e}),setTimeout(()=>c({kind:"picking",viaIntegrationId:e}),0)},[]),f=(0,t.useCallback)(()=>{c({kind:"idle"}),l.notify.success(a("relinkSource.relinkedFromCard")),n?.(),o.refresh()},[n,o,a]);return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)(k.DropdownMenuItem,{onSelect:e=>{e.preventDefault(),m()},disabled:"loading"===s.kind,"data-test":"card-relink-source",children:[(0,r.jsx)(D.Link2,{className:"mr-2 h-4 w-4"}),a("relinkSource.menuItem")]}),"choosing"===s.kind&&(0,r.jsx)(R.RelinkAccountDialog,{provider:u,accounts:s.accounts,onChoose:p,onCancel:()=>c({kind:"idle"})}),"picking"===s.kind&&(0,r.jsx)(P.RelinkSourceDialog,{drawingSetId:e.id,drawingName:e.name,integrationId:s.viaIntegrationId,provider:u,open:!0,onOpenChange:e=>{e||c({kind:"idle"})},sourceFileId:e.externalFileId,sourcePath:e.externalFilePath,suggestedFileName:e.name,onRelinked:f})]})}var M=e.i(796552),E=e.i(99459),T=e.i(668346),O=e.i(357362),_=(0,F.createServerReference)("7f45bdcc41a65aa1b869bb5cbb2dafd68c6e9920b7",F.callServer,void 0,F.findSourceMapURL,"duplicateDrawingSetAction");e.i(389820);var L=e.i(565629),$=e.i(617339),B=e.i(233861),U=e.i(551907),W=e.i(179291),K=(0,F.createServerReference)("7f6b22ce913f28d72afe08e364fb94323adb5d10a4",F.callServer,void 0,F.findSourceMapURL,"createProjectAction"),V=(0,F.createServerReference)("7fc157eaae9d4d79915a2e3baf9a707f50541cd23a",F.callServer,void 0,F.findSourceMapURL,"deleteProjectAction"),G=(0,F.createServerReference)("7f51e24f6c18aeb9bb477b6a91e4ef6df92cc332bb",F.callServer,void 0,F.findSourceMapURL,"moveProjectAction"),q=e.i(4
116111);async function z(r){if(0!==r.length)try{let{purgeDrawingOffline:t}=await e.A(18248);await Promise.all(r.map(e=>t(e)))}catch{}}function H(e){let r=new URLSearchParams;return r.set("accountId",e.accountId),e.projectId&&r.set("projectId",e.projectId),e.cursor&&r.set("cursor",e.cursor),e.search&&r.set("search",e.search),r.set("sortField",e.sortField),r.set("sortDirection",e.sortDirection),e.includeFolders&&r.set("include","folders"),`/api/file-browser/workspace?${r.toString()}`}var Q=e.i(395002),X=e.i(553926),J=e.i(633129),Y=e.i(716012),Z=e.i(728387),ee=e.i(186263),er=e.i(963633),et=e.i(308370),ei=e.i(932647),en=e.i(453620),ea=e.i(396118),eo=e.i(669418),ed=e.i(761530),es=e.i(22726),el=e.i(405459),ec=e.i(466401),eu=e.i(706048),em=e.i(954617),ep=e.i(747761),ef=e.i(214769),eg=e.i(768455),ew=e.i(33542),eh=e.i(411821);let ek="import-source:",ev="import-source:changed";function ey(e){return`${ek}${e}`}function ex(e,r){try{window.localStorage.setItem(ey(e),r)}catch{}window.dispatchEvent(new CustomEvent(ev,{detail:{accountId:e}}))}function eI(e){let r=()=>e(),t=r=>{r.key&&r.key.startsWith(ek)&&e()};return window.addEventListener(ev,r),window.addEventListener("storage",t),()=>{window.removeEventListener(ev,r),window.removeEventListener("storage",t)}}var eb=(0,F.createServerReference)("7f526106b383496b52b96618bb6dfff9cfb29206b0",F.callServer,void 0,F.findSourceMapURL,"copyDocumentAction"),eC=e.i(816665),eS=e.i(438275),ej=e.i(287751);function eD(e){return"device"===e.kind||"upload"===e.kind?"local":(0,eS.fileOriginKey)(e)}function eF({viewMode:e,account:n,projectId:a,sources:o,workspaces:s,disabled:c,isAtIntegrationLimit:u,onPickLocalUpload:m}){let{t:p}=(0,d.useTranslation)("drawings"),f=(0,es.useImportLanding)(),g=(0,h.useSupabase)(),w=(0,t.useSyncExternalStore)(eI,()=>(function(e){try{return window.localStorage.getItem(ey(e))}catch{return null}})(n),()=>null),[v,y]=(0,t.useState)(!1),[x,I]=(0,t.useState)(null),[b,C]=(0,t.useState)(null),[S,j]=(0,t.useState)(!1),[D,F]=(0,t.useState)(!1),[N,P]=(0,t.useState)(!1),R=o.find(e=>"local"===e.provider&&e.connected)??null,A=(0,t.useMemo)(()=>{let e=o.find(e=>"local"===e.provider&&e.connected)??null;return[e?{kind:"device",id:e.id,name:e.displayName}:{kind:"upload"},...o.filter(e=>"local"!==e.provider).map(e=>({kind:"integration",id:e.id,provider:e.provider,name:e.displayName,blocked:e.blocked})),...s.filter(e=>e.id!==n).map(e=>({kind:"workspace",id:e.id,name:e.name}))]},[n,o,s]),M=A[0],E=null===w?null:"local"===w?M:A.find(e=>((0,eS.fileOriginKey)(e)===w||"integration"===e.kind&&e.id===w)&&!("integration"===e.kind&&e.blocked))??null,O=R?.displayName??p("importCard.thisDevice"),_=E?.kind==="integration"||E?.kind==="workspace"?E.name:O,$=(0,t.useCallback)(async e=>{let r=await (0,eC.shareWithWorkspaceAction)({drawingSetId:e,accountId:n,projectId:a});if(r.ok)return{status:"shared",drawingId:e};if("share.already_in_workspace"===r.error.code){let{data:r}=await g.from("drawing_sets").select("account_id").eq("id",e).maybeSingle();if(r?.account_id===n)return{status:"already-here",drawingId:e};let t=await (0,ep.getLinkedDrawingWorkspaceAction)({drawingSetId:e});return{status:"already-elsewhere",teamName:t.ok?t.data.workspaceName:null}}return{status:"failed",message:(0,eg.mapErrorToMessage)(r.error,p("importCard.shareFailed"))}},[n,a,g,p]),B=(0,t.useCallback)(async e=>{let r=[],t=[];for(let i of e){let e=await $(i);"shared"===e.status||"already-here"===e.status?t.push(i):"already-elsewhere"===e.status?r.push(e.teamName?p("importCard.alreadyInNamedTeam",{team:e.teamName}):p("importCard.alreadyInOtherTeam")):r.push(e.message)}return{extraErrors:r,openable:t,successMessage:1===t.length?p("importCard.addedOne"):p("importCard.addedMany",{count:t.length})}},[$,p]),U=(0,t.useMemo)(()=>({importingOne:e=>p("importCard.importing",{name:e||p("importCard.fileFallback")}),importingMany:e=>p("importCard.importingCount",{count:e}),progressStep:(e,r)=>p("importCard.importingProgress",{current:e+1,total:r}),importedOne:p("importCard.addedOne"),importedMany:e=>p("importCard.addedMany",{count:e}),failedMany:e=>p("importCard.failedMany",{count:e}),fallback:p("importCard.importFailed")}),[p]),W=(0,t.useMemo)(()=>({importingOne:e=>p("copyDocument.copying",{name:e||p("importCard.fileFallback")}),importingMany:e=>p("copyDocument.copyingCount",{count:e}),progressStep:(e,r)=>p("copyDocument.copyingProgress",{current:e+1,total:r}),importedOne:p("copyDocument.copiedOne"),importedMany:e=>p("copyDocument.copiedMany",{count:e}),failedMany:e=>p("copyDocument.copyFailedMany",{count:e}),fallback:p("copyDocument.copyFailed")}),[p]),K=(0,t.useCallback)(async e=>{y(!0);let r=(0,ef.deviceImportSteps)(e);try{await (0,eo.runImportFlow)({landing:f,progressId:eo.IMPORT_PROGRESS_ID.device,copy:U,pick:r.pick,importPicked:r.importPicked,postImport:B,destination:e=>`/home/${n}/drawings/${e}`})}finally{y(!1)}},[n,B,U,f]),V=(0,t.useCallback)(async(e,r)=>{y(!0);try{await (0,eo.runImportFlow)({landing:f,progressId:eo.IMPORT_PROGRESS_ID.dropbox,copy:U,pick:async()=>[{id:r.id,name:r.name}],importPicked:async t=>{let i=await (0,ei.importFromDropboxAction)({fileId:t[0].id,integrationId:e});return i.success?{drawingIds:[i.drawingId],errors:[]}:{drawingIds:[],errors:[(0,eg.mapErrorToMessage)(i.error,p("importCard.importFailedName",{name:r.name}))]}},postImport:B,destination:e=>`/home/${n}/drawings/${e}`})}finally{y(!1)}},[n,B,U,f,p]),G=(0,t.useCallback)(async e=>{y(!0);try{await (0,eo.runImportFlow)({landing:f,progressId:eo.IMPORT_PROGRESS_ID.workspace,copy:W,pick:async()=>[{id:e.drawingSetId,name:e.name}],importPicked:async()=>{let r=await eb({sourceVersionId:e.versionId,accountId:n,...a?{projectId:a}:{}});return r.ok?{drawingIds:[r.drawingSetId],errors:[]}:{drawingIds:[],errors:[r.error]}},destination:e=>`/home/${n}/drawings/${e}`})}finally{y(!1)}},[n,W,f,a]),q=(0,t.useCallback)(e=>{(0,ed.markPickInFlight)(e,n),l.notify.info(p("importCard.pickHandoffTitle")),window.location.href=`/integrations/desktop/pick?integrationId=${encodeURIComponent(e)}&accountId=${encodeURIComponent(n)}`},[n,p]),z=(0,t.useCallback)(async e=>{let r=(0,T.isDesktopShell)();if(r&&!(0,eh.canPickInShell)())return void q(e);y(!0);try{await (0,eo.runImportFlow)({landing:f,progressId:eo.IMPORT_PROGRESS_ID.drive,copy:U,pick:async()=>{let{accessToken:t}=(0,L.unwrapAction)(await (0,em.getGoogleDriveTokenAction)({integrationId:e}));if(r){let r=await (0,eh.pickInShell)({accessToken:t});return"unavailable"===r.status?(q(e),null):"picked"===r.status?r.files.map(e=>({id:e.fileId,name:e.name})):null}return(await (0,ew.openFilePicker)({accessToken:t})).map(e=>({id:e.fileId,name:e.name}))},importPicked:async(r,t)=>{let i=[],n=[];for(let[a,o]of r.entries()){t(a,r.length);let d=await (0,en.importFromGoogleDriveAction)({fileId:o.id,integrationId:e});d.success?i.push(d.drawingId):n.push((0,eg.mapErrorToMessage)(d.error,p("importCard.importFailedName",{name:o.name})))}return{drawingIds:i,errors:n}},postImport:B,destination:e=>`/home/${n}/drawings/${e}`})}finally{y(!1)}},[n,B,q,U,f,p]),H=(0,t.useCallback)(e=>{switch(e.kind){case"device":K(e.id);return;case"upload":m();return;case"integration":"dropbox"===e.provider?I(e.id):z(e.id);return;case"workspace":C({id:e.id,name:e.name});return;default:return}},[m,K,z]),Q=(0,t.useCallback)(()=>{c||v||(E?H(E):j(!0))}
1,[v,E,c,H]),X=(0,t.useCallback)(e=>{ex(n,eD(e)),c||v||H(e)},[n,v,c,H]),Y=(0,i.useSearchParams)(),ek=Y.get(ec.CONNECT_INTENT_PARAM),eF=Y.getAll("integrationId").at(-1)??null,eP=Y.get("error"),eR=(0,t.useRef)(!1);(0,t.useEffect)(()=>{if(ek!==ec.CONNECT_INTENT_IMPORT||eR.current)return;eR.current=!0;let e=new URL(window.location.href);e.searchParams.delete(ec.CONNECT_INTENT_PARAM),e.searchParams.delete("integrationId"),e.searchParams.delete("error");let r=`${e.pathname}${e.search}`;if(queueMicrotask(()=>window.history.replaceState(null,"",r)),eP)return void queueMicrotask(()=>l.notify.error("integration_limit_reached"===eP?p("importCard.connectLimitReached"):p("importCard.connectFailed")));let t=A.find(e=>"integration"===e.kind&&e.id===eF&&!e.blocked);!t||c||v||H(t)},[v,eP,ek,eF,c,A,H,p]);let eA=(0,r.jsx)(eS.FileOriginMenu,{origins:A,selected:E,onPick:X,header:p("importCard.pickSource"),footer:(0,r.jsxs)(r.Fragment,{children:[E&&(0,r.jsxs)(k.DropdownMenuItem,{onSelect:()=>(function(e){try{window.localStorage.removeItem(ey(e))}catch{}window.dispatchEvent(new CustomEvent(ev,{detail:{accountId:e}}))})(n),children:[(0,r.jsx)(ee.RotateCcw,{className:"mr-2 h-4 w-4"}),p("importCard.askEveryTime")]}),(0,r.jsxs)(k.DropdownMenuItem,{onSelect:()=>P(!0),children:[(0,r.jsx)(Z.Plus,{className:"mr-2 h-4 w-4"}),p("connectProviderDialog.title")]})]}),children:(0,r.jsxs)("button",{type:"button","data-test":"import-source-selector",onClick:e=>e.stopPropagation(),className:"text-muted-foreground hover:text-foreground flex min-w-0 items-center gap-1 text-[11px] leading-tight transition-colors",children:[E&&(0,r.jsx)(eS.FileOriginIcon,{origin:E,className:"h-3 w-3 shrink-0"}),(0,r.jsx)("span",{className:"truncate",children:E?p("importCard.fromSource",{source:_}):p("importCard.chooseSource")}),(0,r.jsx)(J.ChevronDown,{className:"h-3 w-3 shrink-0"})]})}),eM=(0,r.jsx)(et.Dialog,{open:S,onOpenChange:j,children:(0,r.jsxs)(et.DialogContent,{className:"sm:max-w-sm","data-test":"import-source-panel",children:[(0,r.jsx)(et.DialogHeader,{children:(0,r.jsx)(et.DialogTitle,{children:p("importCard.pickSource")})}),(0,r.jsxs)("div",{className:"flex flex-col gap-1",children:[A.map(e=>(0,r.jsx)(eN,{origin:e,disabled:"integration"===e.kind&&!!(e.blocked||e.unavailable),onPick:()=>{D&&ex(n,eD(e)),j(!1),H(e)}},(0,eS.fileOriginKey)(e))),(0,r.jsxs)("button",{type:"button",onClick:()=>{j(!1),P(!0)},className:"text-muted-foreground hover:bg-accent hover:text-foreground flex items-center gap-3 rounded-md border border-dashed px-3 py-2.5 text-left text-sm transition-colors",children:[(0,r.jsx)(Z.Plus,{className:"h-4 w-4 shrink-0"}),p("connectProviderDialog.title")]})]}),(0,r.jsxs)("label",{className:"text-muted-foreground flex cursor-pointer items-center gap-2 text-xs",children:[(0,r.jsx)(er.Checkbox,{checked:D,onCheckedChange:e=>F(!0===e)}),p("importCard.alwaysUse")]})]})}),eE=null!==x&&(0,r.jsx)(eu.DropboxFilePicker,{integrationId:x,open:!0,onOpenChange:e=>{e||I(null)},mode:"select",onSelect:e=>{I(null),V(x,e)}}),eT=null!==b&&(0,r.jsx)(ej.WorkspaceFilePicker,{root:{kind:"workspace",accountId:b.id,name:b.name},title:b.name,description:p("copyDocument.description"),onOpenChange:e=>{e||C(null)},onPick:e=>{C(null),G(e)}},b.id),eO=(0,r.jsxs)(r.Fragment,{children:[eM,eE,eT,(0,r.jsx)(ea.ConnectProviderDialog,{isOpen:N,setIsOpen:P,isAtLimit:u,intent:ec.CONNECT_INTENT_IMPORT})]});return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(el.ImportCard,{viewMode:e,"data-test":"list"===e?"import-source-row":"import-source-card",title:p("importCard.title"),subtitle:eA,busy:v,disabled:c,onActivate:Q}),eO]})}function eN({origin:e,disabled:t,onPick:i}){return(0,r.jsxs)("button",{type:"button",disabled:t,onClick:i,className:"hover:bg-accent flex items-center gap-1 rounded-md border px-3 py-2.5 text-left text-sm transition-colors disabled:cursor-not-allowed disabled:opacity-50",children:[(0,r.jsx)(eS.FileOriginLabel,{origin:e}),t?(0,r.jsx)(Y.Lock,{className:"ml-auto h-3.5 w-3.5 shrink-0"}):null]})}var eP=e.i(272875),eR=e.i(673345);function eA({drawing:e,accountId:i,projectId:n,teams:a,onClose:o,onMoved:c}){let{t:u}=(0,d.useTranslation)("drawings"),m=(0,h.useSupabase)(),[p,f]=(0,t.useState)({accountId:i,projectId:n}),[w,k]=(0,t.useTransition)(),v=(0,eP.useQuery)({queryKey:["workspace-destination-folders",p.accountId],queryFn:async()=>{let e=[];for(let r=0;;r+=1e3){let{data:t,error:i}=await m.from("projects").select("id, name, parent_id, account_id").eq("account_id",p.accountId).is("deleted_at",null).order("id").range(r,r+999);if(i)throw i;if(e.push(...t),t.length<1e3)return e}}}),y=p.accountId===i&&p.projectId===n;return(0,r.jsx)(et.Dialog,{open:!0,onOpenChange:e=>{e||w||o()},children:(0,r.jsxs)(et.DialogContent,{"data-test":"move-drawing-dialog",className:"sm:max-w-md",children:[(0,r.jsxs)(et.DialogHeader,{children:[(0,r.jsx)(et.DialogTitle,{children:u("drawingSetCard.moveTitle")}),(0,r.jsx)(et.DialogDescription,{children:u("drawingSetCard.moveDescription",{name:e.name})})]}),(0,r.jsx)(eR.WorkspaceDestinationPicker,{teams:a,folders:v.data??[],...p,onChange:f,disabled:w}),v.isPending&&(0,r.jsx)(g.Loader2,{className:"mx-auto h-5 w-5 animate-spin"}),v.isError&&(0,r.jsxs)("div",{role:"alert",className:"text-destructive text-sm",children:[u("drawingSetCard.foldersFailed"),(0,r.jsx)(s.Button,{variant:"ghost",onClick:()=>void v.refetch(),children:u("drawingSetCard.retry")})]}),(0,r.jsxs)(et.DialogFooter,{children:[(0,r.jsx)(s.Button,{variant:"outline",onClick:o,disabled:w,children:u("drawingSetCard.cancel")}),(0,r.jsxs)(s.Button,{onClick:()=>k(async()=>{await (0,M.runAction)((0,U.moveDrawingSetAction)({id:e.id,accountId:i,targetAccountId:p.accountId,projectId:p.projectId}),{fallback:u("drawingSetCard.moveFailed")})&&(l.notify.success(u("drawingSetCard.moveSuccess")),await c(),o())}),disabled:w||y||!v.isSuccess,"data-test":"move-drawing-confirm",children:[w&&(0,r.jsx)(g.Loader2,{className:"mr-2 h-4 w-4 animate-spin"}),u("drawingSetCard.move")]})]})]})})}function eM({account:f,projects:g,drawingSets:w,initialNextCursor:h=null,currentProjectId:k,breadcrumbs:v,basePath:y,rootCrumb:x,menuItems:I,spaceTint:b="workspace",teamAccounts:D,importSources:F,isAtIntegrationLimit:N}){let{t:P}=(0,d.useTranslation)("drawings"),{workspaceLocked:R,blockedDocumentIds:J,isAtDocumentLimit:Y}=(0,X.useBillingStatus)(),Z=(0,i.useRouter)(),ee=(0,t.useRef)(null),[er,et]=(0,t.useState)(!1),[ei,en]=(0,t.useTransition)(),ea=(0,t.useRef)(0),[eo,ed]=(0,t.useState)(null),es=(0,t.useRef)(!1),el=async(e,r)=>{if(!e.currentVersionId||es.current)return;es.current=!0,ed(e.id);let t=l.notify.progress(`duplicate-${e.id}`,P("drawingSetCard.duplicating"));try{await _({id:e.id,accountId:f}),t.succeed(P("drawingSetCard.duplicateSuccess")),await r()}catch(e){t.fail(e,{fallback:P("drawingSetCard.duplicateFailed")})}finally{es.current=!1,ed(null)}},[ec,eu]=(0,t.useState)(null),{handleFiles:em}=(0,Q.usePdfImport)({account:f,projectId:k}),ep=(0,t.useMemo)(()=>D.flatMap(e=>e.name?[{id:e.id,name:e.name}]:[]),[D]),ef=(0,t.useMemo)(()=>(function(r){let{accountId:t,projectId:i}=r;return{key:`workspace:${t}:${i??"root"}`,scope:`account:${t.toLowerCase()}`,allowedSortFields:["name","updated_at"],defaultSort:{field:"updated_at",direction:"desc"},emptyStateLabel:"No files or folders yet",async fetchPage(e){let r=H({accountId:t,projectId:i,cursor:e.cursor,search:e.search,sortField:e.sort.field,sortDirection:e.sort.direction,includeFolders:!1}),n=await fetch(r);if(!n.ok)throw Error(`fetchPage failed: ${n.status}`);let a=await n.json();return{drawings:a.drawings,nextCursor:a.nextCursor}},async fetchFolders({search:e}){let r=H({accountId:t,projectId:i,cursor:null,search:e,sortField:"name",sortDirection:"asc",includeFolders:!0}),n=await fetch(r);if(!n.ok)throw Error(`fetchFolders failed: ${n.status}`);return(await n.json()).folders??[]},actions:{async createFolder(){let e=await K({accountId:t,name:"New Folder",parentId:i??void 0});if(!e.ok)throw l.notify.error(e.error,{fallback:"Failed to create folder"}),new L.ActionResultError(e.error);return{id:e.data.project.id}},async renameDrawing({id:e,name:r}){await (0,M.runAction)((0,W.updateDrawingSetAction)({id:e,accountId:t,name:r}),{fallback:"Failed to rename drawing"})},async deleteDrawing({id:r}){let i=await (0,$.deleteDrawingSetAction)({id:r,accountId:t});if(!i.ok)throw l.notify.error(i.error,{fallback:"Failed to delete drawing"}),new L.ActionResultError(i.error);if(u.default.enableSiteVisitMode)try{let{purgeDrawingOffline:t}=await e.A(18248);await t(r)}catch{}},async deleteItems({drawingIds:e,folderIds:r}){let i=await (0,B.deleteWorkspaceItemsAction)({accountId:t,drawingIds:e,folderIds:r});if(!i.ok)throw l.notify.error(i.error,{fallback:"Failed to delete"}),new L.ActionResultError(i.error);return u.default.enableSiteVisitMode&&z(i.data.deletedDrawingIds),i.data},async moveDrawing({id:e,targetFolderId:r}){await (0,M.runAction)((0,U.moveDrawingSetAction)({id:e,accountId:t,projectId:r}),{fallback:"Failed to move drawing"})},async renameFolder({id:e,name:r}){await (0,M.runAction)((0,q.updateProjectAction)({id:e,accountId:t,name:r}),{fallback:"Failed to rename folder"})},async deleteFolder({id:e}){let r=await V({id:e,accountId:t});if(!r.ok)throw l.notify.error(r.error,{fallback:"Failed to delete folder"}),new L.ActionResultError(r.error)},async moveFolder({id:e,targetFolderId:r}){await (0,M.runAction)(G({id:e,accountId:t,parentId:r}),{fallback:"Failed to move folder"})}}}})({accountId:f,projectId:k??null}),[f,k]);(0,t.useEffect)(()=>{let e=e=>Array.from(e.dataTransfer?.types??[]).includes("Files"),r=r=>{e(r)&&(r.preventDefault(),ea.current+=1,1===ea.current&&et(!0))},t=r=>{e(r)&&r.preventDefault()},i=r=>{e(r)&&(ea.current=Math.max(0,ea.current-1),0===ea.current&&et(!1))},n=r=>{if(!e(r))return;r.preventDefault(),ea.current=0,et(!1);let t=Array.from(r.dataTransfer?.files??[]);t.length>0&&em(t)};return window.addEventListener("dragenter",r),window.addEventListener("dragover",t),window.addEventListener("dragleave",i),window.addEventListener("drop",n),()=>{window.removeEventListener("dragenter",r),window.removeEventListener("dragover",t),window.removeEventListener("dragleave",i),window.removeEventListener("drop",n)}},[em]),(0,t.useEffect)(()=>{let e=e=>{(e.metaKey||e.ctrlKey)&&!e.altKey&&"o"===e.key.toLowerCase()&&!(0,T.isDesktopShell)()&&(e.preventDefault(),Y||ee.current?.click())};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[Y]);let eg=(0,t.useRef)(!1),ew=()=>{eg.current||(eg.current=!0,en(async()=>{try{let e=await (0,M.runAction)((0,O.createWhiteboardAction)({accountId:f,name:P("workspaceBrowser.untitledWhiteboard"),projectId:k}),{fallback:P("workspaceBrowser.createWhiteboardFailed")});if(!e)return;Z.push(`/home/${f}/drawings/${e.drawingSetId}`)}finally{eg.current=!1}}))},eh=(0,t.useRef)(ew);(0,t.useEffect)(()=>{eh.current=ew}),(0,t.useEffect)(()=>
1{if(!Y)return(0,E.registerDesktopMenuCommands)({"file.newWhiteboard":()=>eh.current()})},[Y]);let ek=[{key:"root",icon:x.icon,label:x.label,href:y},...v.map(e=>({key:e.id,label:e.name,href:`${y}?project=${e.id}`}))],ev=(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)(s.Button,{variant:"outline",size:"sm",disabled:ei||Y,onClick:ew,children:[(0,r.jsx)(a.Frame,{className:"mr-2 h-4 w-4"}),(0,r.jsx)("span",{className:"hidden md:inline",children:ei?P("workspaceBrowser.creatingWhiteboard"):P("workspaceBrowser.newWhiteboard")})]}),!F&&(0,r.jsxs)(s.Button,{size:"sm",disabled:Y,onClick:()=>ee.current?.click(),children:[(0,r.jsx)(n.FileText,{className:"mr-2 h-4 w-4"}),(0,r.jsx)("span",{className:"hidden md:inline",children:(0,r.jsx)(c.Trans,{i18nKey:"drawings:workspaceBrowser.openPdf"})})]})]});return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(j.FileBrowser,{source:ef,initial:{drawings:w,folders:g,nextCursor:h},crumbs:ek,spaceTint:b,primaryActions:ev,menuItems:I,leadingItem:F?e=>(0,r.jsx)(eF,{viewMode:e,account:f,projectId:k,sources:F,workspaces:ep,disabled:Y,isAtIntegrationLimit:N,onPickLocalUpload:()=>ee.current?.click()}):void 0,renderers:{renderFolder(e,t,i){let n={project:e,account:f,isNew:i.isNew,onCreated:i.onCreated,onRename:e=>{i.onRename(e)},onDelete:()=>{i.onDelete()},registerRef:i.registerRef};return"grid"===t?(0,r.jsx)(p.FolderCard,{...n}):(0,r.jsx)(p.FolderCardList,{...n})},renderDrawing(e,t,i){var n;let a=u.default.enableSiteVisitMode&&"guest"!==f&&"shared"!==f&&!!e.currentVersionId,o={drawingId:e.id,accountId:f,versionId:e.currentVersionId??"",versionNumber:e.current_version??1,pageCount:e.page_count??0,title:e.name,workspaceName:e.workspaceName},d=e.external_file_id?{currentAccountId:f,currentAccountName:D.find(e=>e.id===f)?.name??null,teamAccounts:D}:void 0,s=(n={provider:e.provider,externalFileId:e.external_file_id}).externalFileId&&("dropbox"===n.provider||"google_drive"===n.provider)?{id:e.id,name:e.name,provider:e.provider,userIntegrationId:e.user_integration_id??null,externalFileId:e.external_file_id,externalFilePath:e.external_file_path}:null,l={drawingSet:e,account:f,shareWorkspace:d,onMove:()=>eu({drawing:e,refresh:i.refresh}),onDuplicate:e.currentVersionId?()=>void el(e,i.refresh):void 0,fileActionPending:R||J.has(e.id)||null!==eo,duplicateDisabled:Y,isBlocked:R||J.has(e.id),onRename:e=>{i.onRename(e)},onDelete:()=>{i.onDelete()},registerRef:i.registerRef,titleExtras:a?(0,r.jsx)(C,{drawingId:e.id}):void 0,extraMenuItems:a||s?(0,r.jsxs)(r.Fragment,{children:[a&&(0,r.jsx)(S,{...o}),s&&(0,r.jsx)(A,{target:s})]}):void 0};return"grid"===t?(0,r.jsx)(m.DrawingSetCard,{...l}):(0,r.jsx)(m.DrawingSetCardList,{...l})}}}),ec&&(0,r.jsx)(eA,{drawing:ec.drawing,accountId:f,projectId:k??null,teams:D.map(e=>({id:e.id,name:e.name??P("drawingSetCard.workspace")})),onClose:()=>eu(null),onMoved:ec.refresh}),(0,r.jsx)("input",{ref:ee,type:"file",accept:".pdf,application/pdf",multiple:!0,className:"hidden","data-test":"drawings-upload-input",onChange:e=>{let r=e.target.files?Array.from(e.target.files):[];r.length>0&&em(r),e.target.value=""}}
1),er&&(0,r.jsx)("div",{className:"bg-foreground/30 pointer-events-none fixed inset-0 z-50 flex items-center justify-center backdrop-blur-[1px]",children:(0,r.jsxs)("div",{className:"bg-card text-foreground border-primary flex items-center gap-3 rounded-xl border-2 border-dashed px-6 py-4 shadow-2xl",children:[(0,r.jsx)(o.Upload,{className:"text-primary h-6 w-6"}),(0,r.jsx)("span",{className:"font-heading text-lg font-semibold",children:(0,r.jsx)(c.Trans,{i18nKey:"drawings:workspaceBrowser.dropToUpload"})})]})})]})}e.s(["WorkspaceBrowser",()=>eM],393638)}]);
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.