text: // All material copyright ESRI, All Rights Reserved, unless otherwise specified.
  // See https://js.arcgis.com/3.38/esri/copyright.txt for details.
  //>>built
  define("esri/layers/vectorTiles/views/2d/engine/webgl/SDFConverter",["require","exports","../../../../core/promiseUtils","../../../../core/promiseUtils","./packingUtils"],function(p,q,u,r,v){Object.defineProperty(q,"__esModule",{value:!0});p=function(){function n(b){this.size=b;this.canvas=document.createElement("canvas");this.canvas.width=this.canvas.height=b;this.context=this.canvas.getContext("2d");this._gridOuter=new Float64Array(b*b);this._gridInner=new Float64Array(b*b);this._f=new Float64Array(b);
  this._d=new Float64Array(b);this._z=new Float64Array(b+1);this._v=new Int16Array(b);b=document.createElementNS("http://www.w3.org/2000/svg","svg");b.setAttribute("style","position: absolute;");b.setAttribute("width","0");b.setAttribute("height","0");document.body.appendChild(b);this._svg=b}n.prototype.draw=function(b,g,c){var a=this;void 0===c&&(c=31);var k=this._createSVGString(b);return u.create(function(e,d){var f=new Image;f.src="data:image/svg+xml; charset\x3dutf8, "+encodeURIComponent(k);f.onload=
  function(){a.context.clearRect(0,0,a.size,a.size);a.context.drawImage(f,0,0,a.size,a.size);for(var w=a.context.getImageData(0,0,a.size,a.size),t=new Uint8Array(a.size*a.size*4),l=0;l<a.size*a.size;l++){var m=w.data[4*l+3]/255;a._gridOuter[l]=1===m?0:0===m?1E20:Math.pow(Math.max(0,.5-m),2);a._gridInner[l]=1===m?1E20:0===m?0:Math.pow(Math.max(0,m-.5),2)}a._edt(a._gridOuter,a.size,a.size);a._edt(a._gridInner,a.size,a.size);for(l=0;l<a.size*a.size;l++)v.packFloatRGBA(.5-(a._gridOuter[l]-a._gridInner[l])/
  (2*c),t,4*l);e(t)};var h=g&&g.signal;if(h)r.onAbort(h,function(){return d(r.createAbortError())})})};n.prototype._createSVGString=function(b){var g=document.createElementNS("http://www.w3.org/2000/svg","path");g.setAttribute("d",b);this._svg.appendChild(g);b=g.getBBox();var c=b.width/b.height,a=this.size/2,k;if(1<c){var e=k=a/b.width;var d=this.size/4;c=a-1/c*a/2}else k=e=a/b.height,d=a-a*c/2,c=this.size/4;g.setAttribute("style","transform: matrix("+k+", 0, 0, "+e+", "+(-b.x*k+d)+", "+(-b.y*e+c)+
  ")");b='\x3csvg style\x3d"fill:red;" height\x3d"'+this.size+'" width\x3d"'+this.size+'" xmlns\x3d"http://www.w3.org/2000/svg"\x3e'+this._svg.innerHTML+"\x3c/svg\x3e";this._svg.removeChild(g);return b};n.prototype._edt=function(b,g,c){for(var a=this._f,k=this._d,e=this._v,d=this._z,f=0;f<g;f++){for(var h=0;h<c;h++)a[h]=b[h*g+f];this._edt1d(a,k,e,d,c);for(h=0;h<c;h++)b[h*g+f]=k[h]}for(h=0;h<c;h++){for(f=0;f<g;f++)a[f]=b[h*g+f];this._edt1d(a,k,e,d,g);for(f=0;f<g;f++)b[h*g+f]=Math.sqrt(k[f])}};n.prototype._edt1d=
  function(b,g,c,a,k){c[0]=0;a[0]=-1E20;a[1]=1E20;for(var e=1,d=0;e<k;e++){for(var f=(b[e]+e*e-(b[c[d]]+c[d]*c[d]))/(2*e-2*c[d]);f<=a[d];)d--,f=(b[e]+e*e-(b[c[d]]+c[d]*c[d]))/(2*e-2*c[d]);d++;c[d]=e;a[d]=f;a[d+1]=1E20}for(d=e=0;e<k;e++){for(;a[d+1]<e;)d++;g[e]=(e-c[d])*(e-c[d])+b[c[d]]}};return n}();q.default=p});