1(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,63209,e=>{"use strict";let t=(0,e.i(475254).default)("circle-alert",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]);e.s(["AlertCircle",()=>t],63209)},643531,e=>{"use strict";let t=(0,e.i(475254).default)("check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);e.s(["Check",()=>t],643531)},158079,(e,t,n)=>{"use strict";let r=/(?:\\(u(?:[a-f\d]{4}|\{[a-f\d]{1,6}\})|x[a-f\d]{2}|.))|(?:\{(~)?(\w+(?:\([^)]*\))?(?:\.\w+(?:\([^)]*\))?)*)(?:[ \t]|(?=\r?\n)))|(\})|((?:.|[\r\n\f])+?)/gi,i=/(?:^|\.)(\w+)(?:\(([^)]*)\))?/g,o=/^(['"])((?:\\.|(?!\1)[^\\])*)\1$/,a=/\\(u(?:[a-f\d]{4}|{[a-f\d]{1,6}})|x[a-f\d]{2}|.)|([^\\])/gi,s=new Map([["n","\n"],["r","\r"],["t"," "],["b","\b"],["f","\f"],["v","\v"],["0","\0"],["\\","\\"],["e","\x1b"],["a","\x07"]]);function l(e){let t="u"===e[0],n="{"===e[1];return t&&!n&&5===e.length||"x"===e[0]&&3===e.length?String.fromCharCode(parseInt(e.slice(1),16)):t&&n?String.fromCodePoint(parseInt(e.slice(2,-1),16)):s.get(e)||e}function c(e,t){let n={};for(let e of t)for(let t of e.styles)n[t[0]]=e.inverse?null:t.slice(1);let r=e;for(let[e,t]of Object.entries(n))if(Array.isArray(t)){if(!(e in r))throw Error(`Unknown Chalk style: ${e}`);r=t.length>0?r[e](...t):r[e]}return r}t.exports=(e,t)=>{let n=[],s=[],u=[];if(t.replace(r,(t,r,d,p,f,h)=>{if(r)u.push(l(r));else if(p){let t=u.join("");u=[],s.push(0===n.length?t:c(e,n)(t)),n.push({inverse:d,styles:function(e){let t;i.lastIndex=0;let n=[];for(;null!==(t=i.exec(e));){let e=t[1];if(t[2]){let r=function(e,t){let n,r=[];for(let i of t.trim().split(/\s*,\s*/g)){let t=Number(i);if(Number.isNaN(t))if(n=i.match(o))r.push(n[2].replace(a,(e,t,n)=>t?l(t):n));else throw Error(`Invalid Chalk template style argument: ${i} (in style '${e}')`);else r.push(t)}return r}(e,t[2]);n.push([e].concat(r))}else n.push([e])}return n}(p)})}else if(f){if(0===n.length)throw Error("Found extraneous } in Chalk template literal");s.push(c(e,n)(u.join(""))),u=[],n.pop()}else u.push(h)}),s.push(u.join("")),n.length>0)throw Error(`Chalk template literal is missing ${n.length} closing bracket${1===n.length?"":"s"} (\`}\`)`);return s.join("")}},304922,(e,t,n)=>{"use strict";t.exports={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],ol
1ive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]}},645687,(e,t,n)=>{let r=e.r(304922),i={};for(let e of Object.keys(r))i[r[e]]=e;let o={rgb:{channels:3,labels:"rgb"},hsl:{channels:3,labels:"hsl"},hsv:{channels:3,labels:"hsv"},hwb:{channels:3,labels:"hwb"},cmyk:{channels:4,labels:"cmyk"},xyz:{channels:3,labels:"xyz"},lab:{channels:3,labels:"lab"},lch:{channels:3,labels:"lch"},hex:{channels:1,labels:["hex"]},keyword:{channels:1,labels:["keyword"]},ansi16:{channels:1,labels:["ansi16"]},ansi256:{channels:1,labels:["ansi256"]},hcg:{channels:3,labels:["h","c","g"]},apple:{channels:3,labels:["r16","g16","b16"]},gray:{channels:1,labels:["gray"]}};for(let e of(t.exports=o,Object.keys(o))){if(!("channels"in o[e]))throw Error("missing channels property: "+e);if(!("labels"in o[e]))throw Error("missing channel labels property: "+e);if(o[e].labels.length!==o[e].channels)throw Error("channel and label counts mismatch: "+e);let{channels:t,labels:n}=o[e];delete o[e].channels,delete o[e].labels,Object.defineProperty(o[e],"channels",{value:t}),Object.defineProperty(o[e],"labels",{value:n})}o.rgb.hsl=function(e){let t,n=e[0]/255,r=e[1]/255,i=e[2]/255,o=Math.min(n,r,i),a=Math.max(n,r,i),s=a-o;a===o?t=0:n===a?t=(r-i)/s:r===a?t=2+(i-n)/s:i===a&&(t=4+(n-r)/s),(t=Math.min(60*t,360))<0&&(t+=360);let l=(o+a)/2;return[t,100*(a===o?0:l<=.5?s/(a+o):s/(2-a-o)),100*l]},o.rgb.hsv=function(e){let t,n,r,i,o,a=e[0]/255,s=e[1]/255,l=e[2]/255,c=Math.max(a,s,l),u=c-Math.min(a,s,l),d=function(e){return(c-e)/6/u+.5};return 0===u?(i=0,o=0):(o=u/c,t=d(a),n=d(s),r=d(l),a===c?i=r-n:s===c?i=1/3+t-r:l===c&&(i=2/3+n-t),i<0?i+=1:i>1&&(i-=1)),[360*i,100*o,100*c]},o.rgb.hwb=function(e){let t=e[0],n=e[1],r=e[2];return[o.rgb.hsl(e)[0],1/255*Math.min(t,Math.min(n,r))*100,100*(r=1-1/255*Math.max(t,Math.max(n,r)))]},o.rgb.cmyk=function(e){let t=e[0]/255,n=e[1]/255,r=e[2]/255,i=Math.min(1-t,1-n,1-r);return[100*((1-t-i)/(1-i)||0),100*((1-n-i)/(1-i)||0),100*((1-r-i)/(1-i)||0),100*i]},o.rgb.keyword=function(e){let t,n=i[e];if(n)return n;let o=1/0;for(let n of Object.keys(r)){let i=r[n],a=(e[0]-i[0])**2+(e[1]-i[1])**2+(e[2]-i[2])**2;a<o&&(o=a,t=n)}return t},o.keyword.rgb=function(e){return r[e]},o.rgb.xyz=function(e){let t=e[0]/255,n=e[1]/255,r=e[2]/255;return[100*(.4124*(t=t>.04045?((t+.055)/1.055)**2.4:t/12.92)+.3576*(n=n>.04045?((n+.055)/1.055)**2.4:n/12.92)+.1805*(r=r>.04045?((r+.055)/1.055)**2.4:r/12.92)),100*(.2126*t+.7152*n+.0722*r),100*(.0193*t+.1192*n+.9505*r)]},o.rgb.lab=function(e){let t=o.rgb.xyz(e),n=t[0],r=t[1],i=t[2];return n/=95.047,r/=100,i/=108.883,[116*(r=r>.008856?r**(1/3):7.787*r+16/116)-16,500*((n=n>.008856?n**(1/3):7.787*n+16/116)-r),200*(r-(i=i>.008856?i**(1/3):7.787*i+16/116))]},o.hsl.rgb=function(e){let t,n,r,i=e[0]/360,o=e[1]/100,a=e[2]/100;if(0===o)return[r=255*a,r,r];t=a<.5?a*(1+o):a+o-a*o;let s=2*a-t,l=[0,0,0];for(let e=0;e<3;e++)(n=i+-(1/3*(e-1)))<0&&n++,n>1&&n--,r=6*n<1?s+(t-s)*6*n:2*n<1?t:3*n<2?s+(t-s)*(2/3-n)*6:s,l[e]=255*r;return l},o.hsl.hsv=function(e){let t=e[0],n=e[1]/100,r=e[2]/100,i=n,o=Math.max(r,.01);r*=2,n*=r<=1?r:2-r,i*=o<=1?o:2-o;let a=(r+n)/2;return[t,100*(0===r?2*i/(o+i):2*n/(r+n)),100*a]},o.hsv.rgb=function(e){let t=e[0]/60,n=e[1]/100,r=e[2]/100,i=Math.floor(t)%6,o=t-Math.floor(t),a=255*r*(1-n),s=255*r*(1-n*o),l=255*r*(1-n*(1-o));switch(r*=255,i){case 0:return[r,l,a];case 1:return[s,r,a];case 2:return[a,r,l];case 3:return[a,s,r];case 4:return[l,a,r];case 5:return[r,a,s]}},o.hsv.hsl=function(e){let t,n,r=e[0],i=e[1]/100,o=e[2]/100,a=Math.max(o,.01);n=(2-i)*o;let s=(2-i)*a;return[r,100*(t=(t=i*a/(s<=1?s:2-s))||0),100*(n/=2)]},o.hwb.rgb=function(e){let t,n,r,i,o=e[0]/360,a=e[1]/100,s=e[2]/100,l=a+s;l>1&&(a/=l,s/=l);let c=Math.floor(6*o),u=1-s;t=6*o-c,(1&c)!=0&&(t=1-t);let d=a+t*(u-a);switch(c){default:case 6:case 0:n=u,r=d,i=a;break;case 1:n=d,r=u,i=a;break;case 2:n=a,r=u,i=d;break;case 3:n=a,r=d,i=u;break;case 4:n=d,r=a,i=u;break;case 5:n=u,r=a,i=d}return[255*n,255*r,255*i]},o.cmyk.rgb=function(e){let t=e[0]/100,n=e[1]/100,r=e[2]/100,i=e[3]/100;return[255*(1-Math.min(1,t*(1-i)+i)),255*(1-Math.min(1,n*(1-i)+i)),255*(1-Math.min(1,r*(1-i)+i))]},o.xyz.rgb=function(e){let t,n,r,i=e[0]/100,o=e[1]/100,a=e[2]/100;return t=(t=3.2406*i+-1.5372*o+-.4986*a)>
1.0031308?1.055*t**(1/2.4)-.055:12.92*t,n=(n=-.9689*i+1.8758*o+.0415*a)>.0031308?1.055*n**(1/2.4)-.055:12.92*n,r=(r=.0557*i+-.204*o+1.057*a)>.0031308?1.055*r**(1/2.4)-.055:12.92*r,[255*(t=Math.min(Math.max(0,t),1)),255*(n=Math.min(Math.max(0,n),1)),255*(r=Math.min(Math.max(0,r),1))]},o.xyz.lab=function(e){let t=e[0],n=e[1],r=e[2];return t/=95.047,n/=100,r/=108.883,[116*(n=n>.008856?n**(1/3):7.787*n+16/116)-16,500*((t=t>.008856?t**(1/3):7.787*t+16/116)-n),200*(n-(r=r>.008856?r**(1/3):7.787*r+16/116))]},o.lab.xyz=function(e){let t,n,r,i=e[0],o=e[1],a=e[2];t=o/500+(n=(i+16)/116),r=n-a/200;let s=n**3,l=t**3,c=r**3;return n=(s>.008856?s:(n-16/116)/7.787)*100,[t=(l>.008856?l:(t-16/116)/7.787)*95.047,n,r=(c>.008856?c:(r-16/116)/7.787)*108.883]},o.lab.lch=function(e){let t,n=e[0],r=e[1],i=e[2];return(t=360*Math.atan2(i,r)/2/Math.PI)<0&&(t+=360),[n,Math.sqrt(r*r+i*i),t]},o.lch.lab=function(e){let t=e[0],n=e[1],r=e[2]/360*2*Math.PI;return[t,n*Math.cos(r),n*Math.sin(r)]},o.rgb.ansi16=function(e,t=null){let[n,r,i]=e,a=null===t?o.rgb.hsv(e)[2]:t;if(0===(a=Math.round(a/50)))return 30;let s=30+(Math.round(i/255)<<2|Math.round(r/255)<<1|Math.round(n/255));return 2===a&&(s+=60),s},o.hsv.ansi16=function(e){return o.rgb.ansi16(o.hsv.rgb(e),e[2])},o.rgb.ansi256=function(e){let t=e[0],n=e[1],r=e[2];return t===n&&n===r?t<8?16:t>248?231:Math.round((t-8)/247*24)+232:16+36*Math.round(t/255*5)+6*Math.round(n/255*5)+Math.round(r/255*5)},o.ansi16.rgb=function(e){let t=e%10;if(0===t||7===t)return e>50&&(t+=3.5),[t=t/10.5*255,t,t];let n=(~~(e>50)+1)*.5;return[(1&t)*n*255,(t>>1&1)*n*255,(t>>2&1)*n*255]},o.ansi256.rgb=function(e){let t;if(e>=232){let t=(e-232)*10+8;return[t,t,t]}return[Math.floor((e-=16)/36)/5*255,Math.floor((t=e%36)/6)/5*255,t%6/5*255]},o.rgb.hex=function(e){let t=(((255&Math.round(e[0]))<<16)+((255&Math.round(e[1]))<<8)+(255&Math.round(e[2]))).toString(16).toUpperCase();return"000000".substring(t.length)+t},o.hex.rgb=function(e){let t=e.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);if(!t)return[0,0,0];let n=t[0];3===t[0].length&&(n=n.split("").map(e=>e+e).join(""));let r=parseInt(n,16);return[r>>16&255,r>>8&255,255&r]},o.rgb.hcg=function(e){let t,n=e[0]/255,r=e[1]/255,i=e[2]/255,o=Math.max(Math.max(n,r),i),a=Math.min(Math.min(n,r),i),s=o-a;return t=s<1?a/(1-s):0,[360*((s<=0?0:o===n?(r-i)/s%6:o===r?2+(i-n)/s:4+(n-r)/s)/6%1),100*s,100*t]},o.hsl.hcg=function(e){let t=e[1]/100,n=e[2]/100,r=n<.5?2*t*n:2*t*(1-n),i=0;return r<1&&(i=(n-.5*r)/(1-r)),[e[0],100*r,100*i]},o.hsv.hcg=function(e){let t=e[1]/100,n=e[2]/100,r=t*n,i=0;return r<1&&(i=(n-r)/(1-r)),[e[0],100*r,100*i]},o.hcg.rgb=function(e){let t=e[0]/360,n=e[1]/100,r=e[2]/100;if(0===n)return[255*r,255*r,255*r];let i=[0,0,0],o=t%1*6,a=o%1,s=1-a,l=0;switch(Math.floor(o)){case 0:i[0]=1,i[1]=a,i[2]=0;break;case 1:i[0]=s,i[1]=1,i[2]=0;break;case 2:i[0]=0,i[1]=1,i[2]=a;break;case 3:i[0]=0,i[1]=s,i[2]=1;break;case 4:i[0]=a,i[1]=0,i[2]=1;break;default:i[0]=1,i[1]=0,i[2]=s}return l=(1-n)*r,[(n*i[0]+l)*255,(n*i[1]+l)*255,(n*i[2]+l)*255]},o.hcg.hsv=function(e){let t=e[1]/100,n=t+e[2]/100*(1-t),r=0;return n>0&&(r=t/n),[e[0],100*r,100*n]},o.hcg.hsl=function(e){let t=e[1]/100,n=e[2]/100*(1-t)+.5*t,r=0;return n>0&&n<.5?r=t/(2*n):n>=.5&&n<1&&(r=t/(2*(1-n))),[e[0],100*r,100*n]},o.hcg.hwb=function(e){let t=e[1]/100,n=t+e[2]/100*(1-t);return[e[0],(n-t)*100,(1-n)*100]},o.hwb.hcg=function(e){let t=e[1]/100,n=1-e[2]/100,r=n-t,i=0;return r<1&&(i=(n-r)/(1-r)),[e[0],100*r,100*i]},o.apple.rgb=function(e){return[e[0]/65535*255,e[1]/65535*255,e[2]/65535*255]},o.rgb.apple=function(e){return[e[0]/255*65535,e[1]/255*65535,e[2]/255*65535]},o.gray.rgb=function(e){return[e[0]/100*255,e[0]/100*255,e[0]/100*255]},o.gray.hsl=function(e){return[0,0,e[0]]},o.gray.hsv=o.gray.hsl,o.gray.hwb=function(e){return[0,100,e[0]]},o.gray.cmyk=function(e){return[0,0,0,e[0]]},o.gray.lab=function(e){return[e[0],0,0]},o.gray.hex=function(e){let t=255&Math.round(e[0]/100*255),n=((t<<16)+(t<<8)+t).toString(16).toUpperCase();return"000000".substring(n.length)+n},o.rgb.gray=function(e){return[(e[0]+e[1]+e[2])/3/255*100]}},28626,(e,t,n)=>{let r=e.r(645687);t.exports=function(e){let t=function(e){let t=function(){let e={},t=Object.keys(r);for(let n=t.length,r=0;r<n;r++)e[t[r]]={distance:-1,parent:null};return e}(),n=[e];for(t[e].distance=0;n.length;){let e=n.pop(),i=Object.keys(r[e]);for(let r=i.length,o=0;o<r;o++){let r=i[o],a=t[r];-1===a.distance&&(a.distance=t[e].distance+1,a.parent=e,n.unshift(r))}}return t}(e),n={},i=Object.keys(t);for(let e=i.length,o=0;o<e;o++){let e=i[o];null!==t[e].parent&&(n[e]=function(e,t){let n=[t[e].parent,e],i=r[t[e].parent][e],o=t[e].parent;for(;t[o].parent;)n.unshift(t[o].parent),i=function(e,t){return function(n){return t(e(n))}}(r[t[o].parent][o],i),o=t[o].parent;return i.conversion=n,i}(e,t))}return n}},438483,(e,t,n)=>{let r=e.r(645687),i=e.r(28626),o={};
1Object.keys(r).forEach(e=>{o[e]={},Object.defineProperty(o[e],"channels",{value:r[e].channels}),Object.defineProperty(o[e],"labels",{value:r[e].labels});let t=i(e);Object.keys(t).forEach(n=>{let r,i,a=t[n];o[e][n]=(r=function(...e){let t=e[0];if(null==t)return t;t.length>1&&(e=t);let n=a(e);if("object"==typeof n)for(let e=n.length,t=0;t<e;t++)n[t]=Math.round(n[t]);return n},"conversion"in a&&(r.conversion=a.conversion),r),o[e][n].raw=(i=function(...e){let t=e[0];return null==t?t:(t.length>1&&(e=t),a(e))},"conversion"in a&&(i.conversion=a.conversion),i)})}),t.exports=o},115388,(e,t,n)=>{"use strict";let r,i=(e,t)=>(...n)=>{let r=e(...n);return`\u001B[${r+t}m`},o=(e,t)=>(...n)=>{let r=e(...n);return`\u001B[${38+t};5;${r}m`},a=(e,t)=>(...n)=>{let r=e(...n);return`\u001B[${38+t};2;${r[0]};${r[1]};${r[2]}m`},s=e=>e,l=(e,t,n)=>[e,t,n],c=(e,t,n)=>{Object.defineProperty(e,t,{get:()=>{let r=n();return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0}),r},enumerable:!0,configurable:!0})},u=(t,n,i,o)=>{void 0===r&&(r=e.r(438483));let a=10*!!o,s={};for(let[e,o]of Object.entries(r)){let r="ansi16"===e?"ansi":e;e===n?s[r]=t(i,a):"object"==typeof o&&(s[r]=t(o[n],a))}return s};Object.defineProperty(t,"exports",{enumerable:!0,get:function(){let e=new Map,t={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}};for(let[n,r]of(t.color.gray=t.color.blackBright,t.bgColor.bgGray=t.bgColor.bgBlackBright,t.color.grey=t.color.blackBright,t.bgColor.bgGrey=t.bgColor.bgBlackBright,Object.entries(t))){for(let[n,i]of Object.entries(r))t[n]={open:`\u001B[${i[0]}m`,close:`\u001B[${i[1]}m`},r[n]=t[n],e.set(i[0],i[1]);Object.defineProperty(t,n,{value:r,enumerable:!1})}return Object.defineProperty(t,"codes",{value:e,enumerable:!1}),t.color.close="\x1b[39m",t.bgColor.close="\x1b[49m",c(t.color,"ansi",()=>u(i,"ansi16",s,!1)),c(t.color,"ansi256",()=>u(o,"ansi256",s,!1)),c(t.color,"ansi16m",()=>u(a,"rgb",l,!1)),c(t.bgColor,"ansi",()=>u(i,"ansi16",s,!0)),c(t.bgColor,"ansi256",()=>u(o,"ansi256",s,!0)),c(t.bgColor,"ansi16m",()=>u(a,"rgb",l,!0)),t}})},97383,(e,t,n)=>{"use strict";t.exports={stdout:!1,stderr:!1}},499939,(e,t,n)=>{"use strict";t.exports={stringReplaceAll:(e,t,n)=>{let r=e.indexOf(t);if(-1===r)return e;let i=t.length,o=0,a="";do a+=e.substr(o,r-o)+t+n,o=r+i,r=e.indexOf(t,o);while(-1!==r)return a+e.substr(o)},stringEncaseCRLFWithFirstIndex:(e,t,n,r)=>{let i=0,o="";do{let a="\r"===e[r-1];o+=e.substr(i,(a?r-1:r)-i)+t+(a?"\r\n":"\n")+n,i=r+1,r=e.indexOf("\n",i)}while(-1!==r)return o+e.substr(i)}}},358909,(e,t,n)=>{"use strict";let r,i=e.r(115388),{stdout:o,stderr:a}=e.r(97383),{stringReplaceAll:s,stringEncaseCRLFWithFirstIndex:l}=e.r(499939),{isArray:c}=Array,u=["ansi","ansi","ansi256","ansi16m"],d=Object.create(null);class p{constructor(e){return f(e)}}let f=e=>{let t={};return((e,t={})=>{if(t.level&&!(Number.isInteger(t.level)&&t.level>=0&&t.level<=3))throw Error("The `level` option should be an integer from 0 to 3");let n=o?o.level:0;e.level=void 0===t.level?n:t.level})(t,e),t.template=(...e)=>b(t.template,...e),Object.setPrototypeOf(t,h.prototype),Object.setPrototypeOf(t.template,t),t.template.constructor=()=>{throw Error("`chalk.constructor()` is deprecated. Use `new chalk.Instance()` instead.")},t.template.Instance=p,t.template};function h(e){return f(e)}for(let[e,t]of Object.entries(i))d[e]={get(){let n=k(this,y(t.open,t.close,this._styler),this._isEmpty);return Object.defineProperty(this,e,{value:n}),n}};d.visible={get(){let e=k(this,this._styler,!0);return Object.defineProperty(this,"visible",{value:e}),e}};let g=["rgb","hex","keyword","hsl","hsv","hwb","ansi","ansi256"];for(let e of g)d[e]={get(){let{level:t}=this;return function(...n){return k(this,y(i.color[u[t]][e](...n),i.color.close,this._styler),this._isEmpty)}}};for(let e of g)d["bg"+e[0].toUpperCase()+e.slice(1)]={get(){let{level:t}=this;return function(...n){return k(this,y(i.bgColor[u[t]][e](...n),i.bgColor.close,this._styler),this._isEmpty)}}};let m=Object.defineProperties(()=>{},{...d,level:{enumerable:!0,get(){return this._generator.level},set(e){this._generator.level=e}}}),y=(e,t,n)=>{let r,i;return void 0===n?(r=e,i=t):(r=n.openAll+e,i=t+n.closeAll),{open:e,close:t,openAll:r,closeAll:i,parent:n}},k=(e,t,n)=>{let r=(...e)=>c(e[0])&&c(e[0].raw)?v(r,b(r,...e)):v(r,1===e.length?""+e[0]:e.join(" "));return Object.setPrototypeOf(r,m),r._generator=e,r._styler=t,r._isEmpty=n,r},v=(e,t)=>
1{if(e.level<=0||!t)return e._isEmpty?"":t;let n=e._styler;if(void 0===n)return t;let{openAll:r,closeAll:i}=n;if(-1!==t.indexOf("\x1b"))for(;void 0!==n;)t=s(t,n.close,n.open),n=n.parent;let o=t.indexOf("\n");return -1!==o&&(t=l(t,i,r,o)),r+t+i},b=(t,...n)=>{let[i]=n;if(!c(i)||!c(i.raw))return n.join(" ");let o=n.slice(1),a=[i.raw[0]];for(let e=1;e<i.length;e++)a.push(String(o[e-1]).replace(/[{}\\]/g,"\\$&"),String(i.raw[e]));return void 0===r&&(r=e.r(158079)),r(t,a.join(""))};Object.defineProperties(h.prototype,d);let x=f(void 0);x.supportsColor=o,x.stderr=f({level:a?a.level:0}),x.stderr.supportsColor=a,t.exports=x},775780,(e,t,n)=>{t.exports=function(e){return null!=e&&null!=e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}},232189,(e,t,n)=>{"use strict";t.exports="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"},865156,(e,t,n)=>{"use strict";var r=e.r(232189);function i(){}function o(){}o.resetWarningCache=i,t.exports=function(){function e(e,t,n,i,o,a){if(a!==r){var s=Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw s.name="Invariant Violation",s}}function t(){return e}e.isRequired=e;var n={array:e,bigint:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,elementType:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t,checkPropTypes:o,resetWarningCache:i}
1;return n.PropTypes=n,n}},745009,(e,t,n)=>{t.exports=e.r(865156)()},460838,(e,t,n)=>{"use strict";var r,i=Symbol.for("react.element"),o=Symbol.for("react.portal"),a=Symbol.for("react.fragment"),s=Symbol.for("react.strict_mode"),l=Symbol.for("react.profiler"),c=Symbol.for("react.provider"),u=Symbol.for("react.context"),d=Symbol.for("react.server_context"),p=Symbol.for("react.forward_ref"),f=Symbol.for("react.suspense"),h=Symbol.for("react.suspense_list"),g=Symbol.for("react.memo"),m=Symbol.for("react.lazy"),y=Symbol.for("react.offscreen");function k(e){if("object"==typeof e&&null!==e){var t=e.$$typeof;switch(t){case i:switch(e=e.type){case a:case l:case s:case f:case h:return e;default:switch(e=e&&e.$$typeof){case d:case u:case p:case m:case g:case c:return e;default:return t}}case o:return t}}}r=Symbol.for("react.module.reference"),n.ContextConsumer=u,n.ContextProvider=c,n.Element=i,n.ForwardRef=p,n.Fragment=a,n.Lazy=m,n.Memo=g,n.Portal=o,n.Profiler=l,n.StrictMode=s,n.Suspense=f,n.SuspenseList=h,n.isAsyncMode=function(){return!1},n.isConcurrentMode=function(){return!1},n.isContextConsumer=function(e){return k(e)===u},n.isContextProvider=function(e){return k(e)===c},n.isElement=function(e){return"object"==typeof e&&null!==e&&e.$$typeof===i},n.isForwardRef=function(e){return k(e)===p},n.isFragment=function(e){return k(e)===a},n.isLazy=function(e){return k(e)===m},n.isMemo=function(e){return k(e)===g},n.isPortal=function(e){return k(e)===o},n.isProfiler=function(e){return k(e)===l},n.isStrictMode=function(e){return k(e)===s},n.isSuspense=function(e){return k(e)===f},n.isSuspenseList=function(e){return k(e)===h},n.isValidElementType=function(e){return"string"==typeof e||"function"==typeof e||e===a||e===l||e===s||e===f||e===h||e===y||"object"==typeof e&&null!==e&&(e.$$typeof===m||e.$$typeof===g||e.$$typeof===c||e.$$typeof===u||e.$$typeof===p||e.$$typeof===r||void 0!==e.getModuleId)||!1},n.typeOf=k},338445,(e,t,n)=>{"use strict";t.exports=e.r(460838)},71606,(e,t,n)=>{var r=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,i=/\n/g,o=/^\s*/,a=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,s=/^:\s*/,l=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,c=/^[;\s]*/,u=/^\s+|\s+$/g;function d(e){return e?e.replace(u,""):""}t.exports=function(e,t){if("string"!=typeof e)throw TypeError("First argument must be a string");if(!e)return[];t=t||{};var n=1,u=1;function p(e){var t=e.match(i);t&&(n+=t.length);var r=e.lastIndexOf("\n");u=~r?e.length-r:u+e.length}function f(){var e={line:n,column:u};return function(t){return t.position=new h(e),y(o),t}}function h(e){this.start=e,this.end={line:n,column:u},this.source=t.source}h.prototype.content=e;var g=[];function m(r){var i=Error(t.source+":"+n+":"+u+": "+r);if(i.reason=r,i.filename=t.source,i.line=n,i.column=u,i.source=e,t.silent)g.push(i);else throw i}function y(t){var n=t.exec(e);if(n){var r=n[0];return p(r),e=e.slice(r.length),n}}function k(e){var t;for(e=e||[];t=v();)!1!==t&&e.push(t);return e}function v(){var t=f();if("/"==e.charAt(0)&&"*"==e.charAt(1)){for(var n=2;""!=e.charAt(n)&&("*"!=e.charAt(n)||"/"!=e.charAt(n+1));)++n;if(n+=2,""===e.charAt(n-1))return m("End of comment missing");var r=e.slice(2,n-2);return u+=2,p(r),e=e.slice(n),u+=2,t({type:"comment",comment:r})}}y(o);var b,x=[];for(k(x);b=function(){var e=f(),t=y(a);if(t){if(v(),!y(s))return m("property missing ':'");var n=y(l),i=e({type:"declaration",property:d(t[0].replace(r,"")),value:n?d(n[0].replace(r,"")):""});return y(c),i}}();)!1!==b&&(x.push(b),k(x));return x}},566935,(e,t,n)=>{var r=e.r(71606);function i(e,t){var n,i,o,a=null;if(!e||"string"!=typeof e)return a;for(var s=r(e),l="function"==typeof t,c=0,u=s.length;c<u;c++)i=(n=s[c]).property,o=n.value,l?t(i,o,n):o&&(a||(a={}),a[i]=o);return a}t.exports=i,t.exports.default=i},563542,75830,586318,842727,405310,685208,1770,284545,647126,e=>{"use strict";let t,n,r,i,o,a;var s,l,c,u,d,p,f,h,g,m,y,k,v=e.i(271645);e.i(405537);var b=e.i(638955),x=e.i(555144),w=e.i(843476);let E={chatInputPlaceholder:"Type a message...",chatInputToolbarStartTranscribeButtonLabel:"Transcribe",chatInputToolbarCancelTranscribeButtonLabel:"Cancel",chatInputToolbarFinishTranscribeButtonLabel:"Finish",chatInputToolbarAddButtonLabel:"Add photos or files",chatInputToolbarToolsButtonLabel:"Tools",assistantMessageToolbarCopyCodeLabel:"Copy",assistantMessageToolbarCopyCodeCopiedLabel:"Copied",assistantMessageToolbarCopyMessageLabel:"Copy",assistantMessageToolbarThumbsUpLabel:"Good response",assistantMessageToolbarThumbsDownLabel:"Bad response",assistantMessageToolbarReadAloudLabel:"Read aloud",assistantMessageToolbarRegenerateLabel:"Regenerate",userMe
1ssageToolbarCopyMessageLabel:"Copy",userMessageToolbarEditMessageLabel:"Edit",chatDisclaimerText:"AI can make mistakes. Please verify important information.",chatToggleOpenLabel:"Open chat",chatToggleCloseLabel:"Close chat",modalHeaderTitle:"CopilotKit Chat",welcomeMessageText:"How can I help you today?"},S=(0,v.createContext)(null),C=({children:e,labels:t,agentId:n,threadId:r,isModalDefaultOpen:i})=>{let o=(0,v.useContext)(S),a=(0,v.useMemo)(()=>({...E,...o?.labels??{},...t??{}}),[t,o?.labels]),s=n??o?.agentId??b.DEFAULT_AGENT_ID,l=(0,v.useMemo)(()=>r||(o?.threadId?o.threadId:(0,x.randomUUID)()),[r,o?.threadId]),c=void 0!==i,[u,d]=(0,v.useState)(o?.isModalOpen??i??!0),p=c?u:o?.isModalOpen,f=c?d:o?.setModalOpen,h=(0,v.useMemo)(()=>({labels:a,agentId:s,threadId:l,isModalOpen:p,setModalOpen:f}),[a,s,l,p,f]);return(0,w.jsx)(S.Provider,{value:h,children:e})},T=()=>(0,v.useContext)(S);var N=e.i(919056),A=class extends Error{constructor(e){super(e),this.name="AudioRecorderError"}};let _=(0,v.forwardRef)((e,t)=>{let{className:n,...r}=e,i=(0,v.useRef)(null),[o,a]=(0,v.useState)("idle"),s=(0,v.useRef)(null),l=(0,v.useRef)([]),c=(0,v.useRef)(null),u=(0,v.useRef)(null),d=(0,v.useRef)(null),p=(0,v.useRef)(null),f=(0,v.useRef)([]),h=(0,v.useRef)(0),g=(0,v.useRef)(0),m=(0,v.useRef)(0),y=(0,v.useRef)(0),k=(0,v.useCallback)(()=>{if(p.current&&(cancelAnimationFrame(p.current),p.current=null),s.current&&"inactive"!==s.current.state)try{s.current.stop()}catch{}c.current&&(c.current.getTracks().forEach(e=>e.stop()),c.current=null),d.current&&"closed"!==d.current.state&&(d.current.close().catch(()=>{}),d.current=null),s.current=null,u.current=null,l.current=[],f.current=[],h.current=0,g.current=0,m.current=0,y.current=0},[]),b=(0,v.useCallback)(async()=>{if("idle"!==o)throw new A("Recorder is already active");try{let e=await navigator.mediaDevices.getUserMedia({audio:!0});c.current=e;let t=new AudioContext;d.current=t;let n=t.createMediaStreamSource(e),r=t.createAnalyser();r.fftSize=2048,n.connect(r),u.current=r;let i=MediaRecorder.isTypeSupported("audio/webm;codecs=opus")?"audio/webm;codecs=opus":MediaRecorder.isTypeSupported("audio/webm")?"audio/webm":MediaRecorder.isTypeSupported("audio/mp4")?"audio/mp4":"",o=new MediaRecorder(e,i?{mimeType:i}:{});s.current=o,l.current=[],o.ondataavailable=e=>{e.data.size>0&&l.current.push(e.data)},o.start(100),a("recording")}catch(e){if(k(),e instanceof Error&&"NotAllowedError"===e.name)throw new A("Microphone permission denied");if(e instanceof Error&&"NotFoundError"===e.name)throw new A("No microphone found");throw new A(e instanceof Error?e.message:"Failed to start recording")}},[o,k]),x=(0,v.useCallback)(()=>new Promise((e,t)=>{let n=s.current;n&&"recording"===o?(a("processing"),n.onstop=()=>{let t=n.mimeType||"audio/webm",r=new Blob(l.current,{type:t});k(),a("idle"),e(r)},n.onerror=()=>{k(),a("idle"),t(new A("Recording failed"))},n.stop()):t(new A("No active recording"))}),[o,k]);return(0,v.useEffect)(()=>{let e=i.current;if(!e)return;let t=e.getContext("2d");if(!t)return;let n=1/3,r=()=>{let i=e.getBoundingClientRect(),a=window.devicePixelRatio||1;(e.width!==i.width*a||e.height!==i.height*a)&&(e.width=i.width*a,e.height=i.height*a,t.scale(a,a));let s=Math.floor(i.width/3)+2;if(u.current&&"recording"===o){0===f.current.length&&(f.current=Array(s).fill(0)),y.current<1&&(y.current=Math.min(1,y.current+.03)),g.current+=n;let e=new Uint8Array(u.current.fftSize);u.current.getByteTimeDomainData(e);let t=(e=>{let t=0;for(let n=0;n<e.length;n++){let r=(e[n]??128)/128-1;t+=r*r}return Math.sqrt(t/e.length)})(e),r=t>m.current?.12:.08;m.current+=(t-m.current)*r,g.current>=3&&(g.current-=3,f.current.push(m.current),f.current.length>s&&(f.current=f.current.slice(-s)))}t.clearRect(0,0,i.width,i.height),t.fillStyle=getComputedStyle(e).color,t.globalAlpha=y.current;let l=i.height/2,c=i.height/2-2,d=f.current;if(d.length>0){let e=g.current;for(let n=0;n<d.length;n++){let r=Math.max(2,Math.min(4*(d[n]??0),1)*c*2),o=i.width-(d.length-n)*3-e,a=l-r/2;if(o+2>0&&o<i.width){let e=1;o<12?e=Math.max(0,o/12):o>i.width-12&&(e=Math.max(0,(i.width-o)/12)),t.globalAlpha=y.current*e,t.fillRect(o,a,2,r)}}}p.current=requestAnimationFrame(r)};return r(),()=>{p.current&&cancelAnimationFrame(p.current)}},[o]),(0,v.useEffect)(()=>k,[k]),(0,v.useImperativeHandle)(t,()=>({get state(){return o},start:b,stop:x,dispose:k}),[o,b,x,k]),(0,w.jsx)("div",{className:(0,N.twMerge)("cpk:w-full cpk:py-3 cpk:px-5",n),...r,children:(0,w.jsx)("canvas",{ref:i,className:"cpk:block cpk:w-full cpk:h-[26px]"})})});_.displayName="CopilotChatAudioRecorder";var I=e.i(207670);let R=(0,N.extendTailwindMerge)({prefix:"cpk"});function M(...e){return R((0,I.clsx)(e))}var O=e.i(991918);let j=(0,e.i(225913).cva)("cpk:inline-flex cpk:items-center cpk:justify-center cpk:gap-2 cpk:whitespace-nowrap cpk:rounded-md cpk:text-sm cpk:font-medium cpk:transition-all cpk:disabled:pointer-events-none cpk:disabled:opacity-50 cpk:[&_svg]:pointer-events-none cpk:[&_svg:not([class*='size-'])]:size-4 cpk:shrink-0 cpk:[&_svg]:shrink-0 cpk:outline-none cpk:focus-visible:border-ring cpk:focus-visible:ring-ring/50 cpk:focus-visible:ring-[3px] cpk:aria-invalid:ring-destructive/20 cpk:dark:aria-invalid:ring-destructive/40 cpk:aria-invalid:border-destructive",{variants:{variant:{default:"cpk:bg-primary cpk:text-primary-foreground cpk:shadow-xs cpk:hover:bg-primary/90",destructive:"cpk:bg-
1destructive cpk:text-white cpk:shadow-xs cpk:hover:bg-destructive/90 cpk:focus-visible:ring-destructive/20 cpk:dark:focus-visible:ring-destructive/40 cpk:dark:bg-destructive/60",outline:"cpk:border cpk:bg-background cpk:shadow-xs cpk:hover:bg-accent cpk:hover:text-accent-foreground cpk:dark:bg-input/30 cpk:dark:border-input cpk:dark:hover:bg-input/50",secondary:"cpk:bg-secondary cpk:text-secondary-foreground cpk:shadow-xs cpk:hover:bg-secondary/80",ghost:"cpk:hover:bg-accent cpk:hover:text-accent-foreground cpk:dark:hover:bg-accent/50 cpk:cursor-pointer",link:"cpk:text-primary cpk:underline-offset-4 cpk:hover:underline",assistantMessageToolbarButton:["cpk:cursor-pointer","cpk:p-0 cpk:text-[rgb(93,93,93)] cpk:hover:bg-[#E8E8E8]","cpk:dark:text-[rgb(243,243,243)] cpk:dark:hover:bg-[#303030]","cpk:h-8 cpk:w-8","cpk:transition-colors","cpk:hover:text-[rgb(93,93,93)]","cpk:dark:hover:text-[rgb(243,243,243)]"],chatInputToolbarPrimary:["cpk:cursor-pointer","cpk:bg-black cpk:text-white","cpk:dark:bg-white cpk:dark:text-black cpk:dark:focus-visible:outline-white","cpk:rounded-full","cpk:transition-colors","cpk:focus:outline-none","cpk:hover:opacity-70 cpk:disabled:hover:opacity-100","cpk:disabled:cursor-not-allowed cpk:disabled:bg-[#00000014] cpk:disabled:text-[rgb(13,13,13)]","cpk:dark:disabled:bg-[#454545] cpk:dark:disabled:text-white "],chatInputToolbarSecondary:["cpk:cursor-pointer","cpk:bg-transparent cpk:text-[#444444]","cpk:dark:text-white cpk:dark:border-[#404040]","cpk:rounded-full","cpk:transition-colors","cpk:focus:outline-none","cpk:hover:bg-[#f8f8f8] cpk:hover:text-[#333333]","cpk:dark:hover:bg-[#404040] cpk:dark:hover:text-[#FFFFFF]","cpk:disabled:cursor-not-allowed cpk:disabled:opacity-50","cpk:disabled:hover:bg-transparent cpk:disabled:hover:text-[#444444]","cpk:dark:disabled:hover:bg-transparent cpk:dark:disabled:hover:text-[#CCCCCC]"]},size:{default:"cpk:h-9 cpk:px-4 cpk:py-2 cpk:has-[>svg]:px-3",sm:"cpk:h-8 cpk:rounded-md cpk:gap-1.5 cpk:px-3 cpk:has-[>svg]:px-2.5",lg:"cpk:h-10 cpk:rounded-md cpk:px-6 cpk:has-[>svg]:px-4",icon:"cpk:size-9",chatInputToolbarIcon:["cpk:h-9 cpk:w-9 cpk:rounded-full"],chatInputToolbarIconLabel:["cpk:h-9 cpk:px-3 cpk:rounded-full","cpk:gap-2","cpk:font-normal"]}},defaultVariants:{variant:"default",size:"default"}});function z({className:e,variant:t,size:n,asChild:r=!1,...i}){return(0,w.jsx)(r?O.Slot:"button",{"data-slot":"button",className:M(j({variant:t,size:n,className:e})),...i})}var D=e.i(186336);function P({delayDuration:e=0,...t}){return(0,w.jsx)(D.Provider,{"data-slot":"tooltip-provider",delayDuration:e,...t})}function F({...e}){return(0,w.jsx)(P,{children:(0,w.jsx)(D.Root,{"data-slot":"tooltip",...e})})}function L({...e}){return(0,w.jsx)(D.Trigger,{"data-slot":"tooltip-trigger",...e})}function U({className:e,sideOffset:t=0,children:n,...r}){return(0,w.jsx)(D.Portal,{children:(0,w.jsxs)(D.Content,{"data-copilotkit":!0,"data-slot":"tooltip-content",sideOffset:t,className:M("cpk:bg-primary cpk:text-primary-foreground cpk:animate-in cpk:fade-in-0 cpk:zoom-in-95 cpk:data-[state=closed]:animate-out cpk:data-[state=closed]:fade-out-0 cpk:data-[state=closed]:zoom-out-95 cpk:data-[side=bottom]:slide-in-from-top-2 cpk:data-[side=left]:slide-in-from-right-2 cpk:data-[side=right]:slide-in-from-left-2 cpk:data-[side=top]:slide-in-from-bottom-2 cpk:z-50 cpk:w-fit cpk:origin-(--radix-tooltip-content-transform-origin) cpk:rounded-md cpk:px-3 cpk:py-1.5 cpk:text-xs cpk:text-balance",e),...r,children:[n,(0,w.jsx)(D.Arrow,{className:"cpk:bg-primary cpk:fill-primary cpk:z-50 cpk:size-2.5 cpk:translate-y-[calc(-50%_-_2px)] cpk:rotate-45 cpk:rounded-[2px]"})]})})}let B=e=>{let t=e.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,t,n)=>n?n.toUpperCase():t.toLowerCase());return t.charAt(0).toUpperCase()+t.slice(1)},$=(...e)=>e.filter((e,t,n)=>!!e&&""!==e.trim()&&n.indexOf(e)===t).join(" ").trim();var H={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};let K=(0,v.forwardRef)(({color:e="currentColor",size:t=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:i="",children:o,iconNode:a,...s},l)=>(0,v.createElement)("svg",{ref:l,...H,width:t,height:t,stroke:e,strokeWidth:r?24*Number(n)/Number(t):n,className:$("lucide",i),...!o&&!(e=>{for(let t in e)if(t.startsWith("aria-")||"role"===t||"title"===t)return!0})(s)&&{"aria-hidden":"true"},...s},[...a.map(([e,t])=>(0,v.createElement)(e,t)),...Array.isArray(o)?o:[o]])),G=(e,t)=>{let n=(0,v.forwardRef)(({className:n,...r},i)=>(0,v.createElement)(K,{ref:i,iconNode:t,className:$(`lucide-${B(e).replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}`,`lucide-${e}`,n),...r}));return n.displayName=B(e),n},V=G("chevron-right",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);var W=e.i(981140),q=e.i(820783),J=e.i(369340),X=e.i(174080),Y=Symbol("radix.slottable");function Q(e){return v.isValidElement(e)&&"function"==typeof e.type&&"__radixId"in e.type&&e.type.__radixId===Y}var Z=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"].reduce((e,t)=>
1{var n,r;let i,o,a,s=(r=n=`Primitive.${t}`,(i=v.forwardRef((e,t)=>{let{children:n,...r}=e;if(v.isValidElement(n)){var i;let e,o,a=(i=n,(o=(e=Object.getOwnPropertyDescriptor(i.props,"ref")?.get)&&"isReactWarning"in e&&e.isReactWarning)?i.ref:(o=(e=Object.getOwnPropertyDescriptor(i,"ref")?.get)&&"isReactWarning"in e&&e.isReactWarning)?i.props.ref:i.props.ref||i.ref),s=function(e,t){let n={...t};for(let r in t){let i=e[r],o=t[r];/^on[A-Z]/.test(r)?i&&o?n[r]=(...e)=>{let t=o(...e);return i(...e),t}:i&&(n[r]=i):"style"===r?n[r]={...i,...o}:"className"===r&&(n[r]=[i,o].filter(Boolean).join(" "))}return{...e,...n}}(r,n.props);return n.type!==v.Fragment&&(s.ref=t?(0,q.composeRefs)(t,a):a),v.cloneElement(n,s)}return v.Children.count(n)>1?v.Children.only(null):null})).displayName=`${r}.SlotClone`,o=i,(a=v.forwardRef((e,t)=>{let{children:n,...r}=e,i=v.Children.toArray(n),a=i.find(Q);if(a){let e=a.props.children,n=i.map(t=>t!==a?t:v.Children.count(e)>1?v.Children.only(null):v.isValidElement(e)?e.props.children:null);return(0,w.jsx)(o,{...r,ref:t,children:v.isValidElement(e)?v.cloneElement(e,void 0,n):null})}return(0,w.jsx)(o,{...r,ref:t,children:n})})).displayName=`${n}.Slot`,a),l=v.forwardRef((e,n)=>{let{asChild:r,...i}=e;return"undefined"!=typeof window&&(window[Symbol.for("radix-ui")]=!0),(0,w.jsx)(r?s:t,{...i,ref:n})});return l.displayName=`Primitive.${t}`,{...e,[t]:l}},{});function ee(e){var t;let n,r=(t=e,(n=v.forwardRef((e,t)=>{let{children:n,...r}=e;if(v.isValidElement(n)){var i;let e,o,a=(i=n,(o=(e=Object.getOwnPropertyDescriptor(i.props,"ref")?.get)&&"isReactWarning"in e&&e.isReactWarning)?i.ref:(o=(e=Object.getOwnPropertyDescriptor(i,"ref")?.get)&&"isReactWarning"in e&&e.isReactWarning)?i.props.ref:i.props.ref||i.ref),s=function(e,t){let n={...t};for(let r in t){let i=e[r],o=t[r];/^on[A-Z]/.test(r)?i&&o?n[r]=(...e)=>{let t=o(...e);return i(...e),t}:i&&(n[r]=i):"style"===r?n[r]={...i,...o}:"className"===r&&(n[r]=[i,o].filter(Boolean).join(" "))}return{...e,...n}}(r,n.props);return n.type!==v.Fragment&&(s.ref=t?(0,q.composeRefs)(t,a):a),v.cloneElement(n,s)}return v.Children.count(n)>1?v.Children.only(null):null})).displayName=`${t}.SlotClone`,n),i=v.forwardRef((e,t)=>{let{children:n,...i}=e,o=v.Children.toArray(n),a=o.find(en);if(a){let e=a.props.children,n=o.map(t=>t!==a?t:v.Children.count(e)>1?v.Children.only(null):v.isValidElement(e)?e.props.children:null);return(0,w.jsx)(r,{...i,ref:t,children:v.isValidElement(e)?v.cloneElement(e,void 0,n):null})}return(0,w.jsx)(r,{...i,ref:t,children:n})});return i.displayName=`${e}.Slot`,i}var et=Symbol("radix.slottable");function en(e){return v.isValidElement(e)&&"function"==typeof e.type&&"__radixId"in e.type&&e.type.__radixId===et}function er(e){let t=e+"CollectionProvider",[n,r]=function(e,t=[]){let n=[],r=()=>{let t=n.map(e=>v.createContext(e));return function(n){let r=n?.[e]||t;return v.useMemo(()=>({[`__scope${e}`]:{...n,[e]:r}}),[n,r])}};return r.scopeName=e,[function(t,r){let i=v.createContext(r),o=n.length;n=[...n,r];let a=t=>{let{scope:n,children:r,...a}=t,s=n?.[e]?.[o]||i,l=v.useMemo(()=>a,Object.values(a));return(0,w.jsx)(s.Provider,{value:l,children:r})};return a.displayName=t+"Provider",[a,function(n,a){let s=a?.[e]?.[o]||i,l=v.useContext(s);if(l)return l;if(void 0!==r)return r;throw Error(`\`${n}\` must be used within \`${t}\``)}]},function(...e){let t=e[0];if(1===e.length)return t;let n=()=>{let n=e.map(e=>({useScope:e(),scopeName:e.scopeName}));return function(e){let r=n.reduce((t,{useScope:n,scopeName:r})=>{let i=n(e)[`__scope${r}`];return{...t,...i}},{});return v.useMemo(()=>({[`__scope${t.scopeName}`]:r}),[r])}};return n.scopeName=t.scopeName,n}(r,...t)]}(t),[i,o]=n(t,{collectionRef:{current:null},itemMap:new Map}),a=e=>{let{scope:t,children:n}=e,r=v.default.useRef(null),o=v.default.useRef(new Map).current;return(0,w.jsx)(i,{scope:t,itemMap:o,collectionRef:r,children:n})};a.displayName=t;let s=e+"CollectionSlot",l=ee(s),c=v.default.forwardRef((e,t)=>{let{scope:n,children:r}=e,i=o(s,n),a=(0,q.useComposedRefs)(t,i.collectionRef);return(0,w.jsx)(l,{ref:a,children:r})});c.displayName=s;let u=e+"CollectionItemSlot",d="data-radix-collection-item",p=ee(u),f=v.default.forwardRef((e,t)=>
1{let{scope:n,children:r,...i}=e,a=v.default.useRef(null),s=(0,q.useComposedRefs)(t,a),l=o(u,n);return v.default.useEffect(()=>(l.itemMap.set(a,{ref:a,...i}),()=>void l.itemMap.delete(a))),(0,w.jsx)(p,{...{[d]:""},ref:s,children:r})});return f.displayName=u,[{Provider:a,Slot:c,ItemSlot:f},function(t){let n=o(e+"CollectionConsumer",t);return v.default.useCallback(()=>{let e=n.collectionRef.current;if(!e)return[];let t=Array.from(e.querySelectorAll(`[${d}]`));return Array.from(n.itemMap.values()).sort((e,n)=>t.indexOf(e.ref.current)-t.indexOf(n.ref.current))},[n.collectionRef,n.itemMap])},r]}var ei=new WeakMap;function eo(e,t){var n,r;let i,o,a;if("at"in Array.prototype)return Array.prototype.at.call(e,t);let s=(n=e,r=t,i=n.length,(a=(o=ea(r))>=0?o:i+o)<0||a>=i?-1:a);return -1===s?void 0:e[s]}function ea(e){return e!=e||0===e?0:Math.trunc(e)}(class e extends Map{#e;constructor(e){super(e),this.#e=[...super.keys()],ei.set(this,!0)}set(e,t){return ei.get(this)&&(this.has(e)?this.#e[this.#e.indexOf(e)]=e:this.#e.push(e)),super.set(e,t),this}insert(e,t,n){let r,i=this.has(t),o=this.#e.length,a=ea(e),s=a>=0?a:o+a,l=s<0||s>=o?-1:s;if(l===this.size||i&&l===this.size-1||-1===l)return this.set(t,n),this;let c=this.size+ +!i;a<0&&s++;let u=[...this.#e],d=!1;for(let e=s;e<c;e++)if(s===e){let o=u[e];u[e]===t&&(o=u[e+1]),i&&this.delete(t),r=this.get(o),this.set(t,n)}else{d||u[e-1]!==t||(d=!0);let n=u[d?e:e-1],i=r;r=this.get(n),this.delete(n),this.set(n,i)}return this}with(t,n,r){let i=new e(this);return i.insert(t,n,r),i}before(e){let t=this.#e.indexOf(e)-1;if(!(t<0))return this.entryAt(t)}setBefore(e,t,n){let r=this.#e.indexOf(e);return -1===r?this:this.insert(r,t,n)}after(e){let t=this.#e.indexOf(e);if(-1!==(t=-1===t||t===this.size-1?-1:t+1))return this.entryAt(t)}setAfter(e,t,n){let r=this.#e.indexOf(e);return -1===r?this:this.insert(r+1,t,n)}first(){return this.entryAt(0)}last(){return this.entryAt(-1)}clear(){return this.#e=[],super.clear()}delete(e){let t=super.delete(e);return t&&this.#e.splice(this.#e.indexOf(e),1),t}deleteAt(e){let t=this.keyAt(e);return void 0!==t&&this.delete(t)}at(e){let t=eo(this.#e,e);if(void 0!==t)return this.get(t)}entryAt(e){let t=eo(this.#e,e);if(void 0!==t)return[t,this.get(t)]}indexOf(e){return this.#e.indexOf(e)}keyAt(e){return eo(this.#e,e)}from(e,t){let n=this.indexOf(e);if(-1===n)return;let r=n+t;return r<0&&(r=0),r>=this.size&&(r=this.size-1),this.at(r)}keyFrom(e,t){let n=this.indexOf(e);if(-1===n)return;let r=n+t;return r<0&&(r=0),r>=this.size&&(r=this.size-1),this.keyAt(r)}find(e,t){let n=0;for(let r of this){if(Reflect.apply(e,t,[r,n,this]))return r;n++}}findIndex(e,t){let n=0;for(let r of this){if(Reflect.apply(e,t,[r,n,this]))return n;n++}return -1}filter(t,n){let r=[],i=0;for(let e of this)Reflect.apply(t,n,[e,i,this])&&r.push(e),i++;return new e(r)}map(t,n){let r=[],i=0;for(let e of this)r.push([e[0],Reflect.apply(t,n,[e,i,this])]),i++;return new e(r)}reduce(...e){let[t,n]=e,r=0,i=n??this.at(0);for(let n of this)i=0===r&&1===e.length?n:Reflect.apply(t,this,[i,n,r,this]),r++;return i}reduceRight(...e){let[t,n]=e,r=n??this.at(-1);for(let n=this.size-1;n>=0;n--){let i=this.at(n);r=n===this.size-1&&1===e.length?i:Reflect.apply(t,this,[r,i,n,this])}return r}toSorted(t){return new e([...this.entries()].sort(t))}toReversed(){let t=new e;for(let e=this.size-1;e>=0;e--){let n=this.keyAt(e),r=this.get(n);t.set(n,r)}return t}toSpliced(...t){let n=[...this.entries()];return n.splice(...t),new e(n)}slice(t,n){let r=new e,i=this.size-1;if(void 0===t)return r;t<0&&(t+=this.size),void 0!==n&&n>0&&(i=n-1);for(let e=t;e<=i;e++){let t=this.keyAt(e),n=this.get(t);r.set(t,n)}return r}every(e,t){let n=0;for(let r of this){if(!Reflect.apply(e,t,[r,n,this]))return!1;n++}return!0}some(e,t){let n=0;for(let r of this){if(Reflect.apply(e,t,[r,n,this]))return!0;n++}return!1}}),e.s(["createCollection",()=>er],75830);var es=v.createContext(void 0);function el(e){let t=v.useContext(es);return e||t||"ltr"}e.s(["useDirection",()=>el],586318);var ec=e.i(726330),eu=e.i(303536),ed=e.i(765491),ep=e.i(610772),ef=e.i(853660),eh=e.i(774606),eg=e.i(296626);function em(e){var t;let n,r=(t=e,(n=v.forwardRef((e,t)=>
1{let{children:n,...r}=e;if(v.isValidElement(n)){var i;let e,o,a=(i=n,(o=(e=Object.getOwnPropertyDescriptor(i.props,"ref")?.get)&&"isReactWarning"in e&&e.isReactWarning)?i.ref:(o=(e=Object.getOwnPropertyDescriptor(i,"ref")?.get)&&"isReactWarning"in e&&e.isReactWarning)?i.props.ref:i.props.ref||i.ref),s=function(e,t){let n={...t};for(let r in t){let i=e[r],o=t[r];/^on[A-Z]/.test(r)?i&&o?n[r]=(...e)=>{let t=o(...e);return i(...e),t}:i&&(n[r]=i):"style"===r?n[r]={...i,...o}:"className"===r&&(n[r]=[i,o].filter(Boolean).join(" "))}return{...e,...n}}(r,n.props);return n.type!==v.Fragment&&(s.ref=t?(0,q.composeRefs)(t,a):a),v.cloneElement(n,s)}return v.Children.count(n)>1?v.Children.only(null):null})).displayName=`${t}.SlotClone`,n),i=v.forwardRef((e,t)=>{let{children:n,...i}=e,o=v.Children.toArray(n),a=o.find(ek);if(a){let e=a.props.children,n=o.map(t=>t!==a?t:v.Children.count(e)>1?v.Children.only(null):v.isValidElement(e)?e.props.children:null);return(0,w.jsx)(r,{...i,ref:t,children:v.isValidElement(e)?v.cloneElement(e,void 0,n):null})}return(0,w.jsx)(r,{...i,ref:t,children:n})});return i.displayName=`${e}.Slot`,i}var ey=Symbol("radix.slottable");function ek(e){return v.isValidElement(e)&&"function"==typeof e.type&&"__radixId"in e.type&&e.type.__radixId===ey}var ev=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"].reduce((e,t)=>{let n=em(`Primitive.${t}`),r=v.forwardRef((e,r)=>{let{asChild:i,...o}=e;return"undefined"!=typeof window&&(window[Symbol.for("radix-ui")]=!0),(0,w.jsx)(i?n:t,{...o,ref:r})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{}),eb=Symbol("radix.slottable");function ex(e){return v.isValidElement(e)&&"function"==typeof e.type&&"__radixId"in e.type&&e.type.__radixId===eb}var ew=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"].reduce((e,t)=>{var n,r;let i,o,a,s=(r=n=`Primitive.${t}`,(i=v.forwardRef((e,t)=>{let{children:n,...r}=e;if(v.isValidElement(n)){var i;let e,o,a=(i=n,(o=(e=Object.getOwnPropertyDescriptor(i.props,"ref")?.get)&&"isReactWarning"in e&&e.isReactWarning)?i.ref:(o=(e=Object.getOwnPropertyDescriptor(i,"ref")?.get)&&"isReactWarning"in e&&e.isReactWarning)?i.props.ref:i.props.ref||i.ref),s=function(e,t){let n={...t};for(let r in t){let i=e[r],o=t[r];/^on[A-Z]/.test(r)?i&&o?n[r]=(...e)=>{let t=o(...e);return i(...e),t}:i&&(n[r]=i):"style"===r?n[r]={...i,...o}:"className"===r&&(n[r]=[i,o].filter(Boolean).join(" "))}return{...e,...n}}(r,n.props);return n.type!==v.Fragment&&(s.ref=t?(0,q.composeRefs)(t,a):a),v.cloneElement(n,s)}return v.Children.count(n)>1?v.Children.only(null):null})).displayName=`${r}.SlotClone`,o=i,(a=v.forwardRef((e,t)=>{let{children:n,...r}=e,i=v.Children.toArray(n),a=i.find(ex);if(a){let e=a.props.children,n=i.map(t=>t!==a?t:v.Children.count(e)>1?v.Children.only(null):v.isValidElement(e)?e.props.children:null);return(0,w.jsx)(o,{...r,ref:t,children:v.isValidElement(e)?v.cloneElement(e,void 0,n):null})}return(0,w.jsx)(o,{...r,ref:t,children:n})})).displayName=`${n}.Slot`,a),l=v.forwardRef((e,n)=>{let{asChild:r,...i}=e;return"undefined"!=typeof window&&(window[Symbol.for("radix-ui")]=!0),(0,w.jsx)(r?s:t,{...i,ref:n})});return l.displayName=`Primitive.${t}`,{...e,[t]:l}},{}),eE=e.i(30207),eS="rovingFocusGroup.onEntryFocus",eC={bubbles:!1,cancelable:!0},eT="RovingFocusGroup",[eN,eA,e_]=er(eT),[eI,eR]=function(e,t=[]){let n=[],r=()=>{let t=n.map(e=>v.createContext(e));return function(n){let r=n?.[e]||t;return v.useMemo(()=>({[`__scope${e}`]:{...n,[e]:r}}),[n,r])}};return r.scopeName=e,[function(t,r){let i=v.createContext(r),o=n.length;n=[...n,r];let a=t=>{let{scope:n,children:r,...a}=t,s=n?.[e]?.[o]||i,l=v.useMemo(()=>a,Object.values(a));return(0,w.jsx)(s.Provider,{value:l,children:r})};return a.displayName=t+"Provider",[a,function(n,a){let s=a?.[e]?.[o]||i,l=v.useContext(s);if(l)return l;if(void 0!==r)return r;throw Error(`\`${n}\` must be used within \`${t}\``)}]},function(...e){let t=e[0];if(1===e.length)return t;let n=()=>{let n=e.map(e=>({useScope:e(),scopeName:e.scopeName}));return function(e){let r=n.reduce((t,{useScope:n,scopeName:r})=>{let i=n(e)[`__scope${r}`];return{...t,...i}},{});return v.useMemo(()=>({[`__scope${t.scopeName}`]:r}),[r])}};return n.scopeName=t.scopeName,n}(r,...t)]}(eT,[e_]),[eM,eO]=eI(eT),ej=v.forwardRef((e,t)=>
1(0,w.jsx)(eN.Provider,{scope:e.__scopeRovingFocusGroup,children:(0,w.jsx)(eN.Slot,{scope:e.__scopeRovingFocusGroup,children:(0,w.jsx)(ez,{...e,ref:t})})}));ej.displayName=eT;var ez=v.forwardRef((e,t)=>{let{__scopeRovingFocusGroup:n,orientation:r,loop:i=!1,dir:o,currentTabStopId:a,defaultCurrentTabStopId:s,onCurrentTabStopIdChange:l,onEntryFocus:c,preventScrollOnEntryFocus:u=!1,...d}=e,p=v.useRef(null),f=(0,q.useComposedRefs)(t,p),h=el(o),[g,m]=(0,J.useControllableState)({prop:a,defaultProp:s??null,onChange:l,caller:eT}),[y,k]=v.useState(!1),b=(0,eE.useCallbackRef)(c),x=eA(n),E=v.useRef(!1),[S,C]=v.useState(0);return v.useEffect(()=>{let e=p.current;if(e)return e.addEventListener(eS,b),()=>e.removeEventListener(eS,b)},[b]),(0,w.jsx)(eM,{scope:n,orientation:r,dir:h,loop:i,currentTabStopId:g,onItemFocus:v.useCallback(e=>m(e),[m]),onItemShiftTab:v.useCallback(()=>k(!0),[]),onFocusableItemAdd:v.useCallback(()=>C(e=>e+1),[]),onFocusableItemRemove:v.useCallback(()=>C(e=>e-1),[]),children:(0,w.jsx)(ew.div,{tabIndex:y||0===S?-1:0,"data-orientation":r,...d,ref:f,style:{outline:"none",...e.style},onMouseDown:(0,W.composeEventHandlers)(e.onMouseDown,()=>{E.current=!0}),onFocus:(0,W.composeEventHandlers)(e.onFocus,e=>{let t=!E.current;if(e.target===e.currentTarget&&t&&!y){let t=new CustomEvent(eS,eC);if(e.currentTarget.dispatchEvent(t),!t.defaultPrevented){let e=x().filter(e=>e.focusable);eL([e.find(e=>e.active),e.find(e=>e.id===g),...e].filter(Boolean).map(e=>e.ref.current),u)}}E.current=!1}),onBlur:(0,W.composeEventHandlers)(e.onBlur,()=>k(!1))})})}),eD="RovingFocusGroupItem",eP=v.forwardRef((e,t)=>{let{__scopeRovingFocusGroup:n,focusable:r=!0,active:i=!1,tabStopId:o,children:a,...s}=e,l=(0,ep.useId)(),c=o||l,u=eO(eD,n),d=u.currentTabStopId===c,p=eA(n),{onFocusableItemAdd:f,onFocusableItemRemove:h,currentTabStopId:g}=u;return v.useEffect(()=>{if(r)return f(),()=>h()},[r,f,h]),(0,w.jsx)(eN.ItemSlot,{scope:n,id:c,focusable:r,active:i,children:(0,w.jsx)(ew.span,{tabIndex:d?0:-1,"data-orientation":u.orientation,...s,ref:t,onMouseDown:(0,W.composeEventHandlers)(e.onMouseDown,e=>{r?u.onItemFocus(c):e.preventDefault()}),onFocus:(0,W.composeEventHandlers)(e.onFocus,()=>u.onItemFocus(c)),onKeyDown:(0,W.composeEventHandlers)(e.onKeyDown,e=>{if("Tab"===e.key&&e.shiftKey)return void u.onItemShiftTab();if(e.target!==e.currentTarget)return;let t=function(e,t,n){var r;let i=(r=e.key,"rtl"!==n?r:"ArrowLeft"===r?"ArrowRight":"ArrowRight"===r?"ArrowLeft":r);if(!("vertical"===t&&["ArrowLeft","ArrowRight"].includes(i))&&!("horizontal"===t&&["ArrowUp","ArrowDown"].includes(i)))return eF[i]}(e,u.orientation,u.dir);if(void 0!==t){if(e.metaKey||e.ctrlKey||e.altKey||e.shiftKey)return;e.preventDefault();let i=p().filter(e=>e.focusable).map(e=>e.ref.current);if("last"===t)i.reverse();else if("prev"===t||"next"===t){var n,r;"prev"===t&&i.reverse();let o=i.indexOf(e.currentTarget);i=u.loop?(n=i,r=o+1,n.map((e,t)=>n[(r+t)%n.length])):i.slice(o+1)}setTimeout(()=>eL(i))}}),children:"function"==typeof a?a({isCurrentTabStop:d,hasTabStop:null!=g}):a})})});eP.displayName=eD;var eF={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function eL(e,t=!1){let n=document.activeElement;for(let r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}e.s(["Item",()=>eP,"Root",()=>ej,"createRovingFocusGroupScope",()=>eR],842727);var eU=e.i(186312),eB=e.i(985369),e$=["Enter"," "],eH=["ArrowUp","PageDown","End"],eK=["ArrowDown","PageUp","Home",...eH],eG={ltr:[...e$,"ArrowRight"],rtl:[...e$,"ArrowLeft"]},eV={ltr:["ArrowLeft"],rtl:["ArrowRight"]},eW="Menu",[eq,eJ,eX]=er(eW),[eY,eQ]=function(e,t=[]){let n=[],r=()=>{let t=n.map(e=>v.createContext(e));return function(n){let r=n?.[e]||t;return v.useMemo(()=>({[`__scope${e}`]:{...n,[e]:r}}),[n,r])}};return r.scopeName=e,[function(t,r){let i=v.createContext(r),o=n.length;n=[...n,r];let a=t=>{let{scope:n,children:r,...a}=t,s=n?.[e]?.[o]||i,l=v.useMemo(()=>a,Object.values(a));return(0,w.jsx)(s.Provider,{value:l,children:r})};return a.displayName=t+"Provider",[a,function(n,a){let s=a?.[e]?.[o]||i,l=v.useContext(s);if(l)return l;if(void 0!==r)return r;throw Error(`\`${n}\` must be used within \`${t}\``)}]},function(...e){let t=e[0];if(1===e.length)return t;let n=()=>{let n=e.map(e=>({useScope:e(),scopeName:e.scopeName}));return function(e){let r=n.reduce((t,{useScope:n,scopeName:r})=>{let i=n(e)[`__scope${r}`];return{...t,...i}},{});return v.useMemo(()=>({[`__scope${t.scopeName}`]:r}),[r])}};return n.scopeName=t.scopeName,n}(r,...t)]}(eW,[eX,ef.createPopperScope,eR]),eZ=(0,ef.createPopperScope)(),e0=eR(),[e1,e2]=eY(eW),[e5,e4]=eY(eW),e3=e=>{let{__scopeMenu:t,open:n=!1,children:r,dir:i,onOpenChange:o,modal:a=!0}=e,s=eZ(t),[l,c]=v.useState(null),u=v.useRef(!1),d=(0,eE.useCallbackRef)(o),p=el(i);return v.useEffect(()=>{let e=()=>{u.current=!0,document.addEventListener("pointerdown",t,{capture:!0,once:!0}),document.addEventListener("pointermove",t,{capture:!0,once:!0})},t=()=>u.current=!1;return document.addEventListener("keydown",e,{capture:!0}),()=>{document.removeEventListener("keydown",e,{capture:!0}),document.removeEventListener("pointerdown",t,{capture:!0}),document.removeEventListener("pointermove",t,{capture:!0})}},[]),(0,w.jsx)(ef.Root,{...s,children:(0,w.jsx)(e1,{scope:t,open:n,onOpenChange:d,content:l,onContentChange:c,children:(0,w.jsx)(e5,{scope:t,onClose:v.useCallback(()=>d(!1),[d]),isUsingKeyboardRef:u,dir:p,modal:a,children:r})})})};e3.displayName=eW;var e6=v.forwardRef((e,t)=>
1{let{__scopeMenu:n,...r}=e,i=eZ(n);return(0,w.jsx)(ef.Anchor,{...i,...r,ref:t})});e6.displayName="MenuAnchor";var e8="MenuPortal",[e9,e7]=eY(e8,{forceMount:void 0}),te=e=>{let{__scopeMenu:t,forceMount:n,children:r,container:i}=e,o=e2(e8,t);return(0,w.jsx)(e9,{scope:t,forceMount:n,children:(0,w.jsx)(eg.Presence,{present:n||o.open,children:(0,w.jsx)(eh.Portal,{asChild:!0,container:i,children:r})})})};te.displayName=e8;var tt="MenuContent",[tn,tr]=eY(tt),ti=v.forwardRef((e,t)=>{let n=e7(tt,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,o=e2(tt,e.__scopeMenu),a=e4(tt,e.__scopeMenu);return(0,w.jsx)(eq.Provider,{scope:e.__scopeMenu,children:(0,w.jsx)(eg.Presence,{present:r||o.open,children:(0,w.jsx)(eq.Slot,{scope:e.__scopeMenu,children:a.modal?(0,w.jsx)(to,{...i,ref:t}):(0,w.jsx)(ta,{...i,ref:t})})})})}),to=v.forwardRef((e,t)=>{let n=e2(tt,e.__scopeMenu),r=v.useRef(null),i=(0,q.useComposedRefs)(t,r);return v.useEffect(()=>{let e=r.current;if(e)return(0,eU.hideOthers)(e)},[]),(0,w.jsx)(tl,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:(0,W.composeEventHandlers)(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),ta=v.forwardRef((e,t)=>{let n=e2(tt,e.__scopeMenu);return(0,w.jsx)(tl,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),ts=em("MenuContent.ScrollLock"),tl=v.forwardRef((e,t)=>{let{__scopeMenu:n,loop:r=!1,trapFocus:i,onOpenAutoFocus:o,onCloseAutoFocus:a,disableOutsidePointerEvents:s,onEntryFocus:l,onEscapeKeyDown:c,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:p,onDismiss:f,disableOutsideScroll:h,...g}=e,m=e2(tt,n),y=e4(tt,n),k=eZ(n),b=e0(n),x=eJ(n),[E,S]=v.useState(null),C=v.useRef(null),T=(0,q.useComposedRefs)(t,C,m.onContentChange),N=v.useRef(0),A=v.useRef(""),_=v.useRef(0),I=v.useRef(null),R=v.useRef("right"),M=v.useRef(0),O=h?eB.RemoveScroll:v.Fragment;v.useEffect(()=>()=>window.clearTimeout(N.current),[]),(0,eu.useFocusGuards)();let j=v.useCallback(e=>{var t,n;return R.current===I.current?.side&&(t=e,!!(n=I.current?.area)&&function(e,t){let{x:n,y:r}=e,i=!1;for(let e=0,o=t.length-1;e<t.length;o=e++){let a=t[e],s=t[o],l=a.x,c=a.y,u=s.x,d=s.y;c>r!=d>r&&n<(u-l)*(r-c)/(d-c)+l&&(i=!i)}return i}({x:t.clientX,y:t.clientY},n))},[]);return(0,w.jsx)(tn,{scope:n,searchRef:A,onItemEnter:v.useCallback(e=>{j(e)&&e.preventDefault()},[j]),onItemLeave:v.useCallback(e=>{j(e)||(C.current?.focus(),S(null))},[j]),onTriggerLeave:v.useCallback(e=>{j(e)&&e.preventDefault()},[j]),pointerGraceTimerRef:_,onPointerGraceIntentChange:v.useCallback(e=>{I.current=e},[]),children:(0,w.jsx)(O,{...h?{as:ts,allowPinchZoom:!0}:void 0,children:(0,w.jsx)(ed.FocusScope,{asChild:!0,trapped:i,onMountAutoFocus:(0,W.composeEventHandlers)(o,e=>{e.preventDefault(),C.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:a,children:(0,w.jsx)(ec.DismissableLayer,{asChild:!0,disableOutsidePointerEvents:s,onEscapeKeyDown:c,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:p,onDismiss:f,children:(0,w.jsx)(ej,{asChild:!0,...b,dir:y.dir,orientation:"vertical",loop:r,currentTabStopId:E,onCurrentTabStopIdChange:S,onEntryFocus:(0,W.composeEventHandlers)(l,e=>{y.isUsingKeyboardRef.current||e.preventDefault()}),preventScrollOnEntryFocus:!0,children:(0,w.jsx)(ef.Content,{role:"menu","aria-orientation":"vertical","data-state":tD(m.open),"data-radix-menu-content":"",dir:y.dir,...k,...g,ref:T,style:{outline:"none",...g.style},onKeyDown:(0,W.composeEventHandlers)(g.onKeyDown,e=>{let t=e.target.closest("[data-radix-menu-content]")===e.currentTarget,n=e.ctrlKey||e.altKey||e.metaKey,r=1===e.key.length;if(t){var i;let t,o,a,s,l,c;"Tab"===e.key&&e.preventDefault(),!n&&r&&(i=e.key,t=A.current+i,o=x().filter(e=>!e.disabled),a=document.activeElement,s=o.find(e=>e.ref.current===a)?.textValue,l=function(e,t,n){var r;let i=t.length>1&&Array.from(t).every(e=>e===t[0])?t[0]:t,o=n?e.indexOf(n):-1,a=(r=Math.max(o,0),e.map((t,n)=>e[(r+n)%e.length]));1===i.length&&(a=a.filter(e=>e!==n));let s=a.find(e=>e.toLowerCase().startsWith(i.toLowerCase()));return s!==n?s:void 0}(o.map(e=>e.textValue),t,s),c=o.find(e=>e.textValue===l)?.ref.current,function e(t){A.current=t,window.clearTimeout(N.current),""!==t&&(N.current=window.setTimeout(()=>e(""),1e3))}(t),c&&setTimeout(()=>c.focus()))}let o=C.current;
1if(e.target!==o||!eK.includes(e.key))return;e.preventDefault();let a=x().filter(e=>!e.disabled).map(e=>e.ref.current);eH.includes(e.key)&&a.reverse(),function(e){let t=document.activeElement;for(let n of e)if(n===t||(n.focus(),document.activeElement!==t))return}(a)}),onBlur:(0,W.composeEventHandlers)(e.onBlur,e=>{e.currentTarget.contains(e.target)||(window.clearTimeout(N.current),A.current="")}),onPointerMove:(0,W.composeEventHandlers)(e.onPointerMove,tL(e=>{let t=e.target,n=M.current!==e.clientX;e.currentTarget.contains(t)&&n&&(R.current=e.clientX>M.current?"right":"left",M.current=e.clientX)}))})})})})})})});ti.displayName=tt;var tc=v.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e;return(0,w.jsx)(ev.div,{role:"group",...r,ref:t})});tc.displayName="MenuGroup";var tu=v.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e;return(0,w.jsx)(ev.div,{...r,ref:t})});tu.displayName="MenuLabel";var td="MenuItem",tp="menu.itemSelect",tf=v.forwardRef((e,t)=>{let{disabled:n=!1,onSelect:r,...i}=e,o=v.useRef(null),a=e4(td,e.__scopeMenu),s=tr(td,e.__scopeMenu),l=(0,q.useComposedRefs)(t,o),c=v.useRef(!1);return(0,w.jsx)(th,{...i,ref:l,disabled:n,onClick:(0,W.composeEventHandlers)(e.onClick,()=>{let e=o.current;if(!n&&e){let t=new CustomEvent(tp,{bubbles:!0,cancelable:!0});e.addEventListener(tp,e=>r?.(e),{once:!0}),e&&X.flushSync(()=>e.dispatchEvent(t)),t.defaultPrevented?c.current=!1:a.onClose()}}),onPointerDown:t=>{e.onPointerDown?.(t),c.current=!0},onPointerUp:(0,W.composeEventHandlers)(e.onPointerUp,e=>{c.current||e.currentTarget?.click()}),onKeyDown:(0,W.composeEventHandlers)(e.onKeyDown,e=>{let t=""!==s.searchRef.current;n||t&&" "===e.key||e$.includes(e.key)&&(e.currentTarget.click(),e.preventDefault())})})});tf.displayName=td;var th=v.forwardRef((e,t)=>{let{__scopeMenu:n,disabled:r=!1,textValue:i,...o}=e,a=tr(td,n),s=e0(n),l=v.useRef(null),c=(0,q.useComposedRefs)(t,l),[u,d]=v.useState(!1),[p,f]=v.useState("");return v.useEffect(()=>{let e=l.current;e&&f((e.textContent??"").trim())},[o.children]),(0,w.jsx)(eq.ItemSlot,{scope:n,disabled:r,textValue:i??p,children:(0,w.jsx)(eP,{asChild:!0,...s,focusable:!r,children:(0,w.jsx)(ev.div,{role:"menuitem","data-highlighted":u?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...o,ref:c,onPointerMove:(0,W.composeEventHandlers)(e.onPointerMove,tL(e=>{r?a.onItemLeave(e):(a.onItemEnter(e),e.defaultPrevented||e.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:(0,W.composeEventHandlers)(e.onPointerLeave,tL(e=>a.onItemLeave(e))),onFocus:(0,W.composeEventHandlers)(e.onFocus,()=>d(!0)),onBlur:(0,W.composeEventHandlers)(e.onBlur,()=>d(!1))})})})}),tg=v.forwardRef((e,t)=>{let{checked:n=!1,onCheckedChange:r,...i}=e;return(0,w.jsx)(tE,{scope:e.__scopeMenu,checked:n,children:(0,w.jsx)(tf,{role:"menuitemcheckbox","aria-checked":tP(n)?"mixed":n,...i,ref:t,"data-state":tF(n),onSelect:(0,W.composeEventHandlers)(i.onSelect,()=>r?.(!!tP(n)||!n),{checkForDefaultPrevented:!1})})})});tg.displayName="MenuCheckboxItem";var tm="MenuRadioGroup",[ty,tk]=eY(tm,{value:void 0,onValueChange:()=>{}}),tv=v.forwardRef((e,t)=>{let{value:n,onValueChange:r,...i}=e,o=(0,eE.useCallbackRef)(r);return(0,w.jsx)(ty,{scope:e.__scopeMenu,value:n,onValueChange:o,children:(0,w.jsx)(tc,{...i,ref:t})})});tv.displayName=tm;var tb="MenuRadioItem",tx=v.forwardRef((e,t)=>{let{value:n,...r}=e,i=tk(tb,e.__scopeMenu),o=n===i.value;return(0,w.jsx)(tE,{scope:e.__scopeMenu,checked:o,children:(0,w.jsx)(tf,{role:"menuitemradio","aria-checked":o,...r,ref:t,"data-state":tF(o),onSelect:(0,W.composeEventHandlers)(r.onSelect,()=>i.onValueChange?.(n),{checkForDefaultPrevented:!1})})})});tx.displayName=tb;var tw="MenuItemIndicator",[tE,tS]=eY(tw,{checked:!1}),tC=v.forwardRef((e,t)=>{let{__scopeMenu:n,forceMount:r,...i}=e,o=tS(tw,n);return(0,w.jsx)(eg.Presence,{present:r||tP(o.checked)||!0===o.checked,children:(0,w.jsx)(ev.span,{...i,ref:t,"data-state":tF(o.checked)})})});tC.displayName=tw;var tT=v.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e;return(0,w.jsx)(ev.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});tT.displayName="MenuSeparator";var tN=v.forwardRef((e,t)=>
1{let{__scopeMenu:n,...r}=e,i=eZ(n);return(0,w.jsx)(ef.Arrow,{...i,...r,ref:t})});tN.displayName="MenuArrow";var tA="MenuSub",[t_,tI]=eY(tA),tR=e=>{let{__scopeMenu:t,children:n,open:r=!1,onOpenChange:i}=e,o=e2(tA,t),a=eZ(t),[s,l]=v.useState(null),[c,u]=v.useState(null),d=(0,eE.useCallbackRef)(i);return v.useEffect(()=>(!1===o.open&&d(!1),()=>d(!1)),[o.open,d]),(0,w.jsx)(ef.Root,{...a,children:(0,w.jsx)(e1,{scope:t,open:r,onOpenChange:d,content:c,onContentChange:u,children:(0,w.jsx)(t_,{scope:t,contentId:(0,ep.useId)(),triggerId:(0,ep.useId)(),trigger:s,onTriggerChange:l,children:n})})})};tR.displayName=tA;var tM="MenuSubTrigger",tO=v.forwardRef((e,t)=>{let n=e2(tM,e.__scopeMenu),r=e4(tM,e.__scopeMenu),i=tI(tM,e.__scopeMenu),o=tr(tM,e.__scopeMenu),a=v.useRef(null),{pointerGraceTimerRef:s,onPointerGraceIntentChange:l}=o,c={__scopeMenu:e.__scopeMenu},u=v.useCallback(()=>{a.current&&window.clearTimeout(a.current),a.current=null},[]);return v.useEffect(()=>u,[u]),v.useEffect(()=>{let e=s.current;return()=>{window.clearTimeout(e),l(null)}},[s,l]),(0,w.jsx)(e6,{asChild:!0,...c,children:(0,w.jsx)(th,{id:i.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":i.contentId,"data-state":tD(n.open),...e,ref:(0,q.composeRefs)(t,i.onTriggerChange),onClick:t=>{e.onClick?.(t),e.disabled||t.defaultPrevented||(t.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:(0,W.composeEventHandlers)(e.onPointerMove,tL(t=>{o.onItemEnter(t),!t.defaultPrevented&&(e.disabled||n.open||a.current||(o.onPointerGraceIntentChange(null),a.current=window.setTimeout(()=>{n.onOpenChange(!0),u()},100)))})),onPointerLeave:(0,W.composeEventHandlers)(e.onPointerLeave,tL(e=>{u();let t=n.content?.getBoundingClientRect();if(t){let r=n.content?.dataset.side,i="right"===r,a=t[i?"left":"right"],l=t[i?"right":"left"];o.onPointerGraceIntentChange({area:[{x:e.clientX+(i?-5:5),y:e.clientY},{x:a,y:t.top},{x:l,y:t.top},{x:l,y:t.bottom},{x:a,y:t.bottom}],side:r}),window.clearTimeout(s.current),s.current=window.setTimeout(()=>o.onPointerGraceIntentChange(null),300)}else{if(o.onTriggerLeave(e),e.defaultPrevented)return;o.onPointerGraceIntentChange(null)}})),onKeyDown:(0,W.composeEventHandlers)(e.onKeyDown,t=>{let i=""!==o.searchRef.current;e.disabled||i&&" "===t.key||eG[r.dir].includes(t.key)&&(n.onOpenChange(!0),n.content?.focus(),t.preventDefault())})})})});tO.displayName=tM;var tj="MenuSubContent",tz=v.forwardRef((e,t)=>{let n=e7(tt,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,o=e2(tt,e.__scopeMenu),a=e4(tt,e.__scopeMenu),s=tI(tj,e.__scopeMenu),l=v.useRef(null),c=(0,q.useComposedRefs)(t,l);return(0,w.jsx)(eq.Provider,{scope:e.__scopeMenu,children:(0,w.jsx)(eg.Presence,{present:r||o.open,children:(0,w.jsx)(eq.Slot,{scope:e.__scopeMenu,children:(0,w.jsx)(tl,{id:s.contentId,"aria-labelledby":s.triggerId,...i,ref:c,align:"start",side:"rtl"===a.dir?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:e=>{a.isUsingKeyboardRef.current&&l.current?.focus(),e.preventDefault()},onCloseAutoFocus:e=>e.preventDefault(),onFocusOutside:(0,W.composeEventHandlers)(e.onFocusOutside,e=>{e.target!==s.trigger&&o.onOpenChange(!1)}),onEscapeKeyDown:(0,W.composeEventHandlers)(e.onEscapeKeyDown,e=>{a.onClose(),e.preventDefault()}),onKeyDown:(0,W.composeEventHandlers)(e.onKeyDown,e=>{let t=e.currentTarget.contains(e.target),n=eV[a.dir].includes(e.key);t&&n&&(o.onOpenChange(!1),s.trigger?.focus(),e.preventDefault())})})})})})});function tD(e){return e?"open":"closed"}function tP(e){return"indeterminate"===e}function tF(e){return tP(e)?"indeterminate":e?"checked":"unchecked"}function tL(e){return t=>"mouse"===t.pointerType?e(t):void 0}tz.displayName=tj;var tU="DropdownMenu",[tB,t$]=function(e,t=[]){let n=[],r=()=>{let t=n.map(e=>v.createContext(e));return function(n){let r=n?.[e]||t;return v.useMemo(()=>({[`__scope${e}`]:{...n,[e]:r}}),[n,r])}};return r.scopeName=e,[function(t,r){let i=v.createContext(r),o=n.length;n=[...n,r];let a=t=>{let{scope:n,children:r,...a}=t,s=n?.[e]?.[o]||i,l=v.useMemo(()=>a,Object.values(a));return(0,w.jsx)(s.Provider,{value:l,children:r})};return a.displayName=t+"Provider",[a,function(n,a){let s=a?.[e]?.[o]||i,l=v.useContext(s);if(l)return l;if(void 0!==r)return r;throw Error(`\`${n}\` must be used within \`${t}\``)}]},function(...e){let t=e[0];if(1===e.length)return t;let n=()=>{let n=e.map(e=>({useScope:e(),scopeName:e.scopeName}));return function(e){let r=n.reduce((t,{useScope:n,scopeName:r})=>{let i=n(e)[`__scope${r}`];return{...t,...i}},{});return v.useMemo(()=>({[`__scope${t.scopeName}`]:r}),[r])}};return n.scopeName=t.scopeName,n}(r,...t)]}(tU,[eQ]),tH=eQ(),[tK,tG]=tB(tU),tV=e=>{let{__scopeDropdownMenu:t,children:n,dir:r,open:i,defaultOpen:o,onOpenChange:a,modal:s=!0}=e,l=tH(t),c=v.useRef(null),[u,d]=(0,J.useControllableState)({prop:i,defaultProp:o??!1,onChange:a,caller:tU});return(0,w.jsx)(tK,{scope:t,triggerId:(0,ep.useId)(),triggerRef:c,contentId:(0,ep.useId)(),open:u,onOpenChange:d,onOpenToggle:v.useCallback(()=>d(e=>!e),[d]),modal:s,children:(0,w.jsx)(e3,{...l,open:u,onOpenChange:d,dir:r,modal:s,children:n})})};tV.displayName=tU;var tW="DropdownMenuTrigger",tq=v.forwardRef((e,t)=>
1{let{__scopeDropdownMenu:n,disabled:r=!1,...i}=e,o=tG(tW,n),a=tH(n);return(0,w.jsx)(e6,{asChild:!0,...a,children:(0,w.jsx)(Z.button,{type:"button",id:o.triggerId,"aria-haspopup":"menu","aria-expanded":o.open,"aria-controls":o.open?o.contentId:void 0,"data-state":o.open?"open":"closed","data-disabled":r?"":void 0,disabled:r,...i,ref:(0,q.composeRefs)(t,o.triggerRef),onPointerDown:(0,W.composeEventHandlers)(e.onPointerDown,e=>{!r&&0===e.button&&!1===e.ctrlKey&&(o.onOpenToggle(),o.open||e.preventDefault())}),onKeyDown:(0,W.composeEventHandlers)(e.onKeyDown,e=>{!r&&(["Enter"," "].includes(e.key)&&o.onOpenToggle(),"ArrowDown"===e.key&&o.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(e.key)&&e.preventDefault())})})})});tq.displayName=tW;var tJ=e=>{let{__scopeDropdownMenu:t,...n}=e,r=tH(t);return(0,w.jsx)(te,{...r,...n})};tJ.displayName="DropdownMenuPortal";var tX="DropdownMenuContent",tY=v.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=tG(tX,n),o=tH(n),a=v.useRef(!1);return(0,w.jsx)(ti,{id:i.contentId,"aria-labelledby":i.triggerId,...o,...r,ref:t,onCloseAutoFocus:(0,W.composeEventHandlers)(e.onCloseAutoFocus,e=>{a.current||i.triggerRef.current?.focus(),a.current=!1,e.preventDefault()}),onInteractOutside:(0,W.composeEventHandlers)(e.onInteractOutside,e=>{let t=e.detail.originalEvent,n=0===t.button&&!0===t.ctrlKey,r=2===t.button||n;(!i.modal||r)&&(a.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});tY.displayName=tX,v.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=tH(n);return(0,w.jsx)(tc,{...i,...r,ref:t})}).displayName="DropdownMenuGroup",v.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=tH(n);return(0,w.jsx)(tu,{...i,...r,ref:t})}).displayName="DropdownMenuLabel";var tQ=v.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=tH(n);return(0,w.jsx)(tf,{...i,...r,ref:t})});tQ.displayName="DropdownMenuItem",v.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=tH(n);return(0,w.jsx)(tg,{...i,...r,ref:t})}).displayName="DropdownMenuCheckboxItem",v.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=tH(n);return(0,w.jsx)(tv,{...i,...r,ref:t})}).displayName="DropdownMenuRadioGroup",v.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=tH(n);return(0,w.jsx)(tx,{...i,...r,ref:t})}).displayName="DropdownMenuRadioItem",v.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=tH(n);return(0,w.jsx)(tC,{...i,...r,ref:t})}).displayName="DropdownMenuItemIndicator";var tZ=v.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=tH(n);return(0,w.jsx)(tT,{...i,...r,ref:t})});tZ.displayName="DropdownMenuSeparator",v.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=tH(n);return(0,w.jsx)(tN,{...i,...r,ref:t})}).displayName="DropdownMenuArrow";var t0=v.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=tH(n);return(0,w.jsx)(tO,{...i,...r,ref:t})});t0.displayName="DropdownMenuSubTrigger";var t1=v.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=tH(n);return(0,w.jsx)(tz,{...i,...r,ref:t,style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});t1.displayName="DropdownMenuSubContent";var t2=e=>{let{__scopeDropdownMenu:t,children:n,open:r,onOpenChange:i,defaultOpen:o}=e,a=tH(t),[s,l]=(0,J.useControllableState)({prop:r,defaultProp:o??!1,onChange:i,caller:"DropdownMenuSub"});return(0,w.jsx)(tR,{...a,open:s,onOpenChange:l,children:n})};function t5({...e}){return(0,w.jsx)(tV,{"data-slot":"dropdown-menu",...e})}function t4({...e}){return(0,w.jsx)(tq,{"data-slot":"dropdown-menu-trigger",...e})}function t3({className:e,sideOffset:t=4,...n}){return(0,w.jsx)(tJ,{children:(0,w.jsx)(tY,{"data-copilotkit":!0,"data-slot":"dropdown-menu-content",sideOffset:t,className:M("cpk:bg-popover cpk:text-popover-foreground cpk:data-[state=open]:animate-in cpk:data-[state=closed]:animate-out cpk:data-[state=closed]:fade-out-0 cpk:data-[state=open]:fade-in-0 cpk:data-[state=closed]:zoom-out-95 cpk:data-[state=open]:zoom-in-95 cpk:data-[side=bottom]:slide-in-from-top-2 cpk:data-[side=left]:slide-in-from-right-2 cpk:data-[side=right]:sli
1de-in-from-left-2 cpk:data-[side=top]:slide-in-from-bottom-2 cpk:z-50 cpk:max-h-(--radix-dropdown-menu-content-available-height) cpk:min-w-[8rem] cpk:origin-(--radix-dropdown-menu-content-transform-origin) cpk:overflow-x-hidden cpk:overflow-y-auto cpk:rounded-md cpk:border cpk:p-1 cpk:shadow-md",e),...n})})}function t6({className:e,inset:t,variant:n="default",...r}){return(0,w.jsx)(tQ,{"data-slot":"dropdown-menu-item","data-inset":t,"data-variant":n,className:M("cpk:focus:bg-accent cpk:focus:text-accent-foreground cpk:data-[variant=destructive]:text-destructive cpk:data-[variant=destructive]:focus:bg-destructive/10 cpk:dark:data-[variant=destructive]:focus:bg-destructive/20 cpk:data-[variant=destructive]:focus:text-destructive cpk:data-[variant=destructive]:*:[svg]:!text-destructive cpk:[&_svg:not([class*='text-'])]:text-muted-foreground cpk:relative cpk:flex cpk:cursor-default cpk:items-center cpk:gap-2 cpk:rounded-sm cpk:px-2 cpk:py-1.5 cpk:text-sm cpk:outline-hidden cpk:select-none cpk:data-[disabled]:pointer-events-none cpk:data-[disabled]:opacity-50 cpk:data-[inset]:pl-8 cpk:[&_svg]:pointer-events-none cpk:[&_svg]:shrink-0 cpk:[&_svg:not([class*='size-'])]:size-4",e),...r})}function t8({className:e,...t}){return(0,w.jsx)(tZ,{"data-slot":"dropdown-menu-separator",className:M("cpk:bg-border cpk:-mx-1 cpk:my-1 cpk:h-px",e),...t})}function t9({...e}){return(0,w.jsx)(t2,{"data-slot":"dropdown-menu-sub",...e})}function t7({className:e,inset:t,children:n,...r}){return(0,w.jsxs)(t0,{"data-slot":"dropdown-menu-sub-trigger","data-inset":t,className:M("cpk:focus:bg-accent cpk:focus:text-accent-foreground cpk:data-[state=open]:bg-accent cpk:data-[state=open]:text-accent-foreground cpk:flex cpk:cursor-default cpk:items-center cpk:rounded-sm cpk:px-2 cpk:py-1.5 cpk:text-sm cpk:outline-hidden cpk:select-none cpk:data-[inset]:pl-8",e),...r,children:[n,(0,w.jsx)(V,{className:"cpk:ml-auto cpk:size-4"})]})}function ne({className:e,...t}){return(0,w.jsx)(t1,{"data-slot":"dropdown-menu-sub-content",className:M("cpk:bg-popover cpk:text-popover-foreground cpk:data-[state=open]:animate-in cpk:data-[state=closed]:animate-out cpk:data-[state=closed]:fade-out-0 cpk:data-[state=open]:fade-in-0 cpk:data-[state=closed]:zoom-out-95 cpk:data-[state=open]:zoom-in-95 cpk:data-[side=bottom]:slide-in-from-top-2 cpk:data-[side=left]:slide-in-from-right-2 cpk:data-[side=right]:slide-in-from-left-2 cpk:data-[side=top]:slide-in-from-bottom-2 cpk:z-50 cpk:min-w-[8rem] cpk:origin-(--radix-dropdown-menu-content-transform-origin) cpk:overflow-hidden cpk:rounded-md cpk:border cpk:p-1 cpk:shadow-lg",e),...t})}function nt(e){return!("function"!=typeof e&&(!e||"object"!=typeof e||!("$$typeof"in e)||v.default.isValidElement(e)))}let nn=v.default.memo(v.default.forwardRef(function(e,t){let{$slot:n,$component:r,...i}=e;var o=null!==t?{...i,ref:t}:i;if("string"==typeof n){let e=o.className;return v.default.createElement(r,{...o,className:(0,N.twMerge)(e,n)})}return nt(n)?v.default.createElement(n,o):n&&"object"==typeof n&&!v.default.isValidElement(n)?v.default.createElement(r,{...o,...n}):v.default.createElement(r,o)}),(e,t)=>{if(e.$slot!==t.$slot||e.$component!==t.$component)return!1;let{$slot:n,$component:r,...i}=e,{$slot:o,$component:a,...s}=t,l=Object.keys(i),c=Object.keys(s);if(l.length!==c.length)return!1;for(let e of l)if(i[e]!==s[e])return!1;return!0});function nr(e,t,n){return v.default.createElement(nn,{...n,$slot:e,$component:t})}let ni=G("arrow-up",[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]]),no=G("check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]),na=G("loader-circle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]),ns=G("mic",[["path",{d:"M12 19v3",key:"npa21l"}],["path",{d:"M19 10v2a7 7 0 0 1-14 0v-2",key:"1vc78b"}],["rect",{x:"9",y:"2",width:"6",height:"13",rx:"3",key:"s6n7sd"}]]),nl=G("plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]),nc=G("square",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]),nu=G("x",[["path",{d:"M18 6 6 18",key:"1bl5f8"}
1],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);function nd({mode:e="input",onSubmitMessage:t,onStop:n,isRunning:r=!1,onStartTranscribe:i,onCancelTranscribe:o,onFinishTranscribe:a,onFinishTranscribeWithAudio:s,onAddFile:l,onChange:c,value:u,toolsMenu:d,autoFocus:p=!0,positioning:f="static",keyboardHeight:h=0,containerRef:g,showDisclaimer:m,textArea:y,sendButton:k,startTranscribeButton:b,cancelTranscribeButton:x,finishTranscribeButton:S,addMenuButton:C,audioRecorder:A,disclaimer:I,children:R,className:O,...j}){let z=void 0!==u,[D,P]=(0,v.useState)(()=>u??"");(0,v.useEffect)(()=>{z||void 0===u||P(u)},[z,u]);let F=z?u??"":D,[L,U]=(0,v.useState)("compact"),B=(0,v.useRef)(!1),$=(0,v.useRef)(null),H="input"===e&&"expanded"===L,[K,G]=(0,v.useState)(null),[V,W]=(0,v.useState)(0),q=(0,v.useRef)(null),J=(0,v.useRef)(null),X=(0,v.useRef)(null),Y=(0,v.useRef)(null),Q=(0,v.useRef)(null),Z=(0,v.useRef)(null),ee=T(),et=ee?.labels??E,en=(0,v.useRef)(void 0),er=(0,v.useRef)(null),ei=(0,v.useRef)({singleLineHeight:0,maxHeight:0,paddingLeft:0,paddingRight:0}),eo=(0,v.useMemo)(()=>{let e=[],t=new Set,n=r=>{if("-"!==r){if(r.items&&r.items.length>0){for(let e of r.items)n(e);return}t.has(r.label)||(t.add(r.label),e.push(r))}};if(l&&n({label:et.chatInputToolbarAddButtonLabel,action:l}),d&&d.length>0)for(let e of d)n(e);return e},[et.chatInputToolbarAddButtonLabel,l,d]),ea=(0,v.useMemo)(()=>{if(null===K||0===eo.length)return[];let e=K.trim().toLowerCase();if(0===e.length)return eo;let t=[],n=[];for(let r of eo){let i=r.label.toLowerCase();i.startsWith(e)?t.push(r):i.includes(e)&&n.push(r)}return[...t,...n]},[eo,K]);(0,v.useEffect)(()=>{if(!p){en.current=ee?.isModalOpen;return}ee?.isModalOpen&&!en.current&&q.current?.focus(),en.current=ee?.isModalOpen},[ee?.isModalOpen,p]),(0,v.useEffect)(()=>{0===eo.length&&null!==K&&G(null)},[eo.length,K]);let es=(0,v.useRef)(null);(0,v.useEffect)(()=>{null!==K&&K!==es.current&&ea.length>0&&W(0),es.current=K},[K,ea.length]),(0,v.useEffect)(()=>{null===K?W(0):0===ea.length?W(-1):(V<0||V>=ea.length)&&W(0)},[K,ea,V]),(0,v.useEffect)(()=>{let t=Q.current;t&&("transcribe"===e?t.start().catch(console.error):"recording"===t.state&&t.stop().catch(console.error))},[e]),(0,v.useEffect)(()=>{"input"!==e&&(U("compact"),G(null))},[e]);let el=(0,v.useCallback)(e=>{if(0===eo.length)return void G(e=>null===e?e:null);if(e.startsWith("/")){let t=(e.split(/\r?\n/,1)[0]??"").slice(1);G(e=>e===t?e:t)}else G(e=>null===e?e:null)},[eo.length]);(0,v.useEffect)(()=>{el(F)},[F,el]);let ec=(0,v.useCallback)(()=>{z||P(""),c&&c("")},[z,c]),eu=(0,v.useCallback)(e=>{ec(),e.action?.(),G(null),W(0),requestAnimationFrame(()=>{q.current?.focus()})},[ec]),ed=()=>{if(!t)return;let e=F.trim();e&&(t(e),z||(P(""),c?.("")),q.current&&q.current.focus())},ep=nr(y,nd.TextArea,{ref:q,value:F,onChange:e=>{let t=e.target.value;z||P(t),c?.(t),el(t)},onKeyDown:t=>{if(null!==K&&"input"===e){if("ArrowDown"===t.key){ea.length>0&&(t.preventDefault(),W(e=>0===ea.length?e:-1===e?0:(e+1)%ea.length));return}if("ArrowUp"===t.key){ea.length>0&&(t.preventDefault(),W(e=>0===ea.length?e:-1===e||e<=0?ea.length-1:e-1));return}if("Enter"===t.key){let e=V>=0?ea[V]:void 0;if(e){t.preventDefault(),eu(e);return}}if("Escape"===t.key){t.preventDefault(),G(null);return}}"Enter"!==t.key||t.shiftKey||(t.preventDefault(),ef?n?.():ed())},autoFocus:p,className:(0,N.twMerge)("cpk:w-full cpk:py-3",H?"cpk:px-5":"cpk:pr-5")}),ef="transcribe"!==e&&r,eh=F.trim().length>0&&!!t,eg=!!n,em=nr(A,_,{ref:Q}),ey=nr(k,nd.SendButton,{onClick:()=>{ef?n?.():ed()},disabled:ef?!eg:!eh,children:ef&&eg?(0,w.jsx)(nc,{className:"cpk:size-[18px] cpk:fill-current"}):void 0}),ek=nr(b,nd.StartTranscribeButton,{onClick:i}),ev=nr(x,nd.CancelTranscribeButton,{onClick:o}),eb=(0,v.useCallback)(async()=>{let e=Q.current;if(e&&"recording"===e.state)try{let t=await e.stop();s&&await s(t)}catch(e){console.error("Failed to stop recording:",e)}a?.()},[a,s]),ex=nr(S,nd.FinishTranscribeButton,{onClick:eb}),ew=nr(C,nd.AddMenuButton,{disabled:"transcribe"===e,onAddFile:l,toolsMenu:d}),eE=nr(I,nd.Disclaimer,{}),eS=m??"absolute"===f;if(R)return(0,w.jsx)("div",{"data-copilotkit":!0,style:{display:"contents"},children:R({textArea:ep,audioRecorder:em,sendButton:ey,startTranscribeButton:ek,cancelTranscribeButton:ev,finishTranscribeButton:ex,addMenuButton:ew,disclaimer:eE,onSubmitMessage:t,onStop:n,isRunning:r,onStartTranscribe:i,onCancelTranscribe:o,onFinishTranscribe:a,onAddFile:l,mode:e,toolsMenu:d,autoFocus:p,positioning:f,keyboardHeight:h,showDisclaimer:eS})});let eC=(0,v.useCallback)(()=>{let e=q.current;if(!e)return;let t=e.value,n=e.style.height;e.style.height="auto";let r=window.getComputedStyle(e),i=parseFloat(r.paddingLeft)||0,o=parseFloat(r.paddingRight)||0,a=parseFloat(r.paddingTop)||0,s=parseFloat(r.paddingBottom)||
10;e.value="";let l=e.scrollHeight;e.value=t;let c=(l-a-s)*5+a+s;ei.current={singleLineHeight:l,maxHeight:c,paddingLeft:i,paddingRight:o},e.style.height=n,e.style.maxHeight=`${c}px`},[]),eT=(0,v.useCallback)(()=>{let e=q.current;if(!e)return 0;0===ei.current.singleLineHeight&&eC();let{maxHeight:t}=ei.current;t&&(e.style.maxHeight=`${t}px`),e.style.height="auto";let n=e.scrollHeight;return t?e.style.height=`${Math.min(n,t)}px`:e.style.height=`${n}px`,n},[eC]),eN=(0,v.useCallback)(e=>{U(t=>t===e?t:(B.current=!0,e))},[]),eA=(0,v.useCallback)(()=>{if("input"!==e)return void eN("compact");if("undefined"!=typeof window&&"function"==typeof window.matchMedia&&window.matchMedia("(max-width: 767px)").matches){eC(),eT(),eN("expanded");return}let t=q.current,n=J.current,r=X.current,i=Y.current;if(!t||!n||!r||!i)return;0===ei.current.singleLineHeight&&eC();let o=eT(),a=ei.current.singleLineHeight,s=F.includes("\n")||a>0&&o>a+1;if(!s){let e=window.getComputedStyle(n),o=parseFloat(e.paddingLeft)||0,a=parseFloat(e.paddingRight)||0,l=parseFloat(e.columnGap)||0,c=n.clientWidth-o-a;if(c>0){let e=Math.max(c-r.getBoundingClientRect().width-i.getBoundingClientRect().width-2*l,0),n=er.current??document.createElement("canvas");er.current||(er.current=n);let o=n.getContext("2d");if(o){let n=window.getComputedStyle(t);o.font=n.font||`${n.fontStyle} ${n.fontVariant} ${n.fontWeight} ${n.fontSize}/${n.lineHeight} ${n.fontFamily}`;let r=Math.max(e-(ei.current.paddingLeft||0)-(ei.current.paddingRight||0),0);if(r>0){let e=F.length>0?F.split("\n"):[""],t=0;for(let n of e){let e=o.measureText(n||" ");e.width>t&&(t=e.width)}t>r&&(s=!0)}}}}eN(s?"expanded":"compact")},[eT,eC,e,F,eN]);(0,v.useLayoutEffect)(()=>{eA()},[eA]),(0,v.useEffect)(()=>{if("undefined"==typeof ResizeObserver)return;let e=q.current,t=J.current,n=X.current,r=Y.current;if(!e||!t||!n||!r)return;let i=new ResizeObserver(()=>{(()=>{if(B.current){B.current=!1;return}"undefined"==typeof window?eA():(null!==$.current&&cancelAnimationFrame($.current),$.current=window.requestAnimationFrame(()=>{$.current=null,eA()}))})()});return i.observe(t),i.observe(n),i.observe(r),i.observe(e),()=>{i.disconnect(),"undefined"!=typeof window&&null!==$.current&&(cancelAnimationFrame($.current),$.current=null)}},[eA]);let e_=null!==K&&eo.length>0;(0,v.useEffect)(()=>{e_&&!(V<0)&&Z.current?.querySelector(`[data-slash-index="${V}"]`)?.scrollIntoView({block:"nearest"})},[e_,V]);let eI=e_?(0,w.jsx)("div",{"data-testid":"copilot-slash-menu",role:"listbox","aria-label":"Slash commands",ref:Z,className:"cpk:absolute cpk:bottom-full cpk:left-0 cpk:right-0 cpk:z-30 cpk:mb-2 cpk:max-h-64 cpk:overflow-y-auto cpk:rounded-lg cpk:border cpk:border-border cpk:bg-white cpk:shadow-lg cpk:dark:border-[#3a3a3a] cpk:dark:bg-[#1f1f1f]",style:{maxHeight:"200px"},children:0===ea.length?(0,w.jsx)("div",{className:"cpk:px-3 cpk:py-2 cpk:text-sm cpk:text-muted-foreground",children:"No commands found"}):ea.map((e,t)=>{let n=t===V;return(0,w.jsx)("button",{type:"button",role:"option","aria-selected":n,"data-active":n?"true":void 0,"data-slash-index":t,className:(0,N.twMerge)("cpk:w-full cpk:px-3 cpk:py-2 cpk:text-left cpk:text-sm cpk:transition-colors","cpk:hover:bg-muted cpk:dark:hover:bg-[#2f2f2f]",n?"cpk:bg-muted cpk:dark:bg-[#2f2f2f]":"cpk:bg-transparent"),onMouseEnter:()=>W(t),onMouseDown:t=>{t.preventDefault(),eu(e)},children:e.label},`${e.label}-${t}`)})}):null,eR=(0,w.jsx)("div",{"data-testid":"copilot-chat-input",className:(0,N.twMerge)("cpk:flex cpk:w-full cpk:flex-col cpk:items-center cpk:justify-center","cpk:cursor-text","cpk:overflow-visible cpk:bg-clip-padding cpk:contain-inline-size","cpk:bg-white cpk:dark:bg-[#303030]","cpk:shadow-[0_4px_4px_0_#0000000a,0_0_1px_0_#0000009e] cpk:rounded-[28px]"),onClick:t=>{let n=t.target;"BUTTON"!==n.tagName&&!n.closest("button")&&q.current&&"input"===e&&q.current.focus()},"data-layout":H?"expanded":"compact",children:(0,w.jsxs)("div",{ref:J,className:(0,N.twMerge)("cpk:grid cpk:w-full cpk:gap-x-3 cpk:gap-y-3 cpk:px-3 cpk:py-2",H?"cpk:grid-cols-[auto_minmax(0,1fr)_auto] cpk:grid-rows-[auto_auto]":"cpk:grid-cols-[auto_minmax(0,1fr)_auto] cpk:items-center"),"data-layout":H?"expanded":"compact",children:[(0,w.jsx)("div",{ref:X,className:(0,N.twMerge)("cpk:flex cpk:items-center",H?"cpk:row-start-2":"cpk:row-start-1","cpk:col-start-1"),children:ew}),(0,w.jsx)("div",{className:(0,N.twMerge)("cpk:relative cpk:flex cpk:min-w-0 cpk:flex-col cpk:min-h-[50px] cpk:justify-center",H?"cpk:col-span-3 cpk:row-start-1":"cpk:col-start-2 cpk:row-start-1"),children:"transcribe"===e?em:"processing"===e?(0,w.jsx)("div",{className:"cpk:flex cpk:w-full cpk:items-center cpk:justify-center cpk:py-3 cpk:px-5",children:(0,w.jsx)(na,{className:"cpk:size-[26px] cpk:animate-spin cpk:text-muted-foreground"})}):(0,w.jsxs)(w.Fragment,{children:[ep,eI]})}),(0,w.jsx)("div",{ref:Y,className:(0,N.twMerge)("cpk:flex cpk:items-center cpk:justify-end cpk:gap-2",H?"cpk:col-start-3 cpk:row-start-2":"cpk:col-start-3 cpk:row-start-1"),children:"transcribe"===e?(0,w.jsxs)(w.Fragment,{children:[o&&ev,a&&ex]}):(0,w.jsxs)(w.Fragment,{children:[i&&ek,ey]})})]})});return(0,w.jsxs)("div",{"data-copilotkit":!0,ref:g,className:M("absolute"===f&&"cpk:absolute cpk:bottom-0 cpk:left-0 cpk:right-0 cpk:z-20 cpk:pointer-events-none",O),style:{transform:h>0?`translateY(-${h}px)`:void 0,transition:"transform 0.2s ease-out"},...j,children:[(0,w.jsx)("div",{className:"cpk:max-w-3xl cpk:mx-auto cpk:py-0 cpk:px-4 cpk:sm:px-0 cpk:[div[data-sidebar-chat]_&]:px-8 cpk:[div[data-popup-chat]_&]:px-4 cpk:pointer-events-auto",children:eR}),eS&&eE]})}(iX=nd||(nd={})).SendButton=({className:e,children:t,...n})=>(0,w.jsx)("div",{className:"cpk:mr-[10px]",children:(0,w.jsx)(z,{type:"button","data-testid":"copilot-send-button",variant:"chatInputToolbarPrimary",size:"chatInputToolbarIcon",className:e,...n,children:t??(0,w.jsx)(ni,{className:"cpk:size-[18px]"})})}),r=iX.ToolbarButton=({icon:e,labelKey:t,defaultClassName:n,className:r,...i})=>{let o=T()?.labels??E;return(0,w.jsxs)(F,{children:[(0,w.jsx)(L,{asChild:!0,children:(0,w.jsx)(z,{type:"button",variant:"chatInputToolbarSecondary",size:"chatInputToolbarIcon",className:(0,N.twMerge)(n,r),...i,children:e})}),(0,w.jsx)(U,{side:"bottom",children:(0,w.jsx)("p",{children:o[t]})})]})}
1,iX.StartTranscribeButton=e=>(0,w.jsx)(r,{"data-testid":"copilot-start-transcribe-button",icon:(0,w.jsx)(ns,{className:"cpk:size-[18px]"}),labelKey:"chatInputToolbarStartTranscribeButtonLabel",defaultClassName:"cpk:mr-2",...e}),iX.CancelTranscribeButton=e=>(0,w.jsx)(r,{"data-testid":"copilot-cancel-transcribe-button",icon:(0,w.jsx)(nu,{className:"cpk:size-[18px]"}),labelKey:"chatInputToolbarCancelTranscribeButtonLabel",defaultClassName:"cpk:mr-2",...e}),iX.FinishTranscribeButton=e=>(0,w.jsx)(r,{"data-testid":"copilot-finish-transcribe-button",icon:(0,w.jsx)(no,{className:"cpk:size-[18px]"}),labelKey:"chatInputToolbarFinishTranscribeButtonLabel",defaultClassName:"cpk:mr-[10px]",...e}),iX.AddMenuButton=({className:e,toolsMenu:t,onAddFile:n,disabled:r,...i})=>{let o=T()?.labels??E,a=(0,v.useMemo)(()=>{let e=[];if(n&&e.push({label:o.chatInputToolbarAddButtonLabel,action:n}),t&&t.length>0){for(let n of(e.length>0&&e.push("-"),t))if("-"===n){if(0===e.length||"-"===e[e.length-1])continue;e.push(n)}else e.push(n);for(;e.length>0&&"-"===e[e.length-1];)e.pop()}return e},[n,t,o.chatInputToolbarAddButtonLabel]),s=(0,v.useCallback)(e=>e.map((e,t)=>"-"===e?(0,w.jsx)(t8,{},`separator-${t}`):e.items&&e.items.length>0?(0,w.jsxs)(t9,{children:[(0,w.jsx)(t7,{children:e.label}),(0,w.jsx)(ne,{children:s(e.items)})]},`group-${t}`):(0,w.jsx)(t6,{onClick:e.action,children:e.label},`item-${t}`)),[]),l=a.length>0;return(0,w.jsxs)(t5,{children:[(0,w.jsxs)(F,{children:[(0,w.jsx)(L,{asChild:!0,children:(0,w.jsx)(t4,{asChild:!0,children:(0,w.jsx)(z,{type:"button","data-testid":"copilot-add-menu-button",variant:"chatInputToolbarSecondary",size:"chatInputToolbarIcon",className:(0,N.twMerge)("cpk:ml-1",e),disabled:r||!l,...i,children:(0,w.jsx)(nl,{className:"cpk:size-[20px]"})})})}),(0,w.jsx)(U,{side:"bottom",children:(0,w.jsxs)("p",{className:"cpk:flex cpk:items-center cpk:gap-1 cpk:text-xs cpk:font-medium",children:[(0,w.jsx)("span",{children:"Add files and more"}),(0,w.jsx)("code",{className:"cpk:rounded cpk:bg-[#4a4a4a] cpk:px-1 cpk:py-[1px] cpk:font-mono cpk:text-[11px] cpk:text-white cpk:dark:bg-[#e0e0e0] cpk:dark:text-black",children:"/"})]})})]}),l&&(0,w.jsx)(t3,{side:"top",align:"start",children:s(a)})]})},iX.TextArea=(0,v.forwardRef)(function({style:e,className:t,autoFocus:n,placeholder:r,...i},o){let a=(0,v.useRef)(null),s=T()?.labels??E;return(0,v.useImperativeHandle)(o,()=>a.current),(0,v.useEffect)(()=>{let e=a.current;if(!e)return;let t=()=>{setTimeout(()=>{e.scrollIntoView({behavior:"smooth",block:"nearest"})},300)};return e.addEventListener("focus",t),()=>e.removeEventListener("focus",t)},[]),(0,v.useEffect)(()=>{n&&a.current?.focus()},[n]),(0,w.jsx)("textarea",{ref:a,"data-testid":"copilot-chat-textarea",placeholder:r??s.chatInputPlaceholder,className:(0,N.twMerge)("cpk:bg-transparent cpk:outline-none cpk:antialiased cpk:font-regular cpk:leading-relaxed cpk:text-[16px] cpk:placeholder:text-[#00000077] cpk:dark:placeholder:text-[#fffc]",t),style:{overflow:"auto",resize:"none",...e},rows:1,...i})}),iX.AudioRecorder=_,iX.Disclaimer=({className:e,...t})=>{let n=T()?.labels??E;return(0,w.jsx)("div",{className:M("cpk:text-center cpk:text-xs cpk:text-muted-foreground cpk:py-3 cpk:px-4 cpk:max-w-3xl cpk:mx-auto",e),...t,children:n.chatDisclaimerText})},nd.TextArea.displayName="CopilotChatInput.TextArea",nd.SendButton.displayName="CopilotChatInput.SendButton",nd.ToolbarButton.displayName="CopilotChatInput.ToolbarButton",nd.StartTranscribeButton.displayName="CopilotChatInput.StartTranscribeButton",nd.CancelTranscribeButton.displayName="CopilotChatInput.CancelTranscribeButton",nd.FinishTranscribeButton.displayName="CopilotChatInput.FinishTranscribeButton",nd.AddMenuButton.displayName="CopilotChatInput.AddMenuButton",nd.Disclaimer.displayName="CopilotChatInput.Disclaimer";var np=nd;let nf=new Set(["children","localName","ref","style","className"]),nh=new WeakMap,ng=(e,t,n,r,i)=>{let o,a,s=i?.[t];void 0===s?(e[t]=n,null==n&&t in HTMLElement.prototype&&e.removeAttribute(t)):n!==r&&(void 0===(o=nh.get(e))&&nh.set(e,o=new Map),a=o.get(s),void 0!==n?void 0===a?(o.set(s,a={handleEvent:n}),e.addEventListener(s,a)):a.handleEvent=n:void 0!==a&&(o.delete(s),e.removeEventListener(s,a)))},nm=({core:t,...n})=>{let[r,i]=v.useState(null);return(v.useEffect(()=>{let t=!0;return e.A(136040).then(e=>{e.defineWebInspector?.();let n=(({react:e,tagName:t,elementClass:n,events:r,displayName:i})=>{let o=new Set(Object.keys(r??{})),a=e.forwardRef((i,a)=>{let s=e.useRef(new Map),l=e.useRef(null),c={},u={};for(let[e,t]of Object.entries(i))nf.has(e)?c["className"===e?"class":e]=t:o.has(e)||e in n.prototype?u[e]=t:c[e]=t;return e.useLayoutEffect(()=>{if(null===l.current)return;let e=new Map;for(let t in u)ng(l.current,t,i[t],s.current.get(t),r),s.current.delete(t),e.set(t,i[t]);for(let[e,t]of s.current)ng(l.current,e,void 0,t,r);s.current=e}),e.useLayoutEffect(()=>{l.current?.removeAttribute("defer-hydration")},[]),c.suppressHydrationWarning=!0,e.createElement(t,{...c,ref:e.useCallback(e=>{l.current=e,"function"==typeof a?a(e):null!==a&&(a.current=e)},[a])})});return a.displayName=i??n.name,a})({tagName:e.WEB_INSPECTOR_TAG,elementClass:e.WebInspectorElement,react:v});t&&i(()=>n)}),()=>{t=!1}},[]),r)?(0,w.jsx)(r,{...n,core:t??null}):null};nm.displayName="CopilotKitInspector";var ny=e.i(50270);let nk=new class{queues=new Map;processing=new Map;async enqueue(e,t){let n=e.threadId||"default";return new Promise((r,i)=>{let o=this.queues.get(n);o||(o=[],this.queues.set(n,o)),o.push({execute:t,resolve:r,reject:i}),this.processQueue(n,e)})}async processQueue(e,t){if(!this.processing.get(e)){this.processing.set(e,!0);try{let n=this.queues.get(e);if(!n)return;for(;n.length>0;){let e=n[0];try{await this.waitForAgentIdle(t);let n=await e.execute();e.resolve(n)}catch(t){e.reject(t instanceof Error?t:Error(String(t)))}n.shift()}}finally{this.processing.set(e,!1)}}}waitForAgentIdle(e){return new Promise(t=>{if(!e.isRunning)return void t();let n=!1,r=()=>{n||(n=!0,clearInterval(o),i.unsubscribe(),t())},i=e.subscribe({onRunFinalized:r,onRunFailed:r}),o=setInterval(()=>{e.isRunning||r()},500)})}},nv=ny.z.object({result:ny.z.object({content:ny.z.array(ny.z.any()).optional(),structuredContent:ny.z.any().optional(),isError:ny.z.boolean().optional()}),resourceUri:ny.z.string(),serverHash:ny.z.string(),serverId:ny.z.string().optional(),toolInput:ny.z.record(ny.z.unknown()).optional()}),nb=function({content:e,agent:t}){let n=(0,v.useRef)(null),r=(0,v.useRef)(null),[i,o]=(0,v.useState)(!1),[a,s]=(0,v.useState)(null),[l,c]=(0,v.useState)(!0),[u,d]=(0,v.useState)({}),[p,f]=(0,v.useState)(null),h=(0,v.useRef)(e);h.current=e;let g=(0,v.useRef)(t);g.current=t;let m=(0,v.useRef)({inProgress:!1,promise:null,resourceUri:null}),y=(0,v.useCallback)(e=>{r.current?.contentWindow&&(console.log("[MCPAppsRenderer] Sending to iframe:",e),r.current.contentWindow.postMessage(e,"*"))},[]),k=(0,v.useCallback)((e,t)=>{y({jsonrpc:"2.0",id:e,result:t})},[y]),b=(0,v.useCallback)((e,t,n)=>{y({jsonrpc:"2.0",id:e,error:{code:t,message:n}})},[y]),x=(0,v.useCallback)((e,t)=>{y({jsonrpc:"2.0",method:e,params:t||{}})},[y]);(0,v.useEffect)(()=>{let{resourceUri:n,serverHash:r,serverId:i}=e;if(m.current.inProgress&&m.current.resourceUri===n)return void m.current.promise?.then(e=>{e&&(f(e),c(!1))}).catch(e=>{s(e instanceof Error?e:Error(String(e))),c(!1)});if(!t){s(Error("No agent available to fetch resource")),c(!1);return}m.current.inProgress=!0,m.current.resourceUri=n;let o=(async()=>{try{let e=(await nk.enqueue(t,()=>t.runAgent({forwardedProps:{__proxiedMCPRequest:{serverHash:r,serverId:i,method:"resources/read",params:{uri:n}}}}))).result?.contents?.[0];if(!e)throw Error("No resource content in response");return e}catch(e){throw console.error("[MCPAppsRenderer] Failed to fetch resource:",e),e}finally{m.current.inProgress=!1}})();m.current.promise=o,o.then(e=>{e&&(f(e),c(!1))}).catch(e=>{s(e instanceof Error?e:Error(String(e))),c(!1)})},[t,e]),(0,v.useEffect)(()=>
1{if(l||!p)return;let e=n.current;if(!e)return;let t=!0,i=null,a=null,c=null;return(async()=>{try{var n;let s,l,u=document.createElement("iframe");c=u,u.style.width="100%",u.style.height="100px",u.style.border="none",u.style.backgroundColor="transparent",u.style.display="block",u.setAttribute("sandbox","allow-scripts allow-same-origin allow-forms");let f=new Promise(e=>{a=t=>{t.source===u.contentWindow&&t.data?.method==="ui/notifications/sandbox-proxy-ready"&&(a&&(window.removeEventListener("message",a),a=null),e())},window.addEventListener("message",a)});if(!t){a&&(window.removeEventListener("message",a),a=null);return}if(n=p._meta?.ui?.csp?.resourceDomains,l=n?.length?" "+n.join(" "):"",u.srcdoc=`<!doctype html> 2<html> 3<head> 4<meta charset="utf-8" /> 5<meta http-equiv="Content-Security-Policy" content="default-src 'self'; img-src * data: blob: 'unsafe-inline'; media-src * blob: data:; font-src * blob: data:; script-src ${"'self' 'wasm-unsafe-eval' 'unsafe-inline' 'unsafe-eval' blob: data: http://localhost:* https://localhost:*"+l}; style-src * blob: data: 'unsafe-inline'; connect-src *; frame-src ${"* blob: data: http://localhost:* https://localhost:*"+l}; base-uri 'self';" /> 6<style>html,body{margin:0;padding:0;height:100%;width:100%;overflow:hidden}*{box-sizing:border-box}iframe{background-color:transparent;border:none;padding:0;overflow:hidden;width:100%;height:100%}</style> 7</head> 8<body> 9<script> 10if(window.self===window.top){throw new Error("This file must be used in an iframe.")} 11const inner=document.createElement("iframe"); 12inner.style="width:100%;height:100%;border:none;"; 13inner.setAttribute("sandbox","allow-scripts allow-same-origin allow-forms"); 14document.body.appendChild(inner); 15window.addEventListener("message",async(event)=>{ 16if(event.source===window.parent){ 17if(event.data&&event.data.method==="ui/notifications/sandbox-resource-ready"){ 18const{html,sandbox}=event.data.params; 19if(typeof sandbox==="string")inner.setAttribute("sandbox",sandbox); 20if(typeof html==="string")inner.srcdoc=html; 21}else if(inner&&inner.contentWindow){ 22inner.contentWindow.postMessage(event.data,"*"); 23} 24}else if(event.source===inner.contentWindow){ 25window.parent.postMessage(event.data,"*"); 26} 27}); 28window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-ready",params:{}},"*"); 29</script> 30</body> 31</html>`,r.current=u,e.appendChild(u),await f,!t)return;if(console.log("[MCPAppsRenderer] Sandbox proxy ready"),i=async e=>{if(e.source!==u.contentWindow)return;let n=e.data;if(n&&"object"==typeof n&&"2.0"===n.jsonrpc){if(console.log("[MCPAppsRenderer] Received from iframe:",n),"id"in n&&"method"in n)switch(n.method){case"ui/initialize":k(n.id,{protocolVersion:"2025-06-18",hostInfo:{name:"CopilotKit MCP Apps Host",version:"1.0.0"},hostCapabilities:{openLinks:{},logging:{}},hostContext:{theme:"light",platform:"web"}});break;case"ui/message":{let e=g.current;if(!e){console.warn("[MCPAppsRenderer] ui/message: No agent available"),k(n.id,{isError:!1});break}try{let t=n.params,r=t.content?.filter(e=>"text"===e.type&&e.text).map(e=>e.text).join("\n")||"";r&&e.addMessage({id:crypto.randomUUID(),role:t.role||"user",content:r}),k(n.id,{isError:!1})}catch(e){console.error("[MCPAppsRenderer] ui/message error:",e),k(n.id,{isError:!0})}break}case"ui/open-link":{let e=n.params?.url;e?(window.open(e,"_blank","noopener,noreferrer"),k(n.id,{isError:!1})):b(n.id,-32602,"Missing url parameter");break}case"tools/call":{let{serverHash:e,serverId:t}=h.current,r=g.current;if(!e){b(n.id,-32603,"No server hash available for proxying");break}if(!r){b(n.id,-32603,"No agent available for proxying");break}try{let i=await nk.enqueue(r,()=>r.runAgent({forwardedProps:{__proxiedMCPRequest:{serverHash:e,serverId:t,method:"tools/call",params:n.params}}}));k(n.id,i.result||{})}catch(e){console.error("[MCPAppsRenderer] tools/call error:",e),b(n.id,-32603,String(e))}break}default:b(n.id,-32601,`Method not found: ${n.method}`)}if(!("id"in n)&&"method"in n)switch(n.method){case"ui/notifications/initialized":console.log("[MCPAppsRenderer] Inner iframe initialized"),t&&o(!0);break;case"ui/notifications/size-changed":{let{width:e,height:r}=n.params||{};console.log("[MCPAppsRenderer] Size change:",{width:e,height:r}),t&&d({width:"number"==typeof e?e:void 0,height:"number"==typeof r?r:void 0});break}case"notifications/message":console.log("[MCPAppsRenderer] App log:",n.params)}}},window.addEventListener("message",i),p.text)s=p.text;else if(p.blob)s=atob(p.blob);else throw Error("Resource has no text or blob content");x("ui/notifications/sandbox-resource-ready",{html:s})}catch(e){console.error("[MCPAppsRenderer] Setup error:",e),t&&s(e instanceof Error?e:Error(String(e)))}})(),()=>{t=!1,a&&(window.removeEventListener("message",a),a=null),i&&window.removeEventListener("message",i),c&&(c.remove(),c=null),r.current=null}},[l,p,x,k,b]),(0,v.useEffect)(()=>{r.current&&(void 0!==u.width&&(r.current.style.minWidth=`min(${u.width}px, 100%)`,r.current.style.width="100%"),void 0!==u.height&&(r.current.style.height=`${u.height}px`))},[u]),(0,v.useEffect)(()=>{i&&e.toolInput&&(console.log("[MCPAppsRenderer] Sending tool input:",e.toolInput),x("ui/notifications/tool-input",{arguments:e.toolInput}))},[i,e.toolInput,x]),(0,v.useEffect)(()=>{i&&e.result&&(console.log("[MCPAppsRenderer] Sending tool result:",e.result),x("ui/notifications/tool-result",e.result))},[i,e.result,x]);let E=p?._meta?.ui?.prefersBorder===!0?{borderRadius:"8px",backgroundColor:"#f9f9f9",border:"1px solid #e0e0e0"}:{};return(0,w.jsxs)("div",{ref:n,style:{width:"100%",height:u.height?`${u.height}px`:"auto",minHeight:"100px",overflow:"hidden",position:"relative",...E},children:[l&&(0,w.jsx)("div",{style:{padding:"1rem",color:"#666"},children:"Loading..."}),a&&(0,w.jsxs)("div",{style:{color:"red",padding:"1rem"},children:["Error: ",a.message]})]})};var nx=e.i(471721),nw=class extends nx.CopilotKitCore{_renderToolCalls=[];_renderCustomMessages=[];_renderActivityMessages=[];_interruptElement=null;constructor(e){super(e),this._renderToolCalls=e.renderToolCalls??[],this._renderCustomMessages=e.renderCustomMessages??[],this._renderActivityMessages=e.renderActivityMessages??[]}get renderCustomMessages(){return this._renderCustomMessages}get renderActivityMessages(){return this._renderActivityMessages}get renderToolCalls(){return this._renderToolCalls}setRenderToolCalls(e){this._renderToolCalls=e,this.notifySubscribers(e=>{e.onRenderToolCallsChanged&&e.onRenderToolCallsChanged({copilotkit:this,renderToolCalls:this.renderToolCalls})},"Subscriber onRenderToolCallsChanged error:")}get interruptElement(){return this._interruptElement}setInterruptElement(e){this._interruptElement=e,this.notifySubscribers(e=>{e.onInterruptElementChanged?.({copilotkit:this,interruptElement:this._interruptElement})},"Subscriber onInterruptElementChanged error:")}subscribe(e){return super.subscribe(e)}},nE=e.i(247167);let nS="X-CopilotCloud-Public-Api-Key",nC=(0,v.createContext)({copilotkit:null,executingToolCallIds:new Set});function nT(e,t,n){let r=(0,v.useMemo)(()=>[],[]),i=e??r,o=(0,v.useRef)(i);return(0,v.useEffect)(()=>{t&&i!==o.current&&(!n||n(o.current,i))&&console.error(t)},[i,t]),i}let nN=({children:e,runtimeUrl:t,headers:n={},credentials:r,publicApiKey:i,publicLicenseKey:o,properties:a={},agents__unsafe_dev_only:s={},selfManagedAgents:l={},renderToolCalls:c,renderActivityMessages:u,renderCustomMessages:d,frontendTools:p,humanInTheLoop:f,showDevConsole:h=!1,useSingleEndpoint:g=!1})=>{let[m,y]=(0,v.useState)(!1);(0,v.useEffect)(()=>{"undefined"!=typeof window&&(!0===h||"auto"===h&&new Set(["localhost","127.0.0.1"]).has(window.location.hostname)?y(!0):y(!1))},[h]);let k=nT(c,"renderToolCalls must be a stable array. If you want to dynamically add or remove tools, use `useFrontendTool` instead.",(e,t)=>{let n=e=>`${e?.agentId??""}:${e?.name??""}`,r=e=>new Set(e.map(n)),i=r(e),o=r(t);if(i.size!==o.size)return!0;for(let e of i)if(!o.has(e))return!0;return!1}),b=nT(d,"renderCustomMessages must be a stable array."),x=nT(u,"renderActivityMessages must be a stable array."),E=(0,v.useMemo)(()=>[{activityType:"mcp-apps",content:nv,render:nb}],[]),S=(0,v.useMemo)(()=>[...x,...E],[x,E]),C=i??o,T=(0,v.useMemo)(()=>({...s,...l}),[s,l]),N=T&&Object.keys(T).length>0,A=(0,v.useMemo)(()=>!C||n[nS]?n:{...n,[nS]:C},[n,C]);if(!t&&!C&&!N)throw Error("Missing required prop: 'runtimeUrl' or 'publicApiKey' or 'publicLicenseKey'");let _=t??(C?"https://api.cloud.copilotkit.ai/copilotkit/v1":void 0),I=nT(p,"frontendTools must be a stable array. If you want to dynamically add or remove tools, use `useFrontendTool` instead."),R=nT(f,"humanInTheLoop must be a stable array. If you want to dynamically add or remove human-in-the-loop tools, use `useHumanInTheLoop` instead."),M=(0,v.useMemo)(()=>{let e=[],t=[];return R.forEach(n=>{let r={name:n.name,description:n.description,parameters:n.parameters,followUp:n.followUp,...n.agentId&&{agentId:n.agentId},handler:async()=>new Promise(e=>{console.warn(`Human-in-the-loop tool '${n.name}' called but no interactive handler is set up.`),e(void 0)})};e.push(r),n.render&&t.push({name:n.name,args:n.parameters,render:n.render,...n.agentId&&{agentId:n.agentId}})}),{tools:e,renderToolCalls:t}},[R]),O=(0,v.useMemo)(()=>{let e=[];return e.push(...I),e.push(...M.tools),e},[I,M]),j=(0,v.useMemo)(()=>{let e=[...k];return I.forEach(t=>{if(t.render){let n=t.parameters||("*"===t.name?ny.z.any():void 0);n&&e.push({name:t.name,args:n,render:t.render})}}),e.push(...M.renderToolCalls),e},[k,I,M]),z=(0,v.useMemo)(()=>
31new nw({runtimeUrl:_,runtimeTransport:g?"single":"rest",headers:A,credentials:r,properties:a,agents__unsafe_dev_only:T,tools:O,renderToolCalls:j,renderActivityMessages:S,renderCustomMessages:b}),[O,j,S,b,g]),[,D]=(0,v.useReducer)(e=>e+1,0);(0,v.useEffect)(()=>{let e=z.subscribe({onRenderToolCallsChanged:()=>{D()}});return()=>{e.unsubscribe()}},[z]);let[P,F]=(0,v.useState)(()=>new Set);return(0,v.useEffect)(()=>{let e=z.subscribe({onToolExecutionStart:({toolCallId:e})=>{F(t=>{if(t.has(e))return t;let n=new Set(t);return n.add(e),n})},onToolExecutionEnd:({toolCallId:e})=>{F(t=>{if(!t.has(e))return t;let n=new Set(t);return n.delete(e),n})}});return()=>{e.unsubscribe()}},[z]),(0,v.useEffect)(()=>{z.setRuntimeUrl(_),z.setRuntimeTransport(g?"single":"rest"),z.setHeaders(A),z.setCredentials(r),z.setProperties(a),z.setAgents__unsafe_dev_only(T)},[_,A,r,a,T,g]),(0,w.jsxs)(nC.Provider,{value:{copilotkit:z,executingToolCallIds:P},children:[e,m?(0,w.jsx)(nm,{core:z}):null]})},nA=()=>{let e=(0,v.useContext)(nC),[,t]=(0,v.useReducer)(e=>e+1,0);if(!e)throw Error("useCopilotKit must be used within CopilotKitProvider");return(0,v.useEffect)(()=>{let n=e.copilotkit.subscribe({onRuntimeConnectionStatusChanged:()=>{t()}});return()=>{n.unsubscribe()}},[]),e},n_=v.default.memo(function({toolCall:e,toolMessage:t,RenderComponent:n,isExecuting:r}){let i=(0,v.useMemo)(()=>(0,x.partialJSONParse)(e.function.arguments),[e.function.arguments]),o=e.function.name;return t?(0,w.jsx)(n,{name:o,args:i,status:nx.ToolCallStatus.Complete,result:t.content}):r?(0,w.jsx)(n,{name:o,args:i,status:nx.ToolCallStatus.Executing,result:void 0}):(0,w.jsx)(n,{name:o,args:i,status:nx.ToolCallStatus.InProgress,result:void 0})},(e,t)=>e.toolCall.id===t.toolCall.id&&e.toolCall.function.name===t.toolCall.function.name&&e.toolCall.function.arguments===t.toolCall.function.arguments&&e.toolMessage?.content===t.toolMessage?.content&&e.isExecuting===t.isExecuting&&e.RenderComponent===t.RenderComponent);function nI(){let{copilotkit:e,executingToolCallIds:t}=nA(),n=T()?.agentId??b.DEFAULT_AGENT_ID,r=(0,v.useSyncExternalStore)(t=>e.subscribe({onRenderToolCallsChanged:t}).unsubscribe,()=>e.renderToolCalls,()=>e.renderToolCalls);return(0,v.useCallback)(({toolCall:e,toolMessage:i})=>{let o=r.filter(t=>t.name===e.function.name),a=o.find(e=>e.agentId===n)||o.find(e=>!e.agentId)||o[0]||r.find(e=>"*"===e.name);if(!a)return null;let s=a.render;return(0,w.jsx)(n_,{toolCall:e,toolMessage:i,RenderComponent:s,isExecuting:t.has(e.id)},e.id)},[r,t,n])}function nR(){let{copilotkit:e}=nA(),t=T();if(!t)return null;let{agentId:n,threadId:r}=t,i=e.renderCustomMessages.filter(e=>void 0===e.agentId||e.agentId===n).sort((e,t)=>{let n=void 0!==e.agentId;return n===(void 0!==t.agentId)?0:n?-1:1});return function(t){if(!i.length)return null;let{message:o,position:a}=t,s=e.getRunIdForMessage(n,r,o.id)??e.getRunIdsForThread(n,r).slice(-1)[0],l=s??`missing-run-id:${o.id}`,c=e.getAgent(n);if(!c)throw Error("Agent not found");let u=s?c.messages.filter(t=>e.getRunIdForMessage(n,r,t.id)===s).map(e=>e.id):[o.id],d=c.messages.findIndex(e=>e.id===o.id),p=d>=0?d:0,f=s?Math.max(u.indexOf(o.id),0):0,h=s?u.length:1,g=s?e.getStateByRun(n,r,s):void 0,m=null;for(let e of i){if(!e.render)continue;let t=e.render;if(m=(0,w.jsx)(t,{message:o,position:a,runId:l,messageIndex:p,messageIndexInRun:f,numberOfMessagesInRun:h,agentId:n,stateSnapshot:g},`${l}-${o.id}-${a}`))break}return m}}let nM=((iY={}).OnMessagesChanged="OnMessagesChanged",iY.OnStateChanged="OnStateChanged",iY.OnRunStatusChanged="OnRunStatusChanged",iY),nO=[nM.OnMessagesChanged,nM.OnStateChanged,nM.OnRunStatusChanged];function nj({agentId:e,updates:t}={}){e??=b.DEFAULT_AGENT_ID;let{copilotkit:n}=nA(),[,r]=(0,v.useReducer)(e=>e+1,0),i=(0,v.useMemo)(()=>t??nO,[JSON.stringify(t)]),o=(0,v.useMemo)(()=>{let t=n.getAgent(e);if(t)return t;let r=void 0!==n.runtimeUrl,i=n.runtimeConnectionStatus;if(r&&(i===nx.CopilotKitCoreRuntimeConnectionStatus.Disconnected||i===nx.CopilotKitCoreRuntimeConnectionStatus.Connecting)){let t=new nx.ProxiedCopilotRuntimeAgent({runtimeUrl:n.runtimeUrl,agentId:e,transport:n.runtimeTrans
31port});return t.headers={...n.headers},t}let o=Object.keys(n.agents??{}),a=r?`runtimeUrl=${n.runtimeUrl}`:"no runtimeUrl";throw Error(`useAgent: Agent '${e}' not found after runtime sync (${a}). `+(o.length?`Known agents: [${o.join(", ")}]`:"No agents registered.")+" Verify your runtime /info and/or agents__unsafe_dev_only.")},[e,n.agents,n.runtimeConnectionStatus,n.runtimeUrl,n.runtimeTransport,JSON.stringify(n.headers),n]);return(0,v.useEffect)(()=>{if(0===i.length)return;let e={};i.includes(nM.OnMessagesChanged)&&(e.onMessagesChanged=()=>{r()}),i.includes(nM.OnStateChanged)&&(e.onStateChanged=r),i.includes(nM.OnRunStatusChanged)&&(e.onRunInitialized=r,e.onRunFinalized=r,e.onRunFailed=r);let t=o.subscribe(e);return()=>t.unsubscribe()},[o,r,JSON.stringify(i)]),{agent:o}}function nz({agentId:e}={}){let{copilotkit:t}=nA(),n=T(),r=(0,v.useMemo)(()=>e??n?.agentId??b.DEFAULT_AGENT_ID,[e,n?.agentId]),[i,o]=(0,v.useState)(()=>t.getSuggestions(r).suggestions),[a,s]=(0,v.useState)(()=>t.getSuggestions(r).isLoading);return(0,v.useEffect)(()=>{let e=t.getSuggestions(r);o(e.suggestions),s(e.isLoading)},[t,r]),(0,v.useEffect)(()=>{let e=t.subscribe({onSuggestionsChanged:({agentId:e,suggestions:t})=>{e===r&&o(t)},onSuggestionsStartedLoading:({agentId:e})=>{e===r&&s(!0)},onSuggestionsFinishedLoading:({agentId:e})=>{e===r&&s(!1)},onSuggestionsConfigChanged:()=>{let e=t.getSuggestions(r);o(e.suggestions),s(e.isLoading)}});return()=>{e.unsubscribe()}},[t,r]),{suggestions:i,reloadSuggestions:(0,v.useCallback)(()=>{t.reloadSuggestions(r)},[t,r]),clearSuggestions:(0,v.useCallback)(()=>{t.clearSuggestions(r)},[t,r]),isLoading:a}}function nD({message:e,messages:t=[]}){let n=nI();return e.toolCalls&&0!==e.toolCalls.length?(0,w.jsx)(w.Fragment,{children:e.toolCalls.map(e=>{let r=t.find(t=>"tool"===t.role&&t.toolCallId===e.id);return(0,w.jsx)(v.default.Fragment,{children:n({toolCall:e,toolMessage:r})},e.id)})}):null}let nP=G("copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]),nF=G("refresh-cw",[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]]),nL=G("thumbs-down",[["path",{d:"M17 14V2",key:"8ymqnk"}],["path",{d:"M9 18.12 10 14H4.17a2 2 0 0 1-1.92-2.56l2.33-8A2 2 0 0 1 6.5 2H20a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2h-2.76a2 2 0 0 0-1.79 1.11L12 22a3.13 3.13 0 0 1-3-3.88Z",key:"m61m77"}]]),nU=G("thumbs-up",[["path",{d:"M7 10v12",key:"1qc93n"}],["path",{d:"M15 5.88 14 10h5.83a2 2 0 0 1 1.92 2.56l-2.33 8A2 2 0 0 1 17.5 22H4a2 2 0 0 1-2-2v-8a2 2 0 0 1 2-2h2.76a2 2 0 0 0 1.79-1.11L12 2a3.13 3.13 0 0 1 3 3.88Z",key:"emmmcr"}]]),nB=G("volume-2",[["path",{d:"M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z",key:"uqj9uw"}],["path",{d:"M16 9a5 5 0 0 1 0 6",key:"1q6k2b"}],["path",{d:"M19.364 18.364a9 9 0 0 0 0-12.728",key:"ijwkga"}]]);var n$=e.i(633154),nH=n$;function nK({message:e,messages:t,isRunning:n,onThumbsUp:r,onThumbsDown:i,onReadAloud:o,onRegenerate:a,additionalToolbarItems:s,toolbarVisible:l=!0,markdownRenderer:c,toolbar:u,copyButton:d,thumbsUpButton:p,thumbsDownButton:f,readAloudButton:h,regenerateButton:g,toolCallsView:m,children:y,className:k,...v}){let b=nr(c,nK.MarkdownRenderer,{content:e.content||""}),x=nr(d,nK.CopyButton,{onClick:async()=>{if(e.content)try{await navigator.clipboard.writeText(e.content)}catch(e){console.error("Failed to copy message:",e)}}}),E=nr(p,nK.ThumbsUpButton,{onClick:r}),S=nr(f,nK.ThumbsDownButton,{onClick:i}),C=nr(h,nK.ReadAloudButton,{onClick:o}),T=nr(g,nK.RegenerateButton,{onClick:a}),A=nr(u,nK.Toolbar,{children:(0,w.jsxs)("div",{className:"cpk:flex cpk:items-center cpk:gap-1",children:[x,(r||p)&&E,(i||f)&&S,(o||h)&&C,(a||g)&&T,s]})}),_=nr(m,nD,{message:e,messages:t}),I=!!(e.content&&e.content.trim().length>0),R="assistant"===e.role&&t?.[t.length-1]?.id===e.id,M=l&&I&&!(n&&R);return y?(0,w.jsx)("div",{"data-copilotkit":!0,style:{display:"contents"},children:y({markdownRenderer:b,toolbar:A,toolCallsView:_,copyButton:x,thumbsUpButton:E,thumbsDownButton:S,readAloudButton:C,regenerateButton:T,message:e,messages:t,isRunning:n,onThumbsUp:r,onThumbsDown:i,onReadAloud:o,onRegenerate:a,additionalToolbarItems:s,toolbarVisible:M})}):(0,w.jsxs)("div",{"data-copilotkit":!0,"data-testid":"copilot-assistant-message",className:(0,N.twMerge)(k),...v,"data-message-id":e.id,children:[(0,w.jsx)("div",{className:"cpk:prose cpk:max-w-full cpk:break-words cpk:dark:prose-invert",children:b}),_,M&&A]})}(iQ=nK||(nK={})).MarkdownRenderer=({content:e,className:t,...n})=>(0,w.jsx)(nH.i,{className:t,...n,children:e??""}),iQ.Toolbar=({className:e,...t})=>(0,w.jsx)("div",{"data-testid":"copilot-assistant-toolbar",className:(0,N.twMerge)("cpk:w-full cpk:bg-transparent cpk:flex cpk:items-center cpk:-ml-[5px] cpk:-mt-[0px]",e),...t}),i=iQ.ToolbarButton=({title:e,children:t,...n})=>(0,w.jsxs)(F,{children:[(0,w.jsx)(L,{asChild:!0,children:(0,w.jsx)(z,{type:"button",variant:"assistantMessageToolbarButton","aria-label":e,...n,children:t})}),(0,w.jsx)(U,{side:"bottom",children:(0,w.jsx)("p",{children:e})})]}),iQ.CopyButton=({className:e,title:t,onClick:n,...r})=>{let o=T()?.labels??E,[a,s]=(0,v.useState)(!1);return(0,w.jsx)(i,{"data-testid":"copilot-copy-button",title:t||o.assistantMessageToolbarCopyMessageLabel,onClick:e=>{s(!0),setTimeout(()=>s(!1),2e3),n&&n(e)},className:e,...r,children:a?(0,w.jsx)(no,{className:"cpk:size-[18px]"}):(0,w.jsx)(nP,{className:"cpk:size-[18px]"})})},iQ.ThumbsUpButton=({title:e,...t})=>{let n=T()?.labels??E;return(0,w.jsx)(i,{"data-testid":"copilot-thumbs-up-button",title:e||n.assistantMessageToolbarThumbsUpLabel,...t,children:(0,w.jsx)(nU,{className:"cpk:size-[18px]"})})},iQ.ThumbsDownButton=({title:e,...t})=>{let n=T()?.labels??E;return(0,w.jsx)(i,{"data-testid":"copilot-thumbs-down-button",title:e||n.assistantMessageToolbarThumbsDownLabel,...t,children:(0,w.jsx)(nL,{className:"cpk:size-[18px]"})})},iQ.ReadAloudButton=({title:e,...t})=>{let n=T()?.labels??E;return(0,w.jsx)(i,{"data-testid":"copilot-read-aloud-button",title:e||n.assistantMessageToolbarReadAloudLabel,...t,children:(0,w.jsx)(nB,{className:"cpk:size-[20px]"})})},iQ.RegenerateButton=({title:e,...t})=>{let n=T()?.labels??E;return(0,w.jsx)(i,{"data-testid":"copilot-regenerate-button",title:e||n.assistantMessageToolbarRegenerateLabel,...t,children:(0,w.jsx)(nF,{className:"cpk:size-[18px]"})})},nK.MarkdownRenderer.displayName="CopilotChatAssistantMessage.MarkdownRenderer",nK.Toolbar.displayName="CopilotChatAssistantMessage.Toolbar",nK.CopyButton.displayName="CopilotChatAssistantMessage.CopyButton",nK.ThumbsUpButton.displayName="CopilotChatAssistantMessage.ThumbsUpButton",nK.ThumbsDownButton.displayName="CopilotChatAssistantMessage.ThumbsDownButton",nK.ReadAloudButton.displayName="CopilotChatAssistantMessage.ReadAloudButton",nK.RegenerateButton.displayName="CopilotChatAssistantMessage.RegenerateButton";var nG=nK;let nV=G("chevron-left",[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]]),nW=G("square-pen",[["path",{d:"M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7",key:"1m0v6g"}],["path",{d:"M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z",key:"ohrbg2"}]]);function nq({message:e,onEditMessage:t,branchIndex:n,numberOfBranches:r,onSwitchToBranch:i,additionalToolbarItems:o,messageRenderer:a,toolbar:s,copyButton:l,editButton:c,branchNavigation:u,children:d,className:p,...f}){let h=(0,v.useMemo)(()=>{var t;return(t=e.content)?"string"==typeof t?t:t.map(e=>e&&"object"==typeof e&&"type"in e&&"text"===e.type&&"string"==typeof e.text?e.text:"").filter(e=>e.length>0).join("\n"):""}
31,[e.content]),g=nr(a,nq.MessageRenderer,{content:h}),m=nr(l,nq.CopyButton,{onClick:async()=>{if(h)try{await navigator.clipboard.writeText(h)}catch(e){console.error("Failed to copy message:",e)}}}),y=nr(c,nq.EditButton,{onClick:()=>t?.({message:e})}),k=nr(u,nq.BranchNavigation,{currentBranch:n,numberOfBranches:r,onSwitchToBranch:i,message:e}),b=nr(s,nq.Toolbar,{children:(0,w.jsxs)("div",{className:"cpk:flex cpk:items-center cpk:gap-1 cpk:justify-end",children:[o,m,t&&y,r&&r>1&&i&&k]})});return d?(0,w.jsx)("div",{"data-copilotkit":!0,style:{display:"contents"},children:d({messageRenderer:g,toolbar:b,copyButton:m,editButton:y,branchNavigation:k,message:e,branchIndex:n,numberOfBranches:r,additionalToolbarItems:o})}):(0,w.jsxs)("div",{"data-copilotkit":!0,"data-testid":"copilot-user-message",className:(0,N.twMerge)("cpk:flex cpk:flex-col cpk:items-end cpk:group cpk:pt-10",p),"data-message-id":e.id,...f,children:[g,b]})}(iZ=nq||(nq={})).Container=({children:e,className:t,...n})=>(0,w.jsx)("div",{className:(0,N.twMerge)("cpk:flex cpk:flex-col cpk:items-end cpk:group",t),...n,children:e}),iZ.MessageRenderer=({content:e,className:t})=>(0,w.jsx)("div",{className:(0,N.twMerge)("cpk:prose cpk:dark:prose-invert cpk:bg-muted cpk:relative cpk:max-w-[80%] cpk:rounded-[18px] cpk:px-4 cpk:py-1.5 cpk:data-[multiline]:py-3 cpk:inline-block cpk:whitespace-pre-wrap",t),children:e}),iZ.Toolbar=({className:e,...t})=>(0,w.jsx)("div",{"data-testid":"copilot-user-toolbar",className:(0,N.twMerge)("cpk:w-full cpk:bg-transparent cpk:flex cpk:items-center cpk:justify-end cpk:-mr-[5px] cpk:mt-[4px] cpk:invisible cpk:group-hover:visible",e),...t}),o=iZ.ToolbarButton=({title:e,children:t,className:n,...r})=>(0,w.jsxs)(F,{children:[(0,w.jsx)(L,{asChild:!0,children:(0,w.jsx)(z,{type:"button",variant:"assistantMessageToolbarButton","aria-label":e,className:(0,N.twMerge)(n),...r,children:t})}),(0,w.jsx)(U,{side:"bottom",children:(0,w.jsx)("p",{children:e})})]}),iZ.CopyButton=({className:e,title:t,onClick:n,...r})=>{let i=T()?.labels??E,[a,s]=(0,v.useState)(!1);return(0,w.jsx)(o,{"data-testid":"copilot-user-copy-button",title:t||i.userMessageToolbarCopyMessageLabel,onClick:e=>{s(!0),setTimeout(()=>s(!1),2e3),n&&n(e)},className:e,...r,children:a?(0,w.jsx)(no,{className:"cpk:size-[18px]"}):(0,w.jsx)(nP,{className:"cpk:size-[18px]"})})},iZ.EditButton=({className:e,title:t,...n})=>{let r=T()?.labels??E;return(0,w.jsx)(o,{"data-testid":"copilot-edit-button",title:t||r.userMessageToolbarEditMessageLabel,className:e,...n,children:(0,w.jsx)(nW,{className:"cpk:size-[18px]"})})},iZ.BranchNavigation=({className:e,currentBranch:t=0,numberOfBranches:n=1,onSwitchToBranch:r,message:i,...o})=>{if(!n||n<=1||!r)return null;let a=t<n-1;return(0,w.jsxs)("div",{"data-testid":"copilot-branch-navigation",className:(0,N.twMerge)("cpk:flex cpk:items-center cpk:gap-1",e),...o,children:[(0,w.jsx)(z,{type:"button",variant:"assistantMessageToolbarButton",onClick:()=>r?.({branchIndex:t-1,numberOfBranches:n,message:i}),disabled:!(t>0),className:"cpk:h-6 cpk:w-6 cpk:p-0",children:(0,w.jsx)(nV,{className:"cpk:size-[20px]"})}),(0,w.jsxs)("span",{className:"cpk:text-sm cpk:text-muted-foreground cpk:px-0 cpk:font-medium",children:[t+1,"/",n]}),(0,w.jsx)(z,{type:"button",variant:"assistantMessageToolbarButton",onClick:()=>r?.({branchIndex:t+1,numberOfBranches:n,message:i}),disabled:!a,className:"cpk:h-6 cpk:w-6 cpk:p-0",children:(0,w.jsx)(V,{className:"cpk:size-[20px]"})})]})},nq.Container.displayName="CopilotChatUserMessage.Container",nq.MessageRenderer.displayName="CopilotChatUserMessage.MessageRenderer",nq.Toolbar.displayName="CopilotChatUserMessage.Toolbar",nq.ToolbarButton.displayName="CopilotChatUserMessage.ToolbarButton",nq.CopyButton.displayName="CopilotChatUserMessage.CopyButton",nq.EditButton.displayName="CopilotChatUserMessage.EditButton",nq.BranchNavigation.displayName="CopilotChatUserMessage.BranchNavigation";var nJ=nq,nH=n$;function nX({message:e,messages:t,isRunning:n,header:r,contentView:i,toggle:o,children:a,className:s,...l}){let c=t?.[t.length-1]?.id===e.id,u=!!(n&&c),d=!!(e.content&&e.content.length>0),p=(0,v.useRef)(null),[f,h]=(0,v.useState)(0);(0,v.useEffect)(()=>
31{if(u&&null===p.current&&(p.current=Date.now()),!u&&null!==p.current)return void h((Date.now()-p.current)/1e3);if(!u)return;let e=setInterval(()=>{null!==p.current&&h((Date.now()-p.current)/1e3)},1e3);return()=>clearInterval(e)},[u]);let[g,m]=(0,v.useState)(u);(0,v.useEffect)(()=>{u?m(!0):m(!1)},[u]);let y=u?"Thinkingâ¦":`Thought for ${function(e){if(e<1)return"a few seconds";if(e<60)return`${Math.round(e)} seconds`;let t=Math.floor(e/60),n=Math.round(e%60);return 0===n?`${t} minute${t>1?"s":""}`:`${t}m ${n}s`}(f)}`,k=nr(r,nX.Header,{isOpen:g,label:y,hasContent:d,isStreaming:u,onClick:d?()=>m(e=>!e):void 0}),b=nr(i,nX.Content,{isStreaming:u,hasContent:d,children:e.content}),x=nr(o,nX.Toggle,{isOpen:g,children:b});return a?(0,w.jsx)("div",{"data-copilotkit":!0,style:{display:"contents"},children:a({header:k,contentView:b,toggle:x,message:e,messages:t,isRunning:n})}):(0,w.jsxs)("div",{className:(0,N.twMerge)("cpk:my-1",s),"data-message-id":e.id,...l,children:[k,x]})}(i0=nX||(nX={})).Header=({isOpen:e,label:t="Thoughts",hasContent:n,isStreaming:r,className:i,children:o,...a})=>{let s=!!n;return(0,w.jsxs)("button",{type:"button",className:(0,N.twMerge)("cpk:inline-flex cpk:items-center cpk:gap-1 cpk:py-1 cpk:text-sm cpk:text-muted-foreground cpk:transition-colors cpk:select-none",s?"cpk:hover:text-foreground cpk:cursor-pointer":"cpk:cursor-default",i),"aria-expanded":s?e:void 0,...a,children:[(0,w.jsx)("span",{className:"cpk:font-medium",children:t}),r&&!n&&(0,w.jsx)("span",{className:"cpk:inline-flex cpk:items-center cpk:ml-1",children:(0,w.jsx)("span",{className:"cpk:w-1.5 cpk:h-1.5 cpk:rounded-full cpk:bg-muted-foreground cpk:animate-pulse"})}),o,s&&(0,w.jsx)(V,{className:(0,N.twMerge)("cpk:size-3.5 cpk:shrink-0 cpk:transition-transform cpk:duration-200",e&&"cpk:rotate-90")})]})},i0.Content=({isStreaming:e,hasContent:t,className:n,children:r,...i})=>t||e?(0,w.jsx)("div",{className:(0,N.twMerge)("cpk:pb-2 cpk:pt-1",n),...i,children:(0,w.jsxs)("div",{className:"cpk:text-sm cpk:text-muted-foreground",children:[(0,w.jsx)(nH.i,{children:"string"==typeof r?r:""}),e&&t&&(0,w.jsx)("span",{className:"cpk:inline-flex cpk:items-center cpk:ml-1 cpk:align-middle",children:(0,w.jsx)("span",{className:"cpk:w-2 cpk:h-2 cpk:rounded-full cpk:bg-muted-foreground cpk:animate-pulse-cursor"})})]})}):null,i0.Toggle=({isOpen:e,className:t,children:n,...r})=>(0,w.jsx)("div",{className:(0,N.twMerge)("cpk:grid cpk:transition-[grid-template-rows] cpk:duration-200 cpk:ease-in-out",t),style:{gridTemplateRows:e?"1fr":"0fr"},...r,children:(0,w.jsx)("div",{className:"cpk:overflow-hidden",children:n})}),nX.Header.displayName="CopilotChatReasoningMessage.Header",nX.Content.displayName="CopilotChatReasoningMessage.Content",nX.Toggle.displayName="CopilotChatReasoningMessage.Toggle";var nY=nX;let nQ=v.default.forwardRef(function({className:e,children:t,icon:n,isLoading:r,type:i,...o},a){let s=!r&&n;return(0,w.jsxs)("button",{ref:a,"data-copilotkit":!0,"data-testid":"copilot-suggestion","data-slot":"suggestion-pill",className:M("group cpk:inline-flex cpk:h-7 cpk:sm:h-8 cpk:items-center cpk:gap-1 cpk:sm:gap-1.5 cpk:rounded-full cpk:border cpk:border-border/60 cpk:bg-background cpk:px-2.5 cpk:sm:px-3 cpk:text-[11px] cpk:sm:text-xs cpk:leading-none cpk:text-foreground cpk:transition-colors cpk:cursor-pointer cpk:hover:bg-accent/60 cpk:hover:text-foreground cpk:focus-visible:outline-none cpk:focus-visible:ring-2 cpk:focus-visible:ring-ring cpk:focus-visible:ring-offset-2 cpk:focus-visible:ring-offset-background cpk:disabled:cursor-not-allowed cpk:disabled:text-muted-foreground cpk:disabled:hover:bg-background cpk:disabled:hover:text-muted-foreground cpk:pointer-events-auto",e),type:i??"button","aria-busy":r||void 0,disabled:r||o.disabled,...o,children:[r?(0,w.jsx)("span",{className:"cpk:flex cpk:h-3.5 cpk:sm:h-4 cpk:w-3.5 cpk:sm:w-4 cpk:items-center cpk:justify-center cpk:text-muted-foreground",children:(0,w.jsx)(na,{className:"cpk:h-3.5 cpk:sm:h-4 cpk:w-3.5 cpk:sm:w-4 cpk:animate-spin","aria-hidden":"true"})}):s&&(0,w.jsx)("span",{className:"cpk:flex cpk:h-3.5 cpk:sm:h-4 cpk:w-3.5 cpk:sm:w-4 cpk:items-center cpk:justify-center cpk:text-muted-foreground",children:n}),(0,w.jsx)("span",{className:"cpk:whitespace-nowrap cpk:font-medium cpk:leading-none",children:t})]})});nQ.displayName="CopilotChatSuggestionPill";let nZ=v.default.forwardRef(function({className:e,...t},n){return(0,w.jsx)("div",{ref:n,"data-copilotkit":!0,"data-testid":"copilot-suggestions",className:M("cpk:flex cpk:flex-wrap cpk:items-center cpk:gap-1.5 cpk:sm:gap-2 cpk:pl-0 cpk:pr-4 cpk:sm:px-0 cpk:pointer-events-none",e),...t})}),n0=v.default.forwardRef(function({suggestions:e,onSelectSuggestion:t,loadingIndexes:n,container:r,suggestion:i,className:o,children:a,...s},l){let c=v.default.useMemo(()=>n&&0!==n.length?new Set(n):new Set,[n]),u=nr(r,nZ,{ref:l,className:o,...s}),d=e.map((e,n)=>{let r=c.has(n)||!0===e.isLoading,o=nr(i,nQ,{children:e.title,isLoading:r,type:"button",onClick:()=>t?.(e,n)});
31return v.default.cloneElement(o,{key:`${e.title}-${n}`})}),p=v.default.cloneElement(u,void 0,d);if("function"==typeof a){let r=nr(i,nQ,{children:e[0]?.title??"",isLoading:e.length>0&&(c.has(0)||e[0]?.isLoading===!0),type:"button"});return(0,w.jsx)("div",{"data-copilotkit":!0,style:{display:"contents"},children:a({container:p,suggestion:r,suggestions:e,onSelectSuggestion:t,loadingIndexes:n,className:o,...s})})}return a?(0,w.jsxs)("div",{"data-copilotkit":!0,style:{display:"contents"},children:[p,a]}):p});n0.displayName="CopilotChatSuggestionView";let n1=v.default.memo(function({message:e,messages:t,isRunning:n,AssistantMessageComponent:r,slotProps:i}){return(0,w.jsx)(r,{message:e,messages:t,isRunning:n,...i})},(e,t)=>{if(e.message.id!==t.message.id||e.message.content!==t.message.content)return!1;let n=e.message.toolCalls,r=t.message.toolCalls;if(n?.length!==r?.length)return!1;if(n&&r)for(let e=0;e<n.length;e++){let t=n[e],i=r[e];if(!t||!i||t.id!==i.id||t.function.arguments!==i.function.arguments)return!1}if(n&&n.length>0){let r=new Set(n.map(e=>e.id)),i=e.messages.filter(e=>"tool"===e.role&&r.has(e.toolCallId)),o=t.messages.filter(e=>"tool"===e.role&&r.has(e.toolCallId));if(i.length!==o.length)return!1;for(let e=0;e<i.length;e++)if(i[e].content!==o[e].content)return!1}return(t.messages[t.messages.length-1]?.id!==t.message.id||e.isRunning===t.isRunning)&&e.AssistantMessageComponent===t.AssistantMessageComponent&&e.slotProps===t.slotProps}),n2=v.default.memo(function({message:e,UserMessageComponent:t,slotProps:n}){return(0,w.jsx)(t,{message:e,...n})},(e,t)=>e.message.id===t.message.id&&e.message.content===t.message.content&&e.UserMessageComponent===t.UserMessageComponent&&e.slotProps===t.slotProps),n5=v.default.memo(function({message:e,renderActivityMessage:t}){return t(e)},(e,t)=>e.message.id===t.message.id&&e.message.activityType===t.message.activityType&&JSON.stringify(e.message.content)===JSON.stringify(t.message.content)),n4=v.default.memo(function({message:e,messages:t,isRunning:n,ReasoningMessageComponent:r,slotProps:i}){return(0,w.jsx)(r,{message:e,messages:t,isRunning:n,...i})},(e,t)=>{if(e.message.id!==t.message.id||e.message.content!==t.message.content)return!1;let n=e.messages[e.messages.length-1]?.id===e.message.id,r=t.messages[t.messages.length-1]?.id===t.message.id;return n===r&&(!r||e.isRunning===t.isRunning)&&e.ReasoningMessageComponent===t.ReasoningMessageComponent&&e.slotProps===t.slotProps}),n3=v.default.memo(function({message:e,position:t,renderCustomMessage:n}){return n({message:e,position:t})},(e,t)=>e.message.id===t.message.id&&e.position===t.position&&e.message.content===t.message.content&&e.message.role===t.message.role&&JSON.stringify(e.stateSnapshot)===JSON.stringify(t.stateSnapshot));function n6({messages:e=[],assistantMessage:t,userMessage:n,reasoningMessage:r,cursor:i,isRunning:o=!1,children:a,className:s,...l}){let c=nR(),{renderActivityMessage:u}=function(){let{copilotkit:e}=nA(),t=T()?.agentId??b.DEFAULT_AGENT_ID,n=e.renderActivityMessages,r=(0,v.useCallback)(e=>{if(!n.length)return null;let r=n.filter(t=>t.activityType===e);return r.find(e=>e.agentId===t)??r.find(e=>void 0===e.agentId)??n.find(e=>"*"===e.activityType)??null},[t,n]),i=(0,v.useCallback)(n=>{let i=r(n.activityType);if(!i)return null;let o=i.content.safeParse(n.content);if(!o.success)return console.warn(`Failed to parse content for activity message '${n.activityType}':`,o.error),null;let a=i.render,s=e.getAgent(t);return(0,w.jsx)(a,{activityType:n.activityType,content:o.data,message:n,agent:s},n.id)},[t,e,r]);return(0,v.useMemo)(()=>({renderActivityMessage:i,findRenderer:r}),[i,r])}(),{copilotkit:d}=nA(),p=T(),[,f]=(0,v.useReducer)(e=>e+1,0);(0,v.useEffect)(()=>{if(!p?.agentId)return;let e=d.getAgent(p.agentId);if(!e)return;let t=e.subscribe({onStateChanged:f});return()=>t.unsubscribe()},[p?.agentId,d,f]);let[h,g]=(0,v.useState)(null);(0,v.useEffect)(()=>{g(d.interruptElement);let e=d.subscribe({onInterruptElementChanged:({interruptElement:e})=>{g(e)}});return()=>e.unsubscribe()},[d]);let m=e.flatMap(i=>{let a=[],s=(e=>{if(!p)return;let t=d.getRunIdForMessage(p.agentId,p.threadId,e)??d.getRunIdsForThread(p.agentId,p.threadId).slice(-1)[0];if(t)return d.getStateByRun(p.agentId,p.threadId,t)})(i.id);if(c&&a.push((0,w.jsx)(n3,{message:i,position:"before",renderCustomMessage:c,stateSnapshot:s},`${i.id}-custom-before`)),"assistant"===i.role){let n,r=nG;nt(t)?r=t:"string"==typeof t?n={className:t}:t&&"object"==typeof t&&(n=t),a.push((0,w.jsx)(n1,{message:i,messages:e,isRunning:o,AssistantMessageComponent:r,slotProps:n},i.id))}else if("user"===i.role){let e,t=nJ;nt(n)?t=n:"string"==typeof n?e={className:n}:n&&"object"==typeof n&&(e=n),a.push((0,w.jsx)(n2,{message:i,UserMessageComponent:t,slotProps:e},i.id))}else if("activity"===i.role)a.push((0,w.jsx)(n5,{message:i,renderActivityMessage:u},i.id));else if("reasoning"===i.role){let t,n=nY;nt(r)?n=r:"string"==typeof r?t={className:r}:r&&"object"==typeof r&&(t=r),a.push((0,w.jsx)(n4,{message:i,messages:e,isRunning:o,ReasoningMessageComponent:n,slotProps:t},i.id))}return c&&a.push((0,w.jsx)(n3,{message:i,position:"after",renderCustomMessage:c,stateSnapshot:s},`${i.id}-custom-after`)),a}
31).filter(Boolean);if(a)return(0,w.jsx)("div",{"data-copilotkit":!0,style:{display:"contents"},children:a({messageElements:m,messages:e,isRunning:o,interruptElement:h})});let y=e[e.length-1],k=o&&y?.role!=="reasoning";return(0,w.jsxs)("div",{"data-copilotkit":!0,"data-testid":"copilot-message-list",className:(0,N.twMerge)("cpk:flex cpk:flex-col",s),...l,children:[m,h,k&&(0,w.jsx)("div",{className:"cpk:mt-2",children:nr(i,n6.Cursor,{})})]})}n6.Cursor=function({className:e,...t}){return(0,w.jsx)("div",{"data-testid":"copilot-loading-cursor",className:(0,N.twMerge)("cpk:w-[11px] cpk:h-[11px] cpk:rounded-full cpk:bg-foreground cpk:animate-pulse-cursor cpk:ml-1",e),...t})};let n8=G("chevron-down",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]),n9={damping:.7,stiffness:.05,mass:1.25},n7=1e3/60,re=!1;globalThis.document?.addEventListener("mousedown",()=>{re=!0}),globalThis.document?.addEventListener("mouseup",()=>{re=!1}),globalThis.document?.addEventListener("click",()=>{re=!1});let rt=(e={})=>{let[t,n]=(0,v.useState)(!1),[r,i]=(0,v.useState)(!1!==e.initial),[o,a]=(0,v.useState)(!1),s=(0,v.useRef)(null);s.current=e;let l=(0,v.useCallback)(()=>{if(!re)return!1;let e=window.getSelection();if(!e||!e.rangeCount)return!1;let t=e.getRangeAt(0);return t.commonAncestorContainer.contains(m.current)||m.current?.contains(t.commonAncestorContainer)},[]),c=(0,v.useCallback)(e=>{d.isAtBottom=e,i(e)},[]),u=(0,v.useCallback)(e=>{d.escapedFromLock=e,n(e)},[]),d=(0,v.useMemo)(()=>{let n;return{escapedFromLock:t,isAtBottom:r,resizeDifference:0,accumulated:0,velocity:0,listeners:new Set,get scrollTop(){return m.current?.scrollTop??0},set scrollTop(scrollTop){m.current&&(m.current.scrollTop=scrollTop,d.ignoreScrollToTop=m.current.scrollTop)},get targetScrollTop(){if(!m.current||!y.current)return 0;return m.current.scrollHeight-1-m.current.clientHeight},get calculatedTargetScrollTop(){if(!m.current||!y.current)return 0;let{targetScrollTop:t}=this;if(!e.targetScrollTop)return t;if(n?.targetScrollTop===t)return n.calculatedScrollTop;let r=Math.max(Math.min(e.targetScrollTop(t,{scrollElement:m.current,contentElement:y.current}),t),0);return n={targetScrollTop:t,calculatedScrollTop:r},requestAnimationFrame(()=>{n=void 0}),r},get scrollDifference(){return this.calculatedTargetScrollTop-this.scrollTop},get isNearBottom(){return this.scrollDifference<=70}}},[]),p=(0,v.useCallback)((e={})=>{let t;"string"==typeof e&&(e={animation:e}),e.preserveScrollPosition||c(!0);let n=Date.now()+(Number(e.wait)||0),r=ri(s.current,e.animation),{ignoreEscapes:i=!1}=e,o=d.calculatedTargetScrollTop;e.duration instanceof Promise?e.duration.finally(()=>{t=Date.now()}):t=n+(e.duration??0);let a=async()=>{let e=new Promise(requestAnimationFrame).then(()=>{if(!d.isAtBottom)return d.animation=void 0,!1;let{scrollTop:c}=d,u=performance.now(),f=(u-(d.lastTick??u))/n7;if(d.animation||(d.animation={behavior:r,promise:e,ignoreEscapes:i}),d.animation.behavior===r&&(d.lastTick=u),l()||n>Date.now())return a();if(c<Math.min(o,d.calculatedTargetScrollTop)){if(d.animation?.behavior===r){if("instant"===r)return d.scrollTop=d.calculatedTargetScrollTop,a();d.velocity=(r.damping*d.velocity+r.stiffness*d.scrollDifference)/r.mass,d.accumulated+=d.velocity*f,d.scrollTop+=d.accumulated,d.scrollTop!==c&&(d.accumulated=0)}return a()}return t>Date.now()?(o=d.calculatedTargetScrollTop,a()):(d.animation=void 0,d.scrollTop<d.calculatedTargetScrollTop)?p({animation:ri(s.current,s.current.resize),ignoreEscapes:i,duration:Math.max(0,t-Date.now())||void 0}):d.isAtBottom});return e.then(e=>(requestAnimationFrame(()=>{d.animation||(d.lastTick=void 0,d.velocity=0)}),e))};return(!0!==e.wait&&(d.animation=void 0),d.animation?.behavior===r)?d.animation.promise:a()},[c,l,d]),f=(0,v.useCallback)(()=>{u(!0),c(!1)},[u,c]),h=(0,v.useCallback)(({target:e})=>{if(e!==m.current)return;let{scrollTop:t,ignoreScrollToTop:n}=d,{lastScrollTop:r=t}=d;d.lastScrollTop=t,d.ignoreScrollToTop=void 0,n&&n>t&&(r=n),a(d.isNearBottom),setTimeout(()=>{if(d.resizeDifference||t===n)return;if(l()){u(!0),c(!1);return}let e=t>r,i=t<r;if(d.animation?.ignoreEscapes){d.scrollTop=r;return}i&&(u(!0),c(!1)),e&&u(!1),!d.escapedFromLock&&d.isNearBottom&&c(!0)},1)},[u,c,l,d]),g=(0,v.useCallback)(({target:e,deltaY:t})=>{let n=e;for(;!["scroll","auto"].includes(getComputedStyle(n).overflow);){if(!n.parentElement)return;n=n.parentElement}n===m.current&&t<0&&m.current.scrollHeight>m.current.clientHeight&&!d.animation?.ignoreEscapes&&(u(!0),c(!1))},[u,c,d]),m=rn(e=>{m.current?.removeEventListener("scroll",h),m.current?.removeEventListener("wheel",g),e?.addEventListener("scroll",h,{passive:!0}),e?.addEventListener("wheel",g,{passive:!0})},[]),y=rn(e=>{let t;d.resizeObserver?.disconnect(),e&&(d.resizeObserver=new ResizeObserver(([e])=>{let{height:n}=e.contentRect,r=n-(t??n);if(d.resizeDifference=r,d.scrollTop>d.targetScrollTop&&(d.scrollTop=d.targetScrollTop),a(d.isNearBottom),r>=0){let e=ri(s.current,t?s.current.resize:s.current.initial);p({animation:e,wait:!0,preserveScrollPosition:!0,duration:"instant"===e?void 0:350})}else d.isNearBottom&&(u(!1),c(!0));t=n,requestAnimationFrame(()=>{setTimeout(()=>{d.resizeDifference===r&&(d.resizeDifference=0)},1)})}),d.resizeObserver?.observe(e))},[]);return{contentRef:y,scrollRef:m,scrollToBottom:p,stopScroll:f,isAtBottom:r||o,isNearBottom:o,escapedFromLock:t,state:d}};function rn(e,t){let n=(0,v.useCallback)(t=>(n.current=t,e(t)),t);return n}let rr=new Map;function ri(...e){let t={...n9},n=!1;for(let r of e){if("instant"===r){n=!0;continue}"object"==typeof r&&(n=!1,t.damping=r.damping??t.damping,t.stiffness=r.stiffness??t.stiffness,t.mass=r.mass??t.mass)}let r=JSON.stringify(t);return rr.has(r)||rr.set(r,Object.freeze(t)),n?"instant":rr.get(r)}let ro=(0,v.createContext)(null),ra="undefined"!=typeof window?v.useLayoutEffect:v.useEffect;function rs({instance:e,children:t,resize:n,initial:r,mass:i,damping:o,stiffness:a,targetScrollTop:s,contextRef:l,...c}){let u=(0,v.useRef)(null),d=rt({mass:i,damping:o,stiffness:a,resize:n,initial:r,targetScrollTop:v.useCallback((e,t)=>{let n=b?.targetScrollTop??s;return n?.(e,t)??e},[s])}),{scrollRef:p,contentRef:f,scrollToBottom:h,stopScroll:g,isAtBottom:m,escapedFromLock:y,state:k}=e??d,b=(0,v.useMemo)(()=>({scrollToBottom:h,stopScroll:g,scrollRef:p,isAtBottom:m,escapedFromLock:y,contentRef:f,state:k,get targetScrollTop(){return u.current},set targetScrollTop(targetScrollTop){u.current=targetScrollTop}}),[h,m,f,p,g,y,k]);return(0,v.useImperativeHandle)(l,()=>b,[b]),ra(()=>{p.current&&"visible"===getComputedStyle(p.current).overflow&&(p.current.style.overflow="auto")},[]),v.createElement(ro.Provider,{value:b},v.createElement("div",{...c},"function"==typeof t?t(b):t))}function rl(){let e=(0,v.useContext)(ro);if(!e)throw Error("use-stick-to-bottom component context must be used within a StickToBottom component");return e}function rc({messageView:e,input:t,scrollView:n,suggestionView:r,wel
31comeScreen:i,messages:o=[],autoScroll:a=!0,isRunning:s=!1,suggestions:l,suggestionLoadingIndexes:c,onSelectSuggestion:u,onSubmitMessage:d,onStop:p,inputMode:f,inputValue:h,onInputChange:g,onStartTranscribe:m,onCancelTranscribe:y,onFinishTranscribe:k,onFinishTranscribeWithAudio:b,children:x,className:E,...S}){let C=(0,v.useRef)(null),[T,A]=(0,v.useState)(0),[_,I]=(0,v.useState)(!1),R=(0,v.useRef)(null),{isKeyboardOpen:M,keyboardHeight:O,availableHeight:j}=function(){let[e,t]=(0,v.useState)({isKeyboardOpen:!1,keyboardHeight:0,availableHeight:"undefined"!=typeof window?window.innerHeight:0,viewportHeight:"undefined"!=typeof window?window.innerHeight:0});return(0,v.useEffect)(()=>{if("undefined"==typeof window)return;let e=window.visualViewport;if(!e)return;let n=()=>{let n=window.innerHeight,r=e.height,i=Math.max(0,n-r);t({isKeyboardOpen:i>150,keyboardHeight:i,availableHeight:r,viewportHeight:n})};return n(),e.addEventListener("resize",n),e.addEventListener("scroll",n),()=>{e.removeEventListener("resize",n),e.removeEventListener("scroll",n)}},[]),e}();(0,v.useEffect)(()=>{let e=C.current;if(!e)return;let t=new ResizeObserver(e=>{for(let t of e){let e=t.contentRect.height;A(t=>e!==t?(I(!0),R.current&&clearTimeout(R.current),R.current=setTimeout(()=>{I(!1)},250),e):t)}});return t.observe(e),A(e.offsetHeight),()=>{t.disconnect(),R.current&&clearTimeout(R.current)}},[]);let z=nr(e,n6,{messages:o,isRunning:s}),D=nr(t,np,{onSubmitMessage:d,onStop:p,mode:f,value:h,onChange:g,isRunning:s,onStartTranscribe:m,onCancelTranscribe:y,onFinishTranscribe:k,onFinishTranscribeWithAudio:b,positioning:"absolute",keyboardHeight:M?O:0,containerRef:C,showDisclaimer:!0}),P=Array.isArray(l)&&l.length>0,F=P?nr(r,n0,{suggestions:l,loadingIndexes:c,onSelectSuggestion:u,className:"cpk:mb-3 cpk:lg:ml-4 cpk:lg:mr-4 cpk:ml-0 cpk:mr-0"}):null,L=nr(n,rc.ScrollView,{autoScroll:a,inputContainerHeight:T,isResizing:_,children:(0,w.jsx)("div",{style:{paddingBottom:`${T+96+(P?4:32)}px`},children:(0,w.jsxs)("div",{className:"cpk:max-w-3xl cpk:mx-auto",children:[z,P?(0,w.jsx)("div",{className:"cpk:pl-0 cpk:pr-4 cpk:sm:px-0 cpk:mt-4",children:F}):null]})})});if(0===o.length&&!1!==i){let e=nr(t,np,{onSubmitMessage:d,onStop:p,mode:f,value:h,onChange:g,isRunning:s,onStartTranscribe:m,onCancelTranscribe:y,onFinishTranscribe:k,onFinishTranscribeWithAudio:b,positioning:"static",showDisclaimer:!0}),n=nr(!0===i?void 0:i,rc.WelcomeScreen,{input:e,suggestionView:F??(0,w.jsx)(w.Fragment,{})});return(0,w.jsx)("div",{"data-copilotkit":!0,"data-testid":"copilot-chat","data-copilot-running":s?"true":"false",className:(0,N.twMerge)("cpk:relative cpk:h-full cpk:flex cpk:flex-col",E),...S,children:n})}return x?(0,w.jsx)("div",{"data-copilotkit":!0,style:{display:"contents"},children:x({messageView:z,input:D,scrollView:L,suggestionView:F??(0,w.jsx)(w.Fragment,{})})}):(0,w.jsxs)("div",{"data-copilotkit":!0,"data-testid":"copilot-chat","data-copilot-running":s?"true":"false",className:(0,N.twMerge)("cpk:relative cpk:h-full",E),...S,children:[L,D]})}(rs||(rs={})).Content=function({children:e,scrollClassName:t,...n}){let r=rl();return v.createElement("div",{ref:r.scrollRef,style:{height:"100%",width:"100%",scrollbarGutter:"stable both-edges"},className:t},v.createElement("div",{...n,ref:r.contentRef},"function"==typeof e?e(r):e))},i1=rc||(rc={}),a=({children:e,scrollToBottomButton:t,feather:n,inputContainerHeight:r,isResizing:i})=>{let{isAtBottom:o,scrollToBottom:a}=rl(),s=nr(n,rc.Feather,{});return(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(rs.Content,{className:"cpk:overflow-y-scroll cpk:overflow-x-hidden",style:{flex:"1 1 0%",minHeight:0},children:(0,w.jsx)("div",{className:"cpk:px-4 cpk:sm:px-0 cpk:[div[data-sidebar-chat]_&]:px-8 cpk:[div[data-popup-chat]_&]:px-6",children:e})}),s,!o&&!i&&(0,w.jsx)("div",{className:"cpk:absolute cpk:inset-x-0 cpk:flex cpk:justify-center cpk:z-30 cpk:pointer-events-none",style:{bottom:`${r+96+16}px`},children:nr(t,rc.ScrollToBottomButton,{onClick:()=>a()})})]})},i1.ScrollView=({children:e,autoScroll:t=!0,scrollToBottomButton:n,feather:r,inputContainerHeight:i=0,isResizing:o=!1,className:s,...l})=>{let[c,u]=(0,v.useState)(!1),{scrollRef:d,contentRef:p,scrollToBottom:f}=rt(),[h,g]=(0,v.useState)(!1);if((0,v.useEffect)(()=>{u(!0)},[]),(0,v.useEffect)(()=>
31{if(t)return;let e=d.current;if(!e)return;let n=()=>{g(!(e.scrollHeight-e.scrollTop-e.clientHeight<10))};n(),e.addEventListener("scroll",n);let r=new ResizeObserver(n);return r.observe(e),()=>{e.removeEventListener("scroll",n),r.disconnect()}},[d,t]),!c)return(0,w.jsx)("div",{className:"cpk:h-full cpk:max-h-full cpk:flex cpk:flex-col cpk:min-h-0 cpk:overflow-y-scroll cpk:overflow-x-hidden",children:(0,w.jsx)("div",{className:"cpk:px-4 cpk:sm:px-0 cpk:[div[data-sidebar-chat]_&]:px-8 cpk:[div[data-popup-chat]_&]:px-6",children:e})});if(!t){let t=nr(r,rc.Feather,{});return(0,w.jsxs)("div",{ref:d,className:M("cpk:h-full cpk:max-h-full cpk:flex cpk:flex-col cpk:min-h-0 cpk:overflow-y-scroll cpk:overflow-x-hidden cpk:relative",s),...l,children:[(0,w.jsx)("div",{ref:p,className:"cpk:px-4 cpk:sm:px-0 cpk:[div[data-sidebar-chat]_&]:px-8 cpk:[div[data-popup-chat]_&]:px-6",children:e}),t,h&&!o&&(0,w.jsx)("div",{className:"cpk:absolute cpk:inset-x-0 cpk:flex cpk:justify-center cpk:z-30 cpk:pointer-events-none",style:{bottom:`${i+96+16}px`},children:nr(n,rc.ScrollToBottomButton,{onClick:()=>f()})})]})}return(0,w.jsx)(rs,{className:M("cpk:h-full cpk:max-h-full cpk:flex cpk:flex-col cpk:min-h-0 cpk:relative",s),resize:"smooth",initial:"smooth",...l,children:(0,w.jsx)(a,{scrollToBottomButton:n,feather:r,inputContainerHeight:i,isResizing:o,children:e})})},i1.ScrollToBottomButton=({className:e,...t})=>(0,w.jsx)(z,{"data-testid":"copilot-scroll-to-bottom",variant:"outline",size:"sm",className:(0,N.twMerge)("cpk:rounded-full cpk:w-10 cpk:h-10 cpk:p-0 cpk:pointer-events-auto","cpk:bg-white cpk:dark:bg-gray-900","cpk:shadow-lg cpk:border cpk:border-gray-200 cpk:dark:border-gray-700","cpk:hover:bg-gray-50 cpk:dark:hover:bg-gray-800","cpk:flex cpk:items-center cpk:justify-center cpk:cursor-pointer",e),...t,children:(0,w.jsx)(n8,{className:"cpk:w-4 cpk:h-4 cpk:text-gray-600 cpk:dark:text-white"})}),i1.Feather=({className:e,style:t,...n})=>(0,w.jsx)("div",{className:M("cpk:absolute cpk:bottom-0 cpk:left-0 cpk:right-4 cpk:h-24 cpk:pointer-events-none cpk:z-10 cpk:bg-gradient-to-t","cpk:from-white cpk:via-white cpk:to-transparent","cpk:dark:from-[rgb(33,33,33)] cpk:dark:via-[rgb(33,33,33)]",e),style:t,...n}),i1.WelcomeMessage=({className:e,...t})=>{let n=T()?.labels??E;return(0,w.jsx)("h1",{className:M("cpk:text-xl cpk:sm:text-2xl cpk:font-medium cpk:text-foreground cpk:text-center",e),...t,children:n.welcomeMessageText})},i1.WelcomeScreen=({welcomeMessage:e,input:t,suggestionView:n,className:r,children:i,...o})=>{let a=nr(e,rc.WelcomeMessage,{});return i?(0,w.jsx)("div",{"data-copilotkit":!0,style:{display:"contents"},children:i({welcomeMessage:a,input:t,suggestionView:n,className:r,...o})}):(0,w.jsx)("div",{"data-testid":"copilot-welcome-screen",className:M("cpk:flex-1 cpk:flex cpk:flex-col cpk:items-center cpk:justify-center cpk:px-4",r),...o,children:(0,w.jsxs)("div",{className:"cpk:w-full cpk:max-w-3xl cpk:flex cpk:flex-col cpk:items-center",children:[(0,w.jsx)("div",{className:"cpk:mb-6",children:a}),(0,w.jsx)("div",{className:"cpk:w-full",children:t}),(0,w.jsx)("div",{className:"cpk:mt-4 cpk:flex cpk:justify-center",children:n})]})})};var ru=rc,rd=e.i(317674);async function rp(e){return new Promise((t,n)=>{let r=new FileReader;r.onloadend=()=>{t(r.result.split(",")[1]??"")},r.onerror=()=>n(Error("Failed to read audio data")),r.readAsDataURL(e)})}var rf=class extends Error{info;constructor(e){super(e.message),this.name="TranscriptionError",this.info=e}};async function rh(e,t,n="recording.webm"){let r,i=e.runtimeUrl;if(!i)throw new rf({code:rd.TranscriptionErrorCode.INVALID_REQUEST,message:"Runtime URL is not configured",retryable:!1});let o={...e.headers};try{if("single"===e.runtimeTransport){let e=await rp(t);o["Content-Type"]="application/json",r=await fetch(i,{method:"POST",headers:o,body:JSON.stringify({method:"transcribe",body:{audio:e,mimeType:t.type||"audio/webm",filename:n}})})}else{delete o["Content-Type"];let e=new FormData;e.append("audio",t,n),r=await fetch(`${i}/transcribe`,{method:"POST",headers:o,body:e})}}
31catch(e){throw new rf({code:rd.TranscriptionErrorCode.NETWORK_ERROR,message:e instanceof Error?e.message:"Network request failed",retryable:!0})}if(!r.ok){var a,s;let e;try{e=await r.json()}catch{throw new rf({code:rd.TranscriptionErrorCode.PROVIDER_ERROR,message:`HTTP ${r.status}: ${r.statusText}`,retryable:r.status>=500})}if("object"==typeof(a=e)&&null!==a&&"error"in a&&"message"in a&&"string"==typeof a.error&&"string"==typeof a.message)throw new rf({code:(s=e).error,message:s.message,retryable:s.retryable??!1});throw new rf({code:rd.TranscriptionErrorCode.PROVIDER_ERROR,message:"object"==typeof e&&null!==e&&"message"in e?String(e.message):"Transcription failed",retryable:r.status>=500})}return await r.json()}let rg=ny.z.object({name:ny.z.string(),arguments:ny.z.string()}),rm=ny.z.object({id:ny.z.string(),type:ny.z.literal("function"),function:rg,encryptedValue:ny.z.string().optional()}),ry=ny.z.object({id:ny.z.string(),role:ny.z.string(),content:ny.z.string().optional(),name:ny.z.string().optional(),encryptedValue:ny.z.string().optional()}),rk=ny.z.object({type:ny.z.literal("text"),text:ny.z.string()}),rv=ny.z.object({type:ny.z.literal("binary"),mimeType:ny.z.string(),id:ny.z.string().optional(),url:ny.z.string().optional(),data:ny.z.string().optional(),filename:ny.z.string().optional()}),rb=(e,t)=>{e.id||e.url||e.data||t.addIssue({code:ny.z.ZodIssueCode.custom,message:"BinaryInputContent requires at least one of id, url, or data.",path:["id"]})};rv.superRefine((e,t)=>{rb(e,t)});let rx=ny.z.discriminatedUnion("type",[rk,rv]).superRefine((e,t)=>{"binary"===e.type&&rb(e,t)}),rw=ry.extend({role:ny.z.literal("developer"),content:ny.z.string()}),rE=ry.extend({role:ny.z.literal("system"),content:ny.z.string()}),rS=ry.extend({role:ny.z.literal("assistant"),content:ny.z.string().optional(),toolCalls:ny.z.array(rm).optional()}),rC=ry.extend({role:ny.z.literal("user"),content:ny.z.union([ny.z.string(),ny.z.array(rx)])}),rT=ny.z.object({id:ny.z.string(),content:ny.z.string(),role:ny.z.literal("tool"),toolCallId:ny.z.string(),error:ny.z.string().optional(),encryptedValue:ny.z.string().optional()}),rN=ny.z.object({id:ny.z.string(),role:ny.z.literal("activity"),activityType:ny.z.string(),content:ny.z.record(ny.z.any())}),rA=ny.z.object({id:ny.z.string(),role:ny.z.literal("reasoning"),content:ny.z.string(),encryptedValue:ny.z.string().optional()}),r_=ny.z.discriminatedUnion("role",[rw,rE,rS,rC,rT,rN,rA]);ny.z.union([ny.z.literal("developer"),ny.z.literal("system"),ny.z.literal("assistant"),ny.z.literal("user"),ny.z.literal("tool"),ny.z.literal("activity"),ny.z.literal("reasoning")]);let rI=ny.z.object({description:ny.z.string(),value:ny.z.string()}),rR=ny.z.object({name:ny.z.string(),description:ny.z.string(),parameters:ny.z.any()}),rM=ny.z.object({threadId:ny.z.string(),runId:ny.z.string(),parentRunId:ny.z.string().optional(),state:ny.z.any(),messages:ny.z.array(r_),tools:ny.z.array(rR),context:ny.z.array(rI),forwardedProps:ny.z.any()}),rO=ny.z.any();var rj=class extends Error{constructor(e){super(e)}},rz=class extends rj{constructor(){super("Connect not implemented. This method is not supported by the current agent.")}};let rD=ny.z.union([ny.z.literal("developer"),ny.z.literal("system"),ny.z.literal("assistant"),ny.z.literal("user")]),rP=((i2={}).TEXT_MESSAGE_START="TEXT_MESSAGE_START",i2.TEXT_MESSAGE_CONTENT="TEXT_MESSAGE_CONTENT",i2.TEXT_MESSAGE_END="TEXT_MESSAGE_END",i2.TEXT_MESSAGE_CHUNK="TEXT_MESSAGE_CHUNK",i2.TOOL_CALL_START="TOOL_CALL_START",i2.TOOL_CALL_ARGS="TOOL_CALL_ARGS",i2.TOOL_CALL_END="TOOL_CALL_END",i2.TOOL_CALL_CHUNK="TOOL_CALL_CHUNK",i2.TOOL_CALL_RESULT="TOOL_CALL_RESULT",i2.THINKING_START="THINKING_START",i2.THINKING_END="THINKING_END",i2.THINKING_TEXT_MESSAGE_START="THINKING_TEXT_MESSAGE_START",i2.THINKING_TEXT_MESSAGE_CONTENT="THINKING_TEXT_MESSAGE_CONTENT",i2.THINKING_TEXT_MESSAGE_END="THINKING_TEXT_MESSAGE_END",i2.STATE_SNAPSHOT="STATE_
31SNAPSHOT",i2.STATE_DELTA="STATE_DELTA",i2.MESSAGES_SNAPSHOT="MESSAGES_SNAPSHOT",i2.ACTIVITY_SNAPSHOT="ACTIVITY_SNAPSHOT",i2.ACTIVITY_DELTA="ACTIVITY_DELTA",i2.RAW="RAW",i2.CUSTOM="CUSTOM",i2.RUN_STARTED="RUN_STARTED",i2.RUN_FINISHED="RUN_FINISHED",i2.RUN_ERROR="RUN_ERROR",i2.STEP_STARTED="STEP_STARTED",i2.STEP_FINISHED="STEP_FINISHED",i2.REASONING_START="REASONING_START",i2.REASONING_MESSAGE_START="REASONING_MESSAGE_START",i2.REASONING_MESSAGE_CONTENT="REASONING_MESSAGE_CONTENT",i2.REASONING_MESSAGE_END="REASONING_MESSAGE_END",i2.REASONING_MESSAGE_CHUNK="REASONING_MESSAGE_CHUNK",i2.REASONING_END="REASONING_END",i2.REASONING_ENCRYPTED_VALUE="REASONING_ENCRYPTED_VALUE",i2),rF=ny.z.object({type:ny.z.nativeEnum(rP),timestamp:ny.z.number().optional(),rawEvent:ny.z.any().optional()}).passthrough(),rL=rF.extend({type:ny.z.literal(rP.TEXT_MESSAGE_START),messageId:ny.z.string(),role:rD.default("assistant")}),rU=rF.extend({type:ny.z.literal(rP.TEXT_MESSAGE_CONTENT),messageId:ny.z.string(),delta:ny.z.string().refine(e=>e.length>0,"Delta must not be an empty string")}),rB=rF.extend({type:ny.z.literal(rP.TEXT_MESSAGE_END),messageId:ny.z.string()}),r$=rF.extend({type:ny.z.literal(rP.TEXT_MESSAGE_CHUNK),messageId:ny.z.string().optional(),role:rD.optional(),delta:ny.z.string().optional()}),rH=rF.extend({type:ny.z.literal(rP.THINKING_TEXT_MESSAGE_START)}),rK=rU.omit({messageId:!0,type:!0}).extend({type:ny.z.literal(rP.THINKING_TEXT_MESSAGE_CONTENT)}),rG=rF.extend({type:ny.z.literal(rP.THINKING_TEXT_MESSAGE_END)}),rV=rF.extend({type:ny.z.literal(rP.TOOL_CALL_START),toolCallId:ny.z.string(),toolCallName:ny.z.string(),parentMessageId:ny.z.string().optional()}),rW=rF.extend({type:ny.z.literal(rP.TOOL_CALL_ARGS),toolCallId:ny.z.string(),delta:ny.z.string()}),rq=rF.extend({type:ny.z.literal(rP.TOOL_CALL_END),toolCallId:ny.z.string()}),rJ=rF.extend({messageId:ny.z.string(),type:ny.z.literal(rP.TOOL_CALL_RESULT),toolCallId:ny.z.string(),content:ny.z.string(),role:ny.z.literal("tool").optional()}),rX=rF.extend({type:ny.z.literal(rP.TOOL_CALL_CHUNK),toolCallId:ny.z.string().optional(),toolCallName:ny.z.string().optional(),parentMessageId:ny.z.string().optional(),delta:ny.z.string().optional()}),rY=rF.extend({type:ny.z.literal(rP.THINKING_START),title:ny.z.string().optional()}),rQ=rF.extend({type:ny.z.literal(rP.THINKING_END)}),rZ=rF.extend({type:ny.z.literal(rP.STATE_SNAPSHOT),snapshot:rO}),r0=rF.extend({type:ny.z.literal(rP.STATE_DELTA),delta:ny.z.array(ny.z.any())}),r1=rF.extend({type:ny.z.literal(rP.MESSAGES_SNAPSHOT),messages:ny.z.array(r_)}),r2=rF.extend({type:ny.z.literal(rP.ACTIVITY_SNAPSHOT),messageId:ny.z.string(),activityType:ny.z.string(),content:ny.z.record(ny.z.any()),replace:ny.z.boolean().optional().default(!0)}),r5=rF.extend({type:ny.z.literal(rP.ACTIVITY_DELTA),messageId:ny.z.string(),activityType:ny.z.string(),patch:ny.z.array(ny.z.any())}),r4=rF.extend({type:ny.z.literal(rP.RAW),event:ny.z.any(),source:ny.z.string().optional()}),r3=rF.extend({type:ny.z.literal(rP.CUSTOM),name:ny.z.string(),value:ny.z.any()}),r6=rF.extend({type:ny.z.literal(rP.RUN_STARTED),threadId:ny.z.string(),runId:ny.z.string(),parentRunId:ny.z.string().optional(),input:rM.optional()}),r8=rF.extend({type:ny.z.literal(rP.RUN_FINISHED),threadId:ny.z.string(),runId:ny.z.string(),result:ny.z.any().optional()}),r9=rF.extend({type:ny.z.literal(rP.RUN_ERROR),message:ny.z.string(),code:ny.z.string().optional()}),r7=rF.extend({type:ny.z.literal(rP.STEP_STARTED),stepName:ny.z.string()}),ie=rF.extend({type:ny.z.literal(rP.STEP_FINISHED),stepName:ny.z.string()}),it=ny.z.union([ny.z.literal("tool-call"),ny.z.literal("message")]),ir=rF.extend({type:ny.z.literal(rP.REASONING_START),messageId:ny.z.string()}),ii=rF.extend({type:ny.z.literal(rP.REASONING_MESSAGE_START),messageId:ny.z.string(),role:ny.z.literal("reasoning")}),io=rF.extend({type:ny.z.literal(rP.REASONING_MESSAGE_CONTENT),messageId:ny.z.string(),delta:ny.z.string().refine(e=>e.length>0,"Delta must not be an empty string")}),ia=rF.extend({type:ny.z.literal(rP.REASONING_MESSAGE_END),messageId:ny.z.string()}),is=rF.extend({type:ny.z.literal(rP.REASONING_MESSAGE_CHUNK),messageId:ny.z.string().optional(),delta:ny.z.string().optional()}),il=rF.extend({type:ny.z.literal(rP.REASONING_END),messageId:ny.z.string()}),ic=rF.extend({type:ny.z.literal(rP.REASONING_ENCRYPTED_VALUE),subtype:it,entityId:ny.z.string(),encryptedValue:ny.z.string()});ny.z.discriminatedUnion("type",[rL,rU,rB,r$,rY,rQ,rH,rK,rG,rV,rW,rq,rX,rJ,rZ,r0,r1,r2,r5,r4,r3,r6,r8,r9,r7,ie,ir,ii,io,ia,is,il,ic]);let iu=e=>{if("object"==typeof e&&null!==e){if("function"==typeof Object.getPrototypeOf){let t=Object.getPrototypeOf(e);return t===Object.prototype||null===t}return"[object Object]"===Object.prototype.toString.call(e)}return!1},id=(...e)=>e.reduce((e,t)=>
31{if(void 0===t)return e;if(Array.isArray(t))throw TypeError("Arguments provided to ts-deepmerge must be objects, not arrays.");return Object.keys(t).forEach(n=>{["__proto__","constructor","prototype"].includes(n)||(Array.isArray(e[n])&&Array.isArray(t[n])?e[n]=id.options.mergeArrays?id.options.uniqueArrayItems?Array.from(new Set(e[n].concat(t[n]))):[...e[n],...t[n]]:t[n]:iu(e[n])&&iu(t[n])?e[n]=id(e[n],t[n]):!iu(e[n])&&iu(t[n])?e[n]=id(t[n],void 0):e[n]=void 0===t[n]?id.options.allowUndefinedOverrides?t[n]:e[n]:t[n])}),e},{}),ip={allowUndefinedOverrides:!0,mergeArrays:!0,uniqueArrayItems:!0};function ih({agentId:e,threadId:t,labels:n,chatView:r,...i}){let o=T(),a=e??o?.agentId??b.DEFAULT_AGENT_ID,s=(0,v.useMemo)(()=>t??o?.threadId??(0,x.randomUUID)(),[t,o?.threadId]),{agent:l}=nj({agentId:a}),{copilotkit:c}=nA(),{suggestions:u}=nz({agentId:a}),[d,p]=(0,v.useState)("input"),[f,h]=(0,v.useState)(""),[g,m]=(0,v.useState)(null),[y,k]=(0,v.useState)(!1),E=c.audioFileTranscriptionEnabled,S="undefined"!=typeof window&&"undefined"!=typeof MediaRecorder,{messageView:N,suggestionView:A,onStop:_,...I}=i;(0,v.useEffect)(()=>{let e=async e=>{try{await c.connectAgent({agent:e})}catch(e){if(e instanceof rz);else throw e}};return l.threadId=s,e(l),()=>{}},[s,l,c,a]);let R=(0,v.useCallback)(async e=>{l.addMessage({id:(0,x.randomUUID)(),role:"user",content:e}),h("");try{await c.runAgent({agent:l})}catch(e){console.error("CopilotChat: runAgent failed",e)}},[l,c]),M=(0,v.useCallback)(async e=>{l.addMessage({id:(0,x.randomUUID)(),role:"user",content:e.message});try{await c.runAgent({agent:l})}catch(e){console.error("CopilotChat: runAgent failed after selecting suggestion",e)}},[l,c]),O=(0,v.useCallback)(()=>{try{c.stopAgent({agent:l})}catch(e){console.error("CopilotChat: stopAgent failed",e);try{l.abortRun()}catch(e){console.error("CopilotChat: abortRun fallback failed",e)}}},[l,c]),j=(0,v.useCallback)(()=>{m(null),p("transcribe")},[]),z=(0,v.useCallback)(()=>{m(null),p("input")},[]),D=(0,v.useCallback)(()=>{p("input")},[]),P=(0,v.useCallback)(async e=>{k(!0);try{m(null);let t=await rh(c,e);h(e=>{let n=e.trim();return n?`${n} ${t.text}`:t.text})}catch(e){if(console.error("CopilotChat: Transcription failed",e),e instanceof rf){let{code:t,retryable:n,message:r}=e.info;switch(t){case rd.TranscriptionErrorCode.RATE_LIMITED:m("Too many requests. Please wait a moment.");break;case rd.TranscriptionErrorCode.AUTH_FAILED:m("Authentication error. Please check your configuration.");break;case rd.TranscriptionErrorCode.AUDIO_TOO_LONG:m("Recording is too long. Please try a shorter recording.");break;case rd.TranscriptionErrorCode.AUDIO_TOO_SHORT:m("Recording is too short. Please try again.");break;case rd.TranscriptionErrorCode.INVALID_AUDIO_FORMAT:m("Audio format not supported.");break;case rd.TranscriptionErrorCode.SERVICE_NOT_CONFIGURED:m("Transcription service is not available.");break;case rd.TranscriptionErrorCode.NETWORK_ERROR:m("Network error. Please check your connection.");break;default:m(n?"Transcription failed. Please try again.":r)}}else m("Transcription failed. Please try again.")}finally{k(!1)}},[c]);(0,v.useEffect)(()=>{if(g){let e=setTimeout(()=>{m(null)},5e3);return()=>clearTimeout(e)}},[g]);let F=id({isRunning:l.isRunning,suggestions:u,onSelectSuggestion:M,suggestionView:A},{...I,..."string"==typeof N?{messageView:{className:N}}:void 0!==N?{messageView:N}:{}}),L=l.messages.length>0,U=l.isRunning&&L?_??O:_,B=E&&S,$=nr(r,rc,id(F,{messages:(0,v.useMemo)(()=>[...l.messages],[JSON.stringify(l.messages)]),onSubmitMessage:R,onStop:U,inputMode:y?"processing":d,inputValue:f,onInputChange:h,onStartTranscribe:B?j:void 0,onCancelTranscribe:B?z:void 0,onFinishTranscribe:B?D:void 0,onFinishTranscribeWithAudio:B?P:void 0}));return(0,w.jsxs)(C,{agentId:a,threadId:s,labels:n,children:[g&&(0,w.jsx)("div",{style:{position:"absolute",bottom:"100px",left:"50%",transform:"translateX(-50%)",backgroundColor:"#ef4444",color:"white",padding:"8px 16px",borderRadius:"8px",fontSize:"14px",zIndex:50},children:g}),$]})}id.options=ip,id.withOptions=(e,...t)=>{id.options=Object.assign(Object.assign({},ip),e);let n=id(...t);return id.options=ip,n},(ih||(ih={})).View=rc;let ig=G("message-circle",[["path",{d:"M7.9 20A9 9 0 1 0 4 16.1L2 22Z",key:"vv11sd"}]]),im=({className:e,...t})=>(0,w.jsx)(ig,{className:M("cpk:h-6 cpk:w-6",e),strokeWidth:1.75,fill:"currentColor",...t}),iy=({className:e,...t})=>(0,w.jsx)(nu,{className:M("cpk:h-6 cpk:w-6",e),strokeWidth:1.75,...t});im.displayName="CopilotChatToggleButton.OpenIcon",iy.displayName="CopilotChatToggleButton.CloseIcon";let ik=Object.freeze({transition:"opacity 120ms ease-out, transform 260ms cubic-bezier(0.22, 1, 0.36, 1)"}),iv="cpk:pointer-events-none cpk:absolute cpk:inset-0 cpk:flex cpk:items-center cpk:justify-center cpk:will-change-transform",ib=M("cpk:fixed cpk:bottom-6 cpk:right-6 cpk:z-[1100] cpk:flex cpk:h-14 cpk:w-14 cpk:items-center cpk:justify-center","cpk:rounded-full cpk:border cpk:border-primary cpk:bg-primary cpk:text-primary-foreground","cpk:shadow-sm cpk:transition-all cpk:duration-200 cpk:ease-out","cpk:hover:scale-[1.04] cpk:hover:shadow-md","cpk:cursor-pointer","cpk:active:scale-[0.96]","cpk:focus-visible:outline-none cpk:focus-visible:ring-2 cpk:focus-visible:ring-primary/50 cpk:focus-visible:ring-offset-2 cpk:focus-visible:ring-offset-background","cpk:disabled:pointer-events-none cpk:disabled:opacity-60"),ix=v.default.forwardRef(function({openIcon:e,closeIcon:t,className:n,...r},i){let{onClick:o,type:a,disabled:s,...l}=r,c=T(),u=c?.labels??E,[d,p]=(0,v.useState)(!1),f=c?.isModalOpen??d,h=c?.setModalOpen??p,g=nr(e,im,{className:"cpk:h-6 cpk:w-6","aria-hidden":!0,focusable:!1}),m=nr(t,iy,{className:"cpk:h-6 cpk:w-6","aria-hidden":!0,focusable:!1}),y=(0,w.jsx)("span",{"aria-hidden":"true","data-slot":"chat-toggle-button-open-icon",className:iv,style:{...ik,op
31acity:+!f,transform:`scale(${f?.75:1}) rotate(${90*!!f}deg)`},children:g}),k=(0,w.jsx)("span",{"aria-hidden":"true","data-slot":"chat-toggle-button-close-icon",className:iv,style:{...ik,opacity:+!!f,transform:`scale(${f?1:.75}) rotate(${f?0:-90}deg)`},children:m});return(0,w.jsxs)("button",{ref:i,type:a??"button","data-copilotkit":!0,"data-testid":"copilot-chat-toggle","data-slot":"chat-toggle-button","data-state":f?"open":"closed",className:M(ib,n),"aria-label":f?u.chatToggleCloseLabel:u.chatToggleOpenLabel,"aria-pressed":f,disabled:s,onClick:e=>{s||(o&&o(e),e.defaultPrevented||h(!f))},...l,children:[y,k]})});function iw({title:e,titleContent:t,closeButton:n,children:r,className:i,...o}){let a=T(),s=a?.labels.modalHeaderTitle??E.modalHeaderTitle,l=e??s,c=(0,v.useCallback)(()=>{a?.setModalOpen?.(!1)},[a]),u=nr(t,iw.Title,{children:l}),d=nr(n,iw.CloseButton,{onClick:c});return r?r({titleContent:u,closeButton:d,title:l,...o}):(0,w.jsx)("header",{"data-testid":"copilot-modal-header","data-slot":"copilot-modal-header",className:M("cpk:flex cpk:items-center cpk:justify-between cpk:border-b cpk:border-border cpk:px-4 cpk:py-4","cpk:bg-background/95 cpk:backdrop-blur cpk:supports-[backdrop-filter]:bg-background/80",i),...o,children:(0,w.jsxs)("div",{className:"cpk:flex cpk:w-full cpk:items-center cpk:gap-2",children:[(0,w.jsx)("div",{className:"cpk:flex-1","aria-hidden":"true"}),(0,w.jsx)("div",{className:"cpk:flex cpk:flex-1 cpk:justify-center cpk:text-center",children:u}),(0,w.jsx)("div",{className:"cpk:flex cpk:flex-1 cpk:justify-end",children:d})]})})}function iE({header:e,toggleButton:t,width:n,defaultOpen:r=!0,...i}){return(0,w.jsx)(C,{isModalDefaultOpen:r,children:(0,w.jsx)(iS,{header:e,toggleButton:t,width:n,...i})})}function iS({header:e,toggleButton:t,width:n,...r}){let i=T()?.isModalOpen??!1,o=(0,v.useRef)(null),[a,s]=(0,v.useState)(n??480);(0,v.useEffect)(()=>{if(void 0!==n||"undefined"==typeof window)return;let e=o.current;if(!e)return;let t=()=>{let t=e.getBoundingClientRect();t.width>0&&s(t.width)};if(t(),"undefined"!=typeof ResizeObserver){let n=new ResizeObserver(()=>t());return n.observe(e),()=>n.disconnect()}return window.addEventListener("resize",t),()=>window.removeEventListener("resize",t)},[n]);let l=(0,v.useRef)(!1);(0,v.useLayoutEffect)(()=>{if("undefined"!=typeof window&&"function"==typeof window.matchMedia&&window.matchMedia("(min-width: 768px)").matches){if(i)l.current&&(document.body.style.transition="margin-inline-end 260ms ease"),document.body.style.marginInlineEnd="number"==typeof a?`${a}px`:a;else l.current&&(document.body.style.transition="margin-inline-end 260ms ease",document.body.style.marginInlineEnd="");return l.current=!0,()=>{document.body.style.marginInlineEnd="",document.body.style.transition=""}}},[i,a]);let c=nr(e,iw,{});return(0,w.jsxs)(w.Fragment,{children:[nr(t,ix,{}),(0,w.jsx)("aside",{ref:o,"data-copilotkit":!0,"data-testid":"copilot-sidebar","data-copilot-sidebar":!0,className:M("cpk:fixed cpk:right-0 cpk:top-0 cpk:z-[1200] cpk:flex","cpk:h-[100vh] cpk:h-[100dvh] cpk:max-h-screen","cpk:w-full","cpk:border-l cpk:border-border cpk:bg-background cpk:text-foreground cpk:shadow-xl","cpk:transition-transform cpk:duration-300 cpk:ease-out",i?"cpk:translate-x-0":"cpk:translate-x-full cpk:pointer-events-none"),style:{"--sidebar-width":"number"==typeof a?`${a}px`:a,paddingTop:"env(safe-area-inset-top)",paddingBottom:"env(safe-area-inset-bottom)"},"aria-hidden":!i,"aria-label":"Copilot chat sidebar",role:"complementary",children:(0,w.jsxs)("div",{className:"cpk:flex cpk:h-full cpk:w-full cpk:flex-col cpk:overflow-hidden",children:[c,(0,w.jsx)("div",{className:"cpk:flex-1 cpk:overflow-hidden","data-sidebar-chat":!0,children:(0,w.jsx)(ru,{...r})})]})})]})}ix.displayName="CopilotChatToggleButton",iw.displayName="CopilotModalHeader",(i5=iw||(iw={})).Title=({children:e,className:t,...n})=>(0,w.jsx)("div",{"data-testid":"copilot-header-title",className:M("cpk:w-full cpk:text-base cpk:font-medium cpk:leading-none cpk:tracking-tight cpk:text-foreground",t),...n,children:e}),i5.CloseButton=({className:e,...t})=>(0,w.jsx)("button",{type:"button","data-testid":"copilot-close-button",className:M("cpk:inline-flex cpk:size-8 cpk:items-center cpk:justify-center cpk:rounded-full cpk:text-muted-foreground cpk:transition cpk:cursor-pointer","cpk:hover:bg-muted cpk:hover:text-foreground cpk:focus-visible:outline-none cpk:focus-visible:ring-2 cpk:focus-visible:ring-ring",e),"aria-label":"Close",...t,children:(0,w.jsx)(nu,{className:"cpk:h-4 cpk:w-4","aria-hidden":"true"})}),iw.Title.displayName="CopilotModalHeader.Title",iw.CloseButton.displayName="CopilotModalHeader.CloseButton",iE.displayName="CopilotSidebarView",(iE||(iE={})).WelcomeScreen=({welcomeMessage:e,input:t,suggestionView:n,className:r,children:i,...o})=>{let a=nr(e,ru.WelcomeMessage,{});return i?(0,w.jsx)("div",{"data-copilotkit":!0,style:{display:"contents"}
31,children:i({welcomeMessage:a,input:t,suggestionView:n,className:r,...o})}):(0,w.jsxs)("div",{className:M("cpk:h-full cpk:flex cpk:flex-col",r),...o,children:[(0,w.jsx)("div",{className:"cpk:flex-1 cpk:flex cpk:flex-col cpk:items-center cpk:justify-center cpk:px-4",children:a}),(0,w.jsx)("div",{className:"cpk:px-8 cpk:pb-4",children:(0,w.jsxs)("div",{className:"cpk:max-w-3xl cpk:mx-auto",children:[(0,w.jsx)("div",{className:"cpk:mb-4 cpk:flex cpk:justify-center",children:n}),t]})})]})};let iC=(e,t)=>"number"==typeof e&&Number.isFinite(e)?`${e}px`:"string"==typeof e&&e.trim().length>0?e:`${t}px`;function iT({header:e,toggleButton:t,width:n,height:r,clickOutsideToClose:i,defaultOpen:o=!0,className:a,...s}){return(0,w.jsx)(C,{isModalDefaultOpen:o,children:(0,w.jsx)(iN,{header:e,toggleButton:t,width:n,height:r,clickOutsideToClose:i,className:a,...s})})}function iN({header:e,toggleButton:t,width:n,height:r,clickOutsideToClose:i,className:o,...a}){let s=T(),l=s?.isModalOpen??!1,c=s?.setModalOpen,u=s?.labels??E,d=(0,v.useRef)(null),[p,f]=(0,v.useState)(l),[h,g]=(0,v.useState)(!1);(0,v.useEffect)(()=>{if(l){f(!0),g(!1);return}if(!p)return;g(!0);let e=setTimeout(()=>{f(!1),g(!1)},200);return()=>clearTimeout(e)},[l,p]),(0,v.useEffect)(()=>{if(!l||"undefined"==typeof window)return;let e=e=>{"Escape"===e.key&&(e.preventDefault(),c?.(!1))};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[l,c]),(0,v.useEffect)(()=>{if(!l)return;let e=setTimeout(()=>{let e=d.current;e&&!e.contains(document.activeElement)&&e.focus({preventScroll:!0})},200);return()=>clearTimeout(e)},[l]),(0,v.useEffect)(()=>{if(!l||!i||"undefined"==typeof document)return;let e=e=>{let t=e.target;if(!t||d.current?.contains(t))return;let n=document.querySelector("[data-slot='chat-toggle-button']");n&&n.contains(t)||c?.(!1)};return document.addEventListener("pointerdown",e),()=>document.removeEventListener("pointerdown",e)},[l,i,c]);let m=(0,v.useMemo)(()=>nr(e,iw,{}),[e]),y=(0,v.useMemo)(()=>nr(t,ix,{}),[t]),k=iC(n,420),b=iC(r,560),x=(0,v.useMemo)(()=>({"--copilot-popup-width":k,"--copilot-popup-height":b,"--copilot-popup-max-width":"calc(100vw - 3rem)","--copilot-popup-max-height":"calc(100dvh - 7.5rem)",paddingTop:"env(safe-area-inset-top)",paddingBottom:"env(safe-area-inset-bottom)",paddingLeft:"env(safe-area-inset-left)",paddingRight:"env(safe-area-inset-right)"}),[b,k]),S=l&&!h?"cpk:pointer-events-auto cpk:translate-y-0 cpk:opacity-100 cpk:md:scale-100":"cpk:pointer-events-none cpk:translate-y-4 cpk:opacity-0 cpk:md:translate-y-5 cpk:md:scale-[0.95]";return(0,w.jsxs)(w.Fragment,{children:[y,p?(0,w.jsx)("div",{"data-copilotkit":!0,className:M("cpk:fixed cpk:inset-0 cpk:z-[1200] cpk:flex cpk:max-w-full cpk:flex-col cpk:items-stretch","cpk:md:inset-auto cpk:md:bottom-24 cpk:md:right-6 cpk:md:items-end cpk:md:gap-4"),children:(0,w.jsxs)("div",{ref:d,tabIndex:-1,role:"dialog","aria-label":u.modalHeaderTitle,"data-testid":"copilot-popup","data-copilot-popup":!0,className:M("cpk:relative cpk:flex cpk:h-full cpk:w-full cpk:flex-col cpk:overflow-hidden cpk:bg-background cpk:text-foreground","cpk:origin-bottom cpk:focus:outline-none cpk:transform-gpu cpk:transition-transform cpk:transition-opacity cpk:duration-200 cpk:ease-out","cpk:md:transition-transform cpk:md:transition-opacity","cpk:rounded-none cpk:border cpk:border-border/0 cpk:shadow-none cpk:ring-0","cpk:md:h-[var(--copilot-popup-height)] cpk:md:w-[var(--copilot-popup-width)]","cpk:md:max-h-[var(--copilot-popup-max-height)] cpk:md:max-w-[var(--copilot-popup-max-width)]","cpk:md:origin-bottom-right cpk:md:rounded-2xl cpk:md:border-border cpk:md:shadow-xl cpk:md:ring-1 cpk:md:ring-border/40",S),style:x,children:[m,(0,w.jsx)("div",{className:"cpk:flex-1 cpk:overflow-hidden","data-popup-chat":!0,children:(0,w.jsx)(ru,{...a,className:M("cpk:h-full cpk:min-h-0",o)})})]})}):null]})}iT.displayName="CopilotPopupView",(iT||(iT={})).WelcomeScreen=({welcomeMessage:e,input:t,suggestionView:n,className:r,children:i,...o})=>{let a=nr(e,ru.WelcomeMessage,{});return i?(0,w.jsx)("div",{"data-copilotkit":!0,style:{display:"contents"}
31,children:i({welcomeMessage:a,input:t,suggestionView:n,className:r,...o})}):(0,w.jsxs)("div",{className:M("cpk:h-full cpk:flex cpk:flex-col",r),...o,children:[(0,w.jsx)("div",{className:"cpk:flex-1 cpk:flex cpk:flex-col cpk:items-center cpk:justify-center cpk:px-4",children:a}),(0,w.jsxs)("div",{children:[(0,w.jsx)("div",{className:"cpk:mb-4 cpk:flex cpk:justify-center cpk:px-4",children:n}),t]})]})};"*"!==(i4={name:"*",render:({args:e,result:t,name:n,status:r})=>{let[i,o]=(0,v.useState)(!1),a=String(r);return(0,w.jsx)("div",{className:"cpk:mt-2 cpk:pb-2",children:(0,w.jsxs)("div",{className:"cpk:rounded-xl cpk:border cpk:border-zinc-200/60 cpk:dark:border-zinc-800/60 cpk:bg-white/70 cpk:dark:bg-zinc-900/50 cpk:shadow-sm cpk:backdrop-blur cpk:p-4",children:[(0,w.jsxs)("div",{className:"cpk:flex cpk:items-center cpk:justify-between cpk:gap-3 cpk:cursor-pointer",onClick:()=>o(!i),children:[(0,w.jsxs)("div",{className:"cpk:flex cpk:items-center cpk:gap-2 cpk:min-w-0",children:[(0,w.jsx)("svg",{className:`cpk:h-4 cpk:w-4 cpk:text-zinc-500 cpk:dark:text-zinc-400 cpk:transition-transform ${i?"cpk:rotate-90":""}`,fill:"none",viewBox:"0 0 24 24",strokeWidth:2,stroke:"currentColor",children:(0,w.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8.25 4.5l7.5 7.5-7.5 7.5"})}),(0,w.jsx)("span",{className:"cpk:inline-block cpk:h-2 cpk:w-2 cpk:rounded-full cpk:bg-blue-500"}),(0,w.jsx)("span",{className:"cpk:truncate cpk:text-sm cpk:font-medium cpk:text-zinc-900 cpk:dark:text-zinc-100",children:n})]}),(0,w.jsx)("span",{className:`cpk:inline-flex cpk:items-center cpk:rounded-full cpk:px-2 cpk:py-1 cpk:text-xs cpk:font-medium ${"inProgress"===a||"executing"===a?"cpk:bg-amber-100 cpk:text-amber-800 cpk:dark:bg-amber-500/15 cpk:dark:text-amber-400":"complete"===a?"cpk:bg-emerald-100 cpk:text-emerald-800 cpk:dark:bg-emerald-500/15 cpk:dark:text-emerald-400":"cpk:bg-zinc-100 cpk:text-zinc-800 cpk:dark:bg-zinc-700/40 cpk:dark:text-zinc-300"}`,children:String(r)})]}),i&&(0,w.jsxs)("div",{className:"cpk:mt-3 cpk:grid cpk:gap-4",children:[(0,w.jsxs)("div",{children:[(0,w.jsx)("div",{className:"cpk:text-xs cpk:uppercase cpk:tracking-wide cpk:text-zinc-500 cpk:dark:text-zinc-400",children:"Arguments"}),(0,w.jsx)("pre",{className:"cpk:mt-2 cpk:max-h-64 cpk:overflow-auto cpk:rounded-md cpk:bg-zinc-50 cpk:dark:bg-zinc-800/60 cpk:p-3 cpk:text-xs cpk:leading-relaxed cpk:text-zinc-800 cpk:dark:text-zinc-200 cpk:whitespace-pre-wrap cpk:break-words",children:JSON.stringify(e??{},null,2)})]}),void 0!==t&&(0,w.jsxs)("div",{children:[(0,w.jsx)("div",{className:"cpk:text-xs cpk:uppercase cpk:tracking-wide cpk:text-zinc-500 cpk:dark:text-zinc-400",children:"Result"}),(0,w.jsx)("pre",{className:"cpk:mt-2 cpk:max-h-64 cpk:overflow-auto cpk:rounded-md cpk:bg-zinc-50 cpk:dark:bg-zinc-800/60 cpk:p-3 cpk:text-xs cpk:leading-relaxed cpk:text-zinc-800 cpk:dark:text-zinc-200 cpk:whitespace-pre-wrap cpk:break-words",children:"string"==typeof t?t:JSON.stringify(t,null,2)})]})]})]})})}}).name||i4.args?i4.args:ny.z.any(),i4.name,i4.render,i4.agentId&&i4.agentId;let iA="https://api.cloud.copilotkit.ai",i_=`${iA}/copilotkit/v1`,iI="X-CopilotCloud-Public-Api-Key",iR="#22c55e",iM="undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto);var iO=new Uint8Array(16);let ij=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/i;for(var iz=[],iD=0;iD<256;++iD)iz.push((iD+256).toString(16).slice(1));function iP(e,t=0){return(iz[e[t+0]]+iz[e[t+1]]+iz[e[t+2]]+iz[e[t+3]]+"-"+iz[e[t+4]]+iz[e[t+5]]+"-"+iz[e[t+6]]+iz[e[t+7]]+"-"+iz[e[t+8]]+iz[e[t+9]]+"-"+iz[e[t+10]]+iz[e[t+11]]+iz[e[t+12]]+iz[e[t+13]]+iz[e[t+14]]+iz[e[t+15]]).toLowerCase()}let iF=function(e,t,n){if(iM&&!t&&!e)return iM();var r=(e=e||{}).random||(e.rng||function(){if(!i3&&!(i3="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)))throw Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return i3(iO)})();if(r[6]=15&r[6]|64,r[8]=63&r[8]|128,t){n=n||0;for(var i=0;i<16;++i)t[n+i]=r[i];return t}return iP(r)},iL=function(e){if(!("string"==typeof e&&ij.test(e)))throw TypeError("Invalid UUID");var t,n=new Uint8Array(16);return n[0]=(t=parseInt(e.slice(0,8),16))>>>24,n[1]=t>>>16&255,n[2]=t>>>8&255,n[3]=255&t,n[4]=(t=parseInt(e.slice(9,13),16))>>>8,n[5]=255&t,n[6]=(t=parseInt(e.slice(14,18),16))>>>8,n[7]=255&t,n[8]=(t=parseInt(e.slice(19,23),16))>>>8,n[9]=255&t,n[10]=(t=parseInt(e.slice(24,36),16))/0x10000000000&25
315,n[11]=t/0x100000000&255,n[12]=t>>>24&255,n[13]=t>>>16&255,n[14]=t>>>8&255,n[15]=255&t,n};function iU(e,t){return e<<t|e>>>32-t}var iB=function(e,t,n){function r(e,t,r,i){if("string"==typeof e&&(e=function(e){e=unescape(encodeURIComponent(e));for(var t=[],n=0;n<e.length;++n)t.push(e.charCodeAt(n));return t}(e)),"string"==typeof t&&(t=iL(t)),(null==(o=t)?void 0:o.length)!==16)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");var o,a=new Uint8Array(16+e.length);if(a.set(t),a.set(e,t.length),(a=n(a))[6]=15&a[6]|80,a[8]=63&a[8]|128,r){i=i||0;for(var s=0;s<16;++s)r[i+s]=a[s];return r}return iP(a)}try{r.name="v5"}catch(e){}return r.DNS="6ba7b810-9dad-11d1-80b4-00c04fd430c8",r.URL="6ba7b811-9dad-11d1-80b4-00c04fd430c8",r}(0,0,function(e){var t=[0x5a827999,0x6ed9eba1,0x8f1bbcdc,0xca62c1d6],n=[0x67452301,0xefcdab89,0x98badcfe,0x10325476,0xc3d2e1f0];if("string"==typeof e){var r=unescape(encodeURIComponent(e));e=[];for(var i=0;i<r.length;++i)e.push(r.charCodeAt(i))}else Array.isArray(e)||(e=Array.prototype.slice.call(e));e.push(128);for(var o=Math.ceil((e.length/4+2)/16),a=Array(o),s=0;s<o;++s){for(var l=new Uint32Array(16),c=0;c<16;++c)l[c]=e[64*s+4*c]<<24|e[64*s+4*c+1]<<16|e[64*s+4*c+2]<<8|e[64*s+4*c+3];a[s]=l}a[o-1][14]=(e.length-1)*8/0x100000000,a[o-1][14]=Math.floor(a[o-1][14]),a[o-1][15]=(e.length-1)*8|0;for(var u=0;u<o;++u){for(var d=new Uint32Array(80),p=0;p<16;++p)d[p]=a[u][p];for(var f=16;f<80;++f)d[f]=iU(d[f-3]^d[f-8]^d[f-14]^d[f-16],1);for(var h=n[0],g=n[1],m=n[2],y=n[3],k=n[4],v=0;v<80;++v){var b=Math.floor(v/20),x=iU(h,5)+function(e,t,n,r){switch(e){case 0:return t&n^~t&r;case 1:case 3:return t^n^r;case 2:return t&n^t&r^n&r}}(b,g,m,y)+k+t[b]+d[v]>>>0;k=y,y=m,m=iU(g,30)>>>0,g=h,h=x}n[0]=n[0]+h>>>0,n[1]=n[1]+g>>>0,n[2]=n[2]+m>>>0,n[3]=n[3]+y>>>0,n[4]=n[4]+k>>>0}return[n[0]>>24&255,n[0]>>16&255,n[0]>>8&255,255&n[0],n[1]>>24&255,n[1]>>16&255,n[1]>>8&255,255&n[1],n[2]>>24&255,n[2]>>16&255,n[2]>>8&255,255&n[2],n[3]>
31>24&255,n[3]>>16&255,n[3]>>8&255,255&n[3],n[4]>>24&255,n[4]>>16&255,n[4]>>8&255,255&n[4]]});function i$(e,t){let n="e4b01160-ff74-4c6e-9b27-d53cd930fe8e",r=t?iB(t,n):n;return iB("string"==typeof e?e:JSON.stringify(function e(t){if("function"==typeof t)return t.toString();if(Array.isArray(t))return t.map(e);if(null!==t&&"object"==typeof t){let n={};for(let r of Object.keys(t))n[r]=e(t[r]);return n}return t}(e)),r)}function iH(e,t="unset"){try{return JSON.parse(e)}catch(e){return"unset"===t?null:t}}e.i(358909);function iK(e,t){return new Promise(function(n,r){var i=setTimeout(function(){r(Error("Promise timed out"))},t);e.then(function(e){return clearTimeout(i),n(e)}).catch(r)})}function iG(e){return new Promise(function(t){return setTimeout(t,e)})}new class{constructor(){}async logEvent(e){try{let t=new AbortController,n=setTimeout(()=>t.abort(),3e3),r=new URLSearchParams;Object.entries(e).forEach(([e,t])=>{null!=t&&r.append(e,String(t))});let i=`https://copilotkit.gateway.scarf.sh/1.52.1?${r.toString()}`,o=await fetch(i,{method:"GET",signal:t.signal});if(clearTimeout(n),!o.ok)throw Error(`HTTP error! status: ${o.status}`)}catch{}}};var iV=e.i(290571),iW=function(e){function t(t,n){var r=e.call(this,"".concat(t," ").concat(n))||this;return r.field=t,r}return(0,iV.__extends)(t,e),t}(Error);let iq="2.3.0";function iJ(e){var t=Math.random()+1,n=e.minTimeout,r=e.factor,i=e.attempt,o=e.maxTimeout;return Math.min(t*(void 0===n?500:n)*Math.pow(void 0===r?2:r,i),void 0===o?1/0:o)}for(var iX,iY,iQ,iZ,i0,i1,i2,i5,i4,i3,i6,i8=function(){var e,t,n=!1,r=new Promise(function(r,i){e=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];n=!0,r.apply(void 0,e)},t=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];n=!0,i.apply(void 0,e)}});return{resolve:e,reject:t,promise:r,isSettled:function(){return n}}},i9=256,i7=[];i9--;)i7[i9]=(i9+256).toString(16).substring(1);function oe(){var e,t=0,n="";if(!i6||i9+16>256){for(i6=Array(t=256);t--;)i6[t]=256*Math.random()|0;t=i9=0}for(;t<16;t++)e=i6[i9+t],6==t?n+=i7[15&e|64]:8==t?n+=i7[63&e|128]:n+=i7[e],1&t&&t>1&&t<11&&(n+="-");return i9++,n}class ot{id=oe();items=[];sizeInBytes=0;maxEventCount;constructor(e){this.maxEventCount=Math.max(1,e)}tryAdd(e){if(this.length===this.maxEventCount)return{success:!1,message:`Event limit of ${this.maxEventCount} has been exceeded.`};let t=this.calculateSize(e.context);return t>32768?{success:!1,message:"Event exceeds maximum event size of 32 KB"}:this.sizeInBytes+t>491520?{success:!1,message:"Event has caused batch size to exceed 480 KB"}:(this.items.push(e),this.sizeInBytes+=t,{success:!0})}get length(){return this.items.length}calculateSize(e){return encodeURI(JSON.stringify(e.event)).split(/%..|i/).length}getEvents(){return this.items.map(({context:e})=>e.event)}getContexts(){return this.items.map(e=>e.context)}resolveEvents(){this.items.forEach(({resolver:e,context:t})=>e(t))}}let on=crypto,or=new TextEncoder,oi=new TextDecoder,oo=e=>(e=>{let t=e;"string"==typeof t&&(t=or.encode(t));let n=[];for(let e=0;e<t.length;e+=32768)n.push(String.fromCharCode.apply(null,t.subarray(e,e+32768)));return btoa(n.join(""))})(e).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_"),oa=e=>{let t=e;t instanceof Uint8Array&&(t=oi.decode(t)),t=t.replace(/-/g,"+").replace(/_/g,"/").replace(/\s/g,"");try{var n=t;let e=atob(n),r=new Uint8Array(e.length);for(let t=0;t<e.length;t++)r[t]=e.charCodeAt(t);return r}catch{throw TypeError("The input to be decoded is not correctly encoded.")}};class os extends Error{constructor(e,t){super(e,t),this.code="ERR_JOSE_GENERIC",this.name=this.constructor.name,Error.captureStackTrace?.(this,this.constructor)}}os.code="ERR_JOSE_GENERIC";class ol extends os{constructor(){super(...arguments),this.code="ERR_JOSE_NOT_SUPPORTED"}}ol.code="ERR_JOSE_NOT_SUPPORTED";class oc extends os{constructor(){super(...arguments),this.code="ERR_JWS_INVALID"}}oc.code="ERR_JWS_INVALID";class ou extends os{constructor(){super(...arguments),this.code="ERR_JWT_INVALID"}}function od(e,t="algorithm.name"){return TypeError(`CryptoKey does not support this operation, its ${t} must be ${e}`)}function op(e,t){return e.name===t}function of(e){return parseInt(e.name.slice(4),10)}
31function oh(e,t,...n){if((n=n.filter(Boolean)).length>2){let t=n.pop();e+=`one of type ${n.join(", ")}, or ${t}.`}else 2===n.length?e+=`one of type ${n[0]} or ${n[1]}.`:e+=`of type ${n[0]}.`;return null==t?e+=` Received ${t}`:"function"==typeof t&&t.name?e+=` Received function ${t.name}`:"object"==typeof t&&null!=t&&t.constructor?.name&&(e+=` Received an instance of ${t.constructor.name}`),e}ou.code="ERR_JWT_INVALID";let og=(e,...t)=>oh("Key must be ",e,...t);function om(e,t,...n){return oh(`Key for the ${e} algorithm must be `,t,...n)}let oy=e=>e instanceof CryptoKey||e?.[Symbol.toStringTag]==="KeyObject",ok=["CryptoKey"];function ov(e){if("object"!=typeof e||null===e||"[object Object]"!==Object.prototype.toString.call(e))return!1;if(null===Object.getPrototypeOf(e))return!0;let t=e;for(;null!==Object.getPrototypeOf(t);)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}function ob(e){return ov(e)&&"string"==typeof e.kty}let ox=async e=>{if(!e.alg)throw TypeError('"alg" argument is required when "jwk.alg" is not present');let{algorithm:t,keyUsages:n}=function(e){let t,n;switch(e.kty){case"RSA":switch(e.alg){case"PS256":case"PS384":case"PS512":t={name:"RSA-PSS",hash:`SHA-${e.alg.slice(-3)}`},n=e.d?["sign"]:["verify"];break;case"RS256":case"RS384":case"RS512":t={name:"RSASSA-PKCS1-v1_5",hash:`SHA-${e.alg.slice(-3)}`},n=e.d?["sign"]:["verify"];break;case"RSA-OAEP":case"RSA-OAEP-256":case"RSA-OAEP-384":case"RSA-OAEP-512":t={name:"RSA-OAEP",hash:`SHA-${parseInt(e.alg.slice(-3),10)||1}`},n=e.d?["decrypt","unwrapKey"]:["encrypt","wrapKey"];break;default:throw new ol('Invalid or unsupported JWK "alg" (Algorithm) Parameter value')}break;case"EC":switch(e.alg){case"ES256":t={name:"ECDSA",namedCurve:"P-256"},n=e.d?["sign"]:["verify"];break;case"ES384":t={name:"ECDSA",namedCurve:"P-384"},n=e.d?["sign"]:["verify"];break;case"ES512":t={name:"ECDSA",namedCurve:"P-521"},n=e.d?["sign"]:["verify"];break;case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":t={name:"ECDH",namedCurve:e.crv},n=e.d?["deriveBits"]:[];break;default:throw new ol('Invalid or unsupported JWK "alg" (Algorithm) Parameter value')}break;case"OKP":switch(e.alg){case"Ed25519":t={name:"Ed25519"},n=e.d?["sign"]:["verify"];break;case"EdDSA":t={name:e.crv},n=e.d?["sign"]:["verify"];break;case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":t={name:e.crv},n=e.d?["deriveBits"]:[];break;default:throw new ol('Invalid or unsupported JWK "alg" (Algorithm) Parameter value')}break;default:throw new ol('Invalid or unsupported JWK "kty" (Key Type) Parameter value')}return{algorithm:t,keyUsages:n}}(e),r=[t,e.ext??!1,e.key_ops??n],i={...e};return delete i.alg,delete i.use,on.subtle.importKey("jwk",i,...r)},ow=e=>e?.[Symbol.toStringTag]==="KeyObject",oE=async(e,t,n,r,i=!1)=>{let o=e.get(t);if(o?.[r])return o[r];let a=await ox({...n,alg:r});return i&&Object.freeze(t),o?o[r]=a:e.set(t,{[r]:a}),a};async function oS(e,r,i){if("sign"===i&&(r=await ((e,n)=>{if(ow(e)){let r=e.export({format:"jwk"});return r.k?oa(r.k):(t||(t=new WeakMap),oE(t,e,r,n))}return ob(e)?e.k?oa(e.k):(t||(t=new WeakMap),oE(t,e,e,n,!0)):e})(r,e)),"verify"===i&&(r=await ((e,t)=>{if(ow(e)){let r=e.export({format:"jwk"});return(delete r.d,delete r.dp,delete r.dq,delete r.p,delete r.q,delete r.qi,r.k)?oa(r.k):(n||(n=new WeakMap),oE(n,e,r,t))}return ob(e)?e.k?oa(e.k):(n||(n=new WeakMap),oE(n,e,e,t,!0)):e})(r,e)),r instanceof CryptoKey)return!function(e,t,...n){switch(t){case"HS256":case"HS384":case"HS512":{if(!op(e.algorithm,"HMAC"))throw od("HMAC");let n=parseInt(t.slice(2),10);if(of(e.algorithm.hash)!==n)throw od(`SHA-${n}`,"algorithm.hash");break}case"RS256":case"RS384":case"RS512":{if(!op(e.algorithm,"RSASSA-PKCS1-v1_5"))throw od("RSASSA-PKCS1-v1_5");let n=parseInt(t.slice(2),10);if(of(e.algorithm.hash)!==n)throw od(`SHA-${n}`,"algorithm.hash");break}
31case"PS256":case"PS384":case"PS512":{if(!op(e.algorithm,"RSA-PSS"))throw od("RSA-PSS");let n=parseInt(t.slice(2),10);if(of(e.algorithm.hash)!==n)throw od(`SHA-${n}`,"algorithm.hash");break}case"EdDSA":if("Ed25519"!==e.algorithm.name&&"Ed448"!==e.algorithm.name)throw od("Ed25519 or Ed448");break;case"Ed25519":if(!op(e.algorithm,"Ed25519"))throw od("Ed25519");break;case"ES256":case"ES384":case"ES512":{if(!op(e.algorithm,"ECDSA"))throw od("ECDSA");let n=function(e){switch(e){case"ES256":return"P-256";case"ES384":return"P-384";case"ES512":return"P-521";default:throw Error("unreachable")}}(t);if(e.algorithm.namedCurve!==n)throw od(n,"algorithm.namedCurve");break}default:throw TypeError("CryptoKey does not support this operation")}if(n.length&&!n.some(t=>e.usages.includes(t))){let e="CryptoKey does not support this operation, its usages must include ";if(n.length>2){let t=n.pop();e+=`one of ${n.join(", ")}, or ${t}.`}else 2===n.length?e+=`one of ${n[0]} or ${n[1]}.`:e+=`${n[0]}.`;throw TypeError(e)}}(r,e,i),r;if(r instanceof Uint8Array){if(!e.startsWith("HS"))throw TypeError(og(r,...ok));return on.subtle.importKey("raw",r,{hash:`SHA-${e.slice(-3)}`,name:"HMAC"},!1,[i])}throw TypeError(og(r,...ok,"Uint8Array","JSON Web Key"))}let oC=async(e,t,n)=>{let r=await oS(e,t,"sign");return((e,t)=>{if(e.startsWith("RS")||e.startsWith("PS")){let{modulusLength:n}=t.algorithm;if("number"!=typeof n||n<2048)throw TypeError(`${e} requires key modulusLength to be 2048 bits or larger`)}})(e,r),new Uint8Array(await on.subtle.sign(function(e,t){let n=`SHA-${e.slice(-3)}`;switch(e){case"HS256":case"HS384":case"HS512":return{hash:n,name:"HMAC"};case"PS256":case"PS384":case"PS512":return{hash:n,name:"RSA-PSS",saltLength:e.slice(-3)>>3};case"RS256":case"RS384":case"RS512":return{hash:n,name:"RSASSA-PKCS1-v1_5"};case"ES256":case"ES384":case"ES512":return{hash:n,name:"ECDSA",namedCurve:t.namedCurve};case"Ed25519":return{name:"Ed25519"};case"EdDSA":return{name:t.name};default:throw new ol(`alg ${e} is not supported either by JOSE or your javascript runtime`)}}(e,r.algorithm),r,n))},oT=e=>e?.[Symbol.toStringTag],oN=(e,t,n)=>{if(void 0!==t.use&&"sig"!==t.use)throw TypeError("Invalid key for this operation, when present its use must be sig");if(void 0!==t.key_ops&&t.key_ops.includes?.(n)!==!0)throw TypeError(`Invalid key for this operation, when present its key_ops must include ${n}`);if(void 0!==t.alg&&t.alg!==e)throw TypeError(`Invalid key for this operation, when present its alg must be ${e}`);return!0};function oA(e,t,n,r){t.startsWith("HS")||"dir"===t||t.startsWith("PBES2")||/^A\d{3}(?:GCM)?KW$/.test(t)?((e,t,n,r)=>{if(!(t instanceof Uint8Array)){if(r&&ob(t)){if(ob(t)&&"oct"===t.kty&&"string"==typeof t.k&&oN(e,t,n))return;throw TypeError('JSON Web Key for symmetric algorithms must have JWK "kty" (Key Type) equal to "oct" and the JWK "k" (Key Value) present')}if(!oy(t))throw TypeError(om(e,t,...ok,"Uint8Array",r?"JSON Web Key":null));if("secret"!==t.type)throw TypeError(`${oT(t)} instances for symmetric algorithms must be of type "secret"`)}})(t,n,r,e):((e,t,n,r)=>{if(r&&ob(t))switch(n){case"sign":if("oct"!==t.kty&&"string"==typeof t.d&&oN(e,t,n))return;throw TypeError("JSON Web Key for this operation be a private JWK");case"verify":if("oct"!==t.kty&&void 0===t.d&&oN(e,t,n))return;throw TypeError("JSON Web Key for this operation be a public JWK")}if(!oy(t))throw TypeError(om(e,t,...ok,r?"JSON Web Key":null));if("secret"===t.type)throw TypeError(`${oT(t)} instances for asymmetric algorithms must not be of type "secret"`);if("sign"===n&&"public"===t.type)throw TypeError(`${oT(t)} instances for asymmetric algorithm signing must be of type "private"`);if("decrypt"===n&&"public"===t.type)throw TypeError(`${oT(t)} instances for asymmetric algorithm decryption must be of type "private"`);if(t.algorithm&&"verify"===n&&"private"===t.type)throw TypeError(`${oT(t)} instances for asymmetric algorithm verifying must be of type "public"`);if(t.algorithm&&"encrypt"===n&&"private"===t.type)throw TypeError(`${oT(t)} instances for asymmetric algorithm encryption must be of type "public"`)})(t,n,r,e)}oA.bind(void 0,!1);let o_=oA.bind(void 0,!0),oI=function(e,t,n,r,i){let o;if(void 0!==i.crit&&r?.crit===void 0)throw new e('"crit" (Critical) Header Parameter MUST be integrity protected');if(!r||void 0===r.crit)return new Set;if(!Array.isArray(r.crit)||0===r.crit.length||r.crit.some(e=>"string"!=typeof e||0===e.length))throw new e('"crit" (Critical) Header Parameter MUST be an array of non-empty strings when present');for(let a of(o=void 0!==n?new Map([...Object.entries(n),...t.entries()]):t,r.crit)){if(!o.has(a))throw new ol(`Extension Header Parameter "${a}" is not recognized`);if(void 0===i[a])throw new e(`Extension Header Parameter "${a}" is missing`);if(o.get(a)&&void 0===r[a])throw new e(`Extension Header Parameter "${a}" MUST be integrity protected`)}return new Set(r.crit)};class oR{constructor(e){if(!(e instanceof Uint8Array))throw TypeError("payload must be an instance of Uint8Array");this._payload=e}setProtectedHeader(e){if(this._protectedHeader)throw TypeError("setProtectedHeader can only be called once");return this._protectedHeader=e,this}setUnprotectedHeader(e){if(this._unprotectedHeader)throw TypeError("setUnprotectedHeader can only be called once");return this._unprotectedHeader=e,this}async sign(e,t){let n;if(!this._protectedHeader&&!this._unprotectedHeader)throw new oc("either setProtectedHeader or setUnprotectedHeader must be called before #sign()");if(!((...e)=>{let t,n=e.filter(Boolean);if(0===n.length||1===n.length)return!0;for(let e of n){let n=Object.keys(e);if(!t||0===t.size){t=new Set(n);continue}for(let e of n){if(t.has(e))return!1;t.add(e)}}return!0})(this._protectedHeader,this._unprotectedHeader))throw new oc("JWS Protected and JWS Unprotected Header Parameter names must be disjoint");let r={...this._protectedHeader,...this._unprotectedHeader},i=oI(oc,new Map([["b64",!0]]),t?.crit,this._protectedHeader,r),o=!0;if(i.has("b64")&&"boolean"!=typeof(o=this._protectedHeader.b64))throw new oc('The "b64" (base64url-encode payload) Header Parameter must be a boolean');let{alg:a}=r;if("string"!=typeof a||!a)throw new oc('JWS "alg" (Algorithm) Header Parameter missing or invalid');o_(a,e,"sign");let s=this._payload;o&&(s=or.encode(oo(s)));let l=function(...e){let t=new Uint8Array(e.reduce((e,{length:t})=>e+t,0)),n=0;for(let r of e)t.set(r,n),n+=r.length;return t}(n=this._protectedHeader?or.encode(oo(JSON.stringify(this._protectedHeader))):or.encode(""),or.encode("."),s),c={signature:oo(await oC(a,e,l)),payload:""};return o&&(c.payload=oi.decode(s)),this._unprotectedHeader&&(c.header=this._unprotectedHeader),this._protectedHeader&&(c.protected=oi.decode(n)),c}}class oM{constructor(e){this._flattened=new oR(e)}setProtectedHeader(e){return this._flattened.setProtectedHeader(e),this}async sign(e,t){let n=await this._flattened.sign(e,t);if(void 0===n.payload)throw TypeError("use the flattened module for creating JWS with b64: false");return`${n.protected}.${n.payload}.${n.signature}`}}let oO=e=>Math.floor(e.getTime()/1e3),oj=/^(\+|\-)? ?(\d+|\d+\.\d+) ?(seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)(?: (ago|from now))?$/i,oz=e=>{let t,n=oj.exec(e);if(!n||n[4]&&n[1])throw TypeError("Invalid time period format");let r=parseFloat(n[2]);switch(n[3].toLowerCase()){case"sec":case"secs":case"second":case"seconds":case"s":t=Math.round(r);break;case"minute":case"minutes":case"min":case"mins":case"m":t=Math.round(60*r);break;case"hour":case"hours":case"hr":case"hrs":case"h":t=Math.round(3600*r);break;case"day":case"days":case"d":t=Math.round(86400*r);break;case"week":case"weeks":case"w":t=Math.round(604800*r);break;default:t=Math.round(0x1e187e0*r)}return"-"===n[1]||"ago"===n[4]?-t:t};function oD(e,t){if(!Number.isFinite(t))throw TypeError(`Invalid ${e} input`);return t}class oP{constructor(e={}){if(!ov(e))throw TypeError("JWT Claims Set MUST be an object");this._payload=e}setIssuer(e){return this._payload={...this._payload,iss:e},this}setSubject(e){return this._payload={...this._payload,sub:e},this}setAudience(e){return this._payload={...this._payload,aud:e},this}setJti(e){return this._payload={...this._payload,jti:e},this}setNotBefore(e){return"number"==typeof e?this._payload={...this._payload,nbf:oD("setNotBefore",e)}:e instanceof Date?this._payload={...this._payload,nbf:oD("setNotBefore",oO(e))}:this._payload={...this._payload,nbf:oO(new Date)+oz(e)},this}setExpirationTime(e){return"number"==typeof e?this._payload={...this._payload,exp:oD("setExpirationTime",e)}:e instanceof Date?this._payload={...this._payload,exp:oD("setExpirationTime",oO(e))}:this._payload={...this._payload,exp:oO(new Date)+oz(e)},this}setIssuedAt(e){return void 0===e?this._payload={...this._payload,iat:oO(new Date)}:e instanceof Date?this._payload={...this._payload,iat:oD("setIssuedAt",oO(e))}:"string"==typeof e?this._payload={...this._payload,iat:oD("setIssuedAt",oO(new Date)+oz(e))}:this._payload={...this._payload,iat:oD("setIssuedAt",e)},this}}class oF extends oP{setProtectedHeader(e){return this._protectedHeader=e,this}async sign(e,t){let n=new oM(or.encode(JSON.stringify(this._payload)));if(n.setProtectedHeader(this._protectedHeader),Array.isArray(this._protectedHeader?.crit)&&this._protectedHeader.crit.includes("b64")&&!1===this._protectedHeader.b64)throw new ou("JWTs MUST NOT use unencoded payload");return n.sign(e,t)}}let oL=(e,t,n=0)=>{0===n&&(t.unshift(t.length),t.unshift(6));let r=e.indexOf(t[0],n);if(-1===r)return!1;let i=e.subarray(r,r+t.length);return i.length===t.length&&(i.every((e,n)=>e===t[n])||oL(e,t,r+1))},oU=e=>{switch(!0){case oL(e,[42,134,72,206,61,3,1,7]):return"P-256";case oL(e,[43,129,4,0,34]):return"P-384";case oL(e,[43,129,4,0,35]):return"P-521";case oL(e,[43,101,110]):return"X25519";case oL(e,[43,101,111]):return"X448";case oL(e,[43,101,112]):return"Ed25519";case oL(e,[43,101,113]):return"Ed448";default:throw new ol("Invalid or unsupported EC Key Curve or OKP Key Sub Type")}},oB=async(e,t,n,r,i)=>{let o,a,s=new Uint8Array(atob(n.replace(e,"")).split("").map(e=>e.charCodeAt(0))),l="spki"===t;switch(r){case"PS256":case"PS384":case"PS512":o={name:"RSA-PSS",hash:`SHA-${r.slice(-3)}`},a=l?["verify"]:["sign"];break;case"RS256":case"RS384":case"RS512":o={name:"RSASSA-PKCS1-v1_5",hash:`SHA-${r.slice(-3)}`},a=l?["verify"]:["sign"];break;case"RSA-OAEP":case"RSA-OAEP-256":case"RSA-OAEP-384":case"RSA-OAEP-512":o={name:"RSA-OAEP",hash:`SHA-${parseInt(r.slice(-3),10)||1}`},a=l?["encrypt","wrapKey"]:["decrypt","unwrapKey"];break;case"ES256":o={name:"ECDSA",namedCurve:"P-256"},a=l?["verify"]:["sign"];break;case"ES384":o={name:"ECDSA",namedCurve:"P-384"},a=l?["verify"]:["sign"];break;case"ES512":o={name:"ECDSA",namedCurve:"P-521"},a=l?["verify"]:["sign"];break;case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":{let e=oU(s);o=e.startsWith("P-")?{name:"ECDH",namedCurve:e}:{name:e},a=l?[]:["deriveBits"];break}
31case"Ed25519":o={name:"Ed25519"},a=l?["verify"]:["sign"];break;case"EdDSA":o={name:oU(s)},a=l?["verify"]:["sign"];break;default:throw new ol('Invalid or unsupported "alg" (Algorithm) value')}return on.subtle.importKey(t,s,o,i?.extractable??!1,a)};async function o$(e,t,n){if("string"!=typeof e||0!==e.indexOf("-----BEGIN PRIVATE KEY-----"))throw TypeError('"pkcs8" must be PKCS#8 formatted string');return oB(/(?:-----(?:BEGIN|END) PRIVATE KEY-----|\s)/g,"pkcs8",e,t,n)}var oH=function(){function e(e){var t;this.callbacks={},this.warned=!1,this.maxListeners=null!=(t=null==e?void 0:e.maxListeners)?t:10}return e.prototype.warnIfPossibleMemoryLeak=function(e){!this.warned&&this.maxListeners&&this.callbacks[e].length>this.maxListeners&&(console.warn("Event Emitter: Possible memory leak detected; ".concat(String(e)," has exceeded ").concat(this.maxListeners," listeners.")),this.warned=!0)},e.prototype.on=function(e,t){return this.callbacks[e]?(this.callbacks[e].push(t),this.warnIfPossibleMemoryLeak(e)):this.callbacks[e]=[t],this},e.prototype.once=function(e,t){var n=this,r=function(){for(var i=[],o=0;o<arguments.length;o++)i[o]=arguments[o];n.off(e,r),t.apply(n,i)};return this.on(e,r),this},e.prototype.off=function(e,t){var n,r=(null!=(n=this.callbacks[e])?n:[]).filter(function(e){return e!==t});return this.callbacks[e]=r,this},e.prototype.emit=function(e){for(var t,n=this,r=[],i=1;i<arguments.length;i++)r[i-1]=arguments[i];return(null!=(t=this.callbacks[e])?t:[]).forEach(function(e){e.apply(n,r)}),this},e}();class oK{alg="RS256";grantType="client_credentials";clientAssertionType="urn:ietf:params:oauth:client-assertion-type:jwt-bearer";clientId;clientKey;keyId;scope;authServer;httpClient;maxRetries;clockSkewInSeconds=0;accessToken;tokenEmitter=new oH;retryCount;pollerTimer;constructor(e){this.keyId=e.keyId,this.clientId=e.clientId,this.clientKey=e.clientKey,this.authServer=e.authServer??"https://oauth2.segment.io",this.scope=e.scope??"tracking_api:write",this.httpClient=e.httpClient,this.maxRetries=e.maxRetries,this.tokenEmitter.on("access_token",e=>{"token"in e&&(this.accessToken=e.token)}),this.retryCount=0}stopPoller(){clearTimeout(this.pollerTimer)}async pollerLoop(){let e,t=25;try{e=await this.requestAccessToken()}catch(e){return this.handleTransientError({error:e})}if("function"!=typeof e.text)return this.handleInvalidCustomResponse();let n=function(e){var t;let n={};if(!e)return{};if("object"==typeof(t=e)&&null!==t&&"entries"in Object(t)&&"function"==typeof Object(t).entries){for(let[t,r]of e.entries())n[t.toLowerCase()]=r;return n}for(let[t,r]of Object.entries(e))n[t.toLowerCase()]=r;return n}(e.headers);if(n.date&&this.updateClockSkew(Date.parse(n.date)),200===e.status)try{let n=await e.text(),r=JSON.parse(n);if(!(r&&"object"==typeof r&&"access_token"in r&&"expires_in"in r&&"string"==typeof r.access_token&&"number"==typeof r.expires_in))throw Error("Response did not contain a valid access_token and expires_in");return r.expires_at=Math.round(Date.now()/1e3)+r.expires_in,this.tokenEmitter.emit("access_token",{token:r}),this.retryCount=0,t=r.expires_in/2*1e3,this.queueNextPoll(t)}catch(e){return this.handleTransientError({error:e,forceEmitError:!0})}return 429===e.status?await this.handleRateLimited(e,n,t):[400,401,415].includes(e.status)?this.handleUnrecoverableErrors(e):this.handleTransientError({error:Error(`[${e.status}] ${e.statusText}`)})}handleTransientError({error:e,forceEmitError:t}){this.incrementRetries({error:e,forceEmitError:t});let n=iJ({attempt:this.retryCount,minTimeout:25,maxTimeout:1e3});this.queueNextPoll(n)}handleInvalidCustomResponse(){this.tokenEmitter.emit("access_token",{error:Error("HTTPClient does not implement response.text method")})}async handleRateLimited(e,t,n){if(this.incrementRetries({error:Error(`[${e.status}] ${e.statusText}`)}),t["x-ratelimit-reset"]){let e=parseInt(t["x-ratelimit-reset"],10);n=isFinite(e)?e-Date.now()+1e3*this.clockSkewInSeconds:5e3,await iG(n),n=0}this.queueNextPoll(n)}handleUnrecoverableErrors(e){this.retryCount=0,this.tokenEmitter.emit("access_token",{error:Error(`[${e.status}] ${e.statusText}`)}),this.stopPoller()}updateClockSkew(e){this.clockSkewInSeconds=(Date.now()-e)/1e3}incrementRetries({error:e,forceEmitError:t}){this.retryCount++,(t||this.retryCount%this.maxRetries==0)&&(this.retryCount=0,this.tokenEmitter.emit("access_token",{error:e}))}queueNextPoll(e){this.pollerTimer=setTimeout(()=>this.pollerLoop(),e),this.pollerTimer.unref&&this.pollerTimer.unref()}async requestAccessToken(){let e=oe(),t=Math.round(Date.now()/1e3)-this.clockSkewInSeconds,n={iss:this.clientId,sub:this.clientId,aud:this.authServer,iat:t-5,exp:t+55,jti:e},r=await o$(this.clientKey,"RS256"),i=await new oF(n).setProtectedHeader({alg:this.alg,kid:this.keyId,typ:"JWT"}).sign(r),o=`grant_type=${this.grantType}&client_assertion_type=${this.clientAssertionType}&client_assertion=${i}&scope=${this.scope}`,a=`${this.authServer}/token`;
31return this.httpClient.makeRequest({method:"POST",url:a,body:o,headers:{"Content-Type":"application/x-www-form-urlencoded"},httpRequestTimeout:1e4})}async getAccessToken(){return this.isValidToken(this.accessToken)?this.accessToken:(this.stopPoller(),this.pollerLoop().catch(()=>{}),new Promise((e,t)=>{this.tokenEmitter.once("access_token",n=>{"token"in n?e(n.token):t(n.error)})}))}clearToken(){this.accessToken=void 0}isValidToken(e){return null!=e&&e.expires_in<Date.now()/1e3}}function oG(){}class oV{pendingFlushTimeout;_batch;_flushInterval;_flushAt;_maxRetries;_url;_flushPendingItemsCount;_httpRequestTimeout;_emitter;_disable;_httpClient;_writeKey;_tokenManager;constructor({host:e,path:t,maxRetries:n,flushAt:r,flushInterval:i,writeKey:o,httpRequestTimeout:a,httpClient:s,disable:l,oauthSettings:c},u){this._emitter=u,this._maxRetries=n,this._flushAt=Math.max(r,1),this._flushInterval=i,this._url=new URL((t??"/v1/batch")||"",e??"https://api.segment.io").href.replace(/\/$/,""),this._httpRequestTimeout=a??1e4,this._disable=!!l,this._httpClient=s,this._writeKey=o,c&&(this._tokenManager=new oK({...c,httpClient:c.httpClient??s,maxRetries:c.maxRetries??n}))}createBatch(){this.pendingFlushTimeout&&clearTimeout(this.pendingFlushTimeout);let e=new ot(this._flushAt);return this._batch=e,this.pendingFlushTimeout=setTimeout(()=>{e===this._batch&&(this._batch=void 0),this.pendingFlushTimeout=void 0,e.length&&this.send(e).catch(oG)},this._flushInterval),e}clearBatch(){this.pendingFlushTimeout&&clearTimeout(this.pendingFlushTimeout),this._batch=void 0}flush(e){if(!e){this._tokenManager&&this._tokenManager.stopPoller();return}this._flushPendingItemsCount=e,this._batch&&this._batch.length===e&&(this.send(this._batch).catch(oG).finally(()=>{this._tokenManager&&this._tokenManager.stopPoller()}),this.clearBatch())}enqueue(e){let t=this._batch??this.createBatch(),{promise:n,resolve:r}=i8(),i={context:e,resolver:r};if(t.tryAdd(i).success){let e=t.length===this._flushPendingItemsCount;return(t.length===this._flushAt||e)&&(this.send(t).catch(oG),this.clearBatch()),n}t.length&&(this.send(t).catch(oG),this.clearBatch());let o=this.createBatch(),a=o.tryAdd(i);return a.success?(o.length===this._flushPendingItemsCount&&(this.send(o).catch(oG),this.clearBatch()),n):(e.setFailedDelivery({reason:Error(a.message)}),Promise.resolve(e))}async send(e){this._flushPendingItemsCount&&(this._flushPendingItemsCount-=e.length);let t=e.getEvents(),n=this._maxRetries+1,r=0;for(;r<n;){let i,o;r++;try{let n;if(this._disable)return e.resolveEvents();if(this._tokenManager){let e=await this._tokenManager.getAccessToken();e&&e.access_token&&(n=`Bearer ${e.access_token}`)}let r={"Content-Type":"application/json","User-Agent":"analytics-node-next/latest",...n?{Authorization:n}:{}},a={url:this._url,method:"POST",headers:r,body:JSON.stringify({batch:t,writeKey:this._writeKey,sentAt:new Date}),httpRequestTimeout:this._httpRequestTimeout};this._emitter.emit("http_request",{body:a.body,method:a.method,url:a.url,headers:a.headers});let s=await this._httpClient.makeRequest(a);if(s.status>=200&&s.status<300)return void e.resolveEvents();if(this._tokenManager&&(400===s.status||401===s.status||403===s.status))this._tokenManager.clearToken(),o=Error(`[${s.status}] ${s.statusText}`);else if(400===s.status)return void oW(e,Error(`[${s.status}] ${s.statusText}`));else if(429===s.status){if(s.headers&&"x-ratelimit-reset"in s.headers){let e=parseInt(s.headers["x-ratelimit-reset"],10);isFinite(e)&&(i=e-Date.now())}o=Error(`[${s.status}] ${s.statusText}`)}else o=Error(`[${s.status}] ${s.statusText}`)}catch(e){o=e}if(r===n)return void oW(e,o);await function(e){return new Promise(t=>setTimeout(t,e))}(i||iJ({attempt:r,minTimeout:25,maxTimeout:1e3}))}}}
31function oW(e,t){e.getContexts().forEach(e=>e.setFailedDelivery({reason:t})),e.resolveEvents()}let oq=()=>"object"==typeof nE.default&&nE.default&&"object"==typeof nE.default.env&&nE.default.env&&"string"==typeof nE.default.version?"node":"object"==typeof window?"browser":"undefined"!=typeof WebSocketPair?"cloudflare-worker":"string"==typeof EdgeRuntime?"vercel-edge":"undefined"!=typeof WorkerGlobalScope&&"function"==typeof importScripts?"web-worker":"unknown";function oJ(e){return"string"==typeof e}function oX(e){return"object"===Object.prototype.toString.call(e).slice(8,-1).toLowerCase()}var oY="is not a string",oQ="is not an object",oZ="is nil";function o0(e,t,n){t.split&&(t=t.split("."));for(var r,i,o=0,a=t.length,s=e;o<a&&"__proto__"!=(i=""+t[o++])&&"constructor"!==i&&"prototype"!==i;)s=s[i]=o===a?n:typeof(r=s[i])==typeof t?r:0*t[o]!=0||~(""+t[o]).indexOf(".")?{}:[]}var o1=function(e){var t,n;this.settings=e,this.createMessageId=e.createMessageId,this.onEventMethodCall=null!=(t=e.onEventMethodCall)?t:function(){},this.onFinishedEvent=null!=(n=e.onFinishedEvent)?n:function(){}},o2=function(){function e(e){this.settings=new o1(e)}return e.prototype.track=function(e,t,n,r){return this.settings.onEventMethodCall({type:"track",options:n}),this.normalize((0,iV.__assign)((0,iV.__assign)({},this.baseEvent()),{event:e,type:"track",properties:null!=t?t:{},options:(0,iV.__assign)({},n),integrations:(0,iV.__assign)({},r)}))},e.prototype.page=function(e,t,n,r,i){this.settings.onEventMethodCall({type:"page",options:r});var o,a={type:"page",properties:(0,iV.__assign)({},n),options:(0,iV.__assign)({},r),integrations:(0,iV.__assign)({},i)};return null!==e&&(a.category=e,a.properties=null!=(o=a.properties)?o:{},a.properties.category=e),null!==t&&(a.name=t),this.normalize((0,iV.__assign)((0,iV.__assign)({},this.baseEvent()),a))},e.prototype.screen=function(e,t,n,r,i){this.settings.onEventMethodCall({type:"screen",options:r});var o={type:"screen",properties:(0,iV.__assign)({},n),options:(0,iV.__assign)({},r),integrations:(0,iV.__assign)({},i)};return null!==e&&(o.category=e),null!==t&&(o.name=t),this.normalize((0,iV.__assign)((0,iV.__assign)({},this.baseEvent()),o))},e.prototype.identify=function(e,t,n,r){return this.settings.onEventMethodCall({type:"identify",options:n}),this.normalize((0,iV.__assign)((0,iV.__assign)({},this.baseEvent()),{type:"identify",userId:e,traits:null!=t?t:{},options:(0,iV.__assign)({},n),integrations:r}))},e.prototype.group=function(e,t,n,r){return this.settings.onEventMethodCall({type:"group",options:n}),this.normalize((0,iV.__assign)((0,iV.__assign)({},this.baseEvent()),{type:"group",traits:null!=t?t:{},options:(0,iV.__assign)({},n),integrations:(0,iV.__assign)({},r),groupId:e}))},e.prototype.alias=function(e,t,n,r){this.settings.onEventMethodCall({type:"alias",options:n});var i={userId:e,type:"alias",options:(0,iV.__assign)({},n),integrations:(0,iV.__assign)({},r)};return(null!==t&&(i.previousId=t),void 0===e)?this.normalize((0,iV.__assign)((0,iV.__assign)({},i),this.baseEvent())):this.normalize((0,iV.__assign)((0,iV.__assign)({},this.baseEvent()),i))},e.prototype.baseEvent=function(){return{integrations:{},options:{}}},e.prototype.context=function(e){var t,n=["userId","anonymousId","timestamp","messageId"];delete e.integrations;var r=Object.keys(e),i=null!=(t=e.context)?t:{},o={};return r.forEach(function(t){"context"!==t&&(n.includes(t)?o0(o,t,e[t]):o0(i,t,e[t]))}),[i,o]},e.prototype.normalize=function(e){var t,n,r,i=Object.keys(null!=(n=e.integrations)?n:{}).reduce(function(t,n){var r,i;return(0,iV.__assign)((0,iV.__assign)({},t),((r={})[n]=!!(null==(i=e.integrations)?void 0:i[n]),r))},{});t=e.options||{},e.options=Object.keys(t).filter(function(e){return function(e,t){return void 0!==t}(e,t[e])}).reduce(function(e,n){return e[n]=t[n],e},{});var o=(0,iV.__assign)((0,iV.__assign)({},i),null==(r=e.options)?void 0:r.integrations),a=e.options?this.context(e.options):[],s=a[0],l=a[1],c=e.options,u=(0,iV.__rest)(e,["options"]),d=(0,iV.__assign)((0,iV.__assign)((0,iV.__assign)((0,iV.__assign)({timestamp:new Date},u),{context:s,integrations:o}),l),{messageId:c.messageId||this.settings.createMessageId()});return this.settings.onFinishedEvent(d),!function(e){if(null==e)throw new iW("Event",oZ);if("object"!=typeof e)throw new iW("Event",oQ);if(!oJ(e.type))throw new iW(".type",oY);
31if(!oJ(e.messageId))throw new iW(".messageId",oY);if("track"===e.type){if(!oJ(e.event))throw new iW(".event",oY);if(!oX(e.properties))throw new iW(".properties",oQ)}["group","identify"].includes(e.type)&&function(e){if(!oX(e.traits))throw new iW(".traits",oQ)}(e)}(d),d},e}();let o5=()=>`node-next-${Date.now()}-${oe()}`;class o4 extends o2{constructor(){super({createMessageId:o5,onFinishedEvent:e=>{!function(e){var t,n,r,i=".userId/anonymousId/previousId/groupId",o=null!=(r=null!=(n=null!=(t=e.userId)?t:e.anonymousId)?n:e.groupId)?r:e.previousId;if(null!=o){if(!oJ(o))throw new iW(i,oY)}else throw new iW(i,oZ)}(e)}})}}var o3=function(){function e(){this._logs=[]}return e.prototype.log=function(e,t,n){var r=new Date;this._logs.push({level:e,message:t,time:r,extras:n})},Object.defineProperty(e.prototype,"logs",{get:function(){return this._logs},enumerable:!1,configurable:!0}),e.prototype.flush=function(){if(this.logs.length>1){var e=this._logs.reduce(function(e,t){var n,r,i,o=(0,iV.__assign)((0,iV.__assign)({},t),{json:JSON.stringify(t.extras,null," "),extras:t.extras});delete o.time;var a=null!=(i=null==(r=t.time)?void 0:r.toISOString())?i:"";return e[a]&&(a="".concat(a,"-").concat(Math.random())),(0,iV.__assign)((0,iV.__assign)({},e),((n={})[a]=o,n))},{});console.table?console.table(e):console.log(e)}else this.logs.forEach(function(e){var t=e.level,n=e.message,r=e.extras;"info"===t||"debug"===t?console.log(n,null!=r?r:""):console[t](n,null!=r?r:"")});this._logs=[]},e}(),o6=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return(0,iV.__extends)(t,e),t.prototype.gauge=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t]},t.prototype.increment=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t]},t.prototype.flush=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t]},t.prototype.serialize=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return[]},t}(function(){function e(){this.metrics=[]}return e.prototype.increment=function(e,t,n){void 0===t&&(t=1),this.metrics.push({metric:e,value:t,tags:null!=n?n:[],type:"counter",timestamp:Date.now()})},e.prototype.gauge=function(e,t,n){this.metrics.push({metric:e,value:t,tags:null!=n?n:[],type:"gauge",timestamp:Date.now()})},e.prototype.flush=function(){var e=this.metrics.map(function(e){return(0,iV.__assign)((0,iV.__assign)({},e),{tags:e.tags.join(",")})});console.table?console.table(e):console.log(e),this.metrics=[]},e.prototype.serialize=function(){return this.metrics.map(function(e){return{m:e.metric,v:e.value,t:e.tags,k:({gauge:"g",counter:"c"})[e.type],e:e.timestamp}})},e}()),o8=function(e){var t,n,r;this.retry=null==(t=e.retry)||t,this.type=null!=(n=e.type)?n:"plugin Error",this.reason=null!=(r=e.reason)?r:""},o9=function(){function e(e,t,n,r){void 0===t&&(t=oe()),void 0===n&&(n=new o6),void 0===r&&(r=new o3),this.attempts=0,this.event=e,this._id=t,this.logger=r,this.stats=n}return e.system=function(){},e.prototype.isSame=function(e){return e.id===this.id},e.prototype.cancel=function(e){if(e)throw e;throw new o8({reason:"Context Cancel"})},e.prototype.log=function(e,t,n){this.logger.log(e,t,n)},Object.defineProperty(e.prototype,"id",{get:function(){return this._id},enumerable:!1,configurable:!0}),e.prototype.updateEvent=function(e,t){var n;if("integrations"===e.split(".")[0]){var r=e.split(".")[1];if((null==(n=this.event.integrations)?void 0:n[r])===!1)return this.event}return o0(this.event,e,t),this.event},e.prototype.failedDelivery=function(){return this._failedDelivery},e.prototype.setFailedDelivery=function(e){this._failedDelivery=e},e.prototype.logs=function(){return this.logger.logs},e.prototype.flush=function(){this.logger.flush(),this.stats.flush()},e.prototype.toJSON=function(){return{id:this._id,event:this.event,logs:this.logger.logs,metrics:this.stats.metrics}},e}();class o7 extends o9{static system(){return new this({type:"track",event:"system"})}}let ae=async(e,t,n,r)=>{try{let i=new o7(e),o=await function(e,t,n,r){return(0,iV.__awaiter)(this,void 0,void 0,function(){var i,o;return(0,iV.__generator)(this,function(a){switch(a.label){case 0:if(n.emit("dispatch_start",e),i=Date.now(),!t.isEmpty())return[3,2];return[4,t.dispatchSingle(e)];case 1:return o=a.sent(),[3,4];case 2:return[4,t.dispatch(e)];case 3:o=a.sent(),a.label=4;case 4:var s,l,c,u,d,p;if(!(null==r?void 0:r.callback))return[3,6];return[4,(c=o,u=r.callback,s=i,d=Math.max((null!=(l=r.timeout)?l:300)-(Date.now()-s),0),p=function(){try{return Promise.resolve(u(c))}catch(e){return Promise.reject(e)}},iG(d).then(function(){return iK(p(),1e3)}).catch(function(e){null==c||c.log("warn","Callback Error",{error:e}),null==c||c.stats.increment("callback_error")}).then(function(){return c}))];case 5:o=a.sent(),a.label=6;case 6:return(null==r?void 0:r.debug)&&o.flush(),[2,o]}})})}(i,t,n,{...r?{callback:e=>{let t=e.failedDelivery();return r(t?t.reason:void 0,e)}}:{}}),a=o.failedDelivery();a?n.emit("error",{code:"delivery_failure",reason:a.reason,ctx:o}):n.emit(e.type,o)}catch(e){n.emit("error",{code:"unknown",reason:e})}};class at extends oH{}var an="onRemoveFromFuture",ar=function(e){function t(t,n,r){var i=e.call(this)||this;return i.future=[],i.maxAttempts=t,i.queue=n,i.seen=null!=r?r:{},i}return(0,iV.__extends)(t,e),t.prototype.push=function(){for(var e=this,t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];var r=t.map(function(t){return!(e.updateAttempts(t)>e.maxAttempts||e.includes(t))&&(e.queue.push(t),!0)});return this.queue=this.queue.sort(function(t,n){return e.getAttempts(t)-e.getAttempts(n)}),r},t.prototype.pushWithBackoff=function(e,t){var n=this;if(void 0===t&&(t=0),0==t&&0===this.getAttempts(e))return this.push(e)[0];var r=this.updateAttempts(e);if(r>this.maxAttempts||this.includes(e))return!1;var i=iJ({attempt:r-1});return t>0&&i<t&&(i=t),setTimeout(function(){n.queue.push(e),n.future=n.future.filter(function(t){return t.id!==e.id}),n.emit(an)},i),this.future.push(e),!0},t.prototype.getAttempts=function(e){var t;return null!=(t=this.seen[e.id])?t:0},t.prototype.updateAttempts=function(e){return this.seen[e.id]=this.getAttempts(e)+1,this.getAttempts(e)},t.prototype.includes=function(e){return this.queue.includes(e)||this.future.includes(e)||!!this.queue.find(function(t){return t.id===e.id})||!!this.future.find(function(t){return t.id===e.id})},t.prototype.pop=function(){return this.queue.shift()}
31,Object.defineProperty(t.prototype,"length",{get:function(){return this.queue.length},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"todo",{get:function(){return this.queue.length+this.future.length},enumerable:!1,configurable:!0}),t}(oH),ai=function(){var e,t,n=0;return{done:function(){return e},run:function(r){var i=r();return"object"==typeof i&&null!==i&&"then"in i&&"function"==typeof i.then&&(1==++n&&(e=new Promise(function(e){return t=e})),i.finally(function(){return 0==--n&&t()})),i}}};function ao(e,t){e.log("debug","plugin",{plugin:t.name});var n=new Date().getTime(),r=t[e.event.type];return void 0===r?Promise.resolve(e):(function(e){return(0,iV.__awaiter)(this,void 0,void 0,function(){return(0,iV.__generator)(this,function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,e()];case 1:return[2,t.sent()];case 2:return[2,Promise.reject(t.sent())];case 3:return[2]}})})})(function(){return r.apply(t,[e])}).then(function(e){var r=new Date().getTime()-n;return e.stats.gauge("plugin_time",r,["plugin:".concat(t.name)]),e}).catch(function(n){if(n instanceof o8&&"middleware_cancellation"===n.type)throw n;return n instanceof o8?e.log("warn",n.type,{plugin:t.name,error:n}):(e.log("error","plugin Error",{plugin:t.name,error:n}),e.stats.increment("plugin_error",1,["plugin:".concat(t.name)])),n})}var aa=function(e){function t(t){var n=e.call(this)||this;return n.criticalTasks=ai(),n.plugins=[],n.failedInitializations=[],n.flushing=!1,n.queue=t,n.queue.on(an,function(){n.scheduleFlush(0)}),n}return(0,iV.__extends)(t,e),t.prototype.register=function(e,t,n){return(0,iV.__awaiter)(this,void 0,void 0,function(){var r,i,o=this;return(0,iV.__generator)(this,function(a){switch(a.label){case 0:if(this.plugins.push(t),r=function(n){o.failedInitializations.push(t.name),o.emit("initialization_failure",t),console.warn(t.name,n),e.log("warn","Failed to load destination",{plugin:t.name,error:n}),o.plugins=o.plugins.filter(function(e){return e!==t})},"destination"!==t.type||"Segment.io"===t.name)return[3,1];return t.load(e,n).catch(r),[3,4];case 1:return a.trys.push([1,3,,4]),[4,t.load(e,n)];case 2:return a.sent(),[3,4];case 3:return i=a.sent(),r(i),[3,4];case 4:return[2]}})})},t.prototype.deregister=function(e,t,n){return(0,iV.__awaiter)(this,void 0,void 0,function(){var r;return(0,iV.__generator)(this,function(i){switch(i.label){case 0:if(i.trys.push([0,3,,4]),!t.unload)return[3,2];return[4,Promise.resolve(t.unload(e,n))];case 1:i.sent(),i.label=2;case 2:return this.plugins=this.plugins.filter(function(e){return e.name!==t.name}),[3,4];case 3:return r=i.sent(),e.log("warn","Failed to unload destination",{plugin:t.name,error:r}),[3,4];case 4:return[2]}})})},t.prototype.dispatch=function(e){return(0,iV.__awaiter)(this,void 0,void 0,function(){var t;return(0,iV.__generator)(this,function(n){return e.log("debug","Dispatching"),e.stats.increment("message_dispatched"),this.queue.push(e),t=this.subscribeToDelivery(e),this.scheduleFlush(0),[2,t]})})},t.prototype.subscribeToDelivery=function(e){return(0,iV.__awaiter)(this,void 0,void 0,function(){var t=this;return(0,iV.__generator)(this,function(n){return[2,new Promise(function(n){var r=function(i,o){i.isSame(e)&&(t.off("flush",r),n(i))};t.on("flush",r)})]})})},t.prototype.dispatchSingle=function(e){return(0,iV.__awaiter)(this,void 0,void 0,function(){var t=this;return(0,iV.__generator)(this,function(n){return e.log("debug","Dispatching"),e.stats.increment("message_dispatched"),this.queue.updateAttempts(e),e.attempts=1,[2,this.deliver(e).catch(function(n){return t.enqueuRetry(n,e)?t.subscribeToDelivery(e):(e.setFailedDelivery({reason:n}),e)})]})})},t.prototype.isEmpty=function(){return 0===this.queue.length},t.prototype.scheduleFlush=function(e){var t=this;void 0===e&&(e=500),this.flushing||(this.flushing=!0,setTimeout(function(){t.flush().then(function(){setTimeout(function(){t.flushing=!1,t.queue.length&&t.scheduleFlush(0)},0)})},e))},t.prototype.deliver=function(e){return(0,iV.__awaiter)(this,void 0,void 0,function(){var t,n,r,i;return(0,iV.__generator)(this,function(o){switch(o.label){case 0:return[4,this.criticalTasks.done()];case 1:o.sent(),t=Date.now(),o.label=2;case 2:return o.trys.push([2,4,,5]),[4,this.flushOne(e)];
31case 3:return e=o.sent(),n=Date.now()-t,this.emit("delivery_success",e),e.stats.gauge("delivered",n),e.log("debug","Delivered",e.event),[2,e];case 4:throw i=r=o.sent(),e.log("error","Failed to deliver",i),this.emit("delivery_failure",e,i),e.stats.increment("delivery_failed"),r;case 5:return[2]}})})},t.prototype.enqueuRetry=function(e,t){return!!(!(e instanceof o8)||e.retry)&&this.queue.pushWithBackoff(t)},t.prototype.flush=function(){return(0,iV.__awaiter)(this,void 0,void 0,function(){var e,t;return(0,iV.__generator)(this,function(n){switch(n.label){case 0:if(0===this.queue.length||!(e=this.queue.pop()))return[2,[]];e.attempts=this.queue.getAttempts(e),n.label=1;case 1:return n.trys.push([1,3,,4]),[4,this.deliver(e)];case 2:return e=n.sent(),this.emit("flush",e,!0),[3,4];case 3:return t=n.sent(),this.enqueuRetry(t,e)||(e.setFailedDelivery({reason:t}),this.emit("flush",e,!1)),[2,[]];case 4:return[2,[e]]}})})},t.prototype.isReady=function(){return!0},t.prototype.availableExtensions=function(e){var t,n,r=(t="type",n={},this.plugins.filter(function(t){if("destination"!==t.type&&"Segment.io"!==t.name)return!0;var n,r,i,o=void 0;return null==(n=t.alternativeNames)||n.forEach(function(t){void 0!==e[t]&&(o=e[t])}),null!=(i=null!=(r=e[t.name])?r:o)?i:!1!==("Segment.io"===t.name||e.All)}).forEach(function(e){var r,i=void 0;if("string"==typeof t){var o=e[t];i="string"!=typeof o?JSON.stringify(o):o}else t instanceof Function&&(i=t(e));void 0!==i&&(n[i]=(0,iV.__spreadArray)((0,iV.__spreadArray)([],null!=(r=n[i])?r:[],!0),[e],!1))}),n),i=r.before,o=r.enrichment,a=r.destination,s=r.after;return{before:void 0===i?[]:i,enrichment:void 0===o?[]:o,destinations:void 0===a?[]:a,after:void 0===s?[]:s}},t.prototype.flushOne=function(e){var t,n;return(0,iV.__awaiter)(this,void 0,void 0,function(){var r,i,o,a,s,l,c,u,d,p,f,h,g;return(0,iV.__generator)(this,function(m){switch(m.label){case 0:if(!this.isReady())throw Error("Not ready");e.attempts>1&&this.emit("delivery_retry",e),i=(r=this.availableExtensions(null!=(t=e.event.integrations)?t:{})).before,o=r.enrichment,a=0,s=i,m.label=1;case 1:var y;if(!(a<s.length))return[3,4];return l=s[a],[4,ao(y=e,l).then(function(e){if(e instanceof o9)return e;y.log("debug","Context canceled"),y.stats.increment("context_canceled"),y.cancel(e)})];case 2:(c=m.sent())instanceof o9&&(e=c),this.emit("message_enriched",e,l),m.label=3;case 3:return a++,[3,1];case 4:u=0,d=o,m.label=5;case 5:if(!(u<d.length))return[3,8];return p=d[u],[4,ao(e,p)];case 6:(c=m.sent())instanceof o9&&(e=c),this.emit("message_enriched",e,p),m.label=7;case 7:return u++,[3,5];case 8:return h=(f=this.availableExtensions(null!=(n=e.event.integrations)?n:{})).destinations,g=f.after,[4,new Promise(function(t,n){setTimeout(function(){Promise.all(h.map(function(t){return ao(e,t)})).then(t).catch(n)},0)})];case 9:return m.sent(),e.stats.increment("message_delivered"),this.emit("message_delivered",e),[4,Promise.all(g.map(function(t){return ao(e,t)}))];case 10:return m.sent(),[2,e]}})})},t}(oH);class as extends ar{constructor(){super(1,[])}getAttempts(e){return e.attempts??0}updateAttempts(e){return e.attempts=this.getAttempts(e)+1,this.getAttempts(e)}}class al extends aa{constructor(){super(new as)}}class AbortSignal{onabort=null;aborted=!1;eventEmitter=new oH;toString(){return"[object AbortSignal]"}get[Symbol.toStringTag](){return"AbortSignal"}removeEventListener(...e){this.eventEmitter.off(...e)}addEventListener(...e){this.eventEmitter.on(...e)}dispatchEvent(e){let t={type:e,target:this},n=`on${e}`;"function"==typeof this[n]&&this[n](t),this.eventEmitter.emit(e,t)}}class ac{signal=new AbortSignal;abort(){this.signal.aborted||(this.signal.aborted=!0,this.signal.dispatchEvent("abort"))}toString(){return"[object AbortController]"}get[Symbol.toStringTag](){return"AbortController"}}let au=async(...t)=>{if(globalThis.fetch)return globalThis.fetch(...t);if("string"!=typeof EdgeRuntime)return(await e.A(833430)).default(...t);throw Error("Invariant: an edge runtime that does not support fetch should not exist")};class ad{_fetch;constructor(e){this._fetch=e??au}
31async makeRequest(e){let[t,n]=(e=>{if("cloudflare-worker"===oq())return[];let t=new(globalThis.AbortController||ac),n=setTimeout(()=>{t.abort()},e);return n?.unref?.(),[t.signal,n]})(e.httpRequestTimeout),r={url:e.url,method:e.method,headers:e.headers,body:e.body,signal:t};return this._fetch(e.url,r).finally(()=>clearTimeout(n))}}class ap extends at{_eventFactory;_isClosed=!1;_pendingEvents=0;_closeAndFlushDefaultTimeout;_publisher;_isFlushing=!1;_queue;ready;constructor(e){super();if(!e.writeKey)throw new iW("writeKey","writeKey is missing.");this._eventFactory=new o4,this._queue=new al;const t=e.flushInterval??1e4;this._closeAndFlushDefaultTimeout=1.25*t;const{plugin:n,publisher:r}=((e,t)=>{let n=new oV(e,t);return{publisher:n,plugin:function(e){function t(t){let n;return t.updateEvent("context.library.name","@segment/analytics-node"),t.updateEvent("context.library.version",iq),"node"===(n=oq())&&t.updateEvent("_metadata.nodeVersion",nE.default.version),t.updateEvent("_metadata.jsRuntime",n),e.enqueue(t)}return{name:"Segment.io",type:"destination",version:"1.0.0",isLoaded:()=>!0,load:()=>Promise.resolve(),alias:t,group:t,identify:t,page:t,screen:t,track:t}}(n)}})({writeKey:e.writeKey,host:e.host,path:e.path,maxRetries:e.maxRetries??3,flushAt:e.flushAt??e.maxEventsInBatch??15,httpRequestTimeout:e.httpRequestTimeout,disable:e.disable,flushInterval:t,httpClient:"function"==typeof e.httpClient?new ad(e.httpClient):e.httpClient??new ad,oauthSettings:e.oauthSettings},this);this._publisher=r,this.ready=this.register(n).then(()=>void 0),this.emit("initialize",e),function(e){for(var t=e.constructor.prototype,n=0,r=Object.getOwnPropertyNames(t);n<r.length;n++){var i=r[n];if("constructor"!==i){var o=Object.getOwnPropertyDescriptor(e.constructor.prototype,i);o&&"function"==typeof o.value&&(e[i]=e[i].bind(e))}}}(this)}get VERSION(){return iq}closeAndFlush({timeout:e=this._closeAndFlushDefaultTimeout}={}){return this.flush({timeout:e,close:!0})}async flush({timeout:e,close:t=!1}={}){if(this._isFlushing)return void console.warn("Overlapping flush calls detected. Please wait for the previous flush to finish before calling .flush again");this._isFlushing=!0,t&&(this._isClosed=!0),this._publisher.flush(this._pendingEvents);let n=new Promise(e=>{this._pendingEvents?this.once("drained",()=>{e()}):e()}).finally(()=>{this._isFlushing=!1});return e?iK(n,e).catch(()=>void 0):n}_dispatch(e,t){this._isClosed?this.emit("call_after_close",e):(this._pendingEvents++,ae(e,this._queue,this,t).catch(e=>e).finally(()=>{this._pendingEvents--,this._pendingEvents||this.emit("drained")}))}alias({userId:e,previousId:t,context:n,timestamp:r,integrations:i,messageId:o},a){let s=this._eventFactory.alias(e,t,{context:n,integrations:i,timestamp:r,messageId:o});this._dispatch(s,a)}group({timestamp:e,groupId:t,userId:n,anonymousId:r,traits:i={},context:o,integrations:a,messageId:s},l){let c=this._eventFactory.group(t,i,{context:o,anonymousId:r,userId:n,timestamp:e,integrations:a,messageId:s});this._dispatch(c,l)}identify({userId:e,anonymousId:t,traits:n={},context:r,timestamp:i,integrations:o,messageId:a},s){let l=this._eventFactory.identify(e,n,{context:r,anonymousId:t,userId:e,timestamp:i,integrations:o,messageId:a});this._dispatch(l,s)}page({userId:e,anonymousId:t,category:n,name:r,properties:i,context:o,timestamp:a,integrations:s,messageId:l},c){let u=this._eventFactory.page(n??null,r??null,i,{context:o,anonymousId:t,userId:e,timestamp:a,integrations:s,messageId:l});this._dispatch(u,c)}screen({userId:e,anonymousId:t,category:n,name:r,properties:i,context:o,timestamp:a,integrations:s,messageId:l},c){let u=this._eventFactory.screen(n??null,r??null,i,{context:o,anonymousId:t,userId:e,timestamp:a,integrations:s,messageId:l});this._dispatch(u,c)}track({userId:e,anonymousId:t,event:n,properties:r,context:i,timestamp:o,integrations:a,messageId:s},l){let c=this._eventFactory.track(n,r,{context:i,userId:e,anonymousId:t,timestamp:o,integrations:a,messageId:s});this._dispatch(c,l)}register(...e){return this._queue.criticalTasks.run(async()=>
31{let t=o7.system(),n=e.map(e=>this._queue.register(t,e,this));await Promise.all(n),this.emit("register",e.map(e=>e.name))})}async deregister(...e){let t=o7.system(),n=e.map(e=>{let n=this._queue.plugins.find(t=>t.name===e);if(n)return this._queue.deregister(t,n,this);t.log("warn",`plugin ${e} not found`)});await Promise.all(n),this.emit("deregister",e)}}e.s([],972699),e.s([],405310),e.i(972699),e.s(["Analytics",()=>ap],685208);let af=/\r\n|[\n\r]/g;function ah(e,t){let n=0,r=1;for(let i of e.body.matchAll(af)){if("number"==typeof i.index||function(e,t){if(!e)throw Error("Unexpected invariant triggered.")}(!1),i.index>=t)break;n=i.index+i[0].length,r+=1}return{line:r,column:t+1-n}}function ag(e,t){let n=e.locationOffset.column-1,r="".padStart(n)+e.body,i=t.line-1,o=e.locationOffset.line-1,a=t.line+o,s=1===t.line?n:0,l=t.column+s,c=`${e.name}:${a}:${l} 32`,u=r.split(/\r\n|[\n\r]/g),d=u[i];if(d.length>120){let e=Math.floor(l/80),t=[];for(let e=0;e<d.length;e+=80)t.push(d.slice(e,e+80));return c+am([[`${a} |`,t[0]],...t.slice(1,e+1).map(e=>["|",e]),["|","^".padStart(l%80)],["|",t[e+1]]])}return c+am([[`${a-1} |`,u[i-1]],[`${a} |`,d],["|","^".padStart(l)],[`${a+1} |`,u[i+1]]])}function am(e){let t=e.filter(([e,t])=>void 0!==t),n=Math.max(...t.map(([e])=>e.length));return t.map(([e,t])=>e.padStart(n)+(t?" "+t:"")).join("\n")}class ay extends Error{constructor(e,...t){var n,r,i;const{nodes:o,source:a,positions:s,path:l,originalError:c,extensions:u}=function(e){let t=e[0];return null==t||"kind"in t||"length"in t?{nodes:t,source:e[1],positions:e[2],path:e[3],originalError:e[4],extensions:e[5]}:t}(t);super(e),this.name="GraphQLError",this.path=null!=l?l:void 0,this.originalError=null!=c?c:void 0,this.nodes=ak(Array.isArray(o)?o:o?[o]:void 0);const d=ak(null==(n=this.nodes)?void 0:n.map(e=>e.loc).filter(e=>null!=e));this.source=null!=a?a:null==d||null==(r=d[0])?void 0:r.source,this.positions=null!=s?s:null==d?void 0:d.map(e=>e.start),this.locations=s&&a?s.map(e=>ah(a,e)):null==d?void 0:d.map(e=>ah(e.source,e.start));const p=!function(e){return"object"==typeof e&&null!==e}(null==c?void 0:c.extensions)||null==c?void 0:c.extensions;this.extensions=null!=(i=null!=u?u:p)?i:Object.create(null),Object.defineProperties(this,{message:{writable:!0,enumerable:!0},name:{enumerable:!1},nodes:{enumerable:!1},source:{enumerable:!1},positions:{enumerable:!1},originalError:{enumerable:!1}}),null!=c&&c.stack?Object.defineProperty(this,"stack",{value:c.stack,writable:!0,configurable:!0}):Error.captureStackTrace?Error.captureStackTrace(this,ay):Object.defineProperty(this,"stack",{value:Error().stack,writable:!0,configurable:!0})}get[Symbol.toStringTag](){return"GraphQLError"}toString(){let e=this.message;if(this.nodes)for(let n of this.nodes){var t;n.loc&&(e+="\n\n"+ag((t=n.loc).source,ah(t.source,t.start)))}else if(this.source&&this.locations)for(let t of this.locations)e+="\n\n"+ag(this.source,t);return e}toJSON(){let e={message:this.message};return null!=this.locations&&(e.locations=this.locations),null!=this.path&&(e.path=this.path),null!=this.extensions&&Object.keys(this.extensions).length>0&&(e.extensions=this.extensions),e}}function ak(e){return void 0===e||0===e.length?void 0:e}e.s(["GraphQLError",()=>ay],1770);let av=((s={}).CRITICAL="critical",s.WARNING="warning",s.INFO="info",s),ab=((l={}).BANNER="banner",l.TOAST="toast",l.SILENT="silent",l.DEV_ONLY="dev_only",l),ax=((c={}).NETWORK_ERROR="NETWORK_ERROR",c.NOT_FOUND="NOT_FOUND",c.AGENT_NOT_FOUND="AGENT_NOT_FOUND",c.API_NOT_FOUND="API_NOT_FOUND",c.REMOTE_ENDPOINT_NOT_FOUND="REMOTE_ENDPOINT_NOT_FOUND",c.AUTHENTICATION_ERROR="AUTHENTICATION_ERROR",c.MISUSE="MISUSE",c.UNKNOWN="UNKNOWN",c.VERSION_MISMATCH="VERSION_MISMATCH",c.CONFIGURATION_ERROR="CONFIGURATION_ERROR",c.MISSING_PUBLIC_API_KEY_ERROR="MISSING_PUBLIC_API_KEY_ERROR",c.UPGRADE_REQUIRED_ERROR="UPGRADE_REQUIRED_ERROR",c),aw="https://docs.copilotkit.ai",aE=e=>`See more: [${e}](${e})`,aS={[ax.NETWORK_ERROR]:{statusCode:503,troubleshootingUrl:`${aw}/troubleshooting/common-issues#i-am-getting-a-network-errors--api-not-found`,visibility:ab.BANNER,severity:av.CRITICAL},[ax.NOT_FOUND]:{statusCode:404,troubleshootingUrl:`${aw}/troubleshooting/common-issues#i-am-getting-a-network-errors--api-not-found`,visibility:ab.BANNER,severity:av.CRITICAL},[ax.AGENT_NOT_FOUND]:{statusCode:500,troubleshootingUrl:`${aw}/coagents/troubleshooting/common-issues#i-am-getting-agent-not-found-error`,visibility:ab.BANNER,severity:av.CRITICAL},[ax.API_NOT_FOUND]:{statusCode:404,troubleshootingUrl:`${aw}/troubleshooting/common-issues#i-am-getting-a-network-errors--api-not-found`,visibility:ab.BANNER,severity:av.CRITICAL},[ax.REMOTE_ENDPOINT_NOT_FOUND]:{statusCode:404,troubleshootingUrl:`${aw}/troubleshooting/common-issues#i-am-getting-copilotkits-remote-endpoint-not-found-error`,visibility:ab.BANNER,severity:av.CRITICAL},[ax.AUTHENTICATION_ERROR]:{statusCode:401,troubleshootingUrl:`${aw}/troubleshooting/common-issues#authentication-errors`,visibility:ab.BANNER,severity:av.CRITICAL},[ax.MISUSE]:{statusCode:400,troubleshootingUrl:null,visibility:ab.DEV_ONLY,severity:av.WARNING},[ax.UNKNOWN]:{statusCode:500,visibility:ab.TOAST,severity:av.CRITICAL},[ax.CONFIGURATION_ERROR]:{statusCode:400,troubleshootingUrl:null,severity:av.WARNING,visibility:ab.BANNER},[ax.MISSING_PUBLIC_API_KEY_ERROR]:{statusCode:400,troubleshootingUrl:null,severity:av.CRITICAL,visibility:ab.BANNER},[ax.UPGRADE_REQUIRED_ERROR]:{statusCode:402,troubleshootingUrl:null,severity:av.WARNING,visibility:ab.BANNER},[ax.VERSION_MISMATCH]:{statusCode:400,troubleshootingUrl:null,visibility:ab.DEV_ONLY,severity:av.INFO}};var aC=class extends ay{constructor({message:e="Unknown error occurred",code:t,severity:n,visibility:r}){const i="CopilotError",o=aS[t],{statusCode:a}=o,s=r??o.visibility??ab.TOAST,l=n??("severity"in o?o.severity:void 0);super(e,{extensions:{name:i,statusCode:a,code:t,visibility:s,severity:l,troubleshootingUrl:"troubleshootingUrl"in o?o.troubleshootingUrl:null,originalError:{message:e,stack:Error().stack}}}),this.code=t,this.name=i,this.statusCode=a,this.severity=l,this.visibility=s}},aT=class extends aC{constructor(e={}){const t=e.url??"";let n="";t?.includes("/info")?n="when fetching CopilotKit info":t.includes("/actions/execute")?n="when attempting to execute actions.":t.includes("/agents/state")?n="when attempting to get agent state.":t.includes("/agents/execute")&&(n="when attempting to execute agent(s).");const r=e.message??(e.url?`Failed to find CopilotKit API endpoint at url ${e.url} ${n}`:"Failed to find CopilotKit API endpoint."),i=e.code??ax.API_NOT_FOUND;super({message:`${r}. 33 34${aE(aS[i].troubleshootingUrl)}`,code:i}),this.name="CopilotApiDiscoveryError"}},aN=class extends aT{constructor(e){super({message:e?.message??(e?.url?`Failed to find or contact remote endpoint at url ${e.url}`:"Failed to find or contact remote endpoint"),code:ax.REMOTE_ENDPOINT_NOT_FOUND}),this.name="CopilotKitRemoteEndpointDiscoveryError"}},aA=class extends aC{constructor(e){let t;const{agentName:n,availableAgents:r}=e,i=ax.AGENT_NOT_FOUND,o=aE(aS[i].troubleshootingUrl);if(r.length){const e=r.map(e=>e.name).join(", ");t=n?`Agent '${n}' was not found. Available agents are: ${e}. Please verify the agent name in your configuration and ensure it matches one of the available agents. 35 36${o}`:`The requested agent was not found. Available agents are: ${e}. Please verify the agent name in your configuration and ensure it matches one of the available agents. 37 38${o}`}else t=`${n?`Agent '${n}'`:"The requested agent"} was not found. Please set up at least one agent before proceeding. ${o}`;super({message:t,code:i}),this.name="CopilotKitAgentDiscoveryError"}},a_=class extends aC{constructor({error:e,url:t,message:n}
38){let r=ax.NETWORK_ERROR;super({message:n??aM({errorCode:e.code,url:t}),code:r}),this.name="CopilotKitLowLevelError"}},aI=class extends aC{constructor(e){super({message:e,code:ax.CONFIGURATION_ERROR}),this.name="ConfigurationError",this.severity=av.WARNING}},aR=class extends aI{constructor(e){super(e),this.name="MissingPublicApiKeyError",this.severity=av.CRITICAL}};let aM=({errorCode:e,url:t})=>{let n=aS[ax.NETWORK_ERROR].troubleshootingUrl,r=(e=`Failed to fetch from url ${t}.`)=>`${e}. 39 40Possible reasons: 41- -The server may have an error preventing it from returning a response (Check the server logs for more info). 42- -The server might be down or unreachable 43- -There might be a network issue (e.g., DNS failure, connection timeout) 44- -The URL might be incorrect 45- -The server is not running on the specified port 46 47${aE(n)}`;if(t.includes("/info"))return r(`Failed to fetch CopilotKit agents/action information from url ${t}.`);if(t.includes("/actions/execute"))return r(`Fetch call to ${t} to execute actions failed.`);if(t.includes("/agents/state"))return r(`Fetch call to ${t} to get agent state failed.`);if(t.includes("/agents/execute"))return r(`Fetch call to ${t} to execute agent(s) failed.`);switch(e){case"ECONNREFUSED":return`Connection to ${t} was refused. Ensure the server is running and accessible. 48 49${aE(n)}`;case"ENOTFOUND":return`The server on ${t} could not be found. Check the URL or your network configuration. 50 51${aE(aS[ax.NOT_FOUND].troubleshootingUrl)}`;case"ETIMEDOUT":return`The connection to ${t} timed out. The server might be overloaded or taking too long to respond. 52 53${aE(n)}`;default:return}};var aO=e.i(775780);function aj(e){return e&&"object"==typeof e?"position"in e||"type"in e?aD(e.position):"start"in e||"end"in e?aD(e):"line"in e||"column"in e?az(e):"":""}function az(e){return aP(e&&e.line)+":"+aP(e&&e.column)}function aD(e){return az(e&&e.start)+"-"+az(e&&e.end)}function aP(e){return e&&"number"==typeof e?e:1}class aF extends Error{constructor(e,t,n){const r=[null,null];let i={start:{line:null,column:null},end:{line:null,column:null}};if(super(),"string"==typeof t&&(n=t,t=void 0),"string"==typeof n){const e=n.indexOf(":");-1===e?r[1]=n:(r[0]=n.slice(0,e),r[1]=n.slice(e+1))}t&&("type"in t||"position"in t?t.position&&(i=t.position):"start"in t||"end"in t?i=t:("line"in t||"column"in t)&&(i.start=t)),this.name=aj(t)||"1:1",this.message="object"==typeof e?e.message:e,this.stack="","object"==typeof e&&e.stack&&(this.stack=e.stack),this.reason=this.message,this.fatal,this.line=i.start.line,this.column=i.start.column,this.position=i,this.source=r[0],this.ruleId=r[1],this.file,this.actual,this.expected,this.url,this.note}}aF.prototype.file="",aF.prototype.name="",aF.prototype.reason="",aF.prototype.message="",aF.prototype.stack="",aF.prototype.fatal=null,aF.prototype.column=null,aF.prototype.line=null,aF.prototype.source=null,aF.prototype.ruleId=null,aF.prototype.position=null;let aL=function(e,t){let n;if(void 0!==t&&"string"!=typeof t)throw TypeError('"ext" argument must be a string');aH(e);let r=0,i=-1,o=e.length;if(void 0===t||0===t.length||t.length>e.length){for(;o--;)if(47===e.charCodeAt(o)){if(n){r=o+1;break}}else i<0&&(n=!0,i=o+1);return i<0?"":e.slice(r,i)}if(t===e)return"";let a=-1,s=t.length-1;for(;o--;)if(47===e.charCodeAt(o)){if(n){r=o+1;break}}else a<0&&(n=!0,a=o+1),s>-1&&(e.charCodeAt(o)===t.charCodeAt(s--)?s<0&&(i=o):(s=-1,i=a));return r===i?i=a:i<0&&(i=e.length),e.slice(r,i)},aU=function(e){let t;if(aH(e),0===e.length)return".";let n=-1,r=e.length;for(;--r;)if(47===e.charCodeAt(r)){if(t){n=r;break}}else t||(t=!0);return n<0?47===e.charCodeAt(0)?"/":".":1===n&&47===e.charCodeAt(0)?"//":e.slice(0,n)},aB=function(e){let t;aH(e);let n=e.length,r=-1,i=0,o=-1,a=0;for(;n--;){let s=e.charCodeAt(n);if(47===s){if(t){i=n+1;break}continue}r<0&&(t=!0,r=n+1),46===s?o<0?o=n:1!==a&&(a=1):o>-1&&(a=-1)}return o<0||r<0||0===a||1===a&&o===r-1&&o===i+1?"":e.slice(o,r)},a$=function(...e){var t;let n,r,i,o=-1;for(;++o<e.length;)aH(e[o]),e[o]&&(i=void 0===i?e[o]:i+"/"+e[o]);return void 0===i?".":(aH(t=i),n=47===t.charCodeAt(0),0!==(r=function(e,t){let n,r,i="",o=0,a=-1,s=0,l=-1;for(;++l<=e.length;){if(l<e.length)n=e.charCodeAt(l);else if(47===n)break;else n=47;if(47===n){if(a===l-1||1===s);else if(a!==l-1&&2===s){if(i.length<2||2!==o||46!==i.charCodeAt(i.length-1)||46!==i.charCodeAt(i.length-2)){if(i.length>2){if((r=i.lastIndexOf("/"))!==i.length-1){r<0?(i="",o=0):o=(i=i.slice(0,r)).length-1-i.lastIndexOf("/"),a=l,s=0;continue}}else if(i.length>0){i="",o=0,a=l,s=0;continue}}t&&(i=i.length>0?i+"/..":"..",o=2)}else i.length>0?i+="/"+e.slice(a+1,l):i=e.slice(a+1,l),o=l-a-1;a=l,s=0}else 46===n&&s>-1?s++:s=-1}return i}(t,!n)).length||n||(r="."),r.length>0&&47===t.charCodeAt(t.length-1)&&(r+="/"),n?"/"+r:r)};function aH(e){if("string"!=typeof e)throw TypeError("Path must be a string. Received "+JSON.stringify(e))}function aK(e){return null!==e&&"object"==typeof e&&e.href&&e.origin}let aG=["history","path","basename","stem","extname","dirname"];class aV{constructor(e){var t;let n,r;n=e?"string"==typeof e||(t=e,(0,aO.default)(t))?{value:e}:aK(e)?{path:e}:e:{},this.data={},this.messages=[],this.history=[],this.cwd="/",this.value,this.stored,this.result,this.map;let i=-1;for(;++i<aG.length;){const e=aG[i];e in n&&void 0!==n[e]&&null!==n[e]&&(this[e]="history"===e?[...n[e]]:n[e])}for(r in n)aG.includes(r)||(this[r]=n[r])}get path(){return this.history[this.history.length-1]}set path(e){aK(e)&&(e=function(e){if("string"==typeof e)e=new URL(e);else if(!aK(e)){let t=TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code="ERR_INVALID_ARG_TYPE",t}if("file:"!==e.protocol){let e=TypeError("The URL must be of scheme file");throw e.code="ERR_INVALID_URL_SCHEME",e}return function(e){if(""!==e.hostname){let e=TypeError('File URL host must be "localhost" or empty on darwin');throw e.code="ERR_INVALID_FILE_URL_HOST",e}let t=e.pathname,n=-1;for(;++n<t.length;)if(37===t.charCodeAt(n)&&50===t.charCodeAt(n+1)){let e=t.charCodeAt(n+2);if(70===e||102===e){let e=TypeError("File URL path must not include encoded / characters");throw e.code="ERR_INVALID_FILE_URL_PATH",e}}return decodeURIComponent(t)}(e)}(e)),aq(e,"path"),this.path!==e&&this.history.push(e)}get dirname(){return"string"==typeof this.path?aU(this.path):void 0}set dirname(e){aJ(this.basename,"dirname"),this.path=a$(e||"",this.basename)}get basename(){return"string"==typeof this.path?aL(this.path):void 0}
53set basename(e){aq(e,"basename"),aW(e,"basename"),this.path=a$(this.dirname||"",e)}get extname(){return"string"==typeof this.path?aB(this.path):void 0}set extname(e){if(aW(e,"extname"),aJ(this.dirname,"extname"),e){if(46!==e.charCodeAt(0))throw Error("`extname` must start with `.`");if(e.includes(".",1))throw Error("`extname` cannot contain multiple dots")}this.path=a$(this.dirname,this.stem+(e||""))}get stem(){return"string"==typeof this.path?aL(this.path,this.extname):void 0}set stem(e){aq(e,"stem"),aW(e,"stem"),this.path=a$(this.dirname||"",e+(this.extname||""))}toString(e){return(this.value||"").toString(e||void 0)}message(e,t,n){let r=new aF(e,t,n);return this.path&&(r.name=this.path+":"+r.name,r.file=this.path),r.fatal=!1,this.messages.push(r),r}info(e,t,n){let r=this.message(e,t,n);return r.fatal=null,r}fail(e,t,n){let r=this.message(e,t,n);throw r.fatal=!0,r}}function aW(e,t){if(e&&e.includes("/"))throw Error("`"+t+"` cannot be a path: did not expect `/`")}function aq(e,t){if(!e)throw Error("`"+t+"` cannot be empty")}function aJ(e,t){if(!e)throw Error("Setting `"+t+"` requires `path` to be set too")}var aX=e.i(534193),aY=e.i(104100),aQ=e.i(194511),aZ=e.i(553807);let a0=(function e(){let t,n=(0,aZ.trough)(),r=[],i={},o=-1;return a.data=function(e,n){return"string"==typeof e?2==arguments.length?(a3("data",t),i[e]=n,a):a1.call(i,e)&&i[e]||null:e?(a3("data",t),i=e,a):i},a.Parser=void 0,a.Compiler=void 0,a.freeze=function(){if(t)return a;for(;++o<r.length;){let[e,...t]=r[o];if(!1===t[0])continue;!0===t[0]&&(t[0]=void 0);let i=e.call(a,...t);"function"==typeof i&&n.use(i)}return t=!0,o=1/0,a},a.attachers=r,a.use=function(e,...n){let o;if(a3("use",t),null==e);else if("function"==typeof e)c(e,...n);else if("object"==typeof e)Array.isArray(e)?l(e):s(e);else throw TypeError("Expected usable value, not `"+e+"`");return o&&(i.settings=Object.assign(i.settings||{},o)),a;function s(e){l(e.plugins),e.settings&&(o=Object.assign(o||{},e.settings))}function l(e){let t=-1;if(null==e);else if(Array.isArray(e))for(;++t<e.length;)!function(e){if("function"==typeof e)c(e);else if("object"==typeof e)if(Array.isArray(e)){let[t,...n]=e;c(t,...n)}else s(e);else throw TypeError("Expected usable value, not `"+e+"`")}(e[t]);else throw TypeError("Expected a list of plugins, not `"+e+"`")}function c(e,t){let n,i=-1;for(;++i<r.length;)if(r[i][0]===e){n=r[i];break}n?((0,aQ.default)(n[1])&&(0,aQ.default)(t)&&(t=(0,aY.default)(!0,n[1],t)),n[1]=t):r.push([...arguments])}},a.parse=function(e){a.freeze();let t=a9(e),n=a.Parser;return(a5("parse",n),a2(n,"parse"))?new n(String(t),t).parse():n(String(t),t)},a.stringify=function(e,t){a.freeze();let n=a9(t),r=a.Compiler;return(a4("stringify",r),a6(e),a2(r,"compile"))?new r(e,n).compile():r(e,n)},a.run=function(e,t,r){if(a6(e),a.freeze(),r||"function"!=typeof t||(r=t,t=void 0),!r)return new Promise(i);function i(i,o){n.run(e,a9(t),function(t,n,a){n=n||e,t?o(t):i?i(n):r(null,n,a)})}i(null,r)},a.runSync=function(e,t){let n,r;return a.run(e,t,function(e,t){(0,aX.bail)(e),n=t,r=!0}),a8("runSync","run",r),n},a.process=function(e,t){if(a.freeze(),a5("process",a.Parser),a4("process",a.Compiler),!t)return new Promise(n);function n(n,r){let i=a9(e);function o(e,i){e||!i?r(e):n?n(i):t(null,i)}a.run(a.parse(i),i,(e,t,n)=>{if(!e&&t&&n){var r;let i=a.stringify(t,n);null==i||("string"==typeof(r=i)||(0,aO.default)(r)?n.value=i:n.result=i),o(e,n)}else o(e)})}n(null,t)},a.processSync=function(e){let t;a.freeze(),a5("processSync",a.Parser),a4("processSync",a.Compiler);let n=a9(e);return a.process(n,function(e){t=!0,(0,aX.bail)(e)}),a8("processSync","process",t),n},a;function a(){let t=e(),n=-1;for(;++n<r.length;)t.use(...r[n]);return t.data((0,aY.default)(!0,{},i)),t}})().freeze(),a1={}.hasOwnProperty;function a2(e,t){return"function"==typeof e&&e.prototype&&(function(e){let t;for(t in e)if(a1.call(e,t))return!0;return!1}(e.prototype)||t in e.prototype)}function a5(e,t){if("function"!=typeof t)throw TypeError("Cannot `"+e+"` without `Parser`")}function a4(e,t){if("function"!=typeof t)throw TypeError("Cannot `"+e+"` without `Compiler`")}function a3(e,t){if(t)throw Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function a6(e){if(!(0,aQ.default)(e)||"string"!=typeof e.type)throw TypeError("Expected node, got `"+e+"`")}function a8(e,t,n){if(!n)throw Error("`"+e+"` finished async. Use `"+t+"` instead")}function a9(e){var t;return(t=e)&&"object"==typeof t&&"message"in t&&"messages"in t?e:new aV(e)}let a7={};function se(e,t,n){var r;if((r=e)&&"object"==typeof r){if("value"in e)return"html"!==e.type||n?e.value:"";if(t&&"alt"in e&&e.alt)return e.alt;if("children"in e)return st(e.children,t,n)}
53return Array.isArray(e)?st(e,t,n):""}function st(e,t,n){let r=[],i=-1;for(;++i<e.length;)r[i]=se(e[i],t,n);return r.join("")}function sn(e,t,n,r){let i,o=e.length,a=0;if(t=t<0?-t>o?0:o+t:t>o?o:t,n=n>0?n:0,r.length<1e4)(i=Array.from(r)).unshift(t,n),e.splice(...i);else for(n&&e.splice(t,n);a<r.length;)(i=r.slice(a,a+1e4)).unshift(t,0),e.splice(...i),a+=1e4,t+=1e4}function sr(e,t){return e.length>0?(sn(e,e.length,0,t),e):t}let si={}.hasOwnProperty,so=sy(/[A-Za-z]/),sa=sy(/[\dA-Za-z]/),ss=sy(/[#-'*+\--9=?A-Z^-~]/);function sl(e){return null!==e&&(e<32||127===e)}let sc=sy(/\d/),su=sy(/[\dA-Fa-f]/),sd=sy(/[!-/:-@[-`{-~]/);function sp(e){return null!==e&&e<-2}function sf(e){return null!==e&&(e<0||32===e)}function sh(e){return -2===e||-1===e||32===e}let sg=sy(/[!-\/:-@\[-`\{-~\xA1\xA7\xAB\xB6\xB7\xBB\xBF\u037E\u0387\u055A-\u055F\u0589\u058A\u05BE\u05C0\u05C3\u05C6\u05F3\u05F4\u0609\u060A\u060C\u060D\u061B\u061D-\u061F\u066A-\u066D\u06D4\u0700-\u070D\u07F7-\u07F9\u0830-\u083E\u085E\u0964\u0965\u0970\u09FD\u0A76\u0AF0\u0C77\u0C84\u0DF4\u0E4F\u0E5A\u0E5B\u0F04-\u0F12\u0F14\u0F3A-\u0F3D\u0F85\u0FD0-\u0FD4\u0FD9\u0FDA\u104A-\u104F\u10FB\u1360-\u1368\u1400\u166E\u169B\u169C\u16EB-\u16ED\u1735\u1736\u17D4-\u17D6\u17D8-\u17DA\u1800-\u180A\u1944\u1945\u1A1E\u1A1F\u1AA0-\u1AA6\u1AA8-\u1AAD\u1B5A-\u1B60\u1B7D\u1B7E\u1BFC-\u1BFF\u1C3B-\u1C3F\u1C7E\u1C7F\u1CC0-\u1CC7\u1CD3\u2010-\u2027\u2030-\u2043\u2045-\u2051\u2053-\u205E\u207D\u207E\u208D\u208E\u2308-\u230B\u2329\u232A\u2768-\u2775\u27C5\u27C6\u27E6-\u27EF\u2983-\u2998\u29D8-\u29DB\u29FC\u29FD\u2CF9-\u2CFC\u2CFE\u2CFF\u2D70\u2E00-\u2E2E\u2E30-\u2E4F\u2E52-\u2E5D\u3001-\u3003\u3008-\u3011\u3014-\u301F\u3030\u303D\u30A0\u30FB\uA4FE\uA4FF\uA60D-\uA60F\uA673\uA67E\uA6F2-\uA6F7\uA874-\uA877\uA8CE\uA8CF\uA8F8-\uA8FA\uA8FC\uA92E\uA92F\uA95F\uA9C1-\uA9CD\uA9DE\uA9DF\uAA5C-\uAA5F\uAADE\uAADF\uAAF0\uAAF1\uABEB\uFD3E\uFD3F\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE61\uFE63\uFE68\uFE6A\uFE6B\uFF01-\uFF03\uFF05-\uFF0A\uFF0C-\uFF0F\uFF1A\uFF1B\uFF1F\uFF20\uFF3B-\uFF3D\uFF3F\uFF5B\uFF5D\uFF5F-\uFF65]/),sm=sy(/\s/);function sy(e){return function(t){return null!==t&&e.test(String.fromCharCode(t))}}function sk(e,t,n,r){let i=r?r-1:1/0,o=0;return function(r){return sh(r)?(e.enter(n),function r(a){return sh(a)&&o++<i?(e.consume(a),r):(e.exit(n),t(a))}(r)):t(r)}}let sv={tokenize:function(e){let t,n=e.attempt(this.parser.constructs.contentInitial,function(t){return null===t?void e.consume(t):(e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),sk(e,n,"linePrefix"))},function(n){return e.enter("paragraph"),function n(r){let i=e.enter("chunkText",{contentType:"text",previous:t});return t&&(t.next=i),t=i,function t(r){if(null===r){e.exit("chunkText"),e.exit("paragraph"),e.consume(r);return}return sp(r)?(e.consume(r),e.exit("chunkText"),n):(e.consume(r),t)}(r)}(n)});return n}},sb={tokenize:function(e){let t,n,r,i=this,o=[],a=0;return s;function s(t){if(a<o.length){let n=o[a];return i.containerState=n[1],e.attempt(n[0].continuation,l,c)(t)}return c(t)}function l(e){if(a++,i.containerState._closeFlow){let n;i.containerState._closeFlow=void 0,t&&y();let r=i.events.length,o=r;for(;o--;)if("exit"===i.events[o][0]&&"chunkFlow"===i.events[o][1].type){n=i.events[o][1].end;break}m(a);let s=r;for(;s<i.events.length;)i.events[s][1].end=Object.assign({},n),s++;return sn(i.events,o+1,0,i.events.slice(r)),i.events.length=s,c(e)}return s(e)}function c(n){if(a===o.length){if(!t)return p(n);if(t.currentConstruct&&t.currentConstruct.concrete)return h(n);i.interrupt=!!(t.currentConstruct&&!t._gfmTableDynamicInterruptHack)}return i.containerState={},e.check(sx,u,d)(n)}function u(e){return t&&y(),m(a),p(e)}function d(e){return i.parser.lazy[i.now().line]=a!==o.length,r=i.now().offset,h(e)}function p(t){return i.containerState={},e.attempt(sx,f,h)(t)}function f(e){return a++,o.push([i.currentConstruct,i.containerState]),p(e)}function h(r){if(null===r){t&&y(),m(0),e.consume(r);return}return t=t||i.parser.flow(i.now()),e.enter("chunkFlow",{contentType:"flow",previous:n,_tokenizer:t}),function t(n){if(null===n){g(e.exit("chunkFlow"),!0),m(0),e.consume(n);return}return sp(n)?(e.consume(n),g(e.exit("chunkFlow")),a=0,i.interrupt=void 0,s):(e.consume(n),t)}(r)}function g(e,o){let s=i.sliceStream(e);
53if(o&&s.push(null),e.previous=n,n&&(n.next=e),n=e,t.defineSkip(e.start),t.write(s),i.parser.lazy[e.start.line]){let e,n,o=t.events.length;for(;o--;)if(t.events[o][1].start.offset<r&&(!t.events[o][1].end||t.events[o][1].end.offset>r))return;let s=i.events.length,l=s;for(;l--;)if("exit"===i.events[l][0]&&"chunkFlow"===i.events[l][1].type){if(e){n=i.events[l][1].end;break}e=!0}for(m(a),o=s;o<i.events.length;)i.events[o][1].end=Object.assign({},n),o++;sn(i.events,l+1,0,i.events.slice(s)),i.events.length=o}}function m(t){let n=o.length;for(;n-- >t;){let t=o[n];i.containerState=t[1],t[0].exit.call(i,e)}o.length=t}function y(){t.write([null]),n=void 0,t=void 0,i.containerState._closeFlow=void 0}}},sx={tokenize:function(e,t,n){return sk(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}},sw={tokenize:function(e,t,n){return function(t){return sh(t)?sk(e,r,"linePrefix")(t):r(t)};function r(e){return null===e||sp(e)?t(e):n(e)}},partial:!0};function sE(e){let t,n,r,i,o,a,s,l={},c=-1;for(;++c<e.length;){for(;c in l;)c=l[c];if(t=e[c],c&&"chunkFlow"===t[1].type&&"listItemPrefix"===e[c-1][1].type&&((r=0)<(a=t[1]._tokenizer.events).length&&"lineEndingBlank"===a[r][1].type&&(r+=2),r<a.length&&"content"===a[r][1].type))for(;++r<a.length&&"content"!==a[r][1].type;)"chunkText"===a[r][1].type&&(a[r][1]._isInFirstContentOfListItem=!0,r++);if("enter"===t[0])t[1].contentType&&(Object.assign(l,function(e,t){let n,r,i=e[t][1],o=e[t][2],a=t-1,s=[],l=i._tokenizer||o.parser[i.contentType](i.start),c=l.events,u=[],d={},p=-1,f=i,h=0,g=0,m=[0];for(;f;){for(;e[++a][1]!==f;);s.push(a),!f._tokenizer&&(n=o.sliceStream(f),f.next||n.push(null),r&&l.defineSkip(f.start),f._isInFirstContentOfListItem&&(l._gfmTasklistFirstContentOfListItem=!0),l.write(n),f._isInFirstContentOfListItem&&(l._gfmTasklistFirstContentOfListItem=void 0)),r=f,f=f.next}for(f=i;++p<c.length;)"exit"===c[p][0]&&"enter"===c[p-1][0]&&c[p][1].type===c[p-1][1].type&&c[p][1].start.line!==c[p][1].end.line&&(g=p+1,m.push(g),f._tokenizer=void 0,f.previous=void 0,f=f.next);for(l.events=[],f?(f._tokenizer=void 0,f.previous=void 0):m.pop(),p=m.length;p--;){let t=c.slice(m[p],m[p+1]),n=s.pop();u.unshift([n,n+t.length-1]),sn(e,n,2,t)}for(p=-1;++p<u.length;)d[h+u[p][0]]=h+u[p][1],h+=u[p][1]-u[p][0]-1;return d}(e,c)),c=l[c],s=!0);else if(t[1]._container){for(r=c,n=void 0;r--;)if("lineEnding"===(i=e[r])[1].type||"lineEndingBlank"===i[1].type)"enter"===i[0]&&(n&&(e[n][1].type="lineEndingBlank"),i[1].type="lineEnding",n=r);else break;n&&(t[1].end=Object.assign({},e[n][1].start),(o=e.slice(n,c)).unshift(t),sn(e,n,c-n+1,o))}}return!s}let sS={tokenize:function(e,t){let n;return function(t){return e.enter("content"),n=e.enter("chunkContent",{contentType:"content"}),r(t)};function r(t){return null===t?i(t):sp(t)?e.check(sC,o,i)(t):(e.consume(t),r)}function i(n){return e.exit("chunkContent"),e.exit("content"),t(n)}function o(t){return e.consume(t),e.exit("chunkContent"),n.next=e.enter("chunkContent",{contentType:"content",previous:n}),n=n.next,r}},resolve:function(e){return sE(e),e}},sC={tokenize:function(e,t,n){let r=this;return function(t){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),sk(e,i,"linePrefix")};function i(i){if(null===i||sp(i))return n(i);let o=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes("codeIndented")&&o&&"linePrefix"===o[1].type&&o[2].sliceSerialize(o[1],!0).length>=4?t(i):e.interrupt(r.parser.constructs.flow,n,t)(i)}},partial:!0},sT={tokenize:function(e){let t=this,n=e.attempt(sw,function(r){return null===r?void e.consume(r):(e.enter("lineEndingBlank"),e.consume(r),e.exit("lineEndingBlank"),t.currentConstruct=void 0,n)},e.attempt(this.parser.constructs.flowInitial,r,sk(e,e.attempt(this.parser.constructs.flow,r,e.attempt(sS,r)),"linePrefix")));return n;function r(r){return null===r?void e.consume(r):(e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),t.currentConstruct=void 0,n)}}},sN={resolveAll:sR()},sA=sI("string"),s_=sI("text");function sI(e){return{tokenize:function(t){let n=this,r=this.parser.constructs[e],i=t.attempt(r,o,a);return o;function o(e){return l(e)?i(e):a(e)}function a(e){return null===e?void t.consume(e):(t.enter("data"),t.consume(e),s)}function s(e){return l(e)?(t.exit("data"),i(e)):(t.consume(e),s)}function l(e){if(null===e)return!0;let t=r[e],i=-1;if(t)for(;++i<t.length;){let e=t[i];if(!e.previous||e.previous.call(n,n.previous))return!0}return!1}},resolveAll:sR("text"===e?sM:void 0)}}function sR(e){return function(t,n){let r,i=-1;for(;++i<=t.length;)void 0===r?t[i]&&"data"===t[i][1].type&&(r=i,i++):t[i]&&"data"===t[i][1].type||(i!==r+2&&(t[r][1].end=t[i-1][1].end,t.splice(r+2,i-r-2),i=r+2),r=void 0);return e?e(t,n):t}}function sM(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||"lineEnding"===e[n][1].type)&&"data"===e[n-1][1].type){let r,i=e[n-1][1],o=t.sliceStream(i),a=o.length,s=-1,l=0;for(;a--;){let e=o[a];if("string"==typeof e){for(s=e.length;32===e.charCodeAt(s-1);)l++,s--;if(s)break;s=-1}else if(-2===e)r=!0,l++;else if(-1===e);else{a++;break}}if(l){let o={type:n===e.length||r||l<2?"lineSuffix":"hardBreakTrailing",start:{line:i.end.line,column:i.end.column-l,offset:i.end.offset-l,_index:i.start._index+a,_bufferIndex:a?s:i.start._bufferIndex+s},end:Object.assign({},i.end)};i.end=Object.assign({},o.start),i.start.offset===i.end.offset?Object.assign(i,o):(e.splice(n,0,["enter",o,t],["exit",o,t]),n+=2)}n++}return e}function sO(e,t,n){let r=[],i=-1;for(;++i<e.length;){let o=e[i].resolveAll;o&&!r.includes(o)&&(t=o(t,n),r.push(o))}return t}function sj(e){return null===e||sf(e)||sm(e)?1:sg(e)?2:void 0}let sz={name:"attention",tokenize:function(e,t){let n,r=this.parser.constructs.attentionMarkers.null,i=this.previous,o=sj(i);return function(a){return n=a,e.enter("attentionSequence"),function a(s){if(s===n)return e.consume(s),a;let l=e.exit("attentionSequence"),c=sj(s),u=!c||2===c&&o||r.includes(s),d=!o||2===o&&c||r.includes(i);return l._open=!!(42===n?u:u&&(o||!d)),l._close=!!(42===n?d:d&&(c||!u)),t(s)}(a)}},resolveAll:function(e,t){let n,r,i,o,a,s,l,c,u=-1;for(;++u<e.length;)if("enter"===e[u][0]&&"attentionSequence"===e[u][1].type&&e[u][1]._close){for(n=u;n--;)if("exit"===e[n][0]&&"attentionSequence"===e[n][1].type&&e[n][1]._open&&t.sliceSerialize(e[
vendor: 4,483 bytes, line 53
53n][1]).charCodeAt(0)===t.sliceSerialize(e[u][1]).charCodeAt(0)){if((e[n][1]._close||e[u][1]._open)&&(e[u][1].end.offset-e[u][1].start.offset)%3&&!((e[n][1].end.offset-e[n][1].start.offset+e[u][1].end.offset-e[u][1].start.offset)%3))continue;s=e[n][1].end.offset-e[n][1].start.offset>1&&e[u][1].end.offset-e[u][1].start.offset>1?2:1;let d=Object.assign({},e[n][1].end),p=Object.assign({},e[u][1].start);sD(d,-s),sD(p,s),o={type:s>1?"strongSequence":"emphasisSequence",start:d,end:Object.assign({},e[n][1].end)},a={type:s>1?"strongSequence":"emphasisSequence",start:Object.assign({},e[u][1].start),end:p},i={type:s>1?"strongText":"emphasisText",start:Object.assign({},e[n][1].end),end:Object.assign({},e[u][1].start)},r={type:s>1?"strong":"emphasis",start:Object.assign({},o.start),end:Object.assign({},a.end)},e[n][1].end=Object.assign({},o.start),e[u][1].start=Object.assign({},a.end),l=[],e[n][1].end.offset-e[n][1].start.offset&&(l=sr(l,[["enter",e[n][1],t],["exit",e[n][1],t]])),l=sr(l,[["enter",r,t],["enter",o,t],["exit",o,t],["enter",i,t]]),l=sr(l,sO(t.parser.constructs.insideSpan.null,e.slice(n+1,u),t)),l=sr(l,[["exit",i,t],["enter",a,t],["exit",a,t],["exit",r,t]]),e[u][1].end.offset-e[u][1].start.offset?(c=2,l=sr(l,[["enter",e[u][1],t],["exit",e[u][1],t]])):c=0,sn(e,n-1,u-n+3,l),u=n+l.length-c-2;break}}for(u=-1;++u<e.length;)"attentionSequence"===e[u][1].type&&(e[u][1].type="data");return e}};function sD(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}let sP={name:"blockQuote",tokenize:function(e,t,n){let r=this;return function(t){if(62===t){let n=r.containerState;return n.open||(e.enter("blockQuote",{_container:!0}),n.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(t),e.exit("blockQuoteMarker"),i}return n(t)};function i(n){return sh(n)?(e.enter("blockQuotePrefixWhitespace"),e.consume(n),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(n))}},continuation:{tokenize:function(e,t,n){let r=this;return function(t){return sh(t)?sk(e,i,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(t):i(t)};function i(r){return e.attempt(sP,t,n)(r)}}},exit:function(e){e.exit("blockQuote")}},sF={name:"characterEscape",tokenize:function(e,t,n){return function(t){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(t),e.exit("escapeMarker"),r};function r(r){return sd(r)?(e.enter("characterEscapeValue"),e.consume(r),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(r)}}};var sL=e.i(849087);let sU={name:"characterReference",tokenize:function(e,t,n){let r,i,o=this,a=0;return function(t){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(t),e.exit("characterReferenceMarker"),s};function s(t){return 35===t?(e.enter("characterReferenceMarkerNumeric"),e.consume(t),e.exit("characterReferenceMarkerNumeric"),l):(e.enter("characterReferenceValue"),r=31,i=sa,c(t))}function l(t){return 88===t||120===t?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(t),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),r=6,i=su,c):(e.enter("characterReferenceValue"),r=7,i=sc,c(t))}function c(s){if(59===s&&a){let r=e.exit("characterReferenceValue");return i!==sa||(0,sL.decodeNamedCharacterReference)(o.sliceSerialize(r))?(e.enter("characterReferenceMarker"),e.consume(s),e.exit("characterReferenceMarker"),e.exit("characterReference"),t):n(s)}return i(s)&&a++<r?(e.consume(s),c):n(s)}}},sB={tokenize:function(e,t,n){let r=this;return function(t){return null===t?n(t):(e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),i)};function i(e){return r.parser.lazy[r.now().line]?n(e):t(e)}},partial:!0},s$={name:"codeFenced",tokenize:function(e,t,n){let r,i=this,o={tokenize:function(e,t,n){let o=0;return function(t){return e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),a};function a(t){return e.enter("codeFencedFence"),sh(t)?sk(e,l,"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(t):l(t)}function l(t){return t===r?(e.enter("codeFencedFenceSequence"),function t(i){return i===r?(o++,e.consume(i),t):o>=s?(e.exit("codeFencedFenceSequence"),sh(i)?sk(e,c,"whitespace")(i):c(i)):n(i)}(t)):n(t)}function c(r){return null===r||sp(r)?(e.exit("codeFencedFence"),t(r)):n(r)}},partial:!0},a=0,s=0;return function(t){var o;let c;return o=t,a=(c=i.events[i.events.length-1])&&"linePrefix"===c[1].type?c[2].sliceSerialize(c[1],!0).length:0,r=o,e.enter("co
53deFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),function t(i){return i===r?(s++,e.consume(i),t):s<3?n(i):(e.exit("codeFencedFenceSequence"),sh(i)?sk(e,l,"whitespace")(i):l(i))}(o)};function l(o){return null===o||sp(o)?(e.exit("codeFencedFence"),i.interrupt?t(o):e.check(sB,u,h)(o)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),function t(i){return null===i||sp(i)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),l(i)):sh(i)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),sk(e,c,"whitespace")(i)):96===i&&i===r?n(i):(e.consume(i),t)}(o))}function c(t){return null===t||sp(t)?l(t):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),function t(i){return null===i||sp(i)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),l(i)):96===i&&i===r?n(i):(e.consume(i),t)}(t))}function u(t){return e.attempt(o,h,d)(t)}function d(t){return e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),p}function p(t){return a>0&&sh(t)?sk(e,f,"linePrefix",a+1)(t):f(t)}function f(t){return null===t||sp(t)?e.check(sB,u,h)(t):(e.enter("codeFlowValue"),function t(n){return null===n||sp(n)?(e.exit("codeFlowValue"),f(n)):(e.consume(n),t)}(t))}function h(n){return e.exit("codeFenced"),t(n)}},concrete:!0},sH={name:"codeIndented",tokenize:function(e,t,n){let r=this;return function(t){return e.enter("codeIndented"),sk(e,i,"linePrefix",5)(t)};function i(t){let i=r.events[r.events.length-1];return i&&"linePrefix"===i[1].type&&i[2].sliceSerialize(i[1],!0).length>=4?function t(n){return null===n?o(n):sp(n)?e.attempt(sK,t,o)(n):(e.enter("codeFlowValue"),function n(r){return null===r||sp(r)?(e.exit("codeFlowValue"),t(r)):(e.consume(r),n)}(n))}(t):n(t)}function o(n){return e.exit("codeIndented"),t(n)}}},sK={tokenize:function(e,t,n){let r=this;return i;function i(t){return r.parser.lazy[r.now().line]?n(t):sp(t)?(e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),i):sk(e,o,"linePrefix",5)(t)}function o(e){let o=r.events[r.events.length-1];return o&&"linePrefix"===o[1].type&&o[2].sliceSerialize(o[1],!0).length>=4?t(e):sp(e)?i(e):n(e)}},partial:!0};function sG(e,t,n,r,i,o,a,s,l){let c=l||1/0,u=0;return function(t){return 60===t?(e.enter(r),e.enter(i),e.enter(o),e.consume(t),e.exit(o),d):null===t||32===t||41===t||sl(t)?n(t):(e.enter(r),e.enter(a),e.enter(s),e.enter("chunkString",{contentType:"string"}),h(t))};function d(n){return 62===n?(e.enter(o),e.consume(n),e.exit(o),e.exit(i),e.exit(r),t):(e.enter(s),e.enter("chunkString",{contentType:"string"}),p(n))}function p(t){return 62===t?(e.exit("chunkString"),e.exit(s),d(t)):null===t||60===t||sp(t)?n(t):(e.consume(t),92===t?f:p)}function f(t){return 60===t||62===t||92===t?(e.consume(t),p):p(t)}function h(i){return!u&&(null===i||41===i||sf(i))?(e.exit("chunkString"),e.exit(s),e.exit(a),e.exit(r),t(i)):u<c&&40===i?(e.consume(i),u++,h):41===i?(e.consume(i),u--,h):null===i||32===i||40===i||sl(i)?n(i):(e.consume(i),92===i?g:h)}function g(t){return 40===t||41===t||92===t?(e.consume(t),h):h(t)}}function sV(e,t,n,r,i,o){let a,s=this,l=0;return function(t){return e.enter(r),e.enter(i),e.consume(t),e.exit(i),e.enter(o),c};function c(d){return l>999||null===d||91===d||93===d&&!a||94===d&&!l&&"_hiddenFootnoteSupport"in s.parser.constructs?n(d):93===d?(e.exit(o),e.enter(i),e.consume(d),e.exit(i),e.exit(r),t):sp(d)?(e.enter("lineEnding"),e.consume(d),e.exit("lineEnding"),c):(e.enter("chunkString",{contentType:"string"}),u(d))}function u(t){return null===t||91===t||93===t||sp(t)||l++>999?(e.exit("chunkString"),c(t)):(e.consume(t),a||(a=!sh(t)),92===t?d:u)}function d(t){return 91===t||92===t||93===t?(e.consume(t),l++,u):u(t)}}function sW(e,t,n,r,i,o){let a;return function(t){return 34===t||39===t||40===t?(e.enter(r),e.enter(i),e.consume(t),e.exit(i),a=40===t?41:t,s):n(t)};function s(n){return n===a?(e.enter(i),e.consume(n),e.exit(i),e.exit(r),t):(e.enter(o),l(n))}function l(t){return t===a?(e.exit(o),s(a)):null===t?n(t):sp(t)?(e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),sk(e,l,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),c(t))}function c(t){return t===a||null===t||sp(t)?(e.exit("chunkString"),l(t)):(e.consume(t),92===t?u:c)}function u(t){return t===a||92===t?(e.consume(t),c):c(t)}}function sq(e,t){let n;return function r(i){return sp(i)?(e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),n=!0,r):sh(i)?sk(e,r,n?"linePrefix":"lineSuffix")(i):t(i)}}function sJ(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}let sX={tokenize:function(e,t,n){return function(t){return sf(t)?sq(e,r)(t):n(t)};function r(t){return sW(e,i,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(t)}function i(t){return sh(t)?sk(e,o,"whitespace")(t):o(t)}function o(e){return null===e||sp(e)?t(e):n(e)}},partial:!0},sY=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],sQ=["pre","script","style","textarea"],sZ={tokenize:function(e,t,n){return function(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),e.attempt(sw,t,n)}},partial:!0},s0={tokenize:function(e,t,n){let r=this;return function(t){return sp(t)?(e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),i):n(t)};function i(e){return r.parser.lazy[r.now().line]?n(e):t(e)}},partial:!0},s1={name:"labelEnd",tokenize:function(e,t,n){let r,i,o=this,a=o.events.length;for(;a--;)if(("labelImage"===o.events[a][1].type||"labelLink"===o.events[a][1].type)&&!o.events[a][1]._balanced){r=o.events[a][1];break}return function(t){return r?r._inactive?u(t):(i=o.parser.defined.includes(sJ(o.sliceSerialize({start:r.end,end:o.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(t),e.exit("labelMarker"),e.exit("labelEnd"),s):n(t)};function s(t){return 40===t?e.attempt(s2,c,i?c:u)(t):91===t?e.attempt(s5,c,i?l:u)(t):i?c(t):u(t)}function l(t){return e.attempt(s4,c,u)(t)}function c(e){return t(e)}function u(e){return r._balanced=!0,n(e)}},resolveTo:function(e,t){let n,r,i,o,a=e.length,s=0;for(;a--;)if(n=e[a][1],r){if("link"===n.type||"labelLink"===n.type&&n._inactive)break;"enter"===e[a][0]&&"labelLink"===n.type&&(n._inactive=!0)}else if(i){if("enter"===e[a][0]&&("labelImage"===n.type||"labelLink"===n.type)&&!n._balanced&&(r=a,"labelLink"!==n.type)){s=2;break}}else"labelEnd"===n.type&&(i=a);let l={type:"labelLink"===e[r][1].type?"link":"image",start:Object.assign({},e[r][1].start),end:Object.assign({},e[e.length-1][1].end)},c={type:"label",start:Object.assign({},e[r][1].start),end:Object.assign({},e[i][1].end)},u={type:"labelText",start:Object.assign({},e[r+s+2][1].end),end:Object.assign({},e[i-2][1].start)};return o=sr(o=[["enter",l,t],["enter",c,t]],e.slice(r+1,r+s+3)),o=sr(o,[["enter",u,t]]),o=sr(o,sO(t.parser.constructs.insideSpan.null,e.slice(r+s+4,i-3),t)),o=sr(o,[["exit",u,t],e[i-2],e[i-1],["exit",c,t]]),o=sr(o,e.slice(i+1)),o=sr(o,[["exit",l,t]]),sn(e,r,e.length,o),e},resolveAll:function(e){let t=-1;for(;++t<e.length;){let n=e[t][1];("labelImage"===n.type||"labelLink"===n.type||"labelEnd"===n.type)&&(e.splice(t+1,"labelImage"===n.type?4:2),n.type="data",t++)}return e}},s2={tokenize:function(e,t,n){return function(t){return e.enter("resource"),e.enter("resourceMarker"),e.consume(t),e.exit("resourceMarker"),r};function r(t){return sf(t)?sq(e,i)(t):i(t)}function i(t){return 41===t?c(t):sG(e,o,a,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(t)}function o(t){return sf(t)?sq(e,s)(t):c(t)}function a(e){return n(e)}function s(t){return 34===t||39===t||40===t?sW(e,l,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(t):c(t)}function l(t){return sf(t)?sq(e,c)(t):c(t)}function c(r){return 41===r?(e.enter("resourceMarker"),e.consume(r),e.exit("resourceMarker"),e.exit("resource"),t):n(r)}}},s5={tokenize:function(e,t,n){let r=this;return function(t){return sV.call(r,e,i,o,"reference","referenceMarker","referenceString")(t)};function i(e){return r.parser.defined.includes(sJ(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(e):n(e)}function o(e){return n(e)}}},s4={tokenize:function(e,t,n){return function(t){return e.enter("reference"),e.enter("referenceMarker"),e.consume(t),e.exit("referenceMarker"),r};function r(r){return 93===r?(e.enter("referenceMarker"),e.consume(r),e.exit("referenceMarker"),e.exit("reference"),t):n(r)}}},s3={name:"labelStartImage",tokenize:function(e,t,n){let r=this;return function(t){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(t),e.exit("labelImageMarker"),i};function i(t){return 91===t?(e.enter("labelMarker"),e.consume(t),e.exit("labelMarker"),e.exit("labelImage"),o):n(t)}function o(e){return 94===e&&"_hiddenFootnoteSupport"in r.parser.constructs?n(e):t(e)}},resolveAll:s1.resolveAll},s6={name:"labelStartLink",tokenize:function(e,t,n){let r=this;return function(t){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(t),e.exit("labelMarker"),e.exit("labelLink"),i};function i(e){return 94===e&&"_hiddenFootnoteSupport"in r.parser.constructs?n(e):t(e)}},resolveAll:s1.resolveAll},s8={name:"lineEnding",tokenize:function(e,t){return function(n){return e.enter("lineEnding"),e.consume(n),e.exit("lineEnding"),sk(e,t,"linePrefix")}}},s9={name:"thematicBreak",tokenize:function(e,t,n){let r,i=0;return function(o){var a;return e.enter("thematicBreak"),r=a=o,function o(a){return a===r?(e.enter("thematicBreakSequence"),function t(n){return n===r?(e.consume(n),i++,t):(e.exit("thematicBreakSequence"),sh(n)?sk(e,o,"whitespace")(n):o(n))}
vendor: 1,043 bytes, line 53
53(a)):i>=3&&(null===a||sp(a))?(e.exit("thematicBreak"),t(a)):n(a)}(a)}}},s7={name:"list",tokenize:function(e,t,n){let r=this,i=r.events[r.events.length-1],o=i&&"linePrefix"===i[1].type?i[2].sliceSerialize(i[1],!0).length:0,a=0;return function(t){let i=r.containerState.type||(42===t||43===t||45===t?"listUnordered":"listOrdered");if("listUnordered"===i?!r.containerState.marker||t===r.containerState.marker:sc(t)){if(r.containerState.type||(r.containerState.type=i,e.enter(i,{_container:!0})),"listUnordered"===i)return e.enter("listItemPrefix"),42===t||45===t?e.check(s9,n,s)(t):s(t);if(!r.interrupt||49===t)return e.enter("listItemPrefix"),e.enter("listItemValue"),function t(i){return sc(i)&&++a<10?(e.consume(i),t):(!r.interrupt||a<2)&&(r.containerState.marker?i===r.containerState.marker:41===i||46===i)?(e.exit("listItemValue"),s(i)):n(i)}(t)}return n(t)};function s(t){return e.enter("listItemMarker"),e.consume(t),e.exit("listItemMarker"),r.containerState.marker=r.containerState.marker||t,e.check(sw,r.interrupt?n:l,e.attempt(le,u,c))}
53function l(e){return r.containerState.initialBlankLine=!0,o++,u(e)}function c(t){return sh(t)?(e.enter("listItemPrefixWhitespace"),e.consume(t),e.exit("listItemPrefixWhitespace"),u):n(t)}function u(n){return r.containerState.size=o+r.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(n)}},continuation:{tokenize:function(e,t,n){let r=this;return r.containerState._closeFlow=void 0,e.check(sw,function(n){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,sk(e,t,"listItemIndent",r.containerState.size+1)(n)},function(n){return r.containerState.furtherBlankLines||!sh(n)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,i(n)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(lt,t,i)(n))});function i(i){return r.containerState._closeFlow=!0,r.interrupt=void 0,sk(e,e.attempt(s7,t,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(i)}}},exit:function(e){e.exit(this.containerState.type)}},le={tokenize:function(e,t,n){let r=this;return sk(e,function(e){let i=r.events[r.events.length-1];return!sh(e)&&i&&"listItemPrefixWhitespace"===i[1].type?t(e):n(e)},"listItemPrefixWhitespace",r.parser.constructs.disable.null.includes("codeIndented")?void 0:5)},partial:!0},lt={tokenize:function(e,t,n){let r=this;return sk(e,function(e){let i=r.events[r.events.length-1];return i&&"listItemIndent"===i[1].type&&i[2].sliceSerialize(i[1],!0).length===r.containerState.size?t(e):n(e)},"listItemIndent",r.containerState.size+1)},partial:!0},ln={name:"setextUnderline",tokenize:function(e,t,n){let r,i=this;return function(t){var a;let s,l=i.events.length;for(;l--;)if("lineEnding"!==i.events[l][1].type&&"linePrefix"!==i.events[l][1].type&&"content"!==i.events[l][1].type){s="paragraph"===i.events[l][1].type;break}return!i.parser.lazy[i.now().line]&&(i.interrupt||s)?(e.enter("setextHeadingLine"),r=t,a=t,e.enter("setextHeadingLineSequence"),function t(n){return n===r?(e.consume(n),t):(e.exit("setextHeadingLineSequence"),sh(n)?sk(e,o,"lineSuffix")(n):o(n))}(a)):n(t)};function o(r){return null===r||sp(r)?(e.exit("setextHeadingLine"),t(r)):n(r)}},resolveTo:function(e,t){let n,r,i,o=e.length;for(;o--;)if("enter"===e[o][0]){if("content"===e[o][1].type){n=o;break}"paragraph"===e[o][1].type&&(r=o)}else"content"===e[o][1].type&&e.splice(o,1),i||"definition"!==e[o][1].type||(i=o);let a={type:"setextHeading",start:Object.assign({},e[r][1].start),end:Object.assign({},e[e.length-1][1].end)};return e[r][1].type="setextHeadingText",i?(e.splice(r,0,["enter",a,t]),e.splice(i+1,0,["exit",e[n][1],t]),e[n][1].end=Object.assign({},e[i][1].end)):e[n][1]=a,e.push(["exit",a,t]),e}};e.s(["attentionMarkers",0,{null:[42,95]},"contentInitial",0,{91:{name:"definition",tokenize:function(e,t,n){let r,i=this;return function(t){var r;return e.enter("definition"),r=t,sV.call(i,e,o,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(r)};function o(t){return(r=sJ(i.sliceSerialize(i.events[i.events.length-1][1]).slice(1,-1)),58===t)?(e.enter("definitionMarker"),e.consume(t),e.exit("definitionMarker"),a):n(t)}function a(t){return sf(t)?sq(e,s)(t):s(t)}function s(t){return sG(e,l,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(t)}function l(t){return e.attempt(sX,c,c)(t)}function c(t){return sh(t)?sk(e,u,"whitespace")(t):u(t)}function u(o){return null===o||sp(o)?(e.exit("definition"),i.parser.defined.push(r),t(o)):n(o)}}}},"disable",0,{null:[]},"document",0,{42:s7,43:s7,45:s7,48:s7,49:s7,50:s7,51:s7,52:s7,53:s7,54:s7,55:s7,56:s7,57:s7,62:sP},"flow",0,{35:{name:"headingAtx",tokenize:function(e,t,n){let r=0;return function(i){var o;return e.enter("atxHeading"),o=i,e.enter("atxHeadingSequence"),function i(o){return 35===o&&r++<6?(e.consume(o),i):null===o||sf(o)?(e.exit("atxHeadingSequence"),function n(r){return 35===r?(e.enter("atxHeadingSequence"),function t(r){return 35===r?(e.consume(r),t):(e.exit("atxHeadingSequence"),n(r))}(r)):null===r||sp(r)?(e.exit("atxHeading"),t(r)):sh(r)?sk(e,n,"whitespace")(r):(e.enter("atxHeadingText"),function t(r){return null===r||35===r||sf(r)?(e.exit("atxHeadingText"),n(r)):(e.consume(r),t)}(r))}(o)):n(o)}(o)}},resolve:function(e,t){let n,r,i=e.length-2,o=3;return"whitespace"===e[3][1].type&&(o+=2),i-2>o&&"whitespace"===e[i][1].type&&(i-=2),"atxHeadingSequence"===e[i][1].type&&(o===i-1||i-4>o&&"whitespace"===e[i-2][1].type)&&(i-=o+1===i?2:4),i>o&&(n={type:"atxHeadingText",start:e[o][1].start,end:e[i][1].end},r={type:"chunkText",start:e[o][1].start,end:e[i][1].end,contentType:"text"},sn(e,o,i-o+1,[["enter",n,t],["enter",r,t],["exit",r,t],["exit",n,t]])),e}},42:s9,45:[ln,s9],60:{name:"htmlFlow",tokenize:function(e,t,n){let r,i,o,a,s,l=this;return function(t){var n;return n=t,e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(n),c};function c(a){return 33===a?(e.consume(a),u):47===a?(e.consume(a),i=!0,f):63===a?(e.consume(a),r=3,l.interrupt?t:M):so(a)?(e.consume(a),o=String.fromCharCode(a),h):n(a)}function u(i){return 45===i?(e.consume(i),r=2,d):91===i?(e.consume(i),r=5,a=0,p):so(i)?(e.consume(i),r=4,l.interrupt?t:M):n(i)}function d(r){return 45===r?(e.consume(r),l.interrupt?t:M):n(r)}function p(r){let i="CDATA[";return r===i.charCodeAt(a++)?(e.consume(r),a===i.length)?l.interrupt?t:S:p:n(r)}function f(t){return so(t)?(e.consume(t),o=String.fromCharCode(t),h):n(t)}
53function h(a){if(null===a||47===a||62===a||sf(a)){let s=47===a,c=o.toLowerCase();return!s&&!i&&sQ.includes(c)?(r=1,l.interrupt?t(a):S(a)):sY.includes(o.toLowerCase())?(r=6,s)?(e.consume(a),g):l.interrupt?t(a):S(a):(r=7,l.interrupt&&!l.parser.lazy[l.now().line]?n(a):i?function t(n){return sh(n)?(e.consume(n),t):w(n)}(a):m(a))}return 45===a||sa(a)?(e.consume(a),o+=String.fromCharCode(a),h):n(a)}function g(r){return 62===r?(e.consume(r),l.interrupt?t:S):n(r)}function m(t){return 47===t?(e.consume(t),w):58===t||95===t||so(t)?(e.consume(t),y):sh(t)?(e.consume(t),m):w(t)}function y(t){return 45===t||46===t||58===t||95===t||sa(t)?(e.consume(t),y):k(t)}function k(t){return 61===t?(e.consume(t),v):sh(t)?(e.consume(t),k):m(t)}function v(t){return null===t||60===t||61===t||62===t||96===t?n(t):34===t||39===t?(e.consume(t),s=t,b):sh(t)?(e.consume(t),v):function t(n){return null===n||34===n||39===n||47===n||60===n||61===n||62===n||96===n||sf(n)?k(n):(e.consume(n),t)}(t)}function b(t){return t===s?(e.consume(t),s=null,x):null===t||sp(t)?n(t):(e.consume(t),b)}function x(e){return 47===e||62===e||sh(e)?m(e):n(e)}function w(t){return 62===t?(e.consume(t),E):n(t)}function E(t){return null===t||sp(t)?S(t):sh(t)?(e.consume(t),E):n(t)}function S(t){return 45===t&&2===r?(e.consume(t),A):60===t&&1===r?(e.consume(t),_):62===t&&4===r?(e.consume(t),O):63===t&&3===r?(e.consume(t),M):93===t&&5===r?(e.consume(t),R):sp(t)&&(6===r||7===r)?(e.exit("htmlFlowData"),e.check(sZ,j,C)(t)):null===t||sp(t)?(e.exit("htmlFlowData"),C(t)):(e.consume(t),S)}function C(t){return e.check(s0,T,j)(t)}function T(t){return e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),N}function N(t){return null===t||sp(t)?C(t):(e.enter("htmlFlowData"),S(t))}function A(t){return 45===t?(e.consume(t),M):S(t)}function _(t){return 47===t?(e.consume(t),o="",I):S(t)}function I(t){if(62===t){let n=o.toLowerCase();return sQ.includes(n)?(e.consume(t),O):S(t)}return so(t)&&o.length<8?(e.consume(t),o+=String.fromCharCode(t),I):S(t)}function R(t){return 93===t?(e.consume(t),M):S(t)}function M(t){return 62===t?(e.consume(t),O):45===t&&2===r?(e.consume(t),M):S(t)}function O(t){return null===t||sp(t)?(e.exit("htmlFlowData"),j(t)):(e.consume(t),O)}function j(n){return e.exit("htmlFlow"),t(n)}},resolveTo:function(e){let t=e.length;for(;t--&&("enter"!==e[t][0]||"htmlFlow"!==e[t][1].type););return t>1&&"linePrefix"===e[t-2][1].type&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e},concrete:!0},61:ln,95:s9,96:s$,126:s$},"flowInitial",0,{[-2]:sH,[-1]:sH,32:sH},"insideSpan",0,{null:[sz,sN]},"string",0,{38:sU,92:sF},"text",0,{[-5]:s8,[-4]:s8,[-3]:s8,33:s3,38:sU,42:sz,60:[{name:"autolink",tokenize:function(e,t,n){let r=0;return function(t){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(t),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),i};function i(t){return so(t)?(e.consume(t),o):s(t)}function o(t){return 43===t||45===t||46===t||sa(t)?(r=1,function t(n){return 58===n?(e.consume(n),r=0,a):(43===n||45===n||46===n||sa(n))&&r++<32?(e.consume(n),t):(r=0,s(n))}(t)):s(t)}function a(r){return 62===r?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(r),e.exit("autolinkMarker"),e.exit("autolink"),t):null===r||32===r||60===r||sl(r)?n(r):(e.consume(r),a)}function s(t){return 64===t?(e.consume(t),l):ss(t)?(e.consume(t),s):n(t)}function l(i){return sa(i)?function i(o){return 46===o?(e.consume(o),r=0,l):62===o?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(o),e.exit("autolinkMarker"),e.exit("autolink"),t):function t(o){if((45===o||sa(o))&&r++<63){let n=45===o?t:i;return e.consume(o),n}return n(o)}(o)}(i):n(i)}}},{name:"htmlText",tokenize:function(e,t,n){let r,i,o,a=this;return function(t){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(t),s};function s(t){return 33===t?(e.consume(t),l):47===t?(e.consume(t),b):63===t?(e.consume(t),k):so(t)?(e.consume(t),w):n(t)}function l(t){return 45===t?(e.consume(t),c):91===t?(e.consume(t),i=0,f):so(t)?(e.consume(t),y):n(t)}function c(t){return 45===t?(e.consume(t),p):n(t)}function u(t){return null===t?n(t):45===t?(e.consume(t),d):sp(t)?(o=u,I(t)):(e.consume(t),u)}function d(t){return 45===t?(e.consume(t),p):u(t)}function p(e){return 62===e?_(e):45===e?d(e):u(e)}function f(t){let r="CDATA[";return t===r.charCodeAt(i++)?(e.consume(t),i===r.length?h:f):n(t)}function h(t){return null===t?n(t):93===t?(e.consume(t),g):sp(t)?(o=h,I(t)):(e.consume(t),h)}function g(t){return 93===t?(e.consume(t),m):h(t)}function m(t){return 62===t?_(t):93===t?(e.consume(t),m):h(t)}function y(t){return null===t||62===t?_(t):sp(t)?(o=y,I(t)):(e.consume(t),y)}function k(t){return null===t?n(t):63===t?(e.consume(t),v):sp(t)?(o=k,I(t)):(e.consume(t),k)}function v(e){return 62===e?_(e):k(e)}function b(t){return so(t)?(e.consume(t),x):n(t)}function x(t){return 45===t||sa(t)?(e.consume(t),x):function t(n){return sp(n)?(o=t,I(n)):sh(n)?(e.consume(n),t):_(n)}(t)}function w(t){return 45===t||sa(t)?(e.consume(t),w):47===t||62===t||sf(t)?E(t):n(t)}function E(t){return 47===t?(e.consume(t),_):58===t||95===t||so(t)?(e.consume(t),S):sp(t)?(o=E,I(t)):sh(t)?(e.consume(t),E):_(t)}function S(t){return 45===t||46===t||58===t||95===t||sa(t)?(e.consume(t),S):function t(n){return 61===n?(e.consume(n),C):sp(n)?(o=t,I(n)):sh(n)?(e.consume(n),t):E(n)}(t)}function C(t){return null===t||60===t||61===t||62===t||96===t?n(t):34===t||39===t?(e.consume(t),r=t,T):sp(t)?(o=C,I(t)):sh(t)?(e.consume(t),C):(e.consume(t),N)}function T(t){return t===r?(e.consume(t),r=void 0,A):null===t?n(t):sp(t)?(o=T,I(t)):(e.consume(t),T)}function N(t){return null===t||34===t||39===t||60===t||61===t||96===t?n(t):47===t||62===t||sf(t)?E(t):(e.consume(t),N)}function A(e){return 47===e||62===e||sf(e)?E(e):n(e)}function _(r){return 62===r?(e.consume(r),e.exit("htmlTextData"),e.exit("htmlText"),t):n(r)}function I(t){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),R}function R(t){return sh(t)?sk(e,M,"linePrefix",a.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(t):M(t)}function M(t){return e.enter("htmlTextData"),o(t)}}}],91:s6,92:[{name:"hardBreakEscape",tokenize:function(e,t,n){return function(t){return e.enter("hardBreakEscape"),e.consume(t),r};function r(r){return sp(r)?(e.exit("hardBreakEscape"),t(r)):n(r)}}},sF],93:s1,95:sz,96:{name:"codeText",tokenize:function(e,t,n){let r,i,o=0;
53return function(t){return e.enter("codeText"),e.enter("codeTextSequence"),function t(n){return 96===n?(e.consume(n),o++,t):(e.exit("codeTextSequence"),a(n))}(t)};function a(l){return null===l?n(l):32===l?(e.enter("space"),e.consume(l),e.exit("space"),a):96===l?(i=e.enter("codeTextSequence"),r=0,function n(a){return 96===a?(e.consume(a),r++,n):r===o?(e.exit("codeTextSequence"),e.exit("codeText"),t(a)):(i.type="codeTextData",s(a))}(l)):sp(l)?(e.enter("lineEnding"),e.consume(l),e.exit("lineEnding"),a):(e.enter("codeTextData"),s(l))}function s(t){return null===t||32===t||96===t||sp(t)?(e.exit("codeTextData"),a(t)):(e.consume(t),s)}},resolve:function(e){let t,n,r=e.length-4,i=3;if(("lineEnding"===e[3][1].type||"space"===e[i][1].type)&&("lineEnding"===e[r][1].type||"space"===e[r][1].type)){for(t=i;++t<r;)if("codeTextData"===e[t][1].type){e[i][1].type="codeTextPadding",e[r][1].type="codeTextPadding",i+=2,r-=2;break}}for(t=i-1,r++;++t<=r;)void 0===n?t!==r&&"lineEnding"!==e[t][1].type&&(n=t):(t===r||"lineEnding"===e[t][1].type)&&(e[n][1].type="codeTextData",t!==n+2&&(e[n][1].end=e[t-1][1].end,e.splice(n+2,t-n-2),r-=t-n-2,t=n+2),n=void 0);return e},previous:function(e){return 96!==e||"characterEscape"===this.events[this.events.length-1][1].type}}}],894443);var lr=e.i(894443);let li=/[\0\t\n\r]/g;function lo(e,t){let n=Number.parseInt(e,t);return n<9||11===n||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(65535&n)==65535||(65535&n)==65534||n>1114111?"�":String.fromCharCode(n)}let la=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function ls(e,t,n){if(t)return t;if(35===n.charCodeAt(0)){let e=n.charCodeAt(1),t=120===e||88===e;return lo(n.slice(t?2:1),t?16:10)}return(0,sL.decodeNamedCharacterReference)(n)||e}let ll={}.hasOwnProperty,lc=function(e,t,n){let r,i,o,a;return"string"!=typeof t&&(n=t,t=void 0),(function(e){let t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:o(v),autolinkProtocol:d,autolinkEmail:d,atxHeading:o(m),blockQuote:o(function(){return{type:"blockquote",children:[]}}),characterEscape:d,characterReference:d,codeFenced:o(g),codeFencedFenceInfo:a,codeFencedFenceMeta:a,codeIndented:o(g,a),codeText:o(function(){return{type:"inlineCode",value:""}},a),codeTextData:d,data:d,codeFlowValue:d,definition:o(function(){return{type:"definition",identifier:"",label:null,title:null,url:""}}),definitionDestinationString:a,definitionLabelString:a,definitionTitleString:a,emphasis:o(function(){return{type:"emphasis",children:[]}}),hardBreakEscape:o(y),hardBreakTrailing:o(y),htmlFlow:o(k,a),htmlFlowData:d,htmlText:o(k,a),htmlTextData:d,image:o(function(){return{type:"image",title:null,url:"",alt:null}}),label:a,link:o(v),listItem:o(function(e){return{type:"listItem",spread:e._spread,checked:null,children:[]}}),listItemValue:function(e){n.expectingFirstListItemValue&&(this.stack[this.stack.length-2].start=Number.parseInt(this.sliceSerialize(e),10),n.expectingFirstListItemValue=void 0)},listOrdered:o(b,function(){n.expectingFirstListItemValue=!0}),listUnordered:o(b),paragraph:o(function(){return{type:"paragraph",children:[]}}),reference:function(){n.referenceType="collapsed"},referenceString:a,resourceDestinationString:a,resourceTitleString:a,setextHeading:o(m),strong:o(function(){return{type:"strong",children:[]}}),thematicBreak:o(function(){return{type:"thematicBreak"}})},exit:{atxHeading:l(),atxHeadingSequence:function(e){let t=this.stack[this.stack.length-1];t.depth||(t.depth=this.sliceSerialize(e).length)},autolink:l(),autolinkEmail:function(e){p.call(this,e),this.stack[this.stack.length-1].url="mailto:"+this.sliceSerialize(e)},autolinkProtocol:function(e){p.call(this,e),this.stack[this.stack.length-1].url=this.sliceSerialize(e)},blockQuote:l(),characterEscapeValue:p,characterReferenceMarkerHexadecimal:h,characterReferenceMarkerNumeric:h,characterReferenceValue:function(e){let t,r=this.sliceSerialize(e),i=n.characterReferenceType;i?(t=lo(r,"characterReferenceMarkerNumeric"===i?10:16),n.characterReferenceType=void 0):t=(0,sL.decodeNamedCharacterReference)(r);let o=this.stack.pop();o.value+=t,o.position.end=lu(e.end)},codeFenced:l(function(){let e=this.resume();this.stack[this.stack.length-1].value=e.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),n.flowCodeInside=void 0}),codeFencedFence:function(){!n.flowCodeInside&&(this.buffer(),n.flowCodeInside=!0)},codeFencedFenceInfo:function(){let e=this.resume();this.stack[this.stack.length-1].lang=e},codeFencedFenceMeta:function(){let e=this.resume();this.stack[this.stack.length-1].meta=e},codeFlowValue:p,codeIndented:l(function(){let e=this.resume();this.stack[this.stack.length-1].value=e.replace(/(\r?\n|\r)$/g,"")}),codeText:l(function(){let e=this.resume();this.stack[this.stack.length-1].value=e}),codeTextData:p,data:p,definition:l(),definitionDestinationString:function(){let e=this.resume();this.stack[this.stack.length-1].url=e},definitionLabelString:function(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=sJ(this.sliceSerialize(e)).toLowerCase()},definitionTitleString:function(){let e=this.resume();this.stack[this.stack.length-1].title=e},emphasis:l(),hardBreakEscape:l(f),hardBreakTrailing:l(f),htmlFlow:l(function(){let e=this.resume();this.stack[this.stack.length-1].value=e}),htmlFlowData:p,htmlText:l(function(){let e=this.resume();this.stack[this.stack.length-1].value=e}),htmlTextData:p,image:l(function(){let e=this.stack[this.stack.length-1];if(n.inReference){let t=n.referenceType||"shortcut";e.type+="Reference",e.referenceType=t,delete e.url,delete e.title}else delete e.identifier,delete e.label;n.referenceType=void 0}),label:function(){let e=this.stack[this.stack.length-1],t=this.resume(),r=this.stack[this.stack.length-1];n.inReference=!0,"link"===r.type?r.children=e.children:r.alt=t},labelText:function(e){let t=this.sliceSerialize(e),n=this.stack[this.stack.length-2];n.label=t.replace(la,ls),n.identifier=sJ(t).toLowerCase()},lineEnding:function(e){let r=this.stack[this.stack.length-1];if(n.atHardBreak){r.children[r.children.length-1].position.end=lu(e.end),n.atHardBreak=void 0;return}!n.setextHeadingSlurpLineEnding&&t.canContainEols.includes(r.type)&&(d.call(this,e),p.call(this,e))},link:l(function(){let e=this.stack[this.stack.length-1];if(n.inReference){let t=n.referenceType||"shortcut";e.type+="Reference",e.referenceType=t,delete e.url,delete e.title}else delete e.identifier,delete e.label;n.referenceType=void 0}),listItem:l(),listOrdered:l(),listUnordered:l(),paragraph:l(),referenceString:function(e){let t=this.resume(),r=this.stack[this.stack.length-1];r.label=t,r.identifier=sJ(this.sliceSerialize(e)).toLowerCase(),n.referenceType="full"},resourceDestinationString:function(){let e=this.resume();this.stack[this.stack.length-1].url=e},resourceTitleString:function(){let e=this.resume();this.stack[this.stack.length-1].title=e},resource:function(){n.inReference=void 0},setextHeading:l(function(){n.setextHeadingSlurpLineEnding=void 0}),setextHeadingLineSequence:function(e){this.stack[this.stack.length-1].depth=61===this.sliceSerialize(e).charCodeAt(0)?1:2},setextHeadingText:function(){n.setextHeadingSlurpLineEnding=!0},strong:l(),thematicBreak:l()}};!function e(t,n){let r=-1;for(;++r<n.length;){let i=n[r];Array.isArray(i)?e(t,i):function(e,t){let n;for(n in t)if(ll.call(t,n)){if("canContainEols"===n){let r=t[n];r&&e[n].push(...r)}else if("transforms"===n){let r=t[n];r&&e[n].push(...r)}else if("enter"===n||"exit"===n){let r=t[n];r&&Object.assign(e[n],r)}}}(t,i)}}(t,(e||{}).mdastExtensions||[]);let n={};return function(e){let n={type:"root",children:[]},o={stack:[n],tokenStack:[],config:t,enter:s,exit:c,buffer:a,resume:u,setData:r,getData:i},l=[],d=-1;for(;++d<e.length;)("listOrdered"===e[d][1].type||"listUnordered"===e[d][1].type)&&("enter"===e[d][0]?l.push(d):d=function(e,t,n){let r,i,o,a,s=t-1,l=-1,c=!1;for(;++s<=n;){let t=e[s];if("listUnordered"===t[1].type||"listOrdered"===t[1].type||"blockQuote"===t[1].type?("enter"===t[0]?l++:l--,a=void 0):"lineEndingBlank"===t[1].type?"enter"
53===t[0]&&(!r||a||l||o||(o=s),a=void 0):"linePrefix"===t[1].type||"listItemValue"===t[1].type||"listItemMarker"===t[1].type||"listItemPrefix"===t[1].type||"listItemPrefixWhitespace"===t[1].type||(a=void 0),!l&&"enter"===t[0]&&"listItemPrefix"===t[1].type||-1===l&&"exit"===t[0]&&("listUnordered"===t[1].type||"listOrdered"===t[1].type)){if(r){let a=s;for(i=void 0;a--;){let t=e[a];if("lineEnding"===t[1].type||"lineEndingBlank"===t[1].type){if("exit"===t[0])continue;i&&(e[i][1].type="lineEndingBlank",c=!0),t[1].type="lineEnding",i=a}else if("linePrefix"===t[1].type||"blockQuotePrefix"===t[1].type||"blockQuotePrefixWhitespace"===t[1].type||"blockQuoteMarker"===t[1].type||"listItemIndent"===t[1].type);else break}o&&(!i||o<i)&&(r._spread=!0),r.end=Object.assign({},i?e[i][1].start:t[1].end),e.splice(i||s,0,["exit",r,t[2]]),s++,n++}"listItemPrefix"===t[1].type&&(r={type:"listItem",_spread:!1,start:Object.assign({},t[1].start),end:void 0},e.splice(s,0,["enter",r,t[2]]),s++,n++,o=void 0,a=!0)}}return e[t][1]._spread=c,n}(e,l.pop(),d));for(d=-1;++d<e.length;){let n=t[e[d][0]];ll.call(n,e[d][1].type)&&n[e[d][1].type].call(Object.assign({sliceSerialize:e[d][2].sliceSerialize},o),e[d][1])}if(o.tokenStack.length>0){let e=o.tokenStack[o.tokenStack.length-1];(e[1]||ld).call(o,void 0,e[0])}for(n.position={start:lu(e.length>0?e[0][1].start:{line:1,column:1,offset:0}),end:lu(e.length>0?e[e.length-2][1].end:{line:1,column:1,offset:0})},d=-1;++d<t.transforms.length;)n=t.transforms[d](n)||n;return n};function r(e,t){n[e]=t}function i(e){return n[e]}function o(e,t){return function(n){s.call(this,e(n),n),t&&t.call(this,n)}}function a(){this.stack.push({type:"fragment",children:[]})}function s(e,t,n){return this.stack[this.stack.length-1].children.push(e),this.stack.push(e),this.tokenStack.push([t,n]),e.position={start:lu(t.start)},e}function l(e){return function(t){e&&e.call(this,t),c.call(this,t)}}function c(e,t){let n=this.stack.pop(),r=this.tokenStack.pop();if(r)r[0].type!==e.type&&(t?t.call(this,e,r[0]):(r[1]||ld).call(this,e,r[0]));else throw Error("Cannot close `"+e.type+"` ("+aj({start:e.start,end:e.end})+"): itâs not open");return n.position.end=lu(e.end),n}function u(){var e;return e=this.stack.pop(),se(e,"boolean"!=typeof a7.includeImageAlt||a7.includeImageAlt,"boolean"!=typeof a7.includeHtml||a7.includeHtml)}function d(e){let t=this.stack[this.stack.length-1],n=t.children[t.children.length-1];n&&"text"===n.type||((n={type:"text",value:""}).position={start:lu(e.start)},t.children.push(n)),this.stack.push(n)}function p(e){let t=this.stack.pop();t.value+=this.sliceSerialize(e),t.position.end=lu(e.end)}function f(){n.atHardBreak=!0}function h(e){n.characterReferenceType=e.type}function g(){return{type:"code",lang:null,meta:null,value:""}}function m(){return{type:"heading",depth:void 0,children:[]}}function y(){return{type:"break"}}function k(){return{type:"html",value:""}}function v(){return{type:"link",title:null,url:"",children:[]}}function b(e){return{type:"list",ordered:"listOrdered"===e.type,start:null,spread:e._spread,children:[]}}})(n)(function(e){for(;!sE(e););return e}((function(e){let t={defined:[],lazy:{},constructs:function(e){let t={},n=-1;for(;++n<e.length;)!function(e,t){let n;for(n in t){let r,i=(si.call(e,n)?e[n]:void 0)||(e[n]={}),o=t[n];if(o)for(r in o){si.call(i,r)||(i[r]=[]);let e=o[r];!function(e,t){let n=-1,r=[];for(;++n<t.length;)("after"===t[n].add?e:r).push(t[n]);sn(e,0,0,r)}(i[r],Array.isArray(e)?e:e?[e]:[])}}}(t,e[n]);return t}([lr,...(e||{}).extensions||[]]),content:n(sv),document:n(sb),flow:n(sT),string:n(sA),text:n(s_)};return t;function n(e){return function(n){return function(e,t,n){let r=Object.assign(n?Object.assign({},n):{line:1,column:1,offset:0},{_index:0,_bufferIndex:-1}),i={},o=[],a=[],s=[],l={consume:function(e){sp(e)?(r.line++,r.column=1,r.offset+=-3===e?2:1,m()):-1!==e&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===a[r._index].length&&(r._bufferIndex=-1,r._index++)),c.previous=e},enter:function(e,t){let n=t||{};return n.type=e,n.start=p(),c.events.push(["enter",n,c]),s.push(n),n},exit:function(e){let t=s.pop();return t.end=p(),c.events.push(["exit",t,c]),t},attempt:h(function(e,t){g(e,t.from)}),check:h(f),interrupt:h(f,{interrupt:!0})},c={previous:null,code:null,containerState:{},events:[],parser:e,sliceStream:d,sliceSerialize:function(e,t){return function(e,t){let n,r=-1,i=[];for(;++r<e.length;){let o,a=e[r];if("string"==typeof a)o=a;else switch(a){case -5:o="\r";break;case -4:o="\n";break;case -3:o="\r\n";break;case -2:o=t?" ":" ";break;case -1:if(!t&&n)continue;o=" ";break;default:o=String.fromCharCode(a)}n=-2===a,i.push(o)}return i.join("")}(d(e),t)}
53,now:p,defineSkip:function(e){i[e.line]=e.column,m()},write:function(e){return(a=sr(a,e),function(){let e;for(;r._index<a.length;){let n=a[r._index];if("string"==typeof n)for(e=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===e&&r._bufferIndex<n.length;){var t;t=n.charCodeAt(r._bufferIndex),u=u(t)}else u=u(n)}}(),null!==a[a.length-1])?[]:(g(t,0),c.events=sO(o,c.events,c),c.events)}},u=t.tokenize.call(c,l);return t.resolveAll&&o.push(t),c;function d(e){return function(e,t){let n,r=t.start._index,i=t.start._bufferIndex,o=t.end._index,a=t.end._bufferIndex;if(r===o)n=[e[r].slice(i,a)];else{if(n=e.slice(r,o),i>-1){let e=n[0];"string"==typeof e?n[0]=e.slice(i):n.shift()}a>0&&n.push(e[o].slice(0,a))}return n}(a,e)}function p(){let{line:e,column:t,offset:n,_index:i,_bufferIndex:o}=r;return{line:e,column:t,offset:n,_index:i,_bufferIndex:o}}function f(e,t){t.restore()}function h(e,t){return function(n,i,o){var a;let u,d,f,h;return Array.isArray(n)?g(n):"tokenize"in n?g([n]):(a=n,function(e){let t=null!==e&&a[e],n=null!==e&&a.null;return g([...Array.isArray(t)?t:t?[t]:[],...Array.isArray(n)?n:n?[n]:[]])(e)});function g(e){return(u=e,d=0,0===e.length)?o:y(e[d])}function y(e){return function(n){let i,o,a,u,d;return(i=p(),o=c.previous,a=c.currentConstruct,u=c.events.length,d=Array.from(s),h={restore:function(){r=i,c.previous=o,c.currentConstruct=a,c.events.length=u,s=d,m()},from:u},f=e,e.partial||(c.currentConstruct=e),e.name&&c.parser.constructs.disable.null.includes(e.name))?v(n):e.tokenize.call(t?Object.assign(Object.create(c),t):c,l,k,v)(n)}}function k(t){return e(f,h),i}function v(e){return(h.restore(),++d<u.length)?y(u[d]):o}}}function g(e,t){e.resolveAll&&!o.includes(e)&&o.push(e),e.resolve&&sn(c.events,t,c.events.length-t,e.resolve(c.events.slice(t),c)),e.resolveTo&&(c.events=e.resolveTo(c.events,c))}function m(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}(t,e,n)}}})(n).document().write((i=1,o="",a=!0,function(e,t,n){let s,l,c,u,d,p=[];for(e=o+e.toString(t),c=0,o="",a&&(65279===e.charCodeAt(0)&&c++,a=void 0);c<e.length;){if(li.lastIndex=c,u=(s=li.exec(e))&&void 0!==s.index?s.index:e.length,d=e.charCodeAt(u),!s){o=e.slice(c);break}if(10===d&&c===u&&r)p.push(-3),r=void 0;else switch(r&&(p.push(-5),r=void 0),c<u&&(p.push(e.slice(c,u)),i+=u-c),d){case 0:p.push(65533),i++;break;case 9:for(l=4*Math.ceil(i/4),p.push(-2);i++<l;)p.push(-1);break;case 10:p.push(-4),i=1;break;default:r=!0,i=1}c=u+1}return n&&(r&&p.push(-5),o&&p.push(o),p.push(null)),p})(e,t,!0))))};function lu(e){return{line:e.line,column:e.column,offset:e.offset}}function ld(e,t){if(e)throw Error("Cannot close `"+e.type+"` ("+aj({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+aj({start:t.start,end:t.end})+") is open");throw Error("Cannot close document, a token (`"+t.type+"`, "+aj({start:t.start,end:t.end})+") is still open")}function lp(e){Object.assign(this,{Parser:t=>lc(t,Object.assign({},this.data("settings"),e,{extensions:this.data("micromarkExtensions")||[],mdastExtensions:this.data("fromMarkdownExtensions")||[]}))})}function lf(e){let t=[],n=-1,r=0,i=0;for(;++n<e.length;){let o=e.charCodeAt(n),a="";if(37===o&&sa(e.charCodeAt(n+1))&&sa(e.charCodeAt(n+2)))i=2;else if(o<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(o))||(a=String.fromCharCode(o));else if(o>55295&&o<57344){let t=e.charCodeAt(n+1);o<56320&&t>56319&&t<57344?(a=String.fromCharCode(o,t),i=1):a="�"}else a=String.fromCharCode(o);a&&(t.push(e.slice(r,n),encodeURIComponent(a)),r=n+i+1,a=""),i&&(n+=i,i=0)}return t.join("")+e.slice(r)}let lh=function(e){var t,n;if(null==e)return lm;if("string"==typeof e){return t=e,lg(function(e){return e&&e.type===t})}if("object"==typeof e){return Array.isArray(e)?function(e){let t=[],n=-1;for(;++n<e.length;)t[n]=lh(e[n]);return lg(function(...e){let n=-1;for(;++n<t.length;)if(t[n].call(this,...e))return!0;return!1})}(e):(n=e,lg(function(e){let t;for(t in n)if(e[t]!==n[t])return!1;return!0}))}if("function"==typeof e)return lg(e);throw Error("Expected function, string, or object as test")};function lg(e){return function(t,...n){return!!(t&&"object"==typeof t&&"type"in t&&e.call(this,t,...n))}}function lm(){return!0}let ly=function(e,t,n,r){"function"==typeof t&&"function"!=typeof n&&(r=n,n=t,t=null);let i=lh(t),o=r?-1:1;(function e(a,s,l){let c=a&&"object"==typeof a?a:{};if("string"==typeof c.type){let e="string"==typeof c.tagName?c.tagName:"string"==typeof c.name?c.name:void 0;Object.defineProperty(u,"name",{value:"node ("+a.type+(e?"<"+e+">":"")+")"})}return u;function u(){var c;let u,d,p,f=[];if((!t||i(a,s,l[l.length-1]||null))&&!1===(f=Array.isArray(c=n(a,l))?c:"number"==typeof c?[!0,c]:[c])[0])return f;if(a.children&&"skip"!==f[0])for(d=(r?a.children.length:-1)+o,p=l.concat(a);d>-1&&d<a.children.length;){if(!1===(u=e(a.children[d],d,p)())[0])return u;d="number"==typeof u[1]?u[1]:d+o}return f}})(e,void 0,[])()},lk=function(e,t,n,r){"function"==typeof t&&"function"!=typeof n&&(r=n,n=t,t=null),ly(e,t,function(e,t){let r=t[t.length-1];return n(e,r?r.children.indexOf(e):null,r)},r)},lv=lx("start"),lb=lx("end");function lx(e){return function(t){let n=t&&t.position&&t.position[e]||{};return{line:n.line||null,column:n.column||null,offset:n.offset>-1?n.offset:null}}}let lw=function(e){var t,n;if(null==e)return lS;if("string"==typeof e){return t=e,lE(function(e){return e&&e.type===t})}if("object"==typeof e){return Array.isArray(e)?function(e){let t=[],n=-1;for(;++n<e.length;)t[n]=lw(e[n]);return lE(function(...e){let n=-1;for(;++n<t.length;)if(t[n].call(this,...e))return!0;return!1})}(e):(n=e,lE(function(e){let t;for(t in n)if(e[t]!==n[t])return!1;return!0}))}if("function"==typeof e)return lE(e);throw Error("Expected function, string, or object as test")};function lE(e){return function(t,...n){return!!(t&&"object"==typeof t&&"type"in t&&e.call(this,t,...n))}}function lS(){return!0}let lC=function(e,t,n,r){"function"==typeof t&&"function"!=typeof n&&(r=n,n=t,t=null);let i=lw(t),o=r?-1:1;(function e(a,s,l){let c=a&&"object"==typeof a?a:{};if("string"==typeof c.type){let e="string"==typeof c.tagName?c.tagName:"string"==typeof c.name?c.name:void 0;Object.defineProperty(u,"name",{value:"node ("+a.type+(e?"<"+e+">":"")+")"})}return u;function u(){var c;let u,d,p,f=[];if((!t||i(a,s,l[l.length-1]||null))&&!1===(f=Array.isArray(c=n(a,l))?c:"number"==typeof c?[!0,c]:[c])[0])return f;if(a.children&&"skip"!==f[0])for(d=(r?a.children.length:-1)+o,p=l.concat(a);d>-1&&d<a.children.length;){if(!1===(u=e(a.children[d],d,p)())[0])return u;d="number"==typeof u[1]?u[1]:d+o}return f}})(e,void 0,[])()},lT=function(e,t,n,r){"function"==typeof t&&"function"!=typeof n&&(r=n,n=t,t=null),lC(e,t,function(e,t){let r=t[t.length-1];return n(e,r?r.children.indexOf(e):null,r)},r)},lN={}.hasOwnProperty;function lA(e){return String(e||"").toUpperCase()}function l_(e,t){let n,r=String(t.identifier).toUpperCase(),i=lf(r.toLowerCase()),o=e.footnoteOrder.indexOf(r);-1===o?(e.footnoteOrder.push(r),e.footnoteCounts[r]=1,n=e.footnoteOrder.length):(e.footnoteCounts[r]++,n=o+1);let a=e.footnoteCounts[r],s={type:"element",tagName:"a",properties:{href:"#"+e.clobberPrefix+"fn-"+i,id:e.clobberPrefix+"fnref-"+i+(a>1?"-"+a:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(n)}]};e.patch(t,s);let l={type:"element",tagName:"sup",properties:{},children:[s]};return e.patch(t,l),e.applyData(t,l)}function lI(e,t){let n=t.referenceType,r="]";if("collapsed"===n?r+="[]":"full"===n&&(r+="["+(t.label||t.identifier)+"]"),"imageReference"===t.type)return{type:"text",value:"!["+t.alt+r};let i=e.all(t),o=i[0];o&&"text"===o.type?o.value="["+o.value:i.unshift({type:"text",value:"["});let a=i[i.length-1];return a&&"text"===a.type?a.value+=r:i.push({type:"text",value:r}),i}function lR(e){let t=e.spread;return null==t?e.children.length>1:t}var lM=e.i(876543);let lO={blockquote:function(e,t){let n={type:"element",tagName:"blockquote",properties:{},children:e.wrap(e.all(t),!0)};return e.patch(t,n),e.applyData(t,n)},break:function(e,t){let n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:"\n"}]},code:function(e,t){let n=t.value?t.value+"\n":"",r=t.lang?t.lang.match(/^[^ \t]+(?=[ \t]|$)/):null,i={};r&&(i.className=["language-"+r]);let o={type:"element",tagName:"code",properties:i,children:[{type:"text",value:n}]};return t.meta&&(o.data={meta:t.meta}),e.patch(t,o),o={type:"element",tagName:"pre",properties:{},children:[o=e.applyData(t,o)]},e.patch(t,o),o},delete:function(e,t){let n={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)},emphasis:function(e,t){let n={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)},footnoteReference:l_,footnote:function(e,t){let n=e.footnoteById,r=1;for(;r in n;)r++;let i=String(r);return n[i]={type:"footnoteDefinition",identifier:i,children:[{type:"paragraph",children:t.children}],position:t.position},l_(e,{type:"footnoteReference",identifier:i,position:t.position})},heading:function(e,t){let n={type:"element",tagName:"h"+t.depth,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)},html:function(e,t){if(e.dangerous){let n={type:"raw",value:t.value};return e.patch(t,n),e.applyData(t,n)}return null},imageReference:function(e,t){let n=e.definition(t.identifier);if(!n)return lI(e,t);let r={src:lf(n.url||""),alt:t.alt};null!==n.title&&void 0!==n.title&&(r.title=n.title);let i={type:"element",tagName:"img",properties:r,children:[]};return e.patch(t,i),e.applyData(t,i)},image:function(e,t){let n={src:lf(t.url)};null!==t.alt&&void 0!==t.alt&&(n.alt=t.alt),null!==t.title&&void 0!==t.title&&(n.title=t.title);let r={type:"element",tagName:"img",properties:n,children:[]};return e.patch(t,r),e.applyData(t,r)},inlineCode:function(e,t){let n={type:"text",value:t.value.replace(/\r?\n|\r/g," ")};e.patch(t,n);let r={type:"element",tagName:"code",properties:{},children:[n]};return e.patch(t,r),e.applyData(t,r)},linkReference:function(e,t){let n=e.definition(t.identifier);if(!n)return lI(e,t);let r={href:lf(n.url||"")};null!==n.title&&void 0!==n.title&&(r.title=n.title);let i={type:"element",tagName:"a",properties:r,children:e.all(t)};return e.patch(t,i),e.applyData(t,i)},link:function(e,t){let n={href:lf(t.url)};null!==t.title&&void 0!==t.title&&(n.title=t.title);let r={type:"element",tagName:"a",properties:n,children:e.all(t)};return e.patch(t,r),e.applyData(t,r)},listItem:function(e,t,n){let r=e.all(t),i=n?function(e){let t=!1;if("list"===e.type){t=e.spread||!1;let n=e.children,r=-1;for(;!t&&++r<n.length;)t=lR(n[r])}return t}(n):lR(t),o={},a=[];if("boolean"==typeof t.checked){let e,n=r[0];n&&"element"===n.type&&"p"===n.tagName?e=n:(e={type:"element",tagName:"p",properties:{},children:[]},r.unshift(e)),e.children.length>0&&e.children.unshift({type:"text",value:" "}),e.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:t.checked,disabled:!0},children:[]}),o.className=["task-list-item"]}let s=-1;for(;++s<r.length;){let e=r[s];(i||0!==s||"element"!==e.type||"p"!==e.tagName)&&a.push({type:"text",value:"\n"}),"element"!==e.type||"p"!==e.tagName||i?a.push(e):a.push(...e.children)}let l=r[r.length-1];l&&(i||"element"!==l.type||"p"!==l.tagName)&&a.push({type:"text",value:"\n"});let c={type:"element",tagName:"li",properties:o,children:a};return e.patch(t,c),e.applyData(t,c)},list:function(e,t){let n={},r=e.all(t),i=-1;for("number"==typeof t.start&&1!==t.start&&(n.start=t.start);++i<r.length;){let e=r[i];if("element"===e.type&&"li"===e.tagName&&e.properties&&Array.isArray(e.properties.className)&&e.properties.className.includes("task-list-item")){n.className=["contains-task-list"];break}}let o={type:"element",tagName:t.ordered?"ol":"ul",properties:n,children:e.wrap(r,!0)};return e.patch(t,o),e.applyData(t,o)},paragraph:function(e,t){let n={type:"element",tagName:"p",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)},root:function(e,t){let n={type:"root",children:e.wrap(e.all(t))};return e.patch(t,n),e.applyData(t,n)},strong:function(e,t){let n={type:"element",tagName:"strong",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)},table:function(e,t){let n=e.all(t),r=n.shift(),i=[];if(r){let n={type:"element",tagName:"thead",properties:{},children:e.wrap([r],!0)};e.patch(t.children[0],n),i.push(n)}if(n.length>0){let r={type:"element",tagName:"tbody",properties:{},children:e.wrap(n,!0)}
53,o=lv(t.children[1]),a=lb(t.children[t.children.length-1]);o.line&&a.line&&(r.position={start:o,end:a}),i.push(r)}let o={type:"element",tagName:"table",properties:{},children:e.wrap(i,!0)};return e.patch(t,o),e.applyData(t,o)},tableCell:function(e,t){let n={type:"element",tagName:"td",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)},tableRow:function(e,t,n){let r=n?n.children:void 0,i=0===(r?r.indexOf(t):1)?"th":"td",o=n&&"table"===n.type?n.align:void 0,a=o?o.length:t.children.length,s=-1,l=[];for(;++s<a;){let n=t.children[s],r={},a=o?o[s]:void 0;a&&(r.align=a);let c={type:"element",tagName:i,properties:r,children:[]};n&&(c.children=e.all(n),e.patch(n,c),c=e.applyData(t,c)),l.push(c)}let c={type:"element",tagName:"tr",properties:{},children:e.wrap(l,!0)};return e.patch(t,c),e.applyData(t,c)},text:function(e,t){let n={type:"text",value:(0,lM.trimLines)(String(t.value))};return e.patch(t,n),e.applyData(t,n)},thematicBreak:function(e,t){let n={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)},toml:lj,yaml:lj,definition:lj,footnoteDefinition:lj};function lj(){return null}let lz={}.hasOwnProperty;function lD(e,t){e.position&&(t.position={start:lv(e),end:lb(e)})}function lP(e,t){let n=t;if(e&&e.data){let t=e.data.hName,r=e.data.hChildren,i=e.data.hProperties;"string"==typeof t&&("element"===n.type?n.tagName=t:n={type:"element",tagName:t,properties:{},children:[]}),"element"===n.type&&i&&(n.properties={...n.properties,...i}),"children"in n&&n.children&&null!=r&&(n.children=r)}return n}function lF(e,t,n){var r,i;let o,a,s=t&&t.type;if(!s)throw Error("Expected node, got `"+t+"`");return lz.call(e.handlers,s)?e.handlers[s](e,t,n):e.passThrough&&e.passThrough.includes(s)?"children"in t?{...t,children:lL(e,t)}:t:e.unknownHandler?e.unknownHandler(e,t,n):(r=e,o=(i=t).data||{},a="value"in i&&!(lz.call(o,"hProperties")||lz.call(o,"hChildren"))?{type:"text",value:i.value}:{type:"element",tagName:"div",properties:{},children:lL(r,i)},r.patch(i,a),r.applyData(i,a))}function lL(e,t){let n=[];if("children"in t){let r=t.children,i=-1;for(;++i<r.length;){let o=lF(e,r[i],t);if(o){if(i&&"break"===r[i-1].type&&(Array.isArray(o)||"text"!==o.type||(o.value=o.value.replace(/^\s+/,"")),!Array.isArray(o)&&"element"===o.type)){let e=o.children[0];e&&"text"===e.type&&(e.value=e.value.replace(/^\s+/,""))}Array.isArray(o)?n.push(...o):n.push(o)}}}return n}function lU(e,t){let n=[],r=-1;for(t&&n.push({type:"text",value:"\n"});++r<e.length;)r&&n.push({type:"text",value:"\n"}),n.push(e[r]);return t&&e.length>0&&n.push({type:"text",value:"\n"}),n}function lB(e,t){let n=function(e,t){let n=t||{},r=n.allowDangerousHtml||!1,i={};return a.dangerous=r,a.clobberPrefix=void 0===n.clobberPrefix||null===n.clobberPrefix?"user-content-":n.clobberPrefix,a.footnoteLabel=n.footnoteLabel||"Footnotes",a.footnoteLabelTagName=n.footnoteLabelTagName||"h2",a.footnoteLabelProperties=n.footnoteLabelProperties||{className:["sr-only"]},a.footnoteBackLabel=n.footnoteBackLabel||"Back to content",a.unknownHandler=n.unknownHandler,a.passThrough=n.passThrough,a.handlers={...lO,...n.handlers},a.definition=function(e){let t=Object.create(null);if(!e||!e.type)throw Error("mdast-util-definitions expected node");return lT(e,"definition",e=>{let n=lA(e.identifier);n&&!lN.call(t,n)&&(t[n]=e)}),function(e){let n=lA(e);return n&&lN.call(t,n)?t[n]:null}}(e),a.footnoteById=i,a.footnoteOrder=[],a.footnoteCounts={},a.patch=lD,a.applyData=lP,a.one=function(e,t){return lF(a,e,t)},a.all=function(e){return lL(a,e)},a.wrap=lU,a.augment=o,lk(e,"footnoteDefinition",e=>{let t=String(e.identifier).toUpperCase();lz.call(i,t)||(i[t]=e)}),a;function o(e,t){if(e&&"data"in e&&e.data){let n=e.data;n.hName&&("element"!==t.type&&(t={type:"element",tagName:"",properties:{},children:[]}),t.tagName=n.hName),"element"===t.type&&n.hProperties&&(t.properties={...t.properties,...n.hProperties}),"children"in t&&t.children&&n.hChildren&&(t.children=n.hChildren)}if(e){let n="type"in e?e:{position:e};n&&n.position&&n.position.start&&n.position.start.line&&n.position.start.column&&n.position.end&&n.position.end.line&&n.position.end.column&&(t.position={start:lv(n),end:lb(n)})}return t}function a(e,t,n,r){return Array.isArray(n)&&(r=n,n={}),o(e,{type:"element",tagName:t,properties:n||{},children:r||[]})}}(e,t),r=n.one(e,null),i=function(e){let t=[],n=-1;for(;++n<e.footnoteOrder.length;){let r=e.footnoteById[e.footnoteOrder[n]];if(!r)continue;let i=e.all(r),o=String(r.identifier).toUpperCase(),a=lf(o.toLowerCase()),s=0,l=[];for(;++s<=e.footnoteCounts[o];){let t={type:"element",tagName:"a",properties:{href:"#"+e.clobberPrefix+"fnref-"+a+(s>1?"-"+s:""),dataFootnoteBackref:!0,className:["data-footnote-backref"],ariaLabel:e.footnoteBackLabel},children:[{type:"text",value:"â©"}]};s>1&&t.children.push({type:"element",tagName:"sup",children:[{type:"text",value:String(s)}]}),l.length>0&&l.push({type:"text",value:" "}),l.push(t)}let c=i[i.length-1];
53if(c&&"element"===c.type&&"p"===c.tagName){let e=c.children[c.children.length-1];e&&"text"===e.type?e.value+=" ":c.children.push({type:"text",value:" "}),c.children.push(...l)}else i.push(...l);let u={type:"element",tagName:"li",properties:{id:e.clobberPrefix+"fn-"+a},children:e.wrap(i,!0)};e.patch(r,u),t.push(u)}if(0!==t.length)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:e.footnoteLabelTagName,properties:{...JSON.parse(JSON.stringify(e.footnoteLabelProperties)),id:"footnote-label"},children:[{type:"text",value:e.footnoteLabel}]},{type:"text",value:"\n"},{type:"element",tagName:"ol",properties:{},children:e.wrap(t,!0)},{type:"text",value:"\n"}]}}(n);return i&&r.children.push({type:"text",value:"\n"},i),Array.isArray(r)?{type:"root",children:r}:r}let l$=function(e,t){var n,r,i;return e&&"run"in e?(n=e,r=t,(e,t,i)=>{n.run(lB(e,r),t,e=>{i(e)})}):(i=e||t,e=>lB(e,i))};var lH=e.i(745009);class lK{constructor(e,t,n){this.property=e,this.normal=t,n&&(this.space=n)}}function lG(e,t){let n={},r={},i=-1;for(;++i<e.length;)Object.assign(n,e[i].property),Object.assign(r,e[i].normal);return new lK(n,r,t)}function lV(e){return e.toLowerCase()}lK.prototype.property={},lK.prototype.normal={},lK.prototype.space=null;class lW{constructor(e,t){this.property=e,this.attribute=t}}lW.prototype.space=null,lW.prototype.boolean=!1,lW.prototype.booleanish=!1,lW.prototype.overloadedBoolean=!1,lW.prototype.number=!1,lW.prototype.commaSeparated=!1,lW.prototype.spaceSeparated=!1,lW.prototype.commaOrSpaceSeparated=!1,lW.prototype.mustUseProperty=!1,lW.prototype.defined=!1;let lq=0,lJ=l2(),lX=l2(),lY=l2(),lQ=l2(),lZ=l2(),l0=l2(),l1=l2();function l2(){return 2**++lq}e.s(["boolean",0,lJ,"booleanish",0,lX,"commaOrSpaceSeparated",0,l1,"commaSeparated",0,l0,"number",0,lQ,"overloadedBoolean",0,lY,"spaceSeparated",0,lZ],354135);var l5=e.i(354135);let l4=Object.keys(l5);class l3 extends lW{constructor(e,t,n,r){let i=-1;if(super(e,t),function(e,t,n){n&&(e[t]=n)}(this,"space",r),"number"==typeof n)for(;++i<l4.length;){const e=l4[i];!function(e,t,n){n&&(e[t]=n)}(this,l4[i],(n&l5[e])===l5[e])}}}l3.prototype.defined=!0;let l6={}.hasOwnProperty;function l8(e){let t,n={},r={};for(t in e.properties)if(l6.call(e.properties,t)){let i=e.properties[t],o=new l3(t,e.transform(e.attributes||{},t),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(t)&&(o.mustUseProperty=!0),n[t]=o,r[lV(t)]=t,r[lV(o.attribute)]=t}return new lK(n,r,e.space)}let l9=l8({space:"xlink",transform:(e,t)=>"xlink:"+t.slice(5).toLowerCase(),properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null}}),l7=l8({space:"xml",transform:(e,t)=>"xml:"+t.slice(3).toLowerCase(),properties:{xmlLang:null,xmlBase:null,xmlSpace:null}});function ce(e,t){return t in e?e[t]:t}function ct(e,t){return ce(e,t.toLowerCase())}let cn=l8({space:"xmlns",attributes:{xmlnsxlink:"xmlns:xlink"},transform:ct,properties:{xmlns:null,xmlnsXLink:null}}),cr=l8({transform:(e,t)=>"role"===t?t:"aria-"+t.slice(4).toLowerCase(),properties:{ariaActiveDescendant:null,ariaAtomic:lX,ariaAutoComplete:null,ariaBusy:lX,ariaChecked:lX,ariaColCount:lQ,ariaColIndex:lQ,ariaColSpan:lQ,ariaControls:lZ,ariaCurrent:null,ariaDescribedBy:lZ,ariaDetails:null,ariaDisabled:lX,ariaDropEffect:lZ,ariaErrorMessage:null,ariaExpanded:lX,ariaFlowTo:lZ,ariaGrabbed:lX,ariaHasPopup:null,ariaHidden:lX,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:lZ,ariaLevel:lQ,ariaLive:null,ariaModal:lX,ariaMultiLine:lX,ariaMultiSelectable:lX,ariaOrientation:null,ariaOwns:lZ,ariaPlaceholder:null,ariaPosInSet:lQ,ariaPressed:lX,ariaReadOnly:lX,ariaRelevant:null,ariaRequired:lX,ariaRoleDescription:lZ,ariaRowCount:lQ,ariaRowIndex:lQ,ariaRowSpan:lQ,ariaSelected:lX,ariaSetSize:lQ,ariaSort:null,ariaValueMax:lQ,ariaValueMin:lQ,ariaValueNow:lQ,ariaValueText:null,role:null}}),ci=l8({space:"html",attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},transform:ct,mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:l0,acceptCharset:lZ,accessKey:lZ,action:null,allow:null,allowFullScreen:lJ,allowPaymentRequest:lJ,allowUserMedia:lJ,alt:null,as:null,async:lJ,autoCapitalize:null,autoComplete:lZ,autoFocus:lJ,autoPlay:lJ,blocking:lZ,capture:null,charSet:null,checked:lJ,cite:null,className:lZ,cols:lQ,colSpan:null,content:null,contentEditable:lX,controls:lJ,controlsList:lZ,coords:lQ|l0,crossOrigin:null,data:null,dateTime:null,decoding:null,default:lJ,defer:lJ,dir:null,dirName:null,disabled:lJ,download:lY,draggable:lX,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:lJ,formTarget:null,headers:lZ,height:lQ,hidden:lJ,high:lQ,href:null,hrefLang:null,htmlFor:lZ,httpEquiv:lZ,id:null,imageSizes:null,imageSrcSet:null,inert:lJ,inputMode:null,integrity:null,is:null,isMap:lJ,itemId:null,itemProp:lZ,itemRef:lZ,itemScope:lJ,itemType:lZ,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:lJ,low:lQ,manifest:null,max:null,maxLength:lQ,media:null,method:null,min:null,minLength:lQ,multiple:lJ,muted:lJ,name:null,nonce:null,noModule:lJ,noValidate:lJ,onAbort:null,onAfterPrint:null,onAuxCl
53ick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:lJ,optimum:lQ,pattern:null,ping:lZ,placeholder:null,playsInline:lJ,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:lJ,referrerPolicy:null,rel:lZ,required:lJ,reversed:lJ,rows:lQ,rowSpan:lQ,sandbox:lZ,scope:null,scoped:lJ,seamless:lJ,selected:lJ,shadowRootClonable:lJ,shadowRootDelegatesFocus:lJ,shadowRootMode:null,shape:null,size:lQ,sizes:null,slot:null,span:lQ,spellCheck:lX,src:null,srcDoc:null,srcLang:null,srcSet:null,start:lQ,step:null,style:null,tabIndex:lQ,target:null,title:null,translate:null,type:null,typeMustMatch:lJ,useMap:null,value:lX,width:lQ,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:lZ,axis:null,background:null,bgColor:null,border:lQ,borderColor:null,bottomMargin:lQ,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:lJ,declare:lJ,event:null,face:null,frame:null,frameBorder:null,hSpace:lQ,leftMargin:lQ,link:null,longDesc:null,lowSrc:null,marginHeight:lQ,marginWidth:lQ,noResize:lJ,noHref:lJ,noShade:lJ,noWrap:lJ,object:null,profile:null,prompt:null,rev:null,rightMargin:lQ,rules:null,scheme:null,scrolling:lX,standby:null,summary:null,text:null,topMargin:lQ,valueType:null,version:null,vAlign:null,vLink:null,vSpace:lQ,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:lJ,disableRemotePlayback:lJ,prefix:null,property:null,results:lQ,security:null,unselectable:null}}),co=l8({space:"svg",attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav
53-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},transform:ce,properties:{about:l1,accentHeight:lQ,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:lQ,amplitude:lQ,arabicForm:null,ascent:lQ,attributeName:null,attributeType:null,azimuth:lQ,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:lQ,by:null,calcMode:null,capHeight:lQ,className:lZ,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:lQ,diffuseConstant:lQ,direction:null,display:null,dur:null,divisor:lQ,dominantBaseline:null,download:lJ,dx:null,dy:null,edgeMode:null,editable:null,elevation:lQ,enableBackgroun
53d:null,end:null,event:null,exponent:lQ,externalResourcesRequired:null,fill:null,fillOpacity:lQ,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:l0,g2:l0,glyphName:l0,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:lQ,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:lQ,horizOriginX:lQ,horizOriginY:lQ,id:null,ideographic:lQ,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:lQ,k:lQ,k1:lQ,k2:lQ,k3:lQ,k4:lQ,kernelMatrix:l1,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:lQ,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:lQ,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:lQ,overlineThickness:lQ,paintOrder:null,panose1:null,path:null,pathLength:lQ,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:lZ,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:lQ,pointsAtY:lQ,pointsAtZ:lQ,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:l1,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:l1,rev:l1,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:l1,requiredFeatures:l1,requiredFonts:l1,requiredFormats:l1,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:lQ,specularExponent:lQ,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:lQ,strikethroughThickness:lQ,string:null,stroke:null,strokeDashArray:l1,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:lQ,strokeOpacity:lQ,strokeWidth:null,style:null,surfaceScale:lQ,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:l1,tabIndex:lQ,tableValues:null,target:null,targetX:lQ,targetY:lQ,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:l1,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:lQ,underlineThickness:lQ,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:lQ,values:null,vAlphabetic:lQ,vMathematical:lQ,vectorEffect:null,vHanging:lQ,vIdeographic:lQ,version:null,vertAdvY:lQ,vertOriginX:lQ,vertOriginY:lQ,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:lQ,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null}}),ca=lG([l7,l9,cn,cr,ci],"html"),cs=lG([l7,l9,cn,cr,co],"svg");function cl(e){if(e.allowedElements&&e.disallowedElements)throw TypeError("Only one of `allowedElements` and `disallowedElements` should be defined");if(e.allowedElements||e.disallowedElements||e.allowElement)return t=>{lk(t,"element",(t,n,r)=>{let i;if(e.allowedElements?i=!e.allowedElements.includes(t.tagName):e.disallowedElements&&(i=e.disallowedElements.includes(t.tagName)),!i&&e.allowElement&&"number"==typeof n&&(i=!e.allowElement(t,n,r)),i&&"number"==typeof n)return e.unwrapDisallowed&&t.children?r.children.splice(n,1,...t.children):r.children.splice(n,1),n})}}var cc=e.i(338445);let cu=/^data[-\w.:]+$/i,cd=/-[a-z]/g,cp=/[A-Z]/g;function cf(e){return"-"+e.toLowerCase()}function ch(e){return e.charAt(1).toUpperCase()}let cg={classId:"classID",dataType:"datatype",itemId:"itemID",strokeDashArray:"strokeDasharray",strokeDashOffset:"strokeDashoffset",strokeLineCap:"strokeLinecap",strokeLineJoin:"strokeLinejoin",strokeMiterLimit:"strokeMiterlimit",typeOf:"typeof",xLinkActuate:"xlinkActuate",xLinkArcRole:"xlinkArcrole",xLinkHref:"xlinkHref",xLinkRole:"xlinkRole",xLinkShow:"xlinkShow",xLinkTitle:"xlinkTitle",xLinkType:"xlinkType",xmlnsXLink:"xmlnsXlink"};var cm=e.i(359091),cy=e.i(76696);let ck=e.i(566935).default,cv=["http","https","mailto","tel"];function cb(e){let t=(e||"").trim(),n=t.charAt(0);if("#"===n||"/"===n)return t;let r=t.indexOf(":");if(-1===r)return t;let i=-1;for(;++i<cv.length;){let e=cv[i];if(r===e.length&&t.slice(0,e.length).toLowerCase()===e)return t}return -1!==(i=t.indexOf("?"))&&r>i||-1!==(i=t.indexOf("#"))&&r>i?t:"javascript:void(0)"}let cx={}.hasOwnProperty,cw=new Set(["table","thead","tbody","tfoot","tr"]);function cE(e,t){let n=-1,r=0;for(;++n<e.children.length&&e.children[n]!==t;)"element"===e.children[n].type&&r++;return r}function cS(e,t){return t.toUpperCase()}let cC={}.hasOwnProperty,cT={plugins:{to:"remarkPlugins",id:"change-plugins-to-remarkplugins"},renderers:{to:"components",id:"change-renderers-to-components"},astPlugins:{id:"remove-buggy-html-in-markdown-parser"},allowDangerousHtml:{id:"remove-buggy-html-in-markdown-parser"},escapeHtml:{id:"remove-buggy-html-in-markdown-parser"},source:{to:"children",id:"change-source-to-children"},allowNode:{to:"allowElement",id:"replace-allownode-allowedtypes-and-disallowedtypes"},allowedTypes:{to:"allowedElements",id:"replace-allownode-allowedtypes-and-disallowedtypes"},disallowedTypes:{to:"disallowedElements",id:"replace-allownode-allowedtypes-and-disallowedtypes"},includeNodeIndex:{to:"includeElementIndex",id:"change-includenodeindex-to-includeelementindex"}};function cN(e){for(let t in cT)if(cC.call(cT,t)&&cC.call(e,t)){let e=cT[t];console.warn(`[react-markdown] Warning: please ${e.to?`use \`${e.to}\` instead of`:"remove"} \`${t}\` (see <https://github.com/remarkjs/react-markdown/blob/main/changelog.md#${e.id}> for more info)`),delete cT[t]}let t=a0().use(lp).use(e.remarkPlugins||[]).use(l$,{...e.remarkRehypeOptions,allowDangerousHtml:!0}).use(e.rehypePlugins||[]).use(cl,e),n=new aV;"string"==typeof e.children?n.value=e.children:void 0!==e.children&&null!==e.children&&console.warn(`[react-markdown] Warning: please pass a string as \`children\` (not: \`${e.children}\`)`);let r=t.runSync(t.parse(n),n);if("root"!==r.type)throw TypeError("Expected a `root` node");let i=v.default.createElement(v.default.Fragment,{},function e(t,n){let r,i=[],o=-1;for(;++o<n.children.length;)"element"===(r=n.children[o]).type?i.push(function(t,n,r,i){var o;let a,s=t.options,l=void 0===s.transformLinkUri?cb:s.transformLinkUri,c=t.schema,u=n.tagName,d={};if("html"===c.space&&"svg"===u&&(t.schema=cs),n.properties)for(a in n.properties)cx.call(n.properties,a)&&function(e,t,n,r){let i=function(e,t){let n=lV(t),r=t,i=lW;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&"data"===n.slice(0,4)&&cu.test(t)){if("-"===t.charAt(4)){let e=t.slice(5).replace(cd,ch);r="data"+e.charAt(0).toUpperCase()+e.slice(1)}else{let e=t.slice(4);if(!cd.test(e)){let n=e.replace(cp,cf);"-"!==n.charAt(0)&&(n="-"+n),t="data"+n}}i=l3}return new i(r,t)}(r.schema,t),o=n;null!=o&&o==o&&(Array.isArray(o)&&(o=i.commaSeparated?(0,cy.stringify)(o):(0,cm.stringify)(o)),"style"===i.property&&"string"==typeof o&&(o=function(e){let t={};try{ck(e,function(e,n){t[("-ms-"===e.slice(0,4)?`ms-${e.slice(4)}`:e).replace(/-([a-z])/g,cS)]=n})}catch{}return t}
53(o)),i.space&&i.property?e[cx.call(cg,i.property)?cg[i.property]:i.property]=o:i.attribute&&(e[i.attribute]=o))}(d,a,n.properties[a],t);("ol"===u||"ul"===u)&&t.listDepth++;let p=e(t,n);("ol"===u||"ul"===u)&&t.listDepth--,t.schema=c;let f=n.position||{start:{line:null,column:null,offset:null},end:{line:null,column:null,offset:null}},h=s.components&&cx.call(s.components,u)?s.components[u]:u,g="string"==typeof h||h===v.default.Fragment;if(!cc.default.isValidElementType(h))throw TypeError(`Component for name \`${u}\` not defined or is not renderable`);if(d.key=r,"a"===u&&s.linkTarget&&(d.target="function"==typeof s.linkTarget?s.linkTarget(String(d.href||""),n.children,"string"==typeof d.title?d.title:null):s.linkTarget),"a"===u&&l&&(d.href=l(String(d.href||""),n.children,"string"==typeof d.title?d.title:null)),g||"code"!==u||"element"!==i.type||"pre"===i.tagName||(d.inline=!0),g||"h1"!==u&&"h2"!==u&&"h3"!==u&&"h4"!==u&&"h5"!==u&&"h6"!==u||(d.level=Number.parseInt(u.charAt(1),10)),"img"===u&&s.transformImageUri&&(d.src=s.transformImageUri(String(d.src||""),String(d.alt||""),"string"==typeof d.title?d.title:null)),!g&&"li"===u&&"element"===i.type){let e=function(e){let t=-1;for(;++t<e.children.length;){let n=e.children[t];if("element"===n.type&&"input"===n.tagName)return n}return null}(n);d.checked=e&&e.properties?!!e.properties.checked:null,d.index=cE(i,n),d.ordered="ol"===i.tagName}return g||"ol"!==u&&"ul"!==u||(d.ordered="ol"===u,d.depth=t.listDepth),("td"===u||"th"===u)&&(d.align&&(d.style||(d.style={}),d.style.textAlign=d.align,delete d.align),g||(d.isHeader="th"===u)),g||"tr"!==u||"element"!==i.type||(d.isHeader="thead"===i.tagName),s.sourcePos&&(d["data-sourcepos"]=[(o=f).start.line,":",o.start.column,"-",o.end.line,":",o.end.column].map(String).join("")),!g&&s.rawSourcePos&&(d.sourcePosition=n.position),!g&&s.includeElementIndex&&(d.index=cE(i,n),d.siblingCount=cE(i)),g||(d.node=n),p.length>0?v.default.createElement(h,d,p):v.default.createElement(h,d)}(t,r,o,n)):"text"===r.type?"element"===n.type&&cw.has(n.tagName)&&function(e){let t=e&&"object"==typeof e&&"text"===e.type?e.value||"":e;return"string"==typeof t&&""===t.replace(/[ \t\n\f\r]/g,"")}(r)||i.push(r.value):"raw"!==r.type||t.options.skipHtml||i.push(r.value);return i}({options:e,schema:ca,listDepth:0},r));return e.className&&(i=v.default.createElement("div",{className:e.className},i)),i}cN.propTypes={children:lH.default.string,className:lH.default.string,allowElement:lH.default.func,allowedElements:lH.default.arrayOf(lH.default.string),disallowedElements:lH.default.arrayOf(lH.default.string),unwrapDisallowed:lH.default.bool,remarkPlugins:lH.default.arrayOf(lH.default.oneOfType([lH.default.object,lH.default.func,lH.default.arrayOf(lH.default.oneOfType([lH.default.bool,lH.default.string,lH.default.object,lH.default.func,lH.default.arrayOf(lH.default.any)]))])),rehypePlugins:lH.default.arrayOf(lH.default.oneOfType([lH.default.object,lH.default.func,lH.default.arrayOf(lH.default.oneOfType([lH.default.bool,lH.default.string,lH.default.object,lH.default.func,lH.default.arrayOf(lH.default.any)]))])),sourcePos:lH.default.bool,rawSourcePos:lH.default.bool,skipHtml:lH.default.bool,includeElementIndex:lH.default.bool,transformLinkUri:lH.default.oneOfType([lH.default.func,lH.default.bool]),linkTarget:lH.default.oneOfType([lH.default.func,lH.default.string]),transformImageUri:lH.default.func,components:lH.default.object};let cA=((u={}).Assistant="assistant",u.Developer="developer",u.System="system",u.Tool="tool",u.User="user",u),c_=((d={}).Failed="Failed",d.Pending="Pending",d.Success="Success",d),cI={"\n mutation generateCopilotResponse(\n $data: GenerateCopilotResponseInput!\n $properties: JSONObject\n ) {\n generateCopilotResponse(data: $data, properties: $properties) {\n threadId\n runId\n extensions {\n openaiAssistantAPI {\n runId\n threadId\n }\n }\n ... on CopilotResponse @defer {\n status {\n ... on BaseResponseStatus {\n code\n }\n ... on FailedResponseStatus {\n reason\n details\n }\n }\n }\n messages @stream {\n __typename\n ... on BaseMessageOutput {\n id\n createdAt\n }\n ... on BaseMessageOutput @defer {\n status {\n ... on SuccessMessageStatus {\n code\n }\n ... on FailedMessageStatus {\n code\n reason\n }\n ... on PendingMessageStatus {\n code\n }\n }\n }\n ... on TextMessageOutput {\n content @stream\n role\n parentMessageId\n }\n ... on ImageMessageOutput {\n format\n bytes\n role\n parentMessageId\n }\n ... on ActionExecutionMessageOutput {\n name\n arguments @stream\n parentMessageId\n }\n ... on ResultMessageOutput {\n result\n actionExecutionId\n actionName\n }\n ... on AgentStateMessageOutput {\n threadId\n state\n running\n agentName\n nodeName\n runI
53d\n active\n role\n }\n }\n metaEvents @stream {\n ... on LangGraphInterruptEvent {\n type\n name\n value\n }\n\n ... on CopilotKitLangGraphInterruptEvent {\n type\n name\n data {\n messages {\n __typename\n ... on BaseMessageOutput {\n id\n createdAt\n }\n ... on BaseMessageOutput @defer {\n status {\n ... on SuccessMessageStatus {\n code\n }\n ... on FailedMessageStatus {\n code\n reason\n }\n ... on PendingMessageStatus {\n code\n }\n }\n }\n ... on TextMessageOutput {\n content\n role\n parentMessageId\n }\n ... on ActionExecutionMessageOutput {\n name\n arguments\n parentMessageId\n }\n ... on ResultMessageOutput {\n result\n actionExecutionId\n actionName\n }\n }\n value\n }\n }\n }\n }\n }\n":{kind:"Document",definitions:[{kind:"OperationDefinition",operation:"mutation",name:{kind:"Name",value:"generateCopilotResponse"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"data"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"GenerateCopilotResponseInput"}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"properties"}},type:{kind:"NamedType",name:{kind:"Name",value:"JSONObject"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"generateCopilotResponse"},arguments:[{kind:"Argument",name:{kind:"Name",value:"data"},value:{kind:"Variable",name:{kind:"Name",value:"data"}}},{kind:"Argument",name:{kind:"Name",value:"properties"},value:{kind:"Variable",name:{kind:"Name",value:"properties"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"threadId"}},{kind:"Field",name:{kind:"Name",value:"runId"}},{kind:"Field",name:{kind:"Name",value:"extensions"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"openaiAssistantAPI"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"runId"}},{kind:"Field",name:{kind:"Name",value:"threadId"}}]}}]}},{kind:"InlineFragment",typeCondition:{kind:"NamedType",name:{kind:"Name",value:"CopilotResponse"}},directives:[{kind:"Directive",name:{kind:"Name",value:"defer"}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"status"},selectionSet:{kind:"SelectionSet",selections:[{kind:"InlineFragment",typeCondition:{kind:"NamedType",name:{kind:"Name",value:"BaseResponseStatus"}},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"code"}}]}},{kind:"InlineFragment",typeCondition:{kind:"NamedType",name:{kind:"Name",value:"FailedResponseStatus"}},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"reason"}},{kind:"Field",name:{kind:"Name",value:"details"}}]}}]}}]}},{kind:"Field",name:{kind:"Name",value:"messages"},directives:[{kind:"Directive",name:{kind:"Name",value:"stream"}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"__typename"}},{kind:"InlineFragment",typeCondition:{kind:"NamedType",name:{kind:"Name",value:"BaseMessageOutput"}},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"id"}},{kind:"Field",name:{kind:"Name",value:"createdAt"}}]}},{kind:"InlineFragment",typeCondition:{kind:"NamedType",name:{kind:"Name",value:"BaseMessageOutput"}},directives:[{kind:"Directive",name:{kind:"Name",value:"defer"}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"status"},selectionSet:{kind:"SelectionSet",selections:[{kind:"InlineFragment",typeCondition:{kind:"NamedType",name:{kind:"Name",value:"SuccessMessageStatus"}},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"code"}}]}},{kind:"InlineFragment",typeCondition:{kind:"NamedType",name:{kind:"Name",value:"FailedMessageStatus"}},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"code"}},{kind:"Field",name:{kind:"Name",value:"reason"}}]}},{kind:"InlineFragment",typeCondition:{kind:"NamedType",name:{kind:"Name",value:"PendingMessageStatus"}},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"code"}}]}}]}}]}},{kind:"InlineFragment",typeCondition:{kind:"NamedType",name:{kind:"Name",value:"TextMessageOutput"}},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"content"},directives:[{kind:"Directive",name:{kind:"Name",value:"stream"}}]},{kind:"Field",name:{kind:"Name",value:"role"}},{kind:"Field",name:{kind:"Name",value:"parentMessageId"}}]}},{kind:"InlineFragment",typeCondition:{kind:"NamedType",name:{kind:"Name",value:"ImageMessageOutput"}},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"format"}},{kind:"Field",name:{kind:"Name",value:"bytes"}},{kind:"Field",name:{kind:"Name",value:"role"}},{kind:"Field",name:{kind:"Name",value:"parentMessageId"}}]}},{kind:"InlineFragment",typeCondition:{kind:"NamedType",name:{kind:"Name",value:"ActionExecutionMessageOutput"}},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"name"}},{kind:"Field",name:{kind:"Name",value:"arguments"},directives:[{kind:"Directive",name:{kind:"Name",value:"stream"}}]},{kind:"Field",name:{kind:"Name",value:"parentMessageId"}}]}},{kind:"InlineFragment",typeCondition:{kind:"NamedType",name:{kind:"Name",value:"ResultMessageOutput"}},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"result"}},{kind:"Field",name:{kind:"Name",value:"actionExecutionId"}},{kind:"Field",name:{kind:"Name",value:"actionName"}}]}},{kind:"InlineFragment",typeCondition:{kind:"NamedType",name:{kind:"Name",value:"AgentStateMessageOutput"}},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"threadId"}},{kind:"Field",name:{kind:"Name",value:"state"}},{kind:"Field",name:{kind:"Name",value:"running"}},{kind:"Field",name:{kind:"Name",value:"agentName"}},{kind:"Field",name:{kind:"Name",value:"nodeName"}}
53,{kind:"Field",name:{kind:"Name",value:"runId"}},{kind:"Field",name:{kind:"Name",value:"active"}},{kind:"Field",name:{kind:"Name",value:"role"}}]}}]}},{kind:"Field",name:{kind:"Name",value:"metaEvents"},directives:[{kind:"Directive",name:{kind:"Name",value:"stream"}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"InlineFragment",typeCondition:{kind:"NamedType",name:{kind:"Name",value:"LangGraphInterruptEvent"}},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"type"}},{kind:"Field",name:{kind:"Name",value:"name"}},{kind:"Field",name:{kind:"Name",value:"value"}}]}},{kind:"InlineFragment",typeCondition:{kind:"NamedType",name:{kind:"Name",value:"CopilotKitLangGraphInterruptEvent"}},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"type"}},{kind:"Field",name:{kind:"Name",value:"name"}},{kind:"Field",name:{kind:"Name",value:"data"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"messages"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"__typename"}},{kind:"InlineFragment",typeCondition:{kind:"NamedType",name:{kind:"Name",value:"BaseMessageOutput"}},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"id"}},{kind:"Field",name:{kind:"Name",value:"createdAt"}}]}},{kind:"InlineFragment",typeCondition:{kind:"NamedType",name:{kind:"Name",value:"BaseMessageOutput"}},directives:[{kind:"Directive",name:{kind:"Name",value:"defer"}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"status"},selectionSet:{kind:"SelectionSet",selections:[{kind:"InlineFragment",typeCondition:{kind:"NamedType",name:{kind:"Name",value:"SuccessMessageStatus"}},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"code"}}]}},{kind:"InlineFragment",typeCondition:{kind:"NamedType",name:{kind:"Name",value:"FailedMessageStatus"}},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"code"}},{kind:"Field",name:{kind:"Name",value:"reason"}}]}},{kind:"InlineFragment",typeCondition:{kind:"NamedType",name:{kind:"Name",value:"PendingMessageStatus"}},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"code"}}]}}]}}]}},{kind:"InlineFragment",typeCondition:{kind:"NamedType",name:{kind:"Name",value:"TextMessageOutput"}},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"content"}},{kind:"Field",name:{kind:"Name",value:"role"}},{kind:"Field",name:{kind:"Name",value:"parentMessageId"}}]}},{kind:"InlineFragment",typeCondition:{kind:"NamedType",name:{kind:"Name",value:"ActionExecutionMessageOutput"}},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"name"}},{kind:"Field",name:{kind:"Name",value:"arguments"}},{kind:"Field",name:{kind:"Name",value:"parentMessageId"}}]}},{kind:"InlineFragment",typeCondition:{kind:"NamedType",name:{kind:"Name",value:"ResultMessageOutput"}},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"result"}},{kind:"Field",name:{kind:"Name",value:"actionExecutionId"}},{kind:"Field",name:{kind:"Name",value:"actionName"}}]}}]}},{kind:"Field",name:{kind:"Name",value:"value"}}]}}]}}]}}]}}]}}]},"\n query availableAgents {\n availableAgents {\n agents {\n name\n id\n description\n }\n }\n }\n":{kind:"Document",definitions:[{kind:"OperationDefinition",operation:"query",name:{kind:"Name",value:"availableAgents"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"availableAgents"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"agents"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"name"}},{kind:"Field",name:{kind:"Name",value:"id"}},{kind:"Field",name:{kind:"Name",value:"description"}}]}}]}}]}}]},"\n query loadAgentState($data: LoadAgentStateInput!) {\n loadAgentState(data: $data) {\n threadId\n threadExists\n state\n messages\n }\n }\n":{kind:"Document",definitions:[{kind:"OperationDefinition",operation:"query",name:{kind:"Name",value:"loadAgentState"}
53,variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"data"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"LoadAgentStateInput"}}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"loadAgentState"},arguments:[{kind:"Argument",name:{kind:"Name",value:"data"},value:{kind:"Variable",name:{kind:"Name",value:"data"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"threadId"}},{kind:"Field",name:{kind:"Name",value:"threadExists"}},{kind:"Field",name:{kind:"Name",value:"state"}},{kind:"Field",name:{kind:"Name",value:"messages"}}]}}]}}]}};cI[` 54 mutation generateCopilotResponse( 55 $data: GenerateCopilotResponseInput! 56 $properties: JSONObject 57 ) { 58 generateCopilotResponse(data: $data, properties: $properties) { 59 threadId 60 runId 61 extensions { 62 openaiAssistantAPI { 63 runId 64 threadId 65 } 66 } 67 ... on CopilotResponse @defer { 68 status { 69 ... on BaseResponseStatus { 70 code 71 } 72 ... on FailedResponseStatus { 73 reason 74 details 75 } 76 } 77 } 78 messages @stream { 79 __typename 80 ... on BaseMessageOutput { 81 id 82 createdAt 83 } 84 ... on BaseMessageOutput @defer { 85 status { 86 ... on SuccessMessageStatus { 87 code 88 } 89 ... on FailedMessageStatus { 90 code 91 reason 92 } 93 ... on PendingMessageStatus { 94 code 95 } 96 } 97 } 98 ... on TextMessageOutput { 99 content @stream 100 role 101 parentMessageId 102 } 103 ... on ImageMessageOutput { 104 format 105 bytes 106 role 107 parentMessageId 108 } 109 ... on ActionExecutionMessageOutput { 110 name 111 arguments @stream 112 parentMessageId 113 } 114 ... on ResultMessageOutput { 115 result 116 actionExecutionId 117 actionName 118 } 119 ... on AgentStateMessageOutput { 120 threadId 121 state 122 running 123 agentName 124 nodeName 125 runId 126 active 127 role 128 } 129 } 130 metaEvents @stream { 131 ... on LangGraphInterruptEvent { 132 type 133 name 134 value 135 } 136 137 ... on CopilotKitLangGraphInterruptEvent { 138 type 139 name 140 data { 141 messages { 142 __typename 143 ... on BaseMessageOutput { 144 id 145 createdAt 146 } 147 ... on BaseMessageOutput @defer { 148 status { 149 ... on SuccessMessageStatus { 150 code 151 } 152 ... on FailedMessageStatus { 153 code 154 reason 155 } 156 ... on PendingMessageStatus { 157 code 158 } 159 } 160 } 161 ... on TextMessageOutput { 162 content 163 role 164 parentMessageId 165 } 166 ... on ActionExecutionMessageOutput { 167 name 168 arguments 169 parentMessageId 170 } 171 ... on ResultMessageOutput { 172 result 173 actionExecutionId 174 actionName 175 } 176 } 177 value 178 } 179 } 180 } 181 } 182 } 183`],cI[` 184 query availableAgents { 185 availableAgents { 186 agents { 187 name 188 id 189 description 190 } 191 } 192 } 193`],cI[` 194 query loadAgentState($data: LoadAgentStateInput!) { 195 loadAgentState(data: $data) { 196 threadId 197 threadExists 198 state 199 messages 200 } 201 } 202`];function cR(e,t,n){for(var r="",i=0;i<e.length;i++)i&&(r+=t),r+=n(e[i]);return r}var cM="\n",cO={OperationDefinition(e){var t="";e.description&&(t+=cO.StringValue(e.description)+"\n"),t+=e.operation,e.name&&(t+=" "+e.name.value),e.variableDefinitions&&e.variableDefinitions.length&&(e.name||(t+=" "),t+="("+cR(e.variableDefinitions,", ",cO.VariableDefinition)+")"),e.directives&&e.directives.length&&(t+=" "+cR(e.directives," ",cO.Directive));var n=cO.SelectionSet(e.selectionSet);return"query"!==t?t+" "+n:n},VariableDefinition(e){var t="";return e.description&&(t+=cO.StringValue(e.description)+" "),t+=cO.Variable(e.variable)+": "+cj(e.type),e.defaultValue&&(t+=" = "+cj(e.defaultValue)),e.directives&&e.directives.length&&(t+=" "+cR(e.directives," ",cO.Directive)),t},Field(e){var t=e.alias?e.alias.value+": "+e.name.value:e.name.value;if(e.arguments&&e.arguments.length){var n=cR(e.arguments,", ",cO.Argument);t.length+n.length+2>80?t+="("+(cM+=" ")+cR(e.arguments,cM,cO.Argument)+(cM=cM.slice(0,-2))+")":t+="("+n+")"}return e.directives&&e.directives.length&&(t+=" "+cR(e.directives," ",cO.Directive)),e.selectionSet&&e.selectionSet.selections.length&&(t+=" "+cO.SelectionSet(e.selectionSet)),t}
202,StringValue:e=>e.block?('"""\n'+e.value.replace(/"""/g,'\\"""')+'\n"""').replace(/\n/g,cM):JSON.stringify(e.value),BooleanValue:e=>""+e.value,NullValue:e=>"null",IntValue:e=>e.value,FloatValue:e=>e.value,EnumValue:e=>e.value,Name:e=>e.value,Variable:e=>"$"+e.name.value,ListValue:e=>"["+cR(e.values,", ",cj)+"]",ObjectValue:e=>"{"+cR(e.fields,", ",cO.ObjectField)+"}",ObjectField:e=>e.name.value+": "+cj(e.value),Document:e=>e.definitions&&e.definitions.length?cR(e.definitions,"\n\n",cj):"",SelectionSet:e=>"{"+(cM+=" ")+cR(e.selections,cM,cj)+(cM=cM.slice(0,-2))+"}",Argument:e=>e.name.value+": "+cj(e.value),FragmentSpread(e){var t="..."+e.name.value;return e.directives&&e.directives.length&&(t+=" "+cR(e.directives," ",cO.Directive)),t},InlineFragment(e){var t="...";return e.typeCondition&&(t+=" on "+e.typeCondition.name.value),e.directives&&e.directives.length&&(t+=" "+cR(e.directives," ",cO.Directive)),t+" "+cO.SelectionSet(e.selectionSet)},FragmentDefinition(e){var t="";return e.description&&(t+=cO.StringValue(e.description)+"\n"),t+="fragment "+e.name.value+" on "+e.typeCondition.name.value,e.directives&&e.directives.length&&(t+=" "+cR(e.directives," ",cO.Directive)),t+" "+cO.SelectionSet(e.selectionSet)},Directive(e){var t="@"+e.name.value;return e.arguments&&e.arguments.length&&(t+="("+cR(e.arguments,", ",cO.Argument)+")"),t},NamedType:e=>
202e.name.value,ListType:e=>"["+cj(e.type)+"]",NonNullType:e=>cj(e.type)+"!"},cj=e=>cO[e.kind](e);new WeakMap;"undefined"!=typeof File&&File,"undefined"!=typeof Blob&&Blob;let cz="undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto);var cD=new Uint8Array(16);let cP=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/i;for(var cF=[],cL=0;cL<256;++cL)cF.push((cL+256).toString(16).slice(1));function cU(e,t=0){return(cF[e[t+0]]+cF[e[t+1]]+cF[e[t+2]]+cF[e[t+3]]+"-"+cF[e[t+4]]+cF[e[t+5]]+"-"+cF[e[t+6]]+cF[e[t+7]]+"-"+cF[e[t+8]]+cF[e[t+9]]+"-"+cF[e[t+10]]+cF[e[t+11]]+cF[e[t+12]]+cF[e[t+13]]+cF[e[t+14]]+cF[e[t+15]]).toLowerCase()}let cB=function(e,t,n){if(cz&&!t&&!e)return cz();var r=(e=e||{}).random||(e.rng||function(){if(!k&&!(k="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)))throw Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return k(cD)})();if(r[6]=15&r[6]|64,r[8]=63&r[8]|128,t){n=n||0;for(var i=0;i<16;++i)t[n+i]=r[i];return t}return cU(r)},c$=function(e){if(!("string"==typeof e&&cP.test(e)))throw TypeError("Invalid UUID");var t,n=new Uint8Array(16);return n[0]=(t=parseInt(e.slice(0,8),16))>>>24,n[1]=t>>>16&255,n[2]=t>>>8&255,n[3]=255&t,n[4]=(t=parseInt(e.slice(9,13),16))>>>8,n[5]=255&t,n[6]=(t=parseInt(e.slice(14,18),16))>>>8,n[7]=255&t,n[8]=(t=parseInt(e.slice(19,23),16))>>>8,n[9]=255&t,n[10]=(t=parseInt(e.slice(24,36),16))/0x10000000000&255,n[11]=t/0x100000000&255,n[12]=t>>>24&255,n[13]=t>>>16&255,n[14]=t>>>8&255,n[15]=255&t,n};function cH(e,t){return e<<t|e>>>32-t}var cK=function(e){var t=[0x5a827999,0x6ed9eba1,0x8f1bbcdc,0xca62c1d6],n=[0x67452301,0xefcdab89,0x98badcfe,0x10325476,0xc3d2e1f0];if("string"==typeof e){var r=unescape(encodeURIComponent(e));e=[];for(var i=0;i<r.length;++i)e.push(r.charCodeAt(i))}else Array.isArray(e)||(e=Array.prototype.slice.call(e));e.push(128);for(var o=Math.ceil((e.length/4+2)/16),a=Array(o),s=0;s<o;++s){for(var l=new Uint32Array(16),c=0;c<16;++c)l[c]=e[64*s+4*c]<<24|e[64*s+4*c+1]<<16|e[64*s+4*c+2]<<8|e[64*s+4*c+3];a[s]=l}a[o-1][14]=(e.length-1)*8/0x100000000,a[o-1][14]=Math.floor(a[o-1][14]),a[o-1][15]=(e.length-1)*8|0;for(var u=0;u<o;++u){for(var d=new Uint32Array(80),p=0;p<16;++p)d[p]=a[u][p];for(var f=16;f<80;++f)d[f]=cH(d[f-3]^d[f-8]^d[f-14]^d[f-16],1);for(var h=n[0],g=n[1],m=n[2],y=n[3],k=n[4],v=0;v<80;++v){var b=Math.floor(v/20),x=cH(h,5)+function(e,t,n,r){switch(e){case 0:return t&n^~t&r;case 1:case 3:return t^n^r;case 2:return t&n^t&r^n&r}}(b,g,m,y)+k+t[b]+d[v]>>>0;k=y,y=m,m=cH(g,30)>>>0,g=h,h=x}n[0]=n[0]+h>>>0,n[1]=n[1]+g>>>0,n[2]=n[2]+m>>>0,n[3]=n[3]+y>>>0,n[4]=n[4]+k>>>0}return[n[0]>>24&255,n[0]>>16&255,n[0]>>8&255,255&n[0],n[1]>>24&255,n[1]>>16&255,n[1]>>8&255,255&n[1],n[2]>>24&255,n[2]>>16&255,n[2]>>8&255,255&n[2],n[3]>
202>24&255,n[3]>>16&255,n[3]>>8&255,255&n[3],n[4]>>24&255,n[4]>>16&255,n[4]>>8&255,255&n[4]]};function cG(e,t,n,r){if("string"==typeof e&&(e=function(e){e=unescape(encodeURIComponent(e));for(var t=[],n=0;n<e.length;++n)t.push(e.charCodeAt(n));return t}(e)),"string"==typeof t&&(t=c$(t)),(null==(i=t)?void 0:i.length)!==16)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");var i,o=new Uint8Array(16+e.length);if(o.set(t),o.set(e,t.length),(o=cK(o))[6]=15&o[6]|80,o[8]=63&o[8]|128,n){r=r||0;for(var a=0;a<16;++a)n[r+a]=o[a];return n}return cU(o)}try{cG.name="v5"}catch(e){}cG.DNS="6ba7b810-9dad-11d1-80b4-00c04fd430c8",cG.URL="6ba7b811-9dad-11d1-80b4-00c04fd430c8";new class{constructor(){}async logEvent(e){try{let t=new AbortController,n=setTimeout(()=>t.abort(),3e3),r=new URLSearchParams;Object.entries(e).forEach(([e,t])=>{null!=t&&r.append(e,String(t))});let i=`https://copilotkit.gateway.scarf.sh/1.52.1?${r.toString()}`,o=await fetch(i,{method:"GET",signal:t.signal});if(clearTimeout(n),!o.ok)throw Error(`HTTP error! status: ${o.status}`)}catch{}}};let cV=((p={}).CRITICAL="critical",p.WARNING="warning",p.INFO="info",p),cW=((f={}).BANNER="banner",f.TOAST="toast",f.SILENT="silent",f.DEV_ONLY="dev_only",f),cq=((h={}).NETWORK_ERROR="NETWORK_ERROR",h.NOT_FOUND="NOT_FOUND",h.AGENT_NOT_FOUND="AGENT_NOT_FOUND",h.API_NOT_FOUND="API_NOT_FOUND",h.REMOTE_ENDPOINT_NOT_FOUND="REMOTE_ENDPOINT_NOT_FOUND",h.AUTHENTICATION_ERROR="AUTHENTICATION_ERROR",h.MISUSE="MISUSE",h.UNKNOWN="UNKNOWN",h.VERSION_MISMATCH="VERSION_MISMATCH",h.CONFIGURATION_ERROR="CONFIGURATION_ERROR",h.MISSING_PUBLIC_API_KEY_ERROR="MISSING_PUBLIC_API_KEY_ERROR",h.UPGRADE_REQUIRED_ERROR="UPGRADE_REQUIRED_ERROR",h);cq.NETWORK_ERROR,cW.BANNER,cV.CRITICAL,cq.NOT_FOUND,cW.BANNER,cV.CRITICAL,cq.AGENT_NOT_FOUND,cW.BANNER,cV.CRITICAL,cq.API_NOT_FOUND,cW.BANNER,cV.CRITICAL,cq.REMOTE_ENDPOINT_NOT_FOUND,cW.BANNER,cV.CRITICAL,cq.AUTHENTICATION_ERROR,cW.BANNER,cV.CRITICAL,cq.MISUSE,cW.DEV_ONLY,cV.WARNING,cq.UNKNOWN,cW.TOAST,cV.CRITICAL,cq.CONFIGURATION_ERROR,cV.WARNING,cW.BANNER,cq.MISSING_PUBLIC_API_KEY_ERROR,cV.CRITICAL,cW.BANNER,cq.UPGRADE_REQUIRED_ERROR,cV.WARNING,cW.BANNER,cq.VERSION_MISMATCH,cW.DEV_ONLY,cV.INFO;var cJ=class{constructor(e){e.id??="ck-"+cB(),e.status??={code:c_.Success},e.createdAt??=new Date,Object.assign(this,e)}isTextMessage(){return"TextMessage"===this.type}isActionExecutionMessage(){return"ActionExecutionMessage"===this.type}isResultMessage(){return"ResultMessage"===this.type}isAgentStateMessage(){return"AgentStateMessage"===this.type}isImageMessage(){return"ImageMessage"===this.type}},cX=class extends cJ{constructor(e){super(e),this.type="TextMessage",this.type="TextMessage"}},cY=class extends cJ{constructor(e){super(e),this.type="ActionExecutionMessage"}},cQ=class extends cJ{constructor(e){super(e),this.type="ResultMessage"}static decodeResult(e){return function(e,t="unset"){try{return JSON.parse(e)}catch(e){return"unset"===t?null:t}}(e,e)}static encodeResult(e){return void 0===e?"":"string"==typeof e?e:JSON.stringify(e)}},cZ=class extends cJ{constructor(e){super(e),this.type="AgentStateMessage"}},c0=class extends cJ{constructor(e){super(e),this.type="ImageMessage"}};e.s(["ActionExecutionMessage",()=>cY,"AgentStateMessage",()=>cZ,"ImageMessage",()=>c0,"Message",()=>cJ,"ResultMessage",()=>cQ,"Role",()=>cA,"TextMessage",()=>cX],284545),e.i(992630);let c1=["jpeg","png","webp","gif"];function c2(e,t,n){let r=[];e=Array.isArray(e)?e:[e];let i=new Map;for(let t of e)t.isResultMessage()&&i.set(t.actionExecutionId,t.result);for(let a of e)if(a.isTextMessage())r.push(function(e){switch(e.role){case cA.Developer:return{id:e.id,role:"developer",content:e.content};case cA.System:return{id:e.id,role:"system",content:e.content};case cA.Assistant:return{id:e.id,role:"assistant",content:e.content};case cA.User:return{id:e.id,role:"user",content:e.content};default:throw Error("Unknown message role")}}(a));else if(a.isResultMessage()){var o;r.push({id:(o=a).id,role:"tool",content:o.result,toolCallId:o.actionExecutionId,toolName:o.actionName})}else if(a.isActionExecutionMessage())r.push(function(e,t,n){let r=t&&Object.values(t).some(t=>t.name===e.name),i=t&&Object.values(t).some(e=>"*"===e.name);if(!t||!r&&!i)return{id:e.id,role:"assistant",toolCalls:[c5(e)],name:e.name};let o=Object.values(t).find(t=>t.name===e.name)||Object.values(t).find(e=>"*"===e.name);return{id:e.id,role:"assistant",content:"",toolCalls:[c5(e)],generativeUI:(t=>{if(t)return r=>{let i=n?.get(e.id),a="inProgress";if(void 0!==i?a="complete":e.status?.code!==c_.Pending&&(a="executing"),"string"==typeof r?.result)try{r.result=JSON.parse(r.result)}catch(e){}if("string"==typeof i)try{i=JSON.parse(i)}catch(e){}let s={status:r?.status||a,args:e.arguments||{},result:r?.result||i||void 0,messageId:e.id};if("*"===o.name)return t({...s,...r,name:e.name});{let e=r?.respond??(()=>{});return t({...s,...r,respond:e})}}})(o.render),name:e.name}}(a,t,i));else if(a.isAgentStateMessage())r.push(function(e,t){if(t&&Object.values(t).some(t=>t.name===e.agentName)){let n=Object.values(t).find(t=>t.name===e.agentName);return{id:e.id,role:"assistant",generativeUI:(t=>{if(t)return n=>t({state:e.state})})(n.render),agentName:e.agentName,state:e.state}}return{id:e.id,role:"assistant",agentName:e.agentName,state:e.state}}(a,n));else if(a.isImageMessage())r.push(function(e){var t;if(t=e.format,!c1.includes(t))throw Error(`Invalid image format: ${e.format}. Supported formats are: ${c1.join(", ")}`);
202if(!e.bytes||"string"!=typeof e.bytes||""===e.bytes.trim())throw Error("Image bytes must be a non-empty string");let n=e.role===cA.Assistant?"assistant":"user";return{id:e.id,role:n,content:"",image:{format:e.format,bytes:e.bytes}}}(a));else throw Error("Unknown message type");return r}function c5(e){return{id:e.id,function:{name:e.name,arguments:JSON.stringify(e.arguments)},type:"function"}}e.s(["gqlToAGUI",()=>c2],647126);let c4=ny.z.object({name:ny.z.string(),arguments:ny.z.string()}),c3=ny.z.object({id:ny.z.string(),type:ny.z.literal("function"),function:c4,encryptedValue:ny.z.string().optional()}),c6=ny.z.object({id:ny.z.string(),role:ny.z.string(),content:ny.z.string().optional(),name:ny.z.string().optional(),encryptedValue:ny.z.string().optional()}),c8=ny.z.object({type:ny.z.literal("text"),text:ny.z.string()}),c9=ny.z.object({type:ny.z.literal("binary"),mimeType:ny.z.string(),id:ny.z.string().optional(),url:ny.z.string().optional(),data:ny.z.string().optional(),filename:ny.z.string().optional()}),c7=(e,t)=>{e.id||e.url||e.data||t.addIssue({code:ny.z.ZodIssueCode.custom,message:"BinaryInputContent requires at least one of id, url, or data.",path:["id"]})};c9.superRefine((e,t)=>{c7(e,t)});let ue=ny.z.discriminatedUnion("type",[c8,c9]).superRefine((e,t)=>{"binary"===e.type&&c7(e,t)}),ut=c6.extend({role:ny.z.literal("developer"),content:ny.z.string()}),un=c6.extend({role:ny.z.literal("system"),content:ny.z.string()}),ur=c6.extend({role:ny.z.literal("assistant"),content:ny.z.string().optional(),toolCalls:ny.z.array(c3).optional()}),ui=c6.extend({role:ny.z.literal("user"),content:ny.z.union([ny.z.string(),ny.z.array(ue)])}),uo=ny.z.object({id:ny.z.string(),content:ny.z.string(),role:ny.z.literal("tool"),toolCallId:ny.z.string(),error:ny.z.string().optional(),encryptedValue:ny.z.string().optional()}),ua=ny.z.object({id:ny.z.string(),role:ny.z.literal("activity"),activityType:ny.z.string(),content:ny.z.record(ny.z.any())}),us=ny.z.object({id:ny.z.string(),role:ny.z.literal("reasoning"),content:ny.z.string(),encryptedValue:ny.z.string().optional()}),ul=ny.z.discriminatedUnion("role",[ut,un,ur,ui,uo,ua,us]);ny.z.union([ny.z.literal("developer"),ny.z.literal("system"),ny.z.literal("assistant"),ny.z.literal("user"),ny.z.literal("tool"),ny.z.literal("activity"),ny.z.literal("reasoning")]);let uc=ny.z.object({description:ny.z.string(),value:ny.z.string()}),uu=ny.z.object({name:ny.z.string(),description:ny.z.string(),parameters:ny.z.any()}),ud=ny.z.object({threadId:ny.z.string(),runId:ny.z.string(),parentRunId:ny.z.string().optional(),state:ny.z.any(),messages:ny.z.array(ul),tools:ny.z.array(uu),context:ny.z.array(uc),forwardedProps:ny.z.any()}),up=ny.z.any();var uf=class extends Error{constructor(e){super(e)}},uh=class extends uf{constructor(){super("Connect not implemented. This method is not supported by the current agent.")}};let ug=ny.z.union([ny.z.literal("developer"),ny.z.literal("system"),ny.z.literal("assistant"),ny.z.literal("user")]),um=((g={}).TEXT_MESSAGE_START="TEXT_MESSAGE_START",g.TEXT_MESSAGE_CONTENT="TEXT_MESSAGE_CONTENT",g.TEXT_MESSAGE_END="TEXT_MESSAGE_END",g.TEXT_MESSAGE_CHUNK="TEXT_MESSAGE_CHUNK",g.TOOL_CALL_START="TOOL_CALL_START",g.TOOL_CALL_ARGS="TOOL_CALL_ARGS",g.TOOL_CALL_END="TOOL_CALL_END",g.TOOL_CALL_CHUNK="TOOL_CALL_CHUNK",g.TOOL_CALL_RESULT="TOOL_CALL_RESULT",g.THINKING_START="THINKING_START",g.THINKING_END="THINKING_END",g.THINKING_TEXT_MESSAGE_START="THINKING_TEXT_MESSAGE_START",g.THINKING_TEXT_MESSAGE_CONTENT="THINKING_TEXT_MESSAGE_CONTENT",g.THINKING_TEXT_MESSAGE_END="THINKING_TEXT_MESSAGE_END",g.STATE_SNAPSHOT="STATE_
202SNAPSHOT",g.STATE_DELTA="STATE_DELTA",g.MESSAGES_SNAPSHOT="MESSAGES_SNAPSHOT",g.ACTIVITY_SNAPSHOT="ACTIVITY_SNAPSHOT",g.ACTIVITY_DELTA="ACTIVITY_DELTA",g.RAW="RAW",g.CUSTOM="CUSTOM",g.RUN_STARTED="RUN_STARTED",g.RUN_FINISHED="RUN_FINISHED",g.RUN_ERROR="RUN_ERROR",g.STEP_STARTED="STEP_STARTED",g.STEP_FINISHED="STEP_FINISHED",g.REASONING_START="REASONING_START",g.REASONING_MESSAGE_START="REASONING_MESSAGE_START",g.REASONING_MESSAGE_CONTENT="REASONING_MESSAGE_CONTENT",g.REASONING_MESSAGE_END="REASONING_MESSAGE_END",g.REASONING_MESSAGE_CHUNK="REASONING_MESSAGE_CHUNK",g.REASONING_END="REASONING_END",g.REASONING_ENCRYPTED_VALUE="REASONING_ENCRYPTED_VALUE",g),uy=ny.z.object({type:ny.z.nativeEnum(um),timestamp:ny.z.number().optional(),rawEvent:ny.z.any().optional()}).passthrough(),uk=uy.extend({type:ny.z.literal(um.TEXT_MESSAGE_START),messageId:ny.z.string(),role:ug.default("assistant")}),uv=uy.extend({type:ny.z.literal(um.TEXT_MESSAGE_CONTENT),messageId:ny.z.string(),delta:ny.z.string().refine(e=>e.length>0,"Delta must not be an empty string")}),ub=uy.extend({type:ny.z.literal(um.TEXT_MESSAGE_END),messageId:ny.z.string()}),ux=uy.extend({type:ny.z.literal(um.TEXT_MESSAGE_CHUNK),messageId:ny.z.string().optional(),role:ug.optional(),delta:ny.z.string().optional()}),uw=uy.extend({type:ny.z.literal(um.THINKING_TEXT_MESSAGE_START)}),uE=uv.omit({messageId:!0,type:!0}).extend({type:ny.z.literal(um.THINKING_TEXT_MESSAGE_CONTENT)}),uS=uy.extend({type:ny.z.literal(um.THINKING_TEXT_MESSAGE_END)}),uC=uy.extend({type:ny.z.literal(um.TOOL_CALL_START),toolCallId:ny.z.string(),toolCallName:ny.z.string(),parentMessageId:ny.z.string().optional()}),uT=uy.extend({type:ny.z.literal(um.TOOL_CALL_ARGS),toolCallId:ny.z.string(),delta:ny.z.string()}),uN=uy.extend({type:ny.z.literal(um.TOOL_CALL_END),toolCallId:ny.z.string()}),uA=uy.extend({messageId:ny.z.string(),type:ny.z.literal(um.TOOL_CALL_RESULT),toolCallId:ny.z.string(),content:ny.z.string(),role:ny.z.literal("tool").optional()}),u_=uy.extend({type:ny.z.literal(um.TOOL_CALL_CHUNK),toolCallId:ny.z.string().optional(),toolCallName:ny.z.string().optional(),parentMessageId:ny.z.string().optional(),delta:ny.z.string().optional()}),uI=uy.extend({type:ny.z.literal(um.THINKING_START),title:ny.z.string().optional()}),uR=uy.extend({type:ny.z.literal(um.THINKING_END)}),uM=uy.extend({type:ny.z.literal(um.STATE_SNAPSHOT),snapshot:up}),uO=uy.extend({type:ny.z.literal(um.STATE_DELTA),delta:ny.z.array(ny.z.any())}),uj=uy.extend({type:ny.z.literal(um.MESSAGES_SNAPSHOT),messages:ny.z.array(ul)}),uz=uy.extend({type:ny.z.literal(um.ACTIVITY_SNAPSHOT),messageId:ny.z.string(),activityType:ny.z.string(),content:ny.z.record(ny.z.any()),replace:ny.z.boolean().optional().default(!0)}),uD=uy.extend({type:ny.z.literal(um.ACTIVITY_DELTA),messageId:ny.z.string(),activityType:ny.z.string(),patch:ny.z.array(ny.z.any())}),uP=uy.extend({type:ny.z.literal(um.RAW),event:ny.z.any(),source:ny.z.string().optional()}),uF=uy.extend({type:ny.z.literal(um.CUSTOM),name:ny.z.string(),value:ny.z.any()}),uL=uy.extend({type:ny.z.literal(um.RUN_STARTED),threadId:ny.z.string(),runId:ny.z.string(),parentRunId:ny.z.string().optional(),input:ud.optional()}),uU=uy.extend({type:ny.z.literal(um.RUN_FINISHED),threadId:ny.z.string(),runId:ny.z.string(),result:ny.z.any().optional()}),uB=uy.extend({type:ny.z.literal(um.RUN_ERROR),message:ny.z.string(),code:ny.z.string().optional()}),u$=uy.extend({type:ny.z.literal(um.STEP_STARTED),stepName:ny.z.string()}),uH=uy.extend({type:ny.z.literal(um.STEP_FINISHED),stepName:ny.z.string()}),uK=ny.z.union([ny.z.literal("tool-call"),ny.z.literal("message")]),uG=uy.extend({type:ny.z.literal(um.REASONING_START),messageId:ny.z.string()}),uV=uy.extend({type:ny.z.literal(um.REASONING_MESSAGE_START),messageId:ny.z.string(),role:ny.z.literal("reasoning")}),uW=uy.extend({type:ny.z.literal(um.REASONING_MESSAGE_CONTENT),messageId:ny.z.string(),delta:ny.z.string().refine(e=>e.length>0,"Delta must not be an empty string")}),uq=uy.extend({type:ny.z.literal(um.REASONING_MESSAGE_END),messageId:ny.z.string()}),uJ=uy.extend({type:ny.z.literal(um.REASONING_MESSAGE_CHUNK),messageId:ny.z.string().optional(),delta:ny.z.string().optional()}),uX=uy.extend({type:ny.z.literal(um.REASONING_END),messageId:ny.z.string()}),uY=uy.extend({type:ny.z.literal(um.REASONING_ENCRYPTED_VALUE),subtype:uK,entityId:ny.z.string(),encryptedValue:ny.z.string()});ny.z.discriminatedUnion("type",[uk,uv,ub,ux,uI,uR,uw,uE,uS,uC,uT,uN,u_,uA,uM,uO,uj,uz,uD,uP,uF,uL,uU,uB,u$,uH,uG,u
202V,uW,uq,uJ,uX,uY]);let uQ={actions:{},setAction:()=>{},removeAction:()=>{},setRegisteredActions:()=>"",removeRegisteredAction:()=>{},chatComponentsCache:{current:{actions:{},coAgentStateRenders:{}}},getContextString:(e,t)=>u1(""),addContext:()=>"",removeContext:()=>{},getAllContext:()=>[],getFunctionCallHandler:()=>u1(async()=>{}),isLoading:!1,setIsLoading:()=>u1(!1),chatInstructions:"",setChatInstructions:()=>u1(""),additionalInstructions:[],setAdditionalInstructions:()=>u1([]),getDocumentsContext:e=>u1([]),addDocumentContext:()=>u1(""),removeDocumentContext:()=>{},copilotApiConfig:new class{get chatApiEndpoint(){throw Error("Remember to wrap your app in a `<CopilotKit> {...} </CopilotKit>` !!!")}get headers(){return{}}get body(){return{}}},chatSuggestionConfiguration:{},addChatSuggestionConfiguration:()=>{},removeChatSuggestionConfiguration:()=>{},showDevConsole:!1,coagentStates:{},setCoagentStates:()=>{},coagentStatesRef:{current:{}},setCoagentStatesWithRef:()=>{},agentSession:null,setAgentSession:()=>{},forwardedParameters:{},agentLock:null,threadId:"",setThreadId:()=>{},runId:null,setRunId:()=>{},chatAbortControllerRef:{current:null},availableAgents:[],extensions:{},setExtensions:()=>{},interruptActions:{},setInterruptAction:()=>{},removeInterruptAction:()=>{},interruptEventQueue:{},addInterruptEvent:()=>{},resolveInterruptEvent:()=>{},onError:()=>{},bannerError:null,setBannerError:()=>{},internalErrorHandlers:{},setInternalErrorHandler:()=>{},removeInternalErrorHandler:()=>{}},uZ=v.default.createContext(uQ);function u0(){let e=v.default.useContext(uZ);if(e===uQ)throw Error("Remember to wrap your app in a `<CopilotKit> {...} </CopilotKit>` !!!");return e}function u1(e){throw Error("Remember to wrap your app in a `<CopilotKit> {...} </CopilotKit>` !!!")}let u2=(e,t)=>e.reduce((e,n)=>{if(n.id!==t){let r={...n,children:u2(n.children,t)};e.push(r)}return e},[]),u5=(e,t,n)=>n?e.map(e=>e.id===n?{...e,children:[...e.children,t]}:e.children.length?{...e,children:u5(e.children,t,n)}:e):[...e,t],u4=(e,t)=>0===t?(e+1).toString():1===t?String.fromCharCode(65+e):2===t?String.fromCharCode(97+e):"-",u3=(e,t="",n=0)=>{let r=" ".repeat(3).repeat(n),i=t.length+r.length,o=" ".repeat(i),a=e.value.split("\n"),s=`${r}${t}${a[0]}`,l=a.slice(1).map(e=>`${o}${e}`).join("\n"),c=`${s} 203`;l&&(c+=`${l} 204`);let u=" ".repeat(t.length);return e.children.forEach((e,t)=>c+=u3(e,`${u}${u4(t,n+1)}. `,n+1)),c};function u6(e,t){switch(t.type){case"ADD_NODE":{let{value:n,parentId:r,id:i}=t,o={id:i,value:n,children:[],categories:new Set(t.categories)};try{return u5(e,o,r)}
204catch(t){return console.error(`Error while adding node with id ${i}: ${t}`),e}}case"REMOVE_NODE":return u2(e,t.id);default:return e}}function u8(e,t){switch(t.type){case"ADD_ELEMENT":{let{value:n,id:r,categories:i}=t,o={id:r,value:n,categories:new Set(i)},a=new Map(e);return a.set(r,o),a}case"REMOVE_ELEMENT":{let n=new Map(e);return n.delete(t.id),n}default:return e}}let u9={messages:[],setMessages:()=>[],suggestions:[],setSuggestions:()=>[]},u7=v.default.createContext(u9);function de(){let e=v.default.useContext(u7);if(e===u9)throw Error("A messages consuming component was not wrapped with `<CopilotMessages> {...} </CopilotMessages>`");return e}let dt=(0,v.createContext)(void 0);function dn(){let e=(0,v.useContext)(dt);if(!e)throw Error("useToast must be used within a ToastProvider");return e}function dr({enabled:e,children:t}){let n,r,i,[o,a]=(0,v.useState)([]),[s,l]=(0,v.useState)(null),c=(0,v.useCallback)(e=>{a(t=>t.filter(t=>t.id!==e))},[]),u=(0,v.useCallback)(t=>{if(!e)return;let n=t.id??Math.random().toString(36).substring(2,9);a(e=>e.find(e=>e.id===n)?e:[...e,{...t,id:n}]),t.duration&&setTimeout(()=>{c(n)},t.duration)},[e,c]),d=(0,v.useCallback)(t=>{(e||null===t)&&l(t)},[e]),p={toasts:o,addToast:u,addGraphQLErrorsToast:(0,v.useCallback)(e=>{console.warn("addGraphQLErrorsToast is deprecated. All errors now show as banners.")},[]),removeToast:c,enabled:e,bannerError:s,setBannerError:d};return(0,w.jsxs)(dt.Provider,{value:p,children:[s&&(n=function(e){switch(e){case"critical":return{background:"#fee2e2",border:"#dc2626",text:"#7f1d1d",icon:"#dc2626"};case"warning":return{background:"#fef3c7",border:"#d97706",text:"#78350f",icon:"#d97706"};case"info":return{background:"#dbeafe",border:"#2563eb",text:"#1e3a8a",icon:"#2563eb"}}}(function(e){if(e.severity)switch(e.severity){case av.CRITICAL:return"critical";case av.WARNING:return"warning";case av.INFO:default:return"info"}let t=e.message.toLowerCase();return t.includes("api key")||t.includes("401")||t.includes("unauthorized")||t.includes("authentication")||t.includes("incorrect api key")?"critical":"info"}(s)),(0,w.jsx)("div",{style:{position:"fixed",bottom:"20px",left:"50%",transform:"translateX(-50%)",zIndex:9999,backgroundColor:n.background,border:`1px solid ${n.border}`,borderLeft:`4px solid ${n.border}`,borderRadius:"8px",padding:"12px 16px",fontSize:"13px",boxShadow:"0 4px 12px rgba(0, 0, 0, 0.15)",backdropFilter:"blur(8px)",maxWidth:"min(90vw, 700px)",width:"100%",boxSizing:"border-box",overflow:"hidden"},children:(0,w.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",gap:"10px"},children:[(0,w.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"8px",flex:1,minWidth:0},children:[(0,w.jsx)("div",{style:{width:"12px",height:"12px",borderRadius:"50%",backgroundColor:n.border,flexShrink:0}}),(0,w.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"10px",flex:1,minWidth:0},children:[(0,w.jsx)("div",{style:{color:n.text,lineHeight:"1.4",fontWeight:"400",fontSize:"13px",flex:1,wordBreak:"break-all",overflowWrap:"break-word",maxWidth:"550px",overflow:"hidden",display:"-webkit-box",WebkitLineClamp:10,WebkitBoxOrient:"vertical"},children:(i=(r=s.message).match(/'message':\s*'([^']+)'/))?i[1]:(r=(r=(r=(r=(r=r.split(" - ")[0]).split(": Error code")[0]).replace(/:\s*\d{3}$/,"")).replace(/See more:.*$/g,"")).trim())||"Configuration error occurred."}),(()=>{let e=s.message,t=null,r="See More",i=/\[([^\]]+)\]\(([^)]+)\)/g.exec(e);if(i)t=i[2],r="See More";else{let n=/(https?:\/\/[^\s)]+)/g.exec(e);n&&(t=n[0].replace(/[.,;:'"]*$/,""),r="See More")}return t?(0,w.jsx)("button",{onClick:()=>window.open(t,"_blank","noopener,noreferrer"),style:{background:n.border,color:"white",border:"none",borderRadius:"5px",padding:"4px 10px",fontSize:"11px",fontWeight:"500",cursor:"pointer",transition:"all 0.2s ease",flexShrink:0},onMouseEnter:e=>{e.currentTarget.style.opacity="0.9",e.currentTarget.style.transform="translateY(-1px)"},onMouseLeave:e=>{e.currentTarget.style.opacity="1",e.currentTarget.style.transform="translateY(0)"},children:r}):null})()]})]}),(0,w.jsx)("button",{onClick:()=>d(null),style:{background:"transparent",border:"none",color:n.text,cursor:"pointer",padding:"2px",borderRadius:"3px",fontSize:"14px",lineHeight:"1",opacity:.6,transition:"all 0.2s ease",flexShrink:0},title:"Dismiss",onMouseEnter:e=>{e.currentTarget.style.opacity="1",e.currentTarget.style.background="rgba(0, 0, 0, 0.05)"},onMouseLeave:e=>{e.currentTarget.style.opacity="0.6",e.currentTarget.style.background="transparent"},children:"Ã"})]})})),t]})}function di(e){return void 0!==e?e:"undefined"!=typeof window&&("localhost"===window.location.hostname||"127.0.0.1"===window.location.hostname||"0.0.0.0"===window.location.hostname)}let da=(0,v.createContext)(null);function ds({children:e}){let t=(0,v.useRef)([]),n=(0,v.useRef)({getMessagesFromTap:()=>t.current,updateTapMessages:e=>{t.current=e}});return(0,w.jsx)(da.Provider,{value:n.current,children:e})}function dl({children:e}){let[t,n]=(0,v.useState)([]);(0,v.useRef)(void 0),(0,v.useRef)(void 0),(0,v.useRef)(void 0);let{updateTapMessages:r}=function(){let e=(0,v.useContext)(da);if(!e)throw Error("useMessagesTap must be used inside <MessagesTapProvider>");return e}(),{threadId:i,agentSession:o,showDevConsole:a,onError:s,copilotApiConfig:l}=u0(),{setBannerError:c}=dn(),u=(0,v.useCallback)(async(e,t)=>{if(s&&l.publicApiKey)try{await s({type:"error",timestamp:Date.now(),context:{source:"ui",request:{operation:"loadAgentState",url:l.chatApiEndpoint,startTime:Date.now()},technical:{environment:"browser",userAgent:"undefined"!=typeof navigator?navigator.userAgent:void 0,stackTrace:t instanceof Error?t.stack:void 0}},error:e})}catch(e){console.error("Error in CopilotMessages onError handler:",e)}},[s,l.publicApiKey,l.chatApiEndpoint]);(0,v.useCallback)(e=>
204{if(e.graphQLErrors?.length)e.graphQLErrors.forEach(e=>{let t=e.extensions?.visibility;if(!di(a))return void console.error("CopilotKit Error (hidden in production):",e.message);if(t===ab.SILENT)return void console.error("CopilotKit Silent Error:",e.message);let n=(e=>{let t=e.extensions,n=t?.originalError;if(n?.stack){if(n.stack.includes("CopilotApiDiscoveryError"))return new aT({message:n.message});if(n.stack.includes("CopilotKitRemoteEndpointDiscoveryError"))return new aN({message:n.message});if(n.stack.includes("CopilotKitAgentDiscoveryError"))return new aA({agentName:"",availableAgents:[]})}let r=n?.message||e.message,i=t?.code;return i?new aC({message:r,code:i}):null})(e);if(n)c(n),u(n,e);else{let t=new aC({message:e.message,code:ax.UNKNOWN});c(t),u(t,e)}});else if(di(a)){let t=new aC({message:e?.message||String(e),code:ax.UNKNOWN});c(t),u(t,e)}else console.error("CopilotKit Error (hidden in production):",e)},[c,a,u]),(0,v.useEffect)(()=>{r(t)},[t,r]);let d=(0,v.useMemo)(()=>e,[e]),[p,f]=(0,v.useState)([]);return(0,w.jsx)(u7.Provider,{value:{messages:t,setMessages:n,suggestions:p,setSuggestions:f},children:d})}function dc({severity:e=av.CRITICAL,message:t="",onClose:n,actions:r}){if(!t||!e)return null;let i={[av.INFO]:{bg:"#f8fafc",border:"#e2e8f0",text:"#475569",accent:"#3b82f6"},[av.WARNING]:{bg:"#fffbeb",border:"#fbbf24",text:"#92400e",accent:"#f59e0b"},[av.CRITICAL]:{bg:"#fef2f2",border:"#fecaca",text:"#dc2626",accent:"#ef4444"}}[e];return(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)("style",{children:` 205 @keyframes slideUp { 206 from { opacity: 0; transform: translateX(-50%) translateY(8px); } 207 to { opacity: 1; transform: translateX(-50%) translateY(0); } 208 } 209 210 .usage-banner { 211 position: fixed; 212 bottom: 24px; 213 left: 50%; 214 transform: translateX(-50%); 215 width: min(600px, calc(100vw - 32px)); 216 z-index: 10000; 217 animation: slideUp 0.2s cubic-bezier(0.16, 1, 0.3, 1); 218 } 219 220 .banner-content { 221 background: linear-gradient(135deg, ${i.bg} 0%, ${i.bg}f5 100%); 222 border: 1px solid ${i.border}; 223 border-radius: 12px; 224 padding: 18px 20px; 225 box-shadow: 226 0 4px 24px rgba(0, 0, 0, 0.08), 227 0 2px 8px rgba(0, 0, 0, 0.04), 228 inset 0 1px 0 rgba(255, 255, 255, 0.7); 229 display: flex; 230 align-items: center; 231 gap: 16px; 232 font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif; 233 backdrop-filter: blur(12px); 234 position: relative; 235 overflow: hidden; 236 } 237 238 .banner-content::before { 239 content: ''; 240 position: absolute; 241 top: 0; 242 left: 0; 243 right: 0; 244 height: 1px; 245 background: linear-gradient(90deg, transparent, ${i.accent}40, transparent); 246 } 247 248 .banner-message { 249 color: ${i.text}; 250 font-size: 14px; 251 line-height: 1.5; 252 font-weight: 500; 253 flex: 1; 254 letter-spacing: -0.01em; 255 } 256 257 .close-btn { 258 background: rgba(0, 0, 0, 0.05); 259 border: none; 260 color: ${i.text}; 261 cursor: pointer; 262 padding: 0; 263 border-radius: 6px; 264 opacity: 0.6; 265 transition: all 0.15s cubic-bezier(0.16, 1, 0.3, 1); 266 font-size: 14px; 267 line-height: 1; 268 flex-shrink: 0; 269 width: 24px; 270 height: 24px; 271 display: flex; 272 align-items: center; 273 justify-content: center; 274 } 275 276 .close-btn:hover { 277 opacity: 1; 278 background: rgba(0, 0, 0, 0.08); 279 transform: scale(1.05); 280 } 281 282 .btn-primary { 283 background: linear-gradient(135deg, ${i.accent} 0%, ${i.accent}e6 100%); 284 color: white; 285 border: none; 286 border-radius: 8px; 287 padding: 10px 18px; 288 font-size: 13px; 289 font-weight: 600; 290 cursor: pointer; 291 transition: all 0.15s cubic-bezier(0.16, 1, 0.3, 1); 292 font-family: inherit; 293 flex-shrink: 0; 294 box-shadow: 295 0 2px 8px ${i.accent}30, 296 inset 0 1px 0 rgba(255, 255, 255, 0.2); 297 letter-spacing: -0.01em; 298 } 299 300 .btn-primary:hover { 301 transform: translateY(-1px) scale(1.02); 302 box-shadow: 303 0 4px 12px ${i.accent}40, 304 inset 0 1px 0 rgba(255, 255, 255, 0.25); 305 } 306 307 .btn-primary:active { 308 transform: translateY(0) scale(0.98); 309 transition: all 0.08s cubic-bezier(0.16, 1, 0.3, 1); 310 } 311 312 @media (max-width: 640px) { 313 .usage-banner { 314 width: calc(100vw - 24px); 315 } 316 317 .banner-content { 318 padding: 16px; 319 gap: 12px; 320 } 321 322 .banner-message { 323 font-size: 13px; 324 line-height: 1.45; 325 } 326 327 .btn-primary { 328 padding: 8px 14px; 329 font-size: 12px; 330 } 331 332 .close-btn { 333 width: 22px; 334 height: 22px; 335 font-size: 12px; 336 } 337 } 338 `}),(0,w.jsx)("div",{className:"usage-banner",children:(0,w.jsxs)("div",{className:"banner-content",children:[(0,w.jsx)("div",{className:"banner-message",children:t}),r?.primary&&(0,w.jsx)("button",{className:"btn-primary",onClick:r.primary.onClick,children:r.primary.label}),n&&(0,w.jsx)("button",{className:"close-btn",onClick:n,title:"Close",children:"Ã"})]})})]})}let du=e=>{switch(e.code){case ax.MISSING_PUBLIC_API_KEY_ERROR:return{primary:{label:"Show me how",onClick:()=>window.open("https://docs.copilotkit.ai/premium#how-do-i-get-access-to-premium-features","_blank","noopener,noreferrer")}};case ax.UPGRADE_REQUIRED_ERROR:return{primary:{label:"Upgrade",onClick:()=>window.open("https://cloud.copilotkit.ai","_blank","noopener,noreferrer")}};default:return}};var dd=class{constructor(){this.activeKey=null,this.intervalId=null,this.instanceCount=0,this.lastResponse=null}async start(e,t){if(this.instanceCount++,this.activeKey===e)return;this.intervalId&&clearInterval(this.intervalId);let n=async()=>{try{let n=await fetch(`${iA}/ciu`,{method:"GET",headers:{[iI]:e}}).then(e=>e.json());return this.lastResponse=n,t?.(n),n}catch(e){return null}},r=await n();return this.intervalId=setInterval(n,3e5),this.activeKey=e,r}getLastResponse(){return this.lastResponse}stop(){this.instanceCount--,0===this.instanceCount&&this.intervalId&&(clearInterval(this.intervalId),this.intervalId=null,this.activeKey=null,this.lastResponse=null)}};let dp=({className:e,style:t})=>(0,w.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:`lucide lucide-circle-alert ${e||""}`,style:t,children:[(0,w.jsx)("circle",{cx:"12",cy:"12",r:"10"}),(0,w.jsx)("line",{x1:"12",x2:"12",y1:"8",y2:"12"}),(0,w.jsx)("line",{x1:"12",x2:"12.01",y1:"16",y2:"16"})]});function df({errors:e}){return(0,w.jsxs)("div",{style:{fontSize:"13px",maxWidth:"600px"},children:[e.map((e,t)=>{let n=("extensions"in e?e.extensions?.originalError:{})?.message??e.message,r="extensions"in e?e.extensions?.code:null;return(0,w.jsxs)("div",{style:{marginTop:10*(0!==t),marginBottom:14},children:[(0,w.jsx)(dp,{style:{marginBottom:4}}),r&&(0,w.jsxs)("div",{style:{fontWeight:"600",marginBottom:4},children:["Copilot Runtime Error:"," ",(0,w.jsx)("span",{style:{fontFamily:"monospace",fontWeight:"normal"},children:r})]}),(0,w.jsx)(cN,{children:n})]},t)}
338),(0,w.jsx)("div",{style:{fontSize:"11px",opacity:.75},children:"NOTE: This error only displays during local development."})]})}function dh(e,t){let n=function(){let{addToast:e}=dn();return(0,v.useCallback)(t=>{e({type:"error",id:t.map(e=>btoa(("extensions"in e&&e.extensions?.originalError?.message||e.message)+(e.stack||"")).slice(0,32)).join("|"),message:(0,w.jsx)(df,{errors:t})})},[e])}();return(0,v.useCallback)(async(...t)=>{try{return await e(...t)}catch(e){throw console.error("Error in async callback:",e),n([e]),e}},t)}let dg=new dd;var dm=class extends v.default.Component{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidMount(){this.props.publicApiKey&&dg.start(this.props.publicApiKey,e=>{this.setState(t=>e?.severity!==t.status?.severity?{status:e??void 0}:null)})}componentWillUnmount(){dg.stop()}componentDidCatch(e,t){console.error("CopilotKit Error:",e,t)}render(){if(this.state.hasError){if(this.state.error instanceof aC)return(0,w.jsxs)(w.Fragment,{children:[this.props.children,this.props.showUsageBanner&&(0,w.jsx)(dc,{severity:this.state.status?.severity??this.state.error.severity,message:this.state.status?.message??this.state.error.message,actions:du(this.state.error)})]});throw this.state.error}return this.props.children}};let dy=(0,v.createContext)(void 0);function dk({children:e}){let[t,n]=(0,v.useState)({}),r=(0,v.useCallback)((e,t)=>{n(n=>({...n,[e]:t}))},[]),i=(0,v.useCallback)(e=>{n(t=>{let n={...t};return delete n[e],n})},[]),o=(0,v.useRef)({});return(0,w.jsx)(dy.Provider,{value:{coAgentStateRenders:t,setCoAgentStateRender:r,removeCoAgentStateRender:i,claimsRef:o},children:e})}let dv=(0,v.createContext)(void 0);function db({children:e,threadId:t}){let[n,r]=(0,v.useState)(()=>iF());return(0,w.jsx)(dv.Provider,{value:{threadId:t??n,setThreadId:r},children:e})}let dx=((m={}).InProgress="inProgress",m.Complete="complete",m),dw=((y={}).Create="create",y.Override="override",y.Existing="existing",y.Block="block",y);function dE(e){if(!e)return{};let{messages:t,tools:n,copilotkit:r,...i}=e;return i}function dS(e,t){if(e&&!t||!e&&t)return!1;let{messages:n,tools:r,copilotkit:i,...o}=e,{messages:a,tools:s,copilotkit:l,...c}=t;return JSON.stringify(o)===JSON.stringify(c)}function dC(e){return!!e&&e.startsWith("coagent-state-render-")}function dT(e){return"coagent-state-render"===e}function dN(e){return e&&"object"==typeof e?{snapshot:"snapshot"in e?e.snapshot:e,runId:"runId"in e?e.runId:void 0}:{snapshot:e,runId:void 0}}let dA="__lastSnapshotsByStateRenderIdAndRun",d_="__lastSnapshotsByMessageId";function dI(e){return function(e,t){let{stateSnapshot:n,message:r}=t,{coAgentStateRenders:i,claimsRef:o}=function(){let e=(0,v.useContext)(dy);if(!e)throw Error("useCoAgentStateRenders must be used within CoAgentStateRendersProvider");return e}(),{agent:a}=nj({agentId:e}),[s,l]=(0,v.useState)(void 0),[,c]=(0,v.useState)(0);(0,v.useEffect)(()=>{if(!a)return;let{unsubscribe:e}=a.subscribe({onStateChanged:()=>{c(e=>e+1)},onStepStartedEvent:({event:e})=>{e.stepName!==s&&l(e.stepName)},onStepFinishedEvent:({event:e})=>{e.stepName===s&&l(void 0)}});return()=>{e()}},[e,s]);let u=(0,v.useCallback)(t=>Object.entries(i).find(([n,r])=>{if(o.current[t])return n===o.current[t].stateRenderId;let i=r.name===e,a=!r.nodeName||r.nodeName===s;return i&&a}),[i,s,e]),d=(0,v.useMemo)(()=>u(r.id),[u,r.id]),p=d?.[0],f=d?.[1],{canRender:h}=function({agentId:e,stateRenderId:t,message:n,messageIndex:r,stateSnapshot:i,agentState:o,agentMessages:a,claimsRef:s}){let l,c=s.current,u=n.runId,{runId:d}=dN(c[d_]?.[n.id]),p=function({existingClaimRunId:e,cachedMessageRunId:t,runId:n}){return e||t||n||"pending"}({existingClaimRunId:s.current[n.id]?.runId,cachedMessageRunId:d,runId:u});if((0,v.useEffect)(()=>()=>{let e=s.current[n.id];if(e?.stateSnapshot&&Object.keys(e.stateSnapshot).length>0){let t={...c[dA]??{}};t[`${e.stateRenderId}::${e.runId??"pending"}`]=e.stateSnapshot,t[`${e.stateRenderId}::latest`]=e.stateSnapshot,c[dA]=t;let r={...c[d_]??{}};r[n.id]={snapshot:e.stateSnapshot,runId:e.runId??p},c[d_]=r}delete s.current[n.id]},[s,p,n.id]),!t)return{canRender:!1};let f={byStateRenderAndRun:(l=s.current)[dA]??{},byMessageId:l[d_]??{}},h=s.current[n.id],{snapshot:g,hasSnapshotKeys:m,allowEmptySnapshot:y,snapshotForClaim:k}=function({messageId:e,messageName:t,allowLiveState:n,skipLatestCache:r,stateRenderId:i,effectiveRunId:o,stateSnapshotProp:a,agentState:s,agentMessages:l,existingClaim:c,caches:u}){let d,p=l?[...l].reverse().find(e=>"assistant"===e.role)?.id:void 0,f=void 0!==i?u.byStateRenderAndRun[`${i}::latest`]:void 0,h=l?l.findIndex(t=>t.id===e):-1,g=h>=0&&l?l[h]?.role:void 0;if(h>0&&l){for(let e=h-1;e>=0;e-=1)if(l[e]?.role==="user"){d=l[e]?.id;break}}let m=void 0===a&&void 0!==f&&void 0!==s&&dS(f,s),y=(!!n||!p||e===p)&&!m,k=a?iH(a,a):y?s:void 0,v=!!(k&&Object.keys(k).length>0),b=void 0!==k&&!v&&(void 0!==a||y),x=dN(u.byMessageId[e]).snapshot,w=void 0!==i?`${i}::${o}`:void 0,E=x??u.byMessageId[e];void 0===E&&w&&void 0!==u.byStateRenderAndRun[w]&&(E=u.byStateRenderAndRun[w]),void 0===E&&i&&d&&void 0!==u.byStateRenderAndRun[`${i}::pending:${d}`]&&(E=u.byStateRenderAndRun[`${i}::pending:${d}`]),void 0===E&&!r&&i&&"assistant"!==g&&(void 0!==a||s&&Object.keys(s).length>0)&&(E=u.byStateRenderAndRun[`${i}::latest`]);let S=c?.locked?c.stateSnapshot??E:v?k:c?.stateSnapshot??E;return{snapshot:k,hasSnapshotKeys:v,cachedSnapshot:E,allowEmptySnapshot:b,snapshotForClaim:S}}({messageId:n.id,messageName:n.name,allowLiveState:dT(n.name)||dC(n.id),skipLatestCache:dT(n.name)||dC(n.id),stateRenderId:t,effectiveRunId:p,stateSnapshotProp:i,agentState:o,agentMessages:a,existingClaim:h,c
338aches:f}),b=function({claims:e,context:t,stateSnapshot:n}){let{messageId:r,stateRenderId:i,runId:o,messageIndex:a}=t,s=e[r];if(s){let e=s.stateRenderId===i,t=e&&o&&(!s.runId||"pending"===s.runId);return{canRender:e,action:e?dw.Existing:dw.Block,updateRunId:t?o:void 0}}let l=o??"pending",c=Object.entries(e).find(([,e])=>e.stateRenderId===i&&(e.runId??"pending")===l&&i$(dE(e.stateSnapshot))===i$(dE(n))),u=c?.[1],d=c?.[0];return u?void 0!==a&&void 0!==u.messageIndex&&a>u.messageIndex?{canRender:!0,action:dw.Override,nextClaim:{stateRenderId:i,runId:o,messageIndex:a},lockOthers:o===u.runId||dC(d)}:o&&u.runId&&o!==u.runId?{canRender:!0,action:dw.Override,nextClaim:{stateRenderId:i,runId:o,messageIndex:a},lockOthers:dC(d)}:dC(d)?{canRender:!0,action:dw.Override,nextClaim:{stateRenderId:i,runId:o,messageIndex:a},lockOthers:!0}:n&&u.stateSnapshot&&!dS(u.stateSnapshot,n)?{canRender:!0,action:dw.Override,nextClaim:{stateRenderId:i,runId:o}}:{canRender:!1,action:dw.Block}:o?{canRender:!0,action:dw.Create,nextClaim:{stateRenderId:i,runId:o,messageIndex:a}}:{canRender:!1,action:dw.Block}}({claims:s.current,context:{agentId:e,messageId:n.id,stateRenderId:t,runId:p,messageIndex:r},stateSnapshot:k});if(b.action===dw.Block)return{canRender:!1};if(b.updateRunId&&s.current[n.id]&&(s.current[n.id].runId=b.updateRunId),b.nextClaim&&(s.current[n.id]=b.nextClaim),b.lockOthers&&Object.entries(s.current).forEach(([e,r])=>{e!==n.id&&r.stateRenderId===t&&(r.locked=!0)}),h&&!h.locked&&a?.length){let e=a.findIndex(e=>e.id===n.id);e>=0&&e<a.length-1&&(h.locked=!0)}let x=s.current[n.id].stateSnapshot,w=i&&void 0!==x&&!dS(x,g);if(g&&(i||m||y)&&(!s.current[n.id].locked||w)){if(!s.current[n.id].locked||w){s.current[n.id].stateSnapshot=g;let e={...c[dA]??{}};e[`${t}::${p}`]=g,e[`${t}::latest`]=g,c[dA]=e;let r={...c[d_]??{}};r[n.id]={snapshot:g,runId:p},c[d_]=r,i&&(s.current[n.id].locked=!0)}}else if(k&&!s.current[n.id].stateSnapshot){s.current[n.id].stateSnapshot=k;let e={...c[dA]??{}};e[`${t}::${p}`]=k,e[`${t}::latest`]=k,c[dA]=e;let r={...c[d_]??{}};r[n.id]={snapshot:k,runId:p},c[d_]=r}return{canRender:!0}}({agentId:e,stateRenderId:p,message:{...r,runId:t.runId??r.runId},messageIndex:t.messageIndex,stateSnapshot:n,agentState:a?.state,agentMessages:a?.messages,claimsRef:o});return(0,v.useMemo)(()=>{if(!f||!p||!h)return null;if(f.handler&&f.handler({state:n?iH(n,n):a?.state??{},nodeName:s??""}),f.render){let e=a?.isRunning?dx.InProgress:dx.Complete;return"string"==typeof f.render?f.render:f.render({status:e,state:o.current[r.id].stateSnapshot??{},nodeName:s??""})}},[f,p,a?.state,a?.isRunning,s,r.id,n,h])}(e.agentId,e)}function dR(){let e,t,{copilotkit:n}=nA(),r=T()?.agentId,{setBannerError:i}=dn(),{agent:o}=nj({agentId:r});return e=(0,v.useRef)([]),t=(0,v.useCallback)(t=>({onCustomEvent:({event:t})=>{"PredictState"===t.name&&(e.current=t.value)},onToolCallArgsEvent:({partialToolCallArgs:n,toolCallName:r})=>{e.current.forEach(e=>{if(e?.tool!==r)return;let i="string"==typeof n?iH(n,n):n;t.setState({[e.state_key]:i[e.state_key]})})}}),[]),(0,v.useEffect)(()=>{if(!o)return;let e=t(o),{unsubscribe:n}=o.subscribe(e);return()=>{n()}},[o,t]),(0,v.useEffect)(()=>{let e=n.subscribe({onError:({error:e})=>{i(new a_({error:e,message:e.message,url:"undefined"!=typeof window?window.location.href:""}))}});return()=>{e.unsubscribe()}},[n?.subscribe]),null}function dM({children:e,...t}){let n=di(t.showDevConsole),r=di(t.enableInspector),i=t.publicApiKey||t.publicLicenseKey,o=(0,v.useMemo)(()=>[{render:dI}],[]);return(0,w.jsx)(dr,{enabled:n,children:(0,w.jsx)(dm,{publicApiKey:i,showUsageBanner:n,children:(0,w.jsx)(db,{threadId:t.threadId,children:(0,w.jsx)(nN,{...t,showDevConsole:r,renderCustomMessages:o,useSingleEndpoint:t.useSingleEndpoint??!0,children:(0,w.jsx)(dj,{...t,children:e})})})})})}function dO(){let{copilotkit:e}=nA(),{onError:t,copilotApiConfig:n}=u0();return(0,v.useEffect)(()=>{if(!e)return;let r=e.subscribe({onError:async e=>{let r={type:"error",timestamp:Date.now(),context:{source:"agent",request:{operation:e.code||"unknown",url:n?.chatApiEndpoint,startTime:Date.now()},technical:{environment:"browser",userAgent:"undefined"!=typeof navigator?navigator.userAgent:void 0,stackTrace:e.error.stack},...e.context},error:e.error};try{await t(r)}catch(e){console.error("Error in onError handler:",e)}}});return()=>{r.unsubscribe()}},[e,t,n]),null}function dj(e){let{children:t,...n}=e;var r=e;let i=Object.keys(r).filter(e=>e.endsWith("_c")),o=r.publicApiKey||r.publicLicenseKey;if(!r.runtimeUrl&&!o)throw new aI("Missing required prop: 'runtimeUrl' or 'publicApiKey' or 'publicLicenseKey'");if(i.length>0&&!o)throw new aR(`Missing required prop: 'publicApiKey' or 'publicLicenseKey' to use cloud features: ${i.map(dD).join(", ")}`);let a=n.publicLicenseKey||n.publicApiKey,s=n.runtimeUrl||i_,[l,c]=(0,v.useState)({}),[u,d]=(0,v.useState)(new Map),p=(0,v.useRef)({actions:{},coAgentStateRenders:{}}),{addElement:f,removeElement:h,printTree:g,getAllElements:m}=(()=>{let[e,t]=(0,v.useReducer)(u6,[]),n=(0,v.useCallback)((e,n,r)=>{let i="ck-"+iF();return t({type:"ADD_NODE",value:e,parentId:r,id:i,categories:n}),i},[]),r=(0,v.useCallback)(e=>{t({type:"REMOVE_NODE",id:e})},[]),i=(0,v.useCallback)(()=>e,[e]);return{tree:e,addElement:n,printTree:(0,v.useCallback)(t=>{let n=new Set(t),r="";return e.forEach((e,t)=>{(function(e,t){let[n,r]=e.size<=t.size?[e,t]:[t,e];for(let e of n)if(r.has(e))return!0;return!1})(n,e.categories)&&(0!==t&&(r+="\n"),r+=u3(e,`${u4(t,0)}. `))}),r},[e]),removeElement:r,getAllElements:i}})(),[y,k]=(0,v.useState)(!1),[b,x]=(0,v.useState)(""),[E,S]=(0,v.useState)({}),[T,N]=(0,v.useState)({}),[A,_]=(0,v.useState)([]),{addElement:I,removeElement:R,allElements:M}=(()=>{let[e,t]=(0,v.useReducer)(u8,new Map);return{addElement:(0,v.useCallback)((e,n)=>{let r="ck-"+iF();return t({type:"ADD_ELEMENT",value:e,id:r,categories:n}),r},[]),removeElement:(0,v.useCallback)(e=>{t({type:"REMOVE_ELEMENT",id:e})},[]),allElements:(0,v.useCallback)(t=>{let n=new Set(t),r=[];
338return e.forEach(e=>{(function(e,t){let[n,r]=e.size<=t.size?[e,t]:[t,e];for(let e of n)if(r.has(e))return!0;return!1})(n,e.categories)&&r.push(e.value)}),r},[e])}})(),O=(0,v.useCallback)((e,t)=>{c(n=>({...n,[e]:t}))},[]),j=(0,v.useCallback)(e=>{c(t=>{let n={...t};return delete n[e],n})},[]),z=(0,v.useCallback)((e,t)=>`${e.map(e=>`${e.name} (${e.sourceApplication}): 339${e.getContents()}`).join("\n\n")} 340 341${g(t)}`,[g]),D=(0,v.useCallback)((e,t,n=dz)=>f(e,n,t),[f]),P=(0,v.useCallback)(e=>{h(e)},[h]),F=(0,v.useCallback)(()=>m(),[m]),L=(0,v.useCallback)(e=>{var t;return t=Object.values(e||l),async({name:e,args:n})=>{let r,i={};for(let e of t)i[e.name]=e;let o=i[e];return o&&(await new Promise((e,t)=>{(0,X.flushSync)(async()=>{try{r=await o.handler?.(n),e()}catch(e){t(e)}})}),await new Promise(e=>setTimeout(e,20))),r}},[l]),U=(0,v.useCallback)(e=>M(e),[M]),B=(0,v.useCallback)((e,t=dz)=>I(e,t),[I]),$=(0,v.useCallback)(e=>{R(e)},[R]),H=(0,v.useMemo)(()=>{let e;return a&&(e={guardrails:{input:{restrictToTopic:{enabled:!!n.guardrails_c,validTopics:n.guardrails_c?.validTopics||[],invalidTopics:n.guardrails_c?.invalidTopics||[]}}}}),{publicApiKey:a,...e?{cloud:e}:{},chatApiEndpoint:s,headers:n.headers||{},properties:n.properties||{},transcribeAudioUrl:n.transcribeAudioUrl,textToSpeechUrl:n.textToSpeechUrl,credentials:n.credentials}},[a,n.headers,n.properties,n.transcribeAudioUrl,n.textToSpeechUrl,n.credentials,n.cloudRestrictToTopic,n.guardrails_c]);(0,v.useMemo)(()=>{let e=Object.values(E||{}).reduce((e,t)=>"authenticated"===t.status&&t.authHeaders?{...e,...Object.entries(t.authHeaders).reduce((e,[t,n])=>({...e,[t.startsWith("X-Custom-")?t:`X-Custom-${t}`]:n}),{})}:e,{});return{...H.headers||{},...H.publicApiKey?{[iI]:H.publicApiKey}:{},...e}},[H.headers,H.publicApiKey,E]);let[K,G]=(0,v.useState)({}),V=(0,v.useCallback)(e=>{G(t=>({...t,...e}))},[]),W=(0,v.useCallback)(e=>{G(t=>{let{[e]:n,...r}=t;return r})},[]),q=(0,v.useRef)(n.onError);(0,v.useEffect)(()=>{q.current=n.onError},[n.onError]);let J=(0,v.useRef)({});(0,v.useEffect)(()=>{J.current=K},[K]);let Y=(0,v.useCallback)(async e=>{if(H.publicApiKey&&q.current)try{await q.current(e)}catch(e){console.error("Error in public onError handler:",e)}let t=Object.values(J.current);await Promise.all(t.map(t=>Promise.resolve(t(e)).catch(e=>console.error("Error in internal error handler:",e))))},[H.publicApiKey]),[Q,Z]=(0,v.useState)({}),ee=(0,v.useCallback)((e,t)=>{Z(n=>({...n,[e]:t}))},[Z]),et=(0,v.useCallback)(e=>{Z(t=>{let{[e]:n,...r}=t;return r})},[Z]),[en,er]=(0,v.useState)([]),[ei,eo]=(0,v.useState)({}),ea=(0,v.useRef)({}),es=(0,v.useCallback)(e=>{let t="function"==typeof e?e(ea.current):e;ea.current=t,eo(e=>t)},[]),el=null;n.agent&&(el={agentName:n.agent});let[ec,eu]=(0,v.useState)(el);(0,v.useEffect)(()=>{n.agent?eu({agentName:n.agent}):eu(null)},[n.agent]);let{threadId:ed,setThreadId:ep}=function(){let e=(0,v.useContext)(dv);if(!e)throw Error("useThreads must be used within ThreadsProvider");return e}(),ef=(0,v.useCallback)(e=>{if(n.threadId)throw Error("Cannot call setThreadId() when threadId is provided via props.");ep(e)},[n.threadId]),[eh,eg]=(0,v.useState)(null),em=(0,v.useRef)(null),ey=di(n.showDevConsole),[ek,ev]=(0,v.useState)({}),eb=(0,v.useCallback)(e=>{ev(t=>null!=e&&e.id?{...t,[e.id]:{...t[e.id]??{},...e}}:t)},[]),ex=(0,v.useCallback)(e=>{ev(t=>{let{[e]:n,...r}=t;return r})},[]),[ew,eE]=(0,v.useState)({}),eS=(0,v.useCallback)(e=>{eE(t=>{let n=t[e.threadId]||[];return{...t,[e.threadId]:[...n,e]}})},[]),eC=(0,v.useCallback)((e,t,n)=>{eE(r=>{let i=r[e]||[];return{...r,[e]:i.map(e=>e.eventId===t?{...e,event:{...e.event,response:n}}:e)}})},[]),eT=(0,v.useMemo)(()=>t,[t]),[eN,eA]=(0,v.useState)(null),e_=(0,v.useMemo)(()=>n.agent??null,[n.agent]),eI=(0,v.useMemo)(()=>n.forwardedParameters??{},[n.forwardedParameters]),eR=(0,v.useCallback)(e=>{N(t=>{let n="function"==typeof e?e(t):e;return Object.keys(n).length===Object.keys(t).length&&Object.entries(n).every(([e,n])=>t[e]===n)?t:n})},[N]),eM=(0,v.useCallback)(e=>{S(t=>{let n="function"==typeof e?e(t):e;return Object.keys(n).length===Object.keys(t).length&&Object.entries(n).every(([e,n])=>t[e]===n)?t:n})},[S]),eO=(0,v.useCallback)(e=>{let t=e.action.name||iF();return d(n=>{let r=new Map(n);return r.set(t,e),r}),t},[]),ej=(0,v.useCallback)(e=>{d(t=>{let n=new Map(t);return n.delete(e),n})},[]),ez=(0,v.useMemo)(()=>()=>(0,w.jsx)(w.Fragment,{children:Array.from(u.entries()).map(([e,t])=>{let n=t.component;return(0,w.jsx)(n,{action:t.action},e)})}),[u]);return(0,w.jsx)(C,{agentId:n.agent??"default",threadId:ed,children:(0,w.jsxs)(uZ.Provider,{value:{actions:l,chatComponentsCache:p,getFunctionCallHandler:L,setAction:O,removeAction:j,setRegisteredActions:eO,removeRegisteredAction:ej,getContextString:z,addContext:D,removeContext:P,getAllContext:F,getDocumentsContext:U,addDocumentContext:B,removeDocumentContext:$,copilotApiConfig:H,isLoading:y,setIsLoading:k,chatSuggestionConfiguration:Q,addChatSuggestionConfiguration:ee,removeChatSuggestionConfiguration:et,chatInstructions:b,setChatInstructions:x,additionalInstructions:A,setAdditionalInstructions:_,showDevConsole:ey,coagentStates:ei,setCoagentStates:eo,coagentStatesRef:ea,setCoagentStatesWithRef:es,agentSession:ec,setAgentSession:eu,forwardedParameters:eI,agentLock:e_,threadId:ed,setThreadId:ef,runId:eh,setRunId:eg,chatAbortControllerRef:em,availableAgents:en,authConfig_c:n.authConfig_c,authStates_c:E,setAuthStates_c:eM,extensions:T,setExtensions:eR,interruptActions:ek,setInterruptAction:eb,removeInterruptAction:ex,interruptEventQueue:ew,addInterruptEvent:eS,resolveInterruptEvent:eC,bannerError:eN,setBannerError:eA,onError:Y,internalErrorHandlers:K,setInternalErrorHandler:V,removeInternalErrorHandler:W},children:[(0,w.jsx)(dR,{}),(0,w.jsx)(dO,{}),(0,w.jsxs)(dk,{children:[(0,w.jsx)(ds,{children:(0,w.jsxs)(dl,{children:[eT,(0,w.jsx)(ez,{})]})}),eN&&ey&&(0,w.jsx)(dc,{severity:eN.severity,message:eN.message,onClose:()=>eA(null),actions:du(eN)})]})]})})}let dz=["global"];function dD(e){return e.replace(/_c$/,"").split("_").map(e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()).join(" ")}function dP({suggestions:e,onInProgress:t,onSubmitMessage:n,onStopGeneration:r,onReloadMessages:i}={}){let o,{copilotkit:a}=nA(),{threadId:s,agentSession:l}=u0(),c=T(),[u,d]=(0,v.useState)(!1),p=c?.agentId??"default",{agent:f}=nj({agentId:p});(0,v.useEffect)(()=>{let e=async e=>{d(!1);try{await a.connectAgent({agent:e}),d(!0)}catch(e){e instanceof uh||console.error("CopilotChat: connectAgent failed",e)}};return f&&c?.threadId&&f.threadId!==c.threadId&&(f.threadId=c.threadId,e(f)),()=>{}},[c?.threadId,f,a,p]),(0,v.useEffect)(()=>{t?.(!!f?.isRunning)},[f?.isRunning,t]);let[h,g]=(0,v.useState)(null);(0,v.useEffect)(()=>{g(a.interruptElement);let e=a.subscribe({onInterruptElementChanged:({interruptElement:e})=>{g(e)}});return()=>e.unsubscribe()},[a]);let m=dF((0,v.useCallback)(e=>{let t=(f?.messages??[]).filter(t=>t.id!==e);f?.setMessages(t)},[f?.setMessages,f?.messages])),y=(0,v.useCallback)(e=>m.current(e),[m]),k=nz({agentId:p}),b=dh(async e=>{if(!f)return;let t=f?.messages??[];if(f.isRunning||0===t.length)return;let n=t.findIndex(t=>t.id===e);if(-1===n)return void console.warn(`Message with id ${e} not found`);let r=t[n].role;if("assistant"!==r)return void console.warn(`Regenerate cannot be performed on ${r} role`);let i=[t[0]];if(t.length>2&&0!==n){let e=t.slice(0,n).reverse().find(e=>"user"===e.role);if(e){let n=t.findIndex(t=>t.id===e.id);i=t.slice(0,n+1)}else i=[t[0]]}else t.length>2&&0===n&&(i=[t[0],t[1]]);if(f?.setMessages(i),f)try{await a.runAgent({agent:f})}catch(e){console.error("CopilotChat: runAgent failed during reload",e)}},[f?.messages.length,f?.isRunning,f?.setMessages,a?.runAgent]),x=dh(async(e,t)=>{if(!f)return;let r=t?.followUp??!0;if(t?.clearSuggestions&&a.clearSuggestions(p),n){let t="string"==typeof e.content?e.content:e.content&&"text"in e.content?e.content.text:e.content&&"filename"in e.content?e.content.filename:"";try{await n(t)}catch(e){console.error("Error in onSubmitMessage:",e)}}if(f?.addMessage(e),r)try{await a.runAgent({agent:f})}catch(e){console.error("CopilotChat: runAgent failed",e)}},[f,a,p,n]),w=dh(async(e,t)=>x(c2([e])[0],t),[x]),E=(0,v.useCallback)(e=>e.every(e=>e instanceof cJ)?f?.setMessages?.(c2(e)):f?.setMessages?.(e),[f?.setMessages,f]),S=dF(b),C=dh(async e=>(i?.({messageId:e,currentAgentName:f?.agentId,messages:f?.messages??[]}),await S.current(e)),[S,f,i]),N=(0,v.useCallback)(()=>(r?.({currentAgentName:f?.agentId,messages:f?.messages??[]}),f?.abortRun?.()),[r,f]),A=dF(()=>{f?.setMessages([]),f?.setState(null)}),_=(0,v.useCallback)(()=>A.current(),[A]),I=(o=nI(),(0,v.useCallback)((e,t)=>{if(!e?.toolCalls?.length)return null;let n=e.toolCalls[0];if(!n)return null;let r=t?.find(e=>"tool"===e.role&&e.toolCallId===n.id);return()=>o({toolCall:n,toolMessage:r})},[o])),R=nR(),M=function({copilotkit:e,agent:t,agentId:n,threadId:r}){return(0,v.useMemo)(()=>e&&t?({message:i,position:o})=>{let a=r??t.threadId??"default",s=i.runId;return(0,v.createElement)(dI,{message:i,position:o,runId:s||e.getRunIdForMessage(n,a,i.id)||`pending:${i.id}`,messageIndex:Math.max(t.messages.findIndex(e=>e.id===i.id),0),messageIndexInRun:0,numberOfMessagesInRun:1,agentId:n,stateSnapshot:i.state})}:null,[t,n,e,r])}({copilotkit:a,agent:f,agentId:p,threadId:c?.threadId??s}),O=f?.messages??[],j=(0,v.useMemo)(()=>{let e=O.map(e=>{if("assistant"!==e.role)return e;let t=I(e,O);if(t){let n=t();if(n)return{...e,generativeUI:()=>n}}let n=M||R?()=>{if(M)return M({message:e,position:"before"});try{return R?.({message:e,position:"before"})??null}catch(e){return console.warn("[CopilotKit] renderCustomMessages failed, falling back to legacy renderer",e),null}}:null;return n?{...e,generativeUI:n,generativeUIPosition:"before"}:e}),t=e.some(e=>"assistant"===e.role),n=!!(R&&a?.getAgent?.(p)),r=M||(n?R:null),i=!!f?.isRunning||!!(f?.state&&Object.keys(f.state).length),o=s??f?.threadId??"default",l=-1;for(let t=e.length-1;t>=0;t-=1)if("user"===e[t].role){l=t;break}let c=l>=0?e[l].id:void 0,u=c?a.getRunIdForMessage(p,o,c)||`pending:${c}`:void 0,d=l>=0?e.slice(l+1).some(e=>"assistant"===e.role):t;if(r&&i&&!d){let t={id:u?`coagent-state-render-${p}-${u}`:`coagent-state-render-${p}`,role:"assistant",content:"",name:"coagent-state-render",runId:u};e=[...e,{...t,generativeUIPosition:"before",generativeUI:()=>r({message:t,position:"before"})}]}return e},[f?.messages,I,O,R,M,p,a,f?.isRunning,f?.state]),z=(0,v.useMemo)(()=>Array.isArray(e)?{suggestions:e.map(e=>({...e,isLoading:!1})),isLoading:!1}:k,[e,k]);return{messages:j,sendMessage:x,appendMessage:w,setMessages:E,reloadMessages:C,stopGeneration:N,reset:_,deleteMessage:y,isAvailable:u,isLoading:!!f?.isRunning,suggestions:z.suggestions,setSuggestions:e=>a.addSuggestionsConfig({suggestions:e}),generateSuggestions:async()=>a.reloadSuggestions(p),resetSuggestions:()=>a.clearSuggestions(p),isLoadingSuggestions:z.isLoading,interrupt:h,agent:f,threadId:s}}function dF(e){let t=(0,v.useRef)(e);return(0,v.useEffect)(()=>{t.current=e},[e]),t}function dL(e,t=[]){let n=T()?.agentId??"default",r=("enabled"===e.available?"always":e.available)??"before-first-message";
341!function(e,t){let{copilotkit:n}=nA(),r=T(),i=t??[],o=(0,v.useMemo)(()=>r?.agentId??b.DEFAULT_AGENT_ID,[r?.agentId]),a=(0,v.useMemo)(()=>e?e.consumerAgentId:void 0,[e]),s=(0,v.useRef)({serialized:null,config:null}),{normalizedConfig:l,serializedConfig:c}=(0,v.useMemo)(()=>{let t;if(!e||"disabled"===e.available)return s.current={serialized:null,config:null},{normalizedConfig:null,serializedConfig:null};if("instructions"in e)t={...e};else{let n=e.suggestions.map(e=>({...e,isLoading:e.isLoading??!1}));t={...e,suggestions:n}}let n=JSON.stringify(t),r=s.current;return r.serialized===n&&r.config?{normalizedConfig:r.config,serializedConfig:n}:(s.current={serialized:n,config:t},{normalizedConfig:t,serializedConfig:n})},[e,o,...i]),u=(0,v.useRef)(null);u.current=l;let d=(0,v.useRef)(null),p=(0,v.useMemo)(()=>{if(!l)return o;let e=l.consumerAgentId;return e&&"*"!==e?e:o},[l,o]),f=void 0===a||"*"===a,h=(0,v.useCallback)(()=>{if(l){if(f){for(let e of Object.values(n.agents??{})){let t=e.agentId;t&&(e.isRunning||n.reloadSuggestions(t))}return}p&&n.reloadSuggestions(p)}},[n,f,l,p]);(0,v.useEffect)(()=>{if(!c||!u.current)return;let e=n.addSuggestionsConfig(u.current);return h(),()=>{n.removeSuggestionsConfig(e)}},[n,c,h]),(0,v.useEffect)(()=>{if(!l){d.current=null;return}c&&d.current===c||(c&&(d.current=c),h())},[l,h,c]),(0,v.useEffect)(()=>{l&&0!==i.length&&h()},[i.length,l,h,...i])}({...e,available:r,consumerAgentId:n},t)}e.s(["CopilotKit",()=>dM,"defaultCopilotContextCategories",()=>dz,"shouldShowDevConsole",()=>di,"useCopilotChatInternal",()=>dP,"useCopilotChatSuggestions",()=>dL,"useCopilotContext",()=>u0,"useCopilotMessagesContext",()=>de],563542)}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.