import React from"react";import ReactDOM from"react-dom";import{Task}from"../Task.js";function update(e,t){let r=!1;if(null!=t)for(const i in t)e[i]!==t[i]&&(e[i]=t[i],r=!0);return r}function AppActivity(){const i=this.execute;this.execute=function(e,r){var t=r.ambient.trivia;return this.app=t.app,this.map=t.map,this.site=t.site,this.widget=t.widget,this.FormRenderer=t.FormRenderer,this.completion=r.ambient.completion,this.execute=i,this.createRenderer=()=>{let e=this.renderer;var t;return void 0===e&&(e=this.renderer=this.FormRenderer.createCustom(),e.state=r.ambient,t=()=>e.dispose(),this.completion.then(t,t)),this.renderer||(this.renderer=this.FormRenderer.createCustom())},i.apply(this,arguments)}}AppActivity.prototype.createRenderer=function(){return null},AppActivity.prototype.applyProps=function(e){const t=this.createRenderer();if(update(this.showProps||(this.showProps={}),e)){const e=this.showProps;t.form={defaults:{container:e.container},elements:{header:{type:"Header",section:"header",title:{markdown:e.title},value:e.icon}}},t.invalidate()}},AppActivity.prototype.show=function(e){return this.applyProps(e),this.createRenderer().show()},AppActivity.prototype.spin=function(e){return this.applyProps(e),this.createRenderer().spin()},AppActivity.prototype.spinNoBlock=function(e){return this.applyProps(e),this.createRenderer().spinNoBlock()},AppActivity.prototype.hide=function(){return this.createRenderer().hide()},AppActivity.prototype.render=async function(t,i){const n=this.createRenderer().container;if("function"!=typeof t)return React.isValidElement(t)?new Task(function(e){ReactDOM.render(t,n,e)}):n;{const o=this,s=t;return new Task(async function(e,t){const r=e.bind(void 0);r.reject=t.bind(void 0),ReactDOM.render(await s.call(o,r,i),n)})}};export{React,AppActivity};