var __awaiter=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))(function(o,r){function a(e){try{u(n.next(e))}catch(e){r(e)}}function c(e){try{u(n.throw(e))}catch(e){r(e)}}function u(e){var t;e.done?o(e.value):((t=e.value)instanceof i?t:new i(function(e){e(t)})).then(a,c)}u((n=n.apply(e,t||[])).next())})};import{widgetTypes as e}from"../index";import{Util as t}from"@openremote/core";export class WidgetService{static getManifest(t){let i=e.get(t);if(!i)throw Error(`Widget manifest could not be found during widget creation. [ID=${t}]`);return i}static placeNew(e,i,n){return __awaiter(this,void 0,void 0,function*(){let o=t.generateUniqueUUID(),r=this.getManifest(e);return{id:o,displayName:r.displayName,gridItem:{id:o,x:i,y:n,w:2,h:2,minW:r.minColumnWidth,minH:r.minColumnHeight,minPixelW:r.minPixelWidth,minPixelH:r.minPixelHeight,noResize:!1,noMove:!1,locked:!1},widgetConfig:r.getDefaultConfig(),widgetTypeId:e}})}static correctToConfigSpec(e,i){let n=t.mergeObjects(e.getDefaultConfig(),i,!1);return t.objectsEqual(n,i)?i:n}}