"use strict";(self.webpackChunk_cocalc_static=self.webpackChunk_cocalc_static||[]).push([[2081],{12081:(t,e,n)=>{n.r(e),n.d(e,{Actions:()=>i,CourseEditorActions:()=>i});var o,s=n(55696),r=n(52743),c=(o=function(t,e){return o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},o(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function n(){this.constructor=t}o(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}),i=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.doctype="none",e}return c(e,t),e.prototype._raw_default_frame_tree=function(){return{type:"course_students"}},e.prototype._init2=function(){this.init_course_actions_and_store(),this.init_changes_state()},e.prototype.close=function(){this.close_course_actions_and_store(),t.prototype.close.call(this)},e.prototype.init_changes_state=function(){var t=this,e=this.course_actions.syncdb;e.on("has-uncommitted-changes",(function(e){return t.setState({has_uncommitted_changes:e})})),e.on("has-unsaved-changes",(function(e){t.setState({has_unsaved_changes:e})}))},e.prototype.init_course_actions_and_store=function(){this.course_actions=(0,r.LM)({redux:this.redux,path:this.path,project_id:this.project_id})},e.prototype.close_course_actions_and_store=function(){(0,r.ex)({redux:this.redux,path:this.path,project_id:this.project_id})},e.prototype.save=function(t){return void 0===t&&(t=!0),e=this,n=void 0,s=function(){var t;return function(t,e){var n,o,s,r,c={label:0,sent:function(){if(1&s[0])throw s[1];return s[1]},trys:[],ops:[]};return r={next:i(0),throw:i(1),return:i(2)},"function"==typeof Symbol&&(r[Symbol.iterator]=function(){return this}),r;function i(r){return function(i){return function(r){if(n)throw new TypeError("Generator is already executing.");for(;c;)try{if(n=1,o&&(s=2&r[0]?o.return:r[0]?o.throw||((s=o.return)&&s.call(o),0):o.next)&&!(s=s.call(o,r[1])).done)return s;switch(o=0,s&&(r=[2&r[0],s.value]),r[0]){case 0:case 1:s=r;break;case 4:return c.label++,{value:r[1],done:!1};case 5:c.label++,o=r[1],r=[0];continue;case 7:r=c.ops.pop(),c.trys.pop();continue;default:if(!((s=(s=c.trys).length>0&&s[s.length-1])||6!==r[0]&&2!==r[0])){c=0;continue}if(3===r[0]&&(!s||r[1]>s[0]&&r[1]<s[3])){c.label=r[1];break}if(6===r[0]&&c.label<s[1]){c.label=s[1],s=r;break}if(s&&c.label<s[2]){c.label=s[2],c.ops.push(r);break}s[2]&&c.ops.pop(),c.trys.pop();continue}r=e.call(t,c)}catch(t){r=[6,t],o=0}finally{n=s=0}if(5&r[0])throw r[1];return{value:r[0]?r[1]:void 0,done:!0}}([r,i])}}}(this,(function(e){switch(e.label){case 0:if(null==this.course_actions||null==this.course_actions.syncdb||!this.course_actions.syncdb.has_unsaved_changes())return[2];e.label=1;case 1:return e.trys.push([1,3,4,5]),this.setState({is_saving:!0}),[4,this.course_actions.save()];case 2:return e.sent(),[3,5];case 3:return t=e.sent(),console.warn("save_to_disk",this.path,"ERROR",t),"closed"==this._state?[2]:(this.set_error("error saving file to disk -- ".concat(t)),[3,5]);case 4:return this.setState({is_saving:!1}),[7];case 5:return[2]}}))},new((o=Promise)||(o=Promise))((function(t,r){function c(t){try{a(s.next(t))}catch(t){r(t)}}function i(t){try{a(s.throw(t))}catch(t){r(t)}}function a(e){var n;e.done?t(e.value):(n=e.value,n instanceof o?n:new o((function(t){t(n)}))).then(c,i)}a((s=s.apply(e,n||[])).next())}));var e,n,o,s},e.prototype.exit_undo_mode=function(){this.course_actions.syncdb.exit_undo_mode()},e.prototype.undo=function(t){this.course_actions.syncdb.undo(),this.course_actions.syncdb.commit()},e.prototype.redo=function(t){this.course_actions.syncdb.redo(),this.course_actions.syncdb.commit()},e}(s.e)}}]);