@runmedev/react-components 3.15.7 → 3.15.9
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/app/index.js
CHANGED
|
@@ -6656,7 +6656,7 @@ Open Dashboard to configure it`)},N=function(){var De;const He=(0,Z.getContext)(
|
|
|
6656
6656
|
!*** ./src/client/index.ts ***!
|
|
6657
6657
|
\*****************************/Object.defineProperty(t,"__esModule",{value:!0}),t.ClientMessages=t.setContext=t.activate=void 0;const e=mo("./src/constants.ts");Object.defineProperty(t,"ClientMessages",{enumerable:!0,get:function(){return e.ClientMessages}});const n=mo("./src/client/utils.ts");Object.defineProperty(t,"setContext",{enumerable:!0,get:function(){return n.setContext}}),mo("./src/client/components/index.ts");const r=s=>((0,n.setContext)(s),{renderOutputItem(c,i){var o,u,l;const a=c.json();switch(a.type){case e.OutputType.vercel:if(a.output.error){d(a.output.error);break}const h=document.createElement(e.RENDERERS.VercelOutput);h.setAttribute("content",JSON.stringify(a.output)),i.appendChild(h);break;case e.OutputType.daggerCall:if(!((o=a.output)!=null&&o.cellId))return;const p=document.createElement(e.RENDERERS.DaggerCli);p.setAttribute("cellId",a.output.cellId);const v={...a.output,cli:{status:"active"}};p.setAttribute("state",JSON.stringify(v)),i.appendChild(p);break;case e.OutputType.deno:if((u=a.output)!=null&&u.error){d(a.output.error);break}const m=a.output||{},b=document.createElement(e.RENDERERS.DenoOutput);b.setAttribute("state",JSON.stringify(m)),i.appendChild(b);break;case e.OutputType.outputItems:const y=decodeURIComponent(escape(window.atob(a.output.content))),_=document.createElement(e.RENDERERS.ShellOutput);_.innerHTML=y,i.appendChild(_);const S=document.createElement(e.RENDERERS.ShellOutputItems);S.setAttribute("id",a.output.id),S.setAttribute("content",y),i.appendChild(S);break;case e.OutputType.annotations:const x=document.createElement(e.RENDERERS.EditAnnotations);x.setAttribute("annotations",JSON.stringify(a.output.annotations??[])),x.setAttribute("validationErrors",JSON.stringify(a.output.validationErrors??[])),x.setAttribute("settings",JSON.stringify(a.output.settings)),i.appendChild(x);break;case e.OutputType.terminal:const C=document.createElement(e.RENDERERS.TerminalView);C.setAttribute("id",a.output["runme.dev/id"]),C.setAttribute("fontFamily",a.output.fontFamily),typeof a.output.fontSize=="number"&&C.setAttribute("fontSize",a.output.fontSize.toString()),a.output.cursorStyle&&C.setAttribute("cursorStyle",a.output.cursorStyle),typeof a.output.cursorBlink=="boolean"&&C.setAttribute("cursorBlink",a.output.cursorBlink?"true":"false"),typeof a.output.cursorWidth=="number"&&C.setAttribute("cursorWidth",a.output.cursorWidth.toString()),typeof a.output.smoothScrollDuration=="number"&&C.setAttribute("smoothScrollDuration",a.output.smoothScrollDuration.toString()),typeof a.output.scrollback=="number"&&C.setAttribute("scrollback",a.output.scrollback.toString()),a.output.initialRows!==void 0&&C.setAttribute("initialRows",a.output.initialRows.toString()),a.output.content!==void 0&&C.setAttribute("initialContent",a.output.content),a.output.isAutoSaveEnabled&&C.setAttribute("isAutoSaveEnabled",a.output.isAutoSaveEnabled.toString()),a.output.isPlatformAuthEnabled&&C.setAttribute("isPlatformAuthEnabled",a.output.isPlatformAuthEnabled.toString()),a.output.isDaggerOutput&&C.setAttribute("isDaggerOutput",a.output.isDaggerOutput.toString()),i.appendChild(C);break;case e.OutputType.error:d(a.output);break;case e.OutputType.github:const j=document.createElement(e.RENDERERS.GitHubWorkflowViewer);(l=a.output)!=null&&l.content&&j.setAttribute("state",JSON.stringify(a.output)),i.appendChild(j);break;case e.OutputType.gcp:const k=document.createElement(e.RENDERERS.GCPView);a.output&&k.setAttribute("state",JSON.stringify(a.output)),i.appendChild(k);break;case e.OutputType.aws:const A=document.createElement(e.RENDERERS.AWSView);a.output&&A.setAttribute("state",JSON.stringify(a.output)),i.appendChild(A);break;default:i.innerHTML="No renderer found!"}function d(h){i.innerHTML=`⚠️ ${h}`}},disposeOutputItem(){}});t.activate=r})();const Lu=_d.ClientMessages;_d.__esModule;_d.activate;const _P=_d.setContext,P5=gp("ChVnb29nbGUvcnBjL2NvZGUucHJvdG8SCmdvb2dsZS5ycGMqtwIKBENvZGUSBgoCT0sQABINCglDQU5DRUxMRUQQARILCgdVTktOT1dOEAISFAoQSU5WQUxJRF9BUkdVTUVOVBADEhUKEURFQURMSU5FX0VYQ0VFREVEEAQSDQoJTk9UX0ZPVU5EEAUSEgoOQUxSRUFEWV9FWElTVFMQBhIVChFQRVJNSVNTSU9OX0RFTklFRBAHEhMKD1VOQVVUSEVOVElDQVRFRBAQEhYKElJFU09VUkNFX0VYSEFVU1RFRBAIEhcKE0ZBSUxFRF9QUkVDT05ESVRJT04QCRILCgdBQk9SVEVEEAoSEAoMT1VUX09GX1JBTkdFEAsSEQoNVU5JTVBMRU1FTlRFRBAMEgwKCElOVEVSTkFMEA0SDwoLVU5BVkFJTEFCTEUQDhINCglEQVRBX0xPU1MQD0JYCg5jb20uZ29vZ2xlLnJwY0IJQ29kZVByb3RvUAFaM2dvb2dsZS5nb2xhbmcub3JnL2dlbnByb3RvL2dvb2dsZWFwaXMvcnBjL2NvZGU7Y29kZaICA1JQQ2IGcHJvdG8z"),wP=M0(P5,0),SP=P0(wP),B5=gp("CiBydW5tZS9zdHJlYW0vdjEvd2Vic29ja2V0cy5wcm90bxIPcnVubWUuc3RyZWFtLnYxIkIKD1dlYnNvY2tldFN0YXR1cxIeCgRjb2RlGAEgASgOMhAuZ29vZ2xlLnJwYy5Db2RlEg8KB21lc3NhZ2UYAiABKAkiGQoEUGluZxIRCgl0aW1lc3RhbXAYASABKAMiGQoEUG9uZxIRCgl0aW1lc3RhbXAYASABKAMiugEKEFdlYnNvY2tldFJlcXVlc3QSOgoPZXhlY3V0ZV9yZXF1ZXN0GAEgASgLMh8ucnVubWUucnVubmVyLnYyLkV4ZWN1dGVSZXF1ZXN0SAASIwoEcGluZxhkIAEoCzIVLnJ1bm1lLnN0cmVhbS52MS5QaW5nEhYKDWF1dGhvcml6YXRpb24YyAEgASgJEhEKCGtub3duX2lkGNIBIAEoCRIPCgZydW5faWQY3AEgASgJQgkKB3BheWxvYWQi2AEKEVdlYnNvY2tldFJlc3BvbnNlEjwKEGV4ZWN1dGVfcmVzcG9uc2UYASABKAsyIC5ydW5tZS5ydW5uZXIudjIuRXhlY3V0ZVJlc3BvbnNlSAASIwoEcG9uZxhkIAEoCzIVLnJ1bm1lLnN0cmVhbS52MS5Qb25nEjEKBnN0YXR1cxjIASABKAsyIC5ydW5tZS5zdHJlYW0udjEuV2Vic29ja2V0U3RhdHVzEhEKCGtub3duX2lkGNIBIAEoCRIPCgZydW5faWQY3AEgASgJQgkKB3BheWxvYWRCSFpGZ2l0aHViLmNvbS9ydW5tZWRldi9ydW5tZS92My9hcGkvZ2VuL3Byb3RvL2dvL3J1bm1lL3N0cmVhbS92MTtzdHJlYW12MWIGcHJvdG8z",[P5,bp]),Xg=yd(B5,3),xP=yd(B5,4);var qg=function(t,e){return qg=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,r){n.__proto__=r}||function(n,r){for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(n[s]=r[s])},qg(t,e)};function va(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");qg(t,e);function n(){this.constructor=t}t.prototype=e===null?Object.create(e):(n.prototype=e.prototype,new n)}function CP(t,e,n,r){function s(c){return c instanceof n?c:new n(function(i){i(c)})}return new(n||(n=Promise))(function(c,i){function o(a){try{l(r.next(a))}catch(d){i(d)}}function u(a){try{l(r.throw(a))}catch(d){i(d)}}function l(a){a.done?c(a.value):s(a.value).then(o,u)}l((r=r.apply(t,[])).next())})}function $5(t,e){var n={label:0,sent:function(){if(c[0]&1)throw c[1];return c[1]},trys:[],ops:[]},r,s,c,i=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return i.next=o(0),i.throw=o(1),i.return=o(2),typeof Symbol=="function"&&(i[Symbol.iterator]=function(){return this}),i;function o(l){return function(a){return u([l,a])}}function u(l){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,l[0]&&(n=0)),n;)try{if(r=1,s&&(c=l[0]&2?s.return:l[0]?s.throw||((c=s.return)&&c.call(s),0):s.next)&&!(c=c.call(s,l[1])).done)return c;switch(s=0,c&&(l=[l[0]&2,c.value]),l[0]){case 0:case 1:c=l;break;case 4:return n.label++,{value:l[1],done:!1};case 5:n.label++,s=l[1],l=[0];continue;case 7:l=n.ops.pop(),n.trys.pop();continue;default:if(c=n.trys,!(c=c.length>0&&c[c.length-1])&&(l[0]===6||l[0]===2)){n=0;continue}if(l[0]===3&&(!c||l[1]>c[0]&&l[1]<c[3])){n.label=l[1];break}if(l[0]===6&&n.label<c[1]){n.label=c[1],c=l;break}if(c&&n.label<c[2]){n.label=c[2],n.ops.push(l);break}c[2]&&n.ops.pop(),n.trys.pop();continue}l=e.call(t,n)}catch(a){l=[6,a],s=0}finally{r=c=0}if(l[0]&5)throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}}function ac(t){var e=typeof Symbol=="function"&&Symbol.iterator,n=e&&t[e],r=0;if(n)return n.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function _o(t,e){var n=typeof Symbol=="function"&&t[Symbol.iterator];if(!n)return t;var r=n.call(t),s,c=[],i;try{for(;(e===void 0||e-- >0)&&!(s=r.next()).done;)c.push(s.value)}catch(o){i={error:o}}finally{try{s&&!s.done&&(n=r.return)&&n.call(r)}finally{if(i)throw i.error}}return c}function fa(t,e,n){if(arguments.length===2)for(var r=0,s=e.length,c;r<s;r++)(c||!(r in e))&&(c||(c=Array.prototype.slice.call(e,0,r)),c[r]=e[r]);return t.concat(c||Array.prototype.slice.call(e))}function Wl(t){return this instanceof Wl?(this.v=t,this):new Wl(t)}function EP(t,e,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=n.apply(t,e||[]),s,c=[];return s=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),o("next"),o("throw"),o("return",i),s[Symbol.asyncIterator]=function(){return this},s;function i(p){return function(v){return Promise.resolve(v).then(p,d)}}function o(p,v){r[p]&&(s[p]=function(m){return new Promise(function(b,y){c.push([p,m,b,y])>1||u(p,m)})},v&&(s[p]=v(s[p])))}function u(p,v){try{l(r[p](v))}catch(m){h(c[0][3],m)}}function l(p){p.value instanceof Wl?Promise.resolve(p.value.v).then(a,d):h(c[0][2],p)}function a(p){u("next",p)}function d(p){u("throw",p)}function h(p,v){p(v),c.shift(),c.length&&u(c[0][0],c[0][1])}}function jP(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=t[Symbol.asyncIterator],n;return e?e.call(t):(t=typeof ac=="function"?ac(t):t[Symbol.iterator](),n={},r("next"),r("throw"),r("return"),n[Symbol.asyncIterator]=function(){return this},n);function r(c){n[c]=t[c]&&function(i){return new Promise(function(o,u){i=t[c](i),s(o,u,i.done,i.value)})}}function s(c,i,o,u){Promise.resolve(u).then(function(l){c({value:l,done:o})},i)}}function Cn(t){return typeof t=="function"}function U5(t){var e=function(r){Error.call(r),r.stack=new Error().stack},n=t(e);return n.prototype=Object.create(Error.prototype),n.prototype.constructor=n,n}var qv=U5(function(t){return function(e){t(this),this.message=e?e.length+` errors occurred during unsubscription:
|
|
6658
6658
|
`+e.map(function(n,r){return r+1+") "+n.toString()}).join(`
|
|
6659
|
-
`):"",this.name="UnsubscriptionError",this.errors=e}});function Rh(t,e){if(t){var n=t.indexOf(e);0<=n&&t.splice(n,1)}}var wd=function(){function t(e){this.initialTeardown=e,this.closed=!1,this._parentage=null,this._finalizers=null}return t.prototype.unsubscribe=function(){var e,n,r,s,c;if(!this.closed){this.closed=!0;var i=this._parentage;if(i)if(this._parentage=null,Array.isArray(i))try{for(var o=ac(i),u=o.next();!u.done;u=o.next()){var l=u.value;l.remove(this)}}catch(m){e={error:m}}finally{try{u&&!u.done&&(n=o.return)&&n.call(o)}finally{if(e)throw e.error}}else i.remove(this);var a=this.initialTeardown;if(Cn(a))try{a()}catch(m){c=m instanceof qv?m.errors:[m]}var d=this._finalizers;if(d){this._finalizers=null;try{for(var h=ac(d),p=h.next();!p.done;p=h.next()){var v=p.value;try{Y2(v)}catch(m){c=c??[],m instanceof qv?c=fa(fa([],_o(c)),_o(m.errors)):c.push(m)}}}catch(m){r={error:m}}finally{try{p&&!p.done&&(s=h.return)&&s.call(h)}finally{if(r)throw r.error}}}if(c)throw new qv(c)}},t.prototype.add=function(e){var n;if(e&&e!==this)if(this.closed)Y2(e);else{if(e instanceof t){if(e.closed||e._hasParent(this))return;e._addParent(this)}(this._finalizers=(n=this._finalizers)!==null&&n!==void 0?n:[]).push(e)}},t.prototype._hasParent=function(e){var n=this._parentage;return n===e||Array.isArray(n)&&n.includes(e)},t.prototype._addParent=function(e){var n=this._parentage;this._parentage=Array.isArray(n)?(n.push(e),n):n?[n,e]:e},t.prototype._removeParent=function(e){var n=this._parentage;n===e?this._parentage=null:Array.isArray(n)&&Rh(n,e)},t.prototype.remove=function(e){var n=this._finalizers;n&&Rh(n,e),e instanceof t&&e._removeParent(this)},t.EMPTY=function(){var e=new t;return e.closed=!0,e}(),t}(),V5=wd.EMPTY;function F5(t){return t instanceof wd||t&&"closed"in t&&Cn(t.remove)&&Cn(t.add)&&Cn(t.unsubscribe)}function Y2(t){Cn(t)?t():t.unsubscribe()}var kP={Promise:void 0},TP={setTimeout:function(t,e){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];return setTimeout.apply(void 0,fa([t,e],_o(n)))},clearTimeout:function(t){return clearTimeout(t)},delegate:void 0};function z5(t){TP.setTimeout(function(){throw t})}function sd(){}function ch(t){t()}var $0=function(t){va(e,t);function e(n){var r=t.call(this)||this;return r.isStopped=!1,n?(r.destination=n,F5(n)&&n.add(r)):r.destination=OP,r}return e.create=function(n,r,s){return new id(n,r,s)},e.prototype.next=function(n){this.isStopped||this._next(n)},e.prototype.error=function(n){this.isStopped||(this.isStopped=!0,this._error(n))},e.prototype.complete=function(){this.isStopped||(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(n){this.destination.next(n)},e.prototype._error=function(n){try{this.destination.error(n)}finally{this.unsubscribe()}},e.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},e}(wd),AP=function(){function t(e){this.partialObserver=e}return t.prototype.next=function(e){var n=this.partialObserver;if(n.next)try{n.next(e)}catch(r){zf(r)}},t.prototype.error=function(e){var n=this.partialObserver;if(n.error)try{n.error(e)}catch(r){zf(r)}else zf(e)},t.prototype.complete=function(){var e=this.partialObserver;if(e.complete)try{e.complete()}catch(n){zf(n)}},t}(),id=function(t){va(e,t);function e(n,r,s){var c=t.call(this)||this,i;return Cn(n)||!n?i={next:n??void 0,error:r??void 0,complete:s??void 0}:i=n,c.destination=new AP(i),c}return e}($0);function zf(t){z5(t)}function IP(t){throw t}var OP={closed:!0,next:sd,error:IP,complete:sd},U0=function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"}();function yp(t){return t}function RP(t){return t.length===0?yp:t.length===1?t[0]:function(e){return t.reduce(function(n,r){return r(n)},e)}}var ur=function(){function t(e){e&&(this._subscribe=e)}return t.prototype.lift=function(e){var n=new t;return n.source=this,n.operator=e,n},t.prototype.subscribe=function(e,n,r){var s=this,c=LP(e)?e:new id(e,n,r);return ch(function(){var i=s,o=i.operator,u=i.source;c.add(o?o.call(c,u):u?s._subscribe(c):s._trySubscribe(c))}),c},t.prototype._trySubscribe=function(e){try{return this._subscribe(e)}catch(n){e.error(n)}},t.prototype.forEach=function(e,n){var r=this;return n=X2(n),new n(function(s,c){var i=new id({next:function(o){try{e(o)}catch(u){c(u),i.unsubscribe()}},error:c,complete:s});r.subscribe(i)})},t.prototype._subscribe=function(e){var n;return(n=this.source)===null||n===void 0?void 0:n.subscribe(e)},t.prototype[U0]=function(){return this},t.prototype.pipe=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];return RP(e)(this)},t.prototype.toPromise=function(e){var n=this;return e=X2(e),new e(function(r,s){var c;n.subscribe(function(i){return c=i},function(i){return s(i)},function(){return r(c)})})},t.create=function(e){return new t(e)},t}();function X2(t){var e;return(e=t??kP.Promise)!==null&&e!==void 0?e:Promise}function NP(t){return t&&Cn(t.next)&&Cn(t.error)&&Cn(t.complete)}function LP(t){return t&&t instanceof $0||NP(t)&&F5(t)}function DP(t){return Cn(t==null?void 0:t.lift)}function $r(t){return function(e){if(DP(e))return e.lift(function(n){try{return t(n,this)}catch(r){this.error(r)}});throw new TypeError("Unable to lift unknown Observable type")}}function nr(t,e,n,r,s){return new MP(t,e,n,r,s)}var MP=function(t){va(e,t);function e(n,r,s,c,i,o){var u=t.call(this,n)||this;return u.onFinalize=i,u.shouldUnsubscribe=o,u._next=r?function(l){try{r(l)}catch(a){n.error(a)}}:t.prototype._next,u._error=c?function(l){try{c(l)}catch(a){n.error(a)}finally{this.unsubscribe()}}:t.prototype._error,u._complete=s?function(){try{s()}catch(l){n.error(l)}finally{this.unsubscribe()}}:t.prototype._complete,u}return e.prototype.unsubscribe=function(){var n;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var r=this.closed;t.prototype.unsubscribe.call(this),!r&&((n=this.onFinalize)===null||n===void 0||n.call(this))}},e}($0),PP=U5(function(t){return function(){t(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}}),Hs=function(t){va(e,t);function e(){var n=t.call(this)||this;return n.closed=!1,n.currentObservers=null,n.observers=[],n.isStopped=!1,n.hasError=!1,n.thrownError=null,n}return e.prototype.lift=function(n){var r=new q2(this,this);return r.operator=n,r},e.prototype._throwIfClosed=function(){if(this.closed)throw new PP},e.prototype.next=function(n){var r=this;ch(function(){var s,c;if(r._throwIfClosed(),!r.isStopped){r.currentObservers||(r.currentObservers=Array.from(r.observers));try{for(var i=ac(r.currentObservers),o=i.next();!o.done;o=i.next()){var u=o.value;u.next(n)}}catch(l){s={error:l}}finally{try{o&&!o.done&&(c=i.return)&&c.call(i)}finally{if(s)throw s.error}}}})},e.prototype.error=function(n){var r=this;ch(function(){if(r._throwIfClosed(),!r.isStopped){r.hasError=r.isStopped=!0,r.thrownError=n;for(var s=r.observers;s.length;)s.shift().error(n)}})},e.prototype.complete=function(){var n=this;ch(function(){if(n._throwIfClosed(),!n.isStopped){n.isStopped=!0;for(var r=n.observers;r.length;)r.shift().complete()}})},e.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(e.prototype,"observed",{get:function(){var n;return((n=this.observers)===null||n===void 0?void 0:n.length)>0},enumerable:!1,configurable:!0}),e.prototype._trySubscribe=function(n){return this._throwIfClosed(),t.prototype._trySubscribe.call(this,n)},e.prototype._subscribe=function(n){return this._throwIfClosed(),this._checkFinalizedStatuses(n),this._innerSubscribe(n)},e.prototype._innerSubscribe=function(n){var r=this,s=this,c=s.hasError,i=s.isStopped,o=s.observers;return c||i?V5:(this.currentObservers=null,o.push(n),new wd(function(){r.currentObservers=null,Rh(o,n)}))},e.prototype._checkFinalizedStatuses=function(n){var r=this,s=r.hasError,c=r.thrownError,i=r.isStopped;s?n.error(c):i&&n.complete()},e.prototype.asObservable=function(){var n=new ur;return n.source=this,n},e.create=function(n,r){return new q2(n,r)},e}(ur),q2=function(t){va(e,t);function e(n,r){var s=t.call(this)||this;return s.destination=n,s.source=r,s}return e.prototype.next=function(n){var r,s;(s=(r=this.destination)===null||r===void 0?void 0:r.next)===null||s===void 0||s.call(r,n)},e.prototype.error=function(n){var r,s;(s=(r=this.destination)===null||r===void 0?void 0:r.error)===null||s===void 0||s.call(r,n)},e.prototype.complete=function(){var n,r;(r=(n=this.destination)===null||n===void 0?void 0:n.complete)===null||r===void 0||r.call(n)},e.prototype._subscribe=function(n){var r,s;return(s=(r=this.source)===null||r===void 0?void 0:r.subscribe(n))!==null&&s!==void 0?s:V5},e}(Hs),BP={now:function(){return Date.now()}},$P=function(t){va(e,t);function e(n,r){return t.call(this)||this}return e.prototype.schedule=function(n,r){return this},e}(wd),J2={setInterval:function(t,e){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];return setInterval.apply(void 0,fa([t,e],_o(n)))},clearInterval:function(t){return clearInterval(t)},delegate:void 0},UP=function(t){va(e,t);function e(n,r){var s=t.call(this,n,r)||this;return s.scheduler=n,s.work=r,s.pending=!1,s}return e.prototype.schedule=function(n,r){var s;if(r===void 0&&(r=0),this.closed)return this;this.state=n;var c=this.id,i=this.scheduler;return c!=null&&(this.id=this.recycleAsyncId(i,c,r)),this.pending=!0,this.delay=r,this.id=(s=this.id)!==null&&s!==void 0?s:this.requestAsyncId(i,this.id,r),this},e.prototype.requestAsyncId=function(n,r,s){return s===void 0&&(s=0),J2.setInterval(n.flush.bind(n,this),s)},e.prototype.recycleAsyncId=function(n,r,s){if(s===void 0&&(s=0),s!=null&&this.delay===s&&this.pending===!1)return r;r!=null&&J2.clearInterval(r)},e.prototype.execute=function(n,r){if(this.closed)return new Error("executing a cancelled action");this.pending=!1;var s=this._execute(n,r);if(s)return s;this.pending===!1&&this.id!=null&&(this.id=this.recycleAsyncId(this.scheduler,this.id,null))},e.prototype._execute=function(n,r){var s=!1,c;try{this.work(n)}catch(i){s=!0,c=i||new Error("Scheduled action threw falsy error")}if(s)return this.unsubscribe(),c},e.prototype.unsubscribe=function(){if(!this.closed){var n=this,r=n.id,s=n.scheduler,c=s.actions;this.work=this.state=this.scheduler=null,this.pending=!1,Rh(c,this),r!=null&&(this.id=this.recycleAsyncId(s,r,null)),this.delay=null,t.prototype.unsubscribe.call(this)}},e}($P),Q2=function(){function t(e,n){n===void 0&&(n=t.now),this.schedulerActionCtor=e,this.now=n}return t.prototype.schedule=function(e,n,r){return n===void 0&&(n=0),new this.schedulerActionCtor(this,e).schedule(r,n)},t.now=BP.now,t}(),VP=function(t){va(e,t);function e(n,r){r===void 0&&(r=Q2.now);var s=t.call(this,n,r)||this;return s.actions=[],s._active=!1,s}return e.prototype.flush=function(n){var r=this.actions;if(this._active){r.push(n);return}var s;this._active=!0;do if(s=n.execute(n.state,n.delay))break;while(n=r.shift());if(this._active=!1,s){for(;n=r.shift();)n.unsubscribe();throw s}},e}(Q2),_p=new VP(UP),FP=_p,H5=new ur(function(t){return t.complete()});function G5(t){return t&&Cn(t.schedule)}function V0(t){return t[t.length-1]}function zP(t){return Cn(V0(t))?t.pop():void 0}function W5(t){return G5(V0(t))?t.pop():void 0}function HP(t,e){return typeof V0(t)=="number"?t.pop():e}var F0=function(t){return t&&typeof t.length=="number"&&typeof t!="function"};function Z5(t){return Cn(t==null?void 0:t.then)}function K5(t){return Cn(t[U0])}function Y5(t){return Symbol.asyncIterator&&Cn(t==null?void 0:t[Symbol.asyncIterator])}function X5(t){return new TypeError("You provided "+(t!==null&&typeof t=="object"?"an invalid object":"'"+t+"'")+" where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.")}function GP(){return typeof Symbol!="function"||!Symbol.iterator?"@@iterator":Symbol.iterator}var q5=GP();function J5(t){return Cn(t==null?void 0:t[q5])}function Q5(t){return EP(this,arguments,function(){var e,n,r,s;return $5(this,function(c){switch(c.label){case 0:e=t.getReader(),c.label=1;case 1:c.trys.push([1,,9,10]),c.label=2;case 2:return[4,Wl(e.read())];case 3:return n=c.sent(),r=n.value,s=n.done,s?[4,Wl(void 0)]:[3,5];case 4:return[2,c.sent()];case 5:return[4,Wl(r)];case 6:return[4,c.sent()];case 7:return c.sent(),[3,2];case 8:return[3,10];case 9:return e.releaseLock(),[7];case 10:return[2]}})})}function ek(t){return Cn(t==null?void 0:t.getReader)}function Ir(t){if(t instanceof ur)return t;if(t!=null){if(K5(t))return WP(t);if(F0(t))return ZP(t);if(Z5(t))return KP(t);if(Y5(t))return tk(t);if(J5(t))return YP(t);if(ek(t))return XP(t)}throw X5(t)}function WP(t){return new ur(function(e){var n=t[U0]();if(Cn(n.subscribe))return n.subscribe(e);throw new TypeError("Provided object does not correctly implement Symbol.observable")})}function ZP(t){return new ur(function(e){for(var n=0;n<t.length&&!e.closed;n++)e.next(t[n]);e.complete()})}function KP(t){return new ur(function(e){t.then(function(n){e.closed||(e.next(n),e.complete())},function(n){return e.error(n)}).then(null,z5)})}function YP(t){return new ur(function(e){var n,r;try{for(var s=ac(t),c=s.next();!c.done;c=s.next()){var i=c.value;if(e.next(i),e.closed)return}}catch(o){n={error:o}}finally{try{c&&!c.done&&(r=s.return)&&r.call(s)}finally{if(n)throw n.error}}e.complete()})}function tk(t){return new ur(function(e){qP(t,e).catch(function(n){return e.error(n)})})}function XP(t){return tk(Q5(t))}function qP(t,e){var n,r,s,c;return CP(this,void 0,void 0,function(){var i,o;return $5(this,function(u){switch(u.label){case 0:u.trys.push([0,5,6,11]),n=jP(t),u.label=1;case 1:return[4,n.next()];case 2:if(r=u.sent(),!!r.done)return[3,4];if(i=r.value,e.next(i),e.closed)return[2];u.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return o=u.sent(),s={error:o},[3,11];case 6:return u.trys.push([6,,9,10]),r&&!r.done&&(c=n.return)?[4,c.call(n)]:[3,8];case 7:u.sent(),u.label=8;case 8:return[3,10];case 9:if(s)throw s.error;return[7];case 10:return[7];case 11:return e.complete(),[2]}})})}function Za(t,e,n,r,s){r===void 0&&(r=0),s===void 0&&(s=!1);var c=e.schedule(function(){n(),s?t.add(this.schedule(null,r)):this.unsubscribe()},r);if(t.add(c),!s)return c}function nk(t,e){return e===void 0&&(e=0),$r(function(n,r){n.subscribe(nr(r,function(s){return Za(r,t,function(){return r.next(s)},e)},function(){return Za(r,t,function(){return r.complete()},e)},function(s){return Za(r,t,function(){return r.error(s)},e)}))})}function rk(t,e){return e===void 0&&(e=0),$r(function(n,r){r.add(t.schedule(function(){return n.subscribe(r)},e))})}function JP(t,e){return Ir(t).pipe(rk(e),nk(e))}function QP(t,e){return Ir(t).pipe(rk(e),nk(e))}function eB(t,e){return new ur(function(n){var r=0;return e.schedule(function(){r===t.length?n.complete():(n.next(t[r++]),n.closed||this.schedule())})})}function tB(t,e){return new ur(function(n){var r;return Za(n,e,function(){r=t[q5](),Za(n,e,function(){var s,c,i;try{s=r.next(),c=s.value,i=s.done}catch(o){n.error(o);return}i?n.complete():n.next(c)},0,!0)}),function(){return Cn(r==null?void 0:r.return)&&r.return()}})}function sk(t,e){if(!t)throw new Error("Iterable cannot be null");return new ur(function(n){Za(n,e,function(){var r=t[Symbol.asyncIterator]();Za(n,e,function(){r.next().then(function(s){s.done?n.complete():n.next(s.value)})},0,!0)})})}function nB(t,e){return sk(Q5(t),e)}function rB(t,e){if(t!=null){if(K5(t))return JP(t,e);if(F0(t))return eB(t,e);if(Z5(t))return QP(t,e);if(Y5(t))return sk(t,e);if(J5(t))return tB(t,e);if(ek(t))return nB(t,e)}throw X5(t)}function ik(t,e){return e?rB(t,e):Ir(t)}function sB(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=W5(t);return ik(t,n)}function iB(t){return t instanceof Date&&!isNaN(t)}function zs(t,e){return $r(function(n,r){var s=0;n.subscribe(nr(r,function(c){r.next(t.call(e,c,s++))}))})}var oB=Array.isArray;function aB(t,e){return oB(e)?t.apply(void 0,fa([],_o(e))):t(e)}function lB(t){return zs(function(e){return aB(t,e)})}function cB(t,e,n,r,s,c,i,o){var u=[],l=0,a=0,d=!1,h=function(){d&&!u.length&&!l&&e.complete()},p=function(m){return l<r?v(m):u.push(m)},v=function(m){l++;var b=!1;Ir(n(m,a++)).subscribe(nr(e,function(y){e.next(y)},function(){b=!0},void 0,function(){if(b)try{l--;for(var y=function(){var _=u.shift();i||v(_)};u.length&&l<r;)y();h()}catch(_){e.error(_)}}))};return t.subscribe(nr(e,p,function(){d=!0,h()})),function(){}}function Ha(t,e,n){return n===void 0&&(n=1/0),Cn(e)?Ha(function(r,s){return zs(function(c,i){return e(r,c,s,i)})(Ir(t(r,s)))},n):(typeof e=="number"&&(n=e),$r(function(r,s){return cB(r,s,t,n)}))}function uB(t){return t===void 0&&(t=1/0),Ha(yp,t)}function dB(t){return new ur(function(e){Ir(t()).subscribe(e)})}var fB={connector:function(){return new Hs},resetOnDisconnect:!0};function Va(t,e){e===void 0&&(e=fB);var n=null,r=e.connector,s=e.resetOnDisconnect,c=s===void 0?!0:s,i=r(),o=new ur(function(u){return i.subscribe(u)});return o.connect=function(){return(!n||n.closed)&&(n=dB(function(){return t}).subscribe(i),c&&n.add(function(){return i=r()})),n},o}var hB=["addListener","removeListener"],pB=["addEventListener","removeEventListener"],mB=["on","off"];function Jg(t,e,n,r){if(Cn(n)&&(r=n,n=void 0),r)return Jg(t,e,n).pipe(lB(r));var s=_o(bB(t)?pB.map(function(o){return function(u){return t[o](e,u,n)}}):vB(t)?hB.map(ex(t,e)):gB(t)?mB.map(ex(t,e)):[],2),c=s[0],i=s[1];if(!c&&F0(t))return Ha(function(o){return Jg(o,e,n)})(Ir(t));if(!c)throw new TypeError("Invalid event target");return new ur(function(o){var u=function(){for(var l=[],a=0;a<arguments.length;a++)l[a]=arguments[a];return o.next(1<l.length?l:l[0])};return c(u),function(){return i(u)}})}function ex(t,e){return function(n){return function(r){return t[n](e,r)}}}function vB(t){return Cn(t.addListener)&&Cn(t.removeListener)}function gB(t){return Cn(t.on)&&Cn(t.off)}function bB(t){return Cn(t.addEventListener)&&Cn(t.removeEventListener)}function Du(t,e,n){t===void 0&&(t=0),n===void 0&&(n=FP);var r=-1;return e!=null&&(G5(e)?n=e:r=e),new ur(function(s){var c=iB(t)?+t-n.now():t;c<0&&(c=0);var i=0;return n.schedule(function(){s.closed||(s.next(i++),0<=r?this.schedule(void 0,r):s.complete())},c)})}function yB(t,e){return e===void 0&&(e=_p),Du(t,t,e)}function _B(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=W5(t),r=HP(t,1/0),s=t;return s.length?s.length===1?Ir(s[0]):uB(r)(ik(s,n)):H5}var wB=Array.isArray;function SB(t){return t.length===1&&wB(t[0])?t[0]:t}function ra(t,e){return $r(function(n,r){var s=0;n.subscribe(nr(r,function(c){return t.call(e,c,s++)&&r.next(c)}))})}function xB(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return t=SB(t),t.length===1?Ir(t[0]):new ur(CB(t))}function CB(t){return function(e){for(var n=[],r=function(c){n.push(Ir(t[c]).subscribe(nr(e,function(i){if(n){for(var o=0;o<n.length;o++)o!==c&&n[o].unsubscribe();n=null}e.next(i)})))},s=0;n&&!e.closed&&s<t.length;s++)r(s)}}function EB(t){return $r(function(e,n){var r=null,s=null,c=function(){s==null||s.unsubscribe();var i=r;r=[],i&&n.next(i),Ir(t()).subscribe(s=nr(n,c,sd))};c(),e.subscribe(nr(n,function(i){return r==null?void 0:r.push(i)},function(){r&&n.next(r),n.complete()},void 0,function(){return r=s=null}))})}function ok(t){return $r(function(e,n){var r=null,s=!1,c;r=e.subscribe(nr(n,void 0,void 0,function(i){c=Ir(t(i,ok(t)(e))),r?(r.unsubscribe(),r=null,c.subscribe(n)):s=!0})),s&&(r.unsubscribe(),r=null,c.subscribe(n))})}function jB(t,e,n,r,s){return function(c,i){var o=n,u=e,l=0;c.subscribe(nr(i,function(a){var d=l++;u=o?t(u,a,d):(o=!0,a),i.next(u)},s))}}function tx(t){return t<=0?function(){return H5}:$r(function(e,n){var r=0;e.subscribe(nr(n,function(s){++r<=t&&(n.next(s),t<=r&&n.complete())}))})}function kB(t){return $r(function(e,n){try{e.subscribe(n)}finally{n.add(t)}})}function TB(t,e){return $r(jB(t,e,arguments.length>=2,!0))}function AB(t){t===void 0&&(t={});var e=t.connector,n=e===void 0?function(){return new Hs}:e,r=t.resetOnError,s=r===void 0?!0:r,c=t.resetOnComplete,i=c===void 0?!0:c,o=t.resetOnRefCountZero,u=o===void 0?!0:o;return function(l){var a,d,h,p=0,v=!1,m=!1,b=function(){d==null||d.unsubscribe(),d=void 0},y=function(){b(),a=h=void 0,v=m=!1},_=function(){var S=a;y(),S==null||S.unsubscribe()};return $r(function(S,x){p++,!m&&!v&&b();var C=h=h??n();x.add(function(){p--,p===0&&!m&&!v&&(d=Jv(_,u))}),C.subscribe(x),!a&&p>0&&(a=new id({next:function(j){return C.next(j)},error:function(j){m=!0,b(),d=Jv(y,s,j),C.error(j)},complete:function(){v=!0,b(),d=Jv(y,i),C.complete()}}),Ir(S).subscribe(a))})(l)}}function Jv(t,e){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];if(e===!0){t();return}if(e!==!1){var s=new id({next:function(){s.unsubscribe(),t()}});return Ir(e.apply(void 0,fa([],_o(n)))).subscribe(s)}}function IB(t){return $r(function(e,n){var r=!1,s=nr(n,function(){s==null||s.unsubscribe(),r=!0},sd);Ir(t).subscribe(s),e.subscribe(nr(n,function(c){return r&&n.next(c)}))})}function nx(t,e){return $r(function(n,r){var s=null,c=0,i=!1,o=function(){return i&&!s&&r.complete()};n.subscribe(nr(r,function(u){s==null||s.unsubscribe();var l=0,a=c++;Ir(t(u,a)).subscribe(s=nr(r,function(d){return r.next(e?e(u,d,a,l++):d)},function(){s=null,o()}))},function(){i=!0,o()}))})}function Hf(t,e){return e===void 0&&(e=!1),$r(function(n,r){var s=0;n.subscribe(nr(r,function(c){var i=t(c,s++);(i||e)&&r.next(c),!i&&r.complete()}))})}function OB(t,e,n){var r=Cn(t)||e||n?{next:t,error:e,complete:n}:t;return r?$r(function(s,c){var i;(i=r.subscribe)===null||i===void 0||i.call(r);var o=!0;s.subscribe(nr(c,function(u){var l;(l=r.next)===null||l===void 0||l.call(r,u),c.next(u)},function(){var u;o=!1,(u=r.complete)===null||u===void 0||u.call(r),c.complete()},function(u){var l;o=!1,(l=r.error)===null||l===void 0||l.call(r,u),c.error(u)},function(){var u,l;o&&((u=r.unsubscribe)===null||u===void 0||u.call(r)),(l=r.finalize)===null||l===void 0||l.call(r)}))}):yp}function RB(t,e){return $r(function(n,r){var s=e??{},c=s.leading,i=c===void 0?!0:c,o=s.trailing,u=o===void 0?!1:o,l=!1,a=null,d=null,h=!1,p=function(){d==null||d.unsubscribe(),d=null,u&&(b(),h&&r.complete())},v=function(){d=null,h&&r.complete()},m=function(y){return d=Ir(t(y)).subscribe(nr(r,p,v))},b=function(){if(l){l=!1;var y=a;a=null,r.next(y),!h&&m(y)}};n.subscribe(nr(r,function(y){l=!0,a=y,!(d&&!d.closed)&&(i?b():m(y))},function(){h=!0,!(u&&l&&d&&!d.closed)&&r.complete()}))})}function rx(t,e,n){e===void 0&&(e=_p);var r=Du(t,e);return RB(function(){return r},n)}function Qv(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=zP(t);return $r(function(r,s){for(var c=t.length,i=new Array(c),o=t.map(function(){return!1}),u=!1,l=function(d){Ir(t[d]).subscribe(nr(s,function(h){i[d]=h,!u&&!o[d]&&(o[d]=!0,(u=o.every(yp))&&(o=null))},sd))},a=0;a<c;a++)l(a);r.subscribe(nr(s,function(d){if(u){var h=fa([d],_o(i));s.next(n?n.apply(void 0,fa([],_o(h))):h)}}))})}const ak="0123456789ABCDEFGHJKMNPQRSTVWXYZ",Nh=32,NB=16,lk=10,sx=0xffffffffffff;var Ga;(function(t){t.Base32IncorrectEncoding="B32_ENC_INVALID",t.DecodeTimeInvalidCharacter="DEC_TIME_CHAR",t.DecodeTimeValueMalformed="DEC_TIME_MALFORMED",t.EncodeTimeNegative="ENC_TIME_NEG",t.EncodeTimeSizeExceeded="ENC_TIME_SIZE_EXCEED",t.EncodeTimeValueMalformed="ENC_TIME_MALFORMED",t.PRNGDetectFailure="PRNG_DETECT",t.ULIDInvalid="ULID_INVALID",t.Unexpected="UNEXPECTED",t.UUIDInvalid="UUID_INVALID"})(Ga||(Ga={}));class Eu extends Error{constructor(e,n){super(`${n} (${e})`),this.name="ULIDError",this.code=e}}function LB(t){const e=Math.floor(t()*Nh)%Nh;return ak.charAt(e)}function DB(t){const e=MB(),n=e&&(e.crypto||e.msCrypto)||null;if(typeof(n==null?void 0:n.getRandomValues)=="function")return()=>{const r=new Uint8Array(1);return n.getRandomValues(r),r[0]/255};if(typeof(n==null?void 0:n.randomBytes)=="function")return()=>n.randomBytes(1).readUInt8()/255;throw new Eu(Ga.PRNGDetectFailure,"Failed to find a reliable PRNG")}function MB(){return $B()?self:typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:null}function PB(t,e){let n="";for(;t>0;t--)n=LB(e)+n;return n}function BB(t,e=lk){if(isNaN(t))throw new Eu(Ga.EncodeTimeValueMalformed,`Time must be a number: ${t}`);if(t>sx)throw new Eu(Ga.EncodeTimeSizeExceeded,`Cannot encode a time larger than ${sx}: ${t}`);if(t<0)throw new Eu(Ga.EncodeTimeNegative,`Time must be positive: ${t}`);if(Number.isInteger(t)===!1)throw new Eu(Ga.EncodeTimeValueMalformed,`Time must be an integer: ${t}`);let n,r="";for(let s=e;s>0;s--)n=t%Nh,r=ak.charAt(n)+r,t=(t-n)/Nh;return r}function $B(){return typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope}function UB(t,e){const n=DB(),r=Date.now();return BB(r,lk)+PB(NB,n)}const Pr=[];for(let t=0;t<256;++t)Pr.push((t+256).toString(16).slice(1));function VB(t,e=0){return(Pr[t[e+0]]+Pr[t[e+1]]+Pr[t[e+2]]+Pr[t[e+3]]+"-"+Pr[t[e+4]]+Pr[t[e+5]]+"-"+Pr[t[e+6]]+Pr[t[e+7]]+"-"+Pr[t[e+8]]+Pr[t[e+9]]+"-"+Pr[t[e+10]]+Pr[t[e+11]]+Pr[t[e+12]]+Pr[t[e+13]]+Pr[t[e+14]]+Pr[t[e+15]]).toLowerCase()}let eg;const FB=new Uint8Array(16);function zB(){if(!eg){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");eg=crypto.getRandomValues.bind(crypto)}return eg(FB)}const HB=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),ix={randomUUID:HB};function GB(t,e,n){var r;if(ix.randomUUID&&!t)return ix.randomUUID();t=t||{};const s=t.random??((r=t.rng)==null?void 0:r.call(t))??zB();if(s.length<16)throw new Error("Random bytes length must be >= 16");return s[6]=s[6]&15|64,s[8]=s[8]&63|128,VB(s)}const WB=5e3,ZB=1e3,Gf=4e3,ox=1e3;var ck=(t=>(t.CONTINUOUS="CONTINUOUS",t.INITIAL="INITIAL",t))(ck||{});class uk{constructor({knownID:e,runID:n,sequence:r,options:s}){Ln(this,"callback"),Ln(this,"queue",new Hs),Ln(this,"subscriptions",[]),Ln(this,"reconnect",new Hs),Ln(this,"client",new ur),Ln(this,"_latencies",new Hs),Ln(this,"_latenciesConnectable",Va(this._latencies.asObservable().pipe(TB((c,i)=>{if(i.latency<0){const o=c.get(i.streamID);o&&c.set(i.streamID,{...o,readyState:i.readyState})}else c.set(i.streamID,i);return c},new Map)))),Ln(this,"_errors",new Hs),Ln(this,"_errorsConnectable",Va(this._errors.asObservable())),Ln(this,"_stdout",new Hs),Ln(this,"_stderr",new Hs),Ln(this,"_exitCode",new Hs),Ln(this,"_pid",new Hs),Ln(this,"_mimeType",new Hs),Ln(this,"_stdoutConnectable",Va(this._stdout.asObservable())),Ln(this,"_stderrConnectable",Va(this._stderr.asObservable())),Ln(this,"_exitCodeConnectable",Va(this._exitCode.asObservable())),Ln(this,"_pidConnectable",Va(this._pid.asObservable())),Ln(this,"_mimeTypeConnectable",Va(this._mimeType.asObservable())),Ln(this,"knownID"),Ln(this,"runID"),Ln(this,"sequence"),Ln(this,"runnerEndpoint"),Ln(this,"interceptors"),Ln(this,"autoReconnect"),this.knownID=e,this.runID=n,this.sequence=r,this.runnerEndpoint=s.runnerEndpoint,this.interceptors=s.interceptors,this.autoReconnect=s.autoReconnect,this._latenciesConnectable.connect(),this._errorsConnectable.connect(),this._stdoutConnectable.connect(),this._stderrConnectable.connect(),this._exitCodeConnectable.connect(),this._pidConnectable.connect(),this._mimeTypeConnectable.connect(),this.client=this.reconnect.pipe(rx(ox,_p,{leading:!0,trailing:!0}),nx(c=>this.useSocketClient(c.streamID).pipe(nx(i=>this.useHeartbeat(i,c))))).pipe(AB()),this.subscriptions.push(this.monitor()),this.subscriptions.push(this.process())}get latencies(){return this._latenciesConnectable}get errors(){return this._errorsConnectable}get stdout(){return this._stdoutConnectable}get stderr(){return this._stderrConnectable}get exitCode(){return this._exitCodeConnectable}get pid(){return this._pidConnectable}get mimeType(){return this._mimeTypeConnectable}monitor(){return yB(ZB).pipe(ra(()=>this.autoReconnect),Qv(this.reconnect),ra(([,e])=>e.heartbeat==="CONTINUOUS"),Qv(this.latencies),zs(([,e])=>Array.from(e.values()).filter(n=>n.readyState===WebSocket.OPEN&&n.latency>=Gf)),ra(e=>e.length>0),rx(ox)).subscribe({next:e=>{console.log(new Date,"Triggering reconnect",e),this.connect()},complete:()=>{console.log("Monitor complete")},error:e=>{console.error("Error in monitor",e)}})}process(){const e=this.client.pipe(ra(s=>(s==null?void 0:s.readyState)===WebSocket.OPEN),tx(1)),n=this.queue.pipe(EB(()=>e),ra(s=>s.length>0),zs(s=>s.sort((c,i)=>{const o=u=>{var l;return!!((l=u.payload.value)!=null&&l.config)};return o(i)?1:o(c)?-1:0}))),r=this.queue.pipe(IB(e));return _B(n.pipe(Ha(s=>s)),r).pipe(Qv(this.client),Hf(([,s])=>s.readyState===WebSocket.OPEN),Ha(async([s,c])=>{await lx({req:s,interceptors:this.interceptors,socket:c,knownID:this.knownID,runID:this.runID})})).subscribe({error:s=>{this._errors.next(s)}})}useSocketClient(e){return new ur(n=>{const r=new URL(this.runnerEndpoint);r.searchParams.set("id",e),r.searchParams.set("runID",this.runID);const s=new WebSocket(r.toString()),c=l=>{if(console.log(new Date,`WebSocket transport ${e} closed`,l),l.code===1005){n.complete();return}if(this.autoReconnect){this.connect();return}},i=l=>{console.log(new Date,`WebSocket transport ${e} error`,l),this.autoReconnect||n.error(l)},o=l=>{var a,d;if(typeof l.data!="string"){console.warn("Unexpected WebSocket message type:",typeof l.data);return}let h;try{h=ax(l.data),console.log("Received WebsocketResponse:",h)}catch(m){console.error("Failed to parse WebsocketResponse:",m)}const p=h.status;if(p&&p.code!==SP.OK){n.error(p);return}if(h.pong)return;const v=h.payload.value;if(v.stdoutData&&v.stdoutData.length>0&&((a=this.callback)==null||a.call(this,{type:Lu.terminalStdout,output:{"runme.dev/id":this.knownID,data:v.stdoutData}}),this._stdout.next(v.stdoutData)),v.stderrData&&v.stderrData.length>0&&((d=this.callback)==null||d.call(this,{type:Lu.terminalStderr,output:{"runme.dev/id":this.knownID,data:v.stderrData}}),this._stderr.next(v.stderrData)),v.exitCode!==void 0&&(this._exitCode.next(v.exitCode),n.complete()),v.pid!==void 0&&this._pid.next(v.pid),v.mimeType){const m=v.mimeType.split(";")[0];this._mimeType.next(m)}},u=()=>{console.log(new Date,`✅ Connected WebSocket for cell ${this.knownID} (#${this.sequence}) with runID ${this.runID}`),n.next(s)};return s.addEventListener("close",c),s.addEventListener("error",i),s.addEventListener("message",o),s.addEventListener("open",u),()=>{console.log(new Date,`☑️ Cleanly disconnected WebSocket for cell ${this.knownID} (#${this.sequence}) with runID ${this.runID}`),s.removeEventListener("close",c),s.removeEventListener("error",i),s.removeEventListener("message",o),s.removeEventListener("open",u),s.close()}})}setCallback(e){this.callback=e}sendExecuteRequest(e){this.queue.next(qt(Xg,{payload:{value:e,case:"executeRequest"}}))}useHeartbeat(e,{streamID:n,heartbeat:r}){return new ur(s=>{const c=Jg(e,"message").pipe(Hf(()=>e.readyState===WebSocket.OPEN),zs(u=>ax(u.data)),zs(u=>u.pong),ra(u=>u!==void 0),zs(u=>({receivedAt:BigInt(Date.now()),pong:u}))),i=(r==="INITIAL"?Du(0):Du(0,WB)).pipe(Hf(()=>e.readyState===WebSocket.OPEN),zs(()=>{const u={timestamp:BigInt(Date.now())};return qt(Xg,{ping:u})}),Ha(async u=>(await lx({req:u,interceptors:this.interceptors,socket:e}),u)),zs(u=>u.ping)).pipe(ra(u=>(u==null?void 0:u.timestamp)!==void 0),Ha(u=>xB(c.pipe(ra(l=>l.pong.timestamp===u.timestamp),tx(1),zs(l=>{const a=u.timestamp,d=l.receivedAt;return Number(d-a)})),Du(Gf).pipe(zs(()=>{throw new Error(`Pong not received within ${Gf}ms for stream ${n}`)}))).pipe(ok(l=>(this._latencies.next({streamID:n,latency:Gf,readyState:e.readyState,updatedAt:BigInt(Date.now())}),console.log(new Date,"Ping deadline exceeded",l.message),sB(null))))),kB(()=>{this._latencies.next({streamID:n,latency:-1,readyState:e.readyState,updatedAt:BigInt(Date.now())})}),OB(u=>{u!==null&&this._latencies.next({streamID:n,latency:u,readyState:e.readyState,updatedAt:BigInt(Date.now())})})),o=[];return o.push(i.subscribe({error:u=>{console.error("Unexpected error sending heartbeat",u)}})),s.next(e),()=>{o.forEach(u=>u.unsubscribe())}})}connect(e="CONTINUOUS"){const n=KB(),r=this.latencies.pipe(zs(s=>{const c=s.get(n);return c===void 0?null:c}),Hf(s=>(s==null?void 0:s.readyState)===WebSocket.OPEN));return this.reconnect.next({streamID:n,heartbeat:e}),r}close(){this.reconnect.complete(),this.queue.complete(),this._latencies.complete(),this.subscriptions.forEach(e=>e.unsubscribe())}}function ax(t){const e=JSON.parse(t);return b0(xP,e)}async function lx({req:t,interceptors:e,socket:n,knownID:r,runID:s}){r&&(t.knownId=r),s&&(t.runId=s);const c={stream:!1,message:{},method:{},service:{},requestMethod:"UPGRADE",url:n.url,signal:new AbortController().signal,header:new Headers,contextValues:{}};let i=async u=>({stream:!1,message:{},method:{},service:{},header:u.header});for(const u of e.concat().reverse())i=u(i);const o=(await i(c)).header.get("Authorization");o&&t&&(t.authorization=o),n.send(JSON.stringify(U3(Xg,t)))}function KB(){return GB().replace(/-/g,"")}function dk(){return`run_${UB()}`}function YB({cellID:t,runID:e,sequence:n,commands:r,content:s,runner:c,settings:i={},onStdout:o,onStderr:u,onExitCode:l,onPid:a,onMimeType:d}){var h;const{rows:p=20,className:v,fontSize:m=12,fontFamily:b="monospace",takeFocus:y=!0,scrollToFit:_=!0}=i,S=B.useMemo(()=>!t||s===""?null:s,[t,s]),x=B.useMemo(()=>{if(!(!t||!e||!c.endpoint))return console.log("Creating stream",t,e,c.endpoint),new uk({knownID:t,runID:e,sequence:n,options:{runnerEndpoint:c.endpoint,interceptors:c.interceptors,autoReconnect:c.reconnect}})},[t,e,n,c]);B.useEffect(()=>{const N=x==null?void 0:x.connect().subscribe(D=>console.log(`Heartbeat latency for streamID ${D==null?void 0:D.streamID} (${(D==null?void 0:D.readyState)===1?"open":"closed"}): ${D==null?void 0:D.latency}ms`));return()=>{N==null||N.unsubscribe(),x==null||x.close()}},[x]);let C=qt(Z2,{rows:34,cols:100,x:0,y:0});const j=B.useMemo(()=>qt(Xv,{sessionStrategy:bP.MOST_RECENT,storeStdoutInEnv:!0,config:{languageId:"sh",background:!1,fileExtension:"",env:[`RUNME_ID=${t}`,"RUNME_RUNNER=v2","TERM=xterm-256color"],source:{case:"commands",value:{items:r}},interactive:!0,mode:vP.INLINE,runId:e,knownId:t},winsize:C}),[t,e,r,C]),k=B.useMemo(()=>{var N;return{output:{"runme.dev/id":(N=j.config)==null?void 0:N.knownId,fontFamily:b||"monospace",fontSize:m||12,cursorStyle:"block",cursorBlink:!0,cursorWidth:1,takeFocus:y,scrollToFit:_,smoothScrollDuration:0,scrollback:4e3,initialRows:p,content:S||"",isAutoSaveEnabled:!1,isPlatformAuthEnabled:!1}}},[(h=j.config)==null?void 0:h.knownId,b,m,y,_,p,S]),A=new TextEncoder;return _P({postMessage:N=>{if(N.type===Lu.terminalOpen||N.type===Lu.terminalResize){const D=Number(N.output.terminalDimensions.columns),M=Number(N.output.terminalDimensions.rows);if(Number.isFinite(D)&&Number.isFinite(M)){if(C.cols===D&&C.rows===M)return;C=qt(Z2,{cols:D,rows:M,x:0,y:0});const U=qt(Xv,{winsize:C});x==null||x.sendExecuteRequest(U)}}if(N.type===Lu.terminalStdin){const D=A.encode(N.output.input),M=qt(Xv,{inputData:D});x==null||x.sendExecuteRequest(M)}},onDidReceiveMessage:N=>{x==null||x.setCallback(N)}}),B.useEffect(()=>{const N=x==null?void 0:x.stdout.subscribe(D=>{o==null||o(D)});return()=>N==null?void 0:N.unsubscribe()},[x,o]),B.useEffect(()=>{const N=x==null?void 0:x.stderr.subscribe(D=>{u==null||u(D)});return()=>N==null?void 0:N.unsubscribe()},[x,u]),B.useEffect(()=>{const N=x==null?void 0:x.exitCode.subscribe(D=>{l==null||l(D),x==null||x.close()});return()=>N==null?void 0:N.unsubscribe()},[x,l]),B.useEffect(()=>{const N=x==null?void 0:x.pid.subscribe(D=>{a==null||a(D)});return()=>N==null?void 0:N.unsubscribe()},[x,a]),B.useEffect(()=>{const N=x==null?void 0:x.mimeType.subscribe(D=>{d==null||d(D)});return()=>N==null?void 0:N.unsubscribe()},[x,d]),B.useEffect(()=>{!x||!j||(console.log("useEffect invoked - Commands changed:",JSON.stringify(j.config.source.value)),x==null||x.sendExecuteRequest(j))},[j,x]),ie.jsx("div",{className:v,ref:N=>{if(!N||N.hasChildNodes())return;const D=document.createElement("terminal-view");D.setAttribute("buttons","false"),D.setAttribute("id",k.output["runme.dev/id"]),D.setAttribute("fontFamily",k.output.fontFamily),typeof k.output.fontSize=="number"&&D.setAttribute("fontSize",k.output.fontSize.toString()),k.output.cursorStyle&&D.setAttribute("cursorStyle",k.output.cursorStyle),typeof k.output.cursorBlink=="boolean"&&D.setAttribute("cursorBlink",k.output.cursorBlink?"true":"false"),typeof k.output.cursorWidth=="number"&&D.setAttribute("cursorWidth",k.output.cursorWidth.toString()),typeof k.output.takeFocus=="boolean"&&D.setAttribute("takeFocus",k.output.takeFocus?"true":"false"),typeof k.output.smoothScrollDuration=="number"&&D.setAttribute("smoothScrollDuration",k.output.smoothScrollDuration.toString()),typeof k.output.scrollback=="number"&&D.setAttribute("scrollback",k.output.scrollback.toString()),k.output.initialRows!==void 0&&D.setAttribute("initialRows",k.output.initialRows.toString()),k.output.content!==void 0&&D.setAttribute("initialContent",k.output.content),k.output.isAutoSaveEnabled&&D.setAttribute("isAutoSaveEnabled",k.output.isAutoSaveEnabled.toString()),k.output.isPlatformAuthEnabled&&D.setAttribute("isPlatformAuthEnabled",k.output.isPlatformAuthEnabled.toString()),N.appendChild(D);const M=document.createElement("div");M.setAttribute("className","h-1"),N.appendChild(M),setTimeout(()=>{_&&!XB(M)&&M.scrollIntoView({behavior:"smooth"})},0)}})}function XB(t){const e=t.getBoundingClientRect();return e.top>=0&&e.left>=0&&e.bottom<=(window.innerHeight||document.documentElement.clientHeight)&&e.right<=(window.innerWidth||document.documentElement.clientWidth)}class ju extends Error{}ju.prototype.name="InvalidTokenError";function qB(t){return decodeURIComponent(atob(t).replace(/(.)/g,(e,n)=>{let r=n.charCodeAt(0).toString(16).toUpperCase();return r.length<2&&(r="0"+r),"%"+r}))}function JB(t){let e=t.replace(/-/g,"+").replace(/_/g,"/");switch(e.length%4){case 0:break;case 2:e+="==";break;case 3:e+="=";break;default:throw new Error("base64 string is not of the correct length")}try{return qB(e)}catch{return atob(e)}}function fk(t,e){if(typeof t!="string")throw new ju("Invalid token specified: must be a string");e||(e={});const n=e.header===!0?0:1,r=t.split(".")[n];if(typeof r!="string")throw new ju(`Invalid token specified: missing part #${n+1}`);let s;try{s=JB(r)}catch(c){throw new ju(`Invalid token specified: invalid base64 for part #${n+1} (${c.message})`)}try{return JSON.parse(s)}catch(c){throw new ju(`Invalid token specified: invalid json for part #${n+1} (${c.message})`)}}const hk="0123456789ABCDEFGHJKMNPQRSTVWXYZ",Lh=32,QB=16,pk=10,cx=0xffffffffffff;var Wa;(function(t){t.Base32IncorrectEncoding="B32_ENC_INVALID",t.DecodeTimeInvalidCharacter="DEC_TIME_CHAR",t.DecodeTimeValueMalformed="DEC_TIME_MALFORMED",t.EncodeTimeNegative="ENC_TIME_NEG",t.EncodeTimeSizeExceeded="ENC_TIME_SIZE_EXCEED",t.EncodeTimeValueMalformed="ENC_TIME_MALFORMED",t.PRNGDetectFailure="PRNG_DETECT",t.ULIDInvalid="ULID_INVALID",t.Unexpected="UNEXPECTED",t.UUIDInvalid="UUID_INVALID"})(Wa||(Wa={}));class ku extends Error{constructor(e,n){super(`${n} (${e})`),this.name="ULIDError",this.code=e}}function e$(t){const e=Math.floor(t()*Lh)%Lh;return hk.charAt(e)}function t$(t){const e=n$(),n=e&&(e.crypto||e.msCrypto)||null;if(typeof(n==null?void 0:n.getRandomValues)=="function")return()=>{const r=new Uint8Array(1);return n.getRandomValues(r),r[0]/255};if(typeof(n==null?void 0:n.randomBytes)=="function")return()=>n.randomBytes(1).readUInt8()/255;throw new ku(Wa.PRNGDetectFailure,"Failed to find a reliable PRNG")}function n$(){return i$()?self:typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:null}function r$(t,e){let n="";for(;t>0;t--)n=e$(e)+n;return n}function s$(t,e=pk){if(isNaN(t))throw new ku(Wa.EncodeTimeValueMalformed,`Time must be a number: ${t}`);if(t>cx)throw new ku(Wa.EncodeTimeSizeExceeded,`Cannot encode a time larger than ${cx}: ${t}`);if(t<0)throw new ku(Wa.EncodeTimeNegative,`Time must be positive: ${t}`);if(Number.isInteger(t)===!1)throw new ku(Wa.EncodeTimeValueMalformed,`Time must be an integer: ${t}`);let n,r="";for(let s=e;s>0;s--)n=t%Lh,r=hk.charAt(n)+r,t=(t-n)/Lh;return r}function i$(){return typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope}function o$(t,e){const n=t$(),r=Date.now();return s$(r,pk)+r$(QB,n)}const a$=Ys("ChphZ2VudC92MS9jcmVkZW50aWFscy5wcm90bxIIYWdlbnQudjEioQEKCk9BdXRoVG9rZW4SFAoMYWNjZXNzX3Rva2VuGAEgASgJEhIKCnRva2VuX3R5cGUYAiABKAkSFQoNcmVmcmVzaF90b2tlbhgDIAEoCRISCgpleHBpcmVzX2F0GAQgASgDEioKBmV4cGlyeRgFIAEoCzIaLmdvb2dsZS5wcm90b2J1Zi5UaW1lc3RhbXASEgoKZXhwaXJlc19pbhgGIAEoA0JAWj5naXRodWIuY29tL3J1bm1lZGV2L3J1bm1lL3YzL2FwaS9nZW4vcHJvdG8vZ28vYWdlbnQvdjE7YWdlbnR2MWIGcHJvdG8z",[NL]),ux=Wn(a$,0);/*! js-cookie v3.0.5 | MIT */function Wf(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)t[r]=n[r]}return t}var l$={read:function(t){return t[0]==='"'&&(t=t.slice(1,-1)),t.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent)},write:function(t){return encodeURIComponent(t).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,decodeURIComponent)}};function Qg(t,e){function n(s,c,i){if(!(typeof document>"u")){i=Wf({},e,i),typeof i.expires=="number"&&(i.expires=new Date(Date.now()+i.expires*864e5)),i.expires&&(i.expires=i.expires.toUTCString()),s=encodeURIComponent(s).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var o="";for(var u in i)i[u]&&(o+="; "+u,i[u]!==!0&&(o+="="+i[u].split(";")[0]));return document.cookie=s+"="+t.write(c,s)+o}}function r(s){if(!(typeof document>"u"||arguments.length&&!s)){for(var c=document.cookie?document.cookie.split("; "):[],i={},o=0;o<c.length;o++){var u=c[o].split("="),l=u.slice(1).join("=");try{var a=decodeURIComponent(u[0]);if(i[a]=t.read(l,a),s===a)break}catch{}}return s?i[s]:i}}return Object.create({set:n,get:r,remove:function(s,c){n(s,"",Wf({},c,{expires:-1}))},withAttributes:function(s){return Qg(this.converter,Wf({},this.attributes,s))},withConverter:function(s){return Qg(Wf({},this.converter,s),this.attributes)}},{attributes:{value:Object.freeze(e)},converter:{value:Object.freeze(t)}})}var mk=Qg(l$,{path:"/"});const c$=["agent-session","cassie-session"],u$=["agent-oauth-token","cassie-oauth-token"];function eb(){for(const t of c$){const e=mk.get(t);if(e&&e.length>0)return e}}function d$(){let t=qt(ux);for(const e of u$){const n=mk.get(e);if(n&&n.length>0)try{const r=JSON.parse(n);return t=b0(ux,r),t.accessToken}catch(r){console.error("Failed to parse OAuthToken:",r)}}return t.accessToken}const vk=B.createContext(void 0),Ui=()=>{const t=B.useContext(vk);if(!t)throw new Error("useSettings must be used within a SettingsProvider");return t},f$=({children:t,agentEndpoint:e,requireAuth:n,webApp:r,createAuthInterceptors:s})=>{const[c,i]=B.useState(null),o=B.useMemo(()=>{const m=eb();if(!m)return"unauthenticated";let b;try{return b=fk(m),b.email||b.sub||"unauthenticated"}catch(y){return console.error("Error decoding token",y),"unauthenticated"}},[]),u=B.useMemo(()=>{const m=window.location.hostname==="localhost",b=window.location.protocol==="http:",y=window.location.port==="4173"||window.location.port==="5173",_=m&&b&&y;return{requireAuth:n??!1,agentEndpoint:e??_?"http://localhost:8080":window.location.origin,webApp:{runner:(r==null?void 0:r.runner)??_?"ws://localhost:8080/ws":`${b?"ws:":"wss:"}//${window.location.host}/ws`,reconnect:(r==null?void 0:r.reconnect)??!0,invertedOrder:(r==null?void 0:r.invertedOrder)??!1}}},[n,r]),[l,a]=B.useState(()=>{const m=localStorage.getItem("cloudAssistantSettings"),b=m?JSON.parse(m):{};return b&&b.webApp&&b.webApp.reconnect!==void 0&&(b.webApp.reconnect=u.webApp.reconnect),m?{...u,...b}:u});B.useEffect(()=>{localStorage.setItem("cloudAssistantSettings",JSON.stringify(l))},[l]);const d=B.useCallback(m=>{const b=y=>{const _=xn.from(y);_.code===ln.Unauthenticated&&(window.location.href=`/login?error=${encodeURIComponent(_.name)}&error_description=${encodeURIComponent(_.message)}`)};return[y=>async _=>{const S=eb();return S&&_.header.set("Authorization",`Bearer ${S}`),m?y(_).catch(x=>{throw b(x),x}):y(_)}]},[]),h=B.useMemo(()=>s??d,[s,d]),p=B.useCallback(async()=>{if(!l.webApp.runner)return;i(null);const m=new uk({knownID:`check_${o$()}`,runID:dk(),sequence:0,options:{runnerEndpoint:l.webApp.runner,interceptors:h(!1),autoReconnect:!1}}),b=[];return b.push(m.errors.subscribe({next:y=>i(y)})),b.push(m.connect(ck.INITIAL).subscribe(y=>{y!==null&&(console.log(`Initial heartbeat latency for streamID ${y.streamID} (${y.readyState===1?"open":"closed"}): ${y.latency}ms`),m.close())})),()=>{b.forEach(y=>y.unsubscribe())}},[s,l.webApp.runner]);B.useEffect(()=>{p()},[p]);const v=m=>{a(b=>({...b,...m,webApp:{...b.webApp,...m.webApp}}))};return ie.jsx(vk.Provider,{value:{principal:o,checkRunnerAuth:p,createAuthInterceptors:h,defaultSettings:u,runnerError:c,settings:l,updateSettings:v},children:t})},gk=B.createContext(void 0),h$=()=>{const t=B.useContext(gk);if(!t)throw new Error("useClient must be used within a ClientProvider");return t},p$=({children:t})=>{const[e,n]=B.useState(),{settings:r,createAuthInterceptors:s}=Ui();return B.useEffect(()=>{n(m$(r.agentEndpoint,s(!0)))},[r.agentEndpoint,s]),ie.jsx(gk.Provider,{value:{client:e,setClient:n},children:t})};function m$(t,e){console.log(`initializing the client: baseURL ${t}`);const n=r5({baseUrl:t,interceptors:e});return Y3(L7,n)}const bk=B.createContext(void 0),z0=()=>{const t=B.useContext(bk);if(!t)throw new Error("useOutput must be used within an OutputProvider");return t},v$=({children:t})=>{const e=B.useMemo(()=>new Map,[]),n=B.useCallback((o,u)=>{e.set(o,u)},[e]),r=B.useCallback(o=>{e.delete(o)},[e]),s=B.useCallback(o=>e.get(o),[e]),c=B.useCallback(()=>e,[e]),i=B.useMemo(()=>({registerRenderer:n,unregisterRenderer:r,getRenderer:s,getAllRenderers:c}),[n,r,s,c]);return ie.jsx(bk.Provider,{value:i,children:t})},yk=B.createContext(void 0),Co=()=>{const t=B.useContext(yk);if(!t)throw new Error("useCell must be used within a CellProvider");return t};function dx(t,e){if(!t)return[];const n=t.positions.map(r=>{const s=t.cells[r];return s.languageId="sh",s});return n.length===0?[]:e?n.reverse():n}const g$=({children:t,getAccessToken:e})=>{const{settings:n,createAuthInterceptors:r,principal:s}=Ui(),[c,i]=B.useState(0),[o,u]=B.useState(!1),[l,a]=B.useState(!1),[d,h]=B.useState(),{getAllRenderers:p}=z0(),v=B.useMemo(()=>{const P=new URL(n.webApp.runner);return P.protocol==="ws:"?P.protocol="http:":P.protocol="https:",P.pathname="",P.toString()},[n.webApp.runner]),m=B.useMemo(()=>{if(s)return new qD("agent",s,e2(H7,v,r(!0)))},[n.agentEndpoint,s]),b=B.useMemo(()=>n.webApp.invertedOrder,[n.webApp.invertedOrder]),{client:y}=h$(),[_,S]=B.useState(void 0),x=B.useCallback(()=>{if(!_)return;const P=dx(_,b),z=qt(MS,{cells:P});d&&(z.metadata[zg.PreviousResponseId]=d),m==null||m.saveNotebook(_.runmeSession,z)},[_,b,d,m]),C=B.useCallback(async({attemptRestore:P})=>{if(!m)return;i(0),h(void 0);const z=m.createSession();let O;if(!P)O=await z;else{const Z=await m.listActiveSessions(),F=(await m.loadSessions(Z)).filter(ae=>ae.data.cells.length!==0);if(F.length===0)O=await z;else{const ae=F[0];let le=ae.data.cells.map(G=>G.refId);b&&(le=le.reverse());const ee=ae.data.metadata[zg.PreviousResponseId];ee&&h(ee),S({runmeSession:ae.id,cells:ae.data.cells.reduce((G,ge)=>(G[ge.refId]=ge,G),{}),positions:le});return}}S({runmeSession:O,cells:{},positions:[]})},[b,m]);B.useEffect(()=>{x()},[_,m,b,x]),B.useEffect(()=>{S(P=>({runmeSession:(P==null?void 0:P.runmeSession)??"",cells:(P==null?void 0:P.cells)??{},positions:[...(P==null?void 0:P.positions)??[]].reverse()}))},[b]),B.useEffect(()=>{C&&C({attemptRestore:!0})},[C]);const j=B.useMemo(()=>_?_.positions.map(P=>_.cells[P]).filter(P=>!!P&&(P.kind===Ts.MARKUP||P.kind===Ts.CODE)):[],[_]),k=B.useMemo(()=>_?_.positions.map(P=>_.cells[P]).filter(P=>!!P&&P.kind===Ts.CODE):[],[_]),A=B.useMemo(()=>_?_.positions.map(P=>_.cells[P]).filter(P=>!!P&&P.kind===Ts.DOC_RESULTS):[],[_]),N=()=>({chat:j,actions:k,files:A}),D=P=>K8(Ou,P),M=async P=>{const z=await e(),O=qt(N7,{cells:P,previousResponseId:d});O.openaiAccessToken=z,z||console.error("No access token found");try{const Z=y.generate(O);for await(const W of Z){for(const F of W.cells)a(!1),J(F);h(W.responseId)}}catch(Z){console.log(Z)}finally{a(!1),u(!1)}},U=async P=>{if(!P.trim())return;const z=qt(Ou,{refId:`user_${BS()}`,role:yo.USER,kind:Ts.MARKUP,value:P});J(z),u(!0),a(!0),await M([z])},Y=async P=>{P.outputs.length!==0&&(console.log("sending output cell",P.refId,"previousResponseId",d),u(!0),a(!0),await M([P]))},J=P=>{const z=p();for(const O of z.values())O.onCellUpdate(P);S(O=>{if(O){if(!O.cells[P.refId]){const Z=b?[P.refId,...O.positions]:[...O.positions,P.refId];return{runmeSession:O.runmeSession,cells:{...O.cells,[P.refId]:P},positions:Z}}return{...O,runmeSession:O.runmeSession,cells:{...O.cells,[P.refId]:P}}}})},te=()=>{const P=`code_${BS().replace(/-/g,"")}`,z=qt(Ou,{metadata:{[cs.ID]:P,[cs.RunmeID]:P},refId:P,languageId:"sh",role:yo.USER,kind:Ts.CODE,value:""});J(z)},Q=P=>{if(!k.find(Z=>Z.refId===P.refId))return;const O=new CustomEvent("runCodeCell",{detail:{cellId:P.refId}});P.executionSummary=void 0,P.outputs=P.outputs.filter(Z=>Z.items.some(W=>W.mime===po.StatefulRunmeTerminal)),i(Z=>{const W=Z+1;return P.metadata[cs.Sequence]=W.toString(),W}),window.dispatchEvent(O)},ne=async({asSessionRecord:P})=>{var ge;const z=dx(_,b);if(!_||z.length===0)return;const O=qt(MS,{cells:z}),Z=e2(R7,n.agentEndpoint),W=qt(A7,{notebook:O,options:qt(T7,{outputs:qt(k7,{enabled:!1,summary:!1})})});P&&((ge=W.options)!=null&&ge.outputs)&&(W.options.outputs.enabled=!0,W.options.outputs.summary=!0,W.options.session=qt(j7,{id:_.runmeSession}));const F=await Z.serialize(W),ae=new Blob([F.result],{type:"text/plain"}),le=URL.createObjectURL(ae),ee=document.createElement("a");ee.href=le;const G=P?"Session":"Notebook";ee.download=`${G}-${l5()}.md`,document.body.appendChild(ee),ee.click(),document.body.removeChild(ee),URL.revokeObjectURL(le)};return ie.jsx(yk.Provider,{value:{useColumns:N,sequence:c,saveState:x,exportDocument:ne,sendOutputCell:Y,createOutputCell:D,sendUserCell:U,addCodeCell:te,isInputDisabled:o,isTyping:l,runCodeCell:Q,resetSession:C},children:t})},fx=new TextEncoder;function b$({pid:t,exitCode:e},n,r,s){let c;return t!==null&&e!==null&&(c=qt(C7,{pid:BigInt(t),exitReason:qt(x7,{type:"exit",code:e})})),[qt(W3,{items:[qt(Fg,{mime:po.VSCodeNotebookStdOut,type:"Buffer",data:fx.encode(n)}),qt(Fg,{mime:po.VSCodeNotebookStdErr,type:"Buffer",data:fx.encode(r)})],processInfo:c})]}const y$=qt(Ou,{kind:Ts.MARKUP,role:yo.ASSISTANT,value:"..."}),tb={fontSize:14,fontFamily:"monospace"},_$=new TextDecoder,w$=B.memo(YB,(t,e)=>t.cellID===e.cellID&&t.runID===e.runID),S$=({cell:t,onExitCode:e,onPid:n})=>{const{createAuthInterceptors:r,settings:{webApp:s}}=Ui(),{sendOutputCell:c,saveState:i}=Co(),o=s.invertedOrder,[u,l]=B.useState(!1),[a,d]=B.useState({value:"",runID:""}),[h,p]=B.useState(null),[v,m]=B.useState(null),[b,y]=B.useState(null),[_,S]=B.useState(null),[x,C]=B.useState(""),[j,k]=B.useState(""),[A,N]=B.useState(""),D=B.useMemo(()=>Number(t.metadata[cs.Sequence]??0),[t,v,b]),M=B.useCallback((le=!1)=>{p(BigInt(Date.now())),C(""),k(""),m(null),y(null),l(le),d({value:t.value,runID:dk()})},[t]),U=B.useMemo(()=>({...tb,className:"rounded-md overflow-hidden",rows:14,scrollToFit:!o,takeFocus:u}),[o,u]);B.useEffect(()=>{const le=ee=>{ee.detail.cellId===t.refId&&M()};return window.addEventListener("runCodeCell",le),()=>{window.removeEventListener("runCodeCell",le)}},[t.refId,M]);const Y=B.useMemo(()=>{const le=t.outputs.filter(G=>G.items.some(ge=>ge.mime===po.StatefulRunmeTerminal)),ee=b$({pid:v,exitCode:b},x,j);return[...le,...ee]},[v,b,x,j,_,t.outputs]);B.useEffect(()=>{h!==null&&(t.outputs=Y,t.executionSummary=qt(E7,{timing:qt(S7,{startTime:h,endTime:BigInt(Date.now())}),executionOrder:D,success:Number.isFinite(b)&&b===0}))},[t,Y,b,D,h]);const J=B.useMemo(()=>v===null||b===null||a.runID===""||!Number.isFinite(v)||!Number.isInteger(b)?null:t,[t,a.runID,b,v]);B.useEffect(()=>{!J||A===a.runID||(N(a.runID),c(J))},[c,J,a.runID,A]),B.useEffect(()=>{v!==null&&n(v)},[v,n]),B.useEffect(()=>{b!==null&&e(b)},[b,e]),B.useEffect(()=>{t.kind===Ts.CODE&&(a.runID!==""&&(t.metadata[cs.LastRunID]=a.runID),v?t.metadata[cs.Pid]=v.toString():delete t.metadata[cs.Pid],b!==null&&Number.isFinite(b)?(delete t.metadata[cs.Pid],t.metadata[cs.ExitCode]=b.toString()):delete t.metadata[cs.ExitCode],i())},[v,b,t,i,a.runID]);const te=B.useMemo(()=>{if(t.kind!==Ts.CODE||A!=="")return;const le=t.outputs.flatMap(ee=>ee.items).find(ee=>ee.mime===po.VSCodeNotebookStdOut);if(le)return _$.decode(le.data)},[t.kind,t.outputs,A]),Q=B.useMemo(()=>{var ee;return((ee=t.metadata)==null?void 0:ee[cs.Pid])??""?t.metadata[cs.LastRunID]??"":""},[t.metadata]),ne=B.useMemo(()=>a.value===""||a.runID===""?[]:a.value.split(`
|
|
6659
|
+
`):"",this.name="UnsubscriptionError",this.errors=e}});function Rh(t,e){if(t){var n=t.indexOf(e);0<=n&&t.splice(n,1)}}var wd=function(){function t(e){this.initialTeardown=e,this.closed=!1,this._parentage=null,this._finalizers=null}return t.prototype.unsubscribe=function(){var e,n,r,s,c;if(!this.closed){this.closed=!0;var i=this._parentage;if(i)if(this._parentage=null,Array.isArray(i))try{for(var o=ac(i),u=o.next();!u.done;u=o.next()){var l=u.value;l.remove(this)}}catch(m){e={error:m}}finally{try{u&&!u.done&&(n=o.return)&&n.call(o)}finally{if(e)throw e.error}}else i.remove(this);var a=this.initialTeardown;if(Cn(a))try{a()}catch(m){c=m instanceof qv?m.errors:[m]}var d=this._finalizers;if(d){this._finalizers=null;try{for(var h=ac(d),p=h.next();!p.done;p=h.next()){var v=p.value;try{Y2(v)}catch(m){c=c??[],m instanceof qv?c=fa(fa([],_o(c)),_o(m.errors)):c.push(m)}}}catch(m){r={error:m}}finally{try{p&&!p.done&&(s=h.return)&&s.call(h)}finally{if(r)throw r.error}}}if(c)throw new qv(c)}},t.prototype.add=function(e){var n;if(e&&e!==this)if(this.closed)Y2(e);else{if(e instanceof t){if(e.closed||e._hasParent(this))return;e._addParent(this)}(this._finalizers=(n=this._finalizers)!==null&&n!==void 0?n:[]).push(e)}},t.prototype._hasParent=function(e){var n=this._parentage;return n===e||Array.isArray(n)&&n.includes(e)},t.prototype._addParent=function(e){var n=this._parentage;this._parentage=Array.isArray(n)?(n.push(e),n):n?[n,e]:e},t.prototype._removeParent=function(e){var n=this._parentage;n===e?this._parentage=null:Array.isArray(n)&&Rh(n,e)},t.prototype.remove=function(e){var n=this._finalizers;n&&Rh(n,e),e instanceof t&&e._removeParent(this)},t.EMPTY=function(){var e=new t;return e.closed=!0,e}(),t}(),V5=wd.EMPTY;function F5(t){return t instanceof wd||t&&"closed"in t&&Cn(t.remove)&&Cn(t.add)&&Cn(t.unsubscribe)}function Y2(t){Cn(t)?t():t.unsubscribe()}var kP={Promise:void 0},TP={setTimeout:function(t,e){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];return setTimeout.apply(void 0,fa([t,e],_o(n)))},clearTimeout:function(t){return clearTimeout(t)},delegate:void 0};function z5(t){TP.setTimeout(function(){throw t})}function sd(){}function ch(t){t()}var $0=function(t){va(e,t);function e(n){var r=t.call(this)||this;return r.isStopped=!1,n?(r.destination=n,F5(n)&&n.add(r)):r.destination=OP,r}return e.create=function(n,r,s){return new id(n,r,s)},e.prototype.next=function(n){this.isStopped||this._next(n)},e.prototype.error=function(n){this.isStopped||(this.isStopped=!0,this._error(n))},e.prototype.complete=function(){this.isStopped||(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(n){this.destination.next(n)},e.prototype._error=function(n){try{this.destination.error(n)}finally{this.unsubscribe()}},e.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},e}(wd),AP=function(){function t(e){this.partialObserver=e}return t.prototype.next=function(e){var n=this.partialObserver;if(n.next)try{n.next(e)}catch(r){zf(r)}},t.prototype.error=function(e){var n=this.partialObserver;if(n.error)try{n.error(e)}catch(r){zf(r)}else zf(e)},t.prototype.complete=function(){var e=this.partialObserver;if(e.complete)try{e.complete()}catch(n){zf(n)}},t}(),id=function(t){va(e,t);function e(n,r,s){var c=t.call(this)||this,i;return Cn(n)||!n?i={next:n??void 0,error:r??void 0,complete:s??void 0}:i=n,c.destination=new AP(i),c}return e}($0);function zf(t){z5(t)}function IP(t){throw t}var OP={closed:!0,next:sd,error:IP,complete:sd},U0=function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"}();function yp(t){return t}function RP(t){return t.length===0?yp:t.length===1?t[0]:function(e){return t.reduce(function(n,r){return r(n)},e)}}var ur=function(){function t(e){e&&(this._subscribe=e)}return t.prototype.lift=function(e){var n=new t;return n.source=this,n.operator=e,n},t.prototype.subscribe=function(e,n,r){var s=this,c=LP(e)?e:new id(e,n,r);return ch(function(){var i=s,o=i.operator,u=i.source;c.add(o?o.call(c,u):u?s._subscribe(c):s._trySubscribe(c))}),c},t.prototype._trySubscribe=function(e){try{return this._subscribe(e)}catch(n){e.error(n)}},t.prototype.forEach=function(e,n){var r=this;return n=X2(n),new n(function(s,c){var i=new id({next:function(o){try{e(o)}catch(u){c(u),i.unsubscribe()}},error:c,complete:s});r.subscribe(i)})},t.prototype._subscribe=function(e){var n;return(n=this.source)===null||n===void 0?void 0:n.subscribe(e)},t.prototype[U0]=function(){return this},t.prototype.pipe=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];return RP(e)(this)},t.prototype.toPromise=function(e){var n=this;return e=X2(e),new e(function(r,s){var c;n.subscribe(function(i){return c=i},function(i){return s(i)},function(){return r(c)})})},t.create=function(e){return new t(e)},t}();function X2(t){var e;return(e=t??kP.Promise)!==null&&e!==void 0?e:Promise}function NP(t){return t&&Cn(t.next)&&Cn(t.error)&&Cn(t.complete)}function LP(t){return t&&t instanceof $0||NP(t)&&F5(t)}function DP(t){return Cn(t==null?void 0:t.lift)}function $r(t){return function(e){if(DP(e))return e.lift(function(n){try{return t(n,this)}catch(r){this.error(r)}});throw new TypeError("Unable to lift unknown Observable type")}}function nr(t,e,n,r,s){return new MP(t,e,n,r,s)}var MP=function(t){va(e,t);function e(n,r,s,c,i,o){var u=t.call(this,n)||this;return u.onFinalize=i,u.shouldUnsubscribe=o,u._next=r?function(l){try{r(l)}catch(a){n.error(a)}}:t.prototype._next,u._error=c?function(l){try{c(l)}catch(a){n.error(a)}finally{this.unsubscribe()}}:t.prototype._error,u._complete=s?function(){try{s()}catch(l){n.error(l)}finally{this.unsubscribe()}}:t.prototype._complete,u}return e.prototype.unsubscribe=function(){var n;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var r=this.closed;t.prototype.unsubscribe.call(this),!r&&((n=this.onFinalize)===null||n===void 0||n.call(this))}},e}($0),PP=U5(function(t){return function(){t(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}}),Hs=function(t){va(e,t);function e(){var n=t.call(this)||this;return n.closed=!1,n.currentObservers=null,n.observers=[],n.isStopped=!1,n.hasError=!1,n.thrownError=null,n}return e.prototype.lift=function(n){var r=new q2(this,this);return r.operator=n,r},e.prototype._throwIfClosed=function(){if(this.closed)throw new PP},e.prototype.next=function(n){var r=this;ch(function(){var s,c;if(r._throwIfClosed(),!r.isStopped){r.currentObservers||(r.currentObservers=Array.from(r.observers));try{for(var i=ac(r.currentObservers),o=i.next();!o.done;o=i.next()){var u=o.value;u.next(n)}}catch(l){s={error:l}}finally{try{o&&!o.done&&(c=i.return)&&c.call(i)}finally{if(s)throw s.error}}}})},e.prototype.error=function(n){var r=this;ch(function(){if(r._throwIfClosed(),!r.isStopped){r.hasError=r.isStopped=!0,r.thrownError=n;for(var s=r.observers;s.length;)s.shift().error(n)}})},e.prototype.complete=function(){var n=this;ch(function(){if(n._throwIfClosed(),!n.isStopped){n.isStopped=!0;for(var r=n.observers;r.length;)r.shift().complete()}})},e.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(e.prototype,"observed",{get:function(){var n;return((n=this.observers)===null||n===void 0?void 0:n.length)>0},enumerable:!1,configurable:!0}),e.prototype._trySubscribe=function(n){return this._throwIfClosed(),t.prototype._trySubscribe.call(this,n)},e.prototype._subscribe=function(n){return this._throwIfClosed(),this._checkFinalizedStatuses(n),this._innerSubscribe(n)},e.prototype._innerSubscribe=function(n){var r=this,s=this,c=s.hasError,i=s.isStopped,o=s.observers;return c||i?V5:(this.currentObservers=null,o.push(n),new wd(function(){r.currentObservers=null,Rh(o,n)}))},e.prototype._checkFinalizedStatuses=function(n){var r=this,s=r.hasError,c=r.thrownError,i=r.isStopped;s?n.error(c):i&&n.complete()},e.prototype.asObservable=function(){var n=new ur;return n.source=this,n},e.create=function(n,r){return new q2(n,r)},e}(ur),q2=function(t){va(e,t);function e(n,r){var s=t.call(this)||this;return s.destination=n,s.source=r,s}return e.prototype.next=function(n){var r,s;(s=(r=this.destination)===null||r===void 0?void 0:r.next)===null||s===void 0||s.call(r,n)},e.prototype.error=function(n){var r,s;(s=(r=this.destination)===null||r===void 0?void 0:r.error)===null||s===void 0||s.call(r,n)},e.prototype.complete=function(){var n,r;(r=(n=this.destination)===null||n===void 0?void 0:n.complete)===null||r===void 0||r.call(n)},e.prototype._subscribe=function(n){var r,s;return(s=(r=this.source)===null||r===void 0?void 0:r.subscribe(n))!==null&&s!==void 0?s:V5},e}(Hs),BP={now:function(){return Date.now()}},$P=function(t){va(e,t);function e(n,r){return t.call(this)||this}return e.prototype.schedule=function(n,r){return this},e}(wd),J2={setInterval:function(t,e){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];return setInterval.apply(void 0,fa([t,e],_o(n)))},clearInterval:function(t){return clearInterval(t)},delegate:void 0},UP=function(t){va(e,t);function e(n,r){var s=t.call(this,n,r)||this;return s.scheduler=n,s.work=r,s.pending=!1,s}return e.prototype.schedule=function(n,r){var s;if(r===void 0&&(r=0),this.closed)return this;this.state=n;var c=this.id,i=this.scheduler;return c!=null&&(this.id=this.recycleAsyncId(i,c,r)),this.pending=!0,this.delay=r,this.id=(s=this.id)!==null&&s!==void 0?s:this.requestAsyncId(i,this.id,r),this},e.prototype.requestAsyncId=function(n,r,s){return s===void 0&&(s=0),J2.setInterval(n.flush.bind(n,this),s)},e.prototype.recycleAsyncId=function(n,r,s){if(s===void 0&&(s=0),s!=null&&this.delay===s&&this.pending===!1)return r;r!=null&&J2.clearInterval(r)},e.prototype.execute=function(n,r){if(this.closed)return new Error("executing a cancelled action");this.pending=!1;var s=this._execute(n,r);if(s)return s;this.pending===!1&&this.id!=null&&(this.id=this.recycleAsyncId(this.scheduler,this.id,null))},e.prototype._execute=function(n,r){var s=!1,c;try{this.work(n)}catch(i){s=!0,c=i||new Error("Scheduled action threw falsy error")}if(s)return this.unsubscribe(),c},e.prototype.unsubscribe=function(){if(!this.closed){var n=this,r=n.id,s=n.scheduler,c=s.actions;this.work=this.state=this.scheduler=null,this.pending=!1,Rh(c,this),r!=null&&(this.id=this.recycleAsyncId(s,r,null)),this.delay=null,t.prototype.unsubscribe.call(this)}},e}($P),Q2=function(){function t(e,n){n===void 0&&(n=t.now),this.schedulerActionCtor=e,this.now=n}return t.prototype.schedule=function(e,n,r){return n===void 0&&(n=0),new this.schedulerActionCtor(this,e).schedule(r,n)},t.now=BP.now,t}(),VP=function(t){va(e,t);function e(n,r){r===void 0&&(r=Q2.now);var s=t.call(this,n,r)||this;return s.actions=[],s._active=!1,s}return e.prototype.flush=function(n){var r=this.actions;if(this._active){r.push(n);return}var s;this._active=!0;do if(s=n.execute(n.state,n.delay))break;while(n=r.shift());if(this._active=!1,s){for(;n=r.shift();)n.unsubscribe();throw s}},e}(Q2),_p=new VP(UP),FP=_p,H5=new ur(function(t){return t.complete()});function G5(t){return t&&Cn(t.schedule)}function V0(t){return t[t.length-1]}function zP(t){return Cn(V0(t))?t.pop():void 0}function W5(t){return G5(V0(t))?t.pop():void 0}function HP(t,e){return typeof V0(t)=="number"?t.pop():e}var F0=function(t){return t&&typeof t.length=="number"&&typeof t!="function"};function Z5(t){return Cn(t==null?void 0:t.then)}function K5(t){return Cn(t[U0])}function Y5(t){return Symbol.asyncIterator&&Cn(t==null?void 0:t[Symbol.asyncIterator])}function X5(t){return new TypeError("You provided "+(t!==null&&typeof t=="object"?"an invalid object":"'"+t+"'")+" where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.")}function GP(){return typeof Symbol!="function"||!Symbol.iterator?"@@iterator":Symbol.iterator}var q5=GP();function J5(t){return Cn(t==null?void 0:t[q5])}function Q5(t){return EP(this,arguments,function(){var e,n,r,s;return $5(this,function(c){switch(c.label){case 0:e=t.getReader(),c.label=1;case 1:c.trys.push([1,,9,10]),c.label=2;case 2:return[4,Wl(e.read())];case 3:return n=c.sent(),r=n.value,s=n.done,s?[4,Wl(void 0)]:[3,5];case 4:return[2,c.sent()];case 5:return[4,Wl(r)];case 6:return[4,c.sent()];case 7:return c.sent(),[3,2];case 8:return[3,10];case 9:return e.releaseLock(),[7];case 10:return[2]}})})}function ek(t){return Cn(t==null?void 0:t.getReader)}function Ir(t){if(t instanceof ur)return t;if(t!=null){if(K5(t))return WP(t);if(F0(t))return ZP(t);if(Z5(t))return KP(t);if(Y5(t))return tk(t);if(J5(t))return YP(t);if(ek(t))return XP(t)}throw X5(t)}function WP(t){return new ur(function(e){var n=t[U0]();if(Cn(n.subscribe))return n.subscribe(e);throw new TypeError("Provided object does not correctly implement Symbol.observable")})}function ZP(t){return new ur(function(e){for(var n=0;n<t.length&&!e.closed;n++)e.next(t[n]);e.complete()})}function KP(t){return new ur(function(e){t.then(function(n){e.closed||(e.next(n),e.complete())},function(n){return e.error(n)}).then(null,z5)})}function YP(t){return new ur(function(e){var n,r;try{for(var s=ac(t),c=s.next();!c.done;c=s.next()){var i=c.value;if(e.next(i),e.closed)return}}catch(o){n={error:o}}finally{try{c&&!c.done&&(r=s.return)&&r.call(s)}finally{if(n)throw n.error}}e.complete()})}function tk(t){return new ur(function(e){qP(t,e).catch(function(n){return e.error(n)})})}function XP(t){return tk(Q5(t))}function qP(t,e){var n,r,s,c;return CP(this,void 0,void 0,function(){var i,o;return $5(this,function(u){switch(u.label){case 0:u.trys.push([0,5,6,11]),n=jP(t),u.label=1;case 1:return[4,n.next()];case 2:if(r=u.sent(),!!r.done)return[3,4];if(i=r.value,e.next(i),e.closed)return[2];u.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return o=u.sent(),s={error:o},[3,11];case 6:return u.trys.push([6,,9,10]),r&&!r.done&&(c=n.return)?[4,c.call(n)]:[3,8];case 7:u.sent(),u.label=8;case 8:return[3,10];case 9:if(s)throw s.error;return[7];case 10:return[7];case 11:return e.complete(),[2]}})})}function Za(t,e,n,r,s){r===void 0&&(r=0),s===void 0&&(s=!1);var c=e.schedule(function(){n(),s?t.add(this.schedule(null,r)):this.unsubscribe()},r);if(t.add(c),!s)return c}function nk(t,e){return e===void 0&&(e=0),$r(function(n,r){n.subscribe(nr(r,function(s){return Za(r,t,function(){return r.next(s)},e)},function(){return Za(r,t,function(){return r.complete()},e)},function(s){return Za(r,t,function(){return r.error(s)},e)}))})}function rk(t,e){return e===void 0&&(e=0),$r(function(n,r){r.add(t.schedule(function(){return n.subscribe(r)},e))})}function JP(t,e){return Ir(t).pipe(rk(e),nk(e))}function QP(t,e){return Ir(t).pipe(rk(e),nk(e))}function eB(t,e){return new ur(function(n){var r=0;return e.schedule(function(){r===t.length?n.complete():(n.next(t[r++]),n.closed||this.schedule())})})}function tB(t,e){return new ur(function(n){var r;return Za(n,e,function(){r=t[q5](),Za(n,e,function(){var s,c,i;try{s=r.next(),c=s.value,i=s.done}catch(o){n.error(o);return}i?n.complete():n.next(c)},0,!0)}),function(){return Cn(r==null?void 0:r.return)&&r.return()}})}function sk(t,e){if(!t)throw new Error("Iterable cannot be null");return new ur(function(n){Za(n,e,function(){var r=t[Symbol.asyncIterator]();Za(n,e,function(){r.next().then(function(s){s.done?n.complete():n.next(s.value)})},0,!0)})})}function nB(t,e){return sk(Q5(t),e)}function rB(t,e){if(t!=null){if(K5(t))return JP(t,e);if(F0(t))return eB(t,e);if(Z5(t))return QP(t,e);if(Y5(t))return sk(t,e);if(J5(t))return tB(t,e);if(ek(t))return nB(t,e)}throw X5(t)}function ik(t,e){return e?rB(t,e):Ir(t)}function sB(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=W5(t);return ik(t,n)}function iB(t){return t instanceof Date&&!isNaN(t)}function zs(t,e){return $r(function(n,r){var s=0;n.subscribe(nr(r,function(c){r.next(t.call(e,c,s++))}))})}var oB=Array.isArray;function aB(t,e){return oB(e)?t.apply(void 0,fa([],_o(e))):t(e)}function lB(t){return zs(function(e){return aB(t,e)})}function cB(t,e,n,r,s,c,i,o){var u=[],l=0,a=0,d=!1,h=function(){d&&!u.length&&!l&&e.complete()},p=function(m){return l<r?v(m):u.push(m)},v=function(m){l++;var b=!1;Ir(n(m,a++)).subscribe(nr(e,function(y){e.next(y)},function(){b=!0},void 0,function(){if(b)try{l--;for(var y=function(){var _=u.shift();i||v(_)};u.length&&l<r;)y();h()}catch(_){e.error(_)}}))};return t.subscribe(nr(e,p,function(){d=!0,h()})),function(){}}function Ha(t,e,n){return n===void 0&&(n=1/0),Cn(e)?Ha(function(r,s){return zs(function(c,i){return e(r,c,s,i)})(Ir(t(r,s)))},n):(typeof e=="number"&&(n=e),$r(function(r,s){return cB(r,s,t,n)}))}function uB(t){return t===void 0&&(t=1/0),Ha(yp,t)}function dB(t){return new ur(function(e){Ir(t()).subscribe(e)})}var fB={connector:function(){return new Hs},resetOnDisconnect:!0};function Va(t,e){e===void 0&&(e=fB);var n=null,r=e.connector,s=e.resetOnDisconnect,c=s===void 0?!0:s,i=r(),o=new ur(function(u){return i.subscribe(u)});return o.connect=function(){return(!n||n.closed)&&(n=dB(function(){return t}).subscribe(i),c&&n.add(function(){return i=r()})),n},o}var hB=["addListener","removeListener"],pB=["addEventListener","removeEventListener"],mB=["on","off"];function Jg(t,e,n,r){if(Cn(n)&&(r=n,n=void 0),r)return Jg(t,e,n).pipe(lB(r));var s=_o(bB(t)?pB.map(function(o){return function(u){return t[o](e,u,n)}}):vB(t)?hB.map(ex(t,e)):gB(t)?mB.map(ex(t,e)):[],2),c=s[0],i=s[1];if(!c&&F0(t))return Ha(function(o){return Jg(o,e,n)})(Ir(t));if(!c)throw new TypeError("Invalid event target");return new ur(function(o){var u=function(){for(var l=[],a=0;a<arguments.length;a++)l[a]=arguments[a];return o.next(1<l.length?l:l[0])};return c(u),function(){return i(u)}})}function ex(t,e){return function(n){return function(r){return t[n](e,r)}}}function vB(t){return Cn(t.addListener)&&Cn(t.removeListener)}function gB(t){return Cn(t.on)&&Cn(t.off)}function bB(t){return Cn(t.addEventListener)&&Cn(t.removeEventListener)}function Du(t,e,n){t===void 0&&(t=0),n===void 0&&(n=FP);var r=-1;return e!=null&&(G5(e)?n=e:r=e),new ur(function(s){var c=iB(t)?+t-n.now():t;c<0&&(c=0);var i=0;return n.schedule(function(){s.closed||(s.next(i++),0<=r?this.schedule(void 0,r):s.complete())},c)})}function yB(t,e){return e===void 0&&(e=_p),Du(t,t,e)}function _B(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=W5(t),r=HP(t,1/0),s=t;return s.length?s.length===1?Ir(s[0]):uB(r)(ik(s,n)):H5}var wB=Array.isArray;function SB(t){return t.length===1&&wB(t[0])?t[0]:t}function ra(t,e){return $r(function(n,r){var s=0;n.subscribe(nr(r,function(c){return t.call(e,c,s++)&&r.next(c)}))})}function xB(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return t=SB(t),t.length===1?Ir(t[0]):new ur(CB(t))}function CB(t){return function(e){for(var n=[],r=function(c){n.push(Ir(t[c]).subscribe(nr(e,function(i){if(n){for(var o=0;o<n.length;o++)o!==c&&n[o].unsubscribe();n=null}e.next(i)})))},s=0;n&&!e.closed&&s<t.length;s++)r(s)}}function EB(t){return $r(function(e,n){var r=null,s=null,c=function(){s==null||s.unsubscribe();var i=r;r=[],i&&n.next(i),Ir(t()).subscribe(s=nr(n,c,sd))};c(),e.subscribe(nr(n,function(i){return r==null?void 0:r.push(i)},function(){r&&n.next(r),n.complete()},void 0,function(){return r=s=null}))})}function ok(t){return $r(function(e,n){var r=null,s=!1,c;r=e.subscribe(nr(n,void 0,void 0,function(i){c=Ir(t(i,ok(t)(e))),r?(r.unsubscribe(),r=null,c.subscribe(n)):s=!0})),s&&(r.unsubscribe(),r=null,c.subscribe(n))})}function jB(t,e,n,r,s){return function(c,i){var o=n,u=e,l=0;c.subscribe(nr(i,function(a){var d=l++;u=o?t(u,a,d):(o=!0,a),i.next(u)},s))}}function tx(t){return t<=0?function(){return H5}:$r(function(e,n){var r=0;e.subscribe(nr(n,function(s){++r<=t&&(n.next(s),t<=r&&n.complete())}))})}function kB(t){return $r(function(e,n){try{e.subscribe(n)}finally{n.add(t)}})}function TB(t,e){return $r(jB(t,e,arguments.length>=2,!0))}function AB(t){t===void 0&&(t={});var e=t.connector,n=e===void 0?function(){return new Hs}:e,r=t.resetOnError,s=r===void 0?!0:r,c=t.resetOnComplete,i=c===void 0?!0:c,o=t.resetOnRefCountZero,u=o===void 0?!0:o;return function(l){var a,d,h,p=0,v=!1,m=!1,b=function(){d==null||d.unsubscribe(),d=void 0},y=function(){b(),a=h=void 0,v=m=!1},_=function(){var S=a;y(),S==null||S.unsubscribe()};return $r(function(S,x){p++,!m&&!v&&b();var C=h=h??n();x.add(function(){p--,p===0&&!m&&!v&&(d=Jv(_,u))}),C.subscribe(x),!a&&p>0&&(a=new id({next:function(j){return C.next(j)},error:function(j){m=!0,b(),d=Jv(y,s,j),C.error(j)},complete:function(){v=!0,b(),d=Jv(y,i),C.complete()}}),Ir(S).subscribe(a))})(l)}}function Jv(t,e){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];if(e===!0){t();return}if(e!==!1){var s=new id({next:function(){s.unsubscribe(),t()}});return Ir(e.apply(void 0,fa([],_o(n)))).subscribe(s)}}function IB(t){return $r(function(e,n){var r=!1,s=nr(n,function(){s==null||s.unsubscribe(),r=!0},sd);Ir(t).subscribe(s),e.subscribe(nr(n,function(c){return r&&n.next(c)}))})}function nx(t,e){return $r(function(n,r){var s=null,c=0,i=!1,o=function(){return i&&!s&&r.complete()};n.subscribe(nr(r,function(u){s==null||s.unsubscribe();var l=0,a=c++;Ir(t(u,a)).subscribe(s=nr(r,function(d){return r.next(e?e(u,d,a,l++):d)},function(){s=null,o()}))},function(){i=!0,o()}))})}function Hf(t,e){return e===void 0&&(e=!1),$r(function(n,r){var s=0;n.subscribe(nr(r,function(c){var i=t(c,s++);(i||e)&&r.next(c),!i&&r.complete()}))})}function OB(t,e,n){var r=Cn(t)||e||n?{next:t,error:e,complete:n}:t;return r?$r(function(s,c){var i;(i=r.subscribe)===null||i===void 0||i.call(r);var o=!0;s.subscribe(nr(c,function(u){var l;(l=r.next)===null||l===void 0||l.call(r,u),c.next(u)},function(){var u;o=!1,(u=r.complete)===null||u===void 0||u.call(r),c.complete()},function(u){var l;o=!1,(l=r.error)===null||l===void 0||l.call(r,u),c.error(u)},function(){var u,l;o&&((u=r.unsubscribe)===null||u===void 0||u.call(r)),(l=r.finalize)===null||l===void 0||l.call(r)}))}):yp}function RB(t,e){return $r(function(n,r){var s=e??{},c=s.leading,i=c===void 0?!0:c,o=s.trailing,u=o===void 0?!1:o,l=!1,a=null,d=null,h=!1,p=function(){d==null||d.unsubscribe(),d=null,u&&(b(),h&&r.complete())},v=function(){d=null,h&&r.complete()},m=function(y){return d=Ir(t(y)).subscribe(nr(r,p,v))},b=function(){if(l){l=!1;var y=a;a=null,r.next(y),!h&&m(y)}};n.subscribe(nr(r,function(y){l=!0,a=y,!(d&&!d.closed)&&(i?b():m(y))},function(){h=!0,!(u&&l&&d&&!d.closed)&&r.complete()}))})}function rx(t,e,n){e===void 0&&(e=_p);var r=Du(t,e);return RB(function(){return r},n)}function Qv(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=zP(t);return $r(function(r,s){for(var c=t.length,i=new Array(c),o=t.map(function(){return!1}),u=!1,l=function(d){Ir(t[d]).subscribe(nr(s,function(h){i[d]=h,!u&&!o[d]&&(o[d]=!0,(u=o.every(yp))&&(o=null))},sd))},a=0;a<c;a++)l(a);r.subscribe(nr(s,function(d){if(u){var h=fa([d],_o(i));s.next(n?n.apply(void 0,fa([],_o(h))):h)}}))})}const ak="0123456789ABCDEFGHJKMNPQRSTVWXYZ",Nh=32,NB=16,lk=10,sx=0xffffffffffff;var Ga;(function(t){t.Base32IncorrectEncoding="B32_ENC_INVALID",t.DecodeTimeInvalidCharacter="DEC_TIME_CHAR",t.DecodeTimeValueMalformed="DEC_TIME_MALFORMED",t.EncodeTimeNegative="ENC_TIME_NEG",t.EncodeTimeSizeExceeded="ENC_TIME_SIZE_EXCEED",t.EncodeTimeValueMalformed="ENC_TIME_MALFORMED",t.PRNGDetectFailure="PRNG_DETECT",t.ULIDInvalid="ULID_INVALID",t.Unexpected="UNEXPECTED",t.UUIDInvalid="UUID_INVALID"})(Ga||(Ga={}));class Eu extends Error{constructor(e,n){super(`${n} (${e})`),this.name="ULIDError",this.code=e}}function LB(t){const e=Math.floor(t()*Nh)%Nh;return ak.charAt(e)}function DB(t){const e=MB(),n=e&&(e.crypto||e.msCrypto)||null;if(typeof(n==null?void 0:n.getRandomValues)=="function")return()=>{const r=new Uint8Array(1);return n.getRandomValues(r),r[0]/255};if(typeof(n==null?void 0:n.randomBytes)=="function")return()=>n.randomBytes(1).readUInt8()/255;throw new Eu(Ga.PRNGDetectFailure,"Failed to find a reliable PRNG")}function MB(){return $B()?self:typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:null}function PB(t,e){let n="";for(;t>0;t--)n=LB(e)+n;return n}function BB(t,e=lk){if(isNaN(t))throw new Eu(Ga.EncodeTimeValueMalformed,`Time must be a number: ${t}`);if(t>sx)throw new Eu(Ga.EncodeTimeSizeExceeded,`Cannot encode a time larger than ${sx}: ${t}`);if(t<0)throw new Eu(Ga.EncodeTimeNegative,`Time must be positive: ${t}`);if(Number.isInteger(t)===!1)throw new Eu(Ga.EncodeTimeValueMalformed,`Time must be an integer: ${t}`);let n,r="";for(let s=e;s>0;s--)n=t%Nh,r=ak.charAt(n)+r,t=(t-n)/Nh;return r}function $B(){return typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope}function UB(t,e){const n=DB(),r=Date.now();return BB(r,lk)+PB(NB,n)}const Pr=[];for(let t=0;t<256;++t)Pr.push((t+256).toString(16).slice(1));function VB(t,e=0){return(Pr[t[e+0]]+Pr[t[e+1]]+Pr[t[e+2]]+Pr[t[e+3]]+"-"+Pr[t[e+4]]+Pr[t[e+5]]+"-"+Pr[t[e+6]]+Pr[t[e+7]]+"-"+Pr[t[e+8]]+Pr[t[e+9]]+"-"+Pr[t[e+10]]+Pr[t[e+11]]+Pr[t[e+12]]+Pr[t[e+13]]+Pr[t[e+14]]+Pr[t[e+15]]).toLowerCase()}let eg;const FB=new Uint8Array(16);function zB(){if(!eg){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");eg=crypto.getRandomValues.bind(crypto)}return eg(FB)}const HB=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),ix={randomUUID:HB};function GB(t,e,n){var r;if(ix.randomUUID&&!t)return ix.randomUUID();t=t||{};const s=t.random??((r=t.rng)==null?void 0:r.call(t))??zB();if(s.length<16)throw new Error("Random bytes length must be >= 16");return s[6]=s[6]&15|64,s[8]=s[8]&63|128,VB(s)}const WB=5e3,ZB=1e3,Gf=4e3,ox=1e3;var ck=(t=>(t.CONTINUOUS="CONTINUOUS",t.INITIAL="INITIAL",t))(ck||{});class uk{constructor({knownID:e,runID:n,sequence:r,options:s}){Ln(this,"callback"),Ln(this,"queue",new Hs),Ln(this,"subscriptions",[]),Ln(this,"reconnect",new Hs),Ln(this,"client",new ur),Ln(this,"_latencies",new Hs),Ln(this,"_latenciesConnectable",Va(this._latencies.asObservable().pipe(TB((c,i)=>{if(i.latency<0){const o=c.get(i.streamID);o&&c.set(i.streamID,{...o,readyState:i.readyState})}else c.set(i.streamID,i);return c},new Map)))),Ln(this,"_errors",new Hs),Ln(this,"_errorsConnectable",Va(this._errors.asObservable())),Ln(this,"_stdout",new Hs),Ln(this,"_stderr",new Hs),Ln(this,"_exitCode",new Hs),Ln(this,"_pid",new Hs),Ln(this,"_mimeType",new Hs),Ln(this,"_stdoutConnectable",Va(this._stdout.asObservable())),Ln(this,"_stderrConnectable",Va(this._stderr.asObservable())),Ln(this,"_exitCodeConnectable",Va(this._exitCode.asObservable())),Ln(this,"_pidConnectable",Va(this._pid.asObservable())),Ln(this,"_mimeTypeConnectable",Va(this._mimeType.asObservable())),Ln(this,"knownID"),Ln(this,"runID"),Ln(this,"sequence"),Ln(this,"runnerEndpoint"),Ln(this,"interceptors"),Ln(this,"autoReconnect"),this.knownID=e,this.runID=n,this.sequence=r,this.runnerEndpoint=s.runnerEndpoint,this.interceptors=s.interceptors,this.autoReconnect=s.autoReconnect,this._latenciesConnectable.connect(),this._errorsConnectable.connect(),this._stdoutConnectable.connect(),this._stderrConnectable.connect(),this._exitCodeConnectable.connect(),this._pidConnectable.connect(),this._mimeTypeConnectable.connect(),this.client=this.reconnect.pipe(rx(ox,_p,{leading:!0,trailing:!0}),nx(c=>this.useSocketClient(c.streamID).pipe(nx(i=>this.useHeartbeat(i,c))))).pipe(AB()),this.subscriptions.push(this.monitor()),this.subscriptions.push(this.process())}get latencies(){return this._latenciesConnectable}get errors(){return this._errorsConnectable}get stdout(){return this._stdoutConnectable}get stderr(){return this._stderrConnectable}get exitCode(){return this._exitCodeConnectable}get pid(){return this._pidConnectable}get mimeType(){return this._mimeTypeConnectable}monitor(){return yB(ZB).pipe(ra(()=>this.autoReconnect),Qv(this.reconnect),ra(([,e])=>e.heartbeat==="CONTINUOUS"),Qv(this.latencies),zs(([,e])=>Array.from(e.values()).filter(n=>n.readyState===WebSocket.OPEN&&n.latency>=Gf)),ra(e=>e.length>0),rx(ox)).subscribe({next:e=>{console.log(new Date,"Triggering reconnect",e),this.connect()},complete:()=>{console.log("Monitor complete")},error:e=>{console.error("Error in monitor",e)}})}process(){const e=this.client.pipe(ra(s=>(s==null?void 0:s.readyState)===WebSocket.OPEN),tx(1)),n=this.queue.pipe(EB(()=>e),ra(s=>s.length>0),zs(s=>s.sort((c,i)=>{const o=u=>{var l;return!!((l=u.payload.value)!=null&&l.config)};return o(i)?1:o(c)?-1:0}))),r=this.queue.pipe(IB(e));return _B(n.pipe(Ha(s=>s)),r).pipe(Qv(this.client),Hf(([,s])=>s.readyState===WebSocket.OPEN),Ha(async([s,c])=>{await lx({req:s,interceptors:this.interceptors,socket:c,knownID:this.knownID,runID:this.runID})})).subscribe({error:s=>{this._errors.next(s)}})}useSocketClient(e){return new ur(n=>{const r=new URL(this.runnerEndpoint);r.searchParams.set("id",e),r.searchParams.set("runID",this.runID);const s=new WebSocket(r.toString()),c=l=>{if(console.log(new Date,`WebSocket transport ${e} closed`,l),l.code===1005){n.complete();return}if(this.autoReconnect){this.connect();return}},i=l=>{console.log(new Date,`WebSocket transport ${e} error`,l),this.autoReconnect||n.error(l)},o=l=>{var a,d;if(typeof l.data!="string"){console.warn("Unexpected WebSocket message type:",typeof l.data);return}let h;try{h=ax(l.data),console.log("Received WebsocketResponse:",h)}catch(m){console.error("Failed to parse WebsocketResponse:",m)}const p=h.status;if(p&&p.code!==SP.OK){n.error(p);return}if(h.pong)return;const v=h.payload.value;if(v.stdoutData&&v.stdoutData.length>0&&((a=this.callback)==null||a.call(this,{type:Lu.terminalStdout,output:{"runme.dev/id":this.knownID,data:v.stdoutData}}),this._stdout.next(v.stdoutData)),v.stderrData&&v.stderrData.length>0&&((d=this.callback)==null||d.call(this,{type:Lu.terminalStderr,output:{"runme.dev/id":this.knownID,data:v.stderrData}}),this._stderr.next(v.stderrData)),v.exitCode!==void 0&&(this._exitCode.next(v.exitCode),n.complete()),v.pid!==void 0&&this._pid.next(v.pid),v.mimeType){const m=v.mimeType.split(";")[0];this._mimeType.next(m)}},u=()=>{console.log(new Date,`✅ Connected WebSocket for cell ${this.knownID} (#${this.sequence}) with runID ${this.runID}`),n.next(s)};return s.addEventListener("close",c),s.addEventListener("error",i),s.addEventListener("message",o),s.addEventListener("open",u),()=>{console.log(new Date,`☑️ Cleanly disconnected WebSocket for cell ${this.knownID} (#${this.sequence}) with runID ${this.runID}`),s.removeEventListener("close",c),s.removeEventListener("error",i),s.removeEventListener("message",o),s.removeEventListener("open",u),s.close()}})}setCallback(e){this.callback=e}sendExecuteRequest(e){this.queue.next(qt(Xg,{payload:{value:e,case:"executeRequest"}}))}useHeartbeat(e,{streamID:n,heartbeat:r}){return new ur(s=>{const c=Jg(e,"message").pipe(Hf(()=>e.readyState===WebSocket.OPEN),zs(u=>ax(u.data)),zs(u=>u.pong),ra(u=>u!==void 0),zs(u=>({receivedAt:BigInt(Date.now()),pong:u}))),i=(r==="INITIAL"?Du(0):Du(0,WB)).pipe(Hf(()=>e.readyState===WebSocket.OPEN),zs(()=>{const u={timestamp:BigInt(Date.now())};return qt(Xg,{ping:u})}),Ha(async u=>(await lx({req:u,interceptors:this.interceptors,socket:e}),u)),zs(u=>u.ping)).pipe(ra(u=>(u==null?void 0:u.timestamp)!==void 0),Ha(u=>xB(c.pipe(ra(l=>l.pong.timestamp===u.timestamp),tx(1),zs(l=>{const a=u.timestamp,d=l.receivedAt;return Number(d-a)})),Du(Gf).pipe(zs(()=>{throw new Error(`Pong not received within ${Gf}ms for stream ${n}`)}))).pipe(ok(l=>(this._latencies.next({streamID:n,latency:Gf,readyState:e.readyState,updatedAt:BigInt(Date.now())}),console.log(new Date,"Ping deadline exceeded",l.message),sB(null))))),kB(()=>{this._latencies.next({streamID:n,latency:-1,readyState:e.readyState,updatedAt:BigInt(Date.now())})}),OB(u=>{u!==null&&this._latencies.next({streamID:n,latency:u,readyState:e.readyState,updatedAt:BigInt(Date.now())})})),o=[];return o.push(i.subscribe({error:u=>{console.error("Unexpected error sending heartbeat",u)}})),s.next(e),()=>{o.forEach(u=>u.unsubscribe())}})}connect(e="CONTINUOUS"){const n=KB(),r=this.latencies.pipe(zs(s=>{const c=s.get(n);return c===void 0?null:c}),Hf(s=>(s==null?void 0:s.readyState)===WebSocket.OPEN));return this.reconnect.next({streamID:n,heartbeat:e}),r}close(){this.reconnect.complete(),this.queue.complete(),this._latencies.complete(),this.subscriptions.forEach(e=>e.unsubscribe())}}function ax(t){const e=JSON.parse(t);return b0(xP,e)}async function lx({req:t,interceptors:e,socket:n,knownID:r,runID:s}){r&&(t.knownId=r),s&&(t.runId=s);const c={stream:!1,message:{},method:{},service:{},requestMethod:"UPGRADE",url:n.url,signal:new AbortController().signal,header:new Headers,contextValues:{}};let i=async u=>({stream:!1,message:{},method:{},service:{},header:u.header});for(const u of e.concat().reverse())i=u(i);const o=(await i(c)).header.get("Authorization");o&&t&&(t.authorization=o),n.send(JSON.stringify(U3(Xg,t)))}function KB(){return GB().replace(/-/g,"")}function dk(){return`run_${UB()}`}function YB({cellID:t,runID:e,sequence:n,commands:r,content:s,runner:c,settings:i={},onStdout:o,onStderr:u,onExitCode:l,onPid:a,onMimeType:d}){var h;const{rows:p=20,className:v,fontSize:m=12,fontFamily:b="monospace",takeFocus:y=!0,scrollToFit:_=!0}=i,S=B.useMemo(()=>!t||s===""?null:s,[t,s]),x=B.useMemo(()=>{if(!(!t||!e||!c.endpoint))return console.log("Creating stream",t,e,c.endpoint),new uk({knownID:t,runID:e,sequence:n,options:{runnerEndpoint:c.endpoint,interceptors:c.interceptors,autoReconnect:c.reconnect}})},[t,e,n,c]);B.useEffect(()=>{const N=x==null?void 0:x.connect().subscribe(D=>console.log(`Heartbeat latency for streamID ${D==null?void 0:D.streamID} (${(D==null?void 0:D.readyState)===1?"open":"closed"}): ${D==null?void 0:D.latency}ms`));return()=>{N==null||N.unsubscribe(),x==null||x.close()}},[x]);let C=qt(Z2,{rows:34,cols:100,x:0,y:0});const j=B.useMemo(()=>qt(Xv,{sessionStrategy:bP.MOST_RECENT,storeStdoutInEnv:!0,config:{languageId:"sh",background:!1,fileExtension:"",env:[`RUNME_ID=${t}`,"RUNME_RUNNER=v2","TERM=xterm-256color"],source:{case:"commands",value:{items:r}},interactive:!0,mode:vP.INLINE,runId:e,knownId:t},winsize:C}),[t,e,r,C]),k=B.useMemo(()=>{var N;return{output:{"runme.dev/id":(N=j.config)==null?void 0:N.knownId,fontFamily:b||"monospace",fontSize:m||12,cursorStyle:"block",cursorBlink:!0,cursorWidth:1,takeFocus:y,scrollToFit:_,smoothScrollDuration:0,scrollback:4e3,initialRows:p,content:S||"",isAutoSaveEnabled:!1,isPlatformAuthEnabled:!1}}},[(h=j.config)==null?void 0:h.knownId,b,m,y,_,p,S]),A=new TextEncoder;return _P({postMessage:N=>{if(N.type===Lu.terminalOpen||N.type===Lu.terminalResize){const D=Number(N.output.terminalDimensions.columns),M=Number(N.output.terminalDimensions.rows);if(Number.isFinite(D)&&Number.isFinite(M)){if(C.cols===D&&C.rows===M)return;C=qt(Z2,{cols:D,rows:M,x:0,y:0});const U=qt(Xv,{winsize:C});x==null||x.sendExecuteRequest(U)}}if(N.type===Lu.terminalStdin){const D=A.encode(N.output.input),M=qt(Xv,{inputData:D});x==null||x.sendExecuteRequest(M)}},onDidReceiveMessage:N=>{x==null||x.setCallback(N)}}),B.useEffect(()=>{const N=x==null?void 0:x.stdout.subscribe(D=>{o==null||o(D)});return()=>N==null?void 0:N.unsubscribe()},[x,o]),B.useEffect(()=>{const N=x==null?void 0:x.stderr.subscribe(D=>{u==null||u(D)});return()=>N==null?void 0:N.unsubscribe()},[x,u]),B.useEffect(()=>{const N=x==null?void 0:x.exitCode.subscribe(D=>{l==null||l(D),x==null||x.close()});return()=>N==null?void 0:N.unsubscribe()},[x,l]),B.useEffect(()=>{const N=x==null?void 0:x.pid.subscribe(D=>{a==null||a(D)});return()=>N==null?void 0:N.unsubscribe()},[x,a]),B.useEffect(()=>{const N=x==null?void 0:x.mimeType.subscribe(D=>{d==null||d(D)});return()=>N==null?void 0:N.unsubscribe()},[x,d]),B.useEffect(()=>{!x||!j||(console.log("useEffect invoked - Commands changed:",JSON.stringify(j.config.source.value)),x==null||x.sendExecuteRequest(j))},[j,x]),ie.jsx("div",{className:v,ref:N=>{if(!N||N.hasChildNodes())return;const D=document.createElement("terminal-view");D.setAttribute("buttons","false"),D.setAttribute("id",k.output["runme.dev/id"]),D.setAttribute("fontFamily",k.output.fontFamily),typeof k.output.fontSize=="number"&&D.setAttribute("fontSize",k.output.fontSize.toString()),k.output.cursorStyle&&D.setAttribute("cursorStyle",k.output.cursorStyle),typeof k.output.cursorBlink=="boolean"&&D.setAttribute("cursorBlink",k.output.cursorBlink?"true":"false"),typeof k.output.cursorWidth=="number"&&D.setAttribute("cursorWidth",k.output.cursorWidth.toString()),typeof k.output.takeFocus=="boolean"&&D.setAttribute("takeFocus",k.output.takeFocus?"true":"false"),typeof k.output.smoothScrollDuration=="number"&&D.setAttribute("smoothScrollDuration",k.output.smoothScrollDuration.toString()),typeof k.output.scrollback=="number"&&D.setAttribute("scrollback",k.output.scrollback.toString()),k.output.initialRows!==void 0&&D.setAttribute("initialRows",k.output.initialRows.toString()),k.output.content!==void 0&&D.setAttribute("initialContent",k.output.content),k.output.isAutoSaveEnabled&&D.setAttribute("isAutoSaveEnabled",k.output.isAutoSaveEnabled.toString()),k.output.isPlatformAuthEnabled&&D.setAttribute("isPlatformAuthEnabled",k.output.isPlatformAuthEnabled.toString()),N.appendChild(D);const M=document.createElement("div");M.setAttribute("className","h-1"),N.appendChild(M),setTimeout(()=>{_&&!XB(M)&&M.scrollIntoView({behavior:"smooth"})},0)}})}function XB(t){const e=t.getBoundingClientRect();return e.top>=0&&e.left>=0&&e.bottom<=(window.innerHeight||document.documentElement.clientHeight)&&e.right<=(window.innerWidth||document.documentElement.clientWidth)}class ju extends Error{}ju.prototype.name="InvalidTokenError";function qB(t){return decodeURIComponent(atob(t).replace(/(.)/g,(e,n)=>{let r=n.charCodeAt(0).toString(16).toUpperCase();return r.length<2&&(r="0"+r),"%"+r}))}function JB(t){let e=t.replace(/-/g,"+").replace(/_/g,"/");switch(e.length%4){case 0:break;case 2:e+="==";break;case 3:e+="=";break;default:throw new Error("base64 string is not of the correct length")}try{return qB(e)}catch{return atob(e)}}function fk(t,e){if(typeof t!="string")throw new ju("Invalid token specified: must be a string");e||(e={});const n=e.header===!0?0:1,r=t.split(".")[n];if(typeof r!="string")throw new ju(`Invalid token specified: missing part #${n+1}`);let s;try{s=JB(r)}catch(c){throw new ju(`Invalid token specified: invalid base64 for part #${n+1} (${c.message})`)}try{return JSON.parse(s)}catch(c){throw new ju(`Invalid token specified: invalid json for part #${n+1} (${c.message})`)}}const hk="0123456789ABCDEFGHJKMNPQRSTVWXYZ",Lh=32,QB=16,pk=10,cx=0xffffffffffff;var Wa;(function(t){t.Base32IncorrectEncoding="B32_ENC_INVALID",t.DecodeTimeInvalidCharacter="DEC_TIME_CHAR",t.DecodeTimeValueMalformed="DEC_TIME_MALFORMED",t.EncodeTimeNegative="ENC_TIME_NEG",t.EncodeTimeSizeExceeded="ENC_TIME_SIZE_EXCEED",t.EncodeTimeValueMalformed="ENC_TIME_MALFORMED",t.PRNGDetectFailure="PRNG_DETECT",t.ULIDInvalid="ULID_INVALID",t.Unexpected="UNEXPECTED",t.UUIDInvalid="UUID_INVALID"})(Wa||(Wa={}));class ku extends Error{constructor(e,n){super(`${n} (${e})`),this.name="ULIDError",this.code=e}}function e$(t){const e=Math.floor(t()*Lh)%Lh;return hk.charAt(e)}function t$(t){const e=n$(),n=e&&(e.crypto||e.msCrypto)||null;if(typeof(n==null?void 0:n.getRandomValues)=="function")return()=>{const r=new Uint8Array(1);return n.getRandomValues(r),r[0]/255};if(typeof(n==null?void 0:n.randomBytes)=="function")return()=>n.randomBytes(1).readUInt8()/255;throw new ku(Wa.PRNGDetectFailure,"Failed to find a reliable PRNG")}function n$(){return i$()?self:typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:null}function r$(t,e){let n="";for(;t>0;t--)n=e$(e)+n;return n}function s$(t,e=pk){if(isNaN(t))throw new ku(Wa.EncodeTimeValueMalformed,`Time must be a number: ${t}`);if(t>cx)throw new ku(Wa.EncodeTimeSizeExceeded,`Cannot encode a time larger than ${cx}: ${t}`);if(t<0)throw new ku(Wa.EncodeTimeNegative,`Time must be positive: ${t}`);if(Number.isInteger(t)===!1)throw new ku(Wa.EncodeTimeValueMalformed,`Time must be an integer: ${t}`);let n,r="";for(let s=e;s>0;s--)n=t%Lh,r=hk.charAt(n)+r,t=(t-n)/Lh;return r}function i$(){return typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope}function o$(t,e){const n=t$(),r=Date.now();return s$(r,pk)+r$(QB,n)}const a$=Ys("ChphZ2VudC92MS9jcmVkZW50aWFscy5wcm90bxIIYWdlbnQudjEioQEKCk9BdXRoVG9rZW4SFAoMYWNjZXNzX3Rva2VuGAEgASgJEhIKCnRva2VuX3R5cGUYAiABKAkSFQoNcmVmcmVzaF90b2tlbhgDIAEoCRISCgpleHBpcmVzX2F0GAQgASgDEioKBmV4cGlyeRgFIAEoCzIaLmdvb2dsZS5wcm90b2J1Zi5UaW1lc3RhbXASEgoKZXhwaXJlc19pbhgGIAEoA0JAWj5naXRodWIuY29tL3J1bm1lZGV2L3J1bm1lL3YzL2FwaS9nZW4vcHJvdG8vZ28vYWdlbnQvdjE7YWdlbnR2MWIGcHJvdG8z",[NL]),ux=Wn(a$,0);/*! js-cookie v3.0.5 | MIT */function Wf(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)t[r]=n[r]}return t}var l$={read:function(t){return t[0]==='"'&&(t=t.slice(1,-1)),t.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent)},write:function(t){return encodeURIComponent(t).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,decodeURIComponent)}};function Qg(t,e){function n(s,c,i){if(!(typeof document>"u")){i=Wf({},e,i),typeof i.expires=="number"&&(i.expires=new Date(Date.now()+i.expires*864e5)),i.expires&&(i.expires=i.expires.toUTCString()),s=encodeURIComponent(s).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var o="";for(var u in i)i[u]&&(o+="; "+u,i[u]!==!0&&(o+="="+i[u].split(";")[0]));return document.cookie=s+"="+t.write(c,s)+o}}function r(s){if(!(typeof document>"u"||arguments.length&&!s)){for(var c=document.cookie?document.cookie.split("; "):[],i={},o=0;o<c.length;o++){var u=c[o].split("="),l=u.slice(1).join("=");try{var a=decodeURIComponent(u[0]);if(i[a]=t.read(l,a),s===a)break}catch{}}return s?i[s]:i}}return Object.create({set:n,get:r,remove:function(s,c){n(s,"",Wf({},c,{expires:-1}))},withAttributes:function(s){return Qg(this.converter,Wf({},this.attributes,s))},withConverter:function(s){return Qg(Wf({},this.converter,s),this.attributes)}},{attributes:{value:Object.freeze(e)},converter:{value:Object.freeze(t)}})}var mk=Qg(l$,{path:"/"});const c$=["agent-session","cassie-session"],u$=["agent-oauth-token","cassie-oauth-token"];function eb(){for(const t of c$){const e=mk.get(t);if(e&&e.length>0)return e}}function d$(){let t=qt(ux);for(const e of u$){const n=mk.get(e);if(n&&n.length>0)try{const r=JSON.parse(n);return t=b0(ux,r),t.accessToken}catch(r){console.error("Failed to parse OAuthToken:",r)}}return t.accessToken}const vk=B.createContext(void 0),Ui=()=>{const t=B.useContext(vk);if(!t)throw new Error("useSettings must be used within a SettingsProvider");return t},f$=({children:t,agentEndpoint:e,requireAuth:n,webApp:r,createAuthInterceptors:s})=>{const[c,i]=B.useState(null),o=B.useMemo(()=>{const m=eb();if(!m)return"unauthenticated";let b;try{return b=fk(m),b.email||b.sub||"unauthenticated"}catch(y){return console.error("Error decoding token",y),"unauthenticated"}},[]),u=B.useMemo(()=>{const m=window.location.hostname==="localhost",b=window.location.protocol==="http:",y=window.location.port==="4173"||window.location.port==="5173",_=m&&b&&y;return{requireAuth:n??!1,agentEndpoint:e??(_?"http://localhost:8080":window.location.origin),webApp:{runner:(r==null?void 0:r.runner)??(_?"ws://localhost:8080/ws":`${b?"ws:":"wss:"}//${window.location.host}/ws`),reconnect:(r==null?void 0:r.reconnect)??!0,invertedOrder:(r==null?void 0:r.invertedOrder)??!1}}},[n,r]),[l,a]=B.useState(()=>{const m=localStorage.getItem("cloudAssistantSettings"),b=m?JSON.parse(m):{};return b&&b.webApp&&b.webApp.reconnect!==void 0&&(b.webApp.reconnect=u.webApp.reconnect),m?{...u,...b}:u});B.useEffect(()=>{localStorage.setItem("cloudAssistantSettings",JSON.stringify(l))},[l]);const d=B.useCallback(m=>{const b=y=>{const _=xn.from(y);_.code===ln.Unauthenticated&&(window.location.href=`/login?error=${encodeURIComponent(_.name)}&error_description=${encodeURIComponent(_.message)}`)};return[y=>async _=>{const S=eb();return S&&_.header.set("Authorization",`Bearer ${S}`),m?y(_).catch(x=>{throw b(x),x}):y(_)}]},[]),h=B.useMemo(()=>s??d,[s,d]),p=B.useCallback(async()=>{if(!l.webApp.runner)return;i(null);const m=new uk({knownID:`check_${o$()}`,runID:dk(),sequence:0,options:{runnerEndpoint:l.webApp.runner,interceptors:h(!1),autoReconnect:!1}}),b=[];return b.push(m.errors.subscribe({next:y=>i(y)})),b.push(m.connect(ck.INITIAL).subscribe(y=>{y!==null&&(console.log(`Initial heartbeat latency for streamID ${y.streamID} (${y.readyState===1?"open":"closed"}): ${y.latency}ms`),m.close())})),()=>{b.forEach(y=>y.unsubscribe())}},[s,l.webApp.runner]);B.useEffect(()=>{p()},[p]);const v=m=>{a(b=>({...b,...m,webApp:{...b.webApp,...m.webApp}}))};return ie.jsx(vk.Provider,{value:{principal:o,checkRunnerAuth:p,createAuthInterceptors:h,defaultSettings:u,runnerError:c,settings:l,updateSettings:v},children:t})},gk=B.createContext(void 0),h$=()=>{const t=B.useContext(gk);if(!t)throw new Error("useClient must be used within a ClientProvider");return t},p$=({children:t})=>{const[e,n]=B.useState(),{settings:r,createAuthInterceptors:s}=Ui();return B.useEffect(()=>{n(m$(r.agentEndpoint,s(!0)))},[r.agentEndpoint,s]),ie.jsx(gk.Provider,{value:{client:e,setClient:n},children:t})};function m$(t,e){console.log(`initializing the client: baseURL ${t}`);const n=r5({baseUrl:t,interceptors:e});return Y3(L7,n)}const bk=B.createContext(void 0),z0=()=>{const t=B.useContext(bk);if(!t)throw new Error("useOutput must be used within an OutputProvider");return t},v$=({children:t})=>{const e=B.useMemo(()=>new Map,[]),n=B.useCallback((o,u)=>{e.set(o,u)},[e]),r=B.useCallback(o=>{e.delete(o)},[e]),s=B.useCallback(o=>e.get(o),[e]),c=B.useCallback(()=>e,[e]),i=B.useMemo(()=>({registerRenderer:n,unregisterRenderer:r,getRenderer:s,getAllRenderers:c}),[n,r,s,c]);return ie.jsx(bk.Provider,{value:i,children:t})},yk=B.createContext(void 0),Co=()=>{const t=B.useContext(yk);if(!t)throw new Error("useCell must be used within a CellProvider");return t};function dx(t,e){if(!t)return[];const n=t.positions.map(r=>{const s=t.cells[r];return s.languageId="sh",s});return n.length===0?[]:e?n.reverse():n}const g$=({children:t,getAccessToken:e})=>{const{settings:n,createAuthInterceptors:r,principal:s}=Ui(),[c,i]=B.useState(0),[o,u]=B.useState(!1),[l,a]=B.useState(!1),[d,h]=B.useState(),{getAllRenderers:p}=z0(),v=B.useMemo(()=>{const P=new URL(n.webApp.runner);return P.protocol==="ws:"?P.protocol="http:":P.protocol="https:",P.pathname="",P.toString()},[n.webApp.runner]),m=B.useMemo(()=>{if(s)return new qD("agent",s,e2(H7,v,r(!0)))},[n.agentEndpoint,s]),b=B.useMemo(()=>n.webApp.invertedOrder,[n.webApp.invertedOrder]),{client:y}=h$(),[_,S]=B.useState(void 0),x=B.useCallback(()=>{if(!_)return;const P=dx(_,b),z=qt(MS,{cells:P});d&&(z.metadata[zg.PreviousResponseId]=d),m==null||m.saveNotebook(_.runmeSession,z)},[_,b,d,m]),C=B.useCallback(async({attemptRestore:P})=>{if(!m)return;i(0),h(void 0);const z=m.createSession();let O;if(!P)O=await z;else{const Z=await m.listActiveSessions(),F=(await m.loadSessions(Z)).filter(ae=>ae.data.cells.length!==0);if(F.length===0)O=await z;else{const ae=F[0];let le=ae.data.cells.map(G=>G.refId);b&&(le=le.reverse());const ee=ae.data.metadata[zg.PreviousResponseId];ee&&h(ee),S({runmeSession:ae.id,cells:ae.data.cells.reduce((G,ge)=>(G[ge.refId]=ge,G),{}),positions:le});return}}S({runmeSession:O,cells:{},positions:[]})},[b,m]);B.useEffect(()=>{x()},[_,m,b,x]),B.useEffect(()=>{S(P=>({runmeSession:(P==null?void 0:P.runmeSession)??"",cells:(P==null?void 0:P.cells)??{},positions:[...(P==null?void 0:P.positions)??[]].reverse()}))},[b]),B.useEffect(()=>{C&&C({attemptRestore:!0})},[C]);const j=B.useMemo(()=>_?_.positions.map(P=>_.cells[P]).filter(P=>!!P&&(P.kind===Ts.MARKUP||P.kind===Ts.CODE)):[],[_]),k=B.useMemo(()=>_?_.positions.map(P=>_.cells[P]).filter(P=>!!P&&P.kind===Ts.CODE):[],[_]),A=B.useMemo(()=>_?_.positions.map(P=>_.cells[P]).filter(P=>!!P&&P.kind===Ts.DOC_RESULTS):[],[_]),N=()=>({chat:j,actions:k,files:A}),D=P=>K8(Ou,P),M=async P=>{const z=await e(),O=qt(N7,{cells:P,previousResponseId:d});O.openaiAccessToken=z,z||console.error("No access token found");try{const Z=y.generate(O);for await(const W of Z){for(const F of W.cells)a(!1),J(F);h(W.responseId)}}catch(Z){console.log(Z)}finally{a(!1),u(!1)}},U=async P=>{if(!P.trim())return;const z=qt(Ou,{refId:`user_${BS()}`,role:yo.USER,kind:Ts.MARKUP,value:P});J(z),u(!0),a(!0),await M([z])},Y=async P=>{P.outputs.length!==0&&(console.log("sending output cell",P.refId,"previousResponseId",d),u(!0),a(!0),await M([P]))},J=P=>{const z=p();for(const O of z.values())O.onCellUpdate(P);S(O=>{if(O){if(!O.cells[P.refId]){const Z=b?[P.refId,...O.positions]:[...O.positions,P.refId];return{runmeSession:O.runmeSession,cells:{...O.cells,[P.refId]:P},positions:Z}}return{...O,runmeSession:O.runmeSession,cells:{...O.cells,[P.refId]:P}}}})},te=()=>{const P=`code_${BS().replace(/-/g,"")}`,z=qt(Ou,{metadata:{[cs.ID]:P,[cs.RunmeID]:P},refId:P,languageId:"sh",role:yo.USER,kind:Ts.CODE,value:""});J(z)},Q=P=>{if(!k.find(Z=>Z.refId===P.refId))return;const O=new CustomEvent("runCodeCell",{detail:{cellId:P.refId}});P.executionSummary=void 0,P.outputs=P.outputs.filter(Z=>Z.items.some(W=>W.mime===po.StatefulRunmeTerminal)),i(Z=>{const W=Z+1;return P.metadata[cs.Sequence]=W.toString(),W}),window.dispatchEvent(O)},ne=async({asSessionRecord:P})=>{var ge;const z=dx(_,b);if(!_||z.length===0)return;const O=qt(MS,{cells:z}),Z=e2(R7,n.agentEndpoint),W=qt(A7,{notebook:O,options:qt(T7,{outputs:qt(k7,{enabled:!1,summary:!1})})});P&&((ge=W.options)!=null&&ge.outputs)&&(W.options.outputs.enabled=!0,W.options.outputs.summary=!0,W.options.session=qt(j7,{id:_.runmeSession}));const F=await Z.serialize(W),ae=new Blob([F.result],{type:"text/plain"}),le=URL.createObjectURL(ae),ee=document.createElement("a");ee.href=le;const G=P?"Session":"Notebook";ee.download=`${G}-${l5()}.md`,document.body.appendChild(ee),ee.click(),document.body.removeChild(ee),URL.revokeObjectURL(le)};return ie.jsx(yk.Provider,{value:{useColumns:N,sequence:c,saveState:x,exportDocument:ne,sendOutputCell:Y,createOutputCell:D,sendUserCell:U,addCodeCell:te,isInputDisabled:o,isTyping:l,runCodeCell:Q,resetSession:C},children:t})},fx=new TextEncoder;function b$({pid:t,exitCode:e},n,r,s){let c;return t!==null&&e!==null&&(c=qt(C7,{pid:BigInt(t),exitReason:qt(x7,{type:"exit",code:e})})),[qt(W3,{items:[qt(Fg,{mime:po.VSCodeNotebookStdOut,type:"Buffer",data:fx.encode(n)}),qt(Fg,{mime:po.VSCodeNotebookStdErr,type:"Buffer",data:fx.encode(r)})],processInfo:c})]}const y$=qt(Ou,{kind:Ts.MARKUP,role:yo.ASSISTANT,value:"..."}),tb={fontSize:14,fontFamily:"monospace"},_$=new TextDecoder,w$=B.memo(YB,(t,e)=>t.cellID===e.cellID&&t.runID===e.runID),S$=({cell:t,onExitCode:e,onPid:n})=>{const{createAuthInterceptors:r,settings:{webApp:s}}=Ui(),{sendOutputCell:c,saveState:i}=Co(),o=s.invertedOrder,[u,l]=B.useState(!1),[a,d]=B.useState({value:"",runID:""}),[h,p]=B.useState(null),[v,m]=B.useState(null),[b,y]=B.useState(null),[_,S]=B.useState(null),[x,C]=B.useState(""),[j,k]=B.useState(""),[A,N]=B.useState(""),D=B.useMemo(()=>Number(t.metadata[cs.Sequence]??0),[t,v,b]),M=B.useCallback((le=!1)=>{p(BigInt(Date.now())),C(""),k(""),m(null),y(null),l(le),d({value:t.value,runID:dk()})},[t]),U=B.useMemo(()=>({...tb,className:"rounded-md overflow-hidden",rows:14,scrollToFit:!o,takeFocus:u}),[o,u]);B.useEffect(()=>{const le=ee=>{ee.detail.cellId===t.refId&&M()};return window.addEventListener("runCodeCell",le),()=>{window.removeEventListener("runCodeCell",le)}},[t.refId,M]);const Y=B.useMemo(()=>{const le=t.outputs.filter(G=>G.items.some(ge=>ge.mime===po.StatefulRunmeTerminal)),ee=b$({pid:v,exitCode:b},x,j);return[...le,...ee]},[v,b,x,j,_,t.outputs]);B.useEffect(()=>{h!==null&&(t.outputs=Y,t.executionSummary=qt(E7,{timing:qt(S7,{startTime:h,endTime:BigInt(Date.now())}),executionOrder:D,success:Number.isFinite(b)&&b===0}))},[t,Y,b,D,h]);const J=B.useMemo(()=>v===null||b===null||a.runID===""||!Number.isFinite(v)||!Number.isInteger(b)?null:t,[t,a.runID,b,v]);B.useEffect(()=>{!J||A===a.runID||(N(a.runID),c(J))},[c,J,a.runID,A]),B.useEffect(()=>{v!==null&&n(v)},[v,n]),B.useEffect(()=>{b!==null&&e(b)},[b,e]),B.useEffect(()=>{t.kind===Ts.CODE&&(a.runID!==""&&(t.metadata[cs.LastRunID]=a.runID),v?t.metadata[cs.Pid]=v.toString():delete t.metadata[cs.Pid],b!==null&&Number.isFinite(b)?(delete t.metadata[cs.Pid],t.metadata[cs.ExitCode]=b.toString()):delete t.metadata[cs.ExitCode],i())},[v,b,t,i,a.runID]);const te=B.useMemo(()=>{if(t.kind!==Ts.CODE||A!=="")return;const le=t.outputs.flatMap(ee=>ee.items).find(ee=>ee.mime===po.VSCodeNotebookStdOut);if(le)return _$.decode(le.data)},[t.kind,t.outputs,A]),Q=B.useMemo(()=>{var ee;return((ee=t.metadata)==null?void 0:ee[cs.Pid])??""?t.metadata[cs.LastRunID]??"":""},[t.metadata]),ne=B.useMemo(()=>a.value===""||a.runID===""?[]:a.value.split(`
|
|
6660
6660
|
`),[a]),P=B.useMemo(()=>a.runID===""?Q:a.runID,[a.runID,Q]),z=B.useMemo(()=>({endpoint:s.runner,reconnect:s.reconnect,interceptors:r(!1)}),[s.runner,s.reconnect,r]),O=B.useCallback(le=>{C(ee=>ee+new TextDecoder().decode(le))},[]),Z=B.useCallback(le=>{k(ee=>ee+new TextDecoder().decode(le))},[]),W=B.useCallback(le=>{m(le)},[]),F=B.useCallback(le=>{y(le)},[]),ae=B.useCallback(le=>{S(le)},[]);return ne.length===0&&(!te||te.length===0)?null:ie.jsx(w$,{cellID:t.refId,runID:P,sequence:D,commands:ne,content:te,runner:z,settings:U,onPid:W,onStdout:O,onStderr:Z,onExitCode:F,onMimeType:ae},P)};function x$(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function hx(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(s){return Object.getOwnPropertyDescriptor(t,s).enumerable})),n.push.apply(n,r)}return n}function px(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?hx(Object(n),!0).forEach(function(r){x$(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):hx(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function C$(t,e){if(t==null)return{};var n={},r=Object.keys(t),s,c;for(c=0;c<r.length;c++)s=r[c],!(e.indexOf(s)>=0)&&(n[s]=t[s]);return n}function E$(t,e){if(t==null)return{};var n=C$(t,e),r,s;if(Object.getOwnPropertySymbols){var c=Object.getOwnPropertySymbols(t);for(s=0;s<c.length;s++)r=c[s],!(e.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(t,r)&&(n[r]=t[r])}return n}function j$(t,e){return k$(t)||T$(t,e)||A$(t,e)||I$()}function k$(t){if(Array.isArray(t))return t}function T$(t,e){if(!(typeof Symbol>"u"||!(Symbol.iterator in Object(t)))){var n=[],r=!0,s=!1,c=void 0;try{for(var i=t[Symbol.iterator](),o;!(r=(o=i.next()).done)&&(n.push(o.value),!(e&&n.length===e));r=!0);}catch(u){s=!0,c=u}finally{try{!r&&i.return!=null&&i.return()}finally{if(s)throw c}}return n}}function A$(t,e){if(t){if(typeof t=="string")return mx(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);if(n==="Object"&&t.constructor&&(n=t.constructor.name),n==="Map"||n==="Set")return Array.from(t);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return mx(t,e)}}function mx(t,e){(e==null||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function I$(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
6661
6661
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function O$(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function vx(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(s){return Object.getOwnPropertyDescriptor(t,s).enumerable})),n.push.apply(n,r)}return n}function gx(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?vx(Object(n),!0).forEach(function(r){O$(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):vx(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function R$(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return function(r){return e.reduceRight(function(s,c){return c(s)},r)}}function Tu(t){return function e(){for(var n=this,r=arguments.length,s=new Array(r),c=0;c<r;c++)s[c]=arguments[c];return s.length>=t.length?t.apply(this,s):function(){for(var i=arguments.length,o=new Array(i),u=0;u<i;u++)o[u]=arguments[u];return e.apply(n,[].concat(s,o))}}}function Dh(t){return{}.toString.call(t).includes("Object")}function N$(t){return!Object.keys(t).length}function od(t){return typeof t=="function"}function L$(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function D$(t,e){return Dh(e)||la("changeType"),Object.keys(e).some(function(n){return!L$(t,n)})&&la("changeField"),e}function M$(t){od(t)||la("selectorType")}function P$(t){od(t)||Dh(t)||la("handlerType"),Dh(t)&&Object.values(t).some(function(e){return!od(e)})&&la("handlersType")}function B$(t){t||la("initialIsRequired"),Dh(t)||la("initialType"),N$(t)&&la("initialContent")}function $$(t,e){throw new Error(t[e]||t.default)}var U$={initialIsRequired:"initial state is required",initialType:"initial state should be an object",initialContent:"initial state shouldn't be an empty object",handlerType:"handler should be an object or a function",handlersType:"all handlers should be a functions",selectorType:"selector should be a function",changeType:"provided value of changes should be an object",changeField:'it seams you want to change a field in the state which is not specified in the "initial" state',default:"an unknown error accured in `state-local` package"},la=Tu($$)(U$),Zf={changes:D$,selector:M$,handler:P$,initial:B$};function V$(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};Zf.initial(t),Zf.handler(e);var n={current:t},r=Tu(H$)(n,e),s=Tu(z$)(n),c=Tu(Zf.changes)(t),i=Tu(F$)(n);function o(){var l=arguments.length>0&&arguments[0]!==void 0?arguments[0]:function(a){return a};return Zf.selector(l),l(n.current)}function u(l){R$(r,s,c,i)(l)}return[o,u]}function F$(t,e){return od(e)?e(t.current):e}function z$(t,e){return t.current=gx(gx({},t.current),e),e}function H$(t,e,n){return od(e)?e(t.current):Object.keys(n).forEach(function(r){var s;return(s=e[r])===null||s===void 0?void 0:s.call(e,t.current[r])}),n}var G$={create:V$},W$={paths:{vs:"https://cdn.jsdelivr.net/npm/monaco-editor@0.52.2/min/vs"}};function Z$(t){return function e(){for(var n=this,r=arguments.length,s=new Array(r),c=0;c<r;c++)s[c]=arguments[c];return s.length>=t.length?t.apply(this,s):function(){for(var i=arguments.length,o=new Array(i),u=0;u<i;u++)o[u]=arguments[u];return e.apply(n,[].concat(s,o))}}}function K$(t){return{}.toString.call(t).includes("Object")}function Y$(t){return t||bx("configIsRequired"),K$(t)||bx("configType"),t.urls?(X$(),{paths:{vs:t.urls.monacoBase}}):t}function X$(){console.warn(_k.deprecation)}function q$(t,e){throw new Error(t[e]||t.default)}var _k={configIsRequired:"the configuration object is required",configType:"the configuration object should be an object",default:"an unknown error accured in `@monaco-editor/loader` package",deprecation:`Deprecation warning!
|
|
6662
6662
|
You are using deprecated way of configuration.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SettingsContext.d.ts","sourceRoot":"","sources":["../../src/contexts/SettingsContext.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EAOV,MAAM,OAAO,CAAA;AAEd,OAAO,EAAE,YAAY,EAAE,MAAM,oDAAoD,CAAA;AACjF,OAAO,EAAsB,WAAW,EAAE,MAAM,qBAAqB,CAAA;AACrE,OAAO,EAEL,WAAW,EAGZ,MAAM,yBAAyB,CAAA;AAChC,OAAO,2CAA2C,CAAA;AAOlD,UAAU,QAAQ;IAChB,aAAa,EAAE,MAAM,CAAA;IACrB,WAAW,EAAE,OAAO,CAAA;IACpB,MAAM,EAAE,QAAQ,CAAC,IAAI,CAAC,YAAY,EAAE,WAAW,GAAG,UAAU,CAAC,CAAC,CAAA;CAC/D;AAED,UAAU,mBAAmB;IAC3B,SAAS,EAAE,MAAM,CAAA;IACjB,eAAe,EAAE,MAAM,IAAI,CAAA;IAC3B,sBAAsB,EAAE,CAAC,QAAQ,EAAE,OAAO,KAAK,WAAW,EAAE,CAAA;IAC5D,eAAe,EAAE,QAAQ,CAAA;IACzB,WAAW,EAAE,WAAW,GAAG,IAAI,CAAA;IAC/B,QAAQ,EAAE,QAAQ,CAAA;IAClB,cAAc,EAAE,CAAC,WAAW,EAAE,OAAO,CAAC,QAAQ,CAAC,KAAK,IAAI,CAAA;CACzD;AAOD,eAAO,MAAM,WAAW,2BAMvB,CAAA;AAED,UAAU,qBAAqB;IAC7B,QAAQ,EAAE,SAAS,CAAA;IACnB,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,MAAM,CAAC,EAAE,YAAY,CAAA;IACrB,qEAAqE;IACrE,sBAAsB,CAAC,EAAE,CAAC,QAAQ,EAAE,OAAO,KAAK,WAAW,EAAE,CAAA;CAC9D;AAED,eAAO,MAAM,gBAAgB,GAAI,2EAM9B,qBAAqB,
|
|
1
|
+
{"version":3,"file":"SettingsContext.d.ts","sourceRoot":"","sources":["../../src/contexts/SettingsContext.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EAOV,MAAM,OAAO,CAAA;AAEd,OAAO,EAAE,YAAY,EAAE,MAAM,oDAAoD,CAAA;AACjF,OAAO,EAAsB,WAAW,EAAE,MAAM,qBAAqB,CAAA;AACrE,OAAO,EAEL,WAAW,EAGZ,MAAM,yBAAyB,CAAA;AAChC,OAAO,2CAA2C,CAAA;AAOlD,UAAU,QAAQ;IAChB,aAAa,EAAE,MAAM,CAAA;IACrB,WAAW,EAAE,OAAO,CAAA;IACpB,MAAM,EAAE,QAAQ,CAAC,IAAI,CAAC,YAAY,EAAE,WAAW,GAAG,UAAU,CAAC,CAAC,CAAA;CAC/D;AAED,UAAU,mBAAmB;IAC3B,SAAS,EAAE,MAAM,CAAA;IACjB,eAAe,EAAE,MAAM,IAAI,CAAA;IAC3B,sBAAsB,EAAE,CAAC,QAAQ,EAAE,OAAO,KAAK,WAAW,EAAE,CAAA;IAC5D,eAAe,EAAE,QAAQ,CAAA;IACzB,WAAW,EAAE,WAAW,GAAG,IAAI,CAAA;IAC/B,QAAQ,EAAE,QAAQ,CAAA;IAClB,cAAc,EAAE,CAAC,WAAW,EAAE,OAAO,CAAC,QAAQ,CAAC,KAAK,IAAI,CAAA;CACzD;AAOD,eAAO,MAAM,WAAW,2BAMvB,CAAA;AAED,UAAU,qBAAqB;IAC7B,QAAQ,EAAE,SAAS,CAAA;IACnB,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,MAAM,CAAC,EAAE,YAAY,CAAA;IACrB,qEAAqE;IACrE,sBAAsB,CAAC,EAAE,CAAC,QAAQ,EAAE,OAAO,KAAK,WAAW,EAAE,CAAA;CAC9D;AAED,eAAO,MAAM,gBAAgB,GAAI,2EAM9B,qBAAqB,4CA6KvB,CAAA"}
|
|
@@ -6545,7 +6545,7 @@ Open Dashboard to configure it`)},k=function(){var Se;const Ie=(0,H.getContext)(
|
|
|
6545
6545
|
!*** ./src/client/index.ts ***!
|
|
6546
6546
|
\*****************************/Object.defineProperty(r,"__esModule",{value:!0}),r.ClientMessages=r.setContext=r.activate=void 0;const e=un("./src/constants.ts");Object.defineProperty(r,"ClientMessages",{enumerable:!0,get:function(){return e.ClientMessages}});const t=un("./src/client/utils.ts");Object.defineProperty(r,"setContext",{enumerable:!0,get:function(){return t.setContext}}),un("./src/client/components/index.ts");const s=u=>((0,t.setContext)(u),{renderOutputItem(d,a){var o,c,i;const n=d.json();switch(n.type){case e.OutputType.vercel:if(n.output.error){l(n.output.error);break}const h=document.createElement(e.RENDERERS.VercelOutput);h.setAttribute("content",JSON.stringify(n.output)),a.appendChild(h);break;case e.OutputType.daggerCall:if(!((o=n.output)!=null&&o.cellId))return;const m=document.createElement(e.RENDERERS.DaggerCli);m.setAttribute("cellId",n.output.cellId);const p={...n.output,cli:{status:"active"}};m.setAttribute("state",JSON.stringify(p)),a.appendChild(m);break;case e.OutputType.deno:if((c=n.output)!=null&&c.error){l(n.output.error);break}const f=n.output||{},v=document.createElement(e.RENDERERS.DenoOutput);v.setAttribute("state",JSON.stringify(f)),a.appendChild(v);break;case e.OutputType.outputItems:const g=decodeURIComponent(escape(window.atob(n.output.content))),b=document.createElement(e.RENDERERS.ShellOutput);b.innerHTML=g,a.appendChild(b);const y=document.createElement(e.RENDERERS.ShellOutputItems);y.setAttribute("id",n.output.id),y.setAttribute("content",g),a.appendChild(y);break;case e.OutputType.annotations:const _=document.createElement(e.RENDERERS.EditAnnotations);_.setAttribute("annotations",JSON.stringify(n.output.annotations??[])),_.setAttribute("validationErrors",JSON.stringify(n.output.validationErrors??[])),_.setAttribute("settings",JSON.stringify(n.output.settings)),a.appendChild(_);break;case e.OutputType.terminal:const w=document.createElement(e.RENDERERS.TerminalView);w.setAttribute("id",n.output["runme.dev/id"]),w.setAttribute("fontFamily",n.output.fontFamily),typeof n.output.fontSize=="number"&&w.setAttribute("fontSize",n.output.fontSize.toString()),n.output.cursorStyle&&w.setAttribute("cursorStyle",n.output.cursorStyle),typeof n.output.cursorBlink=="boolean"&&w.setAttribute("cursorBlink",n.output.cursorBlink?"true":"false"),typeof n.output.cursorWidth=="number"&&w.setAttribute("cursorWidth",n.output.cursorWidth.toString()),typeof n.output.smoothScrollDuration=="number"&&w.setAttribute("smoothScrollDuration",n.output.smoothScrollDuration.toString()),typeof n.output.scrollback=="number"&&w.setAttribute("scrollback",n.output.scrollback.toString()),n.output.initialRows!==void 0&&w.setAttribute("initialRows",n.output.initialRows.toString()),n.output.content!==void 0&&w.setAttribute("initialContent",n.output.content),n.output.isAutoSaveEnabled&&w.setAttribute("isAutoSaveEnabled",n.output.isAutoSaveEnabled.toString()),n.output.isPlatformAuthEnabled&&w.setAttribute("isPlatformAuthEnabled",n.output.isPlatformAuthEnabled.toString()),n.output.isDaggerOutput&&w.setAttribute("isDaggerOutput",n.output.isDaggerOutput.toString()),a.appendChild(w);break;case e.OutputType.error:l(n.output);break;case e.OutputType.github:const x=document.createElement(e.RENDERERS.GitHubWorkflowViewer);(i=n.output)!=null&&i.content&&x.setAttribute("state",JSON.stringify(n.output)),a.appendChild(x);break;case e.OutputType.gcp:const S=document.createElement(e.RENDERERS.GCPView);n.output&&S.setAttribute("state",JSON.stringify(n.output)),a.appendChild(S);break;case e.OutputType.aws:const j=document.createElement(e.RENDERERS.AWSView);n.output&&j.setAttribute("state",JSON.stringify(n.output)),a.appendChild(j);break;default:a.innerHTML="No renderer found!"}function l(h){a.innerHTML=`⚠️ ${h}`}},disposeOutputItem(){}});r.activate=s})();const xs=Fs.ClientMessages;Fs.__esModule;Fs.activate;const wb=Fs.setContext,Eh=Di("ChVnb29nbGUvcnBjL2NvZGUucHJvdG8SCmdvb2dsZS5ycGMqtwIKBENvZGUSBgoCT0sQABINCglDQU5DRUxMRUQQARILCgdVTktOT1dOEAISFAoQSU5WQUxJRF9BUkdVTUVOVBADEhUKEURFQURMSU5FX0VYQ0VFREVEEAQSDQoJTk9UX0ZPVU5EEAUSEgoOQUxSRUFEWV9FWElTVFMQBhIVChFQRVJNSVNTSU9OX0RFTklFRBAHEhMKD1VOQVVUSEVOVElDQVRFRBAQEhYKElJFU09VUkNFX0VYSEFVU1RFRBAIEhcKE0ZBSUxFRF9QUkVDT05ESVRJT04QCRILCgdBQk9SVEVEEAoSEAoMT1VUX09GX1JBTkdFEAsSEQoNVU5JTVBMRU1FTlRFRBAMEgwKCElOVEVSTkFMEA0SDwoLVU5BVkFJTEFCTEUQDhINCglEQVRBX0xPU1MQD0JYCg5jb20uZ29vZ2xlLnJwY0IJQ29kZVByb3RvUAFaM2dvb2dsZS5nb2xhbmcub3JnL2dlbnByb3RvL2dvb2dsZWFwaXMvcnBjL2NvZGU7Y29kZaICA1JQQ2IGcHJvdG8z"),Sb=za(Eh,0),xb=Ka(Sb),kh=Di("CiBydW5tZS9zdHJlYW0vdjEvd2Vic29ja2V0cy5wcm90bxIPcnVubWUuc3RyZWFtLnYxIkIKD1dlYnNvY2tldFN0YXR1cxIeCgRjb2RlGAEgASgOMhAuZ29vZ2xlLnJwYy5Db2RlEg8KB21lc3NhZ2UYAiABKAkiGQoEUGluZxIRCgl0aW1lc3RhbXAYASABKAMiGQoEUG9uZxIRCgl0aW1lc3RhbXAYASABKAMiugEKEFdlYnNvY2tldFJlcXVlc3QSOgoPZXhlY3V0ZV9yZXF1ZXN0GAEgASgLMh8ucnVubWUucnVubmVyLnYyLkV4ZWN1dGVSZXF1ZXN0SAASIwoEcGluZxhkIAEoCzIVLnJ1bm1lLnN0cmVhbS52MS5QaW5nEhYKDWF1dGhvcml6YXRpb24YyAEgASgJEhEKCGtub3duX2lkGNIBIAEoCRIPCgZydW5faWQY3AEgASgJQgkKB3BheWxvYWQi2AEKEVdlYnNvY2tldFJlc3BvbnNlEjwKEGV4ZWN1dGVfcmVzcG9uc2UYASABKAsyIC5ydW5tZS5ydW5uZXIudjIuRXhlY3V0ZVJlc3BvbnNlSAASIwoEcG9uZxhkIAEoCzIVLnJ1bm1lLnN0cmVhbS52MS5Qb25nEjEKBnN0YXR1cxjIASABKAsyIC5ydW5tZS5zdHJlYW0udjEuV2Vic29ja2V0U3RhdHVzEhEKCGtub3duX2lkGNIBIAEoCRIPCgZydW5faWQY3AEgASgJQgkKB3BheWxvYWRCSFpGZ2l0aHViLmNvbS9ydW5tZWRldi9ydW5tZS92My9hcGkvZ2VuL3Byb3RvL2dvL3J1bm1lL3N0cmVhbS92MTtzdHJlYW12MWIGcHJvdG8z",[Eh,Mi]),Yo=$s(kh,3),Cb=$s(kh,4);var Jo=function(r,e){return Jo=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,s){t.__proto__=s}||function(t,s){for(var u in s)Object.prototype.hasOwnProperty.call(s,u)&&(t[u]=s[u])},Jo(r,e)};function wn(r,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");Jo(r,e);function t(){this.constructor=r}r.prototype=e===null?Object.create(e):(t.prototype=e.prototype,new t)}function jb(r,e,t,s){function u(d){return d instanceof t?d:new t(function(a){a(d)})}return new(t||(t=Promise))(function(d,a){function o(n){try{i(s.next(n))}catch(l){a(l)}}function c(n){try{i(s.throw(n))}catch(l){a(l)}}function i(n){n.done?d(n.value):u(n.value).then(o,c)}i((s=s.apply(r,[])).next())})}function Ih(r,e){var t={label:0,sent:function(){if(d[0]&1)throw d[1];return d[1]},trys:[],ops:[]},s,u,d,a=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return a.next=o(0),a.throw=o(1),a.return=o(2),typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function o(i){return function(n){return c([i,n])}}function c(i){if(s)throw new TypeError("Generator is already executing.");for(;a&&(a=0,i[0]&&(t=0)),t;)try{if(s=1,u&&(d=i[0]&2?u.return:i[0]?u.throw||((d=u.return)&&d.call(u),0):u.next)&&!(d=d.call(u,i[1])).done)return d;switch(u=0,d&&(i=[i[0]&2,d.value]),i[0]){case 0:case 1:d=i;break;case 4:return t.label++,{value:i[1],done:!1};case 5:t.label++,u=i[1],i=[0];continue;case 7:i=t.ops.pop(),t.trys.pop();continue;default:if(d=t.trys,!(d=d.length>0&&d[d.length-1])&&(i[0]===6||i[0]===2)){t=0;continue}if(i[0]===3&&(!d||i[1]>d[0]&&i[1]<d[3])){t.label=i[1];break}if(i[0]===6&&t.label<d[1]){t.label=d[1],d=i;break}if(d&&t.label<d[2]){t.label=d[2],t.ops.push(i);break}d[2]&&t.ops.pop(),t.trys.pop();continue}i=e.call(r,t)}catch(n){i=[6,n],u=0}finally{s=d=0}if(i[0]&5)throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}}function ns(r){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&r[e],s=0;if(t)return t.call(r);if(r&&typeof r.length=="number")return{next:function(){return r&&s>=r.length&&(r=void 0),{value:r&&r[s++],done:!r}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function dn(r,e){var t=typeof Symbol=="function"&&r[Symbol.iterator];if(!t)return r;var s=t.call(r),u,d=[],a;try{for(;(e===void 0||e-- >0)&&!(u=s.next()).done;)d.push(u.value)}catch(o){a={error:o}}finally{try{u&&!u.done&&(t=s.return)&&t.call(s)}finally{if(a)throw a.error}}return d}function bn(r,e,t){if(arguments.length===2)for(var s=0,u=e.length,d;s<u;s++)(d||!(s in e))&&(d||(d=Array.prototype.slice.call(e,0,s)),d[s]=e[s]);return r.concat(d||Array.prototype.slice.call(e))}function Hn(r){return this instanceof Hn?(this.v=r,this):new Hn(r)}function Eb(r,e,t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var s=t.apply(r,e||[]),u,d=[];return u=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),o("next"),o("throw"),o("return",a),u[Symbol.asyncIterator]=function(){return this},u;function a(m){return function(p){return Promise.resolve(p).then(m,l)}}function o(m,p){s[m]&&(u[m]=function(f){return new Promise(function(v,g){d.push([m,f,v,g])>1||c(m,f)})},p&&(u[m]=p(u[m])))}function c(m,p){try{i(s[m](p))}catch(f){h(d[0][3],f)}}function i(m){m.value instanceof Hn?Promise.resolve(m.value.v).then(n,l):h(d[0][2],m)}function n(m){c("next",m)}function l(m){c("throw",m)}function h(m,p){m(p),d.shift(),d.length&&c(d[0][0],d[0][1])}}function kb(r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=r[Symbol.asyncIterator],t;return e?e.call(r):(r=typeof ns=="function"?ns(r):r[Symbol.iterator](),t={},s("next"),s("throw"),s("return"),t[Symbol.asyncIterator]=function(){return this},t);function s(d){t[d]=r[d]&&function(a){return new Promise(function(o,c){a=r[d](a),u(o,c,a.done,a.value)})}}function u(d,a,o,c){Promise.resolve(c).then(function(i){d({value:i,done:o})},a)}}function Nt(r){return typeof r=="function"}function Th(r){var e=function(s){Error.call(s),s.stack=new Error().stack},t=r(e);return t.prototype=Object.create(Error.prototype),t.prototype.constructor=t,t}var ko=Th(function(r){return function(e){r(this),this.message=e?e.length+` errors occurred during unsubscription:
|
|
6547
6547
|
`+e.map(function(t,s){return s+1+") "+t.toString()}).join(`
|
|
6548
|
-
`):"",this.name="UnsubscriptionError",this.errors=e}});function Oi(r,e){if(r){var t=r.indexOf(e);0<=t&&r.splice(t,1)}}var Vs=function(){function r(e){this.initialTeardown=e,this.closed=!1,this._parentage=null,this._finalizers=null}return r.prototype.unsubscribe=function(){var e,t,s,u,d;if(!this.closed){this.closed=!0;var a=this._parentage;if(a)if(this._parentage=null,Array.isArray(a))try{for(var o=ns(a),c=o.next();!c.done;c=o.next()){var i=c.value;i.remove(this)}}catch(f){e={error:f}}finally{try{c&&!c.done&&(t=o.return)&&t.call(o)}finally{if(e)throw e.error}}else a.remove(this);var n=this.initialTeardown;if(Nt(n))try{n()}catch(f){d=f instanceof ko?f.errors:[f]}var l=this._finalizers;if(l){this._finalizers=null;try{for(var h=ns(l),m=h.next();!m.done;m=h.next()){var p=m.value;try{au(p)}catch(f){d=d??[],f instanceof ko?d=bn(bn([],dn(d)),dn(f.errors)):d.push(f)}}}catch(f){s={error:f}}finally{try{m&&!m.done&&(u=h.return)&&u.call(h)}finally{if(s)throw s.error}}}if(d)throw new ko(d)}},r.prototype.add=function(e){var t;if(e&&e!==this)if(this.closed)au(e);else{if(e instanceof r){if(e.closed||e._hasParent(this))return;e._addParent(this)}(this._finalizers=(t=this._finalizers)!==null&&t!==void 0?t:[]).push(e)}},r.prototype._hasParent=function(e){var t=this._parentage;return t===e||Array.isArray(t)&&t.includes(e)},r.prototype._addParent=function(e){var t=this._parentage;this._parentage=Array.isArray(t)?(t.push(e),t):t?[t,e]:e},r.prototype._removeParent=function(e){var t=this._parentage;t===e?this._parentage=null:Array.isArray(t)&&Oi(t,e)},r.prototype.remove=function(e){var t=this._finalizers;t&&Oi(t,e),e instanceof r&&e._removeParent(this)},r.EMPTY=function(){var e=new r;return e.closed=!0,e}(),r}(),Oh=Vs.EMPTY;function Ah(r){return r instanceof Vs||r&&"closed"in r&&Nt(r.remove)&&Nt(r.add)&&Nt(r.unsubscribe)}function au(r){Nt(r)?r():r.unsubscribe()}var Ib={Promise:void 0},Tb={setTimeout:function(r,e){for(var t=[],s=2;s<arguments.length;s++)t[s-2]=arguments[s];return setTimeout.apply(void 0,bn([r,e],dn(t)))},clearTimeout:function(r){return clearTimeout(r)},delegate:void 0};function Rh(r){Tb.setTimeout(function(){throw r})}function Ps(){}function gi(r){r()}var Ya=function(r){wn(e,r);function e(t){var s=r.call(this)||this;return s.isStopped=!1,t?(s.destination=t,Ah(t)&&t.add(s)):s.destination=Rb,s}return e.create=function(t,s,u){return new Ds(t,s,u)},e.prototype.next=function(t){this.isStopped||this._next(t)},e.prototype.error=function(t){this.isStopped||(this.isStopped=!0,this._error(t))},e.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},e.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,r.prototype.unsubscribe.call(this),this.destination=null)},e.prototype._next=function(t){this.destination.next(t)},e.prototype._error=function(t){try{this.destination.error(t)}finally{this.unsubscribe()}},e.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},e}(Vs),Ob=function(){function r(e){this.partialObserver=e}return r.prototype.next=function(e){var t=this.partialObserver;if(t.next)try{t.next(e)}catch(s){oi(s)}},r.prototype.error=function(e){var t=this.partialObserver;if(t.error)try{t.error(e)}catch(s){oi(s)}else oi(e)},r.prototype.complete=function(){var e=this.partialObserver;if(e.complete)try{e.complete()}catch(t){oi(t)}},r}(),Ds=function(r){wn(e,r);function e(t,s,u){var d=r.call(this)||this,a;return Nt(t)||!t?a={next:t??void 0,error:s??void 0,complete:u??void 0}:a=t,d.destination=new Ob(a),d}return e}(Ya);function oi(r){Rh(r)}function Ab(r){throw r}var Rb={closed:!0,next:Ps,error:Ab,complete:Ps},Ja=function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"}();function Bi(r){return r}function Lb(r){return r.length===0?Bi:r.length===1?r[0]:function(e){return r.reduce(function(t,s){return s(t)},e)}}var Kt=function(){function r(e){e&&(this._subscribe=e)}return r.prototype.lift=function(e){var t=new r;return t.source=this,t.operator=e,t},r.prototype.subscribe=function(e,t,s){var u=this,d=Pb(e)?e:new Ds(e,t,s);return gi(function(){var a=u,o=a.operator,c=a.source;d.add(o?o.call(d,c):c?u._subscribe(d):u._trySubscribe(d))}),d},r.prototype._trySubscribe=function(e){try{return this._subscribe(e)}catch(t){e.error(t)}},r.prototype.forEach=function(e,t){var s=this;return t=lu(t),new t(function(u,d){var a=new Ds({next:function(o){try{e(o)}catch(c){d(c),a.unsubscribe()}},error:d,complete:u});s.subscribe(a)})},r.prototype._subscribe=function(e){var t;return(t=this.source)===null||t===void 0?void 0:t.subscribe(e)},r.prototype[Ja]=function(){return this},r.prototype.pipe=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return Lb(e)(this)},r.prototype.toPromise=function(e){var t=this;return e=lu(e),new e(function(s,u){var d;t.subscribe(function(a){return d=a},function(a){return u(a)},function(){return s(d)})})},r.create=function(e){return new r(e)},r}();function lu(r){var e;return(e=r??Ib.Promise)!==null&&e!==void 0?e:Promise}function Nb(r){return r&&Nt(r.next)&&Nt(r.error)&&Nt(r.complete)}function Pb(r){return r&&r instanceof Ya||Nb(r)&&Ah(r)}function Db(r){return Nt(r==null?void 0:r.lift)}function tr(r){return function(e){if(Db(e))return e.lift(function(t){try{return r(t,this)}catch(s){this.error(s)}});throw new TypeError("Unable to lift unknown Observable type")}}function Ht(r,e,t,s,u){return new Mb(r,e,t,s,u)}var Mb=function(r){wn(e,r);function e(t,s,u,d,a,o){var c=r.call(this,t)||this;return c.onFinalize=a,c.shouldUnsubscribe=o,c._next=s?function(i){try{s(i)}catch(n){t.error(n)}}:r.prototype._next,c._error=d?function(i){try{d(i)}catch(n){t.error(n)}finally{this.unsubscribe()}}:r.prototype._error,c._complete=u?function(){try{u()}catch(i){t.error(i)}finally{this.unsubscribe()}}:r.prototype._complete,c}return e.prototype.unsubscribe=function(){var t;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var s=this.closed;r.prototype.unsubscribe.call(this),!s&&((t=this.onFinalize)===null||t===void 0||t.call(this))}},e}(Ya),Bb=Th(function(r){return function(){r(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}}),Rr=function(r){wn(e,r);function e(){var t=r.call(this)||this;return t.closed=!1,t.currentObservers=null,t.observers=[],t.isStopped=!1,t.hasError=!1,t.thrownError=null,t}return e.prototype.lift=function(t){var s=new cu(this,this);return s.operator=t,s},e.prototype._throwIfClosed=function(){if(this.closed)throw new Bb},e.prototype.next=function(t){var s=this;gi(function(){var u,d;if(s._throwIfClosed(),!s.isStopped){s.currentObservers||(s.currentObservers=Array.from(s.observers));try{for(var a=ns(s.currentObservers),o=a.next();!o.done;o=a.next()){var c=o.value;c.next(t)}}catch(i){u={error:i}}finally{try{o&&!o.done&&(d=a.return)&&d.call(a)}finally{if(u)throw u.error}}}})},e.prototype.error=function(t){var s=this;gi(function(){if(s._throwIfClosed(),!s.isStopped){s.hasError=s.isStopped=!0,s.thrownError=t;for(var u=s.observers;u.length;)u.shift().error(t)}})},e.prototype.complete=function(){var t=this;gi(function(){if(t._throwIfClosed(),!t.isStopped){t.isStopped=!0;for(var s=t.observers;s.length;)s.shift().complete()}})},e.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(e.prototype,"observed",{get:function(){var t;return((t=this.observers)===null||t===void 0?void 0:t.length)>0},enumerable:!1,configurable:!0}),e.prototype._trySubscribe=function(t){return this._throwIfClosed(),r.prototype._trySubscribe.call(this,t)},e.prototype._subscribe=function(t){return this._throwIfClosed(),this._checkFinalizedStatuses(t),this._innerSubscribe(t)},e.prototype._innerSubscribe=function(t){var s=this,u=this,d=u.hasError,a=u.isStopped,o=u.observers;return d||a?Oh:(this.currentObservers=null,o.push(t),new Vs(function(){s.currentObservers=null,Oi(o,t)}))},e.prototype._checkFinalizedStatuses=function(t){var s=this,u=s.hasError,d=s.thrownError,a=s.isStopped;u?t.error(d):a&&t.complete()},e.prototype.asObservable=function(){var t=new Kt;return t.source=this,t},e.create=function(t,s){return new cu(t,s)},e}(Kt),cu=function(r){wn(e,r);function e(t,s){var u=r.call(this)||this;return u.destination=t,u.source=s,u}return e.prototype.next=function(t){var s,u;(u=(s=this.destination)===null||s===void 0?void 0:s.next)===null||u===void 0||u.call(s,t)},e.prototype.error=function(t){var s,u;(u=(s=this.destination)===null||s===void 0?void 0:s.error)===null||u===void 0||u.call(s,t)},e.prototype.complete=function(){var t,s;(s=(t=this.destination)===null||t===void 0?void 0:t.complete)===null||s===void 0||s.call(t)},e.prototype._subscribe=function(t){var s,u;return(u=(s=this.source)===null||s===void 0?void 0:s.subscribe(t))!==null&&u!==void 0?u:Oh},e}(Rr),$b={now:function(){return Date.now()}},Fb=function(r){wn(e,r);function e(t,s){return r.call(this)||this}return e.prototype.schedule=function(t,s){return this},e}(Vs),uu={setInterval:function(r,e){for(var t=[],s=2;s<arguments.length;s++)t[s-2]=arguments[s];return setInterval.apply(void 0,bn([r,e],dn(t)))},clearInterval:function(r){return clearInterval(r)},delegate:void 0},Vb=function(r){wn(e,r);function e(t,s){var u=r.call(this,t,s)||this;return u.scheduler=t,u.work=s,u.pending=!1,u}return e.prototype.schedule=function(t,s){var u;if(s===void 0&&(s=0),this.closed)return this;this.state=t;var d=this.id,a=this.scheduler;return d!=null&&(this.id=this.recycleAsyncId(a,d,s)),this.pending=!0,this.delay=s,this.id=(u=this.id)!==null&&u!==void 0?u:this.requestAsyncId(a,this.id,s),this},e.prototype.requestAsyncId=function(t,s,u){return u===void 0&&(u=0),uu.setInterval(t.flush.bind(t,this),u)},e.prototype.recycleAsyncId=function(t,s,u){if(u===void 0&&(u=0),u!=null&&this.delay===u&&this.pending===!1)return s;s!=null&&uu.clearInterval(s)},e.prototype.execute=function(t,s){if(this.closed)return new Error("executing a cancelled action");this.pending=!1;var u=this._execute(t,s);if(u)return u;this.pending===!1&&this.id!=null&&(this.id=this.recycleAsyncId(this.scheduler,this.id,null))},e.prototype._execute=function(t,s){var u=!1,d;try{this.work(t)}catch(a){u=!0,d=a||new Error("Scheduled action threw falsy error")}if(u)return this.unsubscribe(),d},e.prototype.unsubscribe=function(){if(!this.closed){var t=this,s=t.id,u=t.scheduler,d=u.actions;this.work=this.state=this.scheduler=null,this.pending=!1,Oi(d,this),s!=null&&(this.id=this.recycleAsyncId(u,s,null)),this.delay=null,r.prototype.unsubscribe.call(this)}},e}(Fb),du=function(){function r(e,t){t===void 0&&(t=r.now),this.schedulerActionCtor=e,this.now=t}return r.prototype.schedule=function(e,t,s){return t===void 0&&(t=0),new this.schedulerActionCtor(this,e).schedule(s,t)},r.now=$b.now,r}(),Ub=function(r){wn(e,r);function e(t,s){s===void 0&&(s=du.now);var u=r.call(this,t,s)||this;return u.actions=[],u._active=!1,u}return e.prototype.flush=function(t){var s=this.actions;if(this._active){s.push(t);return}var u;this._active=!0;do if(u=t.execute(t.state,t.delay))break;while(t=s.shift());if(this._active=!1,u){for(;t=s.shift();)t.unsubscribe();throw u}},e}(du),$i=new Ub(Vb),Wb=$i,Lh=new Kt(function(r){return r.complete()});function Nh(r){return r&&Nt(r.schedule)}function qa(r){return r[r.length-1]}function Zb(r){return Nt(qa(r))?r.pop():void 0}function Ph(r){return Nh(qa(r))?r.pop():void 0}function Gb(r,e){return typeof qa(r)=="number"?r.pop():e}var Qa=function(r){return r&&typeof r.length=="number"&&typeof r!="function"};function Dh(r){return Nt(r==null?void 0:r.then)}function Mh(r){return Nt(r[Ja])}function Bh(r){return Symbol.asyncIterator&&Nt(r==null?void 0:r[Symbol.asyncIterator])}function $h(r){return new TypeError("You provided "+(r!==null&&typeof r=="object"?"an invalid object":"'"+r+"'")+" where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.")}function Hb(){return typeof Symbol!="function"||!Symbol.iterator?"@@iterator":Symbol.iterator}var Fh=Hb();function Vh(r){return Nt(r==null?void 0:r[Fh])}function Uh(r){return Eb(this,arguments,function(){var e,t,s,u;return Ih(this,function(d){switch(d.label){case 0:e=r.getReader(),d.label=1;case 1:d.trys.push([1,,9,10]),d.label=2;case 2:return[4,Hn(e.read())];case 3:return t=d.sent(),s=t.value,u=t.done,u?[4,Hn(void 0)]:[3,5];case 4:return[2,d.sent()];case 5:return[4,Hn(s)];case 6:return[4,d.sent()];case 7:return d.sent(),[3,2];case 8:return[3,10];case 9:return e.releaseLock(),[7];case 10:return[2]}})})}function Wh(r){return Nt(r==null?void 0:r.getReader)}function Xt(r){if(r instanceof Kt)return r;if(r!=null){if(Mh(r))return zb(r);if(Qa(r))return Kb(r);if(Dh(r))return Xb(r);if(Bh(r))return Zh(r);if(Vh(r))return Yb(r);if(Wh(r))return Jb(r)}throw $h(r)}function zb(r){return new Kt(function(e){var t=r[Ja]();if(Nt(t.subscribe))return t.subscribe(e);throw new TypeError("Provided object does not correctly implement Symbol.observable")})}function Kb(r){return new Kt(function(e){for(var t=0;t<r.length&&!e.closed;t++)e.next(r[t]);e.complete()})}function Xb(r){return new Kt(function(e){r.then(function(t){e.closed||(e.next(t),e.complete())},function(t){return e.error(t)}).then(null,Rh)})}function Yb(r){return new Kt(function(e){var t,s;try{for(var u=ns(r),d=u.next();!d.done;d=u.next()){var a=d.value;if(e.next(a),e.closed)return}}catch(o){t={error:o}}finally{try{d&&!d.done&&(s=u.return)&&s.call(u)}finally{if(t)throw t.error}}e.complete()})}function Zh(r){return new Kt(function(e){qb(r,e).catch(function(t){return e.error(t)})})}function Jb(r){return Zh(Uh(r))}function qb(r,e){var t,s,u,d;return jb(this,void 0,void 0,function(){var a,o;return Ih(this,function(c){switch(c.label){case 0:c.trys.push([0,5,6,11]),t=kb(r),c.label=1;case 1:return[4,t.next()];case 2:if(s=c.sent(),!!s.done)return[3,4];if(a=s.value,e.next(a),e.closed)return[2];c.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return o=c.sent(),u={error:o},[3,11];case 6:return c.trys.push([6,,9,10]),s&&!s.done&&(d=t.return)?[4,d.call(t)]:[3,8];case 7:c.sent(),c.label=8;case 8:return[3,10];case 9:if(u)throw u.error;return[7];case 10:return[7];case 11:return e.complete(),[2]}})})}function Dn(r,e,t,s,u){s===void 0&&(s=0),u===void 0&&(u=!1);var d=e.schedule(function(){t(),u?r.add(this.schedule(null,s)):this.unsubscribe()},s);if(r.add(d),!u)return d}function Gh(r,e){return e===void 0&&(e=0),tr(function(t,s){t.subscribe(Ht(s,function(u){return Dn(s,r,function(){return s.next(u)},e)},function(){return Dn(s,r,function(){return s.complete()},e)},function(u){return Dn(s,r,function(){return s.error(u)},e)}))})}function Hh(r,e){return e===void 0&&(e=0),tr(function(t,s){s.add(r.schedule(function(){return t.subscribe(s)},e))})}function Qb(r,e){return Xt(r).pipe(Hh(e),Gh(e))}function e0(r,e){return Xt(r).pipe(Hh(e),Gh(e))}function t0(r,e){return new Kt(function(t){var s=0;return e.schedule(function(){s===r.length?t.complete():(t.next(r[s++]),t.closed||this.schedule())})})}function r0(r,e){return new Kt(function(t){var s;return Dn(t,e,function(){s=r[Fh](),Dn(t,e,function(){var u,d,a;try{u=s.next(),d=u.value,a=u.done}catch(o){t.error(o);return}a?t.complete():t.next(d)},0,!0)}),function(){return Nt(s==null?void 0:s.return)&&s.return()}})}function zh(r,e){if(!r)throw new Error("Iterable cannot be null");return new Kt(function(t){Dn(t,e,function(){var s=r[Symbol.asyncIterator]();Dn(t,e,function(){s.next().then(function(u){u.done?t.complete():t.next(u.value)})},0,!0)})})}function n0(r,e){return zh(Uh(r),e)}function s0(r,e){if(r!=null){if(Mh(r))return Qb(r,e);if(Qa(r))return t0(r,e);if(Dh(r))return e0(r,e);if(Bh(r))return zh(r,e);if(Vh(r))return r0(r,e);if(Wh(r))return n0(r,e)}throw $h(r)}function Kh(r,e){return e?s0(r,e):Xt(r)}function i0(){for(var r=[],e=0;e<arguments.length;e++)r[e]=arguments[e];var t=Ph(r);return Kh(r,t)}function o0(r){return r instanceof Date&&!isNaN(r)}function Ar(r,e){return tr(function(t,s){var u=0;t.subscribe(Ht(s,function(d){s.next(r.call(e,d,u++))}))})}var a0=Array.isArray;function l0(r,e){return a0(e)?r.apply(void 0,bn([],dn(e))):r(e)}function c0(r){return Ar(function(e){return l0(r,e)})}function u0(r,e,t,s,u,d,a,o){var c=[],i=0,n=0,l=!1,h=function(){l&&!c.length&&!i&&e.complete()},m=function(f){return i<s?p(f):c.push(f)},p=function(f){i++;var v=!1;Xt(t(f,n++)).subscribe(Ht(e,function(g){e.next(g)},function(){v=!0},void 0,function(){if(v)try{i--;for(var g=function(){var b=c.shift();a||p(b)};c.length&&i<s;)g();h()}catch(b){e.error(b)}}))};return r.subscribe(Ht(e,m,function(){l=!0,h()})),function(){}}function Rn(r,e,t){return t===void 0&&(t=1/0),Nt(e)?Rn(function(s,u){return Ar(function(d,a){return e(s,d,u,a)})(Xt(r(s,u)))},t):(typeof e=="number"&&(t=e),tr(function(s,u){return u0(s,u,r,t)}))}function d0(r){return r===void 0&&(r=1/0),Rn(Bi,r)}function h0(r){return new Kt(function(e){Xt(r()).subscribe(e)})}var f0={connector:function(){return new Rr},resetOnDisconnect:!0};function On(r,e){e===void 0&&(e=f0);var t=null,s=e.connector,u=e.resetOnDisconnect,d=u===void 0?!0:u,a=s(),o=new Kt(function(c){return a.subscribe(c)});return o.connect=function(){return(!t||t.closed)&&(t=h0(function(){return r}).subscribe(a),d&&t.add(function(){return a=s()})),t},o}var p0=["addListener","removeListener"],m0=["addEventListener","removeEventListener"],v0=["on","off"];function qo(r,e,t,s){if(Nt(t)&&(s=t,t=void 0),s)return qo(r,e,t).pipe(c0(s));var u=dn(y0(r)?m0.map(function(o){return function(c){return r[o](e,c,t)}}):g0(r)?p0.map(hu(r,e)):b0(r)?v0.map(hu(r,e)):[],2),d=u[0],a=u[1];if(!d&&Qa(r))return Rn(function(o){return qo(o,e,t)})(Xt(r));if(!d)throw new TypeError("Invalid event target");return new Kt(function(o){var c=function(){for(var i=[],n=0;n<arguments.length;n++)i[n]=arguments[n];return o.next(1<i.length?i:i[0])};return d(c),function(){return a(c)}})}function hu(r,e){return function(t){return function(s){return r[t](e,s)}}}function g0(r){return Nt(r.addListener)&&Nt(r.removeListener)}function b0(r){return Nt(r.on)&&Nt(r.off)}function y0(r){return Nt(r.addEventListener)&&Nt(r.removeEventListener)}function Cs(r,e,t){r===void 0&&(r=0),t===void 0&&(t=Wb);var s=-1;return e!=null&&(Nh(e)?t=e:s=e),new Kt(function(u){var d=o0(r)?+r-t.now():r;d<0&&(d=0);var a=0;return t.schedule(function(){u.closed||(u.next(a++),0<=s?this.schedule(void 0,s):u.complete())},d)})}function _0(r,e){return e===void 0&&(e=$i),Cs(r,r,e)}function w0(){for(var r=[],e=0;e<arguments.length;e++)r[e]=arguments[e];var t=Ph(r),s=Gb(r,1/0),u=r;return u.length?u.length===1?Xt(u[0]):d0(s)(Kh(u,t)):Lh}var S0=Array.isArray;function x0(r){return r.length===1&&S0(r[0])?r[0]:r}function gn(r,e){return tr(function(t,s){var u=0;t.subscribe(Ht(s,function(d){return r.call(e,d,u++)&&s.next(d)}))})}function C0(){for(var r=[],e=0;e<arguments.length;e++)r[e]=arguments[e];return r=x0(r),r.length===1?Xt(r[0]):new Kt(j0(r))}function j0(r){return function(e){for(var t=[],s=function(d){t.push(Xt(r[d]).subscribe(Ht(e,function(a){if(t){for(var o=0;o<t.length;o++)o!==d&&t[o].unsubscribe();t=null}e.next(a)})))},u=0;t&&!e.closed&&u<r.length;u++)s(u)}}function E0(r){return tr(function(e,t){var s=null,u=null,d=function(){u==null||u.unsubscribe();var a=s;s=[],a&&t.next(a),Xt(r()).subscribe(u=Ht(t,d,Ps))};d(),e.subscribe(Ht(t,function(a){return s==null?void 0:s.push(a)},function(){s&&t.next(s),t.complete()},void 0,function(){return s=u=null}))})}function Xh(r){return tr(function(e,t){var s=null,u=!1,d;s=e.subscribe(Ht(t,void 0,void 0,function(a){d=Xt(r(a,Xh(r)(e))),s?(s.unsubscribe(),s=null,d.subscribe(t)):u=!0})),u&&(s.unsubscribe(),s=null,d.subscribe(t))})}function k0(r,e,t,s,u){return function(d,a){var o=t,c=e,i=0;d.subscribe(Ht(a,function(n){var l=i++;c=o?r(c,n,l):(o=!0,n),a.next(c)},u))}}function fu(r){return r<=0?function(){return Lh}:tr(function(e,t){var s=0;e.subscribe(Ht(t,function(u){++s<=r&&(t.next(u),r<=s&&t.complete())}))})}function I0(r){return tr(function(e,t){try{e.subscribe(t)}finally{t.add(r)}})}function T0(r,e){return tr(k0(r,e,arguments.length>=2,!0))}function O0(r){r===void 0&&(r={});var e=r.connector,t=e===void 0?function(){return new Rr}:e,s=r.resetOnError,u=s===void 0?!0:s,d=r.resetOnComplete,a=d===void 0?!0:d,o=r.resetOnRefCountZero,c=o===void 0?!0:o;return function(i){var n,l,h,m=0,p=!1,f=!1,v=function(){l==null||l.unsubscribe(),l=void 0},g=function(){v(),n=h=void 0,p=f=!1},b=function(){var y=n;g(),y==null||y.unsubscribe()};return tr(function(y,_){m++,!f&&!p&&v();var w=h=h??t();_.add(function(){m--,m===0&&!f&&!p&&(l=Io(b,c))}),w.subscribe(_),!n&&m>0&&(n=new Ds({next:function(x){return w.next(x)},error:function(x){f=!0,v(),l=Io(g,u,x),w.error(x)},complete:function(){p=!0,v(),l=Io(g,a),w.complete()}}),Xt(y).subscribe(n))})(i)}}function Io(r,e){for(var t=[],s=2;s<arguments.length;s++)t[s-2]=arguments[s];if(e===!0){r();return}if(e!==!1){var u=new Ds({next:function(){u.unsubscribe(),r()}});return Xt(e.apply(void 0,bn([],dn(t)))).subscribe(u)}}function A0(r){return tr(function(e,t){var s=!1,u=Ht(t,function(){u==null||u.unsubscribe(),s=!0},Ps);Xt(r).subscribe(u),e.subscribe(Ht(t,function(d){return s&&t.next(d)}))})}function pu(r,e){return tr(function(t,s){var u=null,d=0,a=!1,o=function(){return a&&!u&&s.complete()};t.subscribe(Ht(s,function(c){u==null||u.unsubscribe();var i=0,n=d++;Xt(r(c,n)).subscribe(u=Ht(s,function(l){return s.next(e?e(c,l,n,i++):l)},function(){u=null,o()}))},function(){a=!0,o()}))})}function ai(r,e){return e===void 0&&(e=!1),tr(function(t,s){var u=0;t.subscribe(Ht(s,function(d){var a=r(d,u++);(a||e)&&s.next(d),!a&&s.complete()}))})}function R0(r,e,t){var s=Nt(r)||e||t?{next:r,error:e,complete:t}:r;return s?tr(function(u,d){var a;(a=s.subscribe)===null||a===void 0||a.call(s);var o=!0;u.subscribe(Ht(d,function(c){var i;(i=s.next)===null||i===void 0||i.call(s,c),d.next(c)},function(){var c;o=!1,(c=s.complete)===null||c===void 0||c.call(s),d.complete()},function(c){var i;o=!1,(i=s.error)===null||i===void 0||i.call(s,c),d.error(c)},function(){var c,i;o&&((c=s.unsubscribe)===null||c===void 0||c.call(s)),(i=s.finalize)===null||i===void 0||i.call(s)}))}):Bi}function L0(r,e){return tr(function(t,s){var u=e??{},d=u.leading,a=d===void 0?!0:d,o=u.trailing,c=o===void 0?!1:o,i=!1,n=null,l=null,h=!1,m=function(){l==null||l.unsubscribe(),l=null,c&&(v(),h&&s.complete())},p=function(){l=null,h&&s.complete()},f=function(g){return l=Xt(r(g)).subscribe(Ht(s,m,p))},v=function(){if(i){i=!1;var g=n;n=null,s.next(g),!h&&f(g)}};t.subscribe(Ht(s,function(g){i=!0,n=g,!(l&&!l.closed)&&(a?v():f(g))},function(){h=!0,!(c&&i&&l&&!l.closed)&&s.complete()}))})}function mu(r,e,t){e===void 0&&(e=$i);var s=Cs(r,e);return L0(function(){return s},t)}function To(){for(var r=[],e=0;e<arguments.length;e++)r[e]=arguments[e];var t=Zb(r);return tr(function(s,u){for(var d=r.length,a=new Array(d),o=r.map(function(){return!1}),c=!1,i=function(l){Xt(r[l]).subscribe(Ht(u,function(h){a[l]=h,!c&&!o[l]&&(o[l]=!0,(c=o.every(Bi))&&(o=null))},Ps))},n=0;n<d;n++)i(n);s.subscribe(Ht(u,function(l){if(c){var h=bn([l],dn(a));u.next(t?t.apply(void 0,bn([],dn(h))):h)}}))})}const Yh="0123456789ABCDEFGHJKMNPQRSTVWXYZ",Ai=32,N0=16,Jh=10,vu=0xffffffffffff;var Ln;(function(r){r.Base32IncorrectEncoding="B32_ENC_INVALID",r.DecodeTimeInvalidCharacter="DEC_TIME_CHAR",r.DecodeTimeValueMalformed="DEC_TIME_MALFORMED",r.EncodeTimeNegative="ENC_TIME_NEG",r.EncodeTimeSizeExceeded="ENC_TIME_SIZE_EXCEED",r.EncodeTimeValueMalformed="ENC_TIME_MALFORMED",r.PRNGDetectFailure="PRNG_DETECT",r.ULIDInvalid="ULID_INVALID",r.Unexpected="UNEXPECTED",r.UUIDInvalid="UUID_INVALID"})(Ln||(Ln={}));class bs extends Error{constructor(e,t){super(`${t} (${e})`),this.name="ULIDError",this.code=e}}function P0(r){const e=Math.floor(r()*Ai)%Ai;return Yh.charAt(e)}function D0(r){const e=M0(),t=e&&(e.crypto||e.msCrypto)||null;if(typeof(t==null?void 0:t.getRandomValues)=="function")return()=>{const s=new Uint8Array(1);return t.getRandomValues(s),s[0]/255};if(typeof(t==null?void 0:t.randomBytes)=="function")return()=>t.randomBytes(1).readUInt8()/255;throw new bs(Ln.PRNGDetectFailure,"Failed to find a reliable PRNG")}function M0(){return F0()?self:typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:null}function B0(r,e){let t="";for(;r>0;r--)t=P0(e)+t;return t}function $0(r,e=Jh){if(isNaN(r))throw new bs(Ln.EncodeTimeValueMalformed,`Time must be a number: ${r}`);if(r>vu)throw new bs(Ln.EncodeTimeSizeExceeded,`Cannot encode a time larger than ${vu}: ${r}`);if(r<0)throw new bs(Ln.EncodeTimeNegative,`Time must be positive: ${r}`);if(Number.isInteger(r)===!1)throw new bs(Ln.EncodeTimeValueMalformed,`Time must be an integer: ${r}`);let t,s="";for(let u=e;u>0;u--)t=r%Ai,s=Yh.charAt(t)+s,r=(r-t)/Ai;return s}function F0(){return typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope}function V0(r,e){const t=D0(),s=Date.now();return $0(s,Jh)+B0(N0,t)}const er=[];for(let r=0;r<256;++r)er.push((r+256).toString(16).slice(1));function U0(r,e=0){return(er[r[e+0]]+er[r[e+1]]+er[r[e+2]]+er[r[e+3]]+"-"+er[r[e+4]]+er[r[e+5]]+"-"+er[r[e+6]]+er[r[e+7]]+"-"+er[r[e+8]]+er[r[e+9]]+"-"+er[r[e+10]]+er[r[e+11]]+er[r[e+12]]+er[r[e+13]]+er[r[e+14]]+er[r[e+15]]).toLowerCase()}let Oo;const W0=new Uint8Array(16);function Z0(){if(!Oo){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");Oo=crypto.getRandomValues.bind(crypto)}return Oo(W0)}const G0=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),gu={randomUUID:G0};function H0(r,e,t){var s;if(gu.randomUUID&&!r)return gu.randomUUID();r=r||{};const u=r.random??((s=r.rng)==null?void 0:s.call(r))??Z0();if(u.length<16)throw new Error("Random bytes length must be >= 16");return u[6]=u[6]&15|64,u[8]=u[8]&63|128,U0(u)}const z0=5e3,K0=1e3,li=4e3,bu=1e3;var qh=(r=>(r.CONTINUOUS="CONTINUOUS",r.INITIAL="INITIAL",r))(qh||{});class Qh{constructor({knownID:e,runID:t,sequence:s,options:u}){Ft(this,"callback"),Ft(this,"queue",new Rr),Ft(this,"subscriptions",[]),Ft(this,"reconnect",new Rr),Ft(this,"client",new Kt),Ft(this,"_latencies",new Rr),Ft(this,"_latenciesConnectable",On(this._latencies.asObservable().pipe(T0((d,a)=>{if(a.latency<0){const o=d.get(a.streamID);o&&d.set(a.streamID,{...o,readyState:a.readyState})}else d.set(a.streamID,a);return d},new Map)))),Ft(this,"_errors",new Rr),Ft(this,"_errorsConnectable",On(this._errors.asObservable())),Ft(this,"_stdout",new Rr),Ft(this,"_stderr",new Rr),Ft(this,"_exitCode",new Rr),Ft(this,"_pid",new Rr),Ft(this,"_mimeType",new Rr),Ft(this,"_stdoutConnectable",On(this._stdout.asObservable())),Ft(this,"_stderrConnectable",On(this._stderr.asObservable())),Ft(this,"_exitCodeConnectable",On(this._exitCode.asObservable())),Ft(this,"_pidConnectable",On(this._pid.asObservable())),Ft(this,"_mimeTypeConnectable",On(this._mimeType.asObservable())),Ft(this,"knownID"),Ft(this,"runID"),Ft(this,"sequence"),Ft(this,"runnerEndpoint"),Ft(this,"interceptors"),Ft(this,"autoReconnect"),this.knownID=e,this.runID=t,this.sequence=s,this.runnerEndpoint=u.runnerEndpoint,this.interceptors=u.interceptors,this.autoReconnect=u.autoReconnect,this._latenciesConnectable.connect(),this._errorsConnectable.connect(),this._stdoutConnectable.connect(),this._stderrConnectable.connect(),this._exitCodeConnectable.connect(),this._pidConnectable.connect(),this._mimeTypeConnectable.connect(),this.client=this.reconnect.pipe(mu(bu,$i,{leading:!0,trailing:!0}),pu(d=>this.useSocketClient(d.streamID).pipe(pu(a=>this.useHeartbeat(a,d))))).pipe(O0()),this.subscriptions.push(this.monitor()),this.subscriptions.push(this.process())}get latencies(){return this._latenciesConnectable}get errors(){return this._errorsConnectable}get stdout(){return this._stdoutConnectable}get stderr(){return this._stderrConnectable}get exitCode(){return this._exitCodeConnectable}get pid(){return this._pidConnectable}get mimeType(){return this._mimeTypeConnectable}monitor(){return _0(K0).pipe(gn(()=>this.autoReconnect),To(this.reconnect),gn(([,e])=>e.heartbeat==="CONTINUOUS"),To(this.latencies),Ar(([,e])=>Array.from(e.values()).filter(t=>t.readyState===WebSocket.OPEN&&t.latency>=li)),gn(e=>e.length>0),mu(bu)).subscribe({next:e=>{console.log(new Date,"Triggering reconnect",e),this.connect()},complete:()=>{console.log("Monitor complete")},error:e=>{console.error("Error in monitor",e)}})}process(){const e=this.client.pipe(gn(u=>(u==null?void 0:u.readyState)===WebSocket.OPEN),fu(1)),t=this.queue.pipe(E0(()=>e),gn(u=>u.length>0),Ar(u=>u.sort((d,a)=>{const o=c=>{var i;return!!((i=c.payload.value)!=null&&i.config)};return o(a)?1:o(d)?-1:0}))),s=this.queue.pipe(A0(e));return w0(t.pipe(Rn(u=>u)),s).pipe(To(this.client),ai(([,u])=>u.readyState===WebSocket.OPEN),Rn(async([u,d])=>{await _u({req:u,interceptors:this.interceptors,socket:d,knownID:this.knownID,runID:this.runID})})).subscribe({error:u=>{this._errors.next(u)}})}useSocketClient(e){return new Kt(t=>{const s=new URL(this.runnerEndpoint);s.searchParams.set("id",e),s.searchParams.set("runID",this.runID);const u=new WebSocket(s.toString()),d=i=>{if(console.log(new Date,`WebSocket transport ${e} closed`,i),i.code===1005){t.complete();return}if(this.autoReconnect){this.connect();return}},a=i=>{console.log(new Date,`WebSocket transport ${e} error`,i),this.autoReconnect||t.error(i)},o=i=>{var n,l;if(typeof i.data!="string"){console.warn("Unexpected WebSocket message type:",typeof i.data);return}let h;try{h=yu(i.data),console.log("Received WebsocketResponse:",h)}catch(f){console.error("Failed to parse WebsocketResponse:",f)}const m=h.status;if(m&&m.code!==xb.OK){t.error(m);return}if(h.pong)return;const p=h.payload.value;if(p.stdoutData&&p.stdoutData.length>0&&((n=this.callback)==null||n.call(this,{type:xs.terminalStdout,output:{"runme.dev/id":this.knownID,data:p.stdoutData}}),this._stdout.next(p.stdoutData)),p.stderrData&&p.stderrData.length>0&&((l=this.callback)==null||l.call(this,{type:xs.terminalStderr,output:{"runme.dev/id":this.knownID,data:p.stderrData}}),this._stderr.next(p.stderrData)),p.exitCode!==void 0&&(this._exitCode.next(p.exitCode),t.complete()),p.pid!==void 0&&this._pid.next(p.pid),p.mimeType){const f=p.mimeType.split(";")[0];this._mimeType.next(f)}},c=()=>{console.log(new Date,`✅ Connected WebSocket for cell ${this.knownID} (#${this.sequence}) with runID ${this.runID}`),t.next(u)};return u.addEventListener("close",d),u.addEventListener("error",a),u.addEventListener("message",o),u.addEventListener("open",c),()=>{console.log(new Date,`☑️ Cleanly disconnected WebSocket for cell ${this.knownID} (#${this.sequence}) with runID ${this.runID}`),u.removeEventListener("close",d),u.removeEventListener("error",a),u.removeEventListener("message",o),u.removeEventListener("open",c),u.close()}})}setCallback(e){this.callback=e}sendExecuteRequest(e){this.queue.next(vt.create(Yo,{payload:{value:e,case:"executeRequest"}}))}useHeartbeat(e,{streamID:t,heartbeat:s}){return new Kt(u=>{const d=qo(e,"message").pipe(ai(()=>e.readyState===WebSocket.OPEN),Ar(c=>yu(c.data)),Ar(c=>c.pong),gn(c=>c!==void 0),Ar(c=>({receivedAt:BigInt(Date.now()),pong:c}))),a=(s==="INITIAL"?Cs(0):Cs(0,z0)).pipe(ai(()=>e.readyState===WebSocket.OPEN),Ar(()=>{const c={timestamp:BigInt(Date.now())};return vt.create(Yo,{ping:c})}),Rn(async c=>(await _u({req:c,interceptors:this.interceptors,socket:e}),c)),Ar(c=>c.ping)).pipe(gn(c=>(c==null?void 0:c.timestamp)!==void 0),Rn(c=>C0(d.pipe(gn(i=>i.pong.timestamp===c.timestamp),fu(1),Ar(i=>{const n=c.timestamp,l=i.receivedAt;return Number(l-n)})),Cs(li).pipe(Ar(()=>{throw new Error(`Pong not received within ${li}ms for stream ${t}`)}))).pipe(Xh(i=>(this._latencies.next({streamID:t,latency:li,readyState:e.readyState,updatedAt:BigInt(Date.now())}),console.log(new Date,"Ping deadline exceeded",i.message),i0(null))))),I0(()=>{this._latencies.next({streamID:t,latency:-1,readyState:e.readyState,updatedAt:BigInt(Date.now())})}),R0(c=>{c!==null&&this._latencies.next({streamID:t,latency:c,readyState:e.readyState,updatedAt:BigInt(Date.now())})})),o=[];return o.push(a.subscribe({error:c=>{console.error("Unexpected error sending heartbeat",c)}})),u.next(e),()=>{o.forEach(c=>c.unsubscribe())}})}connect(e="CONTINUOUS"){const t=X0(),s=this.latencies.pipe(Ar(u=>{const d=u.get(t);return d===void 0?null:d}),ai(u=>(u==null?void 0:u.readyState)===WebSocket.OPEN));return this.reconnect.next({streamID:t,heartbeat:e}),s}close(){this.reconnect.complete(),this.queue.complete(),this._latencies.complete(),this.subscriptions.forEach(e=>e.unsubscribe())}}function yu(r){const e=JSON.parse(r);return vt.fromJson(Cb,e)}async function _u({req:r,interceptors:e,socket:t,knownID:s,runID:u}){s&&(r.knownId=s),u&&(r.runId=u);const d={stream:!1,message:{},method:{},service:{},requestMethod:"UPGRADE",url:t.url,signal:new AbortController().signal,header:new Headers,contextValues:{}};let a=async c=>({stream:!1,message:{},method:{},service:{},header:c.header});for(const c of e.concat().reverse())a=c(a);const o=(await a(d)).header.get("Authorization");o&&r&&(r.authorization=o),t.send(JSON.stringify(vt.toJson(Yo,r)))}function X0(){return H0().replace(/-/g,"")}function ef(){return`run_${V0()}`}function Y0({cellID:r,runID:e,sequence:t,commands:s,content:u,runner:d,settings:a={},onStdout:o,onStderr:c,onExitCode:i,onPid:n,onMimeType:l}){var h;const{rows:m=20,className:p,fontSize:f=12,fontFamily:v="monospace",takeFocus:g=!0,scrollToFit:b=!0}=a,y=Ae.useMemo(()=>!r||u===""?null:u,[r,u]),_=Ae.useMemo(()=>{if(!(!r||!e||!d.endpoint))return console.log("Creating stream",r,e,d.endpoint),new Qh({knownID:r,runID:e,sequence:t,options:{runnerEndpoint:d.endpoint,interceptors:d.interceptors,autoReconnect:d.reconnect}})},[r,e,t,d]);Ae.useEffect(()=>{const k=_==null?void 0:_.connect().subscribe(O=>console.log(`Heartbeat latency for streamID ${O==null?void 0:O.streamID} (${(O==null?void 0:O.readyState)===1?"open":"closed"}): ${O==null?void 0:O.latency}ms`));return()=>{k==null||k.unsubscribe(),_==null||_.close()}},[_]);let w=vt.create(iu,{rows:34,cols:100,x:0,y:0});const x=Ae.useMemo(()=>vt.create(Eo,{sessionStrategy:yb.MOST_RECENT,storeStdoutInEnv:!0,config:{languageId:"sh",background:!1,fileExtension:"",env:[`RUNME_ID=${r}`,"RUNME_RUNNER=v2","TERM=xterm-256color"],source:{case:"commands",value:{items:s}},interactive:!0,mode:gb.INLINE,runId:e,knownId:r},winsize:w}),[r,e,s,w]),S=Ae.useMemo(()=>{var k;return{output:{"runme.dev/id":(k=x.config)==null?void 0:k.knownId,fontFamily:v||"monospace",fontSize:f||12,cursorStyle:"block",cursorBlink:!0,cursorWidth:1,takeFocus:g,scrollToFit:b,smoothScrollDuration:0,scrollback:4e3,initialRows:m,content:y||"",isAutoSaveEnabled:!1,isPlatformAuthEnabled:!1}}},[(h=x.config)==null?void 0:h.knownId,v,f,g,b,m,y]),j=new TextEncoder;return wb({postMessage:k=>{if(k.type===xs.terminalOpen||k.type===xs.terminalResize){const O=Number(k.output.terminalDimensions.columns),T=Number(k.output.terminalDimensions.rows);if(Number.isFinite(O)&&Number.isFinite(T)){if(w.cols===O&&w.rows===T)return;w=vt.create(iu,{cols:O,rows:T,x:0,y:0});const L=vt.create(Eo,{winsize:w});_==null||_.sendExecuteRequest(L)}}if(k.type===xs.terminalStdin){const O=j.encode(k.output.input),T=vt.create(Eo,{inputData:O});_==null||_.sendExecuteRequest(T)}},onDidReceiveMessage:k=>{_==null||_.setCallback(k)}}),Ae.useEffect(()=>{const k=_==null?void 0:_.stdout.subscribe(O=>{o==null||o(O)});return()=>k==null?void 0:k.unsubscribe()},[_,o]),Ae.useEffect(()=>{const k=_==null?void 0:_.stderr.subscribe(O=>{c==null||c(O)});return()=>k==null?void 0:k.unsubscribe()},[_,c]),Ae.useEffect(()=>{const k=_==null?void 0:_.exitCode.subscribe(O=>{i==null||i(O),_==null||_.close()});return()=>k==null?void 0:k.unsubscribe()},[_,i]),Ae.useEffect(()=>{const k=_==null?void 0:_.pid.subscribe(O=>{n==null||n(O)});return()=>k==null?void 0:k.unsubscribe()},[_,n]),Ae.useEffect(()=>{const k=_==null?void 0:_.mimeType.subscribe(O=>{l==null||l(O)});return()=>k==null?void 0:k.unsubscribe()},[_,l]),Ae.useEffect(()=>{!_||!x||(console.log("useEffect invoked - Commands changed:",JSON.stringify(x.config.source.value)),_==null||_.sendExecuteRequest(x))},[x,_]),oe.jsx("div",{className:p,ref:k=>{if(!k||k.hasChildNodes())return;const O=document.createElement("terminal-view");O.setAttribute("buttons","false"),O.setAttribute("id",S.output["runme.dev/id"]),O.setAttribute("fontFamily",S.output.fontFamily),typeof S.output.fontSize=="number"&&O.setAttribute("fontSize",S.output.fontSize.toString()),S.output.cursorStyle&&O.setAttribute("cursorStyle",S.output.cursorStyle),typeof S.output.cursorBlink=="boolean"&&O.setAttribute("cursorBlink",S.output.cursorBlink?"true":"false"),typeof S.output.cursorWidth=="number"&&O.setAttribute("cursorWidth",S.output.cursorWidth.toString()),typeof S.output.takeFocus=="boolean"&&O.setAttribute("takeFocus",S.output.takeFocus?"true":"false"),typeof S.output.smoothScrollDuration=="number"&&O.setAttribute("smoothScrollDuration",S.output.smoothScrollDuration.toString()),typeof S.output.scrollback=="number"&&O.setAttribute("scrollback",S.output.scrollback.toString()),S.output.initialRows!==void 0&&O.setAttribute("initialRows",S.output.initialRows.toString()),S.output.content!==void 0&&O.setAttribute("initialContent",S.output.content),S.output.isAutoSaveEnabled&&O.setAttribute("isAutoSaveEnabled",S.output.isAutoSaveEnabled.toString()),S.output.isPlatformAuthEnabled&&O.setAttribute("isPlatformAuthEnabled",S.output.isPlatformAuthEnabled.toString()),k.appendChild(O);const T=document.createElement("div");T.setAttribute("className","h-1"),k.appendChild(T),setTimeout(()=>{b&&!J0(T)&&T.scrollIntoView({behavior:"smooth"})},0)}})}function J0(r){const e=r.getBoundingClientRect();return e.top>=0&&e.left>=0&&e.bottom<=(window.innerHeight||document.documentElement.clientHeight)&&e.right<=(window.innerWidth||document.documentElement.clientWidth)}class ys extends Error{}ys.prototype.name="InvalidTokenError";function q0(r){return decodeURIComponent(atob(r).replace(/(.)/g,(e,t)=>{let s=t.charCodeAt(0).toString(16).toUpperCase();return s.length<2&&(s="0"+s),"%"+s}))}function Q0(r){let e=r.replace(/-/g,"+").replace(/_/g,"/");switch(e.length%4){case 0:break;case 2:e+="==";break;case 3:e+="=";break;default:throw new Error("base64 string is not of the correct length")}try{return q0(e)}catch{return atob(e)}}function tf(r,e){if(typeof r!="string")throw new ys("Invalid token specified: must be a string");e||(e={});const t=e.header===!0?0:1,s=r.split(".")[t];if(typeof s!="string")throw new ys(`Invalid token specified: missing part #${t+1}`);let u;try{u=Q0(s)}catch(d){throw new ys(`Invalid token specified: invalid base64 for part #${t+1} (${d.message})`)}try{return JSON.parse(u)}catch(d){throw new ys(`Invalid token specified: invalid json for part #${t+1} (${d.message})`)}}const rf="0123456789ABCDEFGHJKMNPQRSTVWXYZ",Ri=32,ey=16,nf=10,wu=0xffffffffffff;var Nn;(function(r){r.Base32IncorrectEncoding="B32_ENC_INVALID",r.DecodeTimeInvalidCharacter="DEC_TIME_CHAR",r.DecodeTimeValueMalformed="DEC_TIME_MALFORMED",r.EncodeTimeNegative="ENC_TIME_NEG",r.EncodeTimeSizeExceeded="ENC_TIME_SIZE_EXCEED",r.EncodeTimeValueMalformed="ENC_TIME_MALFORMED",r.PRNGDetectFailure="PRNG_DETECT",r.ULIDInvalid="ULID_INVALID",r.Unexpected="UNEXPECTED",r.UUIDInvalid="UUID_INVALID"})(Nn||(Nn={}));class _s extends Error{constructor(e,t){super(`${t} (${e})`),this.name="ULIDError",this.code=e}}function ty(r){const e=Math.floor(r()*Ri)%Ri;return rf.charAt(e)}function ry(r){const e=ny(),t=e&&(e.crypto||e.msCrypto)||null;if(typeof(t==null?void 0:t.getRandomValues)=="function")return()=>{const s=new Uint8Array(1);return t.getRandomValues(s),s[0]/255};if(typeof(t==null?void 0:t.randomBytes)=="function")return()=>t.randomBytes(1).readUInt8()/255;throw new _s(Nn.PRNGDetectFailure,"Failed to find a reliable PRNG")}function ny(){return oy()?self:typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:null}function sy(r,e){let t="";for(;r>0;r--)t=ty(e)+t;return t}function iy(r,e=nf){if(isNaN(r))throw new _s(Nn.EncodeTimeValueMalformed,`Time must be a number: ${r}`);if(r>wu)throw new _s(Nn.EncodeTimeSizeExceeded,`Cannot encode a time larger than ${wu}: ${r}`);if(r<0)throw new _s(Nn.EncodeTimeNegative,`Time must be positive: ${r}`);if(Number.isInteger(r)===!1)throw new _s(Nn.EncodeTimeValueMalformed,`Time must be an integer: ${r}`);let t,s="";for(let u=e;u>0;u--)t=r%Ri,s=rf.charAt(t)+s,r=(r-t)/Ri;return s}function oy(){return typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope}function ay(r,e){const t=ry(),s=Date.now();return iy(s,nf)+sy(ey,t)}const ly=yn("ChphZ2VudC92MS9jcmVkZW50aWFscy5wcm90bxIIYWdlbnQudjEioQEKCk9BdXRoVG9rZW4SFAoMYWNjZXNzX3Rva2VuGAEgASgJEhIKCnRva2VuX3R5cGUYAiABKAkSFQoNcmVmcmVzaF90b2tlbhgDIAEoCRISCgpleHBpcmVzX2F0GAQgASgDEioKBmV4cGlyeRgFIAEoCzIaLmdvb2dsZS5wcm90b2J1Zi5UaW1lc3RhbXASEgoKZXhwaXJlc19pbhgGIAEoA0JAWj5naXRodWIuY29tL3J1bm1lZGV2L3J1bm1lL3YzL2FwaS9nZW4vcHJvdG8vZ28vYWdlbnQvdjE7YWdlbnR2MWIGcHJvdG8z",[Ms.file_google_protobuf_timestamp]),Su=dt(ly,0);/*! js-cookie v3.0.5 | MIT */function ci(r){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var s in t)r[s]=t[s]}return r}var cy={read:function(r){return r[0]==='"'&&(r=r.slice(1,-1)),r.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent)},write:function(r){return encodeURIComponent(r).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,decodeURIComponent)}};function Qo(r,e){function t(u,d,a){if(!(typeof document>"u")){a=ci({},e,a),typeof a.expires=="number"&&(a.expires=new Date(Date.now()+a.expires*864e5)),a.expires&&(a.expires=a.expires.toUTCString()),u=encodeURIComponent(u).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var o="";for(var c in a)a[c]&&(o+="; "+c,a[c]!==!0&&(o+="="+a[c].split(";")[0]));return document.cookie=u+"="+r.write(d,u)+o}}function s(u){if(!(typeof document>"u"||arguments.length&&!u)){for(var d=document.cookie?document.cookie.split("; "):[],a={},o=0;o<d.length;o++){var c=d[o].split("="),i=c.slice(1).join("=");try{var n=decodeURIComponent(c[0]);if(a[n]=r.read(i,n),u===n)break}catch{}}return u?a[u]:a}}return Object.create({set:t,get:s,remove:function(u,d){t(u,"",ci({},d,{expires:-1}))},withAttributes:function(u){return Qo(this.converter,ci({},this.attributes,u))},withConverter:function(u){return Qo(ci({},this.converter,u),this.attributes)}},{attributes:{value:Object.freeze(e)},converter:{value:Object.freeze(r)}})}var sf=Qo(cy,{path:"/"});const uy=["agent-session","cassie-session"],dy=["agent-oauth-token","cassie-oauth-token"];function ea(){for(const r of uy){const e=sf.get(r);if(e&&e.length>0)return e}}function hy(){let r=vt.create(Su);for(const e of dy){const t=sf.get(e);if(t&&t.length>0)try{const s=JSON.parse(t);return r=vt.fromJson(Su,s),r.accessToken}catch(s){console.error("Failed to parse OAuthToken:",s)}}return r.accessToken}const of=Ae.createContext(void 0),Zr=()=>{const r=Ae.useContext(of);if(!r)throw new Error("useSettings must be used within a SettingsProvider");return r},af=({children:r,agentEndpoint:e,requireAuth:t,webApp:s,createAuthInterceptors:u})=>{const[d,a]=Ae.useState(null),o=Ae.useMemo(()=>{const f=ea();if(!f)return"unauthenticated";let v;try{return v=tf(f),v.email||v.sub||"unauthenticated"}catch(g){return console.error("Error decoding token",g),"unauthenticated"}},[]),c=Ae.useMemo(()=>{const f=window.location.hostname==="localhost",v=window.location.protocol==="http:",g=window.location.port==="4173"||window.location.port==="5173",b=f&&v&&g;return{requireAuth:t??!1,agentEndpoint:e??b?"http://localhost:8080":window.location.origin,webApp:{runner:(s==null?void 0:s.runner)??b?"ws://localhost:8080/ws":`${v?"ws:":"wss:"}//${window.location.host}/ws`,reconnect:(s==null?void 0:s.reconnect)??!0,invertedOrder:(s==null?void 0:s.invertedOrder)??!1}}},[t,s]),[i,n]=Ae.useState(()=>{const f=localStorage.getItem("cloudAssistantSettings"),v=f?JSON.parse(f):{};return v&&v.webApp&&v.webApp.reconnect!==void 0&&(v.webApp.reconnect=c.webApp.reconnect),f?{...c,...v}:c});Ae.useEffect(()=>{localStorage.setItem("cloudAssistantSettings",JSON.stringify(i))},[i]);const l=Ae.useCallback(f=>{const v=g=>{const b=Lt.from(g);b.code===Ct.Unauthenticated&&(window.location.href=`/login?error=${encodeURIComponent(b.name)}&error_description=${encodeURIComponent(b.message)}`)};return[g=>async b=>{const y=ea();return y&&b.header.set("Authorization",`Bearer ${y}`),f?g(b).catch(_=>{throw v(_),_}):g(b)}]},[]),h=Ae.useMemo(()=>u??l,[u,l]),m=Ae.useCallback(async()=>{if(!i.webApp.runner)return;a(null);const f=new Qh({knownID:`check_${ay()}`,runID:ef(),sequence:0,options:{runnerEndpoint:i.webApp.runner,interceptors:h(!1),autoReconnect:!1}}),v=[];return v.push(f.errors.subscribe({next:g=>a(g)})),v.push(f.connect(qh.INITIAL).subscribe(g=>{g!==null&&(console.log(`Initial heartbeat latency for streamID ${g.streamID} (${g.readyState===1?"open":"closed"}): ${g.latency}ms`),f.close())})),()=>{v.forEach(g=>g.unsubscribe())}},[u,i.webApp.runner]);Ae.useEffect(()=>{m()},[m]);const p=f=>{n(v=>({...v,...f,webApp:{...v.webApp,...f.webApp}}))};return oe.jsx(of.Provider,{value:{principal:o,checkRunnerAuth:m,createAuthInterceptors:h,defaultSettings:c,runnerError:d,settings:i,updateSettings:p},children:r})},lf=Ae.createContext(void 0),cf=()=>{const r=Ae.useContext(lf);if(!r)throw new Error("useClient must be used within a ClientProvider");return r},uf=({children:r})=>{const[e,t]=Ae.useState(),{settings:s,createAuthInterceptors:u}=Zr();return Ae.useEffect(()=>{t(fy(s.agentEndpoint,u(!0)))},[s.agentEndpoint,u]),oe.jsx(lf.Provider,{value:{client:e,setClient:t},children:r})};function fy(r,e){console.log(`initializing the client: baseURL ${r}`);const t=Gd({baseUrl:r,interceptors:e});return Md(am,t)}const df=Ae.createContext(void 0),Fi=()=>{const r=Ae.useContext(df);if(!r)throw new Error("useOutput must be used within an OutputProvider");return r},hf=({children:r})=>{const e=Ae.useMemo(()=>new Map,[]),t=Ae.useCallback((o,c)=>{e.set(o,c)},[e]),s=Ae.useCallback(o=>{e.delete(o)},[e]),u=Ae.useCallback(o=>e.get(o),[e]),d=Ae.useCallback(()=>e,[e]),a=Ae.useMemo(()=>({registerRenderer:t,unregisterRenderer:s,getRenderer:u,getAllRenderers:d}),[t,s,u,d]);return oe.jsx(df.Provider,{value:a,children:r})},ff=Ae.createContext(void 0),Qr=()=>{const r=Ae.useContext(ff);if(!r)throw new Error("useCell must be used within a CellProvider");return r};function xu(r,e){if(!r)return[];const t=r.positions.map(s=>{const u=r.cells[s];return u.languageId="sh",u});return t.length===0?[]:e?t.reverse():t}const pf=({children:r,getAccessToken:e})=>{const{settings:t,createAuthInterceptors:s,principal:u}=Zr(),[d,a]=Ae.useState(0),[o,c]=Ae.useState(!1),[i,n]=Ae.useState(!1),[l,h]=Ae.useState(),{getAllRenderers:m}=Fi(),p=Ae.useMemo(()=>{const R=new URL(t.webApp.runner);return R.protocol==="ws:"?R.protocol="http:":R.protocol="https:",R.pathname="",R.toString()},[t.webApp.runner]),f=Ae.useMemo(()=>{if(u)return new qv("agent",u,Vo(Pd,p,s(!0)))},[t.agentEndpoint,u]),v=Ae.useMemo(()=>t.webApp.invertedOrder,[t.webApp.invertedOrder]),{client:g}=cf(),[b,y]=Ae.useState(void 0),_=Ae.useCallback(()=>{if(!b)return;const R=xu(b,v),$=vt.create(wi,{cells:R});l&&($.metadata[Si.PreviousResponseId]=l),f==null||f.saveNotebook(b.runmeSession,$)},[b,v,l,f]),w=Ae.useCallback(async({attemptRestore:R})=>{if(!f)return;a(0),h(void 0);const $=f.createSession();let B;if(!R)B=await $;else{const H=await f.listActiveSessions(),z=(await f.loadSessions(H)).filter(ee=>ee.data.cells.length!==0);if(z.length===0)B=await $;else{const ee=z[0];let Q=ee.data.cells.map(D=>D.refId);v&&(Q=Q.reverse());const Z=ee.data.metadata[Si.PreviousResponseId];Z&&h(Z),y({runmeSession:ee.id,cells:ee.data.cells.reduce((D,ue)=>(D[ue.refId]=ue,D),{}),positions:Q});return}}y({runmeSession:B,cells:{},positions:[]})},[v,f]);Ae.useEffect(()=>{_()},[b,f,v,_]),Ae.useEffect(()=>{y(R=>({runmeSession:(R==null?void 0:R.runmeSession)??"",cells:(R==null?void 0:R.cells)??{},positions:[...(R==null?void 0:R.positions)??[]].reverse()}))},[v]),Ae.useEffect(()=>{w&&w({attemptRestore:!0})},[w]);const x=Ae.useMemo(()=>b?b.positions.map(R=>b.cells[R]).filter(R=>!!R&&(R.kind===fr.MARKUP||R.kind===fr.CODE)):[],[b]),S=Ae.useMemo(()=>b?b.positions.map(R=>b.cells[R]).filter(R=>!!R&&R.kind===fr.CODE):[],[b]),j=Ae.useMemo(()=>b?b.positions.map(R=>b.cells[R]).filter(R=>!!R&&R.kind===fr.DOC_RESULTS):[],[b]),k=()=>({chat:x,actions:S,files:j}),O=R=>vt.clone(Pn,R),T=async R=>{const $=await e(),B=vt.create(om,{cells:R,previousResponseId:l});B.openaiAccessToken=$,$||console.error("No access token found");try{const H=g.generate(B);for await(const V of H){for(const z of V.cells)n(!1),G(z);h(V.responseId)}}catch(H){console.log(H)}finally{n(!1),c(!1)}},L=async R=>{if(!R.trim())return;const $=vt.create(Pn,{refId:`user_${Jl()}`,role:Wr.USER,kind:fr.MARKUP,value:R});G($),c(!0),n(!0),await T([$])},F=async R=>{R.outputs.length!==0&&(console.log("sending output cell",R.refId,"previousResponseId",l),c(!0),n(!0),await T([R]))},G=R=>{const $=m();for(const B of $.values())B.onCellUpdate(R);y(B=>{if(B){if(!B.cells[R.refId]){const H=v?[R.refId,...B.positions]:[...B.positions,R.refId];return{runmeSession:B.runmeSession,cells:{...B.cells,[R.refId]:R},positions:H}}return{...B,runmeSession:B.runmeSession,cells:{...B.cells,[R.refId]:R}}}})},X=()=>{const R=`code_${Jl().replace(/-/g,"")}`,$=vt.create(Pn,{metadata:{[hr.ID]:R,[hr.RunmeID]:R},refId:R,languageId:"sh",role:Wr.USER,kind:fr.CODE,value:""});G($)},ie=R=>{if(!S.find(H=>H.refId===R.refId))return;const B=new CustomEvent("runCodeCell",{detail:{cellId:R.refId}});R.executionSummary=void 0,R.outputs=R.outputs.filter(H=>H.items.some(V=>V.mime===Jr.StatefulRunmeTerminal)),a(H=>{const V=H+1;return R.metadata[hr.Sequence]=V.toString(),V}),window.dispatchEvent(B)},te=async({asSessionRecord:R})=>{var ue;const $=xu(b,v);if(!b||$.length===0)return;const B=vt.create(wi,{cells:$}),H=Vo(Ra,t.agentEndpoint),V=vt.create(Ia,{notebook:B,options:vt.create(ka,{outputs:vt.create(Ea,{enabled:!1,summary:!1})})});R&&((ue=V.options)!=null&&ue.outputs)&&(V.options.outputs.enabled=!0,V.options.outputs.summary=!0,V.options.session=vt.create(ja,{id:b.runmeSession}));const z=await H.serialize(V),ee=new Blob([z.result],{type:"text/plain"}),Q=URL.createObjectURL(ee),Z=document.createElement("a");Z.href=Q;const D=R?"Session":"Notebook";Z.download=`${D}-${Jd()}.md`,document.body.appendChild(Z),Z.click(),document.body.removeChild(Z),URL.revokeObjectURL(Q)};return oe.jsx(ff.Provider,{value:{useColumns:k,sequence:d,saveState:_,exportDocument:te,sendOutputCell:F,createOutputCell:O,sendUserCell:L,addCodeCell:X,isInputDisabled:o,isTyping:i,runCodeCell:ie,resetSession:w},children:r})},Cu=new TextEncoder;function py({pid:r,exitCode:e},t,s,u){let d;return r!==null&&e!==null&&(d=vt.create(xa,{pid:BigInt(r),exitReason:vt.create(Sa,{type:"exit",code:e})})),[vt.create(Ni,{items:[vt.create(Ts,{mime:Jr.VSCodeNotebookStdOut,type:"Buffer",data:Cu.encode(t)}),vt.create(Ts,{mime:Jr.VSCodeNotebookStdErr,type:"Buffer",data:Cu.encode(s)})],processInfo:d})]}const my=vt.create(Pn,{kind:fr.MARKUP,role:Wr.ASSISTANT,value:"..."}),ta={fontSize:14,fontFamily:"monospace"},vy=new TextDecoder,gy=Ae.memo(Y0,(r,e)=>r.cellID===e.cellID&&r.runID===e.runID),mf=({cell:r,onExitCode:e,onPid:t})=>{const{createAuthInterceptors:s,settings:{webApp:u}}=Zr(),{sendOutputCell:d,saveState:a}=Qr(),o=u.invertedOrder,[c,i]=Ae.useState(!1),[n,l]=Ae.useState({value:"",runID:""}),[h,m]=Ae.useState(null),[p,f]=Ae.useState(null),[v,g]=Ae.useState(null),[b,y]=Ae.useState(null),[_,w]=Ae.useState(""),[x,S]=Ae.useState(""),[j,k]=Ae.useState(""),O=Ae.useMemo(()=>Number(r.metadata[hr.Sequence]??0),[r,p,v]),T=Ae.useCallback((Q=!1)=>{m(BigInt(Date.now())),w(""),S(""),f(null),g(null),i(Q),l({value:r.value,runID:ef()})},[r]),L=Ae.useMemo(()=>({...ta,className:"rounded-md overflow-hidden",rows:14,scrollToFit:!o,takeFocus:c}),[o,c]);Ae.useEffect(()=>{const Q=Z=>{Z.detail.cellId===r.refId&&T()};return window.addEventListener("runCodeCell",Q),()=>{window.removeEventListener("runCodeCell",Q)}},[r.refId,T]);const F=Ae.useMemo(()=>{const Q=r.outputs.filter(D=>D.items.some(ue=>ue.mime===Jr.StatefulRunmeTerminal)),Z=py({pid:p,exitCode:v},_,x);return[...Q,...Z]},[p,v,_,x,b,r.outputs]);Ae.useEffect(()=>{h!==null&&(r.outputs=F,r.executionSummary=vt.create(Ca,{timing:vt.create(wa,{startTime:h,endTime:BigInt(Date.now())}),executionOrder:O,success:Number.isFinite(v)&&v===0}))},[r,F,v,O,h]);const G=Ae.useMemo(()=>p===null||v===null||n.runID===""||!Number.isFinite(p)||!Number.isInteger(v)?null:r,[r,n.runID,v,p]);Ae.useEffect(()=>{!G||j===n.runID||(k(n.runID),d(G))},[d,G,n.runID,j]),Ae.useEffect(()=>{p!==null&&t(p)},[p,t]),Ae.useEffect(()=>{v!==null&&e(v)},[v,e]),Ae.useEffect(()=>{r.kind===fr.CODE&&(n.runID!==""&&(r.metadata[hr.LastRunID]=n.runID),p?r.metadata[hr.Pid]=p.toString():delete r.metadata[hr.Pid],v!==null&&Number.isFinite(v)?(delete r.metadata[hr.Pid],r.metadata[hr.ExitCode]=v.toString()):delete r.metadata[hr.ExitCode],a())},[p,v,r,a,n.runID]);const X=Ae.useMemo(()=>{if(r.kind!==fr.CODE||j!=="")return;const Q=r.outputs.flatMap(Z=>Z.items).find(Z=>Z.mime===Jr.VSCodeNotebookStdOut);if(Q)return vy.decode(Q.data)},[r.kind,r.outputs,j]),ie=Ae.useMemo(()=>{var Z;return((Z=r.metadata)==null?void 0:Z[hr.Pid])??""?r.metadata[hr.LastRunID]??"":""},[r.metadata]),te=Ae.useMemo(()=>n.value===""||n.runID===""?[]:n.value.split(`
|
|
6548
|
+
`):"",this.name="UnsubscriptionError",this.errors=e}});function Oi(r,e){if(r){var t=r.indexOf(e);0<=t&&r.splice(t,1)}}var Vs=function(){function r(e){this.initialTeardown=e,this.closed=!1,this._parentage=null,this._finalizers=null}return r.prototype.unsubscribe=function(){var e,t,s,u,d;if(!this.closed){this.closed=!0;var a=this._parentage;if(a)if(this._parentage=null,Array.isArray(a))try{for(var o=ns(a),c=o.next();!c.done;c=o.next()){var i=c.value;i.remove(this)}}catch(f){e={error:f}}finally{try{c&&!c.done&&(t=o.return)&&t.call(o)}finally{if(e)throw e.error}}else a.remove(this);var n=this.initialTeardown;if(Nt(n))try{n()}catch(f){d=f instanceof ko?f.errors:[f]}var l=this._finalizers;if(l){this._finalizers=null;try{for(var h=ns(l),m=h.next();!m.done;m=h.next()){var p=m.value;try{au(p)}catch(f){d=d??[],f instanceof ko?d=bn(bn([],dn(d)),dn(f.errors)):d.push(f)}}}catch(f){s={error:f}}finally{try{m&&!m.done&&(u=h.return)&&u.call(h)}finally{if(s)throw s.error}}}if(d)throw new ko(d)}},r.prototype.add=function(e){var t;if(e&&e!==this)if(this.closed)au(e);else{if(e instanceof r){if(e.closed||e._hasParent(this))return;e._addParent(this)}(this._finalizers=(t=this._finalizers)!==null&&t!==void 0?t:[]).push(e)}},r.prototype._hasParent=function(e){var t=this._parentage;return t===e||Array.isArray(t)&&t.includes(e)},r.prototype._addParent=function(e){var t=this._parentage;this._parentage=Array.isArray(t)?(t.push(e),t):t?[t,e]:e},r.prototype._removeParent=function(e){var t=this._parentage;t===e?this._parentage=null:Array.isArray(t)&&Oi(t,e)},r.prototype.remove=function(e){var t=this._finalizers;t&&Oi(t,e),e instanceof r&&e._removeParent(this)},r.EMPTY=function(){var e=new r;return e.closed=!0,e}(),r}(),Oh=Vs.EMPTY;function Ah(r){return r instanceof Vs||r&&"closed"in r&&Nt(r.remove)&&Nt(r.add)&&Nt(r.unsubscribe)}function au(r){Nt(r)?r():r.unsubscribe()}var Ib={Promise:void 0},Tb={setTimeout:function(r,e){for(var t=[],s=2;s<arguments.length;s++)t[s-2]=arguments[s];return setTimeout.apply(void 0,bn([r,e],dn(t)))},clearTimeout:function(r){return clearTimeout(r)},delegate:void 0};function Rh(r){Tb.setTimeout(function(){throw r})}function Ps(){}function gi(r){r()}var Ya=function(r){wn(e,r);function e(t){var s=r.call(this)||this;return s.isStopped=!1,t?(s.destination=t,Ah(t)&&t.add(s)):s.destination=Rb,s}return e.create=function(t,s,u){return new Ds(t,s,u)},e.prototype.next=function(t){this.isStopped||this._next(t)},e.prototype.error=function(t){this.isStopped||(this.isStopped=!0,this._error(t))},e.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},e.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,r.prototype.unsubscribe.call(this),this.destination=null)},e.prototype._next=function(t){this.destination.next(t)},e.prototype._error=function(t){try{this.destination.error(t)}finally{this.unsubscribe()}},e.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},e}(Vs),Ob=function(){function r(e){this.partialObserver=e}return r.prototype.next=function(e){var t=this.partialObserver;if(t.next)try{t.next(e)}catch(s){oi(s)}},r.prototype.error=function(e){var t=this.partialObserver;if(t.error)try{t.error(e)}catch(s){oi(s)}else oi(e)},r.prototype.complete=function(){var e=this.partialObserver;if(e.complete)try{e.complete()}catch(t){oi(t)}},r}(),Ds=function(r){wn(e,r);function e(t,s,u){var d=r.call(this)||this,a;return Nt(t)||!t?a={next:t??void 0,error:s??void 0,complete:u??void 0}:a=t,d.destination=new Ob(a),d}return e}(Ya);function oi(r){Rh(r)}function Ab(r){throw r}var Rb={closed:!0,next:Ps,error:Ab,complete:Ps},Ja=function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"}();function Bi(r){return r}function Lb(r){return r.length===0?Bi:r.length===1?r[0]:function(e){return r.reduce(function(t,s){return s(t)},e)}}var Kt=function(){function r(e){e&&(this._subscribe=e)}return r.prototype.lift=function(e){var t=new r;return t.source=this,t.operator=e,t},r.prototype.subscribe=function(e,t,s){var u=this,d=Pb(e)?e:new Ds(e,t,s);return gi(function(){var a=u,o=a.operator,c=a.source;d.add(o?o.call(d,c):c?u._subscribe(d):u._trySubscribe(d))}),d},r.prototype._trySubscribe=function(e){try{return this._subscribe(e)}catch(t){e.error(t)}},r.prototype.forEach=function(e,t){var s=this;return t=lu(t),new t(function(u,d){var a=new Ds({next:function(o){try{e(o)}catch(c){d(c),a.unsubscribe()}},error:d,complete:u});s.subscribe(a)})},r.prototype._subscribe=function(e){var t;return(t=this.source)===null||t===void 0?void 0:t.subscribe(e)},r.prototype[Ja]=function(){return this},r.prototype.pipe=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return Lb(e)(this)},r.prototype.toPromise=function(e){var t=this;return e=lu(e),new e(function(s,u){var d;t.subscribe(function(a){return d=a},function(a){return u(a)},function(){return s(d)})})},r.create=function(e){return new r(e)},r}();function lu(r){var e;return(e=r??Ib.Promise)!==null&&e!==void 0?e:Promise}function Nb(r){return r&&Nt(r.next)&&Nt(r.error)&&Nt(r.complete)}function Pb(r){return r&&r instanceof Ya||Nb(r)&&Ah(r)}function Db(r){return Nt(r==null?void 0:r.lift)}function tr(r){return function(e){if(Db(e))return e.lift(function(t){try{return r(t,this)}catch(s){this.error(s)}});throw new TypeError("Unable to lift unknown Observable type")}}function Ht(r,e,t,s,u){return new Mb(r,e,t,s,u)}var Mb=function(r){wn(e,r);function e(t,s,u,d,a,o){var c=r.call(this,t)||this;return c.onFinalize=a,c.shouldUnsubscribe=o,c._next=s?function(i){try{s(i)}catch(n){t.error(n)}}:r.prototype._next,c._error=d?function(i){try{d(i)}catch(n){t.error(n)}finally{this.unsubscribe()}}:r.prototype._error,c._complete=u?function(){try{u()}catch(i){t.error(i)}finally{this.unsubscribe()}}:r.prototype._complete,c}return e.prototype.unsubscribe=function(){var t;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var s=this.closed;r.prototype.unsubscribe.call(this),!s&&((t=this.onFinalize)===null||t===void 0||t.call(this))}},e}(Ya),Bb=Th(function(r){return function(){r(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}}),Rr=function(r){wn(e,r);function e(){var t=r.call(this)||this;return t.closed=!1,t.currentObservers=null,t.observers=[],t.isStopped=!1,t.hasError=!1,t.thrownError=null,t}return e.prototype.lift=function(t){var s=new cu(this,this);return s.operator=t,s},e.prototype._throwIfClosed=function(){if(this.closed)throw new Bb},e.prototype.next=function(t){var s=this;gi(function(){var u,d;if(s._throwIfClosed(),!s.isStopped){s.currentObservers||(s.currentObservers=Array.from(s.observers));try{for(var a=ns(s.currentObservers),o=a.next();!o.done;o=a.next()){var c=o.value;c.next(t)}}catch(i){u={error:i}}finally{try{o&&!o.done&&(d=a.return)&&d.call(a)}finally{if(u)throw u.error}}}})},e.prototype.error=function(t){var s=this;gi(function(){if(s._throwIfClosed(),!s.isStopped){s.hasError=s.isStopped=!0,s.thrownError=t;for(var u=s.observers;u.length;)u.shift().error(t)}})},e.prototype.complete=function(){var t=this;gi(function(){if(t._throwIfClosed(),!t.isStopped){t.isStopped=!0;for(var s=t.observers;s.length;)s.shift().complete()}})},e.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(e.prototype,"observed",{get:function(){var t;return((t=this.observers)===null||t===void 0?void 0:t.length)>0},enumerable:!1,configurable:!0}),e.prototype._trySubscribe=function(t){return this._throwIfClosed(),r.prototype._trySubscribe.call(this,t)},e.prototype._subscribe=function(t){return this._throwIfClosed(),this._checkFinalizedStatuses(t),this._innerSubscribe(t)},e.prototype._innerSubscribe=function(t){var s=this,u=this,d=u.hasError,a=u.isStopped,o=u.observers;return d||a?Oh:(this.currentObservers=null,o.push(t),new Vs(function(){s.currentObservers=null,Oi(o,t)}))},e.prototype._checkFinalizedStatuses=function(t){var s=this,u=s.hasError,d=s.thrownError,a=s.isStopped;u?t.error(d):a&&t.complete()},e.prototype.asObservable=function(){var t=new Kt;return t.source=this,t},e.create=function(t,s){return new cu(t,s)},e}(Kt),cu=function(r){wn(e,r);function e(t,s){var u=r.call(this)||this;return u.destination=t,u.source=s,u}return e.prototype.next=function(t){var s,u;(u=(s=this.destination)===null||s===void 0?void 0:s.next)===null||u===void 0||u.call(s,t)},e.prototype.error=function(t){var s,u;(u=(s=this.destination)===null||s===void 0?void 0:s.error)===null||u===void 0||u.call(s,t)},e.prototype.complete=function(){var t,s;(s=(t=this.destination)===null||t===void 0?void 0:t.complete)===null||s===void 0||s.call(t)},e.prototype._subscribe=function(t){var s,u;return(u=(s=this.source)===null||s===void 0?void 0:s.subscribe(t))!==null&&u!==void 0?u:Oh},e}(Rr),$b={now:function(){return Date.now()}},Fb=function(r){wn(e,r);function e(t,s){return r.call(this)||this}return e.prototype.schedule=function(t,s){return this},e}(Vs),uu={setInterval:function(r,e){for(var t=[],s=2;s<arguments.length;s++)t[s-2]=arguments[s];return setInterval.apply(void 0,bn([r,e],dn(t)))},clearInterval:function(r){return clearInterval(r)},delegate:void 0},Vb=function(r){wn(e,r);function e(t,s){var u=r.call(this,t,s)||this;return u.scheduler=t,u.work=s,u.pending=!1,u}return e.prototype.schedule=function(t,s){var u;if(s===void 0&&(s=0),this.closed)return this;this.state=t;var d=this.id,a=this.scheduler;return d!=null&&(this.id=this.recycleAsyncId(a,d,s)),this.pending=!0,this.delay=s,this.id=(u=this.id)!==null&&u!==void 0?u:this.requestAsyncId(a,this.id,s),this},e.prototype.requestAsyncId=function(t,s,u){return u===void 0&&(u=0),uu.setInterval(t.flush.bind(t,this),u)},e.prototype.recycleAsyncId=function(t,s,u){if(u===void 0&&(u=0),u!=null&&this.delay===u&&this.pending===!1)return s;s!=null&&uu.clearInterval(s)},e.prototype.execute=function(t,s){if(this.closed)return new Error("executing a cancelled action");this.pending=!1;var u=this._execute(t,s);if(u)return u;this.pending===!1&&this.id!=null&&(this.id=this.recycleAsyncId(this.scheduler,this.id,null))},e.prototype._execute=function(t,s){var u=!1,d;try{this.work(t)}catch(a){u=!0,d=a||new Error("Scheduled action threw falsy error")}if(u)return this.unsubscribe(),d},e.prototype.unsubscribe=function(){if(!this.closed){var t=this,s=t.id,u=t.scheduler,d=u.actions;this.work=this.state=this.scheduler=null,this.pending=!1,Oi(d,this),s!=null&&(this.id=this.recycleAsyncId(u,s,null)),this.delay=null,r.prototype.unsubscribe.call(this)}},e}(Fb),du=function(){function r(e,t){t===void 0&&(t=r.now),this.schedulerActionCtor=e,this.now=t}return r.prototype.schedule=function(e,t,s){return t===void 0&&(t=0),new this.schedulerActionCtor(this,e).schedule(s,t)},r.now=$b.now,r}(),Ub=function(r){wn(e,r);function e(t,s){s===void 0&&(s=du.now);var u=r.call(this,t,s)||this;return u.actions=[],u._active=!1,u}return e.prototype.flush=function(t){var s=this.actions;if(this._active){s.push(t);return}var u;this._active=!0;do if(u=t.execute(t.state,t.delay))break;while(t=s.shift());if(this._active=!1,u){for(;t=s.shift();)t.unsubscribe();throw u}},e}(du),$i=new Ub(Vb),Wb=$i,Lh=new Kt(function(r){return r.complete()});function Nh(r){return r&&Nt(r.schedule)}function qa(r){return r[r.length-1]}function Zb(r){return Nt(qa(r))?r.pop():void 0}function Ph(r){return Nh(qa(r))?r.pop():void 0}function Gb(r,e){return typeof qa(r)=="number"?r.pop():e}var Qa=function(r){return r&&typeof r.length=="number"&&typeof r!="function"};function Dh(r){return Nt(r==null?void 0:r.then)}function Mh(r){return Nt(r[Ja])}function Bh(r){return Symbol.asyncIterator&&Nt(r==null?void 0:r[Symbol.asyncIterator])}function $h(r){return new TypeError("You provided "+(r!==null&&typeof r=="object"?"an invalid object":"'"+r+"'")+" where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.")}function Hb(){return typeof Symbol!="function"||!Symbol.iterator?"@@iterator":Symbol.iterator}var Fh=Hb();function Vh(r){return Nt(r==null?void 0:r[Fh])}function Uh(r){return Eb(this,arguments,function(){var e,t,s,u;return Ih(this,function(d){switch(d.label){case 0:e=r.getReader(),d.label=1;case 1:d.trys.push([1,,9,10]),d.label=2;case 2:return[4,Hn(e.read())];case 3:return t=d.sent(),s=t.value,u=t.done,u?[4,Hn(void 0)]:[3,5];case 4:return[2,d.sent()];case 5:return[4,Hn(s)];case 6:return[4,d.sent()];case 7:return d.sent(),[3,2];case 8:return[3,10];case 9:return e.releaseLock(),[7];case 10:return[2]}})})}function Wh(r){return Nt(r==null?void 0:r.getReader)}function Xt(r){if(r instanceof Kt)return r;if(r!=null){if(Mh(r))return zb(r);if(Qa(r))return Kb(r);if(Dh(r))return Xb(r);if(Bh(r))return Zh(r);if(Vh(r))return Yb(r);if(Wh(r))return Jb(r)}throw $h(r)}function zb(r){return new Kt(function(e){var t=r[Ja]();if(Nt(t.subscribe))return t.subscribe(e);throw new TypeError("Provided object does not correctly implement Symbol.observable")})}function Kb(r){return new Kt(function(e){for(var t=0;t<r.length&&!e.closed;t++)e.next(r[t]);e.complete()})}function Xb(r){return new Kt(function(e){r.then(function(t){e.closed||(e.next(t),e.complete())},function(t){return e.error(t)}).then(null,Rh)})}function Yb(r){return new Kt(function(e){var t,s;try{for(var u=ns(r),d=u.next();!d.done;d=u.next()){var a=d.value;if(e.next(a),e.closed)return}}catch(o){t={error:o}}finally{try{d&&!d.done&&(s=u.return)&&s.call(u)}finally{if(t)throw t.error}}e.complete()})}function Zh(r){return new Kt(function(e){qb(r,e).catch(function(t){return e.error(t)})})}function Jb(r){return Zh(Uh(r))}function qb(r,e){var t,s,u,d;return jb(this,void 0,void 0,function(){var a,o;return Ih(this,function(c){switch(c.label){case 0:c.trys.push([0,5,6,11]),t=kb(r),c.label=1;case 1:return[4,t.next()];case 2:if(s=c.sent(),!!s.done)return[3,4];if(a=s.value,e.next(a),e.closed)return[2];c.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return o=c.sent(),u={error:o},[3,11];case 6:return c.trys.push([6,,9,10]),s&&!s.done&&(d=t.return)?[4,d.call(t)]:[3,8];case 7:c.sent(),c.label=8;case 8:return[3,10];case 9:if(u)throw u.error;return[7];case 10:return[7];case 11:return e.complete(),[2]}})})}function Dn(r,e,t,s,u){s===void 0&&(s=0),u===void 0&&(u=!1);var d=e.schedule(function(){t(),u?r.add(this.schedule(null,s)):this.unsubscribe()},s);if(r.add(d),!u)return d}function Gh(r,e){return e===void 0&&(e=0),tr(function(t,s){t.subscribe(Ht(s,function(u){return Dn(s,r,function(){return s.next(u)},e)},function(){return Dn(s,r,function(){return s.complete()},e)},function(u){return Dn(s,r,function(){return s.error(u)},e)}))})}function Hh(r,e){return e===void 0&&(e=0),tr(function(t,s){s.add(r.schedule(function(){return t.subscribe(s)},e))})}function Qb(r,e){return Xt(r).pipe(Hh(e),Gh(e))}function e0(r,e){return Xt(r).pipe(Hh(e),Gh(e))}function t0(r,e){return new Kt(function(t){var s=0;return e.schedule(function(){s===r.length?t.complete():(t.next(r[s++]),t.closed||this.schedule())})})}function r0(r,e){return new Kt(function(t){var s;return Dn(t,e,function(){s=r[Fh](),Dn(t,e,function(){var u,d,a;try{u=s.next(),d=u.value,a=u.done}catch(o){t.error(o);return}a?t.complete():t.next(d)},0,!0)}),function(){return Nt(s==null?void 0:s.return)&&s.return()}})}function zh(r,e){if(!r)throw new Error("Iterable cannot be null");return new Kt(function(t){Dn(t,e,function(){var s=r[Symbol.asyncIterator]();Dn(t,e,function(){s.next().then(function(u){u.done?t.complete():t.next(u.value)})},0,!0)})})}function n0(r,e){return zh(Uh(r),e)}function s0(r,e){if(r!=null){if(Mh(r))return Qb(r,e);if(Qa(r))return t0(r,e);if(Dh(r))return e0(r,e);if(Bh(r))return zh(r,e);if(Vh(r))return r0(r,e);if(Wh(r))return n0(r,e)}throw $h(r)}function Kh(r,e){return e?s0(r,e):Xt(r)}function i0(){for(var r=[],e=0;e<arguments.length;e++)r[e]=arguments[e];var t=Ph(r);return Kh(r,t)}function o0(r){return r instanceof Date&&!isNaN(r)}function Ar(r,e){return tr(function(t,s){var u=0;t.subscribe(Ht(s,function(d){s.next(r.call(e,d,u++))}))})}var a0=Array.isArray;function l0(r,e){return a0(e)?r.apply(void 0,bn([],dn(e))):r(e)}function c0(r){return Ar(function(e){return l0(r,e)})}function u0(r,e,t,s,u,d,a,o){var c=[],i=0,n=0,l=!1,h=function(){l&&!c.length&&!i&&e.complete()},m=function(f){return i<s?p(f):c.push(f)},p=function(f){i++;var v=!1;Xt(t(f,n++)).subscribe(Ht(e,function(g){e.next(g)},function(){v=!0},void 0,function(){if(v)try{i--;for(var g=function(){var b=c.shift();a||p(b)};c.length&&i<s;)g();h()}catch(b){e.error(b)}}))};return r.subscribe(Ht(e,m,function(){l=!0,h()})),function(){}}function Rn(r,e,t){return t===void 0&&(t=1/0),Nt(e)?Rn(function(s,u){return Ar(function(d,a){return e(s,d,u,a)})(Xt(r(s,u)))},t):(typeof e=="number"&&(t=e),tr(function(s,u){return u0(s,u,r,t)}))}function d0(r){return r===void 0&&(r=1/0),Rn(Bi,r)}function h0(r){return new Kt(function(e){Xt(r()).subscribe(e)})}var f0={connector:function(){return new Rr},resetOnDisconnect:!0};function On(r,e){e===void 0&&(e=f0);var t=null,s=e.connector,u=e.resetOnDisconnect,d=u===void 0?!0:u,a=s(),o=new Kt(function(c){return a.subscribe(c)});return o.connect=function(){return(!t||t.closed)&&(t=h0(function(){return r}).subscribe(a),d&&t.add(function(){return a=s()})),t},o}var p0=["addListener","removeListener"],m0=["addEventListener","removeEventListener"],v0=["on","off"];function qo(r,e,t,s){if(Nt(t)&&(s=t,t=void 0),s)return qo(r,e,t).pipe(c0(s));var u=dn(y0(r)?m0.map(function(o){return function(c){return r[o](e,c,t)}}):g0(r)?p0.map(hu(r,e)):b0(r)?v0.map(hu(r,e)):[],2),d=u[0],a=u[1];if(!d&&Qa(r))return Rn(function(o){return qo(o,e,t)})(Xt(r));if(!d)throw new TypeError("Invalid event target");return new Kt(function(o){var c=function(){for(var i=[],n=0;n<arguments.length;n++)i[n]=arguments[n];return o.next(1<i.length?i:i[0])};return d(c),function(){return a(c)}})}function hu(r,e){return function(t){return function(s){return r[t](e,s)}}}function g0(r){return Nt(r.addListener)&&Nt(r.removeListener)}function b0(r){return Nt(r.on)&&Nt(r.off)}function y0(r){return Nt(r.addEventListener)&&Nt(r.removeEventListener)}function Cs(r,e,t){r===void 0&&(r=0),t===void 0&&(t=Wb);var s=-1;return e!=null&&(Nh(e)?t=e:s=e),new Kt(function(u){var d=o0(r)?+r-t.now():r;d<0&&(d=0);var a=0;return t.schedule(function(){u.closed||(u.next(a++),0<=s?this.schedule(void 0,s):u.complete())},d)})}function _0(r,e){return e===void 0&&(e=$i),Cs(r,r,e)}function w0(){for(var r=[],e=0;e<arguments.length;e++)r[e]=arguments[e];var t=Ph(r),s=Gb(r,1/0),u=r;return u.length?u.length===1?Xt(u[0]):d0(s)(Kh(u,t)):Lh}var S0=Array.isArray;function x0(r){return r.length===1&&S0(r[0])?r[0]:r}function gn(r,e){return tr(function(t,s){var u=0;t.subscribe(Ht(s,function(d){return r.call(e,d,u++)&&s.next(d)}))})}function C0(){for(var r=[],e=0;e<arguments.length;e++)r[e]=arguments[e];return r=x0(r),r.length===1?Xt(r[0]):new Kt(j0(r))}function j0(r){return function(e){for(var t=[],s=function(d){t.push(Xt(r[d]).subscribe(Ht(e,function(a){if(t){for(var o=0;o<t.length;o++)o!==d&&t[o].unsubscribe();t=null}e.next(a)})))},u=0;t&&!e.closed&&u<r.length;u++)s(u)}}function E0(r){return tr(function(e,t){var s=null,u=null,d=function(){u==null||u.unsubscribe();var a=s;s=[],a&&t.next(a),Xt(r()).subscribe(u=Ht(t,d,Ps))};d(),e.subscribe(Ht(t,function(a){return s==null?void 0:s.push(a)},function(){s&&t.next(s),t.complete()},void 0,function(){return s=u=null}))})}function Xh(r){return tr(function(e,t){var s=null,u=!1,d;s=e.subscribe(Ht(t,void 0,void 0,function(a){d=Xt(r(a,Xh(r)(e))),s?(s.unsubscribe(),s=null,d.subscribe(t)):u=!0})),u&&(s.unsubscribe(),s=null,d.subscribe(t))})}function k0(r,e,t,s,u){return function(d,a){var o=t,c=e,i=0;d.subscribe(Ht(a,function(n){var l=i++;c=o?r(c,n,l):(o=!0,n),a.next(c)},u))}}function fu(r){return r<=0?function(){return Lh}:tr(function(e,t){var s=0;e.subscribe(Ht(t,function(u){++s<=r&&(t.next(u),r<=s&&t.complete())}))})}function I0(r){return tr(function(e,t){try{e.subscribe(t)}finally{t.add(r)}})}function T0(r,e){return tr(k0(r,e,arguments.length>=2,!0))}function O0(r){r===void 0&&(r={});var e=r.connector,t=e===void 0?function(){return new Rr}:e,s=r.resetOnError,u=s===void 0?!0:s,d=r.resetOnComplete,a=d===void 0?!0:d,o=r.resetOnRefCountZero,c=o===void 0?!0:o;return function(i){var n,l,h,m=0,p=!1,f=!1,v=function(){l==null||l.unsubscribe(),l=void 0},g=function(){v(),n=h=void 0,p=f=!1},b=function(){var y=n;g(),y==null||y.unsubscribe()};return tr(function(y,_){m++,!f&&!p&&v();var w=h=h??t();_.add(function(){m--,m===0&&!f&&!p&&(l=Io(b,c))}),w.subscribe(_),!n&&m>0&&(n=new Ds({next:function(x){return w.next(x)},error:function(x){f=!0,v(),l=Io(g,u,x),w.error(x)},complete:function(){p=!0,v(),l=Io(g,a),w.complete()}}),Xt(y).subscribe(n))})(i)}}function Io(r,e){for(var t=[],s=2;s<arguments.length;s++)t[s-2]=arguments[s];if(e===!0){r();return}if(e!==!1){var u=new Ds({next:function(){u.unsubscribe(),r()}});return Xt(e.apply(void 0,bn([],dn(t)))).subscribe(u)}}function A0(r){return tr(function(e,t){var s=!1,u=Ht(t,function(){u==null||u.unsubscribe(),s=!0},Ps);Xt(r).subscribe(u),e.subscribe(Ht(t,function(d){return s&&t.next(d)}))})}function pu(r,e){return tr(function(t,s){var u=null,d=0,a=!1,o=function(){return a&&!u&&s.complete()};t.subscribe(Ht(s,function(c){u==null||u.unsubscribe();var i=0,n=d++;Xt(r(c,n)).subscribe(u=Ht(s,function(l){return s.next(e?e(c,l,n,i++):l)},function(){u=null,o()}))},function(){a=!0,o()}))})}function ai(r,e){return e===void 0&&(e=!1),tr(function(t,s){var u=0;t.subscribe(Ht(s,function(d){var a=r(d,u++);(a||e)&&s.next(d),!a&&s.complete()}))})}function R0(r,e,t){var s=Nt(r)||e||t?{next:r,error:e,complete:t}:r;return s?tr(function(u,d){var a;(a=s.subscribe)===null||a===void 0||a.call(s);var o=!0;u.subscribe(Ht(d,function(c){var i;(i=s.next)===null||i===void 0||i.call(s,c),d.next(c)},function(){var c;o=!1,(c=s.complete)===null||c===void 0||c.call(s),d.complete()},function(c){var i;o=!1,(i=s.error)===null||i===void 0||i.call(s,c),d.error(c)},function(){var c,i;o&&((c=s.unsubscribe)===null||c===void 0||c.call(s)),(i=s.finalize)===null||i===void 0||i.call(s)}))}):Bi}function L0(r,e){return tr(function(t,s){var u=e??{},d=u.leading,a=d===void 0?!0:d,o=u.trailing,c=o===void 0?!1:o,i=!1,n=null,l=null,h=!1,m=function(){l==null||l.unsubscribe(),l=null,c&&(v(),h&&s.complete())},p=function(){l=null,h&&s.complete()},f=function(g){return l=Xt(r(g)).subscribe(Ht(s,m,p))},v=function(){if(i){i=!1;var g=n;n=null,s.next(g),!h&&f(g)}};t.subscribe(Ht(s,function(g){i=!0,n=g,!(l&&!l.closed)&&(a?v():f(g))},function(){h=!0,!(c&&i&&l&&!l.closed)&&s.complete()}))})}function mu(r,e,t){e===void 0&&(e=$i);var s=Cs(r,e);return L0(function(){return s},t)}function To(){for(var r=[],e=0;e<arguments.length;e++)r[e]=arguments[e];var t=Zb(r);return tr(function(s,u){for(var d=r.length,a=new Array(d),o=r.map(function(){return!1}),c=!1,i=function(l){Xt(r[l]).subscribe(Ht(u,function(h){a[l]=h,!c&&!o[l]&&(o[l]=!0,(c=o.every(Bi))&&(o=null))},Ps))},n=0;n<d;n++)i(n);s.subscribe(Ht(u,function(l){if(c){var h=bn([l],dn(a));u.next(t?t.apply(void 0,bn([],dn(h))):h)}}))})}const Yh="0123456789ABCDEFGHJKMNPQRSTVWXYZ",Ai=32,N0=16,Jh=10,vu=0xffffffffffff;var Ln;(function(r){r.Base32IncorrectEncoding="B32_ENC_INVALID",r.DecodeTimeInvalidCharacter="DEC_TIME_CHAR",r.DecodeTimeValueMalformed="DEC_TIME_MALFORMED",r.EncodeTimeNegative="ENC_TIME_NEG",r.EncodeTimeSizeExceeded="ENC_TIME_SIZE_EXCEED",r.EncodeTimeValueMalformed="ENC_TIME_MALFORMED",r.PRNGDetectFailure="PRNG_DETECT",r.ULIDInvalid="ULID_INVALID",r.Unexpected="UNEXPECTED",r.UUIDInvalid="UUID_INVALID"})(Ln||(Ln={}));class bs extends Error{constructor(e,t){super(`${t} (${e})`),this.name="ULIDError",this.code=e}}function P0(r){const e=Math.floor(r()*Ai)%Ai;return Yh.charAt(e)}function D0(r){const e=M0(),t=e&&(e.crypto||e.msCrypto)||null;if(typeof(t==null?void 0:t.getRandomValues)=="function")return()=>{const s=new Uint8Array(1);return t.getRandomValues(s),s[0]/255};if(typeof(t==null?void 0:t.randomBytes)=="function")return()=>t.randomBytes(1).readUInt8()/255;throw new bs(Ln.PRNGDetectFailure,"Failed to find a reliable PRNG")}function M0(){return F0()?self:typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:null}function B0(r,e){let t="";for(;r>0;r--)t=P0(e)+t;return t}function $0(r,e=Jh){if(isNaN(r))throw new bs(Ln.EncodeTimeValueMalformed,`Time must be a number: ${r}`);if(r>vu)throw new bs(Ln.EncodeTimeSizeExceeded,`Cannot encode a time larger than ${vu}: ${r}`);if(r<0)throw new bs(Ln.EncodeTimeNegative,`Time must be positive: ${r}`);if(Number.isInteger(r)===!1)throw new bs(Ln.EncodeTimeValueMalformed,`Time must be an integer: ${r}`);let t,s="";for(let u=e;u>0;u--)t=r%Ai,s=Yh.charAt(t)+s,r=(r-t)/Ai;return s}function F0(){return typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope}function V0(r,e){const t=D0(),s=Date.now();return $0(s,Jh)+B0(N0,t)}const er=[];for(let r=0;r<256;++r)er.push((r+256).toString(16).slice(1));function U0(r,e=0){return(er[r[e+0]]+er[r[e+1]]+er[r[e+2]]+er[r[e+3]]+"-"+er[r[e+4]]+er[r[e+5]]+"-"+er[r[e+6]]+er[r[e+7]]+"-"+er[r[e+8]]+er[r[e+9]]+"-"+er[r[e+10]]+er[r[e+11]]+er[r[e+12]]+er[r[e+13]]+er[r[e+14]]+er[r[e+15]]).toLowerCase()}let Oo;const W0=new Uint8Array(16);function Z0(){if(!Oo){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");Oo=crypto.getRandomValues.bind(crypto)}return Oo(W0)}const G0=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),gu={randomUUID:G0};function H0(r,e,t){var s;if(gu.randomUUID&&!r)return gu.randomUUID();r=r||{};const u=r.random??((s=r.rng)==null?void 0:s.call(r))??Z0();if(u.length<16)throw new Error("Random bytes length must be >= 16");return u[6]=u[6]&15|64,u[8]=u[8]&63|128,U0(u)}const z0=5e3,K0=1e3,li=4e3,bu=1e3;var qh=(r=>(r.CONTINUOUS="CONTINUOUS",r.INITIAL="INITIAL",r))(qh||{});class Qh{constructor({knownID:e,runID:t,sequence:s,options:u}){Ft(this,"callback"),Ft(this,"queue",new Rr),Ft(this,"subscriptions",[]),Ft(this,"reconnect",new Rr),Ft(this,"client",new Kt),Ft(this,"_latencies",new Rr),Ft(this,"_latenciesConnectable",On(this._latencies.asObservable().pipe(T0((d,a)=>{if(a.latency<0){const o=d.get(a.streamID);o&&d.set(a.streamID,{...o,readyState:a.readyState})}else d.set(a.streamID,a);return d},new Map)))),Ft(this,"_errors",new Rr),Ft(this,"_errorsConnectable",On(this._errors.asObservable())),Ft(this,"_stdout",new Rr),Ft(this,"_stderr",new Rr),Ft(this,"_exitCode",new Rr),Ft(this,"_pid",new Rr),Ft(this,"_mimeType",new Rr),Ft(this,"_stdoutConnectable",On(this._stdout.asObservable())),Ft(this,"_stderrConnectable",On(this._stderr.asObservable())),Ft(this,"_exitCodeConnectable",On(this._exitCode.asObservable())),Ft(this,"_pidConnectable",On(this._pid.asObservable())),Ft(this,"_mimeTypeConnectable",On(this._mimeType.asObservable())),Ft(this,"knownID"),Ft(this,"runID"),Ft(this,"sequence"),Ft(this,"runnerEndpoint"),Ft(this,"interceptors"),Ft(this,"autoReconnect"),this.knownID=e,this.runID=t,this.sequence=s,this.runnerEndpoint=u.runnerEndpoint,this.interceptors=u.interceptors,this.autoReconnect=u.autoReconnect,this._latenciesConnectable.connect(),this._errorsConnectable.connect(),this._stdoutConnectable.connect(),this._stderrConnectable.connect(),this._exitCodeConnectable.connect(),this._pidConnectable.connect(),this._mimeTypeConnectable.connect(),this.client=this.reconnect.pipe(mu(bu,$i,{leading:!0,trailing:!0}),pu(d=>this.useSocketClient(d.streamID).pipe(pu(a=>this.useHeartbeat(a,d))))).pipe(O0()),this.subscriptions.push(this.monitor()),this.subscriptions.push(this.process())}get latencies(){return this._latenciesConnectable}get errors(){return this._errorsConnectable}get stdout(){return this._stdoutConnectable}get stderr(){return this._stderrConnectable}get exitCode(){return this._exitCodeConnectable}get pid(){return this._pidConnectable}get mimeType(){return this._mimeTypeConnectable}monitor(){return _0(K0).pipe(gn(()=>this.autoReconnect),To(this.reconnect),gn(([,e])=>e.heartbeat==="CONTINUOUS"),To(this.latencies),Ar(([,e])=>Array.from(e.values()).filter(t=>t.readyState===WebSocket.OPEN&&t.latency>=li)),gn(e=>e.length>0),mu(bu)).subscribe({next:e=>{console.log(new Date,"Triggering reconnect",e),this.connect()},complete:()=>{console.log("Monitor complete")},error:e=>{console.error("Error in monitor",e)}})}process(){const e=this.client.pipe(gn(u=>(u==null?void 0:u.readyState)===WebSocket.OPEN),fu(1)),t=this.queue.pipe(E0(()=>e),gn(u=>u.length>0),Ar(u=>u.sort((d,a)=>{const o=c=>{var i;return!!((i=c.payload.value)!=null&&i.config)};return o(a)?1:o(d)?-1:0}))),s=this.queue.pipe(A0(e));return w0(t.pipe(Rn(u=>u)),s).pipe(To(this.client),ai(([,u])=>u.readyState===WebSocket.OPEN),Rn(async([u,d])=>{await _u({req:u,interceptors:this.interceptors,socket:d,knownID:this.knownID,runID:this.runID})})).subscribe({error:u=>{this._errors.next(u)}})}useSocketClient(e){return new Kt(t=>{const s=new URL(this.runnerEndpoint);s.searchParams.set("id",e),s.searchParams.set("runID",this.runID);const u=new WebSocket(s.toString()),d=i=>{if(console.log(new Date,`WebSocket transport ${e} closed`,i),i.code===1005){t.complete();return}if(this.autoReconnect){this.connect();return}},a=i=>{console.log(new Date,`WebSocket transport ${e} error`,i),this.autoReconnect||t.error(i)},o=i=>{var n,l;if(typeof i.data!="string"){console.warn("Unexpected WebSocket message type:",typeof i.data);return}let h;try{h=yu(i.data),console.log("Received WebsocketResponse:",h)}catch(f){console.error("Failed to parse WebsocketResponse:",f)}const m=h.status;if(m&&m.code!==xb.OK){t.error(m);return}if(h.pong)return;const p=h.payload.value;if(p.stdoutData&&p.stdoutData.length>0&&((n=this.callback)==null||n.call(this,{type:xs.terminalStdout,output:{"runme.dev/id":this.knownID,data:p.stdoutData}}),this._stdout.next(p.stdoutData)),p.stderrData&&p.stderrData.length>0&&((l=this.callback)==null||l.call(this,{type:xs.terminalStderr,output:{"runme.dev/id":this.knownID,data:p.stderrData}}),this._stderr.next(p.stderrData)),p.exitCode!==void 0&&(this._exitCode.next(p.exitCode),t.complete()),p.pid!==void 0&&this._pid.next(p.pid),p.mimeType){const f=p.mimeType.split(";")[0];this._mimeType.next(f)}},c=()=>{console.log(new Date,`✅ Connected WebSocket for cell ${this.knownID} (#${this.sequence}) with runID ${this.runID}`),t.next(u)};return u.addEventListener("close",d),u.addEventListener("error",a),u.addEventListener("message",o),u.addEventListener("open",c),()=>{console.log(new Date,`☑️ Cleanly disconnected WebSocket for cell ${this.knownID} (#${this.sequence}) with runID ${this.runID}`),u.removeEventListener("close",d),u.removeEventListener("error",a),u.removeEventListener("message",o),u.removeEventListener("open",c),u.close()}})}setCallback(e){this.callback=e}sendExecuteRequest(e){this.queue.next(vt.create(Yo,{payload:{value:e,case:"executeRequest"}}))}useHeartbeat(e,{streamID:t,heartbeat:s}){return new Kt(u=>{const d=qo(e,"message").pipe(ai(()=>e.readyState===WebSocket.OPEN),Ar(c=>yu(c.data)),Ar(c=>c.pong),gn(c=>c!==void 0),Ar(c=>({receivedAt:BigInt(Date.now()),pong:c}))),a=(s==="INITIAL"?Cs(0):Cs(0,z0)).pipe(ai(()=>e.readyState===WebSocket.OPEN),Ar(()=>{const c={timestamp:BigInt(Date.now())};return vt.create(Yo,{ping:c})}),Rn(async c=>(await _u({req:c,interceptors:this.interceptors,socket:e}),c)),Ar(c=>c.ping)).pipe(gn(c=>(c==null?void 0:c.timestamp)!==void 0),Rn(c=>C0(d.pipe(gn(i=>i.pong.timestamp===c.timestamp),fu(1),Ar(i=>{const n=c.timestamp,l=i.receivedAt;return Number(l-n)})),Cs(li).pipe(Ar(()=>{throw new Error(`Pong not received within ${li}ms for stream ${t}`)}))).pipe(Xh(i=>(this._latencies.next({streamID:t,latency:li,readyState:e.readyState,updatedAt:BigInt(Date.now())}),console.log(new Date,"Ping deadline exceeded",i.message),i0(null))))),I0(()=>{this._latencies.next({streamID:t,latency:-1,readyState:e.readyState,updatedAt:BigInt(Date.now())})}),R0(c=>{c!==null&&this._latencies.next({streamID:t,latency:c,readyState:e.readyState,updatedAt:BigInt(Date.now())})})),o=[];return o.push(a.subscribe({error:c=>{console.error("Unexpected error sending heartbeat",c)}})),u.next(e),()=>{o.forEach(c=>c.unsubscribe())}})}connect(e="CONTINUOUS"){const t=X0(),s=this.latencies.pipe(Ar(u=>{const d=u.get(t);return d===void 0?null:d}),ai(u=>(u==null?void 0:u.readyState)===WebSocket.OPEN));return this.reconnect.next({streamID:t,heartbeat:e}),s}close(){this.reconnect.complete(),this.queue.complete(),this._latencies.complete(),this.subscriptions.forEach(e=>e.unsubscribe())}}function yu(r){const e=JSON.parse(r);return vt.fromJson(Cb,e)}async function _u({req:r,interceptors:e,socket:t,knownID:s,runID:u}){s&&(r.knownId=s),u&&(r.runId=u);const d={stream:!1,message:{},method:{},service:{},requestMethod:"UPGRADE",url:t.url,signal:new AbortController().signal,header:new Headers,contextValues:{}};let a=async c=>({stream:!1,message:{},method:{},service:{},header:c.header});for(const c of e.concat().reverse())a=c(a);const o=(await a(d)).header.get("Authorization");o&&r&&(r.authorization=o),t.send(JSON.stringify(vt.toJson(Yo,r)))}function X0(){return H0().replace(/-/g,"")}function ef(){return`run_${V0()}`}function Y0({cellID:r,runID:e,sequence:t,commands:s,content:u,runner:d,settings:a={},onStdout:o,onStderr:c,onExitCode:i,onPid:n,onMimeType:l}){var h;const{rows:m=20,className:p,fontSize:f=12,fontFamily:v="monospace",takeFocus:g=!0,scrollToFit:b=!0}=a,y=Ae.useMemo(()=>!r||u===""?null:u,[r,u]),_=Ae.useMemo(()=>{if(!(!r||!e||!d.endpoint))return console.log("Creating stream",r,e,d.endpoint),new Qh({knownID:r,runID:e,sequence:t,options:{runnerEndpoint:d.endpoint,interceptors:d.interceptors,autoReconnect:d.reconnect}})},[r,e,t,d]);Ae.useEffect(()=>{const k=_==null?void 0:_.connect().subscribe(O=>console.log(`Heartbeat latency for streamID ${O==null?void 0:O.streamID} (${(O==null?void 0:O.readyState)===1?"open":"closed"}): ${O==null?void 0:O.latency}ms`));return()=>{k==null||k.unsubscribe(),_==null||_.close()}},[_]);let w=vt.create(iu,{rows:34,cols:100,x:0,y:0});const x=Ae.useMemo(()=>vt.create(Eo,{sessionStrategy:yb.MOST_RECENT,storeStdoutInEnv:!0,config:{languageId:"sh",background:!1,fileExtension:"",env:[`RUNME_ID=${r}`,"RUNME_RUNNER=v2","TERM=xterm-256color"],source:{case:"commands",value:{items:s}},interactive:!0,mode:gb.INLINE,runId:e,knownId:r},winsize:w}),[r,e,s,w]),S=Ae.useMemo(()=>{var k;return{output:{"runme.dev/id":(k=x.config)==null?void 0:k.knownId,fontFamily:v||"monospace",fontSize:f||12,cursorStyle:"block",cursorBlink:!0,cursorWidth:1,takeFocus:g,scrollToFit:b,smoothScrollDuration:0,scrollback:4e3,initialRows:m,content:y||"",isAutoSaveEnabled:!1,isPlatformAuthEnabled:!1}}},[(h=x.config)==null?void 0:h.knownId,v,f,g,b,m,y]),j=new TextEncoder;return wb({postMessage:k=>{if(k.type===xs.terminalOpen||k.type===xs.terminalResize){const O=Number(k.output.terminalDimensions.columns),T=Number(k.output.terminalDimensions.rows);if(Number.isFinite(O)&&Number.isFinite(T)){if(w.cols===O&&w.rows===T)return;w=vt.create(iu,{cols:O,rows:T,x:0,y:0});const L=vt.create(Eo,{winsize:w});_==null||_.sendExecuteRequest(L)}}if(k.type===xs.terminalStdin){const O=j.encode(k.output.input),T=vt.create(Eo,{inputData:O});_==null||_.sendExecuteRequest(T)}},onDidReceiveMessage:k=>{_==null||_.setCallback(k)}}),Ae.useEffect(()=>{const k=_==null?void 0:_.stdout.subscribe(O=>{o==null||o(O)});return()=>k==null?void 0:k.unsubscribe()},[_,o]),Ae.useEffect(()=>{const k=_==null?void 0:_.stderr.subscribe(O=>{c==null||c(O)});return()=>k==null?void 0:k.unsubscribe()},[_,c]),Ae.useEffect(()=>{const k=_==null?void 0:_.exitCode.subscribe(O=>{i==null||i(O),_==null||_.close()});return()=>k==null?void 0:k.unsubscribe()},[_,i]),Ae.useEffect(()=>{const k=_==null?void 0:_.pid.subscribe(O=>{n==null||n(O)});return()=>k==null?void 0:k.unsubscribe()},[_,n]),Ae.useEffect(()=>{const k=_==null?void 0:_.mimeType.subscribe(O=>{l==null||l(O)});return()=>k==null?void 0:k.unsubscribe()},[_,l]),Ae.useEffect(()=>{!_||!x||(console.log("useEffect invoked - Commands changed:",JSON.stringify(x.config.source.value)),_==null||_.sendExecuteRequest(x))},[x,_]),oe.jsx("div",{className:p,ref:k=>{if(!k||k.hasChildNodes())return;const O=document.createElement("terminal-view");O.setAttribute("buttons","false"),O.setAttribute("id",S.output["runme.dev/id"]),O.setAttribute("fontFamily",S.output.fontFamily),typeof S.output.fontSize=="number"&&O.setAttribute("fontSize",S.output.fontSize.toString()),S.output.cursorStyle&&O.setAttribute("cursorStyle",S.output.cursorStyle),typeof S.output.cursorBlink=="boolean"&&O.setAttribute("cursorBlink",S.output.cursorBlink?"true":"false"),typeof S.output.cursorWidth=="number"&&O.setAttribute("cursorWidth",S.output.cursorWidth.toString()),typeof S.output.takeFocus=="boolean"&&O.setAttribute("takeFocus",S.output.takeFocus?"true":"false"),typeof S.output.smoothScrollDuration=="number"&&O.setAttribute("smoothScrollDuration",S.output.smoothScrollDuration.toString()),typeof S.output.scrollback=="number"&&O.setAttribute("scrollback",S.output.scrollback.toString()),S.output.initialRows!==void 0&&O.setAttribute("initialRows",S.output.initialRows.toString()),S.output.content!==void 0&&O.setAttribute("initialContent",S.output.content),S.output.isAutoSaveEnabled&&O.setAttribute("isAutoSaveEnabled",S.output.isAutoSaveEnabled.toString()),S.output.isPlatformAuthEnabled&&O.setAttribute("isPlatformAuthEnabled",S.output.isPlatformAuthEnabled.toString()),k.appendChild(O);const T=document.createElement("div");T.setAttribute("className","h-1"),k.appendChild(T),setTimeout(()=>{b&&!J0(T)&&T.scrollIntoView({behavior:"smooth"})},0)}})}function J0(r){const e=r.getBoundingClientRect();return e.top>=0&&e.left>=0&&e.bottom<=(window.innerHeight||document.documentElement.clientHeight)&&e.right<=(window.innerWidth||document.documentElement.clientWidth)}class ys extends Error{}ys.prototype.name="InvalidTokenError";function q0(r){return decodeURIComponent(atob(r).replace(/(.)/g,(e,t)=>{let s=t.charCodeAt(0).toString(16).toUpperCase();return s.length<2&&(s="0"+s),"%"+s}))}function Q0(r){let e=r.replace(/-/g,"+").replace(/_/g,"/");switch(e.length%4){case 0:break;case 2:e+="==";break;case 3:e+="=";break;default:throw new Error("base64 string is not of the correct length")}try{return q0(e)}catch{return atob(e)}}function tf(r,e){if(typeof r!="string")throw new ys("Invalid token specified: must be a string");e||(e={});const t=e.header===!0?0:1,s=r.split(".")[t];if(typeof s!="string")throw new ys(`Invalid token specified: missing part #${t+1}`);let u;try{u=Q0(s)}catch(d){throw new ys(`Invalid token specified: invalid base64 for part #${t+1} (${d.message})`)}try{return JSON.parse(u)}catch(d){throw new ys(`Invalid token specified: invalid json for part #${t+1} (${d.message})`)}}const rf="0123456789ABCDEFGHJKMNPQRSTVWXYZ",Ri=32,ey=16,nf=10,wu=0xffffffffffff;var Nn;(function(r){r.Base32IncorrectEncoding="B32_ENC_INVALID",r.DecodeTimeInvalidCharacter="DEC_TIME_CHAR",r.DecodeTimeValueMalformed="DEC_TIME_MALFORMED",r.EncodeTimeNegative="ENC_TIME_NEG",r.EncodeTimeSizeExceeded="ENC_TIME_SIZE_EXCEED",r.EncodeTimeValueMalformed="ENC_TIME_MALFORMED",r.PRNGDetectFailure="PRNG_DETECT",r.ULIDInvalid="ULID_INVALID",r.Unexpected="UNEXPECTED",r.UUIDInvalid="UUID_INVALID"})(Nn||(Nn={}));class _s extends Error{constructor(e,t){super(`${t} (${e})`),this.name="ULIDError",this.code=e}}function ty(r){const e=Math.floor(r()*Ri)%Ri;return rf.charAt(e)}function ry(r){const e=ny(),t=e&&(e.crypto||e.msCrypto)||null;if(typeof(t==null?void 0:t.getRandomValues)=="function")return()=>{const s=new Uint8Array(1);return t.getRandomValues(s),s[0]/255};if(typeof(t==null?void 0:t.randomBytes)=="function")return()=>t.randomBytes(1).readUInt8()/255;throw new _s(Nn.PRNGDetectFailure,"Failed to find a reliable PRNG")}function ny(){return oy()?self:typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:null}function sy(r,e){let t="";for(;r>0;r--)t=ty(e)+t;return t}function iy(r,e=nf){if(isNaN(r))throw new _s(Nn.EncodeTimeValueMalformed,`Time must be a number: ${r}`);if(r>wu)throw new _s(Nn.EncodeTimeSizeExceeded,`Cannot encode a time larger than ${wu}: ${r}`);if(r<0)throw new _s(Nn.EncodeTimeNegative,`Time must be positive: ${r}`);if(Number.isInteger(r)===!1)throw new _s(Nn.EncodeTimeValueMalformed,`Time must be an integer: ${r}`);let t,s="";for(let u=e;u>0;u--)t=r%Ri,s=rf.charAt(t)+s,r=(r-t)/Ri;return s}function oy(){return typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope}function ay(r,e){const t=ry(),s=Date.now();return iy(s,nf)+sy(ey,t)}const ly=yn("ChphZ2VudC92MS9jcmVkZW50aWFscy5wcm90bxIIYWdlbnQudjEioQEKCk9BdXRoVG9rZW4SFAoMYWNjZXNzX3Rva2VuGAEgASgJEhIKCnRva2VuX3R5cGUYAiABKAkSFQoNcmVmcmVzaF90b2tlbhgDIAEoCRISCgpleHBpcmVzX2F0GAQgASgDEioKBmV4cGlyeRgFIAEoCzIaLmdvb2dsZS5wcm90b2J1Zi5UaW1lc3RhbXASEgoKZXhwaXJlc19pbhgGIAEoA0JAWj5naXRodWIuY29tL3J1bm1lZGV2L3J1bm1lL3YzL2FwaS9nZW4vcHJvdG8vZ28vYWdlbnQvdjE7YWdlbnR2MWIGcHJvdG8z",[Ms.file_google_protobuf_timestamp]),Su=dt(ly,0);/*! js-cookie v3.0.5 | MIT */function ci(r){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var s in t)r[s]=t[s]}return r}var cy={read:function(r){return r[0]==='"'&&(r=r.slice(1,-1)),r.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent)},write:function(r){return encodeURIComponent(r).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,decodeURIComponent)}};function Qo(r,e){function t(u,d,a){if(!(typeof document>"u")){a=ci({},e,a),typeof a.expires=="number"&&(a.expires=new Date(Date.now()+a.expires*864e5)),a.expires&&(a.expires=a.expires.toUTCString()),u=encodeURIComponent(u).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var o="";for(var c in a)a[c]&&(o+="; "+c,a[c]!==!0&&(o+="="+a[c].split(";")[0]));return document.cookie=u+"="+r.write(d,u)+o}}function s(u){if(!(typeof document>"u"||arguments.length&&!u)){for(var d=document.cookie?document.cookie.split("; "):[],a={},o=0;o<d.length;o++){var c=d[o].split("="),i=c.slice(1).join("=");try{var n=decodeURIComponent(c[0]);if(a[n]=r.read(i,n),u===n)break}catch{}}return u?a[u]:a}}return Object.create({set:t,get:s,remove:function(u,d){t(u,"",ci({},d,{expires:-1}))},withAttributes:function(u){return Qo(this.converter,ci({},this.attributes,u))},withConverter:function(u){return Qo(ci({},this.converter,u),this.attributes)}},{attributes:{value:Object.freeze(e)},converter:{value:Object.freeze(r)}})}var sf=Qo(cy,{path:"/"});const uy=["agent-session","cassie-session"],dy=["agent-oauth-token","cassie-oauth-token"];function ea(){for(const r of uy){const e=sf.get(r);if(e&&e.length>0)return e}}function hy(){let r=vt.create(Su);for(const e of dy){const t=sf.get(e);if(t&&t.length>0)try{const s=JSON.parse(t);return r=vt.fromJson(Su,s),r.accessToken}catch(s){console.error("Failed to parse OAuthToken:",s)}}return r.accessToken}const of=Ae.createContext(void 0),Zr=()=>{const r=Ae.useContext(of);if(!r)throw new Error("useSettings must be used within a SettingsProvider");return r},af=({children:r,agentEndpoint:e,requireAuth:t,webApp:s,createAuthInterceptors:u})=>{const[d,a]=Ae.useState(null),o=Ae.useMemo(()=>{const f=ea();if(!f)return"unauthenticated";let v;try{return v=tf(f),v.email||v.sub||"unauthenticated"}catch(g){return console.error("Error decoding token",g),"unauthenticated"}},[]),c=Ae.useMemo(()=>{const f=window.location.hostname==="localhost",v=window.location.protocol==="http:",g=window.location.port==="4173"||window.location.port==="5173",b=f&&v&&g;return{requireAuth:t??!1,agentEndpoint:e??(b?"http://localhost:8080":window.location.origin),webApp:{runner:(s==null?void 0:s.runner)??(b?"ws://localhost:8080/ws":`${v?"ws:":"wss:"}//${window.location.host}/ws`),reconnect:(s==null?void 0:s.reconnect)??!0,invertedOrder:(s==null?void 0:s.invertedOrder)??!1}}},[t,s]),[i,n]=Ae.useState(()=>{const f=localStorage.getItem("cloudAssistantSettings"),v=f?JSON.parse(f):{};return v&&v.webApp&&v.webApp.reconnect!==void 0&&(v.webApp.reconnect=c.webApp.reconnect),f?{...c,...v}:c});Ae.useEffect(()=>{localStorage.setItem("cloudAssistantSettings",JSON.stringify(i))},[i]);const l=Ae.useCallback(f=>{const v=g=>{const b=Lt.from(g);b.code===Ct.Unauthenticated&&(window.location.href=`/login?error=${encodeURIComponent(b.name)}&error_description=${encodeURIComponent(b.message)}`)};return[g=>async b=>{const y=ea();return y&&b.header.set("Authorization",`Bearer ${y}`),f?g(b).catch(_=>{throw v(_),_}):g(b)}]},[]),h=Ae.useMemo(()=>u??l,[u,l]),m=Ae.useCallback(async()=>{if(!i.webApp.runner)return;a(null);const f=new Qh({knownID:`check_${ay()}`,runID:ef(),sequence:0,options:{runnerEndpoint:i.webApp.runner,interceptors:h(!1),autoReconnect:!1}}),v=[];return v.push(f.errors.subscribe({next:g=>a(g)})),v.push(f.connect(qh.INITIAL).subscribe(g=>{g!==null&&(console.log(`Initial heartbeat latency for streamID ${g.streamID} (${g.readyState===1?"open":"closed"}): ${g.latency}ms`),f.close())})),()=>{v.forEach(g=>g.unsubscribe())}},[u,i.webApp.runner]);Ae.useEffect(()=>{m()},[m]);const p=f=>{n(v=>({...v,...f,webApp:{...v.webApp,...f.webApp}}))};return oe.jsx(of.Provider,{value:{principal:o,checkRunnerAuth:m,createAuthInterceptors:h,defaultSettings:c,runnerError:d,settings:i,updateSettings:p},children:r})},lf=Ae.createContext(void 0),cf=()=>{const r=Ae.useContext(lf);if(!r)throw new Error("useClient must be used within a ClientProvider");return r},uf=({children:r})=>{const[e,t]=Ae.useState(),{settings:s,createAuthInterceptors:u}=Zr();return Ae.useEffect(()=>{t(fy(s.agentEndpoint,u(!0)))},[s.agentEndpoint,u]),oe.jsx(lf.Provider,{value:{client:e,setClient:t},children:r})};function fy(r,e){console.log(`initializing the client: baseURL ${r}`);const t=Gd({baseUrl:r,interceptors:e});return Md(am,t)}const df=Ae.createContext(void 0),Fi=()=>{const r=Ae.useContext(df);if(!r)throw new Error("useOutput must be used within an OutputProvider");return r},hf=({children:r})=>{const e=Ae.useMemo(()=>new Map,[]),t=Ae.useCallback((o,c)=>{e.set(o,c)},[e]),s=Ae.useCallback(o=>{e.delete(o)},[e]),u=Ae.useCallback(o=>e.get(o),[e]),d=Ae.useCallback(()=>e,[e]),a=Ae.useMemo(()=>({registerRenderer:t,unregisterRenderer:s,getRenderer:u,getAllRenderers:d}),[t,s,u,d]);return oe.jsx(df.Provider,{value:a,children:r})},ff=Ae.createContext(void 0),Qr=()=>{const r=Ae.useContext(ff);if(!r)throw new Error("useCell must be used within a CellProvider");return r};function xu(r,e){if(!r)return[];const t=r.positions.map(s=>{const u=r.cells[s];return u.languageId="sh",u});return t.length===0?[]:e?t.reverse():t}const pf=({children:r,getAccessToken:e})=>{const{settings:t,createAuthInterceptors:s,principal:u}=Zr(),[d,a]=Ae.useState(0),[o,c]=Ae.useState(!1),[i,n]=Ae.useState(!1),[l,h]=Ae.useState(),{getAllRenderers:m}=Fi(),p=Ae.useMemo(()=>{const R=new URL(t.webApp.runner);return R.protocol==="ws:"?R.protocol="http:":R.protocol="https:",R.pathname="",R.toString()},[t.webApp.runner]),f=Ae.useMemo(()=>{if(u)return new qv("agent",u,Vo(Pd,p,s(!0)))},[t.agentEndpoint,u]),v=Ae.useMemo(()=>t.webApp.invertedOrder,[t.webApp.invertedOrder]),{client:g}=cf(),[b,y]=Ae.useState(void 0),_=Ae.useCallback(()=>{if(!b)return;const R=xu(b,v),$=vt.create(wi,{cells:R});l&&($.metadata[Si.PreviousResponseId]=l),f==null||f.saveNotebook(b.runmeSession,$)},[b,v,l,f]),w=Ae.useCallback(async({attemptRestore:R})=>{if(!f)return;a(0),h(void 0);const $=f.createSession();let B;if(!R)B=await $;else{const H=await f.listActiveSessions(),z=(await f.loadSessions(H)).filter(ee=>ee.data.cells.length!==0);if(z.length===0)B=await $;else{const ee=z[0];let Q=ee.data.cells.map(D=>D.refId);v&&(Q=Q.reverse());const Z=ee.data.metadata[Si.PreviousResponseId];Z&&h(Z),y({runmeSession:ee.id,cells:ee.data.cells.reduce((D,ue)=>(D[ue.refId]=ue,D),{}),positions:Q});return}}y({runmeSession:B,cells:{},positions:[]})},[v,f]);Ae.useEffect(()=>{_()},[b,f,v,_]),Ae.useEffect(()=>{y(R=>({runmeSession:(R==null?void 0:R.runmeSession)??"",cells:(R==null?void 0:R.cells)??{},positions:[...(R==null?void 0:R.positions)??[]].reverse()}))},[v]),Ae.useEffect(()=>{w&&w({attemptRestore:!0})},[w]);const x=Ae.useMemo(()=>b?b.positions.map(R=>b.cells[R]).filter(R=>!!R&&(R.kind===fr.MARKUP||R.kind===fr.CODE)):[],[b]),S=Ae.useMemo(()=>b?b.positions.map(R=>b.cells[R]).filter(R=>!!R&&R.kind===fr.CODE):[],[b]),j=Ae.useMemo(()=>b?b.positions.map(R=>b.cells[R]).filter(R=>!!R&&R.kind===fr.DOC_RESULTS):[],[b]),k=()=>({chat:x,actions:S,files:j}),O=R=>vt.clone(Pn,R),T=async R=>{const $=await e(),B=vt.create(om,{cells:R,previousResponseId:l});B.openaiAccessToken=$,$||console.error("No access token found");try{const H=g.generate(B);for await(const V of H){for(const z of V.cells)n(!1),G(z);h(V.responseId)}}catch(H){console.log(H)}finally{n(!1),c(!1)}},L=async R=>{if(!R.trim())return;const $=vt.create(Pn,{refId:`user_${Jl()}`,role:Wr.USER,kind:fr.MARKUP,value:R});G($),c(!0),n(!0),await T([$])},F=async R=>{R.outputs.length!==0&&(console.log("sending output cell",R.refId,"previousResponseId",l),c(!0),n(!0),await T([R]))},G=R=>{const $=m();for(const B of $.values())B.onCellUpdate(R);y(B=>{if(B){if(!B.cells[R.refId]){const H=v?[R.refId,...B.positions]:[...B.positions,R.refId];return{runmeSession:B.runmeSession,cells:{...B.cells,[R.refId]:R},positions:H}}return{...B,runmeSession:B.runmeSession,cells:{...B.cells,[R.refId]:R}}}})},X=()=>{const R=`code_${Jl().replace(/-/g,"")}`,$=vt.create(Pn,{metadata:{[hr.ID]:R,[hr.RunmeID]:R},refId:R,languageId:"sh",role:Wr.USER,kind:fr.CODE,value:""});G($)},ie=R=>{if(!S.find(H=>H.refId===R.refId))return;const B=new CustomEvent("runCodeCell",{detail:{cellId:R.refId}});R.executionSummary=void 0,R.outputs=R.outputs.filter(H=>H.items.some(V=>V.mime===Jr.StatefulRunmeTerminal)),a(H=>{const V=H+1;return R.metadata[hr.Sequence]=V.toString(),V}),window.dispatchEvent(B)},te=async({asSessionRecord:R})=>{var ue;const $=xu(b,v);if(!b||$.length===0)return;const B=vt.create(wi,{cells:$}),H=Vo(Ra,t.agentEndpoint),V=vt.create(Ia,{notebook:B,options:vt.create(ka,{outputs:vt.create(Ea,{enabled:!1,summary:!1})})});R&&((ue=V.options)!=null&&ue.outputs)&&(V.options.outputs.enabled=!0,V.options.outputs.summary=!0,V.options.session=vt.create(ja,{id:b.runmeSession}));const z=await H.serialize(V),ee=new Blob([z.result],{type:"text/plain"}),Q=URL.createObjectURL(ee),Z=document.createElement("a");Z.href=Q;const D=R?"Session":"Notebook";Z.download=`${D}-${Jd()}.md`,document.body.appendChild(Z),Z.click(),document.body.removeChild(Z),URL.revokeObjectURL(Q)};return oe.jsx(ff.Provider,{value:{useColumns:k,sequence:d,saveState:_,exportDocument:te,sendOutputCell:F,createOutputCell:O,sendUserCell:L,addCodeCell:X,isInputDisabled:o,isTyping:i,runCodeCell:ie,resetSession:w},children:r})},Cu=new TextEncoder;function py({pid:r,exitCode:e},t,s,u){let d;return r!==null&&e!==null&&(d=vt.create(xa,{pid:BigInt(r),exitReason:vt.create(Sa,{type:"exit",code:e})})),[vt.create(Ni,{items:[vt.create(Ts,{mime:Jr.VSCodeNotebookStdOut,type:"Buffer",data:Cu.encode(t)}),vt.create(Ts,{mime:Jr.VSCodeNotebookStdErr,type:"Buffer",data:Cu.encode(s)})],processInfo:d})]}const my=vt.create(Pn,{kind:fr.MARKUP,role:Wr.ASSISTANT,value:"..."}),ta={fontSize:14,fontFamily:"monospace"},vy=new TextDecoder,gy=Ae.memo(Y0,(r,e)=>r.cellID===e.cellID&&r.runID===e.runID),mf=({cell:r,onExitCode:e,onPid:t})=>{const{createAuthInterceptors:s,settings:{webApp:u}}=Zr(),{sendOutputCell:d,saveState:a}=Qr(),o=u.invertedOrder,[c,i]=Ae.useState(!1),[n,l]=Ae.useState({value:"",runID:""}),[h,m]=Ae.useState(null),[p,f]=Ae.useState(null),[v,g]=Ae.useState(null),[b,y]=Ae.useState(null),[_,w]=Ae.useState(""),[x,S]=Ae.useState(""),[j,k]=Ae.useState(""),O=Ae.useMemo(()=>Number(r.metadata[hr.Sequence]??0),[r,p,v]),T=Ae.useCallback((Q=!1)=>{m(BigInt(Date.now())),w(""),S(""),f(null),g(null),i(Q),l({value:r.value,runID:ef()})},[r]),L=Ae.useMemo(()=>({...ta,className:"rounded-md overflow-hidden",rows:14,scrollToFit:!o,takeFocus:c}),[o,c]);Ae.useEffect(()=>{const Q=Z=>{Z.detail.cellId===r.refId&&T()};return window.addEventListener("runCodeCell",Q),()=>{window.removeEventListener("runCodeCell",Q)}},[r.refId,T]);const F=Ae.useMemo(()=>{const Q=r.outputs.filter(D=>D.items.some(ue=>ue.mime===Jr.StatefulRunmeTerminal)),Z=py({pid:p,exitCode:v},_,x);return[...Q,...Z]},[p,v,_,x,b,r.outputs]);Ae.useEffect(()=>{h!==null&&(r.outputs=F,r.executionSummary=vt.create(Ca,{timing:vt.create(wa,{startTime:h,endTime:BigInt(Date.now())}),executionOrder:O,success:Number.isFinite(v)&&v===0}))},[r,F,v,O,h]);const G=Ae.useMemo(()=>p===null||v===null||n.runID===""||!Number.isFinite(p)||!Number.isInteger(v)?null:r,[r,n.runID,v,p]);Ae.useEffect(()=>{!G||j===n.runID||(k(n.runID),d(G))},[d,G,n.runID,j]),Ae.useEffect(()=>{p!==null&&t(p)},[p,t]),Ae.useEffect(()=>{v!==null&&e(v)},[v,e]),Ae.useEffect(()=>{r.kind===fr.CODE&&(n.runID!==""&&(r.metadata[hr.LastRunID]=n.runID),p?r.metadata[hr.Pid]=p.toString():delete r.metadata[hr.Pid],v!==null&&Number.isFinite(v)?(delete r.metadata[hr.Pid],r.metadata[hr.ExitCode]=v.toString()):delete r.metadata[hr.ExitCode],a())},[p,v,r,a,n.runID]);const X=Ae.useMemo(()=>{if(r.kind!==fr.CODE||j!=="")return;const Q=r.outputs.flatMap(Z=>Z.items).find(Z=>Z.mime===Jr.VSCodeNotebookStdOut);if(Q)return vy.decode(Q.data)},[r.kind,r.outputs,j]),ie=Ae.useMemo(()=>{var Z;return((Z=r.metadata)==null?void 0:Z[hr.Pid])??""?r.metadata[hr.LastRunID]??"":""},[r.metadata]),te=Ae.useMemo(()=>n.value===""||n.runID===""?[]:n.value.split(`
|
|
6549
6549
|
`),[n]),R=Ae.useMemo(()=>n.runID===""?ie:n.runID,[n.runID,ie]),$=Ae.useMemo(()=>({endpoint:u.runner,reconnect:u.reconnect,interceptors:s(!1)}),[u.runner,u.reconnect,s]),B=Ae.useCallback(Q=>{w(Z=>Z+new TextDecoder().decode(Q))},[]),H=Ae.useCallback(Q=>{S(Z=>Z+new TextDecoder().decode(Q))},[]),V=Ae.useCallback(Q=>{f(Q)},[]),z=Ae.useCallback(Q=>{g(Q)},[]),ee=Ae.useCallback(Q=>{y(Q)},[]);return te.length===0&&(!X||X.length===0)?null:oe.jsx(gy,{cellID:r.refId,runID:R,sequence:O,commands:te,content:X,runner:$,settings:L,onPid:V,onStdout:B,onStderr:H,onExitCode:z,onMimeType:ee},R)},ju="vs-dark",by=Ae.memo(({id:r,value:e,language:t,fontSize:s=14,fontFamily:u="monospace",onChange:d,onEnter:a})=>{const o=Ae.useRef(a),c=Ae.useRef(null),i=Ae.useRef(null),[n,l]=Ae.useState("140px"),[h,m]=Ae.useState(!1),p=Ae.useRef(0),f=Ae.useRef(0);Ae.useEffect(()=>{o.current=a},[a]),Ae.useEffect(()=>{const b=_=>{if(!h)return;const w=_.clientY-p.current,x=Math.max(100,f.current+w);l(`${x}px`),c.current&&c.current.layout()},y=()=>{m(!1),document.body.style.cursor="default"};return h&&(document.addEventListener("mousemove",b),document.addEventListener("mouseup",y)),()=>{document.removeEventListener("mousemove",b),document.removeEventListener("mouseup",y)}},[h]);const v=(b,y)=>{c.current=b,y!=null&&y.editor&&(y.editor.setTheme(ju),b&&(b.onKeyDown(_=>{_.ctrlKey&&_.keyCode===3&&o.current()}),e===""&&b.focus()))},g=b=>{var y;m(!0),p.current=b.clientY,f.current=((y=i.current)==null?void 0:y.clientHeight)||140,document.body.style.cursor="ns-resize",b.preventDefault()};return oe.jsxs("div",{className:"pb-1 w-full",ref:i,children:[oe.jsx("div",{className:"rounded-md overflow-hidden",children:oe.jsx(Ff,{height:n,width:"100%",defaultLanguage:t,value:e,options:{scrollbar:{alwaysConsumeMouseWheel:!1},minimap:{enabled:!1},theme:ju,wordWrap:"wordWrapColumn",fontSize:s,fontFamily:u,lineHeight:20},onChange:b=>{b&&(e=b,d==null||d(b))},onMount:v,className:"rounded-lg",wrapperProps:{className:"rounded-lg"}},r)}),oe.jsx("div",{className:"h-2 w-full cursor-ns-resize",onMouseDown:g})]})},(r,e)=>r.value===e.value),yy=()=>oe.jsx("svg",{width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:oe.jsx("path",{d:"M3.24182 2.32181C3.3919 2.23132 3.5784 2.22601 3.73338 2.30781L12.7334 7.05781C12.8974 7.14436 13 7.31457 13 7.5C13 7.68543 12.8974 7.85564 12.7334 7.94219L3.73338 12.6922C3.5784 12.774 3.3919 12.7687 3.24182 12.6782C3.09175 12.5877 3 12.4252 3 12.25V2.75C3 2.57476 3.09175 2.4123 3.24182 2.32181ZM4 3.57925V11.4207L11.4338 7.5L4 3.57925Z",fill:"currentColor",fillRule:"evenodd",clipRule:"evenodd",stroke:"currentColor",strokeWidth:"0.5"})}),_y=()=>oe.jsx("svg",{width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:oe.jsx("path",{d:"M7.5 1.5C4.5 1.5 2 4 2 7C2 8.9 3 10.5 4.5 11.5L4 12.5C2 11.5 1 9.2 1 7C1 3.5 4 0.5 7.5 0.5C11 0.5 14 3.5 14 7C14 9.2 13 11.5 11 12.5L10.5 11.5C12 10.5 13 8.9 13 7C13 4 10.5 1.5 7.5 1.5Z",fill:"currentColor",fillRule:"evenodd",clipRule:"evenodd"})}),wy=()=>oe.jsx("svg",{width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:oe.jsx("path",{d:"M11.4669 3.72684C11.7558 3.91574 11.8369 4.30308 11.648 4.59198L7.39799 11.092C7.29783 11.2452 7.13556 11.3467 6.95402 11.3699C6.77247 11.3931 6.58989 11.3355 6.45446 11.2124L3.70446 8.71241C3.44905 8.48022 3.43023 8.08494 3.66242 7.82953C3.89461 7.57412 4.28989 7.55529 4.5453 7.78749L6.75292 9.79441L10.6018 3.90792C10.7907 3.61902 11.178 3.53795 11.4669 3.72684Z",fill:"#22c55e",fillRule:"evenodd",clipRule:"evenodd",stroke:"#22c55e",strokeWidth:"1"})}),Sy=({exitCode:r})=>oe.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[oe.jsx("circle",{cx:"12",cy:"12",r:"20",fill:"#ef4444",fillOpacity:"0.3"}),oe.jsx("text",{x:"50%",y:"50%",dominantBaseline:"middle",textAnchor:"middle",fill:"#ef4444",fontSize:"10",fontWeight:"bold",children:r})]});function xy(){return oe.jsx("svg",{width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:oe.jsx("path",{d:"M7.5 0.75C7.91421 0.75 8.25 1.08579 8.25 1.5V7.25H14C14.4142 7.25 14.75 7.58579 14.75 8C14.75 8.41421 14.4142 8.75 14 8.75H8.25V14.5C8.25 14.9142 7.91421 15.25 7.5 15.25C7.08579 15.25 6.75 14.9142 6.75 14.5V8.75H1C0.585786 8.75 0.25 8.41421 0.25 8C0.25 7.58579 0.585786 7.25 1 7.25H6.75V1.5C6.75 1.08579 7.08579 0.75 7.5 0.75Z",fill:"currentColor",fillRule:"evenodd",clipRule:"evenodd",strokeWidth:"0.5"})})}function Cy(){return oe.jsx("svg",{width:"28",height:"28",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:oe.jsx("path",{d:"M10 6.5C10 8.433 8.433 10 6.5 10C4.567 10 3 8.433 3 6.5C3 4.567 4.567 3 6.5 3C8.433 3 10 4.567 10 6.5ZM9.30884 10.0159C8.53901 10.6318 7.56251 11 6.5 11C4.01472 11 2 8.98528 2 6.5C2 4.01472 4.01472 2 6.5 2C8.98528 2 11 4.01472 11 6.5C11 7.56251 10.6318 8.53901 10.0159 9.30884L12.8536 12.1464C13.0488 12.3417 13.0488 12.6583 12.8536 12.8536C12.6583 13.0488 12.3417 13.0488 12.1464 12.8536L9.30884 10.0159Z",fill:"currentColor",stroke:"currentColor",strokeWidth:"0.3",fillRule:"evenodd",clipRule:"evenodd"})})}function jy({pid:r,exitCode:e,onClick:t}){const s=()=>e===null&&r===null?"Run code":e===null&&r!==null?"Running...":e!==null&&e===0?"Execution successful":e!==null&&e>0?`Execution failed with exit code ${e}`:"Run code";return oe.jsxs(tt.Button,{variant:"soft",onClick:t,"aria-label":s(),children:[e===null&&r===null&&oe.jsx(yy,{}),e===null&&r!==null&&oe.jsx("div",{className:"animate-spin",children:oe.jsx(_y,{})}),e!==null&&e===0&&oe.jsx(wy,{}),e!==null&&e>0&&oe.jsx(Sy,{exitCode:e})]})}function vf({cell:r}){const{saveState:e,runCodeCell:t}=Qr(),{getRenderer:s}=Fi(),[u,d]=Ae.useState(null),[a,o]=Ae.useState(null),c=Ae.useCallback(()=>{t(r)},[r,t]),i=Ae.useMemo(()=>{const n=Number(r.metadata[hr.Sequence]);return n?n.toString():" "},[r,u,a]);return oe.jsx("div",{children:oe.jsx(tt.Box,{className:"w-full p-2",children:oe.jsxs("div",{className:"flex justify-between items-top",children:[oe.jsxs("div",{className:"flex flex-col items-center",children:[oe.jsx(jy,{pid:u,exitCode:a,onClick:c}),oe.jsxs(tt.Text,{size:"2",className:"mt-1 p-2 font-bold text-gray-400 font-mono","data-testid":"sequence-label",children:["[",i,"]"]})]}),oe.jsxs(tt.Card,{className:"whitespace-nowrap overflow-hidden flex-1 ml-2",children:[oe.jsx(by,{id:r.refId,value:r.value,language:"shellscript",fontSize:ta.fontSize,fontFamily:ta.fontFamily,onChange:n=>{r.value=n,e()},onEnter:c},`editor-${r.refId}`),r.outputs.flatMap(n=>(n.items??[]).map(l=>{const h=s(l.mime);if(!h)return null;const m=h.component;return oe.jsx(m,{cell:r,onPid:d,onExitCode:o,...h.props},`${l.mime}-${r.refId}`)}))]})]})})})}function ra(){const{useColumns:r,addCodeCell:e}=Qr(),{settings:t}=Zr(),{actions:s}=r(),u=Ae.useRef(null),d=Ae.useRef(null);Ae.useEffect(()=>{var c,i;if(t.webApp.invertedOrder){(c=u.current)==null||c.scrollIntoView({behavior:"smooth"});return}(i=d.current)==null||i.scrollIntoView({behavior:"smooth"})},[s,t.webApp.invertedOrder]);const{registerRenderer:a,unregisterRenderer:o}=Fi();return Ae.useEffect(()=>(a(Jr.StatefulRunmeTerminal,{onCellUpdate:c=>{!c.languageId.endsWith("sh")&&c.languageId!==""||c.kind!==fr.CODE||c.outputs.length>0||(c.outputs=[vt.create(Ni,{items:[vt.create(Ts,{mime:Jr.StatefulRunmeTerminal,type:"Buffer",data:new Uint8Array})]})])},component:({cell:c,onPid:i,onExitCode:n})=>oe.jsx(mf,{cell:c,onPid:i,onExitCode:n},`console-${c.refId}`)}),()=>{o(Jr.StatefulRunmeTerminal)}),[a,o]),oe.jsxs("div",{className:"flex flex-col h-full",children:[oe.jsxs("div",{className:"flex items-center mb-2",children:[oe.jsx(tt.Text,{size:"5",weight:"bold",className:"pr-2",children:"Actions"}),oe.jsx(tt.Button,{variant:"ghost",size:"1",className:"cursor-pointer",onClick:e,"aria-label":"Add code cell",children:oe.jsx(xy,{})})]}),oe.jsxs(tt.ScrollArea,{type:"auto",scrollbars:"vertical",className:"flex-1 p-2",children:[oe.jsx("div",{ref:u}),s.map(c=>oe.jsx(vf,{cell:c},`action-${c.refId}`)),oe.jsx("div",{ref:d})]})]})}const gf=({role:r,children:e})=>{const t=r===Wr.USER?"self-end":"self-start",s=r===Wr.USER?"indigo":"gray";return oe.jsx(tt.Callout.Root,{highContrast:!0,color:s,className:`${t} max-w-[80%] break-words m-1`,children:oe.jsx(tt.Callout.Text,{children:e})})},Ey=({cell:r})=>oe.jsx(gf,{role:Wr.USER,children:r.value}),ky=({cell:r})=>oe.jsx(gf,{role:Wr.ASSISTANT,children:oe.jsx(Vf,{components:{code:({children:e,...t})=>oe.jsx("pre",{className:"whitespace-pre-wrap",children:oe.jsx("code",{...t,children:String(e).replace(/\n$/,"")})})},children:r.value})}),Iy=Ae.memo(({cell:r,isRecentCodeCell:e,onClick:t})=>{var i,n;const{runCodeCell:s}=Qr(),{settings:u}=Zr(),d=((n=(i=r.value)==null?void 0:i.split(/&&|;|\n|\\n/)[0])==null?void 0:n.substring(0,50))||"",a=()=>{t?t():s(r)},o=u.webApp.invertedOrder?"justify-end":"justify-start",c=oe.jsx("span",{className:"text-xs text-gray-400 p-2",children:"Press CTRL+ENTER to run"});return oe.jsxs("div",{className:`flex ${o} items-center h-full`,children:[e&&u.webApp.invertedOrder&&c,oe.jsxs("div",{className:"flex items-center m-1 p-2 bg-[#1e1e1e] rounded-md max-w-[60%] cursor-pointer",onClick:a,children:[oe.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"#d4d4d4",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:oe.jsx("polygon",{points:"5 3 19 12 5 21 5 3"})}),oe.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"#d4d4d4",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"ml-1",children:[oe.jsx("polyline",{points:"4 17 10 11 4 5"}),oe.jsx("line",{x1:"12",y1:"19",x2:"20",y2:"19"})]}),oe.jsx("span",{className:"text-sm text-[#d4d4d4] italic truncate max-w-4/5",children:d})]}),e&&!u.webApp.invertedOrder&&c]})},(r,e)=>r.cell.refId===e.cell.refId&&JSON.stringify(r.cell.value)===JSON.stringify(e.cell.value)&&r.isRecentCodeCell===e.isRecentCodeCell),Eu=({cell:r,isRecentCodeCell:e})=>{if(r.kind===fr.CODE)return oe.jsx(Iy,{cell:r,isRecentCodeCell:e},r.refId);switch(r.role){case Wr.USER:return oe.jsx(Ey,{cell:r});case Wr.ASSISTANT:return oe.jsx(ky,{cell:r});default:return null}},ku=()=>{const{useColumns:r,isTyping:e}=Qr(),{settings:t}=Zr(),{chat:s}=r(),u=Ae.useRef(null);Ae.useEffect(()=>{var c;t.webApp.invertedOrder||(c=u.current)==null||c.scrollIntoView({behavior:"smooth"})},[s,t.webApp.invertedOrder]);const d=t.webApp.invertedOrder?0:s.length-1,o=oe.jsx("div",{className:"flex justify-start items-center h-full",children:oe.jsx(Eu,{cell:my})});return oe.jsxs("div",{className:"overflow-y-clip p-1 flex flex-col whitespace-pre-wrap",children:[e&&t.webApp.invertedOrder&&o,s.map((c,i)=>oe.jsx(Eu,{cell:c,isRecentCodeCell:c.kind===fr.CODE&&i===d&&!e},i)),e&&!t.webApp.invertedOrder&&o,oe.jsx("div",{ref:u})]})},Iu=()=>{const{sendUserCell:r,isInputDisabled:e}=Qr(),[t,s]=Ae.useState(""),u=Ae.useRef(null);Ae.useEffect(()=>{var o;(o=u.current)==null||o.focus()},[]);const d=o=>{o.preventDefault(),t.trim()&&(r(t),s(""))},a=o=>{if(o.key==="Enter"&&!o.shiftKey){o.preventDefault();const c=o.currentTarget.form;c&&c.requestSubmit()}};return oe.jsx("form",{onSubmit:d,className:"flex w-full",children:oe.jsxs(tt.Flex,{className:"w-full flex flex-nowrap items-start gap-4 m-2",children:[oe.jsx(tt.TextArea,{name:"userInput",value:t,onChange:o=>s(o.target.value),onKeyDown:a,placeholder:"Enter your question",size:"3",className:"flex-grow min-w-0",ref:u,rows:2,style:{resize:"vertical"}}),oe.jsx(tt.Button,{type:"submit",disabled:e,children:oe.jsx(Cy,{})})]})})};function na(){const{useColumns:r,runCodeCell:e}=Qr(),{settings:t}=Zr(),{chat:s}=r(),u=Ae.useRef(null);Ae.useEffect(()=>{const a=c=>{if(c.ctrlKey&&c.key==="Enter"){const i=t.webApp.invertedOrder?s[0]:s[s.length-1];(i==null?void 0:i.kind)===fr.CODE&&e(i)}},o=u.current;if(o)return o.addEventListener("keydown",a),()=>o.removeEventListener("keydown",a)},[s,e,t.webApp.invertedOrder]);const d=t.webApp.invertedOrder?"flex-col":"flex-col-reverse";return oe.jsxs("div",{ref:u,className:"flex flex-col h-full",children:[oe.jsx(tt.Text,{size:"5",weight:"bold",className:"mb-2",children:"How can I help you?"}),oe.jsx(tt.ScrollArea,{type:"auto",scrollbars:"vertical",className:"flex-1 p-4",children:oe.jsx("div",{className:`flex ${d} h-full w-full`,children:t.webApp.invertedOrder?oe.jsxs(oe.Fragment,{children:[oe.jsx(Iu,{}),oe.jsx(ku,{})]}):oe.jsxs(oe.Fragment,{children:[oe.jsx(Iu,{}),oe.jsx(ku,{})]})})})]})}const bf=()=>{const{useColumns:r}=Qr(),{files:e}=r(),t=Ae.useRef(null),s=()=>{var a;(a=t.current)==null||a.scrollIntoView({behavior:"smooth"})},u=Ae.useMemo(()=>{let a=vt.create(Pn,{});return e.length>0&&(a=e[e.length-1]),a},[e]);Ae.useEffect(()=>{s()},[u]);const d=u.docResults.length>0;return oe.jsxs("div",{className:"flex flex-col h-full",children:[oe.jsx(tt.Text,{size:"5",weight:"bold",className:"mb-2",children:"Files"}),oe.jsx(tt.ScrollArea,{type:"auto",scrollbars:"vertical",className:"flex-1 pt-4",children:d?oe.jsxs("div",{className:"grow",children:[u.docResults.map(a=>oe.jsx("div",{className:"mb-2",children:oe.jsx(tt.Box,{p:"2",style:{borderRadius:"6px",border:"1px solid var(--gray-5)"},children:oe.jsx(tt.Text,{size:"2",weight:"medium",children:oe.jsx(tt.Link,{href:a.link,target:"_blank",className:"text-blue-500 hover:underline",children:a.fileName})})})},a.fileId)),oe.jsx("div",{ref:t,className:"h-1"})]}):oe.jsxs("div",{children:[oe.jsx("div",{children:"No search results yet"}),oe.jsx("div",{ref:t,className:"h-1"})]})})]})},Ty=yn("ChVnb29nbGUvcnBjL2NvZGUucHJvdG8SCmdvb2dsZS5ycGMqtwIKBENvZGUSBgoCT0sQABINCglDQU5DRUxMRUQQARILCgdVTktOT1dOEAISFAoQSU5WQUxJRF9BUkdVTUVOVBADEhUKEURFQURMSU5FX0VYQ0VFREVEEAQSDQoJTk9UX0ZPVU5EEAUSEgoOQUxSRUFEWV9FWElTVFMQBhIVChFQRVJNSVNTSU9OX0RFTklFRBAHEhMKD1VOQVVUSEVOVElDQVRFRBAQEhYKElJFU09VUkNFX0VYSEFVU1RFRBAIEhcKE0ZBSUxFRF9QUkVDT05ESVRJT04QCRILCgdBQk9SVEVEEAoSEAoMT1VUX09GX1JBTkdFEAsSEQoNVU5JTVBMRU1FTlRFRBAMEgwKCElOVEVSTkFMEA0SDwoLVU5BVkFJTEFCTEUQDhINCglEQVRBX0xPU1MQD0JYCg5jb20uZ29vZ2xlLnJwY0IJQ29kZVByb3RvUAFaM2dvb2dsZS5nb2xhbmcub3JnL2dlbnByb3RvL2dvb2dsZWFwaXMvcnBjL2NvZGU7Y29kZaICA1JQQ2IGcHJvdG8z"),Oy=yr(Ty,0),sa=_r(Oy);function yf(){const{runnerError:r}=Zr(),[e]=br.useSearchParams(),t=Ae.useMemo(()=>r&&!(r instanceof Error)?sa[r.code]??r.code:e.get("error"),[r,e]),s=Ae.useMemo(()=>r&&!(r instanceof Error)?r.message:e.get("error_description"),[r,e]),u=()=>{window.location.href="/oidc/login"};return oe.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-4",children:[t&&oe.jsxs(tt.Callout.Root,{color:"red",children:[oe.jsxs(tt.Callout.Text,{className:"font-bold",children:["Error: ",t]}),s&&oe.jsx(tt.Callout.Text,{children:s})]}),oe.jsx(tt.Button,{size:"4",onClick:u,className:"cursor-pointer",children:"Login"})]})}const _f=()=>oe.jsxs(tt.Container,{size:"3",style:{padding:"2rem",textAlign:"center"},children:[oe.jsx(tt.Heading,{size:"8",mb:"4",children:"404"}),oe.jsx(tt.Text,{size:"5",color:"gray",children:"Page not found"}),oe.jsx(tt.Text,{as:"p",mt:"4",children:"The page you're looking for doesn't exist or has been moved."}),oe.jsxs(tt.Text,{as:"p",mt:"4",children:["Click"," ",oe.jsx(tt.Link,{href:"/",underline:"always",children:"here"})," ","to go back home."]})]});function wf(){const r=br.useNavigate(),{settings:e,updateSettings:t,runnerError:s,defaultSettings:u}=Zr(),[d,a]=Ae.useState(!1),[o,c]=Ae.useState(e.agentEndpoint),[i,n]=Ae.useState(e.webApp.runner),[l,h]=Ae.useState(e.webApp.invertedOrder),m=()=>{t({agentEndpoint:o,webApp:{runner:i,reconnect:e.webApp.reconnect,invertedOrder:l}}),a(!0)};Ae.useEffect(()=>{d&&(a(!1),s&&r("/"))},[s,d,r]);const p=()=>{c(u.agentEndpoint),n(u.webApp.runner),h(u.webApp.invertedOrder)},f=Ae.useMemo(()=>{if(s&&!(!s||typeof s!="object"||!("message"in s)))return s.message},[s]),v=o!==e.agentEndpoint||i!==e.webApp.runner||l!==e.webApp.invertedOrder;return oe.jsxs(tt.Box,{className:"w-full mx-auto",children:[oe.jsx(tt.Text,{size:"5",weight:"bold",className:"mb-2",children:"Settings"}),oe.jsxs(tt.Box,{className:"mt-4",children:[oe.jsxs(tt.Flex,{direction:"column",gap:"4",children:[oe.jsxs(tt.Flex,{direction:"column",gap:"2",children:[oe.jsx(tt.Text,{size:"3",weight:"bold",children:"Agent Endpoint Configuration"}),oe.jsx(tt.Text,{size:"2",color:"gray",children:"Configure the endpoint URL for the AI agent. Changes will take effect after saving."}),oe.jsx(tt.TextArea,{size:"3",placeholder:"Enter AI endpoint URL",value:o,onChange:g=>c(g.target.value)})]}),oe.jsxs(tt.Flex,{direction:"column",gap:"2",children:[oe.jsx(tt.Text,{size:"3",weight:"bold",children:"Runner Endpoint Configuration"}),oe.jsx(tt.Text,{size:"2",color:"gray",children:"Configure the WebSocket endpoint URL for the runner. Changes will take effect after saving."}),s&&oe.jsx(tt.Callout.Root,{color:"red",children:oe.jsxs(tt.Callout.Text,{className:"font-bold",children:["Runner error",f?": "+f:""]})}),oe.jsx(tt.TextArea,{size:"3",placeholder:"Enter Runner WebSocket endpoint URL",value:i,onChange:g=>n(g.target.value)}),oe.jsx(tt.Text,{size:"2",color:"gray",children:"Revert will reset endpoints to the default values, including protocol http(s), based on the current page."})]}),oe.jsxs(tt.Flex,{direction:"column",gap:"2",children:[oe.jsx(tt.Text,{size:"3",weight:"bold",children:"User Experience Mode"}),oe.jsx(tt.Text,{as:"label",size:"2",children:oe.jsxs(tt.Flex,{gap:"2",children:["Document Mode",oe.jsx(tt.Switch,{checked:l,onCheckedChange:h}),"Console Mode"]})})]})]}),oe.jsxs(tt.Flex,{gap:"3",justify:"end",mt:"4",children:[oe.jsx(tt.Button,{size:"2",variant:"soft",onClick:()=>r("/"),children:"Back"}),oe.jsx(tt.Button,{size:"2",variant:"soft",onClick:p,children:"Revert"}),oe.jsx(tt.Button,{size:"2",onClick:m,disabled:!v,children:"Save"})]})]})]})}function Ay(r,e=[]){let t=[];function s(d,a){const o=kt.createContext(a),c=t.length;t=[...t,a];const i=l=>{var g;const{scope:h,children:m,...p}=l,f=((g=h==null?void 0:h[r])==null?void 0:g[c])||o,v=kt.useMemo(()=>p,Object.values(p));return oe.jsx(f.Provider,{value:v,children:m})};i.displayName=d+"Provider";function n(l,h){var f;const m=((f=h==null?void 0:h[r])==null?void 0:f[c])||o,p=kt.useContext(m);if(p)return p;if(a!==void 0)return a;throw new Error(`\`${l}\` must be used within \`${d}\``)}return[i,n]}const u=()=>{const d=t.map(a=>kt.createContext(a));return function(o){const c=(o==null?void 0:o[r])||d;return kt.useMemo(()=>({[`__scope${r}`]:{...o,[r]:c}}),[o,c])}};return u.scopeName=r,[s,Ry(u,...e)]}function Ry(...r){const e=r[0];if(r.length===1)return e;const t=()=>{const s=r.map(u=>({useScope:u(),scopeName:u.scopeName}));return function(d){const a=s.reduce((o,{useScope:c,scopeName:i})=>{const l=c(d)[`__scope${i}`];return{...o,...l}},{});return kt.useMemo(()=>({[`__scope${e.scopeName}`]:a}),[a])}};return t.scopeName=e.scopeName,t}function Ly(r){const e=kt.useRef(r);return kt.useEffect(()=>{e.current=r}),kt.useMemo(()=>(...t)=>{var s;return(s=e.current)==null?void 0:s.call(e,...t)},[])}var ia=globalThis!=null&&globalThis.document?kt.useLayoutEffect:()=>{};function Tu(r,e){if(typeof r=="function")return r(e);r!=null&&(r.current=e)}function Ny(...r){return e=>{let t=!1;const s=r.map(u=>{const d=Tu(u,e);return!t&&typeof d=="function"&&(t=!0),d});if(t)return()=>{for(let u=0;u<s.length;u++){const d=s[u];typeof d=="function"?d():Tu(r[u],null)}}}}function Py(r){const e=Dy(r),t=kt.forwardRef((s,u)=>{const{children:d,...a}=s,o=kt.Children.toArray(d),c=o.find(By);if(c){const i=c.props.children,n=o.map(l=>l===c?kt.Children.count(i)>1?kt.Children.only(null):kt.isValidElement(i)?i.props.children:null:l);return oe.jsx(e,{...a,ref:u,children:kt.isValidElement(i)?kt.cloneElement(i,void 0,n):null})}return oe.jsx(e,{...a,ref:u,children:d})});return t.displayName=`${r}.Slot`,t}function Dy(r){const e=kt.forwardRef((t,s)=>{const{children:u,...d}=t;if(kt.isValidElement(u)){const a=Fy(u),o=$y(d,u.props);return u.type!==kt.Fragment&&(o.ref=s?Ny(s,a):a),kt.cloneElement(u,o)}return kt.Children.count(u)>1?kt.Children.only(null):null});return e.displayName=`${r}.SlotClone`,e}var My=Symbol("radix.slottable");function By(r){return kt.isValidElement(r)&&typeof r.type=="function"&&"__radixId"in r.type&&r.type.__radixId===My}function $y(r,e){const t={...e};for(const s in e){const u=r[s],d=e[s];/^on[A-Z]/.test(s)?u&&d?t[s]=(...o)=>{const c=d(...o);return u(...o),c}:u&&(t[s]=u):s==="style"?t[s]={...u,...d}:s==="className"&&(t[s]=[u,d].filter(Boolean).join(" "))}return{...r,...t}}function Fy(r){var s,u;let e=(s=Object.getOwnPropertyDescriptor(r.props,"ref"))==null?void 0:s.get,t=e&&"isReactWarning"in e&&e.isReactWarning;return t?r.ref:(e=(u=Object.getOwnPropertyDescriptor(r,"ref"))==null?void 0:u.get,t=e&&"isReactWarning"in e&&e.isReactWarning,t?r.props.ref:r.props.ref||r.ref)}var Vy=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],el=Vy.reduce((r,e)=>{const t=Py(`Primitive.${e}`),s=kt.forwardRef((u,d)=>{const{asChild:a,...o}=u,c=a?t:e;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),oe.jsx(c,{...o,ref:d})});return s.displayName=`Primitive.${e}`,{...r,[e]:s}},{}),ui={exports:{}},Ao={};/**
|
|
6550
6550
|
* @license React
|
|
6551
6551
|
* use-sync-external-store-shim.production.js
|
|
@@ -69269,9 +69269,9 @@ const gf = Fi(
|
|
|
69269
69269
|
const f = window.location.hostname === "localhost", v = window.location.protocol === "http:", g = window.location.port === "4173" || window.location.port === "5173", b = f && v && g;
|
|
69270
69270
|
return {
|
|
69271
69271
|
requireAuth: t ?? !1,
|
|
69272
|
-
agentEndpoint: e ?? b ? "http://localhost:8080" : window.location.origin,
|
|
69272
|
+
agentEndpoint: e ?? (b ? "http://localhost:8080" : window.location.origin),
|
|
69273
69273
|
webApp: {
|
|
69274
|
-
runner: (s == null ? void 0 : s.runner) ?? b ? "ws://localhost:8080/ws" : `${v ? "ws:" : "wss:"}//${window.location.host}/ws
|
|
69274
|
+
runner: (s == null ? void 0 : s.runner) ?? (b ? "ws://localhost:8080/ws" : `${v ? "ws:" : "wss:"}//${window.location.host}/ws`),
|
|
69275
69275
|
reconnect: (s == null ? void 0 : s.reconnect) ?? !0,
|
|
69276
69276
|
invertedOrder: (s == null ? void 0 : s.invertedOrder) ?? !1
|
|
69277
69277
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@runmedev/react-components",
|
|
3
|
-
"version": "3.15.
|
|
3
|
+
"version": "3.15.9",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"private": false,
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"dist"
|
|
20
20
|
],
|
|
21
21
|
"devDependencies": {
|
|
22
|
-
"@runmedev/react-console": "3.15.
|
|
22
|
+
"@runmedev/react-console": "3.15.6"
|
|
23
23
|
},
|
|
24
24
|
"peerDependencies": {
|
|
25
25
|
"js-cookie": "^3.0.5",
|