@axsdk/core 0.2.5 → 0.2.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/lib.cjs CHANGED
@@ -20,7 +20,7 @@ var M7=Object.create;var{getPrototypeOf:Q7,defineProperty:s0,getOwnPropertyNames
20
20
  content: "" !important;
21
21
  display: none !important;
22
22
  }`,A5=function(M){z5(M,"."+CQ+H5+m6+`
23
- .`+EQ+D5+m6)},z5=function(M,q){var Z=M.ownerDocument;if(Z){var Q=Z.createElement("style");Q.textContent=q,M.appendChild(Q)}},p6=function(){function M(){}return M.getOrigin=function(q){var Z=M._link;if(!Z)return"about:blank";return Z.href=q,Z.href=Z.href,Z.protocol+Z.hostname+Z.port},M.isSameOrigin=function(q){return M.getOrigin(q)===M._origin},M.setContext=function(q){M._link=q.document.createElement("a"),M._origin=M.getOrigin(q.location.href)},M._origin="about:blank",M}(),F5=function(){function M(q,Z){this.context=q,this._options=Z,this._cache={}}return M.prototype.addImage=function(q){var Z=Promise.resolve();if(this.has(q))return Z;if(PQ(q)||B5(q))return(this._cache[q]=this.loadImage(q)).catch(function(){}),Z;return Z},M.prototype.match=function(q){return this._cache[q]},M.prototype.loadImage=function(q){return D(this,void 0,void 0,function(){var Z,Q,X,J,j=this;return F(this,function(G){switch(G.label){case 0:if(Z=p6.isSameOrigin(q),Q=!yQ(q)&&this._options.useCORS===!0&&Zq.SUPPORT_CORS_IMAGES&&!Z,X=!yQ(q)&&!Z&&!PQ(q)&&typeof this._options.proxy==="string"&&Zq.SUPPORT_CORS_XHR&&!Q,!Z&&this._options.allowTaint===!1&&!yQ(q)&&!PQ(q)&&!X&&!Q)return[2];if(J=q,!X)return[3,2];return[4,this.proxy(J)];case 1:J=G.sent(),G.label=2;case 2:return this.context.logger.debug("Added image "+q.substring(0,256)),[4,new Promise(function(Y,V){var H=new Image;if(H.onload=function(){return Y(H)},H.onerror=V,N5(J)||Q)H.crossOrigin="anonymous";if(H.src=J,H.complete===!0)setTimeout(function(){return Y(H)},500);if(j._options.imageTimeout>0)setTimeout(function(){return V("Timed out ("+j._options.imageTimeout+"ms) loading image")},j._options.imageTimeout)})];case 3:return[2,G.sent()]}})})},M.prototype.has=function(q){return typeof this._cache[q]<"u"},M.prototype.keys=function(){return Promise.resolve(Object.keys(this._cache))},M.prototype.proxy=function(q){var Z=this,Q=this._options.proxy;if(!Q)throw Error("No proxy defined");var X=q.substring(0,256);return new Promise(function(J,j){var G=Zq.SUPPORT_RESPONSE_TYPE?"blob":"text",Y=new XMLHttpRequest;Y.onload=function(){if(Y.status===200)if(G==="text")J(Y.response);else{var A=new FileReader;A.addEventListener("load",function(){return J(A.result)},!1),A.addEventListener("error",function(z){return j(z)},!1),A.readAsDataURL(Y.response)}else j("Failed to proxy resource "+X+" with status code "+Y.status)},Y.onerror=j;var V=Q.indexOf("?")>-1?"&":"?";if(Y.open("GET",""+Q+V+"url="+encodeURIComponent(q)+"&responseType="+G),G!=="text"&&Y instanceof XMLHttpRequest)Y.responseType=G;if(Z._options.imageTimeout){var H=Z._options.imageTimeout;Y.timeout=H,Y.ontimeout=function(){return j("Timed out ("+H+"ms) proxying "+X)}}Y.send()})},M}(),I5=/^data:image\/svg\+xml/i,O5=/^data:image\/.*;base64,/i,W5=/^data:image\/.*/i,B5=function(M){return Zq.SUPPORT_SVG_DRAWING||!w5(M)},yQ=function(M){return W5.test(M)},N5=function(M){return O5.test(M)},PQ=function(M){return M.substr(0,4)==="blob"},w5=function(M){return M.substr(-3).toLowerCase()==="svg"||I5.test(M)},N=function(){function M(q,Z){this.type=0,this.x=q,this.y=Z}return M.prototype.add=function(q,Z){return new M(this.x+q,this.y+Z)},M}(),A0=function(M,q,Z){return new N(M.x+(q.x-M.x)*Z,M.y+(q.y-M.y)*Z)},CM=function(){function M(q,Z,Q,X){this.type=1,this.start=q,this.startControl=Z,this.endControl=Q,this.end=X}return M.prototype.subdivide=function(q,Z){var Q=A0(this.start,this.startControl,q),X=A0(this.startControl,this.endControl,q),J=A0(this.endControl,this.end,q),j=A0(Q,X,q),G=A0(X,J,q),Y=A0(j,G,q);return Z?new M(this.start,Q,j,Y):new M(Y,G,J,this.end)},M.prototype.add=function(q,Z){return new M(this.start.add(q,Z),this.startControl.add(q,Z),this.endControl.add(q,Z),this.end.add(q,Z))},M.prototype.reverse=function(){return new M(this.end,this.endControl,this.startControl,this.start)},M}(),Iq=function(M){return M.type===1},L5=function(){function M(q){var{styles:Z,bounds:Q}=q,X=p0(Z.borderTopLeftRadius,Q.width,Q.height),J=X[0],j=X[1],G=p0(Z.borderTopRightRadius,Q.width,Q.height),Y=G[0],V=G[1],H=p0(Z.borderBottomRightRadius,Q.width,Q.height),A=H[0],z=H[1],R=p0(Z.borderBottomLeftRadius,Q.width,Q.height),W=R[0],B=R[1],m=[];m.push((J+Y)/Q.width),m.push((W+A)/Q.width),m.push((j+B)/Q.height),m.push((V+z)/Q.height);var E=Math.max.apply(Math,m);if(E>1)J/=E,j/=E,Y/=E,V/=E,A/=E,z/=E,W/=E,B/=E;var S=Q.width-Y,h=Q.height-z,p=Q.width-A,P=Q.height-B,w=Z.borderTopWidth,b=Z.borderRightWidth,v=Z.borderBottomWidth,k=Z.borderLeftWidth,t=d(Z.paddingTop,q.bounds.width),Gq=d(Z.paddingRight,q.bounds.width),Aq=d(Z.paddingBottom,q.bounds.width),s=d(Z.paddingLeft,q.bounds.width);this.topLeftBorderDoubleOuterBox=J>0||j>0?a(Q.left+k/3,Q.top+w/3,J-k/3,j-w/3,_.TOP_LEFT):new N(Q.left+k/3,Q.top+w/3),this.topRightBorderDoubleOuterBox=J>0||j>0?a(Q.left+S,Q.top+w/3,Y-b/3,V-w/3,_.TOP_RIGHT):new N(Q.left+Q.width-b/3,Q.top+w/3),this.bottomRightBorderDoubleOuterBox=A>0||z>0?a(Q.left+p,Q.top+h,A-b/3,z-v/3,_.BOTTOM_RIGHT):new N(Q.left+Q.width-b/3,Q.top+Q.height-v/3),this.bottomLeftBorderDoubleOuterBox=W>0||B>0?a(Q.left+k/3,Q.top+P,W-k/3,B-v/3,_.BOTTOM_LEFT):new N(Q.left+k/3,Q.top+Q.height-v/3),this.topLeftBorderDoubleInnerBox=J>0||j>0?a(Q.left+k*2/3,Q.top+w*2/3,J-k*2/3,j-w*2/3,_.TOP_LEFT):new N(Q.left+k*2/3,Q.top+w*2/3),this.topRightBorderDoubleInnerBox=J>0||j>0?a(Q.left+S,Q.top+w*2/3,Y-b*2/3,V-w*2/3,_.TOP_RIGHT):new N(Q.left+Q.width-b*2/3,Q.top+w*2/3),this.bottomRightBorderDoubleInnerBox=A>0||z>0?a(Q.left+p,Q.top+h,A-b*2/3,z-v*2/3,_.BOTTOM_RIGHT):new N(Q.left+Q.width-b*2/3,Q.top+Q.height-v*2/3),this.bottomLeftBorderDoubleInnerBox=W>0||B>0?a(Q.left+k*2/3,Q.top+P,W-k*2/3,B-v*2/3,_.BOTTOM_LEFT):new N(Q.left+k*2/3,Q.top+Q.height-v*2/3),this.topLeftBorderStroke=J>0||j>0?a(Q.left+k/2,Q.top+w/2,J-k/2,j-w/2,_.TOP_LEFT):new N(Q.left+k/2,Q.top+w/2),this.topRightBorderStroke=J>0||j>0?a(Q.left+S,Q.top+w/2,Y-b/2,V-w/2,_.TOP_RIGHT):new N(Q.left+Q.width-b/2,Q.top+w/2),this.bottomRightBorderStroke=A>0||z>0?a(Q.left+p,Q.top+h,A-b/2,z-v/2,_.BOTTOM_RIGHT):new N(Q.left+Q.width-b/2,Q.top+Q.height-v/2),this.bottomLeftBorderStroke=W>0||B>0?a(Q.left+k/2,Q.top+P,W-k/2,B-v/2,_.BOTTOM_LEFT):new N(Q.left+k/2,Q.top+Q.height-v/2),this.topLeftBorderBox=J>0||j>0?a(Q.left,Q.top,J,j,_.TOP_LEFT):new N(Q.left,Q.top),this.topRightBorderBox=Y>0||V>0?a(Q.left+S,Q.top,Y,V,_.TOP_RIGHT):new N(Q.left+Q.width,Q.top),this.bottomRightBorderBox=A>0||z>0?a(Q.left+p,Q.top+h,A,z,_.BOTTOM_RIGHT):new N(Q.left+Q.width,Q.top+Q.height),this.bottomLeftBorderBox=W>0||B>0?a(Q.left,Q.top+P,W,B,_.BOTTOM_LEFT):new N(Q.left,Q.top+Q.height),this.topLeftPaddingBox=J>0||j>0?a(Q.left+k,Q.top+w,Math.max(0,J-k),Math.max(0,j-w),_.TOP_LEFT):new N(Q.left+k,Q.top+w),this.topRightPaddingBox=Y>0||V>0?a(Q.left+Math.min(S,Q.width-b),Q.top+w,S>Q.width+b?0:Math.max(0,Y-b),Math.max(0,V-w),_.TOP_RIGHT):new N(Q.left+Q.width-b,Q.top+w),this.bottomRightPaddingBox=A>0||z>0?a(Q.left+Math.min(p,Q.width-k),Q.top+Math.min(h,Q.height-v),Math.max(0,A-b),Math.max(0,z-v),_.BOTTOM_RIGHT):new N(Q.left+Q.width-b,Q.top+Q.height-v),this.bottomLeftPaddingBox=W>0||B>0?a(Q.left+k,Q.top+Math.min(P,Q.height-v),Math.max(0,W-k),Math.max(0,B-v),_.BOTTOM_LEFT):new N(Q.left+k,Q.top+Q.height-v),this.topLeftContentBox=J>0||j>0?a(Q.left+k+s,Q.top+w+t,Math.max(0,J-(k+s)),Math.max(0,j-(w+t)),_.TOP_LEFT):new N(Q.left+k+s,Q.top+w+t),this.topRightContentBox=Y>0||V>0?a(Q.left+Math.min(S,Q.width+k+s),Q.top+w+t,S>Q.width+k+s?0:Y-k+s,V-(w+t),_.TOP_RIGHT):new N(Q.left+Q.width-(b+Gq),Q.top+w+t),this.bottomRightContentBox=A>0||z>0?a(Q.left+Math.min(p,Q.width-(k+s)),Q.top+Math.min(h,Q.height+w+t),Math.max(0,A-(b+Gq)),z-(v+Aq),_.BOTTOM_RIGHT):new N(Q.left+Q.width-(b+Gq),Q.top+Q.height-(v+Aq)),this.bottomLeftContentBox=W>0||B>0?a(Q.left+k+s,Q.top+P,Math.max(0,W-(k+s)),B-(v+Aq),_.BOTTOM_LEFT):new N(Q.left+k+s,Q.top+Q.height-(v+Aq))}return M}(),_;(function(M){M[M.TOP_LEFT=0]="TOP_LEFT",M[M.TOP_RIGHT=1]="TOP_RIGHT",M[M.BOTTOM_RIGHT=2]="BOTTOM_RIGHT",M[M.BOTTOM_LEFT=3]="BOTTOM_LEFT"})(_||(_={}));var a=function(M,q,Z,Q,X){var J=4*((Math.sqrt(2)-1)/3),j=Z*J,G=Q*J,Y=M+Z,V=q+Q;switch(X){case _.TOP_LEFT:return new CM(new N(M,V),new N(M,V-G),new N(Y-j,q),new N(Y,q));case _.TOP_RIGHT:return new CM(new N(M,q),new N(M+j,q),new N(Y,V-G),new N(Y,V));case _.BOTTOM_RIGHT:return new CM(new N(Y,q),new N(Y,q+G),new N(M+j,V),new N(M,V));case _.BOTTOM_LEFT:default:return new CM(new N(Y,V),new N(Y-j,V),new N(M,q+G),new N(M,q))}},EM=function(M){return[M.topLeftBorderBox,M.topRightBorderBox,M.bottomRightBorderBox,M.bottomLeftBorderBox]},R5=function(M){return[M.topLeftContentBox,M.topRightContentBox,M.bottomRightContentBox,M.bottomLeftContentBox]},yM=function(M){return[M.topLeftPaddingBox,M.topRightPaddingBox,M.bottomRightPaddingBox,M.bottomLeftPaddingBox]},T5=function(){function M(q,Z,Q){this.offsetX=q,this.offsetY=Z,this.matrix=Q,this.type=0,this.target=6}return M}(),PM=function(){function M(q,Z){this.path=q,this.target=Z,this.type=1}return M}(),S5=function(){function M(q){this.opacity=q,this.type=2,this.target=6}return M}(),C5=function(M){return M.type===0},g6=function(M){return M.type===1},E5=function(M){return M.type===2},b6=function(M,q){if(M.length===q.length)return M.some(function(Z,Q){return Z===q[Q]});return!1},y5=function(M,q,Z,Q,X){return M.map(function(J,j){switch(j){case 0:return J.add(q,Z);case 1:return J.add(q+Q,Z);case 2:return J.add(q+Q,Z+X);case 3:return J.add(q,Z+X)}return J})},v6=function(){function M(q){this.element=q,this.inlineLevel=[],this.nonInlineLevel=[],this.negativeZIndex=[],this.zeroOrAutoZIndexOrTransformedOrOpacity=[],this.positiveZIndex=[],this.nonPositionedFloats=[],this.nonPositionedInlineLevel=[]}return M}(),x6=function(){function M(q,Z){if(this.container=q,this.parent=Z,this.effects=[],this.curves=new L5(this.container),this.container.styles.opacity<1)this.effects.push(new S5(this.container.styles.opacity));if(this.container.styles.transform!==null){var Q=this.container.bounds.left+this.container.styles.transformOrigin[0].number,X=this.container.bounds.top+this.container.styles.transformOrigin[1].number,J=this.container.styles.transform;this.effects.push(new T5(Q,X,J))}if(this.container.styles.overflowX!==0){var j=EM(this.curves),G=yM(this.curves);if(b6(j,G))this.effects.push(new PM(j,6));else this.effects.push(new PM(j,2)),this.effects.push(new PM(G,4))}}return M.prototype.getEffects=function(q){var Z=[2,3].indexOf(this.container.styles.position)===-1,Q=this.parent,X=this.effects.slice(0);while(Q){var J=Q.effects.filter(function(Y){return!g6(Y)});if(Z||Q.container.styles.position!==0||!Q.parent){if(X.unshift.apply(X,J),Z=[2,3].indexOf(Q.container.styles.position)===-1,Q.container.styles.overflowX!==0){var j=EM(Q.curves),G=yM(Q.curves);if(!b6(j,G))X.unshift(new PM(G,6))}}else X.unshift.apply(X,J);Q=Q.parent}return X.filter(function(Y){return e(Y.target,q)})},M}(),kQ=function(M,q,Z,Q){M.container.elements.forEach(function(X){var J=e(X.flags,4),j=e(X.flags,2),G=new x6(X,M);if(e(X.styles.display,2048))Q.push(G);var Y=e(X.flags,8)?[]:Q;if(J||j){var V=J||X.styles.isPositioned()?Z:q,H=new v6(G);if(X.styles.isPositioned()||X.styles.opacity<1||X.styles.isTransformed()){var A=X.styles.zIndex.order;if(A<0){var z=0;V.negativeZIndex.some(function(W,B){if(A>W.element.container.styles.zIndex.order)return z=B,!1;else if(z>0)return!0;return!1}),V.negativeZIndex.splice(z,0,H)}else if(A>0){var R=0;V.positiveZIndex.some(function(W,B){if(A>=W.element.container.styles.zIndex.order)return R=B+1,!1;else if(R>0)return!0;return!1}),V.positiveZIndex.splice(R,0,H)}else V.zeroOrAutoZIndexOrTransformedOrOpacity.push(H)}else if(X.styles.isFloating())V.nonPositionedFloats.push(H);else V.nonPositionedInlineLevel.push(H);kQ(G,H,J?H:Z,Y)}else{if(X.styles.isInlineLevel())q.inlineLevel.push(G);else q.nonInlineLevel.push(G);kQ(G,q,Z,Y)}if(e(X.flags,8))h6(X,Y)})},h6=function(M,q){var Z=M instanceof BQ?M.start:1,Q=M instanceof BQ?M.reversed:!1;for(var X=0;X<q.length;X++){var J=q[X];if(J.container instanceof $6&&typeof J.container.value==="number"&&J.container.value!==0)Z=J.container.value;J.listValue=_0(Z,J.container.styles.listStyleType,!0),Z+=Q?-1:1}},P5=function(M){var q=new x6(M,null),Z=new v6(q),Q=[];return kQ(q,Z,Z,Q),h6(q.container,Q),Z},_6=function(M,q){switch(q){case 0:return Oq(M.topLeftBorderBox,M.topLeftPaddingBox,M.topRightBorderBox,M.topRightPaddingBox);case 1:return Oq(M.topRightBorderBox,M.topRightPaddingBox,M.bottomRightBorderBox,M.bottomRightPaddingBox);case 2:return Oq(M.bottomRightBorderBox,M.bottomRightPaddingBox,M.bottomLeftBorderBox,M.bottomLeftPaddingBox);case 3:default:return Oq(M.bottomLeftBorderBox,M.bottomLeftPaddingBox,M.topLeftBorderBox,M.topLeftPaddingBox)}},k5=function(M,q){switch(q){case 0:return Oq(M.topLeftBorderBox,M.topLeftBorderDoubleOuterBox,M.topRightBorderBox,M.topRightBorderDoubleOuterBox);case 1:return Oq(M.topRightBorderBox,M.topRightBorderDoubleOuterBox,M.bottomRightBorderBox,M.bottomRightBorderDoubleOuterBox);case 2:return Oq(M.bottomRightBorderBox,M.bottomRightBorderDoubleOuterBox,M.bottomLeftBorderBox,M.bottomLeftBorderDoubleOuterBox);case 3:default:return Oq(M.bottomLeftBorderBox,M.bottomLeftBorderDoubleOuterBox,M.topLeftBorderBox,M.topLeftBorderDoubleOuterBox)}},f5=function(M,q){switch(q){case 0:return Oq(M.topLeftBorderDoubleInnerBox,M.topLeftPaddingBox,M.topRightBorderDoubleInnerBox,M.topRightPaddingBox);case 1:return Oq(M.topRightBorderDoubleInnerBox,M.topRightPaddingBox,M.bottomRightBorderDoubleInnerBox,M.bottomRightPaddingBox);case 2:return Oq(M.bottomRightBorderDoubleInnerBox,M.bottomRightPaddingBox,M.bottomLeftBorderDoubleInnerBox,M.bottomLeftPaddingBox);case 3:default:return Oq(M.bottomLeftBorderDoubleInnerBox,M.bottomLeftPaddingBox,M.topLeftBorderDoubleInnerBox,M.topLeftPaddingBox)}},m5=function(M,q){switch(q){case 0:return kM(M.topLeftBorderStroke,M.topRightBorderStroke);case 1:return kM(M.topRightBorderStroke,M.bottomRightBorderStroke);case 2:return kM(M.bottomRightBorderStroke,M.bottomLeftBorderStroke);case 3:default:return kM(M.bottomLeftBorderStroke,M.topLeftBorderStroke)}},kM=function(M,q){var Z=[];if(Iq(M))Z.push(M.subdivide(0.5,!1));else Z.push(M);if(Iq(q))Z.push(q.subdivide(0.5,!0));else Z.push(q);return Z},Oq=function(M,q,Z,Q){var X=[];if(Iq(M))X.push(M.subdivide(0.5,!1));else X.push(M);if(Iq(Z))X.push(Z.subdivide(0.5,!0));else X.push(Z);if(Iq(Q))X.push(Q.subdivide(0.5,!0).reverse());else X.push(Q);if(Iq(q))X.push(q.subdivide(0.5,!1).reverse());else X.push(q);return X},u6=function(M){var{bounds:q,styles:Z}=M;return q.add(Z.borderLeftWidth,Z.borderTopWidth,-(Z.borderRightWidth+Z.borderLeftWidth),-(Z.borderTopWidth+Z.borderBottomWidth))},fM=function(M){var{styles:q,bounds:Z}=M,Q=d(q.paddingLeft,Z.width),X=d(q.paddingRight,Z.width),J=d(q.paddingTop,Z.width),j=d(q.paddingBottom,Z.width);return Z.add(Q+q.borderLeftWidth,J+q.borderTopWidth,-(q.borderRightWidth+q.borderLeftWidth+Q+X),-(q.borderTopWidth+q.borderBottomWidth+J+j))},p5=function(M,q){if(M===0)return q.bounds;if(M===2)return fM(q);return u6(q)},g5=function(M,q){if(M===0)return q.bounds;if(M===2)return fM(q);return u6(q)},fQ=function(M,q,Z){var Q=p5(F0(M.styles.backgroundOrigin,q),M),X=g5(F0(M.styles.backgroundClip,q),M),J=b5(F0(M.styles.backgroundSize,q),Z,Q),j=J[0],G=J[1],Y=p0(F0(M.styles.backgroundPosition,q),Q.width-j,Q.height-G),V=v5(F0(M.styles.backgroundRepeat,q),Y,J,Q,X),H=Math.round(Q.left+Y[0]),A=Math.round(Q.top+Y[1]);return[V,H,A,j,G]},z0=function(M){return l(M)&&M.value===$0.AUTO},mM=function(M){return typeof M==="number"},b5=function(M,q,Z){var Q=q[0],X=q[1],J=q[2],j=M[0],G=M[1];if(!j)return[0,0];if(o(j)&&G&&o(G))return[d(j,Z.width),d(G,Z.height)];var Y=mM(J);if(l(j)&&(j.value===$0.CONTAIN||j.value===$0.COVER)){if(mM(J)){var V=Z.width/Z.height;return V<J!==(j.value===$0.COVER)?[Z.width,Z.width/J]:[Z.height*J,Z.height]}return[Z.width,Z.height]}var H=mM(Q),A=mM(X),z=H||A;if(z0(j)&&(!G||z0(G))){if(H&&A)return[Q,X];if(!Y&&!z)return[Z.width,Z.height];if(z&&Y){var R=H?Q:X*J,W=A?X:Q/J;return[R,W]}var B=H?Q:Z.width,m=A?X:Z.height;return[B,m]}if(Y){var E=0,S=0;if(o(j))E=d(j,Z.width);else if(o(G))S=d(G,Z.height);if(z0(j))E=S*J;else if(!G||z0(G))S=E/J;return[E,S]}var h=null,p=null;if(o(j))h=d(j,Z.width);else if(G&&o(G))p=d(G,Z.height);if(h!==null&&(!G||z0(G)))p=H&&A?h/Q*X:Z.height;if(p!==null&&z0(j))h=H&&A?p/X*Q:Z.width;if(h!==null&&p!==null)return[h,p];throw Error("Unable to calculate background-size for element")},F0=function(M,q){var Z=M[q];if(typeof Z>"u")return M[0];return Z},v5=function(M,q,Z,Q,X){var J=q[0],j=q[1],G=Z[0],Y=Z[1];switch(M){case 2:return[new N(Math.round(Q.left),Math.round(Q.top+j)),new N(Math.round(Q.left+Q.width),Math.round(Q.top+j)),new N(Math.round(Q.left+Q.width),Math.round(Y+Q.top+j)),new N(Math.round(Q.left),Math.round(Y+Q.top+j))];case 3:return[new N(Math.round(Q.left+J),Math.round(Q.top)),new N(Math.round(Q.left+J+G),Math.round(Q.top)),new N(Math.round(Q.left+J+G),Math.round(Q.height+Q.top)),new N(Math.round(Q.left+J),Math.round(Q.height+Q.top))];case 1:return[new N(Math.round(Q.left+J),Math.round(Q.top+j)),new N(Math.round(Q.left+J+G),Math.round(Q.top+j)),new N(Math.round(Q.left+J+G),Math.round(Q.top+j+Y)),new N(Math.round(Q.left+J),Math.round(Q.top+j+Y))];default:return[new N(Math.round(X.left),Math.round(X.top)),new N(Math.round(X.left+X.width),Math.round(X.top)),new N(Math.round(X.left+X.width),Math.round(X.height+X.top)),new N(Math.round(X.left),Math.round(X.height+X.top))]}},x5="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7",l6="Hidden Text",h5=function(){function M(q){this._data={},this._document=q}return M.prototype.parseMetrics=function(q,Z){var Q=this._document.createElement("div"),X=this._document.createElement("img"),J=this._document.createElement("span"),j=this._document.body;Q.style.visibility="hidden",Q.style.fontFamily=q,Q.style.fontSize=Z,Q.style.margin="0",Q.style.padding="0",Q.style.whiteSpace="nowrap",j.appendChild(Q),X.src=x5,X.width=1,X.height=1,X.style.margin="0",X.style.padding="0",X.style.verticalAlign="baseline",J.style.fontFamily=q,J.style.fontSize=Z,J.style.margin="0",J.style.padding="0",J.appendChild(this._document.createTextNode(l6)),Q.appendChild(J),Q.appendChild(X);var G=X.offsetTop-J.offsetTop+2;Q.removeChild(J),Q.appendChild(this._document.createTextNode(l6)),Q.style.lineHeight="normal",X.style.verticalAlign="super";var Y=X.offsetTop-Q.offsetTop+2;return j.removeChild(Q),{baseline:G,middle:Y}},M.prototype.getMetrics=function(q,Z){var Q=q+" "+Z;if(typeof this._data[Q]>"u")this._data[Q]=this.parseMetrics(q,Z);return this._data[Q]},M}(),s6=function(){function M(q,Z){this.context=q,this.options=Z}return M}(),_5=1e4,u5=function(M){K(q,M);function q(Z,Q){var X=M.call(this,Z,Q)||this;if(X._activeEffects=[],X.canvas=Q.canvas?Q.canvas:document.createElement("canvas"),X.ctx=X.canvas.getContext("2d"),!Q.canvas)X.canvas.width=Math.floor(Q.width*Q.scale),X.canvas.height=Math.floor(Q.height*Q.scale),X.canvas.style.width=Q.width+"px",X.canvas.style.height=Q.height+"px";return X.fontMetrics=new h5(document),X.ctx.scale(X.options.scale,X.options.scale),X.ctx.translate(-Q.x,-Q.y),X.ctx.textBaseline="bottom",X._activeEffects=[],X.context.logger.debug("Canvas renderer initialized ("+Q.width+"x"+Q.height+") with scale "+Q.scale),X}return q.prototype.applyEffects=function(Z){var Q=this;while(this._activeEffects.length)this.popEffect();Z.forEach(function(X){return Q.applyEffect(X)})},q.prototype.applyEffect=function(Z){if(this.ctx.save(),E5(Z))this.ctx.globalAlpha=Z.opacity;if(C5(Z))this.ctx.translate(Z.offsetX,Z.offsetY),this.ctx.transform(Z.matrix[0],Z.matrix[1],Z.matrix[2],Z.matrix[3],Z.matrix[4],Z.matrix[5]),this.ctx.translate(-Z.offsetX,-Z.offsetY);if(g6(Z))this.path(Z.path),this.ctx.clip();this._activeEffects.push(Z)},q.prototype.popEffect=function(){this._activeEffects.pop(),this.ctx.restore()},q.prototype.renderStack=function(Z){return D(this,void 0,void 0,function(){var Q;return F(this,function(X){switch(X.label){case 0:if(Q=Z.element.container.styles,!Q.isVisible())return[3,2];return[4,this.renderStackContent(Z)];case 1:X.sent(),X.label=2;case 2:return[2]}})})},q.prototype.renderNode=function(Z){return D(this,void 0,void 0,function(){return F(this,function(Q){switch(Q.label){case 0:if(e(Z.container.flags,16))debugger;if(!Z.container.styles.isVisible())return[3,3];return[4,this.renderNodeBackgroundAndBorders(Z)];case 1:return Q.sent(),[4,this.renderNodeContent(Z)];case 2:Q.sent(),Q.label=3;case 3:return[2]}})})},q.prototype.renderTextWithLetterSpacing=function(Z,Q,X){var J=this;if(Q===0)this.ctx.fillText(Z.text,Z.bounds.left,Z.bounds.top+X);else{var j=WQ(Z.text);j.reduce(function(G,Y){return J.ctx.fillText(Y,G,Z.bounds.top+X),G+J.ctx.measureText(Y).width},Z.bounds.left)}},q.prototype.createFontStyle=function(Z){var Q=Z.fontVariant.filter(function(j){return j==="normal"||j==="small-caps"}).join(""),X=a5(Z.fontFamily).join(", "),J=m0(Z.fontSize)?""+Z.fontSize.number+Z.fontSize.unit:Z.fontSize.number+"px";return[[Z.fontStyle,Q,Z.fontWeight,J,X].join(" "),X,J]},q.prototype.renderTextNode=function(Z,Q){return D(this,void 0,void 0,function(){var X,J,j,G,Y,V,H,A,z=this;return F(this,function(R){return X=this.createFontStyle(Q),J=X[0],j=X[1],G=X[2],this.ctx.font=J,this.ctx.direction=Q.direction===1?"rtl":"ltr",this.ctx.textAlign="left",this.ctx.textBaseline="alphabetic",Y=this.fontMetrics.getMetrics(j,G),V=Y.baseline,H=Y.middle,A=Q.paintOrder,Z.textBounds.forEach(function(W){A.forEach(function(B){switch(B){case 0:z.ctx.fillStyle=qq(Q.color),z.renderTextWithLetterSpacing(W,Q.letterSpacing,V);var m=Q.textShadow;if(m.length&&W.text.trim().length)m.slice(0).reverse().forEach(function(E){z.ctx.shadowColor=qq(E.color),z.ctx.shadowOffsetX=E.offsetX.number*z.options.scale,z.ctx.shadowOffsetY=E.offsetY.number*z.options.scale,z.ctx.shadowBlur=E.blur.number,z.renderTextWithLetterSpacing(W,Q.letterSpacing,V)}),z.ctx.shadowColor="",z.ctx.shadowOffsetX=0,z.ctx.shadowOffsetY=0,z.ctx.shadowBlur=0;if(Q.textDecorationLine.length)z.ctx.fillStyle=qq(Q.textDecorationColor||Q.color),Q.textDecorationLine.forEach(function(E){switch(E){case 1:z.ctx.fillRect(W.bounds.left,Math.round(W.bounds.top+V),W.bounds.width,1);break;case 2:z.ctx.fillRect(W.bounds.left,Math.round(W.bounds.top),W.bounds.width,1);break;case 3:z.ctx.fillRect(W.bounds.left,Math.ceil(W.bounds.top+H),W.bounds.width,1);break}});break;case 1:if(Q.webkitTextStrokeWidth&&W.text.trim().length)z.ctx.strokeStyle=qq(Q.webkitTextStrokeColor),z.ctx.lineWidth=Q.webkitTextStrokeWidth,z.ctx.lineJoin=window.chrome?"miter":"round",z.ctx.strokeText(W.text,W.bounds.left,W.bounds.top+V);z.ctx.strokeStyle="",z.ctx.lineWidth=0,z.ctx.lineJoin="miter";break}})}),[2]})})},q.prototype.renderReplacedElement=function(Z,Q,X){if(X&&Z.intrinsicWidth>0&&Z.intrinsicHeight>0){var J=fM(Z),j=yM(Q);this.path(j),this.ctx.save(),this.ctx.clip(),this.ctx.drawImage(X,0,0,Z.intrinsicWidth,Z.intrinsicHeight,J.left,J.top,J.width,J.height),this.ctx.restore()}},q.prototype.renderNodeContent=function(Z){return D(this,void 0,void 0,function(){var Q,X,J,j,G,Y,S,S,V,H,A,z,p,R,W,P,B,m,E,S,h,p,P;return F(this,function(w){switch(w.label){case 0:this.applyEffects(Z.getEffects(4)),Q=Z.container,X=Z.curves,J=Q.styles,j=0,G=Q.textNodes,w.label=1;case 1:if(!(j<G.length))return[3,4];return Y=G[j],[4,this.renderTextNode(Y,J)];case 2:w.sent(),w.label=3;case 3:return j++,[3,1];case 4:if(!(Q instanceof Y6))return[3,8];w.label=5;case 5:return w.trys.push([5,7,,8]),[4,this.context.cache.match(Q.src)];case 6:return S=w.sent(),this.renderReplacedElement(Q,X,S),[3,8];case 7:return w.sent(),this.context.logger.error("Error loading image "+Q.src),[3,8];case 8:if(Q instanceof G6)this.renderReplacedElement(Q,X,Q.canvas);if(!(Q instanceof K6))return[3,12];w.label=9;case 9:return w.trys.push([9,11,,12]),[4,this.context.cache.match(Q.svg)];case 10:return S=w.sent(),this.renderReplacedElement(Q,X,S),[3,12];case 11:return w.sent(),this.context.logger.error("Error loading svg "+Q.svg.substring(0,255)),[3,12];case 12:if(!(Q instanceof A6&&Q.tree))return[3,14];return V=new q(this.context,{scale:this.options.scale,backgroundColor:Q.backgroundColor,x:0,y:0,width:Q.width,height:Q.height}),[4,V.render(Q.tree)];case 13:if(H=w.sent(),Q.width&&Q.height)this.ctx.drawImage(H,0,0,Q.width,Q.height,Q.bounds.left,Q.bounds.top,Q.bounds.width,Q.bounds.height);w.label=14;case 14:if(Q instanceof NQ){if(A=Math.min(Q.bounds.width,Q.bounds.height),Q.type===NM){if(Q.checked)this.ctx.save(),this.path([new N(Q.bounds.left+A*0.39363,Q.bounds.top+A*0.79),new N(Q.bounds.left+A*0.16,Q.bounds.top+A*0.5549),new N(Q.bounds.left+A*0.27347,Q.bounds.top+A*0.44071),new N(Q.bounds.left+A*0.39694,Q.bounds.top+A*0.5649),new N(Q.bounds.left+A*0.72983,Q.bounds.top+A*0.23),new N(Q.bounds.left+A*0.84,Q.bounds.top+A*0.34085),new N(Q.bounds.left+A*0.39363,Q.bounds.top+A*0.79)]),this.ctx.fillStyle=qq(V6),this.ctx.fill(),this.ctx.restore()}else if(Q.type===wM){if(Q.checked)this.ctx.save(),this.ctx.beginPath(),this.ctx.arc(Q.bounds.left+A/2,Q.bounds.top+A/2,A/4,0,Math.PI*2,!0),this.ctx.fillStyle=qq(V6),this.ctx.fill(),this.ctx.restore()}}if(l5(Q)&&Q.value.length){switch(z=this.createFontStyle(J),p=z[0],R=z[1],W=this.fontMetrics.getMetrics(p,R).baseline,this.ctx.font=p,this.ctx.fillStyle=qq(J.color),this.ctx.textBaseline="alphabetic",this.ctx.textAlign=d5(Q.styles.textAlign),P=fM(Q),B=0,Q.styles.textAlign){case 1:B+=P.width/2;break;case 2:B+=P.width;break}m=P.add(B,0,0,-P.height/2+1),this.ctx.save(),this.path([new N(P.left,P.top),new N(P.left+P.width,P.top),new N(P.left+P.width,P.top+P.height),new N(P.left,P.top+P.height)]),this.ctx.clip(),this.renderTextWithLetterSpacing(new x0(Q.value,m),J.letterSpacing,W),this.ctx.restore(),this.ctx.textBaseline="alphabetic",this.ctx.textAlign="left"}if(!e(Q.styles.display,2048))return[3,20];if(Q.styles.listStyleImage===null)return[3,19];if(E=Q.styles.listStyleImage,E.type!==0)return[3,18];S=void 0,h=E.url,w.label=15;case 15:return w.trys.push([15,17,,18]),[4,this.context.cache.match(h)];case 16:return S=w.sent(),this.ctx.drawImage(S,Q.bounds.left-(S.width+10),Q.bounds.top),[3,18];case 17:return w.sent(),this.context.logger.error("Error loading list-style-image "+h),[3,18];case 18:return[3,20];case 19:if(Z.listValue&&Q.styles.listStyleType!==-1)p=this.createFontStyle(J)[0],this.ctx.font=p,this.ctx.fillStyle=qq(J.color),this.ctx.textBaseline="middle",this.ctx.textAlign="right",P=new O(Q.bounds.left,Q.bounds.top+d(Q.styles.paddingTop,Q.bounds.width),Q.bounds.width,l1(J.lineHeight,J.fontSize.number)/2+1),this.renderTextWithLetterSpacing(new x0(Z.listValue,P),J.letterSpacing,l1(J.lineHeight,J.fontSize.number)/2+2),this.ctx.textBaseline="bottom",this.ctx.textAlign="left";w.label=20;case 20:return[2]}})})},q.prototype.renderStackContent=function(Z){return D(this,void 0,void 0,function(){var Q,X,E,J,j,E,G,Y,E,V,H,E,A,z,E,R,W,E,B,m,E;return F(this,function(S){switch(S.label){case 0:if(e(Z.element.container.flags,16))debugger;return[4,this.renderNodeBackgroundAndBorders(Z.element)];case 1:S.sent(),Q=0,X=Z.negativeZIndex,S.label=2;case 2:if(!(Q<X.length))return[3,5];return E=X[Q],[4,this.renderStack(E)];case 3:S.sent(),S.label=4;case 4:return Q++,[3,2];case 5:return[4,this.renderNodeContent(Z.element)];case 6:S.sent(),J=0,j=Z.nonInlineLevel,S.label=7;case 7:if(!(J<j.length))return[3,10];return E=j[J],[4,this.renderNode(E)];case 8:S.sent(),S.label=9;case 9:return J++,[3,7];case 10:G=0,Y=Z.nonPositionedFloats,S.label=11;case 11:if(!(G<Y.length))return[3,14];return E=Y[G],[4,this.renderStack(E)];case 12:S.sent(),S.label=13;case 13:return G++,[3,11];case 14:V=0,H=Z.nonPositionedInlineLevel,S.label=15;case 15:if(!(V<H.length))return[3,18];return E=H[V],[4,this.renderStack(E)];case 16:S.sent(),S.label=17;case 17:return V++,[3,15];case 18:A=0,z=Z.inlineLevel,S.label=19;case 19:if(!(A<z.length))return[3,22];return E=z[A],[4,this.renderNode(E)];case 20:S.sent(),S.label=21;case 21:return A++,[3,19];case 22:R=0,W=Z.zeroOrAutoZIndexOrTransformedOrOpacity,S.label=23;case 23:if(!(R<W.length))return[3,26];return E=W[R],[4,this.renderStack(E)];case 24:S.sent(),S.label=25;case 25:return R++,[3,23];case 26:B=0,m=Z.positiveZIndex,S.label=27;case 27:if(!(B<m.length))return[3,30];return E=m[B],[4,this.renderStack(E)];case 28:S.sent(),S.label=29;case 29:return B++,[3,27];case 30:return[2]}})})},q.prototype.mask=function(Z){this.ctx.beginPath(),this.ctx.moveTo(0,0),this.ctx.lineTo(this.canvas.width,0),this.ctx.lineTo(this.canvas.width,this.canvas.height),this.ctx.lineTo(0,this.canvas.height),this.ctx.lineTo(0,0),this.formatPath(Z.slice(0).reverse()),this.ctx.closePath()},q.prototype.path=function(Z){this.ctx.beginPath(),this.formatPath(Z),this.ctx.closePath()},q.prototype.formatPath=function(Z){var Q=this;Z.forEach(function(X,J){var j=Iq(X)?X.start:X;if(J===0)Q.ctx.moveTo(j.x,j.y);else Q.ctx.lineTo(j.x,j.y);if(Iq(X))Q.ctx.bezierCurveTo(X.startControl.x,X.startControl.y,X.endControl.x,X.endControl.y,X.end.x,X.end.y)})},q.prototype.renderRepeat=function(Z,Q,X,J){this.path(Z),this.ctx.fillStyle=Q,this.ctx.translate(X,J),this.ctx.fill(),this.ctx.translate(-X,-J)},q.prototype.resizeImage=function(Z,Q,X){var J;if(Z.width===Q&&Z.height===X)return Z;var j=(J=this.canvas.ownerDocument)!==null&&J!==void 0?J:document,G=j.createElement("canvas");G.width=Math.max(1,Q),G.height=Math.max(1,X);var Y=G.getContext("2d");return Y.drawImage(Z,0,0,Z.width,Z.height,0,0,Q,X),G},q.prototype.renderBackgroundImage=function(Z){return D(this,void 0,void 0,function(){var Q,X,J,j,G,Y;return F(this,function(V){switch(V.label){case 0:Q=Z.styles.backgroundImage.length-1,X=function(H){var A,z,R,t,Kq,$q,s,Xq,v,W,t,Kq,$q,s,Xq,B,m,E,S,h,p,P,w,b,v,k,t,Gq,Aq,s,Xq,cq,Kq,$q,q0,Tq,aq,M0,Q0,Pq,Z0,kq;return F(this,function(I0){switch(I0.label){case 0:if(H.type!==0)return[3,5];A=void 0,z=H.url,I0.label=1;case 1:return I0.trys.push([1,3,,4]),[4,J.context.cache.match(z)];case 2:return A=I0.sent(),[3,4];case 3:return I0.sent(),J.context.logger.error("Error loading background-image "+z),[3,4];case 4:if(A)R=fQ(Z,Q,[A.width,A.height,A.width/A.height]),t=R[0],Kq=R[1],$q=R[2],s=R[3],Xq=R[4],v=J.ctx.createPattern(J.resizeImage(A,s,Xq),"repeat"),J.renderRepeat(t,v,Kq,$q);return[3,6];case 5:if(CZ(H)){if(W=fQ(Z,Q,[null,null,null]),t=W[0],Kq=W[1],$q=W[2],s=W[3],Xq=W[4],B=wZ(H.angle,s,Xq),m=B[0],E=B[1],S=B[2],h=B[3],p=B[4],P=document.createElement("canvas"),P.width=s,P.height=Xq,w=P.getContext("2d"),b=w.createLinearGradient(E,h,S,p),k1(H.stops,m).forEach(function(l0){return b.addColorStop(l0.stop,qq(l0.color))}),w.fillStyle=b,w.fillRect(0,0,s,Xq),s>0&&Xq>0)v=J.ctx.createPattern(P,"repeat"),J.renderRepeat(t,v,Kq,$q)}else if(EZ(H)){if(k=fQ(Z,Q,[null,null,null]),t=k[0],Gq=k[1],Aq=k[2],s=k[3],Xq=k[4],cq=H.position.length===0?[JQ]:H.position,Kq=d(cq[0],s),$q=d(cq[cq.length-1],Xq),q0=LZ(H,Kq,$q,s,Xq),Tq=q0[0],aq=q0[1],Tq>0&&aq>0)if(M0=J.ctx.createRadialGradient(Gq+Kq,Aq+$q,0,Gq+Kq,Aq+$q,Tq),k1(H.stops,Tq*2).forEach(function(l0){return M0.addColorStop(l0.stop,qq(l0.color))}),J.path(t),J.ctx.fillStyle=M0,Tq!==aq)Q0=Z.bounds.left+0.5*Z.bounds.width,Pq=Z.bounds.top+0.5*Z.bounds.height,Z0=aq/Tq,kq=1/Z0,J.ctx.save(),J.ctx.translate(Q0,Pq),J.ctx.transform(1,0,0,Z0,0,0),J.ctx.translate(-Q0,-Pq),J.ctx.fillRect(Gq,kq*(Aq-Pq)+Pq,s,Xq*kq),J.ctx.restore();else J.ctx.fill()}I0.label=6;case 6:return Q--,[2]}})},J=this,j=0,G=Z.styles.backgroundImage.slice(0).reverse(),V.label=1;case 1:if(!(j<G.length))return[3,4];return Y=G[j],[5,X(Y)];case 2:V.sent(),V.label=3;case 3:return j++,[3,1];case 4:return[2]}})})},q.prototype.renderSolidBorder=function(Z,Q,X){return D(this,void 0,void 0,function(){return F(this,function(J){return this.path(_6(X,Q)),this.ctx.fillStyle=qq(Z),this.ctx.fill(),[2]})})},q.prototype.renderDoubleBorder=function(Z,Q,X,J){return D(this,void 0,void 0,function(){var j,G;return F(this,function(Y){switch(Y.label){case 0:if(!(Q<3))return[3,2];return[4,this.renderSolidBorder(Z,X,J)];case 1:return Y.sent(),[2];case 2:return j=k5(J,X),this.path(j),this.ctx.fillStyle=qq(Z),this.ctx.fill(),G=f5(J,X),this.path(G),this.ctx.fill(),[2]}})})},q.prototype.renderNodeBackgroundAndBorders=function(Z){return D(this,void 0,void 0,function(){var Q,X,J,j,G,Y,V,H,A=this;return F(this,function(z){switch(z.label){case 0:if(this.applyEffects(Z.getEffects(2)),Q=Z.container.styles,X=!uq(Q.backgroundColor)||Q.backgroundImage.length,J=[{style:Q.borderTopStyle,color:Q.borderTopColor,width:Q.borderTopWidth},{style:Q.borderRightStyle,color:Q.borderRightColor,width:Q.borderRightWidth},{style:Q.borderBottomStyle,color:Q.borderBottomColor,width:Q.borderBottomWidth},{style:Q.borderLeftStyle,color:Q.borderLeftColor,width:Q.borderLeftWidth}],j=s5(F0(Q.backgroundClip,0),Z.curves),!(X||Q.boxShadow.length))return[3,2];if(this.ctx.save(),this.path(j),this.ctx.clip(),!uq(Q.backgroundColor))this.ctx.fillStyle=qq(Q.backgroundColor),this.ctx.fill();return[4,this.renderBackgroundImage(Z.container)];case 1:z.sent(),this.ctx.restore(),Q.boxShadow.slice(0).reverse().forEach(function(R){A.ctx.save();var W=EM(Z.curves),B=R.inset?0:_5,m=y5(W,-B+(R.inset?1:-1)*R.spread.number,(R.inset?1:-1)*R.spread.number,R.spread.number*(R.inset?-2:2),R.spread.number*(R.inset?-2:2));if(R.inset)A.path(W),A.ctx.clip(),A.mask(m);else A.mask(W),A.ctx.clip(),A.path(m);A.ctx.shadowOffsetX=R.offsetX.number+B,A.ctx.shadowOffsetY=R.offsetY.number,A.ctx.shadowColor=qq(R.color),A.ctx.shadowBlur=R.blur.number,A.ctx.fillStyle=R.inset?qq(R.color):"rgba(0,0,0,1)",A.ctx.fill(),A.ctx.restore()}),z.label=2;case 2:G=0,Y=0,V=J,z.label=3;case 3:if(!(Y<V.length))return[3,13];if(H=V[Y],!(H.style!==0&&!uq(H.color)&&H.width>0))return[3,11];if(H.style!==2)return[3,5];return[4,this.renderDashedDottedBorder(H.color,H.width,G,Z.curves,2)];case 4:return z.sent(),[3,11];case 5:if(H.style!==3)return[3,7];return[4,this.renderDashedDottedBorder(H.color,H.width,G,Z.curves,3)];case 6:return z.sent(),[3,11];case 7:if(H.style!==4)return[3,9];return[4,this.renderDoubleBorder(H.color,H.width,G,Z.curves)];case 8:return z.sent(),[3,11];case 9:return[4,this.renderSolidBorder(H.color,G,Z.curves)];case 10:z.sent(),z.label=11;case 11:G++,z.label=12;case 12:return Y++,[3,3];case 13:return[2]}})})},q.prototype.renderDashedDottedBorder=function(Z,Q,X,J,j){return D(this,void 0,void 0,function(){var G,Y,V,H,A,z,R,W,B,m,E,S,h,p,P,w,P,w;return F(this,function(b){if(this.ctx.save(),G=m5(J,X),Y=_6(J,X),j===2)this.path(Y),this.ctx.clip();if(Iq(Y[0]))V=Y[0].start.x,H=Y[0].start.y;else V=Y[0].x,H=Y[0].y;if(Iq(Y[1]))A=Y[1].end.x,z=Y[1].end.y;else A=Y[1].x,z=Y[1].y;if(X===0||X===2)R=Math.abs(V-A);else R=Math.abs(H-z);if(this.ctx.beginPath(),j===3)this.formatPath(G);else this.formatPath(Y.slice(0,2));if(W=Q<3?Q*3:Q*2,B=Q<3?Q*2:Q,j===3)W=Q,B=Q;if(m=!0,R<=W*2)m=!1;else if(R<=W*2+B)E=R/(2*W+B),W*=E,B*=E;else S=Math.floor((R+B)/(W+B)),h=(R-S*W)/(S-1),p=(R-(S+1)*W)/S,B=p<=0||Math.abs(B-h)<Math.abs(B-p)?h:p;if(m)if(j===3)this.ctx.setLineDash([0,W+B]);else this.ctx.setLineDash([W,B]);if(j===3)this.ctx.lineCap="round",this.ctx.lineWidth=Q;else this.ctx.lineWidth=Q*2+1.1;if(this.ctx.strokeStyle=qq(Z),this.ctx.stroke(),this.ctx.setLineDash([]),j===2){if(Iq(Y[0]))P=Y[3],w=Y[0],this.ctx.beginPath(),this.formatPath([new N(P.end.x,P.end.y),new N(w.start.x,w.start.y)]),this.ctx.stroke();if(Iq(Y[1]))P=Y[1],w=Y[2],this.ctx.beginPath(),this.formatPath([new N(P.end.x,P.end.y),new N(w.start.x,w.start.y)]),this.ctx.stroke()}return this.ctx.restore(),[2]})})},q.prototype.render=function(Z){return D(this,void 0,void 0,function(){var Q;return F(this,function(X){switch(X.label){case 0:if(this.options.backgroundColor)this.ctx.fillStyle=qq(this.options.backgroundColor),this.ctx.fillRect(this.options.x,this.options.y,this.options.width,this.options.height);return Q=P5(Z),[4,this.renderStack(Q)];case 1:return X.sent(),this.applyEffects([]),[2,this.canvas]}})})},q}(s6),l5=function(M){if(M instanceof D6)return!0;else if(M instanceof H6)return!0;else if(M instanceof NQ&&M.type!==wM&&M.type!==NM)return!0;return!1},s5=function(M,q){switch(M){case 0:return EM(q);case 2:return R5(q);case 1:default:return yM(q)}},d5=function(M){switch(M){case 1:return"center";case 2:return"right";case 0:default:return"left"}},c5=["-apple-system","system-ui"],a5=function(M){return/iPhone OS 15_(0|1)/.test(window.navigator.userAgent)?M.filter(function(q){return c5.indexOf(q)===-1}):M},r5=function(M){K(q,M);function q(Z,Q){var X=M.call(this,Z,Q)||this;return X.canvas=Q.canvas?Q.canvas:document.createElement("canvas"),X.ctx=X.canvas.getContext("2d"),X.options=Q,X.canvas.width=Math.floor(Q.width*Q.scale),X.canvas.height=Math.floor(Q.height*Q.scale),X.canvas.style.width=Q.width+"px",X.canvas.style.height=Q.height+"px",X.ctx.scale(X.options.scale,X.options.scale),X.ctx.translate(-Q.x,-Q.y),X.context.logger.debug("EXPERIMENTAL ForeignObject renderer initialized ("+Q.width+"x"+Q.height+" at "+Q.x+","+Q.y+") with scale "+Q.scale),X}return q.prototype.render=function(Z){return D(this,void 0,void 0,function(){var Q,X;return F(this,function(J){switch(J.label){case 0:return Q=OQ(this.options.width*this.options.scale,this.options.height*this.options.scale,this.options.scale,this.options.scale,Z),[4,i5(Q)];case 1:if(X=J.sent(),this.options.backgroundColor)this.ctx.fillStyle=qq(this.options.backgroundColor),this.ctx.fillRect(0,0,this.options.width*this.options.scale,this.options.height*this.options.scale);return this.ctx.drawImage(X,-this.options.x*this.options.scale,-this.options.y*this.options.scale),[2,this.canvas]}})})},q}(s6),i5=function(M){return new Promise(function(q,Z){var Q=new Image;Q.onload=function(){q(Q)},Q.onerror=Z,Q.src="data:image/svg+xml;charset=utf-8,"+encodeURIComponent(new XMLSerializer().serializeToString(M))})},n5=function(){function M(q){var{id:Z,enabled:Q}=q;this.id=Z,this.enabled=Q,this.start=Date.now()}return M.prototype.debug=function(){var q=[];for(var Z=0;Z<arguments.length;Z++)q[Z]=arguments[Z];if(this.enabled)if(typeof window<"u"&&window.console&&typeof console.debug==="function")console.debug.apply(console,I([this.id,this.getTime()+"ms"],q));else this.info.apply(this,q)},M.prototype.getTime=function(){return Date.now()-this.start},M.prototype.info=function(){var q=[];for(var Z=0;Z<arguments.length;Z++)q[Z]=arguments[Z];if(this.enabled){if(typeof window<"u"&&window.console&&typeof console.info==="function")console.info.apply(console,I([this.id,this.getTime()+"ms"],q))}},M.prototype.warn=function(){var q=[];for(var Z=0;Z<arguments.length;Z++)q[Z]=arguments[Z];if(this.enabled)if(typeof window<"u"&&window.console&&typeof console.warn==="function")console.warn.apply(console,I([this.id,this.getTime()+"ms"],q));else this.info.apply(this,q)},M.prototype.error=function(){var q=[];for(var Z=0;Z<arguments.length;Z++)q[Z]=arguments[Z];if(this.enabled)if(typeof window<"u"&&window.console&&typeof console.error==="function")console.error.apply(console,I([this.id,this.getTime()+"ms"],q));else this.info.apply(this,q)},M.instances={},M}(),o5=function(){function M(q,Z){var Q;this.windowBounds=Z,this.instanceName="#"+M.instanceCount++,this.logger=new n5({id:this.instanceName,enabled:q.logging}),this.cache=(Q=q.cache)!==null&&Q!==void 0?Q:new F5(this,q)}return M.instanceCount=1,M}(),t5=function(M,q){if(q===void 0)q={};return e5(M,q)};if(typeof window<"u")p6.setContext(window);var e5=function(M,q){return D(void 0,void 0,void 0,function(){var Z,Q,X,J,j,G,Y,V,H,A,z,R,W,B,m,E,S,h,p,P,b,w,b,v,k,t,Gq,Aq,s,Xq,cq,Kq,$q,q0,Tq,aq,M0,Q0,Pq,Z0;return F(this,function(kq){switch(kq.label){case 0:if(!M||typeof M!=="object")return[2,Promise.reject("Invalid element provided as first argument")];if(Z=M.ownerDocument,!Z)throw Error("Element is not attached to a Document");if(Q=Z.defaultView,!Q)throw Error("Document is not attached to a Window");if(X={allowTaint:(v=q.allowTaint)!==null&&v!==void 0?v:!1,imageTimeout:(k=q.imageTimeout)!==null&&k!==void 0?k:15000,proxy:q.proxy,useCORS:(t=q.useCORS)!==null&&t!==void 0?t:!1},J=$({logging:(Gq=q.logging)!==null&&Gq!==void 0?Gq:!0,cache:q.cache},X),j={windowWidth:(Aq=q.windowWidth)!==null&&Aq!==void 0?Aq:Q.innerWidth,windowHeight:(s=q.windowHeight)!==null&&s!==void 0?s:Q.innerHeight,scrollX:(Xq=q.scrollX)!==null&&Xq!==void 0?Xq:Q.pageXOffset,scrollY:(cq=q.scrollY)!==null&&cq!==void 0?cq:Q.pageYOffset},G=new O(j.scrollX,j.scrollY,j.windowWidth,j.windowHeight),Y=new o5(J,G),V=(Kq=q.foreignObjectRendering)!==null&&Kq!==void 0?Kq:!1,H={allowTaint:($q=q.allowTaint)!==null&&$q!==void 0?$q:!1,onclone:q.onclone,ignoreElements:q.ignoreElements,inlineImages:V,copyStyles:V},Y.logger.debug("Starting document clone with size "+G.width+"x"+G.height+" scrolled to "+-G.left+","+-G.top),A=new f6(Y,M,H),z=A.clonedReferenceElement,!z)return[2,Promise.reject("Unable to find element in cloned iframe")];return[4,A.toIFrame(Z,G)];case 1:if(R=kq.sent(),W=LQ(z)||q5(z)?L(z.ownerDocument):C(Y,z),B=W.width,m=W.height,E=W.left,S=W.top,h=q7(Y,z,q.backgroundColor),p={canvas:q.canvas,backgroundColor:h,scale:(Tq=(q0=q.scale)!==null&&q0!==void 0?q0:Q.devicePixelRatio)!==null&&Tq!==void 0?Tq:1,x:((aq=q.x)!==null&&aq!==void 0?aq:0)+E,y:((M0=q.y)!==null&&M0!==void 0?M0:0)+S,width:(Q0=q.width)!==null&&Q0!==void 0?Q0:Math.ceil(B),height:(Pq=q.height)!==null&&Pq!==void 0?Pq:Math.ceil(m)},!V)return[3,3];return Y.logger.debug("Document cloned, using foreign object rendering"),b=new r5(Y,p),[4,b.render(z)];case 2:return P=kq.sent(),[3,5];case 3:if(Y.logger.debug("Document cloned, element located at "+E+","+S+" with size "+B+"x"+m+" using computed rendering"),Y.logger.debug("Starting DOM parsing"),w=F6(Y,z),h===w.styles.backgroundColor)w.styles.backgroundColor=Eq.TRANSPARENT;return Y.logger.debug("Starting renderer for element at "+p.x+","+p.y+" with size "+p.width+"x"+p.height),b=new u5(Y,p),[4,b.render(w)];case 4:P=kq.sent(),kq.label=5;case 5:if((Z0=q.removeContainer)!==null&&Z0!==void 0?Z0:!0){if(!f6.destroy(R))Y.logger.error("Cannot detach cloned iframe as it is not in the DOM anymore")}return Y.logger.debug("Finished rendering"),[2,P]}})})},q7=function(M,q,Z){var Q=q.ownerDocument,X=Q.documentElement?g0(M,getComputedStyle(Q.documentElement).backgroundColor):Eq.TRANSPARENT,J=Q.body?g0(M,getComputedStyle(Q.body).backgroundColor):Eq.TRANSPARENT,j=typeof Z==="string"?g0(M,Z):Z===null?Eq.TRANSPARENT:4294967295;return q===Q.documentElement?uq(X)?uq(J)?j:J:X:j};return t5})});var f7={};G7(f7,{captureScreenshotBlob:()=>C7,captureScreenshot:()=>lQ,AXSDK:()=>X0});module.exports=j7(f7);var e6=i6(t6(),1);var gM=e6.default;var Mq=new gM;var Nq={baseURL:"https://api.axsdk.ai",basePath:"/axsdk"};class O0 extends Error{status;statusText;response;url;method;constructor(U,K,$,D,F="",I=""){super(U);this.name="ApiError",this.status=K,this.statusText=$,this.response=D,this.url=F,this.method=I}isClientError(){return this.status>=400&&this.status<500}isServerError(){return this.status>=500&&this.status<600}isNetworkError(){return this.status===0}}class pQ{baseURL;basePath;defaultHeaders;timeout;requestInterceptors;responseInterceptors;errorInterceptors;constructor(U={}){this.baseURL=U.baseURL||void 0,this.basePath=U.basePath||void 0,this.defaultHeaders={"Content-Type":"application/json",...U.defaultHeaders},this.timeout=U.timeout||30000,this.requestInterceptors=U.requestInterceptors||[],this.responseInterceptors=U.responseInterceptors||[],this.errorInterceptors=U.errorInterceptors||[]}buildUrl(U,K){let $=this.baseURL||Nq.baseURL,D=this.basePath||Nq.basePath,F=new URL(`${D[0]!=="/"?"/":""}${D}${U}`,$);if(K)Object.entries(K).forEach(([I,O])=>{F.searchParams.append(I,String(O))});return F.toString()}buildHeaders(U){return{...this.defaultHeaders,...U}}async applyRequestInterceptors(U,K){let $=K;for(let D of this.requestInterceptors)$=await D(U,$);return $}async applyResponseInterceptors(U,K){let $=K;for(let D of this.responseInterceptors)$=await D(U,$);return $}async applyErrorInterceptors(U){let K=U;for(let $ of this.errorInterceptors)K=await $(K);return K}createAbortController(U){if(U===void 0&&this.timeout===0)return;let K=new AbortController,$=U??this.timeout;return setTimeout(()=>{K.abort()},$),K}async handleResponse(U,K,$){let F=U.headers.get("content-type")?.includes("application/json"),I;if(F)I=await U.json();else if(U.status!==204)I=await U.text();let O=await this.applyResponseInterceptors(U,I);if(!U.ok)throw new O0(`HTTP error! status: ${U.status}`,U.status,U.statusText,O,K,$);return O}async request(U,K,$,D={}){let F=this.buildUrl(K,D.params),I=this.buildHeaders(D.headers),O={method:U,headers:I,signal:D.signal||this.createAbortController(D.timeout)?.signal};if($!==void 0&&$!==null)if($ instanceof FormData)delete O.headers["Content-Type"],O.body=$;else if(typeof $==="string")O.body=$;else O.body=JSON.stringify($);O=await this.applyRequestInterceptors(F,O);try{let C=await fetch(F,O);return await this.handleResponse(C,F,U)}catch(C){if(C instanceof O0){if(!C.url)C.url=F;if(!C.method)C.method=U;throw await this.applyErrorInterceptors(C)}if(C instanceof Error){if(C.name==="AbortError"){let y=new O0("Request timeout",0,"Timeout",{message:"The request timed out"},F,U);throw await this.applyErrorInterceptors(y)}let x=new O0(C.message,0,"Network Error",{message:C.message},F,U);throw await this.applyErrorInterceptors(x)}let L=new O0("An unknown error occurred",0,"Unknown Error",{error:C},F,U);throw await this.applyErrorInterceptors(L)}}async get(U,K={}){return this.request("GET",U,void 0,K)}async post(U,K,$={}){return this.request("POST",U,K,$)}async put(U,K,$={}){return this.request("PUT",U,K,$)}async patch(U,K,$={}){return this.request("PATCH",U,K,$)}async delete(U,K={}){return this.request("DELETE",U,void 0,K)}setHeader(U,K){this.defaultHeaders[U]=K}removeHeader(U){delete this.defaultHeaders[U]}setAuthToken(U,K="Bearer"){this.setHeader("Authorization",`${K} ${U}`)}clearAuthToken(){this.removeHeader("Authorization")}addRequestInterceptor(U){this.requestInterceptors.push(U)}addResponseInterceptor(U){this.responseInterceptors.push(U)}addErrorInterceptor(U){this.errorInterceptors.push(U)}}var Sq=new pQ({defaultHeaders:{"Content-Type":"application/json"}});function q8(U,K){if(Sq.addRequestInterceptor(U),K)Sq.addErrorInterceptor(K)}async function M8(){return Sq.get("")}async function Q8(){return Sq.post("/sessions")}async function Z8(){return Sq.get("/sessions/messages")}async function X8(U,K){return Sq.post("/sessions/message",{text:U,images:K})}async function J8(U){return Sq.get(`/sessions/${U}/cancel`)}async function j8(){return Sq.get("/calls/pendings")}async function U8(U,K,$){return Sq.put(`/calls/${U}`,{status:K,result:$})}async function Y8(U,K,$){return Sq.post(`/questions/${U}/${K}`,{answers:$})}var G8=(U)=>{let K,$=new Set,D=(x,y)=>{let f=typeof x==="function"?x(K):x;if(!Object.is(f,K)){let Vq=K;K=(y!=null?y:typeof f!=="object"||f===null)?f:Object.assign({},K,f),$.forEach((r)=>r(K,Vq))}},F=()=>K,C={setState:D,getState:F,getInitialState:()=>L,subscribe:(x)=>{return $.add(x),()=>$.delete(x)}},L=K=U(D,F,C);return C},bM=(U)=>U?G8(U):G8;function vM(U,K){let $;try{$=U()}catch(F){return}return{getItem:(F)=>{var I;let O=(L)=>{if(L===null)return null;return JSON.parse(L,K==null?void 0:K.reviver)},C=(I=$.getItem(F))!=null?I:null;if(C instanceof Promise)return C.then(O);return O(C)},setItem:(F,I)=>$.setItem(F,JSON.stringify(I,K==null?void 0:K.replacer)),removeItem:(F)=>$.removeItem(F)}}var bQ=(U)=>(K)=>{try{let $=U(K);if($ instanceof Promise)return $;return{then(D){return bQ(D)($)},catch(D){return this}}}catch($){return{then(D){return this},catch(D){return bQ(D)($)}}}},V7=(U,K)=>($,D,F)=>{let I={storage:vM(()=>window.localStorage),partialize:(u)=>u,version:0,merge:(u,gq)=>({...gq,...u}),...K},O=!1,C=0,L=new Set,x=new Set,y=I.storage;if(!y)return U((...u)=>{console.warn(`[zustand persist middleware] Unable to update item '${I.name}', the given storage is currently unavailable.`),$(...u)},D,F);let f=()=>{let u=I.partialize({...D()});return y.setItem(I.name,{state:u,version:I.version})},Vq=F.setState;F.setState=(u,gq)=>{return Vq(u,gq),f()};let r=U((...u)=>{return $(...u),f()},D,F);F.getInitialState=()=>r;let mq,pq=()=>{var u,gq;if(!y)return;let N0=++C;O=!1,L.forEach((i)=>{var Hq;return i((Hq=D())!=null?Hq:r)});let J0=((gq=I.onRehydrateStorage)==null?void 0:gq.call(I,(u=D())!=null?u:r))||void 0;return bQ(y.getItem.bind(y))(I.name).then((i)=>{if(i)if(typeof i.version==="number"&&i.version!==I.version){if(I.migrate){let Hq=I.migrate(i.state,i.version);if(Hq instanceof Promise)return Hq.then((iq)=>[!0,iq]);return[!0,Hq]}console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return[!1,i.state];return[!1,void 0]}).then((i)=>{var Hq;if(N0!==C)return;let[iq,hM]=i;if(mq=I.merge(hM,(Hq=D())!=null?Hq:r),$(mq,!0),iq)return f()}).then(()=>{if(N0!==C)return;J0==null||J0(D(),void 0),mq=D(),O=!0,x.forEach((i)=>i(mq))}).catch((i)=>{if(N0!==C)return;J0==null||J0(void 0,i)})};if(F.persist={setOptions:(u)=>{if(I={...I,...u},u.storage)y=u.storage},clearStorage:()=>{y==null||y.removeItem(I.name)},getOptions:()=>I,rehydrate:()=>pq(),hasHydrated:()=>O,onHydrate:(u)=>{return L.add(u),()=>{L.delete(u)}},onFinishHydration:(u)=>{return x.add(u),()=>{x.delete(u)}}},!I.skipHydration)pq();return mq||r},vQ=V7;var K8="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";var $8=(U=21)=>{let K="",$=crypto.getRandomValues(new Uint8Array(U|=0));while(U--)K+=K8[$[U]&63];return K};var H7=50,rq=bM()((U)=>({errors:[],addError:(K)=>U(($)=>{return{errors:[{id:crypto.randomUUID(),timestamp:Date.now(),...K},...$.errors].slice(0,H7)}}),removeError:(K)=>U(($)=>({errors:$.errors.filter((D)=>D.id!==K)})),clearErrors:()=>U({errors:[]})})),Wq=bM()(vQ((U,K)=>({isLoading:!1,apiKey:void 0,appId:void 0,appUserId:void 0,appAuthToken:void 0,language:"en",setApiKey:($)=>U({apiKey:$}),setAppId:($)=>U({appId:$}),getAppUserId:()=>{let $=K().appUserId||`${K().appId}-user-${$8()}`;return U({appUserId:$}),$},resetAppUserId:()=>U({appUserId:void 0}),setAppAuthToken:($)=>U({appAuthToken:$}),setLanguage:($)=>U({language:$})}),{name:"axsdk:app",storage:vM(()=>typeof window<"u"?localStorage:(()=>{return{getItem:()=>null,setItem:()=>{},removeItem:()=>{}}})()),partialize:(U)=>({apiKey:U.apiKey,appId:U.appId,appUserId:U.appUserId})})),c=bM()(vQ((U,K)=>({isLoading:!1,isOpen:!1,chatWasEverOpened:!1,session:null,setSession:($)=>U({session:$}),messages:[],setMessages:($)=>U({messages:$}),updateMessage:($)=>{let D=K().messages,F=D.findIndex((I)=>I.info.id===$.info.id);U({messages:F>=0?D.with(F,{...D[F],...$}):[...D,$].sort((I,O)=>I.info.id.localeCompare(O.info.id))})},setIsOpen:($)=>U({isOpen:$}),setChatWasEverOpened:($)=>U({chatWasEverOpened:$}),translations:{},setTranslations:($)=>U({translations:$}),questions:null,setQuestions:($)=>U({questions:$})}),{name:"axsdk:chat",storage:vM(()=>typeof window<"u"?localStorage:(()=>{return{getItem:()=>null,setItem:()=>{},removeItem:()=>{}}})()),partialize:(U)=>({session:U.session,messages:U.messages,isOpen:U.isOpen})}));var xQ=1000,V8=30000,H8=2,fq={DISCONNECTED:"DISCONNECTED",CONNECTING:"CONNECTING",CONNECTED:"CONNECTED",RECONNECTING:"RECONNECTING",ERROR:"ERROR"};class D8{config;connection=null;status=fq.DISCONNECTED;retryDelay=xQ;retryTimer;shouldReconnect=!1;messageCount=0;constructor(U={}){this.config={initialRetryDelay:U.initialRetryDelay??xQ,maxRetryDelay:U.maxRetryDelay??V8,retryBackoffMultiplier:U.retryBackoffMultiplier??H8,enableLogging:U.enableLogging??!0,appId:U.appId??"",apiKey:U.apiKey??"",appUserId:U.appUserId??"",sessionId:U.sessionId??"",headers:U.headers??{}}}start(){if(this.status===fq.CONNECTED||this.status===fq.CONNECTING){if(this.config.enableLogging)console.log("Connection already active or in progress");return}this.shouldReconnect=!0,this.connect()}async stop(){if(this.shouldReconnect=!1,this.retryTimer)clearTimeout(this.retryTimer),this.retryTimer=void 0;if(await this.closeConnection(),this.updateStatus(fq.DISCONNECTED),this.config.enableLogging)console.log("SSE connection stopped")}getStatus(){return this.status}isConnected(){return this.status===fq.CONNECTED}getMessageCount(){return this.messageCount}async buildHeaders(){let U={Accept:"text/event-stream","Cache-Control":"no-cache",...this.config.headers};if(this.config.apiKey)U["x-api-key"]=this.config.apiKey;if(this.config.appId)U["x-app-id"]=this.config.appId;if(this.config.appUserId)U["x-app-user-id"]=this.config.appUserId;if(this.config.sessionId)U["x-app-user-session-id"]=this.config.sessionId;return U}async closeConnection(){if(this.connection){try{this.connection.abortController.abort()}catch(U){console.warn(U)}if(this.connection.reader){try{await this.connection.reader.cancel()}catch(U){}this.connection.reader=null}this.connection=null}}async connect(){let U=`${Nq.baseURL}${Nq.basePath}/event`;if(this.updateStatus(fq.CONNECTING),this.config.enableLogging)console.log("Connecting...");try{let K=new AbortController,$=await this.buildHeaders(),D=await fetch(U,{method:"GET",headers:$,signal:K.signal});if(!D.ok)throw Error(`HTTP error! status: ${D.status}`);if(!D.body)throw Error("Response body is null");if(this.connection={abortController:K,reader:D.body.getReader()},this.updateStatus(fq.CONNECTED),this.config.enableLogging)console.log("SSE connection established successfully");this.resetRetryDelay(),await this.readStream()}catch(K){this.handleConnectionError(K)}}async readStream(){if(!this.connection||!this.connection.reader){console.error("No reader available");return}let U=this.connection.reader,K=new TextDecoder,$="";try{while(this.shouldReconnect){let{done:D,value:F}=await U.read();if(D){if(this.config.enableLogging)console.log("Stream ended");throw Error("Stream ended unexpectedly")}$+=K.decode(F,{stream:!0}),$=this.processBuffer($)}}catch(D){if(D instanceof Error&&D.name==="AbortError"){if(this.config.enableLogging)console.log("Stream aborted")}else throw D}}processBuffer(U){let K;while((K=U.indexOf(`
23
+ .`+EQ+D5+m6)},z5=function(M,q){var Z=M.ownerDocument;if(Z){var Q=Z.createElement("style");Q.textContent=q,M.appendChild(Q)}},p6=function(){function M(){}return M.getOrigin=function(q){var Z=M._link;if(!Z)return"about:blank";return Z.href=q,Z.href=Z.href,Z.protocol+Z.hostname+Z.port},M.isSameOrigin=function(q){return M.getOrigin(q)===M._origin},M.setContext=function(q){M._link=q.document.createElement("a"),M._origin=M.getOrigin(q.location.href)},M._origin="about:blank",M}(),F5=function(){function M(q,Z){this.context=q,this._options=Z,this._cache={}}return M.prototype.addImage=function(q){var Z=Promise.resolve();if(this.has(q))return Z;if(PQ(q)||B5(q))return(this._cache[q]=this.loadImage(q)).catch(function(){}),Z;return Z},M.prototype.match=function(q){return this._cache[q]},M.prototype.loadImage=function(q){return D(this,void 0,void 0,function(){var Z,Q,X,J,j=this;return F(this,function(G){switch(G.label){case 0:if(Z=p6.isSameOrigin(q),Q=!yQ(q)&&this._options.useCORS===!0&&Zq.SUPPORT_CORS_IMAGES&&!Z,X=!yQ(q)&&!Z&&!PQ(q)&&typeof this._options.proxy==="string"&&Zq.SUPPORT_CORS_XHR&&!Q,!Z&&this._options.allowTaint===!1&&!yQ(q)&&!PQ(q)&&!X&&!Q)return[2];if(J=q,!X)return[3,2];return[4,this.proxy(J)];case 1:J=G.sent(),G.label=2;case 2:return this.context.logger.debug("Added image "+q.substring(0,256)),[4,new Promise(function(Y,V){var H=new Image;if(H.onload=function(){return Y(H)},H.onerror=V,N5(J)||Q)H.crossOrigin="anonymous";if(H.src=J,H.complete===!0)setTimeout(function(){return Y(H)},500);if(j._options.imageTimeout>0)setTimeout(function(){return V("Timed out ("+j._options.imageTimeout+"ms) loading image")},j._options.imageTimeout)})];case 3:return[2,G.sent()]}})})},M.prototype.has=function(q){return typeof this._cache[q]<"u"},M.prototype.keys=function(){return Promise.resolve(Object.keys(this._cache))},M.prototype.proxy=function(q){var Z=this,Q=this._options.proxy;if(!Q)throw Error("No proxy defined");var X=q.substring(0,256);return new Promise(function(J,j){var G=Zq.SUPPORT_RESPONSE_TYPE?"blob":"text",Y=new XMLHttpRequest;Y.onload=function(){if(Y.status===200)if(G==="text")J(Y.response);else{var A=new FileReader;A.addEventListener("load",function(){return J(A.result)},!1),A.addEventListener("error",function(z){return j(z)},!1),A.readAsDataURL(Y.response)}else j("Failed to proxy resource "+X+" with status code "+Y.status)},Y.onerror=j;var V=Q.indexOf("?")>-1?"&":"?";if(Y.open("GET",""+Q+V+"url="+encodeURIComponent(q)+"&responseType="+G),G!=="text"&&Y instanceof XMLHttpRequest)Y.responseType=G;if(Z._options.imageTimeout){var H=Z._options.imageTimeout;Y.timeout=H,Y.ontimeout=function(){return j("Timed out ("+H+"ms) proxying "+X)}}Y.send()})},M}(),I5=/^data:image\/svg\+xml/i,O5=/^data:image\/.*;base64,/i,W5=/^data:image\/.*/i,B5=function(M){return Zq.SUPPORT_SVG_DRAWING||!w5(M)},yQ=function(M){return W5.test(M)},N5=function(M){return O5.test(M)},PQ=function(M){return M.substr(0,4)==="blob"},w5=function(M){return M.substr(-3).toLowerCase()==="svg"||I5.test(M)},N=function(){function M(q,Z){this.type=0,this.x=q,this.y=Z}return M.prototype.add=function(q,Z){return new M(this.x+q,this.y+Z)},M}(),A0=function(M,q,Z){return new N(M.x+(q.x-M.x)*Z,M.y+(q.y-M.y)*Z)},CM=function(){function M(q,Z,Q,X){this.type=1,this.start=q,this.startControl=Z,this.endControl=Q,this.end=X}return M.prototype.subdivide=function(q,Z){var Q=A0(this.start,this.startControl,q),X=A0(this.startControl,this.endControl,q),J=A0(this.endControl,this.end,q),j=A0(Q,X,q),G=A0(X,J,q),Y=A0(j,G,q);return Z?new M(this.start,Q,j,Y):new M(Y,G,J,this.end)},M.prototype.add=function(q,Z){return new M(this.start.add(q,Z),this.startControl.add(q,Z),this.endControl.add(q,Z),this.end.add(q,Z))},M.prototype.reverse=function(){return new M(this.end,this.endControl,this.startControl,this.start)},M}(),Iq=function(M){return M.type===1},L5=function(){function M(q){var{styles:Z,bounds:Q}=q,X=p0(Z.borderTopLeftRadius,Q.width,Q.height),J=X[0],j=X[1],G=p0(Z.borderTopRightRadius,Q.width,Q.height),Y=G[0],V=G[1],H=p0(Z.borderBottomRightRadius,Q.width,Q.height),A=H[0],z=H[1],R=p0(Z.borderBottomLeftRadius,Q.width,Q.height),W=R[0],B=R[1],m=[];m.push((J+Y)/Q.width),m.push((W+A)/Q.width),m.push((j+B)/Q.height),m.push((V+z)/Q.height);var E=Math.max.apply(Math,m);if(E>1)J/=E,j/=E,Y/=E,V/=E,A/=E,z/=E,W/=E,B/=E;var S=Q.width-Y,h=Q.height-z,p=Q.width-A,P=Q.height-B,w=Z.borderTopWidth,b=Z.borderRightWidth,v=Z.borderBottomWidth,k=Z.borderLeftWidth,t=d(Z.paddingTop,q.bounds.width),Gq=d(Z.paddingRight,q.bounds.width),Aq=d(Z.paddingBottom,q.bounds.width),s=d(Z.paddingLeft,q.bounds.width);this.topLeftBorderDoubleOuterBox=J>0||j>0?a(Q.left+k/3,Q.top+w/3,J-k/3,j-w/3,_.TOP_LEFT):new N(Q.left+k/3,Q.top+w/3),this.topRightBorderDoubleOuterBox=J>0||j>0?a(Q.left+S,Q.top+w/3,Y-b/3,V-w/3,_.TOP_RIGHT):new N(Q.left+Q.width-b/3,Q.top+w/3),this.bottomRightBorderDoubleOuterBox=A>0||z>0?a(Q.left+p,Q.top+h,A-b/3,z-v/3,_.BOTTOM_RIGHT):new N(Q.left+Q.width-b/3,Q.top+Q.height-v/3),this.bottomLeftBorderDoubleOuterBox=W>0||B>0?a(Q.left+k/3,Q.top+P,W-k/3,B-v/3,_.BOTTOM_LEFT):new N(Q.left+k/3,Q.top+Q.height-v/3),this.topLeftBorderDoubleInnerBox=J>0||j>0?a(Q.left+k*2/3,Q.top+w*2/3,J-k*2/3,j-w*2/3,_.TOP_LEFT):new N(Q.left+k*2/3,Q.top+w*2/3),this.topRightBorderDoubleInnerBox=J>0||j>0?a(Q.left+S,Q.top+w*2/3,Y-b*2/3,V-w*2/3,_.TOP_RIGHT):new N(Q.left+Q.width-b*2/3,Q.top+w*2/3),this.bottomRightBorderDoubleInnerBox=A>0||z>0?a(Q.left+p,Q.top+h,A-b*2/3,z-v*2/3,_.BOTTOM_RIGHT):new N(Q.left+Q.width-b*2/3,Q.top+Q.height-v*2/3),this.bottomLeftBorderDoubleInnerBox=W>0||B>0?a(Q.left+k*2/3,Q.top+P,W-k*2/3,B-v*2/3,_.BOTTOM_LEFT):new N(Q.left+k*2/3,Q.top+Q.height-v*2/3),this.topLeftBorderStroke=J>0||j>0?a(Q.left+k/2,Q.top+w/2,J-k/2,j-w/2,_.TOP_LEFT):new N(Q.left+k/2,Q.top+w/2),this.topRightBorderStroke=J>0||j>0?a(Q.left+S,Q.top+w/2,Y-b/2,V-w/2,_.TOP_RIGHT):new N(Q.left+Q.width-b/2,Q.top+w/2),this.bottomRightBorderStroke=A>0||z>0?a(Q.left+p,Q.top+h,A-b/2,z-v/2,_.BOTTOM_RIGHT):new N(Q.left+Q.width-b/2,Q.top+Q.height-v/2),this.bottomLeftBorderStroke=W>0||B>0?a(Q.left+k/2,Q.top+P,W-k/2,B-v/2,_.BOTTOM_LEFT):new N(Q.left+k/2,Q.top+Q.height-v/2),this.topLeftBorderBox=J>0||j>0?a(Q.left,Q.top,J,j,_.TOP_LEFT):new N(Q.left,Q.top),this.topRightBorderBox=Y>0||V>0?a(Q.left+S,Q.top,Y,V,_.TOP_RIGHT):new N(Q.left+Q.width,Q.top),this.bottomRightBorderBox=A>0||z>0?a(Q.left+p,Q.top+h,A,z,_.BOTTOM_RIGHT):new N(Q.left+Q.width,Q.top+Q.height),this.bottomLeftBorderBox=W>0||B>0?a(Q.left,Q.top+P,W,B,_.BOTTOM_LEFT):new N(Q.left,Q.top+Q.height),this.topLeftPaddingBox=J>0||j>0?a(Q.left+k,Q.top+w,Math.max(0,J-k),Math.max(0,j-w),_.TOP_LEFT):new N(Q.left+k,Q.top+w),this.topRightPaddingBox=Y>0||V>0?a(Q.left+Math.min(S,Q.width-b),Q.top+w,S>Q.width+b?0:Math.max(0,Y-b),Math.max(0,V-w),_.TOP_RIGHT):new N(Q.left+Q.width-b,Q.top+w),this.bottomRightPaddingBox=A>0||z>0?a(Q.left+Math.min(p,Q.width-k),Q.top+Math.min(h,Q.height-v),Math.max(0,A-b),Math.max(0,z-v),_.BOTTOM_RIGHT):new N(Q.left+Q.width-b,Q.top+Q.height-v),this.bottomLeftPaddingBox=W>0||B>0?a(Q.left+k,Q.top+Math.min(P,Q.height-v),Math.max(0,W-k),Math.max(0,B-v),_.BOTTOM_LEFT):new N(Q.left+k,Q.top+Q.height-v),this.topLeftContentBox=J>0||j>0?a(Q.left+k+s,Q.top+w+t,Math.max(0,J-(k+s)),Math.max(0,j-(w+t)),_.TOP_LEFT):new N(Q.left+k+s,Q.top+w+t),this.topRightContentBox=Y>0||V>0?a(Q.left+Math.min(S,Q.width+k+s),Q.top+w+t,S>Q.width+k+s?0:Y-k+s,V-(w+t),_.TOP_RIGHT):new N(Q.left+Q.width-(b+Gq),Q.top+w+t),this.bottomRightContentBox=A>0||z>0?a(Q.left+Math.min(p,Q.width-(k+s)),Q.top+Math.min(h,Q.height+w+t),Math.max(0,A-(b+Gq)),z-(v+Aq),_.BOTTOM_RIGHT):new N(Q.left+Q.width-(b+Gq),Q.top+Q.height-(v+Aq)),this.bottomLeftContentBox=W>0||B>0?a(Q.left+k+s,Q.top+P,Math.max(0,W-(k+s)),B-(v+Aq),_.BOTTOM_LEFT):new N(Q.left+k+s,Q.top+Q.height-(v+Aq))}return M}(),_;(function(M){M[M.TOP_LEFT=0]="TOP_LEFT",M[M.TOP_RIGHT=1]="TOP_RIGHT",M[M.BOTTOM_RIGHT=2]="BOTTOM_RIGHT",M[M.BOTTOM_LEFT=3]="BOTTOM_LEFT"})(_||(_={}));var a=function(M,q,Z,Q,X){var J=4*((Math.sqrt(2)-1)/3),j=Z*J,G=Q*J,Y=M+Z,V=q+Q;switch(X){case _.TOP_LEFT:return new CM(new N(M,V),new N(M,V-G),new N(Y-j,q),new N(Y,q));case _.TOP_RIGHT:return new CM(new N(M,q),new N(M+j,q),new N(Y,V-G),new N(Y,V));case _.BOTTOM_RIGHT:return new CM(new N(Y,q),new N(Y,q+G),new N(M+j,V),new N(M,V));case _.BOTTOM_LEFT:default:return new CM(new N(Y,V),new N(Y-j,V),new N(M,q+G),new N(M,q))}},EM=function(M){return[M.topLeftBorderBox,M.topRightBorderBox,M.bottomRightBorderBox,M.bottomLeftBorderBox]},R5=function(M){return[M.topLeftContentBox,M.topRightContentBox,M.bottomRightContentBox,M.bottomLeftContentBox]},yM=function(M){return[M.topLeftPaddingBox,M.topRightPaddingBox,M.bottomRightPaddingBox,M.bottomLeftPaddingBox]},T5=function(){function M(q,Z,Q){this.offsetX=q,this.offsetY=Z,this.matrix=Q,this.type=0,this.target=6}return M}(),PM=function(){function M(q,Z){this.path=q,this.target=Z,this.type=1}return M}(),S5=function(){function M(q){this.opacity=q,this.type=2,this.target=6}return M}(),C5=function(M){return M.type===0},g6=function(M){return M.type===1},E5=function(M){return M.type===2},b6=function(M,q){if(M.length===q.length)return M.some(function(Z,Q){return Z===q[Q]});return!1},y5=function(M,q,Z,Q,X){return M.map(function(J,j){switch(j){case 0:return J.add(q,Z);case 1:return J.add(q+Q,Z);case 2:return J.add(q+Q,Z+X);case 3:return J.add(q,Z+X)}return J})},v6=function(){function M(q){this.element=q,this.inlineLevel=[],this.nonInlineLevel=[],this.negativeZIndex=[],this.zeroOrAutoZIndexOrTransformedOrOpacity=[],this.positiveZIndex=[],this.nonPositionedFloats=[],this.nonPositionedInlineLevel=[]}return M}(),x6=function(){function M(q,Z){if(this.container=q,this.parent=Z,this.effects=[],this.curves=new L5(this.container),this.container.styles.opacity<1)this.effects.push(new S5(this.container.styles.opacity));if(this.container.styles.transform!==null){var Q=this.container.bounds.left+this.container.styles.transformOrigin[0].number,X=this.container.bounds.top+this.container.styles.transformOrigin[1].number,J=this.container.styles.transform;this.effects.push(new T5(Q,X,J))}if(this.container.styles.overflowX!==0){var j=EM(this.curves),G=yM(this.curves);if(b6(j,G))this.effects.push(new PM(j,6));else this.effects.push(new PM(j,2)),this.effects.push(new PM(G,4))}}return M.prototype.getEffects=function(q){var Z=[2,3].indexOf(this.container.styles.position)===-1,Q=this.parent,X=this.effects.slice(0);while(Q){var J=Q.effects.filter(function(Y){return!g6(Y)});if(Z||Q.container.styles.position!==0||!Q.parent){if(X.unshift.apply(X,J),Z=[2,3].indexOf(Q.container.styles.position)===-1,Q.container.styles.overflowX!==0){var j=EM(Q.curves),G=yM(Q.curves);if(!b6(j,G))X.unshift(new PM(G,6))}}else X.unshift.apply(X,J);Q=Q.parent}return X.filter(function(Y){return e(Y.target,q)})},M}(),kQ=function(M,q,Z,Q){M.container.elements.forEach(function(X){var J=e(X.flags,4),j=e(X.flags,2),G=new x6(X,M);if(e(X.styles.display,2048))Q.push(G);var Y=e(X.flags,8)?[]:Q;if(J||j){var V=J||X.styles.isPositioned()?Z:q,H=new v6(G);if(X.styles.isPositioned()||X.styles.opacity<1||X.styles.isTransformed()){var A=X.styles.zIndex.order;if(A<0){var z=0;V.negativeZIndex.some(function(W,B){if(A>W.element.container.styles.zIndex.order)return z=B,!1;else if(z>0)return!0;return!1}),V.negativeZIndex.splice(z,0,H)}else if(A>0){var R=0;V.positiveZIndex.some(function(W,B){if(A>=W.element.container.styles.zIndex.order)return R=B+1,!1;else if(R>0)return!0;return!1}),V.positiveZIndex.splice(R,0,H)}else V.zeroOrAutoZIndexOrTransformedOrOpacity.push(H)}else if(X.styles.isFloating())V.nonPositionedFloats.push(H);else V.nonPositionedInlineLevel.push(H);kQ(G,H,J?H:Z,Y)}else{if(X.styles.isInlineLevel())q.inlineLevel.push(G);else q.nonInlineLevel.push(G);kQ(G,q,Z,Y)}if(e(X.flags,8))h6(X,Y)})},h6=function(M,q){var Z=M instanceof BQ?M.start:1,Q=M instanceof BQ?M.reversed:!1;for(var X=0;X<q.length;X++){var J=q[X];if(J.container instanceof $6&&typeof J.container.value==="number"&&J.container.value!==0)Z=J.container.value;J.listValue=_0(Z,J.container.styles.listStyleType,!0),Z+=Q?-1:1}},P5=function(M){var q=new x6(M,null),Z=new v6(q),Q=[];return kQ(q,Z,Z,Q),h6(q.container,Q),Z},_6=function(M,q){switch(q){case 0:return Oq(M.topLeftBorderBox,M.topLeftPaddingBox,M.topRightBorderBox,M.topRightPaddingBox);case 1:return Oq(M.topRightBorderBox,M.topRightPaddingBox,M.bottomRightBorderBox,M.bottomRightPaddingBox);case 2:return Oq(M.bottomRightBorderBox,M.bottomRightPaddingBox,M.bottomLeftBorderBox,M.bottomLeftPaddingBox);case 3:default:return Oq(M.bottomLeftBorderBox,M.bottomLeftPaddingBox,M.topLeftBorderBox,M.topLeftPaddingBox)}},k5=function(M,q){switch(q){case 0:return Oq(M.topLeftBorderBox,M.topLeftBorderDoubleOuterBox,M.topRightBorderBox,M.topRightBorderDoubleOuterBox);case 1:return Oq(M.topRightBorderBox,M.topRightBorderDoubleOuterBox,M.bottomRightBorderBox,M.bottomRightBorderDoubleOuterBox);case 2:return Oq(M.bottomRightBorderBox,M.bottomRightBorderDoubleOuterBox,M.bottomLeftBorderBox,M.bottomLeftBorderDoubleOuterBox);case 3:default:return Oq(M.bottomLeftBorderBox,M.bottomLeftBorderDoubleOuterBox,M.topLeftBorderBox,M.topLeftBorderDoubleOuterBox)}},f5=function(M,q){switch(q){case 0:return Oq(M.topLeftBorderDoubleInnerBox,M.topLeftPaddingBox,M.topRightBorderDoubleInnerBox,M.topRightPaddingBox);case 1:return Oq(M.topRightBorderDoubleInnerBox,M.topRightPaddingBox,M.bottomRightBorderDoubleInnerBox,M.bottomRightPaddingBox);case 2:return Oq(M.bottomRightBorderDoubleInnerBox,M.bottomRightPaddingBox,M.bottomLeftBorderDoubleInnerBox,M.bottomLeftPaddingBox);case 3:default:return Oq(M.bottomLeftBorderDoubleInnerBox,M.bottomLeftPaddingBox,M.topLeftBorderDoubleInnerBox,M.topLeftPaddingBox)}},m5=function(M,q){switch(q){case 0:return kM(M.topLeftBorderStroke,M.topRightBorderStroke);case 1:return kM(M.topRightBorderStroke,M.bottomRightBorderStroke);case 2:return kM(M.bottomRightBorderStroke,M.bottomLeftBorderStroke);case 3:default:return kM(M.bottomLeftBorderStroke,M.topLeftBorderStroke)}},kM=function(M,q){var Z=[];if(Iq(M))Z.push(M.subdivide(0.5,!1));else Z.push(M);if(Iq(q))Z.push(q.subdivide(0.5,!0));else Z.push(q);return Z},Oq=function(M,q,Z,Q){var X=[];if(Iq(M))X.push(M.subdivide(0.5,!1));else X.push(M);if(Iq(Z))X.push(Z.subdivide(0.5,!0));else X.push(Z);if(Iq(Q))X.push(Q.subdivide(0.5,!0).reverse());else X.push(Q);if(Iq(q))X.push(q.subdivide(0.5,!1).reverse());else X.push(q);return X},u6=function(M){var{bounds:q,styles:Z}=M;return q.add(Z.borderLeftWidth,Z.borderTopWidth,-(Z.borderRightWidth+Z.borderLeftWidth),-(Z.borderTopWidth+Z.borderBottomWidth))},fM=function(M){var{styles:q,bounds:Z}=M,Q=d(q.paddingLeft,Z.width),X=d(q.paddingRight,Z.width),J=d(q.paddingTop,Z.width),j=d(q.paddingBottom,Z.width);return Z.add(Q+q.borderLeftWidth,J+q.borderTopWidth,-(q.borderRightWidth+q.borderLeftWidth+Q+X),-(q.borderTopWidth+q.borderBottomWidth+J+j))},p5=function(M,q){if(M===0)return q.bounds;if(M===2)return fM(q);return u6(q)},g5=function(M,q){if(M===0)return q.bounds;if(M===2)return fM(q);return u6(q)},fQ=function(M,q,Z){var Q=p5(F0(M.styles.backgroundOrigin,q),M),X=g5(F0(M.styles.backgroundClip,q),M),J=b5(F0(M.styles.backgroundSize,q),Z,Q),j=J[0],G=J[1],Y=p0(F0(M.styles.backgroundPosition,q),Q.width-j,Q.height-G),V=v5(F0(M.styles.backgroundRepeat,q),Y,J,Q,X),H=Math.round(Q.left+Y[0]),A=Math.round(Q.top+Y[1]);return[V,H,A,j,G]},z0=function(M){return l(M)&&M.value===$0.AUTO},mM=function(M){return typeof M==="number"},b5=function(M,q,Z){var Q=q[0],X=q[1],J=q[2],j=M[0],G=M[1];if(!j)return[0,0];if(o(j)&&G&&o(G))return[d(j,Z.width),d(G,Z.height)];var Y=mM(J);if(l(j)&&(j.value===$0.CONTAIN||j.value===$0.COVER)){if(mM(J)){var V=Z.width/Z.height;return V<J!==(j.value===$0.COVER)?[Z.width,Z.width/J]:[Z.height*J,Z.height]}return[Z.width,Z.height]}var H=mM(Q),A=mM(X),z=H||A;if(z0(j)&&(!G||z0(G))){if(H&&A)return[Q,X];if(!Y&&!z)return[Z.width,Z.height];if(z&&Y){var R=H?Q:X*J,W=A?X:Q/J;return[R,W]}var B=H?Q:Z.width,m=A?X:Z.height;return[B,m]}if(Y){var E=0,S=0;if(o(j))E=d(j,Z.width);else if(o(G))S=d(G,Z.height);if(z0(j))E=S*J;else if(!G||z0(G))S=E/J;return[E,S]}var h=null,p=null;if(o(j))h=d(j,Z.width);else if(G&&o(G))p=d(G,Z.height);if(h!==null&&(!G||z0(G)))p=H&&A?h/Q*X:Z.height;if(p!==null&&z0(j))h=H&&A?p/X*Q:Z.width;if(h!==null&&p!==null)return[h,p];throw Error("Unable to calculate background-size for element")},F0=function(M,q){var Z=M[q];if(typeof Z>"u")return M[0];return Z},v5=function(M,q,Z,Q,X){var J=q[0],j=q[1],G=Z[0],Y=Z[1];switch(M){case 2:return[new N(Math.round(Q.left),Math.round(Q.top+j)),new N(Math.round(Q.left+Q.width),Math.round(Q.top+j)),new N(Math.round(Q.left+Q.width),Math.round(Y+Q.top+j)),new N(Math.round(Q.left),Math.round(Y+Q.top+j))];case 3:return[new N(Math.round(Q.left+J),Math.round(Q.top)),new N(Math.round(Q.left+J+G),Math.round(Q.top)),new N(Math.round(Q.left+J+G),Math.round(Q.height+Q.top)),new N(Math.round(Q.left+J),Math.round(Q.height+Q.top))];case 1:return[new N(Math.round(Q.left+J),Math.round(Q.top+j)),new N(Math.round(Q.left+J+G),Math.round(Q.top+j)),new N(Math.round(Q.left+J+G),Math.round(Q.top+j+Y)),new N(Math.round(Q.left+J),Math.round(Q.top+j+Y))];default:return[new N(Math.round(X.left),Math.round(X.top)),new N(Math.round(X.left+X.width),Math.round(X.top)),new N(Math.round(X.left+X.width),Math.round(X.height+X.top)),new N(Math.round(X.left),Math.round(X.height+X.top))]}},x5="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7",l6="Hidden Text",h5=function(){function M(q){this._data={},this._document=q}return M.prototype.parseMetrics=function(q,Z){var Q=this._document.createElement("div"),X=this._document.createElement("img"),J=this._document.createElement("span"),j=this._document.body;Q.style.visibility="hidden",Q.style.fontFamily=q,Q.style.fontSize=Z,Q.style.margin="0",Q.style.padding="0",Q.style.whiteSpace="nowrap",j.appendChild(Q),X.src=x5,X.width=1,X.height=1,X.style.margin="0",X.style.padding="0",X.style.verticalAlign="baseline",J.style.fontFamily=q,J.style.fontSize=Z,J.style.margin="0",J.style.padding="0",J.appendChild(this._document.createTextNode(l6)),Q.appendChild(J),Q.appendChild(X);var G=X.offsetTop-J.offsetTop+2;Q.removeChild(J),Q.appendChild(this._document.createTextNode(l6)),Q.style.lineHeight="normal",X.style.verticalAlign="super";var Y=X.offsetTop-Q.offsetTop+2;return j.removeChild(Q),{baseline:G,middle:Y}},M.prototype.getMetrics=function(q,Z){var Q=q+" "+Z;if(typeof this._data[Q]>"u")this._data[Q]=this.parseMetrics(q,Z);return this._data[Q]},M}(),s6=function(){function M(q,Z){this.context=q,this.options=Z}return M}(),_5=1e4,u5=function(M){K(q,M);function q(Z,Q){var X=M.call(this,Z,Q)||this;if(X._activeEffects=[],X.canvas=Q.canvas?Q.canvas:document.createElement("canvas"),X.ctx=X.canvas.getContext("2d"),!Q.canvas)X.canvas.width=Math.floor(Q.width*Q.scale),X.canvas.height=Math.floor(Q.height*Q.scale),X.canvas.style.width=Q.width+"px",X.canvas.style.height=Q.height+"px";return X.fontMetrics=new h5(document),X.ctx.scale(X.options.scale,X.options.scale),X.ctx.translate(-Q.x,-Q.y),X.ctx.textBaseline="bottom",X._activeEffects=[],X.context.logger.debug("Canvas renderer initialized ("+Q.width+"x"+Q.height+") with scale "+Q.scale),X}return q.prototype.applyEffects=function(Z){var Q=this;while(this._activeEffects.length)this.popEffect();Z.forEach(function(X){return Q.applyEffect(X)})},q.prototype.applyEffect=function(Z){if(this.ctx.save(),E5(Z))this.ctx.globalAlpha=Z.opacity;if(C5(Z))this.ctx.translate(Z.offsetX,Z.offsetY),this.ctx.transform(Z.matrix[0],Z.matrix[1],Z.matrix[2],Z.matrix[3],Z.matrix[4],Z.matrix[5]),this.ctx.translate(-Z.offsetX,-Z.offsetY);if(g6(Z))this.path(Z.path),this.ctx.clip();this._activeEffects.push(Z)},q.prototype.popEffect=function(){this._activeEffects.pop(),this.ctx.restore()},q.prototype.renderStack=function(Z){return D(this,void 0,void 0,function(){var Q;return F(this,function(X){switch(X.label){case 0:if(Q=Z.element.container.styles,!Q.isVisible())return[3,2];return[4,this.renderStackContent(Z)];case 1:X.sent(),X.label=2;case 2:return[2]}})})},q.prototype.renderNode=function(Z){return D(this,void 0,void 0,function(){return F(this,function(Q){switch(Q.label){case 0:if(e(Z.container.flags,16))debugger;if(!Z.container.styles.isVisible())return[3,3];return[4,this.renderNodeBackgroundAndBorders(Z)];case 1:return Q.sent(),[4,this.renderNodeContent(Z)];case 2:Q.sent(),Q.label=3;case 3:return[2]}})})},q.prototype.renderTextWithLetterSpacing=function(Z,Q,X){var J=this;if(Q===0)this.ctx.fillText(Z.text,Z.bounds.left,Z.bounds.top+X);else{var j=WQ(Z.text);j.reduce(function(G,Y){return J.ctx.fillText(Y,G,Z.bounds.top+X),G+J.ctx.measureText(Y).width},Z.bounds.left)}},q.prototype.createFontStyle=function(Z){var Q=Z.fontVariant.filter(function(j){return j==="normal"||j==="small-caps"}).join(""),X=a5(Z.fontFamily).join(", "),J=m0(Z.fontSize)?""+Z.fontSize.number+Z.fontSize.unit:Z.fontSize.number+"px";return[[Z.fontStyle,Q,Z.fontWeight,J,X].join(" "),X,J]},q.prototype.renderTextNode=function(Z,Q){return D(this,void 0,void 0,function(){var X,J,j,G,Y,V,H,A,z=this;return F(this,function(R){return X=this.createFontStyle(Q),J=X[0],j=X[1],G=X[2],this.ctx.font=J,this.ctx.direction=Q.direction===1?"rtl":"ltr",this.ctx.textAlign="left",this.ctx.textBaseline="alphabetic",Y=this.fontMetrics.getMetrics(j,G),V=Y.baseline,H=Y.middle,A=Q.paintOrder,Z.textBounds.forEach(function(W){A.forEach(function(B){switch(B){case 0:z.ctx.fillStyle=qq(Q.color),z.renderTextWithLetterSpacing(W,Q.letterSpacing,V);var m=Q.textShadow;if(m.length&&W.text.trim().length)m.slice(0).reverse().forEach(function(E){z.ctx.shadowColor=qq(E.color),z.ctx.shadowOffsetX=E.offsetX.number*z.options.scale,z.ctx.shadowOffsetY=E.offsetY.number*z.options.scale,z.ctx.shadowBlur=E.blur.number,z.renderTextWithLetterSpacing(W,Q.letterSpacing,V)}),z.ctx.shadowColor="",z.ctx.shadowOffsetX=0,z.ctx.shadowOffsetY=0,z.ctx.shadowBlur=0;if(Q.textDecorationLine.length)z.ctx.fillStyle=qq(Q.textDecorationColor||Q.color),Q.textDecorationLine.forEach(function(E){switch(E){case 1:z.ctx.fillRect(W.bounds.left,Math.round(W.bounds.top+V),W.bounds.width,1);break;case 2:z.ctx.fillRect(W.bounds.left,Math.round(W.bounds.top),W.bounds.width,1);break;case 3:z.ctx.fillRect(W.bounds.left,Math.ceil(W.bounds.top+H),W.bounds.width,1);break}});break;case 1:if(Q.webkitTextStrokeWidth&&W.text.trim().length)z.ctx.strokeStyle=qq(Q.webkitTextStrokeColor),z.ctx.lineWidth=Q.webkitTextStrokeWidth,z.ctx.lineJoin=window.chrome?"miter":"round",z.ctx.strokeText(W.text,W.bounds.left,W.bounds.top+V);z.ctx.strokeStyle="",z.ctx.lineWidth=0,z.ctx.lineJoin="miter";break}})}),[2]})})},q.prototype.renderReplacedElement=function(Z,Q,X){if(X&&Z.intrinsicWidth>0&&Z.intrinsicHeight>0){var J=fM(Z),j=yM(Q);this.path(j),this.ctx.save(),this.ctx.clip(),this.ctx.drawImage(X,0,0,Z.intrinsicWidth,Z.intrinsicHeight,J.left,J.top,J.width,J.height),this.ctx.restore()}},q.prototype.renderNodeContent=function(Z){return D(this,void 0,void 0,function(){var Q,X,J,j,G,Y,S,S,V,H,A,z,p,R,W,P,B,m,E,S,h,p,P;return F(this,function(w){switch(w.label){case 0:this.applyEffects(Z.getEffects(4)),Q=Z.container,X=Z.curves,J=Q.styles,j=0,G=Q.textNodes,w.label=1;case 1:if(!(j<G.length))return[3,4];return Y=G[j],[4,this.renderTextNode(Y,J)];case 2:w.sent(),w.label=3;case 3:return j++,[3,1];case 4:if(!(Q instanceof Y6))return[3,8];w.label=5;case 5:return w.trys.push([5,7,,8]),[4,this.context.cache.match(Q.src)];case 6:return S=w.sent(),this.renderReplacedElement(Q,X,S),[3,8];case 7:return w.sent(),this.context.logger.error("Error loading image "+Q.src),[3,8];case 8:if(Q instanceof G6)this.renderReplacedElement(Q,X,Q.canvas);if(!(Q instanceof K6))return[3,12];w.label=9;case 9:return w.trys.push([9,11,,12]),[4,this.context.cache.match(Q.svg)];case 10:return S=w.sent(),this.renderReplacedElement(Q,X,S),[3,12];case 11:return w.sent(),this.context.logger.error("Error loading svg "+Q.svg.substring(0,255)),[3,12];case 12:if(!(Q instanceof A6&&Q.tree))return[3,14];return V=new q(this.context,{scale:this.options.scale,backgroundColor:Q.backgroundColor,x:0,y:0,width:Q.width,height:Q.height}),[4,V.render(Q.tree)];case 13:if(H=w.sent(),Q.width&&Q.height)this.ctx.drawImage(H,0,0,Q.width,Q.height,Q.bounds.left,Q.bounds.top,Q.bounds.width,Q.bounds.height);w.label=14;case 14:if(Q instanceof NQ){if(A=Math.min(Q.bounds.width,Q.bounds.height),Q.type===NM){if(Q.checked)this.ctx.save(),this.path([new N(Q.bounds.left+A*0.39363,Q.bounds.top+A*0.79),new N(Q.bounds.left+A*0.16,Q.bounds.top+A*0.5549),new N(Q.bounds.left+A*0.27347,Q.bounds.top+A*0.44071),new N(Q.bounds.left+A*0.39694,Q.bounds.top+A*0.5649),new N(Q.bounds.left+A*0.72983,Q.bounds.top+A*0.23),new N(Q.bounds.left+A*0.84,Q.bounds.top+A*0.34085),new N(Q.bounds.left+A*0.39363,Q.bounds.top+A*0.79)]),this.ctx.fillStyle=qq(V6),this.ctx.fill(),this.ctx.restore()}else if(Q.type===wM){if(Q.checked)this.ctx.save(),this.ctx.beginPath(),this.ctx.arc(Q.bounds.left+A/2,Q.bounds.top+A/2,A/4,0,Math.PI*2,!0),this.ctx.fillStyle=qq(V6),this.ctx.fill(),this.ctx.restore()}}if(l5(Q)&&Q.value.length){switch(z=this.createFontStyle(J),p=z[0],R=z[1],W=this.fontMetrics.getMetrics(p,R).baseline,this.ctx.font=p,this.ctx.fillStyle=qq(J.color),this.ctx.textBaseline="alphabetic",this.ctx.textAlign=d5(Q.styles.textAlign),P=fM(Q),B=0,Q.styles.textAlign){case 1:B+=P.width/2;break;case 2:B+=P.width;break}m=P.add(B,0,0,-P.height/2+1),this.ctx.save(),this.path([new N(P.left,P.top),new N(P.left+P.width,P.top),new N(P.left+P.width,P.top+P.height),new N(P.left,P.top+P.height)]),this.ctx.clip(),this.renderTextWithLetterSpacing(new x0(Q.value,m),J.letterSpacing,W),this.ctx.restore(),this.ctx.textBaseline="alphabetic",this.ctx.textAlign="left"}if(!e(Q.styles.display,2048))return[3,20];if(Q.styles.listStyleImage===null)return[3,19];if(E=Q.styles.listStyleImage,E.type!==0)return[3,18];S=void 0,h=E.url,w.label=15;case 15:return w.trys.push([15,17,,18]),[4,this.context.cache.match(h)];case 16:return S=w.sent(),this.ctx.drawImage(S,Q.bounds.left-(S.width+10),Q.bounds.top),[3,18];case 17:return w.sent(),this.context.logger.error("Error loading list-style-image "+h),[3,18];case 18:return[3,20];case 19:if(Z.listValue&&Q.styles.listStyleType!==-1)p=this.createFontStyle(J)[0],this.ctx.font=p,this.ctx.fillStyle=qq(J.color),this.ctx.textBaseline="middle",this.ctx.textAlign="right",P=new O(Q.bounds.left,Q.bounds.top+d(Q.styles.paddingTop,Q.bounds.width),Q.bounds.width,l1(J.lineHeight,J.fontSize.number)/2+1),this.renderTextWithLetterSpacing(new x0(Z.listValue,P),J.letterSpacing,l1(J.lineHeight,J.fontSize.number)/2+2),this.ctx.textBaseline="bottom",this.ctx.textAlign="left";w.label=20;case 20:return[2]}})})},q.prototype.renderStackContent=function(Z){return D(this,void 0,void 0,function(){var Q,X,E,J,j,E,G,Y,E,V,H,E,A,z,E,R,W,E,B,m,E;return F(this,function(S){switch(S.label){case 0:if(e(Z.element.container.flags,16))debugger;return[4,this.renderNodeBackgroundAndBorders(Z.element)];case 1:S.sent(),Q=0,X=Z.negativeZIndex,S.label=2;case 2:if(!(Q<X.length))return[3,5];return E=X[Q],[4,this.renderStack(E)];case 3:S.sent(),S.label=4;case 4:return Q++,[3,2];case 5:return[4,this.renderNodeContent(Z.element)];case 6:S.sent(),J=0,j=Z.nonInlineLevel,S.label=7;case 7:if(!(J<j.length))return[3,10];return E=j[J],[4,this.renderNode(E)];case 8:S.sent(),S.label=9;case 9:return J++,[3,7];case 10:G=0,Y=Z.nonPositionedFloats,S.label=11;case 11:if(!(G<Y.length))return[3,14];return E=Y[G],[4,this.renderStack(E)];case 12:S.sent(),S.label=13;case 13:return G++,[3,11];case 14:V=0,H=Z.nonPositionedInlineLevel,S.label=15;case 15:if(!(V<H.length))return[3,18];return E=H[V],[4,this.renderStack(E)];case 16:S.sent(),S.label=17;case 17:return V++,[3,15];case 18:A=0,z=Z.inlineLevel,S.label=19;case 19:if(!(A<z.length))return[3,22];return E=z[A],[4,this.renderNode(E)];case 20:S.sent(),S.label=21;case 21:return A++,[3,19];case 22:R=0,W=Z.zeroOrAutoZIndexOrTransformedOrOpacity,S.label=23;case 23:if(!(R<W.length))return[3,26];return E=W[R],[4,this.renderStack(E)];case 24:S.sent(),S.label=25;case 25:return R++,[3,23];case 26:B=0,m=Z.positiveZIndex,S.label=27;case 27:if(!(B<m.length))return[3,30];return E=m[B],[4,this.renderStack(E)];case 28:S.sent(),S.label=29;case 29:return B++,[3,27];case 30:return[2]}})})},q.prototype.mask=function(Z){this.ctx.beginPath(),this.ctx.moveTo(0,0),this.ctx.lineTo(this.canvas.width,0),this.ctx.lineTo(this.canvas.width,this.canvas.height),this.ctx.lineTo(0,this.canvas.height),this.ctx.lineTo(0,0),this.formatPath(Z.slice(0).reverse()),this.ctx.closePath()},q.prototype.path=function(Z){this.ctx.beginPath(),this.formatPath(Z),this.ctx.closePath()},q.prototype.formatPath=function(Z){var Q=this;Z.forEach(function(X,J){var j=Iq(X)?X.start:X;if(J===0)Q.ctx.moveTo(j.x,j.y);else Q.ctx.lineTo(j.x,j.y);if(Iq(X))Q.ctx.bezierCurveTo(X.startControl.x,X.startControl.y,X.endControl.x,X.endControl.y,X.end.x,X.end.y)})},q.prototype.renderRepeat=function(Z,Q,X,J){this.path(Z),this.ctx.fillStyle=Q,this.ctx.translate(X,J),this.ctx.fill(),this.ctx.translate(-X,-J)},q.prototype.resizeImage=function(Z,Q,X){var J;if(Z.width===Q&&Z.height===X)return Z;var j=(J=this.canvas.ownerDocument)!==null&&J!==void 0?J:document,G=j.createElement("canvas");G.width=Math.max(1,Q),G.height=Math.max(1,X);var Y=G.getContext("2d");return Y.drawImage(Z,0,0,Z.width,Z.height,0,0,Q,X),G},q.prototype.renderBackgroundImage=function(Z){return D(this,void 0,void 0,function(){var Q,X,J,j,G,Y;return F(this,function(V){switch(V.label){case 0:Q=Z.styles.backgroundImage.length-1,X=function(H){var A,z,R,t,Kq,$q,s,Xq,v,W,t,Kq,$q,s,Xq,B,m,E,S,h,p,P,w,b,v,k,t,Gq,Aq,s,Xq,cq,Kq,$q,q0,Tq,aq,M0,Q0,Pq,Z0,kq;return F(this,function(I0){switch(I0.label){case 0:if(H.type!==0)return[3,5];A=void 0,z=H.url,I0.label=1;case 1:return I0.trys.push([1,3,,4]),[4,J.context.cache.match(z)];case 2:return A=I0.sent(),[3,4];case 3:return I0.sent(),J.context.logger.error("Error loading background-image "+z),[3,4];case 4:if(A)R=fQ(Z,Q,[A.width,A.height,A.width/A.height]),t=R[0],Kq=R[1],$q=R[2],s=R[3],Xq=R[4],v=J.ctx.createPattern(J.resizeImage(A,s,Xq),"repeat"),J.renderRepeat(t,v,Kq,$q);return[3,6];case 5:if(CZ(H)){if(W=fQ(Z,Q,[null,null,null]),t=W[0],Kq=W[1],$q=W[2],s=W[3],Xq=W[4],B=wZ(H.angle,s,Xq),m=B[0],E=B[1],S=B[2],h=B[3],p=B[4],P=document.createElement("canvas"),P.width=s,P.height=Xq,w=P.getContext("2d"),b=w.createLinearGradient(E,h,S,p),k1(H.stops,m).forEach(function(l0){return b.addColorStop(l0.stop,qq(l0.color))}),w.fillStyle=b,w.fillRect(0,0,s,Xq),s>0&&Xq>0)v=J.ctx.createPattern(P,"repeat"),J.renderRepeat(t,v,Kq,$q)}else if(EZ(H)){if(k=fQ(Z,Q,[null,null,null]),t=k[0],Gq=k[1],Aq=k[2],s=k[3],Xq=k[4],cq=H.position.length===0?[JQ]:H.position,Kq=d(cq[0],s),$q=d(cq[cq.length-1],Xq),q0=LZ(H,Kq,$q,s,Xq),Tq=q0[0],aq=q0[1],Tq>0&&aq>0)if(M0=J.ctx.createRadialGradient(Gq+Kq,Aq+$q,0,Gq+Kq,Aq+$q,Tq),k1(H.stops,Tq*2).forEach(function(l0){return M0.addColorStop(l0.stop,qq(l0.color))}),J.path(t),J.ctx.fillStyle=M0,Tq!==aq)Q0=Z.bounds.left+0.5*Z.bounds.width,Pq=Z.bounds.top+0.5*Z.bounds.height,Z0=aq/Tq,kq=1/Z0,J.ctx.save(),J.ctx.translate(Q0,Pq),J.ctx.transform(1,0,0,Z0,0,0),J.ctx.translate(-Q0,-Pq),J.ctx.fillRect(Gq,kq*(Aq-Pq)+Pq,s,Xq*kq),J.ctx.restore();else J.ctx.fill()}I0.label=6;case 6:return Q--,[2]}})},J=this,j=0,G=Z.styles.backgroundImage.slice(0).reverse(),V.label=1;case 1:if(!(j<G.length))return[3,4];return Y=G[j],[5,X(Y)];case 2:V.sent(),V.label=3;case 3:return j++,[3,1];case 4:return[2]}})})},q.prototype.renderSolidBorder=function(Z,Q,X){return D(this,void 0,void 0,function(){return F(this,function(J){return this.path(_6(X,Q)),this.ctx.fillStyle=qq(Z),this.ctx.fill(),[2]})})},q.prototype.renderDoubleBorder=function(Z,Q,X,J){return D(this,void 0,void 0,function(){var j,G;return F(this,function(Y){switch(Y.label){case 0:if(!(Q<3))return[3,2];return[4,this.renderSolidBorder(Z,X,J)];case 1:return Y.sent(),[2];case 2:return j=k5(J,X),this.path(j),this.ctx.fillStyle=qq(Z),this.ctx.fill(),G=f5(J,X),this.path(G),this.ctx.fill(),[2]}})})},q.prototype.renderNodeBackgroundAndBorders=function(Z){return D(this,void 0,void 0,function(){var Q,X,J,j,G,Y,V,H,A=this;return F(this,function(z){switch(z.label){case 0:if(this.applyEffects(Z.getEffects(2)),Q=Z.container.styles,X=!uq(Q.backgroundColor)||Q.backgroundImage.length,J=[{style:Q.borderTopStyle,color:Q.borderTopColor,width:Q.borderTopWidth},{style:Q.borderRightStyle,color:Q.borderRightColor,width:Q.borderRightWidth},{style:Q.borderBottomStyle,color:Q.borderBottomColor,width:Q.borderBottomWidth},{style:Q.borderLeftStyle,color:Q.borderLeftColor,width:Q.borderLeftWidth}],j=s5(F0(Q.backgroundClip,0),Z.curves),!(X||Q.boxShadow.length))return[3,2];if(this.ctx.save(),this.path(j),this.ctx.clip(),!uq(Q.backgroundColor))this.ctx.fillStyle=qq(Q.backgroundColor),this.ctx.fill();return[4,this.renderBackgroundImage(Z.container)];case 1:z.sent(),this.ctx.restore(),Q.boxShadow.slice(0).reverse().forEach(function(R){A.ctx.save();var W=EM(Z.curves),B=R.inset?0:_5,m=y5(W,-B+(R.inset?1:-1)*R.spread.number,(R.inset?1:-1)*R.spread.number,R.spread.number*(R.inset?-2:2),R.spread.number*(R.inset?-2:2));if(R.inset)A.path(W),A.ctx.clip(),A.mask(m);else A.mask(W),A.ctx.clip(),A.path(m);A.ctx.shadowOffsetX=R.offsetX.number+B,A.ctx.shadowOffsetY=R.offsetY.number,A.ctx.shadowColor=qq(R.color),A.ctx.shadowBlur=R.blur.number,A.ctx.fillStyle=R.inset?qq(R.color):"rgba(0,0,0,1)",A.ctx.fill(),A.ctx.restore()}),z.label=2;case 2:G=0,Y=0,V=J,z.label=3;case 3:if(!(Y<V.length))return[3,13];if(H=V[Y],!(H.style!==0&&!uq(H.color)&&H.width>0))return[3,11];if(H.style!==2)return[3,5];return[4,this.renderDashedDottedBorder(H.color,H.width,G,Z.curves,2)];case 4:return z.sent(),[3,11];case 5:if(H.style!==3)return[3,7];return[4,this.renderDashedDottedBorder(H.color,H.width,G,Z.curves,3)];case 6:return z.sent(),[3,11];case 7:if(H.style!==4)return[3,9];return[4,this.renderDoubleBorder(H.color,H.width,G,Z.curves)];case 8:return z.sent(),[3,11];case 9:return[4,this.renderSolidBorder(H.color,G,Z.curves)];case 10:z.sent(),z.label=11;case 11:G++,z.label=12;case 12:return Y++,[3,3];case 13:return[2]}})})},q.prototype.renderDashedDottedBorder=function(Z,Q,X,J,j){return D(this,void 0,void 0,function(){var G,Y,V,H,A,z,R,W,B,m,E,S,h,p,P,w,P,w;return F(this,function(b){if(this.ctx.save(),G=m5(J,X),Y=_6(J,X),j===2)this.path(Y),this.ctx.clip();if(Iq(Y[0]))V=Y[0].start.x,H=Y[0].start.y;else V=Y[0].x,H=Y[0].y;if(Iq(Y[1]))A=Y[1].end.x,z=Y[1].end.y;else A=Y[1].x,z=Y[1].y;if(X===0||X===2)R=Math.abs(V-A);else R=Math.abs(H-z);if(this.ctx.beginPath(),j===3)this.formatPath(G);else this.formatPath(Y.slice(0,2));if(W=Q<3?Q*3:Q*2,B=Q<3?Q*2:Q,j===3)W=Q,B=Q;if(m=!0,R<=W*2)m=!1;else if(R<=W*2+B)E=R/(2*W+B),W*=E,B*=E;else S=Math.floor((R+B)/(W+B)),h=(R-S*W)/(S-1),p=(R-(S+1)*W)/S,B=p<=0||Math.abs(B-h)<Math.abs(B-p)?h:p;if(m)if(j===3)this.ctx.setLineDash([0,W+B]);else this.ctx.setLineDash([W,B]);if(j===3)this.ctx.lineCap="round",this.ctx.lineWidth=Q;else this.ctx.lineWidth=Q*2+1.1;if(this.ctx.strokeStyle=qq(Z),this.ctx.stroke(),this.ctx.setLineDash([]),j===2){if(Iq(Y[0]))P=Y[3],w=Y[0],this.ctx.beginPath(),this.formatPath([new N(P.end.x,P.end.y),new N(w.start.x,w.start.y)]),this.ctx.stroke();if(Iq(Y[1]))P=Y[1],w=Y[2],this.ctx.beginPath(),this.formatPath([new N(P.end.x,P.end.y),new N(w.start.x,w.start.y)]),this.ctx.stroke()}return this.ctx.restore(),[2]})})},q.prototype.render=function(Z){return D(this,void 0,void 0,function(){var Q;return F(this,function(X){switch(X.label){case 0:if(this.options.backgroundColor)this.ctx.fillStyle=qq(this.options.backgroundColor),this.ctx.fillRect(this.options.x,this.options.y,this.options.width,this.options.height);return Q=P5(Z),[4,this.renderStack(Q)];case 1:return X.sent(),this.applyEffects([]),[2,this.canvas]}})})},q}(s6),l5=function(M){if(M instanceof D6)return!0;else if(M instanceof H6)return!0;else if(M instanceof NQ&&M.type!==wM&&M.type!==NM)return!0;return!1},s5=function(M,q){switch(M){case 0:return EM(q);case 2:return R5(q);case 1:default:return yM(q)}},d5=function(M){switch(M){case 1:return"center";case 2:return"right";case 0:default:return"left"}},c5=["-apple-system","system-ui"],a5=function(M){return/iPhone OS 15_(0|1)/.test(window.navigator.userAgent)?M.filter(function(q){return c5.indexOf(q)===-1}):M},r5=function(M){K(q,M);function q(Z,Q){var X=M.call(this,Z,Q)||this;return X.canvas=Q.canvas?Q.canvas:document.createElement("canvas"),X.ctx=X.canvas.getContext("2d"),X.options=Q,X.canvas.width=Math.floor(Q.width*Q.scale),X.canvas.height=Math.floor(Q.height*Q.scale),X.canvas.style.width=Q.width+"px",X.canvas.style.height=Q.height+"px",X.ctx.scale(X.options.scale,X.options.scale),X.ctx.translate(-Q.x,-Q.y),X.context.logger.debug("EXPERIMENTAL ForeignObject renderer initialized ("+Q.width+"x"+Q.height+" at "+Q.x+","+Q.y+") with scale "+Q.scale),X}return q.prototype.render=function(Z){return D(this,void 0,void 0,function(){var Q,X;return F(this,function(J){switch(J.label){case 0:return Q=OQ(this.options.width*this.options.scale,this.options.height*this.options.scale,this.options.scale,this.options.scale,Z),[4,i5(Q)];case 1:if(X=J.sent(),this.options.backgroundColor)this.ctx.fillStyle=qq(this.options.backgroundColor),this.ctx.fillRect(0,0,this.options.width*this.options.scale,this.options.height*this.options.scale);return this.ctx.drawImage(X,-this.options.x*this.options.scale,-this.options.y*this.options.scale),[2,this.canvas]}})})},q}(s6),i5=function(M){return new Promise(function(q,Z){var Q=new Image;Q.onload=function(){q(Q)},Q.onerror=Z,Q.src="data:image/svg+xml;charset=utf-8,"+encodeURIComponent(new XMLSerializer().serializeToString(M))})},n5=function(){function M(q){var{id:Z,enabled:Q}=q;this.id=Z,this.enabled=Q,this.start=Date.now()}return M.prototype.debug=function(){var q=[];for(var Z=0;Z<arguments.length;Z++)q[Z]=arguments[Z];if(this.enabled)if(typeof window<"u"&&window.console&&typeof console.debug==="function")console.debug.apply(console,I([this.id,this.getTime()+"ms"],q));else this.info.apply(this,q)},M.prototype.getTime=function(){return Date.now()-this.start},M.prototype.info=function(){var q=[];for(var Z=0;Z<arguments.length;Z++)q[Z]=arguments[Z];if(this.enabled){if(typeof window<"u"&&window.console&&typeof console.info==="function")console.info.apply(console,I([this.id,this.getTime()+"ms"],q))}},M.prototype.warn=function(){var q=[];for(var Z=0;Z<arguments.length;Z++)q[Z]=arguments[Z];if(this.enabled)if(typeof window<"u"&&window.console&&typeof console.warn==="function")console.warn.apply(console,I([this.id,this.getTime()+"ms"],q));else this.info.apply(this,q)},M.prototype.error=function(){var q=[];for(var Z=0;Z<arguments.length;Z++)q[Z]=arguments[Z];if(this.enabled)if(typeof window<"u"&&window.console&&typeof console.error==="function")console.error.apply(console,I([this.id,this.getTime()+"ms"],q));else this.info.apply(this,q)},M.instances={},M}(),o5=function(){function M(q,Z){var Q;this.windowBounds=Z,this.instanceName="#"+M.instanceCount++,this.logger=new n5({id:this.instanceName,enabled:q.logging}),this.cache=(Q=q.cache)!==null&&Q!==void 0?Q:new F5(this,q)}return M.instanceCount=1,M}(),t5=function(M,q){if(q===void 0)q={};return e5(M,q)};if(typeof window<"u")p6.setContext(window);var e5=function(M,q){return D(void 0,void 0,void 0,function(){var Z,Q,X,J,j,G,Y,V,H,A,z,R,W,B,m,E,S,h,p,P,b,w,b,v,k,t,Gq,Aq,s,Xq,cq,Kq,$q,q0,Tq,aq,M0,Q0,Pq,Z0;return F(this,function(kq){switch(kq.label){case 0:if(!M||typeof M!=="object")return[2,Promise.reject("Invalid element provided as first argument")];if(Z=M.ownerDocument,!Z)throw Error("Element is not attached to a Document");if(Q=Z.defaultView,!Q)throw Error("Document is not attached to a Window");if(X={allowTaint:(v=q.allowTaint)!==null&&v!==void 0?v:!1,imageTimeout:(k=q.imageTimeout)!==null&&k!==void 0?k:15000,proxy:q.proxy,useCORS:(t=q.useCORS)!==null&&t!==void 0?t:!1},J=$({logging:(Gq=q.logging)!==null&&Gq!==void 0?Gq:!0,cache:q.cache},X),j={windowWidth:(Aq=q.windowWidth)!==null&&Aq!==void 0?Aq:Q.innerWidth,windowHeight:(s=q.windowHeight)!==null&&s!==void 0?s:Q.innerHeight,scrollX:(Xq=q.scrollX)!==null&&Xq!==void 0?Xq:Q.pageXOffset,scrollY:(cq=q.scrollY)!==null&&cq!==void 0?cq:Q.pageYOffset},G=new O(j.scrollX,j.scrollY,j.windowWidth,j.windowHeight),Y=new o5(J,G),V=(Kq=q.foreignObjectRendering)!==null&&Kq!==void 0?Kq:!1,H={allowTaint:($q=q.allowTaint)!==null&&$q!==void 0?$q:!1,onclone:q.onclone,ignoreElements:q.ignoreElements,inlineImages:V,copyStyles:V},Y.logger.debug("Starting document clone with size "+G.width+"x"+G.height+" scrolled to "+-G.left+","+-G.top),A=new f6(Y,M,H),z=A.clonedReferenceElement,!z)return[2,Promise.reject("Unable to find element in cloned iframe")];return[4,A.toIFrame(Z,G)];case 1:if(R=kq.sent(),W=LQ(z)||q5(z)?L(z.ownerDocument):C(Y,z),B=W.width,m=W.height,E=W.left,S=W.top,h=q7(Y,z,q.backgroundColor),p={canvas:q.canvas,backgroundColor:h,scale:(Tq=(q0=q.scale)!==null&&q0!==void 0?q0:Q.devicePixelRatio)!==null&&Tq!==void 0?Tq:1,x:((aq=q.x)!==null&&aq!==void 0?aq:0)+E,y:((M0=q.y)!==null&&M0!==void 0?M0:0)+S,width:(Q0=q.width)!==null&&Q0!==void 0?Q0:Math.ceil(B),height:(Pq=q.height)!==null&&Pq!==void 0?Pq:Math.ceil(m)},!V)return[3,3];return Y.logger.debug("Document cloned, using foreign object rendering"),b=new r5(Y,p),[4,b.render(z)];case 2:return P=kq.sent(),[3,5];case 3:if(Y.logger.debug("Document cloned, element located at "+E+","+S+" with size "+B+"x"+m+" using computed rendering"),Y.logger.debug("Starting DOM parsing"),w=F6(Y,z),h===w.styles.backgroundColor)w.styles.backgroundColor=Eq.TRANSPARENT;return Y.logger.debug("Starting renderer for element at "+p.x+","+p.y+" with size "+p.width+"x"+p.height),b=new u5(Y,p),[4,b.render(w)];case 4:P=kq.sent(),kq.label=5;case 5:if((Z0=q.removeContainer)!==null&&Z0!==void 0?Z0:!0){if(!f6.destroy(R))Y.logger.error("Cannot detach cloned iframe as it is not in the DOM anymore")}return Y.logger.debug("Finished rendering"),[2,P]}})})},q7=function(M,q,Z){var Q=q.ownerDocument,X=Q.documentElement?g0(M,getComputedStyle(Q.documentElement).backgroundColor):Eq.TRANSPARENT,J=Q.body?g0(M,getComputedStyle(Q.body).backgroundColor):Eq.TRANSPARENT,j=typeof Z==="string"?g0(M,Z):Z===null?Eq.TRANSPARENT:4294967295;return q===Q.documentElement?uq(X)?uq(J)?j:J:X:j};return t5})});var f7={};G7(f7,{captureScreenshotBlob:()=>C7,captureScreenshot:()=>lQ,AXSDK:()=>X0});module.exports=j7(f7);var e6=i6(t6(),1);var gM=e6.default;var Mq=new gM;var Nq={baseURL:"https://api.axsdk.ai",basePath:"/axsdk"};class O0 extends Error{status;statusText;response;url;method;constructor(U,K,$,D,F="",I=""){super(U);this.name="ApiError",this.status=K,this.statusText=$,this.response=D,this.url=F,this.method=I}isClientError(){return this.status>=400&&this.status<500}isServerError(){return this.status>=500&&this.status<600}isNetworkError(){return this.status===0}}class pQ{baseURL;basePath;defaultHeaders;timeout;requestInterceptors;responseInterceptors;errorInterceptors;constructor(U={}){this.baseURL=U.baseURL||void 0,this.basePath=U.basePath||void 0,this.defaultHeaders={"Content-Type":"application/json",...U.defaultHeaders},this.timeout=U.timeout||30000,this.requestInterceptors=U.requestInterceptors||[],this.responseInterceptors=U.responseInterceptors||[],this.errorInterceptors=U.errorInterceptors||[]}buildUrl(U,K){let $=this.baseURL||Nq.baseURL,D=this.basePath||Nq.basePath,F=new URL(`${D[0]!=="/"?"/":""}${D}${U}`,$);if(K)Object.entries(K).forEach(([I,O])=>{F.searchParams.append(I,String(O))});return F.toString()}buildHeaders(U){return{...this.defaultHeaders,...U}}async applyRequestInterceptors(U,K){let $=K;for(let D of this.requestInterceptors)$=await D(U,$);return $}async applyResponseInterceptors(U,K){let $=K;for(let D of this.responseInterceptors)$=await D(U,$);return $}async applyErrorInterceptors(U){let K=U;for(let $ of this.errorInterceptors)K=await $(K);return K}createAbortController(U){if(U===void 0&&this.timeout===0)return;let K=new AbortController,$=U??this.timeout;return setTimeout(()=>{K.abort()},$),K}async handleResponse(U,K,$){let F=U.headers.get("content-type")?.includes("application/json"),I;if(F)I=await U.json();else if(U.status!==204)I=await U.text();let O=await this.applyResponseInterceptors(U,I);if(!U.ok)throw new O0(`HTTP error! status: ${U.status}`,U.status,U.statusText,O,K,$);return O}async request(U,K,$,D={}){let F=this.buildUrl(K,D.params),I=this.buildHeaders(D.headers),O={method:U,headers:I,signal:D.signal||this.createAbortController(D.timeout)?.signal};if($!==void 0&&$!==null)if($ instanceof FormData)delete O.headers["Content-Type"],O.body=$;else if(typeof $==="string")O.body=$;else O.body=JSON.stringify($);O=await this.applyRequestInterceptors(F,O);try{let C=await fetch(F,O);return await this.handleResponse(C,F,U)}catch(C){if(C instanceof O0){if(!C.url)C.url=F;if(!C.method)C.method=U;throw await this.applyErrorInterceptors(C)}if(C instanceof Error){if(C.name==="AbortError"){let y=new O0("Request timeout",0,"Timeout",{message:"The request timed out"},F,U);throw await this.applyErrorInterceptors(y)}let x=new O0(C.message,0,"Network Error",{message:C.message},F,U);throw await this.applyErrorInterceptors(x)}let L=new O0("An unknown error occurred",0,"Unknown Error",{error:C},F,U);throw await this.applyErrorInterceptors(L)}}async get(U,K={}){return this.request("GET",U,void 0,K)}async post(U,K,$={}){return this.request("POST",U,K,$)}async put(U,K,$={}){return this.request("PUT",U,K,$)}async patch(U,K,$={}){return this.request("PATCH",U,K,$)}async delete(U,K={}){return this.request("DELETE",U,void 0,K)}setHeader(U,K){this.defaultHeaders[U]=K}removeHeader(U){delete this.defaultHeaders[U]}setAuthToken(U,K="Bearer"){this.setHeader("Authorization",`${K} ${U}`)}clearAuthToken(){this.removeHeader("Authorization")}addRequestInterceptor(U){this.requestInterceptors.push(U)}addResponseInterceptor(U){this.responseInterceptors.push(U)}addErrorInterceptor(U){this.errorInterceptors.push(U)}}var Sq=new pQ({defaultHeaders:{"Content-Type":"application/json"}});function q8(U,K){if(Sq.addRequestInterceptor(U),K)Sq.addErrorInterceptor(K)}async function M8(){return Sq.get("")}async function Q8(){return Sq.post("/sessions")}async function Z8(){return Sq.get("/sessions/messages")}async function X8(U,K){return Sq.post("/sessions/message",{text:U,images:K})}async function J8(U){return Sq.get(`/sessions/${U}/cancel`)}async function j8(){return Sq.get("/calls/pendings")}async function U8(U,K,$){return Sq.put(`/calls/${U}`,{status:K,result:$})}async function Y8(U,K,$){return Sq.post(`/questions/${U}/${K}`,{answers:$})}var G8=(U)=>{let K,$=new Set,D=(x,y)=>{let f=typeof x==="function"?x(K):x;if(!Object.is(f,K)){let Vq=K;K=(y!=null?y:typeof f!=="object"||f===null)?f:Object.assign({},K,f),$.forEach((r)=>r(K,Vq))}},F=()=>K,C={setState:D,getState:F,getInitialState:()=>L,subscribe:(x)=>{return $.add(x),()=>$.delete(x)}},L=K=U(D,F,C);return C},bM=(U)=>U?G8(U):G8;function vM(U,K){let $;try{$=U()}catch(F){return}return{getItem:(F)=>{var I;let O=(L)=>{if(L===null)return null;return JSON.parse(L,K==null?void 0:K.reviver)},C=(I=$.getItem(F))!=null?I:null;if(C instanceof Promise)return C.then(O);return O(C)},setItem:(F,I)=>$.setItem(F,JSON.stringify(I,K==null?void 0:K.replacer)),removeItem:(F)=>$.removeItem(F)}}var bQ=(U)=>(K)=>{try{let $=U(K);if($ instanceof Promise)return $;return{then(D){return bQ(D)($)},catch(D){return this}}}catch($){return{then(D){return this},catch(D){return bQ(D)($)}}}},V7=(U,K)=>($,D,F)=>{let I={storage:vM(()=>window.localStorage),partialize:(u)=>u,version:0,merge:(u,gq)=>({...gq,...u}),...K},O=!1,C=0,L=new Set,x=new Set,y=I.storage;if(!y)return U((...u)=>{console.warn(`[zustand persist middleware] Unable to update item '${I.name}', the given storage is currently unavailable.`),$(...u)},D,F);let f=()=>{let u=I.partialize({...D()});return y.setItem(I.name,{state:u,version:I.version})},Vq=F.setState;F.setState=(u,gq)=>{return Vq(u,gq),f()};let r=U((...u)=>{return $(...u),f()},D,F);F.getInitialState=()=>r;let mq,pq=()=>{var u,gq;if(!y)return;let N0=++C;O=!1,L.forEach((i)=>{var Hq;return i((Hq=D())!=null?Hq:r)});let J0=((gq=I.onRehydrateStorage)==null?void 0:gq.call(I,(u=D())!=null?u:r))||void 0;return bQ(y.getItem.bind(y))(I.name).then((i)=>{if(i)if(typeof i.version==="number"&&i.version!==I.version){if(I.migrate){let Hq=I.migrate(i.state,i.version);if(Hq instanceof Promise)return Hq.then((iq)=>[!0,iq]);return[!0,Hq]}console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return[!1,i.state];return[!1,void 0]}).then((i)=>{var Hq;if(N0!==C)return;let[iq,hM]=i;if(mq=I.merge(hM,(Hq=D())!=null?Hq:r),$(mq,!0),iq)return f()}).then(()=>{if(N0!==C)return;J0==null||J0(D(),void 0),mq=D(),O=!0,x.forEach((i)=>i(mq))}).catch((i)=>{if(N0!==C)return;J0==null||J0(void 0,i)})};if(F.persist={setOptions:(u)=>{if(I={...I,...u},u.storage)y=u.storage},clearStorage:()=>{y==null||y.removeItem(I.name)},getOptions:()=>I,rehydrate:()=>pq(),hasHydrated:()=>O,onHydrate:(u)=>{return L.add(u),()=>{L.delete(u)}},onFinishHydration:(u)=>{return x.add(u),()=>{x.delete(u)}}},!I.skipHydration)pq();return mq||r},vQ=V7;var K8="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";var $8=(U=21)=>{let K="",$=crypto.getRandomValues(new Uint8Array(U|=0));while(U--)K+=K8[$[U]&63];return K};var H7=50,rq=bM()((U)=>({errors:[],addError:(K)=>U(($)=>{return{errors:[{id:crypto.randomUUID(),timestamp:Date.now(),...K},...$.errors].slice(0,H7)}}),removeError:(K)=>U(($)=>({errors:$.errors.filter((D)=>D.id!==K)})),clearErrors:()=>U({errors:[]})})),Wq=bM()(vQ((U,K)=>({isLoading:!1,apiKey:void 0,appId:void 0,appUserId:void 0,appAuthToken:void 0,language:"en",setApiKey:($)=>U({apiKey:$}),setAppId:($)=>U({appId:$}),getAppUserId:()=>{let $=K().appUserId;if(!$||!$.startsWith(K().appId||""))$=`${K().appId}-user-${$8()}`;return U({appUserId:$}),$},resetAppUserId:()=>U({appUserId:void 0}),setAppAuthToken:($)=>U({appAuthToken:$}),setLanguage:($)=>U({language:$})}),{name:"axsdk:app",storage:vM(()=>typeof window<"u"?localStorage:(()=>{return{getItem:()=>null,setItem:()=>{},removeItem:()=>{}}})()),partialize:(U)=>({apiKey:U.apiKey,appId:U.appId,appUserId:U.appUserId})})),c=bM()(vQ((U,K)=>({isLoading:!1,isOpen:!1,chatWasEverOpened:!1,session:null,setSession:($)=>U({session:$}),messages:[],setMessages:($)=>U({messages:$}),updateMessage:($)=>{let D=K().messages,F=D.findIndex((I)=>I.info.id===$.info.id);U({messages:F>=0?D.with(F,{...D[F],...$}):[...D,$].sort((I,O)=>I.info.id.localeCompare(O.info.id))})},setIsOpen:($)=>U({isOpen:$}),setChatWasEverOpened:($)=>U({chatWasEverOpened:$}),translations:{},setTranslations:($)=>U({translations:$}),questions:null,setQuestions:($)=>U({questions:$})}),{name:"axsdk:chat",storage:vM(()=>typeof window<"u"?localStorage:(()=>{return{getItem:()=>null,setItem:()=>{},removeItem:()=>{}}})()),partialize:(U)=>({session:U.session,messages:U.messages,isOpen:U.isOpen})}));var xQ=1000,V8=30000,H8=2,fq={DISCONNECTED:"DISCONNECTED",CONNECTING:"CONNECTING",CONNECTED:"CONNECTED",RECONNECTING:"RECONNECTING",ERROR:"ERROR"};class D8{config;connection=null;status=fq.DISCONNECTED;retryDelay=xQ;retryTimer;shouldReconnect=!1;messageCount=0;constructor(U={}){this.config={initialRetryDelay:U.initialRetryDelay??xQ,maxRetryDelay:U.maxRetryDelay??V8,retryBackoffMultiplier:U.retryBackoffMultiplier??H8,enableLogging:U.enableLogging??!0,appId:U.appId??"",apiKey:U.apiKey??"",appUserId:U.appUserId??"",sessionId:U.sessionId??"",headers:U.headers??{}}}start(){if(this.status===fq.CONNECTED||this.status===fq.CONNECTING){if(this.config.enableLogging)console.log("Connection already active or in progress");return}this.shouldReconnect=!0,this.connect()}async stop(){if(this.shouldReconnect=!1,this.retryTimer)clearTimeout(this.retryTimer),this.retryTimer=void 0;if(await this.closeConnection(),this.updateStatus(fq.DISCONNECTED),this.config.enableLogging)console.log("SSE connection stopped")}getStatus(){return this.status}isConnected(){return this.status===fq.CONNECTED}getMessageCount(){return this.messageCount}async buildHeaders(){let U={Accept:"text/event-stream","Cache-Control":"no-cache",...this.config.headers};if(this.config.apiKey)U["x-api-key"]=this.config.apiKey;if(this.config.appId)U["x-app-id"]=this.config.appId;if(this.config.appUserId)U["x-app-user-id"]=this.config.appUserId;if(this.config.sessionId)U["x-app-user-session-id"]=this.config.sessionId;return U}async closeConnection(){if(this.connection){try{this.connection.abortController.abort()}catch(U){console.warn(U)}if(this.connection.reader){try{await this.connection.reader.cancel()}catch(U){}this.connection.reader=null}this.connection=null}}async connect(){let U=`${Nq.baseURL}${Nq.basePath}/event`;if(this.updateStatus(fq.CONNECTING),this.config.enableLogging)console.log("Connecting...");try{let K=new AbortController,$=await this.buildHeaders(),D=await fetch(U,{method:"GET",headers:$,signal:K.signal});if(!D.ok)throw Error(`HTTP error! status: ${D.status}`);if(!D.body)throw Error("Response body is null");if(this.connection={abortController:K,reader:D.body.getReader()},this.updateStatus(fq.CONNECTED),this.config.enableLogging)console.log("SSE connection established successfully");this.resetRetryDelay(),await this.readStream()}catch(K){this.handleConnectionError(K)}}async readStream(){if(!this.connection||!this.connection.reader){console.error("No reader available");return}let U=this.connection.reader,K=new TextDecoder,$="";try{while(this.shouldReconnect){let{done:D,value:F}=await U.read();if(D){if(this.config.enableLogging)console.log("Stream ended");throw Error("Stream ended unexpectedly")}$+=K.decode(F,{stream:!0}),$=this.processBuffer($)}}catch(D){if(D instanceof Error&&D.name==="AbortError"){if(this.config.enableLogging)console.log("Stream aborted")}else throw D}}processBuffer(U){let K;while((K=U.indexOf(`
24
24
 
25
25
  `))>=0){let $=U.slice(0,K);if(U=U.slice(K+2),$.startsWith("data: "))$=$.slice(6);this.handleMessage($)}return U}handleMessage(U){try{this.messageCount++;let K;try{K=JSON.parse(U)}catch($){if(this.config.enableLogging)console.log(`Message #${this.messageCount} received (not JSON):`,U);K={raw:U}}if(K.payload&&typeof K.payload==="object"){let $=K.payload;if($.type)Mq.emit($.type,$.properties)}Mq.emit("message",K)}catch(K){console.error("Error handling message:",K)}}async handleConnectionError(U){if(console.error("Connection error:",U),this.updateStatus(fq.ERROR),await this.closeConnection(),this.shouldReconnect)this.scheduleReconnect()}scheduleReconnect(){if(!this.shouldReconnect)return;if(this.retryTimer)clearTimeout(this.retryTimer);if(this.updateStatus(fq.RECONNECTING),this.config.enableLogging)console.log(`Scheduling reconnection in ${this.retryDelay}ms...`);this.retryTimer=setTimeout(()=>{this.retryTimer=void 0,this.closeConnection().then(()=>{this.increaseRetryDelay(),this.connect()})},this.retryDelay)}increaseRetryDelay(){this.retryDelay=Math.min(this.retryDelay*(this.config.retryBackoffMultiplier??H8),this.config.maxRetryDelay??V8)}resetRetryDelay(){this.retryDelay=this.config.initialRetryDelay??xQ}updateStatus(U){if(this.status!==U){if(this.config.enableLogging)console.log(`Status changed: ${this.status} -> ${U}`);this.status=U}}}var c0=new Map;function A8(U){let K=`${U.apiKey}:${U.appUserId}:${U.sessionId}`,$=[];for(let[F,I]of c0.entries()){if(F===K)continue;I.stop(),$.push(F)}if($.forEach((F)=>c0.delete(F)),c0.has(K))return c0.get(K);let D=new D8(U);return c0.set(K,D),D}function z8(U,K){rq.getState().removeError(U),rq.getState().addError({id:U,timestamp:Date.now(),url:`axsdk://${U}`,method:"message",status:K.data?.statusCode,statusText:K?.name??"",message:K.data?.message??"",requestBody:void 0,responseBody:K.data?.responseBody})}async function F8(U){let K=U,$=c.getState(),D=$.session;if(!D)return;let F=$.messages;for(let I of K){if(I.info?.sessionID!=D.id)continue;let C=F.find((f)=>f.info?.id==I.info.id)||I;C.info=I.info;let L=C.parts??[];for(let f of I.parts){let Vq=L.find((r)=>r.id==f.id);if(Vq){let r=f;if((r.text??"").length<(Vq.text??"").length)Vq.text=r.text}else L.push(f)}C.parts=L.sort((f,Vq)=>f.id.localeCompare(Vq.id));let x=I.info.time.completed?new Date(I.info.time.completed):new Date(I.info.time.created),y={...C,role:I.info.role,timestamp:x,parts:L,finish:I.info.finish};if($.updateMessage(y),C.info?.error)z8(C.info.id,C.info.error)}}async function I8(U){let K=c.getState(),$=K.session;if(!$)return;let D=U;if($.id!==D.sessionID)return;let F=D.status.type;if(K.setSession({...$,status:F}),!["","idle","busy"].includes(D.status.type)){let O=D.sessionID;rq.getState().removeError(O),rq.getState().addError({id:O,timestamp:Date.now(),url:`axsdk://${O}`,method:"session",status:500,statusText:D.status.type??"",message:D.status.message??"",requestBody:void 0,responseBody:D.status.message})}return F}async function O8(U){let K=c.getState(),$=K.session;if(!$)return;let D=U;if($.id!==D.info.id)return;K.setSession({...$,status:D.info.status,title:D.info.title,time:D.info.time})}async function W8(U){let K=c.getState(),$=K.session;if(!$)return;let D=U;if($.id!==D.info.sessionID)return;let F=K.messages.find((I)=>I.info.id===D.info.id)??{info:D.info};if(K.updateMessage({...F,...D}),D.info?.error)z8(D.info.id,D.info.error)}async function B8(U){let K=c.getState(),$=K.session;if(!$)return;let D=U;if($.id!==D.part.sessionID)return;let F=K.messages.find((L)=>L.info.id===D.part.messageID);if(!F)return;let I=F.parts??[],O=I.findIndex((L)=>L.id===D.part.id),C=O!==-1?I.map((L,x)=>x===O?D.part:L):[...I,D.part];K.updateMessage({...F,parts:C})}async function N8(U){let K=c.getState(),$=K.session;if(!$)return;let D=U;if($.id!==D.sessionID)return;if(D.field!=="text")return;let F=K.messages.find((y)=>y.info.id===D.messageID);if(!F)return;let I=F.parts??[],O=I.findIndex((y)=>y.id===D.partID);if(O===-1)return;let C=I[O],L={...C,text:(C.text??"")+D.delta},x=I.map((y,f)=>f===O?L:y);K.updateMessage({...F,parts:x})}var w8=void 0,W0=void 0;async function D7(){if(W0)clearInterval(W0);async function U(){try{if(!c.getState().session)return;let{messages:$}=await Z8();F8($)}catch(K){console.error("AXSDK: Error polling messages:",K)}}await U(),W0=setInterval(async()=>{await U()},30000)}function L8(){if(W0)clearInterval(W0),W0=void 0}async function A7(U){let K=c.getState().session;if(!K)return;Mq.emit("message.chat",{type:"axsdk.chat.session",data:{sessionID:K.id}}),await D7()}async function z7(U){L8()}async function F7(U){let{sessionID:K}=U,$=Wq.getState();if(!$.apiKey){console.warn("AXSDK: not initialized");return}w8=A8({apiKey:$.apiKey,appId:$.appId,appUserId:Wq.getState().getAppUserId(),sessionId:K,headers:C8.headers()}),w8?.start()}async function I7(U){let K=c.getState().session;if(!K)K=(await Q8()).session,c.getState().setSession(K),Mq.emit("message.chat",{type:"axsdk.chat.session",data:{sessionID:K.id}});let{text:$,images:D}=U;await X8($,D)}async function O7(U){let{request:K,status:$,answers:D}=U;await Y8(K.id,$,D)}async function W7(U){await I8(U)}async function B7(U){O8(U)}async function N7(U){W8(U)}async function w7(U){let K=U;if(K.part.type==="tool"&&K.part.tool?.startsWith("AX")){if(K.part.state.status==="running"){let $={id:K.part.callID,sessionID:K.part.sessionID,messageID:K.part.messageID,command:K.part.tool,args:K.part.state.input,status:void 0};Mq.emit("axsdk.call.execute",{sessionID:K.part.sessionID,call:$})}}B8(U)}async function L7(U){N8(U)}async function R7(){let U=c.getState().session;if(!U)return;await J8(U.id)}async function T7(U){c.getState().setQuestions(U)}async function R8(U){let{type:K,data:$}=U;if(K==="axsdk.chat.open")return A7($);else if(K==="axsdk.chat.close")return z7($);else if(K==="axsdk.chat.session")return F7($);else if(K==="axsdk.chat.message")return I7($);else if(K==="axsdk.chat.reply")return O7($);else if(K==="axsdk.chat.cancel")return R7();else if(K==="session.status")return W7($);else if(K==="session.updated")return B7($);else if(K==="message.updated")return N7($);else if(K==="message.part.updated")return w7($);else if(K==="message.part.delta")return L7($);else if(K==="question.asked")return T7($)}async function T8(){Mq.on("message.chat",R8);let U=c.getState().session;if(U)Mq.emit("message.chat",{type:"axsdk.chat.session",data:{sessionID:U.id}})}async function S8(){Mq.off("message.chat",R8),L8()}var uQ=i6(E8(),1);async function lQ(U){let{element:K=document.documentElement,type:$="image/png",quality:D=0.92,scale:F=typeof window<"u"?window.devicePixelRatio??1:1}=U??{};if(typeof document>"u")throw Error("[axtools] captureScreenshot: This function must be called in a browser environment.");let I;try{I=await uQ.default(K,{scale:F,useCORS:!0,allowTaint:!1,logging:!1})}catch(O){throw Error(`[axtools] captureScreenshot: html2canvas failed to capture the element. ${O instanceof Error?O.message:String(O)}`)}try{return I.toDataURL($,D)}catch(O){throw Error(`[axtools] captureScreenshot: Failed to convert canvas to data URL. ${O instanceof Error?O.message:String(O)}`)}}async function C7(U){let{element:K=document.documentElement,type:$="image/png",quality:D=0.92,scale:F=typeof window<"u"?window.devicePixelRatio??1:1}=U??{};if(typeof document>"u")throw Error("[axtools] captureScreenshotBlob: This function must be called in a browser environment.");let I;try{I=await uQ.default(K,{scale:F,useCORS:!0,allowTaint:!1,logging:!1})}catch(O){throw Error(`[axtools] captureScreenshotBlob: html2canvas failed to capture the element. ${O instanceof Error?O.message:String(O)}`)}return new Promise((O,C)=>{I.toBlob((L)=>{if(L)O(L);else C(Error("[axtools] captureScreenshotBlob: canvas.toBlob returned null — the canvas may be empty or tainted."))},$,D)})}async function y8(U,K){let $="",D={};if(U==="AX_get_env")D.now=new Date().toISOString();if(U==="AXSDK_clear")return X0.eventBus().emit("message.chat",{type:"axsdk.chat.cancel"}),X0.resetSession(),"OK";if(U==="AXSDK_screenshot")return await lQ();let F=await X0.axHandler()?.(U,K);if(!F)$="OK";else if(typeof F==="object")$=JSON.stringify({...D,...F});else $=`${JSON.stringify(D)}
26
26
  ${F}`;return $}var P8=1800000,xM=new Map;function E7(){let U=Date.now();for(let[K,$]of xM)if(U-$>P8)xM.delete(K)}async function k8(U){let{sessionID:K,call:$}=U;E7();let D=Date.now(),F=xM.get($.id);if(F!==void 0&&D-F<=P8)return;xM.set($.id,D);let I=c.getState().session,O="completed",C="";try{let L=typeof $.args==="string"?JSON.parse($.args):$.args;C=await y8($.command,L)}catch(L){console.error("axHandler: error:",L),O="failed",C=`ERROR: ${L}`}await U8($.id,O,C)}var B0=void 0;async function y7(){if(B0)clearInterval(B0);async function U(){try{let K=c.getState().session;if(!K)return;let{calls:$}=await j8();for(let D of $)Mq.emit("axsdk.call.execute",{sessionID:K.id,call:D})}catch(K){console.error("AXSDK: Error polling calls:",K)}}await U(),B0=setInterval(async()=>{await U()},30000)}function P7(){if(B0)clearInterval(B0),B0=void 0}async function f8(){await y7(),Mq.on("axsdk.call.execute",k8)}async function m8(){Mq.off("axsdk.call.execute",k8),P7()}var sQ={en:{chatInput:"Ask me anything...",chatAskMe:"Feel free to call on me.",chatHide:"Tap the button to hide this chat.",chatClearTooltip:"Reset conversation",chatClear:"Click here to start over.",chatSend:"Send",notifShowMore:"Show more",notifCollapse:"Collapse",notifYouAsked:"You asked",chatThought:"Thought","chatThinking...":"Thinking...",chatEmpty:`Just tell the AI what you need.
@@ -29,5 +29,5 @@ Feel free to ask again if needed.`,chatBusyGuide:"AI is working. Please stand by
29
29
  예)뭐 팔아?, 가장 저렴한 사과 구매해줘, 주문 내역 보여줘, 어제 산 초코렛 취소해줘`,chatIdleGuide:`AI는 실수를 할 수 있습니다.
30
30
  그럴 때는 다시 요청해보세요.`,chatBusyGuide:"AI가 일하는 중입니다. 잠시만 기다려주세요...","questionDialog.title":"조금 더 알려주세요","questionDialog.aiAssistant":"AI Assistant","questionDialog.submit":"확인","questionDialog.decline":"답변 거부","questionDialog.submitted":"답변이 제출되었습니다","questionDialog.declined":"답변을 거부했습니다","questionDialog.progressFormat":"{answered}/{total} 답변됨","questionDialog.next":"다음","questionDialog.prev":"이전","questionDialog.pageIndicator":"{current} / {total}","questionDialog.customAnswerPlaceholder":"직접 입력...",poweredBy:"Powered by AXSDK"}};class p8 extends gM{config;constructor(){super();Mq.on("message",async(U)=>{let{payload:{type:K,properties:$}}=U;if(K==="session.status"||K==="session.updated"||K==="message.updated"||K==="message.part.updated"||K==="message.part.delta"||K==="question.asked")Mq.emit("message.chat",{type:K,data:$})})}async init(U){let K=!!this.config;if(this.config=U,U.debug)console.log("AXSDK initialized");Nq.baseURL=U.baseUrl||Nq.baseURL,Nq.basePath=U.basePath||Nq.basePath,Wq.getState().setApiKey(U.apiKey),Wq.getState().setAppId(U.appId);let $=typeof navigator<"u"&&navigator.language?navigator.language.split("-")[0]:"en";Wq.getState().setLanguage(U.language??$??"en");let D=Object.fromEntries([...Object.keys(sQ),...Object.keys(U?.translations??{})].map((F)=>[F,{...sQ[F],...U?.translations?.[F]}]));if(c.getState().setTranslations(D||{}),!K)q8(this.requestInterceptor.bind(this),this.errorInterceptor.bind(this)),await T8(),await f8();await M8()}async destroy(){await m8(),await S8()}axHandler(){return this.config?.axHandler}eventBus(){return Mq}headers(){return this.config?.headers}getAppStore(){return Wq}setAppAuthToken(U){Wq.getState().setAppAuthToken(U)}getLanguage(){return Wq.getState().language??"en"}t(U){let K=Wq.getState().language;return c.getState().translations[K]?.[U]||""}getChatStore(){return c}getErrorStore(){return rq}getChatState(){return c.getState()}resetSession(){let U=this.getChatState();U.setSession(null),U.setMessages([]),this.getErrorStore().getState().clearErrors()}sendMessage(U){X0.eventBus().emit("message.chat",{type:"axsdk.chat.message",data:{text:U}})}async errorInterceptor(U){return rq.getState().addError({url:U.url||"",method:U.method||"",status:U.status,statusText:U.statusText,message:U.message,responseBody:U.response}),U}async requestInterceptor(U,K){let $=Wq.getState(),D=c.getState();return K.headers={...K.headers,...this.config?.headers,"x-api-key":this.config?.apiKey??"","x-app-id":this.config?.appId??"","x-app-user-id":$.getAppUserId()??"","x-app-user-session-id":D.session?.id??"","x-app-authorization":$.appAuthToken??""},K}}var X0=new p8,C8=X0;
31
31
 
32
- //# debugId=DC8412983F3B4CD364756E2164756E21
32
+ //# debugId=3E01E374D754374B64756E2164756E21
33
33
  //# sourceMappingURL=lib.cjs.map