mirror of
				https://github.com/lingble/chatwoot.git
				synced 2025-11-03 20:48:07 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			20 lines
		
	
	
		
			462 B
		
	
	
	
		
			JavaScript
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			20 lines
		
	
	
		
			462 B
		
	
	
	
		
			JavaScript
		
	
	
		
			Executable File
		
	
	
	
	
export const isEmptyObject = obj =>
 | 
						|
  Object.keys(obj).length === 0 && obj.constructor === Object;
 | 
						|
 | 
						|
export const arrayToHashById = array =>
 | 
						|
  array.reduce((map, obj) => {
 | 
						|
    const newMap = map;
 | 
						|
    newMap[obj.id] = obj;
 | 
						|
    return newMap;
 | 
						|
  }, {});
 | 
						|
 | 
						|
export const IFrameHelper = {
 | 
						|
  isIFrame: () => window.self !== window.top,
 | 
						|
  sendMessage: msg => {
 | 
						|
    window.parent.postMessage(
 | 
						|
      `chatwoot-widget:${JSON.stringify({ ...msg })}`,
 | 
						|
      '*'
 | 
						|
    );
 | 
						|
  },
 | 
						|
};
 |