import{n as a}from"./chunk-2HZMOK4U.js";import{d as o}from"./chunk-ELIH6GCC.js";import{g as u}from"./chunk-VKWPEFWQ.js";u();var n={LOCALHOST:"localhost",HTTP:"http",PUBSUB:"google-pub-sub",EVENTBRIDGE:"event-bridge"},p={LOCALHOST:new RegExp("^http:","i"),HTTP:new RegExp("^https:","i"),PUBSUB:new RegExp("^pubsub:"),EVENTBRIDGE:new RegExp("^arn:aws:events:")};function c(t,e){let r=h(t);return r===n.LOCALHOST&&e===n.HTTP?!0:r===e}function f(t){return p.LOCALHOST.test(t)?new URL(t.toLowerCase()).hostname==="localhost":!1}function E(t,e){if(!c(t,e))throw new o(`Can't deliver your webhook payload to this address using '${e}'`,"Use a valid URL for address",l(e));let r=e;return f(t)&&(r=n.LOCALHOST),[t.trim(),r]}function l(t){return t===n.HTTP?["For remote HTTP testing, use a URL that starts with https://","For local HTTP testing, use http://localhost:{port}/{url-path}"]:t===n.PUBSUB?["For Google Pub/Sub, use pubsub://{project-id}:{topic-id}"]:t===n.EVENTBRIDGE?["For Amazon EventBridge, use an Amazon Resource Name (ARN) starting with arn:aws:events:"]:[]}function g(t,e){if(e.includes(t))return t;throw new o(`Api Version '${t}' does not exist`,`Allowed values: ${e.join(", ")}`,["Try again with a valid api-version value"])}function L(t,e,r){if(r.length===0)throw new o(`No topics found for '${e}'`);let i=T(t.trim(),r);if(i===void 0)throw new o(`Topic '${t}' does not exist for ApiVersion '${e}'`,`Allowed values: ${r.join(", ")}`,["Try again with a valid api-version - topic pair"]);return i}function T(t,e){return e.includes(t)?t:e.find(r=>r.toUpperCase().replace("/","_")===t)}function h(t){if(t){if(t.startsWith("pubsub:"))return n.PUBSUB;if(t.startsWith("arn:aws:events:"))return n.EVENTBRIDGE;if(f(t))return n.LOCALHOST;if(p.HTTP.test(t))return n.HTTP}}u();async function H(t,e,r){let i={method:"POST",body:e,headers:{"Content-Type":"application/json",...JSON.parse(r)}},s=await a(t,i);return s.status>=200&&s.status<300}export{H as a,n as b,c,E as d,g as e,L as f,h as g};
