"use strict";(self.webpackChunk_cocalc_static=self.webpackChunk_cocalc_static||[]).push([[3843],{18737:(e,t,n)=>{n.d(t,{l:()=>i,v:()=>c});var r=n(26131),o=n(89368),a=n(62799);function i(e){var t=(0,r.path_split)(e),n=(0,r.separate_file_extension)(t.tail);return{directory:t.head,base:n.name,filename:t.tail}}function c(e,t){var n=(0,r.encode_path)(t);return(0,o.join)(a.appBasePath,e,"raw",n)}},5222:(e,t,n)=>{n.r(t),n.d(t,{Editor:()=>b});var r=n(96887),o=n(26131),a=n(67557),i=n(21716),c=n(53059),l=n(83798),s="".concat(900,"px"),u=n(35115),f=n(83444),d=function(){return d=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},d.apply(this,arguments)},p=n(33026),v=n(37685),h=n(4930),m=n(43774),_=n(44990),y={cm:{short:"Code",name:"Source Code",icon:"code",component:v.w,buttons:(0,o.set)(["print","decrease_font_size","increase_font_size","save","time_travel","replace","find","goto_line","cut","paste","copy","undo","redo","format"])},iframe:{short:"HTML",name:"HTML IFrame",icon:"compass",component:p.w,buttons:(0,o.set)(["print","save","time_travel","reload","decrease_font_size","increase_font_size","set_zoom"])},preview:{short:"Preview",name:"Sanitized Preview",icon:"html5",component:function(e){var t=e.id,n=e.actions,r=e.font_size,o=e.value,p=e.editor_state,v=(0,f.B)(),h=l.React.useRef(null);function m(e){return t=this,n=void 0,o=function(){var t;return function(e,t){var n,r,o,a,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function c(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return i.label++,{value:a[1],done:!1};case 5:i.label++,r=a[1],a=[0];continue;case 7:a=i.ops.pop(),i.trys.pop();continue;default:if(!((o=(o=i.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){i=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){i.label=a[1];break}if(6===a[0]&&i.label<o[1]){i.label=o[1],o=a;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(a);break}o[2]&&i.ops.pop(),i.trys.pop();continue}a=t.call(e,i)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}}(this,(function(n){switch(n.label){case 0:return e?[4,(0,i.delay)(e)]:[3,2];case 1:n.sent(),n.label=2;case 2:return void 0!==(t=p.get("scroll"))&&$(l.ReactDOM.findDOMNode(h.current)).scrollTop(t),[2]}}))},new((r=Promise)||(r=Promise))((function(e,a){function i(e){try{l(o.next(e))}catch(e){a(e)}}function c(e){try{l(o.throw(e))}catch(e){a(e)}}function l(t){var n;t.done?e(t.value):(n=t.value,n instanceof r?n:new r((function(e){e(n)}))).then(i,c)}l((o=o.apply(t,n||[])).next())}));var t,n,r,o}return l.React.useEffect((function(){var e,t;try{for(var n=function(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}([0,200,500]),r=n.next();!r.done;r=n.next())m(r.value)}catch(t){e={error:t}}finally{try{r&&!r.done&&(t=n.return)&&t.call(n)}finally{if(e)throw e.error}}}),[]),(0,a.jsx)("div",d({style:{overflowY:"auto",width:"100%",fontSize:"".concat(r,"px")},ref:h,onScroll:(0,c.throttle)((function(){return function(){var e=l.ReactDOM.findDOMNode(h.current);if(null!=e){var r=$(e).scrollTop();n.save_editor_state(t,{scroll:r})}}()}),250),className:"cocalc-editor-div"},{children:(0,a.jsx)("div",d({style:{maxWidth:s,margin:"10px auto",padding:"0 10px"}},{children:(0,a.jsx)(f.s.Provider,d({value:d(d({},v),{noSanitize:!1})},{children:(0,a.jsx)(u.Z,{value:null!=o?o:""})}))}))}))},buttons:(0,o.set)(["print","decrease_font_size","increase_font_size","set_zoom","save","time_travel","reload"])},terminal:m.terminal,settings:h.H,time_travel:_.Y},b=(0,r.J)({format_bar:!0,editor_spec:y,display_name:"HTMLEditor"})}}]);