dromo-uploader-js 2.0.24 → 2.1.1

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.
@@ -1,8 +1,8 @@
1
- import { EStepHook, IBeforeFinishCallback, IBeforeFinishOutput, IBulkRowHook, IColumnHook, IColumnHookInput, IColumnHookOutput, IPublicConnectionMethods, IResultMetadata, IReviewStepData, IReviewStepPostHooksData, IRowDeleteHook, IRowHook, IRowHookInput, IRowHookOutputInternal, IStepHook, IUploadStepData } from "./interfaces";
1
+ import { EStepHook, IBeforeFinishCallback, IBeforeFinishOutput, IBulkRowHook, IColumnHook, IColumnHookInput, IColumnHookOutput, IPublicConnectionMethods, IResultMetadataWithValues, IReviewStepData, IReviewStepPostHooksData, IRowDeleteHook, IRowHook, IRowHookInput, IRowHookOutputInternal, IStepHook, IUploadStepData } from "./interfaces";
2
2
  export type HookErrorHandlerFn = (err: unknown, hookType: string) => void;
3
3
  export declare const consoleErrorHandler: HookErrorHandlerFn;
4
4
  export declare const executeColumnHooks: (hooks: IColumnHook[], data: IColumnHookInput[], errorHandler: HookErrorHandlerFn) => Promise<IColumnHookOutput[]>;
5
5
  export declare const executeRowHooks: (data: IRowHookInput[], mode: "init" | "update", rowHooks: IRowHook[], bulkRowHooks: IBulkRowHook[], errorHandler: HookErrorHandlerFn) => Promise<IRowHookOutputInternal[]>;
6
6
  export declare const executeRowDeleteHooks: (deletedRows: IRowHookInput[], rowDeleteHooks: IRowDeleteHook[], errorHandler: HookErrorHandlerFn) => Promise<void[]>;
7
7
  export declare const executeStepHooks: (step: EStepHook, data: IUploadStepData | IReviewStepData | IReviewStepPostHooksData, stepHooks: IStepHook[], instance: IPublicConnectionMethods, errorHandler: HookErrorHandlerFn) => Promise<void>;
8
- export declare const executeBeforeFinishCallback: (data: Record<string, unknown>[], metadata: IResultMetadata, beforeFinishCallback: IBeforeFinishCallback, instance: IPublicConnectionMethods, errorHandler: HookErrorHandlerFn) => Promise<IBeforeFinishOutput>;
8
+ export declare const executeBeforeFinishCallback: (data: Record<string, unknown>[], metadata: IResultMetadataWithValues, beforeFinishCallback: IBeforeFinishCallback, instance: IPublicConnectionMethods, errorHandler: HookErrorHandlerFn) => Promise<IBeforeFinishOutput>;
package/dist/index.d.ts CHANGED
@@ -8,7 +8,9 @@ export default class DromoUploader {
8
8
  constructor(licenseKey: string, fields: IDeveloperField[], settings: IDeveloperSettings, user: IUser);
9
9
  constructor(licenseKey: string, schemaId: string);
10
10
  initChild: () => Promise<void>;
11
- showIFrame: () => void;
11
+ addIFrameToWrapper: () => void;
12
+ showIframe: () => void;
13
+ showWrapper: () => void;
12
14
  /**
13
15
  * Function called by the developer to set a callback
14
16
  *
@@ -100,6 +102,7 @@ export default class DromoUploader {
100
102
  * Function called by developer called to open the iframe
101
103
  */
102
104
  open: () => Promise<void>;
105
+ initInline: (wrapperIdOrElement: string | HTMLElement) => Promise<void>;
103
106
  /**
104
107
  * Function called by the developer to add rows during the import
105
108
  */
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,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 v=()=>++m,p=(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 p=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=v(),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 v=h.returnValue;h.returnValueIsError&&(v=(e=>{const n=new Error;return Object.keys(e).forEach((t=>n[t]=e[t])),n})(v)),(h.resolution===i.Fulfilled?t:o)(v)};u.addEventListener(a.Message,m);const p={penpal:r.Call,id:s,methodName:e,args:n};d.postMessage(p,h)}))};return t.reduce(((e,n)=>(e[n]=p(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 v={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:v}=s;t(`${o}: Received ${a}() call`);const p=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:v,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:v,resolution:i.Rejected,returnValue:f(e),returnValueIsError:!0};l.postMessage(n,u)}throw e}};new Promise((e=>e(n[a].apply(n,m)))).then(p(i.Fulfilled),p(i.Rejected))};return s.addEventListener(a.Message,m),()=>{h=!0,s.removeEventListener(a.Message,m)}})(v,e,s),u(d),h&&h.forEach((e=>{delete m[e]})),h=o.data.methodNames;const w=p(m,v,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:v}=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 p="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,p),y=w(t,o,p,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,v),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(){v()}}},y=function(e,n){return console.error("[Dromo-External-Error] There was an error running your ".concat(n,"."),e)},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)},k=function(e){clearTimeout(e)},R=function(o,r,i){return n(void 0,void 0,void 0,(function(){var s,c,a;return t(this,(function(l){switch(l.label){case 0:return s=new Map,c=r.map((function(n){return e({},n)})),[4,o.reduce((function(e,o){return n(void 0,void 0,void 0,(function(){return t(this,(function(r){switch(r.label){case 0:return[4,e.then((function(){return n(void 0,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(c)];case 1:return n=t.sent(),k(e),n.forEach((function(e){if(void 0!==e.value||void 0!==e.info){var n={};void 0!==e.value&&(n.value=e.value,c[e.index].value=e.value),void 0!==e.info&&(n.info=e.info),s.set(e.index,n)}})),[3,3];case 2:return r=t.sent(),i(r,"column hooks"),[3,3];case 3:return[2]}}))}))}))];case 1:return r.sent(),[2]}}))}))}),Promise.resolve())];case 1:return l.sent(),a=[],s.forEach((function(n,t){return a.push(e(e({},n),{index:t}))})),[2,a]}}))}))},H=function(e){return void 0===e.value&&void 0===e.info&&void 0===e.selectOptions&&void 0===e.manyToOne},E=function(e,o,r,i,s){return n(void 0,void 0,void 0,(function(){var c,a,l,u,d,h,f,m,v,p,w,g,y;return t(this,(function(R){switch(R.label){case 0:c=new Map,a=new Map(e.map((function(e){return[e.index,e]}))),l=function(e,n){for(var t,o=a.get(e),r=function(n,r){if(H(r))return"continue";var i=o.row[n],s=Array.isArray(i.manyToOne),a="manyToOne"in r&&Array.isArray(r.manyToOne);if(s&&!a)throw new Error("".concat(n," should have manyToOne defined as an array."));if(s&&a&&i.manyToOne.length!==r.manyToOne.length)throw new Error("".concat(n," should be array of length ").concat(i.manyToOne.length));var l=c.get(e)||{},u=null!==(t=l[n])&&void 0!==t?t:{},d=[];a?(u.manyToOne=[],r.manyToOne.forEach((function(e,n){if(!H(e)){var t={};u.manyToOne.push(t),d.push({fieldOutput:e,rowDataField:i.manyToOne[n],cellChange:t})}}))):d.push({fieldOutput:r,rowDataField:i,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,c.set(e,l)},i=0,s=Object.entries(null!=n?n:{});i<s.length;i++){var l=s[i];r(l[0],l[1])}},u=0,d=i,R.label=1;case 1:if(!(u<d.length))return[3,6];h=d[u],R.label=2;case 2:return R.trys.push([2,4,,5]),f=b("bulk row hook"),[4,h(e,o)];case 3:for(m=R.sent(),k(f),v=0,p=m;v<p.length;v++)w=p[v],l(w.index,w.row);return[3,5];case 4:return g=R.sent(),s(g,"bulk row hooks"),[3,5];case 5:return u++,[3,1];case 6:return[4,Promise.all(e.map((function(e){return n(void 0,void 0,void 0,(function(){var n,i,c,a,u,d;return t(this,(function(t){switch(t.label){case 0:n=0,i=r,t.label=1;case 1:if(!(n<i.length))return[3,6];c=i[n],t.label=2;case 2:return t.trys.push([2,4,,5]),a=b("row hook"),[4,c(e,o)];case 3:return u=t.sent(),k(a),l(e.index,u.row),[3,5];case 4:return d=t.sent(),s(d,"row hooks"),[3,5];case 5:return n++,[3,1];case 6:return[2]}}))}))})))];case 7:return R.sent(),y=[],c.forEach((function(e,n){y.push({index:n,row:e})})),[2,y]}}))}))},I=function(e,o,r){return n(void 0,void 0,void 0,(function(){return t(this,(function(i){return[2,Promise.all(e.map((function(e){return n(void 0,void 0,void 0,(function(){return t(this,(function(i){return o.forEach((function(o){return n(void 0,void 0,void 0,(function(){var n,i;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(),k(n),[3,3];case 2:return i=t.sent(),r(i,"row delete hooks"),[3,3];case 3:return[2]}}))}))})),[2]}))}))})))]}))}))},D=function(e,o,r,i,s){return n(void 0,void 0,void 0,(function(){return t(this,(function(c){switch(c.label){case 0:return[4,Promise.all(r.map((function(r){return n(void 0,void 0,void 0,(function(){var n;return t(this,(function(t){switch(t.label){case 0:if(e!==r.type)return[2,Promise.resolve()];t.label=1;case 1:return t.trys.push([1,3,,4]),[4,r.callback(i,o)];case 2:return[2,t.sent()];case 3:return n=t.sent(),s(n,"step hook ".concat(e)),[2,Promise.resolve()];case 4:return[2]}}))}))})))];case 1:return c.sent(),[2]}}))}))},C=function(e,o,r,i,s){return n(void 0,void 0,void 0,(function(){var n;return t(this,(function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,r(e,o,i)];case 1:return[2,t.sent()];case 2:return n=t.sent(),s(n,"before finish callback"),[3,3];case 3:return[2]}}))}))},x=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};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})),[4,n.setNumRegisteredRowHooks(this.totalNumRowHooks())];case 2:return t.sent(),[4,n.setNumRegisteredColHooks(this.columnHooks.length)];case 3:return t.sent(),[4,n.setNumRegisteredRowDeleteHooks(this.rowDeleteHooks.length)];case 4:return t.sent(),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,6];case 5:return t.sent(),[3,9];case 6:return this.schemaId?[4,n.initFromSavedSchema(this.licenseKey,this.schemaId,this.appHost,{user:this.user,developmentMode:this.developmentMode,headerRowOverride:this.headerRowOverride})]:[3,8];case 7:return t.sent(),[3,9];case 8:console.error("Invalid Dromo configuration"),t.label=9;case 9:return[2]}}))}))},this.initIFrame=function(){var e,n,t,o,r;if(window.DROMO_WIDGET_OVERRIDE)r=window.DROMO_WIDGET_OVERRIDE;else if(null===(e=c.settings)||void 0===e?void 0:e.alternateDomain){var i=new URL(c.settings.alternateDomain);r=i.protocol+"//widget."+i.host}else r="v1"===(null===(n=c.settings)||void 0===n?void 0:n.version)?"https://widget-v1.dromo.io/":l;if(!document.getElementById(c.iframeId)){var s=document.createElement("iframe"),a=null!==(o=null===(t=c.settings)||void 0===t?void 0:t.importIdentifier)&&void 0!==o?o:c.schemaId;s.title=a?"Dromo Importer: ".concat(a):"Dromo Importer",s.src=r,s.id=c.iframeId,s.style.height="100%",s.style.width="100%",s.style.border="0",s.crossorigin="anonymous",c.iframe=s}},this.createConnection=function(){var e=c,o=c.iframe;o?c.connection=g({iframe:o,methods:{handleColumnHooks:function(o,r){return n(this,void 0,void 0,(function(){var n;return t(this,(function(t){switch(t.label){case 0:return n=e.columnHooks.filter((function(e){return e.fieldName===o})),[4,R(n,r,y)];case 1:return[2,t.sent()]}}))}))},handleRowHooks:function(o,r){return n(this,void 0,void 0,(function(){return t(this,(function(n){switch(n.label){case 0:return[4,E(o,r,e.rowHooks.map((function(e){return e.callback})),e.bulkRowHooks,y)];case 1:return[2,n.sent()]}}))}))},handleStepHook:function(o,r){return n(this,void 0,void 0,(function(){return t(this,(function(n){switch(n.label){case 0:return[4,D(o,r,e.stepHooks,e,y)];case 1:return[2,n.sent()]}}))}))},handleRowDeleteHooks:function(o){return n(this,void 0,void 0,(function(){return t(this,(function(n){switch(n.label){case 0:return[4,I(o,e.rowDeleteHooks,y)];case 1:return n.sent(),[2]}}))}))},handleBeforeFinishCallback:function(o,r){return n(this,void 0,void 0,(function(){return t(this,(function(n){switch(n.label){case 0:return e.beforeFinishCallback?[4,C(o,r,e.beforeFinishCallback,e,y)]:[3,2];case 1:return[2,n.sent()];case 2:return[2]}}))}))},handleResults:function(o,r){return n(this,void 0,void 0,(function(){var n;return t(this,(function(t){switch(t.label){case 0:if(!e.resultsCallback)return[3,4];t.label=1;case 1:return t.trys.push([1,3,,4]),[4,e.resultsCallback(o,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 e.close(),[2]}}))}))},handleCloseModal:function(){e.close()},handleCancel:function(){if(e.cancelCallback)try{e.cancelCallback()}catch(e){console.error("[Dromo-External-Error] There was an error in your cancel callback.",e)}e.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 v=m[f];c.registerRowDeleteHook(v)}if(e.stepHooks)for(var p=0,w=e.stepHooks;p<w.length;p++){var g=w[p],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(x(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(x),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}()}));
15
+ ***************************************************************************** */var e=function(){return(e=Object.assign||function(e){for(var n,t=1,r=arguments.length;t<r;t++)for(var o in n=arguments[t])Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o]);return e}).apply(this,arguments)};function n(e,n,t,r){return new(t||(t=Promise))((function(o,i){function s(e){try{a(r.next(e))}catch(e){i(e)}}function c(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var n;e.done?o(e.value):(n=e.value,n instanceof t?n:new t((function(e){e(n)}))).then(s,c)}a((r=r.apply(e,n||[])).next())}))}function t(e,n){var t,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[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,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=n.call(e,s)}catch(e){i=[6,e],r=0}finally{t=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,c])}}}var r,o,i,s,c,a,l={IFRAME_URL:"https://widget.dromo.io/"}.IFRAME_URL;!function(e){e.INIT_IFRAME="INIT_IFRAME"}(r||(r={})),function(e){e.Call="call",e.Reply="reply",e.Syn="syn",e.SynAck="synAck",e.Ack="ack"}(o||(o={})),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 p=0;var m=()=>++p,v=(e,n,t,r,c)=>{const{localName:l,local:u,remote:d,originForSending:h,originForReceiving:f}=n;let p=!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&&r(),p){const n=new Error(`Unable to send ${e}() call due to destroyed connection`);throw n.code=s.ConnectionDestroyed,n}return new Promise(((t,r)=>{const s=m(),p=n=>{if(n.source!==d||n.data.penpal!==o.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,p);let m=h.returnValue;h.returnValueIsError&&(m=(e=>{const n=new Error;return Object.keys(e).forEach((t=>n[t]=e[t])),n})(m)),(h.resolution===i.Fulfilled?t:r)(m)};u.addEventListener(a.Message,p);const v={penpal:o.Call,id:s,methodName:e,args:n};d.postMessage(v,h)}))};return t.reduce(((e,n)=>(e[n]=v(n),e)),e),()=>{p=!0}},w=(e,n,t,r,s)=>{const{destroy:l,onDestroy:u}=r;let d,h;const p={};return r=>{if(r.origin!==n)return void s(`Parent: Handshake - Received ACK message from origin ${r.origin} which did not match expected origin ${n}`);s("Parent: Handshake - Received ACK");const m={localName:"Parent",local:window,remote:r.source,originForSending:t,originForReceiving:n};d&&d(),d=((e,n,t)=>{const{localName:r,local:s,remote:l,originForSending:u,originForReceiving:d}=e;let h=!1;const p=e=>{if(e.source!==l||e.data.penpal!==o.Call)return;if(e.origin!==d)return void t(`${r} received message from origin ${e.origin} which did not match expected origin ${d}`);const s=e.data,{methodName:a,args:p,id:m}=s;t(`${r}: Received ${a}() call`);const v=e=>n=>{if(t(`${r}: Sending ${a}() reply`),h)return void t(`${r}: Unable to send ${a}() reply due to destroyed connection`);const s={penpal:o.Reply,id:m,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:o.Reply,id:m,resolution:i.Rejected,returnValue:f(e),returnValueIsError:!0};l.postMessage(n,u)}throw e}};new Promise((e=>e(n[a].apply(n,p)))).then(v(i.Fulfilled),v(i.Rejected))};return s.addEventListener(a.Message,p),()=>{h=!0,s.removeEventListener(a.Message,p)}})(m,e,s),u(d),h&&h.forEach((e=>{delete p[e]})),h=r.data.methodNames;const w=v(p,m,h,l,s);return u(w),p}};var g=e=>{let{iframe:n,methods:t={},childOrigin:r,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:p,destroy:m}=f;r||((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),r=(e=>{if(e&&h.find((n=>e.startsWith(n))))return"null";const n=document.location,t=d.exec(e);let r,o,i;return t?(r=t[1]?t[1]:n.protocol,o=t[2],i=t[4]):(r=n.protocol,o=n.hostname,i=n.port),`${r}//${o}${i&&i!==u[r]?`:${i}`:""}`})(n.src));const v="null"===r?"*":r,g=((e,n,t,r)=>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:o.SynAck,methodNames:Object.keys(n)};i.source.postMessage(s,r)})(l,t,r,v),y=w(t,r,v,f,l);return{promise:new Promise(((e,t)=>{const r=((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,m),c=t=>{if(t.source===n.contentWindow&&t.data)if(t.data.penpal!==o.Syn)if(t.data.penpal!==o.Ack);else{const n=y(t);n&&(r(),e(n))}else g(t)};window.addEventListener(a.Message,c),l("Parent: Awaiting handshake"),((e,n)=>{const{destroy:t,onDestroy:r}=n,o=setInterval((()=>{e.isConnected||(clearInterval(o),t())}),6e4);r((()=>{clearInterval(o)}))})(n,f),p((e=>{window.removeEventListener(a.Message,c),e||((e=new Error("Connection destroyed")).code=s.ConnectionDestroyed),t(e)}))})),destroy(){m()}}},y=function(e,n){return console.error("[Dromo-External-Error] There was an error running your ".concat(n,"."),e)},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)},k=function(e){clearTimeout(e)},I=function(r,o,i){return n(void 0,void 0,void 0,(function(){var s,c,a;return t(this,(function(l){switch(l.label){case 0:return s=new Map,c=o.map((function(n){return e({},n)})),[4,r.reduce((function(e,r){return n(void 0,void 0,void 0,(function(){return t(this,(function(o){switch(o.label){case 0:return[4,e.then((function(){return n(void 0,void 0,void 0,(function(){var e,n,o;return t(this,(function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),e=b("column hook"),[4,r.callback(c)];case 1:return n=t.sent(),k(e),n.forEach((function(e){if(void 0!==e.value||void 0!==e.info){var n={};void 0!==e.value&&(n.value=e.value,c[e.index].value=e.value),void 0!==e.info&&(n.info=e.info),s.set(e.index,n)}})),[3,3];case 2:return o=t.sent(),i(o,"column hooks"),[3,3];case 3:return[2]}}))}))}))];case 1:return o.sent(),[2]}}))}))}),Promise.resolve())];case 1:return l.sent(),a=[],s.forEach((function(n,t){return a.push(e(e({},n),{index:t}))})),[2,a]}}))}))},R=function(e){return void 0===e.value&&void 0===e.info&&void 0===e.selectOptions&&void 0===e.manyToOne},E=function(e,r,o,i,s){return n(void 0,void 0,void 0,(function(){var c,a,l,u,d,h,f,p,m,v,w,g,y;return t(this,(function(I){switch(I.label){case 0:c=new Map,a=new Map(e.map((function(e){return[e.index,e]}))),l=function(e,n){for(var t,r=a.get(e),o=function(n,o){if(R(o))return"continue";var i=r.row[n],s=Array.isArray(i.manyToOne),a="manyToOne"in o&&Array.isArray(o.manyToOne);if(s&&!a)throw new Error("".concat(n," should have manyToOne defined as an array."));if(s&&a&&i.manyToOne.length!==o.manyToOne.length)throw new Error("".concat(n," should be array of length ").concat(i.manyToOne.length));var l=c.get(e)||{},u=null!==(t=l[n])&&void 0!==t?t:{},d=[];a?(u.manyToOne=[],o.manyToOne.forEach((function(e,n){if(!R(e)){var t={};u.manyToOne.push(t),d.push({fieldOutput:e,rowDataField:i.manyToOne[n],cellChange:t})}}))):d.push({fieldOutput:o,rowDataField:i,cellChange:u}),d.forEach((function(e){var n=e.fieldOutput,t=e.rowDataField,r=e.cellChange;void 0!==n.value&&(r.value=n.value,t.value=n.value),void 0!==n.info&&(r.info=n.info,t.info=n.info),void 0!==n.selectOptions&&(r.selectOptions=n.selectOptions,t.selectOptions=n.selectOptions)})),l[n]=u,c.set(e,l)},i=0,s=Object.entries(null!=n?n:{});i<s.length;i++){var l=s[i];o(l[0],l[1])}},u=0,d=i,I.label=1;case 1:if(!(u<d.length))return[3,6];h=d[u],I.label=2;case 2:return I.trys.push([2,4,,5]),f=b("bulk row hook"),[4,h(e,r)];case 3:for(p=I.sent(),k(f),m=0,v=p;m<v.length;m++)w=v[m],l(w.index,w.row);return[3,5];case 4:return g=I.sent(),s(g,"bulk row hooks"),[3,5];case 5:return u++,[3,1];case 6:return[4,Promise.all(e.map((function(e){return n(void 0,void 0,void 0,(function(){var n,i,c,a,u,d;return t(this,(function(t){switch(t.label){case 0:n=0,i=o,t.label=1;case 1:if(!(n<i.length))return[3,6];c=i[n],t.label=2;case 2:return t.trys.push([2,4,,5]),a=b("row hook"),[4,c(e,r)];case 3:return u=t.sent(),k(a),l(e.index,u.row),[3,5];case 4:return d=t.sent(),s(d,"row hooks"),[3,5];case 5:return n++,[3,1];case 6:return[2]}}))}))})))];case 7:return I.sent(),y=[],c.forEach((function(e,n){y.push({index:n,row:e})})),[2,y]}}))}))},H=function(e,r,o){return n(void 0,void 0,void 0,(function(){return t(this,(function(i){return[2,Promise.all(e.map((function(e){return n(void 0,void 0,void 0,(function(){return t(this,(function(i){return r.forEach((function(r){return n(void 0,void 0,void 0,(function(){var n,i;return t(this,(function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),n=b("row delete hook"),[4,r(e)];case 1:return t.sent(),k(n),[3,3];case 2:return i=t.sent(),o(i,"row delete hooks"),[3,3];case 3:return[2]}}))}))})),[2]}))}))})))]}))}))},D=function(e,r,o,i,s){return n(void 0,void 0,void 0,(function(){return t(this,(function(c){switch(c.label){case 0:return[4,Promise.all(o.map((function(o){return n(void 0,void 0,void 0,(function(){var n;return t(this,(function(t){switch(t.label){case 0:if(e!==o.type)return[2,Promise.resolve()];t.label=1;case 1:return t.trys.push([1,3,,4]),[4,o.callback(i,r)];case 2:return[2,t.sent()];case 3:return n=t.sent(),s(n,"step hook ".concat(e)),[2,Promise.resolve()];case 4:return[2]}}))}))})))];case 1:return c.sent(),[2]}}))}))},C=function(e,r,o,i,s){return n(void 0,void 0,void 0,(function(){var n;return t(this,(function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,o(e,r,i)];case 1:return[2,t.sent()];case 2:return n=t.sent(),s(n,"before finish callback"),[3,3];case 3:return[2]}}))}))},x="dromo-container",O=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};return function(){function r(r,o,i,s){var c=this;this.embedInline=!1,this.columnHooks=[],this.bulkRowHooks=[],this.rowHooks=[],this.stepHooks=[],this.rowDeleteHooks=[],this.initChild=function(){return n(c,void 0,void 0,(function(){var n,r,o,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(),r=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})),[4,n.setNumRegisteredRowHooks(this.totalNumRowHooks())];case 2:return t.sent(),[4,n.setNumRegisteredColHooks(this.columnHooks.length)];case 3:return t.sent(),[4,n.setNumRegisteredRowDeleteHooks(this.rowDeleteHooks.length)];case 4:return t.sent(),[4,n.setEmbedInline(this.embedInline)];case 5:return t.sent(),this.fields&&this.settings&&this.user?(o=e({},this.settings),r||(o.version=null!==(i=o.version)&&void 0!==i?i:"v2"),o.browserExcelParsing=null===(s=o.browserExcelParsing)||void 0===s||s,[4,n.init(this.licenseKey,this.fields,o,this.user,this.appHost)]):[3,7];case 6:return t.sent(),[3,10];case 7:return this.schemaId?[4,n.initFromSavedSchema(this.licenseKey,this.schemaId,this.appHost,{user:this.user,developmentMode:this.developmentMode,headerRowOverride:this.headerRowOverride})]:[3,9];case 8:return t.sent(),[3,10];case 9:console.error("Invalid Dromo configuration"),t.label=10;case 10:return[2]}}))}))},this.initIFrame=function(){var e,n,t,r,o;if(window.DROMO_WIDGET_OVERRIDE)o=window.DROMO_WIDGET_OVERRIDE;else if(null===(e=c.settings)||void 0===e?void 0:e.alternateDomain){var i=new URL(c.settings.alternateDomain);o=i.protocol+"//widget."+i.host}else o="v1"===(null===(n=c.settings)||void 0===n?void 0:n.version)?"https://widget-v1.dromo.io/":l;if(!document.getElementById(c.iframeId)){var s=document.createElement("iframe"),a=null!==(r=null===(t=c.settings)||void 0===t?void 0:t.importIdentifier)&&void 0!==r?r:c.schemaId;s.title=a?"Dromo Importer: ".concat(a):"Dromo Importer",s.src=o,s.id=c.iframeId,s.style.height="100%",s.style.width="100%",s.style.border="0",s.crossorigin="anonymous",c.iframe=s}},this.createConnection=function(){var e=c,r=c.iframe;r?c.connection=g({iframe:r,methods:{handleColumnHooks:function(r,o){return n(this,void 0,void 0,(function(){var n;return t(this,(function(t){switch(t.label){case 0:return n=e.columnHooks.filter((function(e){return e.fieldName===r})),[4,I(n,o,y)];case 1:return[2,t.sent()]}}))}))},handleRowHooks:function(r,o){return n(this,void 0,void 0,(function(){return t(this,(function(n){switch(n.label){case 0:return[4,E(r,o,e.rowHooks.map((function(e){return e.callback})),e.bulkRowHooks,y)];case 1:return[2,n.sent()]}}))}))},handleStepHook:function(r,o){return n(this,void 0,void 0,(function(){return t(this,(function(n){switch(n.label){case 0:return[4,D(r,o,e.stepHooks,e,y)];case 1:return[2,n.sent()]}}))}))},handleRowDeleteHooks:function(r){return n(this,void 0,void 0,(function(){return t(this,(function(n){switch(n.label){case 0:return[4,H(r,e.rowDeleteHooks,y)];case 1:return n.sent(),[2]}}))}))},handleBeforeFinishCallback:function(r,o){return n(this,void 0,void 0,(function(){return t(this,(function(n){switch(n.label){case 0:return e.beforeFinishCallback?[4,C(r,o,e.beforeFinishCallback,e,y)]:[3,2];case 1:return[2,n.sent()];case 2:return[2]}}))}))},handleResults:function(r,o){return n(this,void 0,void 0,(function(){var n;return t(this,(function(t){switch(t.label){case 0:if(!e.resultsCallback)return[3,4];t.label=1;case 1:return t.trys.push([1,3,,4]),[4,e.resultsCallback(r,o)];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 e.close(),[2]}}))}))},handleCloseModal:function(){e.close()},handleCancel:function(){if(e.cancelCallback)try{e.cancelCallback()}catch(e){console.error("[Dromo-External-Error] There was an error in your cancel callback.",e)}e.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.addIFrameToWrapper=function(){c.wrapper&&c.iframe&&(c.iframe.style.visibility="hidden",c.wrapper.appendChild(c.iframe))},this.showIframe=function(){c.iframe&&(c.iframe.style.visibility="visible")},this.showWrapper=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 r=t[n],o=r.fieldName,i=r.callback;c.registerColumnHook(o,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,p=e.rowDeleteHooks;f<p.length;f++){var m=p[f];c.registerRowDeleteHook(m)}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,r){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(O(e),r)];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.showWrapper(),[2]}}))}))},this.initInline=function(e){return n(c,void 0,void 0,(function(){var n,r;return t(this,(function(t){switch(t.label){case 0:this.embedInline=!0,t.label=1;case 1:if(t.trys.push([1,3,,4]),e instanceof HTMLElement&&(this.wrapper=e,this.wrapperId=e.id,""!==this.wrapperId&&void 0!==this.wrapperId||(this.wrapperId=Math.random().toString(36).substring(7)+"-"+x)),"string"==typeof e){if(null===(n=document.getElementById(e)))throw new Error("WRAPPER_NOT_FOUND");this.wrapper=n,this.wrapperId=e}return this.iframe||(this.initIFrame(),this.createConnection(),this.addIFrameToWrapper()),[4,this.initChild()];case 2:return t.sent(),this.showIframe(),[3,4];case 3:throw"WRAPPER_NOT_FOUND"===(r=t.sent()).message&&console.error("[Dromo-Error] Could not find wrapper using provided ID."),r;case 4:return[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,r){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,r)];case 3:return n.sent(),this.showWrapper(),[2]}}))}))},this.iframeId=Math.random().toString(36).substring(7)+"-dromo-iframe-element",this.wrapperId=Math.random().toString(36).substring(7)+"-"+x,this.appHost=document.location.hostname,void 0!==i&&void 0!==s?(this.licenseKey=r,this.fields=o.map(O),this.settings=i,this.user=s,this.checkCloneable({licenseKey:this.licenseKey,fields:this.fields,settings:this.settings,user:this.user})):(this.licenseKey=r,this.schemaId=o,this.checkCloneable({licenseKey:this.licenseKey,schemaId:this.schemaId}))}var o;return r.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"))}}},o=r,r.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(o,(function(n){switch(n.label){case 0:return(e=new r(i,c,a,{id:"headless-review"})).registerAllHooks(l),[4,e.rehydrate(u,s)];case 1:return n.sent(),e.open(),[2,e]}}))}))},r}()}));
16
16
  //# sourceMappingURL=index.js.map