!function(e,t){"use strict";function r(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function n(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}var a=n(e),o=r(t);function i(){var e=Object.create(null);function t(n,a){var o=n.id,i=n.name,s=n.dependencies;void 0===s&&(s=[]);var l=n.init;void 0===l&&(l=function(){});var u=n.getTransferables;if(void 0===u&&(u=null),!e[o])try{s=s.map((function(r){return r&&r.isWorkerModule&&(t(r,(function(e){if(e instanceof Error)throw e})),r=e[r.id].value),r})),l=r("<"+i+">.init",l),u&&(u=r("<"+i+">.getTransferables",u));var f=null;"function"==typeof l?f=l.apply(void 0,s):console.error("worker module init function failed to rehydrate"),e[o]={id:o,value:f,getTransferables:u},a(f)}catch(e){e&&e.noLog||console.error(e),a(e)}}function r(e,t){var r=void 0;self.troikaDefine=function(e){return r=e};var n=URL.createObjectURL(new Blob(["/** "+e.replace(/\*/g,"")+" **/\n\ntroikaDefine(\n"+t+"\n)"],{type:"application/javascript"}));try{importScripts(n)}catch(e){console.error(e)}return URL.revokeObjectURL(n),delete self.troikaDefine,r}self.addEventListener("message",(function(r){var n=r.data,a=n.messageId,o=n.action,i=n.data;try{"registerModule"===o&&t(i,(function(e){e instanceof Error?postMessage({messageId:a,success:!1,error:e.message}):postMessage({messageId:a,success:!0,result:{isCallable:"function"==typeof e}})})),"callModule"===o&&function(t,r){var n,a=t.id,o=t.args;e[a]&&"function"==typeof e[a].value||r(new Error("Worker module "+a+": not found or its 'init' did not return a function"));try{var i=(n=e[a]).value.apply(n,o);i&&"function"==typeof i.then?i.then(s,(function(e){return r(e instanceof Error?e:new Error(""+e))})):s(i)}catch(e){r(e)}function s(t){try{var n=e[a].getTransferables&&e[a].getTransferables(t);n&&Array.isArray(n)&&n.length||(n=void 0),r(t,n)}catch(e){console.error(e),r(e)}}}(i,(function(e,t){e instanceof Error?postMessage({messageId:a,success:!1,error:e.message}):postMessage({messageId:a,success:!0,result:e},t||void 0)}))}catch(e){postMessage({messageId:a,success:!1,error:e.stack})}}))}var s=function(){var e=!1;if("undefined"!=typeof window&&void 0!==window.document)try{new Worker(URL.createObjectURL(new Blob([""],{type:"application/javascript"}))).terminate(),e=!0}catch(e){"undefined"!=typeof process&&"test"===process.env.NODE_ENV||console.log("Troika createWorkerModule: web workers not allowed; falling back to main thread execution. Cause: ["+e.message+"]")}return s=function(){return e},e},l=0,u=0,f=!1,c=Object.create(null),h=Object.create(null),d=Object.create(null);function p(e){if(!(e&&"function"==typeof e.init||f))throw new Error("requires `options.init` function");var t=e.dependencies,r=e.init,n=e.getTransferables,a=e.workerId;if(!s())return function(e){var t=function(){for(var e=[],r=arguments.length;r--;)e[r]=arguments[r];return t._getInitResult().then((function(t){if("function"==typeof t)return t.apply(void 0,e);throw new Error("Worker module function was called but `init` did not return a callable function")}))};return t._getInitResult=function(){var r=e.dependencies,n=e.init;r=Array.isArray(r)?r.map((function(e){return e&&e._getInitResult?e._getInitResult():e})):[];var a=Promise.all(r).then((function(e){return n.apply(null,e)}));return t._getInitResult=function(){return a},a},t}(e);null==a&&(a="#default");var o="workerModule"+ ++l,i=e.name||o,u=null;function c(){for(var e=[],t=arguments.length;t--;)e[t]=arguments[t];if(!u){u=g(a,"registerModule",c.workerModuleData);var r=function(){u=null,h[a].delete(r)};(h[a]||(h[a]=new Set)).add(r)}return u.then((function(t){if(t.isCallable)return g(a,"callModule",{id:o,args:e});throw new Error("Worker module function was called but `init` did not return a callable function")}))}return t=t&&t.map((function(e){return"function"!=typeof e||e.workerModuleData||(f=!0,e=p({workerId:a,name:"<"+i+"> function dependency: "+e.name,init:"function(){return (\n"+v(e)+"\n)}"}),f=!1),e&&e.workerModuleData&&(e=e.workerModuleData),e})),c.workerModuleData={isWorkerModule:!0,id:o,name:i,dependencies:t,init:v(r),getTransferables:n&&v(n)},c}function v(e){var t=e.toString();return!/^function/.test(t)&&/^\w+\s*\(/.test(t)&&(t="function "+t),t}function g(e,t,r){return new Promise((function(n,a){var o=++u;d[o]=function(e){e.success?n(e.result):a(new Error("Error in worker "+t+" call: "+e.error))},function(e){var t=c[e];if(!t){var r=v(i);(t=c[e]=new Worker(URL.createObjectURL(new Blob(["/** Worker Module Bootstrap: "+e.replace(/\*/g,"")+" **/\n\n;("+r+")()"],{type:"application/javascript"})))).onmessage=function(e){var t=e.data,r=t.messageId,n=d[r];if(!n)throw new Error("WorkerModule response with empty or unknown messageId");delete d[r],n(t)}}return t}(e).postMessage({messageId:o,action:t,data:r})}))}function m(){var e=function(e){function t(e,t,r,n,a,o,i,s,l,u){var f=1-l;u.x=f*f*f*e+3*f*f*l*r+3*f*l*l*a+l*l*l*i,u.y=f*f*f*t+3*f*f*l*n+3*f*l*l*o+l*l*l*s}function r(e,t){for(var r,n,a,o,i,s=/([MLQCZ])([^MLQCZ]*)/g;r=s.exec(e);){var l=r[2].replace(/^\s*|\s*$/g,"").split(/[,\s]+/).map((function(e){return parseFloat(e)}));switch(r[1]){case"M":o=n=l[0],i=a=l[1];break;case"L":l[0]===o&&l[1]===i||t("L",o,i,o=l[0],i=l[1]);break;case"Q":t("Q",o,i,o=l[2],i=l[3],l[0],l[1]);break;case"C":t("C",o,i,o=l[4],i=l[5],l[0],l[1],l[2],l[3]);break;case"Z":o===n&&i===a||t("L",o,i,n,a)}}}function n(e,n,a){void 0===a&&(a=16);var o={x:0,y:0};r(e,(function(e,r,i,s,l,u,f,c,h){switch(e){case"L":n(r,i,s,l);break;case"Q":for(var d=r,p=i,v=1;v0;)n[a]=arguments[a+2];var o=s[t]||(s[t]=r.getUniformLocation(u,t));r["uniform"+e].apply(r,[o].concat(n))},setAttribute:function(e,t,n,o,s){var l=i[e];l||(l=i[e]={buf:r.createBuffer(),loc:r.getAttribLocation(u,e),data:null}),r.bindBuffer(r.ARRAY_BUFFER,l.buf),r.vertexAttribPointer(l.loc,t,r.FLOAT,!1,0,0),r.enableVertexAttribArray(l.loc),a?r.vertexAttribDivisor(l.loc,o):h("ANGLE_instanced_arrays").vertexAttribDivisorANGLE(l.loc,o),s!==l.data&&(r.bufferData(r.ARRAY_BUFFER,s,n),l.data=s)}})}}}l[e].transaction(o)}function v(e,t){f++;try{r.activeTexture(r.TEXTURE0+f);var n=u[e];n||(n=u[e]=r.createTexture(),r.bindTexture(r.TEXTURE_2D,n),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,r.NEAREST),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,r.NEAREST)),r.bindTexture(r.TEXTURE_2D,n),t(n,f)}finally{f--}}function g(e,t,n){var a=r.createFramebuffer();c.push(a),r.bindFramebuffer(r.FRAMEBUFFER,a),r.activeTexture(r.TEXTURE0+t),r.bindTexture(r.TEXTURE_2D,e),r.framebufferTexture2D(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0,r.TEXTURE_2D,e,0);try{n(a)}finally{r.deleteFramebuffer(a),r.bindFramebuffer(r.FRAMEBUFFER,c[--c.length-1]||null)}}function m(){s={},l={},u={},f=-1,c.length=0}r.canvas.addEventListener("webglcontextlost",(function(e){m(),e.preventDefault()}),!1),o.set(r,n={gl:r,isWebGL2:a,getExtension:h,withProgram:p,withTexture:v,withTextureFramebuffer:g,handleContextLoss:m})}t(n)}function l(e,t,r,n,o,i,l,u){void 0===l&&(l=15),void 0===u&&(u=null),s(e,(function(e){var s=e.gl,f=e.withProgram;(0,e.withTexture)("copy",(function(e,c){s.texImage2D(s.TEXTURE_2D,0,s.RGBA,o,i,0,s.RGBA,s.UNSIGNED_BYTE,t),f("copy",a,"precision highp float;uniform sampler2D tex;varying vec2 vUV;void main(){gl_FragColor=texture2D(tex,vUV);}",(function(e){var t=e.setUniform;(0,e.setAttribute)("aUV",2,s.STATIC_DRAW,0,new Float32Array([0,0,2,0,0,2])),t("1i","image",c),s.bindFramebuffer(s.FRAMEBUFFER,u||null),s.disable(s.BLEND),s.colorMask(8&l,4&l,2&l,1&l),s.viewport(r,n,o,i),s.scissor(r,n,o,i),s.drawArrays(s.TRIANGLES,0,3)}))}))}))}var u=Object.freeze({__proto__:null,withWebGLContext:s,renderImageData:l,resizeWebGLCanvasWithoutClearing:function(e,t,r){var n=e.width,a=e.height;s(e,(function(o){var i=o.gl,s=new Uint8Array(n*a*4);i.readPixels(0,0,n,a,i.RGBA,i.UNSIGNED_BYTE,s),e.width=t,e.height=r,l(i,s,0,0,n,a)}))}});function f(e,t,r,a,o,i){void 0===i&&(i=1);var s=new Uint8Array(e*t),l=a[2]-a[0],u=a[3]-a[1],f=[];n(r,(function(e,t,r,n){f.push({x1:e,y1:t,x2:r,y2:n,minX:Math.min(e,r),minY:Math.min(t,n),maxX:Math.max(e,r),maxY:Math.max(t,n)})})),f.sort((function(e,t){return e.maxX-t.maxX}));for(var c=0;co.minX&&t-no.minY){var i=d(e,t,o.x1,o.y1,o.x2,o.y2);it!=a.y2>t&&e<(a.x2-a.x1)*(t-a.y1)/(a.y2-a.y1)+a.x1&&(r+=a.y1p.y!=seg.w>p.y)&&(p.x<(seg.z-seg.x)*(p.y-seg.y)/(seg.w-seg.y)+seg.x);bool crossingUp=crossing&&vLineSegment.y/gm,(function(t,r){let n=e.ShaderChunk[r];return n?b(n):t}))}const x=[];for(let e=0;e<256;e++)x[e]=(e<16?"0":"")+e.toString(16);const S=Object.assign||function(){let e=arguments[0];for(let t=1,r=arguments.length;t/gm,"\n//!BEGIN_POST_CHUNK $1\n$&\n//!END_POST_CHUNK\n")));if(d){let e=d({vertexShader:t,fragmentShader:r});t=e.vertexShader,r=e.fragmentShader}if(h){let e=[];r=r.replace(/^\/\/!BEGIN_POST_CHUNK[^]+?^\/\/!END_POST_CHUNK/gm,(t=>(e.push(t),""))),c=`${h}\n${e.join("\n")}\n${c}`}if(p){const e=`\nuniform float ${p};\n`;o=e+o,u=e+u}l&&(o=`${o}\nvoid troikaVertexTransform${a}(inout vec3 position, inout vec3 normal, inout vec2 uv) {\n ${l}\n}\n`,i=`\ntroika_position_${a} = vec3(position);\ntroika_normal_${a} = vec3(normal);\ntroika_uv_${a} = vec2(uv);\ntroikaVertexTransform${a}(troika_position_${a}, troika_normal_${a}, troika_uv_${a});\n${i}\n`,t=(t=`vec3 troika_position_${a};\nvec3 troika_normal_${a};\nvec2 troika_uv_${a};\n${t}\n`).replace(/\b(position|normal|uv)\b/g,((e,t,r,n)=>/\battribute\s+vec[23]\s+$/.test(n.substr(0,r))?t:`troika_${t}_${a}`)),e.map&&e.map.channel>0||(t=t.replace(/\bMAP_UV\b/g,`troika_uv_${a}`)));return t=F(t,a,o,i,s),r=F(r,a,u,f,c),{vertexShader:t,fragmentShader:r}}(this,e,r,n);s=w[i]=t}e.vertexShader=s.vertexShader,e.fragmentShader=s.fragmentShader,S(e.uniforms,this.uniforms),r.timeUniform&&(e.uniforms[r.timeUniform]={get value(){return Date.now()-U}}),this[o]&&this[o](e)},s=function(){return l(r.chained?t:t.clone())},l=function(e){const a=Object.create(e,u);return Object.defineProperty(a,"baseMaterial",{value:t}),Object.defineProperty(a,"id",{value:T++}),a.uuid=function(){const e=4294967295*Math.random()|0,t=4294967295*Math.random()|0,r=4294967295*Math.random()|0,n=4294967295*Math.random()|0;return(x[255&e]+x[e>>8&255]+x[e>>16&255]+x[e>>24&255]+"-"+x[255&t]+x[t>>8&255]+"-"+x[t>>16&15|64]+x[t>>24&255]+"-"+x[63&r|128]+x[r>>8&255]+"-"+x[r>>16&255]+x[r>>24&255]+x[255&n]+x[n>>8&255]+x[n>>16&255]+x[n>>24&255]).toUpperCase()}(),a.uniforms=S({},e.uniforms,r.uniforms),a.defines=S({},e.defines,r.defines),a.defines[`TROIKA_DERIVED_MATERIAL_${n}`]="",a.extensions=S({},e.extensions,r.extensions),a._listeners=void 0,a},u={constructor:{value:s},isDerivedMaterial:{value:!0},customProgramCacheKey:{writable:!0,configurable:!0,value:function(){return t.customProgramCacheKey()+"|"+n}},onBeforeCompile:{get:()=>i,set(e){this[o]=e}},copy:{writable:!0,configurable:!0,value:function(r){return t.copy.call(this,r),t.isShaderMaterial||t.isDerivedMaterial||(S(this.extensions,r.extensions),S(this.defines,r.defines),S(this.uniforms,e.UniformsUtils.clone(r.uniforms))),this}},clone:{writable:!0,configurable:!0,value:function(){const e=new t.constructor;return l(e).copy(this)}},getDepthMaterial:{writable:!0,configurable:!0,value:function(){let n=this._depthMaterial;return n||(n=this._depthMaterial=_(t.isDerivedMaterial?t.getDepthMaterial():new e.MeshDepthMaterial({depthPacking:e.RGBADepthPacking}),r),n.defines.IS_DEPTH_MATERIAL="",n.uniforms=this.uniforms),n}},getDistanceMaterial:{writable:!0,configurable:!0,value:function(){let n=this._distanceMaterial;return n||(n=this._distanceMaterial=_(t.isDerivedMaterial?t.getDistanceMaterial():new e.MeshDistanceMaterial,r),n.defines.IS_DISTANCE_MATERIAL="",n.uniforms=this.uniforms),n}},dispose:{writable:!0,configurable:!0,value(){const{_depthMaterial:e,_distanceMaterial:r}=this;e&&e.dispose(),r&&r.dispose(),t.dispose.call(this)}}};return a[n]=s,new s}function F(e,t,r,n,a){return(n||a||r)&&(e=e.replace(y,`\n${r}\nvoid troikaOrigMain${t}() {`),e+=`\nvoid main() {\n ${n}\n troikaOrigMain${t}();\n ${a}\n}`),e}function C(e,t){return"uniforms"===e?void 0:"function"==typeof t?t.toString():t}let D=0;const A=new Map;const O=p({name:"Typr Font Parser",dependencies:[function(){return"undefined"==typeof window&&(self.window=self),function(e){var t={parse:function(e){var r=t._bin,n=new Uint8Array(e);if("ttcf"==r.readASCII(n,0,4)){var a=4;r.readUshort(n,a),a+=2,r.readUshort(n,a),a+=2;var o=r.readUint(n,a);a+=4;for(var i=[],s=0;s>>r&1)&&t++;return t},t._lctf.readClassDef=function(e,r){var n=t._bin,a=[],o=n.readUshort(e,r);if(r+=2,1==o){var i=n.readUshort(e,r);r+=2;var s=n.readUshort(e,r);r+=2;for(var l=0;l0&&(o.featureParams=a+i);var s=n.readUshort(e,r);r+=2,o.tab=[];for(var l=0;l0&&(o.default=t._lctf.readLangSysTable(e,a+i));var s=n.readUshort(e,r);r+=2;for(var l=0;l255?-1:t.CFF.glyphByUnicode(e,t.CFF.tableSE[r])},t.CFF.readEncoding=function(e,r,n){t._bin;var a=[".notdef"],o=e[r];if(r++,0!=o)throw"error: unknown encoding format: "+o;var i=e[r];r++;for(var s=0;s>4,v=15&d;if(15!=p&&h.push(p),15!=v&&h.push(v),15==v)break}for(var g="",m=[0,1,2,3,4,5,6,7,8,9,".","e","e-","reserved","-","endOfNumber"],y=0;y=i.xMax||i.yMin>=i.yMax)return null;if(i.noc>0){i.endPts=[];for(var s=0;s=1&&s.fmt<=2){u=o.readUshort(e,n),n+=2;var c=o.readUshort(e,n);n+=2,f=t._lctf.numOfOnes(u);var h=t._lctf.numOfOnes(c);if(1==s.fmt){s.pairsets=[];var d=o.readUshort(e,n);n+=2;for(var p=0;p=1&&s.fmt<=2){if(1==s.fmt)s.delta=o.readShort(e,n),n+=2;else if(2==s.fmt){var u=o.readUshort(e,n);n+=2,s.newg=o.readUshorts(e,n,u),n+=2*s.newg.length}}else if(4==r){s.vals=[],u=o.readUshort(e,n),n+=2;for(var f=0;f>>8;if(0!=(c&=15))throw"unknown kern table format: "+c;r=t.kern.readFormat0(e,r,l)}return l},t.kern.parseV1=function(e,r,n,a){var o=t._bin;o.readFixed(e,r),r+=4;var i=o.readUint(e,r);r+=4;for(var s={glyph1:[],rval:[]},l=0;l>>8;if(0!=(f&=15))throw"unknown kern table format: "+f;r=t.kern.readFormat0(e,r,s)}return s},t.kern.readFormat0=function(e,r,n){var a=t._bin,o=-1,i=a.readUshort(e,r);r+=2,a.readUshort(e,r),r+=2,a.readUshort(e,r),r+=2,a.readUshort(e,r),r+=2;for(var s=0;s=a.map.length?0:a.map[t];if(4==a.format){for(var o=-1,i=0;it?0:65535&(0!=a.idRangeOffset[o]?a.glyphIdArray[t-a.startCount[o]+(a.idRangeOffset[o]>>1)-(a.idRangeOffset.length-o)]:t+a.idDelta[o])}if(12==a.format){if(t>a.groups[a.groups.length-1][1])return 0;for(i=0;i-1?t.U._simpleGlyph(a,n):t.U._compoGlyph(a,r,n))},t.U._simpleGlyph=function(e,r){for(var n=0;no)){for(var d=!0,p=0,v=0;vo)){for(d=!0,v=0;v>1,i.length=0,l=!0;else if("o3"==T||"o23"==T)i.length%2!=0&&!l&&(u=i.shift()+a.nominalWidthX),s+=i.length>>1,i.length=0,l=!0;else if("o4"==T)i.length>1&&!l&&(u=i.shift()+a.nominalWidthX,l=!0),f&&t.U.P.closePath(o),d+=i.pop(),t.U.P.moveTo(o,h,d),f=!0;else if("o5"==T)for(;i.length>0;)h+=i.shift(),d+=i.shift(),t.U.P.lineTo(o,h,d);else if("o6"==T||"o7"==T)for(var _=i.length,F="o6"==T,C=0;C<_;C++){var D=i.shift();F?h+=D:d+=D,F=!F,t.U.P.lineTo(o,h,d)}else if("o8"==T||"o24"==T){_=i.length;for(var A=0;A+6<=_;)p=h+i.shift(),v=d+i.shift(),g=p+i.shift(),m=v+i.shift(),h=g+i.shift(),d=m+i.shift(),t.U.P.curveTo(o,p,v,g,m,h,d),A+=6;"o24"==T&&(h+=i.shift(),d+=i.shift(),t.U.P.lineTo(o,h,d))}else{if("o11"==T)break;if("o1234"==T||"o1235"==T||"o1236"==T||"o1237"==T)"o1234"==T&&(v=d,g=(p=h+i.shift())+i.shift(),k=m=v+i.shift(),b=m,S=d,h=(x=(y=(U=g+i.shift())+i.shift())+i.shift())+i.shift(),t.U.P.curveTo(o,p,v,g,m,U,k),t.U.P.curveTo(o,y,b,x,S,h,d)),"o1235"==T&&(p=h+i.shift(),v=d+i.shift(),g=p+i.shift(),m=v+i.shift(),U=g+i.shift(),k=m+i.shift(),y=U+i.shift(),b=k+i.shift(),x=y+i.shift(),S=b+i.shift(),h=x+i.shift(),d=S+i.shift(),i.shift(),t.U.P.curveTo(o,p,v,g,m,U,k),t.U.P.curveTo(o,y,b,x,S,h,d)),"o1236"==T&&(p=h+i.shift(),v=d+i.shift(),g=p+i.shift(),k=m=v+i.shift(),b=m,x=(y=(U=g+i.shift())+i.shift())+i.shift(),S=b+i.shift(),h=x+i.shift(),t.U.P.curveTo(o,p,v,g,m,U,k),t.U.P.curveTo(o,y,b,x,S,h,d)),"o1237"==T&&(p=h+i.shift(),v=d+i.shift(),g=p+i.shift(),m=v+i.shift(),U=g+i.shift(),k=m+i.shift(),y=U+i.shift(),b=k+i.shift(),x=y+i.shift(),S=b+i.shift(),Math.abs(x-h)>Math.abs(S-d)?h=x+i.shift():d=S+i.shift(),t.U.P.curveTo(o,p,v,g,m,U,k),t.U.P.curveTo(o,y,b,x,S,h,d));else if("o14"==T){if(i.length>0&&!l&&(u=i.shift()+n.nominalWidthX,l=!0),4==i.length){var O=i.shift(),R=i.shift(),E=i.shift(),M=i.shift(),I=t.CFF.glyphBySE(n,E),P=t.CFF.glyphBySE(n,M);t.U._drawCFF(n.CharStrings[I],r,n,a,o),r.x=O,r.y=R,t.U._drawCFF(n.CharStrings[P],r,n,a,o)}f&&(t.U.P.closePath(o),f=!1)}else if("o19"==T||"o20"==T)i.length%2!=0&&!l&&(u=i.shift()+a.nominalWidthX),s+=i.length>>1,i.length=0,l=!0,c+=s+7>>3;else if("o21"==T)i.length>2&&!l&&(u=i.shift()+a.nominalWidthX,l=!0),d+=i.pop(),h+=i.pop(),f&&t.U.P.closePath(o),t.U.P.moveTo(o,h,d),f=!0;else if("o22"==T)i.length>1&&!l&&(u=i.shift()+a.nominalWidthX,l=!0),h+=i.pop(),f&&t.U.P.closePath(o),t.U.P.moveTo(o,h,d),f=!0;else if("o25"==T){for(;i.length>6;)h+=i.shift(),d+=i.shift(),t.U.P.lineTo(o,h,d);p=h+i.shift(),v=d+i.shift(),g=p+i.shift(),m=v+i.shift(),h=g+i.shift(),d=m+i.shift(),t.U.P.curveTo(o,p,v,g,m,h,d)}else if("o26"==T)for(i.length%2&&(h+=i.shift());i.length>0;)p=h,v=d+i.shift(),h=g=p+i.shift(),d=(m=v+i.shift())+i.shift(),t.U.P.curveTo(o,p,v,g,m,h,d);else if("o27"==T)for(i.length%2&&(d+=i.shift());i.length>0;)v=d,g=(p=h+i.shift())+i.shift(),m=v+i.shift(),h=g+i.shift(),d=m,t.U.P.curveTo(o,p,v,g,m,h,d);else if("o10"==T||"o29"==T){var B="o10"==T?a:n;if(0==i.length)console.debug("error: empty stack");else{var G=i.pop(),L=B.Subrs[G+B.Bias];r.x=h,r.y=d,r.nStems=s,r.haveWidth=l,r.width=u,r.open=f,t.U._drawCFF(L,r,n,a,o),h=r.x,d=r.y,s=r.nStems,l=r.haveWidth,u=r.width,f=r.open}}else if("o30"==T||"o31"==T){var W=i.length,j=(A=0,"o31"==T);for(A+=W-(_=-3&W);A<_;)j?(v=d,g=(p=h+i.shift())+i.shift(),d=(m=v+i.shift())+i.shift(),_-A==5?(h=g+i.shift(),A++):h=g,j=!1):(p=h,v=d+i.shift(),g=p+i.shift(),m=v+i.shift(),h=g+i.shift(),_-A==5?(d=m+i.shift(),A++):d=m,j=!0),t.U.P.curveTo(o,p,v,g,m,h,d),A+=4}else{if("o"==(T+"").charAt(0))throw console.debug("Unknown operation: "+T,e),T;i.push(T)}}}r.x=h,r.y=d,r.nStems=s,r.haveWidth=l,r.width=u,r.open=f};var r=t,n={Typr:r};return e.Typr=r,e.default=n,Object.defineProperty(e,"__esModule",{value:!0}),e}({}).Typr} /*! Custom bundle of woff2otf (https://github.com/arty-name/woff2otf) with fflate (https://github.com/101arrowz/fflate) for use in Troika text rendering. Original licenses apply: - fflate: https://github.com/101arrowz/fflate/blob/master/LICENSE (MIT) - woff2otf.js: https://github.com/arty-name/woff2otf/blob/master/woff2otf.js (Apache2) */,function(){return function(e){var t=Uint8Array,r=Uint16Array,n=Uint32Array,a=new t([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),o=new t([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),i=new t([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),s=function(e,t){for(var a=new r(31),o=0;o<31;++o)a[o]=t+=1<>>1|(21845&d)<<1;p=(61680&(p=(52428&p)>>>2|(13107&p)<<2))>>>4|(3855&p)<<4,h[d]=((65280&p)>>>8|(255&p)<<8)>>>1}var v=function(e,t,n){for(var a=e.length,o=0,i=new r(t);o>>u]=f}else for(s=new r(a),o=0;o>>15-e[o]);return s},g=new t(288);for(d=0;d<144;++d)g[d]=8;for(d=144;d<256;++d)g[d]=9;for(d=256;d<280;++d)g[d]=7;for(d=280;d<288;++d)g[d]=8;var m=new t(32);for(d=0;d<32;++d)m[d]=5;var y=v(g,9,1),b=v(m,5,1),x=function(e){for(var t=e[0],r=1;rt&&(t=e[r]);return t},S=function(e,t,r){var n=t/8|0;return(e[n]|e[n+1]<<8)>>(7&t)&r},U=function(e,t){var r=t/8|0;return(e[r]|e[r+1]<<8|e[r+2]<<16)>>(7&t)},k=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],w=function(e,t,r){var n=new Error(t||k[e]);if(n.code=e,Error.captureStackTrace&&Error.captureStackTrace(n,w),!r)throw n;return n},T=function(e,s,l){var f=e.length;if(!f||l&&!l.l&&f<5)return s||new t(0);var h=!s||l,d=!l||l.i;l||(l={}),s||(s=new t(3*f));var p,g=function(e){var r=s.length;if(e>r){var n=new t(Math.max(2*r,e));n.set(s),s=n}},m=l.f||0,k=l.p||0,T=l.b||0,_=l.l,F=l.d,C=l.m,D=l.n,A=8*f;do{if(!_){l.f=m=S(e,k,1);var O=S(e,k+1,3);if(k+=3,!O){var R=e[(N=((p=k)/8|0)+(7&p&&1)+4)-4]|e[N-3]<<8,E=N+R;if(E>f){d&&w(0);break}h&&g(T+R),s.set(e.subarray(N,E),T),l.b=T+=R,l.p=k=8*E;continue}if(1==O)_=y,F=b,C=9,D=5;else if(2==O){var M=S(e,k,31)+257,I=S(e,k+10,15)+4,P=M+S(e,k+5,31)+1;k+=14;for(var B=new t(P),G=new t(19),L=0;L>>4)<16)B[L++]=N;else{var X=0,q=0;for(16==N?(q=3+S(e,k,3),k+=2,X=B[L-1]):17==N?(q=3+S(e,k,7),k+=3):18==N&&(q=11+S(e,k,127),k+=7);q--;)B[L++]=X}}var H=B.subarray(0,M),$=B.subarray(M);C=x(H),D=x($),_=v(H,C,1),F=v($,D,1)}else w(1);if(k>A){d&&w(0);break}}h&&g(T+131072);for(var Y=(1<>>4;if((k+=15&X)>A){d&&w(0);break}if(X||w(2),J<256)s[T++]=J;else{if(256==J){K=k,_=null;break}var Q=J-254;if(J>264){var ee=a[L=J-257];Q=S(e,k,(1<>>4;if(te||w(3),k+=15&te,$=c[re],re>3&&(ee=o[re],$+=U(e,k)&(1<A){d&&w(0);break}h&&g(T+131072);for(var ne=T+Q;Te.length)&&(o=e.length);var i=new(e instanceof r?r:e instanceof n?n:t)(o-a);return i.set(e.subarray(a,o)),i}(s,0,T)},_=new t(0),F="undefined"!=typeof TextDecoder&&new TextDecoder;try{F.decode(_,{stream:!0})}catch(e){}return e.convert_streams=function(e){var t=new DataView(e),r=0;function n(){var e=t.getUint16(r);return r+=2,e}function a(){var e=t.getUint32(r);return r+=4,e}function o(e){m.setUint16(y,e),y+=2}function i(e){m.setUint32(y,e),y+=4}for(var s={signature:a(),flavor:a(),length:a(),numTables:n(),reserved:n(),totalSfntSize:a(),majorVersion:n(),minorVersion:n(),metaOffset:a(),metaLength:a(),metaOrigLength:a(),privOffset:a(),privLength:a()},l=0;Math.pow(2,l)<=s.numTables;)l++;l--;for(var u=16*Math.pow(2,l),f=16*s.numTables-u,c=12,h=[],d=0;d{let[o,i]=n.split("+");o=parseInt(o,36),i=i?parseInt(i,36):0,a.set(r+=o,e[t]);for(let n=i;n--;)a.set(++r,e[t])}))}}return a.get(e)||32}const i=[null,"isol","init","fina","medi"];function s(e){const t=new Uint8Array(e.length);let r=32,n=1,a=-1;for(let i=0;i65535&&i++)}return t}function l(...e){for(let t=0;te.U.codeToGlyph(t,r)>0,forEachGlyph(a,o,l,u){let f=0;const h=1/c.unitsPerEm*o,d=function(t,r){const n=[];for(let a=0;a65535&&a++,n.push(e.U.codeToGlyph(t,o))}const a=t.GSUB;if(a){const{lookupList:t,featureList:o}=a;let l;const u=/^(rlig|liga|mset|isol|init|fina|medi|half|pres|blws)$/,f=[];o.forEach((a=>{if(u.test(a.tag))for(let o=0;o{if(-1!==i){let a=n[i];if(!a){const{cmds:o,crds:s}=e.U.glyphToPath(t,i);let l,u,f,c,h="",d=0;for(let e=0,t=o.length;e1?",":"")+s[d++]}if(s.length){l=u=1/0,f=c=-1/0;for(let e=0,t=s.length;ef&&(f=t),r>c&&(c=r)}}else l=f=u=c=0;a=n[i]={index:i,advanceWidth:t.hmtx.aWidth[i],xMin:l,yMin:u,xMax:f,yMax:c,path:h,pathCommandCount:o.length}}-1!==v&&(f+=e.U.getPairAdjustment(t,v,i)*h),u.call(null,a,f,p),a.advanceWidth&&(f+=a.advanceWidth*h),l&&(f+=l*o),v=i}p+=a.codePointAt(p)>65535?2:1})),f}};return c}return function(r){const n=new Uint8Array(r,0,4),a=e._bin.readASCII(n,0,4);if("wOFF"===a)r=t(r);else if("wOF2"===a)throw new Error("woff2 fonts not supported");return u(e.parse(r)[0])}}],init:(e,t,r)=>r(e(),t())}); /*! Custom bundle of @unicode-font-resolver/client v1.0.0 (https://github.com/lojjic/unicode-font-resolver) for use in Troika text rendering. Original MIT license applies */const R=p({name:"FontResolver",dependencies:[function(e,t){const r=Object.create(null),n=Object.create(null);function a(t,a){let o=r[t];o?a(o):n[t]?n[t].push(a):(n[t]=[a],function(t,r){const n=e=>{console.error(`Failure loading font ${t}`,e)};try{const a=new XMLHttpRequest;a.open("get",t,!0),a.responseType="arraybuffer",a.onload=function(){if(a.status>=400)n(new Error(a.statusText));else if(a.status>0)try{const n=e(a.response);n.src=t,r(n)}catch(e){n(e)}},a.onerror=n,a.send()}catch(e){n(e)}}(t,(e=>{e.src=t,r[t]=e,n[t].forEach((t=>t(e))),delete n[t]})))}return function(e,n,{lang:o,fonts:i=[],style:s="normal",weight:l="normal",unicodeFontsURL:u}={}){const f=new Uint8Array(e.length),c=[];e.length||v();const h=new Map,d=[];if("italic"!==s&&(s="normal"),"number"!=typeof l&&(l="bold"===l?700:400),i&&!Array.isArray(i)&&(i=[i]),(i=i.slice().filter((e=>!e.lang||e.lang.test(o))).reverse()).length){const t=1,n=2;let o=0;!function s(l=0){for(let u=l,p=e.length;u{s(u)}));if(e.supportsCodePoint(l)){let r=h.get(e);"number"!=typeof r&&(r=c.length,c.push(e),h.set(e,r)),f[u]=r,o=t;break}}}l>65535&&u+1e.substring(t[0],t[1]+1))).join("\n");t.getFontsForString(r,{lang:o,style:s,weight:l,dataUrl:u}).then((({fontUrls:e,chars:t})=>{const r=c.length;let n=0;d.forEach((e=>{for(let a=0,o=e[1]-e[0];a<=o;a++)f[e[0]+a]=t[n++]+r;n++}));let o=0;e.forEach(((t,n)=>{a(t,(t=>{c[n+r]=t,++o===e.length&&v()}))}))}))}else v()}function v(){n({chars:f,fonts:c})}function g(e,t){for(let r=0;r>5;this.buckets.set(t,(this.buckets.get(t)||0)|1<<(31&e))},t.prototype.has=function(e){var t=this.buckets.get(e>>5);return void 0!==t&&0!=(t&1<<(31&e))},t.prototype.serialize=function(){var e=[];return this.buckets.forEach((function(t,r){e.push((+r).toString(36)+":"+t.toString(36))})),e.join(",")},t.prototype.deserialize=function(e){var t=this;this.buckets.clear(),e.split(",").forEach((function(e){var r=e.split(":");t.buckets.set(parseInt(r[0],36),parseInt(r[1],36))}))};var r=Math.pow(2,8),n=r-1,a=~n;function o(e){var t=function(e){return e&a}(e).toString(16),n=function(e){return(e&a)+r-1}(e).toString(16);return"codepoint-index/plane"+(e>>16)+"/"+t+"-"+n+".json"}function i(e,t){var r=e&n,a=t.codePointAt(r/6|0);return 0!=((a=(a||48)-48)&1<65535&&(t++,_=t)},_=0;_65535&&(t++,n=t)},n=0;n65535&&(o++,y[o]=y[o-1])}return{fontUrls:Array.from(d.keys()),chars:y}}))},Object.defineProperty(e,"__esModule",{value:!0}),e}({})}],init:(e,t,r)=>e(t,r())});const E=()=>(self.performance||Date).now(),M=m();let I;const P=[];let B=0;function G(){const e=E();for(;P.length&&E()-e<5;)P.shift()();B=P.length?setTimeout(G,0):0}const L=(...e)=>new Promise(((t,r)=>{P.push((()=>{const n=E();try{M.webgl.generateIntoCanvas(...e),t({timing:E()-n})}catch(e){r(e)}})),B||(B=setTimeout(G,0))})),W={};let j=0;function z(e,t,r,n,a,o,i,s,l,u){const f="TroikaTextSDFGenerator_JS_"+j++%4;let d=W[f];return d||(d=W[f]={workerModule:p({name:f,workerId:f,dependencies:[m,E],init(e,t){const r=e().javascript.generate;return function(...e){const n=t();return{textureData:r(...e),timing:t()-n}}},getTransferables:e=>[e.textureData.buffer]}),requests:0,idleTimer:null}),d.requests++,clearTimeout(d.idleTimer),d.workerModule(e,t,r,n,a,o).then((({textureData:r,timing:n})=>{const a=E(),o=new Uint8Array(4*r.length);for(let e=0;e{!function(e){h[e]&&h[e].forEach((function(e){e()})),c[e]&&(c[e].terminate(),delete c[e])}(f)}),2e3)),{timing:n}}))}const N=M.webglUtils.resizeWebGLCanvasWithoutClearing,V={defaultFontURL:null,unicodeFontsURL:null,sdfGlyphSize:64,sdfMargin:1/16,sdfExponent:9,textureWidth:2048},X=new e.Color;function q(){return(self.performance||Date).now()}const H=Object.create(null);function $(t,r){t=function(e,t){for(let r in t)t.hasOwnProperty(r)&&(e[r]=t[r]);return e}({},t);const n=q(),{defaultFontURL:a}=V,o=[];if(a&&o.push({label:"default",src:K(a)}),t.font&&o.push({label:"user",src:K(t.font)}),t.font=o,t.text=""+t.text,t.sdfGlyphSize=t.sdfGlyphSize||V.sdfGlyphSize,t.unicodeFontsURL=t.unicodeFontsURL||V.unicodeFontsURL,null!=t.colorRanges){let e={};for(let r in t.colorRanges)if(t.colorRanges.hasOwnProperty(r)){let n=t.colorRanges[r];"number"!=typeof n&&(n=X.set(n).getHex()),e[r]=n}t.colorRanges=e}Object.freeze(t);const{textureWidth:i,sdfExponent:s}=V,{sdfGlyphSize:l}=t,u=i/l*4;let f=H[l];if(!f){const t=document.createElement("canvas");t.width=i,t.height=256*l/u,f=H[l]={glyphCount:0,sdfGlyphSize:l,sdfCanvas:t,sdfTexture:new e.Texture(t,void 0,void 0,void 0,e.LinearFilter,e.LinearFilter),contextLost:!1,glyphsByFont:new Map},f.sdfTexture.generateMipmaps=!1,function(e){const t=e.sdfCanvas;t.addEventListener("webglcontextlost",(t=>{console.log("Context Lost",t),t.preventDefault(),e.contextLost=!0})),t.addEventListener("webglcontextrestored",(t=>{console.log("Context Restored",t),e.contextLost=!1;const r=[];e.glyphsByFont.forEach((t=>{t.forEach((t=>{r.push(Y(t,e,!0))}))})),Promise.all(r).then((()=>{J(e),e.sdfTexture.needsUpdate=!0}))}))}(f)}const{sdfTexture:c,sdfCanvas:h}=f;ee(t).then((e=>{const{glyphIds:a,glyphFontIndices:o,fontData:d,glyphPositions:p,fontSize:v,timings:g}=e,m=[],y=new Float32Array(4*a.length);let b=0,x=0;const S=q(),U=d.map((e=>{let t=f.glyphsByFont.get(e.src);return t||f.glyphsByFont.set(e.src,t=new Map),t}));a.forEach(((t,r)=>{const n=o[r],{src:i,unitsPerEm:s}=d[n];let u=U[n].get(t);if(!u){const{path:r,pathBounds:a}=e.glyphData[i][t],o=Math.max(a[2]-a[0],a[3]-a[1])/l*(V.sdfMargin*l+.5),s=f.glyphCount++,c=[a[0]-o,a[1]-o,a[2]+o,a[3]+o];U[n].set(t,u={path:r,atlasIndex:s,sdfViewBox:c}),m.push(u)}const{sdfViewBox:c}=u,h=p[x++],g=p[x++],S=v/s;y[b++]=h+c[0]*S,y[b++]=g+c[1]*S,y[b++]=h+c[2]*S,y[b++]=g+c[3]*S,a[r]=u.atlasIndex})),g.quads=(g.quads||0)+(q()-S);const k=q();g.sdf={};const w=h.height,T=Math.ceil(f.glyphCount/u),_=Math.pow(2,Math.ceil(Math.log2(T*l)));_>w&&(console.info(`Increasing SDF texture size ${w}->${_}`),N(h,i,_),c.dispose()),Promise.all(m.map((e=>Y(e,f,t.gpuAccelerateSDF).then((({timing:t})=>{g.sdf[e.atlasIndex]=t}))))).then((()=>{m.length&&!f.contextLost&&(J(f),c.needsUpdate=!0),g.sdfTotal=q()-k,g.total=q()-n,r(Object.freeze({parameters:t,sdfTexture:c,sdfGlyphSize:l,sdfExponent:s,glyphBounds:y,glyphAtlasIndices:a,glyphColors:e.glyphColors,caretPositions:e.caretPositions,chunkedBounds:e.chunkedBounds,ascender:e.ascender,descender:e.descender,lineHeight:e.lineHeight,capHeight:e.capHeight,xHeight:e.xHeight,topBaseline:e.topBaseline,blockBounds:e.blockBounds,visibleBounds:e.visibleBounds,timings:e.timings}))}))})),Promise.resolve().then((()=>{var e;f.contextLost||(e=h)._warm||(M.webgl.isSupported(e),e._warm=!0)}))}function Y({path:e,atlasIndex:t,sdfViewBox:r},{sdfGlyphSize:n,sdfCanvas:a,contextLost:o},i){if(o)return Promise.resolve({timing:-1});const{textureWidth:s,sdfExponent:l}=V,u=Math.max(r[2]-r[0],r[3]-r[1]),f=Math.floor(t/4);return function(e,t,r,n,a,o,i,s,l,u,f=!0){return f?L(e,t,r,n,a,o,i,s,l,u).then(null,(f=>(I||(console.warn("WebGL SDF generation failed, falling back to JS",f),I=!0),z(e,t,r,n,a,o,i,s,l,u)))):z(e,t,r,n,a,o,i,s,l,u)}(n,n,e,r,u,l,a,f%(s/n)*n,Math.floor(f/(s/n))*n,t%4,i)}let Z;function K(e){return Z||(Z="undefined"==typeof document?{}:document.createElement("a")),Z.href=e,Z.href}function J(e){if("function"!=typeof createImageBitmap){console.info("Safari<15: applying SDF canvas workaround");const{sdfCanvas:t,sdfTexture:r}=e,{width:n,height:a}=t,o=e.sdfCanvas.getContext("webgl");let i=r.image.data;i&&i.length===n*a*4||(i=new Uint8Array(n*a*4),r.image={width:n,height:a,data:i},r.flipY=!1,r.isDataTexture=!0),o.readPixels(0,0,n,a,o.RGBA,o.UNSIGNED_BYTE,i)}}const Q=p({name:"Typesetter",dependencies:[function(e,t){const r=1/0,n=/[\u00AD\u034F\u061C\u115F-\u1160\u17B4-\u17B5\u180B-\u180E\u200B-\u200F\u202A-\u202E\u2060-\u206F\u3164\uFE00-\uFE0F\uFEFF\uFFA0\uFFF0-\uFFF8]/,a="[^\\S\\u00A0]",o=new RegExp("[^\\S\\u00A0]|[\\-\\u007C\\u00AD\\u2010\\u2012-\\u2014\\u2027\\u2056\\u2E17\\u2E40]");function i({text:i="",font:c,lang:h="en",sdfGlyphSize:d=64,fontSize:p=400,fontWeight:v=1,fontStyle:g="normal",letterSpacing:m=0,lineHeight:y="normal",maxWidth:b=r,direction:x,textAlign:S="left",textIndent:U=0,whiteSpace:k="normal",overflowWrap:w="normal",anchorX:T=0,anchorY:_=0,metricsOnly:F=!1,unicodeFontsURL:C,preResolvedFonts:D=null,includeCaretPositions:A=!1,chunkedBoundsSize:O=8192,colorRanges:R=null},E){const M=u(),I={fontLoad:0,typesetting:0};i.indexOf("\r")>-1&&(console.info("Typesetter: got text with \\r chars; normalizing to \\n"),i=i.replace(/\r\n/g,"\n").replace(/\r/g,"\n")),p=+p,m=+m,b=+b,y=y||"normal",U=+U,function({text:t,lang:r,fonts:n,style:a,weight:o,preResolvedFonts:i,unicodeFontsURL:s},l){const u=({chars:e,fonts:t})=>{let r,n;const a=[];for(let o=0;o{I.fontLoad=u()-M;const c=isFinite(b);let h=null,d=null,v=null,g=null,C=null,D=null,P=null,B=null,G=0,L=0,W="nowrap"!==k;const j=new Map,z=u();let N=U,V=0,X=new f;const q=[X];e.forEach((e=>{const{fontObj:t}=e,{ascender:r,descender:s,unitsPerEm:l,lineGap:u,capHeight:h,xHeight:d}=t;let v=j.get(t);if(!v){const e=p/l,n="normal"===y?(r-s+u)*e:y*p,a=(n-(r-s)*e)/2,o=Math.min(n,(r-s)*e),i=(r+s)/2*e+o/2;v={index:j.size,src:t.src,fontObj:t,fontSizeMult:e,unitsPerEm:l,ascender:r*e,descender:s*e,capHeight:h*e,xHeight:d*e,lineHeight:n,baseline:-a-r*e,caretTop:(r+s)/2*e+o/2,caretBottom:i-o},j.set(t,v)}const{fontSizeMult:g}=v,x=i.slice(e.start,e.end+1);let S,k;t.forEachGlyph(x,p,m,((t,r,s)=>{r+=V,s+=e.start,S=r,k=t;const l=i.charAt(s),u=t.advanceWidth*g,h=X.count;let d;if("isEmpty"in t||(t.isWhitespace=!!l&&new RegExp(a).test(l),t.canBreakAfter=!!l&&o.test(l),t.isEmpty=t.xMin===t.xMax||t.yMin===t.yMax||n.test(l)),t.isWhitespace||t.isEmpty||L++,W&&c&&!t.isWhitespace&&r+u+N>b&&h){if(X.glyphAt(h-1).glyphObj.canBreakAfter)d=new f,N=-r;else for(let e=h;e--;){if(0===e&&"break-word"===w){d=new f,N=-r;break}if(X.glyphAt(e).glyphObj.canBreakAfter){d=X.splitAt(e+1);const t=d.glyphAt(0).x;N-=t;for(let e=d.count;e--;)d.glyphAt(e).x-=t;break}}d&&(X.isSoftWrapped=!0,X=d,q.push(X),G=b)}let y=X.glyphAt(X.count);y.glyphObj=t,y.x=r+N,y.width=u,y.charIndex=s,y.fontData=v,"\n"===l&&(X=new f,q.push(X),N=-(r+u+m*p)+U)})),V=S+k.advanceWidth*g+m*p}));let H=0;q.forEach((e=>{let t=!0;for(let r=e.count;r--;){const n=e.glyphAt(r);t&&!n.glyphObj.isWhitespace&&(e.width=n.x+n.width,e.width>G&&(G=e.width),t=!1);let{lineHeight:a,capHeight:o,xHeight:i,baseline:s}=n.fontData;a>e.lineHeight&&(e.lineHeight=a);const l=s-e.baseline;l<0&&(e.baseline+=l,e.cap+=l,e.ex+=l),e.cap=Math.max(e.cap,e.baseline+o),e.ex=Math.max(e.ex,e.baseline+i)}e.baseline-=H,e.cap-=H,e.ex-=H,H+=e.lineHeight}));let $=0,Y=0;if(T&&("number"==typeof T?$=-T:"string"==typeof T&&($=-G*("left"===T?0:"center"===T?.5:"right"===T?1:s(T)))),_&&("number"==typeof _?Y=-_:"string"==typeof _&&(Y="top"===_?0:"top-baseline"===_?-q[0].baseline:"top-cap"===_?-q[0].cap:"top-ex"===_?-q[0].ex:"middle"===_?H/2:"bottom"===_?H:"bottom-baseline"===_?q[q.length-1].baseline:s(_)*H)),!F){const e=t.getEmbeddingLevels(i,x);h=new Uint16Array(L),d=new Uint8Array(L),v=new Float32Array(2*L),g={},P=[r,r,-1/0,-1/0],B=[],A&&(D=new Float32Array(4*i.length)),R&&(C=new Uint8Array(3*L));let n,a,o=0,s=-1,u=-1;if(q.forEach(((f,c)=>{let{count:p,width:m}=f;if(p>0){let c=0;for(let e=p;e--&&f.glyphAt(e).glyphObj.isWhitespace;)c++;let y=0,b=0;if("center"===S)y=(G-m)/2;else if("right"===S)y=G-m;else if("justify"===S&&f.isSoftWrapped){let e=0;for(let t=p-c;t--;)f.glyphAt(t).glyphObj.isWhitespace&&e++;b=(G-m)/e}if(b||y){let e=0;for(let t=0;t=t){let t=e,o=e;for(;or)break;oU=e;for(let c=0;c1&&l(D,s,a),s=e}if(R){const{charIndex:e}=p;for(;e>u;)u++,R.hasOwnProperty(u)&&(a=R[u])}if(!U.isWhitespace&&!U.isEmpty){const e=o++,{fontSizeMult:t,src:i,index:s}=p.fontData,l=g[i]||(g[i]={});l[m]||(l[m]={path:U.path,pathBounds:[U.xMin,U.yMin,U.xMax,U.yMax]});const u=p.x+$,c=f.baseline+Y;v[2*e]=u,v[2*e+1]=c;const y=u+U.xMin*t,b=c+U.yMin*t,x=u+U.xMax*t,S=c+U.yMax*t;yP[2]&&(P[2]=x),S>P[3]&&(P[3]=S),e%O==0&&(n={start:e,end:e,rect:[r,r,-1/0,-1/0]},B.push(n)),n.end++;const k=n.rect;if(yk[2]&&(k[2]=x),S>k[3]&&(k[3]=S),h[e]=m,d[e]=s,R){const t=3*e;C[t]=a>>16&255,C[t+1]=a>>8&255,C[t+2]=255&a}}}}})),D){const e=i.length-s;e>1&&l(D,s,e)}}const Z=[];j.forEach((({index:e,src:t,unitsPerEm:r,ascender:n,descender:a,lineHeight:o,capHeight:i,xHeight:s})=>{Z[e]={src:t,unitsPerEm:r,ascender:n,descender:a,lineHeight:o,capHeight:i,xHeight:s}})),I.typesetting=u()-z,E({glyphIds:h,glyphFontIndices:d,glyphPositions:v,glyphData:g,fontData:Z,caretPositions:D,glyphColors:C,chunkedBounds:B,fontSize:p,topBaseline:Y+q[0].baseline,blockBounds:[$,Y-H,$+G,Y],visibleBounds:P,timings:I})}))}function s(e){let t=e.match(/^([\d.]+)%$/),r=t?parseFloat(t[1]):NaN;return isNaN(r)?0:r/100}function l(e,t,r){const n=e[4*t],a=e[4*t+1],o=e[4*t+2],i=e[4*t+3],s=(a-n)/r;for(let a=0;a(Object.defineProperty(e,t,{get(){return this.data[this.index*c.length+r]},set(e){this.data[this.index*c.length+r]=e}}),e)),{data:null,index:0}),{typeset:i,measure:function(e,t){i({...e,metricsOnly:!0},(e=>{const[r,n,a,o]=e.blockBounds;t({width:a-r,height:o-n})}))}}},R,function(){return function(e){var t={R:"13k,1a,2,3,3,2+1j,ch+16,a+1,5+2,2+n,5,a,4,6+16,4+3,h+1b,4mo,179q,2+9,2+11,2i9+7y,2+68,4,3+4,5+13,4+3,2+4k,3+29,8+cf,1t+7z,w+17,3+3m,1t+3z,16o1+5r,8+30,8+mc,29+1r,29+4v,75+73",EN:"1c+9,3d+1,6,187+9,513,4+5,7+9,sf+j,175h+9,qw+q,161f+1d,4xt+a,25i+9",ES:"17,2,6dp+1,f+1,av,16vr,mx+1,4o,2",ET:"z+2,3h+3,b+1,ym,3e+1,2o,p4+1,8,6u,7c,g6,1wc,1n9+4,30+1b,2n,6d,qhx+1,h0m,a+1,49+2,63+1,4+1,6bb+3,12jj",AN:"16o+5,2j+9,2+1,35,ed,1ff2+9,87+u",CS:"18,2+1,b,2u,12k,55v,l,17v0,2,3,53,2+1,b",B:"a,3,f+2,2v,690",S:"9,2,k",WS:"c,k,4f4,1vk+a,u,1j,335",ON:"x+1,4+4,h+5,r+5,r+3,z,5+3,2+1,2+1,5,2+2,3+4,o,w,ci+1,8+d,3+d,6+8,2+g,39+1,9,6+1,2,33,b8,3+1,3c+1,7+1,5r,b,7h+3,sa+5,2,3i+6,jg+3,ur+9,2v,ij+1,9g+9,7+a,8m,4+1,49+x,14u,2+2,c+2,e+2,e+2,e+1,i+n,e+e,2+p,u+2,e+2,36+1,2+3,2+1,b,2+2,6+5,2,2,2,h+1,5+4,6+3,3+f,16+2,5+3l,3+81,1y+p,2+40,q+a,m+13,2r+ch,2+9e,75+hf,3+v,2+2w,6e+5,f+6,75+2a,1a+p,2+2g,d+5x,r+b,6+3,4+o,g,6+1,6+2,2k+1,4,2j,5h+z,1m+1,1e+f,t+2,1f+e,d+3,4o+3,2s+1,w,535+1r,h3l+1i,93+2,2s,b+1,3l+x,2v,4g+3,21+3,kz+1,g5v+1,5a,j+9,n+v,2,3,2+8,2+1,3+2,2,3,46+1,4+4,h+5,r+5,r+a,3h+2,4+6,b+4,78,1r+24,4+c,4,1hb,ey+6,103+j,16j+c,1ux+7,5+g,fsh,jdq+1t,4,57+2e,p1,1m,1m,1m,1m,4kt+1,7j+17,5+2r,d+e,3+e,2+e,2+10,m+4,w,1n+5,1q,4z+5,4b+rb,9+c,4+c,4+37,d+2g,8+b,l+b,5+1j,9+9,7+13,9+t,3+1,27+3c,2+29,2+3q,d+d,3+4,4+2,6+6,a+o,8+6,a+2,e+6,16+42,2+1i",BN:"0+8,6+d,2s+5,2+p,e,4m9,1kt+2,2b+5,5+5,17q9+v,7k,6p+8,6+1,119d+3,440+7,96s+1,1ekf+1,1ekf+1,1ekf+1,1ekf+1,1ekf+1,1ekf+1,1ekf+1,1ekf+1,1ekf+1,1ekf+1,1ekf+1,1ekf+75,6p+2rz,1ben+1,1ekf+1,1ekf+1",NSM:"lc+33,7o+6,7c+18,2,2+1,2+1,2,21+a,1d+k,h,2u+6,3+5,3+1,2+3,10,v+q,2k+a,1n+8,a,p+3,2+8,2+2,2+4,18+2,3c+e,2+v,1k,2,5+7,5,4+6,b+1,u,1n,5+3,9,l+1,r,3+1,1m,5+1,5+1,3+2,4,v+1,4,c+1,1m,5+4,2+1,5,l+1,n+5,2,1n,3,2+3,9,8+1,c+1,v,1q,d,1f,4,1m+2,6+2,2+3,8+1,c+1,u,1n,g+1,l+1,t+1,1m+1,5+3,9,l+1,u,21,8+2,2,2j,3+6,d+7,2r,3+8,c+5,23+1,s,2,2,1k+d,2+4,2+1,6+a,2+z,a,2v+3,2+5,2+1,3+1,q+1,5+2,h+3,e,3+1,7,g,jk+2,qb+2,u+2,u+1,v+1,1t+1,2+6,9,3+a,a,1a+2,3c+1,z,3b+2,5+1,a,7+2,64+1,3,1n,2+6,2,2,3+7,7+9,3,1d+g,1s+3,1d,2+4,2,6,15+8,d+1,x+3,3+1,2+2,1l,2+1,4,2+2,1n+7,3+1,49+2,2+c,2+6,5,7,4+1,5j+1l,2+4,k1+w,2db+2,3y,2p+v,ff+3,30+1,n9x+3,2+9,x+1,29+1,7l,4,5,q+1,6,48+1,r+h,e,13+7,q+a,1b+2,1d,3+3,3+1,14,1w+5,3+1,3+1,d,9,1c,1g,2+2,3+1,6+1,2,17+1,9,6n,3,5,fn5,ki+f,h+f,r2,6b,46+4,1af+2,2+1,6+3,15+2,5,4m+1,fy+3,as+1,4a+a,4x,1j+e,1l+2,1e+3,3+1,1y+2,11+4,2+7,1r,d+1,1h+8,b+3,3,2o+2,3,2+1,7,4h,4+7,m+1,1m+1,4,12+6,4+4,5g+7,3+2,2,o,2d+5,2,5+1,2+1,6n+3,7+1,2+1,s+1,2e+7,3,2+1,2z,2,3+5,2,2u+2,3+3,2+4,78+8,2+1,75+1,2,5,41+3,3+1,5,x+5,3+1,15+5,3+3,9,a+5,3+2,1b+c,2+1,bb+6,2+5,2d+l,3+6,2+1,2+1,3f+5,4,2+1,2+6,2,21+1,4,2,9o+1,f0c+4,1o+6,t5,1s+3,2a,f5l+1,43t+2,i+7,3+6,v+3,45+2,1j0+1i,5+1d,9,f,n+4,2+e,11t+6,2+g,3+6,2+1,2+4,7a+6,c6+3,15t+6,32+6,gzhy+6n",AL:"16w,3,2,e+1b,z+2,2+2s,g+1,8+1,b+m,2+t,s+2i,c+e,4h+f,1d+1e,1bwe+dp,3+3z,x+c,2+1,35+3y,2rm+z,5+7,b+5,dt+l,c+u,17nl+27,1t+27,4x+6n,3+d",LRO:"6ct",RLO:"6cu",LRE:"6cq",RLE:"6cr",PDF:"6cs",LRI:"6ee",RLI:"6ef",FSI:"6eg",PDI:"6eh"},r={},n={};r.L=1,n[1]="L",Object.keys(t).forEach((function(e,t){r[e]=1<"),u=l[0],f=l[1];u=String.fromCodePoint(n+=parseInt(u,36)),f=String.fromCodePoint(n+=parseInt(f,36)),a.set(u,f),t&&o.set(f,u)}})),{map:a,reverseMap:o}}function m(){if(!c){var e=g(p,!0),t=e.map,r=e.reverseMap;c=t,h=r,d=g(v,!1).map}}function y(e){return m(),c.get(e)||null}function b(e){return m(),h.get(e)||null}function x(e){return m(),d.get(e)||null}var S=r.L,U=r.R,k=r.EN,w=r.ES,T=r.ET,_=r.AN,F=r.CS,C=r.B,D=r.S,A=r.ON,O=r.BN,R=r.NSM,E=r.AL,M=r.LRO,I=r.RLO,P=r.LRE,B=r.RLE,G=r.PDF,L=r.LRI,W=r.RLI,j=r.FSI,z=r.PDI;var N;function V(e){return function(){if(!N){var e=g("14>1,j>2,t>2,u>2,1a>g,2v3>1,1>1,1ge>1,1wd>1,b>1,1j>1,f>1,ai>3,-2>3,+1,8>1k0,-1jq>1y7,-1y6>1hf,-1he>1h6,-1h5>1ha,-1h8>1qi,-1pu>1,6>3u,-3s>7,6>1,1>1,f>1,1>1,+2,3>1,1>1,+13,4>1,1>1,6>1eo,-1ee>1,3>1mg,-1me>1mk,-1mj>1mi,-1mg>1mi,-1md>1,1>1,+2,1>10k,-103>1,1>1,4>1,5>1,1>1,+10,3>1,1>8,-7>8,+1,-6>7,+1,a>1,1>1,u>1,u6>1,1>1,+5,26>1,1>1,2>1,2>2,8>1,7>1,4>1,1>1,+5,b8>1,1>1,+3,1>3,-2>1,2>1,1>1,+2,c>1,3>1,1>1,+2,h>1,3>1,a>1,1>1,2>1,3>1,1>1,d>1,f>1,3>1,1a>1,1>1,6>1,7>1,13>1,k>1,1>1,+19,4>1,1>1,+2,2>1,1>1,+18,m>1,a>1,1>1,lk>1,1>1,4>1,2>1,f>1,3>1,1>1,+3,db>1,1>1,+3,3>1,1>1,+2,14qm>1,1>1,+1,6>1,4j>1,j>2,t>2,u>2,2>1,+1",!0),t=e.map;e.reverseMap.forEach((function(e,r){t.set(r,e)})),N=t}}(),N.get(e)||null}function X(e,t,r,n){var a=e.length;r=Math.max(0,null==r?0:+r),n=Math.min(a-1,null==n?a-1:+n);var o=[];return t.paragraphs.forEach((function(a){var i=Math.max(r,a.start),s=Math.min(n,a.end);if(i=i&&f(e[c])&l;c--)u[c]=a.level;for(var h=a.level,d=1/0,p=0;ph&&(h=v),v=d;g--)for(var m=0;m=g){for(var y=m;m+1=g;)m++;m>y&&o.push([y+r,m+r])}}})),o}function q(e,t,r,n){for(var a=X(e,t,r,n),o=[],i=0;i0)$--;else if(Z>0){for(Y=0;!q[q.length-1]._isolate;)q.pop();var re=q[q.length-1]._isolInitIndex;null!=re&&(d.set(re,K),d.set(K,re)),q.pop(),Z--}H=q[q.length-1],h[K]=H._level,H._override&&c(K,H._override)}else J&G?(0===$&&(Y>0?Y--:!H._isolate&&q.length>1&&(q.pop(),H=q[q.length-1])),h[K]=H._level):J&C&&(h[K]=v.level);else h[K]=H._level,H._override&&J!==O&&c(K,H._override)}for(var ne=[],ae=null,oe=v.start;oe<=v.end;oe++){var ie=r[oe];if(!(ie&s)){var se=h[oe],le=ie&a,ue=ie===z;ae&&se===ae._level?(ae._end=oe,ae._endsWithIsolInit=le):ne.push(ae={_start:oe,_end:oe,_level:se,_startsWithPDI:ue,_endsWithIsolInit:le})}}for(var fe=[],ce=0;ce=0;Ue--)if(!(r[Ue]&s)){Se=h[Ue];break}var ke=ge[ge.length-1],we=h[ke],Te=v.level;if(!(r[ke]&a))for(var _e=ke+1;_e<=v.end;_e++)if(!(r[_e]&s)){Te=h[_e];break}fe.push({_seqIndices:ge,_sosType:Math.max(Se,xe)%2?U:S,_eosType:Math.max(Te,we)%2?U:S})}}for(var Fe=0;Fe=0;Ie--)if(!(r[De[Ie]]&s)){Me=r[De[Ie]];break}c(Ee,Me&(a|z)?A:Me)}}if(u.get(k))for(var Pe=0;Pe=-1;Ge--){var Le=-1===Ge?Ae:r[De[Ge]];if(Le&o){Le===E&&c(Be,_);break}}}if(u.get(E))for(var We=0;We=0&&(Ve=r[De[qe]])&s;qe--);for(var He=ze+1;He=0&&r[De[Ze]]&(T|s);Ze--)c(De[Ze],k);for(var Ke=$e+1;Ke=0&&r[De[et]]&s;et--)c(De[et],A);for(var tt=Je+1;tt=0;dt--){var pt=ut[dt].char;if(pt===ht||pt===b(x(ct))||y(x(pt))===ct){lt.push([ut[dt].seqIndex,ft]),ut.length=dt;break}}}lt.sort((function(e,t){return e[0]-t[0]}));for(var vt=0;vt=0;wt--){var Tt=De[wt];if(r[Tt]&st){var _t=r[Tt]&it?U:S;xt=_t!==Nt(Tt)?_t:Nt(Tt);break}}}if(xt){if(r[De[mt]]=r[De[yt]]=xt,xt!==Nt(De[mt]))for(var Ft=mt+1;Ft=0;Et--){if(!(r[De[Et]]&s)){Rt=r[De[Et]]&it?U:S;break}At=Et}for(var Mt=Oe,It=Dt+1;It=0&&f(e[Wt])&l;Wt--)h[Wt]=v.level}}return{levels:h,paragraphs:p};function jt(t,n){for(var o=t;oe(t,r())}),ee=p({name:"Typesetter",dependencies:[Q],init:e=>function(t){return new Promise((r=>{e.typeset(t,r)}))},getTransferables(e){const t=[];for(let r in e)e[r]&&e[r].buffer&&t.push(e[r].buffer);return t}}),te={};const re="aTroikaGlyphIndex";class ne extends e.InstancedBufferGeometry{constructor(){super(),this.detail=1,this.curveRadius=0,this.groups=[{start:0,count:1/0,materialIndex:0},{start:0,count:1/0,materialIndex:1}],this.boundingSphere=new e.Sphere,this.boundingBox=new e.Box3}computeBoundingSphere(){}computeBoundingBox(){}setSide(t){const r=this.getIndex().count;this.setDrawRange(t===e.BackSide?r/2:0,t===e.DoubleSide?r:r/2)}set detail(t){if(t!==this._detail){this._detail=t,("number"!=typeof t||t<1)&&(t=1);let r=function(t){let r=te[t];if(!r){const n=new e.PlaneGeometry(1,1,t,t),a=n.clone(),o=n.attributes,i=a.attributes,s=new e.BufferGeometry,l=o.uv.count;for(let e=0;e{s.setAttribute(t,new e.Float32BufferAttribute([...o[t].array,...i[t].array],o[t].itemSize))})),s.setIndex([...n.index.array,...a.index.array.map((e=>e+l))]),s.translate(.5,.5,0),r=te[t]=s}return r}(t);["position","normal","uv"].forEach((e=>{this.attributes[e]=r.attributes[e].clone()})),this.setIndex(r.getIndex().clone())}}get detail(){return this._detail}set curveRadius(e){e!==this._curveRadius&&(this._curveRadius=e,this._updateBounds())}get curveRadius(){return this._curveRadius}updateGlyphs(e,t,r,n,a){ae(this,"aTroikaGlyphBounds",e,4),ae(this,re,t,1),ae(this,"aTroikaGlyphColor",a,3),this._blockBounds=r,this._chunkedBounds=n,this.instanceCount=t.length,this._updateBounds()}_updateBounds(){const e=this._blockBounds;if(e){const{curveRadius:t,boundingBox:r}=this;if(t){const{PI:n,floor:a,min:o,max:i,sin:s,cos:l}=Math,u=n/2,f=2*n,c=Math.abs(t),h=e[0]/c,d=e[2]/c,p=a((h+u)/f)!==a((d+u)/f)?-c:o(s(h)*c,s(d)*c),v=a((h-u)/f)!==a((d-u)/f)?c:i(s(h)*c,s(d)*c),g=a((h+n)/f)!==a((d+n)/f)?2*c:i(c-l(h)*c,c-l(d)*c);r.min.set(p,e[1],t<0?-g:0),r.max.set(v,e[3],t<0?0:g)}else r.min.set(e[0],e[1],0),r.max.set(e[2],e[3],0);r.getBoundingSphere(this.boundingSphere)}}applyClipRect(e){let t=this.getAttribute(re).count,r=this._chunkedBounds;if(r)for(let n=r.length;n--;){t=r[n].end;let a=r[n].rect;if(a[1]e.y&&a[0]e.x)break}this.instanceCount=t}}function ae(t,r,n,a){const o=t.getAttribute(r);n?o&&o.array.length===n.length?(o.array.set(n),o.needsUpdate=!0):(t.setAttribute(r,new e.InstancedBufferAttribute(n,a)),delete t._maxInstanceCount,t.dispose()):o&&t.deleteAttribute(r)}const oe=new e.MeshBasicMaterial({color:16777215,side:e.DoubleSide,transparent:!0}),ie=8421504,se=new e.Matrix4,le=new e.Vector3,ue=new e.Vector3,fe=[],ce=new e.Vector3,he="+x+y";function de(e){return Array.isArray(e)?e[0]:e}let pe=()=>{const t=new e.Mesh(new e.PlaneGeometry(1,1),oe);return pe=()=>t,t},ve=()=>{const t=new e.Mesh(new e.PlaneGeometry(1,1,32,1),oe);return ve=()=>t,t};const ge={type:"syncstart"},me={type:"synccomplete"},ye=["font","fontSize","fontStyle","fontWeight","lang","letterSpacing","lineHeight","maxWidth","overflowWrap","text","direction","textAlign","textIndent","whiteSpace","anchorX","anchorY","colorRanges","sdfGlyphSize"],be=ye.concat("material","color","depthOffset","clipRect","curveRadius","orientation","glyphGeometryDetail");class xe extends e.Mesh{constructor(){super(new ne,null),this.text="",this.anchorX=0,this.anchorY=0,this.curveRadius=0,this.direction="auto",this.font=null,this.unicodeFontsURL=null,this.fontSize=.1,this.fontWeight="normal",this.fontStyle="normal",this.lang="en",this.letterSpacing=0,this.lineHeight="normal",this.maxWidth=1/0,this.overflowWrap="normal",this.textAlign="left",this.textIndent=0,this.whiteSpace="normal",this.material=null,this.color=null,this.colorRanges=null,this.outlineWidth=0,this.outlineColor=0,this.outlineOpacity=1,this.outlineBlur=0,this.outlineOffsetX=0,this.outlineOffsetY=0,this.strokeWidth=0,this.strokeColor=ie,this.strokeOpacity=1,this.fillOpacity=1,this.depthOffset=0,this.clipRect=null,this.orientation=he,this.glyphGeometryDetail=1,this.sdfGlyphSize=null,this.gpuAccelerateSDF=!0,this.debugSDF=!1}sync(e){this._needsSync&&(this._needsSync=!1,this._isSyncing?(this._queuedSyncs||(this._queuedSyncs=[])).push(e):(this._isSyncing=!0,this.dispatchEvent(ge),$({text:this.text,font:this.font,lang:this.lang,fontSize:this.fontSize||.1,fontWeight:this.fontWeight||"normal",fontStyle:this.fontStyle||"normal",letterSpacing:this.letterSpacing||0,lineHeight:this.lineHeight||"normal",maxWidth:this.maxWidth,direction:this.direction||"auto",textAlign:this.textAlign,textIndent:this.textIndent,whiteSpace:this.whiteSpace,overflowWrap:this.overflowWrap,anchorX:this.anchorX,anchorY:this.anchorY,colorRanges:this.colorRanges,includeCaretPositions:!0,sdfGlyphSize:this.sdfGlyphSize,gpuAccelerateSDF:this.gpuAccelerateSDF,unicodeFontsURL:this.unicodeFontsURL},(t=>{this._isSyncing=!1,this._textRenderInfo=t,this.geometry.updateGlyphs(t.glyphBounds,t.glyphAtlasIndices,t.blockBounds,t.chunkedBounds,t.glyphColors);const r=this._queuedSyncs;r&&(this._queuedSyncs=null,this._needsSync=!0,this.sync((()=>{r.forEach((e=>e&&e()))}))),this.dispatchEvent(me),e&&e()}))))}onBeforeRender(t,r,n,a,o,i){this.sync(),o.isTroikaTextMaterial&&this._prepareForRender(o),o._hadOwnSide=o.hasOwnProperty("side"),this.geometry.setSide(o._actualSide=o.side),o.side=e.FrontSide}onAfterRender(e,t,r,n,a,o){a._hadOwnSide?a.side=a._actualSide:delete a.side}dispose(){this.geometry.dispose()}get textRenderInfo(){return this._textRenderInfo||null}get material(){let t=this._derivedMaterial;const r=this._baseMaterial||this._defaultMaterial||(this._defaultMaterial=oe.clone());if(t&&t.baseMaterial===r||(t=this._derivedMaterial=function(t){const r=_(t,{chained:!0,extensions:{derivatives:!0},uniforms:{uTroikaSDFTexture:{value:null},uTroikaSDFTextureSize:{value:new e.Vector2},uTroikaSDFGlyphSize:{value:0},uTroikaSDFExponent:{value:0},uTroikaTotalBounds:{value:new e.Vector4(0,0,0,0)},uTroikaClipRect:{value:new e.Vector4(0,0,0,0)},uTroikaDistanceOffset:{value:0},uTroikaOutlineOpacity:{value:0},uTroikaFillOpacity:{value:1},uTroikaPositionOffset:{value:new e.Vector2},uTroikaCurveRadius:{value:0},uTroikaBlurRadius:{value:0},uTroikaStrokeWidth:{value:0},uTroikaStrokeColor:{value:new e.Color},uTroikaStrokeOpacity:{value:1},uTroikaOrient:{value:new e.Matrix3},uTroikaUseGlyphColors:{value:!0},uTroikaSDFDebug:{value:!1}},vertexDefs:"\nuniform vec2 uTroikaSDFTextureSize;\nuniform float uTroikaSDFGlyphSize;\nuniform vec4 uTroikaTotalBounds;\nuniform vec4 uTroikaClipRect;\nuniform mat3 uTroikaOrient;\nuniform bool uTroikaUseGlyphColors;\nuniform float uTroikaDistanceOffset;\nuniform float uTroikaBlurRadius;\nuniform vec2 uTroikaPositionOffset;\nuniform float uTroikaCurveRadius;\nattribute vec4 aTroikaGlyphBounds;\nattribute float aTroikaGlyphIndex;\nattribute vec3 aTroikaGlyphColor;\nvarying vec2 vTroikaGlyphUV;\nvarying vec4 vTroikaTextureUVBounds;\nvarying float vTroikaTextureChannel;\nvarying vec3 vTroikaGlyphColor;\nvarying vec2 vTroikaGlyphDimensions;\n",vertexTransform:"\nvec4 bounds = aTroikaGlyphBounds;\nbounds.xz += uTroikaPositionOffset.x;\nbounds.yw -= uTroikaPositionOffset.y;\n\nvec4 outlineBounds = vec4(\n bounds.xy - uTroikaDistanceOffset - uTroikaBlurRadius,\n bounds.zw + uTroikaDistanceOffset + uTroikaBlurRadius\n);\nvec4 clippedBounds = vec4(\n clamp(outlineBounds.xy, uTroikaClipRect.xy, uTroikaClipRect.zw),\n clamp(outlineBounds.zw, uTroikaClipRect.xy, uTroikaClipRect.zw)\n);\n\nvec2 clippedXY = (mix(clippedBounds.xy, clippedBounds.zw, position.xy) - bounds.xy) / (bounds.zw - bounds.xy);\n\nposition.xy = mix(bounds.xy, bounds.zw, clippedXY);\n\nuv = (position.xy - uTroikaTotalBounds.xy) / (uTroikaTotalBounds.zw - uTroikaTotalBounds.xy);\n\nfloat rad = uTroikaCurveRadius;\nif (rad != 0.0) {\n float angle = position.x / rad;\n position.xz = vec2(sin(angle) * rad, rad - cos(angle) * rad);\n normal.xz = vec2(sin(angle), cos(angle));\n}\n \nposition = uTroikaOrient * position;\nnormal = uTroikaOrient * normal;\n\nvTroikaGlyphUV = clippedXY.xy;\nvTroikaGlyphDimensions = vec2(bounds[2] - bounds[0], bounds[3] - bounds[1]);\n\n\nfloat txCols = uTroikaSDFTextureSize.x / uTroikaSDFGlyphSize;\nvec2 txUvPerSquare = uTroikaSDFGlyphSize / uTroikaSDFTextureSize;\nvec2 txStartUV = txUvPerSquare * vec2(\n mod(floor(aTroikaGlyphIndex / 4.0), txCols),\n floor(floor(aTroikaGlyphIndex / 4.0) / txCols)\n);\nvTroikaTextureUVBounds = vec4(txStartUV, vec2(txStartUV) + txUvPerSquare);\nvTroikaTextureChannel = mod(aTroikaGlyphIndex, 4.0);\n",fragmentDefs:"\nuniform sampler2D uTroikaSDFTexture;\nuniform vec2 uTroikaSDFTextureSize;\nuniform float uTroikaSDFGlyphSize;\nuniform float uTroikaSDFExponent;\nuniform float uTroikaDistanceOffset;\nuniform float uTroikaFillOpacity;\nuniform float uTroikaOutlineOpacity;\nuniform float uTroikaBlurRadius;\nuniform vec3 uTroikaStrokeColor;\nuniform float uTroikaStrokeWidth;\nuniform float uTroikaStrokeOpacity;\nuniform bool uTroikaSDFDebug;\nvarying vec2 vTroikaGlyphUV;\nvarying vec4 vTroikaTextureUVBounds;\nvarying float vTroikaTextureChannel;\nvarying vec2 vTroikaGlyphDimensions;\n\nfloat troikaSdfValueToSignedDistance(float alpha) {\n // Inverse of exponential encoding in webgl-sdf-generator\n \n float maxDimension = max(vTroikaGlyphDimensions.x, vTroikaGlyphDimensions.y);\n float absDist = (1.0 - pow(2.0 * (alpha > 0.5 ? 1.0 - alpha : alpha), 1.0 / uTroikaSDFExponent)) * maxDimension;\n float signedDist = absDist * (alpha > 0.5 ? -1.0 : 1.0);\n return signedDist;\n}\n\nfloat troikaGlyphUvToSdfValue(vec2 glyphUV) {\n vec2 textureUV = mix(vTroikaTextureUVBounds.xy, vTroikaTextureUVBounds.zw, glyphUV);\n vec4 rgba = texture2D(uTroikaSDFTexture, textureUV);\n float ch = floor(vTroikaTextureChannel + 0.5); //NOTE: can't use round() in WebGL1\n return ch == 0.0 ? rgba.r : ch == 1.0 ? rgba.g : ch == 2.0 ? rgba.b : rgba.a;\n}\n\nfloat troikaGlyphUvToDistance(vec2 uv) {\n return troikaSdfValueToSignedDistance(troikaGlyphUvToSdfValue(uv));\n}\n\nfloat troikaGetAADist() {\n \n #if defined(GL_OES_standard_derivatives) || __VERSION__ >= 300\n return length(fwidth(vTroikaGlyphUV * vTroikaGlyphDimensions)) * 0.5;\n #else\n return vTroikaGlyphDimensions.x / 64.0;\n #endif\n}\n\nfloat troikaGetFragDistValue() {\n vec2 clampedGlyphUV = clamp(vTroikaGlyphUV, 0.5 / uTroikaSDFGlyphSize, 1.0 - 0.5 / uTroikaSDFGlyphSize);\n float distance = troikaGlyphUvToDistance(clampedGlyphUV);\n \n // Extrapolate distance when outside bounds:\n distance += clampedGlyphUV == vTroikaGlyphUV ? 0.0 : \n length((vTroikaGlyphUV - clampedGlyphUV) * vTroikaGlyphDimensions);\n\n \n\n return distance;\n}\n\nfloat troikaGetEdgeAlpha(float distance, float distanceOffset, float aaDist) {\n #if defined(IS_DEPTH_MATERIAL) || defined(IS_DISTANCE_MATERIAL)\n float alpha = step(-distanceOffset, -distance);\n #else\n\n float alpha = smoothstep(\n distanceOffset + aaDist,\n distanceOffset - aaDist,\n distance\n );\n #endif\n\n return alpha;\n}\n",fragmentColorTransform:"\nfloat aaDist = troikaGetAADist();\nfloat fragDistance = troikaGetFragDistValue();\nfloat edgeAlpha = uTroikaSDFDebug ?\n troikaGlyphUvToSdfValue(vTroikaGlyphUV) :\n troikaGetEdgeAlpha(fragDistance, uTroikaDistanceOffset, max(aaDist, uTroikaBlurRadius));\n\n#if !defined(IS_DEPTH_MATERIAL) && !defined(IS_DISTANCE_MATERIAL)\nvec4 fillRGBA = gl_FragColor;\nfillRGBA.a *= uTroikaFillOpacity;\nvec4 strokeRGBA = uTroikaStrokeWidth == 0.0 ? fillRGBA : vec4(uTroikaStrokeColor, uTroikaStrokeOpacity);\nif (fillRGBA.a == 0.0) fillRGBA.rgb = strokeRGBA.rgb;\ngl_FragColor = mix(fillRGBA, strokeRGBA, smoothstep(\n -uTroikaStrokeWidth - aaDist,\n -uTroikaStrokeWidth + aaDist,\n fragDistance\n));\ngl_FragColor.a *= edgeAlpha;\n#endif\n\nif (edgeAlpha == 0.0) {\n discard;\n}\n",customRewriter({vertexShader:e,fragmentShader:t}){let r=/\buniform\s+vec3\s+diffuse\b/;return r.test(t)&&(t=t.replace(r,"varying vec3 vTroikaGlyphColor").replace(/\bdiffuse\b/g,"vTroikaGlyphColor"),r.test(e)||(e=e.replace(y,"uniform vec3 diffuse;\n$&\nvTroikaGlyphColor = uTroikaUseGlyphColors ? aTroikaGlyphColor / 255.0 : diffuse;\n"))),{vertexShader:e,fragmentShader:t}}});return r.transparent=!0,Object.defineProperties(r,{isTroikaTextMaterial:{value:!0},shadowSide:{get(){return this.side},set(){}}}),r}(r),r.addEventListener("dispose",(function e(){r.removeEventListener("dispose",e),t.dispose()}))),this.outlineWidth||this.outlineBlur||this.outlineOffsetX||this.outlineOffsetY){let e=t._outlineMtl;return e||(e=t._outlineMtl=Object.create(t,{id:{value:t.id+.1}}),e.isTextOutlineMaterial=!0,e.depthWrite=!1,e.map=null,t.addEventListener("dispose",(function r(){t.removeEventListener("dispose",r),e.dispose()}))),[e,t]}return t}set material(e){e&&e.isTroikaTextMaterial?(this._derivedMaterial=e,this._baseMaterial=e.baseMaterial):this._baseMaterial=e}get glyphGeometryDetail(){return this.geometry.detail}set glyphGeometryDetail(e){this.geometry.detail=e}get curveRadius(){return this.geometry.curveRadius}set curveRadius(e){this.geometry.curveRadius=e}get customDepthMaterial(){return de(this.material).getDepthMaterial()}get customDistanceMaterial(){return de(this.material).getDistanceMaterial()}_prepareForRender(t){const r=t.isTextOutlineMaterial,n=t.uniforms,a=this.textRenderInfo;if(a){const{sdfTexture:e,blockBounds:t}=a;n.uTroikaSDFTexture.value=e,n.uTroikaSDFTextureSize.value.set(e.image.width,e.image.height),n.uTroikaSDFGlyphSize.value=a.sdfGlyphSize,n.uTroikaSDFExponent.value=a.sdfExponent,n.uTroikaTotalBounds.value.fromArray(t),n.uTroikaUseGlyphColors.value=!r&&!!a.glyphColors;let o,i,s,l=0,u=0,f=0,c=0,h=0;if(r){let{outlineWidth:e,outlineOffsetX:t,outlineOffsetY:r,outlineBlur:n,outlineOpacity:a}=this;l=this._parsePercent(e)||0,u=Math.max(0,this._parsePercent(n)||0),o=a,c=this._parsePercent(t)||0,h=this._parsePercent(r)||0}else f=Math.max(0,this._parsePercent(this.strokeWidth)||0),f&&(s=this.strokeColor,n.uTroikaStrokeColor.value.set(null==s?ie:s),i=this.strokeOpacity,null==i&&(i=1)),o=this.fillOpacity;n.uTroikaDistanceOffset.value=l,n.uTroikaPositionOffset.value.set(c,h),n.uTroikaBlurRadius.value=u,n.uTroikaStrokeWidth.value=f,n.uTroikaStrokeOpacity.value=i,n.uTroikaFillOpacity.value=null==o?1:o,n.uTroikaCurveRadius.value=this.curveRadius||0;let d=this.clipRect;if(d&&Array.isArray(d)&&4===d.length)n.uTroikaClipRect.value.fromArray(d);else{const e=100*(this.fontSize||.1);n.uTroikaClipRect.value.set(t[0]-e,t[1]-e,t[2]+e,t[3]+e)}this.geometry.applyClipRect(n.uTroikaClipRect.value)}n.uTroikaSDFDebug.value=!!this.debugSDF,t.polygonOffset=!!this.depthOffset,t.polygonOffsetFactor=t.polygonOffsetUnits=this.depthOffset||0;const o=r?this.outlineColor||0:this.color;if(null==o)delete t.color;else{const r=t.hasOwnProperty("color")?t.color:t.color=new e.Color;o===r._input&&"object"!=typeof o||r.set(r._input=o)}let i=this.orientation||he;if(i!==t._orientation){let e=n.uTroikaOrient.value;i=i.replace(/[^-+xyz]/g,"");let r=i!==he&&i.match(/^([-+])([xyz])([-+])([xyz])$/);if(r){let[,t,n,a,o]=r;le.set(0,0,0)[n]="-"===t?1:-1,ue.set(0,0,0)[o]="-"===a?-1:1,se.lookAt(ce,le.cross(ue),ue),e.setFromMatrix4(se)}else e.identity();t._orientation=i}}_parsePercent(e){if("string"==typeof e){let t=e.match(/^(-?[\d.]+)%$/),r=t?parseFloat(t[1]):NaN;e=(isNaN(r)?0:r/100)*this.fontSize}return e}localPositionToTextCoords(t,r=new e.Vector2){r.copy(t);const n=this.curveRadius;return n&&(r.x=Math.atan2(t.x,Math.abs(n)-Math.abs(t.z))*Math.abs(n)),r}worldPositionToTextCoords(t,r=new e.Vector2){return le.copy(t),this.localPositionToTextCoords(this.worldToLocal(le),r)}raycast(e,t){const{textRenderInfo:r,curveRadius:n}=this;if(r){const a=r.blockBounds,o=n?ve():pe(),i=o.geometry,{position:s,uv:l}=i.attributes;for(let e=0;e{this[t]=e[t]})),this}clone(){return(new this.constructor).copy(this)}}ye.forEach((e=>{const t="_private_"+e;Object.defineProperty(xe.prototype,e,{get(){return this[t]},set(e){e!==this[t]&&(this[t]=e,this._needsSync=!0)}})}));var Se="troika-text";function Ue(e){return{default:e,parse:function(e){return"string"==typeof e&&e.indexOf("%")>0?e:(e=+e,isNaN(e)?0:e)},stringify:function(e){return""+e}}}o.default.registerComponent(Se,{schema:{align:{type:"string",default:"left",oneOf:["left","right","center","justify"]},anchor:{default:"center",oneOf:["left","right","center","align"]},baseline:{default:"center",oneOf:["top","center","bottom"]},clipRect:{type:"string",default:"",parse:function(e){return e&&(e=e.split(/[\s,]+/).reduce((function(e,t){return t=+t,isNaN(t)||e.push(t),e}),[])),e&&4===e.length?e:null},stringify:function(e){return e?e.join(" "):""}},color:{type:"color",default:"#FFF"},colorRanges:{type:"string",default:null,parse:function(e){return"string"==typeof e?JSON.parse(e):e},stringify:JSON.stringify},curveRadius:{type:"number",default:0},depthOffset:{type:"number",default:0},direction:{type:"string",default:"auto",oneOf:["auto","ltr","rtl"]},fillOpacity:{type:"number",default:1},font:{type:"string"},fontSize:{type:"number",default:.2},letterSpacing:{type:"number",default:0},lineHeight:{type:"number"},maxWidth:{type:"number",default:1/0},outlineBlur:Ue(0),outlineColor:{type:"color",default:"#000"},outlineOffsetX:Ue(0),outlineOffsetY:Ue(0),outlineOpacity:{type:"number",default:1},outlineWidth:Ue(0),overflowWrap:{type:"string",default:"normal",oneOf:["normal","break-word"]},strokeColor:{type:"color",default:"grey"},strokeOpacity:{type:"number",default:1},strokeWidth:Ue(0),textIndent:{type:"number",default:0},value:{type:"string"},whiteSpace:{default:"normal",oneOf:["normal","nowrap"]}},init:function(){var e;"a-troika-text"===this.el.tagName.toLowerCase()?e=this.el:(e=document.createElement("a-entity"),this.el.appendChild(e)),this.troikaTextEntity=e;var t=this.troikaTextMesh=new xe;e.setObject3D("mesh",t)},update:function(){var e=this.data,t=this.troikaTextMesh,r=this.troikaTextEntity,n=e.font;if(t.text=(e.value||"").replace(/\\n/g,"\n").replace(/\\t/g,"\t"),t.textAlign=e.align,e.font.startsWith("#")){n=document.querySelector(e.font).getAttribute("src")}if(t.anchorX=we["align"===e.anchor?e.align:e.anchor]||"center",t.anchorY=Te[e.baseline]||"middle",t.color=e.color,t.colorRanges=e.colorRanges,t.clipRect=e.clipRect,t.curveRadius=e.curveRadius,t.depthOffset=e.depthOffset||0,t.direction=e.direction,t.fillOpacity=e.fillOpacity,t.font=n,t.fontSize=e.fontSize,t.letterSpacing=e.letterSpacing||0,t.lineHeight=e.lineHeight||"normal",t.outlineBlur=e.outlineBlur,t.outlineColor=e.outlineColor,t.outlineOffsetX=e.outlineOffsetX,t.outlineOffsetY=e.outlineOffsetY,t.outlineOpacity=e.outlineOpacity,t.outlineWidth=e.outlineWidth,t.overflowWrap=e.overflowWrap,t.strokeColor=e.strokeColor,t.strokeOpacity=e.strokeOpacity,t.strokeWidth=e.strokeWidth,t.textIndent=e.textIndent,t.whiteSpace=e.whiteSpace,t.maxWidth=e.maxWidth,t.sync(),r!==this.el){var a=this.el.getAttribute("troika-text-material");a?r.setAttribute("material",a):r.removeAttribute("material")}},remove:function(){this.troikaTextMesh.dispose(),this.troikaTextEntity!==this.el&&this.el.removeChild(this.troikaTextEntity)}});var ke,we={left:"left",center:"center",right:"right"},Te={top:"top",center:"middle",bottom:"bottom"},_e={},Fe=o.default.components["troika-text"].schema;Object.keys(Fe).map((function(e){var t=e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase();_e[t]="troika-text."+e})),o.default.registerPrimitive("a-troika-text",{defaultComponents:{"troika-text":{}},mappings:_e}),(ke=a).MathUtils||(ke.MathUtils=ke.Math)}(THREE,AFRAME); //# sourceMappingURL=aframe-troika-text.min.js.map