@bkm016/basalt 0.1.14 → 0.1.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (126) hide show
  1. package/{chunk-nysatg77.js → chunk-5n1qra6k.js} +45 -43
  2. package/{chunk-xk3t5ves.js → chunk-tszctb17.js} +130 -130
  3. package/compiled.js +1 -1
  4. package/package.json +1 -1
  5. package/ui-test-worker.js +1 -1
  6. package/web/chunk-00swes3c.js +1 -0
  7. package/web/{chunk-vg346gxc.js → chunk-01nbc18z.js} +1 -1
  8. package/web/chunk-0e995hjg.js +1 -0
  9. package/web/{chunk-y3tb6410.js → chunk-1bhpfsvr.js} +1 -1
  10. package/web/{chunk-w5q7978e.js → chunk-1v6hhgc6.js} +1 -1
  11. package/web/{chunk-qcdej581.js → chunk-251yw6f2.js} +1 -1
  12. package/web/{chunk-vpegzgzb.js → chunk-27cntdyk.js} +1 -1
  13. package/web/{chunk-kk5rw81s.js → chunk-2tm4xe0j.js} +1 -1
  14. package/web/{chunk-4qehf2xx.js → chunk-3egthz5k.js} +1 -1
  15. package/web/{chunk-tdzh6nsz.js → chunk-3f8fjee5.js} +1 -1
  16. package/web/chunk-3fjzgpaw.js +1 -0
  17. package/web/{chunk-d3hyf9yd.js → chunk-3hy2gsgf.js} +1 -1
  18. package/web/chunk-3mgzqbc8.js +1 -0
  19. package/web/chunk-3yvanftw.js +1 -0
  20. package/web/{chunk-ffywf5w5.js → chunk-3zs2v6b4.js} +1 -1
  21. package/web/{chunk-zx3h7v72.js → chunk-43194184.js} +1 -1
  22. package/web/{chunk-9h0f3gar.js → chunk-43bczb21.js} +1 -1
  23. package/web/{chunk-jzge034r.js → chunk-4m9mgdaa.js} +1 -1
  24. package/web/{chunk-2gvz70wr.js → chunk-4q2jtvwn.js} +1 -1
  25. package/web/{chunk-rjakb64x.js → chunk-4tbhxtnm.js} +1 -1
  26. package/web/{chunk-wspk8qbg.js → chunk-50vgq2nk.js} +1 -1
  27. package/web/{chunk-zkq1xknc.js → chunk-57b8j192.js} +1 -1
  28. package/web/{chunk-410qdvmv.js → chunk-5fzmk43v.js} +1 -1
  29. package/web/{chunk-we4mhfmq.js → chunk-5rwg3qqd.js} +1 -1
  30. package/web/{chunk-54mgncq3.js → chunk-62gj74fq.js} +1 -1
  31. package/web/chunk-64h7k870.js +1 -0
  32. package/web/{chunk-797bh7z6.js → chunk-65ay0j1t.js} +1 -1
  33. package/web/{chunk-y6mcxfm0.js → chunk-66164wmv.js} +1 -1
  34. package/web/{chunk-sgkevxdf.js → chunk-6s1vjny7.js} +1 -1
  35. package/web/{chunk-tjd8qp87.js → chunk-6x1hfjb9.js} +1 -1
  36. package/web/{chunk-zpzvz973.js → chunk-6xfbh4z5.js} +1 -1
  37. package/web/{chunk-3rxhs9qm.js → chunk-7frnjms9.js} +1 -1
  38. package/web/chunk-7jh6zxg3.js +1 -0
  39. package/web/chunk-7mgwejn4.js +1 -0
  40. package/web/{chunk-2c7kxr4v.js → chunk-8nm0mghm.js} +1 -1
  41. package/web/{chunk-ahn2frbt.js → chunk-8qzsxg1q.js} +1 -1
  42. package/web/{chunk-vxm7n7w6.js → chunk-937ndmh1.js} +1 -1
  43. package/web/chunk-95gbcs8j.js +1 -0
  44. package/web/{chunk-faskbfjf.js → chunk-aw6wg8fe.js} +1 -1
  45. package/web/{chunk-ppa21760.js → chunk-b323qea5.js} +1 -1
  46. package/web/{chunk-npw1s1h2.js → chunk-bcx7xges.js} +1 -1
  47. package/web/{chunk-k9fyqrhp.js → chunk-bzdn9sxz.js} +1 -1
  48. package/web/{chunk-c7fqrs8j.js → chunk-cq1f20k6.js} +1 -1
  49. package/web/{chunk-feanedhx.js → chunk-dde64qjd.js} +1 -1
  50. package/web/{chunk-p4pqtybm.js → chunk-dgepxev9.js} +2 -2
  51. package/web/{chunk-nfpff7yf.js → chunk-djnq1w1e.js} +2 -2
  52. package/web/{chunk-snaepr87.js → chunk-ea6b8b50.js} +1 -1
  53. package/web/{chunk-qftcdcps.js → chunk-ed5xfgxb.js} +1 -1
  54. package/web/{chunk-783s8jds.js → chunk-ehz9m6g4.js} +1 -1
  55. package/web/chunk-evp6t44y.js +8 -0
  56. package/web/chunk-eyg28s83.js +1 -0
  57. package/web/{chunk-r8p741qj.js → chunk-fttdbcqv.js} +1 -1
  58. package/web/chunk-g9bqacq1.js +1 -0
  59. package/web/chunk-gh8kjzdj.js +1 -0
  60. package/web/{chunk-ve9dz857.js → chunk-jab2p5zv.js} +1 -1
  61. package/web/{chunk-ysw5fs45.js → chunk-jca9xbe0.js} +1 -1
  62. package/web/chunk-jpf8x9tm.js +1 -0
  63. package/web/{chunk-3haw3wcw.js → chunk-jx3z63tq.js} +1 -1
  64. package/web/{chunk-ty2rmwda.js → chunk-jy448465.js} +89 -89
  65. package/web/{chunk-51b8n5e1.js → chunk-k3ah0513.js} +1 -1
  66. package/web/{chunk-dwtatme7.js → chunk-ksnsfqrn.js} +1 -1
  67. package/web/{chunk-ex8rmqn1.js → chunk-kxr473dw.js} +1 -1
  68. package/web/{chunk-wkhj4hsw.js → chunk-m5psa69k.js} +1 -1
  69. package/web/{chunk-8ttp8fh3.js → chunk-mss6eg27.js} +1 -1
  70. package/web/{chunk-g3szt4c4.js → chunk-mv9q8jrm.js} +1 -1
  71. package/web/{chunk-59g6rrew.js → chunk-n0ezfa12.js} +1 -1
  72. package/web/{chunk-mvm68qtt.js → chunk-p1bb9xp8.js} +1 -1
  73. package/web/{chunk-mv7jgmnb.js → chunk-pa82db2e.js} +1 -1
  74. package/web/{chunk-7hpqrfgg.js → chunk-pdmcr6d4.js} +1 -1
  75. package/web/{chunk-8sr9w61v.js → chunk-phj4pcx4.js} +1 -1
  76. package/web/{chunk-xhqvzmfj.js → chunk-pma5pats.js} +1 -1
  77. package/web/{chunk-ptpkv0te.js → chunk-pmghe7rh.js} +1 -1
  78. package/web/{chunk-s45g7fp6.js → chunk-ppfhtyxt.js} +1 -1
  79. package/web/chunk-pze2v3v1.js +2 -0
  80. package/web/{chunk-mn2wv9ye.js → chunk-q6j2e8a1.js} +1 -1
  81. package/web/chunk-q6jf3zc1.js +1 -0
  82. package/web/{chunk-xf1hnpme.js → chunk-qdn3hmfy.js} +1 -1
  83. package/web/{chunk-s2ps0ct5.js → chunk-qdsg8wp0.js} +1 -1
  84. package/web/{chunk-32dh0hft.js → chunk-qf2kb7zj.js} +1 -1
  85. package/web/{chunk-7kywe73f.js → chunk-s6bc73n3.js} +1 -1
  86. package/web/chunk-sdtesqbb.js +1 -0
  87. package/web/chunk-t0z8ygx4.js +1 -0
  88. package/web/{chunk-bahccwb9.js → chunk-t2v01k4z.js} +1 -1
  89. package/web/{chunk-zsat72qd.js → chunk-t5ke9cyg.js} +2 -2
  90. package/web/{chunk-j6wcszxq.js → chunk-t72z2ww3.js} +1 -1
  91. package/web/{chunk-ya696bfe.js → chunk-t78qm9gs.js} +1 -1
  92. package/web/{chunk-aknsydan.js → chunk-te15yhn5.js} +1 -1
  93. package/web/{chunk-2gsf89vs.js → chunk-tvaxyhh0.js} +1 -1
  94. package/web/{chunk-9vr6hpmk.js → chunk-vypfy030.js} +1 -1
  95. package/web/chunk-w7cyrbk2.js +1 -0
  96. package/web/{chunk-fx3d48e6.js → chunk-w9nkvcjr.js} +1 -1
  97. package/web/chunk-x2f8bwd2.js +1 -0
  98. package/web/chunk-xq8x7dvr.js +1 -0
  99. package/web/{chunk-p79c7aak.js → chunk-yeh77fvq.js} +1 -1
  100. package/web/{chunk-kpmd893m.js → chunk-ymtq18z6.js} +1 -1
  101. package/web/{chunk-s70aj1v5.js → chunk-yzmrbssn.js} +1 -1
  102. package/web/{chunk-988e9wx6.js → chunk-z5h046zm.js} +1 -1
  103. package/web/{chunk-78m018ya.js → chunk-zf4b8jb9.js} +1 -1
  104. package/web/index.html +1 -1
  105. package/web/sw.js +17 -1
  106. package/web/chunk-15g9pnzy.js +0 -1
  107. package/web/chunk-19tkjg9w.js +0 -1
  108. package/web/chunk-26sp6jre.js +0 -1
  109. package/web/chunk-2s3my1jn.js +0 -1
  110. package/web/chunk-6481wt3t.js +0 -1
  111. package/web/chunk-6m8hq6ph.js +0 -1
  112. package/web/chunk-9vrp249f.js +0 -2
  113. package/web/chunk-dcegr80c.js +0 -1
  114. package/web/chunk-gr1tjqbd.js +0 -1
  115. package/web/chunk-jge7nn3s.js +0 -1
  116. package/web/chunk-kg3tksv7.js +0 -1
  117. package/web/chunk-nk7jkpam.js +0 -1
  118. package/web/chunk-nmvt1rn3.js +0 -1
  119. package/web/chunk-nzzxv84v.js +0 -8
  120. package/web/chunk-rcexbkjj.js +0 -1
  121. package/web/chunk-say8bvkc.js +0 -1
  122. package/web/chunk-sjffrcq9.js +0 -1
  123. package/web/chunk-tncc9e57.js +0 -1
  124. package/web/chunk-v22hp18w.js +0 -1
  125. package/web/chunk-xq70hgre.js +0 -1
  126. package/web/chunk-zkv025s5.js +0 -1
package/compiled.js CHANGED
@@ -93,4 +93,4 @@ import{zr,jr,$n}from"./chunk-bjvv3403.js";import{G}from"./chunk-38g4jd6v.js";imp
93
93
  ${r?`<div class="details">${r}</div>`:""}
94
94
  </main>
95
95
  </body>
96
- </html>`}function Pt(e){return Vr({title:"Authentication successful",heading:"Authentication successful",message:e})}function P(e,t){return Vr({title:"Authentication failed",heading:"Authentication failed",message:e,details:t})}function Q(e,t,o){e.writeHead(t,{"content-type":"text/html; charset=utf-8","cache-control":"no-store"}),e.end(o)}async function K(e){let{providerName:t,signal:o}=e;if(o?.aborted)throw Error("Login cancelled");let n=()=>{},r=()=>{},s=new Promise((g,h)=>{n=g,r=h});s.catch(()=>{return});let i=!1,d=!1,c,u=()=>l({error:Error("Login cancelled")}),l=(g)=>{if(d)return;if(d=!0,c)clearTimeout(c);if(o?.removeEventListener("abort",u),"error"in g)r(g.error);else n(g.value)},p=Md((g,h)=>{(async()=>{let x=new URL(g.url??"/","http://localhost");if(g.method!=="GET"||x.pathname!==e.path){Q(h,404,P("Callback route not found."));return}if(e.state!==void 0&&x.searchParams.get("state")!==e.state){Q(h,400,P("State mismatch."));return}if(i||d){Q(h,409,P("This sign-in has already been handled."));return}let I=x.searchParams.get("error");if(I){let S=x.searchParams.get("error_description")??I;Q(h,400,P(`${t} authorization failed.`,S)),l({error:Error(`${t} authorization failed: ${S}`)});return}let R=x.searchParams.get("code");if(!R){Q(h,400,P("Missing authorization code."));return}i=!0;try{let S=await e.complete(R);Q(h,200,Pt(`Signed in to ${t}. You may now close this page.`)),l({value:S})}catch(S){let D=S instanceof Error?S:Error(String(S));Q(h,502,P(`${t} sign-in failed.`,D.message)),l({error:D})}})()});await new Promise((g,h)=>{p.once("error",h),p.listen(e.port,e.host,()=>{p.off("error",h),g()})});let C=p.address();if(!C||typeof C==="string")throw p.close(),Error("OAuth callback server did not bind to TCP");if(p.on("error",(g)=>l({error:g})),o?.addEventListener("abort",u,{once:!0}),e.timeoutMs!==void 0)c=setTimeout(()=>l({error:Error(`${t} sign-in timed out`)}),e.timeoutMs);let m=e.redirectHost??e.host;return{redirectUri:`http://${m.includes(":")?`[${m}]`:m}:${C.port}${e.path}`,wait:()=>s,cancel:()=>{if(!i)l({value:void 0})},close:()=>{l({error:Error("OAuth callback server closed")}),p.close()}}}async function ve(e,t,o){let n=new AbortController,r,s=e.prompt({type:"manual_code",...o,signal:n.signal}).then((i)=>(t?.cancel(),i)).catch((i)=>{r=i instanceof Error?i:Error(String(i)),t?.cancel();return});try{let i=await t?.wait();if(r)throw r;if(i!==void 0)return{type:"callback",value:i};let d=await s;if(r)throw r;return{type:"manual",input:d??""}}finally{n.abort()}}function Kr(e){let t="";for(let o of e)t+=String.fromCharCode(o);return btoa(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}async function N(){let e=new Uint8Array(32);crypto.getRandomValues(e);let t=Kr(e),n=new TextEncoder().encode(t),r=await crypto.subtle.digest("SHA-256",n),s=Kr(new Uint8Array(r));return{verifier:t,challenge:s}}var Ud=(e)=>atob(e),Gt=Ud("OWQxYzI1MGEtZTYxYi00NGQ5LTg4ZWQtNTk0NGQxOTYyZjVl"),Yr="https://claude.ai/oauth/authorize",Re="https://platform.claude.com/v1/oauth/token",Bd=_("PI_OAUTH_CALLBACK_HOST")||"127.0.0.1",Qr=53692,Zr="/callback",Dd=`http://localhost:${Qr}${Zr}`,Xr="https://platform.claude.com/oauth/code/callback",qr="browser",Jr="copy_code",es="org:create_api_key user:profile user:inference user:sessions:claude_code user:mcp_servers user:file_upload";function ts(e){let t=e.trim();if(!t)return{};try{let o=new URL(t);return{code:o.searchParams.get("code")??void 0,state:o.searchParams.get("state")??void 0}}catch{}if(t.includes("#")){let[o,n]=t.split("#",2);return{code:o,state:n}}if(t.includes("code=")){let o=new URLSearchParams(t);return{code:o.get("code")??void 0,state:o.get("state")??void 0}}return{code:t}}function Fe(e){if(e instanceof Error){let t=[`${e.name}: ${e.message}`],o=e;if(o.code)t.push(`code=${o.code}`);if(typeof o.errno<"u")t.push(`errno=${String(o.errno)}`);if(typeof e.cause<"u")t.push(`cause=${Fe(e.cause)}`);if(e.stack)t.push(`stack=${e.stack}`);return t.join("; ")}return String(e)}async function os(e,t,o){let n=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify(t),signal:AbortSignal.any([o,AbortSignal.timeout(30000)])}),r=await n.text();if(!n.ok)throw Error(`HTTP request failed. status=${n.status}; url=${e}; body=${r}`);return r}async function ns(e,t,o,n,r){let s;try{s=await os(Re,{grant_type:"authorization_code",client_id:Gt,code:e,state:t,redirect_uri:n,code_verifier:o},r)}catch(d){throw Error(`Token exchange request failed. url=${Re}; redirect_uri=${n}; response_type=authorization_code; details=${Fe(d)}`)}let i;try{i=JSON.parse(s)}catch(d){throw Error(`Token exchange returned invalid JSON. url=${Re}; body=${s}; details=${Fe(d)}`)}return{type:"oauth",refresh:i.refresh_token,access:i.access_token,expires:Date.now()+i.expires_in*1000-300000}}async function $d(e){let{verifier:t,challenge:o}=await N(),n=(i)=>K({providerName:"Anthropic",host:Bd,port:i,path:Zr,redirectHost:"localhost",state:t,complete:async(d)=>d,signal:e.signal}),r=await n(Qr).catch(()=>n(0)).catch(()=>{return}),s=r?.redirectUri??Dd;try{let i=new URLSearchParams({code:"true",client_id:Gt,response_type:"code",redirect_uri:s,scope:es,code_challenge:o,code_challenge_method:"S256",state:t});e.notify({type:"auth_url",url:`${Yr}?${i.toString()}`,instructions:"Complete login in your browser. If the browser is on another machine, paste the final redirect URL here."});let d=await ve(e,r,{message:"Complete login in your browser, or paste the authorization code / redirect URL here:",placeholder:s}),c,u=t;if(d.type==="callback")c=d.value;else{let l=ts(d.input);if(l.state&&l.state!==t)throw Error("OAuth state mismatch");c=l.code,u=l.state??t}if(!c)throw Error("Missing authorization code");return e.notify({type:"progress",message:"Exchanging authorization code for tokens..."}),await ns(c,u,t,s,e.signal)}finally{r?.close()}}async function Fd(e){let{verifier:t,challenge:o}=await N(),n=new URLSearchParams({code:"true",client_id:Gt,response_type:"code",redirect_uri:Xr,scope:es,code_challenge:o,code_challenge_method:"S256",state:t});e.notify({type:"auth_url",url:`${Yr}?${n.toString()}`,instructions:"Complete login in your browser, then copy the code Anthropic shows and paste it here."});let r=await e.prompt({type:"manual_code",message:"Paste the code Anthropic shows after you sign in:",placeholder:"code#state",signal:e.signal}),s=ts(r);if(s.state&&s.state!==t)throw Error("OAuth state mismatch");if(!s.code)throw Error("Missing authorization code");return e.notify({type:"progress",message:"Exchanging authorization code for tokens..."}),await ns(s.code,s.state??t,t,Xr,e.signal)}async function Hd(e,t){let o;try{o=await os(Re,{grant_type:"refresh_token",client_id:Gt,refresh_token:e},t)}catch(r){throw Error(`Anthropic token refresh request failed. url=${Re}; details=${Fe(r)}`)}let n;try{n=JSON.parse(o)}catch(r){throw Error(`Anthropic token refresh returned invalid JSON. url=${Re}; body=${o}; details=${Fe(r)}`)}return{type:"oauth",refresh:n.refresh_token,access:n.access_token,expires:Date.now()+n.expires_in*1000-300000}}var rs={name:"Anthropic (Claude Pro/Max)",isSubscription:!0,async login(e){let t=await e.prompt({type:"select",message:"Select Anthropic login method:",options:[{id:qr,label:"Browser login (default)"},{id:Jr,label:"Copy code login (headless)"}]});if(t===Jr)return Fd(e);if(t!==qr)throw Error(`Unknown Anthropic login method: ${t}`);return $d(e)},refresh:(e,t)=>Hd(e.refresh,t),async toAuth(e){return{apiKey:e.access}}};function bt(e,t){return new Promise((o,n)=>{t.throwIfAborted();let r=()=>{clearTimeout(s),n(t.reason)},s=setTimeout(()=>{t.removeEventListener("abort",r),o()},e);t.addEventListener("abort",r,{once:!0})})}function ss(e,t,o){return new Promise((n,r)=>{if(t.aborted){r(Error(o));return}let s=()=>{clearTimeout(i),r(Error(o))},i=setTimeout(()=>{t.removeEventListener("abort",s),n()},e);t.addEventListener("abort",s,{once:!0})})}async function b(e){let t=typeof e.expiresInSeconds==="number"?Date.now()+e.expiresInSeconds*1000:Number.POSITIVE_INFINITY,o=Math.max(1000,Math.floor((e.intervalSeconds??5)*1000)),n=0;if(e.waitBeforeFirstPoll){let r=t-Date.now();if(r>0)await ss(Math.min(o,r),e.signal,"Login cancelled")}while(Date.now()<t){if(e.signal.aborted)throw Error("Login cancelled");let r=await e.poll();if(r.status==="complete")return r.value;if(r.status==="failed")throw Error(r.message);if(r.status==="slow_down")n+=1,o=typeof r.intervalSeconds==="number"&&Number.isFinite(r.intervalSeconds)&&r.intervalSeconds>0?Math.max(1000,Math.floor(r.intervalSeconds*1000)):Math.max(1000,o+5000);let s=t-Date.now();if(s<=0)break;await ss(Math.min(o,s),e.signal,"Login cancelled")}throw Error(n>0?"Device flow timed out after one or more slow_down responses. This is often caused by clock drift in WSL or VM environments. Please sync or restart the VM clock and try again.":"Device flow timed out")}var Wd=(e)=>atob(e),as=Wd("SXYxLmI1MDdhMDhjODdlY2ZlOTg="),lo={"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},Vd="2026-06-01";function cs(e){let t=e.trim();if(!t)return null;try{return(t.includes("://")?new URL(t):new URL(`https://${t}`)).hostname}catch{return null}}function po(e){return{deviceCodeUrl:`https://${e}/login/device/code`,accessTokenUrl:`https://${e}/login/oauth/access_token`,copilotTokenUrl:`https://api.${e}/copilot_internal/v2/token`}}function Kd(e){let t=e.match(/proxy-ep=([^;]+)/);if(!t)return null;return`https://${t[1].replace(/^proxy\./,"api.")}`}function _o(e,t){if(e){let o=Kd(e);if(o)return o}if(t)return`https://copilot-api.${t}`;return"https://api.individual.githubcopilot.com"}function We(e){return e&&typeof e==="object"?e:void 0}function jd(e,t){let o=We(e)?.data;if(!Array.isArray(o))throw Error("Invalid Copilot models response");let n=o.flatMap((c)=>{let u=We(c),l=u?.id;if(!u||typeof l!=="string")return[];let p=We(u.capabilities);if(We(p?.supports)?.tool_calls===!1)return[];return[{id:l,pickerEnabled:u.model_picker_enabled===!0,policyState:We(u.policy)?.state}]}),r=n.filter((c)=>c.pickerEnabled&&c.policyState!=="disabled").map((c)=>c.id),s=t&&r.length===0,i=r.length>0||!t?r:n.filter((c)=>c.policyState==="enabled").map((c)=>c.id),d=n.filter((c)=>c.policyState==="unconfigured"&&Object.hasOwn($r,c.id)&&(c.pickerEnabled||s)).map((c)=>c.id);return{availableModelIds:i,policyModelIds:d}}async function ds(e,t,o,n){let r=n.maxRetries>0&&n.maxElapsedMs>0?AbortSignal.timeout(n.maxElapsedMs):void 0,s=r?AbortSignal.any([o,r]):o,i=r?Date.now()+n.maxElapsedMs:void 0;for(let d=0;;d++){let c=await fetch(e,{...t,signal:AbortSignal.any([s,AbortSignal.timeout(5000)])});if(c.status!==429||d===n.maxRetries)return c;let u=c.headers.get("retry-after"),l=500*2**d;if(u){let p=Number.parseFloat(u);if(l=Number.isNaN(p)?Date.parse(u)-Date.now():p*1000,!Number.isFinite(l))return c}if(l=Math.max(0,l),i!==void 0&&l>=i-Date.now())return c;await c.body?.cancel(),await bt(l,s)}}async function us(e,t,o,n){let r=_o(e,t),s=r==="https://api.individual.githubcopilot.com",i=await ds(`${r}/models`,{headers:{Accept:"application/json",Authorization:`Bearer ${e}`,...lo,"X-GitHub-Api-Version":Vd}},o,n);if(!i.ok)throw Error(`${i.status} ${i.statusText}: ${await i.text()}`);return jd(await i.json(),s)}async function ho(e,t){let o=await fetch(e,t);if(!o.ok){let n=await o.text();throw Error(`${o.status} ${o.statusText}: ${n}`)}return o.json()}async function zd(e,t){let o=po(e),n=await ho(o.deviceCodeUrl,{method:"POST",headers:{Accept:"application/json","Content-Type":"application/x-www-form-urlencoded","User-Agent":"GitHubCopilotChat/0.35.0"},body:new URLSearchParams({client_id:as,scope:"read:user"}),signal:t});if(!n||typeof n!=="object")throw Error("Invalid device code response");let{device_code:r,user_code:s,verification_uri:i,interval:d,expires_in:c}=n;if(typeof r!=="string"||typeof s!=="string"||typeof i!=="string"||d!==void 0&&typeof d!=="number"||typeof c!=="number")throw Error("Invalid device code response fields");let u;try{u=new URL(i)}catch{throw Error("Untrusted verification_uri in device code response")}if(u.protocol!=="https:"&&u.protocol!=="http:")throw Error("Untrusted verification_uri in device code response");return{device_code:r,user_code:s,verification_uri:u.href,interval:d,expires_in:c}}async function Xd(e,t,o){let n=po(e);return b({intervalSeconds:t.interval,expiresInSeconds:t.expires_in,waitBeforeFirstPoll:!0,signal:o,poll:async()=>{let r=await ho(n.accessTokenUrl,{method:"POST",headers:{Accept:"application/json","Content-Type":"application/x-www-form-urlencoded","User-Agent":"GitHubCopilotChat/0.35.0"},body:new URLSearchParams({client_id:as,device_code:t.device_code,grant_type:"urn:ietf:params:oauth:grant-type:device_code"}),signal:o});if(r&&typeof r==="object"&&typeof r.access_token==="string")return{status:"complete",value:r.access_token};if(r&&typeof r==="object"&&typeof r.error==="string"){let{error:s,error_description:i,interval:d}=r;if(s==="authorization_pending")return{status:"pending"};if(s==="slow_down")return{status:"slow_down",intervalSeconds:typeof d==="number"?d:void 0};let c=i?`: ${i}`:"";return{status:"failed",message:`Device flow failed: ${s}${c}`}}return{status:"failed",message:"Invalid device token response"}}})}async function ls(e,t,o){let r=po(t||"github.com"),s=await ho(r.copilotTokenUrl,{headers:{Accept:"application/json",Authorization:`Bearer ${e}`,...lo},signal:o});if(!s||typeof s!=="object")throw Error("Invalid Copilot token response");let{token:i,expires_at:d}=s;if(typeof i!=="string"||typeof d!=="number")throw Error("Invalid Copilot token response fields");return{type:"oauth",refresh:e,access:i,expires:d*1000-300000,enterpriseUrl:t}}async function qd(e,t,o){let n=await ls(e,t,o),{availableModelIds:r}=await us(n.access,t,o,{maxRetries:0,maxElapsedMs:0});return{...n,availableModelIds:r}}async function Jd(e,t,o,n){let s=`${_o(e,o)}/models/${t}/policy`,i;try{i=await ds(s,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${e}`,...lo,"openai-intent":"chat-policy","x-interaction-type":"chat-policy"},body:JSON.stringify({state:"enabled"})},n,{maxRetries:2,maxElapsedMs:5000})}catch(d){if(n.aborted)throw d;return!1}if(i.status===429)throw Error(`${i.status} ${i.statusText}: ${await i.text()}`);return i.ok}async function Yd(e,t,o,n){let r=[];for(let s of t)try{if(await Jd(e,s,o,n))r.push(s)}catch(i){if(n.aborted)throw i;break}return r}async function Qd(e){let t=await e.prompt({type:"text",message:"GitHub Enterprise URL/domain (blank for github.com)",placeholder:"company.ghe.com"});if(e.signal.aborted)throw Error("Login cancelled");let o=t.trim(),n=cs(t);if(o&&!n)throw Error("Invalid GitHub Enterprise URL/domain");let r=n||"github.com",s=await zd(r,e.signal);e.notify({type:"device_code",userCode:s.user_code,verificationUri:s.verification_uri,intervalSeconds:s.interval,expiresInSeconds:s.expires_in});let i=await Xd(r,s,e.signal),d=await ls(i,n??void 0,e.signal),c=await us(d.access,n??void 0,e.signal,{maxRetries:2,maxElapsedMs:5000}),u=[];if(c.policyModelIds.length>0)e.notify({type:"progress",message:"Enabling models..."}),u=await Yd(d.access,c.policyModelIds,n??void 0,e.signal);return{...d,availableModelIds:[...new Set([...c.availableModelIds,...u])]}}function is(e){let t=e.enterpriseUrl;if(typeof t!=="string"||!t)return;return cs(t)??void 0}var ps={name:"GitHub Copilot",isSubscription:!0,login:Qd,refresh:(e,t)=>qd(e.refresh,is(e),t),async toAuth(e){return{apiKey:e.access,baseUrl:_o(e.access,is(e))}}};var fo="17e5f671-d194-4dfb-9706-5516cb48c098",Zd="https://auth.kimi.com",eu=900,tu=5,ou=30000,_s=3;function fs(){return(_("KIMI_CODE_OAUTH_HOST")||_("KIMI_OAUTH_HOST")||Zd).replace(/\/+$/,"")}function mo(e){return AbortSignal.any([AbortSignal.timeout(ou),e])}function go(e){return new URLSearchParams(e).toString()}async function Co(e){try{let t=await e.json();return t&&typeof t==="object"?t:null}catch{return null}}function hs(e){if(typeof e!=="string"||!e)return null;try{let t=new URL(e);if(t.protocol!=="https:"&&t.protocol!=="http:")return null;return t.href}catch{return null}}async function nu(e,t){let o=await fetch(`${e}/api/oauth/device_authorization`,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json"},body:go({client_id:fo}),signal:mo(t)});if(!o.ok){let l=await o.text().catch(()=>"");throw Error(`Kimi Code device authorization failed with status ${o.status}${l?`: ${l}`:""}`)}let n=await Co(o),r=n?.device_code,s=n?.user_code,i=n?.verification_uri,d=n?.verification_uri_complete;if(typeof r!=="string"||typeof s!=="string"||typeof i!=="string"||typeof d!=="string"||!hs(d)||!hs(i))throw Error(`Invalid Kimi Code device authorization response: ${JSON.stringify(n)}`);let c=n?.interval,u=n?.expires_in;return{deviceCode:r,userCode:s,verificationUri:i,verificationUriComplete:d,intervalSeconds:typeof c==="number"&&Number.isFinite(c)&&c>0?c:tu,expiresInSeconds:typeof u==="number"&&Number.isFinite(u)&&u>0?u:eu}}function ms(e,t){let o=e?.access_token,n=e?.refresh_token,r=e?.expires_in;if(typeof o!=="string"||!o||typeof n!=="string"||!n||typeof r!=="number"||!Number.isFinite(r)||r<=0)throw Error(`Kimi Code token ${t} response missing fields: ${JSON.stringify(e)}`);return{access:o,refresh:n,expires:Date.now()+r*1000}}async function ru(e,t,o){return b({intervalSeconds:t.intervalSeconds,expiresInSeconds:t.expiresInSeconds,waitBeforeFirstPoll:!0,signal:o,poll:async()=>{let n=await fetch(`${e}/api/oauth/token`,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json"},body:go({client_id:fo,device_code:t.deviceCode,grant_type:"urn:ietf:params:oauth:grant-type:device_code"}),signal:mo(o)});if(n.status>=500){let d=await n.text().catch(()=>"");return{status:"failed",message:`Kimi Code device token request failed with status ${n.status}${d?`: ${d}`:""}`}}let r=await Co(n);if(n.ok&&typeof r?.access_token==="string")try{return{status:"complete",value:ms(r,"poll")}}catch(d){return{status:"failed",message:d instanceof Error?d.message:String(d)}}let s=r?.error,i=typeof r?.error_description==="string"?`: ${r.error_description}`:"";if(s==="authorization_pending")return{status:"pending"};if(s==="slow_down"){let d=r?.interval;return{status:"slow_down",intervalSeconds:typeof d==="number"&&d>0?d:void 0}}if(s==="expired_token")return{status:"failed",message:"Kimi Code device authorization expired. Please restart login."};if(s==="access_denied")return{status:"failed",message:"Kimi Code login was denied."};return{status:"failed",message:`Kimi Code device token request failed (status ${n.status})${typeof s==="string"?`: ${s}${i}`:""}`}}})}function su(e){return e.status===429||e.status>=500}async function iu(e,t,o){let n;for(let r=0;r<=_s;r++){if(r>0)await bt(1000*2**(r-1),o);if(o.aborted)throw Error("Kimi Code token refresh aborted");let s;try{s=await fetch(`${e}/api/oauth/token`,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json"},body:go({client_id:fo,grant_type:"refresh_token",refresh_token:t}),signal:mo(o)})}catch(c){n=c instanceof Error?c:Error(String(c));continue}let i=await Co(s);if(s.ok)return ms(i,"refresh");if(s.status===401||s.status===403||i?.error==="invalid_grant"){let c=typeof i?.error_description==="string"?`: ${i.error_description}`:"";throw Error(`Kimi Code token refresh unauthorized (status ${s.status})${c}`)}if(su(s)&&r<_s){n=Error(`Kimi Code token refresh failed with status ${s.status}`);continue}let d=JSON.stringify(i);throw Error(`Kimi Code token refresh failed with status ${s.status}${d?`: ${d}`:""}`)}throw n??Error("Kimi Code token refresh failed")}async function au(e){let t=fs(),o=await nu(t,e.signal);e.notify({type:"device_code",userCode:o.userCode,verificationUri:o.verificationUriComplete,intervalSeconds:o.intervalSeconds,expiresInSeconds:o.expiresInSeconds});let n=await ru(t,o,e.signal);return{type:"oauth",access:n.access,refresh:n.refresh,expires:n.expires}}var gs={name:"Kimi Code (subscription)",isSubscription:!0,loginLabel:"Sign in with Kimi Code",login:au,refresh:async(e,t)=>{let o=await iu(fs(),e.refresh,t);return{type:"oauth",access:o.access,refresh:o.refresh,expires:o.expires}},async toAuth(e){return{headers:{Authorization:`Bearer ${e.access}`}}}};var Cs="1031625952748946",Ss="https://auth.meta.com",cu=`${Ss}/oidc/device/authorization/`,du=`${Ss}/oidc/device/token/`,uu="https://api.meta.ai/muse-code/key",lu=86400000,pu=30000;function vo(e){return AbortSignal.any([AbortSignal.timeout(pu),e])}async function Ao(e){try{let t=await e.json();return t&&typeof t==="object"?t:null}catch{return null}}function Nt(e){for(let t of["error_description","detail","message","error"]){let o=e?.[t];if(typeof o==="string"&&o.trim())return`: ${o.trim()}`}return""}function So(e){if(typeof e!=="string"||!e)return null;try{let t=new URL(e);if(t.protocol!=="https:"&&t.protocol!=="http:")return null;return t.href}catch{return null}}function Eo(e){return typeof e==="number"&&Number.isFinite(e)&&e>0?e:void 0}async function _u(e){let t=await fetch(cu,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json"},body:new URLSearchParams({client_id:Cs}).toString(),signal:vo(e)}),o=await Ao(t);if(!t.ok)throw Error(`Meta device authorization failed with status ${t.status}${Nt(o)}`);let n=o?.device_code,r=o?.user_code,s=So(o?.verification_uri_complete)??So(o?.verification_uri);if(typeof n!=="string"||!n||typeof r!=="string"||!r||!s)throw Error(`Invalid Meta device authorization response: ${JSON.stringify(o)}`);return{deviceCode:n,userCode:r,verificationUri:s,intervalSeconds:Eo(o?.interval),expiresInSeconds:Eo(o?.expires_in)}}async function hu(e,t){return b({intervalSeconds:e.intervalSeconds,expiresInSeconds:e.expiresInSeconds,waitBeforeFirstPoll:!0,signal:t,poll:async()=>{let o=await fetch(du,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json"},body:new URLSearchParams({grant_type:"urn:ietf:params:oauth:grant-type:device_code",device_code:e.deviceCode,client_id:Cs}).toString(),signal:vo(t)}),n=await Ao(o);if(o.ok&&typeof n?.access_token==="string"&&n.access_token)return{status:"complete",value:n.access_token};switch(n?.error){case"authorization_pending":return{status:"pending"};case"slow_down":return{status:"slow_down",intervalSeconds:Eo(n?.interval)};case"access_denied":return{status:"failed",message:"Meta login was denied."};case"expired_token":return{status:"failed",message:"Meta device authorization expired. Please restart login."};default:return{status:"failed",message:`Meta device token request failed with status ${o.status}${Nt(n)}`}}}})}async function Es(e,t){let o=await fetch(uu,{method:"POST",headers:{Accept:"application/json",Authorization:`Bearer ${e}`,"Content-Type":"application/json","x-api-version":"1.0.0"},body:"{}",signal:vo(t)}),n=await Ao(o);if(o.status===401||o.status===403)throw Error(`Meta session expired (status ${o.status}). Run \`/login meta\` to sign in again.${Nt(n)}`);if(!o.ok)throw Error(`Meta API key mint failed with status ${o.status}${Nt(n)}`);let r=n?.api_key;if(typeof r!=="string"||!r){let s=So(n?.action_url);throw Error(`Meta did not issue an API key.${s?` Complete setup at ${s}`:""}`)}return{type:"oauth",refresh:e,access:r,expires:Date.now()+lu}}async function fu(e){try{let t=await _u(e.signal);e.notify({type:"device_code",userCode:t.userCode,verificationUri:t.verificationUri,intervalSeconds:t.intervalSeconds,expiresInSeconds:t.expiresInSeconds});let o=await hu(t,e.signal);return e.notify({type:"progress",message:"Enabling Meta Model API access..."}),await Es(o,e.signal)}catch(t){if(e.signal.aborted)throw Error("Login cancelled");throw t}}var vs={name:"Meta (Muse subscription)",isSubscription:!0,loginLabel:"Sign in with Meta",login:fu,refresh:(e,t)=>Es(e.refresh,t),async toAuth(e){return{apiKey:e.access}}};import{randomBytes as mu}from"crypto";import{createServer as gu}from"http";var Cu="dynamic_agent_client",Su="Pi",Eu=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,vu="https://auth.openai.com/api/accounts/authorize",Au="https://auth.openai.com/api/accounts/oauth/token",xo="https://api.openai.com/v1",Ru=_("PI_OAUTH_CALLBACK_HOST")||"127.0.0.1",Io=1455,Rs="/auth/callback",ye=`http://127.0.0.1:${Io}${Rs}`,yo="chatgpt.tokens.use.direct",yu=`openid profile email offline_access resource.invoke ${yo}`,xu=180000;function As(){return mu(32).toString("base64url")}function ys(e,t){let o=e.searchParams.get("code");if(!o)throw Error("Missing authorization code");let n=e.searchParams.get("state");if(!n)throw Error("Missing OAuth state");if(n!==t)throw Error("OAuth state mismatch");let r=e.searchParams.get("client_id")?.trim();if(!r)throw Error("OpenAI OAuth registration callback did not contain an issued client ID");return{code:o,clientId:r}}function Iu(e,t){let o;try{o=new URL(e.trim())}catch{throw Error("Paste the full callback URL from the browser")}let n=new URL(ye);if(o.origin!==n.origin||o.pathname!==n.pathname)throw Error(`The pasted callback URL must start with ${ye}`);let r=o.searchParams.get("error");if(r)throw Error(`ChatGPT authorization failed: ${r}`);return ys(o,t)}function Ve(e,t,o){e.writeHead(t,{"Content-Type":"text/html; charset=utf-8"}),e.end(o)}function Tu(e){return new Promise((t,o)=>{let n,r,s=new Promise((d,c)=>{n=d,r=c}),i=gu((d,c)=>{try{let u=new URL(d.url||"",ye);if(u.pathname!==Rs){Ve(c,404,P("Callback route not found."));return}let l=u.searchParams.get("error");if(l){Ve(c,400,P("ChatGPT was not connected.",`Error: ${l}`)),r(Error(`ChatGPT authorization failed: ${l}`));return}let p;try{p=ys(u,e)}catch(C){let m=C instanceof Error?C.message:"Invalid callback";Ve(c,400,P(m));return}Ve(c,200,Pt("ChatGPT authentication completed. You can close this window.")),n(p)}catch{Ve(c,500,P("Internal error while processing the callback."))}});i.once("error",o),i.listen(Io,Ru,()=>{i.removeListener("error",o),i.on("error",r),t({server:i,result:s})})})}async function xs(e,t){let o=await fetch(Au,{method:"POST",headers:{accept:"application/json","content-type":"application/x-www-form-urlencoded"},body:e,signal:t});if(!o.ok){let r=await o.text().catch(()=>"");throw Error(`OpenAI OAuth token request failed (${o.status}): ${r||o.statusText}`)}let n=await o.json();if(typeof n!=="object"||n===null||Array.isArray(n))throw Error("OpenAI OAuth token response must be an object");return n}function Ro(e,t){if(typeof e!=="string"||e.trim().length===0)throw Error(`OpenAI OAuth token response has invalid ${t}`);return e}function Is(e,t,o){let n=Ro(e.access_token,"access_token"),r=Ro(e.refresh_token,"refresh_token"),s=Ro(e.scope,"scope"),i=typeof e.id_token==="string"?e.id_token:o?.idToken;if(typeof e.expires_in!=="number"||!Number.isFinite(e.expires_in)||e.expires_in<=0)throw Error("OpenAI OAuth token response has invalid expires_in");let d=s.trim().split(/\s+/).filter(Boolean);if(!d.includes(yo))throw Error(`OpenAI OAuth grant did not include ${yo}`);return{type:"oauth",...i?{idToken:i}:{},access:n,refresh:r,expires:Date.now()+e.expires_in*1000-xu,clientId:t,scopes:d}}async function wu(e,t,o,n){let r=await xs(new URLSearchParams({grant_type:"authorization_code",client_id:o,code:e,code_verifier:t,redirect_uri:ye,resource:xo}),n);if(typeof r.id_token!=="string"||r.id_token.trim().length===0)throw Error("OpenAI OAuth token response did not contain an ID token");return Is(r,o)}async function ku(e,t){let o=e.clientId;if(typeof o!=="string"||o.trim().length===0)throw Error("Stored OpenAI OAuth credential does not contain an issued client ID; reconnect ChatGPT");let n=await xs(new URLSearchParams({grant_type:"refresh_token",client_id:o,refresh_token:e.refresh,resource:xo}),t);return Is(n,o,e)}function Ou(e){if(!e||!Eu.test(e))throw Error("Sign in with ChatGPT requires a device ID (UUID) for this installation");return`urn:uuid:${e.toLowerCase()}`}async function Pu(e,t){let o=Ou(t?.getDeviceId?.()),{verifier:n,challenge:r}=await N(),s=As(),i=As(),d=await Tu(s).catch((p)=>{if(!(p instanceof Error&&("code"in p)&&p.code==="EADDRINUSE"))throw p;throw Error(`Port ${Io} is in use, probably by an unfinished login in another pi session or by the Codex CLI. Cancel that login and try again.`)}),c=new URL(vu);c.search=new URLSearchParams({client_id:Cu,agent_name_hint:t?.agentName??Su,ext_agent_host_id:o,response_type:"code",redirect_uri:ye,resource:xo,scope:yu,state:s,code_challenge:r,code_challenge_method:"S256",nonce:i}).toString(),e.notify({type:"auth_url",url:c.toString(),instructions:"Complete sign-in in your browser. If the callback does not complete, paste the final redirect URL here."});let u=new AbortController,l=e.prompt({type:"manual_code",message:"Complete login in your browser, or paste the final redirect URL here:",placeholder:ye,signal:AbortSignal.any([u.signal,e.signal])}).then((p)=>Iu(p,s));try{let p=await Promise.race([d.result,l]);return e.notify({type:"progress",message:"Exchanging authorization code for tokens..."}),await wu(p.code,n,p.clientId,e.signal)}catch(p){if(e.signal.aborted)throw Error("Login cancelled");throw p}finally{u.abort(),d.server.close(),d.server.closeAllConnections()}}var Ts={name:"OpenAI (ChatGPT subscription)",isSubscription:!0,loginLabel:"Sign in with ChatGPT",login:Pu,refresh:ku,async toAuth(e){return{apiKey:e.access}}};var To=null;if(typeof process<"u"&&(process.versions?.node||process.versions?.bun))import("crypto").then((e)=>{To=e.randomBytes});var Lt="app_EMoamEEZ73f0CkXaXp7hrann",xe="https://auth.openai.com",Gu=`${xe}/oauth/authorize`,Os=`${xe}/oauth/token`,wo="http://localhost:1455/auth/callback",bu=`${xe}/api/accounts/deviceauth/usercode`,Nu=`${xe}/api/accounts/deviceauth/token`,Lu=`${xe}/codex/device`,Mu=`${xe}/deviceauth/callback`,Ps=900,ws="browser",ks="device_code",Uu="openid profile email offline_access",Bu="https://api.openai.com/auth";function Du(){return _("PI_OAUTH_CALLBACK_HOST")||"127.0.0.1"}function $u(){if(!To)throw Error("OpenAI Codex OAuth is only available in Node.js environments");return To(16).toString("hex")}function Fu(e){let t=e.trim();if(!t)return{};try{let o=new URL(t);return{code:o.searchParams.get("code")??void 0,state:o.searchParams.get("state")??void 0}}catch{}if(t.includes("#")){let[o,n]=t.split("#",2);return{code:o,state:n}}if(t.includes("code=")){let o=new URLSearchParams(t);return{code:o.get("code")??void 0,state:o.get("state")??void 0}}return{code:t}}function Hu(e){try{let t=e.split(".");if(t.length!==3)return null;let o=t[1]??"",n=atob(o);return JSON.parse(n)}catch{return null}}async function ko(e,t){try{return await fetch(e,t)}catch(o){if(t.signal?.aborted)throw Error("Login cancelled");throw o}}async function Gs(e,t){if(!e.ok){let r=await e.text().catch(()=>"");throw Error(`OpenAI Codex token ${t} failed (${e.status}): ${r||e.statusText}`)}let n=await e.json();if(!n?.access_token||!n.refresh_token||typeof n.expires_in!=="number")throw Error(`OpenAI Codex token ${t} response missing fields: ${JSON.stringify(n)}`);return{access:n.access_token,refresh:n.refresh_token,expires:Date.now()+n.expires_in*1000}}async function Wu(e,t,o,n){let r=await ko(Os,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams({grant_type:"authorization_code",client_id:Lt,code:e,code_verifier:t,redirect_uri:o}),signal:n});return Gs(r,"exchange")}async function Vu(e,t){let o;try{o=await fetch(Os,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams({grant_type:"refresh_token",refresh_token:e,client_id:Lt}),signal:t})}catch(n){throw Error(`OpenAI Codex token refresh error: ${n instanceof Error?n.message:String(n)}`)}return Gs(o,"refresh")}async function Ku(e){let t=await ko(bu,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({client_id:Lt}),signal:e});if(!t.ok){if(t.status===404)throw Error("OpenAI Codex device code login is not enabled for this server. Use browser login or verify the server URL.");let s=await t.text().catch(()=>"");throw Error(`OpenAI Codex device code request failed with status ${t.status}${s?`: ${s}`:""}`)}let n=await t.json(),r=typeof n?.interval==="string"?Number(n.interval.trim()):n?.interval;if(!n?.device_auth_id||!n.user_code||typeof r!=="number"||!Number.isFinite(r)||r<0)throw Error(`Invalid OpenAI Codex device code response: ${JSON.stringify(n)}`);return{deviceAuthId:n.device_auth_id,userCode:n.user_code,intervalSeconds:r}}async function ju(e,t){return b({intervalSeconds:e.intervalSeconds,expiresInSeconds:Ps,signal:t,poll:async()=>{let o=await ko(Nu,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({device_auth_id:e.deviceAuthId,user_code:e.userCode}),signal:t});if(o.ok){let i=await o.json();if(!i?.authorization_code||!i.code_verifier)return{status:"failed",message:`Invalid OpenAI Codex device auth token response: ${JSON.stringify(i)}`};return{status:"complete",value:{authorizationCode:i.authorization_code,codeVerifier:i.code_verifier}}}if(o.status===403||o.status===404)return{status:"pending"};let n=await o.text().catch(()=>""),r;try{let i=JSON.parse(n)?.error;r=typeof i==="object"?i?.code:i}catch{}if(r==="deviceauth_authorization_pending")return{status:"pending"};if(r==="slow_down")return{status:"slow_down"};return{status:"failed",message:`OpenAI Codex device auth failed with status ${o.status}${n?`: ${n}`:""}`}}})}async function zu(e="pi"){let{verifier:t,challenge:o}=await N(),n=$u(),r=new URL(Gu);return r.searchParams.set("response_type","code"),r.searchParams.set("client_id",Lt),r.searchParams.set("redirect_uri",wo),r.searchParams.set("scope",Uu),r.searchParams.set("code_challenge",o),r.searchParams.set("code_challenge_method","S256"),r.searchParams.set("state",n),r.searchParams.set("id_token_add_organizations","true"),r.searchParams.set("codex_cli_simplified_flow","true"),r.searchParams.set("originator",e),{verifier:t,state:n,url:r.toString()}}function Xu(e){let n=Hu(e)?.[Bu]?.chatgpt_account_id;return typeof n==="string"&&n.length>0?n:null}function bs(e){let t=Xu(e.access);if(!t)throw Error("Failed to extract accountId from token");return{type:"oauth",access:e.access,refresh:e.refresh,expires:e.expires,accountId:t}}async function Ns(e,t,o,n){return bs(await Wu(e,t,o,n))}async function qu(e){let t=await Ku(e.signal);e.notify({type:"device_code",userCode:t.userCode,verificationUri:Lu,intervalSeconds:t.intervalSeconds,expiresInSeconds:Ps});let o=await ju(t,e.signal);return Ns(o.authorizationCode,o.codeVerifier,Mu,e.signal)}async function Ju(e,t){let{verifier:o,state:n,url:r}=await zu(t?.agentName),s=await K({providerName:"OpenAI",host:Du(),port:1455,path:"/auth/callback",state:n,complete:async(i)=>i,signal:e.signal}).catch(()=>{return});e.notify({type:"auth_url",url:r,instructions:"A browser window should open. Complete login to finish."});try{let i=await ve(e,s,{message:"Complete login in your browser, or paste the authorization code / redirect URL here:",placeholder:wo}),d;if(i.type==="callback")d=i.value;else{let c=Fu(i.input);if(c.state&&c.state!==n)throw Error("State mismatch");d=c.code}if(!d)throw Error("Missing authorization code");return await Ns(d,o,wo,e.signal)}finally{s?.close()}}async function Yu(e,t){return bs(await Vu(e,t))}var Ls={name:"OpenAI (ChatGPT Plus/Pro)",isSubscription:!0,async login(e,t){let o=await e.prompt({type:"select",message:"Select OpenAI Codex login method:",options:[{id:ws,label:"Browser login (default)"},{id:ks,label:"Device code login (headless)"}]});if(o===ks)return qu(e);if(o!==ws)throw Error(`Unknown OpenAI Codex login method: ${o}`);return Ju(e,t)},refresh:(e,t)=>Yu(e.refresh,t),async toAuth(e){return{apiKey:e.access}}};var Qu="https://openrouter.ai/auth",Zu="https://openrouter.ai/api/v1/auth/keys",el=300000,tl=30000;function ol(){return _("PI_OAUTH_CALLBACK_HOST")||"127.0.0.1"}function nl(e){let t=e.trim();if(!t)return;try{return new URL(t).searchParams.get("code")??void 0}catch{}if(t.includes("code="))return new URLSearchParams(t).get("code")??void 0;return t}function rl(e){if(typeof e.error_description==="string")return e.error_description;if(typeof e.message==="string")return e.message;if(typeof e.error==="string")return e.error;if(e.error&&typeof e.error==="object"&&!Array.isArray(e.error)){let t=e.error.message;if(typeof t==="string")return t}return}async function Ms(e,t,o){if(o.aborted)throw Error("Login cancelled");let n=new AbortController,r=()=>n.abort(o.reason);o.addEventListener("abort",r,{once:!0});let s=setTimeout(()=>n.abort(Error("OpenRouter OAuth token exchange timed out")),tl),i,d={};try{i=await fetch(Zu,{method:"POST",headers:{accept:"application/json","content-type":"application/json"},body:JSON.stringify({code:e,code_verifier:t,code_challenge_method:"S256"}),signal:n.signal});try{let c=await i.json();if(c&&typeof c==="object"&&!Array.isArray(c))d=c}catch{if(i.ok)throw Error("OpenRouter OAuth returned invalid JSON")}}catch(c){if(o.aborted)throw Error("Login cancelled");if(n.signal.aborted)throw Error("OpenRouter OAuth token exchange timed out");throw c}finally{clearTimeout(s),o.removeEventListener("abort",r)}if(!i.ok){let c=rl(d);throw Error(`OpenRouter OAuth key exchange failed (HTTP ${i.status})${c?`: ${c}`:""}`)}if(typeof d.key!=="string"||d.key.length===0)throw Error('OpenRouter OAuth response carries no "key"');return{type:"oauth",access:d.key,refresh:"",expires:Number.MAX_SAFE_INTEGER}}async function sl(e){let{verifier:t,challenge:o}=await N(),n=await K({providerName:"OpenRouter",host:ol(),port:0,path:`/oauth/callback/${crypto.randomUUID()}`,complete:(r)=>Ms(r,t,e.signal),signal:e.signal,timeoutMs:el});try{let r=new URL(Qu);r.search=new URLSearchParams({callback_url:n.redirectUri,code_challenge:o,code_challenge_method:"S256"}).toString(),e.notify({type:"progress",message:`Listening for OpenRouter OAuth callback on ${n.redirectUri}`}),e.notify({type:"auth_url",url:r.toString(),instructions:"Complete sign-in in your browser. If the browser is on another machine, paste the final redirect URL here."});let s=await ve(e,n,{message:"Complete sign-in in your browser, or paste the authorization code / redirect URL here:",placeholder:n.redirectUri});if(s.type==="callback")return s.value;let i=nl(s.input);if(!i)throw Error("Missing authorization code");return e.notify({type:"progress",message:"Exchanging authorization code for an API key..."}),await Ms(i,t,e.signal)}finally{n.close()}}var Us={name:"OpenRouter OAuth",loginLabel:"Sign in with OpenRouter",login:sl,async refresh(e,t){return e},async toAuth(e){return{apiKey:e.access}}};var $s="127.0.0.1",Fs=1456,Hs="/oauth/callback",Oo=`http://${$s}:${Fs}${Hs}`,il=60000,Bs="browser",Ds="device-code",Ke="pi-gateway",Ws="gateway offline_access",al="urn:ietf:params:oauth:grant-type:device_code";async function cl(e,t){let o=await fetch(new URL("/v1/oauth",e),{headers:{accept:"application/json"},signal:t});if(!o.ok)throw Error(`Could not load Radius OAuth config from ${e}: ${o.status} ${await o.text()}`);let n=await o.json();if(typeof n.authorizationEndpoint!=="string")throw Error(`Invalid Radius OAuth config from ${e}`);return{authorizationEndpoint:n.authorizationEndpoint}}class Po extends Error{status;oauthError;constructor(e,t,o,n){let r=t?o?`${t}: ${o}`:t:o||String(e);super(`${n}: ${r}`);this.status=e,this.oauthError=t}}async function Vs(e,t){let o=await e.text().catch(()=>""),n,r;if(o)try{let s=JSON.parse(o);n=typeof s.error==="string"?s.error:void 0,r=typeof s.error_description==="string"?s.error_description:void 0}catch{r=o}return new Po(e.status,n,r,t)}async function Go(e,t,o){let n;try{n=await fetch(new URL("/v1/oauth/token",e),{method:"POST",headers:{accept:"application/json","content-type":"application/x-www-form-urlencoded"},body:t,signal:o})}catch(s){if(o.aborted)throw Error("Login cancelled");throw s}if(!n.ok)throw await Vs(n,"Radius OAuth token request failed");let r=await n.json();return{type:"oauth",access:r.access_token,refresh:r.refresh_token,expires:Date.now()+r.expires_in*1000-il,scope:r.scope}}async function dl(e,t,o){let{verifier:n,challenge:r}=await N(),s=crypto.randomUUID(),i=new URL(t);i.search=new URLSearchParams({response_type:"code",client_id:Ke,redirect_uri:Oo,scope:Ws,code_challenge:r,code_challenge_method:"S256",handoff:"url",state:s}).toString();let d=await K({providerName:"Radius",host:$s,port:Fs,path:Hs,state:s,complete:(c)=>Go(e,new URLSearchParams({grant_type:"authorization_code",client_id:Ke,redirect_uri:Oo,code:c,code_verifier:n}),o.signal),signal:o.signal});o.notify({type:"progress",message:`Listening for OAuth callback on ${Oo}`}),o.notify({type:"auth_url",url:i.toString(),instructions:"Continue in your browser."});try{let c=await d.wait();if(!c)throw Error("OAuth callback did not complete.");return c}finally{d.close()}}async function ul(e,t){let o;try{o=await fetch(new URL("/v1/oauth/device",e),{method:"POST",headers:{accept:"application/json","content-type":"application/x-www-form-urlencoded"},body:new URLSearchParams({client_id:Ke,scope:Ws}),signal:t})}catch(r){if(t.aborted)throw Error("Login cancelled");throw r}if(!o.ok)throw await Vs(o,"Radius OAuth device authorization failed");let n=await o.json();if(!n.device_code||!n.user_code||!n.verification_uri||!n.expires_in)throw Error("Radius OAuth device authorization response is missing required fields");return{device_code:n.device_code,user_code:n.user_code,verification_uri:n.verification_uri,expires_in:n.expires_in,interval:n.interval}}async function ll(e,t){let o=await ul(e,t.signal);return t.notify({type:"device_code",userCode:o.user_code,verificationUri:o.verification_uri,intervalSeconds:o.interval,expiresInSeconds:o.expires_in}),b({intervalSeconds:o.interval,expiresInSeconds:o.expires_in,signal:t.signal,poll:async()=>{try{return{status:"complete",value:await Go(e,new URLSearchParams({grant_type:al,client_id:Ke,device_code:o.device_code}),t.signal)}}catch(n){if(!(n instanceof Po))throw n;switch(n.oauthError){case"authorization_pending":return{status:"pending"};case"slow_down":return{status:"slow_down"};case"expired_token":return{status:"failed",message:"Device authorization expired."};case"access_denied":return{status:"failed",message:"Device authorization was denied."};default:throw n}}}})}function Ks(e){let t=rr(e.gateway);return{name:e.name,async login(o){let n=await o.prompt({type:"select",message:`Sign in to ${e.name}:`,options:[{id:Bs,label:"Sign in with browser (recommended)"},{id:Ds,label:"Sign in with device code (when signing in from another device)"}]});if(n===Ds)return ll(t,o);if(n===Bs){let r=await cl(t,o.signal);return dl(t,r.authorizationEndpoint,o)}throw Error(`Unknown ${e.name} sign-in method: ${n}`)},async refresh(o,n){return await Go(t,new URLSearchParams({grant_type:"refresh_token",client_id:Ke,refresh_token:o.refresh}),n)},async toAuth(o){return{apiKey:o.access}}}}var bo="b1a00492-073a-47ea-816f-4c329264a828",pl="openid profile email offline_access grok-cli:access api:access",_l="https://auth.x.ai/oauth2/device/code",zs="https://auth.x.ai/oauth2/token",hl=300000,fl=3600;function ze(e,t){let o=e[t];if(typeof o!=="string"||o.length===0)throw Error(`Invalid xAI OAuth response field: ${t}`);return o}function Xs(e,t){let o=e[t];if(typeof o!=="number"||!Number.isFinite(o)||o<=0)throw Error(`Invalid xAI OAuth response field: ${t}`);return o}function js(e){let t;try{t=new URL(e)}catch{throw Error("Untrusted verification URI in xAI OAuth response")}if(t.protocol!=="https:")throw Error("Untrusted verification URI in xAI OAuth response");return t.href}async function No(e,t,o){let n;try{n=await fetch(e,{method:"POST",headers:{Accept:"application/json","Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams(t),signal:o})}catch(s){if(o.aborted)throw Error("Login cancelled");throw s}let r;try{let s=await n.json();r=s&&typeof s==="object"&&!Array.isArray(s)?s:{}}catch{if(o.aborted)throw Error("Login cancelled");throw Error(`xAI OAuth returned invalid JSON (HTTP ${n.status})`)}return{ok:n.ok,status:n.status,body:r}}function Lo(e,t){let o=typeof t.body.error==="string"?t.body.error:void 0,n=typeof t.body.error_description==="string"?t.body.error_description:void 0,r=[o,n].filter(Boolean).join(": ");return Error(`xAI OAuth ${e} failed (HTTP ${t.status})${r?`: ${r}`:""}`)}function ml(e){let t=e.interval,o=typeof t==="number"&&Number.isFinite(t)&&t>0?t:void 0,n=typeof e.verification_uri_complete==="string"&&e.verification_uri_complete.length>0?js(e.verification_uri_complete):void 0;return{deviceCode:ze(e,"device_code"),userCode:ze(e,"user_code"),verificationUri:js(ze(e,"verification_uri")),verificationUriComplete:n,intervalSeconds:o,expiresInSeconds:Xs(e,"expires_in")}}function qs(e,t){let o=ze(e,"access_token"),n=e.refresh_token===void 0&&t?t:ze(e,"refresh_token"),r=e.expires_in===void 0?fl:Xs(e,"expires_in");return{type:"oauth",access:o,refresh:n,expires:Date.now()+r*1000-hl}}async function gl(e){let t=await No(_l,{client_id:bo,scope:pl,referrer:"pi"},e);if(!t.ok)throw Lo("device authorization",t);return ml(t.body)}async function Cl(e,t){return b({intervalSeconds:e.intervalSeconds,expiresInSeconds:e.expiresInSeconds,waitBeforeFirstPoll:!0,signal:t,poll:async()=>{let o=await No(zs,{grant_type:"urn:ietf:params:oauth:grant-type:device_code",client_id:bo,device_code:e.deviceCode},t);if(o.ok)return{status:"complete",value:qs(o.body)};let n=o.body.error;if(n==="authorization_pending")return{status:"pending"};if(n==="slow_down"){let r=o.body.interval;return{status:"slow_down",intervalSeconds:typeof r==="number"?r:void 0}}if(n==="access_denied"||n==="authorization_denied")return{status:"failed",message:"xAI device authorization was denied"};if(n==="expired_token")return{status:"failed",message:"xAI device code expired"};return{status:"failed",message:Lo("device token polling",o).message}}})}async function Sl(e){let t=await gl(e.signal);return e.notify({type:"device_code",userCode:t.userCode,verificationUri:t.verificationUriComplete??t.verificationUri,intervalSeconds:t.intervalSeconds,expiresInSeconds:t.expiresInSeconds}),Cl(t,e.signal)}async function El(e,t){let o=await No(zs,{grant_type:"refresh_token",client_id:bo,refresh_token:e},t);if(!o.ok)throw Lo("token refresh",o);return qs(o.body,e)}var Js={name:"xAI (Grok/X subscription)",isSubscription:!0,loginLabel:"Sign in with SuperGrok or X Premium",login:Sl,refresh:(e,t)=>El(e.refresh,t),async toAuth(e){return{apiKey:e.access}}};function Ys(){xi({anthropic:()=>rs,openaiCodex:()=>Ls,openaiChatGPT:()=>Ts,githubCopilot:()=>ps,openrouter:()=>Us,kimiCoding:()=>gs,meta:()=>vs,xai:()=>Js,radius:Ks})}Si(Hr);Ys();await import("./chunk-nysatg77.js");
96
+ </html>`}function Pt(e){return Vr({title:"Authentication successful",heading:"Authentication successful",message:e})}function P(e,t){return Vr({title:"Authentication failed",heading:"Authentication failed",message:e,details:t})}function Q(e,t,o){e.writeHead(t,{"content-type":"text/html; charset=utf-8","cache-control":"no-store"}),e.end(o)}async function K(e){let{providerName:t,signal:o}=e;if(o?.aborted)throw Error("Login cancelled");let n=()=>{},r=()=>{},s=new Promise((g,h)=>{n=g,r=h});s.catch(()=>{return});let i=!1,d=!1,c,u=()=>l({error:Error("Login cancelled")}),l=(g)=>{if(d)return;if(d=!0,c)clearTimeout(c);if(o?.removeEventListener("abort",u),"error"in g)r(g.error);else n(g.value)},p=Md((g,h)=>{(async()=>{let x=new URL(g.url??"/","http://localhost");if(g.method!=="GET"||x.pathname!==e.path){Q(h,404,P("Callback route not found."));return}if(e.state!==void 0&&x.searchParams.get("state")!==e.state){Q(h,400,P("State mismatch."));return}if(i||d){Q(h,409,P("This sign-in has already been handled."));return}let I=x.searchParams.get("error");if(I){let S=x.searchParams.get("error_description")??I;Q(h,400,P(`${t} authorization failed.`,S)),l({error:Error(`${t} authorization failed: ${S}`)});return}let R=x.searchParams.get("code");if(!R){Q(h,400,P("Missing authorization code."));return}i=!0;try{let S=await e.complete(R);Q(h,200,Pt(`Signed in to ${t}. You may now close this page.`)),l({value:S})}catch(S){let D=S instanceof Error?S:Error(String(S));Q(h,502,P(`${t} sign-in failed.`,D.message)),l({error:D})}})()});await new Promise((g,h)=>{p.once("error",h),p.listen(e.port,e.host,()=>{p.off("error",h),g()})});let C=p.address();if(!C||typeof C==="string")throw p.close(),Error("OAuth callback server did not bind to TCP");if(p.on("error",(g)=>l({error:g})),o?.addEventListener("abort",u,{once:!0}),e.timeoutMs!==void 0)c=setTimeout(()=>l({error:Error(`${t} sign-in timed out`)}),e.timeoutMs);let m=e.redirectHost??e.host;return{redirectUri:`http://${m.includes(":")?`[${m}]`:m}:${C.port}${e.path}`,wait:()=>s,cancel:()=>{if(!i)l({value:void 0})},close:()=>{l({error:Error("OAuth callback server closed")}),p.close()}}}async function ve(e,t,o){let n=new AbortController,r,s=e.prompt({type:"manual_code",...o,signal:n.signal}).then((i)=>(t?.cancel(),i)).catch((i)=>{r=i instanceof Error?i:Error(String(i)),t?.cancel();return});try{let i=await t?.wait();if(r)throw r;if(i!==void 0)return{type:"callback",value:i};let d=await s;if(r)throw r;return{type:"manual",input:d??""}}finally{n.abort()}}function Kr(e){let t="";for(let o of e)t+=String.fromCharCode(o);return btoa(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}async function N(){let e=new Uint8Array(32);crypto.getRandomValues(e);let t=Kr(e),n=new TextEncoder().encode(t),r=await crypto.subtle.digest("SHA-256",n),s=Kr(new Uint8Array(r));return{verifier:t,challenge:s}}var Ud=(e)=>atob(e),Gt=Ud("OWQxYzI1MGEtZTYxYi00NGQ5LTg4ZWQtNTk0NGQxOTYyZjVl"),Yr="https://claude.ai/oauth/authorize",Re="https://platform.claude.com/v1/oauth/token",Bd=_("PI_OAUTH_CALLBACK_HOST")||"127.0.0.1",Qr=53692,Zr="/callback",Dd=`http://localhost:${Qr}${Zr}`,Xr="https://platform.claude.com/oauth/code/callback",qr="browser",Jr="copy_code",es="org:create_api_key user:profile user:inference user:sessions:claude_code user:mcp_servers user:file_upload";function ts(e){let t=e.trim();if(!t)return{};try{let o=new URL(t);return{code:o.searchParams.get("code")??void 0,state:o.searchParams.get("state")??void 0}}catch{}if(t.includes("#")){let[o,n]=t.split("#",2);return{code:o,state:n}}if(t.includes("code=")){let o=new URLSearchParams(t);return{code:o.get("code")??void 0,state:o.get("state")??void 0}}return{code:t}}function Fe(e){if(e instanceof Error){let t=[`${e.name}: ${e.message}`],o=e;if(o.code)t.push(`code=${o.code}`);if(typeof o.errno<"u")t.push(`errno=${String(o.errno)}`);if(typeof e.cause<"u")t.push(`cause=${Fe(e.cause)}`);if(e.stack)t.push(`stack=${e.stack}`);return t.join("; ")}return String(e)}async function os(e,t,o){let n=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify(t),signal:AbortSignal.any([o,AbortSignal.timeout(30000)])}),r=await n.text();if(!n.ok)throw Error(`HTTP request failed. status=${n.status}; url=${e}; body=${r}`);return r}async function ns(e,t,o,n,r){let s;try{s=await os(Re,{grant_type:"authorization_code",client_id:Gt,code:e,state:t,redirect_uri:n,code_verifier:o},r)}catch(d){throw Error(`Token exchange request failed. url=${Re}; redirect_uri=${n}; response_type=authorization_code; details=${Fe(d)}`)}let i;try{i=JSON.parse(s)}catch(d){throw Error(`Token exchange returned invalid JSON. url=${Re}; body=${s}; details=${Fe(d)}`)}return{type:"oauth",refresh:i.refresh_token,access:i.access_token,expires:Date.now()+i.expires_in*1000-300000}}async function $d(e){let{verifier:t,challenge:o}=await N(),n=(i)=>K({providerName:"Anthropic",host:Bd,port:i,path:Zr,redirectHost:"localhost",state:t,complete:async(d)=>d,signal:e.signal}),r=await n(Qr).catch(()=>n(0)).catch(()=>{return}),s=r?.redirectUri??Dd;try{let i=new URLSearchParams({code:"true",client_id:Gt,response_type:"code",redirect_uri:s,scope:es,code_challenge:o,code_challenge_method:"S256",state:t});e.notify({type:"auth_url",url:`${Yr}?${i.toString()}`,instructions:"Complete login in your browser. If the browser is on another machine, paste the final redirect URL here."});let d=await ve(e,r,{message:"Complete login in your browser, or paste the authorization code / redirect URL here:",placeholder:s}),c,u=t;if(d.type==="callback")c=d.value;else{let l=ts(d.input);if(l.state&&l.state!==t)throw Error("OAuth state mismatch");c=l.code,u=l.state??t}if(!c)throw Error("Missing authorization code");return e.notify({type:"progress",message:"Exchanging authorization code for tokens..."}),await ns(c,u,t,s,e.signal)}finally{r?.close()}}async function Fd(e){let{verifier:t,challenge:o}=await N(),n=new URLSearchParams({code:"true",client_id:Gt,response_type:"code",redirect_uri:Xr,scope:es,code_challenge:o,code_challenge_method:"S256",state:t});e.notify({type:"auth_url",url:`${Yr}?${n.toString()}`,instructions:"Complete login in your browser, then copy the code Anthropic shows and paste it here."});let r=await e.prompt({type:"manual_code",message:"Paste the code Anthropic shows after you sign in:",placeholder:"code#state",signal:e.signal}),s=ts(r);if(s.state&&s.state!==t)throw Error("OAuth state mismatch");if(!s.code)throw Error("Missing authorization code");return e.notify({type:"progress",message:"Exchanging authorization code for tokens..."}),await ns(s.code,s.state??t,t,Xr,e.signal)}async function Hd(e,t){let o;try{o=await os(Re,{grant_type:"refresh_token",client_id:Gt,refresh_token:e},t)}catch(r){throw Error(`Anthropic token refresh request failed. url=${Re}; details=${Fe(r)}`)}let n;try{n=JSON.parse(o)}catch(r){throw Error(`Anthropic token refresh returned invalid JSON. url=${Re}; body=${o}; details=${Fe(r)}`)}return{type:"oauth",refresh:n.refresh_token,access:n.access_token,expires:Date.now()+n.expires_in*1000-300000}}var rs={name:"Anthropic (Claude Pro/Max)",isSubscription:!0,async login(e){let t=await e.prompt({type:"select",message:"Select Anthropic login method:",options:[{id:qr,label:"Browser login (default)"},{id:Jr,label:"Copy code login (headless)"}]});if(t===Jr)return Fd(e);if(t!==qr)throw Error(`Unknown Anthropic login method: ${t}`);return $d(e)},refresh:(e,t)=>Hd(e.refresh,t),async toAuth(e){return{apiKey:e.access}}};function bt(e,t){return new Promise((o,n)=>{t.throwIfAborted();let r=()=>{clearTimeout(s),n(t.reason)},s=setTimeout(()=>{t.removeEventListener("abort",r),o()},e);t.addEventListener("abort",r,{once:!0})})}function ss(e,t,o){return new Promise((n,r)=>{if(t.aborted){r(Error(o));return}let s=()=>{clearTimeout(i),r(Error(o))},i=setTimeout(()=>{t.removeEventListener("abort",s),n()},e);t.addEventListener("abort",s,{once:!0})})}async function b(e){let t=typeof e.expiresInSeconds==="number"?Date.now()+e.expiresInSeconds*1000:Number.POSITIVE_INFINITY,o=Math.max(1000,Math.floor((e.intervalSeconds??5)*1000)),n=0;if(e.waitBeforeFirstPoll){let r=t-Date.now();if(r>0)await ss(Math.min(o,r),e.signal,"Login cancelled")}while(Date.now()<t){if(e.signal.aborted)throw Error("Login cancelled");let r=await e.poll();if(r.status==="complete")return r.value;if(r.status==="failed")throw Error(r.message);if(r.status==="slow_down")n+=1,o=typeof r.intervalSeconds==="number"&&Number.isFinite(r.intervalSeconds)&&r.intervalSeconds>0?Math.max(1000,Math.floor(r.intervalSeconds*1000)):Math.max(1000,o+5000);let s=t-Date.now();if(s<=0)break;await ss(Math.min(o,s),e.signal,"Login cancelled")}throw Error(n>0?"Device flow timed out after one or more slow_down responses. This is often caused by clock drift in WSL or VM environments. Please sync or restart the VM clock and try again.":"Device flow timed out")}var Wd=(e)=>atob(e),as=Wd("SXYxLmI1MDdhMDhjODdlY2ZlOTg="),lo={"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},Vd="2026-06-01";function cs(e){let t=e.trim();if(!t)return null;try{return(t.includes("://")?new URL(t):new URL(`https://${t}`)).hostname}catch{return null}}function po(e){return{deviceCodeUrl:`https://${e}/login/device/code`,accessTokenUrl:`https://${e}/login/oauth/access_token`,copilotTokenUrl:`https://api.${e}/copilot_internal/v2/token`}}function Kd(e){let t=e.match(/proxy-ep=([^;]+)/);if(!t)return null;return`https://${t[1].replace(/^proxy\./,"api.")}`}function _o(e,t){if(e){let o=Kd(e);if(o)return o}if(t)return`https://copilot-api.${t}`;return"https://api.individual.githubcopilot.com"}function We(e){return e&&typeof e==="object"?e:void 0}function jd(e,t){let o=We(e)?.data;if(!Array.isArray(o))throw Error("Invalid Copilot models response");let n=o.flatMap((c)=>{let u=We(c),l=u?.id;if(!u||typeof l!=="string")return[];let p=We(u.capabilities);if(We(p?.supports)?.tool_calls===!1)return[];return[{id:l,pickerEnabled:u.model_picker_enabled===!0,policyState:We(u.policy)?.state}]}),r=n.filter((c)=>c.pickerEnabled&&c.policyState!=="disabled").map((c)=>c.id),s=t&&r.length===0,i=r.length>0||!t?r:n.filter((c)=>c.policyState==="enabled").map((c)=>c.id),d=n.filter((c)=>c.policyState==="unconfigured"&&Object.hasOwn($r,c.id)&&(c.pickerEnabled||s)).map((c)=>c.id);return{availableModelIds:i,policyModelIds:d}}async function ds(e,t,o,n){let r=n.maxRetries>0&&n.maxElapsedMs>0?AbortSignal.timeout(n.maxElapsedMs):void 0,s=r?AbortSignal.any([o,r]):o,i=r?Date.now()+n.maxElapsedMs:void 0;for(let d=0;;d++){let c=await fetch(e,{...t,signal:AbortSignal.any([s,AbortSignal.timeout(5000)])});if(c.status!==429||d===n.maxRetries)return c;let u=c.headers.get("retry-after"),l=500*2**d;if(u){let p=Number.parseFloat(u);if(l=Number.isNaN(p)?Date.parse(u)-Date.now():p*1000,!Number.isFinite(l))return c}if(l=Math.max(0,l),i!==void 0&&l>=i-Date.now())return c;await c.body?.cancel(),await bt(l,s)}}async function us(e,t,o,n){let r=_o(e,t),s=r==="https://api.individual.githubcopilot.com",i=await ds(`${r}/models`,{headers:{Accept:"application/json",Authorization:`Bearer ${e}`,...lo,"X-GitHub-Api-Version":Vd}},o,n);if(!i.ok)throw Error(`${i.status} ${i.statusText}: ${await i.text()}`);return jd(await i.json(),s)}async function ho(e,t){let o=await fetch(e,t);if(!o.ok){let n=await o.text();throw Error(`${o.status} ${o.statusText}: ${n}`)}return o.json()}async function zd(e,t){let o=po(e),n=await ho(o.deviceCodeUrl,{method:"POST",headers:{Accept:"application/json","Content-Type":"application/x-www-form-urlencoded","User-Agent":"GitHubCopilotChat/0.35.0"},body:new URLSearchParams({client_id:as,scope:"read:user"}),signal:t});if(!n||typeof n!=="object")throw Error("Invalid device code response");let{device_code:r,user_code:s,verification_uri:i,interval:d,expires_in:c}=n;if(typeof r!=="string"||typeof s!=="string"||typeof i!=="string"||d!==void 0&&typeof d!=="number"||typeof c!=="number")throw Error("Invalid device code response fields");let u;try{u=new URL(i)}catch{throw Error("Untrusted verification_uri in device code response")}if(u.protocol!=="https:"&&u.protocol!=="http:")throw Error("Untrusted verification_uri in device code response");return{device_code:r,user_code:s,verification_uri:u.href,interval:d,expires_in:c}}async function Xd(e,t,o){let n=po(e);return b({intervalSeconds:t.interval,expiresInSeconds:t.expires_in,waitBeforeFirstPoll:!0,signal:o,poll:async()=>{let r=await ho(n.accessTokenUrl,{method:"POST",headers:{Accept:"application/json","Content-Type":"application/x-www-form-urlencoded","User-Agent":"GitHubCopilotChat/0.35.0"},body:new URLSearchParams({client_id:as,device_code:t.device_code,grant_type:"urn:ietf:params:oauth:grant-type:device_code"}),signal:o});if(r&&typeof r==="object"&&typeof r.access_token==="string")return{status:"complete",value:r.access_token};if(r&&typeof r==="object"&&typeof r.error==="string"){let{error:s,error_description:i,interval:d}=r;if(s==="authorization_pending")return{status:"pending"};if(s==="slow_down")return{status:"slow_down",intervalSeconds:typeof d==="number"?d:void 0};let c=i?`: ${i}`:"";return{status:"failed",message:`Device flow failed: ${s}${c}`}}return{status:"failed",message:"Invalid device token response"}}})}async function ls(e,t,o){let r=po(t||"github.com"),s=await ho(r.copilotTokenUrl,{headers:{Accept:"application/json",Authorization:`Bearer ${e}`,...lo},signal:o});if(!s||typeof s!=="object")throw Error("Invalid Copilot token response");let{token:i,expires_at:d}=s;if(typeof i!=="string"||typeof d!=="number")throw Error("Invalid Copilot token response fields");return{type:"oauth",refresh:e,access:i,expires:d*1000-300000,enterpriseUrl:t}}async function qd(e,t,o){let n=await ls(e,t,o),{availableModelIds:r}=await us(n.access,t,o,{maxRetries:0,maxElapsedMs:0});return{...n,availableModelIds:r}}async function Jd(e,t,o,n){let s=`${_o(e,o)}/models/${t}/policy`,i;try{i=await ds(s,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${e}`,...lo,"openai-intent":"chat-policy","x-interaction-type":"chat-policy"},body:JSON.stringify({state:"enabled"})},n,{maxRetries:2,maxElapsedMs:5000})}catch(d){if(n.aborted)throw d;return!1}if(i.status===429)throw Error(`${i.status} ${i.statusText}: ${await i.text()}`);return i.ok}async function Yd(e,t,o,n){let r=[];for(let s of t)try{if(await Jd(e,s,o,n))r.push(s)}catch(i){if(n.aborted)throw i;break}return r}async function Qd(e){let t=await e.prompt({type:"text",message:"GitHub Enterprise URL/domain (blank for github.com)",placeholder:"company.ghe.com"});if(e.signal.aborted)throw Error("Login cancelled");let o=t.trim(),n=cs(t);if(o&&!n)throw Error("Invalid GitHub Enterprise URL/domain");let r=n||"github.com",s=await zd(r,e.signal);e.notify({type:"device_code",userCode:s.user_code,verificationUri:s.verification_uri,intervalSeconds:s.interval,expiresInSeconds:s.expires_in});let i=await Xd(r,s,e.signal),d=await ls(i,n??void 0,e.signal),c=await us(d.access,n??void 0,e.signal,{maxRetries:2,maxElapsedMs:5000}),u=[];if(c.policyModelIds.length>0)e.notify({type:"progress",message:"Enabling models..."}),u=await Yd(d.access,c.policyModelIds,n??void 0,e.signal);return{...d,availableModelIds:[...new Set([...c.availableModelIds,...u])]}}function is(e){let t=e.enterpriseUrl;if(typeof t!=="string"||!t)return;return cs(t)??void 0}var ps={name:"GitHub Copilot",isSubscription:!0,login:Qd,refresh:(e,t)=>qd(e.refresh,is(e),t),async toAuth(e){return{apiKey:e.access,baseUrl:_o(e.access,is(e))}}};var fo="17e5f671-d194-4dfb-9706-5516cb48c098",Zd="https://auth.kimi.com",eu=900,tu=5,ou=30000,_s=3;function fs(){return(_("KIMI_CODE_OAUTH_HOST")||_("KIMI_OAUTH_HOST")||Zd).replace(/\/+$/,"")}function mo(e){return AbortSignal.any([AbortSignal.timeout(ou),e])}function go(e){return new URLSearchParams(e).toString()}async function Co(e){try{let t=await e.json();return t&&typeof t==="object"?t:null}catch{return null}}function hs(e){if(typeof e!=="string"||!e)return null;try{let t=new URL(e);if(t.protocol!=="https:"&&t.protocol!=="http:")return null;return t.href}catch{return null}}async function nu(e,t){let o=await fetch(`${e}/api/oauth/device_authorization`,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json"},body:go({client_id:fo}),signal:mo(t)});if(!o.ok){let l=await o.text().catch(()=>"");throw Error(`Kimi Code device authorization failed with status ${o.status}${l?`: ${l}`:""}`)}let n=await Co(o),r=n?.device_code,s=n?.user_code,i=n?.verification_uri,d=n?.verification_uri_complete;if(typeof r!=="string"||typeof s!=="string"||typeof i!=="string"||typeof d!=="string"||!hs(d)||!hs(i))throw Error(`Invalid Kimi Code device authorization response: ${JSON.stringify(n)}`);let c=n?.interval,u=n?.expires_in;return{deviceCode:r,userCode:s,verificationUri:i,verificationUriComplete:d,intervalSeconds:typeof c==="number"&&Number.isFinite(c)&&c>0?c:tu,expiresInSeconds:typeof u==="number"&&Number.isFinite(u)&&u>0?u:eu}}function ms(e,t){let o=e?.access_token,n=e?.refresh_token,r=e?.expires_in;if(typeof o!=="string"||!o||typeof n!=="string"||!n||typeof r!=="number"||!Number.isFinite(r)||r<=0)throw Error(`Kimi Code token ${t} response missing fields: ${JSON.stringify(e)}`);return{access:o,refresh:n,expires:Date.now()+r*1000}}async function ru(e,t,o){return b({intervalSeconds:t.intervalSeconds,expiresInSeconds:t.expiresInSeconds,waitBeforeFirstPoll:!0,signal:o,poll:async()=>{let n=await fetch(`${e}/api/oauth/token`,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json"},body:go({client_id:fo,device_code:t.deviceCode,grant_type:"urn:ietf:params:oauth:grant-type:device_code"}),signal:mo(o)});if(n.status>=500){let d=await n.text().catch(()=>"");return{status:"failed",message:`Kimi Code device token request failed with status ${n.status}${d?`: ${d}`:""}`}}let r=await Co(n);if(n.ok&&typeof r?.access_token==="string")try{return{status:"complete",value:ms(r,"poll")}}catch(d){return{status:"failed",message:d instanceof Error?d.message:String(d)}}let s=r?.error,i=typeof r?.error_description==="string"?`: ${r.error_description}`:"";if(s==="authorization_pending")return{status:"pending"};if(s==="slow_down"){let d=r?.interval;return{status:"slow_down",intervalSeconds:typeof d==="number"&&d>0?d:void 0}}if(s==="expired_token")return{status:"failed",message:"Kimi Code device authorization expired. Please restart login."};if(s==="access_denied")return{status:"failed",message:"Kimi Code login was denied."};return{status:"failed",message:`Kimi Code device token request failed (status ${n.status})${typeof s==="string"?`: ${s}${i}`:""}`}}})}function su(e){return e.status===429||e.status>=500}async function iu(e,t,o){let n;for(let r=0;r<=_s;r++){if(r>0)await bt(1000*2**(r-1),o);if(o.aborted)throw Error("Kimi Code token refresh aborted");let s;try{s=await fetch(`${e}/api/oauth/token`,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json"},body:go({client_id:fo,grant_type:"refresh_token",refresh_token:t}),signal:mo(o)})}catch(c){n=c instanceof Error?c:Error(String(c));continue}let i=await Co(s);if(s.ok)return ms(i,"refresh");if(s.status===401||s.status===403||i?.error==="invalid_grant"){let c=typeof i?.error_description==="string"?`: ${i.error_description}`:"";throw Error(`Kimi Code token refresh unauthorized (status ${s.status})${c}`)}if(su(s)&&r<_s){n=Error(`Kimi Code token refresh failed with status ${s.status}`);continue}let d=JSON.stringify(i);throw Error(`Kimi Code token refresh failed with status ${s.status}${d?`: ${d}`:""}`)}throw n??Error("Kimi Code token refresh failed")}async function au(e){let t=fs(),o=await nu(t,e.signal);e.notify({type:"device_code",userCode:o.userCode,verificationUri:o.verificationUriComplete,intervalSeconds:o.intervalSeconds,expiresInSeconds:o.expiresInSeconds});let n=await ru(t,o,e.signal);return{type:"oauth",access:n.access,refresh:n.refresh,expires:n.expires}}var gs={name:"Kimi Code (subscription)",isSubscription:!0,loginLabel:"Sign in with Kimi Code",login:au,refresh:async(e,t)=>{let o=await iu(fs(),e.refresh,t);return{type:"oauth",access:o.access,refresh:o.refresh,expires:o.expires}},async toAuth(e){return{headers:{Authorization:`Bearer ${e.access}`}}}};var Cs="1031625952748946",Ss="https://auth.meta.com",cu=`${Ss}/oidc/device/authorization/`,du=`${Ss}/oidc/device/token/`,uu="https://api.meta.ai/muse-code/key",lu=86400000,pu=30000;function vo(e){return AbortSignal.any([AbortSignal.timeout(pu),e])}async function Ao(e){try{let t=await e.json();return t&&typeof t==="object"?t:null}catch{return null}}function Nt(e){for(let t of["error_description","detail","message","error"]){let o=e?.[t];if(typeof o==="string"&&o.trim())return`: ${o.trim()}`}return""}function So(e){if(typeof e!=="string"||!e)return null;try{let t=new URL(e);if(t.protocol!=="https:"&&t.protocol!=="http:")return null;return t.href}catch{return null}}function Eo(e){return typeof e==="number"&&Number.isFinite(e)&&e>0?e:void 0}async function _u(e){let t=await fetch(cu,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json"},body:new URLSearchParams({client_id:Cs}).toString(),signal:vo(e)}),o=await Ao(t);if(!t.ok)throw Error(`Meta device authorization failed with status ${t.status}${Nt(o)}`);let n=o?.device_code,r=o?.user_code,s=So(o?.verification_uri_complete)??So(o?.verification_uri);if(typeof n!=="string"||!n||typeof r!=="string"||!r||!s)throw Error(`Invalid Meta device authorization response: ${JSON.stringify(o)}`);return{deviceCode:n,userCode:r,verificationUri:s,intervalSeconds:Eo(o?.interval),expiresInSeconds:Eo(o?.expires_in)}}async function hu(e,t){return b({intervalSeconds:e.intervalSeconds,expiresInSeconds:e.expiresInSeconds,waitBeforeFirstPoll:!0,signal:t,poll:async()=>{let o=await fetch(du,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json"},body:new URLSearchParams({grant_type:"urn:ietf:params:oauth:grant-type:device_code",device_code:e.deviceCode,client_id:Cs}).toString(),signal:vo(t)}),n=await Ao(o);if(o.ok&&typeof n?.access_token==="string"&&n.access_token)return{status:"complete",value:n.access_token};switch(n?.error){case"authorization_pending":return{status:"pending"};case"slow_down":return{status:"slow_down",intervalSeconds:Eo(n?.interval)};case"access_denied":return{status:"failed",message:"Meta login was denied."};case"expired_token":return{status:"failed",message:"Meta device authorization expired. Please restart login."};default:return{status:"failed",message:`Meta device token request failed with status ${o.status}${Nt(n)}`}}}})}async function Es(e,t){let o=await fetch(uu,{method:"POST",headers:{Accept:"application/json",Authorization:`Bearer ${e}`,"Content-Type":"application/json","x-api-version":"1.0.0"},body:"{}",signal:vo(t)}),n=await Ao(o);if(o.status===401||o.status===403)throw Error(`Meta session expired (status ${o.status}). Run \`/login meta\` to sign in again.${Nt(n)}`);if(!o.ok)throw Error(`Meta API key mint failed with status ${o.status}${Nt(n)}`);let r=n?.api_key;if(typeof r!=="string"||!r){let s=So(n?.action_url);throw Error(`Meta did not issue an API key.${s?` Complete setup at ${s}`:""}`)}return{type:"oauth",refresh:e,access:r,expires:Date.now()+lu}}async function fu(e){try{let t=await _u(e.signal);e.notify({type:"device_code",userCode:t.userCode,verificationUri:t.verificationUri,intervalSeconds:t.intervalSeconds,expiresInSeconds:t.expiresInSeconds});let o=await hu(t,e.signal);return e.notify({type:"progress",message:"Enabling Meta Model API access..."}),await Es(o,e.signal)}catch(t){if(e.signal.aborted)throw Error("Login cancelled");throw t}}var vs={name:"Meta (Muse subscription)",isSubscription:!0,loginLabel:"Sign in with Meta",login:fu,refresh:(e,t)=>Es(e.refresh,t),async toAuth(e){return{apiKey:e.access}}};import{randomBytes as mu}from"crypto";import{createServer as gu}from"http";var Cu="dynamic_agent_client",Su="Pi",Eu=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,vu="https://auth.openai.com/api/accounts/authorize",Au="https://auth.openai.com/api/accounts/oauth/token",xo="https://api.openai.com/v1",Ru=_("PI_OAUTH_CALLBACK_HOST")||"127.0.0.1",Io=1455,Rs="/auth/callback",ye=`http://127.0.0.1:${Io}${Rs}`,yo="chatgpt.tokens.use.direct",yu=`openid profile email offline_access resource.invoke ${yo}`,xu=180000;function As(){return mu(32).toString("base64url")}function ys(e,t){let o=e.searchParams.get("code");if(!o)throw Error("Missing authorization code");let n=e.searchParams.get("state");if(!n)throw Error("Missing OAuth state");if(n!==t)throw Error("OAuth state mismatch");let r=e.searchParams.get("client_id")?.trim();if(!r)throw Error("OpenAI OAuth registration callback did not contain an issued client ID");return{code:o,clientId:r}}function Iu(e,t){let o;try{o=new URL(e.trim())}catch{throw Error("Paste the full callback URL from the browser")}let n=new URL(ye);if(o.origin!==n.origin||o.pathname!==n.pathname)throw Error(`The pasted callback URL must start with ${ye}`);let r=o.searchParams.get("error");if(r)throw Error(`ChatGPT authorization failed: ${r}`);return ys(o,t)}function Ve(e,t,o){e.writeHead(t,{"Content-Type":"text/html; charset=utf-8"}),e.end(o)}function Tu(e){return new Promise((t,o)=>{let n,r,s=new Promise((d,c)=>{n=d,r=c}),i=gu((d,c)=>{try{let u=new URL(d.url||"",ye);if(u.pathname!==Rs){Ve(c,404,P("Callback route not found."));return}let l=u.searchParams.get("error");if(l){Ve(c,400,P("ChatGPT was not connected.",`Error: ${l}`)),r(Error(`ChatGPT authorization failed: ${l}`));return}let p;try{p=ys(u,e)}catch(C){let m=C instanceof Error?C.message:"Invalid callback";Ve(c,400,P(m));return}Ve(c,200,Pt("ChatGPT authentication completed. You can close this window.")),n(p)}catch{Ve(c,500,P("Internal error while processing the callback."))}});i.once("error",o),i.listen(Io,Ru,()=>{i.removeListener("error",o),i.on("error",r),t({server:i,result:s})})})}async function xs(e,t){let o=await fetch(Au,{method:"POST",headers:{accept:"application/json","content-type":"application/x-www-form-urlencoded"},body:e,signal:t});if(!o.ok){let r=await o.text().catch(()=>"");throw Error(`OpenAI OAuth token request failed (${o.status}): ${r||o.statusText}`)}let n=await o.json();if(typeof n!=="object"||n===null||Array.isArray(n))throw Error("OpenAI OAuth token response must be an object");return n}function Ro(e,t){if(typeof e!=="string"||e.trim().length===0)throw Error(`OpenAI OAuth token response has invalid ${t}`);return e}function Is(e,t,o){let n=Ro(e.access_token,"access_token"),r=Ro(e.refresh_token,"refresh_token"),s=Ro(e.scope,"scope"),i=typeof e.id_token==="string"?e.id_token:o?.idToken;if(typeof e.expires_in!=="number"||!Number.isFinite(e.expires_in)||e.expires_in<=0)throw Error("OpenAI OAuth token response has invalid expires_in");let d=s.trim().split(/\s+/).filter(Boolean);if(!d.includes(yo))throw Error(`OpenAI OAuth grant did not include ${yo}`);return{type:"oauth",...i?{idToken:i}:{},access:n,refresh:r,expires:Date.now()+e.expires_in*1000-xu,clientId:t,scopes:d}}async function wu(e,t,o,n){let r=await xs(new URLSearchParams({grant_type:"authorization_code",client_id:o,code:e,code_verifier:t,redirect_uri:ye,resource:xo}),n);if(typeof r.id_token!=="string"||r.id_token.trim().length===0)throw Error("OpenAI OAuth token response did not contain an ID token");return Is(r,o)}async function ku(e,t){let o=e.clientId;if(typeof o!=="string"||o.trim().length===0)throw Error("Stored OpenAI OAuth credential does not contain an issued client ID; reconnect ChatGPT");let n=await xs(new URLSearchParams({grant_type:"refresh_token",client_id:o,refresh_token:e.refresh,resource:xo}),t);return Is(n,o,e)}function Ou(e){if(!e||!Eu.test(e))throw Error("Sign in with ChatGPT requires a device ID (UUID) for this installation");return`urn:uuid:${e.toLowerCase()}`}async function Pu(e,t){let o=Ou(t?.getDeviceId?.()),{verifier:n,challenge:r}=await N(),s=As(),i=As(),d=await Tu(s).catch((p)=>{if(!(p instanceof Error&&("code"in p)&&p.code==="EADDRINUSE"))throw p;throw Error(`Port ${Io} is in use, probably by an unfinished login in another pi session or by the Codex CLI. Cancel that login and try again.`)}),c=new URL(vu);c.search=new URLSearchParams({client_id:Cu,agent_name_hint:t?.agentName??Su,ext_agent_host_id:o,response_type:"code",redirect_uri:ye,resource:xo,scope:yu,state:s,code_challenge:r,code_challenge_method:"S256",nonce:i}).toString(),e.notify({type:"auth_url",url:c.toString(),instructions:"Complete sign-in in your browser. If the callback does not complete, paste the final redirect URL here."});let u=new AbortController,l=e.prompt({type:"manual_code",message:"Complete login in your browser, or paste the final redirect URL here:",placeholder:ye,signal:AbortSignal.any([u.signal,e.signal])}).then((p)=>Iu(p,s));try{let p=await Promise.race([d.result,l]);return e.notify({type:"progress",message:"Exchanging authorization code for tokens..."}),await wu(p.code,n,p.clientId,e.signal)}catch(p){if(e.signal.aborted)throw Error("Login cancelled");throw p}finally{u.abort(),d.server.close(),d.server.closeAllConnections()}}var Ts={name:"OpenAI (ChatGPT subscription)",isSubscription:!0,loginLabel:"Sign in with ChatGPT",login:Pu,refresh:ku,async toAuth(e){return{apiKey:e.access}}};var To=null;if(typeof process<"u"&&(process.versions?.node||process.versions?.bun))import("crypto").then((e)=>{To=e.randomBytes});var Lt="app_EMoamEEZ73f0CkXaXp7hrann",xe="https://auth.openai.com",Gu=`${xe}/oauth/authorize`,Os=`${xe}/oauth/token`,wo="http://localhost:1455/auth/callback",bu=`${xe}/api/accounts/deviceauth/usercode`,Nu=`${xe}/api/accounts/deviceauth/token`,Lu=`${xe}/codex/device`,Mu=`${xe}/deviceauth/callback`,Ps=900,ws="browser",ks="device_code",Uu="openid profile email offline_access",Bu="https://api.openai.com/auth";function Du(){return _("PI_OAUTH_CALLBACK_HOST")||"127.0.0.1"}function $u(){if(!To)throw Error("OpenAI Codex OAuth is only available in Node.js environments");return To(16).toString("hex")}function Fu(e){let t=e.trim();if(!t)return{};try{let o=new URL(t);return{code:o.searchParams.get("code")??void 0,state:o.searchParams.get("state")??void 0}}catch{}if(t.includes("#")){let[o,n]=t.split("#",2);return{code:o,state:n}}if(t.includes("code=")){let o=new URLSearchParams(t);return{code:o.get("code")??void 0,state:o.get("state")??void 0}}return{code:t}}function Hu(e){try{let t=e.split(".");if(t.length!==3)return null;let o=t[1]??"",n=atob(o);return JSON.parse(n)}catch{return null}}async function ko(e,t){try{return await fetch(e,t)}catch(o){if(t.signal?.aborted)throw Error("Login cancelled");throw o}}async function Gs(e,t){if(!e.ok){let r=await e.text().catch(()=>"");throw Error(`OpenAI Codex token ${t} failed (${e.status}): ${r||e.statusText}`)}let n=await e.json();if(!n?.access_token||!n.refresh_token||typeof n.expires_in!=="number")throw Error(`OpenAI Codex token ${t} response missing fields: ${JSON.stringify(n)}`);return{access:n.access_token,refresh:n.refresh_token,expires:Date.now()+n.expires_in*1000}}async function Wu(e,t,o,n){let r=await ko(Os,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams({grant_type:"authorization_code",client_id:Lt,code:e,code_verifier:t,redirect_uri:o}),signal:n});return Gs(r,"exchange")}async function Vu(e,t){let o;try{o=await fetch(Os,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams({grant_type:"refresh_token",refresh_token:e,client_id:Lt}),signal:t})}catch(n){throw Error(`OpenAI Codex token refresh error: ${n instanceof Error?n.message:String(n)}`)}return Gs(o,"refresh")}async function Ku(e){let t=await ko(bu,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({client_id:Lt}),signal:e});if(!t.ok){if(t.status===404)throw Error("OpenAI Codex device code login is not enabled for this server. Use browser login or verify the server URL.");let s=await t.text().catch(()=>"");throw Error(`OpenAI Codex device code request failed with status ${t.status}${s?`: ${s}`:""}`)}let n=await t.json(),r=typeof n?.interval==="string"?Number(n.interval.trim()):n?.interval;if(!n?.device_auth_id||!n.user_code||typeof r!=="number"||!Number.isFinite(r)||r<0)throw Error(`Invalid OpenAI Codex device code response: ${JSON.stringify(n)}`);return{deviceAuthId:n.device_auth_id,userCode:n.user_code,intervalSeconds:r}}async function ju(e,t){return b({intervalSeconds:e.intervalSeconds,expiresInSeconds:Ps,signal:t,poll:async()=>{let o=await ko(Nu,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({device_auth_id:e.deviceAuthId,user_code:e.userCode}),signal:t});if(o.ok){let i=await o.json();if(!i?.authorization_code||!i.code_verifier)return{status:"failed",message:`Invalid OpenAI Codex device auth token response: ${JSON.stringify(i)}`};return{status:"complete",value:{authorizationCode:i.authorization_code,codeVerifier:i.code_verifier}}}if(o.status===403||o.status===404)return{status:"pending"};let n=await o.text().catch(()=>""),r;try{let i=JSON.parse(n)?.error;r=typeof i==="object"?i?.code:i}catch{}if(r==="deviceauth_authorization_pending")return{status:"pending"};if(r==="slow_down")return{status:"slow_down"};return{status:"failed",message:`OpenAI Codex device auth failed with status ${o.status}${n?`: ${n}`:""}`}}})}async function zu(e="pi"){let{verifier:t,challenge:o}=await N(),n=$u(),r=new URL(Gu);return r.searchParams.set("response_type","code"),r.searchParams.set("client_id",Lt),r.searchParams.set("redirect_uri",wo),r.searchParams.set("scope",Uu),r.searchParams.set("code_challenge",o),r.searchParams.set("code_challenge_method","S256"),r.searchParams.set("state",n),r.searchParams.set("id_token_add_organizations","true"),r.searchParams.set("codex_cli_simplified_flow","true"),r.searchParams.set("originator",e),{verifier:t,state:n,url:r.toString()}}function Xu(e){let n=Hu(e)?.[Bu]?.chatgpt_account_id;return typeof n==="string"&&n.length>0?n:null}function bs(e){let t=Xu(e.access);if(!t)throw Error("Failed to extract accountId from token");return{type:"oauth",access:e.access,refresh:e.refresh,expires:e.expires,accountId:t}}async function Ns(e,t,o,n){return bs(await Wu(e,t,o,n))}async function qu(e){let t=await Ku(e.signal);e.notify({type:"device_code",userCode:t.userCode,verificationUri:Lu,intervalSeconds:t.intervalSeconds,expiresInSeconds:Ps});let o=await ju(t,e.signal);return Ns(o.authorizationCode,o.codeVerifier,Mu,e.signal)}async function Ju(e,t){let{verifier:o,state:n,url:r}=await zu(t?.agentName),s=await K({providerName:"OpenAI",host:Du(),port:1455,path:"/auth/callback",state:n,complete:async(i)=>i,signal:e.signal}).catch(()=>{return});e.notify({type:"auth_url",url:r,instructions:"A browser window should open. Complete login to finish."});try{let i=await ve(e,s,{message:"Complete login in your browser, or paste the authorization code / redirect URL here:",placeholder:wo}),d;if(i.type==="callback")d=i.value;else{let c=Fu(i.input);if(c.state&&c.state!==n)throw Error("State mismatch");d=c.code}if(!d)throw Error("Missing authorization code");return await Ns(d,o,wo,e.signal)}finally{s?.close()}}async function Yu(e,t){return bs(await Vu(e,t))}var Ls={name:"OpenAI (ChatGPT Plus/Pro)",isSubscription:!0,async login(e,t){let o=await e.prompt({type:"select",message:"Select OpenAI Codex login method:",options:[{id:ws,label:"Browser login (default)"},{id:ks,label:"Device code login (headless)"}]});if(o===ks)return qu(e);if(o!==ws)throw Error(`Unknown OpenAI Codex login method: ${o}`);return Ju(e,t)},refresh:(e,t)=>Yu(e.refresh,t),async toAuth(e){return{apiKey:e.access}}};var Qu="https://openrouter.ai/auth",Zu="https://openrouter.ai/api/v1/auth/keys",el=300000,tl=30000;function ol(){return _("PI_OAUTH_CALLBACK_HOST")||"127.0.0.1"}function nl(e){let t=e.trim();if(!t)return;try{return new URL(t).searchParams.get("code")??void 0}catch{}if(t.includes("code="))return new URLSearchParams(t).get("code")??void 0;return t}function rl(e){if(typeof e.error_description==="string")return e.error_description;if(typeof e.message==="string")return e.message;if(typeof e.error==="string")return e.error;if(e.error&&typeof e.error==="object"&&!Array.isArray(e.error)){let t=e.error.message;if(typeof t==="string")return t}return}async function Ms(e,t,o){if(o.aborted)throw Error("Login cancelled");let n=new AbortController,r=()=>n.abort(o.reason);o.addEventListener("abort",r,{once:!0});let s=setTimeout(()=>n.abort(Error("OpenRouter OAuth token exchange timed out")),tl),i,d={};try{i=await fetch(Zu,{method:"POST",headers:{accept:"application/json","content-type":"application/json"},body:JSON.stringify({code:e,code_verifier:t,code_challenge_method:"S256"}),signal:n.signal});try{let c=await i.json();if(c&&typeof c==="object"&&!Array.isArray(c))d=c}catch{if(i.ok)throw Error("OpenRouter OAuth returned invalid JSON")}}catch(c){if(o.aborted)throw Error("Login cancelled");if(n.signal.aborted)throw Error("OpenRouter OAuth token exchange timed out");throw c}finally{clearTimeout(s),o.removeEventListener("abort",r)}if(!i.ok){let c=rl(d);throw Error(`OpenRouter OAuth key exchange failed (HTTP ${i.status})${c?`: ${c}`:""}`)}if(typeof d.key!=="string"||d.key.length===0)throw Error('OpenRouter OAuth response carries no "key"');return{type:"oauth",access:d.key,refresh:"",expires:Number.MAX_SAFE_INTEGER}}async function sl(e){let{verifier:t,challenge:o}=await N(),n=await K({providerName:"OpenRouter",host:ol(),port:0,path:`/oauth/callback/${crypto.randomUUID()}`,complete:(r)=>Ms(r,t,e.signal),signal:e.signal,timeoutMs:el});try{let r=new URL(Qu);r.search=new URLSearchParams({callback_url:n.redirectUri,code_challenge:o,code_challenge_method:"S256"}).toString(),e.notify({type:"progress",message:`Listening for OpenRouter OAuth callback on ${n.redirectUri}`}),e.notify({type:"auth_url",url:r.toString(),instructions:"Complete sign-in in your browser. If the browser is on another machine, paste the final redirect URL here."});let s=await ve(e,n,{message:"Complete sign-in in your browser, or paste the authorization code / redirect URL here:",placeholder:n.redirectUri});if(s.type==="callback")return s.value;let i=nl(s.input);if(!i)throw Error("Missing authorization code");return e.notify({type:"progress",message:"Exchanging authorization code for an API key..."}),await Ms(i,t,e.signal)}finally{n.close()}}var Us={name:"OpenRouter OAuth",loginLabel:"Sign in with OpenRouter",login:sl,async refresh(e,t){return e},async toAuth(e){return{apiKey:e.access}}};var $s="127.0.0.1",Fs=1456,Hs="/oauth/callback",Oo=`http://${$s}:${Fs}${Hs}`,il=60000,Bs="browser",Ds="device-code",Ke="pi-gateway",Ws="gateway offline_access",al="urn:ietf:params:oauth:grant-type:device_code";async function cl(e,t){let o=await fetch(new URL("/v1/oauth",e),{headers:{accept:"application/json"},signal:t});if(!o.ok)throw Error(`Could not load Radius OAuth config from ${e}: ${o.status} ${await o.text()}`);let n=await o.json();if(typeof n.authorizationEndpoint!=="string")throw Error(`Invalid Radius OAuth config from ${e}`);return{authorizationEndpoint:n.authorizationEndpoint}}class Po extends Error{status;oauthError;constructor(e,t,o,n){let r=t?o?`${t}: ${o}`:t:o||String(e);super(`${n}: ${r}`);this.status=e,this.oauthError=t}}async function Vs(e,t){let o=await e.text().catch(()=>""),n,r;if(o)try{let s=JSON.parse(o);n=typeof s.error==="string"?s.error:void 0,r=typeof s.error_description==="string"?s.error_description:void 0}catch{r=o}return new Po(e.status,n,r,t)}async function Go(e,t,o){let n;try{n=await fetch(new URL("/v1/oauth/token",e),{method:"POST",headers:{accept:"application/json","content-type":"application/x-www-form-urlencoded"},body:t,signal:o})}catch(s){if(o.aborted)throw Error("Login cancelled");throw s}if(!n.ok)throw await Vs(n,"Radius OAuth token request failed");let r=await n.json();return{type:"oauth",access:r.access_token,refresh:r.refresh_token,expires:Date.now()+r.expires_in*1000-il,scope:r.scope}}async function dl(e,t,o){let{verifier:n,challenge:r}=await N(),s=crypto.randomUUID(),i=new URL(t);i.search=new URLSearchParams({response_type:"code",client_id:Ke,redirect_uri:Oo,scope:Ws,code_challenge:r,code_challenge_method:"S256",handoff:"url",state:s}).toString();let d=await K({providerName:"Radius",host:$s,port:Fs,path:Hs,state:s,complete:(c)=>Go(e,new URLSearchParams({grant_type:"authorization_code",client_id:Ke,redirect_uri:Oo,code:c,code_verifier:n}),o.signal),signal:o.signal});o.notify({type:"progress",message:`Listening for OAuth callback on ${Oo}`}),o.notify({type:"auth_url",url:i.toString(),instructions:"Continue in your browser."});try{let c=await d.wait();if(!c)throw Error("OAuth callback did not complete.");return c}finally{d.close()}}async function ul(e,t){let o;try{o=await fetch(new URL("/v1/oauth/device",e),{method:"POST",headers:{accept:"application/json","content-type":"application/x-www-form-urlencoded"},body:new URLSearchParams({client_id:Ke,scope:Ws}),signal:t})}catch(r){if(t.aborted)throw Error("Login cancelled");throw r}if(!o.ok)throw await Vs(o,"Radius OAuth device authorization failed");let n=await o.json();if(!n.device_code||!n.user_code||!n.verification_uri||!n.expires_in)throw Error("Radius OAuth device authorization response is missing required fields");return{device_code:n.device_code,user_code:n.user_code,verification_uri:n.verification_uri,expires_in:n.expires_in,interval:n.interval}}async function ll(e,t){let o=await ul(e,t.signal);return t.notify({type:"device_code",userCode:o.user_code,verificationUri:o.verification_uri,intervalSeconds:o.interval,expiresInSeconds:o.expires_in}),b({intervalSeconds:o.interval,expiresInSeconds:o.expires_in,signal:t.signal,poll:async()=>{try{return{status:"complete",value:await Go(e,new URLSearchParams({grant_type:al,client_id:Ke,device_code:o.device_code}),t.signal)}}catch(n){if(!(n instanceof Po))throw n;switch(n.oauthError){case"authorization_pending":return{status:"pending"};case"slow_down":return{status:"slow_down"};case"expired_token":return{status:"failed",message:"Device authorization expired."};case"access_denied":return{status:"failed",message:"Device authorization was denied."};default:throw n}}}})}function Ks(e){let t=rr(e.gateway);return{name:e.name,async login(o){let n=await o.prompt({type:"select",message:`Sign in to ${e.name}:`,options:[{id:Bs,label:"Sign in with browser (recommended)"},{id:Ds,label:"Sign in with device code (when signing in from another device)"}]});if(n===Ds)return ll(t,o);if(n===Bs){let r=await cl(t,o.signal);return dl(t,r.authorizationEndpoint,o)}throw Error(`Unknown ${e.name} sign-in method: ${n}`)},async refresh(o,n){return await Go(t,new URLSearchParams({grant_type:"refresh_token",client_id:Ke,refresh_token:o.refresh}),n)},async toAuth(o){return{apiKey:o.access}}}}var bo="b1a00492-073a-47ea-816f-4c329264a828",pl="openid profile email offline_access grok-cli:access api:access",_l="https://auth.x.ai/oauth2/device/code",zs="https://auth.x.ai/oauth2/token",hl=300000,fl=3600;function ze(e,t){let o=e[t];if(typeof o!=="string"||o.length===0)throw Error(`Invalid xAI OAuth response field: ${t}`);return o}function Xs(e,t){let o=e[t];if(typeof o!=="number"||!Number.isFinite(o)||o<=0)throw Error(`Invalid xAI OAuth response field: ${t}`);return o}function js(e){let t;try{t=new URL(e)}catch{throw Error("Untrusted verification URI in xAI OAuth response")}if(t.protocol!=="https:")throw Error("Untrusted verification URI in xAI OAuth response");return t.href}async function No(e,t,o){let n;try{n=await fetch(e,{method:"POST",headers:{Accept:"application/json","Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams(t),signal:o})}catch(s){if(o.aborted)throw Error("Login cancelled");throw s}let r;try{let s=await n.json();r=s&&typeof s==="object"&&!Array.isArray(s)?s:{}}catch{if(o.aborted)throw Error("Login cancelled");throw Error(`xAI OAuth returned invalid JSON (HTTP ${n.status})`)}return{ok:n.ok,status:n.status,body:r}}function Lo(e,t){let o=typeof t.body.error==="string"?t.body.error:void 0,n=typeof t.body.error_description==="string"?t.body.error_description:void 0,r=[o,n].filter(Boolean).join(": ");return Error(`xAI OAuth ${e} failed (HTTP ${t.status})${r?`: ${r}`:""}`)}function ml(e){let t=e.interval,o=typeof t==="number"&&Number.isFinite(t)&&t>0?t:void 0,n=typeof e.verification_uri_complete==="string"&&e.verification_uri_complete.length>0?js(e.verification_uri_complete):void 0;return{deviceCode:ze(e,"device_code"),userCode:ze(e,"user_code"),verificationUri:js(ze(e,"verification_uri")),verificationUriComplete:n,intervalSeconds:o,expiresInSeconds:Xs(e,"expires_in")}}function qs(e,t){let o=ze(e,"access_token"),n=e.refresh_token===void 0&&t?t:ze(e,"refresh_token"),r=e.expires_in===void 0?fl:Xs(e,"expires_in");return{type:"oauth",access:o,refresh:n,expires:Date.now()+r*1000-hl}}async function gl(e){let t=await No(_l,{client_id:bo,scope:pl,referrer:"pi"},e);if(!t.ok)throw Lo("device authorization",t);return ml(t.body)}async function Cl(e,t){return b({intervalSeconds:e.intervalSeconds,expiresInSeconds:e.expiresInSeconds,waitBeforeFirstPoll:!0,signal:t,poll:async()=>{let o=await No(zs,{grant_type:"urn:ietf:params:oauth:grant-type:device_code",client_id:bo,device_code:e.deviceCode},t);if(o.ok)return{status:"complete",value:qs(o.body)};let n=o.body.error;if(n==="authorization_pending")return{status:"pending"};if(n==="slow_down"){let r=o.body.interval;return{status:"slow_down",intervalSeconds:typeof r==="number"?r:void 0}}if(n==="access_denied"||n==="authorization_denied")return{status:"failed",message:"xAI device authorization was denied"};if(n==="expired_token")return{status:"failed",message:"xAI device code expired"};return{status:"failed",message:Lo("device token polling",o).message}}})}async function Sl(e){let t=await gl(e.signal);return e.notify({type:"device_code",userCode:t.userCode,verificationUri:t.verificationUriComplete??t.verificationUri,intervalSeconds:t.intervalSeconds,expiresInSeconds:t.expiresInSeconds}),Cl(t,e.signal)}async function El(e,t){let o=await No(zs,{grant_type:"refresh_token",client_id:bo,refresh_token:e},t);if(!o.ok)throw Lo("token refresh",o);return qs(o.body,e)}var Js={name:"xAI (Grok/X subscription)",isSubscription:!0,loginLabel:"Sign in with SuperGrok or X Premium",login:Sl,refresh:(e,t)=>El(e.refresh,t),async toAuth(e){return{apiKey:e.access}}};function Ys(){xi({anthropic:()=>rs,openaiCodex:()=>Ls,openaiChatGPT:()=>Ts,githubCopilot:()=>ps,openrouter:()=>Us,kimiCoding:()=>gs,meta:()=>vs,xai:()=>Js,radius:Ks})}Si(Hr);Ys();await import("./chunk-5n1qra6k.js");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bkm016/basalt",
3
- "version": "0.1.14",
3
+ "version": "0.1.15",
4
4
  "description": "Local-first AI software engineering agent runtime and web workbench",
5
5
  "license": "MIT",
6
6
  "type": "module",
package/ui-test-worker.js CHANGED
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{yr,Vn,M,Kn,Qn,Xn,en,Jn,gt,tn}from"./chunk-pdt65s31.js";import{jn,gr}from"./chunk-xk3t5ves.js";import"./chunk-38g4jd6v.js";import"./chunk-44a7f5ta.js";import{a,r,Ze,Kt}from"./chunk-qd2enpr2.js";var mh=r(function(FA){FA.removeLeadingAndTrailingHTTPWhitespace=(t)=>t.replace(/^[ \t\n\r]+/u,"").replace(/[ \t\n\r]+$/u,"");FA.removeTrailingHTTPWhitespace=(t)=>t.replace(/[ \t\n\r]+$/u,"");FA.isHTTPWhitespaceChar=(t)=>t===" "||t==="\t"||t===`
2
+ import{yr,Vn,M,Kn,Qn,Xn,en,Jn,gt,tn}from"./chunk-pdt65s31.js";import{jn,gr}from"./chunk-tszctb17.js";import"./chunk-38g4jd6v.js";import"./chunk-44a7f5ta.js";import{a,r,Ze,Kt}from"./chunk-qd2enpr2.js";var mh=r(function(FA){FA.removeLeadingAndTrailingHTTPWhitespace=(t)=>t.replace(/^[ \t\n\r]+/u,"").replace(/[ \t\n\r]+$/u,"");FA.removeTrailingHTTPWhitespace=(t)=>t.replace(/[ \t\n\r]+$/u,"");FA.isHTTPWhitespaceChar=(t)=>t===" "||t==="\t"||t===`
3
3
  `||t==="\r";FA.solelyContainsHTTPTokenCodePoints=(t)=>/^[-!#$%&'*+.^_`|~A-Za-z0-9]*$/u.test(t);FA.soleyContainsHTTPQuotedStringTokenCodePoints=(t)=>/^[\t\u0020-\u007E\u0080-\u00FF]*$/u.test(t);FA.asciiLowercase=(t)=>t.replace(/[A-Z]/ug,(e)=>e.toLowerCase());FA.collectAnHTTPQuotedString=(t,e)=>{let o="";e++;while(!0){while(e<t.length&&t[e]!=='"'&&t[e]!=="\\")o+=t[e],++e;if(e>=t.length)break;let i=t[e];if(++e,i==="\\"){if(e>=t.length){o+="\\";break}o+=t[e],++e}else break}return[o,e]}});var PS=r(function(z2,fS){var{asciiLowercase:Rc,solelyContainsHTTPTokenCodePoints:WA,soleyContainsHTTPQuotedStringTokenCodePoints:_A}=mh();fS.exports=class{constructor(e){this._map=e}get size(){return this._map.size}get(e){return e=Rc(String(e)),this._map.get(e)}has(e){return e=Rc(String(e)),this._map.has(e)}set(e,o){if(e=Rc(String(e)),o=String(o),!WA(e))throw Error(`Invalid MIME type parameter name "${e}": only HTTP token code points are valid.`);if(!_A(o))throw Error(`Invalid MIME type parameter value "${o}": only HTTP quoted-string token code points are valid.`);return this._map.set(e,o)}clear(){this._map.clear()}delete(e){return e=Rc(String(e)),this._map.delete(e)}forEach(e,o){this._map.forEach(e,o)}keys(){return this._map.keys()}values(){return this._map.values()}entries(){return this._map.entries()}[Symbol.iterator](){return this._map[Symbol.iterator]()}}});var ES=r(function(J2,wS){var{removeLeadingAndTrailingHTTPWhitespace:YA,removeTrailingHTTPWhitespace:AS,isHTTPWhitespaceChar:KA,solelyContainsHTTPTokenCodePoints:cg,soleyContainsHTTPQuotedStringTokenCodePoints:QA,asciiLowercase:dg,collectAnHTTPQuotedString:jA}=mh();wS.exports=(t)=>{t=YA(t);let e=0,o="";while(e<t.length&&t[e]!=="/")o+=t[e],++e;if(o.length===0||!cg(o))return null;if(e>=t.length)return null;++e;let i="";while(e<t.length&&t[e]!==";")i+=t[e],++e;if(i=AS(i),i.length===0||!cg(i))return null;let s={type:dg(o),subtype:dg(i),parameters:new Map};while(e<t.length){++e;while(KA(t[e]))++e;let n="";while(e<t.length&&t[e]!==";"&&t[e]!=="=")n+=t[e],++e;if(n=dg(n),e<t.length){if(t[e]===";")continue;++e}let l=null;if(t[e]==='"'){[l,e]=jA(t,e);while(e<t.length&&t[e]!==";")++e}else{l="";while(e<t.length&&t[e]!==";")l+=t[e],++e;if(l=AS(l),l==="")continue}if(n.length>0&&cg(n)&&QA(l)&&!s.parameters.has(n))s.parameters.set(n,l)}return s}});var vS=r(function(Z2,xS){var{solelyContainsHTTPTokenCodePoints:qA}=mh();xS.exports=(t)=>{let e=`${t.type}/${t.subtype}`;if(t.parameters.size===0)return e;for(let[o,i]of t.parameters){if(e+=";",e+=o,e+="=",!qA(i)||i.length===0)i=i.replace(/(["\\])/ug,"\\$1"),i=`"${i}"`;e+=i}return e}});var LS=r(function(tU,NS){var $A=PS(),XA=ES(),zA=vS(),{asciiLowercase:TS,solelyContainsHTTPTokenCodePoints:CS}=mh();NS.exports=class{constructor(e){e=String(e);let o=XA(e);if(o===null)throw Error(`Could not parse MIME type string "${e}"`);this._type=o.type,this._subtype=o.subtype,this._parameters=new $A(o.parameters)}static parse(e){try{return new this(e)}catch(o){return null}}get essence(){return`${this.type}/${this.subtype}`}get type(){return this._type}set type(e){if(e=TS(String(e)),e.length===0)throw Error("Invalid type: must be a non-empty string");if(!CS(e))throw Error(`Invalid type ${e}: must contain only HTTP token code points`);this._type=e}get subtype(){return this._subtype}set subtype(e){if(e=TS(String(e)),e.length===0)throw Error("Invalid subtype: must be a non-empty string");if(!CS(e))throw Error(`Invalid subtype ${e}: must contain only HTTP token code points`);this._subtype=e}get parameters(){return this._parameters}toString(){return zA(this)}isJavaScript({prohibitParameters:e=!1}={}){switch(this._type){case"text":switch(this._subtype){case"ecmascript":case"javascript":case"javascript1.0":case"javascript1.1":case"javascript1.2":case"javascript1.3":case"javascript1.4":case"javascript1.5":case"jscript":case"livescript":case"x-ecmascript":case"x-javascript":return!e||this._parameters.size===0;default:return!1}case"application":switch(this._subtype){case"ecmascript":case"javascript":case"x-ecmascript":case"x-javascript":return!e||this._parameters.size===0;default:return!1}default:return!1}}isXML(){return this._subtype==="xml"&&(this._type==="text"||this._type==="application")||this._subtype.endsWith("+xml")}isHTML(){return this._subtype==="html"&&this._type==="text"}}});var $d={};Ze($d,{PluginWebUIContext:()=>qd,SlotButton:()=>kw,useDraftReplace:()=>Lw,usePluginWebUI:()=>OS});var Lg={};Kt(Lg,{Fragment:()=>GS,jsxDEV:()=>US},{Fragment:(D5)=>GS=D5,jsxDEV:(D5)=>US=D5});var kg={};Kt(kg,{Fragment:()=>WS,jsx:()=>_S,jsxs:()=>YS},{Fragment:(B5)=>WS=B5,jsx:(B5)=>_S=B5,jsxs:(B5)=>YS=B5});var An=(t)=>globalThis.postMessage(t),lf=0,zd=new Map;function Rg(t,e){let o=lf++;return new Promise((i,s)=>{zd.set(o,{resolve:i,reject:s}),e.addEventListener("abort",()=>An({type:"cancel",id:o}),{once:!0}),An({type:"request",id:o,input:t})})}function Fg(t){let e=zd.get(t.id);if(zd.delete(t.id),t.error)e?.reject(Error(t.error));else if(t.response)e?.resolve(t.response)}var af="http://basalt.internal";function mf(t){if(!t.startsWith("/api/")||/[\\\r\n#]/.test(t)||!new URL(t,af).pathname.startsWith("/api/"))throw Error("request path must stay within /api/")}function yf(t,e){return new Promise((o,i)=>{let n=setTimeout(()=>{e.removeEventListener("abort",l),o()},t),l=()=>{clearTimeout(n),e.removeEventListener("abort",l),i(Error("Request aborted"))};e.addEventListener("abort",l,{once:!0})})}function pf(t){if(t===void 0||t===null)return;if(typeof t!=="string")throw Error("ui_test requests require a JSON string body");if(!t)return;let e=JSON.parse(t);if(!e||typeof e!=="object"||Array.isArray(e))throw Error("request body must be a JSON object");return e}function Vg(t,e){return{async request(o,i){mf(o);let s=(i?.method??"GET").toUpperCase(),n=i?.signal?AbortSignal.any([i.signal,e]):e;n.throwIfAborted();let l=`${s} ${o}`,y=t&&Object.hasOwn(t,l)?t[l]:void 0;if(y){if(await yf(y.delayMs??0,n),n.throwIfAborted(),y.status<200||y.status>=300)throw Error(`Request failed (${y.status})`);return structuredClone(y.body)}let u=await Rg({path:o,method:s,body:pf(i?.body)},n);if(n.throwIfAborted(),u.status<200||u.status>=300)throw Error(`Request failed (${u.status})`);if(u.truncated)throw Error("API response exceeds ui_test response limit");return JSON.parse(u.body)}}}function Dg(t,e){let o=t.ownerDocument;function i(E){for(let R=E;R;R=R.parentElement){if(R.hasAttribute("hidden")||R.getAttribute("aria-hidden")==="true")return!1;let H=e.getComputedStyle(R);if(H.display==="none"||H.visibility==="hidden")return!1}return!0}function s(E){let R=E.getAttribute("aria-label");if(R!==null)return R;let H=E.getAttribute("aria-labelledby");if(H)return H.split(/\s+/).map((yt)=>o.getElementById(yt)?.textContent??"").join(" ");if("labels"in E){let yt=Array.from(E.labels??[]);if(yt.length)return yt.map((bt)=>bt.textContent).join(" ")}return E.textContent??""}function n(E){return E.hasAttribute("disabled")||E.getAttribute("aria-disabled")==="true"}function l(E){let R=[],H=o.createTreeWalker(E,4);while(H.nextNode()){let yt=H.currentNode,bt=yt?.parentElement;if(bt&&!bt.closest("script,style,textarea")&&i(bt))R.push(yt?.textContent??"")}return R.join(" ").replace(/\s+/g," ").trim()}function y(){return Array.from(t.querySelectorAll("button,[role=button]")).filter(i).map((E)=>({name:s(E).trim(),disabled:n(E),busy:E.getAttribute("aria-busy")==="true"}))}function u(){return Array.from(t.querySelectorAll("input,textarea,select")).filter((E)=>E instanceof e.HTMLInputElement||E instanceof e.HTMLTextAreaElement||E instanceof e.HTMLSelectElement).filter(i).map((E)=>({label:s(E).trim(),value:E.value}))}function c(E=t,R=!0){let H=l(E),yt=y(),bt=u();if(!R)return{text:H,buttons:yt,values:bt,truncated:!1};let Rt=new TextEncoder().encode(H);return{text:new TextDecoder().decode(Rt.slice(0,2048),{stream:!0}),buttons:yt.slice(0,50),values:bt.slice(0,50),truncated:Rt.length>2048||yt.length>50||bt.length>50}}function d(E,R){let H=Array.from(t.querySelectorAll(E)).filter((yt)=>yt instanceof e.HTMLElement).filter((yt)=>i(yt)&&s(yt).trim()===R);if(H.length!==1||!H[0])throw Error(`Expected one control named ${JSON.stringify(R)}, found ${H.length}`);return H[0]}function g(E){let R=Array.from(t.querySelectorAll(E)).filter(i),H=R[0];if(R.length!==1||!(H instanceof e.HTMLElement))throw Error(`Expected one visible element for ${E}, found ${R.length}`);return H}function f(E,R){let H=200,yt=(bt,Rt)=>{H--;let lt=[];if(Rt<R)for(let ct of bt.children){if(!H)break;lt.push(yt(ct,Rt+1))}return{tag:bt.tagName.toLowerCase(),role:bt.getAttribute("role"),class:bt.className,text:Array.from(bt.childNodes).filter((ct)=>ct.nodeType===3).map((ct)=>ct.textContent).join(" ").trim(),childCount:bt.children.length,children:lt}};return yt(E,0)}return{visible:i,isDisabled:n,snapshot:c,findByName:d,selectOne:g,outline:f,count:(E)=>t.querySelectorAll(E).length,anyVisible:(E)=>Array.from(t.querySelectorAll(E)).some(i)}}var ui=Symbol("abort"),Me=Symbol("activeElement"),Pt=Symbol("asyncTaskManager"),hi=Symbol("bodyBuffer"),Nt=Symbol("buffer"),Qo=Symbol("cachedResponse"),ci=Symbol("callbacks"),wn=Symbol("checked"),Ts=Symbol("childNodes"),ir=Symbol("children"),Aa=Symbol("classList"),zr=Symbol("connectedToNode"),Vi=Symbol("disconnectedFromNode"),sr=Symbol("connectedToDocument"),nr=Symbol("disconnectedFromDocument"),xl=Symbol("contentLength"),xe=Symbol("contentType"),fr=Symbol("cssText"),Do=Symbol("currentScript"),Bo=Symbol("currentTarget"),Yt=Symbol("data"),Lr=Symbol("defaultView"),At=Symbol("destroy"),En=Symbol("dirtyness"),Y=Symbol("end"),Xe=Symbol("entries"),oE=Symbol("evaluateCSS"),Oo=Symbol("evaluateScript"),Jr=Symbol("exceptionObserver"),Gt=Symbol("formNode"),xn=Symbol("internalId"),F=Symbol("height"),Cs=Symbol("immediatePropagationStopped"),vn=Symbol("indeterminate"),Ns=Symbol("isFirstWrite"),Ls=Symbol("isFirstWriteAfterOpen"),wa=Symbol("isInPassiveEventListener"),Zr=Symbol("isValue"),ks=Symbol("listenerOptions"),he=Symbol("listeners"),Hr=Symbol("itemsByName"),Ms=Symbol("nextActiveElement"),vl=Symbol("observeMutations"),to=Symbol("mutationListeners"),x=Symbol("ownerDocument"),xt=Symbol("ownerElement"),Is=Symbol("propagationStopped"),Ao=Symbol("readyStateManager"),Pr=Symbol("referrer"),di=Symbol("registry"),eo=Symbol("relList"),Ea=Symbol("resetSelection"),ve=Symbol("rootNode"),Ie=Symbol("selectNode"),Ar=Symbol("selectedness"),Tn=Symbol("selection"),Tm=Symbol("setupVMContext"),be=Symbol("shadowRoot"),O=Symbol("start"),ge=Symbol("style"),wr=Symbol("target"),ze=Symbol("textAreaNode"),xa=Symbol("unobserveMutations"),Di=Symbol("reportMutation"),Cn=Symbol("updateSelectedness"),Pe=Symbol("url"),q=Symbol("value"),V=Symbol("width"),m=Symbol("window"),vh=Symbol("windowResizeListener"),Nn=Symbol("mutationObservers"),ro=Symbol("openerFrame"),bi=Symbol("openerWindow"),Cm=Symbol("pointerCaptures"),Ln=Symbol("popup"),tt=Symbol("isConnected"),W=Symbol("parentNode"),D=Symbol("nodeType"),z=Symbol("tagName"),Ft=Symbol("prefix"),Jd=Symbol("scrollHeight"),Zd=Symbol("scrollWidth"),Th=Symbol("scrollTop"),Ch=Symbol("scrollLeft"),St=Symbol("attributes"),va=Symbol("attributesProxy"),J=Symbol("namespaceURI"),Ta=Symbol("accessKey"),iE=Symbol("accessKeyLabel"),tb=Symbol("offsetHeight"),eb=Symbol("offsetWidth"),rb=Symbol("offsetLeft"),ob=Symbol("offsetTop"),ib=Symbol("clientHeight"),sb=Symbol("clientWidth"),nb=Symbol("clientLeft"),lb=Symbol("clientTop"),rt=Symbol("name"),Nm=Symbol("specified"),Rs=Symbol("adoptedStyleSheets"),Nh=Symbol("implementation"),kn=Symbol("readyState"),Fs=Symbol("publicId"),Vs=Symbol("systemId"),Ce=Symbol("validationMessage"),Ke=Symbol("validity"),Lh=Symbol("returnValue"),Bi=Symbol("elements"),sE=Symbol("length"),ab=Symbol("complete"),mb=Symbol("naturalHeight"),yb=Symbol("naturalWidth"),Bg=Symbol("loading"),L=Symbol("x"),k=Symbol("y"),nE=Symbol("defaultChecked"),jo=Symbol("files"),Be=Symbol("sheet"),kh=Symbol("volume"),Tl=Symbol("paused"),Mh=Symbol("currentTime"),Ih=Symbol("playbackRate"),Rh=Symbol("defaultPlaybackRate"),Ca=Symbol("muted"),Cl=Symbol("defaultMuted"),Fh=Symbol("preservesPitch"),pb=Symbol("buffered"),ub=Symbol("duration"),Qe=Symbol("error"),hb=Symbol("ended"),cb=Symbol("networkState"),Vh=Symbol("textTracks"),db=Symbol("seeking"),bb=Symbol("seekable"),gb=Symbol("played"),Oi=Symbol("options"),oo=Symbol("content"),Ee=Symbol("mode"),Mn=Symbol("host"),Wr=Symbol("setURL"),ot=Symbol("localName"),Na=Symbol("classRegistry"),Lm=Symbol("nodeStream"),io=Symbol("location"),Oe=Symbol("history"),Dh=Symbol("navigator"),Bh=Symbol("screen"),Oh=Symbol("sessionStorage"),Gh=Symbol("localStorage"),km=Symbol("sandbox"),ht=Symbol("cloneNode"),Et=Symbol("appendChild"),hr=Symbol("removeChild"),kr=Symbol("insertBefore"),La=Symbol("replaceChild"),gi=Symbol("tracks"),ka=Symbol("constraints"),Si=Symbol("capabilities"),In=Symbol("settings"),lE=Symbol("clone"),Ds=Symbol("removeNamedItem"),Q=Symbol("items"),Rn=Symbol("selectedOptions"),cr=Symbol("styleNode"),Fn=Symbol("updateSheet"),Mr=Symbol("clearCache"),Re=Symbol("onSetAttribute"),dr=Symbol("onRemoveAttribute"),_=Symbol("nodeArray"),dt=Symbol("elementArray"),U=Symbol("cache"),He=Symbol("affectsCache"),Ma=Symbol("forms"),qo=Symbol("affectsComputedStyleCache"),Nl=Symbol("query"),Ll=Symbol("computedStyle"),so=Symbol("getFormControlItems"),Mm=Symbol("getFormControlNamedItem"),Uh=Symbol("dataset"),aE=Symbol("getNamespaceItemKey"),mE=Symbol("getNamedItemKey"),fi=Symbol("itemsByNamespaceURI"),Vt=Symbol("proxy"),$o=Symbol("setNamedItem"),Er=Symbol("getTokenList"),Bs=Symbol("attributeName"),Go=Symbol("selectedIndex"),Dn=Symbol("self"),no=Symbol("parent"),Xo=Symbol("top"),Im=Symbol("areas"),lo=Symbol("defaultValue"),Pi=Symbol("elementIdMap"),Bn=Symbol("clonable"),kl=Symbol("delegatesFocus"),Gi=Symbol("serializable"),Ai=Symbol("slotAssignment"),Ui=Symbol("assignedNodes"),zo=Symbol("assignedToSlot"),Rm=Symbol("cells"),Fm=Symbol("rows"),Hh=Symbol("headers"),Vm=Symbol("tBodies"),Ia=Symbol("track"),Dm=Symbol("controlsList"),Wh=Symbol("mediaKeys"),Sb=Symbol("remote"),_h=Symbol("sinkId"),Yh=Symbol("srcObject"),Ml=Symbol("cues"),fb=Symbol("activeCues"),wo=Symbol("kind"),Os=Symbol("label"),Il=Symbol("language"),Bm=Symbol("id"),h=Symbol("illegalConstructor"),Pb=Symbol("state"),Om=Symbol("canvas"),On=Symbol("popoverTargetElement"),Gm=Symbol("composed"),Gs=Symbol("bubbles"),Hi=Symbol("cancelable"),lr=Symbol("defaultPrevented"),xr=Symbol("eventPhase"),Ab=Symbol("timeStamp"),Qt=Symbol("type"),Um=Symbol("detail"),yE=Symbol("globalObject"),Hm=Symbol("destroyed"),Se=Symbol("aborted"),Wm=Symbol("browserFrames"),Kh=Symbol("windowInternalId"),K=Symbol("getItemList"),Wi=Symbol("requiredExtensions"),_i=Symbol("systemLanguage"),_m=Symbol("transform"),se=Symbol("baseVal"),ne=Symbol("animVal"),Ym=Symbol("pathLength"),pE=Symbol("unitType"),Yi=Symbol("viewBox"),Km=Symbol("markerUnits"),Qm=Symbol("markerWidth"),jm=Symbol("markerHeight"),Je=Symbol("values"),qm=Symbol("orientType"),$m=Symbol("orientAngle"),Xm=Symbol("refX"),zm=Symbol("refY"),j=Symbol("readOnly"),ar=Symbol("preserveAspectRatio"),Ki=Symbol("animatedPoints"),Qi=Symbol("points"),ji=Symbol("rx"),qi=Symbol("ry"),ao=Symbol("cx"),mo=Symbol("cy"),$i=Symbol("r"),Jm=Symbol("clipPathUnits"),Zm=Symbol("maskUnits"),ty=Symbol("maskContentUnits"),ey=Symbol("filterUnits"),ry=Symbol("primitiveUnits"),Lt=Symbol("href"),Xi=Symbol("x1"),zi=Symbol("y1"),Ji=Symbol("x2"),Zi=Symbol("y2"),oy=Symbol("gradientUnits"),iy=Symbol("gradientTransform"),sy=Symbol("spreadMethod"),ny=Symbol("patternUnits"),ly=Symbol("patternContentUnits"),ay=Symbol("patternTransform"),my=Symbol("fx"),yy=Symbol("fy"),ts=Symbol("offset"),Gn=Symbol("disabled"),py=Symbol("textLength"),uy=Symbol("lengthAdjust"),v=Symbol("getAttribute"),A=Symbol("setAttribute"),Ir=Symbol("z"),Rl=Symbol("w"),hy=Symbol("toArray"),Fl=Symbol("fromString"),Eo=Symbol("fromArray"),uE=Symbol("angle"),kt=Symbol("m11"),Dt=Symbol("m12"),zt=Symbol("m13"),Jt=Symbol("m14"),Mt=Symbol("m21"),Bt=Symbol("m22"),Zt=Symbol("m23"),te=Symbol("m24"),Ht=Symbol("m31"),jt=Symbol("m32"),qt=Symbol("m33"),Wt=Symbol("m34"),It=Symbol("m41"),Ot=Symbol("m42"),$t=Symbol("m43"),Xt=Symbol("m44"),Ra=Symbol("setMatrixValue"),xo=Symbol("translateSelf"),Us=Symbol("rotateSelf"),Hs=Symbol("rotateAxisAngleSelf"),es=Symbol("scaleSelf"),cy=Symbol("scale3dSelf"),dy=Symbol("scaleNonUniformSelf"),Vl=Symbol("skewXSelf"),Dl=Symbol("skewYSelf"),vo=Symbol("multiplySelf"),Ws=Symbol("matrix"),hE=Symbol("domMatrix"),Ne=Symbol("getDOMMatrix"),br=Symbol("setDOMMatrix"),I=Symbol("attributeValue"),by=Symbol("startOffset"),_s=Symbol("method"),gy=Symbol("spacing"),at=Symbol("in1"),yo=Symbol("in2"),Z=Symbol("result"),Sy=Symbol("bias"),fy=Symbol("divisor"),rs=Symbol("edgeMode"),Py=Symbol("kernelMatrix"),po=Symbol("kernelUnitLengthX"),uo=Symbol("kernelUnitLengthY"),Ay=Symbol("orderX"),wy=Symbol("orderY"),Ey=Symbol("preserveAlpha"),xy=Symbol("targetX"),vy=Symbol("targetY"),Ty=Symbol("diffuseConstant"),os=Symbol("surfaceScale"),Cy=Symbol("scale"),Ny=Symbol("xChannelSelector"),Ly=Symbol("yChannelSelector"),ky=Symbol("azimuth"),My=Symbol("elevation"),ho=Symbol("dx"),co=Symbol("dy"),is=Symbol("stdDeviationX"),ss=Symbol("stdDeviationY"),Iy=Symbol("tableValues"),Ry=Symbol("slope"),Fy=Symbol("intercept"),Vy=Symbol("amplitude"),Dy=Symbol("exponent"),Og=Symbol("crossOrigin"),By=Symbol("operator"),Oy=Symbol("radiusX"),Gy=Symbol("radiusY"),Uy=Symbol("specularConstant"),ns=Symbol("specularExponent"),Hy=Symbol("pointsAtX"),Wy=Symbol("pointsAtY"),_y=Symbol("pointsAtZ"),Yy=Symbol("limitingConeAngle"),Ky=Symbol("baseFrequencyX"),Qy=Symbol("baseFrequencyY"),jy=Symbol("numOctaves"),qy=Symbol("seed"),$y=Symbol("stitchTiles"),Xy=Symbol("rotateFromVectorSelf"),zy=Symbol("flipXSelf"),Jy=Symbol("flipYSelf"),Zy=Symbol("invertSelf"),wb=Symbol("getLength"),Qh=Symbol("currentScale"),tp=Symbol("rotate"),Eb=Symbol("bindMethods"),Un=Symbol("xmlProcessingInstruction"),cE=Symbol("root"),Uo=Symbol("filterNode"),Ys=Symbol("customElementReactionStack"),Hn=Symbol("dispatching"),ls=Symbol("modules"),Rr=Symbol("preloads"),Ks=Symbol("body"),jh=Symbol("redirect"),Fa=Symbol("referrerPolicy"),qh=Symbol("signal"),wi=Symbol("bodyUsed"),$h=Symbol("credentials"),ep=Symbol("blocking"),Bl=Symbol("moduleImportMap"),le=Symbol("dispatchError"),Xh=Symbol("supports"),To=Symbol("reason"),p=Symbol("propertyEventListeners"),We=Symbol("cssRules"),Qs=Symbol("parentRule"),Co=Symbol("parentStyleSheet"),bo=Symbol("conditionText"),as=Symbol("keyText"),xb=Symbol("media"),rp=Symbol("styleMap"),Ol=Symbol("selectorText"),Gl=Symbol("cssParser"),js=Symbol("cssRule"),Fr=Symbol("rulePrefix"),_r=Symbol("virtualServerFile"),vb=Symbol("frames"),qs=Symbol("disableEvaluation"),Tb=Symbol("validateJavaScriptExecutionEnvironment"),dE=Symbol("currentNode"),Wn=Symbol("openWebSockets"),vr=Symbol("webSocket"),Va=Symbol("moduleCache");var Cb;(function(t){t.strict="Strict",t.lax="Lax",t.none="None"})(Cb||(Cb={}));var $s=Cb;var zh={key:null,originURL:null,value:null,domain:"",path:"",expires:null,httpOnly:!1,secure:!1,sameSite:$s.lax};class op{static hasExpired(t){return t.expires&&t.expires.getTime()<Date.now()}}class Jh{static cookieMatchesURL(t,e){let o=e.hostname==="localhost"||e.hostname?.endsWith(".localhost");return(!t.secure||e.protocol==="https:"||o)&&(!t.domain||e.hostname?.endsWith(t.domain))&&(!t.path||e.pathname?.startsWith(t.path))&&(t.sameSite===$s.none&&t.secure||t.originURL?.hostname===e.hostname)}}class ip{#t=[];addCookies(t){let e=new Map,o=(i)=>`${i.key}-${i.originURL.hostname}-${i.path}-${typeof i.value}`;for(let i=0,s=this.#t.length;i<s;i++)e.set(o(this.#t[i]),i);for(let i of t){let s=Object.assign({},zh,i);if(s&&s.key&&s.originURL){let n=e.get(o(s));if(n!==void 0)this.#t.splice(n,1);if(!op.hasExpired(s))e.set(o(s),this.#t.length),this.#t.push(s)}}}getCookies(t=null,e=!1){let o=[];for(let i of this.#t)if(!op.hasExpired(i)&&(!e||!i.httpOnly)&&(!t||Jh.cookieMatchesURL(i,t)))o.push(i);return o}clearCookies(){this.#t=[]}}var Nb;(function(t){t.fresh="fresh",t.stale="stale"})(Nb||(Nb={}));var _n=Nb;var Lb;(function(t){t.invalidStateError="InvalidStateError",t.indexSizeError="IndexSizeError",t.syntaxError="SyntaxError",t.hierarchyRequestError="HierarchyRequestError",t.notSupportedError="NotSupportedError",t.wrongDocumentError="WrongDocumentError",t.invalidNodeTypeError="InvalidNodeTypeError",t.invalidCharacterError="InvalidCharacterError",t.notFoundError="NotFoundError",t.securityError="SecurityError",t.networkError="NetworkError",t.domException="DOMException",t.invalidAccessError="InvalidAccessError",t.unknownError="UnknownError",t.abortError="AbortError",t.timeoutError="TimeoutError",t.encodingError="EncodingError",t.uriMismatchError="URIMismatchError",t.inUseAttributeError="InUseAttributeError",t.namespaceError="NamespaceError"})(Lb||(Lb={}));var w=Lb;class re extends Error{constructor(t,e=null){super(t);this.name=e||w.domException}}class Ei{[Xe]={};constructor(t){if(t)if(t instanceof Ei)this[Xe]=JSON.parse(JSON.stringify(t[Xe]));else if(Array.isArray(t))for(let e of t){if(e.length!==2)throw new re('Failed to construct "Headers": The provided init is not a valid array.',w.invalidStateError);this.append(e[0],e[1])}else for(let e of Object.keys(t))this.set(e,t[e])}append(t,e){let o=t.toLowerCase();if(this[Xe][o])this[Xe][o].value.push(e);else this[Xe][o]={name:t,value:[e]}}delete(t){delete this[Xe][t.toLowerCase()]}get(t){return this[Xe][t.toLowerCase()]?.value.join(", ")??null}set(t,e){this[Xe][t.toLowerCase()]={name:t,value:[e]}}getSetCookie(){let t=this[Xe]["set-cookie"];if(!t)return[];return t.value}has(t){return!!this[Xe][t.toLowerCase()]}forEach(t,e){let o=e??this[m];for(let i of Object.values(this[Xe]))t.call(o,i.value.join(", "),i.name,this)}*keys(){for(let t of Object.values(this[Xe]))yield t.name}*values(){for(let t of Object.values(this[Xe]))yield t.value.join(", ")}*entries(){for(let t of Object.values(this[Xe]))yield[t.name,t.value.join(", ")]}*[Symbol.iterator](){for(let t of Object.values(this[Xe]))yield[t.name,t.value.join(", ")]}}import Da from"fs";import Ba from"path";import uf from"crypto";class Zh{#t=new Set;#e=new Set;#r;constructor(t){this.#r=t}async load(t){if(!t)throw Error("Failed to execute 'load' on 'ResponseCacheFileSystem': Directory is not specified.");let e=Ba.resolve(t),o=[];try{o=await Da.promises.readdir(e)}catch(n){return}let i=[],s=this.#r;for(let n of o)if(n.endsWith(".json"))i.push(Da.promises.readFile(Ba.join(e,n),"utf8").then((l)=>{let y=JSON.parse(l);if(y.response&&y.request&&!y.virtual)return y.response.headers=new Ei(y.response.headers),y.request.headers=new Ei(y.request.headers),Da.promises.readFile(Ba.join(e,n.split(".")[0]+".data")).then((u)=>{y.response.body=u;let c=s.get(y.response.url);if(!c)c=[],s.set(y.response.url,c);c.push(y)}).catch(()=>{let u=s.get(y.response.url);if(!u)u=[],s.set(y.response.url,u);u.push(y)})}).catch(()=>{}));await Promise.all(i)}async save(t){if(!t)throw Error("Failed to execute 'store' on 'ResponseCacheFileSystem': Directory is not specified.");if(!this.#r.size)return;let e=Ba.resolve(t);if(!this.#t.has(e)){this.#t.add(e);try{await Da.promises.mkdir(e,{recursive:!0})}catch(n){}}let i=this.#r,s=[];for(let n of i.values())for(let l of n)if(!l.virtual){let y={},u={};for(let[f,E]of l.response.headers.entries())y[f]=E;for(let[f,E]of l.request.headers.entries())u[f]=E;let c={...l,response:{...l.response,headers:y,body:null},request:{...l.request,headers:u}},d=JSON.stringify(c,null,3),g=uf.createHash("md5").update(d).digest("hex");if(!this.#e.has(g)){if(this.#e.add(g),s.push(Da.promises.writeFile(Ba.join(e,`${g}.json`),d)),l.response.body)s.push(Da.promises.writeFile(Ba.join(e,`${g}.data`),l.response.body))}}await Promise.all(s)}}var hf=["Cache-Control","Last-Modified","Vary","ETag"];class sp{fileSystem;#t=new Map;constructor(){this.fileSystem=new Zh(this.#t)}get(t){if(t.headers.get("Cache-Control")?.includes("no-cache"))return null;let e=t.url,o=this.#t.get(e);if(o)for(let i=0,s=o.length;i<s;i++){let n=o[i],l=n.request.method===t.method;if(l)for(let y of Object.keys(n.vary)){let u=t.headers.get(y);if(u!==null&&n.vary[y]!==u){l=!1;break}}if(l){if(n.expires&&n.expires<Date.now()){if(n.lastModified)n.state=_n.stale;else if(!n.etag)return o.splice(i,1),null}return n}}return null}add(t,e){if(t.method!=="GET"&&t.method!=="HEAD"||t.headers.get("Cache-Control")?.includes("no-cache"))return null;let o=t.url,i=this.get(t);if(e.status===304){if(!i)throw Error("ResponseCache: Cached response not found.");for(let s of hf)if(e.headers.has(s))i.response.headers.set(s,e.headers.get(s));i.cacheUpdateTime=Date.now(),i.state=_n.fresh}else{if(i){let n=this.#t.get(o);if(n){let l=n.indexOf(i);if(l!==-1)n.splice(l,1)}}i={response:{status:e.status,statusText:e.statusText,url:e.url,headers:new Ei(e.headers),waitingForBody:e.waitingForBody,body:e.body??null},request:{headers:t.headers,method:t.method},vary:{},expires:null,etag:null,cacheUpdateTime:Date.now(),lastModified:null,mustRevalidate:!1,staleWhileRevalidate:!1,state:_n.fresh,virtual:e.virtual??!1};let s=this.#t.get(o);if(!s)s=[],this.#t.set(o,s);s.push(i)}if(e.headers.has("Cache-Control")){let s=e.headers.get("Age");for(let n of e.headers.get("Cache-Control").split(",")){let[l,y]=n.trim().split("=");switch(l){case"max-age":i.expires=Date.now()+parseFloat(y)*1000-(s?parseFloat(s)*1000:0);break;case"no-cache":case"no-store":let u=this.#t.get(o);if(u){let c=u.indexOf(i);if(c!==-1)u.splice(c,1)}return null;case"must-revalidate":i.mustRevalidate=!0;break;case"stale-while-revalidate":i.staleWhileRevalidate=!0;break}}}if(e.headers.has("Last-Modified"))i.lastModified=Date.parse(e.headers.get("Last-Modified"));if(e.headers.has("Vary"))for(let s of e.headers.get("Vary").split(",")){let n=s.trim(),l=t.headers.get(n);if(l)i.vary[n]=l}if(e.headers.has("ETag"))i.etag=e.headers.get("ETag");if(!i.expires){let s=e.headers.get("Expires");if(s)i.expires=Date.parse(s)}if(!i.etag&&(!i.expires||i.expires<Date.now())){let s=this.#t.get(o);if(s){let n=s.indexOf(i);if(n!==-1)s.splice(n,1)}return null}return i}clear(t){if(t){if(t.toTime)for(let e of t.url?[t.url]:this.#t.keys()){let o=this.#t.get(e);if(o){for(let i=0,s=o.length;i<s;i++)if(o[i].cacheUpdateTime<t.toTime)o.splice(i,1),i--,s--}}else if(t.url)this.#t.delete(t.url)}else this.#t.clear()}}var kb;(function(t){t[t.log=0]="log",t[t.info=1]="info",t[t.warn=2]="warn",t[t.error=3]="error"})(kb||(kb={}));var mr=kb;var Mb;(function(t){t[t.elementNode=1]="elementNode",t[t.attributeNode=2]="attributeNode",t[t.textNode=3]="textNode",t[t.cdataSectionNode=4]="cdataSectionNode",t[t.commentNode=8]="commentNode",t[t.documentNode=9]="documentNode",t[t.documentTypeNode=10]="documentTypeNode",t[t.documentFragmentNode=11]="documentFragmentNode",t[t.processingInstructionNode=7]="processingInstructionNode"})(Mb||(Mb={}));var T=Mb;var Ib;(function(t){t[t.none=0]="none",t[t.capturing=1]="capturing",t[t.atTarget=2]="atTarget",t[t.bubbling=3]="bubbling"})(Ib||(Ib={}));var ae=Ib;class C{static NONE=ae.none;static CAPTURING_PHASE=ae.capturing;static AT_TARGET=ae.atTarget;static BUBBLING_PHASE=ae.bubbling;NONE=C.NONE;CAPTURING_PHASE=C.CAPTURING_PHASE;AT_TARGET=C.AT_TARGET;BUBBLING_PHASE=C.BUBBLING_PHASE;[Gm]=!1;[Gs]=!1;[Hi]=!1;[lr]=!1;[xr]=ae.none;[Ab]=performance.now();[Qt];[Hn]=!1;[Cs]=!1;[Is]=!1;[wr]=null;[Bo]=null;[wa]=!1;constructor(t,e=null){this[Qt]=t,this[Gs]=e?.bubbles??!1,this[Hi]=e?.cancelable??!1,this[Gm]=e?.composed??!1}get composed(){return this[Gm]}get bubbles(){return this[Gs]}get cancelable(){return this[Hi]}get defaultPrevented(){return this[lr]}get eventPhase(){return this[xr]}get timeStamp(){return this[Ab]}get type(){return this[Qt]}get target(){return this[wr]}get currentTarget(){return this[Bo]}get cancelBubble(){return this[Is]}composedPath(){if(!this[wr])return[];let t=[],e=this[wr];while(e)if(t.push(e),e.parentNode)e=e.parentNode;else if(this[Gm]&&e[D]===T.documentFragmentNode&&e.host)e=e.host;else if(e[D]===T.documentNode&&this[Qt]!=="load")e=e[m];else break;return t}initEvent(t,e=!1,o=!1){this[Qt]=t,this[Gs]=e,this[Hi]=o,this[Is]=!1,this[Cs]=!1,this[lr]=!1}preventDefault(){if(!this[wa]&&this.cancelable)this[lr]=!0}stopImmediatePropagation(){this[Cs]=!0}stopPropagation(){this[Is]=!0}}var Rb;(function(t){t.log="log",t.table="table",t.trace="trace",t.dir="dir",t.dirxml="dirxml",t.group="group",t.groupCollapsed="groupCollapsed",t.debug="debug",t.timeLog="timeLog",t.info="info",t.count="count",t.timeEnd="timeEnd",t.warn="warn",t.countReset="countReset",t.error="error",t.assert="assert"})(Rb||(Rb={}));var Fe=Rb;class tc{static toString(t){if(this.isLogEntryCollapsed(t))return"";let e=this.getLogEntryGroupTabbing(t),o=e;for(let i of t.message)if(o+=o!==""&&o!==e?" ":"",typeof i==="object"&&(i===null||i.constructor.name==="Object"||Array.isArray(i)))try{o+=JSON.stringify(i)}catch(s){o+=Error("Failed to JSON stringify object in log entry.").stack.replace(/\n at/gm,`
4
4
  `+e+"at")}else if(typeof i==="object"&&i.message&&i.stack)o+=i.stack.replace(/\n at/gm,`
5
5
  `+e+"at");else o+=this.getLogEntryIcon(t)+String(i);return o+`
@@ -0,0 +1 @@
1
+ import{Li}from"./chunk-dgepxev9.js";export{Li as createGitGraphServices};
@@ -1,2 +1,2 @@
1
- import{ae,Gi,We,In,xo,Fa,Ut,Vn,Be,Rr,Xr,Wn,_o,Hi,Gn}from"./chunk-zsat72qd.js";function Z(l){return l.innerRadius}function k(l){return l.outerRadius}function b(l){return l.startAngle}function _(l){return l.endAngle}function nn(l){return l&&l.padAngle}function en(l,d,q,P,x,h,S,r){var D=q-l,a=P-d,n=S-x,y=r-h,u=y*D-n*a;if(u*u<Be)return;return u=(n*(d-h)-y*(l-x))/u,[l+u*D,d+u*a]}function L(l,d,q,P,x,h,S){var r=l-q,D=d-P,a=(S?h:-h)/Vn(r*r+D*D),n=a*D,y=-a*r,u=l+n,s=d+y,t=q+n,f=P+y,j=(u+t)/2,o=(s+f)/2,g=t-u,c=f-s,v=g*g+c*c,A=x-h,R=u*f-t*s,E=(c<0?-1:1)*Vn(xo(0,A*A*v-R*R)),I=(R*c-g*E)/v,O=(-R*g-c*E)/v,T=(R*c+g*E)/v,m=(-R*g+c*E)/v,p=I-j,e=O-o,i=T-j,z=m-o;if(p*p+e*e>i*i+z*z)I=T,O=m;return{cx:I,cy:O,x01:-n,y01:-y,x11:I*(x/A-1),y11:O*(x/A-1)}}function _t(){var l=Z,d=k,q=ae(0),P=null,x=b,h=_,S=nn,r=null,D=Gn(a);function a(){var n,y,u=+l.apply(this,arguments),s=+d.apply(this,arguments),t=x.apply(this,arguments)-Xr,f=h.apply(this,arguments)-Xr,j=Gi(f-t),o=f>t;if(!r)r=n=D();if(s<u)y=s,s=u,u=y;if(!(s>Be))r.moveTo(0,0);else if(j>Wn-Be){if(r.moveTo(s*In(t),s*Ut(t)),r.arc(0,0,s,t,f,!o),u>Be)r.moveTo(u*In(f),u*Ut(f)),r.arc(0,0,u,f,t,o)}else{var g=t,c=f,v=t,A=f,R=j,E=j,I=S.apply(this,arguments)/2,O=I>Be&&(P?+P.apply(this,arguments):Vn(u*u+s*s)),T=Fa(Gi(s-u)/2,+q.apply(this,arguments)),m=T,p=T,e,i;if(O>Be){var z=Hi(O/u*Ut(I)),F=Hi(O/s*Ut(I));if((R-=z*2)>Be)z*=o?1:-1,v+=z,A-=z;else R=0,v=A=(t+f)/2;if((E-=F*2)>Be)F*=o?1:-1,g+=F,c-=F;else E=0,g=c=(t+f)/2}var B=s*In(g),C=s*Ut(g),G=u*In(A),H=u*Ut(A);if(T>Be){var J=s*In(c),K=s*Ut(c),M=u*In(v),N=u*Ut(v),w;if(j<Rr)if(w=en(B,C,M,N,J,K,G,H)){var Q=B-w[0],U=C-w[1],V=J-w[0],W=K-w[1],X=1/Ut(_o((Q*V+U*W)/(Vn(Q*Q+U*U)*Vn(V*V+W*W)))/2),Y=Vn(w[0]*w[0]+w[1]*w[1]);m=Fa(T,(u-Y)/(X-1)),p=Fa(T,(s-Y)/(X+1))}else m=p=0}if(!(E>Be))r.moveTo(B,C);else if(p>Be)if(e=L(M,N,B,C,s,p,o),i=L(J,K,G,H,s,p,o),r.moveTo(e.cx+e.x01,e.cy+e.y01),p<T)r.arc(e.cx,e.cy,p,We(e.y01,e.x01),We(i.y01,i.x01),!o);else r.arc(e.cx,e.cy,p,We(e.y01,e.x01),We(e.y11,e.x11),!o),r.arc(0,0,s,We(e.cy+e.y11,e.cx+e.x11),We(i.cy+i.y11,i.cx+i.x11),!o),r.arc(i.cx,i.cy,p,We(i.y11,i.x11),We(i.y01,i.x01),!o);else r.moveTo(B,C),r.arc(0,0,s,g,c,!o);if(!(u>Be)||!(R>Be))r.lineTo(G,H);else if(m>Be)if(e=L(G,H,J,K,u,-m,o),i=L(B,C,M,N,u,-m,o),r.lineTo(e.cx+e.x01,e.cy+e.y01),m<T)r.arc(e.cx,e.cy,m,We(e.y01,e.x01),We(i.y01,i.x01),!o);else r.arc(e.cx,e.cy,m,We(e.y01,e.x01),We(e.y11,e.x11),!o),r.arc(0,0,u,We(e.cy+e.y11,e.cx+e.x11),We(i.cy+i.y11,i.cx+i.x11),o),r.arc(i.cx,i.cy,m,We(i.y11,i.x11),We(i.y01,i.x01),!o);else r.arc(0,0,u,A,v,o)}if(r.closePath(),n)return r=null,n+""||null}return a.centroid=function(){var n=(+l.apply(this,arguments)+ +d.apply(this,arguments))/2,y=(+x.apply(this,arguments)+ +h.apply(this,arguments))/2-Rr/2;return[In(y)*n,Ut(y)*n]},a.innerRadius=function(n){return arguments.length?(l=typeof n==="function"?n:ae(+n),a):l},a.outerRadius=function(n){return arguments.length?(d=typeof n==="function"?n:ae(+n),a):d},a.cornerRadius=function(n){return arguments.length?(q=typeof n==="function"?n:ae(+n),a):q},a.padRadius=function(n){return arguments.length?(P=n==null?null:typeof n==="function"?n:ae(+n),a):P},a.startAngle=function(n){return arguments.length?(x=typeof n==="function"?n:ae(+n),a):x},a.endAngle=function(n){return arguments.length?(h=typeof n==="function"?n:ae(+n),a):h},a.padAngle=function(n){return arguments.length?(S=typeof n==="function"?n:ae(+n),a):S},a.context=function(n){return arguments.length?(r=n==null?null:n,a):r},a}
1
+ import{ae,Gi,We,In,xo,Fa,Ut,Vn,Be,Rr,Xr,Wn,_o,Hi,Gn}from"./chunk-t5ke9cyg.js";function Z(l){return l.innerRadius}function k(l){return l.outerRadius}function b(l){return l.startAngle}function _(l){return l.endAngle}function nn(l){return l&&l.padAngle}function en(l,d,q,P,x,h,S,r){var D=q-l,a=P-d,n=S-x,y=r-h,u=y*D-n*a;if(u*u<Be)return;return u=(n*(d-h)-y*(l-x))/u,[l+u*D,d+u*a]}function L(l,d,q,P,x,h,S){var r=l-q,D=d-P,a=(S?h:-h)/Vn(r*r+D*D),n=a*D,y=-a*r,u=l+n,s=d+y,t=q+n,f=P+y,j=(u+t)/2,o=(s+f)/2,g=t-u,c=f-s,v=g*g+c*c,A=x-h,R=u*f-t*s,E=(c<0?-1:1)*Vn(xo(0,A*A*v-R*R)),I=(R*c-g*E)/v,O=(-R*g-c*E)/v,T=(R*c+g*E)/v,m=(-R*g+c*E)/v,p=I-j,e=O-o,i=T-j,z=m-o;if(p*p+e*e>i*i+z*z)I=T,O=m;return{cx:I,cy:O,x01:-n,y01:-y,x11:I*(x/A-1),y11:O*(x/A-1)}}function _t(){var l=Z,d=k,q=ae(0),P=null,x=b,h=_,S=nn,r=null,D=Gn(a);function a(){var n,y,u=+l.apply(this,arguments),s=+d.apply(this,arguments),t=x.apply(this,arguments)-Xr,f=h.apply(this,arguments)-Xr,j=Gi(f-t),o=f>t;if(!r)r=n=D();if(s<u)y=s,s=u,u=y;if(!(s>Be))r.moveTo(0,0);else if(j>Wn-Be){if(r.moveTo(s*In(t),s*Ut(t)),r.arc(0,0,s,t,f,!o),u>Be)r.moveTo(u*In(f),u*Ut(f)),r.arc(0,0,u,f,t,o)}else{var g=t,c=f,v=t,A=f,R=j,E=j,I=S.apply(this,arguments)/2,O=I>Be&&(P?+P.apply(this,arguments):Vn(u*u+s*s)),T=Fa(Gi(s-u)/2,+q.apply(this,arguments)),m=T,p=T,e,i;if(O>Be){var z=Hi(O/u*Ut(I)),F=Hi(O/s*Ut(I));if((R-=z*2)>Be)z*=o?1:-1,v+=z,A-=z;else R=0,v=A=(t+f)/2;if((E-=F*2)>Be)F*=o?1:-1,g+=F,c-=F;else E=0,g=c=(t+f)/2}var B=s*In(g),C=s*Ut(g),G=u*In(A),H=u*Ut(A);if(T>Be){var J=s*In(c),K=s*Ut(c),M=u*In(v),N=u*Ut(v),w;if(j<Rr)if(w=en(B,C,M,N,J,K,G,H)){var Q=B-w[0],U=C-w[1],V=J-w[0],W=K-w[1],X=1/Ut(_o((Q*V+U*W)/(Vn(Q*Q+U*U)*Vn(V*V+W*W)))/2),Y=Vn(w[0]*w[0]+w[1]*w[1]);m=Fa(T,(u-Y)/(X-1)),p=Fa(T,(s-Y)/(X+1))}else m=p=0}if(!(E>Be))r.moveTo(B,C);else if(p>Be)if(e=L(M,N,B,C,s,p,o),i=L(J,K,G,H,s,p,o),r.moveTo(e.cx+e.x01,e.cy+e.y01),p<T)r.arc(e.cx,e.cy,p,We(e.y01,e.x01),We(i.y01,i.x01),!o);else r.arc(e.cx,e.cy,p,We(e.y01,e.x01),We(e.y11,e.x11),!o),r.arc(0,0,s,We(e.cy+e.y11,e.cx+e.x11),We(i.cy+i.y11,i.cx+i.x11),!o),r.arc(i.cx,i.cy,p,We(i.y11,i.x11),We(i.y01,i.x01),!o);else r.moveTo(B,C),r.arc(0,0,s,g,c,!o);if(!(u>Be)||!(R>Be))r.lineTo(G,H);else if(m>Be)if(e=L(G,H,J,K,u,-m,o),i=L(B,C,M,N,u,-m,o),r.lineTo(e.cx+e.x01,e.cy+e.y01),m<T)r.arc(e.cx,e.cy,m,We(e.y01,e.x01),We(i.y01,i.x01),!o);else r.arc(e.cx,e.cy,m,We(e.y01,e.x01),We(e.y11,e.x11),!o),r.arc(0,0,u,We(e.cy+e.y11,e.cx+e.x11),We(i.cy+i.y11,i.cx+i.x11),o),r.arc(i.cx,i.cy,m,We(i.y11,i.x11),We(i.y01,i.x01),!o);else r.arc(0,0,u,A,v,o)}if(r.closePath(),n)return r=null,n+""||null}return a.centroid=function(){var n=(+l.apply(this,arguments)+ +d.apply(this,arguments))/2,y=(+x.apply(this,arguments)+ +h.apply(this,arguments))/2-Rr/2;return[In(y)*n,Ut(y)*n]},a.innerRadius=function(n){return arguments.length?(l=typeof n==="function"?n:ae(+n),a):l},a.outerRadius=function(n){return arguments.length?(d=typeof n==="function"?n:ae(+n),a):d},a.cornerRadius=function(n){return arguments.length?(q=typeof n==="function"?n:ae(+n),a):q},a.padRadius=function(n){return arguments.length?(P=n==null?null:typeof n==="function"?n:ae(+n),a):P},a.startAngle=function(n){return arguments.length?(x=typeof n==="function"?n:ae(+n),a):x},a.endAngle=function(n){return arguments.length?(h=typeof n==="function"?n:ae(+n),a):h},a.padAngle=function(n){return arguments.length?(S=typeof n==="function"?n:ae(+n),a):S},a.context=function(n){return arguments.length?(r=n==null?null:n,a):r},a}
2
2
  export{_t};
@@ -0,0 +1 @@
1
+ import{Ai}from"./chunk-dgepxev9.js";export{Ai as createWardleyServices};
@@ -1,4 +1,4 @@
1
- import{H}from"./chunk-p79c7aak.js";import{t,a,N,x,O,yt,C,S,E,T,A,L,R,l,p,V,Yi,Dn,at,j,Fe,Le}from"./chunk-zsat72qd.js";import{J}from"./chunk-p4pqtybm.js";import{ht,xr}from"./chunk-3rxhs9qm.js";import{Ce,Se}from"./chunk-ty2rmwda.js";var ft=Se(function(rt,st){(function(i,s){if(typeof rt==="object"&&typeof st==="object")st.exports=s(xr());else if(typeof define==="function"&&define.amd)define(["cose-base"],s);else if(typeof rt==="object")rt.cytoscapeFcose=s(xr());else i.cytoscapeFcose=s(i.coseBase)})(rt,function(e){return(()=>{var i={658:(k)=>{k.exports=Object.assign!=null?Object.assign.bind(Object):function(z){for(var v=arguments.length,b=Array(v>1?v-1:0),c=1;c<v;c++)b[c-1]=arguments[c];return b.forEach(function(y){Object.keys(y).forEach(function(d){return z[d]=y[d]})}),z}},548:(k,z,v)=>{var b=function(){function d(f,u){var g=[],r=!0,B=!1,F=void 0;try{for(var o=f[Symbol.iterator](),h;!(r=(h=o.next()).done);r=!0)if(g.push(h.value),u&&g.length===u)break}catch(D){B=!0,F=D}finally{try{if(!r&&o.return)o.return()}finally{if(B)throw F}}return g}return function(f,u){if(Array.isArray(f))return f;else if(Symbol.iterator in Object(f))return d(f,u);else throw TypeError("Invalid attempt to destructure non-iterable instance")}}(),c=v(140).layoutBase.LinkedList,y={};y.getTopMostNodes=function(d){var f={};for(var u=0;u<d.length;u++)f[d[u].id()]=!0;var g=d.filter(function(r,B){if(typeof r==="number")r=B;var F=r.parent()[0];while(F!=null){if(f[F.id()])return!1;F=F.parent()[0]}return!0});return g},y.connectComponents=function(d,f,u,g){var r=new c,B=new Set,F=[],o=void 0,h=void 0,D=void 0,n=!1,P=1,U=[],M=[],X=function(){var I=d.collection();M.push(I);var Y=u[0],Z=d.collection();Z.merge(Y).merge(Y.descendants().intersection(f)),F.push(Y),Z.forEach(function(re){r.push(re),B.add(re),I.merge(re)});var Q=function(){Y=r.shift();var ue=d.collection();Y.neighborhood().nodes().forEach(function(q){if(f.intersection(Y.edgesWith(q)).length>0)ue.merge(q)});for(var Ae=0;Ae<ue.length;Ae++){var Pe=ue[Ae];if(o=u.intersection(Pe.union(Pe.ancestors())),o!=null&&!B.has(o[0])){var de=o.union(o.descendants());de.forEach(function(q){if(r.push(q),B.add(q),I.merge(q),u.has(q))F.push(q)})}}};while(r.length!=0)Q();if(I.forEach(function(re){f.intersection(re.connectedEdges()).forEach(function(ue){if(I.has(ue.source())&&I.has(ue.target()))I.merge(ue)})}),F.length==u.length)n=!0;if(!n||n&&P>1){h=F[0],D=h.connectedEdges().length,F.forEach(function(re){if(re.connectedEdges().length<D)D=re.connectedEdges().length,h=re}),U.push(h.id());var se=d.collection();se.merge(F[0]),F.forEach(function(re){se.merge(re)}),F=[],u=u.difference(se),P++}};do X();while(!n);if(g){if(U.length>0)g.set("dummy"+(g.size+1),U)}return M},y.relocateComponent=function(d,f,u){if(!u.fixedNodeConstraint){var{POSITIVE_INFINITY:g,NEGATIVE_INFINITY:r,POSITIVE_INFINITY:B,NEGATIVE_INFINITY:F}=Number;if(u.quality=="draft"){var o=!0,h=!1,D=void 0;try{for(var n=f.nodeIndexes[Symbol.iterator](),P;!(o=(P=n.next()).done);o=!0){var U=P.value,M=b(U,2),X=M[0],_=M[1],I=u.cy.getElementById(X);if(I){var Y=I.boundingBox(),Z=f.xCoords[_]-Y.w/2,Q=f.xCoords[_]+Y.w/2,se=f.yCoords[_]-Y.h/2,re=f.yCoords[_]+Y.h/2;if(Z<g)g=Z;if(Q>r)r=Q;if(se<B)B=se;if(re>F)F=re}}}catch(q){h=!0,D=q}finally{try{if(!o&&n.return)n.return()}finally{if(h)throw D}}var ue=d.x-(r+g)/2,Ae=d.y-(F+B)/2;f.xCoords=f.xCoords.map(function(q){return q+ue}),f.yCoords=f.yCoords.map(function(q){return q+Ae})}else{Object.keys(f).forEach(function(q){var oe=f[q],Ne=oe.getRect().x,ke=oe.getRect().x+oe.getRect().width,De=oe.getRect().y,xe=oe.getRect().y+oe.getRect().height;if(Ne<g)g=Ne;if(ke>r)r=ke;if(De<B)B=De;if(xe>F)F=xe});var Pe=d.x-(r+g)/2,de=d.y-(F+B)/2;Object.keys(f).forEach(function(q){var oe=f[q];oe.setCenter(oe.getCenterX()+Pe,oe.getCenterY()+de)})}}},y.calcBoundingBox=function(d,f,u,g){var{MAX_SAFE_INTEGER:r,MIN_SAFE_INTEGER:B,MAX_SAFE_INTEGER:F,MIN_SAFE_INTEGER:o}=Number,h=void 0,D=void 0,n=void 0,P=void 0,U=d.descendants().not(":parent"),M=U.length;for(var X=0;X<M;X++){var _=U[X];if(h=f[g.get(_.id())]-_.width()/2,D=f[g.get(_.id())]+_.width()/2,n=u[g.get(_.id())]-_.height()/2,P=u[g.get(_.id())]+_.height()/2,r>h)r=h;if(B<D)B=D;if(F>n)F=n;if(o<P)o=P}var I={};return I.topLeftX=r,I.topLeftY=F,I.width=B-r,I.height=o-F,I},y.calcParentsWithoutChildren=function(d,f){var u=d.collection();return f.nodes(":parent").forEach(function(g){var r=!1;if(g.children().forEach(function(B){if(B.css("display")!="none")r=!0}),!r)u.merge(g)}),u},k.exports=y},816:(k,z,v)=>{var b=v(548),c=v(140).CoSELayout,y=v(140).CoSENode,d=v(140).layoutBase.PointD,f=v(140).layoutBase.DimensionD,u=v(140).layoutBase.LayoutConstants,g=v(140).layoutBase.FDLayoutConstants,r=v(140).CoSEConstants,B=function(o,h){var{cy:D,eles:n}=o,P=n.nodes(),U=n.edges(),M=void 0,X=void 0,_=void 0,I={};if(o.randomize)M=h.nodeIndexes,X=h.xCoords,_=h.yCoords;var Y=function(q){return typeof q==="function"},Z=function(q,oe){if(Y(q))return q(oe);else return q},Q=b.calcParentsWithoutChildren(D,n),se=function de(q,oe,Ne,ke){var De=oe.length;for(var xe=0;xe<De;xe++){var W=oe[xe],Te=null;if(W.intersection(Q).length==0)Te=W.children();var ie=void 0,ve=W.layoutDimensions({nodeDimensionsIncludeLabels:ke.nodeDimensionsIncludeLabels});if(W.outerWidth()!=null&&W.outerHeight()!=null)if(ke.randomize)if(!W.isParent())ie=q.add(new y(Ne.graphManager,new d(X[M.get(W.id())]-ve.w/2,_[M.get(W.id())]-ve.h/2),new f(parseFloat(ve.w),parseFloat(ve.h))));else{var Me=b.calcBoundingBox(W,X,_,M);if(W.intersection(Q).length==0)ie=q.add(new y(Ne.graphManager,new d(Me.topLeftX,Me.topLeftY),new f(Me.width,Me.height)));else ie=q.add(new y(Ne.graphManager,new d(Me.topLeftX,Me.topLeftY),new f(parseFloat(ve.w),parseFloat(ve.h))))}else ie=q.add(new y(Ne.graphManager,new d(W.position("x")-ve.w/2,W.position("y")-ve.h/2),new f(parseFloat(ve.w),parseFloat(ve.h))));else ie=q.add(new y(this.graphManager));if(ie.id=W.data("id"),ie.nodeRepulsion=Z(ke.nodeRepulsion,W),ie.paddingLeft=parseInt(W.css("padding")),ie.paddingTop=parseInt(W.css("padding")),ie.paddingRight=parseInt(W.css("padding")),ie.paddingBottom=parseInt(W.css("padding")),ke.nodeDimensionsIncludeLabels)ie.labelWidth=W.boundingBox({includeLabels:!0,includeNodes:!1,includeOverlays:!1}).w,ie.labelHeight=W.boundingBox({includeLabels:!0,includeNodes:!1,includeOverlays:!1}).h,ie.labelPosVertical=W.css("text-valign"),ie.labelPosHorizontal=W.css("text-halign");if(I[W.data("id")]=ie,isNaN(ie.rect.x))ie.rect.x=0;if(isNaN(ie.rect.y))ie.rect.y=0;if(Te!=null&&Te.length>0){var ze=void 0;ze=Ne.getGraphManager().add(Ne.newGraph(),ie),de(ze,Te,Ne,ke)}}},re=function(q,oe,Ne){var ke=0,De=0;for(var xe=0;xe<Ne.length;xe++){var W=Ne[xe],Te=I[W.data("source")],ie=I[W.data("target")];if(Te&&ie&&Te!==ie&&Te.getEdgesBetween(ie).length==0){var ve=oe.add(q.newEdge(),Te,ie);ve.id=W.id(),ve.idealLength=Z(o.idealEdgeLength,W),ve.edgeElasticity=Z(o.edgeElasticity,W),ke+=ve.idealLength,De++}}if(o.idealEdgeLength!=null){if(De>0)r.DEFAULT_EDGE_LENGTH=g.DEFAULT_EDGE_LENGTH=ke/De;else if(!Y(o.idealEdgeLength))r.DEFAULT_EDGE_LENGTH=g.DEFAULT_EDGE_LENGTH=o.idealEdgeLength;else r.DEFAULT_EDGE_LENGTH=g.DEFAULT_EDGE_LENGTH=50;r.MIN_REPULSION_DIST=g.MIN_REPULSION_DIST=g.DEFAULT_EDGE_LENGTH/10,r.DEFAULT_RADIAL_SEPARATION=g.DEFAULT_EDGE_LENGTH}},ue=function(q,oe){if(oe.fixedNodeConstraint)q.constraints.fixedNodeConstraint=oe.fixedNodeConstraint;if(oe.alignmentConstraint)q.constraints.alignmentConstraint=oe.alignmentConstraint;if(oe.relativePlacementConstraint)q.constraints.relativePlacementConstraint=oe.relativePlacementConstraint};if(o.nestingFactor!=null)r.PER_LEVEL_IDEAL_EDGE_LENGTH_FACTOR=g.PER_LEVEL_IDEAL_EDGE_LENGTH_FACTOR=o.nestingFactor;if(o.gravity!=null)r.DEFAULT_GRAVITY_STRENGTH=g.DEFAULT_GRAVITY_STRENGTH=o.gravity;if(o.numIter!=null)r.MAX_ITERATIONS=g.MAX_ITERATIONS=o.numIter;if(o.gravityRange!=null)r.DEFAULT_GRAVITY_RANGE_FACTOR=g.DEFAULT_GRAVITY_RANGE_FACTOR=o.gravityRange;if(o.gravityCompound!=null)r.DEFAULT_COMPOUND_GRAVITY_STRENGTH=g.DEFAULT_COMPOUND_GRAVITY_STRENGTH=o.gravityCompound;if(o.gravityRangeCompound!=null)r.DEFAULT_COMPOUND_GRAVITY_RANGE_FACTOR=g.DEFAULT_COMPOUND_GRAVITY_RANGE_FACTOR=o.gravityRangeCompound;if(o.initialEnergyOnIncremental!=null)r.DEFAULT_COOLING_FACTOR_INCREMENTAL=g.DEFAULT_COOLING_FACTOR_INCREMENTAL=o.initialEnergyOnIncremental;if(o.tilingCompareBy!=null)r.TILING_COMPARE_BY=o.tilingCompareBy;if(o.quality=="proof")u.QUALITY=2;else u.QUALITY=0;if(r.NODE_DIMENSIONS_INCLUDE_LABELS=g.NODE_DIMENSIONS_INCLUDE_LABELS=u.NODE_DIMENSIONS_INCLUDE_LABELS=o.nodeDimensionsIncludeLabels,r.DEFAULT_INCREMENTAL=g.DEFAULT_INCREMENTAL=u.DEFAULT_INCREMENTAL=!o.randomize,r.ANIMATE=g.ANIMATE=u.ANIMATE=o.animate,r.TILE=o.tile,r.TILING_PADDING_VERTICAL=typeof o.tilingPaddingVertical==="function"?o.tilingPaddingVertical.call():o.tilingPaddingVertical,r.TILING_PADDING_HORIZONTAL=typeof o.tilingPaddingHorizontal==="function"?o.tilingPaddingHorizontal.call():o.tilingPaddingHorizontal,r.DEFAULT_INCREMENTAL=g.DEFAULT_INCREMENTAL=u.DEFAULT_INCREMENTAL=!0,r.PURE_INCREMENTAL=!o.randomize,u.DEFAULT_UNIFORM_LEAF_NODE_SIZES=o.uniformNodeDimensions,o.step=="transformed")r.TRANSFORM_ON_CONSTRAINT_HANDLING=!0,r.ENFORCE_CONSTRAINTS=!1,r.APPLY_LAYOUT=!1;if(o.step=="enforced")r.TRANSFORM_ON_CONSTRAINT_HANDLING=!1,r.ENFORCE_CONSTRAINTS=!0,r.APPLY_LAYOUT=!1;if(o.step=="cose")r.TRANSFORM_ON_CONSTRAINT_HANDLING=!1,r.ENFORCE_CONSTRAINTS=!1,r.APPLY_LAYOUT=!0;if(o.step=="all"){if(o.randomize)r.TRANSFORM_ON_CONSTRAINT_HANDLING=!0;else r.TRANSFORM_ON_CONSTRAINT_HANDLING=!1;r.ENFORCE_CONSTRAINTS=!0,r.APPLY_LAYOUT=!0}if(o.fixedNodeConstraint||o.alignmentConstraint||o.relativePlacementConstraint)r.TREE_REDUCTION_ON_INCREMENTAL=!1;else r.TREE_REDUCTION_ON_INCREMENTAL=!0;var Ae=new c,Pe=Ae.newGraphManager();return se(Pe.addRoot(),b.getTopMostNodes(P),Ae,o),re(Ae,Pe,U),ue(Ae,o),Ae.runLayout(),I};k.exports={coseLayout:B}},212:(k,z,v)=>{var b=function(){function o(h,D){for(var n=0;n<D.length;n++){var P=D[n];if(P.enumerable=P.enumerable||!1,P.configurable=!0,"value"in P)P.writable=!0;Object.defineProperty(h,P.key,P)}}return function(h,D,n){if(D)o(h.prototype,D);if(n)o(h,n);return h}}();function c(o,h){if(!(o instanceof h))throw TypeError("Cannot call a class as a function")}var y=v(658),d=v(548),f=v(657),u=f.spectralLayout,g=v(816),r=g.coseLayout,B=Object.freeze({quality:"default",randomize:!0,animate:!0,animationDuration:1000,animationEasing:void 0,fit:!0,padding:30,nodeDimensionsIncludeLabels:!1,uniformNodeDimensions:!1,packComponents:!0,step:"all",samplingType:!0,sampleSize:25,nodeSeparation:75,piTol:0.0000001,nodeRepulsion:function(h){return 4500},idealEdgeLength:function(h){return 50},edgeElasticity:function(h){return 0.45},nestingFactor:0.1,gravity:0.25,numIter:2500,tile:!0,tilingCompareBy:void 0,tilingPaddingVertical:10,tilingPaddingHorizontal:10,gravityRangeCompound:1.5,gravityCompound:1,gravityRange:3.8,initialEnergyOnIncremental:0.3,fixedNodeConstraint:void 0,alignmentConstraint:void 0,relativePlacementConstraint:void 0,ready:function(){},stop:function(){}}),F=function(){function o(h){c(this,o),this.options=y({},B,h)}return b(o,[{key:"run",value:function(){var D=this,n=this.options,{cy:P,eles:U}=n,M=[],X=void 0,_=void 0,I=[],Y=void 0,Z=[];if(n.fixedNodeConstraint&&(!Array.isArray(n.fixedNodeConstraint)||n.fixedNodeConstraint.length==0))n.fixedNodeConstraint=void 0;if(n.alignmentConstraint){if(n.alignmentConstraint.vertical&&(!Array.isArray(n.alignmentConstraint.vertical)||n.alignmentConstraint.vertical.length==0))n.alignmentConstraint.vertical=void 0;if(n.alignmentConstraint.horizontal&&(!Array.isArray(n.alignmentConstraint.horizontal)||n.alignmentConstraint.horizontal.length==0))n.alignmentConstraint.horizontal=void 0}if(n.relativePlacementConstraint&&(!Array.isArray(n.relativePlacementConstraint)||n.relativePlacementConstraint.length==0))n.relativePlacementConstraint=void 0;var Q=n.fixedNodeConstraint||n.alignmentConstraint||n.relativePlacementConstraint;if(Q)n.tile=!1,n.packComponents=!1;var se=void 0,re=!1;if(P.layoutUtilities&&n.packComponents){if(se=P.layoutUtilities("get"),!se)se=P.layoutUtilities();re=!0}if(U.nodes().length>0)if(!re){var ue=n.eles.boundingBox();if(Z.push({x:ue.x1+ue.w/2,y:ue.y1+ue.h/2}),n.randomize){var Ae=u(n);M.push(Ae)}if(n.quality=="default"||n.quality=="proof")I.push(r(n,M[0])),d.relocateComponent(Z[0],I[0],n);else d.relocateComponent(Z[0],M[0],n)}else{var Pe=d.getTopMostNodes(n.eles.nodes());if(Y=d.connectComponents(P,n.eles,Pe),Y.forEach(function(K){var G=K.boundingBox();Z.push({x:G.x1+G.w/2,y:G.y1+G.h/2})}),n.randomize)Y.forEach(function(K){n.eles=K,M.push(u(n))});if(n.quality=="default"||n.quality=="proof"){var de=P.collection();if(n.tile){var q=new Map,oe=[],Ne=[],ke=0,De={nodeIndexes:q,xCoords:oe,yCoords:Ne},xe=[];if(Y.forEach(function(K,G){if(K.edges().length==0)K.nodes().forEach(function(pe,le){if(de.merge(K.nodes()[le]),!pe.isParent())De.nodeIndexes.set(K.nodes()[le].id(),ke++),De.xCoords.push(K.nodes()[0].position().x),De.yCoords.push(K.nodes()[0].position().y)}),xe.push(G)}),de.length>1){var W=de.boundingBox();Z.push({x:W.x1+W.w/2,y:W.y1+W.h/2}),Y.push(de),M.push(De);for(var Te=xe.length-1;Te>=0;Te--)Y.splice(xe[Te],1),M.splice(xe[Te],1),Z.splice(xe[Te],1)}}Y.forEach(function(K,G){n.eles=K,I.push(r(n,M[G])),d.relocateComponent(Z[G],I[G],n)})}else Y.forEach(function(K,G){d.relocateComponent(Z[G],M[G],n)});var ie=new Set;if(Y.length>1){var ve=[],Me=U.filter(function(K){return K.css("display")=="none"});Y.forEach(function(K,G){var pe=void 0;if(n.quality=="draft")pe=M[G].nodeIndexes;if(K.nodes().not(Me).length>0){var le={};le.edges=[],le.nodes=[];var me=void 0;if(K.nodes().not(Me).forEach(function(fe){if(n.quality=="draft")if(!fe.isParent())me=pe.get(fe.id()),le.nodes.push({x:M[G].xCoords[me]-fe.boundingbox().w/2,y:M[G].yCoords[me]-fe.boundingbox().h/2,width:fe.boundingbox().w,height:fe.boundingbox().h});else{var he=d.calcBoundingBox(fe,M[G].xCoords,M[G].yCoords,pe);le.nodes.push({x:he.topLeftX,y:he.topLeftY,width:he.width,height:he.height})}else if(I[G][fe.id()])le.nodes.push({x:I[G][fe.id()].getLeft(),y:I[G][fe.id()].getTop(),width:I[G][fe.id()].getWidth(),height:I[G][fe.id()].getHeight()})}),K.edges().forEach(function(fe){var he=fe.source(),Ee=fe.target();if(he.css("display")!="none"&&Ee.css("display")!="none"){if(n.quality=="draft"){var Be=pe.get(he.id()),et=pe.get(Ee.id()),Oe=[],Ye=[];if(he.isParent()){var We=d.calcBoundingBox(he,M[G].xCoords,M[G].yCoords,pe);Oe.push(We.topLeftX+We.width/2),Oe.push(We.topLeftY+We.height/2)}else Oe.push(M[G].xCoords[Be]),Oe.push(M[G].yCoords[Be]);if(Ee.isParent()){var Je=d.calcBoundingBox(Ee,M[G].xCoords,M[G].yCoords,pe);Ye.push(Je.topLeftX+Je.width/2),Ye.push(Je.topLeftY+Je.height/2)}else Ye.push(M[G].xCoords[et]),Ye.push(M[G].yCoords[et]);le.edges.push({startX:Oe[0],startY:Oe[1],endX:Ye[0],endY:Ye[1]})}else if(I[G][he.id()]&&I[G][Ee.id()])le.edges.push({startX:I[G][he.id()].getCenterX(),startY:I[G][he.id()].getCenterY(),endX:I[G][Ee.id()].getCenterX(),endY:I[G][Ee.id()].getCenterY()})}}),le.nodes.length>0)ve.push(le),ie.add(G)}});var ze=se.packComponents(ve,n.randomize).shifts;if(n.quality=="draft")M.forEach(function(K,G){var pe=K.xCoords.map(function(me){return me+ze[G].dx}),le=K.yCoords.map(function(me){return me+ze[G].dy});K.xCoords=pe,K.yCoords=le});else{var Ke=0;ie.forEach(function(K){Object.keys(I[K]).forEach(function(G){var pe=I[K][G];pe.setCenter(pe.getCenterX()+ze[Ke].dx,pe.getCenterY()+ze[Ke].dy)}),Ke++})}}}var je=function(G,pe){if(n.quality=="default"||n.quality=="proof"){if(typeof G==="number")G=pe;var le=void 0,me=void 0,fe=G.data("id");if(I.forEach(function(Ee){if(fe in Ee)le={x:Ee[fe].getRect().getCenterX(),y:Ee[fe].getRect().getCenterY()},me=Ee[fe]}),n.nodeDimensionsIncludeLabels){if(me.labelWidth){if(me.labelPosHorizontal=="left")le.x+=me.labelWidth/2;else if(me.labelPosHorizontal=="right")le.x-=me.labelWidth/2}if(me.labelHeight){if(me.labelPosVertical=="top")le.y+=me.labelHeight/2;else if(me.labelPosVertical=="bottom")le.y-=me.labelHeight/2}}if(le==null)le={x:G.position("x"),y:G.position("y")};return{x:le.x,y:le.y}}else{var he=void 0;if(M.forEach(function(Ee){var Be=Ee.nodeIndexes.get(G.id());if(Be!=null)he={x:Ee.xCoords[Be],y:Ee.yCoords[Be]}}),he==null)he={x:G.position("x"),y:G.position("y")};return{x:he.x,y:he.y}}};if(n.quality=="default"||n.quality=="proof"||n.randomize){var nt=d.calcParentsWithoutChildren(P,U),qe=U.filter(function(K){return K.css("display")=="none"});if(n.eles=U.not(qe),U.nodes().not(":parent").not(qe).layoutPositions(D,n,je),nt.length>0)nt.forEach(function(K){K.position(je(K))})}else console.log("If randomize option is set to false, then quality option must be 'default' or 'proof'.")}}]),o}();k.exports=F},657:(k,z,v)=>{var b=v(548),c=v(140).layoutBase.Matrix,y=v(140).layoutBase.SVD,d=function(u){var{cy:g,eles:r}=u,B=r.nodes(),F=r.nodes(":parent"),o=new Map,h=new Map,D=new Map,n=[],P=[],U=[],M=[],X=[],_=[],I=[],Y=[],Z=void 0,Q=void 0,se=1e8,re=0.000000001,{piTol:ue,samplingType:Ae,nodeSeparation:Pe}=u,de=void 0,q=function(){var ee=0,te=0,ne=!1;while(te<de){ee=Math.floor(Math.random()*Q),ne=!1;for(var ae=0;ae<te;ae++)if(M[ae]==ee){ne=!0;break}if(!ne)M[te]=ee,te++;else continue}},oe=function(ee,te,ne){var ae=[],we=0,ge=0,ce=0,Ie=void 0,be=[],$e=0,_e=1;for(var Ue=0;Ue<Q;Ue++)be[Ue]=se;ae[ge]=ee,be[ee]=0;while(ge>=we){ce=ae[we++];var Xe=n[ce];for(var He=0;He<Xe.length;He++)if(Ie=h.get(Xe[He]),be[Ie]==se)be[Ie]=be[ce]+1,ae[++ge]=Ie;_[ce][te]=be[ce]*Pe}if(ne){for(var Ge=0;Ge<Q;Ge++)if(_[Ge][te]<X[Ge])X[Ge]=_[Ge][te];for(var tt=0;tt<Q;tt++)if(X[tt]>$e)$e=X[tt],_e=tt}return _e},Ne=function(ee){var te=void 0;if(!ee){q();for(var ne=0;ne<de;ne++)oe(M[ne],ne,ee,!1)}else{te=Math.floor(Math.random()*Q),Z=te;for(var ae=0;ae<Q;ae++)X[ae]=se;for(var we=0;we<de;we++)M[we]=te,te=oe(te,we,ee)}for(var ge=0;ge<Q;ge++)for(var ce=0;ce<de;ce++)_[ge][ce]*=_[ge][ce];for(var Ie=0;Ie<de;Ie++)I[Ie]=[];for(var be=0;be<de;be++)for(var $e=0;$e<de;$e++)I[be][$e]=_[M[$e]][be]},ke=function(){var ee=y.svd(I),{S:te,U:ne,V:ae}=ee,we=te[0]*te[0]*te[0],ge=[];for(var ce=0;ce<de;ce++){ge[ce]=[];for(var Ie=0;Ie<de;Ie++)if(ge[ce][Ie]=0,ce==Ie)ge[ce][Ie]=te[ce]/(te[ce]*te[ce]+we/(te[ce]*te[ce]))}Y=c.multMat(c.multMat(ae,ge),c.transpose(ne))},De=function(){var ee=void 0,te=void 0,ne=[],ae=[],we=[],ge=[];for(var ce=0;ce<Q;ce++)ne[ce]=Math.random(),ae[ce]=Math.random();ne=c.normalize(ne),ae=c.normalize(ae);var Ie=0,be=re,$e=re,_e=void 0;while(!0){Ie++;for(var Ue=0;Ue<Q;Ue++)we[Ue]=ne[Ue];if(ne=c.multGamma(c.multL(c.multGamma(we),_,Y)),ee=c.dotProduct(we,ne),ne=c.normalize(ne),be=c.dotProduct(we,ne),_e=Math.abs(be/$e),_e<=1+ue&&_e>=1)break;$e=be}for(var Xe=0;Xe<Q;Xe++)we[Xe]=ne[Xe];Ie=0,$e=re;while(!0){Ie++;for(var He=0;He<Q;He++)ge[He]=ae[He];if(ge=c.minusOp(ge,c.multCons(we,c.dotProduct(we,ge))),ae=c.multGamma(c.multL(c.multGamma(ge),_,Y)),te=c.dotProduct(ge,ae),ae=c.normalize(ae),be=c.dotProduct(ge,ae),_e=Math.abs(be/$e),_e<=1+ue&&_e>=1)break;$e=be}for(var Ge=0;Ge<Q;Ge++)ge[Ge]=ae[Ge];P=c.multCons(we,Math.sqrt(Math.abs(ee))),U=c.multCons(ge,Math.sqrt(Math.abs(te)))};b.connectComponents(g,r,b.getTopMostNodes(B),o),F.forEach(function(ye){b.connectComponents(g,r,b.getTopMostNodes(ye.descendants().intersection(r)),o)});var xe=0;for(var W=0;W<B.length;W++)if(!B[W].isParent())h.set(B[W].id(),xe++);var Te=!0,ie=!1,ve=void 0;try{for(var Me=o.keys()[Symbol.iterator](),ze;!(Te=(ze=Me.next()).done);Te=!0){var Ke=ze.value;h.set(Ke,xe++)}}catch(ye){ie=!0,ve=ye}finally{try{if(!Te&&Me.return)Me.return()}finally{if(ie)throw ve}}for(var je=0;je<h.size;je++)n[je]=[];F.forEach(function(ye){var ee=ye.children().intersection(r);while(ee.nodes(":childless").length==0)ee=ee.nodes()[0].children().intersection(r);var te=0,ne=ee.nodes(":childless")[0].connectedEdges().length;ee.nodes(":childless").forEach(function(ae,we){if(ae.connectedEdges().length<ne)ne=ae.connectedEdges().length,te=we}),D.set(ye.id(),ee.nodes(":childless")[te].id())}),B.forEach(function(ye){var ee=void 0;if(ye.isParent())ee=h.get(D.get(ye.id()));else ee=h.get(ye.id());ye.neighborhood().nodes().forEach(function(te){if(r.intersection(ye.edgesWith(te)).length>0)if(te.isParent())n[ee].push(D.get(te.id()));else n[ee].push(te.id())})});var nt=function(ee){var te=h.get(ee),ne=void 0;o.get(ee).forEach(function(ae){if(g.getElementById(ae).isParent())ne=D.get(ae);else ne=ae;n[te].push(ne),n[h.get(ne)].push(ee)})},qe=!0,K=!1,G=void 0;try{for(var pe=o.keys()[Symbol.iterator](),le;!(qe=(le=pe.next()).done);qe=!0){var me=le.value;nt(me)}}catch(ye){K=!0,G=ye}finally{try{if(!qe&&pe.return)pe.return()}finally{if(K)throw G}}Q=h.size;var fe=void 0;if(Q>2){de=Q<u.sampleSize?Q:u.sampleSize;for(var he=0;he<Q;he++)_[he]=[];for(var Ee=0;Ee<de;Ee++)Y[Ee]=[];if(u.quality=="draft"||u.step=="all")Ne(Ae),ke(),De(),fe={nodeIndexes:h,xCoords:P,yCoords:U};else h.forEach(function(ye,ee){P.push(g.getElementById(ee).position("x")),U.push(g.getElementById(ee).position("y"))}),fe={nodeIndexes:h,xCoords:P,yCoords:U};return fe}else{var Be=h.keys(),et=g.getElementById(Be.next().value),Oe=et.position(),Ye=et.outerWidth();if(P.push(Oe.x),U.push(Oe.y),Q==2){var We=g.getElementById(Be.next().value),Je=We.outerWidth();P.push(Oe.x+Ye/2+Je/2+u.idealEdgeLength),U.push(Oe.y)}return fe={nodeIndexes:h,xCoords:P,yCoords:U},fe}};k.exports={spectralLayout:d}},579:(k,z,v)=>{var b=v(212),c=function(d){if(!d)return;d("layout","fcose",b)};if(typeof cytoscape<"u")c(cytoscape);k.exports=c},140:(k)=>{k.exports=e}},s={};function w(k){var z=s[k];if(z!==void 0)return z.exports;var v=s[k]={exports:{}};return i[k](v,v.exports,w),v.exports}var m=w(579);return m})()})});var xt=Ce(ft(),1);var ut={L:"left",R:"right",T:"top",B:"bottom"},gt={L:t((e)=>`${e},${e/2} 0,${e} 0,0`,"L"),R:t((e)=>`0,${e/2} ${e},0 ${e},${e}`,"R"),T:t((e)=>`0,0 ${e},0 ${e/2},${e}`,"T"),B:t((e)=>`${e/2},0 ${e},${e} 0,${e}`,"B")},ot={L:t((e,i)=>e-i+2,"L"),R:t((e,i)=>e-2,"R"),T:t((e,i)=>e-i+2,"T"),B:t((e,i)=>e-2,"B")},kt=t(function(e){if(Re(e))return e==="L"?"R":"L";else return e==="T"?"B":"T"},"getOppositeArchitectureDirection"),vt=t(function(e){let i=e;return i==="L"||i==="R"||i==="T"||i==="B"},"isArchitectureDirection"),Re=t(function(e){let i=e;return i==="L"||i==="R"},"isArchitectureDirectionX"),Ve=t(function(e){let i=e;return i==="T"||i==="B"},"isArchitectureDirectionY"),dt=t(function(e,i){let s=Re(e)&&Ve(i),w=Ve(e)&&Re(i);return s||w},"isArchitectureDirectionXY"),Dt=t(function(e){let i=e[0],s=e[1],w=Re(i)&&Ve(s),m=Ve(i)&&Re(s);return w||m},"isArchitecturePairXY"),Rt=t(function(e){return e!=="LL"&&e!=="RR"&&e!=="TT"&&e!=="BB"},"isValidArchitectureDirectionPair"),lt=t(function(e,i){let s=`${e}${i}`;return Rt(s)?s:void 0},"getArchitectureDirectionPair"),Mt=t(function([e,i],s){let w=s[0],m=s[1];if(Re(w))if(Ve(m))return[e+(w==="L"?-1:1),i+(m==="T"?1:-1)];else return[e+(w==="L"?-1:1),i];else if(Re(m))return[e+(m==="L"?1:-1),i+(w==="T"?1:-1)];else return[e,i+(w==="T"?1:-1)]},"shiftPositionByArchitectureDirectionPair"),Ft=t(function(e){if(e==="LT"||e==="TL")return[1,1];else if(e==="BL"||e==="LB")return[1,-1];else if(e==="BR"||e==="RB")return[-1,-1];else return[-1,1]},"getArchitectureDirectionXYFactors"),$t=t(function(e,i){if(dt(e,i))return"bend";else if(Re(e))return"horizontal";return"vertical"},"getArchitectureDirectionAlignment"),Pt=t(function(e){return e.type==="service"},"isArchitectureService"),Ot=t(function(e){return e.type==="junction"},"isArchitectureJunction"),pt=t((e,i)=>{let[s,w]=[e,i].sort();return`${JSON.stringify(s)}-${JSON.stringify(w)}`},"architectureGroupAlignmentKey"),mt=t((e)=>e.data(),"edgeData"),Qe=t((e)=>e.data(),"nodeData"),Gt=N.architecture,Et=class{constructor(){this.nodes=new Map,this.groups=new Map,this.edges=[],this.layoutHints=[],this.registeredIds=new Map,this.elements=new Map,this.diagramId="",this.setAccTitle=S,this.getAccTitle=E,this.setDiagramTitle=L,this.getDiagramTitle=R,this.getAccDescription=A,this.setAccDescription=T,this.clear()}static{t(this,"ArchitectureDB")}setDiagramId(e){this.diagramId=e}getDiagramId(){return this.diagramId}clear(){this.nodes=new Map,this.groups=new Map,this.edges=[],this.layoutHints=[],this.registeredIds=new Map,this.dataStructures=void 0,this.elements=new Map,this.diagramId="",C()}addService({id:e,icon:i,in:s,title:w,iconText:m}){if(this.registeredIds.has(e))throw Error(`The service id [${e}] is already in use by another ${this.registeredIds.get(e)}`);if(s!==void 0){if(e===s)throw Error(`The service [${e}] cannot be placed within itself`);if(!this.registeredIds.has(s))throw Error(`The service [${e}]'s parent does not exist. Please make sure the parent is created before this service`);if(this.registeredIds.get(s)==="node")throw Error(`The service [${e}]'s parent is not a group`)}this.registeredIds.set(e,"node"),this.nodes.set(e,{id:e,type:"service",icon:i,iconText:m,title:w,edges:[],in:s})}getServices(){return[...this.nodes.values()].filter(Pt)}addJunction({id:e,in:i}){if(this.registeredIds.has(e))throw Error(`The junction id [${e}] is already in use by another ${this.registeredIds.get(e)}`);if(i!==void 0){if(e===i)throw Error(`The junction [${e}] cannot be placed within itself`);if(!this.registeredIds.has(i))throw Error(`The junction [${e}]'s parent does not exist. Please make sure the parent is created before this junction`);if(this.registeredIds.get(i)==="node")throw Error(`The junction [${e}]'s parent is not a group`)}this.registeredIds.set(e,"node"),this.nodes.set(e,{id:e,type:"junction",edges:[],in:i})}getJunctions(){return[...this.nodes.values()].filter(Ot)}getNodes(){return[...this.nodes.values()]}getNode(e){return this.nodes.get(e)??null}addGroup({id:e,icon:i,in:s,title:w}){if(this.registeredIds.has(e))throw Error(`The group id [${e}] is already in use by another ${this.registeredIds.get(e)}`);if(s!==void 0){if(e===s)throw Error(`The group [${e}] cannot be placed within itself`);if(!this.registeredIds.has(s))throw Error(`The group [${e}]'s parent does not exist. Please make sure the parent is created before this group`);if(this.registeredIds.get(s)==="node")throw Error(`The group [${e}]'s parent is not a group`)}this.registeredIds.set(e,"group"),this.groups.set(e,{id:e,icon:i,title:w,in:s})}getGroups(){return[...this.groups.values()]}addEdge({lhsId:e,rhsId:i,lhsDir:s,rhsDir:w,lhsInto:m,rhsInto:k,lhsGroup:z,rhsGroup:v,title:b}){if(!vt(s))throw Error(`Invalid direction given for left hand side of edge ${e}--${i}. Expected (L,R,T,B) got ${String(s)}`);if(!vt(w))throw Error(`Invalid direction given for right hand side of edge ${e}--${i}. Expected (L,R,T,B) got ${String(w)}`);if(!this.nodes.has(e)&&!this.groups.has(e))throw Error(`The left-hand id [${e}] does not yet exist. Please create the service/group before declaring an edge to it.`);if(!this.nodes.has(i)&&!this.groups.has(i))throw Error(`The right-hand id [${i}] does not yet exist. Please create the service/group before declaring an edge to it.`);let c=this.nodes.get(e).in,y=this.nodes.get(i).in;if(z&&c&&y&&c==y)throw Error(`The left-hand id [${e}] is modified to traverse the group boundary, but the edge does not pass through two groups.`);if(v&&c&&y&&c==y)throw Error(`The right-hand id [${i}] is modified to traverse the group boundary, but the edge does not pass through two groups.`);let d={lhsId:e,lhsDir:s,lhsInto:m,lhsGroup:z,rhsId:i,rhsDir:w,rhsInto:k,rhsGroup:v,title:b};this.edges.push(d);let f=this.nodes.get(e),u=this.nodes.get(i);if(f&&u)f.edges.push(this.edges[this.edges.length-1]),u.edges.push(this.edges[this.edges.length-1])}getEdges(){return this.edges}addLayoutHint(e){if(e.members.length<2)throw Error(`An align directive requires at least two members; got ${e.members.length}`);let i=new Set;e.members.forEach((s)=>{if(this.registeredIds.get(s)!=="node")throw Error(`align ${e.direction} references [${s}], which is not a service or junction`);if(i.has(s))throw Error(`align ${e.direction} lists [${s}] more than once`);i.add(s)}),this.layoutHints.push(e)}getLayoutHints(){return this.layoutHints}getDataStructures(){if(this.dataStructures===void 0){let e=new Map,i=new Map;for(let[z,v]of this.nodes.entries()){let b=new Map;for(let c of v.edges){let y=this.getNode(c.lhsId)?.in,d=this.getNode(c.rhsId)?.in;if(y&&d&&y!==d){let f=$t(c.lhsDir,c.rhsDir);if(f!=="bend")e.set(pt(y,d),f)}if(c.lhsId===z){let f=lt(c.lhsDir,c.rhsDir);if(f)b.set(f,c.rhsId)}else{let f=lt(c.rhsDir,c.lhsDir);if(f)b.set(f,c.lhsId)}}i.set(z,b)}let s=new Set,w=new Set(i.keys()),m=t((z)=>{let v=new Map([[z,[0,0]]]),b=[z];while(b.length>0){let c=b.shift();if(c){s.add(c),w.delete(c);let y=i.get(c);if(!y)throw Error(`BFS error: adjacency list for id ${c} not found. Please report this as a bug.`);let d=v.get(c);if(!d)throw Error(`BFS error: position for id ${c} not found in spatial map. Please report this as a bug.`);let[f,u]=d;y.forEach((g,r)=>{if(!s.has(g))v.set(g,Mt([f,u],r)),b.push(g)})}}return v},"BFS"),k=[];while(w.size>0){let z=w.values().next().value;k.push(m(z))}this.dataStructures={adjList:i,spatialMaps:k,groupAlignments:e}}return this.dataStructures}setElementForId(e,i){this.elements.set(e,i)}getElementById(e){return this.elements.get(e)}getConfig(){return j({...Gt,...x().architecture})}getConfigField(e){return this.getConfig()[e]}},zt=t((e,i)=>{H(e,i),e.groups.map((s)=>i.addGroup(s)),e.services.map((s)=>i.addService({...s,type:"service"})),e.junctions.map((s)=>i.addJunction({...s,type:"junction"})),e.edges.map((s)=>i.addEdge(s)),e.alignments?.map((s)=>i.addLayoutHint({direction:s.direction,members:[...s.members]}))},"populateDb"),wt={parser:{yy:void 0},parse:t(async(e)=>{let i=await J("architecture",e);a.debug(i);let s=wt.parser?.yy;if(!(s instanceof Et))throw Error("parser.parser?.yy was not a ArchitectureDB. This is due to a bug within Mermaid, please report this issue at https://github.com/mermaid-js/mermaid/issues.");zt(i,s)},"parse")},Bt=t((e)=>`
1
+ import{H}from"./chunk-yeh77fvq.js";import{t,a,N,x,O,yt,C,S,E,T,A,L,R,l,p,V,Yi,Dn,at,j,Fe,Le}from"./chunk-t5ke9cyg.js";import{J}from"./chunk-dgepxev9.js";import{ht,xr}from"./chunk-7frnjms9.js";import{Ce,Se}from"./chunk-jy448465.js";var ft=Se(function(rt,st){(function(i,s){if(typeof rt==="object"&&typeof st==="object")st.exports=s(xr());else if(typeof define==="function"&&define.amd)define(["cose-base"],s);else if(typeof rt==="object")rt.cytoscapeFcose=s(xr());else i.cytoscapeFcose=s(i.coseBase)})(rt,function(e){return(()=>{var i={658:(k)=>{k.exports=Object.assign!=null?Object.assign.bind(Object):function(z){for(var v=arguments.length,b=Array(v>1?v-1:0),c=1;c<v;c++)b[c-1]=arguments[c];return b.forEach(function(y){Object.keys(y).forEach(function(d){return z[d]=y[d]})}),z}},548:(k,z,v)=>{var b=function(){function d(f,u){var g=[],r=!0,B=!1,F=void 0;try{for(var o=f[Symbol.iterator](),h;!(r=(h=o.next()).done);r=!0)if(g.push(h.value),u&&g.length===u)break}catch(D){B=!0,F=D}finally{try{if(!r&&o.return)o.return()}finally{if(B)throw F}}return g}return function(f,u){if(Array.isArray(f))return f;else if(Symbol.iterator in Object(f))return d(f,u);else throw TypeError("Invalid attempt to destructure non-iterable instance")}}(),c=v(140).layoutBase.LinkedList,y={};y.getTopMostNodes=function(d){var f={};for(var u=0;u<d.length;u++)f[d[u].id()]=!0;var g=d.filter(function(r,B){if(typeof r==="number")r=B;var F=r.parent()[0];while(F!=null){if(f[F.id()])return!1;F=F.parent()[0]}return!0});return g},y.connectComponents=function(d,f,u,g){var r=new c,B=new Set,F=[],o=void 0,h=void 0,D=void 0,n=!1,P=1,U=[],M=[],X=function(){var I=d.collection();M.push(I);var Y=u[0],Z=d.collection();Z.merge(Y).merge(Y.descendants().intersection(f)),F.push(Y),Z.forEach(function(re){r.push(re),B.add(re),I.merge(re)});var Q=function(){Y=r.shift();var ue=d.collection();Y.neighborhood().nodes().forEach(function(q){if(f.intersection(Y.edgesWith(q)).length>0)ue.merge(q)});for(var Ae=0;Ae<ue.length;Ae++){var Pe=ue[Ae];if(o=u.intersection(Pe.union(Pe.ancestors())),o!=null&&!B.has(o[0])){var de=o.union(o.descendants());de.forEach(function(q){if(r.push(q),B.add(q),I.merge(q),u.has(q))F.push(q)})}}};while(r.length!=0)Q();if(I.forEach(function(re){f.intersection(re.connectedEdges()).forEach(function(ue){if(I.has(ue.source())&&I.has(ue.target()))I.merge(ue)})}),F.length==u.length)n=!0;if(!n||n&&P>1){h=F[0],D=h.connectedEdges().length,F.forEach(function(re){if(re.connectedEdges().length<D)D=re.connectedEdges().length,h=re}),U.push(h.id());var se=d.collection();se.merge(F[0]),F.forEach(function(re){se.merge(re)}),F=[],u=u.difference(se),P++}};do X();while(!n);if(g){if(U.length>0)g.set("dummy"+(g.size+1),U)}return M},y.relocateComponent=function(d,f,u){if(!u.fixedNodeConstraint){var{POSITIVE_INFINITY:g,NEGATIVE_INFINITY:r,POSITIVE_INFINITY:B,NEGATIVE_INFINITY:F}=Number;if(u.quality=="draft"){var o=!0,h=!1,D=void 0;try{for(var n=f.nodeIndexes[Symbol.iterator](),P;!(o=(P=n.next()).done);o=!0){var U=P.value,M=b(U,2),X=M[0],_=M[1],I=u.cy.getElementById(X);if(I){var Y=I.boundingBox(),Z=f.xCoords[_]-Y.w/2,Q=f.xCoords[_]+Y.w/2,se=f.yCoords[_]-Y.h/2,re=f.yCoords[_]+Y.h/2;if(Z<g)g=Z;if(Q>r)r=Q;if(se<B)B=se;if(re>F)F=re}}}catch(q){h=!0,D=q}finally{try{if(!o&&n.return)n.return()}finally{if(h)throw D}}var ue=d.x-(r+g)/2,Ae=d.y-(F+B)/2;f.xCoords=f.xCoords.map(function(q){return q+ue}),f.yCoords=f.yCoords.map(function(q){return q+Ae})}else{Object.keys(f).forEach(function(q){var oe=f[q],Ne=oe.getRect().x,ke=oe.getRect().x+oe.getRect().width,De=oe.getRect().y,xe=oe.getRect().y+oe.getRect().height;if(Ne<g)g=Ne;if(ke>r)r=ke;if(De<B)B=De;if(xe>F)F=xe});var Pe=d.x-(r+g)/2,de=d.y-(F+B)/2;Object.keys(f).forEach(function(q){var oe=f[q];oe.setCenter(oe.getCenterX()+Pe,oe.getCenterY()+de)})}}},y.calcBoundingBox=function(d,f,u,g){var{MAX_SAFE_INTEGER:r,MIN_SAFE_INTEGER:B,MAX_SAFE_INTEGER:F,MIN_SAFE_INTEGER:o}=Number,h=void 0,D=void 0,n=void 0,P=void 0,U=d.descendants().not(":parent"),M=U.length;for(var X=0;X<M;X++){var _=U[X];if(h=f[g.get(_.id())]-_.width()/2,D=f[g.get(_.id())]+_.width()/2,n=u[g.get(_.id())]-_.height()/2,P=u[g.get(_.id())]+_.height()/2,r>h)r=h;if(B<D)B=D;if(F>n)F=n;if(o<P)o=P}var I={};return I.topLeftX=r,I.topLeftY=F,I.width=B-r,I.height=o-F,I},y.calcParentsWithoutChildren=function(d,f){var u=d.collection();return f.nodes(":parent").forEach(function(g){var r=!1;if(g.children().forEach(function(B){if(B.css("display")!="none")r=!0}),!r)u.merge(g)}),u},k.exports=y},816:(k,z,v)=>{var b=v(548),c=v(140).CoSELayout,y=v(140).CoSENode,d=v(140).layoutBase.PointD,f=v(140).layoutBase.DimensionD,u=v(140).layoutBase.LayoutConstants,g=v(140).layoutBase.FDLayoutConstants,r=v(140).CoSEConstants,B=function(o,h){var{cy:D,eles:n}=o,P=n.nodes(),U=n.edges(),M=void 0,X=void 0,_=void 0,I={};if(o.randomize)M=h.nodeIndexes,X=h.xCoords,_=h.yCoords;var Y=function(q){return typeof q==="function"},Z=function(q,oe){if(Y(q))return q(oe);else return q},Q=b.calcParentsWithoutChildren(D,n),se=function de(q,oe,Ne,ke){var De=oe.length;for(var xe=0;xe<De;xe++){var W=oe[xe],Te=null;if(W.intersection(Q).length==0)Te=W.children();var ie=void 0,ve=W.layoutDimensions({nodeDimensionsIncludeLabels:ke.nodeDimensionsIncludeLabels});if(W.outerWidth()!=null&&W.outerHeight()!=null)if(ke.randomize)if(!W.isParent())ie=q.add(new y(Ne.graphManager,new d(X[M.get(W.id())]-ve.w/2,_[M.get(W.id())]-ve.h/2),new f(parseFloat(ve.w),parseFloat(ve.h))));else{var Me=b.calcBoundingBox(W,X,_,M);if(W.intersection(Q).length==0)ie=q.add(new y(Ne.graphManager,new d(Me.topLeftX,Me.topLeftY),new f(Me.width,Me.height)));else ie=q.add(new y(Ne.graphManager,new d(Me.topLeftX,Me.topLeftY),new f(parseFloat(ve.w),parseFloat(ve.h))))}else ie=q.add(new y(Ne.graphManager,new d(W.position("x")-ve.w/2,W.position("y")-ve.h/2),new f(parseFloat(ve.w),parseFloat(ve.h))));else ie=q.add(new y(this.graphManager));if(ie.id=W.data("id"),ie.nodeRepulsion=Z(ke.nodeRepulsion,W),ie.paddingLeft=parseInt(W.css("padding")),ie.paddingTop=parseInt(W.css("padding")),ie.paddingRight=parseInt(W.css("padding")),ie.paddingBottom=parseInt(W.css("padding")),ke.nodeDimensionsIncludeLabels)ie.labelWidth=W.boundingBox({includeLabels:!0,includeNodes:!1,includeOverlays:!1}).w,ie.labelHeight=W.boundingBox({includeLabels:!0,includeNodes:!1,includeOverlays:!1}).h,ie.labelPosVertical=W.css("text-valign"),ie.labelPosHorizontal=W.css("text-halign");if(I[W.data("id")]=ie,isNaN(ie.rect.x))ie.rect.x=0;if(isNaN(ie.rect.y))ie.rect.y=0;if(Te!=null&&Te.length>0){var ze=void 0;ze=Ne.getGraphManager().add(Ne.newGraph(),ie),de(ze,Te,Ne,ke)}}},re=function(q,oe,Ne){var ke=0,De=0;for(var xe=0;xe<Ne.length;xe++){var W=Ne[xe],Te=I[W.data("source")],ie=I[W.data("target")];if(Te&&ie&&Te!==ie&&Te.getEdgesBetween(ie).length==0){var ve=oe.add(q.newEdge(),Te,ie);ve.id=W.id(),ve.idealLength=Z(o.idealEdgeLength,W),ve.edgeElasticity=Z(o.edgeElasticity,W),ke+=ve.idealLength,De++}}if(o.idealEdgeLength!=null){if(De>0)r.DEFAULT_EDGE_LENGTH=g.DEFAULT_EDGE_LENGTH=ke/De;else if(!Y(o.idealEdgeLength))r.DEFAULT_EDGE_LENGTH=g.DEFAULT_EDGE_LENGTH=o.idealEdgeLength;else r.DEFAULT_EDGE_LENGTH=g.DEFAULT_EDGE_LENGTH=50;r.MIN_REPULSION_DIST=g.MIN_REPULSION_DIST=g.DEFAULT_EDGE_LENGTH/10,r.DEFAULT_RADIAL_SEPARATION=g.DEFAULT_EDGE_LENGTH}},ue=function(q,oe){if(oe.fixedNodeConstraint)q.constraints.fixedNodeConstraint=oe.fixedNodeConstraint;if(oe.alignmentConstraint)q.constraints.alignmentConstraint=oe.alignmentConstraint;if(oe.relativePlacementConstraint)q.constraints.relativePlacementConstraint=oe.relativePlacementConstraint};if(o.nestingFactor!=null)r.PER_LEVEL_IDEAL_EDGE_LENGTH_FACTOR=g.PER_LEVEL_IDEAL_EDGE_LENGTH_FACTOR=o.nestingFactor;if(o.gravity!=null)r.DEFAULT_GRAVITY_STRENGTH=g.DEFAULT_GRAVITY_STRENGTH=o.gravity;if(o.numIter!=null)r.MAX_ITERATIONS=g.MAX_ITERATIONS=o.numIter;if(o.gravityRange!=null)r.DEFAULT_GRAVITY_RANGE_FACTOR=g.DEFAULT_GRAVITY_RANGE_FACTOR=o.gravityRange;if(o.gravityCompound!=null)r.DEFAULT_COMPOUND_GRAVITY_STRENGTH=g.DEFAULT_COMPOUND_GRAVITY_STRENGTH=o.gravityCompound;if(o.gravityRangeCompound!=null)r.DEFAULT_COMPOUND_GRAVITY_RANGE_FACTOR=g.DEFAULT_COMPOUND_GRAVITY_RANGE_FACTOR=o.gravityRangeCompound;if(o.initialEnergyOnIncremental!=null)r.DEFAULT_COOLING_FACTOR_INCREMENTAL=g.DEFAULT_COOLING_FACTOR_INCREMENTAL=o.initialEnergyOnIncremental;if(o.tilingCompareBy!=null)r.TILING_COMPARE_BY=o.tilingCompareBy;if(o.quality=="proof")u.QUALITY=2;else u.QUALITY=0;if(r.NODE_DIMENSIONS_INCLUDE_LABELS=g.NODE_DIMENSIONS_INCLUDE_LABELS=u.NODE_DIMENSIONS_INCLUDE_LABELS=o.nodeDimensionsIncludeLabels,r.DEFAULT_INCREMENTAL=g.DEFAULT_INCREMENTAL=u.DEFAULT_INCREMENTAL=!o.randomize,r.ANIMATE=g.ANIMATE=u.ANIMATE=o.animate,r.TILE=o.tile,r.TILING_PADDING_VERTICAL=typeof o.tilingPaddingVertical==="function"?o.tilingPaddingVertical.call():o.tilingPaddingVertical,r.TILING_PADDING_HORIZONTAL=typeof o.tilingPaddingHorizontal==="function"?o.tilingPaddingHorizontal.call():o.tilingPaddingHorizontal,r.DEFAULT_INCREMENTAL=g.DEFAULT_INCREMENTAL=u.DEFAULT_INCREMENTAL=!0,r.PURE_INCREMENTAL=!o.randomize,u.DEFAULT_UNIFORM_LEAF_NODE_SIZES=o.uniformNodeDimensions,o.step=="transformed")r.TRANSFORM_ON_CONSTRAINT_HANDLING=!0,r.ENFORCE_CONSTRAINTS=!1,r.APPLY_LAYOUT=!1;if(o.step=="enforced")r.TRANSFORM_ON_CONSTRAINT_HANDLING=!1,r.ENFORCE_CONSTRAINTS=!0,r.APPLY_LAYOUT=!1;if(o.step=="cose")r.TRANSFORM_ON_CONSTRAINT_HANDLING=!1,r.ENFORCE_CONSTRAINTS=!1,r.APPLY_LAYOUT=!0;if(o.step=="all"){if(o.randomize)r.TRANSFORM_ON_CONSTRAINT_HANDLING=!0;else r.TRANSFORM_ON_CONSTRAINT_HANDLING=!1;r.ENFORCE_CONSTRAINTS=!0,r.APPLY_LAYOUT=!0}if(o.fixedNodeConstraint||o.alignmentConstraint||o.relativePlacementConstraint)r.TREE_REDUCTION_ON_INCREMENTAL=!1;else r.TREE_REDUCTION_ON_INCREMENTAL=!0;var Ae=new c,Pe=Ae.newGraphManager();return se(Pe.addRoot(),b.getTopMostNodes(P),Ae,o),re(Ae,Pe,U),ue(Ae,o),Ae.runLayout(),I};k.exports={coseLayout:B}},212:(k,z,v)=>{var b=function(){function o(h,D){for(var n=0;n<D.length;n++){var P=D[n];if(P.enumerable=P.enumerable||!1,P.configurable=!0,"value"in P)P.writable=!0;Object.defineProperty(h,P.key,P)}}return function(h,D,n){if(D)o(h.prototype,D);if(n)o(h,n);return h}}();function c(o,h){if(!(o instanceof h))throw TypeError("Cannot call a class as a function")}var y=v(658),d=v(548),f=v(657),u=f.spectralLayout,g=v(816),r=g.coseLayout,B=Object.freeze({quality:"default",randomize:!0,animate:!0,animationDuration:1000,animationEasing:void 0,fit:!0,padding:30,nodeDimensionsIncludeLabels:!1,uniformNodeDimensions:!1,packComponents:!0,step:"all",samplingType:!0,sampleSize:25,nodeSeparation:75,piTol:0.0000001,nodeRepulsion:function(h){return 4500},idealEdgeLength:function(h){return 50},edgeElasticity:function(h){return 0.45},nestingFactor:0.1,gravity:0.25,numIter:2500,tile:!0,tilingCompareBy:void 0,tilingPaddingVertical:10,tilingPaddingHorizontal:10,gravityRangeCompound:1.5,gravityCompound:1,gravityRange:3.8,initialEnergyOnIncremental:0.3,fixedNodeConstraint:void 0,alignmentConstraint:void 0,relativePlacementConstraint:void 0,ready:function(){},stop:function(){}}),F=function(){function o(h){c(this,o),this.options=y({},B,h)}return b(o,[{key:"run",value:function(){var D=this,n=this.options,{cy:P,eles:U}=n,M=[],X=void 0,_=void 0,I=[],Y=void 0,Z=[];if(n.fixedNodeConstraint&&(!Array.isArray(n.fixedNodeConstraint)||n.fixedNodeConstraint.length==0))n.fixedNodeConstraint=void 0;if(n.alignmentConstraint){if(n.alignmentConstraint.vertical&&(!Array.isArray(n.alignmentConstraint.vertical)||n.alignmentConstraint.vertical.length==0))n.alignmentConstraint.vertical=void 0;if(n.alignmentConstraint.horizontal&&(!Array.isArray(n.alignmentConstraint.horizontal)||n.alignmentConstraint.horizontal.length==0))n.alignmentConstraint.horizontal=void 0}if(n.relativePlacementConstraint&&(!Array.isArray(n.relativePlacementConstraint)||n.relativePlacementConstraint.length==0))n.relativePlacementConstraint=void 0;var Q=n.fixedNodeConstraint||n.alignmentConstraint||n.relativePlacementConstraint;if(Q)n.tile=!1,n.packComponents=!1;var se=void 0,re=!1;if(P.layoutUtilities&&n.packComponents){if(se=P.layoutUtilities("get"),!se)se=P.layoutUtilities();re=!0}if(U.nodes().length>0)if(!re){var ue=n.eles.boundingBox();if(Z.push({x:ue.x1+ue.w/2,y:ue.y1+ue.h/2}),n.randomize){var Ae=u(n);M.push(Ae)}if(n.quality=="default"||n.quality=="proof")I.push(r(n,M[0])),d.relocateComponent(Z[0],I[0],n);else d.relocateComponent(Z[0],M[0],n)}else{var Pe=d.getTopMostNodes(n.eles.nodes());if(Y=d.connectComponents(P,n.eles,Pe),Y.forEach(function(K){var G=K.boundingBox();Z.push({x:G.x1+G.w/2,y:G.y1+G.h/2})}),n.randomize)Y.forEach(function(K){n.eles=K,M.push(u(n))});if(n.quality=="default"||n.quality=="proof"){var de=P.collection();if(n.tile){var q=new Map,oe=[],Ne=[],ke=0,De={nodeIndexes:q,xCoords:oe,yCoords:Ne},xe=[];if(Y.forEach(function(K,G){if(K.edges().length==0)K.nodes().forEach(function(pe,le){if(de.merge(K.nodes()[le]),!pe.isParent())De.nodeIndexes.set(K.nodes()[le].id(),ke++),De.xCoords.push(K.nodes()[0].position().x),De.yCoords.push(K.nodes()[0].position().y)}),xe.push(G)}),de.length>1){var W=de.boundingBox();Z.push({x:W.x1+W.w/2,y:W.y1+W.h/2}),Y.push(de),M.push(De);for(var Te=xe.length-1;Te>=0;Te--)Y.splice(xe[Te],1),M.splice(xe[Te],1),Z.splice(xe[Te],1)}}Y.forEach(function(K,G){n.eles=K,I.push(r(n,M[G])),d.relocateComponent(Z[G],I[G],n)})}else Y.forEach(function(K,G){d.relocateComponent(Z[G],M[G],n)});var ie=new Set;if(Y.length>1){var ve=[],Me=U.filter(function(K){return K.css("display")=="none"});Y.forEach(function(K,G){var pe=void 0;if(n.quality=="draft")pe=M[G].nodeIndexes;if(K.nodes().not(Me).length>0){var le={};le.edges=[],le.nodes=[];var me=void 0;if(K.nodes().not(Me).forEach(function(fe){if(n.quality=="draft")if(!fe.isParent())me=pe.get(fe.id()),le.nodes.push({x:M[G].xCoords[me]-fe.boundingbox().w/2,y:M[G].yCoords[me]-fe.boundingbox().h/2,width:fe.boundingbox().w,height:fe.boundingbox().h});else{var he=d.calcBoundingBox(fe,M[G].xCoords,M[G].yCoords,pe);le.nodes.push({x:he.topLeftX,y:he.topLeftY,width:he.width,height:he.height})}else if(I[G][fe.id()])le.nodes.push({x:I[G][fe.id()].getLeft(),y:I[G][fe.id()].getTop(),width:I[G][fe.id()].getWidth(),height:I[G][fe.id()].getHeight()})}),K.edges().forEach(function(fe){var he=fe.source(),Ee=fe.target();if(he.css("display")!="none"&&Ee.css("display")!="none"){if(n.quality=="draft"){var Be=pe.get(he.id()),et=pe.get(Ee.id()),Oe=[],Ye=[];if(he.isParent()){var We=d.calcBoundingBox(he,M[G].xCoords,M[G].yCoords,pe);Oe.push(We.topLeftX+We.width/2),Oe.push(We.topLeftY+We.height/2)}else Oe.push(M[G].xCoords[Be]),Oe.push(M[G].yCoords[Be]);if(Ee.isParent()){var Je=d.calcBoundingBox(Ee,M[G].xCoords,M[G].yCoords,pe);Ye.push(Je.topLeftX+Je.width/2),Ye.push(Je.topLeftY+Je.height/2)}else Ye.push(M[G].xCoords[et]),Ye.push(M[G].yCoords[et]);le.edges.push({startX:Oe[0],startY:Oe[1],endX:Ye[0],endY:Ye[1]})}else if(I[G][he.id()]&&I[G][Ee.id()])le.edges.push({startX:I[G][he.id()].getCenterX(),startY:I[G][he.id()].getCenterY(),endX:I[G][Ee.id()].getCenterX(),endY:I[G][Ee.id()].getCenterY()})}}),le.nodes.length>0)ve.push(le),ie.add(G)}});var ze=se.packComponents(ve,n.randomize).shifts;if(n.quality=="draft")M.forEach(function(K,G){var pe=K.xCoords.map(function(me){return me+ze[G].dx}),le=K.yCoords.map(function(me){return me+ze[G].dy});K.xCoords=pe,K.yCoords=le});else{var Ke=0;ie.forEach(function(K){Object.keys(I[K]).forEach(function(G){var pe=I[K][G];pe.setCenter(pe.getCenterX()+ze[Ke].dx,pe.getCenterY()+ze[Ke].dy)}),Ke++})}}}var je=function(G,pe){if(n.quality=="default"||n.quality=="proof"){if(typeof G==="number")G=pe;var le=void 0,me=void 0,fe=G.data("id");if(I.forEach(function(Ee){if(fe in Ee)le={x:Ee[fe].getRect().getCenterX(),y:Ee[fe].getRect().getCenterY()},me=Ee[fe]}),n.nodeDimensionsIncludeLabels){if(me.labelWidth){if(me.labelPosHorizontal=="left")le.x+=me.labelWidth/2;else if(me.labelPosHorizontal=="right")le.x-=me.labelWidth/2}if(me.labelHeight){if(me.labelPosVertical=="top")le.y+=me.labelHeight/2;else if(me.labelPosVertical=="bottom")le.y-=me.labelHeight/2}}if(le==null)le={x:G.position("x"),y:G.position("y")};return{x:le.x,y:le.y}}else{var he=void 0;if(M.forEach(function(Ee){var Be=Ee.nodeIndexes.get(G.id());if(Be!=null)he={x:Ee.xCoords[Be],y:Ee.yCoords[Be]}}),he==null)he={x:G.position("x"),y:G.position("y")};return{x:he.x,y:he.y}}};if(n.quality=="default"||n.quality=="proof"||n.randomize){var nt=d.calcParentsWithoutChildren(P,U),qe=U.filter(function(K){return K.css("display")=="none"});if(n.eles=U.not(qe),U.nodes().not(":parent").not(qe).layoutPositions(D,n,je),nt.length>0)nt.forEach(function(K){K.position(je(K))})}else console.log("If randomize option is set to false, then quality option must be 'default' or 'proof'.")}}]),o}();k.exports=F},657:(k,z,v)=>{var b=v(548),c=v(140).layoutBase.Matrix,y=v(140).layoutBase.SVD,d=function(u){var{cy:g,eles:r}=u,B=r.nodes(),F=r.nodes(":parent"),o=new Map,h=new Map,D=new Map,n=[],P=[],U=[],M=[],X=[],_=[],I=[],Y=[],Z=void 0,Q=void 0,se=1e8,re=0.000000001,{piTol:ue,samplingType:Ae,nodeSeparation:Pe}=u,de=void 0,q=function(){var ee=0,te=0,ne=!1;while(te<de){ee=Math.floor(Math.random()*Q),ne=!1;for(var ae=0;ae<te;ae++)if(M[ae]==ee){ne=!0;break}if(!ne)M[te]=ee,te++;else continue}},oe=function(ee,te,ne){var ae=[],we=0,ge=0,ce=0,Ie=void 0,be=[],$e=0,_e=1;for(var Ue=0;Ue<Q;Ue++)be[Ue]=se;ae[ge]=ee,be[ee]=0;while(ge>=we){ce=ae[we++];var Xe=n[ce];for(var He=0;He<Xe.length;He++)if(Ie=h.get(Xe[He]),be[Ie]==se)be[Ie]=be[ce]+1,ae[++ge]=Ie;_[ce][te]=be[ce]*Pe}if(ne){for(var Ge=0;Ge<Q;Ge++)if(_[Ge][te]<X[Ge])X[Ge]=_[Ge][te];for(var tt=0;tt<Q;tt++)if(X[tt]>$e)$e=X[tt],_e=tt}return _e},Ne=function(ee){var te=void 0;if(!ee){q();for(var ne=0;ne<de;ne++)oe(M[ne],ne,ee,!1)}else{te=Math.floor(Math.random()*Q),Z=te;for(var ae=0;ae<Q;ae++)X[ae]=se;for(var we=0;we<de;we++)M[we]=te,te=oe(te,we,ee)}for(var ge=0;ge<Q;ge++)for(var ce=0;ce<de;ce++)_[ge][ce]*=_[ge][ce];for(var Ie=0;Ie<de;Ie++)I[Ie]=[];for(var be=0;be<de;be++)for(var $e=0;$e<de;$e++)I[be][$e]=_[M[$e]][be]},ke=function(){var ee=y.svd(I),{S:te,U:ne,V:ae}=ee,we=te[0]*te[0]*te[0],ge=[];for(var ce=0;ce<de;ce++){ge[ce]=[];for(var Ie=0;Ie<de;Ie++)if(ge[ce][Ie]=0,ce==Ie)ge[ce][Ie]=te[ce]/(te[ce]*te[ce]+we/(te[ce]*te[ce]))}Y=c.multMat(c.multMat(ae,ge),c.transpose(ne))},De=function(){var ee=void 0,te=void 0,ne=[],ae=[],we=[],ge=[];for(var ce=0;ce<Q;ce++)ne[ce]=Math.random(),ae[ce]=Math.random();ne=c.normalize(ne),ae=c.normalize(ae);var Ie=0,be=re,$e=re,_e=void 0;while(!0){Ie++;for(var Ue=0;Ue<Q;Ue++)we[Ue]=ne[Ue];if(ne=c.multGamma(c.multL(c.multGamma(we),_,Y)),ee=c.dotProduct(we,ne),ne=c.normalize(ne),be=c.dotProduct(we,ne),_e=Math.abs(be/$e),_e<=1+ue&&_e>=1)break;$e=be}for(var Xe=0;Xe<Q;Xe++)we[Xe]=ne[Xe];Ie=0,$e=re;while(!0){Ie++;for(var He=0;He<Q;He++)ge[He]=ae[He];if(ge=c.minusOp(ge,c.multCons(we,c.dotProduct(we,ge))),ae=c.multGamma(c.multL(c.multGamma(ge),_,Y)),te=c.dotProduct(ge,ae),ae=c.normalize(ae),be=c.dotProduct(ge,ae),_e=Math.abs(be/$e),_e<=1+ue&&_e>=1)break;$e=be}for(var Ge=0;Ge<Q;Ge++)ge[Ge]=ae[Ge];P=c.multCons(we,Math.sqrt(Math.abs(ee))),U=c.multCons(ge,Math.sqrt(Math.abs(te)))};b.connectComponents(g,r,b.getTopMostNodes(B),o),F.forEach(function(ye){b.connectComponents(g,r,b.getTopMostNodes(ye.descendants().intersection(r)),o)});var xe=0;for(var W=0;W<B.length;W++)if(!B[W].isParent())h.set(B[W].id(),xe++);var Te=!0,ie=!1,ve=void 0;try{for(var Me=o.keys()[Symbol.iterator](),ze;!(Te=(ze=Me.next()).done);Te=!0){var Ke=ze.value;h.set(Ke,xe++)}}catch(ye){ie=!0,ve=ye}finally{try{if(!Te&&Me.return)Me.return()}finally{if(ie)throw ve}}for(var je=0;je<h.size;je++)n[je]=[];F.forEach(function(ye){var ee=ye.children().intersection(r);while(ee.nodes(":childless").length==0)ee=ee.nodes()[0].children().intersection(r);var te=0,ne=ee.nodes(":childless")[0].connectedEdges().length;ee.nodes(":childless").forEach(function(ae,we){if(ae.connectedEdges().length<ne)ne=ae.connectedEdges().length,te=we}),D.set(ye.id(),ee.nodes(":childless")[te].id())}),B.forEach(function(ye){var ee=void 0;if(ye.isParent())ee=h.get(D.get(ye.id()));else ee=h.get(ye.id());ye.neighborhood().nodes().forEach(function(te){if(r.intersection(ye.edgesWith(te)).length>0)if(te.isParent())n[ee].push(D.get(te.id()));else n[ee].push(te.id())})});var nt=function(ee){var te=h.get(ee),ne=void 0;o.get(ee).forEach(function(ae){if(g.getElementById(ae).isParent())ne=D.get(ae);else ne=ae;n[te].push(ne),n[h.get(ne)].push(ee)})},qe=!0,K=!1,G=void 0;try{for(var pe=o.keys()[Symbol.iterator](),le;!(qe=(le=pe.next()).done);qe=!0){var me=le.value;nt(me)}}catch(ye){K=!0,G=ye}finally{try{if(!qe&&pe.return)pe.return()}finally{if(K)throw G}}Q=h.size;var fe=void 0;if(Q>2){de=Q<u.sampleSize?Q:u.sampleSize;for(var he=0;he<Q;he++)_[he]=[];for(var Ee=0;Ee<de;Ee++)Y[Ee]=[];if(u.quality=="draft"||u.step=="all")Ne(Ae),ke(),De(),fe={nodeIndexes:h,xCoords:P,yCoords:U};else h.forEach(function(ye,ee){P.push(g.getElementById(ee).position("x")),U.push(g.getElementById(ee).position("y"))}),fe={nodeIndexes:h,xCoords:P,yCoords:U};return fe}else{var Be=h.keys(),et=g.getElementById(Be.next().value),Oe=et.position(),Ye=et.outerWidth();if(P.push(Oe.x),U.push(Oe.y),Q==2){var We=g.getElementById(Be.next().value),Je=We.outerWidth();P.push(Oe.x+Ye/2+Je/2+u.idealEdgeLength),U.push(Oe.y)}return fe={nodeIndexes:h,xCoords:P,yCoords:U},fe}};k.exports={spectralLayout:d}},579:(k,z,v)=>{var b=v(212),c=function(d){if(!d)return;d("layout","fcose",b)};if(typeof cytoscape<"u")c(cytoscape);k.exports=c},140:(k)=>{k.exports=e}},s={};function w(k){var z=s[k];if(z!==void 0)return z.exports;var v=s[k]={exports:{}};return i[k](v,v.exports,w),v.exports}var m=w(579);return m})()})});var xt=Ce(ft(),1);var ut={L:"left",R:"right",T:"top",B:"bottom"},gt={L:t((e)=>`${e},${e/2} 0,${e} 0,0`,"L"),R:t((e)=>`0,${e/2} ${e},0 ${e},${e}`,"R"),T:t((e)=>`0,0 ${e},0 ${e/2},${e}`,"T"),B:t((e)=>`${e/2},0 ${e},${e} 0,${e}`,"B")},ot={L:t((e,i)=>e-i+2,"L"),R:t((e,i)=>e-2,"R"),T:t((e,i)=>e-i+2,"T"),B:t((e,i)=>e-2,"B")},kt=t(function(e){if(Re(e))return e==="L"?"R":"L";else return e==="T"?"B":"T"},"getOppositeArchitectureDirection"),vt=t(function(e){let i=e;return i==="L"||i==="R"||i==="T"||i==="B"},"isArchitectureDirection"),Re=t(function(e){let i=e;return i==="L"||i==="R"},"isArchitectureDirectionX"),Ve=t(function(e){let i=e;return i==="T"||i==="B"},"isArchitectureDirectionY"),dt=t(function(e,i){let s=Re(e)&&Ve(i),w=Ve(e)&&Re(i);return s||w},"isArchitectureDirectionXY"),Dt=t(function(e){let i=e[0],s=e[1],w=Re(i)&&Ve(s),m=Ve(i)&&Re(s);return w||m},"isArchitecturePairXY"),Rt=t(function(e){return e!=="LL"&&e!=="RR"&&e!=="TT"&&e!=="BB"},"isValidArchitectureDirectionPair"),lt=t(function(e,i){let s=`${e}${i}`;return Rt(s)?s:void 0},"getArchitectureDirectionPair"),Mt=t(function([e,i],s){let w=s[0],m=s[1];if(Re(w))if(Ve(m))return[e+(w==="L"?-1:1),i+(m==="T"?1:-1)];else return[e+(w==="L"?-1:1),i];else if(Re(m))return[e+(m==="L"?1:-1),i+(w==="T"?1:-1)];else return[e,i+(w==="T"?1:-1)]},"shiftPositionByArchitectureDirectionPair"),Ft=t(function(e){if(e==="LT"||e==="TL")return[1,1];else if(e==="BL"||e==="LB")return[1,-1];else if(e==="BR"||e==="RB")return[-1,-1];else return[-1,1]},"getArchitectureDirectionXYFactors"),$t=t(function(e,i){if(dt(e,i))return"bend";else if(Re(e))return"horizontal";return"vertical"},"getArchitectureDirectionAlignment"),Pt=t(function(e){return e.type==="service"},"isArchitectureService"),Ot=t(function(e){return e.type==="junction"},"isArchitectureJunction"),pt=t((e,i)=>{let[s,w]=[e,i].sort();return`${JSON.stringify(s)}-${JSON.stringify(w)}`},"architectureGroupAlignmentKey"),mt=t((e)=>e.data(),"edgeData"),Qe=t((e)=>e.data(),"nodeData"),Gt=N.architecture,Et=class{constructor(){this.nodes=new Map,this.groups=new Map,this.edges=[],this.layoutHints=[],this.registeredIds=new Map,this.elements=new Map,this.diagramId="",this.setAccTitle=S,this.getAccTitle=E,this.setDiagramTitle=L,this.getDiagramTitle=R,this.getAccDescription=A,this.setAccDescription=T,this.clear()}static{t(this,"ArchitectureDB")}setDiagramId(e){this.diagramId=e}getDiagramId(){return this.diagramId}clear(){this.nodes=new Map,this.groups=new Map,this.edges=[],this.layoutHints=[],this.registeredIds=new Map,this.dataStructures=void 0,this.elements=new Map,this.diagramId="",C()}addService({id:e,icon:i,in:s,title:w,iconText:m}){if(this.registeredIds.has(e))throw Error(`The service id [${e}] is already in use by another ${this.registeredIds.get(e)}`);if(s!==void 0){if(e===s)throw Error(`The service [${e}] cannot be placed within itself`);if(!this.registeredIds.has(s))throw Error(`The service [${e}]'s parent does not exist. Please make sure the parent is created before this service`);if(this.registeredIds.get(s)==="node")throw Error(`The service [${e}]'s parent is not a group`)}this.registeredIds.set(e,"node"),this.nodes.set(e,{id:e,type:"service",icon:i,iconText:m,title:w,edges:[],in:s})}getServices(){return[...this.nodes.values()].filter(Pt)}addJunction({id:e,in:i}){if(this.registeredIds.has(e))throw Error(`The junction id [${e}] is already in use by another ${this.registeredIds.get(e)}`);if(i!==void 0){if(e===i)throw Error(`The junction [${e}] cannot be placed within itself`);if(!this.registeredIds.has(i))throw Error(`The junction [${e}]'s parent does not exist. Please make sure the parent is created before this junction`);if(this.registeredIds.get(i)==="node")throw Error(`The junction [${e}]'s parent is not a group`)}this.registeredIds.set(e,"node"),this.nodes.set(e,{id:e,type:"junction",edges:[],in:i})}getJunctions(){return[...this.nodes.values()].filter(Ot)}getNodes(){return[...this.nodes.values()]}getNode(e){return this.nodes.get(e)??null}addGroup({id:e,icon:i,in:s,title:w}){if(this.registeredIds.has(e))throw Error(`The group id [${e}] is already in use by another ${this.registeredIds.get(e)}`);if(s!==void 0){if(e===s)throw Error(`The group [${e}] cannot be placed within itself`);if(!this.registeredIds.has(s))throw Error(`The group [${e}]'s parent does not exist. Please make sure the parent is created before this group`);if(this.registeredIds.get(s)==="node")throw Error(`The group [${e}]'s parent is not a group`)}this.registeredIds.set(e,"group"),this.groups.set(e,{id:e,icon:i,title:w,in:s})}getGroups(){return[...this.groups.values()]}addEdge({lhsId:e,rhsId:i,lhsDir:s,rhsDir:w,lhsInto:m,rhsInto:k,lhsGroup:z,rhsGroup:v,title:b}){if(!vt(s))throw Error(`Invalid direction given for left hand side of edge ${e}--${i}. Expected (L,R,T,B) got ${String(s)}`);if(!vt(w))throw Error(`Invalid direction given for right hand side of edge ${e}--${i}. Expected (L,R,T,B) got ${String(w)}`);if(!this.nodes.has(e)&&!this.groups.has(e))throw Error(`The left-hand id [${e}] does not yet exist. Please create the service/group before declaring an edge to it.`);if(!this.nodes.has(i)&&!this.groups.has(i))throw Error(`The right-hand id [${i}] does not yet exist. Please create the service/group before declaring an edge to it.`);let c=this.nodes.get(e).in,y=this.nodes.get(i).in;if(z&&c&&y&&c==y)throw Error(`The left-hand id [${e}] is modified to traverse the group boundary, but the edge does not pass through two groups.`);if(v&&c&&y&&c==y)throw Error(`The right-hand id [${i}] is modified to traverse the group boundary, but the edge does not pass through two groups.`);let d={lhsId:e,lhsDir:s,lhsInto:m,lhsGroup:z,rhsId:i,rhsDir:w,rhsInto:k,rhsGroup:v,title:b};this.edges.push(d);let f=this.nodes.get(e),u=this.nodes.get(i);if(f&&u)f.edges.push(this.edges[this.edges.length-1]),u.edges.push(this.edges[this.edges.length-1])}getEdges(){return this.edges}addLayoutHint(e){if(e.members.length<2)throw Error(`An align directive requires at least two members; got ${e.members.length}`);let i=new Set;e.members.forEach((s)=>{if(this.registeredIds.get(s)!=="node")throw Error(`align ${e.direction} references [${s}], which is not a service or junction`);if(i.has(s))throw Error(`align ${e.direction} lists [${s}] more than once`);i.add(s)}),this.layoutHints.push(e)}getLayoutHints(){return this.layoutHints}getDataStructures(){if(this.dataStructures===void 0){let e=new Map,i=new Map;for(let[z,v]of this.nodes.entries()){let b=new Map;for(let c of v.edges){let y=this.getNode(c.lhsId)?.in,d=this.getNode(c.rhsId)?.in;if(y&&d&&y!==d){let f=$t(c.lhsDir,c.rhsDir);if(f!=="bend")e.set(pt(y,d),f)}if(c.lhsId===z){let f=lt(c.lhsDir,c.rhsDir);if(f)b.set(f,c.rhsId)}else{let f=lt(c.rhsDir,c.lhsDir);if(f)b.set(f,c.lhsId)}}i.set(z,b)}let s=new Set,w=new Set(i.keys()),m=t((z)=>{let v=new Map([[z,[0,0]]]),b=[z];while(b.length>0){let c=b.shift();if(c){s.add(c),w.delete(c);let y=i.get(c);if(!y)throw Error(`BFS error: adjacency list for id ${c} not found. Please report this as a bug.`);let d=v.get(c);if(!d)throw Error(`BFS error: position for id ${c} not found in spatial map. Please report this as a bug.`);let[f,u]=d;y.forEach((g,r)=>{if(!s.has(g))v.set(g,Mt([f,u],r)),b.push(g)})}}return v},"BFS"),k=[];while(w.size>0){let z=w.values().next().value;k.push(m(z))}this.dataStructures={adjList:i,spatialMaps:k,groupAlignments:e}}return this.dataStructures}setElementForId(e,i){this.elements.set(e,i)}getElementById(e){return this.elements.get(e)}getConfig(){return j({...Gt,...x().architecture})}getConfigField(e){return this.getConfig()[e]}},zt=t((e,i)=>{H(e,i),e.groups.map((s)=>i.addGroup(s)),e.services.map((s)=>i.addService({...s,type:"service"})),e.junctions.map((s)=>i.addJunction({...s,type:"junction"})),e.edges.map((s)=>i.addEdge(s)),e.alignments?.map((s)=>i.addLayoutHint({direction:s.direction,members:[...s.members]}))},"populateDb"),wt={parser:{yy:void 0},parse:t(async(e)=>{let i=await J("architecture",e);a.debug(i);let s=wt.parser?.yy;if(!(s instanceof Et))throw Error("parser.parser?.yy was not a ArchitectureDB. This is due to a bug within Mermaid, please report this issue at https://github.com/mermaid-js/mermaid/issues.");zt(i,s)},"parse")},Bt=t((e)=>`
2
2
  .edge {
3
3
  stroke-width: ${e.archEdgeWidth};
4
4
  stroke: ${e.archEdgeColor};
@@ -1,4 +1,4 @@
1
- import{t}from"./chunk-zsat72qd.js";var qe=t(()=>`
1
+ import{t}from"./chunk-t5ke9cyg.js";var qe=t(()=>`
2
2
  /* Font Awesome icon styling - consolidated */
3
3
  .label-icon {
4
4
  display: inline-block;