scrawl-canvas
Version:
Version 8.9.4 - 19 Nov 2022
1 lines • 565 kB
JavaScript
const t={},e={},i={},s=[],n={},r=[],o={},a={},l=[],h={},c={},u=[],d={},f={},p={},m={},g=[],y={},b={DEFAULTS:{defaults:!0},b:{weight:"bold"},"/b":{weight:"normal"},strong:{weight:"bold"},"/strong":{weight:"normal"},BOLD:{weight:"bold"},"/BOLD":{weight:"normal"},i:{style:"italic"},"/i":{style:"normal"},em:{style:"italic"},"/em":{style:"normal"},ITALIC:{style:"italic"},"/ITALIC":{style:"normal"},u:{underline:!0},"/u":{underline:!1},UNDERLINE:{underline:!0},"/UNDERLINE":{underline:!1},OVERLINE:{overline:!0},"/OVERLINE":{overline:!1},"SMALL-CAPS":{variant:"small-caps"},"/SMALL-CAPS":{variant:"normal"},HIGHLIGHT:{highlight:!0},"/HIGHLIGHT":{highlight:!1}},S={},k={},A=[],O={},v={},w=Math.PI/180,C=new Set(["all","background","backgroundAttachment","backgroundBlendMode","backgroundClip","backgroundColor","backgroundOrigin","backgroundPosition","backgroundRepeat","border","borderBottom","borderBottomColor","borderBottomStyle","borderBottomWidth","borderCollapse","borderColor","borderLeft","borderLeftColor","borderLeftStyle","borderLeftWidth","borderRight","borderRightColor","borderRightStyle","borderRightWidth","borderSpacing","borderStyle","borderTop","borderTopColor","borderTopStyle","borderTopWidth","borderWidth","clear","color","columns","content","counterIncrement","counterReset","cursor","direction","display","emptyCells","float","font","fontFamily","fontSize","fontSizeAdjust","fontStretch","fontStyle","fontSynthesis","fontVariant","fontVariantAlternates","fontVariantCaps","fontVariantEastAsian","fontVariantLigatures","fontVariantNumeric","fontVariantPosition","fontWeight","grid","gridArea","gridAutoColumns","gridAutoFlow","gridAutoPosition","gridAutoRows","gridColumn","gridColumnStart","gridColumnEnd","gridRow","gridRowStart","gridRowEnd","gridTemplate","gridTemplateAreas","gridTemplateRows","gridTemplateColumns","imageResolution","imeMode","inherit","inlineSize","isolation","letterSpacing","lineBreak","lineHeight","listStyle","listStyleImage","listStylePosition","listStyleType","margin","marginBlockStart","marginBlockEnd","marginInlineStart","marginInlineEnd","marginBottom","marginLeft","marginRight","marginTop","marks","mask","maskType","maxWidth","maxHeight","maxBlockSize","maxInlineSize","maxZoom","minWidth","minHeight","minBlockSize","minInlineSize","minZoom","mixBlendMode","objectFit","objectPosition","offsetBlockStart","offsetBlockEnd","offsetInlineStart","offsetInlineEnd","orphans","overflow","overflowWrap","overflowX","overflowY","pad","padding","paddingBlockStart","paddingBlockEnd","paddingInlineStart","paddingInlineEnd","paddingBottom","paddingLeft","paddingRight","paddingTop","pageBreakAfter","pageBreakBefore","pageBreakInside","pointerEvents","position","prefix","quotes","rubyAlign","rubyMerge","rubyPosition","scrollBehavior","scrollSnapCoordinate","scrollSnapDestination","scrollSnapPointsX","scrollSnapPointsY","scrollSnapType","scrollSnapTypeX","scrollSnapTypeY","shapeImageThreshold","shapeMargin","shapeOutside","tableLayout","textAlign","textDecoration","textIndent","textOrientation","textOverflow","textRendering","textShadow","textTransform","textUnderlinePosition","unicodeRange","unset","verticalAlign","widows","willChange","wordBreak","wordSpacing","wordWrap","zIndex"]),x=new Set(["alignContent","alignItems","alignSelf","animation","animationDelay","animationDirection","animationDuration","animationFillMode","animationIterationCount","animationName","animationPlayState","animationTimingFunction","backfaceVisibility","backgroundImage","backgroundSize","borderBottomLeftRadius","borderBottomRightRadius","borderImage","borderImageOutset","borderImageRepeat","borderImageSlice","borderImageSource","borderImageWidth","borderRadius","borderTopLeftRadius","borderTopRightRadius","boxDecorationBreak","boxShadow","boxSizing","columnCount","columnFill","columnGap","columnRule","columnRuleColor","columnRuleStyle","columnRuleWidth","columnSpan","columnWidth","filter","flex","flexBasis","flexDirection","flexFlow","flexGrow","flexShrink","flexWrap","fontFeatureSettings","fontKerning","fontLanguageOverride","hyphens","imageRendering","imageOrientation","initial","justifyContent","linearGradient","opacity","order","orientation","outline","outlineColor","outlineOffset","outlineStyle","outlineWidth","resize","tabSize","textAlignLast","textCombineUpright","textDecorationColor","textDecorationLine","textDecorationStyle","touchAction","transformStyle","transition","transitionDelay","transitionDuration","transitionProperty","transitionTimingFunction","unicodeBidi","whiteSpace","writingMode"]);var P=Object.freeze({__proto__:null,version:"8.9.4",anchor:{},anchornames:[],animation:t,animationnames:[],animationtickers:e,animationtickersnames:[],artefact:i,artefactnames:s,asset:n,assetnames:r,canvas:o,canvasnames:[],cell:a,cellnames:l,element:{},elementnames:[],entity:h,entitynames:[],filter:c,filternames:u,fontattribute:{},fontattributenames:[],group:d,groupnames:[],palette:{},palettenames:[],particle:f,particlenames:[],force:p,forcenames:[],spring:m,springnames:g,world:y,worldnames:[],sectionClasses:b,stack:{},stacknames:[],tween:S,tweennames:[],styles:k,stylesnames:A,unstackedelement:O,unstackedelementnames:[],constructors:v,radian:w,css:C,xcss:x});let D=!1,R=!0,F=[],E=[];const M=function(){R=!0},H=function(){let e,i;for(R&&function(){if(R){R=!1;let e,i,s,n,r,o=Math.floor,a=[];for(s=0,n=E.length;s<n;s++)r=E[s],e=t[r],e&&(i=o(e.order)||0,a[i]||(a[i]=[]),a[i].push(e));F=a.reduce(((t,e)=>t.concat(e)),[])}}(),e=0,i=F.length;e<i;e++)F[e].fn();D&&window.requestAnimationFrame((()=>H()))},I=function(){D=!0,H()},B=function(){D=!1},T=(t,e)=>{if(!nt(e))throw new Error(`core/utilities addStrings() error - no delta argument supplied ${t}, ${e}`);if(null!=e){"left"===t||"top"===t?t="0%":"right"===t||"bottom"===t?t="100%":"center"===t&&(t="50%");let i=!(!t.substring&&!e.substring);return q(t)?t+=q(e)?e:parseFloat(e):t=parseFloat(t)+(q(e)?e:parseFloat(e)),i?t+"%":t}return t},L=t=>{let e,i,s;if(!nt(t))throw new Error("core/utilities convertTime() error - no argument supplied");if(q(t))return["ms",t];if(!t.substring)throw new Error(`core/utilities convertTime() error - invalid argument: ${t}`);if(e=t.match(/^\d+\.?\d*(\D*)/),i=e[1].toLowerCase?e[1].toLowerCase():"ms",s=parseFloat(t),!q(s))throw new Error(`core/base error - convertTime() argument converts to NaN: ${t}`);switch(i){case"s":s*=1e3;break;case"%":break;default:i="ms"}return[i,s]},$=t=>!t.toFixed||isNaN(t)?(console.log(`${t} is not a valid number`),t):((t%=360)<0&&(t+=360),t),j=t=>t.toFixed?0==t?t:isNaN(t)?0:t<-1e-6||t>1e-6?t:0:t,X=()=>{},Y=function(t){return t},N=function(){return this},G=()=>Promise.resolve(!0),z={},W=()=>performance.now().toString(36)+Math.random().toString(36).substr(2),V=function(t,e,i){return e+t*(i-e)},Z=t=>"boolean"==typeof t,_=t=>"[object HTMLCanvasElement]"===Object.prototype.toString.call(t),U=t=>!!(t&&t.querySelector&&t.dispatchEvent),K=t=>"function"==typeof t,q=t=>!(null==t||!t.toFixed||Number.isNaN(t)),Q=t=>"[object Object]"===Object.prototype.toString.call(t),J=t=>!(!t||!t.type||"Quaternion"!==t.type),tt=(t,e)=>{if(!Q(t)||!Q(e))throw new Error(`core/utilities mergeOver() error - insufficient arguments supplied ${t}, ${e}`);for(let i in e)e.hasOwnProperty(i)&&(t[i]=e[i]);return t},et=(t,e)=>{if(!Q(t)||!Q(e))throw new Error(`core/utilities mergeDiscard() error - insufficient arguments supplied ${t}, ${e}`);return Object.entries(e).forEach((([i,s])=>{null===s?delete t[i]:t[i]=e[i]})),t},it=(t,e)=>{if(!rt(t,e))throw new Error(`core/utilities pushUnique() error - insufficient arguments supplied ${t}, ${e}`);if(!Array.isArray(t))throw new Error(`core/utilities pushUnique() error - argument not an array ${t}`);return Array.isArray(e)?e.forEach((e=>it(t,e))):t.indexOf(e)<0&&t.push(e),t},st=(t,e)=>{if(!rt(t,e))throw new Error(`core/utilities removeItem() error - insufficient arguments supplied ${t}, ${e}`);if(!Array.isArray(t))throw new Error(`core/utilities removeItem() error - argument not an array ${t}`);let i=t.indexOf(e);return i>=0&&t.splice(i,1),t},nt=t=>void 0!==t,rt=(...t)=>t.every((t=>void 0!==t)),ot=(...t)=>t.find((t=>void 0!==t)),at=(...t)=>!!t.find((t=>void 0!==t)),lt={out:t=>1-Math.cos(t*Math.PI/2),in:t=>Math.sin(t*Math.PI/2),easeIn:t=>{let e=1-t;return 1-e*e},easeIn3:t=>{let e=1-t;return 1-e*e*e},easeIn4:t=>{let e=1-t;return 1-e*e*e*e},easeIn5:t=>{let e=1-t;return 1-e*e*e*e*e},easeOutIn:t=>t<.5?2*t*t:1-Math.pow(-2*t+2,2)/2,easeOutIn3:t=>t<.5?4*t*t*t:1-Math.pow(-2*t+2,3)/2,easeOutIn4:t=>t<.5?8*t*t*t*t:1-Math.pow(-2*t+2,4)/2,easeOutIn5:t=>t<.5?16*t*t*t*t*t:1-Math.pow(-2*t+2,5)/2,easeInOut:t=>{const e=.5-t,i=t-.5;return t<.5?.5+-2*e*e:.5+Math.pow(2*i,2)/2},easeInOut3:t=>{const e=.5-t,i=t-.5;return t<.5?.5+-4*e*e*e:.5+Math.pow(2*i,3)/2},easeInOut4:t=>{const e=.5-t,i=t-.5;return t<.5?.5+-8*e*e*e*e:.5+Math.pow(2*i,4)/2},easeInOut5:t=>{const e=.5-t,i=t-.5;return t<.5?.5+-16*e*e*e*e*e:.5+Math.pow(2*i,5)/2},easeOut:t=>t*t,easeOut3:t=>t*t*t,easeOut4:t=>t*t*t*t,easeOut5:t=>t*t*t*t*t,none:t=>t,linear:t=>t,cosine:t=>.5*(1+Math.cos((1-t)*Math.PI)),hermite:t=>t*t*(2*-t+3),quintic:t=>t*t*t*(t*(6*t-15)+10),easeOutSine:t=>1-Math.cos(t*Math.PI/2),easeInSine:t=>Math.sin(t*Math.PI/2),easeOutInSine:t=>-(Math.cos(Math.PI*t)-1)/2,easeOutQuad:t=>t*t,easeInQuad:t=>1-(1-t)*(1-t),easeOutInQuad:t=>t<.5?2*t*t:1-Math.pow(-2*t+2,2)/2,easeOutCubic:t=>t*t*t,easeInCubic:t=>1-Math.pow(1-t,3),easeOutInCubic:t=>t<.5?4*t*t*t:1-Math.pow(-2*t+2,3)/2,easeOutQuart:t=>t*t*t*t,easeInQuart:t=>1-Math.pow(1-t,4),easeOutInQuart:t=>t<.5?8*t*t*t*t:1-Math.pow(-2*t+2,4)/2,easeOutQuint:t=>t*t*t*t*t,easeInQuint:t=>1-Math.pow(1-t,5),easeOutInQuint:t=>t<.5?16*t*t*t*t*t:1-Math.pow(-2*t+2,5)/2,easeOutExpo:t=>0===t?0:Math.pow(2,10*t-10),easeInExpo:t=>1===t?1:1-Math.pow(2,-10*t),easeOutInExpo:t=>0===t||1===t?t:t<.5?Math.pow(2,20*t-10)/2:(2-Math.pow(2,-20*t+10))/2,easeOutCirc:t=>1-Math.sqrt(1-Math.pow(t,2)),easeInCirc:t=>Math.sqrt(1-Math.pow(t-1,2)),easeOutInCirc:t=>t<.5?(1-Math.sqrt(1-Math.pow(2*t,2)))/2:(Math.sqrt(1-Math.pow(-2*t+2,2))+1)/2,easeOutBack:t=>2.70158*t*t*t-1.70158*t*t,easeInBack:t=>1+2.70158*Math.pow(t-1,3)+1.70158*Math.pow(t-1,2),easeOutInBack:t=>{const e=2.5949095;return t<.5?Math.pow(2*t,2)*(7.189819*t-e)/2:(Math.pow(2*t-2,2)*((e+1)*(2*t-2)+e)+2)/2},easeOutElastic:t=>{const e=2*Math.PI/3;return 0===t||1===t?t:-Math.pow(2,10*t-10)*Math.sin((10*t-10.75)*e)},easeInElastic:t=>{const e=2*Math.PI/3;return 0===t||1===t?t:Math.pow(2,-10*t)*Math.sin((10*t-.75)*e)+1},easeOutInElastic:t=>{const e=2*Math.PI/4.5;return 0===t||1===t?t:t<.5?-Math.pow(2,20*t-10)*Math.sin((20*t-11.125)*e)/2:Math.pow(2,-20*t+10)*Math.sin((20*t-11.125)*e)/2+1},easeOutBounce:t=>{const e=7.5625,i=2.75;return(t=1-t)<1/i?1-e*t*t:t<2/i?1-(e*(t-=1.5/i)*t+.75):t<2.5/i?1-(e*(t-=2.25/i)*t+.9375):1-(e*(t-=2.625/i)*t+.984375)},easeInBounce:t=>{const e=7.5625,i=2.75;return t<1/i?e*t*t:t<2/i?e*(t-=1.5/i)*t+.75:t<2.5/i?e*(t-=2.25/i)*t+.9375:e*(t-=2.625/i)*t+.984375},easeOutInBounce:t=>{const e=7.5625,i=2.75;let s;return t<.5?(s=(t=1-2*t)<1/i?e*t*t:t<2/i?e*(t-=1.5/i)*t+.75:t<2.5/i?e*(t-=2.25/i)*t+.9375:e*(t-=2.625/i)*t+.984375,(1-s)/2):(s=(t=2*t-1)<1/i?e*t*t:t<2/i?e*(t-=1.5/i)*t+.75:t<2.5/i?e*(t-=2.25/i)*t+.9375:e*(t-=2.625/i)*t+.984375,(1+s)/2)}},ht=function(t,e,i=z){if("function"==typeof window.IntersectionObserver&&t&&t.run){let s=new IntersectionObserver(((e,i)=>{let s,n,r;for(s=0,n=e.length;s<n;s++)r=e[s],r.isIntersecting?!t.isRunning()&&t.run():r.isIntersecting||t.isRunning()&&t.halt()}),i);return e&&e.domElement&&s.observe(e.domElement),function(){s.disconnect()}}return X},ct=function(t,e,i){if(!K(e))throw new Error(`core/document addListener() error - no function supplied: ${t}, ${i}`);return dt(t,e,i,"removeEventListener"),dt(t,e,i,"addEventListener"),function(){ut(t,e,i)}},ut=function(t,e,i){if(!K(e))throw new Error(`core/document removeListener() error - no function supplied: ${t}, ${i}`);dt(t,e,i,"removeEventListener")},dt=function(t,e,i,s){let n,r=[].concat(t);n=i.substring?document.body.querySelectorAll(i):Array.isArray(i)?i:[i],navigator.pointerEnabled||navigator.msPointerEnabled?pt(r,e,n,s):ft(r,e,n,s)},ft=function(t,e,i,s){let n,r,o,a,l,h;for(n=0,r=t.length;n<r;n++)for(l=t[n],o=0,a=i.length;o<a;o++){if(h=i[o],!(U(h)||h.document||h.characterSet))throw new Error(`core/document actionMouseListener() error - bad target: ${l}, ${h}`);switch(l){case"move":h[s]("mousemove",e,!1),h[s]("touchmove",e,{passive:!1}),h[s]("touchfollow",e,{passive:!1});break;case"up":h[s]("mouseup",e,!1),h[s]("touchend",e,{passive:!1});break;case"down":h[s]("mousedown",e,!1),h[s]("touchstart",e,{passive:!1});break;case"leave":h[s]("mouseleave",e,!1),h[s]("touchleave",e,{passive:!1});break;case"enter":h[s]("mouseenter",e,!1),h[s]("touchenter",e,{passive:!1})}}},pt=function(t,e,i,s){let n,r,o,a,l,h;for(n=0,r=t.length;n<r;n++)for(l=t[n],o=0,a=i.length;o<a;o++)if(h=i[o],U(h)||h.document||h.characterSet)switch(l){case"move":h[s]("pointermove",e,!1);break;case"up":h[s]("pointerup",e,!1);break;case"down":h[s]("pointerdown",e,!1);break;case"leave":h[s]("pointerleave",e,!1);break;case"enter":h[s]("pointerenter",e,!1)}},mt=function(t,e,i){if(!K(e))throw new Error(`core/document addNativeListener() error - no function supplied: ${t}, ${i}`);return yt(t,e,i,"removeEventListener"),yt(t,e,i,"addEventListener"),function(){gt(t,e,i)}},gt=function(t,e,i){if(!K(e))throw new Error(`core/document removeNativeListener() error - no function supplied: ${t}, ${i}`);yt(t,e,i,"removeEventListener")},yt=function(t,e,i,s){let n,r,o,a,l,h,c,u=[].concat(t);for(n=i.substring?document.body.querySelectorAll(i):Array.isArray(i)?i:[i],r=0,o=u.length;r<o;r++)for(h=u[r],a=0,l=n.length;a<l;a++){if(c=n[a],!(U(c)||c.document||c.characterSet))throw new Error(`core/document actionNativeListener() error - bad target: ${h}, ${c}`);c[s](h,e,!1)}};let bt=X;const St=t=>bt=t,kt=function(){let t=[];return(window.opr&&opr.addons||window.opera||navigator.userAgent.indexOf(" OPR/")>=0)&&t.push("old-opera"),"undefined"!=typeof InstallTrigger?t.push("firefox"):(/constructor/i.test(window.HTMLElement)||"[object SafariRemoteNotification]"===(!window.safari||"undefined"!=typeof safari&&safari.pushNotification).toString())&&t.push("safari"),document.documentMode&&t.push("internet-explorer"),t.indexOf("internet-explorer")<0&&window.StyleMedia&&t.push("edge"),window.chrome&&t.push("chrome"),(t.indexOf("chrome")>=0||t.indexOf("old-opera")>=0)&&window.CSS&&t.push("blink"),t}();window.scrawlEnvironmentBrowserDetection=kt;let At=0;const Ot=()=>At;let vt=!1;const wt=()=>vt,Ct=t=>vt=t,xt=()=>{At=window.devicePixelRatio;for(const[t,e]of Object.entries(o))e.dirtyDimensions=!0;for(const[t,e]of Object.entries(a))e.dirtyDimensions=!0;for(const[t,e]of Object.entries(h))e.dirtyHost=!0;vt||bt(),kt.indexOf("safari")<0&&matchMedia(`(resolution: ${At}dppx)`).addEventListener("change",xt,{once:!0})};function Pt(t=z){t.defs={},t.getters={},t.setters={},t.deltaSetters={},t.get=function(t){if(nt(t)){let e=this.getters[t];if(e)return e.call(this);{let e=this.defs[t];if(void 0!==e){let i=this[t];return void 0!==i?i:e}}}return null},t.set=function(t=z){const e=Object.keys(t),i=e.length;if(i){const s=this.setters,n=this.defs;let r,o,a,l;for(o=0;o<i;o++)a=e[o],l=t[a],a&&"name"!==a&&null!=l&&(r=s[a],r?r.call(this,l):void 0!==n[a]&&(this[a]=l))}return this},t.setDelta=function(t=z){const e=Object.keys(t),i=e.length;if(i){const s=this.deltaSetters,n=this.defs;let r,o,a,l;for(o=0;o<i;o++)a=e[o],l=t[a],a&&"name"!==a&&null!=l&&(r=s[a],r?r.call(this,l):void 0!==n[a]&&(this[a]=T(this[a],l)))}return this};t.defs=tt(t.defs,{name:""});let e=t.getters;return e.type=function(){return this.type},e.isArtefact=function(){return this.isArtefact},e.isAsset=function(){return this.isAsset},t.packetExclusions=[],t.packetExclusionsByRegex=[],t.packetCoordinates=[],t.packetObjects=[],t.packetFunctions=[],t.saveAsPacket=function(t=z){Z(t)&&t&&(t={includeDefaults:!0});let e=this.defs,i=Object.keys(e),s=this.packetExclusions,n=this.packetExclusionsByRegex,r=this.packetCoordinates,o=this.packetObjects,a=this.packetFunctions,l=t.includeDefaults||!1,h={};return l&&!Array.isArray(l)?l=Object.keys(e):l||(l=[]),Object.entries(this).forEach((([t,e])=>{let c,u=!0;if(i.indexOf(t)<0&&(u=!1),u&&s.indexOf(t)>=0&&(u=!1),u&&(c=n.some((e=>new RegExp(e).test(t))),c&&(u=!1)),u)if(a.indexOf(t)>=0){if(nt(e)&&null!==e){let i=this.stringifyFunction(e);i&&i.length&&(h[t]=i)}}else o.indexOf(t)>=0&&this[t]&&this[t].name?h[t]=this[t].name:r.indexOf(t)>=0?(l.indexOf(t)>=0||e[0]||e[1])&&(h[t]=e):(c=this.processPacketOut(t,e,l),c&&(h[t]=e))}),this),h=this.finalizePacketOut(h,t),JSON.stringify([this.name,this.type,this.lib,h])},t.stringifyFunction=function(t){let e=t.toString().match(/\(([\s\S]*?)\)[\s\S]*?\{([\s\S]*)\}/),i=e[1],s=e[2];return!!rt(i,s)&&`${i}~~~${s}`},t.processPacketOut=function(t,e,i){let s=!0;return i.indexOf(t)<0&&e===this.defs[t]&&(s=!1),s},t.finalizePacketOut=function(t,e){return t},t.importPacket=function(t){let e=this;const i=function(t){return new Promise(((i,s)=>{let n;t.substring||s(new Error("Packet url supplied for import is not a string")),"["===t[0]?(n=e.actionPacket(t),n&&n.lib?i(n):s(n)):t.indexOf('"name":')>=0?s(new Error("Bad packet supplied for import")):fetch(t).then((t=>{if(!t.ok)throw new Error(`Packet import from server failed - ${t.status}: ${t.statusText} - ${t.url}`);return t.text()})).then((t=>{if(n=e.actionPacket(t),!n||!n.lib)throw n;i(n)})).catch((t=>s(t)))}))};if(Array.isArray(t)){let e=[];return t.forEach((t=>e.push(i(t)))),new Promise(((t,i)=>{Promise.all(e).then((e=>t(e))).catch((t=>i(t)))}))}if(t.substring)return i(t);Promise.reject(new Error("Argument supplied for packet import is not a string or array of strings"))},t.actionPacketExclusions=["Image","Sprite","Video","Canvas","Stack"],t.actionPacket=function(t){try{if(t&&t.substring){if("["===t[0]){let e,i,s,n;try{[e,i,s,n]=JSON.parse(t)}catch(t){throw new Error(`Failed to process packet due to JSON parsing error - ${t.message}`)}if(rt(e,i,s,n)){if(this.actionPacketExclusions.indexOf(i)>=0)throw new Error("Failed to process packet - Stacks, Canvases and visual assets are excluded from the packet system");let t=P[s][e];if(t)t.set(n);else{if(n.outerHTML&&n.host){let t=document.querySelector(`#${n.host}`);if(t){let i=document.createElement("div");i.innerHTML=n.outerHTML;let s=i.firstElementChild;s&&(s.id=e,t.appendChild(s),n.domElement=s)}}if(t=new v[i](n),!t)throw new Error("Failed to create Scrawl-canvas object from supplied packet")}if(t.packetFunctions.forEach((e=>this.actionPacketFunctions(t,e))),n.anchor&&t.anchor&&t.anchor.packetFunctions.forEach((e=>{t.anchor[e]=n.anchor[e],this.actionPacketFunctions(t.anchor,e),t.anchor.build()})),n.glyphStyles&&t.glyphStyles&&n.glyphStyles.forEach(((e,i)=>{Q(e)&&t.setGlyphStyles(e,i)})),t)return t;throw new Error("Failed to process supplied packet")}throw new Error("Failed to process packet - JSON string holds incomplete data")}throw new Error("Failed to process packet - JSON string does not represent an array")}throw new Error("Failed to process packet - not a JSON string")}catch(t){return console.log(t),t}},t.actionPacketFunctions=function(t,e){let i=t[e];if(nt(i)&&null!==i&&i.substring)if("~~~"===i)t[e]=X;else{let s,n,r;[s,n]=i.split("~~~"),s=s.split(","),s=s.map((t=>t.trim())),n.indexOf("[native code]")<0?(r=new Function(...s,n),t[e]=r.bind(t)):t[e]=X}},t.clone=function(t=z){let e,i,s=this.name;this.name=t.name||"",t.useNewTicker?(i=this.ticker,this.ticker=null,e=this.saveAsPacket(),this.ticker=i):e=this.saveAsPacket(),this.name=s;let n=this.actionPacket(e);return this.packetFunctions.forEach((t=>{this[t]&&(n[t]=this[t])})),n=this.postCloneAction(n,t),n.set(t),n},t.postCloneAction=function(t,e){return t},t.kill=function(){return this.deregister()},t.makeName=function(t){return t&&t.substring&&P[`${this.lib}names`].indexOf(t)<0?this.name=t:this.name=W(),this},t.register=function(){if(!nt(this.name))throw new Error(`core/base error - register() name not set: ${this}`);let t=P[`${this.lib}names`],e=P[this.lib];return this.isArtefact&&(it(s,this.name),i[this.name]=this),this.isAsset&&(it(r,this.name),n[this.name]=this),it(t,this.name),e[this.name]=this,this},t.deregister=function(){if(!nt(this.name))throw new Error(`core/base error - deregister() name not set: ${this}`);let t=P[`${this.lib}names`],e=P[this.lib];return this.isArtefact&&(st(s,this.name),delete i[this.name]),this.isAsset&&(st(r,this.name),delete n[this.name]),st(t,this.name),delete e[this.name],this},t}xt();const Animation=function(t=z){return this.makeName(t.name),this.order=nt(t.order)?t.order:this.defs.order,this.fn=t.fn||G,this.onRun=t.onRun||X,this.onHalt=t.onHalt||X,this.onKill=t.onKill||X,this.register(),t.delay||this.run(),this};let Dt=Animation.prototype=Object.create(Object.prototype);Dt.type="Animation",Dt.lib="animation",Dt.isArtefact=!1,Dt.isAsset=!1,Dt=Pt(Dt);Dt.defs=tt(Dt.defs,{order:1,fn:null,onRun:null,onHalt:null,onKill:null}),Dt.stringifyFunction=X,Dt.processPacketOut=X,Dt.finalizePacketOut=X,Dt.saveAsPacket=function(){return`[${this.name}, ${this.type}, ${this.lib}, {}]`},Dt.clone=N,Dt.run=function(){return this.onRun(),it(E,this.name),M(),setTimeout((()=>oe()),20),this},Dt.isRunning=function(){return E.indexOf(this.name)>=0},Dt.halt=function(){return this.onHalt(),st(E,this.name),M(),this},Dt.kill=function(){return this.onKill(),st(E,this.name),M(),this.deregister(),!0};const Rt=function(t){return!!t&&new Animation(t)};v.Animation=Animation;const Ft=[];let Et=!1,Mt=!1,Ht=!1,It=!1,Bt=!1,Tt=!1,Lt=!1,$t=!1;const jt={x:0,y:0,scrollX:0,scrollY:0,w:0,h:0,type:"mouse",prefersReducedMotion:!1,prefersDarkColorScheme:!1,prefersReduceTransparency:!1,prefersContrast:!1,prefersReduceData:!1,rawTouches:[]},Xt=window.matchMedia("(prefers-contrast: more)");Xt.addEventListener("change",(()=>{let t=Xt.matches;jt.prefersContrast!==t&&(jt.prefersContrast=t,It=!0)})),jt.prefersContrast=Xt.matches;const Yt=window.matchMedia("(prefers-reduced-motion: reduce)");Yt.addEventListener("change",(()=>{let t=Yt.matches;jt.prefersReducedMotion!==t&&(jt.prefersReducedMotion=t,Bt=!0)})),jt.prefersReducedMotion=Yt.matches;const Nt=window.matchMedia("(prefers-color-scheme: dark)");Nt.addEventListener("change",(()=>{let t=Nt.matches;jt.prefersDarkColorScheme!==t&&(jt.prefersDarkColorScheme=t,Tt=!0)})),jt.prefersDarkColorScheme=Nt.matches;const Gt=window.matchMedia("(prefers-reduced-transparency: reduce)");Gt.addEventListener("change",(()=>{let t=Gt.matches;jt.prefersReduceTransparency!==t&&(jt.prefersReduceTransparency=t,Lt=!0)})),jt.prefersReduceTransparency=Gt.matches;const zt=window.matchMedia("(prefers-reduced-data: reduce)");zt.addEventListener("change",(()=>{let t=zt.matches;jt.prefersReduceData!==t&&(jt.prefersReduceData=t,$t=!0)})),jt.prefersReduceData=zt.matches;const Wt=function(t){let e=document.documentElement.clientWidth,i=document.documentElement.clientHeight;jt.w===e&&jt.h===i||(jt.w=e,jt.h=i,Mt=!0,Ht=!0)},Vt=function(t){let e=window.pageXOffset,i=window.pageYOffset;jt.scrollX===e&&jt.scrollY===i||(jt.x+=e-jt.scrollX,jt.y+=i-jt.scrollY,jt.scrollX=e,jt.scrollY=i,Mt=!0)},Zt=function(t){let e=Math.round(t.pageX),i=Math.round(t.pageY);jt.x===e&&jt.y===i||(jt.type=navigator.pointerEnabled?"pointer":"mouse",jt.x=e,jt.y=i,Mt=!0)};let _t=0,Ut=16;const Kt=function(){return Ut},qt=function(t){t&&t.toFixed&&!isNaN(t)&&(Ut=t)},Qt=function(t,e=!0){if(jt.rawTouches.length=0,t.touches&&t.touches.length){jt.rawTouches.push(...t.touches);const e=t.touches[0],i=Math.round(e.pageX),s=Math.round(e.pageY);jt.x===i&&jt.y===s||(jt.type="touch",jt.x=i,jt.y=s)}else jt.type="touch",e&&(jt.x=0,jt.y=0);const i=Date.now();i>_t+Ut&&(_t=i,Jt())},Jt=function(){for(let t=0,e=Ft.length;t<e;t++)te(Ft[t])},te=function(t){const e=i[t];if(e){e.here||(e.here={});const{here:t,domElement:i}=e;if(t.prefersContrast=jt.prefersContrast,t.prefersReducedMotion=jt.prefersReducedMotion,t.prefersDarkColorScheme=jt.prefersDarkColorScheme,t.prefersReduceTransparency=jt.prefersReduceTransparency,t.prefersReduceData=jt.prefersReduceData,It&&e.contrastActions(),Bt&&e.reducedMotionActions(),Tt&&e.colorSchemeActions(),Lt&&e.reducedTransparencyActions(),$t&&e.reducedDataActions(),i){const s=i.getBoundingClientRect(),n=Math.round(s.left+window.pageXOffset),r=Math.round(s.top+window.pageYOffset),o=s.top,a=s.height,l=window.innerHeight;t.w=Math.round(s.width),t.h=Math.round(a),t.type=jt.type;const h=o/l,c=(o+a)/l,u=(h+c)/2;t.inViewportTop=h,t.inViewportBase=c,t.inViewportCenter=u,e.localMouseListener?(t.localListener=!0,t.active=!1,t.normX=!!t.originalWidth&&t.x/t.originalWidth,t.normY=!!t.originalHeight&&t.y/t.originalHeight,t.offsetX=n,t.offsetY=r,t.x>e.activePadding&&t.x<t.originalWidth-e.activePadding&&t.y>0+e.activePadding&&t.y<t.originalHeight-e.activePadding&&(t.active=!0)):(t.localListener=!1,t.active=!0,t.x=Math.round(jt.x-n),t.y=Math.round(jt.y-r),t.normX=!!t.w&&t.x/t.w,t.normY=!!t.h&&t.y/t.h,t.offsetX=n,t.offsetY=r,(t.normX<0||t.normX>1||t.normY<0||t.normY>1)&&(t.active=!1));const d=jt.rawTouches;if(d.length){t.touches||(t.touches=[]),t.touches.length=0;for(let e=0,i=d.length;e<i;e++){const i=d[e];t.touches.push([Math.round(i.pageX-n),Math.round(i.pageY-r)])}}if("Canvas"===e.type&&e.updateBaseHere(t,e.fit),e.checkForResize&&!e.dirtyDimensions&&!e.dirtyDomDimensions){let[i,s]=e.currentDimensions;if("Canvas"===e.type){e.computedStyles||(e.computedStyles=window.getComputedStyle(e.domElement));let n=e.computedStyles,r=Math.floor(t.w-parseFloat(n.borderLeftWidth)-parseFloat(n.borderRightWidth)-parseFloat(n.paddingLeft)-parseFloat(n.paddingRight)),o=Math.floor(t.h-parseFloat(n.borderTopWidth)-parseFloat(n.borderBottomWidth)-parseFloat(n.paddingTop)-parseFloat(n.paddingBottom));i===r&&s===o||e.set({dimensions:[r,o]})}else i===t.w&&s===t.h||e.set({dimensions:[t.w,t.h]})}}}},ee=Rt({name:"coreListenersTracker",order:0,delay:!0,fn:function(){if(!Ft.length)return!1;(Et&&Mt||Bt||Tt||Lt||$t)&&(Jt(),Et&&Mt&&(Mt=!1),(Bt||Tt||Lt||$t)&&(Bt=!1,Tt=!1,Lt=!1,$t=!1)),Ht&&(Ht=!1,function(){for(const[t,e]of Object.entries(h))"Phrase"===e.type&&(e.dirtyDimensions=!0,e.dirtyFont=!0)}())}}),ie=function(){ne("removeEventListener"),ne("addEventListener"),Et=!0,Mt=!0,ee.run()},se=function(){Et=!1,Mt=!1,ee.halt(),ne("removeEventListener")},ne=function(t){navigator.pointerEnabled||navigator.msPointerEnabled?(window[t]("pointermove",Zt,!1),window[t]("pointerup",Zt,!1),window[t]("pointerdown",Zt,!1),window[t]("pointerleave",Zt,!1),window[t]("pointerenter",Zt,!1)):(window[t]("mousemove",Zt,!1),window[t]("mouseup",Zt,!1),window[t]("mousedown",Zt,!1),window[t]("mouseleave",Zt,!1),window[t]("mouseenter",Zt,!1),window[t]("touchmove",Qt,{passive:!0}),window[t]("touchstart",Qt,{passive:!0}),window[t]("touchend",Qt,{passive:!0}),window[t]("touchcancel",Qt,{passive:!0})),window[t]("scroll",Vt,{passive:!0}),window[t]("resize",Wt,!1)},re=function(){Wt(),Mt=!0,Ht=!0},oe=function(){Mt=!0,Ht=!0},ae=function(t=z){if(!rt(t.event,t.origin,t.updates))return!1;let e=t.target.substring&&t.targetLibrarySection?P[t.targetLibrarySection][t.target]:t.target;if(!e)return!1;let i=t.event,s=t.origin,n=t.useNativeListener?mt:ct,r=t.useNativeListener?gt:ut,o=X;t.preventDefault&&(o=t=>{t.preventDefault(),t.returnValue=!1});let a=K(t.setup)?t.setup:X,l=K(t.callback)?t.callback:X,h=function(i){o(i);let s=!(!i||!i.target)&&i.target.id;if(s){let n=t.updates[s];if(n){a();let t,s=n[0],r=n[1],o=i.target.value,h=!0;switch(r){case"float":t=parseFloat(o);break;case"int":t=parseInt(o,10);break;case"round":t=Math.round(o);break;case"roundDown":t=Math.floor(o);break;case"roundUp":t=Math.ceil(o);break;case"raw":t=o;break;case"string":t=`${o}`;break;case"boolean":t=!!nt(o)&&(o.substring?"true"===o.toLowerCase()||"false"!==o.toLowerCase()&&!!parseFloat(o):!!o);break;default:r.substring?t=`${parseFloat(o)}${r}`:h=!1}h&&("Group"===e.type?e.setArtefacts({[s]:t}):e.set({[s]:t}),l())}}};return n(i,h,s),function(){r(i,h,s)}},le={},he=function(t=z){const e=(t=z)=>{if(t&&t.target){let e=t.target,s="";for(;!s&&(le[e.id]&&(s=e.id),"BODY"!==e.tagName);)e=e.parentElement;const r=le[s];if(r)for(let e=0,s=r.length;e<s;e++){const s=r[e].pickup(t);if(s.current){i=s.move,n=s.drop;break}}}};let i=X;const s=(t=z)=>{i(t)};let n=X;const r=(t=z)=>{n(t),i=X,n=X},o=function(t=z,e,i){let{zone:s,coordinateSource:n,collisionGroup:r,startOn:o,endOn:a,updateOnStart:l,updateOnEnd:h,updateWhileMoving:c,updateOnShiftStart:u,updateOnShiftEnd:f,updateWhileShiftMoving:p,updateOnPrematureExit:m,exposeCurrentArtefact:g,preventTouchDefaultWhenDragging:y,resetCoordsToZeroOnTouchEnd:b,processingOrder:S}=t;if(!s)return new Error("dragZone constructor - no zone supplied");if(s.substring&&(s=artefact[s]),!s||["Canvas","Stack"].indexOf(s.type)<0)return new Error("dragZone constructor - zone object is not a Stack or Canvas wrapper");let k=s.domElement;if(!k)return new Error("dragZone constructor - zone does not contain a target DOM element");if(r?r.substring&&(r=d[r]):r="Canvas"===s.type?d[s.base.name]:d[s.name],!r||"Group"!==r.type)return new Error("dragZone constructor - unable to recover collisionGroup group");if(n?n.here?n=n.here:rt(n.x,n.y)||(n=!1):n="Canvas"===s.type?s.base.here:s.here,!n)return new Error("dragZone constructor - unable to discover a usable coordinateSource object");Array.isArray(o)||(o=["down"]),Array.isArray(a)||(a=["up"]),null==g&&(g=!1),null==y&&(y=!1),null==b&&(b=!0),Q(l)&&(l=function(){A.artefact.set(t.updateOnStart)}),K(l)||(l=X),Q(u)&&(u=function(){A.artefact.set(t.updateOnShiftStart)}),K(u)||(u=l),Q(h)&&(h=function(){A.artefact.set(t.updateOnEnd)}),K(h)||(h=X),Q(f)&&(f=function(){A.artefact.set(t.updateOnShiftEnd)}),K(f)||(f=h),K(c)||(c=X),K(p)||(p=c),K(m)||(m=X),Z(g)||(g=!1),null==S&&(S=0);let A=!1;const O=function(t){t&&t.cancelable&&(y&&A?(t.preventDefault(),t.returnValue=!1):y||(t.preventDefault(),t.returnValue=!1))},v=function(t=z){A&&(O(t),"touchmove"===t.type&&Qt(t),t.shiftKey?p(t):c(t))},w=function(t=z){A&&(O(t),"touchend"===t.type&&Qt(t,b),A.artefact.dropArtefact(),t.shiftKey?f(t):h(t),A=!1)};le[s.name]||(le[s.name]=[],e(o,a,k));const C=function(){const t=`${s.name}_${r.name}_${S}`;le[s.name]=le[s.name].filter((e=>e.name!==t)),le[s.name].length||i(o,a,k)},x=function(t){if(!t)return A;"exit"===t||"drop"===t?(w(),m()):C()},P={name:`${s.name}_${r.name}_${S}`,exposeCurrentArtefact:g,target:k,processingOrder:S,pickup:function(t=z){O(t);let e=t.type;return"touchstart"!==e&&"touchcancel"!==e||Qt(t,b),A=r.getArtefactAt(n),A&&(A.artefact.pickupArtefact(n),t.shiftKey?u(t):l(t)),{current:A,move:v,drop:w}},move:v,drop:w,kill:C,getCurrent:x};return le[s.name].push(P),le[s.name].sort(((t,e)=>t.processingOrder-e.processingOrder)),{exposeCurrentArtefact:g,getCurrent:x,kill:C,zone:s}}(t,((t,i,n)=>{ct(t,e,n),ct("move",s,n),ct(i,r,n)}),((t,i,n)=>{ut(t,e,n),ut("move",s,n),ut(i,r,n)}));return o.exposeCurrentArtefact?o.getCurrent:o.kill},ce={},ue=function(t=z){const e=(t=z)=>{if(t&&t.target){let e=t.target,s="";for(;!s&&(le[e.id]&&(s=e.id),"BODY"!==e.tagName);)e=e.parentElement;const n=ce[s];n?(n.onKeyDown(t),i=n.onKeyUp):i=X}};let i=X;const s=t=>{i(t)};return function(t=z,e,i){let{zone:s}=t;if(!s)return new Error("keyboardZone constructor - no zone supplied");if(s.substring&&(s=artefact[s]),!s||["Canvas","Stack"].indexOf(s.type)<0)return new Error("keyboardZone constructor - zone object is not a Stack or Canvas wrapper");let n=s.domElement;if(!n)return new Error("keyboardZone constructor - zone does not contain a target DOM element");let r=ce[s.name];r||(ce[s.name]={},r=ce[s.name],e(n)),r.extraKeys||(r.extraKeys={Shift:!1,Control:!1,Alt:!1,Meta:!1});const o=["none","shiftOnly","altOnly","ctrlOnly","metaOnly","shiftAlt","shiftCtrl","shiftMeta","altCtrl","altMeta","ctrlMeta","shiftAltCtrl","shiftAltMeta","shiftCtrlMeta","altCtrlMeta","all"];if(!r.keyGroups){const t={};o.forEach((e=>t[e]={})),r.keyGroups=t}const a=r.keyGroups;return o.forEach((e=>{const i=t[e];null!=i&&et(a[e],i)})),r.onKeyDown||(r.onKeyDown=(t=z)=>{if(t&&t.key){t.preventDefault();const{extraKeys:e,keyGroups:i}=r,{key:s}=t;if("Tab"===s||"Escape"===s)return void n.blur();if(null!=e[s])return void(e[s]=!0);const{Shift:o,Control:a,Alt:l,Meta:h}=e;let c=i.none;(o||a||l||h)&&(c=o?l?a?h?i.all:i.shiftAltCtrl:h?i.shiftAltMeta:i.shiftAlt:a?h?i.shiftCtrlMeta:i.shiftCtrl:h?i.shiftMeta:i.shiftOnly:l?a?h?i.altCtrlMeta:i.altCtrl:h?i.altMeta:i.altOnly:a?h?i.ctrlMeta:i.ctrlOnly:h?i.altOnly:i.none),c[s]&&c[s]()}}),r.onKeyUp||(r.onKeyUp=(t=z)=>{if(t&&t.key){t.preventDefault();const{extraKeys:e}=r,{key:i}=t;null!=e[i]&&(e[i]=!1)}}),r.kill||(r.kill=function(){delete ce[s.name],i(n)}),{kill:r.kill,getMappedKeys:(t="none")=>null!=r.keyGroups[t]?Object.keys(r.keyGroups[t]):[]}}(t,(t=>{mt("keydown",e,t),mt("keyup",s,t)}),(t=>{gt("keydown",e,t),gt("keyup",s,t)}))};var de=function(){var t=4022871197;return function(e){if(e){e=e.toString();for(var i=0;i<e.length;i++){var s=.02519603282416938*(t+=e.charCodeAt(i));s-=t=s>>>0,t=(s*=t)>>>0,t+=4294967296*(s-=t)}return 2.3283064365386963e-10*(t>>>0)}t=4022871197}},fe=function(t){return function(){var e,i,s=48,n=1,r=s,o=new Array(s),a=0,l=new de;for(e=0;e<s;e++)o[e]=l(Math.random());var h=function(){++r>=s&&(r=0);var t=1768863*o[r]+2.3283064365386963e-10*n;return o[r]=t-(n=0|t)},c=function(t){return Math.floor(t*(h()+11102230246251565e-32*(2097152*h()|0)))};c.string=function(t){var e,i="";for(e=0;e<t;e++)i+=String.fromCharCode(33+c(94));return i};var u=function(){var t=Array.prototype.slice.call(arguments);for(e=0;e<t.length;e++)for(i=0;i<s;i++)o[i]-=l(t[e]),o[i]<0&&(o[i]+=1)};return c.cleanString=function(t){return t=(t=(t=t.replace(/(^\s*)|(\s*$)/gi,"")).replace(/[\x00-\x1F]/gi,"")).replace(/\n /,"\n")},c.hashString=function(t){for(t=c.cleanString(t),l(t),e=0;e<t.length;e++)for(a=t.charCodeAt(e),i=0;i<s;i++)o[i]-=l(a),o[i]<0&&(o[i]+=1)},c.seed=function(t){var e,i,s,n;null==t&&(t=Math.random()),"string"!=typeof t&&(e=t,i=function(t,e){return"function"==typeof e?e.toString():e},t=JSON.stringify(e,function(t,e){var i=[],s=[];return null==e&&(e=function(t,e){return i[0]===e?"[Circular ~]":"[Circular ~."+s.slice(0,i.indexOf(e)).join(".")+"]"}),function(n,r){if(i.length>0){var o=i.indexOf(this);~o?i.splice(o+1):i.push(this),~o?s.splice(o,1/0,n):s.push(n),~i.indexOf(r)&&(r=e.call(this,n,r))}else i.push(r);return null==t?r:t.call(this,n,r)}}(i,n),s)),c.initState(),c.hashString(t)},c.addEntropy=function(){var t=[];for(e=0;e<arguments.length;e++)t.push(arguments[e]);u(a+++(new Date).getTime()+t.join("")+Math.random())},c.initState=function(){for(l(),e=0;e<s;e++)o[e]=l(" ");n=1,r=s},c.done=function(){l=null},void 0!==t&&c.seed(t),c.range=function(t){return c(t)},c.random=function(){return c(Number.MAX_VALUE-1)/Number.MAX_VALUE},c.floatBetween=function(t,e){return c.random()*(e-t)+t},c.intBetween=function(t,e){return Math.floor(c.random()*(e-t+1))+t},c}()};const pe=function(t){return new fe(t)},State=function(t=z){return this.set(this.defs),this.lineDash=[],this};let me=State.prototype=Object.create(Object.prototype);me.type="State",me=Pt(me),me.defs={fillStyle:"rgba(0,0,0,1)",strokeStyle:"rgba(0,0,0,1)",globalAlpha:1,globalCompositeOperation:"source-over",lineWidth:1,lineCap:"butt",lineJoin:"miter",lineDash:null,lineDashOffset:0,miterLimit:10,shadowOffsetX:0,shadowOffsetY:0,shadowBlur:0,shadowColor:"rgba(0,0,0,0)",font:"12px sans-serif",textAlign:"left",textBaseline:"top",filter:"none",imageSmoothingEnabled:!0,imageSmoothingQuality:"high"},me.processPacketOut=function(t,e,i){let s=!0;if("lineDash"===t)e.length||(s=i.indexOf("lineDash")>=0);else i.indexOf(t)<0&&e===this.defs[t]&&(s=!1);return s},me.finalizePacketOut=function(t,e){let i=t.fillStyle,s=t.strokeStyle;return i&&!i.substring&&(t.fillStyle=i.name),s&&!s.substring&&(t.strokeStyle=s.name),t},me.set=function(t=z){let e,i,s=Object.keys(t),n=s.length,r=this.defs;for(i=0;i<n;i++)e=s[i],"name"!=e&&void 0!==r[e]&&(this[e]=t[e],this.dirtyFilterIdentifier=!0);return this},me.get=function(t){let e,i;return e=this.defs[t],void 0!==e?(i=this[t],void 0!==i?i:e):void 0},me.getters;let ge=me.setters;me.deltaSetters,ge.fillStyle=function(t){let e;Q(t)&&"styles"===t.lib?this.fillStyle=t:(e=k[t],e?this.fillStyle=e:t.includes("rgb")||t.includes("hsl")||t.includes("#")?this.fillStyle=t:this.fillStyle=window.scrawlEnvironmentColorChecker.checkColor(t))},ge.strokeStyle=function(t){let e;Q(t)&&"styles"===t.lib?this.strokeStyle=t:(e=k[t],e?this.strokeStyle=e:t.includes("rgb")||t.includes("hsl")||t.includes("#")?this.strokeStyle=t:this.strokeStyle=window.scrawlEnvironmentColorChecker.checkColor(t))},ge.shadowColor=function(t){t.includes("rgb")||t.includes("hsl")||t.includes("#")?this.shadowColor=t:this.shadowColor=window.scrawlEnvironmentColorChecker.checkColor(t)},me.allKeys=Object.keys(me.defs),me.mainKeys=["filter","globalAlpha","globalCompositeOperation","imageSmoothingEnabled","imageSmoothingQuality","shadowBlur","shadowOffsetX","shadowOffsetY"],me.lineKeys=["lineCap","lineDash","lineDashOffset","lineJoin","lineWidth","miterLimit"],me.styleKeys=["fillStyle","shadowColor","strokeStyle"],me.textKeys=["font"],me.getChanges=function(t,e){let i,s,n,r,o,a,l,c,u,d=this.mainKeys,f=this.lineKeys,p=this.styleKeys,m=this.textKeys,g=this.defs,y={},b=function(t,e){return void 0!==t[e]?t[e]:g[e]};for(t.substring&&(t=h[t]),n=0,r=d.length;n<r;n++)i=d[n],c=b(this,i),u=b(e,i),u!==c&&(y[i]=c);if(this.lineWidth||e.lineWidth)for(n=0,r=f.length;n<r;n++)if(i=f[n],c=b(this,i),u=b(e,i),"lineDash"==i){if(c.length||u.length)if(c.length!=u.length)y.lineDash=c;else{for(l=!1,o=0,a=c.length;o<a;o++)if(c[o]!=u[o]){l=!0;break}l&&(y.lineDash=c)}}else"lineWidth"==i?t.scaleOutline?(s=(c||1)*(t.scale||1),s!==u&&(y.lineWidth=s)):c!==u&&(y.lineWidth=c):u!==c&&(y[i]=c);for(n=0,r=p.length;n<r;n++)i=p[n],u=b(e,i),c=b(this,i),c.substring&&u!==c?y[i]=c:"Color"===c.type?(c=c.getData(),u!==c&&(y[i]=c)):y[i]=c;if("Phrase"===t.type)for(n=0,r=m.length;n<r;n++)i=m[n],c=b(this,i),u=b(e,i),u!==c&&(y[i]=c);return y},me.setStateFromEngine=function(t){let e,i=this.allKeys;for(let s=0,n=i.length;s<n;s++)e=i[s],this[e]=t[e];return this.lineDash=nt(t.lineDash)?t.lineDash:[],this.lineDashOffset=ot(t.lineDashOffset,0),t.textAlign=this.textAlign="left",t.textBaseline=this.textBaseline="top",this};const ye=function(t){return!!t&&new State(t)},be=["fillStyle","filter","globalAlpha","globalCompositeOperation","imageSmoothingEnabled","imageSmoothingQuality","lineCap","lineDash","lineDashOffset","lineJoin","lineWidth","miterLimit","shadowBlur","shadowColor","shadowOffsetX","shadowOffsetY","strokeStyle"];v.State=State;const Coordinate=function(t,e){let i=[0,0];return Object.setPrototypeOf(i,Coordinate.prototype),t&&i.set(t,e),i};let Se=Coordinate.prototype=Object.create(Array.prototype);Se.constructor=Coordinate,Se.type="Coordinate",Se.set=function(t,e){return nt(t)&&("Coordinate"===t.type?this.setFromArray(t):"Vector"===t.type?this.setFromVector(t):"Quaternion"===t.type?this.setFromVector(t.v):Array.isArray(t)?this.setFromArray(t):nt(e)&&this.setFromArray([t,e])),this},Se.setFromArray=function(t){return this[0]=t[0],this[1]=t[1],this},Se.setFromVector=function(t){return this[0]=t.x,this[1]=t.y,this},Se.zero=function(){return this[0]=0,this[1]=0,this},Se.vectorAdd=function(t){return this[0]+=t.x,this[1]+=t.y,this},Se.vectorSubtract=function(t){return this[0]-=t.x,this[1]-=t.y,this},Se.add=function(t){return this[0]+=t[0],this[1]+=t[1],this},Se.subtract=function(t){return this[0]-=t[0],this[1]-=t[1],this},Se.multiply=function(t){return this[0]*=t[0],this[1]*=t[1],this},Se.divide=function(t){let[e,i]=t;return e&&i&&(this[0]/=e,this[1]/=i),this},Se.scalarMultiply=function(t){return this[0]*=t,this[1]*=t,this},Se.scalarDivide=function(t){return t&&t.toFixed&&(this[0]/=t,this[1]/=t),this},Se.getMagnitude=function(){return Math.hypot(this[0],this[1])},Se.rotate=function(t){let e,i,s=this[0],n=this[1];return e=Math.atan2(n,s),e+=.01745329251*t,i=Math.hypot(s,n),this[0]=i*Math.cos(e),this[1]=i*Math.sin(e),this},Se.reverse=function(){return this[0]=-this[0],this[1]=-this[1],this},Se.getDotProduct=function(t){return this[0]*t[0]+this[1]*t[1]},Se.normalize=function(){let t=this.getMagnitude();return t>0&&(this[0]/=t,this[1]/=t),this};const ke=[],Ae=function(t,e){ke.length||ke.push(new Coordinate);let i=ke.shift();return i.set(t,e),i},Oe=function(t){t&&"Coordinate"===t.type&&ke.push(t.zero())},ve=function(t,e){return new Coordinate(t,e)};function we(t=z){t.defs=tt(t.defs,{sourceLoaded:!1,source:null,subscribers:null}),t.packetExclusions=it(t.packetExclusions,["sourceLoaded","source","subscribers"]),t.finalizePacketOut=function(t,e){return this.subscribers&&this.subscribers.length&&(t.subscribers=this.subscribers.map((t=>t.name))),t},t.kill=function(t=!1){return t&&this.source&&this.source.remove(),this.deregister()},t.getters;let e=t.setters;return t.deltaSetters,e.source=function(t){t&&this.sourceLoaded&&this.notifySubscribers()},e.subscribers=X,t.assetConstructor=function(t){return this.makeName(t.name),this.register(),this.subscribers=[],this.set(this.defs),this.set(t),t.subscribe&&this.subscribers.push(t.subscribe),this},t.subscribe=function(t){if(t&&t.name){let e=t.name;this.subscribers.every((t=>t.name!==e))&&this.subscribeAction(t)}},t.subscribeAction=function(t){t&&(this.subscribers.push(t),t.asset=this,t.source=this.source,this.notifySubscriber(t))},t.unsubscribe=function(t){if(t&&t.name){let e=t.name,i=this.subscribers.findIndex((t=>t.name===e));i>=0&&(t.source=null,t.asset=null,t.sourceNaturalHeight=0,t.sourceNaturalWidth=0,t.sourceLoaded=!1,this.subscribers.splice(i,1))}},t.notifySubscribers=function(){this.subscribers.forEach((t=>this.notifySubscriber(t)),this)},t.notifySubscriber=function(t){t.sourceNaturalWidth=this.sourceNaturalWidth,t.sourceNaturalHeight=this.sourceNaturalHeight,t.sourceLoaded=this.sourceLoaded,t.source=this.source,t.dirtyImage=!0,t.dirtyCopyStart=!0,t.dirtyCopyDimensions=!0,t.dirtyImageSubscribers=!0,t.dirtyFilterIdentifier=!0},t}v.Coordinate=Coordinate;const ImageAsset=function(t=z){return this.assetConstructor(t)};let Ce=ImageAsset.prototype=Object.create(Object.prototype);Ce.type="Image",Ce.lib="asset",Ce.isArtefact=!1,Ce.isAsset=!0,Ce=Pt(Ce),Ce=we(Ce);Ce.defs=tt(Ce.defs,{intrinsicDimensions:null}),Ce.saveAsPacket=function(){return[this.name,this.type,this.lib,{}]},Ce.stringifyFunction=X,Ce.processPacketOut=X,Ce.finalizePacketOut=X,Ce.clone=N;let xe=Ce.getters,Pe=Ce.setters;Ce.deltaSetters,xe.width=function(){return this.sourceNaturalWidth||this.source.naturalWidth||0},xe.height=function(){return this.sourceNaturalHeight||this.source.naturalHeight||0},Pe.source=function(t){t&&(["IMG","PICTURE"].indexOf(t.tagName.toUpperCase())>=0&&(this.source=t,this.sourceNaturalWidth=t.naturalWidth,this.sourceNaturalHeight=t.naturalHeight,this.sourceLoaded=t.complete),this.sourceLoaded&&this.notifySubscribers())},Pe.currentSrc=function(t){this.currentSrc=t,this.currentFile=this.currentSrc.split("/").pop()},Ce.checkSource=function(t,e){let i=this.source,s="element";if(this.sourceLoaded){let n=this.intrinsicDimensions[this.currentFile];switch(this.currentSrc!==i.currentSrc?(this.set({currentSrc:i.currentSrc}),n=this.intrinsicDimensions[this.currentFile],s=n?"intrinsic":"zero"):n&&(s="intrinsic"),s){case"zero":this.sourceNaturalWidth=0,this.sourceNaturalHeight=0,this.notifySubscribers();break;case"intrinsic":this.sourceNaturalWidth===n[0]&&this.sourceNaturalHeight===n[1]||(this.sourceNaturalWidth=n[0],this.sourceNaturalHeight=n[1],this.notifySubscribers());break;default:this.sourceNaturalWidth===i.naturalWidth&&this.sourceNaturalHeight===i.naturalHeight&&this.sourceNaturalWidth===t&&this.sourceNaturalHeight===e||(this.sourceNaturalWidth=i.naturalWidth,this.sourceNaturalHeight=i.naturalHeight,this.notifySubscribers())}}};const De=[],Re=[],Fe=function(...t){let e=/.*\/(.*?)\./,i=[];return t.forEach((t=>{let s,n,r,o,a=!1,l=!1;if(t.substring){let i=e.exec(t);s=i&&i[1]?i[1]:"",n=t,r="",o=!1,l=!0}else(t=!!Q(t)&&t)&&t.src&&(s=t.name||"",n=t.src,r=t.className||"",o=t.visibility||!1,t.parent&&(a=document.querySelector(t.parent)),l=!0);if(l){let t=Be({name:s,intrinsicDimensions:{}}),e=document.createElement("img");e.name=s,e.className=r,e.crossorigin="anonymous",e.style.display=o?"block":"none",a&&a.appendChild(e),e.onload=()=>{t.set({source:e})},e.src=n,t.set({source:e}),i.push(s)}else i.push(!1)})),i},Ee=function(t){let e=/.*\/(.*?)\./;document.querySelectorAll(t).forEach((t=>{let i;if(["IMG","PICTURE"].indexOf(t.tagName.toUpperCase())>=0){if(t.id||t.name)i=t.id||t.name;else{let s=e.exec(t.src);i=s&&s[1]?s[1]:""}let s=t.dataset.dimensions||{};s.substring&&(s=JSON.parse(s));let n=Be({name:i,source:t,intrinsicDimensions:s,currentSrc:t.currentSrc});t.onload=()=>{n.set({source:t})}}}))},Me=function(t,e=!1){let i=t.substring?a[t]||o[t]:t;"Canvas"===i.type&&(i=i.base),"Cell"===i.type&&(i.stashOutput=!0,e&&(i.stashOutputAsAsset=!0))},He=function(t,e=!1){let i;t&&!t.substring?"Group"===t.type?i=t:"Cell"===t.type?i=d[t.name]:"Canvas"===t.type&&(i=d[t.base.name]):t&&t.substring&&(i=d[t]),i&&(i.stashOutput=!0,e&&(i.stashOutputAsAsset=!0))},Ie=function(t,e=!1){let s=t.substring?i[t]:t;s.isArtefact&&(s.stashOutput=!0,e&&(s.stashOutputAsAsset=!0))},Be=function(t){return!!t&&new ImageAsset(t)};function Te(t=z){t.defs=tt(t.defs,{group:null,visibility:!0,calculateOrder:0,stampOrder:0,start:null,handle:null,offset:null,dimensions:null,pivoted:null,mimicked:null,particle:null,lockTo:null,bringToFrontOnDrag:!0,ignoreDragForX:!1,ignoreDragForY:!1,scale:1,roll:0,noUserInteraction:!1,noPositionDependencies:!1,noCanvasEngineUpdates:!1,noFilters:!1,noPathUpdates:!1,purge:null}),t.packetExclusions=it(t.packetExclusions,["pathObject","mimicked","pivoted"]),t.packetExclusionsByRegex=it(t.packetExclusionsByRegex,["^(local|dirty|current)","Subscriber$"]),t.packetCoordinates=it(t.packetCoordinates,["start","handle","offset"]),t.packetObjects=it(t.packetObjects,["group"]),t.packetFunctions=it(t.packetFunctions,[]),t.processPacketOut=function(t,e,i){let s=!0;if("lockTo"===t)"start"===e[0]&&"start"===e[1]&&(s=i.indexOf("lockTo")>=0);else"entity"===this.lib?s=this.processEntityPacketOut(t,e,i):this.isArtefact&&(s=this.processDOMPacketOut(t,e,i));return s},t.handlePacketAnchor=function(t,e){if(this.anchor){let i=JSON.parse(this.anchor.saveAsPacket(e))[3];t.anchor=i}return t},t.kill=function(t=!1,e=!1){let s=this.name;return Object.entries(d).forEach((([t,e])=>{e.artefacts.indexOf(s)>=0&&e.removeArtefacts(s)})),this.anchor&&this.demolishAnchor(),Object.entries(i).forEach((([t,e])=>{e.name!==s&&(e.pivot&&e.pivot.name===s&&e.set({pivot:!1}),e.mimic&&e.mimic.name===s&&e.set({mimic:!1}),e.path&&e.path.name===s&&e.set({path:!1}),e.generateAlongPath&&e.generateAlongPath.name===s&&e.set({generateAlongPath:!1}),e.generateInArea&&e.generateInArea.name===s&&e.set({generateInArea:!1}),e.artefact&&e.artefact.name===s&&e.set({artefact:!1}),Array.isArray(e.pins)&&e.pins.forEach(((t,i)=>{Q(t)&&t.name===s&&e.removePinAt(i)})))})),Object.entries(S).forEach((([t,e])=>{e.checkForTarget(s)&&e.removeFromTargets(this)})),this.factoryKill(t,e),this.deregister(),this},t.factoryKill=X;let e=t.getters,s=t.setters,n=t.deltaSetters;return e.positionX=function(){return this.currentStampPosition[0]},e.positionY=function(){return this.currentStampPosition[1]},e.position=function(){return[].concat(this.currentStampPosition)},e.startX=function(){return this.currentStart[0]},e.startY=function(){return this.currentStart[1]},e.start=function(){return[].concat(this.currentStart)},s.startX=function(t){null!=t&&(this.start[0]=t,this.dirtyStart=!0)},s.startY=function(t){null!=t&&(this.start[1]=t,this.dirtyStart=!0)},s.start=function(t,e){this.setCoordinateHelper("start",t,e),this.dirtyStart=!0},n.startX=function(t){let e=this.start;e[0]=T(e[0],t),this.dirtyStart=!0},n.startY=function(t){let e=this.start;e[1]=T(e[1],t),this.dirtyStart=!0},n.start=function(t,e){this.setDeltaCoordinateHelper("start",t,e),this.dirtyStart=!0},e.handleX=function(){return this.currentHandle[0]},e.handleY=function(){return this.currentHandle[1]},e.handle=function(){return[].concat(this.currentHandle)},s.handleX=function(t){null!=t&&(this.handle[0]=t,this.dirtyHandle=!0)},s.handleY=function(t){null!=t&&(this.handle[1]=t,this.dirtyHandle=!0)},s.handle=function(t,e){this.setCoordinateHelper("handle",t,e),this.dirtyHandle=!0},n.handleX=function(t){let e=this.handle;e[0]=T(e[0],t),this.dirtyHandle=!0},n.handleY=function(t){let e=this.handle;e[1]=T(e[1],t),this.dirtyHandle=!0},n.handle=function(t,e){this.setDeltaCoordinateHelper("handle",t,e),this.dirtyHandle=!0},e.offsetX=function(){return this.currentOffset[0]},e.offsetY=function(){return this.currentOffset[1]},e.offset=function(){return[].concat(this.currentOffset)},s.offsetX=function(t){null!=t&&(this.offset[0]=t,this.dirtyOffset=!0)},s.offsetY=function(t){null!=t&&(this.offset[1]=t,this.dirtyOffset=!0)},s.offset=function(t,e){this.setCoordinateHelper("offset",t,e),this.dirtyOffset=!0},n.offsetX=function(t){let e=this.offset;e[0]=T(e[0],t),this.dirtyOffset=!0},n.offsetY=function(t){let e=this.offset;e[1]=T(e[1],t),this.dirtyOffset=!0},n.offset=function(t,e){this.setDeltaCoordinateHelper("offset",t,e),this.dirtyOffset=!0},e.width=function(){return this.currentDimensions[0]},e.height=function(){return this.currentDimensions[1]},e.dimensions=function(){return[].concat(this.currentDimensions)},s.width=function(t){null!=t&&(this.dimensions[0]=t,this.dirtyDimensions=!0)},s.height=function(t){null!=t&&(this.dimensions[1]=t,this.dirtyDimensions=!0)},s.dimensions=function(t,e){this.setCoordinateHelper("dimensions",t,e),this.dirtyDimensions=!0},n.width=function(t){let e=this.dimensions;e[0]=T(e[0],t),this.dirtyDimensions=!0},n.height=function(t){let e=this.dimensions;e[1]=T(e[1],t),this.dirtyDimensions=!0},n.dimensions=function(t,e){this.setDeltaCoordinateHelper("dimensions",t,e),this.dirtyDimensions=!0},e.order=function(){return this.stampOrder},s.order=function(t){thi