presenter 0.5.2 → 0.5.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/418.js +2 -0
- package/dist/418.js.LICENSE.txt +1 -0
- package/dist/661.js +1 -1
- package/dist/presenter-code.js +1 -1
- package/dist/presenter-export.js +1 -1
- package/dist/presenter-export.js.LICENSE.txt +1 -1
- package/dist/presenter.js +1 -1
- package/dist/src/code/codeBlock.d.ts +25 -0
- package/dist/src/index.d.ts +1 -0
- package/dist/src/objects/circle.d.ts +12 -0
- package/dist/src/objects/group.d.ts +7 -0
- package/dist/src/objects/line.d.ts +2 -0
- package/dist/src/objects/mask.d.ts +13 -0
- package/dist/src/objects/path.d.ts +3 -1
- package/dist/src/objects/rectangle.d.ts +12 -0
- package/dist/src/objects/text.d.ts +5 -1
- package/dist/src/presentation/object.d.ts +1 -0
- package/dist/src/util/richText.d.ts +1 -0
- package/package.json +2 -2
- package/dist/838.js +0 -2
- package/dist/838.js.LICENSE.txt +0 -1
package/dist/presenter-code.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(t,n){"object"==typeof exports&&"object"==typeof module?module.exports=n():"function"==typeof define&&define.amd?define([],n):"object"==typeof exports?exports.PresenterCode=n():t.PresenterCode=n()}(this,(()=>(()=>{"use strict";var t={d:(n,e)=>{for(var o in e)t.o(e,o)&&!t.o(n,o)&&Object.defineProperty(n,o,{enumerable:!0,get:e[o]})},o:(t,n)=>Object.prototype.hasOwnProperty.call(t,n),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},n={};t.r(n),t.d(n,{CodeBlock:()=>m});var e,o=function(){function t(t,n,e){this.origin=t,this.width=n,this.height=e}return t.fromElement=function(n){var e=n.getBBox();return new t({x:e.x,y:e.y},e.width,e.height)},t}(),r=function(){return r=Object.assign||function(t){for(var n,e=1,o=arguments.length;e<o;e++)for(var r in n=arguments[e])Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r]);return t},r.apply(this,arguments)},i=function(){function t(t){this.props=r({position:{x:0,y:0},anchor:"topleft"},t),this.initialProps=r({},this.props),this._element=null,this._presentation=null,this._children=[]}return t.prototype.tagName=function(){return"g"},t.prototype.attributes=function(){return{}},t.prototype.additionalAttributes=function(){return{}},t.prototype.styles=function(){var t=this.props.opacity;return r({},void 0!==t?{opacity:t.toString()}:{})},t.prototype.children=function(){return[]},t.prototype.requiresChildrenUpdate=function(t){return!1},t.prototype.positionAttributes=function(t){if(null===this._presentation)throw new Error("Cannot compute object position attributes without presentation");var n=this.positionInPresentation(t.origin),e=n.x,r=n.y,i=this.anchorBoundingBox(new o({x:e,y:r},t.width,t.height));return{x:i.origin.x,y:i.origin.y}},t.prototype.generate=function(t){this.props=r({},this.initialProps),this._presentation=t;for(var n=this.createElement(),e=0,o=Object.entries(this.attributes());e<o.length;e++){var i=o[e],a=i[0],s=i[1];n.setAttribute(a,s)}for(var c=0,l=Object.entries(this.styles());c<l.length;c++){var u=l[c],p=u[0];s=u[1],n.style.setProperty(p,s)}this._children=this.children();for(var h=0,f=this._children;h<f.length;h++){var d=f[h];n.appendChild(d)}this._element=n;for(var g=0,y=Object.entries(this.additionalAttributes());g<y.length;g++){var v=y[g];a=v[0],s=v[1],n.setAttribute(a,s)}return n},t.prototype.createElement=function(){return document.createElementNS("http://www.w3.org/2000/svg",this.tagName())},t.prototype.element=function(){if(null===this._element)throw new Error("Element not yet generated");return this._element},t.prototype.animate=function(t,n,e,o){var i=this;return void 0===n&&(n={}),void 0===e&&(e=null),void 0===o&&(o=!0),function(a){if(null===i._presentation)throw new Error("Cannot animate object without presentation");var s=i.requiresChildrenUpdate(t);i.props=r(r({},i.props),t),s&&(i._children=i.children());var c=i.attributes(),l=i.styles(),u=i.additionalAttributes(),p=Object.fromEntries(Object.entries(c).filter((function(t){var n=t[0],e=t[1];return i._element.getAttribute(n)!==e}))),h=Object.fromEntries(Object.entries(l).filter((function(t){var n=t[0],e=t[1];return i._element.style.getPropertyValue(n)!==e}))),f=Object.fromEntries(Object.entries(u).filter((function(t){var n=t[0],e=t[1];return i._element.getAttribute(n)!==e})));a(r(r(r({animate:o,element:i.element(),attributes:r(r({},p),f),styles:h},null!==e?{delay:e}:{}),s?{children:i._children}:{}),{animationParams:r(r({duration:500,easing:"linear"},n),"cubic"===n.easing?{easing:"cubicBezier(0.42, 0, 0.58, 1)"}:{})}))}},t.prototype.set=function(t,n){return void 0===n&&(n=null),this.animate(t,{},n,!1)},t.prototype.move=function(t,n){return void 0===n&&(n={}),this.animate({position:t},n)},t.prototype.fadeIn=function(t){return void 0===t&&(t={}),this.animate({opacity:1},t)},t.prototype.fadeOut=function(t){return void 0===t&&(t={}),this.animate({opacity:0},t)},t.prototype.show=function(){return this.set({opacity:1})},t.prototype.hide=function(){return this.set({opacity:0})},t.prototype.positionInPresentation=function(t){var n=this._presentation,e=t.x,o=t.y;return e<=1&&e>=-1&&(e*=n.boundingBox.width),o<=1&&o>=-1&&(o*=n.boundingBox.height),{x:e,y:o}},t.prototype.anchorBoundingBox=function(t){var n=this,e=function(){switch(n.props.anchor){case"topleft":case"top":case"topright":return t.origin.y;case"left":case"center":case"right":return t.origin.y-t.height/2;case"bottomleft":case"bottom":case"bottomright":return t.origin.y-t.height}}(),r=function(){switch(n.props.anchor){case"topleft":case"left":case"bottomleft":return t.origin.x;case"top":case"center":case"bottom":return t.origin.x-t.width/2;case"topright":case"right":case"bottomright":return t.origin.x-t.width}}();return new o({x:r,y:e},t.width,t.height)},t.prototype.computeRenderedBoundingBox=function(t,n){void 0===n&&(n=null);var e=this._presentation.computeRenderedBoundingBox(t,n);return new o({x:this.props.position.x,y:this.props.position.y},e.width,e.height)},t}(),a=(e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},e(t,n)},function(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function o(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(o.prototype=n.prototype,new o)}),s=function(){return s=Object.assign||function(t){for(var n,e=1,o=arguments.length;e<o;e++)for(var r in n=arguments[e])Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r]);return t},s.apply(this,arguments)},c=function(t){function n(n,e,o){return void 0===e&&(e={}),void 0===o&&(o=null),t.call(this,s({objects:n,position:{x:0,y:0},positioned:null===o?"position"in e:o,rotation:0,rotationOrigin:{x:0,y:0},scale:1,skewX:0,skewY:0},e))||this}return a(n,t),n.prototype.tagName=function(){return"g"},n.prototype.attributes=function(){return s({},t.prototype.attributes.call(this))},n.prototype.additionalAttributes=function(){var t=this.props,n=t.rotation,e=t.rotationOrigin,r=t.scale,i=t.skewX,a=t.skewY,s="rotate(".concat(n,", ").concat(e.x,", ").concat(e.y,")"),c="scale(".concat(r,")"),l="".concat(0!==i?"skewX(".concat(i,")"):""," ").concat(0!==a?"skewY(".concat(a,")"):"");if(!this.props.positioned){var u=this.positionInPresentation(this.props.position),p=u.x,h=u.y;return{transform:"translate(".concat(p,", ").concat(h,") ").concat(s," ").concat(c," ").concat(l)}}var f=this._presentation.computeRenderedBoundingBox(this._element);f.width*=r,f.height*=r;var d=this.positionInPresentation(this.props.position),g=d.x,y=d.y,v=this.anchorBoundingBox(new o({x:g,y},f.width,f.height)),b=v.origin.x-f.origin.x,m=v.origin.y-f.origin.y;return{transform:"translate(".concat(b,", ").concat(m,") ").concat(s," ").concat(c," ").concat(l)}},n.prototype.children=function(){var t=this;return this.props.objects.map((function(n){return n.generate(t._presentation),n._element}))},n}(i),l=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function o(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(o.prototype=e.prototype,new o)}}(),u=function(){return u=Object.assign||function(t){for(var n,e=1,o=arguments.length;e<o;e++)for(var r in n=arguments[e])Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r]);return t},u.apply(this,arguments)},p=function(t){function n(n){return void 0===n&&(n={}),t.call(this,u({fill:"#000000",width:100,height:100,rounding:0,borderWidth:0,borderColor:"#000000"},n))||this}return l(n,t),n.prototype.tagName=function(){return"rect"},n.prototype.attributes=function(){var n=this.props,e=n.position,r=n.width,i=n.height,a=n.fill,s=n.rounding,c=n.borderWidth,l=n.borderColor,p=this.positionAttributes(new o(e,r,i)),h=p.x,f=p.y;return u(u(u({},t.prototype.attributes.call(this)),{fill:a,width:r.toString(),height:i.toString(),rx:s.toString(),x:h.toString(),y:f.toString()}),c>0?{"stroke-width":c.toString(),stroke:l}:{})},n}(i);function h(t,n,e){void 0===n&&(n="1em"),void 0===e&&(e="start");for(var o=[],r=0,i=0,a=t;i<a.length;i++){var s=a[i];r++;var c=document.createElementNS("http://www.w3.org/2000/svg","tspan");if(c.setAttribute("x","0"),c.setAttribute("text-anchor",e),r>1&&c.setAttribute("dy",n),0===s.length||1===s.length&&""===s[0])c.appendChild(document.createTextNode(" ")),o.push(c);else if("string"!=typeof s){for(var l=0,u=s;l<u.length;l++){var p=u[l];if("string"==typeof p)c.appendChild(document.createTextNode(p));else{var h=p[0],f=p[1],d=document.createElementNS("http://www.w3.org/2000/svg","tspan");d.textContent=h;for(var g={fill:f.color,dy:f.dy,"text-decoration":f.textDecoration},y=0,v=Object.entries(g);y<v.length;y++){var b=v[y],m=b[0];void 0!==(_=b[1])&&d.setAttribute(m,_.toString())}var w={"font-family":f.fontFamily?'"'.concat(f.fontFamily,'"'):void 0,"font-size":f.fontSize,"font-weight":f.fontWeight,"font-style":f.fontStyle};!0===f.superscript?(w["baseline-shift"]="super",void 0===w["font-size"]&&(w["font-size"]="50%")):!0===f.subscript&&(w["baseline-shift"]="sub",void 0===w["font-size"]&&(w["font-size"]="50%"));for(var x=0,O=Object.entries(w);x<O.length;x++){var _,j=O[x];m=j[0],void 0!==(_=j[1])&&d.style.setProperty(m,_.toString())}c.appendChild(d)}}o.push(c)}else c.appendChild(document.createTextNode(s)),o.push(c)}return o}var f=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function o(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(o.prototype=e.prototype,new o)}}(),d=function(){return d=Object.assign||function(t){for(var n,e=1,o=arguments.length;e<o;e++)for(var r in n=arguments[e])Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r]);return t},d.apply(this,arguments)},g=function(t){function n(n,e){return void 0===e&&(e={}),t.call(this,d({content:n,color:"#000000",fontSize:150,fontStyle:"normal",fontWeight:"normal",fontFamily:"Arial",baselineHeight:.22,dominantBaseline:"ideographic",textDecoration:"none",length:null,align:"left",lineSpacing:"1em",ligatures:null},e))||this}return f(n,t),n.prototype.isRichText=function(){return"string"!=typeof this.props.content},n.prototype.tagName=function(){return"text"},n.prototype.attributes=function(){var n=this.props,e=n.color,o=n.textDecoration;return d(d(d({},t.prototype.attributes.call(this)),"none"!==o?{"text-decoration":o}:{}),{fill:e})},n.prototype.additionalAttributes=function(){var n=this.computeRenderedBoundingBox(this.element(),this.childrenWithContentLength(this.contentLength())),e=this.positionAttributes(n),o=e.x,r=e.y;return this.isRichText()&&("center"===this.props.align?o+=n.width/2:"right"===this.props.align&&(o+=n.width)),r-=this.props.fontSize*this.props.baselineHeight,d(d({},t.prototype.additionalAttributes.call(this)),this.isRichText()?{transform:"translate(".concat(o.toString()," ").concat(r.toString(),")"),y:this.computeRenderedBoundingBox(this.element(),this.childrenWithContentLength(1)).height.toString()}:{x:o.toString(),y:(r+n.height).toString()})},n.prototype.styles=function(){var n=this.props,e=n.fontSize,o=n.fontFamily,r=n.fontStyle,i=n.fontWeight,a=n.ligatures;return d(d(d(d(d({},t.prototype.styles.call(this)),"normal"!==r?{"font-style":r}:{}),"normal"!==i?{"font-weight":i.toString()}:{}),null!==a?{"font-variant-ligatures":a}:{}),{"font-size":"".concat(e,"px"),"font-family":'"'.concat(o,'"'),"white-space":"pre"})},n.prototype.children=function(){var t,n=null!==(t=this.props.length)&&void 0!==t?t:this.contentLength();return this.childrenWithContentLength(n)},n.prototype.requiresChildrenUpdate=function(t){return"content"in t&&t.content!==this.props.content||"length"in t&&t.length!==this.props.length},n.prototype.contentLength=function(){return"string"==typeof this.props.content?this.props.content.length:this.props.content.reduce((function(t,n){return"string"==typeof n?t+n.length:t+n.reduce((function(t,n){return t+("string"==typeof n?n:n[0]).length}),0)}),0)},n.prototype.childrenWithContentLength=function(t){var n=this.props.content;if("string"==typeof n){var e=null===t?n:n.slice(0,t);return[document.createTextNode(e)]}var o="left"===this.props.align?"start":"center"===this.props.align?"middle":"end";if(null===t)return h(n,this.props.lineSpacing,o);for(var r=t,i=[],a=0,s=n;a<s.length;a++){var c=s[a];if("string"==typeof c)c.length<=r?(i.push(c),r-=c.length):(i.push(c.slice(0,r)),r=0);else{for(var l=[],u=0,p=c;u<p.length;u++){var f=p[u];if("string"==typeof f?f.length<=r?(l.push(f),r-=f.length):(l.push(f.slice(0,r)),r=0):f[0].length<=r?(l.push(f),r-=f[0].length):(l.push([f[0].slice(0,r),f[1]]),r=0),0===r)break}i.push(l)}if(0===r)break}return h(i,this.props.lineSpacing,o)},n.prototype.regenerateChildren=function(){this._children=this.children(),this._element.innerHTML="";for(var t=0,n=this._children;t<n.length;t++){var e=n[t];this._element.appendChild(e)}},n.prototype.animate=function(n,e,o,r){var i=this;void 0===e&&(e={}),void 0===o&&(o=null),void 0===r&&(r=!0);var a=n.length,s=function(t,n){var e={};for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&n.indexOf(o)<0&&(e[o]=t[o]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(o=Object.getOwnPropertySymbols(t);r<o.length;r++)n.indexOf(o[r])<0&&Object.prototype.propertyIsEnumerable.call(t,o[r])&&(e[o[r]]=t[o[r]])}return e}(n,["length"]);return void 0===a?t.prototype.animate.call(this,s,e,o,r):function(n){var c;i.writeOn(a,null!==(c=e.duration)&&void 0!==c?c:1e3,r)(n),Object.keys(s).length>0&&t.prototype.animate.call(i,s,e,o,r)(n)}},n.prototype.writeOn=function(t,n,e){var o=this;void 0===t&&(t=null),void 0===n&&(n=1e3),void 0===e&&(e=!0);var r=null,i=null,a=null,s=function(e){var c;null===a&&(a=e),null===r&&(r=null!==(c=o.props.length)&&void 0!==c?c:o.contentLength()),null===i&&(i=null!=t?t:o.contentLength());var l=e-a,u=Math.min(l/n,1);o.props.length=Math.floor(r+(i-r)*u),o.regenerateChildren(),u<1&&requestAnimationFrame(s)};return function(n){return n({animate:e,animateCallback:function(){a=null,r=null,i=null,requestAnimationFrame(s)},updateCallback:function(){a=null,r=null,i=null,o.props.length=t,o.regenerateChildren()}})}},n.prototype.generateChildrenAndReposition=function(){for(var t=this.element(),n=0,e=Object.entries(this.attributes());n<e.length;n++){var o=e[n],r=o[0],i=o[1];t.setAttribute(r,i)}this.regenerateChildren();for(var a=0,s=Object.entries(this.additionalAttributes());a<s.length;a++){var c=s[a];r=c[0],i=c[1],t.setAttribute(r,i)}},n.prototype.animateContent=function(t,n){var e=this;void 0===n&&(n=1e3);var o=null,r=function(i){null===o&&(o=i);var a=i-o,s=Math.min(a/n,1);e.props.content=t(s),e.generateChildrenAndReposition(),s<1&&requestAnimationFrame(r)};return function(n){return n({animate:!0,animateCallback:function(){o=null,requestAnimationFrame(r)},updateCallback:function(){o=null,e.props.content=t(1),e.generateChildrenAndReposition()}})}},n}(i),y=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function o(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(o.prototype=e.prototype,new o)}}(),v=function(){return v=Object.assign||function(t){for(var n,e=1,o=arguments.length;e<o;e++)for(var r in n=arguments[e])Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r]);return t},v.apply(this,arguments)},b=function(t,n){var e={};for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&n.indexOf(o)<0&&(e[o]=t[o]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(o=Object.getOwnPropertySymbols(t);r<o.length;r++)n.indexOf(o[r])<0&&Object.prototype.propertyIsEnumerable.call(t,o[r])&&(e[o[r]]=t[o[r]])}return e},m=function(t){function n(e){void 0===e&&(e={});var o,r=this,i=v({code:"",highlights:null,length:null,fontFamily:"Courier New",fontSize:130,textColor:"#ffffff",backgroundColor:"#000000",backgroundRounding:10,padding:50,lineHeight:null!==(o=e.fontSize)&&void 0!==o?o:130,characterWidth:80,focusColor:"#4166a5",focusOpacity:0,focusRounding:10,focusLineStart:1,focusLineEnd:1,focusColStart:1,focusColEnd:1,focusPaddingX:0,focusPaddingY:0,focusOffsetX:0,focusOffsetY:0,position:{x:0,y:0},anchor:"topleft"},e),a=n.getComponentProps(i),s=a.group,c=a.background,l=a.focus,u=a.text,h=u.content,f=b(u,["content"]),d=new p(c),y=new p(l),m=new g(h,f);return(r=t.call(this,[d,y,m],s)||this).codeBlockProps=i,r.background=d,r.focus=y,r.text=m,r}return y(n,t),n.prototype.animate=function(e,o,r,i){var a=this;return void 0===o&&(o={}),void 0===r&&(r=null),void 0===i&&(i=!0),function(s){a.codeBlockProps=v(v({},a.codeBlockProps),e);var c=n.getComponentProps(a.codeBlockProps),l=c.group,u=c.background,p=c.focus,h=c.text,f=h.content,d=b(h,["content"]);t.prototype.animate.call(a,l,o,r,i)(s),a.background.animate(u,o,r,i)(s),a.focus.animate(p,o,r,i)(s),a.text.animate(v({content:f},d),o,r,i)(s)}},n.getComponentProps=function(t){var e=t.padding,o=t.characterWidth,r=t.lineHeight,i=t.focusLineStart,a=t.focusLineEnd,s=t.focusColStart,c=t.focusColEnd,l=t.focusOffsetX,u=t.focusOffsetY,p=t.focusPaddingX,h=t.focusPaddingY,f=t.code.trimEnd(),d=f.split("\n").reduce((function(t,n){return Math.max(t,n.length)}),0),g=n.buildTextContent(f,t.highlights);return{group:{position:t.position,anchor:t.anchor},background:{width:o*d+2*e,height:r*g.length+2*e,rounding:t.backgroundRounding,fill:null===t.backgroundColor?"transparent":t.backgroundColor,position:{x:0,y:0},anchor:"topleft"},focus:{width:o*(c-s+1)+2*p,height:r*(a-i+1)+2*h,rounding:t.focusRounding,fill:t.focusColor,opacity:t.focusOpacity,position:{x:e+(s-1)*o-p+l,y:e+(i-1)*r-h+u},anchor:"topleft"},text:{content:g,length:t.length,fontFamily:t.fontFamily,fontSize:t.fontSize,color:t.textColor,position:{x:e,y:e},anchor:"topleft"}}},n.buildTextContent=function(t,n){if(null===n)return t.split("\n").map((function(t){return t}));for(var e=t.split("\n"),o=[],r=0,i=n;r<i.length;r++){for(var a=[],s=0,c=i[r];s<c.length;s++){var l=c[s];a.push([e[o.length].substring(l.start-1,l.end),{color:l.color,fontWeight:l.bold?"bold":"normal"}])}o.push(a)}return o},n.computePropsForText=function(t,n){var e=new g(Array(10).fill("H".repeat(10)),n);e.generate(t);var o=new g(Array(50).fill("H".repeat(50)),n);o.generate(t);var r=e.computeRenderedBoundingBox(e.element()),i=o.computeRenderedBoundingBox(o.element());return{lineHeight:(i.height-r.height)/40,characterWidth:(i.width-r.width)/40}},n}(c);return n})()));
|
|
1
|
+
!function(t,n){"object"==typeof exports&&"object"==typeof module?module.exports=n():"function"==typeof define&&define.amd?define([],n):"object"==typeof exports?exports.PresenterCode=n():t.PresenterCode=n()}(this,(()=>(()=>{"use strict";var t={d:(n,e)=>{for(var o in e)t.o(e,o)&&!t.o(n,o)&&Object.defineProperty(n,o,{enumerable:!0,get:e[o]})},o:(t,n)=>Object.prototype.hasOwnProperty.call(t,n),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},n={};t.r(n),t.d(n,{CodeBlock:()=>C});var e,o=function(){function t(t,n,e){this.origin=t,this.width=n,this.height=e}return t.fromElement=function(n){var e=n.getBBox();return new t({x:e.x,y:e.y},e.width,e.height)},t}(),r=function(){return r=Object.assign||function(t){for(var n,e=1,o=arguments.length;e<o;e++)for(var r in n=arguments[e])Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r]);return t},r.apply(this,arguments)},i=function(){function t(t){this.props=r({position:{x:0,y:0},anchor:"topleft"},t),this.initialProps=r({},this.props),this._element=null,this._presentation=null,this._children=[]}return t.prototype.tagName=function(){return"g"},t.prototype.attributes=function(){var t=this.props.mask;return r({},void 0!==t?{mask:"url(#".concat(t,")")}:{})},t.prototype.additionalAttributes=function(){return{}},t.prototype.styles=function(){var t=this.props.opacity;return r({},void 0!==t?{opacity:t.toString()}:{})},t.prototype.children=function(){return[]},t.prototype.requiresChildrenUpdate=function(t){return!1},t.prototype.positionAttributes=function(t){if(null===this._presentation)throw new Error("Cannot compute object position attributes without presentation");var n=this.positionInPresentation(t.origin),e=n.x,r=n.y,i=this.anchorBoundingBox(new o({x:e,y:r},t.width,t.height));return{x:i.origin.x,y:i.origin.y}},t.prototype.generate=function(t){this.props=r({},this.initialProps),this._presentation=t;for(var n=this.createElement(),e=0,o=Object.entries(this.attributes());e<o.length;e++){var i=o[e],a=i[0],s=i[1];n.setAttribute(a,s)}for(var l=0,c=Object.entries(this.styles());l<c.length;l++){var u=c[l],p=u[0];s=u[1],n.style.setProperty(p,s)}this._children=this.children();for(var h=0,f=this._children;h<f.length;h++){var d=f[h];n.appendChild(d)}this._element=n;for(var g=0,y=Object.entries(this.additionalAttributes());g<y.length;g++){var m=y[g];a=m[0],s=m[1],n.setAttribute(a,s)}return n},t.prototype.createElement=function(){return document.createElementNS("http://www.w3.org/2000/svg",this.tagName())},t.prototype.element=function(){if(null===this._element)throw new Error("Element not yet generated");return this._element},t.prototype.animate=function(t,n,e,o){var i=this;return void 0===n&&(n={}),void 0===e&&(e=null),void 0===o&&(o=!0),function(a){if(null===i._presentation)throw new Error("Cannot animate object without presentation");var s=i.requiresChildrenUpdate(t);i.props=r(r({},i.props),t),s&&(i._children=i.children());var l=i.attributes(),c=i.styles(),u=i.additionalAttributes(),p=Object.fromEntries(Object.entries(l).filter((function(t){var n=t[0],e=t[1];return i._element.getAttribute(n)!==e}))),h=Object.fromEntries(Object.entries(c).filter((function(t){var n=t[0],e=t[1];return i._element.style.getPropertyValue(n)!==e}))),f=Object.fromEntries(Object.entries(u).filter((function(t){var n=t[0],e=t[1];return i._element.getAttribute(n)!==e})));a(r(r(r({animate:o,element:i.element(),attributes:r(r({},p),f),styles:h},null!==e?{delay:e}:{}),s?{children:i._children}:{}),{animationParams:r(r({duration:500,easing:"linear"},n),"cubic"===n.easing?{easing:"cubicBezier(0.42, 0, 0.58, 1)"}:{})}))}},t.prototype.set=function(t,n){return void 0===n&&(n=null),this.animate(t,{},n,!1)},t.prototype.move=function(t,n){return void 0===n&&(n={}),this.animate({position:t},n)},t.prototype.fadeIn=function(t){return void 0===t&&(t={}),this.animate({opacity:1},t)},t.prototype.fadeOut=function(t){return void 0===t&&(t={}),this.animate({opacity:0},t)},t.prototype.show=function(){return this.set({opacity:1})},t.prototype.hide=function(){return this.set({opacity:0})},t.prototype.positionInPresentation=function(t){var n=this._presentation,e=t.x,o=t.y;return e<=1&&e>=-1&&(e*=n.boundingBox.width),o<=1&&o>=-1&&(o*=n.boundingBox.height),{x:e,y:o}},t.prototype.anchorBoundingBox=function(t){var n=this,e=function(){switch(n.props.anchor){case"topleft":case"top":case"topright":return t.origin.y;case"left":case"center":case"right":return t.origin.y-t.height/2;case"bottomleft":case"bottom":case"bottomright":return t.origin.y-t.height}}(),r=function(){switch(n.props.anchor){case"topleft":case"left":case"bottomleft":return t.origin.x;case"top":case"center":case"bottom":return t.origin.x-t.width/2;case"topright":case"right":case"bottomright":return t.origin.x-t.width}}();return new o({x:r,y:e},t.width,t.height)},t.prototype.computeRenderedBoundingBox=function(t,n){void 0===n&&(n=null);var e=this._presentation.computeRenderedBoundingBox(t,n);return new o({x:this.props.position.x,y:this.props.position.y},e.width,e.height)},t}(),a=(e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},e(t,n)},function(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function o(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(o.prototype=n.prototype,new o)}),s=function(){return s=Object.assign||function(t){for(var n,e=1,o=arguments.length;e<o;e++)for(var r in n=arguments[e])Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r]);return t},s.apply(this,arguments)},l=function(t){function n(n,e,o){return void 0===e&&(e={}),void 0===o&&(o=null),t.call(this,s({objects:n,position:{x:0,y:0},positioned:null===o?"position"in e:o,rotation:0,rotationOrigin:{x:0,y:0},transformOrigin:null,scale:1,skewX:0,skewY:0},e))||this}return a(n,t),n.prototype.tagName=function(){return"g"},n.prototype.attributes=function(){var n=this.props.transformOrigin;return s(s({},t.prototype.attributes.call(this)),null!==n?{"transform-origin":"string"==typeof n?n:"".concat(n.x," ").concat(n.y)}:{})},n.prototype.additionalAttributes=function(){var t=this.props,n=t.rotation,e=t.rotationOrigin,r=t.scale,i=t.skewX,a=t.skewY,s="rotate(".concat(n,", ").concat(e.x,", ").concat(e.y,")"),l="scale(".concat(r,")"),c="".concat(0!==i?"skewX(".concat(i,")"):""," ").concat(0!==a?"skewY(".concat(a,")"):"");if(!this.props.positioned){var u=this.positionInPresentation(this.props.position),p=u.x,h=u.y;return{transform:"translate(".concat(p,", ").concat(h,") ").concat(s," ").concat(l," ").concat(c)}}var f=this._presentation.computeRenderedBoundingBox(this.sizingElement());f.width*=r,f.height*=r;var d=this.positionInPresentation(this.props.position),g=d.x,y=d.y,m=this.anchorBoundingBox(new o({x:g,y},f.width,f.height)),v=m.origin.x-f.origin.x,b=m.origin.y-f.origin.y;return{transform:"translate(".concat(v,", ").concat(b,") ").concat(s," ").concat(l," ").concat(c)}},n.prototype.sizingElement=function(){return this._element},n.prototype.children=function(){var t=this;return this.props.objects.map((function(n){return n.generate(t._presentation),n._element}))},n}(i),c=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function o(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(o.prototype=e.prototype,new o)}}(),u=function(){return u=Object.assign||function(t){for(var n,e=1,o=arguments.length;e<o;e++)for(var r in n=arguments[e])Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r]);return t},u.apply(this,arguments)},p=function(t){function n(e,o){void 0===o&&(o={});var r=t.call(this,u({id:"mask-".concat(n.maskIndex++),objects:e},o))||this;return r.id=r.props.id,r}return c(n,t),n.prototype.tagName=function(){return"mask"},n.prototype.attributes=function(){return{id:this.id}},n.prototype.children=function(){var t=this;return this.props.objects.map((function(n){return n.generate(t._presentation),n._element}))},n.maskIndex=0,n}(i),h=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function o(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(o.prototype=e.prototype,new o)}}(),f=function(){return f=Object.assign||function(t){for(var n,e=1,o=arguments.length;e<o;e++)for(var r in n=arguments[e])Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r]);return t},f.apply(this,arguments)},d=function(t){function n(n){return void 0===n&&(n={}),t.call(this,f({fill:"#000000",width:100,height:100,rounding:0,borderWidth:0,borderColor:"#000000",drawn:!0},n))||this}return h(n,t),n.prototype.tagName=function(){return"rect"},n.prototype.attributes=function(){var n=this.props,e=n.position,r=n.width,i=n.height,a=n.fill,s=n.rounding,l=n.borderWidth,c=n.borderColor,u=n.drawn,p=this.positionAttributes(new o(e,r,i)),h=p.x,d=p.y;return f(f(f(f({},t.prototype.attributes.call(this)),{fill:a,width:r.toString(),height:i.toString(),rx:s.toString(),x:h.toString(),y:d.toString()}),l>0?{"stroke-width":l.toString(),stroke:c}:{}),u?{}:{stroke:"none",fill:"none"})},n.prototype.animate=function(n,e,o,r){var i=this;void 0===e&&(e={}),void 0===o&&(o=null),void 0===r&&(r=!0);var a=n.drawn,s=function(t,n){var e={};for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&n.indexOf(o)<0&&(e[o]=t[o]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(o=Object.getOwnPropertySymbols(t);r<o.length;r++)n.indexOf(o[r])<0&&Object.prototype.propertyIsEnumerable.call(t,o[r])&&(e[o[r]]=t[o[r]])}return e}(n,["drawn"]);return void 0===a?t.prototype.animate.call(this,s,e,o,r):function(n){var a,l,c;i.drawOn({drawDuration:null!==(a=e.duration)&&void 0!==a?a:1e3,fillDuration:null!==(l=e.fillDuration)&&void 0!==l?l:300,easing:null!==(c=e.easing)&&void 0!==c?c:"linear"})(n),Object.keys(s).length>0&&t.prototype.animate.call(i,s,e,o,r)(n)}},n.prototype.drawOn=function(t){var n=this;return void 0===t&&(t={}),function(e){var o,r,i,a=n.props,s=a.borderColor,l=a.borderWidth,c=a.fill;n.props.drawn=!0;var u,p=n.element();try{u=p.getTotalLength()}catch(t){u=0}var h=null!==(o=t.drawDuration)&&void 0!==o?o:1e3;p.setAttribute("stroke-dashoffset","".concat(u)),p.setAttribute("stroke-dasharray","".concat(u)),p.setAttribute("stroke",s),e({animate:!0,element:p,attributes:{"stroke-dashoffset":"0"},animationParams:{duration:h,easing:null!==(r=t.easing)&&void 0!==r?r:"linear"},updateCallback:function(){l>0&&p.setAttribute("stroke",s),p.setAttribute("fill",c)}}),"none"!==n.props.fill&&e({animate:!0,delay:h,element:p,attributes:{fill:n.props.fill,"stroke-dasharray":"none"},animationParams:{duration:null!==(i=t.fillDuration)&&void 0!==i?i:500,easing:"linear"}})}},n}(i);function g(t,n,e){void 0===n&&(n="1em"),void 0===e&&(e="start");for(var o=[],r=0,i=0,a=t;i<a.length;i++){var s=a[i];r++;var l=document.createElementNS("http://www.w3.org/2000/svg","tspan");if(l.setAttribute("x","0"),l.setAttribute("text-anchor",e),r>1&&l.setAttribute("dy",n),0===s.length||1===s.length&&""===s[0])l.appendChild(document.createTextNode(" ")),o.push(l);else if("string"!=typeof s){for(var c=0,u=s;c<u.length;c++){var p=u[c];if("string"==typeof p)l.appendChild(document.createTextNode(p));else{var h=p[0],f=p[1],d=document.createElementNS("http://www.w3.org/2000/svg","tspan");d.textContent=h;for(var g={fill:f.color,dy:f.dy,"text-decoration":f.textDecoration},y=0,m=Object.entries(g);y<m.length;y++){var v=m[y],b=v[0];void 0!==(C=v[1])&&d.setAttribute(b,C.toString())}var w={"font-family":f.fontFamily?'"'.concat(f.fontFamily,'"'):void 0,"font-size":f.fontSize,"font-weight":f.fontWeight,"font-style":f.fontStyle};!0===f.superscript?(w["baseline-shift"]="super",void 0===w["font-size"]&&(w["font-size"]="50%")):!0===f.subscript&&(w["baseline-shift"]="sub",void 0===w["font-size"]&&(w["font-size"]="50%")),!0===f.smallCaps&&(w["font-variant"]="small-caps");for(var O=0,x=Object.entries(w);O<x.length;O++){var C,_=x[O];b=_[0],void 0!==(C=_[1])&&d.style.setProperty(b,C.toString())}l.appendChild(d)}}o.push(l)}else l.appendChild(document.createTextNode(s)),o.push(l)}return o}var y=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function o(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(o.prototype=e.prototype,new o)}}(),m=function(){return m=Object.assign||function(t){for(var n,e=1,o=arguments.length;e<o;e++)for(var r in n=arguments[e])Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r]);return t},m.apply(this,arguments)},v=function(t){function n(n,e){return void 0===e&&(e={}),t.call(this,m({content:n,color:"#000000",fontSize:150,fontStyle:"normal",fontWeight:"normal",fontFamily:"Arial",baselineHeight:.22,dominantBaseline:"ideographic",textDecoration:"none",smallCaps:!1,length:null,align:"left",lineSpacing:"1em",ligatures:null},e))||this}return y(n,t),n.prototype.isRichText=function(){return"string"!=typeof this.props.content},n.prototype.tagName=function(){return"text"},n.prototype.attributes=function(){var n=this.props,e=n.color,o=n.textDecoration;return m(m(m({},t.prototype.attributes.call(this)),"none"!==o?{"text-decoration":o}:{}),{fill:e})},n.prototype.additionalAttributes=function(){var n=this.computeRenderedBoundingBox(this.element(),this.childrenWithContentLength(this.contentLength())),e=this.positionAttributes(n),o=e.x,r=e.y;return this.isRichText()&&("center"===this.props.align?o+=n.width/2:"right"===this.props.align&&(o+=n.width)),r-=this.props.fontSize*this.props.baselineHeight,m(m({},t.prototype.additionalAttributes.call(this)),this.isRichText()?{transform:"translate(".concat(o.toString()," ").concat(r.toString(),")"),y:this.computeRenderedBoundingBox(this.element(),this.childrenWithContentLength(1)).height.toString()}:{x:o.toString(),y:(r+n.height).toString()})},n.prototype.styles=function(){var n=this.props,e=n.fontSize,o=n.fontFamily,r=n.fontStyle,i=n.fontWeight,a=n.ligatures,s=n.smallCaps;return m(m(m(m(m(m({},t.prototype.styles.call(this)),"normal"!==r?{"font-style":r}:{}),"normal"!==i?{"font-weight":i.toString()}:{}),null!==a?{"font-variant-ligatures":a}:{}),!0===s?{"font-variant":"small-caps"}:{}),{"font-size":"".concat(e,"px"),"font-family":'"'.concat(o,'"'),"white-space":"pre"})},n.prototype.children=function(){var t,n=null!==(t=this.props.length)&&void 0!==t?t:this.contentLength();return this.childrenWithContentLength(n)},n.prototype.requiresChildrenUpdate=function(t){return"content"in t&&t.content!==this.props.content||"length"in t&&t.length!==this.props.length},n.prototype.contentLength=function(t){if(void 0===t&&(t=null),"string"==typeof this.props.content)return this.props.content.length;var n=this.props.content;return null!==t&&(n=n.slice(0,t)),n.reduce((function(t,n){return"string"==typeof n?t+n.length:t+n.reduce((function(t,n){return t+("string"==typeof n?n:n[0]).length}),0)}),0)},n.prototype.childrenWithContentLength=function(t){var n=this.props.content;if("string"==typeof n){var e=null===t?n:n.slice(0,t);return[document.createTextNode(e)]}var o="left"===this.props.align?"start":"center"===this.props.align?"middle":"end";if(null===t)return g(n,this.props.lineSpacing,o);for(var r=t,i=[],a=0,s=n;a<s.length;a++){var l=s[a];if("string"==typeof l)l.length<=r?(i.push(l),r-=l.length):(i.push(l.slice(0,r)),r=0);else{for(var c=[],u=0,p=l;u<p.length;u++){var h=p[u];if("string"==typeof h?h.length<=r?(c.push(h),r-=h.length):(c.push(h.slice(0,r)),r=0):h[0].length<=r?(c.push(h),r-=h[0].length):(c.push([h[0].slice(0,r),h[1]]),r=0),0===r)break}i.push(c)}if(0===r)break}return g(i,this.props.lineSpacing,o)},n.prototype.regenerateChildren=function(){this._children=this.children(),this._element.innerHTML="";for(var t=0,n=this._children;t<n.length;t++){var e=n[t];this._element.appendChild(e)}},n.prototype.animate=function(n,e,o,r){var i=this;void 0===e&&(e={}),void 0===o&&(o=null),void 0===r&&(r=!0);var a=n.length,s=function(t,n){var e={};for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&n.indexOf(o)<0&&(e[o]=t[o]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(o=Object.getOwnPropertySymbols(t);r<o.length;r++)n.indexOf(o[r])<0&&Object.prototype.propertyIsEnumerable.call(t,o[r])&&(e[o[r]]=t[o[r]])}return e}(n,["length"]);return void 0===a?t.prototype.animate.call(this,s,e,o,r):function(n){var l;i.writeOn(a,null!==(l=e.duration)&&void 0!==l?l:1e3,r)(n),Object.keys(s).length>0&&t.prototype.animate.call(i,s,e,o,r)(n)}},n.prototype.writeOn=function(t,n,e){var o=this;void 0===t&&(t=null),void 0===n&&(n=1e3),void 0===e&&(e=!0);var r=null,i=null,a=null,s=function(e){var l;null===a&&(a=e),null===r&&(r=null!==(l=o.props.length)&&void 0!==l?l:o.contentLength()),null===i&&(i=null!=t?t:o.contentLength());var c=e-a,u=Math.min(c/n,1);o.props.length=Math.floor(r+(i-r)*u),o.regenerateChildren(),u<1&&requestAnimationFrame(s)};return function(n){return n({animate:e,animateCallback:function(){a=null,r=null,i=null,requestAnimationFrame(s)},updateCallback:function(){a=null,r=null,i=null,o.props.length=t,o.regenerateChildren()}})}},n.prototype.generateChildrenAndReposition=function(){for(var t=this.element(),n=0,e=Object.entries(this.attributes());n<e.length;n++){var o=e[n],r=o[0],i=o[1];t.setAttribute(r,i)}this.regenerateChildren();for(var a=0,s=Object.entries(this.additionalAttributes());a<s.length;a++){var l=s[a];r=l[0],i=l[1],t.setAttribute(r,i)}},n.prototype.animateContent=function(t,n){var e=this;void 0===n&&(n=1e3);var o=null,r=function(i){null===o&&(o=i);var a=i-o,s=Math.min(a/n,1);e.props.content=t(s),e.generateChildrenAndReposition(),s<1&&requestAnimationFrame(r)};return function(n){return n({animate:!0,animateCallback:function(){o=null,requestAnimationFrame(r)},updateCallback:function(){o=null,e.props.content=t(1),e.generateChildrenAndReposition()}})}},n}(i),b=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function o(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(o.prototype=e.prototype,new o)}}(),w=function(){return w=Object.assign||function(t){for(var n,e=1,o=arguments.length;e<o;e++)for(var r in n=arguments[e])Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r]);return t},w.apply(this,arguments)},O=function(t,n){var e={};for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&n.indexOf(o)<0&&(e[o]=t[o]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(o=Object.getOwnPropertySymbols(t);r<o.length;r++)n.indexOf(o[r])<0&&Object.prototype.propertyIsEnumerable.call(t,o[r])&&(e[o[r]]=t[o[r]])}return e},x=function(t,n,e){if(e||2===arguments.length)for(var o,r=0,i=n.length;r<i;r++)!o&&r in n||(o||(o=Array.prototype.slice.call(n,0,r)),o[r]=n[r]);return t.concat(o||Array.prototype.slice.call(n))},C=function(t){function n(n){void 0===n&&(n={});var e,o=this,r=void 0===n.maskLines?"lineCount"in n&&null!==n.lineCount:n.maskLines,i=w({code:"",highlights:null,length:null,fontFamily:"Courier New",fontSize:130,textColor:"#ffffff",backgroundColor:"#000000",backgroundRounding:10,padding:15,lineSpacing:"1em",lineHeight:null!==(e=n.fontSize)&&void 0!==e?e:130,characterWidth:80,lineCount:null,colCount:null,maskLines:r,firstLine:1,unfocusedOpacity:1,lineNumbers:!1,firstLineNumber:1,lineNumberColor:"#d0d0d0",focusColor:"#4166a5",focusOpacity:0,focusRounding:10,focusLineStart:1,focusLineEnd:1,focusColStart:1,focusColEnd:1,focusPaddingX:0,focusPaddingY:0,focusOffsetX:0,focusOffsetY:0,position:{x:0,y:0},anchor:"topleft"},n);return(o=t.call(this,[],{positioned:!0})||this).codeBlockProps=i,o.initialCodeBlockProps=i,o}return b(n,t),n.prototype.createElement=function(){this.codeBlockProps=w({},this.initialCodeBlockProps);var e=n.getComponentProps(this.codeBlockProps),o=e.group,r=e.background,i=e.mask,a=e.maskFocus,s=e.focus,c=e.text,u=c.content,h=O(c,["content"]),f=e.lineNumbers,g=new d(r),y=null,m=null,b=null;this.codeBlockProps.maskLines&&(m=new d(i),b=new d(a),y=new p([m,b]));var C=new d(s),_=new v(u,h),k=null;if(null!==f){var j=f.content,P=O(f,["content"]);k=new v(j,P)}var S=new l(x([C,_],null!==k?[k]:[],!0),w({},null!==y?{mask:y.id}:{}));return this.props.objects=x(x([],null!==y?[y]:[],!0),[g,S],!1),this.props=w(w({},this.props),o),this.background=g,this.maskRect=m,this.maskFocusRect=b,this.focus=C,this.text=_,this.lineNumbers=k,t.prototype.createElement.call(this)},n.prototype.animate=function(e,o,r,i){var a=this;return void 0===o&&(o={}),void 0===r&&(r=null),void 0===i&&(i=!0),function(s){a.codeBlockProps=w(w({},a.codeBlockProps),e);var l=n.getComponentProps(a.codeBlockProps),c=l.group,u=l.background,p=l.mask,h=l.maskFocus,f=l.focus,d=l.text,g=d.content,y=O(d,["content"]),m=l.lineNumbers;t.prototype.animate.call(a,c,o,r,i)(s),a.background.animate(u,o,r,i)(s),a.focus.animate(f,o,r,i)(s),null!==a.maskRect&&(a.maskRect.animate(p,o,r,i)(s),a.maskFocusRect.animate(h,o,r,i)(s)),a.text.animate(w({content:g},y),o,r,i)(s),null!==m&&a.lineNumbers.animate(m,o,r,i)(s)}},n.prototype.set=function(t,n){return void 0===n&&(n=null),this.animate(t,{},n,!1)},n.getComponentProps=function(t){var e,o,r=t.padding,i=t.characterWidth,a=t.lineHeight,s=t.firstLine,l=t.unfocusedOpacity,c=t.lineNumbers,u=t.firstLineNumber,p=t.lineNumberColor,h=t.focusLineStart,f=t.focusLineEnd,d=t.focusColStart,g=t.focusColEnd,y=t.focusOffsetX,m=t.focusOffsetY,v=t.focusPaddingX,b=t.focusPaddingY,O=t.code.trimEnd(),x=O.split("\n").reduce((function(t,n){return Math.max(t,n.length)}),0),C=null!==(e=t.colCount)&&void 0!==e?e:x,_=n.buildTextContent(O,t.highlights),k=null!==(o=t.lineCount)&&void 0!==o?o:_.length,j=null,P=_.length.toString().length+3;c&&(j={content:Array.from({length:_.length},(function(t,n){return u+n})).map((function(t){return"".concat(t," ").padStart(P," ")})),fontFamily:t.fontFamily,fontSize:t.fontSize,lineSpacing:t.lineSpacing,color:p,position:{x:r,y:r-(s-1)*a},anchor:"topleft"});var S=c?P*i:0,A={width:i*C+2*r+S,height:a*k+2*r,rounding:t.backgroundRounding,fill:null===t.backgroundColor?"transparent":t.backgroundColor,position:{x:0,y:0},anchor:"topleft"},B={width:i*(g-d+1)+2*v,height:a*(f-h+1)+2*b,rounding:t.focusRounding,fill:t.focusColor,opacity:t.focusOpacity,position:{x:r+S+(d-1)*i-v+y,y:r-(s-1)*a+(h-1)*a-b+m},anchor:"topleft"};return{group:{position:t.position,anchor:t.anchor},background:w({},A),mask:w(w({},A),{fill:"rgb(255, 255, 255, ".concat(l,")")}),focus:w({},B),maskFocus:w(w({},B),{fill:"white"}),text:{content:_,length:t.length,fontFamily:t.fontFamily,fontSize:t.fontSize,lineSpacing:t.lineSpacing,color:t.textColor,position:{x:r+S,y:r-(s-1)*a},anchor:"topleft"},lineNumbers:j}},n.buildTextContent=function(t,n){if(null===n)return t.split("\n").map((function(t){return t}));for(var e=t.split("\n"),o=[],r=0,i=n;r<i.length;r++){for(var a=[],s=0,l=i[r];s<l.length;s++){var c=l[s];a.push([e[o.length].substring(c.start-1,c.end),{color:c.color,fontWeight:c.bold?"bold":"normal"}])}o.push(a)}return o},n.prototype.sizingElement=function(){if(!this.codeBlockProps.maskLines)return t.prototype.sizingElement.call(this);var n=this.element().cloneNode();return n.appendChild(this.background.element().cloneNode()),n},n.computePropsForText=function(t,n){var e=new v(Array(10).fill("H".repeat(10)),n);e.generate(t);var o=new v(Array(50).fill("H".repeat(50)),n);o.generate(t);var r=e.computeRenderedBoundingBox(e.element()),i=o.computeRenderedBoundingBox(o.element());return{lineHeight:(i.height-r.height)/40,characterWidth:(i.width-r.width)/40}},n}(l);return n})()));
|