import{j as e,y as t,z as n,A as i,B as r}from"./index-Bu3F9tAw.js";const o="mingdao_guide_registration_state";function a(){return n(o)||null}function d(t){return e({url:"/guide/registration/sms-code",method:"POST",authenticated:!1,data:{phone:t}})}function s(n,i){return e({url:"/guide/registration/verify-phone",method:"POST",authenticated:!1,data:{phone:n,code:i}}).then(e=>{const i={phone:n,...e};return t(o,i),i})}function u(){return e({url:"/guide/registration/teams",authenticated:!1})}function c(e,t){return function(e){if(!e)return Promise.resolve(e);if("function"!=typeof uni.compressImage)return g(e);return new Promise(t=>{uni.compressImage({src:e,quality:60,compressedWidth:1280,success:n=>t(n&&n.tempFilePath?n.tempFilePath:e),fail:()=>g(e).then(t)})})}(e).then(e=>i({url:"/guide/registration/documents",filePath:e,header:{"X-Registration-Token":t}})).then(e=>e.url)}function g(e){return"undefined"==typeof window||"function"!=typeof window.fetch||"function"!=typeof window.Image?Promise.resolve(e):window.fetch(e).then(e=>e.blob()).then(t=>new Promise(n=>{const i=new window.Image,r=window.URL.createObjectURL(t);i.onload=()=>{const t=Math.min(1,1280/i.width),o=document.createElement("canvas");o.width=Math.max(1,Math.round(i.width*t)),o.height=Math.max(1,Math.round(i.height*t)),o.getContext("2d").drawImage(i,0,0,o.width,o.height),o.toBlob(t=>{window.URL.revokeObjectURL(r),n(t?window.URL.createObjectURL(t):e)},"image/jpeg",.6)},i.onerror=()=>{window.URL.revokeObjectURL(r),n(e)},i.src=r})).catch(()=>e)}function h(t){const n=a();if(!n||!n.registrationToken)return Promise.reject(new Error("手机号验证已失效,请重新验证"));const i=[c(t.idFront,n.registrationToken),c(t.idBack,n.registrationToken),c(t.guideLicense,n.registrationToken),t.guideCert?c(t.guideCert,n.registrationToken):Promise.resolve("")];return Promise.all(i).then(([i,r,o,a])=>e({url:"/guide/registration/applications",method:"POST",authenticated:!1,data:{realName:t.name,gender:"男"===t.gender?1:2,ageRange:t.age,workYearRange:t.workYear,guideType:t.guideType,teamId:t.teamId,idCardNo:t.idNo,idCardFrontUrl:i,idCardBackUrl:r,guideCertificateUrl:o,qualificationCertificateUrl:a},headers:{"X-Registration-Token":n.registrationToken}})).then(e=>(r(o),e))}export{h as a,u as b,a as g,d as s,s as v};