From f9af0fddb2077340ef277475bbdad1b0101b0333 Mon Sep 17 00:00:00 2001 From: Jamie Wong Date: Tue, 30 Jan 2018 10:34:47 -0800 Subject: [PATCH] release --- dist/speedscope.js | 142 ++++++++++++++++++++++----------------------- 1 file changed, 71 insertions(+), 71 deletions(-) diff --git a/dist/speedscope.js b/dist/speedscope.js index d630977..8ae5abe 100644 --- a/dist/speedscope.js +++ b/dist/speedscope.js @@ -69,114 +69,114 @@ require = (function (modules, cache, entry) { !function(){"use strict";function e(e,t){var n,o,r,i,l=N;for(i=arguments.length;i-- >2;)x.push(arguments[i]);for(t&&null!=t.children&&(x.length||x.push(t.children),delete t.children);x.length;)if((o=x.pop())&&void 0!==o.pop)for(i=o.length;i--;)x.push(o[i]);else"boolean"==typeof o&&(o=null),(r="function"!=typeof e)&&(null==o?o="":"number"==typeof o?o=String(o):"string"!=typeof o&&(r=!1)),r&&n?l[l.length-1]+=o:l===N?l=[o]:l.push(o),n=r;var a=new function(){};return a.nodeName=e,a.children=l,a.attributes=null==t?void 0:t,a.key=null==t?void 0:t.key,void 0!==C.vnode&&C.vnode(a),a}function t(e,t){for(var n in t)e[n]=t[n];return e}function n(e){!e.__d&&(e.__d=!0)&&1==U.push(e)&&(C.debounceRendering||w)(o)}function o(){var e,t=U;for(U=[];e=t.pop();)e.__d&&b(e)}function r(e,t,n){return"string"==typeof t||"number"==typeof t?void 0!==e.splitText:"string"==typeof t.nodeName?!e._componentConstructor&&i(e,t.nodeName):n||e._componentConstructor===t.nodeName}function i(e,t){return e.__n===t||e.nodeName.toLowerCase()===t.toLowerCase()}function l(e){var n=t({},e.attributes);n.children=e.children;var o=e.nodeName.defaultProps;if(void 0!==o)for(var r in o)void 0===n[r]&&(n[r]=o[r]);return n}function a(e){var t=e.parentNode;t&&t.removeChild(e)}function u(e,t,n,o,r){if("className"===t&&(t="class"),"key"===t);else if("ref"===t)n&&n(null),o&&o(e);else if("class"!==t||r)if("style"===t){if(o&&"string"!=typeof o&&"string"!=typeof n||(e.style.cssText=o||""),o&&"object"==typeof o){if("string"!=typeof n)for(var i in n)i in o||(e.style[i]="");for(var i in o)e.style[i]="number"==typeof o[i]&&!1===k.test(i)?o[i]+"px":o[i]}}else if("dangerouslySetInnerHTML"===t)o&&(e.innerHTML=o.__html||"");else if("o"==t[0]&&"n"==t[1]){var l=t!==(t=t.replace(/Capture$/,""));t=t.toLowerCase().substring(2),o?n||e.addEventListener(t,_,l):e.removeEventListener(t,_,l),(e.__l||(e.__l={}))[t]=o}else if("list"!==t&&"type"!==t&&!r&&t in e)!function(e,t,n){try{e[t]=n}catch(e){}}(e,t,null==o?"":o),null!=o&&!1!==o||e.removeAttribute(t);else{var a=r&&t!==(t=t.replace(/^xlink\:?/,""));null==o||!1===o?a?e.removeAttributeNS("http://www.w3.org/1999/xlink",t.toLowerCase()):e.removeAttribute(t):"function"!=typeof o&&(a?e.setAttributeNS("http://www.w3.org/1999/xlink",t.toLowerCase(),o):e.setAttribute(t,o))}else e.className=o||""}function _(e){return this.__l[e.type](C.event&&C.event(e)||e)}function p(){for(var e;e=S.pop();)C.afterMount&&C.afterMount(e),e.componentDidMount&&e.componentDidMount()}function c(e,t,n,o,r,i){L++||(T=null!=r&&void 0!==r.ownerSVGElement,M=null!=e&&!("__preactattr_"in e));var l=s(e,t,n,o,i);return r&&l.parentNode!==r&&r.appendChild(l),--L||(M=!1,i||p()),l}function s(e,t,n,o,_){var p=e,c=T;if(null!=t&&"boolean"!=typeof t||(t=""),"string"==typeof t||"number"==typeof t)return e&&void 0!==e.splitText&&e.parentNode&&(!e._component||_)?e.nodeValue!=t&&(e.nodeValue=t):(p=document.createTextNode(t),e&&(e.parentNode&&e.parentNode.replaceChild(p,e),f(e,!0))),p.__preactattr_=!0,p;var d=t.nodeName;if("function"==typeof d)return function(e,t,n,o){var r=e&&e._component,i=r,a=e,u=r&&e._componentConstructor===t.nodeName,_=u,p=l(t);for(;r&&!_&&(r=r.__u);)_=r.constructor===t.nodeName;r&&_&&(!o||r._component)?(v(r,p,3,n,o),e=r.base):(i&&!u&&(y(i),e=a=null),r=h(t.nodeName,p,n),e&&!r.__b&&(r.__b=e,a=null),v(r,p,1,n,o),e=r.base,a&&e!==a&&(a._component=null,f(a,!1)));return e}(e,t,n,o);if(T="svg"===d||"foreignObject"!==d&&T,d=String(d),(!e||!i(e,d))&&(p=function(e,t){var n=t?document.createElementNS("http://www.w3.org/2000/svg",e):document.createElement(e);return n.__n=e,n}(d,T),e)){for(;e.firstChild;)p.appendChild(e.firstChild);e.parentNode&&e.parentNode.replaceChild(p,e),f(e,!0)}var m=p.firstChild,b=p.__preactattr_,g=t.children;if(null==b){b=p.__preactattr_={};for(var C=p.attributes,x=C.length;x--;)b[C[x].name]=C[x].value}return!M&&g&&1===g.length&&"string"==typeof g[0]&&null!=m&&void 0!==m.splitText&&null==m.nextSibling?m.nodeValue!=g[0]&&(m.nodeValue=g[0]):(g&&g.length||null!=m)&&function(e,t,n,o,i){var l,u,_,p,c,d=e.childNodes,h=[],m={},v=0,b=0,y=d.length,g=0,C=t?t.length:0;if(0!==y)for(var x=0;x2?[].slice.call(arguments,2):n.children)},Component:g,render:function(e,t,n){return c(n,e,{},!1,t,!1)},rerender:o,options:C};"undefined"!=typeof module?module.exports=E:self.preact=E}(); },{}],5:[function(require,module,exports) { "use strict";Object.defineProperty(exports,"__esModule",{value:!0});const e=require("preact");class t extends e.Component{serialize(){const e=Object.create(null),s=this.subcomponents();for(const n in s){const o=s[n];o&&o instanceof t&&(e[n]=o.serialize())}return{state:this.state,serializedSubcomponents:e}}rehydrate(e){this.setState(e.state,()=>{const s=this.subcomponents();for(const n in s){const o=s[n],r=e.serializedSubcomponents[n];r&&o&&o instanceof t&&o.rehydrate(r)}})}subcomponents(){return Object.create(null)}}exports.ReloadableComponent=t; -},{"preact":4}],24:[function(require,module,exports) { -"use strict";function r(r){for(var t=5381,e=r.length;e;)t=33*t^r.charCodeAt(--e);return t>>>0}module.exports=r; -},{}],19:[function(require,module,exports) { -"use strict";function r(r){return r&&r.__esModule?r:{default:r}}function t(r,t){return r+t.charAt(0).toUpperCase()+t.substring(1)}Object.defineProperty(exports,"__esModule",{value:!0});var e=function(){return function(r,t){if(Array.isArray(r))return r;if(Symbol.iterator in Object(r))return function(r,t){var e=[],n=!0,o=!1,i=void 0;try{for(var a,u=r[Symbol.iterator]();!(n=(a=u.next()).done)&&(e.push(a.value),!t||e.length!==t);n=!0);}catch(r){o=!0,i=r}finally{try{!n&&u.return&&u.return()}finally{if(o)throw i}}return e}(r,t);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),n=require("string-hash"),o=r(n),i=function(r,t){for(var n=Object.keys(r),o={},i=0;i-1)return u.map(function(e){return t.replace(/image-set\(/g,e+"image-set(")})}Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=t;var r=require("css-in-js-utils/lib/isPrefixedValue"),i=e(r),u=["-webkit-",""];module.exports=exports.default; -},{"css-in-js-utils/lib/isPrefixedValue":44}],34:[function(require,module,exports) { -"use strict";function e(e){return e&&e.__esModule?e:{default:e}}function t(e,t){if("string"==typeof t&&!(0,i.default)(t)&&n.test(t))return a.map(function(e){return e+t})}Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=t;var r=require("css-in-js-utils/lib/isPrefixedValue"),i=e(r),a=["-webkit-","-moz-",""],n=/linear-gradient|radial-gradient|repeating-linear-gradient|repeating-radial-gradient/;module.exports=exports.default; -},{"css-in-js-utils/lib/isPrefixedValue":44}],35:[function(require,module,exports) { -"use strict";function e(e){return e&&e.__esModule?e:{default:e}}function t(e,t){if("string"==typeof t&&!(0,i.default)(t)&&t.indexOf("filter(")>-1)return u.map(function(e){return t.replace(/filter\(/g,e+"filter(")})}Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=t;var r=require("css-in-js-utils/lib/isPrefixedValue"),i=e(r),u=["-webkit-",""];module.exports=exports.default; -},{"css-in-js-utils/lib/isPrefixedValue":44}],31:[function(require,module,exports) { -"use strict";function e(e){return e.charAt(0).toUpperCase()+e.slice(1)}Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=e,module.exports=exports.default; -},{}],46:[function(require,module,exports) { -"use strict";function e(e){return e in t?t[e]:t[e]=e.replace(r,"-$&").toLowerCase().replace(s,"-ms-")}var r=/[A-Z]/g,s=/^ms-/,t={};module.exports=e; -},{}],45:[function(require,module,exports) { -"use strict";function e(e){return e&&e.__esModule?e:{default:e}}function t(e){return(0,u.default)(e)}Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=t;var r=require("hyphenate-style-name"),u=e(r);module.exports=exports.default; -},{"hyphenate-style-name":46}],36:[function(require,module,exports) { -"use strict";function t(t){return t&&t.__esModule?t:{default:t}}function e(t,e){if((0,s.default)(t))return t;for(var r=t.split(/,(?![^()]*(?:\([^()]*\))?\))/g),i=0,o=r.length;i-1&&"order"!==p)for(var d=e[f],c=0,b=d.length;c-1)return s;var u=o.split(/,(?![^()]*(?:\([^()]*\))?\))/g).filter(function(t){return!/-webkit-|-ms-/.test(t)}).join(",");return t.indexOf("Moz")>-1?u:(i["Webkit"+(0,a.default)(t)]=s,i["Moz"+(0,a.default)(t)]=u,o)}}Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=r;var i=require("css-in-js-utils/lib/hyphenateProperty"),n=t(i),o=require("css-in-js-utils/lib/isPrefixedValue"),s=t(o),u=require("../../utils/capitalizeString"),a=t(u),f={transition:!0,transitionProperty:!0,WebkitTransition:!0,WebkitTransitionProperty:!0,MozTransition:!0,MozTransitionProperty:!0},l={Webkit:"-webkit-",Moz:"-moz-",ms:"-ms-"};module.exports=exports.default; -},{"../../utils/capitalizeString":31,"css-in-js-utils/lib/isPrefixedValue":44,"css-in-js-utils/lib/hyphenateProperty":45}],37:[function(require,module,exports) { -"use strict";function e(e,t){if("position"===e&&"sticky"===t)return["-webkit-sticky","sticky"]}Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=e,module.exports=exports.default; -},{}],38:[function(require,module,exports) { -"use strict";function e(e){return e&&e.__esModule?e:{default:e}}function t(e,t){if("string"==typeof t&&!(0,u.default)(t)&&t.indexOf("calc(")>-1)return i.map(function(e){return t.replace(/calc\(/g,e+"calc(")})}Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=t;var r=require("css-in-js-utils/lib/isPrefixedValue"),u=e(r),i=["-webkit-","-moz-",""];module.exports=exports.default; -},{"css-in-js-utils/lib/isPrefixedValue":44}],39:[function(require,module,exports) { -"use strict";function t(t,o){if(n.hasOwnProperty(t)&&i.hasOwnProperty(o))return e.map(function(t){return t+o})}Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=t;var e=["-webkit-","-moz-",""],n={maxHeight:!0,maxWidth:!0,width:!0,height:!0,columnWidth:!0,minWidth:!0,minHeight:!0},i={"min-content":!0,"max-content":!0,"fill-available":!0,"fit-content":!0,"contain-floats":!0};module.exports=exports.default; -},{}],40:[function(require,module,exports) { -"use strict";function e(e,r,o){"flexDirection"===e&&"string"==typeof r&&(r.indexOf("column")>-1?o.WebkitBoxOrient="vertical":o.WebkitBoxOrient="horizontal",r.indexOf("reverse")>-1?o.WebkitBoxDirection="reverse":o.WebkitBoxDirection="normal"),i.hasOwnProperty(e)&&(o[i[e]]=t[r]||r)}Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=e;var t={"space-around":"justify","space-between":"justify","flex-start":"start","flex-end":"end","wrap-reverse":"multiple",wrap:"multiple"},i={alignItems:"WebkitBoxAlign",justifyContent:"WebkitBoxPack",flexWrap:"WebkitBoxLines"};module.exports=exports.default; },{}],41:[function(require,module,exports) { -"use strict";function e(e,l,r){s.hasOwnProperty(e)&&(r[s[e]]=t[l]||l)}Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=e;var t={"space-around":"distribute","space-between":"justify","flex-start":"start","flex-end":"end"},s={alignContent:"msFlexLinePack",alignSelf:"msFlexItemAlign",alignItems:"msFlexAlign",justifyContent:"msFlexPack",order:"msFlexOrder",flexGrow:"msFlexPositive",flexShrink:"msFlexNegative",flexBasis:"msFlexPreferredSize"};module.exports=exports.default; -},{}],42:[function(require,module,exports) { "use strict";function e(e){return e&&e.__esModule?e:{default:e}}function r(e,r){if("string"==typeof r&&!(0,s.default)(r)&&r.indexOf("cross-fade(")>-1)return u.map(function(e){return r.replace(/cross-fade\(/g,e+"cross-fade(")})}Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=r;var t=require("css-in-js-utils/lib/isPrefixedValue"),s=e(t),u=["-webkit-",""];module.exports=exports.default; -},{"css-in-js-utils/lib/isPrefixedValue":44}],43:[function(require,module,exports) { +},{"css-in-js-utils/lib/isPrefixedValue":53}],42:[function(require,module,exports) { +"use strict";function e(e){return e&&e.__esModule?e:{default:e}}function t(e,t){if("string"==typeof t&&!(0,u.default)(t)&&t.indexOf("calc(")>-1)return i.map(function(e){return t.replace(/calc\(/g,e+"calc(")})}Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=t;var r=require("css-in-js-utils/lib/isPrefixedValue"),u=e(r),i=["-webkit-","-moz-",""];module.exports=exports.default; +},{"css-in-js-utils/lib/isPrefixedValue":53}],43:[function(require,module,exports) { "use strict";function e(e,l){if("display"===e&&i.hasOwnProperty(l))return i[l]}Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=e;var i={flex:["-webkit-box","-moz-box","-ms-flexbox","-webkit-flex","flex"],"inline-flex":["-webkit-inline-box","-moz-inline-box","-ms-inline-flexbox","-webkit-inline-flex","inline-flex"]};module.exports=exports.default; -},{}],20:[function(require,module,exports) { +},{}],44:[function(require,module,exports) { +"use strict";function e(e,t){if("cursor"===e&&o.hasOwnProperty(t))return r.map(function(e){return e+t})}Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=e;var r=["-webkit-","-moz-",""],o={"zoom-in":!0,"zoom-out":!0,grab:!0,grabbing:!0};module.exports=exports.default; +},{}],45:[function(require,module,exports) { +"use strict";function e(e){return e&&e.__esModule?e:{default:e}}function t(e,t){if("string"==typeof t&&!(0,i.default)(t)&&t.indexOf("filter(")>-1)return u.map(function(e){return t.replace(/filter\(/g,e+"filter(")})}Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=t;var r=require("css-in-js-utils/lib/isPrefixedValue"),i=e(r),u=["-webkit-",""];module.exports=exports.default; +},{"css-in-js-utils/lib/isPrefixedValue":53}],46:[function(require,module,exports) { +"use strict";function e(e,l,r){s.hasOwnProperty(e)&&(r[s[e]]=t[l]||l)}Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=e;var t={"space-around":"distribute","space-between":"justify","flex-start":"start","flex-end":"end"},s={alignContent:"msFlexLinePack",alignSelf:"msFlexItemAlign",alignItems:"msFlexAlign",justifyContent:"msFlexPack",order:"msFlexOrder",flexGrow:"msFlexPositive",flexShrink:"msFlexNegative",flexBasis:"msFlexPreferredSize"};module.exports=exports.default; +},{}],47:[function(require,module,exports) { +"use strict";function e(e){return e&&e.__esModule?e:{default:e}}function t(e,t){if("string"==typeof t&&!(0,i.default)(t)&&n.test(t))return a.map(function(e){return e+t})}Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=t;var r=require("css-in-js-utils/lib/isPrefixedValue"),i=e(r),a=["-webkit-","-moz-",""],n=/linear-gradient|radial-gradient|repeating-linear-gradient|repeating-radial-gradient/;module.exports=exports.default; +},{"css-in-js-utils/lib/isPrefixedValue":53}],48:[function(require,module,exports) { +"use strict";function e(e,t){if("position"===e&&"sticky"===t)return["-webkit-sticky","sticky"]}Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=e,module.exports=exports.default; +},{}],49:[function(require,module,exports) { +"use strict";function t(t,o){if(n.hasOwnProperty(t)&&i.hasOwnProperty(o))return e.map(function(t){return t+o})}Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=t;var e=["-webkit-","-moz-",""],n={maxHeight:!0,maxWidth:!0,width:!0,height:!0,columnWidth:!0,minWidth:!0,minHeight:!0},i={"min-content":!0,"max-content":!0,"fill-available":!0,"fit-content":!0,"contain-floats":!0};module.exports=exports.default; +},{}],50:[function(require,module,exports) { +"use strict";function e(e,r,o){"flexDirection"===e&&"string"==typeof r&&(r.indexOf("column")>-1?o.WebkitBoxOrient="vertical":o.WebkitBoxOrient="horizontal",r.indexOf("reverse")>-1?o.WebkitBoxDirection="reverse":o.WebkitBoxDirection="normal"),i.hasOwnProperty(e)&&(o[i[e]]=t[r]||r)}Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=e;var t={"space-around":"justify","space-between":"justify","flex-start":"start","flex-end":"end","wrap-reverse":"multiple",wrap:"multiple"},i={alignItems:"WebkitBoxAlign",justifyContent:"WebkitBoxPack",flexWrap:"WebkitBoxLines"};module.exports=exports.default; +},{}],40:[function(require,module,exports) { +"use strict";function e(e){return e.charAt(0).toUpperCase()+e.slice(1)}Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=e,module.exports=exports.default; +},{}],55:[function(require,module,exports) { +"use strict";function e(e){return e in t?t[e]:t[e]=e.replace(r,"-$&").toLowerCase().replace(s,"-ms-")}var r=/[A-Z]/g,s=/^ms-/,t={};module.exports=e; +},{}],54:[function(require,module,exports) { +"use strict";function e(e){return e&&e.__esModule?e:{default:e}}function t(e){return(0,u.default)(e)}Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=t;var r=require("hyphenate-style-name"),u=e(r);module.exports=exports.default; +},{"hyphenate-style-name":55}],51:[function(require,module,exports) { +"use strict";function t(t){return t&&t.__esModule?t:{default:t}}function e(t,e){if((0,s.default)(t))return t;for(var r=t.split(/,(?![^()]*(?:\([^()]*\))?\))/g),i=0,o=r.length;i-1&&"order"!==p)for(var d=e[f],c=0,b=d.length;c-1)return s;var u=o.split(/,(?![^()]*(?:\([^()]*\))?\))/g).filter(function(t){return!/-webkit-|-ms-/.test(t)}).join(",");return t.indexOf("Moz")>-1?u:(i["Webkit"+(0,a.default)(t)]=s,i["Moz"+(0,a.default)(t)]=u,o)}}Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=r;var i=require("css-in-js-utils/lib/hyphenateProperty"),n=t(i),o=require("css-in-js-utils/lib/isPrefixedValue"),s=t(o),u=require("../../utils/capitalizeString"),a=t(u),f={transition:!0,transitionProperty:!0,WebkitTransition:!0,WebkitTransitionProperty:!0,MozTransition:!0,MozTransitionProperty:!0},l={Webkit:"-webkit-",Moz:"-moz-",ms:"-ms-"};module.exports=exports.default; +},{"../../utils/capitalizeString":40,"css-in-js-utils/lib/hyphenateProperty":54,"css-in-js-utils/lib/isPrefixedValue":53}],52:[function(require,module,exports) { +"use strict";function e(e){return e&&e.__esModule?e:{default:e}}function t(e,t){if("string"==typeof t&&!(0,i.default)(t)&&t.indexOf("image-set(")>-1)return u.map(function(e){return t.replace(/image-set\(/g,e+"image-set(")})}Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=t;var r=require("css-in-js-utils/lib/isPrefixedValue"),i=e(r),u=["-webkit-",""];module.exports=exports.default; +},{"css-in-js-utils/lib/isPrefixedValue":53}],28:[function(require,module,exports) { var e=require("inline-style-prefixer/static/plugins/calc"),i=require("inline-style-prefixer/static/plugins/crossFade"),t=require("inline-style-prefixer/static/plugins/cursor"),r=require("inline-style-prefixer/static/plugins/filter"),s=require("inline-style-prefixer/static/plugins/flex"),o=require("inline-style-prefixer/static/plugins/flexboxIE"),n=require("inline-style-prefixer/static/plugins/flexboxOld"),a=require("inline-style-prefixer/static/plugins/gradient"),k=require("inline-style-prefixer/static/plugins/imageSet"),m=require("inline-style-prefixer/static/plugins/position"),l=require("inline-style-prefixer/static/plugins/sizing"),b=require("inline-style-prefixer/static/plugins/transition");module.exports={plugins:[e,i,t,r,s,o,n,a,k,m,l,b],prefixMap:{transform:["Webkit","ms"],transformOrigin:["Webkit","ms"],transformOriginX:["Webkit","ms"],transformOriginY:["Webkit","ms"],backfaceVisibility:["Webkit"],perspective:["Webkit"],perspectiveOrigin:["Webkit"],transformStyle:["Webkit"],transformOriginZ:["Webkit"],animation:["Webkit"],animationDelay:["Webkit"],animationDirection:["Webkit"],animationFillMode:["Webkit"],animationDuration:["Webkit"],animationIterationCount:["Webkit"],animationName:["Webkit"],animationPlayState:["Webkit"],animationTimingFunction:["Webkit"],appearance:["Webkit","Moz"],userSelect:["Webkit","Moz","ms"],fontKerning:["Webkit"],textEmphasisPosition:["Webkit"],textEmphasis:["Webkit"],textEmphasisStyle:["Webkit"],textEmphasisColor:["Webkit"],boxDecorationBreak:["Webkit"],clipPath:["Webkit"],maskImage:["Webkit"],maskMode:["Webkit"],maskRepeat:["Webkit"],maskPosition:["Webkit"],maskClip:["Webkit"],maskOrigin:["Webkit"],maskSize:["Webkit"],maskComposite:["Webkit"],mask:["Webkit"],maskBorderSource:["Webkit"],maskBorderMode:["Webkit"],maskBorderSlice:["Webkit"],maskBorderWidth:["Webkit"],maskBorderOutset:["Webkit"],maskBorderRepeat:["Webkit"],maskBorder:["Webkit"],maskType:["Webkit"],textDecorationStyle:["Webkit","Moz"],textDecorationSkip:["Webkit","Moz"],textDecorationLine:["Webkit","Moz"],textDecorationColor:["Webkit","Moz"],filter:["Webkit"],fontFeatureSettings:["Webkit","Moz"],breakAfter:["Webkit","Moz","ms"],breakBefore:["Webkit","Moz","ms"],breakInside:["Webkit","Moz","ms"],columnCount:["Webkit","Moz"],columnFill:["Webkit","Moz"],columnGap:["Webkit","Moz"],columnRule:["Webkit","Moz"],columnRuleColor:["Webkit","Moz"],columnRuleStyle:["Webkit","Moz"],columnRuleWidth:["Webkit","Moz"],columns:["Webkit","Moz"],columnSpan:["Webkit","Moz"],columnWidth:["Webkit","Moz"],flex:["Webkit","ms"],flexBasis:["Webkit"],flexDirection:["Webkit","ms"],flexGrow:["Webkit"],flexFlow:["Webkit","ms"],flexShrink:["Webkit"],flexWrap:["Webkit","ms"],alignContent:["Webkit"],alignItems:["Webkit"],alignSelf:["Webkit"],justifyContent:["Webkit"],order:["Webkit"],transitionDelay:["Webkit"],transitionDuration:["Webkit"],transitionProperty:["Webkit"],transitionTimingFunction:["Webkit"],backdropFilter:["Webkit"],scrollSnapType:["Webkit","ms"],scrollSnapPointsX:["Webkit","ms"],scrollSnapPointsY:["Webkit","ms"],scrollSnapDestination:["Webkit","ms"],scrollSnapCoordinate:["Webkit","ms"],shapeImageThreshold:["Webkit"],shapeImageMargin:["Webkit"],shapeImageOutside:["Webkit"],hyphens:["Webkit","Moz","ms"],flowInto:["Webkit","ms"],flowFrom:["Webkit","ms"],regionFragment:["Webkit","ms"],boxSizing:["Moz"],textAlignLast:["Moz"],tabSize:["Moz"],wrapFlow:["ms"],wrapThrough:["ms"],wrapMargin:["ms"],touchAction:["ms"],gridTemplateColumns:["ms"],gridTemplateRows:["ms"],gridTemplateAreas:["ms"],gridTemplate:["ms"],gridAutoColumns:["ms"],gridAutoRows:["ms"],gridAutoFlow:["ms"],grid:["ms"],gridRowStart:["ms"],gridColumnStart:["ms"],gridRowEnd:["ms"],gridRow:["ms"],gridColumn:["ms"],gridColumnEnd:["ms"],gridColumnGap:["ms"],gridRowGap:["ms"],gridArea:["ms"],gridGap:["ms"],textSizeAdjust:["Webkit","ms"],borderImage:["Webkit"],borderImageOutset:["Webkit"],borderImageRepeat:["Webkit"],borderImageSlice:["Webkit"],borderImageSource:["Webkit"],borderImageWidth:["Webkit"]}}; -},{"inline-style-prefixer/static/plugins/cursor":32,"inline-style-prefixer/static/plugins/imageSet":33,"inline-style-prefixer/static/plugins/gradient":34,"inline-style-prefixer/static/plugins/filter":35,"inline-style-prefixer/static/plugins/transition":36,"inline-style-prefixer/static/plugins/position":37,"inline-style-prefixer/static/plugins/calc":38,"inline-style-prefixer/static/plugins/sizing":39,"inline-style-prefixer/static/plugins/flexboxOld":40,"inline-style-prefixer/static/plugins/flexboxIE":41,"inline-style-prefixer/static/plugins/crossFade":42,"inline-style-prefixer/static/plugins/flex":43}],21:[function(require,module,exports) { -"use strict";function e(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(exports,"__esModule",{value:!0});var t=function(){function e(e,t){for(var n=0;n>>0}module.exports=r; },{}],29:[function(require,module,exports) { -"use strict";function e(e){return e instanceof Object&&!Array.isArray(e)}Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=e,module.exports=exports.default; -},{}],30:[function(require,module,exports) { +"use strict";function r(r){return r&&r.__esModule?r:{default:r}}function t(r,t){return r+t.charAt(0).toUpperCase()+t.substring(1)}Object.defineProperty(exports,"__esModule",{value:!0});var e=function(){return function(r,t){if(Array.isArray(r))return r;if(Symbol.iterator in Object(r))return function(r,t){var e=[],n=!0,o=!1,i=void 0;try{for(var a,u=r[Symbol.iterator]();!(n=(a=u.next()).done)&&(e.push(a.value),!t||e.length!==t);n=!0);}catch(r){o=!0,i=r}finally{try{!n&&u.return&&u.return()}finally{if(o)throw i}}return e}(r,t);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),n=require("string-hash"),o=r(n),i=function(r,t){for(var n=Object.keys(r),o={},i=0;i0&&(e[i]=d)}else{var x=(0,a.default)(l,i,s,e,t);x&&(e[i]=x),(0,u.default)(t,i,e)}}return e}var t=e.prefixMap,l=e.plugins;return r}Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=r;var t=require("../utils/prefixProperty"),u=e(t),l=require("../utils/prefixValue"),a=e(l),i=require("../utils/addNewValuesOnly"),f=e(i),s=require("../utils/isObject"),n=e(s);module.exports=exports.default; -},{"../utils/addNewValuesOnly":27,"../utils/prefixValue":28,"../utils/isObject":29,"../utils/prefixProperty":30}],17:[function(require,module,exports) { +},{"../utils/prefixProperty":36,"../utils/prefixValue":37,"../utils/isObject":38,"../utils/addNewValuesOnly":39}],25:[function(require,module,exports) { "use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(exports,"__esModule",{value:!0});var r=Object.assign||function(e){for(var r=1;rc){for(var t=0,n=u.length-i;t0&&u(e)};exports.flushToStyleTag=g;var S=function(){return Object.keys(c)};exports.getRenderedClassNames=S;var x=function(e){e.forEach(function(e){c[e]=!0})};exports.addRenderedClassNames=x;var N=function e(t,n){for(var r=0;rs?s:t}Object.defineProperty(exports,"__esModule",{value:!0}),exports.clamp=t;class i{constructor(t,i){this.x=t,this.y=i}withX(t){return new i(t,this.y)}withY(t){return new i(this.x,t)}plus(t){return new i(this.x+t.x,this.y+t.y)}minus(t){return new i(this.x-t.x,this.y-t.y)}times(t){return new i(this.x*t,this.y*t)}timesPointwise(t){return new i(this.x*t.x,this.y*t.y)}dividedByPointwise(t){return new i(this.x/t.x,this.y/t.y)}dot(t){return this.x*t.x+this.y*t.y}equals(t){return this.x===t.x&&this.y===t.y}length2(){return this.dot(this)}length(){return Math.sqrt(this.length2())}abs(){return new i(Math.abs(this.x),Math.abs(this.y))}static min(t,s){return new i(Math.min(t.x,s.x),Math.min(t.y,s.y))}static max(t,s){return new i(Math.max(t.x,s.x),Math.max(t.y,s.y))}flatten(){return[this.x,this.y]}}i.zero=new i(0,0),i.unit=new i(1,1),exports.Vec2=i;class s{constructor(t=1,i=0,s=0,e=0,r=1,n=0){this.m00=t,this.m01=i,this.m02=s,this.m10=e,this.m11=r,this.m12=n}withScale(t){let{m00:i,m01:e,m02:r,m10:n,m11:h,m12:m}=this;return i=t.x,h=t.y,new s(i,e,r,n,h,m)}static withScale(t){return(new s).withScale(t)}scaledBy(t){return s.withScale(t).times(this)}getScale(){return new i(this.m00,this.m11)}withTranslation(t){let{m00:i,m01:e,m02:r,m10:n,m11:h,m12:m}=this;return r=t.x,m=t.y,new s(i,e,r,n,h,m)}static withTranslation(t){return(new s).withTranslation(t)}getTranslation(){return new i(this.m02,this.m12)}translatedBy(t){return s.withTranslation(t).times(this)}static betweenRects(t,e){return s.withTranslation(t.origin.times(-1)).scaledBy(new i(e.size.x/t.size.x,e.size.y/t.size.y)).translatedBy(e.origin)}times(t){const i=this.m00*t.m00+this.m01*t.m10,e=this.m00*t.m01+this.m01*t.m11,r=this.m00*t.m02+this.m01*t.m12+this.m02,n=this.m10*t.m00+this.m11*t.m10,h=this.m10*t.m01+this.m11*t.m11,m=this.m10*t.m02+this.m11*t.m12+this.m12;return new s(i,e,r,n,h,m)}equals(t){return this.m00==t.m00&&this.m01==t.m01&&this.m02==t.m02&&this.m10==t.m10&&this.m11==t.m11&&this.m12==t.m12}timesScalar(t){const{m00:i,m01:e,m02:r,m10:n,m11:h,m12:m}=this;return new s(t*i,t*e,t*r,t*n,t*h,t*m)}det(){const{m00:t,m01:i,m02:s,m10:e,m11:r,m12:n}=this;return t*(1*r-0*n)-i*(1*e-0*n)+s*(0*e-0*r)}adj(){const{m00:t,m01:i,m02:e,m10:r,m11:n,m12:h}=this;return new s(+(1*n-0*h),-(1*i-0*e),+(i*h-e*n),-(1*r-0*h),+(1*t-0*e),-(t*h-e*r))}inverted(){const t=this.det();if(0===t)return null;return this.adj().timesScalar(1/t)}transformVector(t){return new i(t.x*this.m00+t.y*this.m01,t.x*this.m10+t.y*this.m11)}inverseTransformVector(t){const i=this.inverted();return i?i.transformVector(t):null}transformPosition(t){return new i(t.x*this.m00+t.y*this.m01+this.m02,t.x*this.m10+t.y*this.m11+this.m12)}inverseTransformPosition(t){const i=this.inverted();return i?i.transformPosition(t):null}transformRect(t){const i=this.transformVector(t.size),s=this.transformPosition(t.origin);return i.x<0&&i.y<0?new e(s.plus(i),i.abs()):i.x<0?new e(s.withX(s.x+i.x),i.abs()):i.y<0?new e(s.withY(s.y+i.y),i.abs()):new e(s,i)}inverseTransformRect(t){const i=this.inverted();return i?i.transformRect(t):null}flatten(){return[this.m00,this.m10,0,this.m01,this.m11,0,this.m02,this.m12,1]}}exports.AffineTransform=s;class e{constructor(t,i){this.origin=t,this.size=i}isEmpty(){return 0==this.width()||0==this.height()}width(){return this.size.x}height(){return this.size.y}left(){return this.origin.x}right(){return this.left()+this.width()}top(){return this.origin.y}bottom(){return this.top()+this.height()}topLeft(){return this.origin}topRight(){return this.origin.plus(new i(this.width(),0))}bottomRight(){return this.origin.plus(this.size)}bottomLeft(){return this.origin.plus(new i(0,this.height()))}withOrigin(t){return new e(t,this.size)}withSize(t){return new e(this.origin,t)}closestPointTo(s){return new i(t(s.x,this.left(),this.right()),t(s.y,this.top(),this.bottom()))}distanceFrom(t){return t.minus(this.closestPointTo(t)).length()}contains(t){return 0===this.distanceFrom(t)}hasIntersectionWith(t){const i=Math.max(this.top(),t.top());if(Math.max(i,Math.min(this.bottom(),t.bottom()))-i==0)return!1;const s=Math.max(this.left(),t.left());return Math.max(s,Math.min(this.right(),t.right()))-s!=0}intersectWith(t){const s=i.max(this.topLeft(),t.topLeft()),r=i.max(s,i.min(this.bottomRight(),t.bottomRight()));return new e(s,r.minus(s))}equals(t){return this.origin.equals(t.origin)&&this.size.equals(t.size)}}e.empty=new e(i.zero,i.zero),e.unit=new e(i.zero,i.unit),e.NDC=new e(new i(-1,-1),new i(2,2)),exports.Rect=e; -},{}],16:[function(require,module,exports) { +},{}],23:[function(require,module,exports) { "use strict";function t(t){return t[t.length-1]||null}function e(t,e){t.sort(function(t,r){return e(t){this.container=e||null}),this.overlayCanvas=null,this.overlayCtx=null,this.cachedRenderer=null,this.onBeforeFrame=(()=>{this.maybeClearInteractionLock(),this.renderRects(),this.renderOverlays()}),this.renderCanvas=(()=>{this.props.canvasContext.requestFrame()}),this.frameHadWheelEvent=!1,this.framesWithoutWheelEvents=0,this.interactionLock=null,this.maybeClearInteractionLock=(()=>{this.interactionLock&&(this.frameHadWheelEvent||(this.framesWithoutWheelEvents++,this.framesWithoutWheelEvents>=2&&(this.interactionLock=null,this.framesWithoutWheelEvents=0)),this.props.canvasContext.requestFrame()),this.frameHadWheelEvent=!1}),this.onWheel=(e=>{e.preventDefault(),this.frameHadWheelEvent=!0;if((e.metaKey||e.ctrlKey)&&"pan"!==this.interactionLock){let t=1+e.deltaY/100;e.ctrlKey&&(t=1+e.deltaY/40),t=i.clamp(t,.1,10),this.zoom(t)}else"zoom"!==this.interactionLock&&this.pan(new i.Vec2(e.deltaX,e.deltaY));this.renderCanvas()}),this.dragStartConfigSpaceMouse=null,this.dragConfigSpaceViewportOffset=null,this.draggingMode=null,this.onMouseDown=(e=>{const t=this.configSpaceMouse(e);t&&(this.props.configSpaceViewportRect.contains(t)?(this.draggingMode=a.TRANSLATE_VIEWPORT,this.dragConfigSpaceViewportOffset=t.minus(this.props.configSpaceViewportRect.origin)):this.draggingMode=a.DRAW_NEW_VIEWPORT,this.dragStartConfigSpaceMouse=t,window.addEventListener("mousemove",this.onWindowMouseMove),window.addEventListener("mouseup",this.onWindowMouseUp),this.updateCursor(t))}),this.onWindowMouseMove=(e=>{if(!this.dragStartConfigSpaceMouse)return;let t=this.configSpaceMouse(e);if(t)if(this.updateCursor(t),t=new i.Rect(new i.Vec2(0,0),this.configSpaceSize()).closestPointTo(t),this.draggingMode===a.DRAW_NEW_VIEWPORT){const e=this.dragStartConfigSpaceMouse;let s=t;if(!e||!s)return;const n=Math.min(e.x,s.x),o=Math.max(e.x,s.x)-n,r=this.props.configSpaceViewportRect.height();this.props.setConfigSpaceViewportRect(new i.Rect(new i.Vec2(n,s.y-r/2),new i.Vec2(o,r)))}else if(this.draggingMode===a.TRANSLATE_VIEWPORT){if(!this.dragConfigSpaceViewportOffset)return;const e=t.minus(this.dragConfigSpaceViewportOffset);this.props.setConfigSpaceViewportRect(this.props.configSpaceViewportRect.withOrigin(e))}}),this.updateCursor=(e=>{this.draggingMode===a.TRANSLATE_VIEWPORT?(document.body.style.cursor="grabbing",document.body.style.cursor="-webkit-grabbing"):this.draggingMode===a.DRAW_NEW_VIEWPORT?document.body.style.cursor="col-resize":this.props.configSpaceViewportRect.contains(e)?(document.body.style.cursor="grab",document.body.style.cursor="-webkit-grab"):document.body.style.cursor="col-resize"}),this.onMouseMove=(e=>{const t=this.configSpaceMouse(e);t&&this.updateCursor(t)}),this.onWindowMouseUp=(e=>{this.draggingMode=null,window.removeEventListener("mousemove",this.onWindowMouseMove),window.removeEventListener("mouseup",this.onWindowMouseUp);const t=this.configSpaceMouse(e);t&&this.updateCursor(t)}),this.overlayCanvasRef=(e=>{e?(this.overlayCanvas=e,this.overlayCtx=this.overlayCanvas.getContext("2d"),this.renderCanvas()):(this.overlayCanvas=null,this.overlayCtx=null)})}physicalViewSize(){return new i.Vec2(this.overlayCanvas?this.overlayCanvas.width:0,this.overlayCanvas?this.overlayCanvas.height:0)}minimapOrigin(){return new i.Vec2(0,n.Sizes.FRAME_HEIGHT*r)}configSpaceSize(){return new i.Vec2(this.props.flamechart.getTotalWeight(),this.props.flamechart.getLayers().length)}configSpaceToPhysicalViewSpace(){const e=this.minimapOrigin();return i.AffineTransform.betweenRects(new i.Rect(new i.Vec2(0,0),this.configSpaceSize()),new i.Rect(e,this.physicalViewSize().minus(e)))}logicalToPhysicalViewSpace(){return i.AffineTransform.withScale(new i.Vec2(r,r))}windowToLogicalViewSpace(){if(!this.container)return new i.AffineTransform;const e=this.container.getBoundingClientRect();return i.AffineTransform.withTranslation(new i.Vec2(-e.left,-e.top))}renderRects(){this.container&&(this.physicalViewSize().x<2||(this.cachedRenderer||(this.cachedRenderer=this.props.canvasContext.createTextureCachedRenderer({shouldUpdate:(e,t)=>!e.physicalSize.equals(t.physicalSize),render:e=>{this.props.flamechartRenderer.render({physicalSpaceDstRect:new i.Rect(this.minimapOrigin(),this.physicalViewSize().minus(this.minimapOrigin())),configSpaceSrcRect:new i.Rect(new i.Vec2(0,0),this.configSpaceSize()),renderOutlines:!1})}})),this.props.canvasContext.renderInto(this.container,e=>{this.props.flamechartRenderer.render({configSpaceSrcRect:new i.Rect(new i.Vec2(0,0),this.configSpaceSize()),physicalSpaceDstRect:new i.Rect(this.minimapOrigin(),this.physicalViewSize().minus(this.minimapOrigin())),renderOutlines:!1}),this.props.canvasContext.drawViewportRectangle({configSpaceViewportRect:this.props.configSpaceViewportRect,configSpaceToPhysicalViewSpace:this.configSpaceToPhysicalViewSpace()})})))}renderOverlays(){const e=this.overlayCtx;if(!e)return;const t=this.physicalViewSize();e.clearRect(0,0,t.x,t.y),this.resizeOverlayCanvasIfNeeded();const a=this.configSpaceToPhysicalViewSpace(),c=this.configSpaceSize().x,h=(this.configSpaceToPhysicalViewSpace().inverted()||new i.AffineTransform).times(this.logicalToPhysicalViewSpace()).transformVector(new i.Vec2(200,1)).x,l=n.Sizes.FRAME_HEIGHT*r,p=o.FontSize.LABEL*r,f=(l-p)/2;e.font=`${p}px/${l}px ${o.FontFamily.MONOSPACE}`,e.textBaseline="top";let d=Math.pow(10,Math.floor(Math.log10(h)));h/d>5?d*=5:h/d>2&&(d*=2),e.fillStyle="rgba(255, 255, 255, 0.8)",e.fillRect(0,0,t.x,l),e.fillStyle=o.Colors.GRAY;for(let n=Math.ceil(0/d)*d;na.cachedMeasureTextWidth(i,t(s,e)),o);return t(s,r)}Object.defineProperty(exports,"__esModule",{value:!0});const s=require("preact"),o=require("aphrodite"),r=require("./reloadable"),n=require("./math"),a=require("./utils"),h=require("./flamechart-minimap-view"),c=require("./flamechart-style"),l=require("./style"),p="…",f=window.devicePixelRatio;class w extends r.ReloadableComponent{constructor(){super(...arguments),this.container=null,this.containerRef=(e=>{this.container=e||null}),this.overlayCanvas=null,this.overlayCtx=null,this.hoveredLabel=null,this.overlayCanvasRef=(e=>{e?(this.overlayCanvas=e,this.overlayCtx=this.overlayCanvas.getContext("2d"),this.renderCanvas()):(this.overlayCanvas=null,this.overlayCtx=null)}),this.LOGICAL_VIEW_SPACE_FRAME_HEIGHT=16,this.lastBounds=null,this.onWindowResize=(()=>{this.updateConfigSpaceViewport(!0),this.renderCanvas()}),this.frameHadWheelEvent=!1,this.framesWithoutWheelEvents=0,this.interactionLock=null,this.maybeClearInteractionLock=(()=>{this.interactionLock&&(this.frameHadWheelEvent||(this.framesWithoutWheelEvents++,this.framesWithoutWheelEvents>=2&&(this.interactionLock=null,this.framesWithoutWheelEvents=0)),this.props.canvasContext.requestFrame()),this.frameHadWheelEvent=!1}),this.onBeforeFrame=(()=>{this.renderRects(),this.renderOverlays(),this.maybeClearInteractionLock()}),this.renderCanvas=(()=>{this.props.canvasContext.requestFrame()}),this.lastDragPos=null,this.onMouseDown=(e=>{this.lastDragPos=new n.Vec2(e.offsetX,e.offsetY),this.updateCursor(),window.addEventListener("mouseup",this.onWindowMouseUp)}),this.onMouseDrag=(e=>{if(!this.lastDragPos)return;const t=new n.Vec2(e.offsetX,e.offsetY);this.pan(this.lastDragPos.minus(t)),this.lastDragPos=t,this.hoveredLabel&&this.props.setNodeHover(this.hoveredLabel.node,t)}),this.onWindowMouseUp=(e=>{this.lastDragPos=null,this.updateCursor(),window.removeEventListener("mouseup",this.onWindowMouseUp)}),this.onMouseMove=(e=>{if(this.updateCursor(),this.lastDragPos)return e.preventDefault(),void this.onMouseDrag(e);this.hoveredLabel=null;const t=new n.Vec2(e.offsetX,e.offsetY),i=this.logicalToPhysicalViewSpace().transformPosition(t),s=this.configSpaceToPhysicalViewSpace().inverseTransformPosition(i);if(!s)return;const o=(e,t=0)=>{const i=e.end-e.start,r=new n.Rect(new n.Vec2(e.start,t),new n.Vec2(i,1));if(s.xr.right())return null;r.contains(s)&&(this.hoveredLabel={configSpaceBounds:r,node:e.node});for(let i of e.children)o(i,t+1)};for(let e of this.props.flamechart.getLayers()[0]||[])o(e);this.hoveredLabel?this.props.setNodeHover(this.hoveredLabel.node,t):this.props.setNodeHover(null,t),this.renderCanvas()}),this.onMouseLeave=(e=>{this.hoveredLabel=null,this.props.setNodeHover(null,n.Vec2.zero),this.renderCanvas()}),this.onWheel=(e=>{e.preventDefault(),this.frameHadWheelEvent=!0;if((e.metaKey||e.ctrlKey)&&"pan"!==this.interactionLock){let t=1+e.deltaY/100;e.ctrlKey&&(t=1+e.deltaY/40),t=n.clamp(t,.1,10),this.zoom(new n.Vec2(e.offsetX,e.offsetY),t)}else"zoom"!==this.interactionLock&&this.pan(new n.Vec2(e.deltaX,e.deltaY));this.renderCanvas()}),this.onWindowKeyPress=(e=>{if(!this.container)return;const{width:t,height:i}=this.container.getBoundingClientRect();"="===e.key||"+"===e.key?(this.zoom(new n.Vec2(t/2,i/2),.5),e.preventDefault()):"-"===e.key||"_"===e.key?(this.zoom(new n.Vec2(t/2,i/2),2),e.preventDefault()):"0"===e.key?this.zoom(new n.Vec2(t/2,i/2),1e9):"ArrowRight"===e.key||"d"===e.key?this.pan(new n.Vec2(100,0)):"ArrowLeft"===e.key||"a"===e.key?this.pan(new n.Vec2(-100,0)):"ArrowUp"===e.key||"w"===e.key?this.pan(new n.Vec2(0,-100)):"ArrowDown"!==e.key&&"s"!==e.key||this.pan(new n.Vec2(0,100))})}setConfigSpaceViewportRect(e){this.props.setConfigSpaceViewportRect(e)}configSpaceSize(){return new n.Vec2(this.props.flamechart.getTotalWeight(),this.props.flamechart.getLayers().length)}physicalViewSize(){return new n.Vec2(this.overlayCanvas?this.overlayCanvas.width:0,this.overlayCanvas?this.overlayCanvas.height:0)}configSpaceToPhysicalViewSpace(){return n.AffineTransform.betweenRects(this.props.configSpaceViewportRect,new n.Rect(new n.Vec2(0,0),this.physicalViewSize()))}logicalToPhysicalViewSpace(){return n.AffineTransform.withScale(new n.Vec2(f,f))}resizeOverlayCanvasIfNeeded(){if(!this.overlayCanvas)return;let{width:e,height:t}=this.overlayCanvas.getBoundingClientRect();if(e=Math.floor(e),t=Math.floor(t),0===e||0===t)return;const i=e*f,s=t*f;i===this.overlayCanvas.width&&s===this.overlayCanvas.height||(this.overlayCanvas.width=i,this.overlayCanvas.height=s)}renderOverlays(){const e=this.overlayCtx;if(!e)return;if(this.resizeOverlayCanvasIfNeeded(),this.props.configSpaceViewportRect.isEmpty())return;const t=this.configSpaceToPhysicalViewSpace(),s=l.FontSize.LABEL*f,o=this.LOGICAL_VIEW_SPACE_FRAME_HEIGHT*f,r=this.physicalViewSize();if(e.clearRect(0,0,r.x,r.y),e.strokeStyle="rgba(15, 10, 5, 0.5)",e.lineWidth=2,this.hoveredLabel){const i=t.transformRect(this.hoveredLabel.configSpaceBounds);e.strokeRect(Math.floor(i.left()),Math.floor(i.top()),Math.floor(i.width()),Math.floor(i.height()))}e.font=`${s}px/${o}px ${l.FontFamily.MONOSPACE}`,e.fillStyle=l.Colors.GRAY,e.textBaseline="top";const h=a.cachedMeasureTextWidth(e,"M"+p+"M"),c=(t.inverseTransformVector(new n.Vec2(h,0))||new n.Vec2(0,0)).x,w=(o-s)/2,d=new n.Vec2(w,w),u=new n.Vec2(2*w,2*w),m=(s,o=0)=>{const a=s.end-s.start,h=new n.Rect(new n.Vec2(s.start,o),new n.Vec2(a,1));if(!(athis.props.configSpaceViewportRect.right()||h.right()this.props.configSpaceViewportRect.bottom())){if(h.hasIntersectionWith(this.props.configSpaceViewportRect)){let o=t.transformRect(h);o.left()<0&&(o=o.withOrigin(o.origin.withX(0)).withSize(o.size.withX(o.size.x+o.left()))),o.right()>r.x&&(o=o.withSize(o.size.withX(r.x-o.left()))),o=o.withOrigin(o.origin.plus(d)).withSize(o.size.minus(u));const n=i(e,s.node.frame.name,o.width());e.fillText(n,o.left(),o.top())}for(let e of s.children)m(e,o+1)}};for(let e of this.props.flamechart.getLayers()[0]||[])m(e);const g=this.props.configSpaceViewportRect.left(),v=this.props.configSpaceViewportRect.right(),V=(this.configSpaceToPhysicalViewSpace().inverted()||new n.AffineTransform).times(this.logicalToPhysicalViewSpace()).transformVector(new n.Vec2(200,1)).x;let y=Math.pow(10,Math.floor(Math.log10(V)));V/y>5?y*=5:V/y>2&&(y*=2),e.fillStyle="rgba(255, 255, 255, 0.8)",e.fillRect(0,0,r.x,o),e.fillStyle=l.Colors.GRAY;for(let i=Math.ceil(g/y)*y;i{this.props.flamechartRenderer.render({physicalSpaceDstRect:new n.Rect(n.Vec2.zero,this.physicalViewSize()),configSpaceSrcRect:this.props.configSpaceViewportRect,renderOutlines:!0})}))}pan(e){this.interactionLock="pan";const t=this.logicalToPhysicalViewSpace().transformVector(e),i=this.configSpaceToPhysicalViewSpace().inverseTransformVector(t);i&&this.props.transformViewport(n.AffineTransform.withTranslation(i))}zoom(e,t){this.interactionLock="zoom";const i=this.logicalToPhysicalViewSpace().transformPosition(e),s=this.configSpaceToPhysicalViewSpace().inverseTransformPosition(i);if(!s)return;const o=n.AffineTransform.withTranslation(s.times(-1)).scaledBy(new n.Vec2(t,1)).translatedBy(s);this.props.transformViewport(o)}updateCursor(){this.lastDragPos?(document.body.style.cursor="grabbing",document.body.style.cursor="-webkit-grabbing"):document.body.style.cursor="default"}shouldComponentUpdate(){return!1}componentWillReceiveProps(e){this.props.flamechart!==e.flamechart?this.renderCanvas():this.props.configSpaceViewportRect!==e.configSpaceViewportRect&&this.renderCanvas()}componentDidMount(){this.props.canvasContext.addBeforeFrameHandler(this.onBeforeFrame),window.addEventListener("resize",this.onWindowResize),window.addEventListener("keydown",this.onWindowKeyPress)}componentWillUnmount(){this.props.canvasContext.removeBeforeFrameHandler(this.onBeforeFrame),window.removeEventListener("resize",this.onWindowResize),window.removeEventListener("keydown",this.onWindowKeyPress)}render(){return s.h("div",{className:o.css(c.style.panZoomView,c.style.vbox),onMouseDown:this.onMouseDown,onMouseMove:this.onMouseMove,onMouseLeave:this.onMouseLeave,onWheel:this.onWheel,ref:this.containerRef},s.h("canvas",{width:1,height:1,ref:this.overlayCanvasRef,className:o.css(c.style.fill)}))}}exports.FlamechartPanZoomView=w;class d extends r.ReloadableComponent{constructor(){super(),this.container=null,this.setConfigSpaceViewportRect=(e=>{const t=new n.Rect(new n.Vec2(0,-1),n.Vec2.max(new n.Vec2(0,0),this.configSpaceSize().minus(e.size))),i=new n.Rect(new n.Vec2(this.minConfigSpaceViewportRectWidth(),e.height()),new n.Vec2(this.configSpaceSize().x,e.height()));this.setState({configSpaceViewportRect:new n.Rect(t.closestPointTo(e.origin),i.closestPointTo(e.size))})}),this.transformViewport=(e=>{const t=e.transformRect(this.state.configSpaceViewportRect);this.setConfigSpaceViewportRect(t)}),this.onNodeHover=((e,t)=>{this.setState({hoveredNode:e,logicalSpaceMouse:t.plus(new n.Vec2(0,c.Sizes.MINIMAP_HEIGHT))})}),this.containerRef=(e=>{this.container=e||null}),this.panZoomRef=(e=>{this.panZoomView=e}),this.state={hoveredNode:null,configSpaceViewportRect:n.Rect.empty,logicalSpaceMouse:n.Vec2.zero}}configSpaceSize(){return new n.Vec2(this.props.flamechart.getTotalWeight(),this.props.flamechart.getLayers().length)}minConfigSpaceViewportRectWidth(){return Math.min(this.props.flamechart.getTotalWeight(),3*this.props.flamechart.getMinFrameWidth())}formatValue(e){const t=100*e/this.props.flamechart.getTotalWeight();let i=`${t.toFixed(0)}%`;return 100===t?i="100%":t>99?i=">99%":t<.01?i="<0.01%":t<1?i=`${t.toFixed(2)}%`:t<10&&(i=`${t.toFixed(1)}%`),`${this.props.flamechart.formatValue(e)} (${i})`}renderTooltip(){if(!this.container)return null;const{hoveredNode:e,logicalSpaceMouse:t}=this.state;if(!e)return null;const{width:i,height:r}=this.container.getBoundingClientRect(),n={};return t.x+7+c.Sizes.TOOLTIP_WIDTH_MAXa.cachedMeasureTextWidth(i,t(o,e)),s);return t(o,r)}Object.defineProperty(exports,"__esModule",{value:!0});const o=require("preact"),s=require("aphrodite"),r=require("./reloadable"),n=require("./math"),a=require("./utils"),h=require("./flamechart-minimap-view"),c=require("./flamechart-style"),l=require("./style"),p="…",f=window.devicePixelRatio;class w extends r.ReloadableComponent{constructor(){super(...arguments),this.container=null,this.containerRef=(e=>{this.container=e||null}),this.overlayCanvas=null,this.overlayCtx=null,this.hoveredLabel=null,this.overlayCanvasRef=(e=>{e?(this.overlayCanvas=e,this.overlayCtx=this.overlayCanvas.getContext("2d"),this.renderCanvas()):(this.overlayCanvas=null,this.overlayCtx=null)}),this.LOGICAL_VIEW_SPACE_FRAME_HEIGHT=16,this.lastBounds=null,this.onWindowResize=(()=>{this.updateConfigSpaceViewport(!0),this.onBeforeFrame()}),this.frameHadWheelEvent=!1,this.framesWithoutWheelEvents=0,this.interactionLock=null,this.maybeClearInteractionLock=(()=>{this.interactionLock&&(this.frameHadWheelEvent||(this.framesWithoutWheelEvents++,this.framesWithoutWheelEvents>=2&&(this.interactionLock=null,this.framesWithoutWheelEvents=0)),this.props.canvasContext.requestFrame()),this.frameHadWheelEvent=!1}),this.onBeforeFrame=(()=>{this.renderRects(),this.renderOverlays(),this.maybeClearInteractionLock()}),this.renderCanvas=(()=>{this.props.canvasContext.requestFrame()}),this.lastDragPos=null,this.onMouseDown=(e=>{this.lastDragPos=new n.Vec2(e.offsetX,e.offsetY),this.updateCursor(),window.addEventListener("mouseup",this.onWindowMouseUp)}),this.onMouseDrag=(e=>{if(!this.lastDragPos)return;const t=new n.Vec2(e.offsetX,e.offsetY);this.pan(this.lastDragPos.minus(t)),this.lastDragPos=t,this.hoveredLabel&&this.props.setNodeHover(this.hoveredLabel.node,t)}),this.onWindowMouseUp=(e=>{this.lastDragPos=null,this.updateCursor(),window.removeEventListener("mouseup",this.onWindowMouseUp)}),this.onMouseMove=(e=>{if(this.updateCursor(),this.lastDragPos)return e.preventDefault(),void this.onMouseDrag(e);this.hoveredLabel=null;const t=new n.Vec2(e.offsetX,e.offsetY),i=this.logicalToPhysicalViewSpace().transformPosition(t),o=this.configSpaceToPhysicalViewSpace().inverseTransformPosition(i);if(!o)return;const s=(e,t=0)=>{const i=e.end-e.start,r=new n.Rect(new n.Vec2(e.start,t),new n.Vec2(i,1));if(o.xr.right())return null;r.contains(o)&&(this.hoveredLabel={configSpaceBounds:r,node:e.node});for(let i of e.children)s(i,t+1)};for(let e of this.props.flamechart.getLayers()[0]||[])s(e);this.hoveredLabel?this.props.setNodeHover(this.hoveredLabel.node,t):this.props.setNodeHover(null,t),this.renderCanvas()}),this.onMouseLeave=(e=>{this.hoveredLabel=null,this.props.setNodeHover(null,n.Vec2.zero),this.renderCanvas()}),this.onWheel=(e=>{e.preventDefault(),this.frameHadWheelEvent=!0;if((e.metaKey||e.ctrlKey)&&"pan"!==this.interactionLock){let t=1+e.deltaY/100;e.ctrlKey&&(t=1+e.deltaY/40),t=n.clamp(t,.1,10),this.zoom(new n.Vec2(e.offsetX,e.offsetY),t)}else"zoom"!==this.interactionLock&&this.pan(new n.Vec2(e.deltaX,e.deltaY));this.renderCanvas()}),this.onWindowKeyPress=(e=>{if(!this.container)return;const{width:t,height:i}=this.container.getBoundingClientRect();"="===e.key||"+"===e.key?(this.zoom(new n.Vec2(t/2,i/2),.5),e.preventDefault()):"-"===e.key||"_"===e.key?(this.zoom(new n.Vec2(t/2,i/2),2),e.preventDefault()):"0"===e.key?this.zoom(new n.Vec2(t/2,i/2),1e9):"ArrowRight"===e.key||"d"===e.key?this.pan(new n.Vec2(100,0)):"ArrowLeft"===e.key||"a"===e.key?this.pan(new n.Vec2(-100,0)):"ArrowUp"===e.key||"w"===e.key?this.pan(new n.Vec2(0,-100)):"ArrowDown"!==e.key&&"s"!==e.key||this.pan(new n.Vec2(0,100))})}setConfigSpaceViewportRect(e){this.props.setConfigSpaceViewportRect(e)}configSpaceSize(){return new n.Vec2(this.props.flamechart.getTotalWeight(),this.props.flamechart.getLayers().length)}physicalViewSize(){return new n.Vec2(this.overlayCanvas?this.overlayCanvas.width:0,this.overlayCanvas?this.overlayCanvas.height:0)}configSpaceToPhysicalViewSpace(){return n.AffineTransform.betweenRects(this.props.configSpaceViewportRect,new n.Rect(new n.Vec2(0,0),this.physicalViewSize()))}logicalToPhysicalViewSpace(){return n.AffineTransform.withScale(new n.Vec2(f,f))}resizeOverlayCanvasIfNeeded(){if(!this.overlayCanvas)return;let{width:e,height:t}=this.overlayCanvas.getBoundingClientRect();if(e=Math.floor(e),t=Math.floor(t),0===e||0===t)return;const i=e*f,o=t*f;i===this.overlayCanvas.width&&o===this.overlayCanvas.height||(this.overlayCanvas.width=i,this.overlayCanvas.height=o)}renderOverlays(){const e=this.overlayCtx;if(!e)return;if(this.resizeOverlayCanvasIfNeeded(),this.props.configSpaceViewportRect.isEmpty())return;const t=this.configSpaceToPhysicalViewSpace(),o=l.FontSize.LABEL*f,s=this.LOGICAL_VIEW_SPACE_FRAME_HEIGHT*f,r=this.physicalViewSize();if(e.clearRect(0,0,r.x,r.y),e.strokeStyle="rgba(15, 10, 5, 0.5)",e.lineWidth=2,this.hoveredLabel){const i=t.transformRect(this.hoveredLabel.configSpaceBounds);e.strokeRect(Math.floor(i.left()),Math.floor(i.top()),Math.floor(i.width()),Math.floor(i.height()))}e.font=`${o}px/${s}px ${l.FontFamily.MONOSPACE}`,e.fillStyle=l.Colors.GRAY,e.textBaseline="top";const h=a.cachedMeasureTextWidth(e,"M"+p+"M"),c=(t.inverseTransformVector(new n.Vec2(h,0))||new n.Vec2(0,0)).x,w=(s-o)/2,d=new n.Vec2(w,w),u=new n.Vec2(2*w,2*w),m=(o,s=0)=>{const a=o.end-o.start,h=new n.Rect(new n.Vec2(o.start,s),new n.Vec2(a,1));if(!(athis.props.configSpaceViewportRect.right()||h.right()this.props.configSpaceViewportRect.bottom())){if(h.hasIntersectionWith(this.props.configSpaceViewportRect)){let s=t.transformRect(h);s.left()<0&&(s=s.withOrigin(s.origin.withX(0)).withSize(s.size.withX(s.size.x+s.left()))),s.right()>r.x&&(s=s.withSize(s.size.withX(r.x-s.left()))),s=s.withOrigin(s.origin.plus(d)).withSize(s.size.minus(u));const n=i(e,o.node.frame.name,s.width());e.fillText(n,s.left(),s.top())}for(let e of o.children)m(e,s+1)}};for(let e of this.props.flamechart.getLayers()[0]||[])m(e);const g=this.props.configSpaceViewportRect.left(),v=this.props.configSpaceViewportRect.right(),V=(this.configSpaceToPhysicalViewSpace().inverted()||new n.AffineTransform).times(this.logicalToPhysicalViewSpace()).transformVector(new n.Vec2(200,1)).x;let y=Math.pow(10,Math.floor(Math.log10(V)));V/y>5?y*=5:V/y>2&&(y*=2),e.fillStyle="rgba(255, 255, 255, 0.8)",e.fillRect(0,0,r.x,s),e.fillStyle=l.Colors.GRAY;for(let i=Math.ceil(g/y)*y;i{this.props.flamechartRenderer.render({physicalSpaceDstRect:new n.Rect(n.Vec2.zero,this.physicalViewSize()),configSpaceSrcRect:this.props.configSpaceViewportRect,renderOutlines:!0})}))}pan(e){this.interactionLock="pan";const t=this.logicalToPhysicalViewSpace().transformVector(e),i=this.configSpaceToPhysicalViewSpace().inverseTransformVector(t);i&&this.props.transformViewport(n.AffineTransform.withTranslation(i))}zoom(e,t){this.interactionLock="zoom";const i=this.logicalToPhysicalViewSpace().transformPosition(e),o=this.configSpaceToPhysicalViewSpace().inverseTransformPosition(i);if(!o)return;const s=n.AffineTransform.withTranslation(o.times(-1)).scaledBy(new n.Vec2(t,1)).translatedBy(o);this.props.transformViewport(s)}updateCursor(){this.lastDragPos?(document.body.style.cursor="grabbing",document.body.style.cursor="-webkit-grabbing"):document.body.style.cursor="default"}shouldComponentUpdate(){return!1}componentWillReceiveProps(e){this.props.flamechart!==e.flamechart?this.renderCanvas():this.props.configSpaceViewportRect!==e.configSpaceViewportRect&&this.renderCanvas()}componentDidMount(){this.props.canvasContext.addBeforeFrameHandler(this.onBeforeFrame),window.addEventListener("resize",this.onWindowResize),window.addEventListener("keydown",this.onWindowKeyPress)}componentWillUnmount(){this.props.canvasContext.removeBeforeFrameHandler(this.onBeforeFrame),window.removeEventListener("resize",this.onWindowResize),window.removeEventListener("keydown",this.onWindowKeyPress)}render(){return o.h("div",{className:s.css(c.style.panZoomView,c.style.vbox),onMouseDown:this.onMouseDown,onMouseMove:this.onMouseMove,onMouseLeave:this.onMouseLeave,onWheel:this.onWheel,ref:this.containerRef},o.h("canvas",{width:1,height:1,ref:this.overlayCanvasRef,className:s.css(c.style.fill)}))}}exports.FlamechartPanZoomView=w;class d extends r.ReloadableComponent{constructor(){super(),this.container=null,this.setConfigSpaceViewportRect=(e=>{const t=new n.Rect(new n.Vec2(0,-1),n.Vec2.max(new n.Vec2(0,0),this.configSpaceSize().minus(e.size))),i=new n.Rect(new n.Vec2(this.minConfigSpaceViewportRectWidth(),e.height()),new n.Vec2(this.configSpaceSize().x,e.height()));this.setState({configSpaceViewportRect:new n.Rect(t.closestPointTo(e.origin),i.closestPointTo(e.size))})}),this.transformViewport=(e=>{const t=e.transformRect(this.state.configSpaceViewportRect);this.setConfigSpaceViewportRect(t)}),this.onNodeHover=((e,t)=>{this.setState({hoveredNode:e,logicalSpaceMouse:t.plus(new n.Vec2(0,c.Sizes.MINIMAP_HEIGHT))})}),this.containerRef=(e=>{this.container=e||null}),this.panZoomRef=(e=>{this.panZoomView=e}),this.state={hoveredNode:null,configSpaceViewportRect:n.Rect.empty,logicalSpaceMouse:n.Vec2.zero}}configSpaceSize(){return new n.Vec2(this.props.flamechart.getTotalWeight(),this.props.flamechart.getLayers().length)}minConfigSpaceViewportRectWidth(){return Math.min(this.props.flamechart.getTotalWeight(),3*this.props.flamechart.getMinFrameWidth())}formatValue(e){const t=100*e/this.props.flamechart.getTotalWeight();let i=`${t.toFixed(0)}%`;return 100===t?i="100%":t>99?i=">99%":t<.01?i="<0.01%":t<1?i=`${t.toFixed(2)}%`:t<10&&(i=`${t.toFixed(1)}%`),`${this.props.flamechart.formatValue(e)} (${i})`}renderTooltip(){if(!this.container)return null;const{hoveredNode:e,logicalSpaceMouse:t}=this.state;if(!e)return null;const{width:i,height:r}=this.container.getBoundingClientRect(),n={};return t.x+7+c.Sizes.TOOLTIP_WIDTH_MAX=this.capacity;)this.map.delete(this.list.pop().data);const h=this.list.prepend(new t(e));this.map.set(e,{value:i,listNode:h})}getOrInsert(t,e){let i=this.get(t);return null==i&&(i=e(t),this.insert(t,i)),i}removeLRU(){const t=this.list.pop();if(!t)return null;const e=t.data,i=this.map.get(e).value;return this.map.delete(e),[e,i]}}exports.LRUCache=i; -},{}],55:[function(require,module,exports) { +},{}],22:[function(require,module,exports) { "use strict";function t(t){return t-Math.floor(t)}Object.defineProperty(exports,"__esModule",{value:!0});class o{constructor(t=0,o=0,r=0,e=1){this.r=t,this.g=o,this.b=r,this.a=e}static fromLumaChromaHue(t,r,e){const s=e/60,n=r*(1-Math.abs(s%2-1)),[a,l,u]=s<1?[r,n,0]:s<2?[n,r,0]:s<3?[0,r,n]:s<4?[0,n,r]:s<5?[n,0,r]:[r,0,n],c=t-(.3*a+.59*l+.11*u);return new o(a+c,l+c,u+c,1)}}exports.Color=o;class r{constructor(r){function e(t){return(t.file||"")+t.name}function s(t,o){return e(t)>e(o)?1:-1}this.frameToColor=new Map,(r=[...r]).sort(s);const n=[];let a=0;for(let t=0;t{for(let s of e){let e=this.rowCache.get(s);if(null!=e)continue;e=this.allocateLine(s);const c=new t.Rect(new t.Vec2(0,e),new t.Vec2(this.texture.width,1));this.canvasContext.drawRectangleBatch({batch:this.clearLineBatch,configSpaceSrcRect:t.Rect.unit,physicalSpaceDstRect:c}),r(c,s)}})}renderViaAtlas(e,r){let s=this.rowCache.get(e);if(null==s)return!1;const c=new t.Rect(new t.Vec2(0,s),new t.Vec2(this.texture.width,1));return this.canvasContext.drawTexture({texture:this.texture,srcRect:c,dstRect:r}),!0}}class a{constructor(t,e,r){this.batch=t,this.bounds=e,this.numPrecedingRectanglesInRow=r,this.children=[],t.uploadToGPU()}getBatch(){return this.batch}getBounds(){return this.bounds}getRectCount(){return this.batch.getRectCount()}getChildren(){return this.children}getParity(){return this.numPrecedingRectanglesInRow%2}forEachLeafNodeWithinBounds(t,e){this.bounds.hasIntersectionWith(t)&&e(this)}}class i{constructor(e){if(this.children=e,this.rectCount=0,0===e.length)throw new Error("Empty interior node");let r=1/0,s=-1/0,c=1/0,n=-1/0;for(let t of e){this.rectCount+=t.getRectCount();const e=t.getBounds();r=Math.min(r,e.left()),s=Math.max(s,e.right()),c=Math.min(c,e.top()),n=Math.max(n,e.bottom())}this.bounds=new t.Rect(new t.Vec2(r,c),new t.Vec2(s-r,n-c))}getBounds(){return this.bounds}getRectCount(){return this.rectCount}getChildren(){return this.children}forEachLeafNodeWithinBounds(t,e){if(this.bounds.hasIntersectionWith(t))for(let r of this.children)r.forEachLeafNodeWithinBounds(t,e)}}class h{constructor(e,s){this.canvasContext=e,this.flamechart=s,this.layers=[],this.atlasKeys=new Map;const h=s.getLayers().length;this.rowAtlas=new n(e);for(let n=0;n=c&&(h.push(new a(f,new t.Rect(new t.Vec2(l,n),new t.Vec2(u-l,1)),g)),l=1/0,u=-1/0,f=e.createRectangleBatch());const w=new t.Rect(new t.Vec2(i.start,o),new t.Vec2(i.end-i.start,1));l=Math.min(l,w.left()),u=Math.max(u,w.right());const p=new r.Color((1+s%255)/256,(1+n%255)/256,(1+this.flamechart.getColorBucketForFrame(i.node.frame))/256);f.addRect(w,p),g++}f.getRectCount()>0&&h.push(new a(f,new t.Rect(new t.Vec2(l,n),new t.Vec2(u-l,1)),g)),this.layers.push(new i(h)),this.rectInfoTexture=this.canvasContext.gl.texture({width:1,height:1}),this.framebuffer=this.canvasContext.gl.framebuffer({color:[this.rectInfoTexture]})}}getOrInsertKey(t){const e=`${t.stackDepth}_${t.index}_${t.zoomLevel}`;return s.getOrInsert(this.atlasKeys,e,()=>t)}configSpaceBoundsForKey(e){const{stackDepth:r,zoomLevel:s,index:c}=e,n=this.flamechart.getTotalWeight()/Math.pow(2,s);return new t.Rect(new t.Vec2(n*c,r),new t.Vec2(n,1))}render(e){const{configSpaceSrcRect:r,physicalSpaceDstRect:s}=e,c=[],n=t.AffineTransform.betweenRects(r,s);let a=0;for(;;){const t=this.configSpaceBoundsForKey({stackDepth:0,zoomLevel:a,index:0});if(n.transformRect(t).width(){const r=this.configSpaceBoundsForKey(e);this.layers[e.stackDepth].forEachLeafNodeWithinBounds(r,s=>{this.canvasContext.drawRectangleBatch({batch:s.getBatch(),configSpaceSrcRect:r,physicalSpaceDstRect:t,parityMin:e.stackDepth%2==0?2:0,parityOffset:s.getParity()})})}),this.framebuffer.resize(s.width(),s.height()),this.framebuffer.use(e=>{this.canvasContext.gl.clear({color:[0,0,0,0]});const s=new t.Rect(t.Vec2.zero,new t.Vec2(e.viewportWidth,e.viewportHeight)),c=t.AffineTransform.betweenRects(r,s);for(let t of d){const e=this.configSpaceBoundsForKey(t);this.rowAtlas.renderViaAtlas(t,c.transformRect(e))}for(let t of w){const e=this.configSpaceBoundsForKey(t),s=c.transformRect(e);this.layers[t.stackDepth].forEachLeafNodeWithinBounds(e,e=>{this.canvasContext.drawRectangleBatch({batch:e.getBatch(),configSpaceSrcRect:r,physicalSpaceDstRect:s,parityMin:t.stackDepth%2==0?2:0,parityOffset:e.getParity()})})}}),this.canvasContext.drawFlamechartColorPass({rectInfoTexture:this.rectInfoTexture,srcRect:new t.Rect(t.Vec2.zero,new t.Vec2(this.rectInfoTexture.width,this.rectInfoTexture.height)),dstRect:s,renderOutlines:e.renderOutlines})}}exports.FlamechartRenderer=h; -},{"./math":51,"./utils":16,"./lru-cache":54,"./color":55}],47:[function(require,module,exports) { +},{"./math":18,"./lru-cache":21,"./color":22,"./utils":23}],15:[function(require,module,exports) { "use strict";Object.defineProperty(exports,"__esModule",{value:!0});const e=require("./math");class t{constructor(e){this.gl=e,this.rectCapacity=1e3,this.rectCount=0,this.configSpaceOffsets=new Float32Array(2*this.rectCapacity),this.configSpaceSizes=new Float32Array(2*this.rectCapacity),this.colors=new Float32Array(3*this.rectCapacity),this.configSpaceOffsetBuffer=null,this.configSpaceSizeBuffer=null,this.colorBuffer=null}getRectCount(){return this.rectCount}getConfigSpaceOffsetBuffer(){return this.configSpaceOffsetBuffer||(this.configSpaceOffsetBuffer=this.gl.buffer(this.configSpaceOffsets)),this.configSpaceOffsetBuffer}getConfigSpaceSizeBuffer(){return this.configSpaceSizeBuffer||(this.configSpaceSizeBuffer=this.gl.buffer(this.configSpaceSizes)),this.configSpaceSizeBuffer}getColorBuffer(){return this.colorBuffer||(this.colorBuffer=this.gl.buffer(this.colors)),this.colorBuffer}uploadToGPU(){this.getConfigSpaceOffsetBuffer(),this.getConfigSpaceSizeBuffer(),this.getColorBuffer()}addRect(e,t){const i=this.rectCount++;if(i>=this.rectCapacity){this.rectCapacity*=2;const e=new Float32Array(2*this.rectCapacity),t=new Float32Array(2*this.rectCapacity),i=new Float32Array(3*this.rectCapacity);e.set(this.configSpaceOffsets),t.set(this.configSpaceSizes),i.set(this.colors),this.configSpaceOffsets=e,this.configSpaceSizes=t,this.colors=i}this.configSpaceOffsets[2*i]=e.origin.x,this.configSpaceOffsets[2*i+1]=e.origin.y,this.configSpaceSizes[2*i]=e.size.x,this.configSpaceSizes[2*i+1]=e.size.y,this.colors[3*i]=t.r,this.colors[3*i+1]=t.g,this.colors[3*i+2]=t.b}}exports.RectangleBatch=t;class i{constructor(t){this.command=t({vert:"\n uniform mat3 configSpaceToNDC;\n\n // Non-instanced\n attribute vec2 corner;\n\n // Instanced\n attribute vec2 configSpaceOffset;\n attribute vec2 configSpaceSize;\n attribute vec3 color;\n attribute float index;\n\n varying vec3 vColor;\n\n void main() {\n vColor = color;\n vec2 configSpacePos = configSpaceOffset + corner * configSpaceSize;\n vec2 position = (configSpaceToNDC * vec3(configSpacePos, 1)).xy;\n gl_Position = vec4(position, 1, 1);\n }\n ",depth:{enable:!1},frag:"\n precision mediump float;\n varying vec3 vColor;\n varying float vParity;\n\n void main() {\n gl_FragColor = vec4(vColor.rgb, 1);\n }\n ",attributes:{corner:t.buffer([[0,0],[1,0],[0,1],[1,1]]),configSpaceOffset:(e,t)=>({buffer:t.batch.getConfigSpaceOffsetBuffer(),offset:0,stride:8,size:2,divisor:1}),configSpaceSize:(e,t)=>({buffer:t.batch.getConfigSpaceSizeBuffer(),offset:0,stride:8,size:2,divisor:1}),color:(e,t)=>({buffer:t.batch.getColorBuffer(),offset:0,stride:12,size:3,divisor:1})},uniforms:{configSpaceToNDC:(t,i)=>{const c=e.AffineTransform.betweenRects(i.configSpaceSrcRect,i.physicalSpaceDstRect),s=new e.Vec2(t.viewportWidth,t.viewportHeight);return e.AffineTransform.withTranslation(new e.Vec2(-1,1)).times(e.AffineTransform.withScale(new e.Vec2(2,-2).dividedByPointwise(s))).times(c).flatten()},parityOffset:(e,t)=>null==t.parityOffset?0:t.parityOffset,parityMin:(e,t)=>null==t.parityMin?0:1+t.parityMin},instances:(e,t)=>t.batch.getRectCount(),count:4,primitive:"triangle strip"})}render(e){this.command(e)}resetStats(){return Object.assign(this.command.stats,{cpuTime:0,gpuTime:0,count:0})}stats(){return this.command.stats}}exports.RectangleBatchRenderer=i; -},{"./math":51}],48:[function(require,module,exports) { +},{"./math":18}],16:[function(require,module,exports) { "use strict";Object.defineProperty(exports,"__esModule",{value:!0});class e{constructor(e){this.command=e({vert:"\n attribute vec2 position;\n\n void main() {\n gl_Position = vec4(position, 0, 1);\n }\n ",frag:"\n precision mediump float;\n\n uniform mat3 configSpaceToPhysicalViewSpace;\n uniform vec2 physicalSize;\n uniform vec2 physicalOrigin;\n uniform vec2 configSpaceViewportOrigin;\n uniform vec2 configSpaceViewportSize;\n uniform float framebufferHeight;\n\n void main() {\n vec2 origin = (configSpaceToPhysicalViewSpace * vec3(configSpaceViewportOrigin, 1.0)).xy;\n vec2 size = (configSpaceToPhysicalViewSpace * vec3(configSpaceViewportSize, 0.0)).xy;\n\n vec2 halfSize = physicalSize / 2.0;\n\n float borderWidth = 2.0;\n\n origin = floor(origin * halfSize) / halfSize + borderWidth * vec2(1.0, 1.0);\n size = floor(size * halfSize) / halfSize - 2.0 * borderWidth * vec2(1.0, 1.0);\n\n vec2 coord = gl_FragCoord.xy;\n coord.x = coord.x - physicalOrigin.x;\n coord.y = framebufferHeight - coord.y - physicalOrigin.y;\n vec2 clamped = clamp(coord, origin, origin + size);\n vec2 gap = clamped - coord;\n float maxdist = max(abs(gap.x), abs(gap.y));\n\n // TOOD(jlfwong): Could probably optimize this to use mix somehow.\n if (maxdist == 0.0) {\n // Inside viewport rectangle\n gl_FragColor = vec4(0, 0, 0, 0);\n } else if (maxdist < borderWidth) {\n // Inside viewport rectangle at border\n gl_FragColor = vec4(0.7, 0.7, 0.7, 0.8);\n } else {\n // Outside viewport rectangle\n gl_FragColor = vec4(0.7, 0.7, 0.7, 0.5);\n }\n }\n ",blend:{enable:!0,func:{srcRGB:"src alpha",srcAlpha:"one",dstRGB:"one minus src alpha",dstAlpha:"one"}},depth:{enable:!1},attributes:{position:[[-1,1],[1,1],[-1,-1],[1,-1]]},uniforms:{configSpaceToPhysicalViewSpace:(e,i)=>i.configSpaceToPhysicalViewSpace.flatten(),configSpaceViewportOrigin:(e,i)=>i.configSpaceViewportRect.origin.flatten(),configSpaceViewportSize:(e,i)=>i.configSpaceViewportRect.size.flatten(),physicalSize:(e,i)=>[e.viewportWidth,e.viewportHeight],physicalOrigin:(e,i)=>[e.viewportX,e.viewportY],framebufferHeight:(e,i)=>e.framebufferHeight},primitive:"triangle strip",count:4})}render(e){this.command(e)}resetStats(){return Object.assign(this.command.stats,{cpuTime:0,gpuTime:0,count:0})}stats(){return this.command.stats}}exports.ViewportRectangleRenderer=e; -},{}],49:[function(require,module,exports) { -"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const e=require("./math");class t{}exports.TextureRendererProps=t;class r{constructor(t){this.command=t({vert:"\n uniform mat3 uvTransform;\n uniform mat3 positionTransform;\n\n attribute vec2 position;\n attribute vec2 uv;\n varying vec2 vUv;\n\n void main() {\n vUv = (uvTransform * vec3(uv, 1)).xy;\n gl_Position = vec4((positionTransform * vec3(position, 1)).xy, 0, 1);\n }\n ",frag:"\n precision mediump float;\n\n varying vec2 vUv;\n uniform sampler2D texture;\n\n void main() {\n gl_FragColor = texture2D(texture, vUv);\n }\n ",depth:{enable:!1},attributes:{position:t.buffer([[-1,1],[1,1],[-1,-1],[1,-1]]),uv:t.buffer([[0,1],[1,1],[0,0],[1,0]])},uniforms:{texture:(e,t)=>t.texture,uvTransform:(t,r)=>{const{srcRect:i,texture:n}=r,s=e.AffineTransform.withTranslation(new e.Vec2(0,1)).times(e.AffineTransform.withScale(new e.Vec2(1,-1))).times(e.AffineTransform.betweenRects(new e.Rect(e.Vec2.zero,new e.Vec2(n.width,n.height)),e.Rect.unit)).transformRect(i);return e.AffineTransform.betweenRects(e.Rect.unit,s).flatten()},positionTransform:(t,r)=>{const{dstRect:i}=r,n=new e.Vec2(t.viewportWidth,t.viewportHeight),s=e.AffineTransform.withScale(new e.Vec2(1,-1)).times(e.AffineTransform.betweenRects(new e.Rect(e.Vec2.zero,n),e.Rect.NDC)).transformRect(i);return e.AffineTransform.betweenRects(e.Rect.NDC,s).flatten()}},primitive:"triangle strip",count:4})}render(e){this.command(e)}resetStats(){return Object.assign(this.command.stats,{cpuTime:0,gpuTime:0,count:0})}stats(){return this.command.stats}}exports.TextureRenderer=r;class i{constructor(e,t){this.gl=e,this.lastRenderProps=null,this.dirty=!1,this.renderUncached=t.render,this.shouldUpdate=t.shouldUpdate,this.textureRenderer=t.textureRenderer,this.texture=e.texture(1,1),this.framebuffer=e.framebuffer({color:[this.texture]}),this.withContext=e({})}setDirty(){this.dirty=!0}render(t){this.withContext(r=>{let i=!1;this.texture.width!==r.viewportWidth||this.texture.height!==r.viewportHeight?(this.texture({width:r.viewportWidth,height:r.viewportHeight}),this.framebuffer({color:[this.texture]}),i=!0):null==this.lastRenderProps?i=!0:this.shouldUpdate(this.lastRenderProps,t)?i=!0:this.dirty&&(i=!0),i&&this.gl({viewport:(e,t)=>({x:0,y:0,width:e.viewportWidth,height:e.viewportHeight}),framebuffer:this.framebuffer})(()=>{this.gl.clear({color:[0,0,0,0]}),this.renderUncached(t)});const n=new e.Rect(e.Vec2.zero,new e.Vec2(r.viewportWidth,r.viewportHeight));this.textureRenderer.render({texture:this.texture,srcRect:n,dstRect:n}),this.lastRenderProps=t,this.dirty=!1})}}exports.TextureCachedRenderer=i; -},{"./math":51}],50:[function(require,module,exports) { +},{}],17:[function(require,module,exports) { "use strict";Object.defineProperty(exports,"__esModule",{value:!0});class t{constructor(){this.container=document.createElement("div"),this.shown=0,this.panels=[],this.msPanel=new s("MS","#0f0","#020"),this.fpsPanel=new s("FPS","#0ff","#002"),this.frames=0,this.prevTime=0,this.container.style.cssText="\n position:fixed;\n bottom:0;\n right:0;\n cursor:pointer;\n opacity:0.9;\n z-index:10000\n ",this.container.addEventListener("click",()=>{this.showPanel((this.shown+1)%this.panels.length)}),this.addPanel(this.msPanel),this.addPanel(this.fpsPanel),document.body.appendChild(this.container)}addPanel(t){t.appendTo(this.container),this.panels.push(t),this.showPanel(this.panels.length-1)}showPanel(t){for(var i=0;i=this.prevTime+1e3&&(this.fpsPanel.update(1e3*this.frames/(t-this.prevTime),100),this.prevTime=t,this.frames=0)}}exports.StatsPanel=t;const i=Math.round(window.devicePixelRatio||1);class s{constructor(t,s,h){this.name=t,this.fg=s,this.bg=h,this.min=1/0,this.max=0,this.canvas=document.createElement("canvas"),this.context=this.canvas.getContext("2d"),this.WIDTH=80*i,this.HEIGHT=48*i,this.TEXT_X=3*i,this.TEXT_Y=2*i,this.GRAPH_X=3*i,this.GRAPH_Y=15*i,this.GRAPH_WIDTH=74*i,this.GRAPH_HEIGHT=30*i,this.canvas.width=this.WIDTH,this.canvas.height=this.HEIGHT,this.canvas.style.cssText="width:80px;height:48px",this.context.font="bold "+9*i+"px Helvetica,Arial,sans-serif",this.context.textBaseline="top",this.context.fillStyle=h,this.context.fillRect(0,0,this.WIDTH,this.HEIGHT),this.context.fillStyle=s,this.context.fillText(this.name,this.TEXT_X,this.TEXT_Y),this.context.fillRect(this.GRAPH_X,this.GRAPH_Y,this.GRAPH_WIDTH,this.GRAPH_HEIGHT),this.context.fillStyle=h,this.context.globalAlpha=.9,this.context.fillRect(this.GRAPH_X,this.GRAPH_Y,this.GRAPH_WIDTH,this.GRAPH_HEIGHT)}appendTo(t){t.appendChild(this.canvas)}update(t,s){this.min=Math.min(this.min,t),this.max=Math.max(this.max,t),this.context.fillStyle=this.bg,this.context.globalAlpha=1,this.context.fillRect(0,0,this.WIDTH,this.GRAPH_Y),this.context.fillStyle=this.fg,this.context.fillText(Math.round(t)+" "+name+" ("+Math.round(this.min)+"-"+Math.round(this.max)+")",this.TEXT_X,this.TEXT_Y),this.context.drawImage(this.canvas,this.GRAPH_X+i,this.GRAPH_Y,this.GRAPH_WIDTH-i,this.GRAPH_HEIGHT,this.GRAPH_X,this.GRAPH_Y,this.GRAPH_WIDTH-i,this.GRAPH_HEIGHT),this.context.fillRect(this.GRAPH_X+this.GRAPH_WIDTH-i,this.GRAPH_Y,i,this.GRAPH_HEIGHT),this.context.fillStyle=this.bg,this.context.globalAlpha=.9,this.context.fillRect(this.GRAPH_X+this.GRAPH_WIDTH-i,this.GRAPH_Y,i,Math.round((1-t/s)*this.GRAPH_HEIGHT))}} -},{}],52:[function(require,module,exports) { +},{}],19:[function(require,module,exports) { +"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const e=require("./math");class t{}exports.TextureRendererProps=t;class r{constructor(t){this.command=t({vert:"\n uniform mat3 uvTransform;\n uniform mat3 positionTransform;\n\n attribute vec2 position;\n attribute vec2 uv;\n varying vec2 vUv;\n\n void main() {\n vUv = (uvTransform * vec3(uv, 1)).xy;\n gl_Position = vec4((positionTransform * vec3(position, 1)).xy, 0, 1);\n }\n ",frag:"\n precision mediump float;\n\n varying vec2 vUv;\n uniform sampler2D texture;\n\n void main() {\n gl_FragColor = texture2D(texture, vUv);\n }\n ",depth:{enable:!1},attributes:{position:t.buffer([[-1,1],[1,1],[-1,-1],[1,-1]]),uv:t.buffer([[0,1],[1,1],[0,0],[1,0]])},uniforms:{texture:(e,t)=>t.texture,uvTransform:(t,r)=>{const{srcRect:i,texture:n}=r,s=e.AffineTransform.withTranslation(new e.Vec2(0,1)).times(e.AffineTransform.withScale(new e.Vec2(1,-1))).times(e.AffineTransform.betweenRects(new e.Rect(e.Vec2.zero,new e.Vec2(n.width,n.height)),e.Rect.unit)).transformRect(i);return e.AffineTransform.betweenRects(e.Rect.unit,s).flatten()},positionTransform:(t,r)=>{const{dstRect:i}=r,n=new e.Vec2(t.viewportWidth,t.viewportHeight),s=e.AffineTransform.withScale(new e.Vec2(1,-1)).times(e.AffineTransform.betweenRects(new e.Rect(e.Vec2.zero,n),e.Rect.NDC)).transformRect(i);return e.AffineTransform.betweenRects(e.Rect.NDC,s).flatten()}},primitive:"triangle strip",count:4})}render(e){this.command(e)}resetStats(){return Object.assign(this.command.stats,{cpuTime:0,gpuTime:0,count:0})}stats(){return this.command.stats}}exports.TextureRenderer=r;class i{constructor(e,t){this.gl=e,this.lastRenderProps=null,this.dirty=!1,this.renderUncached=t.render,this.shouldUpdate=t.shouldUpdate,this.textureRenderer=t.textureRenderer,this.texture=e.texture(1,1),this.framebuffer=e.framebuffer({color:[this.texture]}),this.withContext=e({})}setDirty(){this.dirty=!0}render(t){this.withContext(r=>{let i=!1;this.texture.width!==r.viewportWidth||this.texture.height!==r.viewportHeight?(this.texture({width:r.viewportWidth,height:r.viewportHeight}),this.framebuffer({color:[this.texture]}),i=!0):null==this.lastRenderProps?i=!0:this.shouldUpdate(this.lastRenderProps,t)?i=!0:this.dirty&&(i=!0),i&&this.gl({viewport:(e,t)=>({x:0,y:0,width:e.viewportWidth,height:e.viewportHeight}),framebuffer:this.framebuffer})(()=>{this.gl.clear({color:[0,0,0,0]}),this.renderUncached(t)});const n=new e.Rect(e.Vec2.zero,new e.Vec2(r.viewportWidth,r.viewportHeight));this.textureRenderer.render({texture:this.texture,srcRect:n,dstRect:n}),this.lastRenderProps=t,this.dirty=!1})}}exports.TextureCachedRenderer=i; +},{"./math":18}],20:[function(require,module,exports) { "use strict";Object.defineProperty(exports,"__esModule",{value:!0});const e=require("./math");class n{}exports.FlamechartColorPassRenderProps=n;class t{constructor(n){this.command=n({vert:"\n uniform mat3 uvTransform;\n uniform mat3 positionTransform;\n\n attribute vec2 position;\n attribute vec2 uv;\n varying vec2 vUv;\n\n void main() {\n vUv = (uvTransform * vec3(uv, 1)).xy;\n gl_Position = vec4((positionTransform * vec3(position, 1)).xy, 0, 1);\n }\n ",frag:"\n precision mediump float;\n\n uniform vec2 uvSpacePixelSize;\n uniform float renderOutlines;\n\n varying vec2 vUv;\n uniform sampler2D colorTexture;\n\n // https://en.wikipedia.org/wiki/HSL_and_HSV#From_luma/chroma/hue\n vec3 lch2rgb(float L, float C, float H) {\n float hPrime = H / 60.0;\n float X = C * (1.0 - abs(mod(hPrime, 2.0) - 1.0));\n vec3 RGB =\n hPrime < 1.0 ? vec3(C, X, 0) :\n hPrime < 2.0 ? vec3(X, C, 0) :\n hPrime < 3.0 ? vec3(0, C, X) :\n hPrime < 4.0 ? vec3(0, X, C) :\n hPrime < 5.0 ? vec3(X, 0, C) :\n vec3(C, 0, X);\n\n float m = L - dot(RGB, vec3(0.30, 0.59, 0.11));\n return RGB + vec3(m, m, m);\n }\n\n vec3 colorForBucket(float bucket) {\n float x = 2.0 * fract(100.0 * bucket) - 1.0;\n float L = 0.85 - 0.1 * x;\n float C = 0.20 + 0.1 * x;\n float H = 360.0 * bucket;\n return lch2rgb(L, C, H);\n }\n\n void main() {\n vec4 here = texture2D(colorTexture, vUv);\n\n if (here.z == 0.0) {\n // Background color\n gl_FragColor = vec4(0, 0, 0, 0);\n return;\n }\n\n // Sample the 4 surrounding pixels in the depth texture to determine\n // if we should draw a boundary here or not.\n vec4 N = texture2D(colorTexture, vUv + vec2(0, uvSpacePixelSize.y));\n vec4 E = texture2D(colorTexture, vUv + vec2(uvSpacePixelSize.x, 0));\n vec4 S = texture2D(colorTexture, vUv + vec2(0, -uvSpacePixelSize.y));\n vec4 W = texture2D(colorTexture, vUv + vec2(-uvSpacePixelSize.x, 0));\n\n // NOTE: For outline checks, we intentionally check both the right\n // and the left to determine if we're an edge. If a rectangle is a single\n // pixel wide, we don't want to render it as an outline, so this method\n // of checking ensures that we don't outline single physical-space\n // pixel width rectangles.\n if (\n renderOutlines > 0.0 &&\n (\n here.y == N.y && here.y != S.y || // Top edge\n here.y == S.y && here.y != N.y || // Bottom edge\n here.x == E.x && here.x != W.x || // Left edge\n here.x == W.x && here.x != E.x\n )\n ) {\n // We're on an edge! Draw white.\n gl_FragColor = vec4(1, 1, 1, 1);\n } else {\n // Not on an edge. Draw the appropriate color;\n gl_FragColor = vec4(colorForBucket(here.z), here.a);\n }\n }\n ",depth:{enable:!1},attributes:{position:n.buffer([[-1,1],[1,1],[-1,-1],[1,-1]]),uv:n.buffer([[0,1],[1,1],[0,0],[1,0]])},count:4,primitive:"triangle strip",uniforms:{colorTexture:(e,n)=>n.rectInfoTexture,uvTransform:(n,t)=>{const{srcRect:r,rectInfoTexture:o}=t,i=e.AffineTransform.withTranslation(new e.Vec2(0,1)).times(e.AffineTransform.withScale(new e.Vec2(1,-1))).times(e.AffineTransform.betweenRects(new e.Rect(e.Vec2.zero,new e.Vec2(o.width,o.height)),e.Rect.unit)).transformRect(r);return e.AffineTransform.betweenRects(e.Rect.unit,i).flatten()},renderOutlines:(e,n)=>n.renderOutlines?1:0,uvSpacePixelSize:(n,t)=>e.Vec2.unit.dividedByPointwise(new e.Vec2(t.rectInfoTexture.width,t.rectInfoTexture.height)).flatten(),positionTransform:(n,t)=>{const{dstRect:r}=t,o=new e.Vec2(n.viewportWidth,n.viewportHeight),i=e.AffineTransform.withScale(new e.Vec2(1,-1)).times(e.AffineTransform.betweenRects(new e.Rect(e.Vec2.zero,o),e.Rect.NDC)).transformRect(r);return e.AffineTransform.betweenRects(e.Rect.NDC,i).flatten()}}})}render(e){this.command(e)}}exports.FlamechartColorPassRenderer=t; -},{"./math":51}],53:[function(require,module,exports) { +},{"./math":18}],27:[function(require,module,exports) { var global = (1,eval)("this"); var e=(0,eval)("this");!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):e.createREGL=t()}(this,function(){"use strict";function e(e){return"undefined"!=typeof btoa?btoa(e):"base64:"+e}function t(e){var t=new Error("(regl) "+e);throw t}function r(e,r){e||t(r)}function n(e){return e?": "+e:""}function a(e,r,a){r.indexOf(e)<0&&t("invalid value"+n(a)+". must be one of: "+r)}function i(e,t){for(e+="";e.length1&&t===r&&('"'===t||"'"===t))return['"'+v(e.substr(1,e.length-2))+'"'];var n=/\[(false|true|null|\d+|'[^']*'|"[^"]*")\]/.exec(e);if(n)return y(e.substr(0,n.index)).concat(y(n[1])).concat(y(e.substr(n.index+n[0].length)));var a=e.split(".");if(1===a.length)return['"'+v(e)+'"'];for(var i=[],o=0;o0,"invalid pixel ratio")):n=(a=i).canvas:t=i:Ae.raise("invalid arguments to regl"),t&&("canvas"===t.nodeName.toLowerCase()?n=t:r=t),!a){if(!n){Ae("undefined"!=typeof document,"must manually specify webgl context outside of DOM environments");var m=function(e,t,r){function n(){var t=window.innerWidth,n=window.innerHeight;if(e!==document.body){var i=e.getBoundingClientRect();t=i.right-i.left,n=i.bottom-i.top}a.width=r*t,a.height=r*n,se(a.style,{width:t+"px",height:n+"px"})}var a=document.createElement("canvas");return se(a.style,{border:0,margin:0,padding:0,top:0,left:0}),e.appendChild(a),e===document.body&&(a.style.position="absolute",se(e.style,{margin:0,padding:0})),window.addEventListener("resize",n,!1),n(),{canvas:a,onDestroy:function(){window.removeEventListener("resize",n),e.removeChild(a)}}}(r||document.body,0,s);if(!m)return null;n=m.canvas,d=m.onDestroy}a=function(e,t){function r(r){try{return e.getContext(r,t)}catch(e){return null}}return r("webgl")||r("experimental-webgl")||r("webgl-experimental")}(n,o)}return a?{gl:a,canvas:n,container:r,extensions:f,optionalExtensions:u,pixelRatio:s,profile:c,onDone:l,onDestroy:d}:(d(),l("webgl not supported, try upgrading your browser or graphics drivers http://get.webgl.org"),null)}function S(e){return!!e&&"object"==typeof e&&Array.isArray(e.shape)&&Array.isArray(e.stride)&&"number"==typeof e.offset&&e.shape.length===e.stride.length&&(Array.isArray(e.data)||ue(e.data))}function _(e,t){for(var r=Array(e),n=0;n65535)<<4,e>>>=t,r=(e>255)<<3,e>>>=r,t|=r,r=(e>15)<<2,e>>>=r,t|=r,r=(e>3)<<1,e>>>=r,(t|=r)|e>>1}function T(e){var t=function(e){for(var t=16;t<=1<<28;t*=16)if(e<=t)return t;return 0}(e),r=Ie[E(t)>>2];return r.length>0?r.pop():new ArrayBuffer(t)}function D(e){Ie[E(e.byteLength)>>2].push(e)}function j(e,t,r,n,a,i){for(var o=i,f=0;f>>31<<15,i=(n<<1>>>24)-127,o=n>>13&1023;if(i<-24)t[r]=a;else if(i<-14){var f=-14-i;t[r]=a+(o+1024>>f)}else t[r]=i>15?a+31744:a+(i+15<<10)+o}return t}function P(e){return Array.isArray(e)||ue(e)}function R(e){return"[object "+e+"]"}function L(e){return Array.isArray(e)&&(0===e.length||"number"==typeof e[0])}function I(e){if(!Array.isArray(e))return!1;return!(0===e.length||!P(e[0]))}function M(e){return Object.prototype.toString.call(e)}function W(e){return M(e)===kr}function H(e){if(!e)return!1;var t=M(e);return Er.indexOf(t)>=0||(L(e)||I(e)||S(e))}function G(e){return 0|fe[Object.prototype.toString.call(e)]}function U(e,t){return Me.allocType(e.type===Ft?Yt:e.type,t)}function N(e,t){e.type===Ft?(e.data=B(t),Me.freeType(t)):e.data=t}function q(e,t,r,n,a,i){var o;if(o=void 0!==Dr[e]?Dr[e]:wr[e]*Tr[t],i&&(o*=6),a){for(var f=0,u=r;u>=1;)f+=o*u*u,u/=2;return f}return o*r*n}function Q(e,t,r,n,a,i,o){function f(){this.internalformat=bt,this.format=bt,this.type=qt,this.compressed=!1,this.premultiplyAlpha=!1,this.flipY=!1,this.unpackAlignment=1,this.colorSpace=0,this.width=0,this.height=0,this.channels=0}function u(e,t){e.internalformat=t.internalformat,e.format=t.format,e.type=t.type,e.compressed=t.compressed,e.premultiplyAlpha=t.premultiplyAlpha,e.flipY=t.flipY,e.unpackAlignment=t.unpackAlignment,e.colorSpace=t.colorSpace,e.width=t.width,e.height=t.height,e.channels=t.channels}function s(e,n){if("object"==typeof n&&n){if("premultiplyAlpha"in n&&(Ae.type(n.premultiplyAlpha,"boolean","invalid premultiplyAlpha"),e.premultiplyAlpha=n.premultiplyAlpha),"flipY"in n&&(Ae.type(n.flipY,"boolean","invalid texture flip"),e.flipY=n.flipY),"alignment"in n&&(Ae.oneOf(n.alignment,[1,2,4,8],"invalid texture unpack alignment"),e.unpackAlignment=n.alignment),"colorSpace"in n&&(Ae.parameter(n.colorSpace,R,"invalid colorSpace"),e.colorSpace=R[n.colorSpace]),"type"in n){var a=n.type;Ae(t.oes_texture_float||!("float"===a||"float32"===a),"you must enable the OES_texture_float extension in order to use floating point textures."),Ae(t.oes_texture_half_float||!("half float"===a||"float16"===a),"you must enable the OES_texture_half_float extension in order to use 16-bit floating point textures."),Ae(t.webgl_depth_texture||!("uint16"===a||"uint32"===a||"depth stencil"===a),"you must enable the WEBGL_depth_texture extension in order to use depth/stencil textures."),Ae.parameter(a,Q,"invalid texture type"),e.type=Q[a]}var i=e.width,o=e.height,f=e.channels,u=!1;"shape"in n?(Ae(Array.isArray(n.shape)&&n.shape.length>=2,"shape must be an array"),i=n.shape[0],o=n.shape[1],3===n.shape.length&&(f=n.shape[2],Ae(f>0&&f<=4,"invalid number of channels"),u=!0),Ae(i>=0&&i<=r.maxTextureSize,"invalid width"),Ae(o>=0&&o<=r.maxTextureSize,"invalid height")):("radius"in n&&(i=o=n.radius,Ae(i>=0&&i<=r.maxTextureSize,"invalid radius")),"width"in n&&(i=n.width,Ae(i>=0&&i<=r.maxTextureSize,"invalid width")),"height"in n&&(o=n.height,Ae(o>=0&&o<=r.maxTextureSize,"invalid height")),"channels"in n&&(f=n.channels,Ae(f>0&&f<=4,"invalid number of channels"),u=!0)),e.width=0|i,e.height=0|o,e.channels=0|f;var s=!1;if("format"in n){var c=n.format;Ae(t.webgl_depth_texture||!("depth"===c||"depth stencil"===c),"you must enable the WEBGL_depth_texture extension in order to use depth/stencil textures."),Ae.parameter(c,V,"invalid texture format");var l=e.internalformat=V[c];e.format=re[l],c in Q&&("type"in n||(e.type=Q[c])),c in Y&&(e.compressed=!0),s=!0}!u&&s?e.channels=wr[e.format]:u&&!s?e.channels!==xr[e.format]&&(e.format=e.internalformat=xr[e.channels]):s&&u&&Ae(e.channels===wr[e.format],"number of channels inconsistent with specified format")}}function c(t){e.pixelStorei(pr,t.flipY),e.pixelStorei(hr,t.premultiplyAlpha),e.pixelStorei(br,t.colorSpace),e.pixelStorei(mr,t.unpackAlignment)}function l(){f.call(this),this.xOffset=0,this.yOffset=0,this.data=null,this.needsFree=!1,this.element=null,this.needsCopy=!1}function d(e,t){var n=null;if(H(t)?n=t:t&&(Ae.type(t,"object","invalid pixel data type"),s(e,t),"x"in t&&(e.xOffset=0|t.x),"y"in t&&(e.yOffset=0|t.y),H(t.data)&&(n=t.data)),Ae(!e.compressed||n instanceof Uint8Array,"compressed texture data must be stored in a uint8array"),t.copy){Ae(!n,"can not specify copy and data field for the same texture");var i=a.viewportWidth,o=a.viewportHeight;e.width=e.width||i-e.xOffset,e.height=e.height||o-e.yOffset,e.needsCopy=!0,Ae(e.xOffset>=0&&e.xOffset=0&&e.yOffset0&&e.width<=i&&e.height>0&&e.height<=o,"copy texture read out of bounds")}else if(n){if(ue(n))e.channels=e.channels||4,e.data=n,"type"in t||e.type!==qt||(e.type=G(n));else if(L(n))e.channels=e.channels||4,function(e,t){var r=t.length;switch(e.type){case qt:case Qt:case Vt:case Yt:var n=Me.allocType(e.type,r);n.set(t),e.data=n;break;case Ft:e.data=B(t);break;default:Ae.raise("unsupported texture type, must specify a typed array")}}(e,n),e.alignment=1,e.needsFree=!0;else if(S(n)){var f=n.data;Array.isArray(f)||e.type!==qt||(e.type=G(f));var u,c,l,d,m,p,h=n.shape,b=n.stride;3===h.length?(l=h[2],p=b[2]):(Ae(2===h.length,"invalid ndarray pixel data, must be 2 or 3D"),l=1,p=1),u=h[0],c=h[1],d=b[0],m=b[1],e.alignment=1,e.width=u,e.height=c,e.channels=l,e.format=e.internalformat=xr[l],e.needsFree=!0,function(e,t,r,n,a,i){for(var o=e.width,f=e.height,u=e.channels,s=U(e,o*f*u),c=0,l=0;l=0,"oes_texture_float extension not enabled"):e.type===Ft&&Ae(r.extensions.indexOf("oes_texture_half_float")>=0,"oes_texture_half_float extension not enabled")}function m(t,r,a){var i=t.element,o=t.data,f=t.internalformat,u=t.format,s=t.type,l=t.width,d=t.height;c(t),i?e.texImage2D(r,a,u,u,s,i):t.compressed?e.compressedTexImage2D(r,a,f,l,d,0,o):t.needsCopy?(n(),e.copyTexImage2D(r,a,u,t.xOffset,t.yOffset,l,d,0)):e.texImage2D(r,a,u,l,d,0,u,s,o)}function p(t,r,a,i,o){var f=t.element,u=t.data,s=t.internalformat,l=t.format,d=t.type,m=t.width,p=t.height;c(t),f?e.texSubImage2D(r,o,a,i,l,d,f):t.compressed?e.compressedTexSubImage2D(r,o,a,i,s,m,p,u):t.needsCopy?(n(),e.copyTexSubImage2D(r,o,a,i,t.xOffset,t.yOffset,m,p)):e.texSubImage2D(r,o,a,i,m,p,l,d,u)}function h(){return ne.pop()||new l}function b(e){e.needsFree&&Me.freeType(e.data),l.call(e),ne.push(e)}function g(e,t,r){var n=e.images[0]=h();e.mipmask=1,n.width=e.width=t,n.height=e.height=r,n.channels=e.channels=4}function v(e,t){var r=null;if(H(t))u(r=e.images[0]=h(),e),d(r,t),e.mipmask=1;else if(s(e,t),Array.isArray(t.mipmap))for(var n=t.mipmap,a=0;a>=a,r.height>>=a,d(r,n[a]),e.mipmask|=1<=0&&(e.genMipmaps=!0)}if("mag"in t){var a=t.mag;Ae.parameter(a,F),e.magFilter=F[a]}var i=e.wrapS,o=e.wrapT;if("wrap"in t){var f=t.wrap;"string"==typeof f?(Ae.parameter(f,C),i=o=C[f]):Array.isArray(f)&&(Ae.parameter(f[0],C),Ae.parameter(f[1],C),i=C[f[0]],o=C[f[1]])}else{if("wrapS"in t){var u=t.wrapS;Ae.parameter(u,C),i=C[u]}if("wrapT"in t){var s=t.wrapT;Ae.parameter(s,C),o=C[s]}}if(e.wrapS=i,e.wrapT=o,"anisotropic"in t){var c=t.anisotropic;Ae("number"==typeof c&&c>=1&&c<=r.maxAnisotropic,"aniso samples must be between 1 and "),e.anisotropic=t.anisotropic}if("mipmap"in t){var l=!1;switch(typeof t.mipmap){case"string":Ae.parameter(t.mipmap,O,"invalid mipmap hint"),e.mipmapHint=O[t.mipmap],e.genMipmaps=!0,l=!0;break;case"boolean":l=e.genMipmaps=t.mipmap;break;case"object":Ae(Array.isArray(t.mipmap),"invalid mipmap type"),e.genMipmaps=!1,l=!0;break;default:Ae.raise("invalid mipmap type")}!l||"min"in t||(e.minFilter=ar)}}function _(r,n){e.texParameteri(n,tr,r.minFilter),e.texParameteri(n,er,r.magFilter),e.texParameteri(n,Xt,r.wrapS),e.texParameteri(n,$t,r.wrapT),t.ext_texture_filter_anisotropic&&e.texParameteri(n,dr,r.anisotropic),r.genMipmaps&&(e.hint(ur,r.mipmapHint),e.generateMipmap(n))}function E(t){f.call(this),this.mipmask=0,this.internalformat=bt,this.id=ie++,this.refCount=1,this.target=t,this.texture=e.createTexture(),this.unit=-1,this.bindCount=0,this.texInfo=new k,o.profile&&(this.stats={size:0})}function T(t){e.activeTexture(vr),e.bindTexture(t.target,t.texture)}function D(){var t=ce[0];t?e.bindTexture(t.target,t.texture):e.bindTexture(mt,null)}function j(t){var r=t.texture;Ae(r,"must not double destroy texture");var n=t.unit,a=t.target;n>=0&&(e.activeTexture(vr+n),e.bindTexture(a,null),ce[n]=null),e.deleteTexture(r),t.texture=null,t.params=null,t.pixels=null,t.refCount=0,delete oe[t.id],i.textureCount--}var O={"don't care":sr,"dont care":sr,nice:lr,fast:cr},C={repeat:Kt,clamp:Jt,mirror:Zt},F={nearest:rr,linear:nr},z=se({mipmap:fr,"nearest mipmap nearest":ar,"linear mipmap nearest":ir,"nearest mipmap linear":or,"linear mipmap linear":fr},F),R={none:0,browser:gr},Q={uint8:qt,rgba4:St,rgb565:Et,"rgb5 a1":_t},V={alpha:gt,luminance:yt,"luminance alpha":xt,rgb:vt,rgba:bt,rgba4:wt,"rgb5 a1":kt,rgb565:At},Y={};t.ext_srgb&&(V.srgb=Ot,V.srgba=Ct),t.oes_texture_float&&(Q.float32=Q.float=Yt),t.oes_texture_half_float&&(Q.float16=Q["half float"]=Ft),t.webgl_depth_texture&&(se(V,{depth:Dt,"depth stencil":jt}),se(Q,{uint16:Qt,uint32:Vt,"depth stencil":Tt})),t.webgl_compressed_texture_s3tc&&se(Y,{"rgb s3tc dxt1":zt,"rgba s3tc dxt1":Bt,"rgba s3tc dxt3":Pt,"rgba s3tc dxt5":Rt}),t.webgl_compressed_texture_atc&&se(Y,{"rgb atc":Lt,"rgba atc explicit alpha":It,"rgba atc interpolated alpha":Mt}),t.webgl_compressed_texture_pvrtc&&se(Y,{"rgb pvrtc 4bppv1":Wt,"rgb pvrtc 2bppv1":Ht,"rgba pvrtc 4bppv1":Gt,"rgba pvrtc 2bppv1":Ut}),t.webgl_compressed_texture_etc1&&(Y["rgb etc1"]=Nt);var X=Array.prototype.slice.call(e.getParameter(dt));Object.keys(Y).forEach(function(e){var t=Y[e];X.indexOf(t)>=0&&(V[e]=t)});var $=Object.keys(V);r.textureFormats=$;var K=[];Object.keys(V).forEach(function(e){var t=V[e];K[t]=e});var J=[];Object.keys(Q).forEach(function(e){var t=Q[e];J[t]=e});var Z=[];Object.keys(F).forEach(function(e){var t=F[e];Z[t]=e});var ee=[];Object.keys(z).forEach(function(e){var t=z[e];ee[t]=e});var te=[];Object.keys(C).forEach(function(e){var t=C[e];te[t]=e});var re=$.reduce(function(e,t){var r=V[t];return r===yt||r===gt||r===yt||r===xt||r===Dt||r===jt?e[r]=r:r===kt||t.indexOf("rgba")>=0?e[r]=bt:e[r]=vt,e},{}),ne=[],ae=[],ie=0,oe={},fe=r.maxTextureUnits,ce=Array(fe).map(function(){return null});return se(E.prototype,{bind:function(){this.bindCount+=1;var t=this.unit;if(t<0){for(var r=0;r0)continue;n.unit=-1}ce[r]=this,t=r;break}t>=fe&&Ae.raise("insufficient number of texture units"),o.profile&&i.maxTextureUnits>s)-i,c.height=c.height||(f.height>>s)-o,Ae(f.type===c.type&&f.format===c.format&&f.internalformat===c.internalformat,"incompatible format for texture.subimage"),Ae(i>=0&&o>=0&&i+c.width<=f.width&&o+c.height<=f.height,"texture.subimage write out of bounds"),Ae(f.mipmask&1<>u;++u)e.texImage2D(mt,u,f.format,n>>u,i>>u,0,f.format,f.type,null);return D(),o.profile&&(f.stats.size=q(f.internalformat,f.type,n,i,!1,!1)),a},a._reglType="texture2d",a._texture=f,o.profile&&(a.stats=f.stats),a.destroy=function(){f.decRef()},a},createCube:function(t,n,a,f,c,l){function m(e,t,n,a,i,f){var c,l=S.texInfo;for(k.call(l),c=0;c<6;++c)j[c]=x();if("number"!=typeof e&&e)if("object"==typeof e)if(t)v(j[0],e),v(j[1],t),v(j[2],n),v(j[3],a),v(j[4],i),v(j[5],f);else if(A(l,e),s(S,e),"faces"in e){var d=e.faces;for(Ae(Array.isArray(d)&&6===d.length,"cube faces must be a length 6 array"),c=0;c<6;++c)Ae("object"==typeof d[c]&&!!d[c],"invalid input for cube map face"),u(j[c],S),v(j[c],d[c])}else for(c=0;c<6;++c)v(j[c],e);else Ae.raise("invalid arguments to cube map");else{var p=0|e||1;for(c=0;c<6;++c)g(j[c],p,p)}for(u(S,j[0]),l.genMipmaps?S.mipmask=(j[0].width<<1)-1:S.mipmask=j[0].mipmask,Ae.textureCube(S,l,j,r),S.internalformat=j[0].internalformat,m.width=j[0].width,m.height=j[0].height,T(S),c=0;c<6;++c)y(j[c],ht+c);for(_(l,pt),D(),o.profile&&(S.stats.size=q(S.internalformat,S.type,m.width,m.height,l.genMipmaps,!0)),m.format=K[S.internalformat],m.type=J[S.type],m.mag=Z[l.magFilter],m.min=ee[l.minFilter],m.wrapS=te[l.wrapS],m.wrapT=te[l.wrapT],c=0;c<6;++c)w(j[c]);return m}var S=new E(pt);oe[S.id]=S,i.cubeCount++;var j=new Array(6);return m(t,n,a,f,c,l),m.subimage=function(e,t,r,n,a){Ae(!!t,"must specify image data"),Ae("number"==typeof e&&e===(0|e)&&e>=0&&e<6,"invalid face");var i=0|r,o=0|n,f=0|a,s=h();return u(s,S),s.width=0,s.height=0,d(s,t),s.width=s.width||(S.width>>f)-i,s.height=s.height||(S.height>>f)-o,Ae(S.type===s.type&&S.format===s.format&&S.internalformat===s.internalformat,"incompatible format for texture.subimage"),Ae(i>=0&&o>=0&&i+s.width<=S.width&&o+s.height<=S.height,"texture.subimage write out of bounds"),Ae(S.mipmask&1<>a;++a)e.texImage2D(ht+n,a,S.format,r>>a,r>>a,0,S.format,S.type,null);return D(),o.profile&&(S.stats.size=q(S.internalformat,S.type,m.width,m.height,!1,!0)),m}},m._reglType="textureCube",m._texture=S,o.profile&&(m.stats=S.stats),m.destroy=function(){S.decRef()},m},clear:function(){for(var t=0;t>r,t.height>>r,0,t.internalformat,t.type,null);else for(var n=0;n<6;++n)e.texImage2D(ht+n,r,t.internalformat,t.width>>r,t.height>>r,0,t.internalformat,t.type,null);_(t.texInfo,t.target)})}}}function V(e,t,r){return Cr[e]*t*r}function Y(){this.state=0,this.x=0,this.y=0,this.z=0,this.w=0,this.buffer=null,this.size=0,this.normalized=!1,this.type=Kr,this.offset=0,this.stride=0,this.divisor=0}function X(e,t,r,n){function a(e,t,r,n){this.name=e,this.id=t,this.location=r,this.info=n}function i(e,t){for(var r=0;r1)for(var h=0;he&&(e=t.stats.uniformsCount)}),e},r.getMaxAttributesCount=function(){var e=0;return l.forEach(function(t){t.stats.attributesCount>e&&(e=t.stats.attributesCount)}),e}),{clear:function(){var t=e.deleteShader.bind(e);Oe(u).forEach(t),u={},Oe(s).forEach(t),s={},l.forEach(function(t){e.deleteProgram(t.program)}),l.length=0,c={},r.shaderCount=0},program:function(e,t,a){Ae.command(e>=0,"missing vertex shader",a),Ae.command(t>=0,"missing fragment shader",a);var i=c[t];i||(i=c[t]={});var o=i[e];return o||(o=new function(e,t){this.id=d++,this.fragId=e,this.vertId=t,this.program=null,this.uniforms=[],this.attributes=[],n.profile&&(this.stats={uniformsCount:0,attributesCount:0})}(t,e),r.shaderCount++,f(o,a),i[e]=o,l.push(o)),o},restore:function(){u={},s={};for(var e=0;e=0&&u=0&&s0&&c+u<=n.framebufferWidth,"invalid width for read pixels"),Ae(l>0&&l+s<=n.framebufferHeight,"invalid height for read pixels"),r();var m=c*l*4;return d||(f===nn?d=new Uint8Array(m):f===on&&(d=d||new Float32Array(m))),Ae.isTypedArray(d,"data buffer for regl.read() must be a typedarray"),Ae(d.byteLength>=m,"data buffer for regl.read() too small"),e.pixelStorei(an,4),e.readPixels(u,s,c,l,rn,f,d),d}return function(e){return e&&"framebuffer"in e?function(e){var r;return t.setFBO({framebuffer:e.framebuffer},function(){r=o(e)}),r}(e):o(e)}}function K(e){return Array.prototype.slice.call(e)}function J(e){return K(e).join("")}function Z(e){return Array.isArray(e)||ue(e)||S(e)}function ee(e){return e.sort(function(e,t){return e===Gn?-1:t===Gn?1:e=1,n>=2,t)}if(r===hn){var a=e.data;return new te(a.thisDep,a.contextDep,a.propDep,t)}return new te(r===pn,r===mn,r===dn,t)}function ie(e,t,r,n,a,i,o,f,u,s,c,l,d,m,p){function h(e){return e.replace(".","_")}function b(e,t,r){var n=h(e);G.push(e),H[n]=W[n]=!!r,U[n]=t}function g(e,t,r){var n=h(e);G.push(e),Array.isArray(r)?(W[n]=r.slice(),H[n]=r.slice()):W[n]=H[n]=r,N[n]=t}function v(){var e=function(){function e(){var e=[],t=[];return se(function(){e.push.apply(e,K(arguments))},{def:function(){var n="v"+r++;return t.push(n),arguments.length>0&&(e.push(n,"="),e.push.apply(e,K(arguments)),e.push(";")),n},toString:function(){return J([t.length>0?"var "+t+";":"",J(e)])}})}function t(){function t(e,t){n(e,t,"=",r.def(e,t),";")}var r=e(),n=e(),a=r.toString,i=n.toString;return se(function(){r.apply(r,K(arguments))},{def:r.def,entry:r,exit:n,save:t,set:function(e,n,a){t(e,n),r(e,n,"=",a,";")},toString:function(){return a()+i()}})}var r=0,n=[],a=[],i=e(),o={};return{global:i,link:function(e){for(var t=0;t=0,'unknown parameter "'+e+'"',s.commandStr)})}var t=[Nn,qn,Qn,Vn,Yn,$n,Xn,Kn,Un].concat(G);e(d),e(m)});var p=function(e,t){var r=e.static,n=e.dynamic;if(Nn in r){var a=r[Nn];return a?(a=f.getFramebuffer(a),Ae.command(a,"invalid framebuffer object"),ne(function(e,t){var r=e.link(a),n=e.shared;t.set(n.framebuffer,".next",r);var i=n.context;return t.set(i,"."+Jn,r+".width"),t.set(i,"."+Zn,r+".height"),r})):ne(function(e,t){var r=e.shared;t.set(r.framebuffer,".next","null");var n=r.context;return t.set(n,"."+Jn,n+"."+ra),t.set(n,"."+Zn,n+"."+na),"null"})}if(Nn in n){var i=n[Nn];return ae(i,function(e,t){var r=e.invoke(t,i),n=e.shared,a=n.framebuffer,o=t.def(a,".getFramebuffer(",r,")");Ae.optional(function(){e.assert(t,"!"+r+"||"+o,"invalid framebuffer object")}),t.set(a,".next",o);var f=n.context;return t.set(f,"."+Jn,o+"?"+o+".width:"+f+"."+ra),t.set(f,"."+Zn,o+"?"+o+".height:"+f+"."+na),o})}return null}(e),b=function(e,t,r){function n(e){if(e in a){var n=a[e];Ae.commandType(n,"object","invalid "+e,r.commandStr);var o,f,u=!0,s=0|n.x,c=0|n.y;return"width"in n?(o=0|n.width,Ae.command(o>=0,"invalid "+e,r.commandStr)):u=!1,"height"in n?(f=0|n.height,Ae.command(f>=0,"invalid "+e,r.commandStr)):u=!1,new te(!u&&t&&t.thisDep,!u&&t&&t.contextDep,!u&&t&&t.propDep,function(e,t){var r=e.shared.context,a=o;"width"in n||(a=t.def(r,".",Jn,"-",s));var i=f;return"height"in n||(i=t.def(r,".",Zn,"-",c)),[s,c,a,i]})}if(e in i){var l=i[e],d=ae(l,function(t,r){var n=t.invoke(r,l);Ae.optional(function(){t.assert(r,n+"&&typeof "+n+'==="object"',"invalid "+e)});var a=t.shared.context,i=r.def(n,".x|0"),o=r.def(n,".y|0"),f=r.def('"width" in ',n,"?",n,".width|0:","(",a,".",Jn,"-",i,")"),u=r.def('"height" in ',n,"?",n,".height|0:","(",a,".",Zn,"-",o,")");return Ae.optional(function(){t.assert(r,f+">=0&&"+u+">=0","invalid "+e)}),[i,o,f,u]});return t&&(d.thisDep=d.thisDep||t.thisDep,d.contextDep=d.contextDep||t.contextDep,d.propDep=d.propDep||t.propDep),d}return t?new te(t.thisDep,t.contextDep,t.propDep,function(e,t){var r=e.shared.context;return[0,0,t.def(r,".",Jn),t.def(r,".",Zn)]}):null}var a=e.static,i=e.dynamic,o=n(Gn);if(o){var f=o;o=new te(o.thisDep,o.contextDep,o.propDep,function(e,t){var r=f.append(e,t),n=e.shared.context;return t.set(n,"."+ea,r[2]),t.set(n,"."+ta,r[3]),r})}return{viewport:o,scissor_box:n(Hn)}}(e,p,s),g=function(e,t){function r(e,r){if(e in n){var i=0|n[e];return Ae.command(!r||i>=0,"invalid "+e,t.commandStr),ne(function(e,t){return r&&(e.OFFSET=i),i})}if(e in a){var f=a[e];return ae(f,function(t,n){var a=t.invoke(n,f);return r&&(t.OFFSET=a,Ae.optional(function(){t.assert(n,a+">=0","invalid "+e)})),a})}return r&&o?ne(function(e,t){return e.OFFSET="0",0}):null}var n=e.static,a=e.dynamic,o=function(){if(Vn in n){var e=n[Vn];Z(e)?e=i.getElements(i.create(e,!0)):e&&(e=i.getElements(e),Ae.command(e,"invalid elements",t.commandStr));var r=ne(function(t,r){if(e){var n=t.link(e);return t.ELEMENTS=n,n}return t.ELEMENTS=null,null});return r.value=e,r}if(Vn in a){var o=a[Vn];return ae(o,function(e,t){var r=e.shared,n=r.isBufferArgs,a=r.elements,i=e.invoke(t,o),f=t.def("null"),u=t.def(n,"(",i,")"),s=e.cond(u).then(f,"=",a,".createStream(",i,");").else(f,"=",a,".getElements(",i,");");return Ae.optional(function(){e.assert(s.else,"!"+i+"||"+f,"invalid elements")}),t.entry(s),t.exit(e.cond(u).then(a,".destroyStream(",f,");")),e.ELEMENTS=f,f})}return null}(),f=r($n,!0);return{elements:o,primitive:function(){if(Yn in n){var e=n[Yn];return Ae.commandParameter(e,$e,"invalid primitve",t.commandStr),ne(function(t,r){return $e[e]})}if(Yn in a){var r=a[Yn];return ae(r,function(e,t){var n=e.constants.primTypes,a=e.invoke(t,r);return Ae.optional(function(){e.assert(t,a+" in "+n,"invalid primitive, must be one of "+Object.keys($e))}),t.def(n,"[",a,"]")})}return o?re(o)?o.value?ne(function(e,t){return t.def(e.ELEMENTS,".primType")}):ne(function(){return Pa}):new te(o.thisDep,o.contextDep,o.propDep,function(e,t){var r=e.ELEMENTS;return t.def(r,"?",r,".primType:",Pa)}):null}(),count:function(){if(Xn in n){var e=0|n[Xn];return Ae.command("number"==typeof e&&e>=0,"invalid vertex count",t.commandStr),ne(function(){return e})}if(Xn in a){var r=a[Xn];return ae(r,function(e,t){var n=e.invoke(t,r);return Ae.optional(function(){e.assert(t,"typeof "+n+'==="number"&&'+n+">=0&&"+n+"===("+n+"|0)","invalid vertex count")}),n})}if(o){if(re(o)){if(o)return f?new te(f.thisDep,f.contextDep,f.propDep,function(e,t){var r=t.def(e.ELEMENTS,".vertCount-",e.OFFSET);return Ae.optional(function(){e.assert(t,r+">=0","invalid vertex offset/element buffer too small")}),r}):ne(function(e,t){return t.def(e.ELEMENTS,".vertCount")});var i=ne(function(){return-1});return Ae.optional(function(){i.MISSING=!0}),i}var u=new te(o.thisDep||f.thisDep,o.contextDep||f.contextDep,o.propDep||f.propDep,function(e,t){var r=e.ELEMENTS;return e.OFFSET?t.def(r,"?",r,".vertCount-",e.OFFSET,":-1"):t.def(r,"?",r,".vertCount:-1")});return Ae.optional(function(){u.DYNAMIC=!0}),u}return null}(),instances:r(Kn,!1),offset:f}}(e,s),v=function(e,t){var r=e.static,a=e.dynamic,i={};return G.forEach(function(e){function o(t,n){if(e in r){var o=t(r[e]);i[f]=ne(function(){return o})}else if(e in a){var u=a[e];i[f]=ae(u,function(e,t){return n(e,t,e.invoke(t,u))})}}var f=h(e);switch(e){case En:case gn:case bn:case Pn:case wn:case Wn:case On:case Fn:case zn:case Sn:return o(function(r){return Ae.commandType(r,"boolean",e,t.commandStr),r},function(t,r,n){return Ae.optional(function(){t.assert(r,"typeof "+n+'==="boolean"',"invalid flag "+e,t.commandStr)}),n});case kn:return o(function(r){return Ae.commandParameter(r,Ja,"invalid "+e,t.commandStr),Ja[r]},function(t,r,n){var a=t.constants.compareFuncs;return Ae.optional(function(){t.assert(r,n+" in "+a,"invalid "+e+", must be one of "+Object.keys(Ja))}),r.def(a,"[",n,"]")});case An:return o(function(e){return Ae.command(P(e)&&2===e.length&&"number"==typeof e[0]&&"number"==typeof e[1]&&e[0]<=e[1],"depth range is 2d array",t.commandStr),e},function(e,t,r){return Ae.optional(function(){e.assert(t,e.shared.isArrayLike+"("+r+")&&"+r+".length===2&&typeof "+r+'[0]==="number"&&typeof '+r+'[1]==="number"&&'+r+"[0]<="+r+"[1]","depth range must be a 2d array")}),[t.def("+",r,"[0]"),t.def("+",r,"[1]")]});case xn:return o(function(e){Ae.commandType(e,"object","blend.func",t.commandStr);var r="srcRGB"in e?e.srcRGB:e.src,n="srcAlpha"in e?e.srcAlpha:e.src,a="dstRGB"in e?e.dstRGB:e.dst,i="dstAlpha"in e?e.dstAlpha:e.dst;return Ae.commandParameter(r,$a,f+".srcRGB",t.commandStr),Ae.commandParameter(n,$a,f+".srcAlpha",t.commandStr),Ae.commandParameter(a,$a,f+".dstRGB",t.commandStr),Ae.commandParameter(i,$a,f+".dstAlpha",t.commandStr),Ae.command(-1===Ka.indexOf(r+", "+a),"unallowed blending combination (srcRGB, dstRGB) = ("+r+", "+a+")",t.commandStr),[$a[r],$a[a],$a[n],$a[i]]},function(t,r,n){function a(a,o){var f=r.def('"',a,o,'" in ',n,"?",n,".",a,o,":",n,".",a);return Ae.optional(function(){t.assert(r,f+" in "+i,"invalid "+e+"."+a+o+", must be one of "+Object.keys($a))}),f}var i=t.constants.blendFuncs;Ae.optional(function(){t.assert(r,n+"&&typeof "+n+'==="object"',"invalid blend func, must be an object")});var o=a("src","RGB"),f=a("dst","RGB");Ae.optional(function(){var e=t.constants.invalidBlendCombinations;t.assert(r,e+".indexOf("+o+'+", "+'+f+") === -1 ","unallowed blending combination for (srcRGB, dstRGB)")});var u=r.def(i,"[",o,"]"),s=r.def(i,"[",a("src","Alpha"),"]");return[u,r.def(i,"[",f,"]"),s,r.def(i,"[",a("dst","Alpha"),"]")]});case yn:return o(function(r){return"string"==typeof r?(Ae.commandParameter(r,L,"invalid "+e,t.commandStr),[L[r],L[r]]):"object"==typeof r?(Ae.commandParameter(r.rgb,L,e+".rgb",t.commandStr),Ae.commandParameter(r.alpha,L,e+".alpha",t.commandStr),[L[r.rgb],L[r.alpha]]):void Ae.commandRaise("invalid blend.equation",t.commandStr)},function(t,r,n){var a=t.constants.blendEquations,i=r.def(),o=r.def(),f=t.cond("typeof ",n,'==="string"');return Ae.optional(function(){function r(e,r,n){t.assert(e,n+" in "+a,"invalid "+r+", must be one of "+Object.keys(L))}r(f.then,e,n),t.assert(f.else,n+"&&typeof "+n+'==="object"',"invalid "+e),r(f.else,e+".rgb",n+".rgb"),r(f.else,e+".alpha",n+".alpha")}),f.then(i,"=",o,"=",a,"[",n,"];"),f.else(i,"=",a,"[",n,".rgb];",o,"=",a,"[",n,".alpha];"),r(f),[i,o]});case vn:return o(function(e){return Ae.command(P(e)&&4===e.length,"blend.color must be a 4d array",t.commandStr),_(4,function(t){return+e[t]})},function(e,t,r){return Ae.optional(function(){e.assert(t,e.shared.isArrayLike+"("+r+")&&"+r+".length===4","blend.color must be a 4d array")}),_(4,function(e){return t.def("+",r,"[",e,"]")})});case Rn:return o(function(e){return Ae.commandType(e,"number",f,t.commandStr),0|e},function(e,t,r){return Ae.optional(function(){e.assert(t,"typeof "+r+'==="number"',"invalid stencil.mask")}),t.def(r,"|0")});case Ln:return o(function(r){Ae.commandType(r,"object",f,t.commandStr);var n=r.cmp||"keep",a=r.ref||0,i="mask"in r?r.mask:-1;return Ae.commandParameter(n,Ja,e+".cmp",t.commandStr),Ae.commandType(a,"number",e+".ref",t.commandStr),Ae.commandType(i,"number",e+".mask",t.commandStr),[Ja[n],a,i]},function(e,t,r){var n=e.constants.compareFuncs;return Ae.optional(function(){function a(){e.assert(t,Array.prototype.join.call(arguments,""),"invalid stencil.func")}a(r+"&&typeof ",r,'==="object"'),a('!("cmp" in ',r,")||(",r,".cmp in ",n,")")}),[t.def('"cmp" in ',r,"?",n,"[",r,".cmp]",":",Ua),t.def(r,".ref|0"),t.def('"mask" in ',r,"?",r,".mask|0:-1")]});case In:case Mn:return o(function(r){Ae.commandType(r,"object",f,t.commandStr);var n=r.fail||"keep",a=r.zfail||"keep",i=r.zpass||"keep";return Ae.commandParameter(n,Za,e+".fail",t.commandStr),Ae.commandParameter(a,Za,e+".zfail",t.commandStr),Ae.commandParameter(i,Za,e+".zpass",t.commandStr),[e===Mn?La:Ra,Za[n],Za[a],Za[i]]},function(t,r,n){function a(a){return Ae.optional(function(){t.assert(r,'!("'+a+'" in '+n+")||("+n+"."+a+" in "+i+")","invalid "+e+"."+a+", must be one of "+Object.keys(Za))}),r.def('"',a,'" in ',n,"?",i,"[",n,".",a,"]:",Ua)}var i=t.constants.stencilOps;return Ae.optional(function(){t.assert(r,n+"&&typeof "+n+'==="object"',"invalid "+e)}),[e===Mn?La:Ra,a("fail"),a("zfail"),a("zpass")]});case Cn:return o(function(e){Ae.commandType(e,"object",f,t.commandStr);var r=0|e.factor,n=0|e.units;return Ae.commandType(r,"number",f+".factor",t.commandStr),Ae.commandType(n,"number",f+".units",t.commandStr),[r,n]},function(t,r,n){return Ae.optional(function(){t.assert(r,n+"&&typeof "+n+'==="object"',"invalid "+e)}),[r.def(n,".factor|0"),r.def(n,".units|0")]});case Tn:return o(function(e){var r=0;return"front"===e?r=Ra:"back"===e&&(r=La),Ae.command(!!r,f,t.commandStr),r},function(e,t,r){return Ae.optional(function(){e.assert(t,r+'==="front"||'+r+'==="back"',"invalid cull.face")}),t.def(r,'==="front"?',Ra,":",La)});case jn:return o(function(e){return Ae.command("number"==typeof e&&e>=n.lineWidthDims[0]&&e<=n.lineWidthDims[1],"invalid line width, must positive number between "+n.lineWidthDims[0]+" and "+n.lineWidthDims[1],t.commandStr),e},function(e,t,r){return Ae.optional(function(){e.assert(t,"typeof "+r+'==="number"&&'+r+">="+n.lineWidthDims[0]+"&&"+r+"<="+n.lineWidthDims[1],"invalid line width")}),r});case Dn:return o(function(e){return Ae.commandParameter(e,ti,f,t.commandStr),ti[e]},function(e,t,r){return Ae.optional(function(){e.assert(t,r+'==="cw"||'+r+'==="ccw"',"invalid frontFace, must be one of cw,ccw")}),t.def(r+'==="cw"?'+Ia+":"+Ma)});case _n:return o(function(e){return Ae.command(P(e)&&4===e.length,"color.mask must be length 4 array",t.commandStr),e.map(function(e){return!!e})},function(e,t,r){return Ae.optional(function(){e.assert(t,e.shared.isArrayLike+"("+r+")&&"+r+".length===4","invalid color.mask")}),_(4,function(e){return"!!"+r+"["+e+"]"})});case Bn:return o(function(e){Ae.command("object"==typeof e&&e,f,t.commandStr);var r="value"in e?e.value:1,n=!!e.invert;return Ae.command("number"==typeof r&&r>=0&&r<=1,"sample.coverage.value must be a number between 0 and 1",t.commandStr),[r,n]},function(e,t,r){return Ae.optional(function(){e.assert(t,r+"&&typeof "+r+'==="object"',"invalid sample.coverage")}),[t.def('"value" in ',r,"?+",r,".value:1"),t.def("!!",r,".invert")]})}}),i}(e,s),y=function(e){function r(e){if(e in a){var r=t.id(a[e]);Ae.optional(function(){c.shader(ei[e],r,Ae.guessCommand())});var n=ne(function(){return r});return n.id=r,n}if(e in i){var o=i[e];return ae(o,function(t,r){var n=t.invoke(r,o),a=r.def(t.shared.strings,".id(",n,")");return Ae.optional(function(){r(t.shared.shader,".shader(",ei[e],",",a,",",t.command,");")}),a})}return null}var n,a=e.static,i=e.dynamic,o=r(Qn),f=r(qn),u=null;return re(o)&&re(f)?(u=c.program(f.id,o.id),n=ne(function(e,t){return e.link(u)})):n=new te(o&&o.thisDep||f&&f.thisDep,o&&o.contextDep||f&&f.contextDep,o&&o.propDep||f&&f.propDep,function(e,t){var r,n=e.shared.shader;r=o?o.append(e,t):t.def(n,".",Qn);var a=n+".program("+(f?f.append(e,t):t.def(n,".",qn))+","+r;return Ae.optional(function(){a+=","+e.command}),t.def(a+")")}),{frag:o,vert:f,progVar:n,program:u}}(e);l(Gn),l(h(Hn));var x=Object.keys(v).length>0,w={framebuffer:p,draw:g,shader:y,state:v,dirty:x};return w.profile=function(e){var t,r=e.static,n=e.dynamic;if(Un in r){var a=!!r[Un];(t=ne(function(e,t){return a})).enable=a}else if(Un in n){var i=n[Un];t=ae(i,function(e,t){return e.invoke(t,i)})}return t}(e),w.uniforms=function(e,t){var r=e.static,n=e.dynamic,a={};return Object.keys(r).forEach(function(e){var n,i=r[e];if("number"==typeof i||"boolean"==typeof i)n=ne(function(){return i});else if("function"==typeof i){var o=i._reglType;"texture2d"===o||"textureCube"===o?n=ne(function(e){return e.link(i)}):"framebuffer"===o||"framebufferCube"===o?(Ae.command(i.color.length>0,'missing color attachment for framebuffer sent to uniform "'+e+'"',t.commandStr),n=ne(function(e){return e.link(i.color[0])})):Ae.commandRaise('invalid data for uniform "'+e+'"',t.commandStr)}else P(i)?n=ne(function(t){return t.global.def("[",_(i.length,function(r){return Ae.command("number"==typeof i[r]||"boolean"==typeof i[r],"invalid uniform "+e,t.commandStr),i[r]}),"]")}):Ae.commandRaise('invalid or missing data for uniform "'+e+'"',t.commandStr);n.value=i,a[e]=n}),Object.keys(n).forEach(function(e){var t=n[e];a[e]=ae(t,function(e,r){return e.invoke(r,t)})}),a}(o,s),w.attributes=function(e,r){var n=e.static,i=e.dynamic,o={};return Object.keys(n).forEach(function(e){var i=n[e],f=t.id(e),u=new R;if(Z(i))u.state=sn,u.buffer=a.getBuffer(a.create(i,ia,!1,!0)),u.type=0;else{var s=a.getBuffer(i);if(s)u.state=sn,u.buffer=s,u.type=0;else if(Ae.command("object"==typeof i&&i,"invalid data for attribute "+e,r.commandStr),i.constant){var c=i.constant;u.buffer="null",u.state=cn,"number"==typeof c?u.x=c:(Ae.command(P(c)&&c.length>0&&c.length<=4,"invalid constant for attribute "+e,r.commandStr),fn.forEach(function(e,t){t=0,'invalid offset for attribute "'+e+'"',r.commandStr);var d=0|i.stride;Ae.command(d>=0&&d<256,'invalid stride for attribute "'+e+'", must be integer betweeen [0, 255]',r.commandStr);var m=0|i.size;Ae.command(!("size"in i)||m>0&&m<=4,'invalid size for attribute "'+e+'", must be 1,2,3,4',r.commandStr);var p=!!i.normalized,h=0;"type"in i&&(Ae.commandParameter(i.type,He,"invalid type for attribute "+e,r.commandStr),h=He[i.type]);var b=0|i.divisor;"divisor"in i&&(Ae.command(0===b||I,'cannot specify divisor for attribute "'+e+'", instancing not supported',r.commandStr),Ae.command(b>=0,'invalid divisor for attribute "'+e+'"',r.commandStr)),Ae.optional(function(){var t=r.commandStr,n=["buffer","offset","divisor","normalized","type","size","stride"];Object.keys(i).forEach(function(r){Ae.command(n.indexOf(r)>=0,'unknown parameter "'+r+'" for attribute pointer "'+e+'" (valid parameters are '+n+")",t)})}),u.buffer=s,u.state=sn,u.size=m,u.normalized=p,u.type=h||s.dtype,u.offset=l,u.stride=d,u.divisor=b}}o[e]=ne(function(e,t){var r=e.attribCache;if(f in r)return r[f];var n={isStream:!1};return Object.keys(u).forEach(function(e){n[e]=u[e]}),u.buffer&&(n.buffer=e.link(u.buffer),n.type=n.type||n.buffer+".dtype"),r[f]=n,n})}),Object.keys(i).forEach(function(e){var t=i[e];o[e]=ae(t,function(r,n){function a(e){n(s[e],"=",i,".",e,"|0;")}var i=r.invoke(n,t),o=r.shared,f=o.isBufferArgs,u=o.buffer;Ae.optional(function(){r.assert(n,i+"&&(typeof "+i+'==="object"||typeof '+i+'==="function")&&('+f+"("+i+")||"+u+".getBuffer("+i+")||"+u+".getBuffer("+i+".buffer)||"+f+"("+i+'.buffer)||("constant" in '+i+"&&(typeof "+i+'.constant==="number"||'+o.isArrayLike+"("+i+".constant))))",'invalid dynamic attribute "'+e+'"')});var s={isStream:n.def(!1)},c=new R;c.state=sn,Object.keys(c).forEach(function(e){s[e]=n.def(""+c[e])});var l=s.buffer,d=s.type;return n("if(",f,"(",i,")){",s.isStream,"=true;",l,"=",u,".createStream(",ia,",",i,");",d,"=",l,".dtype;","}else{",l,"=",u,".getBuffer(",i,");","if(",l,"){",d,"=",l,".dtype;",'}else if("constant" in ',i,"){",s.state,"=",cn,";","if(typeof "+i+'.constant === "number"){',s[fn[0]],"=",i,".constant;",fn.slice(1).map(function(e){return s[e]}).join("="),"=0;","}else{",fn.map(function(e,t){return s[e]+"="+i+".constant.length>="+t+"?"+i+".constant["+t+"]:0;"}).join(""),"}}else{","if(",f,"(",i,".buffer)){",l,"=",u,".createStream(",ia,",",i,".buffer);","}else{",l,"=",u,".getBuffer(",i,".buffer);","}",d,'="type" in ',i,"?",o.glTypes,"[",i,".type]:",l,".dtype;",s.normalized,"=!!",i,".normalized;"),a("size"),a("offset"),a("stride"),a("divisor"),n("}}"),n.exit("if(",s.isStream,"){",u,".destroyStream(",l,");","}"),s})}),o}(r,s),w.context=function(e){var t=e.static,r=e.dynamic,n={};return Object.keys(t).forEach(function(e){var r=t[e];n[e]=ne(function(e,t){return"number"==typeof r||"boolean"==typeof r?""+r:e.link(r)})}),Object.keys(r).forEach(function(e){var t=r[e];n[e]=ae(t,function(e,r){return e.invoke(r,t)})}),n}(u),w}function x(e,t,r){var n=e.shared.context,a=e.scope();Object.keys(r).forEach(function(i){t.save(n,"."+i);var o=r[i];a(n,".",i,"=",o.append(e,t),";")}),t(a)}function w(e,t,r,n){var a,i=e.shared,o=i.gl,f=i.framebuffer;M&&(a=t.def(i.extensions,".webgl_draw_buffers"));var u,s=e.constants,c=s.drawBuffer,l=s.backBuffer;u=r?r.append(e,t):t.def(f,".next"),n||t("if(",u,"!==",f,".cur){"),t("if(",u,"){",o,".bindFramebuffer(",Ya,",",u,".framebuffer);"),M&&t(a,".drawBuffersWEBGL(",c,"[",u,".colorAttachments.length]);"),t("}else{",o,".bindFramebuffer(",Ya,",null);"),M&&t(a,".drawBuffersWEBGL(",l,");"),t("}",f,".cur=",u,";"),n||t("}")}function k(e,t,r){var n=e.shared,a=n.gl,i=e.current,o=e.next,f=n.current,u=n.next,s=e.cond(f,".dirty");G.forEach(function(t){var n=h(t);if(!(n in r.state)){var c,l;if(n in o){c=o[n],l=i[n];var d=_(W[n].length,function(e){return s.def(c,"[",e,"]")});s(e.cond(d.map(function(e,t){return e+"!=="+l+"["+t+"]"}).join("||")).then(a,".",N[n],"(",d,");",d.map(function(e,t){return l+"["+t+"]="+e}).join(";"),";"))}else{c=s.def(u,".",n);var m=e.cond(c,"!==",f,".",n);s(m),n in U?m(e.cond(c).then(a,".enable(",U[n],");").else(a,".disable(",U[n],");"),f,".",n,"=",c,";"):m(a,".",N[n],"(",c,");",f,".",n,"=",c,";")}}}),0===Object.keys(r.state).length&&s(f,".dirty=false;"),t(s)}function A(e,t,r,n){var a=e.shared,i=e.current,o=a.current,f=a.gl;ee(Object.keys(r)).forEach(function(a){var u=r[a];if(!n||n(u)){var s=u.append(e,t);if(U[a]){var c=U[a];re(u)?t(f,s?".enable(":".disable(",c,");"):t(e.cond(s).then(f,".enable(",c,");").else(f,".disable(",c,");")),t(o,".",a,"=",s,";")}else if(P(s)){var l=i[a];t(f,".",N[a],"(",s,");",s.map(function(e,t){return l+"["+t+"]="+e}).join(";"),";")}else t(f,".",N[a],"(",s,");",o,".",a,"=",s,";")}})}function S(e,t){I&&(e.instancing=t.def(e.shared.extensions,".angle_instanced_arrays"))}function E(e,t,r,n,a){function i(){return"undefined"==typeof performance?"Date.now()":"performance.now()"}function o(e){e(s=t.def(),"=",i(),";"),"string"==typeof a?e(p,".count+=",a,";"):e(p,".count++;"),m&&(n?e(c=t.def(),"=",b,".getNumPendingQueries();"):e(b,".beginQuery(",p,");"))}function f(e){e(p,".cpuTime+=",i(),"-",s,";"),m&&(n?e(b,".pushScopeStats(",c,",",b,".getNumPendingQueries(),",p,");"):e(b,".endQuery();"))}function u(e){var r=t.def(h,".profile");t(h,".profile=",e,";"),t.exit(h,".profile=",r,";")}var s,c,l,d=e.shared,p=e.stats,h=d.current,b=d.timer,g=r.profile;if(g){if(re(g))return void(g.enable?(o(t),f(t.exit),u("true")):u("false"));u(l=g.append(e,t))}else l=t.def(h,".profile");var v=e.block();o(v),t("if(",l,"){",v,"}");var y=e.block();f(y),t.exit("if(",l,"){",y,"}")}function T(e,t,r,n,a){var i=e.shared;n.forEach(function(n){var o,f=n.name,u=r.attributes[f];if(u){if(!a(u))return;o=u.append(e,t)}else{if(!a(ri))return;var s=e.scopeAttrib(f);Ae.optional(function(){e.assert(t,s+".state","missing attribute "+f)}),o={},Object.keys(new R).forEach(function(e){o[e]=t.def(s,".",e)})}!function(r,n,a){function o(){t("if(!",c,".buffer){",u,".enableVertexAttribArray(",s,");}");var r,i=a.type;if(r=a.size?t.def(a.size,"||",n):n,t("if(",c,".type!==",i,"||",c,".size!==",r,"||",p.map(function(e){return c+"."+e+"!=="+a[e]}).join("||"),"){",u,".bindBuffer(",ia,",",d,".buffer);",u,".vertexAttribPointer(",[s,r,i,a.normalized,a.stride,a.offset],");",c,".type=",i,";",c,".size=",r,";",p.map(function(e){return c+"."+e+"="+a[e]+";"}).join(""),"}"),I){var o=a.divisor;t("if(",c,".divisor!==",o,"){",e.instancing,".vertexAttribDivisorANGLE(",[s,o],");",c,".divisor=",o,";}")}}function f(){t("if(",c,".buffer){",u,".disableVertexAttribArray(",s,");","}if(",fn.map(function(e,t){return c+"."+e+"!=="+m[t]}).join("||"),"){",u,".vertexAttrib4f(",s,",",m,");",fn.map(function(e,t){return c+"."+e+"="+m[t]+";"}).join(""),"}")}var u=i.gl,s=t.def(r,".location"),c=t.def(i.attributes,"[",s,"]"),l=a.state,d=a.buffer,m=[a.x,a.y,a.z,a.w],p=["buffer","normalized","offset","stride"];l===sn?o():l===cn?f():(t("if(",l,"===",sn,"){"),o(),t("}else{"),f(),t("}"))}(e.link(n),function(e){switch(e){case ya:case Aa:case Ta:return 2;case xa:case Sa:case Da:return 3;case wa:case _a:case ja:return 4;default:return 1}}(n.info.type),o)})}function D(e,r,n,a,i){for(var o,f=e.shared,u=f.gl,s=0;s1?_(x,function(e){return c+"["+e+"]"}):c);r(");")}}function j(e,t,r,n){function a(a){var i=c[a];return i?i.contextDep&&n.contextDynamic||i.propDep?i.append(e,r):i.append(e,t):t.def(s,".",a)}function i(){function e(){r(b,".drawElementsInstancedANGLE(",[d,p,g,m+"<<(("+g+"-"+un+")>>1)",h],");")}function t(){r(b,".drawArraysInstancedANGLE(",[d,m,p,h],");")}l?v?e():(r("if(",l,"){"),e(),r("}else{"),t(),r("}")):t()}function o(){function e(){r(u+".drawElements("+[d,p,g,m+"<<(("+g+"-"+un+")>>1)"]+");")}function t(){r(u+".drawArrays("+[d,m,p]+");")}l?v?e():(r("if(",l,"){"),e(),r("}else{"),t(),r("}")):t()}var f=e.shared,u=f.gl,s=f.draw,c=n.draw,l=function(){var a,i=c.elements,o=t;return i?((i.contextDep&&n.contextDynamic||i.propDep)&&(o=r),a=i.append(e,o)):a=o.def(s,".",Vn),a&&o("if("+a+")"+u+".bindBuffer("+oa+","+a+".buffer.buffer);"),a}(),d=a(Yn),m=a($n),p=function(){var a,i=c.count,o=t;return i?((i.contextDep&&n.contextDynamic||i.propDep)&&(o=r),a=i.append(e,o),Ae.optional(function(){i.MISSING&&e.assert(t,"false","missing vertex count"),i.DYNAMIC&&e.assert(o,a+">=0","missing vertex count")})):(a=o.def(s,".",Xn),Ae.optional(function(){e.assert(o,a+">=0","missing vertex count")})),a}();if("number"==typeof p){if(0===p)return}else r("if(",p,"){"),r.exit("}");var h,b;I&&(h=a(Kn),b=e.instancing);var g=l+".type",v=c.elements&&re(c.elements);I&&("number"!=typeof h||h>=0)?"string"==typeof h?(r("if(",h,">0){"),i(),r("}else if(",h,"<0){"),o(),r("}")):i():o()}function O(e,t,r,n,a){var i=v(),o=i.proc("body",a);return Ae.optional(function(){i.commandStr=t.commandStr,i.command=i.link(t.commandStr)}),I&&(i.instancing=o.def(i.shared.extensions,".angle_instanced_arrays")),e(i,o,r,n),i.compile().body}function C(e,t,r,n){S(e,t),T(e,t,r,n.attributes,function(){return!0}),D(e,t,r,n.uniforms,function(){return!0}),j(e,t,t,r)}function F(e,t,r,n){function a(){return!0}e.batchId="a1",S(e,t),T(e,t,r,n.attributes,a),D(e,t,r,n.uniforms,a),j(e,t,t,r)}function z(e,t,r,n){function a(e){return e.contextDep&&o||e.propDep}function i(e){return!a(e)}S(e,t);var o=r.contextDep,f=t.def(),u=t.def();e.shared.props=u,e.batchId=f;var s=e.scope(),c=e.scope();if(t(s.entry,"for(",f,"=0;",f,"<","a1",";++",f,"){",u,"=","a0","[",f,"];",c,"}",s.exit),r.needsContext&&x(e,c,r.context),r.needsFramebuffer&&w(e,c,r.framebuffer),A(e,c,r.state,a),r.profile&&a(r.profile)&&E(e,c,r,!1,!0),n)T(e,s,r,n.attributes,i),T(e,c,r,n.attributes,a),D(e,s,r,n.uniforms,i),D(e,c,r,n.uniforms,a),j(e,s,c,r);else{var l=e.global.def("{}"),d=r.shader.progVar.append(e,c),m=c.def(d,".id"),p=c.def(l,"[",m,"]");c(e.shared.gl,".useProgram(",d,".program);","if(!",p,"){",p,"=",l,"[",m,"]=",e.link(function(t){return O(F,e,r,t,2)}),"(",d,");}",p,".call(this,a0[",f,"],",f,");")}}function B(e,t,r){var n=t.static[r];if(n&&function(e){if("object"==typeof e&&!P(e)){for(var t=Object.keys(e),r=0;r0&&r(e.shared.current,".dirty=true;")}(o,f),function(e,r){function n(t){var n=r.shader[t];n&&a.set(i.shader,"."+t,n.append(e,a))}var a=e.proc("scope",3);e.batchId="a2";var i=e.shared,o=i.current;x(e,a,r.context),r.framebuffer&&r.framebuffer.append(e,a),ee(Object.keys(r.state)).forEach(function(t){var n=r.state[t].append(e,a);P(n)?n.forEach(function(r,n){a.set(e.next[t],"["+n+"]",r)}):a.set(i.next,"."+t,n)}),E(e,a,r,!0,!0),[Vn,$n,Xn,Kn,Yn].forEach(function(t){var n=r.draw[t];n&&a.set(i.draw,"."+t,""+n.append(e,a))}),Object.keys(r.uniforms).forEach(function(n){a.set(i.uniforms,"["+t.id(n)+"]",r.uniforms[n].append(e,a))}),Object.keys(r.attributes).forEach(function(t){var n=r.attributes[t].append(e,a),i=e.scopeAttrib(t);Object.keys(new R).forEach(function(e){a.set(i,"."+e,n[e])})}),n(qn),n(Qn),Object.keys(r.state).length>0&&(a(o,".dirty=true;"),a.exit(o,".dirty=true;")),a("a1(",e.shared.context,",a0,",e.batchId,");")}(o,f),function(e,t){function r(e){return e.contextDep&&a||e.propDep}var n=e.proc("batch",2);e.batchId="0",S(e,n);var a=!1,i=!0;Object.keys(t.context).forEach(function(e){a=a||t.context[e].propDep}),a||(x(e,n,t.context),i=!1);var o=t.framebuffer,f=!1;o?(o.propDep?a=f=!0:o.contextDep&&a&&(f=!0),f||w(e,n,o)):w(e,n,null),t.state.viewport&&t.state.viewport.propDep&&(a=!0),k(e,n,t),A(e,n,t.state,function(e){return!r(e)}),t.profile&&r(t.profile)||E(e,n,t,!1,"a1"),t.contextDep=a,t.needsContext=i,t.needsFramebuffer=f;var u=t.shader.progVar;if(u.contextDep&&a||u.propDep)z(e,n,t,null);else{var s=u.append(e,n);if(n(e.shared.gl,".useProgram(",s,".program);"),t.shader.program)z(e,n,t,t.shader.program);else{var c=e.global.def("{}"),l=n.def(s,".id"),d=n.def(c,"[",l,"]");n(e.cond(d).then(d,".call(this,a0,a1);").else(d,"=",c,"[",l,"]=",e.link(function(r){return O(z,e,t,r,2)}),"(",s,");",d,".call(this,a0,a1);"))}}Object.keys(t.state).length>0&&n(e.shared.current,".dirty=true;")}(o,f),o.compile()}}}function oe(e,t){for(var r=0;r=0&&(0|e)===e||t("invalid parameter type, ("+e+")"+n(r)+". must be a nonnegative integer")},oneOf:a,shaderError:function(e,t,n,a,o){if(!e.getShaderParameter(t,e.COMPILE_STATUS)){var f=e.getShaderInfoLog(t),s=a===e.FRAGMENT_SHADER?"fragment":"vertex";p(n,"string",s+" shader source must be a string",o);var c=l(n,o),d=function(e){var t=[];return e.split("\n").forEach(function(e){if(!(e.length<5)){var r=/^ERROR\:\s+(\d+)\:(\d+)\:\s*(.*)$/.exec(e);r?t.push(new u(0|r[1],0|r[2],r[3].trim())):e.length>0&&t.push(new u("unknown",0,e))}}),t}(f);!function(e,t){t.forEach(function(t){var r=e[t.file];if(r){var n=r.index[t.line];if(n)return n.errors.push(t),void(r.hasErrors=!0)}e.unknown.hasErrors=!0,e.unknown.lines[0].errors.push(t)})}(c,d),Object.keys(c).forEach(function(e){function t(e,t){n.push(e),a.push(t||"")}var r=c[e];if(r.hasErrors){var n=[""],a=[""];t("file number "+e+": "+r.name+"\n","color:red;text-decoration:underline;font-weight:bold"),r.lines.forEach(function(e){if(e.errors.length>0){t(i(e.number,4)+"| ","background-color:yellow; font-weight:bold"),t(e.line+"\n","color:red; background-color:yellow; font-weight:bold");var r=0;e.errors.forEach(function(n){var a=n.message,o=/^\s*\'(.*)\'\s*\:\s*(.*)$/.exec(a);if(o){var f=o[1];switch(a=o[2],f){case"assign":f="="}r=Math.max(e.line.indexOf(f,r),0)}else r=0;t(i("| ",6)),t(i("^^^",r+3)+"\n","font-weight:bold"),t(i("| ",6)),t(a+"\n","font-weight:bold")}),t(i("| ",6)+"\n")}else t(i(e.number,4)+"| "),t(e.line+"\n","color:red")}),"undefined"!=typeof document&&(a[0]=n.join("%c"))}}),r.raise("Error compiling "+s+" shader, "+c[0].name)}},linkError:function(e,t,n,a,i){if(!e.getProgramParameter(t,e.LINK_STATUS)){e.getProgramInfoLog(t);var o=l(n,i),f='Error linking program with vertex shader, "'+l(a,i)[0].name+'", and fragment shader "'+o[0].name+'"';r.raise(f)}},callSite:c,saveCommandRef:d,saveDrawInfo:function(e,t,r,n){function a(e){return e?n.id(e):0}function i(e,t){Object.keys(t).forEach(function(t){e[n.id(t)]=!0})}d(e),e._fragId=a(e.static.frag),e._vertId=a(e.static.vert);var o=e._uniformSet={};i(o,t.static),i(o,t.dynamic);var f=e._attributeSet={};i(f,r.static),i(f,r.dynamic),e._hasCount="count"in e.static||"count"in e.dynamic||"elements"in e.static||"elements"in e.dynamic},framebufferFormat:function(e,t,r){e.texture?a(e.texture._texture.internalformat,t,"unsupported texture format for attachment"):a(e.renderbuffer._renderbuffer.format,r,"unsupported renderbuffer format for attachment")},guessCommand:s,texture2D:function(e,t,n){var a,i=t.width,o=t.height,f=t.channels;r(i>0&&i<=n.maxTextureSize&&o>0&&o<=n.maxTextureSize,"invalid texture shape"),e.wrapS===le&&e.wrapT===le||r(b(i)&&b(o),"incompatible wrap mode for texture, both width and height must be power of 2"),1===t.mipmask?1!==i&&1!==o&&r(e.minFilter!==me&&e.minFilter!==he&&e.minFilter!==pe&&e.minFilter!==be,"min filter requires mipmap"):(r(b(i)&&b(o),"texture must be a square power of 2 to support mipmapping"),r(t.mipmask===(i<<1)-1,"missing or incomplete mipmap data")),t.type===ge&&(n.extensions.indexOf("oes_texture_float_linear")<0&&r(e.minFilter===de&&e.magFilter===de,"filter not supported, must enable oes_texture_float_linear"),r(!e.genMipmaps,"mipmap generation not supported with float textures"));var u=t.images;for(a=0;a<16;++a)if(u[a]){var s=i>>a,c=o>>a;r(t.mipmask&1<0&&i<=a.maxTextureSize&&o>0&&o<=a.maxTextureSize,"invalid texture shape"),r(i===o,"cube map must be square"),r(t.wrapS===le&&t.wrapT===le,"wrap mode not supported by cube map");for(var u=0;u>l,p=o>>l;r(s.mipmask&1<=2,"invalid renderbuffer shape"),i=0|m[0],o=0|m[1]}else"radius"in d&&(i=o=0|d.radius),"width"in d&&(i=0|d.width),"height"in d&&(o=0|d.height);"format"in d&&(Ae.parameter(d.format,f,"invalid renderbuffer format"),c=f[d.format])}else"number"==typeof t?(i=0|t,o="number"==typeof n?0|n:i):t?Ae.raise("invalid arguments to renderbuffer constructor"):i=o=1;if(Ae(i>0&&o>0&&i<=r.maxRenderbufferSize&&o<=r.maxRenderbufferSize,"invalid renderbuffer size"),i!==l.width||o!==l.height||c!==l.format)return s.width=l.width=i,s.height=l.height=o,l.format=c,e.bindRenderbuffer(jr,l.renderbuffer),e.renderbufferStorage(jr,c,i,o),a.profile&&(l.stats.size=V(l.format,l.width,l.height)),s.format=u[l.format],s}var l=new i(e.createRenderbuffer());return c[l.id]=l,n.renderbufferCount++,s(t,o),s.resize=function(t,n){var i=0|t,o=0|n||i;return i===l.width&&o===l.height?s:(Ae(i>0&&o>0&&i<=r.maxRenderbufferSize&&o<=r.maxRenderbufferSize,"invalid renderbuffer size"),s.width=l.width=i,s.height=l.height=o,e.bindRenderbuffer(jr,l.renderbuffer),e.renderbufferStorage(jr,l.format,i,o),a.profile&&(l.stats.size=V(l.format,l.width,l.height)),s)},s._reglType="renderbuffer",s._renderbuffer=l,a.profile&&(s.stats=l.stats),s.destroy=function(){l.decRef()},s},clear:function(){Oe(c).forEach(o)},restore:function(){Oe(c).forEach(function(t){t.renderbuffer=e.createRenderbuffer(),e.bindRenderbuffer(jr,t.renderbuffer),e.renderbufferStorage(jr,t.format,t.width,t.height)}),e.bindRenderbuffer(jr,null)}}},zr=36160,Br=36161,Pr=3553,Rr=34069,Lr=36064,Ir=36096,Mr=36128,Wr=33306,Hr=36053,Gr=6402,Ur=[6408],Nr=[];Nr[6408]=4;var qr=[];qr[5121]=1,qr[5126]=4,qr[36193]=2;var Qr=33189,Vr=36168,Yr=34041,Xr=[32854,32855,36194,35907,34842,34843,34836],$r={};$r[Hr]="complete",$r[36054]="incomplete attachment",$r[36057]="incomplete dimensions",$r[36055]="incomplete, missing attachment",$r[36061]="unsupported";var Kr=5126,Jr=35632,Zr=35633,en=35718,tn=35721,rn=6408,nn=5121,an=3333,on=5126,fn="xyzw".split(""),un=5121,sn=1,cn=2,ln=0,dn=1,mn=2,pn=3,hn=4,bn="dither",gn="blend.enable",vn="blend.color",yn="blend.equation",xn="blend.func",wn="depth.enable",kn="depth.func",An="depth.range",Sn="depth.mask",_n="colorMask",En="cull.enable",Tn="cull.face",Dn="frontFace",jn="lineWidth",On="polygonOffset.enable",Cn="polygonOffset.offset",Fn="sample.alpha",zn="sample.enable",Bn="sample.coverage",Pn="stencil.enable",Rn="stencil.mask",Ln="stencil.func",In="stencil.opFront",Mn="stencil.opBack",Wn="scissor.enable",Hn="scissor.box",Gn="viewport",Un="profile",Nn="framebuffer",qn="vert",Qn="frag",Vn="elements",Yn="primitive",Xn="count",$n="offset",Kn="instances",Jn=Nn+"Width",Zn=Nn+"Height",ea=Gn+"Width",ta=Gn+"Height",ra="drawingBufferWidth",na="drawingBufferHeight",aa=[xn,yn,Ln,In,Mn,Bn,Gn,Hn,Cn],ia=34962,oa=34963,fa=3553,ua=34067,sa=2884,ca=3042,la=3024,da=2960,ma=2929,pa=3089,ha=32823,ba=32926,ga=32928,va=5126,ya=35664,xa=35665,wa=35666,ka=5124,Aa=35667,Sa=35668,_a=35669,Ea=35670,Ta=35671,Da=35672,ja=35673,Oa=35674,Ca=35675,Fa=35676,za=35678,Ba=35680,Pa=4,Ra=1028,La=1029,Ia=2304,Ma=2305,Wa=32775,Ha=32776,Ga=519,Ua=7680,Na=0,qa=1,Qa=32774,Va=513,Ya=36160,Xa=36064,$a={0:0,1:1,zero:0,one:1,"src color":768,"one minus src color":769,"src alpha":770,"one minus src alpha":771,"dst color":774,"one minus dst color":775,"dst alpha":772,"one minus dst alpha":773,"constant color":32769,"one minus constant color":32770,"constant alpha":32771,"one minus constant alpha":32772,"src alpha saturate":776},Ka=["constant color, constant alpha","one minus constant color, constant alpha","constant color, one minus constant alpha","one minus constant color, one minus constant alpha","constant alpha, constant color","constant alpha, one minus constant color","one minus constant alpha, constant color","one minus constant alpha, one minus constant color"],Ja={never:512,less:513,"<":513,equal:514,"=":514,"==":514,"===":514,lequal:515,"<=":515,greater:516,">":516,notequal:517,"!=":517,"!==":517,gequal:518,">=":518,always:519},Za={0:0,zero:0,keep:7680,replace:7681,increment:7682,decrement:7683,"increment wrap":34055,"decrement wrap":34056,invert:5386},ei={frag:35632,vert:35633},ti={cw:Ia,ccw:Ma},ri=new te(!1,!1,!1,function(){}),ni=34918,ai=34919,ii=35007,oi=function(e,t){function r(e){o.push(e)}function n(e){u.push(e)}function a(e,t,r){var n=u.pop()||new function(){this.startQueryIndex=-1,this.endQueryIndex=-1,this.sum=0,this.stats=null};n.startQueryIndex=e,n.endQueryIndex=t,n.sum=0,n.stats=r,s.push(n)}var i=t.ext_disjoint_timer_query;if(!i)return null;var o=[],f=[],u=[],s=[],c=[],l=[];return{beginQuery:function(e){var t=o.pop()||i.createQueryEXT();i.beginQueryEXT(ii,t),f.push(t),a(f.length-1,f.length,e)},endQuery:function(){i.endQueryEXT(ii)},pushScopeStats:a,update:function(){var e,t,a=f.length;if(0!==a){l.length=Math.max(l.length,a+1),c.length=Math.max(c.length,a+1),c[0]=0,l[0]=0;var o=0;for(e=0,t=0;t=0;--e){var r=U[e];r&&r(T,null,0)}p.flush(),w&&w.update()}function r(){!K&&U.length>0&&(K=Te.next(t))}function n(){K&&(Te.cancel(t),K=null)}function a(e){e.preventDefault(),b=!0,n(),N.forEach(function(e){e()})}function i(e){p.getError(),b=!1,g.restore(),P.restore(),j.restore(),R.restore(),L.restore(),I.restore(),w&&w.restore(),M.procs.refresh(),r(),q.forEach(function(e){e()})}function o(e){function t(e){var t={},r={};return Object.keys(e).forEach(function(n){var a=e[n];Ee.isDynamic(a)?r[n]=Ee.unbox(a,n):t[n]=a}),{dynamic:r,static:t}}Ae(!!e,"invalid args to regl({...})"),Ae.type(e,"object","invalid args to regl({...})");var r=t(e.context||{}),n=t(e.uniforms||{}),a=t(e.attributes||{}),i=t(function(e){function t(e){if(e in r){var t=r[e];delete r[e],Object.keys(t).forEach(function(n){r[e+"."+n]=t[n]})}}var r=se({},e);return delete r.uniforms,delete r.attributes,delete r.context,"stencil"in r&&r.stencil.op&&(r.stencil.opBack=r.stencil.opFront=r.stencil.op,delete r.stencil.op),t("blend"),t("depth"),t("cull"),t("stencil"),t("polygonOffset"),t("scissor"),t("sample"),r}(e)),o={gpuTime:0,cpuTime:0,count:0},f=M.compile(i,a,n,r,o),u=f.draw,s=f.batch,c=f.scope,l=[];return se(function(e,t){var r;if(b&&Ae.raise("context lost"),"function"==typeof e)return c.call(this,null,e,0);if("function"==typeof t){if("number"==typeof e){for(r=0;r0)return s.call(this,function(e){for(;l.length=0,"cannot cancel a frame twice"),U[r]=t}}}function s(){var e=H.viewport,t=H.scissor_box;e[0]=e[1]=t[0]=t[1]=0,T.viewportWidth=T.framebufferWidth=T.drawingBufferWidth=e[2]=t[2]=p.drawingBufferWidth,T.viewportHeight=T.framebufferHeight=T.drawingBufferHeight=e[3]=t[3]=p.drawingBufferHeight}function c(){T.tick+=1,T.time=d(),s(),M.procs.poll()}function l(){s(),M.procs.refresh(),w&&w.update()}function d(){return(De()-k)/1e3}var m=A(e);if(!m)return null;var p=m.gl,h=p.getContextAttributes(),b=p.isContextLost(),g=function(e,t){function r(t){Ae.type(t,"string","extension name must be string");var r,a=t.toLowerCase();try{r=n[a]=e.getExtension(a)}catch(e){}return!!r}for(var n={},a=0;a0){var u;if(Array.isArray(t[0])){f=Ne(t);for(var s=1,c=1;c0)if("number"==typeof e[0]){var a=Me.allocType(m.dtype,e.length);F(a,e),d(a,n),Me.freeType(a)}else if(Array.isArray(e[0])||ue(e[0])){r=Ne(e);var i=Ue(e,r,m.dtype);d(i,n),Me.freeType(i)}else Ae.raise("invalid buffer data")}else if(ue(e))d(e,n);else if(S(e)){r=e.shape;var o=e.stride,f=0,u=0,s=0,c=0;1===r.length?(f=r[0],u=1,s=o[0],c=0):2===r.length?(f=r[0],u=r[1],s=o[0],c=o[1]):Ae.raise("invalid shape");var p=Array.isArray(e.data)?m.dtype:C(e.data),h=Me.allocType(p,f*u);z(h,e.data,f,u,s,c,e.offset),d(h,n),Me.freeType(h)}else Ae.raise("invalid data for buffer subdata");return l},r.profile&&(l.stats=m.stats),l.destroy=function(){o(m)},l},createStream:function(e,t){var r=s.pop();return r||(r=new n(e)),r.bind(),i(r,t,Qe,0,1,!1),r},destroyStream:function(e){s.push(e)},clear:function(){Oe(u).forEach(o),s.forEach(o)},getBuffer:function(e){return e&&e._buffer instanceof n?e._buffer:null},restore:function(){Oe(u).forEach(function(t){t.buffer=e.createBuffer(),e.bindBuffer(t.type,t.buffer),e.bufferData(t.type,t.persistentData||t.byteLength,t.usage)})},_initBuffer:i}}(p,y,m),O=function(e,t,r,n){function a(e){this.id=u++,f[this.id]=this,this.buffer=e,this.primType=Ze,this.vertCount=0,this.type=0}function i(n,a,i,o,f,u,s){if(n.buffer.bind(),a){var c=s;s||ue(a)&&(!S(a)||ue(a.data))||(c=t.oes_element_index_uint?it:nt),r._initBuffer(n.buffer,a,i,c,3)}else e.bufferData(ot,u,i),n.buffer.dtype=l||tt,n.buffer.usage=i,n.buffer.dimension=3,n.buffer.byteLength=u;var l=s;if(!s){switch(n.buffer.dtype){case tt:case et:l=tt;break;case nt:case rt:l=nt;break;case it:case at:l=it;break;default:Ae.raise("unsupported type for element array")}n.buffer.dtype=l}n.type=l,Ae(l!==it||!!t.oes_element_index_uint,"32 bit element buffers not supported, enable oes_element_index_uint first");var d=f;d<0&&(d=n.buffer.byteLength,l===nt?d>>=1:l===it&&(d>>=2)),n.vertCount=d;var m=o;if(o<0){m=Ze;var p=n.buffer.dimension;1===p&&(m=Ke),2===p&&(m=Je),3===p&&(m=Ze)}n.primType=m}function o(e){n.elementsCount--,Ae(null!==e.buffer,"must not double destroy elements"),delete f[e.id],e.buffer.destroy(),e.buffer=null}var f={},u=0,s={uint8:tt,uint16:nt};t.oes_element_index_uint&&(s.uint32=it),a.prototype.bind=function(){this.buffer.bind()};var c=[];return{create:function(e,t){function f(e){if(e)if("number"==typeof e)u(e),c.primType=Ze,c.vertCount=0|e,c.type=tt;else{var t=null,r=ut,n=-1,a=-1,o=0,l=0;Array.isArray(e)||ue(e)||S(e)?t=e:(Ae.type(e,"object","invalid arguments for elements"),"data"in e&&(t=e.data,Ae(Array.isArray(t)||ue(t)||S(t),"invalid data for element buffer")),"usage"in e&&(Ae.parameter(e.usage,Ge,"invalid element buffer usage"),r=Ge[e.usage]),"primitive"in e&&(Ae.parameter(e.primitive,$e,"invalid element buffer primitive"),n=$e[e.primitive]),"count"in e&&(Ae("number"==typeof e.count&&e.count>=0,"invalid vertex count for elements"),a=0|e.count),"type"in e&&(Ae.parameter(e.type,s,"invalid buffer type"),l=s[e.type]),"length"in e?o=0|e.length:(o=a,l===nt||l===rt?o*=2:l!==it&&l!==at||(o*=4))),i(c,t,r,n,a,o,l)}else u(),c.primType=Ze,c.vertCount=0,c.type=tt;return f}var u=r.create(null,ot,!0),c=new a(u._buffer);return n.elementsCount++,f(e),f._reglType="elements",f._elements=c,f.subdata=function(e,t){return u.subdata(e,t),f},f.destroy=function(){o(c)},f},createStream:function(e){var t=c.pop();return t||(t=new a(r.create(null,ot,!0,!1)._buffer)),i(t,e,ft,-1,-1,0,0),t},destroyStream:function(e){c.push(e)},getElements:function(e){return"function"==typeof e&&e._elements instanceof a?e._elements:null},clear:function(){Oe(f).forEach(o)}}}(p,x,j,y),B=function(e,t,r,n,a){for(var i=r.maxAttributes,o=new Array(i),f=0;f=Rr&&t=2,"invalid shape for framebuffer"),s=F[0],m=F[1]}else"radius"in C&&(s=m=C.radius),"width"in C&&(s=C.width),"height"in C&&(m=C.height);("color"in C||"colors"in C)&&(v=C.color||C.colors,Array.isArray(v)&&Ae(1===v.length||f,"multiple render targets not supported")),v||("colorCount"in C&&(E=0|C.colorCount,Ae(E>0,"invalid color buffer count")),"colorTexture"in C&&(A=!!C.colorTexture,S="rgba4"),"colorType"in C&&(_=C.colorType,A?(Ae(t.oes_texture_float||!("float"===_||"float32"===_),"you must enable OES_texture_float in order to use floating point framebuffer objects"),Ae(t.oes_texture_half_float||!("half float"===_||"float16"===_),"you must enable OES_texture_half_float in order to use 16-bit floating point framebuffer objects")):"half float"===_||"float16"===_?(Ae(t.ext_color_buffer_half_float,"you must enable EXT_color_buffer_half_float to use 16-bit render buffers"),S="rgba16f"):"float"!==_&&"float32"!==_||(Ae(t.webgl_color_buffer_float,"you must enable WEBGL_color_buffer_float in order to use 32-bit floating point renderbuffers"),S="rgba32f"),Ae.oneOf(_,k,"invalid color type")),"colorFormat"in C&&(S=C.colorFormat,x.indexOf(S)>=0?A=!0:w.indexOf(S)>=0?A=!1:A?Ae.oneOf(C.colorFormat,x,"invalid color format for texture"):Ae.oneOf(C.colorFormat,w,"invalid color format for renderbuffer"))),("depthTexture"in C||"depthStencilTexture"in C)&&(O=!(!C.depthTexture&&!C.depthStencilTexture),Ae(!O||t.webgl_depth_texture,"webgl_depth_texture extension not supported")),"depth"in C&&("boolean"==typeof C.depth?p=C.depth:(T=C.depth,b=!1)),"stencil"in C&&("boolean"==typeof C.stencil?b=C.stencil:(D=C.stencil,p=!1)),"depthStencil"in C&&("boolean"==typeof C.depthStencil?p=b=C.depthStencil:(j=C.depthStencil,p=!1,b=!1))}else s=m=1;var z=null,B=null,P=null,R=null;if(Array.isArray(v))z=v.map(c);else if(v)z=[c(v)];else for(z=new Array(E),i=0;i=0||z[i].renderbuffer&&Xr.indexOf(z[i].renderbuffer._renderbuffer.format)>=0,"framebuffer color attachment "+i+" is invalid"),z[i]&&z[i].texture){var I=Nr[z[i].texture._texture.format]*qr[z[i].texture._texture.type];null===L?L=I:Ae(L===I,"all color attachments much have the same number of bits per pixel.")}return u(B,s,m),Ae(!B||B.texture&&B.texture._texture.format===Gr||B.renderbuffer&&B.renderbuffer._renderbuffer.format===Qr,"invalid depth attachment for framebuffer object"),u(P,s,m),Ae(!P||P.renderbuffer&&P.renderbuffer._renderbuffer.format===Vr,"invalid stencil attachment for framebuffer object"),u(R,s,m),Ae(!R||R.texture&&R.texture._texture.format===Yr||R.renderbuffer&&R.renderbuffer._renderbuffer.format===Yr,"invalid depth-stencil attachment for framebuffer object"),h(o),o.width=s,o.height=m,o.colorAttachments=z,o.depthAttachment=B,o.stencilAttachment=P,o.depthStencilAttachment=R,a.color=z.map(d),a.depth=d(B),a.stencil=d(P),a.depthStencil=d(R),a.width=o.width,a.height=o.height,g(o),a}var o=new p;return i.framebufferCount++,a(e,n),se(a,{resize:function(e,t){Ae(y.next!==o,"can not resize a framebuffer which is currently in use");var r=0|e,n=0|t||r;if(r===o.width&&n===o.height)return a;for(var i=o.colorAttachments,f=0;f=2,"invalid shape for framebuffer"),Ae(p[0]===p[1],"cube framebuffer must be square"),u=p[0]}else"radius"in m&&(u=0|m.radius),"width"in m?(u=0|m.width,"height"in m&&Ae(m.height===u,"must be square")):"height"in m&&(u=0|m.height);("color"in m||"colors"in m)&&(s=m.color||m.colors,Array.isArray(s)&&Ae(1===s.length||o,"multiple render targets not supported")),s||("colorCount"in m&&(d=0|m.colorCount,Ae(d>0,"invalid color buffer count")),"colorType"in m&&(Ae.oneOf(m.colorType,k,"invalid color type"),l=m.colorType),"colorFormat"in m&&(c=m.colorFormat,Ae.oneOf(m.colorFormat,x,"invalid color format for texture"))),"depth"in m&&(f.depth=m.depth),"stencil"in m&&(f.stencil=m.stencil),"depthStencil"in m&&(f.depthStencil=m.depthStencil)}else u=1;var h;if(s)if(Array.isArray(s))for(h=[],r=0;r0&&(f.depth=i[0].depth,f.stencil=i[0].stencil,f.depthStencil=i[0].depthStencil),i[r]?i[r](f):i[r]=v(f)}return se(a,{width:u,height:u,color:h})}var i=Array(6);return a(e),se(a,{faces:i,resize:function(e){var t,n=0|e;if(Ae(n>0&&n<=r.maxCubeMapSize,"invalid radius for cube fbo"),n===a.width)return a;var o=a.color;for(t=0;t=0},read:W,destroy:function(){U.length=0,n(),G&&(G.removeEventListener(li,a),G.removeEventListener(di,i)),P.clear(),I.clear(),L.clear(),R.clear(),O.clear(),j.clear(),w&&w.clear(),V.forEach(function(e){e()})},_gl:p,_refresh:l,poll:function(){c(),w&&w.update()},now:d,stats:y});return m.onDone(null,Z),Z}}); },{}],8:[function(require,module,exports) { "use strict";Object.defineProperty(exports,"__esModule",{value:!0});const e=require("regl"),t=require("./rectangle-batch-renderer"),r=require("./overlay-rectangle-renderer"),i=require("./texture-catched-renderer"),s=require("./stats"),n=require("./math"),a=require("./flamechart-color-pass-renderer");class h{constructor(n){this.tick=null,this.tickNeeded=!1,this.beforeFrameHandlers=new Set,this.perfDebug=-1!==window.location.href.indexOf("perf-debug=1"),this.statsPanel=this.perfDebug?new s.StatsPanel:null,this.onBeforeFrame=(e=>{this.setScissor(()=>{this.gl.clear({color:[0,0,0,0]})}),this.tickNeeded=!1,this.statsPanel&&this.statsPanel.begin();for(const e of this.beforeFrameHandlers)e();this.statsPanel&&this.statsPanel.end(),this.tick&&!this.tickNeeded&&(this.perfDebug||(this.tick.cancel(),this.tick=null))}),this.gl=e({canvas:n,attributes:{antialias:!1},extensions:["ANGLE_instanced_arrays","WEBGL_depth_texture"],optionalExtensions:["EXT_disjoint_timer_query"],profile:!0}),window.CanvasContext=this,this.rectangleBatchRenderer=new t.RectangleBatchRenderer(this.gl),this.viewportRectangleRenderer=new r.ViewportRectangleRenderer(this.gl),this.textureRenderer=new i.TextureRenderer(this.gl),this.flamechartColorPassRenderer=new a.FlamechartColorPassRenderer(this.gl),this.setScissor=this.gl({scissor:{enable:!0}}),this.setViewportScope=this.gl({context:{viewportX:(e,t)=>t.physicalBounds.left(),viewportY:(e,t)=>t.physicalBounds.top()},viewport:(e,t)=>{const{physicalBounds:r}=t;return{x:r.left(),y:window.devicePixelRatio*window.innerHeight-r.top()-r.height(),width:r.width(),height:r.height()}},scissor:(e,t)=>{const{physicalBounds:r}=t;return{enable:!0,box:{x:r.left(),y:window.devicePixelRatio*window.innerHeight-r.top()-r.height(),width:r.width(),height:r.height()}}}})}addBeforeFrameHandler(e){this.beforeFrameHandlers.add(e)}removeBeforeFrameHandler(e){this.beforeFrameHandlers.delete(e)}requestFrame(){this.tickNeeded=!0,this.tick||(this.tick=this.gl.frame(this.onBeforeFrame))}drawRectangleBatch(e){this.rectangleBatchRenderer.render(e)}drawTexture(e){this.textureRenderer.render(e)}drawFlamechartColorPass(e){this.flamechartColorPassRenderer.render(e)}createRectangleBatch(){return new t.RectangleBatch(this.gl)}createTextureCachedRenderer(e){return new i.TextureCachedRenderer(this.gl,Object.assign({},e,{textureRenderer:this.textureRenderer}))}drawViewportRectangle(e){this.viewportRectangleRenderer.render(e)}renderInto(e,t){const r=e.getBoundingClientRect(),i=new n.Rect(new n.Vec2(r.left*window.devicePixelRatio,r.top*window.devicePixelRatio),new n.Vec2(r.width*window.devicePixelRatio,r.height*window.devicePixelRatio));this.setViewportScope({physicalBounds:i},t)}setViewport(e,t){this.setViewportScope({physicalBounds:e},t)}getMaxTextureSize(){return this.gl.limits.maxTextureSize}}exports.CanvasContext=h; -},{"./rectangle-batch-renderer":47,"./overlay-rectangle-renderer":48,"./texture-catched-renderer":49,"./stats":50,"./math":51,"./flamechart-color-pass-renderer":52,"regl":53}],10:[function(require,module,exports) { +},{"./rectangle-batch-renderer":15,"./overlay-rectangle-renderer":16,"./stats":17,"./math":18,"./texture-catched-renderer":19,"./flamechart-color-pass-renderer":20,"regl":27}],9:[function(require,module,exports) { "use strict";Object.defineProperty(exports,"__esModule",{value:!0});const t=require("./utils");class e{constructor(e){this.source=e,this.layers=[],this.totalWeight=0,this.minFrameWidth=1;const r=[];this.minFrameWidth=1/0;this.totalWeight=e.getTotalWeight(),e.forEachCall((e,i)=>{const s=t.lastOf(r),h={node:e,parent:s,children:[],start:i,end:i};s&&s.children.push(h),r.push(h)},t=>{const e=r.pop();if(e.end=t,e.end-e.start==0)return;const i=r.length;for(;this.layers.length<=i;)this.layers.push([]);this.layers[i].push(e),this.minFrameWidth=Math.min(this.minFrameWidth,e.end-e.start)}),isFinite(this.minFrameWidth)||(this.minFrameWidth=1)}getTotalWeight(){return this.totalWeight}getLayers(){return this.layers}getColorBucketForFrame(t){return this.source.getColorBucketForFrame(t)}getMinFrameWidth(){return this.minFrameWidth}formatValue(t){return this.source.formatValue(t)}}exports.Flamechart=e; -},{"./utils":16}],15:[function(require,module,exports) { +},{"./utils":23}],24:[function(require,module,exports) { "use strict";Object.defineProperty(exports,"__esModule",{value:!0});const e=require("./utils");class t{constructor(){this.selfWeight=0,this.totalWeight=0}getSelfWeight(){return this.selfWeight}getTotalWeight(){return this.totalWeight}addToTotalWeight(e){this.totalWeight+=e}addToSelfWeight(e){this.selfWeight+=e}}exports.HasWeights=t;class s extends t{constructor(e){super(),this.key=e.key,this.name=e.name,this.file=e.file,this.line=e.line,this.col=e.col}}exports.Frame=s;class a extends t{constructor(e,t){super(),this.frame=e,this.parent=t,this.children=[]}}exports.CallTreeNode=a;const r=new s({key:"(speedscope root)",name:"(speedscope root)"});class i{format(e){return e.toLocaleString()}}exports.RawValueFormatter=i;class l{constructor(e){this.multiplier="nanoseconds"===e?1e-9:"microseconds"===e?1e-6:"milliseconds"===e?.001:1}format(e){const t=e*this.multiplier;return t/1>=1?`${t.toFixed(2)}s`:t/.001>=1?`${(t/.001).toFixed(2)}ms`:t/1e-6>=1?`${(t/1e-6).toFixed(2)}µs`:`${(t/1e-9).toFixed(2)}ms`}}exports.TimeFormatter=l;class o{constructor(e){this.frames=new Map,this.appendOrderCalltreeRoot=new a(r,null),this.groupedCalltreeRoot=new a(r,null),this.samples=[],this.weights=[],this.valueFormatter=new i,this.appendOrderStack=[this.appendOrderCalltreeRoot],this.groupedOrderStack=[this.groupedCalltreeRoot],this.framesInStack=new Map,this.stack=[],this.lastValue=null,this.totalWeight=e}formatValue(e){return this.valueFormatter.format(e)}setValueFormatter(e){this.valueFormatter=e}getName(){return this.name}setName(e){this.name=e}getTotalWeight(){return this.totalWeight}getTotalNonIdleWeight(){return this.groupedCalltreeRoot.children.reduce((e,t)=>e+t.getTotalWeight(),0)}forEachCallGrouped(e,t){function s(a,i){a.frame!==r&&e(a,i);let l=0;const o=[...a.children];o.sort((e,t)=>e.getTotalWeight()>t.getTotalWeight()?-1:1),o.forEach(function(e){s(e,i+l),l+=e.getTotalWeight()}),a.frame!==r&&t(i+a.getTotalWeight())}s(this.groupedCalltreeRoot,0)}forEachCall(t,s){let a=[],i=0,l=0;for(let o of this.samples){let h=null;for(h=o;h&&h.frame!=r&&-1===a.indexOf(h);h=h.parent);for(;a.length>0&&e.lastOf(a)!=h;)a.pop(),s(i);const n=[];for(let e=o;e&&e.frame!=r&&e!=h;e=e.parent)n.push(e);n.reverse();for(let e of n)t(e,i);a=a.concat(n),i+=this.weights[l++]}for(let e=a.length-1;e>=0;e--)s(i)}forEachFrame(e){this.frames.forEach(e)}_appendSample(t,r,i){if(isNaN(r))throw new Error("invalid weight");let l=i?this.appendOrderCalltreeRoot:this.groupedCalltreeRoot,o=new Set;for(let h of t){const t=e.getOrInsert(this.frames,h.key,()=>new s(h)),n=i?e.lastOf(l.children):l.children.find(e=>e.frame===t);if(n&&n.frame==t)l=n;else{const e=l;l=new a(t,l),e.children.push(l)}l.addToTotalWeight(r),o.add(l.frame)}if(l.addToSelfWeight(r),i){l.frame.addToSelfWeight(r);for(let e of o)e.addToTotalWeight(r);this.samples.push(l),this.weights.push(r)}}appendSample(e,t){this._appendSample(e,t,!0),this._appendSample(e,t,!1)}addWeightsToFrames(t){null==this.lastValue&&(this.lastValue=t);const s=t-this.lastValue;for(let e of this.framesInStack.keys())e.addToTotalWeight(s);const a=e.lastOf(this.stack);a&&a.addToSelfWeight(s)}addWeightsToNodes(t,s){const a=t-this.lastValue;for(let e of s)e.addToTotalWeight(a);const r=e.lastOf(s);r&&r.addToSelfWeight(a)}_enterFrame(t,s,r){let i=r?this.appendOrderStack:this.groupedOrderStack;this.addWeightsToNodes(s,i);let l=e.lastOf(i);if(l){if(r){s-this.lastValue>0&&(this.samples.push(l),this.weights.push(s-this.lastValue))}const o=r?e.lastOf(l.children):l.children.find(e=>e.frame===t);let h;o&&o.frame==t?h=o:(h=new a(t,l),l.children.push(h)),i.push(h)}}enterFrame(t,a){const r=e.getOrInsert(this.frames,t.key,()=>new s(t));this.addWeightsToFrames(a),this._enterFrame(r,a,!0),this._enterFrame(r,a,!1),this.stack.push(r);const i=this.framesInStack.get(r)||0;this.framesInStack.set(r,i+1),this.lastValue=a}_leaveFrame(e,t,s){let a=s?this.appendOrderStack:this.groupedOrderStack;if(this.addWeightsToNodes(t,a),s){const e=this.appendOrderStack.pop();t-this.lastValue>0&&(this.samples.push(e),this.weights.push(t-this.lastValue))}else this.groupedOrderStack.pop()}leaveFrame(t,a){const r=e.getOrInsert(this.frames,t.key,()=>new s(t));this.addWeightsToFrames(a),this._leaveFrame(r,a,!0),this._leaveFrame(r,a,!1),this.stack.pop();const i=this.framesInStack.get(r);null!=i&&(1===i?this.framesInStack.delete(r):this.framesInStack.set(r,i-1),this.lastValue=a)}}exports.Profile=o; -},{"./utils":16}],11:[function(require,module,exports) { +},{"./utils":23}],11:[function(require,module,exports) { "use strict";function e(e){const r=[];return e.replace(/^(.*) (\d+)$/gm,(e,t,o)=>(r.push({stack:t.split(";").map(e=>({key:e,name:e})),duration:parseInt(o,10)}),e)),r}function r(r){const o=e(r),n=o.reduce((e,r)=>e+r.duration,0),a=new t.Profile(n);for(let e of o)a.appendSample(e.stack,e.duration);return a}Object.defineProperty(exports,"__esModule",{value:!0});const t=require("../profile");exports.importFromBGFlameGraph=r; -},{"../profile":15}],12:[function(require,module,exports) { -"use strict";function e(e){return r(e[e.length-1].args.data.cpuProfile)}function t(e){return o.getOrInsert(n,e,e=>{const t=e.functionName||"(anonymous)",r=e.url,l=e.lineNumber,o=e.columnNumber;return{key:`${t}:${r}:${l}:${o}`,name:t,file:r,line:l,col:o}})}function r(e){const r=new l.Profile(e.endTime-e.startTime),n=new Map;for(let t of e.nodes)n.set(t.id,t);for(let t of e.nodes)if(t.children)for(let e of t.children){const r=n.get(e);r&&(r.parent=t)}const a=[],s=[];let c=0,i=NaN;for(let t=0;t0&&o.lastOf(f)!=u;){const e=t(f.pop().callFrame);r.leaveFrame(e,m)}const p=[];for(let e=i;e&&e!=u;e="(garbage collector)"===e.callFrame.functionName?o.lastOf(f):e.parent||null)p.push(e);p.reverse();for(let e of p)r.enterFrame(t(e.callFrame),m);f=f.concat(p),m+=l}for(let e=f.length-1;e>=0;e--)r.leaveFrame(t(f[e].callFrame),m);return r.setValueFormatter(new l.TimeFormatter("microseconds")),r}Object.defineProperty(exports,"__esModule",{value:!0});const l=require("../profile"),o=require("../utils");exports.importFromChromeTimeline=e;const n=new Map;exports.importFromChromeCPUProfile=r; -},{"../profile":15,"../utils":16}],13:[function(require,module,exports) { +},{"../profile":24}],12:[function(require,module,exports) { "use strict";function e(e){const r=e.raw_timestamp_deltas.reduce((e,t)=>e+t,0),o=new t.Profile(r),{frames:s,raw:a,raw_timestamp_deltas:n}=e;let l=0;for(let e=0;e{const t=e.functionName||"(anonymous)",r=e.url,l=e.lineNumber,o=e.columnNumber;return{key:`${t}:${r}:${l}:${o}`,name:t,file:r,line:l,col:o}})}function r(e){const r=new l.Profile(e.endTime-e.startTime),n=new Map;for(let t of e.nodes)n.set(t.id,t);for(let t of e.nodes)if(t.children)for(let e of t.children){const r=n.get(e);r&&(r.parent=t)}const a=[],s=[];let c=0,i=NaN;for(let t=0;t0&&o.lastOf(f)!=u;){const e=t(f.pop().callFrame);r.leaveFrame(e,m)}const p=[];for(let e=i;e&&e!=u;e="(garbage collector)"===e.callFrame.functionName?o.lastOf(f):e.parent||null)p.push(e);p.reverse();for(let e of p)r.enterFrame(t(e.callFrame),m);f=f.concat(p),m+=l}for(let e=f.length-1;e>=0;e--)r.leaveFrame(t(f[e].callFrame),m);return r.setValueFormatter(new l.TimeFormatter("microseconds")),r}Object.defineProperty(exports,"__esModule",{value:!0});const l=require("../profile"),o=require("../utils");exports.importFromChromeTimeline=e;const n=new Map;exports.importFromChromeCPUProfile=r; +},{"../utils":23,"../profile":24}],2:[function(require,module,exports) { "use strict";function e(e,t){try{if(t.endsWith(".cpuprofile"))return n.importFromChromeCPUProfile(JSON.parse(e));if(t.endsWith(".chrome.json")||/Profile-\d{8}T\d{6}/.exec(t))return n.importFromChromeTimeline(JSON.parse(e));if(t.endsWith(".stackprof.json"))return o.importFromStackprof(JSON.parse(e));if(t.endsWith(".txt"))return s.importFromBGFlameGraph(e);try{const t=JSON.parse(e);if(Array.isArray(t)&&"CpuProfile"===t[t.length-1].name)return n.importFromChromeTimeline(t);if("nodes"in t&&"samples"in t&&"timeDeltas"in t)return n.importFromChromeCPUProfile(t);if("mode"in t&&"frames"in t)return o.importFromStackprof(t)}catch(t){const r=e.split(/\n/).length;if(r>1&&r===e.split(/ \d+\n/).length)return s.importFromBGFlameGraph(e)}return null}catch(e){return null}}Object.defineProperty(exports,"__esModule",{value:!0});const t=require("preact"),r=require("aphrodite"),a=require("./reloadable"),s=require("./import/bg-flamegraph"),o=require("./import/stackprof"),n=require("./import/chrome"),i=require("./flamechart-renderer"),l=require("./canvas-context"),h=require("./flamechart"),c=require("./flamechart-view"),d=require("./style");var m;!function(e){e[e.CHRONO=0]="CHRONO",e[e.LEFT_HEAVY=1]="LEFT_HEAVY"}(m||(m={}));class p extends a.ReloadableComponent{constructor(){super(...arguments),this.setTimeOrder=(()=>{this.props.setSortOrder(m.CHRONO)}),this.setLeftHeavyOrder=(()=>{this.props.setSortOrder(m.LEFT_HEAVY)})}render(){const e=t.h("div",{className:r.css(g.toolbarTab)},t.h("a",{href:"https://github.com/jlfwong/speedscope#usage",className:r.css(g.noLinkStyle),target:"_blank"},t.h("span",{className:r.css(g.emoji)},"❓"),"Help"));return this.props.profile?t.h("div",{className:r.css(g.toolbar)},t.h("div",{className:r.css(g.toolbarLeft)},t.h("div",{className:r.css(g.toolbarTab,this.props.sortOrder===m.CHRONO&&g.toolbarTabActive),onClick:this.setTimeOrder},t.h("span",{className:r.css(g.emoji)},"🕰"),"Time Order"),t.h("div",{className:r.css(g.toolbarTab,this.props.sortOrder===m.LEFT_HEAVY&&g.toolbarTabActive),onClick:this.setLeftHeavyOrder},t.h("span",{className:r.css(g.emoji)},"⬅️"),"Left Heavy"),e),this.props.profile.getName(),t.h("div",{className:r.css(g.toolbarRight)},"🔬speedscope")):t.h("div",{className:r.css(g.toolbar)},t.h("div",{className:r.css(g.toolbarLeft)},e),"🔬speedscope")}}exports.Toolbar=p;class f extends a.ReloadableComponent{constructor(){super(...arguments),this.canvas=null,this.canvasContext=null,this.ref=(e=>{e instanceof HTMLCanvasElement?(this.canvas=e,this.canvasContext=new l.CanvasContext(e)):(this.canvas=null,this.canvasContext=null),this.props.setCanvasContext(this.canvasContext)}),this.onWindowResize=(()=>{this.maybeResize(),window.addEventListener("resize",this.onWindowResize)})}maybeResize(){if(!this.canvas)return;let{width:e,height:t}=this.canvas.getBoundingClientRect();if(e=Math.floor(e)*window.devicePixelRatio,t=Math.floor(t)*window.devicePixelRatio,e<4||t<4)return;const r=this.canvas.width,a=this.canvas.height;e===r&&t===a||(this.canvas.width=e,this.canvas.height=t)}componentDidMount(){window.addEventListener("resize",this.onWindowResize),requestAnimationFrame(()=>this.maybeResize())}componentWillUnmount(){window.removeEventListener("resize",this.onWindowResize)}render(){return t.h("canvas",{className:r.css(g.glCanvasView),ref:this.ref,width:1,height:1})}}exports.GLCanvas=f;class u extends a.ReloadableComponent{constructor(){super(),this.loadExample=(()=>{this.setState({loading:!0}),fetch("dist/perf-vertx-stacks-01-collapsed-all.txt").then(e=>e.text()).then(e=>{this.loadFromString("perf-vertx-stacks-01-collapsed-all.txt",e)})}),this.onDrop=(e=>{this.loadFromFile(e.dataTransfer.files.item(0)),e.preventDefault()}),this.onDragOver=(e=>{e.preventDefault()}),this.onWindowKeyPress=(e=>{"1"===e.key?this.setState({sortOrder:m.CHRONO}):"2"===e.key&&this.setState({sortOrder:m.LEFT_HEAVY})}),this.flamechartRef=(e=>this.flamechartView=e),this.onFileSelect=(e=>{this.loadFromFile(e.target.files.item(0))}),this.setSortOrder=(e=>{this.setState({sortOrder:e})}),this.canvasContext=null,this.setCanvasContext=(e=>{this.canvasContext=e}),this.state={loading:!1,profile:null,flamechart:null,flamechartRenderer:null,sortedFlamechart:null,sortedFlamechartRenderer:null,sortOrder:m.CHRONO}}serialize(){const e=super.serialize();return delete e.state.flamechartRenderer,delete e.state.sortedFlamechartRenderer,e}rehydrate(e){super.rehydrate(e);const{flamechart:t,sortedFlamechart:r}=e.state;this.canvasContext&&t&&r&&this.setState({flamechartRenderer:new i.FlamechartRenderer(this.canvasContext,t),sortedFlamechartRenderer:new i.FlamechartRenderer(this.canvasContext,r)})}loadFromString(t,r){function a(e){return(e.file||"")+e.name}function s(e){return l.get(e)||0}if(!this.canvasContext)return;const o=e(r,t);if(null==o)return this.setState({loading:!1}),void alert("Unrecognized format! See documentation about supported formats.");o.setName(t),document.title=`${t} - speedscope`;const n=[];o.forEachFrame(e=>n.push(e)),n.sort(function(e,t){return a(e)>a(t)?1:-1});const l=new Map;for(let e=0;e{})}loadFromFile(e){this.setState({loading:!0},()=>{requestAnimationFrame(()=>{const t=new FileReader;t.addEventListener("loadend",()=>{this.loadFromString(e.name,t.result)}),t.readAsText(e)})})}componentDidMount(){window.addEventListener("keypress",this.onWindowKeyPress)}componentWillUnmount(){window.removeEventListener("keypress",this.onWindowKeyPress)}subcomponents(){return{flamechart:this.flamechartView}}renderLanding(){return t.h("div",{className:r.css(g.landingContainer)},t.h("div",{className:r.css(g.landingMessage)},t.h("p",{className:r.css(g.landingP)},"👋 Hi there! Welcome to 🔬speedscope, an interactive"," ",t.h("a",{className:r.css(g.link),href:"http://www.brendangregg.com/FlameGraphs/cpuflamegraphs.html"},"flamegraph")," visualizer. Use it to help you make your software faster."),t.h("p",{className:r.css(g.landingP)},"Drag and drop a profile file onto this window to get started, click the big blue button below to browse for a profile to explore, or"," ",t.h("a",{className:r.css(g.link),onClick:this.loadExample},"click here")," ","to load an example profile."),t.h("div",{className:r.css(g.browseButtonContainer)},t.h("input",{type:"file",name:"file",id:"file",onChange:this.onFileSelect,className:r.css(g.hide)}),t.h("label",{for:"file",className:r.css(g.browseButton)},"Browse")),t.h("p",{className:r.css(g.landingP)},"See the ",t.h("a",{className:r.css(g.link),href:"https://github.com/jlfwong/speedscope#usage",target:"_blank"},"documentation")," for information about supported file formats, keyboard shortcuts, and how to navigate around the profile."),t.h("p",{className:r.css(g.landingP)},"speedscope is open source. Please ",t.h("a",{className:r.css(g.link),target:"_blank",href:"https://github.com/jlfwong/speedscope/issues"},"report any issues on GitHub"),".")))}renderLoadingBar(){return t.h("div",{className:r.css(g.loading)})}render(){const{flamechart:e,flamechartRenderer:a,sortedFlamechart:s,sortedFlamechartRenderer:o,sortOrder:n,loading:i}=this.state,l=n==m.CHRONO?e:s,h=n==m.CHRONO?a:o;return t.h("div",{onDrop:this.onDrop,onDragOver:this.onDragOver,className:r.css(g.root)},t.h(f,{setCanvasContext:this.setCanvasContext}),t.h(p,Object.assign({setSortOrder:this.setSortOrder},this.state)),i?this.renderLoadingBar():this.canvasContext&&l&&h?t.h(c.FlamechartView,{canvasContext:this.canvasContext,flamechartRenderer:h,ref:this.flamechartRef,flamechart:l}):this.renderLanding())}}exports.Application=u;const g=r.StyleSheet.create({glCanvasView:{position:"absolute",width:"100vw",height:"100vh",zIndex:-1,pointerEvents:"none"},loading:{height:3,marginBottom:-3,background:d.Colors.DARK_BLUE,transformOrigin:"0% 50%",animationName:[{from:{transform:"scaleX(0)"},to:{transform:"scaleX(1)"}}],animationTimingFunction:"cubic-bezier(0, 1, 0, 1)",animationDuration:"30s"},root:{width:"100vw",height:"100vh",overflow:"hidden",display:"flex",flexDirection:"column",position:"relative",fontFamily:d.FontFamily.MONOSPACE,lineHeight:"20px"},landingContainer:{display:"flex",alignItems:"center",justifyContent:"center",flex:1},landingMessage:{maxWidth:600},landingP:{marginBottom:16},hide:{display:"none"},browseButtonContainer:{display:"flex",alignItems:"center",justifyContent:"center"},browseButton:{marginBottom:16,height:72,flex:1,maxWidth:256,textAlign:"center",fontSize:d.FontSize.BIG_BUTTON,lineHeight:"72px",background:d.Colors.DARK_BLUE,color:"white",cursor:"pointer"},link:{color:d.Colors.LIGHT_BLUE,cursor:"pointer",textDecoration:"none"},toolbar:{height:18,background:"black",color:"white",textAlign:"center",fontFamily:d.FontFamily.MONOSPACE,fontSize:d.FontSize.TITLE,lineHeight:"18px",userSelect:"none"},toolbarLeft:{position:"absolute",height:18,overflow:"hidden",top:0,left:0,marginRight:2,textAlign:"left"},toolbarRight:{height:18,overflow:"hidden",position:"absolute",top:0,right:0,marginRight:2,textAlign:"right"},toolbarTab:{background:d.Colors.DARK_GRAY,marginTop:2,height:16,lineHeight:"16px",paddingLeft:2,paddingRight:8,display:"inline-block",marginLeft:2,":hover":{background:d.Colors.GRAY,cursor:"pointer"}},toolbarTabActive:{background:d.Colors.LIGHT_BLUE,":hover":{background:d.Colors.LIGHT_BLUE}},noLinkStyle:{textDecoration:"none",color:"inherit"},emoji:{display:"inline-block",verticalAlign:"middle",paddingTop:"0px",marginRight:"0.3em"}}); -},{"preact":4,"./reloadable":5,"./flamechart-view":6,"./flamechart-renderer":7,"./canvas-context":8,"./style":9,"./flamechart":10,"./import/bg-flamegraph":11,"./import/chrome":12,"./import/stackprof":13,"aphrodite":14}],1:[function(require,module,exports) { +},{"preact":4,"./reloadable":5,"./flamechart-view":6,"./flamechart-renderer":7,"./canvas-context":8,"./flamechart":9,"./style":10,"./import/bg-flamegraph":11,"./import/stackprof":12,"./import/chrome":13,"aphrodite":14}],1:[function(require,module,exports) { "use strict";function e(e){d=e,e&&i&&e.rehydrate(i)}Object.defineProperty(exports,"__esModule",{value:!0});const t=require("preact"),o=require("./application");let d=null;const i=window.__retained__;module.hot&&(module.hot.dispose(()=>{d&&(window.__retained__=d.serialize())}),module.hot.accept()),t.render(t.h(o.Application,{ref:e}),document.body,document.body.lastElementChild||void 0); },{"./application":2,"preact":4}]},{},[1]) \ No newline at end of file