diff --git a/public/asset-manifest.json b/public/asset-manifest.json
index 450a928..c8accc2 100644
--- a/public/asset-manifest.json
+++ b/public/asset-manifest.json
@@ -1,6 +1,6 @@
{
"core.min.js": "core.d23af1c652.min.js",
- "vendor.min.js": "vendor.1d5b2cdece.min.js",
+ "vendor.min.js": "vendor.2f2ca7b3e7.min.js",
"mermaid.min.js": "mermaid.a7356d5ed1.min.js",
"all.min.css": "all.e8df2ae9d6.min.css",
"markdown.min.js": "markdown.6c8dfb7b1d.min.js",
diff --git a/public/script/app.js b/public/script/app.js
index a1fb974..93607aa 100644
--- a/public/script/app.js
+++ b/public/script/app.js
@@ -2028,7 +2028,7 @@ export const anonymizeController = function (state, http, html, params, location
if (field.github || (state.sourceUrlError && state.workspaceOpen)) {
return { kind: "github", title: "Not a GitHub URL", text: "Paste a repository, pull request, or gist URL from github.com." };
}
- if (state.sourceLoading || state.details && !field.used) return null;
+ if (state.sourceLoading || state.details && !field.used && !state.sourceError) return null;
if (state.gistAppRequired || state.gistOAuthRequired) return { kind: "connect", title: "Couldn't load this gist", text: "Connect GitHub to read gists." };
const code = state.sourceError || (field.used ? "repo_already_anonymized" : field.access ? "repo_not_accessible" : field.missing ? "repo_not_found" : "");
if (!code) return null;
@@ -2208,6 +2208,7 @@ export const anonymizeController = function (state, http, html, params, location
if (!confirm("Reconnect to the repository currently at this GitHub URL? Review its branch and commit before saving. Saving will replace the published snapshot.")) return;
state.reconnectingSource = true;
state.reconnectRepositoryId = undefined;
+ state.details = null;
state.source.commit = "";
state.source.branch = "";
state.readme = "";
diff --git a/public/script/vendor.min.js b/public/script/vendor.min.js
index 7c85537..1c56906 100644
--- a/public/script/vendor.min.js
+++ b/public/script/vendor.min.js
@@ -22,8 +22,8 @@ while being at
`).map(b=>b.trim()).filter(b=>b.length>0),options:e.options};e.saving=!0,e.error=null,t.post("/api/user/default",m).then(()=>{p.accept(y),e.saving=!1,e.message=e.unsavedChanges?null:"Saved",v&&i.cancel(v),v=i(()=>{e.message=null},2500)},b=>{e.saving=!1;let E=b&&b.data&&b.data.error,S="Unable to save your defaults. Please try again.";Promise.all([s("ERRORS."+E),s("ERRORS.unknown_error")]).then(([N,w])=>{e.error=E&&N!==w?N:S},()=>{e.error=S})})},e.deleteAccount=()=>{e.deletingAccount||!e.confirmDeleteAccount||e.deleteUsername!==e.user?.username||(e.deletingAccount=!0,t.delete("/api/user").then(()=>{window.location.href="/"},()=>{e.deletingAccount=!1,e.deleteError="Unable to delete the account. Please try again."}))}},Hc=function(e,t,s){e.repoId=null,e.repoUrl=null,e.claim=()=>{t.post("/api/repo/claim",{repoId:e.repoId,repoUrl:e.repoUrl}).then(i=>{s.url("/dashboard")},i=>{e.error=i.data,e.claimForm.repoUrl.setValidity("not_found",!1),e.claimForm.repoId.setValidity("not_found",!1)})}},jc=function(e,t,s,i,o){e.user&&!e.user.status&&s.url("/dashboard"),e.watch("user.status",()=>{e.user&&!e.user.status&&s.url("/dashboard")}),e.features=[{key:"anonymize",num:"01",eyebrow:"Anonymize",title:"Double-anonymous,",accent:"your rules.",text:"Choose what reviewers may see: links, images, PDFs, notebooks, GitHub Pages. Add your own terms, with regex if you need it, and pick the expiration date.",cta:"Start an anonymization",href:"/anonymize",url:"anonymous.4open.science/anonymize",img:"/imgs/anonymize.png",alt:"The anonymize form: source repository, terms to redact, options and a live README preview"},{key:"review",num:"02",eyebrow:"Review",title:"Reviewers browse",accent:"the real thing.",text:"Highlighted source code, rendered PDFs, images, and notebooks, in a familiar file explorer. GitHub Pages is also supported.",cta:"Open the example",href:"https://anonymous.4open.science/r/840c8c57-3c32-451e-bf12-0e20be300389/",target:"_self",url:"anonymous.4open.science/r/840c8c57-\u2026",img:"/imgs/explorer.png",alt:"The repository explorer with a file tree and a rendered README"},{key:"manage",num:"03",eyebrow:"Manage",title:"One dashboard,",accent:"until the decision.",text:"Monitor views, edit configuration, remove or update your repository. Program chairs can group submissions under a conference with one shared expiry.",cta:"Open the dashboard",href:"/dashboard",needsUser:!0,url:"anonymous.4open.science/dashboard",img:"/imgs/dashboard.png",alt:"The dashboard listing anonymized repositories with status, views and expiry"}],e.feature=e.features[0].key,e.selectFeature=function(p){e.feature=p},e.featureHref=function(p){return p.needsUser&&!e.user?"/signin":p.href},e.featureTarget=function(p){return p.needsUser&&!e.user?"_self":p.target||void 0},e.featureKeydown=function(p,c){let v={ArrowDown:1,ArrowRight:1,ArrowUp:-1,ArrowLeft:-1,Home:"first",End:"last"}[p.key];if(v===void 0)return;p.preventDefault();let g=e.features.length,y=v==="first"?0:v==="last"?g-1:(c+v+g)%g;e.feature=e.features[y].key,o(()=>{let m=i.document.getElementById("feature-tab-"+e.feature);m&&m.focus()})},e.demoText=`# DeepLearnUtils
Developed by Jane Smith at MIT CSAIL.
See Smith et al., "Attention That Works," 2026.
-Contact: jane.smith@mit.edu`,e.demoTerms="Jane Smith, Smith, MIT CSAIL, jane.smith@mit.edu",e.demoParts=function(){let p=(e.demoTerms||"").split(/[,\n]/).map(m=>m.trim()).filter(Boolean).sort((m,b)=>b.length-m.length),c=m=>m.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");if(!p.length)return[{text:e.demoText}];let v=new RegExp("("+p.map(c).join("|")+")","gi"),g={},y=0;return(e.demoText||"").split(v).filter(m=>m!=="").map(m=>{let b=p.find(E=>E.toLowerCase()===m.toLowerCase());return b?(g[b.toLowerCase()]||(g[b.toLowerCase()]=++y),{text:String(g[b.toLowerCase()]),redacted:!0,original:m}):{text:m}})},e.demoCount=()=>e.demoParts().filter(p=>p.redacted).length,e.cards=[{key:"repositories",total:0,label:"repositories anonymized"},{key:"users",total:0,label:"researchers"},{key:"pageViews",total:0,label:"page views"},{key:"pullRequests",total:0,label:"pull requests"}],e.statsEmpty=()=>!!e.stat&&e.cards.every(p=>!p.total);function r(){t.get("/api/stat/").then(p=>{e.stat=p.data,e.cards[0].total=p.data.nbRepositories,e.cards[1].total=p.data.nbUsers,e.cards[2].total=p.data.nbPageViews,e.cards[3].total=p.data.nbPullRequests}).catch(()=>{})}r();function u(p){let c={series:p,bars:[],viewW:100,deltaToday:0,pctChange:0,pctAbs:0,isUp:!0};if(!p||p.length<2)return c;let v=new Array(p.length-1);for(let S=1;S
=2){let S=v[g-2];S&&(c.pctChange=(c.deltaToday-S)/S*100)}return c.pctAbs=Math.round(Math.abs(c.pctChange)),c.isUp=c.pctChange>=0,c}e.history={repositories:u([]),users:u([]),pageViews:u([]),pullRequests:u([])},t.get("/api/stat/history?days=60").then(p=>{let c=p.data||[];e.history={repositories:u(c.map(v=>v.nbRepositories||0)),users:u(c.map(v=>v.nbUsers||0)),pageViews:u(c.map(v=>v.nbPageViews||0)),pullRequests:u(c.map(v=>v.nbPullRequests||0))}}).catch(()=>{})},Gc=function(e,t,s,i,o,r){let u=bt();e.on("routeLeave",function(){$('[data-toggle="tooltip"]').tooltip("dispose")}),e.watch("user.status",()=>{e.user==null&&s.url("/")}),e.user==null&&s.url("/"),u.timeout(()=>{$('[data-toggle="tooltip"]').tooltip()},250),e.quotaExpanded=!1,e.closeQuota=()=>{e.quotaExpanded=!1,We(()=>document.querySelector(".dashboard-quota > summary")?.focus())},Bt()(document,"click",k=>{e.quotaExpanded&&!k.target.closest?.(".dashboard-quota")&&(e.quotaExpanded=!1)}),e.filtersExpanded=!1,e.projectView="all",e.selectedProject=null,e.projectName="",e.nameSaving=!1,e.nameError="",e.nameMessage="",e.needsAttention=k=>k.status==="error"||k._broken||c(k.status)==="progress"&&k._stale,e.attentionCount=()=>e.dashboardTotals?.attention??e.items.filter(e.needsAttention).length,e.hasProjects=()=>(e.dashboardTotals?.total??e.items.length)>0,e.setProjectView=k=>{e.projectView=k,k==="attention"&&(e.filters.status.error=!0,e.filters.status.progress=!0)},e.idleText=k=>{let q=Ca(k?.anonymizeDate||k?.lastView)||"";return/ ago$/.test(q)?"No activity for "+q.replace(/ ago$/,""):"No activity since "+q.replace(", "+new Date().getFullYear(),"")},e.projectDetailsId=k=>"project-details-"+encodeURIComponent(k._type+":"+(k._id||k._source||"unknown")),e.showProjectDetails=async k=>{e.selectedProject=k,e.projectName=k.projectName||"",e.nameError="",e.nameMessage="",await We();let q=document.getElementById(e.projectDetailsId(k));q?.focus(),q?.scrollIntoView?.({block:"nearest"})},e.closeProjectDetails=k=>{e.selectedProject=null,We(()=>document.querySelector(`[data-project-actions="${encodeURIComponent(k._type+":"+k._id)}"]`)?.focus())},e.saveProjectName=async k=>{if(e.nameSaving||!k._id)return;let q=e.projectName.trim();if(q.length>100){e.nameError="Use 100 characters or fewer.";return}e.nameSaving=!0,e.nameError="",e.nameMessage="";try{let G=await t.post("/api/user/project-name",{type:k._type,id:k._id,name:q});k.projectName=G.data.name,k._label=k.projectName||k._fallbackLabel,e.selectedProject===k&&(e.nameMessage=q?"Project name saved.":"Default project name restored."),T||(e.dashboardCursor=null,await F(),e.selectedProject===k&&(e.selectedProject=e.items.find(H=>H._type===k._type&&H._id===k._id)||null))}catch{e.selectedProject===k&&(e.nameError="The project name could not be saved. Try again.")}finally{e.nameSaving=!1}},e.copyingId=null,e.copyLink=async k=>{if(!k._viewUrl||e.copyingId)return;let q=new URL(k._viewUrl,o.location.origin).href;e.copyingId=k._type+":"+k._id;try{await Qa(q),e.addToast({title:"Link copied",body:"The anonymous link is ready to share."})}catch{e.addToast({title:"Copy this anonymous link",body:q})}finally{e.copyingId=null}},e.items=[],e.search="",e.loading=!0,e.statusKeyLabels={ready:"Ready",progress:"Preparing",error:"Error",expired:"Expiring / expired",removed:"Removing / removed"};let p=["queue","download","downloaded","preparing","anonymizing"];function c(k){return k==="ready"||k==="error"?k:k==="expired"||k==="expiring"?"expired":k==="removed"||k==="removing"?"removed":(p.indexOf(k)>-1,"progress")}let v=7200*1e3,g="dashboard.filterPrefs",y={typeFilter:"all",filters:{status:{ready:!0,progress:!0,error:!0,expired:!0,removed:!1}},orderBy:"-anonymizeDate"},m=loadFilterPrefs(g)||{};e.typeFilter=m.typeFilter||y.typeFilter,e.filters={status:Object.assign({},y.filters.status,m.filters&&m.filters.status||{})},e.orderBy=m.orderBy||y.orderBy;let b={_name:{label:"Anonymous ID",defaultDesc:!1},_label:{label:"Project",defaultDesc:!1},anonymizeDate:{label:"Anonymize date",defaultDesc:!0},status:{label:"Status",defaultDesc:!1},lastView:{label:"Last view",defaultDesc:!0},pageView:{label:"Views",defaultDesc:!0},"options.expirationDate":{label:"Expiration",defaultDesc:!1}};e.sortFields=b,e.sortField=()=>e.orderBy.replace(/^-/,""),e.sortDesc=()=>e.orderBy.charAt(0)==="-",e.sortLabel=()=>{let k=b[e.sortField()];return k?k.label:"Custom"},e.isSortedBy=k=>e.sortField()===k,e.setSort=(k,q)=>{typeof q!="boolean"&&(q=e.isSortedBy(k)?!e.sortDesc():!!(b[k]&&b[k].defaultDesc)),e.orderBy=(q?"-":"")+k},e.toggleSortDirection=()=>{e.setSort(e.sortField(),!e.sortDesc())},e.watchGroup(["typeFilter","orderBy"],()=>{saveFilterPrefs(g,{typeFilter:e.typeFilter,filters:e.filters,orderBy:e.orderBy})}),e.watch("filters",()=>{saveFilterPrefs(g,{typeFilter:e.typeFilter,filters:e.filters,orderBy:e.orderBy})},!0),r.load().then(k=>{e.quota=k},console.error);function E(k,q,G,H,Y,ee){k.pageView||(k.pageView=0),k.lastView||(k.lastView=""),k.options=k.options||{},k.options.terms=(k.options.terms||[]).filter(fe=>fe),k._id=q||"",k._source=H,k._broken=!q,k._name=q||H||"(unnamed)",k._fallbackLabel=k._type==="gist"?"Gist "+(q||H||"without an ID"):H||G||k._name,k._label=k.projectName||k._fallbackLabel,k._editUrl=q?Y:null,k._viewUrl=q?ee:null,k._broken&&(k.status="error",k.statusMessage="incomplete_record"),k._statusKey=c(k.status);let x=k.anonymizeDate||k.lastView;if(k._stale=k._statusKey==="progress"&&!!x&&Date.now()-new Date(x).getTime()>v,k.status==="expired"||k.status==="expiring")k._expiry={kind:"expired",date:k.options.expirationDate},k._expiry.label=Ea(k.options.expirationDate)||void 0;else if(k.status!=="ready")k._expiry={kind:"none"};else if(k.options.expirationMode==="never"||!k.options.expirationDate)k._expiry={kind:"never"};else{k._expiry={kind:"date",date:k.options.expirationDate};let fe=new Date(k.options.expirationDate).getTime()-Date.now();if(fe>0&&fe<=168*3600*1e3){let he=Math.max(1,Math.round(fe/36e5)),Be=Math.round(fe/864e5);k._expiry.soon=he<48?"in "+he+(he===1?" hour":" hours"):"in "+Be+" days"}}return k}function S(k){return t.get(k).then(q=>q.data||[],q=>(console.error(q),[]))}function N(){return e.loading=!0,i.all([S("/api/user/anonymized_repositories"),S("/api/user/anonymized_pull_requests"),S("/api/user/anonymized_gists")]).then(k=>{let q=k[0],G=k[1],H=k[2],Y=[];q.forEach(ee=>{ee._type="repo";let x=ee.source||{};Y.push(E(ee,ee.repoId,ee.repoId,x.fullName,"/anonymize/"+ee.repoId,"/r/"+ee.repoId+"/"))}),G.forEach(ee=>{ee._type="pr";let x=ee.source||{};Y.push(E(ee,ee.pullRequestId,ee.pullRequestId,x.repositoryFullName?x.repositoryFullName+"#"+x.pullRequestId:void 0,"/pull-request-anonymize/"+ee.pullRequestId,"/pr/"+ee.pullRequestId+"/"))}),H.forEach(ee=>{ee._type="gist";let x=ee.source||{};Y.push(E(ee,ee.gistId,ee.gistId,x.gistId,"/gist-anonymize/"+ee.gistId,"/gist/"+ee.gistId+"/"))}),e.items=Y,e.removedCount=Y.filter(ee=>ee._statusKey==="removed").length,e.loading=!1})}let w=0,T=!1;e.dashboardCursor=null,e.dashboardError="";function M(k){let q=k.source||{};return k._type==="repo"?E(k,k.repoId,k.repoId,q.fullName,"/anonymize/"+k.repoId,"/r/"+k.repoId+"/"):k._type==="pr"?E(k,k.pullRequestId,k.pullRequestId,q.repositoryFullName?q.repositoryFullName+"#"+q.pullRequestId:void 0,"/pull-request-anonymize/"+k.pullRequestId,"/pr/"+k.pullRequestId+"/"):E(k,k.gistId,k.gistId,q.gistId,"/gist-anonymize/"+k.gistId,"/gist/"+k.gistId+"/")}function F(k=!1){if(T)return N();let q=++w;return e.loading=!k,e.loadingMore=k,e.dashboardError="",t.get("/api/user/dashboard",{params:{q:e.search,type:e.typeFilter,sort:e.orderBy,statuses:Object.keys(e.filters.status).filter(G=>e.filters.status[G]!==!1).join(",")||"none",attention:String(e.projectView==="attention"),cursor:k?e.dashboardCursor:void 0}}).then(G=>{if(q===w){if(!Array.isArray(G.data?.items))return T=!0,N();e.items=(k?e.items:[]).concat(G.data.items.map(M)),e.dashboardCursor=G.data.cursor,e.dashboardTotals=G.data,k||_()}},G=>{if(q===w){if(G.status===404)return T=!0,N();e.dashboardError="Projects could not be loaded. Please try again."}}).finally(()=>{q===w&&(e.loading=!1,e.loadingMore=!1)})}e.loadMoreProjects=()=>F(!0);let j;e.watchGroup(["search","typeFilter","orderBy","projectView"],()=>{T||(j&&u.timeout.cancel(j),j=u.timeout(()=>F(),150))},!1),e.watch("filters",()=>{T||F()},!0,!1),e.on("dispose",()=>{w++}),F(),e.openItem=(k,q)=>{if(!k._viewUrl)return;let G=q&&q.target;G&&G.closest&&G.closest("a, button, .dropdown, input")||(o.location.href=k._viewUrl)},e.hiddenStatusCount=()=>Object.keys(e.filters.status).filter(k=>e.filters.status[k]===!1).length,e.hasHiddenStatus=()=>e.hiddenStatusCount()>0;let oe=()=>Object.keys(e.statusKeyLabels);e.onlyRemovedShown=()=>oe().every(k=>k==="removed"==(e.filters.status[k]!==!1)),e.isActiveDefault=()=>oe().every(k=>k==="removed"==(e.filters.status[k]===!1)),e.statusView=()=>e.projectView==="attention"?"attention":e.onlyRemovedShown()?"removed":e.filters.status.removed===!1?"active":"custom",e.setStatusView=k=>{if(k==="attention")return e.setProjectView("attention");e.projectView="all",oe().forEach(q=>{e.filters.status[q]=k==="removed"?q==="removed":q!=="removed"})},e.statusChipKeys=()=>{let k=e.statusView();return k==="removed"?[]:oe().filter(q=>e.filters.status[q]===!1&&!(q==="removed"&&k!=="custom"))},e.removedCount=null;function _(){if(T){e.removedCount=e.items.filter(q=>q._statusKey==="removed").length;return}let k=e.dashboardTotals;!k||e.projectView!=="all"||e.search.trim()||e.typeFilter!=="all"||(e.isActiveDefault()?e.removedCount=Math.max(0,k.total-k.filtered):e.onlyRemovedShown()&&(e.removedCount=k.filtered))}e.showViewTabs=()=>e.statusView()!=="active"||e.attentionCount()>0||e.removedCount>0||e.removedCount==null&&!!e.dashboardTotals&&e.dashboardTotals.total>e.dashboardTotals.filtered,e.hasActiveFilters=()=>e.projectView!=="all"||e.typeFilter!=="all"||e.search.trim().length>0||Object.keys(e.filters.status).some(k=>e.filters.status[k]===!1),e.showClearFilters=()=>e.search.trim().length>0||e.typeFilter!=="all"||e.statusChipKeys().length>0,e.isPlainView=()=>!e.showClearFilters(),e.clearFilters=()=>{let k=e.statusView();e.typeFilter="all",e.search="",e.setStatusView(k==="removed"?"removed":"active")};function z(k,q,G,H){t.get("/api/repo/"+k).then(async Y=>{let ee=H!==void 0&&H!==Y.data.status;for(let x of e.items)if(x._type==="repo"&&x.repoId==k){ee=ee||x.status!==Y.data.status;let fe=e.needsAttention(x);x.status=Y.data.status,x.statusMessage=Y.data.statusMessage,x._statusKey=c(x.status),x._statusKey!=="progress"&&(x._stale=!1);let he=e.needsAttention(x);e.dashboardTotals&&fe!==he&&(e.dashboardTotals.attention=Math.max(0,e.dashboardTotals.attention+(he?1:-1)));break}if(ee&&!T){e.dashboardCursor=null;let x=e.selectedProject;await F(),x&&e.selectedProject===x&&(e.selectedProject=e.items.find(fe=>fe._type===x._type&&fe._id===x._id)||null)}if(Y.data.status=="ready"||Y.data.status=="error"||Y.data.status=="removed"||Y.data.status=="expired"){q(Y.data);return}u.timeout(()=>z(k,q,G,Y.data.status),2500)},G)}let I=k=>k==="repo"?"repository":k==="gist"?"gist":"pull request",L=k=>k==="repo"?"/api/repo":k==="gist"?"/api/gist":"/api/pr";e.removeItem=k=>{let q=I(k._type);if(confirm(`Are you sure that you want to remove the ${q} ${k._id}?`)){let G=at({title:`Removing ${k._id}...`,date:new Date,body:`The ${q} ${k._id} is going to be removed.`});e.addToast(G);let H=`${L(k._type)}/${k._id}`;t.delete(H).then(()=>{k._type==="repo"?z(k._id,()=>{G.title=`${k._id} is removed.`,G.body=`The ${q} ${k._id} is removed.`},void 0,k.status):(G.title=`${k._id} is removed.`,G.body=`The ${q} ${k._id} is removed.`,F())},Y=>{G.title=`Error during the removal of ${k._id}.`,G.body=Y.body,F()})}},e.refreshItem=k=>{let q=I(k._type),G=at({title:`Refreshing ${k._id}...`,date:new Date,body:`The ${q} ${k._id} is going to be refreshed.`});e.addToast(G);let H=ee=>{G.title=`Error during the refresh of ${k._id}.`,G.body=ee.data?.error||ee.body||"The refresh could not be completed. Please try again.",F()},Y=`${L(k._type)}/${k._id}/refresh`;t.post(Y).then(()=>{k._type==="repo"?z(k._id,ee=>{if(ee.status!=="ready"){H({body:ee.statusMessage||`The repository is ${ee.status}.`});return}G.title=`${k._id} is refreshed.`,G.body=`The ${q} ${k._id} is refreshed.`},H,k.status):(G.title=`${k._id} is refreshed.`,G.body=`The ${q} ${k._id} is refreshed.`,F())},H)},e.extendItem=k=>{let q=I(k._type),G=at({title:`Extending ${k._id}...`,date:new Date,body:`The expiration of ${q} ${k._id} is being extended.`});e.addToast(G);let H=`${L(k._type)}/${k._id}/extend`;t.post(H).then(Y=>{let ee=Y?.data?.expirationDate?` until ${new Date(Y.data.expirationDate).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})}`:"";k._type==="repo"?z(k._id,()=>{G.title=`${k._id} is extended.`,G.body=`${q} ${k._id} is extended${ee}.`},void 0,k.status):(G.title=`${k._id} is extended.`,G.body=`${q} ${k._id} is extended${ee}.`,F())},Y=>{G.title=`Error during the extension of ${k._id}.`;let ee=Y.data&&Y.data.error;G.body=ee||Y.body,ee&&Object.prototype.hasOwnProperty.call(Xn.ERRORS,ee)&&(G.body=Xn.ERRORS[ee]),F()})},e.itemFilter=k=>{if(e.projectView==="attention"&&!e.needsAttention(k)||e.typeFilter!=="all"&&k._type!==e.typeFilter||e.filters.status[k._statusKey]===!1)return!1;let q=e.search.trim().toLowerCase();return!!(q.length==0||k._label&&String(k._label).toLowerCase().indexOf(q)>-1||k._source&&String(k._source).toLowerCase().indexOf(q)>-1||k._id&&String(k._id).toLowerCase().indexOf(q)>-1||k.conference&&String(k.conference).toLowerCase().indexOf(q)>-1)}};var Wc=function(e,t,s){let i=bt();e.repoId=s.repoId,e.reviewUrl=window.location.origin+"/r/"+encodeURIComponent(s.repoId)+"/",e.repo=null,e.progress=0,e.rateLimitResetAt=0,e.rateLimitCountdown="",e.shareUrl=(window.location?.origin||"")+"/r/"+encodeURIComponent(e.repoId)+"/",e.copied=!1;let o=null;e.copyShareUrl=async()=>{try{await Qa(e.shareUrl),e.copied=!0,o&&i.timeout.cancel(o),o=i.timeout(()=>{e.copied=!1},2e3)}catch{e.addToast?.({title:"Copy this anonymous link",body:e.shareUrl})}},e.selectShareUrl=g=>{let y=window.getSelection?.();if(!y||!g?.target)return;let m=document.createRange();m.selectNodeContents(g.target),y.removeAllRanges(),y.addRange(m)};var r=null;let u=null,p=!1;function c(g){e.rateLimitResetAt=g,r&&i.interval.cancel(r);function y(){var m=Math.max(0,Math.ceil((g-Date.now())/1e3));if(m<=0)e.rateLimitCountdown="",e.rateLimitResetAt=0,i.interval.cancel(r),r=null;else{var b=Math.floor(m/60),E=m%60;e.rateLimitCountdown=b>0?b+"m "+E+"s":E+"s"}}y(),r=i.interval(y,1e3)}e.on("dispose",function(){p=!0,r&&i.interval.cancel(r),u&&i.timeout.cancel(u)});function v(g){if(!g)return g;var y=g.match(/^rate_limited:(\d+)$/);return y?(c(parseInt(y[1],10)),null):(e.rateLimitResetAt=0,g)}e.getStatus=()=>{p||t.get("/api/repo/"+e.repoId,{repoId:e.repoId,repoUrl:e.repoUrl}).then(g=>{if(!p){e.repo=g.data,g.data.rateLimitResetAt?c(g.data.rateLimitResetAt):e.repo.statusMessage=v(e.repo.statusMessage),e.repo.status=="ready"?e.progress=100:e.repo.status=="queue"?e.progress=10:e.repo.status=="downloaded"?e.progress=50:e.repo.status=="download"||e.repo.status=="preparing"?e.progress=25:e.repo.status=="anonymizing"&&(e.progress=75);var y=!["ready","removed","expired"].includes(e.repo.status);e.repo.status=="error"&&!e.rateLimitResetAt&&(y=!1),y&&(u=i.timeout(e.getStatus,2e3))}},g=>{e.error=g.data.error})},e.getStatus()},mr=function(e,t,s,i,o,r,u){_c(),e.renderRedacted=_s,e.sourceUrl="",e.workspaceOpen=!1,e.sourceUrlError="",e.previewStatus="idle",e.sourceLoading=!1,e.mobilePane="settings";let p=window.matchMedia?.("(max-width: 767px)");e.mobileWorkspace=!!p?.matches,p?.addEventListener&&Bt()(p,"change",C=>{e.mobileWorkspace=C.matches}),e.selectMobilePane=C=>{e.mobilePane=C};let c=0,v=!1,g=new Set,y=(C,O=!1)=>!v&&C.generation===c&&C.url===e.sourceUrl.trim()&&C.connection===e.githubConnection&&(!O||C.branch===e.source.branch),m=()=>{let C={generation:c,url:e.sourceUrl.trim(),connection:e.githubConnection,branch:e.source.branch};return g.add(C),e.sourceLoading=!0,C},b=C=>{g.delete(C),v||(e.sourceLoading=[...g].some(O=>y(O)))};e.on("dispose",()=>{v=!0,c++});let E=null,S=C=>C.gistId&&!C.repo?"gist:"+C.gistId.toLowerCase():(C.owner+"/"+C.repo).toLowerCase()+(C.pullRequestId?"/pull/"+C.pullRequestId:""),N=ka(e,["sourceUrl","terms","repoId","pullRequestId","gistId","source","options","conference","githubConnection"],"anonymize:"+(o.path?.()||"")),w=null,T=null,M=null;e.hostingReview=!1,e.previewExpanded=!1,e.taskValidationError="",e.editRepository=()=>{e.mobilePane="settings",e.previewExpanded=!1,We(()=>document.querySelector(".anonymize-fields .is-invalid")?.focus())},e.submitRepository=C=>{if(e.taskValidationError="",!(e.sourceLoading||e.billingBusy||e.hostingSaving||e.billingPending)){if(si()||e.anonymize?.invalid||e.sourceUrlError){e.taskValidationError="Check the highlighted fields before continuing.",e.editRepository();return}return e.hostingNeedsPayment()?e.checkoutRepository(Xi(e.hostingChoice())?e.hostingChoice():""):e.anonymizeRepo(C)}},e.hostingPayment=!1,e.hostingAlternatives=!1,e.hostingPrice=C=>C.amount==null?"Price shown at checkout":new Intl.NumberFormat(void 0,{style:"currency",currency:C.currency,minimumFractionDigits:0,maximumFractionDigits:2}).format(C.amount/100)+(C.interval==="year"?" billed annually":" billed monthly"),e.hostingPlan="",e.hostingSaving=!1,e.selectedHostingPlan=()=>e.authorPlans().find(C=>C.id===e.hostingPlan)||e.hostingSubscriptionPlan?.();let F=()=>t.get("/api/user/quota").then(C=>{e.hostingQuota=C.data});Zi(e,t,async()=>{await F(),e.hostingQuotaBlocked=!1},{confirmedMessage:"Hosting status refreshed. Your draft is ready to continue."}),F().catch(()=>{}),e.authorPlans=()=>(e.billing?.plans||[]).filter(C=>["author_monthly","author_annual"].includes(C.id)),e.conferenceHosting=()=>!!(e.conference&&e.conference_data?.hosting),e.hasAuthorHosting=()=>["author_monthly","author_annual"].includes(e.billing?.allowance?.plan),e.hostingNeedsPayment=()=>!e.billing?.enabled||e.detectedType!=="repo"||e.hasAuthorHosting()||e.isUpdate&&e.role!=="owner"?!1:!!(e.options?.expirationMode==="never"&&!e._existingNever&&!e.repositoryGrants("repo_never").length||!e.conferenceHosting()&&e.hostingQuotaBlocked),e.repositoryGrants=C=>(e.billing?.grants||[]).filter(O=>O.planId===C&&O.scope===`repo:${e.repoId}`&&["active","paid","past_due"].includes(O.status)&&new Date(O.until).getTime()>Date.now()),e.repositoryAddonPlans=()=>(e.billing?.plans||[]).filter(C=>Xi(C.id)&&(["repo_extend","repo_pack"].includes(C.id)||!e.repositoryGrants(C.id).length)),e.hostingOneTimePlans=()=>{let C=O=>O.map(B=>(e.billing?.plans||[]).find(K=>K.id===B&&!e.repositoryGrants(B).length)).filter(Boolean);return e.options?.expirationMode==="never"&&!e._existingNever&&!e.repositoryGrants("repo_never").length?C(["repo_never"]):e.hostingQuotaBlocked&&!e.conferenceHosting()?C(["repo_slot","repo_pack"]):[]},e.hostingOneTime=()=>e.hostingOneTimePlans()[0];let j=["free","repo_slot"];e.liveUpdatesIncluded=()=>{if(!e.billing?.enabled||e.detectedType!=="repo"||e.isUpdate&&e.role!=="owner"||e.conferenceHosting()||e.hasAuthorHosting())return!0;let C=e.billing?.allowance?.plan;return C&&!j.includes(C)?!0:e.repositoryGrants("author_pass").length>0||e.repositoryGrants("repo_pack").length>0},e.liveUpdatesPrice=()=>{let C=(e.billing?.plans||[]).find(O=>O.id==="author_pass");return C?.amount!=null?e.billingAmount(C):""},e.showHostingOptions=()=>{e.mobilePane="settings",We(()=>document.getElementById("repository-hosting")?.scrollIntoView({block:"start",behavior:"smooth"}))},e.neverExpireTag=()=>{if(e.hasAuthorHosting())return"Included in your subscription";if(e.repositoryGrants("repo_never").length)return"Paid for this repository";let C=(e.billing?.plans||[]).find(O=>O.id==="repo_never");return C?.amount!=null?`${e.billingAmount(C)} once, or with a subscription`:"Subscription or one-time add-on"},e.hostingCycle="author_annual",e.hostingSubscriptionPlan=()=>e.authorPlans().find(C=>C.id===e.hostingCycle)||e.authorPlans().find(C=>C.interval==="year")||e.authorPlans()[0],e.hostingAnnualSavings=()=>{let C=e.authorPlans().find(B=>B.interval==="month")?.amount,O=e.authorPlans().find(B=>B.interval==="year")?.amount;return C&&O&&Oe.hostingOneTimePlans().concat(e.authorPlans().length?[e.hostingSubscriptionPlan()]:[]),e.hostingOptionName=C=>({repo_slot:"Add this repository",repo_pack:"Paper pack",repo_never:"Never expire",author_annual:"Author subscription",author_monthly:"Author subscription"})[C.id]||C.name,e.hostingOptionBlurb=C=>({repo_slot:"Hosted outside your free repositories. Refresh it by hand.",repo_pack:"Adds automatic updates for 180 days and keeps the link online for a year.",repo_never:"This link never expires. No subscription."})[C.id]||`${C.repositories} repositories, ${e.billingBytes(C.storage)}, automatic updates and links that never expire.`,e.hostingChoice=()=>{let C=e.hostingOneTimePlans();return C.some(O=>O.id===e.hostingPlan)||e.authorPlans().some(O=>O.id===e.hostingPlan)?e.hostingPlan:C[0]?.id||e.hostingSubscriptionPlan()?.id||""},e.checkoutRepository=async(C="")=>{if(!(e.hostingSaving||e.billingBusy||!e.billing?.csrf||e.sourceLoading)){e.hostingSaving=!0,e.billingError="";try{let O=N.checkpoint(),B=JSON.stringify(O);(!T||B!==M)&&(T=(await t.post("/api/billing/draft",{path:o.path(),values:O},{headers:{"x-csrf-token":e.billing.csrf}})).data.id,M=B);let K=e.authorPlans().find(ae=>ae.id===e.hostingPlan)||e.hostingSubscriptionPlan();if(!C&&!K)throw new Error("No author plan available");await e.checkout(C||K.id,C?e.repoId:"",{draftId:T})}catch{e.billingError="Your draft could not be saved for checkout. Your form is unchanged. Please try again."}finally{e.hostingSaving=!1}}},e.useDatedHosting=()=>{e.options.expirationMode="remove"},e.discardDraft=async()=>{N.discard(),e.workspaceOpen=!!e.sourceUrl,e.error=null,e.sourceUrl?await e.urlSelected(!0):(c++,e.sourceLoading=!1,e.detectedType=null,e.details=null,e.sourceUrlError="",Jt.cancel(),Mn.cancel(),Vn.cancel(),e.previewStatus="idle")},e.githubConnection=void 0,e.githubConnections=null,e.gistOAuthRequired=!1,e.gistAppRequired=!1;let oe=()=>{let C={};for(let O of["sourceUrl","terms","repoId","pullRequestId","gistId","source","options","conference","githubConnection"])C[O]=e[O];sessionStorage.setItem("github-access-draft",JSON.stringify({path:o.path(),savedAt:Date.now(),draft:C}))};e.connectGistApp=()=>{oe(),window.location.href="/github/app/login?returnTo="+encodeURIComponent(o.path())},e.connectGistOAuth=()=>{oe(),window.location.href="/github/login?returnTo="+encodeURIComponent(o.path())},e.grantGitHubAccess=()=>{oe();let C=o.path(),O=tt(e.sourceUrl)||"",B=e.githubConnections?.appConnected?"/github/app/install":"/github/app/login";window.location.href=B+"?returnTo="+encodeURIComponent(C)+"&repository="+encodeURIComponent(O)+"&install=1"},e.chooseGitHubConnection=async C=>{e.githubConnection=C,e.readme="",e.sourceUrl&&await qe()},e.detectedType=null,e.repoId="",e.pullRequestId="",e.gistId="",e.terms="",e.defaultTerms="",e.branches=[],e.source={branch:"",commit:""},e.options={expirationMode:"remove",expirationDate:new Date,update:!1,image:!0,pdf:!0,notebook:!0,link:!0,body:!0,title:!0,origin:!1,diff:!0,content:!0,comments:!0,username:!0,date:!0};function _(){let C=new Date;return C.setMonth(C.getMonth()+6),C}e.options.expirationDate=_();function z(C){let O=C.getFullYear(),B=String(C.getMonth()+1).padStart(2,"0"),K=String(C.getDate()).padStart(2,"0");return`${O}-${B}-${K}`}e.minExpirationDate=z(new Date);let I=()=>{let C=new Date,O=new Date(C);if(O.setFullYear(O.getFullYear()+1),e.billing?.enabled&&e.detectedType==="repo"&&!e.hasAuthorHosting()){O=new Date(C),O.setMonth(O.getMonth()+(e.billing.freeExpirationMonths||5));for(let ae of e.repositoryGrants("repo_extend"))new Date(ae.until)>O&&(O=new Date(ae.until));e.conference_data?.endDate&&new Date(e.conference_data.endDate)>O&&(O=new Date(e.conference_data.endDate)),e._savedExpirationDate&&e._savedExpirationDate>O&&(O=new Date(e._savedExpirationDate));let B=e.options?.expirationDate,K=e._savedExpirationDate&&B instanceof Date&&B.getTime()===e._savedExpirationDate.getTime();B instanceof Date&&B>O&&!K&&(e.options.expirationDate=new Date(O))}e.maxExpirationDate=z(O)};I(),e.watch(()=>[e.billing,e.repoId,e.conference_data,e.isUpdate,e._savedExpirationDate,e.options?.expirationMode,e.detectedType],I,!0,!1),e.anonymize_readme="",e.readme="",e.isUpdate=!1,e.userRepos=[],e.userReposStatus="idle",e.userRepoFilter="",e.userRepoPage=1,e.userRepoNext=null;let L=0,k,q=[0];e.on("dispose",()=>{L++,clearTimeout(k)}),e.loadUserRepos=async()=>{clearTimeout(k);let C=++L,O=e.userRepoFilter.trim();e.userReposStatus="loading",e.userRepos=[];let B=q[e.userRepoPage-1];try{for(let K=0;K<5;K++){let ae=await t.get("/api/user/repository_picker",{params:{cursor:B,q:O,connection:e.githubConnection}});if(v||C!==L)return;if(e.userRepos=ae.data.items||[],e.userRepoNext=ae.data.nextCursor??null,e.userRepos.length||e.userRepoNext===null||!O)break;B=e.userRepoNext}e.userReposStatus="ready"}catch{!v&&C===L&&(e.userReposStatus="error")}},e.changeUserRepoPage=C=>{if(e.userReposStatus!=="loading"){if(C>0&&e.userRepoNext!==null)q[e.userRepoPage]=e.userRepoNext,e.userRepoPage++;else if(C<0&&e.userRepoPage>1)e.userRepoPage--;else return;e.loadUserRepos()}},e.watch(()=>[e.userRepoFilter,e.githubConnection],()=>{i.repoId||i.pullRequestId||i.gistId||(L++,clearTimeout(k),q=[0],e.userRepoPage=1,e.userRepoNext=null,e.userRepos=[],e.userReposStatus="loading",k=setTimeout(()=>{v||e.loadUserRepos()},300))},!0,!1),e.selectUserRepo=C=>{if(C?.fullName)return e.sourceUrl="https://github.com/"+C.fullName,e.urlSelected()},e.previousConfigurations=[],e.previousConfigurationId="";let G,H=C=>String(C||"").replace(/\/$/,"").replace(/\.git$/i,"").toLowerCase();async function Y(){if(e.isUpdate||i.repoId||i.pullRequestId||i.gistId)return;let C={generation:c,url:e.sourceUrl.trim(),connection:e.githubConnection};try{G||(G=t.get("/api/user/anonymized_repositories").then(K=>K.data));let O=await G;if(!y(C))return;let B=H(tt(C.url));e.previousConfigurations=O.filter(K=>K.repoId&&K.options&&H(K.source?.fullName)===B).sort((K,ae)=>(Date.parse(ae.anonymizeDate)||0)-(Date.parse(K.anonymizeDate)||0)),e.previousConfigurationId=e.previousConfigurations[0]?.repoId||""}catch{G=void 0}}e.sourceSummary=()=>{let C=String(e.sourceUrl||""),O=/github\.com\/([^/\s]+\/[^/\s]+)\/pull\/(\d+)/i.exec(C);return O?O[1]+" \xB7 PR #"+O[2]:(O=/gist\.github\.com\/([^/\s]+)\/([0-9a-f]{8,})/i.exec(C),O?O[1]+" \xB7 gist "+(O[2].length>12?O[2].slice(0,7)+"\u2026"+O[2].slice(-4):O[2]):"")},e.sourceError="",e.sourceErrorText="";let ee={repo_access_limited:"access",repo_not_accessible:"access",repo_saml_enforcement:"access",repo_already_anonymized:"used",github_rate_limit_exceeded:"github-throttle",rate_limited:"throttle",github_unavailable:"upstream",internal_error:"server",unreachable:"server",github_app_reconnect_required:"reconnect",token_expired:"reconnect",repo_not_found:"missing",github_app_access_required:"missing",pull_request_not_found:"missing",gist_not_found:"missing"},x=C=>{let O=typeof C?.data?.error=="string"?C.data.error:"",B=C?.status===429?ee[O]==="github-throttle"?O:"rate_limited":C?.status>=500?O==="github_unavailable"?O:"internal_error":O||(C?.status===404?"repo_not_found":"unknown_error");e.sourceError=B,e.sourceErrorText="",ee[B]||r("ERRORS."+B).then(K=>{e.sourceError===B&&K!=="ERRORS."+B&&(e.sourceErrorText=K)},()=>{}),ii(B),Ee("sourceUrl","missing",!1)},fe=()=>{e.sourceError="",e.sourceErrorText=""};e.sourceReady=()=>!!e.isUpdate||!!e.details,e.sourceProblem=()=>{let C=e.anonymize?.sourceUrl?.errors||{};if(C.github||e.sourceUrlError&&e.workspaceOpen)return{kind:"github",title:"Not a GitHub URL",text:"Paste a repository, pull request, or gist URL from github.com."};if(e.sourceLoading||e.details&&!C.used)return null;if(e.gistAppRequired||e.gistOAuthRequired)return{kind:"connect",title:"Couldn't load this gist",text:"Connect GitHub to read gists."};let O=e.sourceError||(C.used?"repo_already_anonymized":C.access?"repo_not_accessible":C.missing?"repo_not_found":"");if(!O)return null;let B=ee[O]||"other",K=e.detectedType,ae="this gist";try{let Ht=parseGithubUrl(String(e.sourceUrl||"").trim());K==="pr"?ae=`pull request #${Ht.pullRequestId} in ${Ht.owner}/${Ht.repo}`:K!=="gist"&&(ae=`${Ht.owner}/${Ht.repo}`)}catch{}let ye=K==="pr"?"this pull request":K==="gist"?"this gist":"this repository",je=K!=="gist"&&e.githubConnection==="github-app",ft=e.isUpdate&&K==="repo"&&e.role==="owner"&&e.accessRepairAllowed&&e.githubConnections?.appEnabled&&je&&e.sourceUrl==="https://github.com/"+e._originalFullName?null:K==="gist"||!e.githubConnection?"link":je?"app":"link",Rt="Couldn't load "+ye;if(B==="github-throttle")return{kind:B,title:Rt,text:"GitHub's API rate limit has been reached. Wait for the limit to reset, then try again. Your repository access settings do not need to change.",retry:!0};if(B==="throttle")return{kind:B,title:Rt,text:"Too many requests. Wait a little, then try loading the source again.",retry:!0};if(B==="upstream")return{kind:B,title:Rt,text:"GitHub is temporarily unavailable. Try loading the source again in a moment.",retry:!0};if(B==="server")return{kind:B,title:Rt,text:"Anonymous GitHub could not load the source because of a server error. Try again in a moment. This does not mean the repository is missing or that you need to change its permissions.",retry:!0};if(B==="reconnect")return{kind:B,title:Rt,text:"Your GitHub authorization has expired or was revoked. Reconnect your GitHub account, then try loading the source again.",manage:"link",retry:!0};if(B==="used")return{kind:B,title:"Already anonymized",text:`You've already anonymized ${ae}. Open it from My work to change its settings.`,dashboard:!0};if(B==="access"){let Ht=O==="repo_saml_enforcement"?"Its organization requires single sign-on.":"Its organization restricts third-party apps.",pf=O==="repo_saml_enforcement"?"Authorize your GitHub session for the organization, then try again.":"An organization owner may need to approve Anonymous GitHub. You can also anonymize a personal fork.";return{kind:B,title:Rt,text:`We can't read ${ae}. ${Ht}`,note:pf,manage:ft,retry:!0}}return B==="missing"?{kind:B,title:Rt,text:`We can't read ${ae}. It doesn't exist, or ${je?"the Anonymous GitHub app hasn't been given access to it":"your GitHub account can't see it"}.`,manage:ft,retry:!0}:{kind:B,title:Rt,text:e.sourceErrorText||"GitHub didn't return it. Try again in a moment.",retry:!0}},e.submitBlockedReason=()=>e.sourceLoading?e.detectedType==="pr"?"Waiting for the pull request to load from GitHub\u2026":e.detectedType==="gist"?"Waiting for the gist to load from GitHub\u2026":"Waiting for the repository to load from GitHub\u2026":e.sourceReady()?"":e.sourceProblem()?.kind==="github"?"Enter a GitHub URL to continue.":["github-throttle","throttle","upstream","server"].includes(e.sourceProblem()?.kind)?"Wait for the source to load successfully before continuing.":e.detectedType==="pr"?"Add a pull request you can access to continue.":e.detectedType==="gist"?"Add a gist you can access to continue.":"Add a repository you can access to continue.",e.sourceIsPrivate=()=>e.details?e.detectedType==="gist"?e.details.gist?!e.details.gist.isPublic:!0:e.details.private!==!1:!1,e.previewId=()=>e.detectedType==="pr"?e.pullRequestId:e.detectedType==="gist"?e.gistId:e.repoId,e.previewPath=()=>{let C=e.previewId();return C?(e.detectedType==="pr"?"/pr/":e.detectedType==="gist"?"/gist/":"/r/")+encodeURIComponent(C)+"/":""},e.previewUrl=()=>{let C=e.previewPath();return C?"anonymous.4open.science"+C.replace(/\/$/,""):""},e.previewRedactions=()=>{let C=K=>typeof K=="string"?(K.match(ei)||[]).length:0;if(e.detectedType==="repo")return e.previewViewer.redactionCount();let O=e.detectedType==="pr"?Eo:No,B=0;return O.forEach(K=>{B+=C(K)}),B};let he=(C,O)=>C.localeCompare(O,void 0,{sensitivity:"base"}),Be=C=>C.slice(C.lastIndexOf("/")+1),He={key:null,files:[]};e.previewTreeFiles=()=>{if(!e.preserve.commit||!W)return[];let C=e.preserve.commit+"\0"+e.terms+"\0"+Co.size+"\0"+W.files.length;if(He.key===C)return He.files;let O=W.files.map(B=>{let K=e.previewPathName(B),ae=K.lastIndexOf("/");return{name:K.slice(ae+1),path:ae<0?"":K.slice(0,ae),size:0,sourcePath:B}});return He={key:C,files:O},O},e.selectPreviewPath=C=>{let O=e.previewTreeFiles().find(B=>"/"+(B.path?B.path+"/":"")+B.name===C);O&&e.openPreviewFile(O.sourcePath)},e.existingConfigurationUrl=()=>{let C=e.previousConfigurations.find(O=>O.repoId===e.previousConfigurationId);return C?"/anonymize/"+encodeURIComponent(C.repoId):null};function Qe(C){t.get("/api/user/default").then(O=>{let B=O.data;B.terms&&(e.defaultTerms=B.terms.join(`
-`)),e.options=Object.assign({},e.options,B.options),e.options.expirationDate=B.options&&B.options.expirationDate?new Date(B.options.expirationDate):_(),!i.repoId&&!i.pullRequestId&&!i.gistId&&!e.anonymize?.terms?.dirty&&(e.terms=e.defaultTerms),C&&C()})}function Ee(C,O,B){e.anonymize&&e.anonymize[C]&&e.anonymize[C].setValidity(O,B)}function tt(C){try{let O=parseGithubUrl(C);if(O&&O.owner&&O.repo)return O.owner+"/"+O.repo}catch{}return null}e.accessRepairAllowed=!1,e.repairingGitHubAccess=!1,e.accessRepairMessage="",e.repairGitHubAccess=async()=>{if(!e.accessRepairAllowed||e.repairingGitHubAccess||!e.githubConnections?.appEnabled||!i.repoId||e.role!=="owner"||e.githubConnection!=="github-app"||tt(e.sourceUrl)!==e._originalFullName)return;e.repairingGitHubAccess=!0,e.accessRepairMessage="";let C=m();try{let O=await t.get("/github/connections");if(e.githubConnections=O.data,!O.data.appEnabled)return;let B=await t.post("/github/connections/migrate",{type:"repository",id:i.repoId,connection:"github-app"},{headers:{"X-CSRF-Token":O.data.csrf}});if(!y(C))return;e.error=null,B.data.fullName&&(e._originalFullName=B.data.fullName,e.source.fullName=B.data.fullName,e.sourceUrl="https://github.com/"+B.data.fullName),e.accessRepairMessage="GitHub access repaired. Your anonymous URL and published commit are unchanged.",await e.urlSelected(!0)}catch{y(C)&&(e.accessRepairMessage="Unable to repair GitHub access. Check the App's repository permissions in Manage access, then retry. Your published snapshot has not been replaced.")}finally{e.repairingGitHubAccess=!1,b(C)}},e.reconnectingSource=!1,e.reconnectRepositoryId=void 0,e.reconnectSource=async()=>{if(confirm("Reconnect to the repository currently at this GitHub URL? Review its branch and commit before saving. Saving will replace the published snapshot.")){e.reconnectingSource=!0,e.reconnectRepositoryId=void 0,e.source.commit="",e.source.branch="",e.readme="",e.branches=[];try{await ce()}catch{}}};function Ne(){return e.reconnectingSource||!e.isUpdate||!e._originalRepositoryID?void 0:tt(e.sourceUrl)===e._originalFullName?e._originalRepositoryID:void 0}async function qe(){e._preservingDraft=!0;try{await e.urlSelected(!0)}finally{e._preservingDraft=!1}}async function X(){let C=new URLSearchParams(window.location.search).get("billingDraft");if(C){N.restore();try{let B=(await t.get("/api/billing/draft/"+encodeURIComponent(C))).data;if(B.path!==o.path())throw new Error("Wrong task");w=B.values.conference||null;for(let K of["sourceUrl","terms","repoId","source","options","conference","githubConnection"])Object.prototype.hasOwnProperty.call(B.values,K)&&(e[K]=B.values[K]);return e.options?.expirationDate&&(e.options.expirationDate=new Date(e.options.expirationDate)),T=B.id,M=JSON.stringify(N.checkpoint()),e.draftRestored=!0,e.hostingReview=!0,e.sourceUrl&&await qe(),o.replace?.(o.path()),!0}catch{e.billingError="The checkout draft could not be restored. Retry by reloading this page; any local draft is still available."}}let O;try{O=JSON.parse(sessionStorage.getItem("github-access-draft")||"null")}catch{return!1}if(!O||O.path!==o.path()||Date.now()-O.savedAt>=30*6e4)return N.restore()?(e.sourceUrl&&await qe(),!0):!1;N.restore();for(let B of["sourceUrl","terms","repoId","pullRequestId","gistId","source","options","conference","githubConnection"])Object.prototype.hasOwnProperty.call(O.draft,B)&&(e[B]=O.draft[B]);return e.options.expirationDate&&(e.options.expirationDate=new Date(e.options.expirationDate)),await qe(),sessionStorage.removeItem("github-access-draft"),!0}Qe(()=>{!i.repoId&&!i.pullRequestId&&!i.gistId&&u(X,0),i.repoId&&i.repoId!=""&&(e.isUpdate=!0,e.detectedType="repo",e.repoId=i.repoId,t.get("/api/repo/"+e.repoId).then(async C=>{e.accessRepairAllowed=!["removed","archived","preparing","queue","download","removing","expiring"].includes(C.data.status),e.githubConnection=C.data.connection||"oauth",e.sourceUrl="https://github.com/"+C.data.source.fullName,e._originalFullName=C.data.source.fullName,e.terms=C.data.options.terms.filter(O=>O).join(`
+Contact: jane.smith@mit.edu`,e.demoTerms="Jane Smith, Smith, MIT CSAIL, jane.smith@mit.edu",e.demoParts=function(){let p=(e.demoTerms||"").split(/[,\n]/).map(m=>m.trim()).filter(Boolean).sort((m,b)=>b.length-m.length),c=m=>m.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");if(!p.length)return[{text:e.demoText}];let v=new RegExp("("+p.map(c).join("|")+")","gi"),g={},y=0;return(e.demoText||"").split(v).filter(m=>m!=="").map(m=>{let b=p.find(E=>E.toLowerCase()===m.toLowerCase());return b?(g[b.toLowerCase()]||(g[b.toLowerCase()]=++y),{text:String(g[b.toLowerCase()]),redacted:!0,original:m}):{text:m}})},e.demoCount=()=>e.demoParts().filter(p=>p.redacted).length,e.cards=[{key:"repositories",total:0,label:"repositories anonymized"},{key:"users",total:0,label:"researchers"},{key:"pageViews",total:0,label:"page views"},{key:"pullRequests",total:0,label:"pull requests"}],e.statsEmpty=()=>!!e.stat&&e.cards.every(p=>!p.total);function r(){t.get("/api/stat/").then(p=>{e.stat=p.data,e.cards[0].total=p.data.nbRepositories,e.cards[1].total=p.data.nbUsers,e.cards[2].total=p.data.nbPageViews,e.cards[3].total=p.data.nbPullRequests}).catch(()=>{})}r();function u(p){let c={series:p,bars:[],viewW:100,deltaToday:0,pctChange:0,pctAbs:0,isUp:!0};if(!p||p.length<2)return c;let v=new Array(p.length-1);for(let S=1;S=2){let S=v[g-2];S&&(c.pctChange=(c.deltaToday-S)/S*100)}return c.pctAbs=Math.round(Math.abs(c.pctChange)),c.isUp=c.pctChange>=0,c}e.history={repositories:u([]),users:u([]),pageViews:u([]),pullRequests:u([])},t.get("/api/stat/history?days=60").then(p=>{let c=p.data||[];e.history={repositories:u(c.map(v=>v.nbRepositories||0)),users:u(c.map(v=>v.nbUsers||0)),pageViews:u(c.map(v=>v.nbPageViews||0)),pullRequests:u(c.map(v=>v.nbPullRequests||0))}}).catch(()=>{})},Gc=function(e,t,s,i,o,r){let u=bt();e.on("routeLeave",function(){$('[data-toggle="tooltip"]').tooltip("dispose")}),e.watch("user.status",()=>{e.user==null&&s.url("/")}),e.user==null&&s.url("/"),u.timeout(()=>{$('[data-toggle="tooltip"]').tooltip()},250),e.quotaExpanded=!1,e.closeQuota=()=>{e.quotaExpanded=!1,We(()=>document.querySelector(".dashboard-quota > summary")?.focus())},Bt()(document,"click",k=>{e.quotaExpanded&&!k.target.closest?.(".dashboard-quota")&&(e.quotaExpanded=!1)}),e.filtersExpanded=!1,e.projectView="all",e.selectedProject=null,e.projectName="",e.nameSaving=!1,e.nameError="",e.nameMessage="",e.needsAttention=k=>k.status==="error"||k._broken||c(k.status)==="progress"&&k._stale,e.attentionCount=()=>e.dashboardTotals?.attention??e.items.filter(e.needsAttention).length,e.hasProjects=()=>(e.dashboardTotals?.total??e.items.length)>0,e.setProjectView=k=>{e.projectView=k,k==="attention"&&(e.filters.status.error=!0,e.filters.status.progress=!0)},e.idleText=k=>{let q=Ca(k?.anonymizeDate||k?.lastView)||"";return/ ago$/.test(q)?"No activity for "+q.replace(/ ago$/,""):"No activity since "+q.replace(", "+new Date().getFullYear(),"")},e.projectDetailsId=k=>"project-details-"+encodeURIComponent(k._type+":"+(k._id||k._source||"unknown")),e.showProjectDetails=async k=>{e.selectedProject=k,e.projectName=k.projectName||"",e.nameError="",e.nameMessage="",await We();let q=document.getElementById(e.projectDetailsId(k));q?.focus(),q?.scrollIntoView?.({block:"nearest"})},e.closeProjectDetails=k=>{e.selectedProject=null,We(()=>document.querySelector(`[data-project-actions="${encodeURIComponent(k._type+":"+k._id)}"]`)?.focus())},e.saveProjectName=async k=>{if(e.nameSaving||!k._id)return;let q=e.projectName.trim();if(q.length>100){e.nameError="Use 100 characters or fewer.";return}e.nameSaving=!0,e.nameError="",e.nameMessage="";try{let G=await t.post("/api/user/project-name",{type:k._type,id:k._id,name:q});k.projectName=G.data.name,k._label=k.projectName||k._fallbackLabel,e.selectedProject===k&&(e.nameMessage=q?"Project name saved.":"Default project name restored."),T||(e.dashboardCursor=null,await F(),e.selectedProject===k&&(e.selectedProject=e.items.find(H=>H._type===k._type&&H._id===k._id)||null))}catch{e.selectedProject===k&&(e.nameError="The project name could not be saved. Try again.")}finally{e.nameSaving=!1}},e.copyingId=null,e.copyLink=async k=>{if(!k._viewUrl||e.copyingId)return;let q=new URL(k._viewUrl,o.location.origin).href;e.copyingId=k._type+":"+k._id;try{await Qa(q),e.addToast({title:"Link copied",body:"The anonymous link is ready to share."})}catch{e.addToast({title:"Copy this anonymous link",body:q})}finally{e.copyingId=null}},e.items=[],e.search="",e.loading=!0,e.statusKeyLabels={ready:"Ready",progress:"Preparing",error:"Error",expired:"Expiring / expired",removed:"Removing / removed"};let p=["queue","download","downloaded","preparing","anonymizing"];function c(k){return k==="ready"||k==="error"?k:k==="expired"||k==="expiring"?"expired":k==="removed"||k==="removing"?"removed":(p.indexOf(k)>-1,"progress")}let v=7200*1e3,g="dashboard.filterPrefs",y={typeFilter:"all",filters:{status:{ready:!0,progress:!0,error:!0,expired:!0,removed:!1}},orderBy:"-anonymizeDate"},m=loadFilterPrefs(g)||{};e.typeFilter=m.typeFilter||y.typeFilter,e.filters={status:Object.assign({},y.filters.status,m.filters&&m.filters.status||{})},e.orderBy=m.orderBy||y.orderBy;let b={_name:{label:"Anonymous ID",defaultDesc:!1},_label:{label:"Project",defaultDesc:!1},anonymizeDate:{label:"Anonymize date",defaultDesc:!0},status:{label:"Status",defaultDesc:!1},lastView:{label:"Last view",defaultDesc:!0},pageView:{label:"Views",defaultDesc:!0},"options.expirationDate":{label:"Expiration",defaultDesc:!1}};e.sortFields=b,e.sortField=()=>e.orderBy.replace(/^-/,""),e.sortDesc=()=>e.orderBy.charAt(0)==="-",e.sortLabel=()=>{let k=b[e.sortField()];return k?k.label:"Custom"},e.isSortedBy=k=>e.sortField()===k,e.setSort=(k,q)=>{typeof q!="boolean"&&(q=e.isSortedBy(k)?!e.sortDesc():!!(b[k]&&b[k].defaultDesc)),e.orderBy=(q?"-":"")+k},e.toggleSortDirection=()=>{e.setSort(e.sortField(),!e.sortDesc())},e.watchGroup(["typeFilter","orderBy"],()=>{saveFilterPrefs(g,{typeFilter:e.typeFilter,filters:e.filters,orderBy:e.orderBy})}),e.watch("filters",()=>{saveFilterPrefs(g,{typeFilter:e.typeFilter,filters:e.filters,orderBy:e.orderBy})},!0),r.load().then(k=>{e.quota=k},console.error);function E(k,q,G,H,Y,ee){k.pageView||(k.pageView=0),k.lastView||(k.lastView=""),k.options=k.options||{},k.options.terms=(k.options.terms||[]).filter(fe=>fe),k._id=q||"",k._source=H,k._broken=!q,k._name=q||H||"(unnamed)",k._fallbackLabel=k._type==="gist"?"Gist "+(q||H||"without an ID"):H||G||k._name,k._label=k.projectName||k._fallbackLabel,k._editUrl=q?Y:null,k._viewUrl=q?ee:null,k._broken&&(k.status="error",k.statusMessage="incomplete_record"),k._statusKey=c(k.status);let x=k.anonymizeDate||k.lastView;if(k._stale=k._statusKey==="progress"&&!!x&&Date.now()-new Date(x).getTime()>v,k.status==="expired"||k.status==="expiring")k._expiry={kind:"expired",date:k.options.expirationDate},k._expiry.label=Ea(k.options.expirationDate)||void 0;else if(k.status!=="ready")k._expiry={kind:"none"};else if(k.options.expirationMode==="never"||!k.options.expirationDate)k._expiry={kind:"never"};else{k._expiry={kind:"date",date:k.options.expirationDate};let fe=new Date(k.options.expirationDate).getTime()-Date.now();if(fe>0&&fe<=168*3600*1e3){let he=Math.max(1,Math.round(fe/36e5)),Be=Math.round(fe/864e5);k._expiry.soon=he<48?"in "+he+(he===1?" hour":" hours"):"in "+Be+" days"}}return k}function S(k){return t.get(k).then(q=>q.data||[],q=>(console.error(q),[]))}function N(){return e.loading=!0,i.all([S("/api/user/anonymized_repositories"),S("/api/user/anonymized_pull_requests"),S("/api/user/anonymized_gists")]).then(k=>{let q=k[0],G=k[1],H=k[2],Y=[];q.forEach(ee=>{ee._type="repo";let x=ee.source||{};Y.push(E(ee,ee.repoId,ee.repoId,x.fullName,"/anonymize/"+ee.repoId,"/r/"+ee.repoId+"/"))}),G.forEach(ee=>{ee._type="pr";let x=ee.source||{};Y.push(E(ee,ee.pullRequestId,ee.pullRequestId,x.repositoryFullName?x.repositoryFullName+"#"+x.pullRequestId:void 0,"/pull-request-anonymize/"+ee.pullRequestId,"/pr/"+ee.pullRequestId+"/"))}),H.forEach(ee=>{ee._type="gist";let x=ee.source||{};Y.push(E(ee,ee.gistId,ee.gistId,x.gistId,"/gist-anonymize/"+ee.gistId,"/gist/"+ee.gistId+"/"))}),e.items=Y,e.removedCount=Y.filter(ee=>ee._statusKey==="removed").length,e.loading=!1})}let w=0,T=!1;e.dashboardCursor=null,e.dashboardError="";function M(k){let q=k.source||{};return k._type==="repo"?E(k,k.repoId,k.repoId,q.fullName,"/anonymize/"+k.repoId,"/r/"+k.repoId+"/"):k._type==="pr"?E(k,k.pullRequestId,k.pullRequestId,q.repositoryFullName?q.repositoryFullName+"#"+q.pullRequestId:void 0,"/pull-request-anonymize/"+k.pullRequestId,"/pr/"+k.pullRequestId+"/"):E(k,k.gistId,k.gistId,q.gistId,"/gist-anonymize/"+k.gistId,"/gist/"+k.gistId+"/")}function F(k=!1){if(T)return N();let q=++w;return e.loading=!k,e.loadingMore=k,e.dashboardError="",t.get("/api/user/dashboard",{params:{q:e.search,type:e.typeFilter,sort:e.orderBy,statuses:Object.keys(e.filters.status).filter(G=>e.filters.status[G]!==!1).join(",")||"none",attention:String(e.projectView==="attention"),cursor:k?e.dashboardCursor:void 0}}).then(G=>{if(q===w){if(!Array.isArray(G.data?.items))return T=!0,N();e.items=(k?e.items:[]).concat(G.data.items.map(M)),e.dashboardCursor=G.data.cursor,e.dashboardTotals=G.data,k||_()}},G=>{if(q===w){if(G.status===404)return T=!0,N();e.dashboardError="Projects could not be loaded. Please try again."}}).finally(()=>{q===w&&(e.loading=!1,e.loadingMore=!1)})}e.loadMoreProjects=()=>F(!0);let j;e.watchGroup(["search","typeFilter","orderBy","projectView"],()=>{T||(j&&u.timeout.cancel(j),j=u.timeout(()=>F(),150))},!1),e.watch("filters",()=>{T||F()},!0,!1),e.on("dispose",()=>{w++}),F(),e.openItem=(k,q)=>{if(!k._viewUrl)return;let G=q&&q.target;G&&G.closest&&G.closest("a, button, .dropdown, input")||(o.location.href=k._viewUrl)},e.hiddenStatusCount=()=>Object.keys(e.filters.status).filter(k=>e.filters.status[k]===!1).length,e.hasHiddenStatus=()=>e.hiddenStatusCount()>0;let oe=()=>Object.keys(e.statusKeyLabels);e.onlyRemovedShown=()=>oe().every(k=>k==="removed"==(e.filters.status[k]!==!1)),e.isActiveDefault=()=>oe().every(k=>k==="removed"==(e.filters.status[k]===!1)),e.statusView=()=>e.projectView==="attention"?"attention":e.onlyRemovedShown()?"removed":e.filters.status.removed===!1?"active":"custom",e.setStatusView=k=>{if(k==="attention")return e.setProjectView("attention");e.projectView="all",oe().forEach(q=>{e.filters.status[q]=k==="removed"?q==="removed":q!=="removed"})},e.statusChipKeys=()=>{let k=e.statusView();return k==="removed"?[]:oe().filter(q=>e.filters.status[q]===!1&&!(q==="removed"&&k!=="custom"))},e.removedCount=null;function _(){if(T){e.removedCount=e.items.filter(q=>q._statusKey==="removed").length;return}let k=e.dashboardTotals;!k||e.projectView!=="all"||e.search.trim()||e.typeFilter!=="all"||(e.isActiveDefault()?e.removedCount=Math.max(0,k.total-k.filtered):e.onlyRemovedShown()&&(e.removedCount=k.filtered))}e.showViewTabs=()=>e.statusView()!=="active"||e.attentionCount()>0||e.removedCount>0||e.removedCount==null&&!!e.dashboardTotals&&e.dashboardTotals.total>e.dashboardTotals.filtered,e.hasActiveFilters=()=>e.projectView!=="all"||e.typeFilter!=="all"||e.search.trim().length>0||Object.keys(e.filters.status).some(k=>e.filters.status[k]===!1),e.showClearFilters=()=>e.search.trim().length>0||e.typeFilter!=="all"||e.statusChipKeys().length>0,e.isPlainView=()=>!e.showClearFilters(),e.clearFilters=()=>{let k=e.statusView();e.typeFilter="all",e.search="",e.setStatusView(k==="removed"?"removed":"active")};function z(k,q,G,H){t.get("/api/repo/"+k).then(async Y=>{let ee=H!==void 0&&H!==Y.data.status;for(let x of e.items)if(x._type==="repo"&&x.repoId==k){ee=ee||x.status!==Y.data.status;let fe=e.needsAttention(x);x.status=Y.data.status,x.statusMessage=Y.data.statusMessage,x._statusKey=c(x.status),x._statusKey!=="progress"&&(x._stale=!1);let he=e.needsAttention(x);e.dashboardTotals&&fe!==he&&(e.dashboardTotals.attention=Math.max(0,e.dashboardTotals.attention+(he?1:-1)));break}if(ee&&!T){e.dashboardCursor=null;let x=e.selectedProject;await F(),x&&e.selectedProject===x&&(e.selectedProject=e.items.find(fe=>fe._type===x._type&&fe._id===x._id)||null)}if(Y.data.status=="ready"||Y.data.status=="error"||Y.data.status=="removed"||Y.data.status=="expired"){q(Y.data);return}u.timeout(()=>z(k,q,G,Y.data.status),2500)},G)}let I=k=>k==="repo"?"repository":k==="gist"?"gist":"pull request",L=k=>k==="repo"?"/api/repo":k==="gist"?"/api/gist":"/api/pr";e.removeItem=k=>{let q=I(k._type);if(confirm(`Are you sure that you want to remove the ${q} ${k._id}?`)){let G=at({title:`Removing ${k._id}...`,date:new Date,body:`The ${q} ${k._id} is going to be removed.`});e.addToast(G);let H=`${L(k._type)}/${k._id}`;t.delete(H).then(()=>{k._type==="repo"?z(k._id,()=>{G.title=`${k._id} is removed.`,G.body=`The ${q} ${k._id} is removed.`},void 0,k.status):(G.title=`${k._id} is removed.`,G.body=`The ${q} ${k._id} is removed.`,F())},Y=>{G.title=`Error during the removal of ${k._id}.`,G.body=Y.body,F()})}},e.refreshItem=k=>{let q=I(k._type),G=at({title:`Refreshing ${k._id}...`,date:new Date,body:`The ${q} ${k._id} is going to be refreshed.`});e.addToast(G);let H=ee=>{G.title=`Error during the refresh of ${k._id}.`,G.body=ee.data?.error||ee.body||"The refresh could not be completed. Please try again.",F()},Y=`${L(k._type)}/${k._id}/refresh`;t.post(Y).then(()=>{k._type==="repo"?z(k._id,ee=>{if(ee.status!=="ready"){H({body:ee.statusMessage||`The repository is ${ee.status}.`});return}G.title=`${k._id} is refreshed.`,G.body=`The ${q} ${k._id} is refreshed.`},H,k.status):(G.title=`${k._id} is refreshed.`,G.body=`The ${q} ${k._id} is refreshed.`,F())},H)},e.extendItem=k=>{let q=I(k._type),G=at({title:`Extending ${k._id}...`,date:new Date,body:`The expiration of ${q} ${k._id} is being extended.`});e.addToast(G);let H=`${L(k._type)}/${k._id}/extend`;t.post(H).then(Y=>{let ee=Y?.data?.expirationDate?` until ${new Date(Y.data.expirationDate).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})}`:"";k._type==="repo"?z(k._id,()=>{G.title=`${k._id} is extended.`,G.body=`${q} ${k._id} is extended${ee}.`},void 0,k.status):(G.title=`${k._id} is extended.`,G.body=`${q} ${k._id} is extended${ee}.`,F())},Y=>{G.title=`Error during the extension of ${k._id}.`;let ee=Y.data&&Y.data.error;G.body=ee||Y.body,ee&&Object.prototype.hasOwnProperty.call(Xn.ERRORS,ee)&&(G.body=Xn.ERRORS[ee]),F()})},e.itemFilter=k=>{if(e.projectView==="attention"&&!e.needsAttention(k)||e.typeFilter!=="all"&&k._type!==e.typeFilter||e.filters.status[k._statusKey]===!1)return!1;let q=e.search.trim().toLowerCase();return!!(q.length==0||k._label&&String(k._label).toLowerCase().indexOf(q)>-1||k._source&&String(k._source).toLowerCase().indexOf(q)>-1||k._id&&String(k._id).toLowerCase().indexOf(q)>-1||k.conference&&String(k.conference).toLowerCase().indexOf(q)>-1)}};var Wc=function(e,t,s){let i=bt();e.repoId=s.repoId,e.reviewUrl=window.location.origin+"/r/"+encodeURIComponent(s.repoId)+"/",e.repo=null,e.progress=0,e.rateLimitResetAt=0,e.rateLimitCountdown="",e.shareUrl=(window.location?.origin||"")+"/r/"+encodeURIComponent(e.repoId)+"/",e.copied=!1;let o=null;e.copyShareUrl=async()=>{try{await Qa(e.shareUrl),e.copied=!0,o&&i.timeout.cancel(o),o=i.timeout(()=>{e.copied=!1},2e3)}catch{e.addToast?.({title:"Copy this anonymous link",body:e.shareUrl})}},e.selectShareUrl=g=>{let y=window.getSelection?.();if(!y||!g?.target)return;let m=document.createRange();m.selectNodeContents(g.target),y.removeAllRanges(),y.addRange(m)};var r=null;let u=null,p=!1;function c(g){e.rateLimitResetAt=g,r&&i.interval.cancel(r);function y(){var m=Math.max(0,Math.ceil((g-Date.now())/1e3));if(m<=0)e.rateLimitCountdown="",e.rateLimitResetAt=0,i.interval.cancel(r),r=null;else{var b=Math.floor(m/60),E=m%60;e.rateLimitCountdown=b>0?b+"m "+E+"s":E+"s"}}y(),r=i.interval(y,1e3)}e.on("dispose",function(){p=!0,r&&i.interval.cancel(r),u&&i.timeout.cancel(u)});function v(g){if(!g)return g;var y=g.match(/^rate_limited:(\d+)$/);return y?(c(parseInt(y[1],10)),null):(e.rateLimitResetAt=0,g)}e.getStatus=()=>{p||t.get("/api/repo/"+e.repoId,{repoId:e.repoId,repoUrl:e.repoUrl}).then(g=>{if(!p){e.repo=g.data,g.data.rateLimitResetAt?c(g.data.rateLimitResetAt):e.repo.statusMessage=v(e.repo.statusMessage),e.repo.status=="ready"?e.progress=100:e.repo.status=="queue"?e.progress=10:e.repo.status=="downloaded"?e.progress=50:e.repo.status=="download"||e.repo.status=="preparing"?e.progress=25:e.repo.status=="anonymizing"&&(e.progress=75);var y=!["ready","removed","expired"].includes(e.repo.status);e.repo.status=="error"&&!e.rateLimitResetAt&&(y=!1),y&&(u=i.timeout(e.getStatus,2e3))}},g=>{e.error=g.data.error})},e.getStatus()},mr=function(e,t,s,i,o,r,u){_c(),e.renderRedacted=_s,e.sourceUrl="",e.workspaceOpen=!1,e.sourceUrlError="",e.previewStatus="idle",e.sourceLoading=!1,e.mobilePane="settings";let p=window.matchMedia?.("(max-width: 767px)");e.mobileWorkspace=!!p?.matches,p?.addEventListener&&Bt()(p,"change",C=>{e.mobileWorkspace=C.matches}),e.selectMobilePane=C=>{e.mobilePane=C};let c=0,v=!1,g=new Set,y=(C,O=!1)=>!v&&C.generation===c&&C.url===e.sourceUrl.trim()&&C.connection===e.githubConnection&&(!O||C.branch===e.source.branch),m=()=>{let C={generation:c,url:e.sourceUrl.trim(),connection:e.githubConnection,branch:e.source.branch};return g.add(C),e.sourceLoading=!0,C},b=C=>{g.delete(C),v||(e.sourceLoading=[...g].some(O=>y(O)))};e.on("dispose",()=>{v=!0,c++});let E=null,S=C=>C.gistId&&!C.repo?"gist:"+C.gistId.toLowerCase():(C.owner+"/"+C.repo).toLowerCase()+(C.pullRequestId?"/pull/"+C.pullRequestId:""),N=ka(e,["sourceUrl","terms","repoId","pullRequestId","gistId","source","options","conference","githubConnection"],"anonymize:"+(o.path?.()||"")),w=null,T=null,M=null;e.hostingReview=!1,e.previewExpanded=!1,e.taskValidationError="",e.editRepository=()=>{e.mobilePane="settings",e.previewExpanded=!1,We(()=>document.querySelector(".anonymize-fields .is-invalid")?.focus())},e.submitRepository=C=>{if(e.taskValidationError="",!(e.sourceLoading||e.billingBusy||e.hostingSaving||e.billingPending)){if(si()||e.anonymize?.invalid||e.sourceUrlError){e.taskValidationError="Check the highlighted fields before continuing.",e.editRepository();return}return e.hostingNeedsPayment()?e.checkoutRepository(Xi(e.hostingChoice())?e.hostingChoice():""):e.anonymizeRepo(C)}},e.hostingPayment=!1,e.hostingAlternatives=!1,e.hostingPrice=C=>C.amount==null?"Price shown at checkout":new Intl.NumberFormat(void 0,{style:"currency",currency:C.currency,minimumFractionDigits:0,maximumFractionDigits:2}).format(C.amount/100)+(C.interval==="year"?" billed annually":" billed monthly"),e.hostingPlan="",e.hostingSaving=!1,e.selectedHostingPlan=()=>e.authorPlans().find(C=>C.id===e.hostingPlan)||e.hostingSubscriptionPlan?.();let F=()=>t.get("/api/user/quota").then(C=>{e.hostingQuota=C.data});Zi(e,t,async()=>{await F(),e.hostingQuotaBlocked=!1},{confirmedMessage:"Hosting status refreshed. Your draft is ready to continue."}),F().catch(()=>{}),e.authorPlans=()=>(e.billing?.plans||[]).filter(C=>["author_monthly","author_annual"].includes(C.id)),e.conferenceHosting=()=>!!(e.conference&&e.conference_data?.hosting),e.hasAuthorHosting=()=>["author_monthly","author_annual"].includes(e.billing?.allowance?.plan),e.hostingNeedsPayment=()=>!e.billing?.enabled||e.detectedType!=="repo"||e.hasAuthorHosting()||e.isUpdate&&e.role!=="owner"?!1:!!(e.options?.expirationMode==="never"&&!e._existingNever&&!e.repositoryGrants("repo_never").length||!e.conferenceHosting()&&e.hostingQuotaBlocked),e.repositoryGrants=C=>(e.billing?.grants||[]).filter(O=>O.planId===C&&O.scope===`repo:${e.repoId}`&&["active","paid","past_due"].includes(O.status)&&new Date(O.until).getTime()>Date.now()),e.repositoryAddonPlans=()=>(e.billing?.plans||[]).filter(C=>Xi(C.id)&&(["repo_extend","repo_pack"].includes(C.id)||!e.repositoryGrants(C.id).length)),e.hostingOneTimePlans=()=>{let C=O=>O.map(B=>(e.billing?.plans||[]).find(K=>K.id===B&&!e.repositoryGrants(B).length)).filter(Boolean);return e.options?.expirationMode==="never"&&!e._existingNever&&!e.repositoryGrants("repo_never").length?C(["repo_never"]):e.hostingQuotaBlocked&&!e.conferenceHosting()?C(["repo_slot","repo_pack"]):[]},e.hostingOneTime=()=>e.hostingOneTimePlans()[0];let j=["free","repo_slot"];e.liveUpdatesIncluded=()=>{if(!e.billing?.enabled||e.detectedType!=="repo"||e.isUpdate&&e.role!=="owner"||e.conferenceHosting()||e.hasAuthorHosting())return!0;let C=e.billing?.allowance?.plan;return C&&!j.includes(C)?!0:e.repositoryGrants("author_pass").length>0||e.repositoryGrants("repo_pack").length>0},e.liveUpdatesPrice=()=>{let C=(e.billing?.plans||[]).find(O=>O.id==="author_pass");return C?.amount!=null?e.billingAmount(C):""},e.showHostingOptions=()=>{e.mobilePane="settings",We(()=>document.getElementById("repository-hosting")?.scrollIntoView({block:"start",behavior:"smooth"}))},e.neverExpireTag=()=>{if(e.hasAuthorHosting())return"Included in your subscription";if(e.repositoryGrants("repo_never").length)return"Paid for this repository";let C=(e.billing?.plans||[]).find(O=>O.id==="repo_never");return C?.amount!=null?`${e.billingAmount(C)} once, or with a subscription`:"Subscription or one-time add-on"},e.hostingCycle="author_annual",e.hostingSubscriptionPlan=()=>e.authorPlans().find(C=>C.id===e.hostingCycle)||e.authorPlans().find(C=>C.interval==="year")||e.authorPlans()[0],e.hostingAnnualSavings=()=>{let C=e.authorPlans().find(B=>B.interval==="month")?.amount,O=e.authorPlans().find(B=>B.interval==="year")?.amount;return C&&O&&Oe.hostingOneTimePlans().concat(e.authorPlans().length?[e.hostingSubscriptionPlan()]:[]),e.hostingOptionName=C=>({repo_slot:"Add this repository",repo_pack:"Paper pack",repo_never:"Never expire",author_annual:"Author subscription",author_monthly:"Author subscription"})[C.id]||C.name,e.hostingOptionBlurb=C=>({repo_slot:"Hosted outside your free repositories. Refresh it by hand.",repo_pack:"Adds automatic updates for 180 days and keeps the link online for a year.",repo_never:"This link never expires. No subscription."})[C.id]||`${C.repositories} repositories, ${e.billingBytes(C.storage)}, automatic updates and links that never expire.`,e.hostingChoice=()=>{let C=e.hostingOneTimePlans();return C.some(O=>O.id===e.hostingPlan)||e.authorPlans().some(O=>O.id===e.hostingPlan)?e.hostingPlan:C[0]?.id||e.hostingSubscriptionPlan()?.id||""},e.checkoutRepository=async(C="")=>{if(!(e.hostingSaving||e.billingBusy||!e.billing?.csrf||e.sourceLoading)){e.hostingSaving=!0,e.billingError="";try{let O=N.checkpoint(),B=JSON.stringify(O);(!T||B!==M)&&(T=(await t.post("/api/billing/draft",{path:o.path(),values:O},{headers:{"x-csrf-token":e.billing.csrf}})).data.id,M=B);let K=e.authorPlans().find(ae=>ae.id===e.hostingPlan)||e.hostingSubscriptionPlan();if(!C&&!K)throw new Error("No author plan available");await e.checkout(C||K.id,C?e.repoId:"",{draftId:T})}catch{e.billingError="Your draft could not be saved for checkout. Your form is unchanged. Please try again."}finally{e.hostingSaving=!1}}},e.useDatedHosting=()=>{e.options.expirationMode="remove"},e.discardDraft=async()=>{N.discard(),e.workspaceOpen=!!e.sourceUrl,e.error=null,e.sourceUrl?await e.urlSelected(!0):(c++,e.sourceLoading=!1,e.detectedType=null,e.details=null,e.sourceUrlError="",Jt.cancel(),Mn.cancel(),Vn.cancel(),e.previewStatus="idle")},e.githubConnection=void 0,e.githubConnections=null,e.gistOAuthRequired=!1,e.gistAppRequired=!1;let oe=()=>{let C={};for(let O of["sourceUrl","terms","repoId","pullRequestId","gistId","source","options","conference","githubConnection"])C[O]=e[O];sessionStorage.setItem("github-access-draft",JSON.stringify({path:o.path(),savedAt:Date.now(),draft:C}))};e.connectGistApp=()=>{oe(),window.location.href="/github/app/login?returnTo="+encodeURIComponent(o.path())},e.connectGistOAuth=()=>{oe(),window.location.href="/github/login?returnTo="+encodeURIComponent(o.path())},e.grantGitHubAccess=()=>{oe();let C=o.path(),O=tt(e.sourceUrl)||"",B=e.githubConnections?.appConnected?"/github/app/install":"/github/app/login";window.location.href=B+"?returnTo="+encodeURIComponent(C)+"&repository="+encodeURIComponent(O)+"&install=1"},e.chooseGitHubConnection=async C=>{e.githubConnection=C,e.readme="",e.sourceUrl&&await qe()},e.detectedType=null,e.repoId="",e.pullRequestId="",e.gistId="",e.terms="",e.defaultTerms="",e.branches=[],e.source={branch:"",commit:""},e.options={expirationMode:"remove",expirationDate:new Date,update:!1,image:!0,pdf:!0,notebook:!0,link:!0,body:!0,title:!0,origin:!1,diff:!0,content:!0,comments:!0,username:!0,date:!0};function _(){let C=new Date;return C.setMonth(C.getMonth()+6),C}e.options.expirationDate=_();function z(C){let O=C.getFullYear(),B=String(C.getMonth()+1).padStart(2,"0"),K=String(C.getDate()).padStart(2,"0");return`${O}-${B}-${K}`}e.minExpirationDate=z(new Date);let I=()=>{let C=new Date,O=new Date(C);if(O.setFullYear(O.getFullYear()+1),e.billing?.enabled&&e.detectedType==="repo"&&!e.hasAuthorHosting()){O=new Date(C),O.setMonth(O.getMonth()+(e.billing.freeExpirationMonths||5));for(let ae of e.repositoryGrants("repo_extend"))new Date(ae.until)>O&&(O=new Date(ae.until));e.conference_data?.endDate&&new Date(e.conference_data.endDate)>O&&(O=new Date(e.conference_data.endDate)),e._savedExpirationDate&&e._savedExpirationDate>O&&(O=new Date(e._savedExpirationDate));let B=e.options?.expirationDate,K=e._savedExpirationDate&&B instanceof Date&&B.getTime()===e._savedExpirationDate.getTime();B instanceof Date&&B>O&&!K&&(e.options.expirationDate=new Date(O))}e.maxExpirationDate=z(O)};I(),e.watch(()=>[e.billing,e.repoId,e.conference_data,e.isUpdate,e._savedExpirationDate,e.options?.expirationMode,e.detectedType],I,!0,!1),e.anonymize_readme="",e.readme="",e.isUpdate=!1,e.userRepos=[],e.userReposStatus="idle",e.userRepoFilter="",e.userRepoPage=1,e.userRepoNext=null;let L=0,k,q=[0];e.on("dispose",()=>{L++,clearTimeout(k)}),e.loadUserRepos=async()=>{clearTimeout(k);let C=++L,O=e.userRepoFilter.trim();e.userReposStatus="loading",e.userRepos=[];let B=q[e.userRepoPage-1];try{for(let K=0;K<5;K++){let ae=await t.get("/api/user/repository_picker",{params:{cursor:B,q:O,connection:e.githubConnection}});if(v||C!==L)return;if(e.userRepos=ae.data.items||[],e.userRepoNext=ae.data.nextCursor??null,e.userRepos.length||e.userRepoNext===null||!O)break;B=e.userRepoNext}e.userReposStatus="ready"}catch{!v&&C===L&&(e.userReposStatus="error")}},e.changeUserRepoPage=C=>{if(e.userReposStatus!=="loading"){if(C>0&&e.userRepoNext!==null)q[e.userRepoPage]=e.userRepoNext,e.userRepoPage++;else if(C<0&&e.userRepoPage>1)e.userRepoPage--;else return;e.loadUserRepos()}},e.watch(()=>[e.userRepoFilter,e.githubConnection],()=>{i.repoId||i.pullRequestId||i.gistId||(L++,clearTimeout(k),q=[0],e.userRepoPage=1,e.userRepoNext=null,e.userRepos=[],e.userReposStatus="loading",k=setTimeout(()=>{v||e.loadUserRepos()},300))},!0,!1),e.selectUserRepo=C=>{if(C?.fullName)return e.sourceUrl="https://github.com/"+C.fullName,e.urlSelected()},e.previousConfigurations=[],e.previousConfigurationId="";let G,H=C=>String(C||"").replace(/\/$/,"").replace(/\.git$/i,"").toLowerCase();async function Y(){if(e.isUpdate||i.repoId||i.pullRequestId||i.gistId)return;let C={generation:c,url:e.sourceUrl.trim(),connection:e.githubConnection};try{G||(G=t.get("/api/user/anonymized_repositories").then(K=>K.data));let O=await G;if(!y(C))return;let B=H(tt(C.url));e.previousConfigurations=O.filter(K=>K.repoId&&K.options&&H(K.source?.fullName)===B).sort((K,ae)=>(Date.parse(ae.anonymizeDate)||0)-(Date.parse(K.anonymizeDate)||0)),e.previousConfigurationId=e.previousConfigurations[0]?.repoId||""}catch{G=void 0}}e.sourceSummary=()=>{let C=String(e.sourceUrl||""),O=/github\.com\/([^/\s]+\/[^/\s]+)\/pull\/(\d+)/i.exec(C);return O?O[1]+" \xB7 PR #"+O[2]:(O=/gist\.github\.com\/([^/\s]+)\/([0-9a-f]{8,})/i.exec(C),O?O[1]+" \xB7 gist "+(O[2].length>12?O[2].slice(0,7)+"\u2026"+O[2].slice(-4):O[2]):"")},e.sourceError="",e.sourceErrorText="";let ee={repo_access_limited:"access",repo_not_accessible:"access",repo_saml_enforcement:"access",repo_already_anonymized:"used",github_rate_limit_exceeded:"github-throttle",rate_limited:"throttle",github_unavailable:"upstream",internal_error:"server",unreachable:"server",github_app_reconnect_required:"reconnect",token_expired:"reconnect",repo_not_found:"missing",github_app_access_required:"missing",pull_request_not_found:"missing",gist_not_found:"missing"},x=C=>{let O=typeof C?.data?.error=="string"?C.data.error:"",B=C?.status===429?ee[O]==="github-throttle"?O:"rate_limited":C?.status>=500?O==="github_unavailable"?O:"internal_error":O||(C?.status===404?"repo_not_found":"unknown_error");e.sourceError=B,e.sourceErrorText="",ee[B]||r("ERRORS."+B).then(K=>{e.sourceError===B&&K!=="ERRORS."+B&&(e.sourceErrorText=K)},()=>{}),ii(B),Ee("sourceUrl","missing",!1)},fe=()=>{e.sourceError="",e.sourceErrorText=""};e.sourceReady=()=>!!e.isUpdate||!!e.details,e.sourceProblem=()=>{let C=e.anonymize?.sourceUrl?.errors||{};if(C.github||e.sourceUrlError&&e.workspaceOpen)return{kind:"github",title:"Not a GitHub URL",text:"Paste a repository, pull request, or gist URL from github.com."};if(e.sourceLoading||e.details&&!C.used&&!e.sourceError)return null;if(e.gistAppRequired||e.gistOAuthRequired)return{kind:"connect",title:"Couldn't load this gist",text:"Connect GitHub to read gists."};let O=e.sourceError||(C.used?"repo_already_anonymized":C.access?"repo_not_accessible":C.missing?"repo_not_found":"");if(!O)return null;let B=ee[O]||"other",K=e.detectedType,ae="this gist";try{let Ht=parseGithubUrl(String(e.sourceUrl||"").trim());K==="pr"?ae=`pull request #${Ht.pullRequestId} in ${Ht.owner}/${Ht.repo}`:K!=="gist"&&(ae=`${Ht.owner}/${Ht.repo}`)}catch{}let ye=K==="pr"?"this pull request":K==="gist"?"this gist":"this repository",je=K!=="gist"&&e.githubConnection==="github-app",ft=e.isUpdate&&K==="repo"&&e.role==="owner"&&e.accessRepairAllowed&&e.githubConnections?.appEnabled&&je&&e.sourceUrl==="https://github.com/"+e._originalFullName?null:K==="gist"||!e.githubConnection?"link":je?"app":"link",Rt="Couldn't load "+ye;if(B==="github-throttle")return{kind:B,title:Rt,text:"GitHub's API rate limit has been reached. Wait for the limit to reset, then try again. Your repository access settings do not need to change.",retry:!0};if(B==="throttle")return{kind:B,title:Rt,text:"Too many requests. Wait a little, then try loading the source again.",retry:!0};if(B==="upstream")return{kind:B,title:Rt,text:"GitHub is temporarily unavailable. Try loading the source again in a moment.",retry:!0};if(B==="server")return{kind:B,title:Rt,text:"Anonymous GitHub could not load the source because of a server error. Try again in a moment. This does not mean the repository is missing or that you need to change its permissions.",retry:!0};if(B==="reconnect")return{kind:B,title:Rt,text:"Your GitHub authorization has expired or was revoked. Reconnect your GitHub account, then try loading the source again.",manage:"link",retry:!0};if(B==="used")return{kind:B,title:"Already anonymized",text:`You've already anonymized ${ae}. Open it from My work to change its settings.`,dashboard:!0};if(B==="access"){let Ht=O==="repo_saml_enforcement"?"Its organization requires single sign-on.":"Its organization restricts third-party apps.",pf=O==="repo_saml_enforcement"?"Authorize your GitHub session for the organization, then try again.":"An organization owner may need to approve Anonymous GitHub. You can also anonymize a personal fork.";return{kind:B,title:Rt,text:`We can't read ${ae}. ${Ht}`,note:pf,manage:ft,retry:!0}}return B==="missing"?{kind:B,title:Rt,text:`We can't read ${ae}. It doesn't exist, or ${je?"the Anonymous GitHub app hasn't been given access to it":"your GitHub account can't see it"}.`,manage:ft,retry:!0}:{kind:B,title:Rt,text:e.sourceErrorText||"GitHub didn't return it. Try again in a moment.",retry:!0}},e.submitBlockedReason=()=>e.sourceLoading?e.detectedType==="pr"?"Waiting for the pull request to load from GitHub\u2026":e.detectedType==="gist"?"Waiting for the gist to load from GitHub\u2026":"Waiting for the repository to load from GitHub\u2026":e.sourceReady()?"":e.sourceProblem()?.kind==="github"?"Enter a GitHub URL to continue.":["github-throttle","throttle","upstream","server"].includes(e.sourceProblem()?.kind)?"Wait for the source to load successfully before continuing.":e.detectedType==="pr"?"Add a pull request you can access to continue.":e.detectedType==="gist"?"Add a gist you can access to continue.":"Add a repository you can access to continue.",e.sourceIsPrivate=()=>e.details?e.detectedType==="gist"?e.details.gist?!e.details.gist.isPublic:!0:e.details.private!==!1:!1,e.previewId=()=>e.detectedType==="pr"?e.pullRequestId:e.detectedType==="gist"?e.gistId:e.repoId,e.previewPath=()=>{let C=e.previewId();return C?(e.detectedType==="pr"?"/pr/":e.detectedType==="gist"?"/gist/":"/r/")+encodeURIComponent(C)+"/":""},e.previewUrl=()=>{let C=e.previewPath();return C?"anonymous.4open.science"+C.replace(/\/$/,""):""},e.previewRedactions=()=>{let C=K=>typeof K=="string"?(K.match(ei)||[]).length:0;if(e.detectedType==="repo")return e.previewViewer.redactionCount();let O=e.detectedType==="pr"?Eo:No,B=0;return O.forEach(K=>{B+=C(K)}),B};let he=(C,O)=>C.localeCompare(O,void 0,{sensitivity:"base"}),Be=C=>C.slice(C.lastIndexOf("/")+1),He={key:null,files:[]};e.previewTreeFiles=()=>{if(!e.preserve.commit||!W)return[];let C=e.preserve.commit+"\0"+e.terms+"\0"+Co.size+"\0"+W.files.length;if(He.key===C)return He.files;let O=W.files.map(B=>{let K=e.previewPathName(B),ae=K.lastIndexOf("/");return{name:K.slice(ae+1),path:ae<0?"":K.slice(0,ae),size:0,sourcePath:B}});return He={key:C,files:O},O},e.selectPreviewPath=C=>{let O=e.previewTreeFiles().find(B=>"/"+(B.path?B.path+"/":"")+B.name===C);O&&e.openPreviewFile(O.sourcePath)},e.existingConfigurationUrl=()=>{let C=e.previousConfigurations.find(O=>O.repoId===e.previousConfigurationId);return C?"/anonymize/"+encodeURIComponent(C.repoId):null};function Qe(C){t.get("/api/user/default").then(O=>{let B=O.data;B.terms&&(e.defaultTerms=B.terms.join(`
+`)),e.options=Object.assign({},e.options,B.options),e.options.expirationDate=B.options&&B.options.expirationDate?new Date(B.options.expirationDate):_(),!i.repoId&&!i.pullRequestId&&!i.gistId&&!e.anonymize?.terms?.dirty&&(e.terms=e.defaultTerms),C&&C()})}function Ee(C,O,B){e.anonymize&&e.anonymize[C]&&e.anonymize[C].setValidity(O,B)}function tt(C){try{let O=parseGithubUrl(C);if(O&&O.owner&&O.repo)return O.owner+"/"+O.repo}catch{}return null}e.accessRepairAllowed=!1,e.repairingGitHubAccess=!1,e.accessRepairMessage="",e.repairGitHubAccess=async()=>{if(!e.accessRepairAllowed||e.repairingGitHubAccess||!e.githubConnections?.appEnabled||!i.repoId||e.role!=="owner"||e.githubConnection!=="github-app"||tt(e.sourceUrl)!==e._originalFullName)return;e.repairingGitHubAccess=!0,e.accessRepairMessage="";let C=m();try{let O=await t.get("/github/connections");if(e.githubConnections=O.data,!O.data.appEnabled)return;let B=await t.post("/github/connections/migrate",{type:"repository",id:i.repoId,connection:"github-app"},{headers:{"X-CSRF-Token":O.data.csrf}});if(!y(C))return;e.error=null,B.data.fullName&&(e._originalFullName=B.data.fullName,e.source.fullName=B.data.fullName,e.sourceUrl="https://github.com/"+B.data.fullName),e.accessRepairMessage="GitHub access repaired. Your anonymous URL and published commit are unchanged.",await e.urlSelected(!0)}catch{y(C)&&(e.accessRepairMessage="Unable to repair GitHub access. Check the App's repository permissions in Manage access, then retry. Your published snapshot has not been replaced.")}finally{e.repairingGitHubAccess=!1,b(C)}},e.reconnectingSource=!1,e.reconnectRepositoryId=void 0,e.reconnectSource=async()=>{if(confirm("Reconnect to the repository currently at this GitHub URL? Review its branch and commit before saving. Saving will replace the published snapshot.")){e.reconnectingSource=!0,e.reconnectRepositoryId=void 0,e.details=null,e.source.commit="",e.source.branch="",e.readme="",e.branches=[];try{await ce()}catch{}}};function Ne(){return e.reconnectingSource||!e.isUpdate||!e._originalRepositoryID?void 0:tt(e.sourceUrl)===e._originalFullName?e._originalRepositoryID:void 0}async function qe(){e._preservingDraft=!0;try{await e.urlSelected(!0)}finally{e._preservingDraft=!1}}async function X(){let C=new URLSearchParams(window.location.search).get("billingDraft");if(C){N.restore();try{let B=(await t.get("/api/billing/draft/"+encodeURIComponent(C))).data;if(B.path!==o.path())throw new Error("Wrong task");w=B.values.conference||null;for(let K of["sourceUrl","terms","repoId","source","options","conference","githubConnection"])Object.prototype.hasOwnProperty.call(B.values,K)&&(e[K]=B.values[K]);return e.options?.expirationDate&&(e.options.expirationDate=new Date(e.options.expirationDate)),T=B.id,M=JSON.stringify(N.checkpoint()),e.draftRestored=!0,e.hostingReview=!0,e.sourceUrl&&await qe(),o.replace?.(o.path()),!0}catch{e.billingError="The checkout draft could not be restored. Retry by reloading this page; any local draft is still available."}}let O;try{O=JSON.parse(sessionStorage.getItem("github-access-draft")||"null")}catch{return!1}if(!O||O.path!==o.path()||Date.now()-O.savedAt>=30*6e4)return N.restore()?(e.sourceUrl&&await qe(),!0):!1;N.restore();for(let B of["sourceUrl","terms","repoId","pullRequestId","gistId","source","options","conference","githubConnection"])Object.prototype.hasOwnProperty.call(O.draft,B)&&(e[B]=O.draft[B]);return e.options.expirationDate&&(e.options.expirationDate=new Date(e.options.expirationDate)),await qe(),sessionStorage.removeItem("github-access-draft"),!0}Qe(()=>{!i.repoId&&!i.pullRequestId&&!i.gistId&&u(X,0),i.repoId&&i.repoId!=""&&(e.isUpdate=!0,e.detectedType="repo",e.repoId=i.repoId,t.get("/api/repo/"+e.repoId).then(async C=>{e.accessRepairAllowed=!["removed","archived","preparing","queue","download","removing","expiring"].includes(C.data.status),e.githubConnection=C.data.connection||"oauth",e.sourceUrl="https://github.com/"+C.data.source.fullName,e._originalFullName=C.data.source.fullName,e.terms=C.data.options.terms.filter(O=>O).join(`
`),e.source=C.data.source,e.role=C.data.role||"owner",e._existingNever=C.data.options.expirationMode==="never",e._savedExpirationDate=C.data.options.expirationDate?new Date(C.data.options.expirationDate):null,e.coauthors=C.data.coauthors||[],e._originalBranch=C.data.source.branch,e.options=Object.assign({},e.options,C.data.options),e.conference=C.data.conference,e._originalConference=C.data.conference,e.repositoryID=C.data.source.repositoryID,e._originalRepositoryID=C.data.source.repositoryID,C.data.options.expirationDate&&(e.options.expirationDate=new Date(C.data.options.expirationDate)),E=S(parseGithubUrl(e.sourceUrl)),!await X()&&(await Promise.all([ce(),ue()]),So())},()=>{o.url("/404")})),i.pullRequestId&&i.pullRequestId!=""&&(e.isUpdate=!0,e.detectedType="pr",e.pullRequestId=i.pullRequestId,t.get("/api/pr/"+e.pullRequestId).then(async C=>{if(e.githubConnection=C.data.connection||"oauth",e.sourceUrl="https://github.com/"+C.data.source.repositoryFullName+"/pull/"+C.data.source.pullRequestId,e.terms=C.data.options.terms.filter(O=>O).join(`
`),e.source=C.data.source,e.options=Object.assign({},e.options,C.data.options),e.conference=C.data.conference,e._originalConference=C.data.conference,C.data.options.expirationDate&&(e.options.expirationDate=new Date(C.data.options.expirationDate)),E=S(parseGithubUrl(e.sourceUrl)),!await X())try{await ol()}catch{}},()=>{o.url("/404")})),i.gistId&&i.gistId!=""&&(e.isUpdate=!0,e.detectedType="gist",e.gistId=i.gistId,t.get("/api/gist/"+e.gistId).then(async C=>{e.sourceUrl="https://gist.github.com/"+C.data.source.gistId,e.terms=C.data.options.terms.filter(O=>O).join(`
`),e.source=C.data.source,e.options=Object.assign({},e.options,C.data.options),e.conference=C.data.conference,e._originalConference=C.data.conference,C.data.options.expirationDate&&(e.options.expirationDate=new Date(C.data.options.expirationDate)),E=S(parseGithubUrl(e.sourceUrl)),!await X()&&await sl()},()=>{o.url("/404")}))}),t.get("/github/connections").then(C=>{e.githubConnections=C.data,!i.repoId&&!i.pullRequestId&&!i.gistId&&e.githubConnection===void 0&&C.data.appEnabled&&C.data.appConnected&&(e.githubConnection="github-app",e.sourceUrl&&e.workspaceOpen&&qe())}).catch(()=>{}).finally(()=>{!v&&!i.repoId&&!i.pullRequestId&&!i.gistId&&e.userReposStatus==="idle"&&e.loadUserRepos()}),e.urlSelected=async(C=!1)=>{let O=++c;e.previousConfigurations=[],e.previousConfigurationId="";let B;try{B=parseGithubUrl(e.sourceUrl.trim())}catch{e.sourceLoading=!1,e.details=null,fe(),Jt.cancel(),Mn.cancel(),Vn.cancel(),e.previewStatus="idle",e.sourceUrlError=e.sourceUrl?"Please provide a valid GitHub URL.":"",Ee("sourceUrl","github",!1);return}let K=S(B),ae=C||E===K;E=K,e.sourceUrlError="",Ee("sourceUrl","github",!0),fe();let ye=document.activeElement?.id==="sourceUrl-landing";e.workspaceOpen=!0,setTimeout(()=>{let je=window.document.getElementById("sourceUrl");if(je){try{je.setSelectionRange(0,0)}catch{}je.scrollLeft=0}},50),ye&&u(()=>document.getElementById("sourceUrl")?.focus(),0),e.reconnectingSource=!1,e.reconnectRepositoryId=void 0,!ae&&!e.isUpdate&&(e.repoId="",e.pullRequestId="",e.gistId=""),e.details=null,e.branches=[],ae||(e.source={type:"GitHubStream",branch:"",commit:""}),Jt.cancel(),Mn.cancel(),Vn.cancel(),Eo.clear(),No.clear(),e.previewStatus="idle",e.anonymize_readme="",e.readme="",rf(),e.detectedType=null,e.gistOAuthRequired=!1,e.gistAppRequired=!1,e._preservingDraft=ae;try{B.gistId&&!B.repo?(e.detectedType="gist",e.source={gistId:B.gistId},await sl()):B.pullRequestId?(e.detectedType="pr",e.source={repositoryFullName:B.owner+"/"+B.repo,pullRequestId:B.pullRequestId},await ol()):(e.detectedType="repo",Y(),await Promise.all([ce(),ue()]),So())}catch{}finally{O===c&&(e._preservingDraft=!1)}$('[data-toggle="tooltip"]').tooltip()},$('[data-toggle="tooltip"]').tooltip(),e.watch("source.branch",async()=>{if(e.detectedType!=="repo")return;let C=e.branches.filter(B=>B.name==e.source.branch)[0];if(!C)return;!(!e.reconnectingSource&&e.isUpdate&&e._originalBranch===e.source.branch&&e.source.commit)&&!(e._preservingDraft&&e.source.commit)&&(e.source.commit=C.commit),e.readme=C.readme,await ue(),So()}),e.getBranches=async C=>{let O=parseGithubUrl(e.sourceUrl),B=m();try{if(!e.details){await ce(C);return}let K=await t.get(`/api/repo/${O.owner}/${O.repo}/branches`,{params:{reconnect:e.reconnectingSource?"1":void 0,anonymizedRepoId:e.isUpdate&&i.repoId&&tt(e.sourceUrl)===e._originalFullName?i.repoId:void 0,connection:e.githubConnection,force:C===!0||e.reconnectingSource?"1":"0",repositoryID:Ne()}});if(!y(B))return;e.branches=K.data,e.sourceUnreachable=!1,e.source.branch||(e.source.branch=e.details.defaultBranch);let ae=e.branches.filter(ye=>ye.name==e.source.branch);ae.length>0&&(!(!e.reconnectingSource&&!C&&e.isUpdate&&!e.options.update&&e._originalBranch===e.source.branch&&e.source.commit)&&!(e._preservingDraft&&e.source.commit)&&(e.source.commit=ae[0].commit),e.readme=ae[0].readme,await ue(C))}catch(K){if(!y(B))return;e.branches=[],e.sourceUnreachable=K&&(K.status===404||K.data&&K.data.error==="repo_not_found"),e.details=null,x(K)}finally{b(B)}};async function ce(C=!1){let O=parseGithubUrl(e.sourceUrl),B=m();try{Ro(),fe();let K=await t.get(`/api/repo/${O.owner}/${O.repo}/`,{params:{reconnect:e.reconnectingSource?"1":void 0,anonymizedRepoId:e.isUpdate&&i.repoId&&tt(e.sourceUrl)===e._originalFullName?i.repoId:void 0,connection:e.githubConnection,repositoryID:Ne(),force:"1"}});if(!y(B))return;e.details=K.data,e.reconnectingSource&&(e.reconnectRepositoryId=e.details.externalId),e.details&&e.details.id&&(e.repositoryID=e.details.id),e.repoId||(e.repoId=e.details.repo+"-"+generateRandomId(4)),await e.getBranches(C||e.reconnectingSource)}catch(K){if(!y(B))return;throw x(K),K}finally{b(B)}}async function ue(C){if(e.readme&&!C)return e.readme;let O=parseGithubUrl(e.sourceUrl),B=m();try{let K=await t.get(`/api/repo/${O.owner}/${O.repo}/readme`,{params:{reconnect:e.reconnectingSource?"1":void 0,anonymizedRepoId:e.isUpdate&&i.repoId&&tt(e.sourceUrl)===e._originalFullName?i.repoId:void 0,connection:e.githubConnection,force:C===!0?"1":"0",branch:e.source.branch,repositoryID:Ne()}});y(B,!0)&&(e.readme=K.data)}catch{y(B,!0)&&(e.readme="")}finally{b(B)}}let me={magicalBraces:!0},be=C=>C.startsWith("/")&&!C.endsWith("/")&&Gn(bo(C.slice(1),me),me)===C.slice(1),Ve=()=>Object.keys(e.preserve.picked).filter(C=>e.preserve.picked[C]).sort().map(C=>"/"+Gn(C,me)),D=C=>"/"+Gn(C,me)+"/**",A=C=>"!/"+Gn(C,me)+"/",U=()=>String(e.preserve.patterns||"").split(`
diff --git a/test/vue-ui.test.js b/test/vue-ui.test.js
index 3eb4194..a92d66d 100644
--- a/test/vue-ui.test.js
+++ b/test/vue-ui.test.js
@@ -943,6 +943,33 @@ describe("Vue 3 UI", function () {
});
}
+ it("shows failed reconnection after previously loading source metadata", async () => {
+ let fail = false;
+ ui = await browser("/anonymize/saved", {
+ ...repositorySource,
+ "/api/repo/saved": { source: { fullName: "owner/repo", branch: "main", commit: "saved123" }, options: { terms: ["Private Author"] } },
+ "/api/repo/owner/repo/": () => fail ? { __status: 403, body: { error: "github_app_reconnect_required" } }
+ : { defaultBranch: "main", repo: "repo", hasPage: false },
+ });
+ await delay(150);
+ const state = ui.window.document.querySelector("#sourceUrl")._field.binding.state;
+ expect(state.details.repo).to.equal("repo");
+ ui.window.confirm = () => true;
+ fail = true;
+ await state.reconnectSource();
+ await delay(30);
+ expect(state.details).to.equal(null);
+ expect(state.sourceProblem().kind).to.equal("reconnect");
+ expect(ui.window.document.querySelector('.source-error a[href="/connections"]')).not.to.equal(null);
+ expect(ui.window.document.querySelector('.rp-error a[href="/connections"]')).not.to.equal(null);
+ fail = false;
+ await state.reconnectSource();
+ await delay(30);
+ expect(state.sourceProblem()).to.equal(null);
+ expect(state.source.commit).to.equal("abcdef123");
+ expect(ui.errors).to.deep.equal([]);
+ });
+
it("recovers edit source validity after a failed branch refresh", async () => {
let fail = false;
ui = await browser("/anonymize/saved", {