"use strict";var h=Object.create;var n=Object.defineProperty;var x=Object.getOwnPropertyDescriptor;var d=Object.getOwnPropertyNames;var L=Object.getPrototypeOf;var S=Object.prototype.hasOwnProperty;var o=(r,t)=>n(r,"name",{value:t,configurable:true});var A=(r,t)=>{for(var e in t)n(r,e,{get:t[e],enumerable:true})};var c=(r,t,e,a)=>{if(t&&typeof t==="object"||typeof t==="function"){for(let l of d(t))if(!S.call(r,l)&&l!==e)n(r,l,{get:()=>t[l],enumerable:!(a=x(t,l))||a.enumerable})}return r};var R=(r,t,e)=>(e=r!=null?h(L(r)):{},c(t||!r||!r.__esModule?n(e,"default",{value:r,enumerable:true}):e,r));var O=r=>c(n({},"__esModule",{value:true}),r);var E={};A(E,{fixUrl:()=>U,isValidExternalURL:()=>u,isValidFileUrl:()=>W,normalizedUrl:()=>y,openExternalUrl:()=>w,openPath:()=>b});module.exports=O(E);var s=require("node:url");var p=require("electron");var i=require("fs-extra");var m=R(require("normalize-url"));var g=require("../config");const f=require("../preload-safe-debug")("Ferdium:Helpers:url");const u=o(r=>{let t;try{t=new s.URL(r.toString())}catch{return false}const e=g.ALLOWED_PROTOCOLS.includes(t.protocol);f("protocol check is",e,"for:",r);return e},"isValidExternalURL");const U=o(r=>{return r.toString().replaceAll("//","/").replaceAll("http:/","http://").replaceAll("https:/","https://").replaceAll("file:/","file://")},"fixUrl");const W=o(r=>{return r.startsWith("file")&&(0,i.existsSync)(new s.URL(r))},"isValidFileUrl");async function b(r){(0,i.ensureDirSync)(r);p.shell.openPath(r)}o(b,"openPath");const w=o((r,t=false)=>{const e=U(r.toString());f("Open url:",e,"with skipValidityCheck:",t);if(t||u(e)){p.shell.openExternal(e.toString())}},"openExternalUrl");const y=o(r=>{return(0,m.default)(r,{stripAuthentication:false,stripWWW:false,removeTrailingSlash:false})},"normalizedUrl");
