1(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,59752,t=>{"use strict";let e="https://researcherflow.com/api/v1";function a(){let t="true".trim().toLowerCase();return"false"!==t&&"0"!==t}function r(){return a()&&1?"/api/bff":e}class o{toString(){return r()}valueOf(){return r()}[Symbol.toPrimitive](){return r()}}let s=new o;async function n(t="application/json"){let e={};return t&&(e["Content-Type"]=t),e}async function i(t,e){let a={};for(let[e,r]of new Headers(t).entries())"authorization"!==e.toLowerCase()&&(a[e]=r);return{...await n(e),...a}}function c(t){if("u"<typeof document)return;let e="https:"===window.location.protocol?"; Secure":"";document.cookie=`${t}=; Max-Age=0; Path=/; SameSite=Strict${e}`}function h(){try{sessionStorage.removeItem("rf_access"),sessionStorage.removeItem("rf_refresh")}catch{}}function u(){h(),c("rf_access"),c("rf_signed_in")}async function f(){u();let t=a()?"/api/auth/logout":`${e}/auth/logout/`;try{await fetch(t,{method:"POST",credentials:"include",cache:"no-store",headers:{"Content-Type":"application/json"},body:JSON.stringify({})})}catch{}}async function l(){try{let t=a()?"/api/auth/ws-ticket":`${e}/auth/ws-ticket/`,r=await w(t,{method:"POST",body:JSON.stringify({})});if(!r.ok)return null;return(await r.json()).ticket||null}catch{return null}}let p=null;async function d(){if(p)return p;p=(async()=>{try{let t=a()?"/api/auth/refresh":`${e}/auth/refresh/`,r=await fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({})});if(r.ok)return"refreshed";return 401===r.status?"rejected":"unavailable"}catch{return"unavailable"}})();try{return await p}finally{p=null}}async function w(t,e={}){e={...e};let a="u">typeof FormData&&e.body instanceof FormData?"":"application/json",r=e.headers;e.headers=await i(r,a),e.credentials=e.credentials||"include",new Headers(e.headers).has("authorization"),delete e.next,e.cache="no-store";let o=await fetch(t,e);if(401===o.status){let s=await d();if("refreshed"===s)e.headers=await i(r,a),o=await fetch(t,e);else{if("rejected"!==s)return Response.json({error:"Session refresh is temporarily unavailable. Please try again."},{status:503});u()}}return o}t.s(["API_BASE",0,s,"ApiResponseError",0,class extends Error{status;constructor(t,e){super(t),this.name="ApiResponseError",this.status=e}},"fetchWithAuth",0,w,"getApiBase",0,r,"hasClientAuthHint",0,function(){let t;return!!(t=(void 0)??("u">typeof document?document.cookie:""))&&t.split(";").some(t=>{let[e,a]=t.trim().split("=");return"rf_signed_in"===e&&"1"===a})},"isBffEnabled",0,a,"logoutClient",0,f,"purgeLegacySessionTokens",0,h,"resolveWsAuthToken",0,l,"storeAuthTokens",0,function(t){h()}],59752)},78277,2674,30420,79151,36834,58381,7032,56548,86504,19612,11649,54686,10607,76058,43697,38745,55442,66289,89893,63802,96243,t=>{"use strict";var e=t.i(59752);function a(t){return"string"==typeof t?t.trim():Array.isArray(t)?t.filter(t=>"string"==typeof t).map(t=>t.trim()).filter(Boolean).join(" "):""}function r(t,e){if(!t||"object"!=typeof t||Array.isArray(t))return e;let r=a(t.detail);if(r)return r;let o=a(t.error);if(o)return o;let s=[];for(let[e,r]of Object.entries(t)){let t=a(r);t&&s.push("non_field_errors"===e?t:`${e}: ${t}`)}return s.join(" ")||e}async function o(t){let a=await (0,e.fetchWithAuth)(`${e.API_BASE}/workspaces/${t}/agent-runs/`,{cache:"no-store"});if(!a.ok)throw new e.ApiResponseError(`Failed to load copilot history: ${a.status}`,a.status);return a.json()}async function s(t){let a=await (0,e.fetchWithAuth)(`${e.API_BASE}/agent-runs/hitl-summary/?workspace=${encodeURIComponent(t)}`,{cache:"no-store"});if(!a.ok)throw new e.ApiResponseError(`Failed to load agent HITL summary: ${a.status}`,a.status);return a.json()}async function n(t){let a=await (0,e.fetchWithAuth)(`${e.API_BASE}/agent-runs/pending-actions/?workspace=${encodeURIComponent(t)}`,{cache:"no-store"});if(!a.ok)throw new e.ApiResponseError(`Failed to load pending agent actions: ${a.status}`,a.status);return a.json()}async function i(t,a){let o=await (0,e.fetchWithAuth)(`${e.API_BASE}/agent-runs/resolve-action/`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action_id:t,decision:a}),cache:"no-store"});if(!o.ok){let t=await o.json().catch(()=>({}));throw new e.ApiResponseError(r(t,`Failed to resolve agent action: ${o.status}`),o.status)}return o.json()}function c(t,e){return e?`${t}?${new URLSearchParams({workspace:e})}`:t}function h(t){if(!t||"string"!=typeof t||t.includes("\\"))return null;let a=String((0,e.getApiBase)()).replace(/\/$/,"");try{var r,o;
1if(t.startsWith("//"))return null;let e=new URL(t,"https://pagination.invalid");if(!t.startsWith("/")&&!/^https?:\/\//i.test(t)||!["http:","https:"].includes(e.protocol)||e.username||e.password)return null;return r=e.pathname,o=e.search,r.startsWith("/api/v1/")?`${a}${r.slice(7)}${o}`:r.startsWith("/api/bff/")?`${a}${r.slice(8)}${o}`:null}catch{return null}}async function u(t,e,a="collection"){return(await f(t,e,a)).items}async function f(t,a,r="collection"){let o=[],s=t,n=new Set;for(let t=0;s&&t<20;t++){let i=h(s)??s;if(n.has(i))throw Error(`Failed to load ${r}: pagination did not advance`);n.add(i);let c=await (0,e.fetchWithAuth)(s,a);if(!c.ok)throw new e.ApiResponseError(`Failed to load ${r}: ${c.status}`,c.status);let u=await c.json();if(Array.isArray(u)&&0===t)return{items:u,truncated:!1};if(!u||!Array.isArray(u.results))throw Error(`Failed to load ${r}: invalid collection response`);if(o.push(...u.results),s=h(u.next),null!=u.next&&""!==u.next&&!s)throw Error(`Failed to load ${r}: invalid pagination link`)}return{items:o,truncated:!!s}}async function l(t){return(await p(t)).items}function p(t){return f(`${e.API_BASE}/artifacts/?workspace=${t}`,void 0,"artifacts")}async function d(t){let a=new FormData;a.append("workspace",t.workspace),a.append("title",t.title),a.append("artifact_type",t.artifact_type),a.append("source_kind",t.source_kind),t.description&&a.append("description",t.description),t.external_url&&a.append("external_url",t.external_url),t.text_content&&a.append("text_content",t.text_content),t.tags?.length&&a.append("tags",JSON.stringify(t.tags)),t.file&&a.append("file",t.file);let r=await (0,e.fetchWithAuth)(`${e.API_BASE}/artifacts/`,{method:"POST",body:a,cache:"no-store"});if(!r.ok)throw new e.ApiResponseError(`Failed to upload artifact: ${r.status}`,r.status);return r.json()}async function w(t){let a=await (0,e.fetchWithAuth)(`${e.API_BASE}/artifacts/${t}/summarize/`,{method:"POST",cache:"no-store"});if(!a.ok)throw Error(r(await a.json().catch(()=>({})),`Failed to summarize artifact: ${a.status}`));return a.json()}async function A(t,a){let o=await (0,e.fetchWithAuth)(`${e.API_BASE}/artifacts/bulk-move/`,{method:"POST",body:JSON.stringify({ids:t,workspace:a}),cache:"no-store"});if(!o.ok)throw Error(r(await o.json().catch(()=>({})),`Bulk move failed: ${o.status}`));return o.json()}async function $(t,a=[],o=[]){let s=await (0,e.fetchWithAuth)(`${e.API_BASE}/artifacts/bulk-tag/`,{method:"POST",body:JSON.stringify({ids:t,add:a,remove:o}),cache:"no-store"});if(!s.ok)throw Error(r(await s.json().catch(()=>({})),`Bulk tagging failed: ${s.status}`));return s.json()}async function y(t){let a=await (0,e.fetchWithAuth)(`${e.API_BASE}/artifacts/bulk-delete/`,{method:"POST",body:JSON.stringify({ids:t}),cache:"no-store"});if(!a.ok)throw Error(r(await a.json().catch(()=>({})),`Batch delete failed: ${a.status}`));return a.json()}async function k(t){let a=await (0,e.fetchWithAuth)(`${e.API_BASE}/artifacts/${t}/pin/`,{method:"POST",body:JSON.stringify({}),cache:"no-store"});if(!a.ok)throw Error(r(await a.json().catch(()=>({})),`Failed to pin artifact: ${a.status}`));return a.json()}async function S(t){let a=await (0,e.fetchWithAuth)(`${e.API_BASE}/artifacts/${t}/toggle-public/`,{method:"POST",body:JSON.stringify({}),cache:"no-store"});if(!a.ok)throw Error(r(await a.json().catch(()=>({})),`Failed to toggle public for artifact: ${a.status}`));return a.json()}async function E(t,a){let o=await (0,e.fetchWithAuth)(`${e.API_BASE}/artifacts/${t}/`,{method:"PATCH",body:JSON.stringify(a),cache:"no-store"});if(!o.ok)throw Error(r(await o.json().catch(()=>({})),`Failed to update artifact: ${o.status}`));return o.json()}async function m(t){let a=await (0,e.fetchWithAuth)(`${e.API_BASE}/artifacts/${t}/`,{method:"DELETE",cache:"no-store"});if(!a.ok&&204!==a.status)throw Error(r(await a.json().catch(()=>({})),`Failed to delete artifact: ${a.status}`))}async function P(t,a="svg"){let o=await (0,e.fetchWithAuth)(`${e.API_BASE}/artifacts/${t}/export/?file_format=${a}`,{cache:"no-store"});if(!o.ok)throw Error(r(await o.json().catch(()=>({})),`Failed to export figure: ${o.status}`));return o.blob()}async function g(t){let a=await (0,e.fetchWithAuth)(`${e.API_BASE}/artifacts/${t}/generate-chart/`,{method:"POST",body:JSON.stringify({}),cache:"no-store"});if(!a.ok)throw Error(r(await a.json().catch(()=>({})),`Failed to generate chart: ${a.status}`));return a.json()}async function j(t){let a=await (0,e.fetchWithAuth)(`${e.API_BASE}/artifacts/${t}/generate-caption/`,{method:"POST",body:JSON.stringify({}),cache:"no-store"});if(!a.ok)throw Error(r(await a.json().catch(()=>({})),`Failed to generate caption: ${a.status}`));return a.json()}async function _(t,a){let r=await (0,e.fetchWithAuth)(c(`${e.API_BASE}/artifacts/${t}/`,a),{next:{revalidate:60}});if(!r.ok)throw new e.ApiResponseError(`Failed to load artifact: ${r.status}`,r.status);return r.json()}async function b(t,a,r){let o=(0,e.isBffEnabled)()?"/api/auth/register":`${e.API_BASE}/auth/register/`,s=await fetch(o,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({username:t,password:a,email:r})});if(!s.ok)throw Error((await s.json().catch(()=>({}))).error||`Registration failed: ${s.status}`);let n=await s.json();return(0,e.storeAuthTokens)({access:""}),(0,e.isBffEnabled)(),{user:n.user,tokens:{access:""}}}async function B(t,a){let r=(0,e.isBffEnabled)()?"/api/auth/login":`${e.API_BASE}/auth/login/`,o=await fetch(r,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({username:t,password:a})});if(!o.ok)throw Error((await o.json().catch(()=>({}))).error||"Invalid username or password.");return(0,e.storeAuthTokens)({access:""}),{access:""}}async function I(){return u(`${e.API_BASE}/auth/personal-access-tokens/`,{cache:"no-store"},"personal access tokens")}async function W(t){let a={};t&&(a.Authorization=`Bearer ${t}`);let r=await (0,e.fetchWithAuth)(`${e.API_BASE}/auth/me/`,{headers:a,cache:"no-store"});if(!r.ok)throw new e.ApiResponseError("Not authenticated.",r.status);return r.json()}async function O(t){let a=await (0,e.fetchWithAuth)(`${e.API_BASE}/auth/profile/`,{method:"PATCH",body:JSON.stringify(t)});if(!a.ok)throw Error((await a.json().catch(()=>({}))).error||"Failed to update profile.");return a.json()}async function T(t){let a=await (0,e.fetchWithAuth)(`${e.API_BASE}/auth/forgot-password/`,{method:"POST",body:JSON.stringify({email:t})});if(!a.ok)throw Error((await a.json().catch(()=>({}))).error||"Could not send reset email.")}async function F(t,a,r){let o=await (0,e.fetchWithAuth)(`${e.API_BASE}/auth/reset-password/`,{method:"POST",body:JSON.stringify({uid:t,token:a,new_password:r})});if(!o.ok)throw Error((await o.json().catch(()=>({}))).error||"Could not reset password.")}async function x(t){let a=await (0,e.fetchWithAuth)(`${e.API_BASE}/billing/portal/`,{method:"POST",body:JSON.stringify({return_url:t})}
1),r=await a.json().catch(()=>({}));if(!a.ok)throw new e.ApiResponseError(r.error||`Failed to create billing portal session: ${a.status}`,a.status);if("string"!=typeof r.portal_url||!r.portal_url)throw new e.ApiResponseError("Stripe did not return a billing portal URL.",502);return r.portal_url}async function v(t){let a=new URLSearchParams(t).toString();return u(`${e.API_BASE}/comments/?${a}`,{cache:"no-store"},"comments")}async function N(t){let a=await (0,e.fetchWithAuth)(`${e.API_BASE}/comments/`,{method:"POST",body:JSON.stringify(t)});if(!a.ok)throw Error(r(await a.json().catch(()=>({})),`Failed to post comment: ${a.status}`));return a.json()}async function J(t){let a=await (0,e.fetchWithAuth)(`${e.API_BASE}/comments/${t}/resolve/`,{method:"POST"});if(!a.ok)throw Error((await a.json().catch(()=>({}))).error||`Failed to resolve comment: ${a.status}`);return a.json()}async function R(t){let a=await (0,e.fetchWithAuth)(`${e.API_BASE}/comments/${t}/reopen/`,{method:"POST"});if(!a.ok)throw Error((await a.json().catch(()=>({}))).error||`Failed to reopen comment: ${a.status}`);return a.json()}async function C(t){let a=new URLSearchParams(t).toString();return u(`${e.API_BASE}/editing-presences/?${a}`,{cache:"no-store"},"presences")}async function L(t){let a=await (0,e.fetchWithAuth)(`${e.API_BASE}/editing-presences/`,{method:"POST",body:JSON.stringify(t)});if(!a.ok)throw Error(r(await a.json().catch(()=>({})),`Failed to join presence: ${a.status}`));return a.json()}async function U(t){let a=await (0,e.fetchWithAuth)(`${e.API_BASE}/editing-presences/heartbeat/`,{method:"POST",body:JSON.stringify(t)});if(!a.ok)throw Error((await a.json().catch(()=>({}))).error||`Failed to heartbeat presence: ${a.status}`);return a.json()}async function M(t){let a=await (0,e.fetchWithAuth)(`${e.API_BASE}/editing-presences/leave/`,{method:"POST",body:JSON.stringify(t)});if(!a.ok)throw Error((await a.json().catch(()=>({}))).error||`Failed to leave presence: ${a.status}`);return a.json()}async function q(t){return u(`${e.API_BASE}/webhooks/?workspace=${t}`,void 0,"webhooks")}async function D(t,a){let o=await (0,e.fetchWithAuth)(`${e.API_BASE}/webhooks/`,{method:"POST",body:JSON.stringify({workspace:t,...a})});if(!o.ok)throw Error(r(await o.json().catch(()=>({})),`Failed to create webhook: ${o.status}`));return o.json()}async function H(t,a){let r=await (0,e.fetchWithAuth)(`${e.API_BASE}/webhooks/${t}/`,{method:"PATCH",body:JSON.stringify(a)});if(!r.ok)throw new e.ApiResponseError(`Failed to update webhook: ${r.status}`,r.status);return r.json()}async function Q(t){let a=await (0,e.fetchWithAuth)(`${e.API_BASE}/webhooks/${t}/`,{method:"DELETE"});if(!a.ok)throw new e.ApiResponseError(`Failed to delete webhook: ${a.status}`,a.status)}async function z(t){let a=await (0,e.fetchWithAuth)(`${e.API_BASE}/webhooks/${t}/test/`,{method:"POST"});if(!a.ok)throw Error(r(await a.json().catch(()=>({})),`Failed to test webhook: ${a.status}`));return a.json()}async function G(t,a=10){let r=await (0,e.fetchWithAuth)(`${e.API_BASE}/webhooks/${t}/deliveries/?limit=${a}`);if(!r.ok)throw new e.ApiResponseError(`Failed to fetch webhook deliveries: ${r.status}`,r.status);return r.json()}t.s(["apiErrorMessage",0,r],2674),t.s(["fetchAgentHitlSummary",0,s,"fetchAgentRuns",0,o,"fetchPendingAgentActions",0,n,"resolveAgentAction",0,i],30420),t.s(["batchDeleteArtifacts",0,y,"bulkMoveArtifacts",0,A,"bulkTagArtifacts",0,$,"deleteArtifact",0,m,"exportArtifactFigure",0,P,"fetchArtifact",0,_,"fetchWorkspaceArtifacts",0,l,"fetchWorkspaceArtifactsWindow",0,p,"generateArtifactCaption",0,j,"generateArtifactChart",0,g,"pinArtifact",0,k,"searchArtifactsWindow",0,function(t,a,r){let o=new URLSearchParams({workspace:t,search:a});return f(`${e.API_BASE}/artifacts/?${o}`,{...r,cache:"no-store"},"artifact search")},"summarizeArtifact",0,w,"togglePublicArtifact",0,S,"updateArtifact",0,E,"uploadArtifact",0,d],79151),t.s(["confirmPasswordReset",0,F,"fetchMe",0,W,"fetchPersonalAccessTokens",0,I,"login",0,B,"register",0,b,"requestPasswordReset",0,T,"updateProfile",0,O],36834),t.s(["createBillingPortalSession",0,x],58381),t.s(["createWebhook",0,D,"deleteWebhook",0,Q,"fetchActivePresences",0,C,"fetchComments",0,v,"fetchWebhookDeliveries",0,G,"fetchWebhooks",0,q,"heartbeatEditingPresence",0,U,"joinEditingPresence",0,L,"leaveEditingPresence",0,M,"postComment",0,N,"reopenComment",0,R,"resolve
1Comment",0,J,"testWebhook",0,z,"updateWebhook",0,H],7032);let K=t=>new Promise(e=>setTimeout(e,t));async function V(t,a,r=18e4){let o=await (0,e.fetchWithAuth)(t,{method:"POST",body:JSON.stringify(a??{}),cache:"no-store"});if(!o.ok){let t=await o.json().catch(()=>({}));throw Error(t.error||t.detail||`Request failed: ${o.status}`)}let s=await o.json();if(!s||!s.job_id)return s;let n=Date.now()+r;for(;Date.now()<n;){await K(1500);let t=await (0,e.fetchWithAuth)(`${e.API_BASE}/generation-jobs/${s.job_id}/`,{cache:"no-store"});if(!t.ok)throw Error(`Failed to poll generation job: ${t.status}`);let a=await t.json();if("done"===a.status)return a.result;if("failed"===a.status)throw Error(a.error||"Generation failed")}throw Error("Generation timed out")}async function X(t,a=!1){let r=await (0,e.fetchWithAuth)(`${e.API_BASE}/experiment-suggestions/`,{method:"POST",body:JSON.stringify({workspace:t,save_as_artifact:a}),cache:"no-store"});if(!r.ok)throw new e.ApiResponseError(`Failed to generate experiment suggestions: ${r.status}`,r.status);return r.json()}async function Y(t,a,r,o=""){let s=await (0,e.fetchWithAuth)(`${e.API_BASE}/advisor/`,{method:"POST",body:JSON.stringify({workspace:t,context_type:a,context_id:r,additional_context:o}),cache:"no-store"});if(!s.ok)throw Error((await s.json().catch(()=>({}))).error||`Failed to get advice: ${s.status}`);return s.json()}async function Z(t,a){let r=await (0,e.fetchWithAuth)(c(`${e.API_BASE}/experiment-logs/${t}/`,a),{next:{revalidate:60}});if(!r.ok)throw new e.ApiResponseError(`Failed to load experiment: ${r.status}`,r.status);return r.json()}async function tt(t){return(await te(t)).items}function te(t){return f(`${e.API_BASE}/experiment-logs/?${new URLSearchParams({workspace:t})}`,{cache:"no-store"},"experiments")}async function ta(t){return u(`${e.API_BASE}/experiment-runs/?experiment=${t}&ordering=run_number`,{next:{revalidate:30}})}async function tr(t){let a=await (0,e.fetchWithAuth)(`${e.API_BASE}/experiment-runs/${t}/`,{cache:"no-store"});if(!a.ok)throw new e.ApiResponseError(`Failed to load experiment run: ${a.status}`,a.status);return a.json()}async function to(t,a=[],r=""){return V(`${e.API_BASE}/experiment-plan/`,{hypothesis:t,paper_ids:a,context:r})}async function ts(t){let a=await (0,e.fetchWithAuth)(`${e.API_BASE}/experiment-runs/${t}/summarize/`,{method:"POST",cache:"no-store"});if(!a.ok)throw Error(r(await a.json().catch(()=>({})),`Failed to summarize run: ${a.status}`));return a.json()}async function tn(t){let a=await (0,e.fetchWithAuth)(`${e.API_BASE}/experiment-runs/`,{method:"POST",body:JSON.stringify(t),cache:"no-store"});if(!a.ok)throw Error(r(await a.json().catch(()=>({})),`Failed to create run: ${a.status}`));return a.json()}async function ti(t){let a=await (0,e.fetchWithAuth)(`${e.API_BASE}/experiment-logs/`,{method:"POST",body:JSON.stringify(t),cache:"no-store"});if(!a.ok)throw Error(r(await a.json().catch(()=>({})),`Failed to create experiment: ${a.status}`));return a.json()}async function tc(t){let a=await (0,e.fetchWithAuth)(`${e.API_BASE}/experiment-logs/${t}/pin/`,{method:"POST",body:JSON.stringify({}),cache:"no-store"});if(!a.ok)throw Error(r(await a.json().catch(()=>({})),`Failed to pin experiment: ${a.status}`));return a.json()}async function th(t,a){let o=await (0,e.fetchWithAuth)(`${e.API_BASE}/experiment-runs/${t}/`,{method:"PATCH",body:JSON.stringify(a),cache:"no-store"});if(!o.ok)throw Error(r(await o.json().catch(()=>({})),`Failed to update run: ${o.status}`));return o.json()}async function tu(t){let a=await (0,e.fetchWithAuth)(`${e.API_BASE}/experiment-logs/${t}/`,{method:"DELETE",cache:"no-store"});if(!a.ok&&204!==a.status)throw Error(r(await a.json().catch(()=>({})),`Failed to delete experiment: ${a.status}`))}async function tf(t,a){let o=await (0,e.fetchWithAuth)(`${e.API_BASE}/experiment-logs/${t}/`,{method:"PATCH",body:JSON.stringify(a),cache:"no-store"});if(!o.ok)throw Error(r(await o.json().catch(()=>({})),`Failed to update experiment: ${o.status}`));return o.json()}async function tl(t,a){let o=new FormData;o.append("workspace",t),o.append("file",a);let s=await (0,e.fetchWithAuth)(`${e.API_BASE}/experiment-logs/bulk-import-csv/`,{method:"POST",body:o});if(!s.ok)throw Error(r(await s.json().catch(()=>({})),`Bulk import failed: ${s.status}`));return s.json()}async function tp(t){let a=await (0,e.fetchWithAuth)(`${e.API_BASE}
1/workspaces/${t}/experiment-analytics/`,{next:{revalidate:300}});if(!a.ok)throw new e.ApiResponseError(`Failed to fetch experiment analytics: ${a.status}`,a.status);return a.json()}async function td(t,a=7,r=!1){return V(`${e.API_BASE}/weekly-update/`,{workspace:t,days:a,save_as_artifact:r})}async function tw(t){return V(`${e.API_BASE}/workspaces/${t}/publication-ideas/`,{})}async function tA(t,a=7,r=!1){return V(`${e.API_BASE}/slide-outline/`,{workspace:t,days:a,save_as_artifact:r})}async function t$(t,a={}){return V(`${e.API_BASE}/poster-outline/`,{workspace:t,artifact_ids:a.artifactIds||[],paper_ids:a.paperIds||[],experiment_ids:a.experimentIds||[],save_as_artifact:a.saveAsArtifact||!1})}async function ty(t,a={}){return V(`${e.API_BASE}/funding-copilot/`,{workspace:t,artifact_ids:a.artifactIds||[],paper_ids:a.paperIds||[],experiment_ids:a.experimentIds||[],save_as_artifact:a.saveAsArtifact||!1},36e4)}async function tk(t,a="nih",r={}){return V(`${e.API_BASE}/funding-copilot/compliance/`,{workspace:t,agency:a,strategy:r.strategy,save_as_artifact:r.saveAsArtifact||!1},36e4)}async function tS(t,a,o){let s={workspace:t,code:a};o?.timeout&&(s.timeout=o.timeout);let n=o?.runId?`${e.API_BASE}/experiment-runs/${o.runId}/run-in-sandbox/`:`${e.API_BASE}/experiment-runs/execute-in-sandbox/`,i=await (0,e.fetchWithAuth)(n,{method:"POST",body:JSON.stringify(s),cache:"no-store"});if(!i.ok)throw Error(r(await i.json().catch(()=>({})),`Failed to execute in sandbox: ${i.status}`));return i.json()}async function tE(t){let a=await (0,e.fetchWithAuth)(`${e.API_BASE}/external-integrations/`,{method:"POST",body:JSON.stringify(t),cache:"no-store"});if(!a.ok)throw Error(r(await a.json().catch(()=>({})),`Failed to create integration: ${a.status}`));return a.json()}async function tm(t){let a=await (0,e.fetchWithAuth)(`${e.API_BASE}/external-integrations/${t}/sync/`,{method:"POST",body:JSON.stringify({}),cache:"no-store"});if(!a.ok)throw new e.ApiResponseError(`Failed to trigger sync: ${a.status}`,a.status);return a.json()}async function tP(t){let a=await (0,e.fetchWithAuth)(`${e.API_BASE}/external-integrations/${t}/test-post/`,{method:"POST",body:JSON.stringify({}),cache:"no-store"});if(!a.ok)throw Error(r(await a.json().catch(()=>({})),`Failed to test chat post: ${a.status}`));return a.json()}async function tg(t,a){let o=await (0,e.fetchWithAuth)(`${e.API_BASE}/external-integrations/${t}/link_item/`,{method:"POST",body:JSON.stringify(a),cache:"no-store"});if(!o.ok)throw Error(r(await o.json().catch(()=>({})),`Failed to link citation: ${o.status}`));return o.json()}async function tj(t){return u(`${e.API_BASE}/external-integrations/?workspace=${t}`)}async function t_(t){return u(`${e.API_BASE}/linked-resources/?workspace=${t}`)}async function tb(){return u(`${e.API_BASE}/knowledge-articles/`,{cache:"no-store"})}async function tB(t){let a=await (0,e.fetchWithAuth)(`${e.API_BASE}/knowledge-articles/`,{method:"POST",body:JSON.stringify(t),cache:"no-store"});if(!a.ok){let t=await a.json().catch(()=>({})),r="string"==typeof t.detail&&t.detail||"string"==typeof t.error&&t.error||`Failed to create knowledge article: ${a.status}`;throw new e.ApiResponseError(r,a.status)}return a.json()}async function tI(t="30d"){let a=await (0,e.fetchWithAuth)(`${e.API_BASE}/lab/dashboard/?period=${t}`,{cache:"no-store"});if(!a.ok){let t=await a.json().catch(()=>({}));throw new e.ApiResponseError(t.error||`Failed to load lab dashboard: ${a.status}`,a.status)}return a.json()}async function tW(t="30d",a){let r=new URLSearchParams({period:t});a&&r.set("workspace",a);let o=await (0,e.fetchWithAuth)(`${e.API_BASE}/billing/usage/?${r.toString()}`,{cache:"no-store"});if(!o.ok)throw Error((await o.json().catch(()=>({}))).error||`Failed to load usage: ${o.status}`);return o.json()}async function tO(){return u(`${e.API_BASE}/lab-assets/`,{cache:"no-store"})}async function tT(t){let a=await (0,e.fetchWithAuth)(`${e.API_BASE}/lab-assets/`,{method:"POST",body:JSON.stringify(t)});if(!a.ok){let t=await a.json().catch(()=>({}));throw Error(t.error||t.detail||`Failed to create lab asset: ${a.status}`)}return a.json()}async function tF(t,a,r=!0){let o=await (0,e.fetchWithAuth)(`${e.API_BASE}/lab-assets/${t}/link-to-workspace/`,{method:"POST",body:JSON.stringify({workspace:a,create_proxy:r})});if(!o.ok)throw Error((await o.json().catch(()=>({}))).error||`Failed to link lab asset: ${o.status}`);return o.json()}async function tx(t,a=5,r="weekly"){let o=new URLSearchParams({max_tracks:String(a),cadence:r}),s=await (0,e.fetchWithAuth)(`${e.API_BASE}
1/workspaces/${t}/research-program/?${o.toString()}`,{next:{revalidate:120}});if(!s.ok)throw new e.ApiResponseError(`Failed to fetch research program: ${s.status}`,s.status);return s.json()}async function tv(t,a=5,o="weekly"){let s=await (0,e.fetchWithAuth)(`${e.API_BASE}/workspaces/${t}/research-program/`,{method:"POST",body:JSON.stringify({max_tracks:a,create_tasks:!0,cadence:o}),cache:"no-store"});if(!s.ok)throw Error(r(await s.json().catch(()=>({})),`Failed to create program tasks: ${s.status}`));return s.json()}async function tN(t,a){let o=await (0,e.fetchWithAuth)(`${e.API_BASE}/manuscripts/bulk-move/`,{method:"POST",body:JSON.stringify({ids:t,workspace:a}),cache:"no-store"});if(!o.ok)throw Error(r(await o.json().catch(()=>({})),`Bulk move failed: ${o.status}`));return o.json()}async function tJ(t){let a=await (0,e.fetchWithAuth)(`${e.API_BASE}/manuscripts/bulk-delete/`,{method:"POST",body:JSON.stringify({ids:t}),cache:"no-store"});if(!a.ok)throw Error(r(await a.json().catch(()=>({})),`Batch delete failed: ${a.status}`));return a.json()}async function tR(t,a){let r=await (0,e.fetchWithAuth)(c(`${e.API_BASE}/manuscripts/${t}/`,a),{next:{revalidate:60}});if(!r.ok)throw new e.ApiResponseError(`Failed to fetch manuscript: ${r.status}`,r.status);return r.json()}async function tC(t){return u(`${e.API_BASE}/manuscripts/?workspace=${t}`,{next:{revalidate:30}})}async function tL(t){let a=await (0,e.fetchWithAuth)(`${e.API_BASE}/manuscripts/`,{method:"POST",body:JSON.stringify(t),cache:"no-store"});if(!a.ok)throw Error(r(await a.json().catch(()=>({})),`Failed to create manuscript: ${a.status}`));return a.json()}async function tU(t,a){let o=await (0,e.fetchWithAuth)(`${e.API_BASE}/manuscripts/${t}/`,{method:"PATCH",body:JSON.stringify(a),cache:"no-store"});if(!o.ok)throw Error(r(await o.json().catch(()=>({})),`Failed to update manuscript: ${o.status}`));return o.json()}async function tM(t){let a=await (0,e.fetchWithAuth)(`${e.API_BASE}/manuscripts/${t}/`,{method:"DELETE",cache:"no-store"});if(!a.ok&&204!==a.status)throw Error(r(await a.json().catch(()=>({})),`Failed to delete manuscript: ${a.status}`))}async function tq(t){let a=await (0,e.fetchWithAuth)(`${e.API_BASE}/manuscripts/${t}/pin/`,{method:"POST",body:JSON.stringify({}),cache:"no-store"});if(!a.ok)throw Error(r(await a.json().catch(()=>({})),`Failed to pin manuscript: ${a.status}`));return a.json()}async function tD(t){let a=await (0,e.fetchWithAuth)(`${e.API_BASE}/manuscripts/${t}/toggle-public/`,{method:"POST",body:JSON.stringify({}),cache:"no-store"});if(!a.ok)throw Error(r(await a.json().catch(()=>({})),`Failed to toggle public for manuscript: ${a.status}`));return a.json()}async function tH(t){return V(`${e.API_BASE}/manuscripts/${t}/scaffold/`,{})}async function tQ(t){let a=await (0,e.fetchWithAuth)(`${e.API_BASE}/manuscripts/${t}/suggest-titles/`,{method:"POST",body:JSON.stringify({}),cache:"no-store"});if(!a.ok)throw Error(r(await a.json().catch(()=>({})),`Failed to suggest titles: ${a.status}`));return a.json()}async function tz(t,a){return V(`${e.API_BASE}/manuscripts/${t}/refine-section/`,{section:a})}async function tG(t,a){let o={};a&&(o.focus_section=a);let s=await (0,e.fetchWithAuth)(`${e.API_BASE}/manuscripts/${t}/red-team/`,{method:"POST",body:JSON.stringify(o),cache:"no-store"});if(!s.ok)throw Error(r(await s.json().catch(()=>({})),`Failed to red-team: ${s.status}`));return s.json()}async function tK(t){let a=await (0,e.fetchWithAuth)(`${e.API_BASE}/manuscripts/${t}/export/`);if(!a.ok)throw Error("Failed to export manuscript");return a.blob()}async function tV(t){let a=await (0,e.fetchWithAuth)(`${e.API_BASE}/manuscripts/${t}/publish-to-osf/`,{method:"POST",body:JSON.stringify({}),cache:"no-store"});if(!a.ok)throw Error(r(await a.json().catch(()=>({})),`Failed to publish to OSF: ${a.status}`));return a.json()}async function tX(t,a){let r=await (0,e.fetchWithAuth)(c(`${e.API_BASE}/notes/${t}/`,a),{cache:"no-store"});if(!r.ok)throw new e.ApiResponseError(`Failed to load note: ${r.status}`,r.status);return r.json()}async function tY(t){return u(`${e.API_BASE}/notes/?paper=${t}`,{cache:"no-store"})}async function tZ(t){return(await t0(t)).items}function t0(t){return f(`${e.API_BASE}/notes/?workspace=${t}`,{cache:"no-store"},"notes")}async function t3(t){let a=await (0,e.fetchWithAuth)(`${e.API_BASE}/notes/`,{method:"POST",body:JSON.stringify(t),cache:"no-store"});if(!a.ok)throw Error(r(await a.json().catch(()=>({})),`Failed to create note: ${a.status}`));return a.json()}async function t4(t,a){let o=await (0,e.fetchWithAuth)(`${e.API_BASE}/notes/${t}/`,{method:"PATCH",body:JSON.stringify(a),cache:"no-store"});if(!o.ok)throw Error(r(await o.json().catch(()=>({})),`Failed to update note: ${o.status}`));return o.json()}async function t6(t){let a=await (0,e.fetchWithAuth)(`${e.API_BASE}/notes/${t}/`,{method:"DELETE",cache:"no-store"});if(!a.ok&&204!==a.status)throw Error(r(await a.json().catch(()=>({})),`Failed to delete note: ${a.status}`))}async function t2(t,a=[],o=[]){let s=await (0,e.fetchWithAuth)(`${e.API_BASE}/notes/bulk-tag/`,{method:"POST",body:JSON.stringify({ids:t,add:a,remove:o}),cache:"no-store"});if(!s.ok)throw Error(r(await s.json().catch(()=>({})),`Bulk tagging failed: ${s.status}`));return s.json()}async function t1(t){let a=await (0,e.fetchWithAuth)(`${e.API_BASE}/notes/bulk-delete/`,{method:"POST",body:JSON.stringify({ids:t}),cache:"no-store"});if(!a.ok)throw Error(r(await a.json().catch(()=>({})),`Batch delete failed: ${a.status}`));return a.json()}async function t5(t,a){let o=await (0,e.fetchWithAuth)(`${e.API_BASE}/notes/bulk-move/`,{method:"POST",body:JSON.stringify({ids:t,workspace:a}),cache:"no-store"});if(!o.ok)throw Error(r(await o.json().catch(()=>({})),`Bulk move failed: ${o.status}`));return o.json()}async function t8(t){let a=await (0,e.fetchWithAuth)(`${e.API_BASE}
1/workspaces/${t}/note-analytics/`,{next:{revalidate:300}});if(!a.ok)throw new e.ApiResponseError(`Failed to fetch note analytics: ${a.status}`,a.status);return a.json()}async function t7(t){let a=await (0,e.fetchWithAuth)(`${e.API_BASE}/notes/${t}/export/`);if(!a.ok)throw Error("Failed to export note");return a.blob()}async function t9(t){return(await et(t)).items}async function et(t){return f(`${e.API_BASE}/papers/?workspace=${t}`,{next:{revalidate:30}},"papers")}async function ee(t,e,a){return(await ea(t,e,a)).items}async function ea(t,a,r){return f(`${e.API_BASE}/papers/?workspace=${t}&search=${encodeURIComponent(a)}`,{...r,cache:"no-store"},"paper search")}async function er(t){let a=await (0,e.fetchWithAuth)(`${e.API_BASE}/workspaces/${t}/citation-graph/`,{next:{revalidate:30}});if(!a.ok)throw new e.ApiResponseError(`Failed to load citation graph: ${a.status}`,a.status);return a.json()}async function eo(t,a=""){if(!t.length)return null;let r=await (0,e.fetchWithAuth)(`${e.API_BASE}/synthesize/`,{method:"POST",body:JSON.stringify({paper_ids:t,question:a}),cache:"no-store"});if(!r.ok)throw new e.ApiResponseError(`Failed to synthesize papers: ${r.status}`,r.status);return r.json()}async function es(t){let a=await (0,e.fetchWithAuth)(`${e.API_BASE}/ingest/`,{method:"POST",body:JSON.stringify(t),cache:"no-store"});if(!a.ok){let t=await a.json().catch(()=>({})),r=t.detail||t.error||`Failed to ingest paper: ${a.status}`;throw new e.ApiResponseError(r,a.status)}return a.json()}async function en(t,a){let r=new URLSearchParams;a&&r.set("max_themes",String(a));let o=r.toString(),s=await (0,e.fetchWithAuth)(`${e.API_BASE}/workspaces/${t}/frontier-map/${o?`?${o}`:""}`,{next:{revalidate:120}});if(!s.ok)throw new e.ApiResponseError(`Failed to fetch frontier map: ${s.status}`,s.status);return s.json()}async function ei(t,a=!1){let o=await (0,e.fetchWithAuth)(`${e.API_BASE}/papers/${t}/mine-frontier/`,{method:"POST",body:JSON.stringify({create_questions:a}),cache:"no-store"});if(!o.ok)throw Error(r(await o.json().catch(()=>({})),`Failed to mine frontier signals: ${o.status}`));return o.json()}async function ec(t){let a=await (0,e.fetchWithAuth)(`${e.API_BASE}/papers/${t}/extract/`,{method:"POST",cache:"no-store"});if(!a.ok)throw new e.ApiResponseError(`Failed to extract paper card: ${a.status}`,a.status);return a.json()}async function eh(t){let a=await (0,e.fetchWithAuth)(`${e.API_BASE}/bulk-ingest/`,{method:"POST",body:JSON.stringify(t),cache:"no-store"});if(!a.ok)throw Error((await a.json().catch(()=>({}))).error||`Bulk ingest failed: ${a.status}`);return a.json()}async function eu(t){let a=await (0,e.fetchWithAuth)(`${e.API_BASE}/papers/`,{method:"POST",body:JSON.stringify(t),cache:"no-store"});if(!a.ok)throw Error(r(await a.json().catch(()=>({})),`Failed to create paper: ${a.status}`));return a.json()}async function ef(t){let a=await (0,e.fetchWithAuth)(`${e.API_BASE}/papers/${t}/`,{method:"DELETE",cache:"no-store"});if(!a.ok&&204!==a.status)throw Error(r(await a.json().catch(()=>({})),`Failed to delete paper: ${a.status}`))}async function el(t){let a=await (0,e.fetchWithAuth)(`${e.API_BASE}/papers/bulk-delete/`,{method:"POST",body:JSON.stringify({ids:t}),cache:"no-store"});if(!a.ok)throw Error(r(await a.json().catch(()=>({})),`Batch delete failed: ${a.status}`));return a.json()}async function ep(t,a,o){let s=await (0,e.fetchWithAuth)(`${e.API_BASE}/workspaces/${t}/papers/bulk-move/`,{method:"POST",body:JSON.stringify({paper_ids:a,target_workspace:o}),cache:"no-store"});if(!s.ok)throw Error(r(await s.json().catch(()=>({})),`Bulk move failed: ${s.status}`));return s.json()}async function ed(t,a,o){let s=await (0,e.fetchWithAuth)(`${e.API_BASE}/workspaces/${t}/papers/bulk-update/`,{method:"POST",body:JSON.stringify({paper_ids:a,...o}),cache:"no-store"});if(!s.ok)throw Error(r(await s.json().catch(()=>({})),`Failed to bulk update papers: ${s.status}`));return s.json()}async function ew(t,a){let o=await (0,e.fetchWithAuth)(`${e.API_BASE}/papers/${t}/`,{method:"PATCH",body:JSON.stringify(a),cache:"no-store"});if(!o.ok)throw Error(r(await o.json().catch(()=>({})),`Failed to update paper: ${o.status}`));return o.json()}async function eA(t){let a=await (0,e.fetchWithAuth)(`${e.API_BASE}/papers/${t}/pin/`,{method:"POST",body:JSON.stringify({}),cache:"no-store"});if(!a.ok)throw Error(r(await a.json().catch(()=>({})),`Failed to pin paper: ${a.status}`));return a.json()}async function e$(t){let a=await (0,e.fetchWithAuth)(`${e.API_BASE}/papers/${t}/suggest-tags/`,{method:"POST",body:JSON.stringify({}),cache:"no-store"});if(!a.ok)throw Error(r(await a.json().catch(()=>({})),`Failed to suggest tags: ${a.status}`));return a.json()}async function ey(t){let a=await (0,e.fetchWithAuth)(`${e.API_BASE}
1/workspaces/${t}/citation-stats/`,{next:{revalidate:600}});if(!a.ok)throw new e.ApiResponseError(`Failed to fetch citation stats: ${a.status}`,a.status);return a.json()}async function ek(t,a){let r=await (0,e.fetchWithAuth)(c(`${e.API_BASE}/papers/${t}/`,a),{next:{revalidate:300}});if(!r.ok)throw new e.ApiResponseError(`Failed to fetch paper: ${r.status}`,r.status);return r.json()}async function eS(t){let a=await (0,e.fetchWithAuth)(`${e.API_BASE}/workspaces/${t}/paper-analytics/`,{next:{revalidate:300}});if(!a.ok)throw new e.ApiResponseError(`Failed to fetch paper analytics: ${a.status}`,a.status);return a.json()}async function eE(t){return u(`${e.API_BASE}/questions/?workspace=${t}`,{next:{revalidate:30}},"questions")}async function em(t){let a=await (0,e.fetchWithAuth)(`${e.API_BASE}/questions/`,{method:"POST",body:JSON.stringify(t),cache:"no-store"});if(!a.ok)throw Error(r(await a.json().catch(()=>({})),`Failed to create question: ${a.status}`));return a.json()}async function eP(t,a){let o=await (0,e.fetchWithAuth)(`${e.API_BASE}/questions/${t}/`,{method:"PATCH",body:JSON.stringify(a),cache:"no-store"});if(!o.ok)throw Error(r(await o.json().catch(()=>({})),`Failed to update question: ${o.status}`));return o.json()}async function eg(t){let a=await (0,e.fetchWithAuth)(`${e.API_BASE}/questions/${t}/`,{method:"DELETE",cache:"no-store"});if(!a.ok&&204!==a.status)throw Error(r(await a.json().catch(()=>({})),`Failed to delete question: ${a.status}`))}async function ej(t,a){let o=await (0,e.fetchWithAuth)(`${e.API_BASE}/questions/${t}/link-paper/${a}/`,{method:"POST",cache:"no-store"});if(!o.ok)throw Error(r(await o.json().catch(()=>({})),`Failed to link paper: ${o.status}`));return o.json()}async function e_(t,a){let o=await (0,e.fetchWithAuth)(`${e.API_BASE}/questions/${t}/unlink-paper/${a}/`,{method:"DELETE",cache:"no-store"});if(!o.ok)throw Error(r(await o.json().catch(()=>({})),`Failed to unlink paper: ${o.status}`));return o.json()}async function eb(t,a){let o=await (0,e.fetchWithAuth)(`${e.API_BASE}/questions/batch-status/`,{method:"POST",body:JSON.stringify({ids:t,status:a}),cache:"no-store"});if(!o.ok)throw Error(r(await o.json().catch(()=>({})),`Batch status failed: ${o.status}`));return o.json()}async function eB(t,a){let o=await (0,e.fetchWithAuth)(`${e.API_BASE}/questions/batch-priority/`,{method:"POST",body:JSON.stringify({ids:t,priority:a}),cache:"no-store"});if(!o.ok)throw Error(r(await o.json().catch(()=>({})),`Batch priority failed: ${o.status}`));return o.json()}async function eI(t){let a=await (0,e.fetchWithAuth)(`${e.API_BASE}/questions/bulk-delete/`,{method:"POST",body:JSON.stringify({ids:t}),cache:"no-store"});if(!a.ok)throw Error(r(await a.json().catch(()=>({})),`Batch delete failed: ${a.status}`));return a.json()}async function eW(t,a=[],o=[]){let s=await (0,e.fetchWithAuth)(`${e.API_BASE}/questions/bulk-tag/`,{method:"POST",body:JSON.stringify({ids:t,add:a,remove:o}),cache:"no-store"});if(!s.ok)throw Error(r(await s.json().catch(()=>({})),`Bulk tagging failed: ${s.status}`));return s.json()}async function eO(t,a){let o=await (0,e.fetchWithAuth)(`${e.API_BASE}/questions/bulk-move/`,{method:"POST",body:JSON.stringify({ids:t,workspace:a}),cache:"no-store"});if(!o.ok)throw Error(r(await o.json().catch(()=>({})),`Bulk move failed: ${o.status}`));return o.json()}async function eT(t){let a=await (0,e.fetchWithAuth)(`${e.API_BASE}/questions/${t}/pin/`,{method:"POST",body:JSON.stringify({}),cache:"no-store"});if(!a.ok)throw Error(r(await a.json().catch(()=>({})),`Failed to pin question: ${a.status}`));return a.json()}async function eF(t){let a=await (0,e.fetchWithAuth)(`${e.API_BASE}/questions/${t}/suggest-tags/`,{method:"POST",body:JSON.stringify({}),cache:"no-store"});if(!a.ok)throw Error(r(await a.json().catch(()=>({})),`Failed to suggest tags: ${a.status}`));return a.json()}async function ex(t){let a=await (0,e.fetchWithAuth)(`${e.API_BASE}/questions/${t}/scan-now/`,{method:"POST",body:JSON.stringify({}),cache:"no-store"});if(!a.ok)throw Error(r(await a.json().catch(()=>({})),`Failed to trigger scan: ${a.status}`));return a.json()}async function ev(t){let a=await (0,e.fetchWithAuth)(`${e.API_BASE}
1/workspaces/${t}/question-analytics/`,{next:{revalidate:300}});if(!a.ok)throw new e.ApiResponseError(`Failed to fetch question analytics: ${a.status}`,a.status);return a.json()}async function eN(t,a){let r=await (0,e.fetchWithAuth)(c(`${e.API_BASE}/questions/${t}/`,a),{next:{revalidate:60}});if(!r.ok)throw new e.ApiResponseError(`Failed to fetch question: ${r.status}`,r.status);return r.json()}async function eJ(t,a,r=20,o){let s=new URLSearchParams({q:t,limit:String(r)});a&&s.set("workspace",a);let n=await (0,e.fetchWithAuth)(`${e.API_BASE}/global-search/?${s}`,{...o,cache:"no-store"});if(!n.ok)throw Error(`Search failed: ${n.status}`);return n.json()}function eR(t){let a=(0,e.getApiBase)().replace(/\/$/,""),r=t.replace(/^\/+|\/+$/g,"");return"/api/bff"===a?`${a}/${r}`:`${a}/${r}/`}async function eC(t,a,o){let s=await (0,e.fetchWithAuth)(eR("support"),{method:"POST",body:JSON.stringify({subject:t,message:a,email:o})});if(!s.ok){let t=await s.json().catch(()=>({}));throw new e.ApiResponseError(r(t,`Failed to submit ticket: ${s.status}`),s.status)}return s.json()}async function eL(t){let a=await (0,e.fetchWithAuth)(eR("newsletter/subscribe"),{method:"POST",body:JSON.stringify({email:t})});if(!a.ok){let t=await a.json().catch(()=>({}));throw new e.ApiResponseError(r(t,`Failed to subscribe: ${a.status}`),a.status)}return a.json()}async function eU(t){return(await eM(t)).items}function eM(t){return f(`${e.API_BASE}/research-tasks/?workspace=${t}`,void 0,"tasks")}async function eq(t){let a=await (0,e.fetchWithAuth)(`${e.API_BASE}/research-tasks/`,{method:"POST",body:JSON.stringify(t),cache:"no-store"});if(!a.ok)throw Error(r(await a.json().catch(()=>({})),`Failed to create task: ${a.status}`));return a.json()}async function eD(t,a){let o=await (0,e.fetchWithAuth)(`${e.API_BASE}/research-tasks/${t}/`,{method:"PATCH",body:JSON.stringify(a),cache:"no-store"});if(!o.ok)throw Error(r(await o.json().catch(()=>({})),`Failed to update task: ${o.status}`));return o.json()}async function eH(t){let a=await (0,e.fetchWithAuth)(`${e.API_BASE}/research-tasks/${t}/`,{method:"DELETE",cache:"no-store"});if(!a.ok&&204!==a.status)throw Error(r(await a.json().catch(()=>({})),`Failed to delete task: ${a.status}`))}async function eQ(t){let a=await (0,e.fetchWithAuth)(`${e.API_BASE}/research-tasks/bulk-delete/`,{method:"POST",body:JSON.stringify({ids:t}),cache:"no-store"});if(!a.ok)throw Error(r(await a.json().catch(()=>({})),`Batch delete failed: ${a.status}`));return a.json()}async function ez(t,a=[],o=[]){let s=await (0,e.fetchWithAuth)(`${e.API_BASE}/research-tasks/bulk-tag/`,{method:"POST",body:JSON.stringify({ids:t,add:a,remove:o}),cache:"no-store"});if(!s.ok)throw Error(r(await s.json().catch(()=>({})),`Bulk tagging failed: ${s.status}`));return s.json()}async function eG(t,a){let o=await (0,e.fetchWithAuth)(`${e.API_BASE}/research-tasks/bulk-move/`,{method:"POST",body:JSON.stringify({ids:t,workspace:a}),cache:"no-store"});if(!o.ok)throw Error(r(await o.json().catch(()=>({})),`Bulk move failed: ${o.status}`));return o.json()}async function eK(t,a,o){let s=await (0,e.fetchWithAuth)(`${e.API_BASE}/workspaces/${t}/tasks/bulk-update/`,{method:"POST",body:JSON.stringify({task_ids:a,stage:o}),cache:"no-store"});if(!s.ok)throw Error(r(await s.json().catch(()=>({})),`Failed to bulk update tasks: ${s.status}`));return s.json()}async function eV(t){let a=await (0,e.fetchWithAuth)(`${e.API_BASE}/research-tasks/${t}/pin/`,{method:"POST",body:JSON.stringify({}),cache:"no-store"});if(!a.ok)throw Error(r(await a.json().catch(()=>({})),`Failed to pin task: ${a.status}`));return a.json()}async function eX(t){let a=await (0,e.fetchWithAuth)(`${e.API_BASE}/workspaces/${t}/task-analytics/`,{next:{revalidate:120}});if(!a.ok)throw new e.ApiResponseError(`Failed to fetch task analytics: ${a.status}`,a.status);return a.json()}async function eY(t){return u(`${e.API_BASE}/theses/?workspace=${t}`)}async function eZ(t,a){let o=await (0,e.fetchWithAuth)(`${e.API_BASE}/theses/`,{method:"POST",body:JSON.stringify({workspace:t,title:a}),cache:"no-store"});if(!o.ok)throw Error(r(await o.json().catch(()=>({})),`Failed to create thesis: ${o.status}`));return o.json()}async function e0(t,a){let o=await (0,e.fetchWithAuth)(`${e.API_BASE}/theses/${t}/`,{method:"PATCH",body:JSON.stringify(a),cache:"no-store"});if(!o.ok)throw Error(r(await o.json().catch(()=>({})),`Failed to update thesis: ${o.status}`));return o.json()}async function e3(t){let a=await (0,e.fetchWithAuth)(`${e.API_BASE}/theses/${t}/`,{method:"DELETE",cache:"no-store"});if(!a.ok&&204!==a.status)throw new e.ApiResponseError(`Failed to delete thesis: ${a.status}`,a.status)}async function e4(t){let a=await (0,e.fetchWithAuth)(`${e.API_BASE}/theses/${t}
1/pin/`,{method:"POST",cache:"no-store"});if(!a.ok)throw new e.ApiResponseError(`Failed to pin thesis: ${a.status}`,a.status);return a.json()}async function e6(t){let a=await (0,e.fetchWithAuth)(`${e.API_BASE}/theses/${t}/generate_scaffold/`,{method:"POST",cache:"no-store"});if(!a.ok)throw Error(r(await a.json().catch(()=>({})),`Failed to generate scaffold: ${a.status}`));return a.json()}async function e2(t,a){let r=await (0,e.fetchWithAuth)(c(`${e.API_BASE}/theses/${t}/`,a),{cache:"no-store"});if(!r.ok)throw new e.ApiResponseError(`Failed to load thesis: ${r.status}`,r.status);return r.json()}async function e1(t,a){let r=await (0,e.fetchWithAuth)(c(`${e.API_BASE}/thesis-chapters/${t}/`,a),{cache:"no-store"});if(!r.ok)throw new e.ApiResponseError(`Failed to load thesis chapter: ${r.status}`,r.status);return r.json()}async function e5(t,a){let o=await (0,e.fetchWithAuth)(`${e.API_BASE}/thesis-chapters/${t}/`,{method:"PATCH",body:JSON.stringify(a),cache:"no-store"});if(!o.ok)throw Error(r(await o.json().catch(()=>({})),`Failed to update chapter: ${o.status}`));return o.json()}async function e8(){let t=await u(`${e.API_BASE}/workspaces/`,{next:{revalidate:30}},"workspaces");return{results:t,count:t.length}}async function e7(t){let a=await (0,e.fetchWithAuth)(`${e.API_BASE}/workspaces/${t}/metadata/`);if(!a.ok)throw new e.ApiResponseError(`Failed to load workspace metadata: ${a.status}`,a.status);return a.json()}async function e9(t,a={}){let r=a.enrichLinked?{enrich_linked:!0}:{},o=await (0,e.fetchWithAuth)(`${e.API_BASE}/workspaces/${t}/rebuild-context/`,{method:"POST",body:JSON.stringify(r),headers:{"Content-Type":"application/json"},cache:"no-store"});if(!o.ok){let t=await o.json().catch(()=>({}));throw new e.ApiResponseError(t.detail||t.error||`Failed to rebuild Copilot context: ${o.status}`,o.status)}return o.json()}async function at(t){let a=await (0,e.fetchWithAuth)(`${e.API_BASE}/workspaces/${t}/summary/`,{next:{revalidate:30}});if(!a.ok)throw new e.ApiResponseError(`Failed to load workspace summary: ${a.status}`,a.status);return a.json()}async function ae(t){let a=await (0,e.fetchWithAuth)(`${e.API_BASE}/workspaces/${t}/briefing/`);if(!a.ok)throw new e.ApiResponseError(`Failed to load workspace briefing: ${a.status}`,a.status);return a.json()}async function aa(t){let a=await (0,e.fetchWithAuth)(`${e.API_BASE}/workspaces/`,{method:"POST",body:JSON.stringify(t),cache:"no-store"});if(!a.ok){let t=await a.json().catch(()=>({}));throw Error(t.detail||t.error||`Failed to create workspace: ${a.status}`)}return a.json()}async function ar(t,a){let r=await (0,e.fetchWithAuth)(`${e.API_BASE}/workspaces/${t}/`,{method:"PATCH",body:JSON.stringify(a),cache:"no-store"});if(!r.ok){let t=await r.json().catch(()=>({}));throw Error(t.detail||t.error||`Failed to update workspace: ${r.status}`)}return r.json()}async function ao(t){let a=await (0,e.fetchWithAuth)(`${e.API_BASE}/workspaces/${t}/`,{method:"DELETE",cache:"no-store"});if(!a.ok&&204!==a.status){let t=await a.json().catch(()=>({}));throw Error(t.detail||t.error||`Failed to delete workspace: ${a.status}`)}}async function as(t){let a=await (0,e.fetchWithAuth)(`${e.API_BASE}/workspaces/${t}/pin/`,{method:"POST",body:JSON.stringify({}),cache:"no-store"});if(!a.ok){let t=await a.json().catch(()=>({}));throw Error(t.detail||t.error||`Failed to pin workspace: ${a.status}`)}return a.json()}async function an(t){let a=await (0,e.fetchWithAuth)(`${e.API_BASE}/workspaces/${t}/members/`,{cache:"no-store"});if(!a.ok)throw new e.ApiResponseError(`Failed to load members: ${a.status}`,a.status);return a.json()}async function ai(t,a){let r=await (0,e.fetchWithAuth)(`${e.API_BASE}/workspaces/${t}/add-member/`,{method:"POST",body:JSON.stringify(a)});if(!r.ok){let t=await r.json().catch(()=>({}));throw Error(t.error||t.detail||`Failed to add member: ${r.status}`)}return r.json()}async function ac(t,a){let r=await (0,e.fetchWithAuth)(`${e.API_BASE}/workspaces/${t}/remove-member/`,{method:"POST",body:JSON.stringify({user_id:a})});if(!r.ok)throw Error((await r.json().catch(()=>({}))).error||`Failed to remove member: ${r.status}`);return r.json()}async function ah(t,a,r){let o=await (0,e.fetchWithAuth)(`${e.API_BASE}
1/workspaces/${t}/update-member-role/`,{method:"POST",body:JSON.stringify({user_id:a,role:r})});if(!o.ok)throw Error((await o.json().catch(()=>({}))).error||`Failed to update role: ${o.status}`);return o.json()}async function au(t,a,r="viewer"){let o=await (0,e.fetchWithAuth)(`${e.API_BASE}/workspaces/${t}/invite/`,{method:"POST",body:JSON.stringify({email:a,role:r})});if(!o.ok)throw Error((await o.json().catch(()=>({}))).error||`Failed to send invitation: ${o.status}`);return o.json()}async function af(t){let a=await (0,e.fetchWithAuth)(`${e.API_BASE}/workspaces/accept-invitation/`,{method:"POST",body:JSON.stringify({token:t})});if(!a.ok)throw Error((await a.json().catch(()=>({}))).error||`Failed to accept invitation: ${a.status}`);return a.json()}async function al(t,a,r){let o=await (0,e.fetchWithAuth)(`${e.API_BASE}/workspaces/${t}/update-member-permissions/`,{method:"POST",body:JSON.stringify({user_id:a,permissions:r})});if(!o.ok)throw Error((await o.json().catch(()=>({}))).error||`Failed to update permissions: ${o.status}`);return o.json()}async function ap(t,a,r){let o={};a&&(o.invitation_id=a),r&&(o.email=r);let s=await (0,e.fetchWithAuth)(`${e.API_BASE}/workspaces/${t}/revoke-invitation/`,{method:"POST",body:JSON.stringify(o)});if(!s.ok)throw Error((await s.json().catch(()=>({}))).error||`Failed to revoke invitation: ${s.status}`);return s.json()}async function ad(t){let a=await (0,e.fetchWithAuth)(`${e.API_BASE}/workspaces/${t}/export/snapshot/`,{method:"POST"});if(!a.ok){let t=await a.json().catch(()=>({}));throw Error(t.detail||t.error||`Failed to create snapshot: ${a.status}`)}return a.blob()}async function aw(t,a,r){let o=new URLSearchParams({workspace:t,q:a}),s=await (0,e.fetchWithAuth)(`${e.API_BASE}/search/?${o}`,{...r,cache:"no-store"});if(!s.ok)throw new e.ApiResponseError(`Failed to search workspace: ${s.status}`,s.status);return s.json()}async function aA(t){let a=await (0,e.fetchWithAuth)(`${e.API_BASE}/workspaces/${t}/stats/`,{next:{revalidate:30}});if(!a.ok)throw new e.ApiResponseError(`Failed to load workspace stats: ${a.status}`,a.status);return a.json()}async function a$(){let t=await (0,e.fetchWithAuth)(`${e.API_BASE}/tags/`,{next:{revalidate:30}});if(!t.ok)throw new e.ApiResponseError(`Failed to load workspace tags: ${t.status}`,t.status);return t.json()}async function ay(t,a){let r=await (0,e.fetchWithAuth)(`${e.API_BASE}/workspaces/${t}/tags/${encodeURIComponent(a)}/`,{method:"POST",cache:"no-store"});if(!r.ok)throw new e.ApiResponseError(`Failed to add tag: ${r.status}`,r.status);return r.json()}async function ak(t,a){let r=await (0,e.fetchWithAuth)(`${e.API_BASE}/workspaces/${t}/tags/${encodeURIComponent(a)}/`,{method:"DELETE",cache:"no-store"});if(!r.ok)throw new e.ApiResponseError(`Failed to remove tag: ${r.status}`,r.status);return r.json()}async function aS(t){let a=await (0,e.fetchWithAuth)(`${e.API_BASE}/workspaces/import-json/`,{method:"POST",body:JSON.stringify(t),cache:"no-store"});if(!a.ok){let t=await a.json().catch(()=>({}));throw new e.ApiResponseError(t.detail||t.error||`Import failed: ${a.status}`,a.status)}return a.json()}async function aE(){let t=await (0,e.fetchWithAuth)(`${e.API_BASE}/workspace-templates/`,{next:{revalidate:3600}});if(!t.ok)throw new e.ApiResponseError(`Failed to fetch templates: ${t.status}`,t.status);return t.json()}async function am(t,a=24){let r=await (0,e.fetchWithAuth)(`${e.API_BASE}/workspaces/${t}/trends/?window_hours=${a}`,{next:{revalidate:60}});if(!r.ok)throw new e.ApiResponseError(`Failed to fetch trends: ${r.status}`,r.status);return r.json()}async function aP(t,a=1){let r=await (0,e.fetchWithAuth)(`${e.API_BASE}/workspaces/${t}/digest/?days=${a}`,{next:{revalidate:300}});if(!r.ok)throw new e.ApiResponseError(`Failed to fetch digest: ${r.status}`,r.status);return r.json()}async function ag(t,a=20,r){let o=new URLSearchParams({limit:String(a)});r?.since&&o.set("since",r.since),r?.type&&o.set("type",r.type);let s=await (0,e.fetchWithAuth)(`${e.API_BASE}/workspaces/${t}/activity/?${o}`,{next:{revalidate:30}});if(!s.ok)throw new e.ApiResponseError(`Failed to fetch activity: ${s.status}`,s.status);return s.json()}t.s(["bulkImportCSV",0,tl,"createExperimentLog",0,ti,"createExperimentRun",0,tn,"deleteExperimentLog",0,tu,"fetchExperimentAnalytics",0,tp,"fetchExperimentLog",0,Z,"fetchExperimentLogs",0,tt,"fetchExperimentLogsWindow",0,te,"fetchExperimentRun",0,tr,"fetchExperimentRuns",0,ta,"fetchWorkspaceExperimentRunsWindow",0,function(t){return f(`${e.API_BASE}/experiment-runs/?${new URLSearchParams({workspace:t,ordering:"-ran_at,-run_number"})}`,{cache:"no-store"},"experiment runs")},"generateExperimentPlan",0,to,"generateExperimentSuggestions",0,X,"getAdvisorAdvice",0,Y,"pinExperiment",0,tc,"searchExperimentLogsWindow",0,function(t,a,r){return f(`${e.API_BASE}/experiment-logs/?${new URLSearchParams({workspace:t,search:a})}`,{...r,cache:"no-store"},"experiment search")},"summarizeExperimentRun",0,ts,"updateExperimentLog",0,tf,"updateExperimentRun",0,th],56548),t.s(["checkGrantCompliance",0,tk,"executeSandboxCode",0,tS,"generateFundingCopilot",0,ty,"generatePosterOutline",0,t$,"generatePublicationIdeas",0,tw,"generateSlideOutline",0,tA,"generateWeeklyUpdate",0,td],86504),t.s(["createExternalIntegration",0,tE,"fetchExternalIntegrations",0,tj,"fetchLinkedResources",0,t_,"manualLinkCitation",0,tg,"testChatIntegrationPost",0,tP,"triggerIntegrationSync",0,tm],19612),t.s(["createKnowledgeArticle",0,tB,"fetchKnowledgeArticles",0,tb],11649),t.s(["createLabAsset",0,tT,"createResearchProgramTasks",0,tv,"fetchLabAssets",0,tO,"fetchLabDashboard",0,tI,"fetchResearchProgram",0,tx,"fetchUsage",0,tW,"linkLabAssetToWorkspace",0,tF],54686),t.s(["batchDeleteManuscripts",0,tJ,"bulkMoveManuscripts",0,tN,"createManuscript",0,tL,"deleteManuscript",0,tM,"exportManuscriptMarkdown",0,tK,"fetch
1Manuscript",0,tR,"fetchManuscripts",0,tC,"generateManuscriptScaffold",0,tH,"pinManuscript",0,tq,"publishManuscriptToOSF",0,tV,"redTeamManuscript",0,tG,"refineManuscriptSection",0,tz,"suggestManuscriptTitles",0,tQ,"togglePublicManuscript",0,tD,"updateManuscript",0,tU],10607),t.s(["batchDeleteNotes",0,t1,"bulkMoveNotes",0,t5,"bulkTagNotes",0,t2,"createNote",0,t3,"deleteNote",0,t6,"exportNoteMarkdown",0,t7,"fetchNote",0,tX,"fetchNoteAnalytics",0,t8,"fetchNotes",0,tZ,"fetchNotesWindow",0,t0,"fetchPaperNotes",0,tY,"searchNotesWindow",0,function(t,a,r){let o=new URLSearchParams({workspace:t,search:a});return f(`${e.API_BASE}/notes/?${o}`,{...r,cache:"no-store"},"note search")},"updateNote",0,t4],76058),t.s(["batchDeletePapers",0,el,"bulkIngestPapers",0,eh,"bulkMovePapers",0,ep,"bulkUpdatePapers",0,ed,"createPaper",0,eu,"deletePaper",0,ef,"extractPaperCard",0,ec,"fetchCitationGraph",0,er,"fetchCitationNetworkStats",0,ey,"fetchPaper",0,ek,"fetchPaperAnalytics",0,eS,"fetchPapers",0,t9,"fetchPapersWindow",0,et,"fetchWorkspaceFrontierMap",0,en,"ingestPaper",0,es,"minePaperFrontier",0,ei,"paperHasCard",0,function(t){return!!t&&("boolean"==typeof t.has_card?t.has_card:!!t.card)},"pinPaper",0,eA,"searchPapers",0,ee,"searchPapersWindow",0,ea,"suggestPaperTags",0,e$,"synthesizeWorkspacePapers",0,eo,"updatePaper",0,ew],43697),t.s(["batchDeleteQuestions",0,eI,"batchPriorityQuestions",0,eB,"batchStatusQuestions",0,eb,"bulkMoveQuestions",0,eO,"bulkTagQuestions",0,eW,"createQuestion",0,em,"deleteQuestion",0,eg,"fetchQuestion",0,eN,"fetchQuestionAnalytics",0,ev,"fetchQuestions",0,eE,"linkPaperToQuestion",0,ej,"pinQuestion",0,eT,"searchQuestionsWindow",0,function(t,a,r){let o=new URLSearchParams({workspace:t,search:a});return f(`${e.API_BASE}/questions/?${o}`,{...r,cache:"no-store"},"question search")},"suggestQuestionTags",0,eF,"triggerQuestionScan",0,ex,"unlinkPaperFromQuestion",0,e_,"updateQuestion",0,eP],38745),t.s(["globalSearch",0,eJ],55442),t.s(["submitSupportTicket",0,eC,"subscribeNewsletter",0,eL],66289),t.s(["batchDeleteTasks",0,eQ,"bulkMoveTasks",0,eG,"bulkTagTasks",0,ez,"bulkUpdateTasks",0,eK,"createTask",0,eq,"deleteTask",0,eH,"fetchTaskAnalytics",0,eX,"fetchWorkspaceTasks",0,eU,"fetchWorkspaceTasksWindow",0,eM,"pinTask",0,eV,"updateTask",0,eD],89893),t.s(["createThesis",0,eZ,"deleteThesis",0,e3,"fetchTheses",0,eY,"fetchThesis",0,e2,"fetchThesisChapter",0,e1,"generateThesisScaffold",0,e6,"pinThesis",0,e4,"updateThesis",0,e0,"updateThesisChapter",0,e5],63802),t.s(["acceptInvitation",0,af,"addWorkspaceMember",0,ai,"addWorkspaceTag",0,ay,"createWorkspace",0,aa,"createWorkspaceSnapshot",0,ad,"deleteWorkspace",0,ao,"fetchWorkspaceActivity",0,ag,"fetchWorkspaceBriefing",0,ae,"fetchWorkspaceDigest",0,aP,"fetchWorkspaceMembers",0,an,"fetchWorkspaceMetadata",0,e7,"fetchWorkspaceStats",0,aA,"fetchWorkspaceSummary",0,at,"fetchWorkspaceTags",0,a$,"fetchWorkspaceTemplates",0,aE,"fetchWorkspaceTrends",0,am,"fetchWorkspaces",0,e8,"getWorkspaceExportActivityCsvUrl",0,function(t){return`${e.API_BASE}/workspaces/${t}/export/activity.csv`},"getWorkspaceExportArtifactsCsvUrl",0,function(t){return`${e.API_BASE}/workspaces/${t}/export/artifacts.csv`},"getWorkspaceExportExperimentsCsvUrl",0,function(t){return`${e.API_BASE}/workspaces/${t}/export/experiments.csv`},"getWorkspaceExportJsonUrl",0,function(t){return`${e.API_BASE}/workspaces/${t}/export/json/`},"getWorkspaceExportManuscriptsCsvUrl",0,function(t){return`${e.API_BASE}/workspaces/${t}/export/manuscripts.csv`},"getWorkspaceExportNotesCsvUrl",0,function(t){return`${e.API_BASE}/workspaces/${t}/export/notes.csv`},"getWorkspaceExportPapersCsvUrl",0,function(t){return`${e.API_BASE}/workspaces/${t}/export/papers.csv`},"getWorkspaceExportQuestionsCsvUrl",0,function(t){return`${e.API_BASE}/workspaces/${t}/export/questions.csv`},"getWorkspaceExportTasksCsvUrl",0,function(t){return`${e.API_BASE}/workspaces/${t}/export/tasks.csv`},"getWorkspaceExportUrl",0,function(t){return`${e.API_BASE}/workspaces/${t}/export/`},"importWorkspaceJSON",0,aS,"inviteToWorkspace",0,au,"pinWorkspace",0,as,"rebuildWorkspaceContext",0,e9,"removeWorkspaceMember",0,ac,"removeWorkspaceTag",0,ak,"revokeInvitation",0,ap,"searchWorkspace",0,aw,"updateWorksp
1ace",0,ar,"updateWorkspaceMemberPermissions",0,al,"updateWorkspaceMemberRole",0,ah],96243),t.s([],78277)}]);
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.