const m=t=>Math.floor(Math.random()*(9*Math.pow(10,t-1)))+Math.pow(10,t-1),g={jpg:"image/jpg",jpeg:"image/jpeg",pjpeg:"image/pjpeg",png:"image/png",apng:"image/apng","x-png":"image/x-png",gif:"image/gif",webm:"video/webm",mp4:"video/mp4"},f=t=>!t||t.type.includes("svg")?!1:t.type?t.type.split("/")[0]==="image":!1,x=(t,e,a)=>t.toBlob?new Promise(n=>{t.toBlob(n,e,a)}):Promise.resolve().then(()=>globalThis.dataURItoBlob(t.toDataURL(e,a),{})),u=t=>{const a=/(?:\.([^.]+))?$/.exec(t)[1];return{name:t.replace(`.${a}`,""),extension:a}},d=t=>{let e=t.name?u(t.name).extension:null;return e=e?e.toLowerCase():null,t.type?t.type:e&&g[e]?g[e]:null},h=()=>m(10),b=(t,e="")=>{const a=["Bytes","KB","MB","GB","TB"];if(t===0)return"n/a";const n=parseInt(Math.floor(Math.log(t)/Math.log(1024)),10);return n===0?`${t}${e}${a[n]}`:`${+(t/1024**n).toFixed(1)}${e}${a[n]}`},F=t=>t?/image\//.test(t)?"img":/video\//.test(t)?"video":null:null,M=(t,e,a)=>{const n=e==="video"?t.videoWidth:t.naturalWidth,o=e==="video"?t.videoHeight:t.naturalHeight,s=(n/o).toFixed(2),p=a?(a.minWidth/a.minHeight).toFixed(2):null,r=s===p,i=n>=1600&&o>=1200,c=n<1600||o<1200;return{width:n,height:o,orientation:n>o?"landscape":"portrait",optimal:i,optimalExactRatio:i&&r,subOptimal:c,subOptimalExactRatio:c&&r,ratio:s}},j=(t,e)=>{if(/image\/gif/.test(t)===!1)return!1;const a=atob(e.replace("data:image/gif;base64,",""));let n=0;return a.replace(/\x00\x21\xF9\x04.{0,4}\x00[\x2c\x21]/g,()=>{n+=1}),n>1},l=(()=>{if(typeof document>"u")return"";const t=document.querySelector('meta[name="csrf-token"]');return t&&t.getAttribute("content")||""})(),w=t=>(t.response&&t.response.data&&t.response.data.errors&&t.response.data.errors[0]?t.response.data.errors[0]:{}).detail||"Something went wrong, please try again.",E=t=>{const e={headers:{"X-Requested-With":"XMLHttpRequest","X-CSRF-Token":l}};return t&&(e.cancelToken=t.token),e},R=(t,e)=>{const a=new FormData;return Object.keys(e).forEach(n=>{a.append(n,e[n])}),a.append("Content-Type",d(t)),a.append("file",t),a},v=t=>{const e=new FormData(t);return Object.keys(e).forEach(a=>{e.append(a,e[a])}),e};export{E as a,v as b,b as c,R as d,u as e,h as f,d as g,F as h,M as i,j,x as k,f as l,w as m,m as r}; //# sourceMappingURL=axios_helper-aabbd1f9.js.map