PageSourceSearch

https://codecombat.com/javascripts/chunks/play-962e61337b9e579186b4.bundle.js

js codecombat.com collected 2026-09-24 08:31:18 UTC 422,933 bytes, 2 lines download raw bytes

1(self.webpackChunkcodecombat=self.webpackChunkcodecombat||[]).push([[7347],{572269:(e,t,o)=>{"use strict";var n=o(630426);e.exports={name:"flat-layout",template:o(15920)(),components:{"page-errors":n},computed:Vuex.mapState({errors:function(e){return e.pageErrors}})}},630426:(e,t,o)=>{"use strict";e.exports={name:"page-errors",template:o(110637)(),computed:_.assign(Vuex.mapState({error:function(e){return _.first(e.pageErrors)}}),Vuex.mapGetters("me",["isAnonymous"]))}},489886:(e,t,o)=>{"use strict";function n(e){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},n(e)}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function s(e,t){for(var o=0;o<t.length;o++){var n=t[o];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,r(n.key),n)}}function r(e){var t=function(e,t){if("object"!=n(e)||!e)return e;var o=e[Symbol.toPrimitive];if(void 0!==o){var i=o.call(e,t);if("object"!=n(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e,"string");return"symbol"==n(t)?t:t+""}function a(e,t,o){return t=c(t),function(e,t){if(t&&("object"==n(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(e,l()?Reflect.construct(t,o||[],c(e).constructor):t.apply(e,o))}function l(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(l=function(){return!!e})()}function c(e){return c=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},c(e)}function u(e,t){return u=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},u(e,t)}var d,h=o(246709);e.exports=((d=function(e){function t(){return i(this,t),a(this,t,arguments)}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&u(e,t)}(t,e),n=t,r=[{key:"initClass",value:function(){this.className="Mandate",this.schema=o(699794),this.prototype.urlRoot="/db/mandate"}}],null&&s(n.prototype,null),r&&s(n,r),Object.defineProperty(n,"prototype",{writable:!1}),n;var n,r}(h)).initClass(),d)},770431:(e,t,o)=>{"use strict";function n(e){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},n(e)}var i=r(o(246709)),s=r(o(735471));function r(e){return e&&e.__esModule?e:{default:e}}function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function l(e,t,o){return t=u(t),function(e,t){if(t&&("object"==n(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(e,c()?Reflect.construct(t,o||[],u(e).constructor):t.apply(e,o))}function c(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(c=function(){return!!e})()}function u(e){return u=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},u(e)}function d(e,t){return d=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},d(e,t)}var h=function(e){function t(){return a(this,t),l(this,t,arguments)}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&d(e,t)}(t,e),o=t,Object.defineProperty(o,"prototype",{writable:!1}),o;var o}(i.default);h.className="OAuth2Identity",h.schema=s.default,h.urlRoot="/db/oauth2identity",h.prototype.urlRoot="/db/oauth2identity",e.exports=h},699794:(e,t,o)=>{"use strict";var n,i=o(975434);e.exports=n={type:"object",additionalProperties:!1,default:{simulationThroughputRatio:1,sessionSaveDelay:{registered:{min:4,max:10},anonymous:{min:5,max:15}}},properties:{simulationThroughputRatio:{name:"Simulation Throughput Ratio",description:"0-1 fraction of requests for a match to simulate that should be granted.",type:"number",minimum:0,maximum:1},sessionSaveDelay:{name:"Session Save Delay",description:"How often we save level sessions after code changes--min and max wait in seconds.",type:"object",properties:{registered:{description:"How often to save for registered players.",type:"object",additionalProperties:!1,requiredProperties:["min","max"],properties:{min:{type:"number",minimum:1,exclusiveMinimum:!0,format:"seconds"},max:{type:"number",minimum:5,exclusiveMinimum:!0,format:"seconds"}}},anonymous:{description:"How often to save for anonymous players.",type:"object",additionalProperties:!1,requiredProperties:["min","max"],properties:{min:{type:"number",minimum:1,exclusiveMinimum:!0,format:"seconds"},max:{type:"number",minimum:5,exclusiveMinimum:!0,format:"seconds"}}}}},latestAnnouncement:i.int(),currentTournament:i.array({description:"The arrays of the current active tournament, if any."},i.object({},{level:"string",courseInstanceID:i.objectId(),startAt:"integer",endAt:"integer",name:"string"})),tournamentOnlyLevels:i.array({description:"levels only accessible during tournament with specific course instance id"},"string"),experimentProbabilities:{type:"object",description:"Mapping of experiment names to experimental values and their probabilities, like `{m7: {control: 0.75, experiment: 0.25}}`",additionalProperties:{type:"object",description:"Mapping of experimental values to their probabilities, like `{control: 0.75, experiment: 0.25}
1`",additionalProperties:i.pct({description:"Probability of being assigned to this experiment value"})}}}},i.extendBasicProperties(n,"Mandate")},735471:(e,t,o)=>{"use strict";var n=o(975434),i=n.object({description:"An OAuth2 Identity",title:"OAuth2 Identity",required:["provider"]});_.extend(i.properties,{provider:{type:"string"},providerId:n.objectId({description:"The identifier of the user on the OAuth2 provider"}),ownerID:n.objectId(),token:{description:"A single OAuth identity",type:"object",properties:{access_token:{type:"string",description:"The access token for the user"},refresh_token:{type:"string",description:"The refresh token for the user"},token_type:{type:"string",description:"The type of token"},expires_in:{type:"integer",description:"The number of seconds until the token expires"},id_token:{type:"string",description:"The id token for the user"},scope:{type:"string",description:"The scope of the token"},expires_at:{type:n.date(),description:"The time at which the token expires"}}},profile:{type:"object",description:"The profile info of the user on the OAuth2 provider"},identifier:{type:"string",description:"The identifier of the user on the OAuth2 provider"}}),n.extendBasicProperties(i,"oauth2identity"),e.exports=i},501241:(e,t,o)=>{"use strict";var n,i=o(619755);function s(e){return s="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},s(e)}function r(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var o=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var n,i,s,r,a=[],l=!0,c=!1;try{if(s=(o=o.call(e)).next,0===t){if(Object(o)!==o)return;l=!1}else for(;!(l=(n=s.call(o)).done)&&(a.push(n.value),a.length!==t);l=!0);}catch(e){c=!0,i=e}finally{try{if(!l&&null!=o.return&&(r=o.return(),Object(r)!==r))return}finally{if(c)throw i}}return a}}(e,t)||function(e,t){if(e){if("string"==typeof e)return a(e,t);var o={}.toString.call(e).slice(8,-1);return"Object"===o&&e.constructor&&(o=e.constructor.name),"Map"===o||"Set"===o?Array.from(e):"Arguments"===o||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(o)?a(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function a(e,t){(null==t||t>e.length)&&(t=e.length);for(var o=0,n=Array(t);o<t;o++)n[o]=e[o];return n}function l(e,t){for(var o=0;o<t.length;o++){var n=t[o];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,c(n.key),n)}}function c(e){var t=function(e,t){if("object"!=s(e)||!e)return e;var o=e[Symbol.toPrimitive];if(void 0!==o){var n=o.call(e,t);if("object"!=s(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e,"string");return"symbol"==s(t)?t:t+""}function u(e,t,o){return t=g(t),function(e,t){if(t&&("object"==s(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(e,d()?Reflect.construct(t,o||[],g(e).constructor):t.apply(e,o))}function d(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(d=function(){return!!e})()}function h(){return h="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(e,t,o){var n=p(e,t);if(n){var i=Object.getOwnPropertyDescriptor(n,t);return i.get?i.get.call(arguments.length<3?e:o):i.value}},h.apply(null,arguments)}function p(e,t){for(;!{}.hasOwnProperty.call(e,t)&&null!==(e=g(e)););return e}function g(e){return g=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},g(e)}function v(e,t){return v=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},v(e,t)}o(206650);var m=o(976911),f=o(712256),y=o(28045).me,b=o(34088),w=o(299498),k=o(58445),S=o(409285),C=o(486842),x=o(244769),T=o(766230),P=o(847504),L=o(105950),M=o(367906),I=o(869501),D=o(778431),B=o(815117),A=o(225976),E=o(576572),R=o(322417),O=o(662915),V=o(920658);function $(e,t){return null!=e?t(e):void 0}o(830356),e.exports=((n=function(e){function t(e,o){var n;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),(n=u(this,t,[e])).onSupermodelLoadedOne=n.onSupermodelLoadedOne.bind(n),n.saveScreenshot=n.saveScreenshot.bind(n),n.levelID=o,n.isEditorPreview=w.getQueryVariable("dev"),n.sessionOne=w.getQueryVariable("session-one"),n.sessionTwo=w.getQueryVariable("session-two"),n.tournament=w.getQueryVariable("tournament"),e.spectateSessions&&(n.sessionOne=e.spectateSessions.sessionOne,n.sessionTwo=e.spectateSessions.sessionTwo),n.isEditorPreview?(n.supermodel.shouldSaveBackups=function(e){return["Level","LevelComponent","LevelSystem","ThangType"].includes(e.constructor.className)},setTimeout((function(){if(!n.levelLoader)return"function"==typeof n.loadRandomSessions?n.loadRandomSessions():void 0}),100)):n.loadRandomSessions(),n}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&v(e,t)}(t,e),o=t,n=[{key:"loadRandomSessions",value:function(){var e=this;return this.sessionOne&&this.sessionTwo?this.load():this.fetchRandomSessionPair((function(t,o){return null!=t?console.log("There was an error fetching the random session pair: ".concat(o)):(e.setSessions(o[0]._id,o[1]._id),e.load())}))}},{key:"setLevel",value:function(e,t){this.level=e,this.supermodel=t;var o=this.level.serialize({supermodel:this.supermodel,session:this.session,otherSession:this.otherSession,headless:!1,sessionless:!1});return null!=this.god&&this.god.setLevel(o),this.world?this.world.loadFromLevel(o,!1):this.load()}},{key:"load",value:function(){this.levelLoader=new T({supermodel:this.supermodel,levelID:this.levelID,sessionID:this.sessionOne,opponentSessionID:this.sessionTwo,tournament:this.tournament,spectateMode:!0,team:w.getQueryVariable("team")}),this.god=new S({maxAngels:1,spectate:!0})}},{key:"getRenderData",value:function(){var e=h(g(t.prototype),"getRenderData",this).call(this);return e.world=this.world,e}},{key:"afterRender",value:function(){return"function"==typeof window.onPlayLevelViewLoaded&&window.onPlayLevelViewLoaded(this),this.insertSubView(this.loadingView=new I({autoUnveil:!0,level:null!=(null!=this.levelLoader?this.levelLoader.level:void 0)?null!=this.levelLoader?this.levelLoader.level:void 0:this.level})),this.$el.find("#level-done-button").hide(),h(g(t.prototype),"afterRe
1nder",this).call(this),i("body").addClass("is-playing")}},{key:"onLoaded",value:function(){var e=this;return _.defer((function(){return e.onLevelLoaderLoaded()}))}},{key:"onLevelLoaderLoaded",value:function(){this.grabLevelLoaderData();var e="humans";return this.loadOpponentTeam(e),this.god.setLevel(this.level.serialize({supermodel:this.supermodel,session:this.session,otherSession:this.otherSession,headless:!1,sessionless:!1})),this.god.setLevelSessionIDs(this.otherSession?[this.session.id,this.otherSession.id]:[this.session.id]),this.god.setWorldClassMap(this.world.classMap),this.setTeam(e),this.initSurface(),this.initGoalManager(),this.initScriptManager(),this.insertSubviews(),this.initVolume(),this.initSpectateCode(),this.originalSessionState=i.extend(!0,{},this.session.get("state")),this.register(),this.controlBar.setBus(this.bus),this.surface.showLevel()}},{key:"grabLevelLoaderData",value:function(){this.session=this.levelLoader.session,this.world=this.levelLoader.world,this.level=this.levelLoader.level,this.otherSession=this.levelLoader.opponentSession,this.levelLoader.destroy(),this.levelLoader=null}},{key:"loadOpponentTeam",value:function(e){e!==this.session.get("team")&&console.error("Team mismatch. Expected session one to be '".concat(e,"'. Got '").concat(this.session.get("team"),"'"));var t=[];for(var o in w.teamSpells){var n=w.teamSpells[o];o!==e&&e&&(t=t.concat(n))}for(var i=(null!=this.otherSession?this.otherSession.get("code"):void 0)||{},s=this.session.get("code")||{},a=0,l=Array.from(t);a<l.length;a++){var c,u=l[a],d=r(Array.from(u.split("/")),2);c=d[0],u=d[1];var h=null!=i[c]?i[c][u]:void 0;null==s[c]&&(s[c]={}),h?s[c][u]=h:delete s[c][u]}return this.session.set("code",s)}},{key:"onLevelStarted",value:function(e){var t=this;return _.delay((function(){return null!=t.loadingView&&t.loadingView.startUnveiling(),null!=t.loadingView?t.loadingView.unveil(!0):void 0}),1e3)}},{key:"onLoadingViewUnveiled",value:function(e){return Backbone.Mediator.publish("level:set-playing",{playing:!1}),Backbone.Mediator.publish("level:set-time",{time:1})}},{key:"onSupermodelLoadedOne",value:function(){return null==this.modelsLoaded&&(this.modelsLoaded=0),this.modelsLoaded+=1,this.updateInitString()}},{key:"updateInitString",value:function(){if(!this.surface){null==this.modelsLoaded&&(this.modelsLoaded=0);var e=this.$el.find("#surface")[0],t=e.getContext("2d");return t.font="20px Georgia",t.clearRect(0,0,e.width,e.height),t.fillText("Loaded ".concat(this.modelsLoaded," thingies"),50,50)}}},{key:"insertSubviews",value:function(){var e;this.insertSubView(this.tome=new D({levelID:this.levelID,session:this.session,otherSession:this.otherSession,thangs:this.world.thangs,supermodel:this.supermodel,spectateView:!0,level:this.level,god:this.god})),this.insertSubView(new E({session:this.session,level:this.level}));var t=(e=this.level.get("slug"),["wakka-maul","cross-bones"].includes(e));return t||this.insertSubView(new R({})),this.insertSubView(new B({level:this.level})),this.level.isLadder()&&this.insertSubView(new O({level:this.level,session:this.session,otherSession:this.otherSession,supermodel:this.supermodel,thangs:this.world.thangs,showsGold:t})),this.insertSubView(this.controlBar=new A({worldName:w.i18n(this.level.attributes,"name"),session:this.session,level:this.level,supermodel:this.supermodel,spectateGame:!0}))}},{key:"onInfiniteLoop",value:function(e){if(e.firstWorld&&e.god===this.god)return this.openModalView(new V({nonUserCodeProblem:e.nonUserCodeProblem,problem:e.problem,timedOut:e.timedOut})),null!=window.tracker?window.tracker.trackEvent("Saw Initial Infinite Loop",{level:this.world.name,label:this.world.name}):void 0}},{key:"initSurface",value:function(){var e=this,t=i("canvas#webgl-surface",this.$el),o=i("canvas#normal-surface",this.$el);this.surface=new k(this.world,o,t,{thangTypes:this.supermodel.getModels(b),spectateGame:!0,playerNames:this.findPlayerNames(),levelType:this.level.get("type",!0)});var n=this.world.getBounds(),s=[{x:n.left,y:n.top},{x:n.right,y:n.bottom}];return this.surface.camera.setBounds(s),_.delay((function(){return null!=e.surface?e.surface.camera.zoomTo({x:(n.right-n.left)/2,y:(n.top-n.bottom)/2},.1,0):void 0}),4e3)}},{key:"findPlayerNames",value:function(){for(var e={},t=0,o=[this.session,this.otherSession];t<o.length;t++){var n=o[t];(null!=n?n.get("team"):void 0)&&(e[n.get("team")]=w.getCorrectName(n))}return e}},{key:"initGoalManager",value:function(){return this.goalManager=new C(this.world,this.level.get("goals")),this.god.setGoalManager(this.goalManager)}},{key:"initScriptManager",value:function(){var e;return this.world.scripts?e=_.reject(this.world.scripts,(function(e){return!/(Set Camera Boundaries|Introduction)/.test(e.id)})):(console.log("World scripts don't exist!"),e=[]),this.scriptManager=new x({scripts:e,view:this,session:this.session}),this.scriptManager.loadFromSession()}},{key:"initVolume",value:function(){var e=y.get("volume");return null==e&&(e=1),Backbone.Mediator.publish("level:set-volume",{volume:e})}},{key:"initSpectateCode",value:function(){var e=this,t=null!=this.session.get("submittedCode")&&null!=this.otherSession.get("submittedCode");if(!(y.isAdmin()||y.activeProducts("esports").length&&t))return this.$el.find(".spectate-code").remove();this.editors={};for(var o=function(){var t,o,s=i[n],r="humans"===s?e.session:e.otherSession;e.$el.find(".spectate-code.team-"+s+" .programming-language").text(w.capitalLanguages[r.get("
1codeLanguage")]);var a=e.editors[s]=window.ace.edit(e.$el.find(".spectate-code.team-"+s+" .ace")[0]),l=a.getSession();l.setMode(M.aceEditModes[r.get("submittedCodeLanguage")]),l.setWrapLimitRange(null),l.setUseWrapMode(!1),l.setNewLineMode("unix"),l.setUseSoftTabs(!0),a.setFontSize("10px"),a.setTheme("ace/theme/textmate"),a.setDisplayIndentGuides(!1),a.setShowPrintMargin(!1),a.setShowInvisibles(!1),a.setAnimatedScroll(!0),a.setShowFoldWidgets(!0),a.$blockScrolling=1/0,a.setReadOnly(!0);var c=e.level.isType("ladder")?"humans":null!=(t=r.get("team"))?t:s;a.setValue(null!=(o=$($(r.get("submittedCode"),(function(e){return e["hero-placeholder"+("ogres"===c?"-1":"")]})),(function(e){return e.plan})))?o:""),a.clearSelection()},n=0,i=["humans","ogres"];n<i.length;n++)o();return this.$el.find(".spectate-code").addClass("shown"),this.$el.addClass("showing-code")}},{key:"onMouseEnterSpectateCode",value:function(e){var t=i(e.target).closest(".spectate-code").hasClass("team-humans")?"humans":"ogres";return this.editors[t].setFontSize("16px")}},{key:"onMouseLeaveSpectateCode",value:function(e){var t=i(e.target).closest(".spectate-code").hasClass("team-humans")?"humans":"ogres";return this.editors[t].setFontSize("10px")}},{key:"register",value:function(){}},{key:"onSessionWillSave",value:function(e){return console.warn("Session is saving but shouldn't save!!!!!!!")}},{key:"saveScreenshot",value:function(e){var t;if(t=null!=this.surface?this.surface.screenshot():void 0)return e.save({screenshot:t},{patch:!0,type:"PUT"})}},{key:"setTeam",value:function(e){return _.isString(e)||(e=null!=e?e.team:void 0),null==e&&(e="humans"),y.team=e,Backbone.Mediator.publish("level:team-set",{team:e})}},{key:"onNewWorld",value:function(e){var t=this;if(!this.headless){var o=this.world.scripts;this.world=e.world,this.world.scripts=o;var n=this.supermodel.getModels(b),i=null!=this.lastWorldFramesLoaded?this.lastWorldFramesLoaded:0;return this.world.frames.length===this.world.totalFrames?(this.lastWorldFramesLoaded=0,!1!==w.getQueryVariable("autoplay")&&Backbone.Mediator.publish("level:set-playing",{playing:!0})):this.lastWorldFramesLoaded=this.world.frames.length,function(){for(var e=[],o=function(){var t=r(a[s],2),o=t[0],i=t[1],l=_.find(n,(function(e){return e.get("name")===o})),c=P.soundForDialogue(i,l.get("soundTriggers"));return l&&c?void e.push(P.preloadSoundReference(c)):0},s=0,a=Array.from(t.world.thangDialogueSounds(i));s<a.length;s++)o();return e}()}}},{key:"setSessions",value:function(e,t){this.sessionOne=e,this.sessionTwo=t}},{key:"onNextGamePressed",value:function(e){var o=this;return this.fetchRandomSessionPair((function(e,n){var i=w.getQueryVariable("league");if(!o.destroyed){if(e)return console.log("There was an error fetching the random session pair: ".concat(n));o.setSessions(n[0]._id,n[1]._id);var s,r,a="/play/spectate/".concat(o.levelID,"?session-one=").concat(o.sessionOne,"&session-two=").concat(o.sessionTwo);return i&&(a+="&league="+i),Backbone.Mediator.publish("router:navigate",{route:a,viewClass:t,viewArgs:[{spectateSessions:{sessionOne:o.sessionOne,sessionTwo:o.sessionTwo},supermodel:o.supermodel},o.levelID]}),"pushState",r=function(e){return e.pushState({},"",a)},null!=(s=history)&&"function"==typeof s.pushState?r(s):void 0}}))}},{key:"fetchRandomSessionPair",value:function(e){var t=w.getQueryVariable("league");console.log("Fetching random session pair!");var o="/db/level/".concat(this.levelID,"/random_session_pair");return t&&(o+="?league="+t),i.ajax({url:o,type:"GET",cache:!1,complete:function(t,o){return"success"!==o?e("error",t.statusText):e(null,i.parseJSON(t.responseText))}})}},{key:"destroy",value:function(){null!=this.levelLoader&&this.levelLoader.destroy(),null!=this.surface&&this.surface.destroy(),null!=this.god&&this.god.destroy(),null!=this.goalManager&&this.goalManager.destroy(),null!=this.scriptManager&&this.scriptManager.destroy(),delete window.world;var e=null!=this.editors?this.editors:{};for(var o in e){var n=e[o];this.destroyAceEditor(n)}return h(g(t.prototype),"destroy",this).call(this)}}],s=[{key:"initClass",value:function(){this.prototype.id="spectate-level-view",this.prototype.template=f,this.prototype.cache=!1,this.prototype.isEditorPreview=!1,this.prototype.subscriptions={"level:set-volume":function(e){L.Sound.volume=1===e.volume?.6:e.volume},"god:new-world-created":"onNewWorld","god:streaming-world-updated":"onNewWorld","god:infinite-loop":"onInfiniteLoop","level:next-game-pressed":"onNextGamePressed","level:started":"onLevelStarted","level:loading-view-unveiled":"onLoadingViewUnveiled","level:session-will-save":"onSessionWillSave"},this.prototype.events={"mouseenter .spectate-code":"onMouseEnterSpectateCode","mouseleave .spectate-code":"onMouseLeaveSpectateCode"}}}],n&&l(o.prototype,n),s&&l(o,s),Object.defineProperty(o,"prototype",{writable:!1}),o;var o,n,s}(m)).initClass(),n)},118101:(e,t,o)=>{"use strict";var n,i=o(619755);function s(e){return s="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},s(e)}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t){for(var o=0;o<t.length;o++){var n=t[o];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,l(n.key),n)}}function l(e){var t=function(e,t){if("object"!=s(e)||!e)return e;var o=e[Symbol.toPrimitive];if(void 0!==o){var n=o.call(e,t);if("object"!=s(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e,"string");return"symbol"==s(t)?t:t+""}function c(e,t,o){return t=p(t),function(e,t){if(t&&("object"==s(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(e,u()?Reflect.construct(t,o||[],p(e).constructor):t.apply(e,o))}function u(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(u=function(){return!!e})()}function d(){return d="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(e,t,o){var n=h(e,t);if(n){var i=Object.getOwnPropertyDescriptor(n,t);return i.get?i.get.call(arguments.length<3?e:o):i.value}},d.apply(null,arguments)}function h(e,t){for(;!{}.hasOwnProperty.call(e,t)&&null!==(e=p(e)););return e}
1function p(e){return p=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},p(e)}function g(e,t){return g=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},g(e,t)}o(589748);var v=o(968029),m=o(34088),f=o(568811),y=o(299498);function b(e,t){return null!=e?t(e):void 0}e.exports=((n=function(e){function t(){var e;r(this,t);for(var o=arguments.length,n=new Array(o),i=0;i<o;i++)n[i]=arguments[i];return(e=c(this,t,[].concat(n))).tickSequentialAnimation=e.tickSequentialAnimation.bind(e),e}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&g(e,t)}(t,e),n=t,s=[{key:"initialize",value:function(e){d(p(t.prototype),"initialize",this).call(this),this.level=e.level,this.session=e.session,this.nextLevelLocked=e.nextLevelLocked,this.thangTypes={},this.achievements=e.achievements}},{key:"render",value:function(){return this.loadAchievementsData(),this.previousXP=me.get("points",!0),this.previousRank=me.rank(),d(p(t.prototype),"render",this).call(this)}},{key:"afterRender",value:function(){return d(p(t.prototype),"afterRender",this).call(this),this.initializeAnimations()}},{key:"onClickMapButton",value:function(){return this.trigger("to-map")}},{key:"onClickContinueButton",value:function(){return this.trigger("continue")}},{key:"loadAchievementsData",value:function(){for(var e,t=[],o=0,n=Array.from(this.achievements.models);o<n.length;o++){var i=(e=n[o]).get("rewards")||{};t.push(i.items||[])}t=_.uniq(_.flatten(t));for(var s=0,r=Array.from(t);s<r.length;s++){var a=r[s],l=new m;l.url="/db/thang.type/".concat(a,"/version"),l.project=["original","rasterIcon","name","slug","soundTriggers","featureImages","gems","heroClass","description","components","extendedName","shortName","unlockLevelName","i18n","subscriber"],this.thangTypes[a]=this.supermodel.loadModel(l).model}this.newEarnedAchievements=[];for(var c=0,u=Array.from(this.achievements.models);c<u.length;c++)if((e=u[c]).completed){var d=new f({collection:e.get("collection"),triggeredBy:this.session.id,achievement:e.id});me.isSessionless()?this.newEarnedAchievements.push(d):(d.save(),this.newEarnedAchievements.push(d),this.listenToOnce(d,"sync",(function(e){var t=this;if(_.all(function(){for(var e=[],o=0,n=Array.from(t.newEarnedAchievements);o<n.length;o++){var i=n[o];e.push(i.id)}return e}())&&(me.loading||this.supermodel.loadModel(me,{cache:!1}),this.newEarnedAchievementsResource.markLoaded()),!me.loading)return me.fetch({cache:!1})})))}me.isSessionless()||this.newEarnedAchievements.length&&(this.newEarnedAchievementsResource=this.supermodel.addSomethingResource("earned achievements"))}},{key:"getRenderData",value:function(){for(var e,o=d(p(t.prototype),"getRenderData",this).call(this),n=_.indexBy(this.newEarnedAchievements||[],(function(e){return e.get("achievement")})),i=0,s=Array.from((null!=this.achievements?this.achievements.models:void 0)||[]);i<s.length;i++){var r=n[(e=s[i]).id];r&&(e.completedAWhileAgo=(new Date).getTime()-Date.parse(r.attributes.changed)>3e4),e.worth=e.get("worth",!0),e.gems=b(e.get("rewards"),(function(e){return e.gems}))}o.achievements=(null!=this.achievements?this.achievements.models.slice():void 0)||[];for(var a=0,l=Array.from(o.achievements);a<l.length;a++){var c,u,h=(e=l[a]).get("proportionalTo");if(e.description=y.i18n(e.attributes,"description"),this.supermodel.finished()&&h){var g=y.getByPath(this.session.attributes,h),v=Math.max(0,g-1),m=e.getExpFunction();e.previousWorth=(null!=(c=e.get("worth"))?c:0)*m(v),e.worth=(null!=(u=e.get("worth"))?u:0)*m(g);var f=e.get("rewards");(null!=f?f.gems:void 0)&&(e.gems=(null!=f?f.gems:void 0)*m(g)),(null!=f?f.gems:void 0)&&(e.previousGems=(null!=f?f.gems:void 0)*m(v))}}return o.thangTypes=this.thangTypes,o}},{key:"initializeAnimations",value:function(){if(!this.level.isType("course","hero","course-ladder","game-dev","web-dev"))return this.endSequentialAnimations();var e=_.once(_.bind(this.beginSequentialAnimations,this));this.animatedPanels=i();for(var t=this.$el.find(".achievement-panel"),o=0,n=Array.from(t);o<n.length;o++){var s=n[o];null!=(s=i(s)).data("animate")&&(this.animatedPanels=this.animatedPanels.add(s),s.queue((function(){return i(this).addClass("earned"),i(this).dequeue()})),s.delay(500),s.queue((function(){return i(this).find(".reward-image-container").addClass("show"),i(this).dequeue()})),s.delay(500),s.queue((function(){return e()})))}return this.animationComplete=!this.animatedPanels.length,this.animationComplete?e():void 0}},{key:"beginSequentialAnimations",value:function(){var e;if(!this.destroyed&&this.level.isType("course","hero","course-ladder","game-dev","web-dev")){this.sequentialAnimatedPanels=_.map(this.animatedPanels.find(".reward-panel"),(function(e){return{number:i(e).data("number"),previousNumber:i(e).data("previous-number"),textEl:i(e).find(".reward-text"),rootEl:i(e),unit:i(e).data("number-unit"),item:i(e).data("item-thang-type")}})),this.totalXP=0;for(var t=0,o=Array.from(this.sequentialAnimatedPanels);t<o.length;t++)"xp"===(e=o[t]).unit&&(this.totalXP+=e.number);this.totalGems=0;for(var n=0,s=Array.from(this.sequentialAnimatedPanels);n<s.length;n++)"gem"===(e=s[n]).unit&&(this.totalGems+=e.number);this.totalXPAnimated=this.totalGemsAnimated=this.lastTotalXP=this.lastTotalGems=0,this.sequentialAnimationStart=new Date,this.sequentialAnimationInterval=setInterval(this.tickSequentialAnimation,1e3/60)}}},{key:"tickSequentialAnimation",value:function(){var e,t;if(!(t=this.sequentialAnimatedPanels[0]))return this.endSequentialAnimations();e=t.number?Math.log(t.number+1)/Math.LN10*1e3:1e3;var o=this.getEaseRatio(new Date-this.sequentialAnimationStart,e);if("xp"===t.unit){var n=Math.floor(o*(t.number-t.previousNumber)),i=this.totalXPAnimated+n;
1if(i!==this.lastTotalXP){t.textEl.text("+"+n);var s="xp-"+i%6;this.playSound(s,.5+o/2),this.lastTotalXP=i}}else if("gem"===t.unit){var r=Math.floor(o*(t.number-t.previousNumber)),a=this.totalGemsAnimated+r;if(a!==this.lastTotalGems){t.textEl.text("+"+r);var l="gem-"+parseInt(t.number*o)%4;this.playSound(l,.5+o/2),this.lastTotalGems=a}}else if(t.item){var c=this.thangTypes[t.item];t.textEl.text(y.i18n(c.attributes,"name")),o>.5&&o<.6&&this.playSound("item-unlocked")}return 1===o?(t.rootEl.removeClass("animating").find(".reward-image-container img").removeClass("pulse"),this.sequentialAnimationStart=new Date,"xp"===t.unit?this.totalXPAnimated+=t.number-t.previousNumber:"gem"===t.unit&&(this.totalGemsAnimated+=t.number-t.previousNumber),void this.sequentialAnimatedPanels.shift()):t.rootEl.addClass("animating").find(".reward-image-container").removeClass("pending-reward-image").find("img").addClass("pulse")}},{key:"getEaseRatio",value:function(e,t){var o=2*(e=Math.min(e,t))/t;return o<1?.5*o*o:-.5*(--o*(o-2)-1)}},{key:"endSequentialAnimations",value:function(){return clearInterval(this.sequentialAnimationInterval),this.animationComplete=!0,Backbone.Mediator.publish("music-player:enter-menu",{terrain:this.level.get("terrain",!0)||"forest"})}}],l=[{key:"initClass",value:function(){this.prototype.id="course-rewards-view",this.prototype.className="modal-content",this.prototype.template=o(21848),this.prototype.events={"click #continue-btn":"onClickContinueButton","click #map-btn":"onClickMapButton"}}}],s&&a(n.prototype,s),l&&a(n,l),Object.defineProperty(n,"prototype",{writable:!1}),n;var n,s,l}(v)).initClass(),n)},919384:(e,t,o)=>{"use strict";var n,i=o(665420);function s(e){return s="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},s(e)}function r(e,t){(null==t||t>e.length)&&(t=e.length);for(var o=0,n=Array(t);o<t;o++)n[o]=e[o];return n}function a(e,t){for(var o=0;o<t.length;o++){var n=t[o];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,l(n.key),n)}}function l(e){var t=function(e,t){if("object"!=s(e)||!e)return e;var o=e[Symbol.toPrimitive];if(void 0!==o){var n=o.call(e,t);if("object"!=s(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e,"string");return"symbol"==s(t)?t:t+""}function c(e,t,o){return t=p(t),function(e,t){if(t&&("object"==s(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(e,u()?Reflect.construct(t,o||[],p(e).constructor):t.apply(e,o))}function u(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(u=function(){return!!e})()}function d(){return d="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(e,t,o){var n=h(e,t);if(n){var i=Object.getOwnPropertyDescriptor(n,t);return i.get?i.get.call(arguments.length<3?e:o):i.value}},d.apply(null,arguments)}function h(e,t){for(;!{}.hasOwnProperty.call(e,t)&&null!==(e=p(e)););return e}function p(e){return p=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},p(e)}function g(e,t){return g=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},g(e,t)}o(281712);var v=o(921336),m=o(3484),f=o(523402),y=o(573131),b=o(759075),w=o(233946),k=o(609838),S=o(299498),C=o(694879),x=o(586369),T=o(196363),P=o(677820).default,L=o(118101),M=o(900026),I=o(94247);e.exports=((n=function(e){function t(e){var o,n;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),(n=c(this,t,[e])).courseID=e.courseID,n.courseInstanceID=e.courseInstanceID||S.getQueryVariable("course-instance")||S.getQueryVariable("league"),!features.china||n.courseID||n.courseInstanceID||(n.courseID="560f1a9f22961295f9427742",n.courseInstanceID="5cb8403a60778e004634ee6e"),n.views=[],n.session=e.session,n.level=e.level,n.courseInstanceID&&(n.classroom=new k,n.supermodel.trackRequest(n.classroom.fetchForCourseInstance(n.courseInstanceID,{}))),n.playSound("victory"),n.nextLevel=new f,n.nextAssessment=new f;var i=C.levels.fetchNextForCourse({levelOriginalID:n.level.get("original"),courseInstanceID:n.courseInstanceID,courseID:n.courseID,sessionID:n.session.id}).then((function(e){var t=e.level,o=e.assessment;return n.nextLevel.set(t),n.nextAssessment.set(o)})).catch((function(e){404===e.code?console.info("Next level not found:",e):console.error("Error fetching next level:",e)}));
1n.supermodel.trackPromise(i),n.course=e.course,n.courseID&&!n.course&&(n.course=(new y).setURL("/db/course/".concat(n.courseID)),n.course=n.supermodel.loadModel(n.course).model),n.courseInstanceID&&(n.course||(n.course=new y,n.supermodel.trackRequest(n.course.fetchForCourseInstance(n.courseInstanceID,{}))),n.level.isProject()&&(n.galleryURL=x.projectGallery({courseInstanceID:n.courseInstanceID})));var s={category:"Students",levelSlug:n.level.get("slug")},r=n.level.get("goals").filter((function(e){return e.concepts})).map((function(e){return e.id}));if(r.length){var a=n.session.get("state").goalStates,l=r.filter((function(e){var t;return"success"===(null===(t=a[e])||void 0===t?void 0:t.status)}));_.assign(s,{concepts:r,succeededConcepts:l})}return null===(o=window.tracker)||void 0===o||o.trackEvent("Play Level Victory Modal Loaded",s),n.level.isType("hero","course","course-ladder","game-dev","web-dev","ladder")&&(n.achievements=e.achievements,n.achievements||(n.achievements=new M,n.achievements.fetchRelatedToLevel(n.session.get("level").original),n.achievements=n.supermodel.loadCollection(n.achievements,"achievements").model)),n}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&g(e,t)}(t,e),o=t,n=[{key:"onResourceLoadFailed",value:function(e){if(e.resource.jqxhr!==this.nextLevelRequest)return d(p(t.prototype),"onResourceLoadFailed",this).apply(this,arguments)}},{key:"onLoaded",value:function(){var e=this;if(d(p(t.prototype),"onLoaded",this).call(this),this.views=[],me.showGemsAndXpInClassroom()&&this.achievements.length>0){this.achievements.models=_.filter(this.achievements.models,(function(e){var t;return!(null!==(t=e.get("query"))&&void 0!==t&&t.ladderAchievementDifficulty)}));var o,n=!1,i=function(e,t){var o="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!o){if(Array.isArray(e)||(o=function(e,t){if(e){if("string"==typeof e)return r(e,t);var o={}.toString.call(e).slice(8,-1);return"Object"===o&&e.constructor&&(o=e.constructor.name),"Map"===o||"Set"===o?Array.from(e):"Arguments"===o||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(o)?r(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){o&&(e=o);var n=0,i=function(){};return{s:i,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var s,a=!0,l=!1;return{s:function(){o=o.call(e)},n:function(){var e=o.next();return a=e.done,e},e:function(e){l=!0,s=e},f:function(){try{a||null==o.return||o.return()}finally{if(l)throw s}}}}(this.achievements.models);try{for(i.s();!(o=i.n()).done;){var s=o.value;s.completed=I.matchesQuery(this.session.attributes,s.get("query")),s.completed&&(n=!0)}}catch(e){i.e(e)}finally{i.f()}if(n){var a=!1;"codecombat-junior"===this.level.get("product")&&this.nextLevel&&_.isEmpty(this.nextLevel.attributes)&&(a=!0);var l=new L({level:this.level,session:this.session,achievements:this.achievements,supermodel:this.supermodel,nextLevelLocked:a});l.on("continue",this.onViewContinue,this),l.on("to-map",this.onToMap,this),this.views.push(l)}}return this.courseInstanceID?(this.levelSessions=new b,this.levelSessions.fetchForCourseInstance(this.courseInstanceID,{}).then((function(){return e.levelSessionsLoaded()}))):this.levelSessionsLoaded()}},{key:"levelSessionsLoaded",value:function(){return null!=this.levelSessions&&this.levelSessions.remove(this.session),null!=this.levelSessions&&this.levelSessions.add(this.session),this.loadViews()}},{key:"loadViews",value:function(){if(this.level.isLadder()||this.level.isProject()){null==this.courseID&&(this.courseID=this.course.id);var e=new w({level:this.level,nextLevel:this.nextLevel,nextAssessment:this.nextAssessment,course:this.course,classroom:this.classroom,levelSessions:this.levelSessions,session:this.session,courseInstanceID:this.courseInstanceID});e.once("done",this.onDone,this),e.once("next-level",this.onNextLevel,this),e.once("start-challenge",this.onStartChallenge,this),e.once("to-map",this.onToMap,this),e.once("ladder",this.onLadder,this),e.once("publish",this.onPublish,this),this.views.push(e)}return this.views.length>0?this.showView(_.first(this.views)):this.showVictoryComponent()}},{key:"afterRender",value:function(){return d(p(t.prototype),"afterRe
1nder",this).call(this),this.showView(this.currentView)}},{key:"showView",value:function(e){e&&(e.setElement(this.$(".modal-content")),e.$el.attr("id",e.id),e.$el.addClass(e.className),e.render(),this.currentView=e)}},{key:"onViewContinue",value:function(){if(this.level.isLadder()||this.level.isProject()){var e=_.indexOf(this.views,this.currentView);return this.showView(this.views[e+1])}return"codecombat-junior"===this.level.get("product")?this.onNextLevel():this.showVictoryComponent()}},{key:"showVictoryComponent",value:function(){var e,t={nextLevel:this.nextLevel.toJSON(),nextAssessment:this.nextAssessment.toJSON(),level:this.level.toJSON(),session:this.session.toJSON(),course:this.course.toJSON(),courseInstanceID:this.courseInstanceID,stats:null===(e=this.classroom)||void 0===e?void 0:e.statsForSessions(this.levelSessions,this.course.id),supermodel:this.supermodel,parent:this.options.parent,codeLanguage:this.session.get("codeLanguage")};return new P({el:this.$el.find(".modal-content")[0],propsData:t,store:T})}},{key:"onNextLevel",value:function(){var e,t;return null===(e=window.tracker)||void 0===e||e.trackEvent("Play Level Victory Modal Next Level",{category:"Students",levelSlug:this.level.get("slug"),nextLevelSlug:this.nextLevel.get("slug")}),me.isSessionless()?t="/play/level/".concat(this.nextLevel.get("slug"),"?course=").concat(this.courseID,"&codeLanguage=").concat(S.getQueryVariable("codeLanguage","python")):(t="/play/level/".concat(this.nextLevel.get("slug"),"?course=").concat(this.courseID,"&course-instance=").concat(this.courseInstanceID),this.level.get("primerLanguage")&&(t+="&codeLanguage="+this.level.get("primerLanguage"))),i.router.navigate(t,{trigger:!0})}},{key:"onToMap",value:function(){var e,t;return t=me.isSessionless()?S.sessionlessCoursesUrl(this.level.get("product")):"/play/".concat(this.course.get("campaignID"),"?course-instance=").concat(this.courseInstanceID),null===(e=window.tracker)||void 0===e||e.trackEvent("Play Level Victory Modal Back to Map",{category:"Students",levelSlug:this.level.get("slug")}),i.router.navigate(t,{trigger:!0})}},{key:"onDone",value:function(){var e,t;return null===(e=window.tracker)||void 0===e||e.trackEvent("Play Level Victory Modal Done",{category:"Students",levelSlug:this.level.get("slug")}),t=me.isSessionless()?S.sessionlessCoursesUrl(this.level.get("product")):"/students",this.submitLadder(),i.router.navigate(t,{trigger:!0})}},{key:"onPublish",value:function(){var e,t=this;if(null===(e=window.tracker)||void 0===e||e.trackEvent("Play Level Victory Modal Publish",{category:"Students",levelSlug:this.level.get("slug")}),this.session.isFake())return i.router.navigate(this.galleryURL,{trigger:!0});var o=this.session.get("published");return this.session.set({published:!0}),this.session.save().then((function(){i.router.navigate(t.galleryURL,{trigger:!0});var e=i18n.t("play_level.project_published_noty");if(!o)return noty({text:e,layout:"topCenter",type:"success",timeout:5e3})}))}},{key:"onLadder",value:function(){var e=[{supermodel:this.options.hasReceivedMemoryWarning?null:this.supermodel},this.level.get("slug")],t="/play/ladder/".concat(this.level.get("slug")||this.level.id),o=this.courseInstanceID||S.getQueryVariable("league");if(o){var n=this.level.isType("course-ladder")||this.level.isType("ladder")&&S.getQueryVariable("course-instance")?"course":"clan";e.push(n),e.push(o),t+="/".concat(n,"/").concat(o)}return t+="#my-matches",this.submitLadder(),Backbone.Mediator.publish("router:navigate",{route:t,viewClass:"views/ladder/LadderView",viewArgs:e})}},{key:"submitLadder",value:function(){if(!i.testing)return"course-ladder"===this.level.get("type")&&this.session.readyToRank()||!this.session.inLeague(this.courseInstanceID)?C.levelSessions.submitToRank({session:this.session.id,courseInstanceId:this.courseInstanceID}):void 0}},{key:"onCourseMembershipRequired",value:function(e){var t;null===(t=window.tracker)||void 0===t||t.trackEvent("Course Victory Modal Course Membership Required",{category:"Students",levelSlug:this.level.get("slug")}),console.info("Course Membership Required",e),this.onNextLevel()}},{key:"onLicenseRequired",value:function(e){var t;null===(t=window.tracker)||void 0===t||t.trackEvent("Course Victory Modal License Required",{category:"Students",levelSlug:this.level.get("slug")}),console.info("License Required",e),this.onNextLevel()}},{key:"onLevelLocked",value:function(e){var t;null===(t=window.tracker)||void 0===t||t.trackEvent("Course Victory Modal Level Locked",{c
1ategory:"Students",levelSlug:this.level.get("slug")}),console.info("Level Locked",e),this.onNextLevel()}}],s=[{key:"initClass",value:function(){this.prototype.id="course-victory-modal",this.prototype.template=m,this.prototype.closesOnClickOutside=!1,this.prototype.subscriptions={"level:course-membership-required":"onCourseMembershipRequired","level:license-required":"onLicenseRequired","level:locked":"onLevelLocked"}}}],n&&a(o.prototype,n),s&&a(o,s),Object.defineProperty(o,"prototype",{writable:!1}),o;var o,n,s}(v)).initClass(),n)},778363:(e,t,o)=>{"use strict";function n(e){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},n(e)}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function s(e,t){for(var o=0;o<t.length;o++){var n=t[o];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,r(n.key),n)}}function r(e){var t=function(e,t){if("object"!=n(e)||!e)return e;var o=e[Symbol.toPrimitive];if(void 0!==o){var i=o.call(e,t);if("object"!=n(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e,"string");return"symbol"==n(t)?t:t+""}function a(e,t,o){return t=c(t),function(e,t){if(t&&("object"==n(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(e,l()?Reflect.construct(t,o||[],c(e).constructor):t.apply(e,o))}function l(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(l=function(){return!!e})()}function c(e){return c=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},c(e)}function u(e,t){return u=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},u(e,t)}var d;o(908821);var h=o(921336);e.exports=((d=function(e){function t(){return i(this,t),a(this,t,arguments)}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&u(e,t)}(t,e),n=t,l=[{key:"initClass",value:function(){this.prototype.id="game-dev-victory-modal",this.prototype.template=o(643724),this.prototype.events={"click #replay-game-btn":"onClickReplayButton","click #copy-url-btn":"onClickCopyURLButton","click #play-more-codecombat-btn":"onClickPlayMoreCodeCombatButton"}}}],(r=[{key:"initialize",value:function(e){var t=e.shareURL,o=e.eventProperties,n=e.victoryMessage;this.shareURL=t,this.eventProperties=o,this.victoryMessage=n}},{key:"getVictoryMessage",value:function(){return null!=this.victoryMessage?this.victoryMessage:"You beat the game!"}},{key:"onClickReplayButton",value:function(){return this.trigger("replay")}},{key:"onClickCopyURLButton",value:function(){return this.$("#copy-url-input").val(this.shareURL).select(),this.tryCopy(),null!=window.tracker?window.tracker.trackEvent("Play GameDev Victory Modal - Copy URL",this.eventProperties):void 0}},{key:"onClickPlayMoreCodeCombatButton",value:function(){return null!=window.tracker?window.tracker.trackEvent("Play GameDev Victory Modal - Click Play More CodeCombat",this.eventProperties):void 0}}])&&s(n.prototype,r),l&&s(n,l),Object.defineProperty(n,"prototype",{writable:!1}),n;var n,r,l}(h)).initClass(),d)},859017:(e,t,o)=>{"use strict";var n,i=o(665420),s=o(619755);function r(e){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},r(e)}function a(e,t){for(var o=0;o<t.length;o++){var n=t[o];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,l(n.key),n)}}function l(e){var t=function(e,t){if("object"!=r(e)||!e)return e;var o=e[Symbol.toPrimitive];if(void 0!==o){var n=o.call(e,t);if("object"!=r(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e,"string");return"symbol"==r(t)?t:t+""}function c(e,t,o){return t=p(t),function(e,t){if(t&&("object"==r(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(e,u()?Reflect.construct(t,o||[],p(e).constructor):t.apply(e,o))}function u(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(u=function(){return!!e})()}function d(){return d="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(e,t,o){var n=h(e,t);if(n){var i=Object.getOwnPropertyDescriptor(n,t);return i.get?i.get.call(arguments.length<3?e:o):i.value}},d.apply(null,arguments)}function h(e,t){for(;!{}.hasOwnProperty.call(e,t)&&null!==(e=p(e)););return e}
1function p(e){return p=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},p(e)}function g(e,t){return g=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},g(e,t)}o(856640);var v=o(921336),m=o(287127),f=o(860081),y=o(956323),b=o(568811),w=o(566978),k=o(94247),S=o(299498),C=o(694879),x=o(34088),T=o(992148),P=o(847504),L=o(249449),M=o(523402),I=o(375558),D=o(203949),B=o(575002),A=o(439980),E=o(746516);e.exports=((n=function(e){function t(e){var o;if(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),(o=c(this,t,[e])).tickSequentialAnimation=o.tickSequentialAnimation.bind(o),o.courseID=e.courseID,o.courseInstanceID=e.courseInstanceID,o.parentCampaign=e.parentCampaign,o.session=e.session,o.level=e.level,o.thangTypes={},o.level.isType("hero","hero-ladder","course","course-ladder","game-dev","web-dev","ladder")){var n=new w([],{url:"/db/achievement?related=".concat(o.session.get("level").original),model:y});o.achievements=o.supermodel.loadCollection(n,"achievements").model,o.listenToOnce(o.achievements,"sync",o.onAchievementsLoaded),o.readyToContinue=!1,o.waitingToContinueSince=new Date,o.previousXP=me.get("points",!0),o.previousRank=me.rank()}else o.readyToContinue=!0;if(o.playSound("victory"),o.level.isType("course","course-ladder")&&(o.saveReviewEventually=_.debounce(o.saveReviewEventually,2e3)),"project"===o.level.get("shareable")&&(o.shareURL="".concat(window.location.origin,"/play/").concat(o.level.get("type"),"-level/").concat(o.session.id)),o.trackAwsButtonShown=_.once((function(){return null!=window.tracker?window.tracker.trackEvent("Show Amazon Modal Button"):void 0})),"codecombat-junior"===o.level.get("product",!0)&&o.level.get("campaign")){o.nextLevel=new M,C.levels.fetchNextForCampaign({campaignSlug:o.level.get("campaign"),levelOriginal:o.level.get("original"),includePractice:!1}).then((function(e){var t,n,i;null===(t=o.nextLevel)||void 0===t||t.set(e),null===(n=(i=o).renderSelectors)||void 0===n||n.call(i,".next-level-buttons")})).catch((function(e){console.error("Failed to fetch next level for campaign (includePractice: false):",e)}));var i=Boolean("function"==typeof me.isPremium?me.isPremium():me.isPremium);me&&i&&(o.practiceLevel=new M,C.levels.fetchNextForCampaign({campaignSlug:o.level.get("campaign"),levelOriginal:o.level.get("original"),includePractice:!0}).then((function(e){var t,n,i;null===(t=o.practiceLevel)||void 0===t||t.set(e),null===(n=(i=o).renderSelectors)||void 0===n||n.call(i,".next-level-buttons")})).catch((function(e){console.error("Failed to fetch practice level for campaign (includePractice: true):",e)})))}return o}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&g(e,t)}(t,e),o=t,n=[{key:"destroy",value:function(){return clearInterval(this.sequentialAnimationInterval),this.$el.find(".review textarea").val()&&this.saveReview(),null!=this.feedback&&this.feedback.off(),d(p(t.prototype),"destroy",this).call(this)}},{key:"onHidden",value:function(){return Backbone.Mediator.publish("music-player:exit-menu",{}),d(p(t.prototype),"onHidden",this).call(this)}},{key:"loadExistingFeedback",value:function(){var e="/db/level/".concat(this.level.id,"/feedback");return this.feedback=new I,this.feedback.setURL(e),this.feedback.fetch({cache:!1}),this.listenToOnce(this.feedback,"sync",(function(){return this.onFeedbackLoaded()})),this.listenToOnce(this.feedback,"error",(function(){return this.onFeedbackNotFound()}))}},{key:"onFeedbackLoaded",value:function(){return this.feedback.url=function(){return"/db/level.feedback/"+this.id},this.$el.find(".review textarea").val(this.feedback.get("review")),this.$el.find(".review, .review-label").show(),this.showStars()}},{key:"onFeedbackNotFound",value:function(){return this.feedback=new I,this.feedback.set("levelID",this.level.get("slug")||this.level.id),this.feedback.set("levelName",this.level.get("name")||""),this.feedback.set("level",{majorVersion:this.level.get("version").major,original:this.level.get("original")}),this.showStars()}},{key:"onAchievementsLoaded",value:function(){var e;this.achievements.models=_.filter(this.achievements.models,(function(e){return!O
1(e.get("query"),(function(e){return e.ladderAchievementDifficulty}))})),this.$el.toggleClass("full-achievements",3===this.achievements.models.length);for(var t=[],o=[],n=0,i=Array.from(this.achievements.models);n<i.length;n++){var s=(e=i[n]).get("rewards")||{};t.push(s.heroes||[]),t.push(s.items||[]),e.completed=k.matchesQuery(this.session.attributes,e.get("query")),e.completed&&o.push(e.id)}t=_.uniq(_.flatten(t));for(var r=0,a=Array.from(t);r<a.length;r++){var l=a[r],c=new x;c.url="/db/thang.type/".concat(l,"/version"),c.project=["original","rasterIcon","name","slug","soundTriggers","featureImages","gems","heroClass","description","components","extendedName","shortName","unlockLevelName","i18n","subscriber"],this.thangTypes[l]=this.supermodel.loadModel(c).model}this.newEarnedAchievements=[];for(var u=!1,d=0,h=Array.from(this.achievements.models);d<h.length;d++)if((e=h[d]).completed){u=!0;var p=new b({collection:e.get("collection"),triggeredBy:this.session.id,achievement:e.id});p.save(),this.newEarnedAchievements.push(p),this.listenToOnce(p,"sync",(function(){var e=this;if(_.all(function(){for(var t=[],o=0,n=Array.from(e.newEarnedAchievements);o<n.length;o++){var i=n[o];t.push(i.id)}return t}())&&(this.newEarnedAchievementsResource.markLoaded(),this.listenToOnce(me,"sync",(function(){return this.readyToContinue=!0,this.updateSavingProgressStatus()})),!me.loading))return me.fetch({cache:!1})}))}u||(this.readyToContinue=!0),this.newEarnedAchievements.length&&(this.newEarnedAchievementsResource=this.supermodel.addSomethingResource("earned achievements"))}},{key:"getRenderData",value:function(){var e,o,n,r=d(p(t.prototype),"getRenderData",this).call(this);r.levelName=S.i18n(this.level.attributes,"name"),this.level.isType("hero","game-dev","web-dev")&&"codecombat-junior"!==this.level.get("product",!0)&&(r.victoryText=S.i18n(this.level.get("victory")||{},"body"));for(var a=_.indexBy(this.newEarnedAchievements||[],(function(e){return e.get("achievement")})),l=0,c=Array.from((null!=this.achievements?this.achievements.models:void 0)||[]);l<c.length;l++){var u=a[(n=c[l]).id];u&&(n.completedAWhileAgo=(new Date).getTime()-Date.parse(u.attributes.changed)>3e4),n.worth=n.get("worth",!0),n.gems=O(n.get("rewards"),(function(e){return e.gems}))}r.achievements=(null!=this.achievements?this.achievements.models.slice():void 0)||[];for(var h=0,g=Array.from(r.achievements);h<g.length;h++){var v,m,f=(n=g[h]).get("proportionalTo");if(n.description=S.i18n(n.attributes,"description"),this.supermodel.finished()&&n.get("proportionalTo")){var y=S.getByPath(this.session.attributes,f),b=Math.max(0,y-1),w=n.getExpFunction();n.previousWorth=(null!=(v=n.get("worth"))?v:0)*w(b),n.worth=(null!=(m=n.get("worth"))?m:0)*w(y);var k=n.get("rewards");(null!=k?k.gems:void 0)&&(n.gems=(null!=k?k.gems:void 0)*w(y)),(null!=k?k.gems:void 0)&&(n.previousGems=(null!=k?k.gems:void 0)*w(b))}}r.thangTypes=this.thangTypes,r.me=me,r.readyToRank=this.level.isLadder()&&this.session.readyToRank(),r.level=this.level,r.i18n=S.i18n;var C=Boolean("function"==typeof me.isPremium?me.isPremium():me.isPremium);r.hasPracticeLevel=C&&null!=(null===(e=this.practiceLevel)||void 0===e?void 0:e.get("slug"))&&this.practiceLevel.get("slug")!==(null===(o=this.nextLevel)||void 0===o?void 0:o.get("slug"));var x=new Date-new Date(me.get("dateCreated"));if(me.get("hourOfCode")){var T=i.getHocCampaign()&&"intro"!==i.getHocCampaign(),P=function(){switch(T){case"game-dev-hoc":return"57ee6f5786cf4e1f00afca2c";case"game-dev-hoc-2":return"57b71dce7a14ff35003a8f71";case"ai-league-hoc":return"62f9f6506428860025b15a8b";default:return"541c9a30c6362edfb0f34479"}}(),L=this.level.get("original")===P||this.level.isType("ladder"),M=x>72e5,I=x>=18e5&&!M||L;if((x>=12e5||L)&&!M&&!me.get("hourOfCodeComplete")){var D=function(){switch(T){case"game-dev-hoc":return"code_combat_gamedev";case"game-dev-hoc-2":return"code_combat_build_arcade";case"ai-league-hoc":return"codecombat_esports";case"goblins-hoc":return"codecombat_goblins";default:return"code_combat"}}();s("body").append(s("<img src='https://code.org/api/hour/finish_".concat(D,".png' style='visibility: hidden;'>"))),me.set("hourOfCodeComplete",!0),me.patch(),null!=window.tracker&&window.tracker.trackEvent("Hour of Code Finish")}r.showHourOfCodeDoneButton=I,this.showAmazonHocButton="game-dev-hoc"===T&&L,this.showAmazonHocButton&&this.trackAwsButtonShown(),this.showHoc2016ExploreButton=T&&L,this.showShareGameWithTeacher=/game-dev/.test(T)&&L}return r.showLeaderboard=(this.level.get("scoreTypes")||[]).length>0&&!this.level.isType("course")&&!this.showAmazonHocButton&&!this.showHoc2016ExploreButton&&"codecombat-junior"!==this.level.get("product",!0),r.showReturnToCourse=!r.showLeaderboard&&!me.get("anonymous")&&this.level.isType("course","course-ladder"),r.isCourseLevel=this.level.isType("course"),r.currentCourseName=null!=this.course?this.course.get("name"):void 0,r.currentLevelName=null!=this.level?this.level.get("name"):void 0,r.nextLevelName=null!=this.nextLevel?this.nextLevel.get("name"):void 0,r}},{key:"afterRender",value:function(){var e=this;
1if(d(p(t.prototype),"afterRender",this).call(this),this.$el.toggleClass("with-achievements",this.level.isType("hero","hero-ladder","game-dev","web-dev","ladder")),this.supermodel.finished()){for(var o in this.thangTypes){var n=this.thangTypes[o];this.playSelectionSound(n,!0)}return this.updateSavingProgressStatus(),this.initializeAnimations(),_.delay((function(){var t,o;return null===(t=e.$el)||void 0===t||null===(o=t.find("button.btn-success").last())||void 0===o?void 0:o.focus()}),200),this.level.isLadder()?(this.ladderSubmissionView=new T({session:this.session,level:this.level}),this.insertSubView(this.ladderSubmissionView,this.$el.find(".ladder-submission-view"))):void 0}}},{key:"initializeAnimations",value:function(){if(!this.level.isType("hero","hero-ladder","game-dev","web-dev","ladder"))return this.endSequentialAnimations();this.updateXPBars(0),this.$el.find("#victory-header").delay(250).queue((function(){return s(this).removeClass("out").dequeue()}));var e=_.once(_.bind(this.beginSequentialAnimations,this));this.animatedPanels=s();for(var t=this.$el.find(".achievement-panel"),o=0,n=Array.from(t);o<n.length;o++){var i=n[o];null!=(i=s(i)).data("animate")&&(this.animatedPanels=this.animatedPanels.add(i),i.delay(500),i.queue((function(){return s(this).addClass("earned"),s(this).dequeue()})),i.delay(500),i.queue((function(){return s(this).find(".reward-image-container").addClass("show"),s(this).dequeue()})),i.delay(500),i.queue((function(){return e()})))}return this.animationComplete=!this.animatedPanels.length,this.animationComplete?e():void 0}},{key:"beginSequentialAnimations",value:function(){var e;if(!this.destroyed&&this.level.isType("hero","hero-ladder","game-dev","web-dev","ladder")){this.sequentialAnimatedPanels=_.map(this.animatedPanels.find(".reward-panel"),(function(e){return{number:s(e).data("number"),previousNumber:s(e).data("previous-number"),textEl:s(e).find(".reward-text"),rootEl:s(e),unit:s(e).data("number-unit"),hero:s(e).data("hero-thang-type"),item:s(e).data("item-thang-type")}})),this.totalXP=0;for(var t=0,o=Array.from(this.sequentialAnimatedPanels);t<o.length;t++)"xp"===(e=o[t]).unit&&(this.totalXP+=e.number);this.totalGems=0;for(var n=0,i=Array.from(this.sequentialAnimatedPanels);n<i.length;n++)"gem"===(e=i[n]).unit&&(this.totalGems+=e.number);this.gemEl=s("#gem-total"),this.XPEl=s("#xp-total"),this.totalXPAnimated=this.totalGemsAnimated=this.lastTotalXP=this.lastTotalGems=0,this.sequentialAnimationStart=new Date,this.sequentialAnimationInterval=setInterval(this.tickSequentialAnimation,1e3/60)}}},{key:"tickSequentialAnimation",value:function(){var e,t,o;if(!(t=this.sequentialAnimatedPanels[0]))return this.endSequentialAnimations();e=t.number?Math.log(t.number+1)/Math.LN10*1e3:1e3;var n=this.getEaseRatio(new Date-this.sequentialAnimationStart,e);if("xp"===t.unit){var i=Math.floor(n*(t.number-t.previousNumber)),s=this.totalXPAnimated+i;if(s!==this.lastTotalXP){t.textEl.text("+"+i),this.XPEl.text(s),this.updateXPBars(s);var r="xp-"+s%6;this.playSound(r,.5+n/2),s>=1e3&&this.lastTotalXP<1e3&&this.XPEl.addClass("four-digits"),s>=1e4&&this.lastTotalXP<1e4&&this.XPEl.addClass("five-digits"),this.lastTotalXP=s}}else if("gem"===t.unit){var a=Math.floor(n*(t.number-t.previousNumber)),l=this.totalGemsAnimated+a;if(l!==this.lastTotalGems){t.textEl.text("+"+a),this.gemEl.text(l);var c="gem-"+parseInt(t.number*n)%4;this.playSound(c,.5+n/2),l>=1e3&&this.lastTotalGems<1e3&&this.gemEl.addClass("four-digits"),l>=1e4&&this.lastTotalGems<1e4&&this.gemEl.addClass("five-digits"),this.lastTotalGems=l}}else t.item?(o=this.thangTypes[t.item],t.textEl.text(S.i18n(o.attributes,"name")),n>.5&&n<.6&&this.playSound("item-unlocked")):t.hero&&(o=this.thangTypes[t.hero],t.textEl.text(S.i18n(o.attributes,"name")),n>.5&&n<.6&&this.playSelectionSound(o));return 1===n?(t.rootEl.removeClass("animating").find(".reward-image-container img").removeClass("pulse"),this.sequentialAnimationStart=new Date,"xp"===t.unit?this.totalXPAnimated+=t.number-t.previousNumber:"gem"===t.unit&&(this.totalGemsAnimated+=t.number-t.previousNumber),void this.sequentialAnimatedPanels.shift()):t.rootEl.addClass("animating").find(".reward-image-container").removeClass("pe
1nding-reward-image").find("img").addClass("pulse")}},{key:"getEaseRatio",value:function(e,t){var o=2*(e=Math.min(e,t))/t;return o<1?.5*o*o:-.5*(--o*(o-2)-1)}},{key:"updateXPBars",value:function(e){var t=this.previousXP;me.isInGodMode()&&(t+=1e6);var o,n=this.previousRank,i=t+e,r=L.rankFromExp(i),a=L.expForRank(r),l=r+1,c=r>n,u=L.expForRank(l)-a,d=100*(t-a)/u;d<0&&(d=0),o=c?100*(i-a)/u:100*e/u;var h=s("#xp-wrapper");h.find(".xp-bar-already-achieved").css("width",d+"%"),h.find(".xp-bar-total").css("width",d+o+"%");var p=h.find(".rank");S.replaceText(p,r),c&&(!this.displayedRank||r>this.displayedRank)&&this.playSound("level-up"),this.displayedRank=r}},{key:"endSequentialAnimations",value:function(){return clearInterval(this.sequentialAnimationInterval),this.animationComplete=!0,this.updateSavingProgressStatus(),Backbone.Mediator.publish("music-player:enter-menu",{terrain:this.level.get("terrain",!0)||"forest"})}},{key:"updateSavingProgressStatus",value:function(){return this.$el.find("#saving-progress-label").toggleClass("hide",this.readyToContinue),this.$el.find(".next-button").toggleClass("hide",!this.readyToContinue),this.$el.find(".sign-up-poke").toggleClass("hide",!this.readyToContinue)}},{key:"onGameSubmitted",value:function(e){return this.returnToLadder()}},{key:"returnToLadder",value:function(){var e=this.courseInstanceID||S.getQueryVariable("league"),t=[{supermodel:this.options.hasReceivedMemoryWarning?null:this.supermodel},this.level.get("slug")],o="/play/ladder/".concat(this.level.get("slug")||this.level.id);if(e){var n=this.level.isType("course-ladder")?"course":"clan";t.push(n),t.push(e),o+="/".concat(n,"/").concat(e);var i=S.getQueryVariable("tournament");i&&(o+="?tournament=".concat(i))}return o+="#my-matches",this.hide(),Backbone.Mediator.publish("router:navigate",{route:o,viewClass:"views/ladder/LadderView",viewArgs:t})}},{key:"playSelectionSound",value:function(e,t){null==t&&(t=!1);var o=O(e.get("soundTriggers"),(function(e){return e.selected}));if(o){var n=o[Math.floor(Math.random()*o.length)];if(n){var i=P.nameForSoundReference(n);return t?P.preloadSoundReference(n):P.playSound(i,1)}}}},{key:"getNextLevelCampaign",value:function(){var e=this.level.get("campaign");return Array.from(R).includes(this.level.get("slug"))&&(e=""),i.getHocCampaign()&&(e=i.getHocCampaign()),e}},{key:"onClickContinue",value:function(e){var t,o,n,i,s,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;this.playSound("menu-button-click");var a={justBeatLevel:this.level,supermodel:this.options.hasReceivedMemoryWarning?null:this.supermodel};r&&_.merge(a,r);var l,c=this.level.get("returnAfterCompleteMap"),u=this.level.get("product",!0),d="codecombat-junior"===u;if(this.showHoc2016ExploreButton)l="/play",s="views/play/CampaignView",i=[a];else if(c&&c[this.parentCampaign])l="/play/".concat(c[this.parentCampaign]),s="views/play/CampaignView",i=[a,c[this.parentCampaign]];else if(a.sendToPracticeLevel&&d&&null!==(t=this.practiceLevel)&&void 0!==t&&t.get("slug")){l="/play/level/".concat(this.practiceLevel.get("slug")),s="views/play/level/PlayLevelView",a.parentCampaign=this.parentCampaign,a.courseID=this.courseID,a.courseInstanceID=this.courseInstanceID;var h=[];this.parentCampaign&&h.push("fromCampaign=".concat(this.parentCampaign)),this.courseID&&h.push("courseID=".concat(this.courseID)),this.courseInstanceID&&h.push("courseInstanceID=".concat(this.courseInstanceID)),h.length&&(l+="?".concat(h.join("&"))),i=[a,this.practiceLevel.get("slug")]}else if(d&&(me.isHomeUser()||me.isAnonymous())&&this.parentCampaign)l="/play/".concat(this.parentCampaign),s="views/play/CampaignView",i=[a,this.parentCampaign];else if((this.level.isType("course")||d)&&null!==(o=this.nextLevel)&&void 0!==o&&o.get("slug")&&!a.returnToCourse)l="/play/level/".concat(this.nextLevel.get("slug")),this.courseID&&(l+="/".concat(this.courseID),this.courseInstanceID&&(l+="/".concat(this.courseInstanceID))),this.parentCampaign&&(l+="?fromCampaign=".concat(this.parentCampaign)),s="views/play/level/PlayLevelView",a.courseID=this.courseID,a.courseInstanceID=this.courseInstanceID,a.parentCampaign=this.parentCampaign,i=[a,this.nextLevel.get("slug")];else if(this.level.isType("course"))l="/students",this.courseID&&(l+="/".concat(this.courseID),this.courseInstanceID&&(l+="/".concat(this.courseInstanceID))),s="views/courses/CoursesView",
1i=[a],this.courseID&&(s="views/courses/CourseDetailsView",i.push(this.courseID),this.courseInstanceID&&i.push(this.courseInstanceID));else if(this.level.isType("course-ladder")){var p=this.courseInstanceID||S.getQueryVariable("league");l="/play/ladder/".concat(this.level.get("slug")),p&&(l+="/course/".concat(p)),s="views/ladder/LadderView",i=[a,this.level.get("slug")],p&&(i=i.concat(["course",p]))}else{var g;g=this.level.get("slug"),Array.from(R).includes(g)&&(a.worldComplete=this.level.get("campaign")||!0),l="/play";var v=this.getNextLevelCampaign();l+="/"+v,s="views/play/CampaignView",i=[a,v]}var m={route:l,viewClass:s,viewArgs:i};return"lost-viking"!==this.level.get("slug")||(n=me.get("age"),["0-13","14-17"].includes(n))?(this.hide(),Backbone.Mediator.publish("router:navigate",m)):this.showOffer(m)}},{key:"onClickPracticeButton",value:function(e){return this.onClickContinue(e,{sendToPracticeLevel:!0})}},{key:"onClickLeaderboard",value:function(e){return this.onClickContinue(e,{showLeaderboard:!0})}},{key:"onClickReturnToCourse",value:function(e){return this.onClickContinue(e,{returnToCourse:!0})}},{key:"onClickReturnToLadder",value:function(e){return this.playSound("menu-button-click"),e.preventDefault(),this.returnToLadder()}},{key:"onClickSignupButton",value:function(e){return e.preventDefault(),null!=window.tracker&&window.tracker.trackEvent("Started Signup",{category:"Play Level",label:"Hero Victory Modal",level:this.level.get("slug")}),me.isInHourOfCode()&&(window.nextURL=window.location.href),this.openModalView(new m)}},{key:"showOffer",value:function(e){return this.navigationEventUponCompletion=e,this.$el.find(".modal-footer > *").hide(),this.$el.find(".modal-footer > .offer.".concat(this.level.get("slug"))).show()}},{key:"onClickContinueFromOffer",value:function(e){var t={"lost-viking":"http://www.vikingcodeschool.com/codecombat?utm_source=codecombat&utm_medium=viking_level&utm_campaign=affiliate&ref=Code+Combat+Elite"}[this.level.get("slug")];if(this.hide(),Backbone.Mediator.publish("router:navigate",this.navigationEventUponCompletion),t)return window.open(t,"_blank")}},{key:"onClickSkipOffer",value:function(e){return this.hide(),Backbone.Mediator.publish("router:navigate",this.navigationEventUponCompletion)}},{key:"onClickShareLevelButton",value:function(){return this.$("#share-level-input").val(this.shareURL).select(),this.tryCopy()}},{key:"onClickAmazonHocButton",value:function(){return null!=window.tracker&&window.tracker.trackEvent("Click Amazon Modal Button"),this.openModalView(new B)}},{key:"onSubscribeButtonClicked",value:function(){return this.openModalView(new D)}},{key:"onChangeShareGameWithTeacherInput",value:function(e){var t=_.string.trim(this.$("#share-game-with-teacher-input").val()),o=A.validateEmail(t)&&!/codecombat/i.test(t);return this.$("#share-game-with-teacher-btn").attr("disabled",!o).text(s.i18n.t("common.send"))}},{key:"onClickShareGameWithTeacherButton",value:function(e){var t=this,o=_.string.trim(this.$("#share-game-with-teacher-input").attr("disabled",!0).val());return this.$("#share-game-with-teacher-btn").attr("disabled",!0).text(s.i18n.t("common.sending")),E.sendTeacherGameDevProjectShare({teacherEmail:o,sessionId:this.session.id,codeLanguage:this.session.get("codeLanguage")||"python",levelName:S.i18n(this.level.attributes,"name")}).then((function(){return t.$("#share-game-with-teacher-btn").text(s.i18n.t("common.sent"))})).catch((function(){return t.$("#share-game-with-teacher-input").attr("disabled",!1).focus(),t.$("#share-game-with-teacher-btn").text(s.i18n.t("loading_error.error"))}))}},{key:"starNum",value:function(e){return e.prevAll("i").length+1}},{key:"showStars",value:function(e){this.$el.find(".rating").show(),null==e&&(e=(null!=this.feedback?this.feedback.get("rating"):void 0)||0);var t=this.$el.find(".rating i");return t.removeClass("glyphicon-star").addClass("glyphicon-star-empty"),t.slice(0,e).removeClass("glyphicon-star-empty").addClass("glyphicon-star")}},{key:"setStars",value:function(e){return this.feedback.set("rating",e),this.feedback.save()}},{key:"saveReviewEventually",value:function(){return this.saveReview()}},{key:"saveReview",value:function(){return this.feedback.set("review",this.$el.find(".review textarea").val()),this.feedback.save()}}],r=[{key:"initClass",value:function(){this.prototype.id="hero-victory-modal",this.prototype.template=f,this.prototype.closeButton=!1,this.prototype.closesOnClickOutside=!1,this.prototype.subscriptions={"ladder:game-submitted":"onGameSubmitted"},this.prototype.events={"click #continue-button":"onClickContinue","click #practice-button":"onClickPracticeButton","click .leaderboard-button":"onClickLeaderboard","click .return-to-course-button":"onClickReturnToCourse","click .return-to-ladder-button":"onClickReturnToLadder","click .sign-up-button":"onClickSignupButton","click .continue-from-offer-button":"onClickContinueFromOffer","click .ski
1p-offer-button":"onClickSkipOffer","click #share-level-btn":"onClickShareLevelButton","click .subscribe-button":"onSubscribeButtonClicked","click #amazon-hoc-button":"onClickAmazonHocButton","input #share-game-with-teacher-input":"onChangeShareGameWithTeacherInput","click #share-game-with-teacher-btn":"onClickShareGameWithTeacherButton","mouseover .rating i":function(e){return this.showStars(this.starNum(s(e.target)))},"mouseout .rating i":function(){return this.showStars()},"click .rating i":function(e){return this.setStars(this.starNum(s(e.target))),this.$el.find(".review, .review-label").show()},"keypress .review textarea":function(){return this.saveReviewEventually()}}}}],n&&a(o.prototype,n),r&&a(o,r),Object.defineProperty(o,"prototype",{writable:!1}),o;var o,n,r}(v)).initClass(),n);var R=["kithgard-gates","kithgard-mastery","tabula-rasa","wanted-poster","siege-of-stonehold","go-fetch","game-dev-2-final-project","quizlet","clash-of-clones","game-dev-3-final-project","summits-gate"];function O(e,t){return null!=e?t(e):void 0}},920658:(e,t,o)=>{"use strict";function n(e){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},n(e)}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function s(e,t){for(var o=0;o<t.length;o++){var n=t[o];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,r(n.key),n)}}function r(e){var t=function(e,t){if("object"!=n(e)||!e)return e;var o=e[Symbol.toPrimitive];if(void 0!==o){var i=o.call(e,t);if("object"!=n(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e,"string");return"symbol"==n(t)?t:t+""}function a(e,t,o){return t=c(t),function(e,t){if(t&&("object"==n(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(e,l()?Reflect.construct(t,o||[],c(e).constructor):t.apply(e,o))}function l(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(l=function(){return!!e})()}function c(e){return c=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},c(e)}function u(e,t){return u=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},u(e,t)}var d,h=o(921336),p=o(29432);e.exports=((d=function(e){function t(){return i(this,t),a(this,t,arguments)}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&u(e,t)}(t,e),o=t,n=[{key:"initClass",value:function(){this.prototype.id="#infinite-loop-modal",this.prototype.template=p,this.prototype.events={"click #restart-level-infinite-loop-retry-button":function(){return Backbone.Mediator.publish("tome:cast-spell",{})},"click #restart-level-infinite-loop-confirm-button":function(){return Backbone.Mediator.publish("tome:reset-my-code",{})},"click #restart-level-infinite-loop-comment-button":function(){return Backbone.Mediator.publish("tome:comment-my-code",{})}}}}],null&&s(o.prototype,null),n&&s(o,n),Object.defineProperty(o,"prototype",{writable:!1}),o;var o,n}(h)).initClass(),d)},233946:(e,t,o)=>{"use strict";function n(e){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},n(e)}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function s(e,t){for(var o=0;o<t.length;o++){var n=t[o];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,r(n.key),n)}}function r(e){var t=function(e,t){if("object"!=n(e)||!e)return e;var o=e[Symbol.toPrimitive];if(void 0!==o){var i=o.call(e,t);if("object"!=n(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e,"string");return"symbol"==n(t)?t:t+""}function a(e,t,o){return t=c(t),function(e,t){if(t&&("object"==n(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(e,l()?Reflect.construct(t,o||[],c(e).constructor):t.apply(e,o))}function l(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(l=function(){return!!e})()}
1function c(e){return c=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},c(e)}function u(e,t){return u=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},u(e,t)}var d;o(576182);var h=o(968029),p=o(299498),g=o(586369);e.exports=((d=function(e){function t(){return i(this,t),a(this,t,arguments)}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&u(e,t)}(t,e),n=t,l=[{key:"initClass",value:function(){this.prototype.id="progress-view",this.prototype.className="modal-content",this.prototype.template=o(411105),this.prototype.events={"click #done-btn":"onClickDoneButton","click #next-level-btn":"onClickNextLevelButton","click #start-challenge-btn":"onClickStartChallengeButton","click #map-btn":"onClickMapButton","click #ladder-btn":"onClickLadderButton","click #publish-btn":"onClickPublishButton","click #share-level-btn":"onClickShareLevelButton"}}}],(r=[{key:"initialize",value:function(e){this.level=e.level,this.course=e.course,this.classroom=e.classroom,this.nextLevel=e.nextLevel,this.nextAssessment=e.nextAssessment,this.levelSessions=e.levelSessions,this.session=e.session,this.courseInstanceID=e.courseInstanceID,this.nextLevel.get("description",!0),this.nextLevelDescription=marked(p.i18n(this.nextLevel.attributesWithDefaults,"description").replace(/!\[.*?\]\(.*?\)\n*/g,"")),this.nextAssessment.get("description",!0),this.nextAssessmentDescription=marked(p.i18n(this.nextAssessment.attributesWithDefaults,"description").replace(/!\[.*?\]\(.*?\)\n*/g,"")),this.level.isProject()&&(this.shareURL=g.playDevLevel({level:this.level,session:this.session,course:this.course}))}},{key:"onClickDoneButton",value:function(){return this.trigger("done")}},{key:"onClickNextLevelButton",value:function(){return this.trigger("next-level")}},{key:"onClickStartChallengeButton",value:function(){return this.trigger("start-challenge")}},{key:"onClickPublishButton",value:function(){return this.trigger("publish")}},{key:"onClickMapButton",value:function(){return this.trigger("to-map")}},{key:"onClickLadderButton",value:function(){return this.trigger("ladder")}},{key:"onClickShareLevelButton",value:function(){var e,t;_.string.startsWith(this.course.get("slug"),"game-dev")?(t="Student Game Dev - Copy URL",e="GameDev"):(t="Student Web Dev - Copy URL",e="WebDev");var o={levelID:this.level.id,levelSlug:this.level.get("slug"),classroomID:this.classroom.id,courseID:this.course.id,category:e};return null!=window.tracker&&window.tracker.trackEvent(t,o),this.$("#share-level-input").val(this.shareURL).select(),this.tryCopy()}}])&&s(n.prototype,r),l&&s(n,l),Object.defineProperty(n,"prototype",{writable:!1}),n;var n,r,l}(h)).initClass(),d)},109931:(e,t,o)=>{"use strict";var n,i=o(665420),s=o(619755);function r(e){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},r(e)}function a(e,t){for(var o=0;o<t.length;o++){var n=t[o];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,l(n.key),n)}}function l(e){var t=function(e,t){if("object"!=r(e)||!e)return e;var o=e[Symbol.toPrimitive];if(void 0!==o){var n=o.call(e,t);if("object"!=r(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e,"string");return"symbol"==r(t)?t:t+""}function c(e,t,o){return t=p(t),function(e,t){if(t&&("object"==r(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(e,u()?Reflect.construct(t,o||[],p(e).constructor):t.apply(e,o))}function u(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(u=function(){return!!e})()}function d(){return d="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(e,t,o){var n=h(e,t);if(n){var i=Object.getOwnPropertyDescriptor(n,t);return i.get?i.get.call(arguments.length<3?e:o):i.value}},d.apply(null,arguments)}function h(e,t){for(;!{}.hasOwnProperty.call(e,t)&&null!==(e=p(e)););return e}
1function p(e){return p=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},p(e)}function g(e,t){return g=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},g(e,t)}o(944492);var v=o(921336),m=o(287127),f=o(873813),y=o(28045).me,b=o(992148),w=o(375558),k=o(299498);function S(e,t,o){return null!=e&&"function"==typeof e[t]?o(e,t):void 0}e.exports=((n=function(e){function t(e){var o;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),o=c(this,t,[e]),i.router.initializeSocialMediaServices();var n=e.level.get("victory",!0),s=k.i18n(n,"body")||"Sorry, this level has no victory message yet.";return o.body=marked(s),o.level=e.level,o.session=e.session,o.saveReviewEventually=_.debounce(o.saveReviewEventually,2e3),o.loadExistingFeedback(),o}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&g(e,t)}(t,e),o=t,n=[{key:"loadExistingFeedback",value:function(){var e="/db/level/".concat(this.level.id,"/feedback");return this.feedback=new w,this.feedback.setURL(e),this.feedback.fetch({cache:!1}),this.listenToOnce(this.feedback,"sync",(function(){return this.onFeedbackLoaded()})),this.listenToOnce(this.feedback,"error",(function(){return this.onFeedbackNotFound()}))}},{key:"onFeedbackLoaded",value:function(){return this.feedback.url=function(){return"/db/level.feedback/"+this.id},this.$el.find(".review textarea").val(this.feedback.get("review")),this.$el.find(".review").show(),this.showStars()}},{key:"onFeedbackNotFound",value:function(){return this.feedback=new w,this.feedback.set("levelID",this.level.get("slug")||this.level.id),this.feedback.set("levelName",this.level.get("name")||""),this.feedback.set("level",{majorVersion:this.level.get("version").major,original:this.level.get("original")}),this.showStars()}},{key:"onClickSignupButton",value:function(e){return e.preventDefault(),null!=window.tracker&&window.tracker.trackEvent("Started Signup",{category:"Play Level",label:"Victory Modal",level:this.level.get("slug")}),this.openModalView(new m)}},{key:"onGameSubmitted",value:function(e){var t="/play/ladder/".concat(this.level.get("slug"),"#my-matches");return Backbone.Mediator.publish("router:navigate",{route:t})}},{key:"getRenderData",value:function(){var e=d(p(t.prototype),"getRenderData",this).call(this);return e.body=this.body,e.me=y,e.levelName=k.i18n(this.level.attributes,"name"),e.level=this.level,e.level.isType("ladder")&&(e.readyToRank=this.session.readyToRank()),e}},{key:"afterRender",value:function(){return d(p(t.prototype),"afterRender",this).call(this),this.ladderSubmissionView=new b({session:this.session,level:this.level}),this.insertSubView(this.ladderSubmissionView,this.$el.find(".ladder-submission-view"))}},{key:"afterInsert",value:function(){var e=this;return d(p(t.prototype),"afterInsert",this).call(this),this.playSound("victory"),S("undefined"!=typeof gapi&&null!==gapi?gapi.plusone:void 0,"go",(function(t){return t.go(e.$el[0])})),S("undefined"!=typeof FB&&null!==FB?FB.XFBML:void 0,"parse",(function(t){return t.parse(e.$el[0])})),S(void 0!==window.twttr&&null!==window.twttr?window.twttr.widgets:void 0,"load",(function(e){return e.load()}))}},{key:"destroy",value:function(){return this.$el.find(".review textarea").val()&&this.saveReview(),this.feedback.off(),d(p(t.prototype),"destroy",this).call(this)}},{key:"starNum",value:function(e){return e.prevAll("i").length+1}},{key:"showStars",value:function(e){this.$el.find(".rating").show(),null==e&&(e=(null!=this.feedback?this.feedback.get("rating"):void 0)||0);var t=this.$el.find(".rating i");return t.removeClass("icon-star").addClass("icon-star-empty"),t.slice(0,e).removeClass("icon-star-empty").addClass("icon-star")}},{key:"setStars",value:function(e){return this.feedback.set("rating",e),this.feedback.save()}},{key:"saveReviewEventually",value:function(){return this.saveReview()}},{key:"saveReview",value:function(){return this.feedback.set("review",this.$el.find(".review textarea").val()),this.feedback.save()}}],r=[{key:"initClass",value:function(){this.prototype.id="level-victory-modal",this.prototype.template=f,this.prototype.subscriptions={"ladder:game-submitted":"onGameSubmitted"},this.prototype.events={"click .sign-up-button":"onClickSignupButton","mouseover .rating i":function(e){return this.showStars(this.starNum(s(e.target)))},"mouseout .rating i":function(){return this.showStars()},"click .rating i":function(e){return this.setStars(this.starNum(s(e.target))),this.$el.find(".review").show()},"keypress .review textarea":function(){return this.saveReviewEventually()}}}}],n&&a(o.prototype,n),r&&a(o,r),Object.defineProperty(o,"prototype",{writable:!1}),o;var o,n,r}(v)).initClass(),n)},439610:(e,t,o)=>{"use strict";var n=o(619755);Object.defineProperty(t,"X",{value:!0}),t.Z=void 0;var i=r(o(299498)),s=r(o(572269));
1function r(e){return e&&e.__esModule?e:{default:e}}t.Z=Vue.extend({props:{levelSlug:{type:String,required:!0},courseInstanceID:{type:String,required:!0},courseID:{type:String,required:!0},codeLanguage:{type:String},levelOriginalID:{type:String,required:!0}},metaInfo:function(){return{title:this.$t("play.video_title",{video:this.videoData.title}),link:[{vmid:"rel-canonical",rel:"canonical",content:"/play"}]}},data:function(){return{originalDisplaySettings:{}}},components:{"flat-layout":s.default},mounted:function(){this.$nextTick((function(){this.originalDisplaySettings={"main-nav":n("#main-nav")[0]?n("#main-nav")[0].style.display:"",footer:n("#footer")[0]?n("#footer")[0].style.display:"","final-footer":n("#final-footer")[0]?n("#final-footer")[0].style.display:""},n("#main-nav")[0]&&(n("#main-nav")[0].style.display="none"),n("#footer")[0]&&(n("#footer")[0].style.display="none"),n("#final-footer")[0]&&(n("#final-footer")[0].style.display="none")}))},beforeDestroy:function(){n("#main-nav")[0]&&(n("#main-nav")[0].style.display=this.originalDisplaySettings["main-nav"]),n("#footer")[0]&&(n("#footer")[0].style.display=this.originalDisplaySettings.footer),n("#final-footer")[0]&&(n("#final-footer")[0].style.display=this.originalDisplaySettings["final-footer"])},computed:{videoData:function(){return i.default.videoLevels[this.levelOriginalID]||{}},videoUrl:function(){return me.showChinaVideo()?this.videoData.cn_url:this.videoData.url},nextLevelLink:function(){var e="";return me.isSessionless()?(e="/play/level/"+this.levelSlug+"?course="+this.courseID+"&codeLanguage=",e+=this.codeLanguage||"python"):(e="/play/level/"+this.levelSlug+"?course="+this.courseID+"&course-instance="+this.courseInstanceID,this.codeLanguage&&(e+="&codeLanguage="+this.codeLanguage)),e}},methods:{onNextLevel:function(){window.tracker&&window.tracker.trackEvent("Play Video Next Level",{category:"Students",videoTitle:this.videoData.title,nextLevelSlug:this.levelSlug},[])},onSkip:function(){window.tracker&&window.tracker.trackEvent("Play Video Skip",{category:"Students",videoTitle:this.videoData.title,nextLevelSlug:this.levelSlug},[])}}})},453857:e=>{"use strict";e.exports=Vue.extend({props:{levelSlug:{type:String,required:!0,default:""}},computed:{playLink:function(){return"/play/level/".concat(this.levelSlug)}}})},434700:(e,t)=>{"use strict";t.xk=t.sY=void 0,t.sY=function(){var e=this,t=e._self._c;return e._self._setupProxy,t("div",[t("p",[e._v("Hello! This is where a cinematic would play, but all you got was this placeholder... :)")]),e._v(" "),t("a",{attrs:{href:e.playLink}},[e._v("Go back to play more")])])},t.xk=[]},240689:(e,t)=>{"use strict";t.xk=t.sY=void 0,t.sY=function(){var e=this,t=e._self._c;return e._self._setupProxy,t("flat-layout",[t("div",{staticClass:"play-level-video-container container"},[t("div",{staticClass:"video-background container"},[t("div",{staticClass:"row title-row"},[e.videoData?t("div",{staticClass:"col-sm-12"},[t("h3",{staticClass:"text-center text-uppercase video-title"},[e._v(e._s(e.$t("play_level.concept_unlocked"))+" : "+e._s(e.$t("courses.".concat(e.videoData.i18name))))])]):e._e()]),t("div",{staticClass:"row video-row"},[e.videoData?t("div",{staticClass:"col-sm-12 video-col"},[t("iframe",{staticClass:"video",attrs:{src:e.videoUrl,frameborder:"0",webkitallowfullscreen:"",mozallowfullscreen:"",allowfullscreen:""}})]):e._e()]),t("div",{staticClass:"row buttons-row"},[t("div",{staticClass:"col-sm-10"}),t("div",{staticClass:"col-sm-2 text-uppercase"},[t("a",{staticClass:"btn-illustrated btn-success btn-block btn-lg btn",attrs:{id:"next-level-btn",href:e.nextLevelLink},on:{click:e.onSkip}},[e._v(e._s(e.$t("play_level.next_level")))])])]),t("img",{staticClass:"img-unlocked",attrs:{src:"/images/pages/play/modal/unlocked_banner.png"}})])])])},t.xk=[]},732035:(e,t)=>{"use strict";t.xk=t.sY=void 0,t.sY=function(){var e=this,t=e._self._c;return t("div",{staticClass:"modal-content",attrs:{id:"course-victory-component"}},[t("div",{staticClass:"modal-header"},[t("img",{staticClass:"header-img",attrs:{src:e.headerImage}}),e._m(0)]),t("div",{staticClass:"modal-body"},[t("div",{staticClass:"container-fluid"},[t("div",{staticClass:"row"},[t("div",{staticClass:"col-sm-12"},["cumulative"===e.level.assessment?t("div",{staticClass:"clearfix well well-sm well-parchment combo-results"},[t("div",{staticClass:"text-center text-uppercase left-column"},[t("div",{staticClass:"pie-container"},[t("pie-chart",{attrs:{percent:e.percentConceptsCompleted,"stroke-width":10,
1color:"#20572B",opacity:1,borderStrokeWidth:0}}),t("img",{staticClass:"combo-img",attrs:{src:e.comboImage}})],1),t("h5",[e._v(e._s(e.$t("play_level.combo_concepts_used",{complete:e.conceptGoalsCompleted,total:e.conceptGoals.length})))])]),t("div",[t("h3",{staticClass:"text-uppercase"},[e._v(e._s(e.$t("play_level.combo_challenge_complete")))]),e.allConceptsUsed?t("div",[e._v(e._s(e.$t("play_level.combo_all_concepts_used")))]):t("div",[e._v(e._s(e.$t("play_level.combo_not_all_concepts_used",{complete:e.conceptGoalsCompleted,total:e.conceptGoals.length})))])])]):e.level.assessment?t("div",{staticClass:"clearfix well well-sm well-parchment",attrs:{id:"level-status"}},[t("h3",{staticClass:"text-uppercase"},[e._v(e._s(e.$t("play_level.concept_challenge_complete")))]),t("img",{staticClass:"hero-img",attrs:{src:e.heroImage}}),e.inExam?e._e():t("div",[e._v(e._s(e.$t("play_level.combo_challenge_complete_body",{concept:e.primaryConcept})))])]):e.assessmentNext?t("div",{staticClass:"clearfix well well-sm well-parchment"},[t("img",{staticClass:"lock-banner",attrs:{src:"/images/pages/play/modal/unlocked_banner.png"}}),t("h5",{staticClass:"text-uppercase"},["cumulative"===e.nextAssessment.assessment?t("span",[e._v(e._s(e.$t("play_level.combo_challenge_unlocked"))+":")]):t("span",[e._v(e._s(e.$t("play_level.concept_challenge_unlocked"))+":")])]),t("h3",{staticClass:"text-uppercase"},[e._v(e._s(e.$dbt(e.nextAssessment,"name")))]),t("div",{staticClass:"no-imgs",domProps:{innerHTML:e._s(e.marked(e.$dbt(e.nextAssessment,"description")))}})]):t("div",{staticClass:"clearfix well well-sm well-parchment",attrs:{id:"level-status"}},[t("h3",{staticClass:"text-uppercase"},[e._v(e._s(e.$t("play_level.level_complete"))+" "+e._s(e.inExam?"":": "+e.$dbt(e.level,"name")))]),t("img",{staticClass:"hero-img",attrs:{src:e.heroImage}}),e.level.victory&&!e.inExam?t("div",[e._v(e._s(e.$dbt(e.level.victory,"body")))]):e._e()])])]),"cumulative"!==e.level.assessment||e.inExam?!e.assessmentNext||e.level.assessment||e.inExam?e._e():t("div",{staticClass:"row"},[t("div",{staticClass:"col-sm-6 col-sm-offset-6"},[t("a",{staticClass:"btn btn-illustrated btn-success btn-block btn-lg btn-glow text-uppercase",attrs:{id:"start-challenge-btn",href:e.challengeLink},on:{click:e.onStartChallenge}},[e._v(e._s(e.$t("play_level.start_challenge")))])])]):t("div",{staticClass:"row"},[t("div",{staticClass:"col-sm-5 col-sm-offset-7"},[t("button",{staticClass:"btn btn-illustrated btn-default btn-block btn-lg text-uppercase",attrs:{id:"replay-level-btn"},on:{click:e.onReplayLevel}},[e._v(e._s(e.$t("play_level.replay_level")))])])]),e.inExam?e._e():t("div",{staticClass:"row"},[t("div",{staticClass:"col-sm-6 text-uppercase"},[t("div",{staticClass:"well well-sm well-parchment"},[t("h5",[e._v(e._s(e.$t("play_level.completed_level")))]),t("h3",[e._v(e._s(e.$dbt(e.level,"name")))]),t("h5",[e._v(e._s(e.$dbt(e.course,"name")))]),e.stats?t("h3",[e._v("Levels Complete: "+e._s(e.stats.levels.numDone)+"/"+e._s(e.stats.levels.size))]):e._e()])]),e.nextLevelVideo?t("div",{staticClass:"col-sm-6"},[t("div",{staticClass:"well well-sm well-parchment"},[t("h5",{staticClass:"text-uppercase"},[e._v(e._s(e.$t("play.next"))+":")]),t("h3",{staticClass:"text-uppercase"},[e._v(e._s(e.$t("play_level.learn_new_concepts")))]),t("h5",{staticClass:"text-uppercase"},[e._v(e._s(e.$t("play_level.watch_a_video",{concept_name:e.nextLevelVideo.title})))])])]):e.nextLevel._id?t("div",{staticClass:"col-sm-6"},[t("div",{staticClass:"well well-sm well-parchment"},[t("h5",{staticClass:"text-uppercase"},[e._v(e._s(e.$t("play_level.next_level"))+":")]),t("h3",{staticClass:"text-uppercase"},[e._v(e._s(e.$dbt(e.nextLevel,"name")))]),t("div",{staticClass:"no-imgs",domProps:{innerHTML:e._s(e.marked(e.$dbt(e.nextLevel,"description")))}})])]):e._e()]),e.inExam?t("div",{staticClass:"row"},[t("div",{staticClass:"col-sm-12 text-uppercase"},[t("a",{staticClass:"btn btn-illustrated btn-success btn-grow btn-block btn-lg text-uppercase",on:{click:e.onReturnExam}},[e._v(e._s(e.$t("exams.return_to_exam")))])])]):t("div",{staticClass:"row"},[t("div",{staticClass:"col-sm-6 text-uppercase"},[t("a",{staticClass:"btn btn-illustrated btn-block btn-lg text-uppercase",attrs:{id:"map-btn",href:e.mapLink},on:{click:e.onBackToMap}},[e._v(e._s(e.$t("play_level.back_to_map")))])]),e.nextLevelVideo?t("div",{staticClass:"col-sm-6 text-uppercase"},[t("a",{staticClass:"btn btn-illustrated btn-block btn-lg text-uppercase",class:e.nextLevelLinkClasses,attrs:{id:"next-level-btn",href:e.nextLevelVideoLink},on:{click:e.onNextLevelVideo}},[e._v(e._s(e.$t("play.next")))])]):e.nextLevel._id?t("div",{staticClass:"col-sm-6 text-uppercase"},[t("a",{staticClass:"btn btn-illustrated btn-block btn-lg text-uppercase",class:e.nextLevelLinkClasses,attrs:{id:"next-level-btn",href:e.nextLevelLink},on:{click:e.onNextLevel}}
1,[e._v(e._s(e.$t("play_level.next_level")))])]):e._e()])])])])},t.xk=[function(){var e=this._self._c;return e("div",{staticClass:"btn well well-sm well-parchment",attrs:{id:"close-modal","data-dismiss":"modal"}},[e("span",{staticClass:"glyphicon glyphicon-remove"})])}]},225976:(e,t,o)=>{var n,i,s,r,a,l,c,u,d,h,p,g,v,m=o(619755),f=o(665420),y={}.hasOwnProperty,b=[].indexOf||function(e){for(var t=0,o=this.length;t<o;t++)if(t in this&&this[t]===e)return t;return-1};o(401778),o(969278),r=o(968029),p=o(635574),h=o(28045).me,v=o(299498),g=o(482156),i=o(967950),s=o(609838),a=o(573131),l=o(864481),u=o(487658),d=o(994587),c=o(287127),n=o(180908).Z,e.exports=function(e){function t(e){var o,n,r;this.supermodel=e.supermodel,this.courseID=e.courseID,this.courseInstanceID=e.courseInstanceID,this.parentCampaign=e.parentCampaign,this.worldName=e.worldName,this.session=e.session,this.level=e.level,this.levelSlug=this.level.get("slug"),this.levelID=this.levelSlug||this.level.id,this.spectateGame=null!=(n=e.spectateGame)&&n,this.observing=e.session.get("creator")!==h.id,this.product=this.level.attributes.product,this.lastOverallStatus=null,this.aceConfig=e.classroomAceConfig||{},this.showAiBotHelp=v.shouldShowAiBotHelp(this.aceConfig),g.getStorageExam()&&(this.examLevelNumber=g.levelNumberInExam(this.level.get("slug")),this.inExam=0!==this.examLevelNumber),this.levelNumber="",this.level.isType("course","game-dev","web-dev")&&null!=this.level.get("campaignIndex")&&(this.levelNumber=this.level.get("campaignIndex")+1),this.courseInstanceID?(this.courseInstance=new l({_id:this.courseInstanceID}),o=this.courseInstance.fetch(),this.supermodel.trackRequest(o),new Promise(o.then).then((r=this,function(){return r.classroom=new s({_id:r.courseInstance.get("classroomID")}),r.course=new a({_id:r.courseInstance.get("courseID")}),r.supermodel.trackRequest(r.classroom.fetch()),r.supermodel.trackRequest(r.course.fetch())}))):this.courseID&&(this.course=new a({_id:this.courseID}),o=this.course.fetch(),this.supermodel.trackRequest(o),new Promise(o.then).then(function(e){return function(){return e.campaign=new i({_id:e.course.get("campaignID")}),e.supermodel.trackRequest(e.campaign.fetch())}}(this))),t.__super__.constructor.call(this,e),this.level.get("replayable")&&this.listenTo(this.session,"change-difficulty",this.onSessionDifficultyChanged)}return function(e,t){for(var o in t)y.call(t,o)&&(e[o]=t[o]);function n(){this.constructor=e}n.prototype=t.prototype,e.prototype=new n,e.__super__=t.prototype}(t,e),t.prototype.id="control-bar-view",t.prototype.template=p,t.prototype.subscriptions={"level:disable-controls":"onDisableControls","level:enable-controls":"onEnableControls","level:overallStatus-changed":"onOverallStatusChanged","ipad:memory-warning":"onIPadMemoryWarning"},t.prototype.events={"click #next-game-button":function(){return Backbone.Mediator.publish("level:next-game-pressed",{})},"click #game-menu-button":"showGameMenuModal",click:function(){return Backbone.Mediator.publish("tome:focus-editor",{})},"click .levels-link-area":"onClickHome","click .home a":"onClickHome","click #control-bar-sign-up-button":"onClickSignupButton",'click [data-toggle="coco-modal"][data-target="core/CreateAccountModal"]':"openCreateAccountModal","click .hints-button":"onClickHintsButton","click .ai-help-button":"onClickAIHelp"},t.prototype.setLevelName=function(e){return this.levelName=e,this.render()},t.prototype.onLoaded=function(){var e,o;return this.inExam&&this.setLevelName(m.i18n.t("exams.level_num",{num:this.examLevelNumber})),this.classroom?(this.levelNumber=this.classroom.getLevelNumber(this.level.get("original"),this.levelNumber,this.courseID),e=this.classroom.get("classroomItems",!0),o=h.lastClassroomItems(),h.setLastClassroomItems(this.classroom.get("classroomItems",!0)),e!==o&&this.level.isType("course")&&(h.setLastClassroomItems(e),noty({text:"Classroom items & gems setting changed; reloading",layout:"topCenter",type:"success",killer:!1,timeout:2e3}),_.delay((function(){return document.location.reload()}),2e3))):this.campaign&&(this.levelNumber=this.campaign.getLevelNumber(this.level.get("original"),this.levelNumber)),f.getHocCampaign()&&(this.levelNumber=null),t.__super__.onLoaded.call(this)},t.prototype.openCreateAccountModal=function(e){return e.stopPropagation(),this.openModalView(new c)},t.prototype.setBus=function(e){this.bus=e},t.prototype.getRenderData=function(e){var o,n,i,s,r,a,l,c,u;return null==e&&(e={}),t.__super__.getRenderData.call(this,e),e.worldName=this.worldName,e.ladderGame=this.level.isLadder(),this.level.get("replayable")&&(e.levelDifficulty=null!=(a=null!=(l=this.session.get("state"))?l.difficulty:void 0)?a:0,this.observing&&(e.levelDifficulty=Math.max(0,e.levelDifficulty-1)),e.difficultyTitle=""+m.i18n.t("play.level_difficulty")+e.levelDifficulty,this.lastDifficulty=e.levelDifficulty),e.spectateGame=this.spectateGame,e.observing=this.observing,e.product=this.product,e.lastOverallStatus=this.lastOverallStatus,this.homeViewArgs=[{supermodel:this.hasReceivedMemoryWarning?null:this.supermodel}],(n=f.getHocCampaign())&&!this.level.isLadder()?(this.homeLink="/play/"+n,this.homeViewClass="views/play/CampaignView",this.homeViewArgs.push(n)):h.isSe
1ssionless()?(this.homeLink=v.sessionlessCoursesUrl(this.product),this.homeViewClass=null):this.level.isLadder()?(r=(null!=(c=this.level.get("slug"))?c.replace(/\-tutorial$/,""):void 0)||this.level.id,this.homeLink="/play/ladder/"+r,this.homeViewClass="views/ladder/LadderView",this.homeViewArgs.push(r),(i=v.getQueryVariable("league")||v.getQueryVariable("course-instance"))&&(s=this.level.isType("course-ladder")||this.level.isType("ladder")&&v.getQueryVariable("course-instance")?"course":"clan",this.homeViewArgs.push(s),this.homeViewArgs.push(i),this.homeLink+="/"+s+"/"+i,(u=v.getQueryVariable("tournament"))&&(this.homeLink+="?tournament="+u))):this.level.isType("course")||this.courseID?(this.homeLink="/play",null!=this.course&&(this.homeLink+="/"+this.course.get("campaignID"),this.homeViewArgs.push(this.course.get("campaignID"))),this.courseInstanceID&&(this.homeLink+="?course-instance="+this.courseInstanceID),this.homeViewClass="views/play/CampaignView"):this.level.isType("hero","hero-coop","game-dev","web-dev")?(this.homeLink="/play",this.homeViewClass="views/play/CampaignView",o=this.parentCampaign||this.level.get("campaign"),this.homeLink+="/"+o,this.homeViewArgs.push(o)):(this.homeLink="/",this.homeViewClass="views/HomeView"),e.editorLink="/editor/level/"+(this.level.get("slug")||this.level.id),e.homeLink=this.homeLink,e},t.prototype.showGameMenuModal=function(e,t){var o;return null==t&&(t=null),Backbone.Mediator.publish("tome:game-menu-opened",{}),o=new u({level:this.level,session:this.session,supermodel:this.supermodel,showTab:t,classroomAceConfig:this.options.classroomAceConfig,hintsState:this.options.hintsState,teacherID:this.options.teacherID,team:this.team,courseID:this.courseID,courseInstanceID:this.courseInstanceID}),this.openModalView(o),this.listenToOnce(o,"change-hero",(function(){var e;return null!=(e=this.setupManager)&&e.destroy(),this.setupManager=new d({supermodel:this.supermodel,level:this.level,levelID:this.levelID,parent:this,session:this.session,courseID:this.courseID,courseInstanceID:this.courseInstanceID,classroom:this.classroom}),this.setupManager.open()}))},t.prototype.onClickHome=function(e){var t,o,n;return this.level.isType("course")&&(t=h.isTeacher()?"Teachers":"Students",null!=(n=window.tracker)&&n.trackEvent("Play Level Back To Levels",{category:t,levelSlug:this.levelSlug})),e.preventDefault(),e.stopImmediatePropagation(),o={route:this.homeLink,viewArgs:this.homeViewArgs},this.homeViewClass&&(o.viewClass=this.homeViewClass),Backbone.Mediator.publish("router:navigate",o)},t.prototype.onClickSignupButton=function(e){var t;return null!=(t=window.tracker)?t.trackEvent("Started Signup",{category:"Play Level",label:"Control Bar",level:this.levelID}):void 0},t.prototype.onClickHintsButton=function(){var e,t,o;if(null!=this.options.hintsState)return Backbone.Mediator.publish("level:hints-button",{state:this.options.hintsState.get("hidden")}),this.options.hintsState.set("hidden",!this.options.hintsState.get("hidden")),null!=(e=window.tracker)?e.trackEvent("Hints Clicked",{category:"Students",levelSlug:this.levelSlug,hintCount:null!=(t=null!=(o=this.options.hintsState.get("hints"))?o.length:void 0)?t:0}):void 0},t.prototype.onClickAIHelp=function(){return this.openModalView(new n({propsData:{aiChatKind:this.level.get("aiChatKind")}}))},t.prototype.onOverallStatusChanged=function(e){if((null!=e?e.overallStatus:void 0)!==this.lastOverallStatus)return this.lastOverallStatus=e.overallStatus,this.render()},t.prototype.onDisableControls=function(e){return this.toggleControls(e,!1)},t.prototype.onEnableControls=function(e){return this.toggleControls(e,!0)},t.prototype.toggleControls=function(e,t){if((!e.controls||b.call(e.controls,"level")>=0)&&t!==this.controlsEnabled)return this.controlsEnabled=t,this.$el.toggleClass("controls-disabled",!t)},t.prototype.onIPadMemoryWarning=function(e){return this.hasReceivedMemoryWarning=!0},t.prototype.onSessionDifficultyChanged=function(){var e;if((null!=(e=this.session.get("state"))?e.difficulty:void 0)!==this.lastDifficulty)return this.render()},t.prototype.destroy=function(){var e;return null!=(e=this.setupManager)&&e.destroy(),t.__super__.destroy.call(this)},t}(r)},162466:(e,t,o)=>{var n,i=o(619755);n=o(299498),e.exports=function(){function e(e,t){var o,s;this.jqueryElement=t,(null!=(s=me.get("aceConfig"))?s.screenReaderMode:void 0)&&n.isOzaria?this.jqueryElement.html(e):(o=i("<div></div>").html(e),this.childrenToAdd=_.map(o[0].childNodes,(function(e){return e})),this.t0=new Date,this.charsAdded=0,this.charsPerSecond=27)}return e.prototype.jqueryElement=null,e.prototype.childrenToAdd=null,e.prototype.charsToAdd=null,e.prototype.childAnimator=null,e.prototype.tick=function(){if(this.charsToAdd||this.childAnimator||this.addNextElement(),!this.charsToAdd)return this.childAnimator&&(this.childAnimator.tick(),this.childAnimator.done())?this.childAnimator=null:void 0;this.addSingleChar()},e.prototype.addNextElement=function(){var t,o,n;if(this.childrenToAdd.length)return o=this.childrenToAdd[0],this.childrenToAdd=this.childrenToAdd.slice(1),"#text"===o.nodeName?this.charsToAdd=o.nodeValue:(n=o.innerHTML,t=i(o).html(""),this.jqueryElement.append(t),n?(this.childAnimator&&(this.charsAdded+=this.childAnimator.getCharsAdded()),this.childAnimator=new e(n,t)):void 0)},e.prototype.addSingleChar=function(){var e,t,o,n;return e=new Date-this.t0,t=this.getCharsAdded(),n=Math.round(this.charsPerSecond*e/1e3),o=Math.min(n-t,this.charsToAdd.length),this.jqueryElement.html(this.jqueryElement.html()+this.charsToAdd.slice(0,o)),this.charsToAdd=this.charsToAdd.slice(o),0===this.charsToAdd.length&&(this.charsToAdd=null),this.charsAdded+=o},e.prototype.getCharsAdded=function(){var e,t;return this.charsAdded+(null!=(e=null!=(t=this.childAnimator)?t.charsAdded:void 0)?e:0)},e.prototype.done=function(){var e;return!((null!=(e=this.childrenToAdd)?e.length:void 0)>0||this.charsToAdd||this.childAnimator)},e}()},662915:(e,t,o)=>{var n,i,s,r,a=o(619755),l={}.hasOwnProperty,c=[].indexOf||function(e){for(var t=0,o=this.length;t<o;t++)if(t in this&&this[t]===e)return t;return-1};o(888172),n=o(968029),s=o(826526),i=o(16190),r=o(299498),e.exports=function(e){function t(e){var o,n;t.__super__.constructor.call(this,e),e.thangs=_.filter(e.thangs,"inThangList"),e.otherSession||(e.otherSession={get:function(t){return{creatorName:a.i18n.t("ladder.simple_ai"),creator:me.get("_id"),team:"humans"===e.session.get("team")?"ogres":"humans",heroConfig:e.session.get("heroConfig")}[t]}}),this.showsPower="wakka-maul"!==(o=e.level.get("slug"))&&"cross-bones"!==o&&"dueling-grounds"!==o&&"cavern-survival"!==o&&"multiplayer-treasure-grove"!==o,this.teamGold={},this.players=function(){var e,t,o,i;for(i=[],e=0,t=(o=["humans","ogres"]).length;e<t;e++)n=o[e],i.push(this.formatPlayer(n));return i}.call(this)}return function(e,t){for(var o in t)l.call(t,o)&&(e[o]=t[o]);function n(){this.constructor=e}n.prototype=t.prototype,e.prototype=new n,e.__super__=t.prototype}(t,e),t.prototype.id="duel-stats-view",t.prototype.template=s,t.prototype.subscriptions={"surface:gold-changed":"onGoldCh
1anged","god:new-world-created":"onNewWorld","god:streaming-world-updated":"onNewWorld","surface:frame-changed":"onFrameChanged","sprite:speech-updated":"onSpriteDialogue","level:sprite-clear-dialogue":"onSpriteClearDialogue"},t.prototype.formatPlayer=function(e){var t,o,n;return t={team:e},n=_.find([this.options.session,this.options.otherSession],(function(t){return t.get("team")===e})),t.name=r.getCorrectName(n),t.heroThangType=(null!=(o=n.get("heroConfig"))?o:{}).thangType||"529ffbf1cf1818f2be000001",t.heroID="ogres"===e?"Hero Placeholder 1":"Hero Placeholder",t},t.prototype.afterRender=function(){var e,o,n,i;for(t.__super__.afterRender.call(this),e=0,o=(i=this.players).length;e<o;e++)n=i[e],this.buildAvatar(n.heroID,n.team);return this.$el.css("display","flex")},t.prototype.buildAvatar=function(e,t){var o,n;if(null==this.avatars&&(this.avatars={}),!this.avatars[t]&&(n=_.find(this.options.thangs,{id:e})))return this.avatars[t]=o=new i({thang:n,includeName:!1,supermodel:this.supermodel}),this.$find(t,".thang-avatar-placeholder").replaceWith(o.$el),o.render()},t.prototype.onNewWorld=function(e){return this.options.thangs=_.filter(e.world.thangs,"inThangList")},t.prototype.onFrameChanged=function(e){return this.update()},t.prototype.update=function(){var e,t,o,n,i,s,r,a;for(e=0,t=(n=this.players).length;e<t;e++)o=n[e],(a=_.find(this.options.thangs,{id:null!=(i=this.avatars)&&null!=(s=i[o.team])&&null!=(r=s.thang)?r.id:void 0}))&&this.updateHealth(a);if(this.showsPower)return this.updatePower()},t.prototype.updateHealth=function(e){var t;return(t=this.$find(e.team,".player-health")).find(".health-bar").css("width",Math.max(0,Math.min(100,100*e.health/e.maxHealth))+"%"),r.replaceText(t.find(".health-value"),Math.round(e.health))},t.prototype.updatePower=function(){var e,t,o,n,i,s,a,l,u,d,h,p,g,v,m,f,y,b,w;for(null==this.costTable&&(this.costTable={soldier:20,archer:25,decoy:25,"griffin-rider":50,paladin:80,artillery:75,"arrow-tower":100,palisade:10,peasant:50,thrower:9,scout:18}),u={humans:0,ogres:0},b=[],t=0,i=(d=this.players).length;t<i;t++)l=d[t],(e=_.find(this.options.thangs,{id:null!=(h=this.avatars)&&null!=(p=h[l.team])&&null!=(g=p.thang)?g.id:void 0}))&&null!=e.teamPower&&null!=u[e.team]&&(u[e.team]=e.teamPower,b.push(e.team));for(o=0,s=(v=this.options.thangs).length;o<s;o++)m=(w=v[o]).team,c.call(b,m)<0&&w.health>0&&w.exists&&null!=u[w.team]&&(u[w.team]+=this.costTable[w.type]||0);for(y=[],n=0,a=(f=this.players).length;n<a;n++)l=f[n],y.push(r.replaceText(this.$find(l.team,".power-value"),u[l.team]));return y},t.prototype.$find=function(e,t){return this.$el.find(".player-container.team-"+e+" "+t)},t.prototype.destroy=function(){var e,o,n;for(n in o=null!=(e=this.avatars)?e:{})o[n].destroy();return t.__super__.destroy.call(this)},t.prototype.onGoldChanged=function(e){if(this.options.showsGold&&this.teamGold[e.team]!==e.gold)return this.teamGold[e.team]=e.gold,r.replaceText(this.$find(e.team,".gold-value"),""+e.gold)},t.prototype.onSpriteDialogue=function(e){if(e.message)return this.$el.css("display","none")},t.prototype.onSpriteClearDialogue=function(){return this.$el.css("display","flex")},t}(n)},39943:(e,t,o)=>{var n,i,s={}.hasOwnProperty;o(106307),n=o(968029),i=o(778613),e.exports=function(e){function t(e){t.__super__.constructor.call(this,e),this.listings={}}return function(e,t){for(var o in t)s.call(t,o)&&(e[o]=t[o]);function n(){this.constructor=e}n.prototype=t.prototype,e.prototype=new n,e.__super__=t.prototype}(t,e),t.prototype.id="game-dev-track-view",t.prototype.template=i,t.prototype.subscriptions={"surface:frame-changed":"onFrameChanged","playback:real-time-playback-started":"onRealTimePlaybackStarted","playback:real-time-playback-ended":"onRealTimePlaybackEnded"},t.prototype.onFrameChanged=function(e){var t,o,n,i,s,r,a,l,c,u,d,h,p,g,v,m,f,y,b,w,k,S,C,x,T,P,L;if(this.listings={},g=null!=(m=e.world.uiText)?m.scoreLabel:void 0,e.world.synchronous){for(o=0,a=(f=e.world.thangs).length;o<a;o++)if("Hero Placeholder"===(w=f[o]).id&&(t=w),L=w.uiTrackedProperties)for(n=0,l=L.length;n<l;n++)p=L[n],this.listings[null!=g?g:p]=w[p];if(t&&t.objTrackedProperties)for(i=0,c=(y=t.objTrackedProperties).length;i<c;i++)p=y[i],this.listings[null!=g?g:p]=t["__"+p]}else for(s in S=null!=(b=e.world.frames[e.frame])?b.thangStateMap:void 0)if((k=S[s]).trackedPropertyKeys){if(-1!==(P=k.trackedPropertyKeys.indexOf("uiTrackedProperties"))&&(T=k.props[P]))for(r=0,u=T.length;r<u;r++)p=T[r],-1!==(v=k.trackedPropertyKeys.indexOf(p))&&(this.listings[null!=g?g:p]=k.props[v]);if("Hero Placeholder"===s&&-1!==(x=k.trackedPropertyKeys.indexOf("objTrackedProperties")))for(h=0,d=(C=k.props[x]).length;h<d;h++)p=C[h],-1!==(v=k.trackedPropertyKeys.indexOf("__"+p))&&(this.listings[null!=g?g:p]=k.props[v])}return _.isEqual(this.listings,{})?this.$el.hide():(this.$el.show(),this.renderSelectors("#listings"))},t.prototype.onRealTimePlaybackStarted=function(e){return this.$el.addClass("playback-float-right")},t.prototype.onRealTimePlaybackEnded=function(e){return this.$el.removeClass("playback-float-right")},t.prototype.titleize=function(e){return _.string.titleize(_.string.humanize(e))},t.prototype.beautify=function(e,t){return"object"==typeof t&&null!=t.x&&null!=t.y&&null!=t.z?"x: "+Math.round(t.x)+"\ny: "+Math.round(t.y):"number"==typeof t?Math.round(t):null!=t?t:""},t}(n)},2912:(e,t,o)=>{var n,i={}.hasOwnProperty;n=o(554521),e.exports=function(e){function t(){return t.__super__.constructor.apply(this,arguments)}return function(e,t){for(var o in t)i.call(t,o)&&(e[o]=t[o]);function n(){this.constructor=e}n.prototype=t.prototype,e.prototype=new n,e.__super__=t.prototype}(t,Backbone.Model),t.prototype.initialize=function(e,t){return this.level=t.level,this.session=t.session,this.supermodel=t.supermodel,this.listenTo(this.level,"change:documentation",this.update),this.update()},t.prototype.getHint=function(e){var t;return null!=(t=this.get("hints"))?t[e]:void 0},t.prototype.update=function(){var e,t,o,i,s,r,a,l;return e=this.supermodel.getModels(n),o=null!=(r=this.level.get("documentation"))?r:{},i=_.filter(function(){var n,i,s,r,a;for(a=[],n=0,i=(s=o.generalArticles||[]).length;n<i;n++)t=s[n],a.push(null!=(r=_.find(e,(function(e){return e.get("original")===t.original})))?r.attributes:void 0);return a}()),a=o.specificArticles||[],s=(o.hintsB||o.hints||[]).concat(a).concat(me.useGeneralArticle()?i:[]),s=_.sortBy(s,(function(e){return"Intro"===e.name?-1:0})),l=_.size(s),this.set({hints:s,total:l})},t}()},159962:(e,t,o)=>{var n,i,s,r,a,l,c,u,d=o(619755),h=function(e,t){return function(){return e.apply(t,arguments)}},p={}.hasOwnProperty;i=o(968029),s=o(365117),o(385899),u=o(299498),r=o(367906),a=o(261174),c=o(482156),l=o(504015),n=o(180908).Z,e.exports=function(e){function t(){return this.incrementHintViewTime=h(this.incrementHintViewTime,this),t.__super__.constructor.apply(this,arguments)}return function(e,t){for(var o in t)p.call(t,o)&&(e[o]=t[o]);function n(){this.constructor=e}n.prototype=t.prototype,e.prototype=new n,e.__super__=t.prototype}(t,e),t.prototype.template=o(346741),t.prototype.className="hints-view",t.prototype.hintUsedThresholdSeconds=10,t.prototype.events={"click .next-btn":"onClickNextButton","click .previous-btn":"onClickPreviousButton","click .close-hint-btn":"hideView","click .ai-help-button":"onAIHelpClicked"}
1,t.prototype.subscriptions={"level:show-victory":"hideView","tome:manual-cast":"hideView","auth:user-credits-message-updates":"onUserCreditsMessageUpdates"},t.prototype.initialize=function(e){var t;return this.level=e.level,this.session=e.session,this.hintsState=e.hintsState,this.aceConfig=e.aceConfig||{},this.state=new s({hintIndex:0,hintsViewTime:{},hintsUsed:{}}),this.updateHint(),t=_.debounce(this.render),this.listenTo(this.state,"change",t),this.listenTo(this.hintsState,"change",t),this.listenTo(this.state,"change:hintIndex",this.updateHint),this.listenTo(this.hintsState,"change:hidden",this.visibilityChanged),l.userCreditsMessage||(l.userCredtisMessage=""),this.creditMessage=l.userCreditsMessage,this.showAiBotHelp=u.shouldShowAiBotHelp(this.aceConfig)},t.prototype.destroy=function(){return clearInterval(this.timerIntervalID),t.__super__.destroy.call(this)},t.prototype.handleUserCreditsMessage=function(){return c.updateUserCreditsMessage()},t.prototype.onUserCreditsMessageUpdates=function(){return this.creditMessage=l.userCreditsMessage,this.render()},t.prototype.afterRender=function(){var e,o,n,i,s,a,l;for(this.$el.toggleClass("hide",this.hintsState.get("hidden")),this.$('[data-toggle="popover"]').popover(),me.showChinaResourceInfo()||this.creditMessage||this.handleUserCreditsMessage(),t.__super__.afterRender.call(this),this.playSound("game-menu-open"),this.$("a").attr("target","_blank"),o=this.options.session.get("codeLanguage")||(null!=(s=me.get("aceConfig"))?s.language:void 0)||"python",n=0,i=(l=null!=(a=this.aceEditors)?a:[]).length;n<i;n++)l[n].destroy();return this.aceEditors=[],e=this.aceEditors,this.$el.find('pre:has(code[class*="lang-"])').each((function(){var t;return t=r.initializeACE(this,o),e.push(t)}))},t.prototype.getProcessedHint=function(){var e,t,o,n;if(o=this.session.get("codeLanguage"),t=this.state.get("hint"))return n=u.i18n(t,"body"),e=a.filterMarkdownCodeLanguages(n,o),marked(e)},t.prototype.getIndexedHintTitle=function(){var e;return e=this.state.get("hintIndex"),d.i18n.t("play_level.hints_title").replace("{{number}}",e+1)},t.prototype.getHintTitle=function(){var e;return(e=this.state.get("hint"))&&e.name&&u.i18n(e,"name")||this.getIndexedHintTitle()},t.prototype.updateHint=function(){var e;return e=this.state.get("hintIndex"),this.state.set({hint:this.hintsState.getHint(e)})},t.prototype.onClickNextButton=function(){var e,t,o,n;return null!=(t=window.tracker)&&t.trackEvent("Hints Next Clicked",{category:"Students",levelSlug:this.level.get("slug"),hintCount:null!=(o=null!=(n=this.hintsState.get("hints"))?n.length:void 0)?o:0,hintCurrent:this.state.get("hintIndex")}),e=this.hintsState.get("total")-1,this.state.set("hintIndex",Math.min(this.state.get("hintIndex")+1,e)),this.playSound("menu-button-click"),this.updateHintTimer()},t.prototype.onClickPreviousButton=function(){var e,t,o;return null!=(e=window.tracker)&&e.trackEvent("Hints Previous Clicked",{category:"Students",levelSlug:this.level.get("slug"),hintCount:null!=(t=null!=(o=this.hintsState.get("hints"))?o.length:void 0)?t:0,hintCurrent:this.state.get("hintIndex")}),this.state.set("hintIndex",Math.max(this.state.get("hintIndex")-1,0)),this.playSound("menu-button-click"),this.updateHintTimer()},t.prototype.hideView=function(){var e;return null!=(e=this.hintsState)&&e.set("hidden",!0),this.playSound("game-menu-close")},t.prototype.visibilityChanged=function(e){return this.updateHintTimer()},t.prototype.updateHintTimer=function(){var e;if(clearInterval(this.timerIntervalID),!this.hintsState.get("hidden")&&!(null!=(e=this.state.get("hintsUsed"))?e[this.state.get("hintIndex")]:void 0))return this.timerIntervalID=setInterval(this.incrementHintViewTime,1e3)},t.prototype.incrementHintViewTime=function(){var e,t,o,n,i,s;return e=this.state.get("hintIndex"),null==(o=this.state.get("hintsViewTime"))[e]&&(o[e]=0),o[e]++,t=this.state.get("hintsUsed"),o[e]>this.hintUsedThresholdSeconds&&!t[e]&&(null!=(n=window.tracker)&&n.trackEvent("Hint Used",{category:"Students",levelSlug:this.level.get("slug"),hintCount:null!=(i=null!=(s=this.hintsState.get("hints"))?s.length:void 0)?i:0,hintCurrent:e}),t[e]=!0,this.state.set("hintsUsed",t),clearInterval(this.timerIntervalID)),this.state.set("hintsViewTime",o)},t.prototype.onAIHelpClicked=function(e){var t;return this.hideView(),this.openModalView(new n({propsData:{aiChatKind:(null!=(t=this.options.level)?t.get("aiChatKind"):void 0)||"level-chat"}}))},t}(i)},418439:(e,t,o)=>{var n,i,s,r,a=o(619755),l=function(e,t){return function(){return e.apply(t,arguments)}},c={}.hasOwnProperty;o(89412),n=o(968029),r=o(652476),i=o(162466),s=o(285755),e.exports=function(e){function t(e){this.animateEnterButton=l(this.animateEnterButton,this),this.addMoreMessage=l(this.addMoreMessage,this),t.__super__.constructor.call(this,e),this.level=e.level,this.sessionID=e.sessionID}return function(e,t){for(var o in t)c.call(t,o)&&(e[o]=t[o]);function n(){this.constructor=e}n.prototype=t.prototype,e.prototype=new n,e.__super__=t.prototype}(t,e),t.prototype.id="level-dialogue-view",t.prototype.template=r,t.prototype.subscriptions={"sprite:speech-updated":"onSpriteDialogue","level:sprite-clear-dialogue":"onSpriteClearDialogue","level:shift-space-pressed":"onShiftSpacePressed","level:escape-pressed":"onEscapePressed","sprite:dialogue-sound-completed":"onDialogueSoundCompleted","level:open-items-modal":"openItemsModal"},t.prototype.events={click:"onClick","click a":"onClickLink"},t.prototype.onClick=function(e){return Backbone.Mediator.publish("tome:focus-editor",{})},t.prototype.onClickLink=function(e){var t;if((t=a(e.target).attr("href"))&&/item-store/.test(t))return this.openModalView(new s({supermodel:this.supermodal})),e.stopPropagation()},t.prototype.openItemsModal=function(e){return this.openModalView(new s({supermodel:this.supermodal}))},t.prototype.onSpriteDialogue=function(e){if(e.message)return this.$el.addClass("active speaking"),a("body").addClass("dialogue-view-active"),this.setMessage(e.message,e.mood,e.responses)},t.prototype.onDialogueSoundCompleted=function(){return this.$el.removeClass("speaking")},t.prototype.onSpriteClearDialogue=function(){if(this.$el.removeClass("active speaking"),a("body").removeClass("dialogue-view-active"),this.lastMood)return this.$el.removeClass(this.lastMood)},t.prototype.setMessage=function(e,t,o){var n,s,r,l,c,u,d;if(e=(e=marked(e)).replace(/&lt;i class=&#39;(.+?)&#39;&gt;&lt;\/i&gt;/,"<i class='$1'></i>"),this.messageInterval&&clearInterval(this.messageInterval),this.bubble=a(".dialogue-bubble",this.$el),this.lastMood&&this.$el.removeClass(this.lastMood),this.$el.addClass(t),this.lastMood=t,this.bubble.text(""),s=a('<div class="enter secret" dir="ltr"></div>'),this.bubble.append(s),o)for(this.lastResponses=o,r=0,l=o.length;r<l;r++)c=o[r],n=a('<button class="btn btn-small banner"></button>').text(c.text),c.buttonClass&&n.addClass(c.buttonClass),s.append(n),c.button=a("button:last",s);else u=a.i18n.t("common.continue",{defaultValue:"Continue"}),d=a.i18n.t("play_level.skip_tutorial",{defaultValue:"skip: esc"}),this.escapePressed||this.isFullScreen()||s.append('<span class="hud-hint">'+d+"</span>"),s.append(a('<button class="btn btn-small banner with-dot">'+u+' <div class="dot"></div></button>')),this.lastResponses=null;return this.animator=new i(e,this.bubble),this.messageInterval=setInterval(this.addMoreMessage,1e3/30)},t.prototype.isFullScreen=function(){return document.fullScreen||document.mozFullScreen||document.webkitIsFullScreen},t.prototype.addMoreMessage=function(){var e,t,o,n,i,s,r,l;if(!this.animator.done())return this.animator.tick();if(clearInterval(this.messageInterval),this.messageInterval=null,a(".enter",this.bubble).removeClass("secret").css("opacity",0).delay(500).animate({opacity:1},500,this.animateEnterButton),this.lastResponses)for(e=a(".enter button"),n=i=0,s=(r=this.lastResponses).length;i<s;
1n=++i)l=r[n],t=l.channel.replace("level-set-playing","level:set-playing"),o=function(e){return function(){return setTimeout((function(){return Backbone.Mediator.publish(t,e.event||{})}),10)}},a(e[n]).click(o(l));else a(".enter",this.bubble).click((function(){return Backbone.Mediator.publish("script:end-current-script",{})}))},t.prototype.onShiftSpacePressed=function(e){var t,o,n;if(this.shiftSpacePressed=(this.shiftSpacePressed||0)+1,null!=(n=this.lastResponses)?n.length:void 0)return o=this.lastResponses[this.lastResponses.length-1],t=o.channel.replace("level-set-playing","level:set-playing"),_.delay((function(){return Backbone.Mediator.publish(t,o.event||{})}),10)},t.prototype.onEscapePressed=function(e){return this.escapePressed=!0},t.prototype.animateEnterButton=function(){var e;if(this.bubble)return e=a(".enter",this.bubble),a(".dot",e).animate({opacity:.2},300).animate({opacity:1.9},600,this.animateEnterButton)},t.prototype.destroy=function(){return this.messageInterval&&clearInterval(this.messageInterval),t.__super__.destroy.call(this)},t}(n)},974587:(e,t,o)=>{var n,i,s,r={}.hasOwnProperty;o(965597),n=o(968029),s=o(768411),i=o(28045).me,e.exports=function(e){function t(e){t.__super__.constructor.call(this,e),this.levelID=e.levelID,this.world=e.world}return function(e,t){for(var o in t)r.call(t,o)&&(e[o]=t[o]);function n(){this.constructor=e}n.prototype=t.prototype,e.prototype=new n,e.__super__=t.prototype}(t,e),t.prototype.id="level-flags-view",t.prototype.template=s,t.prototype.className="secret",t.prototype.subscriptions={"playback:real-time-playback-started":"onRealTimePlaybackStarted","playback:real-time-playback-ended":"onRealTimePlaybackEnded","surface:stage-mouse-down":"onStageMouseDown","god:new-world-created":"onNewWorld","god:streaming-world-updated":"onNewWorld","surface:remove-flag":"onRemoveFlag"},t.prototype.events={"click .green-flag":function(){return this.onFlagSelected({color:"green",source:"button"})},"click .black-flag":function(){return this.onFlagSelected({color:"black",source:"button"})},"click .violet-flag":function(){return this.onFlagSelected({color:"violet",source:"button"})}},t.prototype.shortcuts={g:function(){return this.onFlagSelected({color:"green",source:"shortcut"})},b:function(){return this.onFlagSelected({color:"black",source:"shortcut"})},v:function(){return this.onFlagSelected({color:"violet",source:"shortcut"})},esc:function(){return this.onFlagSelected({color:null,source:"shortcut"})},"delete, del, backspace":"onDeletePressed"},t.prototype.onRealTimePlaybackStarted=function(e){return this.realTime=!0,this.$el.show(),this.flags={},this.flagHistory=[]},t.prototype.onRealTimePlaybackEnded=function(e){return this.onFlagSelected({color:null}),this.realTime=!1,this.$el.hide()},t.prototype.onFlagSelected=function(e){var t;if(this.realTime)return e.color&&this.playSound("menu-button-click"),t=e.color===this.flagColor?null:e.color,this.flagColor=t,Backbone.Mediator.publish("level:flag-color-selected",{color:t}),this.$el.find(".flag-button").removeClass("active"),t?this.$el.find("."+t+"-flag").addClass("active"):void 0},t.prototype.onStageMouseDown=function(e){var t,o,n,s;if(this.flagColor&&this.realTime)return this.playSound("menu-button-click"),n={x:e.worldPos.x,y:e.worldPos.y},o=this.world.dt*this.world.frames.length,t={player:i.id,team:i.team,color:this.flagColor,pos:n,time:o,active:!0,source:"click"},this.flags[this.flagColor]=t,this.flagHistory.push(t),null!=(s=this.realTimeFlags)&&s.create(t),Backbone.Mediator.publish("level:flag-updated",t)},t.prototype.onDeletePressed=function(e){if(this.realTime)return Backbone.Mediator.publish("surface:remove-selected-flag",{})},t.prototype.onRemoveFlag=function(e){var t,o;return delete this.flags[e.color],o=this.world.dt*this.world.frames.length,t={player:i.id,team:i.team,color:e.color,time:o,active:!1,source:"click"},this.flagHistory.push(t),Backbone.Mediator.publish("level:flag-updated",t)},t.prototype.onNewWorld=function(e){if(e.world.name===this.world.name)return this.world=this.options.world=e.world},t}(n)},85955:(e,t,o)=>{var n,i,s,r,a,l,c=o(619755),u={}.hasOwnProperty;o(793254),n=o(968029),a=o(65079),s=o(28045).me,l=o(299498),o(444705),o(523402),o(967734),i=o(349667).default,r=o(196363),e.exports=function(e){function t(e){this.playToggleSound=function(e,t){return function(){return e.apply(t,arguments)}}(this.playToggleSound,this),t.__super__.constructor.call(this,e),this.level=e.level}return function(e,t){for(var o in t)u.call(t,o)&&(e[o]=t[o]);function n(){this.constructor=e}n.prototype=t.prototype,e.prototype=new n,e.__super__=t.prototype}(t,e),t.prototype.id="goals-view",t.prototype.template=a,t.prototype.className="secret expanded",t.prototype.playbackEnded=!1,t.prototype.subscriptions={"goal-manager:new-goal-states":"onNewGoalStates","tome:cast-spells":"onTomeCast","level:set-letterbox":"onSetLetterbox","level:set-playing":"onSetPlaying","surface:playback-restarted":"onSurfacePlaybackRestarted","surface:playback-ended":"onSurfacePlaybackEnded","level:gather-chat-message-context":"onGatherChatMessageContext","sprite:hero-health-updated":"onHeroHealthUpdated"},t.prototype.events={mouseenter:function(){return this.playbackEnded?this.onSurfacePlaybackRestarted():(this.mouseEntered=!0,this.updatePlacement())},mouseleave:function(){return this.mouseEntered=!1,this.updatePlacement()}}
1,t.prototype.afterRender=function(){return this.levelGoalsComponent=new i({el:this.$(".goals-component")[0],store:r,propsData:{showStatus:!0,product:this.level.get("product",!0)}}),this.$el.toggleClass("codecombat-junior","codecombat-junior"===this.level.get("product",!0)),null},t.prototype.onNewGoalStates=function(e){var t,o,n,i,s,r;for(_.assign(this.levelGoalsComponent,_.pick(e,"overallStatus","timedOut","goals","goalStates")),this.levelGoalsComponent.casting=!1,t=null==this.previousGoalStatus,null==this.previousGoalStatus&&(this.previousGoalStatus={}),this.succeeded="success"===e.overallStatus,n=0,i=(s=e.goals).length;n<i;n++)o=s[n],r=e.goalStates[o.id]||{status:"incomplete"},t||"success"!==r.status||"success"===this.previousGoalStatus[o.id]?t||"success"===r.status||"success"!==this.previousGoalStatus[o.id]?this.soundToPlayWhenPlaybackEnded=null:this.soundToPlayWhenPlaybackEnded="goal-incomplete-again":this.soundToPlayWhenPlaybackEnded="goal-success",this.previousGoalStatus[o.id]=r.status;return e.goals.length>0&&this.$el.hasClass("secret")&&(this.$el.removeClass("secret"),this.lastSizeTweenTime=new Date),this.updatePlacement()},t.prototype.onTomeCast=function(e){if(!e.preload)return this.levelGoalsComponent.casting=!0},t.prototype.onSetPlaying=function(e){if(e.playing)return this.mouseEntered=!1,this.expanded=!0,this.updatePlacement()},t.prototype.onSurfacePlaybackRestarted=function(){return this.playbackEnded=!1,this.$el.removeClass("brighter"),this.lastSizeTweenTime=new Date,this.updatePlacement()},t.prototype.onSurfacePlaybackEnded=function(){if(!this.level.isType("game-dev"))return this.playbackEnded=!0,this.updateHeight(),this.$el.addClass("brighter"),this.lastSizeTweenTime=new Date,this.updatePlacement(),this.soundToPlayWhenPlaybackEnded?this.playSound(this.soundToPlayWhenPlaybackEnded):void 0},t.prototype.onGatherChatMessageContext=function(e){var t,o,n,i,r,a,u,d;for((t=e.chat.context).goalStates={},i=0,r=(a=this.levelGoalsComponent.goals).length;i<r;i++)(o=a[i]).optional||o.team&&o.team!==s.team||(n=this.levelGoalsComponent.goalStates[o.id],t.goalStates[o.id]={name:o.name,status:(null!=n?n.status:void 0)||"incomplete"},e.chat.example?t.goalStates[o.id].i18n=_.cloneDeep(null!=(u=o.i18n)?u:{}):(t.goalStates[o.id].name=l.i18n(this.goal,"name"),d={success:"success",failure:"failing",incomplete:"incomplete"}[t.goalStates[o.id].status],t.goalStates[o.id].status=c.i18n.t("play_level."+d)));return null},t.prototype.onHeroHealthUpdated=function(e){return r.commit("game/setHeroHealth",{current:e.health,max:e.maxHealth})},t.prototype.updateHeight=function(){if(!(this.$el.hasClass("brighter")||this.$el.hasClass("secret")||new Date-this.lastSizeTweenTime<500))return this.normalHeight=this.$el.outerHeight()},t.prototype.updatePlacement=function(){var e,t,o,n;if((e=this.playbackEnded!==this.mouseEntered||"codecombat-junior"===this.level.get("product",!0))!==this.expanded)return this.updateHeight(),o=e?"goals-expand":"goals-collapse",e?n=-5:((t=this.normalHeight)&&!this.playbackEnded||(t=this.$el.outerHeight()),n=41-t),this.$el.css("top",n),this.soundTimeout?(clearTimeout(this.soundTimeout),this.soundTimeout=null):null!=this.expanded&&(this.soundTimeout=_.delay(this.playToggleSound,500,o)),this.expanded=e},t.prototype.playToggleSound=function(e){if(!this.destroyed)return this.options.level.isType("game-dev")||this.playSound(e),this.soundTimeout=null},t.prototype.onSetLetterbox=function(e){return this.$el.toggle(!e.on),this.updatePlacement()},t.prototype.destroy=function(){var e,o,n;return n={commit:_.noop,dispatch:_.noop},null!=(e=this.levelGoalsComponent)&&e.$destroy(),null!=(o=this.levelGoalsComponent)&&(o.$store=n),t.__super__.destroy.call(this)},t}(n)},322417:(e,t,o)=>{var n,i,s,r={}.hasOwnProperty;o(525398),n=o(968029),s=o(191524),i=o(218469),e.exports=function(e){function t(e){t.__super__.constructor.call(this,e),this.teamGold={},this.teamGoldEarned={},this.shownOnce=!1}return function(e,t){for(var o in t)r.call(t,o)&&(e[o]=t[o]);function n(){this.constructor=e}n.prototype=t.prototype,e.prototype=new n,e.__super__=t.prototype}(t,e),t.prototype.id="gold-view",t.prototype.template=s,t.prototype.subscriptions={"surface:gold-changed":"onGoldCh
1anged","level:set-letterbox":"onSetLetterbox"},t.prototype.onGoldChanged=function(e){var t,o,n;if(this.teamGold[e.team]!==e.gold||this.teamGoldEarned[e.team]!==e.goldEarned)return this.teamGold[e.team]=e.gold,this.teamGoldEarned[e.team]=e.goldEarned,(t=this.$el.find(".gold-amount.team-"+e.team)).length||(o=i({team:e.team}),this.$el["humans"===e.team?"prepend":"append"](o),t=this.$el.find(".gold-amount.team-"+e.team)),n=""+e.gold,e.goldEarned&&e.goldEarned>e.gold&&(n+=" ("+e.goldEarned+")"),t.text(n),this.updateTitle(),this.$el.show(),this.shownOnce=!0},t.prototype.updateTitle=function(){var e,t,o,n;for(n in o=[],t=this.teamGold)e=t[n],this.teamGoldEarned[n]?o.push("Team '"+n+"' has "+e+" now of "+this.teamGoldEarned[n]+" gold earned."):o.push("Team '"+n+"' has "+e+" gold.");return this.$el.attr("title",o.join(" "))},t.prototype.onSetLetterbox=function(e){if(this.shownOnce)return this.$el.toggle(!e.on)},t}(n)},815117:(e,t,o)=>{var n,i,s,r,a=o(619755),l={}.hasOwnProperty,c=[].indexOf||function(e){for(var t=0,o=this.length;t<o;t++)if(t in this&&this[t]===e)return t;return-1};o(609682),n=o(968029),s=o(631510),i=o(966872),r=o(299498),e.exports=function(e){function t(){return t.__super__.constructor.apply(this,arguments)}return function(e,t){for(var o in t)l.call(t,o)&&(e[o]=t[o]);function n(){this.constructor=e}n.prototype=t.prototype,e.prototype=new n,e.__super__=t.prototype}(t,e),t.prototype.id="thang-hud",t.prototype.template=s,t.prototype.subscriptions={"surface:frame-changed":"onFrameChanged","level:disable-controls":"onDisableControls","level:enable-controls":"onEnableControls","surface:sprite-selected":"onSpriteSelected","sprite:thang-began-talking":"onThangBeganTalking","sprite:thang-finished-talking":"onThangFinishedTalking","god:new-world-created":"onNewWorld"},t.prototype.events={click:"onClick"},t.prototype.afterRender=function(){if(t.__super__.afterRender.call(this),this.$el.addClass("no-selection"),this.options.level.get("hidesHUD"))return this.hidesHUD=!0,this.$el.addClass("hide-hud-properties")},t.prototype.onClick=function(e){if(!a(e.target).parents(".thang-props").length)return Backbone.Mediator.publish("tome:focus-editor",{})},t.prototype.onFrameChanged=function(e){return this.timeProgress=e.progress,this.update()},t.prototype.onDisableControls=function(e){if(!e.controls||c.call(e.controls,"hud")>=0)return this.disabled=!0,this.$el.addClass("controls-disabled")},t.prototype.onEnableControls=function(e){if(!e.controls||c.call(e.controls,"hud")>=0)return this.disabled=!1,this.$el.removeClass("controls-disabled")},t.prototype.onSpriteSelected=function(e){var t;if(!this.disabled)return this.setThang(e.thang,null!=(t=e.sprite)?t.thangType:void 0)},t.prototype.onNewWorld=function(e){var t;if(t=this.thang,this.thang&&(this.thang=e.world.thangMap[this.thang.id]),t&&!this.thang)return this.setThang(null,null)},t.prototype.setThang=function(e,t){if((null!=e||null!=this.thang)&&(null==e||null==this.thang||e.id!==this.thang.id)&&(null==e||!this.hidesHUD||"Hero Placeholder"===e.id)&&e&&(this.thang=e,this.thangType=t,this.thang))return this.createAvatar(t,this.thang),this.createProperties(),this.update()},t.prototype.createAvatar=function(e,t,o){var n,i,s,r,l,c,u,d;if(!e.isFullyLoaded())return n=arguments,void(this.listeningToCreateAvatar||(this.listenToOnce(e,"sync",(function(){return this.createAvatar.apply(this,n)})),this.listeningToCreateAvatar=!0));if(this.listeningToCreateAvatar=!1,(s=t.getLankOptions()||{}).async=!1,o&&(s.colorConfig=o),d=this.$el.find(".thang-canvas-wrapper"),u=null!=(r=this.thang)?r.team:void 0,d.removeClass("hide"),d.removeClass((function(e,t){return(t.match(/\bteam-\S+/g)||[]).join(" ")})),d.addClass("team-"+u),e.get("raster"))d.empty().append(a('<img draggable="false"/>').addClass("avatar").attr("src","/file/"+e.get("raster")));else{if(!(c=e.getPortraitStage(s,100)))return;i=a(c.canvas).addClass("thang-canvas avatar"),d.empty().append(i),c.update(),null!=(l=this.stage)&&l.stopTalking(),this.stage=c}return d.append(a('<img draggable="false" />').addClass("avatar-frame").attr("src","/images/level/thang_avatar_frame.png"))},t.prototype.onThangBeganTalking=function(e){var t;if(this.stage&&this.thang===e.thang)return null!=(t=this.stage)?t.startTalking():void 0},t.prototype.onThangFinishedTalking=function(e){var t;if(this.stage&&this.thang===e.thang)return null!=(t=this.stage)?t.stopTalking():void 0},t.prototype.createProperties=function(){var e,t,o,n,i,s,a,l,c,u,d;for(n=this.options.level.isType("game-dev")?"Game":"Hero Placeholder"===(c=this.thang.id)||"Hero Placeholder 1"===c?(null!=(u=this.thangType)?u.getHeroShortName():void 0)||"Hero":this.thang.hudName||(this.thang.type?this.thang.id+" - "+this.thang.type:this.thang.id),r.replaceText(this.$el.find(".thang-name"),n),(l=this.$el.find(".thang-props")).find(".prop").remove(),e=t=0,o=(d=null!=(a=this.thang.hudProperties)?a:[]).length;t<o;e=++t)s=d[e],null!=(i=this.createPropElement(s))&&(i.find(".bar").is("*")&&l.find(".bar").is("*")?l.find(".bar-prop").last().after(i):l.append(i));return null},t.prototype.update=function(){var e,t,o,n,i,s;if(this.thang&&(this.$el.find(".thang-props-column").toggleClass("nonexistent",!this.thang.exists),this.thang.exists)){for(s=[],e=0,t=(i=null!=(n=this.thang.hudProperties)?n:[]).length;e<t;e++)o=i[e],s.push(this.updatePropElement(o,this.thang[o]));return s}},t.prototype.createPropElement=function(e){return"maxHealth"===e?null:a(i({prop:e,hasIcon:"health"===e||"pos"===e||"target"===e||"collectedThangIDs"===e||"gold"===e||"bountyGold"===e||"value"===e||"visualRange"===e||"attackDamage"===e||"attackRange"===e||"maxSpeed"===e||"attackNearbyEnemyRange"===e,hasBar:"health"===e}))},t.prototype.updatePropElement=function(e,t){var o,n,i,s,a,l,c,u;if(a=this.$el.find(".thang-props *[name="+e+"]"),"maxHealth"!==e)return"health"===e?(s=this.thang["max"+e.charAt(0).toUpperCase()+e.slice(1)],c=this.thang[e+"ReplenishRate"],l=Math.round(100*t/s),a.find(".bar").css("width",l+"%"),i=e+": "+this.formatValue(e,t)+" / "+this.formatValue(e,s),c&&(i+=" (+"+this.formatValue(e,c)+"/s)"),r.replaceText(a.find(".bar-prop-value"),Math.round(t))):(i=e+": "+(u=this.formatValue(e,t)),"attackDamage"===e&&(o=this.thang.actions.attack.cooldown,n=this.thang.attackDamage/o,i+=" / "+o.toFixed(2)+"s (DPS: "+n.toFixed(2)+")"),r.replaceText(a.find(".prop-value"),u)),a.attr("title",i),a},t.prototype.formatValue=function(e,t){if("target"!==e||t||(null!=(t=this.thang.targetPos)?t.isZero():void 0)&&(t=null),"rotation"===e)return(180*t/Math.PI).toFixed(0)+"˚";if(-1!==e.search(/Range$/))return t+"m";if("number"==typeof t)return Math.round(t)===t||"gold"===e?t.toFixed(0):-10<t&&t<10?t.toFixed(2):-100<t&&t<100?t.toFixed(1):t.toFixed(0);if(t&&"object"==typeof t){if(t.id)return t.id;if(t.x&&t.y)return"x: "+t.x.toFixed(0)+" y: "+t.y.toFixed(0)}else if(null==t)return"No "+e;return t},t.prototype.destroy=function(){var e;return null!=(e=this.stage)&&e.stopTalking(),t.__super__.destroy.call(this)},t}(n)},576572:(e,t,o)=>{var n,i,s,r,a,l,c=o(619755),u=o(665420),d=function(e,t){return function(){return e.apply(t,arguments)}},h=function(e,t){for(var o in t)p.call(t,o)&&(e[o]=t[o]);function n(){this.constructor=e}return n.prototype=t.prototype,e.prototype=new n,e.__super__=t.prototype,e},p={}.hasOwnProperty,g=[].slice,v=[].indexOf||function(e){for(var t=0,o=this.length;t<o;t++)if(t in this&&this[t]===e)return t;return-1};o(185174),n=o(968029),a=o(572433),s=o(28045).me,r=o(196363),l=o(299498),e.exports=function(e){function t(){this.onWindowResize=d(this.onWindowResize,this),this.formatTime=d(this.formatTime,this),t.__super__.constructor.apply(this,arguments),this.utils=l,s.on("change:music",this.updateMusicButton,this)}return h(t,e),t.prototype.id="playback-view",t.prototype.template=a,t.prototype.subscriptions={"level:disable-control
1s":"onDisableControls","level:enable-controls":"onEnableControls","level:set-playing":"onSetPlaying","level:toggle-playing":"onTogglePlay","level:scrub-forward":"onScrubForward","level:scrub-back":"onScrubBack","level:set-volume":"onSetVolume","surface:frame-changed":"onFrameChanged","god:new-world-created":"onNewWorld","god:streaming-world-updated":"onNewWorld","level:set-letterbox":"onSetLetterbox","tome:cast-spells":"onTomeCast","playback:real-time-playback-ended":"onRealTimePlaybackEnded","playback:cinematic-playback-ended":"onCinematicPlaybackEnded","playback:stop-real-time-playback":"onStopRealTimePlayback","playback:stop-cinematic-playback":"onStopCinematicPlayback"},t.prototype.events={"click #music-button":"onToggleMusic","click #volume-button":"onToggleVolume","click #play-button":"onTogglePlay",click:function(){if(!this.realTime)return Backbone.Mediator.publish("tome:focus-editor",{})},"mouseenter #timeProgress":"onProgressEnter","mouseleave #timeProgress":"onProgressLeave","mousemove #timeProgress":"onProgressHover","tapstart #timeProgress":"onProgressTapStart","tapend #timeProgress":"onProgressTapEnd","tapmove #timeProgress":"onProgressTapMove","touchstart #timeProgress":"onProgressTapStart","touchend #timeProgress":"onProgressTapEnd","touchmove #timeProgress":"onProgressTapMove"},t.prototype.shortcuts={"⌘+p, p, ctrl+p":"onTogglePlay","⌘+[, ctrl+[":"onScrubBack","⌘+⇧+[, ctrl+⇧+[":"onSingleScrubBack","⌘+], ctrl+]":"onScrubForward","⌘+⇧+], ctrl+⇧+]":"onSingleScrubForward"},t.prototype.afterRender=function(){if(t.__super__.afterRender.call(this),this.$progressScrubber=c(".scrubber .progress",this.$el),this.options.level.isType("game-dev")||this.hookUpScrubber(),this.updateMusicButton(),c(window).on("resize",this.onWindowResize),this.getFullscreenRequestMethod()||this.$el.find(".toggle-fullscreen").hide(),null==this.timePopup&&(this.timePopup=new i),this.second=c.i18n.t("units.second"),this.seconds=c.i18n.t("units.seconds"),this.minute=c.i18n.t("units.minute"),this.minutes=c.i18n.t("units.minutes"),this.goto=c.i18n.t("play_level.time_goto"),this.current=c.i18n.t("play_level.time_current"),this.total=c.i18n.t("play_level.time_total"),this.options.level.get("hidesPlayButton"))return this.$el.find("#play-button").css("visibility","hidden")},t.prototype.updatePopupContent=function(){var e;return null!=(e=this.timePopup)?e.updateContent("<h2>"+this.timeToString(this.newTime)+"</h2>"+this.formatTime(this.current,this.currentTime)+"<br/>"+this.formatTime(this.total,this.totalTime)):void 0},t.prototype.pad2=function(e){return null==e||0===e?"00":(e<10?"0":"")+e},t.prototype.formatTime=function(e,t){return e+"\t"+this.timeToString(t)},t.prototype.timeToString=function(e,t){var o,n,i;return null==e&&(e=0),null==t&&(t=!1),i=(e-60*(o=Math.floor(e/60))).toFixed(1),t?(n="",o>0&&(n=o+" "+(1===o?this.minute:this.minutes)),i>0||0===o?n+" "+i+" "+(1===i?this.second:this.seconds):void 0):o+":"+this.pad2(i)},t.prototype.updateMusicButton=function(){return this.$el.find("#music-button").toggleClass("music-on",s.get("music"))},t.prototype.onSetLetterbox=function(e){if(!this.realTime&&!this.cinematic)return this.togglePlaybackControls(!e.on),this.disabled=e.on},t.prototype.togglePlaybackControls=function(e){return this.$el.find("#play-button, .scrubber-handle").css("visibility",e?"visible":"hidden")},t.prototype.onTomeCast=function(e){return e.realTime?(this.realTime=!0,this.togglePlaybackControls(!1),Backbone.Mediator.publish("playback:real-time-playback-started",{}),this.playSound("real-time-playback-start")):e.cinematic?(this.cinematic=!0,Backbone.Mediator.publish("playback:cinematic-playback-started",{})):void 0},t.prototype.onWindowResize=function(){return 1<=arguments.length&&g.call(arguments,0),this.barWidth=c(".progress",this.$el).width()},t.prototype.onNewWorld=function(e){return this.updateBarWidth(e.world.frames.length,e.world.maxTotalFrames,e.world.dt)},t.prototype.updateBarWidth=function(e,t,o){var n;return this.totalTime=(e-1)*o,n=Math.min(parseInt(100*e/(t-1)),100)+"%",this.barWidth=c(".progress",this.$el).css("width",n).show().width(),c(".scrubber .progress",this.$el).slider("enable",!0),this.newTime=0,this.currentTime=0,this.lastLoadedFrameCount=e},t.prototype.onDisableControls=function(e){var t,o;if(!e.controls||v.call(e.controls,"playback")>=0){this.disabled=!0,c("button",this.$el).addClass("disabled");try{this.$progressScrubber.slider("disable",!0)}catch(e){t=e,console.warn("error disabling scrubber",t)}return null!=(o=this.timePopup)&&o.disable(),c("#volume-button",this.$el).removeClass("disabled"),this.$el.addClass("controls-disabled")}},t.prototype.onEnableControls=function(e){var t,o;if(!this.realTime&&!this.cinematic&&(!e.controls||v.call(e.controls,"playback")>=0)){this.disabled=!1,c("button",this.$el).removeClass("disabled");try{this.$progressScrubber.slider("enable",!0)}catch(e){t=e,console.warn("error enabling scrubber",t)}return null!=(o=this.timePopup)&&o.enable(),this.$el.removeClass("controls-disabled")}},t.prototype.onSetPlaying=function(e){var t,o,n,i;i=r.state.game.playing,o=(t=this.$el.find("#play-button")).hasClass("ended"),t.hasClass("playing"),t.toggleClass("playing",i&&!o).toggleClass("paused",!i&&!o),n=/Mac/.test("undefined"!=typeof navigator&&null!==navigator?navigator.appVersion:void 0)?"⌘":"Ctrl",t.attr("title",n+" + P: "+(i?"Play":"Pause")),this.options.level.isType("game-dev")||this.playSound(i?"playback-play":"playback-pause")},t.prototype.onSetVolume=function(e){var t,o,n,i,s;for(n=["vol-off","vol-down","vol-up"],t=c("#volume-button",this.$el),i=0,s=n.length;i<s;i++)o=n[i],t.removeClass(o);if(e.volume<=0&&t.addClass(n[0]),e.volume>0&&e.volume<1&&t.addClass(n[1]),e.volume>=1)return t.addClass(n[2])},t.prototype.onScrub=function(e,t){return null!=e&&"function"==typeof e.preventDefault&&e.preventDefault(),t.scrubDuration=500,Backbone.Mediator.publish("level:set-time",t)},t.prototype.onScrubForward=function(e){return this.onScrub(e,{ratioOffset:.05})},t.prototype.onSingleScrubForward=function(e){return this.onScrub(e,{frameOffset:1})},t.prototype.onScrubBack=function(e){return this.onScrub(e,{ratioOffset:-.05})},t.prototype.onSingleScrubBack=function(e){return this.onScrub(e,{frameOffset:-1})},t.prototype.onFrameChanged=function(e){var t;return e.progress!==this.lastProgress&&(this.currentTime=e.frame/e.world.frameRate,(null!=(t=this.timePopup)?t.shown:void 0)&&this.updatePopupContent(),this.updateProgress(e.progress,e.world),this.updatePlayButton(e.progress)),this.lastProgress=e.progress},t.prototype.onProgressEnter=function(e){var t;return null!=(t=this.timePopup)?t.enter(this.timePopup):void 0},t.prototype.onProgressLeave=function(e){var t;return null!=(t=this.timePopup)?t.leave(this.timePopup):void 0},t.prototype.onProgressHover=function(e,t){var o,n;if(n=this.$progressScrubber.width()/this.totalTime,null==t&&(t=e.clientX-c(e.target).closest("#timeProgress").offset().left),t=Math.max(0,t),this.newTime=t/n,this.updatePopupContent(),null!=(o=this.timePopup)&&o.on
1Hover(e),this.timePopup&&Math.abs(this.currentTime-this.newTime)<1&&!this.timePopup.shown)return this.timePopup.show()},t.prototype.onProgressTapStart=function(e,t){var o,n,i,s,r,a,d,h,p,g;if(u.isIPadApp||l.isMobile()){if(this.onProgressEnter(e),"tapstart"===(null!=(n=e.handleObj)?n.type:void 0))g=null!=(i=null!=(s=e.clientX)?s:null!=t?t.position.x:void 0)?i:0;else{if("touchstart"!==(null!=(r=e.handleObj)?r.type:void 0))return;g=null!=(a=null!=(d=e.originalEvent)&&null!=(h=d.touches)&&null!=(p=h[0])?p.clientX:void 0)?a:0}return o=g-c(e.target).closest("#timeProgress").offset().left,o=Math.max(o,0),this.scrubTo(o/this.$progressScrubber.width()),this.$el.find("#play-button").hasClass("playing")?this.onTogglePlay():void 0}},t.prototype.onProgressTapEnd=function(e,t){if(u.isIPadApp||l.isMobile())return this.onProgressLeave(e)},t.prototype.onProgressTapMove=function(e,t){var o,n,i,s,r,a,d,h,p,g;if(u.isIPadApp||l.isMobile()){if("tapmove"===(null!=(n=e.handleObj)?n.type:void 0))g=null!=(i=null!=(s=e.clientX)?s:null!=t?t.position.x:void 0)?i:0;else{if("touchmove"!==(null!=(r=e.handleObj)?r.type:void 0))return;g=null!=(a=null!=(d=e.originalEvent)&&null!=(h=d.touches)&&null!=(p=h[0])?p.clientX:void 0)?a:0}return o=g-c(e.target).closest("#timeProgress").offset().left,o=Math.max(o,0),this.onProgressHover(e,o),this.scrubTo(o/this.$progressScrubber.width())}},t.prototype.updateProgress=function(e,t){var o;return t.frames.length!==this.lastLoadedFrameCount&&this.updateBarWidth(t.frames.length,t.maxTotalFrames,t.dt),o=this.worldCompletelyLoaded,this.worldCompletelyLoaded=t.frames.length===t.totalFrames,this.realTime&&this.worldCompletelyLoaded&&!o&&(Backbone.Mediator.publish("playback:real-time-playback-ended",{}),Backbone.Mediator.publish("level:set-letterbox",{on:!1})),c(".scrubber .progress-bar",this.$el).css("width",100*e+"%")},t.prototype.updatePlayButton=function(e){var t,o,n,i;if(i=(o=this.$el.find("#play-button")).hasClass("ended"),this.worldCompletelyLoaded&&e>=.99&&this.lastProgress<.99&&(o.removeClass("playing").removeClass("paused").addClass("ended"),(this.realTime||this.cinematic)&&Backbone.Mediator.publish("level:set-letterbox",{on:!1}),this.realTime&&Backbone.Mediator.publish("playback:real-time-playback-ended",{}),this.cinematic&&Backbone.Mediator.publish("playback:cinematic-playback-ended",{}),Backbone.Mediator.publish("playback:playback-ended",{})),e<.99&&this.lastProgress>=.99&&(n=r.state.game.playing,o.removeClass("ended"),o.addClass(n?"playing":"paused")),i!==(t=o.hasClass("ended")))return Backbone.Mediator.publish("playback:ended-changed",{ended:t})},t.prototype.onRealTimePlaybackEnded=function(e){if(this.realTime)return this.realTime=!1,this.togglePlaybackControls(!0),this.playSound("real-time-playback-end")},t.prototype.onCinematicPlaybackEnded=function(e){return this.cinematic=!1,this.togglePlaybackControls(!0)},t.prototype.onStopRealTimePlayback=function(e){return Backbone.Mediator.publish("level:set-letterbox",{on:!1}),Backbone.Mediator.publish("playback:real-time-playback-ended",{})},t.prototype.onStopCinematicPlayback=function(e){if(this.cinematic)return Backbone.Mediator.publish("level:set-letterbox",{on:!1}),Backbone.Mediator.publish("playback:cinematic-playback-ended",{})},t.prototype.hookUpScrubber=function(){return this.sliderIncrements=500,this.$progressScrubber.slider({max:this.sliderIncrements,animate:"slow",slide:(e=this,function(t,o){var n,i,s;if(!e.shouldIgnore())return++e.slideCount,n=e.getScrubRatio(),e.scrubTo(o.value/e.sliderIncrements),(i=e.getScrubRatio()-n)&&(s="playback-scrub-slide-"+(i>0?"forward":"back")+"-"+e.slideCount%3,!/back/.test(s))?e.playSound(s,Math.min(1,Math.abs(50*i))):void 0}),start:function(e){return function(t,o){var n;if(!e.shouldIgnore())return e.slideCount=0,n=r.state.game.playing,e.wasPlaying=n&&!c("#play-button").hasClass("ended"),Backbone.Mediator.publish("level:set-playing",{playing:!1}),e.playSound("playback-scrub-start",.5)}}(this),stop:function(e){return function(t,o){if(!e.shouldIgnore())return e.actualProgress=o.value/e.sliderIncrements,Backbone.Mediator.publish("playback:manually-scrubbed",{ratio:e.actualProgress}),Backbone.Mediator.publish("level:set-playing",{playing:e.wasPlaying}),e.slideCount<3?(e.wasPlaying=!1,Backbone.Mediator.publish("level:set-playing",{playing:!1}),e.$el.find(".scrubber-handle").effect("bounce",{times:2})):e.playSound("playback-scrub-end",.5)}}(this)});var e},t.prototype.getScrubRatio=function(){return this.$progressScrubber.find(".progress-bar").width()/this.$progressScrubber.width()},t.prototype.scrubTo=function(e,t){if(null==t&&(t=0),!this.shouldIgnore())return Backbone.Mediator.publish("level:set-time",{ratio:e,scrubDuration:t})},t.prototype.shouldIgnore=function(){return this.disabled||this.realTime},t.prototype.onTogglePlay=function(e){var t,o;if(null!=e&&"function"==typeof e.preventDefault&&e.preventDefault(),!this.shouldIgnore())return o=(t=c("#play-button")).hasClass("paused")||t.hasClass("ended"),"codecombat-junior"===this.options.level.get("product")&&(t.hasClass("ended")||t.hasClass("paused")&&this.get
1ScrubRatio()<.05)?(Backbone.Mediator.publish("level:set-time",{ratio:0,scrubDuration:0}),Backbone.Mediator.publish("tome:manual-cast",{realTime:!1})):Backbone.Mediator.publish("level:set-playing",{playing:o}),c(document.activeElement).blur()},t.prototype.onToggleVolume=function(e){var t,o,n,i,s,r,a,l;for(t=c(e.target).closest("#volume-button"),l=[0,.4,1],n=i=0,s=(o=["vol-off","vol-down","vol-up"]).length;i<s;n=++i){if(a=o[n],t.hasClass(a)){r=(n+1)%o.length;break}n===o.length-1&&(r=2)}return Backbone.Mediator.publish("level:set-volume",{volume:l[r]}),c(document.activeElement).blur()},t.prototype.onToggleMusic=function(e){return null!=e&&e.preventDefault(),s.set("music",!s.get("music",!0)),s.patch(),c(document.activeElement).blur()},t.prototype.destroy=function(){return s.off("change:music",this.updateMusicButton,this),c(window).off("resize",this.onWindowResize),this.onWindowResize=null,t.__super__.destroy.call(this)},t}(n),i=function(e){function t(){this.enabled=!0,this.shown=!1,this.type="HoverPopup",this.options={placement:"top",container:"body",animation:!0,html:!0,delay:{show:400}},this.$element=c("#timeProgress"),this.$tip=c("#timePopover"),this.content=""}return h(t,e),t.prototype.getContent=function(){return this.content},t.prototype.show=function(){if(!this.shown)return t.__super__.show.call(this),this.shown=!0},t.prototype.updateContent=function(e){return this.content=e,this.setContent(),this.$tip.addClass("fade top in")},t.prototype.onHover=function(e){var t,o,n,i;return this.e=e,i=this.getPosition(),o=this.$tip[0].offsetWidth,t=this.$tip[0].offsetHeight,n={top:i.top-t,left:i.left+i.width/2-o/2},this.applyPlacement(n,"top")},t.prototype.getPosition=function(){return{top:this.$element.offset().top,left:null!=this.e?this.e.pageX:this.$element.offset().left,height:0,width:0}},t.prototype.hide=function(){return t.__super__.hide.call(this),this.shown=!1},t.prototype.disable=function(){return t.__super__.disable.call(this),this.hide()},t}(c.fn.popover.Constructor)},659050:(e,t,o)=>{var n,i,s,r,a,l,c,u,d,h,p,g,v,m,f,y,b,w,k,S=o(619755),C=o(665420),x={}.hasOwnProperty;o(515979),h=o(976911),r=o(589792),l=o(409285),u=o(766230),a=o(486842),p=o(244769),v=o(58445),f=o(34088),c=o(523402),d=o(444705),g=o(365117),k=o(299498),w=o(586369),n=o(573131),s=o(778363),y=o(261174),i=o(39943),b=o(694879),o(830356),window.Box2D=o(337286),m="humans",e.exports=function(e){function t(){return t.__super__.constructor.apply(this,arguments)}return function(e,t){for(var o in t)x.call(t,o)&&(e[o]=t[o]);function n(){this.constructor=e}n.prototype=t.prototype,e.prototype=new n,e.__super__=t.prototype}(t,e),t.prototype.id="play-game-dev-level-view",t.prototype.template=o(545808),t.prototype.subscriptions={"god:new-world-created":"onNewWorld","god:streaming-world-updated":"onStreamingWorldUpdated"},t.prototype.events={"click #edit-level-btn":"onEditLevelButton","click #play-btn":"onClickPlayButton","click #copy-url-btn":"onClickCopyURLButton","click #play-more-codecombat-btn":"onClickPlayMoreCodeCombatButton"},t.prototype.initialize=function(e,o){var s;return this.options=e,this.sessionID=o,t.__super__.initialize.call(this,this.options),this.state=new g({loading:!0,progress:0,creatorString:"",isOwner:!1}),k.isCodeCombat&&S(window).keydown((function(e){if(32===e.keyCode&&e.target===document.body)return e.preventDefault()})),k.getQueryVariable("dev")&&(this.supermodel.shouldSaveBackups=function(e){var t;return"Level"===(t=e.constructor.className)||"LevelComponent"===t||"LevelSystem"===t||"ThangType"===t}),this.supermodel.on("update-progress",(s=this,function(e){return s.state.set({progress:(100*e).toFixed(1)+"%"})})),this.level=new c,this.session=new d({_id:this.sessionID}),this.gameUIState=new r,this.courseID=k.getQueryVariable("course"),this.courseInstanceID=k.getQueryVariable("course-instance"),this.god=new l({gameUIState:this.gameUIState,indefiniteLength:!0}),this.supermodel.registerModel(this.session),new Promise(function(e){return function(t,o){return e.session.fetch({cache:!1}).then(t,o)}}(this)).then((function(e){return b.levels.getByOriginal(e.level.original)})).then(function(e){return function(t){return e.levelID=t.slug,e.levelLoader=new u({supermodel:e.supermodel,levelID:e.levelID,sessionID:e.sessionID,observing:!0,team:m,courseID:e.courseID}),e.supermodel.setMaxProgress(1),e.listenTo(e.state,"change",_.debounce(e.renderAllButCanvas)),e.updateDb=_.throttle(e.updateDb,1e3),e.levelLoader.loadWorldNecessities()}}(this)).then(function(e){return function(t){return e.level=t.level,e.session=t.session,e.world=t.world,e.setMeta({title:S.i18n.t("play.game_development_title",{level:e.level.get("name")}
1)}),e.god.setLevel(e.level.serialize({supermodel:e.supermodel,session:e.session})),e.god.setWorldClassMap(e.world.classMap),e.goalManager=new a(e.world,e.level.get("goals"),e.team),e.god.setGoalManager(e.goalManager),e.god.angelsShare.firstWorld=!1,me.team=m,e.session.set("team",m),e.scriptManager=new p({scripts:e.world.scripts||[],view:e,session:e.session,levelID:e.level.get("slug")}),e.scriptManager.loadFromSession(),e.howToPlayText=k.i18n(e.level.attributes,"studentPlayInstructions"),null==e.howToPlayText&&(e.howToPlayText=S.i18n.t("play_game_dev_level.default_student_instructions")),e.howToPlayText=marked(e.howToPlayText,{sanitize:!0}),e.renderAllButCanvas(),e.supermodel.finishLoading()}}(this)).then(function(e){return function(t){var o,s,r,a,l,c,u,d,h,p,g,m,b,_;if(e.levelLoader.destroy(),e.levelLoader=null,m=e.$("canvas#webgl-surface"),u=e.$("canvas#normal-surface"),e.surface=new v(e.world,u,m,{thangTypes:e.supermodel.getModels(f),levelType:e.level.get("type",!0),gameUIState:e.gameUIState,resizeStrategy:"wrapper-size"}),e.listenTo(e.surface,"resize",e.onSurfaceResize),o=[{x:(b=e.world.getBounds()).left,y:b.top},{x:b.right,y:b.bottom}],e.surface.camera.setBounds(o),e.surface.camera.zoomTo({x:0,y:0},.1,0),e.surface.setWorld(e.world),e.scriptManager.initializeCamera(),e.renderSelectors("#info-col"),s=null!=(d=e.session.get("code")["hero-placeholder"])?d.plan:void 0,y.fetchToken(s,e.session.get("codeLanguage")).then((function(t){return e.spells=y.generateSpellsObject({level:e.level,levelSession:e.session,token:t})})),c=function(){var e,t,o,n;for(n=[],e=0,t=(o=this.goalManager.goals).length;e<t;e++)l=o[e],n.push(k.i18n(l,"name"));return n}.call(e),r=e.courseID?new n({_id:e.courseID}):null,g=w.playDevLevel({level:e.level,session:e.session,course:r}),a=e.session.get("creatorName")?S.i18n.t("play_game_dev_level.created_by").replace("{{name}}",e.session.get("creatorName")):S.i18n.t("play_game_dev_level.created_during_hoc"),e.state.set({loading:!1,goalNames:c,shareURL:g,creatorString:a,isOwner:me.id===e.session.get("creator")}),e.eventProperties={category:"Play GameDev Level",courseID:e.courseID,sessionID:e.session.id,levelID:e.level.id,levelSlug:e.level.get("slug")},null!=(h=window.tracker)&&h.trackEvent("Play GameDev Level - Load",e.eventProperties),e.level.isType("game-dev")&&e.insertSubView(new i({})),_={spells:e.spells,preload:!1,realTime:!0,justBegin:!1,keyValueDb:null!=(p=e.session.get("keyValueDb"))?p:{},synchronous:!0},e.god.createWorld(_),e.willUpdateFrontEnd=!0,k.isOzaria)return e.subscribeShortcuts()}}(this)).catch(function(e){return function(t){if(t.stack)throw t;return e.state.set("errorMessage",t.message)}}(this))},t.prototype.getMeta=function(){return{links:[{vmid:"rel-canonical",rel:"canonical",href:"/play"}]}},t.prototype.onEditLevelButton=function(){var e,t;return t="/play/level/"+this.level.get("slug"),this.courseID&&this.courseInstanceID?t+="?course="+this.courseID+"&course-instance="+this.courseInstanceID:k.isOzaria&&(e=this.session.get("codeLanguage"))&&(t+="?codeLanguage="+e),k.isOzaria?C.router.navigate(t,{trigger:!0}):Backbone.Mediator.publish("router:navigate",{route:t,viewClass:"views/play/level/PlayLevelView",viewArgs:[{},this.levelID]})},t.prototype.onClickPlayButton=function(){var e,t,o,n;return S("#play-btn").blur(),n={spells:this.spells,preload:!1,realTime:!0,justBegin:!1,keyValueDb:null!=(t=this.session.get("keyValueDb"))?t:{},synchronous:!0},this.god.createWorld(n),Backbone.Mediator.publish("playback:real-time-playback-started",{}),Backbone.Mediator.publish("level:set-playing",{playing:!0}),e=this.state.get("playing")?"Play GameDev Level - Restart Level":"Play GameDev Level - Start Level",null!=(o=window.tracker)&&o.trackEvent(e,this.eventProperties),this.state.set("playing",!0),this.willUpdateFrontEnd=!0},t.prototype.onClickCopyURLButton=function(){var e;return this.$("#copy-url-input").val(this.state.get("shareURL")).select(),this.tryCopy(),null!=(e=window.tracker)?e.trackEvent("Play GameDev Level - Copy URL",this.eventProperties):void 0},t.prototype.onClickPlayMoreCodeCombatButton=function(){var e;return null!=(e=window.tracker)?e.trackEvent("Play GameDev Level - Click Play More CodeCombat",this.eventProperties):void 0},t.prototype.onSurfaceResize=function(e){var t;return t=e.height,this.state.set("surfaceHeight",t)},t.prototype.renderAllButCanvas=function(){if(this.renderSelectors("#info-col","#share-row"),this.state.get("surfaceHeight"))return this.$el.find("#info-col").css("height",this.state.get("surfaceHeight"))},t.prototype.onNewWorld=function(e){var t;if("success"===this.goalManager.checkOverallStatus())return t=new s({shareURL:this.state.get("shareURL"),eventProperties:this.eventProperties,victoryMessage:this.victoryMessage}),this.openModalView(t),t.once("replay",this.onClickPlayButton,this)},t.prototype.updateStudentGoals=function(){var e,t,o,n,i,s,r;if(e=null!=(t=this.studentGoals)?t.length:void 0,(null!=(o=this.world.uiText)&&null!=(n=o.directions)?n.length:void 0)?this.studentGoals=this.world.uiText.directions.map((function(e){return{type:"user_defined",direction:e}})):this.studentGoals=null!=(i=this.world.thangMap["Hero Placeholder"].stringGoals)?i.map((function(e){return JSON.parse(e)})):void 0,_.size(this.studentGoals)&&_.size(this.studentGoals)!==e)return this.updateRealTimeGoals(),r={spells:this.spells,preload:!1,realTime:!1,justBegin:!0,keyValueDb:null!=(s=this.session.get("keyValueDb"))?s:{}},this.god.createWorld(r)},t.prototype.updateRealTimeGoals=function(e){return null!=e&&(this.studentGoals=null!=e?e.map((function(e){return JSON.parse(e)})):void 0),this.renderSelectors("#directions")},t.prototype.onStreamingWorldUpdated=function(e){return this.world=e.world,this.world.age>0&&this.willUpdateFrontEnd&&(this.willUpdateFrontEnd=!1,this.updateStudentGoals(),this.updateLevelName(),this.updateVictoryMessage()),this.updateDb()},t.prototype.updateLevelName=function(){var e;if(null!=(e=this.world.uiText)?e.levelName:void 0)return this.levelName=this.world.uiText.levelName,this.renderSelectors("#directions")},t.prototype.updateVictoryMessage=function(){var e,t;if(null!=(e=this.world.uiText)?e.victoryMessage:void 0)return this.victoryMessage=null!=(t=this.world.uiText)?t.victoryMessage:void 0},t.prototype.getLevelName=function(){return this.levelName||this.level.get("displayName")||this.level.get("name")},t.prototype.updateDb=function(){var e;if(null!=(e=this.state)?e.get("playing"):void 0)return this.surface.world.keyValueDb&&!_.isEqual(this.surface.world.keyValueDb,this.session.attributes.keyValueDb)?(this.session.updateKeyValueDb(_.cloneDeep(this.surface.world.keyValueDb)),this.session.saveKeyValueDb()):void 0},t.prototype.subscribeShortcuts=function(){return"function"==typeof key?key("space, left, up, right, down","play-game-dev-level-view-shortcut-scope",(function(e){if(e.target===document.body)return e.preventDefault()})):void 0},t.prototype.unsubscribeShortcuts=function(){return"undefined"!=typeof key&&null!==key?key.deleteScope("play-game-dev-level-view-shortcut-scope"):void 0},t.prototype.destroy=function(){var e,o,n,i,s;return k.isOzaria&&this.unsubscribeShortcuts(),null!=(e=this.levelLoader)&&e.destroy(),null!=(o=this.surface)&&o.destroy(),null!=(n=this.god)&&n.destroy(),null!=(i=this.goalManager)&&i.destroy(),null!=(s=this.scriptManager)&&s.destroy(),delete window.world,k.isCodeCombat&&S(window).off("keydown"),t.__super__.destroy.call(this)},t}(h)},72014:(e,t,o)=>{var n,i,s,r={}.hasOwnProperty;i=o(708399),n=o(790684).default,s=o(299498),e.exports=function(e){function t(){return t.__super__.constructor.apply(this,arguments)}return function(e,t){for(var o in t)r.call(t,o)&&(e[o]=t[o]);function n(){this.constructor=e}n.prototype=t.prototype,e.prototype=new n,e.__super__=t.prototype}(t,e),t.prototype.id="play-level-video-view",t.prototype.template=o(848304),t.prototype.VueComponent=n,t.prototype.skipMetaBinding=!0,t.prototype.initialize=function(e,o){return this.levelID=o,null==this.propsData&&(this.propsData={}),this.propsData.levelSlug=this.levelID,this.propsData.courseID=s.getQueryVariable("course"),this.propsData.courseInstanceID=s.getQueryVariable("course-instance"),this.propsData.codeLanguage=s.getQueryVariable("codeLanguage"),this.propsData.levelOriginalID=s.getQueryVariable("level"),t.__super__.initialize.call(this,e)},t.prototype.destroy=function(){return"function"==typeof this.onDestroy&&this.onDestroy(),t.__super__.destroy.call(this)},t}(i)},301698:(e,t,o)=>{var n,i,s,r,a,l,c,u,d,h,p,g,v,m,f,y,b,w,k,S,C,x,T,P,L,M,I,D,B,A,E,R,O,V,$,N,j,F,H,G,U,z,W,q,K=o(665420),Q=o(619755),X=function(e,t){return function(){return e.apply(t,arguments)}},J={}.hasOwnProperty,Z=[].indexOf||function(e){for(var t=0,o=this.length;t<o;t++)if(t in this&&this[t]===e)return t;return-1};o(628365),o(970693),o(607967),I=o(976911),W=o(527351),G=o(28045).me,V=o(34088),q=o(299498),U=o(969278),H=o(269940),E=o(58445),p=o(409285),d=o(486842),B=o(244769),w=o(72636),C=o(766230),o(444705),o(523402),o(828193),o(554521),L=o(489886),o(900878),n=o(847
1504),A=o(779703),u=o(589792),F=o(105950),x=o(869501),M=o(489097),$=o(778431),i=o(709964),v=o(815117),k=o(418439),r=o(225976),T=o(576572),h=o(85955),S=o(974587),g=o(322417),c=o(39943),l=o(662915),N=o(109931),m=o(859017),a=o(919384),b=o(920658),P=o(994587),s=o(669760),y=o(159962),R=o(448917),f=o(2912),j=o(166882),z=o(196363),o(830356),window.Box2D=o(337286),O=[2,3],D=[0,2],e.exports=function(e){function t(e,o){var n,i,s,r,a,l;this.levelID=o,this.onSubmissionComplete=X(this.onSubmissionComplete,this),this.onWindowResize=X(this.onWindowResize,this),t.__super__.constructor.call(this,e),this.options=e,this.courseID=e.courseID||q.getQueryVariable("course"),this.courseInstanceID=e.courseInstanceID||q.getQueryVariable("course-instance"),this.isEditorPreview=q.getQueryVariable("dev"),this.sessionID=q.getQueryVariable("session")||this.options.sessionID,this.observing=q.getQueryVariable("observing"),this.teaching=q.getQueryVariable("teaching"),s=q.getQueryVariable("fromCampaign"),null!=(n=_.isString(s)?s.trim():null)&&/^[a-z0-9-]+$/i.test(n)?this.parentCampaign=n:this.parentCampaign=(null!=(r=e.campaign)?r.get("slug"):void 0)||null,this.opponentSessionID=q.getQueryVariable("opponent"),null==this.opponentSessionID&&(this.opponentSessionID=this.options.opponent),this.gameUIState=new u,Q("flying-focus").remove(),Q(window).on("resize",this.onWindowResize),this.isEditorPreview?(this.supermodel.shouldSaveBackups=function(e){var t;return"Level"===(t=e.constructor.className)||"LevelComponent"===t||"LevelSystem"===t||"ThangType"===t},l=this,setTimeout((function(){if(!l.levelLoader)return"function"==typeof l.load?l.load():void 0}),100)):(this.load(),this.observing||null!=(a=K.tracker)&&a.trackEvent("Started Level Load",{category:"Play Level",level:this.levelID,label:this.levelID})),this.calcTimeOffset(),this.mandate=this.supermodel.loadModel(new L).model,features.china&&(this.checkTournamentEndInterval=setInterval(this.checkTournamentEnd.bind(this),3e3)),i=["/images/level/code_palette_wood_background.png","/images/level/code_editor_background_border.png"],_.delay((function(){var e,t,o,n;for(n=[],e=0,o=i.length;e<o;e++)t=i[e],n.push(Q("<img/>")[0].src=t);return n}),1e3)}return function(e,t){for(var o in t)J.call(t,o)&&(e[o]=t[o]);function n(){this.constructor=e}n.prototype=t.prototype,e.prototype=new n,e.__super__=t.prototype}(t,e),t.prototype.id="level-view",t.prototype.template=W,t.prototype.cache=!1,t.prototype.shortcutsEnabled=!0,t.prototype.isEditorPreview=!1,t.prototype.codeFormat="text-code",t.prototype.subscriptions={"level:set-volume":"onSetVolume","level:show-victory":"onShowVictory","level:restart":"onRestartLevel","level:highlight-dom":"onHighlightDOM","level:end-highlight-dom":"onEndHighlight","level:focus-dom":"onFocusDom","level:disable-controls":"onDisableControls","level:enable-controls":"onEnableControls","god:world-load-progress-changed":"onWorldLoadProgressChanged","god:new-world-created":"onNewWorld","god:streaming-world-updated":"onNewWorld","god:infinite-loop":"onInfiniteLoop","level:reload-from-data":"onLevelReloadFromData","level:reload-thang-type":"onLevelReloadThangType","level:started":"onLevelStarted","level:loading-view-unveiling":"onLoadingViewUnveiling","level:loading-view-unveiled":"onLoadingViewUnveiled","level:loaded":"onLevelLoaded","level:session-loaded":"onSessionLoaded","playback:real-time-playback-started":"onRealTimePlaybackStarted","playback:real-time-playback-ended":"onRealTimePlaybackEnded","playback:cinematic-playback-started":"onCinematicPlaybackStarted","playback:cinematic-playback-ended":"onCinematicPlaybackEnded","ipad:memory-warning":"onIPadMemoryWarning","store:item-purchased":"onItemPurchased","tome:manual-cast":"onRunCode","tome:code-format-changed":"onCodeFormatChanged","world:update-key-value-db":"updateKeyValueDb"},t.prototype.events={"click #level-done-button":"onDonePressed","click #stop-real-time-playback-button":function(){return Backbone.Mediator.publish("playback:stop-real-time-playback",{})},"click #stop-cinematic-playback-button":function(){return Backbone.Mediator.publish("playback:stop-cinematic-playback",{})},"click .contact-link":"onContactClicked","contextmenu #webgl-surface":"onSurfaceContextMenu",click:"onClick","click .close-solution-btn":"onCloseSolution","click .apply-solution-btn":"onApplySolution"},t.prototype.onClick=function(){if(K.userIsIdle&&K.idleTracker.onVisible(),this.$("#surface-context-menu-view").is(":visible"))return Backbone.Mediator.publish("level:surface-context-menu-hide",{})},t.prototype.shortcuts={"ctrl+s":"onCtrlS",esc:"onEscapePressed"},t.prototype.getMeta=function(){return{link:[{vmid:"rel-canonical",rel:"canonical",content:"/play"}]}},t.prototype.setLevel=function(e,t){var o,n;return this.level=e,this.supermodel.models=t.models,this.supermodel.collections=t.collections,this.supermodel.shouldSaveBackups=t.shouldSaveBackups,n=this.level.serialize({supermodel:this.supermodel,session:this.session,otherSession:this.otherSession,headless:!1,sessionless:!1}),G.constrainHeroHealth()&&(n.constrainHeroHealth=!0),null!=(o=this.god)&&o.setLevel(n),this.world?this.world.loadFromLevel(n,!1):this.load()},t.prototype.load=function(){var e,t,o,n,i;return this.loadStartTime=new Date,n={supermodel:this.supermodel,levelID:this.levelID,sessionID:this.sessionID,opponentSessionID:this.opponentSessionID,team:q.getQueryVariable("team"),observing:this.observing,courseID:this.courseID,courseInstanceID:this.courseInstanceID,teaching:this.teaching},G.isSessionless()&&(n.fakeSessionConfig={}),this.levelLoader=new C(n),this.listenToOnce(this.levelLoader,"world-necessities-loaded",this.onWorldNecessitiesLoaded),this.listenTo(this.levelLoader,"world-necessity-load-failed",this.onWorldNecessityLoadFailed),e="text-code",null!=(t=q.getQueryVariable("codeFormat")||q.getQueryVariable("blocks"))&&(e={true:"blocks-and-code",false:"text-code","blocks-icons":"blocks-icons","blocks-text":"blocks-text","blocks-and-code":"blocks-and-code","text-code":"text-code"}[t]||e),this.classroomAceConfig={liveCompletion:!0,codeFormatDefault:e,classroomItems:!0,disablePaste:!1}
1,this.courseInstanceID?(o=Q.get("/db/course_instance/"+this.courseInstanceID+"/classroom?project=aceConfig,members,ownerID,classroomItems"),this.supermodel.trackRequest(o),o.then((i=this,function(t){var o,n,s,r,a,l,c,u,d,h,p,g;if(i.classroomAceConfig.liveCompletion=null==(o=null!=(n=t.aceConfig)?n.liveCompletion:void 0)||o,i.classroomAceConfig.disablePaste=null!=(a=t.aceConfig)?a.disablePaste:void 0,i.classroomAceConfig.codeFormatDefault=null!=(l=null!=(c=null!=(u=t.aceConfig)?u.codeFormatDefault:void 0)?c:t.aceConfig.defaultCodeFormat)?l:e,i.classroomAceConfig.codeFormats=null!=(d=null!=(h=t.aceConfig)?h.codeFormats:void 0)?d:["blocks-icons","blocks-text","blocks-and-code","text-code"],null!=(p=i.tome)&&p.determineCodeFormat(),i.classroomAceConfig.levelChat=null!=(g=null!=(s=t.aceConfig)?s.levelChat:void 0)?g:"none",i.classroomAceConfig.classroomItems=null!=(r=null!=t?t.classroomItems:void 0)?r:!("undefined"!=typeof features&&null!==features?features.china:void 0),i.teacherID=t.ownerID,i.teaching&&!i.teacherID.equals(G.id))return _.defer((function(){return K.router.redirectHome()}))}))):G.isMtoCodingOlympiad()?this.classroomAceConfig.levelChat="none":void 0},t.prototype.hasAccessThroughClan=function(e){var t,o;return _.intersection(null!=(t=e.get("clans"))?t:[],null!=(o=G.get("clans"))?o:[]).length},t.prototype.onLevelLoaded=function(e){var t;if(!this.destroyed)return _.all([(G.isStudent()||G.isTeacher())&&!K.getHocCampaign(),!this.courseID,!e.level.isType("course-ladder","ladder"),!this.hasAccessThroughClan(e.level),"peasants-and-munchkins"!==(t=e.level.get("slug"))&&"game-dev-2-tournament-project"!==t&&"game-dev-3-tournament-project"!==t])?_.defer((function(){return K.router.redirectHome()})):(e.level.isType("web-dev")||(this.god=new p({gameUIState:this.gameUIState,indefiniteLength:e.level.isType("game-dev")})),this.waitingToSetUpGod&&this.setupGod(),this.levelSlug=e.level.get("slug"))},t.prototype.checkTournamentEnd=function(){var e,t,o,n;if(this.timeOffset&&this.mandate.loaded&&this.levelSlug&&"course-ladder"===(null!=(o=this.level)?o.get("type"):void 0))return e=this.courseInstanceID||q.getQueryVariable("league"),n=2,(t=this.mandate.get("0"))&&(n=this.getTournamentState(t,e,this.levelSlug,this.timeOffset),G.isAdmin()||Z.call(O,n)>=0||(window.location.href="/play/ladder/"+this.levelSlug+(e?"/course/"+e:""))),Z.call(D,n)>=0?clearInterval(this.checkTournamentEndInterval):void 0},t.prototype.getTournamentState=function(e,t,o,n){var i,s,r;return(r=_.find(e.currentTournament||[],(function(e){return e.courseInstanceID===t&&e.level===o})))?(i=(Date.now()+n)/1e3,console.log("Current time:",new Date(1e3*i)),i<r.startAt?(s=r.startAt-i,console.log("Tournament will start at: "+new Date(1e3*r.startAt)+", Time left: "+parseInt(s/60/60)+":"+parseInt(s/60)%60+":"+parseInt(s)%60),1):i>r.endAt?(console.log("Tournament ended at: "+new Date(1e3*r.endAt)),0):(s=r.endAt-i,console.log("Tournament will end at: "+new Date(1e3*r.endAt)+", Time left: "+parseInt(s/60/60)+":"+parseInt(s/60)%60+":"+parseInt(s)%60),3)):Z.call(e.tournamentOnlyLevels||[],o)>=0?0:2},t.prototype.calcTimeOffset=function(){return Q.ajax({type:"HEAD",success:(e=this,function(t,o,n){return e.timeOffset=new Date(n.getResponseHeader("Date")).getTime()-Date.now()})});var e},t.prototype.trackLevelLoadEnd=function(){var e,t;if(!this.isEditorPreview)return this.loadEndTime=new Date,this.loadDuration=this.loadEndTime-this.loadStartTime,console.debug("Level unveiled after "+(this.loadDuration/1e3).toFixed(2)+"s"),this.observing||this.isEditorPreview?void 0:(null!=(e=K.tracker)&&e.trackEvent("Finished Level Load",{category:"Play Level",label:this.levelID,level:this.levelID,loadDuration:this.loadDuration}),null!=(t=K.tracker)?t.trackTiming(this.loadDuration,"Level Load Time",this.levelID,this.levelID):void 0)},t.prototype.isCourseMode=function(){return this.courseID&&this.courseInstanceID},t.prototype.getRenderData=function(){var e;return(e=t.__super__.getRenderData.call(this)).world=this.world,e},t.prototype.afterRender=function(){var e,o,n,i;if(t.__super__.afterRender.call(this),"function"==typeof window.onPlayLevelViewLoaded&&window.onPlayLevelViewLoaded(this),this.insertSubView(this.loadingView=new x({autoUnveil:this.options.autoUnveil||this.observing,level:null!=(e=null!=(o=this.levelLoader)?o.level:void 0)?e:this.level,session:null!=(n=null!=(i=this.levelLoader)?i.session:void 0)?n:this.session})),this.$el.find("#level-done-button").hide(),Q("body").addClass("is-playing"),this.isIPadApp())return Q("body").bind("touchmove",!1)},t.prototype.afterInsert=function(){return t.__super__.afterInsert.call(this)},t.prototype.onWorldNecessitiesLoaded=function(){var e,t,o,n,i,s,r,a;return this.grabLevelLoaderData(),e=q.i18n(this.level.attributes,"name"),this.setMeta({title:Q.i18n.t("play.level_title",{level:e,interpolation:{escapeValue:!1}})}),this.level.isType("ladder")||(t=null!=(o=this.world)?o.teamForPlayer():void 0),a=null!=(n=null!=(i=null!=(s=q.getQueryVariable("team"))?s:null!=(r=this.session)?r.get("team"):void 0)?i:t)?n:"humans",this.loadOpponentTeam(a),this.setupGod(),this.setTeam(a
1),this.initGoalManager(),this.insertSubviews(),this.initVolume(),this.register(),this.controlBar.setBus(this.bus),this.initScriptManager()},t.prototype.onWorldNecessityLoadFailed=function(e){return this.loadingView.onLoadError(e)},t.prototype.grabLevelLoaderData=function(){var e;if(this.session=this.levelLoader.session,this.level=this.levelLoader.level,z.commit("game/setLevel",this.level.attributes),!this.level.isType("web-dev")){if(this.world=this.levelLoader.world,this.level.isType("game-dev")&&(this.$el.addClass("game-dev"),this.howToPlayText=q.i18n(this.level.attributes,"studentPlayInstructions"),null==this.howToPlayText&&(this.howToPlayText=Q.i18n.t("play_game_dev_level.default_student_instructions")),this.howToPlayText=marked(this.howToPlayText,{sanitize:!0}),this.renderSelectors("#how-to-play-game-dev-panel")),(_.any(this.world.thangs,(function(e){var t;return e.programmableProperties&&Z.call(e.programmableProperties,"findFlags")>=0||(null!=(t=e.inventory)?t.flag:void 0)}))||"sky-span"===this.level.get("slug"))&&this.$el.addClass("flags"),"codecombat-junior"===this.level.get("product")&&this.$el.addClass("junior"),this.otherSession=this.levelLoader.opponentSession,!this.level.isType("game-dev"))for(this.worldLoadFakeResources=[],e=1;e<=100;++e)this.worldLoadFakeResources.push(this.supermodel.addSomethingResource(1));return this.renderSelectors("#stop-real-time-playback-button")}this.$el.addClass("web-dev")},t.prototype.onWorldLoadProgressChanged=function(e){var t,o,n,i;if(e.god===this.god&&this.worldLoadFakeResources){for(null==this.lastWorldLoadPercent&&(this.lastWorldLoadPercent=0),i=Math.floor(100*e.progress),o=t=this.lastWorldLoadPercent+1,n=i;t<=n;o=t+=1)this.worldLoadFakeResources[o-1].markLoaded();return this.lastWorldLoadPercent=i,100===i?this.worldFakeLoadResources=null:void 0}},t.prototype.loadOpponentTeam=function(e){var t,o,n,i,s,r,a,l,c,u,d,h,p,g;for(h in r=[],a=q.teamSpells)p=a[h],h!==e&&e&&(r=r.concat(p));for(this.session.get("teamSpells")||this.session.set("teamSpells",q.teamSpells),s=(null!=(l=this.otherSession)?l.get("code"):void 0)||{},i=this.session.get("code")||{},o=0,n=r.length;o<n;o++)g=(c=(d=r[o]).split("/"))[0],d=c[1],t=null!=(u=s[g])?u[d]:void 0,null==i[g]&&(i[g]={}),t?i[g][d]=t:delete i[g][d];return this.session.set("code",i)},t.prototype.setupGod=function(){var e;if(!this.level.isType("web-dev"))return this.god?(this.waitingToSetUpGod=void 0,e=this.level.serialize({supermodel:this.supermodel,session:this.session,otherSession:this.otherSession,headless:!1,sessionless:!1}),G.constrainHeroHealth()&&(e.constrainHeroHealth=!0),this.god.setLevel(e),this.god.setLevelSessionIDs(this.otherSession?[this.session.id,this.otherSession.id]:[this.session.id]),this.god.setWorldClassMap(this.world.classMap)):this.waitingToSetUpGod=!0},t.prototype.setTeam=function(e){return _.isString(e)||(e=null!=e?e.team:void 0),null==e&&(e="humans"),G.team=e,this.session.set("team",e),Backbone.Mediator.publish("level:team-set",{team:e}),this.team=e},t.prototype.initGoalManager=function(){var e,t;return e={},"cumulative"===this.level.get("assessment")&&(e.minGoalsToComplete=1),this.goalManager=new d(this.world,this.level.get("goals"),this.team,e),null!=(t=this.god)?t.setGoalManager(this.goalManager):void 0},t.prototype.updateGoals=function(e){return this.level.set("goals",e),this.goalManager.destroy(),this.initGoalManager()},t.prototype.insertSubviews=function(){var e,t,o,n;if(this.hintsState=new f({hidden:!0},{session:this.session,level:this.level,supermodel:this.supermodel}),z.commit("game/setHintsVisible",!1),this.hintsState.on("change:hidden",(function(e,t){return z.commit("game/setHintsVisible",!t)})),this.insertSubView(this.tome=new $({levelID:this.levelID,session:this.session,otherSession:this.otherSession,playLevelView:this,thangs:null!=(t=null!=(o=this.world)?o.thangs:void 0)?t:[],supermodel:this.supermodel,level:this.level,observing:this.observing,courseID:this.courseID,courseInstanceID:this.courseInstanceID,god:this.god,hintsState:this.hintsState,classroomAceConfig:this.classroomAceConfig,teacherID:this.teacherID})),this.level.isType("web-dev")||this.insertSubView(new T({session:this.session,level:this.level})),this.insertSubView(new h({level:this.level,session:this.session})),this.$el.hasClass("flags")&&this.insertSubView(new S({levelID:this.levelID,world:this.world})),e="wakka-maul"===(n=this.level.get("slug"))||"cross-bones"===n,this.level.isType("web-dev","game-dev")||e||"codecombat"!==this.level.get("product",!0)||this.insertSubView(new g({})),this.level.isType("game-dev")&&this.insertSubView(new c({})),this.level.isType("web-dev")||this.insertSubView(new v({level:this.level})),this.insertSubView(new k({level:this.level,sessionID:this.session.id})),this.insertSubView(new i({levelID:this.levelID,sessionID:this.session.id,session:this.session,aceConfig:this.classroomAceConfig,aiCh
1atKind:this.level.get("aiChatKind"),levelRealID:this.level.id,levelisLadder:this.level.isLadder()})),this.insertSubView(new M({session:this.session,level:this.level,supermodel:this.supermodel,aceConfig:this.classroomAceConfig})),this.insertSubView(new R({session:this.session,level:this.level})),this.level.isLadder()&&this.insertSubView(new l({level:this.level,session:this.session,otherSession:this.otherSession,supermodel:this.supermodel,thangs:this.world.thangs,showsGold:e})),this.insertSubView(this.controlBar=new r({worldName:q.i18n(this.level.attributes,"name"),session:this.session,level:this.level,supermodel:this.supermodel,courseID:this.courseID,courseInstanceID:this.courseInstanceID,classroomAceConfig:this.classroomAceConfig,hintsState:this.hintsState,teacherID:this.teacherID,team:this.team,parentCampaign:this.parentCampaign})),this.insertSubView(this.hintsView=new y({session:this.session,level:this.level,hintsState:this.hintsState,aceConfig:this.classroomAceConfig}),this.$(".hints-view")),this.level.isType("web-dev"))return this.insertSubView(this.webSurface=new j({level:this.level,goalManager:this.goalManager}))},t.prototype.initVolume=function(){var e;return null==(e=G.get("volume"))&&(e=1),Backbone.Mediator.publish("level:set-volume",{volume:e})},t.prototype.initScriptManager=function(){if(!this.level.isType("web-dev"))return this.scriptManager=new B({scripts:this.world.scripts||[],view:this,session:this.session,levelID:this.level.get("slug")}),this.scriptManager.loadFromSession()},t.prototype.register=function(){if(this.bus=w.get(this.levelID,this.session.id),this.bus.setSession(this.session),this.bus.setSpells(this.tome.spells),this.teacherID)return this.bus.subscribeTeacher(this.teacherID)},t.prototype.onSessionLoaded=function(e){var t,o,n,i;if(z.commit("game/setTimesCodeRun",e.session.get("timesCodeRun")||0),z.commit("game/setTimesAutocompleteUsed",e.session.get("timesAutocompleteUsed")||0),!this.session)return Backbone.Mediator.publish("ipad:language-chosen",{language:null!=(t=e.session.get("codeLanguage"))?t:"python"}),e.level.usesSessionHeroInventory()&&!_.size(null!=(o=null!=(n=e.session.get("heroConfig"))?n.inventory:void 0)?o:{})?_.defer((i=this,function(){var t,o,n;if(!i.destroyed&&!_.size(null!=(t=null!=(o=e.session.get("heroConfig"))?o.inventory:void 0)?t:{}))return null!=(n=i.setupManager)&&n.destroy(),i.setupManager=new P({supermodel:i.supermodel,level:e.level,levelID:i.levelID,parent:i,session:e.session,courseID:i.courseID,courseInstanceID:i.courseInstanceID}),i.setupManager.open()})):void 0},t.prototype.onLoaded=function(){return Q(".cc-revoke:visible, .cc-window:visible").addClass("play-level-temp-hidden").hide(),_.defer((e=this,function(){return"function"==typeof e.onLevelLoaderLoaded?e.onLevelLoaderLoaded():void 0}));var e},t.prototype.onLevelLoaderLoaded=function(){var e,t,o;if(1===(null!=(e=this.levelLoader)?e.progress():void 0))return this.level?(this.observing||this.isEditorPreview||this.levelLoader.level.isType("ladder-tutorial")||(G.set("lastLevel",this.levelID),G.save(),null!=(t=K.tracker)&&t.identify()),this.otherSession&&this.saveRecentMatch(),this.levelLoader.destroy(),this.levelLoader=null,this.level.isType("web-dev")?Backbone.Mediator.publish("level:started",{}):this.initSurface()):(console.warn("Warning: somehow level loader loaded without having grabbed level loader data first? Trying again soon."),void _.delay((o=this,function(){return"function"==typeof o.onLevelLoaderLoaded?o.onLevelLoaderLoaded():void 0}),2e3))},t.prototype.saveRecentMatch=function(){var e,t,o,n;return t=null!=(n=(e=null!=(o=U.load("recently-played-matches"))?o:{})[this.levelID])?n:[],e[this.levelID]=t,_.find(t,{otherSessionID:this.otherSession.id})||t.unshift({yourTeam:G.team,otherSessionID:this.otherSession.id,opponentName:this.otherSession.get("creatorName")}),t.splice(8),U.save("recently-played-matches",e)},t.prototype.initSurface=function(){var e,t,o,n,i;return n=Q("canvas#webgl-surface",this.$el),t=Q("canvas#normal-surface",this.$el),o={thangTypes:this.supermodel.getModels(V),observing:this.observing,playerNames:this.findPlayerNames(),levelType:this.level.get("type",!0),gameUIState:this.gameUIState,level:this.level,resizeStrategy:"wrapper-size"},this.surface=new E(this.world,t,n,o),e=[{x:(i=this.world.getBounds()).left,y:i.top},{x:i.right,y:i.bottom}],this.surface.camera.setBounds(e),this.surface.camera.zoomTo({x:0,y:0},.1,0),this.listenTo(this.surface,"resize",(function(e){var t;return t=e.height,this.$("#how-to-play-game-dev-panel").css({height:t})}))},t.prototype.findPlayerNames=function(){var e,t,o,n,i;if(!this.level.isType("ladder","hero-ladder","course-ladder"))return{};for(o={},e=0,t=(n=[this.session,this.otherSession]).length;e<t;e++)(null!=(i=n[e])?i.get("team"):void 0)&&(o[i.get("team")]=q.getCorrectName(i));return o},t.prototype.onLevelStarted=function(){var e,t;if(null!=this.surface||null!=this.webSurface)return this.loadingView.showReady(),this.trackLevelLoadEnd(),window.currentModal&&!window.currentModal.destroyed&&-1===[N,a,m].indexOf(window.currentModal.constructor)?Backbone.Mediator.subscribeOnce("modal:closed",this.onLevelStarted,this):(null!=(e=this.surface)&&e.showLevel(),Backbone.Mediator.publish("level:set-time",{time:0}),!this.isEditorPreview&&!this.observing||q.getQueryVariable("intro")?(Q(window).trigger("resize"),null!=(t=this.scriptManager)?t.initializeCamera():void 0):(this.loadingView.startUnveiling(),this.loadingView.unveil(!0)))},t.prototype.onLoadingViewUnveiling=function(e){return this.unveiling=!0,this.selectHero()},t.prototype.onLoadingViewUnveiled=function(e){var t,o,n;return this.unveiling=!1,this.unveiled=!0,(this.level.isType("course-ladder","hero-ladder","ladder")||this.observing)&&Backbone.Mediator.publish("level:set-playing",{playing:!0}),this.loadingView.$el.remove(),this.removeSubView(this.loadingView),this.loadingView=null,this.playAmbientSound(),this.observing||this.isEditorPreview||null!=(t=K.tracker)&&t.trackEvent("Started Level",{category:"Play Level",label:this.levelID,levelID:this.levelID,ls:null!=(o=this.session)?o.get("_id"):void 0}),Q(window).trigger("resize"),_.delay((n=this,function(){return"function"==typeof n.perhapsStartSimulating?n.perhapsStartSimulating():void 0}),1e4)},t.prototype.onSetVolume=function(e){if(F.Sound.volume=1===e.volume?.6:e.volume,e.volume&&!this.ambientSound)return this.playAmbientSound()},t.prototype.playAmbientSound=function(){var e,t,o;if(!this.destroyed&&!this.ambientSound&&G.get("volume")&&(e={Dungeon:"ambient-dungeon",Grass:"ambient-grass"}[this.level.get("terrain")]))return o="/file/interface/"+e+n.ext,(null!=(t=n.getStatus(o))?t.loaded:void 0)?(this.ambientSound=
1F.Sound.play(o,{loop:-1,volume:.1}),F.Tween.get(this.ambientSound).to({volume:1},1e4)):(n.preloadSound(o),void Backbone.Mediator.subscribeOnce("audio-player:loaded",this.playAmbientSound,this))},t.prototype.selectHero=function(){var e;return Backbone.Mediator.publish("level:suppress-selection-sounds",{suppress:!0}),Backbone.Mediator.publish("tome:select-primary-sprite",{}),Backbone.Mediator.publish("level:suppress-selection-sounds",{suppress:!1}),null!=(e=this.surface)?e.focusOnHero():void 0},t.prototype.perhapsStartSimulating=function(){var e,t,o,n,i;if(this.shouldSimulate()){for(i=[],e=0,n=(o=["javascript","python","coffeescript","lua"]).length;e<n;e++)t=o[e],i.push(function(e){return function(t){return H(t).then((function(n){if(!(o=_.without(o,t)).length)return e.simulateNextGame()}))}}(this)(t));return i}},t.prototype.simulateNextGame=function(){var e,t,o;return this.simulator||(t={background:!0,leagueID:this.courseInstanceID},this.level.isLadder()&&(t.levelID=this.level.get("slug")),this.simulateAILeagueFinals&&this.simulateAILeagueLevelOriginalId&&(t.levelOriginal=this.simulateAILeagueLevelOriginalId,t.singleLadder=!0),this.simulator=new A(t),e=this.simulator.fetchAndSimulateOneGame,this.simulator.fetchAndSimulateOneGame=(o=this,function(){return o.simulator.simulatedByYou>=10?(console.log("------------------- Destroying Simulator and making a new one -----------------"),o.simulator.destroy(),o.simulator=null,o.simulateNextGame()):e.apply(o.simulator)})),this.simulator.fetchAndSimulateOneGame()},t.prototype.shouldSimulate=function(){var e,t,o,n,i,s,r,a,l,c,u,d,h,p,g;if(!0===q.getQueryVariable("simulate"))return!0;if(t=new Date,n=new Date("2026-06-25"),this.simulateAILeagueFinals=t.getTime()<n.getTime(),this.simulateAILeagueLevelOriginalId="69415fa85459d73effdd5c51",!this.simulateAILeagueFinals)return!1;if(!1===q.getQueryVariable("simulate"))return!1;if(this.isEditorPreview)return!1;if(e=window.navigator.hardwareConcurrency||2,o=793e6,s=(null!=(a=window.performance)&&null!=(l=a.memory)?l.jsHeapSizeLimit:void 0)||o,i=G.get("simulatedBy"),console.debug("Should we start simulating? Cores:",window.navigator.hardwareConcurrency,"Heap limit:",null!=(c=window.performance)&&null!=(u=c.memory)?u.jsHeapSizeLimit:void 0,"Load duration:",this.loadDuration,"level type:",this.level.get("type")),!(null!=(d=Q.browser)?d.desktop:void 0))return!1;if((null!=(h=Q.browser)?h.msie:void 0)||(null!=(p=Q.browser)?p.msedge:void 0))return!1;if(Q.browser.linux)return!1;if(r=8,this.simulateAILeagueFinals&&(r=1),G.rank()<r)return!1;if("zero-sum"===(g=this.level.get("slug"))||"ace-of-coders"===g||"elemental-wars"===g)return!1;if(this.level.isType("course","game-dev","web-dev"))return!1;if(this.level.isType("hero")&&i){if(e<8)return!1;if(s<o)return!1;if(this.loadDuration>15e3)return!1}else if(this.level.isType("hero-ladder")&&i){if(e<4)return!1;if(s<o)return!1;if(this.loadDuration>15e3)return!1}else if(this.level.isType("hero-ladder")&&!i){if(e<8)return!1;if(s<=o)return!1;if(this.loadDuration>12e3)return!1}else if(this.level.isType("course-ladder")){if(e<=2)return!1;if(s<o)return!1;if(this.loadDuration>18e3)return!1}else if(this.level.isType("ladder")){if(e<=2)return!1;if(s<o)return!1;if(this.loadDuration>18e3)return!1}else{if(console.warn("Unwritten level type simulation heuristics; fill these in for new level type "+this.level.get("type")+"?"),e<8)return!1;if(s<o)return!1;if(this.loadDuration>1e4)return!1}return console.warn("We should have the power. Begin background ladder simulation - "+G.id),!0},t.prototype.onCtrlS=function(e){return e.preventDefault()},t.prototype.onEscapePressed=function(e){return this.$el.hasClass("real-time")?Backbone.Mediator.publish("playback:stop-real-time-playback",{}):this.$el.hasClass("cinematic")?Backbone.Mediator.publish("playback:stop-cinematic-playback",{}):void 0},t.prototype.onLevelReloadFromData=function(e){var t,o,n,i;if(t=Boolean(this.world))for(i in n=this.supermodel.models)o=n[i],e.supermodel.models[i]||e.supermodel.registerModel(o);if(this.setLevel(e.level,e.supermodel),t)return this.scriptManager.setScripts(e.level.get("scripts")),this.updateGoals(e.level.get("goals")),Backbone.Mediator.publish("tome:cast-spell",{})},t.prototype.onLevelReloadThangType=function(e){var t,o,n,i,s,r,a;for(r in s=e.thangType,n=this.supermodel.models)if((o=n[r]).id===s.id){for(t in i=s.attributes)a=i[t],o.attributes[t]=a;break}return Backbone.Mediator.publish("tome:cast-spell",{})},t.prototype.onWindowResize=function(e){var t,o,n,i,s,r,a,l,c,u,d,h,p,g,v,m,f,y,b,w,k,S,_,C,x,T,P,L,M,I,D,B,A,E,R,O,V,$,N,j,F,H,U,z,W,q,K,X,J,Z,Y,ee,te,oe,ne,ie,se,re,ae,le,ce,ue,de,he,pe,ge,ve,me,fe,ye,be,we,ke,Se,_e,Ce,xe,Te,Pe,Le,Me,Ie;return this.endHighlight(),Pe=Q(window).innerWidth(),Te=Q(window).innerHeight(),xe=Pe/Te,t=924/589,$=(null!=(N=this.level)?N.get("product",!0):void 0)||"codecombat",s="codecombat"===$&&this.$el.hasClass("cinematic")&&(xe<2||Pe<=1366)&&xe>1,be=function(){var e;switch(!1){case!(null!=(e=this.level)?e.isType("web-dev"):void 0):return"right";case!(xe<1):case!(xe<1.35&&"blocks-and-code"===this.codeFormat&&!s):return"bottom";default:return"right"}}.call(this),Me=function(){switch(!1){case!!/blocks/.test(this.codeFormat):return"none";case!("bottom"===be&&"blocks-and-code"===this.codeFormat):return"bottom-middle-third";case!("bottom"===be&&"blocks-and-code"!==this.codeFormat):return"bottom-left-half";case!s:return"full-cinematic";case"blocks-and-code"!==this.codeFormat:return"middle-third";default:return"left-half"}}.call(this),_e=function(){switch(!1){case!(!/blocks/.test(this.codeFormat)||s):return"none";case!("bottom"===be&&"blocks-and-code"===this.codeFormat):return"bottom-right-third";case!("bottom"===be&&"blocks-and-code"!==this.codeFormat):return"bottom-right-half";case"blocks-and-code"!==this.codeFormat:return"right-third";default:return"right-half"}}.call(this),me=function(){return 0==!(/blocks/.test(this.codeFormat)||s)?"none":"bottom"}.call(this),r=function(){switch(!1){case!("blocks-and-code"===this.codeFormat&&s):return"none";case!("blocks-and-code"===this.codeFormat&&"bottom"===be):return"bottom-left-third";case"blocks-and-code"!==this.codeFormat:return"left-third";case!("text-code"===this.codeFormat&&s):return"full-cinematic";case!("text-code"===this.codeFormat&&!s):return"full";default:return"none"}}.call(this),R=function(){switch(!1){case"bottom"!==be:return"bottom-left";case"bottom"!==me:return"middle";default:return"bottom"}}(),D=0==!s?Math.max(.15*Te,150):Math.max(.25*Te,250),S=(null!=(j=this.tome)&&null!=(Y=j.spellPaletteView)&&null!=(ce=Y.entries)?ce.length:void 0)>16,null==(M=null!=(ue=this.tome)&&null!=(de=ue.spellView)&&null!=(he=de.codeChars)?he.desired:void 0)&&(M=function(){var e;switch(!1){case!(null!=(e=this.level)?e.isType("web-dev"):void 0):return 80;case"codecombat-junior"!==$:return 28;case!s:return 40;default:return 60}}.call(this)),null==(x=null!=(pe=this.tome)&&null!=(ge=pe.spellView)&&null!=(ve=ge.codeChars)?ve.max:void 0)&&(x="codecombat-junior"===$?40:80),T="none"===r?0:24*x+101,(I="none"===r?0:7.201228070175439*M+101)&&S&&"text-code"===this.codeFormat&&!(null!=(F=this.level)?F.isType("web-dev"):void 0)&&(E=3,(null!=(H=this.tome)&&null!=(U=H.spellPaletteView)&&null!=(z=U.entries)?z.length:void 0)>32&&Pe>=1480&&xe>=1.8&&(E=4),I=Math.max(I,137*E+54),T=Math.max(T,I)),L=function(){switch(!1){case!("blocks-icons"===this.codeFormat&&"codecombat-junior"===$):return 4;case!("blocks-icons"===this.codeFormat&&s):return 6;case"blocks-icons"!==this.codeFormat:return 7;case"codecombat-junior"!==$:return 30;default:return 35}}.call(this),function(){switch(!1){case!("blocks-icons"===this.codeFormat&&"bottom"===be):return 15;case!("blocks-icons"===this.codeFormat&&"codecombat-junior"===$):return 8;case!("blocks-icons"===this.codeFormat&&"codecombat"===$):return 10;case"codecombat-junior"!==$:return 40;default:return 50}}.call(this),P="blocks-icons"===this.codeFormat?50:10,"blocks-icons"===this.codeFormat?70:15,null==(A=null!=(W=this.tome)&&null!=(q=W.
1spellView)&&null!=(K=q.workspaceWidth)?K.desired:void 0)&&(A="none"===Me?0:L*P),null!=(X=this.tome)&&null!=(J=X.spellView)&&null!=(Z=J.workspaceWidth)&&Z.max,null==(B=null!=(ee=this.tome)&&null!=(te=ee.spellView)&&null!=(oe=te.toolboxWidth)?oe.desired:void 0)&&(B="none"===_e?0:L*P),null!=(ne=this.tome)&&null!=(ie=ne.spellView)&&null!=(se=ie.toolboxWidth)&&se.max,this.unveiling||this.unveiled||(I=.435*Pe,A=B=0),((null!=(re=this.level)?re.isType("game-dev"):void 0)&&this.$el.hasClass("real-time")||this.$el.hasClass("real-time"))&&(I=T=A=B=0),n=Math.min(Te,(Pe-I-A-B)/t),Se=Pe-n*t,f=Te-n,u=function(){var e;switch(!1){case!(null!=(e=this.level)?e.isType("web-dev"):void 0):return"left";case!s:return"none";case"bottom"!==be:return"top";case!S:return"left";case!(Se>160&&f<=0):return"right";default:return"left"}}.call(this),l=s?0:50,o=function(){var e;switch(!1){case!(null!=(e=this.level)?e.isType("web-dev"):void 0):return Te-l;case"bottom"!==be:return Math.min(Te-D-l,Pe/t);default:return Math.min(Te-("left"===u?l:0),(Pe-I-A-B)/t)}}.call(this),h=o*t,(null!=(ae=G.get("aceConfig"))?ae.preferWideEditor:void 0)||("undefined"!=typeof features&&null!==features?features.china:void 0)?(i=Pe-h<500&&"right"===be?Math.max(Pe/1.82,Pe-500):h,this.$el.hasClass("real-time")&&(null!=(le=this.level)?le.isType("game-dev"):void 0)&&(i=Math.min(.8*Pe,h)),o=i/t):i=function(){var e,t;switch(!1){case!((null!=(e=this.level)?e.isType("game-dev"):void 0)&&this.$el.hasClass("real-time")):return Math.min(.8*Pe,h);case!(null!=(t=this.level)?t.isType("web-dev"):void 0):return Pe-I;default:return h}}.call(this),m=0==("bottom"!==be)?0:Te-o-("left"===u?l:0),y=0==("right"!==be)?0:(Pe-i)/2,d=function(){switch(!1){case"none"!==u&&"left"!==u:return i;case"right"!==u:return Pe-i;default:return Pe}}(),c="right"===u?i:0,ke="right"===be?Pe-i+6:Pe,ye=function(){switch(!1){case"bottom"!==be:return Te-o-l;case!s:return Te;case"right"!==u&&"top"!==u:return Te-l;default:return Te}}(),we=function(){switch(!1){case"bottom"!==be:return l+o;case"right"!==u:return 50;default:return 0}}(),Ie=function(){switch(!1){case"none"!==Me:return 0;case"left-half"!==Me&&"bottom-left-half"!==Me:return ke-B;case"middle-third"!==Me&&"bottom-middle-third"!==Me:return A/(A+I)*(ke-B);default:return ke}}(),Le="none"===Me?0:ye-46,Ce=0==("none"!==_e)?0:B,a=function(){switch(!1){case"none"!==r:return 0;case"left-third"!==r&&"bottom-left-third"!==r:return ke-Ie-Ce;default:return ke}}(),O=m>15?"below":"bottom",V=Math.min(m-58,-5),_=m>60?"below":"none",w=function(){var e;switch(!1){case"bottom"!==be:return l+o;case"right"!==u:return o+60+V;case!(null!=(e=this.level)?e.isType("web-dev"):void 0):return l+o;default:return l+o+60+V}}.call(this),b=function(){var e;switch(!1){case!(null!=(e=this.level)?e.isType("web-dev"):void 0):case"bottom"!==O:return w-10;default:return w}}.call(this),g=(i-500)/2,v=o-60+("below"===O?V:-32),p="bottom"===be?(i-417)/2:i-417-50,C="right"===u?40:5,k=Pe-i+12,fe=o-30-("right"===u?50:0),this.$el[0].dataset.tomeLocation=be,this.$el[0].dataset.workspaceLocation=Me,this.$el[0].dataset.toolboxLocation=_e,this.$el[0].dataset.spellPaletteLocation=me,this.$el[0].dataset.codeLocation=r,this.$el[0].dataset.playButtonLocation=R,this.$el[0].dataset.controlBarLocation=u,this.$el[0].dataset.playbackLocation=O,this.$el[0].dataset.hudLocation=_,this.$el.find("#canvas-wrapper").css({width:i,height:o,left:y}),this.$el.find("#level-footer-shadow").css({top:b}),this.$el.find("#control-bar-view").css({width:d,height:l,left:c}),this.$el.find("#playback-view").css({width:i,marginTop:V}),this.$el.find("#thang-hud").css({width:i}),this.$el.find("#thang-hud .center").css({maxWidth:i}),this.$el.find("#gold-view").css({right:Pe-i+12,top:12}),this.$el.find("#code-area").css({width:ke,height:ye,top:we}),this.$el.find("#solution-area").css({right:ke,width:ke,height:ye,top:we,bottom:"unset",left:"unset"}),"bottom"===be&&this.$el.find("#solution-area").css({right:"unset",left:"-54px",top:0,width:ke,height:"auto"}),/blocks/.test(this.codeFormat)&&this.$el.find("#code-area #tome-view #spell-view .ace_editor").css({width:a}),/blocks/.test(this.codeFormat)&&this.$el.find("#solution-area .ace_editor").css({width:a}),this.$el.find("#code-area #tome-view #spell-view .blockly-container").css({width:Ie+Ce,height:Le,left:a}),this.$el.find("#duel-stats-view").css({left:g,top:v}),this.$el.find("#level-dialogue-view").css({left:p}),this.$el.find("#level-chat-view").css({bottom:C}),this.$el.find("#game-dev-track-view").css({right:k,top:12}),this.$el.find("#stop-real-time-playback-button").css({top:fe})}
1,t.prototype.onDisableControls=function(e){if(!e.controls||Z.call(e.controls,"level")>=0)return this.shortcutsEnabled=!1,this.wasFocusedOn=document.activeElement,Q("body").focus()},t.prototype.onEnableControls=function(e){if(null==e.controls||Z.call(e.controls,"level")>=0)return this.shortcutsEnabled=!0,this.wasFocusedOn&&Q(this.wasFocusedOn).focus(),this.wasFocusedOn=null},t.prototype.onDonePressed=function(){return this.showVictory()},t.prototype.onShowVictory=function(e){var t,o,n,i,s;if(null==e&&(e={}),this.level.isType("hero","hero-ladder","hero-coop","course","course-ladder","game-dev","web-dev","ladder")||Q("#level-done-button").show(),e.showModal&&this.showVictory(_.pick(e,"manual")),!this.victorySeen)return this.victorySeen=!0,s=new Date-this.loadEndTime,!this.observing&&!this.isEditorPreview&&s>1e4?(null!=(t=K.tracker)&&t.trackEvent("Saw Victory",{category:"Play Level",level:this.level.get("name"),label:this.level.get("name"),levelID:this.levelID,ls:null!=(o=this.session)?o.get("_id"):void 0,playtime:null!=(n=this.session)?n.get("playtime"):void 0}),null!=(i=K.tracker)?i.trackTiming(s,"Level Victory Time",this.levelID,this.levelID):void 0):void 0},t.prototype.showVictory=function(e){var t,o,n,i;if(null==e&&(e={}),!this.level.hasLocalChanges()&&(!this.level.isType("game-dev")||!this.level.get("shareable")||e.manual)&&!this.showVictoryHandlingInProgress)return this.showVictoryHandlingInProgress=!0,this.endHighlight(),e={level:this.level,supermodel:this.supermodel,session:this.session,hasReceivedMemoryWarning:this.hasReceivedMemoryWarning,courseID:this.courseID,courseInstanceID:this.courseInstanceID,world:this.world,parent:this,parentCampaign:this.parentCampaign},t=this.level.isType("hero","hero-ladder","hero-coop","course","course-ladder","game-dev","web-dev","ladder")?m:N,(this.isCourseMode()||G.isSessionless())&&(t=a),(this.level.isType("course-ladder")||this.level.isType("ladder")&&this.courseInstanceID)&&(t=a,e.courseInstanceID=q.getQueryVariable("course-instance")||q.getQueryVariable("league")),n=new t(e),this.openModalView(n),n.once("hidden",(i=this,function(){return i.showVictoryHandlingInProgress=!1})),G.get("anonymous")?(o=this.parentCampaign||this.level.get("campaign"),window.nextURL="/play/"+(null!=o?o:"")):void 0},t.prototype.onRestartLevel=function(){var e;if(this.tome.reloadAllCode(),Backbone.Mediator.publish("level:restarted",{}),Q("#level-done-button",this.$el).hide(),!this.observing&&!this.isEditorPreview)return null!=(e=K.tracker)?e.trackEvent("Confirmed Restart",{category:"Play Level",level:this.level.get("name"),label:this.level.get("name")}):void 0},t.prototype.onInfiniteLoop=function(e){var t;if(e.firstWorld&&e.god===this.god)return this.openModalView(new b({nonUserCodeProblem:e.nonUserCodeProblem,problem:e.problem,timedOut:e.timedOut})),this.observing||this.isEditorPreview?void 0:null!=(t=K.tracker)?t.trackEvent("Saw Initial Infinite Loop",{category:"Play Level",level:this.level.get("name"),label:this.level.get("name")}):void 0},t.prototype.onHighlightDOM=function(e){return this.highlightElement(e.selector,{delay:e.delay,sides:e.sides,offset:e.offset,rotation:e.rotation})},t.prototype.onEndHighlight=function(){return this.endHighlight()},t.prototype.onFocusDom=function(e){return Q(e.selector).focus()},t.prototype.onContactClicked=function(e){var t,o,n;if(!G.isStudent())return Backbone.Mediator.publish("level:contact-button-pressed",{}),this.openModalView(o=new s({levelID:this.level.get("slug")||this.level.id,courseID:this.courseID,courseInstanceID:this.courseInstanceID})),t={b64png:(n=this.surface.screenshot(1,"image/png",1,1)).replace("data:image/png;base64,",""),filename:"screenshot-"+this.levelID+"-"+_.string.slugify((new Date).toString())+".png",path:"db/user/"+G.id,mimetype:"image/png"},o.screenshotURL="http://codecombat.com/file/"+t.path+"/"+t.filename,window.screenshot=n,window.screenshotURL=o.screenshotURL,Q.ajax("/file",{type:"POST",data:t,success:function(e){return"function"==typeof o.updateScreenshot?o.updateScreenshot():void 0}});console.error("Student clicked contact modal.")},t.prototype.onSurfaceContextMenu=function(e){var t,o;if(null!=e&&"function"==typeof e.preventDefault&&e.preventDefault(),!this.$el.hasClass("real-time")&&this.surface.showCoordinates&&(navigator.clipboard||document.queryCommandSupported("copy")))return t={x:e.clientX,y:e.clientY},o=this.surface.coordinateDisplay.lastPos,Backbone.Mediator.publish("level:surface-context-menu-pressed",{posX:t.x,posY:t.y,wopX:o.x,wopY:o.y})},t.prototype.onNewWorld=function(e){var t,o,i,s,r,a,l,c,u,d,h,p,g;if(!this.headless){for(c=this.world.scripts,this.world=e.world,this.world.age>0&&this.willUpdateStudentGoals&&(this.willUpdateStudentGoals=!1,this.updateStudentGoals(),this.updateLevelName()),this.world.scripts=c,g=this.supermodel.getModels(V),h=null!=(r=this.lastWorldFramesLoaded)?r:0,t=this.world.frames.length===this.world.totalFrames,this.realTimePlaybackWaitingForFrames=!1,t?(this.lastWorldFramesLoaded=0,this.waitingForSubmissionComplete&&(_.defer(this.onSubmissionComplete),this.waitingForSubmissionComplete=!1)):this.lastWorldFramesLoaded=this.world.frames.length,o=0,i=(a=this.world.thangDialogueSounds(h)).length;o<i;o++)l=a[o],d=l[0],s=l[1],(p=_.find(g,(function(e){return e.get("name")===d})))&&(u=n.soundForDialogue(s,p.get("soundTriggers")))&&n.preloadSoundReference(u);return this.level.isType("game-dev","hero","course")?this.session.updateKeyValueDb(e.keyValueDb):void 0}},t.prototype.onRealTimePlaybackStarted=function(e){return this.$el.addClass("real-time").focus(),this.willUpdateStudentGoals=!0,this.updateStudentGoals(),this.updateLevelName(),this.onWindowResize(),this.realTimePlaybackWaitingForFrames=!0},t.prototype.updateStudentGoals=function(){var e,t,o;if(this.level.isType("game-dev"))return(null!=(e=this.world.uiText)&&null!=(t=e.directions)?t.length:void 0)?this.studentGoals=this.world.uiText.directions.map((function(e){return{type:"user_defined",direction:e}})):this.studentGoals=null!=(o=this.world.thangMap["Hero Placeholder"].stringGoals)?o.map((function(e){return JSON.parse(e)})):void 0,this.renderSelectors("#how-to-play-game-dev-panel"),this.$("#how-to-play-game-dev-panel").removeClass("hide")},t.prototype.updateKeyValueDb=function(){var e;if(null!=(e=this.world)?e.keyValueDb:void 0)return this.session.updateKeyValueDb(_.cloneDeep(this.world.keyValueDb)),this.session.saveKeyValueDb()},t.prototype.updateLevelName=function(){var e;if(null!=(e=this.world.uiText)?e.levelName:void 0)return this.controlBar.setLevelName(this.world.uiText.levelName)},t.prototype.onRealTimePlaybackEnded=function(e){var t;if(this.$el.hasClass("real-time"))return this.level.isType("game-dev")&&this.$("#how-to-play-game-dev-panel").addClass("hide"),this.$el.removeClass("real-time"),this.onWindowResize(),this.level.isType("game-dev","hero","course")&&this.session.saveKeyValueDb(),this.world.frames.length!==this.world.totalFrames||(null!=(t=this.surface.countdownScreen)?t.showing:void 0)||this.realTimePlaybackWaitingForFrames?this.waitingForSubmissionComplete=!0:_.delay(this.onSubmissionComplete,750)},t.prototype.onCinematicPlaybackStarted=function(e){return this.$el.addClass("cinematic").focus(),this.onWindowResize()},t.prototype.onCinematicPlaybackEnded=function(e){if(this.$el.hasClass("cinematic"))return this.$el.removeClass("cinematic"),this.onWindowResize()},t.prototype.onSubmissionComplete=function(){var e;if(!this.destroyed&&(Backbone.Mediator.publish("level:set-time",{ratio:1}),!this.level.hasLocalChanges()))return"success"===this.goalManager.checkOverallStatus()?(e=function(){return Backbone.Mediator.publish("level:sh
1ow-victory",{showModal:!0})},this.session.recordScores(this.world.scores,this.level),this.level.get("replayable")?this.session.increaseDifficulty(e):e()):void 0},t.prototype.destroy=function(){var e,o,n,i,s,r,a,l,c;return null!=(o=this.levelLoader)&&o.destroy(),null!=(n=this.surface)&&n.destroy(),null!=(i=this.god)&&i.destroy(),null!=(s=this.goalManager)&&s.destroy(),null!=(r=this.scriptManager)&&r.destroy(),null!=(a=this.setupManager)&&a.destroy(),null!=(l=this.simulator)&&l.destroy(),(e=this.ambientSound)&&F.Tween.get(e).to({volume:0},1500).call((function(){return e.stop()})),Q(window).off("resize",this.onWindowResize),delete window.world,null!=(c=this.bus)&&c.destroy(),delete window.nextURL,this.checkTournamentEndInterval&&clearInterval(this.checkTournamentEndInterval),Backbone.Mediator.unsubscribe("modal:closed",this.onLevelStarted,this),Backbone.Mediator.unsubscribe("audio-player:loaded",this.playAmbientSound,this),Q(".cc-revoke.play-level-temp-hidden, .cc-window.play-level-temp-hidden").show().removeClass("play-level-temp-hidden"),t.__super__.destroy.call(this)},t.prototype.onIPadMemoryWarning=function(e){return this.hasReceivedMemoryWarning=!0},t.prototype.onItemPurchased=function(e){var t,o,n,i,s;if(t=null!=(n=(null!=(o=this.session.get("heroConfig"))?o:{}).inventory)?n:{},(s=e.item.getAllowedSlots()[0])&&!t[s])return null!=(i=this.setupManager)&&i.destroy(),this.setupManager=new P({supermodel:this.supermodel,level:this.level,levelID:this.levelID,parent:this,session:this.session,hadEverChosenHero:!0}),this.setupManager.open()},t.prototype.onCloseSolution=function(){return Backbone.Mediator.publish("level:close-solution",{})},t.prototype.onApplySolution=function(){return Backbone.Mediator.publish("level:apply-solution",{})},t.prototype.getLoadTrackingTag=function(){var e;return null!=(e=this.level)?e.get("slug"):void 0},t.prototype.onRunCode=function(){return this.updateKeyValueDb(),z.commit("game/incrementTimesCodeRun")},t.prototype.onCodeFormatChanged=function(e){return this.codeFormat=e.codeFormat,e.oldCodeFormat&&this.$el.removeClass(e.oldCodeFormat),this.$el.addClass(e.codeFormat)},t}(I)},110905:(e,t,o)=>{var n,i,s,r,a,l,c=o(619755),u={}.hasOwnProperty;o(183942),s=o(976911),n=o(523402),i=o(444705),r=o(166882),a=o(694879),o(830356),l=o(299498),e.exports=function(e){function t(){return t.__super__.constructor.apply(this,arguments)}return function(e,t){for(var o in t)u.call(t,o)&&(e[o]=t[o]);function n(){this.constructor=e}n.prototype=t.prototype,e.prototype=new n,e.__super__=t.prototype}(t,e),t.prototype.id="play-web-dev-level-view",t.prototype.template=o(46347),t.prototype.initialize=function(e,o){return this.options=e,this.sessionID=o,t.__super__.initialize.call(this,this.options),this.courseID=l.getQueryVariable("course"),this.session=this.supermodel.loadModel(new i({_id:this.sessionID})).model,this.level=new n,this.session.once("sync",(s=this,function(){var e;return e=s.supermodel.addSomethingResource("level"),a.levels.getByOriginal(s.session.get("level").original).then((function(t){return s.levelID=t.slug,s.level.set({_id:s.levelID}),s.level.fetch(),s.level.once("sync",(function(){return e.markLoaded(),s.setMeta({title:c.i18n.t("play.web_development_title",{level:s.level.get("name")})})}))}))}));var s},t.prototype.getMeta=function(){return{links:[{vmid:"rel-canonical",rel:"canonical",href:"/play"}]}},t.prototype.onLoaded=function(){var e,o;return t.__super__.onLoaded.call(this),this.insertSubView(this.webSurface=new r({level:this.level})),Backbone.Mediator.publish("tome:html-updated",{html:null!=(e=this.getHTML())?e:"<h1>Player has no HTML</h1>",create:!0}),this.$el.find("#info-bar").delay(4e3).fadeOut(2e3),c("body").css("overflow","hidden"),this.eventProperties={category:"Play WebDev Level",courseID:this.courseID,sessionID:this.session.id,levelID:this.level.id,levelSlug:this.level.get("slug")},null!=(o=window.tracker)?o.trackEvent("Play WebDev Level - Load",this.eventProperties):void 0},t.prototype.showError=function(e){return c("h1").text(e.statusText)},t.prototype.getHTML=function(){var e,t,o,n,i;return t=null!=(n=this.session.get("code"))&&null!=(i=n["hero-placeholder"])?i.plan:void 0,(e=_.find(this.level.get("thangs"),{id:"Hero Placeholder"}))&&(o=_.find(e.components,(function(e){var t;return null!=(t=e.config)?t.programmableMethods:void 0})).config)?o.programmableMethods.plan.languages.html.replace(/<playercode>[\s\S]*<\/playercode>/,t):t},t.prototype.destroy=function(){var e;return null!=(e=this.webSurface)&&e.destroy(),c("body").css("overflow","initial"),t.__super__.destroy.call(this)},t}(s)},448917:(e,t,o)=>{var n,i={}.hasOwnProperty;o(589083),n=o(968029),e.exports=function(e){function t(e){this.supermodel=e.supermodel,t.__super__.constructor.call(this,e),this.level=e.level,this.session=e.session}return function(e,t){for(var o in t)i.call(t,o)&&(e[o]=t[o]);function n(){this.constructor=e}n.prototype=t.prototype,e.prototype=new n,e.__super__=t.prototype}(t,e),t.prototype.id="surface-context-menu-view",t.prototype.className="surface-context-menu",t.prototype.template=o(59715),t.prototype.events={"click #copy":"onClickCopy"},t.prototype.subscriptions={"level:surface-context-menu-pressed":"showView","level:surface-context-menu-hide":"hideView"},t.prototype.destroy=function(){return t.__super__.destroy.call(this)},t.prototype.afterInsert=function(){return t.__super__.afterInsert.call(this),this.hideView()}
1,t.prototype.afterRender=function(){return t.__super__.afterRender.call(this)},t.prototype.onClickCopy=function(e){var t;return navigator.clipboard?navigator.clipboard.writeText(this.coordinates):document.queryCommandSupported("copy")?((t=document.createElement("textarea")).value=this.coordinates,document.body.appendChild(t),t.focus(),t.select(),document.execCommand("copy"),document.body.removeChild(t)):void 0},t.prototype.setPosition=function(e){return this.$el.css("left",e.posX),this.$el.css("top",e.posY)},t.prototype.setCoordinates=function(e){var t;return this.coordinates=e.wopX+", "+e.wopY,t="copy "+this.coordinates,this.copyMessage=t},t.prototype.hideView=function(){return this.$el.hide()},t.prototype.showView=function(e){return this.$el.show(),this.setCoordinates(e),this.setPosition(e),this.render()},t}(n)},166882:(e,t,o)=>{var n,i,s,r=o(619755),a=function(e,t){return function(){return e.apply(t,arguments)}},l={}.hasOwnProperty;o(395631),n=o(968029),s=o(56283),i=o(212764),e.exports=function(e){function t(){return this.onIframeMessage=a(this.onIframeMessage,this),t.__super__.constructor.apply(this,arguments)}return function(e,t){for(var o in t)l.call(t,o)&&(e[o]=t[o]);function n(){this.constructor=e}n.prototype=t.prototype,e.prototype=new n,e.__super__=t.prototype}(t,e),t.prototype.id="web-surface-view",t.prototype.template=s,t.prototype.subscriptions={"tome:html-updated":"onHTMLUpdated","web-dev:hover-line":"onHoverLine","web-dev:stop-hovering-line":"onStopHoveringLine"},t.prototype.initialize=function(e){var o;return this.goals=function(){var t,n,i,s,r,a;for(a=[],t=0,n=(r=null!=(i=null!=(s=e.goalManager)?s.goals:void 0)?i:[]).length;t<n;t++)(o=r[t]).html&&a.push(o);return a}(),t.__super__.initialize.call(this,e)},t.prototype.getRenderData=function(){return _.merge(t.__super__.getRenderData.call(this),{fullUnsafeContentHostname:serverConfig.fullUnsafeContentHostname})},t.prototype.afterRender=function(){return t.__super__.afterRender.call(this),this.iframe=this.$("iframe")[0],r(this.iframe).on("load",(e=this,function(t){return window.addEventListener("message",e.onIframeMessage),e.iframeLoaded=!0,"function"==typeof e.onIframeLoaded&&e.onIframeLoaded(),e.onIframeLoaded=null}));var e},t.prototype.onHTMLUpdated=function(e){var t,o,n,s,r;return this.iframeLoaded?(o=i.extractStylesAndScripts(e.html),this.virtualDom=o.virtualDom,s=o.styles,n=o.scripts,this.cssSelectors=i.extractCssSelectors(s,n),this.rawCssLines=i.extractCssLines(s),this.rawJQueryLines=i.extractJQueryLines(n),t=e.create||!this.virtualDom?"create":"update",this.iframe.contentWindow.postMessage({type:t,dom:this.virtualDom,styles:s,scripts:n,goals:this.goals},"*")):this.onIframeLoaded=(r=this,function(){if(!r.destroyed)return r.onHTMLUpdated(e)})},t.prototype.combineNodes=function(e,t){var o;if(_.any(t,(function(t){return t.type!==e})))throw new Error("Can't combine nodes of different types. (Got "+t.map((function(e){return e.type}))+")");return o=t.map((function(e){return e.children})).reduce((function(e,t){return e.concat(t)}),[]),_.isEmpty(o)?deku.element(e,{}):deku.element(e,{},o)},t.prototype.onStopHoveringLine=function(){return this.iframe.contentWindow.postMessage({type:"highlight-css-selector",selector:""},"*")},t.prototype.onHoverLine=function(e){var t,o,n,i,s;return e.row,o=e.line,_.contains(this.rawCssLines,o)?(s=((null!=(n=o.match(/\s(.*)\s*{/))?n[1]:void 0)||o).trim().split(/ +/).join(" "),t=_.find(this.cssSelectors,(function(e){return s===e}))):_.contains(this.rawJQueryLines,o)?(s=((null!=(i=o.match(/\$\(\s*['"](.*)['"]\s*\)/))?i[1]:void 0)||"").trim(),t=_.find(this.cssSelectors,(function(e){return s===e}))):t="",this.iframe.contentWindow.postMessage({type:"highlight-css-selector",selector:t},"*"),null},t.prototype.onIframeMessage=function(e){var t;if(t=e.origin||e.originalEvent.origin,!new RegExp("^https?://"+serverConfig.fullUnsafeContentHostname+"$").test(t))return console.log("Ignoring message from bad origin:",t);if(e.source!==this.iframe.contentWindow)return console.log("Ignoring message from somewhere other than our iframe:",e.source);switch(e.data.type){case"goals-updated":return Backbone.Mediator.publish("god:new-html-goal-states",{goalStates:e.data.goalStates,overallStatus:e.data.overallStatus});case"error":return Backbone.Mediator.publish("web-dev:error",_.pick(e.data,["message","line","column","url"]));default:return console.warn("Unknown message type",e.data.type,"for message",e,"from origin",t)}},t.prototype.destroy=function(){return window.removeEventListener("message",this.onIframeMessage),t.__super__.destroy.call(this)},t}(n)},618729:(e,t,o)=>{var n,i,s,r,a,l,c,u=o(619755),d={}.hasOwnProperty;o(903534),n=o(968029),l=o(591435),a=o(28045).me,i=o(992148),s=o(444705),r=o(257629),c=o(299498),e.exports=function(e){function t(e){this.updateReplayability=function(e,t){return function(){return e.apply(t,arguments)}}(this.updateReplayability,this),t.__super__.constructor.call(this,e),this.spells=e.spells,this.castShortcut="⇧↵",this.updateReplayabilityInterval=setInterval(this.updateReplayability,1e3),this.observing=e.session.get("creator")!==a.id,this.options.level.get("mirrorMatch")&&this.loadMirrorSession(),this.mirror=null!=this.mirrorSession,this.autoSubmitsToLadder=this.options.level.isType("course-ladder"),e.session.get("published")&&Backbone.Mediator.publish("level:sh
1ow-victory",{showModal:!0,manual:!1})}return function(e,t){for(var o in t)d.call(t,o)&&(e[o]=t[o]);function n(){this.constructor=e}n.prototype=t.prototype,e.prototype=new n,e.__super__=t.prototype}(t,e),t.prototype.id="cast-button-view",t.prototype.template=l,t.prototype.events={"click .cast-button":"onCastButtonClick","click .submit-button":"onCastRealTimeButtonClick","click .done-button":"onDoneButtonClick","click .game-dev-play-btn":"onClickGameDevPlayButton"},t.prototype.subscriptions={"tome:spell-changed":"onSpellChanged","tome:cast-spells":"onCastSpells","tome:manual-cast-denied":"onManualCastDenied","god:new-world-created":"onNewWorld","goal-manager:new-goal-states":"onNewGoalStates","god:goals-calculated":"onGoalsCalculated","playback:ended-changed":"onPlaybackEndedChanged","playback:playback-ended":"onPlaybackEnded"},t.prototype.destroy=function(){return clearInterval(this.updateReplayabilityInterval),t.__super__.destroy.call(this)},t.prototype.afterRender=function(){var e,o,n,i,s;for(s in t.__super__.afterRender.call(this),this.castButton=u(".cast-button",this.$el),e=this.spells)null!=(o=e[s].view)&&o.createOnCodeChangeHandlers();return(this.options.level.get("hidesSubmitUntilRun")||this.options.level.get("hidesRealTimePlayback")||this.options.level.isType("web-dev"))&&this.$el.find(".submit-button").hide(),(null!=(n=this.options.session.get("state"))?n.complete:void 0)&&(this.options.level.get("hidesRealTimePlayback")||this.options.level.isType("web-dev"))&&this.$el.find(".done-button").show(),"course-thornbush-farm"!==(i=this.options.level.get("slug"))&&"thornbush-farm"!==i||this.$el.find(".submit-button").hide(),this.updateButtonWidth(),this.updateReplayability(),this.updateLadderSubmissionViews()},t.prototype.attachTo=function(e){return this.$el.detach().prependTo(e.toolbarView.$el).show(),this.updateButtonWidth()},t.prototype.castShortcutVerbose=function(){return u.i18n.t("keyboard_shortcuts.shift")+"+"+u.i18n.t("keyboard_shortcuts.enter")},t.prototype.castVerbose=function(){return this.castShortcutVerbose()+": "+u.i18n.t("keyboard_shortcuts.run_code")},t.prototype.castRealTimeVerbose=function(){return(this.isMac()?"Cmd":"Ctrl")+"+"+this.castShortcutVerbose()+": "+u.i18n.t("keyboard_shortcuts.run_real_time")},t.prototype.onCastButtonClick=function(e){return Backbone.Mediator.publish("tome:manual-cast",{realTime:!1}),Backbone.Mediator.publish("level:close-solution",{})},t.prototype.onCastRealTimeButtonClick=function(e){var t;return this.options.level.get("replayable")&&(t=this.options.session.timeUntilResubmit())>0?Backbone.Mediator.publish("tome:manual-cast-denied",{timeUntilResubmit:t}):Backbone.Mediator.publish("tome:manual-cast",{realTime:!0}),this.updateReplayability()},t.prototype.onClickGameDevPlayButton=function(){return Backbone.Mediator.publish("tome:manual-cast",{realTime:!0})},t.prototype.onDoneButtonClick=function(e){var t;if(!this.options.level.hasLocalChanges())return this.options.session.recordScores(null!=(t=this.world)?t.scores:void 0,this.options.level),Backbone.Mediator.publish("level:show-victory",{showModal:!0,manual:!0})},t.prototype.onSpellChanged=function(e){return this.updateCastButton()},t.prototype.onCastSpells=function(e){if(!e.preload)return this.casting=!0,this.hasStartedCastingOnce&&(this.options.level.isType("game-dev")||this.playSound("cast",.5)),this.hasStartedCastingOnce=!0,this.updateCastButton()},t.prototype.onManualCastDenied=function(e){var t;return t=moment().add(e.timeUntilResubmit,"ms").fromNow(),noty({text:"You can try again "+t+".",layout:"center",type:"warning",killer:!1,timeout:6e3})},t.prototype.onNewWorld=function(e){var t,o,n,i;return this.casting=!1,this.hasCastOnce&&(this.options.level.isType("game-dev")||this.playSound("cast-end",.5),t="ogres"===a.team?"Hero Placeholder 1":"Hero Placeholder",(n=this.autoSubmitsToLadder||this.options.level.isType("ladder")&&!this.options.session.get("submitDate")&&!this.autosubmittedOnce)&&(n=!(null!=(o=e.world.thangMap[t])?o.errorsOut:void 0)&&!a.get("anonymous")),n&&(this.autosubmittedOnce=!0,this.ladderSubmissionView&&_.delay((i=this,function(){var e;
1return null!=(e=i.ladderSubmissionView)?e.rankSession():void 0}),1e3))),this.hasCastOnce=!0,this.updateCastButton(),this.world=e.world},t.prototype.onPlaybackEnded=function(e){if(this.winnable&&("codecombat"!==this.options.level.get("product",!0)||c.isOzaria)&&"capstone"!==this.options.level.get("ozariaType"))return Backbone.Mediator.publish("level:show-victory",{showModal:!0,manual:!0})},t.prototype.onNewGoalStates=function(e){var t,o;if(o="success"===e.overallStatus,this.winnable!==o)return this.winnable=o,this.$el.toggleClass("winnable",this.winnable),Backbone.Mediator.publish("tome:winnability-updated",{winnable:this.winnable,level:this.options.level}),"resource-tycoon"===this.options.level.get("slug")||(this.options.level.get("hidesRealTimePlayback")||this.options.level.isType("web-dev","game-dev")?this.$el.find(".done-button").toggle(this.winnable):!this.winnable||"course-thornbush-farm"!==(t=this.options.level.get("slug"))&&"thornbush-farm"!==t||this.$el.find(".submit-button").show()),this.updateButtonWidth()},t.prototype.onGoalsCalculated=function(e){var t;if(e.god===this.god&&e.preload&&!this.options.level.get("hidesRealTimePlayback")&&"course-thornbush-farm"!==(t=this.options.level.get("slug"))&&"thornbush-farm"!==t)return this.onNewGoalStates(e)},t.prototype.onPlaybackEndedChanged=function(e){if(e.ended&&this.winnable)return this.$el.toggleClass("has-seen-winning-replay",!0)},t.prototype.updateCastButton=function(){var e;if(!_.some(this.spells,(function(e){return!e.loaded})))return r.some(_.values(this.spells),(function(e,t){return e.hasChangedSignificantly(e.getSource(),null,t)}),(e=this,function(t){var o,n;return Backbone.Mediator.publish("tome:spell-has-changed-significantly-calculation",{hasChangedSignificantly:t}),e.castButton.toggleClass("castable",t).toggleClass("casting",e.casting),e.casting?o=u.i18n.t("play_level.tome_cast_button_running"):(o=u.i18n.t("play_level.tome_cast_button_run"),e.options.level.get("hidesRunShortcut")||(o+=" "+e.castShortcut)),"codecombat-junior"!==e.options.level.get("product")&&e.castButton.text(o),null!=(n=e.ladderSubmissionView)?n.updateButton():void 0}))},t.prototype.updateButtonWidth=function(){var e;return e=this.$el.find(".btn:visible").length,this.castButton.add(".game-dev-play-btn").toggleClass("full-width",1===e)},t.prototype.updateReplayability=function(){var e,t,o,n;if(!this.destroyed&&this.options.level.get("replayable"))return e=(o=this.options.session.timeUntilResubmit())>0,t=this.$el.find(".submit-button").toggleClass("disabled",e).find(".submit-again-time").toggleClass("secret",!e),e?(n=moment().add(o,"ms").fromNow(),t.text(n)):void 0},t.prototype.loadMirrorSession=function(){var e,t;return t="/db/level/"+(this.options.level.get("slug")||this.options.level.id)+"/session",t+="?team="+("humans"===a.team?"ogres":"humans"),e=(new s).setURL(t),this.mirrorSession=this.supermodel.loadModel(e,{cache:!1}).model,this.listenToOnce(this.mirrorSession,"sync",(function(){var e;return null!=(e=this.ladderSubmissionView)?e.mirrorSession=this.mirrorSession:void 0}))},t.prototype.updateLadderSubmissionViews=function(){var e,t,o,n;for(e in o=this.subviews)(n=o[e])instanceof i&&this.removeSubView(n);if((t=this.$el.find(".ladder-submission-view")).length)return this.ladderSubmissionView=new i({session:this.options.session,level:this.options.level,mirrorSession:this.mirrorSession}),this.insertSubView(this.ladderSubmissionView,t)},t}(n)},878001:(e,t,o)=>{var n,i,s,r,a=o(619755);n=o(575945),window.Vector=o(317158),r=o(299498),s=o(284358),i=function(e,t){var o,n,i,s;return n=function(e,o,r){var a,l,c,u;if(a={},c=void 0,u=void 0,o=o||"",r=r||0,r++,t&&r>t)return"{depth over "+t+"}";for(l in e)c=(o?o+".":"")+l,"function"==typeof e[l]?a[l]="{function}":"object"==typeof e[l]?-1!==(u=i.indexOf(e[l]))?a[l]="{reference to "+s[u]+"}":(i.push(e[l]),s.push(c),a[l]=n(e[l],c,r)):a[l]=e[l];return a},i=[],s=[],t=t||5,o="object"==typeof e?n(e):e,JSON.stringify(o,null,1)},e.exports=function(){function e(e){this.options=e,this.doc=_.cloneDeep(this.options.doc),this.fillOutDoc()}return e.prototype.fillOutDoc=function(){var e,t,o,n,i,a,l,c,u,d,h,p,g,v,m,f,y,b,w,k,S,C,x,T,P,L,M,I,D,B,A,E,R,O,V,$,N,j,F,H,G,U,z,W;for(_.isString(this.doc)&&(this.doc={name:this.doc,type:typeof this.options.thang[this.doc]}),this.options.isSnippet?(this.doc.type="snippet",this.doc.owner="snippets",this.doc.shortName=this.doc.shorterName=this.doc.title=this.doc.name):"HTML"===(w=this.doc.owner)||"CSS"===w||"WebJavaScript"===w||"jQuery"===w?this.doc.shortName=this.doc.shorterName=this.doc.title=this.doc.name:(null==(n=this.doc).owner&&(n.owner="this"),y=function(){if("this"!==this.doc.owner)return this.doc.owner;switch(this.options.language){case"python":case"lua":case"java":case"cpp":default:return"hero";case"coffeescript":return"@"}}.call(this),this.options.level.isType("game-dev")&&(y="game"),this.doc.ownerName=y,"spawnable"===this.doc.type||"hero"===this.doc.ownerName&&"codecombat-junior"===this.options.level.get("product")?this.doc.shortName=this.doc.name:"function"===this.doc.type?(k=this.getDocNameAndArguments(),a=k[0],t=k[1].join(", "),o=t?"__ARGS__":"",this.doc.shortName=function(){switch(this.options.language){case"coffeescript":return y+("@"===y?"":".")+a+(o?" "+o:"()");case"python":return y+"."+a+"("+o+")";case"lua":return y+":"+a+"("+o+")";default:return y+"."+a+"("+o+");"}}.call(this)):this.doc.shortName=function(){switch(this.options.language){case"coffeescript":return y+("@"===y?"":".")+this.doc.name;case"python":case"lua":return y+"."+this.doc.name;default:return y+"."+this.doc.name+";"}}.call(this),this.doc.shorterName=this.doc.shortName,"function"===this.doc.type&&o&&(this.doc.shortName=this.doc.shorterName.replace(o,t),this.doc.shorterName=this.doc.shorterName.replace(o,!/cast[A-Z]/.test(this.doc.name)&&t.length>6?"...":t)),"event"!==(B=this.doc.type)&&"handler"!==B||(this.doc.shortName=this.doc.name,this.doc.shorterName=this.doc.name),"property"===this.doc.type&&(this.doc.shortName=this.doc.name.split(".").pop()||this.doc.name,this.doc.shorterName=this.doc.shortName),"ui"===this.doc.owner&&(this.doc.shortName=this.doc.shortName.replace(/^game./,""),this.doc.shorterName=this.doc.shortName),"javascript"===(A=this.options.language)||"java"===A||"cpp"===A?(this.doc.shorterName=this.doc.shortName.replace(";",""),("this"===this.doc.owner||this.options.tabbify||"game"===y)&&(this.doc.shorterName=this.doc.shorterName.replace(/^(this|hero)\./,""))):"python"!==(E=this.options.language)&&"lua"!==E||"this"!==this.doc.owner&&!this.options.tabbify&&"game"!==y||(this.doc.shorterName=this.doc.shortName.replace(/^(self|hero|game)[:.]/,"")),this.doc.title=this.options.shortenize?this.doc.shorterName:this.doc.shortName,(U=r.i18n(this.doc,"name"))!==this.doc.name&&(this.doc.translatedShortName=this.doc.shortName.replace(this.doc.name,U))),"spawnable"!==this.doc.type||this.doc.example||(this.doc.example={javascript:"var "+_.string.camelize(this.doc.name)+' = game.
1spawnXY("'+this.doc.name+'", 21, 20)'}),G=[{obj:this.doc,prop:"description"},{obj:this.doc,prop:"example"}],u=0,p=(O=null!=(R=this.doc.args)?R:[]).length;u<p;u++)e=O[u],G.push({obj:e,prop:"example"},{obj:e,prop:"description"});for(this.doc.returns&&G.push({obj:this.doc.returns,prop:"example"},{obj:this.doc.returns,prop:"description"}),d=0,g=G.length;d<g;d++)if(!(null!=($=(m=(V=G[d]).obj)[b=V.prop])?$[this.options.language]:void 0)&&(null!=(N=m[b])?N.javascript:void 0)&&("example"===b?m[b][this.options.language]=s.translateJS(m[b].javascript,this.options.language,!1):"lua"===(S=this.options.language)||"coffeescript"===S||"python"===S?m[b][this.options.language]=null!=(C=m[b].python)?C:m[b].javascript:"java"!==(x=this.options.language)&&"cpp"!==x||(m[b][this.options.language]=m[b].javascript)),(z=null!=(T=m[b])?T[this.options.language]:void 0)?m[b]=z:_.isString(m[b])||(m[b]=null),z=f=m[b]){if(i=this.doc.context,m[b]=z=r.i18n(m,b),_.isObject(z)&&((W=null!=(P=m[b])?P[this.options.language]:void 0)?m[b]=z=W:m[b]=f),this.doc.i18n)for(j=me.get("preferredLanguage");j;){if(null!=c&&(j=j.substr(0,j.lastIndexOf("-"))),F=null!=(L=this.doc.i18n[j])?L.context:void 0){i=_.merge(i,F);break}c=!0}if(i)try{m[b]=_.template(z,i)}catch(e){l=e,console.error("Couldn't create docs template of",z,"\nwith context",i,"\nError:",l)}m[b]=this.replaceSpriteName(m[b])}if((H={python:/self/g,javascript:/this/g,java:/this/g,cpp:/this/g,lua:/self/g})[this.options.language]&&(this.doc.example&&(this.doc.example=this.doc.example.replace(H[this.options.language],"hero")),(null!=(M=this.doc.snippets)&&null!=(I=M[this.options.language])?I.code:void 0)&&this.doc.snippets[this.options.language].code.replace(H[this.options.language],"hero"),this.doc.args))for(h=0,v=(D=this.doc.args).length;h<v;h++)(e=D[h]).example&&(e.example=e.example.replace(H[this.options.language],"hero"));return this.doc.description&&this.options.thangType&&(this.doc.description="!["+this.options.thangType.get("name")+"]("+this.options.thangType.getPortraitURL()+") "+this.doc.description),null},e.prototype.formatPopover=function(){var e,t,o,i,s,l,c,u;return s=(c=this.getDocNameAndArguments())[0],t=c[1],o=function(){var t,o,n,i,s;for(s=[],t=0,o=(i=null!=(n=this.doc.args)?n:[]).length;t<o;t++)e=i[t],s.push(e.example||e.default||e.name);return s}.call(this),t.length>o.length&&o.unshift(t[0]),i=n({doc:this.doc,docName:s,language:this.options.language,value:this.formatValue(void 0,!0),marked,argumentExamples:o,writable:this.options.writable,cooldowns:this.inferCooldowns(),item:this.options.item,_,product:this.options.level.get("product")}),l="this"===this.doc.owner?this.options.thang:window[this.doc.owner],i=(i=(i=this.replaceSpriteName(i)).replace(/\#\{(.*?)\}/g,(u=this,function(e,t){return u.formatValue(r.downTheChain(l,t.split(".")))}))).replace(/{([a-z]+)}([^]*?){\/\1}/g,function(e){return function(t,o,n){var i;return o===e.options.language?n:"javascript"!==o||"java"!==(i=e.options.language)&&"cpp"!==i?"":n}}(this)),a("<div>"+i+"</div>").i18n().html()},e.prototype.replaceSpriteName=function(e){var t,o;return t=null!=(o=this.options.thang.type)?o:this.options.thang.spriteName,/Hero Placeholder/.test(this.options.thang.id)&&(t="hero"),e.replace(/(# ?{spriteName}|`spriteName`)/g,t)},e.prototype.getDocNameAndArguments=function(){var e,t,o;return"function"!==this.doc.type?[this.doc.name,[]]:(o=this.doc.name,t=function(){var t,o,n,i,s;for(s=[],t=0,o=(i=null!=(n=this.doc.args)?n:[]).length;t<o;t++)e=i[t],s.push(e.name);return s}.call(this),/cast[A-Z]/.test(o)&&(o="cast",t.unshift('"'+_.string.dasherize(this.doc.name).replace("cast-","")+'"')),[o,t])},e.prototype.formatValue=function(e,t){var o;return null==t&&(t=!1),this.options.level.isType("web-dev")||"snippet"===this.doc.type?null:"now"===this.doc.name?this.options.thang.now():null==e&&"function"===this.doc.type&&t?"[Function]":(null==e&&(e="this"===this.doc.owner?this.options.thang[this.doc.name]:window[this.doc.owner][this.doc.name]),"number"!==this.doc.type||_.isNaN(e)?_.isString(e)?'"'+e+'"':(null!=e?e.id:void 0)?e.id:(null!=e?e.name:void 0)?e.name:_.isArray(e)?"["+function(){var t,n,i;for(i=[],t=0,n=e.length;t<n;t++)o=e[t],i.push(this.formatValue(o));return i}.call(this).join(", ")+"]":_.isPlainObject(e)?i(e,2):e:e===Math.round(e)?e:_.isNumber(e)?e.toFixed(2):null==e?"null":""+e)},e.prototype.inferCooldowns=function(){var e,t,o,n,i,s,r,a,l,c,u,d,h;if("function"!==this.doc.type||"this"!==this.doc.owner)return null;if(s=this.options.thang,o=null,(u=this.doc.name.match(/^cast(.+)$/))?(t=_.string.slugify(_.string.underscored(u[1])),e=null!=(a=s.spells)?a[t]:void 0,d="spell"):(t=_.string.slugify(_.string.underscored(this.doc.name)),e=null!=(l=s.actions)?l[t]:void 0,d="action"),!e)return null;for(o={cooldown:e.cooldown,specificCooldown:e.specificCooldown,name:t,type:d},n=0,i=(c=["range","radius","duration","damage"]).length;n<i;n++)r=c[n],h=s[_.string.camelize(t+_.string.capitalize(r))],"range"===r&&h<=5||(o[r]=h,_.isNumber(h)&&h!==Math.round(h)&&
1(o[r]=h.toFixed(2)));return o},e}()},489097:(e,t,o)=>{var n,i,s,r,a,l,c=o(619755),u=o(665420),d={}.hasOwnProperty;o(136048),n=o(968029),a=o(311688),s=o(28045).me,l=o(482156),r=o(299498).shouldShowAiBotHelp,i=o(504015),e.exports=function(e){function t(e){this.onWindowResize=function(e,t){return function(){return e.apply(t,arguments)}}(this.onWindowResize,this),this.supermodel=e.supermodel,t.__super__.constructor.call(this,e),this.level=e.level,this.session=e.session,this.aceConfig=e.aceConfig||{},null!=e.problem?(this.problem=e.problem,this.onWindowResize()):this.$el.hide(),this.duckImg=_.sample(this.duckImages),c(window).on("resize",this.onWindowResize),i.userCreditsMessage||(i.userCredtisMessage=""),this.creditMessage=i.userCreditsMessage,this.showAiBotHelp=r(this.aceConfig)}return function(e,t){for(var o in t)d.call(t,o)&&(e[o]=t[o]);function n(){this.constructor=e}n.prototype=t.prototype,e.prototype=new n,e.__super__=t.prototype}(t,e),t.prototype.id="problem-alert-view",t.prototype.className="problem-alert",t.prototype.template=a,t.prototype.duckImages=["/images/pages/play/duck_alejandro.png","/images/pages/play/duck_anya2.png","/images/pages/play/duck_ida.png","/images/pages/play/duck_okar.png","/images/pages/play/duck_tharin2.png","/images/pages/play/duck_amara.png","/images/pages/play/duck_arryn.png","/images/pages/play/duck_hattori.png","/images/pages/play/duck_hushbaum.png","/images/pages/play/duck_illia.png","/images/pages/play/duck_nalfar.png","/images/pages/play/duck_naria.png","/images/pages/play/duck_omarn.png","/images/pages/play/duck_pender.png","/images/pages/play/duck_ritic.png","/images/pages/play/duck_senick.png","/images/pages/play/duck_usara.png","/images/pages/play/duck_zana.png"],t.prototype.subscriptions={"tome:show-problem-alert":"onShowProblemAlert","tome:hide-problem-alert":"onHideProblemAlert","level:restart":"onHideProblemAlert","tome:jiggle-problem-alert":"onJiggleProblemAlert","tome:manual-cast":"onHideProblemAlert","auth:user-credits-message-updates":"onUserCreditsMessageUpdates"},t.prototype.events={"click .close":"onRemoveClicked",click:function(){return Backbone.Mediator.publish("tome:focus-editor",{})},"click .ai-help-button":"onAIHelpClicked"},t.prototype.destroy=function(){return c(window).off("resize",this.onWindowResize),t.__super__.destroy.call(this)},t.prototype.afterRender=function(){if(c(".chatbot-hint").popover().click((function(){return setTimeout((function(){return c(".chatbot-hint").popover("hide")}),3e3)})),s.showChinaResourceInfo()||this.creditMessage||this.handleUserCreditsMessage(),t.__super__.afterRender.call(this),null!=this.problem)return this.$el.addClass("alert").addClass("alert-"+this.problem.level).hide().fadeIn("slow"),this.problem.hint||this.$el.addClass("no-hint"),this.playSound("error_appear")},t.prototype.setProblemMessage=function(){var e,t,o,n;if(this.problem)return t=function(e){if(null!=e)return marked(e)},o=this.problem.message,null!=this.problem.hint&&/(?:null|undefined)/.test(this.problem.hint)&&null!=(e=null!=(n=this.problem.userInfo)?n.age:void 0)&&(o=/^Line \d+:/.test(o)?o.replace(/^(Line \d+)/,"$1, time "+e.toFixed(1)):"Time "+e.toFixed(1)+": "+o),this.message=t(o),this.hint=t(this.problem.hint)},t.prototype.onShowProblemAlert=function(e){var t,o;if(c("#code-area").is(":visible")||this.level.isType("game-dev"))return null!=this.problem&&(this.$el.hasClass("alert-"+this.problem.level)&&this.$el.removeClass("alert-"+this.problem.level),this.$el.hasClass("no-hint")&&this.$el.removeClass("no-hint")),this.problem=e.problem,this.lineOffsetPx=e.lineOffsetPx||0,this.$el.show(),this.onWindowResize(),this.setProblemMessage(),this.render(),this.onJiggleProblemAlert(),null!=(t=u.tracker)?t.trackEvent("Show problem alert",{levelID:this.level.get("slug"),ls:null!=(o=this.session)?o.get("_id"):void 0}):void 0},t.prototype.onJiggleProblemAlert=function(){var e,t;if(null!=this.problem)return this.$el.is(":visible")||this.$el.show(),this.$el.addClass("jiggling"),this.playSound("error_appear"),t=this,e=function(){var e;return null!=(e=t.$el)?e.removeClass("jiggling"):void 0},_.delay(e,1e3)},t.prototype.onHideProblemAlert=function(){if(this.$el.is(":visible"))return this.onRemoveClicked()},t.prototype.onRemoveClicked=function(){return this.playSound("menu-button-click"),this.$el.hide(),Backbone.Mediator.publish("tome:focus-editor",{})},t.prototype.onAIHelpClicked=function(e){var t,o,n;return o=_.random(1,13),t=c.i18n.t("ai.prompt_level_chat_"+o),Backbone.Mediator.publish("level:add-user-chat",{message:t}),_.delay((n=this,function(){return n.handleUserCreditsMessage()}),5e3)},t.prototype.onWindowResize=function(e){var t,o,n,i,s,r,a;if(this.problem)return s=c("#code-area").offset().top>100?"bottom":"right",r=c("#code-area").outerWidth(),i="bottom"===s?"auto":r+40,o="bottom"===s?40:"auto",n=c("#game-area").innerWidth()-c("#goals-view").outerWidth(!0)-40,this.$el.css({left:o,right:i,maxWidth:n}),t=c("#code-area .ace").offset().top,a="bottom"===s?t-this.$el.outerHeight()-80:t+this.lineOffsetPx-this.$el.height()/2,this.$el.css({top:Math.max(60,a)}),null},t.prototype.handleUserCreditsMessage=function(){return l.updateUserCreditsMessage()},t.prototype.onUserCreditsMessageUpdates=function(){return this.creditMessage=i.userCreditsMessage,this.render()},t}(n)},589815:(e,t,o)=>{var n,i,s,r,a,l,c,u,d=o(619755),h=[].indexOf||function(e){for(var t=0,o=this.length;t<o;t++)if(t in this&&this[t]===e)return t;return-1};i=o(584088),n=o(774351),r=o(28045).me,a=o(261174),s=a.createAetherOptions,l=a.replaceSimpleLoops,c=o(284358).translateJS,u=o(299498),e.exports=function(){function e(e){var t;this.spellKey=e.spellKey,this.pathComponents=e.pathComponents,this.session=e.session,this.otherSession=e.otherSession,this.spectateView=e.spectateView,this.observing=e.observing,this.supermodel=e.supermodel,this.skipProtectAPI=e.skipProtectAPI,this.worker=e.worker,this.level=e.level,this.createFromProgrammableMethod(e.programmableMethod,e.language),this.canRead()&&(this.view=new i({spell:this,level:e.level,session:this.session,otherSession:this.otherSession,worker:this.worker,god:e.god,supermodel:this.supermodel,levelID:e.levelID,classroomAceConfig:e.classroomAceConfig,spectateView:this.spectateView,courseID:e.courseID,blocks:e.blocks,codeFormat:e.codeFormat}),this.view.render(),this.topBarView=new n({hintsState:e.hintsState,spell:this,supermodel:this.supermodel,codeLanguage:this.language,level:e.level,session:e.session,courseID:e.courseID,courseInstanceID:e.courseInstanceID,blocks:e.blocks,blocksHidden:e.blocksHidden,c
1odeFormat:e.codeFormat,teacherID:e.teacherID,showLevelHelp:null!=(t=e.classroomAceConfig)?t.levelChat:void 0}),this.topBarView.render()),Backbone.Mediator.publish("tome:spell-created",{spell:this})}return e.prototype.loaded=!1,e.prototype.view=null,e.prototype.topBarView=null,e.prototype.createFromProgrammableMethod=function(e,t){var o,n,i,s,r,a,c,u,d;if(n=e,this.commentI18N=n.i18n,this.commentContext=n.context,n.sourceVariants?this.languages=_.clone(_.sample(n.sourceVariants)):this.languages=null!=(i=n.languages)?i:{},null==(o=this.languages).javascript&&(o.javascript=n.source),this.name=n.name,this.permissions={read:null!=(s=null!=(r=n.permissions)?r.read:void 0)?s:[],readwrite:null!=(a=null!=(c=n.permissions)?c.readwrite:void 0)?a:["humans"]},this.team=null!=(u=this.permissions.readwrite[0])?u:"common",this.canWrite()?this.setLanguage(t):this.otherSession&&this.team===this.otherSession.get("team")?this.setLanguage(this.otherSession.get("submittedCodeLanguage")||this.otherSession.get("codeLanguage")):this.setLanguage("javascript"),this.source=this.originalSource,this.parameters=n.parameters,(this.otherSession&&this.team===this.otherSession.get("team")&&(d=this.otherSession.getSourceFor(this.spellKey))||this.permissions.readwrite.length&&(d=this.session.getSourceFor(this.spellKey))&&"// Should fill in some default source\n"!==d)&&(this.source=l(d,this.language)),n.aiSource&&!this.otherSession&&!this.canWrite())return this.source=this.originalSource=n.aiSource,this.isAISource=!0},e.prototype.destroy=function(){var e,t;return null!=(e=this.view)&&e.destroy(),null!=(t=this.topBarView)&&t.destroy(),this.thang=null,this.worker=null},e.prototype.setLanguage=function(e){var t,o,n,i;if(this.language=e,this.level.isType("web-dev")&&(this.language="html"),this.displayCodeLanguage=u.capitalLanguages[this.language],"python"===this.language&&"# Should fill in some default source\n"===this.languages[this.language]&&(this.languages[this.language]=null),"cpp"!==(o=this.language)&&"java"!==o&&"lua"!==o&&"coffeescript"!==o&&"python"!==o||this.languages[this.language]||(this.languages[this.language]=c(this.languages.javascript,this.language)),this.originalSource=null!=(n=this.languages[this.language])?n:this.languages.javascript,this.level.isType("web-dev")&&(t=u.extractPlayerCodeTag(this.originalSource),this.wrapperCode=this.originalSource.replace(/<playercode>[\s\S]*<\/playercode>/,"☃"),this.originalSource=t),this.commentContext)return d.extend(!0,{},this.commentContext),i=r.get("preferredLanguage"),this.originalSource=this.translateCommentContext({source:this.originalSource,commentContext:this.commentContext,commentI18N:this.commentI18N,spokenLanguage:i,codeLanguage:this.language}),this.wrapperCode=this.translateCommentContext({source:this.wrapperCode,commentContext:this.commentContext,commentI18N:this.commentI18N,spokenLanguage:i,codeLanguage:this.language}),/loop/.test(this.originalSource)&&this.level.isType("course","course-ladder","hero","hero-ladder")?this.originalSource=l(this.originalSource,this.language):void 0},e.prototype.translateCommentContext=function(e){var t,o,n,i,s,r,a,l;if(r=e.source,o=e.commentContext,n=e.commentI18N,t=e.codeLanguage,e.spokenLanguage,o=d.extend(!0,{},o),n&&(o=u.i18nCommentContext({context:o,i18n:n})),"lua"===t)for(s in o)l=o[s],o[s]=l.replace(/\b([a-zA-Z]+)\.([a-zA-Z_]+\()/,"$1:$2");try{a=_.template(r,o)}catch(e){i=e,console.error("Couldn't create example code template of",r,"\nwith commentContext",o,"\nError:",i),a=r}return a},e.prototype.untranslateCommentContext=function(e){var t,o,n,i,s,r,a,l,c,u;if(a=e.source,o=e.commentContext,n=e.commentI18N,t=e.codeLanguage,l=e.spokenLanguage,o=d.extend(!0,{},o),n)for(;l;){if(null!=i&&(l=l.substr(0,l.lastIndexOf("-"))),c=null!=(r=n[l])?r.context:void 0){o=_.merge(o,c);break}i=!0}if("lua"===t)for(s in o)u=o[s],o[s]=u.replace(/\b([a-zA-Z]+)\.([a-zA-Z_]+\()/,"$1:$2");for(s in o)u=o[s],a=a.replace(u,"<%= "+s+" %>");return a},e.prototype.getSolution=function(e){var t,o,n,i,s,r,a,l,c,u;return o=_.find(null!=(i=this.level.get("thangs"))?i:[],{id:"Hero Placeholder"}),t=_.find(null!=(s=o.components)?s:[],(function(e){var t,o;return null!=e&&null!=(t=e.config)&&null!=(o=t.programmableMethods)?o.plan:void 0})),n=null!=(r=t.config)&&null!=(a=r.programmableMethods)?a.plan:void 0,u=_.filter(null!=(l=null!=n?n.solutions:void 0)?l:[],(function(e){return!e.testOnly&&e.succeeds})),null!=(c=_.find(u,{language:e}))?c.source:void 0},e.prototype.constructHTML=function(e){return this.wrapperCode.replace("☃",e)},e.prototype.addThang=function(e){var t;return(null!=(t=this.thang)?t.thang.id:void 0)===e.id?this.thang.thang=e:this.thang={thang:e,aether:this.createAether(e),castAether:null}},e.prototype.removeThangID=function(e){var t;if((null!=(t=this.thang)?t.thang.id:void 0)===e)return this.thang=null},e.prototype.canRead=function(e){var t,o;return t=null!=e?e:r.team,h.call(this.permissions.read,t)>=0||(o=null!=e?e:r.team,h.call(this.permissions.readwrite,o)>=0)},e.prototype.canWrite=function(e){var t;return t=null!=e?e:r.team,h.call(this.permissions.readwrite,t)>=0},e.prototype.getSource=function(){var e,t;return null!=(e=null!=(t=this.view)?t.getSource():void 0)?e:this.source},e.prototype.transpile=function(e){var t,o;return e?this.source=e:e=this.getSource(),e=u.guardJuniorLevelHealthCode(this.level,e),"html"!==this.language&&(null!=(t=this.thang)&&t.aether.transpile(e),this.session.lastAST=null!=(o=this.thang)?o.aether.ast:void 0),null},e.prototype.hasChanged=function(e,t){return null==e&&(e=null),null==t&&(t=null),(null!=e?e:this.originalSource)!==(null!=t?t:this.source)},e.prototype.hasChangedSignificantly=function(e,t,o){var n,i,s,r;return null==e&&(e=null),null==t&&(t=null),(n=null!=(i=this.thang)?i.aether:void 0)||(console.error(this.toString(),"couldn't find a spellThang with aether",this.thang),o(!1)),this.worker?(s={function:"hasChangedSignificantly",a:null!=e?e:this.originalSource,spellKey:this.spellKey,b:null!=t?t:this.source,careAboutLineNumbers:!0,careAboutLint:!0},this.worker.addEventListener("message",(r=this,function(e){var t;if("hasChangedSignificantly"===(t=JSON.parse(e.data)).function&&t.spellKey===r.spellKey)return r.worker.removeEventListener("message",arguments.callee,!1),o(t.hasChanged)})),this.worker.postMessage(JSON.stringify(s))):o(n.hasChangedSignificantly(null!=e?e:this.originalSource,null!=t?t:this.source,!0,!0))},e.prototype.createAether=function(e){var t,o,n,i,r,a,l;return l=this.permissions.readwrite.length>0&&!this.isAISource,r=this.skipProtectAPI||!l||this.level.isType("game-dev"),i=this.createProblemContext(e),n=this.level.isType("hero","hero-ladder","hero-coop","course","course-ladder","game-dev","ladder")&&!r,o=s({functionName:this.name,codeLanguage:this.language,functionParameters:this.parameters,skipProtectAPI:r,includeFlow:n,problemContext:i,useInterpreter:!0}),"codecombat-junior"===this.level.get("product")&&(o.executionLimit=1e5),t=new Aether(o),this.worker&&(a={function:"createAether",spellKey:this.spellKey,options:o},this.worker.postMessage(JSON.stringify(a))),t},e.prototype.updateLanguageAether=function(e){var t,o,n;return this.language=e,null!=(t=this.thang)&&null!=(o=t.aether)&&o.setLanguage(this.language),this.thang&&(this.thang.castAether=null),Backbone.Mediator.publish("tome:spell-changed-language",{spell:this,language:this.language}),this.worker&&(n={function:"updateLanguageAether",newLanguage:this.language},this.worker.postMessage(JSON.stringify(n))),this.transpile()},e.prototype.toString=function(){return"<Spell: "+this.spellKey+">"},e.prototype.createProblemContext=function(e){var t,o,n,i,s,r,a,l,c;if(null!=this.problemContext)return this.problemContext;if(this.problemContext={stringReferences:[],thisMethods:[],thisProperties:[]},this.problemContext.commonThisMethods=["moveRight","moveLeft","moveUp","moveDown","attack","findNearestEnemy","buildXY","moveXY","say","move","distance","findEnemies","findFriends","addFlag","findFlag","removeFlag","findFlags","attackRange","cast","buildTypes","jump","jumpTo","attackXY"],null==e)return this.problemContext;
1for(o in r=null!=(s=e.world)?s.thangMap:void 0)((c=r[o]).isAttackable||c.isSelectable)&&(a=c.id,h.call(this.problemContext.stringReferences,a)<0)&&this.problemContext.stringReferences.push(c.id);if(null!=e.programmableProperties)for(t=0,n=(l=e.programmableProperties).length;t<n;t++)i=l[t],_.isFunction(e[i])?this.problemContext.thisMethods.push(i):this.problemContext.thisProperties.push(i);return this.problemContext.thisValueAlias=this.level.isType("game-dev")?"game":"hero",this.problemContext},e.prototype.createChatMessageContext=function(e){var t,n,i,s,a,l,u,d,h,p,g,v,m;for(a={code:{}},e.example&&(a.codeComments={context:this.commentContext||{},i18n:this.commentI18N||{}}),l=0,h=(g=["start","solution","current"]).length;l<h;l++)for(s=g[l],a.code[s]={},u=0,p=(i=e.example&&"javascript"===this.language?["javascript","python","coffeescript","lua","java","cpp"]:[this.language]).length;u<p;u++)n=i[u],v=function(){switch(s){case"start":return this.languages[n];case"solution":return this.getSolution(n);case"current":return n===this.language?this.source:""}}.call(this),(d=function(){switch(s){case"start":return this.languages.javascript;case"solution":return this.getSolution("javascript");case"current":return"javascript"===this.language?this.source:""}}.call(this))&&!v&&(v=c(d,n)),v&&("current"===s&&/^\u56E7[a-zA-Z0-9+\/=]+\f$/.test(v)&&(t=o(545803).Unibabel,m=JSON.parse(t.base64ToUtf8(v.substr(1,v.length-2))),v=m.src),e.example&&"current"===s&&(v=this.untranslateCommentContext({source:v,commentContext:this.commentContext,commentI18N:this.commentI18N,spokenLanguage:r.get("preferredLanguage"),codeLanguage:n})),e.example||(v=this.translateCommentContext({source:v,commentContext:this.commentContext,commentI18N:this.commentI18N,spokenLanguage:r.get("preferredLanguage"),codeLanguage:n})),a.code[s][n]=v);return a},e.prototype.reloadCode=function(){var e,t,o,n;if(e=null!=(t=this.thang)&&null!=(o=t.thang)&&null!=(n=o.programmableMethods)?n[this.name]:void 0)return this.createFromProgrammableMethod(e,this.language)},e}()},525017:(e,t,o)=>{var n,i,s,r,a,l,c=o(619755),u=function(e,t){return function(){return e.apply(t,arguments)}},d={}.hasOwnProperty;n=o(968029),l=o(307208),r=o(385899),i=r.require("ace/range").Range,s=r.require("ace/token_iterator").TokenIterator,a={Thang:o(721321),Vector:o(317158),Rectangle:o(728461),Ellipse:o(177838),LineSegment:o(250718)},e.exports=function(e){function t(e){var o,n;for(o in this.notifyPropertyHovered=u(this.notifyPropertyHovered,this),this.updateTooltipProgress=u(this.updateTooltipProgress,this),this.onMouseMove=u(this.onMouseMove,this),this.setTooltipProgress=u(this.setTooltipProgress,this),this.setTooltipText=u(this.setTooltipText,this),this.setTooltipKeyAndValue=u(this.setTooltipKeyAndValue,this),this.calculateCurrentTimeString=u(this.calculateCurrentTimeString,this),t.__super__.constructor.call(this,e),this.ace=e.ace,this.thang=e.thang,this.spell=e.spell,this.progress=0,this.variableStates={},this.globals={Math,_,String,Number,Array,Object},a)n=a[o],this.globals[o]=n;this.onMouseMove=_.throttle(this.onMouseMove,25),this.cache={},this.lastFrameRequested=-1,this.workerIsSimulating=!1,this.spellHasChanged=!1,this.currentFrame=0,this.frameRate=10,this.debouncedTooltipUpdate=_.debounce(this.updateTooltipProgress,100)}return function(e,t){for(var o in t)d.call(t,o)&&(e[o]=t[o]);function n(){this.constructor=e}n.prototype=t.prototype,e.prototype=new n,e.__super__=t.prototype}(t,e),t.prototype.className="spell-debug-view",t.prototype.template=l,t.prototype.subscriptions={"god:new-world-created":"onNewWorld","god:debug-value-return":"handleDebugValue","god:debug-world-load-progress-changed":"handleWorldLoadProgressChanged","tome:cast-spells":"onTomeCast","surface:frame-changed":"onFrameChanged","tome:spell-has-changed-significantly-calculation":"onSpellChangedCalculation"},t.prototype.events={},t.prototype.pad2=function(e){return null==e||0===e?"00":(e<10?"0":"")+e},t.prototype.calculateCurrentTimeString=function(){var e,t,o;return t=((o=this.currentFrame/this.frameRate)-60*(e=Math.floor(o/60))).toFixed(1),e+":"+this.pad2(t)},t.prototype.setTooltipKeyAndValue=function(e,t){var o;return this.hideProgressBarAndShowText(),o="Time: "+this.calculateCurrentTimeString()+"\n"+e+": "+t,this.$el.find("code").text(o),this.$el.show().css(this.pos)},t.prototype.setTooltipText=function(e){return this.hideProgressBarAndShowText(),this.$el.find("code").text(e),this.$el.show().css(this.pos)},t.prototype.setTooltipProgress=function(e){return this.showProgressBarAndHideText(),this.$el.find(".progress-bar").css("width",e+"%").attr("aria-valuenow",e),this.$el.show().css(this.pos)},t.prototype.showProgressBarAndHideText=function(){return this.$el.find("pre").css("display","none"),this.$el.find(".progress").css("display","block")},t.prototype.hideProgressBarAndShowText=function(){return this.$el.find("pre").css("display","block"),this.$el.find(".progress").css("display","none")},t.prototype.onTomeCast=function(){return this.invalidateCache()},t.prototype.invalidateCache=function(){return this.cache={}},t.prototype.retrieveValueFromCache=function(e,t,o,n){var i,s,r,a,l;return i=o.join(),null!=(l=null!=(s=this.cache[n])&&null!=(r=s[e])&&null!=(a=r[t])?a[i]:void 0)?l:void 0},t.prototype.updateCache=function(e,t,o,n,i){var s,r,a,l,c,u;for(s=this.cache,l=r=0,u=(c=[n,e,t,o.join()]).length-1;0<=u?r<u:r>u;l=0<=u?++r:--r)(a=c[l])in s||(s[a]={}),s=s[a];return s[c[c.length-1]]=i},t.prototype.handleDebugValue=function(e){var t,o;if(t=e.key,o=e.value,this.workerIsSimulating=!1,this.updateCache(this.thang.id,this.spell.name,t.split("."),this.lastFrameRequested,o),!this.variableChain||!t!==this.variableChain.join("."))return this.setTooltipKeyAndValue(t,o)},t.prototype.handleWorldLoadProgressChanged=function(e){return this.progress=e.progress}
1,t.prototype.afterRender=function(){return t.__super__.afterRender.call(this),this.ace.on("mousemove",this.onMouseMove)},t.prototype.setVariableStates=function(e){return this.variableStates=e,this.update()},t.prototype.isIdentifier=function(e){return e&&("identifier"===e.type||"this"===e.value||this.globals[e.value])},t.prototype.onMouseMove=function(e){var t,o,n,r,a,l,u,d,h,p,g,v,m,f,y,b;if(!this.destroyed){for(u=e.getDocumentPosition(),n=(null!=(h=(r=new s(e.editor.session,u.row,u.column)).getCurrentToken())?h.index:void 0)===r.$rowTokens.length-1;r.getCurrentTokenRow()===u.row&&!this.isIdentifier(y=r.getCurrentToken())&&!n&&y;)r.stepBackward();if(this.isIdentifier(y))for(f=r.getCurrentTokenColumn(),t=(p=[[y.value],f,f+y.value.length])[0],f=p[1],o=p[2];r.getCurrentTokenRow()===u.row&&(r.stepBackward(),"."===(null!=(g=r.getCurrentToken())?g.value:void 0))&&(r.stepBackward(),y=null,this.isIdentifier(d=r.getCurrentToken()));)y=d,f=r.getCurrentTokenColumn(),t.unshift(y.value);return y?(this.variableChain=t,a=null!=(v=e.domEvent.offsetX)?v:e.clientX-c(e.domEvent.target).offset().left,l=null!=(m=e.domEvent.offsetY)?m:e.clientY-c(e.domEvent.target).offset().top,b=c(document).width(),e.clientX+300>b&&(a=b-c(e.domEvent.target).offset().left-300),this.pos={left:a+50,top:l+20},this.markerRange=new i(u.row,f,u.row,o)):this.variableChain=this.markerRange=null,this.update()}},t.prototype.onMouseOut=function(e){return this.variableChain=this.markerRange=null,this.update()},t.prototype.updateTooltipProgress=function(){if(this.variableChain&&this.progress<1)return this.setTooltipProgress(100*this.progress),_.delay(this.updateTooltipProgress,100)},t.prototype.onNewWorld=function(e){return this.thang&&(this.thang=this.options.thang=e.world.thangMap[this.thang.id]),this.frameRate=e.world.frameRate},t.prototype.onFrameChanged=function(e){return this.currentFrame=Math.round(e.frame),this.frameRate=e.world.frameRate},t.prototype.onSpellChangedCalculation=function(e){return this.spellHasChanged=e.hasChangedSignificantly},t.prototype.update=function(){var e,t;return this.variableChain?this.spellHasChanged?this.setTooltipText("You've changed this spell! \nPlease recast to use the hover debugger."):2===this.variableChain.length&&"this"===this.variableChain[0]?this.setTooltipKeyAndValue(this.variableChain.join("."),this.stringifyValue(this.thang[this.variableChain[1]],0)):1===this.variableChain.length&&Aether.globals[this.variableChain[0]]?this.setTooltipKeyAndValue(this.variableChain.join("."),this.stringifyValue(Aether.globals[this.variableChain[0]],0)):this.workerIsSimulating&&this.progress<1?this.debouncedTooltipUpdate():this.currentFrame===this.lastFrameRequested&&(e=this.retrieveValueFromCache(this.thang.id,this.spell.name,this.variableChain,this.currentFrame))?this.setTooltipKeyAndValue(this.variableChain.join("."),e):(Backbone.Mediator.publish("tome:spell-debug-value-request",{thangID:this.thang.id,spellID:this.spell.name,variableChain:this.variableChain,frame:this.currentFrame}),this.currentFrame!==this.lastFrameRequested&&(this.workerIsSimulating=!0),this.lastFrameRequested=this.currentFrame,this.progress=0,this.debouncedTooltipUpdate()):this.$el.hide(),2===(null!=(t=this.variableChain)?t.length:void 0)?(this.hoveredPropertyTimeout&&clearTimeout(this.hoveredPropertyTimeout),this.hoveredPropertyTimeout=_.delay(this.notifyPropertyHovered,500)):this.notifyPropertyHovered(),this.updateMarker()},t.prototype.stringifyValue=function(e,t){var o,n,i,s,r,a,l,c,u,d,h,p,g,v,m,f,y;if(!e||_.isString(e))return e;if(_.isFunction(e))return 2===t?void 0:"<Function>";if(e===this.thang&&t)return"<this "+e.id+">";if(2===t)return"Thang"===(null!=(d=e.constructor)?d.className:void 0)?"<"+(e.type||e.spriteName)+" - "+e.id+", "+(e.pos?e.pos.toString():"non-physical")+">":e.toString();if(n=_.isArray(e),i=_.isObject(e),!n&&!i)return e.toString();if(o=n?["[","]"]:["{","}"],!_.size(e))return o.join("");if(y=[],n)for(s=0,l=e.length;s<l;s++)f=e[s],void 0!==(v=this.stringifyValue(f,t+1))&&y.push(""+v);else for(r=0,c=(p=null!=(h=e.apiProperties)?h:_.keys(e)).length;r<c;r++)a=p[r],void 0!==(v=this.stringifyValue(e[a],t+1))&&y.push(a+": "+v);return m="\n"+function(){var e,o,n;for(n=[],e=0,o=t;0<=o?e<o:e>o;0<=o?++e:--e)n.push("  ");return n}().join(""),u=null!=(g=e.constructor)?g.className:void 0,n&&null==u&&(u="Array"),i&&null==u&&(u="Object"),(u=u?u+" ":"")+o[0]+m+"  "+y.join(m+"  ")+m+o[1]},t.prototype.notifyPropertyHovered=function(){var e,t;if(this.hoveredPropertyTimeout&&clearTimeout(this.hoveredPropertyTimeout),this.hoveredPropertyTimeout=null,e=this.hoveredProperty,this.hoveredProperty=2===(null!=(t=this.variableChain)?t.length:void 0)?{owner:this.variableChain[0],property:this.variableChain[1]}:{},!_.isEqual(e,this.hoveredProperty))return Backbone.Mediator.publish("tome:spell-debug-property-hovered",this.hoveredProperty)},t.prototype.updateMarker=function(){if(this.marker&&(this.ace.getSession().removeMarker(this.marker),this.marker=null),this.markerRange)return this.marker=this.ace.getSession().addMarker(this.markerRange,"ace_bracket","text")},t.prototype.destroy=function(){var e;return null!=(e=this.ace)&&e.removeEventListener("mousemove",this.onMouseMove),t.__super__.destroy.call(this)},t}(n)},931848:(e,t,o)=>{var n,i,s,r,a=o(619755),l=function(e,t){return function(){return e.apply(t,arguments)}},c={}.hasOwnProperty;n=o(968029),r=o(962122),o(28045).me,o(531643),i=o(878001),o(385899),o(299498),s=o(367906),e.exports=function(e){function t(e){this.onClick=l(this.onClick,this),this.onPaletteClicked=l(this.onPaletteClicked,this),t.__super__.constructor.call(this,e),this.thang=e.thang,this.thangType=e.thangType,this.docFormatter=new i(e),this.doc=this.docFormatter.doc,this.doc.initialHTML=this.docFormatter.formatPopover(),this.doc.docFormatter=this.docFormatter,this.aceEditors=[]}return function(e,t){for(var o in t)c.call(t,o)&&(e[o]=t[o]);function n(){this.constructor=e}n.prototype=t.prototype,e.prototype=new n,e.__super__=t.prototype}(t,e),t.prototype.tagName="div",t.prototype.className="spell-palette-entry-v
1iew",t.prototype.template=r,t.prototype.popoverPinned=!1,t.prototype.overridePopoverTemplate='<div class="popover spell-palette-popover" role="tooltip"><div class="arrow"></div><h3 class="popover-title"></h3><div class="popover-content"></div></div>',t.prototype.subscriptions={"surface:frame-changed":"onFrameChanged","tome:palette-hovered":"onPaletteHovered","tome:palette-clicked":"onPaletteClicked","tome:palette-pin-toggled":"onPalettePinToggled","tome:spell-debug-property-hovered":"onSpellDebugPropertyHovered"},t.prototype.events={mouseenter:"onMouseEnter",mouseleave:"onMouseLeave",click:"onClick"},t.prototype.afterRender=function(){var e,o;return t.__super__.afterRender.call(this),this.$el.addClass(_.string.slugify(this.doc.type)),e=function(){return a("body").hasClass("dialogue-view-active")?"top":"left"},this.$el.popover({animation:!1,html:!0,placement:e,trigger:"manual",content:this.docFormatter.formatPopover(),container:"body",template:this.overridePopoverTemplate}).on("inserted.bs.popover",(function(){return a(".spell-palette-popover").attr("translate","no")})).on("shown.bs.popover",(o=this,function(){var e;return Backbone.Mediator.publish("tome:palette-hovered",{thang:o.thang,prop:o.doc.name,entry:o}),e=Math.floor(4*Math.random()),o.playSound("spell-palette-entry-open-"+e,.75),o.afterRenderPopover()}))},t.prototype.afterRenderPopover=function(){var e,t,o,n,i,r,l,c,u,d;for(null!=(r=this.$el.data("bs.popover"))&&null!=(l=r.$tip)&&l.i18n(),o=this.options.language,n=0,i=(c=this.aceEditors).length;n<i;n++)c[n].destroy();return this.aceEditors=[],e=this.aceEditors,null!=r&&null!=(u=r.$tip)&&u.find(".docs-ace").each((function(){var t;return t=s.initializeACE(this,o),e.push(t)})),d=a("#tome-view").offset().top>100?a(window).innerWidth():a("#tome-view").offset().left,t=a("#tome-view").offset().top>100?a("#tome-view").offset().top:a("#spell-palette-view").offset().top,a(".spell-palette-popover.popover").css({left:d-30-a(".spell-palette-popover.popover").width(),top:t-30-a(".spell-palette-popover.popover").height()})},t.prototype.resetPopoverContent=function(){return this.$el.data("bs.popover").options.content=this.docFormatter.formatPopover(),this.$el.popover("setContent")},t.prototype.onMouseEnter=function(e){if(!this.popoverPinned&&!this.otherPopoverPinned)return this.resetPopoverContent(),this.$el.popover("show")},t.prototype.onMouseLeave=function(e){if(!this.popoverPinned&&!this.otherPopoverPinned)return this.$el.popover("hide")},t.prototype.togglePinned=function(){var e;return this.popoverPinned?(this.popoverPinned=!1,this.$el.add(".spell-palette-popover.popover").removeClass("pinned"),a(".spell-palette-popover.popover .close").remove(),this.$el.popover("hide"),this.playSound("spell-palette-entry-unpin")):(this.popoverPinned=!0,this.resetPopoverContent(),this.$el.add(".spell-palette-popover.popover").addClass("pinned"),this.$el.popover("show"),e=a('<button type="button" data-dismiss="modal" aria-hidden="true" class="close">×</button>'),a(".spell-palette-popover.popover").append(e),e.on("click",this.onClick),this.playSound("spell-palette-entry-pin")),Backbone.Mediator.publish("tome:palette-pin-toggled",{entry:this,pinned:this.popoverPinned})},t.prototype.onPaletteClicked=function(e){return this.$el.toggleClass("selected",e.prop===this.doc.name)},t.prototype.onClick=function(e){if(!key.shift)return this.togglePinned(),Backbone.Mediator.publish("tome:palette-clicked",{thang:this.thang,prop:this.doc.name,entry:this});Backbone.Mediator.publish("tome:insert-snippet",{doc:this.options.doc,language:this.options.language,formatted:this.doc})},t.prototype.onFrameChanged=function(e){var t,o;if((null!=(t=e.selectedThang)?t.id:void 0)===(null!=(o=this.thang)?o.id:void 0))return this.options.thang=this.thang=this.docFormatter.options.thang=e.selectedThang},t.prototype.onPaletteHovered=function(e){if(e.entry!==this)return this.popoverPinned?this.togglePinned():void 0},t.prototype.onPalettePinToggled=function(e){if(e.entry!==this)return this.otherPopoverPinned=e.pinned},t.prototype.onSpellDebugPropertyHovered=function(e){var t;return(t=e.property===this.doc.name&&e.owner===this.doc.owner)&&!this.debugHovered?(this.debugHovered=!0,this.popoverPinned||this.togglePinned()):this.debugHovered&&!t&&(this.debugHovered=!1,this.popoverPinned&&this.togglePinned()),null},t.prototype.destroy=function(){var e,o,n;for(this.popoverPinned&&a(".popover.pinned").remove(),this.popoverPinned&&this.togglePinned(),this.$el.popover("destroy"),this.$el.off(),e=0,o=(n=this.aceEditors).length;e<o;e++)n[e].destroy();return t.__super__.destroy.call(this)},t}(n)},831036:(e,t,o)=>{var n,i,s,r,a,l,c=o(619755),u=function(e,t){return function(){return e.apply(t,arguments)}},d={}.hasOwnProperty,h=[].indexOf||function(e){for(var t=0,o=this.length;t<o;t++)if(t in this&&this[t]===e)return t;return-1};o(686713),n=o(968029),l=o(28045).me,o(531643),s=o(931848),i=o(828193),r=o(34088),o(385899),a=o(367906),e.exports=function(e){function t(){return this.hide=u(this.hide,this),this.onResize=u(this.onResize,this),t.__super__.constructor.apply(this,arguments)}return function(e,t){for(var o in t)d.call(t,o)&&(e[o]=t[o]);function n(){this.constructor=e}n.prototype=t.prototype,e.prototype=new n,e.__super__=t.prototype}(t,e),t.prototype.id="spell-palette-view",t.prototype.template=o(851927),t.prototype.controlsEnabled=!0,t.prototype.position="bot",t.prototype.subscriptions={"level:disable-control
1s":"onDisableControls","level:enable-controls":"onEnableControls","surface:frame-changed":"onFrameChanged","tome:change-language":"onTomeChangedLanguage","tome:palette-clicked":"onPaletteClick","surface:stage-mouse-down":"hide","level:gather-chat-message-context":"onGatherChatMessageContext"},t.prototype.events={"click .closeBtn":"onClickClose"},t.prototype.initialize=function(e){return this.level=e.level,this.session=e.session,this.thang=e.thang,this.aceEditors=[],this.options.level.get("documentation"),this.createPalette(),c(window).on("resize",this.onResize)},t.prototype.getRenderData=function(){var e;return(e=t.__super__.getRenderData.call(this)).entryGroups=this.entryGroups,e.tabbed=_.size(this.entryGroups)>1,e.tabs=this.tabs,e.thisName={coffeescript:"@",lua:"self",python:"self",java:"hero",cpp:"hero"}[this.options.language]||"this",e._=_,e},t.prototype.afterRender=function(){var e,o,n,i,s,r,a,l,u,d,h,p,g,v,m,f;for(i in t.__super__.afterRender.call(this),this.entryGroupElements={},p=this.entryGroups)for(e=p[i],this.entryGroupElements[i]=s=c('<div class="property-entry-item-group"></div>').appendTo(this.$el.find(".properties-this")),(null!=(g=e[0].options.item)?g.getPortraitURL:void 0)&&((r=c('<img class="item-image" draggable=false></img>').attr("src",e[0].options.item.getPortraitURL())).css("top",Math.max(0,19*(e.length-2)/2)+2),s.append(r),function(e){r.on("mouseenter",(function(t){return e.onMouseEnter(t)})),r.on("mouseleave",(function(t){return e.onMouseLeave(t)}))}(e[0])),n=l=0,d=e.length;l<d;n=++l)o=e[n],s.append(o.el),o.render(),1===e.length&&o.$el.addClass("single-entry"),0===n&&o.$el.addClass("first-entry");for(m in v=this.tabs||{})for(e=v[m],f=_.string.slugify(m),a=0,n=u=0,h=e.length;u<h;n=++u)o=e[n],(0===a||2===a&&n!==e.length-1)&&(s=c('<div class="property-entry-item-group"></div>').appendTo(this.$el.find(".properties-"+f)),a=0),++a,s.append(o.el),o.render(),0===a&&o.$el.addClass("first-entry");return this.$el.toggleClass("shortenize",Boolean(this.shortenize)),this.$el.toggleClass("web-dev",this.options.level.isType("web-dev"))},t.prototype.afterInsert=function(){return t.__super__.afterInsert.call(this),_.delay((e=this,function(){var t;if(!c("#spell-view").is(".shown"))return null!=(t=e.$el)?t.css("bottom",0):void 0}));var e},t.prototype.updateCodeLanguage=function(e){return this.options.language=e},t.prototype.calculateNColumns=function(){var e,t,o;return e=this.$el.find(".properties-this").innerWidth()||c("#code-area").innerWidth()-40,t=function(){switch(!1){case!this.options.level.isType("web-dev"):return 100;case!this.shortenize:return 175;default:return 212}}.call(this),o=Math.floor(e/t),this.hideImages=o<2||this.options.level.isType("game-dev","ladder")||this.entries.length>32,this.hideImages&&(t-=38,o=Math.floor(e/t)),Math.max(2,o)},t.prototype.updateMaxHeight=function(){var e,t,o,n,i,s,r,a,l,c,u,d,p,g,v,m,f,y;for(e=function(e){var t,o,n,i;for(t=0,o=0,i=e.length;o<i;o++)t+=1===(n=e[o])?40:19*n+2;return t},g=this.calculateNColumns(),t=function(){var e,t,o;for(o=[],e=0,t=g;0<=t?e<t:e>t;0<=t?++e:--e)o.push({items:[],nEntries:0,entryLens:[]});return o}(),v=[],o=0,i=_.sortBy(_.keys(this.entryGroups),(y=this,function(e){return y.entryGroups[e].length})),i.reverse(),r=0,c=i.length;r<c;r++)s=i[r],n=this.entryGroups[s],(f=_.sortBy(t,(function(e){return e.nEntries}))[0])&&(p=this.hideImages?1:2,f.nEntries+=Math.max(p,n.length),f.items.push(this.entryGroupElements[s]),f.entryLens.push(n.length),h.call(v,f)<0&&v.push(f),o=Math.max(o,e(f.entryLens)));for(a=0,u=v.length;a<u;a++)for(l=0,d=(m=v[a].items).length;l<d;l++)m[l].detach().appendTo(this.$el.find(".properties-this"));return this.$el.find(".properties").css("height",o).toggleClass("hide-images",this.hideImages)},t.prototype.onResize=function(e){return"function"==typeof this.updateMaxHeight?this.updateMaxHeight():void 0},t.prototype.createPalette=function(){var e,t,o,n,s,r,a,l,c,u,d,p,g;for(Backbone.Mediator.publish("tome:palette-cleared",{thangID:this.thang.id}),e={},o={},n=0,a=(r=this.supermodel.getModels(i)).length;n<a;n++)for(s=0,l=(p=null!=(d=r[n].get("propertyDocumentation"))?d:[]).length;s<l;s++)!(t=p[s]).codeLanguages||(g=this.options.language,h.call(t.codeLanguages,g)>=0)?(null==e[c="__"+(t=_.cloneDeep(t)).name]&&(e[c]=[]),e["__"+t.name].push(t),"snippet"===t.type&&(t.owner="snippets")):o["__"+t.name]=t;return u=this.options.programmable?{this:"programmableProperties",more:"moreProgrammableProperties",Vector:"programmableVectorProperties",HTML:"programmableHTMLProperties",WebJavaScript:"programmableWebJavaScriptProperties",jQuery:"programmableJQueryProperties",CSS:"programmableCSSProperties",snippets:"programmableSnippets"}:{this:["apiProperties","apiMethods"]}
1,this.organizePalette(u,e,o)},t.prototype.organizePalette=function(e,t,o){var n,i,s,a,c,u,d,p,g,v,m,f,y,b,w,k,S,C,x,T,P,L,M,I,D,B,A,E,R,O,V,$,N,j,F,H,G,U,z,W,q,K,Q,X,J,Z,Y,ee,te,oe,ne,ie,se,re,ae,le,ce,ue,de,he,pe;for(m={},b=0,S=(z=this.supermodel.getModels(r)).length;b<S;b++)m[(he=z[b]).get("name")]=he;for(G={},j=0,f={},re=_.sortBy(_.keys(null!=(W=this.thang.inventoryThangTypeNames)?W:{}),(function(e){return"left-hand"===e?0:"right-hand"===e?1:2})),w=0,C=re.length;w<C;w++)if(se=re[w],g=m[de=this.thang.inventoryThangTypeNames[se]]){for(g.get("components")||console.error("Item",g,"did not have any components when we went to assemble docs."),k=0,x=(Z=null!=(J=g.get("components"))?J:[]).length;k<x;k++)if((n=Z[k]).config)for(O in e)if(ce=e[O],H=n.config[ce])for(D=0,T=(Y=_.sortBy(H)).length;D<T;D++)"_"===(N=Y[D])[0]||f[N]||"moveXY"===N&&"slalom"===this.options.level.get("slug")||this.thang.excludedProperties&&h.call(this.thang.excludedProperties,N)>=0||("beta"!==this.options.level.get("releasePhase")||"moveUp"!==N&&"moveRight"!==N&&"moveDown"!==N&&"moveLeft"!==N)&&("beta"===this.options.level.get("releasePhase")||"moveTo"!==N&&"use"!==N)&&(null==G[E=g.get("name")]&&(G[E]=[]),G[g.get("name")].push({owner:O,prop:N,item:g}),f[N]=g,++j)}else console.log(this.thang.id,"couldn't find item ThangType for",se,de);for(O in e)if(le=e[O],"this"!==O&&"more"!==O&&"snippets"!==O&&"HTML"!==O&&"CSS"!==O&&"WebJavaScript"!==O&&"jQuery"!==O&&(null!=(ee=this.thang[le])?ee.length:void 0))for(null==this.tabs&&(this.tabs={}),this.tabs[O]=[],$=m[this.thang.inventoryThangTypeNames["programming-book"]],B=0,P=(ae=this.thang[le].slice().sort()).length;B<P;B++)N=ae[B],this.thang.excludedProperties&&h.call(this.thang.excludedProperties,N)>=0||(i=_.find(null!=(te=t["__"+N])?te:[],{owner:O}))&&(null==G[O]&&(G[O]=[]),G[O].push({owner:O,prop:N,item:$}));for(O in e)if(le=e[O],"this"===O||"more"===O||"snippets"===O||"HTML"===O||"CSS"===O||"WebJavaScript"===O||"jQuery"===O)for(ne=_.reject(null!=(oe=this.thang[le])?oe:[],(function(e){return f[e]||"_"===e[0]})),R=0,L=ne.length;R<L;R++)"say"===(N=ne[R])&&this.options.level.get("hidesSay")||"moveXY"===N&&"slalom"===this.options.level.get("slug")||this.thang.excludedProperties&&h.call(this.thang.excludedProperties,N)>=0||("beta"!==this.options.level.get("releasePhase")||"moveUp"!==N&&"moveRight"!==N&&"moveDown"!==N&&"moveLeft"!==N)&&("beta"===this.options.level.get("releasePhase")||"moveTo"!==N&&"use"!==N)&&(pe=["warcry","throw","throwAt","throwPos","throwRange","shieldBubble","slam","reflect","forcePush","charismagnetize","stomp","hurl","absoluteShield","heartShield"],l.isStudent()&&l.showHeroAndInventoryModalsToStudents()&&h.call(pe,N)>=0||(null==G.Hero&&(G.Hero=[]),G.Hero.push({owner:O,prop:N,item:m[this.thang.spriteName]}),++j));for(v in Backbone.Mediator.publish("tome:update-snippets",{propGroups:G,allDocs:t,language:this.options.language}),this.shortenize=j>6,this.entries=[],G)for(F=V=0,M=(H=G[v]).length;V<M;F=++V)g=(N=H[F]).item,O=N.owner,N=N.prop,(i=_.find(null!=(ie=t["__"+N])?ie:[],(function(e){return e.owner===O||!("this"!==O&&"more"!==O||null!=e.owner&&"this"!==e.owner&&"ui"!==e.owner)})))||o["__"+N]||(console.log("could not find doc for",N,"from",t["__"+N],"for",O,"of",G,"with item",g),null==i&&(i=N)),i&&("spawnable"===(q=i.type)||"event"===q||"handler"===q||"property"===q||"snippet"===i.type&&"game-dev"===this.level.get("type")?(ue="spawnable"===i.type?this.getThangTypeForDoc(i):null,this.entries.push(this.addEntry(i,this.shortenize,"snippets"===O,i.type,F>0,ue))):this.entries.push(this.addEntry(i,this.shortenize,"snippets"===O,g,F>0)));for(this.options.level.isType("web-dev","game-dev")?this.entryGroups=_.groupBy(this.entries,(function(e){return e.doc.type})):this.entryGroups=_.groupBy(this.entries,(function(e){var t,o;return null!=(t=null!=(o=f[e.doc.name])&&"function"==typeof o.get?o.get("name"):void 0)?t:"Hero"})),A=this.calculateNColumns(),y=Math.max(4,Math.ceil(j/A)),U=0,I=(K=_.keys(this.entryGroups)).length;U<I;U++)for(p=K[U],d=1;this.entryGroups[p].length>y;)u=this.entryGroups[p].splice(y,y),this.entryGroups[p+" "+ ++d]=u;for(p in c={},Q=this.entryGroups)s=Q[p],c[p]={item:{name:p,imageURL:null!=(X=m[p])?X.getPortraitURL():void 0},props:function(){var e,t,o;for(o=[],t=0,e=s.length;t<e;t++)a=s[t],o.push(a.doc);return o}()};return Backbone.Mediator.publish("tome:palette-updated",{thangID:this.thang.id,entryGroups:c})},t.prototype.addEntry=function(e,t,o,n,i,r){var a,l,c;return null==o&&(o=!1),null==n&&(n=null),null==i&&(i=!1),null==r&&(r=null),a=_.isString(e)?e:e.name,c=h.call(null!=(l=this.thang.apiUserProperties)?l:[],a)>=0,new s({doc:e,thang:this.thang,thangType:r,shortenize:t,isSnippet:o,language:this.options.language,writable:c,level:this.options.level,item:n,showImage:i,spellPalettePosition:this.position})},t.prototype.getThangTypeForDoc=function(e){var t,o;return o=e.name,this.thang.spawnAliases[o]&&(o=this.thang.spawnAliases[o][0]),t=this.thang.buildables[o],_.find(this.supermodel.getModels(r),(function(e){return e.get("original")===(null!=t?t.thangType:void 0)}))},t.prototype.onDisableControls=function(e){return this.toggleControls(e,!1)},t.prototype.onEnableControls=function(e){return this.toggleControls(e,!0)}
1,t.prototype.toggleControls=function(e,t){if((!e.controls||h.call(e.controls,"palette")>=0)&&t!==this.controlsEnabled)return this.controlsEnabled=t,this.$el.find("*").attr("disabled",!t),this.$el.toggleClass("controls-disabled",!t)},t.prototype.onFrameChanged=function(e){var t;if((null!=(t=e.selectedThang)?t.id:void 0)===this.thang.id)return this.options.thang=this.thang=e.selectedThang},t.prototype.onTomeChangedLanguage=function(e){var t,o,n;for(this.updateCodeLanguage(e.language),t=0,o=(n=this.entries).length;t<o;t++)n[t].destroy();return this.createPalette(),this.render()},t.prototype.onClickClose=function(e){return this.hide()},t.prototype.hide=function(){return this.$el.find(".left .selected").removeClass("selected"),this.$el.removeClass("open")},t.prototype.onPaletteClick=function(e){var t,o,n,i,s,r;for(this.$el.addClass("open"),(n=this.$el.find(".rightContentTarget")).html(e.entry.doc.initialHTML),n.i18n(),this.applyRTLIfNeeded(),o=e.entry.options.language,i=0,s=(r=this.aceEditors).length;i<s;i++)r[i].destroy();return this.aceEditors=[],t=this.aceEditors,n.find(".docs-ace").each((function(){var e;return e=a.initializeACE(this,o),t.push(e)}))},t.prototype.onGatherChatMessageContext=function(e){var t,o,n,i,s,r,a,l,c,u,d;for(s in(t=e.chat.context).apiProperties=[],l=this.entryGroups)for(r=0,a=(n=l[s]).length;r<a;r++)i=n[r],"this"!==(c=(o=e.chat.example?_.omit(i.options.doc,"shortDescription","autoCompletePriority","snippets","userShouldCaptureReturn"):_.omit(i.doc,"ownerName","shortName","shorterName","title","initialHTML","shortDescription","autoCompletePriority","snippets","i18n","userShouldCaptureReturn")).owner)&&"more"!==c||(o.owner="hero"),o.example||delete o.example,o.returns&&!o.returns.example&&null!=(u=o.returns)&&delete u.example,o.returns&&!o.returns.description&&null!=(d=o.returns)&&delete d.description,t.apiProperties.push(o);return null},t.prototype.destroy=function(){var e,o,n,i;for(e=0,o=(n=this.entries).length;e<o;e++)n[e].destroy();
1return this.toggleBackground=null,c(window).off("resize",this.onResize),null!=(i=this.setupManager)&&i.destroy(),t.__super__.destroy.call(this)},t}(n)},573271:(e,t,o)=>{var n,i,s={}.hasOwnProperty;n=o(968029),i=o(807592),e.exports=function(e){function t(e){t.__super__.constructor.call(this,e),this.ace=e.ace}return function(e,t){for(var o in t)s.call(t,o)&&(e[o]=t[o]);function n(){this.constructor=e}n.prototype=t.prototype,e.prototype=new n,e.__super__=t.prototype}(t,e),t.prototype.className="spell-toolbar-view",t.prototype.template=i,t.prototype.progressHoverDelay=500,t.prototype.subscriptions={"tome:spell-step-backward":"onStepBackward","tome:spell-step-forward":"onStepForward"},t.prototype.events={"mousedown .spell-progress":"onProgressMouseDown","mouseup .spell-progress":"onProgressMouseUp","mousemove .spell-progress":"onProgressMouseMove","tapstart .spell-progress":"onProgressTapStart","tapend .spell-progress":"onProgressTapEnd","tapmove .spell-progress":"onProgressTapMove","click .step-backward":"onStepBackward","click .step-forward":"onStepForward"},t.prototype.afterRender=function(){return t.__super__.afterRender.call(this)},t.prototype.toggleFlow=function(e){return this.$el.find(".flow").toggle(e)},t.prototype.setStatementIndex=function(e){var t,o,n,i,s;if(i=null!=(t=this.callState)?t.statementsExecuted:void 0)return this.statementIndex=Math.min(i-1,Math.max(0,e)),this.statementRatio=this.statementIndex/(i-1),this.statementTime=null!=(o=null!=(n=this.callState.statements[this.statementIndex])?n.userInfo.time:void 0)?o:0,this.$el.find(".progress-bar").css("width",100*this.statementRatio+"%"),this.$el.find(".step-backward").prop("disabled",0===this.statementIndex),this.$el.find(".step-forward").prop("disabled",this.statementIndex===i-1),this.updateMetrics(),_.defer((s=this,function(){return Backbone.Mediator.publish("tome:spell-statement-index-updated",{statementIndex:s.statementIndex,ace:s.ace})}))},t.prototype.updateMetrics=function(){var e,t,o,n;return o=this.callState.statementsExecuted,e=this.$el.find(".metrics"),this.suppressMetricsUpdates||!o&&!this.metrics.statementsExecuted?e.hide():(this.metrics.callsExecuted>1?(e.find(".call-index").text(this.callIndex+1),e.find(".calls-executed").text(this.metrics.callsExecuted),e.find(".calls-metric").show().attr("title","Method call "+(this.callIndex+1)+" of "+this.metrics.callsExecuted+" calls")):e.find(".calls-metric").hide(),this.metrics.statementsExecuted?(e.find(".statement-index").text(this.statementIndex+1),e.find(".statements-executed").text(o),this.metrics.statementsExecuted>o?(e.find(".statements-executed-total").text(" ("+this.metrics.statementsExecuted+")"),n=" ("+this.metrics.statementsExecuted+" statements total)"):(e.find(".statements-executed-total").text(""),n=""),e.find(".statements-metric").show().attr("title","Statement "+(this.statementIndex+1)+" of "+o+" this call"+n)):e.find(".statements-metric").hide(),t=this.$el.find(".scrubber-handle").position().left+this.$el.find(".spell-progress").position().left,e.finish().show().css({left:t-e.width()/2}).delay(2e3).fadeOut("fast"))},t.prototype.setStatementRatio=function(e){var t,o,n;if(n=null!=(t=this.callState)?t.statementsExecuted:void 0)return(o=Math.floor(e*n))!==this.statementIndex?this.setStatementIndex(o):void 0},t.prototype.onProgressMouseDown=function(e){return this.dragging=!0,this.scrubProgress(e),Backbone.Mediator.publish("level:set-playing",{playing:!1})},t.prototype.onProgressMouseUp=function(e){return this.dragging=!1},t.prototype.onProgressMouseMove=function(e){if(this.dragging)return this.scrubProgress(e)},t.prototype.onProgressTapStart=function(e,t){return this.dragging=!0,this.scrubProgress(e,t)},t.prototype.onProgressTapEnd=function(e,t){return this.dragging=!1},t.prototype.onProgressTapMove=function(e,t){if(this.dragging)return this.scrubProgress(e,t)},t.prototype.scrubProgress=function(e,t){var o,n,i;return o=(null!=(n=null!=(i=e.clientX)?i:null!=t?t.position.x:void 0)?n:0)-this.$el.find(".spell-progress").offset().left,o=Math.max(o,0),this.setStatementRatio(o/this.$el.find(".spell-progress").width()),this.updateTime(),this.updateScroll()},t.prototype.onStepBackward=function(e){return this.step(-1)},t.prototype.onStepForward=function(e){return this.step(1)},t.prototype.step=function(e){var t;return t=this.statementTime,this.setStatementIndex(this.statementIndex+e),this.statementTime!==t&&this.updateTime(),this.updateScroll(),Backbone.Mediator.publish("level:set-playing",{playing:!1})},t.prototype.updateTime=function(){var e;return this.maintainIndexScrub=!0,this.maintainIndexScrubTimeout&&clearTimeout(this.maintainIndexScrubTimeout),this.maintainIndexScrubTimeout=_.delay((e=this,function(){return e.maintainIndexScrub=!1}),500),Backbone.Mediator.publish("level:set-time",{time:this.statementTime,scrubDuration:500})},t.prototype.updateScroll=function(){var e,t,o,n,i;if(i=null!=(t=this.callState)&&null!=(o=t.statements)&&null!=(n=o[this.statementIndex])?n.range[0]:void 0)return this.ace.getValue(),e=i.row,this.ace.scrollToLine(e,!0,!0)},t.prototype.setCallState=function(e,t,o,n){var i;if(this.callIndex=o,this.metrics=n,(e!==this.callState||t!==this.statementIndex)&&(this.callState=e))return this.suppressMetricsUpdates=!0,this.maintainIndexScrub||this.dragging||null==t||(null!=(i=e.statements[t])?i.userInfo.time:void 0)===this.statementTime?this.setStatementRatio(this.statementRatio):this.setStatementIndex(t),this.suppressMetricsUpdates=!1},t}(n)},774351:(e,t,o)=>{var n,i,s,r,a,l,c,u,d,h=o(619755),p=o(665420),g=function(e,t){return function(){return e.apply(t,arguments)}},v={}.hasOwnProperty,m=[].indexOf||function(e){for(var t=0,o=this.length;t<o;t++)if(t in this&&this[t]===e)return t;return-1};o(274229),u=o(560737),a=o(233251),i=o(968029),r=o(813929),d=o(299498),s=o(258819),n=o(180908).Z,c=o(196363),l=o(504015),e.exports=function(e){function t(e){this.onSwitchTeam=g
1(this.onSwitchTeam,this),this.otherTeam=g(this.otherTeam,this),this.hintsState=e.hintsState,this.spell=e.spell,this.courseInstanceID=e.courseInstanceID,this.courseID=e.courseID,this.blocks=e.blocks,this.blocksHidden=e.blocksHidden,this.teacherID=e.teacherID,this.teaching=d.getQueryVariable("teaching"),this.showLevelHelp=!0,me.isStudent()&&(this.showLevelHelp=e.showLevelHelp&&"none"!==e.showLevelHelp),this.wsBus=l.application.wsBus,t.__super__.constructor.call(this,e)}return function(e,t){for(var o in t)v.call(t,o)&&(e[o]=t[o]);function n(){this.constructor=e}n.prototype=t.prototype,e.prototype=new n,e.__super__=t.prototype}(t,e),t.prototype.template=u,t.prototype.id="spell-top-bar-view",t.prototype.controlsEnabled=!0,t.prototype.subscriptions={"level:disable-controls":"onDisableControls","level:enable-controls":"onEnableControls","tome:spell-loaded":"onSpellLoaded","tome:spell-changed":"onSpellChanged","tome:spell-changed-language":"onSpellChangedLanguage","tome:game-menu-opened":"onGameMenuOpened","websocket:user-online":"onUserOnlineChanged"},t.prototype.events={"click .reload-code":"onCodeReload","click .beautify-code":"onBeautifyClick","click .fullscreen-code":"onToggleMaximize","click .hints-button":"onClickHintsButton","click .image-gallery-button":"onClickImageGalleryButton","click .videos-button":"onClickVideosButton","click #fill-solution":"onFillSolution","click #toggle-solution":"onToggleSolution","click #switch-team":"onSwitchTeam","click .toggle-blocks":"onToggleBlocks","click #ask-teacher-for-help":"onClickHelpButton","click .spell-chatbot-hint":"onClickHintButton"},t.prototype.getRenderData=function(e){var o,n;return null==e&&(e={}),e=t.__super__.getRenderData.call(this,e),o=this.isMac()?"Cmd":"Ctrl",n=h.i18n.t("keyboard_shortcuts.shift"),e.beautifyShortcutVerbose=o+"+"+n+"+B: "+h.i18n.t("keyboard_shortcuts.beautify"),e.maximizeShortcutVerbose=o+"+"+n+"+M: "+h.i18n.t("keyboard_shortcuts.maximize_editor"),e.codeLanguage=this.options.codeLanguage,e.showAmazonLogo="game-dev-hoc"===p.getHocCampaign(),e.askingTeacher=me.isStudent()&&this.teacherOnline()?h.i18n.t("play_level.ask_teacher_for_help"):h.i18n.t("play_level.ask_teacher_for_help_offline"),e},t.prototype.afterRender=function(){return t.__super__.afterRender.call(this),this.$('[data-toggle="popover"]').popover()},t.prototype.showVideosButton=function(){return me.isStudent()&&this.courseID===d.courseIDs.INTRODUCTION_TO_COMPUTER_SCIENCE},t.prototype.teacherOnline=function(){var e,t,o,n,i,s,r;return console.log("what online?",null!=(e=this.wsBus)&&null!=(t=e.wsInfos)&&null!=(o=t.friends)?o[this.teacherID]:void 0,this.teacherID),null!=(n=this.wsBus)&&null!=(i=n.wsInfos)&&null!=(s=i.friends)&&null!=(r=s[this.teacherID])?r.online:void 0},t.prototype.onDisableControls=function(e){return this.toggleControls(e,!1)},t.prototype.onEnableControls=function(e){return this.toggleControls(e,!0)},t.prototype.onClickImageGalleryButton=function(e){return this.openModalView(new r)},t.prototype.onGameMenuOpened=function(){var e;if(!(e=this.hintsState.get("hidden")))return this.hintsState.set("hidden",!e)},t.prototype.onClickHintsButton=function(){var e,t,o;if(null!=this.hintsState)return Backbone.Mediator.publish("level:hints-button",{state:this.hintsState.get("hidden")}),this.hintsState.set("hidden",!this.hintsState.get("hidden")),null!=(e=window.tracker)?e.trackEvent("Hints Clicked",{category:"Students",levelSlug:this.options.level.get("slug"),hintCount:null!=(t=null!=(o=this.hintsState.get("hints"))?o.length:void 0)?t:0}):void 0},t.prototype.onClickVideosButton=function(){return this.openModalView(new s({courseInstanceID:this.courseInstanceID,courseID:this.courseID}))},t.prototype.onFillSolution=function(){if(me.canAutoFillCode())return c.dispatch("game/autoFillSolution",this.options.codeLanguage)},t.prototype.onToggleSolution=function(){return console.log("click toggle solution"),Backbone.Mediator.publish("level:toggle-solution",{})},t.prototype.onCodeReload=function(e){return key.shift?Backbone.Mediator.publish("level:restart",{}):this.openModalView(new a)},t.prototype.onBeautifyClick=function(e){if(this.controlsEnabled)return Backbone.Mediator.publish("tome:spell-beautify",{spell:this.spell})},t.prototype.updateReloadButton=function(){var e;return e=this.spell.hasChanged(null,this.spell.getSource()),this.$el.find(".reload-code").css("display",e?"inline-block":"none")},t.prototype.onSpellLoaded=function(e){if(e.spell===this.spell)return this.updateReloadButton()},t.prototype.onSpellChanged=function(e){if(e.spell===this.spell)return this.updateReloadButton()},t.prototype.onSpellChangedLanguage=function(e){if(e.spell===this.spell)return this.options.codeLanguage=e.language,this.render(),this.updateReloadButton()},t.prototype.onUserOnlineChanged=function(e){var t;if(console.log("user online changed",e),e.user.toString()===(null!=(t=this.teacherID)?t.toString():void 0))return this.renderSelectors("#ask-teacher-for-help")},t.prototype.toggleControls=function(e,t){if((!e.controls||m.call(e.controls,"editor")>=0)&&t!==this.controlsEnabled)return this.controlsEnabled=t,this.$el.toggleClass("read-only",!t)},t.prototype.otherTeam=function(){return _.without(["humans","ogres"],this.options.spell.team)[0]},t.prototype.onSwitchTeam=function(){var e,t,o,n;return o=window.location.protocol+"//",e=window.location.host,t=window.location.pathname,(n=(n=window.location.search).replace(/team=[^&]*&?/,""))?n.endsWith("?")||n.endsWith("&")?n+="team=":n+="&team=":n="?team=",window.location.href=o+e+t+n+this.otherTeam()},t.prototype.onToggleBlocks=function(){return this.blocks=!this.blocks,Backbone.Mediator.publish("tome:toggle-blocks",{blocks:this.blocks}
1)},t.prototype.onClickHelpButton=function(){return Backbone.Mediator.publish("websocket:asking-help",{msg:{to:this.teacherID.toString(),type:"msg",info:{text:h.i18n.t("teacher.student_ask_for_help",{name:me.broadName()}),url:window.location.pathname}}})},t.prototype.destroy=function(){return t.__super__.destroy.call(this)},t.prototype.onClickHintButton=function(){var e;return this.openModalView(new n({propsData:{aiChatKind:(null!=(e=this.options.level)?e.get("aiChatKind"):void 0)||"level-chat"}}))},t}(i)},622034:(e,t,o)=>{var n,i,s,r,a,l,c,u=o(619755),d=function(e,t){return function(){return e.apply(t,arguments)}},h={}.hasOwnProperty;n=o(968029),i=o(828193),l=o(949429),a=o(385899),s=a.require("ace/range").Range,r=a.require("ace/token_iterator").TokenIterator,c=o(299498),e.exports=function(e){function t(e){var o;this.onPopupFocusChange=d(this.onPopupFocusChange,this),this.onMouseMove=d(this.onMouseMove,this),this.setTooltipText=d(this.setTooltipText,this),t.__super__.constructor.call(this,e),this.ace=e.ace,o=this.supermodel.getModels(i),this.componentTranslations=o.reduce((function(e,t){var o,n,i,s,r,a;for(n=0,i=(r=null!=(s=t.get("propertyDocumentation"))?s:[]).length;n<i;n++)o=r[n],(a=c.i18n(o,"name",null,!1))!==o.name&&(e[o.name]=a);return e}),{}),this.onMouseMove=_.throttle(this.onMouseMove,25)}return function(e,t){for(var o in t)h.call(t,o)&&(e[o]=t[o]);function n(){this.constructor=e}n.prototype=t.prototype,e.prototype=new n,e.__super__=t.prototype}(t,e),t.prototype.className="spell-translation-view",t.prototype.template=l,t.prototype.events={mousemove:function(){return this.$el.hide()}},t.prototype.subscriptions={"tome:completer-popup-focus-change":"onPopupFocusChange"},t.prototype.afterRender=function(){if(t.__super__.afterRender.call(this),null!=this.ace)return this.ace.on("mousemove",this.onMouseMove)},t.prototype.setTooltipText=function(e){return this.$el.find("code").text(e),this.$el.show().css(this.pos)},t.prototype.isIdentifier=function(e){return e&&(_.any([/identifier/,/keyword/],(function(t){return t.test(e.type)}))||"this"===e.value)},t.prototype.onMouseMove=function(e){var t,o,n,i,a,l,c;if(!this.destroyed){for(i=e.getDocumentPosition(),o=(null!=(a=(n=new r(e.editor.session,i.row,i.column)).getCurrentToken())?a.index:void 0)===n.$rowTokens.length-1;n.getCurrentTokenRow()===i.row&&!this.isIdentifier(c=n.getCurrentToken())&&!o&&c;)n.stepBackward();if(!this.isIdentifier(c))return this.word=null,void this.update();try{l=n.getCurrentTokenColumn()}catch(e){l=0}return t=l+c.value.length,this.isIdentifier(c)&&(this.word=c.value,this.markerRange=new s(i.row,l,i.row,t),this.reposition(e.domEvent)),this.update()}},t.prototype.onPopupFocusChange=function(e){if(this.word=e.word,this.markerRang=e.markerRang,!this.destroyed)return this.update()},t.prototype.reposition=function(e){var t,o,n,i,s;return t=null!=(n=e.offsetX)?n:e.clientX-u(e.target).offset().left,o=null!=(i=e.offsetY)?i:e.clientY-u(e.target).offset().top,s=u(document).width()-20,e.clientX+this.$el.width()>s&&(t=s-u(e.target).offset().left-this.$el.width()),this.pos={left:t+80,top:o-20},this.$el.css(this.pos)},t.prototype.onMouseOut=function(){return this.word=null,this.markerRange=null,this.update()},t.prototype.update=function(){var e,t;return e="code."+this.word,t=this.componentTranslations[this.word]||u.t(e),this.word&&t&&t!==e&&t!==this.word?this.setTooltipText(t):this.$el.hide()},t.prototype.destroy=function(){var e;return null!=(e=this.ace)&&e.removeEventListener("mousemove",this.onMouseMove),t.__super__.destroy.call(this)},t}(n)},584088:(e,t,o)=>{var n,i,s,r,a,l,c,u,d,h,p,g,v,m,f,y,b,w,k,S,C,x,T,P,L,M,I,D,B,A=o(619755),E=o(665420),R=function(e,t){return function(){return e.apply(t,arguments)}},O={}.hasOwnProperty,V=[].indexOf||function(e){for(var t=0,o=this.length;t<o;t++)if(t in this&&this[t]===e)return t;return-1},$=[].slice;o(719759),l=o(968029),D=o(40160),P=o(28045).me,x=o(531643),y=o(385899),h=y.require("ace/range").Range,m=y.require("ace/undomanager").UndoManager,d=o(823899),p=o(525017),v=o(622034),g=o(573271),o(828193),f=o(530815),b=o(367906),k=o(105736),M=o(727524),S=M.codeToBlocks,L=M.prepareBlockIntelligence,c=o(300872),r=o(188927),y.require("ace/token_iterator").TokenIterator,u=o(826961),B=o(299498),i=o(431228),w=o(261174),a=o(834948),k.registerBlocklyTheme(),o(969278),n=o(452133),T=o(504015),C=o(86856),I=o(196363),o(247366),s=o(847
1504),e.exports=function(e){function t(e){var o;this.checkSuspectCode=R(this.checkSuspectCode,this),this.checkRequiredCode=R(this.checkRequiredCode,this),this.onWindowResize=R(this.onWindowResize,this),this.toggleBackground=R(this.toggleBackground,this),this.onGutterClick=R(this.onGutterClick,this),this.highlightCurrentLine=R(this.highlightCurrentLine,this),this.onAceMouseMove=R(this.onAceMouseMove,this),this.updateAether=R(this.updateAether,this),this.fetchTokenForSource=R(this.fetchTokenForSource,this),this.fetchToken=R(this.fetchToken,this),this.updateHTML=R(this.updateHTML,this),this.onCursorActivity=R(this.onCursorActivity,this),this.saveSpade=R(this.saveSpade,this),this.updateLines=R(this.updateLines,this),this.updateAceLines=R(this.updateAceLines,this),this.updateSolutionLines=R(this.updateSolutionLines,this),this.notifyEditingBegan=R(this.notifyEditingBegan,this),this.notifyEditingEnded=R(this.notifyEditingEnded,this),this.notifySpellChanged=R(this.notifySpellChanged,this),this.onAllLoaded=R(this.onAllLoaded,this),this.aceToBlockly=R(this.aceToBlockly,this),this.onBlocklyEvent=R(this.onBlocklyEvent,this),this.supermodel=e.supermodel,t.__super__.constructor.call(this,e),this.worker=e.worker,this.session=e.session,this.spell=e.spell,this.courseID=e.courseID,this.problems=[],this.savedProblems={},o=P.team,V.call(this.spell.permissions.readwrite,o)<0&&(this.writable=!1),this.highlightCurrentLine=_.throttle(this.highlightCurrentLine,100),A(window).on("resize",this.onWindowResize),this.observing=this.session.get("creator")!==P.id,this.spectateView=e.spectateView,this.loadedToken={},this.addUserSnippets=_.debounce(this.reallyAddUserSnippets,500,{maxWait:1500,leading:!0,trailing:!1}),this.teaching=B.getQueryVariable("teaching",!1),this.urlSession=B.getQueryVariable("session"),this.blocklySuccess=!0}return function(e,t){for(var o in t)O.call(t,o)&&(e[o]=t[o]);function n(){this.constructor=e}n.prototype=t.prototype,e.prototype=new n,e.__super__=t.prototype}(t,e),t.prototype.id="spell-view",t.prototype.className="shown",t.prototype.template=D,t.prototype.controlsEnabled=!0,t.prototype.eventsSuppressed=!0,t.prototype.writable=!0,t.prototype.languagesThatUseWorkers=["html"],t.prototype.keyBindings={default:null,vim:"ace/keyboard/vim",emacs:"ace/keyboard/emacs"},t.prototype.subscriptions={"level:disable-controls":"onDisableControls","level:enable-controls":"onEnableControls","surface:frame-changed":"onFrameChanged","surface:coordinate-selected":"onCoordinateSelected","god:new-world-created":"onNewWorld","god:user-code-problem":"onUserCodeProblem","god:non-user-code-problem":"onNonUserCodeProblem","tome:manual-cast":"onManualCast","tome:spell-changed":"onSpellChanged","tome:spell-created":"onSpellCreated","tome:completer-add-user-snippets":"onAddUserSnippets","level:session-will-save":"onSessionWillSave","modal:closed":"focus","tome:focus-editor":"focus","tome:spell-statement-index-updated":"onStatementIndexUpdated","tome:change-language":"onChangeLanguage","tome:change-config":"onChangeEditorConfig","tome:update-snippets":"addAutocompleteSnippets","tome:insert-snippet":"onInsertSnippet","tome:spell-beautify":"onSpellBeautify","tome:toggle-blocks":"onToggleBlocks","tome:problems-updated":"onProblemsUpdated","script:state-changed":"onScriptStateChange","playback:ended-changed":"onPlaybackEndedChanged","level:contact-button-pressed":"onContactButtonPressed","level:sh
1ow-victory":"onShowVictory","web-dev:error":"onWebDevError","tome:palette-updated":"onPaletteUpdated","level:gather-chat-message-context":"onGatherChatMessageContext","tome:fix-code":"onFixCode","level:update-solution":"onUpdateSolution","level:toggle-solution":"onToggleSolution","level:close-solution":"closeSolution","level:streaming-solution":"onStreamingSolution","level:apply-solution":"onApplySolution","websocket:asking-help":"onAskingHelp","playback:cinematic-playback-started":"onCinematicPlaybackStarted","playback:cinematic-playback-ended":"onCinematicPlaybackEnded","blockly:clicked-block":"onClickedBlock"},t.prototype.events={mouseout:"onMouseOut"},t.prototype.afterRender=function(){var e;if(t.__super__.afterRender.call(this),this.createACE(),this.createACEShortcuts(),this.hookACECustomBehavior(),!this.spectateView)try{this.fillACESolution()}catch(t){e=t,console.error("Could not fill ace solution:",e)}return this.fillACE(),this.createOnCodeChangeHandlers(),this.lockDefaultCode(),_.defer(this.onAllLoaded)},t.prototype.createACE=function(){var e,t,o,n,i,s,r,a,l,c,u;if(e=null!=(n=P.get("aceConfig"))?n:{},this.destroyAceEditor(this.ace),this.ace=y.edit(this.$el.find(".ace")[0]),this.aceSession=this.ace.getSession(),this.reallySetAnnotations=this.aceSession.setAnnotations.bind(this.aceSession),this.aceSession.setAnnotations=(u=this,function(e){var t,o;return o=u.aceSession.getAnnotations(),t=_.filter(o,(function(e){return null!=e.createdBy})).concat(_.reject(e,(function(e){return"Start tag seen without seeing a doctype first. Expected e.g. <!DOCTYPE html>."===e.text}))),u.reallySetAnnotations(t)}),this.aceDoc=this.aceSession.getDocument(),this.aceSession.setUseWorker((i=this.spell.language,V.call(this.languagesThatUseWorkers,i)>=0)),this.aceSession.setMode(b.aceEditModes[this.spell.language]),this.aceSession.setWrapLimitRange(null),this.aceSession.setUseWrapMode(!0),this.aceSession.setNewLineMode("unix"),this.aceSession.setUseSoftTabs(!0),this.ace.setTheme("ace/theme/textmate"),this.ace.setDisplayIndentGuides(!1),this.ace.setShowPrintMargin(!1),this.ace.setShowInvisibles(!1),this.ace.setBehavioursEnabled(e.behaviors),this.ace.setAnimatedScroll(!0),this.ace.setShowFoldWidgets(!1),this.ace.setKeyboardHandler(this.keyBindings[null!=(s=e.keyBindings)?s:"default"]),this.ace.$blockScrolling=Infinity,this.ace.on("mousemove",this.onAceMouseMove),this.ace.on("mouseout",this.onAceMouseOut),this.toggleControls(null,this.writable),this.aceSession.selection.on("changeCursor",this.onCursorActivity),A(this.ace.container).find(".ace_gutter").on("click mouseenter",".ace_error, .ace_warning, .ace_info",this.onAnnotationClick),A(this.ace.container).find(".ace_gutter").on("click",this.onGutterClick),o=null==(r=e.liveCompletion)||r,o=(null!=(a=this.options.classroomAceConfig)?a:{liveCompletion:!0}).liveCompletion&&o,this.initAutocomplete(o),t=(null!=(l=this.options.classroomAceConfig)?l:{disablePaste:!1}).disablePaste,b.toggleACEPasteFeature(this.ace,t),this.teaching&&(console.log("connect provider:",this.urlSession),this.yjsProvider=b.setupCRDT(""+this.urlSession,P.broadName(),"",this.ace),this.yjsProvider.connections=1,this.yjsProvider.awareness.on("change",function(e){return function(){return console.log("provider get connections? ",e.yjsProvider.awareness.getStates().size),e.yjsProvider.connections=e.yjsProvider.awareness.getStates().size}}(this))),this.session.get("creator")===P.id&&!this.session.fake)return this.spade=new Spade,this.spade.track(this.ace),this.spade.createUIEvent("spade-created"),c=6e5,"beta"===this.options.level.get("releasePhase")&&(c=18e4),this.saveSpadeTimeout=setTimeout(this.saveSpade,c)},t.prototype.createACEShortcuts=function(){var e,t,o;if(this.aceCommands=e=[],o=this,(t=function(t){return o.ace.commands.addCommand(t),e.push(t.name)})({name:"run-code",bindKey:{win:"Shift-Enter|Ctrl-Enter",mac:"Shift-Enter|Command-Enter|Ctrl-Enter"},exec:function(e){return function(){return Backbone.Mediator.publish("tome:manual-cast",{realTime:e.options.level.isType("game-dev")})}}(this)}),this.observing||t({name:"run-code-real-time",bindKey:{win:"Ctrl-Shift-Enter",mac:"Command-Shift-Enter|Ctrl-Shift-Enter"},exec:function(e){return function(){var t,o;return(t=e.$(".done-button:visible")).length?t.trigger("click"):e.options.level.get("replayable")&&(o=e.session.timeUntilResubmit())>0?Backbone.Mediator.publish("tome:manual-cast-denied",{timeUntilResubmit:o}):Backbone.Mediator.publish("tome:manual-cast",{realTime:!0})}}(this)}),t({name:"no-op",bindKey:{win:"Ctrl-S",mac:"Command-S|Ctrl-S"},exec:function(){}}
1),t({name:"previous-line",bindKey:{mac:"Ctrl-P"},passEvent:!0,exec:function(e){return function(){return e.ace.execCommand("golineup")}}(this)}),t({name:"toggle-playing",bindKey:{win:"Ctrl-P",mac:"Command-P"},readOnly:!0,exec:function(){return Backbone.Mediator.publish("level:toggle-playing",{})}}),t({name:"end-current-script",bindKey:{win:"Shift-Space",mac:"Shift-Space"},readOnly:!0,exec:function(e){return function(){return e.scriptRunning?Backbone.Mediator.publish("level:shift-space-pressed",{}):e.ace.insert(" ")}}(this)}),t({name:"end-all-scripts",bindKey:{win:"Escape",mac:"Escape"},readOnly:!0,exec:function(){return Backbone.Mediator.publish("level:escape-pressed",{})}}),t({name:"unfocus-editor",bindKey:{win:"Escape",mac:"Escape"},readOnly:!0,exec:function(){if(B.isOzaria)return A(document.activeElement).hasClass("ace_text-input")?A("#run, #update-code").focus():void 0}}),t({name:"toggle-grid",bindKey:{win:"Ctrl-G",mac:"Command-G|Ctrl-G"},readOnly:!0,exec:function(){return Backbone.Mediator.publish("level:toggle-grid",{})}}),t({name:"toggle-debug",bindKey:{win:"Ctrl-\\",mac:"Command-\\|Ctrl-\\"},readOnly:!0,exec:function(){return Backbone.Mediator.publish("level:toggle-debug",{})}}),t({name:"toggle-pathfinding",bindKey:{win:"Ctrl-O",mac:"Command-O|Ctrl-O"},readOnly:!0,exec:function(){return Backbone.Mediator.publish("level:toggle-pathfinding",{})}}),t({name:"level-scrub-forward",bindKey:{win:"Ctrl-]",mac:"Command-]|Ctrl-]"},readOnly:!0,exec:function(){return Backbone.Mediator.publish("level:scrub-forward",{})}}),t({name:"level-scrub-back",bindKey:{win:"Ctrl-[",mac:"Command-[|Ctrl-]"},readOnly:!0,exec:function(){return Backbone.Mediator.publish("level:scrub-back",{})}}),t({name:"spell-step-forward",bindKey:{win:"Ctrl-Alt-]",mac:"Command-Alt-]|Ctrl-Alt-]"},readOnly:!0,exec:function(){return Backbone.Mediator.publish("tome:spell-step-forward",{})}}),t({name:"spell-step-backward",bindKey:{win:"Ctrl-Alt-[",mac:"Command-Alt-[|Ctrl-Alt-]"},readOnly:!0,exec:function(){return Backbone.Mediator.publish("tome:spell-step-backward",{})}}),t({name:"spell-beautify",bindKey:{win:"Ctrl-Shift-B",mac:"Command-Shift-B|Ctrl-Shift-B"},exec:function(){return Backbone.Mediator.publish("tome:spell-beautify",{})}}),t({name:"prevent-line-jump",bindKey:{win:"Ctrl-L",mac:"Command-L"},passEvent:!0,exec:function(){}}),t({name:"enter-skip-delimiters",bindKey:"Enter|Return",exec:function(e){return function(){var t,o,n;return e.aceSession.selection.isEmpty()&&(t=e.ace.getCursorPosition(),(o=e.aceDoc.getLine(t.row).substring(t.column).match(/^(["|']?\)+;?)/))&&((n=e.ace.getSelectionRange()).setStart(n.start.row,n.start.column+o[1].length),n.setEnd(n.end.row,n.end.column+o[1].length),e.aceSession.selection.setSelectionRange(n))),e.ace.execCommand("insertstring","\n")}}(this)}),t({name:"disable-spaces",bindKey:"Space",exec:function(e){return function(){var t,o,n,i,s;return o=e.options.level.get("disableSpaces")||!1,(t=null!=(i=P.get("aceConfig"))?i:{}).keyBindings&&"default"!==t.keyBindings&&(o=!1),"lua"!==(s=e.spell.language)&&"java"!==s&&"cpp"!==s&&"coffeescript"!==s&&"html"!==s||(o=!1),!o||_.isNumber(o)&&o<P.rank()?e.ace.execCommand("insertstring"," "):(n=e.aceDoc.getLine(e.ace.getCursorPosition().row),e.singleLineCommentRegex().test(n)?e.ace.execCommand("insertstring"," "):void 0)}}(this)}),this.options.level.get("backspaceThrottle"))return t({name:"throttle-backspaces",bindKey:"Backspace",exec:function(e){return function(){var t,o,n;return n=Date.now(),e.aceSession.selection.isEmpty()&&(t=e.ace.getCursorPosition(),o=e.aceDoc.getLine(t.row),/^\s*$/.test(o.substring(0,t.column)))?(null==e.backspaceThrottleMs&&(e.backspaceThrottleMs=500),void((null==e.lastBackspace||n-e.lastBackspace>e.backspaceThrottleMs)&&(e.backspaceThrottleMs=100,e.lastBackspace=n,e.ace.remove("left")))):(e.backspaceThrottleMs=null,e.lastBackspace=n,e.ace.remove("left"))}}(this)})},t.prototype.hookACECustomBehavior=function(){var e,t,o;return P.get("aceConfig"),this.ace.commands.on("exec",(o=this,function(e){var t;if("enter-skip-delimiters"===e.command.name&&((t=o.ace.selection.getRange()).start.column!==t.end.column||t.start.row!==t.end.row))return e.editor.execCommand("gotolineend"),!0})),t=this.spell.language,e=function(e){var o;return"python"===t&&null!=(o=/^\s*([^#]+)/.exec(e))&&/:\s*$/.test(o[1])},this.indentDivMarkers=[],this.aceSession.addDynamicMarker({update:function(o){return function(n,i,s,r){var a,l,c,u,d,p,g,v,m,f,b,w,k,S,_,C,x,T,P,L,M,I,D,B,A,E,R,O,V,$,N,j,F,H,G;if(h=y.require("ace/range").Range,null!=(p=o.aceSession.foldWidgets)){for(x=o.aceDoc.getAllLines(),N=function(e){return x[e].match(/^\s*/).pop().length},l=[{border:"74,144,226",fill:"108,162,226"},{border:"132,180,235",fill:"230,237,245"}
1],o.indentDivMarkers.forEach((function(e){return e.remove()})),o.indentDivMarkers=[],V=w=0,M=o.aceSession.getLength();0<=M?w<=M:w>=M;V=0<=M?++w:--w)if(null==p[V]&&(p[V]=o.aceSession.getFoldWidget(V)),null!=p&&"start"===p[V]){try{u=o.aceSession.getFoldWidgetRange(V)}catch(e){d=e,console.warn("Couldn't find fold widget docRange for row "+V+":",d)}if(null==u&&(v=N(V),u=new h(V,v,V,v+4)),e(x[V])){if(/^\s+$/.test(x[u.end.row+1])&&(u.end.row+=1),G=N(V),"python"===t)for(R=new RegExp("^"+new Array(Math.floor(G/4+1)).join("(    |\t)")+"(    |\t)+(\\S|\\s*$)"),c=k=I=u.start.row+1,D=u.end.row;I<=D?k<=D:k>=D;c=I<=D?++k:--k)if(!R.test(x[c])){u.end.row=c-1;break}$=o.aceSession.documentToScreenPosition(u.start.row,u.start.column),E=o.aceSession.documentToScreenPosition(u.end.row,u.end.column),L=new h($.row,$.column,E.row,E.column),a=l[Math.floor(G/4)%l.length],F=i.$getTop(L.start.row,r),j=i.$getTop(L.start.row+1,r),m=r.lineHeight*(L.end.row-L.start.row),S=i.$padding+G*r.characterWidth,H=4*r.characterWidth,g=r.characterWidth*(o.aceSession.getScreenLastRowColumn(L.start.row)-G),(C=document.createElement("div")).setAttribute("style","position: absolute; top: "+F+"px; left: "+S+"px; width: "+(g+3)+"px; height: "+r.lineHeight+"px;\nborder: 3px solid rgba("+a.border+",1); border-left: none;"),(b=document.createElement("div")).setAttribute("style","position: absolute; top: "+j+"px; left: "+S+"px; width: "+H+"px; height: "+m+"px; background-color: rgba("+a.fill+",0.5);\nborder-right: 3px solid rgba("+a.border+",1); border-bottom: 3px solid rgba("+a.border+",1);"),(f=document.createElement("div")).appendChild(C),f.appendChild(b),o.indentDivMarkers.push(f)}}for(i.elt("indent-highlight"),P=null!=(B=i.element.childNodes[i.i-1])?B:i.element.lastChild,O=[],T=0,_=(A=o.indentDivMarkers).length;T<_;T++)f=A[T],O.push(P.appendChild(f));return O}}}(this)})},t.prototype.fillACE=function(){if(this.ace.setValue(this.spell.source),this.aceSession.setUndoManager(new m),this.ace.clearSelection(),this.options.blocks)return this.addBlockly()},t.prototype.onPaletteUpdated=function(e){if(!this.propertyEntryGroups)return this.propertyEntryGroups=e.entryGroups,this.awaitingBlockly?(this.addBlockly(),this.awaitingBlockly=!1):void 0},t.prototype.addBlockly=function(){var e,t,o,n,i,s,r,l,c,u;if(this.propertyEntryGroups){if(o=this.spell.language,this.blocklyToolbox=k.createBlocklyToolbox({propertyEntryGroups:this.propertyEntryGroups,codeLanguage:o,codeFormat:this.options.codeFormat,level:this.options.level}),this.blocklyToolboxJS="javascript"===o?this.blocklyToolbox:k.createBlocklyToolbox({propertyEntryGroups:this.propertyEntryGroups,codeLanguage:"javascript",codeFormat:this.options.codeFormat,level:this.options.level}),u=this.$(".blockly-container"),r=this.determineMaxBlocks(),t=k.createBlocklyOptions({toolbox:this.blocklyToolbox,codeLanguage:o,codeFormat:this.options.codeFormat,product:this.options.level.get("product")||"codecombat",maxBlocks:r}),this.blockly=a.inject(u[0],t),this.blocklyActive=!0,k.initializeBlocklyTooltips(),this.onCodeChangeMetaHandler&&this.blockly.addChangeListener(this.onBlocklyEvent),n=4===_.filter(null!=(l=this.propertyEntryGroups.Hero)?l.props:void 0,(function(e){return/^go/.test(e.name)})).length,u.toggleClass("static-toolbox-dropdowns",n),this.lastBlocklyState=null,this.lastBlocklyState){if(this.awaitingBlocklySerialization=!0,this.blocklySuccess=k.loadBlocklyState({blocklyState:this.lastBlocklyState,blockly:this.blockly}),!this.blocklySuccess)return Backbone.Mediator.publish("tome:blockly-error",{}),this.resizeBlockly();for(i=0,s=(c=this.blockly.getAllBlocks()).length;i<s;i++)"comment"===(e=c[i]).type&&e.setCollapsed(!0);this.recompile()}else this.awaitingBlocklySerialization=!0,this.aceToBlockly(!0);return this.resizeBlockly()}this.awaitingBlockly=!0},t.prototype.getBlocklySource=function(){return k.getBlocklySource(this.blockly,{codeLanguage:this.spell.language,product:this.options.level.get("product",!0)||"codecombat"})},t.prototype.onClickedBlock=function(e){var t,o,n,i,s,r,a,l,c,u,d,h,p,g,v,m;if(A(e.block).parents(".blocklyFlyout").length&&"blocklyEditableText"!==(null!=(a=e.block.classList)?a[0]:void 0)){for(t=e.block;!(null!=(l=t.dataset)?l.id:void 0)&&t.parentNode;)t=t.parentNode;if((null!=(c=t.dataset)?c.id:void 0)&&!k.createBlockById({workspace:this.blockly,id:t.dataset.id,codeLanguage:this.spell.language})&&((o=null!=(u=e.block.tooltip)&&null!=(d=u.docFormatter)&&null!=(h=d.doc)?h.example:void 0)||(r=e.text.trim().split(/\s/g)[0].trim(),o=null!=(s=_.find(_.values((null!=(p=this.autocomplete)&&null!=(g=p.snippetManager)&&null!=(v=g.snippetMap)?v._:void 0)||{}),(function(e){return e.tabTrigger===r&&e.autocompletePriority>0})))?s.content:void 0),o))return m=this.getSource(),n=(i=_.last(m.split("\n"))).match(/^\s*/)[0],/\S/.test(i)&&(m+="\n"+n),m+=o+"\n"+n,this.updateACEText(m),this.aceToBlockly(),"codecombat-junior"===this.options.level.get("product")&&this.recompile(),null}},t.prototype.onBlocklyEvent=function(e){var t,o,n,i,s,r,l;e.type===a.Events.FINISHED_LOADING&&(this.awaitingBlocklySerialization=!1),s=e.type,V.call(k.blocklyMutationEvents,s)<0||(o=(r=this.blocklyToAce(e)).blocklySource,n=r.blocklySourceRaw,i=this.blockly.getMetricsManager().getViewMetrics(!0),e.type===a.Events.BLOCK_MOVE&&V.call(e.reason||[],"drag")>=0&&e.newCoordinate&&(e.newCoordinate.x<i.left-25||e.newCoordinate.y<i.top-15||e.newCoordinate.y>i.top+i.height-10)?(t=this.blockly.getBlockById(e.blockId)).dispose():o&&(l=e.type,V.call(k.blocklyFinishedMutationEvents,l)>=0)&&o.trim().replace(/\n\s*\n/g,"\n")!==this.spell.source.trim().replace(/\n\s*\n/g,"\n")&&(e.type!==a.Events.BLOCK_MOVE||V.c
1all(e.reason||[],"drag")>=0||V.call(e.reason||[],"connect")>=0)&&((n!==o||o&&1===o.split("\n").length)&&this.aceToBlockly(!0),"codecombat-junior"===this.options.level.get("product")?(this.hideProblemAlert(),(t=k.getBlockById({workspace:this.blockly,id:null!=e?e.blockId:void 0}))&&this.playBlockSound(t),this.recompile()):this.notifySpellChanged()))},t.prototype.blocklyToAce=function(){var e,t,o,n,i;return this.awaitingBlocklySerialization||this.eventsSuppressed?{}:this.blockly?(n=(i=this.getBlocklySource()).blocklyState,t=i.blocklySource,i.combined,o=i.blocklySourceRaw,this.lastBlocklyState=n,t===(e=this.getSource())||t.replace(/(?:[ \t]*\r?\n){2,}/g,"\n")===e.replace(/(?:[ \t]*\r?\n){2,}/g,"\n")||this.updateACEText(t),{blocklySource:t,blocklySourceRaw:o}):{}},t.prototype.aceToBlockly=function(e){var t,o,n,i,s,r,a;if((!this.eventsSuppressed||e)&&this.blockly){if(n=(a=this.getBlocklySource()).blocklyState,a.blocklySource,o=a.blocklySourceRaw,!this.codeToBlocksPrepData)try{this.codeToBlocksPrepData=L({toolbox:this.blocklyToolboxJS,blocklyState:n,workspace:this.blockly})}catch(e){return i=e,void console.error("Error preparing Blockly code to blocks conversion:",i)}if(t=this.ace.getValue(),"codecombat-junior"===this.options.level.get("product")&&(t=(t=(t=t.replace(/(?:[ \t]*\r?\n){2,}/g,"\n")).replace(/^ *'[^']*';? *$/gm,"")).replace(/^ *[ijk] *$/gm,"")),s=t&&1===t.trim().split("\n").length,!t||t!==o||s){try{r=S({code:t,originalCode:this.spell.originalSource,codeLanguage:this.spell.language,toolbox:this.blocklyToolbox,blocklyState:n,prepData:this.codeToBlocksPrepData})}catch(e){return i=e,void console.log("Couldn't parse code to get new blockly state:",i,"\nCode:",t)}if(!k.isEqualBlocklyState(r,this.lastBlocklyState)){if(this.eventsSuppressed=!0,this.awaitingBlocklySerialization=!0,this.blocklySuccess=k.loadBlocklyState({blocklyState:r,blockly:this.blockly}),this.eventsSuppressed=!1,this.blocklySuccess)return this.lastBlocklyState=r;Backbone.Mediator.publish("tome:blockly-error",{})}}}},t.prototype.playBlockSound=function(e){var t,o,n,i,r,a,l,c,u,d,h,p;try{t=null!=(a=k.blockToCode({block:e,codeLanguage:this.spell.language}))?a.trim():void 0}catch(t){n=t,console.log("Cannot play block sound because cannot generate code for",e,n)}if(o=null!=e&&null!=(l=e.docFormatter)&&null!=(c=l.doc)?c.name:void 0,t||o)return i=P.get("preferredLanguage",!0)||"en-US",!o||t&&t.replace(/[^a-zA-Z0-9_-]/g,"")!==o.replace(/[^a-zA-Z0-9_-]/g,"")?u=t:(d=(u=B.i18n(e.docFormatter.doc,"name"))!==o,t||(u=u.replace(/, \d/g,""))),u=u.replace(/, 1/g,""),h=d||"en-GB"===P.get("preferredLanguage")?i:"en-US",r=B.markdownToPlainText(u.replace(/[[\]()'"]+/g," ").trim()),p="/file/text-to-speech/"+h+"/"+encodeURIComponent(r)+".mp3",s.preloadSound(p,p,4),s.playSound(p)},t.prototype.lockDefaultCode=function(e){var t,o,n,i,s,r,a,l,c,u,d,p,g,v,m,f,y,b,w,k,S,C,x,T;if(null==e&&(e=!1),(v=this.options.level.get("lockDefaultCode")||!1)&&!(_.isNumber(v)&&v<P.rank())&&(this.spell.source===this.spell.originalSource||e)&&(!(t=null!=(k=P.get("aceConfig"))?k:{}).keyBindings||"default"===t.keyBindings)){var L;if(console.info("Locking down default code."),L=this,n=function(){var e,t,o,n;for(e=0,t=(n=L.readOnlyRanges).length;e<t;e++)if(o=n[e],L.ace.getSelectionRange().intersects(o))return!0;return!1},i=function(e){return function(){var t,o,n,i,s;for((o=e.ace.getSelectionRange().clone()).start.column>0?o.setStart(o.start.row,o.start.column-1):o.start.row>0&&o.setStart(o.start.row-1,0),t=0,n=(s=e.readOnlyRanges).length;t<n;t++)if(i=s[t],o.intersects(i))return!0;return!1}}(this),s=function(e){return function(){var t,o,n,i,s;for((s=e.ace.getSelectionRange().clone()).end.column<e.aceDoc.getLine(s.end.row).length?s.setEnd(s.end.row,s.end.column+1):s.start.row<e.aceDoc.getLength()-1&&s.setEnd(s.end.row+1,0),t=0,o=(i=e.readOnlyRanges).length;t<o;t++)if(n=i[t],s.intersects(n))return!0;return!1}}(this),b=function(){return A(".locked-code").finish().addClass("pulsating").effect("shake",{times:1,distance:2,direction:"down"}).removeClass("pulsating")},y=function(e){return n()?(b(),!0):"function"==typeof e?e():void 0},o=function(e,t,o){var n;return n=e[t],e[t]=function(){var t;return t=Array.prototype.slice.call(arguments),o((function(){return n.apply(e,t)}))},e[t]},function(e){}(this),null!=this.lockedCodeMarkerIDs)for(r=0,c=(S=this.lockedCodeMarkerIDs).length;r<c;r++)f=S[r],this.aceSession.removeMarker(f);if(this.lockedCodeMarkerIDs=[],this.readOnlyRanges=[],"python"===(C=this.spell.language)||"coffeescript"===C){for(T=a=0,u=(g=this.aceDoc.getAllLines()).length;a<u;T=++a)p=g[T],/^\s*$/.test(p)||(l=T);null!=l&&this.readOnlyRanges.push(new h(0,0,l,g[l].length-1))}for(m=0,d=(x=this.readOnlyRanges).length;m<d;m++)w=x[m],this.lockedCodeMarkerIDs.push(this.aceSession.addMarker(w,"locked-code","fullLine"));return o(this.ace,"onPaste",y),o(this.ace,"onCut",y),this.ace.commands.on("exec",function(e){return function(t){var o,r,a,l,c,u,d,h,p;if(t.stopPropagation(),t.preventDefault(),"insertstring"===t.command.name&&n()||("Backspace"===(c=t.command.name)||"throttle-backspaces"===c)&&i()||"del"===t.command.name&&s())return null!=(u=e.autocomplete)&&"function"==typeof u.off&&u.off(),b(),!1;if("enter-skip-delimiters"===(d=t.command.name)||"Enter"===d||"Return"===d){if(n())return t.editor.navigateDown(1),t.editor.navigateLineStart(),!1;if(("Enter"===(h=t.command.name)||"Return"===h)&&!(null!=(p=t.editor)&&null!=(o=p.completer)&&null!=(r=o.popup)?r.isOpen:void 0))return null!=(a=e.autocomplete)&&"function"==typeof a.on&&a.on(),t.editor.execCommand("enter-skip-delimiters")}return null!=(l=e.autocomplete)&&"function"==typeof l.on&&l.on(),t.command.exec(t.editor,t.args||{})}}(this))}},t.prototype.initAutocomplete=function(e){var t,o;if(this.autocompleteOn=e,"html"!==this.spell.language)return t=null!=(o=this.options.level.get("autocompleteFontSizePx"))?o:16,this.autocomplete=new r(this.ace,{basic:!1,liveCompletion:!1,snippetsLangDefaults:!1,completers:{keywords:!1,snippets:this.autocompleteOn},autoLineEndings:{javascript:"codecombat-junior"===this.options.level.get("product")?"":";",java:";",c_cpp:";"},popupFontSizePx:t,popupLineHeightPx:1.5*t,popupWidthPx:380})},t.prototype.updateAutocomplete=function(e){var t;return this.autocompleteOn=e,null!=(t=this.autocomplete)?t.set("snippets",this.autocompleteOn):void 0},t.prototype.reallyAddUserSnippets=function(e,t,o){var n,i;if(this.autocomplete&&this.autocompleteOn&&"codecombat-junior"!==this.options.level.get("product")&&!(P.rank()<15))return n=b.parseUserSnippets(e,t,o),null!=this.editorLang&&null!=(i=this.autocomplete)?i.addCustomSnippets(Object.values(n),this.editorLang):void 0},t.prototype.addAutocompleteSnippets=function(e){if(this.autocomplete&&this.autocompleteOn)return this.autocomplete.addCodeCombatSnippets(this.options.level,this,e)},t.prototype.translateFindNearest=function(){var e,t,o;if(e=(t=this.getSource()).replace(/(self:|self.|this.|@)findNearestEnemy\(\)/g,"$1findNearest($1findEnemies())"),t!==(e=e.replace(/(self:|self.|this.|@)findNearestItem\(\)/g,"$1findNearest($1findItems())")))return this.spell.originalSource=e,this.updateACEText(e),_.delay((o=this,function(){return"function"==typeof o.recompile?o.recompile():void 0}),1e3)},t.prototype.onAllLoaded=function(){return this.fetchToken(this.spell.source,this.spell.language).then((e=this,function(t){if(e.spell.transpile(t),e.spell.loaded=!0,Backbone.Mediator.publish("tome:spell-loaded",{spell:e.spell}),e.eventsSuppressed=!1,e.createToolbarView(),e.options.level.isType("web-dev"))return e.updateHTML({create:!0})}
1));var e},t.prototype.createDebugView=function(){if(!this.options.level.isType("hero","hero-ladder","hero-coop","course","course-ladder","game-dev","web-dev","ladder"))return this.debugView=new p({ace:this.ace,thang:this.thang,spell:this.spell}),this.$el.append(this.debugView.render().$el.hide())},t.prototype.createTranslationView=function(){return this.translationView=new v({ace:this.ace,supermodel:this.supermodel}),this.$el.append(this.translationView.render().$el.hide())},t.prototype.createToolbarView=function(){return this.toolbarView=new g({ace:this.ace}),this.$el.append(this.toolbarView.render().$el)},t.prototype.onMouseOut=function(e){var t;return null!=(t=this.debugView)?t.onMouseOut(e):void 0},t.prototype.onContactButtonPressed=function(e){return this.saveSpade()},t.prototype.getSource=function(){return this.ace.getValue()},t.prototype.setThang=function(e){var t,o,n;if(this.focus(),this.lastScreenLineCount=null,this.updateLines(),e.id!==(null!=(t=this.thang)?t.id:void 0))return this.thang=e,this.spellThang=this.spell.thang,this.debugView||this.createDebugView(),null!=(o=this.debugView)&&(o.thang=this.thang),this.translationView||this.createTranslationView(),null!=(n=this.toolbarView)&&n.toggleFlow(!1),this.updateAether(!1,!1),this.highlightCurrentLine()},t.prototype.cast=function(e,t,o,n){return null==e&&(e=!1),null==t&&(t=!1),null==o&&(o=!1),null==n&&(n=!1),Backbone.Mediator.publish("tome:cast-spell",{spell:this.spell,thang:this.thang,preload:e,realTime:t,justBegin:o,cinematic:n})},t.prototype.notifySpellChanged=function(){if(!this.destroyed&&(!this.options.blocks||this.blocklySuccess))return Backbone.Mediator.publish("tome:spell-changed",{spell:this.spell})},t.prototype.notifyEditingEnded=function(){if(!this.destroyed)return Backbone.Mediator.publish("tome:editing-ended",{})},t.prototype.notifyEditingBegan=function(){if(!this.destroyed)return Backbone.Mediator.publish("tome:editing-began",{})},t.prototype.updateSolutionLines=function(e,t,o){var n;return n=e.getSession().getScreenLength(),this.updateAceLines(n,e,t,o),e.resize(!0)},t.prototype.updateAceLines=function(e,t,o,n){var i,s,r,a,l,c,u,d,h,p,g,v,m,f,y,b,w,k,S,C,x,T,P,L,M,I,D,B,E;if(null==t&&(t=this.ace),null==o&&(o=".ace"),null==n&&(n="#code-area"),u=A("#level-view").hasClass("cinematic"),l=this.blocklyActive,D=(null!=(w=A("#tome-view").offset())?w.top:void 0)>100?"bottom":"right",d=t.renderer.lineHeight||20,M=A("#tome-view #spell-palette-view"),I=A("#spell-top-bar-view").outerHeight(),s=A("#control-bar-view").outerHeight(),0===I&&parseInt(A("#control-bar-view").css("left"),10)>0&&(I=s),P=function(){switch(!1){case!l:return 0;case".ace"!==o:return M.find(".properties-this").outerHeight();default:return 0}}(),E=A(window).innerHeight(),B=(null!=(k=A(o).offset())?k.top:void 0)||0,T=Math.min(P,.4*(E-B)),P>0&&(T=Math.max(75,T)),S=".ace"===o?75:0,r=A("#game-area").innerHeight(),c=".ace"===o?1:.5,f=l||u?0:100,v=E-B-T-0-S,m=Math.min(v*c,Math.min(r,E)-P-f),(l||u)&&(m=v),y=(L=P>0)?0:2,(l||u)&&(y=0),a="bottom"===D?5:8,g=Math.max(a,Math.floor(m/d-y)),p=Math.floor(v/d),h=Math.max(g,Math.min(e+2,p),a),_.isNaN(h)&&(h=8),".ace"===o?t.setOptions({minLines:h,maxLines:h}):(C=Math.min(h,e+2),t.setOptions({minLines:C,maxLines:C})),L&&".ace"===o)return b=parseInt(this.$el.css("marginTop"),10)+parseInt(this.$el.css("paddingTop"),10)+d*h+parseInt(this.$el.css("paddingBottom"),10)-10,x=Math.min(P,Math.max(T,E-b-I)),M.css({top:b}),M.find(".properties-scroll-container").css({height:Math.min(P,E-b-I)}),i=P?x:0,A(n).css("bottom",i)},t.prototype.updateLines=function(){var e,t,o,n,i,s,r,a,l,c,u,d,h,p,g,v,m,f,y,b,w,k,S,C,x,T,P,L,M,D,B,E,R,O,V,N,j;this.destroyed||(p=this.aceDoc.getLength(),h=this.aceDoc.$lines[p-1],/\S/.test(h)&&(V=(n=this.ace.getCursorPosition()).row===p-1&&n.column===h.length,this.aceDoc.insertNewLine({row:p,column:0}),V&&this.ace.navigateLeft(1),++p,null!=(k=this.ace)&&null!=(S=k.completer)&&S.showPopup(this.ace)),(E=this.aceSession.getScreenLength())!==this.lastScreenLineCount&&(this.lastScreenLineCount=E,this.updateAceLines(E)),null!=this.firstEntryToScrollLine&&(null!=(C=this.ace)&&null!=(x=C.renderer)&&null!=(T=x.$cursorLayer)?T.config:void 0)&&(this.ace.scrollToLine(this.firstEntryToScrollLine,!0,!0),this.firstEntryToScrollLine=void 0),u="codecombat-junior"===this.options.level.get("product",!0),d=this.options.level.isType("web-dev"),j=this,v=function(e){return j.singleLineCommentOnly
1Regex().test(e)?Math.min(e.length,60):e.length},g=function(e){return function(t){return e.singleLineCommentOnlyRegex().test(t)?0:t.length}}(this),t=this.blocklyActive?g:v,m=Math.max.apply(Math,this.aceDoc.getAllLines().map(t)),(R=I.getters["game/getSolutionSrc"](this.spell.language))&&(m=Math.max.apply(Math,[m].concat($.call(R.split("\n").map(g))))),N={cpp:4,java:8}[this.spell.language]||0,m<8&&(m=(u?30:40)+N),d&&(m=Math.max(m,40)),c=function(){switch(!1){case!u:return 16+N;case!this.blocklyActive:return 18+N;default:return 29}}.call(this),l=("codecombat-junior"===u?40:80)+N,i=Math.min(l,Math.max(c,m+1)),b=null!=(P=this.codeChars)?P.desired:void 0,this.codeChars={min:c,max:l,desired:i},B=!1,b&&i!==b&&(this.resizeWindowDebounced||(D=function(e){return function(){if(!e.destroyed)return A(window).trigger("resize")}}(this),this.resizeWindowDebounced=_.debounce(D,600)),B=!0,this.resizeWindowDebounced()),this.blocklyActive&&(o=this.blockly.getScale(),r=this.$el.find(".blocklyFlyout").width()/o,a=Math.max(r+30,this.blockly.getBlocksBoundingBox().getWidth()+40),O=(null!=(L=A("#tome-view").offset())?L.top:void 0)>100?"bottom":"right",e=A(window).width(),"right"===O&&(e-=924*(A(window).height()-50)/589),"blocks-and-code"===this.options.codeFormat&&(e-=410.47*i/57+30+41+30),s=((s=r+a>(e=Math.max(e,A(window).width()*("blocks-and-code"===this.options.codeFormat?.2:.3)))?Math.max(.5,Math.min(1,e/(r+a))):r+a<.8*e?Math.max(1,Math.min(1.5,.8*e/(r+a))):o)+o)/2,Math.abs(s-o)>.02?this.blockly.setScale(s):s=o,r*=s,a*=s,f=u?221:346,this.toolboxWidth={min:144,max:f,desired:Math.min(f,Math.max(144,r))},y=u?512:665,this.workspaceWidth={min:128,max:y,desired:Math.min(y,Math.max(128,a))},(w=null!=(M=this.workspaceWidth)?M.desired:void 0)&&a!==w&&!B&&(this.resizeWindowDebounced||(D=function(e){return function(){if(!e.destroyed)return A(window).trigger("resize")}}(this),this.resizeWindowDebounced=_.debounce(D,600)),B=!0,this.resizeWindowDebounced())))},t.prototype.hideProblemAlert=function(){if(!this.destroyed)return Backbone.Mediator.publish("tome:hide-problem-alert",{})},t.prototype.saveSpade=function(){var e,t,o;if(!this.destroyed&&this.spade&&(this.spade.createUIEvent("saving-spade"),o=this.spade.compile(),(t=this.spade.condense(o)).length))return e=u.compressToUTF16(JSON.stringify(t)),new c({sessionID:this.options.session.id,level:{original:this.options.level.get("original"),majorVersion:this.options.level.get("version").major},levelSlug:this.options.level.get("slug"),userID:this.options.session.get("creator"),log:e}).save()},t.prototype.onShowVictory=function(e){if(null!=this.spade&&this.spade.createUIEvent("victory-shown"),null!=this.saveSpadeTimeout&&(window.clearTimeout(this.saveSpadeTimeout),this.saveSpadeTimeout=null,"beta"===this.options.level.get("releasePhase")))return this.saveSpade()},t.prototype.onManualCast=function(e){var t;if(null!=this.spade&&this.spade.createUIEvent("code-run"),t=this.$el.parent().length,this.recompile(t,e.realTime,!1),t&&this.focus(),this.options.level.isType("web-dev"))return this.sourceAtLastCast=this.getSource(),this.ace.setStyle("spell-cast"),this.updateHTML({create:!0})},t.prototype.reloadCode=function(e){if(null==e&&(e=!0),e&&this.spell.reloadCode(),this.thang=this.spell.thang.thang,this.updateACEText(this.spell.originalSource),this.aceToBlockly(),this.lockDefaultCode(!0),this.recompile(e),Backbone.Mediator.publish("tome:spell-loaded",{spell:this.spell}),this.hasSetInitialCursor=!1,this.highlightCurrentLine(),this.updateLines(),null!=this.spade)return this.spade.createUIEvent("code-reset")},t.prototype.recompile=function(e,t,o){return null==e&&(e=!0),null==t&&(t=!1),null==o&&(o=!1),this.fetchTokenForSource().then((n=this,function(s){var r,a;if(a=i.getTokenSource(s),(r=n.spell.source!==a)&&(n.spell.transpile(s),n.updateAether(!0,!1)),e&&n.cast(!1,t,!1,o),r)return n.notifySpellChanged()}));var n},t.prototype.updateACEText=function(e){var t;this.eventsSuppressed=!0,this.ace.setValue(e),this.ace.clearSelection(),this.aceSession.setUndoManager(new m),this.eventsSuppressed=!1;try{return this.ace.resize(!0)}catch(e){return t=e,console.warn("Error resizing ACE after an update:",t)}},t.prototype.createOnCodeChangeHandlers=function(){var e,t,o;if(this.onCodeChangeMetaHandler&&this.aceDoc.removeListener("change",this.onCodeChangeMetaHandler),t=[],e=[_.debounce(this.updateAether,this.options.level.isType("game-dev")?10:500),_.debounce(this.notifyEditingEnded,1e3),_.throttle(this.notifyEditingBegan,250),_.throttle(this.notifySpellChanged,300),_.throttle(this.updateLines,500),_.throttle(this.hideProblemAlert,500),_.throttle(this.aceToBlockly,500)],this.options.level.get("requiredCode")&&t.push(_.debounce(this.checkRequiredCode,750)),this.options.level.get("suspectCode")&&t.push(_.debounce(this.checkSuspectCode,750)),this.options.level.isType("web-dev")&&e.push(_.throttle(this.updateHTML,10)),this.onCodeChangeMetaHandler=(o=this,function(){if(!o.eventsSuppressed)return o.spellThang?o.spell.hasChangedSignificantly(o.getSource(),o.spellThang.aether.raw,(function(n){var i,s,r,a,l,c;if(!o.spellThang||n)for(s=0,a=t.length;s<a;s++)(i=t[s])();for(c=[],r=0,l=e.length;r<l;r++)i=e[r],c.push(i());return c})):void 0}),this.aceDoc.on("change",this.onCodeChangeMetaHandler),this.blockly)return this.blockly.addChangeListener(this.onBlocklyEvent)},t.prototype.onCursorActivity=function(){},t.prototype.updateHTML=function(e){return null==e&&(e={}),this.spell.hasChanged(this.spell.getSource(),this.sourceAtLastCast)&&this.ace.unsetStyle("spell-cast"),this.clearWebDevErrors(),Backbone.Mediator.publish("tome:html-updated",{html:this.spell.constructHTML(this.getSource()),create:Boolean(e.create)})},t.prototype.fetchToken=function(e,t){return e in this.loadedToken?Promise.resolve(this.loadedToken[e]):(e=B.guardJuniorLevelHealthCode(this.options.level,e),w.fetchToken(e,t))},t.prototype.fetchTokenForSource=function(){var e;return e=this.ace.getValue(),this.fetchToken(e,this.spell.language)},t.prototype.updateAether=function(e,t){var o,n,s;if(null==e&&(e=!1),null==t&&(t=!0),o=null!=(n=this.spellThang)?n.aether:void 0)return this.fetchTokenForSource().then((s=this,function(n){var r;return r=i.getTokenSource(n),s.spell.hasChangedSignificantly(n,o.raw,(function(i){var a,l,c,u,d,h;if(((d=(l=e||i)||s.spellThang!==s.lastUpdatedAetherSpellThang)||o!==s.displayedAether)&&(a=s.spellThang.castAether,(c=a&&r===a.raw)&&(o=a),d||o!==s.displayedAether))return u=function(e){if(s.clearAetherDisplay(),s.displayAether(e,c),s.lastUpdatedAetherSpellThang=s.spellThang,t)return s.guessWhetherFinished(e)},s.clearAetherDisplay(),l&&!c?s.worker?(h={function:"transpile",spellKey:s.spell.spellKey,source:n},s.worker.addEventListener("message",(function(e){var t;if("transpile"===(t=JSON.parse(e.data)).function&&t.spellKey===s.spell.spellKey)return s.worker.removeEventListener("message",arguments.callee,!1),o.problems=t.problems,o.raw=r,u(o)}
1)),s.worker.postMessage(JSON.stringify(h))):(o.transpile(n),u(o)):u(o)}))}))},t.prototype.clearAetherDisplay=function(){return this.clearProblemsCreatedBy("aether"),this.highlightCurrentLine({})},t.prototype.clearWebDevErrors=function(){return this.clearProblemsCreatedBy("web-dev-iframe")},t.prototype.clearProblemsCreatedBy=function(e){var t,o;return null!=this.aceSession&&(t=_.reject(this.aceSession.getAnnotations(),(function(t){return t.createdBy===e})),this.reallySetAnnotations(t)),(o=_.filter(this.problems,(function(t){return t.createdBy===e}))).forEach((function(e){return e.destroy()})),this.problems=_.difference(this.problems,o),Backbone.Mediator.publish("tome:problems-updated",{spell:this.spell,problems:this.problems,isCast:!1})},t.prototype.convertAetherProblems=function(e,t,o){return _.unique(t,(function(e){var t;return null!=(t=e.userInfo)?t.key:void 0})).map((n=this,function(t){return new d({aether:e,aetherProblem:t,ace:n.ace,isCast:o,levelID:n.options.levelID})}));var n},t.prototype.displayAether=function(e,t){var o,n,i,s,r,a,l;if(null==t&&(t=!1),this.displayedAether=e,null!=this.ace){for(t=t||!_.isEmpty(e.metrics)||_.some(e.getAllProblems(),{type:"runtime"}),o=this.aceSession.getAnnotations(),n=0,s=(a=this.convertAetherProblems(e,e.getAllProblems(),t)).length;n<s;n++)(l=a[n]).annotation&&o.push(l.annotation);if(t)for(a[0]&&this.displayProblemBanner(a[0]),i=0,r=a.length;i<r;i++)l=a[i],this.saveUserCodeProblem(e,l.aetherProblem);return this.problems=this.problems.concat(a),this.aceSession.setAnnotations(o),_.isEmpty(e.flow)||this.highlightCurrentLine(e.flow),Backbone.Mediator.publish("tome:problems-updated",{spell:this.spell,problems:this.problems,isCast:t}),this.ace.resize()}},t.prototype.displayProblemBanner=function(e){var t,o,n,i,s;if(null!=this.spade&&this.spade.createUIEvent("code-error"),n=0,null!=e.row){for(t=o=0,i=e.row;0<=i?o<i:o>i;t=0<=i?++o:--o)n+=this.aceSession.getRowLength(t)*this.ace.renderer.lineHeight;n-=this.ace.session.getScrollTop()}return"info"!==(s=e.level)&&"warning"!==s&&Backbone.Mediator.publish("playback:stop-cinematic-playback",{}),Backbone.Mediator.publish("tome:show-problem-alert",{problem:e,lineOffsetPx:Math.max(n,0)})},t.prototype.linesBeforeScript=function(e){return _.size(e.split("<script>")[0].match(/\n/g))},t.prototype.addAnnotation=function(e){var t;return(t=this.aceSession.getAnnotations()).push(e),this.reallySetAnnotations(t)},t.prototype.onWebDevError=function(e){var t,o,n;return t=_.merge({},e,{line:e.line+this.linesBeforeScript(this.getSource())}),n=this.spell.hasChanged(this.spell.getSource(),this.sourceAtLastCast),o=new d({error:t,ace:this.ace,levelID:this.options.levelID,userCodeHasChangedSinceLastCast:n}),_.any(this.problems,(function(e){return o.isEqual(e)}))?o.destroy():(this.problems.push(o),this.displayProblemBanner(o),o.annotation&&this.addAnnotation(o.annotation),Backbone.Mediator.publish("tome:problems-updated",{spell:this.spell,problems:this.problems,isCast:!1}))},t.prototype.onProblemsUpdated=function(e){var t,o;if(e.spell,o=e.problems,t=e.isCast,null!=this.ace)return this.ace[o.length?"setStyle":"unsetStyle"]("user-code-problem"),this.ace[t?"setStyle":"unsetStyle"]("spell-cast")},t.prototype.saveUserCodeProblem=function(e,t){var o,n;if(!((o=e.raw+t.message)in this.savedProblems)&&(this.savedProblems[o]=!0,n=.01*Math.max(1,2*(P.rank()-2)),Math.random()<n))return this.createUserCodeProblem(e,t).save(),null},t.prototype.createUserCodeProblem=function(e,t){var o,n,i,s,r;
1return(r=new f).set("code",e.raw),t.range&&(o=e.raw.split("\n").slice(t.range[0].row,t.range[1].row+1),r.set("codeSnippet",o.join("\n"))),t.hint&&r.set("errHint",t.hint),t.id&&r.set("errId",t.id),t.errorCode&&r.set("errCode",t.errorCode),t.level&&r.set("errLevel",t.level),t.message&&(r.set("errMessage",t.message),(n=(i=t.message).match(/^Line [0-9]+\: /))&&(i=i.slice(n[0].length)),r.set("errMessageNoLineInfo",i)),t.range&&r.set("errRange",t.range),t.type&&r.set("errType",t.type),(null!=(s=e.language)?s.id:void 0)&&r.set("language",e.language.id),this.options.levelID&&r.set("levelID",this.options.levelID),r},t.prototype.guessWhetherFinished=function(e){var t,o,n,i,s,r,a;return r=!e.getAllProblems().length,!!this.blocklyActive||(r?(n=this.ace.getCursorPosition(),o=_.string.rtrim(this.aceDoc.$lines[n.row].replace(this.singleLineCommentRegex(),"")),i=n.column>=o.length,t=!o.substr(0,n.column).trim().length,!(s=/^(s|se|sel|self|t|th|thi|this|g|ga|gam|game|h|he|her|hero)$/.test(o.trim()))&&this.options.level.isType("game-dev")?this.fetchTokenForSource().then((a=this,function(e){return a.spell.transpile(e),a.cast(!1,!1,!0)})):!i&&!t||s?void 0:this.preload()):void 0)},t.prototype.singleLineCommentRegex=function(){var e;return this._singleLineCommentRegex?(this._singleLineCommentRegex.lastIndex=0,this._singleLineCommentRegex):(e="html"===this.spell.language?B.commentStarts.html+"|"+B.commentStarts.css+"|"+B.commentStarts.javascript:B.commentStarts[this.spell.language]||"//",this._singleLineCommentRegex=new RegExp("[ \t]*("+e+")[^\"'\n]*"),this._singleLineCommentRegex)},t.prototype.singleLineCommentOnlyRegex=function(){return this._singleLineCommentOnlyRegex?(this._singleLineCommentOnlyRegex.lastIndex=0,this._singleLineCommentOnlyRegex):(this._singleLineCommentOnlyRegex=new RegExp("^"+this.singleLineCommentRegex().source),this._singleLineCommentOnlyRegex)},t.prototype.commentOutMyCode=function(){var e;return("javascript"===(e=this.spell.language)||"java"===e||"cpp"===e?"return;  ":"return  ")+B.commentStarts[this.spell.language]},t.prototype.preload=function(){var e,t,o,n,i,s,r,a,l;if(-1===this.spell.source.indexOf("while")&&!(this.spell.source.length>500||(null!=(n=this.spellThang)&&null!=(i=n.castAether)&&null!=(s=i.metrics)?s.statementsExecuted:void 0)>2e3||this.options.level.isType("web-dev"))){for(e in t=this.spell.source,o=null!=(r=this.spell.thang)?r.aether.serialize():void 0,this.spell.transpile(this.getSource()),this.cast(!0),this.spell.source=t,a=[],o)l=o[e],a.push(this.spell.thang.aether[e]=l);return a}},t.prototype.onAddUserSnippets=function(){var e;if(this.spell.team===P.team)return this.addUserSnippets(this.spell.getSource(),this.spell.language,null!=(e=this.ace)&&"function"==typeof e.getSession?e.getSession():void 0)},t.prototype.onSpellCreated=function(e){if(e.spell.team===P.team)return setTimeout((t=this,function(){var o;return t.addUserSnippets(e.spell.getSource(),e.spell.language,null!=(o=t.ace)&&"function"==typeof o.getSession?o.getSession():void 0)}),500);var t},t.prototype.onSpellChanged=function(e){return this.spellHasChanged=!0},t.prototype.onAceMouseOut=function(e){return Backbone.Mediator.publish("web-dev:stop-hovering-line",{})},t.prototype.onAceMouseMove=function(e){var t,o;if(!this.destroyed&&(o=e.getDocumentPosition().row)!==this.lastRowHovered)return this.lastRowHovered=o,t=this.aceSession.getLine(o),Backbone.Mediator.publish("web-dev:hover-line",{row:o,line:t}),null},t.prototype.onSessionWillSave=function(e){var t;if(this.spellHasChanged&&P.isAdmin())return setTimeout((t=this,function(){if(!t.destroyed&&!t.spellHasChanged)return t.$el.find(".save-status").finish().show().fadeOut(2e3)}),1e3),this.spellHasChanged=!1},t.prototype.onUserCodeProblem=function(e){var t;if(e.god===this.options.god){if("runtime_InfiniteLoop"===e.problem.id)return this.onInfiniteLoop(e);var o;if(e.problem.userInfo.methodName===this.spell.name&&(null!=(t=this.spell.thang)?t.thang.id:void 0)===e.problem.userInfo.thangID)return this.spell.hasChangedSignificantly(this.getSource(),null,(o=this,function(t){var n,i;if(!t)return"runtime"===e.problem.type?null!=(n=o.spellThang)&&null!=(i=n.castAether)&&i.addProblem(e.problem):o.spell.thang.aether.addProblem(e.problem),o.lastUpdatedAetherSpellThang=null,o.updateAether(!1,!1)}))}},t.prototype.onNonUserCodeProblem=function(e){var t,o;if(e.god===this.options.god&&this.spellThang)return t=this.spellThang.aether.createUserCodeProblem({type:"runtime",kind:"Unhandled",message:"Unhandled error: "+e.problem.message}),this.spellThang.aether.addProblem(t),null!=(o=this.spellThang.castAether)&&o.addProblem(t),this.lastUpdatedAetherSpellThang=null,this.updateAether(!1,!1)},t.prototype.onInfiniteLoop=function(e){var t;if(this.spellThang)return this.spellThang.aether.addProblem(e.problem),null!=(t=this.spellThang.castAether)&&t.addProblem(e.problem),this.lastUpdatedAetherSpellThang=null,this.updateAether(!1,!1)},t.prototype.onNewWorld=function(e){return this.fetchTokenForSource().then((t=this,function(o){var n,i,s,r;return(r=e.world.getThangByID(null!=(i=t.spell.thang)?i.thang.id:void 0))?(n=null!=(s=e.world.userCodeMap[r.id])?s[t.spell.name]:void 0,t.spell.thang.castAether=n,t.spell.thang.aether=t.spell.createAether(r)):t.spell.thang=null,t.spell.transpile(o),t.updateAether(!1,!1)}));var t}
1,t.prototype.focus=function(){var e;if(this.controlsEnabled&&this.writable&&0===A(".modal:visible, .shepherd-button:visible").length&&!this.ace.isFocused()&&!((null!=(e=P.get("aceConfig"))?e.screenReaderMode:void 0)&&B.isOzaria||this.blocklyActive))return this.ace.focus(),this.ace.clearSelection()},t.prototype.onFrameChanged=function(e){var t,o;if(this.spellThang&&(null!=(t=e.selectedThang)?t.id:void 0)===(null!=(o=this.spellThang)?o.thang.id:void 0))return this.thang=e.selectedThang,this.highlightCurrentLine()},t.prototype.onCoordinateSelected=function(e){if(this.ace.isFocused()&&null!=e.x&&null!=e.y)return"python"===this.spell.language?this.ace.insert('{"x": '+e.x+', "y": '+e.y+"}"):"lua"===this.spell.language?this.ace.insert("{x="+e.x+", y="+e.y+"}"):this.ace.insert("{x: "+e.x+", y: "+e.y+"}"),this.highlightCurrentLine()},t.prototype.onStatementIndexUpdated=function(e){if(e.ace===this.ace)return this.highlightCurrentLine()},t.prototype.highlightCurrentLine=function(e){var t,o,n,i,s,r,a,l,c,u,d,p,g,v,m,f,y,b,w,S,C,x,T,P,L,M,I,D,R,O,V,$,N,j,F,H,G,U,z,W,q,K,Q,X,J,Z,Y,ee,te,oe,ne,ie,se;if(this.destroyed||this.highlightEntryPoints(),null==e&&(e=null!=(O=this.spellThang)&&null!=(z=O.castAether)?z.flow:void 0),e&&this.thang){for(u=[],d={},M=!1,l=null,i=m=0,b=(ie=null!=(W=e.states)?W:[]).length;m<b;i=++m){if(s=ie[i],null==l&&(null!=(q=s.userInfo)?q.time:void 0)>this.thang.world.age&&(l=i-1),M){u.pop();break}for(u.push([]),ne=f=0,w=(K=s.statements).length;f<w;ne=++f){if((null!=(Q=(oe=K[ne]).userInfo)?Q.time:void 0)>this.thang.world.age){M=!0;break}_.last(u).push(oe),d[oe.range[0].row]=!0}}if(null==l&&(l=i-1),this.decoratedGutter=this.decoratedGutter||{},null!=this.aceSession){for(x=0,S=(X=null!=this.markerRanges?this.markerRanges:this.markerRanges=[]).length;x<S;x++)(P=X[x]).start.detach(),P.end.detach(),this.aceSession.removeMarker(P.id);for(this.markerRanges=[],Z=I=0,J=this.aceSession.getLength();0<=J?I<J:I>J;Z=0<=J?++I:--I)d[Z]||(this.aceSession.removeGutterDecoration(Z,"executing"),this.aceSession.removeGutterDecoration(Z,"executed"),this.decoratedGutter[Z]="");for(y=_.last(u),u.length&&this.spellThang.castAether.metrics.statementsExecuted>3&&this.options.level.get("hidesCodeToolbar"),this.blockly&&this.$el.find(".highlighted-block").attr("class","blocklyDraggable"),null!=(V=this.toolbarView)&&V.toggleFlow(!1),null!=($=this.debugView)&&$.setVariableStates({}),T={},p=!1,v=D=0,C=(N=null!=y?y:[]).length;D<C;v=++D){if(te=(j=(oe=N[v]).range)[0],c=j[1],"executed"==(r=v===y.length-1?"executing":"executed")){if(T[te.row])continue;T[te.row]=!0,L="fullLine"}else null!=(F=this.debugView)&&F.setVariableStates(oe.variables),p=!0,L="text";if((P=new h(te.row,te.col,c.row,c.col)).start=this.aceDoc.createAnchor(P.start),P.end=this.aceDoc.createAnchor(P.end),P.id=this.aceSession.addMarker(P,r,L),this.markerRanges.push(P),d[te.row]&&this.decoratedGutter[te.row]!==r)for(""!==this.decoratedGutter[te.row]&&this.aceSession.removeGutterDecoration(te.row,this.decoratedGutter[te.row]),this.aceSession.addGutterDecoration(te.row,r),this.decoratedGutter[te.row]=r,E.isIPadApp&&Backbone.Mediator.publish("tome:highlight-line",{line:te.row}),t=A("#cinematic-code-display"),g=0,ee=R=H=c.row-3,G=c.row+3;H<=G?R<=G:R>=G;ee=H<=G?++R:--R)a=_.string.rtrim(this.aceDoc.$lines[ee]),o=t.find(".code-line-"+g++),B.replaceText(o.find(".line-number"),ee>=0?ee+1:""),B.replaceText(o.find(".indentation"),a.match(/\s*/)[0]),B.replaceText(o.find(".code-text"),_.string.trim(a));"executing"===r&&this.blockly&&(se=this.aceDoc.$lines.slice(0,c.row+1).map((function(e){return e.trim().replace(/.*(look\(.*?\))/,"$1")})),a=_.last(se),Y=se.filter((function(e){return e===a})).length-1,(n=k.getBlocksByCodeLine({workspace:this.blockly,codeLine:a,codeLanguage:this.spell.language})[Y])&&A(n.svgGroup_).attr("class","blocklyDraggable highlighted-block"))}return p||null!=(U=this.debugView)&&U.setVariableStates({}),null}}},t.prototype.highlightEntryPoints=function(){var e,t,o,n,i,s,r,a,l,c,u,d,h,p,g,v,m,f,y,b,w,k,S,_,C,x,T,P;if(null!=this.aceDoc){for(g=this.aceDoc.$lines,m=this.spell.originalSource.split("\n"),P=this.aceSession,B.commentStarts[this.spell.language],T=!1,y=null,w=!1,b=!1,k=!1,f=!1,x=[],o=i=0,r=g.length;i<r;o=++i){for(l=g[o],P.removeGutterDecoration(o,"entry-point"),P.removeGutterDecoration(o,"next-entry-point"),s=0,a=(S=[0,4,8,12,16]).length;s<a;s++)e=S[s],P.removeGutterDecoration(o,"entry-point-indent-"+e);if(d=this.singleLineCommentRegex().test(l),u=l.trim()[0]&&!this.singleLineCommentOnly
1Regex().test(l),p=/^[ \t]*$/.test(l),h=/[Δ∆]/.test(l),c=l!==m[o],(n=p&&w&&!b&&f)&&c&&(-1!==(v=m.indexOf(y))&&l===m[v+1]?c=!1:n=!1),h&&(c?-1!==m.indexOf(l)&&(c=!1,n=!0):n=!0),n){for(P.addGutterDecoration(o,"entry-point"),T||(P.addGutterDecoration(o,"next-entry-point"),T=!0,this.hasSetInitialCursor||(this.hasSetInitialCursor=!0,this.ace.navigateTo(o,null!=(_=null!=(C=l.match(/\S/))?C.index:void 0)?_:l.length),this.firstEntryToScrollLine=o)),t=0;/\s/.test(l[t]);)t++;t=Math.min(16,4*Math.floor(t/4)),P.addGutterDecoration(o,"entry-point-indent-"+t)}y=l,w=d,b=u,k=p,x.push(f||(f=u||k))}return x}},t.prototype.onAnnotationClick=function(){return Backbone.Mediator.publish("tome:jiggle-problem-alert",{})},t.prototype.onGutterClick=function(){return this.ace.clearSelection()},t.prototype.onDisableControls=function(e){return this.toggleControls(e,!1)},t.prototype.onEnableControls=function(e){return this.toggleControls(e,this.writable)},t.prototype.toggleControls=function(e,t){var o,n;if(!this.destroyed&&(!(null!=e?e.controls:void 0)||V.call(e.controls,"editor")>=0)&&t!==this.controlsEnabled)return this.controlsEnabled=t&&this.writable,o=!t,n=this.ace.isFocused(),this.ace.setReadOnly(o),this.ace[o?"setStyle":"unsetStyle"]("disabled"),this.toggleBackgroun
1d(),o&&n?A("body").focus():void 0},t.prototype.toggleBackground=function(){var e;return 0===(e=this.$el.find("img.code-background")[0]).naturalWidth?_.delay(this.toggleBackground,100):(this.controlsEnabled&&x.revertImage(e,"span.code-background"),this.controlsEnabled?void 0:x.darkenImage(e,"span.code-background",.8))},t.prototype.onSpellBeautify=function(e){var t,o;if(this.spellThang&&(this.ace.isFocused()||e.spell===this.spell||!e.spell))return o=this.getSource(),t=this.spellThang.aether.beautify(o.replace(/\bloop\b/g,"while (__COCO_LOOP_CONSTRUCT__)")).replace(/while \(__COCO_LOOP_CONSTRUCT__\)/g,"loop"),this.ace.setValue(t)},t.prototype.onFixCode=function(e){return this.ace.setValue(e.code),this.ace.clearSelection(),this.recompile()},t.prototype.onFixCodePreviewStart=function(e){return this.codeBeforePreview=this.getSource(),this.updateACEText(e.code),this.ace.clearSelection()},t.prototype.onFixCodePreviewEnd=function(e){return this.updateACEText(this.codeBeforePreview),this.ace.clearSelection()},t.prototype.fillACESolution=function(){var e,t,o;return this.aceSolution=y.edit(document.querySelector(".ace-solution")),(e=this.aceSolution.getSession()).setMode(b.aceEditModes[this.spell.language]),this.aceSolution.setTheme("ace/theme/textmate"),t=this.teaching?I.getters["game/getSolutionSrc"](this.spell.language):"",this.aceSolution.setValue(t),this.aceSolution.clearSelection(),this.aceSolutionLastLineCount=0,this.updateSolutionLines=_.throttle(this.updateSolutionLines,1e3),this.aceDiff=new n({element:"#solution-view",showDiffs:!1,showConnectors:!0,mode:b.aceEditModes[this.spell.language],left:{ace:this.aceSolution,editable:!1,copyLinkEnabled:!1},right:{ace:this.ace,copyLinkEnabled:!1}}),e.on("changeBackMarker",(o=this,function(){if(o.aceDiff&&0===o.aceDiff.getNumDiffs())return Backbone.Mediator.publish("level:close-solution",{removeButton:!0})}))},t.prototype.onUpdateSolution=function(e){if(this.aceDiff)return this.aceSolution.setValue(e.code),this.aceSolution.clearSelection(),this.updateSolutionLines(this.aceSolution,".ace-solution","#solution-area")},t.prototype.onStreamingSolution=function(e){if(e.finish?this.solutionStreaming=!1:this.solutionStreaming=!0,document.querySelector("#solution-area").classList.contains("display"))return this.aceDiff.setOptions({showDiffs:null!=e.finish})},t.prototype.onToggleSolution=function(e){var t,o;if(this.aceDiff&&!this.blocklyActive&&(e.code&&this.onUpdateSolution(e),(t=document.querySelector("#solution-area")).classList.contains("display")?t.classList.remove("display"):(t.style.opacity=1,t.classList.add("display"),Backbone.Mediator.publish("tome:hide-problem-alert",{}),setTimeout((o=this,function(){return"function"==typeof o.resize?o.resize():void 0}),1100)),!this.solutionStreaming))return this.aceDiff.setOptions({showDiffs:t.classList.contains("display")})},t.prototype.closeSolution=function(){var e;if((e=document.querySelector("#solution-area")).classList.contains("display"))return e.classList.remove("display"),this.aceDiff.setOptions({showDiffs:!1}),setTimeout((function(){return e.style.opacity=0}),1e3)},t.prototype.onApplySolution=function(){var e,t,o;return null==this.aceSolution||null==this.aceSession?console.warn("ApplySolution: solution editor not ready"):(o=this.aceSolution.getValue())&&o.trim()?(e=(t=this.aceSession.getLength()-1)>=0?this.aceDoc.getLine(t).length:0,this.aceSession.replace(new h(0,0,t,e),o),this.closeSolution()):console.log("No solution code found")},t.prototype.onToggleBlocks=function(e){if((!e.blocks||!this.blocklyActive)&&(e.blocks||this.blocklyActive))return e.blocks&&this.blockly?this.blocklyActive=!0:e.blocks?this.addBlockly():this.blockly&&(this.awaitingBlockly=!1,this.blocklyActive=!1),this.resize()},t.prototype.onWindowResize=function(e){return this.spellPaletteHeight=null,_.delay((t=this,function(){return"function"==typeof t.resize?t.resize():void 0}),600);var t},t.prototype.resize=function(){var e;return null!=(e=this.ace)&&e.resize(!0),this.lastScreenLineCount=null,this.updateLines(),this.resizeBlockly(),this.updateSolutionLines(this.aceSolution,".ace-solution","#solution-area")},t.prototype.resizeBlockly=function(e){var t;if(null==e&&(e=!0),this.blocklyActive)return a.svgResize(this.blockly),e?(this.scrollBlocklyToTopLeft(),_.delay((t=this,function(){return"function"==typeof t.resizeBlockly?t.resizeBlockly(!1):void 0}),600)):void 0},t.prototype.scrollBlocklyToTopLeft=function(){var e;return e=this.blockly.getMetrics(),this.blockly.scroll(30-e.contentLeft,50-e.contentTop)},t.prototype.onChangeEditorConfig=function(e){var t,o,n,i;if(t=null!=(o=P.get("aceConfig"))?o:{},this.ace.setBehavioursEnabled(t.behaviors),this.ace.setKeyboardHandler(this.keyBindings[null!=(n=t.keyBindings)?n:"default"]),this.updateAutocomplete(null!=(i=t.liveCompletion)&&i),!this.destroyed)return A(window).trigger("resize")},t.prototype.onChangeLanguage=function(e){var t,o;if(this.spell.canWrite())return this.aceSession.setMode(b.aceEditModes[e.language]),null!=(t=this.autocomplete)&&t.set("language",b.aceEditModes[e.language].substr("ace/mode/")),o=this.getSource()===this.spell.originalSource,this.spell.setLanguage(e.language),o&&this.reloadCode(!0),this.renderSelectors(".programming-language")},t.prototype.onInsertSnippet=function(e){var t,o,n;n=null,(null!=(t=e.doc.snippets)&&null!=(o=t[e.language])?o.code:void 0)?n=e.doc.snippets[e.language].co
1de:"snippet"!==e.formatted.type&&null!=e.formatted.shortName&&(n=e.formatted.shortName),null!=n&&y.require("ace/snippets").snippetManager.insertSnippet(this.ace,n)},t.prototype.dismiss=function(){return this.spell.hasChangedSignificantly(this.getSource(),null,(e=this,function(t){if(t)return e.recompile()}));var e},t.prototype.onScriptStateChange=function(e){return this.scriptRunning=null!==e.currentScript},t.prototype.onPlaybackEndedChanged=function(e){var t;return A(null!=(t=this.ace)?t.container:void 0).toggleClass("playback-ended",e.ended)},t.prototype.onGatherChatMessageContext=function(e){var t,o,n,i,s,r,a,l,c,u;if((n=e.chat.context).codeLanguage=this.spell.language||"python",(s=this.options.level)&&(n.levelOriginal=s.get("original"),n.levelName=s.get("displayName")||s.get("name"),e.chat.example))for(i in null==n.i18n&&(n.i18n={}),l=s.get("i18n"))(r=l[i].name)&&(null==(o=n.i18n)[i]&&(o[i]={}),n.i18n[i].levelName=r);return t=this.displayedAether,this.displayedAether===this.spellThang.aether||!_.isEmpty(t.metrics)||_.some(t.getAllProblems(),{type:"runtime"}),(a=this.convertAetherProblems(t,t.getAllProblems(),!1)[0])&&(u=this.createUserCodeProblem(t,a.aetherProblem),n.error=_.pick({codeSnippet:u.get("codeSnippet"),hint:u.get("errHint"),id:u.get("errId"),errorCode:u.get("errCode"),level:u.get("errLevel"),message:u.get("errMessage"),messageNoLineInfo:u.get("errMessageNoLineInfo"),range:u.get("errRange"),type:u.get("errType"),i18nParams:a.i18nParams},(function(e){return void 0!==e}))),c=this.spell.createChatMessageContext(e.chat),_.assign(n,c)},t.prototype.checkRequiredCode=function(){var e,t,o,n,i,s;if(!this.destroyed){for(s=this.getSource().replace(this.singleLineCommentRegex(),""),i=[],e=0,t=(n=this.options.level.get("requiredCode")).length;e<t;e++)o=n[e],-1===s.indexOf(o)?(null==this.warnedCodeFragments&&(this.warnedCodeFragments={}),this.warnedCodeFragments[o]||Backbone.Mediator.publish("tome:required-code-fragment-deleted",{codeFragment:o}),i.push(this.warnedCodeFragments[o]=!0)):i.push(void 0);return i}},t.prototype.checkSuspectCode=function(){var e,t,o,n,i,s,r,a,l,c,u;if(!this.destroyed){for(l=this.getSource().replace(this.singleLineCommentRegex(),""),e=[],t=0,i=(u=this.options.level.get("suspectCode")).length;t<i;t++)c=u[t],new RegExp(c.pattern,"m").test(l)&&(null==this.warnedCodeFragments&&(this.warnedCodeFragments={}),this.warnedCodeFragments[c.name]||Backbone.Mediator.publish("tome:suspect-code-fragment-added",{codeFragment:c.name,codeLanguage:this.spell.language}),this.warnedCodeFragments[c.name]=!0,e.push(c.name));for(o=0,s=(a=null!=(r=this.lastDetectedSuspectCodeFragmentNames)?r:[]).length;o<s;o++)n=a[o],V.call(e,n)<0&&Backbone.Mediator.publish("tome:suspect-code-fragment-deleted",{codeFragment:n,codeLanguage:this.spell.language});return this.lastDetectedSuspectCodeFragmentNames=e}},t.prototype.onAskingHelp=function(e){var t,o;if(B.useWebsocket)return(t=e.msg).info.url+="?course="+this.courseID+"&codeLanguage="+this.session.get("codeLanguage")+"&session="+this.session.id+"&teaching=true",C("/db/level.session/"+this.session.id+"/permissions/ws/"+t.to,{method:"PUT"}).then((o=this,function(){return o.yjsProvider&&o.yjsProvide.wsconnected?T.application.wsBus.ws.sendJSON(t):(o.yjsProvider=b.setupCRDT(""+o.session.id,P.broadName(),o.getSource(),o.ace,(function(){return T.application.wsBus.ws.sendJSON(t)})),o.yjsProvider.connections=1,o.yjsProvider.awareness.on("change",(function(){return o.yjsProvider.connections=o.yjsProvider.awareness.getStates().size,console.log("provider get awareness update:",o.yjsProvider.connections)})))}))},t.prototype.onCinematicPlaybackStarted=function(e){var t,o,n,i;if(!this.cinematic)return this.cinematic=!0,null!=(t=this.blockly)&&null!=(o=t.getToolbox())&&o.setVisible(!1),null!=(n=this.blockly)&&null!=(i=n.getFlyout())?i.setVisible(!1):void 0},t.prototype.onCinematicPlaybackEnded=function(e){var t,o,n,i;if(this.cinematic)return this.cinematic=!1,null!=(t=this.blockly)&&null!=(o=t.getToolbox())&&o.setVisible(!0),null!=(n=this.blockly)&&null!=(i=n.getFlyout())&&i.setVisible(!0),null},t.prototype.determineMaxBlocks=function(){var e,t,o,n,i,s,r,a,l,c,u,d;if("codecombat-junior"!==this.options.level.get("product"))return Infinity;if(t=this.options.level.get("goals")||[],!(s=_.find(t,(function(e){return e.linesOfCode}))))return Infinity;if(r=s.linesOfCode.humans,n=_.find(Object.values(this.propertyEntryGroups||{}),(function(e){return _.find(e.props,{name:"look"})})),o=_.find(Object.values(this.propertyEntryGroups||{}),(function(e){return _.find(e.props,{name:"dist"})})),i=_.find(Object.values(this.propertyEntryGroups||{}),(function(e){return _.find(e.props,{name:"variable"})})),n){if(e=(null!=(a=(d=I.getters["game/getSolutionSrc"](this.spell.language)||"").match(/(look\(|dist\(|health)/g))?a.length:void 0)||0,e+=(null!=(l=
1d.match(/^ *(if|while).*?(===|==|!==|!=|~=|<|<=|>|>=).+$/gm))?l.length:void 0)||0,e+=(null!=(c=d.match(/^ *(if|while).*?(===|==|!==|!=|~=|<|<=|>|>=).*?['"]?[a-zA-Z0-9_$]+['"]?/gm))?c.length:void 0)||0,o&&(e+=(null!=(u=d.match(/go\(.(up|down|left|right)., \d/g))?u.length:void 0)||0),i)return Infinity;r+=e}return r},t.prototype.destroy=function(){var e,o,n,i,s,r,a,l,c,u,d,h,p,g,v,m;for(A(null!=(i=this.ace)?i.container:void 0).find(".ace_gutter").off("click mouseenter",".ace_error, .ace_warning, .ace_info"),A(null!=(c=this.ace)?c.container:void 0).find(".ace_gutter").off(),null!=(u=this.blockly)&&u.dispose(),o=0,n=(d=this.aceCommands).length;o<n;o++)e=d[o],null!=(h=this.ace)&&h.commands.removeCommand(e);return null!=(p=this.ace)&&p.destroy(),null!=(g=this.aceDoc)&&g.off("change",this.onCodeChangeMetaHandler),null!=(v=this.aceSession)&&v.selection.off("changeCursor",this.onCursorActivity),this.destroyAceEditor(this.ace),this.destroyAceEditor(this.aceSolution),null!=(m=this.debugView)&&m.destroy(),null!=(s=this.translationView)&&s.destroy(),null!=(r=this.toolbarView)&&r.destroy(),null!=this.editorLang&&null!=(a=this.autocomplete)&&a.addSnippets([],this.editorLang),A(window).off("resize",this.onWindowResize),null!=this.spade&&this.spade.createUIEvent("destroying-view"),this.saveSpade(),window.clearTimeout(this.saveSpadeTimeout),this.saveSpadeTimeout=null,null!=(l=this.autocomplete)&&l.destroy(),t.__super__.destroy.call(this)},t}(l)},778431:(e,t,o)=>{var n,i,s,r,a,l,c,u,d,h=o(619755),p={}.hasOwnProperty,g=[].indexOf||function(e){for(var t=0,o=this.length;t<o;t++)if(t in this&&this[t]===e)return t;return-1};o(118530),i=o(968029),u=o(612704),l=o(28045).me,s=o(589815),r=o(831036),n=o(618729),d=o(299498),c=o(196363),a=o(504015),e.exports=function(e){function t(e){var o;t.__super__.constructor.call(this,e),this.determineCodeFormat(),this.unwatchFn=c.watch((function(e,t){return t["game/levelSolution"]}),(o=this,function(e){if(null!=e?e.source:void 0)return o.onChangeMyCode(e.source)})),e.god||"web-dev"===e.level.get("type")||console.error("TomeView created with no God!")}return function(e,t){for(var o in t)p.call(t,o)&&(e[o]=t[o]);function n(){this.constructor=e}n.prototype=t.prototype,e.prototype=new n,e.__super__=t.prototype}(t,e),t.prototype.id="tome-view",t.prototype.template=u,t.prototype.controlsEnabled=!0,t.prototype.cache=!1,t.prototype.subscriptions={"tome:spell-loaded":"onSpellLoaded","tome:cast-spell":"onCastSpell","tome:change-language":"updateLanguageForAllSpells","surface:sprite-selected":"onSpriteSelected","god:new-world-created":"onNewWorld","tome:comment-my-code":"onCommentMyCode","tome:reset-my-code":"onResetMyCode","tome:select-primary-sprite":"onSelectPrimarySprite","tome:toggle-blocks":"onToggleBlocks"},t.prototype.events={click:"onClick"},t.prototype.afterRender=function(){var e,o,i,s;return t.__super__.afterRender.call(this),this.worker=this.createWorker(),e=_.filter(this.options.thangs,(function(e){return e.isProgrammable&&e.programmableMethods})),this.options.level.isType("web-dev")&&(this.fakeProgrammableThang=this.createFakeProgrammableThang())&&(e=[this.fakeProgrammableThang]),this.createSpells(e,null!=(o=e[0])?o.world:void 0),this.castButton=this.insertSubView(new n({spells:this.spells,level:this.options.level,session:this.options.session,god:this.options.god})),this.teamSpellMap=this.generateTeamSpellMap(this.spells),e.length||(this.cast(),s="Warning: There are no Programmable Thangs in this level, which makes it unplayable.",noty({text:s,layout:"topCenter",type:"warning",killer:!1,timeout:15e3,dismissQueue:!0,maxVisible:3}),console.warn(s)),delete this.options.thangs,this.$el.toggleClass("blocks",Boolean(this.blocks)),null!=(i=this.options.playLevelView)?i.$el.toggleClass("blocks",Boolean(this.blocks)):void 0},t.prototype.onNewWorld=function(e){var t;return t=_.filter(e.thangs,(function(e){return e.isProgrammable&&e.programmableMethods&&e.inThangList})),this.createSpells(t,e.world)},t.prototype.onCommentMyCode=function(e){var t,o,n,i,s;for(i in o=this.spells)(n=o[i]).canWrite()&&(console.log("Commenting out",i),t=n.view.commentOutMyCode()+"Commented out to stop infinite loop.\n"+n.getSource(),n.view.updateACEText(t),n.view.recompile(!1),n.view.aceToBlockly());return _.delay((s=this,function(){return"function"==typeof s.cast?s.cast():void 0}),1e3)},t.prototype.onResetMyCode=function(e){var t,o,n,i;for(n in t=this.spells)(o=t[n]).canWrite()&&(o.view.updateACEText(o.originalSource),o.view.recompile(!1),o.view.aceToBlockly());return _.delay((i=this,function(){return"function"==typeof i.cast?i.cast():void 0}),1e3)},t.prototype.onChangeMyCode=function(e){var t,o,n,i;for(i in o=[],t=this.spells)(n=t[i]).canWrite()&&(n.view.updateACEText(e),n.view.recompile(!1),o.push(n.view.aceToBlockly()));return o},t.prototype.createWorker=function(){return"undefined"==typeof Worker||null===Worker||a.application.isIPadApp?null:new Worker("/javascripts/workers/aether_worker.js")},t.prototype.determineCodeFormat=function(){var e,t,o,n,i,s,r,a,c,u,h,p,v;if(s=null!=(a=null!=(c=this.options.session.get("codeLanguage"))?c:null!=(u=l.get("aceConfig"))?u.language:void 0)?a:"python",this.options.level.isType("web-dev","game-dev")||"python"!==s&&"javascript"!==s&&"lua"!==s||"codecombat-junior"!==this.options.level.get("product")?r="text-code":(t=(null!=(h=this.options.classroomAceConfig)?h.codeFormatDefault:void 0)||"text-code",o=(null!=(p=this.options.classroomAceConfig)?p.codeFormats:void 0)||["blocks-icons","blocks-text","blocks-and-code","text-code"],i=null!=(v=l.get("aceConfig"))?v.codeFormat:void 0,"codecombat-junior"===this.options.level.get("product")&&null==i&&(i="blocks-icons"),null==i&&(i=t),r=g.call(o,i)>=0?i:t),null!=(n=d.getQueryVariable("codeFormat"))&&(r=n),r!==this.codeFormat)return this.blocks=/block/.test(r),this.blocksHidden=!_.intersection(o,["blocks-icons","blocks-text","blocks-and-code"]).length,e={codeFormat:r},this.codeFormat&&(e.oldCodeFormat=this.codeFormat),this.codeFormat=r,Backbone.Mediator.publish("tome:code-format-changed",e),this.codeFormat},t.prototype.generateTeamSpellMap=function(e){var t,o,n,i,s;for(t in i={},e)null==i[n=e[t].team]&&(i[n]=[]),s=(o=t.split("/"))[0],t=o[1],g.call(i[n],s)<0&&i[n].push(s);return i},t.prototype.createSpells=function(e,t){var o,n,i,r,a,c,u,h,p,g,v,m,f,y,b,w,k,S,C,x,T,P,L;for(this.options.spectateView&&(r=this.options.session.get("submittedCodeLanguage")),null==r&&(r=this.options.session.get("codeLanguage")),null==r&&(r=null!=(m=l.get("aceConfig"))?m.language:void 0),null==r&&(r="python"),this.determineCodeFormat(),v=["play","level",this.options.levelID,this.options.session.id,"code"],null==this.spells&&(this.spells={}),null==this.thangSpells&&(this.thangSpells={}),o=0,a=e.length;o<a;o++)if(P=e[o],null==this.thangSpells[P.id])for(p in this.thangSpells[P.id]=[],f=P.programmableMethods)h=f[p],(g=[P.id,p])[0]=_.string.slugify(g[0]),x=g.join("/"),this.thangSpells[P.id].push(x),S=d.getQueryVariable("skip_protect_api",!1),C=this.spells[x]=new s({hintsState:this.options.hintsState,programmableMethod:h,spellKey:x,pathComponents:v.concat(g),session:this.options.session,otherSession:this.options.otherSession,supermodel:this.supermodel,skipProtectAPI:S,worker:this.worker,language:r,spectateView:this.options.spectateView,observing:this.options.observing,levelID:this.options.levelID,level:this.options.level,god:this.options.god,courseID:this.options.courseID,courseInstanceID:this.options.courseInstanceID,classroomAceConfig:this.options.classroomAceConfig,blocks:this.blocks,blocksHidden:this.blocksHidden,c
1odeFormat:this.codeFormat,teacherID:this.options.teacherID});for(L in y=this.thangSpells)if(T=y[L],P=null!=(b=this.fakeProgrammableThang)?b:t.getThangByID(L))for(n=0,c=T.length;n<c;n++)x=T[n],this.spells[x].addThang(P);else for(delete this.thangSpells[L],i=0,u=(w=this.spells).length;i<u;i++)(C=w[i]).removeThangID(L);for(x in k=this.spells)(C=k[x]).canRead()||(C.transpile(),C.loaded=!0);return null},t.prototype.onSpellLoaded=function(e){var t,o,n;for(n in o=this.spells)if(!o[n].loaded)return;return t=this.options.level.isType("game-dev"),this.cast(!1,!1,t)},t.prototype.onCastSpell=function(e){return this.cast(null!=e?e.preload:void 0,null!=e?e.realTime:void 0,null!=e?e.justBegin:void 0,null!=e?e.cinematic:void 0)},t.prototype.cast=function(e,t,o,n){var i,s,r,a,l,c,u,d,h,p,g,v;if(null==e&&(e=!1),null==t&&(t=!1),null==o&&(o=!1),null==n&&(n=!1),!this.options.level.isType("web-dev"))return g=null!=(r=this.options.session.get("state"))?r:{},t&&(g.submissionCount=(null!=(a=g.submissionCount)?a:0)+1,g.flagHistory=_.filter(null!=(l=g.flagHistory)?l:[],(v=this,function(e){var t;return e.team!==(null!=(t=v.options.session.get("team"))?t:"humans")})),this.options.level.get("replayable")&&(g.lastUnsuccessfulSubmissionTime=new Date),this.options.session.set("state",g)),i=null!=(c=g.difficulty)?c:0,this.options.observing&&(i=Math.max(0,i-1)),Backbone.Mediator.publish("level:set-playing",{playing:!1}),s=null!=(u=this.spells["hero-placeholder/plan"])?u.source:void 0,Backbone.Mediator.publish("tome:cast-spells",{spells:this.spells,preload:e,realTime:t,synchronous:this.options.level.isType("game-dev")&&!o,justBegin:o,cinematic:n,difficulty:i,submissionCount:null!=(d=g.submissionCount)?d:0,flagHistory:null!=(h=g.flagHistory)?h:[],god:this.options.god,fixedSeed:this.options.fixedSeed,keyValueDb:null!=(p=this.options.session.get("keyValueDb"))?p:{},spellsAreUnchanged:_.isEqual(s,this.lastCastSpellCode)}),this.lastCastSpellCode=s,null},t.prototype.onClick=function(e){if(!h(e.target).parents(".popover").length)return Backbone.Mediator.publish("tome:focus-editor",{})},t.prototype.onSpriteSelected=function(e){var t,o;if(!this.spellView||"hero"!==(t=this.options.level.get("type",!0))&&"hero-ladder"!==t&&"hero-coop"!==t&&"course"!==t&&"course-ladder"!==t&&"game-dev"!==t&&"web-dev"!==t&&"ladder"!==t)return(null!=(o=this.spellFor(e.thang,e.spellName))?o.canRead():void 0)?this.setSpellView(o,e.thang):void 0},t.prototype.setSpellView=function(e,t){var o,n;return e.view!==this.spellView&&(this.spellView=e.view,this.spellTopBarView=e.topBarView,this.$el.find("#"+this.spellView.id).after(this.spellView.el).remove(),this.$el.find("#"+this.spellTopBarView.id).after(this.spellTopBarView.el).remove(),null!=(o=this.castButton)&&o.attachTo(this.spellView)),this.updateSpellPalette
1(t,e),null!=(n=this.spellView)?n.setThang(t):void 0},t.prototype.updateSpellPalette=function(e,t){var o,n;if(this.$("#spell-palette-view").toggleClass("hidden",!1),this.spellPaletteView&&!(null!=(o=this.spellPaletteView)?o.destroyed:void 0)&&this.removeSubView(this.spellPaletteView),this.spellPaletteView=this.insertSubView(new r({thang:e,supermodel:this.supermodel,programmable:null!=t?t.canRead():void 0,language:null!=(n=null!=t?t.language:void 0)?n:this.options.session.get("codeLanguage"),session:this.options.session,level:this.options.level,courseID:this.options.courseID,courseInstanceID:this.options.courseInstanceID})),null!=t?t.view:void 0)return this.spellPaletteView.toggleControls({},t.view.controlsEnabled)},t.prototype.spellFor=function(e,t){var o,n,i;return(null!=e?e.isProgrammable:void 0)?this.thangSpells[e.id]?(o=function(){var t,o,n,s;for(s=[],t=0,o=(n=this.thangSpells[e.id]).length;t<o;t++)i=n[t],s.push(this.spells[i]);return s}.call(this),t?n=_.find(o,{name:t}):null==(n=_.find(o,(function(e){return e.canWrite()})))&&(n=_.find(o,(function(e){return e.canRead()}))),n):void 0:null},t.prototype.reloadAllCode=function(){var e,t,o,n,i;for(n in d.getQueryVariable("dev")&&this.spellView&&this.updateSpellPalette
1(this.spellView.thang,this.spellView.spell),e=this.spells)!(o=e[n]).view||o.team!==l.team&&"common"!==(t=o.team)&&"neutral"!==t&&null!==t||o.view.reloadCode(!1);return _.defer((i=this,function(){if(!i.destroyed)return i.cast(!1,!1)}))},t.prototype.updateLanguageForAllSpells=function(e){var t,o,n;for(n in t=this.spells)(o=t[n]).canWrite()&&o.updateLanguageAether(e.language);return e.reload?this.reloadAllCode():this.cast()},t.prototype.onSelectPrimarySprite=function(e){if(!this.options.level.isType("web-dev"))return"ogres"===this.options.session.get("team")?Backbone.Mediator.publish("level:select-sprite",{thangID:"Hero Placeholder 1"}):Backbone.Mediator.publish("level:select-sprite",{thangID:"Hero Placeholder"});this.setSpellView(this.spells["hero-placeholder/plan"],this.fakeProgrammableThang)},t.prototype.onToggleBlocks=function(e){var t,o,n;if(Boolean(this.blocks)!==Boolean(e.blocks))return this.blocks=Boolean(e.blocks),this.$el.toggleClass("blocks",this.blocks),null!=(o=this.options.playLevelView)&&o.$el.toggleClass("blocks",this.blocks),h(window).trigger("resize"),(t=null!=(n=l.get("aceConfig"))?n:{}).blocks!==this.blocks?(t.blocks=this.blocks,l.set("aceConfig",t),l.save()):void 0},t.prototype.createFakeProgrammableThang=function(){var e,t,o,n,i,s,r,a;return(e=_.find(this.options.level.get("thangs"),{id:"Hero Placeholder"}))&&(t=_.find(e.components,(function(e){var t;return null!=(t=e.config)?t.programmableMethods:void 0})).config)?(s=_.find(e.components,(function(e){var t;return null!=(t=e.config)?t.programmableHTMLProperties:void 0})).config,a=null!=(o=_.find(e.components,(function(e){var t;return null!=(t=e.config)?t.programmableWebJavaScriptProperties:void 0})))?o.config:void 0,r=null!=(n=_.find(e.components,(function(e){var t;return null!=(t=e.config)?t.programmableJQueryProperties:void 0})))?n.config:void 0,s||console.warn("Couldn't find usesHTML config; is it presented and not defaulted on the Hero Placeholder?"),i={id:"Hero Placeholder",isProgrammable:!0},i=_.merge(i,t,s,a,r)):null},t.prototype.destroy=function(){var e,o,n;for(n in e=this.spells)e[n].destroy();return null!=(o=this.worker)&&o.terminate(),this.unwatchFn(),t.__super__.destroy.call(this)},t}(i)},243878:(e,t,o)=>{var n,i,s,r,a,l,c=[].indexOf||function(e){for(var t=0,o=this.length;t<o;t++)if(t in this&&this[t]===e)return t;return-1};i=o(74536).default,l=o(299498),r=o(579483),n=o(994587),o(523402),o(444705),s=_.invert(r.heroes),a=o(482156),e.exports=Vue.extend({props:["nextLevel","nextAssessment","session","course","courseInstanceID","stats","supermodel","parent","codeLanguage"],components:{PieChart:i},computed:{challengeLink:function(){var e;return me.isSessionless()?e="/play/level/"+this.nextAssessment.slug+"?course="+this.course._id+"&codeLanguage="+l.getQueryVariable("codeLanguage","python"):(e="/play/level/"+this.nextAssessment.slug+"?course="+this.course._id+"&course-instance="+this.courseInstanceID,this.level.primerLanguage&&(e+="&codeLanguage="+this.level.primerLanguage)),e},mapLink:function(){return me.isSessionless()?l.sessionlessCoursesUrl(this.level.product):"/play/"+this.course.campaignID+"?course-instance="+this.courseInstanceID},nextLevelLink:function(){var e;if(!me.showHeroAndInventoryModalsToStudents())return me.isSessionless()?e="/play/level/"+this.nextLevel.slug+"?course="+this.course._id+"&codeLanguage="+l.getQueryVariable("codeLanguage","python"):(e="/play/level/"+this.nextLevel.slug+"?course="+this.course._id+"&course-instance="+this.courseInstanceID,this.level.primerLanguage&&(e+="&codeLanguage="+this.level.primerLanguage)),e},nextLevelVideoLink:function(){var e;return e="/play/video/level/"+this.nextLevel.slug+"?course="+this.course._id+"&course-instance="+this.courseInstanceID,this.level.primerLanguage&&(e+="&codeLanguage="+this.level.primerLanguage),e+"&level="+this.nextLevel.original},nextLevelLinkClasses:function(){return this.assessmentNext?{"btn-default":!0}:{"btn-success":!0,"btn-glow":!0}},headerImage:function(){return this.course._id===l.courseIDs.COCO_JUNIOR?"/images/pages/play/modal/level_complete.png":this.level.assessment?"/images/pages/play/modal/challenge_complete.png":this.assessmentNext?"/images/pages/play/modal/challenge_unlocked.png":"/images/pages/play/modal/level_complete.png"},assessmentNext:function(){return this.nextAssessment._id},primaryConcept:function(){var e;return(e=_.first(this.level.primaryConcepts))?this.$t("concepts."+e):e},conceptGoals:function(){return this.level.goals.filter((function(e){var t;return null!=(t=e.concepts)?t.length:void 0}))},conceptGoalsCompleted:function(){return this.conceptGoals.filter((e=this,function(t){return"success"===e.session.state.goalStates[t.id].status})).length;var e},percentConceptsCompleted:function(){return 100*this.conceptGoalsCompleted/this.conceptGoals.length},allConceptsUsed:function(){return this.conceptGoalsCompleted===this.conceptGoals.length},level:function(){return this.$store.state.game.level},heroImage:function(){var e,t,o,n;return(null!=(o=this.$store.state.me.heroConfig)?o.thangType:void 0)?null==(n=s[this.$store.state.me.heroConfig.thangType])?
1"/images/pages/play/modal/captain.png":((t=_.invert(r.juniorHeroReplacements)[n])&&(n=t),e=["stalwart","samurai","raider","guardian","goliath","duelist","champion","captain","knight"],c.call(e,n)>=0?"/images/pages/play/modal/"+n+".png":"/images/pages/play/modal/captain.png")
1:"/images/pages/play/modal/captain.png"},comboImage:function(){return this.allConceptsUsed?"/images/pages/play/modal/combo_complete.png":"/images/pages/play/modal/combo_incomplete.png"},nextLevelVideo:function(){if(me.isStudent()&&this.course._id===l.courseIDs.INTRODUCTION_TO_COMPUTER_SCIENCE&&!me.showHeroAndInventoryModalsToStudents())return l.videoLevels[this.nextLevel.original]},inExam:function(){return 0!==a.levelNumberInExam(this.level.slug)}},methods:{marked,onReturnExam:function(){return window.close()},onStartChallenge:function(){var e;return null!=(e=window.tracker)?e.trackEvent("Play Level Victory Modal Start Challenge",{category:"Students",levelSlug:this.level.slug,nextAssessmentSlug:this.nextAssessment.slug},[]):void 0},onBackToMap:function(){var e;return null!=(e=window.tracker)?e.trackEvent("Play Level Victory Modal Back to Map",{category:"Students",levelSlug:this.level.slug},[]):void 0},onNextLevelVideo:function(){var e;return null!=(e=window.tracker)?e.trackEvent("Play Level Victory Modal Next Level Video",{category:"Students",levelSlug:this.level.slug,nextLevelSlug:this.nextLevel.slug,nextLevelVideoTitle:this.nextLevelVideo.title},[]):void 0},onNextLevel:function(){var e,t,o;if(null!=(e=window.tracker)&&e.trackEvent("Play Level Victory Modal Next Level",{category:"Students",levelSlug:this.level.slug,nextLevelSlug:this.nextLevel.slug},[]),me.showHeroAndInventoryModalsToStudents()&&(null!=(t=this.setupManager)&&t.destroy(),this.setupManager=new n({supermodel:this.supermodel,levelID:this.nextLevel.slug,levelPath:"level",hadEverChosenHero:!0,parent:this.parent,courseID:this.course._id,courseInstanceID:this.courseInstanceID,codeLanguage:this.codeLanguage}),!(null!=(o=this.setupManager)?o.navigatingToPlay:void 0)))return this.setupManager.open()},onReplayLevel:function(){var e;return null!=(e=window.tracker)&&e.trackEvent("Play Level Victory Modal Replay",{category:"Students",levelSlug:this.level.slug,nextLevelSlug:this.nextLevel.slug},[]),document.location.reload()}}})},23280:()=>{},323050:()=>{},279763:()=>{},566103:()=>{},963472:()=>{},48057:()=>{},863152:()=>{},392191:()=>{},408512:()=>{},210136:()=>{},993920:()=>{},953785:()=>{},960816:()=>{},180299:()=>{},648625:()=>{},877705:()=>{},638032:()=>{},853238:()=>{},841418:()=>{},62784:()=>{},479522:()=>{},15920:(e,t,o)=>{o(477055),e.exports=function(e){return""+'<div><page-errors v-if="errors.length"></page-errors><slot v-else></slot></div>'}},110637:(e,t,o)=>{var n=o(477055);e.exports=function(e){var t,o="",i=e||{};return function(e,i,s){o=o+'\x3c!-- TODO: this is the same as app/templates/core/loading-error.pug, but Vue-ified; can we merge them?--\x3e<div class="text-center" id="loading-error"><div v-if="error.stack"><h1>{{ $t("loading_error.unknown") }}</h1></div><div v-else-if="error.code === 401"><h1><span class="spr">401:</span><span>{{ $t("loading_error.login_required") }}</span></h1><p>{{ $t("loading_error.login_required_desc") }}</p><button class="login-btn btn btn-primary">{{ $t("login.log_in") }}</button><button class="btn btn-primary" id="create-account-btn">{{ $t("login.sign_up") }}</button></div>\x3c!-- 402 currently not in use. TODO: Set it up--\x3e<div v-else-if="error.code === 402"><h2>402: Payment Required</h2></div><div v-else-if="error.code === 403"><h1><span class="spr">403:</span><span>{{ $t("loading_error.forbidden") }}</span></h1><p>{{ $t("loading_error.forbidden_desc") }}</p>\x3c!-- this should make no diff... but sometimes the server returns 403 when it should return 401--\x3e<button class="btn btn-primary" id="logout-btn" v-if="isAnonymous">{{ $t("login.log_out") }}</button></div><div v-else-if="error.code === 404"><h1><span class="spr">404:</span><span>{{ $t(\'loading_error.not_found\') }}</span></h1><p>{{ $t("loading_error.not_found_desc") }}</p></div><div v-else-if="!error.code"><h1>{{ $t("loading_error.connection_failure") }}</h1><p>{{ $t("loading_error.connection_failure_desc") }}</p></div><div v-else-if="error.code === 408"><h1><span class="spr">408:</span><span>{{ $t("loading_error.timeout") }}</span></h1></div><div v-else-if="error.code &gt;= 500 &amp;&amp; error.code &lt;= 599"><h1><span class="spr">{{error.code}}</span><span>{{ $t("loading_error.server_error") }}</span></h1></div><div v-else><h1>{{ $t("loading_error.unknown") }}</h1><p>{{ $t("loading_error.general_desc") }}</p></div><p><a href="/">{{ $t("nav.home") }}</a><span>
1'+n.escape(null==(t=" | ")?"":t)+'</span><a href="/about">{{ $t("nav.about") }}</a>',i.china||(o=o+"<span>"+n.escape(null==(t=" | ")?"":t)+'</span><a href="https://codecombat.zendesk.com/hc/en-us" target="_blank">{{ $t("contact.faq") }}</a>'),s.isStudent()||(o=o+"<span>"+n.escape(null==(t=" | ")?"":t)+'</span><a class="contact-modal">{{ $t("nav.contact") }}</a>'),o+="</p>";var r=e.floor(3*e.random())+1;o=o+'<img id="not-found-img"'+n.attr("src","/images/pages/not_found/404_"+r+".png",!0,!0)+"></div>"}.call(this,"Math"in i?i.Math:"undefined"!=typeof Math?Math:void 0,"features"in i?i.features:"undefined"!=typeof features?features:void 0,"me"in i?i.me:"undefined"!=typeof me?me:void 0),o}},346741:(e,t,o)=>{var n=o(477055);e.exports=function(e){var t,o="",i=e||{};return function(e){o=o+'<button class="close-hint-btn btn btn-illustrated btn-danger"><span class="glyphicon glyphicon-remove"></span></button><h1 class="text-center hint-title" dir="auto"><span dir="auto">'+n.escape(null==(t=e.getHintTitle())?"":t)+'</span></h1><div class="row btn-area"><div class="col-md-4">',e.state.get("hintIndex")>0&&(o+='<button class="previous-btn btn btn-illustrated pull-left" data-i18n="about.previous"></button>'),o=o+'</div><div class="col-md-4"><h2 class="text-center hint-pagination">'+n.escape(null==(t=e.state.get("hintIndex")+1)?"":t)+" / "+n.escape(null==(t=e.hintsState.get("total"))?"":t)+'</h2></div><div class="col-md-4">',e.state.get("hintIndex")<e.hintsState.get("total")-1&&(o+='<button class="next-btn btn btn-illustrated pull-right" data-i18n="play.next"></button>'),o=o+'</div></div><div class="hint-body" dir="auto">'+(null==(t=e.getProcessedHint())?"":t)+"</div>",e.showAiBotHelp&&(o+='<div class="chatbot-help"><img class="avatar" src="/images/level/baby-griffin.png" alt="AI"><span data-i18n="play.want_more_hints"></span><button class="btn btn-illustrated btn-primary ai-help-button" data-i18n="play_level.problem_alert_ask_the_ai"></button>',e.creditMessage&&(o=o+'<img class="chatbot-hint" src="/images/ozaria/teachers/dashboard/svg_icons/IconHint.svg" alt="Hint" data-container="body" data-toggle="popover" data-placement="right"'+n.attr("data-content",e.creditMessage,!0,!0)+">"),o+="</div>"),o+='<div class="clearfix"></div>'}.call(this,"view"in i?i.view:"undefined"!=typeof view?view:void 0),o}},631510:(e,t,o)=>{o(477055),e.exports=function(e){return""+'<div class="wood-background"></div><div class="hinge hinge-0"></div><div class="hinge hinge-1"></div><div class="hinge hinge-2"></div><div class="hinge hinge-3"></div><div class="avatar-wrapper-container"><div class="thang-canvas-wrapper thang-elem hide"><canvas class="thang-canvas"></canvas></div></div><div class="center"><div class="thang-name"></div><div class="thang-props thang-elem"></div></div>'}},966872:(e,t,o)=>{var n=o(477055);e.exports=function(e){var t,o="",i=e||{};return function(e,i,s){o=o+'<div class="prop"'+n.attr("name",s,!0,!0)+">",o=i?o+"<span"+n.attr("class",n.classes([`prop-label prop-label-icon prop-label-icon-${s}`],[!0]),!1,!0)+"></span>":o+'<span class="prop-label">'+n.escape(null==(t=s)?"":t)+":</span>",o+=e?'<span class="prop-value bar-prop"><div class="bar"></div></span><span class="prop-value bar-prop-value"></span>':'<span class="prop-value"></span>',o+="</div>"}.call(this,"hasBar"in i?i.hasBar:"undefined"!=typeof hasBar?hasBar:void 0,"hasIcon"in i?i.hasIcon:"undefined"!=typeof hasIcon?hasIcon:void 0,"prop"in i?i.prop:"undefined"!=typeof prop?prop:void 0),o}},652476:(e,t,o)=>{o(477055),e.exports=function(e){return""+'<div class="dialogue-area"><p class="bubble dialogue-bubble" dir="auto"></p></div>'}},643724:(e,t,o)=>{var n=o(477055);e.exports=function(e){var t,o="",i=e||{};return function(e){o+="\x3c!-- this allows the extended templates to add class to .modal-dialog--\x3e";let i=e.utils&&e.utils.isOzaria;o=o+"<div"+n.attr("class",n.classes(["modal-dialog",""],[!1,!0]),!1,!0)+"><div"+n.attr("class",n.classes(["modal-content","style-flat",i?"style-ozaria":""],[!1,!1,!0]),!1,!0)+' id="modal-base-flat"><div class="modal-header">',e.closeButton&&(o+='<div class="button close" type="button" data-dismiss="modal" aria-hidden="true">&times;</div>'),o=o+'<h3 class="text-center">
1'+n.escape(null==(t=e.getVictoryMessage())?"":t)+'</h3></div><div class="modal-body"><div class="text-center">Share this level so your friends and family can play it:</div><div class="share-row text-center"><input class="text-h4 semibold form-control input-lg" id="copy-url-input"'+n.attr("value",e.shareURL,!0,!0)+'><button class="btn btn-lg btn-navy-alt" id="copy-url-btn"><span data-i18n="sharing.copy_url"></span></button></div></div><div class="modal-body wait secret"><h3>Loading...</h3><div class="progress progress-striped active"><div class="progress-bar"></div></div></div><div class="modal-footer"><div class="text-center"><button class="btn btn-navy btn-lg" id="replay-game-btn" data-dismiss="modal">Replay Game</button><a class="btn btn-navy btn-lg" id="play-more-codecombat-btn" href="/">Play More CodeCombat</a></div></div></div></div>'}.call(this,"view"in i?i.view:"undefined"!=typeof view?view:void 0),o}},29432:(e,t,o)=>{var n=o(477055);e.exports=function(e){var t="",o=e||{};return function(e,o){t+='<div class="modal-dialog game"><div class="background-wrapper"><div class="modal-content"><div class="modal-header">',o.closeButton&&(t+='<div class="button close" type="button" data-dismiss="modal" aria-hidden="true">&times;</div>'),o.options.nonUserCodeProblem?t+='<h3 data-i18n="play_level.non_user_code_problem_title">Unable to Load Level</h3>':t+='<h3 data-i18n="play_level.infinite_loop_title">Infinite Loop Detected</h3>',t+='</div><div class="modal-body"><div class="modal-body">',o.options.nonUserCodeProblem?t=t+'<p data-i18n="[html]play_level.non_user_code_problem_description"'+n.attr("data-i18n-options",e.stringify({error:o.options.problem&&o.options.problem.message||""}),!0,!0)+"></p>":t+='<p data-i18n="play_level.infinite_loop_description"></p>',t+='<p><span class="spr" data-i18n="play_level.check_dev_console">You can also open the developer console to see what might be going wrong.</span><a href="http://webmasters.stackexchange.com/questions/8525/how-to-open-the-javascript-console-in-different-browsers/77337#77337" data-i18n="play_level.check_dev_console_link" target="_blank">(instructions)</a></p></div></div><div class="modal-body wait secret"><h3>Reticulating Splines...</h3><div class="progress progress-striped active"><div class="progress-bar"></div></div></div><div class="modal-footer"><a class="btn" href="#" data-dismiss="modal" aria-hidden="true" data-i18n="play_level.infinite_loop_try_again" id="restart-level-infinite-loop-retry-button">Try Again</a><a class="btn btn-danger" href="#" data-dismiss="modal" aria-hidden="true" data-i18n="play_level.infinite_loop_reset_level" id="restart-level-infinite-loop-confirm-button">Reset Level</a><a class="btn btn-primary" href="#" data-dismiss="modal" aria-hidden="true" data-i18n="play_level.infinite_loop_comment_out" id="restart-level-infinite-loop-comment-button">Comment Out My Code</a></div></div></div></div>'}.call(this,"JSON"in o?o.JSON:"undefined"!=typeof JSON?JSON:void 0,"view"in o?o.view:"undefined"!=typeof view?view:void 0),t}},545808:(e,t,o)=>{var n=o(477055);e.exports=function(e){var t,o="",i={},s=e||{};return function(e){var s=!(e.state.get("errorMessage")||e.state.get("loading"));if(i["game-dev-goals"]=t=function(e){this&&this.block,this&&this.attributes,o+='<ul class="goals">';var i=!1;(function(){var s=e;if("number"==typeof s.length)for(var r=0,a=s.length;r<a;r++)"manual"==(l=s[r]).type?o=o+'<li class="goal">'+n.escape(null==(t=l.config.description)?"":t)+"</li>":"survive"==l.type?l.config.seconds?o=o+'<li class="goal" data-i18n="play_game_dev_level.goal_survive_time"'+n.attr("data-i18n-options",{seconds:l.config.seconds},!0,!0)+"></li>":o+='<li class="goal" data-i18n="play_game_dev_level.goal_survive"></li>':"defeat"==l.type?l.config.amount?o=o+'<li class="goal" data-i18n="play_game_dev_level.goal_defeat_amount"'+n.attr("data-i18n-options",{amount:l.config.amount},!0,!0)+"></li>":o+='<li class="goal" data-i18n="play_game_dev_level.goal_defeat"></li>':"move"!=l.type||i?"collect"==l.type?l.config.amount?o=o+'<li class="goal" data-i18n="play_game_dev_level.goal_collect_amount"'+n.attr("data-i18n-options",{amount:l.config.amount},!0,!0)+"></li>":o+='<li class="goal" data-i18n="play_game_dev_level.goal_collect"></li>':"user_defined"==l.type&&(o=o+'<li class="goal">'+n.escape(null==(t=l.direction)?"":t)+"</li>"):(o+='<li class="goal" data-i18n="play_game_dev_level.goal_move"></li>',i=!0);else for(var r in a=0,s){var l;a++,"manual"==(l=s[r]).type?o=o+'<li class="goal">'+n.escape(null==(t=l.config.description)?"":t)+"</li>":"survive"==l.type?l.config.seconds?o=o+'<li class="goal" data-i18n="play_game_dev_level.goal_survive_time"'+n.attr("data-i18n-options",{seconds:l.config.seconds},!0,!0)+"></li>":o+='<li class="goal" data-i18n="play_game_dev_level.goal_survive"></li>':"defeat"==l.type?l.config.amount?o=o+'<li class="goal" data-i18n="play_game_dev_level.goal_defeat_amount"'+n.attr("data-i18n-options",{amount:l.config.amount},!0,!0)+"></li>":o+='<li class="goal" data-i18n="play_game_dev_level.goal_defeat"></li>':"move"!=l.type||i?"collect"==l.type?l.config.amount?o=o+'<li class="goal" data-i18n="play_game_dev_level.goal_collect_amount"'+n.attr("data-i18n-options",{amount:l.config.amount},!0,!0)+"></li>":o+='<li class="goal" data-i18n="play_game_dev_level.goal_collect"></li>':"user_defined"==l.type&&(o=o+'<li class="goal">'+n.escape(null==(t=l.direction)?"":t)+"</li>"):(o+='<li class="goal" data-i18n="play_game_dev_level.goal_move"></li>',i=!0)}}).call(this),o+="</ul>"},o+='<div class="container-fluid style-flat"><div class="row" id="game-row"><div class="col-xs-9"><div id="canvas-wrapper"><div id="game-dev-track-view"></div><canvas width="924" height="589" id="webgl-surface"></canvas><canvas width="924" height="589" id="normal-surface"></canvas></div></div><div class="col-xs-3" id="info-col"><div class="panel panel-default"><div class="panel-body text-center" id="directions">',e.state.get("errorMessage")&&(o=o+'<div class="alert alert-danger">'+n.escape(null==(t=e.state.get("errorMessage"))?"":t)+"</div>"),e.level.id&&e.session.id&&(o=o+'<h3 class="m-y-1">'+n.escape(null==(t=e.getLevelName())?"":t)+"</h3><h4>"+n.escape(null==(t=e.state.get("creatorString"))?"":t)+"</h4><hr>"),e.state.get("loading")&&(o=o+'<h1 class="m-y-1" data-i18n="common.loading"></h1><div class="progress"><div class="progress-bar"'+n.attr("style",n.style(`width: ${e.state.get("progress")}`),!0,!0)+"></div></div>"),s&&(o+='<h3><span data-i18n="play_level.directions"></span>:</h3>',e.studentGoals&&e.studentGoals.length?i["game-dev-goals"](e.studentGoals):o=o+"<p>"+(null==(t=e.howToPlayText)?"":t)+"</p>",o+="<hr>"),o+="</div>",s){o+='<div class="panel-footer">';var r=e.state.get("playing");o+=r?'<button class="btn btn-lg btn-burgundy btn-block" id="play-btn" data-i18n="play_game_dev_level.restart"></button>':'<button class="btn btn-lg btn-forest btn-block" id="play-btn" data-i18n="play_game_dev_level.play"></button>',e.state.get("isOwner")&&(o+='<br><button class="btn btn-lg btn-warning btn-block" id="edit-level-btn" data-i18n="play_level.edit_level"></button>'),o+="</div>"}o+='</div></div></div><div class="m-t-3" id="share-row">',s&&(o=o+'<div class="panel panel-default"><div class="panel-body" id="share-panel-body"><div class="text-right" id="share-text-div"><b data-i18n="sharing.share_game"></b></div><input class="text-h4 semibold form-control input-lg" id="copy-url-input"'+n.attr("value",e.state.get("shareURL"),!0,!0)+'><div id="copy-url-div"><button class="btn btn-lg btn-navy-alt" id="copy-url-btn"><span data-i18n="sharing.copy_url"></span></button></div></div>',e.state.get("isOwner")||(o+='<div class="panel-body"><a class="btn btn-lg btn-navy-alt pull-right" id="play-more-codecombat-btn" href="/" data-i18n="play_game_dev_level.play_more_codecombat"></a></div>'),o+="</div>"),o+="</div></div>"}
1.call(this,"view"in s?s.view:"undefined"!=typeof view?view:void 0),o}},46347:(e,t,o)=>{var n=o(477055);e.exports=function(e){var t,o="",i=e||{};return function(e){o+='<div id="web-surface-view"></div><div class="style-flat" id="info-bar">',e.supermodel.finished()?o=o+'<h1><span data-i18n="game_dev.creator"></span><span>'+n.escape(null==(t=": ")?"":t)+"</span>"+n.escape(null==(t=e.session.get("creatorName"))?"":t)+"</h1>":o+='<h1 data-i18n="common.loading"></h1>',o+="</div>"}.call(this,"view"in i?i.view:"undefined"!=typeof view?view:void 0),o}},591435:(e,t,o)=>{var n=o(477055);e.exports=function(e){var t="",o=e||{};return function(e,o){o.options.level.isType("game-dev")?t+='<button class="btn btn-lg btn-illustrated btn-success game-dev-play-btn"><span data-i18n="common.play"></span></button><button class="btn btn-lg btn-illustrated btn-success done-button secret"><span data-i18n="play_level.done"></span></button>':"codecombat-junior"==o.options.level.get("product")?(t=t+'<button class="btn btn-lg btn-illustrated btn-success cast-button"'+n.attr("title",o.castVerbose(),!0,!0)+'><span class="glyphicon glyphicon-play"></span></button>',o.autoSubmitsToLadder&&(t+='<div class="hidden"><div class="ladder-submission-view"></div></div>')):(t=t+'<button class="btn btn-lg btn-illustrated cast-button"'+n.attr("title",o.castVerbose(),!0,!0)+'><span data-i18n="play_level.tome_cast_button_ran">Ran</span></button>',o.observing||(o.mirror||o.options.level.isType("ladder")&&(!e.isAnonymous()||!e.get("hourOfCode"))?t+='<div class="ladder-submission-view"></div>':(t=t+'<button class="btn btn-lg btn-illustrated submit-button"'+n.attr("title",o.castRealTimeVerbose(),!0,!0)+'><span data-i18n="play_level.tome_submit_button">Submit</span><span class="spl secret submit-again-time"></span></button><button class="btn btn-lg btn-illustrated btn-success done-button secret"><span data-i18n="play_level.done">Done</span></button><button class="btn btn-lg btn-illustrated btn-success" id="stop-cinematic-playback-button"><span class="glyphicon glyphicon-stop"></span></button>',o.autoSubmitsToLadder&&(t+='<div class="hidden"><div class="ladder-submission-view"></div></div>'))))}.call(this,"me"in o?o.me:"undefined"!=typeof me?me:void 0,"view"in o?o.view:"undefined"!=typeof view?view:void 0),t}},311688:(e,t,o)=>{var n=o(477055);e.exports=function(e){var t,o="",i=e||{};return function(e){o+='<button class="close" type="button">&times;</button><table><tr>',e.duckImg&&(o=o+'<td><img class="duck-img"'+n.attr("src",e.duckImg,!0,!0)+' width="100"></td>'),o+='<td><h3 class="problem-alert-title" data-i18n="play_level.problem_alert_title">Fix Your Code</h3>',o=e.hint?o+'<span class="problem-title">'+(null==(t=e.hint)?"":t)+'</span><br><span class="problem-subtitle">'+(null==(t=e.message)?"":t)+"</span>":o+'<span class="problem-title">'+(null==(t=e.message)?"":t)+"</span>",o+="</td></tr></table>",e.showAiBotHelp&&(o+='<div class="chatbot-help"><img class="avatar" src="/images/level/baby-griffin.png" alt="AI"><span class="spr" data-i18n="play_level.problem_alert_need_help"></span><button class="btn btn-illustrated btn-primary ai-help-button" data-i18n="play_level.problem_alert_ask_the_ai"></button>',e.creditMessage&&(o=o+'<img class="chatbot-hint" src="/images/ozaria/teachers/dashboard/svg_icons/IconHint.svg" alt="Hint" data-container="body" data-toggle="popover" data-placement="right"'+n.attr("data-content",e.creditMessage,!0,!0)+">"),o+="</div>")}.call(this,"view"in i?i.view:"undefined"!=typeof view?view:void 0),o}},851927:(e,t,o)=>{o(477055),e.exports=function(e){return""+'<div><span class="code-palette-background"></span><div class="properties-scroll-container" translate="no"><div class="properties properties-this"></div></div></div>'}},560737:(e,t,o)=>{var n=o(477055);e.exports=function(e){var t="",o=e||{};return function(e,o,i,s,r,a,l,c,u){if(l&&(t+='<img id="amazon-level-logo" src="/images/pages/play/amazon_horz_lockup.png">'),t+='<div class="hinge hinge-0"></div><div class="hinge hinge-1"></div><div class="hinge hinge-2"></div><div class="hinge hinge-3"></div><div class="spell-tool-buttons"><div class="btn btn-small btn-illustrated btn-warning reload-code" data-i18n="[title]play_level.tome_reload_method"><div class="glyphicon glyphicon-repeat"></div></div>',a.rank()>=15&&(t=t+'<div class="btn btn-small btn-illustrated fullscreen-code"'+n.attr("title",r,!0,!0)+'><div class="glyphicon glyphicon-fullscreen"></div><div class="glyphicon glyphicon-resize-small"></div></div>'),"javascript"===i&&a.rank()>=15&&(t=t+'<div class="btn btn-small btn-illustrated beautify-code"'+n.attr("title",o,!0,!0)+'><div class="glyphicon glyphicon-magnet"></div></div>'),u.blocksHidden||(t+='<div class="btn btn-small btn-illustrated toggle-blocks" data-i18n="[title]play_level.blocks"><span data-i18n="play_level.blocks"></span></div>'),u.showLevelHelp&&(t+='<span class="spell-chatbot"><img class="spell-chatbot-hint" src="/images/ozaria/teachers/dashboard/svg_icons/IconHint.svg" alt="Hint"></span>'),a.canAutoFillCode()&&(u.teaching?t+='<button class="btn btn-small btn-illustrated btn-success" id="toggle-solution"><span data-i18n="play_level.toggle_solution"></span></button>':t+='<button class="btn btn-small btn-illustrated btn-success" id="fill-solution"><span data-i18n="play_level.fill_in_solution"></span></button>'),t+='<div id="ask-teacher-for-help">',u.courseID&&a.isStudent()&&u.teacherOnline()&&(t=t+"<button"+(n.attr("class",n.classes(["btn","btn-small","btn-illustrated","btn-success",u.teacherOnline()?"":"disabled"],[!1,!1,!1,!1,!0]),!1,!0)+n.attr("title",e,!0,!0))+'><span data-i18n="common.help"></span></button>'),t+="</div>",u.hintsState&&u.hintsState.get("total")>0&&(t+='<div class="btn btn-small btn-illustrated hints-button"><span data-i18n="play_level.hints"></span></div>'),u.showVideosButton()&&(t+='<div class="btn btn-small btn-illustrated btn-success videos-button"><span data-i18n="play_level.videos"></span></div>'),u.options.level.isType("web-dev")&&(t+='<div class="btn btn-small btn-illustrated image-gallery-button"><span data-i18n="web_dev.image_gallery_title"></span></div>'),u.options.level.get("shareable"))if(s=u.options.level.isType("game-dev")?"sharing.game":"sharing.webpage",u.options.session.isFake())t=t+'<button class="btn btn-small btn-illustrated"'+n.attr("data-i18n",s,!0,!0)+' data-toggle="popover" data-placement="bottom"'+n.attr("data-content",c("sharing.your_students_preview"),!0,
1!0)+' data-trigger="hover"></button>';else{var d="/play/"+u.options.level.get("type")+"-level/"+u.options.level.get("slug")+"/"+u.options.session.id;u.options.courseID&&(d+="?course="+u.options.courseID,u.options.courseInstanceID&&(d+="&course-instance="+u.options.courseInstanceID)),t=t+'<a class="btn btn-small btn-illustrated"'+n.attr("href",d,!0,!0)+n.attr("data-i18n",s,!0,!0)+"></a>"}t+='<div class="clearfix"></div></div>'}.call(this,"askingTeacher"in o?o.askingTeacher:"undefined"!=typeof askingTeacher?askingTeacher:void 0,"beautifyShortcutVerbose"in o?o.beautifyShortcutVerbose:"undefined"!=typeof beautifyShortcutVerbose?beautifyShortcutVerbose:void 0,"codeLanguage"in o?o.codeLanguage:"undefined"!=typeof codeLanguage?codeLanguage:void 0,"i18nName"in o?o.i18nName:"undefined"!=typeof i18nName?i18nName:void 0,"maximizeShortcutVerbose"in o?o.maximizeShortcutVerbose:"undefined"!=typeof maximizeShortcutVerbose?maximizeShortcutVerbose:void 0,"me"in o?o.me:"undefined"!=typeof me?me:void 0,"showAmazonLogo"in o?o.showAmazonLogo:"undefined"!=typeof showAmazonLogo?showAmazonLogo:void 0,"translate"in o?o.translate:"undefined"!=typeof translate?translate:void 0,"view"in o?o.view:"undefined"!=typeof view?view:void 0),t}},40160:(e,t,o)=>{var n=o(477055);e.exports=function(e){var t,o="",i=e||{};return function(e){o+='<img class="code-background" src="/images/level/code_editor_background.png"><span class="code-background"></span><div class="ace coco-view" translate="no"></div><div class="blockly-container"></div><div class="save-status" data-i18n="play_level.code_saved"></div><div class="programming-language-container rtl-allowed">',e.spell.level.isType("web-dev")?(e.spell.level.get("campaign")||"").indexOf("web-dev-1")>=0?o+='<span class="programming-language-label" data-i18n="teacher.language"></span><span class="programming-language-label spr">:</span><span class="programming-language">HTML</span>':o+='<span class="programming-language-label" data-i18n="play_level.languages"></span><span class="programming-language-label spr">:</span><span class="programming-language spr">HTML</span><span class="programming-language-label spr">/</span><span class="programming-language">JavaScript</span>':o=o+'<span class="programming-language-label" data-i18n="play_level.programming_language"></span><span class="programming-language-label spr">:</span><span class="programming-language">'+n.escape(null==(t=e.spell.displayCodeLanguage)?"":t)+"</span>",o+='</div><div class="yjs-awareness-container rtl-allowed"></div>'}.call(this,"view"in i?i.view:"undefined"!=typeof view?view:void 0),o}},962122:(e,t,o)=>{var n=o(477055);e.exports=function(e){var t,o="",i=e||{};return function(e){e.thangType&&(o=o+'<img class="spawnable-image"'+n.attr("src",e.thangType.getPortraitURL(),!0,!0)+">"),o=o+'<span class="doc-title"'+n.attr("data-property-name",e.doc.name,!0,!0)+">"+n.escape(null==(t=e.doc.title)?"":t)+"</span>"}.call(this,"view"in i?i.view:"undefined"!=typeof view?view:void 0),o}},575945:(e,t,o)=>{var n=o(477055);e.exports=function(e){var t,o="",i={},s=e||{};return function(e,s,r,a,l,c,u,d,h,p,g,v){o=o+'<h4 dir="ltr"><span class="prop-name">'+n.escape(null==(t=a.shortName)?"":t)+"</span> - ";var m="function"==a.type&&"this"==a.owner?"method":a.type;if(o=o+'<code class="prop-type"'+n.attr("data-i18n","skill_docs."+m,!0,!0)+">\x3c!-- In case there's no translation in en.coffee because we missed one--\x3e"+n.escape(null==(t=m)?"":t)+"</code>\x3c!-- Redundant in case some tag docs are missing an owner--\x3e",e.contains(["function","handler","basic tag","spawnable","event","snippet"],a.type)||"HTML"==a.owner||(o+=" (",o+=v?'<span data-i18n="skill_docs.writable">writable</span>':'<span data-i18n="skill_docs.read_only">read-only</span>',o+=")"),o+="</h4>",a.translatedShortName&&(o=o+'<h5><span class="translated-name">'+n.escape(null==(t=a.translatedShortName)?"":t)+"</span></h5>"),o=o+'<div class="description rtl-allowed rtl-right-aligned" dir="auto"><p dir="auto">'+(null==(t=d(a.description||"Still undocumented, sorry."))?"":t)+'</p><div class="clear" style="clear: both"></div>',r&&(r.cooldown||r.specificCooldown)&&(o+="<p><span>","spell"==r.type?o+='<span data-i18n="skill_docs.spell">Spell</span>':o+='<span data-i18n="skill_docs.action">Action</span>',o=o+'<span class="spl" data-i18n="skill_docs.action_name">name</span><span class="spr">:</span><code>"'+n.escape(null==(t=r.name)?"":t)+'"</code>.</span><span class="spl"><span data-i18n="skill_docs.action_cooldown">Takes</span><span class="spr">:</span><code>'+n.escape(null==(t=r.cooldown)?"":t)+"</code>s.\x3c!-- TODO: localize seconds (ex. Hebrew should say שנ instead of s)--\x3e</span>",r.specificCooldown&&(o=o+'<span class="spl"><span data-i18n="skill_docs.action_specific_cooldown">Cooldown</span><span class="spr">:</span><code>'+n.escape(null==(t=r.specificCooldown)?"":t)+"</code>s.</span>"),r.damage&&(o=o+'<span class="spl"><span data-i18n="skill_docs.action_damage">Damage</span><span class="spr">:</span><code>'+n.escape(null==(t=r.damage)?"":t)+"</code>.</span>"),r.range&&(o=o+'<span class="spl"><span data-i18n="skill_docs.action_range">Range</span><span class="spr">:</span><code>'+n.escape(null==(t=r.range)?"":t)+"</code>m.</span>"),r.radius&&(o=o+'<span class="spl"><span data-i18n="skill_docs.action_radius">Radius</span><span class="spr">:</span><code>'+n.escape(null==(t=r.radius)?"":t)+"</code>m.</span>"),r.duration&&(o=o+'<span class="spl"><span data-i18n="skill_docs.action_duration">Duration</span><span class="spr">:</span><code>'+n.escape(null==(t=r.duration)?"":t)+"</code>s.</span>"),o+="</p>"),o+="</div>",a.example?o=o+'<p class="example"><strong><span data-i18n="skill_docs.example">Example</span>:</strong><div class="docs-ace-container"><div class="docs-ace">'+n.escape(null==(t=a.example)?"":t)+"</div></div></p>":"function"==a.type&&s.length&&(o+='<p class="example"><strong><span data-i18n="skill_docs.example">Example</span>:</strong><div><div class="docs-ace-container"><div class="docs-ace">',"codecombat-junior"==p?o=o+"<span>"+n.escape(null==(t=l+"("+s.join(", ")+")")?"":t)+"</span>":/javascript|java|cpp/.test(u)?o=o+"<span>"+n.escape(null==(t=a.ownerName+"."+l+"("+s.join(", ")+");")?"":t)+"</span>":"coffeescript"==u?o=o+"<span>"+n.escape(null==(t=a.ownerName+("@"==a.ownerName?"":".")+l+" "+s.join(", "))?"":t)+"</span>":"python"==u?o=o+"<span>"+n.escape(null==(t=a.ownerName+"."+l+"("+s.join(", ")+")")?"":t)+"</span>
1":"lua"==u&&(o=o+"<span>"+n.escape(null==(t=a.ownerName+":"+l+"("+s.join(", ")+")")?"":t)+"</span>"),o+="</div></div></div></p>"),("function"!=a.type&&"snippet"!=a.type&&"spawnable"!=a.type&&"event"!=a.type&&"handler"!=a.type&&"property"!=a.type&&!e.contains(["HTML","CSS","WebJavaScript","jQuery"],a.owner)||"now"==a.name)&&(o=o+'<p class="value"><strong><span data-i18n="skill_docs.current_value">Current Value</span><span class="spr">:</span></strong><pre><code class="current-value"'+n.attr("data-prop",a.name,!0,!0)+">"+n.escape(null==(t=g)?"":t)+"</code></pre></p>"),i.argumentEntry=t=function(e){this&&this.block,this&&this.attributes,-1==["he","ar","fa","ur"].indexOf(h.get("preferredLanguage",!0))?(o=o+"<div><code>"+n.escape(null==(t=e.name)?"":t)+'</code><span class="spr">:</span><code>'+n.escape(null==(t=e.type)?"":t)+"</code>",e.example&&(o=o+' (<span data-i18n="skill_docs.ex">ex</span><span class="spr">:</span><code>'+n.escape(null==(t=e.example)?"":t)+"</code>)"),e.description&&(o=o+"<div>"+(null==(t=d(e.description))?"":t)+"</div>"),e.default&&(o=o+'<div><em><span data-i18n="skill_docs.default_value">Default value</span><span class="spr">:</span></em><code>'+n.escape(null==(t=e.default)?"":t)+"</code></div>"),o+="</div>"):(o=o+'<div dir="rtl"><code dir="rtl">'+n.escape(null==(t=e.name)?"":t)+'</code><span dir="rtl">'+n.escape(null==(t=": ")?"":t)+'</span><code dir="rtl">'+n.escape(null==(t=e.type)?"":t)+"</code>",e.example&&(o=o+'<br><span data-i18n="skill_docs.ex" dir="rtl">ex</span><span dir="rtl">'+n.escape(null==(t=": ")?"":t)+'</span><code dir="ltr">'+n.escape(null==(t=e.example)?"":t)+"</code>"),e.description&&(o=o+'<div class="rtl-right-aligned" dir="auto">'+(null==(t=d(e.description))?"":t)+"</div>"),e.default&&(o=o+'<div class="rtl-allowed"><em><span data-i18n="skill_docs.default_value">Default value</span><span dir="rtl">'+n.escape(null==(t=": ")?"":t)+'</span></em><code dir="ltr">'+n.escape(null==(t=e.default)?"":t)+"</code></div>"),o+="</div>")},a.args&&a.args.length){var f=e.any(a.args,(function(e){return e.optional}));e.any(a.args,(function(e){return!e.optional}))&&(o+='<p class="args" dir="auto"><strong><span data-i18n="skill_docs.required_parameters">Required Parameters</span><span class="spr">:</span></strong></p>',function(){var e=a.args;if("number"==typeof e.length)for(var t=0,o=e.length;t<o;t++)(n=e[t]).optional||i.argumentEntry(n);else for(var t in o=0,e){var n;o++,(n=e[t]).optional||i.argumentEntry(n)}}.call(this)),f&&(o+='<p class="args" dir="auto"><strong><span data-i18n="skill_docs.optional_parameters">Optional Parameters</span><span class="spr">:</span></strong>',function(){var e=a.args;if("number"==typeof e.length)for(var t=0,o=e.length;t<o;t++)(n=e[t]).optional&&i.argumentEntry(n);else for(var t in o=0,e){var n;o++,(n=e[t]).optional&&i.argumentEntry(n)}}.call(this),o+="</p>")}a.returns&&(o=o+'<p class="returns" dir="auto"><strong><span data-i18n="skill_docs.returns">Returns</span><span class="spr">:</span></strong><div><code>'+n.escape(null==(t=a.returns.type)?"":t)+"</code>",a.returns.example&&(o=o+' (<span data-i18n="skill_docs.ex">ex</span><span class="spr">:</span><code>'+n.escape(null==(t=a.returns.example)?"":t)+"</code>)"),a.returns.description&&(o=o+"<div>"+(null==(t=d(a.returns.description))?"":t)+"</div>"),o+="</div></p>"),c&&"function"==typeof c.get&&"game"!=a.owner&&"codecombat-junior"!=p&&!a.hideGrantedBy&&(o=o+'<p><em><span class="spr" data-i18n="skill_docs.granted_by">Granted by</span>'+n.escape(null==(t=c.get("name"))?"":t)+".</em></p>")}.call(this,"_"in s?s._:"undefined"!=typeof _?_:void 0,"argumentExamples"in s?s.argumentExamples:"undefined"!=typeof argumentExamples?argumentExamples:void 0,"cooldowns"in s?s.cooldowns:"undefined"!=typeof cooldowns?cooldowns:void 0,"doc"in s?s.doc:"undefined"!=typeof doc?doc:void 0,"docName"in s?s.docName:"undefined"!=typeof docName?docName:void 0,"item"in s?s.item:"undefined"!=typeof item?item:void 0,"language"in s?s.language:"undefined"!=typeof language?language:void 0,"marked"in s?s.marked:"undefined"!=typeof marked?marked:void 0,"me"in s?s.me:"undefined"!=typeof me?me:void 0,"product"in s?s.product:"undefined"!=typeof product?product:void 0,"value"in s?s.value:"undefined"!=typeof value?value:void 0,"writable"in s?s.writable:"undefined"!=typeof writable?writable:void 0),o}},612704:(e,t,o)=>{o(477055),e.exports=function(e){return""+'<div id="spell-top-bar-view"></div><div id="cast-button-view"></div><div id="spell-view"></div><div class="hide" id="spell-palette-view"></div>'}},527351:(e,t,o)=>{var n=o(477055);e.exports=function(e){var t,o="",i={},s=e||{};return function(e){i["game-dev-goals"]=t=function(e){this&&this.block,this&&this.attributes,o+='<ul class="goals">';var i=!1;(function(){var s=e;if("number"==typeof s.length)for(var r=0,a=s.length;r<a;r++)"manual"==(l=s[r]).type?o=o+'<li class="goal">'+n.escape(null==(t=l.config.description)?"":t)+"</li>":"survive"==l.type?l.config.seconds?o=o+'<li class="goal" data-i18n="play_game_dev_level.goal_survive_time"'+n.attr("data-i18n-options",{seconds:l.config.seconds},!0,!0)+"></li>":o+='<li class="goal" data-i18n="play_game_dev_level.goal_survive"></li>':"defeat"==l.type?l.config.amount?o=o+'<li class="goal" data-i18n="play_game_dev_level.goal_defeat_amount"'+n.attr("data-i18n-options",{amount:l.config.amount},!0,!0)+"></li>":o+='<li class="goal" data-i18n="play_game_dev_level.goal_defeat"></li>':"move"!=l.type||i?"collect"==l.type?l.config.amount?o=o+'<li class="goal" data-i18n="play_game_dev_level.goal_collect_amount"'+n.attr("data-i18n-options",{amount:l.config.amount},!0,!0)+"></li>":o+='<li class="goal" data-i18n="play_game_dev_level.goal_collect"></li>':"user_defined"==l.type&&(o=o+'<li class="goal">'+n.escape(null==(t=l.direction)?"":t)+"</li>"):(o+='<li class="goal" data-i18n="play_game_dev_level.goal_move"></li>',i=!0);else for(var r in a=0,s){var l;a++,"manual"==(l=s[r]).type?o=o+'<li class="goal">'+n.escape(null==(t=l.config.description)?"":t)+"</li>":"survive"==l.type?l.config.seconds?o=o+'<li class="goal" data-i18n="play_game_dev_level.goal_survive_time"'+n.attr("data-i18n-options",{seconds:l.config.seconds},!0,!0)+"></li>":o+='<li class="goal" data-i18n="play_game_dev_level.goal_survive"></li>':"defeat"==l.type?l.config.amount?o=o+'<li class="goal" data-i18n="play_game_dev_level.goal_defeat_amount"'+n.attr("data-i18n-options",{amount:l.config.amount},!0,!0)+"></li>":o+='<li class="goal" data-i18n="play_game_dev_level.goal_defeat"></li>':"move"!=l.type||i?"collect"==l.type?l.config.amount?o=o+'<li class="goal" data-i18n="play_game_dev_level.goal_collect_amount"'+n.attr("data-i18n-options",{amount:l.config.amount},!0,!0)+"></li>":o+='<li class="goal" data-i18n="play_game_dev_level.goal_collect"></li>':"user_defined"==l.type&&(o=o+'<li class="goal">'+n.escape(null==(t=l.direction)?"":t)+"</li>"):(o+='<li class="goal" data-i18n="play_game_dev_level.goal_move"></li>',i=!0)}}).call(this),o+="</ul>"},o+='<div class="game-container"><div id="floating-nav"></div><div id="level-loading-view"></div><div class="level-content"><div id="control-bar-view"></div><div id="solution-area"><div id="solution-view"><div class="ace-solution"></div><span class="code-background"></span><div class="solution-label" data-i18n="common.solution"></div><button class="apply-solution-btn btn btn-small btn-illustrated btn-primary" data-i18n="play_level.apply_code"></button><div class="close-solution-btn">×</div></div></div><div id="code-area"><div class="gradient" id="code-area-gradient"></div><div id="tome-view"></div></div><div class="hide" id="spell-palette-view-mid"></div><div id="problem-alert-view"></div><div id="game-area"><div id="canvas-wrapper"><canvas width="924" height="589" id="webgl-surface"></canvas><canvas width="924" height="589" id="normal-surface"></canvas><div id="web-surface-view"></div><div class="gradient" id="canvas-left-gradient"></div><div class="gradient" id="canvas-top-gradient"></div><div id="goals-view"></div></div><div id="level-flags-view"></div><div id="gold-view"></div><div id="game-dev-track-view"></div><div id="multiplayer-status-view"></div><div id="duel-stats-view"></div><div id="playback-view"></div><div id="thang-hud"></div><div id="level-dialogue-view"></div></div><div id="surface-context-menu-view"></div><button class="btn btn-lg btn-warning banner header-font" id="stop-real-time-playback-button" title="Stop real-time playback">',e.level&&e.level.isType("game-dev")?o+='<span data-i18n="play_level.edit_level"></span>':o+='<span data-i18n="play_level.skip"></span>',o+='</button><div id="cinematic-code-display">',function(){var e=[0,1,2,3,4,5,6];if("number"==typeof e.length)for(var t=0,i=e.length;t<i;t++){var s=e[t];o=o+"<div"+n.attr("class",n.classes(["code-line code-line-"+s],[!0]),!1,!0)+'><code class="line-number"></code><code class="indentation"></code><code class="code-text"></code></div>'}
1else for(var t in i=0,e)i++,s=e[t],o=o+"<div"+n.attr("class",n.classes(["code-line code-line-"+s],[!0]),!1,!0)+'><code class="line-number"></code><code class="indentation"></code><code class="code-text"></code></div>'}.call(this),o+='</div><div class="panel panel-default hide style-flat" id="how-to-play-game-dev-panel"><div class="panel-heading"><h3 class="panel-title"><span data-i18n="play_level.directions"></span>:</h3></div>',e.studentGoals&&e.studentGoals.length?(o+='<div class="panel-body">',i["game-dev-goals"](e.studentGoals),o+="</div>"):o=o+'<div class="panel-body">'+(null==(t=e.howToPlayText)?"":t)+"</div>",o+='</div><div class="hints-view hide"></div><div id="level-chat-view"></div></div><div id="level-footer-shadow"></div><div id="level-footer-background"></div></div>'}.call(this,"view"in s?s.view:"undefined"!=typeof view?view:void 0),o}},712256:(e,t,o)=>{var n=o(477055);e.exports=function(e){var t="";return t+='<div id="level-loading-view"></div><div class="level-content"><div id="control-bar-view"></div><div id="canvas-wrapper"><canvas width="924" height="589" id="webgl-surface"></canvas><canvas width="924" height="589" id="normal-surface"></canvas><div class="gradient" id="canvas-left-gradient"></div><div class="gradient" id="canvas-top-gradient"></div></div><div class="secret expanded" id="gold-view"></div><div id="level-chat-view"></div><div id="duel-stats-view"></div><div id="playback-view"></div><div id="thang-hud"></div>',function(){var e=["humans","ogres"];if("number"==typeof e.length)for(var o=0,i=e.length;o<i;o++){var s=e[o];t=t+"<div"+n.attr("class",n.classes(["spectate-code team-"+s],[!0]),!1,!0)+'><img class="code-background" src="/images/level/code_editor_background.png"><span class="code-background"></span><div class="ace"></div><div class="programming-language-container rtl-allowed"><span class="programming-language-label" data-i18n="play_level.programming_language"></span><span class="programming-language-label spr">:</span><span class="programming-language"></span></div></div>'}else for(var o in i=0,e)i++,s=e[o],t=t+"<div"+n.attr("class",n.classes(["spectate-code team-"+s],[!0]),!1,!0)+'><img class="code-background" src="/images/level/code_editor_background.png"><span class="code-background"></span><div class="ace"></div><div class="programming-language-container rtl-allowed"><span class="programming-language-label" data-i18n="play_level.programming_language"></span><span class="programming-language-label spr">:</span><span class="programming-language"></span></div></div>'}.call(this),t+="</div>"}},790684:(e,t,o)=>{"use strict";o.r(t),o.d(t,{__esModule:()=>i.X,default:()=>r});var n=o(240689),i=o(439610);const s=i.Z;o(796468);const r=(0,o(551900).Z)(s,n.sY,n.xk,!1,null,null,null).exports},677820:(e,t,o)=>{"use strict";o.d(t,{default:()=>r});var n=o(732035),i=o(243878);const s=o.n(i)();o(752268);const r=(0,o(551900).Z)(s,n.sY,n.xk,!1,null,null,null).exports},529167:(e,t,o)=>{"use strict";o.r(t),o.d(t,{default:()=>r});var n=o(195917),i=o(449105),s={};for(const e in i)"default"!==e&&(s[e]=()=>i[e]);o.d(t,s);const r=(0,o(551900).Z)(i.default,n.sY,n.xk,!1,null,"7b4e9c68",null).exports},449105:(e,t,o)=>{"use strict";o.r(t),o.d(t,{default:()=>r});var n=o(453857),i=o.n(n),s={};for(const e in n)"default"!==e&&(s[e]=()=>n[e]);o.d(t,s);const r=i()},195917:(e,t,o)=>{"use strict";o.d(t,{sY:()=>n.sY,xk:()=>n.xk});var n=o(434700)},401778:(e,t,o)=>{var n=o(23280);n.__esModule&&(n=n.default),"string"==typeof n&&(n=[[e.id,n,""]]),n.locals&&(e.exports=n.locals),(0,o(745346).Z)("14666898",n,!0,{})},106307:(e,t,o)=>{var n=o(323050);n.__esModule&&(n=n.default),"string"==typeof n&&(n=[[e.id,n,""]]),n.locals&&(e.exports=n.locals),(0,o(745346).Z)("79406f70",n,!0,{})},793254:(e,t,o)=>{var n=o(279763);n.__esModule&&(n=n.default),"string"==typeof n&&(n=[[e.id,n,""]]),n.locals&&(e.exports=n.locals),(0,o(745346).Z)("3ee3a8b0",n,!0,{})},525398:(e,t,o)=>{var n=o(566103);n.__esModule&&(n=n.default),"string"==typeof n&&(n=[[e.id,n,""]]),n.locals&&(e.exports=n.locals),(0,o(745346).Z)("c79e8c14",n,!0,{})},609682:(e,t,o)=>{var n=o(963472);n.__esModule&&(n=n.default),"string"==typeof n&&(n=[[e.id,n,""]]),n.locals&&(e.exports=n.locals),(0,o(745346).Z)("e3132de0",n,!0,{})},89412:(e,t,o)=>{var n=o(48057);n.__esModule&&(n=n.default),"string"==typeof n&&(n=[[e.id,n,""]]),n.locals&&(e.exports=n.locals),(0,o(745346).Z)("486de4d0",
1n,!0,{})},185174:(e,t,o)=>{var n=o(863152);n.__esModule&&(n=n.default),"string"==typeof n&&(n=[[e.id,n,""]]),n.locals&&(e.exports=n.locals),(0,o(745346).Z)("001230b0",n,!0,{})},908821:(e,t,o)=>{var n=o(392191);n.__esModule&&(n=n.default),"string"==typeof n&&(n=[[e.id,n,""]]),n.locals&&(e.exports=n.locals),(0,o(745346).Z)("28c76fe0",n,!0,{})},515979:(e,t,o)=>{var n=o(408512);n.__esModule&&(n=n.default),"string"==typeof n&&(n=[[e.id,n,""]]),n.locals&&(e.exports=n.locals),(0,o(745346).Z)("49002434",n,!0,{})},183942:(e,t,o)=>{var n=o(210136);n.__esModule&&(n=n.default),"string"==typeof n&&(n=[[e.id,n,""]]),n.locals&&(e.exports=n.locals),(0,o(745346).Z)("3b9f6cf0",n,!0,{})},903534:(e,t,o)=>{var n=o(993920);n.__esModule&&(n=n.default),"string"==typeof n&&(n=[[e.id,n,""]]),n.locals&&(e.exports=n.locals),(0,o(745346).Z)("213d5eb4",n,!0,{})},136048:(e,t,o)=>{var n=o(953785);n.__esModule&&(n=n.default),"string"==typeof n&&(n=[[e.id,n,""]]),n.locals&&(e.exports=n.locals),(0,o(745346).Z)("69012452",n,!0,{})},686713:(e,t,o)=>{var n=o(960816);n.__esModule&&(n=n.default),"string"==typeof n&&(n=[[e.id,n,""]]),n.locals&&(e.exports=n.locals),(0,o(745346).Z)("20a4b568",n,!0,{})},274229:(e,t,o)=>{var n=o(180299);n.__esModule&&(n=n.default),"string"==typeof n&&(n=[[e.id,n,""]]),n.locals&&(e.exports=n.locals),(0,o(745346).Z)("6c37a94c",n,!0,{})},719759:(e,t,o)=>{var n=o(648625);n.__esModule&&(n=n.default),"string"==typeof n&&(n=[[e.id,n,""]]),n.locals&&(e.exports=n.locals),(0,o(745346).Z)("4a3b337a",n,!0,{})},970693:(e,t,o)=>{var n=o(877705);n.__esModule&&(n=n.default),"string"==typeof n&&(n=[[e.id,n,""]]),n.locals&&(e.exports=n.locals),(0,o(745346).Z)("262ebedc",n,!0,{})},118530:(e,t,o)=>{var n=o(638032);n.__esModule&&(n=n.default),"string"==typeof n&&(n=[[e.id,n,""]]),n.locals&&(e.exports=n.locals),(0,o(745346).Z)("777c7e28",n,!0,{})},607967:(e,t,o)=>{var n=o(853238);n.__esModule&&(n=n.default),"string"==typeof n&&(n=[[e.id,n,""]]),n.locals&&(e.exports=n.locals),(0,o(745346).Z)("4b7b445f",n,!0,{})},206650:(e,t,o)=>{var n=o(841418);n.__esModule&&(n=n.default),"string"==typeof n&&(n=[[e.id,n,""]]),n.locals&&(e.exports=n.locals),(0,o(745346).Z)("05e5566e",n,!0,{})},796468:(e,t,o)=>{var n=o(62784);n.__esModule&&(n=n.default),"string"==typeof n&&(n=[[e.id,n,""]]),n.locals&&(e.exports=n.locals),(0,o(745346).Z)("56c22300",n,!0,{})},752268:(e,t,o)=>{var n=o(479522);n.__esModule&&(n=n.default),"string"==typeof n&&(n=[[e.id,n,""]]),n.locals&&(e.exports=n.locals),(0,o(745346).Z)("e3178604",n,!0,{})}}]);
2//# sourceMappingURL=play-962e61337b9e579186b4.bundle.js.map

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.