UNPKG

slipshow

Version:

This is not another slide engine, but a slip engine.

3 lines (2 loc) 47.3 kB
var Slipshow=function(t){"use strict";class e extends HTMLImageElement{static get observedAttributes(){return["figure-name"]}constructor(){super(),void 0===this.internalStep&&(this.internalStep=0),this.img=[],this.maxStep=0,this.figureName=this.getAttribute("figure-name"),this.promise=this.preloadImages(0).then((()=>{this.updateSRC()}))}preloadImage(t){return new Promise(((e,i)=>{this.img[t]=new Image,this.img[t].onload=()=>e(),this.img[t].onerror=i,this.img[t].src=this.getURL(t)}))}preloadImages(t){return new Promise(((e,i)=>{this.preloadImage(t).then((()=>{this.preloadImages(t+1).then((()=>{e()}))})).catch((()=>{this.maxStep=t-1,e()}))}))}connectedCallback(){}getURL(t){return"figures/"+this.figureName+"/"+this.figureName+"_"+t+".svg"}updateSRC(){this.src=this.getURL(this.figureStep)}set figureStep(t){this.promise=this.promise.then((()=>{t>this.maxStep?this.internalStep=this.maxStep:this.internalStep=t<0?0:t,this.updateSRC()}))}get figureStep(){return this.internalStep}attributeChangedCallback(t,e,i){"figure-name"==t&&(this.figureName=i,this.promise=this.promise.then((()=>{this.preloadImages(0).then((()=>{this.updateSRC()}))})))}nextFigure(){this.figuresStep++}}customElements.define("slip-figure",e,{extends:"img"});let i=(t,e,i)=>{i=i||"slip-slip",t.id||(t.id="_"+Math.random().toString(36).substr(2,15));let s=Array.from(t.querySelectorAll(e)),n=e.split(",").map((e=>"#"+t.id+" "+i+" "+e)).join(),a=Array.from(t.querySelectorAll(n));return s.filter((t=>!a.includes(t)))};function s(t){let e=t.cloneNode(!1);return t.childNodes.forEach((t=>{if(t.tagName&&"SLIP-SLIP"==t.tagName){let i=document.createElement(t.tagName);["pause","step","auto-enter","immediate-enter"].forEach((e=>{t.hasAttribute(e)&&i.setAttribute(e,t.getAttribute(e))})),i.classList.add("toReplace"),e.appendChild(i)}else if(t.tagName&&"CANVAS"==t.tagName&&t.classList.contains("sketchpad")){let i=document.createElement(t.tagName);i.classList.add("toReplaceSketchpad"),e.appendChild(i)}else e.appendChild(s(t))})),e}function n(t,e,s,n){let a=i(t,".toReplace");e.forEach(((t,e)=>{["pause","step","auto-enter","immediate-enter"].forEach((i=>{a[e].hasAttribute(i)&&t.setAttribute(i,a[e].getAttribute(i))})),a[e].replaceWith(t)}));let r=i(t,".toReplaceSketchpad");r[0]&&r[0].replaceWith(s),r[1]&&r[1].replaceWith(n)}window.myQueryAll=i;var a=Object.freeze({__proto__:null,cloneNoSubslip:s,myQueryAll:i,replaceSubslips:n});function r(t){let e=t;this.getEngine=()=>this.engine,this.setEngine=t=>this.engine=t;let i=!0;this.activate=()=>{i=!0},this.deactivate=()=>{i=!1};let s=["k"],n=["m"],a=["o"],r=["l"],o=["i"],l=["p"],h=["z"],c=["Z"],u=["T"],d=["t"],p=["ArrowRight","ArrowDown"],g=["ArrowLeft","ArrowUp"],m=["r"],f=["f"],v=[],y=["w"],w=["W"],b=["h"],A=["H"],S=["x"],x=["X"],k=["C"],L=["#"],E=1;document.addEventListener("keypress",(t=>{f.includes(t.key)&&i&&(E=(E+4)%30+1),m.includes(t.key)&&i&&e.getCurrentSlip().refresh(),y.includes(t.key)&&i&&e.setTool("drawing"),w.includes(t.key)&&i&&e.setTool("drawing-erase"),b.includes(t.key)&&i&&e.setTool("highlighting"),A.includes(t.key)&&i&&e.setTool("highlighting-erase"),S.includes(t.key)&&i&&e.setTool("no-tool"),x.includes(t.key)&&i&&e.setTool("clear-all"),k.includes(t.key)&&i&&e.reloadCanvas(),L.includes(t.key)&&i&&(document.querySelectorAll("slip-slip").forEach((t=>{t.style.zIndex="-1"})),document.querySelectorAll(".background-canvas").forEach((t=>{t.style.zIndex="1"})))})),document.addEventListener("keydown",(t=>{let m=e.getOpenWindowHeight(),f=e.getOpenWindowWidth();r.includes(t.key)&&i&&e.moveWindowRelative(0,E/m,0,0,.1),a.includes(t.key)&&i&&e.moveWindowRelative(0,-E/m,0,0,.1),s.includes(t.key)&&i&&e.moveWindowRelative(-E/f,0,0,0,.1),n.includes(t.key)&&i&&e.moveWindowRelative(E/f,0,0,0,.1),o.includes(t.key)&&i&&e.moveWindowRelative(0,0,0,1,.1),l.includes(t.key)&&i&&e.moveWindowRelative(0,0,0,-1,.1),h.includes(t.key)&&i&&e.moveWindowRelative(0,0,.01,0,.1),c.includes(t.key)&&i&&e.moveWindowRelative(0,0,-.01,0,.1),u.includes(t.key)&&i&&e.showToC(),d.includes(t.key)&&i&&(document.querySelector(".toc-slip").style.display="none"==document.querySelector(".toc-slip").style.display?"block":"none"),p.includes(t.key)&&i?t.shiftKey?e.nextSlip():e.next():g.includes(t.key)&&i?t.shiftKey?e.previousSlip():e.previous():v.includes(t.key)&&i&&e.pop()}))}class o{constructor(t,e){this.x=t,this.y=e}set(t,e){this.x=t,this.y=e}}class l extends o{constructor(){super(0,0),this.down=!1,this.previous=new o(0,0)}}class h{constructor(){this.eventListeners=new Map}addEventListener(t,e){const i=this.eventListeners.get(t)||new Set;i.add(e),this.eventListeners.set(t,i)}removeEventListener(t,e){const i=this.eventListeners.get(t);i&&i.delete(e)}dispatchEvent(t,e){const i=this.eventListeners.get(t);i&&[...i].forEach((t=>t(e)))}}const c=(t,e,i,s)=>{const n=(i-t)**2,a=(s-e)**2;return Math.sqrt(n+a)},u=(t,e,i,s,n)=>a=>{const r=t[a],o=t[a+1],l=t[a+2],h=t[a+3];return r===e&&o===i&&l===s&&h===n},d="draw",p="erase",g="fill",m="disabled",f=[d,p];class v extends h{constructor(t,e={}){if("undefined"==typeof window)throw new Error("Looks like we're not running in a browser");if(super(),t instanceof window.Node&&"CANVAS"===t.tagName)this.canvas=t;else{if("string"!=typeof t)throw new Error(`can't look for canvas based on '${t}'`);this.canvas=document.querySelector(t)}if(!this.canvas)throw new Error("canvas not found");this.canvas.width=e.width||this.canvas.width,this.canvas.height=e.height||this.canvas.height,this.mouse=new l;const i=t=>{t.cancelable&&t.preventDefault();const e=this.canvas.getBoundingClientRect(),i=t.changedTouches&&t.changedTouches[0]||t;let s=i.offsetX,n=i.offsetY;void 0===s&&(s=i.clientX-e.left),void 0===n&&(n=i.clientY-e.top);const{mouse:a}=this;if(a.down&&f.includes(this.modeInternal)){const{x:t,y:e}=this.draw(s,n,a.previous.x,a.previous.y);this.dirty||this.modeInternal!==d||s===a.x&&n===a.y||(this.dirty=!0,this.fireDirty()),a.set(s,n),a.previous.set(t,e)}else a.set(s,n)},s=t=>{if(t.cancelable&&t.preventDefault(),i(t),this.mode===g)return void this.fill();const{mouse:e}=this;e.previous.set(e.x,e.y),e.down=!0,this.beginStroke(e.previous.x,e.previous.y)},n=t=>{if(this.mode===g)return;const{mouse:e}=this;if(!e.down)return;const i=t.changedTouches&&t.changedTouches[0]||t,s=i.offsetX,n=i.offsetY;if(e.down=!1,e.x===s&&e.y===n&&f.includes(this.mode)){const{x:t,y:i}=this.draw(e.x,e.y,e.previous.x,e.previous.y);e.previous.set(t,i)}this.endStroke(e.x,e.y)};this.canvas.addEventListener("mousemove",i),this.canvas.addEventListener("mousedown",s),document.addEventListener("mouseup",n),this.canvas.addEventListener("touchstart",s),this.canvas.addEventListener("touchend",n),this.canvas.addEventListener("touchmove",i),this.destroy=()=>{this.clear(),this.canvas.removeEventListener("mousemove",i),this.canvas.removeEventListener("mousedown",s),document.removeEventListener("mouseup",n),this.canvas.removeEventListener("touchstart",s),this.canvas.removeEventListener("touchend",n),this.canvas.removeEventListener("touchmove",i)},this.context=this.canvas.getContext("2d"),this.context.globalCompositeOperation="source-over",this.context.globalAlpha=1,this.context.strokeStyle=e.color||"rgba(0,0,0,1)",this.context.lineCap="round",this.context.lineJoin="round",this.context.translate(.5,.5),this.filling=!1,this.fillStack=[],this.recordStrokes=!1,this.strokeMemory=[],this.smoothing=.85,this.thickness=2,this.targetThickness=this.thickness,this.weightInternal=this.thickness,this.maxWeight=this.thickness+10,this.modeInternal=d,this.adaptiveStroke=!0,["weight","smoothing","adaptiveStroke","mode"].forEach((t=>{void 0!==e[t]&&(this[t]=e[t])}))}beginStroke(t,e){this.context.beginPath(),this.context.moveTo(t,e),this.recordStrokes&&(this.strokeTimestamp=performance.now(),this.strokeMemory.push({point:new o(t,e),time:performance.now()-this.strokeTimestamp})),this.dispatchEvent("strokestart",{x:t,y:e})}endStroke(t,e){this.context.closePath(),this.recordStrokes&&this.strokeMemory.push({point:new o(t,e),time:performance.now()-this.strokeTimestamp}),this.dispatchEvent("strokeend",{x:t,y:e}),this.recordStrokes&&this.dispatchEvent("strokerecorded",{stroke:this.currentStroke}),this.strokeMemory=[],delete this.strokeTimestamp}draw(t,e,i,s){this.recordStrokes&&(this.strokeMemory.push({point:new o(t,e),time:performance.now()-this.strokeTimestamp}),this.dispatchEvent("pointdrawn",{stroke:this.currentStroke}));const{context:n}=this,a=c(t,e,i,s),r=Math.min(.87,this.smoothing+(a-60)/3e3),l=t-(t-i)*r,h=e-(e-s)*r,u=c(l,h,i,s);return this.adaptiveStroke?(this.targetThickness=(u-1)/49*(this.maxWeight-this.weightInternal)+this.weightInternal,this.thickness>this.targetThickness?this.thickness-=.5:this.thickness<this.targetThickness&&(this.thickness+=.5),n.lineWidth=this.thickness):n.lineWidth=this.weightInternal,n.quadraticCurveTo(i,s,l,h),n.stroke(),{x:l,y:h}}get color(){return this.context.strokeStyle}set color(t){if("string"!=typeof t)throw new Error("wrong argument type");this.context.strokeStyle=t}get weight(){return this.weightInternal}set weight(t){if("number"!=typeof t)throw new Error("wrong argument type");this.weightInternal=t,this.thickness=t,this.targetThickness=t,this.maxWeight=t+10}get mode(){return this.modeInternal}set mode(t){if("string"!=typeof t)throw new Error("wrong argument type");switch(t){case p:this.modeInternal=p,this.context.globalCompositeOperation="destination-out";break;case g:this.modeInternal=g,this.context.globalCompositeOperation="source-over";break;case m:this.modeInternal=m;break;default:this.modeInternal=d,this.context.globalCompositeOperation="source-over"}}get currentStroke(){return{points:this.strokeMemory.slice(),mode:this.mode,weight:this.weight,smoothing:this.smoothing,color:this.color,adaptiveStroke:this.adaptiveStroke}}isDirty(){return!!this.dirty}fireDirty(){this.dispatchEvent("dirty")}clear(){this.isDirty&&(this.dirty=!1,this.dispatchEvent("clean"),this.modeInternal===p?(this.modeInternal=d,this.context.clearRect(-10,-10,this.canvas.width+20,this.canvas.height+20),this.modeInternal=p):this.context.clearRect(-10,-10,this.canvas.width+20,this.canvas.height+20))}toImage(){return this.canvas.toDataURL()}fill(){const{mouse:t}=this,{context:e}=this,i=Array.from(e.getImageData(t.x,t.y,1,1).data);if(this.filling)this.fillStack.push([t.x,t.y,i]);else{const{x:e,y:s}=t;this.dispatchEvent("fillstart",{x:e,y:s}),this.filling=!0,setTimeout((()=>{this.floodFill(t.x,t.y,i)}),100)}}floodFill(t,e,i){const{context:s}=this,n=Math.floor(t),a=Math.floor(e),r=s.canvas.width,o=s.canvas.height,l=[[n,a]],h=(t=>{const e=t.match(/^#?([\da-f]{2})([\da-f]{2})([\da-f]{2})$/i);return[parseInt(e[1],16),parseInt(e[2],16),parseInt(e[3],16)]})(this.color),c=s.getImageData(0,0,s.canvas.width,s.canvas.height),d=Math.min(10*s.globalAlpha*255,255),p=((t,e,i,s,n,a)=>{const r=u(t,...n);return n=>{t[n]=e,t[n+1]=i,t[n+2]=s,t[n+3]=a,r(n+4)||(t[n+4]=.01*t[n+4]+.99*e,t[n+4+1]=.01*t[n+4+1]+.99*i,t[n+4+2]=.01*t[n+4+2]+.99*s,t[n+4+3]=.01*t[n+4+3]+.99*a),r(n-4)||(t[n-4]=.01*t[n-4]+.99*e,t[n-4+1]=.01*t[n-4+1]+.99*i,t[n-4+2]=.01*t[n-4+2]+.99*s,t[n-4+3]=.01*t[n-4+3]+.99*a)}})(c.data,...h,i,d),g=u(c.data,...i);if(u(c.data,...h,255)(4*(a*s.canvas.width+n)))return this.filling=!1,void this.dispatchEvent("fillend",{});for(;l.length;){const t=l.pop(),e=t[0];let i=t[1],s=4*(i*r+e);for(;i-- >=0&&g(s);)s-=4*r;s+=4*r,++i;let n=!1,a=!1;for(;i++<o-1&&g(s);)p(s),e>0&&(g(s-4)?n||(l.push([e-1,i]),n=!0):n&&(n=!1)),e<r-1&&(g(s+4)?a||(l.push([e+1,i]),a=!0):a&&(a=!1)),s+=4*r}s.putImageData(c,0,0),this.fillStack.length?this.floodFill(...this.fillStack.shift()):(this.filling=!1,this.dispatchEvent("fillend",{}))}}function y(t,e,a,r,o){this.generateActionList=function(){let t=[];return this.queryAll("slip-slip[enter-at]").forEach((e=>{t[e.getAttribute("enter-at")]=new y(e,"",[],r,{})})),t},this.addSubSlips=function(){return this.queryAll("slip-slip[enter-at]").forEach((t=>{this.setNthAction(t.getAttribute("enter-at"),new y(t,"",[],r,{}))})),[]};let l=a;this.setAction=t=>{l=t},this.getActionList=()=>{let t=[];for(let e=0;e<=this.getMaxNext();e++)this.pauseSlipList[e]instanceof y?t[e]=this.pauseSlipList[e]:"function"==typeof l[e]||l[e]instanceof y?t[e]=l[e]:t[e]=()=>{};return t},this.setNthAction=(t,e)=>{l[t]=e},this.getCurrentSubSlip=()=>l[this.getActionIndex()]instanceof y?l[this.getActionIndex()]:this.pauseSlipList[this.getActionIndex()]instanceof y&&this.pauseSlipList[this.getActionIndex()],this.nextStageNeedGoto=()=>!(l[this.getActionIndex()+1]instanceof y)&&(!(this.pauseSlipList[this.getActionIndex()+1]instanceof y)&&!(this.getActionIndex()>=this.getMaxNext())),this.getSubSlipList=function(){return this.getActionList().filter((t=>t instanceof y))};let h=-1;this.setActionIndex=t=>h=t,this.getActionIndex=()=>h,this.getMaxNext=()=>{if(this.maxNext)return this.maxNext;let t=l.length;["mk-visible-at","mk-hidden-at","mk-emphasize-at","mk-unemphasize-at","emphasize-at","chg-visib-at","up-at","down-at","center-at","static-at","exec-at","enter-at","focus-at","unfocus-at","figure-next-at","figure-previous-at"].forEach((e=>{this.queryAll("*["+e+"]").forEach((i=>{i.getAttribute(e).split(" ").forEach((e=>{t=Math.max(Math.abs(parseInt(e)),t)}))}))}));let e=this.queryAll("[pause], [step], [auto-enter], [immediate-enter]").map((t=>t.hasAttribute("pause")&&""!=t.getAttribute("pause")?parseInt(t.getAttribute("pause")):t.hasAttribute("step")&&""!=t.getAttribute("step")?parseInt(t.getAttribute("step")):1));return t=Math.max(t,e.reduce(((t,e)=>t+e),0)),this.maxNext=t,t},this.queryAll=t=>i(this.element,t),this.query=t=>"string"!=typeof t?t:this.queryAll(t)[0],this.findSubslipByID=t=>{let e=this.getSubSlipList().find((e=>e.name==t?1:e.findSubslipByID(t)));return!!e&&(e.name==t?e:e.findSubslipByID(t))},this.findSlipCoordinate=()=>{let t=c.getCoordinateInUniverse(this.element);return t.scale*=this.scale,t.y=t.y+.5*t.scale,t.x=t.centerX,t},this.updatePauseAncestors=()=>{this.queryAll(".pauseAncestor").forEach((t=>{t.classList.remove("pauseAncestor")}));let t=this.query("[pause]");for(;t&&"SLIP-SLIP"!=t.tagName;)t.classList.add("pauseAncestor"),t=t.parentElement},this.unpause=t=>{if(t.hasAttribute("static-at-unpause")&&(""==t.getAttribute("static-at-unpause")?this.makeStatic(t):t.getAttribute("static-at-unpause").split(" ").map((t=>{this.makeStatic("#"+t)}))),t.hasAttribute("unstatic-at-unpause")&&(""==t.getAttribute("unstatic-at-unpause")?this.makeUnStatic(t):t.getAttribute("unstatic-at-unpause").split(" ").map((t=>{this.makeUnStatic("#"+t)}))),t.hasAttribute("down-at-unpause")&&(""==t.getAttribute("down-at-unpause")?this.moveDownTo(t,1):this.moveDownTo("#"+t.getAttribute("down-at-unpause"),1)),t.hasAttribute("up-at-unpause")&&(""==t.getAttribute("up-at-unpause")?this.moveUpTo(t,1):this.moveUpTo("#"+t.getAttribute("up-at-unpause"),1)),t.hasAttribute("center-at-unpause")&&(""==t.getAttribute("center-at-unpause")?this.moveCenterTo(t,1):this.moveCenterTo("#"+t.getAttribute("center-at-unpause"),1)),t.hasAttribute("exec-at-unpause")&&(""==t.getAttribute("exec-at-unpause")?this.executeScript(t):t.getAttribute("exec-at-unpause").split(" ").map((t=>{this.executeScript("#"+t)}))),t.hasAttribute("reveal-at-unpause")&&(""==t.getAttribute("reveal-at-unpause")?this.reveal(t):t.getAttribute("reveal-at-unpause").split(" ").map((t=>{this.reveal("#"+t)}))),t.hasAttribute("hide-at-unpause")&&(""==t.getAttribute("hide-at-unpause")?this.hide(t):t.getAttribute("hide-at-unpause").split(" ").map((t=>{this.hide("#"+t)}))),t.hasAttribute("figure-set-at-unpause")){let[e,i]=t.getAttribute("figure-set-at-unpause").split(" ");this.query("#"+e).figureStep=i}t.hasAttribute("figure-next-at-unpause")&&t.getAttribute("figure-next-at-unpause").split(" ").map((t=>{this.query("#"+t).figureStep++})),t.hasAttribute("figure-previous-at-unpause")&&t.getAttribute("figure-previous-at-unpause").split(" ").map((t=>{this.query("#"+t).figureStep--})),t.hasAttribute("focus-at-unpause")&&(""==t.getAttribute("focus-at-unpause")?this.focus(t):this.focus("#"+t.getAttribute("focus-at-unpause"))),t.hasAttribute("emph-at-unpause")&&(""==t.getAttribute("emph-at-unpause")?this.makeEmph(t):t.getAttribute("emph-at-unpause").split(" ").map((t=>{this.makeEmph("#"+t)}))),t.hasAttribute("unemph-at-unpause")&&(""==t.getAttribute("unemph-at-unpause")?this.makeUnEmph(t):t.getAttribute("unemph-at-unpause").split(" ").map((t=>{this.makeUnEmph("#"+t)}))),t.hasAttribute("unfocus-at-unpause")&&(""==t.getAttribute("unfocus-at-unpause")?this.unfocus(t):this.unfocus("#"+t.getAttribute("unfocus-at-unpause")))},this.incrPause=()=>{let t=this.query('[pause], [auto-enter]:not([auto-enter="0"]), [immediate-enter]:not([immediate-enter="0"]), [step]');if(t){if(t.hasAttribute("step")){t.getAttribute("step")||t.setAttribute("step",1);let e=t.getAttribute("step");e<=1?(t.removeAttribute("step"),this.unpause(t)):t.setAttribute("step",e-1)}if(t.hasAttribute("auto-enter")&&(t.setAttribute("auto-enter",0),this.unpause(t)),t.hasAttribute("immediate-enter")&&(t.setAttribute("immediate-enter",0),this.unpause(t)),t.hasAttribute("pause")){t.getAttribute("pause")||t.setAttribute("pause",1);let e=t.getAttribute("pause");e<=1?(t.removeAttribute("pause"),this.unpause(t)):t.setAttribute("pause",e-1),this.updatePauseAncestors()}}},this.doAttributes=()=>{this.queryAll("*[mk-hidden-at]").forEach((t=>{t.getAttribute("mk-hidden-at").split(" ").map((t=>parseInt(t))).includes(h)&&(t.style.opacity="0")})),this.queryAll("*[mk-visible-at]").forEach((t=>{t.getAttribute("mk-visible-at").split(" ").map((t=>parseInt(t))).includes(h)&&(t.style.opacity="1")})),this.queryAll("*[mk-emphasize-at]").forEach((t=>{t.getAttribute("mk-emphasize-at").split(" ").map((t=>parseInt(t))).includes(h)&&t.classList.add("emphasize")})),this.queryAll("*[mk-unemphasize-at]").forEach((t=>{t.getAttribute("mk-unemphasize-at").split(" ").map((t=>parseInt(t))).includes(h)&&t.classList.remove("emphasize")})),this.queryAll("*[emphasize-at]").forEach((t=>{t.getAttribute("emphasize-at").split(" ").map((t=>parseInt(t))).includes(h)?t.classList.add("emphasize"):t.classList.remove("emphasize")})),this.queryAll("*[chg-visib-at]").forEach((t=>{let e=t.getAttribute("chg-visib-at").split(" ").map((t=>parseInt(t)));e.includes(h)&&(t.style.opacity="1"),e.includes(-h)&&(t.style.opacity="0")})),this.queryAll("*[static-at]").forEach((t=>{let e=t.getAttribute("static-at").split(" ").map((t=>parseInt(t)));h<0||(e.includes(-h)?this.makeUnStatic(t):e.includes(h)&&this.makeStatic(t))})),this.queryAll("*[down-at]").forEach((t=>{t.getAttribute("down-at").split(" ").map((t=>parseInt(t))).includes(h)&&this.moveDownTo(t,1)})),this.queryAll("*[up-at]").forEach((t=>{t.getAttribute("up-at").split(" ").map((t=>parseInt(t))).includes(h)&&this.moveUpTo(t,1)})),this.queryAll("*[center-at]").forEach((t=>{t.getAttribute("center-at").split(" ").map((t=>parseInt(t))).includes(h)&&this.moveCenterTo(t,1)})),this.queryAll("*[focus-at]").forEach((t=>{t.getAttribute("focus-at").split(" ").map((t=>parseInt(t))).includes(h)&&this.focus(t,1)})),this.queryAll("*[unfocus-at]").forEach((t=>{t.getAttribute("unfocus-at").split(" ").map((t=>parseInt(t))).includes(h)&&this.unfocus(t,1)})),this.queryAll("*[exec-at]").forEach((t=>{t.getAttribute("exec-at").split(" ").map((t=>parseInt(t))).includes(h)&&this.executeScript(t)})),this.queryAll("*[figure-next-at]").forEach((t=>{t.getAttribute("figure-next-at").split(" ").map((t=>parseInt(t))).includes(h)&&t.figureStep++})),this.queryAll("*[figure-previous-at]").forEach((t=>{t.getAttribute("figure-previous-at").split(" ").map((t=>parseInt(t))).includes(h)&&t.figureStep--}))},this.incrIndex=()=>{h+=1,this.doAttributes(),h>0&&this.incrPause(),this.updateToC()},this.next=function(){return!(h>=this.getMaxNext())&&(this.incrIndex(),"function"==typeof l[h]&&l[h](this),l[h]instanceof y?l[h]:!(this.pauseSlipList[h]instanceof y)||this.pauseSlipList[h])},this.previous=()=>{let t=this.getActionIndex();this.currentDelay,this.getEngine().setDoNotMove(!0);let e,i=this.element.className;if(this.doRefresh(),this.element.className=i,-1==t)return!1;for(;this.getActionIndex()<t-1;)e=this.next();return setTimeout((()=>{this.getEngine().setDoNotMove(!1)}),0),e},this.setTocElem=t=>{this.tocElem=t},this.updateToC=()=>{if(!this.tocElem)return;let t;for(this.ToCList||(this.ToCList=i(this.tocElem,"li","li")),t=0;t<this.getActionIndex();t++)this.ToCList[t].classList.remove("before","after","current"),this.ToCList[t].classList.add("before");for(t<=this.getActionIndex()&&(this.ToCList[t].classList.remove("before","after","current"),this.ToCList[t].classList.add("current"),t++);t<=this.getMaxNext();t++)this.ToCList[t].classList.remove("before","after","current"),this.ToCList[t].classList.add("after")},this.firstVisit=()=>{this.updateToC(),o.firstVisit&&o.firstVisit(this)},this.init=()=>{this.queryAll("*[chg-visib-at]").forEach((t=>{t.style.opacity="0"})),this.updatePauseAncestors(),o.init&&o.init(this)},this.refresh=()=>{l[h]instanceof y?l[h].refresh():this.doRefresh()},this.refreshAll=()=>{l.filter((t=>t instanceof y)).forEach((t=>{t.refreshAll()})),this.pauseSlipList.filter((t=>t instanceof y)).forEach((t=>{t.refreshAll()})),this.doRefresh()},this.doRefresh=()=>{this.setActionIndex(-1);let t=i(this.element,"slip-slip"),e=d.cloneNode(!0);n(e,t,this.sketchpadCanvas,this.sketchpadCanvasHighlight),this.element.replaceWith(e),this.element=e,this.init(),this.firstVisit(),delete this.currentX,delete this.currentY,delete this.currentDelay,this.getEngine().gotoSlip(this),setTimeout((()=>{this.reObserve()}),0)},this.reObserve=()=>{let t=this.element.firstChild;t&&t.classList&&t.classList.contains("slip-scale-container")&&this.resizeObserver.observe(t),this.getSubSlipList().forEach((t=>{t.reObserve()}))},this.makeUnStatic=(t,e,i)=>{let s=this.query(t);s.style.position="absolute",s.style.visibility="hidden"},this.makeStatic=t=>{let e=this.query(t);e.style.position="static",e.style.visibility="visible"},this.makeEmph=t=>{this.query(t).classList.add("emphasize")},this.makeUnEmph=t=>{this.query(t).classList.remove("emphasize")},this.unfocus=t=>{this.getEngine().gotoSlip(this,{delay:1})},this.focus=t=>{let e=this.query(t);this.getEngine().moveToElement(e,{})},this.executeScript=t=>{let e;e="string"==typeof t?this.query(t):t,new Function("slip",e.innerHTML)(this)},this.moveUpTo=(t,e,i)=>{setTimeout((()=>{let s;s="string"==typeof t?this.query(t):t,void 0===i&&(i=.0125);let n=this.findSlipCoordinate(),a=(s.offsetTop/1080-i)*n.scale;this.moveWindow(n.x,n.y+a,n.scale,this.rotate,e)}),0)},this.moveDownTo=(t,e,i)=>{setTimeout((()=>{let s;s="string"==typeof t?this.query(t):t,void 0===i&&(i=.0125);let n=this.findSlipCoordinate(),a=((s.offsetTop+s.offsetHeight)/1080-1+i)*n.scale;this.moveWindow(n.x,n.y+a,n.scale,this.rotate,e)}),0)},this.moveCenterTo=(t,e,i)=>{setTimeout((()=>{let s;s="string"==typeof t?this.query(t):t,void 0===i&&(i=0);let n=this.findSlipCoordinate(),a=((s.offsetTop+s.offsetHeight/2)/1080-.5+i)*n.scale;this.moveWindow(n.x,n.y+a,n.scale,this.rotate,e)}),0)},this.restoreWindow=()=>{this.getEngine},this.moveWindow=(t,e,i,s,n)=>{this.currentX=t,this.currentY=e,this.currentScale=i,this.currentDelay=n,this.getEngine().moveWindow(t,e,i,s,n)},this.reveal=t=>{let e;e="string"==typeof t?this.query(t):t,e.style.opacity="1"},this.revealAll=t=>{this.queryAll(t).forEach((t=>{t.style.opacity="1"}))},this.hide=t=>{this.query(t).style.opacity="0"},this.hideAll=t=>{this.queryAll(t).forEach((t=>{t.style.opacity="0"}))},this.tool="no-tool",this.getTool=t=>this.tool,this.setTool=t=>{if("clear-all"==t)return this.sketchpad.clear(),void this.sketchpadHighlight.clear();this.tool=t,this.element.classList.remove("drawing","highlighting"),"highlighting"==t?(this.element.classList.add("highlighting"),this.sketchpadHighlight.mode="draw"):"highlighting-erase"==t?(this.element.classList.add("highlighting"),this.sketchpadHighlight.mode="erase"):"drawing"==t?(this.element.classList.add("drawing"),this.sketchpad.mode="draw",this.sketchpad.weight=1):"drawing-erase"==t&&(this.element.classList.add("drawing"),this.sketchpad.weight=20,this.sketchpad.mode="erase")},this.color="blue",this.colorHighlight="yellow",this.getColor=()=>["highlighting","highlighting-erase"].includes(this.getTool())?this.colorHighlight:["drawing","drawing-erase"].includes(this.getTool())?this.color:"no-color",this.setColor=t=>{switch(this.getTool()){case"highlighting":case"highlighting-erase":this.colorHighlight=t,this.sketchpadHighlight.color=t;break;case"drawing":case"drawing-erase":this.color=t,this.sketchpad.color=t}},this.lineWidth="medium",this.lineWidthErase="medium",this.lineWidthHighlight="medium",this.getLineWidth=()=>["highlighting","highlighting-erase"].includes(this.getTool())?this.lineWidthHighlight:["drawing"].includes(this.getTool())?this.lineWidth:["drawing-erase"].includes(this.getTool())?this.lineWidthErase:"no-line-width",this.setLineWidth=t=>{if(["highlighting","highlighting-erase"].includes(this.getTool()))switch(this.lineWidthHighlight=t,t){case"small":this.sketchpadHighlight.weight=10;break;case"medium":this.sketchpadHighlight.weight=30;break;case"large":this.sketchpadHighlight.weight=90}else if(["drawing"].includes(this.getTool()))switch(this.lineWidth=t,t){case"small":this.sketchpad.weight=.25;break;case"medium":this.sketchpad.weight=1;break;case"large":this.sketchpad.weight=5}else if(["drawing-erase"].includes(this.getTool()))switch(this.lineWidthErase=t,t){case"small":this.sketchpad.weight=5;break;case"medium":this.sketchpad.weight=20;break;case"large":this.sketchpad.weight=80}};let c=r;this.getEngine=()=>c,this.setEngine=t=>c=t,this.element="string"==typeof t?document.querySelector("#"==t[0]?t:"#"+t):t,this.scale=parseFloat(this.element.getAttribute("scale")),(void 0===this.scale||isNaN(this.scale))&&(this.scale=1),this.rotate=parseFloat(this.element.getAttribute("rotate"))||0,this.delay=isNaN(parseFloat(this.element.getAttribute("delay")))?0:parseFloat(this.element.getAttribute("delay"));var u=this;let d,p=this.element;this.reloadCanvas=()=>{var t=this;let e=this.element;setTimeout((function(){let i=e.firstChild,s=document.createElement("canvas");s.classList.add("sketchpad","drawing"),s.style.opacity="1",t.sketchpadCanvas=s;let n=t.queryAll(".sketchpad");n[0].replaceWith(s);let a=new v(s);a.smoothing=.2,a.color="blue",t.sketchpad=a;let r=document.createElement("canvas");r.classList.add("sketchpad","sketchpad-highlighting"),r.style.opacity="0.5",t.sketchpadCanvasHighlight=r,n[1].replaceWith(r),t.sketchpadHighlight=new v(r),t.sketchpadHighlight.color="yellow",t.sketchpadHighlight.weight=30,t.sketchpadHighlight.smoothing=.2,t.resizeObserver=new ResizeObserver((e=>{s.height=i.offsetHeight/t.scale,s.width=i.offsetWidth/t.scale,r.height=i.offsetHeight/t.scale,r.width=i.offsetWidth/t.scale,t.sketchpad.smoothing=.2,t.sketchpad.color="blue",t.sketchpadHighlight.color="yellow",t.sketchpadHighlight.weight=30,t.sketchpadHighlight.smoothing=.2})),i&&i.classList&&i.classList.contains("slip-scale-container")&&t.resizeObserver.observe(i)}),0)},setTimeout((function(){let t=document.createElement("canvas");t.classList.add("sketchpad","drawing"),u.sketchpadCanvas=t,p&&p.firstChild&&p.firstChild.firstChild?p.firstChild.firstChild.appendChild(t):p.appendChild(t);let e=document.createElement("canvas");e.classList.add("sketchpad","sketchpad-highlighting"),u.sketchpadCanvasHighlight=e,p&&p.firstChild&&p.firstChild.firstChild?p.firstChild.firstChild.appendChild(e):p.appendChild(e),setTimeout((function(){u.reloadCanvas()}),0)}),0),this.name="string"==typeof t?t:t.id,"string"==typeof e?this.fullName=e:this.element.hasAttribute("toc-title")?this.fullName=this.element.getAttribute("toc-title"):this.fullName=this.name,"undefined"!=typeof MathJax?MathJax.startup.promise.then((()=>{setTimeout((()=>{d=s(this.element)}),0)})):setTimeout((()=>{d=s(this.element)}),0),this.getCloned=()=>d,this.setCloned=t=>d=t;let g=this.findSlipCoordinate();this.x=g.x,this.y=g.y,this.init(this,c),this.addSubSlips(),this.generatePauseFlowSlipList=function(){let t=[],e=this.queryAll("[pause], [step], [auto-enter], [immediate-enter]"),i=1;return e.forEach((e=>{if(e.hasAttribute("auto-enter")&&(t[i]=new y(e,e.getAttribute("toc-title")||"",[],r,{}),i++),e.hasAttribute("immediate-enter")&&(t[i-1]=new y(e,e.getAttribute("toc-title")||"",[],r,{}),i++),e.hasAttribute("step")){if(e.hasAttribute("enter-at-unpause"))if(""!=e.getAttribute("enter-at-unpause")){let s=this.query("#"+e.getAttribute("enter-at-unpause"));t[i]=new y(s,s.getAttribute("toc-title")||"",[],r,{})}else t[i+(parseInt(e.getAttribute("step"))||1)-1]=new y(e,e.getAttribute("toc-title")||"",[],r,{});i+=parseInt(e.getAttribute("step"))||1}if(e.hasAttribute("pause")){if(e.hasAttribute("enter-at-unpause"))if(""!=e.getAttribute("enter-at-unpause")){let s=this.query(e.getAttribute("enter-at-unpause"));t[i+(parseInt(e.getAttribute("step"))||1)-1]=new y(s,s.getAttribute("toc-title")||"",[],r,{})}else t[i+(parseInt(e.getAttribute("step"))||1)-1]=new y(e,e.getAttribute("toc-title")||"",[],r,{});i+=parseInt(e.getAttribute("pause"))||1}})),t},this.pauseSlipList=this.generatePauseFlowSlipList()}const w=function(t){"string"==typeof t?("#"!=t[0]&&(t="#"+t),t=document.querySelector(t)):void 0===t&&(t=document.querySelector("slip-slipshow")),function(t){let e=document.createElement("div");e.innerHTML='\t\n\t<div class="toc-slip" style="display:none;"></div>\n <div id="open-window">\n\t <div class="cpt-slip">0</div>\n\t <div class="slip-writing-toolbar">\n <div class="slip-toolbar-tool no-tool">\n <div class="slip-toolbar-pen">\n<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" focusable="false" width="20" height="20" style="-ms-transform: rotate(360deg); -webkit-transform: rotate(360deg); transform: rotate(360deg);" preserveAspectRatio="xMidYMid meet" viewBox="0 0 36 36"><path class="clr-i-outline clr-i-outline-path-1" d="M33.87 8.32L28 2.42a2.07 2.07 0 0 0-2.92 0L4.27 23.2l-1.9 8.2a2.06 2.06 0 0 0 2 2.5a2.14 2.14 0 0 0 .43 0l8.29-1.9l20.78-20.76a2.07 2.07 0 0 0 0-2.92zM12.09 30.2l-7.77 1.63l1.77-7.62L21.66 8.7l6 6zM29 13.25l-6-6l3.48-3.46l5.9 6z" fill="#000000"/><rect x="0" y="0" width="36" height="36" fill="rgba(0, 0, 0, 0)" /></svg>\n </div>\n <div class="slip-toolbar-highlighter">\n<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" focusable="false" width="25" height="25" style="-ms-transform: rotate(360deg); -webkit-transform: rotate(360deg); transform: rotate(360deg);" preserveAspectRatio="xMidYMid meet" viewBox="0 0 36 36"><path d="M15.82 26.06a1 1 0 0 1-.71-.29l-6.44-6.44a1 1 0 0 1-.29-.71a1 1 0 0 1 .29-.71L23 3.54a5.55 5.55 0 1 1 7.85 7.86L16.53 25.77a1 1 0 0 1-.71.29zm-5-7.44l5 5L29.48 10a3.54 3.54 0 0 0 0-5a3.63 3.63 0 0 0-5 0z" class="clr-i-outline clr-i-outline-path-1" fill="#000000"/><path d="M10.38 28.28a1 1 0 0 1-.71-.28l-3.22-3.23a1 1 0 0 1-.22-1.09l2.22-5.44a1 1 0 0 1 1.63-.33l6.45 6.44A1 1 0 0 1 16.2 26l-5.44 2.22a1.33 1.33 0 0 1-.38.06zm-2.05-4.46l2.29 2.28l3.43-1.4l-4.31-4.31z" class="clr-i-outline clr-i-outline-path-2" fill="#000000"/><path d="M8.94 30h-5a1 1 0 0 1-.84-1.55l3.22-4.94a1 1 0 0 1 1.55-.16l3.21 3.22a1 1 0 0 1 .06 1.35L9.7 29.64a1 1 0 0 1-.76.36zm-3.16-2h2.69l.53-.66l-1.7-1.7z" class="clr-i-outline clr-i-outline-path-3" fill="#000000"/><rect x="0" y="0" width="36" height="36" fill="rgba(0, 0, 0, 0)" /></svg>\n</div>\n <div class="slip-toolbar-eraser">\n<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" focusable="false" width="20" height="20" style="-ms-transform: rotate(360deg); -webkit-transform: rotate(360deg); transform: rotate(360deg);" preserveAspectRatio="xMidYMid meet" viewBox="0 0 36 36"><path d="M35.62 12a2.82 2.82 0 0 0-.84-2l-7.29-7.35a2.9 2.9 0 0 0-4 0L2.83 23.28a2.84 2.84 0 0 0 0 4L7.53 32H3a1 1 0 0 0 0 2h25a1 1 0 0 0 0-2H16.74l18-18a2.82 2.82 0 0 0 .88-2zM13.91 32h-3.55l-6.11-6.11a.84.84 0 0 1 0-1.19l5.51-5.52l8.49 8.48zm19.46-19.46L19.66 26.25l-8.48-8.49l13.7-13.7a.86.86 0 0 1 1.19 0l7.3 7.29a.86.86 0 0 1 .25.6a.82.82 0 0 1-.25.59z" class="clr-i-outline clr-i-outline-path-1" fill="#000000"/><rect x="0" y="0" width="36" height="36" fill="rgba(0, 0, 0, 0)" /></svg>\n</div>\n <div class="slip-toolbar-cursor">\n<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" focusable="false" width="20" height="20" style="-ms-transform: rotate(360deg); -webkit-transform: rotate(360deg); transform: rotate(360deg);" preserveAspectRatio="xMidYMid meet" viewBox="0 0 36 36"><path class="clr-i-outline clr-i-outline-path-1" d="M14.58 32.31a1 1 0 0 1-.94-.65L4 5.65a1 1 0 0 1 1.25-1.28l26 9.68a1 1 0 0 1-.05 1.89l-8.36 2.57l8.3 8.3a1 1 0 0 1 0 1.41l-3.26 3.26a1 1 0 0 1-.71.29a1 1 0 0 1-.71-.29l-8.33-8.33l-2.6 8.45a1 1 0 0 1-.93.71zm3.09-12a1 1 0 0 1 .71.29l8.79 8.79L29 27.51l-8.76-8.76a1 1 0 0 1 .41-1.66l7.13-2.2L6.6 7l7.89 21.2l2.22-7.2a1 1 0 0 1 .71-.68z" fill="#000000"/><rect x="0" y="0" width="36" height="36" fill="rgba(0, 0, 0, 0)" /></svg>\n</div>\n </div>\n <div class="slip-toolbar-color">\n <div class="slip-toolbar-black"></div>\n <div class="slip-toolbar-blue"></div>\n <div class="slip-toolbar-red"></div>\n <div class="slip-toolbar-green"></div>\n <div class="slip-toolbar-yellow"></div>\n </div>\n\n <div class="slip-toolbar-width">\n <div class="slip-toolbar-small"><div></div></div>\n <div class="slip-toolbar-medium"><div></div></div>\n <div class="slip-toolbar-large"><div></div></div>\n </div>\n <div class="slip-toolbar-control">\n \x3c!-- <div class="slip-toolbar-stop">✓</div> --\x3e\n <div class="slip-toolbar-clear">✗</div>\n </div>\n </div>\n\t <div class="format-container">\n\t <div class="rotate-container">\n\t\t<div class="scale-container">\n\t\t <div class="universe movable" id="universe">\n\t\t\t<div width="10000" height="10000" class="fog"></div>\n <div class="placeHolder"></div>\n\t\t </div>\n\t\t</div>\n </div>\n\t </div>\n\t</div>',t.replaceWith(e),e.querySelector(".placeHolder").replaceWith(t),t.querySelectorAll("slip-slip").forEach((t=>{setTimeout((()=>{var e=document.createElement("div"),i=document.createElement("div");let s;for(e.classList.add("slip-scale-container"),i.classList.add("slip-container");s=t.firstChild;)i.appendChild(s);e.appendChild(i),t.appendChild(e),setTimeout((()=>{}),0)}),0)})),t.style.width="unset",t.style.height="unset"}(t),document.body.style.cursor="auto";let e=[];document.body.addEventListener("mousemove",(t=>{e.forEach((t=>{clearTimeout(t)})),document.body.style.cursor="auto",e.push(setTimeout((()=>{document.body.style.cursor="none"}),5e3))}));let s,n,a,o,l,h,c,u,d=document.querySelector("#open-window"),p=document.querySelector("#universe"),g=p.querySelectorAll("slip-slip:not(slip-slipshow)");this.getOpenWindowHeight=()=>o,this.getOpenWindowWidth=()=>n,this.getCoord=()=>({x:l,y:h,scale:c});let m=!1;this.setDoNotMove=t=>m=t,this.getDoNotMove=t=>m;let f=!1;function v(t,e){if(1==e||e>3)return t.toString();let i,s="",n=[1e3,900,500,400,100,90,50,40,10,9,5,4,1];i=0==e?["M","CM","D","CD","C","XC","L","XL","X","IX","V","IV","I"]:["m","cm","d","cd","c","xc","l","xl","x","ix","v","iv","i"];for(var a=0;a<=n.length;a++)for(;t%n[a]<t;)s+=i[a],t-=n[a];return s}this.setAlwaysMoveFast=t=>{setTimeout((()=>{f=t}),0)},this.getAlwaysMoveFast=t=>f,this.moveWindow=function(t,e,i,s,n){if(this.getDoNotMove())return;let a=n;this.getAlwaysMoveFast()&&(a="0"),c=i,u=s,l=t,h=e,setTimeout((()=>{document.querySelector(".scale-container").style.transitionDuration=a+"s",document.querySelector(".rotate-container").style.transitionDuration=a+"s",p.style.transitionDuration=a+"s, "+a+"s",setTimeout((()=>{p.style.left=-(1440*t-720)+"px",p.style.top=-(1080*e-540)+"px",document.querySelector(".scale-container").style.transform="scale("+1/i+")",document.querySelector(".rotate-container").style.transform="rotate("+s+"deg)"}),0)}),0)},this.moveWindowRelative=function(t,e,i,s,n){this.moveWindow(l+t,h+e,c+i,u+s,n)},this.placeSlip=function(t){let e=parseFloat(t.getAttribute("scale")),i=t.querySelector(".slip-scale-container");e=isNaN(e)?1:e,i.style.transform="scale("+e+")";new ResizeObserver((s=>{t.style.width=Math.max(i.offsetWidth,1440)*e+"px",t.style.height=Math.max(i.offsetHeight,1080)*e+"px"})).observe(i)},this.placeSlips=function(){let t=function(e){return 1+i(e,"slip-slip").map(t).reduce(((t,e)=>Math.max(t,e)),0)},e=t(document.body);for(let t=0;t<e;t++)g.forEach(this.placeSlip)},setTimeout((()=>{this.placeSlips()}),0),this.placeOpenWindow=function(){s=window.innerHeight,a=window.innerWidth,s/3<a/4?(n=Math.floor(4*s/3),o=s,d.style.left=(window.innerWidth-n)/2+"px",d.style.right=(window.innerWidth-n)/2+"px",d.style.width=n+"px",d.style.top="0",d.style.bottom="0",d.style.height=o+"px"):(o=Math.floor(3*a/4),n=a,d.style.top=(window.innerHeight-o)/2+"px",d.style.bottom=(window.innerHeight-o)/2+"px",d.style.height=o+"px",d.style.right="0",d.style.left="0",d.style.width=n+"px"),document.querySelector(".scale-container").style.transformOrigin="720px 540px",document.querySelector(".rotate-container").style.transformOrigin="720px 540px",document.querySelector(".format-container").style.transform="scale("+n/1440+")",document.querySelector(".cpt-slip").style.right=parseInt(d.style.left)+"px",document.querySelector(".cpt-slip").style.bottom="0",document.querySelector(".cpt-slip").style.zIndex="10"},this.placeOpenWindow(),window.addEventListener("resize",(t=>{this.placeOpenWindow(),this.moveWindow(l,h,c,u,0)})),this.countersToString=t=>{let e="";e+=v(t[0]+1,0);for(let i=1;i<t.length;i++)e+="."+v(t[i]+1,i);return e},this.updateCounter=function(){let t=A.map((t=>t.getActionIndex())),e=t.join(",");window.parent!==window?this.send_stage&&window.parent.postMessage({id:this.id,kind:"state",data:e},"*"):window.history.replaceState(null,null,"#"+e),document.querySelector(".cpt-slip").innerHTML=this.countersToString(t)},this.enter=t=>{this.gotoSlip(t),this.push(t),this.next()},this.next=()=>{""==document.querySelector(".toc-slip").innerHTML&&this.showToC();let t=this.getCurrentSlip().next();if(this.updateCounter(),t instanceof y)return this.enter(t),!0;if(!t){this.pop();let t=this.getCurrentSlip();return t.nextStageNeedGoto()&&this.gotoSlip(t),A.length>1||t.getActionIndex()<t.getMaxNext()?this.next():this.gotoSlip(t),!0}return!1},this.nextSlip=function(){for(;!this.next(););},this.previous=t=>{let e=this.getCurrentSlip(),i=e.previous();if(i instanceof y){for(;i.getCurrentSubSlip()instanceof y;)this.push(i),i=i.getCurrentSubSlip();return this.push(i),this.gotoSlip(i,t),this.updateCounter(),!0}if(!i){this.pop();let i=this.getCurrentSlip();return A.length>1||i.getActionIndex()>-1?this.previous({delay:e.currentDelay?e.currentDelay:e.delay}):this.gotoSlip(i,t),this.updateCounter(),!0}return t&&setTimeout((()=>{this.gotoSlip(e,t)}),0),setTimeout((()=>{this.gotoSlip(e,t)}),0),this.updateCounter(),!1},this.previousSlip=function(){for(;!this.previous(););},this.getCoordinateInUniverse=function(t){let e=1,i=function(t){return"none"==t?1:parseFloat(t.split("(")[1].split(",")[0])},s=t=>{let n=(t=>({x:t.offsetLeft,y:t.offsetTop}))(t);if(!t.offsetParent)return{x:0,y:0,centerX:0,centerY:0,width:0,height:0,scale:0};if(t.offsetParent.classList.contains("universe"))return n;let a,r=s(t.offsetParent),o=window.getComputedStyle(t.offsetParent);return a=i(o.transform),e*=a,{x:r.x+n.x*e,y:r.y+n.y*e}},n=s(t),a=window.getComputedStyle(t),r=i(a.transform);return e*=r,{x:n.x/1440,y:n.y/1080,centerX:n.x/1440+.5*t.offsetWidth/1440*e,centerY:n.y/1080+.5*t.offsetHeight/1080*e,width:t.offsetWidth/1440*e,height:t.offsetHeight/1080*e,scale:e}},this.moveToElement=function(t,e){let i=this.getCoordinateInUniverse(t);t.offsetWidth,i.scale,t.offsetHeight,i.scale,e&&this.moveWindow(i.centerX,i.centerY,Math.max(i.width,i.height),0,e.delay?e.delay:1)},this.gotoSlip=function(t,e){e=e||{},"SLIP-SLIP"==t.element.tagName?setTimeout((()=>{let i=t.findSlipCoordinate();void 0!==t.currentX&&void 0!==t.currentY&&void 0!==t.currentScale?this.moveWindow(t.currentX,t.currentY,t.currentScale,t.rotate,void 0!==e.delay?e.delay:void 0!==t.currentDelay?t.currentDelay:t.delay):(t.currentX=i.x,t.currentY=i.y,t.currentDelay=t.delay,this.moveWindow(i.x,i.y,i.scale,t.rotate,void 0!==e.delay?e.delay:void 0!==t.currentDelay?t.currentDelay:t.delay))}),0):setTimeout((()=>{let i=this.getCoordinateInUniverse(t.element);this.moveWindow(i.centerX,i.centerY,Math.max(i.width,i.height),0,void 0!==e.delay?e.delay:t.delay)}),0)};let w,b=new y(t,"Presentation",[],this,{}),A=[b];this.push=function(t){this.getToC().querySelectorAll(".toc-slip .active-slip").forEach((t=>t.classList.remove("active-slip"))),t.tocElem&&t.tocElem.classList.add("active-slip"),t.element.classList.add("active-true-slip"),A.length>0&&A[A.length-1].element.classList.remove("active-true-slip"),A.push(t)},this.pop=function(){this.getToC().querySelectorAll(".toc-slip .active-slip").forEach((t=>t.classList.remove("active-slip")));let t=A.pop();return t.element.classList.remove("active-true-slip"),0==A.length&&A.push(t),A[A.length-1].element.classList.add("active-true-slip"),A[A.length-1].tocElem&&A[A.length-1].tocElem.classList.add("active-slip"),t},this.getCurrentSlip=function(){return A[A.length-1]},this.getSlipTree=function(t){return(t=t||b)instanceof y?{name:t.name,slip:t,subslips:t.getActionList().map((t=>this.getSlipTree(t)))}:{function:!0}},this.goToState=function(t){let e=t=>{if(0!=t.length)for(e(t[0]);t[1].getActionIndex()<t[2];)this.next()};A=[b],b.refreshAll(),e(t),this.gotoSlip(t[1])},this.getToC=function(){return w||(w=document.querySelector(".toc-slip"),w)},this.showToC=function(){let t=document.querySelector(".toc-slip");document.createElement("div");let e=this.getSlipTree(),i=(t,e)=>{let s=document.createElement("div"),n=document.createElement("div");if(n.innerText=t.slip.fullName,s.appendChild(n),t.subslips.length>0){let n=document.createElement("ul");t.subslips.forEach(((s,a)=>{let r=[e,t.slip,a],o=document.createElement("li");if(s.function){let t=e=>0==e.length?[]:t(e[0]).concat([e[2]]);o.innerText=this.countersToString(t(r)),o.classList.add("toc-function")}else o.appendChild(i(s,r));o.addEventListener("click",(t=>{t.target==o&&this.goToState(r)})),n.appendChild(o)})),s.appendChild(n),t.slip.setTocElem(s)}return s};t.innerHTML="",t.appendChild(i(e,[]))},this.getTool=()=>this.getCurrentSlip().getTool(),this.setTool=t=>{this.getCurrentSlip().setTool(t),this.updateToolClasses()},this.getColor=()=>this.getCurrentSlip().getColor(),this.setColor=t=>{this.getCurrentSlip().setColor(t),this.updateToolClasses()},this.setLineWidth=t=>{this.getCurrentSlip().setLineWidth(t),this.updateToolClasses()},this.getLineWidth=()=>this.getCurrentSlip().getLineWidth(),this.reloadCanvas=()=>{this.getCurrentSlip().reloadCanvas()};let S=this;this.updateToolClasses=()=>{document.querySelector(".slip-toolbar-tool").classList.remove("drawing","highlighting","drawing-erase","highlighting-erase","no-tool"),"no-tool"==this.getTool()||"cursor"==this.getTool()?document.querySelector(".slip-writing-toolbar").classList.remove("active"):document.querySelector(".slip-writing-toolbar").classList.add("active"),document.querySelector(".slip-toolbar-tool").classList.add(this.getTool()),document.querySelector(".slip-toolbar-color").classList.remove("black","blue","red","green","yellow"),document.querySelector(".slip-toolbar-color").classList.add(this.getColor()),document.querySelector(".slip-toolbar-width").classList.remove("small","medium","large"),document.querySelector(".slip-toolbar-width").classList.add(this.getLineWidth())},setTimeout((function(){document.querySelector(".slip-toolbar-pen").addEventListener("click",(function(t){S.setTool("drawing")})),document.querySelector(".slip-toolbar-cursor").addEventListener("click",(function(t){S.setTool("no-tool")})),document.querySelector(".slip-toolbar-eraser").addEventListener("click",(function(t){switch(S.getTool()){case"drawing-erase":S.setTool("drawing");break;case"highlighting":S.setTool("highlighting-erase");break;case"highlighting-erase":S.setTool("highlighting");break;case"no-tool":S.setTool("no-tool");break;case"drawing":S.setTool("drawing-erase")}})),document.querySelector(".slip-toolbar-highlighter").addEventListener("click",(function(t){S.setTool("highlighting")})),document.querySelector(".slip-toolbar-black").addEventListener("click",(function(t){S.setColor("black")})),document.querySelector(".slip-toolbar-blue").addEventListener("click",(function(t){S.setColor("blue")})),document.querySelector(".slip-toolbar-red").addEventListener("click",(function(t){S.setColor("red")})),document.querySelector(".slip-toolbar-green").addEventListener("click",(function(t){S.setColor("green")})),document.querySelector(".slip-toolbar-yellow").addEventListener("click",(function(t){S.setColor("yellow")})),document.querySelector(".slip-toolbar-small").addEventListener("click",(function(t){S.setLineWidth("small")})),document.querySelector(".slip-toolbar-medium").addEventListener("click",(function(t){S.setLineWidth("medium")})),document.querySelector(".slip-toolbar-large").addEventListener("click",(function(t){S.setLineWidth("large")})),document.querySelector(".slip-toolbar-clear").addEventListener("click",(function(t){S.setTool("clear-all")}))}),0),this.setRootSlip=t=>{b=t,A=[b]},this.getRootSlip=()=>b,this.send_stage=!1,this.start=async(t,e)=>{if(this.id=e,A=[b],window.location.hash||t){let e;e=window.location.hash?window.location.hash.slice(1).split(",").map((t=>parseInt(t))):t,this.setAlwaysMoveFast(!0),console.log("alwaysMoveFast",this.getAlwaysMoveFast());let i=()=>new Promise((function(t){setTimeout(t,0)})),s=-1,n=0,a=1,r=function(){let t=A.map((t=>t.getActionIndex())),i=s;return e.forEach(((e,r)=>{i==s&&(e<t[r]&&(i=a),e>t[r]&&(i=n))})),i};for(;r()==n;)await i(),await this.next();this.setAlwaysMoveFast(!1)}else this.next();return this.send_stage=!0,window.parent!==window&&window.parent.postMessage({id:e,kind:"ready",data:e},"*"),this},this.restart=()=>{A=[b],b.refreshAll(),this.next()};let x=new r(this);this.getController=()=>x,window.addEventListener("message",(t=>{console.log(t),this.restart();let e=t.data.split(",").map((t=>parseInt(t)));this.setAlwaysMoveFast(!0),console.log("alwaysMoveFast",this.getAlwaysMoveFast());let i=function(){let t=A.map((t=>t.getActionIndex())),i=-1;return e.forEach(((e,s)=>{-1==i&&(e<t[s]&&(i=1),e>t[s]&&(i=0))})),i};for(;0==i();)this.next();this.setAlwaysMoveFast(!1)}))},b=r,A=y,S=a;return t.Controller=b,t.Engine=w,t.Slip=A,t.Util=S,t.startSlipshow=async(t,e)=>{let i;return"undefined"!=typeof MathJax?MathJax.startup.promise.then((()=>(i=new w(document.querySelector("slip-slipshow")).start(t,e),Promise.resolve(i)))):(i=new w(document.querySelector("slip-slipshow")).start(t,e),Promise.resolve(i))},t}({}); //# sourceMappingURL=slipshow.cdn.min.js.map