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,GAAY,EAAI,KAAM,IAC5B,MAAO,GAAS,EAAI,EAAO,OAKvB,EAdC,IAgBT","file":"/npm/movie-trailer@3.2.3/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.48.0.\n * Original file: /npm/movie-trailer@3.2.3/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","/* global define */\n'use strict';\n\n( function ( root, cx ) {\n\n\tif ( typeof define === 'function' && define.amd ) {\n\n\t\t// AMD\n\t\tdefine( [ 'isomorphic-fetch' ], cx )\n\n\t} else if ( typeof exports === 'object' ) {\n\n\t\t// Node, CommonJS-like\n\t\tmodule.exports = cx( require( 'isomorphic-fetch' ) )\n\n\t} else {\n\n\t\t// Browser globals (root is window)\n\t\troot.movieTrailer = cx( root.fetch )\n\n\t}\n\n} )( this, fetch => {\n\n\tfunction handleErrors( error ) {\n\n\t\tconst message = ( error && error.message ) ? error.message : error\n\t\tconsole.warn( `movie-trailer: ${message}` )\n\t\t// Throw Error( error.message )\n\n\t}\n\n\tfunction handleFetchErrors( response ) {\n\n\t\tif ( !response.ok ) {\n\n\t\t\tthrow new Error( response.statusText )\n\n\t\t}\n\n\t\treturn response\n\n\t}\n\n\tfunction toUrl( videoId ) {\n\n\t\treturn encodeURI( 'https://www.youtube.com/watch?v=' + videoId )\n\n\t}\n\n\tfunction getMovieId( search, options ) {\n\n\t\t/* Fetch a Movie ID for querying the TMDB API */\n\t\tconst path = options && options.videoType === 'tv' ? '/3/search/tv?api_key=' : '/3/search/movie?api_key='\n\n\t\tconst endpoint = 'https://api.themoviedb.org' + encodeURI( path + options.apiKey + '&query=' + search + ( ( options.year === null ) ? '' : '&year=' + options.year ) + ( ( options.language === null ) ? '' : '&language=' + options.language ) )\n\t\tconst result = fetch( endpoint, {\n\t\t\tmethod: 'GET'\n\t\t} )\n\t\t\t.then( handleFetchErrors )\n\t\t\t.then( response => response.json() )\n\t\t\t.then( json => {\n\n\t\t\t\tif ( typeof json.status_message !== 'undefined' ) {\n\n\t\t\t\t\t// Error\n\t\t\t\t\tthrow new TypeError( json.status_message )\n\n\t\t\t\t} else if ( json.results.length === 0 ) {\n\n\t\t\t\t\t// Retry failed search without year\n\t\t\t\t\tif ( options.year !== null ) {\n\n\t\t\t\t\t\tconst { year, ...rest } = options\n\n\t\t\t\t\t\treturn getMovieId( search, rest )\n\n\t\t\t\t\t}\n\n\t\t\t\t\t// Error\n\t\t\t\t\tthrow new Error( `No TMDB Movie found with that search query, try searching https://www.themoviedb.org/search?query=${encodeURIComponent( search )} to verify one exists` )\n\n\t\t\t\t} else {\n\n\t\t\t\t\treturn json.results[0].id\n\n\t\t\t\t}\n\n\t\t\t} )\n\t\t\t.catch( error => {\n\n\t\t\t\thandleErrors( error )\n\n\t\t\t\treturn null\n\n\t\t\t} )\n\n\t\treturn result\n\n\t}\n\n\tfunction getTrailer( movieId, options ) {\n\n\t\tconst path = options && options.videoType === 'tv' ? '/3/tv/' : '/3/movie/'\n\n\t\t/* Fetch single or multiple movie trailers via the TMDB API */\n\t\tconst endpoint = 'https://api.themoviedb.org' + encodeURI( path + movieId + '/videos?api_key=' + options.apiKey + ( ( options.language === null ) ? '' : '&language=' + options.language ) )\n\t\tconst result = fetch( endpoint, {\n\t\t\tmethod: 'GET'\n\t\t} )\n\t\t\t.then( handleFetchErrors )\n\t\t\t.then( response => response.json() )\n\t\t\t.then( json => {\n\n\t\t\t\tif ( typeof ( json.status_message ) !== 'undefined' ) {\n\n\t\t\t\t\t// Error\n\t\t\t\t\tthrow new TypeError( `movie-trailer: ${json.status_message}` )\n\n\t\t\t\t}\n\n\t\t\t\tif ( json.results.length === 0 ) {\n\n\t\t\t\t\t// Error\n\t\t\t\t\tthrow new Error( 'No trailers found for that TMDB ID' )\n\n\t\t\t\t}\n\n\t\t\t\tlet { results } = json\n\n\t\t\t\t// Strip all but videoId\n\t\t\t\tresults = results.map( result => {\n\n\t\t\t\t\treturn result.key\n\n\t\t\t\t} )\n\n\t\t\t\tif ( !options.id ) {\n\n\t\t\t\t\t// Return Youtube videoId or full `Watch` URL\n\t\t\t\t\tresults = results.map( videoId => toUrl( videoId ) )\n\n\t\t\t\t}\n\n\t\t\t\treturn options.multi ? [ ...new Set( results ) ] : results[0]\n\n\t\t\t} )\n\t\t\t.catch( error => {\n\n\t\t\t\thandleErrors( error )\n\n\t\t\t\treturn null\n\n\t\t\t} )\n\n\t\treturn result\n\n\t}\n\n\tasync function movieTrailer( movie, options, cb, legacy ) {\n\n\t\t/* Fetch movie trailers */\n\n\t\t// Massage inputs\n\t\tlet config = {\n\t\t\tmulti: false,\n\t\t\tid: false,\n\t\t\tyear: null,\n\t\t\tlanguage: null,\n\t\t\tvideoType: 'movie', // Added videoType property\n\n\t\t\t// Public Key on purpose\n\t\t\tapiKey: '9d2bff12ed955c7f1f74b83187f188ae'\n\t\t}\n\n\t\tif ( !options ) {\n\n\t\t\toptions = {}\n\n\t\t}\n\n\t\tif ( typeof movie !== 'string' && !options.tmdbId ) {\n\n\t\t\tthrow new Error( 'Expected first parameter to be a movie or TMDB ID (string)' )\n\n\t\t} else if ( typeof options === 'function' ) {\n\n\t\t\t// Second parameter is the callback\n\t\t\tcb = options\n\t\t\toptions = null\n\n\t\t} else if ( typeof options === 'boolean' || options === 'true' ) {\n\n\t\t\t// Second parameter is multi\n\t\t\tconfig.multi = options\n\n\t\t} else if ( typeof options === 'string' || typeof options === 'number' ) {\n\n\t\t\t// Second parameter is year\n\t\t\tconfig.year = options\n\n\t\t\t/* BACKWARDS-COMPATABILITY FOR v1 */\n\t\t\tif ( typeof legacy === 'function' && ( typeof cb === 'boolean' || ( typeof cb === 'string' && cb === 'true' ) ) ) {\n\n\t\t\t\t// Third parameter is multi\n\t\t\t\tconfig.multi = cb\n\t\t\t\tcb = legacy\n\n\t\t\t}\n\t\t\t/* END BACKWARDS-COMPATABILITY */\n\n\t\t} else if ( typeof options === 'object' ) {\n\n\t\t\t// Set options\n\t\t\tconfig = Object.assign( config, options )\n\n\t\t}\n\n\t\t// Remove invalid callback\n\t\tif ( typeof cb !== 'function' ) {\n\n\t\t\tcb = null\n\n\t\t}\n\n\t\tconst movieId = config.tmdbId ? config.tmdbId : ( await getMovieId( movie, config )\n\t\t\t.catch( error => {\n\n\t\t\t\thandleErrors( error )\n\n\t\t\t\treturn null\n\n\t\t\t} ) )\n\n\t\t// Get the TMDB content ID\n\t\tif ( !movieId ) {\n\n\t\t\t// Failed\n\t\t\treturn null\n\n\t\t}\n\n\t\t// Get the trailers themselves\n\t\tconst result = getTrailer( movieId, config )\n\n\t\tif ( !result ) {\n\n\t\t\t// Failed\n\t\t\treturn null\n\n\t\t}\n\n\t\t// Call callback if supplied\n\t\tif ( cb ) {\n\n\t\t\treturn result\n\t\t\t\t.then( response => cb( null, response ) )\n\t\t\t\t.catch( error => cb( error, null ) )\n\n\t\t}\n\n\t\t// Return promise\n\t\treturn result\n\n\t}\n\n\t// Exposed public method\n\treturn movieTrailer\n\n} )\n"]}