@verdocs/web-sdk 6.8.9 → 6.8.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/{utils-kkGeJs-8.js → utils-DsDnct9q.js} +2 -4
- package/dist/cjs/utils-DsDnct9q.js.map +1 -0
- package/dist/cjs/verdocs-auth.cjs.entry.js +22 -0
- package/dist/cjs/verdocs-auth.entry.cjs.js.map +1 -1
- package/dist/cjs/verdocs-contact-picker.cjs.entry.js +1102 -808
- package/dist/cjs/verdocs-contact-picker.entry.cjs.js.map +1 -1
- package/dist/cjs/verdocs-download-dialog_4.cjs.entry.js +1 -1
- package/dist/cjs/verdocs-envelopes-list.cjs.entry.js +1 -1
- package/dist/cjs/verdocs-pagination_2.cjs.entry.js +1 -1
- package/dist/cjs/verdocs-preview_6.cjs.entry.js +1 -1
- package/dist/cjs/verdocs-sign.cjs.entry.js +1 -1
- package/dist/cjs/verdocs-signing-progress.cjs.entry.js +1 -1
- package/dist/cjs/verdocs-template-document-page_2.cjs.entry.js +1 -1
- package/dist/collection/components/embeds/verdocs-auth/verdocs-auth.js +23 -1
- package/dist/collection/components/embeds/verdocs-auth/verdocs-auth.js.map +1 -1
- package/dist/collection/utils/utils.js +0 -2
- package/dist/collection/utils/utils.js.map +1 -1
- package/dist/components/{p-Cj8PYi4t.js → p-B1XBGdC7.js} +4 -4
- package/dist/components/{p-Cj8PYi4t.js.map → p-B1XBGdC7.js.map} +1 -1
- package/dist/components/{p-RdlD8c2P.js → p-B6tZPSE-.js} +3 -3
- package/dist/components/{p-RdlD8c2P.js.map → p-B6tZPSE-.js.map} +1 -1
- package/dist/components/{p-zAW1BOj6.js → p-BCwx8bsK.js} +3 -3
- package/dist/components/{p-zAW1BOj6.js.map → p-BCwx8bsK.js.map} +1 -1
- package/dist/components/{p-aH_YLUuP.js → p-CaoZmlp7.js} +3 -3
- package/dist/components/{p-aH_YLUuP.js.map → p-CaoZmlp7.js.map} +1 -1
- package/dist/components/{p-Cx0Mif05.js → p-CndV_5Je.js} +2 -4
- package/dist/components/{p-Cx0Mif05.js.map → p-CndV_5Je.js.map} +1 -1
- package/dist/components/{p-BrtyCjOf.js → p-DPfgYCMd.js} +3 -3
- package/dist/components/{p-BrtyCjOf.js.map → p-DPfgYCMd.js.map} +1 -1
- package/dist/components/{p-DNYvorxL.js → p-DqlhK3CE.js} +4 -4
- package/dist/components/{p-DNYvorxL.js.map → p-DqlhK3CE.js.map} +1 -1
- package/dist/components/{p-Bzs-6uU0.js → p-EQhWyfg9.js} +1104 -810
- package/dist/components/p-EQhWyfg9.js.map +1 -0
- package/dist/components/{p---tnXjlx.js → p-uNqpODUQ.js} +3 -3
- package/dist/components/{p---tnXjlx.js.map → p-uNqpODUQ.js.map} +1 -1
- package/dist/components/verdocs-auth.js +22 -0
- package/dist/components/verdocs-auth.js.map +1 -1
- package/dist/components/verdocs-build.js +5 -5
- package/dist/components/verdocs-contact-picker.js +1 -1
- package/dist/components/verdocs-envelope-document-page.js +1 -1
- package/dist/components/verdocs-envelopes-list.js +2 -2
- package/dist/components/verdocs-preview.js +1 -1
- package/dist/components/verdocs-quick-filter.js +1 -1
- package/dist/components/verdocs-send.js +1 -1
- package/dist/components/verdocs-sign.js +3 -3
- package/dist/components/verdocs-signing-progress.js +1 -1
- package/dist/components/verdocs-template-document-page.js +1 -1
- package/dist/components/verdocs-template-fields.js +1 -1
- package/dist/components/verdocs-templates-list.js +1 -1
- package/dist/components/verdocs-view.js +1 -1
- package/dist/esm/{utils-CPSY5rft.js → utils-Bty_rQI7.js} +2 -4
- package/dist/esm/utils-Bty_rQI7.js.map +1 -0
- package/dist/esm/verdocs-auth.entry.js +22 -0
- package/dist/esm/verdocs-auth.entry.js.map +1 -1
- package/dist/esm/verdocs-contact-picker.entry.js +1102 -808
- package/dist/esm/verdocs-contact-picker.entry.js.map +1 -1
- package/dist/esm/verdocs-download-dialog_4.entry.js +1 -1
- package/dist/esm/verdocs-envelopes-list.entry.js +1 -1
- package/dist/esm/verdocs-pagination_2.entry.js +1 -1
- package/dist/esm/verdocs-preview_6.entry.js +1 -1
- package/dist/esm/verdocs-sign.entry.js +1 -1
- package/dist/esm/verdocs-signing-progress.entry.js +1 -1
- package/dist/esm/verdocs-template-document-page_2.entry.js +1 -1
- package/dist/esm-es5/{utils-CPSY5rft.js → utils-Bty_rQI7.js} +1 -1
- package/dist/esm-es5/utils-Bty_rQI7.js.map +1 -0
- package/dist/esm-es5/verdocs-auth.entry.js +1 -1
- package/dist/esm-es5/verdocs-auth.entry.js.map +1 -1
- package/dist/esm-es5/verdocs-contact-picker.entry.js +2 -2
- package/dist/esm-es5/verdocs-contact-picker.entry.js.map +1 -1
- package/dist/esm-es5/verdocs-download-dialog_4.entry.js +1 -1
- package/dist/esm-es5/verdocs-envelopes-list.entry.js +1 -1
- package/dist/esm-es5/verdocs-pagination_2.entry.js +1 -1
- package/dist/esm-es5/verdocs-preview_6.entry.js +1 -1
- package/dist/esm-es5/verdocs-sign.entry.js +1 -1
- package/dist/esm-es5/verdocs-signing-progress.entry.js +1 -1
- package/dist/esm-es5/verdocs-template-document-page_2.entry.js +1 -1
- package/dist/types/components/embeds/verdocs-auth/verdocs-auth.d.ts +4 -1
- package/dist/verdocs-web-sdk/{p-b7d907b4.system.entry.js → p-0f6aa428.system.entry.js} +2 -2
- package/dist/verdocs-web-sdk/{p-92b4f218.entry.js → p-30ce93f4.entry.js} +2 -2
- package/dist/verdocs-web-sdk/p-4a24c445.system.entry.js +4 -0
- package/dist/verdocs-web-sdk/p-4a24c445.system.entry.js.map +1 -0
- package/dist/verdocs-web-sdk/p-5b00dbf2.entry.js +3 -0
- package/dist/verdocs-web-sdk/p-5b00dbf2.entry.js.map +1 -0
- package/dist/verdocs-web-sdk/{p-3be22031.entry.js → p-64a68e39.entry.js} +2 -2
- package/dist/verdocs-web-sdk/{p-0b59a4a5.entry.js → p-76770d9c.entry.js} +2 -2
- package/dist/verdocs-web-sdk/{p-2ba8c771.system.entry.js → p-7fa0abc5.system.entry.js} +2 -2
- package/dist/verdocs-web-sdk/{p-60cfa50a.system.entry.js → p-83f10fb7.system.entry.js} +2 -2
- package/dist/verdocs-web-sdk/{p-641dbbfa.system.entry.js → p-8b80fe24.system.entry.js} +2 -2
- package/dist/verdocs-web-sdk/{p-fc308ef0.entry.js → p-90005b19.entry.js} +3 -3
- package/dist/verdocs-web-sdk/p-B8zpaHu-.system.js +1 -1
- package/dist/verdocs-web-sdk/p-BC0LsUzY.system.js.map +1 -0
- package/dist/verdocs-web-sdk/p-Bg14ZSNR.system.js.map +1 -0
- package/dist/verdocs-web-sdk/{p-a51WVEiq.system.js.map → p-BkSli2zt.system.js.map} +1 -1
- package/dist/verdocs-web-sdk/{p-DmQa-gqf.system.js.map → p-CLSDwNJu.system.js.map} +1 -1
- package/dist/verdocs-web-sdk/{p-BFC8G6sY.system.js.map → p-CkFoHSeo.system.js.map} +1 -1
- package/dist/verdocs-web-sdk/{p-DGti20Vc.system.js → p-CnF3etgg.system.js} +1 -1
- package/dist/verdocs-web-sdk/p-CnF3etgg.system.js.map +1 -0
- package/dist/verdocs-web-sdk/{p-N4-IQ3Cb.system.js.map → p-CotMN3Ey.system.js.map} +1 -1
- package/dist/verdocs-web-sdk/{p-CVmJ8lYI.system.js.map → p-CyHGFYot.system.js.map} +1 -1
- package/dist/verdocs-web-sdk/{p-BJ0cUjeu.system.js.map → p-Fo42OGz9.system.js.map} +1 -1
- package/dist/verdocs-web-sdk/{p-H1Y4Zb4E.system.js.map → p-HR08HTpW.system.js.map} +1 -1
- package/dist/verdocs-web-sdk/{p-C9JdpYtM.js → p-NAwq_U8G.js} +1 -1
- package/dist/verdocs-web-sdk/p-NAwq_U8G.js.map +1 -0
- package/dist/verdocs-web-sdk/p-ae1318c0.entry.js +2 -0
- package/dist/verdocs-web-sdk/p-ae1318c0.entry.js.map +1 -0
- package/dist/verdocs-web-sdk/{p-6c8883ff.entry.js → p-b99e606b.entry.js} +2 -2
- package/dist/verdocs-web-sdk/{p-6c8883ff.entry.js.map → p-b99e606b.entry.js.map} +1 -1
- package/dist/verdocs-web-sdk/p-bcf3f5ed.system.entry.js +2 -0
- package/dist/verdocs-web-sdk/p-bcf3f5ed.system.entry.js.map +1 -0
- package/dist/verdocs-web-sdk/{p-066eaea8.system.entry.js → p-e33fd901.system.entry.js} +2 -2
- package/dist/verdocs-web-sdk/{p-d4e3efdb.system.entry.js → p-e97ce39e.system.entry.js} +3 -3
- package/dist/verdocs-web-sdk/{p-4f820bee.entry.js → p-f02af327.entry.js} +2 -2
- package/dist/verdocs-web-sdk/{p-04981f9f.entry.js → p-f79ebbc1.entry.js} +2 -2
- package/dist/verdocs-web-sdk/{p-4424623c.system.entry.js → p-ffbf5761.system.entry.js} +2 -2
- package/dist/verdocs-web-sdk/verdocs-auth.entry.esm.js.map +1 -1
- package/dist/verdocs-web-sdk/verdocs-contact-picker.entry.esm.js.map +1 -1
- package/dist/verdocs-web-sdk/verdocs-web-sdk.esm.js +1 -1
- package/package.json +3 -3
- package/dist/cjs/utils-kkGeJs-8.js.map +0 -1
- package/dist/components/p-Bzs-6uU0.js.map +0 -1
- package/dist/esm/utils-CPSY5rft.js.map +0 -1
- package/dist/esm-es5/utils-CPSY5rft.js.map +0 -1
- package/dist/verdocs-web-sdk/p-898b4c05.entry.js +0 -2
- package/dist/verdocs-web-sdk/p-898b4c05.entry.js.map +0 -1
- package/dist/verdocs-web-sdk/p-BuHYXI2L.system.js.map +0 -1
- package/dist/verdocs-web-sdk/p-C9JdpYtM.js.map +0 -1
- package/dist/verdocs-web-sdk/p-CHowGhis.system.js.map +0 -1
- package/dist/verdocs-web-sdk/p-DGti20Vc.system.js.map +0 -1
- package/dist/verdocs-web-sdk/p-bcffad7a.system.entry.js +0 -4
- package/dist/verdocs-web-sdk/p-bcffad7a.system.entry.js.map +0 -1
- package/dist/verdocs-web-sdk/p-f7f33a99.entry.js +0 -3
- package/dist/verdocs-web-sdk/p-f7f33a99.entry.js.map +0 -1
- package/dist/verdocs-web-sdk/p-fde71466.system.entry.js +0 -2
- package/dist/verdocs-web-sdk/p-fde71466.system.entry.js.map +0 -1
- /package/dist/verdocs-web-sdk/{p-b7d907b4.system.entry.js.map → p-0f6aa428.system.entry.js.map} +0 -0
- /package/dist/verdocs-web-sdk/{p-92b4f218.entry.js.map → p-30ce93f4.entry.js.map} +0 -0
- /package/dist/verdocs-web-sdk/{p-3be22031.entry.js.map → p-64a68e39.entry.js.map} +0 -0
- /package/dist/verdocs-web-sdk/{p-0b59a4a5.entry.js.map → p-76770d9c.entry.js.map} +0 -0
- /package/dist/verdocs-web-sdk/{p-2ba8c771.system.entry.js.map → p-7fa0abc5.system.entry.js.map} +0 -0
- /package/dist/verdocs-web-sdk/{p-60cfa50a.system.entry.js.map → p-83f10fb7.system.entry.js.map} +0 -0
- /package/dist/verdocs-web-sdk/{p-641dbbfa.system.entry.js.map → p-8b80fe24.system.entry.js.map} +0 -0
- /package/dist/verdocs-web-sdk/{p-fc308ef0.entry.js.map → p-90005b19.entry.js.map} +0 -0
- /package/dist/verdocs-web-sdk/{p-066eaea8.system.entry.js.map → p-e33fd901.system.entry.js.map} +0 -0
- /package/dist/verdocs-web-sdk/{p-d4e3efdb.system.entry.js.map → p-e97ce39e.system.entry.js.map} +0 -0
- /package/dist/verdocs-web-sdk/{p-4f820bee.entry.js.map → p-f02af327.entry.js.map} +0 -0
- /package/dist/verdocs-web-sdk/{p-04981f9f.entry.js.map → p-f79ebbc1.entry.js.map} +0 -0
- /package/dist/verdocs-web-sdk/{p-4424623c.system.entry.js.map → p-ffbf5761.system.entry.js.map} +0 -0
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import{d as e}from"./p-dzBXqXlK.js";import{getEnvelopesZip as t,downloadBlob as s,rescale as a}from"@verdocs/js-sdk";import{F as n}from"./p-BqoC0yeA.js";const o=e=>{switch(e){case"textarea":return 150;case"textbox":return 150;case"timestamp":return 105;case"date":return 75;case"dropdown":return 85;case"attachment":case"payment":return 24;case"radio":case"checkbox":return 14;case"signature":case"initial":return 71}return 150};const c=e=>{switch(e){case"textarea":return 41;case"textbox":return 15;case"timestamp":return 15;case"date":return 15;case"dropdown":return 20;case"attachment":case"payment":return 24;case"radio":case"checkbox":return 14;case"signature":case"initial":return 36}return 50};const r=(e,t,s,n)=>{var r,i;let{x:d=0,y:l=0,width:u=o(t.type),height:p=c(t.type),settings:x}=t;const m=t.type==="signature"||t.type==="initial";const f=!m?u:(r=x===null||x===void 0?void 0:x.canvasWidth)!==null&&r!==void 0?r:u;const b=!m?p:(i=x===null||x===void 0?void 0:x.canvasHeight)!==null&&i!==void 0?i:p;e.style.width=`${f}px`;e.style.height=`${b}px`;e.style.position="absolute";e.style.left=`${a(s,d)}px`;e.style.bottom=`${a(n,l)}px`;e.style.transform=`scale(${s}, ${n})`};const i=(e,t,s)=>{let{x:n=0,y:r=0,width:i=o(e.type),height:d=c(e.type)}=e;return{zIndex:"100",width:`${i}px`,height:`${d}px`,position:"absolute",left:`${a(t,n)}px`,bottom:`${a(s,r)}px`,transform:`scale(${t}, ${s})`}};const d=e=>`verdocs-doc-fld-${e.name}`;const l=e=>{const t=d(e);const s=document.getElementById(t);if(s){s.field=e;s.roleindex=e;s.setAttribute("id",t);s.setAttribute("disabled",true);s.setAttribute("disabled",false)}};const u=(e,t,s,a,n=1)=>{var o,c;const{disabled:i=false,editable:l=false,draggable:u=false,done:p=false}=a;const x=document.getElementById(s.containerId+"-controls");if(!x){return}switch(t.type){case"radio":case"checkbox":case"attachment":case"date":case"dropdown":case"initial":case"payment":case"signature":case"timestamp":case"textarea":case"textbox":{const a=d(t);const m=document.getElementById(a);if(m){m.field=t;m.done=p;r(m,t,s.xScale,s.yScale);return m}let{type:f}=t;if(f==="textbox"){if(((o=t["setting"])===null||o===void 0?void 0:o.leading)>0||((c=t["settings"])===null||c===void 0?void 0:c.leading)>0){f="textarea"}}const b=document.createElement(`verdocs-field-${f}`);b.field=t;b.setAttribute("id",a);b.setAttribute("fieldname",t.name);b.setAttribute("source",e);b.setAttribute("sourceid","template_id"in t?t.template_id:t.envelope_id);if(i){b.setAttribute("tabindex",-1);b.setAttribute("disabled",true)}else{b.setAttribute("tabindex",n)}b.setAttribute("editable",l);b.setAttribute("draggable",u);b.setAttribute("done",p);r(b,t,s.xScale,s.yScale);x.appendChild(b);return b}default:console.log("[PREVIEW] Skipping unsupported field type",t);return null}};const p=(e,t,s)=>{const a=e.style.transform||"";const n=`${t}(${s})`;if(a.includes(t)){e.style.transform=a.replace(new RegExp(`${t}\\(.+?\\)`),n)}else{e.style.transform=a+" "+n}};const x=e=>{e.style.transform=e.style.transform.split(")")[0]+")"};const m=async(a,o)=>{const c=e.format(o.length===1?new Date(o[0].updated_at):new Date,n);const r=o.length===1?`${o[0].name} - ${c}.zip`:`Verdocs-Envelopes-${c}`;console.log("Downloading envelopes as ZIP",o,r);const i=await t(a,o.map((e=>e.id)));s(i.data,r)};const f=(e,t)=>{let s=0;return function(...a){clearTimeout(s);s=setTimeout((()=>e.apply(this,a)),t)}};const b=(e,t="16px Arial")=>{const s=document.createElement("canvas");const a=s.getContext("2d");a.font=t;return a.measureText(e).width};const h=e=>{let t=(e||"").trim();if(!t||t.startsWith("+")){return t}t=t.replace(/[^0-9]/g,"");t=t.replace(/^0/g,"");return`+1${t}`};const $=(e,t,s,n)=>{const o=document.getElementById(e.containerId+"-controls");if(!o){return}const c=document.createElement("verdocs-flag");c.variant=n.variant;c.label=n.label;c.showSkip=n.showSkip;if(n.id){c.setAttribute("id",n.id)}c.classList.add("verdocs-flag-instance");if(n.onSkip){c.addEventListener("skip",n.onSkip)}if(n.onClick){c.addEventListener("flagClick",n.onClick)}c.style.position="absolute";c.style.left="calc(100% - 14px)";const r=a(e.yScale,t);const i=a(e.yScale,s);const d=r+i;c.style.bottom=`${d}px`;o.appendChild(c);return c};const g=e=>{if(!e)return"";const t={signature:"Signature",initial:"Initials",date:"Date",textbox:"Text Field",checkbox:"Checkbox",radio:"Radio Button",dropdown:"Dropdown",attachment:"Attachment",payment:"Payment"};const s=t[e.type]||"Field";if(e.required){return`Required ${s}*`}return`Optional ${s}`};export{u as a,g as b,b as c,c as d,i as e,h as f,d as g,p as h,x as i,r as j,o as k,$ as r,m as s,f as t,l as u};
|
|
2
|
-
//# sourceMappingURL=p-
|
|
2
|
+
//# sourceMappingURL=p-NAwq_U8G.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"p-NAwq_U8G.js","sources":["src/utils/utils.ts"],"sourcesContent":["import {format} from 'date-fns';\nimport {downloadBlob, getEnvelopeFile, getEnvelopesZip, IEnvelope, IEnvelopeField, ITemplateField, rescale, TFieldType, VerdocsEndpoint} from '@verdocs/js-sdk';\nimport {FORMAT_DATE, IDocumentPageInfo} from './Types';\n\nexport const defaultWidth = (type: TFieldType) => {\n // checkbox was a legacy field type\n switch (type as any) {\n case 'textarea':\n return 150;\n case 'textbox':\n return 150;\n case 'timestamp':\n return 105;\n case 'date':\n return 75;\n case 'dropdown':\n return 85;\n case 'attachment':\n case 'payment':\n return 24;\n case 'radio':\n case 'checkbox':\n return 14;\n case 'signature':\n case 'initial':\n return 71;\n }\n\n return 150;\n};\n\nexport const defaultHeight = (type: TFieldType) => {\n switch (type as any) {\n case 'textarea':\n return 41;\n case 'textbox':\n return 15;\n case 'timestamp':\n return 15;\n case 'date':\n return 15;\n case 'dropdown':\n return 20;\n case 'attachment':\n case 'payment':\n return 24;\n case 'radio':\n case 'checkbox':\n return 14;\n case 'signature':\n case 'initial':\n return 36;\n }\n\n return 50;\n};\n\nexport const setControlStyles = (el: HTMLElement, field: ITemplateField | IEnvelopeField, xScale: number, yScale: number) => {\n let {x = 0, y = 0, width = defaultWidth(field.type), height = defaultHeight(field.type), settings} = field;\n const isCanvasField = field.type === 'signature' || field.type === 'initial';\n const canvasWidth = !isCanvasField ? width : (settings?.canvasWidth ?? width);\n const canvasHeight = !isCanvasField ? height : (settings?.canvasHeight ?? height);\n\n el.style.width = `${canvasWidth}px`;\n el.style.height = `${canvasHeight}px`;\n el.style.position = 'absolute';\n el.style.left = `${rescale(xScale, x)}px`;\n el.style.bottom = `${rescale(yScale, y)}px`;\n el.style.transform = `scale(${xScale}, ${yScale})`;\n};\n\nexport const getControlStyles = (field: ITemplateField | IEnvelopeField, xScale: number, yScale: number) => {\n let {x = 0, y = 0, width = defaultWidth(field.type), height = defaultHeight(field.type)} = field;\n\n return {\n zIndex: '100',\n width: `${width}px`,\n height: `${height}px`,\n position: 'absolute',\n left: `${rescale(xScale, x)}px`,\n bottom: `${rescale(yScale, y)}px`,\n transform: `scale(${xScale}, ${yScale})`,\n };\n};\n\nexport const getFieldId = (field: ITemplateField | IEnvelopeField) => {\n return `verdocs-doc-fld-${field.name}`;\n};\n\ninterface IFieldOptions {\n disabled?: boolean;\n editable?: boolean;\n draggable?: boolean;\n done?: boolean;\n}\n\nexport const updateDocumentFieldValue = (field: ITemplateField | IEnvelopeField) => {\n const id = getFieldId(field);\n const existingField = document.getElementById(id) as any;\n if (existingField) {\n existingField.field = field;\n existingField.roleindex = field;\n existingField.setAttribute('id', id); // We need this to trigger a re-render\n existingField.setAttribute('disabled', true); // We need this to trigger a re-render\n existingField.setAttribute('disabled', false); // We need this to trigger a re-render\n }\n};\n\nexport const renderDocumentField = (\n source: 'envelope' | 'template',\n field: ITemplateField | IEnvelopeField,\n docPage: IDocumentPageInfo,\n fieldOptions: IFieldOptions,\n tabIndex: number = 1,\n) => {\n const {disabled = false, editable = false, draggable = false, done = false} = fieldOptions;\n const controlsDiv = document.getElementById(docPage.containerId + '-controls');\n if (!controlsDiv) {\n // TODO: This gets emitted a lot by the builder naturally, when placing or updating fields, because Store.updateTemplate\n // triggers a re-render but we still have async code pending in contexts with references to the old/wrong controls DIV\n // IDs. It doesn't break anything because the re-render fixes it all up. But we do want to trap this for \"other\" situations.\n // console.log('[renderDocumentField] No controls DIV found', docPage.containerId + '-controls', docPage);\n return;\n }\n\n switch (field.type as any) {\n case 'radio':\n case 'checkbox':\n case 'attachment':\n case 'date':\n case 'dropdown':\n case 'initial':\n case 'payment':\n case 'signature':\n case 'timestamp':\n case 'textarea':\n case 'textbox': {\n const id = getFieldId(field);\n const existingField = document.getElementById(id) as any;\n if (existingField) {\n existingField.field = field;\n existingField.done = done;\n setControlStyles(existingField, field, docPage.xScale, docPage.yScale);\n return existingField;\n }\n\n let {type} = field;\n if (type === 'textbox') {\n if (field['setting']?.leading > 0 || field['settings']?.leading > 0) {\n type = 'textarea';\n }\n }\n\n const el: any = document.createElement(`verdocs-field-${type}`);\n el.field = field;\n el.setAttribute('id', id);\n el.setAttribute('fieldname', field.name);\n el.setAttribute('source', source);\n el.setAttribute('sourceid', 'template_id' in field ? field.template_id : field.envelope_id);\n\n if (disabled) {\n el.setAttribute('tabindex', -1);\n el.setAttribute('disabled', true);\n } else {\n el.setAttribute('tabindex', tabIndex);\n }\n\n el.setAttribute('editable', editable);\n el.setAttribute('draggable', draggable);\n el.setAttribute('done', done);\n\n setControlStyles(el, field, docPage.xScale, docPage.yScale);\n controlsDiv.appendChild(el);\n\n return el;\n }\n\n default:\n console.log('[PREVIEW] Skipping unsupported field type', field);\n return null;\n }\n};\n\n/**\n * Helper function to safely set/update components in a CSS transform attribute. Transform is normally set as a string of\n * `operation1(param) operation2(param) ...` components, which makes updating them a bit of a pain. This will remove the\n * specified component if it's already set and replace it with the new value, without touching the other components that\n * may already be set. Note that this operation moves the component to the end of the transform chain so it's not meant\n * to be used for order-sensitive components e.g. translate-then-rotate.\n */\nexport const updateCssTransform = (el: HTMLElement, key: string, value: string) => {\n const currentTransform = el.style.transform || '';\n\n const newValue = `${key}(${value})`;\n if (currentTransform.includes(key)) {\n el.style.transform = currentTransform.replace(new RegExp(`${key}\\\\(.+?\\\\)`), newValue);\n } else {\n el.style.transform = currentTransform + ' ' + newValue;\n }\n};\n\nexport const removeCssTransform = (el: HTMLElement) => {\n // const currentTransform = el.style.transform || '';\n el.style.transform = el.style.transform.split(')')[0] + ')';\n // TODO: This is not working\n // el.style.transform = currentTransform.replace(new RegExp(`\\(${key}\\\\(.+?\\\\)\\)`), '');\n};\n\n// TODO: Shift to getDownloadLilnk\nexport const saveAttachment = async (endpoint: VerdocsEndpoint, envelope: IEnvelope, documentId: string) => {\n // e.g. \"Colorado-Motor-Vehicle-Bill-of-Sale.pdf\"\n const date = format(new Date(envelope.updated_at), FORMAT_DATE);\n const fileName = `${envelope.name} - ${date}.pdf`;\n const data = await getEnvelopeFile(endpoint, documentId);\n downloadBlob(data, fileName);\n};\n\nexport const saveEnvelopesAsZip = async (endpoint: VerdocsEndpoint, envelopes: IEnvelope[]) => {\n const formattedDate = format(envelopes.length === 1 ? new Date(envelopes[0].updated_at) : new Date(), FORMAT_DATE);\n const zipFileName = envelopes.length === 1 ? `${envelopes[0].name} - ${formattedDate}.zip` : `Verdocs-Envelopes-${formattedDate}`;\n console.log('Downloading envelopes as ZIP', envelopes, zipFileName);\n const result = await getEnvelopesZip(\n endpoint,\n envelopes.map(e => e.id),\n );\n downloadBlob(result.data, zipFileName);\n};\n\n/**\n * Throttle a given function by a delay value. Useful for things like resizeObserver.\n */\nexport const throttle = (f: Function, delay: number) => {\n let timer: any = 0;\n return function (...args) {\n clearTimeout(timer);\n timer = setTimeout(() => f.apply(this, args), delay);\n };\n};\n\n/**\n * Compute the rendered width of a given text string, using a given font.\n */\nexport const renderedTextWidth = (text: string, font: string = '16px Arial') => {\n const canvas = document.createElement('canvas');\n const ctx = canvas.getContext('2d');\n ctx.font = font;\n return ctx.measureText(text).width;\n};\n\n// \"(212) 555-1212\" => +12125551212\n// \"+46766861004\" => \"+46766861004\"\n// \"212-555-1212\" => +12125551212\n// \"212.555.1212\" => +12125551212\n// \"212 555 1212\" => +12125551212\n// @see https://46elks.com/kb/e164\nexport const convertToE164 = (input: string) => {\n let temp = (input || '').trim();\n // If we are already prefixed, assume the user did it deliberately and attempt to use what they entered. We also short-circuit blanks.\n if (!temp || temp.startsWith('+')) {\n return temp;\n }\n\n // Remove any spaces, parenthesis or other punctuation.\n temp = temp.replace(/[^0-9]/g, '');\n\n // If the number begins with a zero, remove the leading zero. Do not combine this with the previous step because it needs to be removed\n // whether it's the actual first character e.g. `0(5)` or just the first digit e.g. `(05`.\n temp = temp.replace(/^0/g, '');\n\n // Prepend the country code and +. We're assuming US in this case given the target demographic. Users in other countries would/should be\n // already entering a prefix so they'd shortcut out of this routine via the + prefix check.\n return `+1${temp}`;\n};\n\nexport interface IFlagOptions {\n variant: 'fill' | 'next';\n label: string;\n showSkip?: boolean;\n onSkip?: () => void;\n onClick?: () => void;\n id?: string;\n}\n\nexport const renderDocumentFlag = (\n docPage: IDocumentPageInfo,\n y: number, // Bottom position from field\n height: number, // Field height\n options: IFlagOptions,\n) => {\n const controlsDiv = document.getElementById(docPage.containerId + '-controls');\n if (!controlsDiv) {\n return;\n }\n\n const el: any = document.createElement('verdocs-flag');\n el.variant = options.variant;\n el.label = options.label;\n el.showSkip = options.showSkip;\n if (options.id) {\n el.setAttribute('id', options.id);\n }\n el.classList.add('verdocs-flag-instance'); // Marker class for easy removal\n\n if (options.onSkip) {\n el.addEventListener('skip', options.onSkip);\n }\n if (options.onClick) {\n el.addEventListener('flagClick', options.onClick);\n }\n\n // Position the flag to stick out of the right edge of the page\n el.style.position = 'absolute';\n\n // The flag has a left-pointing arrow that is 14px wide (15% of 97px ~= 14.5px).\n // We want the \"body\" of the rectangle (starting after the arrow) to align with the\n // right edge of the page.\n el.style.left = 'calc(100% - 14px)';\n\n /*\n * Positioning Logic:\n * Field Y is distance from bottom.\n * Fields have `transform-origin: bottom left`.\n * Visual Bottom = y * scale.\n * Visual Top = (y * scale) + (height * scale).\n * Visual Center = (y * scale) + (height * scale) / 2.\n */\n // const flagHeight = 24; // Matches CSS\n const scaledY = rescale(docPage.yScale, y);\n const scaledHeight = rescale(docPage.yScale, height);\n\n // Align Flag Bottom with Field Top\n const bottom = scaledY + scaledHeight;\n\n el.style.bottom = `${bottom}px`;\n\n controlsDiv.appendChild(el);\n return el;\n};\n\n/**\n * Helper to generate a human-readable label for a field.\n */\nexport const getFieldLabel = (field: IEnvelopeField | ITemplateField) => {\n if (!field) return '';\n const typeMap: Record<string, string> = {\n signature: 'Signature',\n initial: 'Initials',\n date: 'Date',\n textbox: 'Text Field',\n checkbox: 'Checkbox',\n radio: 'Radio Button',\n dropdown: 'Dropdown',\n attachment: 'Attachment',\n payment: 'Payment',\n };\n\n const typeName = typeMap[field.type] || 'Field';\n if (field.required) {\n return `Required ${typeName}*`;\n }\n return `Optional ${typeName}`;\n};\n"],"names":["format"],"mappings":";;;;AAIa,MAAA,YAAY,GAAG,CAAC,IAAgB,KAAI;;IAE/C,QAAQ,IAAW;AACjB,QAAA,KAAK,UAAU;AACb,YAAA,OAAO,GAAG;AACZ,QAAA,KAAK,SAAS;AACZ,YAAA,OAAO,GAAG;AACZ,QAAA,KAAK,WAAW;AACd,YAAA,OAAO,GAAG;AACZ,QAAA,KAAK,MAAM;AACT,YAAA,OAAO,EAAE;AACX,QAAA,KAAK,UAAU;AACb,YAAA,OAAO,EAAE;AACX,QAAA,KAAK,YAAY;AACjB,QAAA,KAAK,SAAS;AACZ,YAAA,OAAO,EAAE;AACX,QAAA,KAAK,OAAO;AACZ,QAAA,KAAK,UAAU;AACb,YAAA,OAAO,EAAE;AACX,QAAA,KAAK,WAAW;AAChB,QAAA,KAAK,SAAS;AACZ,YAAA,OAAO,EAAE;;AAGb,IAAA,OAAO,GAAG;AACZ;AAEa,MAAA,aAAa,GAAG,CAAC,IAAgB,KAAI;IAChD,QAAQ,IAAW;AACjB,QAAA,KAAK,UAAU;AACb,YAAA,OAAO,EAAE;AACX,QAAA,KAAK,SAAS;AACZ,YAAA,OAAO,EAAE;AACX,QAAA,KAAK,WAAW;AACd,YAAA,OAAO,EAAE;AACX,QAAA,KAAK,MAAM;AACT,YAAA,OAAO,EAAE;AACX,QAAA,KAAK,UAAU;AACb,YAAA,OAAO,EAAE;AACX,QAAA,KAAK,YAAY;AACjB,QAAA,K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ser as l,resendVerification as n,resetPassword as d}from"@verdocs/js-sdk";import{V as h}from"./p-D97GxsI-.js";import{S as c}from"./p-C1sRVZWv.js";const u='verdocs-auth{font-family:var(--verdocs-primary-font, "Inter", "Barlow", sans-serif);display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;-ms-flex-direction:column;flex-direction:column;-ms-flex-pack:center;justify-content:center}verdocs-auth .form{width:320px;display:-ms-flexbox;display:flex;padding:20px;max-width:90%;-ms-flex-align:center;align-items:center;-ms-flex-direction:column;flex-direction:column;-webkit-box-sizing:border-box;box-sizing:border-box;-ms-flex-pack:center;justify-content:center;background:#ffffff}verdocs-auth .logo{width:128px;max-width:100%;margin:20px 0 30px}verdocs-auth h3{color:#092c4c;text-align:center;font-weight:400;font-size:18px;line-height:1.75;margin:0}verdocs-auth em{font-size:14px;margin:15px 0}verdocs-auth .buttons{gap:20px;margin:20px 0 0 0;display:-ms-flexbox;display:flex;-ms-flex-direction:row;flex-direction:row;-ms-flex-pack:center;justify-content:center}verdocs-auth .status-result{display:none}verdocs-auth .status-result.debug{white-space:pre-wrap;font-size:14px;background:#fff;padding:10px;display:block;-ms-flex-direction:row;flex-direction:row;-ms-flex-pack:center;justify-content:center}verdocs-auth form{width:100%}verdocs-auth verdocs-text-input{margin-bottom:10px}verdocs-auth .account-option{gap:8px;margin:20px 0 8px 0;display:-ms-flexbox;display:flex;-ms-flex-direction:row;flex-direction:row}verdocs-auth p{color:#092c4c;margin:1em 0;font-size:14px}verdocs-auth p+p{margin-top:0}verdocs-auth verdocs-help-icon{margin-top:18px;display:-ms-flexbox;display:flex;width:32px;height:32px;-ms-flex:0 0 32px;flex:0 0 32px}verdocs-auth .already-have{color:#092c4c;margin:0.5em 0;font-size:14px}';const f=class{constructor(s){e(this,s);this.authenticated=t(this,"authenticated");this.sdkError=t(this,"sdkError");this.endpoint=i.getDefault();this.visible=true;this.logo="https://app.verdocs.com/assets/blue-logo.svg";this.displayMode="login";this.org_name="";this.first_name="";this.last_name="";this.email="";this.verificationCode="";this.newPassword="";this.password="";this.confirmpass="";this.submitting=false;this.resendDisabled=false;this.session=null;this.profile=null;this.resendDisabledTimer=null;this.tempAuthEndpoint=new i({baseURL:i.getDefault().getBaseURL(),persist:false});this.handleHashChange=()=>{this.applyHashDisplayMode()}}componentWillLoad(){this.endpoint.loadSession();this.applyHashDisplayMode();if(typeof window!=="undefined"){window.addEventListener("hashchange",this.handleHashChange)}i.getDefault().onSessionChanged(((e,t,s)=>{var i,o;this.session=t;this.profile=s;if(t){(i=this.authenticated)===null||i===void 0?void 0:i.emit({authenticated:true,session:t,profile:s})}else{(o=this.authenticated)===null||o===void 0?void 0:o.emit({authenticated:false,session:t,profile:s})}}))}disconnectedCallback(){if(typeof window!=="undefined"){window.removeEventListener("hashchange",this.handleHashChange)}}applyHashDisplayMode(){if(typeof window==="undefined"){return}const e=(window.location.hash||"").replace(/^#/,"").toLowerCase();if(e==="forgot-password"||e==="forgot"){this.displayMode="forgot"}}isPasswordComplex(e){const t=e=>/[A-Z]/.test(e);const s=e=>/[a-z]/.test(e);const i=e=>/[`!@#$%^&*()_\-+=\[\]{};':"\\|,.<>\/?~ ]/.test(e);let o=0,a=0,r=0;for(let l=0;l<e.length;l++){let n=e.charAt(l);if(t(n))o++;else if(s(n))a++;else if(i(n))r++}return e.length>=8&&a>0&&o>0&&r>0}handleSignup(){if(!this.isPasswordComplex(this.password)){h("Password must be at least 8 characters long and contain at least one uppercase, one lowercase, and one special character.",{style:"error"});return}if(this.password!==this.confirmpass){h("Passwords do not match.",{style:"error"});return}this.submitting=true;this.tempAuthEndpoint.clearSession();o(this.tempAuthEndpoint,{email:this.email,password:this.password,first_name:this.first_name,last_name:this.last_name,org_name:this.org_name}).then((e=>{console.log("[AUTH] Profile creation result",e);this.tempAuthEndpoint.setToken(e.access_token);this.password="";this.first_name="";this.last_name="";this.org_name="";this.displayMode="verify";this.submitting=false})).catch((e=>{var t,s,i,o,a,r;console.log("[AUTH] Signup error",e.response);this.submitting=false;(t=this.authenticated)===null||t===void 0?void 0:t.emit({authenticated:false,profile:null,session:null});(s=this.sdkError)===null||s===void 0?void 0:s.emit(new c(e.message,(i=e.response)===null||i===void 0?void 0:i.status,(o=e.response)===null||o===void 0?void 0:o.data));h("Signup failed: "+((r=(a=e.response)===null||a===void 0?void 0:a.data)===null||r===void 0?void 0:r.error)||"Unknown Error",{style:"error"})}))}async handleVerification(){this.submitting=true;try{this.submitting=false;const e=await a(this.tempAuthEndpoint,{email:this.email,token:this.verificationCode});h("Thank you for verifying your email address.",{style:"success"});this.completeLogin(e)}catch(e){this.submitting=false;console.log("Verification error",e);h("Verification error, please check the code and try again.")}}completeLogin(e){this.clearForms();this.tempAuthEndpoint.clearSession();this.endpoint.setToken(e.access_token)}async loginAndCheckVerification(){var e,t,s;if(this.submitting){return}this.submitting=true;this.tempAuthEndpoint.clearSession();try{this.submitting=false;const e=await r(this.tempAuthEndpoint,{username:this.email.trim(),password:this.password,grant_type:"password"});console.log("[AUTH] Authenticated, checking email verification");this.tempAuthEndpoint.setToken(e.access_token);const t=await l(this.tempAuthEndpoint);if(!t.email_verified){console.log("[AUTH] Logged in, pending email address verification");this.displayMode="verify"}else{console.log("[AUTH] Email address is verified, completing login");this.completeLogin(e)}}catch(i){this.submitting=false;console.log("[AUTH] Authentication failed",((e=i.response)===null||e===void 0?void 0:e.data)||i);h(((s=(t=i.response)===null||t===void 0?void 0:t.data)===null||s===void 0?void 0:s.error)||"Login failed. Please check your credentials and try again.",{style:"error"})}}clearForms(){this.submitting=false;this.resendDisabled=false;this.email="";this.password="";this.newPassword="";this.confirmpass="";this.verificationCode="";this.first_name="";this.last_name="";this.org_name=""}handleLogout(){console.log("logging out");this.endpoint.clearSession();this.tempAuthEndpoint.clearSession();this.clearForms();this.displayMode="login"}handleResendVerification(){this.resendDisabled=true;this.resendDisabledTimer=setTimeout((()=>{this.resendDisabled=false;this.resendDisabledTimer=null}),3e4);n(this.tempAuthEndpoint).then((e=>{console.log("[AUTH] Verification request resent",e);h("Please check your email for a verification code.",{style:"info"})})).catch((e=>{console.log("[AUTH] Unable to resend verification",e);h("Unable to resend code. Please try again later.",{style:"error"})}))}handleResendReset(){this.resendDisabled=true;this.resendDisabledTimer=setTimeout((()=>{this.resendDisabled=false;this.resendDisabledTimer=null}),3e4);d(this.tempAuthEndpoint,{email:this.email}).then((e=>{console.log("[AUTH] Resend-code request resent",e);h("Please check your email again for a verification code.",{style:"info"})})).catch((e=>{console.log("[AUTH] Unable to resend reset request",e);h("Unable to resend code. Please try again later.",{style:"error"})}))}async handleResetGetCode(){this.submitting=true;this.confirmpass="";this.newPassword="";try{this.submitting=false;const e=await d(this.endpoint,{email:this.email});console.log("[AUTH] Reset result",e);h("Please check your email inbox for a password reset code.",{style:"success"});this.verificationCode="";this.confirmpass="";this.newPassword="";this.displayMode="reset"}catch(e){this.submitting=false;console.log("Reset request error",e);h("Request failed. Please check your email address and try again.")}}async handleResetPassword(){if(!this.isPasswordComplex(this.newPassword)){h("Password must be at least 8 characters long and contain at least one uppercase, one lowercase, and one special character.",{style:"error"});return}if(this.newPassword!==this.confirmpass){h("Passwords do not match.",{style:"error"});return}this.submitting=true;try{this.submitting=false;const e=await d(this.endpoint,{email:this.email,code:this.verificationCode,new_password:this.newPassword});console.log("reset result",e);h("Your password has been reset. You may now use your new password to login.",{style:"success"});this.verificationCode="";this.confirmpass="";this.newPassword="";this.password="";this.displayMode="login"}catch(e){this.submitting=false;console.log("Verification error",e);h("Verification error, please check the code and try again.")}}async handleReset(){this.submitting=true;try{const e=await d(this.endpoint,{email:this.email});console.log("[AUTH] Reset sent",e);this.submitting=false;this.displayMode="login";h("If your email address is registered, you will receive instructions on resetting your password shortly.",{style:"info"})}catch(e){console.log("[AUTH] Unable to reset password",e);this.submitting=false;h("Unable to reset password. Please check your email address and try again.",{style:"error"})}}render(){if(!this.visible){return s("div",{style:{display:"none"}},"Authenticated")}if(this.session){return s("verdocs-button",{label:"Sign Out",disabled:this.submitting,onClick:()=>this.handleLogout(),style:{display:"flex",justifyContent:"center",margin:"30px auto 0"}})}if(this.displayMode==="signup"){const e=this.submitting||!this.first_name||!this.last_name||!this.email||!this.password||!this.confirmpass||!this.org_name;return s("div",{class:"form"},s("a",{href:"https://verdocs.com/en/"},s("img",{src:this.logo,alt:"Verdocs Logo",class:"logo"})),s("h3",null,"Sign up for a free account"),s("div",{class:"already-have"},"Already have an account?",s("verdocs-button",{label:"Log In",variant:"text",onClick:()=>this.displayMode="login",disabled:this.submitting})),s("form",{onSubmit:()=>this.handleSignup()},s("div",{style:{display:"flex",flexDirection:"row",columnGap:"20px"}},s("verdocs-text-input",{label:"First Name",autocomplete:"first",required:true,value:this.first_name,onInput:e=>this.first_name=e.target.value,disabled:this.submitting}),s("verdocs-text-input",{label:"Last Name",autocomplete:"last",required:true,value:this.last_name,onInput:e=>this.last_name=e.target.value,disabled:this.submitting})),s("verdocs-text-input",{label:"Email Address",autocomplete:"email",required:true,value:this.email,onInput:e=>this.email=e.target.value,disabled:this.submitting}),s("verdocs-text-input",{label:"Password",type:"password",required:true,autocomplete:"new-password",value:this.password,onInput:e=>this.password=e.target.value,disabled:this.submitting}),s("verdocs-text-input",{label:"Confirm Password",type:"password",required:true,autocomplete:"off",value:this.confirmpass,onInput:e=>this.confirmpass=e.target.value,disabled:this.submitting}),s("verdocs-text-input",{label:"Organization Name",autocomplete:"org",required:true,value:this.org_name,onInput:e=>this.org_name=e.target.value,disabled:this.submitting,style:{flex:"1"}}),s("div",{style:{marginTop:"30px"}}),s("verdocs-button",{label:"Next",disabled:e,onClick:e?()=>{}:()=>this.handleSignup(),style:{display:"flex",justifyContent:"center",margin:"30px auto 0"}})))}if(this.displayMode==="verify"){return s("div",{class:"form"},s("form",{onSubmit:()=>this.handleVerification()},s("p",null,"Please check your e-mail inbox for a verification code and enter it below."),s("verdocs-text-input",{label:"Verification Code",required:true,value:this.verificationCode,onInput:e=>this.verificationCode=e.target.value,disabled:this.submitting}),s("div",{class:"buttons"},s("verdocs-button",{label:"Sign Out",variant:"outline",disabled:this.submitting,onClick:()=>this.handleLogout()}),s("verdocs-button",{label:"Verify",disabled:this.submitting||!this.verificationCode||this.verificationCode.length!==6,onClick:()=>this.handleVerification()})),s("div",{class:"buttons"},s("verdocs-button",{variant:"text",label:"Resend Code",disabled:this.resendDisabled||this.submitting,onClick:()=>this.handleResendVerification()}))))}if(this.displayMode==="forgot"){return s("div",{class:"form"},s("a",{href:"https://verdocs.com/en/"},s("img",{src:this.logo,alt:"Verdocs Logo",class:"logo"})),s("h3",null,"Forgot your password?"),s("p",null,"Enter your e-mail address below. If the e-mail address is valid, a password reset code will be sent to your inbox. Please allow up to 15 minutes to arrive, and check your spam folder if you do not receive the message."),s("form",{onSubmit:()=>this.handleResetGetCode()},s("verdocs-text-input",{label:"Email Address",autocomplete:"email",required:true,value:this.email,onInput:e=>this.email=e.target.value,disabled:this.submitting}),s("div",{style:{marginTop:"30px"}}),s("div",{class:"buttons"},s("verdocs-button",{size:"small",label:"Cancel",variant:"outline",disabled:this.submitting,onClick:()=>this.displayMode="login"}),s("verdocs-button",{size:"small",label:"Request Code",disabled:this.submitting,onClick:()=>this.handleResetGetCode()}))))}if(this.displayMode==="reset"){return s("div",{class:"form"},s("a",{href:"https://verdocs.com/en/"},s("img",{src:this.logo,alt:"Verdocs Logo",class:"logo"})),s("h3",null,"Forgot your password?"),s("p",null,"Enter your e-mail address below, and reset instructions will be sent to your Inbox. Please allow up to 15 minutes to arrive. Check your spam folder if you do not receive the message."),s("form",{onSubmit:()=>this.handleResetPassword()},s("verdocs-text-input",{label:"Verification Code",required:true,value:this.verificationCode,onInput:e=>this.verificationCode=e.target.value,disabled:this.submitting}),s("verdocs-text-input",{label:"Password",type:"password",required:true,autocomplete:"off",value:this.newPassword,onInput:e=>this.newPassword=e.target.value,disabled:this.submitting}),s("verdocs-text-input",{label:"Confirm Password",type:"password",required:true,autocomplete:"off",value:this.confirmpass,onInput:e=>this.confirmpass=e.target.value,disabled:this.submitting}),s("div",{style:{marginTop:"30px"}}),s("div",{class:"buttons"},s("verdocs-button",{label:"Cancel",variant:"outline",disabled:this.submitting,onClick:()=>this.displayMode="login"}),s("verdocs-button",{label:"Reset",disabled:this.submitting,onClick:()=>this.handleResetPassword()})),s("div",{class:"buttons"},s("verdocs-button",{variant:"text",label:"Resend Code",disabled:this.resendDisabled||this.submitting,onClick:()=>this.handleResendReset()}))))}return s("div",{class:"form"},s("a",{href:"https://verdocs.com/en/"},s("img",{src:this.logo,alt:"Verdocs Logo",class:"logo"})),s("h3",null,"Log in to your account"),s("div",{class:"already-have"},"Don't have an account?",s("verdocs-button",{label:"Sign Up",variant:"text",onClick:()=>this.displayMode="signup",disabled:this.submitting})),s("form",{onSubmit:()=>this.loginAndCheckVerification()},s("verdocs-text-input",{label:"Email",autocomplete:"username",value:this.email,onInput:e=>this.email=e.target.value,disabled:this.submitting}),s("verdocs-text-input",{label:"Password",type:"password",autocomplete:"current-password",value:this.password,onInput:e=>this.password=e.target.value,disabled:this.submitting}),s("verdocs-button",{label:"Forgot Your Password?",variant:"text",onClick:()=>this.displayMode="forgot",disabled:this.submitting,style:{display:"flex",justifyContent:"center",margin:"10px auto 20px"}}),s("verdocs-button",{label:"Login",disabled:this.submitting,onClick:()=>this.loginAndCheckVerification(),style:{display:"flex",justifyContent:"center",margin:"10px auto 0"}})))}};f.style=u;export{f as verdocs_auth};
|
|
2
|
+
//# sourceMappingURL=p-ae1318c0.entry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["registerInstance","createEvent","h","VerdocsEndpoint","createProfile","verifyEmail","authenticate","getMyUser","resendVerification","resetPassword","VerdocsToast","SDKError","verdocsAuthCss","VerdocsAuth","constructor","hostRef","this","authenticated","sdkError","endpoint","getDefault","visible","logo","displayMode","org_name","first_name","last_name","email","verificationCode","newPassword","password","confirmpass","submitting","resendDisabled","session","profile","resendDisabledTimer","tempAuthEndpoint","baseURL","getBaseURL","persist","handleHashChange","applyHashDisplayMode","componentWillLoad","loadSession","window","addEventListener","onSessionChanged","_endpoint","_a","_b","emit","disconnectedCallback","removeEventListener","hash","location","replace","toLowerCase","isPasswordComplex","isUppercase","ch","test","isLowercase","isSpecialChar","countOfUpperCase","countOfLowerCase","countOfSpecialChar","i","length","charAt","handleSignup","style","clearSession","then","r","console","log","setToken","access_token","catch","e","_c","_d","_e","_f","response","message","status","data","error","handleVerification","verificationResult","token","completeLogin","result","clearForms","loginAndCheckVerification","authResult","username","trim","grant_type","user","email_verified","handleLogout","handleResendVerification","setTimeout","handleResendReset","handleResetGetCode","handleResetPassword","resetResult","code","new_password","handleReset","render","display","label","disabled","onClick","justifyContent","margin","invalid","class","href","src","alt","variant","onSubmit","flexDirection","columnGap","autocomplete","required","value","onInput","target","type","flex","marginTop","size"],"sources":["0"],"mappings":"YAAcA,OAAuBC,OAAaC,MAAS,4CAClDC,mBAAiBC,iBAAeC,kBAAaC,eAAcC,wBAAWC,mBAAoBC,MAAqB,8BAC1GC,MAAoB,8BACpBC,MAAgB,kBAE9B,MAAMC,EAAiB,4oDAEvB,MAAMC,EAAc,MAChB,WAAAC,CAAYC,GACRf,EAAiBgB,KAAMD,GACvBC,KAAKC,cAAgBhB,EAAYe,KAAM,iBACvCA,KAAKE,SAAWjB,EAAYe,KAAM,YAIlCA,KAAKG,SAAWhB,EAAgBiB,aAMhCJ,KAAKK,QAAU,KAMfL,KAAKM,KAAO,+CAIZN,KAAKO,YAAc,QACnBP,KAAKQ,SAAW,GAChBR,KAAKS,WAAa,GAClBT,KAAKU,UAAY,GACjBV,KAAKW,MAAQ,GACbX,KAAKY,iBAAmB,GACxBZ,KAAKa,YAAc,GACnBb,KAAKc,SAAW,GAChBd,KAAKe,YAAc,GACnBf,KAAKgB,WAAa,MAClBhB,KAAKiB,eAAiB,MACtBjB,KAAKkB,QAAU,KACflB,KAAKmB,QAAU,KACfnB,KAAKoB,oBAAsB,KAI3BpB,KAAKqB,iBAAmB,IAAIlC,EAAgB,CACxCmC,QAASnC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AE2C,QAAS,OAAQI,eAAgB,SAAUC,OAAQ,kBAChsC,GAEJ1G,EAAY0D,MAAQ3D,SAEXC","ignoreList":[]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{r as e,c as t,h as i,H as s,F as o,g as n}from"./p-BIRwgFLv.js";import{VerdocsEndpoint as l,DEFAULT_DISCLOSURES as a,startSigningSession as r,envelopeRecipientAgree as d,getEnvelope as c,updateEnvelopeField as h,createSignature as p,createInitials as g,sortFields as u,envelopeRecipientSubmit as f,isFieldValid as v,isFieldFilled as m,uploadEnvelopeFieldAttachment as x,deleteEnvelopeFieldAttachment as b,formatFullName as w,fullNameToInitials as y,verifySigner as k,delegateRecipient as C,envelopeRecipientDecline as S,integerSequence as N,askQuestion as I,getEnvelopeDocumentDownloadLink as z,getEnvelopesZip as L}from"@verdocs/js-sdk";import{u as G,g as H,r as T,a as F,d as D}from"./p-C9JdpYtM.js";import{D as q,C as M}from"./p-BU5rnXp2.js";import{V}from"./p-D97GxsI-.js";import{S as E}from"./p-C1sRVZWv.js";import{S as P}from"./p-C7hFgM52.js";import"./p-dzBXqXlK.js";import"./p-BqoC0yeA.js";const A='verdocs-sign{display:-ms-flexbox;display:flex;overflow:hidden;min-height:700px;position:relative;-ms-flex-direction:column;flex-direction:column;-webkit-box-sizing:border-box;box-sizing:border-box;background-color:#f5f5f5;font-family:var(--verdocs-primary-font, "Inter", "Barlow", sans-serif)}verdocs-sign div{display:block;-webkit-box-sizing:border-box;box-sizing:border-box}verdocs-sign input{vertical-align:top}verdocs-sign>.document{-ms-flex:1;flex:1;width:100%;height:100%;-ms-flex-item-align:center;align-self:center;display:-ms-flexbox;display:flex;padding:15px;padding-right:140px;row-gap:15px;max-width:1200px;min-height:200px;position:relative;overflow-y:scroll;-ms-flex-align:center;align-items:center;-webkit-box-sizing:border-box;box-sizing:border-box;-ms-flex-direction:column;flex-direction:column}verdocs-sign>.document .inner{width:100%;max-width:1028px}verdocs-sign>.document .document-separator{display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;gap:10px;padding:12px 20px;width:100%;max-width:1028px;-webkit-box-sizing:border-box;box-sizing:border-box;background-color:#33364b;color:white;border-radius:6px;font-size:16px;font-weight:500;margin-top:20px;-webkit-box-shadow:0 2px 4px rgba(0, 0, 0, 0.1);box-shadow:0 2px 4px rgba(0, 0, 0, 0.1)}verdocs-sign>.document .document-separator svg{-ms-flex-negative:0;flex-shrink:0}verdocs-sign>.document .document-separator:first-child{margin-top:0}verdocs-sign .signed-document-container{width:64%;margin-left:260px;-webkit-transition:all 0.3s ease;transition:all 0.3s ease}verdocs-sign .signed-document-container.zoom-normal{width:64%;margin-left:260px}verdocs-sign .signed-document-container.zoom-zoom1{width:80%;margin-left:200px}verdocs-sign .signed-document-container.zoom-zoom2{width:100%;margin-left:150px}verdocs-sign .signed-document-container.zoom-zoom2 .verdocs-flag-instance{opacity:0;pointer-events:none}@media (max-width: 768px){verdocs-sign verdocs-sign-footer{padding:0 10px}verdocs-sign verdocs-sign-footer .buttons{gap:8px}verdocs-sign verdocs-sign-footer .buttons button{font-size:10px}verdocs-sign .signed-document-container{width:100%;margin-left:0}verdocs-sign .signed-document-container.zoom-normal,verdocs-sign .signed-document-container.zoom-zoom1,verdocs-sign .signed-document-container.zoom-zoom2{width:100%;margin-left:0}verdocs-sign>.document{padding-right:15px}verdocs-sign .verdocs-flag-instance{display:none !important}verdocs-sign .controls-toolbar .center-controls{display:none}verdocs-sign .controls-toolbar .right-controls .mobile-next-button{display:block;margin-right:10px}verdocs-sign .controls-toolbar .right-controls .minus,verdocs-sign .controls-toolbar .right-controls .plus{display:none}}verdocs-sign .cover{top:0;left:0;right:0;bottom:0;display:-ms-flexbox;display:flex;z-index:5000;position:absolute;padding-top:100px;-ms-flex-align:center;align-items:center;-ms-flex-direction:column;flex-direction:column;background:rgba(0, 0, 0, 0.5)}verdocs-sign verdocs-ok-dialog .background-overlay{-ms-flex-align:start;align-items:flex-start;padding-top:100px}verdocs-sign .loading-indicator{top:0;left:0;right:0;bottom:0;display:-ms-flexbox;display:flex;z-index:10000;position:fixed;background-color:rgba(0, 0, 0, 0.7)}verdocs-sign .fatal-error{position:absolute;z-index:100;top:0;left:0;right:0;bottom:0;background-color:#4a4a4a;display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;-ms-flex-pack:center;justify-content:center}verdocs-sign .fatal-error .placeholder{position:absolute;opacity:0.1;z-index:-1;top:0;left:0;right:0;bottom:0;width:612px;height:792px;-webkit-box-shadow:0 0 10px 5px rgba(0, 0, 0, 0.0588235294);box-shadow:0 0 10px 5px rgba(0, 0, 0, 0.0588235294);margin-top:15px}verdocs-sign .fatal-error .message{max-width:360px;width:50%;font-size:16px;background:white;-webkit-box-shadow:3px 3px 9px -1px rgba(0, 0, 0, 0.2470588235);box-shadow:3px 3px 9px -1px rgba(0, 0, 0, 0.2470588235)}verdocs-sign .fatal-error .header{color:white;font-size:18px;font-weight:500;padding:5px 10px;margin:0 0 10px 0;background:#4c56cb}verdocs-sign .fatal-error p{margin:1rem;font-size:14px;font-weight:400;padding:0 10px}@media print{verdocs-sign .header,.controls-toolbar,.verdocs-flag-instance,verdocs-signing-progress{display:none !important}verdocs-sign{min-height:auto;background-color:white}verdocs-sign>.document{overflow:visible;height:auto;display:block;padding:0;margin:0}verdocs-sign>.document .document-separator{display:none}verdocs-sign .signed-document-container{width:100%;margin:0}}#verdocs-sign-header{color:#fff;width:100%;display:-ms-flexbox;display:flex;z-index:1000;-ms-flex:0 0 46px;flex:0 0 46px;font-size:12px;-webkit-column-gap:15px;-moz-column-gap:15px;column-gap:15px;-ms-flex-align:center;align-items:center;-ms-flex-direction:row;flex-direction:row;-webkit-transition:all 0.25s;transition:all 0.25s;background-color:#33354c;-webkit-box-shadow:0 4px 4px 0 rgba(0, 0, 0, 0.24), 0 0 4px 0 rgba(0, 0, 0, 0.12);box-shadow:0 4px 4px 0 rgba(0, 0, 0, 0.24), 0 0 4px 0 rgba(0, 0, 0, 0.12)}#verdocs-sign-header .inner{width:100%;display:-ms-flexbox;display:flex;margin:0 auto;padding:0 12px;max-width:1200px;-ms-flex-align:center;align-items:center;-ms-flex-direction:row;flex-direction:row;-webkit-column-gap:10px;-moz-column-gap:10px;column-gap:10px}#verdocs-sign-header .logo{width:80px;display:none;margin:-6px 0 0 0}#verdocs-sign-header .title{font-size:18px;font-weight:500;overflow:hidden;white-space:nowrap;padding:0 10px 0 0;text-overflow:ellipsis}#verdocs-sign-header .remaining-count{display:-ms-inline-flexbox;display:inline-flex;-ms-flex-align:center;align-items:center;gap:8px;color:#ffffff;font-size:13px;font-weight:400;white-space:nowrap}#verdocs-sign-header .remaining-count .check-icon{display:-ms-inline-flexbox;display:inline-flex;-ms-flex-align:center;align-items:center}#verdocs-sign-header .remaining-count .check-icon svg{width:16px;height:16px;fill:#55bc81}#verdocs-sign-header .remaining-count .separator{opacity:0.5;margin:0 2px}#verdocs-sign-header .remaining-count .review-optional{cursor:pointer;text-decoration:underline}#verdocs-sign-header .remaining-count .review-optional:hover{color:#54d68c}#verdocs-sign-header .icon-button{width:20px;height:32px;display:-ms-flexbox;display:flex;cursor:pointer;-ms-flex-align:center;align-items:center;-ms-flex-pack:center;justify-content:center;border-radius:4px;-webkit-transition:background-color 0.2s;transition:background-color 0.2s}#verdocs-sign-header .icon-button svg path{fill:#ffffff}#verdocs-sign-header .icon-button:hover{background-color:rgba(255, 255, 255, 0.1)}#verdocs-sign-header .icon-button.disabled{opacity:0.35;pointer-events:none}#verdocs-sign-header .icon-button+.icon-button{margin-left:-6px}.spinner-overlay{position:fixed;top:0;left:0;right:0;bottom:0;z-index:1000;display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;background:rgba(0, 0, 0, 0.4980392157);-ms-flex-pack:center;justify-content:center}.controls-toolbar{display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;-ms-flex-pack:justify;justify-content:space-between;height:54px;padding:0 12px 0 24px;background-color:#ffffff;border-bottom:1px solid #e0e0e0;-webkit-box-shadow:none;box-shadow:none;font-family:"Inter", sans-serif;color:#424242;z-index:1000}.controls-toolbar .left-controls{-ms-flex:1;flex:1;display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center}.controls-toolbar .left-controls .title{font-weight:500;font-size:16px;color:#242424;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.controls-toolbar .center-controls{-ms-flex:1;flex:1;-ms-flex-align:center;align-items:center;-ms-flex-pack:center;justify-content:center;gap:10px;font-size:14px;display:none}.controls-toolbar .center-controls .label{color:#000000;font-weight:300}.controls-toolbar .center-controls .select-wrapper{display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center}.controls-toolbar .center-controls .select-wrapper verdocs-select-input{margin:0}.controls-toolbar .center-controls .select-wrapper verdocs-select-input .input-label{display:none}.controls-toolbar .center-controls .select-wrapper verdocs-select-input .input-element{background:transparent;border:1px solid #e0e0e0;height:32px;padding:2px 8px;min-width:60px;text-align:center;font-family:inherit;color:#424242}.controls-toolbar .center-controls .select-wrapper verdocs-select-input .input-element:focus{border-color:var(--verdocs-primary-color, #55bc81)}.controls-toolbar .center-controls .count{color:#000000;font-weight:300}.controls-toolbar .right-controls{-ms-flex:1;flex:1;display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;-ms-flex-pack:end;justify-content:flex-end}.controls-toolbar .right-controls .mobile-next-button{display:none}.controls-toolbar .right-controls .icon-button{width:32px;height:32px;display:-ms-flexbox;display:flex;color:#424242;cursor:pointer;-ms-flex-align:center;align-items:center;-ms-flex-pack:center;justify-content:center;-webkit-transition:background-color 0.2s;transition:background-color 0.2s}.controls-toolbar .right-controls .icon-button:hover{background-color:#f5f5f5}.controls-toolbar .right-controls .icon-button.disabled{opacity:0.3;pointer-events:none}.controls-toolbar .right-controls .icon-button svg{display:block;width:20px;height:20px}';const R=`<svg width="20" height="20" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M11 8C11.2761 8 11.5 8.22386 11.5 8.5C11.5 8.77614 11.2761 9 11 9H6C5.72386 9 5.5 8.77614 5.5 8.5C5.5 8.22386 5.72386 8 6 8H11ZM14 8.5C14 5.46243 11.5376 3 8.5 3C5.46243 3 3 5.46243 3 8.5C3 11.5376 5.46243 14 8.5 14C9.83879 14 11.0659 13.5217 12.0196 12.7266L16.1464 16.8536L16.2157 16.9114C16.4106 17.0464 16.68 17.0271 16.8536 16.8536C17.0488 16.6583 17.0488 16.3417 16.8536 16.1464L12.7266 12.0196C13.5217 11.0659 14 9.83879 14 8.5ZM4 8.5C4 6.01472 6.01472 4 8.5 4C10.9853 4 13 6.01472 13 8.5C13 10.9853 10.9853 13 8.5 13C6.01472 13 4 10.9853 4 8.5Z" fill="#424242" /></svg>`;const j=`<svg width="20" height="20" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M11.5 8.5C11.5 8.22386 11.2761 8 11 8H9V6C9 5.72386 8.77614 5.5 8.5 5.5C8.22386 5.5 8 5.72386 8 6V8H6C5.72386 8 5.5 8.22386 5.5 8.5C5.5 8.77614 5.72386 9 6 9H8V11C8 11.2761 8.22386 11.5 8.5 11.5C8.77614 11.5 9 11.2761 9 11V9H11C11.2761 9 11.5 8.77614 11.5 8.5ZM8.5 3C11.5376 3 14 5.46243 14 8.5C14 9.83879 13.5217 11.0659 12.7266 12.0196L16.8536 16.1464C17.0488 16.3417 17.0488 16.6583 16.8536 16.8536C16.68 17.0271 16.4106 17.0464 16.2157 16.9114L16.1464 16.8536L12.0196 12.7266C11.0659 13.5217 9.83879 14 8.5 14C5.46243 14 3 11.5376 3 8.5C3 5.46243 5.46243 3 8.5 3ZM8.5 4C6.01472 4 4 6.01472 4 8.5C4 10.9853 6.01472 13 8.5 13C10.9853 13 13 10.9853 13 8.5C13 6.01472 10.9853 4 8.5 4Z" fill="#424242" /></svg>`;const U=`<svg width="20" height="20" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M15.5 16.9988C15.7761 16.9988 16 17.2226 16 17.4988C16 17.7442 15.8231 17.9484 15.5899 17.9907L15.5 17.9988H4.5C4.22386 17.9988 4 17.7749 4 17.4988C4 17.2533 4.17688 17.0492 4.41012 17.0068L4.5 16.9988H15.5ZM10.0001 2.00098C10.2456 2.00098 10.4497 2.17798 10.492 2.41124L10.5 2.50112L10.496 14.295L14.1414 10.6466C14.3148 10.4729 14.5842 10.4534 14.7792 10.5882L14.8485 10.646C15.0222 10.8194 15.0418 11.0888 14.907 11.2838L14.8492 11.3531L10.3574 15.8531C10.285 15.9257 10.1957 15.9714 10.1021 15.9901L9.99608 15.9999C9.83511 15.9999 9.69192 15.9237 9.60051 15.8056L5.14386 11.3537C4.94846 11.1586 4.94823 10.842 5.14336 10.6466C5.3168 10.4729 5.58621 10.4534 5.78117 10.5883L5.85046 10.6461L9.496 14.287L9.5 2.50083C9.50008 2.22469 9.724 2.00098 10.0001 2.00098Z" fill="#424242"/></svg>`;const O=`<svg width="20" height="20" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M5 4.5C5 3.67157 5.67157 3 6.5 3H13.5C14.3284 3 15 3.67157 15 4.5V5H15.5C16.8807 5 18 6.11929 18 7.5V12.5C18 13.3284 17.3284 14 16.5 14H15V15.5C15 16.3284 14.3284 17 13.5 17H6.5C5.67157 17 5 16.3284 5 15.5V14H3.5C2.67157 14 2 13.3284 2 12.5V7.5C2 6.11929 3.11929 5 4.5 5H5V4.5ZM6 5H14V4.5C14 4.22386 13.7761 4 13.5 4H6.5C6.22386 4 6 4.22386 6 4.5V5ZM5 13V11.5C5 10.6716 5.67157 10 6.5 10H13.5C14.3284 10 15 10.6716 15 11.5V13H16.5C16.7761 13 17 12.7761 17 12.5V7.5C17 6.67157 16.3284 6 15.5 6H4.5C3.67157 6 3 6.67157 3 7.5V12.5C3 12.7761 3.22386 13 3.5 13H5ZM6.5 11C6.22386 11 6 11.2239 6 11.5V15.5C6 15.7761 6.22386 16 6.5 16H13.5C13.7761 16 14 15.7761 14 15.5V11.5C14 11.2239 13.7761 11 13.5 11H6.5Z" fill="#424242"/></svg>`;const Z=class{constructor(i){e(this,i);this.sdkError=t(this,"sdkError");this.envelopeLoaded=t(this,"envelopeLoaded");this.envelopeUpdated=t(this,"envelopeUpdated");this.endpoint=new l({sessionType:"signing"});this.envelopeId=null;this.roleId=null;this.inviteCode=null;this.headerTargetId=null;this.toolbarStyle="menu";this.recipient=null;this.hasSignature=false;this.nextButtonLabel="Start";this.nextSubmits=false;this.fatalErrorHeader="";this.fatalErrorMessage="";this.focusedField="";this.disclosures=a;this.fieldUpdateCounter=0;this.submitting=false;this.submitted=false;this.isDone=false;this.showDone=false;this.adoptingSignature=false;this.showLoadError=false;this.finishLater=false;this.showFinishLater=false;this.agreed=false;this.signatureId=null;this.initialId=null;this.documentsSingularPlural="document";this.authStep=null;this.authMethodStates={};this.pageNumber=1;this.kbaQuestions=null;this.showSpinner=false;this.declining=false;this.delegating=false;this.delegated=false;this.kbaChoices=[];this.showDownloadDialog=false;this.loading=true;this.envelope=null;this.zoomLevel="normal";this.signingProgressMode="start";this.polling=true;this.renderedPages={};this.pollingInterval=null}async componentDidLoad(){var e,t,i,s,o,n;this.updateZoomFromWindow();window.addEventListener("resize",(()=>this.updateZoomFromWindow()));if(!this.envelopeId){(e=this.sdkError)===null||e===void 0?void 0:e.emit(new E("[SIGN] Missing required envelopId",500,""));return}if(!this.roleId){(t=this.sdkError)===null||t===void 0?void 0:t.emit(new E("[SIGN] Missing required roleId",500,""));return}if(!this.inviteCode){(i=this.sdkError)===null||i===void 0?void 0:i.emit(new E("[SIGN] Missing required inviteCode",500,""));return}try{console.log(`[SIGN] Processing invite code for ${this.envelopeId} / ${this.roleId}`);const e=await r(this.endpoint,this.envelopeId,this.roleId,this.inviteCode);this.processAuthResponse(e)}catch(e){console.log("[SIGN] Error with signing session",e);(s=this.sdkError)===null||s===void 0?void 0:s.emit(new E(e.message,(o=e.response)===null||o===void 0?void 0:o.status,(n=e.response)===null||n===void 0?void 0:n.data));this.showLoadError=true}}componentDidRender(){const e=this.headerTargetId?document.getElementById(this.headerTargetId):null;const t=document.getElementById("verdocs-sign-header");if(e&&t){console.log("[SIGN] Moving header");t.remove();e.append(t)}this.setupIntersectionObserver()}disconnectedCallback(){var e,t;this.stopPolling();(e=this.observer)===null||e===void 0?void 0:e.disconnect();window.removeEventListener("resize",(()=>this.updateZoomFromWindow()));(t=document.getElementById(this.getOrgStyleOverridesId()))===null||t===void 0?void 0:t.remove()}updateZoomFromWindow(){const e=window.innerWidth;if(e<768){if(this.zoomLevel!=="zoom2")this.zoomLevel="zoom2"}else if(e<1024){if(this.zoomLevel!=="zoom1")this.zoomLevel="zoom1"}else{if(this.zoomLevel!=="normal")this.zoomLevel="normal"}}setupIntersectionObserver(){const e=this.el.querySelectorAll("verdocs-envelope-document-page");if(e.length===0)return;if(this.observer){this.observer.disconnect()}const t=this.el.querySelector(".signed-document-container");const i={root:t,rootMargin:"-40% 0px -40% 0px",threshold:0};this.observer=new IntersectionObserver((e=>{e.forEach((e=>{if(e.isIntersecting){const t=e.target.id;const i=parseInt(t.replace("page-",""),10);if(!isNaN(i)&&this.pageNumber!==i){this.pageNumber=i}}}))}),i);e.forEach((e=>this.observer.observe(e)))}getOrgStyleOverridesId(){return`verdocs-org-style-overrides-${this.envelopeId}`}applyOrgStyleOverrides(){var e,t;const i=this.getOrgStyleOverridesId();const s=document.getElementById(i);const o=(t=(e=this.envelope)===null||e===void 0?void 0:e.organization)===null||t===void 0?void 0:t.style_overrides;if(typeof o==="string"){const e=s||document.createElement("style");e.id=i;e.textContent=o;if(!s){document.head.appendChild(e)}}else if(s){s.remove()}}processAuthResponse(e){var t,i,s,o;const{envelope:n,recipient:l}=e;(t=n.documents)===null||t===void 0?void 0:t.sort(((e,t)=>e.order!==t.order?e.order-t.order:e.created_at.localeCompare(t.created_at)));const{auth_step:r}=l;this.recipient=l;this.envelope=n;this.disclosures=((s=(i=this.envelope)===null||i===void 0?void 0:i.organization)===null||s===void 0?void 0:s.disclaimer)||a;this.applyOrgStyleOverrides();this.authStep=r;this.delegated=!!l.delegated_to;this.agreed=l.agreed;this.signatureId=null;this.initialId=null;this.submitted=l.status==="submitted";this.loading=false;this.isDone=this.submitted;this.showDone=this.submitted;P.updateEnvelope(this.envelopeId,n);if(this.envelope.documents.length>0){this.documentsSingularPlural="document(s)"}this.authMethodStates=l.auth_method_states||{};this.kbaQuestions=l.kba_questions;if(Object.values(this.authMethodStates).includes("failed")){this.fatalErrorHeader="Recipient Verification Failed";this.fatalErrorMessage="We were unable to verify your identity. The sender has been notified.";this.isDone=true}if(this.envelope.status==="canceled"){this.fatalErrorHeader="Unable to Start Signing Session";this.fatalErrorMessage="This envelope has been canceled. The sender has been notified."}else if(l.status==="declined"){this.fatalErrorHeader="Declined";this.fatalErrorMessage="You have declined to sign this request. The sender has been notified."}else if(this.agreed){this.nextButtonLabel="Next"}this.checkRecipientFields();(o=this.envelopeLoaded)===null||o===void 0?void 0:o.emit({endpoint:this.endpoint,envelope:this.envelope})}handleClickAgree(){this.submitting=true;console.log("[SIGN] Accepting disclosures",this.disclosures);d(this.endpoint,this.envelopeId,this.roleId,this.disclosures).then((()=>{var e;this.nextButtonLabel="Next";this.recipient.agreed=true;this.submitting=false;this.agreed=true;(e=this.envelopeUpdated)===null||e===void 0?void 0:e.emit({endpoint:this.endpoint,envelope:this.envelope,event:"agreed"})})).catch((e=>{var t,i,s;console.log("[SIGN] Unable to accept disclosures",e);V("Unable to accept disclosures, please try again later",{style:"error"});(t=this.sdkError)===null||t===void 0?void 0:t.emit(new E(e.message,(i=e.response)===null||i===void 0?void 0:i.status,(s=e.response)===null||s===void 0?void 0:s.data));this.submitting=false}))}handlePageSelect(e){const t=parseInt(e.target.value);if(!isNaN(t)){this.pageNumber=t;const e=this.el.querySelector(".signed-document-container");const i=this.el.querySelector(`#page-${t}`);if(e&&i){const t=i.offsetTop-20;e.scrollTo({top:t,behavior:"smooth"})}}}async handleOptionSelected(e){var t,i;switch(e.detail.id){case"later":this.finishLater=true;this.showFinishLater=true;(t=this.envelopeUpdated)===null||t===void 0?void 0:t.emit({endpoint:this.endpoint,envelope:this.envelope,event:"later"});break;case"delegate":this.delegating=true;break;case"decline":this.declining=true;break;case"print":window.print();(i=this.envelopeUpdated)===null||i===void 0?void 0:i.emit({endpoint:this.endpoint,envelope:this.envelope,event:"printed"});break;case"download":this.showDownloadDialog=true;this.startPolling();break}}startPolling(){this.stopPolling();const e=()=>{var e,t,i,s,o,n;const l=((e=this.envelope)===null||e===void 0?void 0:e.status)==="complete"||!!((t=this.envelope)===null||t===void 0?void 0:t.signed);const a=(s=(i=this.envelope)===null||i===void 0?void 0:i.documents)===null||s===void 0?void 0:s.some((e=>e.type==="certificate"));const r=(n=(o=this.envelope)===null||o===void 0?void 0:o.recipients)===null||n===void 0?void 0:n.every((e=>e.status==="submitted"));if(l&&a)return false;if(!r)return false;return true};if(!e()){return}this.polling=true;this.pollingInterval=setInterval((async()=>{try{const t=await c(this.endpoint,this.envelopeId);this.envelope=t;P.updateEnvelope(this.envelopeId,t);this.checkRecipientFields();if(!e()){this.stopPolling()}}catch(e){console.error("[SIGN] Polling error",e);this.stopPolling()}}),5e3)}stopPolling(){if(this.pollingInterval){clearInterval(this.pollingInterval);this.pollingInterval=null}this.polling=false}handleZoomIn(){if(this.zoomLevel==="normal"){this.zoomLevel="zoom1"}else if(this.zoomLevel==="zoom1"){this.zoomLevel="zoom2"}}handleZoomOut(){if(this.zoomLevel==="zoom1"){this.zoomLevel="normal"}else if(this.zoomLevel==="zoom2"){this.zoomLevel="zoom1"}}updateRecipientFieldValue(e,t){console.log("[SIGN] updateRecipientFieldValue",e,t);this.getRecipientFields().forEach((i=>{if(i.name===e){i.value=t.value;i.settings=t.settings;G(i);this.fieldUpdateCounter++;this.markEnvelopeStarted();this.checkRecipientFields()}}))}getStartedKey(){var e;return`${this.envelopeId}:${((e=this.recipient)===null||e===void 0?void 0:e.role_name)||""}`}markEnvelopeStarted(){const e=JSON.parse(localStorage.getItem("startedEnvelopes")||"[]");const t=this.getStartedKey();if(!e.includes(t)){e.push(t);while(e.length>10){e.shift()}localStorage.setItem("startedEnvelopes",JSON.stringify(e))}}saveFieldChange(e,t,i){const s=this.getRecipientFields().find((t=>t.name===e));if(s===null||s===void 0?void 0:s.readonly){return}console.log("[SIGN] saveFieldChange",e,{value:t,prepared:i});h(this.endpoint,this.envelopeId,this.roleId,e,t,i).then((t=>this.updateRecipientFieldValue(e,t))).catch((e=>{var t,i,s,o,n,l;if(((t=e.response)===null||t===void 0?void 0:t.status)===401&&((s=(i=e.response)===null||i===void 0?void 0:i.data)===null||s===void 0?void 0:s.error)==="jwt expired"){console.log("[SIGN] Signing session expired");this.fatalErrorHeader="Signing Session Expired";this.fatalErrorMessage="Please reload your browser to continue."}else{console.log("[SIGN] Server error",e);V("Unable to save change, please try again later",{style:"error"})}(o=this.sdkError)===null||o===void 0?void 0:o.emit(new E(e.message,(n=e.response)===null||n===void 0?void 0:n.status,(l=e.response)===null||l===void 0?void 0:l.data))}))}async handleFieldChange(e,t){if(!t.target){return}const{value:i,checked:s}=t.target;switch(e.type){case"textarea":case"textbox":return this.saveFieldChange(e.name,i,false);case"checkbox":{return this.saveFieldChange(e.name,String(t.target.checked),false)}case"radio":{return this.saveFieldChange(e.name,String(t.target.checked),false)}case"dropdown":console.log("Saving dropdown",e.name,t.detail);return this.saveFieldChange(e.name,t.detail,false);case"initial":if(t.detail===undefined){return}if(t.detail===null){console.log("[SIGN] Clearing initial");const t=await h(this.endpoint,this.envelopeId,this.roleId,e.name,null,false);return this.updateRecipientFieldValue(e.name,t)}if(this.initialId){console.log("[SIGN] Reusing initial",this.initialId);const t=await h(this.endpoint,this.envelopeId,this.roleId,e.name,this.initialId,false);return this.updateRecipientFieldValue(e.name,t)}if(typeof t.detail==="string"&&/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(t.detail)){console.log("[SIGN] Reusing initial",t.detail);const i=await h(this.endpoint,this.envelopeId,this.roleId,e.name,t.detail,false);this.initialId=t.detail;return this.updateRecipientFieldValue(e.name,i)}this.showSpinner=true;const o=await(await fetch(t.detail)).blob();return g(this.endpoint,"initial",o).then((async t=>{const i=await h(this.endpoint,this.envelopeId,this.roleId,e.name,t.id,false);this.updateRecipientFieldValue(e.name,i);this.initialId=t.id;this.showSpinner=false})).catch((e=>{console.log("Error updating initials",e);V("Unable to save initials, please try again later",{style:"error"});this.showSpinner=false}));case"signature":if(t.detail===undefined){return}if(t.detail===null){console.log("[SIGN] Clearing signature");const t=await h(this.endpoint,this.envelopeId,this.roleId,e.name,null,false);return this.updateRecipientFieldValue(e.name,t)}if(this.signatureId){console.log("[SIGN] Reusing signature",this.signatureId);const t=await h(this.endpoint,this.envelopeId,this.roleId,e.name,this.signatureId,false);return this.updateRecipientFieldValue(e.name,t)}if(typeof t.detail==="string"&&/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(t.detail)){console.log("[SIGN] Reusing signature",t.detail);const i=await h(this.endpoint,this.envelopeId,this.roleId,e.name,t.detail,false);this.signatureId=t.detail;return this.updateRecipientFieldValue(e.name,i)}this.showSpinner=true;const n=await(await fetch(t.detail)).blob();console.log("[SIGN] Creating new signature");return p(this.endpoint,"signature",n).then((async t=>{console.log("Signature update result",t);const i=await h(this.endpoint,this.envelopeId,this.roleId,e.name,t.id,false);this.updateRecipientFieldValue(e.name,i);this.signatureId=t.id;this.showSpinner=false})).catch((e=>{console.warn("[SIGN] Error updating signature",e);V("Unable to save signature, please try again later",{style:"error"});this.showSpinner=false}));case"date":const{formattedDate:l}=t.detail;if(l){return this.saveFieldChange(e.name,l,false)}break;case"timestamp":console.log("[SIGN] Updating timestamp",{value:i,ts:t.target.getAttribute("timestamp")});break;default:console.log("[SIGN] Unhandled field update",{value:i,checked:s},e);break}}getSortedFillableFields(){const e=this.getRecipientFields().filter((e=>e.type!=="timestamp"&&!e.readonly));u(e);return e}getSortedDisplayableFields(){const e=this.getRecipientFields().filter((e=>e.type!=="timestamp"));u(e);return e}async handleNext(){var e;if(this.nextSubmits){try{(e=document.getElementById("air-datepicker-global-container"))===null||e===void 0?void 0:e.remove();this.submitting=true;const t=await f(this.endpoint,this.envelopeId,this.roleId);console.log("[SIGN] Submitted successfully",t);window.location.reload()}catch(e){console.log("[SIGN] Error submitting",e);this.submitting=false;V("Unable to submit document, please try again.",{style:"error"})}return}const t=this.getSortedFillableFields().filter((e=>!this.isFieldActuallyFilled(e)));const i=this.getNextFieldFromList(t);if(i){const e=H(i);const t=document.getElementById(e);t===null||t===void 0?void 0:t.scrollIntoView({behavior:"smooth",block:"center",inline:"center"});t===null||t===void 0?void 0:t.focusField();this.focusedField=i.name}}handleNextOptional(){const e=this.getSortedFillableFields().filter((e=>!e.required&&!this.isFieldActuallyFilled(e)));const t=this.getNextFieldFromList(e);if(t){const e=H(t);const i=document.getElementById(e);i===null||i===void 0?void 0:i.scrollIntoView({behavior:"smooth",block:"center",inline:"center"});i===null||i===void 0?void 0:i.focusField();this.focusedField=t.name}}getRecipientFields(){var e;return((e=this.envelope)===null||e===void 0?void 0:e.fields.filter((e=>e.role_name===this.recipient.role_name)))||[]}getRequiredTotalCount(){return this.getSortedFillableFields().filter((e=>e.required)).length}getRequiredFilledCount(){return this.getSortedFillableFields().filter((e=>e.required&&this.isFieldActuallyFilled(e))).length}getOptionalUnfilledCount(){return this.getSortedFillableFields().filter((e=>!e.required&&!this.isFieldActuallyFilled(e))).length}checkRecipientFields(){const e=this.getRecipientFields().filter((e=>!v(e,this.getRecipientFields())));if(e.length<1){this.nextButtonLabel="Finish";if(!this.nextSubmits){this.nextSubmits=true}}else{this.nextButtonLabel="Next";this.nextSubmits=false}this.updateAllFlags();const t=JSON.parse(localStorage.getItem("startedEnvelopes")||"[]");const i=t.includes(this.getStartedKey());if(this.nextSubmits){this.signingProgressMode="completed"}else if(i){this.signingProgressMode="signing"}else{this.signingProgressMode="start"}}isFieldActuallyFilled(e){if(e.type==="radio"&&e.group){const t=this.getRecipientFields().some((t=>t.group===e.group&&t.value==="true"));if(t){return true}}return m(e,this.getRecipientFields())&&(e.type!=="dropdown"||!!e.value)&&(e.type!=="radio"||e.value==="true")&&(e.type!=="checkbox"||e.value==="true")}getNextRequiredField(){const e=this.getSortedFillableFields().filter((e=>e.required&&!this.isFieldActuallyFilled(e)));u(e);if(e.length===0){const e=this.getSortedFillableFields().filter((e=>!this.isFieldActuallyFilled(e)));u(e);if(e.length>0){return this.getNextFieldFromList(e)}return null}return this.getNextFieldFromList(e)}getNextFieldFromList(e){const t=e.findIndex((e=>e.name===this.focusedField));let i=t+1;if(i>=e.length){i=0}return e[i]}handlePrev(){var e;const t=this.getSortedFillableFields();const i=t.findIndex((e=>e.name===this.focusedField));if(i>0){const s=t[i-1];const o=H(s);const n=document.getElementById(o);n===null||n===void 0?void 0:n.scrollIntoView({behavior:"smooth",block:"center"});(e=n===null||n===void 0?void 0:n.focusField)===null||e===void 0?void 0:e.call(n);this.focusedField=s.name}}updateAllFlags(){Object.values(this.renderedPages).forEach((e=>{this.updateFlagsForPage(e)}))}updateFlagsForPage(e){if(!e)return;const t=document.getElementById(e.containerId+"-controls");if(!t)return;const i=t.querySelectorAll(".verdocs-flag-instance");i.forEach((e=>e.remove()));let s=this.getNextRequiredField();const o=this.getRecipientFields().find((e=>e.name===this.focusedField));if(o&&!m(o,this.getRecipientFields())){s=o}if(s&&s.page===e.pageNumber&&s.document_id===e.documentId){const t="fill";let i="FILL";let o=false;switch(s.type){case"signature":i="SIGN";break;case"initial":i="INITIAL";break;case"checkbox":i="CHECK";break;case"radio":i="SELECT";break;case"date":case"dropdown":i="SELECT";break;case"attachment":i="ATTACH";break;case"payment":i="PAY";break;default:i="FILL";break}if(!s.required){o=true}T(e,s.y,s.height||D(s.type),{variant:t,label:i,showSkip:o,onSkip:()=>{this.handleNext()},onClick:()=>{var e;const t=H(s);const i=document.getElementById(t);i===null||i===void 0?void 0:i.scrollIntoView({behavior:"smooth",block:"center"});(e=i===null||i===void 0?void 0:i.focusField)===null||e===void 0?void 0:e.call(i)}})}}attachFieldAttributes(e,t,i){if(i.getAttribute("attached")==="1"){return}i.setAttribute("attached","1");i.addEventListener("input",(e=>{if(e.target.type==="radio"||e.target.type==="checkbox"){this.handleFieldChange(t,e).finally((()=>this.checkRecipientFields()))}else{this.checkRecipientFields()}}));i.addEventListener("attached",(async i=>{console.log("[SIGN] onAttached",i.detail,i.target.value);this.showSpinner=true;try{const s=await x(this.endpoint,this.envelopeId,this.roleId,t.name,i.detail);this.updateRecipientFieldValue(t.name,s);this.checkRecipientFields();const o=F("envelope",t,e,{disabled:false,editable:false,draggable:false,done:this.isDone});this.attachFieldAttributes(e,t,o);this.showSpinner=false}catch(i){console.log("Error uploading attachment",i);V("Unable to upload attachment, please try again later",{style:"error"});this.showSpinner=false}}));i.addEventListener("deleted",(async i=>{console.log("[SIGN] onDeleted",i.detail,i.target.value);this.showSpinner=true;try{const i=await b(this.endpoint,this.envelopeId,this.roleId,t.name);console.log("[SIGN] Deleted attachment",i);this.updateRecipientFieldValue(t.name,i);this.checkRecipientFields();const s=F("envelope",t,e,{disabled:false,editable:false,draggable:false,done:this.isDone});this.attachFieldAttributes(e,t,s);this.showSpinner=false}catch(i){console.log("Error uploading attachment",i);V("Unable to upload attachment, please try again later",{style:"error"});this.showSpinner=false}}));i.addEventListener("focusout",(e=>{if(t.type!=="dropdown"&&t.type!=="attachment"&&t.type!=="signature"&&t.type!=="initial"&&t.type!=="checkbox"&&t.type!=="radio"){this.handleFieldChange(t,e).finally((()=>this.checkRecipientFields()))}}));i.addEventListener("fieldChange",(e=>{this.handleFieldChange(t,e).finally((()=>this.checkRecipientFields()))}));i.addEventListener("adopt",(()=>{this.focusedField=t.name;this.adoptingSignature=true}));i.setAttribute("templateid",this.envelope.template_id);i.setAttribute("fieldname",t.name);i.setAttribute("page",e.pageNumber);i.setAttribute("xScale",e.xScale);i.setAttribute("yScale",e.yScale);const s=w(this.recipient);i.setAttribute("initials",y(s));i.setAttribute("name",s);if(this.signatureId){i.setAttribute("signatureid",this.signatureId)}if(this.initialId){i.setAttribute("initialid",this.initialId)}}handlePageRendered(e){const t=e.detail;this.renderedPages[`${t.documentId}:${t.pageNumber}`]=t;const i=this.getSortedDisplayableFields();i.filter((e=>e&&e.document_id===t.documentId&&e.page===t.pageNumber)).forEach(((e,i)=>{const s=F("envelope",e,t,{disabled:false,editable:false,draggable:false,done:this.isDone},i);if(!s){return}if(Array.isArray(s)){s.map((i=>this.attachFieldAttributes(t,e,i)))}else{this.attachFieldAttributes(t,e,s)}}));this.envelope.recipients.filter((e=>e.role_name!==this.recipient.role_name&&(e.status==="invited"||e.status==="opened"||e.status==="pending"))).forEach((()=>{this.getRecipientFields().filter((e=>e.document_id===t.documentId&&e.page===t.pageNumber)).forEach((e=>{const i=F("envelope",e,t,{disabled:true,editable:false,draggable:false,done:this.isDone});if(!i){return}if(Array.isArray(i)){i.map((i=>this.attachFieldAttributes(t,e,i)))}else{this.attachFieldAttributes(t,e,i)}}))}));this.checkRecipientFields();this.updateFlagsForPage(t)}handleAuthenticateSigner(e){console.log("[SIGN] Submitting authentication step",e);k(this.endpoint,e).then((e=>{console.log("[SIGN] Verification successful",e);this.processAuthResponse(e)})).catch((e=>{var t,i,s,o,n,l;console.log("[SIGN] Error submitting authentication step",e);console.log((t=e.response)===null||t===void 0?void 0:t.data);if((o=(s=(i=e.response)===null||i===void 0?void 0:i.data)===null||s===void 0?void 0:s.error)===null||o===void 0?void 0:o.includes("failed")){this.fatalErrorHeader="Recipient Verification Failed";this.fatalErrorMessage="We were unable to verify your identity. The sender has been notified.";this.isDone=true}else{V(((l=(n=e.response)===null||n===void 0?void 0:n.data)===null||l===void 0?void 0:l.error)||"Unable to verify your identity. Please try again.",{style:"error"})}}))}render(){var e;if(this.showLoadError){return i(s,null,i("verdocs-ok-dialog",{heading:"Unable to Start Signing",message:`Sorry, your invite code is invalid or has expired. Please check your email for an updated invitation, or contact the sender.`,buttonLabel:"OK",onNext:()=>{window.location.reload()}}))}if(!this.envelope){return i(s,null,i("verdocs-loader",null))}if(this.fatalErrorMessage){return i(s,{class:{agreed:this.agreed}},i("div",{class:"fatal-error"},i("div",{class:"message"},i("div",{class:"header"},this.fatalErrorHeader),i("p",null,this.fatalErrorMessage))))}if(this.delegated){return i(s,{class:{agreed:false}},i("div",{class:"fatal-error"},i("div",{class:"message"},i("div",{class:"header"},"Delegated Signing Request"),i("p",null,"You have delegated signing to another recipient. You will not be able to sign this request again."))))}if(this.isDone){return i(s,{class:{agreed:this.agreed}},i("verdocs-view",{endpoint:this.endpoint,envelopeId:this.envelopeId,onSdkError:e=>{var t;return(t=this.sdkError)===null||t===void 0?void 0:t.emit(e.detail)}}),this.showDone&&i("verdocs-ok-dialog",{heading:"You're Done!",message:`You can access the ${this.documentsSingularPlural} at any time by clicking on the link from the invitation email.<br /><br />After all recipients have completed their actions, you will receive an email with the document and envelope certificate attached.`,onNext:e=>{e.preventDefault();e.stopPropagation();this.showDone=false;this.isDone=true}}),this.submitting&&i("div",{class:"loading-indicator"},i("verdocs-loader",null)))}if(this.delegating){return i(s,{class:"agreed"},i("div",{class:"document",style:{paddingTop:"15px"}},i("img",{src:"https://public-assets.verdocs.com/loading-placeholder.png",style:{width:"612px",height:"792px",boxShadow:"0 0 10px 5px #0000000f",marginTop:"15px"},alt:"Placeholder page"})),i("verdocs-delegate-dialog",{endpoint:this.endpoint,envelope:this.envelope,onExit:()=>this.delegating=false,onNext:e=>{C(this.endpoint,this.envelopeId,this.roleId,e.detail).then((e=>{V("Delegation request submitted.",{style:"success"});console.log("[SIGN] Delegated successfully",e);this.delegated=true;this.delegating=false})).catch((e=>{console.log("[SIGN] Error delegating request",e);V("Unable to process delegation request. Please try again later.",{style:"error"})}))}}))}if(this.declining){return i(s,{class:"agreed"},i("div",{class:"document",style:{paddingTop:"15px"}},i("img",{src:"https://public-assets.verdocs.com/loading-placeholder.png",style:{width:"612px",height:"792px",boxShadow:"0 0 10px 5px #0000000f",marginTop:"15px"},alt:"Placeholder page"})),i("verdocs-ok-dialog",{heading:"Decline Signing Request",message:`If you decline to sign this request, you will not be able to sign again in the future. The envelope sender will be notified.`,buttonLabel:"OK",showCancel:true,onExit:()=>this.declining=false,onNext:()=>{S(this.endpoint,this.envelopeId,this.roleId).then((e=>{console.log("[SIGN] Decline result",e);window.location.reload()})).catch((e=>{console.warn("[SIGN] Error declining signing session",e);V("Unable to decline, please try again later",{style:"error"})}))}}))}if(!this.agreed){return i(s,{class:"agreed"},i("div",{class:"document",style:{paddingTop:"15px"}},i("img",{src:"https://public-assets.verdocs.com/loading-placeholder.png",style:{width:"612px",height:"792px",boxShadow:"0 0 10px 5px #0000000f",marginTop:"15px"},alt:"Placeholder page"})),i("verdocs-disclosure-dialog",{disclosures:this.disclosures,delegator:this.recipient.delegator,onDelegate:()=>this.delegating=true,onDecline:()=>this.declining=true,onAccept:()=>this.handleClickAgree()}))}if(this.authStep==="passcode"){return i("verdocs-passcode-dialog",{endpoint:this.endpoint,onNext:e=>this.processAuthResponse(e.detail.response)})}if(this.authStep==="email"){return i("verdocs-otp-dialog",{endpoint:this.endpoint,method:"email",onNext:async e=>{this.processAuthResponse(e.detail.response)}})}if(this.authStep==="kba"&&!this.authMethodStates.kba){return i(s,{class:"kba"},i("div",{id:"verdocs-sign-header"},i("div",{class:"inner"},i("img",{src:"https://verdocs.com/assets/white-logo.svg",alt:"Verdocs Logo",class:"logo"}),i("div",{class:"title"},this.envelope.name))),i("div",{class:"document",style:{paddingTop:"15px"}},i("img",{src:"https://public-assets.verdocs.com/loading-placeholder.png",style:{width:"612px",height:"792px",boxShadow:"0 0 10px 5px #0000000f",marginTop:"15px"},alt:"Placeholder page"})),i("div",{class:"cover"},i("div",{class:"kba"},i("verdocs-kba-dialog",{mode:"identity",helptitle:"Document requires identity verification",helptext:"Please complete your contact details to proceed.",recipient:this.recipient,onNext:async e=>{const t=e.detail;this.handleAuthenticateSigner({auth_method:"kba",first_name:t.first_name,last_name:t.last_name,address:t.address,city:t.city,state:t.state,zip:t.zip,dob:t.dob})}}))))}if(this.authStep==="kba"&&this.authMethodStates.kba==="questions"){const e=this.kbaChoices.length;const t=this.kbaQuestions[e];return i(s,{class:"kba"},i("div",{id:"verdocs-sign-header"},i("div",{class:"inner"},i("img",{src:"https://verdocs.com/assets/white-logo.svg",alt:"Verdocs Logo",class:"logo"}),i("div",{class:"title"},this.envelope.name))),i("div",{class:"document",style:{paddingTop:"15px"}},i("img",{src:"https://public-assets.verdocs.com/loading-placeholder.png",style:{width:"612px",height:"792px",boxShadow:"0 0 10px 5px #0000000f",marginTop:"15px"},alt:"Placeholder page"})),i("div",{class:"cover"},i("div",{class:"kba"},this.kbaChoices.length>=this.kbaQuestions.length?i("verdocs-spinner",null):i("verdocs-kba-dialog",{mode:"choice",helptitle:"Your identity requires additional verification",helptext:(t===null||t===void 0?void 0:t.prompt)||"Please select one of the options below.",choices:(t===null||t===void 0?void 0:t.answer)||["Skip Question"],step:e+1,steps:this.kbaQuestions.length,onNext:async e=>{const t=e.detail;this.kbaChoices=[...this.kbaChoices,t];if(this.kbaChoices.length>=this.kbaQuestions.length){const e=this.kbaQuestions.map(((e,t)=>({type:e.type,answer:this.kbaChoices[t]})));console.log("Submitting KBA responses",this.kbaChoices,e);this.handleAuthenticateSigner({auth_method:"kba",responses:e})}}}))))}const t=[{id:"later",label:"Finish Later"},{id:"decline",label:"Decline to Sign"},{id:"print",label:"Print Without Signing"},{id:"download",label:"Download"}];const n=[{id:"print",label:"Print"},{id:"download",label:"Download"}];if(this.recipient.delegator){t.unshift({id:"delegate",label:"Delegate"})}const l=this.getRecipientFields().filter((e=>!v(e,this.getRecipientFields())));l.length>0?console.log("[SIGN] Invalid fields remaining",l.map((e=>e.name))):console.log("[SIGN] All field valid");const a=this.envelope.documents.reduce(((e,t)=>e+t.pages),0);const r=N(1,a).map((e=>({label:e.toString(),value:e.toString()})));let d=0;return i(s,null,this.toolbarStyle==="menu"&&i("div",{id:"verdocs-sign-header"},i("div",{class:"inner"},i("div",{class:"title"},this.envelope.name),i("div",{style:{flex:"1"}}),!this.finishLater&&(()=>{const e=this.getRequiredTotalCount()-this.getRequiredFilledCount();const t=this.getOptionalUnfilledCount();if(e>0){return i("span",{class:"remaining-count"},e," required field",e===1?"":"s"," left")}return i("span",{class:"remaining-count"},i("span",{class:"check-icon",innerHTML:M}),"All required fields complete",t>0&&i("span",{class:"separator"},"|"),t>0&&i("span",{class:"review-optional",onClick:()=>this.handleNextOptional()},"Review ",t," optional"))})(),!this.finishLater&&i("verdocs-button",{size:"xsmall",label:this.nextButtonLabel==="Next"?"Next Required":this.nextButtonLabel,disabled:!this.agreed||this.submitting,onClick:()=>this.handleNext()}),i("div",{class:{"icon-button":true,minus:true,disabled:this.zoomLevel==="normal"},innerHTML:R,onClick:()=>this.handleZoomOut()}),i("div",{class:{"icon-button":true,plus:true,disabled:this.zoomLevel==="zoom2"},innerHTML:j,onClick:()=>this.handleZoomIn()}),i("verdocs-dropdown",{options:!this.isDone&&!this.finishLater?t:n,onOptionSelected:e=>this.handleOptionSelected(e)}))),this.toolbarStyle==="controls"&&i("div",{class:"controls-toolbar"},i("div",{class:"left-controls"},i("div",{class:"title"},this.envelope.name)),i("div",{class:"center-controls"},i("span",{class:"label"},"Page"),i("div",{class:"select-wrapper"},i("verdocs-select-input",{options:r,value:this.pageNumber.toString(),onInput:e=>this.handlePageSelect(e)})),i("span",{class:"count"},"of ",a)),i("div",{class:"right-controls"},i("verdocs-button",{class:"mobile-next-button",label:this.nextButtonLabel,size:"xsmall",disabled:!this.agreed||this.submitting,onClick:()=>this.handleNext()}),i("div",{class:{"icon-button":true,minus:true,disabled:this.zoomLevel==="normal"},innerHTML:R,onClick:()=>this.handleZoomOut()}),i("div",{class:{"icon-button":true,plus:true,disabled:this.zoomLevel==="zoom2"},innerHTML:j,onClick:()=>this.handleZoomIn()}),i("div",{class:"icon-button download",innerHTML:U,onClick:()=>this.handleOptionSelected({detail:{id:"download"}})}),i("div",{class:"icon-button print",innerHTML:O,onClick:()=>this.handleOptionSelected({detail:{id:"print"}})}))),i("div",{class:`document signed-document-container zoom-${this.zoomLevel}`},(this.envelope.documents||[]).map((e=>{const t=N(1,e.pages);return i(o,null,this.envelope.documents.length>1&&i("div",{class:"document-separator"},i("div",{innerHTML:q}),i("span",null,e.name)),t.map((t=>{var s;const o=((s=e.page_sizes)===null||s===void 0?void 0:s[t])||{width:612,height:792};d++;return i("verdocs-envelope-document-page",{id:`page-${d}`,envelopeId:this.envelopeId,documentId:e.id,endpoint:this.endpoint,virtualWidth:o.width,virtualHeight:o.height,pageNumber:t,onPageRendered:e=>this.handlePageRendered(e),type:"filled",layers:[{name:"page",type:"canvas"},{name:"controls",type:"div"}]})})))}))),this.showFinishLater&&i("verdocs-ok-dialog",{heading:"You've saved your document to finish later.",message:`To complete the ${this.documentsSingularPlural}, use the link in the original email notification inviting you to review and finish the document.`,onNext:()=>{this.isDone=true;this.showFinishLater=false}}),this.showDone&&i("verdocs-ok-dialog",{heading:"You're Done!",message:`You can access the ${this.documentsSingularPlural} at any time by clicking on the link from the invitation email.<br /><br />After all recipients have completed their actions, you will receive an email with the document and envelope certificate attached.`,onNext:()=>{this.showDone=false;this.isDone=true}}),this.adoptingSignature&&i("verdocs-adopt-signature-dialog",{name:w(this.recipient),nameLocked:!!((e=this.recipient)===null||e===void 0?void 0:e.name_locked),onNext:async e=>{console.log("[SIGN] Adopting signature/initials block",e.detail);this.showSpinner=true;const t=await(await fetch(e.detail.signature)).blob();const i=await(await fetch(e.detail.initials)).blob();const s=await p(this.endpoint,"signature",t);console.log("[SIGN] Created signature",s);this.signatureId=s.id;const o=await g(this.endpoint,"initial",i);console.log("[SIGN] Created initials",o);this.initialId=o.id;this.showSpinner=false;this.adoptingSignature=false;this.markEnvelopeStarted();if(this.focusedField){const e=this.getRecipientFields().find((e=>e.name===this.focusedField));if(e){const t=e.type==="signature"?this.signatureId:e.type==="initial"?this.initialId:null;if(t){const i=await h(this.endpoint,this.envelopeId,this.roleId,e.name,t,false);this.updateRecipientFieldValue(e.name,i)}}this.focusedField=""}const n=this.el.querySelectorAll("verdocs-field-signature");n.forEach((e=>e.setAttribute("signatureid",this.signatureId)));const l=this.el.querySelectorAll("verdocs-field-initial");l.forEach((e=>e.setAttribute("initialid",this.initialId)));this.checkRecipientFields()},onExit:()=>this.adoptingSignature=false}),(this.submitting||this.showSpinner)&&i("verdocs-portal",null,i("div",{class:"spinner-overlay"},i("verdocs-spinner",null))),this.showDownloadDialog&&i("verdocs-download-dialog",{signed:this.envelope.signed,polling:this.polling,documents:this.envelope.documents,onExit:()=>{this.showDownloadDialog=false;this.stopPolling()},onDownload:async e=>{var t;const{action:i,documentId:s}=e.detail;console.log("[SIGN] Download action selected:",i,s);try{if(i==="document"){const e=s||((t=this.envelope.documents.find((e=>e.type==="attachment")))===null||t===void 0?void 0:t.id);if(e){const t=await z(this.endpoint,e);window.open(t,"_blank")}}else if(i==="certificate"){const e=this.envelope.documents.find((e=>e.type==="certificate"));if(e){const t=await z(this.endpoint,e.id);window.open(t,"_blank")}else{V("Certificate not yet available.",{style:"info"})}}else if(i==="zip"){const e=await L(this.endpoint,[this.envelopeId]);const t=window.URL.createObjectURL(e.data);const i=document.createElement("a");i.href=t;i.download=`${this.envelope.name}.zip`;document.body.appendChild(i);i.click();i.remove();window.URL.revokeObjectURL(t)}}catch(e){console.error("Download error",e);V("Unable to complete download request.",{style:"error"})}}}),!this.loading&&!this.isDone&&i("verdocs-sign-footer",{endpoint:this.endpoint,envelopeId:this.envelopeId,isDone:this.isDone,onAskQuestion:e=>{I(this.endpoint,this.envelopeId,this.roleId,{question:e.detail.question}).then((()=>V("Your question has been sent.",{style:"success"}))).catch((e=>{console.log("Error asking question",e);V("Unable to send question, please try again later.",{style:"error"})}))},onDecline:()=>this.declining=true,onFinishLater:()=>this.showFinishLater=true}))}get el(){return n(this)}};Z.style=A;export{Z as verdocs_sign};
|
|
2
|
-
//# sourceMappingURL=p-
|
|
1
|
+
import{r as e,c as t,h as i,H as s,F as o,g as n}from"./p-BIRwgFLv.js";import{VerdocsEndpoint as l,DEFAULT_DISCLOSURES as a,startSigningSession as r,envelopeRecipientAgree as d,getEnvelope as c,updateEnvelopeField as h,createSignature as p,createInitials as g,sortFields as u,envelopeRecipientSubmit as f,isFieldValid as v,isFieldFilled as m,uploadEnvelopeFieldAttachment as x,deleteEnvelopeFieldAttachment as b,formatFullName as w,fullNameToInitials as y,verifySigner as k,delegateRecipient as C,envelopeRecipientDecline as S,integerSequence as N,askQuestion as I,getEnvelopeDocumentDownloadLink as z,getEnvelopesZip as L}from"@verdocs/js-sdk";import{u as G,g as H,r as T,a as F,d as q}from"./p-NAwq_U8G.js";import{D,C as V}from"./p-BU5rnXp2.js";import{V as E}from"./p-D97GxsI-.js";import{S as M}from"./p-C1sRVZWv.js";import{S as A}from"./p-C7hFgM52.js";import"./p-dzBXqXlK.js";import"./p-BqoC0yeA.js";const P='verdocs-sign{display:-ms-flexbox;display:flex;overflow:hidden;min-height:700px;position:relative;-ms-flex-direction:column;flex-direction:column;-webkit-box-sizing:border-box;box-sizing:border-box;background-color:#f5f5f5;font-family:var(--verdocs-primary-font, "Inter", "Barlow", sans-serif)}verdocs-sign div{display:block;-webkit-box-sizing:border-box;box-sizing:border-box}verdocs-sign input{vertical-align:top}verdocs-sign>.document{-ms-flex:1;flex:1;width:100%;height:100%;-ms-flex-item-align:center;align-self:center;display:-ms-flexbox;display:flex;padding:15px;padding-right:140px;row-gap:15px;max-width:1200px;min-height:200px;position:relative;overflow-y:scroll;-ms-flex-align:center;align-items:center;-webkit-box-sizing:border-box;box-sizing:border-box;-ms-flex-direction:column;flex-direction:column}verdocs-sign>.document .inner{width:100%;max-width:1028px}verdocs-sign>.document .document-separator{display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;gap:10px;padding:12px 20px;width:100%;max-width:1028px;-webkit-box-sizing:border-box;box-sizing:border-box;background-color:#33364b;color:white;border-radius:6px;font-size:16px;font-weight:500;margin-top:20px;-webkit-box-shadow:0 2px 4px rgba(0, 0, 0, 0.1);box-shadow:0 2px 4px rgba(0, 0, 0, 0.1)}verdocs-sign>.document .document-separator svg{-ms-flex-negative:0;flex-shrink:0}verdocs-sign>.document .document-separator:first-child{margin-top:0}verdocs-sign .signed-document-container{width:64%;margin-left:260px;-webkit-transition:all 0.3s ease;transition:all 0.3s ease}verdocs-sign .signed-document-container.zoom-normal{width:64%;margin-left:260px}verdocs-sign .signed-document-container.zoom-zoom1{width:80%;margin-left:200px}verdocs-sign .signed-document-container.zoom-zoom2{width:100%;margin-left:150px}verdocs-sign .signed-document-container.zoom-zoom2 .verdocs-flag-instance{opacity:0;pointer-events:none}@media (max-width: 768px){verdocs-sign verdocs-sign-footer{padding:0 10px}verdocs-sign verdocs-sign-footer .buttons{gap:8px}verdocs-sign verdocs-sign-footer .buttons button{font-size:10px}verdocs-sign .signed-document-container{width:100%;margin-left:0}verdocs-sign .signed-document-container.zoom-normal,verdocs-sign .signed-document-container.zoom-zoom1,verdocs-sign .signed-document-container.zoom-zoom2{width:100%;margin-left:0}verdocs-sign>.document{padding-right:15px}verdocs-sign .verdocs-flag-instance{display:none !important}verdocs-sign .controls-toolbar .center-controls{display:none}verdocs-sign .controls-toolbar .right-controls .mobile-next-button{display:block;margin-right:10px}verdocs-sign .controls-toolbar .right-controls .minus,verdocs-sign .controls-toolbar .right-controls .plus{display:none}}verdocs-sign .cover{top:0;left:0;right:0;bottom:0;display:-ms-flexbox;display:flex;z-index:5000;position:absolute;padding-top:100px;-ms-flex-align:center;align-items:center;-ms-flex-direction:column;flex-direction:column;background:rgba(0, 0, 0, 0.5)}verdocs-sign verdocs-ok-dialog .background-overlay{-ms-flex-align:start;align-items:flex-start;padding-top:100px}verdocs-sign .loading-indicator{top:0;left:0;right:0;bottom:0;display:-ms-flexbox;display:flex;z-index:10000;position:fixed;background-color:rgba(0, 0, 0, 0.7)}verdocs-sign .fatal-error{position:absolute;z-index:100;top:0;left:0;right:0;bottom:0;background-color:#4a4a4a;display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;-ms-flex-pack:center;justify-content:center}verdocs-sign .fatal-error .placeholder{position:absolute;opacity:0.1;z-index:-1;top:0;left:0;right:0;bottom:0;width:612px;height:792px;-webkit-box-shadow:0 0 10px 5px rgba(0, 0, 0, 0.0588235294);box-shadow:0 0 10px 5px rgba(0, 0, 0, 0.0588235294);margin-top:15px}verdocs-sign .fatal-error .message{max-width:360px;width:50%;font-size:16px;background:white;-webkit-box-shadow:3px 3px 9px -1px rgba(0, 0, 0, 0.2470588235);box-shadow:3px 3px 9px -1px rgba(0, 0, 0, 0.2470588235)}verdocs-sign .fatal-error .header{color:white;font-size:18px;font-weight:500;padding:5px 10px;margin:0 0 10px 0;background:#4c56cb}verdocs-sign .fatal-error p{margin:1rem;font-size:14px;font-weight:400;padding:0 10px}@media print{verdocs-sign .header,.controls-toolbar,.verdocs-flag-instance,verdocs-signing-progress{display:none !important}verdocs-sign{min-height:auto;background-color:white}verdocs-sign>.document{overflow:visible;height:auto;display:block;padding:0;margin:0}verdocs-sign>.document .document-separator{display:none}verdocs-sign .signed-document-container{width:100%;margin:0}}#verdocs-sign-header{color:#fff;width:100%;display:-ms-flexbox;display:flex;z-index:1000;-ms-flex:0 0 46px;flex:0 0 46px;font-size:12px;-webkit-column-gap:15px;-moz-column-gap:15px;column-gap:15px;-ms-flex-align:center;align-items:center;-ms-flex-direction:row;flex-direction:row;-webkit-transition:all 0.25s;transition:all 0.25s;background-color:#33354c;-webkit-box-shadow:0 4px 4px 0 rgba(0, 0, 0, 0.24), 0 0 4px 0 rgba(0, 0, 0, 0.12);box-shadow:0 4px 4px 0 rgba(0, 0, 0, 0.24), 0 0 4px 0 rgba(0, 0, 0, 0.12)}#verdocs-sign-header .inner{width:100%;display:-ms-flexbox;display:flex;margin:0 auto;padding:0 12px;max-width:1200px;-ms-flex-align:center;align-items:center;-ms-flex-direction:row;flex-direction:row;-webkit-column-gap:10px;-moz-column-gap:10px;column-gap:10px}#verdocs-sign-header .logo{width:80px;display:none;margin:-6px 0 0 0}#verdocs-sign-header .title{font-size:18px;font-weight:500;overflow:hidden;white-space:nowrap;padding:0 10px 0 0;text-overflow:ellipsis}#verdocs-sign-header .remaining-count{display:-ms-inline-flexbox;display:inline-flex;-ms-flex-align:center;align-items:center;gap:8px;color:#ffffff;font-size:13px;font-weight:400;white-space:nowrap}#verdocs-sign-header .remaining-count .check-icon{display:-ms-inline-flexbox;display:inline-flex;-ms-flex-align:center;align-items:center}#verdocs-sign-header .remaining-count .check-icon svg{width:16px;height:16px;fill:#55bc81}#verdocs-sign-header .remaining-count .separator{opacity:0.5;margin:0 2px}#verdocs-sign-header .remaining-count .review-optional{cursor:pointer;text-decoration:underline}#verdocs-sign-header .remaining-count .review-optional:hover{color:#54d68c}#verdocs-sign-header .icon-button{width:20px;height:32px;display:-ms-flexbox;display:flex;cursor:pointer;-ms-flex-align:center;align-items:center;-ms-flex-pack:center;justify-content:center;border-radius:4px;-webkit-transition:background-color 0.2s;transition:background-color 0.2s}#verdocs-sign-header .icon-button svg path{fill:#ffffff}#verdocs-sign-header .icon-button:hover{background-color:rgba(255, 255, 255, 0.1)}#verdocs-sign-header .icon-button.disabled{opacity:0.35;pointer-events:none}#verdocs-sign-header .icon-button+.icon-button{margin-left:-6px}.spinner-overlay{position:fixed;top:0;left:0;right:0;bottom:0;z-index:1000;display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;background:rgba(0, 0, 0, 0.4980392157);-ms-flex-pack:center;justify-content:center}.controls-toolbar{display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;-ms-flex-pack:justify;justify-content:space-between;height:54px;padding:0 12px 0 24px;background-color:#ffffff;border-bottom:1px solid #e0e0e0;-webkit-box-shadow:none;box-shadow:none;font-family:"Inter", sans-serif;color:#424242;z-index:1000}.controls-toolbar .left-controls{-ms-flex:1;flex:1;display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center}.controls-toolbar .left-controls .title{font-weight:500;font-size:16px;color:#242424;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.controls-toolbar .center-controls{-ms-flex:1;flex:1;-ms-flex-align:center;align-items:center;-ms-flex-pack:center;justify-content:center;gap:10px;font-size:14px;display:none}.controls-toolbar .center-controls .label{color:#000000;font-weight:300}.controls-toolbar .center-controls .select-wrapper{display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center}.controls-toolbar .center-controls .select-wrapper verdocs-select-input{margin:0}.controls-toolbar .center-controls .select-wrapper verdocs-select-input .input-label{display:none}.controls-toolbar .center-controls .select-wrapper verdocs-select-input .input-element{background:transparent;border:1px solid #e0e0e0;height:32px;padding:2px 8px;min-width:60px;text-align:center;font-family:inherit;color:#424242}.controls-toolbar .center-controls .select-wrapper verdocs-select-input .input-element:focus{border-color:var(--verdocs-primary-color, #55bc81)}.controls-toolbar .center-controls .count{color:#000000;font-weight:300}.controls-toolbar .right-controls{-ms-flex:1;flex:1;display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;-ms-flex-pack:end;justify-content:flex-end}.controls-toolbar .right-controls .mobile-next-button{display:none}.controls-toolbar .right-controls .icon-button{width:32px;height:32px;display:-ms-flexbox;display:flex;color:#424242;cursor:pointer;-ms-flex-align:center;align-items:center;-ms-flex-pack:center;justify-content:center;-webkit-transition:background-color 0.2s;transition:background-color 0.2s}.controls-toolbar .right-controls .icon-button:hover{background-color:#f5f5f5}.controls-toolbar .right-controls .icon-button.disabled{opacity:0.3;pointer-events:none}.controls-toolbar .right-controls .icon-button svg{display:block;width:20px;height:20px}';const R=`<svg width="20" height="20" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M11 8C11.2761 8 11.5 8.22386 11.5 8.5C11.5 8.77614 11.2761 9 11 9H6C5.72386 9 5.5 8.77614 5.5 8.5C5.5 8.22386 5.72386 8 6 8H11ZM14 8.5C14 5.46243 11.5376 3 8.5 3C5.46243 3 3 5.46243 3 8.5C3 11.5376 5.46243 14 8.5 14C9.83879 14 11.0659 13.5217 12.0196 12.7266L16.1464 16.8536L16.2157 16.9114C16.4106 17.0464 16.68 17.0271 16.8536 16.8536C17.0488 16.6583 17.0488 16.3417 16.8536 16.1464L12.7266 12.0196C13.5217 11.0659 14 9.83879 14 8.5ZM4 8.5C4 6.01472 6.01472 4 8.5 4C10.9853 4 13 6.01472 13 8.5C13 10.9853 10.9853 13 8.5 13C6.01472 13 4 10.9853 4 8.5Z" fill="#424242" /></svg>`;const U=`<svg width="20" height="20" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M11.5 8.5C11.5 8.22386 11.2761 8 11 8H9V6C9 5.72386 8.77614 5.5 8.5 5.5C8.22386 5.5 8 5.72386 8 6V8H6C5.72386 8 5.5 8.22386 5.5 8.5C5.5 8.77614 5.72386 9 6 9H8V11C8 11.2761 8.22386 11.5 8.5 11.5C8.77614 11.5 9 11.2761 9 11V9H11C11.2761 9 11.5 8.77614 11.5 8.5ZM8.5 3C11.5376 3 14 5.46243 14 8.5C14 9.83879 13.5217 11.0659 12.7266 12.0196L16.8536 16.1464C17.0488 16.3417 17.0488 16.6583 16.8536 16.8536C16.68 17.0271 16.4106 17.0464 16.2157 16.9114L16.1464 16.8536L12.0196 12.7266C11.0659 13.5217 9.83879 14 8.5 14C5.46243 14 3 11.5376 3 8.5C3 5.46243 5.46243 3 8.5 3ZM8.5 4C6.01472 4 4 6.01472 4 8.5C4 10.9853 6.01472 13 8.5 13C10.9853 13 13 10.9853 13 8.5C13 6.01472 10.9853 4 8.5 4Z" fill="#424242" /></svg>`;const j=`<svg width="20" height="20" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M15.5 16.9988C15.7761 16.9988 16 17.2226 16 17.4988C16 17.7442 15.8231 17.9484 15.5899 17.9907L15.5 17.9988H4.5C4.22386 17.9988 4 17.7749 4 17.4988C4 17.2533 4.17688 17.0492 4.41012 17.0068L4.5 16.9988H15.5ZM10.0001 2.00098C10.2456 2.00098 10.4497 2.17798 10.492 2.41124L10.5 2.50112L10.496 14.295L14.1414 10.6466C14.3148 10.4729 14.5842 10.4534 14.7792 10.5882L14.8485 10.646C15.0222 10.8194 15.0418 11.0888 14.907 11.2838L14.8492 11.3531L10.3574 15.8531C10.285 15.9257 10.1957 15.9714 10.1021 15.9901L9.99608 15.9999C9.83511 15.9999 9.69192 15.9237 9.60051 15.8056L5.14386 11.3537C4.94846 11.1586 4.94823 10.842 5.14336 10.6466C5.3168 10.4729 5.58621 10.4534 5.78117 10.5883L5.85046 10.6461L9.496 14.287L9.5 2.50083C9.50008 2.22469 9.724 2.00098 10.0001 2.00098Z" fill="#424242"/></svg>`;const O=`<svg width="20" height="20" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M5 4.5C5 3.67157 5.67157 3 6.5 3H13.5C14.3284 3 15 3.67157 15 4.5V5H15.5C16.8807 5 18 6.11929 18 7.5V12.5C18 13.3284 17.3284 14 16.5 14H15V15.5C15 16.3284 14.3284 17 13.5 17H6.5C5.67157 17 5 16.3284 5 15.5V14H3.5C2.67157 14 2 13.3284 2 12.5V7.5C2 6.11929 3.11929 5 4.5 5H5V4.5ZM6 5H14V4.5C14 4.22386 13.7761 4 13.5 4H6.5C6.22386 4 6 4.22386 6 4.5V5ZM5 13V11.5C5 10.6716 5.67157 10 6.5 10H13.5C14.3284 10 15 10.6716 15 11.5V13H16.5C16.7761 13 17 12.7761 17 12.5V7.5C17 6.67157 16.3284 6 15.5 6H4.5C3.67157 6 3 6.67157 3 7.5V12.5C3 12.7761 3.22386 13 3.5 13H5ZM6.5 11C6.22386 11 6 11.2239 6 11.5V15.5C6 15.7761 6.22386 16 6.5 16H13.5C13.7761 16 14 15.7761 14 15.5V11.5C14 11.2239 13.7761 11 13.5 11H6.5Z" fill="#424242"/></svg>`;const Z=class{constructor(i){e(this,i);this.sdkError=t(this,"sdkError");this.envelopeLoaded=t(this,"envelopeLoaded");this.envelopeUpdated=t(this,"envelopeUpdated");this.endpoint=new l({sessionType:"signing"});this.envelopeId=null;this.roleId=null;this.inviteCode=null;this.headerTargetId=null;this.toolbarStyle="menu";this.recipient=null;this.hasSignature=false;this.nextButtonLabel="Start";this.nextSubmits=false;this.fatalErrorHeader="";this.fatalErrorMessage="";this.focusedField="";this.disclosures=a;this.fieldUpdateCounter=0;this.submitting=false;this.submitted=false;this.isDone=false;this.showDone=false;this.adoptingSignature=false;this.showLoadError=false;this.finishLater=false;this.showFinishLater=false;this.agreed=false;this.signatureId=null;this.initialId=null;this.documentsSingularPlural="document";this.authStep=null;this.authMethodStates={};this.pageNumber=1;this.kbaQuestions=null;this.showSpinner=false;this.declining=false;this.delegating=false;this.delegated=false;this.kbaChoices=[];this.showDownloadDialog=false;this.loading=true;this.envelope=null;this.zoomLevel="normal";this.signingProgressMode="start";this.polling=true;this.renderedPages={};this.pollingInterval=null}async componentDidLoad(){var e,t,i,s,o,n;this.updateZoomFromWindow();window.addEventListener("resize",(()=>this.updateZoomFromWindow()));if(!this.envelopeId){(e=this.sdkError)===null||e===void 0?void 0:e.emit(new M("[SIGN] Missing required envelopId",500,""));return}if(!this.roleId){(t=this.sdkError)===null||t===void 0?void 0:t.emit(new M("[SIGN] Missing required roleId",500,""));return}if(!this.inviteCode){(i=this.sdkError)===null||i===void 0?void 0:i.emit(new M("[SIGN] Missing required inviteCode",500,""));return}try{console.log(`[SIGN] Processing invite code for ${this.envelopeId} / ${this.roleId}`);const e=await r(this.endpoint,this.envelopeId,this.roleId,this.inviteCode);this.processAuthResponse(e)}catch(e){console.log("[SIGN] Error with signing session",e);(s=this.sdkError)===null||s===void 0?void 0:s.emit(new M(e.message,(o=e.response)===null||o===void 0?void 0:o.status,(n=e.response)===null||n===void 0?void 0:n.data));this.showLoadError=true}}componentDidRender(){const e=this.headerTargetId?document.getElementById(this.headerTargetId):null;const t=document.getElementById("verdocs-sign-header");if(e&&t){console.log("[SIGN] Moving header");t.remove();e.append(t)}this.setupIntersectionObserver()}disconnectedCallback(){var e,t;this.stopPolling();(e=this.observer)===null||e===void 0?void 0:e.disconnect();window.removeEventListener("resize",(()=>this.updateZoomFromWindow()));(t=document.getElementById(this.getOrgStyleOverridesId()))===null||t===void 0?void 0:t.remove()}updateZoomFromWindow(){const e=window.innerWidth;if(e<768){if(this.zoomLevel!=="zoom2")this.zoomLevel="zoom2"}else if(e<1024){if(this.zoomLevel!=="zoom1")this.zoomLevel="zoom1"}else{if(this.zoomLevel!=="normal")this.zoomLevel="normal"}}setupIntersectionObserver(){const e=this.el.querySelectorAll("verdocs-envelope-document-page");if(e.length===0)return;if(this.observer){this.observer.disconnect()}const t=this.el.querySelector(".signed-document-container");const i={root:t,rootMargin:"-40% 0px -40% 0px",threshold:0};this.observer=new IntersectionObserver((e=>{e.forEach((e=>{if(e.isIntersecting){const t=e.target.id;const i=parseInt(t.replace("page-",""),10);if(!isNaN(i)&&this.pageNumber!==i){this.pageNumber=i}}}))}),i);e.forEach((e=>this.observer.observe(e)))}getOrgStyleOverridesId(){return`verdocs-org-style-overrides-${this.envelopeId}`}applyOrgStyleOverrides(){var e,t;const i=this.getOrgStyleOverridesId();const s=document.getElementById(i);const o=(t=(e=this.envelope)===null||e===void 0?void 0:e.organization)===null||t===void 0?void 0:t.style_overrides;if(typeof o==="string"){const e=s||document.createElement("style");e.id=i;e.textContent=o;if(!s){document.head.appendChild(e)}}else if(s){s.remove()}}processAuthResponse(e){var t,i,s,o;const{envelope:n,recipient:l}=e;(t=n.documents)===null||t===void 0?void 0:t.sort(((e,t)=>e.order!==t.order?e.order-t.order:e.created_at.localeCompare(t.created_at)));const{auth_step:r}=l;this.recipient=l;this.envelope=n;this.disclosures=((s=(i=this.envelope)===null||i===void 0?void 0:i.organization)===null||s===void 0?void 0:s.disclaimer)||a;this.applyOrgStyleOverrides();this.authStep=r;this.delegated=!!l.delegated_to;this.agreed=l.agreed;this.signatureId=null;this.initialId=null;this.submitted=l.status==="submitted";this.loading=false;this.isDone=this.submitted;this.showDone=this.submitted;A.updateEnvelope(this.envelopeId,n);if(this.envelope.documents.length>0){this.documentsSingularPlural="document(s)"}this.authMethodStates=l.auth_method_states||{};this.kbaQuestions=l.kba_questions;if(Object.values(this.authMethodStates).includes("failed")){this.fatalErrorHeader="Recipient Verification Failed";this.fatalErrorMessage="We were unable to verify your identity. The sender has been notified.";this.isDone=true}if(this.envelope.status==="canceled"){this.fatalErrorHeader="Unable to Start Signing Session";this.fatalErrorMessage="This envelope has been canceled. The sender has been notified."}else if(l.status==="declined"){this.fatalErrorHeader="Declined";this.fatalErrorMessage="You have declined to sign this request. The sender has been notified."}else if(this.agreed){this.nextButtonLabel="Next"}this.checkRecipientFields();(o=this.envelopeLoaded)===null||o===void 0?void 0:o.emit({endpoint:this.endpoint,envelope:this.envelope})}handleClickAgree(){this.submitting=true;console.log("[SIGN] Accepting disclosures",this.disclosures);d(this.endpoint,this.envelopeId,this.roleId,this.disclosures).then((()=>{var e;this.nextButtonLabel="Next";this.recipient.agreed=true;this.submitting=false;this.agreed=true;(e=this.envelopeUpdated)===null||e===void 0?void 0:e.emit({endpoint:this.endpoint,envelope:this.envelope,event:"agreed"})})).catch((e=>{var t,i,s;console.log("[SIGN] Unable to accept disclosures",e);E("Unable to accept disclosures, please try again later",{style:"error"});(t=this.sdkError)===null||t===void 0?void 0:t.emit(new M(e.message,(i=e.response)===null||i===void 0?void 0:i.status,(s=e.response)===null||s===void 0?void 0:s.data));this.submitting=false}))}handlePageSelect(e){const t=parseInt(e.target.value);if(!isNaN(t)){this.pageNumber=t;const e=this.el.querySelector(".signed-document-container");const i=this.el.querySelector(`#page-${t}`);if(e&&i){const t=i.offsetTop-20;e.scrollTo({top:t,behavior:"smooth"})}}}async handleOptionSelected(e){var t,i;switch(e.detail.id){case"later":this.finishLater=true;this.showFinishLater=true;(t=this.envelopeUpdated)===null||t===void 0?void 0:t.emit({endpoint:this.endpoint,envelope:this.envelope,event:"later"});break;case"delegate":this.delegating=true;break;case"decline":this.declining=true;break;case"print":window.print();(i=this.envelopeUpdated)===null||i===void 0?void 0:i.emit({endpoint:this.endpoint,envelope:this.envelope,event:"printed"});break;case"download":this.showDownloadDialog=true;this.startPolling();break}}startPolling(){this.stopPolling();const e=()=>{var e,t,i,s,o,n;const l=((e=this.envelope)===null||e===void 0?void 0:e.status)==="complete"||!!((t=this.envelope)===null||t===void 0?void 0:t.signed);const a=(s=(i=this.envelope)===null||i===void 0?void 0:i.documents)===null||s===void 0?void 0:s.some((e=>e.type==="certificate"));const r=(n=(o=this.envelope)===null||o===void 0?void 0:o.recipients)===null||n===void 0?void 0:n.every((e=>e.status==="submitted"));if(l&&a)return false;if(!r)return false;return true};if(!e()){return}this.polling=true;this.pollingInterval=setInterval((async()=>{try{const t=await c(this.endpoint,this.envelopeId);this.envelope=t;A.updateEnvelope(this.envelopeId,t);this.checkRecipientFields();if(!e()){this.stopPolling()}}catch(e){console.error("[SIGN] Polling error",e);this.stopPolling()}}),5e3)}stopPolling(){if(this.pollingInterval){clearInterval(this.pollingInterval);this.pollingInterval=null}this.polling=false}handleZoomIn(){if(this.zoomLevel==="normal"){this.zoomLevel="zoom1"}else if(this.zoomLevel==="zoom1"){this.zoomLevel="zoom2"}}handleZoomOut(){if(this.zoomLevel==="zoom1"){this.zoomLevel="normal"}else if(this.zoomLevel==="zoom2"){this.zoomLevel="zoom1"}}updateRecipientFieldValue(e,t){console.log("[SIGN] updateRecipientFieldValue",e,t);this.getRecipientFields().forEach((i=>{if(i.name===e){i.value=t.value;i.settings=t.settings;G(i);this.fieldUpdateCounter++;this.markEnvelopeStarted();this.checkRecipientFields()}}))}getStartedKey(){var e;return`${this.envelopeId}:${((e=this.recipient)===null||e===void 0?void 0:e.role_name)||""}`}markEnvelopeStarted(){const e=JSON.parse(localStorage.getItem("startedEnvelopes")||"[]");const t=this.getStartedKey();if(!e.includes(t)){e.push(t);while(e.length>10){e.shift()}localStorage.setItem("startedEnvelopes",JSON.stringify(e))}}saveFieldChange(e,t,i){const s=this.getRecipientFields().find((t=>t.name===e));if(s===null||s===void 0?void 0:s.readonly){return}console.log("[SIGN] saveFieldChange",e,{value:t,prepared:i});h(this.endpoint,this.envelopeId,this.roleId,e,t,i).then((t=>this.updateRecipientFieldValue(e,t))).catch((e=>{var t,i,s,o,n,l;if(((t=e.response)===null||t===void 0?void 0:t.status)===401&&((s=(i=e.response)===null||i===void 0?void 0:i.data)===null||s===void 0?void 0:s.error)==="jwt expired"){console.log("[SIGN] Signing session expired");this.fatalErrorHeader="Signing Session Expired";this.fatalErrorMessage="Please reload your browser to continue."}else{console.log("[SIGN] Server error",e);E("Unable to save change, please try again later",{style:"error"})}(o=this.sdkError)===null||o===void 0?void 0:o.emit(new M(e.message,(n=e.response)===null||n===void 0?void 0:n.status,(l=e.response)===null||l===void 0?void 0:l.data))}))}async handleFieldChange(e,t){if(!t.target){return}const{value:i,checked:s}=t.target;switch(e.type){case"textarea":case"textbox":return this.saveFieldChange(e.name,i,false);case"checkbox":{return this.saveFieldChange(e.name,String(t.target.checked),false)}case"radio":{return this.saveFieldChange(e.name,String(t.target.checked),false)}case"dropdown":console.log("Saving dropdown",e.name,t.detail);return this.saveFieldChange(e.name,t.detail,false);case"initial":if(t.detail===undefined){return}if(t.detail===null){console.log("[SIGN] Clearing initial");const t=await h(this.endpoint,this.envelopeId,this.roleId,e.name,null,false);return this.updateRecipientFieldValue(e.name,t)}if(this.initialId){console.log("[SIGN] Reusing initial",this.initialId);const t=await h(this.endpoint,this.envelopeId,this.roleId,e.name,this.initialId,false);return this.updateRecipientFieldValue(e.name,t)}if(typeof t.detail==="string"&&/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(t.detail)){console.log("[SIGN] Reusing initial",t.detail);const i=await h(this.endpoint,this.envelopeId,this.roleId,e.name,t.detail,false);this.initialId=t.detail;return this.updateRecipientFieldValue(e.name,i)}this.showSpinner=true;const o=await(await fetch(t.detail)).blob();return g(this.endpoint,"initial",o).then((async t=>{const i=await h(this.endpoint,this.envelopeId,this.roleId,e.name,t.id,false);this.updateRecipientFieldValue(e.name,i);this.initialId=t.id;this.showSpinner=false})).catch((e=>{console.log("Error updating initials",e);E("Unable to save initials, please try again later",{style:"error"});this.showSpinner=false}));case"signature":if(t.detail===undefined){return}if(t.detail===null){console.log("[SIGN] Clearing signature");const t=await h(this.endpoint,this.envelopeId,this.roleId,e.name,null,false);return this.updateRecipientFieldValue(e.name,t)}if(this.signatureId){console.log("[SIGN] Reusing signature",this.signatureId);const t=await h(this.endpoint,this.envelopeId,this.roleId,e.name,this.signatureId,false);return this.updateRecipientFieldValue(e.name,t)}if(typeof t.detail==="string"&&/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(t.detail)){console.log("[SIGN] Reusing signature",t.detail);const i=await h(this.endpoint,this.envelopeId,this.roleId,e.name,t.detail,false);this.signatureId=t.detail;return this.updateRecipientFieldValue(e.name,i)}this.showSpinner=true;const n=await(await fetch(t.detail)).blob();console.log("[SIGN] Creating new signature");return p(this.endpoint,"signature",n).then((async t=>{console.log("Signature update result",t);const i=await h(this.endpoint,this.envelopeId,this.roleId,e.name,t.id,false);this.updateRecipientFieldValue(e.name,i);this.signatureId=t.id;this.showSpinner=false})).catch((e=>{console.warn("[SIGN] Error updating signature",e);E("Unable to save signature, please try again later",{style:"error"});this.showSpinner=false}));case"date":const{formattedDate:l}=t.detail;if(l){return this.saveFieldChange(e.name,l,false)}break;case"timestamp":console.log("[SIGN] Updating timestamp",{value:i,ts:t.target.getAttribute("timestamp")});break;default:console.log("[SIGN] Unhandled field update",{value:i,checked:s},e);break}}getSortedFillableFields(){const e=this.getRecipientFields().filter((e=>e.type!=="timestamp"&&!e.readonly));u(e);return e}getSortedDisplayableFields(){const e=this.getRecipientFields().filter((e=>e.type!=="timestamp"));u(e);return e}async handleNext(){var e;if(this.nextSubmits){try{(e=document.getElementById("air-datepicker-global-container"))===null||e===void 0?void 0:e.remove();this.submitting=true;const t=await f(this.endpoint,this.envelopeId,this.roleId);console.log("[SIGN] Submitted successfully",t);window.location.reload()}catch(e){console.log("[SIGN] Error submitting",e);this.submitting=false;E("Unable to submit document, please try again.",{style:"error"})}return}const t=this.getSortedFillableFields().filter((e=>!this.isFieldActuallyFilled(e)));const i=this.getNextFieldFromList(t);if(i){const e=H(i);const t=document.getElementById(e);t===null||t===void 0?void 0:t.scrollIntoView({behavior:"smooth",block:"center",inline:"center"});t===null||t===void 0?void 0:t.focusField();this.focusedField=i.name}}handleNextOptional(){const e=this.getSortedFillableFields().filter((e=>!e.required&&!this.isFieldActuallyFilled(e)));const t=this.getNextFieldFromList(e);if(t){const e=H(t);const i=document.getElementById(e);i===null||i===void 0?void 0:i.scrollIntoView({behavior:"smooth",block:"center",inline:"center"});i===null||i===void 0?void 0:i.focusField();this.focusedField=t.name}}getRecipientFields(){var e;return((e=this.envelope)===null||e===void 0?void 0:e.fields.filter((e=>e.role_name===this.recipient.role_name)))||[]}getRequiredTotalCount(){return this.getSortedFillableFields().filter((e=>e.required)).length}getRequiredFilledCount(){return this.getSortedFillableFields().filter((e=>e.required&&this.isFieldActuallyFilled(e))).length}getOptionalUnfilledCount(){return this.getSortedFillableFields().filter((e=>!e.required&&!this.isFieldActuallyFilled(e))).length}checkRecipientFields(){const e=this.getRecipientFields().filter((e=>!v(e,this.getRecipientFields())));if(e.length<1){this.nextButtonLabel="Finish";if(!this.nextSubmits){this.nextSubmits=true}}else{this.nextButtonLabel="Next";this.nextSubmits=false}this.updateAllFlags();const t=JSON.parse(localStorage.getItem("startedEnvelopes")||"[]");const i=t.includes(this.getStartedKey());if(this.nextSubmits){this.signingProgressMode="completed"}else if(i){this.signingProgressMode="signing"}else{this.signingProgressMode="start"}}isFieldActuallyFilled(e){if(e.type==="radio"&&e.group){const t=this.getRecipientFields().some((t=>t.group===e.group&&t.value==="true"));if(t){return true}}return m(e,this.getRecipientFields())&&(e.type!=="dropdown"||!!e.value)&&(e.type!=="radio"||e.value==="true")&&(e.type!=="checkbox"||e.value==="true")}getNextRequiredField(){const e=this.getSortedFillableFields().filter((e=>e.required&&!this.isFieldActuallyFilled(e)));u(e);if(e.length===0){const e=this.getSortedFillableFields().filter((e=>!this.isFieldActuallyFilled(e)));u(e);if(e.length>0){return this.getNextFieldFromList(e)}return null}return this.getNextFieldFromList(e)}getNextFieldFromList(e){const t=e.findIndex((e=>e.name===this.focusedField));let i=t+1;if(i>=e.length){i=0}return e[i]}handlePrev(){var e;const t=this.getSortedFillableFields();const i=t.findIndex((e=>e.name===this.focusedField));if(i>0){const s=t[i-1];const o=H(s);const n=document.getElementById(o);n===null||n===void 0?void 0:n.scrollIntoView({behavior:"smooth",block:"center"});(e=n===null||n===void 0?void 0:n.focusField)===null||e===void 0?void 0:e.call(n);this.focusedField=s.name}}updateAllFlags(){Object.values(this.renderedPages).forEach((e=>{this.updateFlagsForPage(e)}))}updateFlagsForPage(e){if(!e)return;const t=document.getElementById(e.containerId+"-controls");if(!t)return;const i=t.querySelectorAll(".verdocs-flag-instance");i.forEach((e=>e.remove()));let s=this.getNextRequiredField();const o=this.getRecipientFields().find((e=>e.name===this.focusedField));if(o&&!m(o,this.getRecipientFields())){s=o}if(s&&s.page===e.pageNumber&&s.document_id===e.documentId){const t="fill";let i="FILL";let o=false;switch(s.type){case"signature":i="SIGN";break;case"initial":i="INITIAL";break;case"checkbox":i="CHECK";break;case"radio":i="SELECT";break;case"date":case"dropdown":i="SELECT";break;case"attachment":i="ATTACH";break;case"payment":i="PAY";break;default:i="FILL";break}if(!s.required){o=true}T(e,s.y,s.height||q(s.type),{variant:t,label:i,showSkip:o,onSkip:()=>{this.handleNext()},onClick:()=>{var e;const t=H(s);const i=document.getElementById(t);i===null||i===void 0?void 0:i.scrollIntoView({behavior:"smooth",block:"center"});(e=i===null||i===void 0?void 0:i.focusField)===null||e===void 0?void 0:e.call(i)}})}}attachFieldAttributes(e,t,i){if(i.getAttribute("attached")==="1"){return}i.setAttribute("attached","1");i.addEventListener("input",(e=>{if(e.target.type==="radio"||e.target.type==="checkbox"){this.handleFieldChange(t,e).finally((()=>this.checkRecipientFields()))}else{this.checkRecipientFields()}}));i.addEventListener("attached",(async i=>{console.log("[SIGN] onAttached",i.detail,i.target.value);this.showSpinner=true;try{const s=await x(this.endpoint,this.envelopeId,this.roleId,t.name,i.detail);this.updateRecipientFieldValue(t.name,s);this.checkRecipientFields();const o=F("envelope",t,e,{disabled:false,editable:false,draggable:false,done:this.isDone});this.attachFieldAttributes(e,t,o);this.showSpinner=false}catch(i){console.log("Error uploading attachment",i);E("Unable to upload attachment, please try again later",{style:"error"});this.showSpinner=false}}));i.addEventListener("deleted",(async i=>{console.log("[SIGN] onDeleted",i.detail,i.target.value);this.showSpinner=true;try{const i=await b(this.endpoint,this.envelopeId,this.roleId,t.name);console.log("[SIGN] Deleted attachment",i);this.updateRecipientFieldValue(t.name,i);this.checkRecipientFields();const s=F("envelope",t,e,{disabled:false,editable:false,draggable:false,done:this.isDone});this.attachFieldAttributes(e,t,s);this.showSpinner=false}catch(i){console.log("Error uploading attachment",i);E("Unable to upload attachment, please try again later",{style:"error"});this.showSpinner=false}}));i.addEventListener("focusout",(e=>{if(t.type!=="dropdown"&&t.type!=="attachment"&&t.type!=="signature"&&t.type!=="initial"&&t.type!=="checkbox"&&t.type!=="radio"){this.handleFieldChange(t,e).finally((()=>this.checkRecipientFields()))}}));i.addEventListener("fieldChange",(e=>{this.handleFieldChange(t,e).finally((()=>this.checkRecipientFields()))}));i.addEventListener("adopt",(()=>{this.focusedField=t.name;this.adoptingSignature=true}));i.setAttribute("templateid",this.envelope.template_id);i.setAttribute("fieldname",t.name);i.setAttribute("page",e.pageNumber);i.setAttribute("xScale",e.xScale);i.setAttribute("yScale",e.yScale);const s=w(this.recipient);i.setAttribute("initials",y(s));i.setAttribute("name",s);if(this.signatureId){i.setAttribute("signatureid",this.signatureId)}if(this.initialId){i.setAttribute("initialid",this.initialId)}}handlePageRendered(e){const t=e.detail;this.renderedPages[`${t.documentId}:${t.pageNumber}`]=t;const i=this.getSortedDisplayableFields();i.filter((e=>e&&e.document_id===t.documentId&&e.page===t.pageNumber)).forEach(((e,i)=>{const s=F("envelope",e,t,{disabled:false,editable:false,draggable:false,done:this.isDone},i);if(!s){return}if(Array.isArray(s)){s.map((i=>this.attachFieldAttributes(t,e,i)))}else{this.attachFieldAttributes(t,e,s)}}));this.envelope.recipients.filter((e=>e.role_name!==this.recipient.role_name&&(e.status==="invited"||e.status==="opened"||e.status==="pending"))).forEach((()=>{this.getRecipientFields().filter((e=>e.document_id===t.documentId&&e.page===t.pageNumber)).forEach((e=>{const i=F("envelope",e,t,{disabled:true,editable:false,draggable:false,done:this.isDone});if(!i){return}if(Array.isArray(i)){i.map((i=>this.attachFieldAttributes(t,e,i)))}else{this.attachFieldAttributes(t,e,i)}}))}));this.checkRecipientFields();this.updateFlagsForPage(t)}handleAuthenticateSigner(e){console.log("[SIGN] Submitting authentication step",e);k(this.endpoint,e).then((e=>{console.log("[SIGN] Verification successful",e);this.processAuthResponse(e)})).catch((e=>{var t,i,s,o,n,l;console.log("[SIGN] Error submitting authentication step",e);console.log((t=e.response)===null||t===void 0?void 0:t.data);if((o=(s=(i=e.response)===null||i===void 0?void 0:i.data)===null||s===void 0?void 0:s.error)===null||o===void 0?void 0:o.includes("failed")){this.fatalErrorHeader="Recipient Verification Failed";this.fatalErrorMessage="We were unable to verify your identity. The sender has been notified.";this.isDone=true}else{E(((l=(n=e.response)===null||n===void 0?void 0:n.data)===null||l===void 0?void 0:l.error)||"Unable to verify your identity. Please try again.",{style:"error"})}}))}render(){var e;if(this.showLoadError){return i(s,null,i("verdocs-ok-dialog",{heading:"Unable to Start Signing",message:`Sorry, your invite code is invalid or has expired. Please check your email for an updated invitation, or contact the sender.`,buttonLabel:"OK",onNext:()=>{window.location.reload()}}))}if(!this.envelope){return i(s,null,i("verdocs-loader",null))}if(this.fatalErrorMessage){return i(s,{class:{agreed:this.agreed}},i("div",{class:"fatal-error"},i("div",{class:"message"},i("div",{class:"header"},this.fatalErrorHeader),i("p",null,this.fatalErrorMessage))))}if(this.delegated){return i(s,{class:{agreed:false}},i("div",{class:"fatal-error"},i("div",{class:"message"},i("div",{class:"header"},"Delegated Signing Request"),i("p",null,"You have delegated signing to another recipient. You will not be able to sign this request again."))))}if(this.isDone){return i(s,{class:{agreed:this.agreed}},i("verdocs-view",{endpoint:this.endpoint,envelopeId:this.envelopeId,onSdkError:e=>{var t;return(t=this.sdkError)===null||t===void 0?void 0:t.emit(e.detail)}}),this.showDone&&i("verdocs-ok-dialog",{heading:"You're Done!",message:`You can access the ${this.documentsSingularPlural} at any time by clicking on the link from the invitation email.<br /><br />After all recipients have completed their actions, you will receive an email with the document and envelope certificate attached.`,onNext:e=>{e.preventDefault();e.stopPropagation();this.showDone=false;this.isDone=true}}),this.submitting&&i("div",{class:"loading-indicator"},i("verdocs-loader",null)))}if(this.delegating){return i(s,{class:"agreed"},i("div",{class:"document",style:{paddingTop:"15px"}},i("img",{src:"https://public-assets.verdocs.com/loading-placeholder.png",style:{width:"612px",height:"792px",boxShadow:"0 0 10px 5px #0000000f",marginTop:"15px"},alt:"Placeholder page"})),i("verdocs-delegate-dialog",{endpoint:this.endpoint,envelope:this.envelope,onExit:()=>this.delegating=false,onNext:e=>{C(this.endpoint,this.envelopeId,this.roleId,e.detail).then((e=>{E("Delegation request submitted.",{style:"success"});console.log("[SIGN] Delegated successfully",e);this.delegated=true;this.delegating=false})).catch((e=>{console.log("[SIGN] Error delegating request",e);E("Unable to process delegation request. Please try again later.",{style:"error"})}))}}))}if(this.declining){return i(s,{class:"agreed"},i("div",{class:"document",style:{paddingTop:"15px"}},i("img",{src:"https://public-assets.verdocs.com/loading-placeholder.png",style:{width:"612px",height:"792px",boxShadow:"0 0 10px 5px #0000000f",marginTop:"15px"},alt:"Placeholder page"})),i("verdocs-ok-dialog",{heading:"Decline Signing Request",message:`If you decline to sign this request, you will not be able to sign again in the future. The envelope sender will be notified.`,buttonLabel:"OK",showCancel:true,onExit:()=>this.declining=false,onNext:()=>{S(this.endpoint,this.envelopeId,this.roleId).then((e=>{console.log("[SIGN] Decline result",e);window.location.reload()})).catch((e=>{console.warn("[SIGN] Error declining signing session",e);E("Unable to decline, please try again later",{style:"error"})}))}}))}if(!this.agreed){return i(s,{class:"agreed"},i("div",{class:"document",style:{paddingTop:"15px"}},i("img",{src:"https://public-assets.verdocs.com/loading-placeholder.png",style:{width:"612px",height:"792px",boxShadow:"0 0 10px 5px #0000000f",marginTop:"15px"},alt:"Placeholder page"})),i("verdocs-disclosure-dialog",{disclosures:this.disclosures,delegator:this.recipient.delegator,onDelegate:()=>this.delegating=true,onDecline:()=>this.declining=true,onAccept:()=>this.handleClickAgree()}))}if(this.authStep==="passcode"){return i("verdocs-passcode-dialog",{endpoint:this.endpoint,onNext:e=>this.processAuthResponse(e.detail.response)})}if(this.authStep==="email"){return i("verdocs-otp-dialog",{endpoint:this.endpoint,method:"email",onNext:async e=>{this.processAuthResponse(e.detail.response)}})}if(this.authStep==="kba"&&!this.authMethodStates.kba){return i(s,{class:"kba"},i("div",{id:"verdocs-sign-header"},i("div",{class:"inner"},i("img",{src:"https://verdocs.com/assets/white-logo.svg",alt:"Verdocs Logo",class:"logo"}),i("div",{class:"title"},this.envelope.name))),i("div",{class:"document",style:{paddingTop:"15px"}},i("img",{src:"https://public-assets.verdocs.com/loading-placeholder.png",style:{width:"612px",height:"792px",boxShadow:"0 0 10px 5px #0000000f",marginTop:"15px"},alt:"Placeholder page"})),i("div",{class:"cover"},i("div",{class:"kba"},i("verdocs-kba-dialog",{mode:"identity",helptitle:"Document requires identity verification",helptext:"Please complete your contact details to proceed.",recipient:this.recipient,onNext:async e=>{const t=e.detail;this.handleAuthenticateSigner({auth_method:"kba",first_name:t.first_name,last_name:t.last_name,address:t.address,city:t.city,state:t.state,zip:t.zip,dob:t.dob})}}))))}if(this.authStep==="kba"&&this.authMethodStates.kba==="questions"){const e=this.kbaChoices.length;const t=this.kbaQuestions[e];return i(s,{class:"kba"},i("div",{id:"verdocs-sign-header"},i("div",{class:"inner"},i("img",{src:"https://verdocs.com/assets/white-logo.svg",alt:"Verdocs Logo",class:"logo"}),i("div",{class:"title"},this.envelope.name))),i("div",{class:"document",style:{paddingTop:"15px"}},i("img",{src:"https://public-assets.verdocs.com/loading-placeholder.png",style:{width:"612px",height:"792px",boxShadow:"0 0 10px 5px #0000000f",marginTop:"15px"},alt:"Placeholder page"})),i("div",{class:"cover"},i("div",{class:"kba"},this.kbaChoices.length>=this.kbaQuestions.length?i("verdocs-spinner",null):i("verdocs-kba-dialog",{mode:"choice",helptitle:"Your identity requires additional verification",helptext:(t===null||t===void 0?void 0:t.prompt)||"Please select one of the options below.",choices:(t===null||t===void 0?void 0:t.answer)||["Skip Question"],step:e+1,steps:this.kbaQuestions.length,onNext:async e=>{const t=e.detail;this.kbaChoices=[...this.kbaChoices,t];if(this.kbaChoices.length>=this.kbaQuestions.length){const e=this.kbaQuestions.map(((e,t)=>({type:e.type,answer:this.kbaChoices[t]})));console.log("Submitting KBA responses",this.kbaChoices,e);this.handleAuthenticateSigner({auth_method:"kba",responses:e})}}}))))}const t=[{id:"later",label:"Finish Later"},{id:"decline",label:"Decline to Sign"},{id:"print",label:"Print Without Signing"},{id:"download",label:"Download"}];const n=[{id:"print",label:"Print"},{id:"download",label:"Download"}];if(this.recipient.delegator){t.unshift({id:"delegate",label:"Delegate"})}const l=this.getRecipientFields().filter((e=>!v(e,this.getRecipientFields())));l.length>0?console.log("[SIGN] Invalid fields remaining",l.map((e=>e.name))):console.log("[SIGN] All field valid");const a=this.envelope.documents.reduce(((e,t)=>e+t.pages),0);const r=N(1,a).map((e=>({label:e.toString(),value:e.toString()})));let d=0;return i(s,null,this.toolbarStyle==="menu"&&i("div",{id:"verdocs-sign-header"},i("div",{class:"inner"},i("div",{class:"title"},this.envelope.name),i("div",{style:{flex:"1"}}),!this.finishLater&&(()=>{const e=this.getRequiredTotalCount()-this.getRequiredFilledCount();const t=this.getOptionalUnfilledCount();if(e>0){return i("span",{class:"remaining-count"},e," required field",e===1?"":"s"," left")}return i("span",{class:"remaining-count"},i("span",{class:"check-icon",innerHTML:V}),"All required fields complete",t>0&&i("span",{class:"separator"},"|"),t>0&&i("span",{class:"review-optional",onClick:()=>this.handleNextOptional()},"Review ",t," optional"))})(),!this.finishLater&&i("verdocs-button",{size:"xsmall",label:this.nextButtonLabel==="Next"?"Next Required":this.nextButtonLabel,disabled:!this.agreed||this.submitting,onClick:()=>this.handleNext()}),i("div",{class:{"icon-button":true,minus:true,disabled:this.zoomLevel==="normal"},innerHTML:R,onClick:()=>this.handleZoomOut()}),i("div",{class:{"icon-button":true,plus:true,disabled:this.zoomLevel==="zoom2"},innerHTML:U,onClick:()=>this.handleZoomIn()}),i("verdocs-dropdown",{options:!this.isDone&&!this.finishLater?t:n,onOptionSelected:e=>this.handleOptionSelected(e)}))),this.toolbarStyle==="controls"&&i("div",{class:"controls-toolbar"},i("div",{class:"left-controls"},i("div",{class:"title"},this.envelope.name)),i("div",{class:"center-controls"},i("span",{class:"label"},"Page"),i("div",{class:"select-wrapper"},i("verdocs-select-input",{options:r,value:this.pageNumber.toString(),onInput:e=>this.handlePageSelect(e)})),i("span",{class:"count"},"of ",a)),i("div",{class:"right-controls"},i("verdocs-button",{class:"mobile-next-button",label:this.nextButtonLabel,size:"xsmall",disabled:!this.agreed||this.submitting,onClick:()=>this.handleNext()}),i("div",{class:{"icon-button":true,minus:true,disabled:this.zoomLevel==="normal"},innerHTML:R,onClick:()=>this.handleZoomOut()}),i("div",{class:{"icon-button":true,plus:true,disabled:this.zoomLevel==="zoom2"},innerHTML:U,onClick:()=>this.handleZoomIn()}),i("div",{class:"icon-button download",innerHTML:j,onClick:()=>this.handleOptionSelected({detail:{id:"download"}})}),i("div",{class:"icon-button print",innerHTML:O,onClick:()=>this.handleOptionSelected({detail:{id:"print"}})}))),i("div",{class:`document signed-document-container zoom-${this.zoomLevel}`},(this.envelope.documents||[]).map((e=>{const t=N(1,e.pages);return i(o,null,this.envelope.documents.length>1&&i("div",{class:"document-separator"},i("div",{innerHTML:D}),i("span",null,e.name)),t.map((t=>{var s;const o=((s=e.page_sizes)===null||s===void 0?void 0:s[t])||{width:612,height:792};d++;return i("verdocs-envelope-document-page",{id:`page-${d}`,envelopeId:this.envelopeId,documentId:e.id,endpoint:this.endpoint,virtualWidth:o.width,virtualHeight:o.height,pageNumber:t,onPageRendered:e=>this.handlePageRendered(e),type:"filled",layers:[{name:"page",type:"canvas"},{name:"controls",type:"div"}]})})))}))),this.showFinishLater&&i("verdocs-ok-dialog",{heading:"You've saved your document to finish later.",message:`To complete the ${this.documentsSingularPlural}, use the link in the original email notification inviting you to review and finish the document.`,onNext:()=>{this.isDone=true;this.showFinishLater=false}}),this.showDone&&i("verdocs-ok-dialog",{heading:"You're Done!",message:`You can access the ${this.documentsSingularPlural} at any time by clicking on the link from the invitation email.<br /><br />After all recipients have completed their actions, you will receive an email with the document and envelope certificate attached.`,onNext:()=>{this.showDone=false;this.isDone=true}}),this.adoptingSignature&&i("verdocs-adopt-signature-dialog",{name:w(this.recipient),nameLocked:!!((e=this.recipient)===null||e===void 0?void 0:e.name_locked),onNext:async e=>{console.log("[SIGN] Adopting signature/initials block",e.detail);this.showSpinner=true;const t=await(await fetch(e.detail.signature)).blob();const i=await(await fetch(e.detail.initials)).blob();const s=await p(this.endpoint,"signature",t);console.log("[SIGN] Created signature",s);this.signatureId=s.id;const o=await g(this.endpoint,"initial",i);console.log("[SIGN] Created initials",o);this.initialId=o.id;this.showSpinner=false;this.adoptingSignature=false;this.markEnvelopeStarted();if(this.focusedField){const e=this.getRecipientFields().find((e=>e.name===this.focusedField));if(e){const t=e.type==="signature"?this.signatureId:e.type==="initial"?this.initialId:null;if(t){const i=await h(this.endpoint,this.envelopeId,this.roleId,e.name,t,false);this.updateRecipientFieldValue(e.name,i)}}this.focusedField=""}const n=this.el.querySelectorAll("verdocs-field-signature");n.forEach((e=>e.setAttribute("signatureid",this.signatureId)));const l=this.el.querySelectorAll("verdocs-field-initial");l.forEach((e=>e.setAttribute("initialid",this.initialId)));this.checkRecipientFields()},onExit:()=>this.adoptingSignature=false}),(this.submitting||this.showSpinner)&&i("verdocs-portal",null,i("div",{class:"spinner-overlay"},i("verdocs-spinner",null))),this.showDownloadDialog&&i("verdocs-download-dialog",{signed:this.envelope.signed,polling:this.polling,documents:this.envelope.documents,onExit:()=>{this.showDownloadDialog=false;this.stopPolling()},onDownload:async e=>{var t;const{action:i,documentId:s}=e.detail;console.log("[SIGN] Download action selected:",i,s);try{if(i==="document"){const e=s||((t=this.envelope.documents.find((e=>e.type==="attachment")))===null||t===void 0?void 0:t.id);if(e){const t=await z(this.endpoint,e);window.open(t,"_blank")}}else if(i==="certificate"){const e=this.envelope.documents.find((e=>e.type==="certificate"));if(e){const t=await z(this.endpoint,e.id);window.open(t,"_blank")}else{E("Certificate not yet available.",{style:"info"})}}else if(i==="zip"){const e=await L(this.endpoint,[this.envelopeId]);const t=window.URL.createObjectURL(e.data);const i=document.createElement("a");i.href=t;i.download=`${this.envelope.name}.zip`;document.body.appendChild(i);i.click();i.remove();window.URL.revokeObjectURL(t)}}catch(e){console.error("Download error",e);E("Unable to complete download request.",{style:"error"})}}}),!this.loading&&!this.isDone&&i("verdocs-sign-footer",{endpoint:this.endpoint,envelopeId:this.envelopeId,isDone:this.isDone,onAskQuestion:e=>{I(this.endpoint,this.envelopeId,this.roleId,{question:e.detail.question}).then((()=>E("Your question has been sent.",{style:"success"}))).catch((e=>{console.log("Error asking question",e);E("Unable to send question, please try again later.",{style:"error"})}))},onDecline:()=>this.declining=true,onFinishLater:()=>this.showFinishLater=true}))}get el(){return n(this)}};Z.style=P;export{Z as verdocs_sign};
|
|
2
|
+
//# sourceMappingURL=p-b99e606b.entry.js.map
|