dromo-uploader-js 2.0.8 → 2.0.10

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/index.d.ts CHANGED
@@ -1,124 +1,120 @@
1
- import { ITableMessage, IMessagesForCell, IColumnHook, IColumnHookInput, IColumnHookOutput, IRowHook, IRowHookInput, IRowHookOutput, IDeveloperField, IDeveloperSettings, IDeveloperStyleOverrides, IUser, IValidatorField, IRowHookOutputInternal, IResultMetadata, IReviewStepData, IStepHook, IUploadStepData, IRowDeleteHook, IBulkRowHook, IBeforeFinishCallback, IBeforeFinishOutput, IPositionSpec, IConnectionMethods, ISelectField, IImporterOptions, IAllHooks, IRowToAdd } from "./interfaces";
2
- declare global {
3
- interface Window {
4
- DROMO_WIDGET_OVERRIDE?: string;
5
- }
6
- }
7
- export default class DromoUploader {
8
- constructor(licenseKey: string, fields: IDeveloperField[], settings: IDeveloperSettings, user: IUser);
9
- constructor(licenseKey: string, schemaId: string);
10
- initChild: () => Promise<void>;
11
- showIFrame: () => void;
12
- /**
13
- * Function called by the developer to set a callback
14
- *
15
- * @param fieldName the key of the column for which we want to trigger the
16
- * callback
17
- * @param callback developer defined callback that is callback that is added
18
- * to a list of column hooks
19
- */
20
- registerColumnHook: (fieldName: IColumnHook["fieldName"], callback: IColumnHook["callback"]) => void;
21
- /**
22
- * Function called by the developer to set a callback
23
- *
24
- * @param callback developer defined callback that is added to a list of row
25
- * hooks
26
- */
27
- registerBulkRowHook: (bulkRowHook: IBulkRowHook) => void;
28
- /**
29
- * Function called by the developer to set a callback
30
- *
31
- * @param callback developer defined callback that is added to a list of row
32
- * hooks
33
- */
34
- registerRowHook: (callback: IRowHook) => void;
35
- /**
36
- * Function called by the developer to set a callback
37
- *
38
- * @param callback developer defined callback that is called per step of the
39
- * import flow
40
- */
41
- registerStepHook: (type: IStepHook["type"], callback: IStepHook["callback"]) => void;
42
- /**
43
- * Function called by the developer to set a row delete callback
44
- *
45
- * @param callback developer defined callback that is called per step of the
46
- * import flow
47
- */
48
- registerRowDeleteHook: (callback: IRowDeleteHook) => void;
49
- /**
50
- * Function called by the developer to set the beforeFinish callback
51
- *
52
- * @param callback developer defined callback that is called when the user submits
53
- */
54
- beforeFinish: (callback: IBeforeFinishCallback) => void;
55
- /**
56
- * Convenience function for setting all hooks at once.
57
- *
58
- * @param hooks object containing all hooks to register
59
- */
60
- registerAllHooks: (hooks: IAllHooks) => void;
61
- /**
62
- * Function called by the developer to set a callback
63
- *
64
- * @param callback developer defined callback that is called when the import
65
- * flow completes
66
- */
67
- onResults: (callback: (data: Record<string, string | number | boolean | null>[], metadata: IResultMetadata) => Promise<void> | void) => void;
68
- /**
69
- * Function called by the developer to set a callback
70
- *
71
- * @param callback developer defined callback that is called when the user
72
- * cancels the import
73
- */
74
- onCancel: (callback: () => void) => void;
75
- /**
76
- * Function called by the developer to set or reset the user information
77
- */
78
- setUser: (user: IUser) => Promise<void>;
79
- /**
80
- * Function called by the developer to add a field midway through the import
81
- * process
82
- */
83
- addField: (field: IDeveloperField, position?: {
84
- before: string;
85
- } | {
86
- after: string;
87
- } | undefined) => Promise<void>;
88
- /**
89
- * Function called by the developer to remove a field. The data won't appear
90
- * in the user interface nor in the result data.
91
- */
92
- removeField: (fieldKey: string) => Promise<void>;
93
- /**
94
- * Function called by the developer to add new table messages throughout the
95
- * import process
96
- */
97
- updateInfoMessages: (messages: IMessagesForCell[]) => Promise<void>;
98
- /**
99
- * Function called by the developer to change the matchingStep.headerRowOverride
100
- * setting from a step hook
101
- */
102
- setHeaderRowOverride: (headerRowOverride: number | null) => Promise<void>;
103
- /**
104
- * Function called by developer called to open the iframe
105
- */
106
- open: () => Promise<void>;
107
- /**
108
- * Function called by the developer to add rows during the import
109
- */
110
- addRows: (rows: IRowToAdd[]) => Promise<void>;
111
- /**
112
- * Function called by the developer to remove rows
113
- */
114
- removeRows: (rowIds: string[]) => Promise<void>;
115
- /**
116
- * Function called by developer to close the iframe
117
- */
118
- close: () => void;
119
- /**
120
- * Function called by the developer to set developmentMode
121
- */
122
- setDevelopmentMode: (developmentMode: boolean) => Promise<void>;
123
- }
124
- export { ITableMessage, IMessagesForCell, IColumnHook, IColumnHookInput, IColumnHookOutput, IRowHook, IRowHookInput, IRowHookOutput, IDeveloperField, IDeveloperSettings, IDeveloperStyleOverrides, IUser, IValidatorField, IRowHookOutputInternal, IResultMetadata, IReviewStepData, IStepHook, IUploadStepData, IRowDeleteHook, IBulkRowHook, IBeforeFinishCallback, IBeforeFinishOutput, IPositionSpec, IConnectionMethods, ISelectField, IImporterOptions, IAllHooks, };
1
+ import { ITableMessage, IMessagesForCell, IColumnHook, IColumnHookInput, IColumnHookOutput, IRowHook, IRowHookInput, IRowHookOutput, IDeveloperField, IDeveloperSettings, IDeveloperStyleOverrides, IUser, IValidatorField, IRowHookOutputInternal, IResultMetadata, IReviewStepData, IStepHook, IUploadStepData, IRowDeleteHook, IBulkRowHook, IBeforeFinishCallback, IBeforeFinishOutput, IPositionSpec, IConnectionMethods, ISelectField, IImporterOptions, IAllHooks, IRowToAdd } from "./interfaces";
2
+ declare global {
3
+ interface Window {
4
+ DROMO_WIDGET_OVERRIDE?: string;
5
+ }
6
+ }
7
+ export default class DromoUploader {
8
+ constructor(licenseKey: string, fields: IDeveloperField[], settings: IDeveloperSettings, user: IUser);
9
+ constructor(licenseKey: string, schemaId: string);
10
+ initChild: () => Promise<void>;
11
+ showIFrame: () => void;
12
+ /**
13
+ * Function called by the developer to set a callback
14
+ *
15
+ * @param fieldName the key of the column for which we want to trigger the
16
+ * callback
17
+ * @param callback developer defined callback that is callback that is added
18
+ * to a list of column hooks
19
+ */
20
+ registerColumnHook: (fieldName: IColumnHook["fieldName"], callback: IColumnHook["callback"]) => void;
21
+ /**
22
+ * Function called by the developer to set a callback
23
+ *
24
+ * @param callback developer defined callback that is added to a list of row
25
+ * hooks
26
+ */
27
+ registerBulkRowHook: (bulkRowHook: IBulkRowHook) => void;
28
+ /**
29
+ * Function called by the developer to set a callback
30
+ *
31
+ * @param callback developer defined callback that is added to a list of row
32
+ * hooks
33
+ */
34
+ registerRowHook: (callback: IRowHook) => void;
35
+ /**
36
+ * Function called by the developer to set a callback
37
+ *
38
+ * @param callback developer defined callback that is called per step of the
39
+ * import flow
40
+ */
41
+ registerStepHook: (type: IStepHook["type"], callback: IStepHook["callback"]) => void;
42
+ /**
43
+ * Function called by the developer to set a row delete callback
44
+ *
45
+ * @param callback developer defined callback that is called per step of the
46
+ * import flow
47
+ */
48
+ registerRowDeleteHook: (callback: IRowDeleteHook) => void;
49
+ /**
50
+ * Function called by the developer to set the beforeFinish callback
51
+ *
52
+ * @param callback developer defined callback that is called when the user submits
53
+ */
54
+ beforeFinish: (callback: IBeforeFinishCallback) => void;
55
+ /**
56
+ * Convenience function for setting all hooks at once.
57
+ *
58
+ * @param hooks object containing all hooks to register
59
+ */
60
+ registerAllHooks: (hooks: IAllHooks) => void;
61
+ /**
62
+ * Function called by the developer to set a callback
63
+ *
64
+ * @param callback developer defined callback that is called when the import
65
+ * flow completes
66
+ */
67
+ onResults: (callback: (data: Record<string, string | number | boolean | null>[], metadata: IResultMetadata) => Promise<void> | void) => void;
68
+ /**
69
+ * Function called by the developer to set a callback
70
+ *
71
+ * @param callback developer defined callback that is called when the user
72
+ * cancels the import
73
+ */
74
+ onCancel: (callback: () => void) => void;
75
+ /**
76
+ * Function called by the developer to set or reset the user information
77
+ */
78
+ setUser: (user: IUser) => Promise<void>;
79
+ /**
80
+ * Function called by the developer to add a field midway through the import
81
+ * process
82
+ */
83
+ addField: (field: IDeveloperField, position?: IPositionSpec) => Promise<void>;
84
+ /**
85
+ * Function called by the developer to remove a field. The data won't appear
86
+ * in the user interface nor in the result data.
87
+ */
88
+ removeField: (fieldKey: string) => Promise<void>;
89
+ /**
90
+ * Function called by the developer to add new table messages throughout the
91
+ * import process
92
+ */
93
+ updateInfoMessages: (messages: IMessagesForCell[]) => Promise<void>;
94
+ /**
95
+ * Function called by the developer to change the matchingStep.headerRowOverride
96
+ * setting from a step hook
97
+ */
98
+ setHeaderRowOverride: (headerRowOverride: number | null) => Promise<void>;
99
+ /**
100
+ * Function called by developer called to open the iframe
101
+ */
102
+ open: () => Promise<void>;
103
+ /**
104
+ * Function called by the developer to add rows during the import
105
+ */
106
+ addRows: (rows: IRowToAdd[]) => Promise<void>;
107
+ /**
108
+ * Function called by the developer to remove rows
109
+ */
110
+ removeRows: (rowIds: string[]) => Promise<void>;
111
+ /**
112
+ * Function called by developer to close the iframe
113
+ */
114
+ close: () => void;
115
+ /**
116
+ * Function called by the developer to set developmentMode
117
+ */
118
+ setDevelopmentMode: (developmentMode: boolean) => Promise<void>;
119
+ }
120
+ export { ITableMessage, IMessagesForCell, IColumnHook, IColumnHookInput, IColumnHookOutput, IRowHook, IRowHookInput, IRowHookOutput, IDeveloperField, IDeveloperSettings, IDeveloperStyleOverrides, IUser, IValidatorField, IRowHookOutputInternal, IResultMetadata, IReviewStepData, IStepHook, IUploadStepData, IRowDeleteHook, IBulkRowHook, IBeforeFinishCallback, IBeforeFinishOutput, IPositionSpec, IConnectionMethods, ISelectField, IImporterOptions, IAllHooks, };
package/dist/index.js CHANGED
@@ -12,5 +12,5 @@
12
12
  LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
13
13
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
14
14
  PERFORMANCE OF THIS SOFTWARE.
15
- ***************************************************************************** */var e=function(){return(e=Object.assign||function(e){for(var n,o=1,t=arguments.length;o<t;o++)for(var r in n=arguments[o])Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r]);return e}).apply(this,arguments)};function n(e,n,o,t){return new(o||(o=Promise))((function(r,i){function s(e){try{a(t.next(e))}catch(e){i(e)}}function c(e){try{a(t.throw(e))}catch(e){i(e)}}function a(e){var n;e.done?r(e.value):(n=e.value,n instanceof o?n:new o((function(e){e(n)}))).then(s,c)}a((t=t.apply(e,n||[])).next())}))}function o(e,n){var o,t,r,i,s={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(i){return function(c){return function(i){if(o)throw new TypeError("Generator is already executing.");for(;s;)try{if(o=1,t&&(r=2&i[0]?t.return:i[0]?t.throw||((r=t.return)&&r.call(t),0):t.next)&&!(r=r.call(t,i[1])).done)return r;switch(t=0,r&&(i=[2&i[0],r.value]),i[0]){case 0:case 1:r=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,t=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(r=s.trys,(r=r.length>0&&r[r.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!r||i[1]>r[0]&&i[1]<r[3])){s.label=i[1];break}if(6===i[0]&&s.label<r[1]){s.label=r[1],r=i;break}if(r&&s.label<r[2]){s.label=r[2],s.ops.push(i);break}r[2]&&s.ops.pop(),s.trys.pop();continue}i=n.call(e,s)}catch(e){i=[6,e],t=0}finally{o=r=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,c])}}}var t,r,i,s,c,a,l={IFRAME_URL:"https://widget.dromo.io/"}.IFRAME_URL;!function(e){e.INIT_IFRAME="INIT_IFRAME"}(t||(t={})),function(e){e.Call="call",e.Reply="reply",e.Syn="syn",e.SynAck="synAck",e.Ack="ack"}(r||(r={})),function(e){e.Fulfilled="fulfilled",e.Rejected="rejected"}(i||(i={})),function(e){e.ConnectionDestroyed="ConnectionDestroyed",e.ConnectionTimeout="ConnectionTimeout",e.NotInIframe="NotInIframe",e.NoIframeSrc="NoIframeSrc"}(s||(s={})),function(e){e.DataCloneError="DataCloneError"}(c||(c={})),function(e){e.Message="message"}(a||(a={}));const u={"http:":"80","https:":"443"},d=/^(https?:)?\/\/([^/:]+)?(:(\d+))?/,h=["file:","data:"];const f=({name:e,message:n,stack:o})=>({name:e,message:n,stack:o});let m=0;var p=()=>++m,v=(e,n,o,t,c)=>{const{localName:l,local:u,remote:d,originForSending:h,originForReceiving:f}=n;let m=!1;c(`${l}: Connecting call sender`);const v=e=>(...n)=>{let o;c(`${l}: Sending ${e}() call`);try{d.closed&&(o=!0)}catch(e){o=!0}if(o&&t(),m){const n=new Error(`Unable to send ${e}() call due to destroyed connection`);throw n.code=s.ConnectionDestroyed,n}return new Promise(((o,t)=>{const s=p(),m=n=>{if(n.source!==d||n.data.penpal!==r.Reply||n.data.id!==s)return;if(n.origin!==f)return void c(`${l} received message from origin ${n.origin} which did not match expected origin ${f}`);const h=n.data;c(`${l}: Received ${e}() reply`),u.removeEventListener(a.Message,m);let p=h.returnValue;h.returnValueIsError&&(p=(e=>{const n=new Error;return Object.keys(e).forEach((o=>n[o]=e[o])),n})(p)),(h.resolution===i.Fulfilled?o:t)(p)};u.addEventListener(a.Message,m);const v={penpal:r.Call,id:s,methodName:e,args:n};d.postMessage(v,h)}))};return o.reduce(((e,n)=>(e[n]=v(n),e)),e),()=>{m=!0}},w=(e,n,o,t,s)=>{const{destroy:l,onDestroy:u}=t;let d,h;const m={};return t=>{if(t.origin!==n)return void s(`Parent: Handshake - Received ACK message from origin ${t.origin} which did not match expected origin ${n}`);s("Parent: Handshake - Received ACK");const p={localName:"Parent",local:window,remote:t.source,originForSending:o,originForReceiving:n};d&&d(),d=((e,n,o)=>{const{localName:t,local:s,remote:l,originForSending:u,originForReceiving:d}=e;let h=!1;const m=e=>{if(e.source!==l||e.data.penpal!==r.Call)return;if(e.origin!==d)return void o(`${t} received message from origin ${e.origin} which did not match expected origin ${d}`);const s=e.data,{methodName:a,args:m,id:p}=s;o(`${t}: Received ${a}() call`);const v=e=>n=>{if(o(`${t}: Sending ${a}() reply`),h)return void o(`${t}: Unable to send ${a}() reply due to destroyed connection`);const s={penpal:r.Reply,id:p,resolution:e,returnValue:n};e===i.Rejected&&n instanceof Error&&(s.returnValue=f(n),s.returnValueIsError=!0);try{l.postMessage(s,u)}catch(e){if(e.name===c.DataCloneError){const n={penpal:r.Reply,id:p,resolution:i.Rejected,returnValue:f(e),returnValueIsError:!0};l.postMessage(n,u)}throw e}};new Promise((e=>e(n[a].apply(n,m)))).then(v(i.Fulfilled),v(i.Rejected))};return s.addEventListener(a.Message,m),()=>{h=!0,s.removeEventListener(a.Message,m)}})(p,e,s),u(d),h&&h.forEach((e=>{delete m[e]})),h=t.data.methodNames;const w=v(m,p,h,l,s);return u(w),m}};var g=e=>{let{iframe:n,methods:o={},childOrigin:t,timeout:i,debug:c=!1}=e;const l=(e=>(...n)=>{e&&console.log("[Penpal]",...n)})(c),f=(()=>{const e=[];let n=!1;return{destroy(o){n=!0,e.forEach((e=>{e(o)}))},onDestroy(o){n?o():e.push(o)}}})(),{onDestroy:m,destroy:p}=f;t||((e=>{if(!e.src&&!e.srcdoc){const e=new Error("Iframe must have src or srcdoc property defined.");throw e.code=s.NoIframeSrc,e}})(n),t=(e=>{if(e&&h.find((n=>e.startsWith(n))))return"null";const n=document.location,o=d.exec(e);let t,r,i;return o?(t=o[1]?o[1]:n.protocol,r=o[2],i=o[4]):(t=n.protocol,r=n.hostname,i=n.port),`${t}//${r}${i&&i!==u[t]?`:${i}`:""}`})(n.src));const v="null"===t?"*":t,g=((e,n,o,t)=>i=>{if(i.origin!==o)return void e(`Parent: Handshake - Received SYN message from origin ${i.origin} which did not match expected origin ${o}`);e("Parent: Handshake - Received SYN, responding with SYN-ACK");const s={penpal:r.SynAck,methodNames:Object.keys(n)};i.source.postMessage(s,t)})(l,o,t,v),k=w(o,t,v,f,l);return{promise:new Promise(((e,o)=>{const t=((e,n)=>{let o;return void 0!==e&&(o=window.setTimeout((()=>{const o=new Error(`Connection timed out after ${e}ms`);o.code=s.ConnectionTimeout,n(o)}),e)),()=>{clearTimeout(o)}})(i,p),c=o=>{if(o.source===n.contentWindow&&o.data)if(o.data.penpal!==r.Syn)if(o.data.penpal!==r.Ack);else{const n=k(o);n&&(t(),e(n))}else g(o)};window.addEventListener(a.Message,c),l("Parent: Awaiting handshake"),((e,n)=>{const{destroy:o,onDestroy:t}=n,r=setInterval((()=>{e.isConnected||(clearInterval(r),o())}),6e4);t((()=>{clearInterval(r)}))})(n,f),m((e=>{window.removeEventListener(a.Message,c),e||((e=new Error("Connection destroyed")).code=s.ConnectionDestroyed),o(e)}))})),destroy(){p()}}},k=function(n){var o=e({},n);return o.validators&&(o.validators=o.validators.map((function(n){return("regex_match"===n.validate||"regex_exclude"===n.validate)&&n.regex instanceof RegExp?e(e({},n),{regex:n.regex.source,regexOptions:{ignoreCase:n.regex.flags.includes("i"),dotAll:n.regex.flags.includes("s"),multiline:n.regex.flags.includes("m"),unicode:n.regex.flags.includes("u")}}):n}))),o},y=function(e){return setTimeout((function(){console.warn("[Dromo Error] Slow "+e+" detected (>10s). Long running hooks can degrade user experience and importer performance.")}),1e4)},b=function(e){clearTimeout(e)};return function(){function t(t,r,i,s){var c=this;this.columnHooks=[],this.bulkRowHooks=[],this.rowHooks=[],this.stepHooks=[],this.rowDeleteHooks=[],this.initChild=function(){return n(c,void 0,void 0,(function(){var n,t,r,i,s;return o(this,(function(o){switch(o.label){case 0:return this.connection?[4,this.connection.promise]:(console.error("shim cannot connect with Dromo service."),[2]);case 1:return n=o.sent(),t=Array.from(document.getElementsByTagName("script")).some((function(e){return"https://unpkg.com/dromo-uploader-js/dist/DromoUploader.js"===e.src||"https://cdn.jsdelivr.net/npm/dromo-uploader-js@latest/dist/DromoUploader.js"===e.src})),this.fields&&this.settings&&this.user?(r=e({},this.settings),t||(r.version=null!==(i=r.version)&&void 0!==i?i:"v2"),r.browserExcelParsing=null===(s=r.browserExcelParsing)||void 0===s||s,[4,n.init(this.licenseKey,this.fields,r,this.user,this.appHost)]):[3,3];case 2:return o.sent(),[3,6];case 3:return this.schemaId?[4,n.initFromSavedSchema(this.licenseKey,this.schemaId,this.appHost,{user:this.user,developmentMode:this.developmentMode,headerRowOverride:this.headerRowOverride})]:[3,5];case 4:return o.sent(),[3,6];case 5:console.error("Invalid Dromo configuration"),o.label=6;case 6:return[4,n.setNumRegisteredRowHooks(this.totalNumRowHooks())];case 7:return o.sent(),[4,n.setNumRegisteredColHooks(this.columnHooks.length)];case 8:return o.sent(),[4,n.setNumRegisteredRowDeleteHooks(this.rowDeleteHooks.length)];case 9:return o.sent(),[2]}}))}))},this.initIFrame=function(){var e,n;if(!document.getElementById(c.iframeId)){var o=document.createElement("iframe"),t=null!==(n=null===(e=c.settings)||void 0===e?void 0:e.importIdentifier)&&void 0!==n?n:c.schemaId;o.title=t?"Dromo Importer: "+t:"Dromo Importer",o.src=window.DROMO_WIDGET_OVERRIDE||l,o.id=c.iframeId,o.style.height="100%",o.style.width="100%",o.style.border="0",o.crossorigin="anonymous",c.iframe=o}},this.createConnection=function(){var t=c,r=c.iframe;r?c.connection=g({iframe:r,methods:{handleColumnHooks:function(r,i){return n(this,void 0,void 0,(function(){var s,c,a,l,u=this;return o(this,(function(d){switch(d.label){case 0:return s=t.columnHooks.filter((function(e){return e.fieldName===r})),c=new Map,a=i,[4,s.reduce((function(e,t){return n(u,void 0,void 0,(function(){var r=this;return o(this,(function(i){switch(i.label){case 0:return[4,e.then((function(){return n(r,void 0,void 0,(function(){var e,n,r;return o(this,(function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),e=y("column hook"),[4,t.callback(a)];case 1:return n=o.sent(),b(e),n.forEach((function(e){if(void 0!==e.value||void 0!==e.info){var n={};void 0!==e.value&&(n.value=e.value,a[e.index]=e.value),void 0!==e.info&&(n.info=e.info),c.set(e.index,n)}})),[3,3];case 2:return r=o.sent(),console.error("[Dromo-External-Error] There was an error running your col hook.",r),[3,3];case 3:return[2]}}))}))}))];case 1:return i.sent(),[2]}}))}))}),Promise.resolve())];case 1:return d.sent(),l=[],c.forEach((function(n,o){return l.push(e(e({},n),{index:o}))})),[2,l]}}))}))},handleRowHooks:function(e,r){return n(this,void 0,void 0,(function(){var i,s,c,a,l,u,d,h,f,m,p,v,w,g=this;return o(this,(function(k){switch(k.label){case 0:i=new Map,s=new Map(e.map((function(e){return[e.index,e]}))),c=function(e,n){for(var o,t=0,r=Object.entries(null!=n?n:{});t<r.length;t++){var c=r[t],a=c[0],l=c[1];if(void 0===l.value&&void 0===l.info&&void 0===l.selectOptions)return;var u=s.get(e),d=i.get(e)||{},h=null!==(o=d[a])&&void 0!==o?o:{};void 0!==l.value&&(h.value=l.value,u.row[a].value=l.value),void 0!==l.info&&(h.info=l.info,u.row[a].info=l.info),void 0!==l.selectOptions&&(h.selectOptions=l.selectOptions,u.row[a].selectOptions=l.selectOptions),d[a]=h,i.set(e,d)}},a=0,l=t.bulkRowHooks,k.label=1;case 1:if(!(a<l.length))return[3,6];u=l[a],k.label=2;case 2:return k.trys.push([2,4,,5]),d=y("bulk row hook"),[4,u(e,r)];case 3:for(h=k.sent(),b(d),f=0,m=h;f<m.length;f++)p=m[f],c(p.index,p.row);return[3,5];case 4:return v=k.sent(),console.error("[Dromo-External-Error] There was an error running your bulk row hook.",v),[3,5];case 5:return a++,[3,1];case 6:return[4,Promise.all(e.map((function(e){return n(g,void 0,void 0,(function(){var n,i,s,a,l,u;return o(this,(function(o){switch(o.label){case 0:n=0,i=t.rowHooks,o.label=1;case 1:if(!(n<i.length))return[3,6];s=i[n],o.label=2;case 2:return o.trys.push([2,4,,5]),a=y("row hook"),[4,s.callback(e,r)];case 3:return l=o.sent(),b(a),c(e.index,l.row),[3,5];case 4:return u=o.sent(),console.error("[Dromo-External-Error] There was an error running your row hook.",u),[3,5];case 5:return n++,[3,1];case 6:return[2]}}))}))})))];case 7:return k.sent(),w=[],i.forEach((function(e,n){w.push({index:n,row:e})})),[2,w]}}))}))},handleStepHook:function(e,n){t.stepHooks.forEach((function(o){if(e===o.type)try{o.callback(t,n)}catch(e){console.error("[Dromo-External-Error] There was an error in your step callback.",e)}}))},handleRowDeleteHooks:function(e){var r=this;return Promise.all(e.map((function(e){return n(r,void 0,void 0,(function(){var r=this;return o(this,(function(i){switch(i.label){case 0:return[4,t.rowDeleteHooks.forEach((function(t){return n(r,void 0,void 0,(function(){var n,r;return o(this,(function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),n=y("row delete hook"),[4,t(e)];case 1:return o.sent(),b(n),[3,3];case 2:return r=o.sent(),console.error("[Dromo-External-Error] There was an error running your row delete hook.",r),[3,3];case 3:return[2]}}))}))}))];case 1:return i.sent(),[2]}}))}))})))},handleBeforeFinishCallback:function(e,r){return n(this,void 0,void 0,(function(){var n;return o(this,(function(o){switch(o.label){case 0:if(!t.beforeFinishCallback)return[3,4];o.label=1;case 1:return o.trys.push([1,3,,4]),[4,t.beforeFinishCallback(e,r,t)];case 2:return[2,o.sent()];case 3:return n=o.sent(),console.error("[Dromo-External-Error] There was an error in your beforeFinish callback.",n),[3,4];case 4:return[2]}}))}))},handleResults:function(e,r){return n(this,void 0,void 0,(function(){var n;return o(this,(function(o){switch(o.label){case 0:if(!t.resultsCallback)return[3,4];o.label=1;case 1:return o.trys.push([1,3,,4]),[4,t.resultsCallback(e,r)];case 2:return o.sent(),[3,4];case 3:return n=o.sent(),console.error("[Dromo-External-Error] There was an error in your onResult callback.",n),[3,4];case 4:return t.close(),[2]}}))}))},handleCloseModal:function(){t.close()},handleCancel:function(){if(t.cancelCallback)try{t.cancelCallback()}catch(e){console.error("[Dromo-External-Error] There was an error in your cancel callback.",e)}t.close()}}}):console.error("shim cannot connect to Dromo.")},this.mountIFrame=function(){if(!document.getElementById(c.iframeId)){var e=document.createElement("div");e.id=c.wrapperId,e.style.zIndex=Number.MAX_SAFE_INTEGER.toString(),e.style.visibility="hidden",e.style.width="0px",e.style.height="0px",e.style.position="fixed",e.style.top="0px",e.style.left="0px",e.style.right="0px",e.style.bottom="0px",e.appendChild(c.iframe),document.body.appendChild(e),c.wrapper=e}},this.showIFrame=function(){c.wrapper&&(c.wrapper.style.visibility="visible",c.wrapper.style.width="100%",c.wrapper.style.height="100%",document.body.style.overflow="hidden")},this.registerColumnHook=function(e,n){c.columnHooks.push({fieldName:e,callback:n}),c.connection&&c.connection.promise.then((function(e){e.setNumRegisteredColHooks(c.columnHooks.length)}))},this.totalNumRowHooks=function(){return c.rowHooks.length+c.bulkRowHooks.length},this.registerBulkRowHook=function(e){c.bulkRowHooks.push(e),c.connection&&c.connection.promise.then((function(e){e.setNumRegisteredRowHooks(c.totalNumRowHooks())}))},this.registerRowHook=function(e){c.rowHooks.push({callback:e}),c.connection&&c.connection.promise.then((function(e){e.setNumRegisteredRowHooks(c.totalNumRowHooks())}))},this.registerStepHook=function(e,n){c.stepHooks.push({type:e,callback:n})},this.registerRowDeleteHook=function(e){c.rowDeleteHooks.push(e),c.connection&&c.connection.promise.then((function(e){e.setNumRegisteredRowDeleteHooks(c.rowDeleteHooks.length)}))},this.beforeFinish=function(e){c.beforeFinishCallback=e},this.registerAllHooks=function(e){if(e.columnHooks)for(var n=0,o=e.columnHooks;n<o.length;n++){var t=o[n],r=t.fieldName,i=t.callback;c.registerColumnHook(r,i)}if(e.rowHooks)for(var s=0,a=e.rowHooks;s<a.length;s++){var l=a[s];c.registerRowHook(l)}if(e.bulkRowHooks)for(var u=0,d=e.bulkRowHooks;u<d.length;u++){var h=d[u];c.registerBulkRowHook(h)}if(e.rowDeleteHooks)for(var f=0,m=e.rowDeleteHooks;f<m.length;f++){var p=m[f];c.registerRowDeleteHook(p)}if(e.stepHooks)for(var v=0,w=e.stepHooks;v<w.length;v++){var g=w[v],k=g.type;i=g.callback;c.registerStepHook(k,i)}e.beforeFinishCallback&&c.beforeFinish(e.beforeFinishCallback)},this.onResults=function(e){c.resultsCallback=e},this.onCancel=function(e){c.cancelCallback=e},this.setUser=function(e){return n(c,void 0,void 0,(function(){return o(this,(function(n){switch(n.label){case 0:return this.user=e,this.connection?[4,this.connection.promise]:[3,3];case 1:return[4,n.sent().setUser(this.user)];case 2:n.sent(),n.label=3;case 3:return[2]}}))}))},this.addField=function(e,t){return n(c,void 0,void 0,(function(){return o(this,(function(n){switch(n.label){case 0:return this.connection?[4,this.connection.promise]:[3,3];case 1:return[4,n.sent().addField(k(e),t)];case 2:return n.sent(),[3,4];case 3:console.error("[Dromo-Error] Invalid connection to Dromo Uploader."),n.label=4;case 4:return[2]}}))}))},this.removeField=function(e){return n(c,void 0,void 0,(function(){return o(this,(function(n){switch(n.label){case 0:return this.connection?[4,this.connection.promise]:[3,3];case 1:return[4,n.sent().removeField(e)];case 2:return n.sent(),[3,4];case 3:console.error("[Dromo-Error] Invalid connection to Dromo Uploader."),n.label=4;case 4:return[2]}}))}))},this.updateInfoMessages=function(e){return n(c,void 0,void 0,(function(){return o(this,(function(n){switch(n.label){case 0:return this.connection?[4,this.connection.promise]:[3,3];case 1:return[4,n.sent().updateInfoMessages(e)];case 2:return n.sent(),[3,4];case 3:console.error("[Dromo-Error] Invalid connection to Dromo Uploader."),n.label=4;case 4:return[2]}}))}))},this.setHeaderRowOverride=function(e){return n(c,void 0,void 0,(function(){return o(this,(function(n){switch(n.label){case 0:return this.headerRowOverride=e,this.connection?[4,this.connection.promise]:[3,3];case 1:return[4,n.sent().setHeaderRowOverride(e)];case 2:n.sent(),n.label=3;case 3:return[2]}}))}))},this.open=function(){return n(c,void 0,void 0,(function(){return o(this,(function(e){switch(e.label){case 0:return this.wrapper||(this.initIFrame(),this.createConnection(),this.mountIFrame()),[4,this.initChild()];case 1:return e.sent(),this.showIFrame(),[2]}}))}))},this.addRows=function(e){return n(c,void 0,void 0,(function(){return o(this,(function(n){switch(n.label){case 0:return this.connection?[4,this.connection.promise]:[3,3];case 1:return[4,n.sent().addRows(e)];case 2:return n.sent(),[3,4];case 3:console.error("[Dromo-Error] Invalid connection to Dromo Uploader."),n.label=4;case 4:return[2]}}))}))},this.removeRows=function(e){return n(c,void 0,void 0,(function(){return o(this,(function(n){switch(n.label){case 0:return this.connection?[4,this.connection.promise]:[3,3];case 1:return[4,n.sent().removeRows(e)];case 2:return n.sent(),[3,4];case 3:console.error("[Dromo-Error] Invalid connection to Dromo Uploader."),n.label=4;case 4:return[2]}}))}))},this.close=function(){c.wrapper&&(c.wrapper.style.visibility="hidden",c.wrapper.style.width="0px",c.wrapper.style.height="0px",document.body.style.overflow="inherit")},this.setDevelopmentMode=function(e){return n(c,void 0,void 0,(function(){return o(this,(function(n){switch(n.label){case 0:return this.developmentMode=e,this.connection?[4,this.connection.promise]:[3,3];case 1:return[4,n.sent().setDevelopmentMode(this.developmentMode)];case 2:n.sent(),n.label=3;case 3:return[2]}}))}))},this.rehydrate=function(e,t){return n(c,void 0,void 0,(function(){return o(this,(function(n){switch(n.label){case 0:return this.wrapper||(this.initIFrame(),this.createConnection(),this.mountIFrame()),[4,this.initChild()];case 1:return n.sent(),[4,this.connection.promise];case 2:return[4,n.sent().rehydrate(e,t)];case 3:return n.sent(),this.showIFrame(),[2]}}))}))},this.iframeId=Math.random().toString(36).substring(7)+"-dromo-iframe-element",this.wrapperId=Math.random().toString(36).substring(7)+"-dromo-container",this.appHost=document.location.hostname,void 0!==i&&void 0!==s?(this.licenseKey=t,this.fields=r.map(k),this.settings=i,this.user=s):(this.licenseKey=t,this.schemaId=r)}return t.rehydrateHeadless=function(e){var r=e.licenseKey,i=e.headlessImportId,s=e.fields,c=e.settings,a=e.hooks,l=e.rehydrateState;return n(void 0,void 0,void 0,(function(){var e;return o(this,(function(n){switch(n.label){case 0:return(e=new t(r,s,c,{id:"headless-review"})).registerAllHooks(a),[4,e.rehydrate(l,i)];case 1:return n.sent(),e.open(),[2,e]}}))}))},t}()}));
15
+ ***************************************************************************** */var e=function(){return(e=Object.assign||function(e){for(var n,t=1,o=arguments.length;t<o;t++)for(var r in n=arguments[t])Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r]);return e}).apply(this,arguments)};function n(e,n,t,o){return new(t||(t=Promise))((function(r,i){function s(e){try{a(o.next(e))}catch(e){i(e)}}function c(e){try{a(o.throw(e))}catch(e){i(e)}}function a(e){var n;e.done?r(e.value):(n=e.value,n instanceof t?n:new t((function(e){e(n)}))).then(s,c)}a((o=o.apply(e,n||[])).next())}))}function t(e,n){var t,o,r,i,s={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(i){return function(c){return function(i){if(t)throw new TypeError("Generator is already executing.");for(;s;)try{if(t=1,o&&(r=2&i[0]?o.return:i[0]?o.throw||((r=o.return)&&r.call(o),0):o.next)&&!(r=r.call(o,i[1])).done)return r;switch(o=0,r&&(i=[2&i[0],r.value]),i[0]){case 0:case 1:r=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,o=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(r=s.trys,(r=r.length>0&&r[r.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!r||i[1]>r[0]&&i[1]<r[3])){s.label=i[1];break}if(6===i[0]&&s.label<r[1]){s.label=r[1],r=i;break}if(r&&s.label<r[2]){s.label=r[2],s.ops.push(i);break}r[2]&&s.ops.pop(),s.trys.pop();continue}i=n.call(e,s)}catch(e){i=[6,e],o=0}finally{t=r=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,c])}}}var o,r,i,s,c,a,l={IFRAME_URL:"https://widget.dromo.io/"}.IFRAME_URL;!function(e){e.INIT_IFRAME="INIT_IFRAME"}(o||(o={})),function(e){e.Call="call",e.Reply="reply",e.Syn="syn",e.SynAck="synAck",e.Ack="ack"}(r||(r={})),function(e){e.Fulfilled="fulfilled",e.Rejected="rejected"}(i||(i={})),function(e){e.ConnectionDestroyed="ConnectionDestroyed",e.ConnectionTimeout="ConnectionTimeout",e.NotInIframe="NotInIframe",e.NoIframeSrc="NoIframeSrc"}(s||(s={})),function(e){e.DataCloneError="DataCloneError"}(c||(c={})),function(e){e.Message="message"}(a||(a={}));const u={"http:":"80","https:":"443"},d=/^(https?:)?\/\/([^/:]+)?(:(\d+))?/,h=["file:","data:"];const f=({name:e,message:n,stack:t})=>({name:e,message:n,stack:t});let m=0;var p=()=>++m,v=(e,n,t,o,c)=>{const{localName:l,local:u,remote:d,originForSending:h,originForReceiving:f}=n;let m=!1;c(`${l}: Connecting call sender`);const v=e=>(...n)=>{let t;c(`${l}: Sending ${e}() call`);try{d.closed&&(t=!0)}catch(e){t=!0}if(t&&o(),m){const n=new Error(`Unable to send ${e}() call due to destroyed connection`);throw n.code=s.ConnectionDestroyed,n}return new Promise(((t,o)=>{const s=p(),m=n=>{if(n.source!==d||n.data.penpal!==r.Reply||n.data.id!==s)return;if(n.origin!==f)return void c(`${l} received message from origin ${n.origin} which did not match expected origin ${f}`);const h=n.data;c(`${l}: Received ${e}() reply`),u.removeEventListener(a.Message,m);let p=h.returnValue;h.returnValueIsError&&(p=(e=>{const n=new Error;return Object.keys(e).forEach((t=>n[t]=e[t])),n})(p)),(h.resolution===i.Fulfilled?t:o)(p)};u.addEventListener(a.Message,m);const v={penpal:r.Call,id:s,methodName:e,args:n};d.postMessage(v,h)}))};return t.reduce(((e,n)=>(e[n]=v(n),e)),e),()=>{m=!0}},w=(e,n,t,o,s)=>{const{destroy:l,onDestroy:u}=o;let d,h;const m={};return o=>{if(o.origin!==n)return void s(`Parent: Handshake - Received ACK message from origin ${o.origin} which did not match expected origin ${n}`);s("Parent: Handshake - Received ACK");const p={localName:"Parent",local:window,remote:o.source,originForSending:t,originForReceiving:n};d&&d(),d=((e,n,t)=>{const{localName:o,local:s,remote:l,originForSending:u,originForReceiving:d}=e;let h=!1;const m=e=>{if(e.source!==l||e.data.penpal!==r.Call)return;if(e.origin!==d)return void t(`${o} received message from origin ${e.origin} which did not match expected origin ${d}`);const s=e.data,{methodName:a,args:m,id:p}=s;t(`${o}: Received ${a}() call`);const v=e=>n=>{if(t(`${o}: Sending ${a}() reply`),h)return void t(`${o}: Unable to send ${a}() reply due to destroyed connection`);const s={penpal:r.Reply,id:p,resolution:e,returnValue:n};e===i.Rejected&&n instanceof Error&&(s.returnValue=f(n),s.returnValueIsError=!0);try{l.postMessage(s,u)}catch(e){if(e.name===c.DataCloneError){const n={penpal:r.Reply,id:p,resolution:i.Rejected,returnValue:f(e),returnValueIsError:!0};l.postMessage(n,u)}throw e}};new Promise((e=>e(n[a].apply(n,m)))).then(v(i.Fulfilled),v(i.Rejected))};return s.addEventListener(a.Message,m),()=>{h=!0,s.removeEventListener(a.Message,m)}})(p,e,s),u(d),h&&h.forEach((e=>{delete m[e]})),h=o.data.methodNames;const w=v(m,p,h,l,s);return u(w),m}};var g=e=>{let{iframe:n,methods:t={},childOrigin:o,timeout:i,debug:c=!1}=e;const l=(e=>(...n)=>{e&&console.log("[Penpal]",...n)})(c),f=(()=>{const e=[];let n=!1;return{destroy(t){n=!0,e.forEach((e=>{e(t)}))},onDestroy(t){n?t():e.push(t)}}})(),{onDestroy:m,destroy:p}=f;o||((e=>{if(!e.src&&!e.srcdoc){const e=new Error("Iframe must have src or srcdoc property defined.");throw e.code=s.NoIframeSrc,e}})(n),o=(e=>{if(e&&h.find((n=>e.startsWith(n))))return"null";const n=document.location,t=d.exec(e);let o,r,i;return t?(o=t[1]?t[1]:n.protocol,r=t[2],i=t[4]):(o=n.protocol,r=n.hostname,i=n.port),`${o}//${r}${i&&i!==u[o]?`:${i}`:""}`})(n.src));const v="null"===o?"*":o,g=((e,n,t,o)=>i=>{if(i.origin!==t)return void e(`Parent: Handshake - Received SYN message from origin ${i.origin} which did not match expected origin ${t}`);e("Parent: Handshake - Received SYN, responding with SYN-ACK");const s={penpal:r.SynAck,methodNames:Object.keys(n)};i.source.postMessage(s,o)})(l,t,o,v),y=w(t,o,v,f,l);return{promise:new Promise(((e,t)=>{const o=((e,n)=>{let t;return void 0!==e&&(t=window.setTimeout((()=>{const t=new Error(`Connection timed out after ${e}ms`);t.code=s.ConnectionTimeout,n(t)}),e)),()=>{clearTimeout(t)}})(i,p),c=t=>{if(t.source===n.contentWindow&&t.data)if(t.data.penpal!==r.Syn)if(t.data.penpal!==r.Ack);else{const n=y(t);n&&(o(),e(n))}else g(t)};window.addEventListener(a.Message,c),l("Parent: Awaiting handshake"),((e,n)=>{const{destroy:t,onDestroy:o}=n,r=setInterval((()=>{e.isConnected||(clearInterval(r),t())}),6e4);o((()=>{clearInterval(r)}))})(n,f),m((e=>{window.removeEventListener(a.Message,c),e||((e=new Error("Connection destroyed")).code=s.ConnectionDestroyed),t(e)}))})),destroy(){p()}}},y=function(e){return void 0===e.value&&void 0===e.info&&void 0===e.selectOptions&&void 0===e.manyToOne},k=function(n){var t=e({},n);return t.validators&&(t.validators=t.validators.map((function(n){return("regex_match"===n.validate||"regex_exclude"===n.validate)&&n.regex instanceof RegExp?e(e({},n),{regex:n.regex.source,regexOptions:{ignoreCase:n.regex.flags.includes("i"),dotAll:n.regex.flags.includes("s"),multiline:n.regex.flags.includes("m"),unicode:n.regex.flags.includes("u")}}):n}))),t},b=function(e){return setTimeout((function(){console.warn("[Dromo Error] Slow ".concat(e," detected (>10s). Long running hooks can degrade user experience and importer performance."))}),1e4)},E=function(e){clearTimeout(e)};return function(){function o(o,r,i,s){var c=this;this.columnHooks=[],this.bulkRowHooks=[],this.rowHooks=[],this.stepHooks=[],this.rowDeleteHooks=[],this.initChild=function(){return n(c,void 0,void 0,(function(){var n,o,r,i,s;return t(this,(function(t){switch(t.label){case 0:return this.connection?[4,this.connection.promise]:(console.error("shim cannot connect with Dromo service."),alert("There was en error opening the importer. Please contact support if this issue persists."),[2]);case 1:return n=t.sent(),o=Array.from(document.getElementsByTagName("script")).some((function(e){return"https://unpkg.com/dromo-uploader-js/dist/DromoUploader.js"===e.src||"https://cdn.jsdelivr.net/npm/dromo-uploader-js@latest/dist/DromoUploader.js"===e.src})),this.fields&&this.settings&&this.user?(r=e({},this.settings),o||(r.version=null!==(i=r.version)&&void 0!==i?i:"v2"),r.browserExcelParsing=null===(s=r.browserExcelParsing)||void 0===s||s,[4,n.init(this.licenseKey,this.fields,r,this.user,this.appHost)]):[3,3];case 2:return t.sent(),[3,6];case 3:return this.schemaId?[4,n.initFromSavedSchema(this.licenseKey,this.schemaId,this.appHost,{user:this.user,developmentMode:this.developmentMode,headerRowOverride:this.headerRowOverride})]:[3,5];case 4:return t.sent(),[3,6];case 5:console.error("Invalid Dromo configuration"),t.label=6;case 6:return[4,n.setNumRegisteredRowHooks(this.totalNumRowHooks())];case 7:return t.sent(),[4,n.setNumRegisteredColHooks(this.columnHooks.length)];case 8:return t.sent(),[4,n.setNumRegisteredRowDeleteHooks(this.rowDeleteHooks.length)];case 9:return t.sent(),[2]}}))}))},this.initIFrame=function(){var e,n;if(!document.getElementById(c.iframeId)){var t=document.createElement("iframe"),o=null!==(n=null===(e=c.settings)||void 0===e?void 0:e.importIdentifier)&&void 0!==n?n:c.schemaId;t.title=o?"Dromo Importer: ".concat(o):"Dromo Importer",t.src=window.DROMO_WIDGET_OVERRIDE||l,t.id=c.iframeId,t.style.height="100%",t.style.width="100%",t.style.border="0",t.crossorigin="anonymous",c.iframe=t}},this.createConnection=function(){var o=c,r=c.iframe;r?c.connection=g({iframe:r,methods:{handleColumnHooks:function(r,i){return n(this,void 0,void 0,(function(){var s,c,a,l,u=this;return t(this,(function(d){switch(d.label){case 0:return s=o.columnHooks.filter((function(e){return e.fieldName===r})),c=new Map,a=i,[4,s.reduce((function(e,o){return n(u,void 0,void 0,(function(){var r=this;return t(this,(function(i){switch(i.label){case 0:return[4,e.then((function(){return n(r,void 0,void 0,(function(){var e,n,r;return t(this,(function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),e=b("column hook"),[4,o.callback(a)];case 1:return n=t.sent(),E(e),n.forEach((function(e){if(void 0!==e.value||void 0!==e.info){var n={};void 0!==e.value&&(n.value=e.value,a[e.index]=e.value),void 0!==e.info&&(n.info=e.info),c.set(e.index,n)}})),[3,3];case 2:return r=t.sent(),console.error("[Dromo-External-Error] There was an error running your col hook.",r),[3,3];case 3:return[2]}}))}))}))];case 1:return i.sent(),[2]}}))}))}),Promise.resolve())];case 1:return d.sent(),l=[],c.forEach((function(n,t){return l.push(e(e({},n),{index:t}))})),[2,l]}}))}))},handleRowHooks:function(e,r){return n(this,void 0,void 0,(function(){var i,s,c,a,l,u,d,h,f,m,p,v,w,g=this;return t(this,(function(k){switch(k.label){case 0:i=new Map,s=new Map(e.map((function(e){return[e.index,e]}))),c=function(e,n){for(var t,o=s.get(e),r=function(n,r){if(y(r))return"continue";var s=o.row[n],c=Array.isArray(s.manyToOne),a="manyToOne"in r&&Array.isArray(r.manyToOne);if(c&&!a)throw new Error("".concat(n," should have manyToOne defined as an array."));if(c&&a&&s.manyToOne.length!==r.manyToOne.length)throw new Error("".concat(n," should be array of length ").concat(s.manyToOne.length));var l=i.get(e)||{},u=null!==(t=l[n])&&void 0!==t?t:{},d=[];a?(u.manyToOne=[],r.manyToOne.forEach((function(e,n){if(!y(e)){var t={};u.manyToOne.push(t),d.push({fieldOutput:e,rowDataField:s.manyToOne[n],cellChange:t})}}))):d.push({fieldOutput:r,rowDataField:s,cellChange:u}),d.forEach((function(e){var n=e.fieldOutput,t=e.rowDataField,o=e.cellChange;void 0!==n.value&&(o.value=n.value,t.value=n.value),void 0!==n.info&&(o.info=n.info,t.info=n.info),void 0!==n.selectOptions&&(o.selectOptions=n.selectOptions,t.selectOptions=n.selectOptions)})),l[n]=u,i.set(e,l)},c=0,a=Object.entries(null!=n?n:{});c<a.length;c++){var l=a[c];r(l[0],l[1])}},a=0,l=o.bulkRowHooks,k.label=1;case 1:if(!(a<l.length))return[3,6];u=l[a],k.label=2;case 2:return k.trys.push([2,4,,5]),d=b("bulk row hook"),[4,u(e,r)];case 3:for(h=k.sent(),E(d),f=0,m=h;f<m.length;f++)p=m[f],c(p.index,p.row);return[3,5];case 4:return v=k.sent(),console.error("[Dromo-External-Error] There was an error running your bulk row hook.",v),[3,5];case 5:return a++,[3,1];case 6:return[4,Promise.all(e.map((function(e){return n(g,void 0,void 0,(function(){var n,i,s,a,l,u;return t(this,(function(t){switch(t.label){case 0:n=0,i=o.rowHooks,t.label=1;case 1:if(!(n<i.length))return[3,6];s=i[n],t.label=2;case 2:return t.trys.push([2,4,,5]),a=b("row hook"),[4,s.callback(e,r)];case 3:return l=t.sent(),E(a),c(e.index,l.row),[3,5];case 4:return u=t.sent(),console.error("[Dromo-External-Error] There was an error running your row hook.",u),[3,5];case 5:return n++,[3,1];case 6:return[2]}}))}))})))];case 7:return k.sent(),w=[],i.forEach((function(e,n){w.push({index:n,row:e})})),[2,w]}}))}))},handleStepHook:function(e,n){o.stepHooks.forEach((function(t){if(e===t.type)try{t.callback(o,n)}catch(e){console.error("[Dromo-External-Error] There was an error in your step callback.",e)}}))},handleRowDeleteHooks:function(e){var r=this;return Promise.all(e.map((function(e){return n(r,void 0,void 0,(function(){var r=this;return t(this,(function(i){switch(i.label){case 0:return[4,o.rowDeleteHooks.forEach((function(o){return n(r,void 0,void 0,(function(){var n,r;return t(this,(function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),n=b("row delete hook"),[4,o(e)];case 1:return t.sent(),E(n),[3,3];case 2:return r=t.sent(),console.error("[Dromo-External-Error] There was an error running your row delete hook.",r),[3,3];case 3:return[2]}}))}))}))];case 1:return i.sent(),[2]}}))}))})))},handleBeforeFinishCallback:function(e,r){return n(this,void 0,void 0,(function(){var n;return t(this,(function(t){switch(t.label){case 0:if(!o.beforeFinishCallback)return[3,4];t.label=1;case 1:return t.trys.push([1,3,,4]),[4,o.beforeFinishCallback(e,r,o)];case 2:return[2,t.sent()];case 3:return n=t.sent(),console.error("[Dromo-External-Error] There was an error in your beforeFinish callback.",n),[3,4];case 4:return[2]}}))}))},handleResults:function(e,r){return n(this,void 0,void 0,(function(){var n;return t(this,(function(t){switch(t.label){case 0:if(!o.resultsCallback)return[3,4];t.label=1;case 1:return t.trys.push([1,3,,4]),[4,o.resultsCallback(e,r)];case 2:return t.sent(),[3,4];case 3:return n=t.sent(),console.error("[Dromo-External-Error] There was an error in your onResult callback.",n),[3,4];case 4:return o.close(),[2]}}))}))},handleCloseModal:function(){o.close()},handleCancel:function(){if(o.cancelCallback)try{o.cancelCallback()}catch(e){console.error("[Dromo-External-Error] There was an error in your cancel callback.",e)}o.close()}}}):console.error("shim cannot connect to Dromo.")},this.mountIFrame=function(){if(!document.getElementById(c.iframeId)){var e=document.createElement("div");e.id=c.wrapperId,e.style.zIndex=Number.MAX_SAFE_INTEGER.toString(),e.style.visibility="hidden",e.style.width="0px",e.style.height="0px",e.style.position="fixed",e.style.top="0px",e.style.left="0px",e.style.right="0px",e.style.bottom="0px",e.appendChild(c.iframe),document.body.appendChild(e),c.wrapper=e}},this.showIFrame=function(){c.wrapper&&(c.wrapper.style.visibility="visible",c.wrapper.style.width="100%",c.wrapper.style.height="100%",document.body.style.overflow="hidden")},this.registerColumnHook=function(e,n){c.columnHooks.push({fieldName:e,callback:n}),c.connection&&c.connection.promise.then((function(e){e.setNumRegisteredColHooks(c.columnHooks.length)}))},this.totalNumRowHooks=function(){return c.rowHooks.length+c.bulkRowHooks.length},this.registerBulkRowHook=function(e){c.bulkRowHooks.push(e),c.connection&&c.connection.promise.then((function(e){e.setNumRegisteredRowHooks(c.totalNumRowHooks())}))},this.registerRowHook=function(e){c.rowHooks.push({callback:e}),c.connection&&c.connection.promise.then((function(e){e.setNumRegisteredRowHooks(c.totalNumRowHooks())}))},this.registerStepHook=function(e,n){c.stepHooks.push({type:e,callback:n})},this.registerRowDeleteHook=function(e){c.rowDeleteHooks.push(e),c.connection&&c.connection.promise.then((function(e){e.setNumRegisteredRowDeleteHooks(c.rowDeleteHooks.length)}))},this.beforeFinish=function(e){c.beforeFinishCallback=e},this.registerAllHooks=function(e){if(e.columnHooks)for(var n=0,t=e.columnHooks;n<t.length;n++){var o=t[n],r=o.fieldName,i=o.callback;c.registerColumnHook(r,i)}if(e.rowHooks)for(var s=0,a=e.rowHooks;s<a.length;s++){var l=a[s];c.registerRowHook(l)}if(e.bulkRowHooks)for(var u=0,d=e.bulkRowHooks;u<d.length;u++){var h=d[u];c.registerBulkRowHook(h)}if(e.rowDeleteHooks)for(var f=0,m=e.rowDeleteHooks;f<m.length;f++){var p=m[f];c.registerRowDeleteHook(p)}if(e.stepHooks)for(var v=0,w=e.stepHooks;v<w.length;v++){var g=w[v],y=g.type;i=g.callback;c.registerStepHook(y,i)}e.beforeFinishCallback&&c.beforeFinish(e.beforeFinishCallback)},this.onResults=function(e){c.resultsCallback=e},this.onCancel=function(e){c.cancelCallback=e},this.setUser=function(e){return n(c,void 0,void 0,(function(){return t(this,(function(n){switch(n.label){case 0:return this.user=e,this.connection?[4,this.connection.promise]:[3,3];case 1:return[4,n.sent().setUser(this.user)];case 2:n.sent(),n.label=3;case 3:return[2]}}))}))},this.addField=function(e,o){return n(c,void 0,void 0,(function(){return t(this,(function(n){switch(n.label){case 0:return this.connection?[4,this.connection.promise]:[3,3];case 1:return[4,n.sent().addField(k(e),o)];case 2:return n.sent(),[3,4];case 3:console.error("[Dromo-Error] Invalid connection to Dromo Uploader."),n.label=4;case 4:return[2]}}))}))},this.removeField=function(e){return n(c,void 0,void 0,(function(){return t(this,(function(n){switch(n.label){case 0:return this.connection?[4,this.connection.promise]:[3,3];case 1:return[4,n.sent().removeField(e)];case 2:return n.sent(),[3,4];case 3:console.error("[Dromo-Error] Invalid connection to Dromo Uploader."),n.label=4;case 4:return[2]}}))}))},this.updateInfoMessages=function(e){return n(c,void 0,void 0,(function(){return t(this,(function(n){switch(n.label){case 0:return this.connection?[4,this.connection.promise]:[3,3];case 1:return[4,n.sent().updateInfoMessages(e)];case 2:return n.sent(),[3,4];case 3:console.error("[Dromo-Error] Invalid connection to Dromo Uploader."),n.label=4;case 4:return[2]}}))}))},this.setHeaderRowOverride=function(e){return n(c,void 0,void 0,(function(){return t(this,(function(n){switch(n.label){case 0:return this.headerRowOverride=e,this.connection?[4,this.connection.promise]:[3,3];case 1:return[4,n.sent().setHeaderRowOverride(e)];case 2:n.sent(),n.label=3;case 3:return[2]}}))}))},this.open=function(){return n(c,void 0,void 0,(function(){return t(this,(function(e){switch(e.label){case 0:return this.wrapper||(this.initIFrame(),this.createConnection(),this.mountIFrame()),[4,this.initChild()];case 1:return e.sent(),this.showIFrame(),[2]}}))}))},this.addRows=function(e){return n(c,void 0,void 0,(function(){return t(this,(function(n){switch(n.label){case 0:return this.connection?[4,this.connection.promise]:[3,3];case 1:return[4,n.sent().addRows(e)];case 2:return n.sent(),[3,4];case 3:console.error("[Dromo-Error] Invalid connection to Dromo Uploader."),n.label=4;case 4:return[2]}}))}))},this.removeRows=function(e){return n(c,void 0,void 0,(function(){return t(this,(function(n){switch(n.label){case 0:return this.connection?[4,this.connection.promise]:[3,3];case 1:return[4,n.sent().removeRows(e)];case 2:return n.sent(),[3,4];case 3:console.error("[Dromo-Error] Invalid connection to Dromo Uploader."),n.label=4;case 4:return[2]}}))}))},this.close=function(){c.wrapper&&(c.wrapper.style.visibility="hidden",c.wrapper.style.width="0px",c.wrapper.style.height="0px",document.body.style.overflow="inherit")},this.setDevelopmentMode=function(e){return n(c,void 0,void 0,(function(){return t(this,(function(n){switch(n.label){case 0:return this.developmentMode=e,this.connection?[4,this.connection.promise]:[3,3];case 1:return[4,n.sent().setDevelopmentMode(this.developmentMode)];case 2:n.sent(),n.label=3;case 3:return[2]}}))}))},this.rehydrate=function(e,o){return n(c,void 0,void 0,(function(){return t(this,(function(n){switch(n.label){case 0:return this.wrapper||(this.initIFrame(),this.createConnection(),this.mountIFrame()),[4,this.initChild()];case 1:return n.sent(),[4,this.connection.promise];case 2:return[4,n.sent().rehydrate(e,o)];case 3:return n.sent(),this.showIFrame(),[2]}}))}))},this.iframeId=Math.random().toString(36).substring(7)+"-dromo-iframe-element",this.wrapperId=Math.random().toString(36).substring(7)+"-dromo-container",this.appHost=document.location.hostname,void 0!==i&&void 0!==s?(this.licenseKey=o,this.fields=r.map(k),this.settings=i,this.user=s,this.checkCloneable({licenseKey:this.licenseKey,fields:this.fields,settings:this.settings,user:this.user})):(this.licenseKey=o,this.schemaId=r,this.checkCloneable({licenseKey:this.licenseKey,schemaId:this.schemaId}))}var r;return o.prototype.checkCloneable=function(e){if("function"==typeof structuredClone){var n=Object.entries(e).filter((function(e){e[0];var n=e[1];try{return structuredClone(n),!1}catch(e){return!0}})).map((function(e){return e[0]}));if(n.length>0){var t=n.join(", ");throw new Error("[Dromo-External-Error] The Dromo importer received non-cloneable parameters: ".concat(t,". See https://dromo.dev/err/clone"))}}},r=o,o.rehydrateHeadless=function(e){var i=e.licenseKey,s=e.headlessImportId,c=e.fields,a=e.settings,l=e.hooks,u=e.rehydrateState;return n(void 0,void 0,void 0,(function(){var e;return t(r,(function(n){switch(n.label){case 0:return(e=new o(i,c,a,{id:"headless-review"})).registerAllHooks(l),[4,e.rehydrate(u,s)];case 1:return n.sent(),e.open(),[2,e]}}))}))},o}()}));
16
16
  //# sourceMappingURL=index.js.map