performance.mark("js-parse-end:6478-f2d569331647c986.js"); "use strict";(globalThis.webpackChunk_github_ui_github_ui=globalThis.webpackChunk_github_ui_github_ui||[]).push([["6478"],{44093(e,t,a){a.d(t,{L:()=>o});var s=a(7909),r=a(78597),i=a(5045);class o{static warmCachesLoopSetup=!1;static warmResolve;static warm=new Promise(e=>{o.warmResolve=e});async setupWarmCachesLoop(){(0,s.M3)()&&(o.warmCachesLoopSetup?await o.warm:(o.warmCachesLoopSetup=!0,await this.warmCaches()))}async warmCaches(){let e=54e4;try{let t=await (0,r.lS)("/search/warm_blackbird_caches",{headers:{Accept:"application/json",...(0,i.kt)()}}),a=await t.json();e=new Date(a.userCacheExpiresAt).getTime()-Date.now()-3e4,(isNaN(e)||e<=5)&&(e=3e4)}catch{}o.warmResolve(),setTimeout(()=>{this.warmCaches()},e)}}},4216(e,t,a){a.d(t,{$d:()=>h,xR:()=>d});var s=a(74848),r=a(16522),i=a(73537),o=a(96540),n=a(38297),l=a(20331),u=a(49685);let c=(0,o.createContext)(void 0);function h(e){let t,a,o,h,d,m,p,f,y,w,v,k=(0,r.c)(39),{children:g,initialLicenseType:T,initialPlan:b,initialQuotas:I}=e,[R,C]=(0,n.Z2)(T,b,I),P=R.licenseType,q=R.plan??null;k[0]!==R?(t=R.chatQuotaRemaining()??1/0,k[0]=R,k[1]=t):t=k[1];let S=t;k[2]!==R?(a=R.premiumInteractionsQuotaRemaining()??1/0,k[2]=R,k[3]=a):a=k[3];let _=a;k[4]!==R.quotas?(o=R.quotas?.resetDate?new Date(R.quotas.resetDate).toLocaleDateString("en-US",{year:"numeric",month:"long",day:"numeric"}):"",k[4]=R.quotas,k[5]=o):o=k[5];let E=o;k[6]===Symbol.for("react.memo_cache_sentinel")?(h=(0,i.G7)("copilot_simulate_quota_exceeded"),k[6]=h):h=k[6];let A=h,$=A||P===l.mF.LicensedLimited;k[7]!==R?(d=R.canPurchaseAdditionalQuota(),k[7]=R,k[8]=d):d=k[8];let O=d;k[9]!==R?(m=R.canUpgradePlan(),k[9]=R,k[10]=m):m=k[10];let L=m,D=A||$&&S<=0,j=u.W.premiumRequestQuotasEnabled&&!$&&_<=0,x=!!(R.quotas?.sessionQuota?.hasQuota&&R.quotas.sessionQuota.percentRemaining<=0),F=R.quotas?.sessionQuota?.resetAt;k[11]!==F?(p=(0,n.rT)(F),k[11]=F,k[12]=p):p=k[12];let M=p,G=!!(R.quotas?.weeklyQuota?.hasQuota&&R.quotas.weeklyQuota.percentRemaining<=0),Q=R.quotas?.weeklyQuota?.resetAt;k[13]!==Q?(f=(0,n.rT)(Q),k[13]=Q,k[14]=f):f=k[14];let N=f,U=u.W.copilotDotcomChatTbb&&(x||G),W=R.quotas?.overagesEnabled??!1;k[15]!==R?(y=R.eligibleForTrial(),k[15]=R,k[16]=y):y=k[16];let H=y;k[17]!==O||k[18]!==L||k[19]!==D||k[20]!==S||k[21]!==H||k[22]!==$||k[23]!==P||k[24]!==W||k[25]!==q||k[26]!==_||k[27]!==j||k[28]!==C||k[29]!==E||k[30]!==x||k[31]!==M||k[32]!==U||k[33]!==G||k[34]!==N?(w={licenseType:P,chatQuotaRemaining:S,premiumChatQuotaRemaining:_,resetDate:E,isLicensedLimited:$,chatQuotaExceeded:D,premiumInteractionsQuotaExceeded:j,reloadQuota:C,plan:q,canPurchaseAdditionalQuota:O,canUpgradePlan:L,overagesEnabled:W,eligibleForTrial:H,sessionQuotaExceeded:x,sessionQuotaResetLabel:M,weeklyQuotaExceeded:G,weeklyQuotaResetLabel:N,tbbQuotaExceeded:U},k[17]=O,k[18]=L,k[19]=D,k[20]=S,k[21]=H,k[22]=$,k[23]=P,k[24]=W,k[25]=q,k[26]=_,k[27]=j,k[28]=C,k[29]=E,k[30]=x,k[31]=M,k[32]=U,k[33]=G,k[34]=N,k[35]=w):w=k[35];let z=w;return k[36]!==g||k[37]!==z?(v=(0,s.jsx)(c,{value:z,children:g}),k[36]=g,k[37]=z,k[38]=v):v=k[38],v}c.displayName="EntitlementContext",h.displayName="EntitlementProvider";let d=()=>{let e=(0,o.use)(c);if(!e)throw Error("useEntitlement must be used within EntitlementProvider");return e}},70155(e,t,a){a.d(t,{c:()=>l,n:()=>n});var s=a(74848),r=a(16522),i=a(96540);let o=(0,i.createContext)(null);function n(e){let t,a=(0,r.c)(3),{children:i,value:n}=e;return a[0]!==i||a[1]!==n?(t=(0,s.jsx)(o,{value:n,children:i}),a[0]=i,a[1]=n,a[2]=t):t=a[2],t}function l(){let e=(0,i.use)(o);if(!e||!e.current)throw Error("useGetTraceState can only be used inside a TraceProvider");return(0,i.useCallback)(()=>e.current.value,[e])}o.displayName="ObservableTraceStateContext",n.displayName="ObservableTraceStateProvider"},71047(e,t,a){a.d(t,{Q:()=>m,y:()=>p});var s=a(74848),r=a(16522),i=a(96540),o=a(70155),n=a(51189),l=a(51261),u=a(49685),c=a(96978);class h{dispatch;service;getTraceState;constructor(e,t,a,s){this.dispatch=e,this.service=new l.k(a,s),this.getTraceState=t}showTraceDisplay=async(e,t)=>{e&&t&&await this.fetchAndLoadTraces(t),this.dispatch({type:"SET_TRACE_INFO",traceInfo:{visible:e,threadId:t??void 0}})};async fetchAndLoadTraces(e,t){if(!u.W.requestTracing||!(0,n.Xl)())return;let a=this.getTraceState();if(!a.traceInfo?.loadedThreadIds?.has(e))try{let s=await this.service.fetchTracesByThreadID(e,t);s.ok&&s.payload.length>0?this.addTracesToState(a,s,e):this.dispatch({type:"SET_TRACE_INFO",traceInfo:{threadId:e}})}catch{}}addTracesToState(e,t,a){let s=new Map(e.traceInfo?.traces||[]);for(let e of t.payload)for(let[,t]of(0,c.r)(e.spans).entries()){let r=new Date(t.startTime).toISOString(),i=`${a}:${r}`;s.set(i,{spanNode:t,threadId:a,actualTraceId:e.id,timestamp:r,requestId:e.requestId})}this.dispatch({type:"SET_TRACE_INFO",traceInfo:{traces:s,threadId:a}})}async fetchCoffeTrace(e){if(!u.W.requestTracing||!(0,n.Xl)())return{ok:!1,status:403,error:"Tracing not available"};let t=this.getTraceState(),a=await this.service.fetchCoffeTrace(e);if(a.ok&&a.payload.length>0)return this.addTracesToState(t,a,e),a;throw Error(`Failed to load COFFE trace: ${a.status}`)}async deleteTraceSpansForGivenThread(e){let t=await this.service.deleteTracesForThread(e);return t.ok&&this.dispatch({type:"REMOVE_TRACES_FOR_THREAD",threadID:e}),t}async deleteTrace(e,t){let a=await this.service.deleteTrace(e,t);return a.ok&&this.dispatch({type:"REMOVE_TRACE",traceID:t}),a}}let d=(0,i.createContext)(null);function m(e){let t,a,i=(0,r.c)(8),{apiURL:n,children:l,dispatch:u,ssoOrgs:c}=e,m=(0,o.c)();i[0]!==n||i[1]!==u||i[2]!==m||i[3]!==c?(t=new h(u,m,n,c),i[0]=n,i[1]=u,i[2]=m,i[3]=c,i[4]=t):t=i[4];let p=t;return i[5]!==l||i[6]!==p?(a=(0,s.jsx)(d,{value:p,children:l}),i[5]=l,i[6]=p,i[7]=a):a=i[7],a}function p(){let e=(0,i.use)(d);if(null===e)throw Error("useTraceManager must be used within a TraceManagerProvider");return e}d.displayName="TraceManagerContext",m.displayName="TraceManagerProvider"},21341(e,t,a){a.d(t,{hh:()=>p,Kf:()=>f,jR:()=>y});var s=a(74848),r=a(16522),i=a(13865),o=a(96540),n=a(70155),l=a(71047);let u=new Map,c=new Set;function h(e,t){switch(t.type){case"SET_TRACE_INFO":{let{visible:a,spanNode:s,messageId:r,threadId:i,actualTraceId:o,requestId:n,traces:l}=t.traceInfo,h=e.traceInfo?.traces||u,d=e.traceInfo?.loadedThreadIds||c;if(l&&l.size>0){let e=new Map(h);for(let[t,a]of l)e.set(t,a);h=e}else if(s&&r&&i){let e=new Map(h),t=new Date(s.startTime).toISOString();e.set(r,{spanNode:s,threadId:i,actualTraceId:o||"",timestamp:t,requestId:n}),h=e}if(i&&!d.has(i)){let e=new Set(d);e.add(i),d=e}let m=void 0!==a?a:e.traceInfo?.visible||!1;return{...e,traceInfo:{visible:m,traces:h,loadedThreadIds:d}}}case"REMOVE_TRACE":{let a=new Map(e.traceInfo?.traces||[]);for(let[e,s]of a)if(s.actualTraceId===t.traceID){a.delete(e);break}return{...e,traceInfo:{visible:e.traceInfo?.visible||!1,traces:a,loadedThreadIds:e.traceInfo?.loadedThreadIds||new Set}}}case"REMOVE_TRACES_FOR_THREAD":{let a=new Map(e.traceInfo?.traces||[]);for(let[e,s]of a)s.threadId===t.threadID&&a.delete(e);return{...e,traceInfo:{visible:e.traceInfo?.visible||!1,traces:a,loadedThreadIds:e.traceInfo?.loadedThreadIds||new Set}}}}}let d=(0,o.createContext)(null);d.displayName="TraceStateContext";let m=(0,o.createContext)(null);function p(e){let t,a,u,c,p,f,y=(0,r.c)(20),{apiURL:w,children:v,ssoOrgs:k,testReducerState:g}=e;y[0]!==g?(t=g||{},y[0]=g,y[1]=t):t=y[1];let T=t,[b,I]=(0,o.useReducer)(h,T),[R,C]=(0,i.XG)(b);return y[2]!==C||y[3]!==b||y[4]!==R.current.value?(a=()=>{b!==R.current.value&&C(b)},y[2]=C,y[3]=b,y[4]=R.current.value,y[5]=a):a=y[5],y[6]!==C||y[7]!==b||y[8]!==R?(u=[b,R,C],y[6]=C,y[7]=b,y[8]=R,y[9]=u):u=y[9],(0,o.useLayoutEffect)(a,u),y[10]!==w||y[11]!==v||y[12]!==k?(c=(0,s.jsx)(l.Q,{apiURL:w,dispatch:I,ssoOrgs:k,children:v}),y[10]=w,y[11]=v,y[12]=k,y[13]=c):c=y[13],y[14]!==R||y[15]!==c?(p=(0,s.jsx)(m,{value:I,children:(0,s.jsx)(n.n,{value:R,children:c})}),y[14]=R,y[15]=c,y[16]=p):p=y[16],y[17]!==b||y[18]!==p?(f=(0,s.jsx)(d,{value:b,children:p}),y[17]=b,y[18]=p,y[19]=f):f=y[19],f}function f(){let e=(0,o.use)(d);if(!e)throw Error("useTraceState must be used within a TraceContext");return e}function y(){return(0,o.use)(m)}m.displayName="TraceDispatchContext",p.displayName="TraceProvider"},94991(e,t,a){a.d(t,{d:()=>s});class s{separator="-!-";cache=new Map;fetchFn;constructor(e){this.fetchFn=e}async get(...e){let t=e.join(this.separator),a=this.cache.get(t);if(a)return a;{let a=this.fetchFn(...e);return this.cache.set(t,a),(await a).ok||this.cache.delete(t),a}}}},38297(e,t,a){a.d(t,{U1:()=>p,Z2:()=>h,rT:()=>f});var s=a(16522),r=a(66743),i=a(97665),o=a(97286),n=a(78597),l=a(11515),u=a(20331),c=a(49685);function h(e,t,a){let n,h,p,f,y,w,v,k,g,T=(0,s.c)(30),b=(0,i.jE)();T[0]!==b?(n=()=>b.invalidateQueries({queryKey:["copilot-chat","entitlement"]}),T[0]=b,T[1]=n):n=T[1];let I=n;T[2]===Symbol.for("react.memo_cache_sentinel")?(h=["copilot-chat","entitlement"],T[2]=h):h=T[2];let R=e===u.mF.LicensedLimited||e===u.mF.LicensedFull&&c.W.premiumRequestQuotasEnabled;T[3]!==e||T[4]!==t||T[5]!==a?(p={licenseType:e,plan:t,quotas:a},T[3]=e,T[4]=t,T[5]=a,T[6]=p):p=T[6],T[7]!==R||T[8]!==p?(f={queryKey:h,queryFn:d,enabled:R,placeholderData:p,staleTime:3e5},T[7]=R,T[8]=p,T[9]=f):f=T[9];let{data:C}=(0,o.I)(f),P=C?.licenseType??e,q=C?.plan??t,S=C?.quotas??a,_=S?.remaining.chatPercentage,E=S?.remaining.premiumInteractionsPercentage;T[10]!==S?.sessionQuota||T[11]!==S?.weeklyQuota?(y=c.W.copilotDotcomChatTbb&&(0,l.qw)(S?.sessionQuota,l.fG)&&(0,l.qw)(S?.weeklyQuota,l.fG),T[10]=S?.sessionQuota,T[11]=S?.weeklyQuota,T[12]=y):y=T[12];let A=y;T[13]!==_||T[14]!==A?(w=(0,l.qw)({hasQuota:!0,percentRemaining:_},l.fG)||A,T[13]=_,T[14]=A,T[15]=w):w=T[15];let $=w;T[16]!==e||T[17]!==I||T[18]!==P||T[19]!==E||T[20]!==$?(v=t=>{(e===u.mF.LicensedLimited||e===u.mF.LicensedFull&&c.W.premiumRequestQuotasEnabled)&&(c.W.reduceChatQuotaChecks&&P===u.mF.LicensedLimited&&$||P===u.mF.LicensedFull&&(0,l.qw)({hasQuota:!0,percentRemaining:E},l.mF)||(I(),(0,r.BI)("dotcom_chat.activate",{target:"ENTITLEMENTS_RELOAD",origin:t})))},T[16]=e,T[17]=I,T[18]=P,T[19]=E,T[20]=$,T[21]=v):v=T[21];let O=v,L=C?.quotas,D=C?.trial;return T[22]!==P||T[23]!==q||T[24]!==L||T[25]!==D?(k=new m(P,q,L,D),T[22]=P,T[23]=q,T[24]=L,T[25]=D,T[26]=k):k=T[26],T[27]!==O||T[28]!==k?(g=[k,O],T[27]=O,T[28]=k,T[29]=g):g=T[29],g}async function d(){let e=await (0,n.lS)("/github-copilot/chat/entitlement");if(!e.ok)throw Error(`Failed to retrieve Copilot chat entitlement (${e.status} on ${e.url})`);return await e.json()}class m{licenseType;plan;quotas;trial;constructor(e,t,a,s){this.licenseType=e,this.plan=t,this.quotas=a,this.trial=s}isLicensed(){return this.licenseType&&this.licenseType!==u.mF.Unlicensed}canPurchaseAdditionalQuota(){return this.licenseType!==u.mF.LicensedLimited&&c.W.premiumRequestQuotasEnabled&&(this.plan===u.UH.IndividualPro||this.plan===u.UH.IndividualProPlus||this.plan===u.UH.IndividualStudent)}canUpgradePlan(){return this.licenseType===u.mF.LicensedLimited||c.W.premiumRequestQuotasEnabled&&(this.plan===u.UH.IndividualPro||this.plan===u.UH.IndividualStudent)}chatQuotaRemaining(){return c.W.premiumRequestQuotasEnabled&&this.quotas?.remaining.chatPercentage!==void 0?this.quotas?.remaining.chatPercentage??0:this.quotas?.remaining.chat??0}premiumInteractionsQuotaRemaining(){return this.quotas?.remaining.premiumInteractionsPercentage??0}eligibleForTrial(){return this.trial?.eligible??!1}}function p(e){return!!(e&&e!==u.UH.IndividualFree)}function f(e){if(null==e||0===e)return"";let t=new Date(1e3*e),a=new Date,s=Math.floor((t.getTime()-a.getTime())/1e3);if(s<=60)return"soon";if(s<3600){let e=Math.floor(s/60);return`in ${e} ${1===e?"min":"mins"}`}if(s<86400){let e=Math.floor(s/3600),t=Math.floor(s%3600/60),a=`in ${e} ${1===e?"hour":"hours"}`;return t>0&&(a+=` ${t} ${1===t?"min":"mins"}`),a}let r=new Intl.DateTimeFormat("en-US",{month:"long",day:"numeric",timeZone:"UTC"}).format(t);return`on ${r}`}},51261(e,t,a){a.d(t,{k:()=>f});var s=a(44093),r=a(17917),i=a(23666),o=a(78597),n=a(94991),l=a(11515),u=a(49685),c=a(10506),h=a(81830),d=a(9544),m=a(12104);let p=new Set(["snippet","file","symbol","repository"]);class f{apiURL;urlPathPrefix="/github-copilot/chat";repoDetailsCache=new Map;listMessagesCache=void 0;copilotAuthTokenProvider;blackbirdCaches=new s.L;realIp;apiVersion=void 0;constructor(e,t,a,s){this.apiURL=e,this.copilotAuthTokenProvider=new r.JR(t.map(e=>e.id)),this.realIp=a||"",this.apiVersion=s}async fetchThreads(e={}){let t=new URLSearchParams;"string"==typeof e.name&&t.set("name",e.name);let a=`/threads?${t.toString()}`,s=await this.makeCAPIRequest(a,"GET");if(!s.ok)return s;let r=await s.json(),i=(r.threads||[]).map(e=>({...e,ssoRequired:"SSO to see this thread"===e.name})),o=!0===r.orgs_failed_to_load;return{status:s.status,ok:!0,payload:{threads:i,orgsFailedToLoad:o}}}async fetchSharedThreads(){let e=await this.makeCAPIRequest("/threads?shared","GET");if(!e.ok)return e;let t=(await e.json()).threads||[];return{status:e.status,ok:!0,payload:t}}async fetchLatestThread(e){let t=new URLSearchParams;"string"==typeof e&&t.set("thread_id",e);let a=await this.makeCAPIRequest(`/threads/latest?${t.toString()}`,"GET");if(!a.ok)return a;let s=(await a.json()).thread;return{status:a.status,ok:!0,payload:s}}async createThread(e,t){let a={custom_copilot_id:e?.id,custom_copilot_owner:e?.owner,scope_id:t},s=await this.makeCAPIRequest("/threads","POST",a);if(!s.ok)return s;let r=(await s.json()).thread;return{status:s.status,ok:!0,payload:r}}async deleteThread(e){let t=await this.makeCAPIRequest(`/threads/${e}`,"DELETE");return t.ok?{status:t.status,ok:!0,payload:null}:t}async deleteAllThreads(e){let t=await this.makeCAPIRequest("/threads","DELETE",e);return t.ok?{status:t.status,ok:!0,payload:null}:t}async renameThread(e,t){let a=await this.makeCAPIRequest(`/threads/${e}/name`,"PATCH",{generate:!1,name:t});if(!a.ok)return a;let s=(await a.json()).name||"";return{status:a.status,ok:!0,payload:s}}async shareThread(e,t){let a=await this.makeCAPIRequest(`/threads/${e}/share`,"PATCH",{shared_message_id:t});if(!a.ok)return a;let s=(await a.json()).thread;return{status:a.status,ok:!0,payload:s}}async unshareThread(e){let t=await this.makeCAPIRequest(`/threads/${e}/unshare`,"PATCH");if(!t.ok)return t;let a=(await t.json()).thread;return{status:t.status,ok:!0,payload:a}}async unshareAllThreads(){let e=await this.makeCAPIRequest("/threads/unshare","POST");return e.ok?{status:e.status,ok:!0,payload:null}:e}async continueSharedThread(e){let t=await this.makeCAPIRequest(`/shared/${e}/duplicate`,"POST");return t.ok?{status:200,ok:!0,payload:await t.json()}:t}async generateThreadName(e){let t=await this.makeCAPIRequest(`/threads/${e}/name`,"PATCH",{generate:!0,name:""});if(!t.ok)return t;let a=(await t.json()).name||"";return{status:t.status,ok:!0,payload:a}}async getSystemPrompt(e){let t=await this.makeCAPIRequest(`/system_prompt/${e}`,"GET");if(!t.ok)return t;let a=await t.json();return{status:t.status,ok:!0,payload:a}}async listMessages(e){if(this.listMessagesCache?.thread.id===e)return{status:200,ok:!0,payload:this.listMessagesCache};let t=await this.makeCAPIRequest(`/threads/${e}/messages`,"GET");return this.handleListMessages(t,!0)}async listSharedThreadMessages(e){let t=await this.makeCAPIRequest(`/shared/${e}/messages`,"GET");return this.handleListMessages(t,!1)}async handleListMessages(e,t){if(!e.ok)if(!((404===e.status||403===e.status)&&e.response?.headers.has("Content-Type"))||"application/json"!==e.response.headers.get("Content-Type"))return e;else{let t=await e.response.json();return{...e,payload:t}}let a=await e.json();return t&&(Array.isArray(a.messages)&&(a.messages=a.messages.map(e=>(e.references=(0,h.q)(e.references),e))),this.listMessagesCache=a),{status:e.status,ok:!0,payload:a}}async createMessage(e,t,a,s,r,i,o){this.listMessagesCache=void 0;let n=await this.makeCAPIRequest(`/threads/${e}/messages`,"POST",{content:t,mediaContent:a,intent:s,references:r,currentURL:window.location.href,customInstructions:i,model:o,settings:c.Jt.settings??void 0});if(!n.ok)return n;let l=(await n.json()).message;return{status:n.status,ok:!0,payload:l}}async createMessageStreaming({threadID:e,messageID:t,content:a,mediaContent:s,intent:r,mode:i,references:o,context:n,confirmations:l,customInstructions:h,model:d,customCopilotID:m,parentMessageID:p,signal:f,skillOptions:w}){this.listMessagesCache=void 0,m&&(i="custom-copilots");let v=u.W.domPageContext&&"immersive"!==i&&"custom-copilots"!==i?function(){let e=(document.querySelector("main")||document.body).cloneNode(!0);for(let t of["script","style","svg","iframe","textarea",".js-header-wrapper",".footer",".sr-only",".react-code-file-contents"])for(let a of e.querySelectorAll(t))a.remove();for(let t of e.querySelectorAll("*")){if(!t.textContent?.trim()){t.remove();continue}let e=window.getComputedStyle(t);("none"===e.display||"hidden"===e.visibility)&&t.remove()}let t=e.querySelectorAll("p, h1, h2, h3, h4, li, td, th, blockquote, pre, code:not(pre code)"),a=[];for(let e of t){let t=y(e);t&&a.push(t)}let s=a.join("\n");return(s.length<=16e3?s:`${s.substring(0,16e3)} Content was truncated. Use the API to get full content.`).replace(/\s{2,}/g," ").trim()}():void 0,k={responseMessageID:t,content:a,intent:r,references:o,context:n,currentURL:window.location.href,streaming:!0,confirmations:l,customInstructions:h,model:d,mode:i,settings:c.Jt.settings??void 0,customCopilotID:m?.id,customCopilotOwner:m?.owner,parentMessageID:p,mediaContent:s,skillOptions:w,pageContext:v,requestTrace:c.Jt.getTracingRequestedFlag()},g=this.processQueryParams(new URLSearchParams(window.location.search)),T=await this.makeCAPIRequest(`/threads/${e}/messages?${g.toString()}`,"POST",k,!0,void 0,f);return T.ok?{status:T.status,ok:!0,response:T}:T}processQueryParams(e){let t=["instruction_prompt"],a=new URLSearchParams;for(let[s,r]of e)t.includes(s)&&a.append(s,r);return a}async listModels(){let e=await this.makeCAPIRequest("/models","GET",void 0,!1,"");if(!e.ok)return e;let t=await e.json();return{status:e.status,ok:!0,payload:t.data}}async setModelPolicyState(e,t){let a=await this.makeCAPIRequest(`/models/${e}/policy`,"POST",{state:t},!1,"");if(!a.ok)return Promise.reject(Error(`Failed to update model policy state: ${a.status}`))}async getSimpleCompletion(e,t){let a=(0,m.wv)(),s=t??a.id,r=await this.makeCAPIRequest("/chat/completions","POST",{messages:[{role:"user",content:e}],selectedModel:s,stream:!1},!1,"");if(!r.ok)return r;let i=(await r.json()).choices[0]?.message?.content||"";return{status:r.status,ok:!0,payload:i}}async sendFeedback({feedback:e,feedbackChoice:t,messageId:a,threadId:s,textResponse:r}){let i=await this.makeDotcomRequest(`${this.urlPathPrefix}/feedback`,"POST",{feedback:e,feedback_choice:t,message_id:a,thread_id:s,text_response:r});return i.ok?{status:i.status,ok:!0,payload:null}:i}async listRepoFiles(e,t=!1){let a=(0,i.ClY)({repo:e,commitOid:e.commitOID,includeDirectories:t});return this.repoFilesCache.get(a)}listRepoFilesImpl=async e=>{let t=await this.makeDotcomRequest(e,"GET");return t.ok?{status:200,ok:!0,payload:await t.json()}:t};repoFilesCache=new n.d(this.listRepoFilesImpl);async querySymbols(e,t){return await this.blackbirdCaches.setupWarmCachesLoop(),this.querySymbolsCache.get(e.ownerLogin,e.name,t)}querySymbolsImpl=async(e,t,a)=>{let s=await this.makeDotcomRequest(`/search/suggestions?query=repo:${e}/${t} ${a}`,"GET");return s.ok?{status:200,ok:!0,payload:(await s.json()).suggestions.filter(e=>"SUGGESTION_KIND_SYMBOL"===e.kind)}:s};querySymbolsCache=new n.d(this.querySymbolsImpl);async fetchImplicitContext(e,t,a){let s=await this.makeDotcomRequest(`${this.urlPathPrefix}/implicit-context/${t}/${a}/${encodeURIComponent(e)}`,"GET");return s.ok?{status:s.status,ok:s.ok,payload:await s.json()}:s}async fetchReferenceDetails(e,t,a,s){let r=await this.makeDotcomRequest(`/copilot/chat/reference/${e}/${t}/${a}/${s}`,"GET");return r.ok?{status:r.status,ok:r.ok,payload:await r.json()}:r}getCachedRepo(e){return this.repoDetailsCache.get(e)}async fetchRepo(e){let t;if(this.repoDetailsCache.has(e))t=this.repoDetailsCache.get(e);else{let a=await this.makeDotcomRequest(`${this.urlPathPrefix}/repositories/${e}`,"GET");if(!a.ok)return a;t=await a.json(),this.repoDetailsCache.set(e,t)}return{status:200,ok:!0,payload:t}}async fetchFileContents(e,t,a){let s=await this.makeDotcomRequest(`${this.urlPathPrefix}/file_contents/${e}/${t}/${a}`,"GET");return s.ok?{status:200,ok:!0,payload:await s.json()}:s}async fetchFileContentsNwo(e,t,a,s){let r;return(r=s?await this.makeDotcomRequest(`${this.urlPathPrefix}/file_contents_nwo/${e}/${t}/${encodeURIComponent(s)}/${a}`,"GET"):await this.makeDotcomRequest(`${this.urlPathPrefix}/file_contents_nwo/${e}/${t}/${a}`,"GET")).ok?{status:200,ok:!0,payload:await r.json()}:r}async listAgents(e){let t=await (0,o.lS)(e);if(!t.ok)return{status:t.status,ok:!1,error:l.nN[t.status]||l.DW};let a=await t.json();return{status:t.status,ok:t.ok,payload:a}}async listCustomCopilots(){let e=await (0,o.lS)(`${this.urlPathPrefix}/custom_copilots`);if(!e.ok)return{status:e.status,ok:!1,error:l.nN[e.status]||l.DW};let t=await e.json();return{status:e.status,ok:!0,payload:t}}async fetchCopilotSpace(e){let t,{owner:a,id:s}=e;t=a?`${this.urlPathPrefix}/custom_copilots/${a}/${s}`:`${this.urlPathPrefix}/custom_copilots/${s}`;let r=await (0,o.lS)(t);if(!r.ok)return{status:r.status,ok:!1,error:l.nN[r.status]||l.DW};let i=await r.json();return{status:r.status,ok:!0,payload:i}}async fetchCustomAgents(e,t){let a=await this.makeCAPIRequest(`/agents/swe/custom-agents/${e}/${t}`,"GET",void 0,void 0,"");if(!a.ok)return 404===a.status?{status:a.status,ok:!0,payload:[]}:{status:a.status,ok:!1,error:l.nN[a.status]||l.DW};let s=(await a.json()).agents;return{status:a.status,ok:!0,payload:s}}async hydrateReference(e){if(!p.has(e.type))return{status:204,ok:!0,payload:e};let t=await this.makeDotcomRequest(`${this.urlPathPrefix}/reference_details`,"POST",{reference:e});return t.ok?{status:t.status,ok:t.ok,payload:await t.json()}:t}async fetchLanguageForFileReference(e){let{repoOwner:t,repoName:a}=e,s=window.btoa(e.path),r=(0,i.RT3)({ownerLogin:t,name:a},s,!0),o=await this.makeDotcomRequest(r,"GET");return o.ok?{status:o.status,ok:o.ok,payload:await o.json()}:o}async fetchAutocompleteIssues(e,t){let a=await this.makeDotcomRequest(`/copilot/chat/autocomplete/issues?repo=${e}&q=${t}`,"GET");return a.ok?await a.json():[]}async fetchAutocompletePullRequests(e,t){let a=await this.makeDotcomRequest(`/copilot/chat/autocomplete/pulls?repo=${e}&q=${t}`,"GET");return a.ok?await a.json():[]}async fetchAutocompleteDiscussions(e,t){let a=await this.makeDotcomRequest(`/copilot/chat/autocomplete/discussions?repo=${e}&q=${t}`,"GET");return a.ok?await a.json():[]}async fetchRepositoriesSearch(e,t,a=!0,s,r){let i=new URLSearchParams;e&&i.set("q",e),t&&i.set("limit",t.toString()),a||i.set("includeForks","false"),s&&i.set("currentRepoId",s.toString()),r&&i.set("owner",r);let o=await this.makeDotcomRequest(`${this.urlPathPrefix}/repositories_search?${i.toString()}`,"GET");return o.ok?(await o.json()).repositories.map(e=>({databaseId:e.databaseId,isInOrganization:e.isInOrganization,name:e.name,nwo:e.nameWithOwner,ownerLogin:e.ownerLogin,ownerAvatarUrl:e.ownerAvatar})):[]}async fetchTopRepositories(e=10,t=!0,a,s){return this.fetchRepositoriesSearch(void 0,e,t,a,s)}async makeDotcomRequest(e,t,a){let s={};for(let e of(0,d.f)()){let t=e.split("="),a=t[0]?.replaceAll("_","-"),r="1";t.length>1&&(r=t[1]??"1"),s[`X-Experiment-${a}`]=r}let r=await this.copilotAuthTokenProvider.getAuthToken();s["X-Copilot-Api-Token"]=r.value;try{let r=await (0,o.lS)(e,{method:t,body:a,headers:s});if(r.ok)return r;return{status:r.status,ok:!1,error:l.nN[r.status]||l.DW}}catch{return{status:500,ok:!1,error:l.DW}}}get directConnectConfiguration(){return{integrationID:"copilot-chat"}}async makeCAPIRequest(e,t,a,s=!1,r="/github/chat",i){let o=this.apiURL,n=await this.copilotAuthTokenProvider.getAuthToken();return await (0,l.p)({basePath:o+r,path:e,method:t,body:a,streamingResponse:s,authToken:n,integrationId:this.directConnectConfiguration.integrationID,realIp:this.realIp,signal:i,apiVersion:this.apiVersion})}async fetchTracesByThreadID(e,t){let a=`/thread/${e}`;t&&(a+=`?sharedID=${encodeURIComponent(t)}`);let s=await this.makeCAPIRequest(a,"GET",void 0,!1,"/traces");if(!s.ok)return s;let r=await this.processTracesResponse(s);return{status:s.status,ok:!0,payload:r}}async fetchCoffeTrace(e){let t=await this.makeCAPIRequest(`/evaluation/thread/${e}`,"GET",void 0,!1,"/traces");if(!t.ok)return t;let a=await this.processTracesResponse(t);return{status:t.status,ok:!0,payload:a}}async processTracesResponse(e){let t=await e.json(),a=[];for(let e of t)e.spans&&Array.isArray(e.spans)&&e.id&&a.push({id:e.id,spans:e.spans,requestId:e.request_id});return a}async deleteTrace(e,t){let a=await this.makeCAPIRequest(`/thread/${e}/trace/${t}`,"DELETE",void 0,!1,"/traces");return a.ok?{status:a.status,ok:!0,payload:null}:a}async deleteTracesForThread(e){let t=await this.makeCAPIRequest(`/thread/${e}`,"DELETE",void 0,!1,"/traces");return t.ok?{status:t.status,ok:!0,payload:null}:t}}let y=e=>{let t=e.tagName.toLowerCase(),a=e.textContent;if(!a||!a.trim())return null;let s=a.trim();switch(t){case"h1":return`# ${s}`;case"h2":return`## ${s}`;case"h3":return`### ${s}`;case"h4":return`#### ${s}`;case"p":default:return s;case"li":return`\u{2022} ${s}`;case"code":return`\`${s}\``;case"pre":return`\`\`\` ${s} \`\`\``;case"blockquote":return`> ${s}`}}},81830(e,t,a){a.d(t,{q:()=>s});function s(e){return Array.isArray(e)?e.filter(e=>!("refOrigin"in e&&"custom_copilot"===e.refOrigin)&&!("type"in e&&"custom-instructions"===e.type)):e}},33899(e,t,a){a.d(t,{m:()=>s});let s=new Set(["Azure OpenAI","OpenAI"])},12104(e,t,a){a.d(t,{GF:()=>d,QA:()=>c,ZL:()=>y,eW:()=>p,fZ:()=>m,wv:()=>h});var s=a(16522),r=a(4216),i=a(20331),o=a(49685),n=a(33899);let l="/images/modules/marketplace/models/families/openai-logo.svg",u=new Map([["Azure OpenAI",l],["OpenAI",l],["Anthropic","/images/modules/marketplace/models/families/anthropic.svg"],["Google","/images/modules/marketplace/models/families/gemini.svg"],["xAI","/images/modules/marketplace/models/families/xai.svg"]]),c="copilot-base";function h(){return{capabilities:{family:"gpt-4.1",limits:{max_prompt_tokens:128e3,vision:{supported_media_types:["image/jpeg","image/png","image/webp","image/gif"]}},supports:{parallel_tool_calls:!0,tool_calls:!0},tokenizer:"o200k_base",type:"chat"},id:"gpt-4.1",name:"GPT-4.1",displayName:"GPT-4.1",model_picker_enabled:!0,preview:!1,vendor:"OpenAI",logoURL:l,isThirdParty:!1,hasLimitedCapabilities:!1,version:"gpt-4.1-2025-04-14"}}function d(e){let t,a=(0,s.c)(5),{plan:i,premiumInteractionsQuotaExceeded:o,overagesEnabled:n}=(0,r.xR)();return a[0]!==e||a[1]!==n||a[2]!==i||a[3]!==o?(t=m(e,i,o,n),a[0]=e,a[1]=n,a[2]=i,a[3]=o,a[4]=t):t=a[4],t}function m(e,t,a,s){var r,n;let u;return o.W.forceLegacyChatDefaultModel?{capabilities:{family:"gpt-4o",limits:{max_prompt_tokens:2e4,vision:{supported_media_types:["image/jpeg","image/png","image/webp","image/gif"]}},supports:{parallel_tool_calls:!0,tool_calls:!0},tokenizer:"o200k_base",type:"chat"},id:"gpt-4o",name:"GPT 4o",version:"gpt-4o-2024-05-13",displayName:"GPT 4o",vendor:"Azure OpenAI",logoURL:l,hasLimitedCapabilities:!1,preview:!1,isThirdParty:!1,model_picker_enabled:!0}:(r=!!a,n=!!s,(u=o.W.premiumRequestQuotasEnabled&&t!==i.UH.IndividualFree&&r&&!n?e?.find(e=>!0===e.is_chat_fallback):e?.find(e=>!0===e.is_chat_default))||h())}function p(e){return(e??[h()]).map(f).filter(e=>!!e).filter(e=>e.model_picker_enabled)}function f(e){var t,a,s,r;if("chat"!==e.capabilities.type||!((t=e).model_picker_enabled&&(!t.policy||"enabled"===t.policy.state||t.policy.terms)))return null;let i=u.get(e.vendor);return"xAI"===e.vendor&&null!==document.querySelector('[data-color-mode="dark"]')&&(i="/images/modules/marketplace/models/families/xai-dark.svg"),{...e,displayName:function(e){for(let t of w)if(e.name.endsWith(t))return e.name.replace(t,"").trim();return e.name}(e),hasLimitedCapabilities:(a=e,s=o.W.copilotChatO1Tools,"o1-ga"===a.capabilities.family?!s:"o3"===a.capabilities.family||!a.capabilities.supports.tool_calls),isThirdParty:(r=e,!n.m.has(r.vendor)),logoURL:i}}function y(e){return null!=e.custom_model}let w=["(Beta)","(Preview)"]},96978(e,t,a){a.d(t,{r:()=>s});function s(e){let t=new Map,a=[];return e.map(e=>{let s={name:e.name,spanId:e.spanId,attributes:e.attributes,startTime:e.startTime,endTime:e.endTime,children:[],sessionId:e.sessionId,userId:e.userId,input:e.input,output:e.output,metadata:e.metadata};t.set(s.spanId,s);let r=e.parentId&&t.get(e.parentId);return r?r.children.push(s):a.push(s),s}),a}},13589(e,t,a){a.d(t,{Es:()=>o,Lj:()=>r,yy:()=>i});class s{#e=new Set;subscribe(e){return this.#e.add(e),()=>{this.#e.delete(e)}}notify(e){for(let t of this.#e)t(e)}}class r extends s{#t;constructor(e){super(),this.#t=e}get value(){return this.#t}set value(e){var t,a;t=this.#t,("object"==typeof(a=e)&&a&&"object"==typeof t&&t?function(e,t){for(let a of new Set(Object.keys(e).concat(Object.keys(t))))if(!Object.is(e[a],t[a]))return!0;return!1}(t,a):!Object.is(t,a))&&(this.#t=e,this.notify(e))}setValue(e){this.value=e}}class i extends s{#t;#a=new Map;constructor(...e){super(),this.#t=new Set(...e)}get value(){return this.#t}has(e){if(!this.#a.has(e)){let t=new r(this.#t.has(e));this.#a.set(e,t)}return this.#a.get(e)}add(e){this.#t.has(e)||(this.#t.add(e),this.#a.has(e)&&(this.#a.get(e).value=!0),this.notify(this.#t))}delete(e){this.#t.has(e)&&(this.#t.delete(e),this.#a.has(e)&&(this.#a.get(e).value=!1),this.notify(this.#t))}clear(){if(0!==this.#t.size){for(let e of(this.#t.clear(),this.#a.values()))e.value=!1;this.notify(this.#t)}}}class o extends s{#t;#s=new Map;#r=new Map;constructor(...e){super(),this.#t=new Map(...e)}get value(){return this.#t}has(e){if(!this.#s.has(e)){let t=new r(this.#t.has(e));this.#s.set(e,t)}return this.#s.get(e)}get(e){if(!this.#r.has(e)){let t=new r(this.#t.get(e));this.#r.set(e,t)}return this.#r.get(e)}set(e,t){this.#t.get(e)!==t&&(this.#t.set(e,t),this.#s.has(e)&&(this.#s.get(e).value=!0),this.#r.has(e)&&(this.#r.get(e).value=t),this.notify(this.#t))}delete(e){this.#t.has(e)&&(this.#t.delete(e),this.#s.has(e)&&(this.#s.get(e).value=!1),this.#r.has(e)&&(this.#r.get(e).value=void 0),this.notify(this.#t))}clear(){if(0!==this.#t.size){for(let e of(this.#t.clear(),this.#s.values()))e.value=!1;for(let e of this.#r.values())e.value=void 0;this.notify(this.#t)}}}},13865(e,t,a){a.d(t,{AI:()=>o,HN:()=>h,R:()=>l,Rs:()=>c,Sk:()=>p,XG:()=>n,tQ:()=>d});var s=a(16522),r=a(96540),i=a(13589);function o(e){let t,a=(0,s.c)(2);a[0]!==e?(t=()=>new i.Lj(e),a[0]=e,a[1]=t):t=a[1];let[o]=(0,r.useState)(t);return o}function n(e){let t,a,o=(0,s.c)(4),n=(0,r.useRef)(null);if(null===n.current){let t;o[0]!==e?(t=new i.Lj(e),o[0]=e,o[1]=t):t=o[1],n.current=t}o[2]===Symbol.for("react.memo_cache_sentinel")?(t=e=>{null!==n.current&&(n.current.value=e)},o[2]=t):t=o[2];let l=t;return o[3]===Symbol.for("react.memo_cache_sentinel")?(a=[n,l],o[3]=a):a=o[3],a}function l(...e){let t,a=(0,s.c)(2);a[0]!==e?(t=()=>new i.Es(...e),a[0]=e,a[1]=t):t=a[1];let[o]=(0,r.useState)(t);return o}let u=Symbol("no value");function c(e,t){let a,i,o=(0,s.c)(5),n=(0,r.useRef)(e.value),l=(0,r.useEffectEvent)(t);o[0]!==l||o[1]!==e?(a=()=>(n.current!==u&&n.current!==e.value&&(l(e.value),n.current=u),e.subscribe(e=>l(e))),o[0]=l,o[1]=e,o[2]=a):a=o[2],o[3]!==e?(i=[e],o[3]=e,o[4]=i):i=o[4],(0,r.useEffect)(a,i)}function h(e){let t,a=(0,s.c)(1),[i,o]=(0,r.useState)(e.value);return a[0]===Symbol.for("react.memo_cache_sentinel")?(t=e=>o(e),a[0]=t):t=a[0],c(e,t),i}function d(e){let t,a=(0,s.c)(2),[i,o]=(0,r.useState)(e.value),[,n]=(0,r.useReducer)(m,0);return a[0]!==n?(t=e=>{o(e),n()},a[0]=n,a[1]=t):t=a[1],c(e,t),i}function m(e){return e+1}function p(e,t){let a=o(t(e.value));return c(e,e=>{a.value=t(e)}),a}}}]); //# sourceMappingURL=6478-f2d569331647c986-40694abdd0eb1df1.js.map