import"./rolldown-runtime-BM3Ffeng.js";import{r as e}from"./element-plus-vendor-BF9PNysW.js";import{n as t}from"./index-kSn5YXd0.js";var n=`42007`,r=null,i=null,a=async(e,t)=>{if(!e||typeof e!=`object`)return e;let n={...e};return await Promise.all(t.map(async e=>{let t=l(n,e);typeof t!=`string`||t.length===0||u(n,e,await s(t))})),n},o=async(e,o)=>{let s=await a(e.data,o),l=c(s,o);return t({...e,data:s,config:l?{...e.config,showDefaultMsg:!1}:e.config}).catch(a=>l&&d(a)===n?(r=null,i=null,t(e)):(l&&e.config?.showDefaultMsg!==!1&&p(a),Promise.reject(a)))},s=async e=>{try{if(!window.crypto?.subtle)return e;let t=await m();if(e.startsWith(t.encryptPrefix))return e;let n=await h(t),r=await window.crypto.subtle.encrypt({name:`RSA-OAEP`},n,new TextEncoder().encode(e));return t.encryptPrefix+_(r)}catch{return e}},c=(e,t)=>{if(!e||typeof e!=`object`)return!1;let n=e;return t.some(e=>{let t=l(n,e);return typeof t==`string`&&t.startsWith(`ZFILE_RSA_PASSWORD_V1:`)})},l=(e,t)=>t.split(`.`).reduce((e,t)=>{if(!(!e||typeof e!=`object`))return e[t]},e),u=(e,t,n)=>{let r=t.split(`.`),i=e;r.forEach((e,t)=>{if(t===r.length-1){i[e]=n;return}let a=i[e],o=a&&typeof a==`object`?{...a}:{};i[e]=o,i=o})},d=e=>{let t=e;return t?.data?.code||t?.response?.data?.code||``},f=e=>{let t=e;return t?.data?.msg||t?.response?.data?.msg||`请求失败，请联系管理员`},p=t=>{e({type:`error`,grouping:!0,message:f(t)})},m=async()=>(r||=t({url:`/user/login/password-public-key`,method:`get`,config:{responseIntercept:!0}}).then(e=>e.data),r),h=e=>(i||=window.crypto.subtle.importKey(`spki`,g(e.publicKey),{name:`RSA-OAEP`,hash:`SHA-256`},!1,[`encrypt`]),i),g=e=>{let t=window.atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e+=1)n[e]=t.charCodeAt(e);return n.buffer},_=e=>{let t=new Uint8Array(e),n=``;for(let e=0;e<t.byteLength;e+=1)n+=String.fromCharCode(t[e]);return window.btoa(n)};export{o as t};