@rensblitz/customer-instant-feedback-app 2.0.2 → 2.0.3

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.
@@ -48,4 +48,4 @@ React keys must be passed directly to JSX without using spread:
48
48
  content: "" !important;
49
49
  display: none !important;
50
50
  }`,ol=function(e){cl(e,"."+Tt+il+Ps+`
51
- .`+Dt+Bl+Ps)},cl=function(e,A){var r=e.ownerDocument;if(r){var t=r.createElement("style");t.textContent=A,e.appendChild(t)}},Xs=function(){function e(){}return e.getOrigin=function(A){var r=e._link;return r?(r.href=A,r.href=r.href,r.protocol+r.hostname+r.port):"about:blank"},e.isSameOrigin=function(A){return e.getOrigin(A)===e._origin},e.setContext=function(A){e._link=A.document.createElement("a"),e._origin=e.getOrigin(A.location.href)},e._origin="about:blank",e}(),ll=function(){function e(A,r){this.context=A,this._options=r,this._cache={}}return e.prototype.addImage=function(A){var r=Promise.resolve();return this.has(A)||(Rt(A)||wl(A))&&(this._cache[A]=this.loadImage(A)).catch(function(){}),r},e.prototype.match=function(A){return this._cache[A]},e.prototype.loadImage=function(A){return dA(this,void 0,void 0,function(){var r,t,n,s,a=this;return QA(this,function(B){switch(B.label){case 0:return r=Xs.isSameOrigin(A),t=!Ot(A)&&this._options.useCORS===!0&&gA.SUPPORT_CORS_IMAGES&&!r,n=!Ot(A)&&!r&&!Rt(A)&&typeof this._options.proxy=="string"&&gA.SUPPORT_CORS_XHR&&!t,!r&&this._options.allowTaint===!1&&!Ot(A)&&!Rt(A)&&!n&&!t?[2]:(s=A,n?[4,this.proxy(s)]:[3,2]);case 1:s=B.sent(),B.label=2;case 2:return this.context.logger.debug("Added image "+A.substring(0,256)),[4,new Promise(function(i,o){var c=new Image;c.onload=function(){return i(c)},c.onerror=o,(Ql(s)||t)&&(c.crossOrigin="anonymous"),c.src=s,c.complete===!0&&setTimeout(function(){return i(c)},500),a._options.imageTimeout>0&&setTimeout(function(){return o("Timed out ("+a._options.imageTimeout+"ms) loading image")},a._options.imageTimeout)})];case 3:return[2,B.sent()]}})})},e.prototype.has=function(A){return typeof this._cache[A]<"u"},e.prototype.keys=function(){return Promise.resolve(Object.keys(this._cache))},e.prototype.proxy=function(A){var r=this,t=this._options.proxy;if(!t)throw new Error("No proxy defined");var n=A.substring(0,256);return new Promise(function(s,a){var B=gA.SUPPORT_RESPONSE_TYPE?"blob":"text",i=new XMLHttpRequest;i.onload=function(){if(i.status===200)if(B==="text")s(i.response);else{var u=new FileReader;u.addEventListener("load",function(){return s(u.result)},!1),u.addEventListener("error",function(g){return a(g)},!1),u.readAsDataURL(i.response)}else a("Failed to proxy resource "+n+" with status code "+i.status)},i.onerror=a;var o=t.indexOf("?")>-1?"&":"?";if(i.open("GET",""+t+o+"url="+encodeURIComponent(A)+"&responseType="+B),B!=="text"&&i instanceof XMLHttpRequest&&(i.responseType=B),r._options.imageTimeout){var c=r._options.imageTimeout;i.timeout=c,i.ontimeout=function(){return a("Timed out ("+c+"ms) proxying "+n)}}i.send()})},e}(),ul=/^data:image\/svg\+xml/i,gl=/^data:image\/.*;base64,/i,fl=/^data:image\/.*/i,wl=function(e){return gA.SUPPORT_SVG_DRAWING||!Cl(e)},Ot=function(e){return fl.test(e)},Ql=function(e){return gl.test(e)},Rt=function(e){return e.substr(0,4)==="blob"},Cl=function(e){return e.substr(-3).toLowerCase()==="svg"||ul.test(e)},y=function(){function e(A,r){this.type=0,this.x=A,this.y=r}return e.prototype.add=function(A,r){return new e(this.x+A,this.y+r)},e}(),Qe=function(e,A,r){return new y(e.x+(A.x-e.x)*r,e.y+(A.y-e.y)*r)},Sr=function(){function e(A,r,t,n){this.type=1,this.start=A,this.startControl=r,this.endControl=t,this.end=n}return e.prototype.subdivide=function(A,r){var t=Qe(this.start,this.startControl,A),n=Qe(this.startControl,this.endControl,A),s=Qe(this.endControl,this.end,A),a=Qe(t,n,A),B=Qe(n,s,A),i=Qe(a,B,A);return r?new e(this.start,t,a,i):new e(i,B,s,this.end)},e.prototype.add=function(A,r){return new e(this.start.add(A,r),this.startControl.add(A,r),this.endControl.add(A,r),this.end.add(A,r))},e.prototype.reverse=function(){return new e(this.end,this.endControl,this.startControl,this.start)},e}(),IA=function(e){return e.type===1},dl=function(){function e(A){var r=A.styles,t=A.bounds,n=Re(r.borderTopLeftRadius,t.width,t.height),s=n[0],a=n[1],B=Re(r.borderTopRightRadius,t.width,t.height),i=B[0],o=B[1],c=Re(r.borderBottomRightRadius,t.width,t.height),u=c[0],g=c[1],w=Re(r.borderBottomLeftRadius,t.width,t.height),Q=w[0],d=w[1],S=[];S.push((s+i)/t.width),S.push((Q+u)/t.width),S.push((a+d)/t.height),S.push((o+g)/t.height);var F=Math.max.apply(Math,S);F>1&&(s/=F,a/=F,i/=F,o/=F,u/=F,g/=F,Q/=F,d/=F);var p=t.width-i,b=t.height-g,I=t.width-u,v=t.height-d,C=r.borderTopWidth,R=r.borderRightWidth,x=r.borderBottomWidth,E=r.borderLeftWidth,T=Z(r.paddingTop,A.bounds.width),_=Z(r.paddingRight,A.bounds.width),AA=Z(r.paddingBottom,A.bounds.width),D=Z(r.paddingLeft,A.bounds.width);this.topLeftBorderDoubleOuterBox=s>0||a>0?q(t.left+E/3,t.top+C/3,s-E/3,a-C/3,X.TOP_LEFT):new y(t.left+E/3,t.top+C/3),this.topRightBorderDoubleOuterBox=s>0||a>0?q(t.left+p,t.top+C/3,i-R/3,o-C/3,X.TOP_RIGHT):new y(t.left+t.width-R/3,t.top+C/3),this.bottomRightBorderDoubleOuterBox=u>0||g>0?q(t.left+I,t.top+b,u-R/3,g-x/3,X.BOTTOM_RIGHT):new y(t.left+t.width-R/3,t.top+t.height-x/3),this.bottomLeftBorderDoubleOuterBox=Q>0||d>0?q(t.left+E/3,t.top+v,Q-E/3,d-x/3,X.BOTTOM_LEFT):new y(t.left+E/3,t.top+t.height-x/3),this.topLeftBorderDoubleInnerBox=s>0||a>0?q(t.left+E*2/3,t.top+C*2/3,s-E*2/3,a-C*2/3,X.TOP_LEFT):new y(t.left+E*2/3,t.top+C*2/3),this.topRightBorderDoubleInnerBox=s>0||a>0?q(t.left+p,t.top+C*2/3,i-R*2/3,o-C*2/3,X.TOP_RIGHT):new y(t.left+t.width-R*2/3,t.top+C*2/3),this.bottomRightBorderDoubleInnerBox=u>0||g>0?q(t.left+I,t.top+b,u-R*2/3,g-x*2/3,X.BOTTOM_RIGHT):new y(t.left+t.width-R*2/3,t.top+t.height-x*2/3),this.bottomLeftBorderDoubleInnerBox=Q>0||d>0?q(t.left+E*2/3,t.top+v,Q-E*2/3,d-x*2/3,X.BOTTOM_LEFT):new y(t.left+E*2/3,t.top+t.height-x*2/3),this.topLeftBorderStroke=s>0||a>0?q(t.left+E/2,t.top+C/2,s-E/2,a-C/2,X.TOP_LEFT):new y(t.left+E/2,t.top+C/2),this.topRightBorderStroke=s>0||a>0?q(t.left+p,t.top+C/2,i-R/2,o-C/2,X.TOP_RIGHT):new y(t.left+t.width-R/2,t.top+C/2),this.bottomRightBorderStroke=u>0||g>0?q(t.left+I,t.top+b,u-R/2,g-x/2,X.BOTTOM_RIGHT):new y(t.left+t.width-R/2,t.top+t.height-x/2),this.bottomLeftBorderStroke=Q>0||d>0?q(t.left+E/2,t.top+v,Q-E/2,d-x/2,X.BOTTOM_LEFT):new y(t.left+E/2,t.top+t.height-x/2),this.topLeftBorderBox=s>0||a>0?q(t.left,t.top,s,a,X.TOP_LEFT):new y(t.left,t.top),this.topRightBorderBox=i>0||o>0?q(t.left+p,t.top,i,o,X.TOP_RIGHT):new y(t.left+t.width,t.top),this.bottomRightBorderBox=u>0||g>0?q(t.left+I,t.top+b,u,g,X.BOTTOM_RIGHT):new y(t.left+t.width,t.top+t.height),this.bottomLeftBorderBox=Q>0||d>0?q(t.left,t.top+v,Q,d,X.BOTTOM_LEFT):new y(t.left,t.top+t.height),this.topLeftPaddingBox=s>0||a>0?q(t.left+E,t.top+C,Math.max(0,s-E),Math.max(0,a-C),X.TOP_LEFT):new y(t.left+E,t.top+C),this.topRightPaddingBox=i>0||o>0?q(t.left+Math.min(p,t.width-R),t.top+C,p>t.width+R?0:Math.max(0,i-R),Math.max(0,o-C),X.TOP_RIGHT):new y(t.left+t.width-R,t.top+C),this.bottomRightPaddingBox=u>0||g>0?q(t.left+Math.min(I,t.width-E),t.top+Math.min(b,t.height-x),Math.max(0,u-R),Math.max(0,g-x),X.BOTTOM_RIGHT):new y(t.left+t.width-R,t.top+t.height-x),this.bottomLeftPaddingBox=Q>0||d>0?q(t.left+E,t.top+Math.min(v,t.height-x),Math.max(0,Q-E),Math.max(0,d-x),X.BOTTOM_LEFT):new y(t.left+E,t.top+t.height-x),this.topLeftContentBox=s>0||a>0?q(t.left+E+D,t.top+C+T,Math.max(0,s-(E+D)),Math.max(0,a-(C+T)),X.TOP_LEFT):new y(t.left+E+D,t.top+C+T),this.topRightContentBox=i>0||o>0?q(t.left+Math.min(p,t.width+E+D),t.top+C+T,p>t.width+E+D?0:i-E+D,o-(C+T),X.TOP_RIGHT):new y(t.left+t.width-(R+_),t.top+C+T),this.bottomRightContentBox=u>0||g>0?q(t.left+Math.min(I,t.width-(E+D)),t.top+Math.min(b,t.height+C+T),Math.max(0,u-(R+_)),g-(x+AA),X.BOTTOM_RIGHT):new y(t.left+t.width-(R+_),t.top+t.height-(x+AA)),this.bottomLeftContentBox=Q>0||d>0?q(t.left+E+D,t.top+v,Math.max(0,Q-(E+D)),d-(x+AA),X.BOTTOM_LEFT):new y(t.left+E+D,t.top+t.height-(x+AA))}return e}(),X;(function(e){e[e.TOP_LEFT=0]="TOP_LEFT",e[e.TOP_RIGHT=1]="TOP_RIGHT",e[e.BOTTOM_RIGHT=2]="BOTTOM_RIGHT",e[e.BOTTOM_LEFT=3]="BOTTOM_LEFT"})(X||(X={}));var q=function(e,A,r,t,n){var s=4*((Math.sqrt(2)-1)/3),a=r*s,B=t*s,i=e+r,o=A+t;switch(n){case X.TOP_LEFT:return new Sr(new y(e,o),new y(e,o-B),new y(i-a,A),new y(i,A));case X.TOP_RIGHT:return new Sr(new y(e,A),new y(e+a,A),new y(i,o-B),new y(i,o));case X.BOTTOM_RIGHT:return new Sr(new y(i,A),new y(i,A+B),new y(e+a,o),new y(e,o));case X.BOTTOM_LEFT:default:return new Sr(new y(i,o),new y(i-a,o),new y(e,A+B),new y(e,A))}},Tr=function(e){return[e.topLeftBorderBox,e.topRightBorderBox,e.bottomRightBorderBox,e.bottomLeftBorderBox]},Ul=function(e){return[e.topLeftContentBox,e.topRightContentBox,e.bottomRightContentBox,e.bottomLeftContentBox]},Dr=function(e){return[e.topLeftPaddingBox,e.topRightPaddingBox,e.bottomRightPaddingBox,e.bottomLeftPaddingBox]},hl=function(){function e(A,r,t){this.offsetX=A,this.offsetY=r,this.matrix=t,this.type=0,this.target=6}return e}(),Or=function(){function e(A,r){this.path=A,this.target=r,this.type=1}return e}(),Fl=function(){function e(A){this.opacity=A,this.type=2,this.target=6}return e}(),pl=function(e){return e.type===0},Js=function(e){return e.type===1},El=function(e){return e.type===2},Ys=function(e,A){return e.length===A.length?e.some(function(r,t){return r===A[t]}):!1},vl=function(e,A,r,t,n){return e.map(function(s,a){switch(a){case 0:return s.add(A,r);case 1:return s.add(A+t,r);case 2:return s.add(A+t,r+n);case 3:return s.add(A,r+n)}return s})},Ws=function(){function e(A){this.element=A,this.inlineLevel=[],this.nonInlineLevel=[],this.negativeZIndex=[],this.zeroOrAutoZIndexOrTransformedOrOpacity=[],this.positiveZIndex=[],this.nonPositionedFloats=[],this.nonPositionedInlineLevel=[]}return e}(),js=function(){function e(A,r){if(this.container=A,this.parent=r,this.effects=[],this.curves=new dl(this.container),this.container.styles.opacity<1&&this.effects.push(new Fl(this.container.styles.opacity)),this.container.styles.transform!==null){var t=this.container.bounds.left+this.container.styles.transformOrigin[0].number,n=this.container.bounds.top+this.container.styles.transformOrigin[1].number,s=this.container.styles.transform;this.effects.push(new hl(t,n,s))}if(this.container.styles.overflowX!==0){var a=Tr(this.curves),B=Dr(this.curves);Ys(a,B)?this.effects.push(new Or(a,6)):(this.effects.push(new Or(a,2)),this.effects.push(new Or(B,4)))}}return e.prototype.getEffects=function(A){for(var r=[2,3].indexOf(this.container.styles.position)===-1,t=this.parent,n=this.effects.slice(0);t;){var s=t.effects.filter(function(i){return!Js(i)});if(r||t.container.styles.position!==0||!t.parent){if(n.unshift.apply(n,s),r=[2,3].indexOf(t.container.styles.position)===-1,t.container.styles.overflowX!==0){var a=Tr(t.curves),B=Dr(t.curves);Ys(a,B)||n.unshift(new Or(B,6))}}else n.unshift.apply(n,s);t=t.parent}return n.filter(function(i){return BA(i.target,A)})},e}(),Mt=function(e,A,r,t){e.container.elements.forEach(function(n){var s=BA(n.flags,4),a=BA(n.flags,2),B=new js(n,e);BA(n.styles.display,2048)&&t.push(B);var i=BA(n.flags,8)?[]:t;if(s||a){var o=s||n.styles.isPositioned()?r:A,c=new Ws(B);if(n.styles.isPositioned()||n.styles.opacity<1||n.styles.isTransformed()){var u=n.styles.zIndex.order;if(u<0){var g=0;o.negativeZIndex.some(function(Q,d){return u>Q.element.container.styles.zIndex.order?(g=d,!1):g>0}),o.negativeZIndex.splice(g,0,c)}else if(u>0){var w=0;o.positiveZIndex.some(function(Q,d){return u>=Q.element.container.styles.zIndex.order?(w=d+1,!1):w>0}),o.positiveZIndex.splice(w,0,c)}else o.zeroOrAutoZIndexOrTransformedOrOpacity.push(c)}else n.styles.isFloating()?o.nonPositionedFloats.push(c):o.nonPositionedInlineLevel.push(c);Mt(B,c,s?c:r,i)}else n.styles.isInlineLevel()?A.inlineLevel.push(B):A.nonInlineLevel.push(B),Mt(B,A,r,i);BA(n.flags,8)&&Zs(n,i)})},Zs=function(e,A){for(var r=e instanceof mt?e.start:1,t=e instanceof mt?e.reversed:!1,n=0;n<A.length;n++){var s=A[n];s.container instanceof Fs&&typeof s.container.value=="number"&&s.container.value!==0&&(r=s.container.value),s.listValue=_e(r,s.container.styles.listStyleType,!0),r+=t?-1:1}},Hl=function(e){var A=new js(e,null),r=new Ws(A),t=[];return Mt(A,r,r,t),Zs(A.container,t),r},zs=function(e,A){switch(A){case 0:return mA(e.topLeftBorderBox,e.topLeftPaddingBox,e.topRightBorderBox,e.topRightPaddingBox);case 1:return mA(e.topRightBorderBox,e.topRightPaddingBox,e.bottomRightBorderBox,e.bottomRightPaddingBox);case 2:return mA(e.bottomRightBorderBox,e.bottomRightPaddingBox,e.bottomLeftBorderBox,e.bottomLeftPaddingBox);case 3:default:return mA(e.bottomLeftBorderBox,e.bottomLeftPaddingBox,e.topLeftBorderBox,e.topLeftPaddingBox)}},Il=function(e,A){switch(A){case 0:return mA(e.topLeftBorderBox,e.topLeftBorderDoubleOuterBox,e.topRightBorderBox,e.topRightBorderDoubleOuterBox);case 1:return mA(e.topRightBorderBox,e.topRightBorderDoubleOuterBox,e.bottomRightBorderBox,e.bottomRightBorderDoubleOuterBox);case 2:return mA(e.bottomRightBorderBox,e.bottomRightBorderDoubleOuterBox,e.bottomLeftBorderBox,e.bottomLeftBorderDoubleOuterBox);case 3:default:return mA(e.bottomLeftBorderBox,e.bottomLeftBorderDoubleOuterBox,e.topLeftBorderBox,e.topLeftBorderDoubleOuterBox)}},ml=function(e,A){switch(A){case 0:return mA(e.topLeftBorderDoubleInnerBox,e.topLeftPaddingBox,e.topRightBorderDoubleInnerBox,e.topRightPaddingBox);case 1:return mA(e.topRightBorderDoubleInnerBox,e.topRightPaddingBox,e.bottomRightBorderDoubleInnerBox,e.bottomRightPaddingBox);case 2:return mA(e.bottomRightBorderDoubleInnerBox,e.bottomRightPaddingBox,e.bottomLeftBorderDoubleInnerBox,e.bottomLeftPaddingBox);case 3:default:return mA(e.bottomLeftBorderDoubleInnerBox,e.bottomLeftPaddingBox,e.topLeftBorderDoubleInnerBox,e.topLeftPaddingBox)}},yl=function(e,A){switch(A){case 0:return Rr(e.topLeftBorderStroke,e.topRightBorderStroke);case 1:return Rr(e.topRightBorderStroke,e.bottomRightBorderStroke);case 2:return Rr(e.bottomRightBorderStroke,e.bottomLeftBorderStroke);case 3:default:return Rr(e.bottomLeftBorderStroke,e.topLeftBorderStroke)}},Rr=function(e,A){var r=[];return IA(e)?r.push(e.subdivide(.5,!1)):r.push(e),IA(A)?r.push(A.subdivide(.5,!0)):r.push(A),r},mA=function(e,A,r,t){var n=[];return IA(e)?n.push(e.subdivide(.5,!1)):n.push(e),IA(r)?n.push(r.subdivide(.5,!0)):n.push(r),IA(t)?n.push(t.subdivide(.5,!0).reverse()):n.push(t),IA(A)?n.push(A.subdivide(.5,!1).reverse()):n.push(A),n},qs=function(e){var A=e.bounds,r=e.styles;return A.add(r.borderLeftWidth,r.borderTopWidth,-(r.borderRightWidth+r.borderLeftWidth),-(r.borderTopWidth+r.borderBottomWidth))},Mr=function(e){var A=e.styles,r=e.bounds,t=Z(A.paddingLeft,r.width),n=Z(A.paddingRight,r.width),s=Z(A.paddingTop,r.width),a=Z(A.paddingBottom,r.width);return r.add(t+A.borderLeftWidth,s+A.borderTopWidth,-(A.borderRightWidth+A.borderLeftWidth+t+n),-(A.borderTopWidth+A.borderBottomWidth+s+a))},bl=function(e,A){return e===0?A.bounds:e===2?Mr(A):qs(A)},Kl=function(e,A){return e===0?A.bounds:e===2?Mr(A):qs(A)},Nt=function(e,A,r){var t=bl(de(e.styles.backgroundOrigin,A),e),n=Kl(de(e.styles.backgroundClip,A),e),s=Ll(de(e.styles.backgroundSize,A),r,t),a=s[0],B=s[1],i=Re(de(e.styles.backgroundPosition,A),t.width-a,t.height-B),o=xl(de(e.styles.backgroundRepeat,A),i,s,t,n),c=Math.round(t.left+i[0]),u=Math.round(t.top+i[1]);return[o,c,u,a,B]},Ce=function(e){return W(e)&&e.value===ue.AUTO},Nr=function(e){return typeof e=="number"},Ll=function(e,A,r){var t=A[0],n=A[1],s=A[2],a=e[0],B=e[1];if(!a)return[0,0];if(aA(a)&&B&&aA(B))return[Z(a,r.width),Z(B,r.height)];var i=Nr(s);if(W(a)&&(a.value===ue.CONTAIN||a.value===ue.COVER)){if(Nr(s)){var o=r.width/r.height;return o<s!=(a.value===ue.COVER)?[r.width,r.width/s]:[r.height*s,r.height]}return[r.width,r.height]}var c=Nr(t),u=Nr(n),g=c||u;if(Ce(a)&&(!B||Ce(B))){if(c&&u)return[t,n];if(!i&&!g)return[r.width,r.height];if(g&&i){var w=c?t:n*s,Q=u?n:t/s;return[w,Q]}var d=c?t:r.width,S=u?n:r.height;return[d,S]}if(i){var F=0,p=0;return aA(a)?F=Z(a,r.width):aA(B)&&(p=Z(B,r.height)),Ce(a)?F=p*s:(!B||Ce(B))&&(p=F/s),[F,p]}var b=null,I=null;if(aA(a)?b=Z(a,r.width):B&&aA(B)&&(I=Z(B,r.height)),b!==null&&(!B||Ce(B))&&(I=c&&u?b/t*n:r.height),I!==null&&Ce(a)&&(b=c&&u?I/n*t:r.width),b!==null&&I!==null)return[b,I];throw new Error("Unable to calculate background-size for element")},de=function(e,A){var r=e[A];return typeof r>"u"?e[0]:r},xl=function(e,A,r,t,n){var s=A[0],a=A[1],B=r[0],i=r[1];switch(e){case 2:return[new y(Math.round(t.left),Math.round(t.top+a)),new y(Math.round(t.left+t.width),Math.round(t.top+a)),new y(Math.round(t.left+t.width),Math.round(i+t.top+a)),new y(Math.round(t.left),Math.round(i+t.top+a))];case 3:return[new y(Math.round(t.left+s),Math.round(t.top)),new y(Math.round(t.left+s+B),Math.round(t.top)),new y(Math.round(t.left+s+B),Math.round(t.height+t.top)),new y(Math.round(t.left+s),Math.round(t.height+t.top))];case 1:return[new y(Math.round(t.left+s),Math.round(t.top+a)),new y(Math.round(t.left+s+B),Math.round(t.top+a)),new y(Math.round(t.left+s+B),Math.round(t.top+a+i)),new y(Math.round(t.left+s),Math.round(t.top+a+i))];default:return[new y(Math.round(n.left),Math.round(n.top)),new y(Math.round(n.left+n.width),Math.round(n.top)),new y(Math.round(n.left+n.width),Math.round(n.height+n.top)),new y(Math.round(n.left),Math.round(n.height+n.top))]}},Sl="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7",$s="Hidden Text",Tl=function(){function e(A){this._data={},this._document=A}return e.prototype.parseMetrics=function(A,r){var t=this._document.createElement("div"),n=this._document.createElement("img"),s=this._document.createElement("span"),a=this._document.body;t.style.visibility="hidden",t.style.fontFamily=A,t.style.fontSize=r,t.style.margin="0",t.style.padding="0",t.style.whiteSpace="nowrap",a.appendChild(t),n.src=Sl,n.width=1,n.height=1,n.style.margin="0",n.style.padding="0",n.style.verticalAlign="baseline",s.style.fontFamily=A,s.style.fontSize=r,s.style.margin="0",s.style.padding="0",s.appendChild(this._document.createTextNode($s)),t.appendChild(s),t.appendChild(n);var B=n.offsetTop-s.offsetTop+2;t.removeChild(s),t.appendChild(this._document.createTextNode($s)),t.style.lineHeight="normal",n.style.verticalAlign="super";var i=n.offsetTop-t.offsetTop+2;return a.removeChild(t),{baseline:B,middle:i}},e.prototype.getMetrics=function(A,r){var t=A+" "+r;return typeof this._data[t]>"u"&&(this._data[t]=this.parseMetrics(A,r)),this._data[t]},e}(),Aa=function(){function e(A,r){this.context=A,this.options=r}return e}(),Dl=1e4,Ol=function(e){bA(A,e);function A(r,t){var n=e.call(this,r,t)||this;return n._activeEffects=[],n.canvas=t.canvas?t.canvas:document.createElement("canvas"),n.ctx=n.canvas.getContext("2d"),t.canvas||(n.canvas.width=Math.floor(t.width*t.scale),n.canvas.height=Math.floor(t.height*t.scale),n.canvas.style.width=t.width+"px",n.canvas.style.height=t.height+"px"),n.fontMetrics=new Tl(document),n.ctx.scale(n.options.scale,n.options.scale),n.ctx.translate(-t.x,-t.y),n.ctx.textBaseline="bottom",n._activeEffects=[],n.context.logger.debug("Canvas renderer initialized ("+t.width+"x"+t.height+") with scale "+t.scale),n}return A.prototype.applyEffects=function(r){for(var t=this;this._activeEffects.length;)this.popEffect();r.forEach(function(n){return t.applyEffect(n)})},A.prototype.applyEffect=function(r){this.ctx.save(),El(r)&&(this.ctx.globalAlpha=r.opacity),pl(r)&&(this.ctx.translate(r.offsetX,r.offsetY),this.ctx.transform(r.matrix[0],r.matrix[1],r.matrix[2],r.matrix[3],r.matrix[4],r.matrix[5]),this.ctx.translate(-r.offsetX,-r.offsetY)),Js(r)&&(this.path(r.path),this.ctx.clip()),this._activeEffects.push(r)},A.prototype.popEffect=function(){this._activeEffects.pop(),this.ctx.restore()},A.prototype.renderStack=function(r){return dA(this,void 0,void 0,function(){var t;return QA(this,function(n){switch(n.label){case 0:return t=r.element.container.styles,t.isVisible()?[4,this.renderStackContent(r)]:[3,2];case 1:n.sent(),n.label=2;case 2:return[2]}})})},A.prototype.renderNode=function(r){return dA(this,void 0,void 0,function(){return QA(this,function(t){switch(t.label){case 0:if(BA(r.container.flags,16))debugger;return r.container.styles.isVisible()?[4,this.renderNodeBackgroundAndBorders(r)]:[3,3];case 1:return t.sent(),[4,this.renderNodeContent(r)];case 2:t.sent(),t.label=3;case 3:return[2]}})})},A.prototype.renderTextWithLetterSpacing=function(r,t,n){var s=this;if(t===0)this.ctx.fillText(r.text,r.bounds.left,r.bounds.top+n);else{var a=It(r.text);a.reduce(function(B,i){return s.ctx.fillText(i,B,r.bounds.top+n),B+s.ctx.measureText(i).width},r.bounds.left)}},A.prototype.createFontStyle=function(r){var t=r.fontVariant.filter(function(a){return a==="normal"||a==="small-caps"}).join(""),n=kl(r.fontFamily).join(", "),s=Oe(r.fontSize)?""+r.fontSize.number+r.fontSize.unit:r.fontSize.number+"px";return[[r.fontStyle,t,r.fontWeight,s,n].join(" "),n,s]},A.prototype.renderTextNode=function(r,t){return dA(this,void 0,void 0,function(){var n,s,a,B,i,o,c,u,g=this;return QA(this,function(w){return n=this.createFontStyle(t),s=n[0],a=n[1],B=n[2],this.ctx.font=s,this.ctx.direction=t.direction===1?"rtl":"ltr",this.ctx.textAlign="left",this.ctx.textBaseline="alphabetic",i=this.fontMetrics.getMetrics(a,B),o=i.baseline,c=i.middle,u=t.paintOrder,r.textBounds.forEach(function(Q){u.forEach(function(d){switch(d){case 0:g.ctx.fillStyle=oA(t.color),g.renderTextWithLetterSpacing(Q,t.letterSpacing,o);var S=t.textShadow;S.length&&Q.text.trim().length&&(S.slice(0).reverse().forEach(function(F){g.ctx.shadowColor=oA(F.color),g.ctx.shadowOffsetX=F.offsetX.number*g.options.scale,g.ctx.shadowOffsetY=F.offsetY.number*g.options.scale,g.ctx.shadowBlur=F.blur.number,g.renderTextWithLetterSpacing(Q,t.letterSpacing,o)}),g.ctx.shadowColor="",g.ctx.shadowOffsetX=0,g.ctx.shadowOffsetY=0,g.ctx.shadowBlur=0),t.textDecorationLine.length&&(g.ctx.fillStyle=oA(t.textDecorationColor||t.color),t.textDecorationLine.forEach(function(F){switch(F){case 1:g.ctx.fillRect(Q.bounds.left,Math.round(Q.bounds.top+o),Q.bounds.width,1);break;case 2:g.ctx.fillRect(Q.bounds.left,Math.round(Q.bounds.top),Q.bounds.width,1);break;case 3:g.ctx.fillRect(Q.bounds.left,Math.ceil(Q.bounds.top+c),Q.bounds.width,1);break}}));break;case 1:t.webkitTextStrokeWidth&&Q.text.trim().length&&(g.ctx.strokeStyle=oA(t.webkitTextStrokeColor),g.ctx.lineWidth=t.webkitTextStrokeWidth,g.ctx.lineJoin=window.chrome?"miter":"round",g.ctx.strokeText(Q.text,Q.bounds.left,Q.bounds.top+o)),g.ctx.strokeStyle="",g.ctx.lineWidth=0,g.ctx.lineJoin="miter";break}})}),[2]})})},A.prototype.renderReplacedElement=function(r,t,n){if(n&&r.intrinsicWidth>0&&r.intrinsicHeight>0){var s=Mr(r),a=Dr(t);this.path(a),this.ctx.save(),this.ctx.clip(),this.ctx.drawImage(n,0,0,r.intrinsicWidth,r.intrinsicHeight,s.left,s.top,s.width,s.height),this.ctx.restore()}},A.prototype.renderNodeContent=function(r){return dA(this,void 0,void 0,function(){var t,n,s,a,B,i,p,p,o,c,u,g,I,w,Q,v,d,S,F,p,b,I,v;return QA(this,function(C){switch(C.label){case 0:this.applyEffects(r.getEffects(4)),t=r.container,n=r.curves,s=t.styles,a=0,B=t.textNodes,C.label=1;case 1:return a<B.length?(i=B[a],[4,this.renderTextNode(i,s)]):[3,4];case 2:C.sent(),C.label=3;case 3:return a++,[3,1];case 4:if(!(t instanceof ds))return[3,8];C.label=5;case 5:return C.trys.push([5,7,,8]),[4,this.context.cache.match(t.src)];case 6:return p=C.sent(),this.renderReplacedElement(t,n,p),[3,8];case 7:return C.sent(),this.context.logger.error("Error loading image "+t.src),[3,8];case 8:if(t instanceof Us&&this.renderReplacedElement(t,n,t.canvas),!(t instanceof hs))return[3,12];C.label=9;case 9:return C.trys.push([9,11,,12]),[4,this.context.cache.match(t.svg)];case 10:return p=C.sent(),this.renderReplacedElement(t,n,p),[3,12];case 11:return C.sent(),this.context.logger.error("Error loading svg "+t.svg.substring(0,255)),[3,12];case 12:return t instanceof Hs&&t.tree?(o=new A(this.context,{scale:this.options.scale,backgroundColor:t.backgroundColor,x:0,y:0,width:t.width,height:t.height}),[4,o.render(t.tree)]):[3,14];case 13:c=C.sent(),t.width&&t.height&&this.ctx.drawImage(c,0,0,t.width,t.height,t.bounds.left,t.bounds.top,t.bounds.width,t.bounds.height),C.label=14;case 14:if(t instanceof yt&&(u=Math.min(t.bounds.width,t.bounds.height),t.type===mr?t.checked&&(this.ctx.save(),this.path([new y(t.bounds.left+u*.39363,t.bounds.top+u*.79),new y(t.bounds.left+u*.16,t.bounds.top+u*.5549),new y(t.bounds.left+u*.27347,t.bounds.top+u*.44071),new y(t.bounds.left+u*.39694,t.bounds.top+u*.5649),new y(t.bounds.left+u*.72983,t.bounds.top+u*.23),new y(t.bounds.left+u*.84,t.bounds.top+u*.34085),new y(t.bounds.left+u*.39363,t.bounds.top+u*.79)]),this.ctx.fillStyle=oA(ps),this.ctx.fill(),this.ctx.restore()):t.type===yr&&t.checked&&(this.ctx.save(),this.ctx.beginPath(),this.ctx.arc(t.bounds.left+u/2,t.bounds.top+u/2,u/4,0,Math.PI*2,!0),this.ctx.fillStyle=oA(ps),this.ctx.fill(),this.ctx.restore())),Rl(t)&&t.value.length){switch(g=this.createFontStyle(s),I=g[0],w=g[1],Q=this.fontMetrics.getMetrics(I,w).baseline,this.ctx.font=I,this.ctx.fillStyle=oA(s.color),this.ctx.textBaseline="alphabetic",this.ctx.textAlign=Nl(t.styles.textAlign),v=Mr(t),d=0,t.styles.textAlign){case 1:d+=v.width/2;break;case 2:d+=v.width;break}S=v.add(d,0,0,-v.height/2+1),this.ctx.save(),this.path([new y(v.left,v.top),new y(v.left+v.width,v.top),new y(v.left+v.width,v.top+v.height),new y(v.left,v.top+v.height)]),this.ctx.clip(),this.renderTextWithLetterSpacing(new ke(t.value,S),s.letterSpacing,Q),this.ctx.restore(),this.ctx.textBaseline="alphabetic",this.ctx.textAlign="left"}if(!BA(t.styles.display,2048))return[3,20];if(t.styles.listStyleImage===null)return[3,19];if(F=t.styles.listStyleImage,F.type!==0)return[3,18];p=void 0,b=F.url,C.label=15;case 15:return C.trys.push([15,17,,18]),[4,this.context.cache.match(b)];case 16:return p=C.sent(),this.ctx.drawImage(p,t.bounds.left-(p.width+10),t.bounds.top),[3,18];case 17:return C.sent(),this.context.logger.error("Error loading list-style-image "+b),[3,18];case 18:return[3,20];case 19:r.listValue&&t.styles.listStyleType!==-1&&(I=this.createFontStyle(s)[0],this.ctx.font=I,this.ctx.fillStyle=oA(s.color),this.ctx.textBaseline="middle",this.ctx.textAlign="right",v=new RA(t.bounds.left,t.bounds.top+Z(t.styles.paddingTop,t.bounds.width),t.bounds.width,$n(s.lineHeight,s.fontSize.number)/2+1),this.renderTextWithLetterSpacing(new ke(r.listValue,v),s.letterSpacing,$n(s.lineHeight,s.fontSize.number)/2+2),this.ctx.textBaseline="bottom",this.ctx.textAlign="left"),C.label=20;case 20:return[2]}})})},A.prototype.renderStackContent=function(r){return dA(this,void 0,void 0,function(){var t,n,F,s,a,F,B,i,F,o,c,F,u,g,F,w,Q,F,d,S,F;return QA(this,function(p){switch(p.label){case 0:if(BA(r.element.container.flags,16))debugger;return[4,this.renderNodeBackgroundAndBorders(r.element)];case 1:p.sent(),t=0,n=r.negativeZIndex,p.label=2;case 2:return t<n.length?(F=n[t],[4,this.renderStack(F)]):[3,5];case 3:p.sent(),p.label=4;case 4:return t++,[3,2];case 5:return[4,this.renderNodeContent(r.element)];case 6:p.sent(),s=0,a=r.nonInlineLevel,p.label=7;case 7:return s<a.length?(F=a[s],[4,this.renderNode(F)]):[3,10];case 8:p.sent(),p.label=9;case 9:return s++,[3,7];case 10:B=0,i=r.nonPositionedFloats,p.label=11;case 11:return B<i.length?(F=i[B],[4,this.renderStack(F)]):[3,14];case 12:p.sent(),p.label=13;case 13:return B++,[3,11];case 14:o=0,c=r.nonPositionedInlineLevel,p.label=15;case 15:return o<c.length?(F=c[o],[4,this.renderStack(F)]):[3,18];case 16:p.sent(),p.label=17;case 17:return o++,[3,15];case 18:u=0,g=r.inlineLevel,p.label=19;case 19:return u<g.length?(F=g[u],[4,this.renderNode(F)]):[3,22];case 20:p.sent(),p.label=21;case 21:return u++,[3,19];case 22:w=0,Q=r.zeroOrAutoZIndexOrTransformedOrOpacity,p.label=23;case 23:return w<Q.length?(F=Q[w],[4,this.renderStack(F)]):[3,26];case 24:p.sent(),p.label=25;case 25:return w++,[3,23];case 26:d=0,S=r.positiveZIndex,p.label=27;case 27:return d<S.length?(F=S[d],[4,this.renderStack(F)]):[3,30];case 28:p.sent(),p.label=29;case 29:return d++,[3,27];case 30:return[2]}})})},A.prototype.mask=function(r){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(r.slice(0).reverse()),this.ctx.closePath()},A.prototype.path=function(r){this.ctx.beginPath(),this.formatPath(r),this.ctx.closePath()},A.prototype.formatPath=function(r){var t=this;r.forEach(function(n,s){var a=IA(n)?n.start:n;s===0?t.ctx.moveTo(a.x,a.y):t.ctx.lineTo(a.x,a.y),IA(n)&&t.ctx.bezierCurveTo(n.startControl.x,n.startControl.y,n.endControl.x,n.endControl.y,n.end.x,n.end.y)})},A.prototype.renderRepeat=function(r,t,n,s){this.path(r),this.ctx.fillStyle=t,this.ctx.translate(n,s),this.ctx.fill(),this.ctx.translate(-n,-s)},A.prototype.resizeImage=function(r,t,n){var s;if(r.width===t&&r.height===n)return r;var a=(s=this.canvas.ownerDocument)!==null&&s!==void 0?s:document,B=a.createElement("canvas");B.width=Math.max(1,t),B.height=Math.max(1,n);var i=B.getContext("2d");return i.drawImage(r,0,0,r.width,r.height,0,0,t,n),B},A.prototype.renderBackgroundImage=function(r){return dA(this,void 0,void 0,function(){var t,n,s,a,B,i;return QA(this,function(o){switch(o.label){case 0:t=r.styles.backgroundImage.length-1,n=function(c){var u,g,w,T,tA,nA,D,Y,x,Q,T,tA,nA,D,Y,d,S,F,p,b,I,v,C,R,x,E,T,_,AA,D,Y,cA,tA,nA,FA,fA,H,U,M,G,P,$;return QA(this,function(lA){switch(lA.label){case 0:if(c.type!==0)return[3,5];u=void 0,g=c.url,lA.label=1;case 1:return lA.trys.push([1,3,,4]),[4,s.context.cache.match(g)];case 2:return u=lA.sent(),[3,4];case 3:return lA.sent(),s.context.logger.error("Error loading background-image "+g),[3,4];case 4:return u&&(w=Nt(r,t,[u.width,u.height,u.width/u.height]),T=w[0],tA=w[1],nA=w[2],D=w[3],Y=w[4],x=s.ctx.createPattern(s.resizeImage(u,D,Y),"repeat"),s.renderRepeat(T,x,tA,nA)),[3,6];case 5:FB(c)?(Q=Nt(r,t,[null,null,null]),T=Q[0],tA=Q[1],nA=Q[2],D=Q[3],Y=Q[4],d=QB(c.angle,D,Y),S=d[0],F=d[1],p=d[2],b=d[3],I=d[4],v=document.createElement("canvas"),v.width=D,v.height=Y,C=v.getContext("2d"),R=C.createLinearGradient(F,b,p,I),Vn(c.stops,S).forEach(function(wA){return R.addColorStop(wA.stop,oA(wA.color))}),C.fillStyle=R,C.fillRect(0,0,D,Y),D>0&&Y>0&&(x=s.ctx.createPattern(v,"repeat"),s.renderRepeat(T,x,tA,nA))):pB(c)&&(E=Nt(r,t,[null,null,null]),T=E[0],_=E[1],AA=E[2],D=E[3],Y=E[4],cA=c.position.length===0?[lt]:c.position,tA=Z(cA[0],D),nA=Z(cA[cA.length-1],Y),FA=CB(c,tA,nA,D,Y),fA=FA[0],H=FA[1],fA>0&&H>0&&(U=s.ctx.createRadialGradient(_+tA,AA+nA,0,_+tA,AA+nA,fA),Vn(c.stops,fA*2).forEach(function(wA){return U.addColorStop(wA.stop,oA(wA.color))}),s.path(T),s.ctx.fillStyle=U,fA!==H?(M=r.bounds.left+.5*r.bounds.width,G=r.bounds.top+.5*r.bounds.height,P=H/fA,$=1/P,s.ctx.save(),s.ctx.translate(M,G),s.ctx.transform(1,0,0,P,0,0),s.ctx.translate(-M,-G),s.ctx.fillRect(_,$*(AA-G)+G,D,Y*$),s.ctx.restore()):s.ctx.fill())),lA.label=6;case 6:return t--,[2]}})},s=this,a=0,B=r.styles.backgroundImage.slice(0).reverse(),o.label=1;case 1:return a<B.length?(i=B[a],[5,n(i)]):[3,4];case 2:o.sent(),o.label=3;case 3:return a++,[3,1];case 4:return[2]}})})},A.prototype.renderSolidBorder=function(r,t,n){return dA(this,void 0,void 0,function(){return QA(this,function(s){return this.path(zs(n,t)),this.ctx.fillStyle=oA(r),this.ctx.fill(),[2]})})},A.prototype.renderDoubleBorder=function(r,t,n,s){return dA(this,void 0,void 0,function(){var a,B;return QA(this,function(i){switch(i.label){case 0:return t<3?[4,this.renderSolidBorder(r,n,s)]:[3,2];case 1:return i.sent(),[2];case 2:return a=Il(s,n),this.path(a),this.ctx.fillStyle=oA(r),this.ctx.fill(),B=ml(s,n),this.path(B),this.ctx.fill(),[2]}})})},A.prototype.renderNodeBackgroundAndBorders=function(r){return dA(this,void 0,void 0,function(){var t,n,s,a,B,i,o,c,u=this;return QA(this,function(g){switch(g.label){case 0:return this.applyEffects(r.getEffects(2)),t=r.container.styles,n=!YA(t.backgroundColor)||t.backgroundImage.length,s=[{style:t.borderTopStyle,color:t.borderTopColor,width:t.borderTopWidth},{style:t.borderRightStyle,color:t.borderRightColor,width:t.borderRightWidth},{style:t.borderBottomStyle,color:t.borderBottomColor,width:t.borderBottomWidth},{style:t.borderLeftStyle,color:t.borderLeftColor,width:t.borderLeftWidth}],a=Ml(de(t.backgroundClip,0),r.curves),n||t.boxShadow.length?(this.ctx.save(),this.path(a),this.ctx.clip(),YA(t.backgroundColor)||(this.ctx.fillStyle=oA(t.backgroundColor),this.ctx.fill()),[4,this.renderBackgroundImage(r.container)]):[3,2];case 1:g.sent(),this.ctx.restore(),t.boxShadow.slice(0).reverse().forEach(function(w){u.ctx.save();var Q=Tr(r.curves),d=w.inset?0:Dl,S=vl(Q,-d+(w.inset?1:-1)*w.spread.number,(w.inset?1:-1)*w.spread.number,w.spread.number*(w.inset?-2:2),w.spread.number*(w.inset?-2:2));w.inset?(u.path(Q),u.ctx.clip(),u.mask(S)):(u.mask(Q),u.ctx.clip(),u.path(S)),u.ctx.shadowOffsetX=w.offsetX.number+d,u.ctx.shadowOffsetY=w.offsetY.number,u.ctx.shadowColor=oA(w.color),u.ctx.shadowBlur=w.blur.number,u.ctx.fillStyle=w.inset?oA(w.color):"rgba(0,0,0,1)",u.ctx.fill(),u.ctx.restore()}),g.label=2;case 2:B=0,i=0,o=s,g.label=3;case 3:return i<o.length?(c=o[i],c.style!==0&&!YA(c.color)&&c.width>0?c.style!==2?[3,5]:[4,this.renderDashedDottedBorder(c.color,c.width,B,r.curves,2)]:[3,11]):[3,13];case 4:return g.sent(),[3,11];case 5:return c.style!==3?[3,7]:[4,this.renderDashedDottedBorder(c.color,c.width,B,r.curves,3)];case 6:return g.sent(),[3,11];case 7:return c.style!==4?[3,9]:[4,this.renderDoubleBorder(c.color,c.width,B,r.curves)];case 8:return g.sent(),[3,11];case 9:return[4,this.renderSolidBorder(c.color,B,r.curves)];case 10:g.sent(),g.label=11;case 11:B++,g.label=12;case 12:return i++,[3,3];case 13:return[2]}})})},A.prototype.renderDashedDottedBorder=function(r,t,n,s,a){return dA(this,void 0,void 0,function(){var B,i,o,c,u,g,w,Q,d,S,F,p,b,I,v,C,v,C;return QA(this,function(R){return this.ctx.save(),B=yl(s,n),i=zs(s,n),a===2&&(this.path(i),this.ctx.clip()),IA(i[0])?(o=i[0].start.x,c=i[0].start.y):(o=i[0].x,c=i[0].y),IA(i[1])?(u=i[1].end.x,g=i[1].end.y):(u=i[1].x,g=i[1].y),n===0||n===2?w=Math.abs(o-u):w=Math.abs(c-g),this.ctx.beginPath(),a===3?this.formatPath(B):this.formatPath(i.slice(0,2)),Q=t<3?t*3:t*2,d=t<3?t*2:t,a===3&&(Q=t,d=t),S=!0,w<=Q*2?S=!1:w<=Q*2+d?(F=w/(2*Q+d),Q*=F,d*=F):(p=Math.floor((w+d)/(Q+d)),b=(w-p*Q)/(p-1),I=(w-(p+1)*Q)/p,d=I<=0||Math.abs(d-b)<Math.abs(d-I)?b:I),S&&(a===3?this.ctx.setLineDash([0,Q+d]):this.ctx.setLineDash([Q,d])),a===3?(this.ctx.lineCap="round",this.ctx.lineWidth=t):this.ctx.lineWidth=t*2+1.1,this.ctx.strokeStyle=oA(r),this.ctx.stroke(),this.ctx.setLineDash([]),a===2&&(IA(i[0])&&(v=i[3],C=i[0],this.ctx.beginPath(),this.formatPath([new y(v.end.x,v.end.y),new y(C.start.x,C.start.y)]),this.ctx.stroke()),IA(i[1])&&(v=i[1],C=i[2],this.ctx.beginPath(),this.formatPath([new y(v.end.x,v.end.y),new y(C.start.x,C.start.y)]),this.ctx.stroke())),this.ctx.restore(),[2]})})},A.prototype.render=function(r){return dA(this,void 0,void 0,function(){var t;return QA(this,function(n){switch(n.label){case 0:return this.options.backgroundColor&&(this.ctx.fillStyle=oA(this.options.backgroundColor),this.ctx.fillRect(this.options.x,this.options.y,this.options.width,this.options.height)),t=Hl(r),[4,this.renderStack(t)];case 1:return n.sent(),this.applyEffects([]),[2,this.canvas]}})})},A}(Aa),Rl=function(e){return e instanceof vs||e instanceof Es?!0:e instanceof yt&&e.type!==yr&&e.type!==mr},Ml=function(e,A){switch(e){case 0:return Tr(A);case 2:return Ul(A);case 1:default:return Dr(A)}},Nl=function(e){switch(e){case 1:return"center";case 2:return"right";case 0:default:return"left"}},Gl=["-apple-system","system-ui"],kl=function(e){return/iPhone OS 15_(0|1)/.test(window.navigator.userAgent)?e.filter(function(A){return Gl.indexOf(A)===-1}):e},Vl=function(e){bA(A,e);function A(r,t){var n=e.call(this,r,t)||this;return n.canvas=t.canvas?t.canvas:document.createElement("canvas"),n.ctx=n.canvas.getContext("2d"),n.options=t,n.canvas.width=Math.floor(t.width*t.scale),n.canvas.height=Math.floor(t.height*t.scale),n.canvas.style.width=t.width+"px",n.canvas.style.height=t.height+"px",n.ctx.scale(n.options.scale,n.options.scale),n.ctx.translate(-t.x,-t.y),n.context.logger.debug("EXPERIMENTAL ForeignObject renderer initialized ("+t.width+"x"+t.height+" at "+t.x+","+t.y+") with scale "+t.scale),n}return A.prototype.render=function(r){return dA(this,void 0,void 0,function(){var t,n;return QA(this,function(s){switch(s.label){case 0:return t=Ht(this.options.width*this.options.scale,this.options.height*this.options.scale,this.options.scale,this.options.scale,r),[4,_l(t)];case 1:return n=s.sent(),this.options.backgroundColor&&(this.ctx.fillStyle=oA(this.options.backgroundColor),this.ctx.fillRect(0,0,this.options.width*this.options.scale,this.options.height*this.options.scale)),this.ctx.drawImage(n,-this.options.x*this.options.scale,-this.options.y*this.options.scale),[2,this.canvas]}})})},A}(Aa),_l=function(e){return new Promise(function(A,r){var t=new Image;t.onload=function(){A(t)},t.onerror=r,t.src="data:image/svg+xml;charset=utf-8,"+encodeURIComponent(new XMLSerializer().serializeToString(e))})},Pl=function(){function e(A){var r=A.id,t=A.enabled;this.id=r,this.enabled=t,this.start=Date.now()}return e.prototype.debug=function(){for(var A=[],r=0;r<arguments.length;r++)A[r]=arguments[r];this.enabled&&(typeof window<"u"&&window.console&&typeof console.debug=="function"?console.debug.apply(console,Ye([this.id,this.getTime()+"ms"],A)):this.info.apply(this,A))},e.prototype.getTime=function(){return Date.now()-this.start},e.prototype.info=function(){for(var A=[],r=0;r<arguments.length;r++)A[r]=arguments[r];this.enabled&&typeof window<"u"&&window.console&&typeof console.info=="function"&&console.info.apply(console,Ye([this.id,this.getTime()+"ms"],A))},e.prototype.warn=function(){for(var A=[],r=0;r<arguments.length;r++)A[r]=arguments[r];this.enabled&&(typeof window<"u"&&window.console&&typeof console.warn=="function"?console.warn.apply(console,Ye([this.id,this.getTime()+"ms"],A)):this.info.apply(this,A))},e.prototype.error=function(){for(var A=[],r=0;r<arguments.length;r++)A[r]=arguments[r];this.enabled&&(typeof window<"u"&&window.console&&typeof console.error=="function"?console.error.apply(console,Ye([this.id,this.getTime()+"ms"],A)):this.info.apply(this,A))},e.instances={},e}(),Xl=function(){function e(A,r){var t;this.windowBounds=r,this.instanceName="#"+e.instanceCount++,this.logger=new Pl({id:this.instanceName,enabled:A.logging}),this.cache=(t=A.cache)!==null&&t!==void 0?t:new ll(this,A)}return e.instanceCount=1,e}(),Jl=function(e,A){return A===void 0&&(A={}),Yl(e,A)};typeof window<"u"&&Xs.setContext(window);var Yl=function(e,A){return dA(void 0,void 0,void 0,function(){var r,t,n,s,a,B,i,o,c,u,g,w,Q,d,S,F,p,b,I,v,R,C,R,x,E,T,_,AA,D,Y,cA,tA,nA,FA,fA,H,U,M,G,P;return QA(this,function($){switch($.label){case 0:if(!e||typeof e!="object")return[2,Promise.reject("Invalid element provided as first argument")];if(r=e.ownerDocument,!r)throw new Error("Element is not attached to a Document");if(t=r.defaultView,!t)throw new Error("Document is not attached to a Window");return n={allowTaint:(x=A.allowTaint)!==null&&x!==void 0?x:!1,imageTimeout:(E=A.imageTimeout)!==null&&E!==void 0?E:15e3,proxy:A.proxy,useCORS:(T=A.useCORS)!==null&&T!==void 0?T:!1},s=Pr({logging:(_=A.logging)!==null&&_!==void 0?_:!0,cache:A.cache},n),a={windowWidth:(AA=A.windowWidth)!==null&&AA!==void 0?AA:t.innerWidth,windowHeight:(D=A.windowHeight)!==null&&D!==void 0?D:t.innerHeight,scrollX:(Y=A.scrollX)!==null&&Y!==void 0?Y:t.pageXOffset,scrollY:(cA=A.scrollY)!==null&&cA!==void 0?cA:t.pageYOffset},B=new RA(a.scrollX,a.scrollY,a.windowWidth,a.windowHeight),i=new Xl(s,B),o=(tA=A.foreignObjectRendering)!==null&&tA!==void 0?tA:!1,c={allowTaint:(nA=A.allowTaint)!==null&&nA!==void 0?nA:!1,onclone:A.onclone,ignoreElements:A.ignoreElements,inlineImages:o,copyStyles:o},i.logger.debug("Starting document clone with size "+B.width+"x"+B.height+" scrolled to "+-B.left+","+-B.top),u=new _s(i,e,c),g=u.clonedReferenceElement,g?[4,u.toIFrame(r,B)]:[2,Promise.reject("Unable to find element in cloned iframe")];case 1:return w=$.sent(),Q=Kt(g)||Wc(g)?Ea(g.ownerDocument):We(i,g),d=Q.width,S=Q.height,F=Q.left,p=Q.top,b=Wl(i,g,A.backgroundColor),I={canvas:A.canvas,backgroundColor:b,scale:(fA=(FA=A.scale)!==null&&FA!==void 0?FA:t.devicePixelRatio)!==null&&fA!==void 0?fA:1,x:((H=A.x)!==null&&H!==void 0?H:0)+F,y:((U=A.y)!==null&&U!==void 0?U:0)+p,width:(M=A.width)!==null&&M!==void 0?M:Math.ceil(d),height:(G=A.height)!==null&&G!==void 0?G:Math.ceil(S)},o?(i.logger.debug("Document cloned, using foreign object rendering"),R=new Vl(i,I),[4,R.render(g)]):[3,3];case 2:return v=$.sent(),[3,5];case 3:return i.logger.debug("Document cloned, element located at "+F+","+p+" with size "+d+"x"+S+" using computed rendering"),i.logger.debug("Starting DOM parsing"),C=ms(i,g),b===C.styles.backgroundColor&&(C.styles.backgroundColor=NA.TRANSPARENT),i.logger.debug("Starting renderer for element at "+I.x+","+I.y+" with size "+I.width+"x"+I.height),R=new Ol(i,I),[4,R.render(C)];case 4:v=$.sent(),$.label=5;case 5:return(!((P=A.removeContainer)!==null&&P!==void 0)||P)&&(_s.destroy(w)||i.logger.error("Cannot detach cloned iframe as it is not in the DOM anymore")),i.logger.debug("Finished rendering"),[2,v]}})})},Wl=function(e,A,r){var t=A.ownerDocument,n=t.documentElement?Me(e,getComputedStyle(t.documentElement).backgroundColor):NA.TRANSPARENT,s=t.body?Me(e,getComputedStyle(t.body).backgroundColor):NA.TRANSPARENT,a=typeof r=="string"?Me(e,r):r===null?NA.TRANSPARENT:4294967295;return A===t.documentElement?YA(n)?YA(s)?a:s:n:a};function jl(e){const A=[],r=Zl(e);r&&A.push(r);const t=ql(e);t&&A.push(`in ${t}`);const n=Au(e);return n&&A.push(n),A.length>0?A.join(" "):null}function Zl(e){const A=[],r=e.getAttribute("data-feedback-id");if(r)return`[data-feedback-id="${r}"]`;const t=e.tagName.toLowerCase();if(A.push(t),e.id)return A.push(`#${e.id}`),A.join("");const n=e.getAttribute("data-testid");if(n)return A.push(`[data-testid="${n}"]`),A.join("");const s=e.getAttribute("aria-label");if(s)return A.push(`[aria-label="${Gr(s,30)}"]`),A.join("");const a=Array.from(e.classList).filter(i=>!Gt(i)).slice(0,2);a.length>0&&A.push(a.map(i=>`.${i}`).join(""));const B=zl(e);return B&&A.push(`"${B}"`),A.join("")}function zl(e){var r,t;if(["BUTTON","A","H1","H2","H3","H4","H5","H6","LABEL","TH","TD"].includes(e.tagName)){let n="";for(const s of e.childNodes)s.nodeType===Node.TEXT_NODE&&(n+=((r=s.textContent)==null?void 0:r.trim())||"");return n||(n=((t=e.textContent)==null?void 0:t.trim())||""),Gr(n,25)}return null}function ql(e){let A=e.parentElement;const r=[];let t=0;const n=5;for(;A&&A!==document.body&&t<n;){const s=A.getAttribute("data-feedback-id");if(s){r.unshift(`[data-feedback-id="${s}"]`);break}if(A.id){r.unshift(`#${A.id}`);break}const a=A.tagName.toLowerCase();if(["section","article","nav","header","footer","main","aside","form","table","ul","ol"].includes(a)){const o=Array.from(A.classList).filter(u=>!Gt(u)).slice(0,1),c=o.length>0?`.${o[0]}`:"";r.unshift(`${a}${c}`)}const i=Array.from(A.classList).find(o=>/card|panel|modal|section|container|wrapper|item|row/i.test(o));if(i){const o=$l(A);if(o){r.unshift(`.${i} "${o}"`);break}else r.unshift(`.${i}`)}A=A.parentElement,t++}return r.length>0?r.join(" > "):null}function $l(e){var n,s;const A=e.querySelector("h1, h2, h3, h4, h5, h6");if(A){const a=(n=A.textContent)==null?void 0:n.trim();if(a)return Gr(a,20)}const r=e.querySelector('[class*="title"], [class*="header"], [class*="name"]');if(r){const a=(s=r.textContent)==null?void 0:s.trim();if(a)return Gr(a,20)}const t=e.querySelector("[data-feedback-id]");return t?t.getAttribute("data-feedback-id"):null}function Au(e){const A=e.parentElement;if(!A)return null;const r=Array.from(A.children).filter(t=>t.tagName===e.tagName);return r.length>1?`(${r.indexOf(e)+1} of ${r.length})`:null}function Gt(e){return[/^(p|m|w|h|min|max|flex|grid|gap|space|text|font|bg|border|rounded|shadow|opacity|z|top|right|bottom|left|inset)-/,/^(sm|md|lg|xl|2xl):/,/^(hover|focus|active|disabled):/,/^(col|row)-span/,/^(justify|items|content|self)-/,/^(overflow|whitespace|break)-/].some(r=>r.test(e))}function Gr(e,A){return e.length<=A?e:e.slice(0,A).trim()+"..."}function eu(e){const A=[];let r=e,t=0;const n=5;for(;r&&r!==document.body&&t<n;){let s=r.tagName.toLowerCase();const a=r.getAttribute("data-feedback-id");if(a){s=`[data-feedback-id="${a}"]`,A.unshift(s);break}if(r.id){s+=`#${r.id}`,A.unshift(s);break}const B=r.getAttribute("data-testid");if(B){s+=`[data-testid="${B}"]`,A.unshift(s);break}const i=Array.from(r.classList).filter(c=>!Gt(c))[0];i&&(s+=`.${i}`);const o=r.parentElement;if(o){const c=r.tagName,u=[];for(let g=0;g<o.children.length;g++){const w=o.children[g];w.tagName===c&&u.push(w)}if(u.length>1){const g=u.indexOf(r)+1;s+=`:nth-of-type(${g})`}}A.unshift(s),r=o,t++}return A.length>0?A.join(" > "):null}function ru(e,A){return document.elementFromPoint(e,A)}function ea(){return`${Date.now()}-${Math.random().toString(36).substr(2,9)}`}const tu=["Bug","UX","Content","Other"];function nu({clickData:e,userName:A,existingItem:r,validation:t,onClose:n,onSave:s,onDelete:a}){const[B,i]=m.useState((r==null?void 0:r.comment)||""),[o,c]=m.useState((r==null?void 0:r.category)||"Bug"),[u,g]=m.useState(null),w=!!r,Q=()=>{if(!B.trim()){g("Comment is required");return}if(t!=null&&t.maxCommentLength&&B.length>t.maxCommentLength){g(`Comment must be under ${t.maxCommentLength} characters`);return}if(t!=null&&t.maxScreenshotSize&&e.screenshot&&e.screenshot.length*3/4>t.maxScreenshotSize){g(`Screenshot is too large (max ${Math.round(t.maxScreenshotSize/1024)}KB)`);return}if(w&&r){const F={...r,updatedAt:new Date().toISOString(),category:o,comment:B.trim()};s(F)}else{const F={id:ea(),createdAt:new Date().toISOString(),userName:A,route:e.route,title:e.title,x:e.x,y:e.y,pageX:e.pageX,pageY:e.pageY,xNorm:e.xNorm,yNorm:e.yNorm,viewportW:e.viewportW,viewportH:e.viewportH,scrollX:e.scrollX,scrollY:e.scrollY,domHint:e.domHint,selectorHint:e.selectorHint,category:o,comment:B.trim(),screenshot:e.screenshot};s(F)}},d=()=>{r&&window.confirm("Delete this feedback?")&&(a==null||a(r.id))},S={position:"fixed",left:Math.min(e.x+20,window.innerWidth-340),top:Math.min(e.y+20,window.innerHeight-450),zIndex:10001};return f.jsxs("div",{className:"feedback-modal",style:S,children:[f.jsxs("div",{className:"feedback-modal-header",children:[f.jsx("h3",{children:w?"Edit Feedback":"Add Feedback"}),f.jsx("button",{className:"feedback-modal-close",onClick:n,children:"×"})]}),f.jsxs("div",{className:"feedback-modal-info",children:[f.jsxs("div",{children:[f.jsx("strong",{children:"Route:"})," ",e.route]}),f.jsxs("div",{children:[f.jsx("strong",{children:"Position:"})," (",Math.round(e.x),", ",Math.round(e.y),")"]}),f.jsxs("div",{children:[f.jsx("strong",{children:"Element:"})," ",e.domHint||"Unknown"]}),w&&r&&f.jsxs("div",{children:[f.jsx("strong",{children:"Created by:"})," ",r.userName||"Anonymous"]}),!w&&f.jsxs("div",{children:[f.jsx("strong",{children:"By:"})," ",A]})]}),f.jsxs("div",{className:"feedback-modal-field",children:[f.jsx("label",{htmlFor:"feedback-category",children:"Category"}),f.jsx("select",{id:"feedback-category",value:o,onChange:F=>c(F.target.value),children:tu.map(F=>f.jsx("option",{value:F,children:F},F))})]}),f.jsxs("div",{className:"feedback-modal-field",children:[f.jsx("label",{htmlFor:"feedback-comment",children:"Comment *"}),f.jsx("textarea",{id:"feedback-comment",value:B,onChange:F=>{i(F.target.value),g(null)},placeholder:"Describe the issue or suggestion...",rows:4}),u&&f.jsx("div",{className:"feedback-modal-error",children:u})]}),f.jsxs("div",{className:"feedback-modal-actions",children:[w&&f.jsx("button",{className:"btn-danger",onClick:d,children:"Delete"}),f.jsx("div",{style:{flex:1}}),f.jsx("button",{className:"btn-secondary",onClick:n,children:"Cancel"}),f.jsx("button",{className:"btn-primary",onClick:Q,children:w?"Update":"Save"})]})]})}function ra(e){return{id:e.id,created_at:e.createdAt,updated_at:e.updatedAt,user_name:e.userName,route:e.route,title:e.title,x:e.x,y:e.y,page_x:e.pageX,page_y:e.pageY,x_norm:e.xNorm,y_norm:e.yNorm,viewport_w:e.viewportW,viewport_h:e.viewportH,scroll_x:e.scrollX,scroll_y:e.scrollY,dom_hint:e.domHint,selector_hint:e.selectorHint,category:e.category,comment:e.comment,screenshot:e.screenshot,project_id:e.projectUuid,reviewer_id:e.reviewerId}}function kt(e){return{id:e.id,createdAt:e.created_at,updatedAt:e.updated_at,userName:e.user_name,route:e.route,title:e.title,x:e.x,y:e.y,pageX:e.page_x,pageY:e.page_y,xNorm:e.x_norm,yNorm:e.y_norm,viewportW:e.viewport_w,viewportH:e.viewport_h,scrollX:e.scroll_x,scrollY:e.scroll_y,domHint:e.dom_hint,selectorHint:e.selector_hint,category:e.category,comment:e.comment,screenshot:e.screenshot,projectId:e.project_id,reviewerId:e.reviewer_id}}const Xe="feedback_items",su="https://ubrdhrngfvwlkuhdireh.supabase.co",au="sb_publishable_e81HvMlbF_TXeB5NUSao6w_9_ZK5EIl";class iu{constructor(A){Ua(this,"prefix");this.prefix=A}getItem(A){try{return sessionStorage.getItem(`${this.prefix}-${A}`)}catch{return null}}setItem(A,r){try{sessionStorage.setItem(`${this.prefix}-${A}`,r)}catch(t){console.error("[Feedback] Failed to set storage item:",t)}}removeItem(A){try{sessionStorage.removeItem(`${this.prefix}-${A}`)}catch{}}}let Vt=null;function kA(){if(!Vt){const e=new iu("feedback-supabase");Vt=ha.createClient(su,au,{auth:{storage:e,storageKey:"auth-token",autoRefreshToken:!0,persistSession:!0}})}return Vt}const ta=m.createContext(null);function Bu({children:e}){const[A,r]=m.useState(null),[t,n]=m.useState(null),[s,a]=m.useState(!1),[B,i]=m.useState(!1),[o,c]=m.useState([]),[u,g]=m.useState(!0),w=kA(),Q=m.useCallback(async I=>{try{const{data:v,error:C}=await w.from("admins").select("id").eq("user_id",I).maybeSingle();return C?(console.error("[Feedback] Error fetching admin status:",C),!1):!!v}catch(v){return console.error("[Feedback] Exception fetching admin status:",v),!1}},[w]),d=m.useCallback(async I=>{try{const{data:v,error:C}=await w.from("reviewers").select("id, project_id, projects(project_id)").eq("user_id",I);return C?(console.error("[Feedback] Error fetching reviewer projects:",C),[]):v?(v??[]).map(x=>{const E=Array.isArray(x.projects)?x.projects[0]:x.projects;return E!=null&&E.project_id?{projectId:E.project_id,projectUuid:x.project_id,reviewerId:x.id}:null}).filter(x=>x!==null):[]}catch(v){return console.error("[Feedback] Exception fetching reviewer projects:",v),[]}},[w]),S=m.useCallback(async I=>{try{if(!I){n(null),a(!1),i(!1),c([]),g(!1);return}const[v,C]=await Promise.all([Q(I.id),d(I.id)]);n(I),i(v),a(C.length>0),c(C),g(!1)}catch(v){console.error("[Feedback] Error loading auth state:",v),g(!1)}},[Q,d]);m.useEffect(()=>{let I=!0,v=null;const C=setTimeout(()=>{I&&(console.warn("[Feedback] Auth initialization timeout - setting loading to false"),g(!1))},1e4);(async()=>{if(v){await v;return}return v=(async()=>{try{await new Promise(_=>setTimeout(_,100));const{data:{session:E},error:T}=await w.auth.getSession();if(!I)return;if(T){console.error("[Feedback] Error getting session:",T),g(!1),clearTimeout(C);return}r(E),await S((E==null?void 0:E.user)??null),clearTimeout(C)}catch(E){console.error("[Feedback] Error initializing session:",E),I&&g(!1),clearTimeout(C)}finally{v=null}})(),v})();const{data:{subscription:x}}=w.auth.onAuthStateChange(async(E,T)=>{try{if(!I)return;r(T),await S((T==null?void 0:T.user)??null)}catch(_){console.error("[Feedback] Error handling auth state change:",_),I&&g(!1)}});return()=>{I=!1,clearTimeout(C),x.unsubscribe()}},[w.auth,S]);const F=m.useCallback(I=>o.some(v=>v.projectId===I),[o]),p=m.useCallback(I=>o.find(v=>v.projectId===I),[o]),b={session:A,user:t,isReviewer:s,isAdmin:B,reviewerProjects:o,loading:u,hasAccessToProject:F,getReviewerProject:p};return f.jsx(ta.Provider,{value:b,children:e})}function Je(){const e=m.useContext(ta);if(!e)throw new Error("useFeedbackAuth must be used within FeedbackAuthProvider");return e}async function ou(e,A){try{const r=document.querySelectorAll(".feedback-toggle-container, .feedback-marker, .feedback-modal, .feedback-overlay-hint");r.forEach(Q=>{Q.style.visibility="hidden"});const t=.5,n=await Jl(document.body,{logging:!1,useCORS:!0,scale:t,windowWidth:window.innerWidth,windowHeight:window.innerHeight});r.forEach(Q=>{Q.style.visibility="visible"});const s=document.createElement("canvas"),a=window.innerWidth*t,B=window.innerHeight*t;s.width=a,s.height=B;const i=s.getContext("2d");if(!i)return;const o=window.scrollX*t,c=window.scrollY*t;i.drawImage(n,o,c,a,B,0,0,a,B);const u=e*t,g=A*t,w=20;return i.beginPath(),i.arc(u,g,w+4,0,Math.PI*2),i.strokeStyle="white",i.lineWidth=4,i.stroke(),i.beginPath(),i.arc(u,g,w,0,Math.PI*2),i.strokeStyle="#ef4444",i.lineWidth=4,i.stroke(),i.beginPath(),i.arc(u,g,6,0,Math.PI*2),i.fillStyle="#ef4444",i.fill(),i.beginPath(),i.moveTo(u-w-10,g),i.lineTo(u-w+5,g),i.moveTo(u+w-5,g),i.lineTo(u+w+10,g),i.moveTo(u,g-w-10),i.lineTo(u,g-w+5),i.moveTo(u,g+w-5),i.lineTo(u,g+w+10),i.strokeStyle="#ef4444",i.lineWidth=3,i.stroke(),s.toDataURL("image/jpeg",.6)}catch(r){console.error("[Feedback] Screenshot capture failed:",r);return}}function cu({item:e,clickData:A,onClose:r}){const t=e.userName||"Anonymous",n={position:"fixed",left:Math.min(A.x+20,window.innerWidth-340),top:Math.min(A.y+20,window.innerHeight-350),zIndex:10001};return f.jsxs("div",{className:"feedback-modal",style:n,children:[f.jsxs("div",{className:"feedback-modal-header",children:[f.jsx("h3",{children:"Feedback"}),f.jsx("button",{className:"feedback-modal-close",onClick:r,children:"×"})]}),f.jsxs("div",{className:"feedback-modal-info",children:[f.jsxs("div",{children:[f.jsx("strong",{children:"By:"})," ",t]}),f.jsxs("div",{children:[f.jsx("strong",{children:"Date:"})," ",new Date(e.createdAt).toLocaleString()]}),f.jsxs("div",{children:[f.jsx("strong",{children:"Category:"})," ",e.category]}),f.jsxs("div",{children:[f.jsx("strong",{children:"Route:"})," ",e.route]}),f.jsxs("div",{children:[f.jsx("strong",{children:"Element:"})," ",e.domHint||"Unknown"]})]}),f.jsxs("div",{className:"feedback-modal-field",children:[f.jsx("label",{children:"Comment"}),f.jsx("div",{className:"feedback-view-comment",children:e.comment})]}),f.jsxs("div",{className:"feedback-modal-actions",children:[f.jsx("div",{className:"feedback-view-hint",children:"Turn on feedback mode to edit"}),f.jsx("button",{className:"btn-secondary",onClick:r,children:"Close"})]})]})}function lu({children:e,projectId:A,enabled:r=!0,rateLimitSeconds:t=0,validation:n,feedbackReviewPath:s="/feedback"}){var H;const{user:a,hasAccessToProject:B,getReviewerProject:i,loading:o}=Je(),[c,u]=m.useState(!1),[g,w]=m.useState(null),[Q,d]=m.useState(null),[S,F]=m.useState(null),[p,b]=m.useState([]),[I,v]=m.useState({x:0,y:0}),C=LA.useLocation(),R=(a==null?void 0:a.email)??((H=a==null?void 0:a.user_metadata)==null?void 0:H.name)??null,x=A?i(A):void 0,E=!!(A&&!o&&a&&B(A));m.useEffect(()=>{const U=()=>{v({x:window.scrollX,y:window.scrollY})};return U(),window.addEventListener("scroll",U,{passive:!0}),()=>window.removeEventListener("scroll",U)},[]);const T=m.useCallback(()=>{if(!t||t<=0)return!0;const U=localStorage.getItem("feedback_last_submission");if(U){const M=parseInt(U,10),P=(Date.now()-M)/1e3;if(P<t)return alert(`Please wait ${Math.ceil(t-P)} seconds before submitting again.`),!1}return!0},[t]),_=m.useCallback(async()=>{if(!(x!=null&&x.projectUuid))return;const U=kA();try{const{data:M,error:G}=await U.from(Xe).select("*").eq("project_id",x.projectUuid);if(G){console.error("[Feedback] Failed to load items from Supabase:",G);return}if(M){const P=M.map(kt);b(P)}}catch(M){console.error("[Feedback] Error loading items:",M)}},[x==null?void 0:x.projectUuid]);m.useEffect(()=>{_();let U;return x!=null&&x.projectUuid&&(U=setInterval(_,3e4)),()=>{U&&clearInterval(U)}},[_,x==null?void 0:x.projectUuid]);const AA=p.filter(U=>U.route===C.pathname+C.search),D=m.useCallback(()=>{u(U=>U?(w(null),d(null),console.log("[Feedback] Mode OFF"),!1):(console.log("[Feedback] Mode ON"),!0))},[]);m.useEffect(()=>{if(!r||!E)return;const U=M=>{(M.ctrlKey||M.metaKey)&&M.shiftKey&&M.key.toLowerCase()==="f"&&(M.preventDefault(),D())};return window.addEventListener("keydown",U),()=>window.removeEventListener("keydown",U)},[r,E,D]);const Y=()=>{kA().auth.signOut(),u(!1),w(null),d(null),console.log("[Feedback] User logged out")};m.useEffect(()=>{if(!c)return;const U=M=>{const G=M.target;if(G.closest(".feedback-toggle")||G.closest(".feedback-modal")||G.closest(".feedback-marker")||G.closest(".feedback-user-modal")||G.closest(".feedback-overlay-backdrop"))return;M.preventDefault(),M.stopPropagation();const P=M.clientX,$=M.clientY,lA=window.scrollX,wA=window.scrollY,DA=P+lA,te=$+wA,OA=window.innerWidth,ne=window.innerHeight,se=ru(P,$),_t=se?jl(se):null,Pt=se?eu(se):null;(async()=>{const Ue=await ou(P,$),zA={x:P,y:$,pageX:DA,pageY:te,xNorm:P/OA,yNorm:$/ne,viewportW:OA,viewportH:ne,scrollX:lA,scrollY:wA,route:C.pathname+C.search,title:document.title,domHint:_t,selectorHint:Pt,screenshot:Ue};console.log("[Feedback] Click captured with screenshot:",zA.screenshot?"yes":"no"),w(zA),d(null)})()};return document.addEventListener("click",U,!0),()=>document.removeEventListener("click",U,!0)},[c,C]);const cA=m.useCallback(()=>{w(null),d(null)},[]),tA=m.useCallback(async U=>{if(!T()||!x)return;const M={...U,projectUuid:x.projectUuid,reviewerId:x.reviewerId},G=kA();try{const P=ra(M),{error:$}=await G.from(Xe).upsert(P);if($){console.error("[Feedback] Failed to save to Supabase:",$),alert("Failed to save feedback. Please try again.");return}localStorage.setItem("feedback_last_submission",Date.now().toString())}catch(P){console.error("[Feedback] Error saving item:",P);return}w(null),d(null),_()},[x,_,T]),nA=m.useCallback(async U=>{const M=kA();try{const{error:G}=await M.from(Xe).delete().eq("id",U);if(G){console.error("[Feedback] Failed to delete from Supabase:",G),alert("Failed to delete feedback.");return}}catch(G){console.error("[Feedback] Error deleting item:",G);return}w(null),d(null),_()},[_]),FA=U=>{const M=window.innerWidth,G=window.innerHeight,P=window.scrollX,$=window.scrollY,lA=U.pageX??U.xNorm*M+(U.scrollX??0),wA=U.pageY??U.yNorm*G+(U.scrollY??0),DA={x:lA-P,y:wA-$,pageX:lA,pageY:wA,xNorm:U.xNorm,yNorm:U.yNorm,viewportW:M,viewportH:G,scrollX:U.scrollX??0,scrollY:U.scrollY??0,route:U.route,title:U.title,domHint:U.domHint,selectorHint:U.selectorHint};w(DA),c?(d(U),F(null)):(F(U),d(null))},fA=m.useCallback(()=>{F(null),w(null)},[]);return r?f.jsxs(f.Fragment,{children:[e,!A&&f.jsx("div",{className:"feedback-warning-banner",style:{position:"fixed",bottom:16,left:16,right:16,padding:"8px 12px",background:"#fef3c7",border:"1px solid #f59e0b",borderRadius:6,fontSize:14,zIndex:9998},children:"Feedback: Project not configured. Add projectId to enable."}),E&&f.jsxs("div",{className:"feedback-toggle-container",children:[R&&f.jsx("span",{className:"feedback-user-badge",onClick:Y,title:"Click to logout",children:R}),f.jsx(LA.Link,{to:s,className:"feedback-view-all-link",title:"View all feedback for this project",children:"View all"}),f.jsxs("button",{className:`feedback-toggle ${c?"active":""}`,onClick:D,title:"Toggle feedback mode (Ctrl/Cmd + Shift + F)",children:["Feedback: ",c?"ON":"OFF"]})]}),E&&c&&AA.map(U=>{var OA,ne;const M=U.userName||"Anonymous",G=(Q==null?void 0:Q.id)===U.id||(S==null?void 0:S.id)===U.id,P=window.innerWidth,$=window.innerHeight,lA=U.pageX??U.xNorm*P+(U.scrollX??0),wA=U.pageY??U.yNorm*$+(U.scrollY??0),DA=lA-I.x,te=wA-I.y;return f.jsx("div",{className:`feedback-marker existing ${G?"active":""}`,style:{left:DA,top:te},onClick:()=>FA(U),title:`${M}: ${((OA=U.comment)==null?void 0:OA.slice(0,50))||""}${(((ne=U.comment)==null?void 0:ne.length)||0)>50?"...":""}`,children:f.jsx("span",{className:"feedback-marker-label",children:M.charAt(0).toUpperCase()})},U.id)}),E&&g&&!Q&&!S&&f.jsx("div",{className:"feedback-marker new",style:{left:g.x,top:g.y}}),E&&g&&R&&c&&!S&&f.jsx(nu,{clickData:g,userName:R,existingItem:Q||void 0,validation:n,onClose:cA,onSave:tA,onDelete:nA}),E&&S&&g&&f.jsx(cu,{item:S,clickData:g,onClose:fA}),E&&c&&!g&&f.jsx("div",{className:"feedback-overlay-hint",children:"Click anywhere to add feedback • Click markers to edit"})]}):f.jsx(f.Fragment,{children:e})}function uu(){const[e,A]=m.useState(""),[r,t]=m.useState(""),[n,s]=m.useState(null),[a,B]=m.useState(!1),i=LA.useNavigate(),{user:o}=Je();if(o)return i("/",{replace:!0}),null;const c=async u=>{u.preventDefault(),s(null),B(!0);try{const{error:g}=await kA().auth.signInWithPassword({email:e,password:r});if(g){s(g.message),B(!1);return}i("/",{replace:!0})}catch(g){s(g instanceof Error?g.message:"Login failed")}finally{B(!1)}};return f.jsx("div",{className:"feedback-overlay-backdrop",children:f.jsxs("div",{className:"feedback-user-modal",children:[f.jsx("h3",{children:"Feedback Login"}),f.jsx("p",{children:"Sign in with your reviewer credentials to use the feedback tool."}),f.jsxs("form",{onSubmit:c,children:[f.jsx("input",{type:"email",value:e,onChange:u=>{A(u.target.value),s(null)},placeholder:"Email",autoComplete:"email",required:!0,disabled:a}),f.jsx("input",{type:"password",value:r,onChange:u=>{t(u.target.value),s(null)},placeholder:"Password",autoComplete:"current-password",required:!0,disabled:a}),n&&f.jsx("div",{className:"feedback-modal-error",children:n}),f.jsxs("div",{className:"feedback-modal-actions",children:[f.jsx("button",{type:"button",className:"btn-secondary",onClick:()=>i(-1),disabled:a,children:"Cancel"}),f.jsx("button",{type:"submit",className:"btn-primary",disabled:a,children:a?"Signing in...":"Sign in"})]})]})]})})}function gu(){const e=LA.useNavigate(),{user:A,isAdmin:r,loading:t}=Je(),[n,s]=m.useState([]),[a,B]=m.useState([]),[i,o]=m.useState([]),[c,u]=m.useState(""),[g,w]=m.useState(""),[Q,d]=m.useState(""),[S,F]=m.useState(""),[p,b]=m.useState(""),[I,v]=m.useState(""),[C,R]=m.useState(""),[x,E]=m.useState(null),T=kA(),_=m.useCallback(async()=>{const{data:H}=await T.from("companies").select("id, name").order("name");s(H??[])},[T]),AA=m.useCallback(async()=>{const{data:H}=await T.from("projects").select("id, company_id, short_code, project_id, github_repo_url, companies(name)").order("short_code");B(H??[])},[T]),D=m.useCallback(async()=>{const{data:H}=await T.from("reviewers").select("id, user_id, project_id, projects(project_id, short_code)").order("project_id");o(H??[])},[T]);if(m.useEffect(()=>{_(),AA(),D()},[_,AA,D]),!t&&!A)return e("/feedback-login",{replace:!0}),null;if(!t&&A&&!r)return f.jsxs("div",{style:{padding:40,fontFamily:"sans-serif"},children:[f.jsx("h2",{children:"Access Denied"}),f.jsx("p",{children:"You must be an admin to access this page."}),f.jsx("button",{className:"btn-secondary",onClick:()=>e("/"),children:"Go back"})]});if(t)return f.jsx("div",{style:{padding:40},children:"Loading..."});const Y=async()=>{if(!c.trim())return;E(null);const{error:H}=await T.from("companies").insert({name:c.trim()});H?E(H.message):(u(""),_())},cA=async H=>{if(!confirm("Delete this company? Projects will be deleted too."))return;E(null);const{error:U}=await T.from("companies").delete().eq("id",H);U?E(U.message):_()},tA=async()=>{if(!g||!Q.trim())return;E(null);const H=`${Q.trim()}_${crypto.randomUUID()}`,{error:U}=await T.from("projects").insert({company_id:g,short_code:Q.trim(),project_id:H,github_repo_url:S.trim()||null});U?E(U.message):(d(""),F(""),AA())},nA=async H=>{if(!confirm("Delete this project?"))return;E(null);const{error:U}=await T.from("projects").delete().eq("id",H);U?E(U.message):AA()},FA=async()=>{if(!p.trim()||!I||!C)return;E(null);const{data:{session:H}}=await T.auth.getSession();if(!H){E("Not authenticated");return}try{const{data:U,error:M}=await T.auth.signUp({email:p.trim(),password:I,options:{emailRedirectTo:void 0}});if(M){E(M.message);return}if(!U.user){E("Failed to create user");return}const G=U.user.id;await T.auth.setSession({access_token:H.access_token,refresh_token:H.refresh_token});const{error:P}=await T.from("reviewers").insert({user_id:G,project_id:C});if(P){E(P.message);return}b(""),v(""),D()}catch(U){E(U instanceof Error?U.message:"Failed to create reviewer")}},fA=async H=>{if(!confirm("Remove this reviewer?"))return;E(null);const{error:U}=await T.from("reviewers").delete().eq("id",H);U?E(U.message):D()};return f.jsxs("div",{style:{padding:40,fontFamily:"sans-serif",maxWidth:800},children:[f.jsx("h1",{children:"Feedback Admin"}),f.jsx("button",{className:"btn-secondary",onClick:()=>e("/"),style:{marginBottom:24},children:"Back to app"}),x&&f.jsx("div",{className:"feedback-modal-error",style:{marginBottom:16},children:x}),f.jsxs("section",{style:{marginBottom:32},children:[f.jsx("h2",{children:"Companies"}),f.jsxs("div",{style:{display:"flex",gap:8,marginBottom:12},children:[f.jsx("input",{type:"text",value:c,onChange:H=>u(H.target.value),placeholder:"Company name",style:{padding:8,flex:1}}),f.jsx("button",{className:"btn-primary",onClick:Y,children:"Add"})]}),f.jsx("ul",{style:{listStyle:"none",padding:0},children:n.map(H=>f.jsxs("li",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:4},children:[f.jsx("span",{children:H.name}),f.jsx("button",{className:"btn-danger",onClick:()=>cA(H.id),style:{padding:"4px 8px",fontSize:12},children:"Delete"})]},H.id))})]}),f.jsxs("section",{style:{marginBottom:32},children:[f.jsx("h2",{children:"Projects"}),f.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:8,marginBottom:12},children:[f.jsxs("select",{value:g,onChange:H=>w(H.target.value),style:{padding:8},children:[f.jsx("option",{value:"",children:"Select company"}),n.map(H=>f.jsx("option",{value:H.id,children:H.name},H.id))]}),f.jsx("input",{type:"text",value:Q,onChange:H=>d(H.target.value),placeholder:"Short code (e.g. acme-dash)",style:{padding:8,width:180}}),f.jsx("input",{type:"text",value:S,onChange:H=>F(H.target.value),placeholder:"GitHub repo URL (optional)",style:{padding:8,flex:1,minWidth:200}}),f.jsx("button",{className:"btn-primary",onClick:tA,children:"Add"})]}),f.jsx("ul",{style:{listStyle:"none",padding:0},children:a.map(H=>{var U;return f.jsx("li",{style:{marginBottom:8},children:f.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,flexWrap:"wrap"},children:[f.jsxs("span",{children:[((U=Array.isArray(H.companies)?H.companies[0]:H.companies)==null?void 0:U.name)??"?"," / ",H.short_code]}),f.jsx("code",{style:{fontSize:12,background:"#f3f4f6",padding:"2px 6px"},children:H.project_id}),f.jsx("button",{className:"btn-danger",onClick:()=>nA(H.id),style:{padding:"4px 8px",fontSize:12},children:"Delete"})]})},H.id)})})]}),f.jsxs("section",{children:[f.jsx("h2",{children:"Reviewers"}),f.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:8,marginBottom:12},children:[f.jsx("input",{type:"email",value:p,onChange:H=>b(H.target.value),placeholder:"Email",style:{padding:8,width:180}}),f.jsx("input",{type:"password",value:I,onChange:H=>v(H.target.value),placeholder:"Password",style:{padding:8,width:140}}),f.jsxs("select",{value:C,onChange:H=>R(H.target.value),style:{padding:8,minWidth:200},children:[f.jsx("option",{value:"",children:"Select project"}),a.map(H=>{var U;return f.jsxs("option",{value:H.id,children:[(U=H.companies)==null?void 0:U.name," / ",H.short_code]},H.id)})]}),f.jsx("button",{className:"btn-primary",onClick:FA,children:"Add"})]}),f.jsx("ul",{style:{listStyle:"none",padding:0},children:i.map(H=>{var U;return f.jsxs("li",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:4},children:[f.jsxs("span",{children:[((U=Array.isArray(H.projects)?H.projects[0]:H.projects)==null?void 0:U.short_code)??"?"," – ",H.user_id.slice(0,8),"..."]}),f.jsx("button",{className:"btn-danger",onClick:()=>fA(H.id),style:{padding:"4px 8px",fontSize:12},children:"Remove"})]},H.id)})})]})]})}const na={Bug:"#ef4444",UX:"#3b82f6",Content:"#8b5cf6",Other:"#6b7280"};function fu({projectId:e}){const A=LA.useNavigate(),{user:r,hasAccessToProject:t,getReviewerProject:n,isAdmin:s,loading:a}=Je(),[B,i]=m.useState([]),[o,c]=m.useState(!0),[u,g]=m.useState(null),w=e?n(e):void 0,Q=(w==null?void 0:w.projectUuid)??u,d=!!(e&&r&&(t(e)||s)),S=m.useCallback(async()=>{if(!Q)return;const b=kA(),{data:I,error:v}=await b.from(Xe).select("*").eq("project_id",Q).order("created_at",{ascending:!1});v?(console.error("[Feedback] Failed to load review items:",v),i([])):i((I??[]).map(C=>kt(C))),c(!1)},[Q]);if(m.useEffect(()=>{s&&e&&!(w!=null&&w.projectUuid)&&kA().from("projects").select("id").eq("project_id",e).maybeSingle().then(({data:I})=>{I?g(I.id):c(!1)})},[s,e,w==null?void 0:w.projectUuid]),m.useEffect(()=>{if(Q){S();const b=setInterval(S,3e4);return()=>clearInterval(b)}else(!s||!e)&&c(!1)},[S,Q,s,e]),!a&&!r)return A("/feedback-login",{replace:!0}),null;if(!a&&r&&!d)return f.jsx("div",{className:"feedback-review-page",children:f.jsxs("div",{className:"feedback-review-container",children:[f.jsx("h2",{children:"Access Denied"}),f.jsx("p",{children:e?"You do not have access to view feedback for this project.":"Project not configured. Add projectId to the FeedbackReviewPage."}),f.jsx("button",{type:"button",className:"btn-secondary",onClick:()=>A("/"),children:"Go back"})]})});if(a||d&&!Q&&s||o)return f.jsx("div",{className:"feedback-review-page",children:f.jsx("div",{className:"feedback-review-container",children:f.jsx("p",{children:"Loading..."})})});const p=b=>(b.route.startsWith("http"),b.route);return f.jsx("div",{className:"feedback-review-page",children:f.jsxs("div",{className:"feedback-review-container",children:[f.jsxs("header",{className:"feedback-review-header",children:[f.jsx("h1",{children:"Feedback for this project"}),f.jsx("button",{type:"button",className:"btn-secondary",onClick:()=>A("/"),children:"Back to app"})]}),B.length===0?f.jsx("p",{className:"feedback-review-empty",children:"No feedback yet. Add feedback using the feedback tool in the app."}):f.jsx("div",{className:"feedback-review-grid",children:B.map(b=>f.jsxs("article",{className:"feedback-review-card",children:[f.jsxs("div",{className:"feedback-review-card-header",children:[f.jsx("span",{className:"feedback-review-avatar",title:b.userName,children:b.userName.charAt(0).toUpperCase()}),f.jsxs("div",{className:"feedback-review-card-meta",children:[f.jsx("strong",{children:b.userName}),f.jsx("span",{className:"feedback-review-date",children:new Date(b.createdAt).toLocaleString()})]}),f.jsx("span",{className:"feedback-review-category",style:{background:na[b.category]??na.Other},children:b.category})]}),b.screenshot&&f.jsx("div",{className:"feedback-review-screenshot",children:f.jsx("a",{href:b.screenshot,target:"_blank",rel:"noopener noreferrer",title:"Open full size",children:f.jsx("img",{src:b.screenshot,alt:"Screenshot of feedback location"})})}),f.jsx("div",{className:"feedback-review-comment",children:b.comment}),f.jsxs("div",{className:"feedback-review-footer",children:[f.jsx("a",{href:p(b),className:"feedback-review-link",title:`Go to: ${b.title??b.route}`,children:b.title||b.route||"View location"}),b.domHint&&f.jsxs("span",{className:"feedback-review-element",title:b.selectorHint??void 0,children:["Element: ",b.domHint]})]})]},b.id))})]})})}z.FeedbackAdminPage=gu,z.FeedbackAuthProvider=Bu,z.FeedbackLoginPage=uu,z.FeedbackProvider=lu,z.FeedbackReviewPage=fu,z.SUPABASE_TABLE=Xe,z.fromDbItem=kt,z.generateId=ea,z.toDbItem=ra,z.useFeedbackAuth=Je,Object.defineProperty(z,Symbol.toStringTag,{value:"Module"})});
51
+ .`+Dt+Bl+Ps)},cl=function(e,A){var r=e.ownerDocument;if(r){var t=r.createElement("style");t.textContent=A,e.appendChild(t)}},Xs=function(){function e(){}return e.getOrigin=function(A){var r=e._link;return r?(r.href=A,r.href=r.href,r.protocol+r.hostname+r.port):"about:blank"},e.isSameOrigin=function(A){return e.getOrigin(A)===e._origin},e.setContext=function(A){e._link=A.document.createElement("a"),e._origin=e.getOrigin(A.location.href)},e._origin="about:blank",e}(),ll=function(){function e(A,r){this.context=A,this._options=r,this._cache={}}return e.prototype.addImage=function(A){var r=Promise.resolve();return this.has(A)||(Rt(A)||wl(A))&&(this._cache[A]=this.loadImage(A)).catch(function(){}),r},e.prototype.match=function(A){return this._cache[A]},e.prototype.loadImage=function(A){return dA(this,void 0,void 0,function(){var r,t,n,s,a=this;return QA(this,function(B){switch(B.label){case 0:return r=Xs.isSameOrigin(A),t=!Ot(A)&&this._options.useCORS===!0&&gA.SUPPORT_CORS_IMAGES&&!r,n=!Ot(A)&&!r&&!Rt(A)&&typeof this._options.proxy=="string"&&gA.SUPPORT_CORS_XHR&&!t,!r&&this._options.allowTaint===!1&&!Ot(A)&&!Rt(A)&&!n&&!t?[2]:(s=A,n?[4,this.proxy(s)]:[3,2]);case 1:s=B.sent(),B.label=2;case 2:return this.context.logger.debug("Added image "+A.substring(0,256)),[4,new Promise(function(i,o){var c=new Image;c.onload=function(){return i(c)},c.onerror=o,(Ql(s)||t)&&(c.crossOrigin="anonymous"),c.src=s,c.complete===!0&&setTimeout(function(){return i(c)},500),a._options.imageTimeout>0&&setTimeout(function(){return o("Timed out ("+a._options.imageTimeout+"ms) loading image")},a._options.imageTimeout)})];case 3:return[2,B.sent()]}})})},e.prototype.has=function(A){return typeof this._cache[A]<"u"},e.prototype.keys=function(){return Promise.resolve(Object.keys(this._cache))},e.prototype.proxy=function(A){var r=this,t=this._options.proxy;if(!t)throw new Error("No proxy defined");var n=A.substring(0,256);return new Promise(function(s,a){var B=gA.SUPPORT_RESPONSE_TYPE?"blob":"text",i=new XMLHttpRequest;i.onload=function(){if(i.status===200)if(B==="text")s(i.response);else{var u=new FileReader;u.addEventListener("load",function(){return s(u.result)},!1),u.addEventListener("error",function(g){return a(g)},!1),u.readAsDataURL(i.response)}else a("Failed to proxy resource "+n+" with status code "+i.status)},i.onerror=a;var o=t.indexOf("?")>-1?"&":"?";if(i.open("GET",""+t+o+"url="+encodeURIComponent(A)+"&responseType="+B),B!=="text"&&i instanceof XMLHttpRequest&&(i.responseType=B),r._options.imageTimeout){var c=r._options.imageTimeout;i.timeout=c,i.ontimeout=function(){return a("Timed out ("+c+"ms) proxying "+n)}}i.send()})},e}(),ul=/^data:image\/svg\+xml/i,gl=/^data:image\/.*;base64,/i,fl=/^data:image\/.*/i,wl=function(e){return gA.SUPPORT_SVG_DRAWING||!Cl(e)},Ot=function(e){return fl.test(e)},Ql=function(e){return gl.test(e)},Rt=function(e){return e.substr(0,4)==="blob"},Cl=function(e){return e.substr(-3).toLowerCase()==="svg"||ul.test(e)},y=function(){function e(A,r){this.type=0,this.x=A,this.y=r}return e.prototype.add=function(A,r){return new e(this.x+A,this.y+r)},e}(),Qe=function(e,A,r){return new y(e.x+(A.x-e.x)*r,e.y+(A.y-e.y)*r)},Sr=function(){function e(A,r,t,n){this.type=1,this.start=A,this.startControl=r,this.endControl=t,this.end=n}return e.prototype.subdivide=function(A,r){var t=Qe(this.start,this.startControl,A),n=Qe(this.startControl,this.endControl,A),s=Qe(this.endControl,this.end,A),a=Qe(t,n,A),B=Qe(n,s,A),i=Qe(a,B,A);return r?new e(this.start,t,a,i):new e(i,B,s,this.end)},e.prototype.add=function(A,r){return new e(this.start.add(A,r),this.startControl.add(A,r),this.endControl.add(A,r),this.end.add(A,r))},e.prototype.reverse=function(){return new e(this.end,this.endControl,this.startControl,this.start)},e}(),IA=function(e){return e.type===1},dl=function(){function e(A){var r=A.styles,t=A.bounds,n=Re(r.borderTopLeftRadius,t.width,t.height),s=n[0],a=n[1],B=Re(r.borderTopRightRadius,t.width,t.height),i=B[0],o=B[1],c=Re(r.borderBottomRightRadius,t.width,t.height),u=c[0],g=c[1],w=Re(r.borderBottomLeftRadius,t.width,t.height),Q=w[0],d=w[1],S=[];S.push((s+i)/t.width),S.push((Q+u)/t.width),S.push((a+d)/t.height),S.push((o+g)/t.height);var F=Math.max.apply(Math,S);F>1&&(s/=F,a/=F,i/=F,o/=F,u/=F,g/=F,Q/=F,d/=F);var p=t.width-i,b=t.height-g,I=t.width-u,v=t.height-d,C=r.borderTopWidth,R=r.borderRightWidth,x=r.borderBottomWidth,E=r.borderLeftWidth,T=Z(r.paddingTop,A.bounds.width),_=Z(r.paddingRight,A.bounds.width),AA=Z(r.paddingBottom,A.bounds.width),D=Z(r.paddingLeft,A.bounds.width);this.topLeftBorderDoubleOuterBox=s>0||a>0?q(t.left+E/3,t.top+C/3,s-E/3,a-C/3,X.TOP_LEFT):new y(t.left+E/3,t.top+C/3),this.topRightBorderDoubleOuterBox=s>0||a>0?q(t.left+p,t.top+C/3,i-R/3,o-C/3,X.TOP_RIGHT):new y(t.left+t.width-R/3,t.top+C/3),this.bottomRightBorderDoubleOuterBox=u>0||g>0?q(t.left+I,t.top+b,u-R/3,g-x/3,X.BOTTOM_RIGHT):new y(t.left+t.width-R/3,t.top+t.height-x/3),this.bottomLeftBorderDoubleOuterBox=Q>0||d>0?q(t.left+E/3,t.top+v,Q-E/3,d-x/3,X.BOTTOM_LEFT):new y(t.left+E/3,t.top+t.height-x/3),this.topLeftBorderDoubleInnerBox=s>0||a>0?q(t.left+E*2/3,t.top+C*2/3,s-E*2/3,a-C*2/3,X.TOP_LEFT):new y(t.left+E*2/3,t.top+C*2/3),this.topRightBorderDoubleInnerBox=s>0||a>0?q(t.left+p,t.top+C*2/3,i-R*2/3,o-C*2/3,X.TOP_RIGHT):new y(t.left+t.width-R*2/3,t.top+C*2/3),this.bottomRightBorderDoubleInnerBox=u>0||g>0?q(t.left+I,t.top+b,u-R*2/3,g-x*2/3,X.BOTTOM_RIGHT):new y(t.left+t.width-R*2/3,t.top+t.height-x*2/3),this.bottomLeftBorderDoubleInnerBox=Q>0||d>0?q(t.left+E*2/3,t.top+v,Q-E*2/3,d-x*2/3,X.BOTTOM_LEFT):new y(t.left+E*2/3,t.top+t.height-x*2/3),this.topLeftBorderStroke=s>0||a>0?q(t.left+E/2,t.top+C/2,s-E/2,a-C/2,X.TOP_LEFT):new y(t.left+E/2,t.top+C/2),this.topRightBorderStroke=s>0||a>0?q(t.left+p,t.top+C/2,i-R/2,o-C/2,X.TOP_RIGHT):new y(t.left+t.width-R/2,t.top+C/2),this.bottomRightBorderStroke=u>0||g>0?q(t.left+I,t.top+b,u-R/2,g-x/2,X.BOTTOM_RIGHT):new y(t.left+t.width-R/2,t.top+t.height-x/2),this.bottomLeftBorderStroke=Q>0||d>0?q(t.left+E/2,t.top+v,Q-E/2,d-x/2,X.BOTTOM_LEFT):new y(t.left+E/2,t.top+t.height-x/2),this.topLeftBorderBox=s>0||a>0?q(t.left,t.top,s,a,X.TOP_LEFT):new y(t.left,t.top),this.topRightBorderBox=i>0||o>0?q(t.left+p,t.top,i,o,X.TOP_RIGHT):new y(t.left+t.width,t.top),this.bottomRightBorderBox=u>0||g>0?q(t.left+I,t.top+b,u,g,X.BOTTOM_RIGHT):new y(t.left+t.width,t.top+t.height),this.bottomLeftBorderBox=Q>0||d>0?q(t.left,t.top+v,Q,d,X.BOTTOM_LEFT):new y(t.left,t.top+t.height),this.topLeftPaddingBox=s>0||a>0?q(t.left+E,t.top+C,Math.max(0,s-E),Math.max(0,a-C),X.TOP_LEFT):new y(t.left+E,t.top+C),this.topRightPaddingBox=i>0||o>0?q(t.left+Math.min(p,t.width-R),t.top+C,p>t.width+R?0:Math.max(0,i-R),Math.max(0,o-C),X.TOP_RIGHT):new y(t.left+t.width-R,t.top+C),this.bottomRightPaddingBox=u>0||g>0?q(t.left+Math.min(I,t.width-E),t.top+Math.min(b,t.height-x),Math.max(0,u-R),Math.max(0,g-x),X.BOTTOM_RIGHT):new y(t.left+t.width-R,t.top+t.height-x),this.bottomLeftPaddingBox=Q>0||d>0?q(t.left+E,t.top+Math.min(v,t.height-x),Math.max(0,Q-E),Math.max(0,d-x),X.BOTTOM_LEFT):new y(t.left+E,t.top+t.height-x),this.topLeftContentBox=s>0||a>0?q(t.left+E+D,t.top+C+T,Math.max(0,s-(E+D)),Math.max(0,a-(C+T)),X.TOP_LEFT):new y(t.left+E+D,t.top+C+T),this.topRightContentBox=i>0||o>0?q(t.left+Math.min(p,t.width+E+D),t.top+C+T,p>t.width+E+D?0:i-E+D,o-(C+T),X.TOP_RIGHT):new y(t.left+t.width-(R+_),t.top+C+T),this.bottomRightContentBox=u>0||g>0?q(t.left+Math.min(I,t.width-(E+D)),t.top+Math.min(b,t.height+C+T),Math.max(0,u-(R+_)),g-(x+AA),X.BOTTOM_RIGHT):new y(t.left+t.width-(R+_),t.top+t.height-(x+AA)),this.bottomLeftContentBox=Q>0||d>0?q(t.left+E+D,t.top+v,Math.max(0,Q-(E+D)),d-(x+AA),X.BOTTOM_LEFT):new y(t.left+E+D,t.top+t.height-(x+AA))}return e}(),X;(function(e){e[e.TOP_LEFT=0]="TOP_LEFT",e[e.TOP_RIGHT=1]="TOP_RIGHT",e[e.BOTTOM_RIGHT=2]="BOTTOM_RIGHT",e[e.BOTTOM_LEFT=3]="BOTTOM_LEFT"})(X||(X={}));var q=function(e,A,r,t,n){var s=4*((Math.sqrt(2)-1)/3),a=r*s,B=t*s,i=e+r,o=A+t;switch(n){case X.TOP_LEFT:return new Sr(new y(e,o),new y(e,o-B),new y(i-a,A),new y(i,A));case X.TOP_RIGHT:return new Sr(new y(e,A),new y(e+a,A),new y(i,o-B),new y(i,o));case X.BOTTOM_RIGHT:return new Sr(new y(i,A),new y(i,A+B),new y(e+a,o),new y(e,o));case X.BOTTOM_LEFT:default:return new Sr(new y(i,o),new y(i-a,o),new y(e,A+B),new y(e,A))}},Tr=function(e){return[e.topLeftBorderBox,e.topRightBorderBox,e.bottomRightBorderBox,e.bottomLeftBorderBox]},Ul=function(e){return[e.topLeftContentBox,e.topRightContentBox,e.bottomRightContentBox,e.bottomLeftContentBox]},Dr=function(e){return[e.topLeftPaddingBox,e.topRightPaddingBox,e.bottomRightPaddingBox,e.bottomLeftPaddingBox]},hl=function(){function e(A,r,t){this.offsetX=A,this.offsetY=r,this.matrix=t,this.type=0,this.target=6}return e}(),Or=function(){function e(A,r){this.path=A,this.target=r,this.type=1}return e}(),Fl=function(){function e(A){this.opacity=A,this.type=2,this.target=6}return e}(),pl=function(e){return e.type===0},Js=function(e){return e.type===1},El=function(e){return e.type===2},Ys=function(e,A){return e.length===A.length?e.some(function(r,t){return r===A[t]}):!1},vl=function(e,A,r,t,n){return e.map(function(s,a){switch(a){case 0:return s.add(A,r);case 1:return s.add(A+t,r);case 2:return s.add(A+t,r+n);case 3:return s.add(A,r+n)}return s})},Ws=function(){function e(A){this.element=A,this.inlineLevel=[],this.nonInlineLevel=[],this.negativeZIndex=[],this.zeroOrAutoZIndexOrTransformedOrOpacity=[],this.positiveZIndex=[],this.nonPositionedFloats=[],this.nonPositionedInlineLevel=[]}return e}(),js=function(){function e(A,r){if(this.container=A,this.parent=r,this.effects=[],this.curves=new dl(this.container),this.container.styles.opacity<1&&this.effects.push(new Fl(this.container.styles.opacity)),this.container.styles.transform!==null){var t=this.container.bounds.left+this.container.styles.transformOrigin[0].number,n=this.container.bounds.top+this.container.styles.transformOrigin[1].number,s=this.container.styles.transform;this.effects.push(new hl(t,n,s))}if(this.container.styles.overflowX!==0){var a=Tr(this.curves),B=Dr(this.curves);Ys(a,B)?this.effects.push(new Or(a,6)):(this.effects.push(new Or(a,2)),this.effects.push(new Or(B,4)))}}return e.prototype.getEffects=function(A){for(var r=[2,3].indexOf(this.container.styles.position)===-1,t=this.parent,n=this.effects.slice(0);t;){var s=t.effects.filter(function(i){return!Js(i)});if(r||t.container.styles.position!==0||!t.parent){if(n.unshift.apply(n,s),r=[2,3].indexOf(t.container.styles.position)===-1,t.container.styles.overflowX!==0){var a=Tr(t.curves),B=Dr(t.curves);Ys(a,B)||n.unshift(new Or(B,6))}}else n.unshift.apply(n,s);t=t.parent}return n.filter(function(i){return BA(i.target,A)})},e}(),Mt=function(e,A,r,t){e.container.elements.forEach(function(n){var s=BA(n.flags,4),a=BA(n.flags,2),B=new js(n,e);BA(n.styles.display,2048)&&t.push(B);var i=BA(n.flags,8)?[]:t;if(s||a){var o=s||n.styles.isPositioned()?r:A,c=new Ws(B);if(n.styles.isPositioned()||n.styles.opacity<1||n.styles.isTransformed()){var u=n.styles.zIndex.order;if(u<0){var g=0;o.negativeZIndex.some(function(Q,d){return u>Q.element.container.styles.zIndex.order?(g=d,!1):g>0}),o.negativeZIndex.splice(g,0,c)}else if(u>0){var w=0;o.positiveZIndex.some(function(Q,d){return u>=Q.element.container.styles.zIndex.order?(w=d+1,!1):w>0}),o.positiveZIndex.splice(w,0,c)}else o.zeroOrAutoZIndexOrTransformedOrOpacity.push(c)}else n.styles.isFloating()?o.nonPositionedFloats.push(c):o.nonPositionedInlineLevel.push(c);Mt(B,c,s?c:r,i)}else n.styles.isInlineLevel()?A.inlineLevel.push(B):A.nonInlineLevel.push(B),Mt(B,A,r,i);BA(n.flags,8)&&Zs(n,i)})},Zs=function(e,A){for(var r=e instanceof mt?e.start:1,t=e instanceof mt?e.reversed:!1,n=0;n<A.length;n++){var s=A[n];s.container instanceof Fs&&typeof s.container.value=="number"&&s.container.value!==0&&(r=s.container.value),s.listValue=_e(r,s.container.styles.listStyleType,!0),r+=t?-1:1}},Hl=function(e){var A=new js(e,null),r=new Ws(A),t=[];return Mt(A,r,r,t),Zs(A.container,t),r},zs=function(e,A){switch(A){case 0:return mA(e.topLeftBorderBox,e.topLeftPaddingBox,e.topRightBorderBox,e.topRightPaddingBox);case 1:return mA(e.topRightBorderBox,e.topRightPaddingBox,e.bottomRightBorderBox,e.bottomRightPaddingBox);case 2:return mA(e.bottomRightBorderBox,e.bottomRightPaddingBox,e.bottomLeftBorderBox,e.bottomLeftPaddingBox);case 3:default:return mA(e.bottomLeftBorderBox,e.bottomLeftPaddingBox,e.topLeftBorderBox,e.topLeftPaddingBox)}},Il=function(e,A){switch(A){case 0:return mA(e.topLeftBorderBox,e.topLeftBorderDoubleOuterBox,e.topRightBorderBox,e.topRightBorderDoubleOuterBox);case 1:return mA(e.topRightBorderBox,e.topRightBorderDoubleOuterBox,e.bottomRightBorderBox,e.bottomRightBorderDoubleOuterBox);case 2:return mA(e.bottomRightBorderBox,e.bottomRightBorderDoubleOuterBox,e.bottomLeftBorderBox,e.bottomLeftBorderDoubleOuterBox);case 3:default:return mA(e.bottomLeftBorderBox,e.bottomLeftBorderDoubleOuterBox,e.topLeftBorderBox,e.topLeftBorderDoubleOuterBox)}},ml=function(e,A){switch(A){case 0:return mA(e.topLeftBorderDoubleInnerBox,e.topLeftPaddingBox,e.topRightBorderDoubleInnerBox,e.topRightPaddingBox);case 1:return mA(e.topRightBorderDoubleInnerBox,e.topRightPaddingBox,e.bottomRightBorderDoubleInnerBox,e.bottomRightPaddingBox);case 2:return mA(e.bottomRightBorderDoubleInnerBox,e.bottomRightPaddingBox,e.bottomLeftBorderDoubleInnerBox,e.bottomLeftPaddingBox);case 3:default:return mA(e.bottomLeftBorderDoubleInnerBox,e.bottomLeftPaddingBox,e.topLeftBorderDoubleInnerBox,e.topLeftPaddingBox)}},yl=function(e,A){switch(A){case 0:return Rr(e.topLeftBorderStroke,e.topRightBorderStroke);case 1:return Rr(e.topRightBorderStroke,e.bottomRightBorderStroke);case 2:return Rr(e.bottomRightBorderStroke,e.bottomLeftBorderStroke);case 3:default:return Rr(e.bottomLeftBorderStroke,e.topLeftBorderStroke)}},Rr=function(e,A){var r=[];return IA(e)?r.push(e.subdivide(.5,!1)):r.push(e),IA(A)?r.push(A.subdivide(.5,!0)):r.push(A),r},mA=function(e,A,r,t){var n=[];return IA(e)?n.push(e.subdivide(.5,!1)):n.push(e),IA(r)?n.push(r.subdivide(.5,!0)):n.push(r),IA(t)?n.push(t.subdivide(.5,!0).reverse()):n.push(t),IA(A)?n.push(A.subdivide(.5,!1).reverse()):n.push(A),n},qs=function(e){var A=e.bounds,r=e.styles;return A.add(r.borderLeftWidth,r.borderTopWidth,-(r.borderRightWidth+r.borderLeftWidth),-(r.borderTopWidth+r.borderBottomWidth))},Mr=function(e){var A=e.styles,r=e.bounds,t=Z(A.paddingLeft,r.width),n=Z(A.paddingRight,r.width),s=Z(A.paddingTop,r.width),a=Z(A.paddingBottom,r.width);return r.add(t+A.borderLeftWidth,s+A.borderTopWidth,-(A.borderRightWidth+A.borderLeftWidth+t+n),-(A.borderTopWidth+A.borderBottomWidth+s+a))},bl=function(e,A){return e===0?A.bounds:e===2?Mr(A):qs(A)},Kl=function(e,A){return e===0?A.bounds:e===2?Mr(A):qs(A)},Nt=function(e,A,r){var t=bl(de(e.styles.backgroundOrigin,A),e),n=Kl(de(e.styles.backgroundClip,A),e),s=Ll(de(e.styles.backgroundSize,A),r,t),a=s[0],B=s[1],i=Re(de(e.styles.backgroundPosition,A),t.width-a,t.height-B),o=xl(de(e.styles.backgroundRepeat,A),i,s,t,n),c=Math.round(t.left+i[0]),u=Math.round(t.top+i[1]);return[o,c,u,a,B]},Ce=function(e){return W(e)&&e.value===ue.AUTO},Nr=function(e){return typeof e=="number"},Ll=function(e,A,r){var t=A[0],n=A[1],s=A[2],a=e[0],B=e[1];if(!a)return[0,0];if(aA(a)&&B&&aA(B))return[Z(a,r.width),Z(B,r.height)];var i=Nr(s);if(W(a)&&(a.value===ue.CONTAIN||a.value===ue.COVER)){if(Nr(s)){var o=r.width/r.height;return o<s!=(a.value===ue.COVER)?[r.width,r.width/s]:[r.height*s,r.height]}return[r.width,r.height]}var c=Nr(t),u=Nr(n),g=c||u;if(Ce(a)&&(!B||Ce(B))){if(c&&u)return[t,n];if(!i&&!g)return[r.width,r.height];if(g&&i){var w=c?t:n*s,Q=u?n:t/s;return[w,Q]}var d=c?t:r.width,S=u?n:r.height;return[d,S]}if(i){var F=0,p=0;return aA(a)?F=Z(a,r.width):aA(B)&&(p=Z(B,r.height)),Ce(a)?F=p*s:(!B||Ce(B))&&(p=F/s),[F,p]}var b=null,I=null;if(aA(a)?b=Z(a,r.width):B&&aA(B)&&(I=Z(B,r.height)),b!==null&&(!B||Ce(B))&&(I=c&&u?b/t*n:r.height),I!==null&&Ce(a)&&(b=c&&u?I/n*t:r.width),b!==null&&I!==null)return[b,I];throw new Error("Unable to calculate background-size for element")},de=function(e,A){var r=e[A];return typeof r>"u"?e[0]:r},xl=function(e,A,r,t,n){var s=A[0],a=A[1],B=r[0],i=r[1];switch(e){case 2:return[new y(Math.round(t.left),Math.round(t.top+a)),new y(Math.round(t.left+t.width),Math.round(t.top+a)),new y(Math.round(t.left+t.width),Math.round(i+t.top+a)),new y(Math.round(t.left),Math.round(i+t.top+a))];case 3:return[new y(Math.round(t.left+s),Math.round(t.top)),new y(Math.round(t.left+s+B),Math.round(t.top)),new y(Math.round(t.left+s+B),Math.round(t.height+t.top)),new y(Math.round(t.left+s),Math.round(t.height+t.top))];case 1:return[new y(Math.round(t.left+s),Math.round(t.top+a)),new y(Math.round(t.left+s+B),Math.round(t.top+a)),new y(Math.round(t.left+s+B),Math.round(t.top+a+i)),new y(Math.round(t.left+s),Math.round(t.top+a+i))];default:return[new y(Math.round(n.left),Math.round(n.top)),new y(Math.round(n.left+n.width),Math.round(n.top)),new y(Math.round(n.left+n.width),Math.round(n.height+n.top)),new y(Math.round(n.left),Math.round(n.height+n.top))]}},Sl="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7",$s="Hidden Text",Tl=function(){function e(A){this._data={},this._document=A}return e.prototype.parseMetrics=function(A,r){var t=this._document.createElement("div"),n=this._document.createElement("img"),s=this._document.createElement("span"),a=this._document.body;t.style.visibility="hidden",t.style.fontFamily=A,t.style.fontSize=r,t.style.margin="0",t.style.padding="0",t.style.whiteSpace="nowrap",a.appendChild(t),n.src=Sl,n.width=1,n.height=1,n.style.margin="0",n.style.padding="0",n.style.verticalAlign="baseline",s.style.fontFamily=A,s.style.fontSize=r,s.style.margin="0",s.style.padding="0",s.appendChild(this._document.createTextNode($s)),t.appendChild(s),t.appendChild(n);var B=n.offsetTop-s.offsetTop+2;t.removeChild(s),t.appendChild(this._document.createTextNode($s)),t.style.lineHeight="normal",n.style.verticalAlign="super";var i=n.offsetTop-t.offsetTop+2;return a.removeChild(t),{baseline:B,middle:i}},e.prototype.getMetrics=function(A,r){var t=A+" "+r;return typeof this._data[t]>"u"&&(this._data[t]=this.parseMetrics(A,r)),this._data[t]},e}(),Aa=function(){function e(A,r){this.context=A,this.options=r}return e}(),Dl=1e4,Ol=function(e){bA(A,e);function A(r,t){var n=e.call(this,r,t)||this;return n._activeEffects=[],n.canvas=t.canvas?t.canvas:document.createElement("canvas"),n.ctx=n.canvas.getContext("2d"),t.canvas||(n.canvas.width=Math.floor(t.width*t.scale),n.canvas.height=Math.floor(t.height*t.scale),n.canvas.style.width=t.width+"px",n.canvas.style.height=t.height+"px"),n.fontMetrics=new Tl(document),n.ctx.scale(n.options.scale,n.options.scale),n.ctx.translate(-t.x,-t.y),n.ctx.textBaseline="bottom",n._activeEffects=[],n.context.logger.debug("Canvas renderer initialized ("+t.width+"x"+t.height+") with scale "+t.scale),n}return A.prototype.applyEffects=function(r){for(var t=this;this._activeEffects.length;)this.popEffect();r.forEach(function(n){return t.applyEffect(n)})},A.prototype.applyEffect=function(r){this.ctx.save(),El(r)&&(this.ctx.globalAlpha=r.opacity),pl(r)&&(this.ctx.translate(r.offsetX,r.offsetY),this.ctx.transform(r.matrix[0],r.matrix[1],r.matrix[2],r.matrix[3],r.matrix[4],r.matrix[5]),this.ctx.translate(-r.offsetX,-r.offsetY)),Js(r)&&(this.path(r.path),this.ctx.clip()),this._activeEffects.push(r)},A.prototype.popEffect=function(){this._activeEffects.pop(),this.ctx.restore()},A.prototype.renderStack=function(r){return dA(this,void 0,void 0,function(){var t;return QA(this,function(n){switch(n.label){case 0:return t=r.element.container.styles,t.isVisible()?[4,this.renderStackContent(r)]:[3,2];case 1:n.sent(),n.label=2;case 2:return[2]}})})},A.prototype.renderNode=function(r){return dA(this,void 0,void 0,function(){return QA(this,function(t){switch(t.label){case 0:if(BA(r.container.flags,16))debugger;return r.container.styles.isVisible()?[4,this.renderNodeBackgroundAndBorders(r)]:[3,3];case 1:return t.sent(),[4,this.renderNodeContent(r)];case 2:t.sent(),t.label=3;case 3:return[2]}})})},A.prototype.renderTextWithLetterSpacing=function(r,t,n){var s=this;if(t===0)this.ctx.fillText(r.text,r.bounds.left,r.bounds.top+n);else{var a=It(r.text);a.reduce(function(B,i){return s.ctx.fillText(i,B,r.bounds.top+n),B+s.ctx.measureText(i).width},r.bounds.left)}},A.prototype.createFontStyle=function(r){var t=r.fontVariant.filter(function(a){return a==="normal"||a==="small-caps"}).join(""),n=kl(r.fontFamily).join(", "),s=Oe(r.fontSize)?""+r.fontSize.number+r.fontSize.unit:r.fontSize.number+"px";return[[r.fontStyle,t,r.fontWeight,s,n].join(" "),n,s]},A.prototype.renderTextNode=function(r,t){return dA(this,void 0,void 0,function(){var n,s,a,B,i,o,c,u,g=this;return QA(this,function(w){return n=this.createFontStyle(t),s=n[0],a=n[1],B=n[2],this.ctx.font=s,this.ctx.direction=t.direction===1?"rtl":"ltr",this.ctx.textAlign="left",this.ctx.textBaseline="alphabetic",i=this.fontMetrics.getMetrics(a,B),o=i.baseline,c=i.middle,u=t.paintOrder,r.textBounds.forEach(function(Q){u.forEach(function(d){switch(d){case 0:g.ctx.fillStyle=oA(t.color),g.renderTextWithLetterSpacing(Q,t.letterSpacing,o);var S=t.textShadow;S.length&&Q.text.trim().length&&(S.slice(0).reverse().forEach(function(F){g.ctx.shadowColor=oA(F.color),g.ctx.shadowOffsetX=F.offsetX.number*g.options.scale,g.ctx.shadowOffsetY=F.offsetY.number*g.options.scale,g.ctx.shadowBlur=F.blur.number,g.renderTextWithLetterSpacing(Q,t.letterSpacing,o)}),g.ctx.shadowColor="",g.ctx.shadowOffsetX=0,g.ctx.shadowOffsetY=0,g.ctx.shadowBlur=0),t.textDecorationLine.length&&(g.ctx.fillStyle=oA(t.textDecorationColor||t.color),t.textDecorationLine.forEach(function(F){switch(F){case 1:g.ctx.fillRect(Q.bounds.left,Math.round(Q.bounds.top+o),Q.bounds.width,1);break;case 2:g.ctx.fillRect(Q.bounds.left,Math.round(Q.bounds.top),Q.bounds.width,1);break;case 3:g.ctx.fillRect(Q.bounds.left,Math.ceil(Q.bounds.top+c),Q.bounds.width,1);break}}));break;case 1:t.webkitTextStrokeWidth&&Q.text.trim().length&&(g.ctx.strokeStyle=oA(t.webkitTextStrokeColor),g.ctx.lineWidth=t.webkitTextStrokeWidth,g.ctx.lineJoin=window.chrome?"miter":"round",g.ctx.strokeText(Q.text,Q.bounds.left,Q.bounds.top+o)),g.ctx.strokeStyle="",g.ctx.lineWidth=0,g.ctx.lineJoin="miter";break}})}),[2]})})},A.prototype.renderReplacedElement=function(r,t,n){if(n&&r.intrinsicWidth>0&&r.intrinsicHeight>0){var s=Mr(r),a=Dr(t);this.path(a),this.ctx.save(),this.ctx.clip(),this.ctx.drawImage(n,0,0,r.intrinsicWidth,r.intrinsicHeight,s.left,s.top,s.width,s.height),this.ctx.restore()}},A.prototype.renderNodeContent=function(r){return dA(this,void 0,void 0,function(){var t,n,s,a,B,i,p,p,o,c,u,g,I,w,Q,v,d,S,F,p,b,I,v;return QA(this,function(C){switch(C.label){case 0:this.applyEffects(r.getEffects(4)),t=r.container,n=r.curves,s=t.styles,a=0,B=t.textNodes,C.label=1;case 1:return a<B.length?(i=B[a],[4,this.renderTextNode(i,s)]):[3,4];case 2:C.sent(),C.label=3;case 3:return a++,[3,1];case 4:if(!(t instanceof ds))return[3,8];C.label=5;case 5:return C.trys.push([5,7,,8]),[4,this.context.cache.match(t.src)];case 6:return p=C.sent(),this.renderReplacedElement(t,n,p),[3,8];case 7:return C.sent(),this.context.logger.error("Error loading image "+t.src),[3,8];case 8:if(t instanceof Us&&this.renderReplacedElement(t,n,t.canvas),!(t instanceof hs))return[3,12];C.label=9;case 9:return C.trys.push([9,11,,12]),[4,this.context.cache.match(t.svg)];case 10:return p=C.sent(),this.renderReplacedElement(t,n,p),[3,12];case 11:return C.sent(),this.context.logger.error("Error loading svg "+t.svg.substring(0,255)),[3,12];case 12:return t instanceof Hs&&t.tree?(o=new A(this.context,{scale:this.options.scale,backgroundColor:t.backgroundColor,x:0,y:0,width:t.width,height:t.height}),[4,o.render(t.tree)]):[3,14];case 13:c=C.sent(),t.width&&t.height&&this.ctx.drawImage(c,0,0,t.width,t.height,t.bounds.left,t.bounds.top,t.bounds.width,t.bounds.height),C.label=14;case 14:if(t instanceof yt&&(u=Math.min(t.bounds.width,t.bounds.height),t.type===mr?t.checked&&(this.ctx.save(),this.path([new y(t.bounds.left+u*.39363,t.bounds.top+u*.79),new y(t.bounds.left+u*.16,t.bounds.top+u*.5549),new y(t.bounds.left+u*.27347,t.bounds.top+u*.44071),new y(t.bounds.left+u*.39694,t.bounds.top+u*.5649),new y(t.bounds.left+u*.72983,t.bounds.top+u*.23),new y(t.bounds.left+u*.84,t.bounds.top+u*.34085),new y(t.bounds.left+u*.39363,t.bounds.top+u*.79)]),this.ctx.fillStyle=oA(ps),this.ctx.fill(),this.ctx.restore()):t.type===yr&&t.checked&&(this.ctx.save(),this.ctx.beginPath(),this.ctx.arc(t.bounds.left+u/2,t.bounds.top+u/2,u/4,0,Math.PI*2,!0),this.ctx.fillStyle=oA(ps),this.ctx.fill(),this.ctx.restore())),Rl(t)&&t.value.length){switch(g=this.createFontStyle(s),I=g[0],w=g[1],Q=this.fontMetrics.getMetrics(I,w).baseline,this.ctx.font=I,this.ctx.fillStyle=oA(s.color),this.ctx.textBaseline="alphabetic",this.ctx.textAlign=Nl(t.styles.textAlign),v=Mr(t),d=0,t.styles.textAlign){case 1:d+=v.width/2;break;case 2:d+=v.width;break}S=v.add(d,0,0,-v.height/2+1),this.ctx.save(),this.path([new y(v.left,v.top),new y(v.left+v.width,v.top),new y(v.left+v.width,v.top+v.height),new y(v.left,v.top+v.height)]),this.ctx.clip(),this.renderTextWithLetterSpacing(new ke(t.value,S),s.letterSpacing,Q),this.ctx.restore(),this.ctx.textBaseline="alphabetic",this.ctx.textAlign="left"}if(!BA(t.styles.display,2048))return[3,20];if(t.styles.listStyleImage===null)return[3,19];if(F=t.styles.listStyleImage,F.type!==0)return[3,18];p=void 0,b=F.url,C.label=15;case 15:return C.trys.push([15,17,,18]),[4,this.context.cache.match(b)];case 16:return p=C.sent(),this.ctx.drawImage(p,t.bounds.left-(p.width+10),t.bounds.top),[3,18];case 17:return C.sent(),this.context.logger.error("Error loading list-style-image "+b),[3,18];case 18:return[3,20];case 19:r.listValue&&t.styles.listStyleType!==-1&&(I=this.createFontStyle(s)[0],this.ctx.font=I,this.ctx.fillStyle=oA(s.color),this.ctx.textBaseline="middle",this.ctx.textAlign="right",v=new RA(t.bounds.left,t.bounds.top+Z(t.styles.paddingTop,t.bounds.width),t.bounds.width,$n(s.lineHeight,s.fontSize.number)/2+1),this.renderTextWithLetterSpacing(new ke(r.listValue,v),s.letterSpacing,$n(s.lineHeight,s.fontSize.number)/2+2),this.ctx.textBaseline="bottom",this.ctx.textAlign="left"),C.label=20;case 20:return[2]}})})},A.prototype.renderStackContent=function(r){return dA(this,void 0,void 0,function(){var t,n,F,s,a,F,B,i,F,o,c,F,u,g,F,w,Q,F,d,S,F;return QA(this,function(p){switch(p.label){case 0:if(BA(r.element.container.flags,16))debugger;return[4,this.renderNodeBackgroundAndBorders(r.element)];case 1:p.sent(),t=0,n=r.negativeZIndex,p.label=2;case 2:return t<n.length?(F=n[t],[4,this.renderStack(F)]):[3,5];case 3:p.sent(),p.label=4;case 4:return t++,[3,2];case 5:return[4,this.renderNodeContent(r.element)];case 6:p.sent(),s=0,a=r.nonInlineLevel,p.label=7;case 7:return s<a.length?(F=a[s],[4,this.renderNode(F)]):[3,10];case 8:p.sent(),p.label=9;case 9:return s++,[3,7];case 10:B=0,i=r.nonPositionedFloats,p.label=11;case 11:return B<i.length?(F=i[B],[4,this.renderStack(F)]):[3,14];case 12:p.sent(),p.label=13;case 13:return B++,[3,11];case 14:o=0,c=r.nonPositionedInlineLevel,p.label=15;case 15:return o<c.length?(F=c[o],[4,this.renderStack(F)]):[3,18];case 16:p.sent(),p.label=17;case 17:return o++,[3,15];case 18:u=0,g=r.inlineLevel,p.label=19;case 19:return u<g.length?(F=g[u],[4,this.renderNode(F)]):[3,22];case 20:p.sent(),p.label=21;case 21:return u++,[3,19];case 22:w=0,Q=r.zeroOrAutoZIndexOrTransformedOrOpacity,p.label=23;case 23:return w<Q.length?(F=Q[w],[4,this.renderStack(F)]):[3,26];case 24:p.sent(),p.label=25;case 25:return w++,[3,23];case 26:d=0,S=r.positiveZIndex,p.label=27;case 27:return d<S.length?(F=S[d],[4,this.renderStack(F)]):[3,30];case 28:p.sent(),p.label=29;case 29:return d++,[3,27];case 30:return[2]}})})},A.prototype.mask=function(r){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(r.slice(0).reverse()),this.ctx.closePath()},A.prototype.path=function(r){this.ctx.beginPath(),this.formatPath(r),this.ctx.closePath()},A.prototype.formatPath=function(r){var t=this;r.forEach(function(n,s){var a=IA(n)?n.start:n;s===0?t.ctx.moveTo(a.x,a.y):t.ctx.lineTo(a.x,a.y),IA(n)&&t.ctx.bezierCurveTo(n.startControl.x,n.startControl.y,n.endControl.x,n.endControl.y,n.end.x,n.end.y)})},A.prototype.renderRepeat=function(r,t,n,s){this.path(r),this.ctx.fillStyle=t,this.ctx.translate(n,s),this.ctx.fill(),this.ctx.translate(-n,-s)},A.prototype.resizeImage=function(r,t,n){var s;if(r.width===t&&r.height===n)return r;var a=(s=this.canvas.ownerDocument)!==null&&s!==void 0?s:document,B=a.createElement("canvas");B.width=Math.max(1,t),B.height=Math.max(1,n);var i=B.getContext("2d");return i.drawImage(r,0,0,r.width,r.height,0,0,t,n),B},A.prototype.renderBackgroundImage=function(r){return dA(this,void 0,void 0,function(){var t,n,s,a,B,i;return QA(this,function(o){switch(o.label){case 0:t=r.styles.backgroundImage.length-1,n=function(c){var u,g,w,T,tA,nA,D,Y,x,Q,T,tA,nA,D,Y,d,S,F,p,b,I,v,C,R,x,E,T,_,AA,D,Y,cA,tA,nA,FA,fA,H,U,M,G,P,$;return QA(this,function(lA){switch(lA.label){case 0:if(c.type!==0)return[3,5];u=void 0,g=c.url,lA.label=1;case 1:return lA.trys.push([1,3,,4]),[4,s.context.cache.match(g)];case 2:return u=lA.sent(),[3,4];case 3:return lA.sent(),s.context.logger.error("Error loading background-image "+g),[3,4];case 4:return u&&(w=Nt(r,t,[u.width,u.height,u.width/u.height]),T=w[0],tA=w[1],nA=w[2],D=w[3],Y=w[4],x=s.ctx.createPattern(s.resizeImage(u,D,Y),"repeat"),s.renderRepeat(T,x,tA,nA)),[3,6];case 5:FB(c)?(Q=Nt(r,t,[null,null,null]),T=Q[0],tA=Q[1],nA=Q[2],D=Q[3],Y=Q[4],d=QB(c.angle,D,Y),S=d[0],F=d[1],p=d[2],b=d[3],I=d[4],v=document.createElement("canvas"),v.width=D,v.height=Y,C=v.getContext("2d"),R=C.createLinearGradient(F,b,p,I),Vn(c.stops,S).forEach(function(wA){return R.addColorStop(wA.stop,oA(wA.color))}),C.fillStyle=R,C.fillRect(0,0,D,Y),D>0&&Y>0&&(x=s.ctx.createPattern(v,"repeat"),s.renderRepeat(T,x,tA,nA))):pB(c)&&(E=Nt(r,t,[null,null,null]),T=E[0],_=E[1],AA=E[2],D=E[3],Y=E[4],cA=c.position.length===0?[lt]:c.position,tA=Z(cA[0],D),nA=Z(cA[cA.length-1],Y),FA=CB(c,tA,nA,D,Y),fA=FA[0],H=FA[1],fA>0&&H>0&&(U=s.ctx.createRadialGradient(_+tA,AA+nA,0,_+tA,AA+nA,fA),Vn(c.stops,fA*2).forEach(function(wA){return U.addColorStop(wA.stop,oA(wA.color))}),s.path(T),s.ctx.fillStyle=U,fA!==H?(M=r.bounds.left+.5*r.bounds.width,G=r.bounds.top+.5*r.bounds.height,P=H/fA,$=1/P,s.ctx.save(),s.ctx.translate(M,G),s.ctx.transform(1,0,0,P,0,0),s.ctx.translate(-M,-G),s.ctx.fillRect(_,$*(AA-G)+G,D,Y*$),s.ctx.restore()):s.ctx.fill())),lA.label=6;case 6:return t--,[2]}})},s=this,a=0,B=r.styles.backgroundImage.slice(0).reverse(),o.label=1;case 1:return a<B.length?(i=B[a],[5,n(i)]):[3,4];case 2:o.sent(),o.label=3;case 3:return a++,[3,1];case 4:return[2]}})})},A.prototype.renderSolidBorder=function(r,t,n){return dA(this,void 0,void 0,function(){return QA(this,function(s){return this.path(zs(n,t)),this.ctx.fillStyle=oA(r),this.ctx.fill(),[2]})})},A.prototype.renderDoubleBorder=function(r,t,n,s){return dA(this,void 0,void 0,function(){var a,B;return QA(this,function(i){switch(i.label){case 0:return t<3?[4,this.renderSolidBorder(r,n,s)]:[3,2];case 1:return i.sent(),[2];case 2:return a=Il(s,n),this.path(a),this.ctx.fillStyle=oA(r),this.ctx.fill(),B=ml(s,n),this.path(B),this.ctx.fill(),[2]}})})},A.prototype.renderNodeBackgroundAndBorders=function(r){return dA(this,void 0,void 0,function(){var t,n,s,a,B,i,o,c,u=this;return QA(this,function(g){switch(g.label){case 0:return this.applyEffects(r.getEffects(2)),t=r.container.styles,n=!YA(t.backgroundColor)||t.backgroundImage.length,s=[{style:t.borderTopStyle,color:t.borderTopColor,width:t.borderTopWidth},{style:t.borderRightStyle,color:t.borderRightColor,width:t.borderRightWidth},{style:t.borderBottomStyle,color:t.borderBottomColor,width:t.borderBottomWidth},{style:t.borderLeftStyle,color:t.borderLeftColor,width:t.borderLeftWidth}],a=Ml(de(t.backgroundClip,0),r.curves),n||t.boxShadow.length?(this.ctx.save(),this.path(a),this.ctx.clip(),YA(t.backgroundColor)||(this.ctx.fillStyle=oA(t.backgroundColor),this.ctx.fill()),[4,this.renderBackgroundImage(r.container)]):[3,2];case 1:g.sent(),this.ctx.restore(),t.boxShadow.slice(0).reverse().forEach(function(w){u.ctx.save();var Q=Tr(r.curves),d=w.inset?0:Dl,S=vl(Q,-d+(w.inset?1:-1)*w.spread.number,(w.inset?1:-1)*w.spread.number,w.spread.number*(w.inset?-2:2),w.spread.number*(w.inset?-2:2));w.inset?(u.path(Q),u.ctx.clip(),u.mask(S)):(u.mask(Q),u.ctx.clip(),u.path(S)),u.ctx.shadowOffsetX=w.offsetX.number+d,u.ctx.shadowOffsetY=w.offsetY.number,u.ctx.shadowColor=oA(w.color),u.ctx.shadowBlur=w.blur.number,u.ctx.fillStyle=w.inset?oA(w.color):"rgba(0,0,0,1)",u.ctx.fill(),u.ctx.restore()}),g.label=2;case 2:B=0,i=0,o=s,g.label=3;case 3:return i<o.length?(c=o[i],c.style!==0&&!YA(c.color)&&c.width>0?c.style!==2?[3,5]:[4,this.renderDashedDottedBorder(c.color,c.width,B,r.curves,2)]:[3,11]):[3,13];case 4:return g.sent(),[3,11];case 5:return c.style!==3?[3,7]:[4,this.renderDashedDottedBorder(c.color,c.width,B,r.curves,3)];case 6:return g.sent(),[3,11];case 7:return c.style!==4?[3,9]:[4,this.renderDoubleBorder(c.color,c.width,B,r.curves)];case 8:return g.sent(),[3,11];case 9:return[4,this.renderSolidBorder(c.color,B,r.curves)];case 10:g.sent(),g.label=11;case 11:B++,g.label=12;case 12:return i++,[3,3];case 13:return[2]}})})},A.prototype.renderDashedDottedBorder=function(r,t,n,s,a){return dA(this,void 0,void 0,function(){var B,i,o,c,u,g,w,Q,d,S,F,p,b,I,v,C,v,C;return QA(this,function(R){return this.ctx.save(),B=yl(s,n),i=zs(s,n),a===2&&(this.path(i),this.ctx.clip()),IA(i[0])?(o=i[0].start.x,c=i[0].start.y):(o=i[0].x,c=i[0].y),IA(i[1])?(u=i[1].end.x,g=i[1].end.y):(u=i[1].x,g=i[1].y),n===0||n===2?w=Math.abs(o-u):w=Math.abs(c-g),this.ctx.beginPath(),a===3?this.formatPath(B):this.formatPath(i.slice(0,2)),Q=t<3?t*3:t*2,d=t<3?t*2:t,a===3&&(Q=t,d=t),S=!0,w<=Q*2?S=!1:w<=Q*2+d?(F=w/(2*Q+d),Q*=F,d*=F):(p=Math.floor((w+d)/(Q+d)),b=(w-p*Q)/(p-1),I=(w-(p+1)*Q)/p,d=I<=0||Math.abs(d-b)<Math.abs(d-I)?b:I),S&&(a===3?this.ctx.setLineDash([0,Q+d]):this.ctx.setLineDash([Q,d])),a===3?(this.ctx.lineCap="round",this.ctx.lineWidth=t):this.ctx.lineWidth=t*2+1.1,this.ctx.strokeStyle=oA(r),this.ctx.stroke(),this.ctx.setLineDash([]),a===2&&(IA(i[0])&&(v=i[3],C=i[0],this.ctx.beginPath(),this.formatPath([new y(v.end.x,v.end.y),new y(C.start.x,C.start.y)]),this.ctx.stroke()),IA(i[1])&&(v=i[1],C=i[2],this.ctx.beginPath(),this.formatPath([new y(v.end.x,v.end.y),new y(C.start.x,C.start.y)]),this.ctx.stroke())),this.ctx.restore(),[2]})})},A.prototype.render=function(r){return dA(this,void 0,void 0,function(){var t;return QA(this,function(n){switch(n.label){case 0:return this.options.backgroundColor&&(this.ctx.fillStyle=oA(this.options.backgroundColor),this.ctx.fillRect(this.options.x,this.options.y,this.options.width,this.options.height)),t=Hl(r),[4,this.renderStack(t)];case 1:return n.sent(),this.applyEffects([]),[2,this.canvas]}})})},A}(Aa),Rl=function(e){return e instanceof vs||e instanceof Es?!0:e instanceof yt&&e.type!==yr&&e.type!==mr},Ml=function(e,A){switch(e){case 0:return Tr(A);case 2:return Ul(A);case 1:default:return Dr(A)}},Nl=function(e){switch(e){case 1:return"center";case 2:return"right";case 0:default:return"left"}},Gl=["-apple-system","system-ui"],kl=function(e){return/iPhone OS 15_(0|1)/.test(window.navigator.userAgent)?e.filter(function(A){return Gl.indexOf(A)===-1}):e},Vl=function(e){bA(A,e);function A(r,t){var n=e.call(this,r,t)||this;return n.canvas=t.canvas?t.canvas:document.createElement("canvas"),n.ctx=n.canvas.getContext("2d"),n.options=t,n.canvas.width=Math.floor(t.width*t.scale),n.canvas.height=Math.floor(t.height*t.scale),n.canvas.style.width=t.width+"px",n.canvas.style.height=t.height+"px",n.ctx.scale(n.options.scale,n.options.scale),n.ctx.translate(-t.x,-t.y),n.context.logger.debug("EXPERIMENTAL ForeignObject renderer initialized ("+t.width+"x"+t.height+" at "+t.x+","+t.y+") with scale "+t.scale),n}return A.prototype.render=function(r){return dA(this,void 0,void 0,function(){var t,n;return QA(this,function(s){switch(s.label){case 0:return t=Ht(this.options.width*this.options.scale,this.options.height*this.options.scale,this.options.scale,this.options.scale,r),[4,_l(t)];case 1:return n=s.sent(),this.options.backgroundColor&&(this.ctx.fillStyle=oA(this.options.backgroundColor),this.ctx.fillRect(0,0,this.options.width*this.options.scale,this.options.height*this.options.scale)),this.ctx.drawImage(n,-this.options.x*this.options.scale,-this.options.y*this.options.scale),[2,this.canvas]}})})},A}(Aa),_l=function(e){return new Promise(function(A,r){var t=new Image;t.onload=function(){A(t)},t.onerror=r,t.src="data:image/svg+xml;charset=utf-8,"+encodeURIComponent(new XMLSerializer().serializeToString(e))})},Pl=function(){function e(A){var r=A.id,t=A.enabled;this.id=r,this.enabled=t,this.start=Date.now()}return e.prototype.debug=function(){for(var A=[],r=0;r<arguments.length;r++)A[r]=arguments[r];this.enabled&&(typeof window<"u"&&window.console&&typeof console.debug=="function"?console.debug.apply(console,Ye([this.id,this.getTime()+"ms"],A)):this.info.apply(this,A))},e.prototype.getTime=function(){return Date.now()-this.start},e.prototype.info=function(){for(var A=[],r=0;r<arguments.length;r++)A[r]=arguments[r];this.enabled&&typeof window<"u"&&window.console&&typeof console.info=="function"&&console.info.apply(console,Ye([this.id,this.getTime()+"ms"],A))},e.prototype.warn=function(){for(var A=[],r=0;r<arguments.length;r++)A[r]=arguments[r];this.enabled&&(typeof window<"u"&&window.console&&typeof console.warn=="function"?console.warn.apply(console,Ye([this.id,this.getTime()+"ms"],A)):this.info.apply(this,A))},e.prototype.error=function(){for(var A=[],r=0;r<arguments.length;r++)A[r]=arguments[r];this.enabled&&(typeof window<"u"&&window.console&&typeof console.error=="function"?console.error.apply(console,Ye([this.id,this.getTime()+"ms"],A)):this.info.apply(this,A))},e.instances={},e}(),Xl=function(){function e(A,r){var t;this.windowBounds=r,this.instanceName="#"+e.instanceCount++,this.logger=new Pl({id:this.instanceName,enabled:A.logging}),this.cache=(t=A.cache)!==null&&t!==void 0?t:new ll(this,A)}return e.instanceCount=1,e}(),Jl=function(e,A){return A===void 0&&(A={}),Yl(e,A)};typeof window<"u"&&Xs.setContext(window);var Yl=function(e,A){return dA(void 0,void 0,void 0,function(){var r,t,n,s,a,B,i,o,c,u,g,w,Q,d,S,F,p,b,I,v,R,C,R,x,E,T,_,AA,D,Y,cA,tA,nA,FA,fA,H,U,M,G,P;return QA(this,function($){switch($.label){case 0:if(!e||typeof e!="object")return[2,Promise.reject("Invalid element provided as first argument")];if(r=e.ownerDocument,!r)throw new Error("Element is not attached to a Document");if(t=r.defaultView,!t)throw new Error("Document is not attached to a Window");return n={allowTaint:(x=A.allowTaint)!==null&&x!==void 0?x:!1,imageTimeout:(E=A.imageTimeout)!==null&&E!==void 0?E:15e3,proxy:A.proxy,useCORS:(T=A.useCORS)!==null&&T!==void 0?T:!1},s=Pr({logging:(_=A.logging)!==null&&_!==void 0?_:!0,cache:A.cache},n),a={windowWidth:(AA=A.windowWidth)!==null&&AA!==void 0?AA:t.innerWidth,windowHeight:(D=A.windowHeight)!==null&&D!==void 0?D:t.innerHeight,scrollX:(Y=A.scrollX)!==null&&Y!==void 0?Y:t.pageXOffset,scrollY:(cA=A.scrollY)!==null&&cA!==void 0?cA:t.pageYOffset},B=new RA(a.scrollX,a.scrollY,a.windowWidth,a.windowHeight),i=new Xl(s,B),o=(tA=A.foreignObjectRendering)!==null&&tA!==void 0?tA:!1,c={allowTaint:(nA=A.allowTaint)!==null&&nA!==void 0?nA:!1,onclone:A.onclone,ignoreElements:A.ignoreElements,inlineImages:o,copyStyles:o},i.logger.debug("Starting document clone with size "+B.width+"x"+B.height+" scrolled to "+-B.left+","+-B.top),u=new _s(i,e,c),g=u.clonedReferenceElement,g?[4,u.toIFrame(r,B)]:[2,Promise.reject("Unable to find element in cloned iframe")];case 1:return w=$.sent(),Q=Kt(g)||Wc(g)?Ea(g.ownerDocument):We(i,g),d=Q.width,S=Q.height,F=Q.left,p=Q.top,b=Wl(i,g,A.backgroundColor),I={canvas:A.canvas,backgroundColor:b,scale:(fA=(FA=A.scale)!==null&&FA!==void 0?FA:t.devicePixelRatio)!==null&&fA!==void 0?fA:1,x:((H=A.x)!==null&&H!==void 0?H:0)+F,y:((U=A.y)!==null&&U!==void 0?U:0)+p,width:(M=A.width)!==null&&M!==void 0?M:Math.ceil(d),height:(G=A.height)!==null&&G!==void 0?G:Math.ceil(S)},o?(i.logger.debug("Document cloned, using foreign object rendering"),R=new Vl(i,I),[4,R.render(g)]):[3,3];case 2:return v=$.sent(),[3,5];case 3:return i.logger.debug("Document cloned, element located at "+F+","+p+" with size "+d+"x"+S+" using computed rendering"),i.logger.debug("Starting DOM parsing"),C=ms(i,g),b===C.styles.backgroundColor&&(C.styles.backgroundColor=NA.TRANSPARENT),i.logger.debug("Starting renderer for element at "+I.x+","+I.y+" with size "+I.width+"x"+I.height),R=new Ol(i,I),[4,R.render(C)];case 4:v=$.sent(),$.label=5;case 5:return(!((P=A.removeContainer)!==null&&P!==void 0)||P)&&(_s.destroy(w)||i.logger.error("Cannot detach cloned iframe as it is not in the DOM anymore")),i.logger.debug("Finished rendering"),[2,v]}})})},Wl=function(e,A,r){var t=A.ownerDocument,n=t.documentElement?Me(e,getComputedStyle(t.documentElement).backgroundColor):NA.TRANSPARENT,s=t.body?Me(e,getComputedStyle(t.body).backgroundColor):NA.TRANSPARENT,a=typeof r=="string"?Me(e,r):r===null?NA.TRANSPARENT:4294967295;return A===t.documentElement?YA(n)?YA(s)?a:s:n:a};function jl(e){const A=[],r=Zl(e);r&&A.push(r);const t=ql(e);t&&A.push(`in ${t}`);const n=Au(e);return n&&A.push(n),A.length>0?A.join(" "):null}function Zl(e){const A=[],r=e.getAttribute("data-feedback-id");if(r)return`[data-feedback-id="${r}"]`;const t=e.tagName.toLowerCase();if(A.push(t),e.id)return A.push(`#${e.id}`),A.join("");const n=e.getAttribute("data-testid");if(n)return A.push(`[data-testid="${n}"]`),A.join("");const s=e.getAttribute("aria-label");if(s)return A.push(`[aria-label="${Gr(s,30)}"]`),A.join("");const a=Array.from(e.classList).filter(i=>!Gt(i)).slice(0,2);a.length>0&&A.push(a.map(i=>`.${i}`).join(""));const B=zl(e);return B&&A.push(`"${B}"`),A.join("")}function zl(e){var r,t;if(["BUTTON","A","H1","H2","H3","H4","H5","H6","LABEL","TH","TD"].includes(e.tagName)){let n="";for(const s of e.childNodes)s.nodeType===Node.TEXT_NODE&&(n+=((r=s.textContent)==null?void 0:r.trim())||"");return n||(n=((t=e.textContent)==null?void 0:t.trim())||""),Gr(n,25)}return null}function ql(e){let A=e.parentElement;const r=[];let t=0;const n=5;for(;A&&A!==document.body&&t<n;){const s=A.getAttribute("data-feedback-id");if(s){r.unshift(`[data-feedback-id="${s}"]`);break}if(A.id){r.unshift(`#${A.id}`);break}const a=A.tagName.toLowerCase();if(["section","article","nav","header","footer","main","aside","form","table","ul","ol"].includes(a)){const o=Array.from(A.classList).filter(u=>!Gt(u)).slice(0,1),c=o.length>0?`.${o[0]}`:"";r.unshift(`${a}${c}`)}const i=Array.from(A.classList).find(o=>/card|panel|modal|section|container|wrapper|item|row/i.test(o));if(i){const o=$l(A);if(o){r.unshift(`.${i} "${o}"`);break}else r.unshift(`.${i}`)}A=A.parentElement,t++}return r.length>0?r.join(" > "):null}function $l(e){var n,s;const A=e.querySelector("h1, h2, h3, h4, h5, h6");if(A){const a=(n=A.textContent)==null?void 0:n.trim();if(a)return Gr(a,20)}const r=e.querySelector('[class*="title"], [class*="header"], [class*="name"]');if(r){const a=(s=r.textContent)==null?void 0:s.trim();if(a)return Gr(a,20)}const t=e.querySelector("[data-feedback-id]");return t?t.getAttribute("data-feedback-id"):null}function Au(e){const A=e.parentElement;if(!A)return null;const r=Array.from(A.children).filter(t=>t.tagName===e.tagName);return r.length>1?`(${r.indexOf(e)+1} of ${r.length})`:null}function Gt(e){return[/^(p|m|w|h|min|max|flex|grid|gap|space|text|font|bg|border|rounded|shadow|opacity|z|top|right|bottom|left|inset)-/,/^(sm|md|lg|xl|2xl):/,/^(hover|focus|active|disabled):/,/^(col|row)-span/,/^(justify|items|content|self)-/,/^(overflow|whitespace|break)-/].some(r=>r.test(e))}function Gr(e,A){return e.length<=A?e:e.slice(0,A).trim()+"..."}function eu(e){const A=[];let r=e,t=0;const n=5;for(;r&&r!==document.body&&t<n;){let s=r.tagName.toLowerCase();const a=r.getAttribute("data-feedback-id");if(a){s=`[data-feedback-id="${a}"]`,A.unshift(s);break}if(r.id){s+=`#${r.id}`,A.unshift(s);break}const B=r.getAttribute("data-testid");if(B){s+=`[data-testid="${B}"]`,A.unshift(s);break}const i=Array.from(r.classList).filter(c=>!Gt(c))[0];i&&(s+=`.${i}`);const o=r.parentElement;if(o){const c=r.tagName,u=[];for(let g=0;g<o.children.length;g++){const w=o.children[g];w.tagName===c&&u.push(w)}if(u.length>1){const g=u.indexOf(r)+1;s+=`:nth-of-type(${g})`}}A.unshift(s),r=o,t++}return A.length>0?A.join(" > "):null}function ru(e,A){return document.elementFromPoint(e,A)}function ea(){return`${Date.now()}-${Math.random().toString(36).substr(2,9)}`}const tu=["Bug","UX","Content","Other"];function nu({clickData:e,userName:A,existingItem:r,validation:t,onClose:n,onSave:s,onDelete:a}){const[B,i]=m.useState((r==null?void 0:r.comment)||""),[o,c]=m.useState((r==null?void 0:r.category)||"Bug"),[u,g]=m.useState(null),w=!!r,Q=()=>{if(!B.trim()){g("Comment is required");return}if(t!=null&&t.maxCommentLength&&B.length>t.maxCommentLength){g(`Comment must be under ${t.maxCommentLength} characters`);return}if(t!=null&&t.maxScreenshotSize&&e.screenshot&&e.screenshot.length*3/4>t.maxScreenshotSize){g(`Screenshot is too large (max ${Math.round(t.maxScreenshotSize/1024)}KB)`);return}if(w&&r){const F={...r,updatedAt:new Date().toISOString(),category:o,comment:B.trim()};s(F)}else{const F={id:ea(),createdAt:new Date().toISOString(),userName:A,route:e.route,title:e.title,x:e.x,y:e.y,pageX:e.pageX,pageY:e.pageY,xNorm:e.xNorm,yNorm:e.yNorm,viewportW:e.viewportW,viewportH:e.viewportH,scrollX:e.scrollX,scrollY:e.scrollY,domHint:e.domHint,selectorHint:e.selectorHint,category:o,comment:B.trim(),screenshot:e.screenshot};s(F)}},d=()=>{r&&window.confirm("Delete this feedback?")&&(a==null||a(r.id))},S={position:"fixed",left:Math.min(e.x+20,window.innerWidth-340),top:Math.min(e.y+20,window.innerHeight-450),zIndex:10001};return f.jsxs("div",{className:"feedback-modal",style:S,children:[f.jsxs("div",{className:"feedback-modal-header",children:[f.jsx("h3",{children:w?"Edit Feedback":"Add Feedback"}),f.jsx("button",{className:"feedback-modal-close",onClick:n,children:"×"})]}),f.jsxs("div",{className:"feedback-modal-info",children:[f.jsxs("div",{children:[f.jsx("strong",{children:"Route:"})," ",e.route]}),f.jsxs("div",{children:[f.jsx("strong",{children:"Position:"})," (",Math.round(e.x),", ",Math.round(e.y),")"]}),f.jsxs("div",{children:[f.jsx("strong",{children:"Element:"})," ",e.domHint||"Unknown"]}),w&&r&&f.jsxs("div",{children:[f.jsx("strong",{children:"Created by:"})," ",r.userName||"Anonymous"]}),!w&&f.jsxs("div",{children:[f.jsx("strong",{children:"By:"})," ",A]})]}),f.jsxs("div",{className:"feedback-modal-field",children:[f.jsx("label",{htmlFor:"feedback-category",children:"Category"}),f.jsx("select",{id:"feedback-category",value:o,onChange:F=>c(F.target.value),children:tu.map(F=>f.jsx("option",{value:F,children:F},F))})]}),f.jsxs("div",{className:"feedback-modal-field",children:[f.jsx("label",{htmlFor:"feedback-comment",children:"Comment *"}),f.jsx("textarea",{id:"feedback-comment",value:B,onChange:F=>{i(F.target.value),g(null)},placeholder:"Describe the issue or suggestion...",rows:4}),u&&f.jsx("div",{className:"feedback-modal-error",children:u})]}),f.jsxs("div",{className:"feedback-modal-actions",children:[w&&f.jsx("button",{className:"btn-danger",onClick:d,children:"Delete"}),f.jsx("div",{style:{flex:1}}),f.jsx("button",{className:"btn-secondary",onClick:n,children:"Cancel"}),f.jsx("button",{className:"btn-primary",onClick:Q,children:w?"Update":"Save"})]})]})}function ra(e){return{id:e.id,created_at:e.createdAt,updated_at:e.updatedAt,user_name:e.userName,route:e.route,title:e.title,x:e.x,y:e.y,page_x:e.pageX,page_y:e.pageY,x_norm:e.xNorm,y_norm:e.yNorm,viewport_w:e.viewportW,viewport_h:e.viewportH,scroll_x:e.scrollX,scroll_y:e.scrollY,dom_hint:e.domHint,selector_hint:e.selectorHint,category:e.category,comment:e.comment,screenshot:e.screenshot,project_id:e.projectUuid,reviewer_id:e.reviewerId}}function kt(e){return{id:e.id,createdAt:e.created_at,updatedAt:e.updated_at,userName:e.user_name,route:e.route,title:e.title,x:e.x,y:e.y,pageX:e.page_x,pageY:e.page_y,xNorm:e.x_norm,yNorm:e.y_norm,viewportW:e.viewport_w,viewportH:e.viewport_h,scrollX:e.scroll_x,scrollY:e.scroll_y,domHint:e.dom_hint,selectorHint:e.selector_hint,category:e.category,comment:e.comment,screenshot:e.screenshot,projectId:e.project_id,reviewerId:e.reviewer_id}}const Xe="feedback_items",su="https://ubrdhrngfvwlkuhdireh.supabase.co",au="sb_publishable_e81HvMlbF_TXeB5NUSao6w_9_ZK5EIl";class iu{constructor(A){Ua(this,"prefix");this.prefix=A}getItem(A){try{return sessionStorage.getItem(`${this.prefix}-${A}`)}catch{return null}}setItem(A,r){try{sessionStorage.setItem(`${this.prefix}-${A}`,r)}catch(t){console.error("[Feedback] Failed to set storage item:",t)}}removeItem(A){try{sessionStorage.removeItem(`${this.prefix}-${A}`)}catch{}}}let Vt=null;function kA(){if(!Vt){const e=new iu("feedback-supabase");Vt=ha.createClient(su,au,{auth:{storage:e,storageKey:"auth-token",autoRefreshToken:!0,persistSession:!0}})}return Vt}const ta=m.createContext(null);function Bu({children:e}){const[A,r]=m.useState(null),[t,n]=m.useState(null),[s,a]=m.useState(!1),[B,i]=m.useState(!1),[o,c]=m.useState([]),[u,g]=m.useState(!0);m.useEffect(()=>{console.log("[Feedback] FeedbackAuthProvider initialized - v2.0.3")},[]);const w=kA(),Q=m.useCallback(async I=>{try{const{data:v,error:C}=await w.from("admins").select("id").eq("user_id",I).maybeSingle();return C?(console.error("[Feedback] Error fetching admin status:",C),!1):!!v}catch(v){return console.error("[Feedback] Exception fetching admin status:",v),!1}},[w]),d=m.useCallback(async I=>{try{const{data:v,error:C}=await w.from("reviewers").select("id, project_id, projects(project_id)").eq("user_id",I);return C?(console.error("[Feedback] Error fetching reviewer projects:",C),[]):v?(v??[]).map(x=>{const E=Array.isArray(x.projects)?x.projects[0]:x.projects;return E!=null&&E.project_id?{projectId:E.project_id,projectUuid:x.project_id,reviewerId:x.id}:null}).filter(x=>x!==null):[]}catch(v){return console.error("[Feedback] Exception fetching reviewer projects:",v),[]}},[w]),S=m.useCallback(async I=>{try{if(!I){n(null),a(!1),i(!1),c([]),g(!1);return}const[v,C]=await Promise.all([Q(I.id),d(I.id)]);n(I),i(v),a(C.length>0),c(C),g(!1)}catch(v){console.error("[Feedback] Error loading auth state:",v),g(!1)}},[Q,d]);m.useEffect(()=>{let I=!0,v=null;const C=setTimeout(()=>{I&&(console.warn("[Feedback] Auth initialization timeout - setting loading to false"),g(!1))},1e4);(async()=>{if(v){await v;return}return v=(async()=>{try{await new Promise(_=>setTimeout(_,100));const{data:{session:E},error:T}=await w.auth.getSession();if(!I)return;if(T){console.error("[Feedback] Error getting session:",T),g(!1),clearTimeout(C);return}r(E),await S((E==null?void 0:E.user)??null),clearTimeout(C)}catch(E){console.error("[Feedback] Error initializing session:",E),I&&g(!1),clearTimeout(C)}finally{v=null}})(),v})();const{data:{subscription:x}}=w.auth.onAuthStateChange(async(E,T)=>{try{if(!I)return;r(T),await S((T==null?void 0:T.user)??null)}catch(_){console.error("[Feedback] Error handling auth state change:",_),I&&g(!1)}});return()=>{I=!1,clearTimeout(C),x.unsubscribe()}},[w.auth,S]);const F=m.useCallback(I=>o.some(v=>v.projectId===I),[o]),p=m.useCallback(I=>o.find(v=>v.projectId===I),[o]),b={session:A,user:t,isReviewer:s,isAdmin:B,reviewerProjects:o,loading:u,hasAccessToProject:F,getReviewerProject:p};return f.jsx(ta.Provider,{value:b,children:e})}function Je(){const e=m.useContext(ta);if(!e)throw new Error("useFeedbackAuth must be used within FeedbackAuthProvider");return e}async function ou(e,A){try{const r=document.querySelectorAll(".feedback-toggle-container, .feedback-marker, .feedback-modal, .feedback-overlay-hint");r.forEach(Q=>{Q.style.visibility="hidden"});const t=.5,n=await Jl(document.body,{logging:!1,useCORS:!0,scale:t,windowWidth:window.innerWidth,windowHeight:window.innerHeight});r.forEach(Q=>{Q.style.visibility="visible"});const s=document.createElement("canvas"),a=window.innerWidth*t,B=window.innerHeight*t;s.width=a,s.height=B;const i=s.getContext("2d");if(!i)return;const o=window.scrollX*t,c=window.scrollY*t;i.drawImage(n,o,c,a,B,0,0,a,B);const u=e*t,g=A*t,w=20;return i.beginPath(),i.arc(u,g,w+4,0,Math.PI*2),i.strokeStyle="white",i.lineWidth=4,i.stroke(),i.beginPath(),i.arc(u,g,w,0,Math.PI*2),i.strokeStyle="#ef4444",i.lineWidth=4,i.stroke(),i.beginPath(),i.arc(u,g,6,0,Math.PI*2),i.fillStyle="#ef4444",i.fill(),i.beginPath(),i.moveTo(u-w-10,g),i.lineTo(u-w+5,g),i.moveTo(u+w-5,g),i.lineTo(u+w+10,g),i.moveTo(u,g-w-10),i.lineTo(u,g-w+5),i.moveTo(u,g+w-5),i.lineTo(u,g+w+10),i.strokeStyle="#ef4444",i.lineWidth=3,i.stroke(),s.toDataURL("image/jpeg",.6)}catch(r){console.error("[Feedback] Screenshot capture failed:",r);return}}function cu({item:e,clickData:A,onClose:r}){const t=e.userName||"Anonymous",n={position:"fixed",left:Math.min(A.x+20,window.innerWidth-340),top:Math.min(A.y+20,window.innerHeight-350),zIndex:10001};return f.jsxs("div",{className:"feedback-modal",style:n,children:[f.jsxs("div",{className:"feedback-modal-header",children:[f.jsx("h3",{children:"Feedback"}),f.jsx("button",{className:"feedback-modal-close",onClick:r,children:"×"})]}),f.jsxs("div",{className:"feedback-modal-info",children:[f.jsxs("div",{children:[f.jsx("strong",{children:"By:"})," ",t]}),f.jsxs("div",{children:[f.jsx("strong",{children:"Date:"})," ",new Date(e.createdAt).toLocaleString()]}),f.jsxs("div",{children:[f.jsx("strong",{children:"Category:"})," ",e.category]}),f.jsxs("div",{children:[f.jsx("strong",{children:"Route:"})," ",e.route]}),f.jsxs("div",{children:[f.jsx("strong",{children:"Element:"})," ",e.domHint||"Unknown"]})]}),f.jsxs("div",{className:"feedback-modal-field",children:[f.jsx("label",{children:"Comment"}),f.jsx("div",{className:"feedback-view-comment",children:e.comment})]}),f.jsxs("div",{className:"feedback-modal-actions",children:[f.jsx("div",{className:"feedback-view-hint",children:"Turn on feedback mode to edit"}),f.jsx("button",{className:"btn-secondary",onClick:r,children:"Close"})]})]})}function lu({children:e,projectId:A,enabled:r=!0,rateLimitSeconds:t=0,validation:n,feedbackReviewPath:s="/feedback"}){var H;const{user:a,hasAccessToProject:B,getReviewerProject:i,loading:o}=Je(),[c,u]=m.useState(!1),[g,w]=m.useState(null),[Q,d]=m.useState(null),[S,F]=m.useState(null),[p,b]=m.useState([]),[I,v]=m.useState({x:0,y:0}),C=LA.useLocation(),R=(a==null?void 0:a.email)??((H=a==null?void 0:a.user_metadata)==null?void 0:H.name)??null,x=A?i(A):void 0,E=!!(A&&!o&&a&&B(A));m.useEffect(()=>{const U=()=>{v({x:window.scrollX,y:window.scrollY})};return U(),window.addEventListener("scroll",U,{passive:!0}),()=>window.removeEventListener("scroll",U)},[]);const T=m.useCallback(()=>{if(!t||t<=0)return!0;const U=localStorage.getItem("feedback_last_submission");if(U){const M=parseInt(U,10),P=(Date.now()-M)/1e3;if(P<t)return alert(`Please wait ${Math.ceil(t-P)} seconds before submitting again.`),!1}return!0},[t]),_=m.useCallback(async()=>{if(!(x!=null&&x.projectUuid))return;const U=kA();try{const{data:M,error:G}=await U.from(Xe).select("*").eq("project_id",x.projectUuid);if(G){console.error("[Feedback] Failed to load items from Supabase:",G);return}if(M){const P=M.map(kt);b(P)}}catch(M){console.error("[Feedback] Error loading items:",M)}},[x==null?void 0:x.projectUuid]);m.useEffect(()=>{_();let U;return x!=null&&x.projectUuid&&(U=setInterval(_,3e4)),()=>{U&&clearInterval(U)}},[_,x==null?void 0:x.projectUuid]);const AA=p.filter(U=>U.route===C.pathname+C.search),D=m.useCallback(()=>{u(U=>U?(w(null),d(null),console.log("[Feedback] Mode OFF"),!1):(console.log("[Feedback] Mode ON"),!0))},[]);m.useEffect(()=>{if(!r||!E)return;const U=M=>{(M.ctrlKey||M.metaKey)&&M.shiftKey&&M.key.toLowerCase()==="f"&&(M.preventDefault(),D())};return window.addEventListener("keydown",U),()=>window.removeEventListener("keydown",U)},[r,E,D]);const Y=()=>{kA().auth.signOut(),u(!1),w(null),d(null),console.log("[Feedback] User logged out")};m.useEffect(()=>{if(!c)return;const U=M=>{const G=M.target;if(G.closest(".feedback-toggle")||G.closest(".feedback-modal")||G.closest(".feedback-marker")||G.closest(".feedback-user-modal")||G.closest(".feedback-overlay-backdrop"))return;M.preventDefault(),M.stopPropagation();const P=M.clientX,$=M.clientY,lA=window.scrollX,wA=window.scrollY,DA=P+lA,te=$+wA,OA=window.innerWidth,ne=window.innerHeight,se=ru(P,$),_t=se?jl(se):null,Pt=se?eu(se):null;(async()=>{const Ue=await ou(P,$),zA={x:P,y:$,pageX:DA,pageY:te,xNorm:P/OA,yNorm:$/ne,viewportW:OA,viewportH:ne,scrollX:lA,scrollY:wA,route:C.pathname+C.search,title:document.title,domHint:_t,selectorHint:Pt,screenshot:Ue};console.log("[Feedback] Click captured with screenshot:",zA.screenshot?"yes":"no"),w(zA),d(null)})()};return document.addEventListener("click",U,!0),()=>document.removeEventListener("click",U,!0)},[c,C]);const cA=m.useCallback(()=>{w(null),d(null)},[]),tA=m.useCallback(async U=>{if(!T()||!x)return;const M={...U,projectUuid:x.projectUuid,reviewerId:x.reviewerId},G=kA();try{const P=ra(M),{error:$}=await G.from(Xe).upsert(P);if($){console.error("[Feedback] Failed to save to Supabase:",$),alert("Failed to save feedback. Please try again.");return}localStorage.setItem("feedback_last_submission",Date.now().toString())}catch(P){console.error("[Feedback] Error saving item:",P);return}w(null),d(null),_()},[x,_,T]),nA=m.useCallback(async U=>{const M=kA();try{const{error:G}=await M.from(Xe).delete().eq("id",U);if(G){console.error("[Feedback] Failed to delete from Supabase:",G),alert("Failed to delete feedback.");return}}catch(G){console.error("[Feedback] Error deleting item:",G);return}w(null),d(null),_()},[_]),FA=U=>{const M=window.innerWidth,G=window.innerHeight,P=window.scrollX,$=window.scrollY,lA=U.pageX??U.xNorm*M+(U.scrollX??0),wA=U.pageY??U.yNorm*G+(U.scrollY??0),DA={x:lA-P,y:wA-$,pageX:lA,pageY:wA,xNorm:U.xNorm,yNorm:U.yNorm,viewportW:M,viewportH:G,scrollX:U.scrollX??0,scrollY:U.scrollY??0,route:U.route,title:U.title,domHint:U.domHint,selectorHint:U.selectorHint};w(DA),c?(d(U),F(null)):(F(U),d(null))},fA=m.useCallback(()=>{F(null),w(null)},[]);return r?f.jsxs(f.Fragment,{children:[e,!A&&f.jsx("div",{className:"feedback-warning-banner",style:{position:"fixed",bottom:16,left:16,right:16,padding:"8px 12px",background:"#fef3c7",border:"1px solid #f59e0b",borderRadius:6,fontSize:14,zIndex:9998},children:"Feedback: Project not configured. Add projectId to enable."}),E&&f.jsxs("div",{className:"feedback-toggle-container",children:[R&&f.jsx("span",{className:"feedback-user-badge",onClick:Y,title:"Click to logout",children:R}),f.jsx(LA.Link,{to:s,className:"feedback-view-all-link",title:"View all feedback for this project",children:"View all"}),f.jsxs("button",{className:`feedback-toggle ${c?"active":""}`,onClick:D,title:"Toggle feedback mode (Ctrl/Cmd + Shift + F)",children:["Feedback: ",c?"ON":"OFF"]})]}),E&&c&&AA.map(U=>{var OA,ne;const M=U.userName||"Anonymous",G=(Q==null?void 0:Q.id)===U.id||(S==null?void 0:S.id)===U.id,P=window.innerWidth,$=window.innerHeight,lA=U.pageX??U.xNorm*P+(U.scrollX??0),wA=U.pageY??U.yNorm*$+(U.scrollY??0),DA=lA-I.x,te=wA-I.y;return f.jsx("div",{className:`feedback-marker existing ${G?"active":""}`,style:{left:DA,top:te},onClick:()=>FA(U),title:`${M}: ${((OA=U.comment)==null?void 0:OA.slice(0,50))||""}${(((ne=U.comment)==null?void 0:ne.length)||0)>50?"...":""}`,children:f.jsx("span",{className:"feedback-marker-label",children:M.charAt(0).toUpperCase()})},U.id)}),E&&g&&!Q&&!S&&f.jsx("div",{className:"feedback-marker new",style:{left:g.x,top:g.y}}),E&&g&&R&&c&&!S&&f.jsx(nu,{clickData:g,userName:R,existingItem:Q||void 0,validation:n,onClose:cA,onSave:tA,onDelete:nA}),E&&S&&g&&f.jsx(cu,{item:S,clickData:g,onClose:fA}),E&&c&&!g&&f.jsx("div",{className:"feedback-overlay-hint",children:"Click anywhere to add feedback • Click markers to edit"})]}):f.jsx(f.Fragment,{children:e})}function uu(){const[e,A]=m.useState(""),[r,t]=m.useState(""),[n,s]=m.useState(null),[a,B]=m.useState(!1),i=LA.useNavigate(),{user:o}=Je();if(o)return i("/",{replace:!0}),null;const c=async u=>{u.preventDefault(),s(null),B(!0);try{const{error:g}=await kA().auth.signInWithPassword({email:e,password:r});if(g){s(g.message),B(!1);return}i("/",{replace:!0})}catch(g){s(g instanceof Error?g.message:"Login failed")}finally{B(!1)}};return f.jsx("div",{className:"feedback-overlay-backdrop",children:f.jsxs("div",{className:"feedback-user-modal",children:[f.jsx("h3",{children:"Feedback Login"}),f.jsx("p",{children:"Sign in with your reviewer credentials to use the feedback tool."}),f.jsxs("form",{onSubmit:c,children:[f.jsx("input",{type:"email",value:e,onChange:u=>{A(u.target.value),s(null)},placeholder:"Email",autoComplete:"email",required:!0,disabled:a}),f.jsx("input",{type:"password",value:r,onChange:u=>{t(u.target.value),s(null)},placeholder:"Password",autoComplete:"current-password",required:!0,disabled:a}),n&&f.jsx("div",{className:"feedback-modal-error",children:n}),f.jsxs("div",{className:"feedback-modal-actions",children:[f.jsx("button",{type:"button",className:"btn-secondary",onClick:()=>i(-1),disabled:a,children:"Cancel"}),f.jsx("button",{type:"submit",className:"btn-primary",disabled:a,children:a?"Signing in...":"Sign in"})]})]})]})})}function gu(){const e=LA.useNavigate(),{user:A,isAdmin:r,loading:t}=Je(),[n,s]=m.useState([]),[a,B]=m.useState([]),[i,o]=m.useState([]),[c,u]=m.useState(""),[g,w]=m.useState(""),[Q,d]=m.useState(""),[S,F]=m.useState(""),[p,b]=m.useState(""),[I,v]=m.useState(""),[C,R]=m.useState(""),[x,E]=m.useState(null),T=kA(),_=m.useCallback(async()=>{const{data:H}=await T.from("companies").select("id, name").order("name");s(H??[])},[T]),AA=m.useCallback(async()=>{const{data:H}=await T.from("projects").select("id, company_id, short_code, project_id, github_repo_url, companies(name)").order("short_code");B(H??[])},[T]),D=m.useCallback(async()=>{const{data:H}=await T.from("reviewers").select("id, user_id, project_id, projects(project_id, short_code)").order("project_id");o(H??[])},[T]);if(m.useEffect(()=>{_(),AA(),D()},[_,AA,D]),!t&&!A)return e("/feedback-login",{replace:!0}),null;if(!t&&A&&!r)return f.jsxs("div",{style:{padding:40,fontFamily:"sans-serif"},children:[f.jsx("h2",{children:"Access Denied"}),f.jsx("p",{children:"You must be an admin to access this page."}),f.jsx("button",{className:"btn-secondary",onClick:()=>e("/"),children:"Go back"})]});if(t)return f.jsx("div",{style:{padding:40},children:"Loading..."});const Y=async()=>{if(!c.trim())return;E(null);const{error:H}=await T.from("companies").insert({name:c.trim()});H?E(H.message):(u(""),_())},cA=async H=>{if(!confirm("Delete this company? Projects will be deleted too."))return;E(null);const{error:U}=await T.from("companies").delete().eq("id",H);U?E(U.message):_()},tA=async()=>{if(!g||!Q.trim())return;E(null);const H=`${Q.trim()}_${crypto.randomUUID()}`,{error:U}=await T.from("projects").insert({company_id:g,short_code:Q.trim(),project_id:H,github_repo_url:S.trim()||null});U?E(U.message):(d(""),F(""),AA())},nA=async H=>{if(!confirm("Delete this project?"))return;E(null);const{error:U}=await T.from("projects").delete().eq("id",H);U?E(U.message):AA()},FA=async()=>{if(!p.trim()||!I||!C)return;E(null);const{data:{session:H}}=await T.auth.getSession();if(!H){E("Not authenticated");return}try{const{data:U,error:M}=await T.auth.signUp({email:p.trim(),password:I,options:{emailRedirectTo:void 0}});if(M){E(M.message);return}if(!U.user){E("Failed to create user");return}const G=U.user.id;await T.auth.setSession({access_token:H.access_token,refresh_token:H.refresh_token});const{error:P}=await T.from("reviewers").insert({user_id:G,project_id:C});if(P){E(P.message);return}b(""),v(""),D()}catch(U){E(U instanceof Error?U.message:"Failed to create reviewer")}},fA=async H=>{if(!confirm("Remove this reviewer?"))return;E(null);const{error:U}=await T.from("reviewers").delete().eq("id",H);U?E(U.message):D()};return f.jsxs("div",{style:{padding:40,fontFamily:"sans-serif",maxWidth:800},children:[f.jsx("h1",{children:"Feedback Admin"}),f.jsx("button",{className:"btn-secondary",onClick:()=>e("/"),style:{marginBottom:24},children:"Back to app"}),x&&f.jsx("div",{className:"feedback-modal-error",style:{marginBottom:16},children:x}),f.jsxs("section",{style:{marginBottom:32},children:[f.jsx("h2",{children:"Companies"}),f.jsxs("div",{style:{display:"flex",gap:8,marginBottom:12},children:[f.jsx("input",{type:"text",value:c,onChange:H=>u(H.target.value),placeholder:"Company name",style:{padding:8,flex:1}}),f.jsx("button",{className:"btn-primary",onClick:Y,children:"Add"})]}),f.jsx("ul",{style:{listStyle:"none",padding:0},children:n.map(H=>f.jsxs("li",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:4},children:[f.jsx("span",{children:H.name}),f.jsx("button",{className:"btn-danger",onClick:()=>cA(H.id),style:{padding:"4px 8px",fontSize:12},children:"Delete"})]},H.id))})]}),f.jsxs("section",{style:{marginBottom:32},children:[f.jsx("h2",{children:"Projects"}),f.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:8,marginBottom:12},children:[f.jsxs("select",{value:g,onChange:H=>w(H.target.value),style:{padding:8},children:[f.jsx("option",{value:"",children:"Select company"}),n.map(H=>f.jsx("option",{value:H.id,children:H.name},H.id))]}),f.jsx("input",{type:"text",value:Q,onChange:H=>d(H.target.value),placeholder:"Short code (e.g. acme-dash)",style:{padding:8,width:180}}),f.jsx("input",{type:"text",value:S,onChange:H=>F(H.target.value),placeholder:"GitHub repo URL (optional)",style:{padding:8,flex:1,minWidth:200}}),f.jsx("button",{className:"btn-primary",onClick:tA,children:"Add"})]}),f.jsx("ul",{style:{listStyle:"none",padding:0},children:a.map(H=>{var U;return f.jsx("li",{style:{marginBottom:8},children:f.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,flexWrap:"wrap"},children:[f.jsxs("span",{children:[((U=Array.isArray(H.companies)?H.companies[0]:H.companies)==null?void 0:U.name)??"?"," / ",H.short_code]}),f.jsx("code",{style:{fontSize:12,background:"#f3f4f6",padding:"2px 6px"},children:H.project_id}),f.jsx("button",{className:"btn-danger",onClick:()=>nA(H.id),style:{padding:"4px 8px",fontSize:12},children:"Delete"})]})},H.id)})})]}),f.jsxs("section",{children:[f.jsx("h2",{children:"Reviewers"}),f.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:8,marginBottom:12},children:[f.jsx("input",{type:"email",value:p,onChange:H=>b(H.target.value),placeholder:"Email",style:{padding:8,width:180}}),f.jsx("input",{type:"password",value:I,onChange:H=>v(H.target.value),placeholder:"Password",style:{padding:8,width:140}}),f.jsxs("select",{value:C,onChange:H=>R(H.target.value),style:{padding:8,minWidth:200},children:[f.jsx("option",{value:"",children:"Select project"}),a.map(H=>{var U;return f.jsxs("option",{value:H.id,children:[(U=H.companies)==null?void 0:U.name," / ",H.short_code]},H.id)})]}),f.jsx("button",{className:"btn-primary",onClick:FA,children:"Add"})]}),f.jsx("ul",{style:{listStyle:"none",padding:0},children:i.map(H=>{var U;return f.jsxs("li",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:4},children:[f.jsxs("span",{children:[((U=Array.isArray(H.projects)?H.projects[0]:H.projects)==null?void 0:U.short_code)??"?"," – ",H.user_id.slice(0,8),"..."]}),f.jsx("button",{className:"btn-danger",onClick:()=>fA(H.id),style:{padding:"4px 8px",fontSize:12},children:"Remove"})]},H.id)})})]})]})}const na={Bug:"#ef4444",UX:"#3b82f6",Content:"#8b5cf6",Other:"#6b7280"};function fu({projectId:e}){const A=LA.useNavigate(),{user:r,hasAccessToProject:t,getReviewerProject:n,isAdmin:s,loading:a}=Je(),[B,i]=m.useState([]),[o,c]=m.useState(!0),[u,g]=m.useState(null),w=e?n(e):void 0,Q=(w==null?void 0:w.projectUuid)??u,d=!!(e&&r&&(t(e)||s)),S=m.useCallback(async()=>{if(!Q)return;const b=kA(),{data:I,error:v}=await b.from(Xe).select("*").eq("project_id",Q).order("created_at",{ascending:!1});v?(console.error("[Feedback] Failed to load review items:",v),i([])):i((I??[]).map(C=>kt(C))),c(!1)},[Q]);if(m.useEffect(()=>{s&&e&&!(w!=null&&w.projectUuid)&&kA().from("projects").select("id").eq("project_id",e).maybeSingle().then(({data:I})=>{I?g(I.id):c(!1)})},[s,e,w==null?void 0:w.projectUuid]),m.useEffect(()=>{if(Q){S();const b=setInterval(S,3e4);return()=>clearInterval(b)}else(!s||!e)&&c(!1)},[S,Q,s,e]),!a&&!r)return A("/feedback-login",{replace:!0}),null;if(!a&&r&&!d)return f.jsx("div",{className:"feedback-review-page",children:f.jsxs("div",{className:"feedback-review-container",children:[f.jsx("h2",{children:"Access Denied"}),f.jsx("p",{children:e?"You do not have access to view feedback for this project.":"Project not configured. Add projectId to the FeedbackReviewPage."}),f.jsx("button",{type:"button",className:"btn-secondary",onClick:()=>A("/"),children:"Go back"})]})});if(a||d&&!Q&&s||o)return f.jsx("div",{className:"feedback-review-page",children:f.jsx("div",{className:"feedback-review-container",children:f.jsx("p",{children:"Loading..."})})});const p=b=>(b.route.startsWith("http"),b.route);return f.jsx("div",{className:"feedback-review-page",children:f.jsxs("div",{className:"feedback-review-container",children:[f.jsxs("header",{className:"feedback-review-header",children:[f.jsx("h1",{children:"Feedback for this project"}),f.jsx("button",{type:"button",className:"btn-secondary",onClick:()=>A("/"),children:"Back to app"})]}),B.length===0?f.jsx("p",{className:"feedback-review-empty",children:"No feedback yet. Add feedback using the feedback tool in the app."}):f.jsx("div",{className:"feedback-review-grid",children:B.map(b=>f.jsxs("article",{className:"feedback-review-card",children:[f.jsxs("div",{className:"feedback-review-card-header",children:[f.jsx("span",{className:"feedback-review-avatar",title:b.userName,children:b.userName.charAt(0).toUpperCase()}),f.jsxs("div",{className:"feedback-review-card-meta",children:[f.jsx("strong",{children:b.userName}),f.jsx("span",{className:"feedback-review-date",children:new Date(b.createdAt).toLocaleString()})]}),f.jsx("span",{className:"feedback-review-category",style:{background:na[b.category]??na.Other},children:b.category})]}),b.screenshot&&f.jsx("div",{className:"feedback-review-screenshot",children:f.jsx("a",{href:b.screenshot,target:"_blank",rel:"noopener noreferrer",title:"Open full size",children:f.jsx("img",{src:b.screenshot,alt:"Screenshot of feedback location"})})}),f.jsx("div",{className:"feedback-review-comment",children:b.comment}),f.jsxs("div",{className:"feedback-review-footer",children:[f.jsx("a",{href:p(b),className:"feedback-review-link",title:`Go to: ${b.title??b.route}`,children:b.title||b.route||"View location"}),b.domHint&&f.jsxs("span",{className:"feedback-review-element",title:b.selectorHint??void 0,children:["Element: ",b.domHint]})]})]},b.id))})]})})}z.FeedbackAdminPage=gu,z.FeedbackAuthProvider=Bu,z.FeedbackLoginPage=uu,z.FeedbackProvider=lu,z.FeedbackReviewPage=fu,z.SUPABASE_TABLE=Xe,z.fromDbItem=kt,z.generateId=ea,z.toDbItem=ra,z.useFeedbackAuth=Je,Object.defineProperty(z,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rensblitz/customer-instant-feedback-app",
3
- "version": "2.0.2",
3
+ "version": "2.0.3",
4
4
  "description": "A React component library for collecting user feedback with screenshots and annotations",
5
5
  "author": "Rens Blitz",
6
6
  "license": "MIT",