function mockChooseImage(){let e=wx.getFileSystemManager();if(!global.__minium__.mock_choose_image){let s=new Map,i=new Map;function t(){i.forEach((e=>{e()}))}global.__minium__.mock_choose_image=function(...a){const r=a.map((t=>{const{imageData:s,imageName:i,size:a}=t,r=`${wx.env.USER_DATA_PATH}/.MINIUM_TMP/${i}`;return s&&0!==s.length?new Promise(((t,a)=>{e.writeFile({filePath:r,data:s,encoding:"base64",success:()=>{e.stat({path:r,success:({stats:e})=>{t({imageName:i,filePath:r,size:e.size})}})},fail:({errMsg:e})=>{a("writeFile:fail the maximum size of the file storage limit is exceeded"===e?new Error("小程序文件空间不足"):"writeFile:fail sdcard not mounted"===e?new Error("sdcard未挂载"):new Error(`Mock失败: ${e}`))}})})):Promise.resolve({imageName:i,filePath:r,size:a})}));return Promise.all(r).then((e=>(function(e,a){if(s.get(e))return!1;s.set(e,!0);const r={chooseImage(e){t();const s={errMsg:"chooseImage:ok",tempFilePaths:a.map((e=>e.filePath)),tempFiles:a.map((e=>({path:e.filePath,size:e.size})))};return Promise.resolve(s)},chooseMedia(e){t();const s={errMsg:"chooseMedia:ok",tempFiles:a.map((e=>({tempFilePath:e.filePath,size:e.size,fileType:"image"}))),type:"image"};return Promise.resolve(s)},createCameraContext(){const i=this.origin(),r=i.takePhoto;return Object.defineProperty(i,"takePhoto",{configurable:!0,get:()=>function(i){if(!s.get(e))return r.call(this,i);t();const c={tempImagePath:a[0].filePath,errMsg:"takePhoto:ok"};i.success&&i.success(c),i.complete&&i.complete(c)}}),i}},c=Object.keys(r);i.set(e,(function(){s.get(e)&&(console.debug("release target"),s.set(e,!1),c.forEach((e=>{global.__minium__.delMock(e)})))})),c.forEach((e=>{global.__minium__.setMock(e,r[e])}))}(wx,e),e.map((e=>({name:e.imageName,size:e.size}))))))};let a=!1;e.mkdir({dirPath:`${wx.env.USER_DATA_PATH}/.MINIUM_STORE`,recursive:!1,success(){a=!0},fail:({errMsg:e})=>{e.indexOf("file already exists")>=0&&(a=!0)}});const r=e.saveFile,c=e.saveFileSync,o=e.getSavedFileList;Object.defineProperty(e,"saveFile",{configurable:!0,get:()=>function({tempFilePath:t,filePath:s,success:i,fail:a,complete:c}){if(t.startsWith(`${wx.env.USER_DATA_PATH}/.MINIUM_TMP`)){const r={srcPath:t,destPath:s||`${wx.env.USER_DATA_PATH}/.MINIUM_STORE/${t.split("/").pop()}`};return i&&(r.success=e=>{e.errMsg=e.errMsg.replace("copyFile","saveFile"),e.savedFilePath=r.destPath,i(e)}),a&&(r.fail=e=>{e.errMsg=e.errMsg.replace("copyFile","saveFile"),a(e)}),c&&(r.complete=e=>{e.errMsg=e.errMsg.replace("copyFile","saveFile"),0===e.errMsg.indexOf("saveFile:ok")&&(e.savedFilePath=r.destPath),c(e)}),e.copyFile(r)}return r({tempFilePath:t,filePath:s,success:i,fail:a,complete:c})}}),Object.defineProperty(e,"saveFileSync",{configurable:!0,get:()=>function(t,s){if(t.startsWith(`${wx.env.USER_DATA_PATH}/.MINIUM_TMP`)){const i=t,a=s||`${wx.env.USER_DATA_PATH}/.MINIUM_STORE/${t.split("/").pop()}`;try{return e.copyFileSync(i,a),a}catch(e){throw e.message.replace("copyFileSync","saveFileSync")}}return c(t,s)}}),Object.defineProperty(e,"getSavedFileList",{configurable:!0,get:()=>function({success:t,complete:s}){Promise.all([new Promise((t=>{e.stat({path:`${wx.env.USER_DATA_PATH}/.MINIUM_STORE/`,recursive:!0,complete:e=>{t((e.stats||[]).filter((e=>"/"!==e.path)).map((e=>({filePath:`${wx.env.USER_DATA_PATH}/.MINIUM_STORE/${e.path.startsWith("/")?e.path.slice(1):e.path}`,size:e.stats.size,createTime:e.stats.lastModifiedTime}))))}})})),new Promise((e=>{o({complete:t=>{e(t.fileList||[])}})}))]).then((([e,i])=>{const a={fileList:e.concat(i),errMsg:"getSavedFileList:ok"};t&&t(a),s&&s(a)}))}})}return new Promise(((t,s)=>{e.mkdir({dirPath:`${wx.env.USER_DATA_PATH}/.MINIUM_TMP`,recursive:!1,success(){t([])},fail:({errMsg:i})=>{i.indexOf("file already exists")>=0?e.stat({path:`${wx.env.USER_DATA_PATH}/.MINIUM_TMP/`,recursive:!0,success:e=>{if(console.warn("[debug]fs.stat success"),!e.stats.length)return t([]);t(e.stats.map((e=>({name:e.path.replace(/^\//,""),size:e.stats.size}))).filter((e=>e.name)))},fail:s}):s({errMsg:i})}})}))}
