(function(global, factory) { typeof exports === "object" && typeof module !== "undefined" ? factory(exports) : typeof define === "function" && define.amd ? define(["exports"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global.oembed = {})); })(this, function(exports2) { "use strict"; var _a; const D = (e2) => { try { return !!new URL(e2); } catch { return false; } }, s$2 = /^(?:(?:https?):)?(?:\/\/)?(?:www\.)?(?:youtube(?:-nocookie)?.com|youtu.be)(?:\/watch\?v)?[=/]([a-zA-Z0-9_-]{11})(?:\\?|=|&|$)/, U = (e2) => { var r2; return e2 ? ((r2 = e2.match(s$2)) == null ? void 0 : r2[1]) ?? "" : ""; }, w = (e2) => `https://www.youtube.com/embed/${e2}`, f$2 = { /** @inheritdoc */ name: "YouTube", /** * Determines if a given URL is recognized as a YouTube link. * * @param url - The string to evaluate. * @returns `true` if the URL matches YouTube patterns; otherwise `false`. */ canParseUrl(e2) { return s$2.test(e2); }, /** * Extracts the 11-char YouTube ID from a recognized YouTube URL. * * @param url - The potential YouTube link. * @returns The extracted video ID or an empty string if none found. */ getIdFromUrl(e2) { return U(e2); }, /** * Builds a full YouTube embed URL (e.g. `https://www.youtube.com/embed/`). * * @param id - The 11-char YouTube video ID. * @returns A fully embeddable ` `; } /** * Computes dimension info for a recognized provider, possibly using specialized defaults * (e.g. Vimeo default is 640x268, EdPuzzle 470x404, etc.). * * @param providerObj - The object with `.name` for the matched provider, if any. * @returns A `Dimensions` object with `width`, `height`, and optional unit-converted fields. */ getDefaultDimensions(providerObj) { const providerName = providerObj == null ? void 0 : providerObj.name; switch (providerName) { case "Vimeo": return this.calculateDefaultDimensions({ defaults: exports2.OEmbedElement.vimeoDefaultDimensions }); case "DailyMotion": return this.calculateDefaultDimensions(); case "EdPuzzle": return this.calculateDefaultDimensions({ defaults: exports2.OEmbedElement.edPuzzleDefaultDimensions }); case "Wistia": return this.calculateDefaultDimensions({ defaults: exports2.OEmbedElement.wistiaDefaultDimensions }); case "Loom": return this.calculateDefaultDimensions({ defaults: exports2.OEmbedElement.loomDefaultDimensions }); case "Spotify": return this.calculateDefaultDimensions({ defaults: exports2.OEmbedElement.spotifyDefaultDimensions }); default: return this.calculateDefaultDimensions(); } } /** * A helper that finalizes width & height, adding `px` if no unit is present. * * @param options - Optional `defaults` object specifying fallback width/height. * @returns A new `Dimensions` object with `widthWithUnits` and `heightWithUnits`. */ calculateDefaultDimensions({ defaults } = {}) { const width = this.getAttribute("width") || (defaults == null ? void 0 : defaults.width) || this.width; const widthWithUnits = width.match(/(px|%)/) ? width : `${width}px`; const height = this.getAttribute("height") || (defaults == null ? void 0 : defaults.height) || this.height; const heightWithUnits = height.match(/(px|%)/) ? height : `${height}px`; return { width, widthWithUnits, height, heightWithUnits }; } /** * Renders a DailyMotion ` `; } /** * Renders a Vimeo ` `; } /** * Renders a YouTube ` `; } /** * Renders a generic ` `; } /** * Renders an EdPuzzle ` `; } /** * Renders a Wistia ` `; } /** * Renders a Loom ` `; } /** * Helper function to decide if `allowfullscreen="true"` should be set. * * @returns `true` if the user supplied `allowfullscreen` as `""`, `"true"`, `true`, or `"1"`; * otherwise `undefined`. */ shouldAllowFullscreen() { return this.allowfullscreen === "" || this.allowfullscreen === "true" || this.allowfullscreen === true || this.allowfullscreen === "1" ? true : void 0; } }; exports2.OEmbedElement.spotifyDefaultDimensions = { height: "352", heightWithUnits: "352px" }; exports2.OEmbedElement.vimeoDefaultDimensions = { width: "640", widthWithUnits: "640px", height: "268", heightWithUnits: "268px" }; exports2.OEmbedElement.edPuzzleDefaultDimensions = { width: "470", widthWithUnits: "470px", height: "404", heightWithUnits: "404px" }; exports2.OEmbedElement.wistiaDefaultDimensions = { width: "470", widthWithUnits: "470px", height: "404", heightWithUnits: "404px" }; exports2.OEmbedElement.loomDefaultDimensions = { width: "470", widthWithUnits: "470px", height: "404", heightWithUnits: "404px" }; __decorateClass([ n({ type: String }) ], exports2.OEmbedElement.prototype, "url", 2); __decorateClass([ n({ type: String }) ], exports2.OEmbedElement.prototype, "width", 2); __decorateClass([ n({ type: String }) ], exports2.OEmbedElement.prototype, "height", 2); __decorateClass([ n({ type: String }) ], exports2.OEmbedElement.prototype, "frameborder", 2); __decorateClass([ n({ type: String }) ], exports2.OEmbedElement.prototype, "allowfullscreen", 2); exports2.OEmbedElement = __decorateClass([ t("o-embed") ], exports2.OEmbedElement); Object.defineProperty(exports2, Symbol.toStringTag, { value: "Module" }); });