import{s as g}from"./base-00eb0fe9.js";import"./index-25eb6331.js";const p=(...e)=>{let n=null;for(let t of e)if(t){if(n===null){n=t;continue}n=n+"/"+t}return n===null?"":b(n)},$=(...e)=>U(p(...e)),b=e=>{let n="";e.indexOf("http://")===0?n="http://":e.indexOf("https://")===0&&(n="https://");for(let t=n.length;t<e.length-1;t++){let o=e.charAt(t),r=e.charAt(t+1);o==="/"&&r==="/"||(n+=o)}return n+=e.charAt(e.length-1),n},U=e=>{if(g(e))return"";let n="",t=-1;for(let o=0;o<e.length;o++){const r=e.charAt(o);if(r==="/"){if(t<o){let l=e.substring(t+1,o);n+=encodeURIComponent(l),t=o}n+=r}if(o===e.length-1&&t<o){let l=e.substring(t+1,o+1);n+=encodeURIComponent(l)}}return n};function w(e,n){var c;const t=e.name,o=e.url;if(!n||!o||!t)return console.error("构建 kkFileView URL 失败：缺少必要参数。"),null;const r=t.lastIndexOf("."),l=r!==-1?t.substring(r):"";let s;typeof((c=window.crypto)==null?void 0:c.randomUUID)=="function"?s=window.crypto.randomUUID():s=Date.now().toString(36)+Math.random().toString(36).substring(2);const i="".concat(s).concat(l),a=o.includes("?")?"&":"?",u="".concat(o).concat(a,"fullfilename=").concat(i),f=new TextEncoder().encode(u),d=String.fromCharCode(...f),m=btoa(d),h=encodeURIComponent(m);return"".concat(n,"/onlinePreview?url=").concat(h)}const A=e=>{if(!e)return"/share";try{return"/share/".concat(encodeURIComponent(e))}catch(n){return"/share/".concat(e)}};export{w as a,A as b,p as c,$ as d,b as r};
