@axiom-lattice/web 0.1.45 → 0.1.46

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 (52) hide show
  1. package/dist/assets/{_baseUniq-fos__v-j.js → _baseUniq-qbMBIyTd.js} +1 -1
  2. package/dist/assets/{architectureDiagram-VXUJARFQ-5kqxux8H.js → architectureDiagram-VXUJARFQ-BphXwUun.js} +1 -1
  3. package/dist/assets/{blockDiagram-VD42YOAC-Dz8pvq0l.js → blockDiagram-VD42YOAC-DsqAGhiR.js} +1 -1
  4. package/dist/assets/{c4Diagram-YG6GDRKO-CFbsOL_6.js → c4Diagram-YG6GDRKO-B7w_l26n.js} +1 -1
  5. package/dist/assets/channel-DMK8vfnR.js +1 -0
  6. package/dist/assets/{chunk-4BX2VUAB-CJMRYy6x.js → chunk-4BX2VUAB-BZ4oEH4p.js} +1 -1
  7. package/dist/assets/{chunk-55IACEB6-DlYz5YPd.js → chunk-55IACEB6-BHk7ORIv.js} +1 -1
  8. package/dist/assets/{chunk-B4BG7PRW-C0gz3isc.js → chunk-B4BG7PRW-BYwX9gb2.js} +1 -1
  9. package/dist/assets/{chunk-DI55MBZ5-Bi63VE4e.js → chunk-DI55MBZ5-C9BKMe8i.js} +1 -1
  10. package/dist/assets/{chunk-FMBD7UC4-BnAdTBXA.js → chunk-FMBD7UC4-Bd7Pmuva.js} +1 -1
  11. package/dist/assets/{chunk-QN33PNHL-1vqH_xTh.js → chunk-QN33PNHL-90bbi3_o.js} +1 -1
  12. package/dist/assets/{chunk-QZHKN3VN-Cq_UQjmz.js → chunk-QZHKN3VN-Bg8baIOB.js} +1 -1
  13. package/dist/assets/{chunk-TZMSLE5B-D9zS_AKX.js → chunk-TZMSLE5B-CUiQVvCU.js} +1 -1
  14. package/dist/assets/classDiagram-2ON5EDUG-DVtap8Es.js +1 -0
  15. package/dist/assets/classDiagram-v2-WZHVMYZB-DVtap8Es.js +1 -0
  16. package/dist/assets/clone-ZhyLHJqa.js +1 -0
  17. package/dist/assets/{cose-bilkent-S5V4N54A-B1E6ZW_B.js → cose-bilkent-S5V4N54A-I_4_miIf.js} +1 -1
  18. package/dist/assets/{dagre-6UL2VRFP-C9LrSZau.js → dagre-6UL2VRFP-VQQajMr1.js} +1 -1
  19. package/dist/assets/{diagram-PSM6KHXK-COVunNLD.js → diagram-PSM6KHXK-CaMB6O5C.js} +1 -1
  20. package/dist/assets/{diagram-QEK2KX5R-Dthsa58w.js → diagram-QEK2KX5R-D9r4ARCA.js} +1 -1
  21. package/dist/assets/{diagram-S2PKOQOG-SkajAYTH.js → diagram-S2PKOQOG-m0QpYod3.js} +1 -1
  22. package/dist/assets/{erDiagram-Q2GNP2WA-Vph2fUyP.js → erDiagram-Q2GNP2WA-DHHlyRE0.js} +1 -1
  23. package/dist/assets/{flowDiagram-NV44I4VS-CwoHM4n1.js → flowDiagram-NV44I4VS-C8pJ2k7r.js} +1 -1
  24. package/dist/assets/{ganttDiagram-JELNMOA3-DTry4dON.js → ganttDiagram-JELNMOA3-BWsElSb9.js} +1 -1
  25. package/dist/assets/{gitGraphDiagram-NY62KEGX-kONnb8Wk.js → gitGraphDiagram-NY62KEGX-qMKDGi9Q.js} +1 -1
  26. package/dist/assets/{graph-BHer4lrS.js → graph-DMEoyNcY.js} +1 -1
  27. package/dist/assets/{index-CI4VIwKt.js → index-CFHIZWCw.js} +5 -5
  28. package/dist/assets/{index.es-CXonP4cP.js → index.es-BSOH_sZ0.js} +1 -1
  29. package/dist/assets/{infoDiagram-WHAUD3N6-BUee9YSG.js → infoDiagram-WHAUD3N6-CrMjkK2F.js} +1 -1
  30. package/dist/assets/{journeyDiagram-XKPGCS4Q-CkDgFU9A.js → journeyDiagram-XKPGCS4Q-BaWx6-mv.js} +1 -1
  31. package/dist/assets/{kanban-definition-3W4ZIXB7-C91uPb38.js → kanban-definition-3W4ZIXB7-VYSH0qj4.js} +1 -1
  32. package/dist/assets/{layout-D6qUI_4D.js → layout-ER12A4pY.js} +1 -1
  33. package/dist/assets/{min-G9LSEs0p.js → min-B0hr8sho.js} +1 -1
  34. package/dist/assets/{mindmap-definition-VGOIOE7T-CqGCQH6t.js → mindmap-definition-VGOIOE7T-hfJbT9LQ.js} +1 -1
  35. package/dist/assets/{ordinal-RD1zpJqz.js → ordinal-C8oVJqU5.js} +1 -1
  36. package/dist/assets/{pieDiagram-ADFJNKIX-DTHIBXap.js → pieDiagram-ADFJNKIX-Cn_Akq0U.js} +1 -1
  37. package/dist/assets/{quadrantDiagram-AYHSOK5B-BVjSs6wL.js → quadrantDiagram-AYHSOK5B-DxL78nMn.js} +1 -1
  38. package/dist/assets/{requirementDiagram-UZGBJVZJ-BepBwmVH.js → requirementDiagram-UZGBJVZJ-D1jOEW5O.js} +1 -1
  39. package/dist/assets/{sankeyDiagram-TZEHDZUN-D_oOF2kW.js → sankeyDiagram-TZEHDZUN-BnVVl6Az.js} +1 -1
  40. package/dist/assets/{sequenceDiagram-WL72ISMW-COz2-fJF.js → sequenceDiagram-WL72ISMW-CI7Io5Gi.js} +1 -1
  41. package/dist/assets/{stateDiagram-FKZM4ZOC-sjSZL91f.js → stateDiagram-FKZM4ZOC-D6peDpB6.js} +1 -1
  42. package/dist/assets/stateDiagram-v2-4FDKWEC3-DxnVGK0H.js +1 -0
  43. package/dist/assets/{timeline-definition-IT6M3QCI-CPOpleC2.js → timeline-definition-IT6M3QCI-CjFRzkWD.js} +1 -1
  44. package/dist/assets/{treemap-KMMF4GRG-CaNzAX1Q.js → treemap-KMMF4GRG-Cb29EFPz.js} +1 -1
  45. package/dist/assets/{xychartDiagram-PRI3JC2R-d-w5E6LQ.js → xychartDiagram-PRI3JC2R-B5w4Bc3R.js} +1 -1
  46. package/dist/index.html +1 -1
  47. package/package.json +2 -2
  48. package/dist/assets/channel-cCnbmeWZ.js +0 -1
  49. package/dist/assets/classDiagram-2ON5EDUG-BQYTzWN4.js +0 -1
  50. package/dist/assets/classDiagram-v2-WZHVMYZB-BQYTzWN4.js +0 -1
  51. package/dist/assets/clone-ByLRvZf7.js +0 -1
  52. package/dist/assets/stateDiagram-v2-4FDKWEC3-f6UwL56_.js +0 -1
@@ -1,4 +1,4 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/dagre-6UL2VRFP-C9LrSZau.js","assets/graph-BHer4lrS.js","assets/_baseUniq-fos__v-j.js","assets/layout-D6qUI_4D.js","assets/min-G9LSEs0p.js","assets/clone-ByLRvZf7.js","assets/cose-bilkent-S5V4N54A-B1E6ZW_B.js","assets/cytoscape.esm-BQaXIfA_.js","assets/c4Diagram-YG6GDRKO-CFbsOL_6.js","assets/chunk-TZMSLE5B-D9zS_AKX.js","assets/flowDiagram-NV44I4VS-CwoHM4n1.js","assets/chunk-FMBD7UC4-BnAdTBXA.js","assets/chunk-55IACEB6-DlYz5YPd.js","assets/chunk-QN33PNHL-1vqH_xTh.js","assets/channel-cCnbmeWZ.js","assets/erDiagram-Q2GNP2WA-Vph2fUyP.js","assets/gitGraphDiagram-NY62KEGX-kONnb8Wk.js","assets/chunk-4BX2VUAB-CJMRYy6x.js","assets/chunk-QZHKN3VN-Cq_UQjmz.js","assets/treemap-KMMF4GRG-CaNzAX1Q.js","assets/infoDiagram-WHAUD3N6-BUee9YSG.js","assets/pieDiagram-ADFJNKIX-DTHIBXap.js","assets/ordinal-RD1zpJqz.js","assets/xychartDiagram-PRI3JC2R-d-w5E6LQ.js","assets/requirementDiagram-UZGBJVZJ-BepBwmVH.js","assets/sequenceDiagram-WL72ISMW-COz2-fJF.js","assets/classDiagram-2ON5EDUG-BQYTzWN4.js","assets/chunk-B4BG7PRW-C0gz3isc.js","assets/classDiagram-v2-WZHVMYZB-BQYTzWN4.js","assets/stateDiagram-FKZM4ZOC-sjSZL91f.js","assets/chunk-DI55MBZ5-Bi63VE4e.js","assets/stateDiagram-v2-4FDKWEC3-f6UwL56_.js","assets/journeyDiagram-XKPGCS4Q-CkDgFU9A.js","assets/mindmap-definition-VGOIOE7T-CqGCQH6t.js","assets/kanban-definition-3W4ZIXB7-C91uPb38.js","assets/sankeyDiagram-TZEHDZUN-D_oOF2kW.js","assets/diagram-S2PKOQOG-SkajAYTH.js","assets/diagram-QEK2KX5R-Dthsa58w.js","assets/blockDiagram-VD42YOAC-Dz8pvq0l.js","assets/architectureDiagram-VXUJARFQ-5kqxux8H.js","assets/diagram-PSM6KHXK-COVunNLD.js"])))=>i.map(i=>d[i]);
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/dagre-6UL2VRFP-VQQajMr1.js","assets/graph-DMEoyNcY.js","assets/_baseUniq-qbMBIyTd.js","assets/layout-ER12A4pY.js","assets/min-B0hr8sho.js","assets/clone-ZhyLHJqa.js","assets/cose-bilkent-S5V4N54A-I_4_miIf.js","assets/cytoscape.esm-BQaXIfA_.js","assets/c4Diagram-YG6GDRKO-B7w_l26n.js","assets/chunk-TZMSLE5B-CUiQVvCU.js","assets/flowDiagram-NV44I4VS-C8pJ2k7r.js","assets/chunk-FMBD7UC4-Bd7Pmuva.js","assets/chunk-55IACEB6-BHk7ORIv.js","assets/chunk-QN33PNHL-90bbi3_o.js","assets/channel-DMK8vfnR.js","assets/erDiagram-Q2GNP2WA-DHHlyRE0.js","assets/gitGraphDiagram-NY62KEGX-qMKDGi9Q.js","assets/chunk-4BX2VUAB-BZ4oEH4p.js","assets/chunk-QZHKN3VN-Bg8baIOB.js","assets/treemap-KMMF4GRG-Cb29EFPz.js","assets/infoDiagram-WHAUD3N6-CrMjkK2F.js","assets/pieDiagram-ADFJNKIX-Cn_Akq0U.js","assets/ordinal-C8oVJqU5.js","assets/xychartDiagram-PRI3JC2R-B5w4Bc3R.js","assets/requirementDiagram-UZGBJVZJ-D1jOEW5O.js","assets/sequenceDiagram-WL72ISMW-CI7Io5Gi.js","assets/classDiagram-2ON5EDUG-DVtap8Es.js","assets/chunk-B4BG7PRW-BYwX9gb2.js","assets/classDiagram-v2-WZHVMYZB-DVtap8Es.js","assets/stateDiagram-FKZM4ZOC-D6peDpB6.js","assets/chunk-DI55MBZ5-C9BKMe8i.js","assets/stateDiagram-v2-4FDKWEC3-DxnVGK0H.js","assets/journeyDiagram-XKPGCS4Q-BaWx6-mv.js","assets/mindmap-definition-VGOIOE7T-hfJbT9LQ.js","assets/kanban-definition-3W4ZIXB7-VYSH0qj4.js","assets/sankeyDiagram-TZEHDZUN-BnVVl6Az.js","assets/diagram-S2PKOQOG-m0QpYod3.js","assets/diagram-QEK2KX5R-D9r4ARCA.js","assets/blockDiagram-VD42YOAC-DsqAGhiR.js","assets/architectureDiagram-VXUJARFQ-BphXwUun.js","assets/diagram-PSM6KHXK-CaMB6O5C.js"])))=>i.map(i=>d[i]);
2
2
  var mAt=Object.defineProperty;var AAt=(e,t,n)=>t in e?mAt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Dn=(e,t,n)=>AAt(e,typeof t!="symbol"?t+"":t,n);function kGe(e,t){for(var n=0;n<t.length;n++){const r=t[n];if(typeof r!="string"&&!Array.isArray(r)){for(const a in r)if(a!=="default"&&!(a in e)){const i=Object.getOwnPropertyDescriptor(r,a);i&&Object.defineProperty(e,a,i.get?i:{enumerable:!0,get:()=>r[a]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const a of document.querySelectorAll('link[rel="modulepreload"]'))r(a);new MutationObserver(a=>{for(const i of a)if(i.type==="childList")for(const o of i.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&r(o)}).observe(document,{childList:!0,subtree:!0});function n(a){const i={};return a.integrity&&(i.integrity=a.integrity),a.referrerPolicy&&(i.referrerPolicy=a.referrerPolicy),a.crossOrigin==="use-credentials"?i.credentials="include":a.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function r(a){if(a.ep)return;a.ep=!0;const i=n(a);fetch(a.href,i)}})();var AT=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Us(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var YF={exports:{}},Q_={},KF={exports:{}},li={};/**
3
3
  * @license React
4
4
  * react.production.min.js
@@ -1211,8 +1211,8 @@ Please report this to https://github.com/markedjs/marked.`,t){let a="<p>An error
1211
1211
  node : x:${e.x} y:${e.y} w:${e.width} h:${e.height}`);const r=e.x,a=e.y,i=Math.abs(r-n.x),o=e.width/2;let l=n.x<t.x?o-i:o+i;const s=e.height/2,c=Math.abs(t.y-n.y),u=Math.abs(t.x-n.x);if(Math.abs(a-t.y)*o>Math.abs(r-t.x)*s){let d=n.y<t.y?t.y-s-a:a-s-t.y;l=u*d/c;const f={x:n.x<t.x?n.x+l:n.x-u+l,y:n.y<t.y?n.y+c-d:n.y-c+d};return l===0&&(f.x=t.x,f.y=t.y),u===0&&(f.x=t.x),c===0&&(f.y=t.y),fn.debug(`abc89 top/bottom calc, Q ${c}, q ${d}, R ${u}, r ${l}`,f),f}else{n.x<t.x?l=t.x-o-r:l=r-o-t.x;let d=c*l/u,f=n.x<t.x?n.x+u-l:n.x-u+l,p=n.y<t.y?n.y+d:n.y-d;return fn.debug(`sides calc abc89, Q ${c}, q ${d}, R ${u}, r ${l}`,{_x:f,_y:p}),l===0&&(f=t.x,p=t.y),u===0&&(f=t.x),c===0&&(p=t.y),{x:f,y:p}}},"intersection"),DCe=Ae((e,t)=>{fn.warn("abc88 cutPathAtIntersect",e,t);let n=[],r=e[0],a=!1;return e.forEach(i=>{if(fn.info("abc88 checking point",i,t),!Q2n(t,i)&&!a){const o=Y2n(t,r,i);fn.debug("abc88 inside",i,r,o),fn.debug("abc88 intersection",o,t);let l=!1;n.forEach(s=>{l=l||s.x===o.x&&s.y===o.y}),n.some(s=>s.x===o.x&&s.y===o.y)?fn.warn("abc88 no intersect",o,n):n.push(o),a=!0}else fn.warn("abc88 outside",i,r),r=i,a||n.push(i)}),fn.debug("returning points",n),n},"cutPathAtIntersect");function Fit(e){const t=[],n=[];for(let r=1;r<e.length-1;r++){const a=e[r-1],i=e[r],o=e[r+1];(a.x===i.x&&i.y===o.y&&Math.abs(i.x-o.x)>5&&Math.abs(i.y-a.y)>5||a.y===i.y&&i.x===o.x&&Math.abs(i.x-a.x)>5&&Math.abs(i.y-o.y)>5)&&(t.push(i),n.push(r))}return{cornerPoints:t,cornerPointPositions:n}}Ae(Fit,"extractCornerPoints");var BCe=Ae(function(e,t,n){const r=t.x-e.x,a=t.y-e.y,i=Math.sqrt(r*r+a*a),o=n/i;return{x:t.x-o*r,y:t.y-o*a}},"findAdjacentPoint"),K2n=Ae(function(e){const{cornerPointPositions:t}=Fit(e),n=[];for(let r=0;r<e.length;r++)if(t.includes(r)){const a=e[r-1],i=e[r+1],o=e[r],l=BCe(a,o,5),s=BCe(i,o,5),c=s.x-l.x,u=s.y-l.y;n.push(l);const d=Math.sqrt(2)*2;let f={x:o.x,y:o.y};if(Math.abs(i.x-a.x)>10&&Math.abs(i.y-a.y)>=10){fn.debug("Corner point fixing",Math.abs(i.x-a.x),Math.abs(i.y-a.y));const p=5;o.x===l.x?f={x:c<0?l.x-p+d:l.x+p-d,y:u<0?l.y-d:l.y+d}:f={x:c<0?l.x-d:l.x+d,y:u<0?l.y-p+d:l.y+p-d}}else fn.debug("Corner point skipping fixing",Math.abs(i.x-a.x),Math.abs(i.y-a.y));n.push(f,s)}else n.push(e[r]);return n},"fixCorners"),X2n=Ae((e,t,n)=>{const r=e-t-n,a=2,i=2,o=a+i,l=Math.floor(r/o),s=Array(l).fill(`${a} ${i}`).join(" ");return`0 ${t} ${s} ${n}`},"generateDashArray"),Z2n=Ae(function(e,t,n,r,a,i,o,l=!1){var M;const{handDrawnSeed:s}=co();let c=t.points,u=!1;const d=a;var f=i;const p=[];for(const D in t.cssCompiledStyles)frt(D)||p.push(t.cssCompiledStyles[D]);fn.debug("UIO intersect check",t.points,f.x,d.x),f.intersect&&d.intersect&&!l&&(c=c.slice(1,t.points.length-1),c.unshift(d.intersect(c[0])),fn.debug("Last point UIO",t.start,"-->",t.end,c[c.length-1],f,f.intersect(c[c.length-1])),c.push(f.intersect(c[c.length-1])));const h=btoa(JSON.stringify(c));t.toCluster&&(fn.info("to cluster abc88",n.get(t.toCluster)),c=DCe(t.points,n.get(t.toCluster).node),u=!0),t.fromCluster&&(fn.debug("from cluster abc88",n.get(t.fromCluster),JSON.stringify(c,null,2)),c=DCe(c.reverse(),n.get(t.fromCluster).node).reverse(),u=!0);let g=c.filter(D=>!Number.isNaN(D.y));g=K2n(g);let m=gO;switch(m=jx,t.curve){case"linear":m=jx;break;case"basis":m=gO;break;case"cardinal":m=htt;break;case"bumpX":m=ctt;break;case"bumpY":m=utt;break;case"catmullRom":m=mtt;break;case"monotoneX":m=Stt;break;case"monotoneY":m=xtt;break;case"natural":m=wtt;break;case"step":m=Ctt;break;case"stepAfter":m=Itt;break;case"stepBefore":m=Ttt;break;default:m=gO}const{x:A,y:v}=idn(t),y=ltt().x(A).y(v).curve(m);let _;switch(t.thickness){case"normal":_="edge-thickness-normal";break;case"thick":_="edge-thickness-thick";break;case"invisible":_="edge-thickness-invisible";break;default:_="edge-thickness-normal"}switch(t.pattern){case"solid":_+=" edge-pattern-solid";break;case"dotted":_+=" edge-pattern-dotted";break;case"dashed":_+=" edge-pattern-dashed";break;default:_+=" edge-pattern-solid"}let x,S=t.curve==="rounded"?Uit(zit(g,t),5):y(g);const E=Array.isArray(t.style)?t.style:[t.style];let w=E.find(D=>D==null?void 0:D.startsWith("stroke:")),T=!1;if(t.look==="handDrawn"){const D=vr.svg(e);Object.assign([],g);const B=D.path(S,{roughness:.3,seed:s});_+=" transition",x=ba(B).select("path").attr("id",t.id).attr("class"," "+_+(t.classes?" "+t.classes:"")).attr("style",E?E.reduce((P,U)=>P+";"+U,""):"");let $=x.attr("d");x.attr("d",$),e.node().appendChild(x.node())}else{const D=p.join(";"),B=E?E.reduce((z,W)=>z+W+";",""):"";let $="";t.animate&&($=" edge-animation-fast"),t.animation&&($=" edge-animation-"+t.animation);const P=(D?D+";"+B+";":B)+";"+(E?E.reduce((z,W)=>z+";"+W,""):"");x=e.append("path").attr("d",S).attr("id",t.id).attr("class"," "+_+(t.classes?" "+t.classes:"")+($??"")).attr("style",P),w=(M=P.match(/stroke:([^;]+)/))==null?void 0:M[1],T=t.animate===!0||!!t.animation||D.includes("animation");const U=x.node(),H=typeof U.getTotalLength=="function"?U.getTotalLength():0,G=eCe[t.arrowTypeStart]||0,F=eCe[t.arrowTypeEnd]||0;if(t.look==="neo"&&!T){const W=`stroke-dasharray: ${t.pattern==="dotted"||t.pattern==="dashed"?X2n(H,G,F):`0 ${G} ${H-G-F} ${F}`}; stroke-dashoffset: 0;`;x.attr("style",W+x.attr("style"))}}x.attr("data-edge",!0),x.attr("data-et","edge"),x.attr("data-id",t.id),x.attr("data-points",h),t.showPoints&&g.forEach(D=>{e.append("circle").style("stroke","red").style("fill","red").attr("r",1).attr("cx",D.x).attr("cy",D.y)});let N="";(co().flowchart.arrowMarkerAbsolute||co().state.arrowMarkerAbsolute)&&(N=window.location.protocol+"//"+window.location.host+window.location.pathname+window.location.search,N=N.replace(/\(/g,"\\(").replace(/\)/g,"\\)")),fn.info("arrowTypeStart",t.arrowTypeStart),fn.info("arrowTypeEnd",t.arrowTypeEnd),G2n(x,t,N,o,r,w);const R=Math.floor(c.length/2),k=c[R];wh.isLabelCoordinateInPath(k,x.attr("d"))||(u=!0);let O={};return u&&(O.updatedPath=c),O.originalPath=t.points,O},"insertEdge");function Uit(e,t){if(e.length<2)return"";let n="";const r=e.length,a=1e-5;for(let i=0;i<r;i++){const o=e[i],l=e[i-1],s=e[i+1];if(i===0)n+=`M${o.x},${o.y}`;else if(i===r-1)n+=`L${o.x},${o.y}`;else{const c=o.x-l.x,u=o.y-l.y,d=s.x-o.x,f=s.y-o.y,p=Math.hypot(c,u),h=Math.hypot(d,f);if(p<a||h<a){n+=`L${o.x},${o.y}`;continue}const g=c/p,m=u/p,A=d/h,v=f/h,y=g*A+m*v,_=Math.max(-1,Math.min(1,y)),x=Math.acos(_);if(x<a||Math.abs(Math.PI-x)<a){n+=`L${o.x},${o.y}`;continue}const S=Math.min(t/Math.sin(x/2),p/2,h/2),E=o.x-g*S,w=o.y-m*S,T=o.x+A*S,N=o.y+v*S;n+=`L${E},${w}`,n+=`Q${o.x},${o.y} ${T},${N}`}}return n}Ae(Uit,"generateRoundedPath");function ole(e,t){if(!e||!t)return{angle:0,deltaX:0,deltaY:0};const n=t.x-e.x,r=t.y-e.y;return{angle:Math.atan2(r,n),deltaX:n,deltaY:r}}Ae(ole,"calculateDeltaAndAngle");function zit(e,t){const n=e.map(a=>({...a}));if(e.length>=2&&iu[t.arrowTypeStart]){const a=iu[t.arrowTypeStart],i=e[0],o=e[1],{angle:l}=ole(i,o),s=a*Math.cos(l),c=a*Math.sin(l);n[0].x=i.x+s,n[0].y=i.y+c}const r=e.length;if(r>=2&&iu[t.arrowTypeEnd]){const a=iu[t.arrowTypeEnd],i=e[r-1],o=e[r-2],{angle:l}=ole(o,i),s=a*Math.cos(l),c=a*Math.sin(l);n[r-1].x=i.x-s,n[r-1].y=i.y-c}return n}Ae(zit,"applyMarkerOffsetsToPoints");var J2n=Ae((e,t,n,r)=>{t.forEach(a=>{ggn[a](e,n,r)})},"insertMarkers"),egn=Ae((e,t,n)=>{fn.trace("Making markers for ",n),e.append("defs").append("marker").attr("id",n+"_"+t+"-extensionStart").attr("class","marker extension "+t).attr("refX",18).attr("refY",7).attr("markerWidth",190).attr("markerHeight",240).attr("orient","auto").append("path").attr("d","M 1,7 L18,13 V 1 Z"),e.append("defs").append("marker").attr("id",n+"_"+t+"-extensionEnd").attr("class","marker extension "+t).attr("refX",1).attr("refY",7).attr("markerWidth",20).attr("markerHeight",28).attr("orient","auto").append("path").attr("d","M 1,1 V 13 L18,7 Z")},"extension"),tgn=Ae((e,t,n)=>{e.append("defs").append("marker").attr("id",n+"_"+t+"-compositionStart").attr("class","marker composition "+t).attr("refX",18).attr("refY",7).attr("markerWidth",190).attr("markerHeight",240).attr("orient","auto").append("path").attr("d","M 18,7 L9,13 L1,7 L9,1 Z"),e.append("defs").append("marker").attr("id",n+"_"+t+"-compositionEnd").attr("class","marker composition "+t).attr("refX",1).attr("refY",7).attr("markerWidth",20).attr("markerHeight",28).attr("orient","auto").append("path").attr("d","M 18,7 L9,13 L1,7 L9,1 Z")},"composition"),ngn=Ae((e,t,n)=>{e.append("defs").append("marker").attr("id",n+"_"+t+"-aggregationStart").attr("class","marker aggregation "+t).attr("refX",18).attr("refY",7).attr("markerWidth",190).attr("markerHeight",240).attr("orient","auto").append("path").attr("d","M 18,7 L9,13 L1,7 L9,1 Z"),e.append("defs").append("marker").attr("id",n+"_"+t+"-aggregationEnd").attr("class","marker aggregation "+t).attr("refX",1).attr("refY",7).attr("markerWidth",20).attr("markerHeight",28).attr("orient","auto").append("path").attr("d","M 18,7 L9,13 L1,7 L9,1 Z")},"aggregation"),rgn=Ae((e,t,n)=>{e.append("defs").append("marker").attr("id",n+"_"+t+"-dependencyStart").attr("class","marker dependency "+t).attr("refX",6).attr("refY",7).attr("markerWidth",190).attr("markerHeight",240).attr("orient","auto").append("path").attr("d","M 5,7 L9,13 L1,7 L9,1 Z"),e.append("defs").append("marker").attr("id",n+"_"+t+"-dependencyEnd").attr("class","marker dependency "+t).attr("refX",13).attr("refY",7).attr("markerWidth",20).attr("markerHeight",28).attr("orient","auto").append("path").attr("d","M 18,7 L9,13 L14,7 L9,1 Z")},"dependency"),agn=Ae((e,t,n)=>{e.append("defs").append("marker").attr("id",n+"_"+t+"-lollipopStart").attr("class","marker lollipop "+t).attr("refX",13).attr("refY",7).attr("markerWidth",190).attr("markerHeight",240).attr("orient","auto").append("circle").attr("stroke","black").attr("fill","transparent").attr("cx",7).attr("cy",7).attr("r",6),e.append("defs").append("marker").attr("id",n+"_"+t+"-lollipopEnd").attr("class","marker lollipop "+t).attr("refX",1).attr("refY",7).attr("markerWidth",190).attr("markerHeight",240).attr("orient","auto").append("circle").attr("stroke","black").attr("fill","transparent").attr("cx",7).attr("cy",7).attr("r",6)},"lollipop"),ign=Ae((e,t,n)=>{e.append("marker").attr("id",n+"_"+t+"-pointEnd").attr("class","marker "+t).attr("viewBox","0 0 10 10").attr("refX",5).attr("refY",5).attr("markerUnits","userSpaceOnUse").attr("markerWidth",8).attr("markerHeight",8).attr("orient","auto").append("path").attr("d","M 0 0 L 10 5 L 0 10 z").attr("class","arrowMarkerPath").style("stroke-width",1).style("stroke-dasharray","1,0"),e.append("marker").attr("id",n+"_"+t+"-pointStart").attr("class","marker "+t).attr("viewBox","0 0 10 10").attr("refX",4.5).attr("refY",5).attr("markerUnits","userSpaceOnUse").attr("markerWidth",8).attr("markerHeight",8).attr("orient","auto").append("path").attr("d","M 0 5 L 10 10 L 10 0 z").attr("class","arrowMarkerPath").style("stroke-width",1).style("stroke-dasharray","1,0")},"point"),ogn=Ae((e,t,n)=>{e.append("marker").attr("id",n+"_"+t+"-circleEnd").attr("class","marker "+t).attr("viewBox","0 0 10 10").attr("refX",11).attr("refY",5).attr("markerUnits","userSpaceOnUse").attr("markerWidth",11).attr("markerHeight",11).attr("orient","auto").append("circle").attr("cx","5").attr("cy","5").attr("r","5").attr("class","arrowMarkerPath").style("stroke-width",1).style("stroke-dasharray","1,0"),e.append("marker").attr("id",n+"_"+t+"-circleStart").attr("class","marker "+t).attr("viewBox","0 0 10 10").attr("refX",-1).attr("refY",5).attr("markerUnits","userSpaceOnUse").attr("markerWidth",11).attr("markerHeight",11).attr("orient","auto").append("circle").attr("cx","5").attr("cy","5").attr("r","5").attr("class","arrowMarkerPath").style("stroke-width",1).style("stroke-dasharray","1,0")},"circle"),lgn=Ae((e,t,n)=>{e.append("marker").attr("id",n+"_"+t+"-crossEnd").attr("class","marker cross "+t).attr("viewBox","0 0 11 11").attr("refX",12).attr("refY",5.2).attr("markerUnits","userSpaceOnUse").attr("markerWidth",11).attr("markerHeight",11).attr("orient","auto").append("path").attr("d","M 1,1 l 9,9 M 10,1 l -9,9").attr("class","arrowMarkerPath").style("stroke-width",2).style("stroke-dasharray","1,0"),e.append("marker").attr("id",n+"_"+t+"-crossStart").attr("class","marker cross "+t).attr("viewBox","0 0 11 11").attr("refX",-1).attr("refY",5.2).attr("markerUnits","userSpaceOnUse").attr("markerWidth",11).attr("markerHeight",11).attr("orient","auto").append("path").attr("d","M 1,1 l 9,9 M 10,1 l -9,9").attr("class","arrowMarkerPath").style("stroke-width",2).style("stroke-dasharray","1,0")},"cross"),sgn=Ae((e,t,n)=>{e.append("defs").append("marker").attr("id",n+"_"+t+"-barbEnd").attr("refX",19).attr("refY",7).attr("markerWidth",20).attr("markerHeight",14).attr("markerUnits","userSpaceOnUse").attr("orient","auto").append("path").attr("d","M 19,7 L9,13 L14,7 L9,1 Z")},"barb"),cgn=Ae((e,t,n)=>{e.append("defs").append("marker").attr("id",n+"_"+t+"-onlyOneStart").attr("class","marker onlyOne "+t).attr("refX",0).attr("refY",9).attr("markerWidth",18).attr("markerHeight",18).attr("orient","auto").append("path").attr("d","M9,0 L9,18 M15,0 L15,18"),e.append("defs").append("marker").attr("id",n+"_"+t+"-onlyOneEnd").attr("class","marker onlyOne "+t).attr("refX",18).attr("refY",9).attr("markerWidth",18).attr("markerHeight",18).attr("orient","auto").append("path").attr("d","M3,0 L3,18 M9,0 L9,18")},"only_one"),ugn=Ae((e,t,n)=>{const r=e.append("defs").append("marker").attr("id",n+"_"+t+"-zeroOrOneStart").attr("class","marker zeroOrOne "+t).attr("refX",0).attr("refY",9).attr("markerWidth",30).attr("markerHeight",18).attr("orient","auto");r.append("circle").attr("fill","white").attr("cx",21).attr("cy",9).attr("r",6),r.append("path").attr("d","M9,0 L9,18");const a=e.append("defs").append("marker").attr("id",n+"_"+t+"-zeroOrOneEnd").attr("class","marker zeroOrOne "+t).attr("refX",30).attr("refY",9).attr("markerWidth",30).attr("markerHeight",18).attr("orient","auto");a.append("circle").attr("fill","white").attr("cx",9).attr("cy",9).attr("r",6),a.append("path").attr("d","M21,0 L21,18")},"zero_or_one"),dgn=Ae((e,t,n)=>{e.append("defs").append("marker").attr("id",n+"_"+t+"-oneOrMoreStart").attr("class","marker oneOrMore "+t).attr("refX",18).attr("refY",18).attr("markerWidth",45).attr("markerHeight",36).attr("orient","auto").append("path").attr("d","M0,18 Q 18,0 36,18 Q 18,36 0,18 M42,9 L42,27"),e.append("defs").append("marker").attr("id",n+"_"+t+"-oneOrMoreEnd").attr("class","marker oneOrMore "+t).attr("refX",27).attr("refY",18).attr("markerWidth",45).attr("markerHeight",36).attr("orient","auto").append("path").attr("d","M3,9 L3,27 M9,18 Q27,0 45,18 Q27,36 9,18")},"one_or_more"),fgn=Ae((e,t,n)=>{const r=e.append("defs").append("marker").attr("id",n+"_"+t+"-zeroOrMoreStart").attr("class","marker zeroOrMore "+t).attr("refX",18).attr("refY",18).attr("markerWidth",57).attr("markerHeight",36).attr("orient","auto");r.append("circle").attr("fill","white").attr("cx",48).attr("cy",18).attr("r",6),r.append("path").attr("d","M0,18 Q18,0 36,18 Q18,36 0,18");const a=e.append("defs").append("marker").attr("id",n+"_"+t+"-zeroOrMoreEnd").attr("class","marker zeroOrMore "+t).attr("refX",39).attr("refY",18).attr("markerWidth",57).attr("markerHeight",36).attr("orient","auto");a.append("circle").attr("fill","white").attr("cx",9).attr("cy",18).attr("r",6),a.append("path").attr("d","M21,18 Q39,0 57,18 Q39,36 21,18")},"zero_or_more"),pgn=Ae((e,t,n)=>{e.append("defs").append("marker").attr("id",n+"_"+t+"-requirement_arrowEnd").attr("refX",20).attr("refY",10).attr("markerWidth",20).attr("markerHeight",20).attr("orient","auto").append("path").attr("d",`M0,0
1212
1212
  L20,10
1213
1213
  M20,10
1214
- L0,20`)},"requirement_arrow"),hgn=Ae((e,t,n)=>{const r=e.append("defs").append("marker").attr("id",n+"_"+t+"-requirement_containsStart").attr("refX",0).attr("refY",10).attr("markerWidth",20).attr("markerHeight",20).attr("orient","auto").append("g");r.append("circle").attr("cx",10).attr("cy",10).attr("r",9).attr("fill","none"),r.append("line").attr("x1",1).attr("x2",19).attr("y1",10).attr("y2",10),r.append("line").attr("y1",1).attr("y2",19).attr("x1",10).attr("x2",10)},"requirement_contains"),ggn={extension:egn,composition:tgn,aggregation:ngn,dependency:rgn,lollipop:agn,point:ign,circle:ogn,cross:lgn,barb:sgn,only_one:cgn,zero_or_one:ugn,one_or_more:dgn,zero_or_more:fgn,requirement_arrow:pgn,requirement_contains:hgn},mgn=J2n,Agn={common:X8,getConfig:hu,insertCluster:w2n,insertEdge:Z2n,insertEdgeLabel:W2n,insertMarkers:mgn,insertNode:$it,interpolateToCurve:F1e,labelHelper:oa,log:fn,positionEdgeLabel:q2n},Xx={},Hit=Ae(e=>{for(const t of e)Xx[t.name]=t},"registerLayoutLoaders"),vgn=Ae(()=>{Hit([{name:"dagre",loader:Ae(async()=>await Pi(()=>import("./dagre-6UL2VRFP-C9LrSZau.js"),__vite__mapDeps([0,1,2,3,4,5])),"loader")},{name:"cose-bilkent",loader:Ae(async()=>await Pi(()=>import("./cose-bilkent-S5V4N54A-B1E6ZW_B.js"),__vite__mapDeps([6,7])),"loader")}])},"registerDefaultLayoutLoaders");vgn();var Wdr=Ae(async(e,t)=>{if(!(e.layoutAlgorithm in Xx))throw new Error(`Unknown layout algorithm: ${e.layoutAlgorithm}`);const n=Xx[e.layoutAlgorithm];return(await n.loader()).render(e,t,Agn,{algorithm:n.algorithm})},"render"),qdr=Ae((e="",{fallback:t="dagre"}={})=>{if(e in Xx)return e;if(t in Xx)return fn.warn(`Layout algorithm ${e} is not registered. Using ${t} as fallback.`),t;throw new Error(`Both layout algorithms ${e} and ${t} are not registered.`)},"getRegisteredLayoutAlgorithm"),ygn=yrt(Object.keys,Object),bgn=Object.prototype,_gn=bgn.hasOwnProperty;function jit(e){if(!YB(e))return ygn(e);var t=[];for(var n in Object(e))_gn.call(e,n)&&n!="constructor"&&t.push(n);return t}var lle=A5(Rg,"DataView"),sle=A5(Rg,"Promise"),cle=A5(Rg,"Set"),ule=A5(Rg,"WeakMap"),PCe="[object Map]",Sgn="[object Object]",$Ce="[object Promise]",FCe="[object Set]",UCe="[object WeakMap]",zCe="[object DataView]",xgn=m5(lle),Egn=m5(Yx),wgn=m5(sle),Cgn=m5(cle),Tgn=m5(ule),W2=g5;(lle&&W2(new lle(new ArrayBuffer(1)))!=zCe||Yx&&W2(new Yx)!=PCe||sle&&W2(sle.resolve())!=$Ce||cle&&W2(new cle)!=FCe||ule&&W2(new ule)!=UCe)&&(W2=function(e){var t=g5(e),n=t==Sgn?e.constructor:void 0,r=n?m5(n):"";if(r)switch(r){case xgn:return zCe;case Egn:return PCe;case wgn:return $Ce;case Cgn:return FCe;case Tgn:return UCe}return t});var Ign="[object Map]",Rgn="[object Set]",Ngn=Object.prototype,Ogn=Ngn.hasOwnProperty;function HCe(e){if(e==null)return!0;if(zw(e)&&(W0(e)||typeof e=="string"||typeof e.splice=="function"||KB(e)||P1e(e)||bk(e)))return!e.length;var t=W2(e);if(t==Ign||t==Rgn)return!e.size;if(YB(e))return!jit(e).length;for(var n in e)if(Ogn.call(e,n))return!1;return!0}var Git="c4",Mgn=Ae(e=>/^\s*C4Context|C4Container|C4Component|C4Dynamic|C4Deployment/.test(e),"detector"),kgn=Ae(async()=>{const{diagram:e}=await Pi(async()=>{const{diagram:t}=await import("./c4Diagram-YG6GDRKO-CFbsOL_6.js");return{diagram:t}},__vite__mapDeps([8,9]));return{id:Git,diagram:e}},"loader"),Lgn={id:Git,detector:Mgn,loader:kgn},Dgn=Lgn,Vit="flowchart",Bgn=Ae((e,t)=>{var n,r;return((n=t==null?void 0:t.flowchart)==null?void 0:n.defaultRenderer)==="dagre-wrapper"||((r=t==null?void 0:t.flowchart)==null?void 0:r.defaultRenderer)==="elk"?!1:/^\s*graph/.test(e)},"detector"),Pgn=Ae(async()=>{const{diagram:e}=await Pi(async()=>{const{diagram:t}=await import("./flowDiagram-NV44I4VS-CwoHM4n1.js");return{diagram:t}},__vite__mapDeps([10,11,12,13,14]));return{id:Vit,diagram:e}},"loader"),$gn={id:Vit,detector:Bgn,loader:Pgn},Fgn=$gn,Wit="flowchart-v2",Ugn=Ae((e,t)=>{var n,r,a;return((n=t==null?void 0:t.flowchart)==null?void 0:n.defaultRenderer)==="dagre-d3"?!1:(((r=t==null?void 0:t.flowchart)==null?void 0:r.defaultRenderer)==="elk"&&(t.layout="elk"),/^\s*graph/.test(e)&&((a=t==null?void 0:t.flowchart)==null?void 0:a.defaultRenderer)==="dagre-wrapper"?!0:/^\s*flowchart/.test(e))},"detector"),zgn=Ae(async()=>{const{diagram:e}=await Pi(async()=>{const{diagram:t}=await import("./flowDiagram-NV44I4VS-CwoHM4n1.js");return{diagram:t}},__vite__mapDeps([10,11,12,13,14]));return{id:Wit,diagram:e}},"loader"),Hgn={id:Wit,detector:Ugn,loader:zgn},jgn=Hgn,qit="er",Ggn=Ae(e=>/^\s*erDiagram/.test(e),"detector"),Vgn=Ae(async()=>{const{diagram:e}=await Pi(async()=>{const{diagram:t}=await import("./erDiagram-Q2GNP2WA-Vph2fUyP.js");return{diagram:t}},__vite__mapDeps([15,12,13,14]));return{id:qit,diagram:e}},"loader"),Wgn={id:qit,detector:Ggn,loader:Vgn},qgn=Wgn,Qit="gitGraph",Qgn=Ae(e=>/^\s*gitGraph/.test(e),"detector"),Ygn=Ae(async()=>{const{diagram:e}=await Pi(async()=>{const{diagram:t}=await import("./gitGraphDiagram-NY62KEGX-kONnb8Wk.js");return{diagram:t}},__vite__mapDeps([16,17,18,19,4,2]));return{id:Qit,diagram:e}},"loader"),Kgn={id:Qit,detector:Qgn,loader:Ygn},Xgn=Kgn,Yit="gantt",Zgn=Ae(e=>/^\s*gantt/.test(e),"detector"),Jgn=Ae(async()=>{const{diagram:e}=await Pi(async()=>{const{diagram:t}=await import("./ganttDiagram-JELNMOA3-DTry4dON.js");return{diagram:t}},[]);return{id:Yit,diagram:e}},"loader"),e0n={id:Yit,detector:Zgn,loader:Jgn},t0n=e0n,Kit="info",n0n=Ae(e=>/^\s*info/.test(e),"detector"),r0n=Ae(async()=>{const{diagram:e}=await Pi(async()=>{const{diagram:t}=await import("./infoDiagram-WHAUD3N6-BUee9YSG.js");return{diagram:t}},__vite__mapDeps([20,19,4,2]));return{id:Kit,diagram:e}},"loader"),a0n={id:Kit,detector:n0n,loader:r0n},Xit="pie",i0n=Ae(e=>/^\s*pie/.test(e),"detector"),o0n=Ae(async()=>{const{diagram:e}=await Pi(async()=>{const{diagram:t}=await import("./pieDiagram-ADFJNKIX-DTHIBXap.js");return{diagram:t}},__vite__mapDeps([21,17,19,4,2,22]));return{id:Xit,diagram:e}},"loader"),l0n={id:Xit,detector:i0n,loader:o0n},Zit="quadrantChart",s0n=Ae(e=>/^\s*quadrantChart/.test(e),"detector"),c0n=Ae(async()=>{const{diagram:e}=await Pi(async()=>{const{diagram:t}=await import("./quadrantDiagram-AYHSOK5B-BVjSs6wL.js");return{diagram:t}},[]);return{id:Zit,diagram:e}},"loader"),u0n={id:Zit,detector:s0n,loader:c0n},d0n=u0n,Jit="xychart",f0n=Ae(e=>/^\s*xychart(-beta)?/.test(e),"detector"),p0n=Ae(async()=>{const{diagram:e}=await Pi(async()=>{const{diagram:t}=await import("./xychartDiagram-PRI3JC2R-d-w5E6LQ.js");return{diagram:t}},__vite__mapDeps([23,22]));return{id:Jit,diagram:e}},"loader"),h0n={id:Jit,detector:f0n,loader:p0n},g0n=h0n,eot="requirement",m0n=Ae(e=>/^\s*requirement(Diagram)?/.test(e),"detector"),A0n=Ae(async()=>{const{diagram:e}=await Pi(async()=>{const{diagram:t}=await import("./requirementDiagram-UZGBJVZJ-BepBwmVH.js");return{diagram:t}},__vite__mapDeps([24,12,13]));return{id:eot,diagram:e}},"loader"),v0n={id:eot,detector:m0n,loader:A0n},y0n=v0n,tot="sequence",b0n=Ae(e=>/^\s*sequenceDiagram/.test(e),"detector"),_0n=Ae(async()=>{const{diagram:e}=await Pi(async()=>{const{diagram:t}=await import("./sequenceDiagram-WL72ISMW-COz2-fJF.js");return{diagram:t}},__vite__mapDeps([25,9,18]));return{id:tot,diagram:e}},"loader"),S0n={id:tot,detector:b0n,loader:_0n},x0n=S0n,not="class",E0n=Ae((e,t)=>{var n;return((n=t==null?void 0:t.class)==null?void 0:n.defaultRenderer)==="dagre-wrapper"?!1:/^\s*classDiagram/.test(e)},"detector"),w0n=Ae(async()=>{const{diagram:e}=await Pi(async()=>{const{diagram:t}=await import("./classDiagram-2ON5EDUG-BQYTzWN4.js");return{diagram:t}},__vite__mapDeps([26,27,11,12,13]));return{id:not,diagram:e}},"loader"),C0n={id:not,detector:E0n,loader:w0n},T0n=C0n,rot="classDiagram",I0n=Ae((e,t)=>{var n;return/^\s*classDiagram/.test(e)&&((n=t==null?void 0:t.class)==null?void 0:n.defaultRenderer)==="dagre-wrapper"?!0:/^\s*classDiagram-v2/.test(e)},"detector"),R0n=Ae(async()=>{const{diagram:e}=await Pi(async()=>{const{diagram:t}=await import("./classDiagram-v2-WZHVMYZB-BQYTzWN4.js");return{diagram:t}},__vite__mapDeps([28,27,11,12,13]));return{id:rot,diagram:e}},"loader"),N0n={id:rot,detector:I0n,loader:R0n},O0n=N0n,aot="state",M0n=Ae((e,t)=>{var n;return((n=t==null?void 0:t.state)==null?void 0:n.defaultRenderer)==="dagre-wrapper"?!1:/^\s*stateDiagram/.test(e)},"detector"),k0n=Ae(async()=>{const{diagram:e}=await Pi(async()=>{const{diagram:t}=await import("./stateDiagram-FKZM4ZOC-sjSZL91f.js");return{diagram:t}},__vite__mapDeps([29,30,12,13,1,2,3,4]));return{id:aot,diagram:e}},"loader"),L0n={id:aot,detector:M0n,loader:k0n},D0n=L0n,iot="stateDiagram",B0n=Ae((e,t)=>{var n;return!!(/^\s*stateDiagram-v2/.test(e)||/^\s*stateDiagram/.test(e)&&((n=t==null?void 0:t.state)==null?void 0:n.defaultRenderer)==="dagre-wrapper")},"detector"),P0n=Ae(async()=>{const{diagram:e}=await Pi(async()=>{const{diagram:t}=await import("./stateDiagram-v2-4FDKWEC3-f6UwL56_.js");return{diagram:t}},__vite__mapDeps([31,30,12,13]));return{id:iot,diagram:e}},"loader"),$0n={id:iot,detector:B0n,loader:P0n},F0n=$0n,oot="journey",U0n=Ae(e=>/^\s*journey/.test(e),"detector"),z0n=Ae(async()=>{const{diagram:e}=await Pi(async()=>{const{diagram:t}=await import("./journeyDiagram-XKPGCS4Q-CkDgFU9A.js");return{diagram:t}},__vite__mapDeps([32,9,11]));return{id:oot,diagram:e}},"loader"),H0n={id:oot,detector:U0n,loader:z0n},j0n=H0n,G0n=Ae((e,t,n)=>{fn.debug(`rendering svg for syntax error
1215
- `);const r=Xcn(t),a=r.append("g");r.attr("viewBox","0 0 2412 512"),_et(r,100,512,!0),a.append("path").attr("class","error-icon").attr("d","m411.313,123.313c6.25-6.25 6.25-16.375 0-22.625s-16.375-6.25-22.625,0l-32,32-9.375,9.375-20.688-20.688c-12.484-12.5-32.766-12.5-45.25,0l-16,16c-1.261,1.261-2.304,2.648-3.31,4.051-21.739-8.561-45.324-13.426-70.065-13.426-105.867,0-192,86.133-192,192s86.133,192 192,192 192-86.133 192-192c0-24.741-4.864-48.327-13.426-70.065 1.402-1.007 2.79-2.049 4.051-3.31l16-16c12.5-12.492 12.5-32.758 0-45.25l-20.688-20.688 9.375-9.375 32.001-31.999zm-219.313,100.687c-52.938,0-96,43.063-96,96 0,8.836-7.164,16-16,16s-16-7.164-16-16c0-70.578 57.422-128 128-128 8.836,0 16,7.164 16,16s-7.164,16-16,16z"),a.append("path").attr("class","error-icon").attr("d","m459.02,148.98c-6.25-6.25-16.375-6.25-22.625,0s-6.25,16.375 0,22.625l16,16c3.125,3.125 7.219,4.688 11.313,4.688 4.094,0 8.188-1.563 11.313-4.688 6.25-6.25 6.25-16.375 0-22.625l-16.001-16z"),a.append("path").attr("class","error-icon").attr("d","m340.395,75.605c3.125,3.125 7.219,4.688 11.313,4.688 4.094,0 8.188-1.563 11.313-4.688 6.25-6.25 6.25-16.375 0-22.625l-16-16c-6.25-6.25-16.375-6.25-22.625,0s-6.25,16.375 0,22.625l15.999,16z"),a.append("path").attr("class","error-icon").attr("d","m400,64c8.844,0 16-7.164 16-16v-32c0-8.836-7.156-16-16-16-8.844,0-16,7.164-16,16v32c0,8.836 7.156,16 16,16z"),a.append("path").attr("class","error-icon").attr("d","m496,96.586h-32c-8.844,0-16,7.164-16,16 0,8.836 7.156,16 16,16h32c8.844,0 16-7.164 16-16 0-8.836-7.156-16-16-16z"),a.append("path").attr("class","error-icon").attr("d","m436.98,75.605c3.125,3.125 7.219,4.688 11.313,4.688 4.094,0 8.188-1.563 11.313-4.688l32-32c6.25-6.25 6.25-16.375 0-22.625s-16.375-6.25-22.625,0l-32,32c-6.251,6.25-6.251,16.375-0.001,22.625z"),a.append("text").attr("class","error-text").attr("x",1440).attr("y",250).attr("font-size","150px").style("text-anchor","middle").text("Syntax error in text"),a.append("text").attr("class","error-text").attr("x",1250).attr("y",400).attr("font-size","100px").style("text-anchor","middle").text(`mermaid version ${n}`)},"draw"),lot={draw:G0n},V0n=lot,W0n={db:{},renderer:lot,parser:{parse:Ae(()=>{},"parse")}},q0n=W0n,sot="flowchart-elk",Q0n=Ae((e,t={})=>{var n;return/^\s*flowchart-elk/.test(e)||/^\s*(flowchart|graph)/.test(e)&&((n=t==null?void 0:t.flowchart)==null?void 0:n.defaultRenderer)==="elk"?(t.layout="elk",!0):!1},"detector"),Y0n=Ae(async()=>{const{diagram:e}=await Pi(async()=>{const{diagram:t}=await import("./flowDiagram-NV44I4VS-CwoHM4n1.js");return{diagram:t}},__vite__mapDeps([10,11,12,13,14]));return{id:sot,diagram:e}},"loader"),K0n={id:sot,detector:Q0n,loader:Y0n},X0n=K0n,cot="timeline",Z0n=Ae(e=>/^\s*timeline/.test(e),"detector"),J0n=Ae(async()=>{const{diagram:e}=await Pi(async()=>{const{diagram:t}=await import("./timeline-definition-IT6M3QCI-CPOpleC2.js");return{diagram:t}},[]);return{id:cot,diagram:e}},"loader"),e1n={id:cot,detector:Z0n,loader:J0n},t1n=e1n,uot="mindmap",n1n=Ae(e=>/^\s*mindmap/.test(e),"detector"),r1n=Ae(async()=>{const{diagram:e}=await Pi(async()=>{const{diagram:t}=await import("./mindmap-definition-VGOIOE7T-CqGCQH6t.js");return{diagram:t}},__vite__mapDeps([33,12,13]));return{id:uot,diagram:e}},"loader"),a1n={id:uot,detector:n1n,loader:r1n},i1n=a1n,dot="kanban",o1n=Ae(e=>/^\s*kanban/.test(e),"detector"),l1n=Ae(async()=>{const{diagram:e}=await Pi(async()=>{const{diagram:t}=await import("./kanban-definition-3W4ZIXB7-C91uPb38.js");return{diagram:t}},__vite__mapDeps([34,11]));return{id:dot,diagram:e}},"loader"),s1n={id:dot,detector:o1n,loader:l1n},c1n=s1n,fot="sankey",u1n=Ae(e=>/^\s*sankey(-beta)?/.test(e),"detector"),d1n=Ae(async()=>{const{diagram:e}=await Pi(async()=>{const{diagram:t}=await import("./sankeyDiagram-TZEHDZUN-D_oOF2kW.js");return{diagram:t}},__vite__mapDeps([35,22]));return{id:fot,diagram:e}},"loader"),f1n={id:fot,detector:u1n,loader:d1n},p1n=f1n,pot="packet",h1n=Ae(e=>/^\s*packet(-beta)?/.test(e),"detector"),g1n=Ae(async()=>{const{diagram:e}=await Pi(async()=>{const{diagram:t}=await import("./diagram-S2PKOQOG-SkajAYTH.js");return{diagram:t}},__vite__mapDeps([36,17,19,4,2]));return{id:pot,diagram:e}},"loader"),m1n={id:pot,detector:h1n,loader:g1n},hot="radar",A1n=Ae(e=>/^\s*radar-beta/.test(e),"detector"),v1n=Ae(async()=>{const{diagram:e}=await Pi(async()=>{const{diagram:t}=await import("./diagram-QEK2KX5R-Dthsa58w.js");return{diagram:t}},__vite__mapDeps([37,17,19,4,2]));return{id:hot,diagram:e}},"loader"),y1n={id:hot,detector:A1n,loader:v1n},got="block",b1n=Ae(e=>/^\s*block(-beta)?/.test(e),"detector"),_1n=Ae(async()=>{const{diagram:e}=await Pi(async()=>{const{diagram:t}=await import("./blockDiagram-VD42YOAC-Dz8pvq0l.js");return{diagram:t}},__vite__mapDeps([38,11,5,1,2,14]));return{id:got,diagram:e}},"loader"),S1n={id:got,detector:b1n,loader:_1n},x1n=S1n,mot="architecture",E1n=Ae(e=>/^\s*architecture/.test(e),"detector"),w1n=Ae(async()=>{const{diagram:e}=await Pi(async()=>{const{diagram:t}=await import("./architectureDiagram-VXUJARFQ-5kqxux8H.js");return{diagram:t}},__vite__mapDeps([39,17,19,4,2,7]));return{id:mot,diagram:e}},"loader"),C1n={id:mot,detector:E1n,loader:w1n},T1n=C1n,Aot="treemap",I1n=Ae(e=>/^\s*treemap/.test(e),"detector"),R1n=Ae(async()=>{const{diagram:e}=await Pi(async()=>{const{diagram:t}=await import("./diagram-PSM6KHXK-COVunNLD.js");return{diagram:t}},__vite__mapDeps([40,13,17,19,4,2,22]));return{id:Aot,diagram:e}},"loader"),N1n={id:Aot,detector:I1n,loader:R1n},jCe=!1,iP=Ae(()=>{jCe||(jCe=!0,ZM("error",q0n,e=>e.toLowerCase().trim()==="error"),ZM("---",{db:{clear:Ae(()=>{},"clear")},styles:{},renderer:{draw:Ae(()=>{},"draw")},parser:{parse:Ae(()=>{throw new Error("Diagrams beginning with --- are not valid. If you were trying to use a YAML front-matter, please ensure that you've correctly opened and closed the YAML front-matter with un-indented `---` blocks")},"parse")},init:Ae(()=>null,"init")},e=>e.toLowerCase().trimStart().startsWith("---")),moe(X0n,i1n,T1n),moe(Dgn,c1n,O0n,T0n,qgn,t0n,a0n,l0n,y0n,x0n,jgn,Fgn,t1n,Xgn,F0n,D0n,j0n,d0n,p1n,m1n,g0n,x1n,y1n,N1n))},"addDiagrams"),O1n=Ae(async()=>{fn.debug("Loading registered diagrams");const t=(await Promise.allSettled(Object.entries(z4).map(async([n,{detector:r,loader:a}])=>{if(a)try{boe(n)}catch{try{const{diagram:i,id:o}=await a();ZM(o,i,r)}catch(i){throw fn.error(`Failed to load external diagram with key ${n}. Removing from detectors.`),delete z4[n],i}}}))).filter(n=>n.status==="rejected");if(t.length>0){fn.error(`Failed to load ${t.length} external diagrams`);for(const n of t)fn.error(n);throw new Error(`Failed to load ${t.length} external diagrams`)}},"loadRegisteredDiagrams"),M1n="graphics-document document";function vot(e,t){e.attr("role",M1n),t!==""&&e.attr("aria-roledescription",t)}Ae(vot,"setA11yDiagramInfo");function yot(e,t,n,r){if(e.insert!==void 0){if(n){const a=`chart-desc-${r}`;e.attr("aria-describedby",a),e.insert("desc",":first-child").attr("id",a).text(n)}if(t){const a=`chart-title-${r}`;e.attr("aria-labelledby",a),e.insert("title",":first-child").attr("id",a).text(t)}}}Ae(yot,"addSVGa11yTitleDescription");var w4,dle=(w4=class{constructor(t,n,r,a,i){this.type=t,this.text=n,this.db=r,this.parser=a,this.renderer=i}static async fromText(t,n={}){var c,u;const r=hu(),a=n1e(t,r);t=qpn(t)+`
1214
+ L0,20`)},"requirement_arrow"),hgn=Ae((e,t,n)=>{const r=e.append("defs").append("marker").attr("id",n+"_"+t+"-requirement_containsStart").attr("refX",0).attr("refY",10).attr("markerWidth",20).attr("markerHeight",20).attr("orient","auto").append("g");r.append("circle").attr("cx",10).attr("cy",10).attr("r",9).attr("fill","none"),r.append("line").attr("x1",1).attr("x2",19).attr("y1",10).attr("y2",10),r.append("line").attr("y1",1).attr("y2",19).attr("x1",10).attr("x2",10)},"requirement_contains"),ggn={extension:egn,composition:tgn,aggregation:ngn,dependency:rgn,lollipop:agn,point:ign,circle:ogn,cross:lgn,barb:sgn,only_one:cgn,zero_or_one:ugn,one_or_more:dgn,zero_or_more:fgn,requirement_arrow:pgn,requirement_contains:hgn},mgn=J2n,Agn={common:X8,getConfig:hu,insertCluster:w2n,insertEdge:Z2n,insertEdgeLabel:W2n,insertMarkers:mgn,insertNode:$it,interpolateToCurve:F1e,labelHelper:oa,log:fn,positionEdgeLabel:q2n},Xx={},Hit=Ae(e=>{for(const t of e)Xx[t.name]=t},"registerLayoutLoaders"),vgn=Ae(()=>{Hit([{name:"dagre",loader:Ae(async()=>await Pi(()=>import("./dagre-6UL2VRFP-VQQajMr1.js"),__vite__mapDeps([0,1,2,3,4,5])),"loader")},{name:"cose-bilkent",loader:Ae(async()=>await Pi(()=>import("./cose-bilkent-S5V4N54A-I_4_miIf.js"),__vite__mapDeps([6,7])),"loader")}])},"registerDefaultLayoutLoaders");vgn();var Wdr=Ae(async(e,t)=>{if(!(e.layoutAlgorithm in Xx))throw new Error(`Unknown layout algorithm: ${e.layoutAlgorithm}`);const n=Xx[e.layoutAlgorithm];return(await n.loader()).render(e,t,Agn,{algorithm:n.algorithm})},"render"),qdr=Ae((e="",{fallback:t="dagre"}={})=>{if(e in Xx)return e;if(t in Xx)return fn.warn(`Layout algorithm ${e} is not registered. Using ${t} as fallback.`),t;throw new Error(`Both layout algorithms ${e} and ${t} are not registered.`)},"getRegisteredLayoutAlgorithm"),ygn=yrt(Object.keys,Object),bgn=Object.prototype,_gn=bgn.hasOwnProperty;function jit(e){if(!YB(e))return ygn(e);var t=[];for(var n in Object(e))_gn.call(e,n)&&n!="constructor"&&t.push(n);return t}var lle=A5(Rg,"DataView"),sle=A5(Rg,"Promise"),cle=A5(Rg,"Set"),ule=A5(Rg,"WeakMap"),PCe="[object Map]",Sgn="[object Object]",$Ce="[object Promise]",FCe="[object Set]",UCe="[object WeakMap]",zCe="[object DataView]",xgn=m5(lle),Egn=m5(Yx),wgn=m5(sle),Cgn=m5(cle),Tgn=m5(ule),W2=g5;(lle&&W2(new lle(new ArrayBuffer(1)))!=zCe||Yx&&W2(new Yx)!=PCe||sle&&W2(sle.resolve())!=$Ce||cle&&W2(new cle)!=FCe||ule&&W2(new ule)!=UCe)&&(W2=function(e){var t=g5(e),n=t==Sgn?e.constructor:void 0,r=n?m5(n):"";if(r)switch(r){case xgn:return zCe;case Egn:return PCe;case wgn:return $Ce;case Cgn:return FCe;case Tgn:return UCe}return t});var Ign="[object Map]",Rgn="[object Set]",Ngn=Object.prototype,Ogn=Ngn.hasOwnProperty;function HCe(e){if(e==null)return!0;if(zw(e)&&(W0(e)||typeof e=="string"||typeof e.splice=="function"||KB(e)||P1e(e)||bk(e)))return!e.length;var t=W2(e);if(t==Ign||t==Rgn)return!e.size;if(YB(e))return!jit(e).length;for(var n in e)if(Ogn.call(e,n))return!1;return!0}var Git="c4",Mgn=Ae(e=>/^\s*C4Context|C4Container|C4Component|C4Dynamic|C4Deployment/.test(e),"detector"),kgn=Ae(async()=>{const{diagram:e}=await Pi(async()=>{const{diagram:t}=await import("./c4Diagram-YG6GDRKO-B7w_l26n.js");return{diagram:t}},__vite__mapDeps([8,9]));return{id:Git,diagram:e}},"loader"),Lgn={id:Git,detector:Mgn,loader:kgn},Dgn=Lgn,Vit="flowchart",Bgn=Ae((e,t)=>{var n,r;return((n=t==null?void 0:t.flowchart)==null?void 0:n.defaultRenderer)==="dagre-wrapper"||((r=t==null?void 0:t.flowchart)==null?void 0:r.defaultRenderer)==="elk"?!1:/^\s*graph/.test(e)},"detector"),Pgn=Ae(async()=>{const{diagram:e}=await Pi(async()=>{const{diagram:t}=await import("./flowDiagram-NV44I4VS-C8pJ2k7r.js");return{diagram:t}},__vite__mapDeps([10,11,12,13,14]));return{id:Vit,diagram:e}},"loader"),$gn={id:Vit,detector:Bgn,loader:Pgn},Fgn=$gn,Wit="flowchart-v2",Ugn=Ae((e,t)=>{var n,r,a;return((n=t==null?void 0:t.flowchart)==null?void 0:n.defaultRenderer)==="dagre-d3"?!1:(((r=t==null?void 0:t.flowchart)==null?void 0:r.defaultRenderer)==="elk"&&(t.layout="elk"),/^\s*graph/.test(e)&&((a=t==null?void 0:t.flowchart)==null?void 0:a.defaultRenderer)==="dagre-wrapper"?!0:/^\s*flowchart/.test(e))},"detector"),zgn=Ae(async()=>{const{diagram:e}=await Pi(async()=>{const{diagram:t}=await import("./flowDiagram-NV44I4VS-C8pJ2k7r.js");return{diagram:t}},__vite__mapDeps([10,11,12,13,14]));return{id:Wit,diagram:e}},"loader"),Hgn={id:Wit,detector:Ugn,loader:zgn},jgn=Hgn,qit="er",Ggn=Ae(e=>/^\s*erDiagram/.test(e),"detector"),Vgn=Ae(async()=>{const{diagram:e}=await Pi(async()=>{const{diagram:t}=await import("./erDiagram-Q2GNP2WA-DHHlyRE0.js");return{diagram:t}},__vite__mapDeps([15,12,13,14]));return{id:qit,diagram:e}},"loader"),Wgn={id:qit,detector:Ggn,loader:Vgn},qgn=Wgn,Qit="gitGraph",Qgn=Ae(e=>/^\s*gitGraph/.test(e),"detector"),Ygn=Ae(async()=>{const{diagram:e}=await Pi(async()=>{const{diagram:t}=await import("./gitGraphDiagram-NY62KEGX-qMKDGi9Q.js");return{diagram:t}},__vite__mapDeps([16,17,18,19,4,2]));return{id:Qit,diagram:e}},"loader"),Kgn={id:Qit,detector:Qgn,loader:Ygn},Xgn=Kgn,Yit="gantt",Zgn=Ae(e=>/^\s*gantt/.test(e),"detector"),Jgn=Ae(async()=>{const{diagram:e}=await Pi(async()=>{const{diagram:t}=await import("./ganttDiagram-JELNMOA3-BWsElSb9.js");return{diagram:t}},[]);return{id:Yit,diagram:e}},"loader"),e0n={id:Yit,detector:Zgn,loader:Jgn},t0n=e0n,Kit="info",n0n=Ae(e=>/^\s*info/.test(e),"detector"),r0n=Ae(async()=>{const{diagram:e}=await Pi(async()=>{const{diagram:t}=await import("./infoDiagram-WHAUD3N6-CrMjkK2F.js");return{diagram:t}},__vite__mapDeps([20,19,4,2]));return{id:Kit,diagram:e}},"loader"),a0n={id:Kit,detector:n0n,loader:r0n},Xit="pie",i0n=Ae(e=>/^\s*pie/.test(e),"detector"),o0n=Ae(async()=>{const{diagram:e}=await Pi(async()=>{const{diagram:t}=await import("./pieDiagram-ADFJNKIX-Cn_Akq0U.js");return{diagram:t}},__vite__mapDeps([21,17,19,4,2,22]));return{id:Xit,diagram:e}},"loader"),l0n={id:Xit,detector:i0n,loader:o0n},Zit="quadrantChart",s0n=Ae(e=>/^\s*quadrantChart/.test(e),"detector"),c0n=Ae(async()=>{const{diagram:e}=await Pi(async()=>{const{diagram:t}=await import("./quadrantDiagram-AYHSOK5B-DxL78nMn.js");return{diagram:t}},[]);return{id:Zit,diagram:e}},"loader"),u0n={id:Zit,detector:s0n,loader:c0n},d0n=u0n,Jit="xychart",f0n=Ae(e=>/^\s*xychart(-beta)?/.test(e),"detector"),p0n=Ae(async()=>{const{diagram:e}=await Pi(async()=>{const{diagram:t}=await import("./xychartDiagram-PRI3JC2R-B5w4Bc3R.js");return{diagram:t}},__vite__mapDeps([23,22]));return{id:Jit,diagram:e}},"loader"),h0n={id:Jit,detector:f0n,loader:p0n},g0n=h0n,eot="requirement",m0n=Ae(e=>/^\s*requirement(Diagram)?/.test(e),"detector"),A0n=Ae(async()=>{const{diagram:e}=await Pi(async()=>{const{diagram:t}=await import("./requirementDiagram-UZGBJVZJ-D1jOEW5O.js");return{diagram:t}},__vite__mapDeps([24,12,13]));return{id:eot,diagram:e}},"loader"),v0n={id:eot,detector:m0n,loader:A0n},y0n=v0n,tot="sequence",b0n=Ae(e=>/^\s*sequenceDiagram/.test(e),"detector"),_0n=Ae(async()=>{const{diagram:e}=await Pi(async()=>{const{diagram:t}=await import("./sequenceDiagram-WL72ISMW-CI7Io5Gi.js");return{diagram:t}},__vite__mapDeps([25,9,18]));return{id:tot,diagram:e}},"loader"),S0n={id:tot,detector:b0n,loader:_0n},x0n=S0n,not="class",E0n=Ae((e,t)=>{var n;return((n=t==null?void 0:t.class)==null?void 0:n.defaultRenderer)==="dagre-wrapper"?!1:/^\s*classDiagram/.test(e)},"detector"),w0n=Ae(async()=>{const{diagram:e}=await Pi(async()=>{const{diagram:t}=await import("./classDiagram-2ON5EDUG-DVtap8Es.js");return{diagram:t}},__vite__mapDeps([26,27,11,12,13]));return{id:not,diagram:e}},"loader"),C0n={id:not,detector:E0n,loader:w0n},T0n=C0n,rot="classDiagram",I0n=Ae((e,t)=>{var n;return/^\s*classDiagram/.test(e)&&((n=t==null?void 0:t.class)==null?void 0:n.defaultRenderer)==="dagre-wrapper"?!0:/^\s*classDiagram-v2/.test(e)},"detector"),R0n=Ae(async()=>{const{diagram:e}=await Pi(async()=>{const{diagram:t}=await import("./classDiagram-v2-WZHVMYZB-DVtap8Es.js");return{diagram:t}},__vite__mapDeps([28,27,11,12,13]));return{id:rot,diagram:e}},"loader"),N0n={id:rot,detector:I0n,loader:R0n},O0n=N0n,aot="state",M0n=Ae((e,t)=>{var n;return((n=t==null?void 0:t.state)==null?void 0:n.defaultRenderer)==="dagre-wrapper"?!1:/^\s*stateDiagram/.test(e)},"detector"),k0n=Ae(async()=>{const{diagram:e}=await Pi(async()=>{const{diagram:t}=await import("./stateDiagram-FKZM4ZOC-D6peDpB6.js");return{diagram:t}},__vite__mapDeps([29,30,12,13,1,2,3,4]));return{id:aot,diagram:e}},"loader"),L0n={id:aot,detector:M0n,loader:k0n},D0n=L0n,iot="stateDiagram",B0n=Ae((e,t)=>{var n;return!!(/^\s*stateDiagram-v2/.test(e)||/^\s*stateDiagram/.test(e)&&((n=t==null?void 0:t.state)==null?void 0:n.defaultRenderer)==="dagre-wrapper")},"detector"),P0n=Ae(async()=>{const{diagram:e}=await Pi(async()=>{const{diagram:t}=await import("./stateDiagram-v2-4FDKWEC3-DxnVGK0H.js");return{diagram:t}},__vite__mapDeps([31,30,12,13]));return{id:iot,diagram:e}},"loader"),$0n={id:iot,detector:B0n,loader:P0n},F0n=$0n,oot="journey",U0n=Ae(e=>/^\s*journey/.test(e),"detector"),z0n=Ae(async()=>{const{diagram:e}=await Pi(async()=>{const{diagram:t}=await import("./journeyDiagram-XKPGCS4Q-BaWx6-mv.js");return{diagram:t}},__vite__mapDeps([32,9,11]));return{id:oot,diagram:e}},"loader"),H0n={id:oot,detector:U0n,loader:z0n},j0n=H0n,G0n=Ae((e,t,n)=>{fn.debug(`rendering svg for syntax error
1215
+ `);const r=Xcn(t),a=r.append("g");r.attr("viewBox","0 0 2412 512"),_et(r,100,512,!0),a.append("path").attr("class","error-icon").attr("d","m411.313,123.313c6.25-6.25 6.25-16.375 0-22.625s-16.375-6.25-22.625,0l-32,32-9.375,9.375-20.688-20.688c-12.484-12.5-32.766-12.5-45.25,0l-16,16c-1.261,1.261-2.304,2.648-3.31,4.051-21.739-8.561-45.324-13.426-70.065-13.426-105.867,0-192,86.133-192,192s86.133,192 192,192 192-86.133 192-192c0-24.741-4.864-48.327-13.426-70.065 1.402-1.007 2.79-2.049 4.051-3.31l16-16c12.5-12.492 12.5-32.758 0-45.25l-20.688-20.688 9.375-9.375 32.001-31.999zm-219.313,100.687c-52.938,0-96,43.063-96,96 0,8.836-7.164,16-16,16s-16-7.164-16-16c0-70.578 57.422-128 128-128 8.836,0 16,7.164 16,16s-7.164,16-16,16z"),a.append("path").attr("class","error-icon").attr("d","m459.02,148.98c-6.25-6.25-16.375-6.25-22.625,0s-6.25,16.375 0,22.625l16,16c3.125,3.125 7.219,4.688 11.313,4.688 4.094,0 8.188-1.563 11.313-4.688 6.25-6.25 6.25-16.375 0-22.625l-16.001-16z"),a.append("path").attr("class","error-icon").attr("d","m340.395,75.605c3.125,3.125 7.219,4.688 11.313,4.688 4.094,0 8.188-1.563 11.313-4.688 6.25-6.25 6.25-16.375 0-22.625l-16-16c-6.25-6.25-16.375-6.25-22.625,0s-6.25,16.375 0,22.625l15.999,16z"),a.append("path").attr("class","error-icon").attr("d","m400,64c8.844,0 16-7.164 16-16v-32c0-8.836-7.156-16-16-16-8.844,0-16,7.164-16,16v32c0,8.836 7.156,16 16,16z"),a.append("path").attr("class","error-icon").attr("d","m496,96.586h-32c-8.844,0-16,7.164-16,16 0,8.836 7.156,16 16,16h32c8.844,0 16-7.164 16-16 0-8.836-7.156-16-16-16z"),a.append("path").attr("class","error-icon").attr("d","m436.98,75.605c3.125,3.125 7.219,4.688 11.313,4.688 4.094,0 8.188-1.563 11.313-4.688l32-32c6.25-6.25 6.25-16.375 0-22.625s-16.375-6.25-22.625,0l-32,32c-6.251,6.25-6.251,16.375-0.001,22.625z"),a.append("text").attr("class","error-text").attr("x",1440).attr("y",250).attr("font-size","150px").style("text-anchor","middle").text("Syntax error in text"),a.append("text").attr("class","error-text").attr("x",1250).attr("y",400).attr("font-size","100px").style("text-anchor","middle").text(`mermaid version ${n}`)},"draw"),lot={draw:G0n},V0n=lot,W0n={db:{},renderer:lot,parser:{parse:Ae(()=>{},"parse")}},q0n=W0n,sot="flowchart-elk",Q0n=Ae((e,t={})=>{var n;return/^\s*flowchart-elk/.test(e)||/^\s*(flowchart|graph)/.test(e)&&((n=t==null?void 0:t.flowchart)==null?void 0:n.defaultRenderer)==="elk"?(t.layout="elk",!0):!1},"detector"),Y0n=Ae(async()=>{const{diagram:e}=await Pi(async()=>{const{diagram:t}=await import("./flowDiagram-NV44I4VS-C8pJ2k7r.js");return{diagram:t}},__vite__mapDeps([10,11,12,13,14]));return{id:sot,diagram:e}},"loader"),K0n={id:sot,detector:Q0n,loader:Y0n},X0n=K0n,cot="timeline",Z0n=Ae(e=>/^\s*timeline/.test(e),"detector"),J0n=Ae(async()=>{const{diagram:e}=await Pi(async()=>{const{diagram:t}=await import("./timeline-definition-IT6M3QCI-CjFRzkWD.js");return{diagram:t}},[]);return{id:cot,diagram:e}},"loader"),e1n={id:cot,detector:Z0n,loader:J0n},t1n=e1n,uot="mindmap",n1n=Ae(e=>/^\s*mindmap/.test(e),"detector"),r1n=Ae(async()=>{const{diagram:e}=await Pi(async()=>{const{diagram:t}=await import("./mindmap-definition-VGOIOE7T-hfJbT9LQ.js");return{diagram:t}},__vite__mapDeps([33,12,13]));return{id:uot,diagram:e}},"loader"),a1n={id:uot,detector:n1n,loader:r1n},i1n=a1n,dot="kanban",o1n=Ae(e=>/^\s*kanban/.test(e),"detector"),l1n=Ae(async()=>{const{diagram:e}=await Pi(async()=>{const{diagram:t}=await import("./kanban-definition-3W4ZIXB7-VYSH0qj4.js");return{diagram:t}},__vite__mapDeps([34,11]));return{id:dot,diagram:e}},"loader"),s1n={id:dot,detector:o1n,loader:l1n},c1n=s1n,fot="sankey",u1n=Ae(e=>/^\s*sankey(-beta)?/.test(e),"detector"),d1n=Ae(async()=>{const{diagram:e}=await Pi(async()=>{const{diagram:t}=await import("./sankeyDiagram-TZEHDZUN-BnVVl6Az.js");return{diagram:t}},__vite__mapDeps([35,22]));return{id:fot,diagram:e}},"loader"),f1n={id:fot,detector:u1n,loader:d1n},p1n=f1n,pot="packet",h1n=Ae(e=>/^\s*packet(-beta)?/.test(e),"detector"),g1n=Ae(async()=>{const{diagram:e}=await Pi(async()=>{const{diagram:t}=await import("./diagram-S2PKOQOG-m0QpYod3.js");return{diagram:t}},__vite__mapDeps([36,17,19,4,2]));return{id:pot,diagram:e}},"loader"),m1n={id:pot,detector:h1n,loader:g1n},hot="radar",A1n=Ae(e=>/^\s*radar-beta/.test(e),"detector"),v1n=Ae(async()=>{const{diagram:e}=await Pi(async()=>{const{diagram:t}=await import("./diagram-QEK2KX5R-D9r4ARCA.js");return{diagram:t}},__vite__mapDeps([37,17,19,4,2]));return{id:hot,diagram:e}},"loader"),y1n={id:hot,detector:A1n,loader:v1n},got="block",b1n=Ae(e=>/^\s*block(-beta)?/.test(e),"detector"),_1n=Ae(async()=>{const{diagram:e}=await Pi(async()=>{const{diagram:t}=await import("./blockDiagram-VD42YOAC-DsqAGhiR.js");return{diagram:t}},__vite__mapDeps([38,11,5,1,2,14]));return{id:got,diagram:e}},"loader"),S1n={id:got,detector:b1n,loader:_1n},x1n=S1n,mot="architecture",E1n=Ae(e=>/^\s*architecture/.test(e),"detector"),w1n=Ae(async()=>{const{diagram:e}=await Pi(async()=>{const{diagram:t}=await import("./architectureDiagram-VXUJARFQ-BphXwUun.js");return{diagram:t}},__vite__mapDeps([39,17,19,4,2,7]));return{id:mot,diagram:e}},"loader"),C1n={id:mot,detector:E1n,loader:w1n},T1n=C1n,Aot="treemap",I1n=Ae(e=>/^\s*treemap/.test(e),"detector"),R1n=Ae(async()=>{const{diagram:e}=await Pi(async()=>{const{diagram:t}=await import("./diagram-PSM6KHXK-CaMB6O5C.js");return{diagram:t}},__vite__mapDeps([40,13,17,19,4,2,22]));return{id:Aot,diagram:e}},"loader"),N1n={id:Aot,detector:I1n,loader:R1n},jCe=!1,iP=Ae(()=>{jCe||(jCe=!0,ZM("error",q0n,e=>e.toLowerCase().trim()==="error"),ZM("---",{db:{clear:Ae(()=>{},"clear")},styles:{},renderer:{draw:Ae(()=>{},"draw")},parser:{parse:Ae(()=>{throw new Error("Diagrams beginning with --- are not valid. If you were trying to use a YAML front-matter, please ensure that you've correctly opened and closed the YAML front-matter with un-indented `---` blocks")},"parse")},init:Ae(()=>null,"init")},e=>e.toLowerCase().trimStart().startsWith("---")),moe(X0n,i1n,T1n),moe(Dgn,c1n,O0n,T0n,qgn,t0n,a0n,l0n,y0n,x0n,jgn,Fgn,t1n,Xgn,F0n,D0n,j0n,d0n,p1n,m1n,g0n,x1n,y1n,N1n))},"addDiagrams"),O1n=Ae(async()=>{fn.debug("Loading registered diagrams");const t=(await Promise.allSettled(Object.entries(z4).map(async([n,{detector:r,loader:a}])=>{if(a)try{boe(n)}catch{try{const{diagram:i,id:o}=await a();ZM(o,i,r)}catch(i){throw fn.error(`Failed to load external diagram with key ${n}. Removing from detectors.`),delete z4[n],i}}}))).filter(n=>n.status==="rejected");if(t.length>0){fn.error(`Failed to load ${t.length} external diagrams`);for(const n of t)fn.error(n);throw new Error(`Failed to load ${t.length} external diagrams`)}},"loadRegisteredDiagrams"),M1n="graphics-document document";function vot(e,t){e.attr("role",M1n),t!==""&&e.attr("aria-roledescription",t)}Ae(vot,"setA11yDiagramInfo");function yot(e,t,n,r){if(e.insert!==void 0){if(n){const a=`chart-desc-${r}`;e.attr("aria-describedby",a),e.insert("desc",":first-child").attr("id",a).text(n)}if(t){const a=`chart-title-${r}`;e.attr("aria-labelledby",a),e.insert("title",":first-child").attr("id",a).text(t)}}}Ae(yot,"addSVGa11yTitleDescription");var w4,dle=(w4=class{constructor(t,n,r,a,i){this.type=t,this.text=n,this.db=r,this.parser=a,this.renderer=i}static async fromText(t,n={}){var c,u;const r=hu(),a=n1e(t,r);t=qpn(t)+`
1216
1216
  `;try{boe(a)}catch{const d=yrn(a);if(!d)throw new cet(`Diagram ${a} not found.`);const{id:f,diagram:p}=await d();ZM(f,p)}const{db:i,parser:o,renderer:l,init:s}=boe(a);return o.parser&&(o.parser.yy=i),(c=i.clear)==null||c.call(i),s==null||s(r),n.title&&((u=i.setDiagramTitle)==null||u.call(i,n.title)),await o.parse(t),new w4(a,t,i,o,l)}async render(t,n){await this.renderer.draw(this.text,t,n,this)}getParser(){return this.parser}getType(){return this.type}},Ae(w4,"Diagram"),w4),GCe=[],k1n=Ae(()=>{GCe.forEach(e=>{e()}),GCe=[]},"attachFunctions"),L1n=Ae(e=>e.replace(/^\s*%%(?!{)[^\n]+\n?/gm,"").trimStart(),"cleanupComments");function bot(e){const t=e.match(set);if(!t)return{text:e,metadata:{}};let n=adn(t[1],{schema:rdn})??{};n=typeof n=="object"&&!Array.isArray(n)?n:{};const r={};return n.displayMode&&(r.displayMode=n.displayMode.toString()),n.title&&(r.title=n.title.toString()),n.config&&(r.config=n.config),{text:e.slice(t[0].length),metadata:r}}Ae(bot,"extractFrontMatter");var D1n=Ae(e=>e.replace(/\r\n?/g,`
1217
1217
  `).replace(/<(\w+)([^>]*)>/g,(t,n,r)=>"<"+n+r.replace(/="([^"]*)"/g,"='$1'")+">"),"cleanupText"),B1n=Ae(e=>{const{text:t,metadata:n}=bot(e),{displayMode:r,title:a,config:i={}}=n;return r&&(i.gantt||(i.gantt={}),i.gantt.displayMode=r),{title:a,config:i,text:t}},"processFrontmatter"),P1n=Ae(e=>{const t=wh.detectInit(e)??{},n=wh.detectDirective(e,"wrap");return Array.isArray(n)?t.wrap=n.some(({type:r})=>r==="wrap"):(n==null?void 0:n.type)==="wrap"&&(t.wrap=!0),{text:Lpn(e),directive:t}},"processDirectives");function ime(e){const t=D1n(e),n=B1n(t),r=P1n(n.text),a=G1e(n.config,r.directive);return e=L1n(r.text),{code:e,title:n.title,config:a}}Ae(ime,"preprocessDiagram");function _ot(e){const t=new TextEncoder().encode(e),n=Array.from(t,r=>String.fromCodePoint(r)).join("");return btoa(n)}Ae(_ot,"toBase64");var $1n=5e4,F1n="graph TB;a[Maximum text size in diagram exceeded];style a fill:#faa",U1n="sandbox",z1n="loose",H1n="http://www.w3.org/2000/svg",j1n="http://www.w3.org/1999/xlink",G1n="http://www.w3.org/1999/xhtml",V1n="100%",W1n="100%",q1n="border:0;margin:0;",Q1n="margin:0",Y1n="allow-top-navigation-by-user-activation allow-popups",K1n='The "iframe" tag is not supported by your browser.',X1n=["foreignobject"],Z1n=["dominant-baseline"];function ome(e){const t=ime(e);return KM(),Drn(t.config??{}),t}Ae(ome,"processAndSetConfigs");async function Sot(e,t){iP();try{const{code:n,config:r}=ome(e);return{diagramType:(await Eot(n)).type,config:r}}catch(n){if(t!=null&&t.suppressErrors)return!1;throw n}}Ae(Sot,"parse");var VCe=Ae((e,t,n=[])=>`
1218
1218
  .${e} ${t} { ${n.join(" !important; ")} !important; }`,"cssImportantStyles"),J1n=Ae((e,t=new Map)=>{var r;let n="";if(e.themeCSS!==void 0&&(n+=`
@@ -2009,7 +2009,7 @@ endobj\r
2009
2009
  * http://opensource.org/licenses/mit-license
2010
2010
  */function oh(e,t){if(this.pos=0,this.buffer=e,this.datav=new DataView(e.buffer),this.is_with_alpha=!!t,this.bottom_up=!0,this.flag=String.fromCharCode(this.buffer[0])+String.fromCharCode(this.buffer[1]),this.pos+=2,["BM","BA","CI","CP","IC","PT"].indexOf(this.flag)===-1)throw new Error("Invalid BMP File");this.parseHeader(),this.parseBGR()}function Qze(e){function t(w){if(!w)throw Error("assert :P")}function n(w,T,N){for(var R=0;4>R;R++)if(w[T+R]!=N.charCodeAt(R))return!0;return!1}function r(w,T,N,R,k){for(var O=0;O<k;O++)w[T+O]=N[R+O]}function a(w,T,N,R){for(var k=0;k<R;k++)w[T+k]=N}function i(w){return new Int32Array(w)}function o(w,T){for(var N=[],R=0;R<w;R++)N.push(new T);return N}function l(w,T){var N=[];return(function R(k,O,M){for(var D=M[O],B=0;B<D&&(k.push(M.length>O+1?[]:new T),!(M.length<O+1));B++)R(k[B],O+1,M)})(N,0,w),N}var s=function(){var w=this;function T(V,J){for(var ce=1<<J-1>>>0;V&ce;)ce>>>=1;return ce?(V&ce-1)+ce:V}function N(V,J,ce,ye,we){t(!(ye%ce));do V[J+(ye-=ce)]=we;while(0<ye)}function R(V,J,ce,ye,we){if(t(2328>=we),512>=we)var Me=i(512);else if((Me=i(we))==null)return 0;return(function(Le,Be,Pe,je,ot,Tt){var It,yt,sn=Be,Vt=1<<Pe,ut=i(16),dt=i(16);for(t(ot!=0),t(je!=null),t(Le!=null),t(0<Pe),yt=0;yt<ot;++yt){if(15<je[yt])return 0;++ut[je[yt]]}if(ut[0]==ot)return 0;for(dt[1]=0,It=1;15>It;++It){if(ut[It]>1<<It)return 0;dt[It+1]=dt[It]+ut[It]}for(yt=0;yt<ot;++yt)It=je[yt],0<je[yt]&&(Tt[dt[It]++]=yt);if(dt[15]==1)return(je=new k).g=0,je.value=Tt[0],N(Le,sn,1,Vt,je),Vt;var en,Jt=-1,nn=Vt-1,tr=0,Fn=1,jr=1,Hn=1<<Pe;for(yt=0,It=1,ot=2;It<=Pe;++It,ot<<=1){if(Fn+=jr<<=1,0>(jr-=ut[It]))return 0;for(;0<ut[It];--ut[It])(je=new k).g=It,je.value=Tt[yt++],N(Le,sn+tr,ot,Hn,je),tr=T(tr,It)}for(It=Pe+1,ot=2;15>=It;++It,ot<<=1){if(Fn+=jr<<=1,0>(jr-=ut[It]))return 0;for(;0<ut[It];--ut[It]){if(je=new k,(tr&nn)!=Jt){for(sn+=Hn,en=1<<(Jt=It)-Pe;15>Jt&&!(0>=(en-=ut[Jt]));)++Jt,en<<=1;Vt+=Hn=1<<(en=Jt-Pe),Le[Be+(Jt=tr&nn)].g=en+Pe,Le[Be+Jt].value=sn-Be-Jt}je.g=It-Pe,je.value=Tt[yt++],N(Le,sn+(tr>>Pe),ot,Hn,je),tr=T(tr,It)}}return Fn!=2*dt[15]-1?0:Vt})(V,J,ce,ye,we,Me)}function k(){this.value=this.g=0}function O(){this.value=this.g=0}function M(){this.G=o(5,k),this.H=i(5),this.jc=this.Qb=this.qb=this.nd=0,this.pd=o(el,O)}function D(V,J,ce,ye){t(V!=null),t(J!=null),t(2147483648>ye),V.Ca=254,V.I=0,V.b=-8,V.Ka=0,V.oa=J,V.pa=ce,V.Jd=J,V.Yc=ce+ye,V.Zc=4<=ye?ce+ye-4+1:ce,Z(V)}function B(V,J){for(var ce=0;0<J--;)ce|=ee(V,128)<<J;return ce}function $(V,J){var ce=B(V,J);return Y(V)?-ce:ce}function P(V,J,ce,ye){var we,Me=0;for(t(V!=null),t(J!=null),t(4294967288>ye),V.Sb=ye,V.Ra=0,V.u=0,V.h=0,4<ye&&(ye=4),we=0;we<ye;++we)Me+=J[ce+we]<<8*we;V.Ra=Me,V.bb=ye,V.oa=J,V.pa=ce}function U(V){for(;8<=V.u&&V.bb<V.Sb;)V.Ra>>>=8,V.Ra+=V.oa[V.pa+V.bb]<<O1-8>>>0,++V.bb,V.u-=8;W(V)&&(V.h=1,V.u=0)}function H(V,J){if(t(0<=J),!V.h&&J<=N1){var ce=z(V)&R1[J];return V.u+=J,U(V),ce}return V.h=1,V.u=0}function G(){this.b=this.Ca=this.I=0,this.oa=[],this.pa=0,this.Jd=[],this.Yc=0,this.Zc=[],this.Ka=0}function F(){this.Ra=0,this.oa=[],this.h=this.u=this.bb=this.Sb=this.pa=0}function z(V){return V.Ra>>>(V.u&O1-1)>>>0}function W(V){return t(V.bb<=V.Sb),V.h||V.bb==V.Sb&&V.u>O1}function q(V,J){V.u=J,V.h=W(V)}function Q(V){V.u>=M1&&(t(V.u>=M1),U(V))}function Z(V){t(V!=null&&V.oa!=null),V.pa<V.Zc?(V.I=(V.oa[V.pa++]|V.I<<8)>>>0,V.b+=8):(t(V!=null&&V.oa!=null),V.pa<V.Yc?(V.b+=8,V.I=V.oa[V.pa++]|V.I<<8):V.Ka?V.b=0:(V.I<<=8,V.b+=8,V.Ka=1))}function Y(V){return B(V,1)}function ee(V,J){var ce=V.Ca;0>V.b&&Z(V);var ye=V.b,we=ce*J>>>8,Me=(V.I>>>ye>we)+0;for(Me?(ce-=we,V.I-=we+1<<ye>>>0):ce=we+1,ye=ce,we=0;256<=ye;)we+=8,ye>>=8;return ye=7^we+pc[ye],V.b-=ye,V.Ca=(ce<<ye)-1,Me}function ae(V,J,ce){V[J+0]=ce>>24&255,V[J+1]=ce>>16&255,V[J+2]=ce>>8&255,V[J+3]=ce>>0&255}function ne(V,J){return V[J+0]<<0|V[J+1]<<8}function te(V,J){return ne(V,J)|V[J+2]<<16}function se(V,J){return ne(V,J)|ne(V,J+2)<<16}function pe(V,J){var ce=1<<J;return t(V!=null),t(0<J),V.X=i(ce),V.X==null?0:(V.Mb=32-J,V.Xa=J,1)}function ue(V,J){t(V!=null),t(J!=null),t(V.Xa==J.Xa),r(J.X,0,V.X,0,1<<J.Xa)}function ie(){this.X=[],this.Xa=this.Mb=0}function be(V,J,ce,ye){t(ce!=null),t(ye!=null);var we=ce[0],Me=ye[0];return we==0&&(we=(V*Me+J/2)/J),Me==0&&(Me=(J*we+V/2)/V),0>=we||0>=Me?0:(ce[0]=we,ye[0]=Me,1)}function de(V,J){return V+(1<<J)-1>>>J}function ve(V,J){return((4278255360&V)+(4278255360&J)>>>0&4278255360)+((16711935&V)+(16711935&J)>>>0&16711935)>>>0}function he(V,J){w[J]=function(ce,ye,we,Me,Le,Be,Pe){var je;for(je=0;je<Le;++je){var ot=w[V](Be[Pe+je-1],we,Me+je);Be[Pe+je]=ve(ce[ye+je],ot)}}}function fe(){this.ud=this.hd=this.jd=0}function me(V,J){return((4278124286&(V^J))>>>1)+(V&J)>>>0}function Se(V){return 0<=V&&256>V?V:0>V?0:255<V?255:void 0}function xe(V,J){return Se(V+(V-J+.5>>1))}function $e(V,J,ce){return Math.abs(J-ce)-Math.abs(V-ce)}function Fe(V,J,ce,ye,we,Me,Le){for(ye=Me[Le-1],ce=0;ce<we;++ce)Me[Le+ce]=ye=ve(V[J+ce],ye)}function et(V,J,ce,ye,we){var Me;for(Me=0;Me<ce;++Me){var Le=V[J+Me],Be=Le>>8&255,Pe=16711935&(Pe=(Pe=16711935&Le)+((Be<<16)+Be));ye[we+Me]=(4278255360&Le)+Pe>>>0}}function rt(V,J){J.jd=V>>0&255,J.hd=V>>8&255,J.ud=V>>16&255}function We(V,J,ce,ye,we,Me){var Le;for(Le=0;Le<ye;++Le){var Be=J[ce+Le],Pe=Be>>>8,je=Be,ot=255&(ot=(ot=Be>>>16)+((V.jd<<24>>24)*(Pe<<24>>24)>>>5));je=255&(je=(je=je+((V.hd<<24>>24)*(Pe<<24>>24)>>>5))+((V.ud<<24>>24)*(ot<<24>>24)>>>5)),we[Me+Le]=(4278255360&Be)+(ot<<16)+je}}function ct(V,J,ce,ye,we){w[J]=function(Me,Le,Be,Pe,je,ot,Tt,It,yt){for(Pe=Tt;Pe<It;++Pe)for(Tt=0;Tt<yt;++Tt)je[ot++]=we(Be[ye(Me[Le++])])},w[V]=function(Me,Le,Be,Pe,je,ot,Tt){var It=8>>Me.b,yt=Me.Ea,sn=Me.K[0],Vt=Me.w;if(8>It)for(Me=(1<<Me.b)-1,Vt=(1<<It)-1;Le<Be;++Le){var ut,dt=0;for(ut=0;ut<yt;++ut)ut&Me||(dt=ye(Pe[je++])),ot[Tt++]=we(sn[dt&Vt]),dt>>=It}else w["VP8LMapColor"+ce](Pe,je,sn,Vt,ot,Tt,Le,Be,yt)}}function De(V,J,ce,ye,we){for(ce=J+ce;J<ce;){var Me=V[J++];ye[we++]=Me>>16&255,ye[we++]=Me>>8&255,ye[we++]=Me>>0&255}}function Ve(V,J,ce,ye,we){for(ce=J+ce;J<ce;){var Me=V[J++];ye[we++]=Me>>16&255,ye[we++]=Me>>8&255,ye[we++]=Me>>0&255,ye[we++]=Me>>24&255}}function Ge(V,J,ce,ye,we){for(ce=J+ce;J<ce;){var Me=(Le=V[J++])>>16&240|Le>>12&15,Le=Le>>0&240|Le>>28&15;ye[we++]=Me,ye[we++]=Le}}function Xe(V,J,ce,ye,we){for(ce=J+ce;J<ce;){var Me=(Le=V[J++])>>16&248|Le>>13&7,Le=Le>>5&224|Le>>3&31;ye[we++]=Me,ye[we++]=Le}}function at(V,J,ce,ye,we){for(ce=J+ce;J<ce;){var Me=V[J++];ye[we++]=Me>>0&255,ye[we++]=Me>>8&255,ye[we++]=Me>>16&255}}function Qe(V,J,ce,ye,we,Me){if(Me==0)for(ce=J+ce;J<ce;)ae(ye,((Me=V[J++])[0]>>24|Me[1]>>8&65280|Me[2]<<8&16711680|Me[3]<<24)>>>0),we+=32;else r(ye,we,V,J,ce)}function He(V,J){w[J][0]=w[V+"0"],w[J][1]=w[V+"1"],w[J][2]=w[V+"2"],w[J][3]=w[V+"3"],w[J][4]=w[V+"4"],w[J][5]=w[V+"5"],w[J][6]=w[V+"6"],w[J][7]=w[V+"7"],w[J][8]=w[V+"8"],w[J][9]=w[V+"9"],w[J][10]=w[V+"10"],w[J][11]=w[V+"11"],w[J][12]=w[V+"12"],w[J][13]=w[V+"13"],w[J][14]=w[V+"0"],w[J][15]=w[V+"0"]}function Ie(V){return V==$1||V==Xg||V==gA||V==mA}function ze(){this.eb=[],this.size=this.A=this.fb=0}function tt(){this.y=[],this.f=[],this.ea=[],this.F=[],this.Tc=this.Ed=this.Cd=this.Fd=this.lb=this.Db=this.Ab=this.fa=this.J=this.W=this.N=this.O=0}function mt(){this.Rd=this.height=this.width=this.S=0,this.f={},this.f.RGBA=new ze,this.f.kb=new tt,this.sd=null}function vt(){this.width=[0],this.height=[0],this.Pd=[0],this.Qd=[0],this.format=[0]}function Dt(){this.Id=this.fd=this.Md=this.hb=this.ib=this.da=this.bd=this.cd=this.j=this.v=this.Da=this.Sd=this.ob=0}function Nt(V){return alert("todo:WebPSamplerProcessPlane"),V.T}function ht(V,J){var ce=V.T,ye=J.ba.f.RGBA,we=ye.eb,Me=ye.fb+V.ka*ye.A,Le=Hc[J.ba.S],Be=V.y,Pe=V.O,je=V.f,ot=V.N,Tt=V.ea,It=V.W,yt=J.cc,sn=J.dc,Vt=J.Mc,ut=J.Nc,dt=V.ka,en=V.ka+V.T,Jt=V.U,nn=Jt+1>>1;for(dt==0?Le(Be,Pe,null,null,je,ot,Tt,It,je,ot,Tt,It,we,Me,null,null,Jt):(Le(J.ec,J.fc,Be,Pe,yt,sn,Vt,ut,je,ot,Tt,It,we,Me-ye.A,we,Me,Jt),++ce);dt+2<en;dt+=2)yt=je,sn=ot,Vt=Tt,ut=It,ot+=V.Rc,It+=V.Rc,Me+=2*ye.A,Le(Be,(Pe+=2*V.fa)-V.fa,Be,Pe,yt,sn,Vt,ut,je,ot,Tt,It,we,Me-ye.A,we,Me,Jt);return Pe+=V.fa,V.j+en<V.o?(r(J.ec,J.fc,Be,Pe,Jt),r(J.cc,J.dc,je,ot,nn),r(J.Mc,J.Nc,Tt,It,nn),ce--):1&en||Le(Be,Pe,null,null,je,ot,Tt,It,je,ot,Tt,It,we,Me+ye.A,null,null,Jt),ce}function ft(V,J,ce){var ye=V.F,we=[V.J];if(ye!=null){var Me=V.U,Le=J.ba.S,Be=Le==hA||Le==gA;J=J.ba.f.RGBA;var Pe=[0],je=V.ka;Pe[0]=V.T,V.Kb&&(je==0?--Pe[0]:(--je,we[0]-=V.width),V.j+V.ka+V.T==V.o&&(Pe[0]=V.o-V.j-je));var ot=J.eb;je=J.fb+je*J.A,V=Wi(ye,we[0],V.width,Me,Pe,ot,je+(Be?0:3),J.A),t(ce==Pe),V&&Ie(Le)&&Uc(ot,je,Be,Me,Pe,J.A)}return 0}function gt(V){var J=V.ma,ce=J.ba.S,ye=11>ce,we=ce==h2||ce==pA||ce==hA||ce==go||ce==12||Ie(ce);if(J.memory=null,J.Ib=null,J.Jb=null,J.Nd=null,!T1(J.Oa,V,we?11:12))return 0;if(we&&Ie(ce)&&gn(),V.da)alert("todo:use_scaling");else{if(ye){if(J.Ib=Nt,V.Kb){if(ce=V.U+1>>1,J.memory=i(V.U+2*ce),J.memory==null)return 0;J.ec=J.memory,J.fc=0,J.cc=J.ec,J.dc=J.fc+V.U,J.Mc=J.cc,J.Nc=J.dc+ce,J.Ib=ht,gn()}}else alert("todo:EmitYUV");we&&(J.Jb=ft,ye&&Et())}if(ye&&!Ss){for(V=0;256>V;++V)jc[V]=89858*(V-128)+Zd>>Vp,Gc[V]=-22014*(V-128)+Zd,H1[V]=-45773*(V-128),t0[V]=113618*(V-128)+Zd>>Vp;for(V=qi;V<no;++V)J=76283*(V-16)+Zd>>Vp,Y5[V-qi]=wu(J,255),HC[V-qi]=wu(J+8>>4,15);Ss=1}return 1}function bt(V){var J=V.ma,ce=V.U,ye=V.T;return t(!(1&V.ka)),0>=ce||0>=ye?0:(ce=J.Ib(V,J),J.Jb!=null&&J.Jb(V,J,ce),J.Dc+=ce,1)}function wt(V){V.ma.memory=null}function xt(V,J,ce,ye){return H(V,8)!=47?0:(J[0]=H(V,14)+1,ce[0]=H(V,14)+1,ye[0]=H(V,1),H(V,3)!=0?0:!V.h)}function Lt(V,J){if(4>V)return V+1;var ce=V-2>>1;return(2+(1&V)<<ce)+H(J,ce)+1}function Mt(V,J){return 120<J?J-120:1<=(ce=((ce=uF[J-1])>>4)*V+(8-(15&ce)))?ce:1;var ce}function Wt(V,J,ce){var ye=z(ce),we=V[J+=255&ye].g-8;return 0<we&&(q(ce,ce.u+8),ye=z(ce),J+=V[J].value,J+=ye&(1<<we)-1),q(ce,ce.u+V[J].g),V[J].value}function _t(V,J,ce){return ce.g+=V.g,ce.value+=V.value<<J>>>0,t(8>=ce.g),V.g}function Bt(V,J,ce){var ye=V.xc;return t((J=ye==0?0:V.vc[V.md*(ce>>ye)+(J>>ye)])<V.Wb),V.Ya[J]}function Ct(V,J,ce,ye){var we=V.ab,Me=V.c*J,Le=V.C;J=Le+J;var Be=ce,Pe=ye;for(ye=V.Ta,ce=V.Ua;0<we--;){var je=V.gc[we],ot=Le,Tt=J,It=Be,yt=Pe,sn=(Pe=ye,Be=ce,je.Ea);switch(t(ot<Tt),t(Tt<=je.nc),je.hc){case 2:G5(It,yt,(Tt-ot)*sn,Pe,Be);break;case 0:var Vt=ot,ut=Tt,dt=Pe,en=Be,Jt=(Hn=je).Ea;Vt==0&&(Vg(It,yt,null,null,1,dt,en),Fe(It,yt+1,0,0,Jt-1,dt,en+1),yt+=Jt,en+=Jt,++Vt);for(var nn=1<<Hn.b,tr=nn-1,Fn=de(Jt,Hn.b),jr=Hn.K,Hn=Hn.w+(Vt>>Hn.b)*Fn;Vt<ut;){var Ti=jr,Ii=Hn,fi=1;for(Pp(It,yt,dt,en-Jt,1,dt,en);fi<Jt;){var za=(fi&~tr)+nn;za>Jt&&(za=Jt),(0,Bf[Ti[Ii++]>>8&15])(It,yt+ +fi,dt,en+fi-Jt,za-fi,dt,en+fi),fi=za}yt+=Jt,en+=Jt,++Vt&tr||(Hn+=Fn)}Tt!=je.nc&&r(Pe,Be-sn,Pe,Be+(Tt-ot-1)*sn,sn);break;case 1:for(sn=It,ut=yt,Jt=(It=je.Ea)-(en=It&~(dt=(yt=1<<je.b)-1)),Vt=de(It,je.b),nn=je.K,je=je.w+(ot>>je.b)*Vt;ot<Tt;){for(tr=nn,Fn=je,jr=new fe,Hn=ut+en,Ti=ut+It;ut<Hn;)rt(tr[Fn++],jr),d2(jr,sn,ut,yt,Pe,Be),ut+=yt,Be+=yt;ut<Ti&&(rt(tr[Fn++],jr),d2(jr,sn,ut,Jt,Pe,Be),ut+=Jt,Be+=Jt),++ot&dt||(je+=Vt)}break;case 3:if(It==Pe&&yt==Be&&0<je.b){for(ut=Pe,It=sn=Be+(Tt-ot)*sn-(en=(Tt-ot)*de(je.Ea,je.b)),yt=Pe,dt=Be,Vt=[],en=(Jt=en)-1;0<=en;--en)Vt[en]=yt[dt+en];for(en=Jt-1;0<=en;--en)ut[It+en]=Vt[en];hc(je,ot,Tt,Pe,sn,Pe,Be)}else hc(je,ot,Tt,It,yt,Pe,Be)}Be=ye,Pe=ce}Pe!=ce&&r(ye,ce,Be,Pe,Me)}function Kt(V,J){var ce=V.V,ye=V.Ba+V.c*V.C,we=J-V.C;if(t(J<=V.l.o),t(16>=we),0<we){var Me=V.l,Le=V.Ta,Be=V.Ua,Pe=Me.width;if(Ct(V,we,ce,ye),we=Be=[Be],t((ce=V.C)<(ye=J)),t(Me.v<Me.va),ye>Me.o&&(ye=Me.o),ce<Me.j){var je=Me.j-ce;ce=Me.j,we[0]+=je*Pe}if(ce>=ye?ce=0:(we[0]+=4*Me.v,Me.ka=ce-Me.j,Me.U=Me.va-Me.v,Me.T=ye-ce,ce=1),ce){if(Be=Be[0],11>(ce=V.ca).S){var ot=ce.f.RGBA,Tt=(ye=ce.S,we=Me.U,Me=Me.T,je=ot.eb,ot.A),It=Me;for(ot=ot.fb+V.Ma*ot.A;0<It--;){var yt=Le,sn=Be,Vt=we,ut=je,dt=ot;switch(ye){case V5:gc(yt,sn,Vt,ut,dt);break;case h2:Ws(yt,sn,Vt,ut,dt);break;case $1:Ws(yt,sn,Vt,ut,dt),Uc(ut,dt,0,Vt,1,0);break;case PC:Fp(yt,sn,Vt,ut,dt);break;case pA:Qe(yt,sn,Vt,ut,dt,1);break;case Xg:Qe(yt,sn,Vt,ut,dt,1),Uc(ut,dt,0,Vt,1,0);break;case hA:Qe(yt,sn,Vt,ut,dt,0);break;case gA:Qe(yt,sn,Vt,ut,dt,0),Uc(ut,dt,1,Vt,1,0);break;case go:f2(yt,sn,Vt,ut,dt);break;case mA:f2(yt,sn,Vt,ut,dt),ho(ut,dt,Vt,1,0);break;case W5:$p(yt,sn,Vt,ut,dt);break;default:t(0)}Be+=Pe,ot+=Tt}V.Ma+=Me}else alert("todo:EmitRescaledRowsYUVA");t(V.Ma<=ce.height)}}V.C=J,t(V.C<=V.i)}function $t(V){var J;if(0<V.ua)return 0;for(J=0;J<V.Wb;++J){var ce=V.Ya[J].G,ye=V.Ya[J].H;if(0<ce[1][ye[1]+0].g||0<ce[2][ye[2]+0].g||0<ce[3][ye[3]+0].g)return 0}return 1}function rn(V,J,ce,ye,we,Me){if(V.Z!=0){var Le=V.qd,Be=V.rd;for(t(Qs[V.Z]!=null);J<ce;++J)Qs[V.Z](Le,Be,ye,we,ye,we,Me),Le=ye,Be=we,we+=Me;V.qd=Le,V.rd=Be}}function qt(V,J){var ce=V.l.ma,ye=ce.Z==0||ce.Z==1?V.l.j:V.C;if(ye=V.C<ye?ye:V.C,t(J<=V.l.o),J>ye){var we=V.l.width,Me=ce.ca,Le=ce.tb+we*ye,Be=V.V,Pe=V.Ba+V.c*ye,je=V.gc;t(V.ab==1),t(je[0].hc==3),uA(je[0],ye,J,Be,Pe,Me,Le),rn(ce,ye,J,Me,Le,we)}V.C=V.Ma=J}function on(V,J,ce,ye,we,Me,Le){var Be=V.$/ye,Pe=V.$%ye,je=V.m,ot=V.s,Tt=ce+V.$,It=Tt;we=ce+ye*we;var yt=ce+ye*Me,sn=280+ot.ua,Vt=V.Pb?Be:16777216,ut=0<ot.ua?ot.Wa:null,dt=ot.wc,en=Tt<yt?Bt(ot,Pe,Be):null;t(V.C<Me),t(yt<=we);var Jt=!1;e:for(;;){for(;Jt||Tt<yt;){var nn=0;if(Be>=Vt){var tr=Tt-ce;t((Vt=V).Pb),Vt.wd=Vt.m,Vt.xd=tr,0<Vt.s.ua&&ue(Vt.s.Wa,Vt.s.vb),Vt=Be+Q5}if(Pe&dt||(en=Bt(ot,Pe,Be)),t(en!=null),en.Qb&&(J[Tt]=en.qb,Jt=!0),!Jt)if(Q(je),en.jc){nn=je,tr=J;var Fn=Tt,jr=en.pd[z(nn)&el-1];t(en.jc),256>jr.g?(q(nn,nn.u+jr.g),tr[Fn]=jr.value,nn=0):(q(nn,nn.u+jr.g-256),t(256<=jr.value),nn=jr.value),nn==0&&(Jt=!0)}else nn=Wt(en.G[0],en.H[0],je);if(je.h)break;if(Jt||256>nn){if(!Jt)if(en.nd)J[Tt]=(en.qb|nn<<8)>>>0;else{if(Q(je),Jt=Wt(en.G[1],en.H[1],je),Q(je),tr=Wt(en.G[2],en.H[2],je),Fn=Wt(en.G[3],en.H[3],je),je.h)break;J[Tt]=(Fn<<24|Jt<<16|nn<<8|tr)>>>0}if(Jt=!1,++Tt,++Pe>=ye&&(Pe=0,++Be,Le!=null&&Be<=Me&&!(Be%16)&&Le(V,Be),ut!=null))for(;It<Tt;)nn=J[It++],ut.X[(506832829*nn&4294967295)>>>ut.Mb]=nn}else if(280>nn){if(nn=Lt(nn-256,je),tr=Wt(en.G[4],en.H[4],je),Q(je),tr=Mt(ye,tr=Lt(tr,je)),je.h)break;if(Tt-ce<tr||we-Tt<nn)break e;for(Fn=0;Fn<nn;++Fn)J[Tt+Fn]=J[Tt+Fn-tr];for(Tt+=nn,Pe+=nn;Pe>=ye;)Pe-=ye,++Be,Le!=null&&Be<=Me&&!(Be%16)&&Le(V,Be);if(t(Tt<=we),Pe&dt&&(en=Bt(ot,Pe,Be)),ut!=null)for(;It<Tt;)nn=J[It++],ut.X[(506832829*nn&4294967295)>>>ut.Mb]=nn}else{if(!(nn<sn))break e;for(Jt=nn-280,t(ut!=null);It<Tt;)nn=J[It++],ut.X[(506832829*nn&4294967295)>>>ut.Mb]=nn;nn=Tt,t(!(Jt>>>(tr=ut).Xa)),J[nn]=tr.X[Jt],Jt=!0}Jt||t(je.h==W(je))}if(V.Pb&&je.h&&Tt<we)t(V.m.h),V.a=5,V.m=V.wd,V.$=V.xd,0<V.s.ua&&ue(V.s.vb,V.s.Wa);else{if(je.h)break e;Le!=null&&Le(V,Be>Me?Me:Be),V.a=0,V.$=Tt-ce}return 1}return V.a=3,0}function Tn(V){t(V!=null),V.vc=null,V.yc=null,V.Ya=null;var J=V.Wa;J!=null&&(J.X=null),V.vb=null,t(V!=null)}function $n(){var V=new N_;return V==null?null:(V.a=0,V.xb=U1,He("Predictor","VP8LPredictors"),He("Predictor","VP8LPredictors_C"),He("PredictorAdd","VP8LPredictorsAdd"),He("PredictorAdd","VP8LPredictorsAdd_C"),G5=et,d2=We,gc=De,Ws=Ve,f2=Ge,$p=Xe,Fp=at,w.VP8LMapColor32b=k1,w.VP8LMapColor8b=L1,V)}function Kn(V,J,ce,ye,we){var Me=1,Le=[V],Be=[J],Pe=ye.m,je=ye.s,ot=null,Tt=0;e:for(;;){if(ce)for(;Me&&H(Pe,1);){var It=Le,yt=Be,sn=ye,Vt=1,ut=sn.m,dt=sn.gc[sn.ab],en=H(ut,2);if(sn.Oc&1<<en)Me=0;else{switch(sn.Oc|=1<<en,dt.hc=en,dt.Ea=It[0],dt.nc=yt[0],dt.K=[null],++sn.ab,t(4>=sn.ab),en){case 0:case 1:dt.b=H(ut,3)+2,Vt=Kn(de(dt.Ea,dt.b),de(dt.nc,dt.b),0,sn,dt.K),dt.K=dt.K[0];break;case 3:var Jt,nn=H(ut,8)+1,tr=16<nn?0:4<nn?1:2<nn?2:3;if(It[0]=de(dt.Ea,tr),dt.b=tr,Jt=Vt=Kn(nn,1,0,sn,dt.K)){var Fn,jr=nn,Hn=dt,Ti=1<<(8>>Hn.b),Ii=i(Ti);if(Ii==null)Jt=0;else{var fi=Hn.K[0],za=Hn.w;for(Ii[0]=Hn.K[0][0],Fn=1;Fn<1*jr;++Fn)Ii[Fn]=ve(fi[za+Fn],Ii[Fn-1]);for(;Fn<4*Ti;++Fn)Ii[Fn]=0;Hn.K[0]=null,Hn.K[0]=Ii,Jt=1}}Vt=Jt;break;case 2:break;default:t(0)}Me=Vt}}if(Le=Le[0],Be=Be[0],Me&&H(Pe,1)&&!(Me=1<=(Tt=H(Pe,4))&&11>=Tt)){ye.a=3;break e}var Qi;if(Qi=Me)t:{var ro,ha,Ho,vc=ye,hl=Le,Bl=Be,Fi=Tt,Ys=ce,Ks=vc.m,jo=vc.s,Pl=[null],xs=1,Vc=0,pd=FC[Fi];n:for(;;){if(Ys&&H(Ks,1)){var Go=H(Ks,3)+2,El=de(hl,Go),Iu=de(Bl,Go),A2=El*Iu;if(!Kn(El,Iu,0,vc,Pl))break n;for(Pl=Pl[0],jo.xc=Go,ro=0;ro<A2;++ro){var qp=Pl[ro]>>8&65535;Pl[ro]=qp,qp>=xs&&(xs=qp+1)}}if(Ks.h)break n;for(ha=0;5>ha;++ha){var Ui=Zg[ha];!ha&&0<Fi&&(Ui+=1<<Fi),Vc<Ui&&(Vc=Ui)}var zf=o(xs*pd,k),K5=xs,B_=o(K5,M);if(B_==null)var hd=null;else t(65536>=K5),hd=B_;var gd=i(Vc);if(hd==null||gd==null||zf==null){vc.a=1;break n}var r0=zf;for(ro=Ho=0;ro<xs;++ro){var md=hd[ro],Qp=md.G,a0=md.H,j1=0,Ru=1,G1=0;for(ha=0;5>ha;++ha){Ui=Zg[ha],Qp[ha]=r0,a0[ha]=Ho,!ha&&0<Fi&&(Ui+=1<<Fi);a:{var v2,Yp=Ui,V1=vc,Hf=gd,GC=r0,P_=Ho,Io=0,Jd=V1.m,$_=H(Jd,1);if(a(Hf,0,0,Yp),$_){var F_=H(Jd,1)+1,X5=H(Jd,1),Z5=H(Jd,X5==0?1:8);Hf[Z5]=1,F_==2&&(Hf[Z5=H(Jd,8)]=1);var jf=1}else{var Mo=i(19),wl=H(Jd,4)+4;if(19<wl){V1.a=3;var gl=0;break a}for(v2=0;v2<wl;++v2)Mo[cF[v2]]=H(Jd,3);var W1=void 0,Kp=void 0,q1=V1,gF=Mo,$l=Yp,J5=Hf,_A=0,Gf=q1.m,ef=8,Nu=o(128,k);r:for(;R(Nu,0,7,gF,19);){if(H(Gf,1)){var SA=2+2*H(Gf,3);if((W1=2+H(Gf,SA))>$l)break r}else W1=$l;for(Kp=0;Kp<$l&&W1--;){Q(Gf);var ey=Nu[0+(127&z(Gf))];q(Gf,Gf.u+ey.g);var y2=ey.value;if(16>y2)J5[Kp++]=y2,y2!=0&&(ef=y2);else{var VC=y2==16,U_=y2-16,WC=q5[U_],z_=H(Gf,AA[U_])+WC;if(Kp+z_>$l)break r;for(var qC=VC?ef:0;0<z_--;)J5[Kp++]=qC}}_A=1;break r}_A||(q1.a=3),jf=_A}(jf=jf&&!Jd.h)&&(Io=R(GC,P_,8,Hf,Yp)),jf&&Io!=0?gl=Io:(V1.a=3,gl=0)}if(gl==0)break n;if(Ru&&$C[ha]==1&&(Ru=r0[Ho].g==0),j1+=r0[Ho].g,Ho+=gl,3>=ha){var Q1,ty=gd[0];for(Q1=1;Q1<Ui;++Q1)gd[Q1]>ty&&(ty=gd[Q1]);G1+=ty}}if(md.nd=Ru,md.Qb=0,Ru&&(md.qb=(Qp[3][a0[3]+0].value<<24|Qp[1][a0[1]+0].value<<16|Qp[2][a0[2]+0].value)>>>0,j1==0&&256>Qp[0][a0[0]+0].value&&(md.Qb=1,md.qb+=Qp[0][a0[0]+0].value<<8)),md.jc=!md.Qb&&6>G1,md.jc){var xA,Ou=md;for(xA=0;xA<el;++xA){var Xp=xA,tf=Ou.pd[Xp],i0=Ou.G[0][Ou.H[0]+Xp];256<=i0.value?(tf.g=i0.g+256,tf.value=i0.value):(tf.g=0,tf.value=0,Xp>>=_t(i0,8,tf),Xp>>=_t(Ou.G[1][Ou.H[1]+Xp],16,tf),Xp>>=_t(Ou.G[2][Ou.H[2]+Xp],0,tf),_t(Ou.G[3][Ou.H[3]+Xp],24,tf))}}}jo.vc=Pl,jo.Wb=xs,jo.Ya=hd,jo.yc=zf,Qi=1;break t}Qi=0}if(!(Me=Qi)){ye.a=3;break e}if(0<Tt){if(je.ua=1<<Tt,!pe(je.Wa,Tt)){ye.a=1,Me=0;break e}}else je.ua=0;var ny=ye,ry=Le,QC=Be,ay=ny.s,iy=ay.xc;if(ny.c=ry,ny.i=QC,ay.md=de(ry,iy),ay.wc=iy==0?-1:(1<<iy)-1,ce){ye.xb=Uf;break e}if((ot=i(Le*Be))==null){ye.a=1,Me=0;break e}Me=(Me=on(ye,ot,0,Le,Be,Be,null))&&!Pe.h;break e}return Me?(we!=null?we[0]=ot:(t(ot==null),t(ce)),ye.$=0,ce||Tn(je)):Tn(je),Me}function Cr(V,J){var ce=V.c*V.i,ye=ce+J+16*J;return t(V.c<=J),V.V=i(ye),V.V==null?(V.Ta=null,V.Ua=0,V.a=1,0):(V.Ta=V.V,V.Ua=V.Ba+ce+J,1)}function dn(V,J){var ce=V.C,ye=J-ce,we=V.V,Me=V.Ba+V.c*ce;for(t(J<=V.l.o);0<ye;){var Le=16<ye?16:ye,Be=V.l.ma,Pe=V.l.width,je=Pe*Le,ot=Be.ca,Tt=Be.tb+Pe*ce,It=V.Ta,yt=V.Ua;Ct(V,Le,we,Me),tl(It,yt,ot,Tt,je),rn(Be,ce,ce+Le,ot,Tt,Pe),ye-=Le,we+=Le*V.c,ce+=Le}t(ce==J),V.C=V.Ma=J}function Ne(){this.ub=this.yd=this.td=this.Rb=0}function qe(){this.Kd=this.Ld=this.Ud=this.Td=this.i=this.c=0}function nt(){this.Fb=this.Bb=this.Cb=0,this.Zb=i(4),this.Lb=i(4)}function Ht(){this.Yb=(function(){var V=[];return(function J(ce,ye,we){for(var Me=we[ye],Le=0;Le<Me&&(ce.push(we.length>ye+1?[]:0),!(we.length<ye+1));Le++)J(ce[Le],ye+1,we)})(V,0,[3,11]),V})()}function Qt(){this.jb=i(3),this.Wc=l([4,8],Ht),this.Xc=l([4,17],Ht)}function Ft(){this.Pc=this.wb=this.Tb=this.zd=0,this.vd=new i(4),this.od=new i(4)}function jt(){this.ld=this.La=this.dd=this.tc=0}function ln(){this.Na=this.la=0}function Vn(){this.Sc=[0,0],this.Eb=[0,0],this.Qc=[0,0],this.ia=this.lc=0}function un(){this.ad=i(384),this.Za=0,this.Ob=i(16),this.$b=this.Ad=this.ia=this.Gc=this.Hc=this.Dd=0}function st(){this.uc=this.M=this.Nb=0,this.wa=Array(new jt),this.Y=0,this.ya=Array(new un),this.aa=0,this.l=new qn}function Gt(){this.y=i(16),this.f=i(8),this.ea=i(8)}function kn(){this.cb=this.a=0,this.sc="",this.m=new G,this.Od=new Ne,this.Kc=new qe,this.ed=new Ft,this.Qa=new nt,this.Ic=this.$c=this.Aa=0,this.D=new st,this.Xb=this.Va=this.Hb=this.zb=this.yb=this.Ub=this.za=0,this.Jc=o(8,G),this.ia=0,this.pb=o(4,Vn),this.Pa=new Qt,this.Bd=this.kc=0,this.Ac=[],this.Bc=0,this.zc=[0,0,0,0],this.Gd=Array(new Gt),this.Hd=0,this.rb=Array(new ln),this.sb=0,this.wa=Array(new jt),this.Y=0,this.oc=[],this.pc=0,this.sa=[],this.ta=0,this.qa=[],this.ra=0,this.Ha=[],this.B=this.R=this.Ia=0,this.Ec=[],this.M=this.ja=this.Vb=this.Fc=0,this.ya=Array(new un),this.L=this.aa=0,this.gd=l([4,2],jt),this.ga=null,this.Fa=[],this.Cc=this.qc=this.P=0,this.Gb=[],this.Uc=0,this.mb=[],this.nb=0,this.rc=[],this.Ga=this.Vc=0}function qn(){this.T=this.U=this.ka=this.height=this.width=0,this.y=[],this.f=[],this.ea=[],this.Rc=this.fa=this.W=this.N=this.O=0,this.ma="void",this.put="VP8IoPutHook",this.ac="VP8IoSetupHook",this.bc="VP8IoTeardownHook",this.ha=this.Kb=0,this.data=[],this.hb=this.ib=this.da=this.o=this.j=this.va=this.v=this.Da=this.ob=this.w=0,this.F=[],this.J=0}function Or(){var V=new kn;return V!=null&&(V.a=0,V.sc="OK",V.cb=0,V.Xb=0,Jg||(Jg=qa)),V}function Qr(V,J,ce){return V.a==0&&(V.a=J,V.sc=ce,V.cb=0),0}function Ga(V,J,ce){return 3<=ce&&V[J+0]==157&&V[J+1]==1&&V[J+2]==42}function ei(V,J){if(V==null)return 0;if(V.a=0,V.sc="OK",J==null)return Qr(V,2,"null VP8Io passed to VP8GetHeaders()");var ce=J.data,ye=J.w,we=J.ha;if(4>we)return Qr(V,7,"Truncated header.");var Me=ce[ye+0]|ce[ye+1]<<8|ce[ye+2]<<16,Le=V.Od;if(Le.Rb=!(1&Me),Le.td=Me>>1&7,Le.yd=Me>>4&1,Le.ub=Me>>5,3<Le.td)return Qr(V,3,"Incorrect keyframe parameters.");if(!Le.yd)return Qr(V,4,"Frame not displayable.");ye+=3,we-=3;var Be=V.Kc;if(Le.Rb){if(7>we)return Qr(V,7,"cannot parse picture header");if(!Ga(ce,ye,we))return Qr(V,3,"Bad code word");Be.c=16383&(ce[ye+4]<<8|ce[ye+3]),Be.Td=ce[ye+4]>>6,Be.i=16383&(ce[ye+6]<<8|ce[ye+5]),Be.Ud=ce[ye+6]>>6,ye+=7,we-=7,V.za=Be.c+15>>4,V.Ub=Be.i+15>>4,J.width=Be.c,J.height=Be.i,J.Da=0,J.j=0,J.v=0,J.va=J.width,J.o=J.height,J.da=0,J.ib=J.width,J.hb=J.height,J.U=J.width,J.T=J.height,a((Me=V.Pa).jb,0,255,Me.jb.length),t((Me=V.Qa)!=null),Me.Cb=0,Me.Bb=0,Me.Fb=1,a(Me.Zb,0,0,Me.Zb.length),a(Me.Lb,0,0,Me.Lb)}if(Le.ub>we)return Qr(V,7,"bad partition length");D(Me=V.m,ce,ye,Le.ub),ye+=Le.ub,we-=Le.ub,Le.Rb&&(Be.Ld=Y(Me),Be.Kd=Y(Me)),Be=V.Qa;var Pe,je=V.Pa;if(t(Me!=null),t(Be!=null),Be.Cb=Y(Me),Be.Cb){if(Be.Bb=Y(Me),Y(Me)){for(Be.Fb=Y(Me),Pe=0;4>Pe;++Pe)Be.Zb[Pe]=Y(Me)?$(Me,7):0;for(Pe=0;4>Pe;++Pe)Be.Lb[Pe]=Y(Me)?$(Me,6):0}if(Be.Bb)for(Pe=0;3>Pe;++Pe)je.jb[Pe]=Y(Me)?B(Me,8):255}else Be.Bb=0;if(Me.Ka)return Qr(V,3,"cannot parse segment header");if((Be=V.ed).zd=Y(Me),Be.Tb=B(Me,6),Be.wb=B(Me,3),Be.Pc=Y(Me),Be.Pc&&Y(Me)){for(je=0;4>je;++je)Y(Me)&&(Be.vd[je]=$(Me,6));for(je=0;4>je;++je)Y(Me)&&(Be.od[je]=$(Me,6))}if(V.L=Be.Tb==0?0:Be.zd?1:2,Me.Ka)return Qr(V,3,"cannot parse filter header");var ot=we;if(we=Pe=ye,ye=Pe+ot,Be=ot,V.Xb=(1<<B(V.m,2))-1,ot<3*(je=V.Xb))ce=7;else{for(Pe+=3*je,Be-=3*je,ot=0;ot<je;++ot){var Tt=ce[we+0]|ce[we+1]<<8|ce[we+2]<<16;Tt>Be&&(Tt=Be),D(V.Jc[+ot],ce,Pe,Tt),Pe+=Tt,Be-=Tt,we+=3}D(V.Jc[+je],ce,Pe,Be),ce=Pe<ye?0:5}if(ce!=0)return Qr(V,ce,"cannot parse partitions");for(ce=B(Pe=V.m,7),we=Y(Pe)?$(Pe,4):0,ye=Y(Pe)?$(Pe,4):0,Be=Y(Pe)?$(Pe,4):0,je=Y(Pe)?$(Pe,4):0,Pe=Y(Pe)?$(Pe,4):0,ot=V.Qa,Tt=0;4>Tt;++Tt){if(ot.Cb){var It=ot.Zb[Tt];ot.Fb||(It+=ce)}else{if(0<Tt){V.pb[Tt]=V.pb[0];continue}It=ce}var yt=V.pb[Tt];yt.Sc[0]=F1[wu(It+we,127)],yt.Sc[1]=vA[wu(It+0,127)],yt.Eb[0]=2*F1[wu(It+ye,127)],yt.Eb[1]=101581*vA[wu(It+Be,127)]>>16,8>yt.Eb[1]&&(yt.Eb[1]=8),yt.Qc[0]=F1[wu(It+je,117)],yt.Qc[1]=vA[wu(It+Pe,127)],yt.lc=It+Pe}if(!Le.Rb)return Qr(V,4,"Not a key frame.");for(Y(Me),Le=V.Pa,ce=0;4>ce;++ce){for(we=0;8>we;++we)for(ye=0;3>ye;++ye)for(Be=0;11>Be;++Be)je=ee(Me,fF[ce][we][ye][Be])?B(Me,8):zC[ce][we][ye][Be],Le.Wc[ce][we].Yb[ye][Be]=je;for(we=0;17>we;++we)Le.Xc[ce][we]=Le.Wc[ce][k_[we]]}return V.kc=Y(Me),V.kc&&(V.Bd=B(Me,8)),V.cb=1}function qa(V,J,ce,ye,we,Me,Le){var Be=J[we].Yb[ce];for(ce=0;16>we;++we){if(!ee(V,Be[ce+0]))return we;for(;!ee(V,Be[ce+1]);)if(Be=J[++we].Yb[0],ce=0,we==16)return 16;var Pe=J[we+1].Yb;if(ee(V,Be[ce+2])){var je=V,ot=0;if(ee(je,(It=Be)[(Tt=ce)+3]))if(ee(je,It[Tt+6])){for(Be=0,Tt=2*(ot=ee(je,It[Tt+8]))+(It=ee(je,It[Tt+9+ot])),ot=0,It=O_[Tt];It[Be];++Be)ot+=ot+ee(je,It[Be]);ot+=3+(8<<Tt)}else ee(je,It[Tt+7])?(ot=7+2*ee(je,165),ot+=ee(je,145)):ot=5+ee(je,159);else ot=ee(je,It[Tt+4])?3+ee(je,It[Tt+5]):2;Be=Pe[2]}else ot=1,Be=Pe[1];Pe=Le+M_[we],0>(je=V).b&&Z(je);var Tt,It=je.b,yt=(Tt=je.Ca>>1)-(je.I>>It)>>31;--je.b,je.Ca+=yt,je.Ca|=1,je.I-=(Tt+1&yt)<<It,Me[Pe]=((ot^yt)-yt)*ye[(0<we)+0]}return 16}function Qa(V){var J=V.rb[V.sb-1];J.la=0,J.Na=0,a(V.zc,0,0,V.zc.length),V.ja=0}function $i(V,J){if(V==null)return 0;if(J==null)return Qr(V,2,"NULL VP8Io parameter in VP8Decode().");if(!V.cb&&!ei(V,J))return 0;if(t(V.cb),J.ac==null||J.ac(J)){J.ob&&(V.L=0);var ce=n0[V.L];if(V.L==2?(V.yb=0,V.zb=0):(V.yb=J.v-ce>>4,V.zb=J.j-ce>>4,0>V.yb&&(V.yb=0),0>V.zb&&(V.zb=0)),V.Va=J.o+15+ce>>4,V.Hb=J.va+15+ce>>4,V.Hb>V.za&&(V.Hb=V.za),V.Va>V.Ub&&(V.Va=V.Ub),0<V.L){var ye=V.ed;for(ce=0;4>ce;++ce){var we;if(V.Qa.Cb){var Me=V.Qa.Lb[ce];V.Qa.Fb||(Me+=ye.Tb)}else Me=ye.Tb;for(we=0;1>=we;++we){var Le=V.gd[ce][we],Be=Me;if(ye.Pc&&(Be+=ye.vd[0],we&&(Be+=ye.od[0])),0<(Be=0>Be?0:63<Be?63:Be)){var Pe=Be;0<ye.wb&&(Pe=4<ye.wb?Pe>>2:Pe>>1)>9-ye.wb&&(Pe=9-ye.wb),1>Pe&&(Pe=1),Le.dd=Pe,Le.tc=2*Be+Pe,Le.ld=40<=Be?2:15<=Be?1:0}else Le.tc=0;Le.La=we}}}ce=0}else Qr(V,6,"Frame setup failed"),ce=V.a;if(ce=ce==0){if(ce){V.$c=0,0<V.Aa||(V.Ic=Wp);e:{ce=V.Ic,ye=4*(Pe=V.za);var je=32*Pe,ot=Pe+1,Tt=0<V.L?Pe*(0<V.Aa?2:1):0,It=(V.Aa==2?2:1)*Pe;if((Le=ye+832+(we=3*(16*ce+n0[V.L])/2*je)+(Me=V.Fa!=null&&0<V.Fa.length?V.Kc.c*V.Kc.i:0))!=Le)ce=0;else{if(Le>V.Vb){if(V.Vb=0,V.Ec=i(Le),V.Fc=0,V.Ec==null){ce=Qr(V,1,"no memory during frame initialization.");break e}V.Vb=Le}Le=V.Ec,Be=V.Fc,V.Ac=Le,V.Bc=Be,Be+=ye,V.Gd=o(je,Gt),V.Hd=0,V.rb=o(ot+1,ln),V.sb=1,V.wa=Tt?o(Tt,jt):null,V.Y=0,V.D.Nb=0,V.D.wa=V.wa,V.D.Y=V.Y,0<V.Aa&&(V.D.Y+=Pe),t(!0),V.oc=Le,V.pc=Be,Be+=832,V.ya=o(It,un),V.aa=0,V.D.ya=V.ya,V.D.aa=V.aa,V.Aa==2&&(V.D.aa+=Pe),V.R=16*Pe,V.B=8*Pe,Pe=(je=n0[V.L])*V.R,je=je/2*V.B,V.sa=Le,V.ta=Be+Pe,V.qa=V.sa,V.ra=V.ta+16*ce*V.R+je,V.Ha=V.qa,V.Ia=V.ra+8*ce*V.B+je,V.$c=0,Be+=we,V.mb=Me?Le:null,V.nb=Me?Be:null,t(Be+Me<=V.Fc+V.Vb),Qa(V),a(V.Ac,V.Bc,0,ye),ce=1}}if(ce){if(J.ka=0,J.y=V.sa,J.O=V.ta,J.f=V.qa,J.N=V.ra,J.ea=V.Ha,J.Vd=V.Ia,J.fa=V.R,J.Rc=V.B,J.F=null,J.J=0,!fA){for(ce=-255;255>=ce;++ce)xl[255+ce]=0>ce?-ce:ce;for(ce=-1020;1020>=ce;++ce)$f[1020+ce]=-128>ce?-128:127<ce?127:ce;for(ce=-112;112>=ce;++ce)B1[112+ce]=-16>ce?-16:15<ce?15:ce;for(ce=-255;510>=ce;++ce)Kg[255+ce]=0>ce?0:255<ce?255:ce;fA=1}D1=Lr,Up=pa,zp=Ta,qs=Ci,Cu=sr,Li=ra,Wg=S1,dA=Dl,qg=zg,Qg=oA,Yg=o2,Tu=l2,Hp=Hg,Pf=x1,jp=Yd,Gp=sd,p2=cd,_s=H5,fd[0]=fc,fd[1]=ma,fd[2]=ys,fd[3]=bs,fd[4]=Lf,fd[5]=Pr,fd[6]=Xn,fd[7]=ki,fd[8]=po,fd[9]=bo,Ac[0]=Qn,Ac[1]=or,Ac[2]=Ua,Ac[3]=Mi,Ac[4]=zn,Ac[5]=yr,Ac[6]=Aa,zc[0]=ns,zc[1]=Ar,zc[2]=a2,zc[3]=Eu,zc[4]=Fg,zc[5]=b1,zc[6]=aA,ce=1}else ce=0}ce&&(ce=(function(yt,sn){for(yt.M=0;yt.M<yt.Va;++yt.M){var Vt,ut=yt.Jc[yt.M&yt.Xb],dt=yt.m,en=yt;for(Vt=0;Vt<en.za;++Vt){var Jt=dt,nn=en,tr=nn.Ac,Fn=nn.Bc+4*Vt,jr=nn.zc,Hn=nn.ya[nn.aa+Vt];if(nn.Qa.Bb?Hn.$b=ee(Jt,nn.Pa.jb[0])?2+ee(Jt,nn.Pa.jb[2]):ee(Jt,nn.Pa.jb[1]):Hn.$b=0,nn.kc&&(Hn.Ad=ee(Jt,nn.Bd)),Hn.Za=!ee(Jt,145)+0,Hn.Za){var Ti=Hn.Ob,Ii=0;for(nn=0;4>nn;++nn){var fi,za=jr[0+nn];for(fi=0;4>fi;++fi){za=dF[tr[Fn+fi]][za];for(var Qi=UC[ee(Jt,za[0])];0<Qi;)Qi=UC[2*Qi+ee(Jt,za[Qi])];za=-Qi,tr[Fn+fi]=za}r(Ti,Ii,tr,Fn,4),Ii+=4,jr[0+nn]=za}}else za=ee(Jt,156)?ee(Jt,128)?1:3:ee(Jt,163)?2:0,Hn.Ob[0]=za,a(tr,Fn,za,4),a(jr,0,za,4);Hn.Dd=ee(Jt,142)?ee(Jt,114)?ee(Jt,183)?1:3:2:0}if(en.m.Ka)return Qr(yt,7,"Premature end-of-partition0 encountered.");for(;yt.ja<yt.za;++yt.ja){if(en=ut,Jt=(dt=yt).rb[dt.sb-1],tr=dt.rb[dt.sb+dt.ja],Vt=dt.ya[dt.aa+dt.ja],Fn=dt.kc?Vt.Ad:0)Jt.la=tr.la=0,Vt.Za||(Jt.Na=tr.Na=0),Vt.Hc=0,Vt.Gc=0,Vt.ia=0;else{var ro,ha;if(Jt=tr,tr=en,Fn=dt.Pa.Xc,jr=dt.ya[dt.aa+dt.ja],Hn=dt.pb[jr.$b],nn=jr.ad,Ti=0,Ii=dt.rb[dt.sb-1],za=fi=0,a(nn,Ti,0,384),jr.Za)var Ho=0,vc=Fn[3];else{Qi=i(16);var hl=Jt.Na+Ii.Na;if(hl=Jg(tr,Fn[1],hl,Hn.Eb,0,Qi,0),Jt.Na=Ii.Na=(0<hl)+0,1<hl)D1(Qi,0,nn,Ti);else{var Bl=Qi[0]+3>>3;for(Qi=0;256>Qi;Qi+=16)nn[Ti+Qi]=Bl}Ho=1,vc=Fn[0]}var Fi=15&Jt.la,Ys=15&Ii.la;for(Qi=0;4>Qi;++Qi){var Ks=1&Ys;for(Bl=ha=0;4>Bl;++Bl)Fi=Fi>>1|(Ks=(hl=Jg(tr,vc,hl=Ks+(1&Fi),Hn.Sc,Ho,nn,Ti))>Ho)<<7,ha=ha<<2|(3<hl?3:1<hl?2:nn[Ti+0]!=0),Ti+=16;Fi>>=4,Ys=Ys>>1|Ks<<7,fi=(fi<<8|ha)>>>0}for(vc=Fi,Ho=Ys>>4,ro=0;4>ro;ro+=2){for(ha=0,Fi=Jt.la>>4+ro,Ys=Ii.la>>4+ro,Qi=0;2>Qi;++Qi){for(Ks=1&Ys,Bl=0;2>Bl;++Bl)hl=Ks+(1&Fi),Fi=Fi>>1|(Ks=0<(hl=Jg(tr,Fn[2],hl,Hn.Qc,0,nn,Ti)))<<3,ha=ha<<2|(3<hl?3:1<hl?2:nn[Ti+0]!=0),Ti+=16;Fi>>=2,Ys=Ys>>1|Ks<<5}za|=ha<<4*ro,vc|=Fi<<4<<ro,Ho|=(240&Ys)<<ro}Jt.la=vc,Ii.la=Ho,jr.Hc=fi,jr.Gc=za,jr.ia=43690&za?0:Hn.ia,Fn=!(fi|za)}if(0<dt.L&&(dt.wa[dt.Y+dt.ja]=dt.gd[Vt.$b][Vt.Za],dt.wa[dt.Y+dt.ja].La|=!Fn),en.Ka)return Qr(yt,7,"Premature end-of-file encountered.")}if(Qa(yt),dt=sn,en=1,Vt=(ut=yt).D,Jt=0<ut.L&&ut.M>=ut.zb&&ut.M<=ut.Va,ut.Aa==0)e:{if(Vt.M=ut.M,Vt.uc=Jt,C1(ut,Vt),en=1,Vt=(ha=ut.D).Nb,Jt=(za=n0[ut.L])*ut.R,tr=za/2*ut.B,Qi=16*Vt*ut.R,Bl=8*Vt*ut.B,Fn=ut.sa,jr=ut.ta-Jt+Qi,Hn=ut.qa,nn=ut.ra-tr+Bl,Ti=ut.Ha,Ii=ut.Ia-tr+Bl,Ys=(Fi=ha.M)==0,fi=Fi>=ut.Va-1,ut.Aa==2&&C1(ut,ha),ha.uc)for(Ks=(hl=ut).D.M,t(hl.D.uc),ha=hl.yb;ha<hl.Hb;++ha){Ho=ha,vc=Ks;var jo=(Pl=(Ui=hl).D).Nb;ro=Ui.R;var Pl=Pl.wa[Pl.Y+Ho],xs=Ui.sa,Vc=Ui.ta+16*jo*ro+16*Ho,pd=Pl.dd,Go=Pl.tc;if(Go!=0)if(t(3<=Go),Ui.L==1)0<Ho&&Gp(xs,Vc,ro,Go+4),Pl.La&&_s(xs,Vc,ro,Go),0<vc&&jp(xs,Vc,ro,Go+4),Pl.La&&p2(xs,Vc,ro,Go);else{var El=Ui.B,Iu=Ui.qa,A2=Ui.ra+8*jo*El+8*Ho,qp=Ui.Ha,Ui=Ui.Ia+8*jo*El+8*Ho;jo=Pl.ld,0<Ho&&(dA(xs,Vc,ro,Go+4,pd,jo),Qg(Iu,A2,qp,Ui,El,Go+4,pd,jo)),Pl.La&&(Tu(xs,Vc,ro,Go,pd,jo),Pf(Iu,A2,qp,Ui,El,Go,pd,jo)),0<vc&&(Wg(xs,Vc,ro,Go+4,pd,jo),qg(Iu,A2,qp,Ui,El,Go+4,pd,jo)),Pl.La&&(Yg(xs,Vc,ro,Go,pd,jo),Hp(Iu,A2,qp,Ui,El,Go,pd,jo))}}if(ut.ia&&alert("todo:DitherRow"),dt.put!=null){if(ha=16*Fi,Fi=16*(Fi+1),Ys?(dt.y=ut.sa,dt.O=ut.ta+Qi,dt.f=ut.qa,dt.N=ut.ra+Bl,dt.ea=ut.Ha,dt.W=ut.Ia+Bl):(ha-=za,dt.y=Fn,dt.O=jr,dt.f=Hn,dt.N=nn,dt.ea=Ti,dt.W=Ii),fi||(Fi-=za),Fi>dt.o&&(Fi=dt.o),dt.F=null,dt.J=null,ut.Fa!=null&&0<ut.Fa.length&&ha<Fi&&(dt.J=sA(ut,dt,ha,Fi-ha),dt.F=ut.mb,dt.F==null&&dt.F.length==0)){en=Qr(ut,3,"Could not decode alpha data.");break e}ha<dt.j&&(za=dt.j-ha,ha=dt.j,t(!(1&za)),dt.O+=ut.R*za,dt.N+=ut.B*(za>>1),dt.W+=ut.B*(za>>1),dt.F!=null&&(dt.J+=dt.width*za)),ha<Fi&&(dt.O+=dt.v,dt.N+=dt.v>>1,dt.W+=dt.v>>1,dt.F!=null&&(dt.J+=dt.v),dt.ka=ha-dt.j,dt.U=dt.va-dt.v,dt.T=Fi-ha,en=dt.put(dt))}Vt+1!=ut.Ic||fi||(r(ut.sa,ut.ta-Jt,Fn,jr+16*ut.R,Jt),r(ut.qa,ut.ra-tr,Hn,nn+8*ut.B,tr),r(ut.Ha,ut.Ia-tr,Ti,Ii+8*ut.B,tr))}if(!en)return Qr(yt,6,"Output aborted.")}return 1})(V,J)),J.bc!=null&&J.bc(J),ce&=1}return ce?(V.cb=0,ce):0}function zr(V,J,ce,ye,we){we=V[J+ce+32*ye]+(we>>3),V[J+ce+32*ye]=-256&we?0>we?0:255:we}function Bn(V,J,ce,ye,we,Me){zr(V,J,0,ce,ye+we),zr(V,J,1,ce,ye+Me),zr(V,J,2,ce,ye-Me),zr(V,J,3,ce,ye-we)}function xn(V){return(20091*V>>16)+V}function Hr(V,J,ce,ye){var we,Me=0,Le=i(16);for(we=0;4>we;++we){var Be=V[J+0]+V[J+8],Pe=V[J+0]-V[J+8],je=(35468*V[J+4]>>16)-xn(V[J+12]),ot=xn(V[J+4])+(35468*V[J+12]>>16);Le[Me+0]=Be+ot,Le[Me+1]=Pe+je,Le[Me+2]=Pe-je,Le[Me+3]=Be-ot,Me+=4,J++}for(we=Me=0;4>we;++we)Be=(V=Le[Me+0]+4)+Le[Me+8],Pe=V-Le[Me+8],je=(35468*Le[Me+4]>>16)-xn(Le[Me+12]),zr(ce,ye,0,0,Be+(ot=xn(Le[Me+4])+(35468*Le[Me+12]>>16))),zr(ce,ye,1,0,Pe+je),zr(ce,ye,2,0,Pe-je),zr(ce,ye,3,0,Be-ot),Me++,ye+=32}function ra(V,J,ce,ye){var we=V[J+0]+4,Me=35468*V[J+4]>>16,Le=xn(V[J+4]),Be=35468*V[J+1]>>16;Bn(ce,ye,0,we+Le,V=xn(V[J+1]),Be),Bn(ce,ye,1,we+Me,V,Be),Bn(ce,ye,2,we-Me,V,Be),Bn(ce,ye,3,we-Le,V,Be)}function pa(V,J,ce,ye,we){Hr(V,J,ce,ye),we&&Hr(V,J+16,ce,ye+4)}function Ta(V,J,ce,ye){Up(V,J+0,ce,ye,1),Up(V,J+32,ce,ye+128,1)}function Ci(V,J,ce,ye){var we;for(V=V[J+0]+4,we=0;4>we;++we)for(J=0;4>J;++J)zr(ce,ye,J,we,V)}function sr(V,J,ce,ye){V[J+0]&&qs(V,J+0,ce,ye),V[J+16]&&qs(V,J+16,ce,ye+4),V[J+32]&&qs(V,J+32,ce,ye+128),V[J+48]&&qs(V,J+48,ce,ye+128+4)}function Lr(V,J,ce,ye){var we,Me=i(16);for(we=0;4>we;++we){var Le=V[J+0+we]+V[J+12+we],Be=V[J+4+we]+V[J+8+we],Pe=V[J+4+we]-V[J+8+we],je=V[J+0+we]-V[J+12+we];Me[0+we]=Le+Be,Me[8+we]=Le-Be,Me[4+we]=je+Pe,Me[12+we]=je-Pe}for(we=0;4>we;++we)Le=(V=Me[0+4*we]+3)+Me[3+4*we],Be=Me[1+4*we]+Me[2+4*we],Pe=Me[1+4*we]-Me[2+4*we],je=V-Me[3+4*we],ce[ye+0]=Le+Be>>3,ce[ye+16]=je+Pe>>3,ce[ye+32]=Le-Be>>3,ce[ye+48]=je-Pe>>3,ye+=64}function xa(V,J,ce){var ye,we=J-32,Me=mc,Le=255-V[we-1];for(ye=0;ye<ce;++ye){var Be,Pe=Me,je=Le+V[J-1];for(Be=0;Be<ce;++Be)V[J+Be]=Pe[je+V[we+Be]];J+=32}}function ma(V,J){xa(V,J,4)}function Ar(V,J){xa(V,J,8)}function or(V,J){xa(V,J,16)}function Ua(V,J){var ce;for(ce=0;16>ce;++ce)r(V,J+32*ce,V,J-32,16)}function Mi(V,J){var ce;for(ce=16;0<ce;--ce)a(V,J,V[J-1],16),J+=32}function vn(V,J,ce){var ye;for(ye=0;16>ye;++ye)a(J,ce+32*ye,V,16)}function Qn(V,J){var ce,ye=16;for(ce=0;16>ce;++ce)ye+=V[J-1+32*ce]+V[J+ce-32];vn(ye>>5,V,J)}function zn(V,J){var ce,ye=8;for(ce=0;16>ce;++ce)ye+=V[J-1+32*ce];vn(ye>>4,V,J)}function yr(V,J){var ce,ye=8;for(ce=0;16>ce;++ce)ye+=V[J+ce-32];vn(ye>>4,V,J)}function Aa(V,J){vn(128,V,J)}function cr(V,J,ce){return V+2*J+ce+2>>2}function ys(V,J){var ce,ye=J-32;for(ye=new Uint8Array([cr(V[ye-1],V[ye+0],V[ye+1]),cr(V[ye+0],V[ye+1],V[ye+2]),cr(V[ye+1],V[ye+2],V[ye+3]),cr(V[ye+2],V[ye+3],V[ye+4])]),ce=0;4>ce;++ce)r(V,J+32*ce,ye,0,ye.length)}function bs(V,J){var ce=V[J-1],ye=V[J-1+32],we=V[J-1+64],Me=V[J-1+96];ae(V,J+0,16843009*cr(V[J-1-32],ce,ye)),ae(V,J+32,16843009*cr(ce,ye,we)),ae(V,J+64,16843009*cr(ye,we,Me)),ae(V,J+96,16843009*cr(we,Me,Me))}function fc(V,J){var ce,ye=4;for(ce=0;4>ce;++ce)ye+=V[J+ce-32]+V[J-1+32*ce];for(ye>>=3,ce=0;4>ce;++ce)a(V,J+32*ce,ye,4)}function Lf(V,J){var ce=V[J-1+0],ye=V[J-1+32],we=V[J-1+64],Me=V[J-1-32],Le=V[J+0-32],Be=V[J+1-32],Pe=V[J+2-32],je=V[J+3-32];V[J+0+96]=cr(ye,we,V[J-1+96]),V[J+1+96]=V[J+0+64]=cr(ce,ye,we),V[J+2+96]=V[J+1+64]=V[J+0+32]=cr(Me,ce,ye),V[J+3+96]=V[J+2+64]=V[J+1+32]=V[J+0+0]=cr(Le,Me,ce),V[J+3+64]=V[J+2+32]=V[J+1+0]=cr(Be,Le,Me),V[J+3+32]=V[J+2+0]=cr(Pe,Be,Le),V[J+3+0]=cr(je,Pe,Be)}function Xn(V,J){var ce=V[J+1-32],ye=V[J+2-32],we=V[J+3-32],Me=V[J+4-32],Le=V[J+5-32],Be=V[J+6-32],Pe=V[J+7-32];V[J+0+0]=cr(V[J+0-32],ce,ye),V[J+1+0]=V[J+0+32]=cr(ce,ye,we),V[J+2+0]=V[J+1+32]=V[J+0+64]=cr(ye,we,Me),V[J+3+0]=V[J+2+32]=V[J+1+64]=V[J+0+96]=cr(we,Me,Le),V[J+3+32]=V[J+2+64]=V[J+1+96]=cr(Me,Le,Be),V[J+3+64]=V[J+2+96]=cr(Le,Be,Pe),V[J+3+96]=cr(Be,Pe,Pe)}function Pr(V,J){var ce=V[J-1+0],ye=V[J-1+32],we=V[J-1+64],Me=V[J-1-32],Le=V[J+0-32],Be=V[J+1-32],Pe=V[J+2-32],je=V[J+3-32];V[J+0+0]=V[J+1+64]=Me+Le+1>>1,V[J+1+0]=V[J+2+64]=Le+Be+1>>1,V[J+2+0]=V[J+3+64]=Be+Pe+1>>1,V[J+3+0]=Pe+je+1>>1,V[J+0+96]=cr(we,ye,ce),V[J+0+64]=cr(ye,ce,Me),V[J+0+32]=V[J+1+96]=cr(ce,Me,Le),V[J+1+32]=V[J+2+96]=cr(Me,Le,Be),V[J+2+32]=V[J+3+96]=cr(Le,Be,Pe),V[J+3+32]=cr(Be,Pe,je)}function ki(V,J){var ce=V[J+0-32],ye=V[J+1-32],we=V[J+2-32],Me=V[J+3-32],Le=V[J+4-32],Be=V[J+5-32],Pe=V[J+6-32],je=V[J+7-32];V[J+0+0]=ce+ye+1>>1,V[J+1+0]=V[J+0+64]=ye+we+1>>1,V[J+2+0]=V[J+1+64]=we+Me+1>>1,V[J+3+0]=V[J+2+64]=Me+Le+1>>1,V[J+0+32]=cr(ce,ye,we),V[J+1+32]=V[J+0+96]=cr(ye,we,Me),V[J+2+32]=V[J+1+96]=cr(we,Me,Le),V[J+3+32]=V[J+2+96]=cr(Me,Le,Be),V[J+3+64]=cr(Le,Be,Pe),V[J+3+96]=cr(Be,Pe,je)}function bo(V,J){var ce=V[J-1+0],ye=V[J-1+32],we=V[J-1+64],Me=V[J-1+96];V[J+0+0]=ce+ye+1>>1,V[J+2+0]=V[J+0+32]=ye+we+1>>1,V[J+2+32]=V[J+0+64]=we+Me+1>>1,V[J+1+0]=cr(ce,ye,we),V[J+3+0]=V[J+1+32]=cr(ye,we,Me),V[J+3+32]=V[J+1+64]=cr(we,Me,Me),V[J+3+64]=V[J+2+64]=V[J+0+96]=V[J+1+96]=V[J+2+96]=V[J+3+96]=Me}function po(V,J){var ce=V[J-1+0],ye=V[J-1+32],we=V[J-1+64],Me=V[J-1+96],Le=V[J-1-32],Be=V[J+0-32],Pe=V[J+1-32],je=V[J+2-32];V[J+0+0]=V[J+2+32]=ce+Le+1>>1,V[J+0+32]=V[J+2+64]=ye+ce+1>>1,V[J+0+64]=V[J+2+96]=we+ye+1>>1,V[J+0+96]=Me+we+1>>1,V[J+3+0]=cr(Be,Pe,je),V[J+2+0]=cr(Le,Be,Pe),V[J+1+0]=V[J+3+32]=cr(ce,Le,Be),V[J+1+32]=V[J+3+64]=cr(ye,ce,Le),V[J+1+64]=V[J+3+96]=cr(we,ye,ce),V[J+1+96]=cr(Me,we,ye)}function a2(V,J){var ce;for(ce=0;8>ce;++ce)r(V,J+32*ce,V,J-32,8)}function Eu(V,J){var ce;for(ce=0;8>ce;++ce)a(V,J,V[J-1],8),J+=32}function $c(V,J,ce){var ye;for(ye=0;8>ye;++ye)a(J,ce+32*ye,V,8)}function ns(V,J){var ce,ye=8;for(ce=0;8>ce;++ce)ye+=V[J+ce-32]+V[J-1+32*ce];$c(ye>>4,V,J)}function b1(V,J){var ce,ye=4;for(ce=0;8>ce;++ce)ye+=V[J+ce-32];$c(ye>>3,V,J)}function Fg(V,J){var ce,ye=4;for(ce=0;8>ce;++ce)ye+=V[J-1+32*ce];$c(ye>>3,V,J)}function aA(V,J){$c(128,V,J)}function i2(V,J,ce){var ye=V[J-ce],we=V[J+0],Me=3*(we-ye)+Ff[1020+V[J-2*ce]-V[J+ce]],Le=P1[112+(Me+4>>3)];V[J-ce]=mc[255+ye+P1[112+(Me+3>>3)]],V[J+0]=mc[255+we-Le]}function Ug(V,J,ce,ye){var we=V[J+0],Me=V[J+ce];return dd[255+V[J-2*ce]-V[J-ce]]>ye||dd[255+Me-we]>ye}function _1(V,J,ce,ye){return 4*dd[255+V[J-ce]-V[J+0]]+dd[255+V[J-2*ce]-V[J+ce]]<=ye}function iA(V,J,ce,ye,we){var Me=V[J-3*ce],Le=V[J-2*ce],Be=V[J-ce],Pe=V[J+0],je=V[J+ce],ot=V[J+2*ce],Tt=V[J+3*ce];return 4*dd[255+Be-Pe]+dd[255+Le-je]>ye?0:dd[255+V[J-4*ce]-Me]<=we&&dd[255+Me-Le]<=we&&dd[255+Le-Be]<=we&&dd[255+Tt-ot]<=we&&dd[255+ot-je]<=we&&dd[255+je-Pe]<=we}function Yd(V,J,ce,ye){var we=2*ye+1;for(ye=0;16>ye;++ye)_1(V,J+ye,ce,we)&&i2(V,J+ye,ce)}function sd(V,J,ce,ye){var we=2*ye+1;for(ye=0;16>ye;++ye)_1(V,J+ye*ce,1,we)&&i2(V,J+ye*ce,1)}function cd(V,J,ce,ye){var we;for(we=3;0<we;--we)Yd(V,J+=4*ce,ce,ye)}function H5(V,J,ce,ye){var we;for(we=3;0<we;--we)sd(V,J+=4,ce,ye)}function Kd(V,J,ce,ye,we,Me,Le,Be){for(Me=2*Me+1;0<we--;){if(iA(V,J,ce,Me,Le))if(Ug(V,J,ce,Be))i2(V,J,ce);else{var Pe=V,je=J,ot=ce,Tt=Pe[je-2*ot],It=Pe[je-ot],yt=Pe[je+0],sn=Pe[je+ot],Vt=Pe[je+2*ot],ut=27*(en=Ff[1020+3*(yt-It)+Ff[1020+Tt-sn]])+63>>7,dt=18*en+63>>7,en=9*en+63>>7;Pe[je-3*ot]=mc[255+Pe[je-3*ot]+en],Pe[je-2*ot]=mc[255+Tt+dt],Pe[je-ot]=mc[255+It+ut],Pe[je+0]=mc[255+yt-ut],Pe[je+ot]=mc[255+sn-dt],Pe[je+2*ot]=mc[255+Vt-en]}J+=ye}}function Fc(V,J,ce,ye,we,Me,Le,Be){for(Me=2*Me+1;0<we--;){if(iA(V,J,ce,Me,Le))if(Ug(V,J,ce,Be))i2(V,J,ce);else{var Pe=V,je=J,ot=ce,Tt=Pe[je-ot],It=Pe[je+0],yt=Pe[je+ot],sn=P1[112+((Vt=3*(It-Tt))+4>>3)],Vt=P1[112+(Vt+3>>3)],ut=sn+1>>1;Pe[je-2*ot]=mc[255+Pe[je-2*ot]+ut],Pe[je-ot]=mc[255+Tt+Vt],Pe[je+0]=mc[255+It-sn],Pe[je+ot]=mc[255+yt-ut]}J+=ye}}function S1(V,J,ce,ye,we,Me){Kd(V,J,ce,1,16,ye,we,Me)}function Dl(V,J,ce,ye,we,Me){Kd(V,J,1,ce,16,ye,we,Me)}function o2(V,J,ce,ye,we,Me){var Le;for(Le=3;0<Le;--Le)Fc(V,J+=4*ce,ce,1,16,ye,we,Me)}function l2(V,J,ce,ye,we,Me){var Le;for(Le=3;0<Le;--Le)Fc(V,J+=4,1,ce,16,ye,we,Me)}function zg(V,J,ce,ye,we,Me,Le,Be){Kd(V,J,we,1,8,Me,Le,Be),Kd(ce,ye,we,1,8,Me,Le,Be)}function oA(V,J,ce,ye,we,Me,Le,Be){Kd(V,J,1,we,8,Me,Le,Be),Kd(ce,ye,1,we,8,Me,Le,Be)}function Hg(V,J,ce,ye,we,Me,Le,Be){Fc(V,J+4*we,we,1,8,Me,Le,Be),Fc(ce,ye+4*we,we,1,8,Me,Le,Be)}function x1(V,J,ce,ye,we,Me,Le,Be){Fc(V,J+4,1,we,8,Me,Le,Be),Fc(ce,ye+4,1,we,8,Me,Le,Be)}function Df(){this.ba=new mt,this.ec=[],this.cc=[],this.Mc=[],this.Dc=this.Nc=this.dc=this.fc=0,this.Oa=new Dt,this.memory=0,this.Ib="OutputFunc",this.Jb="OutputAlphaFunc",this.Nd="OutputRowFunc"}function s2(){this.data=[],this.offset=this.kd=this.ha=this.w=0,this.na=[],this.xa=this.gb=this.Ja=this.Sa=this.P=0}function E1(){this.nc=this.Ea=this.b=this.hc=0,this.K=[],this.w=0}function j5(){this.ua=0,this.Wa=new ie,this.vb=new ie,this.md=this.xc=this.wc=0,this.vc=[],this.Wb=0,this.Ya=new M,this.yc=new k}function N_(){this.xb=this.a=0,this.l=new qn,this.ca=new mt,this.V=[],this.Ba=0,this.Ta=[],this.Ua=0,this.m=new F,this.Pb=0,this.wd=new F,this.Ma=this.$=this.C=this.i=this.c=this.xd=0,this.s=new j5,this.ab=0,this.gc=o(4,E1),this.Oc=0}function w1(){this.Lc=this.Z=this.$a=this.i=this.c=0,this.l=new qn,this.ic=0,this.ca=[],this.tb=0,this.qd=null,this.rd=0}function Bp(V,J,ce,ye,we,Me,Le){for(V=V==null?0:V[J+0],J=0;J<Le;++J)we[Me+J]=V+ce[ye+J]&255,V=we[Me+J]}function lA(V,J,ce,ye,we,Me,Le){var Be;if(V==null)Bp(null,null,ce,ye,we,Me,Le);else for(Be=0;Be<Le;++Be)we[Me+Be]=V[J+Be]+ce[ye+Be]&255}function c2(V,J,ce,ye,we,Me,Le){if(V==null)Bp(null,null,ce,ye,we,Me,Le);else{var Be,Pe=V[J+0],je=Pe,ot=Pe;for(Be=0;Be<Le;++Be)je=ot+(Pe=V[J+Be])-je,ot=ce[ye+Be]+(-256&je?0>je?0:255:je)&255,je=Pe,we[Me+Be]=ot}}function sA(V,J,ce,ye){var we=J.width,Me=J.o;if(t(V!=null&&J!=null),0>ce||0>=ye||ce+ye>Me)return null;if(!V.Cc){if(V.ga==null){var Le;if(V.ga=new w1,(Le=V.ga==null)||(Le=J.width*J.o,t(V.Gb.length==0),V.Gb=i(Le),V.Uc=0,V.Gb==null?Le=0:(V.mb=V.Gb,V.nb=V.Uc,V.rc=null,Le=1),Le=!Le),!Le){Le=V.ga;var Be=V.Fa,Pe=V.P,je=V.qc,ot=V.mb,Tt=V.nb,It=Pe+1,yt=je-1,sn=Le.l;if(t(Be!=null&&ot!=null&&J!=null),Qs[0]=null,Qs[1]=Bp,Qs[2]=lA,Qs[3]=c2,Le.ca=ot,Le.tb=Tt,Le.c=J.width,Le.i=J.height,t(0<Le.c&&0<Le.i),1>=je)J=0;else if(Le.$a=Be[Pe+0]>>0&3,Le.Z=Be[Pe+0]>>2&3,Le.Lc=Be[Pe+0]>>4&3,Pe=Be[Pe+0]>>6&3,0>Le.$a||1<Le.$a||4<=Le.Z||1<Le.Lc||Pe)J=0;else if(sn.put=bt,sn.ac=gt,sn.bc=wt,sn.ma=Le,sn.width=J.width,sn.height=J.height,sn.Da=J.Da,sn.v=J.v,sn.va=J.va,sn.j=J.j,sn.o=J.o,Le.$a)e:{t(Le.$a==1),J=$n();t:for(;;){if(J==null){J=0;break e}if(t(Le!=null),Le.mc=J,J.c=Le.c,J.i=Le.i,J.l=Le.l,J.l.ma=Le,J.l.width=Le.c,J.l.height=Le.i,J.a=0,P(J.m,Be,It,yt),!Kn(Le.c,Le.i,1,J,null)||(J.ab==1&&J.gc[0].hc==3&&$t(J.s)?(Le.ic=1,Be=J.c*J.i,J.Ta=null,J.Ua=0,J.V=i(Be),J.Ba=0,J.V==null?(J.a=1,J=0):J=1):(Le.ic=0,J=Cr(J,Le.c)),!J))break t;J=1;break e}Le.mc=null,J=0}else J=yt>=Le.c*Le.i;Le=!J}if(Le)return null;V.ga.Lc!=1?V.Ga=0:ye=Me-ce}t(V.ga!=null),t(ce+ye<=Me);e:{if(J=(Be=V.ga).c,Me=Be.l.o,Be.$a==0){if(It=V.rc,yt=V.Vc,sn=V.Fa,Pe=V.P+1+ce*J,je=V.mb,ot=V.nb+ce*J,t(Pe<=V.P+V.qc),Be.Z!=0)for(t(Qs[Be.Z]!=null),Le=0;Le<ye;++Le)Qs[Be.Z](It,yt,sn,Pe,je,ot,J),It=je,yt=ot,ot+=J,Pe+=J;else for(Le=0;Le<ye;++Le)r(je,ot,sn,Pe,J),It=je,yt=ot,ot+=J,Pe+=J;V.rc=It,V.Vc=yt}else{if(t(Be.mc!=null),J=ce+ye,t((Le=Be.mc)!=null),t(J<=Le.i),Le.C>=J)J=1;else if(Be.ic||Et(),Be.ic){Be=Le.V,It=Le.Ba,yt=Le.c;var Vt=Le.i,ut=(sn=1,Pe=Le.$/yt,je=Le.$%yt,ot=Le.m,Tt=Le.s,Le.$),dt=yt*Vt,en=yt*J,Jt=Tt.wc,nn=ut<en?Bt(Tt,je,Pe):null;t(ut<=dt),t(J<=Vt),t($t(Tt));t:for(;;){for(;!ot.h&&ut<en;){if(je&Jt||(nn=Bt(Tt,je,Pe)),t(nn!=null),Q(ot),256>(Vt=Wt(nn.G[0],nn.H[0],ot)))Be[It+ut]=Vt,++ut,++je>=yt&&(je=0,++Pe<=J&&!(Pe%16)&&qt(Le,Pe));else{if(!(280>Vt)){sn=0;break t}Vt=Lt(Vt-256,ot);var tr,Fn=Wt(nn.G[4],nn.H[4],ot);if(Q(ot),!(ut>=(Fn=Mt(yt,Fn=Lt(Fn,ot)))&&dt-ut>=Vt)){sn=0;break t}for(tr=0;tr<Vt;++tr)Be[It+ut+tr]=Be[It+ut+tr-Fn];for(ut+=Vt,je+=Vt;je>=yt;)je-=yt,++Pe<=J&&!(Pe%16)&&qt(Le,Pe);ut<en&&je&Jt&&(nn=Bt(Tt,je,Pe))}t(ot.h==W(ot))}qt(Le,Pe>J?J:Pe);break t}!sn||ot.h&&ut<dt?(sn=0,Le.a=ot.h?5:3):Le.$=ut,J=sn}else J=on(Le,Le.V,Le.Ba,Le.c,Le.i,J,dn);if(!J){ye=0;break e}}ce+ye>=Me&&(V.Cc=1),ye=1}if(!ye)return null;if(V.Cc&&((ye=V.ga)!=null&&(ye.mc=null),V.ga=null,0<V.Ga))return alert("todo:WebPDequantizeLevels"),null}return V.nb+ce*we}function re(V,J,ce,ye,we,Me){for(;0<we--;){var Le,Be=V,Pe=J+(ce?1:0),je=V,ot=J+(ce?0:3);for(Le=0;Le<ye;++Le){var Tt=je[ot+4*Le];Tt!=255&&(Tt*=32897,Be[Pe+4*Le+0]=Be[Pe+4*Le+0]*Tt>>23,Be[Pe+4*Le+1]=Be[Pe+4*Le+1]*Tt>>23,Be[Pe+4*Le+2]=Be[Pe+4*Le+2]*Tt>>23)}J+=Me}}function Te(V,J,ce,ye,we){for(;0<ye--;){var Me;for(Me=0;Me<ce;++Me){var Le=V[J+2*Me+0],Be=15&(je=V[J+2*Me+1]),Pe=4369*Be,je=(240&je|je>>4)*Pe>>16;V[J+2*Me+0]=(240&Le|Le>>4)*Pe>>16&240|(15&Le|Le<<4)*Pe>>16>>4&15,V[J+2*Me+1]=240&je|Be}J+=we}}function Ye(V,J,ce,ye,we,Me,Le,Be){var Pe,je,ot=255;for(je=0;je<we;++je){for(Pe=0;Pe<ye;++Pe){var Tt=V[J+Pe];Me[Le+4*Pe]=Tt,ot&=Tt}J+=ce,Le+=Be}return ot!=255}function it(V,J,ce,ye,we){var Me;for(Me=0;Me<we;++Me)ce[ye+Me]=V[J+Me]>>8}function Et(){Uc=re,ho=Te,Wi=Ye,tl=it}function Zt(V,J,ce){w[V]=function(ye,we,Me,Le,Be,Pe,je,ot,Tt,It,yt,sn,Vt,ut,dt,en,Jt){var nn,tr=Jt-1>>1,Fn=Be[Pe+0]|je[ot+0]<<16,jr=Tt[It+0]|yt[sn+0]<<16;t(ye!=null);var Hn=3*Fn+jr+131074>>2;for(J(ye[we+0],255&Hn,Hn>>16,Vt,ut),Me!=null&&(Hn=3*jr+Fn+131074>>2,J(Me[Le+0],255&Hn,Hn>>16,dt,en)),nn=1;nn<=tr;++nn){var Ti=Be[Pe+nn]|je[ot+nn]<<16,Ii=Tt[It+nn]|yt[sn+nn]<<16,fi=Fn+Ti+jr+Ii+524296,za=fi+2*(Ti+jr)>>3;Hn=za+Fn>>1,Fn=(fi=fi+2*(Fn+Ii)>>3)+Ti>>1,J(ye[we+2*nn-1],255&Hn,Hn>>16,Vt,ut+(2*nn-1)*ce),J(ye[we+2*nn-0],255&Fn,Fn>>16,Vt,ut+(2*nn-0)*ce),Me!=null&&(Hn=fi+jr>>1,Fn=za+Ii>>1,J(Me[Le+2*nn-1],255&Hn,Hn>>16,dt,en+(2*nn-1)*ce),J(Me[Le+2*nn+0],255&Fn,Fn>>16,dt,en+(2*nn+0)*ce)),Fn=Ti,jr=Ii}1&Jt||(Hn=3*Fn+jr+131074>>2,J(ye[we+Jt-1],255&Hn,Hn>>16,Vt,ut+(Jt-1)*ce),Me!=null&&(Hn=3*jr+Fn+131074>>2,J(Me[Le+Jt-1],255&Hn,Hn>>16,dt,en+(Jt-1)*ce)))}}function gn(){Hc[V5]=pF,Hc[h2]=g2,Hc[PC]=hF,Hc[pA]=z1,Hc[hA]=e0,Hc[go]=yA,Hc[W5]=L_,Hc[$1]=g2,Hc[Xg]=z1,Hc[gA]=e0,Hc[mA]=yA}function Zn(V){return V&-16384?0>V?0:255:V>>m2}function $r(V,J){return Zn((19077*V>>8)+(26149*J>>8)-14234)}function Ia(V,J,ce){return Zn((19077*V>>8)-(6419*J>>8)-(13320*ce>>8)+8708)}function Ea(V,J){return Zn((19077*V>>8)+(33050*J>>8)-17685)}function ui(V,J,ce,ye,we){ye[we+0]=$r(V,ce),ye[we+1]=Ia(V,J,ce),ye[we+2]=Ea(V,J)}function zo(V,J,ce,ye,we){ye[we+0]=Ea(V,J),ye[we+1]=Ia(V,J,ce),ye[we+2]=$r(V,ce)}function Jo(V,J,ce,ye,we){var Me=Ia(V,J,ce);J=Me<<3&224|Ea(V,J)>>3,ye[we+0]=248&$r(V,ce)|Me>>5,ye[we+1]=J}function Sl(V,J,ce,ye,we){var Me=240&Ea(V,J)|15;ye[we+0]=240&$r(V,ce)|Ia(V,J,ce)>>4,ye[we+1]=Me}function Vs(V,J,ce,ye,we){ye[we+0]=255,ui(V,J,ce,ye,we+1)}function rs(V,J,ce,ye,we){zo(V,J,ce,ye,we),ye[we+3]=255}function Xd(V,J,ce,ye,we){ui(V,J,ce,ye,we),ye[we+3]=255}function wu(V,J){return 0>V?0:V>J?J:V}function ud(V,J,ce){w[V]=function(ye,we,Me,Le,Be,Pe,je,ot,Tt){for(var It=ot+(-2&Tt)*ce;ot!=It;)J(ye[we+0],Me[Le+0],Be[Pe+0],je,ot),J(ye[we+1],Me[Le+0],Be[Pe+0],je,ot+ce),we+=2,++Le,++Pe,ot+=2*ce;1&Tt&&J(ye[we+0],Me[Le+0],Be[Pe+0],je,ot)}}function u2(V,J,ce){return ce==0?V==0?J==0?6:5:J==0?4:0:ce}function cA(V,J,ce,ye,we){switch(V>>>30){case 3:Up(J,ce,ye,we,0);break;case 2:Li(J,ce,ye,we);break;case 1:qs(J,ce,ye,we)}}function C1(V,J){var ce,ye,we=J.M,Me=J.Nb,Le=V.oc,Be=V.pc+40,Pe=V.oc,je=V.pc+584,ot=V.oc,Tt=V.pc+600;for(ce=0;16>ce;++ce)Le[Be+32*ce-1]=129;for(ce=0;8>ce;++ce)Pe[je+32*ce-1]=129,ot[Tt+32*ce-1]=129;for(0<we?Le[Be-1-32]=Pe[je-1-32]=ot[Tt-1-32]=129:(a(Le,Be-32-1,127,21),a(Pe,je-32-1,127,9),a(ot,Tt-32-1,127,9)),ye=0;ye<V.za;++ye){var It=J.ya[J.aa+ye];if(0<ye){for(ce=-1;16>ce;++ce)r(Le,Be+32*ce-4,Le,Be+32*ce+12,4);for(ce=-1;8>ce;++ce)r(Pe,je+32*ce-4,Pe,je+32*ce+4,4),r(ot,Tt+32*ce-4,ot,Tt+32*ce+4,4)}var yt=V.Gd,sn=V.Hd+ye,Vt=It.ad,ut=It.Hc;if(0<we&&(r(Le,Be-32,yt[sn].y,0,16),r(Pe,je-32,yt[sn].f,0,8),r(ot,Tt-32,yt[sn].ea,0,8)),It.Za){var dt=Le,en=Be-32+16;for(0<we&&(ye>=V.za-1?a(dt,en,yt[sn].y[15],4):r(dt,en,yt[sn+1].y,0,4)),ce=0;4>ce;ce++)dt[en+128+ce]=dt[en+256+ce]=dt[en+384+ce]=dt[en+0+ce];for(ce=0;16>ce;++ce,ut<<=2)dt=Le,en=Be+D_[ce],fd[It.Ob[ce]](dt,en),cA(ut,Vt,16*+ce,dt,en)}else if(dt=u2(ye,we,It.Ob[0]),Ac[dt](Le,Be),ut!=0)for(ce=0;16>ce;++ce,ut<<=2)cA(ut,Vt,16*+ce,Le,Be+D_[ce]);for(ce=It.Gc,dt=u2(ye,we,It.Dd),zc[dt](Pe,je),zc[dt](ot,Tt),ut=Vt,dt=Pe,en=je,255&(It=ce>>0)&&(170&It?zp(ut,256,dt,en):Cu(ut,256,dt,en)),It=ot,ut=Tt,255&(ce>>=8)&&(170&ce?zp(Vt,320,It,ut):Cu(Vt,320,It,ut)),we<V.Ub-1&&(r(yt[sn].y,0,Le,Be+480,16),r(yt[sn].f,0,Pe,je+224,8),r(yt[sn].ea,0,ot,Tt+224,8)),ce=8*Me*V.B,yt=V.sa,sn=V.ta+16*ye+16*Me*V.R,Vt=V.qa,It=V.ra+8*ye+ce,ut=V.Ha,dt=V.Ia+8*ye+ce,ce=0;16>ce;++ce)r(yt,sn+ce*V.R,Le,Be+32*ce,16);for(ce=0;8>ce;++ce)r(Vt,It+ce*V.B,Pe,je+32*ce,8),r(ut,dt+ce*V.B,ot,Tt+32*ce,8)}}function jg(V,J,ce,ye,we,Me,Le,Be,Pe){var je=[0],ot=[0],Tt=0,It=Pe!=null?Pe.kd:0,yt=Pe??new s2;if(V==null||12>ce)return 7;yt.data=V,yt.w=J,yt.ha=ce,J=[J],ce=[ce],yt.gb=[yt.gb];e:{var sn=J,Vt=ce,ut=yt.gb;if(t(V!=null),t(Vt!=null),t(ut!=null),ut[0]=0,12<=Vt[0]&&!n(V,sn[0],"RIFF")){if(n(V,sn[0]+8,"WEBP")){ut=3;break e}var dt=se(V,sn[0]+4);if(12>dt||4294967286<dt){ut=3;break e}if(It&&dt>Vt[0]-8){ut=7;break e}ut[0]=dt,sn[0]+=12,Vt[0]-=12}ut=0}if(ut!=0)return ut;for(dt=0<yt.gb[0],ce=ce[0];;){e:{var en=V;Vt=J,ut=ce;var Jt=je,nn=ot,tr=sn=[0];if((Hn=Tt=[Tt])[0]=0,8>ut[0])ut=7;else{if(!n(en,Vt[0],"VP8X")){if(se(en,Vt[0]+4)!=10){ut=3;break e}if(18>ut[0]){ut=7;break e}var Fn=se(en,Vt[0]+8),jr=1+te(en,Vt[0]+12);if(2147483648<=jr*(en=1+te(en,Vt[0]+15))){ut=3;break e}tr!=null&&(tr[0]=Fn),Jt!=null&&(Jt[0]=jr),nn!=null&&(nn[0]=en),Vt[0]+=18,ut[0]-=18,Hn[0]=1}ut=0}}if(Tt=Tt[0],sn=sn[0],ut!=0)return ut;if(Vt=!!(2&sn),!dt&&Tt)return 3;if(Me!=null&&(Me[0]=!!(16&sn)),Le!=null&&(Le[0]=Vt),Be!=null&&(Be[0]=0),Le=je[0],sn=ot[0],Tt&&Vt&&Pe==null){ut=0;break}if(4>ce){ut=7;break}if(dt&&Tt||!dt&&!Tt&&!n(V,J[0],"ALPH")){ce=[ce],yt.na=[yt.na],yt.P=[yt.P],yt.Sa=[yt.Sa];e:{Fn=V,ut=J,dt=ce;var Hn=yt.gb;Jt=yt.na,nn=yt.P,tr=yt.Sa,jr=22,t(Fn!=null),t(dt!=null),en=ut[0];var Ti=dt[0];for(t(Jt!=null),t(tr!=null),Jt[0]=null,nn[0]=null,tr[0]=0;;){if(ut[0]=en,dt[0]=Ti,8>Ti){ut=7;break e}var Ii=se(Fn,en+4);if(4294967286<Ii){ut=3;break e}var fi=8+Ii+1&-2;if(jr+=fi,0<Hn&&jr>Hn){ut=3;break e}if(!n(Fn,en,"VP8 ")||!n(Fn,en,"VP8L")){ut=0;break e}if(Ti[0]<fi){ut=7;break e}n(Fn,en,"ALPH")||(Jt[0]=Fn,nn[0]=en+8,tr[0]=Ii),en+=fi,Ti-=fi}}if(ce=ce[0],yt.na=yt.na[0],yt.P=yt.P[0],yt.Sa=yt.Sa[0],ut!=0)break}ce=[ce],yt.Ja=[yt.Ja],yt.xa=[yt.xa];e:if(Hn=V,ut=J,dt=ce,Jt=yt.gb[0],nn=yt.Ja,tr=yt.xa,Fn=ut[0],en=!n(Hn,Fn,"VP8 "),jr=!n(Hn,Fn,"VP8L"),t(Hn!=null),t(dt!=null),t(nn!=null),t(tr!=null),8>dt[0])ut=7;else{if(en||jr){if(Hn=se(Hn,Fn+4),12<=Jt&&Hn>Jt-12){ut=3;break e}if(It&&Hn>dt[0]-8){ut=7;break e}nn[0]=Hn,ut[0]+=8,dt[0]-=8,tr[0]=jr}else tr[0]=5<=dt[0]&&Hn[Fn+0]==47&&!(Hn[Fn+4]>>5),nn[0]=dt[0];ut=0}if(ce=ce[0],yt.Ja=yt.Ja[0],yt.xa=yt.xa[0],J=J[0],ut!=0)break;if(4294967286<yt.Ja)return 3;if(Be==null||Vt||(Be[0]=yt.xa?2:1),Le=[Le],sn=[sn],yt.xa){if(5>ce){ut=7;break}Be=Le,It=sn,Vt=Me,V==null||5>ce?V=0:5<=ce&&V[J+0]==47&&!(V[J+4]>>5)?(dt=[0],Hn=[0],Jt=[0],P(nn=new F,V,J,ce),xt(nn,dt,Hn,Jt)?(Be!=null&&(Be[0]=dt[0]),It!=null&&(It[0]=Hn[0]),Vt!=null&&(Vt[0]=Jt[0]),V=1):V=0):V=0}else{if(10>ce){ut=7;break}Be=sn,V==null||10>ce||!Ga(V,J+3,ce-3)?V=0:(It=V[J+0]|V[J+1]<<8|V[J+2]<<16,Vt=16383&(V[J+7]<<8|V[J+6]),V=16383&(V[J+9]<<8|V[J+8]),1&It||3<(It>>1&7)||!(It>>4&1)||It>>5>=yt.Ja||!Vt||!V?V=0:(Le&&(Le[0]=Vt),Be&&(Be[0]=V),V=1))}if(!V||(Le=Le[0],sn=sn[0],Tt&&(je[0]!=Le||ot[0]!=sn)))return 3;Pe!=null&&(Pe[0]=yt,Pe.offset=J-Pe.w,t(4294967286>J-Pe.w),t(Pe.offset==Pe.ha-ce));break}return ut==0||ut==7&&Tt&&Pe==null?(Me!=null&&(Me[0]|=yt.na!=null&&0<yt.na.length),ye!=null&&(ye[0]=Le),we!=null&&(we[0]=sn),0):ut}function T1(V,J,ce){var ye=J.width,we=J.height,Me=0,Le=0,Be=ye,Pe=we;if(J.Da=V!=null&&0<V.Da,J.Da&&(Be=V.cd,Pe=V.bd,Me=V.v,Le=V.j,11>ce||(Me&=-2,Le&=-2),0>Me||0>Le||0>=Be||0>=Pe||Me+Be>ye||Le+Pe>we))return 0;if(J.v=Me,J.j=Le,J.va=Me+Be,J.o=Le+Pe,J.U=Be,J.T=Pe,J.da=V!=null&&0<V.da,J.da){if(!be(Be,Pe,ce=[V.ib],Me=[V.hb]))return 0;J.ib=ce[0],J.hb=Me[0]}return J.ob=V!=null&&V.ob,J.Kb=V==null||!V.Sd,J.da&&(J.ob=J.ib<3*ye/4&&J.hb<3*we/4,J.Kb=0),1}function I1(V){if(V==null)return 2;if(11>V.S){var J=V.f.RGBA;J.fb+=(V.height-1)*J.A,J.A=-J.A}else J=V.f.kb,V=V.height,J.O+=(V-1)*J.fa,J.fa=-J.fa,J.N+=(V-1>>1)*J.Ab,J.Ab=-J.Ab,J.W+=(V-1>>1)*J.Db,J.Db=-J.Db,J.F!=null&&(J.J+=(V-1)*J.lb,J.lb=-J.lb);return 0}function Gg(V,J,ce,ye){if(ye==null||0>=V||0>=J)return 2;if(ce!=null){if(ce.Da){var we=ce.cd,Me=ce.bd,Le=-2&ce.v,Be=-2&ce.j;if(0>Le||0>Be||0>=we||0>=Me||Le+we>V||Be+Me>J)return 2;V=we,J=Me}if(ce.da){if(!be(V,J,we=[ce.ib],Me=[ce.hb]))return 2;V=we[0],J=Me[0]}}ye.width=V,ye.height=J;e:{var Pe=ye.width,je=ye.height;if(V=ye.S,0>=Pe||0>=je||!(V>=V5&&13>V))V=2;else{if(0>=ye.Rd&&ye.sd==null){Le=Me=we=J=0;var ot=(Be=Pe*bA[V])*je;if(11>V||(Me=(je+1)/2*(J=(Pe+1)/2),V==12&&(Le=(we=Pe)*je)),(je=i(ot+2*Me+Le))==null){V=1;break e}ye.sd=je,11>V?((Pe=ye.f.RGBA).eb=je,Pe.fb=0,Pe.A=Be,Pe.size=ot):((Pe=ye.f.kb).y=je,Pe.O=0,Pe.fa=Be,Pe.Fd=ot,Pe.f=je,Pe.N=0+ot,Pe.Ab=J,Pe.Cd=Me,Pe.ea=je,Pe.W=0+ot+Me,Pe.Db=J,Pe.Ed=Me,V==12&&(Pe.F=je,Pe.J=0+ot+2*Me),Pe.Tc=Le,Pe.lb=we)}if(J=1,we=ye.S,Me=ye.width,Le=ye.height,we>=V5&&13>we)if(11>we)V=ye.f.RGBA,J&=(Be=Math.abs(V.A))*(Le-1)+Me<=V.size,J&=Be>=Me*bA[we],J&=V.eb!=null;else{V=ye.f.kb,Be=(Me+1)/2,ot=(Le+1)/2,Pe=Math.abs(V.fa),je=Math.abs(V.Ab);var Tt=Math.abs(V.Db),It=Math.abs(V.lb),yt=It*(Le-1)+Me;J&=Pe*(Le-1)+Me<=V.Fd,J&=je*(ot-1)+Be<=V.Cd,J=(J&=Tt*(ot-1)+Be<=V.Ed)&Pe>=Me&je>=Be&Tt>=Be,J&=V.y!=null,J&=V.f!=null,J&=V.ea!=null,we==12&&(J&=It>=Me,J&=yt<=V.Tc,J&=V.F!=null)}else J=0;V=J?0:2}}return V!=0||ce!=null&&ce.fd&&(V=I1(ye)),V}var el=64,R1=[0,1,3,7,15,31,63,127,255,511,1023,2047,4095,8191,16383,32767,65535,131071,262143,524287,1048575,2097151,4194303,8388607,16777215],N1=24,O1=32,M1=8,pc=[0,0,1,1,2,2,2,2,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7];he("Predictor0","PredictorAdd0"),w.Predictor0=function(){return 4278190080},w.Predictor1=function(V){return V},w.Predictor2=function(V,J,ce){return J[ce+0]},w.Predictor3=function(V,J,ce){return J[ce+1]},w.Predictor4=function(V,J,ce){return J[ce-1]},w.Predictor5=function(V,J,ce){return me(me(V,J[ce+1]),J[ce+0])},w.Predictor6=function(V,J,ce){return me(V,J[ce-1])},w.Predictor7=function(V,J,ce){return me(V,J[ce+0])},w.Predictor8=function(V,J,ce){return me(J[ce-1],J[ce+0])},w.Predictor9=function(V,J,ce){return me(J[ce+0],J[ce+1])},w.Predictor10=function(V,J,ce){return me(me(V,J[ce-1]),me(J[ce+0],J[ce+1]))},w.Predictor11=function(V,J,ce){var ye=J[ce+0];return 0>=$e(ye>>24&255,V>>24&255,(J=J[ce-1])>>24&255)+$e(ye>>16&255,V>>16&255,J>>16&255)+$e(ye>>8&255,V>>8&255,J>>8&255)+$e(255&ye,255&V,255&J)?ye:V},w.Predictor12=function(V,J,ce){var ye=J[ce+0];return(Se((V>>24&255)+(ye>>24&255)-((J=J[ce-1])>>24&255))<<24|Se((V>>16&255)+(ye>>16&255)-(J>>16&255))<<16|Se((V>>8&255)+(ye>>8&255)-(J>>8&255))<<8|Se((255&V)+(255&ye)-(255&J)))>>>0},w.Predictor13=function(V,J,ce){var ye=J[ce-1];return(xe((V=me(V,J[ce+0]))>>24&255,ye>>24&255)<<24|xe(V>>16&255,ye>>16&255)<<16|xe(V>>8&255,ye>>8&255)<<8|xe(V>>0&255,ye>>0&255))>>>0};var Vg=w.PredictorAdd0;w.PredictorAdd1=Fe,he("Predictor2","PredictorAdd2"),he("Predictor3","PredictorAdd3"),he("Predictor4","PredictorAdd4"),he("Predictor5","PredictorAdd5"),he("Predictor6","PredictorAdd6"),he("Predictor7","PredictorAdd7"),he("Predictor8","PredictorAdd8"),he("Predictor9","PredictorAdd9"),he("Predictor10","PredictorAdd10"),he("Predictor11","PredictorAdd11"),he("Predictor12","PredictorAdd12"),he("Predictor13","PredictorAdd13");var Pp=w.PredictorAdd2;ct("ColorIndexInverseTransform","MapARGB","32b",(function(V){return V>>8&255}),(function(V){return V})),ct("VP8LColorIndexInverseTransformAlpha","MapAlpha","8b",(function(V){return V}),(function(V){return V>>8&255}));var G5,hc=w.ColorIndexInverseTransform,k1=w.MapARGB,uA=w.VP8LColorIndexInverseTransformAlpha,L1=w.MapAlpha,Bf=w.VP8LPredictorsAdd=[];Bf.length=16,(w.VP8LPredictors=[]).length=16,(w.VP8LPredictorsAdd_C=[]).length=16,(w.VP8LPredictors_C=[]).length=16;var d2,gc,Ws,f2,$p,Fp,D1,Up,Li,zp,qs,Cu,Wg,dA,qg,Qg,Yg,Tu,Hp,Pf,jp,Gp,p2,_s,Uc,ho,Wi,tl,xl=i(511),$f=i(2041),B1=i(225),Kg=i(767),fA=0,Ff=$f,P1=B1,mc=Kg,dd=xl,V5=0,h2=1,PC=2,pA=3,hA=4,go=5,W5=6,$1=7,Xg=8,gA=9,mA=10,AA=[2,3,7],q5=[3,3,11],Zg=[280,256,256,256,40],$C=[0,1,1,1,0],cF=[17,18,0,1,2,3,4,5,16,6,7,8,9,10,11,12,13,14,15],uF=[24,7,23,25,40,6,39,41,22,26,38,42,56,5,55,57,21,27,54,58,37,43,72,4,71,73,20,28,53,59,70,74,36,44,88,69,75,52,60,3,87,89,19,29,86,90,35,45,68,76,85,91,51,61,104,2,103,105,18,30,102,106,34,46,84,92,67,77,101,107,50,62,120,1,119,121,83,93,17,31,100,108,66,78,118,122,33,47,117,123,49,63,99,109,82,94,0,116,124,65,79,16,32,98,110,48,115,125,81,95,64,114,126,97,111,80,113,127,96,112],FC=[2954,2956,2958,2962,2970,2986,3018,3082,3212,3468,3980,5004],Q5=8,F1=[4,5,6,7,8,9,10,10,11,12,13,14,15,16,17,17,18,19,20,20,21,21,22,22,23,23,24,25,25,26,27,28,29,30,31,32,33,34,35,36,37,37,38,39,40,41,42,43,44,45,46,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,76,77,78,79,80,81,82,83,84,85,86,87,88,89,91,93,95,96,98,100,101,102,104,106,108,110,112,114,116,118,122,124,126,128,130,132,134,136,138,140,143,145,148,151,154,157],vA=[4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,60,62,64,66,68,70,72,74,76,78,80,82,84,86,88,90,92,94,96,98,100,102,104,106,108,110,112,114,116,119,122,125,128,131,134,137,140,143,146,149,152,155,158,161,164,167,170,173,177,181,185,189,193,197,201,205,209,213,217,221,225,229,234,239,245,249,254,259,264,269,274,279,284],Jg=null,O_=[[173,148,140,0],[176,155,140,135,0],[180,157,141,134,130,0],[254,254,243,230,196,177,153,140,133,130,129,0]],M_=[0,1,4,8,5,2,3,6,9,12,13,10,7,11,14,15],UC=[-0,1,-1,2,-2,3,4,6,-3,5,-4,-5,-6,7,-7,8,-8,-9],zC=[[[[128,128,128,128,128,128,128,128,128,128,128],[128,128,128,128,128,128,128,128,128,128,128],[128,128,128,128,128,128,128,128,128,128,128]],[[253,136,254,255,228,219,128,128,128,128,128],[189,129,242,255,227,213,255,219,128,128,128],[106,126,227,252,214,209,255,255,128,128,128]],[[1,98,248,255,236,226,255,255,128,128,128],[181,133,238,254,221,234,255,154,128,128,128],[78,134,202,247,198,180,255,219,128,128,128]],[[1,185,249,255,243,255,128,128,128,128,128],[184,150,247,255,236,224,128,128,128,128,128],[77,110,216,255,236,230,128,128,128,128,128]],[[1,101,251,255,241,255,128,128,128,128,128],[170,139,241,252,236,209,255,255,128,128,128],[37,116,196,243,228,255,255,255,128,128,128]],[[1,204,254,255,245,255,128,128,128,128,128],[207,160,250,255,238,128,128,128,128,128,128],[102,103,231,255,211,171,128,128,128,128,128]],[[1,152,252,255,240,255,128,128,128,128,128],[177,135,243,255,234,225,128,128,128,128,128],[80,129,211,255,194,224,128,128,128,128,128]],[[1,1,255,128,128,128,128,128,128,128,128],[246,1,255,128,128,128,128,128,128,128,128],[255,128,128,128,128,128,128,128,128,128,128]]],[[[198,35,237,223,193,187,162,160,145,155,62],[131,45,198,221,172,176,220,157,252,221,1],[68,47,146,208,149,167,221,162,255,223,128]],[[1,149,241,255,221,224,255,255,128,128,128],[184,141,234,253,222,220,255,199,128,128,128],[81,99,181,242,176,190,249,202,255,255,128]],[[1,129,232,253,214,197,242,196,255,255,128],[99,121,210,250,201,198,255,202,128,128,128],[23,91,163,242,170,187,247,210,255,255,128]],[[1,200,246,255,234,255,128,128,128,128,128],[109,178,241,255,231,245,255,255,128,128,128],[44,130,201,253,205,192,255,255,128,128,128]],[[1,132,239,251,219,209,255,165,128,128,128],[94,136,225,251,218,190,255,255,128,128,128],[22,100,174,245,186,161,255,199,128,128,128]],[[1,182,249,255,232,235,128,128,128,128,128],[124,143,241,255,227,234,128,128,128,128,128],[35,77,181,251,193,211,255,205,128,128,128]],[[1,157,247,255,236,231,255,255,128,128,128],[121,141,235,255,225,227,255,255,128,128,128],[45,99,188,251,195,217,255,224,128,128,128]],[[1,1,251,255,213,255,128,128,128,128,128],[203,1,248,255,255,128,128,128,128,128,128],[137,1,177,255,224,255,128,128,128,128,128]]],[[[253,9,248,251,207,208,255,192,128,128,128],[175,13,224,243,193,185,249,198,255,255,128],[73,17,171,221,161,179,236,167,255,234,128]],[[1,95,247,253,212,183,255,255,128,128,128],[239,90,244,250,211,209,255,255,128,128,128],[155,77,195,248,188,195,255,255,128,128,128]],[[1,24,239,251,218,219,255,205,128,128,128],[201,51,219,255,196,186,128,128,128,128,128],[69,46,190,239,201,218,255,228,128,128,128]],[[1,191,251,255,255,128,128,128,128,128,128],[223,165,249,255,213,255,128,128,128,128,128],[141,124,248,255,255,128,128,128,128,128,128]],[[1,16,248,255,255,128,128,128,128,128,128],[190,36,230,255,236,255,128,128,128,128,128],[149,1,255,128,128,128,128,128,128,128,128]],[[1,226,255,128,128,128,128,128,128,128,128],[247,192,255,128,128,128,128,128,128,128,128],[240,128,255,128,128,128,128,128,128,128,128]],[[1,134,252,255,255,128,128,128,128,128,128],[213,62,250,255,255,128,128,128,128,128,128],[55,93,255,128,128,128,128,128,128,128,128]],[[128,128,128,128,128,128,128,128,128,128,128],[128,128,128,128,128,128,128,128,128,128,128],[128,128,128,128,128,128,128,128,128,128,128]]],[[[202,24,213,235,186,191,220,160,240,175,255],[126,38,182,232,169,184,228,174,255,187,128],[61,46,138,219,151,178,240,170,255,216,128]],[[1,112,230,250,199,191,247,159,255,255,128],[166,109,228,252,211,215,255,174,128,128,128],[39,77,162,232,172,180,245,178,255,255,128]],[[1,52,220,246,198,199,249,220,255,255,128],[124,74,191,243,183,193,250,221,255,255,128],[24,71,130,219,154,170,243,182,255,255,128]],[[1,182,225,249,219,240,255,224,128,128,128],[149,150,226,252,216,205,255,171,128,128,128],[28,108,170,242,183,194,254,223,255,255,128]],[[1,81,230,252,204,203,255,192,128,128,128],[123,102,209,247,188,196,255,233,128,128,128],[20,95,153,243,164,173,255,203,128,128,128]],[[1,222,248,255,216,213,128,128,128,128,128],[168,175,246,252,235,205,255,255,128,128,128],[47,116,215,255,211,212,255,255,128,128,128]],[[1,121,236,253,212,214,255,255,128,128,128],[141,84,213,252,201,202,255,219,128,128,128],[42,80,160,240,162,185,255,205,128,128,128]],[[1,1,255,128,128,128,128,128,128,128,128],[244,1,255,128,128,128,128,128,128,128,128],[238,1,255,128,128,128,128,128,128,128,128]]]],dF=[[[231,120,48,89,115,113,120,152,112],[152,179,64,126,170,118,46,70,95],[175,69,143,80,85,82,72,155,103],[56,58,10,171,218,189,17,13,152],[114,26,17,163,44,195,21,10,173],[121,24,80,195,26,62,44,64,85],[144,71,10,38,171,213,144,34,26],[170,46,55,19,136,160,33,206,71],[63,20,8,114,114,208,12,9,226],[81,40,11,96,182,84,29,16,36]],[[134,183,89,137,98,101,106,165,148],[72,187,100,130,157,111,32,75,80],[66,102,167,99,74,62,40,234,128],[41,53,9,178,241,141,26,8,107],[74,43,26,146,73,166,49,23,157],[65,38,105,160,51,52,31,115,128],[104,79,12,27,217,255,87,17,7],[87,68,71,44,114,51,15,186,23],[47,41,14,110,182,183,21,17,194],[66,45,25,102,197,189,23,18,22]],[[88,88,147,150,42,46,45,196,205],[43,97,183,117,85,38,35,179,61],[39,53,200,87,26,21,43,232,171],[56,34,51,104,114,102,29,93,77],[39,28,85,171,58,165,90,98,64],[34,22,116,206,23,34,43,166,73],[107,54,32,26,51,1,81,43,31],[68,25,106,22,64,171,36,225,114],[34,19,21,102,132,188,16,76,124],[62,18,78,95,85,57,50,48,51]],[[193,101,35,159,215,111,89,46,111],[60,148,31,172,219,228,21,18,111],[112,113,77,85,179,255,38,120,114],[40,42,1,196,245,209,10,25,109],[88,43,29,140,166,213,37,43,154],[61,63,30,155,67,45,68,1,209],[100,80,8,43,154,1,51,26,71],[142,78,78,16,255,128,34,197,171],[41,40,5,102,211,183,4,1,221],[51,50,17,168,209,192,23,25,82]],[[138,31,36,171,27,166,38,44,229],[67,87,58,169,82,115,26,59,179],[63,59,90,180,59,166,93,73,154],[40,40,21,116,143,209,34,39,175],[47,15,16,183,34,223,49,45,183],[46,17,33,183,6,98,15,32,183],[57,46,22,24,128,1,54,17,37],[65,32,73,115,28,128,23,128,205],[40,3,9,115,51,192,18,6,223],[87,37,9,115,59,77,64,21,47]],[[104,55,44,218,9,54,53,130,226],[64,90,70,205,40,41,23,26,57],[54,57,112,184,5,41,38,166,213],[30,34,26,133,152,116,10,32,134],[39,19,53,221,26,114,32,73,255],[31,9,65,234,2,15,1,118,73],[75,32,12,51,192,255,160,43,51],[88,31,35,67,102,85,55,186,85],[56,21,23,111,59,205,45,37,192],[55,38,70,124,73,102,1,34,98]],[[125,98,42,88,104,85,117,175,82],[95,84,53,89,128,100,113,101,45],[75,79,123,47,51,128,81,171,1],[57,17,5,71,102,57,53,41,49],[38,33,13,121,57,73,26,1,85],[41,10,67,138,77,110,90,47,114],[115,21,2,10,102,255,166,23,6],[101,29,16,10,85,128,101,196,26],[57,18,10,102,102,213,34,20,43],[117,20,15,36,163,128,68,1,26]],[[102,61,71,37,34,53,31,243,192],[69,60,71,38,73,119,28,222,37],[68,45,128,34,1,47,11,245,171],[62,17,19,70,146,85,55,62,70],[37,43,37,154,100,163,85,160,1],[63,9,92,136,28,64,32,201,85],[75,15,9,9,64,255,184,119,16],[86,6,28,5,64,255,25,248,1],[56,8,17,132,137,255,55,116,128],[58,15,20,82,135,57,26,121,40]],[[164,50,31,137,154,133,25,35,218],[51,103,44,131,131,123,31,6,158],[86,40,64,135,148,224,45,183,128],[22,26,17,131,240,154,14,1,209],[45,16,21,91,64,222,7,1,197],[56,21,39,155,60,138,23,102,213],[83,12,13,54,192,255,68,47,28],[85,26,85,85,128,128,32,146,171],[18,11,7,63,144,171,4,4,246],[35,27,10,146,174,171,12,26,128]],[[190,80,35,99,180,80,126,54,45],[85,126,47,87,176,51,41,20,32],[101,75,128,139,118,146,116,128,85],[56,41,15,176,236,85,37,9,62],[71,30,17,119,118,255,17,18,138],[101,38,60,138,55,70,43,26,142],[146,36,19,30,171,255,97,27,20],[138,45,61,62,219,1,81,188,64],[32,41,20,117,151,142,20,21,163],[112,19,12,61,195,128,48,4,24]]],fF=[[[[255,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255]],[[176,246,255,255,255,255,255,255,255,255,255],[223,241,252,255,255,255,255,255,255,255,255],[249,253,253,255,255,255,255,255,255,255,255]],[[255,244,252,255,255,255,255,255,255,255,255],[234,254,254,255,255,255,255,255,255,255,255],[253,255,255,255,255,255,255,255,255,255,255]],[[255,246,254,255,255,255,255,255,255,255,255],[239,253,254,255,255,255,255,255,255,255,255],[254,255,254,255,255,255,255,255,255,255,255]],[[255,248,254,255,255,255,255,255,255,255,255],[251,255,254,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255]],[[255,253,254,255,255,255,255,255,255,255,255],[251,254,254,255,255,255,255,255,255,255,255],[254,255,254,255,255,255,255,255,255,255,255]],[[255,254,253,255,254,255,255,255,255,255,255],[250,255,254,255,254,255,255,255,255,255,255],[254,255,255,255,255,255,255,255,255,255,255]],[[255,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255]]],[[[217,255,255,255,255,255,255,255,255,255,255],[225,252,241,253,255,255,254,255,255,255,255],[234,250,241,250,253,255,253,254,255,255,255]],[[255,254,255,255,255,255,255,255,255,255,255],[223,254,254,255,255,255,255,255,255,255,255],[238,253,254,254,255,255,255,255,255,255,255]],[[255,248,254,255,255,255,255,255,255,255,255],[249,254,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255]],[[255,253,255,255,255,255,255,255,255,255,255],[247,254,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255]],[[255,253,254,255,255,255,255,255,255,255,255],[252,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255]],[[255,254,254,255,255,255,255,255,255,255,255],[253,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255]],[[255,254,253,255,255,255,255,255,255,255,255],[250,255,255,255,255,255,255,255,255,255,255],[254,255,255,255,255,255,255,255,255,255,255]],[[255,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255]]],[[[186,251,250,255,255,255,255,255,255,255,255],[234,251,244,254,255,255,255,255,255,255,255],[251,251,243,253,254,255,254,255,255,255,255]],[[255,253,254,255,255,255,255,255,255,255,255],[236,253,254,255,255,255,255,255,255,255,255],[251,253,253,254,254,255,255,255,255,255,255]],[[255,254,254,255,255,255,255,255,255,255,255],[254,254,254,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255]],[[255,254,255,255,255,255,255,255,255,255,255],[254,254,255,255,255,255,255,255,255,255,255],[254,255,255,255,255,255,255,255,255,255,255]],[[255,255,255,255,255,255,255,255,255,255,255],[254,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255]],[[255,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255]],[[255,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255]],[[255,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255]]],[[[248,255,255,255,255,255,255,255,255,255,255],[250,254,252,254,255,255,255,255,255,255,255],[248,254,249,253,255,255,255,255,255,255,255]],[[255,253,253,255,255,255,255,255,255,255,255],[246,253,253,255,255,255,255,255,255,255,255],[252,254,251,254,254,255,255,255,255,255,255]],[[255,254,252,255,255,255,255,255,255,255,255],[248,254,253,255,255,255,255,255,255,255,255],[253,255,254,254,255,255,255,255,255,255,255]],[[255,251,254,255,255,255,255,255,255,255,255],[245,251,254,255,255,255,255,255,255,255,255],[253,253,254,255,255,255,255,255,255,255,255]],[[255,251,253,255,255,255,255,255,255,255,255],[252,253,254,255,255,255,255,255,255,255,255],[255,254,255,255,255,255,255,255,255,255,255]],[[255,252,255,255,255,255,255,255,255,255,255],[249,255,254,255,255,255,255,255,255,255,255],[255,255,254,255,255,255,255,255,255,255,255]],[[255,255,253,255,255,255,255,255,255,255,255],[250,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255]],[[255,255,255,255,255,255,255,255,255,255,255],[254,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255]]]],k_=[0,1,2,3,6,4,5,6,6,6,6,6,6,6,6,7,0],Ac=[],fd=[],zc=[],Uf=1,U1=2,Qs=[],Hc=[];Zt("UpsampleRgbLinePair",ui,3),Zt("UpsampleBgrLinePair",zo,3),Zt("UpsampleRgbaLinePair",Xd,4),Zt("UpsampleBgraLinePair",rs,4),Zt("UpsampleArgbLinePair",Vs,4),Zt("UpsampleRgba4444LinePair",Sl,2),Zt("UpsampleRgb565LinePair",Jo,2);var pF=w.UpsampleRgbLinePair,hF=w.UpsampleBgrLinePair,g2=w.UpsampleRgbaLinePair,z1=w.UpsampleBgraLinePair,e0=w.UpsampleArgbLinePair,yA=w.UpsampleRgba4444LinePair,L_=w.UpsampleRgb565LinePair,Vp=16,Zd=1<<Vp-1,qi=-227,no=482,m2=6,Ss=0,jc=i(256),t0=i(256),H1=i(256),Gc=i(256),Y5=i(no-qi),HC=i(no-qi);ud("YuvToRgbRow",ui,3),ud("YuvToBgrRow",zo,3),ud("YuvToRgbaRow",Xd,4),ud("YuvToBgraRow",rs,4),ud("YuvToArgbRow",Vs,4),ud("YuvToRgba4444Row",Sl,2),ud("YuvToRgb565Row",Jo,2);var D_=[0,4,8,12,128,132,136,140,256,260,264,268,384,388,392,396],n0=[0,2,8],jC=[8,7,6,4,4,2,2,2,1,1,1,1],Wp=1;this.WebPDecodeRGBA=function(V,J,ce,ye,we){var Me=h2,Le=new Df,Be=new mt;Le.ba=Be,Be.S=Me,Be.width=[Be.width],Be.height=[Be.height];var Pe=Be.width,je=Be.height,ot=new vt;if(ot==null||V==null)var Tt=2;else t(ot!=null),Tt=jg(V,J,ce,ot.width,ot.height,ot.Pd,ot.Qd,ot.format,null);if(Tt!=0?Pe=0:(Pe!=null&&(Pe[0]=ot.width[0]),je!=null&&(je[0]=ot.height[0]),Pe=1),Pe){Be.width=Be.width[0],Be.height=Be.height[0],ye!=null&&(ye[0]=Be.width),we!=null&&(we[0]=Be.height);e:{if(ye=new qn,(we=new s2).data=V,we.w=J,we.ha=ce,we.kd=1,J=[0],t(we!=null),((V=jg(we.data,we.w,we.ha,null,null,null,J,null,we))==0||V==7)&&J[0]&&(V=4),(J=V)==0){if(t(Le!=null),ye.data=we.data,ye.w=we.w+we.offset,ye.ha=we.ha-we.offset,ye.put=bt,ye.ac=gt,ye.bc=wt,ye.ma=Le,we.xa){if((V=$n())==null){Le=1;break e}if((function(It,yt){var sn=[0],Vt=[0],ut=[0];t:for(;;){if(It==null)return 0;if(yt==null)return It.a=2,0;if(It.l=yt,It.a=0,P(It.m,yt.data,yt.w,yt.ha),!xt(It.m,sn,Vt,ut)){It.a=3;break t}if(It.xb=U1,yt.width=sn[0],yt.height=Vt[0],!Kn(sn[0],Vt[0],1,It,null))break t;return 1}return t(It.a!=0),0})(V,ye)){if(ye=(J=Gg(ye.width,ye.height,Le.Oa,Le.ba))==0){t:{ye=V;n:for(;;){if(ye==null){ye=0;break t}if(t(ye.s.yc!=null),t(ye.s.Ya!=null),t(0<ye.s.Wb),t((ce=ye.l)!=null),t((we=ce.ma)!=null),ye.xb!=0){if(ye.ca=we.ba,ye.tb=we.tb,t(ye.ca!=null),!T1(we.Oa,ce,pA)){ye.a=2;break n}if(!Cr(ye,ce.width)||ce.da)break n;if((ce.da||Ie(ye.ca.S))&&Et(),11>ye.ca.S||(alert("todo:WebPInitConvertARGBToYUV"),ye.ca.f.kb.F!=null&&Et()),ye.Pb&&0<ye.s.ua&&ye.s.vb.X==null&&!pe(ye.s.vb,ye.s.Wa.Xa)){ye.a=1;break n}ye.xb=0}if(!on(ye,ye.V,ye.Ba,ye.c,ye.i,ce.o,Kt))break n;we.Dc=ye.Ma,ye=1;break t}t(ye.a!=0),ye=0}ye=!ye}ye&&(J=V.a)}else J=V.a}else{if((V=new Or)==null){Le=1;break e}if(V.Fa=we.na,V.P=we.P,V.qc=we.Sa,ei(V,ye)){if((J=Gg(ye.width,ye.height,Le.Oa,Le.ba))==0){if(V.Aa=0,ce=Le.Oa,t((we=V)!=null),ce!=null){if(0<(Pe=0>(Pe=ce.Md)?0:100<Pe?255:255*Pe/100)){for(je=ot=0;4>je;++je)12>(Tt=we.pb[je]).lc&&(Tt.ia=Pe*jC[0>Tt.lc?0:Tt.lc]>>3),ot|=Tt.ia;ot&&(alert("todo:VP8InitRandom"),we.ia=1)}we.Ga=ce.Id,100<we.Ga?we.Ga=100:0>we.Ga&&(we.Ga=0)}$i(V,ye)||(J=V.a)}}else J=V.a}J==0&&Le.Oa!=null&&Le.Oa.fd&&(J=I1(Le.ba))}Le=J}Me=Le!=0?null:11>Me?Be.f.RGBA.eb:Be.f.kb.y}else Me=null;return Me};var bA=[3,4,3,4,4,2,2,4,4,4,2,1,1]};function c(w,T){for(var N="",R=0;R<4;R++)N+=String.fromCharCode(w[T++]);return N}function u(w,T){return(w[T+0]<<0|w[T+1]<<8|w[T+2]<<16)>>>0}function d(w,T){return(w[T+0]<<0|w[T+1]<<8|w[T+2]<<16|w[T+3]<<24)>>>0}new s;var f=[0],p=[0],h=[],g=new s,m=e,A=(function(w,T){var N={},R=0,k=!1,O=0,M=0;if(N.frames=[],!(function(z,W,q,Q){for(var Z=0;Z<Q;Z++)if(z[W+Z]!=q.charCodeAt(Z))return!0;return!1})(w,T,"RIFF",4)){var D,B;for(d(w,T+=4),T+=8;T<w.length;){var $=c(w,T),P=d(w,T+=4);T+=4;var U=P+(1&P);switch($){case"VP8 ":case"VP8L":N.frames[R]===void 0&&(N.frames[R]={}),(F=N.frames[R]).src_off=k?M:T-8,F.src_size=O+P+8,R++,k&&(k=!1,O=0,M=0);break;case"VP8X":(F=N.header={}).feature_flags=w[T];var H=T+4;F.canvas_width=1+u(w,H),H+=3,F.canvas_height=1+u(w,H),H+=3;break;case"ALPH":k=!0,O=U+8,M=T-8;break;case"ANIM":(F=N.header).bgcolor=d(w,T),H=T+4,F.loop_count=(D=w)[(B=H)+0]<<0|D[B+1]<<8,H+=2;break;case"ANMF":var G,F;(F=N.frames[R]={}).offset_x=2*u(w,T),T+=3,F.offset_y=2*u(w,T),T+=3,F.width=1+u(w,T),T+=3,F.height=1+u(w,T),T+=3,F.duration=u(w,T),T+=3,G=w[T++],F.dispose=1&G,F.blend=G>>1&1}$!="ANMF"&&(T+=U)}return N}})(m,0);A.response=m,A.rgbaoutput=!0,A.dataurl=!1;var v=A.header?A.header:null,y=A.frames?A.frames:null;if(v){v.loop_counter=v.loop_count,f=[v.canvas_height],p=[v.canvas_width];for(var _=0;_<y.length&&y[_].blend!=0;_++);}var x=y[0],S=g.WebPDecodeRGBA(m,x.src_off,x.src_size,p,f);x.rgba=S,x.imgwidth=p[0],x.imgheight=f[0];for(var E=0;E<p[0]*f[0]*4;E++)h[E]=S[E];return this.width=p,this.height=f,this.data=h,this}(function(e){var t=function(){return typeof Fce=="function"},n=function(f,p,h,g){var m=4,A=o;switch(g){case e.image_compression.FAST:m=1,A=i;break;case e.image_compression.MEDIUM:m=6,A=l;break;case e.image_compression.SLOW:m=9,A=s}f=r(f,p,h,A);var v=Fce(f,{level:m});return e.__addimage__.arrayBufferToBinaryString(v)},r=function(f,p,h,g){for(var m,A,v,y=f.length/p,_=new Uint8Array(f.length+y),x=u(),S=0;S<y;S+=1){if(v=S*p,m=f.subarray(v,v+p),g)_.set(g(m,h,A),v+S);else{for(var E,w=x.length,T=[];E<w;E+=1)T[E]=x[E](m,h,A);var N=d(T.concat());_.set(T[N],v+S)}A=m}return _},a=function(f){var p=Array.apply([],f);return p.unshift(0),p},i=function(f,p){var h,g=[],m=f.length;g[0]=1;for(var A=0;A<m;A+=1)h=f[A-p]||0,g[A+1]=f[A]-h+256&255;return g},o=function(f,p,h){var g,m=[],A=f.length;m[0]=2;for(var v=0;v<A;v+=1)g=h&&h[v]||0,m[v+1]=f[v]-g+256&255;return m},l=function(f,p,h){var g,m,A=[],v=f.length;A[0]=3;for(var y=0;y<v;y+=1)g=f[y-p]||0,m=h&&h[y]||0,A[y+1]=f[y]+256-(g+m>>>1)&255;return A},s=function(f,p,h){var g,m,A,v,y=[],_=f.length;y[0]=4;for(var x=0;x<_;x+=1)g=f[x-p]||0,m=h&&h[x]||0,A=h&&h[x-p]||0,v=c(g,m,A),y[x+1]=f[x]-v+256&255;return y},c=function(f,p,h){if(f===p&&p===h)return f;var g=Math.abs(p-h),m=Math.abs(f-h),A=Math.abs(f+p-h-h);return g<=m&&g<=A?f:m<=A?p:h},u=function(){return[a,i,o,l,s]},d=function(f){var p=f.map((function(h){return h.reduce((function(g,m){return g+Math.abs(m)}),0)}));return p.indexOf(Math.min.apply(null,p))};e.processPNG=function(f,p,h,g){var m,A,v,y,_,x,S,E,w,T,N,R,k,O,M,D=this.decode.FLATE_DECODE,B="";if(this.__addimage__.isArrayBuffer(f)&&(f=new Uint8Array(f)),this.__addimage__.isArrayBufferView(f)){if(f=(v=new qKn(f)).imgData,A=v.bits,m=v.colorSpace,_=v.colors,[4,6].indexOf(v.colorType)!==-1){if(v.bits===8){w=(E=v.pixelBitlength==32?new Uint32Array(v.decodePixels().buffer):v.pixelBitlength==16?new Uint16Array(v.decodePixels().buffer):new Uint8Array(v.decodePixels().buffer)).length,N=new Uint8Array(w*v.colors),T=new Uint8Array(w);var $,P=v.pixelBitlength-v.bits;for(O=0,M=0;O<w;O++){for(k=E[O],$=0;$<P;)N[M++]=k>>>$&255,$+=v.bits;T[O]=k>>>$&255}}if(v.bits===16){w=(E=new Uint32Array(v.decodePixels().buffer)).length,N=new Uint8Array(w*(32/v.pixelBitlength)*v.colors),T=new Uint8Array(w*(32/v.pixelBitlength)),R=v.colors>1,O=0,M=0;for(var U=0;O<w;)k=E[O++],N[M++]=k>>>0&255,R&&(N[M++]=k>>>16&255,k=E[O++],N[M++]=k>>>0&255),T[U++]=k>>>16&255;A=8}g!==e.image_compression.NONE&&t()?(f=n(N,v.width*v.colors,v.colors,g),S=n(T,v.width,1,g)):(f=N,S=T,D=void 0)}if(v.colorType===3&&(m=this.color_spaces.INDEXED,x=v.palette,v.transparency.indexed)){var H=v.transparency.indexed,G=0;for(O=0,w=H.length;O<w;++O)G+=H[O];if((G/=255)===w-1&&H.indexOf(0)!==-1)y=[H.indexOf(0)];else if(G!==w){for(E=v.decodePixels(),T=new Uint8Array(E.length),O=0,w=E.length;O<w;O++)T[O]=H[E[O]];S=n(T,v.width,1)}}var F=(function(z){var W;switch(z){case e.image_compression.FAST:W=11;break;case e.image_compression.MEDIUM:W=13;break;case e.image_compression.SLOW:W=14;break;default:W=12}return W})(g);return D===this.decode.FLATE_DECODE&&(B="/Predictor "+F+" "),B+="/Colors "+_+" /BitsPerComponent "+A+" /Columns "+v.width,(this.__addimage__.isArrayBuffer(f)||this.__addimage__.isArrayBufferView(f))&&(f=this.__addimage__.arrayBufferToBinaryString(f)),(S&&this.__addimage__.isArrayBuffer(S)||this.__addimage__.isArrayBufferView(S))&&(S=this.__addimage__.arrayBufferToBinaryString(S)),{alias:h,data:f,index:p,filter:D,decodeParameters:B,transparency:y,palette:x,sMask:S,predictor:F,width:v.width,height:v.height,bitsPerComponent:A,colorSpace:m}}}})(la.API),(function(e){e.processGIF89A=function(t,n,r,a){var i=new QKn(t),o=i.width,l=i.height,s=[];i.decodeAndBlitFrameRGBA(0,s);var c={data:s,width:o,height:l},u=new mte(100).encode(c,100);return e.processJPEG.call(this,u,n,r,a)},e.processGIF87A=e.processGIF89A})(la.API),oh.prototype.parseHeader=function(){if(this.fileSize=this.datav.getUint32(this.pos,!0),this.pos+=4,this.reserved=this.datav.getUint32(this.pos,!0),this.pos+=4,this.offset=this.datav.getUint32(this.pos,!0),this.pos+=4,this.headerSize=this.datav.getUint32(this.pos,!0),this.pos+=4,this.width=this.datav.getUint32(this.pos,!0),this.pos+=4,this.height=this.datav.getInt32(this.pos,!0),this.pos+=4,this.planes=this.datav.getUint16(this.pos,!0),this.pos+=2,this.bitPP=this.datav.getUint16(this.pos,!0),this.pos+=2,this.compress=this.datav.getUint32(this.pos,!0),this.pos+=4,this.rawSize=this.datav.getUint32(this.pos,!0),this.pos+=4,this.hr=this.datav.getUint32(this.pos,!0),this.pos+=4,this.vr=this.datav.getUint32(this.pos,!0),this.pos+=4,this.colors=this.datav.getUint32(this.pos,!0),this.pos+=4,this.importantColors=this.datav.getUint32(this.pos,!0),this.pos+=4,this.bitPP===16&&this.is_with_alpha&&(this.bitPP=15),this.bitPP<15){var e=this.colors===0?1<<this.bitPP:this.colors;this.palette=new Array(e);for(var t=0;t<e;t++){var n=this.datav.getUint8(this.pos++,!0),r=this.datav.getUint8(this.pos++,!0),a=this.datav.getUint8(this.pos++,!0),i=this.datav.getUint8(this.pos++,!0);this.palette[t]={red:a,green:r,blue:n,quad:i}}}this.height<0&&(this.height*=-1,this.bottom_up=!1)},oh.prototype.parseBGR=function(){this.pos=this.offset;try{var e="bit"+this.bitPP,t=this.width*this.height*4;this.data=new Uint8Array(t),this[e]()}catch(n){Ro.log("bit decode error:"+n)}},oh.prototype.bit1=function(){var e,t=Math.ceil(this.width/8),n=t%4;for(e=this.height-1;e>=0;e--){for(var r=this.bottom_up?e:this.height-1-e,a=0;a<t;a++)for(var i=this.datav.getUint8(this.pos++,!0),o=r*this.width*4+8*a*4,l=0;l<8&&8*a+l<this.width;l++){var s=this.palette[i>>7-l&1];this.data[o+4*l]=s.blue,this.data[o+4*l+1]=s.green,this.data[o+4*l+2]=s.red,this.data[o+4*l+3]=255}n!==0&&(this.pos+=4-n)}},oh.prototype.bit4=function(){for(var e=Math.ceil(this.width/2),t=e%4,n=this.height-1;n>=0;n--){for(var r=this.bottom_up?n:this.height-1-n,a=0;a<e;a++){var i=this.datav.getUint8(this.pos++,!0),o=r*this.width*4+2*a*4,l=i>>4,s=15&i,c=this.palette[l];if(this.data[o]=c.blue,this.data[o+1]=c.green,this.data[o+2]=c.red,this.data[o+3]=255,2*a+1>=this.width)break;c=this.palette[s],this.data[o+4]=c.blue,this.data[o+4+1]=c.green,this.data[o+4+2]=c.red,this.data[o+4+3]=255}t!==0&&(this.pos+=4-t)}},oh.prototype.bit8=function(){for(var e=this.width%4,t=this.height-1;t>=0;t--){for(var n=this.bottom_up?t:this.height-1-t,r=0;r<this.width;r++){var a=this.datav.getUint8(this.pos++,!0),i=n*this.width*4+4*r;if(a<this.palette.length){var o=this.palette[a];this.data[i]=o.red,this.data[i+1]=o.green,this.data[i+2]=o.blue,this.data[i+3]=255}else this.data[i]=255,this.data[i+1]=255,this.data[i+2]=255,this.data[i+3]=255}e!==0&&(this.pos+=4-e)}},oh.prototype.bit15=function(){for(var e=this.width%3,t=parseInt("11111",2),n=this.height-1;n>=0;n--){for(var r=this.bottom_up?n:this.height-1-n,a=0;a<this.width;a++){var i=this.datav.getUint16(this.pos,!0);this.pos+=2;var o=(i&t)/t*255|0,l=(i>>5&t)/t*255|0,s=(i>>10&t)/t*255|0,c=i>>15?255:0,u=r*this.width*4+4*a;this.data[u]=s,this.data[u+1]=l,this.data[u+2]=o,this.data[u+3]=c}this.pos+=e}},oh.prototype.bit16=function(){for(var e=this.width%3,t=parseInt("11111",2),n=parseInt("111111",2),r=this.height-1;r>=0;r--){for(var a=this.bottom_up?r:this.height-1-r,i=0;i<this.width;i++){var o=this.datav.getUint16(this.pos,!0);this.pos+=2;var l=(o&t)/t*255|0,s=(o>>5&n)/n*255|0,c=(o>>11)/t*255|0,u=a*this.width*4+4*i;this.data[u]=c,this.data[u+1]=s,this.data[u+2]=l,this.data[u+3]=255}this.pos+=e}},oh.prototype.bit24=function(){for(var e=this.height-1;e>=0;e--){for(var t=this.bottom_up?e:this.height-1-e,n=0;n<this.width;n++){var r=this.datav.getUint8(this.pos++,!0),a=this.datav.getUint8(this.pos++,!0),i=this.datav.getUint8(this.pos++,!0),o=t*this.width*4+4*n;this.data[o]=i,this.data[o+1]=a,this.data[o+2]=r,this.data[o+3]=255}this.pos+=this.width%4}},oh.prototype.bit32=function(){for(var e=this.height-1;e>=0;e--)for(var t=this.bottom_up?e:this.height-1-e,n=0;n<this.width;n++){var r=this.datav.getUint8(this.pos++,!0),a=this.datav.getUint8(this.pos++,!0),i=this.datav.getUint8(this.pos++,!0),o=this.datav.getUint8(this.pos++,!0),l=t*this.width*4+4*n;this.data[l]=i,this.data[l+1]=a,this.data[l+2]=r,this.data[l+3]=o}},oh.prototype.getData=function(){return this.data},(function(e){e.processBMP=function(t,n,r,a){var i=new oh(t,!1),o=i.width,l=i.height,s={data:i.getData(),width:o,height:l},c=new mte(100).encode(s,100);return e.processJPEG.call(this,c,n,r,a)}})(la.API),Qze.prototype.getData=function(){return this.data},(function(e){e.processWEBP=function(t,n,r,a){var i=new Qze(t),o=i.width,l=i.height,s={data:i.getData(),width:o,height:l},c=new mte(100).encode(s,100);return e.processJPEG.call(this,c,n,r,a)}})(la.API),la.API.processRGBA=function(e,t,n){for(var r=e.data,a=r.length,i=new Uint8Array(a/4*3),o=new Uint8Array(a/4),l=0,s=0,c=0;c<a;c+=4){var u=r[c],d=r[c+1],f=r[c+2],p=r[c+3];i[l++]=u,i[l++]=d,i[l++]=f,o[s++]=p}var h=this.__addimage__.arrayBufferToBinaryString(i);return{alpha:this.__addimage__.arrayBufferToBinaryString(o),data:h,index:t,alias:n,colorSpace:"DeviceRGB",bitsPerComponent:8,width:e.width,height:e.height}},la.API.setLanguage=function(e){return this.internal.languageSettings===void 0&&(this.internal.languageSettings={},this.internal.languageSettings.isSubscribed=!1),{af:"Afrikaans",sq:"Albanian",ar:"Arabic (Standard)","ar-DZ":"Arabic (Algeria)","ar-BH":"Arabic (Bahrain)","ar-EG":"Arabic (Egypt)","ar-IQ":"Arabic (Iraq)","ar-JO":"Arabic (Jordan)","ar-KW":"Arabic (Kuwait)","ar-LB":"Arabic (Lebanon)","ar-LY":"Arabic (Libya)","ar-MA":"Arabic (Morocco)","ar-OM":"Arabic (Oman)","ar-QA":"Arabic (Qatar)","ar-SA":"Arabic (Saudi Arabia)","ar-SY":"Arabic (Syria)","ar-TN":"Arabic (Tunisia)","ar-AE":"Arabic (U.A.E.)","ar-YE":"Arabic (Yemen)",an:"Aragonese",hy:"Armenian",as:"Assamese",ast:"Asturian",az:"Azerbaijani",eu:"Basque",be:"Belarusian",bn:"Bengali",bs:"Bosnian",br:"Breton",bg:"Bulgarian",my:"Burmese",ca:"Catalan",ch:"Chamorro",ce:"Chechen",zh:"Chinese","zh-HK":"Chinese (Hong Kong)","zh-CN":"Chinese (PRC)","zh-SG":"Chinese (Singapore)","zh-TW":"Chinese (Taiwan)",cv:"Chuvash",co:"Corsican",cr:"Cree",hr:"Croatian",cs:"Czech",da:"Danish",nl:"Dutch (Standard)","nl-BE":"Dutch (Belgian)",en:"English","en-AU":"English (Australia)","en-BZ":"English (Belize)","en-CA":"English (Canada)","en-IE":"English (Ireland)","en-JM":"English (Jamaica)","en-NZ":"English (New Zealand)","en-PH":"English (Philippines)","en-ZA":"English (South Africa)","en-TT":"English (Trinidad & Tobago)","en-GB":"English (United Kingdom)","en-US":"English (United States)","en-ZW":"English (Zimbabwe)",eo:"Esperanto",et:"Estonian",fo:"Faeroese",fj:"Fijian",fi:"Finnish",fr:"French (Standard)","fr-BE":"French (Belgium)","fr-CA":"French (Canada)","fr-FR":"French (France)","fr-LU":"French (Luxembourg)","fr-MC":"French (Monaco)","fr-CH":"French (Switzerland)",fy:"Frisian",fur:"Friulian",gd:"Gaelic (Scots)","gd-IE":"Gaelic (Irish)",gl:"Galacian",ka:"Georgian",de:"German (Standard)","de-AT":"German (Austria)","de-DE":"German (Germany)","de-LI":"German (Liechtenstein)","de-LU":"German (Luxembourg)","de-CH":"German (Switzerland)",el:"Greek",gu:"Gujurati",ht:"Haitian",he:"Hebrew",hi:"Hindi",hu:"Hungarian",is:"Icelandic",id:"Indonesian",iu:"Inuktitut",ga:"Irish",it:"Italian (Standard)","it-CH":"Italian (Switzerland)",ja:"Japanese",kn:"Kannada",ks:"Kashmiri",kk:"Kazakh",km:"Khmer",ky:"Kirghiz",tlh:"Klingon",ko:"Korean","ko-KP":"Korean (North Korea)","ko-KR":"Korean (South Korea)",la:"Latin",lv:"Latvian",lt:"Lithuanian",lb:"Luxembourgish",mk:"North Macedonia",ms:"Malay",ml:"Malayalam",mt:"Maltese",mi:"Maori",mr:"Marathi",mo:"Moldavian",nv:"Navajo",ng:"Ndonga",ne:"Nepali",no:"Norwegian",nb:"Norwegian (Bokmal)",nn:"Norwegian (Nynorsk)",oc:"Occitan",or:"Oriya",om:"Oromo",fa:"Persian","fa-IR":"Persian/Iran",pl:"Polish",pt:"Portuguese","pt-BR":"Portuguese (Brazil)",pa:"Punjabi","pa-IN":"Punjabi (India)","pa-PK":"Punjabi (Pakistan)",qu:"Quechua",rm:"Rhaeto-Romanic",ro:"Romanian","ro-MO":"Romanian (Moldavia)",ru:"Russian","ru-MO":"Russian (Moldavia)",sz:"Sami (Lappish)",sg:"Sango",sa:"Sanskrit",sc:"Sardinian",sd:"Sindhi",si:"Singhalese",sr:"Serbian",sk:"Slovak",sl:"Slovenian",so:"Somani",sb:"Sorbian",es:"Spanish","es-AR":"Spanish (Argentina)","es-BO":"Spanish (Bolivia)","es-CL":"Spanish (Chile)","es-CO":"Spanish (Colombia)","es-CR":"Spanish (Costa Rica)","es-DO":"Spanish (Dominican Republic)","es-EC":"Spanish (Ecuador)","es-SV":"Spanish (El Salvador)","es-GT":"Spanish (Guatemala)","es-HN":"Spanish (Honduras)","es-MX":"Spanish (Mexico)","es-NI":"Spanish (Nicaragua)","es-PA":"Spanish (Panama)","es-PY":"Spanish (Paraguay)","es-PE":"Spanish (Peru)","es-PR":"Spanish (Puerto Rico)","es-ES":"Spanish (Spain)","es-UY":"Spanish (Uruguay)","es-VE":"Spanish (Venezuela)",sx:"Sutu",sw:"Swahili",sv:"Swedish","sv-FI":"Swedish (Finland)","sv-SV":"Swedish (Sweden)",ta:"Tamil",tt:"Tatar",te:"Teluga",th:"Thai",tig:"Tigre",ts:"Tsonga",tn:"Tswana",tr:"Turkish",tk:"Turkmen",uk:"Ukrainian",hsb:"Upper Sorbian",ur:"Urdu",ve:"Venda",vi:"Vietnamese",vo:"Volapuk",wa:"Walloon",cy:"Welsh",xh:"Xhosa",ji:"Yiddish",zu:"Zulu"}[e]!==void 0&&(this.internal.languageSettings.languageCode=e,this.internal.languageSettings.isSubscribed===!1&&(this.internal.events.subscribe("putCatalog",(function(){this.internal.write("/Lang ("+this.internal.languageSettings.languageCode+")")})),this.internal.languageSettings.isSubscribed=!0)),this},rb=la.API,XR=rb.getCharWidthsArray=function(e,t){var n,r,a=(t=t||{}).font||this.internal.getFont(),i=t.fontSize||this.internal.getFontSize(),o=t.charSpace||this.internal.getCharSpace(),l=t.widths?t.widths:a.metadata.Unicode.widths,s=l.fof?l.fof:1,c=t.kerning?t.kerning:a.metadata.Unicode.kerning,u=c.fof?c.fof:1,d=t.doKerning!==!1,f=0,p=e.length,h=0,g=l[0]||s,m=[];for(n=0;n<p;n++)r=e.charCodeAt(n),typeof a.metadata.widthOfString=="function"?m.push((a.metadata.widthOfGlyph(a.metadata.characterToGlyph(r))+o*(1e3/i)||0)/1e3):(f=d&&ii(c[r])==="object"&&!isNaN(parseInt(c[r][h],10))?c[r][h]/u:0,m.push((l[r]||g)/s+f)),h=r;return m},Gze=rb.getStringUnitWidth=function(e,t){var n=(t=t||{}).fontSize||this.internal.getFontSize(),r=t.font||this.internal.getFont(),a=t.charSpace||this.internal.getCharSpace();return rb.processArabic&&(e=rb.processArabic(e)),typeof r.metadata.widthOfString=="function"?r.metadata.widthOfString(e,n,a)/n:XR.apply(this,arguments).reduce((function(i,o){return i+o}),0)},Vze=function(e,t,n,r){for(var a=[],i=0,o=e.length,l=0;i!==o&&l+t[i]<n;)l+=t[i],i++;a.push(e.slice(0,i));var s=i;for(l=0;i!==o;)l+t[i]>r&&(a.push(e.slice(s,i)),l=0,s=i),l+=t[i],i++;return s!==i&&a.push(e.slice(s,i)),a},Wze=function(e,t,n){n||(n={});var r,a,i,o,l,s,c,u=[],d=[u],f=n.textIndent||0,p=0,h=0,g=e.split(" "),m=XR.apply(this,[" ",n])[0];if(s=n.lineIndent===-1?g[0].length+2:n.lineIndent||0){var A=Array(s).join(" "),v=[];g.map((function(_){(_=_.split(/\s*\n/)).length>1?v=v.concat(_.map((function(x,S){return(S&&x.length?`
2011
2011
  `:"")+x}))):v.push(_[0])})),g=v,s=Gze.apply(this,[A,n])}for(i=0,o=g.length;i<o;i++){var y=0;if(r=g[i],s&&r[0]==`
2012
- `&&(r=r.substr(1),y=1),f+p+(h=(a=XR.apply(this,[r,n])).reduce((function(_,x){return _+x}),0))>t||y){if(h>t){for(l=Vze.apply(this,[r,a,t-(f+p),t]),u.push(l.shift()),u=[l.pop()];l.length;)d.push([l.shift()]);h=a.slice(r.length-(u[0]?u[0].length:0)).reduce((function(_,x){return _+x}),0)}else u=[r];d.push(u),f=h+s,p=m}else u.push(r),f+=p+h,p=m}return c=s?function(_,x){return(x?A:"")+_.join(" ")}:function(_){return _.join(" ")},d.map(c)},rb.splitTextToSize=function(e,t,n){var r,a=(n=n||{}).fontSize||this.internal.getFontSize(),i=(function(u){if(u.widths&&u.kerning)return{widths:u.widths,kerning:u.kerning};var d=this.internal.getFont(u.fontName,u.fontStyle);return d.metadata.Unicode?{widths:d.metadata.Unicode.widths||{0:1},kerning:d.metadata.Unicode.kerning||{}}:{font:d.metadata,fontSize:this.internal.getFontSize(),charSpace:this.internal.getCharSpace()}}).call(this,n);r=Array.isArray(e)?e:String(e).split(/\r?\n/);var o=1*this.internal.scaleFactor*t/a;i.textIndent=n.textIndent?1*n.textIndent*this.internal.scaleFactor/a:0,i.lineIndent=n.lineIndent;var l,s,c=[];for(l=0,s=r.length;l<s;l++)c=c.concat(Wze.apply(this,[r[l],o,i]));return c},(function(e){e.__fontmetrics__=e.__fontmetrics__||{};for(var t="klmnopqrstuvwxyz",n={},r={},a=0;a<t.length;a++)n[t[a]]="0123456789abcdef"[a],r["0123456789abcdef"[a]]=t[a];var i=function(d){return"0x"+parseInt(d,10).toString(16)},o=e.__fontmetrics__.compress=function(d){var f,p,h,g,m=["{"];for(var A in d){if(f=d[A],isNaN(parseInt(A,10))?p="'"+A+"'":(A=parseInt(A,10),p=(p=i(A).slice(2)).slice(0,-1)+r[p.slice(-1)]),typeof f=="number")f<0?(h=i(f).slice(3),g="-"):(h=i(f).slice(2),g=""),h=g+h.slice(0,-1)+r[h.slice(-1)];else{if(ii(f)!=="object")throw new Error("Don't know what to do with value type "+ii(f)+".");h=o(f)}m.push(p+h)}return m.push("}"),m.join("")},l=e.__fontmetrics__.uncompress=function(d){if(typeof d!="string")throw new Error("Invalid argument passed to uncompress.");for(var f,p,h,g,m={},A=1,v=m,y=[],_="",x="",S=d.length-1,E=1;E<S;E+=1)(g=d[E])=="'"?f?(h=f.join(""),f=void 0):f=[]:f?f.push(g):g=="{"?(y.push([v,h]),v={},h=void 0):g=="}"?((p=y.pop())[0][p[1]]=v,h=void 0,v=p[0]):g=="-"?A=-1:h===void 0?n.hasOwnProperty(g)?(_+=n[g],h=parseInt(_,16)*A,A=1,_=""):_+=g:n.hasOwnProperty(g)?(x+=n[g],v[h]=parseInt(x,16)*A,A=1,h=void 0,x=""):x+=g;return m},s={codePages:["WinAnsiEncoding"],WinAnsiEncoding:l("{19m8n201n9q201o9r201s9l201t9m201u8m201w9n201x9o201y8o202k8q202l8r202m9p202q8p20aw8k203k8t203t8v203u9v2cq8s212m9t15m8w15n9w2dw9s16k8u16l9u17s9z17x8y17y9y}")},c={Unicode:{Courier:s,"Courier-Bold":s,"Courier-BoldOblique":s,"Courier-Oblique":s,Helvetica:s,"Helvetica-Bold":s,"Helvetica-BoldOblique":s,"Helvetica-Oblique":s,"Times-Roman":s,"Times-Bold":s,"Times-BoldItalic":s,"Times-Italic":s}},u={Unicode:{"Courier-Oblique":l("{'widths'{k3w'fof'6o}'kerning'{'fof'-6o}}"),"Times-BoldItalic":l("{'widths'{k3o2q4ycx2r201n3m201o6o201s2l201t2l201u2l201w3m201x3m201y3m2k1t2l2r202m2n2n3m2o3m2p5n202q6o2r1w2s2l2t2l2u3m2v3t2w1t2x2l2y1t2z1w3k3m3l3m3m3m3n3m3o3m3p3m3q3m3r3m3s3m203t2l203u2l3v2l3w3t3x3t3y3t3z3m4k5n4l4m4m4m4n4m4o4s4p4m4q4m4r4s4s4y4t2r4u3m4v4m4w3x4x5t4y4s4z4s5k3x5l4s5m4m5n3r5o3x5p4s5q4m5r5t5s4m5t3x5u3x5v2l5w1w5x2l5y3t5z3m6k2l6l3m6m3m6n2w6o3m6p2w6q2l6r3m6s3r6t1w6u1w6v3m6w1w6x4y6y3r6z3m7k3m7l3m7m2r7n2r7o1w7p3r7q2w7r4m7s3m7t2w7u2r7v2n7w1q7x2n7y3t202l3mcl4mal2ram3man3mao3map3mar3mas2lat4uau1uav3maw3way4uaz2lbk2sbl3t'fof'6obo2lbp3tbq3mbr1tbs2lbu1ybv3mbz3mck4m202k3mcm4mcn4mco4mcp4mcq5ycr4mcs4mct4mcu4mcv4mcw2r2m3rcy2rcz2rdl4sdm4sdn4sdo4sdp4sdq4sds4sdt4sdu4sdv4sdw4sdz3mek3mel3mem3men3meo3mep3meq4ser2wes2wet2weu2wev2wew1wex1wey1wez1wfl3rfm3mfn3mfo3mfp3mfq3mfr3tfs3mft3rfu3rfv3rfw3rfz2w203k6o212m6o2dw2l2cq2l3t3m3u2l17s3x19m3m}'kerning'{cl{4qu5kt5qt5rs17ss5ts}201s{201ss}201t{cks4lscmscnscoscpscls2wu2yu201ts}201x{2wu2yu}2k{201ts}2w{4qx5kx5ou5qx5rs17su5tu}2x{17su5tu5ou}2y{4qx5kx5ou5qx5rs17ss5ts}'fof'-6ofn{17sw5tw5ou5qw5rs}7t{cksclscmscnscoscps4ls}3u{17su5tu5os5qs}3v{17su5tu5os5qs}7p{17su5tu}ck{4qu5kt5qt5rs17ss5ts}4l{4qu5kt5qt5rs17ss5ts}cm{4qu5kt5qt5rs17ss5ts}cn{4qu5kt5qt5rs17ss5ts}co{4qu5kt5qt5rs17ss5ts}cp{4qu5kt5qt5rs17ss5ts}6l{4qu5ou5qw5rt17su5tu}5q{ckuclucmucnucoucpu4lu}5r{ckuclucmucnucoucpu4lu}7q{cksclscmscnscoscps4ls}6p{4qu5ou5qw5rt17sw5tw}ek{4qu5ou5qw5rt17su5tu}el{4qu5ou5qw5rt17su5tu}em{4qu5ou5qw5rt17su5tu}en{4qu5ou5qw5rt17su5tu}eo{4qu5ou5qw5rt17su5tu}ep{4qu5ou5qw5rt17su5tu}es{17ss5ts5qs4qu}et{4qu5ou5qw5rt17sw5tw}eu{4qu5ou5qw5rt17ss5ts}ev{17ss5ts5qs4qu}6z{17sw5tw5ou5qw5rs}fm{17sw5tw5ou5qw5rs}7n{201ts}fo{17sw5tw5ou5qw5rs}fp{17sw5tw5ou5qw5rs}fq{17sw5tw5ou5qw5rs}7r{cksclscmscnscoscps4ls}fs{17sw5tw5ou5qw5rs}ft{17su5tu}fu{17su5tu}fv{17su5tu}fw{17su5tu}fz{cksclscmscnscoscps4ls}}}"),"Helvetica-Bold":l("{'widths'{k3s2q4scx1w201n3r201o6o201s1w201t1w201u1w201w3m201x3m201y3m2k1w2l2l202m2n2n3r2o3r2p5t202q6o2r1s2s2l2t2l2u2r2v3u2w1w2x2l2y1w2z1w3k3r3l3r3m3r3n3r3o3r3p3r3q3r3r3r3s3r203t2l203u2l3v2l3w3u3x3u3y3u3z3x4k6l4l4s4m4s4n4s4o4s4p4m4q3x4r4y4s4s4t1w4u3r4v4s4w3x4x5n4y4s4z4y5k4m5l4y5m4s5n4m5o3x5p4s5q4m5r5y5s4m5t4m5u3x5v2l5w1w5x2l5y3u5z3r6k2l6l3r6m3x6n3r6o3x6p3r6q2l6r3x6s3x6t1w6u1w6v3r6w1w6x5t6y3x6z3x7k3x7l3x7m2r7n3r7o2l7p3x7q3r7r4y7s3r7t3r7u3m7v2r7w1w7x2r7y3u202l3rcl4sal2lam3ran3rao3rap3rar3ras2lat4tau2pav3raw3uay4taz2lbk2sbl3u'fof'6obo2lbp3xbq3rbr1wbs2lbu2obv3rbz3xck4s202k3rcm4scn4sco4scp4scq6ocr4scs4mct4mcu4mcv4mcw1w2m2zcy1wcz1wdl4sdm4ydn4ydo4ydp4ydq4yds4ydt4sdu4sdv4sdw4sdz3xek3rel3rem3ren3reo3rep3req5ter3res3ret3reu3rev3rew1wex1wey1wez1wfl3xfm3xfn3xfo3xfp3xfq3xfr3ufs3xft3xfu3xfv3xfw3xfz3r203k6o212m6o2dw2l2cq2l3t3r3u2l17s4m19m3r}'kerning'{cl{4qs5ku5ot5qs17sv5tv}201t{2ww4wy2yw}201w{2ks}201x{2ww4wy2yw}2k{201ts201xs}2w{7qs4qu5kw5os5qw5rs17su5tu7tsfzs}2x{5ow5qs}2y{7qs4qu5kw5os5qw5rs17su5tu7tsfzs}'fof'-6o7p{17su5tu5ot}ck{4qs5ku5ot5qs17sv5tv}4l{4qs5ku5ot5qs17sv5tv}cm{4qs5ku5ot5qs17sv5tv}cn{4qs5ku5ot5qs17sv5tv}co{4qs5ku5ot5qs17sv5tv}cp{4qs5ku5ot5qs17sv5tv}6l{17st5tt5os}17s{2kwclvcmvcnvcovcpv4lv4wwckv}5o{2kucltcmtcntcotcpt4lt4wtckt}5q{2ksclscmscnscoscps4ls4wvcks}5r{2ks4ws}5t{2kwclvcmvcnvcovcpv4lv4wwckv}eo{17st5tt5os}fu{17su5tu5ot}6p{17ss5ts}ek{17st5tt5os}el{17st5tt5os}em{17st5tt5os}en{17st5tt5os}6o{201ts}ep{17st5tt5os}es{17ss5ts}et{17ss5ts}eu{17ss5ts}ev{17ss5ts}6z{17su5tu5os5qt}fm{17su5tu5os5qt}fn{17su5tu5os5qt}fo{17su5tu5os5qt}fp{17su5tu5os5qt}fq{17su5tu5os5qt}fs{17su5tu5os5qt}ft{17su5tu5ot}7m{5os}fv{17su5tu5ot}fw{17su5tu5ot}}}"),Courier:l("{'widths'{k3w'fof'6o}'kerning'{'fof'-6o}}"),"Courier-BoldOblique":l("{'widths'{k3w'fof'6o}'kerning'{'fof'-6o}}"),"Times-Bold":l("{'widths'{k3q2q5ncx2r201n3m201o6o201s2l201t2l201u2l201w3m201x3m201y3m2k1t2l2l202m2n2n3m2o3m2p6o202q6o2r1w2s2l2t2l2u3m2v3t2w1t2x2l2y1t2z1w3k3m3l3m3m3m3n3m3o3m3p3m3q3m3r3m3s3m203t2l203u2l3v2l3w3t3x3t3y3t3z3m4k5x4l4s4m4m4n4s4o4s4p4m4q3x4r4y4s4y4t2r4u3m4v4y4w4m4x5y4y4s4z4y5k3x5l4y5m4s5n3r5o4m5p4s5q4s5r6o5s4s5t4s5u4m5v2l5w1w5x2l5y3u5z3m6k2l6l3m6m3r6n2w6o3r6p2w6q2l6r3m6s3r6t1w6u2l6v3r6w1w6x5n6y3r6z3m7k3r7l3r7m2w7n2r7o2l7p3r7q3m7r4s7s3m7t3m7u2w7v2r7w1q7x2r7y3o202l3mcl4sal2lam3man3mao3map3mar3mas2lat4uau1yav3maw3tay4uaz2lbk2sbl3t'fof'6obo2lbp3rbr1tbs2lbu2lbv3mbz3mck4s202k3mcm4scn4sco4scp4scq6ocr4scs4mct4mcu4mcv4mcw2r2m3rcy2rcz2rdl4sdm4ydn4ydo4ydp4ydq4yds4ydt4sdu4sdv4sdw4sdz3rek3mel3mem3men3meo3mep3meq4ser2wes2wet2weu2wev2wew1wex1wey1wez1wfl3rfm3mfn3mfo3mfp3mfq3mfr3tfs3mft3rfu3rfv3rfw3rfz3m203k6o212m6o2dw2l2cq2l3t3m3u2l17s4s19m3m}'kerning'{cl{4qt5ks5ot5qy5rw17sv5tv}201t{cks4lscmscnscoscpscls4wv}2k{201ts}2w{4qu5ku7mu5os5qx5ru17su5tu}2x{17su5tu5ou5qs}2y{4qv5kv7mu5ot5qz5ru17su5tu}'fof'-6o7t{cksclscmscnscoscps4ls}3u{17su5tu5os5qu}3v{17su5tu5os5qu}fu{17su5tu5ou5qu}7p{17su5tu5ou5qu}ck{4qt5ks5ot5qy5rw17sv5tv}4l{4qt5ks5ot5qy5rw17sv5tv}cm{4qt5ks5ot5qy5rw17sv5tv}cn{4qt5ks5ot5qy5rw17sv5tv}co{4qt5ks5ot5qy5rw17sv5tv}cp{4qt5ks5ot5qy5rw17sv5tv}6l{17st5tt5ou5qu}17s{ckuclucmucnucoucpu4lu4wu}5o{ckuclucmucnucoucpu4lu4wu}5q{ckzclzcmzcnzcozcpz4lz4wu}5r{ckxclxcmxcnxcoxcpx4lx4wu}5t{ckuclucmucnucoucpu4lu4wu}7q{ckuclucmucnucoucpu4lu}6p{17sw5tw5ou5qu}ek{17st5tt5qu}el{17st5tt5ou5qu}em{17st5tt5qu}en{17st5tt5qu}eo{17st5tt5qu}ep{17st5tt5ou5qu}es{17ss5ts5qu}et{17sw5tw5ou5qu}eu{17sw5tw5ou5qu}ev{17ss5ts5qu}6z{17sw5tw5ou5qu5rs}fm{17sw5tw5ou5qu5rs}fn{17sw5tw5ou5qu5rs}fo{17sw5tw5ou5qu5rs}fp{17sw5tw5ou5qu5rs}fq{17sw5tw5ou5qu5rs}7r{cktcltcmtcntcotcpt4lt5os}fs{17sw5tw5ou5qu5rs}ft{17su5tu5ou5qu}7m{5os}fv{17su5tu5ou5qu}fw{17su5tu5ou5qu}fz{cksclscmscnscoscps4ls}}}"),Symbol:l("{'widths'{k3uaw4r19m3m2k1t2l2l202m2y2n3m2p5n202q6o3k3m2s2l2t2l2v3r2w1t3m3m2y1t2z1wbk2sbl3r'fof'6o3n3m3o3m3p3m3q3m3r3m3s3m3t3m3u1w3v1w3w3r3x3r3y3r3z2wbp3t3l3m5v2l5x2l5z3m2q4yfr3r7v3k7w1o7x3k}'kerning'{'fof'-6o}}"),Helvetica:l("{'widths'{k3p2q4mcx1w201n3r201o6o201s1q201t1q201u1q201w2l201x2l201y2l2k1w2l1w202m2n2n3r2o3r2p5t202q6o2r1n2s2l2t2l2u2r2v3u2w1w2x2l2y1w2z1w3k3r3l3r3m3r3n3r3o3r3p3r3q3r3r3r3s3r203t2l203u2l3v1w3w3u3x3u3y3u3z3r4k6p4l4m4m4m4n4s4o4s4p4m4q3x4r4y4s4s4t1w4u3m4v4m4w3r4x5n4y4s4z4y5k4m5l4y5m4s5n4m5o3x5p4s5q4m5r5y5s4m5t4m5u3x5v1w5w1w5x1w5y2z5z3r6k2l6l3r6m3r6n3m6o3r6p3r6q1w6r3r6s3r6t1q6u1q6v3m6w1q6x5n6y3r6z3r7k3r7l3r7m2l7n3m7o1w7p3r7q3m7r4s7s3m7t3m7u3m7v2l7w1u7x2l7y3u202l3rcl4mal2lam3ran3rao3rap3rar3ras2lat4tau2pav3raw3uay4taz2lbk2sbl3u'fof'6obo2lbp3rbr1wbs2lbu2obv3rbz3xck4m202k3rcm4mcn4mco4mcp4mcq6ocr4scs4mct4mcu4mcv4mcw1w2m2ncy1wcz1wdl4sdm4ydn4ydo4ydp4ydq4yds4ydt4sdu4sdv4sdw4sdz3xek3rel3rem3ren3reo3rep3req5ter3mes3ret3reu3rev3rew1wex1wey1wez1wfl3rfm3rfn3rfo3rfp3rfq3rfr3ufs3xft3rfu3rfv3rfw3rfz3m203k6o212m6o2dw2l2cq2l3t3r3u1w17s4m19m3r}'kerning'{5q{4wv}cl{4qs5kw5ow5qs17sv5tv}201t{2wu4w1k2yu}201x{2wu4wy2yu}17s{2ktclucmucnu4otcpu4lu4wycoucku}2w{7qs4qz5k1m17sy5ow5qx5rsfsu5ty7tufzu}2x{17sy5ty5oy5qs}2y{7qs4qz5k1m17sy5ow5qx5rsfsu5ty7tufzu}'fof'-6o7p{17sv5tv5ow}ck{4qs5kw5ow5qs17sv5tv}4l{4qs5kw5ow5qs17sv5tv}cm{4qs5kw5ow5qs17sv5tv}cn{4qs5kw5ow5qs17sv5tv}co{4qs5kw5ow5qs17sv5tv}cp{4qs5kw5ow5qs17sv5tv}6l{17sy5ty5ow}do{17st5tt}4z{17st5tt}7s{fst}dm{17st5tt}dn{17st5tt}5o{ckwclwcmwcnwcowcpw4lw4wv}dp{17st5tt}dq{17st5tt}7t{5ow}ds{17st5tt}5t{2ktclucmucnu4otcpu4lu4wycoucku}fu{17sv5tv5ow}6p{17sy5ty5ow5qs}ek{17sy5ty5ow}el{17sy5ty5ow}em{17sy5ty5ow}en{5ty}eo{17sy5ty5ow}ep{17sy5ty5ow}es{17sy5ty5qs}et{17sy5ty5ow5qs}eu{17sy5ty5ow5qs}ev{17sy5ty5ow5qs}6z{17sy5ty5ow5qs}fm{17sy5ty5ow5qs}fn{17sy5ty5ow5qs}fo{17sy5ty5ow5qs}fp{17sy5ty5qs}fq{17sy5ty5ow5qs}7r{5ow}fs{17sy5ty5ow5qs}ft{17sv5tv5ow}7m{5ow}fv{17sv5tv5ow}fw{17sv5tv5ow}}}"),"Helvetica-BoldOblique":l("{'widths'{k3s2q4scx1w201n3r201o6o201s1w201t1w201u1w201w3m201x3m201y3m2k1w2l2l202m2n2n3r2o3r2p5t202q6o2r1s2s2l2t2l2u2r2v3u2w1w2x2l2y1w2z1w3k3r3l3r3m3r3n3r3o3r3p3r3q3r3r3r3s3r203t2l203u2l3v2l3w3u3x3u3y3u3z3x4k6l4l4s4m4s4n4s4o4s4p4m4q3x4r4y4s4s4t1w4u3r4v4s4w3x4x5n4y4s4z4y5k4m5l4y5m4s5n4m5o3x5p4s5q4m5r5y5s4m5t4m5u3x5v2l5w1w5x2l5y3u5z3r6k2l6l3r6m3x6n3r6o3x6p3r6q2l6r3x6s3x6t1w6u1w6v3r6w1w6x5t6y3x6z3x7k3x7l3x7m2r7n3r7o2l7p3x7q3r7r4y7s3r7t3r7u3m7v2r7w1w7x2r7y3u202l3rcl4sal2lam3ran3rao3rap3rar3ras2lat4tau2pav3raw3uay4taz2lbk2sbl3u'fof'6obo2lbp3xbq3rbr1wbs2lbu2obv3rbz3xck4s202k3rcm4scn4sco4scp4scq6ocr4scs4mct4mcu4mcv4mcw1w2m2zcy1wcz1wdl4sdm4ydn4ydo4ydp4ydq4yds4ydt4sdu4sdv4sdw4sdz3xek3rel3rem3ren3reo3rep3req5ter3res3ret3reu3rev3rew1wex1wey1wez1wfl3xfm3xfn3xfo3xfp3xfq3xfr3ufs3xft3xfu3xfv3xfw3xfz3r203k6o212m6o2dw2l2cq2l3t3r3u2l17s4m19m3r}'kerning'{cl{4qs5ku5ot5qs17sv5tv}201t{2ww4wy2yw}201w{2ks}201x{2ww4wy2yw}2k{201ts201xs}2w{7qs4qu5kw5os5qw5rs17su5tu7tsfzs}2x{5ow5qs}2y{7qs4qu5kw5os5qw5rs17su5tu7tsfzs}'fof'-6o7p{17su5tu5ot}ck{4qs5ku5ot5qs17sv5tv}4l{4qs5ku5ot5qs17sv5tv}cm{4qs5ku5ot5qs17sv5tv}cn{4qs5ku5ot5qs17sv5tv}co{4qs5ku5ot5qs17sv5tv}cp{4qs5ku5ot5qs17sv5tv}6l{17st5tt5os}17s{2kwclvcmvcnvcovcpv4lv4wwckv}5o{2kucltcmtcntcotcpt4lt4wtckt}5q{2ksclscmscnscoscps4ls4wvcks}5r{2ks4ws}5t{2kwclvcmvcnvcovcpv4lv4wwckv}eo{17st5tt5os}fu{17su5tu5ot}6p{17ss5ts}ek{17st5tt5os}el{17st5tt5os}em{17st5tt5os}en{17st5tt5os}6o{201ts}ep{17st5tt5os}es{17ss5ts}et{17ss5ts}eu{17ss5ts}ev{17ss5ts}6z{17su5tu5os5qt}fm{17su5tu5os5qt}fn{17su5tu5os5qt}fo{17su5tu5os5qt}fp{17su5tu5os5qt}fq{17su5tu5os5qt}fs{17su5tu5os5qt}ft{17su5tu5ot}7m{5os}fv{17su5tu5ot}fw{17su5tu5ot}}}"),ZapfDingbats:l("{'widths'{k4u2k1w'fof'6o}'kerning'{'fof'-6o}}"),"Courier-Bold":l("{'widths'{k3w'fof'6o}'kerning'{'fof'-6o}}"),"Times-Italic":l("{'widths'{k3n2q4ycx2l201n3m201o5t201s2l201t2l201u2l201w3r201x3r201y3r2k1t2l2l202m2n2n3m2o3m2p5n202q5t2r1p2s2l2t2l2u3m2v4n2w1t2x2l2y1t2z1w3k3m3l3m3m3m3n3m3o3m3p3m3q3m3r3m3s3m203t2l203u2l3v2l3w4n3x4n3y4n3z3m4k5w4l3x4m3x4n4m4o4s4p3x4q3x4r4s4s4s4t2l4u2w4v4m4w3r4x5n4y4m4z4s5k3x5l4s5m3x5n3m5o3r5p4s5q3x5r5n5s3x5t3r5u3r5v2r5w1w5x2r5y2u5z3m6k2l6l3m6m3m6n2w6o3m6p2w6q1w6r3m6s3m6t1w6u1w6v2w6w1w6x4s6y3m6z3m7k3m7l3m7m2r7n2r7o1w7p3m7q2w7r4m7s2w7t2w7u2r7v2s7w1v7x2s7y3q202l3mcl3xal2ram3man3mao3map3mar3mas2lat4wau1vav3maw4nay4waz2lbk2sbl4n'fof'6obo2lbp3mbq3obr1tbs2lbu1zbv3mbz3mck3x202k3mcm3xcn3xco3xcp3xcq5tcr4mcs3xct3xcu3xcv3xcw2l2m2ucy2lcz2ldl4mdm4sdn4sdo4sdp4sdq4sds4sdt4sdu4sdv4sdw4sdz3mek3mel3mem3men3meo3mep3meq4mer2wes2wet2weu2wev2wew1wex1wey1wez1wfl3mfm3mfn3mfo3mfp3mfq3mfr4nfs3mft3mfu3mfv3mfw3mfz2w203k6o212m6m2dw2l2cq2l3t3m3u2l17s3r19m3m}'kerning'{cl{5kt4qw}201s{201sw}201t{201tw2wy2yy6q-t}201x{2wy2yy}2k{201tw}2w{7qs4qy7rs5ky7mw5os5qx5ru17su5tu}2x{17ss5ts5os}2y{7qs4qy7rs5ky7mw5os5qx5ru17su5tu}'fof'-6o6t{17ss5ts5qs}7t{5os}3v{5qs}7p{17su5tu5qs}ck{5kt4qw}4l{5kt4qw}cm{5kt4qw}cn{5kt4qw}co{5kt4qw}cp{5kt4qw}6l{4qs5ks5ou5qw5ru17su5tu}17s{2ks}5q{ckvclvcmvcnvcovcpv4lv}5r{ckuclucmucnucoucpu4lu}5t{2ks}6p{4qs5ks5ou5qw5ru17su5tu}ek{4qs5ks5ou5qw5ru17su5tu}el{4qs5ks5ou5qw5ru17su5tu}em{4qs5ks5ou5qw5ru17su5tu}en{4qs5ks5ou5qw5ru17su5tu}eo{4qs5ks5ou5qw5ru17su5tu}ep{4qs5ks5ou5qw5ru17su5tu}es{5ks5qs4qs}et{4qs5ks5ou5qw5ru17su5tu}eu{4qs5ks5qw5ru17su5tu}ev{5ks5qs4qs}ex{17ss5ts5qs}6z{4qv5ks5ou5qw5ru17su5tu}fm{4qv5ks5ou5qw5ru17su5tu}fn{4qv5ks5ou5qw5ru17su5tu}fo{4qv5ks5ou5qw5ru17su5tu}fp{4qv5ks5ou5qw5ru17su5tu}fq{4qv5ks5ou5qw5ru17su5tu}7r{5os}fs{4qv5ks5ou5qw5ru17su5tu}ft{17su5tu5qs}fu{17su5tu5qs}fv{17su5tu5qs}fw{17su5tu5qs}}}"),"Times-Roman":l("{'widths'{k3n2q4ycx2l201n3m201o6o201s2l201t2l201u2l201w2w201x2w201y2w2k1t2l2l202m2n2n3m2o3m2p5n202q6o2r1m2s2l2t2l2u3m2v3s2w1t2x2l2y1t2z1w3k3m3l3m3m3m3n3m3o3m3p3m3q3m3r3m3s3m203t2l203u2l3v1w3w3s3x3s3y3s3z2w4k5w4l4s4m4m4n4m4o4s4p3x4q3r4r4s4s4s4t2l4u2r4v4s4w3x4x5t4y4s4z4s5k3r5l4s5m4m5n3r5o3x5p4s5q4s5r5y5s4s5t4s5u3x5v2l5w1w5x2l5y2z5z3m6k2l6l2w6m3m6n2w6o3m6p2w6q2l6r3m6s3m6t1w6u1w6v3m6w1w6x4y6y3m6z3m7k3m7l3m7m2l7n2r7o1w7p3m7q3m7r4s7s3m7t3m7u2w7v3k7w1o7x3k7y3q202l3mcl4sal2lam3man3mao3map3mar3mas2lat4wau1vav3maw3say4waz2lbk2sbl3s'fof'6obo2lbp3mbq2xbr1tbs2lbu1zbv3mbz2wck4s202k3mcm4scn4sco4scp4scq5tcr4mcs3xct3xcu3xcv3xcw2l2m2tcy2lcz2ldl4sdm4sdn4sdo4sdp4sdq4sds4sdt4sdu4sdv4sdw4sdz3mek2wel2wem2wen2weo2wep2weq4mer2wes2wet2weu2wev2wew1wex1wey1wez1wfl3mfm3mfn3mfo3mfp3mfq3mfr3sfs3mft3mfu3mfv3mfw3mfz3m203k6o212m6m2dw2l2cq2l3t3m3u1w17s4s19m3m}'kerning'{cl{4qs5ku17sw5ou5qy5rw201ss5tw201ws}201s{201ss}201t{ckw4lwcmwcnwcowcpwclw4wu201ts}2k{201ts}2w{4qs5kw5os5qx5ru17sx5tx}2x{17sw5tw5ou5qu}2y{4qs5kw5os5qx5ru17sx5tx}'fof'-6o7t{ckuclucmucnucoucpu4lu5os5rs}3u{17su5tu5qs}3v{17su5tu5qs}7p{17sw5tw5qs}ck{4qs5ku17sw5ou5qy5rw201ss5tw201ws}4l{4qs5ku17sw5ou5qy5rw201ss5tw201ws}cm{4qs5ku17sw5ou5qy5rw201ss5tw201ws}cn{4qs5ku17sw5ou5qy5rw201ss5tw201ws}co{4qs5ku17sw5ou5qy5rw201ss5tw201ws}cp{4qs5ku17sw5ou5qy5rw201ss5tw201ws}6l{17su5tu5os5qw5rs}17s{2ktclvcmvcnvcovcpv4lv4wuckv}5o{ckwclwcmwcnwcowcpw4lw4wu}5q{ckyclycmycnycoycpy4ly4wu5ms}5r{cktcltcmtcntcotcpt4lt4ws}5t{2ktclvcmvcnvcovcpv4lv4wuckv}7q{cksclscmscnscoscps4ls}6p{17su5tu5qw5rs}ek{5qs5rs}el{17su5tu5os5qw5rs}em{17su5tu5os5qs5rs}en{17su5qs5rs}eo{5qs5rs}ep{17su5tu5os5qw5rs}es{5qs}et{17su5tu5qw5rs}eu{17su5tu5qs5rs}ev{5qs}6z{17sv5tv5os5qx5rs}fm{5os5qt5rs}fn{17sv5tv5os5qx5rs}fo{17sv5tv5os5qx5rs}fp{5os5qt5rs}fq{5os5qt5rs}7r{ckuclucmucnucoucpu4lu5os}fs{17sv5tv5os5qx5rs}ft{17ss5ts5qs}fu{17sw5tw5qs}fv{17sw5tw5qs}fw{17ss5ts5qs}fz{ckuclucmucnucoucpu4lu5os5rs}}}"),"Helvetica-Oblique":l("{'widths'{k3p2q4mcx1w201n3r201o6o201s1q201t1q201u1q201w2l201x2l201y2l2k1w2l1w202m2n2n3r2o3r2p5t202q6o2r1n2s2l2t2l2u2r2v3u2w1w2x2l2y1w2z1w3k3r3l3r3m3r3n3r3o3r3p3r3q3r3r3r3s3r203t2l203u2l3v1w3w3u3x3u3y3u3z3r4k6p4l4m4m4m4n4s4o4s4p4m4q3x4r4y4s4s4t1w4u3m4v4m4w3r4x5n4y4s4z4y5k4m5l4y5m4s5n4m5o3x5p4s5q4m5r5y5s4m5t4m5u3x5v1w5w1w5x1w5y2z5z3r6k2l6l3r6m3r6n3m6o3r6p3r6q1w6r3r6s3r6t1q6u1q6v3m6w1q6x5n6y3r6z3r7k3r7l3r7m2l7n3m7o1w7p3r7q3m7r4s7s3m7t3m7u3m7v2l7w1u7x2l7y3u202l3rcl4mal2lam3ran3rao3rap3rar3ras2lat4tau2pav3raw3uay4taz2lbk2sbl3u'fof'6obo2lbp3rbr1wbs2lbu2obv3rbz3xck4m202k3rcm4mcn4mco4mcp4mcq6ocr4scs4mct4mcu4mcv4mcw1w2m2ncy1wcz1wdl4sdm4ydn4ydo4ydp4ydq4yds4ydt4sdu4sdv4sdw4sdz3xek3rel3rem3ren3reo3rep3req5ter3mes3ret3reu3rev3rew1wex1wey1wez1wfl3rfm3rfn3rfo3rfp3rfq3rfr3ufs3xft3rfu3rfv3rfw3rfz3m203k6o212m6o2dw2l2cq2l3t3r3u1w17s4m19m3r}'kerning'{5q{4wv}cl{4qs5kw5ow5qs17sv5tv}201t{2wu4w1k2yu}201x{2wu4wy2yu}17s{2ktclucmucnu4otcpu4lu4wycoucku}2w{7qs4qz5k1m17sy5ow5qx5rsfsu5ty7tufzu}2x{17sy5ty5oy5qs}2y{7qs4qz5k1m17sy5ow5qx5rsfsu5ty7tufzu}'fof'-6o7p{17sv5tv5ow}ck{4qs5kw5ow5qs17sv5tv}4l{4qs5kw5ow5qs17sv5tv}cm{4qs5kw5ow5qs17sv5tv}cn{4qs5kw5ow5qs17sv5tv}co{4qs5kw5ow5qs17sv5tv}cp{4qs5kw5ow5qs17sv5tv}6l{17sy5ty5ow}do{17st5tt}4z{17st5tt}7s{fst}dm{17st5tt}dn{17st5tt}5o{ckwclwcmwcnwcowcpw4lw4wv}dp{17st5tt}dq{17st5tt}7t{5ow}ds{17st5tt}5t{2ktclucmucnu4otcpu4lu4wycoucku}fu{17sv5tv5ow}6p{17sy5ty5ow5qs}ek{17sy5ty5ow}el{17sy5ty5ow}em{17sy5ty5ow}en{5ty}eo{17sy5ty5ow}ep{17sy5ty5ow}es{17sy5ty5qs}et{17sy5ty5ow5qs}eu{17sy5ty5ow5qs}ev{17sy5ty5ow5qs}6z{17sy5ty5ow5qs}fm{17sy5ty5ow5qs}fn{17sy5ty5ow5qs}fo{17sy5ty5ow5qs}fp{17sy5ty5qs}fq{17sy5ty5ow5qs}7r{5ow}fs{17sy5ty5ow5qs}ft{17sv5tv5ow}7m{5ow}fv{17sv5tv5ow}fw{17sv5tv5ow}}}")}};e.events.push(["addFont",function(d){var f=d.font,p=u.Unicode[f.postScriptName];p&&(f.metadata.Unicode={},f.metadata.Unicode.widths=p.widths,f.metadata.Unicode.kerning=p.kerning);var h=c.Unicode[f.postScriptName];h&&(f.metadata.Unicode.encoding=h,f.encoding=h.codePages[0])}])})(la.API),(function(e){var t=function(n){for(var r=n.length,a=new Uint8Array(r),i=0;i<r;i++)a[i]=n.charCodeAt(i);return a};e.API.events.push(["addFont",function(n){var r=void 0,a=n.font,i=n.instance;if(!a.isStandardFont){if(i===void 0)throw new Error("Font does not exist in vFS, import fonts or remove declaration doc.addFont('"+a.postScriptName+"').");if(typeof(r=i.existsFileInVFS(a.postScriptName)===!1?i.loadFile(a.postScriptName):i.getFileFromVFS(a.postScriptName))!="string")throw new Error("Font is not stored as string-data in vFS, import fonts or remove declaration doc.addFont('"+a.postScriptName+"').");(function(o,l){l=/^\x00\x01\x00\x00/.test(l)?t(l):t(JS(l)),o.metadata=e.API.TTFFont.open(l),o.metadata.Unicode=o.metadata.Unicode||{encoding:{},kerning:{},widths:[]},o.metadata.glyIdsUsed=[0]})(a,r)}}])})(la),(function(e){function t(){return(ua.canvg?Promise.resolve(ua.canvg):Pi(()=>import("./index.es-CXonP4cP.js"),[])).catch((function(n){return Promise.reject(new Error("Could not load canvg: "+n))})).then((function(n){return n.default?n.default:n}))}la.API.addSvgAsImage=function(n,r,a,i,o,l,s,c){if(isNaN(r)||isNaN(a))throw Ro.error("jsPDF.addSvgAsImage: Invalid coordinates",arguments),new Error("Invalid coordinates passed to jsPDF.addSvgAsImage");if(isNaN(i)||isNaN(o))throw Ro.error("jsPDF.addSvgAsImage: Invalid measurements",arguments),new Error("Invalid measurements (width and/or height) passed to jsPDF.addSvgAsImage");var u=document.createElement("canvas");u.width=i,u.height=o;var d=u.getContext("2d");d.fillStyle="#fff",d.fillRect(0,0,u.width,u.height);var f={ignoreMouse:!0,ignoreAnimation:!0,ignoreDimensions:!0},p=this;return t().then((function(h){return h.fromString(d,n,f)}),(function(){return Promise.reject(new Error("Could not load canvg."))})).then((function(h){return h.render(f)})).then((function(){p.addImage(u.toDataURL("image/jpeg",1),r,a,i,o,s,c)}))}})(),la.API.putTotalPages=function(e){var t,n=0;parseInt(this.internal.getFont().id.substr(1),10)<15?(t=new RegExp(e,"g"),n=this.internal.getNumberOfPages()):(t=new RegExp(this.pdfEscape16(e,this.internal.getFont()),"g"),n=this.pdfEscape16(this.internal.getNumberOfPages()+"",this.internal.getFont()));for(var r=1;r<=this.internal.getNumberOfPages();r++)for(var a=0;a<this.internal.pages[r].length;a++)this.internal.pages[r][a]=this.internal.pages[r][a].replace(t,n);return this},la.API.viewerPreferences=function(e,t){var n;e=e||{},t=t||!1;var r,a,i,o={HideToolbar:{defaultValue:!1,value:!1,type:"boolean",explicitSet:!1,valueSet:[!0,!1],pdfVersion:1.3},HideMenubar:{defaultValue:!1,value:!1,type:"boolean",explicitSet:!1,valueSet:[!0,!1],pdfVersion:1.3},HideWindowUI:{defaultValue:!1,value:!1,type:"boolean",explicitSet:!1,valueSet:[!0,!1],pdfVersion:1.3},FitWindow:{defaultValue:!1,value:!1,type:"boolean",explicitSet:!1,valueSet:[!0,!1],pdfVersion:1.3},CenterWindow:{defaultValue:!1,value:!1,type:"boolean",explicitSet:!1,valueSet:[!0,!1],pdfVersion:1.3},DisplayDocTitle:{defaultValue:!1,value:!1,type:"boolean",explicitSet:!1,valueSet:[!0,!1],pdfVersion:1.4},NonFullScreenPageMode:{defaultValue:"UseNone",value:"UseNone",type:"name",explicitSet:!1,valueSet:["UseNone","UseOutlines","UseThumbs","UseOC"],pdfVersion:1.3},Direction:{defaultValue:"L2R",value:"L2R",type:"name",explicitSet:!1,valueSet:["L2R","R2L"],pdfVersion:1.3},ViewArea:{defaultValue:"CropBox",value:"CropBox",type:"name",explicitSet:!1,valueSet:["MediaBox","CropBox","TrimBox","BleedBox","ArtBox"],pdfVersion:1.4},ViewClip:{defaultValue:"CropBox",value:"CropBox",type:"name",explicitSet:!1,valueSet:["MediaBox","CropBox","TrimBox","BleedBox","ArtBox"],pdfVersion:1.4},PrintArea:{defaultValue:"CropBox",value:"CropBox",type:"name",explicitSet:!1,valueSet:["MediaBox","CropBox","TrimBox","BleedBox","ArtBox"],pdfVersion:1.4},PrintClip:{defaultValue:"CropBox",value:"CropBox",type:"name",explicitSet:!1,valueSet:["MediaBox","CropBox","TrimBox","BleedBox","ArtBox"],pdfVersion:1.4},PrintScaling:{defaultValue:"AppDefault",value:"AppDefault",type:"name",explicitSet:!1,valueSet:["AppDefault","None"],pdfVersion:1.6},Duplex:{defaultValue:"",value:"none",type:"name",explicitSet:!1,valueSet:["Simplex","DuplexFlipShortEdge","DuplexFlipLongEdge","none"],pdfVersion:1.7},PickTrayByPDFSize:{defaultValue:!1,value:!1,type:"boolean",explicitSet:!1,valueSet:[!0,!1],pdfVersion:1.7},PrintPageRange:{defaultValue:"",value:"",type:"array",explicitSet:!1,valueSet:null,pdfVersion:1.7},NumCopies:{defaultValue:1,value:1,type:"integer",explicitSet:!1,valueSet:null,pdfVersion:1.7}},l=Object.keys(o),s=[],c=0,u=0,d=0;function f(h,g){var m,A=!1;for(m=0;m<h.length;m+=1)h[m]===g&&(A=!0);return A}if(this.internal.viewerpreferences===void 0&&(this.internal.viewerpreferences={},this.internal.viewerpreferences.configuration=JSON.parse(JSON.stringify(o)),this.internal.viewerpreferences.isSubscribed=!1),n=this.internal.viewerpreferences.configuration,e==="reset"||t===!0){var p=l.length;for(d=0;d<p;d+=1)n[l[d]].value=n[l[d]].defaultValue,n[l[d]].explicitSet=!1}if(ii(e)==="object"){for(a in e)if(i=e[a],f(l,a)&&i!==void 0){if(n[a].type==="boolean"&&typeof i=="boolean")n[a].value=i;else if(n[a].type==="name"&&f(n[a].valueSet,i))n[a].value=i;else if(n[a].type==="integer"&&Number.isInteger(i))n[a].value=i;else if(n[a].type==="array"){for(c=0;c<i.length;c+=1)if(r=!0,i[c].length===1&&typeof i[c][0]=="number")s.push(String(i[c]-1));else if(i[c].length>1){for(u=0;u<i[c].length;u+=1)typeof i[c][u]!="number"&&(r=!1);r===!0&&s.push([i[c][0]-1,i[c][1]-1].join(" "))}n[a].value="["+s.join(" ")+"]"}else n[a].value=n[a].defaultValue;n[a].explicitSet=!0}}return this.internal.viewerpreferences.isSubscribed===!1&&(this.internal.events.subscribe("putCatalog",(function(){var h,g=[];for(h in n)n[h].explicitSet===!0&&(n[h].type==="name"?g.push("/"+h+" /"+n[h].value):g.push("/"+h+" "+n[h].value));g.length!==0&&this.internal.write(`/ViewerPreferences
2012
+ `&&(r=r.substr(1),y=1),f+p+(h=(a=XR.apply(this,[r,n])).reduce((function(_,x){return _+x}),0))>t||y){if(h>t){for(l=Vze.apply(this,[r,a,t-(f+p),t]),u.push(l.shift()),u=[l.pop()];l.length;)d.push([l.shift()]);h=a.slice(r.length-(u[0]?u[0].length:0)).reduce((function(_,x){return _+x}),0)}else u=[r];d.push(u),f=h+s,p=m}else u.push(r),f+=p+h,p=m}return c=s?function(_,x){return(x?A:"")+_.join(" ")}:function(_){return _.join(" ")},d.map(c)},rb.splitTextToSize=function(e,t,n){var r,a=(n=n||{}).fontSize||this.internal.getFontSize(),i=(function(u){if(u.widths&&u.kerning)return{widths:u.widths,kerning:u.kerning};var d=this.internal.getFont(u.fontName,u.fontStyle);return d.metadata.Unicode?{widths:d.metadata.Unicode.widths||{0:1},kerning:d.metadata.Unicode.kerning||{}}:{font:d.metadata,fontSize:this.internal.getFontSize(),charSpace:this.internal.getCharSpace()}}).call(this,n);r=Array.isArray(e)?e:String(e).split(/\r?\n/);var o=1*this.internal.scaleFactor*t/a;i.textIndent=n.textIndent?1*n.textIndent*this.internal.scaleFactor/a:0,i.lineIndent=n.lineIndent;var l,s,c=[];for(l=0,s=r.length;l<s;l++)c=c.concat(Wze.apply(this,[r[l],o,i]));return c},(function(e){e.__fontmetrics__=e.__fontmetrics__||{};for(var t="klmnopqrstuvwxyz",n={},r={},a=0;a<t.length;a++)n[t[a]]="0123456789abcdef"[a],r["0123456789abcdef"[a]]=t[a];var i=function(d){return"0x"+parseInt(d,10).toString(16)},o=e.__fontmetrics__.compress=function(d){var f,p,h,g,m=["{"];for(var A in d){if(f=d[A],isNaN(parseInt(A,10))?p="'"+A+"'":(A=parseInt(A,10),p=(p=i(A).slice(2)).slice(0,-1)+r[p.slice(-1)]),typeof f=="number")f<0?(h=i(f).slice(3),g="-"):(h=i(f).slice(2),g=""),h=g+h.slice(0,-1)+r[h.slice(-1)];else{if(ii(f)!=="object")throw new Error("Don't know what to do with value type "+ii(f)+".");h=o(f)}m.push(p+h)}return m.push("}"),m.join("")},l=e.__fontmetrics__.uncompress=function(d){if(typeof d!="string")throw new Error("Invalid argument passed to uncompress.");for(var f,p,h,g,m={},A=1,v=m,y=[],_="",x="",S=d.length-1,E=1;E<S;E+=1)(g=d[E])=="'"?f?(h=f.join(""),f=void 0):f=[]:f?f.push(g):g=="{"?(y.push([v,h]),v={},h=void 0):g=="}"?((p=y.pop())[0][p[1]]=v,h=void 0,v=p[0]):g=="-"?A=-1:h===void 0?n.hasOwnProperty(g)?(_+=n[g],h=parseInt(_,16)*A,A=1,_=""):_+=g:n.hasOwnProperty(g)?(x+=n[g],v[h]=parseInt(x,16)*A,A=1,h=void 0,x=""):x+=g;return m},s={codePages:["WinAnsiEncoding"],WinAnsiEncoding:l("{19m8n201n9q201o9r201s9l201t9m201u8m201w9n201x9o201y8o202k8q202l8r202m9p202q8p20aw8k203k8t203t8v203u9v2cq8s212m9t15m8w15n9w2dw9s16k8u16l9u17s9z17x8y17y9y}")},c={Unicode:{Courier:s,"Courier-Bold":s,"Courier-BoldOblique":s,"Courier-Oblique":s,Helvetica:s,"Helvetica-Bold":s,"Helvetica-BoldOblique":s,"Helvetica-Oblique":s,"Times-Roman":s,"Times-Bold":s,"Times-BoldItalic":s,"Times-Italic":s}},u={Unicode:{"Courier-Oblique":l("{'widths'{k3w'fof'6o}'kerning'{'fof'-6o}}"),"Times-BoldItalic":l("{'widths'{k3o2q4ycx2r201n3m201o6o201s2l201t2l201u2l201w3m201x3m201y3m2k1t2l2r202m2n2n3m2o3m2p5n202q6o2r1w2s2l2t2l2u3m2v3t2w1t2x2l2y1t2z1w3k3m3l3m3m3m3n3m3o3m3p3m3q3m3r3m3s3m203t2l203u2l3v2l3w3t3x3t3y3t3z3m4k5n4l4m4m4m4n4m4o4s4p4m4q4m4r4s4s4y4t2r4u3m4v4m4w3x4x5t4y4s4z4s5k3x5l4s5m4m5n3r5o3x5p4s5q4m5r5t5s4m5t3x5u3x5v2l5w1w5x2l5y3t5z3m6k2l6l3m6m3m6n2w6o3m6p2w6q2l6r3m6s3r6t1w6u1w6v3m6w1w6x4y6y3r6z3m7k3m7l3m7m2r7n2r7o1w7p3r7q2w7r4m7s3m7t2w7u2r7v2n7w1q7x2n7y3t202l3mcl4mal2ram3man3mao3map3mar3mas2lat4uau1uav3maw3way4uaz2lbk2sbl3t'fof'6obo2lbp3tbq3mbr1tbs2lbu1ybv3mbz3mck4m202k3mcm4mcn4mco4mcp4mcq5ycr4mcs4mct4mcu4mcv4mcw2r2m3rcy2rcz2rdl4sdm4sdn4sdo4sdp4sdq4sds4sdt4sdu4sdv4sdw4sdz3mek3mel3mem3men3meo3mep3meq4ser2wes2wet2weu2wev2wew1wex1wey1wez1wfl3rfm3mfn3mfo3mfp3mfq3mfr3tfs3mft3rfu3rfv3rfw3rfz2w203k6o212m6o2dw2l2cq2l3t3m3u2l17s3x19m3m}'kerning'{cl{4qu5kt5qt5rs17ss5ts}201s{201ss}201t{cks4lscmscnscoscpscls2wu2yu201ts}201x{2wu2yu}2k{201ts}2w{4qx5kx5ou5qx5rs17su5tu}2x{17su5tu5ou}2y{4qx5kx5ou5qx5rs17ss5ts}'fof'-6ofn{17sw5tw5ou5qw5rs}7t{cksclscmscnscoscps4ls}3u{17su5tu5os5qs}3v{17su5tu5os5qs}7p{17su5tu}ck{4qu5kt5qt5rs17ss5ts}4l{4qu5kt5qt5rs17ss5ts}cm{4qu5kt5qt5rs17ss5ts}cn{4qu5kt5qt5rs17ss5ts}co{4qu5kt5qt5rs17ss5ts}cp{4qu5kt5qt5rs17ss5ts}6l{4qu5ou5qw5rt17su5tu}5q{ckuclucmucnucoucpu4lu}5r{ckuclucmucnucoucpu4lu}7q{cksclscmscnscoscps4ls}6p{4qu5ou5qw5rt17sw5tw}ek{4qu5ou5qw5rt17su5tu}el{4qu5ou5qw5rt17su5tu}em{4qu5ou5qw5rt17su5tu}en{4qu5ou5qw5rt17su5tu}eo{4qu5ou5qw5rt17su5tu}ep{4qu5ou5qw5rt17su5tu}es{17ss5ts5qs4qu}et{4qu5ou5qw5rt17sw5tw}eu{4qu5ou5qw5rt17ss5ts}ev{17ss5ts5qs4qu}6z{17sw5tw5ou5qw5rs}fm{17sw5tw5ou5qw5rs}7n{201ts}fo{17sw5tw5ou5qw5rs}fp{17sw5tw5ou5qw5rs}fq{17sw5tw5ou5qw5rs}7r{cksclscmscnscoscps4ls}fs{17sw5tw5ou5qw5rs}ft{17su5tu}fu{17su5tu}fv{17su5tu}fw{17su5tu}fz{cksclscmscnscoscps4ls}}}"),"Helvetica-Bold":l("{'widths'{k3s2q4scx1w201n3r201o6o201s1w201t1w201u1w201w3m201x3m201y3m2k1w2l2l202m2n2n3r2o3r2p5t202q6o2r1s2s2l2t2l2u2r2v3u2w1w2x2l2y1w2z1w3k3r3l3r3m3r3n3r3o3r3p3r3q3r3r3r3s3r203t2l203u2l3v2l3w3u3x3u3y3u3z3x4k6l4l4s4m4s4n4s4o4s4p4m4q3x4r4y4s4s4t1w4u3r4v4s4w3x4x5n4y4s4z4y5k4m5l4y5m4s5n4m5o3x5p4s5q4m5r5y5s4m5t4m5u3x5v2l5w1w5x2l5y3u5z3r6k2l6l3r6m3x6n3r6o3x6p3r6q2l6r3x6s3x6t1w6u1w6v3r6w1w6x5t6y3x6z3x7k3x7l3x7m2r7n3r7o2l7p3x7q3r7r4y7s3r7t3r7u3m7v2r7w1w7x2r7y3u202l3rcl4sal2lam3ran3rao3rap3rar3ras2lat4tau2pav3raw3uay4taz2lbk2sbl3u'fof'6obo2lbp3xbq3rbr1wbs2lbu2obv3rbz3xck4s202k3rcm4scn4sco4scp4scq6ocr4scs4mct4mcu4mcv4mcw1w2m2zcy1wcz1wdl4sdm4ydn4ydo4ydp4ydq4yds4ydt4sdu4sdv4sdw4sdz3xek3rel3rem3ren3reo3rep3req5ter3res3ret3reu3rev3rew1wex1wey1wez1wfl3xfm3xfn3xfo3xfp3xfq3xfr3ufs3xft3xfu3xfv3xfw3xfz3r203k6o212m6o2dw2l2cq2l3t3r3u2l17s4m19m3r}'kerning'{cl{4qs5ku5ot5qs17sv5tv}201t{2ww4wy2yw}201w{2ks}201x{2ww4wy2yw}2k{201ts201xs}2w{7qs4qu5kw5os5qw5rs17su5tu7tsfzs}2x{5ow5qs}2y{7qs4qu5kw5os5qw5rs17su5tu7tsfzs}'fof'-6o7p{17su5tu5ot}ck{4qs5ku5ot5qs17sv5tv}4l{4qs5ku5ot5qs17sv5tv}cm{4qs5ku5ot5qs17sv5tv}cn{4qs5ku5ot5qs17sv5tv}co{4qs5ku5ot5qs17sv5tv}cp{4qs5ku5ot5qs17sv5tv}6l{17st5tt5os}17s{2kwclvcmvcnvcovcpv4lv4wwckv}5o{2kucltcmtcntcotcpt4lt4wtckt}5q{2ksclscmscnscoscps4ls4wvcks}5r{2ks4ws}5t{2kwclvcmvcnvcovcpv4lv4wwckv}eo{17st5tt5os}fu{17su5tu5ot}6p{17ss5ts}ek{17st5tt5os}el{17st5tt5os}em{17st5tt5os}en{17st5tt5os}6o{201ts}ep{17st5tt5os}es{17ss5ts}et{17ss5ts}eu{17ss5ts}ev{17ss5ts}6z{17su5tu5os5qt}fm{17su5tu5os5qt}fn{17su5tu5os5qt}fo{17su5tu5os5qt}fp{17su5tu5os5qt}fq{17su5tu5os5qt}fs{17su5tu5os5qt}ft{17su5tu5ot}7m{5os}fv{17su5tu5ot}fw{17su5tu5ot}}}"),Courier:l("{'widths'{k3w'fof'6o}'kerning'{'fof'-6o}}"),"Courier-BoldOblique":l("{'widths'{k3w'fof'6o}'kerning'{'fof'-6o}}"),"Times-Bold":l("{'widths'{k3q2q5ncx2r201n3m201o6o201s2l201t2l201u2l201w3m201x3m201y3m2k1t2l2l202m2n2n3m2o3m2p6o202q6o2r1w2s2l2t2l2u3m2v3t2w1t2x2l2y1t2z1w3k3m3l3m3m3m3n3m3o3m3p3m3q3m3r3m3s3m203t2l203u2l3v2l3w3t3x3t3y3t3z3m4k5x4l4s4m4m4n4s4o4s4p4m4q3x4r4y4s4y4t2r4u3m4v4y4w4m4x5y4y4s4z4y5k3x5l4y5m4s5n3r5o4m5p4s5q4s5r6o5s4s5t4s5u4m5v2l5w1w5x2l5y3u5z3m6k2l6l3m6m3r6n2w6o3r6p2w6q2l6r3m6s3r6t1w6u2l6v3r6w1w6x5n6y3r6z3m7k3r7l3r7m2w7n2r7o2l7p3r7q3m7r4s7s3m7t3m7u2w7v2r7w1q7x2r7y3o202l3mcl4sal2lam3man3mao3map3mar3mas2lat4uau1yav3maw3tay4uaz2lbk2sbl3t'fof'6obo2lbp3rbr1tbs2lbu2lbv3mbz3mck4s202k3mcm4scn4sco4scp4scq6ocr4scs4mct4mcu4mcv4mcw2r2m3rcy2rcz2rdl4sdm4ydn4ydo4ydp4ydq4yds4ydt4sdu4sdv4sdw4sdz3rek3mel3mem3men3meo3mep3meq4ser2wes2wet2weu2wev2wew1wex1wey1wez1wfl3rfm3mfn3mfo3mfp3mfq3mfr3tfs3mft3rfu3rfv3rfw3rfz3m203k6o212m6o2dw2l2cq2l3t3m3u2l17s4s19m3m}'kerning'{cl{4qt5ks5ot5qy5rw17sv5tv}201t{cks4lscmscnscoscpscls4wv}2k{201ts}2w{4qu5ku7mu5os5qx5ru17su5tu}2x{17su5tu5ou5qs}2y{4qv5kv7mu5ot5qz5ru17su5tu}'fof'-6o7t{cksclscmscnscoscps4ls}3u{17su5tu5os5qu}3v{17su5tu5os5qu}fu{17su5tu5ou5qu}7p{17su5tu5ou5qu}ck{4qt5ks5ot5qy5rw17sv5tv}4l{4qt5ks5ot5qy5rw17sv5tv}cm{4qt5ks5ot5qy5rw17sv5tv}cn{4qt5ks5ot5qy5rw17sv5tv}co{4qt5ks5ot5qy5rw17sv5tv}cp{4qt5ks5ot5qy5rw17sv5tv}6l{17st5tt5ou5qu}17s{ckuclucmucnucoucpu4lu4wu}5o{ckuclucmucnucoucpu4lu4wu}5q{ckzclzcmzcnzcozcpz4lz4wu}5r{ckxclxcmxcnxcoxcpx4lx4wu}5t{ckuclucmucnucoucpu4lu4wu}7q{ckuclucmucnucoucpu4lu}6p{17sw5tw5ou5qu}ek{17st5tt5qu}el{17st5tt5ou5qu}em{17st5tt5qu}en{17st5tt5qu}eo{17st5tt5qu}ep{17st5tt5ou5qu}es{17ss5ts5qu}et{17sw5tw5ou5qu}eu{17sw5tw5ou5qu}ev{17ss5ts5qu}6z{17sw5tw5ou5qu5rs}fm{17sw5tw5ou5qu5rs}fn{17sw5tw5ou5qu5rs}fo{17sw5tw5ou5qu5rs}fp{17sw5tw5ou5qu5rs}fq{17sw5tw5ou5qu5rs}7r{cktcltcmtcntcotcpt4lt5os}fs{17sw5tw5ou5qu5rs}ft{17su5tu5ou5qu}7m{5os}fv{17su5tu5ou5qu}fw{17su5tu5ou5qu}fz{cksclscmscnscoscps4ls}}}"),Symbol:l("{'widths'{k3uaw4r19m3m2k1t2l2l202m2y2n3m2p5n202q6o3k3m2s2l2t2l2v3r2w1t3m3m2y1t2z1wbk2sbl3r'fof'6o3n3m3o3m3p3m3q3m3r3m3s3m3t3m3u1w3v1w3w3r3x3r3y3r3z2wbp3t3l3m5v2l5x2l5z3m2q4yfr3r7v3k7w1o7x3k}'kerning'{'fof'-6o}}"),Helvetica:l("{'widths'{k3p2q4mcx1w201n3r201o6o201s1q201t1q201u1q201w2l201x2l201y2l2k1w2l1w202m2n2n3r2o3r2p5t202q6o2r1n2s2l2t2l2u2r2v3u2w1w2x2l2y1w2z1w3k3r3l3r3m3r3n3r3o3r3p3r3q3r3r3r3s3r203t2l203u2l3v1w3w3u3x3u3y3u3z3r4k6p4l4m4m4m4n4s4o4s4p4m4q3x4r4y4s4s4t1w4u3m4v4m4w3r4x5n4y4s4z4y5k4m5l4y5m4s5n4m5o3x5p4s5q4m5r5y5s4m5t4m5u3x5v1w5w1w5x1w5y2z5z3r6k2l6l3r6m3r6n3m6o3r6p3r6q1w6r3r6s3r6t1q6u1q6v3m6w1q6x5n6y3r6z3r7k3r7l3r7m2l7n3m7o1w7p3r7q3m7r4s7s3m7t3m7u3m7v2l7w1u7x2l7y3u202l3rcl4mal2lam3ran3rao3rap3rar3ras2lat4tau2pav3raw3uay4taz2lbk2sbl3u'fof'6obo2lbp3rbr1wbs2lbu2obv3rbz3xck4m202k3rcm4mcn4mco4mcp4mcq6ocr4scs4mct4mcu4mcv4mcw1w2m2ncy1wcz1wdl4sdm4ydn4ydo4ydp4ydq4yds4ydt4sdu4sdv4sdw4sdz3xek3rel3rem3ren3reo3rep3req5ter3mes3ret3reu3rev3rew1wex1wey1wez1wfl3rfm3rfn3rfo3rfp3rfq3rfr3ufs3xft3rfu3rfv3rfw3rfz3m203k6o212m6o2dw2l2cq2l3t3r3u1w17s4m19m3r}'kerning'{5q{4wv}cl{4qs5kw5ow5qs17sv5tv}201t{2wu4w1k2yu}201x{2wu4wy2yu}17s{2ktclucmucnu4otcpu4lu4wycoucku}2w{7qs4qz5k1m17sy5ow5qx5rsfsu5ty7tufzu}2x{17sy5ty5oy5qs}2y{7qs4qz5k1m17sy5ow5qx5rsfsu5ty7tufzu}'fof'-6o7p{17sv5tv5ow}ck{4qs5kw5ow5qs17sv5tv}4l{4qs5kw5ow5qs17sv5tv}cm{4qs5kw5ow5qs17sv5tv}cn{4qs5kw5ow5qs17sv5tv}co{4qs5kw5ow5qs17sv5tv}cp{4qs5kw5ow5qs17sv5tv}6l{17sy5ty5ow}do{17st5tt}4z{17st5tt}7s{fst}dm{17st5tt}dn{17st5tt}5o{ckwclwcmwcnwcowcpw4lw4wv}dp{17st5tt}dq{17st5tt}7t{5ow}ds{17st5tt}5t{2ktclucmucnu4otcpu4lu4wycoucku}fu{17sv5tv5ow}6p{17sy5ty5ow5qs}ek{17sy5ty5ow}el{17sy5ty5ow}em{17sy5ty5ow}en{5ty}eo{17sy5ty5ow}ep{17sy5ty5ow}es{17sy5ty5qs}et{17sy5ty5ow5qs}eu{17sy5ty5ow5qs}ev{17sy5ty5ow5qs}6z{17sy5ty5ow5qs}fm{17sy5ty5ow5qs}fn{17sy5ty5ow5qs}fo{17sy5ty5ow5qs}fp{17sy5ty5qs}fq{17sy5ty5ow5qs}7r{5ow}fs{17sy5ty5ow5qs}ft{17sv5tv5ow}7m{5ow}fv{17sv5tv5ow}fw{17sv5tv5ow}}}"),"Helvetica-BoldOblique":l("{'widths'{k3s2q4scx1w201n3r201o6o201s1w201t1w201u1w201w3m201x3m201y3m2k1w2l2l202m2n2n3r2o3r2p5t202q6o2r1s2s2l2t2l2u2r2v3u2w1w2x2l2y1w2z1w3k3r3l3r3m3r3n3r3o3r3p3r3q3r3r3r3s3r203t2l203u2l3v2l3w3u3x3u3y3u3z3x4k6l4l4s4m4s4n4s4o4s4p4m4q3x4r4y4s4s4t1w4u3r4v4s4w3x4x5n4y4s4z4y5k4m5l4y5m4s5n4m5o3x5p4s5q4m5r5y5s4m5t4m5u3x5v2l5w1w5x2l5y3u5z3r6k2l6l3r6m3x6n3r6o3x6p3r6q2l6r3x6s3x6t1w6u1w6v3r6w1w6x5t6y3x6z3x7k3x7l3x7m2r7n3r7o2l7p3x7q3r7r4y7s3r7t3r7u3m7v2r7w1w7x2r7y3u202l3rcl4sal2lam3ran3rao3rap3rar3ras2lat4tau2pav3raw3uay4taz2lbk2sbl3u'fof'6obo2lbp3xbq3rbr1wbs2lbu2obv3rbz3xck4s202k3rcm4scn4sco4scp4scq6ocr4scs4mct4mcu4mcv4mcw1w2m2zcy1wcz1wdl4sdm4ydn4ydo4ydp4ydq4yds4ydt4sdu4sdv4sdw4sdz3xek3rel3rem3ren3reo3rep3req5ter3res3ret3reu3rev3rew1wex1wey1wez1wfl3xfm3xfn3xfo3xfp3xfq3xfr3ufs3xft3xfu3xfv3xfw3xfz3r203k6o212m6o2dw2l2cq2l3t3r3u2l17s4m19m3r}'kerning'{cl{4qs5ku5ot5qs17sv5tv}201t{2ww4wy2yw}201w{2ks}201x{2ww4wy2yw}2k{201ts201xs}2w{7qs4qu5kw5os5qw5rs17su5tu7tsfzs}2x{5ow5qs}2y{7qs4qu5kw5os5qw5rs17su5tu7tsfzs}'fof'-6o7p{17su5tu5ot}ck{4qs5ku5ot5qs17sv5tv}4l{4qs5ku5ot5qs17sv5tv}cm{4qs5ku5ot5qs17sv5tv}cn{4qs5ku5ot5qs17sv5tv}co{4qs5ku5ot5qs17sv5tv}cp{4qs5ku5ot5qs17sv5tv}6l{17st5tt5os}17s{2kwclvcmvcnvcovcpv4lv4wwckv}5o{2kucltcmtcntcotcpt4lt4wtckt}5q{2ksclscmscnscoscps4ls4wvcks}5r{2ks4ws}5t{2kwclvcmvcnvcovcpv4lv4wwckv}eo{17st5tt5os}fu{17su5tu5ot}6p{17ss5ts}ek{17st5tt5os}el{17st5tt5os}em{17st5tt5os}en{17st5tt5os}6o{201ts}ep{17st5tt5os}es{17ss5ts}et{17ss5ts}eu{17ss5ts}ev{17ss5ts}6z{17su5tu5os5qt}fm{17su5tu5os5qt}fn{17su5tu5os5qt}fo{17su5tu5os5qt}fp{17su5tu5os5qt}fq{17su5tu5os5qt}fs{17su5tu5os5qt}ft{17su5tu5ot}7m{5os}fv{17su5tu5ot}fw{17su5tu5ot}}}"),ZapfDingbats:l("{'widths'{k4u2k1w'fof'6o}'kerning'{'fof'-6o}}"),"Courier-Bold":l("{'widths'{k3w'fof'6o}'kerning'{'fof'-6o}}"),"Times-Italic":l("{'widths'{k3n2q4ycx2l201n3m201o5t201s2l201t2l201u2l201w3r201x3r201y3r2k1t2l2l202m2n2n3m2o3m2p5n202q5t2r1p2s2l2t2l2u3m2v4n2w1t2x2l2y1t2z1w3k3m3l3m3m3m3n3m3o3m3p3m3q3m3r3m3s3m203t2l203u2l3v2l3w4n3x4n3y4n3z3m4k5w4l3x4m3x4n4m4o4s4p3x4q3x4r4s4s4s4t2l4u2w4v4m4w3r4x5n4y4m4z4s5k3x5l4s5m3x5n3m5o3r5p4s5q3x5r5n5s3x5t3r5u3r5v2r5w1w5x2r5y2u5z3m6k2l6l3m6m3m6n2w6o3m6p2w6q1w6r3m6s3m6t1w6u1w6v2w6w1w6x4s6y3m6z3m7k3m7l3m7m2r7n2r7o1w7p3m7q2w7r4m7s2w7t2w7u2r7v2s7w1v7x2s7y3q202l3mcl3xal2ram3man3mao3map3mar3mas2lat4wau1vav3maw4nay4waz2lbk2sbl4n'fof'6obo2lbp3mbq3obr1tbs2lbu1zbv3mbz3mck3x202k3mcm3xcn3xco3xcp3xcq5tcr4mcs3xct3xcu3xcv3xcw2l2m2ucy2lcz2ldl4mdm4sdn4sdo4sdp4sdq4sds4sdt4sdu4sdv4sdw4sdz3mek3mel3mem3men3meo3mep3meq4mer2wes2wet2weu2wev2wew1wex1wey1wez1wfl3mfm3mfn3mfo3mfp3mfq3mfr4nfs3mft3mfu3mfv3mfw3mfz2w203k6o212m6m2dw2l2cq2l3t3m3u2l17s3r19m3m}'kerning'{cl{5kt4qw}201s{201sw}201t{201tw2wy2yy6q-t}201x{2wy2yy}2k{201tw}2w{7qs4qy7rs5ky7mw5os5qx5ru17su5tu}2x{17ss5ts5os}2y{7qs4qy7rs5ky7mw5os5qx5ru17su5tu}'fof'-6o6t{17ss5ts5qs}7t{5os}3v{5qs}7p{17su5tu5qs}ck{5kt4qw}4l{5kt4qw}cm{5kt4qw}cn{5kt4qw}co{5kt4qw}cp{5kt4qw}6l{4qs5ks5ou5qw5ru17su5tu}17s{2ks}5q{ckvclvcmvcnvcovcpv4lv}5r{ckuclucmucnucoucpu4lu}5t{2ks}6p{4qs5ks5ou5qw5ru17su5tu}ek{4qs5ks5ou5qw5ru17su5tu}el{4qs5ks5ou5qw5ru17su5tu}em{4qs5ks5ou5qw5ru17su5tu}en{4qs5ks5ou5qw5ru17su5tu}eo{4qs5ks5ou5qw5ru17su5tu}ep{4qs5ks5ou5qw5ru17su5tu}es{5ks5qs4qs}et{4qs5ks5ou5qw5ru17su5tu}eu{4qs5ks5qw5ru17su5tu}ev{5ks5qs4qs}ex{17ss5ts5qs}6z{4qv5ks5ou5qw5ru17su5tu}fm{4qv5ks5ou5qw5ru17su5tu}fn{4qv5ks5ou5qw5ru17su5tu}fo{4qv5ks5ou5qw5ru17su5tu}fp{4qv5ks5ou5qw5ru17su5tu}fq{4qv5ks5ou5qw5ru17su5tu}7r{5os}fs{4qv5ks5ou5qw5ru17su5tu}ft{17su5tu5qs}fu{17su5tu5qs}fv{17su5tu5qs}fw{17su5tu5qs}}}"),"Times-Roman":l("{'widths'{k3n2q4ycx2l201n3m201o6o201s2l201t2l201u2l201w2w201x2w201y2w2k1t2l2l202m2n2n3m2o3m2p5n202q6o2r1m2s2l2t2l2u3m2v3s2w1t2x2l2y1t2z1w3k3m3l3m3m3m3n3m3o3m3p3m3q3m3r3m3s3m203t2l203u2l3v1w3w3s3x3s3y3s3z2w4k5w4l4s4m4m4n4m4o4s4p3x4q3r4r4s4s4s4t2l4u2r4v4s4w3x4x5t4y4s4z4s5k3r5l4s5m4m5n3r5o3x5p4s5q4s5r5y5s4s5t4s5u3x5v2l5w1w5x2l5y2z5z3m6k2l6l2w6m3m6n2w6o3m6p2w6q2l6r3m6s3m6t1w6u1w6v3m6w1w6x4y6y3m6z3m7k3m7l3m7m2l7n2r7o1w7p3m7q3m7r4s7s3m7t3m7u2w7v3k7w1o7x3k7y3q202l3mcl4sal2lam3man3mao3map3mar3mas2lat4wau1vav3maw3say4waz2lbk2sbl3s'fof'6obo2lbp3mbq2xbr1tbs2lbu1zbv3mbz2wck4s202k3mcm4scn4sco4scp4scq5tcr4mcs3xct3xcu3xcv3xcw2l2m2tcy2lcz2ldl4sdm4sdn4sdo4sdp4sdq4sds4sdt4sdu4sdv4sdw4sdz3mek2wel2wem2wen2weo2wep2weq4mer2wes2wet2weu2wev2wew1wex1wey1wez1wfl3mfm3mfn3mfo3mfp3mfq3mfr3sfs3mft3mfu3mfv3mfw3mfz3m203k6o212m6m2dw2l2cq2l3t3m3u1w17s4s19m3m}'kerning'{cl{4qs5ku17sw5ou5qy5rw201ss5tw201ws}201s{201ss}201t{ckw4lwcmwcnwcowcpwclw4wu201ts}2k{201ts}2w{4qs5kw5os5qx5ru17sx5tx}2x{17sw5tw5ou5qu}2y{4qs5kw5os5qx5ru17sx5tx}'fof'-6o7t{ckuclucmucnucoucpu4lu5os5rs}3u{17su5tu5qs}3v{17su5tu5qs}7p{17sw5tw5qs}ck{4qs5ku17sw5ou5qy5rw201ss5tw201ws}4l{4qs5ku17sw5ou5qy5rw201ss5tw201ws}cm{4qs5ku17sw5ou5qy5rw201ss5tw201ws}cn{4qs5ku17sw5ou5qy5rw201ss5tw201ws}co{4qs5ku17sw5ou5qy5rw201ss5tw201ws}cp{4qs5ku17sw5ou5qy5rw201ss5tw201ws}6l{17su5tu5os5qw5rs}17s{2ktclvcmvcnvcovcpv4lv4wuckv}5o{ckwclwcmwcnwcowcpw4lw4wu}5q{ckyclycmycnycoycpy4ly4wu5ms}5r{cktcltcmtcntcotcpt4lt4ws}5t{2ktclvcmvcnvcovcpv4lv4wuckv}7q{cksclscmscnscoscps4ls}6p{17su5tu5qw5rs}ek{5qs5rs}el{17su5tu5os5qw5rs}em{17su5tu5os5qs5rs}en{17su5qs5rs}eo{5qs5rs}ep{17su5tu5os5qw5rs}es{5qs}et{17su5tu5qw5rs}eu{17su5tu5qs5rs}ev{5qs}6z{17sv5tv5os5qx5rs}fm{5os5qt5rs}fn{17sv5tv5os5qx5rs}fo{17sv5tv5os5qx5rs}fp{5os5qt5rs}fq{5os5qt5rs}7r{ckuclucmucnucoucpu4lu5os}fs{17sv5tv5os5qx5rs}ft{17ss5ts5qs}fu{17sw5tw5qs}fv{17sw5tw5qs}fw{17ss5ts5qs}fz{ckuclucmucnucoucpu4lu5os5rs}}}"),"Helvetica-Oblique":l("{'widths'{k3p2q4mcx1w201n3r201o6o201s1q201t1q201u1q201w2l201x2l201y2l2k1w2l1w202m2n2n3r2o3r2p5t202q6o2r1n2s2l2t2l2u2r2v3u2w1w2x2l2y1w2z1w3k3r3l3r3m3r3n3r3o3r3p3r3q3r3r3r3s3r203t2l203u2l3v1w3w3u3x3u3y3u3z3r4k6p4l4m4m4m4n4s4o4s4p4m4q3x4r4y4s4s4t1w4u3m4v4m4w3r4x5n4y4s4z4y5k4m5l4y5m4s5n4m5o3x5p4s5q4m5r5y5s4m5t4m5u3x5v1w5w1w5x1w5y2z5z3r6k2l6l3r6m3r6n3m6o3r6p3r6q1w6r3r6s3r6t1q6u1q6v3m6w1q6x5n6y3r6z3r7k3r7l3r7m2l7n3m7o1w7p3r7q3m7r4s7s3m7t3m7u3m7v2l7w1u7x2l7y3u202l3rcl4mal2lam3ran3rao3rap3rar3ras2lat4tau2pav3raw3uay4taz2lbk2sbl3u'fof'6obo2lbp3rbr1wbs2lbu2obv3rbz3xck4m202k3rcm4mcn4mco4mcp4mcq6ocr4scs4mct4mcu4mcv4mcw1w2m2ncy1wcz1wdl4sdm4ydn4ydo4ydp4ydq4yds4ydt4sdu4sdv4sdw4sdz3xek3rel3rem3ren3reo3rep3req5ter3mes3ret3reu3rev3rew1wex1wey1wez1wfl3rfm3rfn3rfo3rfp3rfq3rfr3ufs3xft3rfu3rfv3rfw3rfz3m203k6o212m6o2dw2l2cq2l3t3r3u1w17s4m19m3r}'kerning'{5q{4wv}cl{4qs5kw5ow5qs17sv5tv}201t{2wu4w1k2yu}201x{2wu4wy2yu}17s{2ktclucmucnu4otcpu4lu4wycoucku}2w{7qs4qz5k1m17sy5ow5qx5rsfsu5ty7tufzu}2x{17sy5ty5oy5qs}2y{7qs4qz5k1m17sy5ow5qx5rsfsu5ty7tufzu}'fof'-6o7p{17sv5tv5ow}ck{4qs5kw5ow5qs17sv5tv}4l{4qs5kw5ow5qs17sv5tv}cm{4qs5kw5ow5qs17sv5tv}cn{4qs5kw5ow5qs17sv5tv}co{4qs5kw5ow5qs17sv5tv}cp{4qs5kw5ow5qs17sv5tv}6l{17sy5ty5ow}do{17st5tt}4z{17st5tt}7s{fst}dm{17st5tt}dn{17st5tt}5o{ckwclwcmwcnwcowcpw4lw4wv}dp{17st5tt}dq{17st5tt}7t{5ow}ds{17st5tt}5t{2ktclucmucnu4otcpu4lu4wycoucku}fu{17sv5tv5ow}6p{17sy5ty5ow5qs}ek{17sy5ty5ow}el{17sy5ty5ow}em{17sy5ty5ow}en{5ty}eo{17sy5ty5ow}ep{17sy5ty5ow}es{17sy5ty5qs}et{17sy5ty5ow5qs}eu{17sy5ty5ow5qs}ev{17sy5ty5ow5qs}6z{17sy5ty5ow5qs}fm{17sy5ty5ow5qs}fn{17sy5ty5ow5qs}fo{17sy5ty5ow5qs}fp{17sy5ty5qs}fq{17sy5ty5ow5qs}7r{5ow}fs{17sy5ty5ow5qs}ft{17sv5tv5ow}7m{5ow}fv{17sv5tv5ow}fw{17sv5tv5ow}}}")}};e.events.push(["addFont",function(d){var f=d.font,p=u.Unicode[f.postScriptName];p&&(f.metadata.Unicode={},f.metadata.Unicode.widths=p.widths,f.metadata.Unicode.kerning=p.kerning);var h=c.Unicode[f.postScriptName];h&&(f.metadata.Unicode.encoding=h,f.encoding=h.codePages[0])}])})(la.API),(function(e){var t=function(n){for(var r=n.length,a=new Uint8Array(r),i=0;i<r;i++)a[i]=n.charCodeAt(i);return a};e.API.events.push(["addFont",function(n){var r=void 0,a=n.font,i=n.instance;if(!a.isStandardFont){if(i===void 0)throw new Error("Font does not exist in vFS, import fonts or remove declaration doc.addFont('"+a.postScriptName+"').");if(typeof(r=i.existsFileInVFS(a.postScriptName)===!1?i.loadFile(a.postScriptName):i.getFileFromVFS(a.postScriptName))!="string")throw new Error("Font is not stored as string-data in vFS, import fonts or remove declaration doc.addFont('"+a.postScriptName+"').");(function(o,l){l=/^\x00\x01\x00\x00/.test(l)?t(l):t(JS(l)),o.metadata=e.API.TTFFont.open(l),o.metadata.Unicode=o.metadata.Unicode||{encoding:{},kerning:{},widths:[]},o.metadata.glyIdsUsed=[0]})(a,r)}}])})(la),(function(e){function t(){return(ua.canvg?Promise.resolve(ua.canvg):Pi(()=>import("./index.es-BSOH_sZ0.js"),[])).catch((function(n){return Promise.reject(new Error("Could not load canvg: "+n))})).then((function(n){return n.default?n.default:n}))}la.API.addSvgAsImage=function(n,r,a,i,o,l,s,c){if(isNaN(r)||isNaN(a))throw Ro.error("jsPDF.addSvgAsImage: Invalid coordinates",arguments),new Error("Invalid coordinates passed to jsPDF.addSvgAsImage");if(isNaN(i)||isNaN(o))throw Ro.error("jsPDF.addSvgAsImage: Invalid measurements",arguments),new Error("Invalid measurements (width and/or height) passed to jsPDF.addSvgAsImage");var u=document.createElement("canvas");u.width=i,u.height=o;var d=u.getContext("2d");d.fillStyle="#fff",d.fillRect(0,0,u.width,u.height);var f={ignoreMouse:!0,ignoreAnimation:!0,ignoreDimensions:!0},p=this;return t().then((function(h){return h.fromString(d,n,f)}),(function(){return Promise.reject(new Error("Could not load canvg."))})).then((function(h){return h.render(f)})).then((function(){p.addImage(u.toDataURL("image/jpeg",1),r,a,i,o,s,c)}))}})(),la.API.putTotalPages=function(e){var t,n=0;parseInt(this.internal.getFont().id.substr(1),10)<15?(t=new RegExp(e,"g"),n=this.internal.getNumberOfPages()):(t=new RegExp(this.pdfEscape16(e,this.internal.getFont()),"g"),n=this.pdfEscape16(this.internal.getNumberOfPages()+"",this.internal.getFont()));for(var r=1;r<=this.internal.getNumberOfPages();r++)for(var a=0;a<this.internal.pages[r].length;a++)this.internal.pages[r][a]=this.internal.pages[r][a].replace(t,n);return this},la.API.viewerPreferences=function(e,t){var n;e=e||{},t=t||!1;var r,a,i,o={HideToolbar:{defaultValue:!1,value:!1,type:"boolean",explicitSet:!1,valueSet:[!0,!1],pdfVersion:1.3},HideMenubar:{defaultValue:!1,value:!1,type:"boolean",explicitSet:!1,valueSet:[!0,!1],pdfVersion:1.3},HideWindowUI:{defaultValue:!1,value:!1,type:"boolean",explicitSet:!1,valueSet:[!0,!1],pdfVersion:1.3},FitWindow:{defaultValue:!1,value:!1,type:"boolean",explicitSet:!1,valueSet:[!0,!1],pdfVersion:1.3},CenterWindow:{defaultValue:!1,value:!1,type:"boolean",explicitSet:!1,valueSet:[!0,!1],pdfVersion:1.3},DisplayDocTitle:{defaultValue:!1,value:!1,type:"boolean",explicitSet:!1,valueSet:[!0,!1],pdfVersion:1.4},NonFullScreenPageMode:{defaultValue:"UseNone",value:"UseNone",type:"name",explicitSet:!1,valueSet:["UseNone","UseOutlines","UseThumbs","UseOC"],pdfVersion:1.3},Direction:{defaultValue:"L2R",value:"L2R",type:"name",explicitSet:!1,valueSet:["L2R","R2L"],pdfVersion:1.3},ViewArea:{defaultValue:"CropBox",value:"CropBox",type:"name",explicitSet:!1,valueSet:["MediaBox","CropBox","TrimBox","BleedBox","ArtBox"],pdfVersion:1.4},ViewClip:{defaultValue:"CropBox",value:"CropBox",type:"name",explicitSet:!1,valueSet:["MediaBox","CropBox","TrimBox","BleedBox","ArtBox"],pdfVersion:1.4},PrintArea:{defaultValue:"CropBox",value:"CropBox",type:"name",explicitSet:!1,valueSet:["MediaBox","CropBox","TrimBox","BleedBox","ArtBox"],pdfVersion:1.4},PrintClip:{defaultValue:"CropBox",value:"CropBox",type:"name",explicitSet:!1,valueSet:["MediaBox","CropBox","TrimBox","BleedBox","ArtBox"],pdfVersion:1.4},PrintScaling:{defaultValue:"AppDefault",value:"AppDefault",type:"name",explicitSet:!1,valueSet:["AppDefault","None"],pdfVersion:1.6},Duplex:{defaultValue:"",value:"none",type:"name",explicitSet:!1,valueSet:["Simplex","DuplexFlipShortEdge","DuplexFlipLongEdge","none"],pdfVersion:1.7},PickTrayByPDFSize:{defaultValue:!1,value:!1,type:"boolean",explicitSet:!1,valueSet:[!0,!1],pdfVersion:1.7},PrintPageRange:{defaultValue:"",value:"",type:"array",explicitSet:!1,valueSet:null,pdfVersion:1.7},NumCopies:{defaultValue:1,value:1,type:"integer",explicitSet:!1,valueSet:null,pdfVersion:1.7}},l=Object.keys(o),s=[],c=0,u=0,d=0;function f(h,g){var m,A=!1;for(m=0;m<h.length;m+=1)h[m]===g&&(A=!0);return A}if(this.internal.viewerpreferences===void 0&&(this.internal.viewerpreferences={},this.internal.viewerpreferences.configuration=JSON.parse(JSON.stringify(o)),this.internal.viewerpreferences.isSubscribed=!1),n=this.internal.viewerpreferences.configuration,e==="reset"||t===!0){var p=l.length;for(d=0;d<p;d+=1)n[l[d]].value=n[l[d]].defaultValue,n[l[d]].explicitSet=!1}if(ii(e)==="object"){for(a in e)if(i=e[a],f(l,a)&&i!==void 0){if(n[a].type==="boolean"&&typeof i=="boolean")n[a].value=i;else if(n[a].type==="name"&&f(n[a].valueSet,i))n[a].value=i;else if(n[a].type==="integer"&&Number.isInteger(i))n[a].value=i;else if(n[a].type==="array"){for(c=0;c<i.length;c+=1)if(r=!0,i[c].length===1&&typeof i[c][0]=="number")s.push(String(i[c]-1));else if(i[c].length>1){for(u=0;u<i[c].length;u+=1)typeof i[c][u]!="number"&&(r=!1);r===!0&&s.push([i[c][0]-1,i[c][1]-1].join(" "))}n[a].value="["+s.join(" ")+"]"}else n[a].value=n[a].defaultValue;n[a].explicitSet=!0}}return this.internal.viewerpreferences.isSubscribed===!1&&(this.internal.events.subscribe("putCatalog",(function(){var h,g=[];for(h in n)n[h].explicitSet===!0&&(n[h].type==="name"?g.push("/"+h+" /"+n[h].value):g.push("/"+h+" "+n[h].value));g.length!==0&&this.internal.write(`/ViewerPreferences
2013
2013
  <<
2014
2014
  `+g.join(`
2015
2015
  `)+`
@@ -4008,7 +4008,7 @@ ${JSON.stringify(p)}
4008
4008
  `).filter(Boolean):void 0,url:A.transport!=="stdio"?A.url:void 0,env:Object.keys(A.env).length>0?A.env:void 0,timeout:A.timeout,retryAttempts:A.retryAttempts};if(A.transport==="stdio"&&!A.command){bn.error("Please enter the command for stdio transport");return}if(A.transport!=="stdio"&&!A.url){bn.error("Please enter the URL for HTTP/SSE transport");return}h(!0);try{const D=await l("/api/mcp-servers/test-tools",{config:O});D.success&&((M=D.data)!=null&&M.tools)?(m(D.data.tools),t||v(B=>({...B,selectedTools:D.data.tools.map($=>$.name)}))):bn.error(D.message||"Failed to fetch tools")}catch(D){console.error("Failed to fetch tools:",D),bn.error("Failed to fetch tools from MCP server")}finally{h(!1)}},S=async()=>{f(!0);try{const O={id:t==null?void 0:t.id,key:A.key,name:A.name,description:A.description,selectedTools:A.selectedTools,config:{name:A.name||A.key,version:"1.0.0",transport:A.transport,command:A.transport==="stdio"?A.command:void 0,args:A.transport==="stdio"?A.args.split(`
4009
4009
  `).filter(Boolean):void 0,url:A.transport!=="stdio"?A.url:void 0,env:Object.keys(A.env).length>0?A.env:void 0,timeout:A.timeout,retryAttempts:A.retryAttempts}};let M;t?M=await s(`/api/mcp-servers/${t.key}`,O):M=await l("/api/mcp-servers",O),M.success?(a(M.data),bn.success(t?"Configuration updated":"Configuration created")):bn.error(M.message||"Failed to save configuration")}catch(O){console.error("Failed to save config:",O),bn.error("Failed to save configuration")}finally{f(!1)}},E=O=>{v(M=>M.selectedTools.includes(O)?{...M,selectedTools:M.selectedTools.filter(B=>B!==O)}:{...M,selectedTools:[...M.selectedTools,O]})},w=()=>{switch(c){case 0:return A.key&&A.name&&(A.transport==="stdio"?A.command:A.url);case 1:return A.selectedTools.length>0;default:return!0}},T=()=>{switch(c){case 0:return C.jsxs(rr,{direction:"vertical",style:{width:"100%"},size:"large",children:[C.jsxs("div",{children:[C.jsx(ml,{strong:!0,children:"Connection Key"}),C.jsx(Jn,{value:A.key,onChange:O=>v({...A,key:O.target.value}),placeholder:"e.g., filesystem-server",style:{width:"100%",marginTop:8},disabled:!!t})]}),C.jsxs("div",{children:[C.jsx(ml,{strong:!0,children:"Name"}),C.jsx(Jn,{value:A.name,onChange:O=>v({...A,name:O.target.value}),placeholder:"e.g., Filesystem Server",style:{width:"100%",marginTop:8}})]}),C.jsxs("div",{children:[C.jsx(ml,{strong:!0,children:"Description"}),C.jsx(rGe,{value:A.description,onChange:O=>v({...A,description:O.target.value}),placeholder:"Optional description",rows:2,style:{width:"100%",marginTop:8}})]}),C.jsxs("div",{children:[C.jsx(ml,{strong:!0,children:"Transport Type"}),C.jsx(Mf,{value:A.transport,onChange:O=>v({...A,transport:O}),options:[{value:"stdio",label:"STDIO (Command)"},{value:"streamable_http",label:"HTTP"},{value:"sse",label:"SSE (Server-Sent Events)"}],style:{width:"100%",marginTop:8}})]}),A.transport==="stdio"?C.jsxs(C.Fragment,{children:[C.jsxs("div",{children:[C.jsx(ml,{strong:!0,children:"Command"}),C.jsx(Jn,{value:A.command,onChange:O=>v({...A,command:O.target.value}),placeholder:"e.g., npx or python",style:{width:"100%",marginTop:8}})]}),C.jsxs("div",{children:[C.jsx(ml,{strong:!0,children:"Arguments (one per line)"}),C.jsx(rGe,{value:A.args,onChange:O=>v({...A,args:O.target.value}),placeholder:`-y
4010
4010
  @modelcontextprotocol/server-filesystem
4011
- /path/to/files`,rows:4,style:{width:"100%",marginTop:8,fontFamily:"monospace"}})]})]}):C.jsxs("div",{children:[C.jsx(ml,{strong:!0,children:"Server URL"}),C.jsx(Jn,{value:A.url,onChange:O=>v({...A,url:O.target.value}),placeholder:"e.g., http://localhost:3000",style:{width:"100%",marginTop:8}})]}),C.jsx(s5,{ghost:!0,children:C.jsx(hsr,{header:"Advanced Options",children:C.jsxs(rr,{direction:"vertical",style:{width:"100%"},size:"middle",children:[C.jsxs("div",{children:[C.jsx(ml,{strong:!0,children:"Timeout (ms)"}),C.jsx(Jn,{type:"number",value:A.timeout,onChange:O=>v({...A,timeout:parseInt(O.target.value)||3e4}),style:{width:"100%",marginTop:8}})]}),C.jsxs("div",{children:[C.jsx(ml,{strong:!0,children:"Retry Attempts"}),C.jsx(Jn,{type:"number",value:A.retryAttempts,onChange:O=>v({...A,retryAttempts:parseInt(O.target.value)||3}),style:{width:"100%",marginTop:8}})]})]})},"1")})]});case 1:return p?C.jsxs("div",{style:{textAlign:"center",padding:"60px 0"},children:[C.jsx(bl,{size:"large"}),C.jsx("div",{style:{marginTop:16},children:C.jsx(ml,{children:"Connecting to MCP server and fetching tools..."})})]}):g.length===0?C.jsx("div",{style:{textAlign:"center",padding:"40px 0"},children:C.jsx(ml,{type:"secondary",children:"No tools available. Please check your connection settings."})}):C.jsxs("div",{children:[C.jsxs("div",{style:{marginBottom:16},children:[C.jsx(ml,{strong:!0,children:"Available Tools"}),C.jsx("div",{style:{marginTop:4},children:C.jsxs(ml,{type:"secondary",style:{fontSize:12},children:["Selected: ",A.selectedTools.length," / ",g.length]})})]}),C.jsx("div",{style:{overflowY:"auto",maxHeight:"450px"},children:g.map(O=>{const M=A.selectedTools.includes(O.name);return C.jsx(Ri,{size:"small",style:{marginBottom:8,borderColor:M?o.colorPrimary:void 0},bodyStyle:{padding:12},children:C.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:12},children:[C.jsx(Mc,{checked:M,onChange:()=>E(O.name),style:{marginTop:4}}),C.jsxs("div",{style:{flex:1,minWidth:0},children:[C.jsx(ml,{strong:!0,style:{fontSize:14},children:O.name}),O.description&&C.jsx(ml,{type:"secondary",style:{fontSize:12,marginTop:4,display:"block"},children:O.description}),O.inputSchema&&C.jsx("div",{style:{marginTop:8},children:C.jsxs(ml,{type:"secondary",style:{fontSize:11},children:["Parameters: ",Object.keys(O.inputSchema.properties||{}).join(", ")]})})]})]})},O.name)})})]});default:return null}},N=()=>{c===1?S():u(O=>O+1)},R=()=>{u(O=>O-1)};return C.jsx(Gi,{title:t?"Edit MCP Server Configuration":"Add MCP Server Configuration",open:e,onCancel:r,width:700,style:{top:50},footer:null,children:C.jsxs("div",{children:[C.jsx(Zde,{current:c,items:y,style:{marginBottom:24}}),C.jsx("div",{style:{padding:"24px 0",minHeight:300},children:T()}),C.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:12,paddingTop:16,marginTop:24},children:[C.jsx(tn,{onClick:r,children:"Cancel"}),c>0&&C.jsx(tn,{icon:C.jsx(Cfe,{size:16}),onClick:R,children:"Previous"}),C.jsx(tn,{type:"primary",onClick:N,disabled:!w()||d||p,icon:c===1?d?C.jsx(pg,{size:16,className:"spin"}):C.jsx(cB,{size:16}):C.jsx(E3,{size:16}),children:c===1?d?"Saving...":t?"Save Changes":"Create":"Next"})]})]})})},{Text:O2}=fr,Asr=e=>{const t=["#1890ff","#52c41a","#faad14","#f5222d","#722ed1","#13c2c2","#eb2f96","#fa8c16"];let n=0;for(let r=0;r<e.length;r++)n=e.charCodeAt(r)+((n<<5)-n);return t[Math.abs(n)%t.length]},vsr=({data:e,selected:t})=>{var g;const{token:n}=Xl.useToken();if(!e)return null;const{assistant:r,onConfigure:a,onChat:i}=e;if(!r)return null;const o=Asr(r.id),l=((g=r.name)==null?void 0:g.split(" ").map(m=>m.charAt(0)).join("").toUpperCase().slice(0,2))||"A",{modelKey:s,tools:c,agentType:u,prompt:d,subAgents:f}=b.useMemo(()=>{if(!r.graphDefinition)return{modelKey:void 0,tools:[],agentType:void 0,prompt:void 0,subAgents:[]};try{const m=typeof r.graphDefinition=="string"?JSON.parse(r.graphDefinition):r.graphDefinition;return{modelKey:m.modelKey||m.model,tools:m.tools||[],agentType:m.type,prompt:m.prompt,subAgents:m.subAgents||[]}}catch{return{modelKey:void 0,tools:[],agentType:void 0,prompt:void 0,subAgents:[]}}},[r.graphDefinition]),p=m=>m?{react:"Executor",deep_agent:"Orchestrator",plan_execute:"PLAN EXECUTE",sequential:"SEQUENTIAL"}[m]||m.toUpperCase():"",h=C.jsxs("div",{style:{maxWidth:400,maxHeight:"60vh",overflowY:"auto"},children:[C.jsx("div",{style:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",marginBottom:12},children:C.jsxs("div",{style:{flex:1},children:[C.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:8},children:[C.jsx(O2,{strong:!0,style:{fontSize:16,fontWeight:600,color:n.colorText},children:r.name}),u&&C.jsx(Kr,{color:"purple",style:{margin:0,fontSize:10,padding:"2px 8px",fontWeight:600},children:p(u)})]}),C.jsx("div",{style:{display:"flex",alignItems:"center",gap:6},children:C.jsx(O2,{style:{fontSize:11,color:n.colorTextTertiary,fontFamily:"monospace"},children:`>_ ${r.id}`})})]})}),r.description&&C.jsx("div",{style:{marginBottom:12},children:C.jsxs(O2,{style:{fontSize:12,color:n.colorText,lineHeight:1.6,fontStyle:"italic"},children:['"',r.description,'"']})}),s&&C.jsxs("div",{style:{marginBottom:12},children:[C.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:8},children:[C.jsx(_ie,{style:{fontSize:14,color:n.colorTextSecondary}}),C.jsx(O2,{style:{fontSize:12,color:n.colorTextSecondary,fontWeight:500},children:"Model Engine"})]}),C.jsx(Kr,{color:"blue",style:{fontSize:11,padding:"4px 12px"},children:s})]}),d&&C.jsxs("div",{style:{marginBottom:12},children:[C.jsx("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:8,justifyContent:"space-between"},children:C.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[C.jsx(mf,{style:{fontSize:14,color:n.colorTextSecondary}}),C.jsx(O2,{style:{fontSize:12,color:n.colorTextSecondary,fontWeight:600,letterSpacing:.5},children:"SYSTEM PROMPT"})]})}),C.jsx("div",{style:{padding:12,background:n.colorFillTertiary,border:`1px solid ${n.colorBorderSecondary}`,borderRadius:4,maxHeight:150,overflowY:"auto"},children:C.jsx(O2,{style:{fontSize:11,color:n.colorText,lineHeight:1.6,whiteSpace:"pre-wrap"},children:d.length>300?d.slice(0,300)+"...":d})})]}),c&&c.length>0&&C.jsxs("div",{style:{marginBottom:12},children:[C.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:8},children:[C.jsx(bw,{style:{fontSize:14,color:n.colorTextSecondary}}),C.jsxs(O2,{style:{fontSize:12,color:n.colorTextSecondary,fontWeight:500},children:["Available Tools (",c.length,")"]})]}),C.jsxs(rr,{size:[8,8],wrap:!0,children:[c.slice(0,5).map((m,A)=>C.jsx(Kr,{color:"blue",style:{fontSize:11,padding:"4px 12px"},children:m.replace(/_/g," ")},A)),c.length>5&&C.jsxs(Kr,{style:{fontSize:11,padding:"4px 12px",backgroundColor:n.colorFillTertiary,color:n.colorTextSecondary},children:["+",c.length-5," more"]})]})]}),f&&f.length>0&&C.jsxs("div",{style:{marginBottom:8},children:[C.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:8},children:[C.jsx(jre,{style:{fontSize:14,color:n.colorTextSecondary}}),C.jsxs(O2,{style:{fontSize:12,color:n.colorTextSecondary,fontWeight:500},children:["Sub-Agent Architecture (",f.length,")"]})]}),C.jsxs(rr,{size:[8,8],wrap:!0,children:[f.slice(0,3).map((m,A)=>C.jsx(Kr,{style:{fontSize:11,padding:"4px 12px",backgroundColor:n.colorFillTertiary,color:n.colorText,border:`1px solid ${n.colorBorderSecondary}`},children:`> ${m}`},A)),f.length>3&&C.jsxs(Kr,{style:{fontSize:11,padding:"4px 12px",backgroundColor:n.colorFillTertiary,color:n.colorTextSecondary},children:["+",f.length-3," more"]})]})]})]});return C.jsxs("div",{style:{padding:4},children:[C.jsx(j3,{type:"target",position:Br.Top}),C.jsxs("div",{style:{width:260,minHeight:180,background:n.colorBgContainer,borderRadius:8,boxShadow:"0 1px 4px rgba(0, 0, 0, 0.08)",overflow:"hidden",transition:"all 0.2s ease",position:"relative",border:t?`2px solid ${n.colorPrimary}`:`1px solid ${n.colorBorder}`,display:"flex",flexDirection:"column"},onMouseEnter:m=>{m.currentTarget.style.transform="translateY(-2px)",m.currentTarget.style.boxShadow="0 2px 8px rgba(0, 0, 0, 0.12)"},onMouseLeave:m=>{m.currentTarget.style.transform="translateY(0)",m.currentTarget.style.boxShadow="0 1px 4px rgba(0, 0, 0, 0.08)"},children:[C.jsxs("div",{style:{padding:12,display:"flex",flexDirection:"column",gap:10,flex:1},children:[C.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:10},children:[C.jsx(Gr,{title:h,placement:"rightTop",mouseEnterDelay:.5,overlayStyle:{maxWidth:"none"},color:n.colorBgContainer,children:C.jsxs("div",{style:{position:"relative",flexShrink:0,cursor:"pointer"},children:[C.jsx(wg,{size:44,icon:C.jsx(lB,{}),style:{backgroundColor:o,color:"#fff",fontSize:16,fontWeight:600},children:l}),C.jsx("div",{style:{position:"absolute",bottom:0,right:0,width:10,height:10,borderRadius:"50%",background:"#52c41a",border:`2px solid ${n.colorBgContainer}`}})]})}),C.jsxs("div",{style:{flex:1,minWidth:0,paddingRight:32},children:[C.jsx(O2,{strong:!0,style:{fontSize:14,fontWeight:600,display:"block",marginBottom:3,color:n.colorText,lineHeight:1.3},ellipsis:{tooltip:r.name},children:r.name}),C.jsxs("div",{style:{display:"flex",alignItems:"center",gap:4},children:[C.jsx(Qzt,{style:{fontSize:9,color:n.colorTextTertiary}}),C.jsx(O2,{style:{fontSize:9,color:n.colorTextTertiary},ellipsis:{tooltip:r.id},children:r.id})]})]})]}),r.description&&C.jsx("div",{style:{padding:8,background:n.colorFillTertiary,border:`1px solid ${n.colorBorderSecondary}`,borderRadius:4,borderLeft:`2px solid ${o}`},children:C.jsx(Gr,{title:r.description.length>150?r.description:void 0,placement:"top",children:C.jsxs("div",{style:{fontSize:10,color:n.colorText,lineHeight:1.5,fontStyle:"italic",display:"-webkit-box",WebkitLineClamp:3,WebkitBoxOrient:"vertical",overflow:"hidden",textOverflow:"ellipsis",cursor:r.description.length>150?"help":"default"},children:['"',r.description,'"']})})}),C.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:4,padding:"4px 0",marginTop:"auto",alignItems:"center",justifyContent:"space-between"},children:[C.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:4},children:[u&&C.jsx(Kr,{style:{margin:0,fontSize:7,padding:"2px 6px",borderRadius:6,backgroundColor:n.colorPrimaryBg,color:n.colorPrimary,border:`1px solid ${n.colorPrimaryBorder}`,fontWeight:500,lineHeight:"14px"},children:p(u)}),c&&c.length>0&&C.jsxs(Kr,{style:{margin:0,fontSize:7,padding:"2px 6px",borderRadius:6,backgroundColor:n.colorSuccessBg,color:n.colorSuccess,border:`1px solid ${n.colorSuccessBorder}`,fontWeight:500,lineHeight:"14px"},children:[c.length," Tools"]}),s&&C.jsx(Kr,{style:{margin:0,fontSize:7,padding:"2px 6px",borderRadius:6,backgroundColor:n.colorWarningBg,color:n.colorWarning,border:`1px solid ${n.colorWarningBorder}`,fontWeight:500,lineHeight:"14px"},title:s,children:s.length>12?`${s.slice(0,12)}...`:s})]}),i&&C.jsxs("div",{onMouseDown:m=>{m.stopPropagation()},onClick:m=>{m.stopPropagation(),i(r)},style:{display:"flex",alignItems:"center",gap:2,padding:"2px 6px",borderRadius:4,backgroundColor:n.colorPrimary,color:"#fff",cursor:"pointer",fontSize:10,fontWeight:500,transition:"all 0.2s ease"},onMouseEnter:m=>{m.currentTarget.style.backgroundColor=n.colorPrimaryHover},onMouseLeave:m=>{m.currentTarget.style.backgroundColor=n.colorPrimary},children:[C.jsx(xHt,{style:{fontSize:10}}),C.jsx("span",{children:"Chat"})]})]})]}),C.jsx(j3,{type:"source",position:Br.Bottom})]})]})},ysr=vsr,{TextArea:bsr}=Jn,{Text:Bo,Title:nfr}=fr,Kte=({title:e,icon:t,badge:n,children:r,defaultExpanded:a=!0})=>{const{token:i}=Xl.useToken(),[o,l]=b.useState(a);return C.jsxs(Ri,{size:"small",style:{marginBottom:16,border:`1px solid ${i.colorBorderSecondary}`,backgroundColor:`${i.colorBgContainer}d0`,backdropFilter:"blur(8px)",WebkitBackdropFilter:"blur(8px)"},bodyStyle:{padding:0},children:[C.jsxs("div",{onClick:()=>l(!o),style:{padding:"10px 14px",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"space-between",borderBottom:o?`1px solid ${i.colorBorderSecondary}`:"none",backgroundColor:`${i.colorFillQuaternary}d0`},children:[C.jsxs(rr,{size:"small",children:[t,C.jsx(Bo,{strong:!0,style:{fontSize:14},children:e}),n!==void 0&&n>0&&C.jsx(lw,{count:n,style:{backgroundColor:i.colorPrimary}})]}),C.jsx("div",{style:{transform:o?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.2s"},children:C.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",style:{color:i.colorTextSecondary},children:C.jsx("path",{d:"M6 8L1 3h10L6 8z",fill:"currentColor"})})})]}),o&&C.jsx("div",{style:{padding:16},children:r})]})},_sr=(e,t,n,r,a)=>{var o,l;const i=C.jsxs("span",{children:[t.title||e,t.description&&C.jsxs(C.Fragment,{children:[" ",C.jsx(Gr,{title:t.description,children:C.jsx(jHt,{style:{color:a.colorTextSecondary,cursor:"pointer"}})})]})]});if(t.widget==="segmented"||t.enum&&!t.widget){const s=((o=t.enum)==null?void 0:o.map(c=>({value:c,label:{global:"Global",agent:"Per Agent",thread:"Per Thread"}[c]||c})))||[];return C.jsx(Dr.Item,{label:i,style:{marginBottom:0},children:C.jsx(xx,{size:"small",value:n,onChange:r,options:s,block:!0})},e)}if(t.widget==="switch")return C.jsx(Dr.Item,{label:i,style:{marginBottom:8},children:C.jsx(vw,{checked:n,onChange:r})},e);if(t.widget==="numberInput"||t.type==="number"||t.type==="integer")return C.jsx(Dr.Item,{label:i,style:{marginBottom:8},children:C.jsx(Jn,{size:"small",type:"number",value:n,onChange:s=>r(parseFloat(s.target.value)||t.default),min:t.minimum,max:t.maximum,style:{width:"100%"}})},e);if(t.widget==="select"){const s=t.enumLabels,c=s?Object.entries(s).map(([u,d])=>({value:u,label:d})):((l=t.enum)==null?void 0:l.map(u=>({value:u,label:u})))||[];return C.jsx(Dr.Item,{label:i,style:{marginBottom:8},children:C.jsx(Mf,{size:"small",value:n,onChange:r,options:c,style:{width:"100%"}})},e)}return t.widget==="textarea"?C.jsx(Dr.Item,{label:i,style:{marginBottom:8},children:C.jsx(Jn.TextArea,{size:"small",value:n,onChange:s=>r(s.target.value),placeholder:t.default,autoSize:{minRows:2,maxRows:4}})},e):t.widget==="skillSelect"?C.jsx(xsr,{propertyKey:e,label:i,value:n,onChange:r,token:a}):t.widget==="databaseSelect"?C.jsx(Esr,{propertyKey:e,label:i,value:n,onChange:r,token:a}):t.widget==="metricsSelect"?C.jsx(wsr,{propertyKey:e,label:i,value:n,onChange:r,token:a}):C.jsx(Dr.Item,{label:i,style:{marginBottom:8},children:C.jsx(Jn,{size:"small",value:n,onChange:s=>r(s.target.value),placeholder:t.default})},e)},Ssr=(e,t)=>t==null?void 0:t.find(n=>n.type===e),xsr=({propertyKey:e,label:t,value:n,onChange:r,token:a})=>{const[i,o]=b.useState([]),[l,s]=b.useState(!1),{get:c}=_l(),u=b.useRef(!1);b.useEffect(()=>{if(u.current)return;u.current=!0,(async()=>{s(!0);try{const h=await c("/api/skills");h.success&&h.data&&Array.isArray(h.data.records)&&o(h.data.records)}catch(h){console.error("Failed to fetch skills:",h)}finally{s(!1)}})()},[c]);const d=Array.isArray(n)?n:[],f=p=>C.jsx(Ha.Item,{style:{padding:"8px 0",cursor:"pointer",borderRadius:a.borderRadius,backgroundColor:d.includes(p.id)?a.colorSuccessBg:"transparent",border:`1px solid ${d.includes(p.id)?a.colorSuccess:"transparent"}`,marginBottom:4,transition:"all 0.2s ease",paddingLeft:8,paddingRight:8},onClick:()=>{const h=d.includes(p.id)?d.filter(g=>g!==p.id):[...d,p.id];r(h)},children:C.jsx(Ha.Item.Meta,{avatar:C.jsx(Mc,{checked:d.includes(p.id),onChange:()=>{const h=d.includes(p.id)?d.filter(g=>g!==p.id):[...d,p.id];r(h)},onClick:h=>h.stopPropagation()}),title:C.jsx(Bo,{strong:d.includes(p.id),children:p.name}),description:C.jsx(Bo,{type:"secondary",style:{fontSize:12},children:p.description})})},p.id);return C.jsx("div",{children:C.jsxs(Dr.Item,{label:t,style:{marginBottom:8},children:[C.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:12},children:[C.jsxs(Bo,{type:"secondary",style:{fontSize:12},children:[d.length," of ",i.length," selected"]}),C.jsx(tn,{type:"link",size:"small",onClick:()=>r(d.length===i.length?[]:i.map(p=>p.id)),children:d.length===i.length?"Deselect All":"Select All"})]}),l?C.jsx("div",{style:{textAlign:"center",padding:20},children:C.jsx(bl,{size:"small"})}):i.length===0?C.jsx(ai,{description:"No skills available",image:ai.PRESENTED_IMAGE_SIMPLE}):C.jsx(Ha,{dataSource:i,renderItem:f,style:{maxHeight:"40vh",overflowY:"auto"},split:!1})]},e)})},Esr=({propertyKey:e,label:t,value:n,onChange:r,token:a})=>{const[i,o]=b.useState([]),[l,s]=b.useState(!1),{get:c}=_l(),u=b.useRef(!1);b.useEffect(()=>{if(u.current)return;u.current=!0,(async()=>{s(!0);try{const h=await c("/api/database-configs");h.success&&h.data&&Array.isArray(h.data.records)&&o(h.data.records)}catch(h){console.error("Failed to fetch database configs:",h)}finally{s(!1)}})()},[c]);const d=Array.isArray(n)?n:[],f=p=>{const h=p.name||p.key,g=d.includes(p.key);return C.jsx(Ha.Item,{style:{padding:"8px 0",cursor:"pointer",borderRadius:a.borderRadius,backgroundColor:g?a.colorSuccessBg:"transparent",border:`1px solid ${g?a.colorSuccess:"transparent"}`,marginBottom:4,transition:"all 0.2s ease",paddingLeft:8,paddingRight:8},onClick:()=>{const m=g?d.filter(A=>A!==p.key):[...d,p.key];r(m)},children:C.jsx(Ha.Item.Meta,{avatar:C.jsx(Mc,{checked:g,onChange:()=>{const m=g?d.filter(A=>A!==p.key):[...d,p.key];r(m)},onClick:m=>m.stopPropagation()}),title:C.jsx(Bo,{strong:g,children:h}),description:p.description&&C.jsx(Bo,{type:"secondary",style:{fontSize:12},children:p.description})})},p.key)};return C.jsx("div",{children:C.jsxs(Dr.Item,{label:t,style:{marginBottom:8},children:[C.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:12},children:[C.jsxs(Bo,{type:"secondary",style:{fontSize:12},children:[d.length," of ",i.length," selected"]}),C.jsx(tn,{type:"link",size:"small",onClick:()=>r(d.length===i.length?[]:i.map(p=>p.key)),children:d.length===i.length?"Deselect All":"Select All"})]}),l?C.jsx("div",{style:{textAlign:"center",padding:20},children:C.jsx(bl,{size:"small"})}):i.length===0?C.jsx(ai,{description:"No databases available",image:ai.PRESENTED_IMAGE_SIMPLE}):C.jsx(Ha,{dataSource:i,renderItem:f,style:{maxHeight:"40vh",overflowY:"auto"},split:!1})]},e)})},wsr=({propertyKey:e,label:t,value:n,onChange:r,token:a})=>{const[i,o]=b.useState([]),[l,s]=b.useState(!1),{get:c}=_l(),u=b.useRef(!1);b.useEffect(()=>{if(u.current)return;u.current=!0,(async()=>{s(!0);try{const h=await c("/api/metrics-configs");h.success&&h.data&&Array.isArray(h.data.records)&&o(h.data.records)}catch(h){console.error("Failed to fetch metrics configs:",h)}finally{s(!1)}})()},[c]);const d=Array.isArray(n)?n:[],f=p=>{const h=p.name||p.key,g=d.includes(p.key);return C.jsx(Ha.Item,{style:{padding:"8px 0",cursor:"pointer",borderRadius:a.borderRadius,backgroundColor:g?a.colorSuccessBg:"transparent",border:`1px solid ${g?a.colorSuccess:"transparent"}`,marginBottom:4,transition:"all 0.2s ease",paddingLeft:8,paddingRight:8},onClick:()=>{const m=g?d.filter(A=>A!==p.key):[...d,p.key];r(m)},children:C.jsx(Ha.Item.Meta,{avatar:C.jsx(Mc,{checked:g,onChange:()=>{const m=g?d.filter(A=>A!==p.key):[...d,p.key];r(m)},onClick:m=>m.stopPropagation()}),title:C.jsx(Bo,{strong:g,children:h}),description:p.description&&C.jsx(Bo,{type:"secondary",style:{fontSize:12},children:p.description})})},p.key)};return C.jsx("div",{children:C.jsxs(Dr.Item,{label:t,style:{marginBottom:8},children:[C.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:12},children:[C.jsxs(Bo,{type:"secondary",style:{fontSize:12},children:[d.length," of ",i.length," selected"]}),C.jsx(tn,{type:"link",size:"small",onClick:()=>r(d.length===i.length?[]:i.map(p=>p.key)),children:d.length===i.length?"Deselect All":"Select All"})]}),l?C.jsx("div",{style:{textAlign:"center",padding:20},children:C.jsx(bl,{size:"small"})}):i.length===0?C.jsx(ai,{description:"No metrics servers available",image:ai.PRESENTED_IMAGE_SIMPLE}):C.jsx(Ha,{dataSource:i,renderItem:f,style:{maxHeight:"40vh",overflowY:"auto"},split:!1})]},e)})},Csr=({middleware:e,middlewareType:t,onToggle:n,onConfigChange:r,token:a})=>{const[i,o]=b.useState(e.enabled),l=()=>{switch(e.type){case"browser":return C.jsx(LXe,{style:{color:a.colorPrimary}});case"sql":return C.jsx(hfe,{style:{color:a.colorWarning}});case"skill":return C.jsx(fjt,{style:{color:a.colorSuccess}});case"filesystem":return C.jsx(MXe,{style:{color:a.colorInfo}});case"code_eval":return C.jsx(mf,{style:{color:a.colorError}});case"metrics":return C.jsx(sB,{size:16,style:{color:a.colorWarning}});default:return C.jsx(Rx,{style:{color:a.colorWarning}})}},s=()=>{if(e.type==="browser")return C.jsxs("div",{style:{marginTop:12,paddingTop:12,borderTop:`1px solid ${a.colorBorderSecondary}`},children:[C.jsx(Bo,{strong:!0,style:{fontSize:12,display:"block",marginBottom:8},children:"Provided Tools"}),C.jsx(rr,{size:4,wrap:!0,children:["Navigate","Click","Fill","Get Text","Markdown","Screenshot","Scroll","Evaluate"].map(u=>C.jsx(Kr,{color:"green",style:{fontSize:10,margin:0},children:u},u))})]});if(e.type==="sql"||e.type==="skill"){const u=(t==null?void 0:t.tools)||[];return C.jsxs("div",{style:{marginTop:12,paddingTop:12,borderTop:`1px solid ${a.colorBorderSecondary}`},children:[C.jsx(Bo,{strong:!0,style:{fontSize:12,display:"block",marginBottom:8},children:"Provided Tools"}),C.jsx(rr,{size:4,wrap:!0,children:u.map(d=>C.jsx(Kr,{color:e.type==="sql"?"orange":"blue",style:{fontSize:10,margin:0},children:d.name},d.id))})]})}return null},c=()=>{var f;if(!((f=t==null?void 0:t.schema)!=null&&f.properties))return null;const u=t.schema.properties,d=Object.keys(u);return C.jsx("div",{style:{marginTop:8},children:d.map(p=>{const h=u[p];return p==="skills"&&e.config.readAll===!0||p==="serverKeys"&&e.config.connectAll===!0||p==="vmIsolation"?null:_sr(p,h,e.config[p]??h.default,g=>r({[p]:g}),a)})})};return C.jsxs(Ri,{size:"small",style:{marginBottom:16,border:`1px solid ${e.enabled?a.colorPrimary:a.colorBorderSecondary}`,backgroundColor:`${a.colorBgContainer}d0`,backdropFilter:"blur(8px)",WebkitBackdropFilter:"blur(8px)",opacity:e.enabled?1:.7},bodyStyle:{padding:0},children:[C.jsxs("div",{style:{padding:"10px 14px",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"space-between",borderBottom:i?`1px solid ${a.colorBorderSecondary}`:"none",backgroundColor:`${a.colorFillQuaternary}d0`},onClick:()=>e.enabled&&o(!i),children:[C.jsxs(rr,{size:"small",children:[l(),C.jsx(Bo,{strong:!0,style:{fontSize:14},children:e.name})]}),C.jsxs(rr,{size:"small",onClick:u=>u.stopPropagation(),children:[C.jsx(vw,{checked:e.enabled,onChange:u=>{n(),u&&o(!0)},size:"small"}),C.jsx("div",{style:{transform:i?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.2s",opacity:e.enabled?1:.3},children:C.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",style:{color:a.colorTextSecondary},children:C.jsx("path",{d:"M6 8L1 3h10L6 8z",fill:"currentColor"})})})]})]}),e.enabled&&i&&C.jsxs("div",{style:{padding:16},children:[C.jsx(Bo,{type:"secondary",style:{fontSize:11,display:"block",marginBottom:12},children:e.description}),c(),s()]})]})},Tsr=({assistant:e,allAssistants:t,visible:n,onClose:r,onSave:a,onDelete:i})=>{const[o]=Dr.useForm(),{token:l}=Xl.useToken(),{config:s}=Zo(),{get:c}=_l(),[u,d]=b.useState(!1),[f,p]=b.useState(!1),[h,g]=b.useState(!1),[m,A]=b.useState(!1),[v,y]=b.useState([]),[_,x]=b.useState([]),[S,E]=b.useState([]),[w,T]=b.useState(""),[N,R]=b.useState(!1),[k,O]=b.useState("react"),[M,D]=b.useState([]),B=b.useMemo(()=>{if(!(e!=null&&e.graphDefinition))return null;try{const Y=typeof e.graphDefinition=="string"?JSON.parse(e.graphDefinition):e.graphDefinition;return{tools:Y.tools||[],prompt:Y.prompt||"",subAgents:Y.subAgents||[],type:Y.type||"react",middleware:Y.middleware||[]}}catch{return null}},[e]),$=b.useCallback(Y=>(Y||[]).map((ae,ne)=>({id:`${ae.type}-${ne+1}`,type:ae.type,name:ae.name,description:ae.description,enabled:!1,config:{}})),[]),P=b.useCallback((Y,ee)=>{const ae=ee||[],ne=new Map((Y==null?void 0:Y.map(te=>[te.type,te]))||[]);return ae.map((te,se)=>{const pe=ne.get(te.type);return pe?{...pe,name:te.name,description:te.description}:{id:`${te.type}-${se+1}`,type:te.type,name:te.name,description:te.description,enabled:!1,config:{}}})},[]),U=b.useCallback(async()=>{var Y;if(n){d(!0);try{const ee=await c("/api/tools");ee.success&&((Y=ee.data)!=null&&Y.records)&&y(ee.data.records)}catch(ee){console.error("Failed to fetch tools:",ee)}finally{d(!1)}}},[c,n]);b.useEffect(()=>{if(n&&e)if(U(),B){x(B.tools),E(B.subAgents),T(B.prompt),O(B.type);const Y=B.middleware;D(Y!==void 0?P(Y,s.availableMiddlewareTypes||[]):$(s.availableMiddlewareTypes||[])),o.setFieldsValue({name:e.name,description:e.description,prompt:B.prompt,type:B.type})}else x([]),E([]),T(""),O("react"),D($(s.availableMiddlewareTypes||[])),o.resetFields()},[n,e,B,o,U,$,s.availableMiddlewareTypes]);const H=Y=>{x(ee=>ee.includes(Y)?ee.filter(ae=>ae!==Y):[...ee,Y])},G=Y=>{E(ee=>ee.includes(Y)?ee.filter(ae=>ae!==Y):[...ee,Y])},F=async()=>{if(e)try{p(!0);const ee={...await o.validateFields(),type:k,tools:_,subAgents:S,prompt:w,middleware:M};await(a==null?void 0:a(e,ee))}catch(Y){throw Y instanceof Error&&bn.error(Y.message),Y}finally{p(!1)}},z=async()=>{if(e){g(!0);try{await(i==null?void 0:i(e)),A(!1),r()}catch(Y){A(!1),bn.error(Y instanceof Error?Y.message:"Failed to delete assistant")}finally{g(!1)}}},W=Y=>{D(ee=>ee.map(ae=>{var ne;if(ae.id!==Y)return ae;if(ae.enabled)return{...ae,enabled:!1};{const te=(ne=s.availableMiddlewareTypes)==null?void 0:ne.find(se=>se.type===ae.type);return{...ae,enabled:!0,config:(te==null?void 0:te.defaultConfig)||{}}}}))},q=(Y,ee)=>{D(ae=>ae.map(ne=>ne.id===Y?{...ne,config:{...ne.config,...ee}}:ne))},Q=Y=>C.jsx(Ha.Item,{style:{padding:"8px 0",cursor:"pointer",borderRadius:l.borderRadius,backgroundColor:_.includes(Y.id)?l.colorPrimaryBg:"transparent",border:`1px solid ${_.includes(Y.id)?l.colorPrimary:"transparent"}`,marginBottom:4,transition:"all 0.2s ease",paddingLeft:8,paddingRight:8},onClick:()=>H(Y.id),children:C.jsx(Ha.Item.Meta,{avatar:C.jsx(Mc,{checked:_.includes(Y.id),onChange:()=>H(Y.id),onClick:ee=>ee.stopPropagation()}),title:C.jsxs(rr,{size:"small",children:[C.jsx(Bo,{strong:_.includes(Y.id),children:Y.name}),Y.needUserApprove&&C.jsx(Kr,{color:"warning",style:{fontSize:10,padding:"0 4px",margin:0},children:"Approve"})]}),description:C.jsx(Bo,{type:"secondary",style:{fontSize:12},children:Y.description})})},Y.id),Z=Y=>{var ee;return C.jsx(Ha.Item,{style:{padding:"8px 0",cursor:"pointer",borderRadius:l.borderRadius,backgroundColor:S.includes(Y.id)?l.colorInfoBg:"transparent",border:`1px solid ${S.includes(Y.id)?l.colorInfo:"transparent"}`,marginBottom:4,transition:"all 0.2s ease",paddingLeft:8,paddingRight:8},onClick:()=>G(Y.id),children:C.jsx(Ha.Item.Meta,{avatar:C.jsx(Mc,{checked:S.includes(Y.id),onChange:()=>G(Y.id),onClick:ae=>ae.stopPropagation()}),title:C.jsxs(rr,{size:"small",children:[C.jsx(wg,{size:"small",style:{backgroundColor:l.colorSuccess,fontSize:12},children:((ee=Y.name)==null?void 0:ee.charAt(0).toUpperCase())||"A"}),C.jsx(Bo,{strong:S.includes(Y.id),children:Y.name})]}),description:C.jsx(Bo,{type:"secondary",style:{fontSize:12},children:Y.description||"No description"})})},Y.id)};return!n||!e?null:C.jsxs("div",{style:{width:380,height:"100%",backgroundColor:`${l.colorBgContainer}f0`,backdropFilter:"blur(12px)",WebkitBackdropFilter:"blur(12px)",borderLeft:`1px solid ${l.colorBorderSecondary}`,display:"flex",flexDirection:"column",boxShadow:"-2px 0 8px rgba(0, 0, 0, 0.05)"},children:[C.jsxs("div",{style:{padding:"12px 16px",borderBottom:`1px solid ${l.colorBorderSecondary}`,display:"flex",alignItems:"center",justifyContent:"space-between",backgroundColor:`${l.colorFillQuaternary}e0`,backdropFilter:"blur(8px)",WebkitBackdropFilter:"blur(8px)"},children:[C.jsxs(rr,{size:"small",children:[C.jsx(_ie,{style:{color:l.colorPrimary,fontSize:16}}),C.jsx(Bo,{strong:!0,style:{fontSize:14},children:e.name}),C.jsx(Kr,{color:"blue",style:{margin:0,fontSize:10},children:"Config"})]}),C.jsxs(rr,{children:[i&&C.jsx(Gr,{title:"Delete Assistant",children:C.jsx(tn,{type:"text",size:"small",danger:!0,icon:C.jsx(IXe,{}),onClick:()=>A(!0)})}),C.jsx(tn,{type:"text",size:"small",icon:C.jsx(o4,{}),onClick:r})]})]}),C.jsx("div",{style:{flex:1,overflowY:"auto",padding:"16px 20px"},children:C.jsxs(Dr,{form:o,layout:"vertical",autoComplete:"off",children:[C.jsxs(Kte,{title:"Basic Settings",icon:C.jsx(_ie,{style:{color:l.colorPrimary}}),defaultExpanded:!0,children:[C.jsx(Dr.Item,{name:"name",label:"Name",rules:[{required:!0,message:"Please enter agent name"}],style:{marginBottom:8},children:C.jsx(Jn,{placeholder:"Enter agent name..."})}),C.jsx(Dr.Item,{name:"description",label:"Description",rules:[{required:!0,message:"Please enter agent description"}],style:{marginBottom:8},children:C.jsx(Jn.TextArea,{placeholder:"Enter agent description...",autoSize:{minRows:2,maxRows:4}})}),C.jsxs(Dr.Item,{name:"type",label:"Agent Type",rules:[{required:!0}],style:{marginBottom:8},children:[C.jsx(xx,{value:k,onChange:Y=>O(Y),options:[{value:"react",label:"Executor"},{value:"deep_agent",label:"Orchestrator"},{value:"team",label:"Team"}],block:!0}),C.jsx(Bo,{type:"secondary",style:{fontSize:11,marginTop:6,display:"block",lineHeight:1.4},children:k==="react"?"Executor: Directly executes tasks using tools. Best for single-step operations like search, code execution, and data retrieval.":k==="deep_agent"?"Orchestrator: Manages a sequential todo list to plan and assign todo items to sub-agents. Best for structured multi-step workflows.":"Team: Creates tasks with dependencies and dynamically spawns teammates. Like a swarm, teammates communicate via mailbox. Best for tasks requiring exploration and divergent thinking."})]}),C.jsxs(Dr.Item,{label:C.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[C.jsx("span",{children:"System Prompt"}),C.jsxs("div",{onClick:()=>R(!0),style:{cursor:"pointer",padding:"2px 8px",borderRadius:4,fontSize:11,color:l.colorPrimary,background:l.colorPrimaryBg,border:`1px solid ${l.colorPrimaryBorder}`,display:"flex",alignItems:"center",gap:4},children:[C.jsx(RXe,{style:{fontSize:10}}),C.jsx("span",{children:"Expand"})]})]}),children:[C.jsx(bsr,{value:w,onChange:Y=>T(Y.target.value),placeholder:"Enter the system prompt for this agent...",autoSize:{minRows:4,maxRows:8},style:{fontFamily:"monospace",fontSize:13,lineHeight:1.6}}),C.jsx(Bo,{type:"secondary",style:{fontSize:12,marginTop:4,display:"block"},children:"Define the agent's behavior, capabilities, and constraints"})]})]}),M.map(Y=>C.jsx(Csr,{middleware:Y,middlewareType:Ssr(Y.type,s.availableMiddlewareTypes),onToggle:()=>W(Y.id),onConfigChange:ee=>q(Y.id,ee),token:l},Y.id)),C.jsx(Kte,{title:"Common Tools",icon:C.jsx(bw,{style:{color:l.colorPrimary}}),badge:_.length,defaultExpanded:!1,children:u?C.jsx("div",{style:{textAlign:"center",padding:20},children:C.jsx(bl,{size:"small"})}):v.length===0?C.jsx(ai,{description:"No tools available",image:ai.PRESENTED_IMAGE_SIMPLE}):C.jsxs(C.Fragment,{children:[C.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:12},children:[C.jsxs(Bo,{type:"secondary",style:{fontSize:12},children:[_.length," of ",v.length," selected"]}),C.jsx(tn,{type:"link",size:"small",onClick:()=>x(_.length===v.length?[]:v.map(Y=>Y.id)),children:_.length===v.length?"Deselect All":"Select All"})]}),C.jsx(Ha,{dataSource:v,renderItem:Q,style:{maxHeight:"40vh",overflowY:"auto"},split:!1})]})}),C.jsx(Kte,{title:"Sub-Agents",icon:C.jsx(QHt,{style:{color:l.colorInfo}}),badge:S.length,defaultExpanded:!1,children:t.filter(Y=>Y.id!==e.id).length===0?C.jsx(ai,{description:"No other agents available",image:ai.PRESENTED_IMAGE_SIMPLE}):C.jsxs(C.Fragment,{children:[C.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:12},children:[C.jsxs(Bo,{type:"secondary",style:{fontSize:12},children:[S.length," of"," ",t.filter(Y=>Y.id!==e.id).length," ","selected"]}),C.jsx(tn,{type:"link",size:"small",onClick:()=>{const Y=t.filter(ee=>ee.id!==e.id).map(ee=>ee.id);E(S.length===Y.length?[]:Y)},children:S.length===t.filter(Y=>Y.id!==e.id).length?"Deselect All":"Select All"})]}),C.jsx(Ha,{dataSource:t.filter(Y=>Y.id!==e.id),renderItem:Z,style:{maxHeight:"40vh",overflowY:"auto"},split:!1})]})})]})}),C.jsxs("div",{style:{padding:"12px 20px",borderTop:`1px solid ${l.colorBorderSecondary}`,backgroundColor:l.colorFillQuaternary,display:"flex",justifyContent:"space-between",alignItems:"center"},children:[C.jsx(Bo,{type:"secondary",style:{fontSize:12},children:a?"Changes will be saved to the agent":"Viewing agent configuration"}),C.jsxs(rr,{children:[C.jsx(tn,{onClick:r,size:"small",children:"Close"}),a&&C.jsx(tn,{type:"primary",icon:C.jsx(PXe,{}),loading:f,onClick:F,size:"small",children:"Save"})]})]}),C.jsxs(Gi,{title:"System Prompt",open:N,onCancel:()=>R(!1),width:700,footer:null,styles:{body:{padding:"16px 24px"}},children:[C.jsx(Jn.TextArea,{value:w,onChange:Y=>T(Y.target.value),rows:12,style:{width:"100%",fontFamily:"monospace",fontSize:12,resize:"vertical",minHeight:200}}),C.jsxs("div",{style:{marginTop:12,display:"flex",justifyContent:"flex-end",gap:8},children:[C.jsx("div",{onClick:()=>R(!1),style:{padding:"6px 16px",borderRadius:4,cursor:"pointer",fontSize:12,border:`1px solid ${l.colorBorder}`,background:l.colorBgContainer},children:"Cancel"}),C.jsx("div",{onClick:()=>R(!1),style:{padding:"6px 16px",borderRadius:4,cursor:"pointer",fontSize:12,background:l.colorPrimary,color:"#fff"},children:"Done"})]})]}),C.jsx(Gi,{title:"Delete Assistant",open:m,onCancel:()=>A(!1),footer:[C.jsx(tn,{onClick:()=>A(!1),children:"Cancel"},"cancel"),C.jsx(tn,{type:"primary",danger:!0,loading:h,onClick:z,children:"Delete"},"delete")],children:C.jsxs(Bo,{children:["Are you sure you want to delete ",C.jsx(Bo,{strong:!0,children:e.name}),"? This action cannot be undone."]})})]})},Isr=Tsr,{Text:Rsr}=fr,Nsr=({onSelect:e,value:t,placeholder:n="Select a parent agent to extend..."})=>{const[r,a]=b.useState([]),[i,o]=b.useState(!1),{get:l}=_l();b.useEffect(()=>{(async()=>{var u;o(!0);try{const d=await l("/api/assistants");d.success&&a(((u=d.data)==null?void 0:u.records)||[])}catch(d){console.error("Failed to fetch assistants:",d)}finally{o(!1)}})()},[l]);const s=c=>{if(!c){e(null);return}const u=r.find(d=>d.id===c);e(u||null)};return C.jsx(Mf,{showSearch:!0,allowClear:!0,value:t,placeholder:n,loading:i,onChange:s,optionFilterProp:"label",style:{width:"100%"},options:r.map(c=>({value:c.id,label:c.name||c.id,description:c.description})),optionRender:c=>C.jsxs("div",{children:[C.jsx("div",{children:c.label}),c.data.description&&C.jsx(Rsr,{type:"secondary",style:{fontSize:12},children:c.data.description})]})})},{Text:aGe}=fr,Osr=({subAgentKeys:e,decisions:t,onChange:n})=>{const{token:r}=Xl.useToken(),a=(o,l)=>{const s=t.map(c=>c.originalKey===o?{...c,clone:l,cloneKey:l?`${o}_clone`:void 0}:c);n(s)},i=(o,l)=>{const s=t.map(c=>c.originalKey===o?{...c,cloneKey:l}:c);n(s)};return e.length===0?null:C.jsxs("div",{children:[C.jsx(aGe,{type:"secondary",style:{display:"block",marginBottom:8},children:"Choose how to handle each sub-agent from the parent:"}),C.jsx(Ha,{size:"small",bordered:!0,dataSource:t,style:{borderRadius:r.borderRadius},renderItem:o=>C.jsxs(Ha.Item,{style:{display:"flex",flexDirection:"column",alignItems:"stretch",gap:8,padding:"8px 16px"},children:[C.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[C.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[o.clone?C.jsx(kXe,{style:{color:r.colorPrimary}}):C.jsx(WN,{style:{color:r.colorTextSecondary}}),C.jsx(aGe,{style:{fontFamily:"monospace"},children:o.originalKey})]}),C.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[C.jsx(Kr,{color:o.clone?"blue":"default",children:o.clone?"Clone as new":"Reuse"}),C.jsx(vw,{size:"small",checked:o.clone,onChange:l=>a(o.originalKey,l)})]})]}),o.clone&&C.jsx(Jn,{size:"small",placeholder:"Enter key for the cloned agent",value:o.cloneKey,onChange:l=>i(o.originalKey,l.target.value),style:{fontFamily:"monospace",fontSize:12},addonBefore:"Key"})]})})]})},{TextArea:iGe}=Jn,{Text:_7}=fr,Msr=({open:e,onCancel:t,onSuccess:n})=>{var E;const[r]=Dr.useForm(),[a,i]=b.useState(!1),[o,l]=b.useState("scratch"),[s,c]=b.useState(null),[u,d]=b.useState([]),{get:f,post:p}=_l();Xl.useToken();const h=b.useCallback(()=>{c(null),d([])},[]),g=b.useCallback(w=>{if(c(w),!w){r.resetFields(["key","name","description","type","prompt"]),d([]);return}const T=typeof w.graphDefinition=="object"&&w.graphDefinition!==null?w.graphDefinition:{},N=T.key||w.id,R=w.name||T.name||"";r.setFieldsValue({key:`${N}_ext`,name:R?`${R} (Extended)`:"",description:w.description||T.description||"",type:T.type||"react",prompt:T.prompt||""});const k=T.subAgents||[];d(k.map(O=>({originalKey:O,clone:!1})))},[r]),m=b.useCallback(w=>{l(w),w==="scratch"&&(h(),r.resetFields())},[r,h]),A=async(w,T)=>{const N=await f(`/api/assistants/${w}`);if(!N.success)throw new Error(`Failed to fetch sub-agent "${w}" for cloning`);const R=N.data,k=typeof R.graphDefinition=="object"?R.graphDefinition:{},O={id:T,name:`${R.name} (Clone)`,description:R.description||"",graphDefinition:{...k,key:T,name:`${R.name} (Clone)`}},M=await p("/api/assistants",O);if(!M.success)throw new Error(M.message||`Failed to clone sub-agent "${w}"`);return M.data},v=w=>({id:w.key,name:w.name,description:w.description||"",graphDefinition:{key:w.key,name:w.name,description:w.description||"",type:w.type,prompt:w.prompt||"",tools:[],skills:[],subAgents:w.type==="deep_agent"?[]:void 0,middleware:[]}}),y=async(w,T)=>{if(!s)throw new Error("No parent agent selected");const N=u.filter(M=>M.clone);for(const M of N){if(!M.cloneKey||!M.cloneKey.trim())throw new Error(`Please provide a key for the cloned sub-agent "${M.originalKey}"`);if(!/^[a-zA-Z][a-zA-Z0-9_-]*$/.test(M.cloneKey))throw new Error(`Invalid key "${M.cloneKey}" for cloned sub-agent "${M.originalKey}". Key must start with a letter and contain only letters, numbers, underscores, or hyphens.`)}const R=[];for(const M of u)if(M.clone){const D=await A(M.originalKey,M.cloneKey);T.push(D),R.push(M.cloneKey)}else R.push(M.originalKey);const k=typeof s.graphDefinition=="object"?s.graphDefinition:{},O={key:w.key,name:w.name,description:w.description||"",extendsAgent:s.id,type:w.type||k.type};return w.prompt&&w.prompt!==k.prompt&&(O.prompt=w.prompt),(R.length>0||k.subAgents&&k.subAgents.length>0)&&(O.subAgents=R),{id:w.key,name:w.name,description:w.description||"",graphDefinition:O}},_=async()=>{try{const w=await r.validateFields();i(!0);const T=[],N=o==="scratch"?v(w):await y(w,T),R=await p("/api/assistants",N);if(R.success){vp.success({message:"Created",description:o==="extend"?`Assistant created by extending "${s==null?void 0:s.name}"`:"Assistant created successfully"}),r.resetFields(),h(),l("scratch");for(const k of T)n==null||n(k);n==null||n(R.data),t()}else bn.error(R.message||"Failed to create assistant")}catch(w){if(w.errorFields)return;bn.error(w.message||"An error occurred while creating the assistant")}finally{i(!1)}},x=((E=s==null?void 0:s.graphDefinition)==null?void 0:E.subAgents)||[],S=o==="extend"&&s&&x.length>0;return C.jsxs(Gi,{title:"Create New Assistant",open:e,onCancel:()=>{h(),l("scratch"),t()},footer:[C.jsx(tn,{onClick:()=>{h(),l("scratch"),t()},children:"Cancel"},"cancel"),C.jsx(tn,{type:"primary",icon:o==="extend"?C.jsx(kXe,{}):C.jsx(u5,{}),loading:a,onClick:_,children:o==="extend"?"Create (Extend)":"Create"},"submit")],width:600,children:[C.jsxs("div",{style:{marginBottom:20},children:[C.jsx(_7,{type:"secondary",style:{display:"block",marginBottom:8},children:"Creation Mode"}),C.jsx(xx,{value:o,onChange:m,options:[{value:"scratch",label:"From Scratch"},{value:"extend",label:"Extend Existing Agent"}],block:!0})]}),o==="extend"&&C.jsxs("div",{style:{marginBottom:20},children:[C.jsx(_7,{type:"secondary",style:{display:"block",marginBottom:8},children:"Parent Agent"}),C.jsx(Nsr,{value:s==null?void 0:s.id,onSelect:g}),s&&C.jsx(_7,{type:"secondary",style:{display:"block",marginTop:4,fontSize:12},children:"Fields left unchanged will be inherited from the parent agent."})]}),o==="extend"&&s&&C.jsx(D4,{style:{margin:"12px 0"}}),C.jsxs(Dr,{form:r,layout:"vertical",autoComplete:"off",initialValues:{type:"react"},children:[C.jsx(Dr.Item,{name:"key",label:"Key (ID)",rules:[{required:!0,message:"Please enter a unique key"},{pattern:/^[a-zA-Z][a-zA-Z0-9_-]*$/,message:"Key must start with a letter and contain only letters, numbers, underscores, or hyphens"}],style:{marginBottom:16},children:C.jsx(Jn,{placeholder:"e.g., my_assistant"})}),C.jsx(Dr.Item,{name:"name",label:"Name",rules:[{required:!0,message:"Please enter a name"}],style:{marginBottom:16},children:C.jsx(Jn,{placeholder:"e.g., My Assistant"})}),C.jsx(Dr.Item,{name:"description",label:"Description",rules:[{required:!0,message:"Please enter a description"}],style:{marginBottom:16},children:C.jsx(iGe,{placeholder:"Enter a description for this assistant...",autoSize:{minRows:2,maxRows:4}})}),C.jsx(Dr.Item,{name:"type",label:"Agent Type",rules:[{required:!0}],style:{marginBottom:16},children:C.jsx(xx,{options:[{value:"react",label:"Executor"},{value:"deep_agent",label:"Orchestrator"},{value:"team",label:"Team"}],block:!0})}),C.jsx(Dr.Item,{noStyle:!0,shouldUpdate:(w,T)=>w.type!==T.type,children:()=>{const w=r.getFieldValue("type"),T={react:"Executor: Directly executes tasks using tools. Best for single-step operations like search, code execution, and data retrieval.",deep_agent:"Orchestrator: Manages a sequential todo list to plan and assign todo items to sub-agents. Best for structured multi-step workflows.",team:"Team: Creates tasks with dependencies and dynamically spawns teammates. Like a swarm, teammates communicate via mailbox. Best for tasks requiring exploration and divergent thinking."};return C.jsx(_7,{type:"secondary",style:{fontSize:12,display:"block",marginTop:-12,marginBottom:16,lineHeight:1.5},children:T[w]||T.react})}}),C.jsx(Dr.Item,{name:"prompt",label:o==="extend"&&s?"System Prompt (leave unchanged to inherit from parent)":"System Prompt",rules:o==="scratch"?[{required:!0,message:"Please enter a system prompt"}]:[],children:C.jsx(iGe,{placeholder:o==="extend"&&s?"Leave empty to inherit parent's prompt, or enter a new prompt to override...":"Enter the system prompt for this agent...",autoSize:{minRows:4,maxRows:8},style:{fontFamily:"monospace",fontSize:13,lineHeight:1.6}})})]}),S&&C.jsxs(C.Fragment,{children:[C.jsx(D4,{style:{margin:"12px 0"}}),C.jsx(_7,{strong:!0,style:{display:"block",marginBottom:8},children:"Sub-Agents"}),C.jsx(Osr,{subAgentKeys:x,decisions:u,onChange:d})]})]})},ksr=Msr,Lsr=({onChat:e})=>{const{setCenter:t,fitView:n}=LC(),[r,a,i]=$ve([]),[o,l,s]=Fve([]),[c,u]=b.useState([]),[d,f]=b.useState(!1),[p,h]=b.useState(!1),[g,m]=b.useState(null),[A,v]=b.useState(!1),{get:y,del:_,put:x}=_l(),{config:S}=Zo(),{token:E}=Xl.useToken(),{enableAssistantCreation:w=!0,enableAssistantEditing:T=!0}=S,N=b.useMemo(()=>({assistant:ysr}),[]),R=b.useCallback(U=>{m(U),h(!0)},[]),k=b.useCallback(()=>{h(!1),m(null)},[]),O=b.useCallback(({nodes:U})=>{if(U.length===1&&T){const H=U[0].data;H!=null&&H.assistant&&(m(H.assistant),h(!0))}else U.length===0&&(h(!1),m(null))},[T]),M=async()=>{f(!0);try{const U=await y("/api/assistants");U.success&&U.data&&Array.isArray(U.data.records)&&u(U.data.records)}catch(U){console.error("Failed to fetch assistants:",U),u([])}finally{f(!1)}};b.useEffect(()=>{M()},[]),b.useEffect(()=>{if(!c||c.length===0){a([]),l([]);return}const U=[],H=[],G=320,F=300,z=Math.ceil(Math.sqrt(c.length)),W=new Map,q=[];if(c.forEach(Z=>{W.set(Z.id,Z)}),c.forEach(Z=>{if(Z.graphDefinition)try{const Y=typeof Z.graphDefinition=="string"?JSON.parse(Z.graphDefinition):Z.graphDefinition;Y.subAgents&&Array.isArray(Y.subAgents)&&Y.subAgents.forEach(ee=>{const ae=c.find(ne=>ne.id===ee||ne.id===String(ee));ae&&ae.id!==Z.id&&q.push({source:Z.id,target:ae.id})}),Y.internalSubAgents&&Array.isArray(Y.internalSubAgents)&&Y.internalSubAgents.forEach(ee=>{if(ee.key){const ae=c.find(ne=>ne.id===ee.key||ne.id===String(ee.key));ae&&ae.id!==Z.id&&q.push({source:Z.id,target:ae.id})}}),Y.nodes&&Array.isArray(Y.nodes)&&Y.nodes.forEach(ee=>{if(ee.assistantId&&ee.assistantId!==Z.id){const ae=c.find(ne=>ne.id===ee.assistantId||ne.id===String(ee.assistantId));ae&&q.push({source:Z.id,target:ae.id})}}),Y.edges&&Array.isArray(Y.edges)&&Y.edges.forEach(ee=>{if(ee.source&&ee.target){const ae=typeof ee.source=="string"?ee.source:ee.source.id||ee.source.assistantId,ne=typeof ee.target=="string"?ee.target:ee.target.id||ee.target.assistantId,te=c.find(pe=>pe.id===ae||pe.id===String(ae)),se=c.find(pe=>pe.id===ne||pe.id===String(ne));te&&se&&q.push({source:te.id,target:se.id})}})}catch(Y){console.warn(`Failed to parse graphDefinition for assistant ${Z.id}:`,Y)}}),q.length>0){const Z=new Set,Y=new Map,ee=new Map;q.forEach(se=>{ee.has(se.source)||ee.set(se.source,[]),ee.get(se.source).push(se.target)});const ae=[],ne=c.filter(se=>!q.some(pe=>pe.target===se.id));for(ne.length===0&&c.length>0?ae.push({id:c[0].id,level:0}):ne.forEach(se=>{ae.push({id:se.id,level:0})});ae.length>0;){const{id:se,level:pe}=ae.shift();if(Z.has(se))continue;Z.add(se),Y.set(se,pe),(ee.get(se)||[]).forEach(ie=>{Z.has(ie)||ae.push({id:ie,level:pe+1})})}c.forEach(se=>{Y.has(se.id)||Y.set(se.id,0)});const te=new Map;c.forEach(se=>{const pe=Y.get(se.id)||0;te.has(pe)||te.set(pe,[]),te.get(pe).push(se)}),te.forEach((se,pe)=>{const ue=pe*F,be=-((se.length-1)*G)/2;se.forEach((de,ve)=>{const he=be+ve*G;U.push({id:de.id,type:"assistant",data:{assistant:de,onConfigure:T?()=>R(de):void 0,onChat:e},position:{x:he,y:ue}})})}),q.forEach(se=>{W.has(se.source)&&W.has(se.target)&&H.push({id:`e${se.source}-${se.target}`,source:se.source,target:se.target,animated:!0,style:{stroke:"#1677ff"},type:"smoothstep"})})}else c.forEach((Z,Y)=>{const ee=Math.floor(Y/z),ne=Y%z*G-(z-1)*G/2,te=ee*F;U.push({id:Z.id,type:"assistant",data:{assistant:Z,onConfigure:T?()=>R(Z):void 0,onChat:e},position:{x:ne,y:te}})});a(U),l(H)},[c,a,l,R,e]);const D=async(U,H)=>{try{const F={...typeof U.graphDefinition=="string"?JSON.parse(U.graphDefinition||"{}"):U.graphDefinition||{},...H},z=await x(`/api/assistants/${U.id}`,{name:H.name??U.name,description:H.description??U.description,graphDefinition:F});if(z.success)u(W=>W.map(q=>q.id===U.id?{...q,name:H.name??U.name,description:H.description??U.description,graphDefinition:F}:q)),vp.success({message:"Saved",description:z.message||"Agent configuration saved successfully"});else throw bn.error(z.message||"Failed to save agent configuration"),new Error(z.message||"Failed to save agent configuration")}catch(G){throw console.error("Failed to save agent configuration:",G),bn.error(G instanceof Error?G.message:"Failed to save agent configuration"),G}},B=async U=>{try{const H=await _(`/api/assistants/${U.id}`);if(H.success)u(G=>G.filter(F=>F.id!==U.id)),(g==null?void 0:g.id)===U.id&&(m(null),h(!1)),vp.success({message:"Deleted",description:"Assistant deleted successfully"});else throw bn.error(H.message||"Failed to delete assistant"),new Error(H.message||"Failed to delete assistant")}catch(H){throw console.error("Failed to delete assistant:",H),bn.error(H instanceof Error?H.message:"Failed to delete assistant"),H}},$=U=>{u(H=>H.some(F=>F.id===U.id)?H.map(F=>F.id===U.id?U:F):[...H,U]),P.current=U};b.useEffect(()=>{if(g){const U=r.find(H=>H.id===g.id);U&&t(U.position.x+140,U.position.y+100,{zoom:1,duration:800})}},[g,r,t]),b.useEffect(()=>{c.length>0&&g&&c.find(H=>H.id===g.id)&&!p&&h(!0)},[c,g,p]);const P=b.useRef(null);return b.useEffect(()=>{if(P.current&&!c.find(U=>{var H;return U.id===((H=P.current)==null?void 0:H.id)})&&(P.current=null),P.current){const U=r.find(H=>H.id===P.current.id);U&&(t(U.position.x+140,U.position.y+100,{zoom:1,duration:800}),m(P.current),h(!0),P.current=null)}},[r,t]),d?C.jsx("div",{style:{width:"100%",height:"100%",display:"flex",justifyContent:"center",alignItems:"center",background:"#fafafa"},children:"Loading assistants..."}):C.jsxs("div",{style:{width:"100%",height:"100%",display:"flex"},children:[C.jsxs("div",{style:{flex:1,height:"100%",background:"#fafafa",position:"relative"},children:[C.jsxs(Pve,{nodes:r,edges:o,onNodesChange:i,onEdgesChange:s,onSelectionChange:O,nodeTypes:N,fitView:!0,children:[C.jsx(Uve,{color:"#eee",gap:20}),C.jsx(zve,{})]}),w&&C.jsx("div",{style:{position:"absolute",top:20,right:20,zIndex:10},children:C.jsx(tn,{type:"primary",size:"large",icon:C.jsx(u5,{}),onClick:()=>v(!0),style:{height:48,width:48,borderRadius:"50%",boxShadow:E.boxShadowTertiary,display:"flex",alignItems:"center",justifyContent:"center",padding:0}})})]}),C.jsx(Isr,{visible:p,assistant:g,allAssistants:c,onClose:k,onSave:D,onDelete:B}),C.jsx(ksr,{open:A,onCancel:()=>v(!1),onSuccess:$})]})},Dsr=e=>C.jsx(rF,{children:C.jsx(Lsr,{...e})}),Bsr=Dsr,{Text:tc}=fr,{TextArea:oGe}=Jn,Psr=e=>{const t=["#1890ff","#52c41a","#faad14","#f5222d","#722ed1","#13c2c2","#eb2f96","#fa8c16"];let n=0;for(let r=0;r<e.length;r++)n=e.charCodeAt(r)+((n<<5)-n);return t[Math.abs(n)%t.length]},$sr=({data:e})=>{var H;const{token:t}=Xl.useToken(),{config:n}=Zo(),{put:r}=_l(),a=v1("__GLOBAL__");if(!e)return null;const{skill:i,onClick:o,onDelete:l}=e;if(!i)return null;const[s,c]=b.useState(i),u=Psr(s.name),d=((H=s.name)==null?void 0:H.split("-").map(G=>G.charAt(0)).join("").toUpperCase().slice(0,2))||"SK",f=s.subSkills&&s.subSkills.length>0,p=s.metadata&&s.metadata.category||"global",h=b.useMemo(()=>s.metadata?Object.entries(s.metadata).filter(([G,F])=>G&&F):[],[s.metadata]),g=G=>{if(!G)return"";const F=G instanceof Date?G:new Date(G);return Number.isNaN(F.getTime())?"":F.toLocaleString()},m=G=>{navigator.clipboard.writeText(G)},[A,v]=b.useState(!1),[y,_]=b.useState({...i,id:i.name}),[x,S]=b.useState(h.map(([G,F])=>({key:G,value:F}))),[E,w]=b.useState(!1),[T,N]=b.useState(!1);b.useEffect(()=>{v(!1),c(i),_({...i,id:i.name}),S(Object.entries(i.metadata||{}).map(([G,F])=>({key:G,value:F})))},[i]);const R=(G,F)=>{if(G==="name"){_(z=>({...z,name:F,id:F}));return}_(z=>({...z,[G]:F}))},k=async G=>{G==null||G.stopPropagation(),G==null||G.preventDefault();try{const F=s.id||s.name;if(!F){bn.error("Skill ID is missing");return}await a.skills.delete(F),vp.success({message:"Deleted",description:"Skill deleted successfully"}),w(!1),l&&await l()}catch(F){bn.error((F==null?void 0:F.message)||"An error occurred while deleting the skill")}},O=G=>{S(G);const F=G.reduce((z,W)=>(W.key&&(z[W.key]=W.value),z),{});_(z=>({...z,metadata:F}))},M=(G,F,z)=>{const W=[...x];W[G]={...W[G],[F]:z},O(W)},D=()=>{O([...x,{key:"",value:""}])},B=async()=>{try{N(!0);const G={"Content-Type":"application/json"};n.apiKey&&(G.Authorization=`Bearer ${n.apiKey}`);const F={name:y.name,description:y.description,license:y.license||void 0,compatibility:y.compatibility||void 0,metadata:y.metadata||void 0,content:y.content||void 0,subSkills:y.subSkills||void 0},z=await r(`/api/skills/${s.id}`,F);if(z.success){vp.success({message:"Saved",description:"Skill updated successfully"});const W=z.data||y;c(W),_({...W,id:W.name}),S(Object.entries(W.metadata||{}).map(([q,Q])=>({key:q,value:Q}))),v(!1),o==null||o(W)}else bn.error(z.message||"Failed to update skill")}catch(G){bn.error(G.message||"An error occurred while updating the skill")}finally{N(!1)}},$=C.jsxs("div",{style:{display:"flex",flexDirection:"row",gap:24},children:[C.jsxs("div",{style:{flex:"0 0 320px",display:"flex",flexDirection:"column",gap:12},children:[C.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[C.jsx(tc,{style:{fontSize:12,color:t.colorTextSecondary},children:"Description"}),C.jsx(oGe,{value:y.description,onChange:G=>R("description",G.target.value),placeholder:"Description",rows:3})]}),C.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[C.jsx(tc,{style:{fontSize:12,color:t.colorTextSecondary},children:"License"}),C.jsx(Jn,{value:y.license,onChange:G=>R("license",G.target.value),placeholder:"License"})]}),C.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[C.jsx(tc,{style:{fontSize:12,color:t.colorTextSecondary},children:"Compatibility"}),C.jsx(Jn,{value:y.compatibility,onChange:G=>R("compatibility",G.target.value),placeholder:"Compatibility"})]}),C.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8},children:[C.jsx(tc,{style:{fontSize:12,color:t.colorTextSecondary,fontWeight:500},children:"Metadata"}),C.jsx(tn,{size:"small",icon:C.jsx(u5,{}),onClick:D,children:"Add"})]}),C.jsxs(rr,{direction:"vertical",size:8,style:{width:"100%"},children:[x.length===0&&C.jsx(tc,{style:{fontSize:11,color:t.colorTextTertiary},children:"No metadata yet. Use Add to create one."}),x.map((G,F)=>C.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:4,width:"100%"},children:[C.jsxs(tc,{style:{fontSize:11,color:t.colorTextSecondary},children:["Meta ",F+1]}),C.jsxs(rr,{style:{width:"100%"},size:8,wrap:!0,children:[C.jsx(Jn,{value:G.key,placeholder:"Key",style:{width:120},onChange:z=>M(F,"key",z.target.value)}),C.jsx(Jn,{value:G.value,placeholder:"Value",style:{flex:1,minWidth:160},onChange:z=>M(F,"value",z.target.value)})]})]},F))]})]}),C.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",gap:6,minWidth:400},children:[C.jsx(tc,{style:{fontSize:12,color:t.colorTextSecondary},children:"Content"}),C.jsx(oGe,{value:y.content,onChange:G=>R("content",G.target.value),placeholder:"Enter skill content here...",rows:30,style:{fontFamily:"monospace",fontSize:13,flex:1,minHeight:600}})]})]}),P=C.jsxs("div",{style:{width:A?960:720,maxHeight:"95vh",overflowY:"auto",padding:24},children:[C.jsx("div",{style:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",marginBottom:16},children:C.jsxs("div",{style:{flex:1},children:[C.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:8},children:[C.jsx(tc,{strong:!0,style:{fontSize:18,fontWeight:600,color:t.colorText},children:s.name}),C.jsx(Kr,{style:{margin:0,fontSize:10,padding:"2px 8px",fontWeight:600},color:"geekblue",children:p.toUpperCase()})]}),C.jsx("div",{style:{display:"flex",alignItems:"center",gap:6},children:C.jsx(tc,{style:{fontSize:11,color:t.colorTextTertiary,fontFamily:"monospace"},children:`>_ ${s.id}`})})]})}),A?$:C.jsxs(C.Fragment,{children:[s.description&&C.jsx("div",{style:{marginBottom:16},children:C.jsxs(tc,{style:{fontSize:12,color:t.colorText,lineHeight:1.6,fontStyle:"italic"},children:['"',s.description,'"']})}),h.length>0&&C.jsxs("div",{style:{marginBottom:16},children:[C.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:8},children:[C.jsx(Rx,{style:{fontSize:14,color:t.colorTextSecondary}}),C.jsxs(tc,{style:{fontSize:12,color:t.colorTextSecondary,fontWeight:500},children:["Metadata (",h.length,")"]})]}),C.jsx("div",{style:{border:`1px solid ${t.colorBorderSecondary}`,borderRadius:6,overflow:"hidden"},children:h.map(([G,F],z)=>C.jsxs("div",{style:{display:"flex",alignItems:"stretch",borderBottom:z===h.length-1?"none":`1px solid ${t.colorBorderSecondary}`},children:[C.jsx("div",{style:{width:140,padding:"8px 10px",background:t.colorFillTertiary,borderRight:`1px solid ${t.colorBorderSecondary}`,fontSize:11,color:t.colorTextSecondary,fontWeight:600,textTransform:"capitalize"},children:G}),C.jsx("div",{style:{flex:1,padding:"8px 10px",fontSize:11,color:t.colorText,wordBreak:"break-word"},children:F})]},G))})]}),f&&C.jsxs("div",{style:{marginBottom:16},children:[C.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:8},children:[C.jsx(jre,{style:{fontSize:14,color:t.colorTextSecondary}}),C.jsxs(tc,{style:{fontSize:12,color:t.colorTextSecondary,fontWeight:500},children:["Sub-Skills (",s.subSkills.length,")"]})]}),C.jsx(rr,{size:[8,8],wrap:!0,children:s.subSkills.map((G,F)=>C.jsx(Kr,{style:{fontSize:11,padding:"4px 12px",backgroundColor:t.colorFillTertiary,color:t.colorText,border:`1px solid ${t.colorBorderSecondary}`},children:G},F))})]}),(s.license||s.compatibility)&&C.jsx("div",{style:{marginBottom:16},children:C.jsxs(rr,{size:[8,8],wrap:!0,children:[s.license&&C.jsx(Kr,{icon:C.jsx(w8e,{}),style:{margin:0,fontSize:11,padding:"4px 12px",borderRadius:6,backgroundColor:t.colorInfoBg,color:t.colorInfo,border:`1px solid ${t.colorInfoBorder}`,fontWeight:500,lineHeight:"16px"},children:s.license}),s.compatibility&&C.jsx(Kr,{style:{margin:0,fontSize:11,padding:"4px 12px",borderRadius:6,backgroundColor:t.colorSuccessBg,color:t.colorSuccess,border:`1px solid ${t.colorSuccessBorder}`,fontWeight:500,lineHeight:"16px",display:"inline-flex",alignItems:"center",gap:4},children:s.compatibility})]})}),(s.createdAt||s.updatedAt)&&C.jsx("div",{style:{marginBottom:16},children:C.jsxs(rr,{direction:"vertical",size:4,children:[s.createdAt&&C.jsxs(tc,{style:{fontSize:11,color:t.colorTextTertiary,fontFamily:"monospace"},children:["Created: ",g(s.createdAt)]}),s.updatedAt&&C.jsxs(tc,{style:{fontSize:11,color:t.colorTextTertiary,fontFamily:"monospace"},children:["Updated: ",g(s.updatedAt)]})]})}),s.content&&C.jsxs("div",{style:{marginBottom:0},children:[C.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:8},children:[C.jsx(q2,{style:{fontSize:14,color:t.colorTextSecondary}}),C.jsx(tc,{style:{fontSize:12,color:t.colorTextSecondary,fontWeight:600,letterSpacing:.5},children:"CONTENT"})]}),C.jsx("div",{style:{padding:16,background:t.colorFillTertiary,border:`1px solid ${t.colorBorderSecondary}`,borderRadius:6,maxHeight:400,overflowY:"auto"},children:C.jsx(tc,{style:{fontSize:12,color:t.colorText,lineHeight:1.7,whiteSpace:"pre-wrap",fontFamily:"monospace"},children:s.content})})]})]}),C.jsx(D4,{style:{margin:"16px 0"}}),C.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8},children:A?C.jsxs(C.Fragment,{children:[C.jsx(tn,{block:!0,onClick:()=>{v(!1),_(i)},style:{flex:1},children:"Cancel"}),C.jsx(tn,{type:"primary",block:!0,onClick:B,loading:T,style:{flex:1},children:"Save"})]}):C.jsxs(C.Fragment,{children:[C.jsx(tn,{type:"primary",block:!0,onClick:()=>v(!0),style:{flex:1},children:"Edit Skill"}),C.jsx(tn,{danger:!0,onClick:G=>{G.stopPropagation(),k(G)},children:"Delete"}),C.jsx(tn,{icon:C.jsx(TXe,{}),onClick:()=>m(s.id),title:"Copy ID"})]})})]}),U={opacity:0,background:"transparent",border:"none",width:0,height:0,pointerEvents:"none"};return C.jsxs("div",{style:{padding:4},children:[C.jsx(j3,{type:"target",position:Br.Top,style:U,isConnectable:!1}),C.jsx("div",{onClick:()=>{w(!0)},style:{width:280,minHeight:200,background:t.colorBgContainer,borderRadius:8,boxShadow:"0 1px 6px rgba(0, 0, 0, 0.08)",cursor:o?"pointer":"default",overflow:"hidden",transition:"all 0.2s ease",position:"relative",border:`1px solid ${t.colorBorder}`,display:"flex",flexDirection:"column"},onMouseEnter:G=>{o&&(G.currentTarget.style.transform="translateY(-2px)",G.currentTarget.style.boxShadow="0 2px 8px rgba(0, 0, 0, 0.12)")},onMouseLeave:G=>{G.currentTarget.style.transform="translateY(0)",G.currentTarget.style.boxShadow="0 1px 4px rgba(0, 0, 0, 0.08)"},children:C.jsxs("div",{style:{padding:12,display:"flex",flexDirection:"column",gap:10},children:[C.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:10},children:[C.jsxs("div",{style:{position:"relative",flexShrink:0},children:[C.jsx(wg,{size:44,icon:C.jsx(wFt,{}),style:{backgroundColor:u,color:"#fff",fontSize:16,fontWeight:600},children:d}),f&&C.jsx("div",{style:{position:"absolute",bottom:-2,right:-2,width:18,height:18,borderRadius:"50%",background:t.colorPrimary,border:`2px solid ${t.colorBgContainer}`,display:"flex",alignItems:"center",justifyContent:"center"},children:C.jsx(jre,{style:{fontSize:10,color:"#fff"}})})]}),C.jsxs("div",{style:{flex:1,minWidth:0},children:[C.jsx(tc,{strong:!0,style:{fontSize:14,fontWeight:600,display:"block",marginBottom:3,color:t.colorText,lineHeight:1.3},ellipsis:{tooltip:s.name},children:s.name}),C.jsxs("div",{style:{display:"flex",alignItems:"center",gap:4},children:[C.jsx(q2,{style:{fontSize:9,color:t.colorTextTertiary}}),C.jsx(tc,{style:{fontSize:9,color:t.colorTextTertiary},ellipsis:{tooltip:s.id},children:s.id})]})]})]}),s.description&&C.jsx("div",{style:{padding:8,background:t.colorFillTertiary,border:`1px solid ${t.colorBorderSecondary}`,borderRadius:4,borderLeft:`2px solid ${u}`},children:C.jsx(Gr,{title:s.description.length>150?s.description:void 0,placement:"top",children:C.jsxs("div",{style:{fontSize:10,color:t.colorText,lineHeight:1.5,fontStyle:"italic",display:"-webkit-box",WebkitLineClamp:3,WebkitBoxOrient:"vertical",overflow:"hidden",textOverflow:"ellipsis",cursor:s.description.length>150?"help":"default"},children:['"',s.description,'"']})})}),C.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:4,padding:"4px 0",marginTop:"auto"},children:[C.jsx(Kr,{style:{margin:0,fontSize:8,padding:"2px 6px",borderRadius:6,backgroundColor:t.colorPrimaryBg,color:t.colorPrimary,border:`1px solid ${t.colorPrimaryBorder}`,fontWeight:600,lineHeight:"14px",textTransform:"capitalize"},children:p.toUpperCase()}),f&&C.jsxs(Kr,{style:{margin:0,fontSize:8,padding:"2px 6px",borderRadius:6,backgroundColor:t.colorSuccessBg,color:t.colorSuccess,border:`1px solid ${t.colorSuccessBorder}`,fontWeight:500,lineHeight:"14px",display:"inline-flex",alignItems:"center"},children:["SUB-SKILLS (",s.subSkills.length,")"]}),s.license&&C.jsx(Kr,{style:{margin:0,fontSize:7,padding:"2px 6px",borderRadius:6,backgroundColor:t.colorInfoBg,color:t.colorInfo,border:`1px solid ${t.colorInfoBorder}`,fontWeight:500,lineHeight:"14px"},icon:C.jsx(w8e,{}),children:s.license}),s.compatibility&&C.jsx(Kr,{style:{margin:0,fontSize:7,padding:"2px 6px",borderRadius:6,backgroundColor:t.colorSuccessBg,color:t.colorSuccess,border:`1px solid ${t.colorSuccessBorder}`,fontWeight:500,lineHeight:"14px"},icon:C.jsx(Rx,{}),children:s.compatibility})]})]})}),C.jsx(Gi,{open:E,onCancel:()=>{w(!1),v(!1),_({...s,id:s.name})},footer:null,width:A?1e3:760,destroyOnClose:!0,title:null,styles:{body:{padding:0}},children:P}),C.jsx(j3,{type:"source",position:Br.Bottom,style:U,isConnectable:!1})]})},Fsr=$sr,{TextArea:lGe}=Jn,{Text:bm}=fr,Usr=({open:e,onCancel:t,onSuccess:n})=>{const[r]=Dr.useForm(),[a,i]=b.useState(!1),{post:o}=_l(),{token:l}=Xl.useToken(),s=[{key:"category",value:"global"}],[c,u]=b.useState(s),d=async()=>{try{const g=await r.validateFields();i(!0);const m=c.length>0?c.reduce((y,_)=>(_.key&&(y[_.key]=_.value),y),{}):void 0,A={id:g.name,name:g.name,description:g.description,license:g.license||void 0,compatibility:g.compatibility||void 0,metadata:m,content:g.content||void 0,subSkills:void 0},v=await o("/api/skills",A);v.success?(vp.success({message:"Created",description:"Skill created successfully"}),r.resetFields(),u(s),n==null||n(),t()):bn.error(v.message||"Failed to create skill")}catch(g){if(g.errorFields)return;bn.error(g.message||"An error occurred while creating the skill")}finally{i(!1)}},f=()=>{r.resetFields(),u(s),t()},p=(g,m,A)=>{const v=[...c];v[g]={...v[g],[m]:A},u(v)},h=()=>{u([...c,{key:"",value:""}])};return C.jsx(Gi,{title:"Create New Skill",open:e,onCancel:f,footer:null,width:520,destroyOnClose:!0,styles:{body:{padding:16}},children:C.jsx(Dr,{form:r,layout:"vertical",onFinish:d,autoComplete:"off",children:C.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12},children:[C.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[C.jsx(bm,{style:{fontSize:12,color:l.colorTextSecondary},children:"Name"}),C.jsx(Dr.Item,{name:"name",rules:[{required:!0,message:"Please enter skill name"},{pattern:/^[a-z0-9]+(-[a-z0-9]+)*$/,message:"Name must be lowercase alphanumeric with single hyphens (e.g., 'my-skill')"},{min:1,max:64,message:"Name must be 1-64 characters"}],style:{marginBottom:0},children:C.jsx(Jn,{placeholder:"e.g., data-analysis"})})]}),C.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[C.jsx(bm,{style:{fontSize:12,color:l.colorTextSecondary},children:"Description"}),C.jsx(Dr.Item,{name:"description",rules:[{required:!0,message:"Please enter skill description"}],style:{marginBottom:0},children:C.jsx(lGe,{placeholder:"Description",autoSize:{minRows:2,maxRows:4}})})]}),C.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[C.jsx(bm,{style:{fontSize:12,color:l.colorTextSecondary},children:"License"}),C.jsx(Dr.Item,{name:"license",style:{marginBottom:0},children:C.jsx(Jn,{placeholder:"License"})})]}),C.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[C.jsx(bm,{style:{fontSize:12,color:l.colorTextSecondary},children:"Compatibility"}),C.jsx(Dr.Item,{name:"compatibility",style:{marginBottom:0},children:C.jsx(Jn,{placeholder:"Compatibility"})})]}),C.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[C.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8},children:[C.jsx(bm,{style:{fontSize:12,color:l.colorTextSecondary,fontWeight:500},children:"Metadata"}),C.jsx(tn,{size:"small",icon:C.jsx(u5,{}),onClick:h,children:"Add"})]}),C.jsxs(rr,{direction:"vertical",size:8,style:{width:"100%"},children:[c.length===0&&C.jsx(bm,{style:{fontSize:11,color:l.colorTextTertiary},children:"No metadata yet. Use Add to create one."}),c.map((g,m)=>C.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:4,width:"100%"},children:[C.jsxs(bm,{style:{fontSize:11,color:l.colorTextSecondary},children:["Meta ",m+1]}),C.jsxs(rr,{style:{width:"100%"},size:8,wrap:!0,children:[C.jsx(Jn,{value:g.key,placeholder:"Key",style:{width:140},onChange:A=>p(m,"key",A.target.value)}),C.jsx(Jn,{value:g.value,placeholder:"Value",style:{flex:1,minWidth:200},onChange:A=>p(m,"value",A.target.value)})]})]},m))]})]}),C.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[C.jsx(bm,{style:{fontSize:12,color:l.colorTextSecondary},children:"Content"}),C.jsx(Dr.Item,{name:"content",style:{marginBottom:0},children:C.jsx(lGe,{placeholder:"Content",autoSize:{minRows:4,maxRows:8}})})]}),C.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"flex-end",gap:8,marginTop:8},children:[C.jsx(tn,{onClick:f,children:"Cancel"}),C.jsx(tn,{type:"primary",htmlType:"submit",loading:a,children:"Create Skill"})]})]})})})},zsr=Usr,Hsr=({onNodeClick:e})=>{const[t,n,r]=$ve([]),[a,i,o]=Fve([]),[l,s]=b.useState(!1),[c,u]=b.useState([]),[d,f]=b.useState(!1),{token:p}=Xl.useToken(),{get:h}=_l(),g=b.useMemo(()=>({skill:Fsr}),[]),m=async()=>{f(!0);try{const v=await h("/api/skills");v.success&&v.data&&Array.isArray(v.data.records)&&u(v.data.records)}catch(v){console.error("Failed to fetch skills:",v),u([])}finally{f(!1)}};b.useEffect(()=>{m()},[]),b.useEffect(()=>{if(!c||c.length===0){n([]),i([]);return}const v=[],y=[],_=320,x=300,S=new Map,E=[],w=new Map;if(c.forEach(N=>{S.set(N.name,N),N.subSkills&&N.subSkills.length>0&&(w.has(N.name)||w.set(N.name,[]),N.subSkills.forEach(R=>{c.find(O=>O.name===R)&&(E.push({source:N.name,target:R}),w.get(N.name).push(R))}))}),E.length>0){const N=new Set,R=new Map,k=new Map;E.forEach(B=>{k.set(B.target,B.source)});const O=[],M=c.filter(B=>!k.has(B.name));for(M.length===0&&c.length>0?O.push({id:c[0].name,level:0}):M.forEach(B=>{O.push({id:B.name,level:0})});O.length>0;){const{id:B,level:$}=O.shift();if(N.has(B))continue;N.add(B),R.set(B,$),(w.get(B)||[]).forEach(U=>{N.has(U)||O.push({id:U,level:$+1})})}c.forEach(B=>{R.has(B.name)||R.set(B.name,0)});const D=new Map;c.forEach(B=>{const $=R.get(B.name)||0;D.has($)||D.set($,[]),D.get($).push(B)}),D.forEach((B,$)=>{const P=$*x,H=-((B.length-1)*_)/2;B.forEach((G,F)=>{const z=H+F*_;v.push({id:G.name,type:"skill",data:{skill:G,onClick:()=>e==null?void 0:e(G),onDelete:m},position:{x:z,y:P}})})}),E.forEach(B=>{S.has(B.source)&&S.has(B.target)&&y.push({id:`e${B.source}-${B.target}`,source:B.source,target:B.target,style:{stroke:"#1677ff",strokeWidth:2},type:"smoothstep"})})}else{const N=Math.ceil(Math.sqrt(c.length));c.forEach((R,k)=>{const O=Math.floor(k/N),D=k%N*_-(N-1)*_/2,B=O*x;v.push({id:R.name,type:"skill",data:{skill:R,onClick:()=>e==null?void 0:e(R)},position:{x:D,y:B}})})}n(v),i(y)},[c,n,i,e]);const A=async()=>{await m()};return d?C.jsx("div",{style:{width:"100%",height:"100%",display:"flex",justifyContent:"center",alignItems:"center",background:"#fafafa"},children:"Loading skills..."}):C.jsxs("div",{style:{width:"100%",height:"100%",background:"#fafafa",position:"relative"},children:[C.jsxs(Pve,{nodes:t,edges:a,onNodesChange:r,onEdgesChange:o,nodeTypes:g,fitView:!0,children:[C.jsx(Uve,{color:"#eee",gap:20}),C.jsx(zve,{})]}),C.jsx("div",{style:{position:"absolute",top:20,right:20,zIndex:10},children:C.jsx(tn,{type:"primary",size:"large",icon:C.jsx(u5,{}),onClick:()=>s(!0),style:{height:48,width:48,borderRadius:"50%",boxShadow:p.boxShadowTertiary,display:"flex",alignItems:"center",justifyContent:"center",padding:0}})}),C.jsx(zsr,{open:l,onCancel:()=>s(!1),onSuccess:A})]})},jsr=e=>C.jsx(rF,{children:C.jsx(Hsr,{...e})}),Gsr=jsr,Vsr=({onToolSelect:e,autoLoad:t=!0})=>{const{token:n}=Xl.useToken(),{get:r}=_l(),[a,i]=b.useState({tools:[],isLoading:!1,error:null}),[o,l]=b.useState(null),s=b.useCallback(async()=>{i(f=>({...f,isLoading:!0,error:null}));try{const f=await r("/api/tools");if(f.success&&f.data&&Array.isArray(f.data.records))i(p=>({...p,tools:f.data.records,isLoading:!1}));else throw new Error("Invalid response format")}catch(f){i(p=>({...p,tools:[],isLoading:!1,error:f instanceof Error?f:new Error(String(f))}))}},[r]),c=b.useCallback(f=>{l(f.id),e==null||e(f)},[e]),u=b.useCallback(()=>{s()},[s]);b.useEffect(()=>{t&&s()},[t,s]);const d={width:"100%",height:"100%",background:"transparent",borderRadius:n.borderRadius,padding:n.paddingSM};return a.error?C.jsx("div",{style:d,children:C.jsx(zh,{message:"Error Loading Tools",description:a.error.message,type:"error",showIcon:!0,action:C.jsx(tn,{size:"small",icon:C.jsx(xS,{}),onClick:u,children:"Retry"})})}):C.jsxs("div",{style:{position:"relative",width:"100%",height:"100%"},children:[C.jsx("div",{style:{position:"absolute",top:n.paddingSM,right:n.paddingSM,zIndex:1},children:C.jsx(tn,{type:"text",size:"small",icon:C.jsx(xS,{}),onClick:u,title:"Refresh tools",style:{color:n.colorTextSecondary}})}),C.jsx("div",{style:{width:"100%",height:"100%",overflowY:"auto",overflowX:"hidden",paddingTop:n.paddingLG},children:C.jsx(Ha,{dataSource:a.tools,loading:a.isLoading,locale:{emptyText:C.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:n.marginSM,padding:n.paddingLG},children:[C.jsx("div",{style:{color:n.colorTextSecondary},children:"No tools available"}),C.jsx(tn,{icon:C.jsx(xS,{}),onClick:u,type:"dashed",size:"small",children:"Refresh"})]})},style:{...d,paddingTop:0},renderItem:f=>C.jsx(Ha.Item,{onClick:()=>c(f),style:{cursor:"pointer",padding:n.paddingSM,borderRadius:n.borderRadius,backgroundColor:o===f.id?n.colorFillSecondary:"transparent",transition:"background-color 0.2s"},onMouseEnter:p=>{o!==f.id&&(p.currentTarget.style.backgroundColor=n.colorFillTertiary)},onMouseLeave:p=>{o!==f.id&&(p.currentTarget.style.backgroundColor="transparent")},children:C.jsx(Ha.Item.Meta,{avatar:C.jsx(wg,{size:"small",style:{backgroundColor:n.colorFillSecondary,color:n.colorText},children:f.name.charAt(0).toUpperCase()}),title:C.jsxs("div",{style:{display:"flex",alignItems:"center",gap:n.marginXS},children:[C.jsx("span",{children:f.name}),f.needUserApprove&&C.jsx(Kr,{color:"warning",style:{fontSize:"10px",padding:"2px 6px",margin:0,lineHeight:"1.2"},children:"Requires approval"})]}),description:C.jsx("div",{style:{color:n.colorTextSecondary,fontSize:n.fontSizeSM,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:f.description})})},f.id)})})]})},cv=e=>()=>C.jsx(e,{}),Wsr=({workspaceId:e,workspaceName:t,logo:n})=>{const{openContentApp:r,menuCollapsed:a,setMenuCollapsed:i}=pl(),o=b.useRef(!1),l=b.useRef(!1);b.useEffect(()=>{l.current||(l.current=!0,Mm("workspace_projects",{card_view:()=>null,side_app_view:cv(asr)}),Mm("workspace_metrics",{card_view:()=>null,side_app_view:cv(lsr)}),Mm("workspace_database",{card_view:()=>null,side_app_view:cv(dsr)}),Mm("workspace_assistants",{card_view:()=>null,side_app_view:cv(Bsr)}),Mm("workspace_skills",{card_view:()=>null,side_app_view:cv(Gsr)}),Mm("workspace_mcp",{card_view:()=>null,side_app_view:cv(gsr)}),Mm("workspace_tools",{card_view:()=>null,side_app_view:cv(()=>C.jsx(Vsr,{onToolSelect:E=>{console.log("Tool selected:",E)}}))}))},[]);const{user:s,logout:c,tenants:u,currentTenant:d,selectTenant:f,isLoading:p}=A1(),{setWorkspace:h,setProject:g}=lF(),[m,A]=b.useState(!1),[v,y]=b.useState(!1),_=b.useMemo(()=>[{id:"workspace_projects",type:"route",name:"Projects",icon:C.jsx(Nx,{size:20}),order:0},{id:"metrics",builtin:"metrics",type:"route",name:"Metrics",icon:C.jsx(sB,{size:20}),order:10,group:"DataSource"},{id:"database",builtin:"database",type:"route",name:"Database",icon:C.jsx(G0,{size:20}),order:20,group:"DataSource"},{id:"assistants",builtin:"assistants",type:"route",name:"Assistants",icon:C.jsx(Bie,{size:20}),order:30,group:"Settings"},{id:"skills",builtin:"skills",type:"route",name:"Skills",icon:C.jsx(cVt,{size:20}),order:35,group:"Settings"},{id:"mcp",builtin:"mcp",type:"route",name:"MCP",icon:C.jsx($ie,{size:20}),order:40,group:"Settings"},{id:"tools",builtin:"tools",type:"route",name:"Tools",icon:C.jsx(lVt,{size:20}),order:50,group:"Settings"},{id:"switch_tenant",builtin:"switch-tenant",type:"action",name:"Switch tenant",icon:C.jsx(wfe,{size:20}),order:900,group:"Account"}],[t]),x=E=>{if(E.type==="action"&&E.builtin==="switch-tenant"){A(!0);return}if(E.type==="route"){const T={workspace_projects:"workspace_projects",metrics:"workspace_metrics",database:"workspace_database",assistants:"workspace_assistants",skills:"workspace_skills",mcp:"workspace_mcp",tools:"workspace_tools"}[E.id];T&&r({component_key:T,data:{},message:E.name})}};b.useEffect(()=>{o.current||(o.current=!0,r({component_key:"workspace_projects",data:{},message:"Projects"}))},[r]);const S=C.jsxs("div",{style:{minWidth:160},children:[C.jsxs("div",{style:{padding:"8px 12px",borderBottom:"1px solid #f0f0f0"},children:[C.jsx("div",{style:{fontWeight:500},children:(s==null?void 0:s.name)||(s==null?void 0:s.email)}),C.jsx("div",{style:{fontSize:12,color:"#666"},children:s==null?void 0:s.email})]}),C.jsxs(tn,{type:"text",block:!0,style:{justifyContent:"flex-start",padding:"8px 12px"},onClick:()=>y(!0),children:[C.jsx(KXe,{size:16,style:{marginRight:8}}),"Change Password"]}),C.jsxs(tn,{type:"text",block:!0,danger:!0,style:{justifyContent:"flex-start",padding:"8px 12px"},onClick:c,children:[C.jsx(Tfe,{size:16,style:{marginRight:8}}),"Logout"]})]});return C.jsxs("div",{style:{display:"flex",flexDirection:"column",width:"100%",height:"100%"},children:[C.jsx(h3t,{menu:C.jsx(x3t,{items:_,onItemClick:x,logo:n,logoText:t||"Workspace",showToggle:!0,defaultExpanded:!0,collapsed:a,onCollapsedChange:i,footer:({isIconMode:E})=>{var w;return s&&C.jsx(L4,{content:S,placement:"rightTop",trigger:"click",children:C.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:E?"center":"flex-start",gap:E?0:12,padding:E?8:"12px 16px",cursor:"pointer",borderRadius:12,transition:"all 0.2s"},children:[C.jsx(wg,{size:E?32:36,style:{background:"linear-gradient(135deg, #6366f1 0%, #818cf8 100%)",color:"white",flexShrink:0},children:(((w=s.name)==null?void 0:w.charAt(0))||s.email.charAt(0)).toUpperCase()}),!E&&C.jsxs("div",{style:{flex:1,minWidth:0},children:[C.jsx("div",{style:{fontWeight:500,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:s.name||s.email}),C.jsx("div",{style:{fontSize:12,color:"#666",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:s.email})]})]})})}}),logo:n,main:C.jsx(B3t,{region:"content"})}),C.jsx(Gi,{open:m,onCancel:()=>A(!1),footer:null,width:520,closable:!1,styles:{mask:{backgroundColor:"transparent"},content:{backgroundColor:"transparent",boxShadow:"none"}},children:C.jsx(u3t,{tenants:u.map(E=>E.tenant).filter(Boolean),currentTenantId:d==null?void 0:d.id,onSelect:async E=>{await f(E.id),A(!1)},isLoading:p})}),C.jsx(d3t,{open:v,onClose:()=>y(!1)})]})},qsr=({workspaceId:e,workspaceName:t,logo:n})=>C.jsx(p3t,{children:C.jsx(Wsr,{workspaceId:e,workspaceName:t,logo:n})}),Yve=b.createContext(null),lF=()=>{const e=b.useContext(Yve);if(!e)throw new Error("useWorkspaceContext must be used within a WorkspaceContextProvider");return e},Qsr=({children:e})=>{const{currentTenant:t}=A1(),n=(t==null?void 0:t.id)||"",{config:r}=Zo();v1("__GLOBAL__");const a=()=>typeof window<"u"?sessionStorage.getItem("workspaceId"):null,i=()=>typeof window<"u"?sessionStorage.getItem("projectId"):null,[o,l]=b.useState(a),[s,c]=b.useState(i);oe.useEffect(()=>{const G=a(),F=i();(G||F)&&UM.setWorkspaceContext(G||void 0,F||void 0)},[]),b.useEffect(()=>{UM.setWorkspaceContext(o||void 0,s||void 0)},[o,s]);const[u,d]=b.useState([]),[f,p]=b.useState([]),[h,g]=b.useState(!1),[m,A]=b.useState(null),v=oe.useMemo(()=>new I$t({baseURL:r.baseURL,apiKey:r.apiKey||"",assistantId:"",transport:"sse"},n),[r.baseURL,r.apiKey,n]),y=b.useCallback(()=>{p([]),l(null),sessionStorage.removeItem("workspaceId"),c(null),sessionStorage.removeItem("projectId")},[p,l,c]),_=b.useCallback(()=>{d([]),y()},[y,d]);b.useEffect(()=>{_(),x()},[n]);const x=b.useCallback(async()=>{g(!0),A(null);try{const G=await v.listWorkspaces();d(G)}catch(G){A(G instanceof Error?G.message:"Failed to load workspaces")}finally{g(!1)}},[v]),S=b.useCallback(async G=>{const F=G||o;if(!F){p([]);return}g(!0),A(null);try{const z=await v.listProjects(F);p(z)}catch(z){A(z instanceof Error?z.message:"Failed to load projects")}finally{g(!1)}},[v,o]);b.useEffect(()=>{o&&typeof window<"u"&&sessionStorage.setItem("workspaceId",o)},[o]),b.useEffect(()=>{s&&typeof window<"u"&&sessionStorage.setItem("projectId",s)},[s]),b.useEffect(()=>{x().catch(G=>{console.warn("Failed to load workspaces:",G)})},[x]),b.useEffect(()=>{if(u.length>0&&!o){const G=u[0];l(G.id)}},[u,o]),b.useEffect(()=>{o?S(o):p([]),c(null)},[o,S]);const E=b.useCallback(async G=>{g(!0),A(null);try{const F=await v.createWorkspace(G);return await x(),F}catch(F){const z=F instanceof Error?F.message:"Failed to create workspace";throw A(z),F}finally{g(!1)}},[v,x]),w=b.useCallback(async(G,F)=>{g(!0),A(null);try{const z=await v.updateWorkspace(G,F);return await x(),z}catch(z){const W=z instanceof Error?z.message:"Failed to update workspace";throw A(W),z}finally{g(!1)}},[v,x]),T=b.useCallback(async G=>{g(!0),A(null);try{await v.deleteWorkspace(G),o===G&&y(),await x()}catch(F){const z=F instanceof Error?F.message:"Failed to delete workspace";throw A(z),F}finally{g(!1)}},[v,o,x]),N=b.useCallback(async(G,F)=>{g(!0),A(null);try{const z=await v.createProject(G,F);return await S(G),z}catch(z){const W=z instanceof Error?z.message:"Failed to create project";throw A(W),z}finally{g(!1)}},[v,S]),R=b.useCallback(async(G,F,z)=>{g(!0),A(null);try{const W=await v.updateProject(G,F,z);return await S(G),W}catch(W){const q=W instanceof Error?W.message:"Failed to update project";throw A(q),W}finally{g(!1)}},[v,S]),k=b.useCallback(async(G,F)=>{g(!0),A(null);try{await v.deleteProject(G,F),s===F&&c(null),await S(G)}catch(z){const W=z instanceof Error?z.message:"Failed to delete project";throw A(W),z}finally{g(!1)}},[v,s,S]),O=b.useCallback(async(G="/")=>{if(!o||!s)return[];g(!0),A(null);try{return await v.listPath(o,s,G)}catch(F){return A(F instanceof Error?F.message:"Failed to load files"),[]}finally{g(!1)}},[v,o,s]),M=b.useCallback(async G=>{const F=G.startsWith("/")?G:`/${G}`;return O(F)},[O]),D=b.useCallback(async(G,F)=>{if(!o||!s)throw new Error("Workspace and project must be selected before uploading files");g(!0),A(null);try{return await v.uploadFile(o,s,F,G)}catch(z){const W=z instanceof Error?z.message:"Failed to upload file";throw A(W),z}finally{g(!1)}},[v,o,s]),B=b.useCallback(async(G,F)=>D(G,F),[D]),$=b.useCallback(G=>!o||!s?"":v.getFileViewUrl(o,s,G),[v,o,s]),P={workspaceId:o,projectId:s,workspaces:u,projects:f,loading:h,error:m,setWorkspace:l,setProject:c,createWorkspace:E,updateWorkspace:w,deleteWorkspace:T,createProject:N,updateProject:R,deleteProject:k,refreshWorkspaces:x,refreshProjects:S,listPath:O,listPathByFolder:M,uploadFile:D,uploadFileToFolder:B,getFileViewUrl:$},U=u.find(G=>G.id===o),H=U==null?void 0:U.name;return C.jsx(Yve.Provider,{value:P,children:s?e:C.jsx(qsr,{workspaceId:o||"",workspaceName:H})})},Ysr=({senderRef:e,iconOnly:t})=>{const[n,r]=b.useState(!1),[a,i]=b.useState([]),[o,l]=b.useState(!1),[s,c]=b.useState([]),{get:u}=_l(),d=b.useRef(!1),f=async()=>{l(!0);try{const g=await u("/api/database-configs");g.success&&g.data&&Array.isArray(g.data.records)&&i(g.data.records)}catch(g){console.error("Failed to fetch databases:",g)}finally{l(!1)}},p=()=>{c([]),d.current||(f(),d.current=!0),r(!0)},h=()=>{s.forEach(g=>{var A,v;const m=a.find(y=>y.key===g);m&&e.current&&((v=(A=e.current).insert)==null||v.call(A,[{type:"tag",key:`db_${g}_${Date.now()}`,props:{label:C.jsxs(rr,{size:1,children:[C.jsx(G0,{size:10})," ",C.jsx(fr.Text,{children:m.name||g})]}),value:`[Database Scope:${m.name||g}]`}}],"cursor"))}),r(!1),c([])};return C.jsxs(C.Fragment,{children:[C.jsx(Gr,{title:t?"Database":void 0,children:C.jsx(tn,{icon:C.jsx(G0,{size:t?20:22}),onClick:p,type:"text",style:{height:32,width:t?32:void 0,borderRadius:8,padding:t?0:void 0,paddingLeft:t?0:16,paddingRight:t?0:16,display:"flex",alignItems:"center",justifyContent:"center",border:"none"},children:!t&&"Database"})}),C.jsx(Gi,{title:"Select Database",open:n,onOk:h,onCancel:()=>r(!1),width:600,okText:"Confirm",cancelText:"Cancel",children:o?C.jsx("div",{style:{textAlign:"center",padding:40},children:C.jsx(bl,{size:"large"})}):a.length===0?C.jsx(ai,{description:"No databases available",image:ai.PRESENTED_IMAGE_SIMPLE}):C.jsx(Ha,{dataSource:a,renderItem:g=>{const m=s.includes(g.key);return C.jsx(Ha.Item,{style:{padding:"12px 16px",cursor:"pointer",borderRadius:8,backgroundColor:m?"#f6ffed":"transparent",border:`1px solid ${m?"#52c41a":"transparent"}`,marginBottom:8,transition:"all 0.2s ease"},onClick:()=>{const A=m?s.filter(v=>v!==g.key):[...s,g.key];c(A)},children:C.jsx(Ha.Item.Meta,{avatar:C.jsx(Mc,{checked:m,onChange:()=>{const A=m?s.filter(v=>v!==g.key):[...s,g.key];c(A)},onClick:A=>A.stopPropagation()}),title:C.jsx(fr.Text,{strong:m,children:g.name||g.key}),description:g.description&&C.jsx(fr.Text,{type:"secondary",style:{fontSize:12},children:g.description})})},g.key)},style:{maxHeight:"50vh",overflowY:"auto"},split:!1})})]})},Ksr=({senderRef:e,iconOnly:t})=>{const[n,r]=b.useState(!1),[a,i]=b.useState([]),[o,l]=b.useState(!1),[s,c]=b.useState([]),{get:u}=_l(),d=b.useRef(!1),f=async()=>{l(!0);try{const g=await u("/api/skills");g.success&&g.data&&Array.isArray(g.data.records)&&i(g.data.records)}catch(g){console.error("Failed to fetch skills:",g)}finally{l(!1)}},p=()=>{c([]),d.current||(f(),d.current=!0),r(!0)},h=()=>{s.forEach(g=>{var A,v;const m=a.find(y=>y.id===g);m&&e.current&&((v=(A=e.current).insert)==null||v.call(A,[{type:"tag",key:`skill_${g}_${Date.now()}`,props:{label:C.jsxs(rr,{size:1,children:[C.jsx(H6,{size:12})," ",C.jsx(fr.Text,{children:m.name})]}),value:`[Use Skill:${m.name}]`}}],"cursor"))}),r(!1),c([])};return C.jsxs(C.Fragment,{children:[C.jsx(Gr,{title:t?"Skills":void 0,children:C.jsx(tn,{icon:C.jsx(H6,{size:t?20:22}),onClick:p,type:"text",style:{height:32,width:t?32:void 0,borderRadius:8,padding:t?0:void 0,paddingLeft:t?0:16,paddingRight:t?0:16,display:"flex",alignItems:"center",justifyContent:"center",border:"none"},children:!t&&"Skills"})}),C.jsx(Gi,{title:"Select Skills",open:n,onOk:h,onCancel:()=>r(!1),width:600,okText:"Confirm",cancelText:"Cancel",children:o?C.jsx("div",{style:{textAlign:"center",padding:40},children:C.jsx(bl,{size:"large"})}):a.length===0?C.jsx(ai,{description:"No skills available",image:ai.PRESENTED_IMAGE_SIMPLE}):C.jsx(Ha,{dataSource:a,renderItem:g=>{const m=s.includes(g.id);return C.jsx(Ha.Item,{style:{padding:"12px 16px",cursor:"pointer",borderRadius:8,backgroundColor:m?"#f6ffed":"transparent",border:`1px solid ${m?"#52c41a":"transparent"}`,marginBottom:8,transition:"all 0.2s ease"},onClick:()=>{const A=m?s.filter(v=>v!==g.id):[...s,g.id];c(A)},children:C.jsx(Ha.Item.Meta,{avatar:C.jsx(Mc,{checked:m,onChange:()=>{const A=m?s.filter(v=>v!==g.id):[...s,g.id];c(A)},onClick:A=>A.stopPropagation()}),title:C.jsx(fr.Text,{strong:m,children:g.name}),description:g.description&&C.jsx(fr.Text,{type:"secondary",style:{fontSize:12},children:g.description})})},g.id)},style:{maxHeight:"50vh",overflowY:"auto"},split:!1})})]})},Xsr=({senderRef:e,iconOnly:t})=>{const[n,r]=b.useState(!1),[a,i]=b.useState(!1),[o,l]=b.useState(null),{assistants:s,currentAssistant:c,selectAssistant:u}=Hve();b.useRef(!1);const d=()=>{l((c==null?void 0:c.id)||null),r(!0)},f=async()=>{o&&o!==(c==null?void 0:c.id)&&await u(o),r(!1)},p=h=>{l(h)};return C.jsxs(C.Fragment,{children:[C.jsx(Gr,{title:t?(c==null?void 0:c.name)||"Agent":void 0,children:C.jsx(tn,{icon:C.jsx(Bie,{size:t?20:22}),onClick:d,type:"text",style:{height:32,width:t?32:void 0,borderRadius:8,padding:t?0:void 0,paddingLeft:t?0:16,paddingRight:t?0:16,display:"flex",alignItems:"center",justifyContent:"center",border:"none"},children:!t&&((c==null?void 0:c.name)||"Agent")})}),C.jsx(Gi,{title:"Select Agent",open:n,onOk:f,onCancel:()=>r(!1),width:600,okText:"Confirm",cancelText:"Cancel",children:s.length===0?C.jsx(ai,{description:"No agents available",image:ai.PRESENTED_IMAGE_SIMPLE}):C.jsx(Ha,{dataSource:s,renderItem:h=>{const g=o===h.id;return C.jsx(Ha.Item,{style:{padding:"12px 16px",cursor:"pointer",borderRadius:8,backgroundColor:g?"#f6ffed":"transparent",border:`1px solid ${g?"#52c41a":"transparent"}`,marginBottom:8,transition:"all 0.2s ease"},onClick:()=>p(h.id),children:C.jsx(Ha.Item.Meta,{avatar:C.jsx("div",{style:{width:40,height:40,borderRadius:10,background:g?"#52c41a":"#f0f0f0",display:"flex",alignItems:"center",justifyContent:"center"},children:C.jsx(Bie,{size:20,color:g?"white":"#666"})}),title:C.jsx(fr.Text,{strong:g,children:h.name}),description:h.description&&C.jsx(fr.Text,{type:"secondary",style:{fontSize:12},children:h.description})})},h.id)},style:{maxHeight:"50vh",overflowY:"auto"},split:!1})})]})},sGe="metrics_datasource_selection",Zsr=({senderRef:e,iconOnly:t})=>{const[n,r]=b.useState(!1),[a,i]=b.useState(!1),[o,l]=b.useState([]),{config:s}=Zo(),{customRunConfig:c,updateCustomRunConfig:u}=y1(),{get:d}=_l(),f=b.useRef(!1),p=async()=>{var S,E;i(!0);try{const w=await d("/api/metrics-configs");if(!w.success||!((S=w.data)!=null&&S.records)){l([]);return}const T=w.data.records.filter(R=>{var k;return((k=R.config)==null?void 0:k.type)==="semantic"}),N=[];for(const R of T)try{const k=await d(`/api/metrics-configs/${R.key}/datasources`);if(k.success&&((E=k.data)!=null&&E.datasources)){const O=k.data.datasources.map(M=>({id:M.id,name:M.name,serverKey:R.key,serverName:R.name||R.key,connected:M.connected,description:M.description,schemaName:M.schemaName}));N.push(...O)}}catch(k){console.error(`Failed to fetch datasources for ${R.key}:`,k)}l(N)}catch(w){console.error("Failed to load metrics datasources:",w),l([])}finally{i(!1)}},h=()=>{p(),r(!0)},g=()=>{try{const S=sessionStorage.getItem(sGe);if(S){const E=JSON.parse(S);if(E.serverKey&&E.datasourceId)return u({metricsDataSource:{serverKey:E.serverKey,datasourceId:E.datasourceId}}),!0}}catch(S){console.error("Failed to restore datasource from sessionStorage:",S)}return!1},m=(S,E)=>{try{sessionStorage.setItem(sGe,JSON.stringify({serverKey:S,datasourceId:E}))}catch(w){console.error("Failed to save datasource to sessionStorage:",w)}};b.useEffect(()=>{f.current||(f.current=!0,p().then(()=>{const S=c==null?void 0:c.metricsDataSource;if(S){m(S.serverKey,S.datasourceId);return}g()||l(w=>(w.length>0&&r(!0),w))}))},[]);const A=()=>{const S=c==null?void 0:c.metricsDataSource;if(!S)return null;const{serverKey:E,datasourceId:w}=S;return o.find(T=>T.serverKey===E&&String(T.id)===String(w))},v=S=>{const E=c==null?void 0:c.metricsDataSource;return E?S.serverKey===E.serverKey&&String(S.id)===String(E.datasourceId):!1},y=S=>{S.connected&&(u({metricsDataSource:{serverKey:S.serverKey,datasourceId:S.id}}),m(S.serverKey,S.id),r(!1))},_=()=>{const S=A();return(S==null?void 0:S.name)||null},x=o.reduce((S,E)=>(S[E.serverName]||(S[E.serverName]=[]),S[E.serverName].push(E),S),{});return C.jsxs(C.Fragment,{children:[C.jsx(Gr,{title:t?_()||"Select Data Source":o.length===0?"No data sources available":void 0,children:C.jsx(tn,{icon:C.jsx(G0,{size:18}),onClick:h,type:"text",disabled:o.length===0,style:{height:32,width:t?32:void 0,borderRadius:8,padding:t?0:void 0,paddingLeft:t?0:12,paddingRight:t?0:12,display:"flex",alignItems:"center",justifyContent:"center",border:"none",fontSize:14},children:!t&&(_()||"Select Data Source")})}),C.jsx(Gi,{title:C.jsx("div",{style:{fontSize:16,fontWeight:600},children:"Select Metrics Data Source"}),open:n,onCancel:()=>r(!1),width:560,footer:null,styles:{body:{padding:"16px 20px",maxHeight:"60vh",overflowY:"auto"}},children:a?C.jsx("div",{style:{textAlign:"center",padding:40},children:C.jsx(bl,{size:"large"})}):o.length===0?C.jsx(ai,{description:"No Metrics Data Sources Available",image:ai.PRESENTED_IMAGE_SIMPLE}):C.jsx("div",{style:{display:"flex",flexDirection:"column",gap:24},children:Object.entries(x).map(([S,E])=>C.jsxs("div",{children:[C.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:12,paddingBottom:8,borderBottom:"1px solid #f0f0f0"},children:[C.jsx(eZe,{size:14,color:"#8c8c8c"}),C.jsx(fr.Text,{style:{fontSize:13,fontWeight:500,color:"#595959",textTransform:"uppercase",letterSpacing:"0.5px"},children:S}),C.jsx(Kr,{style:{fontSize:11,padding:"0 6px",lineHeight:"18px"},children:E.length})]}),C.jsx(Ha,{dataSource:E,renderItem:w=>{const T=w.connected,N=v(w);return C.jsx(Ha.Item,{style:{padding:"10px 12px",cursor:T?"pointer":"not-allowed",borderRadius:6,backgroundColor:N?"#f0f5ff":"transparent",border:N?"1px solid #2f54eb":"1px solid transparent",opacity:T?1:.5,marginBottom:6,transition:"all 0.15s ease"},onClick:()=>y(w),children:C.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",width:"100%"},children:[C.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[C.jsx("div",{style:{width:32,height:32,borderRadius:6,background:N?"#2f54eb":T?"#f5f5f5":"#f0f0f0",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:N?C.jsx(cB,{size:16,color:"#fff"}):C.jsx(G0,{size:16,color:T?"#595959":"#8c8c8c"})}),C.jsxs("div",{children:[C.jsx(fr.Text,{style:{fontSize:14,fontWeight:N?500:400,color:N?"#2f54eb":"#262626"},children:w.name}),!T&&C.jsx("div",{children:C.jsx(fr.Text,{style:{fontSize:12,color:"#8c8c8c"},children:"Disconnected"})})]})]}),N&&C.jsx(Kr,{color:"blue",style:{fontSize:11,padding:"0 8px",margin:0},children:"Selected"})]})},`${w.serverKey}-${w.id}`)},split:!1})]},S))})})]})},Jsr=({value:e,onChange:t,defaultModelKey:n="default",style:r})=>{const[a,i]=b.useState([]),[o,l]=b.useState(!1),[s,c]=b.useState(null),[u,d]=b.useState(!1),[f,p]=b.useState(!1),h=b.useRef(!1),g=b.useRef(!1),{get:m}=_l(),A=e!==void 0?e:s,v=b.useCallback(S=>{e===void 0&&c(S),t==null||t(S)},[e,t]),y=b.useCallback(async()=>{if(!h.current){h.current=!0,l(!0);try{const E=(await m("/api/models")).data||[];if(i(E),!g.current&&!A&&E.length>0){g.current=!0;const w=E.find(T=>T.key===n);w&&v({modelKey:w.key})}}catch(S){console.error("Failed to fetch models:",S)}finally{l(!1)}}},[m,n]);b.useEffect(()=>{y()},[y]);const _=S=>{v({modelKey:S}),d(!1)},x=a.find(S=>S.key===(A==null?void 0:A.modelKey));return x!=null&&x.displayName||x!=null&&x.model,C.jsx("div",{onMouseEnter:()=>p(!0),onMouseLeave:()=>p(!1),style:{display:"inline-block",borderRadius:8,backgroundColor:f?"rgba(0, 0, 0, 0.06)":"transparent",transition:"background-color 0.2s ease"},children:C.jsx(Mf,{variant:"borderless",value:A==null?void 0:A.modelKey,onChange:_,loading:o,open:u,onDropdownVisibleChange:d,style:{minWidth:80,...r},placeholder:"Model",suffixIcon:null,options:a.map(S=>({value:S.key,label:S.displayName||S.model})),dropdownMatchSelectWidth:!1})})},ecr={business_analysis:{icon:C.jsx(EXe,{}),color:"#1890FF",label:"Business Analysis"},code_generation:{icon:C.jsx(mf,{}),color:"#722ED1",label:"Code Generation"},document_processing:{icon:C.jsx(q2,{}),color:"#52C41A",label:"Document Processing"},data_analysis:{icon:C.jsx(hfe,{}),color:"#13C2C2",label:"Data Analysis"},tool_operation:{icon:C.jsx(bw,{}),color:"#FAAD14",label:"Tool Operations"},general:{icon:C.jsx(wXe,{}),color:"#FFD700",label:"General Skills"},global:{icon:C.jsx(LXe,{}),color:"#EB2F96",label:"Global Skills"}},cGe=e=>ecr[e]||{icon:C.jsx(R7,{}),color:"#8C8C8C",label:e},uGe=["#FFD700","#1890FF","#FF4D4F","#722ED1","#52C41A","#964B00","#FAAD14","#FF4D4F","#13C2C2","#EB2F96"],dGe=[C.jsx(wXe,{}),C.jsx(XHt,{}),C.jsx(Ojt,{}),C.jsx(c5,{}),C.jsx(lUt,{}),C.jsx(ojt,{}),C.jsx(Dzt,{}),C.jsx(EXe,{}),C.jsx(mf,{}),C.jsx(hfe,{})],tcr=({senderRef:e,visible:t=!0})=>{const[n,r]=b.useState([]),[a,i]=b.useState(!1),[o,l]=b.useState(!1),{get:s}=_l(),c=10;b.useEffect(()=>{t&&(async()=>{i(!0);try{const m=await s("/api/skills");m.success&&m.data&&Array.isArray(m.data.records)&&r(m.data.records)}catch(m){console.error("Failed to fetch skills:",m)}finally{i(!1)}})()},[s,t]);const u=b.useMemo(()=>{const g={};return n.forEach(m=>{var v;const A=((v=m.metadata)==null?void 0:v.category)||"global";g[A]||(g[A]=[]),g[A].push(m)}),g},[n]),d=g=>{var m,A;e.current&&((A=(m=e.current).insert)==null||A.call(m,[{type:"tag",key:`skill_${g.id}_${Date.now()}`,props:{label:C.jsxs(rr,{size:1,children:[C.jsx(H6,{size:12}),C.jsx(fr.Text,{children:g.name})]}),value:`[Use Skill:${g.name}]`}}],"cursor"))},f=()=>{l(!0)},p=()=>{const g=n.slice(0,c).map((m,A)=>({key:m.id,icon:C.jsx("span",{style:{color:uGe[A%uGe.length]},children:dGe[A%dGe.length]}),label:m.name}));return(n.length>c||Object.keys(u).length>1)&&g.push({key:"more",icon:C.jsx(Sfe,{style:{color:"#8C8C8C"}}),description:"View more skill categories"}),g},h=g=>g.map(m=>{var A,v,y;return{key:m.id,icon:C.jsx(H6,{size:16,style:{color:cGe(((A=m.metadata)==null?void 0:A.category)||"global").color}}),label:m.name,description:((v=m.description)==null?void 0:v.slice(0,60))+(((y=m.description)==null?void 0:y.length)>60?"...":"")}});return t?a?C.jsx("div",{style:{textAlign:"center",padding:40},children:C.jsx(bl,{size:"large"})}):n.length===0?null:o?C.jsx("div",{style:{padding:"0 16px",maxHeight:"calc(100% - 220px)",overflowY:"auto",overflowX:"hidden"},children:Object.entries(u).map(([g,m])=>{const A=cGe(g);return C.jsx("div",{style:{marginBottom:16},children:C.jsx(Z6,{title:C.jsxs(rr,{children:[C.jsx("span",{style:{color:A.color},children:A.icon}),C.jsx("span",{children:A.label})]}),items:h(m),onItemClick:v=>{const y=m.find(_=>_.id===v.data.key);y&&d(y)},wrap:!0,styles:{item:{flex:"none",width:"calc(50% - 6px)"}}})},g)})}):C.jsx("div",{style:{padding:"0 16px",maxHeight:"calc(100% - 220px)",overflowY:"auto",overflowX:"hidden"},children:C.jsx(Z6,{title:"✨ Quick actions",items:p(),onItemClick:g=>{if(g.data.key==="more")f();else{const m=n.find(A=>A.id===g.data.key);m&&d(m)}},wrap:!0,styles:{item:{flex:"none"}}})}):null},fGe={financial:C.jsx(SUt,{}),sales:C.jsx(pHt,{}),operations:C.jsx(bw,{})},pGe={financial:"#52C41A",sales:"#1890FF",operations:"#FA8C16"},Sv=e=>[{type:"text",value:e}],ncr=[{key:"sales",title:"Sales Analysis",items:[{key:"sales_comprehensive_analysis",label:"Comprehensive Sales Analysis",description:"Analyze sales revenue by specified dimensions with trend analysis and growth opportunities",content:[{type:"text",value:"Please analyze sales revenue of last "},{type:"select",key:"time_period",props:{options:["year","quarter","month","week"],defaultValue:"year"}},{type:"text",value:" by product group, customer and territory, indicate sales trend, concerns and growth opportunities."}]},{key:"sales_performance",label:"Sales Performance Analysis",description:"Aggregate omni-channel sales, evaluate performance achievement rate, and compare with historical growth",content:Sv("Please aggregate omni-channel sales, evaluate performance achievement rate, and compare with historical growth.")},{key:"sales_top_customers",label:"Top Customer Analysis",description:"Identify top 10% customers by sales volume, analyze their purchase preferences and churn risks",content:[{type:"text",value:"Please identify the top "},{type:"input",key:"percentage_threshold",props:{placeholder:"10%",defaultValue:"10%"}},{type:"text",value:" customers by sales volume, analyze their purchase preferences and churn risks."}]},{key:"sales_trend",label:"Sales Trend Analysis",description:"Analyze sales peaks and troughs through time series, forecast sales trends for the next quarter",content:[{type:"text",value:"Please analyze sales peaks and troughs through time series, and forecast sales trends for "},{type:"input",key:"forecast_period",props:{placeholder:"the next quarter",defaultValue:"the next quarter"}},{type:"text",value:"."}]},{key:"sales_rep_performance",label:"Sales Representative Performance",description:"Quantitatively evaluate conversion rates, average order value, and contract fulfillment efficiency of each sales representative",content:Sv("Please quantitatively evaluate conversion rates, average order value, and contract fulfillment efficiency of each sales representative.")},{key:"sales_regional",label:"Regional Sales Comparison",description:"Compare sales penetration across different geographic regions, identify markets with abnormal performance",content:[{type:"text",value:"Please compare sales penetration across "},{type:"input",key:"geographic_scope",props:{placeholder:"different geographic regions",defaultValue:"different geographic regions"}},{type:"text",value:", and identify markets with abnormal performance."}]},{key:"sales_product_volume",label:"Product Volume Analysis",description:"Count sales quantities of each SKU, identify best-selling products and slow-moving inventory",content:[{type:"text",value:"Please count sales quantities of "},{type:"input",key:"product_identifier",props:{placeholder:"each SKU",defaultValue:"each SKU"}},{type:"text",value:", and identify best-selling products and slow-moving inventory."}]}]},{key:"financial",title:"Financial Analysis",items:[{key:"financial_gross_margin",label:"Product Line Gross Margin Analysis",description:"Compare gross margin levels across product lines, identify high-margin contributors and loss-making businesses",content:[{type:"text",value:"Please analyze the gross margin levels of "},{type:"input",key:"product_scope",props:{placeholder:"each product line",defaultValue:"each product line"}},{type:"text",value:", identify high-margin contributors and loss-making businesses, and provide optimization suggestions."}]},{key:"financial_customer_profitability",label:"Customer Profitability Analysis",description:"Analyze net profit contribution by different customer dimensions, identify core high-quality customers and high-service-cost customers",content:[{type:"text",value:"Please analyze the net profit contribution by "},{type:"input",key:"customer_dimension",props:{placeholder:"different customer dimensions",defaultValue:"different customer dimensions"}},{type:"text",value:", identify core high-quality customers and high-service-cost customers, and propose customer tier management recommendations."}]},{key:"financial_monthly_report",label:"Monthly Financial Report",description:"Based on this month's accounting data, automatically generate income statement, balance sheet, and cash flow statement summaries",content:[{type:"text",value:"Please generate income statement, balance sheet, and cash flow statement summaries based on "},{type:"input",key:"time_period",props:{placeholder:"this month's",defaultValue:"this month's"}},{type:"text",value:" accounting data, and analyze key financial indicators."}]},{key:"financial_ratio",label:"Financial Ratio Analysis",description:"Calculate and analyze key indicators such as current ratio, debt-to-asset ratio, and ROE to assess company financial health",content:Sv("Please calculate and analyze key financial indicators such as current ratio, debt-to-asset ratio, and ROE to assess company financial health.")},{key:"financial_cashflow",label:"Cash Flow Analysis",description:"Track cash flows from operating, investing, and financing activities, analyze reasons for changes in net cash flow",content:Sv("Please track cash flows from operating, investing, and financing activities, and analyze the reasons and trends for changes in net cash flow.")},{key:"financial_cost_structure",label:"Cost Structure Analysis",description:"Break down direct costs and indirect expenses of products or services, identify core drivers affecting total costs",content:[{type:"text",value:"Please break down direct costs and indirect expenses of "},{type:"input",key:"cost_object",props:{placeholder:"products or services",defaultValue:"products or services"}},{type:"text",value:", and identify core drivers affecting total costs."}]}]},{key:"operations",title:"Operations Analysis",items:[{key:"ops_supplier_evaluation",label:"Supplier Performance Evaluation",description:"Based on delivery quality, response speed, and price competitiveness, conduct comprehensive rating of core suppliers",content:[{type:"text",value:"Please conduct comprehensive rating of "},{type:"input",key:"supplier_scope",props:{placeholder:"core suppliers",defaultValue:"core suppliers"}},{type:"text",value:" based on delivery quality, response speed, and price competitiveness."}]},{key:"ops_inventory_turnover",label:"Inventory Turnover Analysis",description:"Calculate inventory turnover rate and days, identify slow-moving inventory materials to release capital",content:Sv("Please calculate inventory turnover rate and days, and identify slow-moving inventory materials to release capital.")},{key:"ops_delivery_ontime",label:"On-Time Delivery Analysis",description:"Count order lead time from placement to delivery, analyze core links causing delayed deliveries",content:Sv("Please count order lead time from placement to delivery, and analyze core links causing delayed deliveries.")},{key:"ops_procurement_cost",label:"Procurement Cost Analysis",description:"Monitor raw material procurement price fluctuations, analyze impact of procurement premiums or savings on profit",content:[{type:"text",value:"Please monitor "},{type:"input",key:"procurement_category",props:{placeholder:"raw material",defaultValue:"raw material"}},{type:"text",value:" procurement price fluctuations, and analyze impact of procurement premiums or savings on profit."}]},{key:"ops_production_efficiency",label:"Production Efficiency Analysis",description:"Calculate Overall Equipment Effectiveness (OEE) or per capita output, identify efficiency bottlenecks on production lines",content:[{type:"text",value:"Please calculate Overall Equipment Effectiveness (OEE) or per capita output, and identify efficiency bottlenecks on "},{type:"input",key:"production_scope",props:{placeholder:"production lines",defaultValue:"production lines"}},{type:"text",value:"."}]},{key:"ops_order_fulfillment",label:"Order Fulfillment Analysis",description:"Analyze the full process from order receipt to final delivery, optimize order processing response time",content:[{type:"text",value:"Please analyze the full process from order receipt to final delivery, and optimize "},{type:"input",key:"optimization_target",props:{placeholder:"order processing response time",defaultValue:"order processing response time"}},{type:"text",value:"."}]}]}],hGe=["#1890FF","#52C41A","#FAAD14","#722ED1","#13C2C2","#EB2F96","#FA541C","#2F54EB"],rcr=({visible:e=!0,disabled:t=!1,onItemClick:n,maxSimpleItems:r=8,simpleModeTitle:a="Quick Analysis",expandModeTitle:i="Analysis Categories"})=>{var p;const[o,l]=b.useState(!1),{config:s}=Zo(),c=b.useMemo(()=>{const h=s.quickPromptsData;return h&&Array.isArray(h)&&h.length>0?h.map(g=>({...g,icon:g.icon||fGe[g.key]||C.jsx(R7,{}),color:g.color||pGe[g.key]||"#8C8C8C",items:g.items.map(m=>({...m,content:typeof m.content=="string"?Sv(m.content):m.content}))})):ncr.map(g=>({...g,icon:fGe[g.key]||C.jsx(R7,{}),color:pGe[g.key]||"#8C8C8C"}))},[s.quickPromptsData]),u=b.useMemo(()=>{const h=[];return c.forEach(g=>{g.items.forEach(m=>{h.push({...m,icon:m.icon||g.icon})})}),h},[c]),d=()=>{const h=u.slice(0,r).map((g,m)=>({key:g.key,icon:C.jsx("span",{style:{color:hGe[m%hGe.length]},children:g.icon||C.jsx(R7,{})}),label:g.label}));return(u.length>r||c.length>1)&&h.push({key:"more",icon:C.jsx(Sfe,{style:{color:"#8C8C8C"}}),description:"View more analysis options"}),h},f=h=>h.map(g=>({key:g.key,icon:C.jsx("span",{style:{color:"#8C8C8C"},children:g.icon||C.jsx(R7,{})}),label:g.label,description:g.description}));return e?o?C.jsx("div",{style:{padding:"16px",maxWidth:"800px",margin:"0 auto"},children:C.jsx(fw,{defaultActiveKey:(p=c[0])==null?void 0:p.key,items:c.map(h=>({key:h.key,label:C.jsxs(rr,{children:[C.jsx("span",{style:{color:h.color},children:h.icon}),C.jsx("span",{children:h.title})]}),children:C.jsx(Z6,{items:f(h.items),onItemClick:g=>{const m=h.items.find(A=>A.key===g.data.key);m&&n&&n(m)},wrap:!0,styles:{item:{flex:"none",width:"calc(50% - 8px)",minWidth:"280px"}}})}))})}):C.jsx("div",{style:{padding:"16px",maxWidth:"800px",margin:"0 auto"},children:C.jsx(Z6,{title:a,items:d(),onItemClick:h=>{if(h.data.key==="more")l(!0);else{const g=u.find(m=>m.key===h.data.key);g&&n&&n(g)}},wrap:!0,styles:{item:{flex:"none",width:"calc(50% - 8px)",minWidth:"280px"}}})}):null},acr=[],Kve=({avatar:e,name:t,description:n,default_submit_message:r,senderPromptsItems:a,extra:i,attachment_placeholder:o,extraMeta:l=[],uploadAction:s,showHeader:c=!0,showSender:u=!0,showHITL:d=!0,showRefreshButton:f=!1,showModelSelector:p,showEmptyState:h=!0,emptyStateGreeting:g,emptyStateQuestion:m="Ready to turn data into insightful charts in seconds?",welcomePrefix:A="Hey"})=>{var _t,Bt;const[v,y]=b.useState(""),[_,x]=b.useState([]),{styles:S}=DC(),[E,w]=b.useState(!1),T=b.useRef(null),N=oe.useRef(null),{assistantId:R,threadId:k,messages:O,sendMessage:M,abortAgent:D,loadMessages:B,isLoading:$,error:P,interrupts:U,tenantId:H,clearError:G,pendingMessages:F,updateCustomRunConfig:z}=Gs(),W=$,q=(F==null?void 0:F.length)>0,Q=U&&U.length>0,Z=["⠋","⠙","⠹","⠸","⠼","⠴","⠦","⠧","⠇","⠏"],[Y,ee]=b.useState(0);b.useEffect(()=>{if(!W)return;const Ct=setInterval(()=>{ee(Kt=>(Kt+1)%Z.length)},80);return()=>clearInterval(Ct)},[W]);const ae=y1(),[ne,te]=b.useState(null),se=b.useCallback(Ct=>{te(Ct),Ct&&z({modelConfig:Ct})},[z]),[pe,ue]=b.useState(h&&O.length===0&&!(F!=null&&F.length)),[ie,be]=b.useState(!1);b.useEffect(()=>{if(!h){ue(!1);return}const Ct=O.length===0&&!(F!=null&&F.length);!Ct&&pe?(be(!0),setTimeout(()=>{ue(!1),be(!1)},400)):Ct&&!pe&&ue(!0)},[O.length,F==null?void 0:F.length,pe,h]);const{config:de}=Zo(),{baseURL:ve}=de,he=(_t=Mor())==null?void 0:_t.user,fe=(he==null?void 0:he.name)||((Bt=he==null?void 0:he.email)==null?void 0:Bt.split("@")[0])||"there",me=b.useContext(Yve);me==null||me.listPath;const Se=(me==null?void 0:me.listPathByFolder)??(async()=>[]),xe=(me==null?void 0:me.workspaceId)??null,$e=(me==null?void 0:me.projectId)??null,[Fe,et]=b.useState([]),[rt,We]=b.useState(!1),[ct,De]=b.useState(!1),Ve=Ct=>{var rn;const Kt=(rn=Ct.split(".").pop())==null?void 0:rn.toLowerCase(),$t={fontSize:16};switch(Kt){case"png":case"jpg":case"jpeg":case"gif":case"svg":case"webp":return C.jsx(vfe,{style:{...$t,color:"#52c41a"}});case"pdf":return C.jsx(iB,{style:{...$t,color:"#ff4d4f"}});case"md":case"markdown":return C.jsx(NXe,{style:{...$t,color:"#722ed1"}});case"zip":case"rar":case"7z":return C.jsx(bfe,{style:{...$t,color:"#faad14"}});case"xls":case"xlsx":case"csv":return C.jsx(Afe,{style:{...$t,color:"#52c41a"}});case"ppt":case"pptx":return C.jsx(OXe,{style:{...$t,color:"#fa8c16"}});case"doc":case"docx":return C.jsx(yfe,{style:{...$t,color:"#2f54eb"}});case"txt":return C.jsx(q2,{style:{...$t,color:"#8c8c8c"}});default:return C.jsx(oB,{style:{...$t,color:"#bfbfbf"}})}},Ge=async()=>{var Ct;We(!0);try{const $t=((Ct=de.resourceFolders)!=null&&Ct.length?de.resourceFolders:[{name:"/",displayName:"Root Directory",allowUpload:!0}]).map(async on=>{try{return(await Se(on.name)).filter($n=>!$n.is_dir)}catch(Tn){return console.error(`Failed to load files from folder ${on.name}:`,Tn),[]}}),qt=(await Promise.all($t)).flat();et(qt)}catch(Kt){console.error("Failed to load workspace files:",Kt),et([])}finally{We(!1)}};b.useEffect(()=>{Mm("action_show_attachments_uploader",{card_view:()=>null,action:Ct=>{console.log(Ct),w(!0)}})},[]);const Xe=Ct=>{const Kt=["application/zip"],$t=["application/vnd.rar","application/x-rar-compressed","application/rar"];return[...Kt,...$t].includes(Ct.type)||Ct.name.toLowerCase().endsWith(".zip")||Ct.name.toLowerCase().endsWith(".rar")},at=Ct=>{var rn,qt;if(!Ct&&_.length===0)return;if(_.filter(on=>on.status!=="done").length>0){bn.warning("Files are still uploading...");return}!Ct&&_.length>0&&(Ct=r||"");const Kt=_.map(on=>{var Tn,$n;return Xe(on)?{name:on.response.zipFileName||on.response.rarFileName,id:on.response.zipFileId||on.response.rarFileId,totalFiles:on.response.totalFiles,processedFiles:on.response.processedFiles,skippedFiles:on.response.skippedFiles,type:on.name.toLowerCase().endsWith(".rar")?"application/rar":"application/zip",files:($n=(Tn=on.response)==null?void 0:Tn.results)==null?void 0:$n.map(Kn=>({name:Kn.fileName,path:Kn.filePath,id:Kn.fileId}))}:{name:on.name,id:on.response.id}}),$t=Kt.length>0?["","我已经提交了以下文件:","```attachments",JSON.stringify(Kt),"```"].join(`
4011
+ /path/to/files`,rows:4,style:{width:"100%",marginTop:8,fontFamily:"monospace"}})]})]}):C.jsxs("div",{children:[C.jsx(ml,{strong:!0,children:"Server URL"}),C.jsx(Jn,{value:A.url,onChange:O=>v({...A,url:O.target.value}),placeholder:"e.g., http://localhost:3000",style:{width:"100%",marginTop:8}})]}),C.jsx(s5,{ghost:!0,children:C.jsx(hsr,{header:"Advanced Options",children:C.jsxs(rr,{direction:"vertical",style:{width:"100%"},size:"middle",children:[C.jsxs("div",{children:[C.jsx(ml,{strong:!0,children:"Timeout (ms)"}),C.jsx(Jn,{type:"number",value:A.timeout,onChange:O=>v({...A,timeout:parseInt(O.target.value)||3e4}),style:{width:"100%",marginTop:8}})]}),C.jsxs("div",{children:[C.jsx(ml,{strong:!0,children:"Retry Attempts"}),C.jsx(Jn,{type:"number",value:A.retryAttempts,onChange:O=>v({...A,retryAttempts:parseInt(O.target.value)||3}),style:{width:"100%",marginTop:8}})]})]})},"1")})]});case 1:return p?C.jsxs("div",{style:{textAlign:"center",padding:"60px 0"},children:[C.jsx(bl,{size:"large"}),C.jsx("div",{style:{marginTop:16},children:C.jsx(ml,{children:"Connecting to MCP server and fetching tools..."})})]}):g.length===0?C.jsx("div",{style:{textAlign:"center",padding:"40px 0"},children:C.jsx(ml,{type:"secondary",children:"No tools available. Please check your connection settings."})}):C.jsxs("div",{children:[C.jsxs("div",{style:{marginBottom:16},children:[C.jsx(ml,{strong:!0,children:"Available Tools"}),C.jsx("div",{style:{marginTop:4},children:C.jsxs(ml,{type:"secondary",style:{fontSize:12},children:["Selected: ",A.selectedTools.length," / ",g.length]})})]}),C.jsx("div",{style:{overflowY:"auto",maxHeight:"450px"},children:g.map(O=>{const M=A.selectedTools.includes(O.name);return C.jsx(Ri,{size:"small",style:{marginBottom:8,borderColor:M?o.colorPrimary:void 0},bodyStyle:{padding:12},children:C.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:12},children:[C.jsx(Mc,{checked:M,onChange:()=>E(O.name),style:{marginTop:4}}),C.jsxs("div",{style:{flex:1,minWidth:0},children:[C.jsx(ml,{strong:!0,style:{fontSize:14},children:O.name}),O.description&&C.jsx(ml,{type:"secondary",style:{fontSize:12,marginTop:4,display:"block"},children:O.description}),O.inputSchema&&C.jsx("div",{style:{marginTop:8},children:C.jsxs(ml,{type:"secondary",style:{fontSize:11},children:["Parameters: ",Object.keys(O.inputSchema.properties||{}).join(", ")]})})]})]})},O.name)})})]});default:return null}},N=()=>{c===1?S():u(O=>O+1)},R=()=>{u(O=>O-1)};return C.jsx(Gi,{title:t?"Edit MCP Server Configuration":"Add MCP Server Configuration",open:e,onCancel:r,width:700,style:{top:50},footer:null,children:C.jsxs("div",{children:[C.jsx(Zde,{current:c,items:y,style:{marginBottom:24}}),C.jsx("div",{style:{padding:"24px 0",minHeight:300},children:T()}),C.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:12,paddingTop:16,marginTop:24},children:[C.jsx(tn,{onClick:r,children:"Cancel"}),c>0&&C.jsx(tn,{icon:C.jsx(Cfe,{size:16}),onClick:R,children:"Previous"}),C.jsx(tn,{type:"primary",onClick:N,disabled:!w()||d||p,icon:c===1?d?C.jsx(pg,{size:16,className:"spin"}):C.jsx(cB,{size:16}):C.jsx(E3,{size:16}),children:c===1?d?"Saving...":t?"Save Changes":"Create":"Next"})]})]})})},{Text:O2}=fr,Asr=e=>{const t=["#1890ff","#52c41a","#faad14","#f5222d","#722ed1","#13c2c2","#eb2f96","#fa8c16"];let n=0;for(let r=0;r<e.length;r++)n=e.charCodeAt(r)+((n<<5)-n);return t[Math.abs(n)%t.length]},vsr=({data:e,selected:t})=>{var g;const{token:n}=Xl.useToken();if(!e)return null;const{assistant:r,onConfigure:a,onChat:i}=e;if(!r)return null;const o=Asr(r.id),l=((g=r.name)==null?void 0:g.split(" ").map(m=>m.charAt(0)).join("").toUpperCase().slice(0,2))||"A",{modelKey:s,tools:c,agentType:u,prompt:d,subAgents:f}=b.useMemo(()=>{if(!r.graphDefinition)return{modelKey:void 0,tools:[],agentType:void 0,prompt:void 0,subAgents:[]};try{const m=typeof r.graphDefinition=="string"?JSON.parse(r.graphDefinition):r.graphDefinition;return{modelKey:m.modelKey||m.model,tools:m.tools||[],agentType:m.type,prompt:m.prompt,subAgents:m.subAgents||[]}}catch{return{modelKey:void 0,tools:[],agentType:void 0,prompt:void 0,subAgents:[]}}},[r.graphDefinition]),p=m=>m?{react:"Executor",deep_agent:"Orchestrator",plan_execute:"PLAN EXECUTE",sequential:"SEQUENTIAL"}[m]||m.toUpperCase():"",h=C.jsxs("div",{style:{maxWidth:400,maxHeight:"60vh",overflowY:"auto"},children:[C.jsx("div",{style:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",marginBottom:12},children:C.jsxs("div",{style:{flex:1},children:[C.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:8},children:[C.jsx(O2,{strong:!0,style:{fontSize:16,fontWeight:600,color:n.colorText},children:r.name}),u&&C.jsx(Kr,{color:"purple",style:{margin:0,fontSize:10,padding:"2px 8px",fontWeight:600},children:p(u)})]}),C.jsx("div",{style:{display:"flex",alignItems:"center",gap:6},children:C.jsx(O2,{style:{fontSize:11,color:n.colorTextTertiary,fontFamily:"monospace"},children:`>_ ${r.id}`})})]})}),r.description&&C.jsx("div",{style:{marginBottom:12},children:C.jsxs(O2,{style:{fontSize:12,color:n.colorText,lineHeight:1.6,fontStyle:"italic"},children:['"',r.description,'"']})}),s&&C.jsxs("div",{style:{marginBottom:12},children:[C.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:8},children:[C.jsx(_ie,{style:{fontSize:14,color:n.colorTextSecondary}}),C.jsx(O2,{style:{fontSize:12,color:n.colorTextSecondary,fontWeight:500},children:"Model Engine"})]}),C.jsx(Kr,{color:"blue",style:{fontSize:11,padding:"4px 12px"},children:s})]}),d&&C.jsxs("div",{style:{marginBottom:12},children:[C.jsx("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:8,justifyContent:"space-between"},children:C.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[C.jsx(mf,{style:{fontSize:14,color:n.colorTextSecondary}}),C.jsx(O2,{style:{fontSize:12,color:n.colorTextSecondary,fontWeight:600,letterSpacing:.5},children:"SYSTEM PROMPT"})]})}),C.jsx("div",{style:{padding:12,background:n.colorFillTertiary,border:`1px solid ${n.colorBorderSecondary}`,borderRadius:4,maxHeight:150,overflowY:"auto"},children:C.jsx(O2,{style:{fontSize:11,color:n.colorText,lineHeight:1.6,whiteSpace:"pre-wrap"},children:d.length>300?d.slice(0,300)+"...":d})})]}),c&&c.length>0&&C.jsxs("div",{style:{marginBottom:12},children:[C.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:8},children:[C.jsx(bw,{style:{fontSize:14,color:n.colorTextSecondary}}),C.jsxs(O2,{style:{fontSize:12,color:n.colorTextSecondary,fontWeight:500},children:["Available Tools (",c.length,")"]})]}),C.jsxs(rr,{size:[8,8],wrap:!0,children:[c.slice(0,5).map((m,A)=>C.jsx(Kr,{color:"blue",style:{fontSize:11,padding:"4px 12px"},children:m.replace(/_/g," ")},A)),c.length>5&&C.jsxs(Kr,{style:{fontSize:11,padding:"4px 12px",backgroundColor:n.colorFillTertiary,color:n.colorTextSecondary},children:["+",c.length-5," more"]})]})]}),f&&f.length>0&&C.jsxs("div",{style:{marginBottom:8},children:[C.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:8},children:[C.jsx(jre,{style:{fontSize:14,color:n.colorTextSecondary}}),C.jsxs(O2,{style:{fontSize:12,color:n.colorTextSecondary,fontWeight:500},children:["Sub-Agent Architecture (",f.length,")"]})]}),C.jsxs(rr,{size:[8,8],wrap:!0,children:[f.slice(0,3).map((m,A)=>C.jsx(Kr,{style:{fontSize:11,padding:"4px 12px",backgroundColor:n.colorFillTertiary,color:n.colorText,border:`1px solid ${n.colorBorderSecondary}`},children:`> ${m}`},A)),f.length>3&&C.jsxs(Kr,{style:{fontSize:11,padding:"4px 12px",backgroundColor:n.colorFillTertiary,color:n.colorTextSecondary},children:["+",f.length-3," more"]})]})]})]});return C.jsxs("div",{style:{padding:4},children:[C.jsx(j3,{type:"target",position:Br.Top}),C.jsxs("div",{style:{width:260,minHeight:180,background:n.colorBgContainer,borderRadius:8,boxShadow:"0 1px 4px rgba(0, 0, 0, 0.08)",overflow:"hidden",transition:"all 0.2s ease",position:"relative",border:t?`2px solid ${n.colorPrimary}`:`1px solid ${n.colorBorder}`,display:"flex",flexDirection:"column"},onMouseEnter:m=>{m.currentTarget.style.transform="translateY(-2px)",m.currentTarget.style.boxShadow="0 2px 8px rgba(0, 0, 0, 0.12)"},onMouseLeave:m=>{m.currentTarget.style.transform="translateY(0)",m.currentTarget.style.boxShadow="0 1px 4px rgba(0, 0, 0, 0.08)"},children:[C.jsxs("div",{style:{padding:12,display:"flex",flexDirection:"column",gap:10,flex:1},children:[C.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:10},children:[C.jsx(Gr,{title:h,placement:"rightTop",mouseEnterDelay:.5,overlayStyle:{maxWidth:"none"},color:n.colorBgContainer,children:C.jsxs("div",{style:{position:"relative",flexShrink:0,cursor:"pointer"},children:[C.jsx(wg,{size:44,icon:C.jsx(lB,{}),style:{backgroundColor:o,color:"#fff",fontSize:16,fontWeight:600},children:l}),C.jsx("div",{style:{position:"absolute",bottom:0,right:0,width:10,height:10,borderRadius:"50%",background:"#52c41a",border:`2px solid ${n.colorBgContainer}`}})]})}),C.jsxs("div",{style:{flex:1,minWidth:0,paddingRight:32},children:[C.jsx(O2,{strong:!0,style:{fontSize:14,fontWeight:600,display:"block",marginBottom:3,color:n.colorText,lineHeight:1.3},ellipsis:{tooltip:r.name},children:r.name}),C.jsxs("div",{style:{display:"flex",alignItems:"center",gap:4},children:[C.jsx(Qzt,{style:{fontSize:9,color:n.colorTextTertiary}}),C.jsx(O2,{style:{fontSize:9,color:n.colorTextTertiary},ellipsis:{tooltip:r.id},children:r.id})]})]})]}),r.description&&C.jsx("div",{style:{padding:8,background:n.colorFillTertiary,border:`1px solid ${n.colorBorderSecondary}`,borderRadius:4,borderLeft:`2px solid ${o}`},children:C.jsx(Gr,{title:r.description.length>150?r.description:void 0,placement:"top",children:C.jsxs("div",{style:{fontSize:10,color:n.colorText,lineHeight:1.5,fontStyle:"italic",display:"-webkit-box",WebkitLineClamp:3,WebkitBoxOrient:"vertical",overflow:"hidden",textOverflow:"ellipsis",cursor:r.description.length>150?"help":"default"},children:['"',r.description,'"']})})}),C.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:4,padding:"4px 0",marginTop:"auto",alignItems:"center",justifyContent:"space-between"},children:[C.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:4},children:[u&&C.jsx(Kr,{style:{margin:0,fontSize:7,padding:"2px 6px",borderRadius:6,backgroundColor:n.colorPrimaryBg,color:n.colorPrimary,border:`1px solid ${n.colorPrimaryBorder}`,fontWeight:500,lineHeight:"14px"},children:p(u)}),c&&c.length>0&&C.jsxs(Kr,{style:{margin:0,fontSize:7,padding:"2px 6px",borderRadius:6,backgroundColor:n.colorSuccessBg,color:n.colorSuccess,border:`1px solid ${n.colorSuccessBorder}`,fontWeight:500,lineHeight:"14px"},children:[c.length," Tools"]}),s&&C.jsx(Kr,{style:{margin:0,fontSize:7,padding:"2px 6px",borderRadius:6,backgroundColor:n.colorWarningBg,color:n.colorWarning,border:`1px solid ${n.colorWarningBorder}`,fontWeight:500,lineHeight:"14px"},title:s,children:s.length>12?`${s.slice(0,12)}...`:s})]}),i&&C.jsxs("div",{onMouseDown:m=>{m.stopPropagation()},onClick:m=>{m.stopPropagation(),i(r)},style:{display:"flex",alignItems:"center",gap:2,padding:"2px 6px",borderRadius:4,backgroundColor:n.colorPrimary,color:"#fff",cursor:"pointer",fontSize:10,fontWeight:500,transition:"all 0.2s ease"},onMouseEnter:m=>{m.currentTarget.style.backgroundColor=n.colorPrimaryHover},onMouseLeave:m=>{m.currentTarget.style.backgroundColor=n.colorPrimary},children:[C.jsx(xHt,{style:{fontSize:10}}),C.jsx("span",{children:"Chat"})]})]})]}),C.jsx(j3,{type:"source",position:Br.Bottom})]})]})},ysr=vsr,{TextArea:bsr}=Jn,{Text:Bo,Title:nfr}=fr,Kte=({title:e,icon:t,badge:n,children:r,defaultExpanded:a=!0})=>{const{token:i}=Xl.useToken(),[o,l]=b.useState(a);return C.jsxs(Ri,{size:"small",style:{marginBottom:16,border:`1px solid ${i.colorBorderSecondary}`,backgroundColor:`${i.colorBgContainer}d0`,backdropFilter:"blur(8px)",WebkitBackdropFilter:"blur(8px)"},bodyStyle:{padding:0},children:[C.jsxs("div",{onClick:()=>l(!o),style:{padding:"10px 14px",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"space-between",borderBottom:o?`1px solid ${i.colorBorderSecondary}`:"none",backgroundColor:`${i.colorFillQuaternary}d0`},children:[C.jsxs(rr,{size:"small",children:[t,C.jsx(Bo,{strong:!0,style:{fontSize:14},children:e}),n!==void 0&&n>0&&C.jsx(lw,{count:n,style:{backgroundColor:i.colorPrimary}})]}),C.jsx("div",{style:{transform:o?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.2s"},children:C.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",style:{color:i.colorTextSecondary},children:C.jsx("path",{d:"M6 8L1 3h10L6 8z",fill:"currentColor"})})})]}),o&&C.jsx("div",{style:{padding:16},children:r})]})},_sr=(e,t,n,r,a)=>{var o,l;const i=C.jsxs("span",{children:[t.title||e,t.description&&C.jsxs(C.Fragment,{children:[" ",C.jsx(Gr,{title:t.description,children:C.jsx(jHt,{style:{color:a.colorTextSecondary,cursor:"pointer"}})})]})]});if(t.widget==="segmented"||t.enum&&!t.widget){const s=((o=t.enum)==null?void 0:o.map(c=>({value:c,label:{global:"Global",agent:"Per Agent",thread:"Per Thread"}[c]||c})))||[];return C.jsx(Dr.Item,{label:i,style:{marginBottom:0},children:C.jsx(xx,{size:"small",value:n,onChange:r,options:s,block:!0})},e)}if(t.widget==="switch")return C.jsx(Dr.Item,{label:i,style:{marginBottom:8},children:C.jsx(vw,{checked:n,onChange:r})},e);if(t.widget==="numberInput"||t.type==="number"||t.type==="integer")return C.jsx(Dr.Item,{label:i,style:{marginBottom:8},children:C.jsx(Jn,{size:"small",type:"number",value:n,onChange:s=>r(parseFloat(s.target.value)||t.default),min:t.minimum,max:t.maximum,style:{width:"100%"}})},e);if(t.widget==="select"){const s=t.enumLabels,c=s?Object.entries(s).map(([u,d])=>({value:u,label:d})):((l=t.enum)==null?void 0:l.map(u=>({value:u,label:u})))||[];return C.jsx(Dr.Item,{label:i,style:{marginBottom:8},children:C.jsx(Mf,{size:"small",value:n,onChange:r,options:c,style:{width:"100%"}})},e)}return t.widget==="textarea"?C.jsx(Dr.Item,{label:i,style:{marginBottom:8},children:C.jsx(Jn.TextArea,{size:"small",value:n,onChange:s=>r(s.target.value),placeholder:t.default,autoSize:{minRows:2,maxRows:4}})},e):t.widget==="skillSelect"?C.jsx(xsr,{propertyKey:e,label:i,value:n,onChange:r,token:a}):t.widget==="databaseSelect"?C.jsx(Esr,{propertyKey:e,label:i,value:n,onChange:r,token:a}):t.widget==="metricsSelect"?C.jsx(wsr,{propertyKey:e,label:i,value:n,onChange:r,token:a}):C.jsx(Dr.Item,{label:i,style:{marginBottom:8},children:C.jsx(Jn,{size:"small",value:n,onChange:s=>r(s.target.value),placeholder:t.default})},e)},Ssr=(e,t)=>t==null?void 0:t.find(n=>n.type===e),xsr=({propertyKey:e,label:t,value:n,onChange:r,token:a})=>{const[i,o]=b.useState([]),[l,s]=b.useState(!1),{get:c}=_l(),u=b.useRef(!1);b.useEffect(()=>{if(u.current)return;u.current=!0,(async()=>{s(!0);try{const h=await c("/api/skills");h.success&&h.data&&Array.isArray(h.data.records)&&o(h.data.records)}catch(h){console.error("Failed to fetch skills:",h)}finally{s(!1)}})()},[c]);const d=Array.isArray(n)?n:[],f=p=>C.jsx(Ha.Item,{style:{padding:"8px 0",cursor:"pointer",borderRadius:a.borderRadius,backgroundColor:d.includes(p.id)?a.colorSuccessBg:"transparent",border:`1px solid ${d.includes(p.id)?a.colorSuccess:"transparent"}`,marginBottom:4,transition:"all 0.2s ease",paddingLeft:8,paddingRight:8},onClick:()=>{const h=d.includes(p.id)?d.filter(g=>g!==p.id):[...d,p.id];r(h)},children:C.jsx(Ha.Item.Meta,{avatar:C.jsx(Mc,{checked:d.includes(p.id),onChange:()=>{const h=d.includes(p.id)?d.filter(g=>g!==p.id):[...d,p.id];r(h)},onClick:h=>h.stopPropagation()}),title:C.jsx(Bo,{strong:d.includes(p.id),children:p.name}),description:C.jsx(Bo,{type:"secondary",style:{fontSize:12},children:p.description})})},p.id);return C.jsx("div",{children:C.jsxs(Dr.Item,{label:t,style:{marginBottom:8},children:[C.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:12},children:[C.jsxs(Bo,{type:"secondary",style:{fontSize:12},children:[d.length," of ",i.length," selected"]}),C.jsx(tn,{type:"link",size:"small",onClick:()=>r(d.length===i.length?[]:i.map(p=>p.id)),children:d.length===i.length?"Deselect All":"Select All"})]}),l?C.jsx("div",{style:{textAlign:"center",padding:20},children:C.jsx(bl,{size:"small"})}):i.length===0?C.jsx(ai,{description:"No skills available",image:ai.PRESENTED_IMAGE_SIMPLE}):C.jsx(Ha,{dataSource:i,renderItem:f,style:{maxHeight:"40vh",overflowY:"auto"},split:!1})]},e)})},Esr=({propertyKey:e,label:t,value:n,onChange:r,token:a})=>{const[i,o]=b.useState([]),[l,s]=b.useState(!1),{get:c}=_l(),u=b.useRef(!1);b.useEffect(()=>{if(u.current)return;u.current=!0,(async()=>{s(!0);try{const h=await c("/api/database-configs");h.success&&h.data&&Array.isArray(h.data.records)&&o(h.data.records)}catch(h){console.error("Failed to fetch database configs:",h)}finally{s(!1)}})()},[c]);const d=Array.isArray(n)?n:[],f=p=>{const h=p.name||p.key,g=d.includes(p.key);return C.jsx(Ha.Item,{style:{padding:"8px 0",cursor:"pointer",borderRadius:a.borderRadius,backgroundColor:g?a.colorSuccessBg:"transparent",border:`1px solid ${g?a.colorSuccess:"transparent"}`,marginBottom:4,transition:"all 0.2s ease",paddingLeft:8,paddingRight:8},onClick:()=>{const m=g?d.filter(A=>A!==p.key):[...d,p.key];r(m)},children:C.jsx(Ha.Item.Meta,{avatar:C.jsx(Mc,{checked:g,onChange:()=>{const m=g?d.filter(A=>A!==p.key):[...d,p.key];r(m)},onClick:m=>m.stopPropagation()}),title:C.jsx(Bo,{strong:g,children:h}),description:p.description&&C.jsx(Bo,{type:"secondary",style:{fontSize:12},children:p.description})})},p.key)};return C.jsx("div",{children:C.jsxs(Dr.Item,{label:t,style:{marginBottom:8},children:[C.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:12},children:[C.jsxs(Bo,{type:"secondary",style:{fontSize:12},children:[d.length," of ",i.length," selected"]}),C.jsx(tn,{type:"link",size:"small",onClick:()=>r(d.length===i.length?[]:i.map(p=>p.key)),children:d.length===i.length?"Deselect All":"Select All"})]}),l?C.jsx("div",{style:{textAlign:"center",padding:20},children:C.jsx(bl,{size:"small"})}):i.length===0?C.jsx(ai,{description:"No databases available",image:ai.PRESENTED_IMAGE_SIMPLE}):C.jsx(Ha,{dataSource:i,renderItem:f,style:{maxHeight:"40vh",overflowY:"auto"},split:!1})]},e)})},wsr=({propertyKey:e,label:t,value:n,onChange:r,token:a})=>{const[i,o]=b.useState([]),[l,s]=b.useState(!1),{get:c}=_l(),u=b.useRef(!1);b.useEffect(()=>{if(u.current)return;u.current=!0,(async()=>{s(!0);try{const h=await c("/api/metrics-configs");h.success&&h.data&&Array.isArray(h.data.records)&&o(h.data.records)}catch(h){console.error("Failed to fetch metrics configs:",h)}finally{s(!1)}})()},[c]);const d=Array.isArray(n)?n:[],f=p=>{const h=p.name||p.key,g=d.includes(p.key);return C.jsx(Ha.Item,{style:{padding:"8px 0",cursor:"pointer",borderRadius:a.borderRadius,backgroundColor:g?a.colorSuccessBg:"transparent",border:`1px solid ${g?a.colorSuccess:"transparent"}`,marginBottom:4,transition:"all 0.2s ease",paddingLeft:8,paddingRight:8},onClick:()=>{const m=g?d.filter(A=>A!==p.key):[...d,p.key];r(m)},children:C.jsx(Ha.Item.Meta,{avatar:C.jsx(Mc,{checked:g,onChange:()=>{const m=g?d.filter(A=>A!==p.key):[...d,p.key];r(m)},onClick:m=>m.stopPropagation()}),title:C.jsx(Bo,{strong:g,children:h}),description:p.description&&C.jsx(Bo,{type:"secondary",style:{fontSize:12},children:p.description})})},p.key)};return C.jsx("div",{children:C.jsxs(Dr.Item,{label:t,style:{marginBottom:8},children:[C.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:12},children:[C.jsxs(Bo,{type:"secondary",style:{fontSize:12},children:[d.length," of ",i.length," selected"]}),C.jsx(tn,{type:"link",size:"small",onClick:()=>r(d.length===i.length?[]:i.map(p=>p.key)),children:d.length===i.length?"Deselect All":"Select All"})]}),l?C.jsx("div",{style:{textAlign:"center",padding:20},children:C.jsx(bl,{size:"small"})}):i.length===0?C.jsx(ai,{description:"No metrics servers available",image:ai.PRESENTED_IMAGE_SIMPLE}):C.jsx(Ha,{dataSource:i,renderItem:f,style:{maxHeight:"40vh",overflowY:"auto"},split:!1})]},e)})},Csr=({middleware:e,middlewareType:t,onToggle:n,onConfigChange:r,token:a})=>{const[i,o]=b.useState(e.enabled),l=()=>{switch(e.type){case"browser":return C.jsx(LXe,{style:{color:a.colorPrimary}});case"sql":return C.jsx(hfe,{style:{color:a.colorWarning}});case"skill":return C.jsx(fjt,{style:{color:a.colorSuccess}});case"filesystem":return C.jsx(MXe,{style:{color:a.colorInfo}});case"code_eval":return C.jsx(mf,{style:{color:a.colorError}});case"metrics":return C.jsx(sB,{size:16,style:{color:a.colorWarning}});default:return C.jsx(Rx,{style:{color:a.colorWarning}})}},s=()=>{if(e.type==="browser")return C.jsxs("div",{style:{marginTop:12,paddingTop:12,borderTop:`1px solid ${a.colorBorderSecondary}`},children:[C.jsx(Bo,{strong:!0,style:{fontSize:12,display:"block",marginBottom:8},children:"Provided Tools"}),C.jsx(rr,{size:4,wrap:!0,children:["Navigate","Click","Fill","Get Text","Markdown","Screenshot","Scroll","Evaluate"].map(u=>C.jsx(Kr,{color:"green",style:{fontSize:10,margin:0},children:u},u))})]});if(e.type==="sql"||e.type==="skill"){const u=(t==null?void 0:t.tools)||[];return C.jsxs("div",{style:{marginTop:12,paddingTop:12,borderTop:`1px solid ${a.colorBorderSecondary}`},children:[C.jsx(Bo,{strong:!0,style:{fontSize:12,display:"block",marginBottom:8},children:"Provided Tools"}),C.jsx(rr,{size:4,wrap:!0,children:u.map(d=>C.jsx(Kr,{color:e.type==="sql"?"orange":"blue",style:{fontSize:10,margin:0},children:d.name},d.id))})]})}return null},c=()=>{var f;if(!((f=t==null?void 0:t.schema)!=null&&f.properties))return null;const u=t.schema.properties,d=Object.keys(u);return C.jsx("div",{style:{marginTop:8},children:d.map(p=>{const h=u[p];return p==="skills"&&e.config.readAll===!0||p==="serverKeys"&&e.config.connectAll===!0||p==="vmIsolation"?null:_sr(p,h,e.config[p]??h.default,g=>r({[p]:g}),a)})})};return C.jsxs(Ri,{size:"small",style:{marginBottom:16,border:`1px solid ${e.enabled?a.colorPrimary:a.colorBorderSecondary}`,backgroundColor:`${a.colorBgContainer}d0`,backdropFilter:"blur(8px)",WebkitBackdropFilter:"blur(8px)",opacity:e.enabled?1:.7},bodyStyle:{padding:0},children:[C.jsxs("div",{style:{padding:"10px 14px",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"space-between",borderBottom:i?`1px solid ${a.colorBorderSecondary}`:"none",backgroundColor:`${a.colorFillQuaternary}d0`},onClick:()=>e.enabled&&o(!i),children:[C.jsxs(rr,{size:"small",children:[l(),C.jsx(Bo,{strong:!0,style:{fontSize:14},children:e.name})]}),C.jsxs(rr,{size:"small",onClick:u=>u.stopPropagation(),children:[C.jsx(vw,{checked:e.enabled,onChange:u=>{n(),u&&o(!0)},size:"small"}),C.jsx("div",{style:{transform:i?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.2s",opacity:e.enabled?1:.3},children:C.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",style:{color:a.colorTextSecondary},children:C.jsx("path",{d:"M6 8L1 3h10L6 8z",fill:"currentColor"})})})]})]}),e.enabled&&i&&C.jsxs("div",{style:{padding:16},children:[C.jsx(Bo,{type:"secondary",style:{fontSize:11,display:"block",marginBottom:12},children:e.description}),c(),s()]})]})},Tsr=({assistant:e,allAssistants:t,visible:n,onClose:r,onSave:a,onDelete:i})=>{const[o]=Dr.useForm(),{token:l}=Xl.useToken(),{config:s}=Zo(),{get:c}=_l(),[u,d]=b.useState(!1),[f,p]=b.useState(!1),[h,g]=b.useState(!1),[m,A]=b.useState(!1),[v,y]=b.useState([]),[_,x]=b.useState([]),[S,E]=b.useState([]),[w,T]=b.useState(""),[N,R]=b.useState(!1),[k,O]=b.useState("react"),[M,D]=b.useState([]),B=b.useMemo(()=>{if(!(e!=null&&e.graphDefinition))return null;try{const Y=typeof e.graphDefinition=="string"?JSON.parse(e.graphDefinition):e.graphDefinition;return{tools:Y.tools||[],prompt:Y.prompt||"",subAgents:Y.subAgents||[],type:Y.type||"react",middleware:Y.middleware||[]}}catch{return null}},[e]),$=b.useCallback(Y=>(Y||[]).map((ae,ne)=>({id:`${ae.type}-${ne+1}`,type:ae.type,name:ae.name,description:ae.description,enabled:!1,config:{}})),[]),P=b.useCallback((Y,ee)=>{const ae=ee||[],ne=new Map((Y==null?void 0:Y.map(te=>[te.type,te]))||[]);return ae.map((te,se)=>{const pe=ne.get(te.type);return pe?{...pe,name:te.name,description:te.description}:{id:`${te.type}-${se+1}`,type:te.type,name:te.name,description:te.description,enabled:!1,config:{}}})},[]),U=b.useCallback(async()=>{var Y;if(n){d(!0);try{const ee=await c("/api/tools");ee.success&&((Y=ee.data)!=null&&Y.records)&&y(ee.data.records)}catch(ee){console.error("Failed to fetch tools:",ee)}finally{d(!1)}}},[c,n]);b.useEffect(()=>{if(n&&e)if(U(),B){x(B.tools),E(B.subAgents),T(B.prompt),O(B.type);const Y=B.middleware;D(Y!==void 0?P(Y,s.availableMiddlewareTypes||[]):$(s.availableMiddlewareTypes||[])),o.setFieldsValue({name:e.name,description:e.description,prompt:B.prompt,type:B.type})}else x([]),E([]),T(""),O("react"),D($(s.availableMiddlewareTypes||[])),o.resetFields()},[n,e,B,o,U,$,s.availableMiddlewareTypes]);const H=Y=>{x(ee=>ee.includes(Y)?ee.filter(ae=>ae!==Y):[...ee,Y])},G=Y=>{E(ee=>ee.includes(Y)?ee.filter(ae=>ae!==Y):[...ee,Y])},F=async()=>{if(e)try{p(!0);const ee={...await o.validateFields(),type:k,tools:_,subAgents:S,prompt:w,middleware:M};await(a==null?void 0:a(e,ee))}catch(Y){throw Y instanceof Error&&bn.error(Y.message),Y}finally{p(!1)}},z=async()=>{if(e){g(!0);try{await(i==null?void 0:i(e)),A(!1),r()}catch(Y){A(!1),bn.error(Y instanceof Error?Y.message:"Failed to delete assistant")}finally{g(!1)}}},W=Y=>{D(ee=>ee.map(ae=>{var ne;if(ae.id!==Y)return ae;if(ae.enabled)return{...ae,enabled:!1};{const te=(ne=s.availableMiddlewareTypes)==null?void 0:ne.find(se=>se.type===ae.type);return{...ae,enabled:!0,config:(te==null?void 0:te.defaultConfig)||{}}}}))},q=(Y,ee)=>{D(ae=>ae.map(ne=>ne.id===Y?{...ne,config:{...ne.config,...ee}}:ne))},Q=Y=>C.jsx(Ha.Item,{style:{padding:"8px 0",cursor:"pointer",borderRadius:l.borderRadius,backgroundColor:_.includes(Y.id)?l.colorPrimaryBg:"transparent",border:`1px solid ${_.includes(Y.id)?l.colorPrimary:"transparent"}`,marginBottom:4,transition:"all 0.2s ease",paddingLeft:8,paddingRight:8},onClick:()=>H(Y.id),children:C.jsx(Ha.Item.Meta,{avatar:C.jsx(Mc,{checked:_.includes(Y.id),onChange:()=>H(Y.id),onClick:ee=>ee.stopPropagation()}),title:C.jsxs(rr,{size:"small",children:[C.jsx(Bo,{strong:_.includes(Y.id),children:Y.name}),Y.needUserApprove&&C.jsx(Kr,{color:"warning",style:{fontSize:10,padding:"0 4px",margin:0},children:"Approve"})]}),description:C.jsx(Bo,{type:"secondary",style:{fontSize:12},children:Y.description})})},Y.id),Z=Y=>{var ee;return C.jsx(Ha.Item,{style:{padding:"8px 0",cursor:"pointer",borderRadius:l.borderRadius,backgroundColor:S.includes(Y.id)?l.colorInfoBg:"transparent",border:`1px solid ${S.includes(Y.id)?l.colorInfo:"transparent"}`,marginBottom:4,transition:"all 0.2s ease",paddingLeft:8,paddingRight:8},onClick:()=>G(Y.id),children:C.jsx(Ha.Item.Meta,{avatar:C.jsx(Mc,{checked:S.includes(Y.id),onChange:()=>G(Y.id),onClick:ae=>ae.stopPropagation()}),title:C.jsxs(rr,{size:"small",children:[C.jsx(wg,{size:"small",style:{backgroundColor:l.colorSuccess,fontSize:12},children:((ee=Y.name)==null?void 0:ee.charAt(0).toUpperCase())||"A"}),C.jsx(Bo,{strong:S.includes(Y.id),children:Y.name})]}),description:C.jsx(Bo,{type:"secondary",style:{fontSize:12},children:Y.description||"No description"})})},Y.id)};return!n||!e?null:C.jsxs("div",{style:{width:380,height:"100%",backgroundColor:`${l.colorBgContainer}f0`,backdropFilter:"blur(12px)",WebkitBackdropFilter:"blur(12px)",borderLeft:`1px solid ${l.colorBorderSecondary}`,display:"flex",flexDirection:"column",boxShadow:"-2px 0 8px rgba(0, 0, 0, 0.05)"},children:[C.jsxs("div",{style:{padding:"12px 16px",borderBottom:`1px solid ${l.colorBorderSecondary}`,display:"flex",alignItems:"center",justifyContent:"space-between",backgroundColor:`${l.colorFillQuaternary}e0`,backdropFilter:"blur(8px)",WebkitBackdropFilter:"blur(8px)"},children:[C.jsxs(rr,{size:"small",children:[C.jsx(_ie,{style:{color:l.colorPrimary,fontSize:16}}),C.jsx(Bo,{strong:!0,style:{fontSize:14},children:e.name}),C.jsx(Kr,{color:"blue",style:{margin:0,fontSize:10},children:"Config"})]}),C.jsxs(rr,{children:[i&&C.jsx(Gr,{title:"Delete Assistant",children:C.jsx(tn,{type:"text",size:"small",danger:!0,icon:C.jsx(IXe,{}),onClick:()=>A(!0)})}),C.jsx(tn,{type:"text",size:"small",icon:C.jsx(o4,{}),onClick:r})]})]}),C.jsx("div",{style:{flex:1,overflowY:"auto",padding:"16px 20px"},children:C.jsxs(Dr,{form:o,layout:"vertical",autoComplete:"off",children:[C.jsxs(Kte,{title:"Basic Settings",icon:C.jsx(_ie,{style:{color:l.colorPrimary}}),defaultExpanded:!0,children:[C.jsx(Dr.Item,{name:"name",label:"Name",rules:[{required:!0,message:"Please enter agent name"}],style:{marginBottom:8},children:C.jsx(Jn,{placeholder:"Enter agent name..."})}),C.jsx(Dr.Item,{name:"description",label:"Description",rules:[{required:!0,message:"Please enter agent description"}],style:{marginBottom:8},children:C.jsx(Jn.TextArea,{placeholder:"Enter agent description...",autoSize:{minRows:2,maxRows:4}})}),C.jsxs(Dr.Item,{name:"type",label:"Agent Type",rules:[{required:!0}],style:{marginBottom:8},children:[C.jsx(xx,{value:k,onChange:Y=>O(Y),options:[{value:"react",label:"Executor"},{value:"deep_agent",label:"Orchestrator"},{value:"team",label:"Team"}],block:!0}),C.jsx(Bo,{type:"secondary",style:{fontSize:11,marginTop:6,display:"block",lineHeight:1.4},children:k==="react"?"Executor: Directly executes tasks using tools. Best for single-step operations like search, code execution, and data retrieval.":k==="deep_agent"?"Orchestrator: Manages a sequential todo list to plan and assign todo items to sub-agents. Best for structured multi-step workflows.":"Team: Creates tasks with dependencies and dynamically spawns teammates. Like a swarm, teammates communicate via mailbox. Best for tasks requiring exploration and divergent thinking."})]}),C.jsxs(Dr.Item,{label:C.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[C.jsx("span",{children:"System Prompt"}),C.jsxs("div",{onClick:()=>R(!0),style:{cursor:"pointer",padding:"2px 8px",borderRadius:4,fontSize:11,color:l.colorPrimary,background:l.colorPrimaryBg,border:`1px solid ${l.colorPrimaryBorder}`,display:"flex",alignItems:"center",gap:4},children:[C.jsx(RXe,{style:{fontSize:10}}),C.jsx("span",{children:"Expand"})]})]}),children:[C.jsx(bsr,{value:w,onChange:Y=>T(Y.target.value),placeholder:"Enter the system prompt for this agent...",autoSize:{minRows:4,maxRows:8},style:{fontFamily:"monospace",fontSize:13,lineHeight:1.6}}),C.jsx(Bo,{type:"secondary",style:{fontSize:12,marginTop:4,display:"block"},children:"Define the agent's behavior, capabilities, and constraints"})]})]}),M.map(Y=>C.jsx(Csr,{middleware:Y,middlewareType:Ssr(Y.type,s.availableMiddlewareTypes),onToggle:()=>W(Y.id),onConfigChange:ee=>q(Y.id,ee),token:l},Y.id)),C.jsx(Kte,{title:"Common Tools",icon:C.jsx(bw,{style:{color:l.colorPrimary}}),badge:_.length,defaultExpanded:!1,children:u?C.jsx("div",{style:{textAlign:"center",padding:20},children:C.jsx(bl,{size:"small"})}):v.length===0?C.jsx(ai,{description:"No tools available",image:ai.PRESENTED_IMAGE_SIMPLE}):C.jsxs(C.Fragment,{children:[C.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:12},children:[C.jsxs(Bo,{type:"secondary",style:{fontSize:12},children:[_.length," of ",v.length," selected"]}),C.jsx(tn,{type:"link",size:"small",onClick:()=>x(_.length===v.length?[]:v.map(Y=>Y.id)),children:_.length===v.length?"Deselect All":"Select All"})]}),C.jsx(Ha,{dataSource:v,renderItem:Q,style:{maxHeight:"40vh",overflowY:"auto"},split:!1})]})}),C.jsx(Kte,{title:"Sub-Agents",icon:C.jsx(QHt,{style:{color:l.colorInfo}}),badge:S.length,defaultExpanded:!1,children:t.filter(Y=>Y.id!==e.id).length===0?C.jsx(ai,{description:"No other agents available",image:ai.PRESENTED_IMAGE_SIMPLE}):C.jsxs(C.Fragment,{children:[C.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:12},children:[C.jsxs(Bo,{type:"secondary",style:{fontSize:12},children:[S.length," of"," ",t.filter(Y=>Y.id!==e.id).length," ","selected"]}),C.jsx(tn,{type:"link",size:"small",onClick:()=>{const Y=t.filter(ee=>ee.id!==e.id).map(ee=>ee.id);E(S.length===Y.length?[]:Y)},children:S.length===t.filter(Y=>Y.id!==e.id).length?"Deselect All":"Select All"})]}),C.jsx(Ha,{dataSource:t.filter(Y=>Y.id!==e.id),renderItem:Z,style:{maxHeight:"40vh",overflowY:"auto"},split:!1})]})})]})}),C.jsxs("div",{style:{padding:"12px 20px",borderTop:`1px solid ${l.colorBorderSecondary}`,backgroundColor:l.colorFillQuaternary,display:"flex",justifyContent:"space-between",alignItems:"center"},children:[C.jsx(Bo,{type:"secondary",style:{fontSize:12},children:a?"Changes will be saved to the agent":"Viewing agent configuration"}),C.jsxs(rr,{children:[C.jsx(tn,{onClick:r,size:"small",children:"Close"}),a&&C.jsx(tn,{type:"primary",icon:C.jsx(PXe,{}),loading:f,onClick:F,size:"small",children:"Save"})]})]}),C.jsxs(Gi,{title:"System Prompt",open:N,onCancel:()=>R(!1),width:700,footer:null,styles:{body:{padding:"16px 24px"}},children:[C.jsx(Jn.TextArea,{value:w,onChange:Y=>T(Y.target.value),rows:12,style:{width:"100%",fontFamily:"monospace",fontSize:12,resize:"vertical",minHeight:200}}),C.jsxs("div",{style:{marginTop:12,display:"flex",justifyContent:"flex-end",gap:8},children:[C.jsx("div",{onClick:()=>R(!1),style:{padding:"6px 16px",borderRadius:4,cursor:"pointer",fontSize:12,border:`1px solid ${l.colorBorder}`,background:l.colorBgContainer},children:"Cancel"}),C.jsx("div",{onClick:()=>R(!1),style:{padding:"6px 16px",borderRadius:4,cursor:"pointer",fontSize:12,background:l.colorPrimary,color:"#fff"},children:"Done"})]})]}),C.jsx(Gi,{title:"Delete Assistant",open:m,onCancel:()=>A(!1),footer:[C.jsx(tn,{onClick:()=>A(!1),children:"Cancel"},"cancel"),C.jsx(tn,{type:"primary",danger:!0,loading:h,onClick:z,children:"Delete"},"delete")],children:C.jsxs(Bo,{children:["Are you sure you want to delete ",C.jsx(Bo,{strong:!0,children:e.name}),"? This action cannot be undone."]})})]})},Isr=Tsr,{Text:Rsr}=fr,Nsr=({onSelect:e,value:t,placeholder:n="Select a parent agent to extend..."})=>{const[r,a]=b.useState([]),[i,o]=b.useState(!1),{get:l}=_l();b.useEffect(()=>{(async()=>{var u;o(!0);try{const d=await l("/api/assistants");d.success&&a(((u=d.data)==null?void 0:u.records)||[])}catch(d){console.error("Failed to fetch assistants:",d)}finally{o(!1)}})()},[l]);const s=c=>{if(!c){e(null);return}const u=r.find(d=>d.id===c);e(u||null)};return C.jsx(Mf,{showSearch:!0,allowClear:!0,value:t,placeholder:n,loading:i,onChange:s,optionFilterProp:"label",style:{width:"100%"},options:r.map(c=>({value:c.id,label:c.name||c.id,description:c.description})),optionRender:c=>C.jsxs("div",{children:[C.jsx("div",{children:c.label}),c.data.description&&C.jsx(Rsr,{type:"secondary",style:{fontSize:12},children:c.data.description})]})})},{Text:aGe}=fr,Osr=({subAgentKeys:e,decisions:t,onChange:n})=>{const{token:r}=Xl.useToken(),a=(o,l)=>{const s=t.map(c=>c.originalKey===o?{...c,clone:l,cloneKey:l?`${o}_clone`:void 0}:c);n(s)},i=(o,l)=>{const s=t.map(c=>c.originalKey===o?{...c,cloneKey:l}:c);n(s)};return e.length===0?null:C.jsxs("div",{children:[C.jsx(aGe,{type:"secondary",style:{display:"block",marginBottom:8},children:"Choose how to handle each sub-agent from the parent:"}),C.jsx(Ha,{size:"small",bordered:!0,dataSource:t,style:{borderRadius:r.borderRadius},renderItem:o=>C.jsxs(Ha.Item,{style:{display:"flex",flexDirection:"column",alignItems:"stretch",gap:8,padding:"8px 16px"},children:[C.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[C.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[o.clone?C.jsx(kXe,{style:{color:r.colorPrimary}}):C.jsx(WN,{style:{color:r.colorTextSecondary}}),C.jsx(aGe,{style:{fontFamily:"monospace"},children:o.originalKey})]}),C.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[C.jsx(Kr,{color:o.clone?"blue":"default",children:o.clone?"Clone as new":"Reuse"}),C.jsx(vw,{size:"small",checked:o.clone,onChange:l=>a(o.originalKey,l)})]})]}),o.clone&&C.jsx(Jn,{size:"small",placeholder:"Enter key for the cloned agent",value:o.cloneKey,onChange:l=>i(o.originalKey,l.target.value),style:{fontFamily:"monospace",fontSize:12},addonBefore:"Key"})]})})]})},{TextArea:iGe}=Jn,{Text:_7}=fr,Msr=({open:e,onCancel:t,onSuccess:n})=>{var E;const[r]=Dr.useForm(),[a,i]=b.useState(!1),[o,l]=b.useState("scratch"),[s,c]=b.useState(null),[u,d]=b.useState([]),{get:f,post:p}=_l();Xl.useToken();const h=b.useCallback(()=>{c(null),d([])},[]),g=b.useCallback(w=>{if(c(w),!w){r.resetFields(["key","name","description","type","prompt"]),d([]);return}const T=typeof w.graphDefinition=="object"&&w.graphDefinition!==null?w.graphDefinition:{},N=T.key||w.id,R=w.name||T.name||"";r.setFieldsValue({key:`${N}_ext`,name:R?`${R} (Extended)`:"",description:w.description||T.description||"",type:T.type||"react",prompt:T.prompt||""});const k=T.subAgents||[];d(k.map(O=>({originalKey:O,clone:!1})))},[r]),m=b.useCallback(w=>{l(w),w==="scratch"&&(h(),r.resetFields())},[r,h]),A=async(w,T)=>{const N=await f(`/api/assistants/${w}`);if(!N.success)throw new Error(`Failed to fetch sub-agent "${w}" for cloning`);const R=N.data,k=typeof R.graphDefinition=="object"?R.graphDefinition:{},O={id:T,name:`${R.name} (Clone)`,description:R.description||"",graphDefinition:{...k,key:T,name:`${R.name} (Clone)`}},M=await p("/api/assistants",O);if(!M.success)throw new Error(M.message||`Failed to clone sub-agent "${w}"`);return M.data},v=w=>({id:w.key,name:w.name,description:w.description||"",graphDefinition:{key:w.key,name:w.name,description:w.description||"",type:w.type,prompt:w.prompt||"",tools:[],skills:[],subAgents:w.type==="deep_agent"?[]:void 0,middleware:[]}}),y=async(w,T)=>{if(!s)throw new Error("No parent agent selected");const N=u.filter(M=>M.clone);for(const M of N){if(!M.cloneKey||!M.cloneKey.trim())throw new Error(`Please provide a key for the cloned sub-agent "${M.originalKey}"`);if(!/^[a-zA-Z][a-zA-Z0-9_-]*$/.test(M.cloneKey))throw new Error(`Invalid key "${M.cloneKey}" for cloned sub-agent "${M.originalKey}". Key must start with a letter and contain only letters, numbers, underscores, or hyphens.`)}const R=[];for(const M of u)if(M.clone){const D=await A(M.originalKey,M.cloneKey);T.push(D),R.push(M.cloneKey)}else R.push(M.originalKey);const k=typeof s.graphDefinition=="object"?s.graphDefinition:{},O={key:w.key,name:w.name,description:w.description||"",extendsAgent:s.id,type:w.type||k.type};return w.prompt&&w.prompt!==k.prompt&&(O.prompt=w.prompt),(R.length>0||k.subAgents&&k.subAgents.length>0)&&(O.subAgents=R),{id:w.key,name:w.name,description:w.description||"",graphDefinition:O}},_=async()=>{try{const w=await r.validateFields();i(!0);const T=[],N=o==="scratch"?v(w):await y(w,T),R=await p("/api/assistants",N);if(R.success){vp.success({message:"Created",description:o==="extend"?`Assistant created by extending "${s==null?void 0:s.name}"`:"Assistant created successfully"}),r.resetFields(),h(),l("scratch");for(const k of T)n==null||n(k);n==null||n(R.data),t()}else bn.error(R.message||"Failed to create assistant")}catch(w){if(w.errorFields)return;bn.error(w.message||"An error occurred while creating the assistant")}finally{i(!1)}},x=((E=s==null?void 0:s.graphDefinition)==null?void 0:E.subAgents)||[],S=o==="extend"&&s&&x.length>0;return C.jsxs(Gi,{title:"Create New Assistant",open:e,onCancel:()=>{h(),l("scratch"),t()},footer:[C.jsx(tn,{onClick:()=>{h(),l("scratch"),t()},children:"Cancel"},"cancel"),C.jsx(tn,{type:"primary",icon:o==="extend"?C.jsx(kXe,{}):C.jsx(u5,{}),loading:a,onClick:_,children:o==="extend"?"Create (Extend)":"Create"},"submit")],width:600,children:[C.jsxs("div",{style:{marginBottom:20},children:[C.jsx(_7,{type:"secondary",style:{display:"block",marginBottom:8},children:"Creation Mode"}),C.jsx(xx,{value:o,onChange:m,options:[{value:"scratch",label:"From Scratch"},{value:"extend",label:"Extend Existing Agent"}],block:!0})]}),o==="extend"&&C.jsxs("div",{style:{marginBottom:20},children:[C.jsx(_7,{type:"secondary",style:{display:"block",marginBottom:8},children:"Parent Agent"}),C.jsx(Nsr,{value:s==null?void 0:s.id,onSelect:g}),s&&C.jsx(_7,{type:"secondary",style:{display:"block",marginTop:4,fontSize:12},children:"Fields left unchanged will be inherited from the parent agent."})]}),o==="extend"&&s&&C.jsx(D4,{style:{margin:"12px 0"}}),C.jsxs(Dr,{form:r,layout:"vertical",autoComplete:"off",initialValues:{type:"react"},children:[C.jsx(Dr.Item,{name:"key",label:"Key (ID)",rules:[{required:!0,message:"Please enter a unique key"},{pattern:/^[a-zA-Z][a-zA-Z0-9_-]*$/,message:"Key must start with a letter and contain only letters, numbers, underscores, or hyphens"}],style:{marginBottom:16},children:C.jsx(Jn,{placeholder:"e.g., my_assistant"})}),C.jsx(Dr.Item,{name:"name",label:"Name",rules:[{required:!0,message:"Please enter a name"}],style:{marginBottom:16},children:C.jsx(Jn,{placeholder:"e.g., My Assistant"})}),C.jsx(Dr.Item,{name:"description",label:"Description",rules:[{required:!0,message:"Please enter a description"}],style:{marginBottom:16},children:C.jsx(iGe,{placeholder:"Enter a description for this assistant...",autoSize:{minRows:2,maxRows:4}})}),C.jsx(Dr.Item,{name:"type",label:"Agent Type",rules:[{required:!0}],style:{marginBottom:16},children:C.jsx(xx,{options:[{value:"react",label:"Executor"},{value:"deep_agent",label:"Orchestrator"},{value:"team",label:"Team"}],block:!0})}),C.jsx(Dr.Item,{noStyle:!0,shouldUpdate:(w,T)=>w.type!==T.type,children:()=>{const w=r.getFieldValue("type"),T={react:"Executor: Directly executes tasks using tools. Best for single-step operations like search, code execution, and data retrieval.",deep_agent:"Orchestrator: Manages a sequential todo list to plan and assign todo items to sub-agents. Best for structured multi-step workflows.",team:"Team: Creates tasks with dependencies and dynamically spawns teammates. Like a swarm, teammates communicate via mailbox. Best for tasks requiring exploration and divergent thinking."};return C.jsx(_7,{type:"secondary",style:{fontSize:12,display:"block",marginTop:-12,marginBottom:16,lineHeight:1.5},children:T[w]||T.react})}}),C.jsx(Dr.Item,{name:"prompt",label:o==="extend"&&s?"System Prompt (leave unchanged to inherit from parent)":"System Prompt",rules:o==="scratch"?[{required:!0,message:"Please enter a system prompt"}]:[],children:C.jsx(iGe,{placeholder:o==="extend"&&s?"Leave empty to inherit parent's prompt, or enter a new prompt to override...":"Enter the system prompt for this agent...",autoSize:{minRows:4,maxRows:8},style:{fontFamily:"monospace",fontSize:13,lineHeight:1.6}})})]}),S&&C.jsxs(C.Fragment,{children:[C.jsx(D4,{style:{margin:"12px 0"}}),C.jsx(_7,{strong:!0,style:{display:"block",marginBottom:8},children:"Sub-Agents"}),C.jsx(Osr,{subAgentKeys:x,decisions:u,onChange:d})]})]})},ksr=Msr,Lsr=({onChat:e})=>{const{setCenter:t,fitView:n}=LC(),[r,a,i]=$ve([]),[o,l,s]=Fve([]),[c,u]=b.useState([]),[d,f]=b.useState(!1),[p,h]=b.useState(!1),[g,m]=b.useState(null),[A,v]=b.useState(!1),{get:y,del:_,put:x}=_l(),{config:S}=Zo(),{token:E}=Xl.useToken(),{enableAssistantCreation:w=!0,enableAssistantEditing:T=!0}=S,N=b.useMemo(()=>({assistant:ysr}),[]),R=b.useCallback(U=>{m(U),h(!0)},[]),k=b.useCallback(()=>{h(!1),m(null)},[]),O=b.useCallback(({nodes:U})=>{if(U.length===1&&T){const H=U[0].data;H!=null&&H.assistant&&(m(H.assistant),h(!0))}else U.length===0&&(h(!1),m(null))},[T]),M=async()=>{f(!0);try{const U=await y("/api/assistants");U.success&&U.data&&Array.isArray(U.data.records)&&u(U.data.records)}catch(U){console.error("Failed to fetch assistants:",U),u([])}finally{f(!1)}};b.useEffect(()=>{M()},[]),b.useEffect(()=>{if(!c||c.length===0){a([]),l([]);return}const U=[],H=[],G=320,F=300,z=Math.ceil(Math.sqrt(c.length)),W=new Map,q=[];if(c.forEach(Z=>{W.set(Z.id,Z)}),c.forEach(Z=>{if(Z.graphDefinition)try{const Y=typeof Z.graphDefinition=="string"?JSON.parse(Z.graphDefinition):Z.graphDefinition;Y.subAgents&&Array.isArray(Y.subAgents)&&Y.subAgents.forEach(ee=>{const ae=c.find(ne=>ne.id===ee||ne.id===String(ee));ae&&ae.id!==Z.id&&q.push({source:Z.id,target:ae.id})}),Y.internalSubAgents&&Array.isArray(Y.internalSubAgents)&&Y.internalSubAgents.forEach(ee=>{if(ee.key){const ae=c.find(ne=>ne.id===ee.key||ne.id===String(ee.key));ae&&ae.id!==Z.id&&q.push({source:Z.id,target:ae.id})}}),Y.nodes&&Array.isArray(Y.nodes)&&Y.nodes.forEach(ee=>{if(ee.assistantId&&ee.assistantId!==Z.id){const ae=c.find(ne=>ne.id===ee.assistantId||ne.id===String(ee.assistantId));ae&&q.push({source:Z.id,target:ae.id})}}),Y.edges&&Array.isArray(Y.edges)&&Y.edges.forEach(ee=>{if(ee.source&&ee.target){const ae=typeof ee.source=="string"?ee.source:ee.source.id||ee.source.assistantId,ne=typeof ee.target=="string"?ee.target:ee.target.id||ee.target.assistantId,te=c.find(pe=>pe.id===ae||pe.id===String(ae)),se=c.find(pe=>pe.id===ne||pe.id===String(ne));te&&se&&q.push({source:te.id,target:se.id})}})}catch(Y){console.warn(`Failed to parse graphDefinition for assistant ${Z.id}:`,Y)}}),q.length>0){const Z=new Set,Y=new Map,ee=new Map;q.forEach(se=>{ee.has(se.source)||ee.set(se.source,[]),ee.get(se.source).push(se.target)});const ae=[],ne=c.filter(se=>!q.some(pe=>pe.target===se.id));for(ne.length===0&&c.length>0?ae.push({id:c[0].id,level:0}):ne.forEach(se=>{ae.push({id:se.id,level:0})});ae.length>0;){const{id:se,level:pe}=ae.shift();if(Z.has(se))continue;Z.add(se),Y.set(se,pe),(ee.get(se)||[]).forEach(ie=>{Z.has(ie)||ae.push({id:ie,level:pe+1})})}c.forEach(se=>{Y.has(se.id)||Y.set(se.id,0)});const te=new Map;c.forEach(se=>{const pe=Y.get(se.id)||0;te.has(pe)||te.set(pe,[]),te.get(pe).push(se)}),te.forEach((se,pe)=>{const ue=pe*F,be=-((se.length-1)*G)/2;se.forEach((de,ve)=>{const he=be+ve*G;U.push({id:de.id,type:"assistant",data:{assistant:de,onConfigure:T?()=>R(de):void 0,onChat:e},position:{x:he,y:ue}})})}),q.forEach(se=>{W.has(se.source)&&W.has(se.target)&&H.push({id:`e${se.source}-${se.target}`,source:se.source,target:se.target,animated:!0,style:{stroke:"#1677ff"},type:"smoothstep"})})}else c.forEach((Z,Y)=>{const ee=Math.floor(Y/z),ne=Y%z*G-(z-1)*G/2,te=ee*F;U.push({id:Z.id,type:"assistant",data:{assistant:Z,onConfigure:T?()=>R(Z):void 0,onChat:e},position:{x:ne,y:te}})});a(U),l(H)},[c,a,l,R,e]);const D=async(U,H)=>{try{const F={...typeof U.graphDefinition=="string"?JSON.parse(U.graphDefinition||"{}"):U.graphDefinition||{},...H},z=await x(`/api/assistants/${U.id}`,{name:H.name??U.name,description:H.description??U.description,graphDefinition:F});if(z.success)u(W=>W.map(q=>q.id===U.id?{...q,name:H.name??U.name,description:H.description??U.description,graphDefinition:F}:q)),vp.success({message:"Saved",description:z.message||"Agent configuration saved successfully"});else throw bn.error(z.message||"Failed to save agent configuration"),new Error(z.message||"Failed to save agent configuration")}catch(G){throw console.error("Failed to save agent configuration:",G),bn.error(G instanceof Error?G.message:"Failed to save agent configuration"),G}},B=async U=>{try{const H=await _(`/api/assistants/${U.id}`);if(H.success)u(G=>G.filter(F=>F.id!==U.id)),(g==null?void 0:g.id)===U.id&&(m(null),h(!1)),vp.success({message:"Deleted",description:"Assistant deleted successfully"});else throw bn.error(H.message||"Failed to delete assistant"),new Error(H.message||"Failed to delete assistant")}catch(H){throw console.error("Failed to delete assistant:",H),bn.error(H instanceof Error?H.message:"Failed to delete assistant"),H}},$=U=>{u(H=>H.some(F=>F.id===U.id)?H.map(F=>F.id===U.id?U:F):[...H,U]),P.current=U};b.useEffect(()=>{if(g){const U=r.find(H=>H.id===g.id);U&&t(U.position.x+140,U.position.y+100,{zoom:1,duration:800})}},[g,r,t]),b.useEffect(()=>{c.length>0&&g&&c.find(H=>H.id===g.id)&&!p&&h(!0)},[c,g,p]);const P=b.useRef(null);return b.useEffect(()=>{if(P.current&&!c.find(U=>{var H;return U.id===((H=P.current)==null?void 0:H.id)})&&(P.current=null),P.current){const U=r.find(H=>H.id===P.current.id);U&&(t(U.position.x+140,U.position.y+100,{zoom:1,duration:800}),m(P.current),h(!0),P.current=null)}},[r,t]),d?C.jsx("div",{style:{width:"100%",height:"100%",display:"flex",justifyContent:"center",alignItems:"center",background:"#fafafa"},children:"Loading assistants..."}):C.jsxs("div",{style:{width:"100%",height:"100%",display:"flex"},children:[C.jsxs("div",{style:{flex:1,height:"100%",background:"#fafafa",position:"relative"},children:[C.jsxs(Pve,{nodes:r,edges:o,onNodesChange:i,onEdgesChange:s,onSelectionChange:O,nodeTypes:N,fitView:!0,children:[C.jsx(Uve,{color:"#eee",gap:20}),C.jsx(zve,{})]}),w&&C.jsx("div",{style:{position:"absolute",top:20,right:20,zIndex:10},children:C.jsx(tn,{type:"primary",size:"large",icon:C.jsx(u5,{}),onClick:()=>v(!0),style:{height:48,width:48,borderRadius:"50%",boxShadow:E.boxShadowTertiary,display:"flex",alignItems:"center",justifyContent:"center",padding:0}})})]}),C.jsx(Isr,{visible:p,assistant:g,allAssistants:c,onClose:k,onSave:D,onDelete:B}),C.jsx(ksr,{open:A,onCancel:()=>v(!1),onSuccess:$})]})},Dsr=e=>C.jsx(rF,{children:C.jsx(Lsr,{...e})}),Bsr=Dsr,{Text:tc}=fr,{TextArea:oGe}=Jn,Psr=e=>{const t=["#1890ff","#52c41a","#faad14","#f5222d","#722ed1","#13c2c2","#eb2f96","#fa8c16"];let n=0;for(let r=0;r<e.length;r++)n=e.charCodeAt(r)+((n<<5)-n);return t[Math.abs(n)%t.length]},$sr=({data:e})=>{var H;const{token:t}=Xl.useToken(),{config:n}=Zo(),{put:r}=_l(),a=v1("__GLOBAL__");if(!e)return null;const{skill:i,onClick:o,onDelete:l}=e;if(!i)return null;const[s,c]=b.useState(i),u=Psr(s.name),d=((H=s.name)==null?void 0:H.split("-").map(G=>G.charAt(0)).join("").toUpperCase().slice(0,2))||"SK",f=s.subSkills&&s.subSkills.length>0,p=s.metadata&&s.metadata.category||"global",h=b.useMemo(()=>s.metadata?Object.entries(s.metadata).filter(([G,F])=>G&&F):[],[s.metadata]),g=G=>{if(!G)return"";const F=G instanceof Date?G:new Date(G);return Number.isNaN(F.getTime())?"":F.toLocaleString()},m=G=>{navigator.clipboard.writeText(G)},[A,v]=b.useState(!1),[y,_]=b.useState({...i,id:i.name}),[x,S]=b.useState(h.map(([G,F])=>({key:G,value:F}))),[E,w]=b.useState(!1),[T,N]=b.useState(!1);b.useEffect(()=>{v(!1),c(i),_({...i,id:i.name}),S(Object.entries(i.metadata||{}).map(([G,F])=>({key:G,value:F})))},[i]);const R=(G,F)=>{if(G==="name"){_(z=>({...z,name:F,id:F}));return}_(z=>({...z,[G]:F}))},k=async G=>{G==null||G.stopPropagation(),G==null||G.preventDefault();try{const F=s.id||s.name;if(!F){bn.error("Skill ID is missing");return}await a.skills.delete(F),vp.success({message:"Deleted",description:"Skill deleted successfully"}),w(!1),l&&await l()}catch(F){bn.error((F==null?void 0:F.message)||"An error occurred while deleting the skill")}},O=G=>{S(G);const F=G.reduce((z,W)=>(W.key&&(z[W.key]=W.value),z),{});_(z=>({...z,metadata:F}))},M=(G,F,z)=>{const W=[...x];W[G]={...W[G],[F]:z},O(W)},D=()=>{O([...x,{key:"",value:""}])},B=async()=>{try{N(!0);const G={"Content-Type":"application/json"};n.apiKey&&(G.Authorization=`Bearer ${n.apiKey}`);const F={name:y.name,description:y.description,license:y.license||void 0,compatibility:y.compatibility||void 0,metadata:y.metadata||void 0,content:y.content||void 0,subSkills:y.subSkills||void 0},z=await r(`/api/skills/${s.id}`,F);if(z.success){vp.success({message:"Saved",description:"Skill updated successfully"});const W=z.data||y;c(W),_({...W,id:W.name}),S(Object.entries(W.metadata||{}).map(([q,Q])=>({key:q,value:Q}))),v(!1),o==null||o(W)}else bn.error(z.message||"Failed to update skill")}catch(G){bn.error(G.message||"An error occurred while updating the skill")}finally{N(!1)}},$=C.jsxs("div",{style:{display:"flex",flexDirection:"row",gap:24},children:[C.jsxs("div",{style:{flex:"0 0 320px",display:"flex",flexDirection:"column",gap:12},children:[C.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[C.jsx(tc,{style:{fontSize:12,color:t.colorTextSecondary},children:"Description"}),C.jsx(oGe,{value:y.description,onChange:G=>R("description",G.target.value),placeholder:"Description",rows:3})]}),C.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[C.jsx(tc,{style:{fontSize:12,color:t.colorTextSecondary},children:"License"}),C.jsx(Jn,{value:y.license,onChange:G=>R("license",G.target.value),placeholder:"License"})]}),C.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[C.jsx(tc,{style:{fontSize:12,color:t.colorTextSecondary},children:"Compatibility"}),C.jsx(Jn,{value:y.compatibility,onChange:G=>R("compatibility",G.target.value),placeholder:"Compatibility"})]}),C.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8},children:[C.jsx(tc,{style:{fontSize:12,color:t.colorTextSecondary,fontWeight:500},children:"Metadata"}),C.jsx(tn,{size:"small",icon:C.jsx(u5,{}),onClick:D,children:"Add"})]}),C.jsxs(rr,{direction:"vertical",size:8,style:{width:"100%"},children:[x.length===0&&C.jsx(tc,{style:{fontSize:11,color:t.colorTextTertiary},children:"No metadata yet. Use Add to create one."}),x.map((G,F)=>C.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:4,width:"100%"},children:[C.jsxs(tc,{style:{fontSize:11,color:t.colorTextSecondary},children:["Meta ",F+1]}),C.jsxs(rr,{style:{width:"100%"},size:8,wrap:!0,children:[C.jsx(Jn,{value:G.key,placeholder:"Key",style:{width:120},onChange:z=>M(F,"key",z.target.value)}),C.jsx(Jn,{value:G.value,placeholder:"Value",style:{flex:1,minWidth:160},onChange:z=>M(F,"value",z.target.value)})]})]},F))]})]}),C.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",gap:6,minWidth:400},children:[C.jsx(tc,{style:{fontSize:12,color:t.colorTextSecondary},children:"Content"}),C.jsx(oGe,{value:y.content,onChange:G=>R("content",G.target.value),placeholder:"Enter skill content here...",rows:30,style:{fontFamily:"monospace",fontSize:13,flex:1,minHeight:600}})]})]}),P=C.jsxs("div",{style:{width:A?960:720,maxHeight:"95vh",overflowY:"auto",padding:24},children:[C.jsx("div",{style:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",marginBottom:16},children:C.jsxs("div",{style:{flex:1},children:[C.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:8},children:[C.jsx(tc,{strong:!0,style:{fontSize:18,fontWeight:600,color:t.colorText},children:s.name}),C.jsx(Kr,{style:{margin:0,fontSize:10,padding:"2px 8px",fontWeight:600},color:"geekblue",children:p.toUpperCase()})]}),C.jsx("div",{style:{display:"flex",alignItems:"center",gap:6},children:C.jsx(tc,{style:{fontSize:11,color:t.colorTextTertiary,fontFamily:"monospace"},children:`>_ ${s.id}`})})]})}),A?$:C.jsxs(C.Fragment,{children:[s.description&&C.jsx("div",{style:{marginBottom:16},children:C.jsxs(tc,{style:{fontSize:12,color:t.colorText,lineHeight:1.6,fontStyle:"italic"},children:['"',s.description,'"']})}),h.length>0&&C.jsxs("div",{style:{marginBottom:16},children:[C.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:8},children:[C.jsx(Rx,{style:{fontSize:14,color:t.colorTextSecondary}}),C.jsxs(tc,{style:{fontSize:12,color:t.colorTextSecondary,fontWeight:500},children:["Metadata (",h.length,")"]})]}),C.jsx("div",{style:{border:`1px solid ${t.colorBorderSecondary}`,borderRadius:6,overflow:"hidden"},children:h.map(([G,F],z)=>C.jsxs("div",{style:{display:"flex",alignItems:"stretch",borderBottom:z===h.length-1?"none":`1px solid ${t.colorBorderSecondary}`},children:[C.jsx("div",{style:{width:140,padding:"8px 10px",background:t.colorFillTertiary,borderRight:`1px solid ${t.colorBorderSecondary}`,fontSize:11,color:t.colorTextSecondary,fontWeight:600,textTransform:"capitalize"},children:G}),C.jsx("div",{style:{flex:1,padding:"8px 10px",fontSize:11,color:t.colorText,wordBreak:"break-word"},children:F})]},G))})]}),f&&C.jsxs("div",{style:{marginBottom:16},children:[C.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:8},children:[C.jsx(jre,{style:{fontSize:14,color:t.colorTextSecondary}}),C.jsxs(tc,{style:{fontSize:12,color:t.colorTextSecondary,fontWeight:500},children:["Sub-Skills (",s.subSkills.length,")"]})]}),C.jsx(rr,{size:[8,8],wrap:!0,children:s.subSkills.map((G,F)=>C.jsx(Kr,{style:{fontSize:11,padding:"4px 12px",backgroundColor:t.colorFillTertiary,color:t.colorText,border:`1px solid ${t.colorBorderSecondary}`},children:G},F))})]}),(s.license||s.compatibility)&&C.jsx("div",{style:{marginBottom:16},children:C.jsxs(rr,{size:[8,8],wrap:!0,children:[s.license&&C.jsx(Kr,{icon:C.jsx(w8e,{}),style:{margin:0,fontSize:11,padding:"4px 12px",borderRadius:6,backgroundColor:t.colorInfoBg,color:t.colorInfo,border:`1px solid ${t.colorInfoBorder}`,fontWeight:500,lineHeight:"16px"},children:s.license}),s.compatibility&&C.jsx(Kr,{style:{margin:0,fontSize:11,padding:"4px 12px",borderRadius:6,backgroundColor:t.colorSuccessBg,color:t.colorSuccess,border:`1px solid ${t.colorSuccessBorder}`,fontWeight:500,lineHeight:"16px",display:"inline-flex",alignItems:"center",gap:4},children:s.compatibility})]})}),(s.createdAt||s.updatedAt)&&C.jsx("div",{style:{marginBottom:16},children:C.jsxs(rr,{direction:"vertical",size:4,children:[s.createdAt&&C.jsxs(tc,{style:{fontSize:11,color:t.colorTextTertiary,fontFamily:"monospace"},children:["Created: ",g(s.createdAt)]}),s.updatedAt&&C.jsxs(tc,{style:{fontSize:11,color:t.colorTextTertiary,fontFamily:"monospace"},children:["Updated: ",g(s.updatedAt)]})]})}),s.content&&C.jsxs("div",{style:{marginBottom:0},children:[C.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:8},children:[C.jsx(q2,{style:{fontSize:14,color:t.colorTextSecondary}}),C.jsx(tc,{style:{fontSize:12,color:t.colorTextSecondary,fontWeight:600,letterSpacing:.5},children:"CONTENT"})]}),C.jsx("div",{style:{padding:16,background:t.colorFillTertiary,border:`1px solid ${t.colorBorderSecondary}`,borderRadius:6,maxHeight:400,overflowY:"auto"},children:C.jsx(tc,{style:{fontSize:12,color:t.colorText,lineHeight:1.7,whiteSpace:"pre-wrap",fontFamily:"monospace"},children:s.content})})]})]}),C.jsx(D4,{style:{margin:"16px 0"}}),C.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8},children:A?C.jsxs(C.Fragment,{children:[C.jsx(tn,{block:!0,onClick:()=>{v(!1),_(i)},style:{flex:1},children:"Cancel"}),C.jsx(tn,{type:"primary",block:!0,onClick:B,loading:T,style:{flex:1},children:"Save"})]}):C.jsxs(C.Fragment,{children:[C.jsx(tn,{type:"primary",block:!0,onClick:()=>v(!0),style:{flex:1},children:"Edit Skill"}),C.jsx(tn,{danger:!0,onClick:G=>{G.stopPropagation(),k(G)},children:"Delete"}),C.jsx(tn,{icon:C.jsx(TXe,{}),onClick:()=>m(s.id),title:"Copy ID"})]})})]}),U={opacity:0,background:"transparent",border:"none",width:0,height:0,pointerEvents:"none"};return C.jsxs("div",{style:{padding:4},children:[C.jsx(j3,{type:"target",position:Br.Top,style:U,isConnectable:!1}),C.jsx("div",{onClick:()=>{w(!0)},style:{width:280,minHeight:200,background:t.colorBgContainer,borderRadius:8,boxShadow:"0 1px 6px rgba(0, 0, 0, 0.08)",cursor:o?"pointer":"default",overflow:"hidden",transition:"all 0.2s ease",position:"relative",border:`1px solid ${t.colorBorder}`,display:"flex",flexDirection:"column"},onMouseEnter:G=>{o&&(G.currentTarget.style.transform="translateY(-2px)",G.currentTarget.style.boxShadow="0 2px 8px rgba(0, 0, 0, 0.12)")},onMouseLeave:G=>{G.currentTarget.style.transform="translateY(0)",G.currentTarget.style.boxShadow="0 1px 4px rgba(0, 0, 0, 0.08)"},children:C.jsxs("div",{style:{padding:12,display:"flex",flexDirection:"column",gap:10},children:[C.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:10},children:[C.jsxs("div",{style:{position:"relative",flexShrink:0},children:[C.jsx(wg,{size:44,icon:C.jsx(wFt,{}),style:{backgroundColor:u,color:"#fff",fontSize:16,fontWeight:600},children:d}),f&&C.jsx("div",{style:{position:"absolute",bottom:-2,right:-2,width:18,height:18,borderRadius:"50%",background:t.colorPrimary,border:`2px solid ${t.colorBgContainer}`,display:"flex",alignItems:"center",justifyContent:"center"},children:C.jsx(jre,{style:{fontSize:10,color:"#fff"}})})]}),C.jsxs("div",{style:{flex:1,minWidth:0},children:[C.jsx(tc,{strong:!0,style:{fontSize:14,fontWeight:600,display:"block",marginBottom:3,color:t.colorText,lineHeight:1.3},ellipsis:{tooltip:s.name},children:s.name}),C.jsxs("div",{style:{display:"flex",alignItems:"center",gap:4},children:[C.jsx(q2,{style:{fontSize:9,color:t.colorTextTertiary}}),C.jsx(tc,{style:{fontSize:9,color:t.colorTextTertiary},ellipsis:{tooltip:s.id},children:s.id})]})]})]}),s.description&&C.jsx("div",{style:{padding:8,background:t.colorFillTertiary,border:`1px solid ${t.colorBorderSecondary}`,borderRadius:4,borderLeft:`2px solid ${u}`},children:C.jsx(Gr,{title:s.description.length>150?s.description:void 0,placement:"top",children:C.jsxs("div",{style:{fontSize:10,color:t.colorText,lineHeight:1.5,fontStyle:"italic",display:"-webkit-box",WebkitLineClamp:3,WebkitBoxOrient:"vertical",overflow:"hidden",textOverflow:"ellipsis",cursor:s.description.length>150?"help":"default"},children:['"',s.description,'"']})})}),C.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:4,padding:"4px 0",marginTop:"auto"},children:[C.jsx(Kr,{style:{margin:0,fontSize:8,padding:"2px 6px",borderRadius:6,backgroundColor:t.colorPrimaryBg,color:t.colorPrimary,border:`1px solid ${t.colorPrimaryBorder}`,fontWeight:600,lineHeight:"14px",textTransform:"capitalize"},children:p.toUpperCase()}),f&&C.jsxs(Kr,{style:{margin:0,fontSize:8,padding:"2px 6px",borderRadius:6,backgroundColor:t.colorSuccessBg,color:t.colorSuccess,border:`1px solid ${t.colorSuccessBorder}`,fontWeight:500,lineHeight:"14px",display:"inline-flex",alignItems:"center"},children:["SUB-SKILLS (",s.subSkills.length,")"]}),s.license&&C.jsx(Kr,{style:{margin:0,fontSize:7,padding:"2px 6px",borderRadius:6,backgroundColor:t.colorInfoBg,color:t.colorInfo,border:`1px solid ${t.colorInfoBorder}`,fontWeight:500,lineHeight:"14px"},icon:C.jsx(w8e,{}),children:s.license}),s.compatibility&&C.jsx(Kr,{style:{margin:0,fontSize:7,padding:"2px 6px",borderRadius:6,backgroundColor:t.colorSuccessBg,color:t.colorSuccess,border:`1px solid ${t.colorSuccessBorder}`,fontWeight:500,lineHeight:"14px"},icon:C.jsx(Rx,{}),children:s.compatibility})]})]})}),C.jsx(Gi,{open:E,onCancel:()=>{w(!1),v(!1),_({...s,id:s.name})},footer:null,width:A?1e3:760,destroyOnClose:!0,title:null,styles:{body:{padding:0}},children:P}),C.jsx(j3,{type:"source",position:Br.Bottom,style:U,isConnectable:!1})]})},Fsr=$sr,{TextArea:lGe}=Jn,{Text:bm}=fr,Usr=({open:e,onCancel:t,onSuccess:n})=>{const[r]=Dr.useForm(),[a,i]=b.useState(!1),{post:o}=_l(),{token:l}=Xl.useToken(),s=[{key:"category",value:"global"}],[c,u]=b.useState(s),d=async()=>{try{const g=await r.validateFields();i(!0);const m=c.length>0?c.reduce((y,_)=>(_.key&&(y[_.key]=_.value),y),{}):void 0,A={id:g.name,name:g.name,description:g.description,license:g.license||void 0,compatibility:g.compatibility||void 0,metadata:m,content:g.content||void 0,subSkills:void 0},v=await o("/api/skills",A);v.success?(vp.success({message:"Created",description:"Skill created successfully"}),r.resetFields(),u(s),n==null||n(),t()):bn.error(v.message||"Failed to create skill")}catch(g){if(g.errorFields)return;bn.error(g.message||"An error occurred while creating the skill")}finally{i(!1)}},f=()=>{r.resetFields(),u(s),t()},p=(g,m,A)=>{const v=[...c];v[g]={...v[g],[m]:A},u(v)},h=()=>{u([...c,{key:"",value:""}])};return C.jsx(Gi,{title:"Create New Skill",open:e,onCancel:f,footer:null,width:520,destroyOnClose:!0,styles:{body:{padding:16}},children:C.jsx(Dr,{form:r,layout:"vertical",onFinish:d,autoComplete:"off",children:C.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12},children:[C.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[C.jsx(bm,{style:{fontSize:12,color:l.colorTextSecondary},children:"Name"}),C.jsx(Dr.Item,{name:"name",rules:[{required:!0,message:"Please enter skill name"},{pattern:/^[a-z0-9]+(-[a-z0-9]+)*$/,message:"Name must be lowercase alphanumeric with single hyphens (e.g., 'my-skill')"},{min:1,max:64,message:"Name must be 1-64 characters"}],style:{marginBottom:0},children:C.jsx(Jn,{placeholder:"e.g., data-analysis"})})]}),C.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[C.jsx(bm,{style:{fontSize:12,color:l.colorTextSecondary},children:"Description"}),C.jsx(Dr.Item,{name:"description",rules:[{required:!0,message:"Please enter skill description"}],style:{marginBottom:0},children:C.jsx(lGe,{placeholder:"Description",autoSize:{minRows:2,maxRows:4}})})]}),C.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[C.jsx(bm,{style:{fontSize:12,color:l.colorTextSecondary},children:"License"}),C.jsx(Dr.Item,{name:"license",style:{marginBottom:0},children:C.jsx(Jn,{placeholder:"License"})})]}),C.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[C.jsx(bm,{style:{fontSize:12,color:l.colorTextSecondary},children:"Compatibility"}),C.jsx(Dr.Item,{name:"compatibility",style:{marginBottom:0},children:C.jsx(Jn,{placeholder:"Compatibility"})})]}),C.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[C.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8},children:[C.jsx(bm,{style:{fontSize:12,color:l.colorTextSecondary,fontWeight:500},children:"Metadata"}),C.jsx(tn,{size:"small",icon:C.jsx(u5,{}),onClick:h,children:"Add"})]}),C.jsxs(rr,{direction:"vertical",size:8,style:{width:"100%"},children:[c.length===0&&C.jsx(bm,{style:{fontSize:11,color:l.colorTextTertiary},children:"No metadata yet. Use Add to create one."}),c.map((g,m)=>C.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:4,width:"100%"},children:[C.jsxs(bm,{style:{fontSize:11,color:l.colorTextSecondary},children:["Meta ",m+1]}),C.jsxs(rr,{style:{width:"100%"},size:8,wrap:!0,children:[C.jsx(Jn,{value:g.key,placeholder:"Key",style:{width:140},onChange:A=>p(m,"key",A.target.value)}),C.jsx(Jn,{value:g.value,placeholder:"Value",style:{flex:1,minWidth:200},onChange:A=>p(m,"value",A.target.value)})]})]},m))]})]}),C.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[C.jsx(bm,{style:{fontSize:12,color:l.colorTextSecondary},children:"Content"}),C.jsx(Dr.Item,{name:"content",style:{marginBottom:0},children:C.jsx(lGe,{placeholder:"Content",autoSize:{minRows:4,maxRows:8}})})]}),C.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"flex-end",gap:8,marginTop:8},children:[C.jsx(tn,{onClick:f,children:"Cancel"}),C.jsx(tn,{type:"primary",htmlType:"submit",loading:a,children:"Create Skill"})]})]})})})},zsr=Usr,Hsr=({onNodeClick:e})=>{const[t,n,r]=$ve([]),[a,i,o]=Fve([]),[l,s]=b.useState(!1),[c,u]=b.useState([]),[d,f]=b.useState(!1),{token:p}=Xl.useToken(),{get:h}=_l(),g=b.useMemo(()=>({skill:Fsr}),[]),m=async()=>{f(!0);try{const v=await h("/api/skills");v.success&&v.data&&Array.isArray(v.data.records)&&u(v.data.records)}catch(v){console.error("Failed to fetch skills:",v),u([])}finally{f(!1)}};b.useEffect(()=>{m()},[]),b.useEffect(()=>{if(!c||c.length===0){n([]),i([]);return}const v=[],y=[],_=320,x=300,S=new Map,E=[],w=new Map;if(c.forEach(N=>{S.set(N.name,N),N.subSkills&&N.subSkills.length>0&&(w.has(N.name)||w.set(N.name,[]),N.subSkills.forEach(R=>{c.find(O=>O.name===R)&&(E.push({source:N.name,target:R}),w.get(N.name).push(R))}))}),E.length>0){const N=new Set,R=new Map,k=new Map;E.forEach(B=>{k.set(B.target,B.source)});const O=[],M=c.filter(B=>!k.has(B.name));for(M.length===0&&c.length>0?O.push({id:c[0].name,level:0}):M.forEach(B=>{O.push({id:B.name,level:0})});O.length>0;){const{id:B,level:$}=O.shift();if(N.has(B))continue;N.add(B),R.set(B,$),(w.get(B)||[]).forEach(U=>{N.has(U)||O.push({id:U,level:$+1})})}c.forEach(B=>{R.has(B.name)||R.set(B.name,0)});const D=new Map;c.forEach(B=>{const $=R.get(B.name)||0;D.has($)||D.set($,[]),D.get($).push(B)}),D.forEach((B,$)=>{const P=$*x,H=-((B.length-1)*_)/2;B.forEach((G,F)=>{const z=H+F*_;v.push({id:G.name,type:"skill",data:{skill:G,onClick:()=>e==null?void 0:e(G),onDelete:m},position:{x:z,y:P}})})}),E.forEach(B=>{S.has(B.source)&&S.has(B.target)&&y.push({id:`e${B.source}-${B.target}`,source:B.source,target:B.target,style:{stroke:"#1677ff",strokeWidth:2},type:"smoothstep"})})}else{const N=Math.ceil(Math.sqrt(c.length));c.forEach((R,k)=>{const O=Math.floor(k/N),D=k%N*_-(N-1)*_/2,B=O*x;v.push({id:R.name,type:"skill",data:{skill:R,onClick:()=>e==null?void 0:e(R)},position:{x:D,y:B}})})}n(v),i(y)},[c,n,i,e]);const A=async()=>{await m()};return d?C.jsx("div",{style:{width:"100%",height:"100%",display:"flex",justifyContent:"center",alignItems:"center",background:"#fafafa"},children:"Loading skills..."}):C.jsxs("div",{style:{width:"100%",height:"100%",background:"#fafafa",position:"relative"},children:[C.jsxs(Pve,{nodes:t,edges:a,onNodesChange:r,onEdgesChange:o,nodeTypes:g,fitView:!0,children:[C.jsx(Uve,{color:"#eee",gap:20}),C.jsx(zve,{})]}),C.jsx("div",{style:{position:"absolute",top:20,right:20,zIndex:10},children:C.jsx(tn,{type:"primary",size:"large",icon:C.jsx(u5,{}),onClick:()=>s(!0),style:{height:48,width:48,borderRadius:"50%",boxShadow:p.boxShadowTertiary,display:"flex",alignItems:"center",justifyContent:"center",padding:0}})}),C.jsx(zsr,{open:l,onCancel:()=>s(!1),onSuccess:A})]})},jsr=e=>C.jsx(rF,{children:C.jsx(Hsr,{...e})}),Gsr=jsr,Vsr=({onToolSelect:e,autoLoad:t=!0})=>{const{token:n}=Xl.useToken(),{get:r}=_l(),[a,i]=b.useState({tools:[],isLoading:!1,error:null}),[o,l]=b.useState(null),s=b.useCallback(async()=>{i(f=>({...f,isLoading:!0,error:null}));try{const f=await r("/api/tools");if(f.success&&f.data&&Array.isArray(f.data.records))i(p=>({...p,tools:f.data.records,isLoading:!1}));else throw new Error("Invalid response format")}catch(f){i(p=>({...p,tools:[],isLoading:!1,error:f instanceof Error?f:new Error(String(f))}))}},[r]),c=b.useCallback(f=>{l(f.id),e==null||e(f)},[e]),u=b.useCallback(()=>{s()},[s]);b.useEffect(()=>{t&&s()},[t,s]);const d={width:"100%",height:"100%",background:"transparent",borderRadius:n.borderRadius,padding:n.paddingSM};return a.error?C.jsx("div",{style:d,children:C.jsx(zh,{message:"Error Loading Tools",description:a.error.message,type:"error",showIcon:!0,action:C.jsx(tn,{size:"small",icon:C.jsx(xS,{}),onClick:u,children:"Retry"})})}):C.jsxs("div",{style:{position:"relative",width:"100%",height:"100%"},children:[C.jsx("div",{style:{position:"absolute",top:n.paddingSM,right:n.paddingSM,zIndex:1},children:C.jsx(tn,{type:"text",size:"small",icon:C.jsx(xS,{}),onClick:u,title:"Refresh tools",style:{color:n.colorTextSecondary}})}),C.jsx("div",{style:{width:"100%",height:"100%",overflowY:"auto",overflowX:"hidden",paddingTop:n.paddingLG},children:C.jsx(Ha,{dataSource:a.tools,loading:a.isLoading,locale:{emptyText:C.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:n.marginSM,padding:n.paddingLG},children:[C.jsx("div",{style:{color:n.colorTextSecondary},children:"No tools available"}),C.jsx(tn,{icon:C.jsx(xS,{}),onClick:u,type:"dashed",size:"small",children:"Refresh"})]})},style:{...d,paddingTop:0},renderItem:f=>C.jsx(Ha.Item,{onClick:()=>c(f),style:{cursor:"pointer",padding:n.paddingSM,borderRadius:n.borderRadius,backgroundColor:o===f.id?n.colorFillSecondary:"transparent",transition:"background-color 0.2s"},onMouseEnter:p=>{o!==f.id&&(p.currentTarget.style.backgroundColor=n.colorFillTertiary)},onMouseLeave:p=>{o!==f.id&&(p.currentTarget.style.backgroundColor="transparent")},children:C.jsx(Ha.Item.Meta,{avatar:C.jsx(wg,{size:"small",style:{backgroundColor:n.colorFillSecondary,color:n.colorText},children:f.name.charAt(0).toUpperCase()}),title:C.jsxs("div",{style:{display:"flex",alignItems:"center",gap:n.marginXS},children:[C.jsx("span",{children:f.name}),f.needUserApprove&&C.jsx(Kr,{color:"warning",style:{fontSize:"10px",padding:"2px 6px",margin:0,lineHeight:"1.2"},children:"Requires approval"})]}),description:C.jsx("div",{style:{color:n.colorTextSecondary,fontSize:n.fontSizeSM,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:f.description})})},f.id)})})]})},cv=e=>()=>C.jsx(e,{}),Wsr=({workspaceId:e,workspaceName:t,logo:n})=>{const{openContentApp:r,menuCollapsed:a,setMenuCollapsed:i}=pl(),o=b.useRef(!1),l=b.useRef(!1);b.useEffect(()=>{l.current||(l.current=!0,Mm("workspace_projects",{card_view:()=>null,side_app_view:cv(asr)}),Mm("workspace_metrics",{card_view:()=>null,side_app_view:cv(lsr)}),Mm("workspace_database",{card_view:()=>null,side_app_view:cv(dsr)}),Mm("workspace_assistants",{card_view:()=>null,side_app_view:cv(Bsr)}),Mm("workspace_skills",{card_view:()=>null,side_app_view:cv(Gsr)}),Mm("workspace_mcp",{card_view:()=>null,side_app_view:cv(gsr)}),Mm("workspace_tools",{card_view:()=>null,side_app_view:cv(()=>C.jsx(Vsr,{onToolSelect:E=>{console.log("Tool selected:",E)}}))}))},[]);const{user:s,logout:c,tenants:u,currentTenant:d,selectTenant:f,isLoading:p}=A1(),{setWorkspace:h,setProject:g}=lF(),[m,A]=b.useState(!1),[v,y]=b.useState(!1),_=b.useMemo(()=>[{id:"workspace_projects",type:"route",name:"Projects",icon:C.jsx(Nx,{size:20}),order:0},{id:"metrics",builtin:"metrics",type:"route",name:"Metrics",icon:C.jsx(sB,{size:20}),order:10,group:"DataSource"},{id:"database",builtin:"database",type:"route",name:"Database",icon:C.jsx(G0,{size:20}),order:20,group:"DataSource"},{id:"assistants",builtin:"assistants",type:"route",name:"Assistants",icon:C.jsx(Bie,{size:20}),order:30,group:"Settings"},{id:"skills",builtin:"skills",type:"route",name:"Skills",icon:C.jsx(cVt,{size:20}),order:35,group:"Settings"},{id:"mcp",builtin:"mcp",type:"route",name:"MCP",icon:C.jsx($ie,{size:20}),order:40,group:"Settings"},{id:"tools",builtin:"tools",type:"route",name:"Tools",icon:C.jsx(lVt,{size:20}),order:50,group:"Settings"},{id:"switch_tenant",builtin:"switch-tenant",type:"action",name:"Switch tenant",icon:C.jsx(wfe,{size:20}),order:900,group:"Account"}],[t]),x=E=>{if(E.type==="action"&&E.builtin==="switch-tenant"){A(!0);return}if(E.type==="route"){const T={workspace_projects:"workspace_projects",metrics:"workspace_metrics",database:"workspace_database",assistants:"workspace_assistants",skills:"workspace_skills",mcp:"workspace_mcp",tools:"workspace_tools"}[E.id];T&&r({component_key:T,data:{},message:E.name})}};b.useEffect(()=>{o.current||(o.current=!0,r({component_key:"workspace_projects",data:{},message:"Projects"}))},[r]);const S=C.jsxs("div",{style:{minWidth:160},children:[C.jsxs("div",{style:{padding:"8px 12px",borderBottom:"1px solid #f0f0f0"},children:[C.jsx("div",{style:{fontWeight:500},children:(s==null?void 0:s.name)||(s==null?void 0:s.email)}),C.jsx("div",{style:{fontSize:12,color:"#666"},children:s==null?void 0:s.email})]}),C.jsxs(tn,{type:"text",block:!0,style:{justifyContent:"flex-start",padding:"8px 12px"},onClick:()=>y(!0),children:[C.jsx(KXe,{size:16,style:{marginRight:8}}),"Change Password"]}),C.jsxs(tn,{type:"text",block:!0,danger:!0,style:{justifyContent:"flex-start",padding:"8px 12px"},onClick:c,children:[C.jsx(Tfe,{size:16,style:{marginRight:8}}),"Logout"]})]});return C.jsxs("div",{style:{display:"flex",flexDirection:"column",width:"100%",height:"100%"},children:[C.jsx(h3t,{menu:C.jsx(x3t,{items:_,onItemClick:x,logo:n,logoText:t||"Workspace",showToggle:!0,defaultExpanded:!0,collapsed:a,onCollapsedChange:i,footer:({isIconMode:E})=>{var w;return s&&C.jsx(L4,{content:S,placement:"rightTop",trigger:"click",children:C.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:E?"center":"flex-start",gap:E?0:12,padding:E?8:"12px 16px",cursor:"pointer",borderRadius:12,transition:"all 0.2s"},children:[C.jsx(wg,{size:E?32:36,style:{background:"linear-gradient(135deg, #6366f1 0%, #818cf8 100%)",color:"white",flexShrink:0},children:(((w=s.name)==null?void 0:w.charAt(0))||s.email.charAt(0)).toUpperCase()}),!E&&C.jsxs("div",{style:{flex:1,minWidth:0},children:[C.jsx("div",{style:{fontWeight:500,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:s.name||s.email}),C.jsx("div",{style:{fontSize:12,color:"#666",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:s.email})]})]})})}}),logo:n,main:C.jsx(B3t,{region:"content"})}),C.jsx(Gi,{open:m,onCancel:()=>A(!1),footer:null,width:520,closable:!1,styles:{mask:{backgroundColor:"transparent"},content:{backgroundColor:"transparent",boxShadow:"none"}},children:C.jsx(u3t,{tenants:u.map(E=>E.tenant).filter(Boolean),currentTenantId:d==null?void 0:d.id,onSelect:async E=>{await f(E.id),A(!1)},isLoading:p})}),C.jsx(d3t,{open:v,onClose:()=>y(!1)})]})},qsr=({workspaceId:e,workspaceName:t,logo:n})=>C.jsx(p3t,{children:C.jsx(Wsr,{workspaceId:e,workspaceName:t,logo:n})}),Yve=b.createContext(null),lF=()=>{const e=b.useContext(Yve);if(!e)throw new Error("useWorkspaceContext must be used within a WorkspaceContextProvider");return e},Qsr=({children:e})=>{const{currentTenant:t}=A1(),n=(t==null?void 0:t.id)||"",{config:r}=Zo();v1("__GLOBAL__");const a=()=>typeof window<"u"?sessionStorage.getItem("workspaceId"):null,i=()=>typeof window<"u"?sessionStorage.getItem("projectId"):null,[o,l]=b.useState(a),[s,c]=b.useState(i);oe.useEffect(()=>{const G=a(),F=i();(G||F)&&UM.setWorkspaceContext(G||void 0,F||void 0)},[]),b.useEffect(()=>{UM.setWorkspaceContext(o||void 0,s||void 0)},[o,s]);const[u,d]=b.useState([]),[f,p]=b.useState([]),[h,g]=b.useState(!1),[m,A]=b.useState(null),v=oe.useMemo(()=>new I$t({baseURL:r.baseURL,apiKey:r.apiKey||"",assistantId:"",transport:"sse"},n),[r.baseURL,r.apiKey,n]),y=b.useCallback(()=>{p([]),l(null),sessionStorage.removeItem("workspaceId"),c(null),sessionStorage.removeItem("projectId")},[p,l,c]),_=b.useCallback(()=>{d([]),y()},[y,d]);b.useEffect(()=>{_(),x()},[n]);const x=b.useCallback(async()=>{g(!0),A(null);try{const G=await v.listWorkspaces();d(G)}catch(G){A(G instanceof Error?G.message:"Failed to load workspaces")}finally{g(!1)}},[v]),S=b.useCallback(async G=>{const F=G||o;if(!F){p([]);return}g(!0),A(null);try{const z=await v.listProjects(F);p(z)}catch(z){A(z instanceof Error?z.message:"Failed to load projects")}finally{g(!1)}},[v,o]);b.useEffect(()=>{o&&typeof window<"u"&&sessionStorage.setItem("workspaceId",o)},[o]),b.useEffect(()=>{s&&typeof window<"u"&&sessionStorage.setItem("projectId",s)},[s]),b.useEffect(()=>{x().catch(G=>{console.warn("Failed to load workspaces:",G)})},[x]),b.useEffect(()=>{if(u.length>0&&!o){const G=u[0];l(G.id)}},[u,o]),b.useEffect(()=>{o?S(o):p([]),c(null)},[o,S]);const E=b.useCallback(async G=>{g(!0),A(null);try{const F=await v.createWorkspace(G);return await x(),F}catch(F){const z=F instanceof Error?F.message:"Failed to create workspace";throw A(z),F}finally{g(!1)}},[v,x]),w=b.useCallback(async(G,F)=>{g(!0),A(null);try{const z=await v.updateWorkspace(G,F);return await x(),z}catch(z){const W=z instanceof Error?z.message:"Failed to update workspace";throw A(W),z}finally{g(!1)}},[v,x]),T=b.useCallback(async G=>{g(!0),A(null);try{await v.deleteWorkspace(G),o===G&&y(),await x()}catch(F){const z=F instanceof Error?F.message:"Failed to delete workspace";throw A(z),F}finally{g(!1)}},[v,o,x]),N=b.useCallback(async(G,F)=>{g(!0),A(null);try{const z=await v.createProject(G,F);return await S(G),z}catch(z){const W=z instanceof Error?z.message:"Failed to create project";throw A(W),z}finally{g(!1)}},[v,S]),R=b.useCallback(async(G,F,z)=>{g(!0),A(null);try{const W=await v.updateProject(G,F,z);return await S(G),W}catch(W){const q=W instanceof Error?W.message:"Failed to update project";throw A(q),W}finally{g(!1)}},[v,S]),k=b.useCallback(async(G,F)=>{g(!0),A(null);try{await v.deleteProject(G,F),s===F&&c(null),await S(G)}catch(z){const W=z instanceof Error?z.message:"Failed to delete project";throw A(W),z}finally{g(!1)}},[v,s,S]),O=b.useCallback(async(G="/")=>{if(!o||!s)return[];g(!0),A(null);try{return await v.listPath(o,s,G)}catch(F){return A(F instanceof Error?F.message:"Failed to load files"),[]}finally{g(!1)}},[v,o,s]),M=b.useCallback(async G=>{const F=G.startsWith("/")||G.startsWith("~/")?G:`/${G}`;return O(F)},[O]),D=b.useCallback(async(G,F)=>{if(!o||!s)throw new Error("Workspace and project must be selected before uploading files");g(!0),A(null);try{return await v.uploadFile(o,s,F,G)}catch(z){const W=z instanceof Error?z.message:"Failed to upload file";throw A(W),z}finally{g(!1)}},[v,o,s]),B=b.useCallback(async(G,F)=>D(G,F),[D]),$=b.useCallback(G=>!o||!s?"":v.getFileViewUrl(o,s,G),[v,o,s]),P={workspaceId:o,projectId:s,workspaces:u,projects:f,loading:h,error:m,setWorkspace:l,setProject:c,createWorkspace:E,updateWorkspace:w,deleteWorkspace:T,createProject:N,updateProject:R,deleteProject:k,refreshWorkspaces:x,refreshProjects:S,listPath:O,listPathByFolder:M,uploadFile:D,uploadFileToFolder:B,getFileViewUrl:$},U=u.find(G=>G.id===o),H=U==null?void 0:U.name;return C.jsx(Yve.Provider,{value:P,children:s?e:C.jsx(qsr,{workspaceId:o||"",workspaceName:H})})},Ysr=({senderRef:e,iconOnly:t})=>{const[n,r]=b.useState(!1),[a,i]=b.useState([]),[o,l]=b.useState(!1),[s,c]=b.useState([]),{get:u}=_l(),d=b.useRef(!1),f=async()=>{l(!0);try{const g=await u("/api/database-configs");g.success&&g.data&&Array.isArray(g.data.records)&&i(g.data.records)}catch(g){console.error("Failed to fetch databases:",g)}finally{l(!1)}},p=()=>{c([]),d.current||(f(),d.current=!0),r(!0)},h=()=>{s.forEach(g=>{var A,v;const m=a.find(y=>y.key===g);m&&e.current&&((v=(A=e.current).insert)==null||v.call(A,[{type:"tag",key:`db_${g}_${Date.now()}`,props:{label:C.jsxs(rr,{size:1,children:[C.jsx(G0,{size:10})," ",C.jsx(fr.Text,{children:m.name||g})]}),value:`[Database Scope:${m.name||g}]`}}],"cursor"))}),r(!1),c([])};return C.jsxs(C.Fragment,{children:[C.jsx(Gr,{title:t?"Database":void 0,children:C.jsx(tn,{icon:C.jsx(G0,{size:t?20:22}),onClick:p,type:"text",style:{height:32,width:t?32:void 0,borderRadius:8,padding:t?0:void 0,paddingLeft:t?0:16,paddingRight:t?0:16,display:"flex",alignItems:"center",justifyContent:"center",border:"none"},children:!t&&"Database"})}),C.jsx(Gi,{title:"Select Database",open:n,onOk:h,onCancel:()=>r(!1),width:600,okText:"Confirm",cancelText:"Cancel",children:o?C.jsx("div",{style:{textAlign:"center",padding:40},children:C.jsx(bl,{size:"large"})}):a.length===0?C.jsx(ai,{description:"No databases available",image:ai.PRESENTED_IMAGE_SIMPLE}):C.jsx(Ha,{dataSource:a,renderItem:g=>{const m=s.includes(g.key);return C.jsx(Ha.Item,{style:{padding:"12px 16px",cursor:"pointer",borderRadius:8,backgroundColor:m?"#f6ffed":"transparent",border:`1px solid ${m?"#52c41a":"transparent"}`,marginBottom:8,transition:"all 0.2s ease"},onClick:()=>{const A=m?s.filter(v=>v!==g.key):[...s,g.key];c(A)},children:C.jsx(Ha.Item.Meta,{avatar:C.jsx(Mc,{checked:m,onChange:()=>{const A=m?s.filter(v=>v!==g.key):[...s,g.key];c(A)},onClick:A=>A.stopPropagation()}),title:C.jsx(fr.Text,{strong:m,children:g.name||g.key}),description:g.description&&C.jsx(fr.Text,{type:"secondary",style:{fontSize:12},children:g.description})})},g.key)},style:{maxHeight:"50vh",overflowY:"auto"},split:!1})})]})},Ksr=({senderRef:e,iconOnly:t})=>{const[n,r]=b.useState(!1),[a,i]=b.useState([]),[o,l]=b.useState(!1),[s,c]=b.useState([]),{get:u}=_l(),d=b.useRef(!1),f=async()=>{l(!0);try{const g=await u("/api/skills");g.success&&g.data&&Array.isArray(g.data.records)&&i(g.data.records)}catch(g){console.error("Failed to fetch skills:",g)}finally{l(!1)}},p=()=>{c([]),d.current||(f(),d.current=!0),r(!0)},h=()=>{s.forEach(g=>{var A,v;const m=a.find(y=>y.id===g);m&&e.current&&((v=(A=e.current).insert)==null||v.call(A,[{type:"tag",key:`skill_${g}_${Date.now()}`,props:{label:C.jsxs(rr,{size:1,children:[C.jsx(H6,{size:12})," ",C.jsx(fr.Text,{children:m.name})]}),value:`[Use Skill:${m.name}]`}}],"cursor"))}),r(!1),c([])};return C.jsxs(C.Fragment,{children:[C.jsx(Gr,{title:t?"Skills":void 0,children:C.jsx(tn,{icon:C.jsx(H6,{size:t?20:22}),onClick:p,type:"text",style:{height:32,width:t?32:void 0,borderRadius:8,padding:t?0:void 0,paddingLeft:t?0:16,paddingRight:t?0:16,display:"flex",alignItems:"center",justifyContent:"center",border:"none"},children:!t&&"Skills"})}),C.jsx(Gi,{title:"Select Skills",open:n,onOk:h,onCancel:()=>r(!1),width:600,okText:"Confirm",cancelText:"Cancel",children:o?C.jsx("div",{style:{textAlign:"center",padding:40},children:C.jsx(bl,{size:"large"})}):a.length===0?C.jsx(ai,{description:"No skills available",image:ai.PRESENTED_IMAGE_SIMPLE}):C.jsx(Ha,{dataSource:a,renderItem:g=>{const m=s.includes(g.id);return C.jsx(Ha.Item,{style:{padding:"12px 16px",cursor:"pointer",borderRadius:8,backgroundColor:m?"#f6ffed":"transparent",border:`1px solid ${m?"#52c41a":"transparent"}`,marginBottom:8,transition:"all 0.2s ease"},onClick:()=>{const A=m?s.filter(v=>v!==g.id):[...s,g.id];c(A)},children:C.jsx(Ha.Item.Meta,{avatar:C.jsx(Mc,{checked:m,onChange:()=>{const A=m?s.filter(v=>v!==g.id):[...s,g.id];c(A)},onClick:A=>A.stopPropagation()}),title:C.jsx(fr.Text,{strong:m,children:g.name}),description:g.description&&C.jsx(fr.Text,{type:"secondary",style:{fontSize:12},children:g.description})})},g.id)},style:{maxHeight:"50vh",overflowY:"auto"},split:!1})})]})},Xsr=({senderRef:e,iconOnly:t})=>{const[n,r]=b.useState(!1),[a,i]=b.useState(!1),[o,l]=b.useState(null),{assistants:s,currentAssistant:c,selectAssistant:u}=Hve();b.useRef(!1);const d=()=>{l((c==null?void 0:c.id)||null),r(!0)},f=async()=>{o&&o!==(c==null?void 0:c.id)&&await u(o),r(!1)},p=h=>{l(h)};return C.jsxs(C.Fragment,{children:[C.jsx(Gr,{title:t?(c==null?void 0:c.name)||"Agent":void 0,children:C.jsx(tn,{icon:C.jsx(Bie,{size:t?20:22}),onClick:d,type:"text",style:{height:32,width:t?32:void 0,borderRadius:8,padding:t?0:void 0,paddingLeft:t?0:16,paddingRight:t?0:16,display:"flex",alignItems:"center",justifyContent:"center",border:"none"},children:!t&&((c==null?void 0:c.name)||"Agent")})}),C.jsx(Gi,{title:"Select Agent",open:n,onOk:f,onCancel:()=>r(!1),width:600,okText:"Confirm",cancelText:"Cancel",children:s.length===0?C.jsx(ai,{description:"No agents available",image:ai.PRESENTED_IMAGE_SIMPLE}):C.jsx(Ha,{dataSource:s,renderItem:h=>{const g=o===h.id;return C.jsx(Ha.Item,{style:{padding:"12px 16px",cursor:"pointer",borderRadius:8,backgroundColor:g?"#f6ffed":"transparent",border:`1px solid ${g?"#52c41a":"transparent"}`,marginBottom:8,transition:"all 0.2s ease"},onClick:()=>p(h.id),children:C.jsx(Ha.Item.Meta,{avatar:C.jsx("div",{style:{width:40,height:40,borderRadius:10,background:g?"#52c41a":"#f0f0f0",display:"flex",alignItems:"center",justifyContent:"center"},children:C.jsx(Bie,{size:20,color:g?"white":"#666"})}),title:C.jsx(fr.Text,{strong:g,children:h.name}),description:h.description&&C.jsx(fr.Text,{type:"secondary",style:{fontSize:12},children:h.description})})},h.id)},style:{maxHeight:"50vh",overflowY:"auto"},split:!1})})]})},sGe="metrics_datasource_selection",Zsr=({senderRef:e,iconOnly:t})=>{const[n,r]=b.useState(!1),[a,i]=b.useState(!1),[o,l]=b.useState([]),{config:s}=Zo(),{customRunConfig:c,updateCustomRunConfig:u}=y1(),{get:d}=_l(),f=b.useRef(!1),p=async()=>{var S,E;i(!0);try{const w=await d("/api/metrics-configs");if(!w.success||!((S=w.data)!=null&&S.records)){l([]);return}const T=w.data.records.filter(R=>{var k;return((k=R.config)==null?void 0:k.type)==="semantic"}),N=[];for(const R of T)try{const k=await d(`/api/metrics-configs/${R.key}/datasources`);if(k.success&&((E=k.data)!=null&&E.datasources)){const O=k.data.datasources.map(M=>({id:M.id,name:M.name,serverKey:R.key,serverName:R.name||R.key,connected:M.connected,description:M.description,schemaName:M.schemaName}));N.push(...O)}}catch(k){console.error(`Failed to fetch datasources for ${R.key}:`,k)}l(N)}catch(w){console.error("Failed to load metrics datasources:",w),l([])}finally{i(!1)}},h=()=>{p(),r(!0)},g=()=>{try{const S=sessionStorage.getItem(sGe);if(S){const E=JSON.parse(S);if(E.serverKey&&E.datasourceId)return u({metricsDataSource:{serverKey:E.serverKey,datasourceId:E.datasourceId}}),!0}}catch(S){console.error("Failed to restore datasource from sessionStorage:",S)}return!1},m=(S,E)=>{try{sessionStorage.setItem(sGe,JSON.stringify({serverKey:S,datasourceId:E}))}catch(w){console.error("Failed to save datasource to sessionStorage:",w)}};b.useEffect(()=>{f.current||(f.current=!0,p().then(()=>{const S=c==null?void 0:c.metricsDataSource;if(S){m(S.serverKey,S.datasourceId);return}g()||l(w=>(w.length>0&&r(!0),w))}))},[]);const A=()=>{const S=c==null?void 0:c.metricsDataSource;if(!S)return null;const{serverKey:E,datasourceId:w}=S;return o.find(T=>T.serverKey===E&&String(T.id)===String(w))},v=S=>{const E=c==null?void 0:c.metricsDataSource;return E?S.serverKey===E.serverKey&&String(S.id)===String(E.datasourceId):!1},y=S=>{S.connected&&(u({metricsDataSource:{serverKey:S.serverKey,datasourceId:S.id}}),m(S.serverKey,S.id),r(!1))},_=()=>{const S=A();return(S==null?void 0:S.name)||null},x=o.reduce((S,E)=>(S[E.serverName]||(S[E.serverName]=[]),S[E.serverName].push(E),S),{});return C.jsxs(C.Fragment,{children:[C.jsx(Gr,{title:t?_()||"Select Data Source":o.length===0?"No data sources available":void 0,children:C.jsx(tn,{icon:C.jsx(G0,{size:18}),onClick:h,type:"text",disabled:o.length===0,style:{height:32,width:t?32:void 0,borderRadius:8,padding:t?0:void 0,paddingLeft:t?0:12,paddingRight:t?0:12,display:"flex",alignItems:"center",justifyContent:"center",border:"none",fontSize:14},children:!t&&(_()||"Select Data Source")})}),C.jsx(Gi,{title:C.jsx("div",{style:{fontSize:16,fontWeight:600},children:"Select Metrics Data Source"}),open:n,onCancel:()=>r(!1),width:560,footer:null,styles:{body:{padding:"16px 20px",maxHeight:"60vh",overflowY:"auto"}},children:a?C.jsx("div",{style:{textAlign:"center",padding:40},children:C.jsx(bl,{size:"large"})}):o.length===0?C.jsx(ai,{description:"No Metrics Data Sources Available",image:ai.PRESENTED_IMAGE_SIMPLE}):C.jsx("div",{style:{display:"flex",flexDirection:"column",gap:24},children:Object.entries(x).map(([S,E])=>C.jsxs("div",{children:[C.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:12,paddingBottom:8,borderBottom:"1px solid #f0f0f0"},children:[C.jsx(eZe,{size:14,color:"#8c8c8c"}),C.jsx(fr.Text,{style:{fontSize:13,fontWeight:500,color:"#595959",textTransform:"uppercase",letterSpacing:"0.5px"},children:S}),C.jsx(Kr,{style:{fontSize:11,padding:"0 6px",lineHeight:"18px"},children:E.length})]}),C.jsx(Ha,{dataSource:E,renderItem:w=>{const T=w.connected,N=v(w);return C.jsx(Ha.Item,{style:{padding:"10px 12px",cursor:T?"pointer":"not-allowed",borderRadius:6,backgroundColor:N?"#f0f5ff":"transparent",border:N?"1px solid #2f54eb":"1px solid transparent",opacity:T?1:.5,marginBottom:6,transition:"all 0.15s ease"},onClick:()=>y(w),children:C.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",width:"100%"},children:[C.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[C.jsx("div",{style:{width:32,height:32,borderRadius:6,background:N?"#2f54eb":T?"#f5f5f5":"#f0f0f0",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:N?C.jsx(cB,{size:16,color:"#fff"}):C.jsx(G0,{size:16,color:T?"#595959":"#8c8c8c"})}),C.jsxs("div",{children:[C.jsx(fr.Text,{style:{fontSize:14,fontWeight:N?500:400,color:N?"#2f54eb":"#262626"},children:w.name}),!T&&C.jsx("div",{children:C.jsx(fr.Text,{style:{fontSize:12,color:"#8c8c8c"},children:"Disconnected"})})]})]}),N&&C.jsx(Kr,{color:"blue",style:{fontSize:11,padding:"0 8px",margin:0},children:"Selected"})]})},`${w.serverKey}-${w.id}`)},split:!1})]},S))})})]})},Jsr=({value:e,onChange:t,defaultModelKey:n="default",style:r})=>{const[a,i]=b.useState([]),[o,l]=b.useState(!1),[s,c]=b.useState(null),[u,d]=b.useState(!1),[f,p]=b.useState(!1),h=b.useRef(!1),g=b.useRef(!1),{get:m}=_l(),A=e!==void 0?e:s,v=b.useCallback(S=>{e===void 0&&c(S),t==null||t(S)},[e,t]),y=b.useCallback(async()=>{if(!h.current){h.current=!0,l(!0);try{const E=(await m("/api/models")).data||[];if(i(E),!g.current&&!A&&E.length>0){g.current=!0;const w=E.find(T=>T.key===n);w&&v({modelKey:w.key})}}catch(S){console.error("Failed to fetch models:",S)}finally{l(!1)}}},[m,n]);b.useEffect(()=>{y()},[y]);const _=S=>{v({modelKey:S}),d(!1)},x=a.find(S=>S.key===(A==null?void 0:A.modelKey));return x!=null&&x.displayName||x!=null&&x.model,C.jsx("div",{onMouseEnter:()=>p(!0),onMouseLeave:()=>p(!1),style:{display:"inline-block",borderRadius:8,backgroundColor:f?"rgba(0, 0, 0, 0.06)":"transparent",transition:"background-color 0.2s ease"},children:C.jsx(Mf,{variant:"borderless",value:A==null?void 0:A.modelKey,onChange:_,loading:o,open:u,onDropdownVisibleChange:d,style:{minWidth:80,...r},placeholder:"Model",suffixIcon:null,options:a.map(S=>({value:S.key,label:S.displayName||S.model})),dropdownMatchSelectWidth:!1})})},ecr={business_analysis:{icon:C.jsx(EXe,{}),color:"#1890FF",label:"Business Analysis"},code_generation:{icon:C.jsx(mf,{}),color:"#722ED1",label:"Code Generation"},document_processing:{icon:C.jsx(q2,{}),color:"#52C41A",label:"Document Processing"},data_analysis:{icon:C.jsx(hfe,{}),color:"#13C2C2",label:"Data Analysis"},tool_operation:{icon:C.jsx(bw,{}),color:"#FAAD14",label:"Tool Operations"},general:{icon:C.jsx(wXe,{}),color:"#FFD700",label:"General Skills"},global:{icon:C.jsx(LXe,{}),color:"#EB2F96",label:"Global Skills"}},cGe=e=>ecr[e]||{icon:C.jsx(R7,{}),color:"#8C8C8C",label:e},uGe=["#FFD700","#1890FF","#FF4D4F","#722ED1","#52C41A","#964B00","#FAAD14","#FF4D4F","#13C2C2","#EB2F96"],dGe=[C.jsx(wXe,{}),C.jsx(XHt,{}),C.jsx(Ojt,{}),C.jsx(c5,{}),C.jsx(lUt,{}),C.jsx(ojt,{}),C.jsx(Dzt,{}),C.jsx(EXe,{}),C.jsx(mf,{}),C.jsx(hfe,{})],tcr=({senderRef:e,visible:t=!0})=>{const[n,r]=b.useState([]),[a,i]=b.useState(!1),[o,l]=b.useState(!1),{get:s}=_l(),c=10;b.useEffect(()=>{t&&(async()=>{i(!0);try{const m=await s("/api/skills");m.success&&m.data&&Array.isArray(m.data.records)&&r(m.data.records)}catch(m){console.error("Failed to fetch skills:",m)}finally{i(!1)}})()},[s,t]);const u=b.useMemo(()=>{const g={};return n.forEach(m=>{var v;const A=((v=m.metadata)==null?void 0:v.category)||"global";g[A]||(g[A]=[]),g[A].push(m)}),g},[n]),d=g=>{var m,A;e.current&&((A=(m=e.current).insert)==null||A.call(m,[{type:"tag",key:`skill_${g.id}_${Date.now()}`,props:{label:C.jsxs(rr,{size:1,children:[C.jsx(H6,{size:12}),C.jsx(fr.Text,{children:g.name})]}),value:`[Use Skill:${g.name}]`}}],"cursor"))},f=()=>{l(!0)},p=()=>{const g=n.slice(0,c).map((m,A)=>({key:m.id,icon:C.jsx("span",{style:{color:uGe[A%uGe.length]},children:dGe[A%dGe.length]}),label:m.name}));return(n.length>c||Object.keys(u).length>1)&&g.push({key:"more",icon:C.jsx(Sfe,{style:{color:"#8C8C8C"}}),description:"View more skill categories"}),g},h=g=>g.map(m=>{var A,v,y;return{key:m.id,icon:C.jsx(H6,{size:16,style:{color:cGe(((A=m.metadata)==null?void 0:A.category)||"global").color}}),label:m.name,description:((v=m.description)==null?void 0:v.slice(0,60))+(((y=m.description)==null?void 0:y.length)>60?"...":"")}});return t?a?C.jsx("div",{style:{textAlign:"center",padding:40},children:C.jsx(bl,{size:"large"})}):n.length===0?null:o?C.jsx("div",{style:{padding:"0 16px",maxHeight:"calc(100% - 220px)",overflowY:"auto",overflowX:"hidden"},children:Object.entries(u).map(([g,m])=>{const A=cGe(g);return C.jsx("div",{style:{marginBottom:16},children:C.jsx(Z6,{title:C.jsxs(rr,{children:[C.jsx("span",{style:{color:A.color},children:A.icon}),C.jsx("span",{children:A.label})]}),items:h(m),onItemClick:v=>{const y=m.find(_=>_.id===v.data.key);y&&d(y)},wrap:!0,styles:{item:{flex:"none",width:"calc(50% - 6px)"}}})},g)})}):C.jsx("div",{style:{padding:"0 16px",maxHeight:"calc(100% - 220px)",overflowY:"auto",overflowX:"hidden"},children:C.jsx(Z6,{title:"✨ Quick actions",items:p(),onItemClick:g=>{if(g.data.key==="more")f();else{const m=n.find(A=>A.id===g.data.key);m&&d(m)}},wrap:!0,styles:{item:{flex:"none"}}})}):null},fGe={financial:C.jsx(SUt,{}),sales:C.jsx(pHt,{}),operations:C.jsx(bw,{})},pGe={financial:"#52C41A",sales:"#1890FF",operations:"#FA8C16"},Sv=e=>[{type:"text",value:e}],ncr=[{key:"sales",title:"Sales Analysis",items:[{key:"sales_comprehensive_analysis",label:"Comprehensive Sales Analysis",description:"Analyze sales revenue by specified dimensions with trend analysis and growth opportunities",content:[{type:"text",value:"Please analyze sales revenue of last "},{type:"select",key:"time_period",props:{options:["year","quarter","month","week"],defaultValue:"year"}},{type:"text",value:" by product group, customer and territory, indicate sales trend, concerns and growth opportunities."}]},{key:"sales_performance",label:"Sales Performance Analysis",description:"Aggregate omni-channel sales, evaluate performance achievement rate, and compare with historical growth",content:Sv("Please aggregate omni-channel sales, evaluate performance achievement rate, and compare with historical growth.")},{key:"sales_top_customers",label:"Top Customer Analysis",description:"Identify top 10% customers by sales volume, analyze their purchase preferences and churn risks",content:[{type:"text",value:"Please identify the top "},{type:"input",key:"percentage_threshold",props:{placeholder:"10%",defaultValue:"10%"}},{type:"text",value:" customers by sales volume, analyze their purchase preferences and churn risks."}]},{key:"sales_trend",label:"Sales Trend Analysis",description:"Analyze sales peaks and troughs through time series, forecast sales trends for the next quarter",content:[{type:"text",value:"Please analyze sales peaks and troughs through time series, and forecast sales trends for "},{type:"input",key:"forecast_period",props:{placeholder:"the next quarter",defaultValue:"the next quarter"}},{type:"text",value:"."}]},{key:"sales_rep_performance",label:"Sales Representative Performance",description:"Quantitatively evaluate conversion rates, average order value, and contract fulfillment efficiency of each sales representative",content:Sv("Please quantitatively evaluate conversion rates, average order value, and contract fulfillment efficiency of each sales representative.")},{key:"sales_regional",label:"Regional Sales Comparison",description:"Compare sales penetration across different geographic regions, identify markets with abnormal performance",content:[{type:"text",value:"Please compare sales penetration across "},{type:"input",key:"geographic_scope",props:{placeholder:"different geographic regions",defaultValue:"different geographic regions"}},{type:"text",value:", and identify markets with abnormal performance."}]},{key:"sales_product_volume",label:"Product Volume Analysis",description:"Count sales quantities of each SKU, identify best-selling products and slow-moving inventory",content:[{type:"text",value:"Please count sales quantities of "},{type:"input",key:"product_identifier",props:{placeholder:"each SKU",defaultValue:"each SKU"}},{type:"text",value:", and identify best-selling products and slow-moving inventory."}]}]},{key:"financial",title:"Financial Analysis",items:[{key:"financial_gross_margin",label:"Product Line Gross Margin Analysis",description:"Compare gross margin levels across product lines, identify high-margin contributors and loss-making businesses",content:[{type:"text",value:"Please analyze the gross margin levels of "},{type:"input",key:"product_scope",props:{placeholder:"each product line",defaultValue:"each product line"}},{type:"text",value:", identify high-margin contributors and loss-making businesses, and provide optimization suggestions."}]},{key:"financial_customer_profitability",label:"Customer Profitability Analysis",description:"Analyze net profit contribution by different customer dimensions, identify core high-quality customers and high-service-cost customers",content:[{type:"text",value:"Please analyze the net profit contribution by "},{type:"input",key:"customer_dimension",props:{placeholder:"different customer dimensions",defaultValue:"different customer dimensions"}},{type:"text",value:", identify core high-quality customers and high-service-cost customers, and propose customer tier management recommendations."}]},{key:"financial_monthly_report",label:"Monthly Financial Report",description:"Based on this month's accounting data, automatically generate income statement, balance sheet, and cash flow statement summaries",content:[{type:"text",value:"Please generate income statement, balance sheet, and cash flow statement summaries based on "},{type:"input",key:"time_period",props:{placeholder:"this month's",defaultValue:"this month's"}},{type:"text",value:" accounting data, and analyze key financial indicators."}]},{key:"financial_ratio",label:"Financial Ratio Analysis",description:"Calculate and analyze key indicators such as current ratio, debt-to-asset ratio, and ROE to assess company financial health",content:Sv("Please calculate and analyze key financial indicators such as current ratio, debt-to-asset ratio, and ROE to assess company financial health.")},{key:"financial_cashflow",label:"Cash Flow Analysis",description:"Track cash flows from operating, investing, and financing activities, analyze reasons for changes in net cash flow",content:Sv("Please track cash flows from operating, investing, and financing activities, and analyze the reasons and trends for changes in net cash flow.")},{key:"financial_cost_structure",label:"Cost Structure Analysis",description:"Break down direct costs and indirect expenses of products or services, identify core drivers affecting total costs",content:[{type:"text",value:"Please break down direct costs and indirect expenses of "},{type:"input",key:"cost_object",props:{placeholder:"products or services",defaultValue:"products or services"}},{type:"text",value:", and identify core drivers affecting total costs."}]}]},{key:"operations",title:"Operations Analysis",items:[{key:"ops_supplier_evaluation",label:"Supplier Performance Evaluation",description:"Based on delivery quality, response speed, and price competitiveness, conduct comprehensive rating of core suppliers",content:[{type:"text",value:"Please conduct comprehensive rating of "},{type:"input",key:"supplier_scope",props:{placeholder:"core suppliers",defaultValue:"core suppliers"}},{type:"text",value:" based on delivery quality, response speed, and price competitiveness."}]},{key:"ops_inventory_turnover",label:"Inventory Turnover Analysis",description:"Calculate inventory turnover rate and days, identify slow-moving inventory materials to release capital",content:Sv("Please calculate inventory turnover rate and days, and identify slow-moving inventory materials to release capital.")},{key:"ops_delivery_ontime",label:"On-Time Delivery Analysis",description:"Count order lead time from placement to delivery, analyze core links causing delayed deliveries",content:Sv("Please count order lead time from placement to delivery, and analyze core links causing delayed deliveries.")},{key:"ops_procurement_cost",label:"Procurement Cost Analysis",description:"Monitor raw material procurement price fluctuations, analyze impact of procurement premiums or savings on profit",content:[{type:"text",value:"Please monitor "},{type:"input",key:"procurement_category",props:{placeholder:"raw material",defaultValue:"raw material"}},{type:"text",value:" procurement price fluctuations, and analyze impact of procurement premiums or savings on profit."}]},{key:"ops_production_efficiency",label:"Production Efficiency Analysis",description:"Calculate Overall Equipment Effectiveness (OEE) or per capita output, identify efficiency bottlenecks on production lines",content:[{type:"text",value:"Please calculate Overall Equipment Effectiveness (OEE) or per capita output, and identify efficiency bottlenecks on "},{type:"input",key:"production_scope",props:{placeholder:"production lines",defaultValue:"production lines"}},{type:"text",value:"."}]},{key:"ops_order_fulfillment",label:"Order Fulfillment Analysis",description:"Analyze the full process from order receipt to final delivery, optimize order processing response time",content:[{type:"text",value:"Please analyze the full process from order receipt to final delivery, and optimize "},{type:"input",key:"optimization_target",props:{placeholder:"order processing response time",defaultValue:"order processing response time"}},{type:"text",value:"."}]}]}],hGe=["#1890FF","#52C41A","#FAAD14","#722ED1","#13C2C2","#EB2F96","#FA541C","#2F54EB"],rcr=({visible:e=!0,disabled:t=!1,onItemClick:n,maxSimpleItems:r=8,simpleModeTitle:a="Quick Analysis",expandModeTitle:i="Analysis Categories"})=>{var p;const[o,l]=b.useState(!1),{config:s}=Zo(),c=b.useMemo(()=>{const h=s.quickPromptsData;return h&&Array.isArray(h)&&h.length>0?h.map(g=>({...g,icon:g.icon||fGe[g.key]||C.jsx(R7,{}),color:g.color||pGe[g.key]||"#8C8C8C",items:g.items.map(m=>({...m,content:typeof m.content=="string"?Sv(m.content):m.content}))})):ncr.map(g=>({...g,icon:fGe[g.key]||C.jsx(R7,{}),color:pGe[g.key]||"#8C8C8C"}))},[s.quickPromptsData]),u=b.useMemo(()=>{const h=[];return c.forEach(g=>{g.items.forEach(m=>{h.push({...m,icon:m.icon||g.icon})})}),h},[c]),d=()=>{const h=u.slice(0,r).map((g,m)=>({key:g.key,icon:C.jsx("span",{style:{color:hGe[m%hGe.length]},children:g.icon||C.jsx(R7,{})}),label:g.label}));return(u.length>r||c.length>1)&&h.push({key:"more",icon:C.jsx(Sfe,{style:{color:"#8C8C8C"}}),description:"View more analysis options"}),h},f=h=>h.map(g=>({key:g.key,icon:C.jsx("span",{style:{color:"#8C8C8C"},children:g.icon||C.jsx(R7,{})}),label:g.label,description:g.description}));return e?o?C.jsx("div",{style:{padding:"16px",maxWidth:"800px",margin:"0 auto"},children:C.jsx(fw,{defaultActiveKey:(p=c[0])==null?void 0:p.key,items:c.map(h=>({key:h.key,label:C.jsxs(rr,{children:[C.jsx("span",{style:{color:h.color},children:h.icon}),C.jsx("span",{children:h.title})]}),children:C.jsx(Z6,{items:f(h.items),onItemClick:g=>{const m=h.items.find(A=>A.key===g.data.key);m&&n&&n(m)},wrap:!0,styles:{item:{flex:"none",width:"calc(50% - 8px)",minWidth:"280px"}}})}))})}):C.jsx("div",{style:{padding:"16px",maxWidth:"800px",margin:"0 auto"},children:C.jsx(Z6,{title:a,items:d(),onItemClick:h=>{if(h.data.key==="more")l(!0);else{const g=u.find(m=>m.key===h.data.key);g&&n&&n(g)}},wrap:!0,styles:{item:{flex:"none",width:"calc(50% - 8px)",minWidth:"280px"}}})}):null},acr=[],Kve=({avatar:e,name:t,description:n,default_submit_message:r,senderPromptsItems:a,extra:i,attachment_placeholder:o,extraMeta:l=[],uploadAction:s,showHeader:c=!0,showSender:u=!0,showHITL:d=!0,showRefreshButton:f=!1,showModelSelector:p,showEmptyState:h=!0,emptyStateGreeting:g,emptyStateQuestion:m="Ready to turn data into insightful charts in seconds?",welcomePrefix:A="Hey"})=>{var _t,Bt;const[v,y]=b.useState(""),[_,x]=b.useState([]),{styles:S}=DC(),[E,w]=b.useState(!1),T=b.useRef(null),N=oe.useRef(null),{assistantId:R,threadId:k,messages:O,sendMessage:M,abortAgent:D,loadMessages:B,isLoading:$,error:P,interrupts:U,tenantId:H,clearError:G,pendingMessages:F,updateCustomRunConfig:z}=Gs(),W=$,q=(F==null?void 0:F.length)>0,Q=U&&U.length>0,Z=["⠋","⠙","⠹","⠸","⠼","⠴","⠦","⠧","⠇","⠏"],[Y,ee]=b.useState(0);b.useEffect(()=>{if(!W)return;const Ct=setInterval(()=>{ee(Kt=>(Kt+1)%Z.length)},80);return()=>clearInterval(Ct)},[W]);const ae=y1(),[ne,te]=b.useState(null),se=b.useCallback(Ct=>{te(Ct),Ct&&z({modelConfig:Ct})},[z]),[pe,ue]=b.useState(h&&O.length===0&&!(F!=null&&F.length)),[ie,be]=b.useState(!1);b.useEffect(()=>{if(!h){ue(!1);return}const Ct=O.length===0&&!(F!=null&&F.length);!Ct&&pe?(be(!0),setTimeout(()=>{ue(!1),be(!1)},400)):Ct&&!pe&&ue(!0)},[O.length,F==null?void 0:F.length,pe,h]);const{config:de}=Zo(),{baseURL:ve}=de,he=(_t=Mor())==null?void 0:_t.user,fe=(he==null?void 0:he.name)||((Bt=he==null?void 0:he.email)==null?void 0:Bt.split("@")[0])||"there",me=b.useContext(Yve);me==null||me.listPath;const Se=(me==null?void 0:me.listPathByFolder)??(async()=>[]),xe=(me==null?void 0:me.workspaceId)??null,$e=(me==null?void 0:me.projectId)??null,[Fe,et]=b.useState([]),[rt,We]=b.useState(!1),[ct,De]=b.useState(!1),Ve=Ct=>{var rn;const Kt=(rn=Ct.split(".").pop())==null?void 0:rn.toLowerCase(),$t={fontSize:16};switch(Kt){case"png":case"jpg":case"jpeg":case"gif":case"svg":case"webp":return C.jsx(vfe,{style:{...$t,color:"#52c41a"}});case"pdf":return C.jsx(iB,{style:{...$t,color:"#ff4d4f"}});case"md":case"markdown":return C.jsx(NXe,{style:{...$t,color:"#722ed1"}});case"zip":case"rar":case"7z":return C.jsx(bfe,{style:{...$t,color:"#faad14"}});case"xls":case"xlsx":case"csv":return C.jsx(Afe,{style:{...$t,color:"#52c41a"}});case"ppt":case"pptx":return C.jsx(OXe,{style:{...$t,color:"#fa8c16"}});case"doc":case"docx":return C.jsx(yfe,{style:{...$t,color:"#2f54eb"}});case"txt":return C.jsx(q2,{style:{...$t,color:"#8c8c8c"}});default:return C.jsx(oB,{style:{...$t,color:"#bfbfbf"}})}},Ge=async()=>{var Ct;We(!0);try{const $t=((Ct=de.resourceFolders)!=null&&Ct.length?de.resourceFolders:[{name:"/",displayName:"Root Directory",allowUpload:!0}]).map(async on=>{try{return(await Se(on.name)).filter($n=>!$n.is_dir)}catch(Tn){return console.error(`Failed to load files from folder ${on.name}:`,Tn),[]}}),qt=(await Promise.all($t)).flat();et(qt)}catch(Kt){console.error("Failed to load workspace files:",Kt),et([])}finally{We(!1)}};b.useEffect(()=>{Mm("action_show_attachments_uploader",{card_view:()=>null,action:Ct=>{console.log(Ct),w(!0)}})},[]);const Xe=Ct=>{const Kt=["application/zip"],$t=["application/vnd.rar","application/x-rar-compressed","application/rar"];return[...Kt,...$t].includes(Ct.type)||Ct.name.toLowerCase().endsWith(".zip")||Ct.name.toLowerCase().endsWith(".rar")},at=Ct=>{var rn,qt;if(!Ct&&_.length===0)return;if(_.filter(on=>on.status!=="done").length>0){bn.warning("Files are still uploading...");return}!Ct&&_.length>0&&(Ct=r||"");const Kt=_.map(on=>{var Tn,$n;return Xe(on)?{name:on.response.zipFileName||on.response.rarFileName,id:on.response.zipFileId||on.response.rarFileId,totalFiles:on.response.totalFiles,processedFiles:on.response.processedFiles,skippedFiles:on.response.skippedFiles,type:on.name.toLowerCase().endsWith(".rar")?"application/rar":"application/zip",files:($n=(Tn=on.response)==null?void 0:Tn.results)==null?void 0:$n.map(Kn=>({name:Kn.fileName,path:Kn.filePath,id:Kn.fileId}))}:{name:on.name,id:on.response.id}}),$t=Kt.length>0?["","我已经提交了以下文件:","```attachments",JSON.stringify(Kt),"```"].join(`
4012
4012
  `):"";pe&&!ie?(be(!0),setTimeout(()=>{ue(!1),be(!1),M({input:{message:Ct+$t,files:Kt}})},300)):M({input:{message:Ct+$t,files:Kt}}),y(""),(qt=(rn=N.current)==null?void 0:rn.clear)==null||qt.call(rn),x([]),w(!1)},Qe=Ct=>{at(Ct.data.description)},He=Ct=>{var Kt,$t,rn,qt;E||w(!0),(($t=(Kt=Ct.file)==null?void 0:Kt.response)!=null&&$t.error||Ct.file.status==="error")&&bn.error(`${Ct.file.name} file upload failed.${(qt=(rn=Ct.file)==null?void 0:rn.response)==null?void 0:qt.message}`),x(Ct.fileList),Ct.file.status==="done"&&console.log(`${Ct.file.name} file uploaded successfully`)},Ie=Ct=>Ct.size/1024/1024<20?!0:(bn.error(`File must be smaller than 20MB! ${Ct.name} is too large.`),!1),ze=C.jsx(Mk.Header,{title:"Attachments",open:E,onOpenChange:w,styles:{content:{padding:0}},forceRender:!0,children:C.jsx(zKt,{ref:T,items:_,action:s||(xe&&$e?`${ve}/api/workspaces/${xe}/projects/${$e}/uploadfile`:`${ve}/api/assistants/${R}/threads/${k}/sandbox/uploadfile`),headers:{"x-tenant-id":H||"","x-assistant-id":R||"","x-thread-id":k||""},getDropContainer:()=>document.querySelector(".fina_chat"),onDrop:Ct=>{console.log(Ct)},onChange:He,beforeUpload:Ie,showUploadList:!0,multiple:!0,maxCount:10,placeholder:Ct=>({icon:C.jsx(nUt,{}),title:"Upload File",description:o})})}),tt=de.enableDatabaseSlot,mt=de.enableSkillSlot,vt=de.enableAgentSlot,Dt=de.enableMetricsDataSourceSlot,Nt=p!==void 0?p:de.enableModelSelector,ht=Ct=>{const Kt=vt||tt||mt||Dt;return C.jsxs(Dd,{justify:"space-between",align:"center",style:{padding:"8px 0"},children:[C.jsxs(Dd,{align:"center",gap:8,children:[C.jsx(lw,{dot:_.length>0&&!E,children:C.jsx(tn,{type:"text",icon:C.jsx(NHt,{}),onClick:()=>w(!E)})}),C.jsx(D4,{type:"vertical",style:{margin:0}}),Kt&&C.jsxs(Dd,{align:"center",gap:8,children:[vt&&C.jsx(Xsr,{senderRef:N,iconOnly:!0}),tt&&C.jsx(Ysr,{senderRef:N,iconOnly:!0}),mt&&C.jsx(Ksr,{senderRef:N,iconOnly:!0}),Dt&&C.jsx(Zsr,{senderRef:N,iconOnly:!0})]})]}),C.jsxs(Dd,{align:"center",gap:8,children:[Nt&&C.jsx(Jsr,{value:ne,onChange:se}),W?C.jsx(tn,{type:"primary",shape:"circle",icon:C.jsx(o4,{}),onClick:D,className:S.rotatingBorderButton}):Ct]})]})},[ft,gt]=b.useState([]),[bt,wt]=b.useState(!1),{get:xt}=_l(),Lt=async()=>{if(!(ft.length>0)){wt(!0);try{const Ct=await xt("/api/skills");Ct.success&&Ct.data&&Array.isArray(Ct.data.records)&&gt(Ct.data.records)}catch(Ct){console.error("Failed to fetch skills:",Ct)}finally{wt(!1)}}},Mt=(Ct,Kt,$t)=>{if(!Ct){if(Kt)return`${Z[Y]} Thinking...`;if($t)return`${F.length} messages waiting...`}return Ct?"Type / to see available skills, or @ to reference files":void 0},Wt=Ct=>{const[Kt,$t]=b.useState(null),rn=Kt==="skills"?ft.map(qt=>{var on,Tn;return{value:qt.name,icon:C.jsx(H6,{size:14,style:{color:"#722ed1"}}),label:qt.name,description:((on=qt.description)==null?void 0:on.slice(0,50))+(((Tn=qt.description)==null?void 0:Tn.length)>50?"...":"")}}):Fe.map(qt=>({value:qt.path,icon:Ve(qt.name||qt.path),label:qt.path}));return C.jsx(Jmn,{items:rn,onSelect:qt=>{var on,Tn,$n,Kn;Kt==="skills"?(Tn=(on=N.current)==null?void 0:on.insert)==null||Tn.call(on,[{type:"tag",key:`skill_${qt}_${Date.now()}`,props:{label:C.jsxs(rr,{size:1,children:[C.jsx(H6,{size:12}),C.jsx(fr.Text,{children:qt})]}),value:`[Use Skill:${qt}]`}}],"cursor","/"):(Kn=($n=N.current)==null?void 0:$n.insert)==null||Kn.call($n,[{type:"tag",key:`${qt}_${Date.now()}`,props:{label:"@"+qt,value:" "+qt}}],"cursor","@")},children:({onTrigger:qt,onKeyDown:on})=>C.jsx(Mk,{slotConfig:acr,disabled:Q,allowSpeech:!1,ref:N,value:v,header:ze,onSubmit:at,placeholder:Mt(Ct,W,q),onChange:Tn=>{const $n=/@([^\s]*)$/.test(Tn),Kn=/\/([^\s]*)$/.test(Tn),Cr=Tn.lastIndexOf("@"),dn=Tn.lastIndexOf("/"),Ne=Cr>=0?Tn.slice(Cr+1):"",qe=dn>=0?Tn.slice(dn+1):"";Kn&&!qe.includes(" ")?($t("skills"),Lt(),qt()):$n&&!Ne.includes(" ")?($t("files"),Ge(),qt()):($t(null),qt(!1)),y(Tn)},onKeyDown:on,className:Ct?S.emptyStateSender:S.sender,suffix:!1,footer:ht,onPasteFile:Tn=>{Array.from(Tn).forEach($n=>{var Kn;(Kn=T.current)==null||Kn.upload($n)}),w(!0)}})})};return C.jsxs(C.Fragment,{children:[C.jsx("div",{className:S.fixedHeader,style:{opacity:pe?0:1,pointerEvents:pe?"none":"auto",transition:"opacity 0.3s ease"},children:c&&C.jsx(Zlr,{name:t,onNewThread:async()=>{try{await ae.createThread()}catch(Ct){console.error("Failed to create new thread:",Ct),bn.error("Failed to create new thread")}},onRefresh:()=>{B()},onViewHistory:()=>{const Ct=new CustomEvent("lattice-chat:show-thread-sidebar");window.dispatchEvent(Ct)}})}),pe&&C.jsxs("div",{className:`${S.emptyStateContainer} ${ie?S.exiting:""}`,children:[C.jsxs("div",{className:S.welcomeSection,children:[C.jsx("div",{className:S.greeting,children:g||C.jsxs(C.Fragment,{children:[A," ",C.jsx("span",{className:"user-name",children:fe})]})}),C.jsx("div",{className:S.question,children:m})]}),de.enableSkillSlot!==!1&&C.jsx("div",{className:S.promptsWrapper,children:C.jsx(tcr,{senderRef:N,visible:!0})}),u&&C.jsx("div",{className:`${S.emptyStateSenderWrapper} ${ie?S.transitioning:""}`,children:Wt(!0)}),u&&!(U&&U.length>0)&&C.jsx("div",{style:{marginTop:24},children:C.jsx(rcr,{visible:!0,disabled:U&&U.length>0,onItemClick:Ct=>{var Kt;(Kt=N.current)==null||Kt.insert(Ct.content,"cursor")}})})]}),!pe&&C.jsxs(C.Fragment,{children:[C.jsx(zlr,{messages:O,className:`${S.messages} ${ie?S.entering:""}`}),!$&&O.length>0&&C.jsx(Z6,{items:a,onItemClick:Qe}),P&&C.jsx("div",{style:{padding:"0 16px 8px"},children:C.jsx(zh,{type:"error",banner:!0,closable:!0,onClose:()=>G(),message:`${P.message}`})}),d&&C.jsx(jlr,{}),C.jsx(Vlr,{}),u&&C.jsx("div",{className:`${S.senderContainer} ${ie?S.entering:""}`,children:Wt(!1)})]})]})},{Text:rfr}=fr,icr=({data:e,component_key:t,interactive:n=!0})=>{const{description:r,subagent_type:a,thread_id:i}=e||{};return C.jsx(Vve,{threadId:i,assistantId:a,options:{streaming:!0,enableReturnStateWhenStreamCompleted:!0,enableResumeStream:!0},children:C.jsx("div",{style:{overflow:"hidden"},children:C.jsx(Kve,{showRefreshButton:!0,name:a,showHeader:!0,showSender:!1,showHITL:!1})})})},{Text:Xte}=fr,ocr=vi(({token:e,css:t})=>({listContainer:t`
4013
4013
  background: ${e.colorBgContainer};
4014
4014
  border-radius: ${e.borderRadius}px;