2 lines
No EOL
4.9 KiB
JavaScript
2 lines
No EOL
4.9 KiB
JavaScript
/*! For license information please see index.js.LICENSE.txt */
|
|
(()=>{var e={92868:function(e,t,n){var r,o=o||function(e){"use strict";if("undefined"==typeof navigator||!/MSIE [1-9]\./.test(navigator.userAgent)){var t=e.document,n=function(){return e.URL||e.webkitURL||e},r=t.createElementNS("http://www.w3.org/1999/xhtml","a"),o="download"in r,a=/Version\/[\d\.]+.*Safari/.test(navigator.userAgent),i=e.webkitRequestFileSystem,c=e.requestFileSystem||i||e.mozRequestFileSystem,u=function(t){(e.setImmediate||e.setTimeout)((function(){throw t}),0)},l="application/octet-stream",d=0,s=function(e){setTimeout((function(){"string"==typeof e?n().revokeObjectURL(e):e.remove()}),4e4)},f=function(e,t,n){for(var r=(t=[].concat(t)).length;r--;){var o=e["on"+t[r]];if("function"==typeof o)try{o.call(e,n||e)}catch(e){u(e)}}},p=function(e){return/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(e.type)?new Blob(["\ufeff",e],{type:e.type}):e},v=function(t,u,v){v||(t=p(t));var w,y,m,g=this,S=t.type,h=!1,b=function(){f(g,"writestart progress write writeend".split(" "))},O=function(){if(y&&a&&"undefined"!=typeof FileReader){var r=new FileReader;return r.onloadend=function(){var e=r.result;y.location.href="data:attachment/file"+e.slice(e.search(/[,;]/)),g.readyState=g.DONE,b()},r.readAsDataURL(t),void(g.readyState=g.INIT)}!h&&w||(w=n().createObjectURL(t)),y?y.location.href=w:void 0===e.open(w,"_blank")&&a&&(e.location.href=w),g.readyState=g.DONE,b(),s(w)},R=function(e){return function(){if(g.readyState!==g.DONE)return e.apply(this,arguments)}},E={create:!0,exclusive:!1};if(g.readyState=g.INIT,u||(u="download"),o)return w=n().createObjectURL(t),void setTimeout((function(){var e,t;r.href=w,r.download=u,e=r,t=new MouseEvent("click"),e.dispatchEvent(t),b(),s(w),g.readyState=g.DONE}));e.chrome&&S&&S!==l&&(m=t.slice||t.webkitSlice,t=m.call(t,0,t.size,l),h=!0),i&&"download"!==u&&(u+=".download"),(S===l||i)&&(y=e),c?(d+=t.size,c(e.TEMPORARY,d,R((function(e){e.root.getDirectory("saved",E,R((function(e){var n=function(){e.getFile(u,E,R((function(e){e.createWriter(R((function(n){n.onwriteend=function(t){y.location.href=e.toURL(),g.readyState=g.DONE,f(g,"writeend",t),s(e)},n.onerror=function(){var e=n.error;e.code!==e.ABORT_ERR&&O()},"writestart progress write abort".split(" ").forEach((function(e){n["on"+e]=g["on"+e]})),n.write(t),g.abort=function(){n.abort(),g.readyState=g.DONE},g.readyState=g.WRITING})),O)})),O)};e.getFile(u,{create:!1},R((function(e){e.remove(),n()})),R((function(e){e.code===e.NOT_FOUND_ERR?n():O()})))})),O)})),O)):O()},w=v.prototype;return"undefined"!=typeof navigator&&navigator.msSaveOrOpenBlob?function(e,t,n){return n||(e=p(e)),navigator.msSaveOrOpenBlob(e,t||"download")}:(w.abort=function(){var e=this;e.readyState=e.DONE,f(e,"abort")},w.readyState=w.INIT=0,w.WRITING=1,w.DONE=2,w.error=w.onwritestart=w.onprogress=w.onwrite=w.onabort=w.onerror=w.onwriteend=null,function(e,t,n){return new v(e,t,n)})}}("undefined"!=typeof self&&self||"undefined"!=typeof window&&window||this.content);e.exports?e.exports.saveAs=o:null!==n.amdD&&null!==n.amdO&&(void 0===(r=function(){return o}.apply(t,[]))||(e.exports=r))}},t={};function n(r){var o=t[r];if(void 0!==o)return o.exports;var a=t[r]={exports:{}};return e[r].call(a.exports,a,a.exports,n),a.exports}n.amdD=function(){throw new Error("define cannot be used indirect")},n.amdO={},n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var r={};(()=>{"use strict";n.r(r),n.d(r,{downloadCSVFile:()=>d,generateCSVDataFromTable:()=>u,generateCSVFileName:()=>l});const e=window.moment;var t=n.n(e),o=n(92868);function a(e){let t=e.toString();return["=","+","-","@",String.fromCharCode(9),String.fromCharCode(13)].includes(t.charAt(0))?t="\"'"+t+'"':t.match(/[,"\s]/)&&(t='"'+t.replace(/"/g,'""')+'"'),t}function i(e){return Array.isArray(e)?e.map((e=>a(e.label))).join(","):[]}function c(e){return Array.isArray(e)?e.map((e=>e.map((e=>void 0===e.value||null===e.value?"":a(e.value))).join(","))).join("\n"):[]}function u(e,t){return[i(e),c(t)].filter((e=>e.length)).join("\n")}function l(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const r=[e.toLowerCase().replace(/[^a-z0-9]/g,"-"),t()().format("YYYY-MM-DD"),Object.keys(n).map((e=>e.toLowerCase().replace(/[^a-z0-9]/g,"-")+"-"+decodeURIComponent(n[e]).toLowerCase().replace(/[^a-z0-9]/g,"-"))).join("_")].filter((e=>e.length));return r.join("_")+".csv"}function d(e,t){const n=new Blob([t],{type:"text/csv;charset=utf-8"});(0,o.saveAs)(n,e)}})(),(window.wc=window.wc||{}).csvExport=r})(); |