{"version":3,"file":"createPrintView.mjs","sources":["../../../../../../packages/components/controls/print/createPrintView.ts"],"sourcesContent":["/*\n * @Author: zouyaoji@https://github.com/zouyaoji\n * @Date: 2021-10-27 15:54:13\n * @LastEditTime: 2022-02-09 16:40:15\n * @LastEditors: zouyaoji\n * @Description:\n * @FilePath: \\vue-cesium@next\\packages\\components\\controls\\print\\createPrintView.ts\n */\nimport { createApp } from 'vue'\nimport VcPrintView from './print-view'\n\nconst styles = `\n  .background {\n    width: 100%;\n    fill: rgba(255, 255, 255, 1.0);\n  }\n\n  .map-image {\n    max-width: 95vw;\n    max-height: 95vh;\n  }\n\n  .layer-legends {\n    display: inline;\n    float: left;\n    padding-left: 20px;\n    padding-right: 20px;\n  }\n\n  .layer-title {\n    font-weight: bold;\n  }\n\n  h1, h2, h3 {\n    clear: both;\n  }\n`\n\nconst createPrintView = options => {\n  const { printWindow = window.open(), closeCallback, title } = options\n  if (closeCallback) {\n    printWindow.addEventListener('unload', () => {\n      closeCallback(printWindow)\n    })\n  }\n\n  // Open and immediately close the document. This works around a problem in Firefox that is\n  // captured here: https://bugzilla.mozilla.org/show_bug.cgi?id=667227.\n  // Essentially, when we first create an iframe, it has no document loaded and asynchronously\n  // starts a load of \"about:blank\". If we access the document object and start manipulating it\n  // before that async load completes, a new document will be automatically created. But then\n  // when the async load completes, the original, automatically-created document gets unloaded\n  // and the new \"about:blank\" gets swapped in. End result: everything we add to the DOM before\n  // the async load complete gets lost and Firefox ends up printing a blank page.\n  // Explicitly opening and then closing a new document _seems_ to avoid this.\n  printWindow.document.open()\n  printWindow.document.close()\n  printWindow.document.head.innerHTML = `\n    <meta charset=\"UTF-8\">\n    <title>${options.title}</title>\n    <style>${styles}</style>\n    `\n  printWindow.document.body.innerHTML = '<div id=\"print\"></div>'\n\n  options.printWindow = options.printWindow || printWindow\n\n  const printViewProps = {\n    options\n  }\n\n  const app = createApp(VcPrintView, printViewProps)\n  app.mount(printWindow.document.getElementById('print'))\n}\n\nexport default createPrintView\n"],"names":[],"mappings":";;;AAEA,MAAM,MAAM,GAAG,CAAC;AAChB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC,CAAC;AACG,MAAC,eAAe,GAAG,CAAC,OAAO,KAAK;AACrC,EAAE,MAAM,EAAE,WAAW,GAAG,MAAM,CAAC,IAAI,EAAE,EAAE,aAAa,EAAE,KAAK,EAAE,GAAG,OAAO,CAAC;AACxE,EAAE,IAAI,aAAa,EAAE;AACrB,IAAI,WAAW,CAAC,gBAAgB,CAAC,QAAQ,EAAE,MAAM;AACjD,MAAM,aAAa,CAAC,WAAW,CAAC,CAAC;AACjC,KAAK,CAAC,CAAC;AACP,GAAG;AACH,EAAE,WAAW,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC;AAC9B,EAAE,WAAW,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC;AAC/B,EAAE,WAAW,CAAC,QAAQ,CAAC,IAAI,CAAC,SAAS,GAAG,CAAC;AACzC;AACA,WAAW,EAAE,OAAO,CAAC,KAAK,CAAC;AAC3B,WAAW,EAAE,MAAM,CAAC;AACpB,IAAI,CAAC,CAAC;AACN,EAAE,WAAW,CAAC,QAAQ,CAAC,IAAI,CAAC,SAAS,GAAG,wBAAwB,CAAC;AACjE,EAAE,OAAO,CAAC,WAAW,GAAG,OAAO,CAAC,WAAW,IAAI,WAAW,CAAC;AAC3D,EAAE,MAAM,cAAc,GAAG;AACzB,IAAI,OAAO;AACX,GAAG,CAAC;AACJ,EAAE,MAAM,GAAG,GAAG,SAAS,CAAC,WAAW,EAAE,cAAc,CAAC,CAAC;AACrD,EAAE,GAAG,CAAC,KAAK,CAAC,WAAW,CAAC,QAAQ,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,CAAC;AAC1D;;;;"}