@microsoft/agents-copilotstudio-client 0.6.22 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@microsoft/agents-copilotstudio-client",
3
- "version": "0.6.22",
3
+ "version": "1.0.0",
4
4
  "homepage": "https://github.com/microsoft/Agents-for-js",
5
5
  "repository": {
6
6
  "type": "git",
@@ -27,7 +27,7 @@
27
27
  "build:browser": "esbuild --platform=browser --target=es2019 --format=esm --bundle --sourcemap --minify --outfile=dist/src/browser.mjs src/index.ts"
28
28
  },
29
29
  "dependencies": {
30
- "@microsoft/agents-activity": "0.6.22",
30
+ "@microsoft/agents-activity": "1.0.0",
31
31
  "axios": "^1.9.0",
32
32
  "rxjs": "7.8.2",
33
33
  "uuid": "^11.1.0"
@@ -3,7 +3,7 @@ var Ka=Object.create;var In=Object.defineProperty;var Ga=Object.getOwnPropertyDe
3
3
  `)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(e){return e instanceof this?e:new this(e)}static concat(e,...r){let n=new this(e);return r.forEach(o=>n.set(o)),n}static accessor(e){let n=(this[Ei]=this[Ei]={accessors:{}}).accessors,o=this.prototype;function i(s){let a=Wt(s);n[a]||(ru(o,s),n[a]=!0)}return p.isArray(e)?e.forEach(i):i(e),this}};at.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);p.reduceDescriptors(at.prototype,({value:t},e)=>{let r=e[0].toUpperCase()+e.slice(1);return{get:()=>t,set(n){this[r]=n}}});p.freezeMethods(at);var F=at;function Jt(t,e){let r=this||st,n=e||r,o=F.from(n.headers),i=n.data;return p.forEach(t,function(a){i=a.call(r,i,o.normalize(),e?e.status:void 0)}),o.normalize(),i}function Kt(t){return!!(t&&t.__CANCEL__)}function Pi(t,e,r){A.call(this,t==null?"canceled":t,A.ERR_CANCELED,e,r),this.name="CanceledError"}p.inherits(Pi,A,{__CANCEL__:!0});var de=Pi;function Gt(t,e,r){let n=r.config.validateStatus;!r.status||!n||n(r.status)?t(r):e(new A("Request failed with status code "+r.status,[A.ERR_BAD_REQUEST,A.ERR_BAD_RESPONSE][Math.floor(r.status/100)-4],r.config,r.request,r))}function Fn(t){let e=/^([-+\w]{1,25})(:?\/\/|:)/.exec(t);return e&&e[1]||""}function nu(t,e){t=t||10;let r=new Array(t),n=new Array(t),o=0,i=0,s;return e=e!==void 0?e:1e3,function(c){let u=Date.now(),d=n[i];s||(s=u),r[o]=c,n[o]=u;let m=i,b=0;for(;m!==o;)b+=r[m++],m=m%t;if(o=(o+1)%t,o===i&&(i=(i+1)%t),u-s<e)return;let w=d&&u-d;return w?Math.round(b*1e3/w):void 0}}var Ri=nu;function ou(t,e){let r=0,n=1e3/e,o,i,s=(u,d=Date.now())=>{r=d,o=null,i&&(clearTimeout(i),i=null),t.apply(null,u)};return[(...u)=>{let d=Date.now(),m=d-r;m>=n?s(u,d):(o=u,i||(i=setTimeout(()=>{i=null,s(o)},n-m)))},()=>o&&s(o)]}var ji=ou;var ct=(t,e,r=3)=>{let n=0,o=Ri(50,250);return ji(i=>{let s=i.loaded,a=i.lengthComputable?i.total:void 0,c=s-n,u=o(c),d=s<=a;n=s;let m={loaded:s,total:a,progress:a?s/a:void 0,bytes:c,rate:u||void 0,estimated:u&&a&&d?(a-s)/u:void 0,event:i,lengthComputable:a!=null,[e?"download":"upload"]:!0};t(m)},r)},zn=(t,e)=>{let r=t!=null;return[n=>e[0]({lengthComputable:r,total:t,loaded:n}),e[1]]},qn=t=>(...e)=>p.asap(()=>t(...e));var ki=L.hasStandardBrowserEnv?((t,e)=>r=>(r=new URL(r,L.origin),t.protocol===r.protocol&&t.host===r.host&&(e||t.port===r.port)))(new URL(L.origin),L.navigator&&/(msie|trident)/i.test(L.navigator.userAgent)):()=>!0;var Zi=L.hasStandardBrowserEnv?{write(t,e,r,n,o,i){let s=[t+"="+encodeURIComponent(e)];p.isNumber(r)&&s.push("expires="+new Date(r).toGMTString()),p.isString(n)&&s.push("path="+n),p.isString(o)&&s.push("domain="+o),i===!0&&s.push("secure"),document.cookie=s.join("; ")},read(t){let e=document.cookie.match(new RegExp("(^|;\\s*)("+t+")=([^;]*)"));return e?decodeURIComponent(e[3]):null},remove(t){this.write(t,"",Date.now()-864e5)}}:{write(){},read(){return null},remove(){}};function Vn(t){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(t)}function $n(t,e){return e?t.replace(/\/?\/$/,"")+"/"+e.replace(/^\/+/,""):t}function Yt(t,e,r){let n=!Vn(e);return t&&(n||r==!1)?$n(t,e):e}var Ui=t=>t instanceof F?{...t}:t;function ae(t,e){e=e||{};let r={};function n(u,d,m,b){return p.isPlainObject(u)&&p.isPlainObject(d)?p.merge.call({caseless:b},u,d):p.isPlainObject(d)?p.merge({},d):p.isArray(d)?d.slice():d}function o(u,d,m,b){if(p.isUndefined(d)){if(!p.isUndefined(u))return n(void 0,u,m,b)}else return n(u,d,m,b)}function i(u,d){if(!p.isUndefined(d))return n(void 0,d)}function s(u,d){if(p.isUndefined(d)){if(!p.isUndefined(u))return n(void 0,u)}else return n(void 0,d)}function a(u,d,m){if(m in e)return n(u,d);if(m in t)return n(void 0,u)}let c={url:i,method:i,data:i,baseURL:s,transformRequest:s,transformResponse:s,paramsSerializer:s,timeout:s,timeoutMessage:s,withCredentials:s,withXSRFToken:s,adapter:s,responseType:s,xsrfCookieName:s,xsrfHeaderName:s,onUploadProgress:s,onDownloadProgress:s,decompress:s,maxContentLength:s,maxBodyLength:s,beforeRedirect:s,transport:s,httpAgent:s,httpsAgent:s,cancelToken:s,socketPath:s,responseEncoding:s,validateStatus:a,headers:(u,d,m)=>o(Ui(u),Ui(d),m,!0)};return p.forEach(Object.keys(Object.assign({},t,e)),function(d){let m=c[d]||o,b=m(t[d],e[d],d);p.isUndefined(b)&&m!==a||(r[d]=b)}),r}var Pr=t=>{let e=ae({},t),{data:r,withXSRFToken:n,xsrfHeaderName:o,xsrfCookieName:i,headers:s,auth:a}=e;e.headers=s=F.from(s),e.url=Ht(Yt(e.baseURL,e.url,e.allowAbsoluteUrls),t.params,t.paramsSerializer),a&&s.set("Authorization","Basic "+btoa((a.username||"")+":"+(a.password?unescape(encodeURIComponent(a.password)):"")));let c;if(p.isFormData(r)){if(L.hasStandardBrowserEnv||L.hasStandardBrowserWebWorkerEnv)s.setContentType(void 0);else if((c=s.getContentType())!==!1){let[u,...d]=c?c.split(";").map(m=>m.trim()).filter(Boolean):[];s.setContentType([u||"multipart/form-data",...d].join("; "))}}if(L.hasStandardBrowserEnv&&(n&&p.isFunction(n)&&(n=n(e)),n||n!==!1&&ki(e.url))){let u=o&&i&&Zi.read(i);u&&s.set(o,u)}return e};var iu=typeof XMLHttpRequest!="undefined",Ni=iu&&function(t){return new Promise(function(r,n){let o=Pr(t),i=o.data,s=F.from(o.headers).normalize(),{responseType:a,onUploadProgress:c,onDownloadProgress:u}=o,d,m,b,w,h;function v(){w&&w(),h&&h(),o.cancelToken&&o.cancelToken.unsubscribe(d),o.signal&&o.signal.removeEventListener("abort",d)}let _=new XMLHttpRequest;_.open(o.method.toUpperCase(),o.url,!0),_.timeout=o.timeout;function S(){if(!_)return;let N=F.from("getAllResponseHeaders"in _&&_.getAllResponseHeaders()),D={data:!a||a==="text"||a==="json"?_.responseText:_.response,status:_.status,statusText:_.statusText,headers:N,config:t,request:_};Gt(function(ye){r(ye),v()},function(ye){n(ye),v()},D),_=null}"onloadend"in _?_.onloadend=S:_.onreadystatechange=function(){!_||_.readyState!==4||_.status===0&&!(_.responseURL&&_.responseURL.indexOf("file:")===0)||setTimeout(S)},_.onabort=function(){_&&(n(new A("Request aborted",A.ECONNABORTED,t,_)),_=null)},_.onerror=function(){n(new A("Network Error",A.ERR_NETWORK,t,_)),_=null},_.ontimeout=function(){let z=o.timeout?"timeout of "+o.timeout+"ms exceeded":"timeout exceeded",D=o.transitional||Ar;o.timeoutErrorMessage&&(z=o.timeoutErrorMessage),n(new A(z,D.clarifyTimeoutError?A.ETIMEDOUT:A.ECONNABORTED,t,_)),_=null},i===void 0&&s.setContentType(null),"setRequestHeader"in _&&p.forEach(s.toJSON(),function(z,D){_.setRequestHeader(D,z)}),p.isUndefined(o.withCredentials)||(_.withCredentials=!!o.withCredentials),a&&a!=="json"&&(_.responseType=o.responseType),u&&([b,h]=ct(u,!0),_.addEventListener("progress",b)),c&&_.upload&&([m,w]=ct(c),_.upload.addEventListener("progress",m),_.upload.addEventListener("loadend",w)),(o.cancelToken||o.signal)&&(d=N=>{_&&(n(!N||N.type?new de(null,t,_):N),_.abort(),_=null)},o.cancelToken&&o.cancelToken.subscribe(d),o.signal&&(o.signal.aborted?d():o.signal.addEventListener("abort",d)));let R=Fn(o.url);if(R&&L.protocols.indexOf(R)===-1){n(new A("Unsupported protocol "+R+":",A.ERR_BAD_REQUEST,t));return}_.send(i||null)})};var su=(t,e)=>{let{length:r}=t=t?t.filter(Boolean):[];if(e||r){let n=new AbortController,o,i=function(u){if(!o){o=!0,a();let d=u instanceof Error?u:this.reason;n.abort(d instanceof A?d:new de(d instanceof Error?d.message:d))}},s=e&&setTimeout(()=>{s=null,i(new A(`timeout ${e} of ms exceeded`,A.ETIMEDOUT))},e),a=()=>{t&&(s&&clearTimeout(s),s=null,t.forEach(u=>{u.unsubscribe?u.unsubscribe(i):u.removeEventListener("abort",i)}),t=null)};t.forEach(u=>u.addEventListener("abort",i));let{signal:c}=n;return c.unsubscribe=()=>p.asap(a),c}},Di=su;var au=function*(t,e){let r=t.byteLength;if(!e||r<e){yield t;return}let n=0,o;for(;n<r;)o=n+e,yield t.slice(n,o),n=o},cu=async function*(t,e){for await(let r of uu(t))yield*au(r,e)},uu=async function*(t){if(t[Symbol.asyncIterator]){yield*t;return}let e=t.getReader();try{for(;;){let{done:r,value:n}=await e.read();if(r)break;yield n}}finally{await e.cancel()}},Bn=(t,e,r,n)=>{let o=cu(t,e),i=0,s,a=c=>{s||(s=!0,n&&n(c))};return new ReadableStream({async pull(c){try{let{done:u,value:d}=await o.next();if(u){a(),c.close();return}let m=d.byteLength;if(r){let b=i+=m;r(b)}c.enqueue(new Uint8Array(d))}catch(u){throw a(u),u}},cancel(c){return a(c),o.return()}},{highWaterMark:2})};var jr=typeof fetch=="function"&&typeof Request=="function"&&typeof Response=="function",Mi=jr&&typeof ReadableStream=="function",du=jr&&(typeof TextEncoder=="function"?(t=>e=>t.encode(e))(new TextEncoder):async t=>new Uint8Array(await new Response(t).arrayBuffer())),Fi=(t,...e)=>{try{return!!t(...e)}catch{return!1}},lu=Mi&&Fi(()=>{let t=!1,e=new Request(L.origin,{body:new ReadableStream,method:"POST",get duplex(){return t=!0,"half"}}).headers.has("Content-Type");return t&&!e}),Li=64*1024,Hn=Mi&&Fi(()=>p.isReadableStream(new Response("").body)),Rr={stream:Hn&&(t=>t.body)};jr&&(t=>{["text","arrayBuffer","blob","formData","stream"].forEach(e=>{!Rr[e]&&(Rr[e]=p.isFunction(t[e])?r=>r[e]():(r,n)=>{throw new A(`Response type '${e}' is not supported`,A.ERR_NOT_SUPPORT,n)})})})(new Response);var fu=async t=>{if(t==null)return 0;if(p.isBlob(t))return t.size;if(p.isSpecCompliantForm(t))return(await new Request(L.origin,{method:"POST",body:t}).arrayBuffer()).byteLength;if(p.isArrayBufferView(t)||p.isArrayBuffer(t))return t.byteLength;if(p.isURLSearchParams(t)&&(t=t+""),p.isString(t))return(await du(t)).byteLength},pu=async(t,e)=>{let r=p.toFiniteNumber(t.getContentLength());return r==null?fu(e):r},zi=jr&&(async t=>{let{url:e,method:r,data:n,signal:o,cancelToken:i,timeout:s,onDownloadProgress:a,onUploadProgress:c,responseType:u,headers:d,withCredentials:m="same-origin",fetchOptions:b}=Pr(t);u=u?(u+"").toLowerCase():"text";let w=Di([o,i&&i.toAbortSignal()],s),h,v=w&&w.unsubscribe&&(()=>{w.unsubscribe()}),_;try{if(c&&lu&&r!=="get"&&r!=="head"&&(_=await pu(d,n))!==0){let D=new Request(e,{method:"POST",body:n,duplex:"half"}),te;if(p.isFormData(n)&&(te=D.headers.get("content-type"))&&d.setContentType(te),D.body){let[ye,je]=zn(_,ct(qn(c)));n=Bn(D.body,Li,ye,je)}}p.isString(m)||(m=m?"include":"omit");let S="credentials"in Request.prototype;h=new Request(e,{...b,signal:w,method:r.toUpperCase(),headers:d.normalize().toJSON(),body:n,duplex:"half",credentials:S?m:void 0});let R=await fetch(h,b),N=Hn&&(u==="stream"||u==="response");if(Hn&&(a||N&&v)){let D={};["status","statusText","headers"].forEach(vr=>{D[vr]=R[vr]});let te=p.toFiniteNumber(R.headers.get("content-length")),[ye,je]=a&&zn(te,ct(qn(a),!0))||[];R=new Response(Bn(R.body,Li,ye,()=>{je&&je(),v&&v()}),D)}u=u||"text";let z=await Rr[p.findKey(Rr,u)||"text"](R,t);return!N&&v&&v(),await new Promise((D,te)=>{Gt(D,te,{data:z,headers:F.from(R.headers),status:R.status,statusText:R.statusText,config:t,request:h})})}catch(S){throw v&&v(),S&&S.name==="TypeError"&&/Load failed|fetch/i.test(S.message)?Object.assign(new A("Network Error",A.ERR_NETWORK,t,h),{cause:S.cause||S}):A.from(S,S&&S.code,t,h)}});var Wn={http:Sr,xhr:Ni,fetch:zi};p.forEach(Wn,(t,e)=>{if(t){try{Object.defineProperty(t,"name",{value:e})}catch{}Object.defineProperty(t,"adapterName",{value:e})}});var qi=t=>`- ${t}`,mu=t=>p.isFunction(t)||t===null||t===!1,kr={getAdapter:t=>{t=p.isArray(t)?t:[t];let{length:e}=t,r,n,o={};for(let i=0;i<e;i++){r=t[i];let s;if(n=r,!mu(r)&&(n=Wn[(s=String(r)).toLowerCase()],n===void 0))throw new A(`Unknown adapter '${s}'`);if(n)break;o[s||"#"+i]=n}if(!n){let i=Object.entries(o).map(([a,c])=>`adapter ${a} `+(c===!1?"is not supported by the environment":"is not available in the build")),s=e?i.length>1?`since :
4
4
  `+i.map(qi).join(`
5
5
  `):" "+qi(i[0]):"as no adapter specified";throw new A("There is no suitable adapter to dispatch the request "+s,"ERR_NOT_SUPPORT")}return n},adapters:Wn};function Jn(t){if(t.cancelToken&&t.cancelToken.throwIfRequested(),t.signal&&t.signal.aborted)throw new de(null,t)}function Zr(t){return Jn(t),t.headers=F.from(t.headers),t.data=Jt.call(t,t.transformRequest),["post","put","patch"].indexOf(t.method)!==-1&&t.headers.setContentType("application/x-www-form-urlencoded",!1),kr.getAdapter(t.adapter||st.adapter)(t).then(function(n){return Jn(t),n.data=Jt.call(t,t.transformResponse,n),n.headers=F.from(n.headers),n},function(n){return Kt(n)||(Jn(t),n&&n.response&&(n.response.data=Jt.call(t,t.transformResponse,n.response),n.response.headers=F.from(n.response.headers))),Promise.reject(n)})}var Ur="1.10.0";var Nr={};["object","boolean","number","function","string","symbol"].forEach((t,e)=>{Nr[t]=function(n){return typeof n===t||"a"+(e<1?"n ":" ")+t}});var Vi={};Nr.transitional=function(e,r,n){function o(i,s){return"[Axios v"+Ur+"] Transitional option '"+i+"'"+s+(n?". "+n:"")}return(i,s,a)=>{if(e===!1)throw new A(o(s," has been removed"+(r?" in "+r:"")),A.ERR_DEPRECATED);return r&&!Vi[s]&&(Vi[s]=!0,console.warn(o(s," has been deprecated since v"+r+" and will be removed in the near future"))),e?e(i,s,a):!0}};Nr.spelling=function(e){return(r,n)=>(console.warn(`${n} is likely a misspelling of ${e}`),!0)};function hu(t,e,r){if(typeof t!="object")throw new A("options must be an object",A.ERR_BAD_OPTION_VALUE);let n=Object.keys(t),o=n.length;for(;o-- >0;){let i=n[o],s=e[i];if(s){let a=t[i],c=a===void 0||s(a,i,t);if(c!==!0)throw new A("option "+i+" must be "+c,A.ERR_BAD_OPTION_VALUE);continue}if(r!==!0)throw new A("Unknown option "+i,A.ERR_BAD_OPTION)}}var Xt={assertOptions:hu,validators:Nr};var le=Xt.validators,ut=class{constructor(e){this.defaults=e||{},this.interceptors={request:new kn,response:new kn}}async request(e,r){try{return await this._request(e,r)}catch(n){if(n instanceof Error){let o={};Error.captureStackTrace?Error.captureStackTrace(o):o=new Error;let i=o.stack?o.stack.replace(/^.+\n/,""):"";try{n.stack?i&&!String(n.stack).endsWith(i.replace(/^.+\n.+\n/,""))&&(n.stack+=`
6
- `+i):n.stack=i}catch{}}throw n}}_request(e,r){typeof e=="string"?(r=r||{},r.url=e):r=e||{},r=ae(this.defaults,r);let{transitional:n,paramsSerializer:o,headers:i}=r;n!==void 0&&Xt.assertOptions(n,{silentJSONParsing:le.transitional(le.boolean),forcedJSONParsing:le.transitional(le.boolean),clarifyTimeoutError:le.transitional(le.boolean)},!1),o!=null&&(p.isFunction(o)?r.paramsSerializer={serialize:o}:Xt.assertOptions(o,{encode:le.function,serialize:le.function},!0)),r.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?r.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:r.allowAbsoluteUrls=!0),Xt.assertOptions(r,{baseUrl:le.spelling("baseURL"),withXsrfToken:le.spelling("withXSRFToken")},!0),r.method=(r.method||this.defaults.method||"get").toLowerCase();let s=i&&p.merge(i.common,i[r.method]);i&&p.forEach(["delete","get","head","post","put","patch","common"],h=>{delete i[h]}),r.headers=F.concat(s,i);let a=[],c=!0;this.interceptors.request.forEach(function(v){typeof v.runWhen=="function"&&v.runWhen(r)===!1||(c=c&&v.synchronous,a.unshift(v.fulfilled,v.rejected))});let u=[];this.interceptors.response.forEach(function(v){u.push(v.fulfilled,v.rejected)});let d,m=0,b;if(!c){let h=[Zr.bind(this),void 0];for(h.unshift.apply(h,a),h.push.apply(h,u),b=h.length,d=Promise.resolve(r);m<b;)d=d.then(h[m++],h[m++]);return d}b=a.length;let w=r;for(m=0;m<b;){let h=a[m++],v=a[m++];try{w=h(w)}catch(_){v.call(this,_);break}}try{d=Zr.call(this,w)}catch(h){return Promise.reject(h)}for(m=0,b=u.length;m<b;)d=d.then(u[m++],u[m++]);return d}getUri(e){e=ae(this.defaults,e);let r=Yt(e.baseURL,e.url,e.allowAbsoluteUrls);return Ht(r,e.params,e.paramsSerializer)}};p.forEach(["delete","get","head","options"],function(e){ut.prototype[e]=function(r,n){return this.request(ae(n||{},{method:e,url:r,data:(n||{}).data}))}});p.forEach(["post","put","patch"],function(e){function r(n){return function(i,s,a){return this.request(ae(a||{},{method:e,headers:n?{"Content-Type":"multipart/form-data"}:{},url:i,data:s}))}}ut.prototype[e]=r(),ut.prototype[e+"Form"]=r(!0)});var Qt=ut;var Kn=class t{constructor(e){if(typeof e!="function")throw new TypeError("executor must be a function.");let r;this.promise=new Promise(function(i){r=i});let n=this;this.promise.then(o=>{if(!n._listeners)return;let i=n._listeners.length;for(;i-- >0;)n._listeners[i](o);n._listeners=null}),this.promise.then=o=>{let i,s=new Promise(a=>{n.subscribe(a),i=a}).then(o);return s.cancel=function(){n.unsubscribe(i)},s},e(function(i,s,a){n.reason||(n.reason=new de(i,s,a),r(n.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){if(this.reason){e(this.reason);return}this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;let r=this._listeners.indexOf(e);r!==-1&&this._listeners.splice(r,1)}toAbortSignal(){let e=new AbortController,r=n=>{e.abort(n)};return this.subscribe(r),e.signal.unsubscribe=()=>this.unsubscribe(r),e.signal}static source(){let e;return{token:new t(function(o){e=o}),cancel:e}}},$i=Kn;function Gn(t){return function(r){return t.apply(null,r)}}function Yn(t){return p.isObject(t)&&t.isAxiosError===!0}var Xn={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(Xn).forEach(([t,e])=>{Xn[e]=t});var Bi=Xn;function Hi(t){let e=new Qt(t),r=Vt(Qt.prototype.request,e);return p.extend(r,Qt.prototype,e,{allOwnKeys:!0}),p.extend(r,e,null,{allOwnKeys:!0}),r.create=function(o){return Hi(ae(t,o))},r}var M=Hi(st);M.Axios=Qt;M.CanceledError=de;M.CancelToken=$i;M.isCancel=Kt;M.VERSION=Ur;M.toFormData=Ce;M.AxiosError=A;M.Cancel=M.CanceledError;M.all=function(e){return Promise.all(e)};M.spread=Gn;M.isAxiosError=Yn;M.mergeConfig=ae;M.AxiosHeaders=F;M.formToJSON=t=>Or(p.isHTMLForm(t)?new FormData(t):t);M.getAdapter=kr.getAdapter;M.HttpStatusCode=Bi;M.default=M;var Dr=M;var{Axios:xy,AxiosError:wy,CanceledError:Cy,isCancel:Ty,CancelToken:Sy,VERSION:Iy,all:Ay,Cancel:Oy,isAxiosError:Ey,spread:Py,toFormData:Ry,AxiosHeaders:jy,HttpStatusCode:ky,formToJSON:Zy,getAdapter:Uy,mergeConfig:Ny}=Dr;var Qi=br(er());var zr=class{constructor(e){this.API_VERSION="2022-03-01-preview";let{identifier:r,host:n}=e;this.baseURL=new URL(`/copilotstudio/prebuilt/authenticated/bots/${r}`,n),this.baseURL.searchParams.append("api-version",this.API_VERSION)}getConversationUrl(e){let r=new URL(this.baseURL.href);return r.pathname=`${r.pathname}/conversations`,e&&(r.pathname=`${r.pathname}/${e}`),r.href}};var qr=class{constructor(e){this.API_VERSION="2022-03-01-preview";let{schema:r,host:n}=e;this.baseURL=new URL(`/copilotstudio/dataverse-backed/authenticated/bots/${r}`,n),this.baseURL.searchParams.append("api-version",this.API_VERSION)}getConversationUrl(e){let r=new URL(this.baseURL.href);return r.pathname=`${r.pathname}/conversations`,e&&(r.pathname=`${r.pathname}/${e}`),r.href}};var pt=(0,Qi.debug)("copilot-studio:power-platform");function $r(t,e){var a,c,u,d,m,b;if((a=t.directConnectUrl)!=null&&a.trim()){if(pt.debug(`Using direct connection: ${t.directConnectUrl}`),!tr(t.directConnectUrl))throw new Error("directConnectUrl must be a valid URL");return t.directConnectUrl.toLowerCase().includes("tenants/00000000-0000-0000-0000-000000000000")?(pt.debug(`Direct connection cannot be used, forcing default settings flow. Tenant ID is missing in the URL: ${t.directConnectUrl}`),$r({...t,directConnectUrl:""},e)):ju(t.directConnectUrl,e).href}let r=(c=t.cloud)!=null?c:"Prod",n=(u=t.copilotAgentType)!=null?u:"Published";if(pt.debug(`Using cloud setting: ${r}`),pt.debug(`Using agent type: ${n}`),!((d=t.environmentId)!=null&&d.trim()))throw new Error("EnvironmentId must be provided");if(!((m=t.agentIdentifier)!=null&&m.trim()))throw new Error("AgentIdentifier must be provided");if(r==="Other")if((b=t.customPowerPlatformCloud)!=null&&b.trim())if(tr(t.customPowerPlatformCloud))pt.debug(`Using custom Power Platform cloud: ${t.customPowerPlatformCloud}`);else throw new Error("customPowerPlatformCloud must be a valid URL");else throw new Error("customPowerPlatformCloud must be provided when PowerPlatformCloud is Other");let o=ku(r,t.environmentId,t.customPowerPlatformCloud),s={Published:()=>new qr({host:o,schema:t.agentIdentifier}),Prebuilt:()=>new zr({host:o,identifier:t.agentIdentifier})}[n]().getConversationUrl(e);return pt.debug(`Generated Copilot Studio connection URL: ${s}`),s}function es(t,e="Unknown",r="",n=""){var o,i;if(!n&&!(t!=null&&t.directConnectUrl)){if(e==="Other"&&!r)throw new Error("cloudBaseAddress must be provided when PowerPlatformCloudCategory is Other");if(!t&&e==="Unknown")throw new Error("Either settings or cloud must be provided");if(t&&t.cloud&&t.cloud!=="Unknown"&&(e=t.cloud),e==="Other")if(r&&tr(r))e="Other";else if(t!=null&&t.customPowerPlatformCloud&&tr(t.customPowerPlatformCloud))e="Other",r=t.customPowerPlatformCloud;else throw new Error("Either CustomPowerPlatformCloud or cloudBaseAddress must be provided when PowerPlatformCloudCategory is Other");return r!=null||(r="api.unknown.powerplatform.com"),`https://${Vr(e,r)}/.default`}else if(n||(n=(o=t==null?void 0:t.directConnectUrl)!=null?o:""),n&&tr(n)){if(Xi(new URL(n))==="Unknown"){let s=(i=t==null?void 0:t.cloud)!=null?i:e;if(s==="Other"||s==="Unknown")throw new Error("Unable to resolve the PowerPlatform Cloud from DirectConnectUrl. The Token Audience resolver requires a specific PowerPlatformCloudCategory.");if(s!=="Unknown")return`https://${Vr(s,"")}/.default`;throw new Error("Unable to resolve the PowerPlatform Cloud from DirectConnectUrl. The Token Audience resolver requires a specific PowerPlatformCloudCategory.")}return`https://${Vr(Xi(new URL(n)),"")}/.default`}else throw new Error("DirectConnectUrl must be provided when DirectConnectUrl is set")}function tr(t){try{let e=t.startsWith("http")?t:`https://${t}`;return!!new URL(e)}catch{return!1}}function ju(t,e){let r=new URL(t);return r.searchParams.has("api-version")||r.searchParams.append("api-version","2022-03-01-preview"),r.pathname.endsWith("/")&&(r.pathname=r.pathname.slice(0,-1)),r.pathname.includes("/conversations")&&(r.pathname=r.pathname.substring(0,r.pathname.indexOf("/conversations"))),r.pathname=`${r.pathname}/conversations`,e&&(r.pathname=`${r.pathname}/${e}`),r}function ku(t,e,r){if(t==="Other"&&(!r||!r.trim()))throw new Error("cloudBaseAddress must be provided when PowerPlatformCloud is Other");r=r!=null?r:"api.unknown.powerplatform.com";let n=e.toLowerCase().replaceAll("-",""),o=Zu(t),i=n.substring(0,n.length-o),s=n.substring(n.length-o);return new URL(`https://${i}.${s}.environment.${Vr(t,r)}`)}function Vr(t,e){switch(t){case"Local":return"api.powerplatform.localhost";case"Exp":return"api.exp.powerplatform.com";case"Dev":return"api.dev.powerplatform.com";case"Prv":return"api.prv.powerplatform.com";case"Test":return"api.test.powerplatform.com";case"Preprod":return"api.preprod.powerplatform.com";case"FirstRelease":case"Prod":return"api.powerplatform.com";case"GovFR":return"api.gov.powerplatform.microsoft.us";case"Gov":return"api.gov.powerplatform.microsoft.us";case"High":return"api.high.powerplatform.microsoft.us";case"DoD":return"api.appsplatform.us";case"Mooncake":return"api.powerplatform.partner.microsoftonline.cn";case"Ex":return"api.powerplatform.eaglex.ic.gov";case"Rx":return"api.powerplatform.microsoft.scloud";case"Other":return e;default:throw new Error(`Invalid cluster category value: ${t}`)}}function Zu(t){switch(t){case"FirstRelease":case"Prod":return 2;default:return 1}}function Xi(t){switch(t.host.toLowerCase()){case"api.powerplatform.localhost":return"Local";case"api.exp.powerplatform.com":return"Exp";case"api.dev.powerplatform.com":return"Dev";case"api.prv.powerplatform.com":return"Prv";case"api.test.powerplatform.com":return"Test";case"api.preprod.powerplatform.com":return"Preprod";case"api.powerplatform.com":return"Prod";case"api.gov.powerplatform.microsoft.us":return"GovFR";case"api.high.powerplatform.microsoft.us":return"High";case"api.appsplatform.us":return"DoD";case"api.powerplatform.partner.microsoftonline.cn":return"Mooncake";default:return"Unknown"}}var hr=br(Ea());var bn=class{constructor(e){this.activity=e}};var ja=br(er());var Pa="0.6.22";var _n={};var Q=(0,ja.debug)("copilot-studio:client"),we=class we{constructor(e,r){this.conversationId="";this.settings=e,this.client=Dr.create(),this.client.defaults.headers.common.Authorization=`Bearer ${r}`,this.client.defaults.headers.common["User-Agent"]=we.getProductInfo()}async postRequestAsync(e){var m,b,w,h;let r=[];Q.debug(`>>> SEND TO ${e.url}`);let n=await this.client(e);if(this.settings.useExperimentalEndpoint&&!((m=this.settings.directConnectUrl)!=null&&m.trim())){let v=(b=n.headers)==null?void 0:b[we.islandExperimentalUrlHeaderKey];v&&(this.settings.directConnectUrl=v,Q.debug(`Island Experimental URL: ${v}`))}this.conversationId=(h=(w=n.headers)==null?void 0:w[we.conversationIdHeaderKey])!=null?h:"",this.conversationId&&Q.debug(`Conversation ID: ${this.conversationId}`);let o={...n.headers};delete o.Authorization,delete o[we.conversationIdHeaderKey],Q.debug("Headers received:",o);let s=n.data.pipeThrough(new TextDecoderStream).getReader(),a="",c=[],u=async({done:v,value:_})=>v?(Q.debug("Stream complete"),a+=_,c.push(a),c):(Q.info("Agent is typing ..."),a+=_,await u(await s.read()));return(await s.read().then(u)).forEach(v=>{v.toString().split(`
6
+ `+i):n.stack=i}catch{}}throw n}}_request(e,r){typeof e=="string"?(r=r||{},r.url=e):r=e||{},r=ae(this.defaults,r);let{transitional:n,paramsSerializer:o,headers:i}=r;n!==void 0&&Xt.assertOptions(n,{silentJSONParsing:le.transitional(le.boolean),forcedJSONParsing:le.transitional(le.boolean),clarifyTimeoutError:le.transitional(le.boolean)},!1),o!=null&&(p.isFunction(o)?r.paramsSerializer={serialize:o}:Xt.assertOptions(o,{encode:le.function,serialize:le.function},!0)),r.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?r.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:r.allowAbsoluteUrls=!0),Xt.assertOptions(r,{baseUrl:le.spelling("baseURL"),withXsrfToken:le.spelling("withXSRFToken")},!0),r.method=(r.method||this.defaults.method||"get").toLowerCase();let s=i&&p.merge(i.common,i[r.method]);i&&p.forEach(["delete","get","head","post","put","patch","common"],h=>{delete i[h]}),r.headers=F.concat(s,i);let a=[],c=!0;this.interceptors.request.forEach(function(v){typeof v.runWhen=="function"&&v.runWhen(r)===!1||(c=c&&v.synchronous,a.unshift(v.fulfilled,v.rejected))});let u=[];this.interceptors.response.forEach(function(v){u.push(v.fulfilled,v.rejected)});let d,m=0,b;if(!c){let h=[Zr.bind(this),void 0];for(h.unshift.apply(h,a),h.push.apply(h,u),b=h.length,d=Promise.resolve(r);m<b;)d=d.then(h[m++],h[m++]);return d}b=a.length;let w=r;for(m=0;m<b;){let h=a[m++],v=a[m++];try{w=h(w)}catch(_){v.call(this,_);break}}try{d=Zr.call(this,w)}catch(h){return Promise.reject(h)}for(m=0,b=u.length;m<b;)d=d.then(u[m++],u[m++]);return d}getUri(e){e=ae(this.defaults,e);let r=Yt(e.baseURL,e.url,e.allowAbsoluteUrls);return Ht(r,e.params,e.paramsSerializer)}};p.forEach(["delete","get","head","options"],function(e){ut.prototype[e]=function(r,n){return this.request(ae(n||{},{method:e,url:r,data:(n||{}).data}))}});p.forEach(["post","put","patch"],function(e){function r(n){return function(i,s,a){return this.request(ae(a||{},{method:e,headers:n?{"Content-Type":"multipart/form-data"}:{},url:i,data:s}))}}ut.prototype[e]=r(),ut.prototype[e+"Form"]=r(!0)});var Qt=ut;var Kn=class t{constructor(e){if(typeof e!="function")throw new TypeError("executor must be a function.");let r;this.promise=new Promise(function(i){r=i});let n=this;this.promise.then(o=>{if(!n._listeners)return;let i=n._listeners.length;for(;i-- >0;)n._listeners[i](o);n._listeners=null}),this.promise.then=o=>{let i,s=new Promise(a=>{n.subscribe(a),i=a}).then(o);return s.cancel=function(){n.unsubscribe(i)},s},e(function(i,s,a){n.reason||(n.reason=new de(i,s,a),r(n.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){if(this.reason){e(this.reason);return}this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;let r=this._listeners.indexOf(e);r!==-1&&this._listeners.splice(r,1)}toAbortSignal(){let e=new AbortController,r=n=>{e.abort(n)};return this.subscribe(r),e.signal.unsubscribe=()=>this.unsubscribe(r),e.signal}static source(){let e;return{token:new t(function(o){e=o}),cancel:e}}},$i=Kn;function Gn(t){return function(r){return t.apply(null,r)}}function Yn(t){return p.isObject(t)&&t.isAxiosError===!0}var Xn={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(Xn).forEach(([t,e])=>{Xn[e]=t});var Bi=Xn;function Hi(t){let e=new Qt(t),r=Vt(Qt.prototype.request,e);return p.extend(r,Qt.prototype,e,{allOwnKeys:!0}),p.extend(r,e,null,{allOwnKeys:!0}),r.create=function(o){return Hi(ae(t,o))},r}var M=Hi(st);M.Axios=Qt;M.CanceledError=de;M.CancelToken=$i;M.isCancel=Kt;M.VERSION=Ur;M.toFormData=Ce;M.AxiosError=A;M.Cancel=M.CanceledError;M.all=function(e){return Promise.all(e)};M.spread=Gn;M.isAxiosError=Yn;M.mergeConfig=ae;M.AxiosHeaders=F;M.formToJSON=t=>Or(p.isHTMLForm(t)?new FormData(t):t);M.getAdapter=kr.getAdapter;M.HttpStatusCode=Bi;M.default=M;var Dr=M;var{Axios:xy,AxiosError:wy,CanceledError:Cy,isCancel:Ty,CancelToken:Sy,VERSION:Iy,all:Ay,Cancel:Oy,isAxiosError:Ey,spread:Py,toFormData:Ry,AxiosHeaders:jy,HttpStatusCode:ky,formToJSON:Zy,getAdapter:Uy,mergeConfig:Ny}=Dr;var Qi=br(er());var zr=class{constructor(e){this.API_VERSION="2022-03-01-preview";let{identifier:r,host:n}=e;this.baseURL=new URL(`/copilotstudio/prebuilt/authenticated/bots/${r}`,n),this.baseURL.searchParams.append("api-version",this.API_VERSION)}getConversationUrl(e){let r=new URL(this.baseURL.href);return r.pathname=`${r.pathname}/conversations`,e&&(r.pathname=`${r.pathname}/${e}`),r.href}};var qr=class{constructor(e){this.API_VERSION="2022-03-01-preview";let{schema:r,host:n}=e;this.baseURL=new URL(`/copilotstudio/dataverse-backed/authenticated/bots/${r}`,n),this.baseURL.searchParams.append("api-version",this.API_VERSION)}getConversationUrl(e){let r=new URL(this.baseURL.href);return r.pathname=`${r.pathname}/conversations`,e&&(r.pathname=`${r.pathname}/${e}`),r.href}};var pt=(0,Qi.debug)("copilot-studio:power-platform");function $r(t,e){var a,c,u,d,m,b;if((a=t.directConnectUrl)!=null&&a.trim()){if(pt.debug(`Using direct connection: ${t.directConnectUrl}`),!tr(t.directConnectUrl))throw new Error("directConnectUrl must be a valid URL");return t.directConnectUrl.toLowerCase().includes("tenants/00000000-0000-0000-0000-000000000000")?(pt.debug(`Direct connection cannot be used, forcing default settings flow. Tenant ID is missing in the URL: ${t.directConnectUrl}`),$r({...t,directConnectUrl:""},e)):ju(t.directConnectUrl,e).href}let r=(c=t.cloud)!=null?c:"Prod",n=(u=t.copilotAgentType)!=null?u:"Published";if(pt.debug(`Using cloud setting: ${r}`),pt.debug(`Using agent type: ${n}`),!((d=t.environmentId)!=null&&d.trim()))throw new Error("EnvironmentId must be provided");if(!((m=t.agentIdentifier)!=null&&m.trim()))throw new Error("AgentIdentifier must be provided");if(r==="Other")if((b=t.customPowerPlatformCloud)!=null&&b.trim())if(tr(t.customPowerPlatformCloud))pt.debug(`Using custom Power Platform cloud: ${t.customPowerPlatformCloud}`);else throw new Error("customPowerPlatformCloud must be a valid URL");else throw new Error("customPowerPlatformCloud must be provided when PowerPlatformCloud is Other");let o=ku(r,t.environmentId,t.customPowerPlatformCloud),s={Published:()=>new qr({host:o,schema:t.agentIdentifier}),Prebuilt:()=>new zr({host:o,identifier:t.agentIdentifier})}[n]().getConversationUrl(e);return pt.debug(`Generated Copilot Studio connection URL: ${s}`),s}function es(t,e="Unknown",r="",n=""){var o,i;if(!n&&!(t!=null&&t.directConnectUrl)){if(e==="Other"&&!r)throw new Error("cloudBaseAddress must be provided when PowerPlatformCloudCategory is Other");if(!t&&e==="Unknown")throw new Error("Either settings or cloud must be provided");if(t&&t.cloud&&t.cloud!=="Unknown"&&(e=t.cloud),e==="Other")if(r&&tr(r))e="Other";else if(t!=null&&t.customPowerPlatformCloud&&tr(t.customPowerPlatformCloud))e="Other",r=t.customPowerPlatformCloud;else throw new Error("Either CustomPowerPlatformCloud or cloudBaseAddress must be provided when PowerPlatformCloudCategory is Other");return r!=null||(r="api.unknown.powerplatform.com"),`https://${Vr(e,r)}/.default`}else if(n||(n=(o=t==null?void 0:t.directConnectUrl)!=null?o:""),n&&tr(n)){if(Xi(new URL(n))==="Unknown"){let s=(i=t==null?void 0:t.cloud)!=null?i:e;if(s==="Other"||s==="Unknown")throw new Error("Unable to resolve the PowerPlatform Cloud from DirectConnectUrl. The Token Audience resolver requires a specific PowerPlatformCloudCategory.");if(s!=="Unknown")return`https://${Vr(s,"")}/.default`;throw new Error("Unable to resolve the PowerPlatform Cloud from DirectConnectUrl. The Token Audience resolver requires a specific PowerPlatformCloudCategory.")}return`https://${Vr(Xi(new URL(n)),"")}/.default`}else throw new Error("DirectConnectUrl must be provided when DirectConnectUrl is set")}function tr(t){try{let e=t.startsWith("http")?t:`https://${t}`;return!!new URL(e)}catch{return!1}}function ju(t,e){let r=new URL(t);return r.searchParams.has("api-version")||r.searchParams.append("api-version","2022-03-01-preview"),r.pathname.endsWith("/")&&(r.pathname=r.pathname.slice(0,-1)),r.pathname.includes("/conversations")&&(r.pathname=r.pathname.substring(0,r.pathname.indexOf("/conversations"))),r.pathname=`${r.pathname}/conversations`,e&&(r.pathname=`${r.pathname}/${e}`),r}function ku(t,e,r){if(t==="Other"&&(!r||!r.trim()))throw new Error("cloudBaseAddress must be provided when PowerPlatformCloud is Other");r=r!=null?r:"api.unknown.powerplatform.com";let n=e.toLowerCase().replaceAll("-",""),o=Zu(t),i=n.substring(0,n.length-o),s=n.substring(n.length-o);return new URL(`https://${i}.${s}.environment.${Vr(t,r)}`)}function Vr(t,e){switch(t){case"Local":return"api.powerplatform.localhost";case"Exp":return"api.exp.powerplatform.com";case"Dev":return"api.dev.powerplatform.com";case"Prv":return"api.prv.powerplatform.com";case"Test":return"api.test.powerplatform.com";case"Preprod":return"api.preprod.powerplatform.com";case"FirstRelease":case"Prod":return"api.powerplatform.com";case"GovFR":return"api.gov.powerplatform.microsoft.us";case"Gov":return"api.gov.powerplatform.microsoft.us";case"High":return"api.high.powerplatform.microsoft.us";case"DoD":return"api.appsplatform.us";case"Mooncake":return"api.powerplatform.partner.microsoftonline.cn";case"Ex":return"api.powerplatform.eaglex.ic.gov";case"Rx":return"api.powerplatform.microsoft.scloud";case"Other":return e;default:throw new Error(`Invalid cluster category value: ${t}`)}}function Zu(t){switch(t){case"FirstRelease":case"Prod":return 2;default:return 1}}function Xi(t){switch(t.host.toLowerCase()){case"api.powerplatform.localhost":return"Local";case"api.exp.powerplatform.com":return"Exp";case"api.dev.powerplatform.com":return"Dev";case"api.prv.powerplatform.com":return"Prv";case"api.test.powerplatform.com":return"Test";case"api.preprod.powerplatform.com":return"Preprod";case"api.powerplatform.com":return"Prod";case"api.gov.powerplatform.microsoft.us":return"GovFR";case"api.high.powerplatform.microsoft.us":return"High";case"api.appsplatform.us":return"DoD";case"api.powerplatform.partner.microsoftonline.cn":return"Mooncake";default:return"Unknown"}}var hr=br(Ea());var bn=class{constructor(e){this.activity=e}};var ja=br(er());var Pa="1.0.0";var _n={};var Q=(0,ja.debug)("copilot-studio:client"),we=class we{constructor(e,r){this.conversationId="";this.settings=e,this.client=Dr.create(),this.client.defaults.headers.common.Authorization=`Bearer ${r}`,this.client.defaults.headers.common["User-Agent"]=we.getProductInfo()}async postRequestAsync(e){var m,b,w,h;let r=[];Q.debug(`>>> SEND TO ${e.url}`);let n=await this.client(e);if(this.settings.useExperimentalEndpoint&&!((m=this.settings.directConnectUrl)!=null&&m.trim())){let v=(b=n.headers)==null?void 0:b[we.islandExperimentalUrlHeaderKey];v&&(this.settings.directConnectUrl=v,Q.debug(`Island Experimental URL: ${v}`))}this.conversationId=(h=(w=n.headers)==null?void 0:w[we.conversationIdHeaderKey])!=null?h:"",this.conversationId&&Q.debug(`Conversation ID: ${this.conversationId}`);let o={...n.headers};delete o.Authorization,delete o[we.conversationIdHeaderKey],Q.debug("Headers received:",o);let s=n.data.pipeThrough(new TextDecoderStream).getReader(),a="",c=[],u=async({done:v,value:_})=>v?(Q.debug("Stream complete"),a+=_,c.push(a),c):(Q.info("Agent is typing ..."),a+=_,await u(await s.read()));return(await s.read().then(u)).forEach(v=>{v.toString().split(`
7
7
  `).filter(R=>R.substring(0,4)==="data"&&R!=="data: end\r").forEach(R=>{var N,z;try{let D=hr.Activity.fromJson(R.substring(5,R.length));D.type===hr.ActivityTypes.Message?(r.push(D),this.conversationId.trim()||(this.conversationId=(z=(N=D.conversation)==null?void 0:N.id)!=null?z:"",Q.debug(`Conversation ID: ${this.conversationId}`))):Q.debug(`Activity type: ${D.type}`)}catch(D){throw Q.error("Error: ",D),D}})}),r}static getProductInfo(){let e=`CopilotStudioClient.agents-sdk-js/${Pa}`,r;return typeof window!="undefined"&&window.navigator?r=`${e} ${navigator.userAgent}`:r=`${e} nodejs/${process.version} ${_n.platform()}-${_n.arch()}/${_n.release()}`,Q.debug(`User-Agent: ${r}`),r}async startConversationAsync(e=!0){var a;let o={method:"post",url:$r(this.settings),headers:{Accept:"text/event-stream","Content-Type":"application/json"},data:{emitStartConversationEvent:e},responseType:"stream",adapter:"fetch"};Q.info("Starting conversation ...");let i=await this.postRequestAsync(o),s=i[0];return Q.info(`Conversation '${(a=s.conversation)==null?void 0:a.id}' started. Received ${i.length} activities.`,i),s}async askQuestionAsync(e,r=this.conversationId){var m,b;let o={type:"message",text:e,conversation:{id:r}},i=hr.Activity.fromObject(o),s=(b=(m=i.conversation)==null?void 0:m.id)!=null?b:r,a=$r(this.settings,s),c=new bn(i),u={method:"post",url:a,headers:{Accept:"text/event-stream","Content-Type":"application/json"},data:c,responseType:"stream",adapter:"fetch"};Q.info(`Asking question: ${e} ...`);let d=await this.postRequestAsync(u);return Q.info(`Received ${d.length} activities.`,d),d}};we.conversationIdHeaderKey="x-ms-conversationid",we.islandExperimentalUrlHeaderKey="x-ms-d2e-experimental",we.scopeFromSettings=es;var Ra=we;var V=[];for(let t=0;t<256;++t)V.push((t+256).toString(16).slice(1));function ka(t,e=0){return(V[t[e+0]]+V[t[e+1]]+V[t[e+2]]+V[t[e+3]]+"-"+V[t[e+4]]+V[t[e+5]]+"-"+V[t[e+6]]+V[t[e+7]]+"-"+V[t[e+8]]+V[t[e+9]]+"-"+V[t[e+10]]+V[t[e+11]]+V[t[e+12]]+V[t[e+13]]+V[t[e+14]]+V[t[e+15]]).toLowerCase()}var Go,op=new Uint8Array(16);function Yo(){if(!Go){if(typeof crypto=="undefined"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");Go=crypto.getRandomValues.bind(crypto)}return Go(op)}var ip=typeof crypto!="undefined"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),Xo={randomUUID:ip};function sp(t,e,r){var o,i,s;if(Xo.randomUUID&&!e&&!t)return Xo.randomUUID();t=t||{};let n=(s=(i=t.random)!=null?i:(o=t.rng)==null?void 0:o.call(t))!=null?s:Yo();if(n.length<16)throw new Error("Random bytes length must be >= 16");if(n[6]=n[6]&15|64,n[8]=n[8]&63|128,e){if(r=r||0,r<0||r+16>e.length)throw new RangeError(`UUID byte range ${r}:${r+15} is out of buffer bounds`);for(let a=0;a<16;++a)e[r+a]=n[a];return e}return ka(n)}var Qo=sp;var ei=function(t,e){return ei=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,n){r.__proto__=n}||function(r,n){for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(r[o]=n[o])},ei(t,e)};function Pe(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");ei(t,e);function r(){this.constructor=t}t.prototype=e===null?Object.create(e):(r.prototype=e.prototype,new r)}function yr(t){var e=typeof Symbol=="function"&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function Ut(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),o,i=[],s;try{for(;(e===void 0||e-- >0)&&!(o=n.next()).done;)i.push(o.value)}catch(a){s={error:a}}finally{try{o&&!o.done&&(r=n.return)&&r.call(n)}finally{if(s)throw s.error}}return i}function Nt(t,e,r){if(r||arguments.length===2)for(var n=0,o=e.length,i;n<o;n++)(i||!(n in e))&&(i||(i=Array.prototype.slice.call(e,0,n)),i[n]=e[n]);return t.concat(i||Array.prototype.slice.call(e))}function ie(t){return typeof t=="function"}function xn(t){var e=function(n){Error.call(n),n.stack=new Error().stack},r=t(e);return r.prototype=Object.create(Error.prototype),r.prototype.constructor=r,r}var wn=xn(function(t){return function(r){t(this),this.message=r?r.length+` errors occurred during unsubscription:
8
8
  `+r.map(function(n,o){return o+1+") "+n.toString()}).join(`
9
9
  `):"",this.name="UnsubscriptionError",this.errors=r}});function gr(t,e){if(t){var r=t.indexOf(e);0<=r&&t.splice(r,1)}}var Dt=function(){function t(e){this.initialTeardown=e,this.closed=!1,this._parentage=null,this._finalizers=null}return t.prototype.unsubscribe=function(){var e,r,n,o,i;if(!this.closed){this.closed=!0;var s=this._parentage;if(s)if(this._parentage=null,Array.isArray(s))try{for(var a=yr(s),c=a.next();!c.done;c=a.next()){var u=c.value;u.remove(this)}}catch(v){e={error:v}}finally{try{c&&!c.done&&(r=a.return)&&r.call(a)}finally{if(e)throw e.error}}else s.remove(this);var d=this.initialTeardown;if(ie(d))try{d()}catch(v){i=v instanceof wn?v.errors:[v]}var m=this._finalizers;if(m){this._finalizers=null;try{for(var b=yr(m),w=b.next();!w.done;w=b.next()){var h=w.value;try{Za(h)}catch(v){i=i!=null?i:[],v instanceof wn?i=Nt(Nt([],Ut(i)),Ut(v.errors)):i.push(v)}}}catch(v){n={error:v}}finally{try{w&&!w.done&&(o=b.return)&&o.call(b)}finally{if(n)throw n.error}}}if(i)throw new wn(i)}},t.prototype.add=function(e){var r;if(e&&e!==this)if(this.closed)Za(e);else{if(e instanceof t){if(e.closed||e._hasParent(this))return;e._addParent(this)}(this._finalizers=(r=this._finalizers)!==null&&r!==void 0?r:[]).push(e)}},t.prototype._hasParent=function(e){var r=this._parentage;return r===e||Array.isArray(r)&&r.includes(e)},t.prototype._addParent=function(e){var r=this._parentage;this._parentage=Array.isArray(r)?(r.push(e),r):r?[r,e]:e},t.prototype._removeParent=function(e){var r=this._parentage;r===e?this._parentage=null:Array.isArray(r)&&gr(r,e)},t.prototype.remove=function(e){var r=this._finalizers;r&&gr(r,e),e instanceof t&&e._removeParent(this)},t.EMPTY=function(){var e=new t;return e.closed=!0,e}(),t}();var ti=Dt.EMPTY;function Cn(t){return t instanceof Dt||t&&"closed"in t&&ie(t.remove)&&ie(t.add)&&ie(t.unsubscribe)}function Za(t){ie(t)?t():t.unsubscribe()}var ue={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1};var Lt={setTimeout:function(t,e){for(var r=[],n=2;n<arguments.length;n++)r[n-2]=arguments[n];var o=Lt.delegate;return o!=null&&o.setTimeout?o.setTimeout.apply(o,Nt([t,e],Ut(r))):setTimeout.apply(void 0,Nt([t,e],Ut(r)))},clearTimeout:function(t){var e=Lt.delegate;return((e==null?void 0:e.clearTimeout)||clearTimeout)(t)},delegate:void 0};function Ua(t){Lt.setTimeout(function(){var e=ue.onUnhandledError;if(e)e(t);else throw t})}function ri(){}var Na=function(){return ni("C",void 0,void 0)}();function Da(t){return ni("E",void 0,t)}function La(t){return ni("N",t,void 0)}function ni(t,e,r){return{kind:t,value:e,error:r}}var nt=null;function Mt(t){if(ue.useDeprecatedSynchronousErrorHandling){var e=!nt;if(e&&(nt={errorThrown:!1,error:null}),t(),e){var r=nt,n=r.errorThrown,o=r.error;if(nt=null,n)throw o}}else t()}function Ma(t){ue.useDeprecatedSynchronousErrorHandling&&nt&&(nt.errorThrown=!0,nt.error=t)}var si=function(t){Pe(e,t);function e(r){var n=t.call(this)||this;return n.isStopped=!1,r?(n.destination=r,Cn(r)&&r.add(n)):n.destination=dp,n}return e.create=function(r,n,o){return new Sn(r,n,o)},e.prototype.next=function(r){this.isStopped?ii(La(r),this):this._next(r)},e.prototype.error=function(r){this.isStopped?ii(Da(r),this):(this.isStopped=!0,this._error(r))},e.prototype.complete=function(){this.isStopped?ii(Na,this):(this.isStopped=!0,this._complete())},e.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,t.prototype.unsubscribe.call(this),this.destination=null)},e.prototype._next=function(r){this.destination.next(r)},e.prototype._error=function(r){try{this.destination.error(r)}finally{this.unsubscribe()}},e.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},e}(Dt);var ap=Function.prototype.bind;function oi(t,e){return ap.call(t,e)}var cp=function(){function t(e){this.partialObserver=e}return t.prototype.next=function(e){var r=this.partialObserver;if(r.next)try{r.next(e)}catch(n){Tn(n)}},t.prototype.error=function(e){var r=this.partialObserver;if(r.error)try{r.error(e)}catch(n){Tn(n)}else Tn(e)},t.prototype.complete=function(){var e=this.partialObserver;if(e.complete)try{e.complete()}catch(r){Tn(r)}},t}(),Sn=function(t){Pe(e,t);function e(r,n,o){var i=t.call(this)||this,s;if(ie(r)||!r)s={next:r!=null?r:void 0,error:n!=null?n:void 0,complete:o!=null?o:void 0};else{var a;i&&ue.useDeprecatedNextContext?(a=Object.create(r),a.unsubscribe=function(){return i.unsubscribe()},s={next:r.next&&oi(r.next,a),error:r.error&&oi(r.error,a),complete:r.complete&&oi(r.complete,a)}):s=r}return i.destination=new cp(s),i}return e}(si);function Tn(t){ue.useDeprecatedSynchronousErrorHandling?Ma(t):Ua(t)}function up(t){throw t}function ii(t,e){var r=ue.onStoppedNotification;r&&Lt.setTimeout(function(){return r(t,e)})}var dp={closed:!0,next:ri,error:up,complete:ri};var Fa=function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"}();function za(t){return t}function qa(t){return t.length===0?za:t.length===1?t[0]:function(r){return t.reduce(function(n,o){return o(n)},r)}}var Ft=function(){function t(e){e&&(this._subscribe=e)}return t.prototype.lift=function(e){var r=new t;return r.source=this,r.operator=e,r},t.prototype.subscribe=function(e,r,n){var o=this,i=fp(e)?e:new Sn(e,r,n);return Mt(function(){var s=o,a=s.operator,c=s.source;i.add(a?a.call(i,c):c?o._subscribe(i):o._trySubscribe(i))}),i},t.prototype._trySubscribe=function(e){try{return this._subscribe(e)}catch(r){e.error(r)}},t.prototype.forEach=function(e,r){var n=this;return r=Va(r),new r(function(o,i){var s=new Sn({next:function(a){try{e(a)}catch(c){i(c),s.unsubscribe()}},error:i,complete:o});n.subscribe(s)})},t.prototype._subscribe=function(e){var r;return(r=this.source)===null||r===void 0?void 0:r.subscribe(e)},t.prototype[Fa]=function(){return this},t.prototype.pipe=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return qa(e)(this)},t.prototype.toPromise=function(e){var r=this;return e=Va(e),new e(function(n,o){var i;r.subscribe(function(s){return i=s},function(s){return o(s)},function(){return n(i)})})},t.create=function(e){return new t(e)},t}();function Va(t){var e;return(e=t!=null?t:ue.Promise)!==null&&e!==void 0?e:Promise}function lp(t){return t&&ie(t.next)&&ie(t.error)&&ie(t.complete)}function fp(t){return t&&t instanceof si||lp(t)&&Cn(t)}var $a=xn(function(t){return function(){t(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}});var ai=function(t){Pe(e,t);function e(){var r=t.call(this)||this;return r.closed=!1,r.currentObservers=null,r.observers=[],r.isStopped=!1,r.hasError=!1,r.thrownError=null,r}return e.prototype.lift=function(r){var n=new Ba(this,this);return n.operator=r,n},e.prototype._throwIfClosed=function(){if(this.closed)throw new $a},e.prototype.next=function(r){var n=this;Mt(function(){var o,i;if(n._throwIfClosed(),!n.isStopped){n.currentObservers||(n.currentObservers=Array.from(n.observers));try{for(var s=yr(n.currentObservers),a=s.next();!a.done;a=s.next()){var c=a.value;c.next(r)}}catch(u){o={error:u}}finally{try{a&&!a.done&&(i=s.return)&&i.call(s)}finally{if(o)throw o.error}}}})},e.prototype.error=function(r){var n=this;Mt(function(){if(n._throwIfClosed(),!n.isStopped){n.hasError=n.isStopped=!0,n.thrownError=r;for(var o=n.observers;o.length;)o.shift().error(r)}})},e.prototype.complete=function(){var r=this;Mt(function(){if(r._throwIfClosed(),!r.isStopped){r.isStopped=!0;for(var n=r.observers;n.length;)n.shift().complete()}})},e.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(e.prototype,"observed",{get:function(){var r;return((r=this.observers)===null||r===void 0?void 0:r.length)>0},enumerable:!1,configurable:!0}),e.prototype._trySubscribe=function(r){return this._throwIfClosed(),t.prototype._trySubscribe.call(this,r)},e.prototype._subscribe=function(r){return this._throwIfClosed(),this._checkFinalizedStatuses(r),this._innerSubscribe(r)},e.prototype._innerSubscribe=function(r){var n=this,o=this,i=o.hasError,s=o.isStopped,a=o.observers;return i||s?ti:(this.currentObservers=null,a.push(r),new Dt(function(){n.currentObservers=null,gr(a,r)}))},e.prototype._checkFinalizedStatuses=function(r){var n=this,o=n.hasError,i=n.thrownError,s=n.isStopped;o?r.error(i):s&&r.complete()},e.prototype.asObservable=function(){var r=new Ft;return r.source=this,r},e.create=function(r,n){return new Ba(r,n)},e}(Ft);var Ba=function(t){Pe(e,t);function e(r,n){var o=t.call(this)||this;return o.destination=r,o.source=n,o}return e.prototype.next=function(r){var n,o;(o=(n=this.destination)===null||n===void 0?void 0:n.next)===null||o===void 0||o.call(n,r)},e.prototype.error=function(r){var n,o;(o=(n=this.destination)===null||n===void 0?void 0:n.error)===null||o===void 0||o.call(n,r)},e.prototype.complete=function(){var r,n;(n=(r=this.destination)===null||r===void 0?void 0:r.complete)===null||n===void 0||n.call(r)},e.prototype._subscribe=function(r){var n,o;return(o=(n=this.source)===null||n===void 0?void 0:n.subscribe(r))!==null&&o!==void 0?o:ti},e}(ai);var ci=function(t){Pe(e,t);function e(r){var n=t.call(this)||this;return n._value=r,n}return Object.defineProperty(e.prototype,"value",{get:function(){return this.getValue()},enumerable:!1,configurable:!0}),e.prototype._subscribe=function(r){var n=t.prototype._subscribe.call(this,r);return!n.closed&&r.next(this._value),n},e.prototype.getValue=function(){var r=this,n=r.hasError,o=r.thrownError,i=r._value;if(n)throw o;return this._throwIfClosed(),i},e.prototype.next=function(r){t.prototype.next.call(this,this._value=r)},e}(ai);var Ja=br(er()),Re=(0,Ja.debug)("copilot-studio:webchat"),Ha=class{static createConnection(e,r){Re.info("--> Creating connection between Copilot Studio and WebChat ...");let n=0,o,i,s=new ci(0),a=Wa(async d=>{if(o=d,s.value<2){s.next(2);return}Re.debug("--> Connection established."),u();let m=await e.startConversationAsync();i=m.conversation,n=0,c(m)}),c=d=>{let m={...d,timestamp:new Date().toISOString(),channelData:{...d.channelData,"webchat:sequence-id":n++}};Re.debug(`Notify '${m.type}' activity to WebChat:`,m),o==null||o.next(m)},u=()=>{if(!(r!=null&&r.showTyping))return;let d=i?{id:i.id,name:i.name}:{id:"agent",name:"Agent"};c({type:"typing",from:d})};return{connectionStatus$:s,activity$:a,postActivity(d){var m;if(Re.info("--> Preparing to send activity to Copilot Studio ..."),!((m=d.text)!=null&&m.trim()))throw new Error("Activity text cannot be empty.");if(!o)throw new Error("Activity subscriber is not initialized.");return Wa(async b=>{try{let w=Qo();Re.info("--> Sending activity to Copilot Studio ..."),c({...d,id:w}),u();let h=await e.askQuestionAsync(d.text);for(let v of h)c(v);b.next(w),b.complete(),Re.info("--> Activity received correctly from Copilot Studio.")}catch(w){Re.error("Error sending Activity to Copilot Studio:",w),b.error(w)}})},end(){Re.info("--> Ending connection between Copilot Studio and WebChat ..."),s.complete(),o&&(o.complete(),o=void 0)}}}};function Wa(t){return new Ft(e=>{Promise.resolve(t(e)).catch(r=>e.error(r))})}export{zt as AgentType,On as ConnectionSettings,Ra as CopilotStudioClient,Ha as CopilotStudioWebChat,bn as ExecuteTurnRequest,qt as PowerPlatformCloud,$r as getCopilotStudioConnectionUrl,es as getTokenAudience,vp as loadCopilotStudioConnectionSettingsFromEnv};