"use strict";var e,t;function o(e){const{port1:t,port2:o}=new MessageChannel;return new Promise(((r,s)=>{try{parent.postMessage(e,"*",[o]),t.onmessage=e=>{const t=e.data;t.ok?r(t.data):s(t.data)}}catch(e){s(e)}}))}exports.CortexProtocolMessageType=void 0,(e=exports.CortexProtocolMessageType||(exports.CortexProtocolMessageType={})).Context="context",e.Fetch="fetch",e.Init="init",exports.PluginContextLocation=void 0,(t=exports.PluginContextLocation||(exports.PluginContextLocation={})).Entity="ENTITY",t.Global="GLOBAL";class r{cortexResponse;cortexBody;headers;ok;redirected;status;statusText;trailer;type;url;body;bodyUsed;constructor(e){this.cortexResponse=e,this.cortexBody=e.body,this.headers=new Headers(e.headers),this.ok=e.ok,this.redirected=e.redirected,this.status=e.status,this.trailer=Promise.resolve(new Headers(e.trailer)),this.type=e.type,this.url=e.url,this.body=new ReadableStream({start(e){e.enqueue(this.cortexBody),e.close()}}),this.bodyUsed=!1}clone(){return new r({...this.cortexResponse})}arrayBuffer(){const e=(new TextEncoder).encode(this.cortexBody);return Promise.resolve(e.buffer)}blob(){return Promise.reject("blob() unimplemented")}formData(){return Promise.reject("formData() unimplemented")}json(){try{return Promise.resolve(JSON.parse(this.cortexBody))}catch(e){return Promise.reject(e)}}text(){return Promise.resolve(this.cortexBody)}}const s={pluginInit:()=>{o({type:exports.CortexProtocolMessageType.Init})},getContext:async()=>await o({type:exports.CortexProtocolMessageType.Context}),proxyFetch:async(e,t)=>{const s=await o({init:t,input:e,type:exports.CortexProtocolMessageType.Fetch});return new r(s)}};var n,a;exports.CortexUserRoleType=void 0,(n=exports.CortexUserRoleType||(exports.CortexUserRoleType={})).BASIC="BASIC",n.CUSTOM="CUSTOM",exports.CortexBasicUserRole=void 0,(a=exports.CortexBasicUserRole||(exports.CortexBasicUserRole={})).MANAGER="MANAGER",a.OWNER="OWNER",a.USER="USER",a.VIEWER="VIEWER";function i(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var c=i((function(e){return null==e}));exports.CortexApi=s,exports.octokitPlugin=(e,{CortexApi:t})=>{e.hook.wrap("request",(async(e,o)=>{if(c(t))throw new Error("CortexApi is not defined -- pass it in as an option to the Octokit plugin constructor to make requests");const r=await t.proxyFetch((e=>{const{baseUrl:t,url:o,...r}=e;return`${t}${s=o,n=r,s.replace(/\{(.*?)}/g,((e,t)=>n[t]))}`;var s,n})(o),{headers:o.headers,method:o.method}),s=await r.json(),n={};return r.headers.forEach(((e,t)=>{n[t]=e})),{data:s,headers:n,status:r.status,url:r.url}}))},exports.postCortexMessage=o;
//# sourceMappingURL=index.cjs.js.map
