@smileid/web-components 11.0.2 → 11.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +61 -0
- package/dist/components/smart-camera-web/src/README.md +0 -1
- package/dist/esm/{DocumentCaptureScreens-CRx5ymqY.js → DocumentCaptureScreens-DHAfE8VG.js} +191 -185
- package/dist/esm/DocumentCaptureScreens-DHAfE8VG.js.map +1 -0
- package/dist/esm/{EndUserConsent-D4fd1ovG.js → EndUserConsent-DE6OBSGG.js} +65 -63
- package/dist/esm/EndUserConsent-DE6OBSGG.js.map +1 -0
- package/dist/esm/{Navigation-CTjK6tLU.js → Navigation-kjll5SgE.js} +17 -9
- package/dist/esm/Navigation-kjll5SgE.js.map +1 -0
- package/dist/esm/{SelfieCaptureScreens-DuQjKt_K.js → SelfieCaptureScreens-DaREKFi4.js} +3087 -3177
- package/dist/esm/SelfieCaptureScreens-DaREKFi4.js.map +1 -0
- package/dist/esm/{TotpConsent-CQU5jQi4.js → TotpConsent-DsMJhXD8.js} +13 -9
- package/dist/esm/TotpConsent-DsMJhXD8.js.map +1 -0
- package/dist/esm/combobox.js +20 -19
- package/dist/esm/combobox.js.map +1 -1
- package/dist/esm/document.js +1 -1
- package/dist/esm/end-user-consent.js +1 -1
- package/dist/esm/index-LJce6hoU.js +1360 -0
- package/dist/esm/index-LJce6hoU.js.map +1 -0
- package/dist/esm/localisation.js +21 -0
- package/dist/esm/localisation.js.map +1 -0
- package/dist/esm/main.js +34 -17
- package/dist/esm/main.js.map +1 -1
- package/dist/esm/navigation.js +1 -1
- package/dist/esm/{package-C_cKNrUu.js → package-BoRHLVSv.js} +25 -40
- package/dist/esm/package-BoRHLVSv.js.map +1 -0
- package/dist/esm/selfie.js +1 -1
- package/dist/esm/smart-camera-web.js +22 -18
- package/dist/esm/smart-camera-web.js.map +1 -1
- package/dist/esm/totp-consent.js +1 -1
- package/dist/smart-camera-web.js +136 -177
- package/dist/smart-camera-web.js.map +1 -1
- package/dist/src/components/combobox/src/index.js +424 -1
- package/dist/src/components/document/src/index.js +1422 -1
- package/dist/src/components/end-user-consent/src/index.js +1573 -1
- package/dist/src/components/selfie/src/index.js +1220 -1
- package/dist/src/components/signature-pad/src/index.js +787 -1
- package/dist/src/components/smart-camera-web/src/SmartCameraWeb.js +2753 -1
- package/dist/src/components/totp-consent/src/index.js +1292 -1
- package/dist/types/combobox.d.ts +2 -2
- package/dist/types/document.d.ts +2 -2
- package/dist/types/end-user-consent.d.ts +2 -2
- package/dist/types/locale.d.ts +19 -0
- package/dist/types/localisation.d.ts +21 -0
- package/dist/types/main.d.ts +35 -26
- package/dist/types/navigation.d.ts +2 -2
- package/dist/types/selfie.d.ts +2 -2
- package/dist/types/signature-pad.d.ts +2 -2
- package/dist/types/smart-camera-web.d.ts +2 -2
- package/dist/types/totp-consent.d.ts +2 -2
- package/lib/components/camera-permission/CameraPermission.js +8 -3
- package/lib/components/combobox/src/Combobox.js +4 -2
- package/lib/components/document/src/DocumentCaptureScreens.js +4 -3
- package/lib/components/document/src/DocumentCaptureScreens.stories.js +37 -13
- package/lib/components/document/src/document-capture/DocumentCapture.js +20 -14
- package/lib/components/document/src/document-capture/DocumentCapture.stories.js +11 -2
- package/lib/components/document/src/document-capture-instructions/DocumentCaptureInstructions.js +16 -11
- package/lib/components/document/src/document-capture-instructions/DocumentCaptureInstructions.stories.js +14 -5
- package/lib/components/document/src/document-capture-review/DocumentCaptureReview.js +11 -7
- package/lib/components/document/src/document-capture-review/DocumentCaptureReview.stories.js +14 -5
- package/lib/components/end-user-consent/src/EndUserConsent.js +30 -29
- package/lib/components/end-user-consent/src/EndUserConsent.stories.js +12 -2
- package/lib/components/navigation/src/Navigation.js +15 -2
- package/lib/components/navigation/src/Navigation.stories.js +20 -4
- package/lib/components/selfie/src/SelfieCaptureScreens.js +3 -7
- package/lib/components/selfie/src/SelfieCaptureScreens.stories.js +16 -4
- package/lib/components/selfie/src/selfie-capture/SelfieCapture.js +23 -16
- package/lib/components/selfie/src/selfie-capture/SelfieCapture.stories.js +19 -7
- package/lib/components/selfie/src/selfie-capture-instructions/SelfieCaptureInstructions.js +16 -11
- package/lib/components/selfie/src/selfie-capture-instructions/SelfieCaptureInstructions.stories.js +14 -5
- package/lib/components/selfie/src/selfie-capture-review/SelfieCaptureReview.js +10 -5
- package/lib/components/selfie/src/selfie-capture-review/SelfieCaptureReview.stories.js +14 -5
- package/lib/components/selfie/src/selfie-capture-wrapper/SelfieCaptureWrapper.tsx +2 -2
- package/lib/components/selfie/src/smartselfie-capture/SmartSelfieCapture.stories.js +47 -0
- package/lib/components/selfie/src/smartselfie-capture/SmartSelfieCapture.tsx +2 -2
- package/lib/components/selfie/src/smartselfie-capture/components/CaptureControls.tsx +5 -2
- package/lib/components/selfie/src/smartselfie-capture/hooks/useCamera.ts +4 -4
- package/lib/components/selfie/src/smartselfie-capture/hooks/useFaceCapture.ts +6 -5
- package/lib/components/selfie/src/smartselfie-capture/utils/alertMessages.ts +11 -9
- package/lib/components/selfie/src/smartselfie-capture/utils/imageCapture.ts +3 -1
- package/lib/components/signature-pad/package-lock.json +11 -9
- package/lib/components/signature-pad/package.json +1 -1
- package/lib/components/totp-consent/src/TotpConsent.js +8 -3
- package/lib/domain/camera/src/SmartCamera.js +7 -22
- package/lib/domain/constants/src/Constants.js +28 -0
- package/lib/domain/file-upload/src/SmartFileUpload.js +9 -10
- package/lib/domain/localisation/index.js +456 -0
- package/package.json +13 -7
- package/dist/esm/DocumentCaptureScreens-CRx5ymqY.js.map +0 -1
- package/dist/esm/EndUserConsent-D4fd1ovG.js.map +0 -1
- package/dist/esm/Navigation-CTjK6tLU.js.map +0 -1
- package/dist/esm/SelfieCaptureScreens-DuQjKt_K.js.map +0 -1
- package/dist/esm/TotpConsent-CQU5jQi4.js.map +0 -1
- package/dist/esm/package-C_cKNrUu.js.map +0 -1
|
@@ -1,4 +1,790 @@
|
|
|
1
|
-
(()=>{var C=Object.defineProperty;var M=(u,t,e)=>t in u?C(u,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):u[t]=e;var x=(u,t,e)=>M(u,typeof t!="symbol"?t+"":t,e);var w=class{constructor(t,e,i,s){if(isNaN(t)||isNaN(e))throw new Error("Point is invalid: (".concat(t,", ").concat(e,")"));this.x=+t,this.y=+e,this.pressure=i||0,this.time=s||Date.now()}distanceTo(t){return Math.sqrt(Math.pow(this.x-t.x,2)+Math.pow(this.y-t.y,2))}equals(t){return this.x===t.x&&this.y===t.y&&this.pressure===t.pressure&&this.time===t.time}velocityFrom(t){return this.time!==t.time?this.distanceTo(t)/(this.time-t.time):0}},y=class u{static fromPoints(t,e){let i=this.calculateControlPoints(t[0],t[1],t[2]).c2,s=this.calculateControlPoints(t[1],t[2],t[3]).c1;return new u(t[1],i,s,t[2],e.start,e.end)}static calculateControlPoints(t,e,i){let s=t.x-e.x,o=t.y-e.y,n=e.x-i.x,h=e.y-i.y,a={x:(t.x+e.x)/2,y:(t.y+e.y)/2},r={x:(e.x+i.x)/2,y:(e.y+i.y)/2},c=Math.sqrt(s*s+o*o),l=Math.sqrt(n*n+h*h),m=a.x-r.x,p=a.y-r.y,d=l/(c+l),v={x:r.x+m*d,y:r.y+p*d},S=e.x-v.x,k=e.y-v.y;return{c1:new w(a.x+S,a.y+k),c2:new w(r.x+S,r.y+k)}}constructor(t,e,i,s,o,n){this.startPoint=t,this.control2=e,this.control1=i,this.endPoint=s,this.startWidth=o,this.endWidth=n}length(){let e=0,i,s;for(let o=0;o<=10;o+=1){let n=o/10,h=this.point(n,this.startPoint.x,this.control1.x,this.control2.x,this.endPoint.x),a=this.point(n,this.startPoint.y,this.control1.y,this.control2.y,this.endPoint.y);if(o>0){let r=h-i,c=a-s;e+=Math.sqrt(r*r+c*c)}i=h,s=a}return e}point(t,e,i,s,o){return e*(1-t)*(1-t)*(1-t)+3*i*(1-t)*(1-t)*t+3*s*(1-t)*t*t+o*t*t*t}},b=class{constructor(){try{this._et=new EventTarget}catch(t){this._et=document}}addEventListener(t,e,i){this._et.addEventListener(t,e,i)}dispatchEvent(t){return this._et.dispatchEvent(t)}removeEventListener(t,e,i){this._et.removeEventListener(t,e,i)}};function L(u,t=250){let e=0,i=null,s,o,n,h=()=>{e=Date.now(),i=null,s=u.apply(o,n),i||(o=null,n=[])};return function(...r){let c=Date.now(),l=t-(c-e);return o=this,n=r,l<=0||l>t?(i&&(clearTimeout(i),i=null),e=c,s=u.apply(o,n),i||(o=null,n=[])):i||(i=window.setTimeout(h,l)),s}}var f=class u extends b{constructor(t,e={}){var i,s,o;super(),this.canvas=t,this._drawingStroke=!1,this._isEmpty=!0,this._lastPoints=[],this._data=[],this._lastVelocity=0,this._lastWidth=0,this._handleMouseDown=n=>{!this._isLeftButtonPressed(n,!0)||this._drawingStroke||this._strokeBegin(this._pointerEventToSignatureEvent(n))},this._handleMouseMove=n=>{if(!this._isLeftButtonPressed(n,!0)||!this._drawingStroke){this._strokeEnd(this._pointerEventToSignatureEvent(n),!1);return}this._strokeMoveUpdate(this._pointerEventToSignatureEvent(n))},this._handleMouseUp=n=>{this._isLeftButtonPressed(n)||this._strokeEnd(this._pointerEventToSignatureEvent(n))},this._handleTouchStart=n=>{n.targetTouches.length!==1||this._drawingStroke||(n.cancelable&&n.preventDefault(),this._strokeBegin(this._touchEventToSignatureEvent(n)))},this._handleTouchMove=n=>{if(n.targetTouches.length===1){if(n.cancelable&&n.preventDefault(),!this._drawingStroke){this._strokeEnd(this._touchEventToSignatureEvent(n),!1);return}this._strokeMoveUpdate(this._touchEventToSignatureEvent(n))}},this._handleTouchEnd=n=>{n.targetTouches.length===0&&(n.cancelable&&n.preventDefault(),this.canvas.removeEventListener("touchmove",this._handleTouchMove),this._strokeEnd(this._touchEventToSignatureEvent(n)))},this._handlePointerDown=n=>{!this._isLeftButtonPressed(n)||this._drawingStroke||(n.preventDefault(),this._strokeBegin(this._pointerEventToSignatureEvent(n)))},this._handlePointerMove=n=>{if(!this._isLeftButtonPressed(n,!0)||!this._drawingStroke){this._strokeEnd(this._pointerEventToSignatureEvent(n),!1);return}n.preventDefault(),this._strokeMoveUpdate(this._pointerEventToSignatureEvent(n))},this._handlePointerUp=n=>{this._isLeftButtonPressed(n)||(n.preventDefault(),this._strokeEnd(this._pointerEventToSignatureEvent(n)))},this.velocityFilterWeight=e.velocityFilterWeight||.7,this.minWidth=e.minWidth||.5,this.maxWidth=e.maxWidth||2.5,this.throttle=(i=e.throttle)!==null&&i!==void 0?i:16,this.minDistance=(s=e.minDistance)!==null&&s!==void 0?s:5,this.dotSize=e.dotSize||0,this.penColor=e.penColor||"black",this.backgroundColor=e.backgroundColor||"rgba(0,0,0,0)",this.compositeOperation=e.compositeOperation||"source-over",this.canvasContextOptions=(o=e.canvasContextOptions)!==null&&o!==void 0?o:{},this._strokeMoveUpdate=this.throttle?L(u.prototype._strokeUpdate,this.throttle):u.prototype._strokeUpdate,this._ctx=t.getContext("2d",this.canvasContextOptions),this.clear(),this.on()}clear(){let{_ctx:t,canvas:e}=this;t.fillStyle=this.backgroundColor,t.clearRect(0,0,e.width,e.height),t.fillRect(0,0,e.width,e.height),this._data=[],this._reset(this._getPointGroupOptions()),this._isEmpty=!0}fromDataURL(t,e={}){return new Promise((i,s)=>{let o=new Image,n=e.ratio||window.devicePixelRatio||1,h=e.width||this.canvas.width/n,a=e.height||this.canvas.height/n,r=e.xOffset||0,c=e.yOffset||0;this._reset(this._getPointGroupOptions()),o.onload=()=>{this._ctx.drawImage(o,r,c,h,a),i()},o.onerror=l=>{s(l)},o.crossOrigin="anonymous",o.src=t,this._isEmpty=!1})}toDataURL(t="image/png",e){switch(t){case"image/svg+xml":return typeof e!="object"&&(e=void 0),"data:image/svg+xml;base64,".concat(btoa(this.toSVG(e)));default:return typeof e!="number"&&(e=void 0),this.canvas.toDataURL(t,e)}}on(){this.canvas.style.touchAction="none",this.canvas.style.msTouchAction="none",this.canvas.style.userSelect="none";let t=/Macintosh/.test(navigator.userAgent)&&"ontouchstart"in document;window.PointerEvent&&!t?this._handlePointerEvents():(this._handleMouseEvents(),"ontouchstart"in window&&this._handleTouchEvents())}off(){this.canvas.style.touchAction="auto",this.canvas.style.msTouchAction="auto",this.canvas.style.userSelect="auto",this.canvas.removeEventListener("pointerdown",this._handlePointerDown),this.canvas.removeEventListener("mousedown",this._handleMouseDown),this.canvas.removeEventListener("touchstart",this._handleTouchStart),this._removeMoveUpEventListeners()}_getListenerFunctions(){var t;let e=window.document===this.canvas.ownerDocument?window:(t=this.canvas.ownerDocument.defaultView)!==null&&t!==void 0?t:this.canvas.ownerDocument;return{addEventListener:e.addEventListener.bind(e),removeEventListener:e.removeEventListener.bind(e)}}_removeMoveUpEventListeners(){let{removeEventListener:t}=this._getListenerFunctions();t("pointermove",this._handlePointerMove),t("pointerup",this._handlePointerUp),t("mousemove",this._handleMouseMove),t("mouseup",this._handleMouseUp),t("touchmove",this._handleTouchMove),t("touchend",this._handleTouchEnd)}isEmpty(){return this._isEmpty}fromData(t,{clear:e=!0}={}){e&&this.clear(),this._fromData(t,this._drawCurve.bind(this),this._drawDot.bind(this)),this._data=this._data.concat(t)}toData(){return this._data}_isLeftButtonPressed(t,e){return e?t.buttons===1:(t.buttons&1)===1}_pointerEventToSignatureEvent(t){return{event:t,type:t.type,x:t.clientX,y:t.clientY,pressure:"pressure"in t?t.pressure:0}}_touchEventToSignatureEvent(t){let e=t.changedTouches[0];return{event:t,type:t.type,x:e.clientX,y:e.clientY,pressure:e.force}}_getPointGroupOptions(t){return{penColor:t&&"penColor"in t?t.penColor:this.penColor,dotSize:t&&"dotSize"in t?t.dotSize:this.dotSize,minWidth:t&&"minWidth"in t?t.minWidth:this.minWidth,maxWidth:t&&"maxWidth"in t?t.maxWidth:this.maxWidth,velocityFilterWeight:t&&"velocityFilterWeight"in t?t.velocityFilterWeight:this.velocityFilterWeight,compositeOperation:t&&"compositeOperation"in t?t.compositeOperation:this.compositeOperation}}_strokeBegin(t){if(!this.dispatchEvent(new CustomEvent("beginStroke",{detail:t,cancelable:!0})))return;let{addEventListener:i}=this._getListenerFunctions();switch(t.event.type){case"mousedown":i("mousemove",this._handleMouseMove),i("mouseup",this._handleMouseUp);break;case"touchstart":i("touchmove",this._handleTouchMove),i("touchend",this._handleTouchEnd);break;case"pointerdown":i("pointermove",this._handlePointerMove),i("pointerup",this._handlePointerUp);break}this._drawingStroke=!0;let s=this._getPointGroupOptions(),o=Object.assign(Object.assign({},s),{points:[]});this._data.push(o),this._reset(s),this._strokeUpdate(t)}_strokeUpdate(t){if(!this._drawingStroke)return;if(this._data.length===0){this._strokeBegin(t);return}this.dispatchEvent(new CustomEvent("beforeUpdateStroke",{detail:t}));let e=this._createPoint(t.x,t.y,t.pressure),i=this._data[this._data.length-1],s=i.points,o=s.length>0&&s[s.length-1],n=o?e.distanceTo(o)<=this.minDistance:!1,h=this._getPointGroupOptions(i);if(!o||!(o&&n)){let a=this._addPoint(e,h);o?a&&this._drawCurve(a,h):this._drawDot(e,h),s.push({time:e.time,x:e.x,y:e.y,pressure:e.pressure})}this.dispatchEvent(new CustomEvent("afterUpdateStroke",{detail:t}))}_strokeEnd(t,e=!0){this._removeMoveUpEventListeners(),this._drawingStroke&&(e&&this._strokeUpdate(t),this._drawingStroke=!1,this.dispatchEvent(new CustomEvent("endStroke",{detail:t})))}_handlePointerEvents(){this._drawingStroke=!1,this.canvas.addEventListener("pointerdown",this._handlePointerDown)}_handleMouseEvents(){this._drawingStroke=!1,this.canvas.addEventListener("mousedown",this._handleMouseDown)}_handleTouchEvents(){this.canvas.addEventListener("touchstart",this._handleTouchStart)}_reset(t){this._lastPoints=[],this._lastVelocity=0,this._lastWidth=(t.minWidth+t.maxWidth)/2,this._ctx.fillStyle=t.penColor,this._ctx.globalCompositeOperation=t.compositeOperation}_createPoint(t,e,i){let s=this.canvas.getBoundingClientRect();return new w(t-s.left,e-s.top,i,new Date().getTime())}_addPoint(t,e){let{_lastPoints:i}=this;if(i.push(t),i.length>2){i.length===3&&i.unshift(i[0]);let s=this._calculateCurveWidths(i[1],i[2],e),o=y.fromPoints(i,s);return i.shift(),o}return null}_calculateCurveWidths(t,e,i){let s=i.velocityFilterWeight*e.velocityFrom(t)+(1-i.velocityFilterWeight)*this._lastVelocity,o=this._strokeWidth(s,i),n={end:o,start:this._lastWidth};return this._lastVelocity=s,this._lastWidth=o,n}_strokeWidth(t,e){return Math.max(e.maxWidth/(t+1),e.minWidth)}_drawCurveSegment(t,e,i){let s=this._ctx;s.moveTo(t,e),s.arc(t,e,i,0,2*Math.PI,!1),this._isEmpty=!1}_drawCurve(t,e){let i=this._ctx,s=t.endWidth-t.startWidth,o=Math.ceil(t.length())*2;i.beginPath(),i.fillStyle=e.penColor;for(let n=0;n<o;n+=1){let h=n/o,a=h*h,r=a*h,c=1-h,l=c*c,m=l*c,p=m*t.startPoint.x;p+=3*l*h*t.control1.x,p+=3*c*a*t.control2.x,p+=r*t.endPoint.x;let d=m*t.startPoint.y;d+=3*l*h*t.control1.y,d+=3*c*a*t.control2.y,d+=r*t.endPoint.y;let v=Math.min(t.startWidth+r*s,e.maxWidth);this._drawCurveSegment(p,d,v)}i.closePath(),i.fill()}_drawDot(t,e){let i=this._ctx,s=e.dotSize>0?e.dotSize:(e.minWidth+e.maxWidth)/2;i.beginPath(),this._drawCurveSegment(t.x,t.y,s),i.closePath(),i.fillStyle=e.penColor,i.fill()}_fromData(t,e,i){for(let s of t){let{points:o}=s,n=this._getPointGroupOptions(s);if(o.length>1)for(let h=0;h<o.length;h+=1){let a=o[h],r=new w(a.x,a.y,a.pressure,a.time);h===0&&this._reset(n);let c=this._addPoint(r,n);c&&e(c,n)}else this._reset(n),i(o[0],n)}}toSVG({includeBackgroundColor:t=!1}={}){let e=this._data,i=Math.max(window.devicePixelRatio||1,1),s=0,o=0,n=this.canvas.width/i,h=this.canvas.height/i,a=document.createElementNS("http://www.w3.org/2000/svg","svg");if(a.setAttribute("xmlns","http://www.w3.org/2000/svg"),a.setAttribute("xmlns:xlink","http://www.w3.org/1999/xlink"),a.setAttribute("viewBox","".concat(s," ").concat(o," ").concat(n," ").concat(h)),a.setAttribute("width",n.toString()),a.setAttribute("height",h.toString()),t&&this.backgroundColor){let r=document.createElement("rect");r.setAttribute("width","100%"),r.setAttribute("height","100%"),r.setAttribute("fill",this.backgroundColor),a.appendChild(r)}return this._fromData(e,(r,{penColor:c})=>{let l=document.createElement("path");if(!isNaN(r.control1.x)&&!isNaN(r.control1.y)&&!isNaN(r.control2.x)&&!isNaN(r.control2.y)){let m="M ".concat(r.startPoint.x.toFixed(3),",").concat(r.startPoint.y.toFixed(3)," ")+"C ".concat(r.control1.x.toFixed(3),",").concat(r.control1.y.toFixed(3)," ")+"".concat(r.control2.x.toFixed(3),",").concat(r.control2.y.toFixed(3)," ")+"".concat(r.endPoint.x.toFixed(3),",").concat(r.endPoint.y.toFixed(3));l.setAttribute("d",m),l.setAttribute("stroke-width",(r.endWidth*2.25).toFixed(3)),l.setAttribute("stroke",c),l.setAttribute("fill","none"),l.setAttribute("stroke-linecap","round"),a.appendChild(l)}},(r,{penColor:c,dotSize:l,minWidth:m,maxWidth:p})=>{let d=document.createElement("circle"),v=l>0?l:(m+p)/2;d.setAttribute("r",v.toString()),d.setAttribute("cx",r.x.toString()),d.setAttribute("cy",r.y.toString()),d.setAttribute("fill",c),a.appendChild(d)}),a.outerHTML}};var g=class g{static getHumanSize(t){let e=["B","kB","MB","GB","TB","PB","EB","ZB","YB"],i=Math.min(Math.floor(Math.log(t)/Math.log(1024)),e.length-1),s=t/1024**i;return i===0?"".concat(t," bytes"):"".concat(s.toFixed(0)," ").concat(e[i])}static getData(t){return new Promise((e,i)=>{let s=new FileReader;s.onload=o=>{e(o.target.result)},s.onerror=()=>{i(new Error("An error occurred reading the file. Please check the file, and try again"))},s.readAsDataURL(t)})}static async retrieve(t){if(t.length>1)throw new Error("Only one file upload is permitted at a time");let e=t[0];if(!g.supportedTypes.includes(e.type))throw new Error("Unsupported file format. Please ensure that you are providing a JPG, PNG or SVG image");if(e.size>g.memoryLimit)throw new Error("".concat(e.name," is too large. Please ensure that the file is less than ").concat(g.getHumanSize(g.memoryLimit),"."));return await g.getData(e)}};x(g,"memoryLimit",2048e3),x(g,"supportedTypes",["image/jpeg","image/png","image/svg+xml"]);var E=g,_=class extends HTMLElement{connectedCallback(){let t=this.attachShadow({mode:"open"}),e=document.createElement("style");e.textContent='\n:host {\n display: block;\n block-size: auto;\n inline-size: 30rem;\n max-inline-size: 100%;\n position: relative;\n --color-active: #2D2B2A;\n --color-default: #001096;\n --color-disabled: #848282;\n}\n\n:host::part(upload) {\n text-align: center;\n}\n\n:host::part(signature-controls) {\n display: inline-flex;\n position: absolute;\n top: 1rem;\n right: 1rem;\n}\n\n:host::part(upload) svg + * {\n margin-inline-start: .5rem;\n}\n\n:host::part(canvas) {\n background-color: #F9F0E7;\n --dot-bg: #F9F0E7;\n --dot-color: black;\n --dot-size: 1px;\n --dot-space: 22px;\n background:\n linear-gradient(90deg, var(--dot-bg) calc(var(--dot-space) - var(--dot-size)), transparent 1%) center / var(--dot-space) var(--dot-space),\n linear-gradient(var(--dot-bg) calc(var(--dot-space) - var(--dot-size)), transparent 1%) center / var(--dot-space) var(--dot-space),\n var(--dot-color);\n border-radius: 2rem;\n inline-size: 30rem;\n max-inline-size: 100%;\n aspect-ratio: 2 / 1;\n}\n\n:host::part(upload-preview-image) {\n max-inline-size: 10rem;\n margin-inline: auto;\n}\n\n.visually-hidden {\n clip: rect(0 0 0 0); \n clip-path: inset(50%);\n height: 1px;\n overflow: hidden;\n position: absolute;\n white-space: nowrap; \n width: 1px;\n}\n\nbutton,\nlabel {\n font: inherit;\n cursor: pointer;\n}\n\nlabel {\n display: inline-flex;\n text-decoration: underline;\n}\n\nlabel svg + * {\n margin-inline-start: .5rem;\n}\n\n[type="file"] {\n display: none;\n}\n\n.center {\n text-align: center;\n margin-inline: auto;\n}\n\n.color-red {\n color: red;\n}\n\nbutton[data-variant="icon"] {\n appearance: none;\n -webkit-appearance: none;\n background-color: transparent;\n border: 0px;\n}\n\nbutton[data-variant="text"] {\n appearance: none;\n -webkit-appearance: none;\n background-color: transparent;\n border: 0px;\n text-decoration: underline;\n display: inline-flex;\n align-items: baseline;\n}\n\nbutton[data-variant="solid"] {\n --button-color: '.concat(this.themeColor,";\n border-radius: 2.5rem;\n border: 0;\n background-color: transparent;\n color: #fff;\n cursor: pointer;\n inline-size: 100%;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n font-size: 18px;\n font-weight: 600;\n padding: .75rem 1.5rem;\n text-align: center;\n background-color: var(--button-color);\n border: 2px solid var(--button-color);\n}\n\nbutton:hover,\nbutton:focus,\nbutton:active {\n --button-color: var(--color-active);\n}\n\nbutton:disabled {\n --button-color: var(--color-disabled);\n}\n");let i=document.createElement("div"),s=document.createElement("div");s.innerHTML='\n <p id="error" class="color-red | center"><p>\n ';let o=document.createElement("div");o.setAttribute("id","controls"),o.setAttribute("part","signature-controls"),o.innerHTML='\n <button data-variant="icon" type="button" name="clear" id="clear">\n <span class="visually-hidden">\n Clear Signature\n </span>\n <svg fill="none" xmlns="http://www.w3.org/2000/svg" width="18" viewBox="0 0 17 18">\n <path d="M3.314 15.646a8.004 8.004 0 01-2.217-4.257 8.06 8.06 0 01.545-4.655l1.789.788a6.062 6.062 0 001.264 6.737 6.033 6.033 0 008.551 0c2.358-2.37 2.358-6.224 0-8.592a5.996 5.996 0 00-4.405-1.782l.662 2.354-3.128-.796-3.127-.796 2.25-2.324L7.748 0l.55 1.953a7.966 7.966 0 016.33 2.326 8.004 8.004 0 012.342 5.684 8.005 8.005 0 01-2.343 5.683A7.928 7.928 0 018.97 18a7.928 7.928 0 01-5.656-2.354z" fill="currentColor" />\n </svg>\n </button>\n ';let n=document.createElement("canvas"),r=this.parentElement.closest(":not([hidden])").querySelector(":not([hidden])").offsetWidth,l=30*getComputedStyle(document.documentElement).fontSize.split("px")[0],m=2;n.width=r<l?r:l,n.height=(r<l?r:l)/m,n.setAttribute("id","signature-canvas"),n.setAttribute("part","canvas");let p=document.createElement("div");p.setAttribute("id","signature-upload-wrapper"),p.innerHTML='\n <p part="upload">\n <strong>or</strong>\n <label>\n <input type=\'file\' onclick=\'this.value=null;\' id=\'upload-signature\' accept=\'image/jpeg, image/png, image/svg+xml\' />\n <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="none">\n <rect width="16" height="16" fill="#F9F0E7" rx="2"/>\n <mask id="sign" width="16" height="16" x="0" y="0" maskUnits="userSpaceOnUse" style="mask-type:alpha">\n <rect width="16" height="16" fill="#D9D9D9" rx="2"/>\n </mask>\n <g mask="url(#sign)">\n <path fill="#2D2B2A" d="M0 13.333h16V16H0z"/>\n </g>\n <path fill="#2D2B2A" fill-rule="evenodd" d="M2.69 7.346a.23.23 0 0 1 .059-.073.275.275 0 0 1 .284-.034c.07.036.146.064.224.084h.12c0-.012.105-.048.105-.395a.796.796 0 0 1 .211-.61.667.667 0 0 1 .607-.096c.202.061.39.154.555.275.194.138.38.286.555.443.146.134.31.25.489.347l.092.047c.119.06.238-.023.185-.143l-.04-.12a.817.817 0 0 1-.066-.694.675.675 0 0 1 .244-.273.774.774 0 0 1 .364-.12c.324-.028.651 0 .964.083h.026c.027-.861.225-1.83.82-2.523.593-.694 1.478-.993 2.205-.837.726.155 1.307.73 1.307 1.602 0 1.34-.872 2.26-1.915 2.93.471.374.85.835 1.11 1.351.027.046.05.094.065.144h.014a.55.55 0 0 0 .079.203.44.44 0 0 0 .04.18c.002.025.011.05.026.07h-.013c.037.17.041.344.013.515a.955.955 0 0 1-.188.493 1.097 1.097 0 0 1-.433.344 1.346 1.346 0 0 1-1.122.012 2.194 2.194 0 0 1-.846-.67 5.024 5.024 0 0 1-.462-.681h-.026a.502.502 0 0 0-.106-.144.014.014 0 0 1-.01-.003.011.011 0 0 1-.003-.009.035.035 0 0 1-.013-.023.047.047 0 0 1-.011-.017.626.626 0 0 0-.055-.163.24.24 0 0 0-.014-.095h.014a3.477 3.477 0 0 1-.198-.49 6.318 6.318 0 0 1-.278-1.699L7.51 6.51c-.243-.07-.5-.094-.753-.071-.158.024-.198.071-.211.107-.014.036-.04.168.053.359.092.191.171.478.118.658a.45.45 0 0 1-.21.25.66.66 0 0 1-.305.06 1.521 1.521 0 0 1-.568-.19 3.533 3.533 0 0 1-.58-.42 3.54 3.54 0 0 0-.49-.394 1.49 1.49 0 0 0-.409-.203c-.053-.024-.079-.024-.092-.012H4.05c-.014.012-.066.072-.066.275 0 .395-.12.705-.423.813a.813.813 0 0 1-.41.024 1.646 1.646 0 0 1-.343-.12.237.237 0 0 1-.126-.127.208.208 0 0 1 .007-.172Zm5.731.766c.068.204.152.404.251.598.011.053.03.105.053.155.036.068.08.132.132.191.02.05.047.099.08.144.085.152.186.296.303.43.167.22.389.4.647.526a.847.847 0 0 0 .687-.011.655.655 0 0 0 .247-.204.573.573 0 0 0 .11-.287 1.435 1.435 0 0 0-.04-.454h-.014a.496.496 0 0 0-.079-.335.491.491 0 0 0-.119-.191 3.842 3.842 0 0 0-1.017-1.16l-.356.18a.253.253 0 0 1-.193.027.248.248 0 0 1-.088-.041.22.22 0 0 1-.063-.07.219.219 0 0 1-.02-.172.242.242 0 0 1 .113-.14l.172-.083a3.388 3.388 0 0 0-.463-.251l-.58-.24c.022.47.101.935.237 1.388Zm.568-1.555c.24.12.474.252.7.395 1.017-.634 1.81-1.459 1.81-2.63 0-.67-.41-1.053-.912-1.16-.502-.108-1.189.083-1.704.669-.515.586-.7 1.47-.713 2.32v.083c.251.084.515.192.819.323Z" clip-rule="evenodd"/>\n </svg>\n <span>upload a signature</span>\n </label>\n </p>\n ';let d=document.createElement("p");d.innerHTML='\n <button data-variant="solid" type="button" name="publish" id="publish">\n <span>\n Continue\n </span>\n <svg\n aria-hidden="true"\n width="25"\n height="24"\n fill="none"\n xmlns="http://www.w3.org/2000/svg"\n >\n <path\n d="M7 12h11m0 0-4.588-4M18 12l-4.588 4"\n stroke="#fff"\n stroke-width="1.5"\n stroke-linecap="round"\n stroke-linejoin="round"\n />\n </svg>\n </button>\n ',i.appendChild(s),i.appendChild(o),i.appendChild(n),this.allowUpload&&i.appendChild(p),i.appendChild(d),t.appendChild(e),t.appendChild(i),this.core=new f(n),this.errorMessage=s.querySelector("#error"),window&&(window.onresize=this.resizeCanvas()),this.clearSignatureButton=o.querySelector("#clear"),this.clearSignatureButton.addEventListener("click",()=>this.clearSignature()),this.uploadSignatureButton=p.querySelector("#upload-signature"),this.uploadSignatureButton.addEventListener("change",v=>this.uploadSignature(v)),this.publishSignatureButton=d.querySelector("#publish"),this.publishSignatureButton.addEventListener("click",()=>this.publishSignature())}disconnectedCallback(){this.publishSignatureButton.removeEventListener("click",()=>this.publishSignature()),this.clearSignatureButton.removeEventListener("click",()=>this.clearSignature()),this.uploadSignatureButton.removeEventListener("change",t=>this.uploadSignature(t))}resizeCanvas(){let t=this.shadowRoot.querySelector("canvas"),e=Math.max(window.devicePixelRatio||1,1);t.width=(t.offsetWidth||t.width)*e,t.height=(t.offsetHeight||t.height)*e,t.getContext("2d").scale(e,e),this.core.fromData(this.core.toData())}publishSignature(){try{this.resetErrorMessage();let t=this.shadowRoot.querySelector("img"),e=t?t.src:void 0;if(!e&&!this.core.isEmpty()&&(e=this.core.toDataURL("image/svg+xml")),e)this.dispatchEvent(new CustomEvent("signature-pad.publish",{detail:e}));else throw new Error("No signature present. ".concat(this.allowUpload?"Draw or upload":"Draw"," a signature"))}catch(t){this.handleError(t.message)}}resetErrorMessage(){this.errorMessage.textContent=""}handleError(t){this.errorMessage.textContent=t}clearSignature(){this.resetErrorMessage();let t=this.shadowRoot.querySelector("canvas"),e=this.shadowRoot.querySelector("img");e&&(e.remove(),t.removeAttribute("hidden")),this.core.clear()}previewUpload(t){let e=this.shadowRoot.querySelector("canvas"),i=this.shadowRoot.querySelector("img");i||(i=document.createElement("img")),i.src=t,i.setAttribute("part","upload-preview-image"),e.setAttribute("hidden",!0),e.insertAdjacentElement("afterend",i)}async uploadSignature(t){try{this.resetErrorMessage();let{files:e}=t.target,i=await E.retrieve(e);this.previewUpload(i)}catch(e){this.handleError(e.message)}}get allowUpload(){return this.hasAttribute("allow-upload")}get themeColor(){return this.getAttribute("theme-color")||"#001096"}};"customElements"in window&&!window.customElements.get("smileid-signature-pad")&&window.customElements.define("smileid-signature-pad",_);var P=_;var z=P;})();
|
|
1
|
+
(() => {
|
|
2
|
+
var C = Object.defineProperty;
|
|
3
|
+
var M = (u, t, e) =>
|
|
4
|
+
t in u
|
|
5
|
+
? C(u, t, { enumerable: !0, configurable: !0, writable: !0, value: e })
|
|
6
|
+
: (u[t] = e);
|
|
7
|
+
var x = (u, t, e) => M(u, typeof t != 'symbol' ? t + '' : t, e);
|
|
8
|
+
var w = class {
|
|
9
|
+
constructor(t, e, i, s) {
|
|
10
|
+
if (isNaN(t) || isNaN(e))
|
|
11
|
+
throw new Error('Point is invalid: ('.concat(t, ', ').concat(e, ')'));
|
|
12
|
+
((this.x = +t),
|
|
13
|
+
(this.y = +e),
|
|
14
|
+
(this.pressure = i || 0),
|
|
15
|
+
(this.time = s || Date.now()));
|
|
16
|
+
}
|
|
17
|
+
distanceTo(t) {
|
|
18
|
+
return Math.sqrt(Math.pow(this.x - t.x, 2) + Math.pow(this.y - t.y, 2));
|
|
19
|
+
}
|
|
20
|
+
equals(t) {
|
|
21
|
+
return (
|
|
22
|
+
this.x === t.x &&
|
|
23
|
+
this.y === t.y &&
|
|
24
|
+
this.pressure === t.pressure &&
|
|
25
|
+
this.time === t.time
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
velocityFrom(t) {
|
|
29
|
+
return this.time !== t.time
|
|
30
|
+
? this.distanceTo(t) / (this.time - t.time)
|
|
31
|
+
: 0;
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
y = class u {
|
|
35
|
+
static fromPoints(t, e) {
|
|
36
|
+
let i = this.calculateControlPoints(t[0], t[1], t[2]).c2,
|
|
37
|
+
s = this.calculateControlPoints(t[1], t[2], t[3]).c1;
|
|
38
|
+
return new u(t[1], i, s, t[2], e.start, e.end);
|
|
39
|
+
}
|
|
40
|
+
static calculateControlPoints(t, e, i) {
|
|
41
|
+
let s = t.x - e.x,
|
|
42
|
+
o = t.y - e.y,
|
|
43
|
+
n = e.x - i.x,
|
|
44
|
+
h = e.y - i.y,
|
|
45
|
+
a = { x: (t.x + e.x) / 2, y: (t.y + e.y) / 2 },
|
|
46
|
+
r = { x: (e.x + i.x) / 2, y: (e.y + i.y) / 2 },
|
|
47
|
+
c = Math.sqrt(s * s + o * o),
|
|
48
|
+
l = Math.sqrt(n * n + h * h),
|
|
49
|
+
m = a.x - r.x,
|
|
50
|
+
p = a.y - r.y,
|
|
51
|
+
d = l / (c + l),
|
|
52
|
+
v = { x: r.x + m * d, y: r.y + p * d },
|
|
53
|
+
S = e.x - v.x,
|
|
54
|
+
k = e.y - v.y;
|
|
55
|
+
return { c1: new w(a.x + S, a.y + k), c2: new w(r.x + S, r.y + k) };
|
|
56
|
+
}
|
|
57
|
+
constructor(t, e, i, s, o, n) {
|
|
58
|
+
((this.startPoint = t),
|
|
59
|
+
(this.control2 = e),
|
|
60
|
+
(this.control1 = i),
|
|
61
|
+
(this.endPoint = s),
|
|
62
|
+
(this.startWidth = o),
|
|
63
|
+
(this.endWidth = n));
|
|
64
|
+
}
|
|
65
|
+
length() {
|
|
66
|
+
let e = 0,
|
|
67
|
+
i,
|
|
68
|
+
s;
|
|
69
|
+
for (let o = 0; o <= 10; o += 1) {
|
|
70
|
+
let n = o / 10,
|
|
71
|
+
h = this.point(
|
|
72
|
+
n,
|
|
73
|
+
this.startPoint.x,
|
|
74
|
+
this.control1.x,
|
|
75
|
+
this.control2.x,
|
|
76
|
+
this.endPoint.x,
|
|
77
|
+
),
|
|
78
|
+
a = this.point(
|
|
79
|
+
n,
|
|
80
|
+
this.startPoint.y,
|
|
81
|
+
this.control1.y,
|
|
82
|
+
this.control2.y,
|
|
83
|
+
this.endPoint.y,
|
|
84
|
+
);
|
|
85
|
+
if (o > 0) {
|
|
86
|
+
let r = h - i,
|
|
87
|
+
c = a - s;
|
|
88
|
+
e += Math.sqrt(r * r + c * c);
|
|
89
|
+
}
|
|
90
|
+
((i = h), (s = a));
|
|
91
|
+
}
|
|
92
|
+
return e;
|
|
93
|
+
}
|
|
94
|
+
point(t, e, i, s, o) {
|
|
95
|
+
return (
|
|
96
|
+
e * (1 - t) * (1 - t) * (1 - t) +
|
|
97
|
+
3 * i * (1 - t) * (1 - t) * t +
|
|
98
|
+
3 * s * (1 - t) * t * t +
|
|
99
|
+
o * t * t * t
|
|
100
|
+
);
|
|
101
|
+
}
|
|
102
|
+
},
|
|
103
|
+
b = class {
|
|
104
|
+
constructor() {
|
|
105
|
+
try {
|
|
106
|
+
this._et = new EventTarget();
|
|
107
|
+
} catch (t) {
|
|
108
|
+
this._et = document;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
addEventListener(t, e, i) {
|
|
112
|
+
this._et.addEventListener(t, e, i);
|
|
113
|
+
}
|
|
114
|
+
dispatchEvent(t) {
|
|
115
|
+
return this._et.dispatchEvent(t);
|
|
116
|
+
}
|
|
117
|
+
removeEventListener(t, e, i) {
|
|
118
|
+
this._et.removeEventListener(t, e, i);
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
function L(u, t = 250) {
|
|
122
|
+
let e = 0,
|
|
123
|
+
i = null,
|
|
124
|
+
s,
|
|
125
|
+
o,
|
|
126
|
+
n,
|
|
127
|
+
h = () => {
|
|
128
|
+
((e = Date.now()),
|
|
129
|
+
(i = null),
|
|
130
|
+
(s = u.apply(o, n)),
|
|
131
|
+
i || ((o = null), (n = [])));
|
|
132
|
+
};
|
|
133
|
+
return function (...r) {
|
|
134
|
+
let c = Date.now(),
|
|
135
|
+
l = t - (c - e);
|
|
136
|
+
return (
|
|
137
|
+
(o = this),
|
|
138
|
+
(n = r),
|
|
139
|
+
l <= 0 || l > t
|
|
140
|
+
? (i && (clearTimeout(i), (i = null)),
|
|
141
|
+
(e = c),
|
|
142
|
+
(s = u.apply(o, n)),
|
|
143
|
+
i || ((o = null), (n = [])))
|
|
144
|
+
: i || (i = window.setTimeout(h, l)),
|
|
145
|
+
s
|
|
146
|
+
);
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
var f = class u extends b {
|
|
150
|
+
constructor(t, e = {}) {
|
|
151
|
+
var i, s, o;
|
|
152
|
+
(super(),
|
|
153
|
+
(this.canvas = t),
|
|
154
|
+
(this._drawingStroke = !1),
|
|
155
|
+
(this._isEmpty = !0),
|
|
156
|
+
(this._lastPoints = []),
|
|
157
|
+
(this._data = []),
|
|
158
|
+
(this._lastVelocity = 0),
|
|
159
|
+
(this._lastWidth = 0),
|
|
160
|
+
(this._handleMouseDown = (n) => {
|
|
161
|
+
!this._isLeftButtonPressed(n, !0) ||
|
|
162
|
+
this._drawingStroke ||
|
|
163
|
+
this._strokeBegin(this._pointerEventToSignatureEvent(n));
|
|
164
|
+
}),
|
|
165
|
+
(this._handleMouseMove = (n) => {
|
|
166
|
+
if (!this._isLeftButtonPressed(n, !0) || !this._drawingStroke) {
|
|
167
|
+
this._strokeEnd(this._pointerEventToSignatureEvent(n), !1);
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
this._strokeMoveUpdate(this._pointerEventToSignatureEvent(n));
|
|
171
|
+
}),
|
|
172
|
+
(this._handleMouseUp = (n) => {
|
|
173
|
+
this._isLeftButtonPressed(n) ||
|
|
174
|
+
this._strokeEnd(this._pointerEventToSignatureEvent(n));
|
|
175
|
+
}),
|
|
176
|
+
(this._handleTouchStart = (n) => {
|
|
177
|
+
n.targetTouches.length !== 1 ||
|
|
178
|
+
this._drawingStroke ||
|
|
179
|
+
(n.cancelable && n.preventDefault(),
|
|
180
|
+
this._strokeBegin(this._touchEventToSignatureEvent(n)));
|
|
181
|
+
}),
|
|
182
|
+
(this._handleTouchMove = (n) => {
|
|
183
|
+
if (n.targetTouches.length === 1) {
|
|
184
|
+
if ((n.cancelable && n.preventDefault(), !this._drawingStroke)) {
|
|
185
|
+
this._strokeEnd(this._touchEventToSignatureEvent(n), !1);
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
this._strokeMoveUpdate(this._touchEventToSignatureEvent(n));
|
|
189
|
+
}
|
|
190
|
+
}),
|
|
191
|
+
(this._handleTouchEnd = (n) => {
|
|
192
|
+
n.targetTouches.length === 0 &&
|
|
193
|
+
(n.cancelable && n.preventDefault(),
|
|
194
|
+
this.canvas.removeEventListener('touchmove', this._handleTouchMove),
|
|
195
|
+
this._strokeEnd(this._touchEventToSignatureEvent(n)));
|
|
196
|
+
}),
|
|
197
|
+
(this._handlePointerDown = (n) => {
|
|
198
|
+
!this._isLeftButtonPressed(n) ||
|
|
199
|
+
this._drawingStroke ||
|
|
200
|
+
(n.preventDefault(),
|
|
201
|
+
this._strokeBegin(this._pointerEventToSignatureEvent(n)));
|
|
202
|
+
}),
|
|
203
|
+
(this._handlePointerMove = (n) => {
|
|
204
|
+
if (!this._isLeftButtonPressed(n, !0) || !this._drawingStroke) {
|
|
205
|
+
this._strokeEnd(this._pointerEventToSignatureEvent(n), !1);
|
|
206
|
+
return;
|
|
207
|
+
}
|
|
208
|
+
(n.preventDefault(),
|
|
209
|
+
this._strokeMoveUpdate(this._pointerEventToSignatureEvent(n)));
|
|
210
|
+
}),
|
|
211
|
+
(this._handlePointerUp = (n) => {
|
|
212
|
+
this._isLeftButtonPressed(n) ||
|
|
213
|
+
(n.preventDefault(),
|
|
214
|
+
this._strokeEnd(this._pointerEventToSignatureEvent(n)));
|
|
215
|
+
}),
|
|
216
|
+
(this.velocityFilterWeight = e.velocityFilterWeight || 0.7),
|
|
217
|
+
(this.minWidth = e.minWidth || 0.5),
|
|
218
|
+
(this.maxWidth = e.maxWidth || 2.5),
|
|
219
|
+
(this.throttle = (i = e.throttle) !== null && i !== void 0 ? i : 16),
|
|
220
|
+
(this.minDistance =
|
|
221
|
+
(s = e.minDistance) !== null && s !== void 0 ? s : 5),
|
|
222
|
+
(this.dotSize = e.dotSize || 0),
|
|
223
|
+
(this.penColor = e.penColor || 'black'),
|
|
224
|
+
(this.backgroundColor = e.backgroundColor || 'rgba(0,0,0,0)'),
|
|
225
|
+
(this.compositeOperation = e.compositeOperation || 'source-over'),
|
|
226
|
+
(this.canvasContextOptions =
|
|
227
|
+
(o = e.canvasContextOptions) !== null && o !== void 0 ? o : {}),
|
|
228
|
+
(this._strokeMoveUpdate = this.throttle
|
|
229
|
+
? L(u.prototype._strokeUpdate, this.throttle)
|
|
230
|
+
: u.prototype._strokeUpdate),
|
|
231
|
+
(this._ctx = t.getContext('2d', this.canvasContextOptions)),
|
|
232
|
+
this.clear(),
|
|
233
|
+
this.on());
|
|
234
|
+
}
|
|
235
|
+
clear() {
|
|
236
|
+
let { _ctx: t, canvas: e } = this;
|
|
237
|
+
((t.fillStyle = this.backgroundColor),
|
|
238
|
+
t.clearRect(0, 0, e.width, e.height),
|
|
239
|
+
t.fillRect(0, 0, e.width, e.height),
|
|
240
|
+
(this._data = []),
|
|
241
|
+
this._reset(this._getPointGroupOptions()),
|
|
242
|
+
(this._isEmpty = !0));
|
|
243
|
+
}
|
|
244
|
+
fromDataURL(t, e = {}) {
|
|
245
|
+
return new Promise((i, s) => {
|
|
246
|
+
let o = new Image(),
|
|
247
|
+
n = e.ratio || window.devicePixelRatio || 1,
|
|
248
|
+
h = e.width || this.canvas.width / n,
|
|
249
|
+
a = e.height || this.canvas.height / n,
|
|
250
|
+
r = e.xOffset || 0,
|
|
251
|
+
c = e.yOffset || 0;
|
|
252
|
+
(this._reset(this._getPointGroupOptions()),
|
|
253
|
+
(o.onload = () => {
|
|
254
|
+
(this._ctx.drawImage(o, r, c, h, a), i());
|
|
255
|
+
}),
|
|
256
|
+
(o.onerror = (l) => {
|
|
257
|
+
s(l);
|
|
258
|
+
}),
|
|
259
|
+
(o.crossOrigin = 'anonymous'),
|
|
260
|
+
(o.src = t),
|
|
261
|
+
(this._isEmpty = !1));
|
|
262
|
+
});
|
|
263
|
+
}
|
|
264
|
+
toDataURL(t = 'image/png', e) {
|
|
265
|
+
switch (t) {
|
|
266
|
+
case 'image/svg+xml':
|
|
267
|
+
return (
|
|
268
|
+
typeof e != 'object' && (e = void 0),
|
|
269
|
+
'data:image/svg+xml;base64,'.concat(btoa(this.toSVG(e)))
|
|
270
|
+
);
|
|
271
|
+
default:
|
|
272
|
+
return (
|
|
273
|
+
typeof e != 'number' && (e = void 0),
|
|
274
|
+
this.canvas.toDataURL(t, e)
|
|
275
|
+
);
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
on() {
|
|
279
|
+
((this.canvas.style.touchAction = 'none'),
|
|
280
|
+
(this.canvas.style.msTouchAction = 'none'),
|
|
281
|
+
(this.canvas.style.userSelect = 'none'));
|
|
282
|
+
let t =
|
|
283
|
+
/Macintosh/.test(navigator.userAgent) && 'ontouchstart' in document;
|
|
284
|
+
window.PointerEvent && !t
|
|
285
|
+
? this._handlePointerEvents()
|
|
286
|
+
: (this._handleMouseEvents(),
|
|
287
|
+
'ontouchstart' in window && this._handleTouchEvents());
|
|
288
|
+
}
|
|
289
|
+
off() {
|
|
290
|
+
((this.canvas.style.touchAction = 'auto'),
|
|
291
|
+
(this.canvas.style.msTouchAction = 'auto'),
|
|
292
|
+
(this.canvas.style.userSelect = 'auto'),
|
|
293
|
+
this.canvas.removeEventListener('pointerdown', this._handlePointerDown),
|
|
294
|
+
this.canvas.removeEventListener('mousedown', this._handleMouseDown),
|
|
295
|
+
this.canvas.removeEventListener('touchstart', this._handleTouchStart),
|
|
296
|
+
this._removeMoveUpEventListeners());
|
|
297
|
+
}
|
|
298
|
+
_getListenerFunctions() {
|
|
299
|
+
var t;
|
|
300
|
+
let e =
|
|
301
|
+
window.document === this.canvas.ownerDocument
|
|
302
|
+
? window
|
|
303
|
+
: (t = this.canvas.ownerDocument.defaultView) !== null && t !== void 0
|
|
304
|
+
? t
|
|
305
|
+
: this.canvas.ownerDocument;
|
|
306
|
+
return {
|
|
307
|
+
addEventListener: e.addEventListener.bind(e),
|
|
308
|
+
removeEventListener: e.removeEventListener.bind(e),
|
|
309
|
+
};
|
|
310
|
+
}
|
|
311
|
+
_removeMoveUpEventListeners() {
|
|
312
|
+
let { removeEventListener: t } = this._getListenerFunctions();
|
|
313
|
+
(t('pointermove', this._handlePointerMove),
|
|
314
|
+
t('pointerup', this._handlePointerUp),
|
|
315
|
+
t('mousemove', this._handleMouseMove),
|
|
316
|
+
t('mouseup', this._handleMouseUp),
|
|
317
|
+
t('touchmove', this._handleTouchMove),
|
|
318
|
+
t('touchend', this._handleTouchEnd));
|
|
319
|
+
}
|
|
320
|
+
isEmpty() {
|
|
321
|
+
return this._isEmpty;
|
|
322
|
+
}
|
|
323
|
+
fromData(t, { clear: e = !0 } = {}) {
|
|
324
|
+
(e && this.clear(),
|
|
325
|
+
this._fromData(t, this._drawCurve.bind(this), this._drawDot.bind(this)),
|
|
326
|
+
(this._data = this._data.concat(t)));
|
|
327
|
+
}
|
|
328
|
+
toData() {
|
|
329
|
+
return this._data;
|
|
330
|
+
}
|
|
331
|
+
_isLeftButtonPressed(t, e) {
|
|
332
|
+
return e ? t.buttons === 1 : (t.buttons & 1) === 1;
|
|
333
|
+
}
|
|
334
|
+
_pointerEventToSignatureEvent(t) {
|
|
335
|
+
return {
|
|
336
|
+
event: t,
|
|
337
|
+
type: t.type,
|
|
338
|
+
x: t.clientX,
|
|
339
|
+
y: t.clientY,
|
|
340
|
+
pressure: 'pressure' in t ? t.pressure : 0,
|
|
341
|
+
};
|
|
342
|
+
}
|
|
343
|
+
_touchEventToSignatureEvent(t) {
|
|
344
|
+
let e = t.changedTouches[0];
|
|
345
|
+
return {
|
|
346
|
+
event: t,
|
|
347
|
+
type: t.type,
|
|
348
|
+
x: e.clientX,
|
|
349
|
+
y: e.clientY,
|
|
350
|
+
pressure: e.force,
|
|
351
|
+
};
|
|
352
|
+
}
|
|
353
|
+
_getPointGroupOptions(t) {
|
|
354
|
+
return {
|
|
355
|
+
penColor: t && 'penColor' in t ? t.penColor : this.penColor,
|
|
356
|
+
dotSize: t && 'dotSize' in t ? t.dotSize : this.dotSize,
|
|
357
|
+
minWidth: t && 'minWidth' in t ? t.minWidth : this.minWidth,
|
|
358
|
+
maxWidth: t && 'maxWidth' in t ? t.maxWidth : this.maxWidth,
|
|
359
|
+
velocityFilterWeight:
|
|
360
|
+
t && 'velocityFilterWeight' in t
|
|
361
|
+
? t.velocityFilterWeight
|
|
362
|
+
: this.velocityFilterWeight,
|
|
363
|
+
compositeOperation:
|
|
364
|
+
t && 'compositeOperation' in t
|
|
365
|
+
? t.compositeOperation
|
|
366
|
+
: this.compositeOperation,
|
|
367
|
+
};
|
|
368
|
+
}
|
|
369
|
+
_strokeBegin(t) {
|
|
370
|
+
if (
|
|
371
|
+
!this.dispatchEvent(
|
|
372
|
+
new CustomEvent('beginStroke', { detail: t, cancelable: !0 }),
|
|
373
|
+
)
|
|
374
|
+
)
|
|
375
|
+
return;
|
|
376
|
+
let { addEventListener: i } = this._getListenerFunctions();
|
|
377
|
+
switch (t.event.type) {
|
|
378
|
+
case 'mousedown':
|
|
379
|
+
(i('mousemove', this._handleMouseMove),
|
|
380
|
+
i('mouseup', this._handleMouseUp));
|
|
381
|
+
break;
|
|
382
|
+
case 'touchstart':
|
|
383
|
+
(i('touchmove', this._handleTouchMove),
|
|
384
|
+
i('touchend', this._handleTouchEnd));
|
|
385
|
+
break;
|
|
386
|
+
case 'pointerdown':
|
|
387
|
+
(i('pointermove', this._handlePointerMove),
|
|
388
|
+
i('pointerup', this._handlePointerUp));
|
|
389
|
+
break;
|
|
390
|
+
}
|
|
391
|
+
this._drawingStroke = !0;
|
|
392
|
+
let s = this._getPointGroupOptions(),
|
|
393
|
+
o = Object.assign(Object.assign({}, s), { points: [] });
|
|
394
|
+
(this._data.push(o), this._reset(s), this._strokeUpdate(t));
|
|
395
|
+
}
|
|
396
|
+
_strokeUpdate(t) {
|
|
397
|
+
if (!this._drawingStroke) return;
|
|
398
|
+
if (this._data.length === 0) {
|
|
399
|
+
this._strokeBegin(t);
|
|
400
|
+
return;
|
|
401
|
+
}
|
|
402
|
+
this.dispatchEvent(new CustomEvent('beforeUpdateStroke', { detail: t }));
|
|
403
|
+
let e = this._createPoint(t.x, t.y, t.pressure),
|
|
404
|
+
i = this._data[this._data.length - 1],
|
|
405
|
+
s = i.points,
|
|
406
|
+
o = s.length > 0 && s[s.length - 1],
|
|
407
|
+
n = o ? e.distanceTo(o) <= this.minDistance : !1,
|
|
408
|
+
h = this._getPointGroupOptions(i);
|
|
409
|
+
if (!o || !(o && n)) {
|
|
410
|
+
let a = this._addPoint(e, h);
|
|
411
|
+
(o ? a && this._drawCurve(a, h) : this._drawDot(e, h),
|
|
412
|
+
s.push({ time: e.time, x: e.x, y: e.y, pressure: e.pressure }));
|
|
413
|
+
}
|
|
414
|
+
this.dispatchEvent(new CustomEvent('afterUpdateStroke', { detail: t }));
|
|
415
|
+
}
|
|
416
|
+
_strokeEnd(t, e = !0) {
|
|
417
|
+
(this._removeMoveUpEventListeners(),
|
|
418
|
+
this._drawingStroke &&
|
|
419
|
+
(e && this._strokeUpdate(t),
|
|
420
|
+
(this._drawingStroke = !1),
|
|
421
|
+
this.dispatchEvent(new CustomEvent('endStroke', { detail: t }))));
|
|
422
|
+
}
|
|
423
|
+
_handlePointerEvents() {
|
|
424
|
+
((this._drawingStroke = !1),
|
|
425
|
+
this.canvas.addEventListener('pointerdown', this._handlePointerDown));
|
|
426
|
+
}
|
|
427
|
+
_handleMouseEvents() {
|
|
428
|
+
((this._drawingStroke = !1),
|
|
429
|
+
this.canvas.addEventListener('mousedown', this._handleMouseDown));
|
|
430
|
+
}
|
|
431
|
+
_handleTouchEvents() {
|
|
432
|
+
this.canvas.addEventListener('touchstart', this._handleTouchStart);
|
|
433
|
+
}
|
|
434
|
+
_reset(t) {
|
|
435
|
+
((this._lastPoints = []),
|
|
436
|
+
(this._lastVelocity = 0),
|
|
437
|
+
(this._lastWidth = (t.minWidth + t.maxWidth) / 2),
|
|
438
|
+
(this._ctx.fillStyle = t.penColor),
|
|
439
|
+
(this._ctx.globalCompositeOperation = t.compositeOperation));
|
|
440
|
+
}
|
|
441
|
+
_createPoint(t, e, i) {
|
|
442
|
+
let s = this.canvas.getBoundingClientRect();
|
|
443
|
+
return new w(t - s.left, e - s.top, i, new Date().getTime());
|
|
444
|
+
}
|
|
445
|
+
_addPoint(t, e) {
|
|
446
|
+
let { _lastPoints: i } = this;
|
|
447
|
+
if ((i.push(t), i.length > 2)) {
|
|
448
|
+
i.length === 3 && i.unshift(i[0]);
|
|
449
|
+
let s = this._calculateCurveWidths(i[1], i[2], e),
|
|
450
|
+
o = y.fromPoints(i, s);
|
|
451
|
+
return (i.shift(), o);
|
|
452
|
+
}
|
|
453
|
+
return null;
|
|
454
|
+
}
|
|
455
|
+
_calculateCurveWidths(t, e, i) {
|
|
456
|
+
let s =
|
|
457
|
+
i.velocityFilterWeight * e.velocityFrom(t) +
|
|
458
|
+
(1 - i.velocityFilterWeight) * this._lastVelocity,
|
|
459
|
+
o = this._strokeWidth(s, i),
|
|
460
|
+
n = { end: o, start: this._lastWidth };
|
|
461
|
+
return ((this._lastVelocity = s), (this._lastWidth = o), n);
|
|
462
|
+
}
|
|
463
|
+
_strokeWidth(t, e) {
|
|
464
|
+
return Math.max(e.maxWidth / (t + 1), e.minWidth);
|
|
465
|
+
}
|
|
466
|
+
_drawCurveSegment(t, e, i) {
|
|
467
|
+
let s = this._ctx;
|
|
468
|
+
(s.moveTo(t, e),
|
|
469
|
+
s.arc(t, e, i, 0, 2 * Math.PI, !1),
|
|
470
|
+
(this._isEmpty = !1));
|
|
471
|
+
}
|
|
472
|
+
_drawCurve(t, e) {
|
|
473
|
+
let i = this._ctx,
|
|
474
|
+
s = t.endWidth - t.startWidth,
|
|
475
|
+
o = Math.ceil(t.length()) * 2;
|
|
476
|
+
(i.beginPath(), (i.fillStyle = e.penColor));
|
|
477
|
+
for (let n = 0; n < o; n += 1) {
|
|
478
|
+
let h = n / o,
|
|
479
|
+
a = h * h,
|
|
480
|
+
r = a * h,
|
|
481
|
+
c = 1 - h,
|
|
482
|
+
l = c * c,
|
|
483
|
+
m = l * c,
|
|
484
|
+
p = m * t.startPoint.x;
|
|
485
|
+
((p += 3 * l * h * t.control1.x),
|
|
486
|
+
(p += 3 * c * a * t.control2.x),
|
|
487
|
+
(p += r * t.endPoint.x));
|
|
488
|
+
let d = m * t.startPoint.y;
|
|
489
|
+
((d += 3 * l * h * t.control1.y),
|
|
490
|
+
(d += 3 * c * a * t.control2.y),
|
|
491
|
+
(d += r * t.endPoint.y));
|
|
492
|
+
let v = Math.min(t.startWidth + r * s, e.maxWidth);
|
|
493
|
+
this._drawCurveSegment(p, d, v);
|
|
494
|
+
}
|
|
495
|
+
(i.closePath(), i.fill());
|
|
496
|
+
}
|
|
497
|
+
_drawDot(t, e) {
|
|
498
|
+
let i = this._ctx,
|
|
499
|
+
s = e.dotSize > 0 ? e.dotSize : (e.minWidth + e.maxWidth) / 2;
|
|
500
|
+
(i.beginPath(),
|
|
501
|
+
this._drawCurveSegment(t.x, t.y, s),
|
|
502
|
+
i.closePath(),
|
|
503
|
+
(i.fillStyle = e.penColor),
|
|
504
|
+
i.fill());
|
|
505
|
+
}
|
|
506
|
+
_fromData(t, e, i) {
|
|
507
|
+
for (let s of t) {
|
|
508
|
+
let { points: o } = s,
|
|
509
|
+
n = this._getPointGroupOptions(s);
|
|
510
|
+
if (o.length > 1)
|
|
511
|
+
for (let h = 0; h < o.length; h += 1) {
|
|
512
|
+
let a = o[h],
|
|
513
|
+
r = new w(a.x, a.y, a.pressure, a.time);
|
|
514
|
+
h === 0 && this._reset(n);
|
|
515
|
+
let c = this._addPoint(r, n);
|
|
516
|
+
c && e(c, n);
|
|
517
|
+
}
|
|
518
|
+
else (this._reset(n), i(o[0], n));
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
toSVG({ includeBackgroundColor: t = !1 } = {}) {
|
|
522
|
+
let e = this._data,
|
|
523
|
+
i = Math.max(window.devicePixelRatio || 1, 1),
|
|
524
|
+
s = 0,
|
|
525
|
+
o = 0,
|
|
526
|
+
n = this.canvas.width / i,
|
|
527
|
+
h = this.canvas.height / i,
|
|
528
|
+
a = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
|
|
529
|
+
if (
|
|
530
|
+
(a.setAttribute('xmlns', 'http://www.w3.org/2000/svg'),
|
|
531
|
+
a.setAttribute('xmlns:xlink', 'http://www.w3.org/1999/xlink'),
|
|
532
|
+
a.setAttribute(
|
|
533
|
+
'viewBox',
|
|
534
|
+
''.concat(s, ' ').concat(o, ' ').concat(n, ' ').concat(h),
|
|
535
|
+
),
|
|
536
|
+
a.setAttribute('width', n.toString()),
|
|
537
|
+
a.setAttribute('height', h.toString()),
|
|
538
|
+
t && this.backgroundColor)
|
|
539
|
+
) {
|
|
540
|
+
let r = document.createElement('rect');
|
|
541
|
+
(r.setAttribute('width', '100%'),
|
|
542
|
+
r.setAttribute('height', '100%'),
|
|
543
|
+
r.setAttribute('fill', this.backgroundColor),
|
|
544
|
+
a.appendChild(r));
|
|
545
|
+
}
|
|
546
|
+
return (
|
|
547
|
+
this._fromData(
|
|
548
|
+
e,
|
|
549
|
+
(r, { penColor: c }) => {
|
|
550
|
+
let l = document.createElement('path');
|
|
551
|
+
if (
|
|
552
|
+
!isNaN(r.control1.x) &&
|
|
553
|
+
!isNaN(r.control1.y) &&
|
|
554
|
+
!isNaN(r.control2.x) &&
|
|
555
|
+
!isNaN(r.control2.y)
|
|
556
|
+
) {
|
|
557
|
+
let m =
|
|
558
|
+
'M '
|
|
559
|
+
.concat(r.startPoint.x.toFixed(3), ',')
|
|
560
|
+
.concat(r.startPoint.y.toFixed(3), ' ') +
|
|
561
|
+
'C '
|
|
562
|
+
.concat(r.control1.x.toFixed(3), ',')
|
|
563
|
+
.concat(r.control1.y.toFixed(3), ' ') +
|
|
564
|
+
''
|
|
565
|
+
.concat(r.control2.x.toFixed(3), ',')
|
|
566
|
+
.concat(r.control2.y.toFixed(3), ' ') +
|
|
567
|
+
''
|
|
568
|
+
.concat(r.endPoint.x.toFixed(3), ',')
|
|
569
|
+
.concat(r.endPoint.y.toFixed(3));
|
|
570
|
+
(l.setAttribute('d', m),
|
|
571
|
+
l.setAttribute('stroke-width', (r.endWidth * 2.25).toFixed(3)),
|
|
572
|
+
l.setAttribute('stroke', c),
|
|
573
|
+
l.setAttribute('fill', 'none'),
|
|
574
|
+
l.setAttribute('stroke-linecap', 'round'),
|
|
575
|
+
a.appendChild(l));
|
|
576
|
+
}
|
|
577
|
+
},
|
|
578
|
+
(r, { penColor: c, dotSize: l, minWidth: m, maxWidth: p }) => {
|
|
579
|
+
let d = document.createElement('circle'),
|
|
580
|
+
v = l > 0 ? l : (m + p) / 2;
|
|
581
|
+
(d.setAttribute('r', v.toString()),
|
|
582
|
+
d.setAttribute('cx', r.x.toString()),
|
|
583
|
+
d.setAttribute('cy', r.y.toString()),
|
|
584
|
+
d.setAttribute('fill', c),
|
|
585
|
+
a.appendChild(d));
|
|
586
|
+
},
|
|
587
|
+
),
|
|
588
|
+
a.outerHTML
|
|
589
|
+
);
|
|
590
|
+
}
|
|
591
|
+
};
|
|
592
|
+
var g = class g {
|
|
593
|
+
static getHumanSize(t) {
|
|
594
|
+
let e = ['B', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'],
|
|
595
|
+
i = Math.min(Math.floor(Math.log(t) / Math.log(1024)), e.length - 1),
|
|
596
|
+
s = t / 1024 ** i;
|
|
597
|
+
return i === 0
|
|
598
|
+
? ''.concat(t, ' bytes')
|
|
599
|
+
: ''.concat(s.toFixed(0), ' ').concat(e[i]);
|
|
600
|
+
}
|
|
601
|
+
static getData(t) {
|
|
602
|
+
return new Promise((e, i) => {
|
|
603
|
+
let s = new FileReader();
|
|
604
|
+
((s.onload = (o) => {
|
|
605
|
+
e(o.target.result);
|
|
606
|
+
}),
|
|
607
|
+
(s.onerror = () => {
|
|
608
|
+
i(
|
|
609
|
+
new Error(
|
|
610
|
+
'An error occurred reading the file. Please check the file, and try again',
|
|
611
|
+
),
|
|
612
|
+
);
|
|
613
|
+
}),
|
|
614
|
+
s.readAsDataURL(t));
|
|
615
|
+
});
|
|
616
|
+
}
|
|
617
|
+
static async retrieve(t) {
|
|
618
|
+
if (t.length > 1)
|
|
619
|
+
throw new Error('Only one file upload is permitted at a time');
|
|
620
|
+
let e = t[0];
|
|
621
|
+
if (!g.supportedTypes.includes(e.type))
|
|
622
|
+
throw new Error(
|
|
623
|
+
'Unsupported file format. Please ensure that you are providing a JPG, PNG or SVG image',
|
|
624
|
+
);
|
|
625
|
+
if (e.size > g.memoryLimit)
|
|
626
|
+
throw new Error(
|
|
627
|
+
''
|
|
628
|
+
.concat(
|
|
629
|
+
e.name,
|
|
630
|
+
' is too large. Please ensure that the file is less than ',
|
|
631
|
+
)
|
|
632
|
+
.concat(g.getHumanSize(g.memoryLimit), '.'),
|
|
633
|
+
);
|
|
634
|
+
return await g.getData(e);
|
|
635
|
+
}
|
|
636
|
+
};
|
|
637
|
+
(x(g, 'memoryLimit', 2048e3),
|
|
638
|
+
x(g, 'supportedTypes', ['image/jpeg', 'image/png', 'image/svg+xml']));
|
|
639
|
+
var E = g,
|
|
640
|
+
_ = class extends HTMLElement {
|
|
641
|
+
connectedCallback() {
|
|
642
|
+
let t = this.attachShadow({ mode: 'open' }),
|
|
643
|
+
e = document.createElement('style');
|
|
644
|
+
e.textContent =
|
|
645
|
+
'\n:host {\n display: block;\n block-size: auto;\n inline-size: 30rem;\n max-inline-size: 100%;\n position: relative;\n --color-active: #2D2B2A;\n --color-default: #001096;\n --color-disabled: #848282;\n}\n\n:host::part(upload) {\n text-align: center;\n}\n\n:host::part(signature-controls) {\n display: inline-flex;\n position: absolute;\n top: 1rem;\n right: 1rem;\n}\n\n:host::part(upload) svg + * {\n margin-inline-start: .5rem;\n}\n\n:host::part(canvas) {\n background-color: #F9F0E7;\n --dot-bg: #F9F0E7;\n --dot-color: black;\n --dot-size: 1px;\n --dot-space: 22px;\n background:\n linear-gradient(90deg, var(--dot-bg) calc(var(--dot-space) - var(--dot-size)), transparent 1%) center / var(--dot-space) var(--dot-space),\n linear-gradient(var(--dot-bg) calc(var(--dot-space) - var(--dot-size)), transparent 1%) center / var(--dot-space) var(--dot-space),\n var(--dot-color);\n border-radius: 2rem;\n inline-size: 30rem;\n max-inline-size: 100%;\n aspect-ratio: 2 / 1;\n}\n\n:host::part(upload-preview-image) {\n max-inline-size: 10rem;\n margin-inline: auto;\n}\n\n.visually-hidden {\n clip: rect(0 0 0 0); \n clip-path: inset(50%);\n height: 1px;\n overflow: hidden;\n position: absolute;\n white-space: nowrap; \n width: 1px;\n}\n\nbutton,\nlabel {\n font: inherit;\n cursor: pointer;\n}\n\nlabel {\n display: inline-flex;\n text-decoration: underline;\n}\n\nlabel svg + * {\n margin-inline-start: .5rem;\n}\n\n[type="file"] {\n display: none;\n}\n\n.center {\n text-align: center;\n margin-inline: auto;\n}\n\n.color-red {\n color: red;\n}\n\nbutton[data-variant="icon"] {\n appearance: none;\n -webkit-appearance: none;\n background-color: transparent;\n border: 0px;\n}\n\nbutton[data-variant="text"] {\n appearance: none;\n -webkit-appearance: none;\n background-color: transparent;\n border: 0px;\n text-decoration: underline;\n display: inline-flex;\n align-items: baseline;\n}\n\nbutton[data-variant="solid"] {\n --button-color: '.concat(
|
|
646
|
+
this.themeColor,
|
|
647
|
+
';\n border-radius: 2.5rem;\n border: 0;\n background-color: transparent;\n color: #fff;\n cursor: pointer;\n inline-size: 100%;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n font-size: 18px;\n font-weight: 600;\n padding: .75rem 1.5rem;\n text-align: center;\n background-color: var(--button-color);\n border: 2px solid var(--button-color);\n}\n\nbutton:hover,\nbutton:focus,\nbutton:active {\n --button-color: var(--color-active);\n}\n\nbutton:disabled {\n --button-color: var(--color-disabled);\n}\n',
|
|
648
|
+
);
|
|
649
|
+
let i = document.createElement('div'),
|
|
650
|
+
s = document.createElement('div');
|
|
651
|
+
s.innerHTML =
|
|
652
|
+
'\n <p id="error" class="color-red | center"><p>\n ';
|
|
653
|
+
let o = document.createElement('div');
|
|
654
|
+
(o.setAttribute('id', 'controls'),
|
|
655
|
+
o.setAttribute('part', 'signature-controls'),
|
|
656
|
+
(o.innerHTML =
|
|
657
|
+
'\n <button data-variant="icon" type="button" name="clear" id="clear">\n <span class="visually-hidden">\n Clear Signature\n </span>\n <svg fill="none" xmlns="http://www.w3.org/2000/svg" width="18" viewBox="0 0 17 18">\n <path d="M3.314 15.646a8.004 8.004 0 01-2.217-4.257 8.06 8.06 0 01.545-4.655l1.789.788a6.062 6.062 0 001.264 6.737 6.033 6.033 0 008.551 0c2.358-2.37 2.358-6.224 0-8.592a5.996 5.996 0 00-4.405-1.782l.662 2.354-3.128-.796-3.127-.796 2.25-2.324L7.748 0l.55 1.953a7.966 7.966 0 016.33 2.326 8.004 8.004 0 012.342 5.684 8.005 8.005 0 01-2.343 5.683A7.928 7.928 0 018.97 18a7.928 7.928 0 01-5.656-2.354z" fill="currentColor" />\n </svg>\n </button>\n '));
|
|
658
|
+
let n = document.createElement('canvas'),
|
|
659
|
+
r = this.parentElement
|
|
660
|
+
.closest(':not([hidden])')
|
|
661
|
+
.querySelector(':not([hidden])').offsetWidth,
|
|
662
|
+
l =
|
|
663
|
+
30 *
|
|
664
|
+
getComputedStyle(document.documentElement).fontSize.split('px')[0],
|
|
665
|
+
m = 2;
|
|
666
|
+
((n.width = r < l ? r : l),
|
|
667
|
+
(n.height = (r < l ? r : l) / m),
|
|
668
|
+
n.setAttribute('id', 'signature-canvas'),
|
|
669
|
+
n.setAttribute('part', 'canvas'));
|
|
670
|
+
let p = document.createElement('div');
|
|
671
|
+
(p.setAttribute('id', 'signature-upload-wrapper'),
|
|
672
|
+
(p.innerHTML =
|
|
673
|
+
'\n <p part="upload">\n <strong>or</strong>\n <label>\n <input type=\'file\' onclick=\'this.value=null;\' id=\'upload-signature\' accept=\'image/jpeg, image/png, image/svg+xml\' />\n <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="none">\n <rect width="16" height="16" fill="#F9F0E7" rx="2"/>\n <mask id="sign" width="16" height="16" x="0" y="0" maskUnits="userSpaceOnUse" style="mask-type:alpha">\n <rect width="16" height="16" fill="#D9D9D9" rx="2"/>\n </mask>\n <g mask="url(#sign)">\n <path fill="#2D2B2A" d="M0 13.333h16V16H0z"/>\n </g>\n <path fill="#2D2B2A" fill-rule="evenodd" d="M2.69 7.346a.23.23 0 0 1 .059-.073.275.275 0 0 1 .284-.034c.07.036.146.064.224.084h.12c0-.012.105-.048.105-.395a.796.796 0 0 1 .211-.61.667.667 0 0 1 .607-.096c.202.061.39.154.555.275.194.138.38.286.555.443.146.134.31.25.489.347l.092.047c.119.06.238-.023.185-.143l-.04-.12a.817.817 0 0 1-.066-.694.675.675 0 0 1 .244-.273.774.774 0 0 1 .364-.12c.324-.028.651 0 .964.083h.026c.027-.861.225-1.83.82-2.523.593-.694 1.478-.993 2.205-.837.726.155 1.307.73 1.307 1.602 0 1.34-.872 2.26-1.915 2.93.471.374.85.835 1.11 1.351.027.046.05.094.065.144h.014a.55.55 0 0 0 .079.203.44.44 0 0 0 .04.18c.002.025.011.05.026.07h-.013c.037.17.041.344.013.515a.955.955 0 0 1-.188.493 1.097 1.097 0 0 1-.433.344 1.346 1.346 0 0 1-1.122.012 2.194 2.194 0 0 1-.846-.67 5.024 5.024 0 0 1-.462-.681h-.026a.502.502 0 0 0-.106-.144.014.014 0 0 1-.01-.003.011.011 0 0 1-.003-.009.035.035 0 0 1-.013-.023.047.047 0 0 1-.011-.017.626.626 0 0 0-.055-.163.24.24 0 0 0-.014-.095h.014a3.477 3.477 0 0 1-.198-.49 6.318 6.318 0 0 1-.278-1.699L7.51 6.51c-.243-.07-.5-.094-.753-.071-.158.024-.198.071-.211.107-.014.036-.04.168.053.359.092.191.171.478.118.658a.45.45 0 0 1-.21.25.66.66 0 0 1-.305.06 1.521 1.521 0 0 1-.568-.19 3.533 3.533 0 0 1-.58-.42 3.54 3.54 0 0 0-.49-.394 1.49 1.49 0 0 0-.409-.203c-.053-.024-.079-.024-.092-.012H4.05c-.014.012-.066.072-.066.275 0 .395-.12.705-.423.813a.813.813 0 0 1-.41.024 1.646 1.646 0 0 1-.343-.12.237.237 0 0 1-.126-.127.208.208 0 0 1 .007-.172Zm5.731.766c.068.204.152.404.251.598.011.053.03.105.053.155.036.068.08.132.132.191.02.05.047.099.08.144.085.152.186.296.303.43.167.22.389.4.647.526a.847.847 0 0 0 .687-.011.655.655 0 0 0 .247-.204.573.573 0 0 0 .11-.287 1.435 1.435 0 0 0-.04-.454h-.014a.496.496 0 0 0-.079-.335.491.491 0 0 0-.119-.191 3.842 3.842 0 0 0-1.017-1.16l-.356.18a.253.253 0 0 1-.193.027.248.248 0 0 1-.088-.041.22.22 0 0 1-.063-.07.219.219 0 0 1-.02-.172.242.242 0 0 1 .113-.14l.172-.083a3.388 3.388 0 0 0-.463-.251l-.58-.24c.022.47.101.935.237 1.388Zm.568-1.555c.24.12.474.252.7.395 1.017-.634 1.81-1.459 1.81-2.63 0-.67-.41-1.053-.912-1.16-.502-.108-1.189.083-1.704.669-.515.586-.7 1.47-.713 2.32v.083c.251.084.515.192.819.323Z" clip-rule="evenodd"/>\n </svg>\n <span>upload a signature</span>\n </label>\n </p>\n '));
|
|
674
|
+
let d = document.createElement('p');
|
|
675
|
+
((d.innerHTML =
|
|
676
|
+
'\n <button data-variant="solid" type="button" name="publish" id="publish">\n <span>\n Continue\n </span>\n <svg\n aria-hidden="true"\n width="25"\n height="24"\n fill="none"\n xmlns="http://www.w3.org/2000/svg"\n >\n <path\n d="M7 12h11m0 0-4.588-4M18 12l-4.588 4"\n stroke="#fff"\n stroke-width="1.5"\n stroke-linecap="round"\n stroke-linejoin="round"\n />\n </svg>\n </button>\n '),
|
|
677
|
+
i.appendChild(s),
|
|
678
|
+
i.appendChild(o),
|
|
679
|
+
i.appendChild(n),
|
|
680
|
+
this.allowUpload && i.appendChild(p),
|
|
681
|
+
i.appendChild(d),
|
|
682
|
+
t.appendChild(e),
|
|
683
|
+
t.appendChild(i),
|
|
684
|
+
(this.core = new f(n)),
|
|
685
|
+
(this.errorMessage = s.querySelector('#error')),
|
|
686
|
+
window && (window.onresize = this.resizeCanvas()),
|
|
687
|
+
(this.clearSignatureButton = o.querySelector('#clear')),
|
|
688
|
+
this.clearSignatureButton.addEventListener('click', () =>
|
|
689
|
+
this.clearSignature(),
|
|
690
|
+
),
|
|
691
|
+
(this.uploadSignatureButton = p.querySelector('#upload-signature')),
|
|
692
|
+
this.uploadSignatureButton.addEventListener('change', (v) =>
|
|
693
|
+
this.uploadSignature(v),
|
|
694
|
+
),
|
|
695
|
+
(this.publishSignatureButton = d.querySelector('#publish')),
|
|
696
|
+
this.publishSignatureButton.addEventListener('click', () =>
|
|
697
|
+
this.publishSignature(),
|
|
698
|
+
));
|
|
699
|
+
}
|
|
700
|
+
disconnectedCallback() {
|
|
701
|
+
(this.publishSignatureButton.removeEventListener('click', () =>
|
|
702
|
+
this.publishSignature(),
|
|
703
|
+
),
|
|
704
|
+
this.clearSignatureButton.removeEventListener('click', () =>
|
|
705
|
+
this.clearSignature(),
|
|
706
|
+
),
|
|
707
|
+
this.uploadSignatureButton.removeEventListener('change', (t) =>
|
|
708
|
+
this.uploadSignature(t),
|
|
709
|
+
));
|
|
710
|
+
}
|
|
711
|
+
resizeCanvas() {
|
|
712
|
+
let t = this.shadowRoot.querySelector('canvas'),
|
|
713
|
+
e = Math.max(window.devicePixelRatio || 1, 1);
|
|
714
|
+
((t.width = (t.offsetWidth || t.width) * e),
|
|
715
|
+
(t.height = (t.offsetHeight || t.height) * e),
|
|
716
|
+
t.getContext('2d').scale(e, e),
|
|
717
|
+
this.core.fromData(this.core.toData()));
|
|
718
|
+
}
|
|
719
|
+
publishSignature() {
|
|
720
|
+
try {
|
|
721
|
+
this.resetErrorMessage();
|
|
722
|
+
let t = this.shadowRoot.querySelector('img'),
|
|
723
|
+
e = t ? t.src : void 0;
|
|
724
|
+
if (
|
|
725
|
+
(!e &&
|
|
726
|
+
!this.core.isEmpty() &&
|
|
727
|
+
(e = this.core.toDataURL('image/svg+xml')),
|
|
728
|
+
e)
|
|
729
|
+
)
|
|
730
|
+
this.dispatchEvent(
|
|
731
|
+
new CustomEvent('signature-pad.publish', { detail: e }),
|
|
732
|
+
);
|
|
733
|
+
else
|
|
734
|
+
throw new Error(
|
|
735
|
+
'No signature present. '.concat(
|
|
736
|
+
this.allowUpload ? 'Draw or upload' : 'Draw',
|
|
737
|
+
' a signature',
|
|
738
|
+
),
|
|
739
|
+
);
|
|
740
|
+
} catch (t) {
|
|
741
|
+
this.handleError(t.message);
|
|
742
|
+
}
|
|
743
|
+
}
|
|
744
|
+
resetErrorMessage() {
|
|
745
|
+
this.errorMessage.textContent = '';
|
|
746
|
+
}
|
|
747
|
+
handleError(t) {
|
|
748
|
+
this.errorMessage.textContent = t;
|
|
749
|
+
}
|
|
750
|
+
clearSignature() {
|
|
751
|
+
this.resetErrorMessage();
|
|
752
|
+
let t = this.shadowRoot.querySelector('canvas'),
|
|
753
|
+
e = this.shadowRoot.querySelector('img');
|
|
754
|
+
(e && (e.remove(), t.removeAttribute('hidden')), this.core.clear());
|
|
755
|
+
}
|
|
756
|
+
previewUpload(t) {
|
|
757
|
+
let e = this.shadowRoot.querySelector('canvas'),
|
|
758
|
+
i = this.shadowRoot.querySelector('img');
|
|
759
|
+
(i || (i = document.createElement('img')),
|
|
760
|
+
(i.src = t),
|
|
761
|
+
i.setAttribute('part', 'upload-preview-image'),
|
|
762
|
+
e.setAttribute('hidden', !0),
|
|
763
|
+
e.insertAdjacentElement('afterend', i));
|
|
764
|
+
}
|
|
765
|
+
async uploadSignature(t) {
|
|
766
|
+
try {
|
|
767
|
+
this.resetErrorMessage();
|
|
768
|
+
let { files: e } = t.target,
|
|
769
|
+
i = await E.retrieve(e);
|
|
770
|
+
this.previewUpload(i);
|
|
771
|
+
} catch (e) {
|
|
772
|
+
this.handleError(e.message);
|
|
773
|
+
}
|
|
774
|
+
}
|
|
775
|
+
get allowUpload() {
|
|
776
|
+
return this.hasAttribute('allow-upload');
|
|
777
|
+
}
|
|
778
|
+
get themeColor() {
|
|
779
|
+
return this.getAttribute('theme-color') || '#001096';
|
|
780
|
+
}
|
|
781
|
+
};
|
|
782
|
+
'customElements' in window &&
|
|
783
|
+
!window.customElements.get('smileid-signature-pad') &&
|
|
784
|
+
window.customElements.define('smileid-signature-pad', _);
|
|
785
|
+
var P = _;
|
|
786
|
+
var z = P;
|
|
787
|
+
})();
|
|
2
788
|
/*! Bundled license information:
|
|
3
789
|
|
|
4
790
|
signature_pad/dist/signature_pad.js:
|