/* Uploaded from https://github.com/WPAFC/afch-rewrite, commit: a6f9ad227ef773dfd4530711ba002b21d472d6b3 (master) */
//<nowiki>
( function ( $, mw ) {
	var subscriptToLoad = false,
		pageName = mw.config.get( 'wgPageName' ).replace( /_/g, ' ' ),

		// `loadMap` determines which scripts should be loaded
		// on each page. Each key is a subscript name and
		// its value is a list of page prefixes on which it
		// should be loaded.

		loadMap = {
			// `submissions.js` is for reviewing textual
			// लेख सृजना निवेदनहरू
			submissions: [
				'विकिपिडिया:लेख सृजना/',
				'विकिपिडिया वार्ता:लेख सृजना/',
				'User:',
				'Draft:'
			]
		};

	$.each( loadMap, function ( script, prefixes ) {
		$.each( prefixes, function ( _, prefix ) {
			if ( pageName.indexOf( prefix ) === 0 ) {
				subscriptToLoad = script;
				return false;
			}
		} );

		// Return false and break out of the loop if already found
		return !!subscriptToLoad;
	} );

	if ( subscriptToLoad ) {
		// Initialize the AFCH object
		window.AFCH = {};

		// Set up constants
		AFCH.consts = {};

		// Master version data
		AFCH.consts.version = '0.9.1';
		AFCH.consts.versionName = 'इम्पीरियल आइबेक्स';

		// FIXME: Change when moving into production
		AFCH.consts.beta = true;

		AFCH.consts.scriptpath = mw.config.get( 'wgServer' ) + mw.config.get( 'wgScript' );
		AFCH.consts.baseurl = AFCH.consts.scriptpath +
			'?action=raw&ctype=text/javascript&title=User:Pitambar Bhattarai/afch-master.js';

		$.getScript( AFCH.consts.baseurl + '/core.js' ).done( function () {
			var loaded = AFCH.load( subscriptToLoad );
			if ( !loaded ) {
				mw.notify( 'लोड हुन सकेन: ' + ( AFCH.error || 'अज्ञात त्रुटि' ),
					{ title: 'एएफसीएइच त्रुटि' } );
			}
		} );
	}
}( jQuery, mediaWiki ) );
//</nowiki>