text: import { LocalizationMixin } from './localization-mixin';
  import page from 'page';
  import { RtlMixin } from '@brightspace-ui/core/mixins/rtl-mixin';
  
  export const BaseMixin = superclass => class extends RtlMixin(LocalizationMixin(superclass)) {
  
  	// This navigation method is for use with the custom client-side router that
  	// doesn't support proper URL changes
  	fireNavigationEvent(pageData) {
  		const event = new CustomEvent('d2l-cpd-navigate', {
  			bubbles: true,
  			composed: true,
  			detail: {
  				pageData
  			}
  		});
  		this.dispatchEvent(event);
  	}
  
  	// This navigation method is for use with the client-side router that
  	// supports proper URL changes
  	navigateTo(pathname = '', state, title) {
  		// Set title before triggering page.js route change since page.js reads
  		// the current title
  		if (title && title !== window.document.title) {
  			window.document.title = title;
  		}
  
  		page(pathname, state);
  	}
  
  	lowercasePropertyNames(obj) {
  		const newObj = Array.isArray(obj) ? [] : {};
  		Object.keys(obj).forEach(key => {
  			if (obj[key] !== null && typeof obj[key] === 'object') {
  				newObj[key.toLowerCase()] = this.lowercasePropertyNames(obj[key]);
  			}
  			else {
  				newObj[key.toLowerCase()] = obj[key];
  			}
  		});
  		return newObj;
  	}
  
  };
  