@sumit_yewale/angular 1.1.20 → 1.1.21-fix.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.
@@ -173,6 +173,8 @@
173
173
  this.disabled = true;
174
174
  // True while a different importer on the page is open: the button stays disabled.
175
175
  this.blockedByOther = false;
176
+ this.messageGate = adapterCore.createMessageGate();
177
+ this.importTracker = adapterCore.createImportTracker();
176
178
  this.registryEntry = { getHolder: (/**
177
179
  * @return {?}
178
180
  */
@@ -228,6 +230,12 @@
228
230
  if (!_this.iframe || event.source !== _this.iframe.contentWindow) {
229
231
  return;
230
232
  }
233
+ // A newer importer sends the typed message as well; act on that one only.
234
+ if (!_this.messageGate.allowLegacy()) {
235
+ return;
236
+ }
237
+ /** @type {?} */
238
+ var ended_1 = _this.importTracker.observe(legacy);
231
239
  if (legacy.type === "mainModalHidden") {
232
240
  _this.handleModalClosed();
233
241
  }
@@ -247,6 +255,7 @@
247
255
  if (_this.imported)
248
256
  _this.imported(false);
249
257
  }
258
+ _this.finishImport(ended_1);
250
259
  return;
251
260
  }
252
261
  // Set-file handshake messages. The shared core does not classify these, so they are
@@ -291,6 +300,9 @@
291
300
  if (!message) {
292
301
  return;
293
302
  }
303
+ _this.messageGate.markTyped();
304
+ /** @type {?} */
305
+ var ended = _this.importTracker.observe(message);
294
306
  if (message.type === "data-on-submit") {
295
307
  if (_this.onSubmit)
296
308
  _this.onSubmit(message.metadata);
@@ -300,9 +312,6 @@
300
312
  _this.submitted(message.metadata);
301
313
  }
302
314
  else if (message.type === "data-push-status") {
303
- if (!message.success) {
304
- delete message.metadata["unique_token"];
305
- }
306
315
  if (_this.onImport)
307
316
  _this.onImport(message.success, message.metadata);
308
317
  if (_this.isImported)
@@ -329,6 +338,7 @@
329
338
  if (_this.imported)
330
339
  _this.imported(false);
331
340
  }
341
+ _this.finishImport(ended);
332
342
  });
333
343
  }
334
344
  /**
@@ -410,27 +420,80 @@
410
420
  CSVBoxButtonComponent.prototype.handleModalClosed = /**
411
421
  * @return {?}
412
422
  */
423
+ function () {
424
+ if (this.importTracker.isInFlight()) {
425
+ // Closed after submitting and before the result arrived: keep the iframe and its listener
426
+ // so the late result still reaches onImport. It is removed once that result has been
427
+ // delivered (see finishImport), so the next open is a fresh load.
428
+ if (this.holder) {
429
+ this.holder.style.display = 'none';
430
+ this.holder.style.pointerEvents = 'auto';
431
+ }
432
+ this.isModalShown = false;
433
+ this.openModalOnIframeLoad = false;
434
+ this.clearFileAckTimer();
435
+ unregisterOpenImporter(this.registryEntry);
436
+ }
437
+ else {
438
+ this.destroyImporter();
439
+ }
440
+ if (this.onClose)
441
+ this.onClose();
442
+ if (this.isClosed)
443
+ this.isClosed();
444
+ if (this.closed)
445
+ this.closed();
446
+ };
447
+ // Called after the result of an import has been delivered. If the modal was closed in the
448
+ // meantime the iframe was only hidden, so remove it now.
449
+ // Called after the result of an import has been delivered. If the modal was closed in the
450
+ // meantime the iframe was only hidden, so remove it now.
451
+ /**
452
+ * @private
453
+ * @param {?} ended
454
+ * @return {?}
455
+ */
456
+ CSVBoxButtonComponent.prototype.finishImport =
457
+ // Called after the result of an import has been delivered. If the modal was closed in the
458
+ // meantime the iframe was only hidden, so remove it now.
459
+ /**
460
+ * @private
461
+ * @param {?} ended
462
+ * @return {?}
463
+ */
464
+ function (ended) {
465
+ if (ended && !this.isModalShown && this.iframe) {
466
+ this.destroyImporter();
467
+ }
468
+ };
469
+ // Puts the importer away: the next open builds a new iframe with a new token.
470
+ // Puts the importer away: the next open builds a new iframe with a new token.
471
+ /**
472
+ * @private
473
+ * @return {?}
474
+ */
475
+ CSVBoxButtonComponent.prototype.destroyImporter =
476
+ // Puts the importer away: the next open builds a new iframe with a new token.
477
+ /**
478
+ * @private
479
+ * @return {?}
480
+ */
413
481
  function () {
414
482
  if (this.holder) {
415
483
  this.holder.style.display = 'none';
416
484
  this.holder.style.pointerEvents = 'auto';
485
+ this.holder.remove();
417
486
  }
487
+ this.holder = null;
488
+ this.iframe = null;
418
489
  this.isModalShown = false;
419
490
  this.isIframeLoaded = false;
420
491
  this.openModalOnIframeLoad = false;
421
- if (this.holder)
422
- this.holder.remove();
423
- this.holder = null;
424
- this.iframe = null;
492
+ this.messageGate.reset();
493
+ this.importTracker.reset();
425
494
  // A new iframe is built on the next open, so the origin is learned again.
426
495
  this.clearProbeTimer();
427
496
  unregisterOpenImporter(this.registryEntry);
428
- if (this.onClose)
429
- this.onClose();
430
- if (this.isClosed)
431
- this.isClosed();
432
- if (this.closed)
433
- this.closed();
434
497
  };
435
498
  /**
436
499
  * @return {?}
@@ -442,6 +505,8 @@
442
505
  if (this.loadStarted)
443
506
  this.loadStarted();
444
507
  this.uuid = adapterCore.generateUuid();
508
+ this.messageGate.reset();
509
+ this.importTracker.reset();
445
510
  insertCSS();
446
511
  /** @type {?} */
447
512
  var iframe = document.createElement("iframe");
@@ -455,17 +520,19 @@
455
520
  * @return {?}
456
521
  */
457
522
  function () {
523
+ self.disabled = false;
524
+ self.isIframeLoaded = true;
525
+ // The handshake goes first: a consumer that calls openModalWithFile() from the ready
526
+ // callback needs the importer to already have its customer, columns, options and token.
527
+ if (self.iframe && self.iframe.contentWindow) {
528
+ self.iframe.contentWindow.postMessage(adapterCore.buildInitPayload(self.user, self.dynamicColumns, self.options, (/** @type {?} */ (self.uuid))), "*");
529
+ }
458
530
  if (self.onReady)
459
531
  self.onReady();
460
532
  if (self.isReady)
461
533
  self.isReady();
462
534
  if (self.importerReady)
463
535
  self.importerReady();
464
- self.disabled = false;
465
- self.isIframeLoaded = true;
466
- if (self.iframe && self.iframe.contentWindow) {
467
- self.iframe.contentWindow.postMessage(adapterCore.buildInitPayload(self.user, self.dynamicColumns, self.options, (/** @type {?} */ (self.uuid))), "*");
468
- }
469
536
  if (self.openModalOnIframeLoad) {
470
537
  self.openModal();
471
538
  }
@@ -681,9 +748,10 @@
681
748
  * @return {?}
682
749
  */
683
750
  function () {
684
- this.clearProbeTimer();
685
751
  window.removeEventListener("message", this.messageListener);
686
- unregisterOpenImporter(this.registryEntry);
752
+ // Takes the holder out of document.body: left there, it would keep covering the page with
753
+ // an invisible full-screen layer that nothing is left to hide.
754
+ this.destroyImporter();
687
755
  if (this.unsubscribeOpenImporters) {
688
756
  this.unsubscribeOpenImporters();
689
757
  this.unsubscribeOpenImporters = null;
@@ -795,6 +863,16 @@
795
863
  CSVBoxButtonComponent.prototype.disabled;
796
864
  /** @type {?} */
797
865
  CSVBoxButtonComponent.prototype.blockedByOther;
866
+ /**
867
+ * @type {?}
868
+ * @private
869
+ */
870
+ CSVBoxButtonComponent.prototype.messageGate;
871
+ /**
872
+ * @type {?}
873
+ * @private
874
+ */
875
+ CSVBoxButtonComponent.prototype.importTracker;
798
876
  /**
799
877
  * @type {?}
800
878
  * @private
@@ -1 +1 @@
1
- {"version":3,"file":"sumit_yewale-angular.umd.js","sources":["ng://@sumit_yewale/angular/utlis/insertCSS.ts","ng://@sumit_yewale/angular/lib/csvbox-button.component.ts","ng://@sumit_yewale/angular/lib/csvbox-angular.module.ts","ng://@sumit_yewale/angular/lib/interfaces/interface.ts"],"sourcesContent":["let styleElement: HTMLStyleElement\n\nconst GLOBAL_CSS = `\n.csvbox-holder {\n z-index: 2147483647;\n position: fixed;\n top: 0;\n bottom: 0;\n left: 0;\n right: 0;\n display: none;\n}\n.csvbox-holder iframe {\n height: 100%;\n width: 100%;\n position: absolute;\n top: 0px;\n left: 0px;\n}\n`\n\nexport const insertCSS = (): void => {\n if (styleElement) {\n return\n }\n\n styleElement = document.createElement('style')\n styleElement.setAttribute('type', 'text/css')\n const head = document.querySelector('head');\n if (head) {\n head.appendChild(styleElement);\n }\n\n styleElement.textContent = GLOBAL_CSS\n}\n","import {\n Component,\n OnInit,\n Input,\n OnChanges,\n SimpleChanges,\n SecurityContext,\n AfterContentInit,\n OnDestroy,\n ChangeDetectorRef,\n NgZone\n} from '@angular/core';\n\nimport { DomSanitizer } from '@angular/platform-browser';\nimport { insertCSS } from '../utlis/insertCSS';\nimport { buildImportUrl, generateUuid, buildInitPayload, createFileSender, classifyStructuredMessage, classifyLegacyMessage } from '@sumit_yewale/adapter-core';\n\n// How long we wait for the importer to confirm a file it was sent before giving up on it.\nconst FILE_ACK_TIMEOUT_MS = 8000;\n\n// Page-wide record of the importers that are open or opening, shared by every CSVBox adapter\n// on the page (it lives on window so separate copies of an adapter see the same list). It does\n// two things: the newest importer is stacked on top (every holder is fixed, full screen and\n// z-index 2147483647, so equal z-indexes would leave the one that comes first in the DOM on\n// top), and the other instances learn that an importer is open so they can disable their button.\ninterface OpenImporterEntry { getHolder: () => HTMLElement | null; }\ninterface OpenImporters { open: OpenImporterEntry[]; listeners: Array<() => void>; }\nconst OPEN_IMPORTERS_KEY = '__csvboxOpenImporters';\nconst TOP_Z_INDEX = 2147483647;\n\nfunction openImporters(): OpenImporters {\n const w = window as any;\n if (!w[OPEN_IMPORTERS_KEY]) w[OPEN_IMPORTERS_KEY] = { open: [], listeners: [] };\n return w[OPEN_IMPORTERS_KEY];\n}\n\nfunction restackOpenImporters(reg: OpenImporters): void {\n reg.open.forEach((entry, i) => {\n const holder = entry.getHolder();\n if (holder) holder.style.zIndex = String(TOP_Z_INDEX - (reg.open.length - 1 - i));\n });\n}\n\nfunction registerOpenImporter(entry: OpenImporterEntry): void {\n const reg = openImporters();\n if (reg.open.indexOf(entry) >= 0) return;\n reg.open.push(entry);\n restackOpenImporters(reg);\n reg.listeners.slice().forEach(fn => fn());\n}\n\nfunction unregisterOpenImporter(entry: OpenImporterEntry): void {\n const reg = openImporters();\n const i = reg.open.indexOf(entry);\n if (i < 0) return;\n reg.open.splice(i, 1);\n restackOpenImporters(reg);\n reg.listeners.slice().forEach(fn => fn());\n}\n\nfunction isBlockedByOpenImporter(entry: OpenImporterEntry): boolean {\n const reg = openImporters();\n return reg.open.length > 0 && reg.open.indexOf(entry) < 0;\n}\n\nfunction subscribeOpenImporters(fn: () => void): () => void {\n const reg = openImporters();\n reg.listeners.push(fn);\n return () => {\n const i = reg.listeners.indexOf(fn);\n if (i >= 0) reg.listeners.splice(i, 1);\n };\n}\n\nconst appVersion = '1.1.20';\n\n@Component({\n selector: 'csvbox-button',\n template: `\n <div>\n <button [disabled]=\"disabled || blockedByOther\" (click)=\"openModal()\" [attr.data-csvbox-token]=\"uuid\">\n <ng-content></ng-content>\n </button>\n </div>\n `\n})\n\nexport class CSVBoxButtonComponent implements OnInit, OnChanges, AfterContentInit, OnDestroy {\n\n isModalShown = false;\n\n @Input() onImport?: Function;\n @Input() onReady?: Function;\n @Input() onClose?: Function;\n @Input() onSubmit?: Function;\n\n @Input() isImported?: Function;\n @Input() isReady?: Function;\n @Input() isClosed?: Function;\n @Input() isSubmitted?: Function;\n\n @Input() importerReady?: Function;\n @Input() closed?: Function;\n @Input() submitted?: Function;\n @Input() imported?: Function;\n @Input() loadStarted?: Function;\n\n @Input() user?: object;\n @Input() dynamicColumns?: object;\n @Input() licenseKey: string | null = null;\n @Input() options?: object;\n @Input() uuid: string | null = null;\n @Input() customDomain: string | null = null;\n @Input() dataLocation: string | null = null;\n @Input() language: string | null = null;\n @Input() environment?: object;\n\n @Input() theme: string | null = null;\n\n @Input() isIframeLoaded: boolean = false;\n @Input() openModalOnIframeLoad: boolean = false;\n\n @Input() lazy: boolean = false;\n\n safeUrl: any;\n\n iframe: HTMLIFrameElement | null = null;\n\n @Input() disabled: boolean = true;\n\n constructor(public sanitizer:DomSanitizer, private cdr: ChangeDetectorRef, private zone: NgZone) {}\n\n // True while a different importer on the page is open: the button stays disabled.\n blockedByOther: boolean = false;\n\n private registryEntry: OpenImporterEntry = { getHolder: () => this.holder };\n\n private fileSender = createFileSender({\n getIframe: () => this.iframe,\n getToken: () => this.uuid as string,\n getTargetOrigin: () => this.targetOrigin as string,\n getBaseDomain: () => this.baseDomain,\n takeFile: () => {\n const file = this.pendingFile;\n this.pendingFile = null;\n return file;\n },\n onSent: () => this.startFileAckTimer()\n });\n\n private unsubscribeOpenImporters: (() => void) | null = null;\n\n holder: any;\n\n pendingFile: File | null = null;\n\n targetOrigin: string | undefined;\n\n // Data-location sheets redirect to another host, so the iframe origin can differ from\n // targetOrigin. baseDomain is used to check the real origin before trusting it.\n baseDomain: string = \"app.csvbox.io\";\n\n private fileAckTimer: any = null;\n\n ngOnInit(): void {\n this.uuid = generateUuid();\n let iframeUrl = buildImportUrl(\n {\n licenseKey: this.licenseKey,\n customDomain: this.customDomain,\n dataLocation: this.dataLocation,\n language: this.language,\n theme: this.theme,\n environment: this.environment\n },\n \"angular\",\n appVersion\n );\n // Default place to send the file. A file is only ever sent to a named origin, never \"*\".\n this.targetOrigin = new URL(iframeUrl).origin;\n this.baseDomain = this.customDomain || \"app.csvbox.io\";\n this.safeUrl = this.sanitizer.sanitize(SecurityContext.RESOURCE_URL, this.sanitizer.bypassSecurityTrustResourceUrl(iframeUrl));\n }\n\n ngOnChanges(changes: SimpleChanges) {\n if(changes[\"user\"] && changes['user'].currentValue != changes['user'].previousValue) {\n this.updateUserVariabe(changes['user'].currentValue);\n }\n }\n\n updateUserVariabe(data: any): void {\n this.user = data;\n if (this.iframe && this.iframe.contentWindow) {\n this.iframe.contentWindow.postMessage({\n \"customer\" : data\n }, \"*\");\n }\n }\n\n private messageListener = (event: MessageEvent) => {\n // Older importers send these as bare strings, without a token.\n const legacy = classifyLegacyMessage(event.data);\n if (legacy) {\n // Legacy messages carry no token, so the only way to tell which importer sent one is its\n // window. Ignore those that came from another instance's iframe (or anywhere else).\n if (!this.iframe || event.source !== this.iframe.contentWindow) {\n return;\n }\n if (legacy.type === \"mainModalHidden\") {\n this.handleModalClosed();\n } else if (legacy.type === \"uploadSuccessful\") {\n if (this.onImport) this.onImport(true);\n if (this.isImported) this.isImported(true);\n if (this.imported) this.imported(true);\n } else if (legacy.type === \"uploadFailed\") {\n if (this.onImport) this.onImport(false);\n if (this.isImported) this.isImported(false);\n if (this.imported) this.imported(false);\n }\n return;\n }\n\n // Set-file handshake messages. The shared core does not classify these, so they are\n // read here, behind the same unique_token check the core applies.\n const raw = event.data;\n if (raw && typeof raw === \"object\" && raw.data && raw.data.unique_token == this.uuid) {\n this.fileSender.learnOrigin(event);\n\n if (raw.type === \"csvbox-set-file-rejected\" && raw.data.reason === \"not-a-file\") {\n // Reply to our probe (it has no file). It only tells us the origin, so do nothing.\n return;\n }\n if (raw.type === \"csvbox-modal-shown\") {\n this.clearFileAckTimer();\n registerOpenImporter(this.registryEntry);\n // What the file path in openModal() is waiting for. display as well as\n // pointer-events: a second file declined while the first was still opening the\n // modal has put the holder away in the meantime.\n this.isModalShown = true;\n if (this.holder) {\n this.holder.style.display = 'block';\n this.holder.style.pointerEvents = 'auto';\n }\n return;\n }\n if (raw.type === \"csvbox-set-file-rejected\") {\n this.clearFileAckTimer();\n // The importer has the file and will not take it. Put the holder away only if the\n // modal was never confirmed up: a file declined while it is open leaves that modal\n // where it is, and its own 'csvbox-modal-hidden' will put the holder away.\n if (!this.isModalShown && this.holder) {\n this.holder.style.display = 'none';\n this.holder.style.pointerEvents = 'auto';\n unregisterOpenImporter(this.registryEntry);\n }\n console.warn(\"[csvbox] importer declined the supplied file: \" + raw.data.reason);\n return;\n }\n }\n\n let message = classifyStructuredMessage(event.data, this.uuid!);\n if (!message) {\n return;\n }\n\n if (message.type === \"data-on-submit\") {\n if (this.onSubmit) this.onSubmit(message.metadata);\n if (this.isSubmitted) this.isSubmitted(message.metadata);\n if (this.submitted) this.submitted(message.metadata);\n } else if (message.type === \"data-push-status\") {\n if (!message.success) {\n delete message.metadata[\"unique_token\"];\n }\n if (this.onImport) this.onImport(message.success, message.metadata);\n if (this.isImported) this.isImported(message.success, message.metadata);\n if (this.imported) this.imported(message.success, message.metadata);\n } else if (message.type === \"csvbox-modal-hidden\") {\n this.handleModalClosed();\n } else if (message.type === \"csvbox-upload-successful\") {\n if (this.onImport) this.onImport(true);\n if (this.isImported) this.isImported(true);\n if (this.imported) this.imported(true);\n } else if (message.type === \"csvbox-upload-failed\") {\n if (this.onImport) this.onImport(false);\n if (this.isImported) this.isImported(false);\n if (this.imported) this.imported(false);\n }\n };\n\n ngAfterContentInit(): void {\n window.addEventListener(\"message\", this.messageListener, false);\n this.syncBlocked();\n this.unsubscribeOpenImporters = subscribeOpenImporters(() => this.syncBlocked());\n\n if(this.lazy) {\n this.disabled = false;\n } else {\n this.disabled = true;\n this.initImporter();\n }\n }\n\n handleModalClosed(): void {\n if (this.holder) {\n this.holder.style.display = 'none';\n this.holder.style.pointerEvents = 'auto';\n }\n this.isModalShown = false;\n this.isIframeLoaded = false;\n this.openModalOnIframeLoad = false;\n if (this.holder) this.holder.remove();\n this.holder = null;\n this.iframe = null;\n // A new iframe is built on the next open, so the origin is learned again.\n this.clearProbeTimer();\n unregisterOpenImporter(this.registryEntry);\n if (this.onClose) this.onClose();\n if (this.isClosed) this.isClosed();\n if (this.closed) this.closed();\n }\n\n initImporter() {\n if (this.loadStarted) this.loadStarted();\n\n this.uuid = generateUuid();\n\n insertCSS();\n\n let iframe = document.createElement(\"iframe\");\n this.iframe = iframe;\n iframe.setAttribute(\"src\", this.safeUrl);\n iframe.setAttribute(\"allow\", \"clipboard-read; clipboard-write *\");\n iframe.frameBorder = \"0\";\n\n let self = this;\n iframe.onload = function () {\n if (self.onReady) self.onReady();\n if (self.isReady) self.isReady();\n if (self.importerReady) self.importerReady();\n\n self.disabled = false;\n self.isIframeLoaded = true;\n if (self.iframe && self.iframe.contentWindow) {\n self.iframe.contentWindow.postMessage(buildInitPayload(self.user, self.dynamicColumns, self.options, self.uuid!), \"*\");\n }\n if(self.openModalOnIframeLoad) {\n self.openModal();\n }\n }\n\n this.holder = document.createElement('div');\n this.holder.classList.add('csvbox-holder');\n this.holder.setAttribute('id', `csvbox-embed-${this.uuid}`);\n this.holder.appendChild(iframe);\n\n document.body.insertAdjacentElement(\n 'beforeend', this.holder\n );\n // The holder did not exist yet if openModal() asked for the importer before it was built.\n restackOpenImporters(openImporters());\n }\n\n openModal(): void {\n // Counts as open from the moment it is requested, so the other buttons are disabled while\n // this importer is still loading, and so it is stacked above any importer opened earlier.\n registerOpenImporter(this.registryEntry);\n if(!this.iframe) {\n this.openModalOnIframeLoad = true;\n this.initImporter();\n return;\n }\n if(!this.isModalShown) {\n if(this.isIframeLoaded) {\n if(this.pendingFile) {\n // The importer opens its own modal once it has the file, so that it can inject on\n // 'shown.bs.modal'. Sending 'openModal' as well would race that.\n //\n // It can also decline: wrong step, an import file URL configured on the sheet, or\n // an importer too old to know the message at all. So the holder goes up\n // click-through and stays that way until 'csvbox-modal-shown' confirms the modal\n // is really up. It covers the viewport at z-index 2147483647 and the importer\n // renders transparent with its modal closed, so arming it on an unanswered message\n // leaves an invisible sheet over the host page eating every click.\n //\n // display:block regardless, so the iframe lays out and animates normally; only\n // pointer-events is held back. isModalShown likewise waits for the confirmation,\n // or a declined file would latch the importer shut for good.\n if(this.holder) {\n this.holder.style.pointerEvents = 'none';\n this.holder.style.display = 'block';\n }\n this.fileSender.send();\n } else {\n this.isModalShown = true;\n if(this.holder) {\n // Explicit: a previously declined file leaves the holder click-through.\n this.holder.style.pointerEvents = 'auto';\n this.holder.style.display = 'block';\n }\n if(this.iframe && this.iframe.contentWindow) {\n this.iframe.contentWindow.postMessage('openModal', '*');\n }\n }\n } else {\n this.openModalOnIframeLoad = true;\n }\n }\n }\n\n /**\n * Open the importer on a File the host page already has, instead of the file picker.\n *\n * Reachable through a template reference (`#importer` then `importer.openModalWithFile(file)`)\n * or `@ViewChild(CSVBoxButtonComponent)`.\n *\n * The File crosses to the iframe by structured clone, so the importer receives the real\n * object and applies its own extension, worksheet and size rules to it -- this does not\n * bypass any of them. Pass a File; a Blob has no name for the importer to read an\n * extension from.\n */\n openModalWithFile(file: File): void {\n if(typeof File === 'undefined' || !(file instanceof File)) {\n return;\n }\n\n this.pendingFile = file;\n\n // Already open: hand it over now rather than holding it for the next open. The importer\n // takes it only while it is still on the upload step, and ignores it once the user has a\n // dataset and a mapping in progress.\n if(this.isModalShown && this.iframe && this.isIframeLoaded) {\n this.fileSender.send();\n return;\n }\n\n this.openModal();\n }\n\n clearProbeTimer(): void {\n this.clearFileAckTimer();\n this.fileSender.reset();\n }\n\n startFileAckTimer(): void {\n this.clearFileAckTimer();\n this.fileAckTimer = setTimeout(() => {\n this.fileAckTimer = null;\n this.giveUpOnFile();\n }, FILE_ACK_TIMEOUT_MS);\n }\n\n clearFileAckTimer(): void {\n if (this.fileAckTimer) {\n clearTimeout(this.fileAckTimer);\n this.fileAckTimer = null;\n }\n }\n\n // The importer never confirmed the file it was sent (an origin we do not trust, or an importer too\n // old to know the message). Without this the holder would stay up, invisible and click-through,\n // and the other instances' buttons would stay disabled for good.\n giveUpOnFile(): void {\n if (this.isModalShown) {\n return;\n }\n const holder = this.holder;\n if (holder) {\n holder.style.display = 'none';\n holder.style.pointerEvents = 'auto';\n }\n unregisterOpenImporter(this.registryEntry);\n console.warn(\"[csvbox] the importer did not respond to the supplied file\");\n }\n\n private syncBlocked(): void {\n const blocked = isBlockedByOpenImporter(this.registryEntry);\n if (blocked !== this.blockedByOther) {\n // The registry can call back from outside Angular's zone (another instance, another app).\n this.zone.run(() => {\n this.blockedByOther = blocked;\n this.cdr.markForCheck();\n });\n }\n }\n\n ngOnDestroy(): void {\n this.clearProbeTimer();\n window.removeEventListener(\"message\", this.messageListener);\n unregisterOpenImporter(this.registryEntry);\n if (this.unsubscribeOpenImporters) {\n this.unsubscribeOpenImporters();\n this.unsubscribeOpenImporters = null;\n }\n }\n}\n","import { NgModule } from '@angular/core';\nimport { CSVBoxButtonComponent } from './csvbox-button.component';\n\n\n\n@NgModule({\n declarations: [\n CSVBoxButtonComponent\n ],\n imports: [\n ],\n exports: [\n CSVBoxButtonComponent\n ]\n})\nexport class CSVBoxAngularModule { }\n","export interface CSVBoxMethods {\n onData?: (result:boolean, data:any) => void;\n}\n"],"names":["createFileSender","classifyLegacyMessage","classifyStructuredMessage","generateUuid","buildImportUrl","SecurityContext","buildInitPayload","Component","DomSanitizer","ChangeDetectorRef","NgZone","Input","NgModule"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C,8CAA4E;;;;;QAE5E,2CAWG;;;;;QAEH,yDAA6D;;QAE7D,uCAAY;;QAEZ,4CAAgC;;QAEhC,6CAAiC;;QAIjC,2CAAqC;;;;;QAErC,6CAAiC;;;;;QAqCjC,gDAwFE;;QA7JU,0CAA6B;;;;;QAAE,oCAA8B;;;;;QAAE,qCAAoB;;;;;;;;AClIjG;QAKA;SAUoC;;oBAVnCC,aAAQ,SAAC;wBACR,YAAY,EAAE;4BACZ,qBAAqB;yBACtB;wBACD,OAAO,EAAE,EACR;wBACD,OAAO,EAAE;4BACP,qBAAqB;yBACtB;qBACF;;QACkC,0BAAC;KAVpC;;;;;;;;;;ICLA,4BAEC;;;QADC,+BAA4C;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"sumit_yewale-angular.umd.js","sources":["ng://@sumit_yewale/angular/utlis/insertCSS.ts","ng://@sumit_yewale/angular/lib/csvbox-button.component.ts","ng://@sumit_yewale/angular/lib/csvbox-angular.module.ts","ng://@sumit_yewale/angular/lib/interfaces/interface.ts"],"sourcesContent":["let styleElement: HTMLStyleElement\n\nconst GLOBAL_CSS = `\n.csvbox-holder {\n z-index: 2147483647;\n position: fixed;\n top: 0;\n bottom: 0;\n left: 0;\n right: 0;\n display: none;\n}\n.csvbox-holder iframe {\n height: 100%;\n width: 100%;\n position: absolute;\n top: 0px;\n left: 0px;\n}\n`\n\nexport const insertCSS = (): void => {\n if (styleElement) {\n return\n }\n\n styleElement = document.createElement('style')\n styleElement.setAttribute('type', 'text/css')\n const head = document.querySelector('head');\n if (head) {\n head.appendChild(styleElement);\n }\n\n styleElement.textContent = GLOBAL_CSS\n}\n","import {\n Component,\n OnInit,\n Input,\n OnChanges,\n SimpleChanges,\n SecurityContext,\n AfterContentInit,\n OnDestroy,\n ChangeDetectorRef,\n NgZone\n} from '@angular/core';\n\nimport { DomSanitizer } from '@angular/platform-browser';\nimport { insertCSS } from '../utlis/insertCSS';\nimport { buildImportUrl, generateUuid, buildInitPayload, createMessageGate, createImportTracker, createFileSender, classifyStructuredMessage, classifyLegacyMessage } from '@sumit_yewale/adapter-core';\n\n// How long we wait for the importer to confirm a file it was sent before giving up on it.\nconst FILE_ACK_TIMEOUT_MS = 8000;\n\n// Page-wide record of the importers that are open or opening, shared by every CSVBox adapter\n// on the page (it lives on window so separate copies of an adapter see the same list). It does\n// two things: the newest importer is stacked on top (every holder is fixed, full screen and\n// z-index 2147483647, so equal z-indexes would leave the one that comes first in the DOM on\n// top), and the other instances learn that an importer is open so they can disable their button.\ninterface OpenImporterEntry { getHolder: () => HTMLElement | null; }\ninterface OpenImporters { open: OpenImporterEntry[]; listeners: Array<() => void>; }\nconst OPEN_IMPORTERS_KEY = '__csvboxOpenImporters';\nconst TOP_Z_INDEX = 2147483647;\n\nfunction openImporters(): OpenImporters {\n const w = window as any;\n if (!w[OPEN_IMPORTERS_KEY]) w[OPEN_IMPORTERS_KEY] = { open: [], listeners: [] };\n return w[OPEN_IMPORTERS_KEY];\n}\n\nfunction restackOpenImporters(reg: OpenImporters): void {\n reg.open.forEach((entry, i) => {\n const holder = entry.getHolder();\n if (holder) holder.style.zIndex = String(TOP_Z_INDEX - (reg.open.length - 1 - i));\n });\n}\n\nfunction registerOpenImporter(entry: OpenImporterEntry): void {\n const reg = openImporters();\n if (reg.open.indexOf(entry) >= 0) return;\n reg.open.push(entry);\n restackOpenImporters(reg);\n reg.listeners.slice().forEach(fn => fn());\n}\n\nfunction unregisterOpenImporter(entry: OpenImporterEntry): void {\n const reg = openImporters();\n const i = reg.open.indexOf(entry);\n if (i < 0) return;\n reg.open.splice(i, 1);\n restackOpenImporters(reg);\n reg.listeners.slice().forEach(fn => fn());\n}\n\nfunction isBlockedByOpenImporter(entry: OpenImporterEntry): boolean {\n const reg = openImporters();\n return reg.open.length > 0 && reg.open.indexOf(entry) < 0;\n}\n\nfunction subscribeOpenImporters(fn: () => void): () => void {\n const reg = openImporters();\n reg.listeners.push(fn);\n return () => {\n const i = reg.listeners.indexOf(fn);\n if (i >= 0) reg.listeners.splice(i, 1);\n };\n}\n\nconst appVersion = '1.1.20';\n\n@Component({\n selector: 'csvbox-button',\n template: `\n <div>\n <button [disabled]=\"disabled || blockedByOther\" (click)=\"openModal()\" [attr.data-csvbox-token]=\"uuid\">\n <ng-content></ng-content>\n </button>\n </div>\n `\n})\n\nexport class CSVBoxButtonComponent implements OnInit, OnChanges, AfterContentInit, OnDestroy {\n\n isModalShown = false;\n\n @Input() onImport?: Function;\n @Input() onReady?: Function;\n @Input() onClose?: Function;\n @Input() onSubmit?: Function;\n\n @Input() isImported?: Function;\n @Input() isReady?: Function;\n @Input() isClosed?: Function;\n @Input() isSubmitted?: Function;\n\n @Input() importerReady?: Function;\n @Input() closed?: Function;\n @Input() submitted?: Function;\n @Input() imported?: Function;\n @Input() loadStarted?: Function;\n\n @Input() user?: object;\n @Input() dynamicColumns?: object;\n @Input() licenseKey: string | null = null;\n @Input() options?: object;\n @Input() uuid: string | null = null;\n @Input() customDomain: string | null = null;\n @Input() dataLocation: string | null = null;\n @Input() language: string | null = null;\n @Input() environment?: object;\n\n @Input() theme: string | null = null;\n\n @Input() isIframeLoaded: boolean = false;\n @Input() openModalOnIframeLoad: boolean = false;\n\n @Input() lazy: boolean = false;\n\n safeUrl: any;\n\n iframe: HTMLIFrameElement | null = null;\n\n @Input() disabled: boolean = true;\n\n constructor(public sanitizer:DomSanitizer, private cdr: ChangeDetectorRef, private zone: NgZone) {}\n\n // True while a different importer on the page is open: the button stays disabled.\n blockedByOther: boolean = false;\n\n private messageGate = createMessageGate();\n private importTracker = createImportTracker();\n\n private registryEntry: OpenImporterEntry = { getHolder: () => this.holder };\n\n private fileSender = createFileSender({\n getIframe: () => this.iframe,\n getToken: () => this.uuid as string,\n getTargetOrigin: () => this.targetOrigin as string,\n getBaseDomain: () => this.baseDomain,\n takeFile: () => {\n const file = this.pendingFile;\n this.pendingFile = null;\n return file;\n },\n onSent: () => this.startFileAckTimer()\n });\n\n private unsubscribeOpenImporters: (() => void) | null = null;\n\n holder: any;\n\n pendingFile: File | null = null;\n\n targetOrigin: string | undefined;\n\n // Data-location sheets redirect to another host, so the iframe origin can differ from\n // targetOrigin. baseDomain is used to check the real origin before trusting it.\n baseDomain: string = \"app.csvbox.io\";\n\n private fileAckTimer: any = null;\n\n ngOnInit(): void {\n this.uuid = generateUuid();\n let iframeUrl = buildImportUrl(\n {\n licenseKey: this.licenseKey,\n customDomain: this.customDomain,\n dataLocation: this.dataLocation,\n language: this.language,\n theme: this.theme,\n environment: this.environment\n },\n \"angular\",\n appVersion\n );\n // Default place to send the file. A file is only ever sent to a named origin, never \"*\".\n this.targetOrigin = new URL(iframeUrl).origin;\n this.baseDomain = this.customDomain || \"app.csvbox.io\";\n this.safeUrl = this.sanitizer.sanitize(SecurityContext.RESOURCE_URL, this.sanitizer.bypassSecurityTrustResourceUrl(iframeUrl));\n }\n\n ngOnChanges(changes: SimpleChanges) {\n if(changes[\"user\"] && changes['user'].currentValue != changes['user'].previousValue) {\n this.updateUserVariabe(changes['user'].currentValue);\n }\n }\n\n updateUserVariabe(data: any): void {\n this.user = data;\n if (this.iframe && this.iframe.contentWindow) {\n this.iframe.contentWindow.postMessage({\n \"customer\" : data\n }, \"*\");\n }\n }\n\n private messageListener = (event: MessageEvent) => {\n // Older importers send these as bare strings, without a token.\n const legacy = classifyLegacyMessage(event.data);\n if (legacy) {\n // Legacy messages carry no token, so the only way to tell which importer sent one is its\n // window. Ignore those that came from another instance's iframe (or anywhere else).\n if (!this.iframe || event.source !== this.iframe.contentWindow) {\n return;\n }\n // A newer importer sends the typed message as well; act on that one only.\n if (!this.messageGate.allowLegacy()) {\n return;\n }\n const ended = this.importTracker.observe(legacy);\n if (legacy.type === \"mainModalHidden\") {\n this.handleModalClosed();\n } else if (legacy.type === \"uploadSuccessful\") {\n if (this.onImport) this.onImport(true);\n if (this.isImported) this.isImported(true);\n if (this.imported) this.imported(true);\n } else if (legacy.type === \"uploadFailed\") {\n if (this.onImport) this.onImport(false);\n if (this.isImported) this.isImported(false);\n if (this.imported) this.imported(false);\n }\n this.finishImport(ended);\n return;\n }\n\n // Set-file handshake messages. The shared core does not classify these, so they are\n // read here, behind the same unique_token check the core applies.\n const raw = event.data;\n if (raw && typeof raw === \"object\" && raw.data && raw.data.unique_token == this.uuid) {\n this.fileSender.learnOrigin(event);\n\n if (raw.type === \"csvbox-set-file-rejected\" && raw.data.reason === \"not-a-file\") {\n // Reply to our probe (it has no file). It only tells us the origin, so do nothing.\n return;\n }\n if (raw.type === \"csvbox-modal-shown\") {\n this.clearFileAckTimer();\n registerOpenImporter(this.registryEntry);\n // What the file path in openModal() is waiting for. display as well as\n // pointer-events: a second file declined while the first was still opening the\n // modal has put the holder away in the meantime.\n this.isModalShown = true;\n if (this.holder) {\n this.holder.style.display = 'block';\n this.holder.style.pointerEvents = 'auto';\n }\n return;\n }\n if (raw.type === \"csvbox-set-file-rejected\") {\n this.clearFileAckTimer();\n // The importer has the file and will not take it. Put the holder away only if the\n // modal was never confirmed up: a file declined while it is open leaves that modal\n // where it is, and its own 'csvbox-modal-hidden' will put the holder away.\n if (!this.isModalShown && this.holder) {\n this.holder.style.display = 'none';\n this.holder.style.pointerEvents = 'auto';\n unregisterOpenImporter(this.registryEntry);\n }\n console.warn(\"[csvbox] importer declined the supplied file: \" + raw.data.reason);\n return;\n }\n }\n\n let message = classifyStructuredMessage(event.data, this.uuid!);\n if (!message) {\n return;\n }\n this.messageGate.markTyped();\n const ended = this.importTracker.observe(message);\n\n if (message.type === \"data-on-submit\") {\n if (this.onSubmit) this.onSubmit(message.metadata);\n if (this.isSubmitted) this.isSubmitted(message.metadata);\n if (this.submitted) this.submitted(message.metadata);\n } else if (message.type === \"data-push-status\") {\n if (this.onImport) this.onImport(message.success, message.metadata);\n if (this.isImported) this.isImported(message.success, message.metadata);\n if (this.imported) this.imported(message.success, message.metadata);\n } else if (message.type === \"csvbox-modal-hidden\") {\n this.handleModalClosed();\n } else if (message.type === \"csvbox-upload-successful\") {\n if (this.onImport) this.onImport(true);\n if (this.isImported) this.isImported(true);\n if (this.imported) this.imported(true);\n } else if (message.type === \"csvbox-upload-failed\") {\n if (this.onImport) this.onImport(false);\n if (this.isImported) this.isImported(false);\n if (this.imported) this.imported(false);\n }\n this.finishImport(ended);\n };\n\n ngAfterContentInit(): void {\n window.addEventListener(\"message\", this.messageListener, false);\n this.syncBlocked();\n this.unsubscribeOpenImporters = subscribeOpenImporters(() => this.syncBlocked());\n\n if(this.lazy) {\n this.disabled = false;\n } else {\n this.disabled = true;\n this.initImporter();\n }\n }\n\n handleModalClosed(): void {\n if (this.importTracker.isInFlight()) {\n // Closed after submitting and before the result arrived: keep the iframe and its listener\n // so the late result still reaches onImport. It is removed once that result has been\n // delivered (see finishImport), so the next open is a fresh load.\n if (this.holder) {\n this.holder.style.display = 'none';\n this.holder.style.pointerEvents = 'auto';\n }\n this.isModalShown = false;\n this.openModalOnIframeLoad = false;\n this.clearFileAckTimer();\n unregisterOpenImporter(this.registryEntry);\n } else {\n this.destroyImporter();\n }\n if (this.onClose) this.onClose();\n if (this.isClosed) this.isClosed();\n if (this.closed) this.closed();\n }\n\n // Called after the result of an import has been delivered. If the modal was closed in the\n // meantime the iframe was only hidden, so remove it now.\n private finishImport(ended: boolean): void {\n if (ended && !this.isModalShown && this.iframe) {\n this.destroyImporter();\n }\n }\n\n // Puts the importer away: the next open builds a new iframe with a new token.\n private destroyImporter(): void {\n if (this.holder) {\n this.holder.style.display = 'none';\n this.holder.style.pointerEvents = 'auto';\n this.holder.remove();\n }\n this.holder = null;\n this.iframe = null;\n this.isModalShown = false;\n this.isIframeLoaded = false;\n this.openModalOnIframeLoad = false;\n this.messageGate.reset();\n this.importTracker.reset();\n // A new iframe is built on the next open, so the origin is learned again.\n this.clearProbeTimer();\n unregisterOpenImporter(this.registryEntry);\n }\n\n initImporter() {\n if (this.loadStarted) this.loadStarted();\n\n this.uuid = generateUuid();\n this.messageGate.reset();\n this.importTracker.reset();\n\n insertCSS();\n\n let iframe = document.createElement(\"iframe\");\n this.iframe = iframe;\n iframe.setAttribute(\"src\", this.safeUrl);\n iframe.setAttribute(\"allow\", \"clipboard-read; clipboard-write *\");\n iframe.frameBorder = \"0\";\n\n let self = this;\n iframe.onload = function () {\n self.disabled = false;\n self.isIframeLoaded = true;\n // The handshake goes first: a consumer that calls openModalWithFile() from the ready\n // callback needs the importer to already have its customer, columns, options and token.\n if (self.iframe && self.iframe.contentWindow) {\n self.iframe.contentWindow.postMessage(buildInitPayload(self.user, self.dynamicColumns, self.options, self.uuid!), \"*\");\n }\n if (self.onReady) self.onReady();\n if (self.isReady) self.isReady();\n if (self.importerReady) self.importerReady();\n\n if(self.openModalOnIframeLoad) {\n self.openModal();\n }\n }\n\n this.holder = document.createElement('div');\n this.holder.classList.add('csvbox-holder');\n this.holder.setAttribute('id', `csvbox-embed-${this.uuid}`);\n this.holder.appendChild(iframe);\n\n document.body.insertAdjacentElement(\n 'beforeend', this.holder\n );\n // The holder did not exist yet if openModal() asked for the importer before it was built.\n restackOpenImporters(openImporters());\n }\n\n openModal(): void {\n // Counts as open from the moment it is requested, so the other buttons are disabled while\n // this importer is still loading, and so it is stacked above any importer opened earlier.\n registerOpenImporter(this.registryEntry);\n if(!this.iframe) {\n this.openModalOnIframeLoad = true;\n this.initImporter();\n return;\n }\n if(!this.isModalShown) {\n if(this.isIframeLoaded) {\n if(this.pendingFile) {\n // The importer opens its own modal once it has the file, so that it can inject on\n // 'shown.bs.modal'. Sending 'openModal' as well would race that.\n //\n // It can also decline: wrong step, an import file URL configured on the sheet, or\n // an importer too old to know the message at all. So the holder goes up\n // click-through and stays that way until 'csvbox-modal-shown' confirms the modal\n // is really up. It covers the viewport at z-index 2147483647 and the importer\n // renders transparent with its modal closed, so arming it on an unanswered message\n // leaves an invisible sheet over the host page eating every click.\n //\n // display:block regardless, so the iframe lays out and animates normally; only\n // pointer-events is held back. isModalShown likewise waits for the confirmation,\n // or a declined file would latch the importer shut for good.\n if(this.holder) {\n this.holder.style.pointerEvents = 'none';\n this.holder.style.display = 'block';\n }\n this.fileSender.send();\n } else {\n this.isModalShown = true;\n if(this.holder) {\n // Explicit: a previously declined file leaves the holder click-through.\n this.holder.style.pointerEvents = 'auto';\n this.holder.style.display = 'block';\n }\n if(this.iframe && this.iframe.contentWindow) {\n this.iframe.contentWindow.postMessage('openModal', '*');\n }\n }\n } else {\n this.openModalOnIframeLoad = true;\n }\n }\n }\n\n /**\n * Open the importer on a File the host page already has, instead of the file picker.\n *\n * Reachable through a template reference (`#importer` then `importer.openModalWithFile(file)`)\n * or `@ViewChild(CSVBoxButtonComponent)`.\n *\n * The File crosses to the iframe by structured clone, so the importer receives the real\n * object and applies its own extension, worksheet and size rules to it -- this does not\n * bypass any of them. Pass a File; a Blob has no name for the importer to read an\n * extension from.\n */\n openModalWithFile(file: File): void {\n if(typeof File === 'undefined' || !(file instanceof File)) {\n return;\n }\n\n this.pendingFile = file;\n\n // Already open: hand it over now rather than holding it for the next open. The importer\n // takes it only while it is still on the upload step, and ignores it once the user has a\n // dataset and a mapping in progress.\n if(this.isModalShown && this.iframe && this.isIframeLoaded) {\n this.fileSender.send();\n return;\n }\n\n this.openModal();\n }\n\n clearProbeTimer(): void {\n this.clearFileAckTimer();\n this.fileSender.reset();\n }\n\n startFileAckTimer(): void {\n this.clearFileAckTimer();\n this.fileAckTimer = setTimeout(() => {\n this.fileAckTimer = null;\n this.giveUpOnFile();\n }, FILE_ACK_TIMEOUT_MS);\n }\n\n clearFileAckTimer(): void {\n if (this.fileAckTimer) {\n clearTimeout(this.fileAckTimer);\n this.fileAckTimer = null;\n }\n }\n\n // The importer never confirmed the file it was sent (an origin we do not trust, or an importer too\n // old to know the message). Without this the holder would stay up, invisible and click-through,\n // and the other instances' buttons would stay disabled for good.\n giveUpOnFile(): void {\n if (this.isModalShown) {\n return;\n }\n const holder = this.holder;\n if (holder) {\n holder.style.display = 'none';\n holder.style.pointerEvents = 'auto';\n }\n unregisterOpenImporter(this.registryEntry);\n console.warn(\"[csvbox] the importer did not respond to the supplied file\");\n }\n\n private syncBlocked(): void {\n const blocked = isBlockedByOpenImporter(this.registryEntry);\n if (blocked !== this.blockedByOther) {\n // The registry can call back from outside Angular's zone (another instance, another app).\n this.zone.run(() => {\n this.blockedByOther = blocked;\n this.cdr.markForCheck();\n });\n }\n }\n\n ngOnDestroy(): void {\n window.removeEventListener(\"message\", this.messageListener);\n // Takes the holder out of document.body: left there, it would keep covering the page with\n // an invisible full-screen layer that nothing is left to hide.\n this.destroyImporter();\n if (this.unsubscribeOpenImporters) {\n this.unsubscribeOpenImporters();\n this.unsubscribeOpenImporters = null;\n }\n }\n}\n","import { NgModule } from '@angular/core';\nimport { CSVBoxButtonComponent } from './csvbox-button.component';\n\n\n\n@NgModule({\n declarations: [\n CSVBoxButtonComponent\n ],\n imports: [\n ],\n exports: [\n CSVBoxButtonComponent\n ]\n})\nexport class CSVBoxAngularModule { }\n","export interface CSVBoxMethods {\n onData?: (result:boolean, data:any) => void;\n}\n"],"names":["createMessageGate","createImportTracker","createFileSender","classifyLegacyMessage","classifyStructuredMessage","generateUuid","buildImportUrl","SecurityContext","buildInitPayload","Component","DomSanitizer","ChangeDetectorRef","NgZone","Input","NgModule"],"mappings":";;;;;;;;;;;;QAAI,YAA8B;;QAE5B,UAAU,GAAG,wPAiBlB;;IAED,IAAa,SAAS;;;IAAG;QACvB,IAAI,YAAY,EAAE;YAChB,OAAM;SACP;QAED,YAAY,GAAG,QAAQ,CAAC,aAAa,CAAC,OAAO,CAAC,CAAA;QAC9C,YAAY,CAAC,YAAY,CAAC,MAAM,EAAE,UAAU,CAAC,CAAA;;YACvC,IAAI,GAAG,QAAQ,CAAC,aAAa,CAAC,MAAM,CAAC;QAC3C,IAAI,IAAI,EAAE;YACR,IAAI,CAAC,WAAW,CAAC,YAAY,CAAC,CAAC;SAChC;QAED,YAAY,CAAC,WAAW,GAAG,UAAU,CAAA;KACtC,CAAA;;;;;;;IClCD;;QAkBM,mBAAmB,GAAG,IAAI;;;;I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core"),require("@angular/platform-browser"),require("@sumit_yewale/adapter-core")):"function"==typeof define&&define.amd?define("@sumit_yewale/angular",["exports","@angular/core","@angular/platform-browser","@sumit_yewale/adapter-core"],t):t(((e=e||self).sumit_yewale=e.sumit_yewale||{},e.sumit_yewale.angular={}),e.ng.core,e.ng.platformBrowser,e.adapterCore)}(this,(function(e,t,i,n){"use strict";var o;function r(){var e=window;return e.__csvboxOpenImporters||(e.__csvboxOpenImporters={open:[],listeners:[]}),e.__csvboxOpenImporters}function s(e){e.open.forEach((function(t,i){var n=t.getHolder();n&&(n.style.zIndex=String(2147483647-(e.open.length-1-i)))}))}function a(e){var t=r();t.open.indexOf(e)>=0||(t.open.push(e),s(t),t.listeners.slice().forEach((function(e){return e()})))}function d(e){var t=r(),i=t.open.indexOf(e);i<0||(t.open.splice(i,1),s(t),t.listeners.slice().forEach((function(e){return e()})))}var l=function(){function e(e,t,i){var o=this;this.sanitizer=e,this.cdr=t,this.zone=i,this.isModalShown=!1,this.licenseKey=null,this.uuid=null,this.customDomain=null,this.dataLocation=null,this.language=null,this.theme=null,this.isIframeLoaded=!1,this.openModalOnIframeLoad=!1,this.lazy=!1,this.iframe=null,this.disabled=!0,this.blockedByOther=!1,this.registryEntry={getHolder:function(){return o.holder}},this.fileSender=n.createFileSender({getIframe:function(){return o.iframe},getToken:function(){return o.uuid},getTargetOrigin:function(){return o.targetOrigin},getBaseDomain:function(){return o.baseDomain},takeFile:function(){var e=o.pendingFile;return o.pendingFile=null,e},onSent:function(){return o.startFileAckTimer()}}),this.unsubscribeOpenImporters=null,this.pendingFile=null,this.baseDomain="app.csvbox.io",this.fileAckTimer=null,this.messageListener=function(e){var t=n.classifyLegacyMessage(e.data);if(t){if(!o.iframe||e.source!==o.iframe.contentWindow)return;"mainModalHidden"===t.type?o.handleModalClosed():"uploadSuccessful"===t.type?(o.onImport&&o.onImport(!0),o.isImported&&o.isImported(!0),o.imported&&o.imported(!0)):"uploadFailed"===t.type&&(o.onImport&&o.onImport(!1),o.isImported&&o.isImported(!1),o.imported&&o.imported(!1))}else{var i=e.data;if(i&&"object"==typeof i&&i.data&&i.data.unique_token==o.uuid){if(o.fileSender.learnOrigin(e),"csvbox-set-file-rejected"===i.type&&"not-a-file"===i.data.reason)return;if("csvbox-modal-shown"===i.type)return o.clearFileAckTimer(),a(o.registryEntry),o.isModalShown=!0,void(o.holder&&(o.holder.style.display="block",o.holder.style.pointerEvents="auto"));if("csvbox-set-file-rejected"===i.type)return o.clearFileAckTimer(),!o.isModalShown&&o.holder&&(o.holder.style.display="none",o.holder.style.pointerEvents="auto",d(o.registryEntry)),void console.warn("[csvbox] importer declined the supplied file: "+i.data.reason)}var r=n.classifyStructuredMessage(e.data,o.uuid);r&&("data-on-submit"===r.type?(o.onSubmit&&o.onSubmit(r.metadata),o.isSubmitted&&o.isSubmitted(r.metadata),o.submitted&&o.submitted(r.metadata)):"data-push-status"===r.type?(r.success||delete r.metadata.unique_token,o.onImport&&o.onImport(r.success,r.metadata),o.isImported&&o.isImported(r.success,r.metadata),o.imported&&o.imported(r.success,r.metadata)):"csvbox-modal-hidden"===r.type?o.handleModalClosed():"csvbox-upload-successful"===r.type?(o.onImport&&o.onImport(!0),o.isImported&&o.isImported(!0),o.imported&&o.imported(!0)):"csvbox-upload-failed"===r.type&&(o.onImport&&o.onImport(!1),o.isImported&&o.isImported(!1),o.imported&&o.imported(!1)))}}}return e.prototype.ngOnInit=function(){this.uuid=n.generateUuid();var e=n.buildImportUrl({licenseKey:this.licenseKey,customDomain:this.customDomain,dataLocation:this.dataLocation,language:this.language,theme:this.theme,environment:this.environment},"angular","1.1.20");this.targetOrigin=new URL(e).origin,this.baseDomain=this.customDomain||"app.csvbox.io",this.safeUrl=this.sanitizer.sanitize(t.SecurityContext.RESOURCE_URL,this.sanitizer.bypassSecurityTrustResourceUrl(e))},e.prototype.ngOnChanges=function(e){e.user&&e.user.currentValue!=e.user.previousValue&&this.updateUserVariabe(e.user.currentValue)},e.prototype.updateUserVariabe=function(e){this.user=e,this.iframe&&this.iframe.contentWindow&&this.iframe.contentWindow.postMessage({customer:e},"*")},e.prototype.ngAfterContentInit=function(){var e,t,i=this;window.addEventListener("message",this.messageListener,!1),this.syncBlocked(),this.unsubscribeOpenImporters=(e=function(){return i.syncBlocked()},(t=r()).listeners.push(e),function(){var i=t.listeners.indexOf(e);i>=0&&t.listeners.splice(i,1)}),this.lazy?this.disabled=!1:(this.disabled=!0,this.initImporter())},e.prototype.handleModalClosed=function(){this.holder&&(this.holder.style.display="none",this.holder.style.pointerEvents="auto"),this.isModalShown=!1,this.isIframeLoaded=!1,this.openModalOnIframeLoad=!1,this.holder&&this.holder.remove(),this.holder=null,this.iframe=null,this.clearProbeTimer(),d(this.registryEntry),this.onClose&&this.onClose(),this.isClosed&&this.isClosed(),this.closed&&this.closed()},e.prototype.initImporter=function(){this.loadStarted&&this.loadStarted(),this.uuid=n.generateUuid(),function(){if(!o){(o=document.createElement("style")).setAttribute("type","text/css");var e=document.querySelector("head");e&&e.appendChild(o),o.textContent="\n.csvbox-holder {\n z-index: 2147483647;\n position: fixed;\n top: 0;\n bottom: 0;\n left: 0;\n right: 0;\n display: none;\n}\n.csvbox-holder iframe {\n height: 100%;\n width: 100%;\n position: absolute;\n top: 0px;\n left: 0px;\n}\n"}}();var e=document.createElement("iframe");this.iframe=e,e.setAttribute("src",this.safeUrl),e.setAttribute("allow","clipboard-read; clipboard-write *"),e.frameBorder="0";var t=this;e.onload=function(){t.onReady&&t.onReady(),t.isReady&&t.isReady(),t.importerReady&&t.importerReady(),t.disabled=!1,t.isIframeLoaded=!0,t.iframe&&t.iframe.contentWindow&&t.iframe.contentWindow.postMessage(n.buildInitPayload(t.user,t.dynamicColumns,t.options,t.uuid),"*"),t.openModalOnIframeLoad&&t.openModal()},this.holder=document.createElement("div"),this.holder.classList.add("csvbox-holder"),this.holder.setAttribute("id","csvbox-embed-"+this.uuid),this.holder.appendChild(e),document.body.insertAdjacentElement("beforeend",this.holder),s(r())},e.prototype.openModal=function(){if(a(this.registryEntry),!this.iframe)return this.openModalOnIframeLoad=!0,void this.initImporter();this.isModalShown||(this.isIframeLoaded?this.pendingFile?(this.holder&&(this.holder.style.pointerEvents="none",this.holder.style.display="block"),this.fileSender.send()):(this.isModalShown=!0,this.holder&&(this.holder.style.pointerEvents="auto",this.holder.style.display="block"),this.iframe&&this.iframe.contentWindow&&this.iframe.contentWindow.postMessage("openModal","*")):this.openModalOnIframeLoad=!0)},e.prototype.openModalWithFile=function(e){"undefined"!=typeof File&&e instanceof File&&(this.pendingFile=e,this.isModalShown&&this.iframe&&this.isIframeLoaded?this.fileSender.send():this.openModal())},e.prototype.clearProbeTimer=function(){this.clearFileAckTimer(),this.fileSender.reset()},e.prototype.startFileAckTimer=function(){var e=this;this.clearFileAckTimer(),this.fileAckTimer=setTimeout((function(){e.fileAckTimer=null,e.giveUpOnFile()}),8e3)},e.prototype.clearFileAckTimer=function(){this.fileAckTimer&&(clearTimeout(this.fileAckTimer),this.fileAckTimer=null)},e.prototype.giveUpOnFile=function(){if(!this.isModalShown){var e=this.holder;e&&(e.style.display="none",e.style.pointerEvents="auto"),d(this.registryEntry),console.warn("[csvbox] the importer did not respond to the supplied file")}},e.prototype.syncBlocked=function(){var e,t,i=this,n=(e=this.registryEntry,(t=r()).open.length>0&&t.open.indexOf(e)<0);n!==this.blockedByOther&&this.zone.run((function(){i.blockedByOther=n,i.cdr.markForCheck()}))},e.prototype.ngOnDestroy=function(){this.clearProbeTimer(),window.removeEventListener("message",this.messageListener),d(this.registryEntry),this.unsubscribeOpenImporters&&(this.unsubscribeOpenImporters(),this.unsubscribeOpenImporters=null)},e.decorators=[{type:t.Component,args:[{selector:"csvbox-button",template:'\n <div>\n <button [disabled]="disabled || blockedByOther" (click)="openModal()" [attr.data-csvbox-token]="uuid">\n <ng-content></ng-content>\n </button>\n </div>\n '}]}],e.ctorParameters=function(){return[{type:i.DomSanitizer},{type:t.ChangeDetectorRef},{type:t.NgZone}]},e.propDecorators={onImport:[{type:t.Input}],onReady:[{type:t.Input}],onClose:[{type:t.Input}],onSubmit:[{type:t.Input}],isImported:[{type:t.Input}],isReady:[{type:t.Input}],isClosed:[{type:t.Input}],isSubmitted:[{type:t.Input}],importerReady:[{type:t.Input}],closed:[{type:t.Input}],submitted:[{type:t.Input}],imported:[{type:t.Input}],loadStarted:[{type:t.Input}],user:[{type:t.Input}],dynamicColumns:[{type:t.Input}],licenseKey:[{type:t.Input}],options:[{type:t.Input}],uuid:[{type:t.Input}],customDomain:[{type:t.Input}],dataLocation:[{type:t.Input}],language:[{type:t.Input}],environment:[{type:t.Input}],theme:[{type:t.Input}],isIframeLoaded:[{type:t.Input}],openModalOnIframeLoad:[{type:t.Input}],lazy:[{type:t.Input}],disabled:[{type:t.Input}]},e}();var p=function(){function e(){}return e.decorators=[{type:t.NgModule,args:[{declarations:[l],imports:[],exports:[l]}]}],e}();e.CSVBoxAngularModule=p,e.CSVBoxButtonComponent=l,Object.defineProperty(e,"__esModule",{value:!0})}));
1
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@angular/core"),require("@angular/platform-browser"),require("@sumit_yewale/adapter-core")):"function"==typeof define&&define.amd?define("@sumit_yewale/angular",["exports","@angular/core","@angular/platform-browser","@sumit_yewale/adapter-core"],t):t(((e=e||self).sumit_yewale=e.sumit_yewale||{},e.sumit_yewale.angular={}),e.ng.core,e.ng.platformBrowser,e.adapterCore)}(this,(function(e,t,i,o){"use strict";var n;function r(){var e=window;return e.__csvboxOpenImporters||(e.__csvboxOpenImporters={open:[],listeners:[]}),e.__csvboxOpenImporters}function s(e){e.open.forEach((function(t,i){var o=t.getHolder();o&&(o.style.zIndex=String(2147483647-(e.open.length-1-i)))}))}function a(e){var t=r();t.open.indexOf(e)>=0||(t.open.push(e),s(t),t.listeners.slice().forEach((function(e){return e()})))}function d(e){var t=r(),i=t.open.indexOf(e);i<0||(t.open.splice(i,1),s(t),t.listeners.slice().forEach((function(e){return e()})))}var l=function(){function e(e,t,i){var n=this;this.sanitizer=e,this.cdr=t,this.zone=i,this.isModalShown=!1,this.licenseKey=null,this.uuid=null,this.customDomain=null,this.dataLocation=null,this.language=null,this.theme=null,this.isIframeLoaded=!1,this.openModalOnIframeLoad=!1,this.lazy=!1,this.iframe=null,this.disabled=!0,this.blockedByOther=!1,this.messageGate=o.createMessageGate(),this.importTracker=o.createImportTracker(),this.registryEntry={getHolder:function(){return n.holder}},this.fileSender=o.createFileSender({getIframe:function(){return n.iframe},getToken:function(){return n.uuid},getTargetOrigin:function(){return n.targetOrigin},getBaseDomain:function(){return n.baseDomain},takeFile:function(){var e=n.pendingFile;return n.pendingFile=null,e},onSent:function(){return n.startFileAckTimer()}}),this.unsubscribeOpenImporters=null,this.pendingFile=null,this.baseDomain="app.csvbox.io",this.fileAckTimer=null,this.messageListener=function(e){var t=o.classifyLegacyMessage(e.data);if(t){if(!n.iframe||e.source!==n.iframe.contentWindow)return;if(!n.messageGate.allowLegacy())return;var i=n.importTracker.observe(t);return"mainModalHidden"===t.type?n.handleModalClosed():"uploadSuccessful"===t.type?(n.onImport&&n.onImport(!0),n.isImported&&n.isImported(!0),n.imported&&n.imported(!0)):"uploadFailed"===t.type&&(n.onImport&&n.onImport(!1),n.isImported&&n.isImported(!1),n.imported&&n.imported(!1)),void n.finishImport(i)}var r=e.data;if(r&&"object"==typeof r&&r.data&&r.data.unique_token==n.uuid){if(n.fileSender.learnOrigin(e),"csvbox-set-file-rejected"===r.type&&"not-a-file"===r.data.reason)return;if("csvbox-modal-shown"===r.type)return n.clearFileAckTimer(),a(n.registryEntry),n.isModalShown=!0,void(n.holder&&(n.holder.style.display="block",n.holder.style.pointerEvents="auto"));if("csvbox-set-file-rejected"===r.type)return n.clearFileAckTimer(),!n.isModalShown&&n.holder&&(n.holder.style.display="none",n.holder.style.pointerEvents="auto",d(n.registryEntry)),void console.warn("[csvbox] importer declined the supplied file: "+r.data.reason)}var s=o.classifyStructuredMessage(e.data,n.uuid);if(s){n.messageGate.markTyped();var l=n.importTracker.observe(s);"data-on-submit"===s.type?(n.onSubmit&&n.onSubmit(s.metadata),n.isSubmitted&&n.isSubmitted(s.metadata),n.submitted&&n.submitted(s.metadata)):"data-push-status"===s.type?(n.onImport&&n.onImport(s.success,s.metadata),n.isImported&&n.isImported(s.success,s.metadata),n.imported&&n.imported(s.success,s.metadata)):"csvbox-modal-hidden"===s.type?n.handleModalClosed():"csvbox-upload-successful"===s.type?(n.onImport&&n.onImport(!0),n.isImported&&n.isImported(!0),n.imported&&n.imported(!0)):"csvbox-upload-failed"===s.type&&(n.onImport&&n.onImport(!1),n.isImported&&n.isImported(!1),n.imported&&n.imported(!1)),n.finishImport(l)}}}return e.prototype.ngOnInit=function(){this.uuid=o.generateUuid();var e=o.buildImportUrl({licenseKey:this.licenseKey,customDomain:this.customDomain,dataLocation:this.dataLocation,language:this.language,theme:this.theme,environment:this.environment},"angular","1.1.20");this.targetOrigin=new URL(e).origin,this.baseDomain=this.customDomain||"app.csvbox.io",this.safeUrl=this.sanitizer.sanitize(t.SecurityContext.RESOURCE_URL,this.sanitizer.bypassSecurityTrustResourceUrl(e))},e.prototype.ngOnChanges=function(e){e.user&&e.user.currentValue!=e.user.previousValue&&this.updateUserVariabe(e.user.currentValue)},e.prototype.updateUserVariabe=function(e){this.user=e,this.iframe&&this.iframe.contentWindow&&this.iframe.contentWindow.postMessage({customer:e},"*")},e.prototype.ngAfterContentInit=function(){var e,t,i=this;window.addEventListener("message",this.messageListener,!1),this.syncBlocked(),this.unsubscribeOpenImporters=(e=function(){return i.syncBlocked()},(t=r()).listeners.push(e),function(){var i=t.listeners.indexOf(e);i>=0&&t.listeners.splice(i,1)}),this.lazy?this.disabled=!1:(this.disabled=!0,this.initImporter())},e.prototype.handleModalClosed=function(){this.importTracker.isInFlight()?(this.holder&&(this.holder.style.display="none",this.holder.style.pointerEvents="auto"),this.isModalShown=!1,this.openModalOnIframeLoad=!1,this.clearFileAckTimer(),d(this.registryEntry)):this.destroyImporter(),this.onClose&&this.onClose(),this.isClosed&&this.isClosed(),this.closed&&this.closed()},e.prototype.finishImport=function(e){e&&!this.isModalShown&&this.iframe&&this.destroyImporter()},e.prototype.destroyImporter=function(){this.holder&&(this.holder.style.display="none",this.holder.style.pointerEvents="auto",this.holder.remove()),this.holder=null,this.iframe=null,this.isModalShown=!1,this.isIframeLoaded=!1,this.openModalOnIframeLoad=!1,this.messageGate.reset(),this.importTracker.reset(),this.clearProbeTimer(),d(this.registryEntry)},e.prototype.initImporter=function(){this.loadStarted&&this.loadStarted(),this.uuid=o.generateUuid(),this.messageGate.reset(),this.importTracker.reset(),function(){if(!n){(n=document.createElement("style")).setAttribute("type","text/css");var e=document.querySelector("head");e&&e.appendChild(n),n.textContent="\n.csvbox-holder {\n z-index: 2147483647;\n position: fixed;\n top: 0;\n bottom: 0;\n left: 0;\n right: 0;\n display: none;\n}\n.csvbox-holder iframe {\n height: 100%;\n width: 100%;\n position: absolute;\n top: 0px;\n left: 0px;\n}\n"}}();var e=document.createElement("iframe");this.iframe=e,e.setAttribute("src",this.safeUrl),e.setAttribute("allow","clipboard-read; clipboard-write *"),e.frameBorder="0";var t=this;e.onload=function(){t.disabled=!1,t.isIframeLoaded=!0,t.iframe&&t.iframe.contentWindow&&t.iframe.contentWindow.postMessage(o.buildInitPayload(t.user,t.dynamicColumns,t.options,t.uuid),"*"),t.onReady&&t.onReady(),t.isReady&&t.isReady(),t.importerReady&&t.importerReady(),t.openModalOnIframeLoad&&t.openModal()},this.holder=document.createElement("div"),this.holder.classList.add("csvbox-holder"),this.holder.setAttribute("id","csvbox-embed-"+this.uuid),this.holder.appendChild(e),document.body.insertAdjacentElement("beforeend",this.holder),s(r())},e.prototype.openModal=function(){if(a(this.registryEntry),!this.iframe)return this.openModalOnIframeLoad=!0,void this.initImporter();this.isModalShown||(this.isIframeLoaded?this.pendingFile?(this.holder&&(this.holder.style.pointerEvents="none",this.holder.style.display="block"),this.fileSender.send()):(this.isModalShown=!0,this.holder&&(this.holder.style.pointerEvents="auto",this.holder.style.display="block"),this.iframe&&this.iframe.contentWindow&&this.iframe.contentWindow.postMessage("openModal","*")):this.openModalOnIframeLoad=!0)},e.prototype.openModalWithFile=function(e){"undefined"!=typeof File&&e instanceof File&&(this.pendingFile=e,this.isModalShown&&this.iframe&&this.isIframeLoaded?this.fileSender.send():this.openModal())},e.prototype.clearProbeTimer=function(){this.clearFileAckTimer(),this.fileSender.reset()},e.prototype.startFileAckTimer=function(){var e=this;this.clearFileAckTimer(),this.fileAckTimer=setTimeout((function(){e.fileAckTimer=null,e.giveUpOnFile()}),8e3)},e.prototype.clearFileAckTimer=function(){this.fileAckTimer&&(clearTimeout(this.fileAckTimer),this.fileAckTimer=null)},e.prototype.giveUpOnFile=function(){if(!this.isModalShown){var e=this.holder;e&&(e.style.display="none",e.style.pointerEvents="auto"),d(this.registryEntry),console.warn("[csvbox] the importer did not respond to the supplied file")}},e.prototype.syncBlocked=function(){var e,t,i=this,o=(e=this.registryEntry,(t=r()).open.length>0&&t.open.indexOf(e)<0);o!==this.blockedByOther&&this.zone.run((function(){i.blockedByOther=o,i.cdr.markForCheck()}))},e.prototype.ngOnDestroy=function(){window.removeEventListener("message",this.messageListener),this.destroyImporter(),this.unsubscribeOpenImporters&&(this.unsubscribeOpenImporters(),this.unsubscribeOpenImporters=null)},e.decorators=[{type:t.Component,args:[{selector:"csvbox-button",template:'\n <div>\n <button [disabled]="disabled || blockedByOther" (click)="openModal()" [attr.data-csvbox-token]="uuid">\n <ng-content></ng-content>\n </button>\n </div>\n '}]}],e.ctorParameters=function(){return[{type:i.DomSanitizer},{type:t.ChangeDetectorRef},{type:t.NgZone}]},e.propDecorators={onImport:[{type:t.Input}],onReady:[{type:t.Input}],onClose:[{type:t.Input}],onSubmit:[{type:t.Input}],isImported:[{type:t.Input}],isReady:[{type:t.Input}],isClosed:[{type:t.Input}],isSubmitted:[{type:t.Input}],importerReady:[{type:t.Input}],closed:[{type:t.Input}],submitted:[{type:t.Input}],imported:[{type:t.Input}],loadStarted:[{type:t.Input}],user:[{type:t.Input}],dynamicColumns:[{type:t.Input}],licenseKey:[{type:t.Input}],options:[{type:t.Input}],uuid:[{type:t.Input}],customDomain:[{type:t.Input}],dataLocation:[{type:t.Input}],language:[{type:t.Input}],environment:[{type:t.Input}],theme:[{type:t.Input}],isIframeLoaded:[{type:t.Input}],openModalOnIframeLoad:[{type:t.Input}],lazy:[{type:t.Input}],disabled:[{type:t.Input}]},e}();var p=function(){function e(){}return e.decorators=[{type:t.NgModule,args:[{declarations:[l],imports:[],exports:[l]}]}],e}();e.CSVBoxAngularModule=p,e.CSVBoxButtonComponent=l,Object.defineProperty(e,"__esModule",{value:!0})}));
2
2
  //# sourceMappingURL=sumit_yewale-angular.umd.min.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["ng://@sumit_yewale/angular/utlis/insertCSS.ts","ng://@sumit_yewale/angular/lib/csvbox-button.component.ts","ng://@sumit_yewale/angular/lib/csvbox-angular.module.ts"],"names":["styleElement","openImporters","w","open","listeners","restackOpenImporters","reg","forEach","entry","i","holder","getHolder","style","zIndex","String","length","registerOpenImporter","indexOf","push","slice","fn","unregisterOpenImporter","splice","CSVBoxButtonComponent","sanitizer","cdr","zone","_this","this","isModalShown","licenseKey","uuid","customDomain","dataLocation","language","theme","isIframeLoaded","openModalOnIframeLoad","lazy","iframe","disabled","blockedByOther","registryEntry","fileSender","createFileSender","getIframe","getToken","getTargetOrigin","getBaseDomain","baseDomain","takeFile","file","pendingFile","onSent","startFileAckTimer","unsubscribeOpenImporters","fileAckTimer","messageListener","event","legacy","classifyLegacyMessage","data","source","contentWindow","type","handleModalClosed","onImport","isImported","imported","raw","unique_token","learnOrigin","reason","clearFileAckTimer","display","pointerEvents","console","warn","message","classifyStructuredMessage","onSubmit","metadata","isSubmitted","submitted","success","prototype","ngOnInit","generateUuid","iframeUrl","buildImportUrl","environment","targetOrigin","URL","origin","safeUrl","sanitize","SecurityContext","RESOURCE_URL","bypassSecurityTrustResourceUrl","ngOnChanges","changes","currentValue","previousValue","updateUserVariabe","user","postMessage","customer","ngAfterContentInit","window","addEventListener","syncBlocked","initImporter","remove","clearProbeTimer","onClose","isClosed","closed","loadStarted","document","createElement","setAttribute","head","querySelector","appendChild","textContent","insertCSS","frameBorder","self","onload","onReady","isReady","importerReady","buildInitPayload","dynamicColumns","options","openModal","classList","add","body","insertAdjacentElement","send","openModalWithFile","File","reset","setTimeout","giveUpOnFile","clearTimeout","blocked","run","markForCheck","ngOnDestroy","removeEventListener","Component","args","selector","template","DomSanitizer","ChangeDetectorRef","NgZone","Input","CSVBoxAngularModule","NgModule","declarations","imports","exports"],"mappings":"kfAAIA,EC8BJ,SAASC,QACDC,EAAC,OAEP,OADKA,EAAoB,wBAAGA,EAAoB,sBAAI,CAAEC,KAAM,GAAIC,UAAW,KACpEF,EAAoB,sBAG7B,SAASG,EAAqBC,GAC5BA,EAAIH,KAAKI,SAAO,SAAEC,EAAOC,OACjBC,EAASF,EAAMG,YACjBD,IAAQA,EAAOE,MAAMC,OAASC,OAXlB,YAWwCR,EAAIH,KAAKY,OAAS,EAAIN,QAIlF,SAASO,EAAqBR,OACtBF,EAAML,IACRK,EAAIH,KAAKc,QAAQT,IAAU,IAC/BF,EAAIH,KAAKe,KAAKV,GACdH,EAAqBC,GACrBA,EAAIF,UAAUe,QAAQZ,SAAO,SAACa,GAAM,OAAAA,QAGtC,SAASC,EAAuBb,OACxBF,EAAML,IACNQ,EAAIH,EAAIH,KAAKc,QAAQT,GACvBC,EAAI,IACRH,EAAIH,KAAKmB,OAAOb,EAAG,GACnBJ,EAAqBC,GACrBA,EAAIF,UAAUe,QAAQZ,SAAO,SAACa,GAAM,OAAAA,YAmBtCG,EAAA,WAsDE,SAAAA,EAAmBC,EAAgCC,EAAgCC,GAAnF,IAAAC,EAAAC,KAAmBA,KAAAJ,UAAAA,EAAgCI,KAAAH,IAAAA,EAAgCG,KAAAF,KAAAA,EAzCnFE,KAAAC,cAAe,EAoBND,KAAAE,WA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AA,SA8WHxI,EAlaA,GC5EA,IAAAyI,EAAA,WAKA,SAAAA,KAUmC,2BAVlCC,EAAAA,SAAQR,KAAA,CAAC,CACRS,aAAc,CACZ3I,GAEF4I,QAAS,GAETC,QAAS,CACP7I,OAG+ByI,EAfnC","sourcesContent":["let styleElement: HTMLStyleElement\n\nconst GLOBAL_CSS = `\n.csvbox-holder {\n z-index: 2147483647;\n position: fixed;\n top: 0;\n bottom: 0;\n left: 0;\n right: 0;\n display: none;\n}\n.csvbox-holder iframe {\n height: 100%;\n width: 100%;\n position: absolute;\n top: 0px;\n left: 0px;\n}\n`\n\nexport const insertCSS = (): void => {\n if (styleElement) {\n return\n }\n\n styleElement = document.createElement('style')\n styleElement.setAttribute('type', 'text/css')\n const head = document.querySelector('head');\n if (head) {\n head.appendChild(styleElement);\n }\n\n styleElement.textContent = GLOBAL_CSS\n}\n","import {\n Component,\n OnInit,\n Input,\n OnChanges,\n SimpleChanges,\n SecurityContext,\n AfterContentInit,\n OnDestroy,\n ChangeDetectorRef,\n NgZone\n} from '@angular/core';\n\nimport { DomSanitizer } from '@angular/platform-browser';\nimport { insertCSS } from '../utlis/insertCSS';\nimport { buildImportUrl, generateUuid, buildInitPayload, createFileSender, classifyStructuredMessage, classifyLegacyMessage } from '@sumit_yewale/adapter-core';\n\n// How long we wait for the importer to confirm a file it was sent before giving up on it.\nconst FILE_ACK_TIMEOUT_MS = 8000;\n\n// Page-wide record of the importers that are open or opening, shared by every CSVBox adapter\n// on the page (it lives on window so separate copies of an adapter see the same list). It does\n// two things: the newest importer is stacked on top (every holder is fixed, full screen and\n// z-index 2147483647, so equal z-indexes would leave the one that comes first in the DOM on\n// top), and the other instances learn that an importer is open so they can disable their button.\ninterface OpenImporterEntry { getHolder: () => HTMLElement | null; }\ninterface OpenImporters { open: OpenImporterEntry[]; listeners: Array<() => void>; }\nconst OPEN_IMPORTERS_KEY = '__csvboxOpenImporters';\nconst TOP_Z_INDEX = 2147483647;\n\nfunction openImporters(): OpenImporters {\n const w = window as any;\n if (!w[OPEN_IMPORTERS_KEY]) w[OPEN_IMPORTERS_KEY] = { open: [], listeners: [] };\n return w[OPEN_IMPORTERS_KEY];\n}\n\nfunction restackOpenImporters(reg: OpenImporters): void {\n reg.open.forEach((entry, i) => {\n const holder = entry.getHolder();\n if (holder) holder.style.zIndex = String(TOP_Z_INDEX - (reg.open.length - 1 - i));\n });\n}\n\nfunction registerOpenImporter(entry: OpenImporterEntry): void {\n const reg = openImporters();\n if (reg.open.indexOf(entry) >= 0) return;\n reg.open.push(entry);\n restackOpenImporters(reg);\n reg.listeners.slice().forEach(fn => fn());\n}\n\nfunction unregisterOpenImporter(entry: OpenImporterEntry): void {\n const reg = openImporters();\n const i = reg.open.indexOf(entry);\n if (i < 0) return;\n reg.open.splice(i, 1);\n restackOpenImporters(reg);\n reg.listeners.slice().forEach(fn => fn());\n}\n\nfunction isBlockedByOpenImporter(entry: OpenImporterEntry): boolean {\n const reg = openImporters();\n return reg.open.length > 0 && reg.open.indexOf(entry) < 0;\n}\n\nfunction subscribeOpenImporters(fn: () => void): () => void {\n const reg = openImporters();\n reg.listeners.push(fn);\n return () => {\n const i = reg.listeners.indexOf(fn);\n if (i >= 0) reg.listeners.splice(i, 1);\n };\n}\n\nconst appVersion = '1.1.20';\n\n@Component({\n selector: 'csvbox-button',\n template: `\n <div>\n <button [disabled]=\"disabled || blockedByOther\" (click)=\"openModal()\" [attr.data-csvbox-token]=\"uuid\">\n <ng-content></ng-content>\n </button>\n </div>\n `\n})\n\nexport class CSVBoxButtonComponent implements OnInit, OnChanges, AfterContentInit, OnDestroy {\n\n isModalShown = false;\n\n @Input() onImport?: Function;\n @Input() onReady?: Function;\n @Input() onClose?: Function;\n @Input() onSubmit?: Function;\n\n @Input() isImported?: Function;\n @Input() isReady?: Function;\n @Input() isClosed?: Function;\n @Input() isSubmitted?: Function;\n\n @Input() importerReady?: Function;\n @Input() closed?: Function;\n @Input() submitted?: Function;\n @Input() imported?: Function;\n @Input() loadStarted?: Function;\n\n @Input() user?: object;\n @Input() dynamicColumns?: object;\n @Input() licenseKey: string | null = null;\n @Input() options?: object;\n @Input() uuid: string | null = null;\n @Input() customDomain: string | null = null;\n @Input() dataLocation: string | null = null;\n @Input() language: string | null = null;\n @Input() environment?: object;\n\n @Input() theme: string | null = null;\n\n @Input() isIframeLoaded: boolean = false;\n @Input() openModalOnIframeLoad: boolean = false;\n\n @Input() lazy: boolean = false;\n\n safeUrl: any;\n\n iframe: HTMLIFrameElement | null = null;\n\n @Input() disabled: boolean = true;\n\n constructor(public sanitizer:DomSanitizer, private cdr: ChangeDetectorRef, private zone: NgZone) {}\n\n // True while a different importer on the page is open: the button stays disabled.\n blockedByOther: boolean = false;\n\n private registryEntry: OpenImporterEntry = { getHolder: () => this.holder };\n\n private fileSender = createFileSender({\n getIframe: () => this.iframe,\n getToken: () => this.uuid as string,\n getTargetOrigin: () => this.targetOrigin as string,\n getBaseDomain: () => this.baseDomain,\n takeFile: () => {\n const file = this.pendingFile;\n this.pendingFile = null;\n return file;\n },\n onSent: () => this.startFileAckTimer()\n });\n\n private unsubscribeOpenImporters: (() => void) | null = null;\n\n holder: any;\n\n pendingFile: File | null = null;\n\n targetOrigin: string | undefined;\n\n // Data-location sheets redirect to another host, so the iframe origin can differ from\n // targetOrigin. baseDomain is used to check the real origin before trusting it.\n baseDomain: string = \"app.csvbox.io\";\n\n private fileAckTimer: any = null;\n\n ngOnInit(): void {\n this.uuid = generateUuid();\n let iframeUrl = buildImportUrl(\n {\n licenseKey: this.licenseKey,\n customDomain: this.customDomain,\n dataLocation: this.dataLocation,\n language: this.language,\n theme: this.theme,\n environment: this.environment\n },\n \"angular\",\n appVersion\n );\n // Default place to send the file. A file is only ever sent to a named origin, never \"*\".\n this.targetOrigin = new URL(iframeUrl).origin;\n this.baseDomain = this.customDomain || \"app.csvbox.io\";\n this.safeUrl = this.sanitizer.sanitize(SecurityContext.RESOURCE_URL, this.sanitizer.bypassSecurityTrustResourceUrl(iframeUrl));\n }\n\n ngOnChanges(changes: SimpleChanges) {\n if(changes[\"user\"] && changes['user'].currentValue != changes['user'].previousValue) {\n this.updateUserVariabe(changes['user'].currentValue);\n }\n }\n\n updateUserVariabe(data: any): void {\n this.user = data;\n if (this.iframe && this.iframe.contentWindow) {\n this.iframe.contentWindow.postMessage({\n \"customer\" : data\n }, \"*\");\n }\n }\n\n private messageListener = (event: MessageEvent) => {\n // Older importers send these as bare strings, without a token.\n const legacy = classifyLegacyMessage(event.data);\n if (legacy) {\n // Legacy messages carry no token, so the only way to tell which importer sent one is its\n // window. Ignore those that came from another instance's iframe (or anywhere else).\n if (!this.iframe || event.source !== this.iframe.contentWindow) {\n return;\n }\n if (legacy.type === \"mainModalHidden\") {\n this.handleModalClosed();\n } else if (legacy.type === \"uploadSuccessful\") {\n if (this.onImport) this.onImport(true);\n if (this.isImported) this.isImported(true);\n if (this.imported) this.imported(true);\n } else if (legacy.type === \"uploadFailed\") {\n if (this.onImport) this.onImport(false);\n if (this.isImported) this.isImported(false);\n if (this.imported) this.imported(false);\n }\n return;\n }\n\n // Set-file handshake messages. The shared core does not classify these, so they are\n // read here, behind the same unique_token check the core applies.\n const raw = event.data;\n if (raw && typeof raw === \"object\" && raw.data && raw.data.unique_token == this.uuid) {\n this.fileSender.learnOrigin(event);\n\n if (raw.type === \"csvbox-set-file-rejected\" && raw.data.reason === \"not-a-file\") {\n // Reply to our probe (it has no file). It only tells us the origin, so do nothing.\n return;\n }\n if (raw.type === \"csvbox-modal-shown\") {\n this.clearFileAckTimer();\n registerOpenImporter(this.registryEntry);\n // What the file path in openModal() is waiting for. display as well as\n // pointer-events: a second file declined while the first was still opening the\n // modal has put the holder away in the meantime.\n this.isModalShown = true;\n if (this.holder) {\n this.holder.style.display = 'block';\n this.holder.style.pointerEvents = 'auto';\n }\n return;\n }\n if (raw.type === \"csvbox-set-file-rejected\") {\n this.clearFileAckTimer();\n // The importer has the file and will not take it. Put the holder away only if the\n // modal was never confirmed up: a file declined while it is open leaves that modal\n // where it is, and its own 'csvbox-modal-hidden' will put the holder away.\n if (!this.isModalShown && this.holder) {\n this.holder.style.display = 'none';\n this.holder.style.pointerEvents = 'auto';\n unregisterOpenImporter(this.registryEntry);\n }\n console.warn(\"[csvbox] importer declined the supplied file: \" + raw.data.reason);\n return;\n }\n }\n\n let message = classifyStructuredMessage(event.data, this.uuid!);\n if (!message) {\n return;\n }\n\n if (message.type === \"data-on-submit\") {\n if (this.onSubmit) this.onSubmit(message.metadata);\n if (this.isSubmitted) this.isSubmitted(message.metadata);\n if (this.submitted) this.submitted(message.metadata);\n } else if (message.type === \"data-push-status\") {\n if (!message.success) {\n delete message.metadata[\"unique_token\"];\n }\n if (this.onImport) this.onImport(message.success, message.metadata);\n if (this.isImported) this.isImported(message.success, message.metadata);\n if (this.imported) this.imported(message.success, message.metadata);\n } else if (message.type === \"csvbox-modal-hidden\") {\n this.handleModalClosed();\n } else if (message.type === \"csvbox-upload-successful\") {\n if (this.onImport) this.onImport(true);\n if (this.isImported) this.isImported(true);\n if (this.imported) this.imported(true);\n } else if (message.type === \"csvbox-upload-failed\") {\n if (this.onImport) this.onImport(false);\n if (this.isImported) this.isImported(false);\n if (this.imported) this.imported(false);\n }\n };\n\n ngAfterContentInit(): void {\n window.addEventListener(\"message\", this.messageListener, false);\n this.syncBlocked();\n this.unsubscribeOpenImporters = subscribeOpenImporters(() => this.syncBlocked());\n\n if(this.lazy) {\n this.disabled = false;\n } else {\n this.disabled = true;\n this.initImporter();\n }\n }\n\n handleModalClosed(): void {\n if (this.holder) {\n this.holder.style.display = 'none';\n this.holder.style.pointerEvents = 'auto';\n }\n this.isModalShown = false;\n this.isIframeLoaded = false;\n this.openModalOnIframeLoad = false;\n if (this.holder) this.holder.remove();\n this.holder = null;\n this.iframe = null;\n // A new iframe is built on the next open, so the origin is learned again.\n this.clearProbeTimer();\n unregisterOpenImporter(this.registryEntry);\n if (this.onClose) this.onClose();\n if (this.isClosed) this.isClosed();\n if (this.closed) this.closed();\n }\n\n initImporter() {\n if (this.loadStarted) this.loadStarted();\n\n this.uuid = generateUuid();\n\n insertCSS();\n\n let iframe = document.createElement(\"iframe\");\n this.iframe = iframe;\n iframe.setAttribute(\"src\", this.safeUrl);\n iframe.setAttribute(\"allow\", \"clipboard-read; clipboard-write *\");\n iframe.frameBorder = \"0\";\n\n let self = this;\n iframe.onload = function () {\n if (self.onReady) self.onReady();\n if (self.isReady) self.isReady();\n if (self.importerReady) self.importerReady();\n\n self.disabled = false;\n self.isIframeLoaded = true;\n if (self.iframe && self.iframe.contentWindow) {\n self.iframe.contentWindow.postMessage(buildInitPayload(self.user, self.dynamicColumns, self.options, self.uuid!), \"*\");\n }\n if(self.openModalOnIframeLoad) {\n self.openModal();\n }\n }\n\n this.holder = document.createElement('div');\n this.holder.classList.add('csvbox-holder');\n this.holder.setAttribute('id', `csvbox-embed-${this.uuid}`);\n this.holder.appendChild(iframe);\n\n document.body.insertAdjacentElement(\n 'beforeend', this.holder\n );\n // The holder did not exist yet if openModal() asked for the importer before it was built.\n restackOpenImporters(openImporters());\n }\n\n openModal(): void {\n // Counts as open from the moment it is requested, so the other buttons are disabled while\n // this importer is still loading, and so it is stacked above any importer opened earlier.\n registerOpenImporter(this.registryEntry);\n if(!this.iframe) {\n this.openModalOnIframeLoad = true;\n this.initImporter();\n return;\n }\n if(!this.isModalShown) {\n if(this.isIframeLoaded) {\n if(this.pendingFile) {\n // The importer opens its own modal once it has the file, so that it can inject on\n // 'shown.bs.modal'. Sending 'openModal' as well would race that.\n //\n // It can also decline: wrong step, an import file URL configured on the sheet, or\n // an importer too old to know the message at all. So the holder goes up\n // click-through and stays that way until 'csvbox-modal-shown' confirms the modal\n // is really up. It covers the viewport at z-index 2147483647 and the importer\n // renders transparent with its modal closed, so arming it on an unanswered message\n // leaves an invisible sheet over the host page eating every click.\n //\n // display:block regardless, so the iframe lays out and animates normally; only\n // pointer-events is held back. isModalShown likewise waits for the confirmation,\n // or a declined file would latch the importer shut for good.\n if(this.holder) {\n this.holder.style.pointerEvents = 'none';\n this.holder.style.display = 'block';\n }\n this.fileSender.send();\n } else {\n this.isModalShown = true;\n if(this.holder) {\n // Explicit: a previously declined file leaves the holder click-through.\n this.holder.style.pointerEvents = 'auto';\n this.holder.style.display = 'block';\n }\n if(this.iframe && this.iframe.contentWindow) {\n this.iframe.contentWindow.postMessage('openModal', '*');\n }\n }\n } else {\n this.openModalOnIframeLoad = true;\n }\n }\n }\n\n /**\n * Open the importer on a File the host page already has, instead of the file picker.\n *\n * Reachable through a template reference (`#importer` then `importer.openModalWithFile(file)`)\n * or `@ViewChild(CSVBoxButtonComponent)`.\n *\n * The File crosses to the iframe by structured clone, so the importer receives the real\n * object and applies its own extension, worksheet and size rules to it -- this does not\n * bypass any of them. Pass a File; a Blob has no name for the importer to read an\n * extension from.\n */\n openModalWithFile(file: File): void {\n if(typeof File === 'undefined' || !(file instanceof File)) {\n return;\n }\n\n this.pendingFile = file;\n\n // Already open: hand it over now rather than holding it for the next open. The importer\n // takes it only while it is still on the upload step, and ignores it once the user has a\n // dataset and a mapping in progress.\n if(this.isModalShown && this.iframe && this.isIframeLoaded) {\n this.fileSender.send();\n return;\n }\n\n this.openModal();\n }\n\n clearProbeTimer(): void {\n this.clearFileAckTimer();\n this.fileSender.reset();\n }\n\n startFileAckTimer(): void {\n this.clearFileAckTimer();\n this.fileAckTimer = setTimeout(() => {\n this.fileAckTimer = null;\n this.giveUpOnFile();\n }, FILE_ACK_TIMEOUT_MS);\n }\n\n clearFileAckTimer(): void {\n if (this.fileAckTimer) {\n clearTimeout(this.fileAckTimer);\n this.fileAckTimer = null;\n }\n }\n\n // The importer never confirmed the file it was sent (an origin we do not trust, or an importer too\n // old to know the message). Without this the holder would stay up, invisible and click-through,\n // and the other instances' buttons would stay disabled for good.\n giveUpOnFile(): void {\n if (this.isModalShown) {\n return;\n }\n const holder = this.holder;\n if (holder) {\n holder.style.display = 'none';\n holder.style.pointerEvents = 'auto';\n }\n unregisterOpenImporter(this.registryEntry);\n console.warn(\"[csvbox] the importer did not respond to the supplied file\");\n }\n\n private syncBlocked(): void {\n const blocked = isBlockedByOpenImporter(this.registryEntry);\n if (blocked !== this.blockedByOther) {\n // The registry can call back from outside Angular's zone (another instance, another app).\n this.zone.run(() => {\n this.blockedByOther = blocked;\n this.cdr.markForCheck();\n });\n }\n }\n\n ngOnDestroy(): void {\n this.clearProbeTimer();\n window.removeEventListener(\"message\", this.messageListener);\n unregisterOpenImporter(this.registryEntry);\n if (this.unsubscribeOpenImporters) {\n this.unsubscribeOpenImporters();\n this.unsubscribeOpenImporters = null;\n }\n }\n}\n","import { NgModule } from '@angular/core';\nimport { CSVBoxButtonComponent } from './csvbox-button.component';\n\n\n\n@NgModule({\n declarations: [\n CSVBoxButtonComponent\n ],\n imports: [\n ],\n exports: [\n CSVBoxButtonComponent\n ]\n})\nexport class CSVBoxAngularModule { }\n"]}
1
+ {"version":3,"sources":["ng://@sumit_yewale/angular/utlis/insertCSS.ts","ng://@sumit_yewale/angular/lib/csvbox-button.component.ts","ng://@sumit_yewale/angular/lib/csvbox-angular.module.ts"],"names":["styleElement","openImporters","w","open","listeners","restackOpenImporters","reg","forEach","entry","i","holder","getHolder","style","zIndex","String","length","registerOpenImporter","indexOf","push","slice","fn","unregisterOpenImporter","splice","CSVBoxButtonComponent","sanitizer","cdr","zone","_this","this","isModalShown","licenseKey","uuid","customDomain","dataLocation","language","theme","isIframeLoaded","openModalOnIframeLoad","lazy","iframe","disabled","blockedByOther","messageGate","createMessageGate","importTracker","createImportTracker","registryEntry","fileSender","createFileSender","getIframe","getToken","getTargetOrigin","getBaseDomain","baseDomain","takeFile","file","pendingFile","onSent","startFileAckTimer","unsubscribeOpenImporters","fileAckTimer","messageListener","event","legacy","classifyLegacyMessage","data","source","contentWindow","allowLegacy","ended_1","observe","type","handleModalClosed","onImport","isImported","imported","finishImport","raw","unique_token","learnOrigin","reason","clearFileAckTimer","display","pointerEvents","console","warn","message","classifyStructuredMessage","markTyped","ended","onSubmit","metadata","isSubmitted","submitted","success","prototype","ngOnInit","generateUuid","iframeUrl","buildImportUrl","environment","targetOrigin","URL","origin","safeUrl","sanitize","SecurityContext","RESOURCE_URL","bypassSecurityTrustResourceUrl","ngOnChanges","changes","currentValue","previousValue","updateUserVariabe","user","postMessage","customer","ngAfterContentInit","window","addEventListener","syncBlocked","initImporter","isInFlight","destroyImporter","onClose","isClosed","closed","remove","reset","clearProbeTimer","loadStarted","document","createElement","setAttribute","head","querySelector","appendChild","textContent","insertCSS","frameBorder","self","onload","buildInitPayload","dynamicColumns","options","onReady","isReady","importerReady","openModal","classList","add","body","insertAdjacentElement","send","openModalWithFile","File","setTimeout","giveUpOnFile","clearTimeout","blocked","run","markForCheck","ngOnDestroy","removeEventListener","Component","args","selector","template","DomSanitizer","ChangeDetectorRef","NgZone","Input","CSVBoxAngularModule","NgModule","declarations","imports","exports"],"mappings":"kfAAIA,EC8BJ,SAASC,QACDC,EAAC,OAEP,OADKA,EAAoB,wBAAGA,EAAoB,sBAAI,CAAEC,KAAM,GAAIC,UAAW,KACpEF,EAAoB,sBAG7B,SAASG,EAAqBC,GAC5BA,EAAIH,KAAKI,SAAO,SAAEC,EAAOC,OACjBC,EAASF,EAAMG,YACjBD,IAAQA,EAAOE,MAAMC,OAASC,OAXlB,YAWwCR,EAAIH,KAAKY,OAAS,EAAIN,QAIlF,SAASO,EAAqBR,OACtBF,EAAML,IACRK,EAAIH,KAAKc,QAAQT,IAAU,IAC/BF,EAAIH,KAAKe,KAAKV,GACdH,EAAqBC,GACrBA,EAAIF,UAAUe,QAAQZ,SAAO,SAACa,GAAM,OAAAA,QAGtC,SAASC,EAAuBb,OACxBF,EAAML,IACNQ,EAAIH,EAAIH,KAAKc,QAAQT,GACvBC,EAAI,IACRH,EAAIH,KAAKmB,OAAOb,EAAG,GACnBJ,EAAqBC,GACrBA,EAAIF,UAAUe,QAAQZ,SAAO,SAACa,GAAM,OAAAA,YAmBtCG,EAAA,WAsDE,SAAAA,EAA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Y,OAAS,GAAKT,EAAIH,KAAKc,QAAQT,GAAS,GAwclDuJ,IAAYnI,KAAKa,gBAEnBb,KAAKF,KAAKsI,KAAG,WACXrI,EAAKc,eAAiBsH,EACtBpI,EAAKF,IAAIwI,mBAKf1I,EAAAwE,UAAAmE,YAAA,WACE5C,OAAO6C,oBAAoB,UAAWvI,KAAKiC,iBAG3CjC,KAAK+F,kBACD/F,KAAK+B,2BACP/B,KAAK+B,2BACL/B,KAAK+B,yBAA2B,2BA1crCyG,EAAAA,UAASC,KAAA,CAAC,CACTC,SAAU,gBACVC,SAAU,6OAjEHC,EAAAA,oBAJPC,EAAAA,yBACAC,EAAAA,4CAiFCC,EAAAA,uBACAA,EAAAA,uBACAA,EAAAA,wBACAA,EAAAA,0BAEAA,EAAAA,uBACAA,EAAAA,wBACAA,EAAAA,2BACAA,EAAAA,6BAEAA,EAAAA,sBACAA,EAAAA,yBACAA,EAAAA,wBACAA,EAAAA,2BACAA,EAAAA,oBAEAA,EAAAA,8BACAA,EAAAA,0BACAA,EAAAA,uBACAA,EAAAA,oBACAA,EAAAA,4BACAA,EAAAA,4BACAA,EAAAA,wBACAA,EAAAA,2BACAA,EAAAA,qBAEAA,EAAAA,8BAEAA,EAAAA,qCACAA,EAAAA,oBAEAA,EAAAA,wBAMAA,EAAAA,SAyZHpJ,EA7cA,GC5EA,IAAAqJ,EAAA,WAKA,SAAAA,KAUmC,2BAVlCC,EAAAA,SAAQR,KAAA,CAAC,CACRS,aAAc,CACZvJ,GAEFwJ,QAAS,GAETC,QAAS,CACPzJ,OAG+BqJ,EAfnC","sourcesContent":["let styleElement: HTMLStyleElement\n\nconst GLOBAL_CSS = `\n.csvbox-holder {\n z-index: 2147483647;\n position: fixed;\n top: 0;\n bottom: 0;\n left: 0;\n right: 0;\n display: none;\n}\n.csvbox-holder iframe {\n height: 100%;\n width: 100%;\n position: absolute;\n top: 0px;\n left: 0px;\n}\n`\n\nexport const insertCSS = (): void => {\n if (styleElement) {\n return\n }\n\n styleElement = document.createElement('style')\n styleElement.setAttribute('type', 'text/css')\n const head = document.querySelector('head');\n if (head) {\n head.appendChild(styleElement);\n }\n\n styleElement.textContent = GLOBAL_CSS\n}\n","import {\n Component,\n OnInit,\n Input,\n OnChanges,\n SimpleChanges,\n SecurityContext,\n AfterContentInit,\n OnDestroy,\n ChangeDetectorRef,\n NgZone\n} from '@angular/core';\n\nimport { DomSanitizer } from '@angular/platform-browser';\nimport { insertCSS } from '../utlis/insertCSS';\nimport { buildImportUrl, generateUuid, buildInitPayload, createMessageGate, createImportTracker, createFileSender, classifyStructuredMessage, classifyLegacyMessage } from '@sumit_yewale/adapter-core';\n\n// How long we wait for the importer to confirm a file it was sent before giving up on it.\nconst FILE_ACK_TIMEOUT_MS = 8000;\n\n// Page-wide record of the importers that are open or opening, shared by every CSVBox adapter\n// on the page (it lives on window so separate copies of an adapter see the same list). It does\n// two things: the newest importer is stacked on top (every holder is fixed, full screen and\n// z-index 2147483647, so equal z-indexes would leave the one that comes first in the DOM on\n// top), and the other instances learn that an importer is open so they can disable their button.\ninterface OpenImporterEntry { getHolder: () => HTMLElement | null; }\ninterface OpenImporters { open: OpenImporterEntry[]; listeners: Array<() => void>; }\nconst OPEN_IMPORTERS_KEY = '__csvboxOpenImporters';\nconst TOP_Z_INDEX = 2147483647;\n\nfunction openImporters(): OpenImporters {\n const w = window as any;\n if (!w[OPEN_IMPORTERS_KEY]) w[OPEN_IMPORTERS_KEY] = { open: [], listeners: [] };\n return w[OPEN_IMPORTERS_KEY];\n}\n\nfunction restackOpenImporters(reg: OpenImporters): void {\n reg.open.forEach((entry, i) => {\n const holder = entry.getHolder();\n if (holder) holder.style.zIndex = String(TOP_Z_INDEX - (reg.open.length - 1 - i));\n });\n}\n\nfunction registerOpenImporter(entry: OpenImporterEntry): void {\n const reg = openImporters();\n if (reg.open.indexOf(entry) >= 0) return;\n reg.open.push(entry);\n restackOpenImporters(reg);\n reg.listeners.slice().forEach(fn => fn());\n}\n\nfunction unregisterOpenImporter(entry: OpenImporterEntry): void {\n const reg = openImporters();\n const i = reg.open.indexOf(entry);\n if (i < 0) return;\n reg.open.splice(i, 1);\n restackOpenImporters(reg);\n reg.listeners.slice().forEach(fn => fn());\n}\n\nfunction isBlockedByOpenImporter(entry: OpenImporterEntry): boolean {\n const reg = openImporters();\n return reg.open.length > 0 && reg.open.indexOf(entry) < 0;\n}\n\nfunction subscribeOpenImporters(fn: () => void): () => void {\n const reg = openImporters();\n reg.listeners.push(fn);\n return () => {\n const i = reg.listeners.indexOf(fn);\n if (i >= 0) reg.listeners.splice(i, 1);\n };\n}\n\nconst appVersion = '1.1.20';\n\n@Component({\n selector: 'csvbox-button',\n template: `\n <div>\n <button [disabled]=\"disabled || blockedByOther\" (click)=\"openModal()\" [attr.data-csvbox-token]=\"uuid\">\n <ng-content></ng-content>\n </button>\n </div>\n `\n})\n\nexport class CSVBoxButtonComponent implements OnInit, OnChanges, AfterContentInit, OnDestroy {\n\n isModalShown = false;\n\n @Input() onImport?: Function;\n @Input() onReady?: Function;\n @Input() onClose?: Function;\n @Input() onSubmit?: Function;\n\n @Input() isImported?: Function;\n @Input() isReady?: Function;\n @Input() isClosed?: Function;\n @Input() isSubmitted?: Function;\n\n @Input() importerReady?: Function;\n @Input() closed?: Function;\n @Input() submitted?: Function;\n @Input() imported?: Function;\n @Input() loadStarted?: Function;\n\n @Input() user?: object;\n @Input() dynamicColumns?: object;\n @Input() licenseKey: string | null = null;\n @Input() options?: object;\n @Input() uuid: string | null = null;\n @Input() customDomain: string | null = null;\n @Input() dataLocation: string | null = null;\n @Input() language: string | null = null;\n @Input() environment?: object;\n\n @Input() theme: string | null = null;\n\n @Input() isIframeLoaded: boolean = false;\n @Input() openModalOnIframeLoad: boolean = false;\n\n @Input() lazy: boolean = false;\n\n safeUrl: any;\n\n iframe: HTMLIFrameElement | null = null;\n\n @Input() disabled: boolean = true;\n\n constructor(public sanitizer:DomSanitizer, private cdr: ChangeDetectorRef, private zone: NgZone) {}\n\n // True while a different importer on the page is open: the button stays disabled.\n blockedByOther: boolean = false;\n\n private messageGate = createMessageGate();\n private importTracker = createImportTracker();\n\n private registryEntry: OpenImporterEntry = { getHolder: () => this.holder };\n\n private fileSender = createFileSender({\n getIframe: () => this.iframe,\n getToken: () => this.uuid as string,\n getTargetOrigin: () => this.targetOrigin as string,\n getBaseDomain: () => this.baseDomain,\n takeFile: () => {\n const file = this.pendingFile;\n this.pendingFile = null;\n return file;\n },\n onSent: () => this.startFileAckTimer()\n });\n\n private unsubscribeOpenImporters: (() => void) | null = null;\n\n holder: any;\n\n pendingFile: File | null = null;\n\n targetOrigin: string | undefined;\n\n // Data-location sheets redirect to another host, so the iframe origin can differ from\n // targetOrigin. baseDomain is used to check the real origin before trusting it.\n baseDomain: string = \"app.csvbox.io\";\n\n private fileAckTimer: any = null;\n\n ngOnInit(): void {\n this.uuid = generateUuid();\n let iframeUrl = buildImportUrl(\n {\n licenseKey: this.licenseKey,\n customDomain: this.customDomain,\n dataLocation: this.dataLocation,\n language: this.language,\n theme: this.theme,\n environment: this.environment\n },\n \"angular\",\n appVersion\n );\n // Default place to send the file. A file is only ever sent to a named origin, never \"*\".\n this.targetOrigin = new URL(iframeUrl).origin;\n this.baseDomain = this.customDomain || \"app.csvbox.io\";\n this.safeUrl = this.sanitizer.sanitize(SecurityContext.RESOURCE_URL, this.sanitizer.bypassSecurityTrustResourceUrl(iframeUrl));\n }\n\n ngOnChanges(changes: SimpleChanges) {\n if(changes[\"user\"] && changes['user'].currentValue != changes['user'].previousValue) {\n this.updateUserVariabe(changes['user'].currentValue);\n }\n }\n\n updateUserVariabe(data: any): void {\n this.user = data;\n if (this.iframe && this.iframe.contentWindow) {\n this.iframe.contentWindow.postMessage({\n \"customer\" : data\n }, \"*\");\n }\n }\n\n private messageListener = (event: MessageEvent) => {\n // Older importers send these as bare strings, without a token.\n const legacy = classifyLegacyMessage(event.data);\n if (legacy) {\n // Legacy messages carry no token, so the only way to tell which importer sent one is its\n // window. Ignore those that came from another instance's iframe (or anywhere else).\n if (!this.iframe || event.source !== this.iframe.contentWindow) {\n return;\n }\n // A newer importer sends the typed message as well; act on that one only.\n if (!this.messageGate.allowLegacy()) {\n return;\n }\n const ended = this.importTracker.observe(legacy);\n if (legacy.type === \"mainModalHidden\") {\n this.handleModalClosed();\n } else if (legacy.type === \"uploadSuccessful\") {\n if (this.onImport) this.onImport(true);\n if (this.isImported) this.isImported(true);\n if (this.imported) this.imported(true);\n } else if (legacy.type === \"uploadFailed\") {\n if (this.onImport) this.onImport(false);\n if (this.isImported) this.isImported(false);\n if (this.imported) this.imported(false);\n }\n this.finishImport(ended);\n return;\n }\n\n // Set-file handshake messages. The shared core does not classify these, so they are\n // read here, behind the same unique_token check the core applies.\n const raw = event.data;\n if (raw && typeof raw === \"object\" && raw.data && raw.data.unique_token == this.uuid) {\n this.fileSender.learnOrigin(event);\n\n if (raw.type === \"csvbox-set-file-rejected\" && raw.data.reason === \"not-a-file\") {\n // Reply to our probe (it has no file). It only tells us the origin, so do nothing.\n return;\n }\n if (raw.type === \"csvbox-modal-shown\") {\n this.clearFileAckTimer();\n registerOpenImporter(this.registryEntry);\n // What the file path in openModal() is waiting for. display as well as\n // pointer-events: a second file declined while the first was still opening the\n // modal has put the holder away in the meantime.\n this.isModalShown = true;\n if (this.holder) {\n this.holder.style.display = 'block';\n this.holder.style.pointerEvents = 'auto';\n }\n return;\n }\n if (raw.type === \"csvbox-set-file-rejected\") {\n this.clearFileAckTimer();\n // The importer has the file and will not take it. Put the holder away only if the\n // modal was never confirmed up: a file declined while it is open leaves that modal\n // where it is, and its own 'csvbox-modal-hidden' will put the holder away.\n if (!this.isModalShown && this.holder) {\n this.holder.style.display = 'none';\n this.holder.style.pointerEvents = 'auto';\n unregisterOpenImporter(this.registryEntry);\n }\n console.warn(\"[csvbox] importer declined the supplied file: \" + raw.data.reason);\n return;\n }\n }\n\n let message = classifyStructuredMessage(event.data, this.uuid!);\n if (!message) {\n return;\n }\n this.messageGate.markTyped();\n const ended = this.importTracker.observe(message);\n\n if (message.type === \"data-on-submit\") {\n if (this.onSubmit) this.onSubmit(message.metadata);\n if (this.isSubmitted) this.isSubmitted(message.metadata);\n if (this.submitted) this.submitted(message.metadata);\n } else if (message.type === \"data-push-status\") {\n if (this.onImport) this.onImport(message.success, message.metadata);\n if (this.isImported) this.isImported(message.success, message.metadata);\n if (this.imported) this.imported(message.success, message.metadata);\n } else if (message.type === \"csvbox-modal-hidden\") {\n this.handleModalClosed();\n } else if (message.type === \"csvbox-upload-successful\") {\n if (this.onImport) this.onImport(true);\n if (this.isImported) this.isImported(true);\n if (this.imported) this.imported(true);\n } else if (message.type === \"csvbox-upload-failed\") {\n if (this.onImport) this.onImport(false);\n if (this.isImported) this.isImported(false);\n if (this.imported) this.imported(false);\n }\n this.finishImport(ended);\n };\n\n ngAfterContentInit(): void {\n window.addEventListener(\"message\", this.messageListener, false);\n this.syncBlocked();\n this.unsubscribeOpenImporters = subscribeOpenImporters(() => this.syncBlocked());\n\n if(this.lazy) {\n this.disabled = false;\n } else {\n this.disabled = true;\n this.initImporter();\n }\n }\n\n handleModalClosed(): void {\n if (this.importTracker.isInFlight()) {\n // Closed after submitting and before the result arrived: keep the iframe and its listener\n // so the late result still reaches onImport. It is removed once that result has been\n // delivered (see finishImport), so the next open is a fresh load.\n if (this.holder) {\n this.holder.style.display = 'none';\n this.holder.style.pointerEvents = 'auto';\n }\n this.isModalShown = false;\n this.openModalOnIframeLoad = false;\n this.clearFileAckTimer();\n unregisterOpenImporter(this.registryEntry);\n } else {\n this.destroyImporter();\n }\n if (this.onClose) this.onClose();\n if (this.isClosed) this.isClosed();\n if (this.closed) this.closed();\n }\n\n // Called after the result of an import has been delivered. If the modal was closed in the\n // meantime the iframe was only hidden, so remove it now.\n private finishImport(ended: boolean): void {\n if (ended && !this.isModalShown && this.iframe) {\n this.destroyImporter();\n }\n }\n\n // Puts the importer away: the next open builds a new iframe with a new token.\n private destroyImporter(): void {\n if (this.holder) {\n this.holder.style.display = 'none';\n this.holder.style.pointerEvents = 'auto';\n this.holder.remove();\n }\n this.holder = null;\n this.iframe = null;\n this.isModalShown = false;\n this.isIframeLoaded = false;\n this.openModalOnIframeLoad = false;\n this.messageGate.reset();\n this.importTracker.reset();\n // A new iframe is built on the next open, so the origin is learned again.\n this.clearProbeTimer();\n unregisterOpenImporter(this.registryEntry);\n }\n\n initImporter() {\n if (this.loadStarted) this.loadStarted();\n\n this.uuid = generateUuid();\n this.messageGate.reset();\n this.importTracker.reset();\n\n insertCSS();\n\n let iframe = document.createElement(\"iframe\");\n this.iframe = iframe;\n iframe.setAttribute(\"src\", this.safeUrl);\n iframe.setAttribute(\"allow\", \"clipboard-read; clipboard-write *\");\n iframe.frameBorder = \"0\";\n\n let self = this;\n iframe.onload = function () {\n self.disabled = false;\n self.isIframeLoaded = true;\n // The handshake goes first: a consumer that calls openModalWithFile() from the ready\n // callback needs the importer to already have its customer, columns, options and token.\n if (self.iframe && self.iframe.contentWindow) {\n self.iframe.contentWindow.postMessage(buildInitPayload(self.user, self.dynamicColumns, self.options, self.uuid!), \"*\");\n }\n if (self.onReady) self.onReady();\n if (self.isReady) self.isReady();\n if (self.importerReady) self.importerReady();\n\n if(self.openModalOnIframeLoad) {\n self.openModal();\n }\n }\n\n this.holder = document.createElement('div');\n this.holder.classList.add('csvbox-holder');\n this.holder.setAttribute('id', `csvbox-embed-${this.uuid}`);\n this.holder.appendChild(iframe);\n\n document.body.insertAdjacentElement(\n 'beforeend', this.holder\n );\n // The holder did not exist yet if openModal() asked for the importer before it was built.\n restackOpenImporters(openImporters());\n }\n\n openModal(): void {\n // Counts as open from the moment it is requested, so the other buttons are disabled while\n // this importer is still loading, and so it is stacked above any importer opened earlier.\n registerOpenImporter(this.registryEntry);\n if(!this.iframe) {\n this.openModalOnIframeLoad = true;\n this.initImporter();\n return;\n }\n if(!this.isModalShown) {\n if(this.isIframeLoaded) {\n if(this.pendingFile) {\n // The importer opens its own modal once it has the file, so that it can inject on\n // 'shown.bs.modal'. Sending 'openModal' as well would race that.\n //\n // It can also decline: wrong step, an import file URL configured on the sheet, or\n // an importer too old to know the message at all. So the holder goes up\n // click-through and stays that way until 'csvbox-modal-shown' confirms the modal\n // is really up. It covers the viewport at z-index 2147483647 and the importer\n // renders transparent with its modal closed, so arming it on an unanswered message\n // leaves an invisible sheet over the host page eating every click.\n //\n // display:block regardless, so the iframe lays out and animates normally; only\n // pointer-events is held back. isModalShown likewise waits for the confirmation,\n // or a declined file would latch the importer shut for good.\n if(this.holder) {\n this.holder.style.pointerEvents = 'none';\n this.holder.style.display = 'block';\n }\n this.fileSender.send();\n } else {\n this.isModalShown = true;\n if(this.holder) {\n // Explicit: a previously declined file leaves the holder click-through.\n this.holder.style.pointerEvents = 'auto';\n this.holder.style.display = 'block';\n }\n if(this.iframe && this.iframe.contentWindow) {\n this.iframe.contentWindow.postMessage('openModal', '*');\n }\n }\n } else {\n this.openModalOnIframeLoad = true;\n }\n }\n }\n\n /**\n * Open the importer on a File the host page already has, instead of the file picker.\n *\n * Reachable through a template reference (`#importer` then `importer.openModalWithFile(file)`)\n * or `@ViewChild(CSVBoxButtonComponent)`.\n *\n * The File crosses to the iframe by structured clone, so the importer receives the real\n * object and applies its own extension, worksheet and size rules to it -- this does not\n * bypass any of them. Pass a File; a Blob has no name for the importer to read an\n * extension from.\n */\n openModalWithFile(file: File): void {\n if(typeof File === 'undefined' || !(file instanceof File)) {\n return;\n }\n\n this.pendingFile = file;\n\n // Already open: hand it over now rather than holding it for the next open. The importer\n // takes it only while it is still on the upload step, and ignores it once the user has a\n // dataset and a mapping in progress.\n if(this.isModalShown && this.iframe && this.isIframeLoaded) {\n this.fileSender.send();\n return;\n }\n\n this.openModal();\n }\n\n clearProbeTimer(): void {\n this.clearFileAckTimer();\n this.fileSender.reset();\n }\n\n startFileAckTimer(): void {\n this.clearFileAckTimer();\n this.fileAckTimer = setTimeout(() => {\n this.fileAckTimer = null;\n this.giveUpOnFile();\n }, FILE_ACK_TIMEOUT_MS);\n }\n\n clearFileAckTimer(): void {\n if (this.fileAckTimer) {\n clearTimeout(this.fileAckTimer);\n this.fileAckTimer = null;\n }\n }\n\n // The importer never confirmed the file it was sent (an origin we do not trust, or an importer too\n // old to know the message). Without this the holder would stay up, invisible and click-through,\n // and the other instances' buttons would stay disabled for good.\n giveUpOnFile(): void {\n if (this.isModalShown) {\n return;\n }\n const holder = this.holder;\n if (holder) {\n holder.style.display = 'none';\n holder.style.pointerEvents = 'auto';\n }\n unregisterOpenImporter(this.registryEntry);\n console.warn(\"[csvbox] the importer did not respond to the supplied file\");\n }\n\n private syncBlocked(): void {\n const blocked = isBlockedByOpenImporter(this.registryEntry);\n if (blocked !== this.blockedByOther) {\n // The registry can call back from outside Angular's zone (another instance, another app).\n this.zone.run(() => {\n this.blockedByOther = blocked;\n this.cdr.markForCheck();\n });\n }\n }\n\n ngOnDestroy(): void {\n window.removeEventListener(\"message\", this.messageListener);\n // Takes the holder out of document.body: left there, it would keep covering the page with\n // an invisible full-screen layer that nothing is left to hide.\n this.destroyImporter();\n if (this.unsubscribeOpenImporters) {\n this.unsubscribeOpenImporters();\n this.unsubscribeOpenImporters = null;\n }\n }\n}\n","import { NgModule } from '@angular/core';\nimport { CSVBoxButtonComponent } from './csvbox-button.component';\n\n\n\n@NgModule({\n declarations: [\n CSVBoxButtonComponent\n ],\n imports: [\n ],\n exports: [\n CSVBoxButtonComponent\n ]\n})\nexport class CSVBoxAngularModule { }\n"]}