exports.default=function(e,t,n,r,i){void 0===t&&(t=[{}]),void 0===n&&(n=null),void 0===r&&(r=!1),void 0===i&&(i=null);try{var o=function(r){function o(t){return!n&&i&&i(),Promise.resolve(t.createWritable()).then(function(n){var r;function i(i){if(r)return i;var o=n.write;return Promise.resolve(e).then(function(e){return Promise.resolve(o.call(n,e)).then(function(){return Promise.resolve(n.close()).then(function(){return t})})})}var o=function(){if("stream"in e){var i=e.stream();return Promise.resolve(i.pipeTo(n)).then(function(){return r=1,t})}return function(){if("body"in e)return Promise.resolve(e.body.pipeTo(n)).then(function(){return r=1,t})}()}();return o&&o.then?o.then(i):i(o)})}return n?o(n):Promise.resolve(window.showSaveFilePicker({suggestedName:t[0].fileName,id:t[0].id,startIn:t[0].startIn,types:c,excludeAcceptAllOption:t[0].excludeAcceptAllOption||!1})).then(o)};Array.isArray(t)||(t=[t]),t[0].fileName=t[0].fileName||"Untitled";var c=[],u=null;e instanceof Blob&&e.type?u=e.type:e.headers&&e.headers.get("content-type")&&(u=e.headers.get("content-type")),t.forEach(function(e,t){c[t]={description:e.description||"",accept:{}},e.mimeTypes?(0===t&&u&&e.mimeTypes.push(u),e.mimeTypes.map(function(n){c[t].accept[n]=e.extensions||[]})):u&&(c[t].accept[u]=e.extensions||[])});var s=function(){if(n)return function(e,t){try{var r=Promise.resolve(n.getFile()).then(function(){})}catch(e){return t(e)}return r&&r.then?r.then(void 0,t):r}(0,function(e){if(n=null,r)throw e})}();return Promise.resolve(s&&s.then?s.then(o):o())}catch(e){return Promise.reject(e)}};
