1import{c7 as J,V as Q,T as Z,bj as tt,r as E,j as y,h as et,c8 as nt,aD as at,by as rt,bK as it,I as ot,a2 as V}from"./index-BPR3l8qa.js";import{u as Y}from"./useDebounce-Dg4RtEtB.js";var F={exports:{}};/*! 2 * Signature Pad v2.3.2 3 * https://github.com/szimek/signature_pad 4 * 5 * Copyright 2017 Szymon Nowak 6 * Released under the MIT license 7 * 8 * The main idea and some parts of the code (e.g. drawing variable width Bézier curve) are taken from: 9 * http://corner.squareup.com/2012/07/smoother-signatures.html 10 * 11 * Implementation of interpolation using cubic Bézier curves is taken from: 12 * http://benknowscode.wordpress.com/2012/09/14/path-interpolation-using-cubic-bezier-and-control-point-estimation-in-javascript 13 * 14 * Algorithm for approximated length of a Bézier curve is taken from: 15 * http://www.lemoda.net/maths/bezier-length/index.html 16 * 17 */function S(t,a,n){this.x=t,this.y=a,this.time=n||new Date().getTime()}S.prototype.velocityFrom=function(t){return this.time!==t.time?this.distanceTo(t)/(this.time-t.time):1};S.prototype.distanceTo=function(t){return Math.sqrt(Math.pow(this.x-t.x,2)+Math.pow(this.y-t.y,2))};S.prototype.equals=function(t){return this.x===t.x&&this.y===t.y&&this.time===t.time};function B(t,a,n,e){this.startPoint=t,this.control1=a,this.control2=n,this.endPoint=e}B.prototype.length=function(){for(var t=10,a=0,n=void 0,e=void 0,r=0;r<=t;r+=1){var o=r/t,i=this._point(o,this.startPoint.x,this.control1.x,this.control2.x,this.endPoint.x),s=this._point(o,this.startPoint.y,this.control1.y,this.control2.y,this.endPoint.y);if(r>0){var c=i-n,u=s-e;a+=Math.sqrt(c*c+u*u)}n=i,e=s}return a};B.prototype._point=function(t,a,n,e,r){return a*(1-t)*(1-t)*(1-t)+3*n*(1-t)*(1-t)*t+3*e*(1-t)*t*t+r*t*t*t};function st(t,a,n){var e,r,o,i=null,s=0;n||(n={});var c=function(){s=n.leading===!1?0:Date.now(),i=null,o=t.apply(e,r),i||(e=r=null)};return function(){var u=Date.now();!s&&n.leading===!1&&(s=u);var l=a-(u-s);return e=this,r=arguments,l<=0||l>a?(i&&(clearTimeout(i),i=null),s=u,o=t.apply(e,r),i||(e=r=null)):!i&&n.trailing!==!1&&(i=setTimeout(c,l)),o}}function g(t,a){var n=this,e=a||{};this.velocityFilterWeight=e.velocityFilterWeight||.7,this.minWidth=e.minWidth||.5,this.maxWidth=e.maxWidth||2.5,this.throttle="throttle"in e?e.throttle:16,this.minDistance="minDistance"in e?e.minDistance:5,this.throttle?this._strokeMoveUpdate=st(g.prototype._strokeUpdate,this.throttle):this._strokeMoveUpdate=g.prototype._strokeUpdate,this.dotSize=e.dotSize||function(){return(this.minWidth+this.maxWidth)/2},this.penColor=e.penColor||"black",this.backgroundColor=e.backgroundColor||"rgba(0,0,0,0)",this.onBegin=e.onBegin,this.onEnd=e.onEnd,this._canvas=t,this._ctx=t.getContext("2d"),this.clear(),this._handleMouseDown=function(r){r.which===1&&(n._mouseButtonDown=!0,n._strokeBegin(r))},this._handleMouseMove=function(r){n._mouseButtonDown&&n._strokeMoveUpdate(r)},this._handleMouseUp=function(r){r.which===1&&n._mouseButtonDown&&(n._mouseButtonDown=!1,n._strokeEnd(r))},this._handleTouchStart=function(r){if(r.targetTouches.length===1){var o=r.changedTouches[0];n._strokeBegin(o)}},this._handleTouchMove=function(r){r.preventDefault();var o=r.targetTouches[0];n._strokeMoveUpdate(o)},this._handleTouchEnd=function(r){var o=r.target===n._canvas;o&&(r.preventDefault(),n._strokeEnd(r))},this.on()}g.prototype.clear=function(){var t=this._ctx,a=this._canvas;t.fillStyle=this.backgroundColor,t.clearRect(0,0,a.width,a.height),t.fillRect(0,0,a.width,a.height),this._data=[],this._reset(),this._isEmpty=!0};g.prototype.fromDataURL=function(t){var a=this,n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},e=new Image,r=n.ratio||window.devicePixelRatio||1,o=n.width||this._canvas.width/r,i=n.height||this._canvas.height/r;this._reset(),e.src=t,e.onload=function(){a._ctx.drawImage(e,0,0,o,i)},this._isEmpty=!1};g.prototype.toDataURL=function(t){var a;switch(t){case"image/svg+xml":return this._toSVG();default:for(var n=arguments.length,e=Array(n>1?n-1:0),r=1;r<n;r++)e[r-1]=arguments[r];return(a=this._canvas).toDataURL.apply(a,[t].concat(e))}};g.prototype.on=function(){this._handleMouseEvents(),this._handleTouchEvents()};g.prototype.off=function(){this._canvas.removeEventListener("mousedown",this._handleMouseDown),this._canvas.removeEventListener("mousemove",this._handleMouseMove),document.removeEventListener("mouseup",this._handleMouseUp),this._canvas.removeEventListener("touchstart",this._handleTouchStart),this._canvas.removeEventListener("touchmove",this._handleTouchMove),this._canvas.removeEventListener("touchend",this._handleTouchEnd)};g.prototype.isEmpty=function(){return this._isEmpty};g.prototype._strokeBegin=function(t){this._data.push([]),this._reset(),this._strokeUpdate(t),typeof this.onBegin=="function"&&this.onBegin(t)};g.prototype._strokeUpdate=function(t){var a=t.clientX,n=t.clientY,e=this._createPoint(a,n),r=this._data[this._data.length-1],o=r&&r[r.length-1],i=o&&e.distanceTo(o)<this.minDistance;if(!(o&&i)){var s=this._addPoint(e),c=s.curve,u=s.widths;
17c&&u&&this._drawCurve(c,u.start,u.end),this._data[this._data.length-1].push({x:e.x,y:e.y,time:e.time,color:this.penColor})}};g.prototype._strokeEnd=function(t){var a=this.points.length>2,n=this.points[0];if(!a&&n&&this._drawDot(n),n){var e=this._data[this._data.length-1],r=e[e.length-1];n.equals(r)||e.push({x:n.x,y:n.y,time:n.time,color:this.penColor})}typeof this.onEnd=="function"&&this.onEnd(t)};g.prototype._handleMouseEvents=function(){this._mouseButtonDown=!1,this._canvas.addEventListener("mousedown",this._handleMouseDown),this._canvas.addEventListener("mousemove",this._handleMouseMove),document.addEventListener("mouseup",this._handleMouseUp)};g.prototype._handleTouchEvents=function(){this._canvas.style.msTouchAction="none",this._canvas.style.touchAction="none",this._canvas.addEventListener("touchstart",this._handleTouchStart),this._canvas.addEventListener("touchmove",this._handleTouchMove),this._canvas.addEventListener("touchend",this._handleTouchEnd)};g.prototype._reset=function(){this.points=[],this._lastVelocity=0,this._lastWidth=(this.minWidth+this.maxWidth)/2,this._ctx.fillStyle=this.penColor};g.prototype._createPoint=function(t,a,n){var e=this._canvas.getBoundingClientRect();return new S(t-e.left,a-e.top,n||new Date().getTime())};g.prototype._addPoint=function(t){var a=this.points,n=void 0;if(a.push(t),a.length>2){a.length===3&&a.unshift(a[0]),n=this._calculateCurveControlPoints(a[0],a[1],a[2]);var e=n.c2;n=this._calculateCurveControlPoints(a[1],a[2],a[3]);var r=n.c1,o=new B(a[1],e,r,a[2]),i=this._calculateCurveWidths(o);return a.shift(),{curve:o,widths:i}}return{}};g.prototype._calculateCurveControlPoints=function(t,a,n){var e=t.x-a.x,r=t.y-a.y,o=a.x-n.x,i=a.y-n.y,s={x:(t.x+a.x)/2,y:(t.y+a.y)/2},c={x:(a.x+n.x)/2,y:(a.y+n.y)/2},u=Math.sqrt(e*e+r*r),l=Math.sqrt(o*o+i*i),d=s.x-c.x,f=s.y-c.y,x=l/(u+l),w={x:c.x+d*x,y:c.y+f*x},_=a.x-w.x,P=a.y-w.y;return{c1:new S(s.x+_,s.y+P),c2:new S(c.x+_,c.y+P)}};g.prototype._calculateCurveWidths=function(t){var a=t.startPoint,n=t.endPoint,e={start:null,end:null},r=this.velocityFilterWeight*n.velocityFrom(a)+(1-this.velocityFilterWeight)*this._lastVelocity,o=this._strokeWidth(r);return e.start=this._lastWidth,e.end=o,this._lastVelocity=r,this._lastWidth=o,e};g.prototype._strokeWidth=function(t){return Math.max(this.maxWidth/(t+1),this.minWidth)};g.prototype._drawPoint=function(t,a,n){var e=this._ctx;e.moveTo(t,a),e.arc(t,a,n,0,2*Math.PI,!1),this._isEmpty=!1};g.prototype._drawCurve=function(t,a,n){var e=this._ctx,r=n-a,o=Math.floor(t.length());e.beginPath();for(var i=0;i<o;i+=1){var s=i/o,c=s*s,u=c*s,l=1-s,d=l*l,f=d*l,x=f*t.startPoint.x;x+=3*d*s*t.control1.x,x+=3*l*c*t.control2.x,x+=u*t.endPoint.x;var w=f*t.startPoint.y;w+=3*d*s*t.control1.y,w+=3*l*c*t.control2.y,w+=u*t.endPoint.y;var _=a+u*r;this._drawPoint(x,w,_)}e.closePath(),e.fill()};g.prototype._drawDot=function(t){var a=this._ctx,n=typeof this.dotSize=="function"?this.dotSize():this.dotSize;a.beginPath(),this._drawPoint(t.x,t.y,n),a.closePath(),a.fill()};g.prototype._fromData=function(t,a,n){for(var e=0;e<t.length;e+=1){var r=t[e];if(r.length>1)for(var o=0;o<r.length;o+=1){var i=r[o],s=new S(i.x,i.y,i.time),c=i.color;if(o===0)this.penColor=c,this._reset(),this._addPoint(s);else if(o!==r.length-1){var u=this._addPoint(s),l=u.curve,d=u.widths;l&&d&&a(l,d,c)}}else{this._reset();var f=r[0];n(f)}}};g.prototype._toSVG=function(){var t=this,a=this._data,n=this._canvas,e=Math.max(window.devicePixelRatio||1,1),r=0,o=0,i=n.width/e,s=n.height/e,c=document.createElementNS("http://www.w3.org/2000/svg","svg");c.setAttributeNS(null,"width",n.width),c.setAttributeNS(null,"height",n.height),this._fromData(a,function(p,M,T){var R=document.createElement("path");if(!isNaN(p.control1.x)&&!isNaN(p.control1.y)&&!isNaN(p.control2.x)&&!isNaN(p.control2.y)){var W="M "+p.startPoint.x.toFixed(3)+","+p.startPoint.y.toFixed(3)+" "+("C "+p.control1.x.toFixed(3)+","+p.control1.y.toFixed(3)+" ")+(p.control2.x.toFixed(3)+","+p.control2.y.toFixed(3)+" ")+(p.endPoint.x.toFixed(3)+","+p.endPoint.y.toFixed(3));R.setAttribute("d",W),R.setAttribute("stroke-width",(M.end*2.25).toFixed(3)),R.setAttribute("stroke",T),R.setAttribute("fill","none"),R.setAttribute("stroke-linecap","round"),c.appendChild(R)}},function(p){var M=document.createElement("circle"),T=typeof t.dotSize=="function"?t.dotSize():t.dotSize;M.setAttribute("r",T),M.setAttribute("cx",p.x),M.setAttribute("cy",p.y),M.setAttribute("fill",p.color),c.appendChild(M)});var u="data:image/svg+xml;base64,",l='<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"'+(' viewB
17ox="'+r+" "+o+" "+i+" "+s+'"')+(' width="'+i+'"')+(' height="'+s+'"')+">",d=c.innerHTML;if(d===void 0){var f=document.createElement("dummy"),x=c.childNodes;f.innerHTML="";for(var w=0;w<x.length;w+=1)f.appendChild(x[w].cloneNode(!0));d=f.innerHTML}var _="</svg>",P=l+d+_;return u+btoa(P)};g.prototype.fromData=function(t){var a=this;this.clear(),this._fromData(t,function(n,e){return a._drawCurve(n,e.start,e.end)},function(n){return a._drawDot(n)}),this._data=t};g.prototype.toData=function(){return this._data};const ut=Object.freeze(Object.defineProperty({__proto__:null,default:g},Symbol.toStringTag,{value:"Module"})),ht=J(ut);var U={exports:{}},lt=U.exports,$;function ct(){return $||($=1,function(t,a){(function(n,e){t.exports=e()})(lt,function(){return function(n){function e(o){if(r[o])return r[o].exports;var i=r[o]={exports:{},id:o,loaded:!1};return n[o].call(i.exports,i,i.exports,e),i.loaded=!0,i.exports}var r={};return e.m=n,e.c=r,e.p="",e(0)}([function(n,e){function r(u){var l=u.getContext("2d"),d=u.width,f=u.height,x=l.getImageData(0,0,d,f).data,w=s(!0,d,f,x),_=s(!1,d,f,x),P=c(!0,d,f,x),p=c(!1,d,f,x),M=p-P+1,T=_-w+1,R=l.getImageData(P,w,M,T);return u.width=M,u.height=T,l.clearRect(0,0,M,T),l.putImageData(R,0,0),u}function o(u,l,d,f){return{red:f[4*(d*l+u)],green:f[4*(d*l+u)+1],blue:f[4*(d*l+u)+2],alpha:f[4*(d*l+u)+3]}}function i(u,l,d,f){return o(u,l,d,f).alpha}function s(u,l,d,f){for(var x=u?1:-1,w=u?0:d-1,_=w;u?_<d:_>-1;_+=x)for(var P=0;P<l;P++)if(i(P,_,l,f))return _;return null}function c(u,l,d,f){for(var x=u?1:-1,w=u?0:l-1,_=w;u?_<l:_>-1;_+=x)for(var P=0;P<d;P++)if(i(_,P,l,f))return _;return null}Object.defineProperty(e,"__esModule",{value:!0}),e.default=r}])})}(U)),U.exports}var dt=F.exports,H;function ft(){return H||(H=1,function(t,a){(function(n,e){t.exports=e(Q(),Z(),ht,ct())})(dt,function(n,e,r,o){return function(i){function s(u){if(c[u])return c[u].exports;var l=c[u]={exports:{},id:u,loaded:!1};return i[u].call(l.exports,l,l.exports,s),l.loaded=!0,l.exports}var c={};return s.m=i,s.c=c,s.p="",s(0)}([function(i,s,c){function u(m){return m&&m.__esModule?m:{default:m}}function l(m,v){var C={};for(var b in m)v.indexOf(b)>=0||Object.prototype.hasOwnProperty.call(m,b)&&(C[b]=m[b]);return C}function d(m,v){if(!(m instanceof v))throw new TypeError("Cannot call a class as a function")}function f(m,v){if(!m)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!v||typeof v!="object"&&typeof v!="function"?m:v}function x(m,v){if(typeof v!="function"&&v!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof v);m.prototype=Object.create(v&&v.prototype,{constructor:{value:m,enumerable:!1,writable:!0,configurable:!0}}),v&&(Object.setPrototypeOf?Object.setPrototypeOf(m,v):m.__proto__=v)}Object.defineProperty(s,"__esModule",{value:!0});var w=Object.assign||function(m){for(var v=1;v<arguments.length;v++){var C=arguments[v];for(var b in C)Object.prototype.hasOwnProperty.call(C,b)&&(m[b]=C[b])}return m},_=function(){function m(v,C){for(var b=0;b<C.length;b++){var h=C[b];h.enumerable=h.enumerable||!1,h.configurable=!0,"value"in h&&(h.writable=!0),Object.defineProperty(v,h.key,h)}}return function(v,C,b){return C&&m(v.prototype,C),b&&m(v,b),v}}(),P=c(1),p=u(P),M=c(2),T=u(M),R=c(3),W=u(R),G=c(4),K=u(G),z=function(m){function v(){var C,b,h,N;d(this,v);for(var A=arguments.length,I=Array(A),O=0;O<A;O++)I[O]=arguments[O];return b=h=f(this,(C=v.__proto__||Object.getPrototypeOf(v)).call.apply(C,[this].concat(I
17))),h._sigPad=null,h._excludeOurProps=function(){var D=h.props,k=(D.canvasProps,D.clearOnResize,l(D,["canvasProps","clearOnResize"]));return k},h.getCanvas=function(){return h._canvas},h.getTrimmedCanvas=function(){var D=document.createElement("canvas");return D.width=h._canvas.width,D.height=h._canvas.height,D.getContext("2d").drawImage(h._canvas,0,0),(0,K.default)(D)},h.getSignaturePad=function(){return h._sigPad},h._checkClearOnResize=function(){h.props.clearOnResize&&h._resizeCanvas()},h._resizeCanvas=function(){var D=h.props.canvasProps||{},k=D.width,q=D.height;if(!k||!q){var j=h._canvas,L=Math.max(window.devicePixelRatio||1,1);k||(j.width=j.offsetWidth*L),q||(j.height=j.offsetHeight*L),j.getContext("2d").scale(L,L),h.clear()}},h.on=function(){return window.addEventListener("resize",h._checkClearOnResize),h._sigPad.on()},h.off=function(){return window.removeEventListener("resize",h._checkClearOnResize),h._sigPad.off()},h.clear=function(){return h._sigPad.clear()},h.isEmpty=function(){return h._sigPad.isEmpty()},h.fromDataURL=function(D,k){return h._sigPad.fromDataURL(D,k)},h.toDataURL=function(D,k){return h._sigPad.toDataURL(D,k)},h.fromData=function(D){return h._sigPad.fromData(D)},h.toData=function(){return h._sigPad.toData()},N=b,f(h,N)}return x(v,m),_(v,[{key:"componentDidMount",value:function(){this._sigPad=new W.default(this._canvas,this._excludeOurProps()),this._resizeCanvas(),this.on()}},{key:"componentWillUnmount",value:function(){this.off()}},{key:"componentDidUpdate",value:function(){Object.assign(this._sigPad,this._excludeOurProps())}},{key:"render",value:function(){var C=this,b=this.props.canvasProps;return T.default.createElement("canvas",w({ref:function(h){C._canvas=h}},b))}}]),v}(M.Component);z.propTypes={velocityFilterWeight:p.default.number,minWidth:p.default.number,maxWidth:p.default.number,minDistance:p.default.number,dotSize:p.default.oneOfType([p.default.number,p.default.func]),penColor:p.default.string,throttle:p.default.number,onEnd:p.default.func,onBegin:p.default.func,canvasProps:p.default.object,clearOnResize:p.default.bool},z.defaultProps={clearOnResize:!0},s.default=z},function(i,s){i.exports=n},function(i,s){i.exports=e},function(i,s){i.exports=r},function(i,s){i.exports=o}])})}(F)),F.exports}var vt=ft();const pt=tt(vt);function gt({onChange:t}){const a=E.useCallback(n=>{t({target:{value:n,dataURL:n}})},[t]);return y.jsx(y.Fragment,{children:y.jsx(mt,{updateSignature:a})})}function mt({updateSignature:t}){const[a,n]=E.useState(),e=E.useRef(),r=E.useCallback(()=>{e.current.fromData([]),n(null)},[e]);E.useEffect(()=>{e&&e.current&&e.current.fromDataURL(a)},[a,e]),E.useEffect(()=>{t(a?e.current.getTrimmedCanvas().toDataURL("image/png"):null)},[a]);const[o,i]=et(!0),s=E.useMemo(()=>350,[]);return y.jsxs("div",{className:"border rounded shadow-sm position-relative",style:{width:s},children:[o?y.jsx(y.Fragment,{children:y.jsx(pt,{onEnd:n,ref:e,penColor:"#2980b9",canvasProps:{width:s,height:200,className:"sigCanvas"}})}):y.jsx(_t,{onChange:t,width:s}),y.jsxs("div",{style:{position:"absolute",top:0,right:0},className:"d-flex flex-column",children:[y.jsx("button",{type:"button",className:" btn btn-link ",onClick:i,children:o?y.jsx(nt,{}):y.jsx(at,{})}),a?y.jsx("button",{type:"button",className:"btn btn-link text-danger",onClick:r,children:y.jsx(rt,{})}):null]})]})}gt.propTypes={onChange:V.func.isRequired,value:V.array};function _t({width:t,onChange:a}){const[n,e]=E.useState(""),[r,o]=E.useState(""),i=Y(r,300);E.useEffect(()=>{a(i)},[i]);const s=it();return y.jsxs("div",{children:[y.jsx(xt,{value:n,width:t,onChange:o}),y.jsx(ot,{value:n,placeholder:s.formatMessage({id:"yourName"}),onChange:e})]})}function xt({value:t,width:a,onChange:n}){const e=E.useRef(null),r=E.useRef(null);E.useEffect(()=>{if(e&&e.current){const i=e.current;X(i,t,a)}},[e,a,t]);const o=Y(t,300);return E.useEffect(()=>{if(r&&r.current){const i=r.current;i&&(o?(X(i,o,a),n(yt(i.getContext("2d")))):n(o))}},[o,a,r]),E.useEffect(()=>{new FontFace("SignatureFont","url(/signaturefonts/GreatVibes-Regular.ttf)").load().then(i=>document.fonts.add(i))},[]),y.jsxs(y.Fragment,{children:[y.jsx("canvas",{ref:e}
17),y.jsx("canvas",{ref:r,style:{display:"none"}})]})}function X(t,a,n){const e=t.getContext("2d"),r=100;var o=window.devicePixelRatio;t.style.width=n+"px",t.style.height=r+"px",t.width=Math.floor(n*o),t.height=Math.floor(r*o),e.fillStyle="#2980b9",e.scale(o,o),e.clearRect(0,0,t.width,t.height),e.font="40px SignatureFont",e.textAlign="center",e.textBaseline="middle";var i=n/2,s=r/2;e.fillText(a||"",i,s)}function yt(t){var a=t.canvas,n=a.width,e=a.height,r={x:[],y:[]},o=t.getImageData(0,0,a.width,a.height),i,s,c;for(s=0;s<e;s++)for(i=0;i<n;i++)c=(s*n+i)*4,o.data[c+3]>0&&(r.x.push(i),r.y.push(s));r.x.sort(function(d,f){return d-f}),r.y.sort(function(d,f){return d-f});var u=r.x.length-1;n=1+r.x[u]-r.x[0],e=1+r.y[u]-r.y[0];var l=t.getImageData(r.x[0],r.y[0],n,e);return a.width=n,a.height=e,t.putImageData(l,0,0),a.toDataURL("image/png")}export{gt as default}; 18//# sourceMappingURL=SignatureInputInternal-Duxu5MBZ.js.map
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.