import invoker,{Container_Type_Enum}from"./invoker";var TASK_COMPLETE=1;function downloadFile(e){return invoker.invoke("downloadFile",e)}invoker.registerAPI("downloadFile",{mini:function(e,n){var i=n.resolve,o=n.reject,r=n.containerType,t=n.context;if(r===Container_Type_Enum.isDingTalk){t&&t({m:"taurus.common.downloadFile",args:e,onSuccess:function(e){invoker.handleBridgeResponse(e,i,o)},onFail:function(e){invoker.handleBridgeResponse(e,i,o)}})}else t&&t.call("downloadFile",e,(function(e){e.error?o(e):i(e)}))},pc:function(e,n){window.dingtalk.platform.invokeAPI(n.msgId,"biz.util.downloadFile",e),invoker.registerContinuesEvent(n.msgId,(function(i,o){"im.fileTask.addNewTask"===i&&(invoker.removeContinuesEvent(n.msgId),invoker.registerContinuesEvent(o.taskId,(function(n,i){if("im.fileTask.updateTask"===n){var o=i.doneSize,r=i.fileName,t=i.filePath,a=i.fileSize,l=i.speed;e.onProgress({doneSize:o,fileName:r,filePath:t,fileSize:a,speed:l}),i.status===TASK_COMPLETE&&invoker.removeContinuesEvent(i.taskId)}})))}))}}),downloadFile.version={pc:"1.3.5"};export default downloadFile;