@bkm016/basalt 0.1.11 → 0.1.12

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 (207) hide show
  1. package/{chunk-755sy11p.js → chunk-01nve4qy.js} +1 -1
  2. package/{chunk-jtsve11b.js → chunk-0fc9apfn.js} +9 -9
  3. package/{chunk-d5j74pcp.js → chunk-1h34mzh7.js} +4 -4
  4. package/{chunk-fgwda4m0.js → chunk-1xfv4bd7.js} +1 -1
  5. package/{chunk-mbpb5c7w.js → chunk-2fyjph3f.js} +1 -1
  6. package/{chunk-13gvs0ax.js → chunk-2kxnw7vs.js} +1 -1
  7. package/{chunk-95964592.js → chunk-37zystxb.js} +11 -11
  8. package/{chunk-h1kb8b49.js → chunk-3pf1d62g.js} +2 -2
  9. package/{chunk-29qrxygd.js → chunk-5wnmbc1b.js} +2 -2
  10. package/{chunk-c71173py.js → chunk-6mges89p.js} +4 -4
  11. package/{chunk-d0a1jxk5.js → chunk-6sz5q3df.js} +2 -2
  12. package/chunk-7er5pz7s.js +479 -0
  13. package/{chunk-gbjn6d81.js → chunk-7g5smgjj.js} +1 -1
  14. package/chunk-7m3jagqn.js +2 -0
  15. package/{chunk-wnzvnskb.js → chunk-85v69h91.js} +2 -2
  16. package/{chunk-38g3gctw.js → chunk-9c4gdg1q.js} +2 -2
  17. package/{chunk-en218k4y.js → chunk-cbgpymt4.js} +1 -1
  18. package/{chunk-a1rb1a48.js → chunk-cdw03j4t.js} +2 -2
  19. package/chunk-ch1r3ted.js +2 -0
  20. package/{chunk-dfh9m9n7.js → chunk-db7ws33a.js} +2 -2
  21. package/{chunk-1n7dat03.js → chunk-ejjem0tc.js} +3 -3
  22. package/{chunk-c4qr1f41.js → chunk-eq4wqxzt.js} +2 -2
  23. package/{chunk-zc9ar0r4.js → chunk-eyrtbbdd.js} +1 -1
  24. package/{chunk-r4ttdkrz.js → chunk-fhxy6y34.js} +2 -2
  25. package/{chunk-zyyzk5ha.js → chunk-fy82qxa1.js} +1 -1
  26. package/{chunk-xtq1xpq0.js → chunk-hc300148.js} +1 -1
  27. package/{chunk-vtqr7dm8.js → chunk-j64dc767.js} +2 -2
  28. package/{chunk-msm9hmk9.js → chunk-jpnf71q7.js} +2 -2
  29. package/{chunk-q9f4xb0w.js → chunk-kpe7pnhy.js} +4 -4
  30. package/{chunk-a98wma9j.js → chunk-ksk49hv0.js} +1 -1
  31. package/{chunk-bdjr0kfr.js → chunk-m4bg1apa.js} +5 -5
  32. package/{chunk-dq01v5eq.js → chunk-nhm9z3d8.js} +1 -1
  33. package/{chunk-30rjf7my.js → chunk-ntks40jd.js} +2 -2
  34. package/{chunk-a1352w87.js → chunk-nw1xpt3s.js} +1 -1
  35. package/{chunk-xh444pfn.js → chunk-p2pmdbt2.js} +8 -8
  36. package/{chunk-hb4f2v34.js → chunk-qfcr5g35.js} +2 -2
  37. package/{chunk-n2jcx65v.js → chunk-qs8zzg50.js} +2 -2
  38. package/{chunk-qaeyhe65.js → chunk-r4gm8ngh.js} +1 -1
  39. package/{chunk-pz2afna8.js → chunk-rks90mh1.js} +1 -1
  40. package/{chunk-asyr3gnq.js → chunk-rwks9zaw.js} +2 -2
  41. package/{chunk-v3ee9z3f.js → chunk-t7te60m7.js} +1 -1
  42. package/{chunk-4dw43syb.js → chunk-tv52xajf.js} +1 -1
  43. package/{chunk-c0zfefq8.js → chunk-v7wcchy2.js} +1 -1
  44. package/{chunk-tevejprz.js → chunk-vjne04dp.js} +3 -3
  45. package/{chunk-ax04trym.js → chunk-w0rr66z7.js} +1 -1
  46. package/{chunk-gkf5jwvj.js → chunk-w6f2r052.js} +1 -1
  47. package/{chunk-jymx3a77.js → chunk-wqqjzsjt.js} +310 -278
  48. package/{chunk-c6q04xrd.js → chunk-xef4642x.js} +1 -1
  49. package/compiled.js +7 -7
  50. package/package.json +1 -1
  51. package/ui-test-worker.js +2 -2
  52. package/web/{chunk-jhpg2kcf.js → chunk-04drx71p.js} +1 -1
  53. package/web/chunk-0rdgt4jb.css +1 -0
  54. package/web/{chunk-cbwvfedy.js → chunk-19zd0tye.js} +3 -3
  55. package/web/chunk-1m0kp0g3.js +8 -0
  56. package/web/{chunk-j4gvtszc.js → chunk-1zwc09e8.js} +2 -2
  57. package/web/{chunk-a3pye9ag.js → chunk-2cyzaqjy.js} +3 -3
  58. package/web/{chunk-8csw0mvf.js → chunk-2jfesv7m.js} +2 -2
  59. package/web/chunk-3j2tcphs.js +1 -0
  60. package/web/chunk-3k9h7a73.js +1142 -0
  61. package/web/chunk-3m1bb2fw.js +1 -0
  62. package/web/{chunk-4rwwtfnd.js → chunk-3n9ypydh.js} +2 -2
  63. package/web/{chunk-90fkdzx3.js → chunk-3psgr0q8.js} +13 -13
  64. package/web/{chunk-nafe18y9.js → chunk-3qxxrwsp.js} +6 -6
  65. package/web/{chunk-hjyev38w.js → chunk-3rkkp6ed.js} +4 -4
  66. package/web/{chunk-v3dn9bfw.js → chunk-4f6a8dsk.js} +1 -1
  67. package/web/chunk-55nvm2mj.js +1 -0
  68. package/web/chunk-5dkqfnh7.js +2 -0
  69. package/web/{chunk-96xhmmqz.js → chunk-5g8md2wg.js} +4 -4
  70. package/web/{chunk-mpdeqzc9.js → chunk-5np514v5.js} +8 -8
  71. package/web/{chunk-1zfxaafq.js → chunk-60mym60n.js} +1 -1
  72. package/web/{chunk-nhx8pw7p.js → chunk-6f2sz84q.js} +2 -2
  73. package/web/{chunk-q8v5j963.js → chunk-7adsmqv6.js} +2 -2
  74. package/web/{chunk-27812gqr.js → chunk-7ksg3ccg.js} +3 -3
  75. package/web/chunk-7ky5nrrr.js +1 -0
  76. package/web/{chunk-pq56b3mq.js → chunk-7tkgbbf9.js} +2 -2
  77. package/web/{chunk-tpdcrrf1.js → chunk-7v85yvb2.js} +1 -1
  78. package/web/{chunk-dk0fnj87.js → chunk-7vgh17es.js} +1 -1
  79. package/web/{chunk-rqympya7.js → chunk-80z8s8zb.js} +1 -1
  80. package/web/{chunk-36dc7tcg.js → chunk-81s15c2e.js} +2 -2
  81. package/web/{chunk-mykbcvqz.js → chunk-8539865x.js} +1 -1
  82. package/web/{chunk-wbwets5x.js → chunk-8cnjd0f2.js} +17 -17
  83. package/web/{chunk-48479gnx.js → chunk-8sdjgv3k.js} +1 -1
  84. package/web/chunk-9bxtzwtc.js +1 -0
  85. package/web/{chunk-drchr3yn.js → chunk-aa46mrgh.js} +1 -1
  86. package/web/{chunk-8151c970.js → chunk-act3rr85.js} +1 -1
  87. package/web/{chunk-94denx9h.js → chunk-aebrw6cv.js} +3 -3
  88. package/web/{chunk-3a57m7xm.js → chunk-aeymdtm1.js} +2 -2
  89. package/web/{chunk-3020mmp1.js → chunk-ar6jnhm5.js} +1 -1
  90. package/web/{chunk-e763h2px.js → chunk-b5zf1hs3.js} +66 -66
  91. package/web/{chunk-5ahx98zj.js → chunk-b99k8q22.js} +8 -8
  92. package/web/chunk-bcjgzwef.js +1 -0
  93. package/web/{chunk-f79ajymt.js → chunk-bra33pt0.js} +2 -2
  94. package/web/{chunk-57pyz29y.js → chunk-bygwbpvq.js} +2 -2
  95. package/web/{chunk-3ftb27f3.js → chunk-c3fty2c2.js} +5 -5
  96. package/web/{chunk-d3f763n7.js → chunk-cxpnj495.js} +1 -1
  97. package/web/{chunk-8z7texmv.js → chunk-d1btrqmw.js} +1 -1
  98. package/web/{chunk-jqqbkdtw.js → chunk-d57fm7k0.js} +2 -2
  99. package/web/{chunk-1t38sgrk.js → chunk-d73zkc4q.js} +4 -4
  100. package/web/chunk-d94t9z70.js +1 -0
  101. package/web/{chunk-2ds0a2z1.js → chunk-dndd757x.js} +3 -3
  102. package/web/{chunk-d4519smc.js → chunk-e94pd9rr.js} +10 -10
  103. package/web/{chunk-qykt7avq.js → chunk-enwfd8d5.js} +2 -2
  104. package/web/chunk-fr4fft89.js +1 -0
  105. package/web/{chunk-g0rtcedn.js → chunk-g488hxx0.js} +3 -3
  106. package/web/{chunk-b6sqwmq7.js → chunk-g4zm0crw.js} +1 -1
  107. package/web/{chunk-086dshck.js → chunk-gckmcef6.js} +1 -1
  108. package/web/{chunk-0hvxb5d5.js → chunk-gkmaryr4.js} +1 -1
  109. package/web/chunk-gnb09wmx.js +1 -0
  110. package/web/chunk-gx340asc.js +1 -0
  111. package/web/chunk-h0c42zy3.js +1 -0
  112. package/web/chunk-h24ybwp6.js +1 -0
  113. package/web/{chunk-m24yb8md.js → chunk-h754ntg7.js} +1 -1
  114. package/web/{chunk-3b4wqmnh.js → chunk-hn8m1vsg.js} +7 -7
  115. package/web/{chunk-2f2agfpj.js → chunk-hqxc9m07.js} +7 -7
  116. package/web/chunk-hrgqc1vr.js +1 -0
  117. package/web/{chunk-793m5jjh.js → chunk-hva7xyne.js} +2 -2
  118. package/web/{chunk-yrh86m0n.js → chunk-hxbfkdjd.js} +1 -1
  119. package/web/chunk-j9c8fa82.js +1 -0
  120. package/web/{chunk-4gc663j0.js → chunk-jeafmjsm.js} +1 -1
  121. package/web/chunk-jyf7a7yp.js +2 -0
  122. package/web/chunk-jz5mmp64.js +1 -0
  123. package/web/{chunk-s0xy00v5.js → chunk-k0cg4n2k.js} +2 -2
  124. package/web/{chunk-g31dbnzm.js → chunk-k4dnjf8n.js} +4 -4
  125. package/web/{chunk-59nk506k.js → chunk-kerfb21g.js} +1 -1
  126. package/web/chunk-m0136xav.js +1 -0
  127. package/web/chunk-m6vyvgm5.js +1 -0
  128. package/web/{chunk-0y971zgq.js → chunk-mxkbmgcv.js} +2 -2
  129. package/web/{chunk-0fy590s0.js → chunk-my0ec787.js} +1 -1
  130. package/web/chunk-mzzaet63.js +1 -0
  131. package/web/{chunk-xjc5fmcr.js → chunk-n9v14vyd.js} +18 -18
  132. package/web/{chunk-cpshsp24.js → chunk-ncfzmf2g.js} +1 -1
  133. package/web/chunk-ny436sqg.js +1 -0
  134. package/web/chunk-ph75hddv.js +1 -0
  135. package/web/chunk-phdfyqaa.js +1 -0
  136. package/web/chunk-phxa5krt.js +1 -0
  137. package/web/{chunk-b3j07x0n.js → chunk-pjpre6de.js} +2 -2
  138. package/web/chunk-q1zxvjhs.js +2 -0
  139. package/web/{chunk-n33753da.js → chunk-qdd3bx8q.js} +1 -1
  140. package/web/{chunk-ydtrc1ay.js → chunk-qh62nkem.js} +2 -2
  141. package/web/{chunk-05mvzx00.js → chunk-qp3tjhaq.js} +1 -1
  142. package/web/chunk-r4zbw4zj.js +2 -0
  143. package/web/{chunk-g4as4zzd.js → chunk-r6kk4vp1.js} +4 -4
  144. package/web/{chunk-ppjw1mps.js → chunk-rdr6wt22.js} +4 -4
  145. package/web/chunk-ry4ycah9.js +1 -0
  146. package/web/{chunk-47mbbmst.js → chunk-sdr5wa4z.js} +3 -3
  147. package/web/chunk-sqm16fat.js +1 -0
  148. package/web/{chunk-zv73g4qq.js → chunk-td83xf12.js} +2 -2
  149. package/web/chunk-tj1fn8v2.js +1 -0
  150. package/web/{chunk-q65zxczs.js → chunk-v0wtk059.js} +4 -4
  151. package/web/{chunk-enryqmj7.js → chunk-v1hfbjz9.js} +4 -4
  152. package/web/chunk-v1qt3gq4.js +1 -0
  153. package/web/{chunk-2tsxj613.js → chunk-v34mr9ky.js} +9 -9
  154. package/web/{chunk-tgkdyxbn.js → chunk-v854w9yn.js} +1 -1
  155. package/web/{chunk-dtrh40vr.js → chunk-ve56gxq0.js} +1 -1
  156. package/web/chunk-w573ym17.js +1 -0
  157. package/web/{chunk-9kkzmss7.js → chunk-w9gnqkez.js} +3 -3
  158. package/web/{chunk-kfbgvh0c.js → chunk-wqzbxzk3.js} +1 -1
  159. package/web/{chunk-hm8thq7c.js → chunk-wvrs986a.js} +2 -2
  160. package/web/chunk-x0mjydtp.js +1 -0
  161. package/web/{chunk-7dycbjxn.js → chunk-xpecre7w.js} +4 -4
  162. package/web/{chunk-zdhyq3ch.js → chunk-xvfeq8v2.js} +7 -7
  163. package/web/{chunk-2weaa3gn.js → chunk-y2rzeb4v.js} +2 -2
  164. package/web/{chunk-tggja45g.js → chunk-yf8ykk4v.js} +4 -4
  165. package/web/{chunk-gyhr27dm.js → chunk-yjs6jmdb.js} +1 -1
  166. package/web/{chunk-dsbyfvwz.js → chunk-ym7kv2hs.js} +1 -1
  167. package/web/chunk-zhybh04p.js +1 -0
  168. package/web/index.html +1 -1
  169. package/worker.js +1 -1
  170. package/chunk-7zkswxvk.js +0 -2
  171. package/chunk-m1eam0s5.js +0 -2
  172. package/chunk-zq32mwxj.js +0 -479
  173. package/web/chunk-32zmk3f5.js +0 -1
  174. package/web/chunk-3d3wnh8a.js +0 -2
  175. package/web/chunk-6cjm2yr7.js +0 -1
  176. package/web/chunk-7ycxz39p.js +0 -1
  177. package/web/chunk-9wr33d0t.js +0 -1
  178. package/web/chunk-a4tdrxdh.js +0 -1
  179. package/web/chunk-a9fvsyc1.js +0 -1
  180. package/web/chunk-apvbvg4d.js +0 -1
  181. package/web/chunk-bkxcc7v5.js +0 -1
  182. package/web/chunk-bve354k7.js +0 -1
  183. package/web/chunk-cwpxakby.js +0 -1
  184. package/web/chunk-jd7npyv9.js +0 -8
  185. package/web/chunk-jzz5htxp.js +0 -1
  186. package/web/chunk-ka3q31t1.js +0 -1
  187. package/web/chunk-kahab58k.js +0 -1139
  188. package/web/chunk-krgvx75q.js +0 -1
  189. package/web/chunk-m7k4wr3k.js +0 -1
  190. package/web/chunk-mdj3r75b.js +0 -1
  191. package/web/chunk-nbcpbqq4.js +0 -1
  192. package/web/chunk-p1yc8hwn.js +0 -2
  193. package/web/chunk-p29brxyt.js +0 -1
  194. package/web/chunk-p8fbes0t.js +0 -1
  195. package/web/chunk-r6q1301x.js +0 -1
  196. package/web/chunk-r8kghrkb.js +0 -1
  197. package/web/chunk-rhxn7mxg.js +0 -1
  198. package/web/chunk-svqshmpg.js +0 -1
  199. package/web/chunk-swzxq7r3.css +0 -1
  200. package/web/chunk-t18tn37m.js +0 -2
  201. package/web/chunk-tbsaseer.js +0 -1
  202. package/web/chunk-v0zfnvc1.js +0 -1
  203. package/web/chunk-vj31fs16.js +0 -1
  204. package/web/chunk-vr79r8vh.js +0 -1
  205. package/web/chunk-wb9tax0m.js +0 -1
  206. package/web/chunk-x9eghjjd.js +0 -1
  207. package/web/chunk-z3ky5ews.js +0 -2
@@ -1,2 +1,2 @@
1
- function Pn(i,d){let e;if(d===void 0){for(let n of i)if(n!=null&&(e<n||e===void 0&&n>=n))e=n}else{let n=-1;for(let f of i)if((f=d(f,++n,i))!=null&&(e<f||e===void 0&&f>=f))e=f}return e}function mn(i,d){let e;if(d===void 0){for(let n of i)if(n!=null&&(e>n||e===void 0&&n>=n))e=n}else{let n=-1;for(let f of i)if((f=d(f,++n,i))!=null&&(e>f||e===void 0&&f>=f))e=f}return e}
2
- export{Pn,mn};
1
+ function $n(i,d){let e;if(d===void 0){for(let n of i)if(n!=null&&(e<n||e===void 0&&n>=n))e=n}else{let n=-1;for(let f of i)if((f=d(f,++n,i))!=null&&(e<f||e===void 0&&f>=f))e=f}return e}function hn(i,d){let e;if(d===void 0){for(let n of i)if(n!=null&&(e>n||e===void 0&&n>=n))e=n}else{let n=-1;for(let f of i)if((f=d(f,++n,i))!=null&&(e>f||e===void 0&&f>=f))e=f}return e}
2
+ export{$n,hn};
@@ -1,4 +1,4 @@
1
- import{G}from"./chunk-p1yc8hwn.js";import{t,a,M,x,O,yt,C,S,E,T,A,L,R,l,p,V,Vi,An,rt,U,ze,Le}from"./chunk-e763h2px.js";import{Q}from"./chunk-xjc5fmcr.js";import{ht,gr}from"./chunk-3b4wqmnh.js";import{Se,Te}from"./chunk-kahab58k.js";var ft=Te(function(it,st){(function(i,s){if(typeof it==="object"&&typeof st==="object")st.exports=s(gr());else if(typeof define==="function"&&define.amd)define(["cose-base"],s);else if(typeof it==="object")it.cytoscapeFcose=s(gr());else i.cytoscapeFcose=s(i.coseBase)})(it,function(e){return(()=>{var i={658:(N)=>{N.exports=Object.assign!=null?Object.assign.bind(Object):function(B){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 B[d]=y[d]})}),B}},548:(N,B,v)=>{var b=function(){function d(f,u){var g=[],r=!0,_=!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(k){_=!0,F=k}finally{try{if(!r&&o.return)o.return()}finally{if(_)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,_){if(typeof r==="number")r=_;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,_=new Set,F=[],o=void 0,h=void 0,k=void 0,n=!1,P=1,X=[],D=[],j=function(){var I=d.collection();D.push(I);var H=u[0],J=d.collection();J.merge(H).merge(H.descendants().intersection(f)),F.push(H),J.forEach(function(re){r.push(re),_.add(re),I.merge(re)});var Z=function(){H=r.shift();var ue=d.collection();H.neighborhood().nodes().forEach(function(q){if(f.intersection(H.edgesWith(q)).length>0)ue.merge(q)});for(var Ce=0;Ce<ue.length;Ce++){var $e=ue[Ce];if(o=u.intersection($e.union($e.ancestors())),o!=null&&!_.has(o[0])){var de=o.union(o.descendants());de.forEach(function(q){if(r.push(q),_.add(q),I.merge(q),u.has(q))F.push(q)})}}};while(r.length!=0)Z();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],k=h.connectedEdges().length,F.forEach(function(re){if(re.connectedEdges().length<k)k=re.connectedEdges().length,h=re}),X.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 j();while(!n);if(g){if(X.length>0)g.set("dummy"+(g.size+1),X)}return D},y.relocateComponent=function(d,f,u){if(!u.fixedNodeConstraint){var{POSITIVE_INFINITY:g,NEGATIVE_INFINITY:r,POSITIVE_INFINITY:_,NEGATIVE_INFINITY:F}=Number;if(u.quality=="draft"){var o=!0,h=!1,k=void 0;try{for(var n=f.nodeIndexes[Symbol.iterator](),P;!(o=(P=n.next()).done);o=!0){var X=P.value,D=b(X,2),j=D[0],Y=D[1],I=u.cy.getElementById(j);if(I){var H=I.boundingBox(),J=f.xCoords[Y]-H.w/2,Z=f.xCoords[Y]+H.w/2,se=f.yCoords[Y]-H.h/2,re=f.yCoords[Y]+H.h/2;if(J<g)g=J;if(Z>r)r=Z;if(se<_)_=se;if(re>F)F=re}}}catch(q){h=!0,k=q}finally{try{if(!o&&n.return)n.return()}finally{if(h)throw k}}var ue=d.x-(r+g)/2,Ce=d.y-(F+_)/2;f.xCoords=f.xCoords.map(function(q){return q+ue}),f.yCoords=f.yCoords.map(function(q){return q+Ce})}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<_)_=De;if(xe>F)F=xe});var $e=d.x-(r+g)/2,de=d.y-(F+_)/2;Object.keys(f).forEach(function(q){var oe=f[q];oe.setCenter(oe.getCenterX()+$e,oe.getCenterY()+de)})}}},y.calcBoundingBox=function(d,f,u,g){var{MAX_SAFE_INTEGER:r,MIN_SAFE_INTEGER:_,MAX_SAFE_INTEGER:F,MIN_SAFE_INTEGER:o}=Number,h=void 0,k=void 0,n=void 0,P=void 0,X=d.descendants().not(":parent"),D=X.length;for(var j=0;j<D;j++){var Y=X[j];if(h=f[g.get(Y.id())]-Y.width()/2,k=f[g.get(Y.id())]+Y.width()/2,n=u[g.get(Y.id())]-Y.height()/2,P=u[g.get(Y.id())]+Y.height()/2,r>h)r=h;if(_<k)_=k;if(F>n)F=n;if(o<P)o=P}var I={};return I.topLeftX=r,I.topLeftY=F,I.width=_-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(_){if(_.css("display")!="none")r=!0}),!r)u.merge(g)}),u},N.exports=y},816:(N,B,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,_=function(o,h){var{cy:k,eles:n}=o,P=n.nodes(),X=n.edges(),D=void 0,j=void 0,Y=void 0,I={};if(o.randomize)D=h.nodeIndexes,j=h.xCoords,Y=h.yCoords;var H=function(q){return typeof q==="function"},J=function(q,oe){if(H(q))return q(oe);else return q},Z=b.calcParentsWithoutChildren(k,n),se=function de(q,oe,Ne,ke){var De=oe.length;for(var xe=0;xe<De;xe++){var W=oe[xe],Ae=null;if(W.intersection(Z).length==0)Ae=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(j[D.get(W.id())]-ve.w/2,Y[D.get(W.id())]-ve.h/2),new f(parseFloat(ve.w),parseFloat(ve.h))));else{var Me=b.calcBoundingBox(W,j,Y,D);if(W.intersection(Z).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=J(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(Ae!=null&&Ae.length>0){var Ge=void 0;Ge=Ne.getGraphManager().add(Ne.newGraph(),ie),de(Ge,Ae,Ne,ke)}}},re=function(q,oe,Ne){var ke=0,De=0;for(var xe=0;xe<Ne.length;xe++){var W=Ne[xe],Ae=I[W.data("source")],ie=I[W.data("target")];if(Ae&&ie&&Ae!==ie&&Ae.getEdgesBetween(ie).length==0){var ve=oe.add(q.newEdge(),Ae,ie);ve.id=W.id(),ve.idealLength=J(o.idealEdgeLength,W),ve.edgeElasticity=J(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(!H(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 Ce=new c,$e=Ce.newGraphManager();return se($e.addRoot(),b.getTopMostNodes(P),Ce,o),re(Ce,$e,X),ue(Ce,o),Ce.runLayout(),I};N.exports={coseLayout:_}},212:(N,B,v)=>{var b=function(){function o(h,k){for(var n=0;n<k.length;n++){var P=k[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,k,n){if(k)o(h.prototype,k);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,_=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({},_,h)}return b(o,[{key:"run",value:function(){var k=this,n=this.options,{cy:P,eles:X}=n,D=[],j=void 0,Y=void 0,I=[],H=void 0,J=[];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 Z=n.fixedNodeConstraint||n.alignmentConstraint||n.relativePlacementConstraint;if(Z)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(X.nodes().length>0)if(!re){var ue=n.eles.boundingBox();if(J.push({x:ue.x1+ue.w/2,y:ue.y1+ue.h/2}),n.randomize){var Ce=u(n);D.push(Ce)}if(n.quality=="default"||n.quality=="proof")I.push(r(n,D[0])),d.relocateComponent(J[0],I[0],n);else d.relocateComponent(J[0],D[0],n)}else{var $e=d.getTopMostNodes(n.eles.nodes());if(H=d.connectComponents(P,n.eles,$e),H.forEach(function(K){var z=K.boundingBox();J.push({x:z.x1+z.w/2,y:z.y1+z.h/2})}),n.randomize)H.forEach(function(K){n.eles=K,D.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(H.forEach(function(K,z){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(z)}),de.length>1){var W=de.boundingBox();J.push({x:W.x1+W.w/2,y:W.y1+W.h/2}),H.push(de),D.push(De);for(var Ae=xe.length-1;Ae>=0;Ae--)H.splice(xe[Ae],1),D.splice(xe[Ae],1),J.splice(xe[Ae],1)}}H.forEach(function(K,z){n.eles=K,I.push(r(n,D[z])),d.relocateComponent(J[z],I[z],n)})}else H.forEach(function(K,z){d.relocateComponent(J[z],D[z],n)});var ie=new Set;if(H.length>1){var ve=[],Me=X.filter(function(K){return K.css("display")=="none"});H.forEach(function(K,z){var pe=void 0;if(n.quality=="draft")pe=D[z].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:D[z].xCoords[me]-fe.boundingbox().w/2,y:D[z].yCoords[me]-fe.boundingbox().h/2,width:fe.boundingbox().w,height:fe.boundingbox().h});else{var he=d.calcBoundingBox(fe,D[z].xCoords,D[z].yCoords,pe);le.nodes.push({x:he.topLeftX,y:he.topLeftY,width:he.width,height:he.height})}else if(I[z][fe.id()])le.nodes.push({x:I[z][fe.id()].getLeft(),y:I[z][fe.id()].getTop(),width:I[z][fe.id()].getWidth(),height:I[z][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()),Pe=[],Ye=[];if(he.isParent()){var We=d.calcBoundingBox(he,D[z].xCoords,D[z].yCoords,pe);Pe.push(We.topLeftX+We.width/2),Pe.push(We.topLeftY+We.height/2)}else Pe.push(D[z].xCoords[Be]),Pe.push(D[z].yCoords[Be]);if(Ee.isParent()){var Je=d.calcBoundingBox(Ee,D[z].xCoords,D[z].yCoords,pe);Ye.push(Je.topLeftX+Je.width/2),Ye.push(Je.topLeftY+Je.height/2)}else Ye.push(D[z].xCoords[et]),Ye.push(D[z].yCoords[et]);le.edges.push({startX:Pe[0],startY:Pe[1],endX:Ye[0],endY:Ye[1]})}else if(I[z][he.id()]&&I[z][Ee.id()])le.edges.push({startX:I[z][he.id()].getCenterX(),startY:I[z][he.id()].getCenterY(),endX:I[z][Ee.id()].getCenterX(),endY:I[z][Ee.id()].getCenterY()})}}),le.nodes.length>0)ve.push(le),ie.add(z)}});var Ge=se.packComponents(ve,n.randomize).shifts;if(n.quality=="draft")D.forEach(function(K,z){var pe=K.xCoords.map(function(me){return me+Ge[z].dx}),le=K.yCoords.map(function(me){return me+Ge[z].dy});K.xCoords=pe,K.yCoords=le});else{var Ke=0;ie.forEach(function(K){Object.keys(I[K]).forEach(function(z){var pe=I[K][z];pe.setCenter(pe.getCenterX()+Ge[Ke].dx,pe.getCenterY()+Ge[Ke].dy)}),Ke++})}}}var je=function(z,pe){if(n.quality=="default"||n.quality=="proof"){if(typeof z==="number")z=pe;var le=void 0,me=void 0,fe=z.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:z.position("x"),y:z.position("y")};return{x:le.x,y:le.y}}else{var he=void 0;if(D.forEach(function(Ee){var Be=Ee.nodeIndexes.get(z.id());if(Be!=null)he={x:Ee.xCoords[Be],y:Ee.yCoords[Be]}}),he==null)he={x:z.position("x"),y:z.position("y")};return{x:he.x,y:he.y}}};if(n.quality=="default"||n.quality=="proof"||n.randomize){var at=d.calcParentsWithoutChildren(P,X),qe=X.filter(function(K){return K.css("display")=="none"});if(n.eles=X.not(qe),X.nodes().not(":parent").not(qe).layoutPositions(k,n,je),at.length>0)at.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}();N.exports=F},657:(N,B,v)=>{var b=v(548),c=v(140).layoutBase.Matrix,y=v(140).layoutBase.SVD,d=function(u){var{cy:g,eles:r}=u,_=r.nodes(),F=r.nodes(":parent"),o=new Map,h=new Map,k=new Map,n=[],P=[],X=[],D=[],j=[],Y=[],I=[],H=[],J=void 0,Z=void 0,se=1e8,re=0.000000001,{piTol:ue,samplingType:Ce,nodeSeparation:$e}=u,de=void 0,q=function(){var ee=0,te=0,ne=!1;while(te<de){ee=Math.floor(Math.random()*Z),ne=!1;for(var ae=0;ae<te;ae++)if(D[ae]==ee){ne=!0;break}if(!ne)D[te]=ee,te++;else continue}},oe=function(ee,te,ne){var ae=[],we=0,ge=0,ce=0,Ie=void 0,be=[],Fe=0,_e=1;for(var Ue=0;Ue<Z;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;Y[ce][te]=be[ce]*$e}if(ne){for(var Oe=0;Oe<Z;Oe++)if(Y[Oe][te]<j[Oe])j[Oe]=Y[Oe][te];for(var tt=0;tt<Z;tt++)if(j[tt]>Fe)Fe=j[tt],_e=tt}return _e},Ne=function(ee){var te=void 0;if(!ee){q();for(var ne=0;ne<de;ne++)oe(D[ne],ne,ee,!1)}else{te=Math.floor(Math.random()*Z),J=te;for(var ae=0;ae<Z;ae++)j[ae]=se;for(var we=0;we<de;we++)D[we]=te,te=oe(te,we,ee)}for(var ge=0;ge<Z;ge++)for(var ce=0;ce<de;ce++)Y[ge][ce]*=Y[ge][ce];for(var Ie=0;Ie<de;Ie++)I[Ie]=[];for(var be=0;be<de;be++)for(var Fe=0;Fe<de;Fe++)I[be][Fe]=Y[D[Fe]][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]))}H=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<Z;ce++)ne[ce]=Math.random(),ae[ce]=Math.random();ne=c.normalize(ne),ae=c.normalize(ae);var Ie=0,be=re,Fe=re,_e=void 0;while(!0){Ie++;for(var Ue=0;Ue<Z;Ue++)we[Ue]=ne[Ue];if(ne=c.multGamma(c.multL(c.multGamma(we),Y,H)),ee=c.dotProduct(we,ne),ne=c.normalize(ne),be=c.dotProduct(we,ne),_e=Math.abs(be/Fe),_e<=1+ue&&_e>=1)break;Fe=be}for(var Xe=0;Xe<Z;Xe++)we[Xe]=ne[Xe];Ie=0,Fe=re;while(!0){Ie++;for(var He=0;He<Z;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,H)),te=c.dotProduct(ge,ae),ae=c.normalize(ae),be=c.dotProduct(ge,ae),_e=Math.abs(be/Fe),_e<=1+ue&&_e>=1)break;Fe=be}for(var Oe=0;Oe<Z;Oe++)ge[Oe]=ae[Oe];P=c.multCons(we,Math.sqrt(Math.abs(ee))),X=c.multCons(ge,Math.sqrt(Math.abs(te)))};b.connectComponents(g,r,b.getTopMostNodes(_),o),F.forEach(function(ye){b.connectComponents(g,r,b.getTopMostNodes(ye.descendants().intersection(r)),o)});var xe=0;for(var W=0;W<_.length;W++)if(!_[W].isParent())h.set(_[W].id(),xe++);var Ae=!0,ie=!1,ve=void 0;try{for(var Me=o.keys()[Symbol.iterator](),Ge;!(Ae=(Ge=Me.next()).done);Ae=!0){var Ke=Ge.value;h.set(Ke,xe++)}}catch(ye){ie=!0,ve=ye}finally{try{if(!Ae&&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}),k.set(ye.id(),ee.nodes(":childless")[te].id())}),_.forEach(function(ye){var ee=void 0;if(ye.isParent())ee=h.get(k.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(k.get(te.id()));else n[ee].push(te.id())})});var at=function(ee){var te=h.get(ee),ne=void 0;o.get(ee).forEach(function(ae){if(g.getElementById(ae).isParent())ne=k.get(ae);else ne=ae;n[te].push(ne),n[h.get(ne)].push(ee)})},qe=!0,K=!1,z=void 0;try{for(var pe=o.keys()[Symbol.iterator](),le;!(qe=(le=pe.next()).done);qe=!0){var me=le.value;at(me)}}catch(ye){K=!0,z=ye}finally{try{if(!qe&&pe.return)pe.return()}finally{if(K)throw z}}Z=h.size;var fe=void 0;if(Z>2){de=Z<u.sampleSize?Z:u.sampleSize;for(var he=0;he<Z;he++)Y[he]=[];for(var Ee=0;Ee<de;Ee++)H[Ee]=[];if(u.quality=="draft"||u.step=="all")Ne(Ce),ke(),De(),fe={nodeIndexes:h,xCoords:P,yCoords:X};else h.forEach(function(ye,ee){P.push(g.getElementById(ee).position("x")),X.push(g.getElementById(ee).position("y"))}),fe={nodeIndexes:h,xCoords:P,yCoords:X};return fe}else{var Be=h.keys(),et=g.getElementById(Be.next().value),Pe=et.position(),Ye=et.outerWidth();if(P.push(Pe.x),X.push(Pe.y),Z==2){var We=g.getElementById(Be.next().value),Je=We.outerWidth();P.push(Pe.x+Ye/2+Je/2+u.idealEdgeLength),X.push(Pe.y)}return fe={nodeIndexes:h,xCoords:P,yCoords:X},fe}};N.exports={spectralLayout:d}},579:(N,B,v)=>{var b=v(212),c=function(d){if(!d)return;d("layout","fcose",b)};if(typeof cytoscape<"u")c(cytoscape);N.exports=c},140:(N)=>{N.exports=e}},s={};function w(N){var B=s[N];if(B!==void 0)return B.exports;var v=s[N]={exports:{}};return i[N](v,v.exports,w),v.exports}var m=w(579);return m})()})});var xt=Se(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=M.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:N,lhsGroup:B,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(B&&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:B,rhsId:i,rhsDir:w,rhsInto:N,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[B,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===B){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(B,b)}let s=new Set,w=new Set(i.keys()),m=t((B)=>{let v=new Map([[B,[0,0]]]),b=[B];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"),N=[];while(w.size>0){let B=w.values().next().value;N.push(m(B))}this.dataStructures={adjList:i,spatialMaps:N,groupAlignments:e}}return this.dataStructures}setElementForId(e,i){this.elements.set(e,i)}getElementById(e){return this.elements.get(e)}getConfig(){return U({...Gt,...x().architecture})}getConfigField(e){return this.getConfig()[e]}},zt=t((e,i)=>{G(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 Q("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-jyf7a7yp.js";import{t,a,M,x,O,gt,C,S,E,T,A,L,R,l,p,V,Vi,Ln,at,U,Fe,Le}from"./chunk-b5zf1hs3.js";import{Q}from"./chunk-n9v14vyd.js";import{ft,yr}from"./chunk-hn8m1vsg.js";import{Ce,Se}from"./chunk-3k9h7a73.js";var ut=Se(function(rt,st){(function(i,s){if(typeof rt==="object"&&typeof st==="object")st.exports=s(yr());else if(typeof define==="function"&&define.amd)define(["cose-base"],s);else if(typeof rt==="object")rt.cytoscapeFcose=s(yr());else i.cytoscapeFcose=s(i.coseBase)})(rt,function(e){return(()=>{var i={658:(N)=>{N.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:(N,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(k){B=!0,F=k}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,k=void 0,n=!1,P=1,X=[],D=[],j=function(){var I=d.collection();D.push(I);var Y=u[0],J=d.collection();J.merge(Y).merge(Y.descendants().intersection(f)),F.push(Y),J.forEach(function(re){r.push(re),B.add(re),I.merge(re)});var Z=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)Z();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],k=h.connectedEdges().length,F.forEach(function(re){if(re.connectedEdges().length<k)k=re.connectedEdges().length,h=re}),X.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 j();while(!n);if(g){if(X.length>0)g.set("dummy"+(g.size+1),X)}return D},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,k=void 0;try{for(var n=f.nodeIndexes[Symbol.iterator](),P;!(o=(P=n.next()).done);o=!0){var X=P.value,D=b(X,2),j=D[0],_=D[1],I=u.cy.getElementById(j);if(I){var Y=I.boundingBox(),J=f.xCoords[_]-Y.w/2,Z=f.xCoords[_]+Y.w/2,se=f.yCoords[_]-Y.h/2,re=f.yCoords[_]+Y.h/2;if(J<g)g=J;if(Z>r)r=Z;if(se<B)B=se;if(re>F)F=re}}}catch(q){h=!0,k=q}finally{try{if(!o&&n.return)n.return()}finally{if(h)throw k}}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,k=void 0,n=void 0,P=void 0,X=d.descendants().not(":parent"),D=X.length;for(var j=0;j<D;j++){var _=X[j];if(h=f[g.get(_.id())]-_.width()/2,k=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<k)B=k;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},N.exports=y},816:(N,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:k,eles:n}=o,P=n.nodes(),X=n.edges(),D=void 0,j=void 0,_=void 0,I={};if(o.randomize)D=h.nodeIndexes,j=h.xCoords,_=h.yCoords;var Y=function(q){return typeof q==="function"},J=function(q,oe){if(Y(q))return q(oe);else return q},Z=b.calcParentsWithoutChildren(k,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(Z).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(j[D.get(W.id())]-ve.w/2,_[D.get(W.id())]-ve.h/2),new f(parseFloat(ve.w),parseFloat(ve.h))));else{var Me=b.calcBoundingBox(W,j,_,D);if(W.intersection(Z).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=J(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=J(o.idealEdgeLength,W),ve.edgeElasticity=J(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,X),ue(Ae,o),Ae.runLayout(),I};N.exports={coseLayout:B}},212:(N,z,v)=>{var b=function(){function o(h,k){for(var n=0;n<k.length;n++){var P=k[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,k,n){if(k)o(h.prototype,k);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 k=this,n=this.options,{cy:P,eles:X}=n,D=[],j=void 0,_=void 0,I=[],Y=void 0,J=[];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 Z=n.fixedNodeConstraint||n.alignmentConstraint||n.relativePlacementConstraint;if(Z)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(X.nodes().length>0)if(!re){var ue=n.eles.boundingBox();if(J.push({x:ue.x1+ue.w/2,y:ue.y1+ue.h/2}),n.randomize){var Ae=u(n);D.push(Ae)}if(n.quality=="default"||n.quality=="proof")I.push(r(n,D[0])),d.relocateComponent(J[0],I[0],n);else d.relocateComponent(J[0],D[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();J.push({x:G.x1+G.w/2,y:G.y1+G.h/2})}),n.randomize)Y.forEach(function(K){n.eles=K,D.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();J.push({x:W.x1+W.w/2,y:W.y1+W.h/2}),Y.push(de),D.push(De);for(var Te=xe.length-1;Te>=0;Te--)Y.splice(xe[Te],1),D.splice(xe[Te],1),J.splice(xe[Te],1)}}Y.forEach(function(K,G){n.eles=K,I.push(r(n,D[G])),d.relocateComponent(J[G],I[G],n)})}else Y.forEach(function(K,G){d.relocateComponent(J[G],D[G],n)});var ie=new Set;if(Y.length>1){var ve=[],Me=X.filter(function(K){return K.css("display")=="none"});Y.forEach(function(K,G){var pe=void 0;if(n.quality=="draft")pe=D[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:D[G].xCoords[me]-fe.boundingbox().w/2,y:D[G].yCoords[me]-fe.boundingbox().h/2,width:fe.boundingbox().w,height:fe.boundingbox().h});else{var he=d.calcBoundingBox(fe,D[G].xCoords,D[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,D[G].xCoords,D[G].yCoords,pe);Oe.push(We.topLeftX+We.width/2),Oe.push(We.topLeftY+We.height/2)}else Oe.push(D[G].xCoords[Be]),Oe.push(D[G].yCoords[Be]);if(Ee.isParent()){var Je=d.calcBoundingBox(Ee,D[G].xCoords,D[G].yCoords,pe);Ye.push(Je.topLeftX+Je.width/2),Ye.push(Je.topLeftY+Je.height/2)}else Ye.push(D[G].xCoords[et]),Ye.push(D[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")D.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(D.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,X),qe=X.filter(function(K){return K.css("display")=="none"});if(n.eles=X.not(qe),X.nodes().not(":parent").not(qe).layoutPositions(k,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}();N.exports=F},657:(N,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,k=new Map,n=[],P=[],X=[],D=[],j=[],_=[],I=[],Y=[],J=void 0,Z=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()*Z),ne=!1;for(var ae=0;ae<te;ae++)if(D[ae]==ee){ne=!0;break}if(!ne)D[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<Z;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<Z;Ge++)if(_[Ge][te]<j[Ge])j[Ge]=_[Ge][te];for(var tt=0;tt<Z;tt++)if(j[tt]>$e)$e=j[tt],_e=tt}return _e},Ne=function(ee){var te=void 0;if(!ee){q();for(var ne=0;ne<de;ne++)oe(D[ne],ne,ee,!1)}else{te=Math.floor(Math.random()*Z),J=te;for(var ae=0;ae<Z;ae++)j[ae]=se;for(var we=0;we<de;we++)D[we]=te,te=oe(te,we,ee)}for(var ge=0;ge<Z;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]=_[D[$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<Z;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<Z;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<Z;Xe++)we[Xe]=ne[Xe];Ie=0,$e=re;while(!0){Ie++;for(var He=0;He<Z;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<Z;Ge++)ge[Ge]=ae[Ge];P=c.multCons(we,Math.sqrt(Math.abs(ee))),X=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}),k.set(ye.id(),ee.nodes(":childless")[te].id())}),B.forEach(function(ye){var ee=void 0;if(ye.isParent())ee=h.get(k.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(k.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=k.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}}Z=h.size;var fe=void 0;if(Z>2){de=Z<u.sampleSize?Z:u.sampleSize;for(var he=0;he<Z;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:X};else h.forEach(function(ye,ee){P.push(g.getElementById(ee).position("x")),X.push(g.getElementById(ee).position("y"))}),fe={nodeIndexes:h,xCoords:P,yCoords:X};return fe}else{var Be=h.keys(),et=g.getElementById(Be.next().value),Oe=et.position(),Ye=et.outerWidth();if(P.push(Oe.x),X.push(Oe.y),Z==2){var We=g.getElementById(Be.next().value),Je=We.outerWidth();P.push(Oe.x+Ye/2+Je/2+u.idealEdgeLength),X.push(Oe.y)}return fe={nodeIndexes:h,xCoords:P,yCoords:X},fe}};N.exports={spectralLayout:d}},579:(N,z,v)=>{var b=v(212),c=function(d){if(!d)return;d("layout","fcose",b)};if(typeof cytoscape<"u")c(cytoscape);N.exports=c},140:(N)=>{N.exports=e}},s={};function w(N){var z=s[N];if(z!==void 0)return z.exports;var v=s[N]={exports:{}};return i[N](v,v.exports,w),v.exports}var m=w(579);return m})()})});var xt=Ce(ut(),1);var ht={L:"left",R:"right",T:"top",B:"bottom"},vt={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"),pt=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"),mt=t((e,i)=>{let[s,w]=[e,i].sort();return`${JSON.stringify(s)}-${JSON.stringify(w)}`},"architectureGroupAlignmentKey"),yt=t((e)=>e.data(),"edgeData"),Qe=t((e)=>e.data(),"nodeData"),Gt=M.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:N,lhsGroup:z,rhsGroup:v,title:b}){if(!pt(s))throw Error(`Invalid direction given for left hand side of edge ${e}--${i}. Expected (L,R,T,B) got ${String(s)}`);if(!pt(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:N,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(mt(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"),N=[];while(w.size>0){let z=w.values().next().value;N.push(m(z))}this.dataStructures={adjList:i,spatialMaps:N,groupAlignments:e}}return this.dataStructures}setElementForId(e,i){this.elements.set(e,i)}getElementById(e){return this.elements.get(e)}getConfig(){return U({...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 Q("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};
@@ -29,8 +29,8 @@ import{G}from"./chunk-p1yc8hwn.js";import{t,a,M,x,O,yt,C,S,E,T,A,L,R,l,p,V,Vi,An
29
29
  display: -webkit-box;
30
30
  -webkit-box-orient: vertical;
31
31
  }
32
- `,"getStyles"),_t=Bt;function ct(e,i){if(e===0)return i();let s=Math.random,w=e>>>0;Math.random=function(){w=w+1831565813>>>0;let m=w;return m=Math.imul(m^m>>>15,m|1),m^=m+Math.imul(m^m>>>7,m|61),((m^m>>>14)>>>0)/4294967296};try{return i()}finally{Math.random=s}}t(ct,"withSeededRandom");var Ze=t((e)=>`<g><rect width="80" height="80" style="fill: #087ebf; stroke-width: 0px;"/>${e}</g>`,"wrapIcon"),nt={prefix:"mermaid-architecture",height:80,width:80,icons:{database:{body:Ze('<path id="b" data-name="4" d="m20,57.86c0,3.94,8.95,7.14,20,7.14s20-3.2,20-7.14" style="fill: none; stroke: #fff; stroke-miterlimit: 10; stroke-width: 2px;"/><path id="c" data-name="3" d="m20,45.95c0,3.94,8.95,7.14,20,7.14s20-3.2,20-7.14" style="fill: none; stroke: #fff; stroke-miterlimit: 10; stroke-width: 2px;"/><path id="d" data-name="2" d="m20,34.05c0,3.94,8.95,7.14,20,7.14s20-3.2,20-7.14" style="fill: none; stroke: #fff; stroke-miterlimit: 10; stroke-width: 2px;"/><ellipse id="e" data-name="1" cx="40" cy="22.14" rx="20" ry="7.14" style="fill: none; stroke: #fff; stroke-miterlimit: 10; stroke-width: 2px;"/><line x1="20" y1="57.86" x2="20" y2="22.14" style="fill: none; stroke: #fff; stroke-miterlimit: 10; stroke-width: 2px;"/><line x1="60" y1="57.86" x2="60" y2="22.14" style="fill: none; stroke: #fff; stroke-miterlimit: 10; stroke-width: 2px;"/>')},server:{body:Ze('<rect x="17.5" y="17.5" width="45" height="45" rx="2" ry="2" style="fill: none; stroke: #fff; stroke-miterlimit: 10; stroke-width: 2px;"/><line x1="17.5" y1="32.5" x2="62.5" y2="32.5" style="fill: none; stroke: #fff; stroke-miterlimit: 10; stroke-width: 2px;"/><line x1="17.5" y1="47.5" x2="62.5" y2="47.5" style="fill: none; stroke: #fff; stroke-miterlimit: 10; stroke-width: 2px;"/><g><path d="m56.25,25c0,.27-.45.5-1,.5h-10.5c-.55,0-1-.23-1-.5s.45-.5,1-.5h10.5c.55,0,1,.23,1,.5Z" style="fill: #fff; stroke-width: 0px;"/><path d="m56.25,25c0,.27-.45.5-1,.5h-10.5c-.55,0-1-.23-1-.5s.45-.5,1-.5h10.5c.55,0,1,.23,1,.5Z" style="fill: none; stroke: #fff; stroke-miterlimit: 10;"/></g><g><path d="m56.25,40c0,.27-.45.5-1,.5h-10.5c-.55,0-1-.23-1-.5s.45-.5,1-.5h10.5c.55,0,1,.23,1,.5Z" style="fill: #fff; stroke-width: 0px;"/><path d="m56.25,40c0,.27-.45.5-1,.5h-10.5c-.55,0-1-.23-1-.5s.45-.5,1-.5h10.5c.55,0,1,.23,1,.5Z" style="fill: none; stroke: #fff; stroke-miterlimit: 10;"/></g><g><path d="m56.25,55c0,.27-.45.5-1,.5h-10.5c-.55,0-1-.23-1-.5s.45-.5,1-.5h10.5c.55,0,1,.23,1,.5Z" style="fill: #fff; stroke-width: 0px;"/><path d="m56.25,55c0,.27-.45.5-1,.5h-10.5c-.55,0-1-.23-1-.5s.45-.5,1-.5h10.5c.55,0,1,.23,1,.5Z" style="fill: none; stroke: #fff; stroke-miterlimit: 10;"/></g><g><circle cx="32.5" cy="25" r=".75" style="fill: #fff; stroke: #fff; stroke-miterlimit: 10;"/><circle cx="27.5" cy="25" r=".75" style="fill: #fff; stroke: #fff; stroke-miterlimit: 10;"/><circle cx="22.5" cy="25" r=".75" style="fill: #fff; stroke: #fff; stroke-miterlimit: 10;"/></g><g><circle cx="32.5" cy="40" r=".75" style="fill: #fff; stroke: #fff; stroke-miterlimit: 10;"/><circle cx="27.5" cy="40" r=".75" style="fill: #fff; stroke: #fff; stroke-miterlimit: 10;"/><circle cx="22.5" cy="40" r=".75" style="fill: #fff; stroke: #fff; stroke-miterlimit: 10;"/></g><g><circle cx="32.5" cy="55" r=".75" style="fill: #fff; stroke: #fff; stroke-miterlimit: 10;"/><circle cx="27.5" cy="55" r=".75" style="fill: #fff; stroke: #fff; stroke-miterlimit: 10;"/><circle cx="22.5" cy="55" r=".75" style="fill: #fff; stroke: #fff; stroke-miterlimit: 10;"/></g>')},disk:{body:Ze('<rect x="20" y="15" width="40" height="50" rx="1" ry="1" style="fill: none; stroke: #fff; stroke-miterlimit: 10; stroke-width: 2px;"/><ellipse cx="24" cy="19.17" rx=".8" ry=".83" style="fill: none; stroke: #fff; stroke-miterlimit: 10; stroke-width: 2px;"/><ellipse cx="56" cy="19.17" rx=".8" ry=".83" style="fill: none; stroke: #fff; stroke-miterlimit: 10; stroke-width: 2px;"/><ellipse cx="24" cy="60.83" rx=".8" ry=".83" style="fill: none; stroke: #fff; stroke-miterlimit: 10; stroke-width: 2px;"/><ellipse cx="56" cy="60.83" rx=".8" ry=".83" style="fill: none; stroke: #fff; stroke-miterlimit: 10; stroke-width: 2px;"/><ellipse cx="40" cy="33.75" rx="14" ry="14.58" style="fill: none; stroke: #fff; stroke-miterlimit: 10; stroke-width: 2px;"/><ellipse cx="40" cy="33.75" rx="4" ry="4.17" style="fill: #fff; stroke: #fff; stroke-miterlimit: 10; stroke-width: 2px;"/><path d="m37.51,42.52l-4.83,13.22c-.26.71-1.1,1.02-1.76.64l-4.18-2.42c-.66-.38-.81-1.26-.33-1.84l9.01-10.8c.88-1.05,2.56-.08,2.09,1.2Z" style="fill: #fff; stroke-width: 0px;"/>')},internet:{body:Ze('<circle cx="40" cy="40" r="22.5" style="fill: none; stroke: #fff; stroke-miterlimit: 10; stroke-width: 2px;"/><line x1="40" y1="17.5" x2="40" y2="62.5" style="fill: none; stroke: #fff; stroke-miterlimit: 10; stroke-width: 2px;"/><line x1="17.5" y1="40" x2="62.5" y2="40" style="fill: none; stroke: #fff; stroke-miterlimit: 10; stroke-width: 2px;"/><path d="m39.99,17.51c-15.28,11.1-15.28,33.88,0,44.98" style="fill: none; stroke: #fff; stroke-miterlimit: 10; stroke-width: 2px;"/><path d="m40.01,17.51c15.28,11.1,15.28,33.88,0,44.98" style="fill: none; stroke: #fff; stroke-miterlimit: 10; stroke-width: 2px;"/><line x1="19.75" y1="30.1" x2="60.25" y2="30.1" style="fill: none; stroke: #fff; stroke-miterlimit: 10; stroke-width: 2px;"/><line x1="19.75" y1="49.9" x2="60.25" y2="49.9" style="fill: none; stroke: #fff; stroke-miterlimit: 10; stroke-width: 2px;"/>')},cloud:{body:Ze('<path d="m65,47.5c0,2.76-2.24,5-5,5H20c-2.76,0-5-2.24-5-5,0-1.87,1.03-3.51,2.56-4.36-.04-.21-.06-.42-.06-.64,0-2.6,2.48-4.74,5.65-4.97,1.65-4.51,6.34-7.76,11.85-7.76.86,0,1.69.08,2.5.23,2.09-1.57,4.69-2.5,7.5-2.5,6.1,0,11.19,4.38,12.28,10.17,2.14.56,3.72,2.51,3.72,4.83,0,.03,0,.07-.01.1,2.29.46,4.01,2.48,4.01,4.9Z" style="fill: none; stroke: #fff; stroke-miterlimit: 10; stroke-width: 2px;"/>')},unknown:Vi,blank:{body:Ze("")}}},Yt=t(async function(e,i,s,w){let m=s.getConfigField("padding"),N=s.getConfigField("iconSize"),B=N/2,v=N/6,b=v/2;await Promise.all(i.edges().map(async(c)=>{let{source:y,sourceDir:d,sourceArrow:f,sourceGroup:u,target:g,targetDir:r,targetArrow:_,targetGroup:F,label:o}=mt(c),{x:h,y:k}=c[0].sourceEndpoint(),{x:n,y:P}=c[0].midpoint(),{x:X,y:D}=c[0].targetEndpoint(),j=m+4;if(u)if(Re(d))h+=d==="L"?-j:j;else k+=d==="T"?-j:j+18;if(F)if(Re(r))X+=r==="L"?-j:j;else D+=r==="T"?-j:j+18;if(!u&&s.getNode(y)?.type==="junction")if(Re(d))h+=d==="L"?B:-B;else k+=d==="T"?B:-B;if(!F&&s.getNode(g)?.type==="junction")if(Re(r))X+=r==="L"?B:-B;else D+=r==="T"?B:-B;if(c[0]._private.rscratch){let Y=e.insert("g");if(Y.insert("path").attr("d",`M ${h},${k} L ${n},${P} L${X},${D} `).attr("class","edge").attr("id",`${w}-${ze(y,g,{prefix:"L"})}`),f){let I=Re(d)?ot[d](h,v):h-b,H=Ve(d)?ot[d](k,v):k-b;Y.insert("polygon").attr("points",gt[d](v)).attr("transform",`translate(${I},${H})`).attr("class","arrow")}if(_){let I=Re(r)?ot[r](X,v):X-b,H=Ve(r)?ot[r](D,v):D-b;Y.insert("polygon").attr("points",gt[r](v)).attr("transform",`translate(${I},${H})`).attr("class","arrow")}if(o){let I=!dt(d,r)?Re(d)?"X":"Y":"XY",H=0;if(I==="X")H=Math.abs(h-X);else if(I==="Y")H=Math.abs(k-D)/1.5;else H=Math.abs(h-X)/2;let J=Y.append("g");if(await Le(J,o,{useHtmlLabels:!1,width:H,classes:"architecture-service-label"},l()),J.attr("dy","1em").attr("alignment-baseline","middle").attr("dominant-baseline","middle").attr("text-anchor","middle"),I==="X")J.attr("transform","translate("+n+", "+P+")");else if(I==="Y")J.attr("transform","translate("+n+", "+P+") rotate(-90)");else if(I==="XY"){let Z=lt(d,r);if(Z&&Dt(Z)){let se=J.node().getBoundingClientRect(),[re,ue]=Ft(Z);J.attr("dominant-baseline","auto").attr("transform",`rotate(${-1*re*ue*45})`);let Ce=J.node().getBoundingClientRect();J.attr("transform",`
32
+ `,"getStyles"),_t=Bt;function ct(e,i){if(e===0)return i();let s=Math.random,w=e>>>0;Math.random=function(){w=w+1831565813>>>0;let m=w;return m=Math.imul(m^m>>>15,m|1),m^=m+Math.imul(m^m>>>7,m|61),((m^m>>>14)>>>0)/4294967296};try{return i()}finally{Math.random=s}}t(ct,"withSeededRandom");var Ze=t((e)=>`<g><rect width="80" height="80" style="fill: #087ebf; stroke-width: 0px;"/>${e}</g>`,"wrapIcon"),it={prefix:"mermaid-architecture",height:80,width:80,icons:{database:{body:Ze('<path id="b" data-name="4" d="m20,57.86c0,3.94,8.95,7.14,20,7.14s20-3.2,20-7.14" style="fill: none; stroke: #fff; stroke-miterlimit: 10; stroke-width: 2px;"/><path id="c" data-name="3" d="m20,45.95c0,3.94,8.95,7.14,20,7.14s20-3.2,20-7.14" style="fill: none; stroke: #fff; stroke-miterlimit: 10; stroke-width: 2px;"/><path id="d" data-name="2" d="m20,34.05c0,3.94,8.95,7.14,20,7.14s20-3.2,20-7.14" style="fill: none; stroke: #fff; stroke-miterlimit: 10; stroke-width: 2px;"/><ellipse id="e" data-name="1" cx="40" cy="22.14" rx="20" ry="7.14" style="fill: none; stroke: #fff; stroke-miterlimit: 10; stroke-width: 2px;"/><line x1="20" y1="57.86" x2="20" y2="22.14" style="fill: none; stroke: #fff; stroke-miterlimit: 10; stroke-width: 2px;"/><line x1="60" y1="57.86" x2="60" y2="22.14" style="fill: none; stroke: #fff; stroke-miterlimit: 10; stroke-width: 2px;"/>')},server:{body:Ze('<rect x="17.5" y="17.5" width="45" height="45" rx="2" ry="2" style="fill: none; stroke: #fff; stroke-miterlimit: 10; stroke-width: 2px;"/><line x1="17.5" y1="32.5" x2="62.5" y2="32.5" style="fill: none; stroke: #fff; stroke-miterlimit: 10; stroke-width: 2px;"/><line x1="17.5" y1="47.5" x2="62.5" y2="47.5" style="fill: none; stroke: #fff; stroke-miterlimit: 10; stroke-width: 2px;"/><g><path d="m56.25,25c0,.27-.45.5-1,.5h-10.5c-.55,0-1-.23-1-.5s.45-.5,1-.5h10.5c.55,0,1,.23,1,.5Z" style="fill: #fff; stroke-width: 0px;"/><path d="m56.25,25c0,.27-.45.5-1,.5h-10.5c-.55,0-1-.23-1-.5s.45-.5,1-.5h10.5c.55,0,1,.23,1,.5Z" style="fill: none; stroke: #fff; stroke-miterlimit: 10;"/></g><g><path d="m56.25,40c0,.27-.45.5-1,.5h-10.5c-.55,0-1-.23-1-.5s.45-.5,1-.5h10.5c.55,0,1,.23,1,.5Z" style="fill: #fff; stroke-width: 0px;"/><path d="m56.25,40c0,.27-.45.5-1,.5h-10.5c-.55,0-1-.23-1-.5s.45-.5,1-.5h10.5c.55,0,1,.23,1,.5Z" style="fill: none; stroke: #fff; stroke-miterlimit: 10;"/></g><g><path d="m56.25,55c0,.27-.45.5-1,.5h-10.5c-.55,0-1-.23-1-.5s.45-.5,1-.5h10.5c.55,0,1,.23,1,.5Z" style="fill: #fff; stroke-width: 0px;"/><path d="m56.25,55c0,.27-.45.5-1,.5h-10.5c-.55,0-1-.23-1-.5s.45-.5,1-.5h10.5c.55,0,1,.23,1,.5Z" style="fill: none; stroke: #fff; stroke-miterlimit: 10;"/></g><g><circle cx="32.5" cy="25" r=".75" style="fill: #fff; stroke: #fff; stroke-miterlimit: 10;"/><circle cx="27.5" cy="25" r=".75" style="fill: #fff; stroke: #fff; stroke-miterlimit: 10;"/><circle cx="22.5" cy="25" r=".75" style="fill: #fff; stroke: #fff; stroke-miterlimit: 10;"/></g><g><circle cx="32.5" cy="40" r=".75" style="fill: #fff; stroke: #fff; stroke-miterlimit: 10;"/><circle cx="27.5" cy="40" r=".75" style="fill: #fff; stroke: #fff; stroke-miterlimit: 10;"/><circle cx="22.5" cy="40" r=".75" style="fill: #fff; stroke: #fff; stroke-miterlimit: 10;"/></g><g><circle cx="32.5" cy="55" r=".75" style="fill: #fff; stroke: #fff; stroke-miterlimit: 10;"/><circle cx="27.5" cy="55" r=".75" style="fill: #fff; stroke: #fff; stroke-miterlimit: 10;"/><circle cx="22.5" cy="55" r=".75" style="fill: #fff; stroke: #fff; stroke-miterlimit: 10;"/></g>')},disk:{body:Ze('<rect x="20" y="15" width="40" height="50" rx="1" ry="1" style="fill: none; stroke: #fff; stroke-miterlimit: 10; stroke-width: 2px;"/><ellipse cx="24" cy="19.17" rx=".8" ry=".83" style="fill: none; stroke: #fff; stroke-miterlimit: 10; stroke-width: 2px;"/><ellipse cx="56" cy="19.17" rx=".8" ry=".83" style="fill: none; stroke: #fff; stroke-miterlimit: 10; stroke-width: 2px;"/><ellipse cx="24" cy="60.83" rx=".8" ry=".83" style="fill: none; stroke: #fff; stroke-miterlimit: 10; stroke-width: 2px;"/><ellipse cx="56" cy="60.83" rx=".8" ry=".83" style="fill: none; stroke: #fff; stroke-miterlimit: 10; stroke-width: 2px;"/><ellipse cx="40" cy="33.75" rx="14" ry="14.58" style="fill: none; stroke: #fff; stroke-miterlimit: 10; stroke-width: 2px;"/><ellipse cx="40" cy="33.75" rx="4" ry="4.17" style="fill: #fff; stroke: #fff; stroke-miterlimit: 10; stroke-width: 2px;"/><path d="m37.51,42.52l-4.83,13.22c-.26.71-1.1,1.02-1.76.64l-4.18-2.42c-.66-.38-.81-1.26-.33-1.84l9.01-10.8c.88-1.05,2.56-.08,2.09,1.2Z" style="fill: #fff; stroke-width: 0px;"/>')},internet:{body:Ze('<circle cx="40" cy="40" r="22.5" style="fill: none; stroke: #fff; stroke-miterlimit: 10; stroke-width: 2px;"/><line x1="40" y1="17.5" x2="40" y2="62.5" style="fill: none; stroke: #fff; stroke-miterlimit: 10; stroke-width: 2px;"/><line x1="17.5" y1="40" x2="62.5" y2="40" style="fill: none; stroke: #fff; stroke-miterlimit: 10; stroke-width: 2px;"/><path d="m39.99,17.51c-15.28,11.1-15.28,33.88,0,44.98" style="fill: none; stroke: #fff; stroke-miterlimit: 10; stroke-width: 2px;"/><path d="m40.01,17.51c15.28,11.1,15.28,33.88,0,44.98" style="fill: none; stroke: #fff; stroke-miterlimit: 10; stroke-width: 2px;"/><line x1="19.75" y1="30.1" x2="60.25" y2="30.1" style="fill: none; stroke: #fff; stroke-miterlimit: 10; stroke-width: 2px;"/><line x1="19.75" y1="49.9" x2="60.25" y2="49.9" style="fill: none; stroke: #fff; stroke-miterlimit: 10; stroke-width: 2px;"/>')},cloud:{body:Ze('<path d="m65,47.5c0,2.76-2.24,5-5,5H20c-2.76,0-5-2.24-5-5,0-1.87,1.03-3.51,2.56-4.36-.04-.21-.06-.42-.06-.64,0-2.6,2.48-4.74,5.65-4.97,1.65-4.51,6.34-7.76,11.85-7.76.86,0,1.69.08,2.5.23,2.09-1.57,4.69-2.5,7.5-2.5,6.1,0,11.19,4.38,12.28,10.17,2.14.56,3.72,2.51,3.72,4.83,0,.03,0,.07-.01.1,2.29.46,4.01,2.48,4.01,4.9Z" style="fill: none; stroke: #fff; stroke-miterlimit: 10; stroke-width: 2px;"/>')},unknown:Vi,blank:{body:Ze("")}}},Yt=t(async function(e,i,s,w){let m=s.getConfigField("padding"),N=s.getConfigField("iconSize"),z=N/2,v=N/6,b=v/2;await Promise.all(i.edges().map(async(c)=>{let{source:y,sourceDir:d,sourceArrow:f,sourceGroup:u,target:g,targetDir:r,targetArrow:B,targetGroup:F,label:o}=yt(c),{x:h,y:k}=c[0].sourceEndpoint(),{x:n,y:P}=c[0].midpoint(),{x:X,y:D}=c[0].targetEndpoint(),j=m+4;if(u)if(Re(d))h+=d==="L"?-j:j;else k+=d==="T"?-j:j+18;if(F)if(Re(r))X+=r==="L"?-j:j;else D+=r==="T"?-j:j+18;if(!u&&s.getNode(y)?.type==="junction")if(Re(d))h+=d==="L"?z:-z;else k+=d==="T"?z:-z;if(!F&&s.getNode(g)?.type==="junction")if(Re(r))X+=r==="L"?z:-z;else D+=r==="T"?z:-z;if(c[0]._private.rscratch){let _=e.insert("g");if(_.insert("path").attr("d",`M ${h},${k} L ${n},${P} L${X},${D} `).attr("class","edge").attr("id",`${w}-${Fe(y,g,{prefix:"L"})}`),f){let I=Re(d)?ot[d](h,v):h-b,Y=Ve(d)?ot[d](k,v):k-b;_.insert("polygon").attr("points",vt[d](v)).attr("transform",`translate(${I},${Y})`).attr("class","arrow")}if(B){let I=Re(r)?ot[r](X,v):X-b,Y=Ve(r)?ot[r](D,v):D-b;_.insert("polygon").attr("points",vt[r](v)).attr("transform",`translate(${I},${Y})`).attr("class","arrow")}if(o){let I=!dt(d,r)?Re(d)?"X":"Y":"XY",Y=0;if(I==="X")Y=Math.abs(h-X);else if(I==="Y")Y=Math.abs(k-D)/1.5;else Y=Math.abs(h-X)/2;let J=_.append("g");if(await Le(J,o,{useHtmlLabels:!1,width:Y,classes:"architecture-service-label"},l()),J.attr("dy","1em").attr("alignment-baseline","middle").attr("dominant-baseline","middle").attr("text-anchor","middle"),I==="X")J.attr("transform","translate("+n+", "+P+")");else if(I==="Y")J.attr("transform","translate("+n+", "+P+") rotate(-90)");else if(I==="XY"){let Z=lt(d,r);if(Z&&Dt(Z)){let se=J.node().getBoundingClientRect(),[re,ue]=Ft(Z);J.attr("dominant-baseline","auto").attr("transform",`rotate(${-1*re*ue*45})`);let Ae=J.node().getBoundingClientRect();J.attr("transform",`
33
33
  translate(${n}, ${P-se.height/2})
34
- translate(${re*Ce.width/2}, ${ue*Ce.height/2})
34
+ translate(${re*Ae.width/2}, ${ue*Ae.height/2})
35
35
  rotate(${-1*re*ue*45}, 0, ${se.height/2})
36
- `)}}}}}))},"drawEdges"),Ut=t(async function(e,i,s,w){let N=s.getConfigField("padding")*0.75,B=s.getConfigField("fontSize"),b=s.getConfigField("iconSize")/2;await Promise.all(i.nodes().map(async(c)=>{let y=Qe(c);if(y.type==="group"){let{h:d,w:f,x1:u,y1:g}=c.boundingBox(),r=e.append("rect");r.attr("id",`${w}-group-${y.id}`).attr("x",u+b).attr("y",g+b).attr("width",f).attr("height",d).attr("class","node-bkg");let _=e.append("g"),F=u,o=g;if(y.icon){let h=_.append("g");h.html(`<g>${await rt(y.icon,{height:N,width:N,fallbackPrefix:nt.prefix})}</g>`),h.attr("transform","translate("+(F+b+1)+", "+(o+b+1)+")"),F+=N,o+=B/2-1-2}if(y.label){let h=_.append("g");await Le(h,y.label,{useHtmlLabels:!1,width:f,classes:"architecture-service-label"},l()),h.attr("dy","1em").attr("alignment-baseline","middle").attr("dominant-baseline","start").attr("text-anchor","start"),h.attr("transform","translate("+(F+b+4)+", "+(o+b+2)+")")}s.setElementForId(y.id,r)}}))},"drawGroups"),Ht=t(async function(e,i,s,w){let m=l();for(let N of s){let B=i.append("g"),v=e.getConfigField("iconSize");if(N.title){let d=B.append("g");await Le(d,N.title,{useHtmlLabels:!1,width:v*1.5,classes:"architecture-service-label"},m),d.attr("dy","1em").attr("alignment-baseline","middle").attr("dominant-baseline","middle").attr("text-anchor","middle"),d.attr("transform","translate("+v/2+", "+v+")")}let b=B.append("g");if(N.icon)b.html(`<g>${await rt(N.icon,{height:v,width:v,fallbackPrefix:nt.prefix})}</g>`);else if(N.iconText){b.html(`<g>${await rt("blank",{height:v,width:v,fallbackPrefix:nt.prefix})}</g>`);let u=b.append("g").append("foreignObject").attr("width",v).attr("height",v).append("div").attr("class","node-icon-text").attr("style",`height: ${v}px;`).append("div").html(O(N.iconText,m)),g=parseInt(window.getComputedStyle(u.node(),null).getPropertyValue("font-size").replace(/\D/g,""))??16;u.attr("style",`-webkit-line-clamp: ${Math.floor((v-2)/g)};`)}else b.append("path").attr("class","node-bkg").attr("id",`${w}-node-${N.id}`).attr("d",`M0,${v} V5 Q0,0 5,0 H${v-5} Q${v},0 ${v},5 V${v} Z`);B.attr("id",`${w}-service-${N.id}`).attr("class","architecture-service");let{width:c,height:y}=B.node().getBBox();N.width=c,N.height=y,e.setElementForId(N.id,B)}return 0},"drawServices"),Vt=t(function(e,i,s,w){s.forEach((m)=>{let N=i.append("g"),B=e.getConfigField("iconSize");N.append("g").append("rect").attr("id",`${w}-node-${m.id}`).attr("fill-opacity","0").attr("width",B).attr("height",B),N.attr("class","architecture-junction");let{width:b,height:c}=N._groups[0][0].getBBox();N.width=b,N.height=c,e.setElementForId(m.id,N)})},"drawJunctions");An([{name:nt.prefix,icons:nt}]);ht.use(xt.default);function Tt(e,i,s){e.forEach((w)=>{i.add({group:"nodes",data:{type:"service",id:w.id,icon:w.icon,label:w.title,parent:w.in,width:s.getConfigField("iconSize"),height:s.getConfigField("iconSize")},classes:"node-service"})})}t(Tt,"addServices");function At(e,i,s){e.forEach((w)=>{i.add({group:"nodes",data:{type:"junction",id:w.id,parent:w.in,width:s.getConfigField("iconSize"),height:s.getConfigField("iconSize")},classes:"node-junction"})})}t(At,"addJunctions");function Lt(e,i){i.nodes().map((s)=>{let w=Qe(s);if(w.type==="group")return;w.x=s.position().x,w.y=s.position().y,e.getElementById(w.id).attr("transform","translate("+(w.x||0)+","+(w.y||0)+")")})}t(Lt,"positionNodes");function Ct(e,i){e.forEach((s)=>{i.add({group:"nodes",data:{type:"group",id:s.id,icon:s.icon,label:s.title,parent:s.in},classes:"node-group"})})}t(Ct,"addGroups");function It(e,i){e.forEach((s)=>{let{lhsId:w,rhsId:m,lhsInto:N,lhsGroup:B,rhsInto:v,lhsDir:b,rhsDir:c,rhsGroup:y,title:d}=s,f=dt(s.lhsDir,s.rhsDir)?"segments":"straight",u={id:`${w}-${m}`,label:d,source:w,sourceDir:b,sourceArrow:N,sourceGroup:B,sourceEndpoint:b==="L"?"0 50%":b==="R"?"100% 50%":b==="T"?"50% 0":"50% 100%",target:m,targetDir:c,targetArrow:v,targetGroup:y,targetEndpoint:c==="L"?"0 50%":c==="R"?"100% 50%":c==="T"?"50% 0":"50% 100%"};i.add({group:"edges",data:u,classes:f})})}t(It,"addEdges");function bt(e,i,s,w=[]){let m=t((f,u)=>{let g=new Map;for(let[r,_]of f.entries()){let F=`${r}`,o=0,h=[..._.entries()];if(h.length===1){g.set(F,h[0][1]);continue}for(let k=0;k<h.length-1;k++)for(let n=k+1;n<h.length;n++){let[P,X]=h[k],[D,j]=h[n];if(s.get(pt(P,D))===u)g.set(F,[...g.get(F)??[],...X,...j]);else if(P==="default"||D==="default")g.set(F,[...g.get(F)??[],...X,...j]);else{let I=`${F}-${o++}`;g.set(I,X);let H=`${F}-${o++}`;g.set(H,j)}}}return g},"flattenAlignments"),N=i.map((f)=>{let u=new Map,g=new Map;return f.forEach(([r,_],F)=>{let o=e.getNode(F)?.in??"default",h=u.get(_)??new Map;if(!u.has(_))u.set(_,h);let k=g.get(r)??new Map;if(!g.has(r))g.set(r,k);for(let n of[h,k]){let P=n.get(o)??[];if(!n.has(o))n.set(o,P);P.push(F)}}),{horiz:[...m(u,"horizontal").values()].filter((r)=>r.length>1),vert:[...m(g,"vertical").values()].filter((r)=>r.length>1)}}),[B,v]=N.reduce(([f,u],{horiz:g,vert:r})=>[[...f,...g],[...u,...r]],[[],[]]),b=new Set;w.forEach((f)=>f.members.forEach((u)=>b.add(u)));let c=t((f)=>f.filter((u)=>!u.some((g)=>b.has(g))),"dropOverlapping"),y=c(B),d=c(v);return w.forEach((f)=>{if(f.members.length<2)return;if(f.direction==="row")y.push([...f.members]);else d.push([...f.members])}),{horizontal:y,vertical:d}}t(bt,"getAlignments");function Nt(e,i,s=[]){let w=[],m=i.getConfigField("iconSize"),N=i.getConfigField("idealEdgeLengthMultiplier"),B=N*m,v=new Set;s.forEach((y)=>{for(let d=0;d<y.members.length-1;d++){let f=y.members[d],u=y.members[d+1];if(v.add(`${f}|${u}`),v.add(`${u}|${f}`),y.direction==="row")w.push({left:f,right:u,gap:B});else w.push({top:f,bottom:u,gap:B})}});let b=t((y)=>`${y[0]},${y[1]}`,"posToStr"),c=t((y)=>y.split(",").map((d)=>parseInt(d)),"strToPos");return e.forEach((y)=>{let d=new Map([...y.entries()].map(([r,_])=>[b(_),r])),f=[b([0,0])],u={},g={L:[-1,0],R:[1,0],T:[0,1],B:[0,-1]};while(f.length>0){let r=f.shift();if(r){u[r]=1;let _=d.get(r);if(_){let F=c(r);Object.entries(g).forEach(([o,h])=>{let k=b([F[0]+h[0],F[1]+h[1]]),n=d.get(k);if(n&&!u[k]){if(f.push(k),v.has(`${_}|${n}`))return;w.push({[ut[o]]:n,[ut[kt(o)]]:_,gap:N*m})}})}}}}),w}t(Nt,"getRelativeConstraints");function St(e,i,s,w,m,{spatialMaps:N,groupAlignments:B}){return new Promise((v)=>{let b=p("body").append("div").attr("id","cy").attr("style","display:none"),c=ht({container:document.getElementById("cy"),style:[{selector:"edge",style:{"curve-style":"straight","source-endpoint":"data(sourceEndpoint)","target-endpoint":"data(targetEndpoint)"}},{selector:"edge[label]",style:{label:"data(label)"}},{selector:"edge.segments",style:{"curve-style":"segments","segment-weights":"0","segment-distances":[0.5],"edge-distances":"endpoints","source-endpoint":"data(sourceEndpoint)","target-endpoint":"data(targetEndpoint)"}},{selector:"node",style:{"compound-sizing-wrt-labels":"include"}},{selector:"node[label]",style:{"text-valign":"bottom","text-halign":"center","font-size":`${m.getConfigField("fontSize")}px`}},{selector:".node-service",style:{label:"data(label)",width:"data(width)",height:"data(height)"}},{selector:".node-junction",style:{width:"data(width)",height:"data(height)"}},{selector:".node-group",style:{padding:`${m.getConfigField("padding")}px`}}],layout:{name:"grid",boundingBox:{x1:0,x2:100,y1:0,y2:100}}});b.remove(),Ct(s,c),Tt(e,c,m),At(i,c,m),It(w,c);let y=m.getLayoutHints(),d=bt(m,N,B,y),f=Nt(N,m,y),u=m.getConfigField("iconSize"),g=m.getConfigField("idealEdgeLengthMultiplier")*u,r=0.5*u,_=m.getConfigField("edgeElasticity"),F=m.getConfigField("seed"),o=c.layout({name:"fcose",quality:"proof",randomize:m.getConfigField("randomize"),nodeSeparation:m.getConfigField("nodeSeparation"),numIter:m.getConfigField("numIter"),styleEnabled:!1,animate:!1,nodeDimensionsIncludeLabels:!1,idealEdgeLength(h){let[k,n]=h.connectedNodes(),{parent:P}=Qe(k),{parent:X}=Qe(n);return P===X?g:r},edgeElasticity(h){let[k,n]=h.connectedNodes(),{parent:P}=Qe(k),{parent:X}=Qe(n);return P===X?_:0.001},alignmentConstraint:d,relativePlacementConstraint:f});o.one("layoutstop",()=>{function h(k,n,P,X){let D,j,{x:Y,y:I}=k,{x:H,y:J}=n;j=(X-I+(Y-P)*(I-J)/(Y-H))/Math.sqrt(1+Math.pow((I-J)/(Y-H),2)),D=Math.sqrt(Math.pow(X-I,2)+Math.pow(P-Y,2)-Math.pow(j,2));let Z=Math.sqrt(Math.pow(H-Y,2)+Math.pow(J-I,2));D=D/Z;let se=(H-Y)*(X-I)-(J-I)*(P-Y);switch(!0){case se>=0:se=1;break;case se<0:se=-1;break}let re=(H-Y)*(P-Y)+(J-I)*(X-I);switch(!0){case re>=0:re=1;break;case re<0:re=-1;break}return j=Math.abs(j)*se,D=D*re,{distances:j,weights:D}}t(h,"getSegmentWeights"),c.startBatch();for(let k of Object.values(c.edges()))if(k.data?.()){let{x:n,y:P}=k.source().position(),{x:X,y:D}=k.target().position();if(n!==X&&P!==D){let j=k.sourceEndpoint(),Y=k.targetEndpoint(),{sourceDir:I}=mt(k),[H,J]=Ve(I)?[j.x,Y.y]:[Y.x,j.y],{weights:Z,distances:se}=h(j,Y,H,J);k.style("segment-distances",se),k.style("segment-weights",Z)}}c.endBatch(),ct(F,()=>o.run())});try{ct(F,()=>o.run())}catch(h){if(h instanceof RangeError&&h.message.includes("Invalid array length"))throw Error("Architecture layout failed: a declared `align row|column` directive likely contradicts the edge directions, or two declared alignments overlap on a shared node. Check that the order of members in each `align` chain is consistent with the edges between them, and that no node appears in two `align` directives along the same axis.");throw h}c.ready((h)=>{a.info("Ready",h),v(c)})})}t(St,"layoutArchitecture");var Xt=t(async(e,i,s,w)=>{let m=w.db;m.setDiagramId(i);let N=m.getServices(),B=m.getJunctions(),v=m.getGroups(),b=m.getEdges(),c=m.getDataStructures(),y=V(i),d=y.append("g");d.attr("class","architecture-edges");let f=y.append("g");f.attr("class","architecture-services");let u=y.append("g");u.attr("class","architecture-groups"),await Ht(m,f,N,i),Vt(m,f,B,i);let g=await St(N,B,v,b,m,c);await Yt(d,g,m,i),await Ut(u,g,m,i),Lt(m,g),yt(void 0,y,m.getConfigField("padding"),m.getConfigField("useMaxWidth"))},"draw"),jt={draw:Xt},ar={parser:wt,get db(){return new Et},renderer:jt,styles:_t};export{ar as diagram};
36
+ `)}}}}}))},"drawEdges"),Ut=t(async function(e,i,s,w){let N=s.getConfigField("padding")*0.75,z=s.getConfigField("fontSize"),b=s.getConfigField("iconSize")/2;await Promise.all(i.nodes().map(async(c)=>{let y=Qe(c);if(y.type==="group"){let{h:d,w:f,x1:u,y1:g}=c.boundingBox(),r=e.append("rect");r.attr("id",`${w}-group-${y.id}`).attr("x",u+b).attr("y",g+b).attr("width",f).attr("height",d).attr("class","node-bkg");let B=e.append("g"),F=u,o=g;if(y.icon){let h=B.append("g");h.html(`<g>${await at(y.icon,{height:N,width:N,fallbackPrefix:it.prefix})}</g>`),h.attr("transform","translate("+(F+b+1)+", "+(o+b+1)+")"),F+=N,o+=z/2-1-2}if(y.label){let h=B.append("g");await Le(h,y.label,{useHtmlLabels:!1,width:f,classes:"architecture-service-label"},l()),h.attr("dy","1em").attr("alignment-baseline","middle").attr("dominant-baseline","start").attr("text-anchor","start"),h.attr("transform","translate("+(F+b+4)+", "+(o+b+2)+")")}s.setElementForId(y.id,r)}}))},"drawGroups"),Ht=t(async function(e,i,s,w){let m=l();for(let N of s){let z=i.append("g"),v=e.getConfigField("iconSize");if(N.title){let d=z.append("g");await Le(d,N.title,{useHtmlLabels:!1,width:v*1.5,classes:"architecture-service-label"},m),d.attr("dy","1em").attr("alignment-baseline","middle").attr("dominant-baseline","middle").attr("text-anchor","middle"),d.attr("transform","translate("+v/2+", "+v+")")}let b=z.append("g");if(N.icon)b.html(`<g>${await at(N.icon,{height:v,width:v,fallbackPrefix:it.prefix})}</g>`);else if(N.iconText){b.html(`<g>${await at("blank",{height:v,width:v,fallbackPrefix:it.prefix})}</g>`);let u=b.append("g").append("foreignObject").attr("width",v).attr("height",v).append("div").attr("class","node-icon-text").attr("style",`height: ${v}px;`).append("div").html(O(N.iconText,m)),g=parseInt(window.getComputedStyle(u.node(),null).getPropertyValue("font-size").replace(/\D/g,""))??16;u.attr("style",`-webkit-line-clamp: ${Math.floor((v-2)/g)};`)}else b.append("path").attr("class","node-bkg").attr("id",`${w}-node-${N.id}`).attr("d",`M0,${v} V5 Q0,0 5,0 H${v-5} Q${v},0 ${v},5 V${v} Z`);z.attr("id",`${w}-service-${N.id}`).attr("class","architecture-service");let{width:c,height:y}=z.node().getBBox();N.width=c,N.height=y,e.setElementForId(N.id,z)}return 0},"drawServices"),Vt=t(function(e,i,s,w){s.forEach((m)=>{let N=i.append("g"),z=e.getConfigField("iconSize");N.append("g").append("rect").attr("id",`${w}-node-${m.id}`).attr("fill-opacity","0").attr("width",z).attr("height",z),N.attr("class","architecture-junction");let{width:b,height:c}=N._groups[0][0].getBBox();N.width=b,N.height=c,e.setElementForId(m.id,N)})},"drawJunctions");Ln([{name:it.prefix,icons:it}]);ft.use(xt.default);function Tt(e,i,s){e.forEach((w)=>{i.add({group:"nodes",data:{type:"service",id:w.id,icon:w.icon,label:w.title,parent:w.in,width:s.getConfigField("iconSize"),height:s.getConfigField("iconSize")},classes:"node-service"})})}t(Tt,"addServices");function At(e,i,s){e.forEach((w)=>{i.add({group:"nodes",data:{type:"junction",id:w.id,parent:w.in,width:s.getConfigField("iconSize"),height:s.getConfigField("iconSize")},classes:"node-junction"})})}t(At,"addJunctions");function Lt(e,i){i.nodes().map((s)=>{let w=Qe(s);if(w.type==="group")return;w.x=s.position().x,w.y=s.position().y,e.getElementById(w.id).attr("transform","translate("+(w.x||0)+","+(w.y||0)+")")})}t(Lt,"positionNodes");function Ct(e,i){e.forEach((s)=>{i.add({group:"nodes",data:{type:"group",id:s.id,icon:s.icon,label:s.title,parent:s.in},classes:"node-group"})})}t(Ct,"addGroups");function It(e,i){e.forEach((s)=>{let{lhsId:w,rhsId:m,lhsInto:N,lhsGroup:z,rhsInto:v,lhsDir:b,rhsDir:c,rhsGroup:y,title:d}=s,f=dt(s.lhsDir,s.rhsDir)?"segments":"straight",u={id:`${w}-${m}`,label:d,source:w,sourceDir:b,sourceArrow:N,sourceGroup:z,sourceEndpoint:b==="L"?"0 50%":b==="R"?"100% 50%":b==="T"?"50% 0":"50% 100%",target:m,targetDir:c,targetArrow:v,targetGroup:y,targetEndpoint:c==="L"?"0 50%":c==="R"?"100% 50%":c==="T"?"50% 0":"50% 100%"};i.add({group:"edges",data:u,classes:f})})}t(It,"addEdges");function bt(e,i,s,w=[]){let m=t((f,u)=>{let g=new Map;for(let[r,B]of f.entries()){let F=`${r}`,o=0,h=[...B.entries()];if(h.length===1){g.set(F,h[0][1]);continue}for(let k=0;k<h.length-1;k++)for(let n=k+1;n<h.length;n++){let[P,X]=h[k],[D,j]=h[n];if(s.get(mt(P,D))===u)g.set(F,[...g.get(F)??[],...X,...j]);else if(P==="default"||D==="default")g.set(F,[...g.get(F)??[],...X,...j]);else{let I=`${F}-${o++}`;g.set(I,X);let Y=`${F}-${o++}`;g.set(Y,j)}}}return g},"flattenAlignments"),N=i.map((f)=>{let u=new Map,g=new Map;return f.forEach(([r,B],F)=>{let o=e.getNode(F)?.in??"default",h=u.get(B)??new Map;if(!u.has(B))u.set(B,h);let k=g.get(r)??new Map;if(!g.has(r))g.set(r,k);for(let n of[h,k]){let P=n.get(o)??[];if(!n.has(o))n.set(o,P);P.push(F)}}),{horiz:[...m(u,"horizontal").values()].filter((r)=>r.length>1),vert:[...m(g,"vertical").values()].filter((r)=>r.length>1)}}),[z,v]=N.reduce(([f,u],{horiz:g,vert:r})=>[[...f,...g],[...u,...r]],[[],[]]),b=new Set;w.forEach((f)=>f.members.forEach((u)=>b.add(u)));let c=t((f)=>f.filter((u)=>!u.some((g)=>b.has(g))),"dropOverlapping"),y=c(z),d=c(v);return w.forEach((f)=>{if(f.members.length<2)return;if(f.direction==="row")y.push([...f.members]);else d.push([...f.members])}),{horizontal:y,vertical:d}}t(bt,"getAlignments");function Nt(e,i,s=[]){let w=[],m=i.getConfigField("iconSize"),N=i.getConfigField("idealEdgeLengthMultiplier"),z=N*m,v=new Set;s.forEach((y)=>{for(let d=0;d<y.members.length-1;d++){let f=y.members[d],u=y.members[d+1];if(v.add(`${f}|${u}`),v.add(`${u}|${f}`),y.direction==="row")w.push({left:f,right:u,gap:z});else w.push({top:f,bottom:u,gap:z})}});let b=t((y)=>`${y[0]},${y[1]}`,"posToStr"),c=t((y)=>y.split(",").map((d)=>parseInt(d)),"strToPos");return e.forEach((y)=>{let d=new Map([...y.entries()].map(([r,B])=>[b(B),r])),f=[b([0,0])],u={},g={L:[-1,0],R:[1,0],T:[0,1],B:[0,-1]};while(f.length>0){let r=f.shift();if(r){u[r]=1;let B=d.get(r);if(B){let F=c(r);Object.entries(g).forEach(([o,h])=>{let k=b([F[0]+h[0],F[1]+h[1]]),n=d.get(k);if(n&&!u[k]){if(f.push(k),v.has(`${B}|${n}`))return;w.push({[ht[o]]:n,[ht[kt(o)]]:B,gap:N*m})}})}}}}),w}t(Nt,"getRelativeConstraints");function St(e,i,s,w,m,{spatialMaps:N,groupAlignments:z}){return new Promise((v)=>{let b=p("body").append("div").attr("id","cy").attr("style","display:none"),c=ft({container:document.getElementById("cy"),style:[{selector:"edge",style:{"curve-style":"straight","source-endpoint":"data(sourceEndpoint)","target-endpoint":"data(targetEndpoint)"}},{selector:"edge[label]",style:{label:"data(label)"}},{selector:"edge.segments",style:{"curve-style":"segments","segment-weights":"0","segment-distances":[0.5],"edge-distances":"endpoints","source-endpoint":"data(sourceEndpoint)","target-endpoint":"data(targetEndpoint)"}},{selector:"node",style:{"compound-sizing-wrt-labels":"include"}},{selector:"node[label]",style:{"text-valign":"bottom","text-halign":"center","font-size":`${m.getConfigField("fontSize")}px`}},{selector:".node-service",style:{label:"data(label)",width:"data(width)",height:"data(height)"}},{selector:".node-junction",style:{width:"data(width)",height:"data(height)"}},{selector:".node-group",style:{padding:`${m.getConfigField("padding")}px`}}],layout:{name:"grid",boundingBox:{x1:0,x2:100,y1:0,y2:100}}});b.remove(),Ct(s,c),Tt(e,c,m),At(i,c,m),It(w,c);let y=m.getLayoutHints(),d=bt(m,N,z,y),f=Nt(N,m,y),u=m.getConfigField("iconSize"),g=m.getConfigField("idealEdgeLengthMultiplier")*u,r=0.5*u,B=m.getConfigField("edgeElasticity"),F=m.getConfigField("seed"),o=c.layout({name:"fcose",quality:"proof",randomize:m.getConfigField("randomize"),nodeSeparation:m.getConfigField("nodeSeparation"),numIter:m.getConfigField("numIter"),styleEnabled:!1,animate:!1,nodeDimensionsIncludeLabels:!1,idealEdgeLength(h){let[k,n]=h.connectedNodes(),{parent:P}=Qe(k),{parent:X}=Qe(n);return P===X?g:r},edgeElasticity(h){let[k,n]=h.connectedNodes(),{parent:P}=Qe(k),{parent:X}=Qe(n);return P===X?B:0.001},alignmentConstraint:d,relativePlacementConstraint:f});o.one("layoutstop",()=>{function h(k,n,P,X){let D,j,{x:_,y:I}=k,{x:Y,y:J}=n;j=(X-I+(_-P)*(I-J)/(_-Y))/Math.sqrt(1+Math.pow((I-J)/(_-Y),2)),D=Math.sqrt(Math.pow(X-I,2)+Math.pow(P-_,2)-Math.pow(j,2));let Z=Math.sqrt(Math.pow(Y-_,2)+Math.pow(J-I,2));D=D/Z;let se=(Y-_)*(X-I)-(J-I)*(P-_);switch(!0){case se>=0:se=1;break;case se<0:se=-1;break}let re=(Y-_)*(P-_)+(J-I)*(X-I);switch(!0){case re>=0:re=1;break;case re<0:re=-1;break}return j=Math.abs(j)*se,D=D*re,{distances:j,weights:D}}t(h,"getSegmentWeights"),c.startBatch();for(let k of Object.values(c.edges()))if(k.data?.()){let{x:n,y:P}=k.source().position(),{x:X,y:D}=k.target().position();if(n!==X&&P!==D){let j=k.sourceEndpoint(),_=k.targetEndpoint(),{sourceDir:I}=yt(k),[Y,J]=Ve(I)?[j.x,_.y]:[_.x,j.y],{weights:Z,distances:se}=h(j,_,Y,J);k.style("segment-distances",se),k.style("segment-weights",Z)}}c.endBatch(),ct(F,()=>o.run())});try{ct(F,()=>o.run())}catch(h){if(h instanceof RangeError&&h.message.includes("Invalid array length"))throw Error("Architecture layout failed: a declared `align row|column` directive likely contradicts the edge directions, or two declared alignments overlap on a shared node. Check that the order of members in each `align` chain is consistent with the edges between them, and that no node appears in two `align` directives along the same axis.");throw h}c.ready((h)=>{a.info("Ready",h),v(c)})})}t(St,"layoutArchitecture");var Xt=t(async(e,i,s,w)=>{let m=w.db;m.setDiagramId(i);let N=m.getServices(),z=m.getJunctions(),v=m.getGroups(),b=m.getEdges(),c=m.getDataStructures(),y=V(i),d=y.append("g");d.attr("class","architecture-edges");let f=y.append("g");f.attr("class","architecture-services");let u=y.append("g");u.attr("class","architecture-groups"),await Ht(m,f,N,i),Vt(m,f,z,i);let g=await St(N,z,v,b,m,c);await Yt(d,g,m,i),await Ut(u,g,m,i),Lt(m,g),gt(void 0,y,m.getConfigField("padding"),m.getConfigField("useMaxWidth"))},"draw"),jt={draw:Xt},ar={parser:wt,get db(){return new Et},renderer:jt,styles:_t};export{ar as diagram};
@@ -1,4 +1,4 @@
1
- import{g,o,v,i,r,f,e,n,y,ot}from"./chunk-kahab58k.js";var V="__chat__";function M(t){if(!Number.isFinite(t)||t<=0)return"0";if(t<1000)return Math.round(t).toString();if(t<1e6)return`${(t/1000).toFixed(1)}K`;if(t<1e9)return`${(t/1e6).toFixed(2)}M`;return`${(t/1e9).toFixed(2)}B`}function L(t){let u=Number.isFinite(t)?Math.max(0,t):0;return Math.round(u).toLocaleString("en-US")}function P(t){if(!Number.isFinite(t)||t<=0)return"0s";if(t<1000)return"<1s";if(t<60000)return`${Math.floor(t/1000)}s`;if(t<3600000){let c=Math.floor(t/1000),a=Math.floor(c/60),d=c%60;return d>0?`${a}m ${d}s`:`${a}m`}if(t<259200000){let c=Math.floor(t/60000),a=Math.floor(c/60),d=c%60;return d>0?`${a}h ${d}m`:`${a}h`}let u=Math.floor(t/3600000),b=Math.floor(u/24),p=u%24;return p>0?`${b}d ${p}h`:`${b}d`}function ae(t){if(!Number.isFinite(t)||t<=0)return"0s";if(t<1000)return"<1s";if(t<60000)return`${Math.round(t/1000)}s`;if(t<3600000)return`${Math.round(t/60000)}m`;if(t<86400000){let p=t/3600000;return`${p>=10?Math.round(p).toString():p.toFixed(1).replace(/\.0$/,"")}h`}let u=t/86400000;return`${u>=10?Math.round(u).toString():u.toFixed(1).replace(/\.0$/,"")}d`}function B(t,u=1){if(!Number.isFinite(t)||t<=0)return"0%";let b=10**-u/100;if(t<b)return`<${(b*100).toFixed(u)}%`;return`${(t*100).toFixed(u)}%`}function Q(t){if(!Number.isFinite(t)||t<=0)return"0 B";if(t<1024)return`${Math.round(t)} B`;if(t<1048576)return`${(t/1024).toFixed(1)} KB`;if(t<1073741824)return`${(t/1048576).toFixed(2)} MB`;return`${(t/1073741824).toFixed(2)} GB`}function W(t){let u=t.split("-"),b=u[1],p=u[2];if(b!==void 0&&p!==void 0)return`${b}/${p}`;return t}function Z(t){let u=t.split("-"),b=u[0],p=u[1],c=u[2];if(b===void 0||p===void 0||c===void 0)return t;let a=Number(b),d=Number(p)-1,h=Number(c),w=new Date(Date.UTC(a,d,h)),C=["周日","周一","周二","周三","周四","周五","周六"],D=w.getUTCDay(),F=C[D]??"";return`${t} ${F}`}function se(t,u=Date.now()){if(t===null||t===void 0||!Number.isFinite(t)||t<=0)return"从未";let b=Math.max(0,u-t);if(b<60000)return"刚刚";if(b<3600000)return`${Math.max(1,Math.floor(b/60000))} 分钟前`;if(b<86400000)return`${Math.max(1,Math.floor(b/3600000))} 小时前`;if(b<2592000000)return`${Math.max(1,Math.floor(b/86400000))} 天前`;let p=new Date(t),c=p.getFullYear(),a=String(p.getMonth()+1).padStart(2,"0"),d=String(p.getDate()).padStart(2,"0");return`${c}-${a}-${d}`}function K(t){return e("div",{className:"h-1.5 w-full overflow-hidden rounded-full bg-raised",children:e("div",{className:"h-full rounded-full bg-accent transition-all duration-300",style:{width:`${t.percent}%`}})})}function Y(t){return e("div",{className:"flex flex-wrap items-center justify-between gap-x-4 gap-y-1 font-mono text-[11px] text-dim tabular-nums",children:t.children})}function G(t){return e("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1",children:t.children})}function J(t){return n(G,{children:[n("span",{children:["输入 ",e("span",{className:"text-ink",children:M(t.stat.inputTokens)})]}),n("span",{children:["输出 ",e("span",{className:"text-ink",children:M(t.stat.outputTokens)})]}),n("span",{children:["缓存读 ",e("span",{className:"text-ink",children:M(t.stat.cacheReadTokens)}),t.cacheHitRate!==void 0&&n("span",{className:"text-faint",children:[" (",B(t.cacheHitRate),")"]})]})]})}function oe(t){let{projects:u,selectedProjectID:b,onSelectProject:p}=t,{style:c}=y();if(u.length===0)return e("div",{className:c("surface.empty"),children:"暂无项目统计数据"});return e("div",{className:"divide-y divide-line",children:u.map((a)=>{let d=a.projectID??V,h=b===d,w=Math.max(a.tokenShare>0?1:0,a.tokenShare*100);return n("div",{className:"p-4 space-y-2.5",children:[n("div",{className:"flex flex-wrap items-center justify-between gap-2 text-xs",children:[n("div",{className:"flex min-w-0 items-center gap-2",children:[e("span",{className:"font-medium text-sm text-ink truncate",children:a.name}),e("span",{className:c("control.badge","font-mono truncate max-w-[240px]"),title:a.directory||"未绑定项目目录",children:a.directory||"独立会话"}),e("button",{type:"button",onClick:()=>p(h?null:d),className:"rounded px-1.5 py-0.5 text-[11px] text-accent hover:bg-accent/10 transition-colors cursor-pointer shrink-0",children:h?"取消筛选":"筛选"})]}),n("div",{className:"flex items-baseline gap-1.5 font-mono tabular-nums shrink-0",children:[e("span",{className:"text-xs font-medium text-ink",title:L(a.totalTokens),children:M(a.totalTokens)}),n("span",{className:"text-[11px] text-faint",children:["(",B(a.tokenShare),")"]})]})]}),e(K,{percent:w}),n(Y,{children:[e(J,{stat:a,cacheHitRate:a.cacheHitRate}),n(G,{children:[n("span",{children:["耗时 ",e("span",{className:"text-ink",children:P(a.activeDurationMs)})]}),n("span",{children:[e("span",{className:"text-ink",children:a.sessionCount.toLocaleString()})," 会话"]}),n("span",{children:["工具 ",e("span",{className:"text-ink",children:a.toolCalls.toLocaleString()})," 次"]})]})]})]},d)})})}function re(t){let{models:u}=t,{ModelIcon:b,style:p}=y();if(u.length===0)return e("div",{className:p("surface.empty"),children:"暂无模型调用数据"});return e("div",{className:"divide-y divide-line",children:u.map((c)=>{let a=Math.max(c.share>0?1:0,c.share*100);return n("div",{className:"p-4 space-y-2.5",children:[n("div",{className:"flex flex-wrap items-center justify-between gap-2 text-xs",children:[n("div",{className:"flex min-w-0 items-center gap-2",children:[e(b,{modelID:c.model,className:"size-4 shrink-0"}),e("span",{className:"font-mono text-sm font-medium text-ink truncate",children:c.shortName}),e("span",{className:p("control.badge","font-mono shrink-0"),children:c.provider})]}),n("div",{className:"flex items-baseline gap-2.5 font-mono tabular-nums shrink-0",children:[c.avgTps!==null&&n("span",{className:"text-[11px] text-dim",children:[c.avgTps.toFixed(1)," tok/s"]}),n("span",{className:"text-xs font-medium text-ink",title:L(c.totalTokens),children:[M(c.totalTokens)," ",n("span",{className:"text-[11px] font-normal text-faint",children:["(",B(c.share),")"]})]})]})]}),e(K,{percent:a}),n(Y,{children:[e(J,{stat:c,cacheHitRate:c.cacheHitRate}),n(G,{children:[n("span",{children:[e("span",{className:"text-ink",children:c.turns.toLocaleString()})," 轮",c.errors>0?n("span",{className:"text-danger",children:[" (",c.errors," 错)"]}):null]}),n("span",{children:["工具 ",e("span",{className:"text-ink",children:c.toolCalls.toLocaleString()})," 次"]}),c.generationMs>0&&n("span",{children:["推理 ",e("span",{className:"text-ink",children:ae(c.generationMs)})]})]})]})]},c.model)})})}function ie(t){let{tools:u}=t,{StatusChip:b,style:p}=y();if(u.length===0)return e("div",{className:p("surface.empty"),children:"暂无工具调用数据"});return e("div",{className:"divide-y divide-line",children:u.map((c)=>{let a=Math.max(c.share>0?1:0,c.share*100),d=c.successRate>=0.95?"success":c.successRate>=0.8?"warning":"danger",h=Math.max(0,c.calls-c.errors),w=c.calls>0?Math.round(c.outputBytes/c.calls):0;return n("div",{className:"p-4 space-y-2.5",children:[n("div",{className:"flex flex-wrap items-center justify-between gap-2 text-xs",children:[n("div",{className:"flex min-w-0 items-center gap-2",children:[e("span",{className:"font-mono text-sm font-medium text-ink truncate",children:c.name}),n(b,{tone:d,children:["成功率 ",B(c.successRate)]})]}),n("div",{className:"flex items-baseline gap-1.5 font-mono tabular-nums shrink-0",children:[n("span",{className:"text-xs font-medium text-ink",children:[c.calls.toLocaleString()," 次"]}),n("span",{className:"text-[11px] text-faint",children:["(",B(c.share),")"]})]})]}),e(K,{percent:a}),n(Y,{children:[n(G,{children:[n("span",{children:["成功 ",e("span",{className:"text-ink",children:h.toLocaleString()})," 次"]}),n("span",{children:["失败 ",e("span",{className:c.errors>0?"text-danger":"text-ink",children:c.errors.toLocaleString()})," 次"]})]}),n(G,{children:[n("span",{children:["累计输出 ",e("span",{className:"text-ink",children:Q(c.outputBytes)})]}),n("span",{children:["单次均值 ",e("span",{className:"text-ink",children:Q(w)})]})]})]})]},c.name)})})}function le(t){let{sessions:u,onOpenSession:b}=t,{style:p}=y();if(u.length===0)return e("div",{className:p("surface.empty"),children:"暂无高消耗会话记录"});let c=Math.max(1,...u.map((a)=>a.totalTokens));return e("div",{className:"divide-y divide-line",children:u.map((a)=>{let d=c>0?Math.max(1,a.totalTokens/c*100):0,h=a.model.split("/").pop()??a.model;return n("button",{type:"button",onClick:()=>b(a.id),className:"group block w-full p-4 text-left space-y-2.5 hover:bg-raised/40 transition-colors cursor-pointer",children:[n("div",{className:"flex flex-wrap items-center justify-between gap-2 text-xs",children:[n("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[e("span",{className:"font-medium text-sm text-ink truncate group-hover:text-accent transition-colors",children:a.title.trim()||"新会话"}),e("span",{className:p("control.badge","font-mono truncate max-w-[140px] shrink-0"),title:a.projectName,children:a.projectName}),a.kind==="sub"&&e("span",{className:"rounded bg-accent/15 px-1.5 py-0.5 text-[10.5px] text-accent shrink-0",children:"子代理"}),a.archivedAt!==null&&e("span",{className:p("control.badge","shrink-0"),children:"已归档"})]}),n("div",{className:"flex items-center gap-1.5 font-mono tabular-nums shrink-0",children:[e("span",{className:"text-xs font-medium text-ink",title:L(a.totalTokens),children:M(a.totalTokens)}),e(ot,{className:"size-3.5 text-faint group-hover:text-ink group-hover:translate-x-0.5 transition-all"})]})]}),e(K,{percent:d}),n(Y,{children:[e(J,{stat:a}),n(G,{children:[e("span",{className:"text-ink",children:h}),n("span",{children:["耗时 ",e("span",{className:"text-ink",children:P(a.activeDurationMs)})]}),n("span",{children:[e("span",{className:"text-ink",children:a.assistantTurns})," 轮"]}),e("span",{className:"text-faint",children:se(a.updated)})]})]})]},a.id)})})}var ce=[{value:"tokens",label:"Token 用量"},{value:"duration",label:"活跃耗时"},{value:"activity",label:"交互轮次"}];function ue(t){let{cn:u,Segmented:b,SettingGroup:p,style:c}=y(),{daily:a}=t,[d,h]=r("tokens"),[w,C]=r(null),D=v(()=>a.some((s)=>s.totalTokens>0||s.activeDurationMs>0||s.runs>0),[a]),F=v(()=>{if(a.length===0)return{totalText:"0",avgText:"0",peakDate:"—",peakValueText:"0"};if(d==="tokens"){let S=a.reduce((_,A)=>_+A.totalTokens,0),R=a.filter((_)=>_.totalTokens>0).length,N=a[0];for(let _ of a)if(!N||_.totalTokens>N.totalTokens)N=_;return{totalText:M(S),totalFullText:L(S),avgText:R>0?M(Math.round(S/R)):"0",peakDate:N&&N.totalTokens>0?W(N.date):"—",peakValueText:N&&N.totalTokens>0?M(N.totalTokens):"0"}}if(d==="duration"){let S=a.reduce((_,A)=>_+A.activeDurationMs,0),R=a.filter((_)=>_.activeDurationMs>0).length,N=a[0];for(let _ of a)if(!N||_.activeDurationMs>N.activeDurationMs)N=_;return{totalText:P(S),totalFullText:P(S),avgText:R>0?P(Math.round(S/R)):"0s",peakDate:N&&N.activeDurationMs>0?W(N.date):"—",peakValueText:N&&N.activeDurationMs>0?P(N.activeDurationMs):"0s"}}let s=a.reduce((S,R)=>S+R.assistantTurns,0),l=a.reduce((S,R)=>S+R.userMessages,0),x=s+l,T=a.filter((S)=>S.assistantTurns>0||S.userMessages>0).length,k=a[0];for(let S of a){let R=k?k.assistantTurns+k.userMessages:0;if(!k||S.assistantTurns+S.userMessages>R)k=S}let H=k?k.assistantTurns+k.userMessages:0;return{totalText:`${x.toLocaleString()} 轮`,totalFullText:`助手 ${s.toLocaleString()} 轮 · 用户 ${l.toLocaleString()} 问`,avgText:T>0?`${(x/T).toFixed(1)} 轮/天`:"0 轮/天",peakDate:k&&H>0?W(k.date):"—",peakValueText:k&&H>0?`${H.toLocaleString()} 轮`:"0 轮"}},[a,d]),j=v(()=>{if(w){let s=a.find((l)=>l.date===w);if(s)return s}for(let s=a.length-1;s>=0;s--){let l=a[s];if(l&&(l.totalTokens>0||l.activeDurationMs>0||l.runs>0))return l}return a[a.length-1]},[a,w]),z=v(()=>{if(d==="tokens")return Math.max(1,...a.map((s)=>s.totalTokens));if(d==="duration")return Math.max(1000,...a.map((s)=>s.activeDurationMs));return Math.max(1,...a.map((s)=>s.assistantTurns+s.userMessages))},[a,d]),m=v(()=>{if(a.length<=7)return a.map((x)=>x.date);let s=6,l=[];for(let x=0;x<s;x++){let T=Math.round(x*(a.length-1)/(s-1)),k=a[T];if(k)l.push(k.date)}return l},[a]);if(!D)return e(p,{title:"每日趋势",action:e(b,{value:d,onChange:(s)=>h(s),options:ce}),children:e("div",{className:c("surface.empty"),children:"当前时间范围内暂无活跃数据"})});return e(p,{title:"每日趋势",action:e(b,{value:d,onChange:(s)=>h(s),options:ce}),children:n("div",{className:"p-4 space-y-4",children:[n("div",{className:"flex flex-wrap items-center justify-between gap-2 text-xs",children:[n("div",{className:"flex flex-wrap items-center gap-x-3.5 gap-y-1 font-mono text-dim tabular-nums",children:[n("span",{children:["汇总 ",e("span",{className:"text-ink",children:F.totalText})]}),n("span",{children:["日均 ",e("span",{className:"text-ink",children:F.avgText})]}),n("span",{children:["峰值 ",e("span",{className:"text-ink",children:F.peakValueText}),F.peakDate!=="—"?n("span",{className:"text-faint",children:[" (",F.peakDate,")"]}):null]})]}),n("div",{className:"flex items-center gap-3 text-[11px] text-dim",children:[d==="tokens"&&n(f,{children:[n("span",{className:"inline-flex items-center gap-1.5",children:[e("span",{className:"size-2 rounded-full bg-accent/40"}),"缓存读"]}),n("span",{className:"inline-flex items-center gap-1.5",children:[e("span",{className:"size-2 rounded-full bg-accent"}),"输入"]}),n("span",{className:"inline-flex items-center gap-1.5",children:[e("span",{className:"size-2 rounded-full bg-success"}),"输出"]})]}),d==="duration"&&n(f,{children:[n("span",{className:"inline-flex items-center gap-1.5",children:[e("span",{className:"size-2 rounded-full bg-accent"}),"工作调度"]}),n("span",{className:"inline-flex items-center gap-1.5",children:[e("span",{className:"size-2 rounded-full bg-success"}),"模型推理"]})]}),d==="activity"&&n(f,{children:[n("span",{className:"inline-flex items-center gap-1.5",children:[e("span",{className:"size-2 rounded-full bg-accent"}),"助手回复"]}),n("span",{className:"inline-flex items-center gap-1.5",children:[e("span",{className:"size-2 rounded-full bg-success"}),"用户提问"]})]})]})]}),n("div",{className:"relative h-44 w-full pt-1",children:[n("div",{className:"absolute inset-0 flex flex-col justify-between pointer-events-none pb-5 text-[10px] text-faint/60",children:[e("div",{className:"border-b border-line/40 w-full"}),e("div",{className:"border-b border-line/30 w-full"}),e("div",{className:"border-b border-line/40 w-full"})]}),n("section",{"aria-label":"每日趋势柱状序列",className:"relative h-full flex flex-col justify-between",onMouseLeave:()=>C(null),children:[e("div",{className:"flex-1 flex items-end gap-1 sm:gap-1.5 pb-2",children:a.map((s)=>{let l=s.totalTokens;if(d==="duration")l=s.activeDurationMs;else if(d==="activity")l=s.assistantTurns+s.userMessages;let x=l<=0,T=x?0:Math.max(3,Math.min(100,l/z*100)),k=j?.date===s.date;return n("button",{type:"button","aria-label":`${s.date} 统计数据`,className:"flex-1 h-full flex flex-col justify-end items-center group cursor-pointer relative min-w-0 bg-transparent p-0 border-0 focus:outline-hidden",onMouseEnter:()=>C(s.date),onFocus:()=>C(s.date),onClick:()=>C(s.date),children:[e("div",{className:u("absolute inset-y-0 w-full rounded-xs transition-colors pointer-events-none",k?"bg-accent/10":"group-hover:bg-raised/60")}),x?e("div",{className:"h-1 w-full max-w-[24px] rounded-full bg-raised group-hover:bg-dim/30"}):n("div",{className:"w-full max-w-[24px] rounded-t-xs overflow-hidden flex flex-col justify-end transition-all duration-150",style:{height:`${T}%`},children:[d==="tokens"&&n(f,{children:[s.outputTokens>0&&e("div",{className:"bg-success transition-all duration-200",style:{height:`${s.outputTokens/s.totalTokens*100}%`}}),s.inputTokens+s.cacheWriteTokens>0&&e("div",{className:"bg-accent transition-all duration-200",style:{height:`${(s.inputTokens+s.cacheWriteTokens)/s.totalTokens*100}%`}}),s.cacheReadTokens>0&&e("div",{className:"bg-accent/40 transition-all duration-200",style:{height:`${s.cacheReadTokens/s.totalTokens*100}%`}})]}),d==="duration"&&n(f,{children:[s.generationMs>0&&e("div",{className:"bg-success transition-all duration-200",style:{height:`${Math.min(100,s.generationMs/Math.max(1,s.activeDurationMs)*100)}%`}}),e("div",{className:"bg-accent flex-1 transition-all duration-200"})]}),d==="activity"&&n(f,{children:[s.userMessages>0&&e("div",{className:"bg-success transition-all duration-200",style:{height:`${s.userMessages/Math.max(1,s.assistantTurns+s.userMessages)*100}%`}}),e("div",{className:"bg-accent flex-1 transition-all duration-200"})]})]}),k&&e("div",{className:"absolute -bottom-1 size-1 rounded-full bg-accent"})]},s.date)})}),e("div",{className:u("flex items-center pt-1.5 text-[10px] text-faint font-mono tabular-nums",a.length<=7?"gap-1 sm:gap-1.5":"justify-between"),children:m.map((s)=>e("div",{className:u("whitespace-nowrap",a.length<=7&&"flex-1 text-center"),children:W(s)},s))})]})]}),e("div",{className:"flex flex-wrap items-center justify-between gap-2 border-t border-line pt-3 font-mono text-xs tabular-nums",children:j?n(f,{children:[e("span",{className:"text-ink",children:Z(j.date)}),n("div",{className:"flex flex-wrap items-center gap-x-3.5 gap-y-1 text-dim",children:[n("span",{children:["Token ",e("span",{className:"text-ink",children:M(j.totalTokens)})]}),n("span",{children:["耗时 ",e("span",{className:"text-ink",children:P(j.activeDurationMs)})]}),n("span",{children:["交互 ",n("span",{className:"text-ink",children:[j.assistantTurns+j.userMessages," 轮"]})]}),n("span",{children:["工具 ",n("span",{className:"text-ink",children:[j.toolCalls," 次"]})]})]})]}):e("span",{className:"font-sans text-faint",children:"悬停柱状图查看单日明细"})})]})})}function pe(t){let{cn:u,SettingGroup:b}=y(),{daily:p,hourly:c}=t,[a,d]=r(null),h=v(()=>{let l=new Map;for(let T of c)l.set(T.hour,T);let x=[];for(let T=0;T<24;T++){let k=l.get(T);if(k)x.push(k);else x.push({hour:T,totalTokens:0,activeDurationMs:0,userMessages:0,assistantTurns:0,runs:0})}return x},[c]),w=v(()=>{let l=h[0];for(let x of h)if(!l||x.totalTokens>l.totalTokens)l=x;return l&&l.totalTokens>0?l:null},[h]),C=v(()=>h.reduce((l,x)=>l+x.totalTokens,0),[h]),D=v(()=>Math.max(1,...h.map((l)=>l.totalTokens)),[h]),F=v(()=>{if(C<=0)return 0;return h.filter((x)=>x.hour>=8&&x.hour<20).reduce((x,T)=>x+T.totalTokens,0)/C},[h,C]),j=v(()=>Math.max(1,...p.map((l)=>l.totalTokens)),[p]),z=v(()=>{let l=0,x=0;for(let T of p)if(T.totalTokens>0||T.activeDurationMs>0||T.runs>0){if(x++,x>l)l=x}else x=0;return l},[p]),m=v(()=>p.filter((l)=>l.totalTokens>0||l.activeDurationMs>0||l.runs>0).length,[p]),s=a!==null?h[a]:w;return n(b,{title:"活跃时段与热力",action:n("div",{className:"flex items-center gap-3 font-mono text-xs text-faint tabular-nums",children:[n("span",{children:["日间占比 ",B(F)]}),n("span",{children:["连续活跃 ",z," 天"]}),n("span",{children:["活跃 ",m,"/",p.length," 天"]})]}),children:[n("div",{className:"p-4 space-y-3",children:[n("div",{className:"flex flex-wrap items-center justify-between gap-2 text-xs",children:[e("span",{className:"text-dim",children:"24 小时分布"}),s?n("div",{className:"flex items-center gap-3 font-mono text-dim tabular-nums",children:[n("span",{className:"text-ink",children:[a!==null?"时段 ":"高峰 ",String(s.hour).padStart(2,"0"),":00 -"," ",String((s.hour+1)%24).padStart(2,"0"),":00"]}),e("span",{className:"text-ink",children:M(s.totalTokens)}),s.activeDurationMs>0&&e("span",{children:P(s.activeDurationMs)})]}):e("span",{className:"text-faint",children:"暂无时段分布"})]}),n("section",{"aria-label":"24 小时活跃分布序列",className:"h-28 w-full flex flex-col justify-between pt-1",onMouseLeave:()=>d(null),children:[e("div",{className:"flex-1 flex items-end gap-1.5 pb-1.5",children:h.map((l)=>{let x=w?.hour===l.hour,T=a===l.hour,k=l.totalTokens>0?Math.max(6,l.totalTokens/D*100):0,H=`${String(l.hour).padStart(2,"0")}:00 - ${String((l.hour+1)%24).padStart(2,"0")}:00
1
+ import{g,o,v,i,r,f,e,n,y,st}from"./chunk-3k9h7a73.js";var V="__chat__";function M(t){if(!Number.isFinite(t)||t<=0)return"0";if(t<1000)return Math.round(t).toString();if(t<1e6)return`${(t/1000).toFixed(1)}K`;if(t<1e9)return`${(t/1e6).toFixed(2)}M`;return`${(t/1e9).toFixed(2)}B`}function L(t){let u=Number.isFinite(t)?Math.max(0,t):0;return Math.round(u).toLocaleString("en-US")}function P(t){if(!Number.isFinite(t)||t<=0)return"0s";if(t<1000)return"<1s";if(t<60000)return`${Math.floor(t/1000)}s`;if(t<3600000){let c=Math.floor(t/1000),a=Math.floor(c/60),d=c%60;return d>0?`${a}m ${d}s`:`${a}m`}if(t<259200000){let c=Math.floor(t/60000),a=Math.floor(c/60),d=c%60;return d>0?`${a}h ${d}m`:`${a}h`}let u=Math.floor(t/3600000),b=Math.floor(u/24),p=u%24;return p>0?`${b}d ${p}h`:`${b}d`}function ae(t){if(!Number.isFinite(t)||t<=0)return"0s";if(t<1000)return"<1s";if(t<60000)return`${Math.round(t/1000)}s`;if(t<3600000)return`${Math.round(t/60000)}m`;if(t<86400000){let p=t/3600000;return`${p>=10?Math.round(p).toString():p.toFixed(1).replace(/\.0$/,"")}h`}let u=t/86400000;return`${u>=10?Math.round(u).toString():u.toFixed(1).replace(/\.0$/,"")}d`}function B(t,u=1){if(!Number.isFinite(t)||t<=0)return"0%";let b=10**-u/100;if(t<b)return`<${(b*100).toFixed(u)}%`;return`${(t*100).toFixed(u)}%`}function Q(t){if(!Number.isFinite(t)||t<=0)return"0 B";if(t<1024)return`${Math.round(t)} B`;if(t<1048576)return`${(t/1024).toFixed(1)} KB`;if(t<1073741824)return`${(t/1048576).toFixed(2)} MB`;return`${(t/1073741824).toFixed(2)} GB`}function W(t){let u=t.split("-"),b=u[1],p=u[2];if(b!==void 0&&p!==void 0)return`${b}/${p}`;return t}function Z(t){let u=t.split("-"),b=u[0],p=u[1],c=u[2];if(b===void 0||p===void 0||c===void 0)return t;let a=Number(b),d=Number(p)-1,h=Number(c),w=new Date(Date.UTC(a,d,h)),C=["周日","周一","周二","周三","周四","周五","周六"],D=w.getUTCDay(),F=C[D]??"";return`${t} ${F}`}function se(t,u=Date.now()){if(t===null||t===void 0||!Number.isFinite(t)||t<=0)return"从未";let b=Math.max(0,u-t);if(b<60000)return"刚刚";if(b<3600000)return`${Math.max(1,Math.floor(b/60000))} 分钟前`;if(b<86400000)return`${Math.max(1,Math.floor(b/3600000))} 小时前`;if(b<2592000000)return`${Math.max(1,Math.floor(b/86400000))} 天前`;let p=new Date(t),c=p.getFullYear(),a=String(p.getMonth()+1).padStart(2,"0"),d=String(p.getDate()).padStart(2,"0");return`${c}-${a}-${d}`}function K(t){return e("div",{className:"h-1.5 w-full overflow-hidden rounded-full bg-raised",children:e("div",{className:"h-full rounded-full bg-accent transition-all duration-300",style:{width:`${t.percent}%`}})})}function Y(t){return e("div",{className:"flex flex-wrap items-center justify-between gap-x-4 gap-y-1 font-mono text-[11px] text-dim tabular-nums",children:t.children})}function G(t){return e("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1",children:t.children})}function J(t){return n(G,{children:[n("span",{children:["输入 ",e("span",{className:"text-ink",children:M(t.stat.inputTokens)})]}),n("span",{children:["输出 ",e("span",{className:"text-ink",children:M(t.stat.outputTokens)})]}),n("span",{children:["缓存读 ",e("span",{className:"text-ink",children:M(t.stat.cacheReadTokens)}),t.cacheHitRate!==void 0&&n("span",{className:"text-faint",children:[" (",B(t.cacheHitRate),")"]})]})]})}function oe(t){let{projects:u,selectedProjectID:b,onSelectProject:p}=t,{style:c}=y();if(u.length===0)return e("div",{className:c("surface.empty"),children:"暂无项目统计数据"});return e("div",{className:"divide-y divide-line",children:u.map((a)=>{let d=a.projectID??V,h=b===d,w=Math.max(a.tokenShare>0?1:0,a.tokenShare*100);return n("div",{className:"p-4 space-y-2.5",children:[n("div",{className:"flex flex-wrap items-center justify-between gap-2 text-xs",children:[n("div",{className:"flex min-w-0 items-center gap-2",children:[e("span",{className:"font-medium text-sm text-ink truncate",children:a.name}),e("span",{className:c("control.badge","font-mono truncate max-w-[240px]"),title:a.directory||"未绑定项目目录",children:a.directory||"独立会话"}),e("button",{type:"button",onClick:()=>p(h?null:d),className:"rounded px-1.5 py-0.5 text-[11px] text-accent hover:bg-accent/10 transition-colors cursor-pointer shrink-0",children:h?"取消筛选":"筛选"})]}),n("div",{className:"flex items-baseline gap-1.5 font-mono tabular-nums shrink-0",children:[e("span",{className:"text-xs font-medium text-ink",title:L(a.totalTokens),children:M(a.totalTokens)}),n("span",{className:"text-[11px] text-faint",children:["(",B(a.tokenShare),")"]})]})]}),e(K,{percent:w}),n(Y,{children:[e(J,{stat:a,cacheHitRate:a.cacheHitRate}),n(G,{children:[n("span",{children:["耗时 ",e("span",{className:"text-ink",children:P(a.activeDurationMs)})]}),n("span",{children:[e("span",{className:"text-ink",children:a.sessionCount.toLocaleString()})," 会话"]}),n("span",{children:["工具 ",e("span",{className:"text-ink",children:a.toolCalls.toLocaleString()})," 次"]})]})]})]},d)})})}function re(t){let{models:u}=t,{ModelIcon:b,style:p}=y();if(u.length===0)return e("div",{className:p("surface.empty"),children:"暂无模型调用数据"});return e("div",{className:"divide-y divide-line",children:u.map((c)=>{let a=Math.max(c.share>0?1:0,c.share*100);return n("div",{className:"p-4 space-y-2.5",children:[n("div",{className:"flex flex-wrap items-center justify-between gap-2 text-xs",children:[n("div",{className:"flex min-w-0 items-center gap-2",children:[e(b,{modelID:c.model,className:"size-4 shrink-0"}),e("span",{className:"font-mono text-sm font-medium text-ink truncate",children:c.shortName}),e("span",{className:p("control.badge","font-mono shrink-0"),children:c.provider})]}),n("div",{className:"flex items-baseline gap-2.5 font-mono tabular-nums shrink-0",children:[c.avgTps!==null&&n("span",{className:"text-[11px] text-dim",children:[c.avgTps.toFixed(1)," tok/s"]}),n("span",{className:"text-xs font-medium text-ink",title:L(c.totalTokens),children:[M(c.totalTokens)," ",n("span",{className:"text-[11px] font-normal text-faint",children:["(",B(c.share),")"]})]})]})]}),e(K,{percent:a}),n(Y,{children:[e(J,{stat:c,cacheHitRate:c.cacheHitRate}),n(G,{children:[n("span",{children:[e("span",{className:"text-ink",children:c.turns.toLocaleString()})," 轮",c.errors>0?n("span",{className:"text-danger",children:[" (",c.errors," 错)"]}):null]}),n("span",{children:["工具 ",e("span",{className:"text-ink",children:c.toolCalls.toLocaleString()})," 次"]}),c.generationMs>0&&n("span",{children:["推理 ",e("span",{className:"text-ink",children:ae(c.generationMs)})]})]})]})]},c.model)})})}function ie(t){let{tools:u}=t,{StatusChip:b,style:p}=y();if(u.length===0)return e("div",{className:p("surface.empty"),children:"暂无工具调用数据"});return e("div",{className:"divide-y divide-line",children:u.map((c)=>{let a=Math.max(c.share>0?1:0,c.share*100),d=c.successRate>=0.95?"success":c.successRate>=0.8?"warning":"danger",h=Math.max(0,c.calls-c.errors),w=c.calls>0?Math.round(c.outputBytes/c.calls):0;return n("div",{className:"p-4 space-y-2.5",children:[n("div",{className:"flex flex-wrap items-center justify-between gap-2 text-xs",children:[n("div",{className:"flex min-w-0 items-center gap-2",children:[e("span",{className:"font-mono text-sm font-medium text-ink truncate",children:c.name}),n(b,{tone:d,children:["成功率 ",B(c.successRate)]})]}),n("div",{className:"flex items-baseline gap-1.5 font-mono tabular-nums shrink-0",children:[n("span",{className:"text-xs font-medium text-ink",children:[c.calls.toLocaleString()," 次"]}),n("span",{className:"text-[11px] text-faint",children:["(",B(c.share),")"]})]})]}),e(K,{percent:a}),n(Y,{children:[n(G,{children:[n("span",{children:["成功 ",e("span",{className:"text-ink",children:h.toLocaleString()})," 次"]}),n("span",{children:["失败 ",e("span",{className:c.errors>0?"text-danger":"text-ink",children:c.errors.toLocaleString()})," 次"]})]}),n(G,{children:[n("span",{children:["累计输出 ",e("span",{className:"text-ink",children:Q(c.outputBytes)})]}),n("span",{children:["单次均值 ",e("span",{className:"text-ink",children:Q(w)})]})]})]})]},c.name)})})}function le(t){let{sessions:u,onOpenSession:b}=t,{style:p}=y();if(u.length===0)return e("div",{className:p("surface.empty"),children:"暂无高消耗会话记录"});let c=Math.max(1,...u.map((a)=>a.totalTokens));return e("div",{className:"divide-y divide-line",children:u.map((a)=>{let d=c>0?Math.max(1,a.totalTokens/c*100):0,h=a.model.split("/").pop()??a.model;return n("button",{type:"button",onClick:()=>b(a.id),className:"group block w-full p-4 text-left space-y-2.5 hover:bg-raised/40 transition-colors cursor-pointer",children:[n("div",{className:"flex flex-wrap items-center justify-between gap-2 text-xs",children:[n("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[e("span",{className:"font-medium text-sm text-ink truncate group-hover:text-accent transition-colors",children:a.title.trim()||"新会话"}),e("span",{className:p("control.badge","font-mono truncate max-w-[140px] shrink-0"),title:a.projectName,children:a.projectName}),a.kind==="sub"&&e("span",{className:"rounded bg-accent/15 px-1.5 py-0.5 text-[10.5px] text-accent shrink-0",children:"子代理"}),a.archivedAt!==null&&e("span",{className:p("control.badge","shrink-0"),children:"已归档"})]}),n("div",{className:"flex items-center gap-1.5 font-mono tabular-nums shrink-0",children:[e("span",{className:"text-xs font-medium text-ink",title:L(a.totalTokens),children:M(a.totalTokens)}),e(st,{className:"size-3.5 text-faint group-hover:text-ink group-hover:translate-x-0.5 transition-all"})]})]}),e(K,{percent:d}),n(Y,{children:[e(J,{stat:a}),n(G,{children:[e("span",{className:"text-ink",children:h}),n("span",{children:["耗时 ",e("span",{className:"text-ink",children:P(a.activeDurationMs)})]}),n("span",{children:[e("span",{className:"text-ink",children:a.assistantTurns})," 轮"]}),e("span",{className:"text-faint",children:se(a.updated)})]})]})]},a.id)})})}var ce=[{value:"tokens",label:"Token 用量"},{value:"duration",label:"活跃耗时"},{value:"activity",label:"交互轮次"}];function ue(t){let{cn:u,Segmented:b,SettingGroup:p,style:c}=y(),{daily:a}=t,[d,h]=r("tokens"),[w,C]=r(null),D=v(()=>a.some((s)=>s.totalTokens>0||s.activeDurationMs>0||s.runs>0),[a]),F=v(()=>{if(a.length===0)return{totalText:"0",avgText:"0",peakDate:"—",peakValueText:"0"};if(d==="tokens"){let S=a.reduce((_,A)=>_+A.totalTokens,0),R=a.filter((_)=>_.totalTokens>0).length,N=a[0];for(let _ of a)if(!N||_.totalTokens>N.totalTokens)N=_;return{totalText:M(S),totalFullText:L(S),avgText:R>0?M(Math.round(S/R)):"0",peakDate:N&&N.totalTokens>0?W(N.date):"—",peakValueText:N&&N.totalTokens>0?M(N.totalTokens):"0"}}if(d==="duration"){let S=a.reduce((_,A)=>_+A.activeDurationMs,0),R=a.filter((_)=>_.activeDurationMs>0).length,N=a[0];for(let _ of a)if(!N||_.activeDurationMs>N.activeDurationMs)N=_;return{totalText:P(S),totalFullText:P(S),avgText:R>0?P(Math.round(S/R)):"0s",peakDate:N&&N.activeDurationMs>0?W(N.date):"—",peakValueText:N&&N.activeDurationMs>0?P(N.activeDurationMs):"0s"}}let s=a.reduce((S,R)=>S+R.assistantTurns,0),l=a.reduce((S,R)=>S+R.userMessages,0),x=s+l,T=a.filter((S)=>S.assistantTurns>0||S.userMessages>0).length,k=a[0];for(let S of a){let R=k?k.assistantTurns+k.userMessages:0;if(!k||S.assistantTurns+S.userMessages>R)k=S}let H=k?k.assistantTurns+k.userMessages:0;return{totalText:`${x.toLocaleString()} 轮`,totalFullText:`助手 ${s.toLocaleString()} 轮 · 用户 ${l.toLocaleString()} 问`,avgText:T>0?`${(x/T).toFixed(1)} 轮/天`:"0 轮/天",peakDate:k&&H>0?W(k.date):"—",peakValueText:k&&H>0?`${H.toLocaleString()} 轮`:"0 轮"}},[a,d]),j=v(()=>{if(w){let s=a.find((l)=>l.date===w);if(s)return s}for(let s=a.length-1;s>=0;s--){let l=a[s];if(l&&(l.totalTokens>0||l.activeDurationMs>0||l.runs>0))return l}return a[a.length-1]},[a,w]),z=v(()=>{if(d==="tokens")return Math.max(1,...a.map((s)=>s.totalTokens));if(d==="duration")return Math.max(1000,...a.map((s)=>s.activeDurationMs));return Math.max(1,...a.map((s)=>s.assistantTurns+s.userMessages))},[a,d]),m=v(()=>{if(a.length<=7)return a.map((x)=>x.date);let s=6,l=[];for(let x=0;x<s;x++){let T=Math.round(x*(a.length-1)/(s-1)),k=a[T];if(k)l.push(k.date)}return l},[a]);if(!D)return e(p,{title:"每日趋势",action:e(b,{value:d,onChange:(s)=>h(s),options:ce}),children:e("div",{className:c("surface.empty"),children:"当前时间范围内暂无活跃数据"})});return e(p,{title:"每日趋势",action:e(b,{value:d,onChange:(s)=>h(s),options:ce}),children:n("div",{className:"p-4 space-y-4",children:[n("div",{className:"flex flex-wrap items-center justify-between gap-2 text-xs",children:[n("div",{className:"flex flex-wrap items-center gap-x-3.5 gap-y-1 font-mono text-dim tabular-nums",children:[n("span",{children:["汇总 ",e("span",{className:"text-ink",children:F.totalText})]}),n("span",{children:["日均 ",e("span",{className:"text-ink",children:F.avgText})]}),n("span",{children:["峰值 ",e("span",{className:"text-ink",children:F.peakValueText}),F.peakDate!=="—"?n("span",{className:"text-faint",children:[" (",F.peakDate,")"]}):null]})]}),n("div",{className:"flex items-center gap-3 text-[11px] text-dim",children:[d==="tokens"&&n(f,{children:[n("span",{className:"inline-flex items-center gap-1.5",children:[e("span",{className:"size-2 rounded-full bg-accent/40"}),"缓存读"]}),n("span",{className:"inline-flex items-center gap-1.5",children:[e("span",{className:"size-2 rounded-full bg-accent"}),"输入"]}),n("span",{className:"inline-flex items-center gap-1.5",children:[e("span",{className:"size-2 rounded-full bg-success"}),"输出"]})]}),d==="duration"&&n(f,{children:[n("span",{className:"inline-flex items-center gap-1.5",children:[e("span",{className:"size-2 rounded-full bg-accent"}),"工作调度"]}),n("span",{className:"inline-flex items-center gap-1.5",children:[e("span",{className:"size-2 rounded-full bg-success"}),"模型推理"]})]}),d==="activity"&&n(f,{children:[n("span",{className:"inline-flex items-center gap-1.5",children:[e("span",{className:"size-2 rounded-full bg-accent"}),"助手回复"]}),n("span",{className:"inline-flex items-center gap-1.5",children:[e("span",{className:"size-2 rounded-full bg-success"}),"用户提问"]})]})]})]}),n("div",{className:"relative h-44 w-full pt-1",children:[n("div",{className:"absolute inset-0 flex flex-col justify-between pointer-events-none pb-5 text-[10px] text-faint/60",children:[e("div",{className:"border-b border-line/40 w-full"}),e("div",{className:"border-b border-line/30 w-full"}),e("div",{className:"border-b border-line/40 w-full"})]}),n("section",{"aria-label":"每日趋势柱状序列",className:"relative h-full flex flex-col justify-between",onMouseLeave:()=>C(null),children:[e("div",{className:"flex-1 flex items-end gap-1 sm:gap-1.5 pb-2",children:a.map((s)=>{let l=s.totalTokens;if(d==="duration")l=s.activeDurationMs;else if(d==="activity")l=s.assistantTurns+s.userMessages;let x=l<=0,T=x?0:Math.max(3,Math.min(100,l/z*100)),k=j?.date===s.date;return n("button",{type:"button","aria-label":`${s.date} 统计数据`,className:"flex-1 h-full flex flex-col justify-end items-center group cursor-pointer relative min-w-0 bg-transparent p-0 border-0 focus:outline-hidden",onMouseEnter:()=>C(s.date),onFocus:()=>C(s.date),onClick:()=>C(s.date),children:[e("div",{className:u("absolute inset-y-0 w-full rounded-xs transition-colors pointer-events-none",k?"bg-accent/10":"group-hover:bg-raised/60")}),x?e("div",{className:"h-1 w-full max-w-[24px] rounded-full bg-raised group-hover:bg-dim/30"}):n("div",{className:"w-full max-w-[24px] rounded-t-xs overflow-hidden flex flex-col justify-end transition-all duration-150",style:{height:`${T}%`},children:[d==="tokens"&&n(f,{children:[s.outputTokens>0&&e("div",{className:"bg-success transition-all duration-200",style:{height:`${s.outputTokens/s.totalTokens*100}%`}}),s.inputTokens+s.cacheWriteTokens>0&&e("div",{className:"bg-accent transition-all duration-200",style:{height:`${(s.inputTokens+s.cacheWriteTokens)/s.totalTokens*100}%`}}),s.cacheReadTokens>0&&e("div",{className:"bg-accent/40 transition-all duration-200",style:{height:`${s.cacheReadTokens/s.totalTokens*100}%`}})]}),d==="duration"&&n(f,{children:[s.generationMs>0&&e("div",{className:"bg-success transition-all duration-200",style:{height:`${Math.min(100,s.generationMs/Math.max(1,s.activeDurationMs)*100)}%`}}),e("div",{className:"bg-accent flex-1 transition-all duration-200"})]}),d==="activity"&&n(f,{children:[s.userMessages>0&&e("div",{className:"bg-success transition-all duration-200",style:{height:`${s.userMessages/Math.max(1,s.assistantTurns+s.userMessages)*100}%`}}),e("div",{className:"bg-accent flex-1 transition-all duration-200"})]})]}),k&&e("div",{className:"absolute -bottom-1 size-1 rounded-full bg-accent"})]},s.date)})}),e("div",{className:u("flex items-center pt-1.5 text-[10px] text-faint font-mono tabular-nums",a.length<=7?"gap-1 sm:gap-1.5":"justify-between"),children:m.map((s)=>e("div",{className:u("whitespace-nowrap",a.length<=7&&"flex-1 text-center"),children:W(s)},s))})]})]}),e("div",{className:"flex flex-wrap items-center justify-between gap-2 border-t border-line pt-3 font-mono text-xs tabular-nums",children:j?n(f,{children:[e("span",{className:"text-ink",children:Z(j.date)}),n("div",{className:"flex flex-wrap items-center gap-x-3.5 gap-y-1 text-dim",children:[n("span",{children:["Token ",e("span",{className:"text-ink",children:M(j.totalTokens)})]}),n("span",{children:["耗时 ",e("span",{className:"text-ink",children:P(j.activeDurationMs)})]}),n("span",{children:["交互 ",n("span",{className:"text-ink",children:[j.assistantTurns+j.userMessages," 轮"]})]}),n("span",{children:["工具 ",n("span",{className:"text-ink",children:[j.toolCalls," 次"]})]})]})]}):e("span",{className:"font-sans text-faint",children:"悬停柱状图查看单日明细"})})]})})}function pe(t){let{cn:u,SettingGroup:b}=y(),{daily:p,hourly:c}=t,[a,d]=r(null),h=v(()=>{let l=new Map;for(let T of c)l.set(T.hour,T);let x=[];for(let T=0;T<24;T++){let k=l.get(T);if(k)x.push(k);else x.push({hour:T,totalTokens:0,activeDurationMs:0,userMessages:0,assistantTurns:0,runs:0})}return x},[c]),w=v(()=>{let l=h[0];for(let x of h)if(!l||x.totalTokens>l.totalTokens)l=x;return l&&l.totalTokens>0?l:null},[h]),C=v(()=>h.reduce((l,x)=>l+x.totalTokens,0),[h]),D=v(()=>Math.max(1,...h.map((l)=>l.totalTokens)),[h]),F=v(()=>{if(C<=0)return 0;return h.filter((x)=>x.hour>=8&&x.hour<20).reduce((x,T)=>x+T.totalTokens,0)/C},[h,C]),j=v(()=>Math.max(1,...p.map((l)=>l.totalTokens)),[p]),z=v(()=>{let l=0,x=0;for(let T of p)if(T.totalTokens>0||T.activeDurationMs>0||T.runs>0){if(x++,x>l)l=x}else x=0;return l},[p]),m=v(()=>p.filter((l)=>l.totalTokens>0||l.activeDurationMs>0||l.runs>0).length,[p]),s=a!==null?h[a]:w;return n(b,{title:"活跃时段与热力",action:n("div",{className:"flex items-center gap-3 font-mono text-xs text-faint tabular-nums",children:[n("span",{children:["日间占比 ",B(F)]}),n("span",{children:["连续活跃 ",z," 天"]}),n("span",{children:["活跃 ",m,"/",p.length," 天"]})]}),children:[n("div",{className:"p-4 space-y-3",children:[n("div",{className:"flex flex-wrap items-center justify-between gap-2 text-xs",children:[e("span",{className:"text-dim",children:"24 小时分布"}),s?n("div",{className:"flex items-center gap-3 font-mono text-dim tabular-nums",children:[n("span",{className:"text-ink",children:[a!==null?"时段 ":"高峰 ",String(s.hour).padStart(2,"0"),":00 -"," ",String((s.hour+1)%24).padStart(2,"0"),":00"]}),e("span",{className:"text-ink",children:M(s.totalTokens)}),s.activeDurationMs>0&&e("span",{children:P(s.activeDurationMs)})]}):e("span",{className:"text-faint",children:"暂无时段分布"})]}),n("section",{"aria-label":"24 小时活跃分布序列",className:"h-28 w-full flex flex-col justify-between pt-1",onMouseLeave:()=>d(null),children:[e("div",{className:"flex-1 flex items-end gap-1.5 pb-1.5",children:h.map((l)=>{let x=w?.hour===l.hour,T=a===l.hour,k=l.totalTokens>0?Math.max(6,l.totalTokens/D*100):0,H=`${String(l.hour).padStart(2,"0")}:00 - ${String((l.hour+1)%24).padStart(2,"0")}:00
2
2
  消耗: ${L(l.totalTokens)} Token
3
3
  耗时: ${P(l.activeDurationMs)}
4
4
  助手轮次: ${l.assistantTurns} 轮`;return e("button",{type:"button","aria-label":`${String(l.hour).padStart(2,"0")}:00 时段统计`,className:"flex-1 h-full flex flex-col justify-end items-center group relative cursor-pointer bg-transparent p-0 border-0 focus:outline-hidden",title:H,onMouseEnter:()=>d(l.hour),onFocus:()=>d(l.hour),onClick:()=>d(l.hour),children:k>0?e("div",{className:u("w-full max-w-[20px] rounded-t-xs transition-all duration-200",x||T?"bg-accent":"bg-accent/55 group-hover:bg-accent"),style:{height:`${k}%`}}):e("div",{className:"h-1 w-full max-w-[20px] rounded-full bg-raised group-hover:bg-dim/30"})},l.hour)})}),n("div",{className:"flex justify-between items-center text-[10px] text-faint font-mono pt-1.5 border-t border-line/40",children:[e("span",{children:"00:00"}),e("span",{children:"04:00"}),e("span",{children:"08:00"}),e("span",{children:"12:00"}),e("span",{children:"16:00"}),e("span",{children:"20:00"}),e("span",{children:"23:00"})]})]})]}),n("div",{className:"p-4 space-y-2.5",children:[n("div",{className:"text-xs text-dim",children:["自然日热力 (",p.length," 天)"]}),e("div",{className:"flex flex-wrap items-center gap-1.5",children:p.map((l)=>{let x="bg-raised";if(l.totalTokens>0){let k=l.totalTokens/j;if(k<=0.33)x="bg-accent/30";else if(k<=0.66)x="bg-accent/60";else x="bg-accent"}let T=`${Z(l.date)}
@@ -1 +1 @@
1
- import{o,Y,i,r,f,e,n,y,te,ne}from"./chunk-kahab58k.js";import{ea}from"./chunk-d3f763n7.js";var T=[{id:"exa",name:"Exa",description:"免密钥 · 综合搜索"},{id:"tavily",name:"Tavily",description:"免密钥 · 支持域名筛选"},{id:"parallel",name:"Parallel",description:"免密钥 · 网页搜索"},{id:"firecrawl",name:"Firecrawl",description:"免密钥 · 网页内容"},{id:"tinyfish",name:"TinyFish",description:"免密钥 · 搜索摘要"},{id:"searxng",name:"SearXNG",description:"免密钥 · 需自建服务"},{id:"brave",name:"Brave",description:"需密钥 · 独立搜索引擎"}];function D(t){return{enabled:t.search.provider!=="off",provider:t.search.provider==="off"?"auto":t.search.provider,searxngUrl:t.search.searxngUrl??"",proxy:t.proxy??"",acceptLanguage:t.acceptLanguage??""}}function G(t,c){return{search:{provider:t.enabled?t.provider:"off",searxngUrl:t.searxngUrl},keys:{...c},proxy:t.proxy,acceptLanguage:t.acceptLanguage}}function A(t,c,u){let p=D(t);if(c.enabled!==p.enabled)return!0;if(c.enabled&&c.provider!==p.provider)return!0;return c.searxngUrl!==p.searxngUrl||c.proxy!==p.proxy||c.acceptLanguage!==p.acceptLanguage||Object.keys(u).length>0}function z({notice:t}){let{cn:c}=y();if(!t)return null;let u=t.type==="success"?ea:te;return n("div",{role:t.type==="error"?"alert":"status",className:c("flex items-start gap-2 text-xs",t.type==="success"?"text-success":"text-danger"),children:[e(u,{className:"mt-0.5 size-4 shrink-0","aria-hidden":"true"}),e("span",{className:"min-w-0 break-words",children:t.text})]})}function I(t){let{Button:c,Input:u,Switch:p,Select:x,StatusChip:S,SettingActions:R,SettingGroup:P,SettingRow:C,cn:w}=y(),m=Y(),l=t.busy!==void 0;return n("form",{id:`${m}-form`,className:"min-w-0 space-y-5",onSubmit:async(s)=>{s.preventDefault(),await t.onSave()},children:[n(P,{title:"联网搜索",children:[e(C,{title:"启用搜索",description:"查询会发送至所选搜索服务",children:e(p,{label:"启用联网搜索",disabled:l,checked:t.draft.enabled,onCheckedChange:(s)=>t.onDraft({...t.draft,enabled:s})})}),e(C,{title:"搜索渠道",description:"自动:Exa → Tavily → Parallel → Firecrawl → TinyFish",children:e("div",{className:"w-48",children:e(x,{id:`${m}-provider`,value:t.draft.provider,disabled:l||!t.draft.enabled,className:"min-w-0",groups:[{options:[{value:"auto",label:"自动",description:"失败时依次切换渠道"},...T.map((s)=>({value:s.id,label:s.name}))]}],onValueChange:(s)=>{let a=s==="auto"?s:T.find((k)=>k.id===s)?.id;if(a)t.onDraft({...t.draft,provider:a})}})})}),(t.draft.provider==="searxng"||t.draft.searxngUrl)&&e(C,{vertical:!0,title:"自建 SearXNG 地址",children:e(u,{id:`${m}-searxng`,"aria-label":"自建 SearXNG 地址",type:"url",maxLength:2000,disabled:l||!t.draft.enabled,value:t.draft.searxngUrl,placeholder:"https://search.example.com",onChange:(s)=>t.onDraft({...t.draft,searxngUrl:s.target.value})})})]}),e(P,{title:"渠道与密钥",description:"检测使用已保存的配置",action:n(c,{type:"button",size:"sm",variant:"ghost",disabled:l,className:"text-dim",onClick:async()=>await t.onCheck("all"),children:[e(ne,{className:w("size-3.5",t.checking==="all"&&"animate-spin"),"aria-hidden":"true"}),t.checking==="all"?"正在检测…":"全部检测"]}),children:T.map((s)=>{let a=s.id,k=a==="searxng"?void 0:t.saved.keys[a],K=k?.source==="environment",W=a==="searxng"?void 0:t.keys[a],h=W==="",v=t.checks[a],L=t.checking==="all"||t.checking===a,b=k?.configured?"已配置密钥":"未配置";if(a==="searxng")b=t.saved.search.searxngUrl?"已配置地址":"未配置地址";if(K)b="来自环境变量";if(h)b="待移除";if(W)b="待保存密钥";let E=v&&!v.ok&&!L?v.error??(v.kind==="search"?v.meta?.failed[0]?.error:v.meta?.error)??"检测失败,请检查配置。":void 0;return n("div",{className:"min-w-0",children:[n(C,{title:s.name,description:n(f,{children:[s.description,K&&" · 请在服务端环境变量中更换或移除",E&&e("span",{role:"status",className:"block break-words text-danger",children:E})]}),children:[L?e(S,{tone:"neutral",pulse:!0,children:"检测中"}):v?e(S,{tone:v.ok?"success":"danger",children:v.ok?`可用 ${v.elapsedMs} ms`:"不可用"}):e("span",{className:w("text-xs",W!==void 0?"text-warning":"text-faint"),children:b}),a!=="searxng"&&!K&&n(f,{children:[e(c,{type:"button",size:"sm",variant:"ghost",disabled:l,"aria-label":`${k?.configured?"更换":"设置"} ${s.name} 密钥`,"aria-expanded":t.editingKey===a,"aria-controls":`${m}-${a}-key-editor`,onClick:()=>t.onEditKey(t.editingKey===a?void 0:a),children:k?.configured?"更换":"设置密钥"}),k?.configured&&!h&&e(c,{type:"button",size:"sm",variant:"ghost",disabled:l,"aria-label":`移除 ${s.name} 密钥`,onClick:()=>{t.onKeys({...t.keys,[a]:""}),t.onEditKey(void 0)},children:"移除"})]}),e(c,{type:"button",size:"sm",variant:"ghost",disabled:l,"aria-label":`检测 ${s.name}`,onClick:async()=>await t.onCheck(a),children:"检测"})]}),a!=="searxng"&&t.editingKey===a&&n("div",{id:`${m}-${a}-key-editor`,className:"flex items-center gap-2 pb-3",children:[e(u,{id:`${m}-${a}-key`,"aria-label":`${s.name} API 密钥`,type:"password",autoComplete:"new-password",maxLength:4000,disabled:l,value:t.keys[a]??"",placeholder:"输入新密钥,保存后生效;只写入,不回显",onChange:(N)=>{let d={...t.keys};if(N.target.value.trim())d[a]=N.target.value;else delete d[a];t.onKeys(d)}}),e(c,{type:"button",size:"sm",variant:"ghost",disabled:l,onClick:()=>{let N={...t.keys};delete N[a],t.onKeys(N),t.onEditKey(void 0)},children:"取消"})]})]},a)})}),n(P,{title:"网络",children:[e(C,{vertical:!0,title:"代理 URL",description:"留空使用服务端环境代理",children:e(u,{id:`${m}-proxy`,"aria-label":"代理 URL",type:"url",maxLength:2000,disabled:l,value:t.draft.proxy,placeholder:"http://127.0.0.1:7890",onChange:(s)=>t.onDraft({...t.draft,proxy:s.target.value})})}),e(C,{vertical:!0,title:"Accept-Language",children:e(u,{id:`${m}-language`,"aria-label":"Accept-Language",maxLength:200,disabled:l,value:t.draft.acceptLanguage,placeholder:"en-US,en;q=0.9",onChange:(s)=>t.onDraft({...t.draft,acceptLanguage:s.target.value})})})]}),n(R,{children:[e("div",{className:"mr-auto min-w-0",children:e(z,{notice:t.notice})}),t.dirty&&e(c,{type:"button",size:"sm",variant:"ghost",disabled:l,onClick:t.onRestore,children:"撤销更改"}),e(c,{form:`${m}-form`,type:"submit",size:"sm",variant:"primary",disabled:l||!t.dirty,children:t.busy==="save"?"保存中…":"保存"})]})]})}function M({connection:t}){let{Button:c}=y(),[u,p]=r(),[x,S]=r(),[R,P]=r({}),[C,w]=r(),[m,l]=r("load"),[s,a]=r(),[k,K]=r({}),[W,h]=r(),[v,L]=r(0),b=i(void 0);o(()=>{let d=new AbortController;return b.current=d,l("load"),h(void 0),p(void 0),S(void 0),P({}),w(void 0),K({}),t.request("/api/plugins/webfetch/settings",{signal:d.signal,cache:v>0?"reload":"default"}).then((g)=>{if(d.signal.aborted)return;p(g),S(D(g))}).catch((g)=>{if(!d.signal.aborted)h({type:"error",text:g instanceof Error?g.message:"加载设置失败,请重试。"})}).finally(()=>{if(!d.signal.aborted)b.current=void 0,l(void 0)}),()=>{d.abort(),b.current?.abort(),b.current=void 0}},[t,v]);async function E(){if(b.current||!u||!x||!A(u,x,R))return;let d=new AbortController;b.current=d,l("save"),h(void 0);try{let g=await t.request("/api/plugins/webfetch/settings",{method:"PATCH",signal:d.signal,headers:{"Content-Type":"application/json"},body:JSON.stringify(G(x,R))});if(d.signal.aborted)return;p(g),S(D(g)),P({}),w(void 0),K({}),h({type:"success",text:"设置已保存。"})}catch(g){if(!d.signal.aborted)h({type:"error",text:g instanceof Error?g.message:"保存失败,请重试。"})}finally{if(!d.signal.aborted)b.current=void 0,l(void 0)}}async function N(d){if(b.current||!u)return;let g=new AbortController;b.current=g,l("test"),a(d),h(void 0);try{let U=await t.request(`/api/plugins/webfetch/test?provider=${d}`,{method:"POST",signal:g.signal});if(g.signal.aborted)return;K((q)=>{let F={...q};for(let B of U.checks)if(B.kind==="search"&&B.provider)F[B.provider]=B;return F})}catch(U){if(!g.signal.aborted)h({type:"error",text:U instanceof Error?U.message:"检测失败,请重试。"})}finally{if(!g.signal.aborted)b.current=void 0,l(void 0),a(void 0)}}if(!u||!x)return n("div",{className:"min-w-0 space-y-3",children:[m==="load"&&e("p",{role:"status",className:"text-sm text-dim",children:"正在加载设置…"}),e(z,{notice:W}),m!=="load"&&e(c,{type:"button",size:"sm",variant:"ghost",onClick:()=>L(v+1),children:"重新加载"})]});return e(I,{saved:u,draft:x,keys:R,editingKey:C,dirty:A(u,x,R),busy:m==="load"?void 0:m,checking:s,checks:k,notice:W,onDraft:(d)=>{S(d),h(void 0)},onKeys:(d)=>{P(d),h(void 0)},onEditKey:w,onSave:E,onCheck:N,onRestore:()=>{S(D(u)),P({}),w(void 0),h(void 0)}})}export{M as default};
1
+ import{o,G,i,r,f,e,n,y,te,ne}from"./chunk-3k9h7a73.js";import{ea}from"./chunk-cxpnj495.js";var T=[{id:"exa",name:"Exa",description:"免密钥 · 综合搜索"},{id:"tavily",name:"Tavily",description:"免密钥 · 支持域名筛选"},{id:"parallel",name:"Parallel",description:"免密钥 · 网页搜索"},{id:"firecrawl",name:"Firecrawl",description:"免密钥 · 网页内容"},{id:"tinyfish",name:"TinyFish",description:"免密钥 · 搜索摘要"},{id:"searxng",name:"SearXNG",description:"免密钥 · 需自建服务"},{id:"brave",name:"Brave",description:"需密钥 · 独立搜索引擎"}];function D(t){return{enabled:t.search.provider!=="off",provider:t.search.provider==="off"?"auto":t.search.provider,searxngUrl:t.search.searxngUrl??"",proxy:t.proxy??"",acceptLanguage:t.acceptLanguage??""}}function I(t,c){return{search:{provider:t.enabled?t.provider:"off",searxngUrl:t.searxngUrl},keys:{...c},proxy:t.proxy,acceptLanguage:t.acceptLanguage}}function A(t,c,u){let p=D(t);if(c.enabled!==p.enabled)return!0;if(c.enabled&&c.provider!==p.provider)return!0;return c.searxngUrl!==p.searxngUrl||c.proxy!==p.proxy||c.acceptLanguage!==p.acceptLanguage||Object.keys(u).length>0}function z({notice:t}){let{cn:c}=y();if(!t)return null;let u=t.type==="success"?ea:te;return n("div",{role:t.type==="error"?"alert":"status",className:c("flex items-start gap-2 text-xs",t.type==="success"?"text-success":"text-danger"),children:[e(u,{className:"mt-0.5 size-4 shrink-0","aria-hidden":"true"}),e("span",{className:"min-w-0 break-words",children:t.text})]})}function q(t){let{Button:c,Input:u,Switch:p,Select:x,StatusChip:S,SettingActions:R,SettingGroup:P,SettingRow:C,cn:w}=y(),m=G(),l=t.busy!==void 0;return n("form",{id:`${m}-form`,className:"min-w-0 space-y-5",onSubmit:async(s)=>{s.preventDefault(),await t.onSave()},children:[n(P,{title:"联网搜索",children:[e(C,{title:"启用搜索",description:"查询会发送至所选搜索服务",children:e(p,{label:"启用联网搜索",disabled:l,checked:t.draft.enabled,onCheckedChange:(s)=>t.onDraft({...t.draft,enabled:s})})}),e(C,{title:"搜索渠道",description:"自动:Exa → Tavily → Parallel → Firecrawl → TinyFish",children:e("div",{className:"w-48",children:e(x,{id:`${m}-provider`,value:t.draft.provider,disabled:l||!t.draft.enabled,className:"min-w-0",groups:[{options:[{value:"auto",label:"自动",description:"失败时依次切换渠道"},...T.map((s)=>({value:s.id,label:s.name}))]}],onValueChange:(s)=>{let a=s==="auto"?s:T.find((k)=>k.id===s)?.id;if(a)t.onDraft({...t.draft,provider:a})}})})}),(t.draft.provider==="searxng"||t.draft.searxngUrl)&&e(C,{vertical:!0,title:"自建 SearXNG 地址",children:e(u,{id:`${m}-searxng`,"aria-label":"自建 SearXNG 地址",type:"url",maxLength:2000,disabled:l||!t.draft.enabled,value:t.draft.searxngUrl,placeholder:"https://search.example.com",onChange:(s)=>t.onDraft({...t.draft,searxngUrl:s.target.value})})})]}),e(P,{title:"渠道与密钥",description:"检测使用已保存的配置",action:n(c,{type:"button",size:"sm",variant:"ghost",disabled:l,className:"text-dim",onClick:async()=>await t.onCheck("all"),children:[e(ne,{className:w("size-3.5",t.checking==="all"&&"animate-spin"),"aria-hidden":"true"}),t.checking==="all"?"正在检测…":"全部检测"]}),children:T.map((s)=>{let a=s.id,k=a==="searxng"?void 0:t.saved.keys[a],K=k?.source==="environment",W=a==="searxng"?void 0:t.keys[a],h=W==="",v=t.checks[a],L=t.checking==="all"||t.checking===a,b=k?.configured?"已配置密钥":"未配置";if(a==="searxng")b=t.saved.search.searxngUrl?"已配置地址":"未配置地址";if(K)b="来自环境变量";if(h)b="待移除";if(W)b="待保存密钥";let E=v&&!v.ok&&!L?v.error??(v.kind==="search"?v.meta?.failed[0]?.error:v.meta?.error)??"检测失败,请检查配置。":void 0;return n("div",{className:"min-w-0",children:[n(C,{title:s.name,description:n(f,{children:[s.description,K&&" · 请在服务端环境变量中更换或移除",E&&e("span",{role:"status",className:"block break-words text-danger",children:E})]}),children:[L?e(S,{tone:"neutral",pulse:!0,children:"检测中"}):v?e(S,{tone:v.ok?"success":"danger",children:v.ok?`可用 ${v.elapsedMs} ms`:"不可用"}):e("span",{className:w("text-xs",W!==void 0?"text-warning":"text-faint"),children:b}),a!=="searxng"&&!K&&n(f,{children:[e(c,{type:"button",size:"sm",variant:"ghost",disabled:l,"aria-label":`${k?.configured?"更换":"设置"} ${s.name} 密钥`,"aria-expanded":t.editingKey===a,"aria-controls":`${m}-${a}-key-editor`,onClick:()=>t.onEditKey(t.editingKey===a?void 0:a),children:k?.configured?"更换":"设置密钥"}),k?.configured&&!h&&e(c,{type:"button",size:"sm",variant:"ghost",disabled:l,"aria-label":`移除 ${s.name} 密钥`,onClick:()=>{t.onKeys({...t.keys,[a]:""}),t.onEditKey(void 0)},children:"移除"})]}),e(c,{type:"button",size:"sm",variant:"ghost",disabled:l,"aria-label":`检测 ${s.name}`,onClick:async()=>await t.onCheck(a),children:"检测"})]}),a!=="searxng"&&t.editingKey===a&&n("div",{id:`${m}-${a}-key-editor`,className:"flex items-center gap-2 pb-3",children:[e(u,{id:`${m}-${a}-key`,"aria-label":`${s.name} API 密钥`,type:"password",autoComplete:"new-password",maxLength:4000,disabled:l,value:t.keys[a]??"",placeholder:"输入新密钥,保存后生效;只写入,不回显",onChange:(N)=>{let d={...t.keys};if(N.target.value.trim())d[a]=N.target.value;else delete d[a];t.onKeys(d)}}),e(c,{type:"button",size:"sm",variant:"ghost",disabled:l,onClick:()=>{let N={...t.keys};delete N[a],t.onKeys(N),t.onEditKey(void 0)},children:"取消"})]})]},a)})}),n(P,{title:"网络",children:[e(C,{vertical:!0,title:"代理 URL",description:"留空使用服务端环境代理",children:e(u,{id:`${m}-proxy`,"aria-label":"代理 URL",type:"url",maxLength:2000,disabled:l,value:t.draft.proxy,placeholder:"http://127.0.0.1:7890",onChange:(s)=>t.onDraft({...t.draft,proxy:s.target.value})})}),e(C,{vertical:!0,title:"Accept-Language",children:e(u,{id:`${m}-language`,"aria-label":"Accept-Language",maxLength:200,disabled:l,value:t.draft.acceptLanguage,placeholder:"en-US,en;q=0.9",onChange:(s)=>t.onDraft({...t.draft,acceptLanguage:s.target.value})})})]}),n(R,{children:[e("div",{className:"mr-auto min-w-0",children:e(z,{notice:t.notice})}),t.dirty&&e(c,{type:"button",size:"sm",variant:"ghost",disabled:l,onClick:t.onRestore,children:"撤销更改"}),e(c,{form:`${m}-form`,type:"submit",size:"sm",variant:"primary",disabled:l||!t.dirty,children:t.busy==="save"?"保存中…":"保存"})]})]})}function O({connection:t}){let{Button:c}=y(),[u,p]=r(),[x,S]=r(),[R,P]=r({}),[C,w]=r(),[m,l]=r("load"),[s,a]=r(),[k,K]=r({}),[W,h]=r(),[v,L]=r(0),b=i(void 0);o(()=>{let d=new AbortController;return b.current=d,l("load"),h(void 0),p(void 0),S(void 0),P({}),w(void 0),K({}),t.request("/api/plugins/webfetch/settings",{signal:d.signal,cache:v>0?"reload":"default"}).then((g)=>{if(d.signal.aborted)return;p(g),S(D(g))}).catch((g)=>{if(!d.signal.aborted)h({type:"error",text:g instanceof Error?g.message:"加载设置失败,请重试。"})}).finally(()=>{if(!d.signal.aborted)b.current=void 0,l(void 0)}),()=>{d.abort(),b.current?.abort(),b.current=void 0}},[t,v]);async function E(){if(b.current||!u||!x||!A(u,x,R))return;let d=new AbortController;b.current=d,l("save"),h(void 0);try{let g=await t.request("/api/plugins/webfetch/settings",{method:"PATCH",signal:d.signal,headers:{"Content-Type":"application/json"},body:JSON.stringify(I(x,R))});if(d.signal.aborted)return;p(g),S(D(g)),P({}),w(void 0),K({}),h({type:"success",text:"设置已保存。"})}catch(g){if(!d.signal.aborted)h({type:"error",text:g instanceof Error?g.message:"保存失败,请重试。"})}finally{if(!d.signal.aborted)b.current=void 0,l(void 0)}}async function N(d){if(b.current||!u)return;let g=new AbortController;b.current=g,l("test"),a(d),h(void 0);try{let U=await t.request(`/api/plugins/webfetch/test?provider=${d}`,{method:"POST",signal:g.signal});if(g.signal.aborted)return;K((M)=>{let F={...M};for(let B of U.checks)if(B.kind==="search"&&B.provider)F[B.provider]=B;return F})}catch(U){if(!g.signal.aborted)h({type:"error",text:U instanceof Error?U.message:"检测失败,请重试。"})}finally{if(!g.signal.aborted)b.current=void 0,l(void 0),a(void 0)}}if(!u||!x)return n("div",{className:"min-w-0 space-y-3",children:[m==="load"&&e("p",{role:"status",className:"text-sm text-dim",children:"正在加载设置…"}),e(z,{notice:W}),m!=="load"&&e(c,{type:"button",size:"sm",variant:"ghost",onClick:()=>L(v+1),children:"重新加载"})]});return e(q,{saved:u,draft:x,keys:R,editingKey:C,dirty:A(u,x,R),busy:m==="load"?void 0:m,checking:s,checks:k,notice:W,onDraft:(d)=>{S(d),h(void 0)},onKeys:(d)=>{P(d),h(void 0)},onEditKey:w,onSave:E,onCheck:N,onRestore:()=>{S(D(u)),P({}),w(void 0),h(void 0)}})}export{O as default};
@@ -0,0 +1 @@
1
+ import{Ro}from"./chunk-3k9h7a73.js";export{Ro as QuestionDock};
package/web/index.html CHANGED
@@ -15,7 +15,7 @@
15
15
  <link rel="icon" href="./icon-1wgy7kzy.svg" type="image/svg+xml" />
16
16
  <link rel="apple-touch-icon" href="./apple-touch-icon-7dkm33qp.png" />
17
17
 
18
- <link rel="stylesheet" crossorigin href="./chunk-swzxq7r3.css"><script type="module" crossorigin src="./chunk-kahab58k.js"></script></head>
18
+ <link rel="stylesheet" crossorigin href="./chunk-0rdgt4jb.css"><script type="module" crossorigin src="./chunk-3k9h7a73.js"></script></head>
19
19
  <body>
20
20
  <div id="root"></div>
21
21
 
package/worker.js CHANGED
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{He,Et,Yr,qt,xi,Ei,Zn,Pi,Ne,ki,Ke,Ri}from"./chunk-c71173py.js";var S="backfill";function c(e){return e.query("SELECT sum((SELECT max(seq) FROM store.entries WHERE session_id = sessions.id)) AS n FROM store.sessions").get()?.n??0}function q(e){let t=Yr(e,S);return t?JSON.parse(t):void 0}function g(e,t){qt(e,S,JSON.stringify(t))}class b{db;indexer;batch;todo;page;state;constructor(e,t,s=500){this.db=e;this.indexer=t;this.batch=s;this.todo=e.query("SELECT session_id FROM main.backfill_todo WHERE ord = ?"),this.page=e.query("SELECT seq, time, body FROM store.entries WHERE session_id = ? AND seq > ? ORDER BY seq LIMIT ?"),this.state=q(e)}get running(){return this.state?.state==="running"}begin(e){this.db.transaction(()=>{let t=this.db.query("SELECT max(id) AS id FROM store.search_queue").get()?.id??0;qt(this.db,"queue_done",t),this.db.run("DELETE FROM main.backfill_todo"),this.db.run("INSERT INTO main.backfill_todo (ord, session_id) SELECT row_number() OVER (ORDER BY updated DESC, id), id FROM store.sessions");let s=this.db.query("SELECT count(*) AS n FROM main.backfill_todo").get()?.n??0,r=c(this.db);this.state={state:s?"running":"done",reason:e,ord:1,seq:-1,total:r,sessionsTotal:s,done:0,sessionsDone:0,startedAt:Date.now()},g(this.db,this.state)})()}step(e){let t=this.state;if(t?.state!=="running")return!1;let s={...t};return this.db.transaction(()=>{let r=this.batch;while(r>0&&s.state==="running"){let n=this.todo.get(s.ord)?.session_id;if(n===void 0){s.state="done",this.db.run("DELETE FROM main.backfill_todo");break}if(s.seq<0)this.indexer.reindex(n,0),s.seq=0;let i=this.page.all(n,s.seq,r);for(let a of i)if(this.indexer.indexRow(n,a.seq,a.time,a.body),s.seq=a.seq,s.done++,r--,performance.now()>e){r=0;break}if(r>0)s.ord++,s.seq=-1,s.sessionsDone++;if(performance.now()>e)break}g(this.db,s)})(),this.state=s,!0}}function M(e,t){return BigInt.asIntN(64,Bun.hash.wyhash(`${e?"B":"M"}${t}`))}class p{db;layout;readEntry;readTitle;previousModel;selectRefs;deleteRefs;insertRef;findDoc;insertDoc;increment;decrement;docRefs;deleteDoc;insertMsg;insertOut;deleteMsg;deleteOut;stats={entries:0,fields:0,bytes:0,newDocs:0,newBytes:0};outChanges=0;constructor(e,t){this.db=e;this.layout=t;this.readEntry=e.query("SELECT time, body FROM store.entries WHERE session_id = ? AND seq = ?"),this.readTitle=e.query("SELECT title, created FROM store.sessions WHERE id = ?"),this.previousModel=e.query("SELECT json_extract(body, '$.model') AS model FROM store.entries WHERE session_id = ? AND seq < ? AND json_extract(body, '$.type') = 'assistant' ORDER BY seq DESC LIMIT 1"),this.selectRefs=e.query("SELECT doc FROM main.ref WHERE session_id = ? AND seq = ?"),this.deleteRefs=e.query("DELETE FROM main.ref WHERE session_id = ? AND seq = ?"),this.insertRef=e.query("INSERT INTO main.ref (session_id, seq, part, doc, kind, tool, err, model, time) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)"),this.findDoc=e.query("SELECT id FROM main.doc WHERE hash = ?"),this.insertDoc=e.query("INSERT INTO main.doc (hash, refs, len, bulk) VALUES (?, 1, ?, ?)"),this.increment=e.query("UPDATE main.doc SET refs = refs + 1 WHERE id = ?"),this.decrement=e.query("UPDATE main.doc SET refs = refs - 1 WHERE id = ?"),this.docRefs=e.query("SELECT refs, bulk FROM main.doc WHERE id = ?"),this.deleteDoc=e.query("DELETE FROM main.doc WHERE id = ?"),this.insertMsg=e.query("INSERT INTO main.fts (rowid, text) VALUES (?, ?)"),this.insertOut=e.query("INSERT INTO main.fts_out (rowid, text) VALUES (?, ?)"),this.deleteMsg=e.query("DELETE FROM main.fts WHERE rowid = ?"),this.deleteOut=e.query("DELETE FROM main.fts_out WHERE rowid = ?")}reindex(e,t){let s=0,r=[];if(t===0){let n=this.readTitle.get(e);if(n)s=n.created,r=Ri(n.title)}else{let n=this.readEntry.get(e,t);if(n)s=n.time,r=this.fields(e,t,n.body)}this.apply(e,t,s,r)}indexRow(e,t,s,r){this.apply(e,t,s,this.fields(e,t,r))}fields(e,t,s){let r;try{r=JSON.parse(s)}catch{return[]}if(!r||typeof r!=="object")return[];let n=Ke(r);if(r.type==="tool_result"&&n.length){let i=this.previousModel.get(e,t)?.model??void 0;if(i)for(let a of n)a.model=i}return n}apply(e,t,s,r){let n=this.selectRefs.all(e,t);if(n.length)this.deleteRefs.run(e,t);this.stats.entries++;for(let i of r){let a=ki(i.kind),l=M(a,i.text);this.stats.fields++,this.stats.bytes+=i.text.length;let o=this.findDoc.get(l)?.id;if(o===void 0){if(o=Number(this.insertDoc.run(l,i.text.length,a?1:0).lastInsertRowid),a)this.insertOut.run(o,Zn(i.text)),this.outChanges++;else this.insertMsg.run(o,this.layout.msg==="trigram"?Pi(i.text):Zn(i.text));this.stats.newDocs++,this.stats.newBytes+=i.text.length}else this.increment.run(o);this.insertRef.run(e,t,i.part,o,Ne[i.kind],i.tool??null,i.err?1:0,i.model??null,s)}for(let{doc:i}of n)this.release(i)}release(e){this.decrement.run(e);let t=this.docRefs.get(e);if(!t||t.refs>0)return;if(this.deleteDoc.run(e),t.bulk)this.deleteOut.run(e),this.outChanges++;else this.deleteMsg.run(e)}}class y{db;page;clearRange;clearTail;upsert;constructor(e){this.db=e;this.page=e.query("SELECT term, doc FROM main.fts_out_vocab WHERE term > ? ORDER BY term LIMIT ?"),this.clearRange=e.query("DELETE FROM main.term WHERE t > ? AND t <= ?"),this.clearTail=e.query("DELETE FROM main.term WHERE t > ?"),this.upsert=e.query("INSERT OR REPLACE INTO main.term (t, n) VALUES (?, ?)")}step(e,t){let s=this.page.all(e,t),r=s.at(-1)?.term;if(s.length<t||r===void 0)this.clearTail.run(e);else this.clearRange.run(e,r);for(let{term:n,doc:i}of s)if(n.length<=Ei)this.upsert.run(n,i);return s.length<t?void 0:r}}var w=2000,x=30000;class T{options;db;layout;reset;indexer;backfill;terms;queueRows;queueMax;sliceMs;backfillSliceMs;queueBatch;termRefreshMs;queueDone;termCursor;termStale;lastTermRefresh=Number.NEGATIVE_INFINITY;rateStart;estimate;closed=!1;constructor(e){this.options=e;let t=xi(e.indexPath,e.storePath,e.features);if(this.db=t.db,this.layout=t.layout,this.reset=t.reset,this.sliceMs=e.sliceMs??20,this.backfillSliceMs=e.backfillSliceMs??200,this.queueBatch=e.queueBatch??200,this.termRefreshMs=e.termRefreshMs??60000,this.indexer=new p(this.db,this.layout),this.terms=new y(this.db),this.backfill=new b(this.db,this.indexer,e.batch??500),this.queueRows=this.db.query("SELECT id, session_id, seq FROM store.search_queue WHERE id > ? ORDER BY id LIMIT ?"),this.queueMax=this.db.query("SELECT max(id) AS id FROM store.search_queue"),!this.backfill.state)this.backfill.begin(this.reset?"rebuild":"initial");this.queueDone=Number(Yr(this.db,"queue_done")??0),this.termStale=Number(Yr(this.db,"term_stale")??0)===1}step(e){if(this.closed)return!1;if(this.drainQueue(e??performance.now()+this.sliceMs))return!0;if(this.backfill.running){this.rateStart??={time:performance.now(),done:this.backfill.state?.done??0};let t=this.indexer.outChanges;if(this.backfill.step(e??performance.now()+this.backfillSliceMs),this.markTerms(t),!this.backfill.running)this.lastTermRefresh=Number.NEGATIVE_INFINITY;return!0}return this.refreshTerms(e??performance.now()+this.sliceMs)}drain(){while(this.step());}drainQueue(e){let t=!1;return this.db.transaction(()=>{let s=this.queueRows.all(this.queueDone,this.queueBatch);if(!s.length)return;t=!0;let r=this.indexer.outChanges,n=new Set,i=this.queueDone;for(let a of s){let l=`${a.seq}\x00${a.session_id}`;if(!n.has(l))n.add(l),this.indexer.reindex(a.session_id,a.seq);if(i=a.id,performance.now()>e)break}qt(this.db,"queue_done",i),this.markTerms(r),this.queueDone=i})(),t}markTerms(e){if(this.indexer.outChanges===e||this.termStale)return;this.termStale=!0,qt(this.db,"term_stale",1)}refreshTerms(e){if(this.termCursor===void 0){if(!this.termStale||performance.now()-this.lastTermRefresh<this.termRefreshMs)return!1;this.termCursor="",this.termStale=!1,this.indexer.outChanges=0,qt(this.db,"term_stale",0)}while(this.termCursor!==void 0&&performance.now()<=e){let t=this.termCursor;this.db.transaction(()=>{this.termCursor=this.terms.step(t,w)})()}if(this.termCursor===void 0)this.lastTermRefresh=performance.now();return!0}status(){let e=this.queueMax.get()?.id??this.queueDone,t=this.backfill.state,s;if(t?.state==="running"&&this.rateStart){let n=(performance.now()-this.rateStart.time)/1000,i=(t.done-this.rateStart.done)/n;if(n>0.5&&i>0)s=Math.max(0,Math.round(Math.max(0,t.total-t.done)/i))}let r=t?{state:t.state,reason:t.reason,total:t.total,done:t.done,sessionsTotal:t.sessionsTotal,sessionsDone:t.sessionsDone,startedAt:t.startedAt}:void 0;if(!this.estimate||performance.now()-this.estimate.time>x)this.estimate={time:performance.now(),entries:c(this.db)};return{queueDone:this.queueDone,lag:Math.max(0,e-this.queueDone),entries:this.estimate.entries,...r?{backfill:r}:{},...s!==void 0?{etaSec:s}:{},layout:this.layout,reset:this.reset}}withIndex(e){return e(this.db)}close(){if(this.closed)return;this.closed=!0,this.db.close()}}var R=1000,v=100;function D(e){let t,s,r,n=!1,i=!1,a=0,l=[],o=(d)=>e.postMessage(d),m=(d)=>{if(i)return;if(r)clearTimeout(r);r=setTimeout(k,d)},E=()=>{if(!s||Atomics.load(s,He)!==1)return;Atomics.store(s,Et,1),Atomics.notify(s,Et);while(Atomics.load(s,He)===1)Atomics.wait(s,He,1,1e4);Atomics.store(s,Et,0)};function k(){if(r=void 0,i||!t)return;E();let d=!1;try{d=t.step()}catch(f){o({type:"error",message:f instanceof Error?f.message:String(f),fatal:!1}),n=!1,m(R);return}let u=performance.now();if(d){if(n=!0,u-a>=v)a=u,o({type:"status",status:t.status()});m(0);return}n=!1,a=u;let h=t.status();o({type:"status",status:h});for(let f of l.splice(0))o({type:"flushed",id:f,status:h});m(R)}e.onmessage=(d)=>{let u=d.data;if(u.type==="init"){s=new Int32Array(u.flags);try{t=new T(u.options)}catch(h){o({type:"error",message:h instanceof Error?h.message:String(h),fatal:!0});return}o({type:"status",status:t.status()}),m(0)}else if(u.type==="dirty"){if(!n)m(0)}else if(u.type==="pause")E();else if(u.type==="flush"){if(l.push(u.id),!n)m(0)}else if(u.type==="stop"){if(i=!0,r)clearTimeout(r);t?.close(),o({type:"stopped"})}}}if(!Bun.isMainThread)D(globalThis);export{T as SearchEngine};
2
+ import{He,Et,Yr,qt,xi,Ei,Zn,Ti,Ne,ki,Ke,Ri}from"./chunk-6mges89p.js";var S="backfill";function c(e){return e.query("SELECT sum((SELECT max(seq) FROM store.entries WHERE session_id = sessions.id)) AS n FROM store.sessions").get()?.n??0}function q(e){let t=Yr(e,S);return t?JSON.parse(t):void 0}function g(e,t){qt(e,S,JSON.stringify(t))}class b{db;indexer;batch;todo;page;state;constructor(e,t,s=500){this.db=e;this.indexer=t;this.batch=s;this.todo=e.query("SELECT session_id FROM main.backfill_todo WHERE ord = ?"),this.page=e.query("SELECT seq, time, body FROM store.entries WHERE session_id = ? AND seq > ? ORDER BY seq LIMIT ?"),this.state=q(e)}get running(){return this.state?.state==="running"}begin(e){this.db.transaction(()=>{let t=this.db.query("SELECT max(id) AS id FROM store.search_queue").get()?.id??0;qt(this.db,"queue_done",t),this.db.run("DELETE FROM main.backfill_todo"),this.db.run("INSERT INTO main.backfill_todo (ord, session_id) SELECT row_number() OVER (ORDER BY updated DESC, id), id FROM store.sessions");let s=this.db.query("SELECT count(*) AS n FROM main.backfill_todo").get()?.n??0,r=c(this.db);this.state={state:s?"running":"done",reason:e,ord:1,seq:-1,total:r,sessionsTotal:s,done:0,sessionsDone:0,startedAt:Date.now()},g(this.db,this.state)})()}step(e){let t=this.state;if(t?.state!=="running")return!1;let s={...t};return this.db.transaction(()=>{let r=this.batch;while(r>0&&s.state==="running"){let n=this.todo.get(s.ord)?.session_id;if(n===void 0){s.state="done",this.db.run("DELETE FROM main.backfill_todo");break}if(s.seq<0)this.indexer.reindex(n,0),s.seq=0;let i=this.page.all(n,s.seq,r);for(let a of i)if(this.indexer.indexRow(n,a.seq,a.time,a.body),s.seq=a.seq,s.done++,r--,performance.now()>e){r=0;break}if(r>0)s.ord++,s.seq=-1,s.sessionsDone++;if(performance.now()>e)break}g(this.db,s)})(),this.state=s,!0}}function M(e,t){return BigInt.asIntN(64,Bun.hash.wyhash(`${e?"B":"M"}${t}`))}class p{db;layout;readEntry;readTitle;previousModel;selectRefs;deleteRefs;insertRef;findDoc;insertDoc;increment;decrement;docRefs;deleteDoc;insertMsg;insertOut;deleteMsg;deleteOut;stats={entries:0,fields:0,bytes:0,newDocs:0,newBytes:0};outChanges=0;constructor(e,t){this.db=e;this.layout=t;this.readEntry=e.query("SELECT time, body FROM store.entries WHERE session_id = ? AND seq = ?"),this.readTitle=e.query("SELECT title, created FROM store.sessions WHERE id = ?"),this.previousModel=e.query("SELECT json_extract(body, '$.model') AS model FROM store.entries WHERE session_id = ? AND seq < ? AND json_extract(body, '$.type') = 'assistant' ORDER BY seq DESC LIMIT 1"),this.selectRefs=e.query("SELECT doc FROM main.ref WHERE session_id = ? AND seq = ?"),this.deleteRefs=e.query("DELETE FROM main.ref WHERE session_id = ? AND seq = ?"),this.insertRef=e.query("INSERT INTO main.ref (session_id, seq, part, doc, kind, tool, err, model, time) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)"),this.findDoc=e.query("SELECT id FROM main.doc WHERE hash = ?"),this.insertDoc=e.query("INSERT INTO main.doc (hash, refs, len, bulk) VALUES (?, 1, ?, ?)"),this.increment=e.query("UPDATE main.doc SET refs = refs + 1 WHERE id = ?"),this.decrement=e.query("UPDATE main.doc SET refs = refs - 1 WHERE id = ?"),this.docRefs=e.query("SELECT refs, bulk FROM main.doc WHERE id = ?"),this.deleteDoc=e.query("DELETE FROM main.doc WHERE id = ?"),this.insertMsg=e.query("INSERT INTO main.fts (rowid, text) VALUES (?, ?)"),this.insertOut=e.query("INSERT INTO main.fts_out (rowid, text) VALUES (?, ?)"),this.deleteMsg=e.query("DELETE FROM main.fts WHERE rowid = ?"),this.deleteOut=e.query("DELETE FROM main.fts_out WHERE rowid = ?")}reindex(e,t){let s=0,r=[];if(t===0){let n=this.readTitle.get(e);if(n)s=n.created,r=Ri(n.title)}else{let n=this.readEntry.get(e,t);if(n)s=n.time,r=this.fields(e,t,n.body)}this.apply(e,t,s,r)}indexRow(e,t,s,r){this.apply(e,t,s,this.fields(e,t,r))}fields(e,t,s){let r;try{r=JSON.parse(s)}catch{return[]}if(!r||typeof r!=="object")return[];let n=Ke(r);if(r.type==="tool_result"&&n.length){let i=this.previousModel.get(e,t)?.model??void 0;if(i)for(let a of n)a.model=i}return n}apply(e,t,s,r){let n=this.selectRefs.all(e,t);if(n.length)this.deleteRefs.run(e,t);this.stats.entries++;for(let i of r){let a=ki(i.kind),l=M(a,i.text);this.stats.fields++,this.stats.bytes+=i.text.length;let o=this.findDoc.get(l)?.id;if(o===void 0){if(o=Number(this.insertDoc.run(l,i.text.length,a?1:0).lastInsertRowid),a)this.insertOut.run(o,Zn(i.text)),this.outChanges++;else this.insertMsg.run(o,this.layout.msg==="trigram"?Ti(i.text):Zn(i.text));this.stats.newDocs++,this.stats.newBytes+=i.text.length}else this.increment.run(o);this.insertRef.run(e,t,i.part,o,Ne[i.kind],i.tool??null,i.err?1:0,i.model??null,s)}for(let{doc:i}of n)this.release(i)}release(e){this.decrement.run(e);let t=this.docRefs.get(e);if(!t||t.refs>0)return;if(this.deleteDoc.run(e),t.bulk)this.deleteOut.run(e),this.outChanges++;else this.deleteMsg.run(e)}}class y{db;page;clearRange;clearTail;upsert;constructor(e){this.db=e;this.page=e.query("SELECT term, doc FROM main.fts_out_vocab WHERE term > ? ORDER BY term LIMIT ?"),this.clearRange=e.query("DELETE FROM main.term WHERE t > ? AND t <= ?"),this.clearTail=e.query("DELETE FROM main.term WHERE t > ?"),this.upsert=e.query("INSERT OR REPLACE INTO main.term (t, n) VALUES (?, ?)")}step(e,t){let s=this.page.all(e,t),r=s.at(-1)?.term;if(s.length<t||r===void 0)this.clearTail.run(e);else this.clearRange.run(e,r);for(let{term:n,doc:i}of s)if(n.length<=Ei)this.upsert.run(n,i);return s.length<t?void 0:r}}var w=2000,x=30000;class T{options;db;layout;reset;indexer;backfill;terms;queueRows;queueMax;sliceMs;backfillSliceMs;queueBatch;termRefreshMs;queueDone;termCursor;termStale;lastTermRefresh=Number.NEGATIVE_INFINITY;rateStart;estimate;closed=!1;constructor(e){this.options=e;let t=xi(e.indexPath,e.storePath,e.features);if(this.db=t.db,this.layout=t.layout,this.reset=t.reset,this.sliceMs=e.sliceMs??20,this.backfillSliceMs=e.backfillSliceMs??200,this.queueBatch=e.queueBatch??200,this.termRefreshMs=e.termRefreshMs??60000,this.indexer=new p(this.db,this.layout),this.terms=new y(this.db),this.backfill=new b(this.db,this.indexer,e.batch??500),this.queueRows=this.db.query("SELECT id, session_id, seq FROM store.search_queue WHERE id > ? ORDER BY id LIMIT ?"),this.queueMax=this.db.query("SELECT max(id) AS id FROM store.search_queue"),!this.backfill.state)this.backfill.begin(this.reset?"rebuild":"initial");this.queueDone=Number(Yr(this.db,"queue_done")??0),this.termStale=Number(Yr(this.db,"term_stale")??0)===1}step(e){if(this.closed)return!1;if(this.drainQueue(e??performance.now()+this.sliceMs))return!0;if(this.backfill.running){this.rateStart??={time:performance.now(),done:this.backfill.state?.done??0};let t=this.indexer.outChanges;if(this.backfill.step(e??performance.now()+this.backfillSliceMs),this.markTerms(t),!this.backfill.running)this.lastTermRefresh=Number.NEGATIVE_INFINITY;return!0}return this.refreshTerms(e??performance.now()+this.sliceMs)}drain(){while(this.step());}drainQueue(e){let t=!1;return this.db.transaction(()=>{let s=this.queueRows.all(this.queueDone,this.queueBatch);if(!s.length)return;t=!0;let r=this.indexer.outChanges,n=new Set,i=this.queueDone;for(let a of s){let l=`${a.seq}\x00${a.session_id}`;if(!n.has(l))n.add(l),this.indexer.reindex(a.session_id,a.seq);if(i=a.id,performance.now()>e)break}qt(this.db,"queue_done",i),this.markTerms(r),this.queueDone=i})(),t}markTerms(e){if(this.indexer.outChanges===e||this.termStale)return;this.termStale=!0,qt(this.db,"term_stale",1)}refreshTerms(e){if(this.termCursor===void 0){if(!this.termStale||performance.now()-this.lastTermRefresh<this.termRefreshMs)return!1;this.termCursor="",this.termStale=!1,this.indexer.outChanges=0,qt(this.db,"term_stale",0)}while(this.termCursor!==void 0&&performance.now()<=e){let t=this.termCursor;this.db.transaction(()=>{this.termCursor=this.terms.step(t,w)})()}if(this.termCursor===void 0)this.lastTermRefresh=performance.now();return!0}status(){let e=this.queueMax.get()?.id??this.queueDone,t=this.backfill.state,s;if(t?.state==="running"&&this.rateStart){let n=(performance.now()-this.rateStart.time)/1000,i=(t.done-this.rateStart.done)/n;if(n>0.5&&i>0)s=Math.max(0,Math.round(Math.max(0,t.total-t.done)/i))}let r=t?{state:t.state,reason:t.reason,total:t.total,done:t.done,sessionsTotal:t.sessionsTotal,sessionsDone:t.sessionsDone,startedAt:t.startedAt}:void 0;if(!this.estimate||performance.now()-this.estimate.time>x)this.estimate={time:performance.now(),entries:c(this.db)};return{queueDone:this.queueDone,lag:Math.max(0,e-this.queueDone),entries:this.estimate.entries,...r?{backfill:r}:{},...s!==void 0?{etaSec:s}:{},layout:this.layout,reset:this.reset}}withIndex(e){return e(this.db)}close(){if(this.closed)return;this.closed=!0,this.db.close()}}var R=1000,v=100;function D(e){let t,s,r,n=!1,i=!1,a=0,l=[],o=(d)=>e.postMessage(d),m=(d)=>{if(i)return;if(r)clearTimeout(r);r=setTimeout(k,d)},E=()=>{if(!s||Atomics.load(s,He)!==1)return;Atomics.store(s,Et,1),Atomics.notify(s,Et);while(Atomics.load(s,He)===1)Atomics.wait(s,He,1,1e4);Atomics.store(s,Et,0)};function k(){if(r=void 0,i||!t)return;E();let d=!1;try{d=t.step()}catch(f){o({type:"error",message:f instanceof Error?f.message:String(f),fatal:!1}),n=!1,m(R);return}let u=performance.now();if(d){if(n=!0,u-a>=v)a=u,o({type:"status",status:t.status()});m(0);return}n=!1,a=u;let h=t.status();o({type:"status",status:h});for(let f of l.splice(0))o({type:"flushed",id:f,status:h});m(R)}e.onmessage=(d)=>{let u=d.data;if(u.type==="init"){s=new Int32Array(u.flags);try{t=new T(u.options)}catch(h){o({type:"error",message:h instanceof Error?h.message:String(h),fatal:!0});return}o({type:"status",status:t.status()}),m(0)}else if(u.type==="dirty"){if(!n)m(0)}else if(u.type==="pause")E();else if(u.type==="flush"){if(l.push(u.id),!n)m(0)}else if(u.type==="stop"){if(i=!0,r)clearTimeout(r);t?.close(),o({type:"stopped"})}}}if(!Bun.isMainThread)D(globalThis);export{T as SearchEngine};
package/chunk-7zkswxvk.js DELETED
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{hr}from"./chunk-a1352w87.js";import{ae}from"./chunk-29qrxygd.js";var t={api:"typesafe-system-one",label:"System One API",url:(e)=>new URL("systemone",`${e.baseUrl.replace(/\/+$/u,"")}/`),payload:(e,r)=>({model:e.id,...r}),output:(e)=>{if(!ae(e))throw Error("System One API returned an unexpected response");return e}},a=(e,r,s)=>hr(t,e,r,s);export{a as classify};
package/chunk-m1eam0s5.js DELETED
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{Ur,Br,Mn}from"./chunk-v3ee9z3f.js";export{Ur as ENV_KEY,Br as ENV_SECRET,Mn as fromEnv};