UNPKG

@supernovaio/supernova-sdk

Version:
1 lines 276 kB
(()=>{"use strict";var e={2492(e,t,n){var o=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))(function(r,i){function s(e){try{l(o.next(e))}catch(e){i(e)}}function a(e){try{l(o.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}l((o=o.apply(e,t||[])).next())})};Object.defineProperty(t,"__esModule",{value:!0}),t.Brand=void 0;const r=n(6755),i=n(9929);t.Brand=class{constructor(e,t,n){this.engine=e,this.id=t.id,this.persistentId=t.persistentId,this.designSystemVersion=n,this.name=t.meta.name,this.description=t.meta.description,this.dataCore=n.dataCore}writer(){return new r.BrandWriter(this.engine,this)}tokens(e){return o(this,void 0,void 0,function*(){return(yield this.dataCore.currentDesignSystemTokens(this.designSystemVersion.designSystem.id,this.designSystemVersion,e)).filter(e=>e.brandId===this.persistentId)})}tokensByApplyingThemes(e){return o(this,void 0,void 0,function*(){let t=yield this.tokens(),n=yield this.themes();const o=new Map(n.map(e=>[e.id,e])),r=e.map(e=>{const t=o.get(e);if(!t)throw new Error(`Theme with id ${e} not found`);return t});return i.TokenUtils.tokensByApplyingThemes(t,r)})}themes(){return o(this,void 0,void 0,function*(){return(yield this.dataCore.currentDesignSystemThemes(this.designSystemVersion.designSystem.id,this.designSystemVersion)).filter(e=>e.brandId===this.persistentId)})}tokenGroups(){return o(this,void 0,void 0,function*(){return(yield this.dataCore.currentDesignSystemTokenGroups(this.designSystemVersion.designSystem.id,this.designSystemVersion)).filter(e=>e.brandId===this.persistentId)})}tokenGroupTrees(){return o(this,void 0,void 0,function*(){let e=(yield this.dataCore.currentDesignSystemTokenGroups(this.designSystemVersion.designSystem.id,this.designSystemVersion)).filter(e=>e.isRoot&&e.brandId===this.persistentId),t=new Map;for(let n of e)t.set(n.tokenType,n);return t})}components(){return o(this,void 0,void 0,function*(){return(yield this.dataCore.currentDesignSystemComponents(this.designSystemVersion.designSystem.id,this.designSystemVersion)).filter(e=>e.brandId===this.persistentId)})}designComponents(){return o(this,void 0,void 0,function*(){return(yield this.dataCore.currentDesignSystemDesignComponents(this.designSystemVersion.designSystem.id,this.designSystemVersion)).filter(e=>e.brandId===this.persistentId)})}designComponentGroups(){return o(this,void 0,void 0,function*(){return(yield this.dataCore.currentDesignSystemDesignComponentGroups(this.designSystemVersion.designSystem.id,this.designSystemVersion)).filter(e=>e.brandId===this.persistentId)})}designComponentGroupTree(){return o(this,void 0,void 0,function*(){return(yield this.dataCore.currentDesignSystemDesignComponentGroups(this.designSystemVersion.designSystem.id,this.designSystemVersion)).filter(e=>e.isRoot&&e.brandId===this.persistentId)[0]})}assets(){return o(this,void 0,void 0,function*(){return(yield this.dataCore.currentDesignSystemAssets(this.designSystemVersion.designSystem.id,this.designSystemVersion)).filter(e=>e.brandId===this.persistentId)})}assetGroups(){return o(this,void 0,void 0,function*(){return(yield this.dataCore.currentDesignSystemAssetGroups(this.designSystemVersion.designSystem.id,this.designSystemVersion)).filter(e=>e.brandId===this.persistentId)})}assetGroupTree(){return o(this,void 0,void 0,function*(){return(yield this.dataCore.currentDesignSystemAssetGroups(this.designSystemVersion.designSystem.id,this.designSystemVersion)).filter(e=>e.isRoot&&e.brandId===this.persistentId)[0]})}renderedAssets(e,t){return o(this,void 0,void 0,function*(){let n=yield this.assetGroups(),o=yield this.assets();return yield this.dataCore.renderAssetsForConfiguration(this.designSystemVersion.designSystem.id,this.designSystemVersion,o,n,e,t)})}specificRenderedAssets(e,t,n){return o(this,void 0,void 0,function*(){let o=yield this.assetGroups();return yield this.dataCore.renderAssetsForConfiguration(this.designSystemVersion.designSystem.id,this.designSystemVersion,e,o,t,n)})}}},6755(e,t){var n=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))(function(r,i){function s(e){try{l(o.next(e))}catch(e){i(e)}}function a(e){try{l(o.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}l((o=o.apply(e,t||[])).next())})};Object.defineProperty(t,"__esModule",{value:!0}),t.BrandWriter=void 0,t.BrandWriter=class{constructor(e,t){this.engine=e,this.dataCore=t.dataCore,this.brand=t}writeTokens(e,t,o){return n(this,void 0,void 0,function*(){let n=e.map(e=>e.toWriteObject()),r=t.map(e=>e.toWriteObject());return yield this.dataCore.writeTokenData(this.brand.designSystemVersion.designSystem.id,this.brand.designSystemVersion,n,r,o),{result:"success",errors:[],tokens:e,tokenGroups:t}})}writeTheme(e){return n(this,void 0,void 0,function*(){let t=e.toWriteObject();return yield this.dataCore.writeTokenThemeData(this.brand.designSystemVersion.designSystem.id,this.brand.designSystemVersion,t),{result:"success",errors:[],theme:e}})}}},1782(e,t){var n=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))(function(r,i){function s(e){try{l(o.next(e))}catch(e){i(e)}}function a(e){try{l(o.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}l((o=o.apply(e,t||[])).next())})};Object.defineProperty(t,"__esModule",{value:!0}),t.DesignSystem=void 0,t.DesignSystem=class{constructor(e,t){var n,o;this.engine=e,this.id=t.id,this.workspaceId=t.workspaceId,this.name=t.meta.name,this.description=t.meta.description,this.isMultiBrand=t.isMultibrand,this.isPublic=t.isPublic,this.documentationExporterId=t.docExporterId,this.documentationSlug=t.docSlug,this.documentationUserSlug=null!==(n=t.docUserSlug)&&void 0!==n?n:null,this.designSystemSwitcher=null!==(o=t.designSystemSwitcher)&&void 0!==o?o:{isEnabled:!1,designSystemIds:[]}}versions(){return n(this,void 0,void 0,function*(){return this.engine.designSystemVersions(this.id)})}activeVersion(){return n(this,void 0,void 0,function*(){return this.engine.activeDesignSystemVersion(this.id)})}sourceById(e){return n(this,void 0,void 0,function*(){return(yield this.sources()).filter(t=>t.id===e)[0]})}sources(){return n(this,void 0,void 0,function*(){return this.engine.designSystemSources(this.id)})}figmaFileIdForSourceId(e){return n(this,void 0,void 0,function*(){let t=(yield this.sources()).filter(t=>t.id===e)[0];if(t)return t.fileId})}figmaFileNameForSourceId(e){return n(this,void 0,void 0,function*(){let t=(yield this.sources()).filter(t=>t.id===e)[0];if(t)return t.fileName})}setKeyValueStorageData(e,t){return n(this,void 0,void 0,function*(){const n="string"==typeof t?t:JSON.stringify(t,null,0),o=this.engine.newDataCore();yield o.setKeyValueStorageData(this.id,{[e]:n})})}unsetKeyValueStorageData(e){return n(this,void 0,void 0,function*(){const t=this.engine.newDataCore();yield t.setKeyValueStorageData(this.id,{[e]:null})})}readKeyValueStorageData(e){return n(this,void 0,void 0,function*(){const t=this.engine.newDataCore(),n=yield t.getKeyValueStorageData(this.id,[e]);if(n&&n[e])try{return JSON.parse(n[e])}catch(t){return n[e]}})}}},8648(e,t,n){var o=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))(function(r,i){function s(e){try{l(o.next(e))}catch(e){i(e)}}function a(e){try{l(o.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}l((o=o.apply(e,t||[])).next())})};Object.defineProperty(t,"__esModule",{value:!0}),t.DesignSystemVersion=void 0;const r=n(6112),i=n(2556),s=n(2492),a=n(7431),l=n(9929);t.DesignSystemVersion=class{constructor(e,t,n){var o;this.engine=e,this.id=n.id,this.designSystem=t,this.name=n.meta.name,this.description=n.meta.description,this.version=n.version,this.changeLog=(null===(o=n.changeLog)||void 0===o?void 0:o.length)>0?n.changeLog:null,this.isReadOnly=n.isReadonly,this.engine&&(this.dataCore=this.engine.newDataCore())}writer(){return new a.VersionWriter(this.engine,this)}brands(){return o(this,void 0,void 0,function*(){const e=`design-systems/${this.designSystem.id}/versions/${this.id}/brands`;let t=(yield this.engine.dataBridge.getDSMGenericDataFromEndpoint(e)).result.brands;if(!t)throw i.SupernovaError.fromSDKError(`Unable to retrieve brands for design system version id ${this.id}`);let n=new Array;for(let e of t){let t=new s.Brand(this.engine,e,this);n.push(t)}return n})}tokens(){return o(this,void 0,void 0,function*(){return this.dataCore.currentDesignSystemTokens(this.designSystem.id,this)})}themes(){return o(this,void 0,void 0,function*(){return this.dataCore.currentDesignSystemThemes(this.designSystem.id,this)})}tokensByApplyingThemes(e,t){return o(this,void 0,void 0,function*(){const n=yield this.tokens(),o=yield this.themes(),r=new Map(o.map(e=>[e.id,e])),i=t.map(e=>{const t=r.get(e);if(!t)throw new Error(`Theme with id ${e} not found`);return t});return l.TokenUtils.tokensByApplyingThemes(n,i,e)})}tokenGroups(){return o(this,void 0,void 0,function*(){return this.dataCore.currentDesignSystemTokenGroups(this.designSystem.id,this)})}tokenGroupTrees(){return o(this,void 0,void 0,function*(){let e=(yield this.dataCore.currentDesignSystemTokenGroups(this.designSystem.id,this)).filter(e=>e.isRoot),t=new Map;for(let n of e){let e=t.get(n.tokenType);e?(e.push(n),t.set(n.tokenType,e)):t.set(n.tokenType,[n])}return t})}components(){return o(this,void 0,void 0,function*(){return this.dataCore.currentDesignSystemComponents(this.designSystem.id,this)})}designComponents(){return o(this,void 0,void 0,function*(){return this.dataCore.currentDesignSystemDesignComponents(this.designSystem.id,this)})}designComponentGroups(){return o(this,void 0,void 0,function*(){return this.dataCore.currentDesignSystemDesignComponentGroups(this.designSystem.id,this)})}designComponentGroupTree(){return o(this,void 0,void 0,function*(){return(yield this.dataCore.currentDesignSystemDesignComponentGroups(this.designSystem.id,this)).filter(e=>e.isRoot)})}assets(){return o(this,void 0,void 0,function*(){return this.dataCore.currentDesignSystemAssets(this.designSystem.id,this)})}assetGroups(){return o(this,void 0,void 0,function*(){return this.dataCore.currentDesignSystemAssetGroups(this.designSystem.id,this)})}assetGroupTrees(){return o(this,void 0,void 0,function*(){return(yield this.dataCore.currentDesignSystemAssetGroups(this.designSystem.id,this)).filter(e=>e.isRoot)})}documentation(){return o(this,void 0,void 0,function*(){return this.dataCore.currentDesignSystemDocumentation(this.designSystem,this)})}renderedAssets(e,t){return o(this,void 0,void 0,function*(){let n=yield this.assetGroups(),o=yield this.assets();return yield this.dataCore.renderAssetsForConfiguration(this.designSystem.id,this,o,n,e,t)})}specificRenderedAssets(e,t,n){return o(this,void 0,void 0,function*(){let o=yield this.assetGroups();return yield this.dataCore.renderAssetsForConfiguration(this.designSystem.id,this,e,o,t,n)})}tokenProperties(){return o(this,void 0,void 0,function*(){return(yield this.dataCore.currentDesignSystemElementProperties(this.designSystem.id,this)).filter(e=>e.targetElementType===r.ElementPropertyTargetElementType.token)})}tokenDataViews(){return o(this,void 0,void 0,function*(){return(yield this.dataCore.currentDesignSystemElementDataViews(this.designSystem.id,this)).filter(e=>e.targetElementType===r.ElementPropertyTargetElementType.token)})}componentProperties(){return o(this,void 0,void 0,function*(){return(yield this.dataCore.currentDesignSystemElementProperties(this.designSystem.id,this)).filter(e=>e.targetElementType===r.ElementPropertyTargetElementType.component)})}componentDataViews(){return o(this,void 0,void 0,function*(){return(yield this.dataCore.currentDesignSystemElementDataViews(this.designSystem.id,this)).filter(e=>e.targetElementType===r.ElementPropertyTargetElementType.component)})}getTokenStudioData(){return o(this,void 0,void 0,function*(){return yield this.dataCore.getTokenStudioData(this.designSystem.id,this)})}}},7431(e,t){var n=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))(function(r,i){function s(e){try{l(o.next(e))}catch(e){i(e)}}function a(e){try{l(o.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}l((o=o.apply(e,t||[])).next())})};Object.defineProperty(t,"__esModule",{value:!0}),t.VersionWriter=void 0,t.VersionWriter=class{constructor(e,t){this.engine=e,this.dataCore=t.dataCore,this.version=t}writeTokenStudioData(e){return n(this,void 0,void 0,function*(){return this.dataCore.writeTokenStudioJSONData(this.version.designSystem.id,this.version,e)})}}},4483(e,t,n){var o=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))(function(r,i){function s(e){try{l(o.next(e))}catch(e){i(e)}}function a(e){try{l(o.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}l((o=o.apply(e,t||[])).next())})};Object.defineProperty(t,"__esModule",{value:!0}),t.Documentation=void 0;const r=n(8138),i=n(577),s=n(7729);t.Documentation=class{constructor(e,t,n,o){this.version=e,this.designSystem=t,this.settings=new r.DocumentationConfiguration(n.settings,o)}rootGroup(e){return o(this,void 0,void 0,function*(){let t=yield this.version.dataCore.currentDesignSystemDocumentationItems(this.designSystem,this.version,e);for(let e of t)if(e.type===i.DocumentationItemType.group&&e.isRoot)return e;throw new Error("No documentation root found")})}items(e){return o(this,void 0,void 0,function*(){return this.version.dataCore.currentDesignSystemDocumentationItems(this.designSystem,this.version,e)})}groups(e){return o(this,void 0,void 0,function*(){return(yield this.version.dataCore.currentDesignSystemDocumentationItems(this.designSystem,this.version,e)).filter(e=>e.type===i.DocumentationItemType.group)})}pages(e){return o(this,void 0,void 0,function*(){return(yield this.version.dataCore.currentDesignSystemDocumentationItems(this.designSystem,this.version,e)).filter(e=>e.type===i.DocumentationItemType.page)})}customBlocks(){return o(this,void 0,void 0,function*(){return yield this.version.dataCore.currentExporterCustomBlocks(this.designSystem.id,this.version)})}customConfiguration(){return o(this,void 0,void 0,function*(){return yield this.version.dataCore.currentExporterConfigurationProperties(this.designSystem.workspaceId,this.designSystem.id,this.designSystem.documentationExporterId,this.version)})}customBlockVariants(){return o(this,void 0,void 0,function*(){return yield this.version.dataCore.currentExporterBlockVariants(this.designSystem.workspaceId,this.designSystem.id,this.designSystem.documentationExporterId,this.version)})}pageProperties(){return o(this,void 0,void 0,function*(){return(yield this.version.dataCore.currentDesignSystemElementProperties(this.designSystem.id,this.version)).filter(e=>e.targetElementType===s.ElementPropertyTargetElementType.documentationPage)})}pageDataViews(){return o(this,void 0,void 0,function*(){return(yield this.version.dataCore.currentDesignSystemElementDataViews(this.designSystem.id,this.version)).filter(e=>e.targetElementType===s.ElementPropertyTargetElementType.documentationPage)})}publish(e){return o(this,void 0,void 0,function*(){let t=yield this.isPublishing(e);return"Idle"===t.status?yield this.version.dataCore.publishDocumentation(this.version,e):{status:"InProgress",jobId:t.jobId,exporterId:t.exporterId}})}isPublishing(e){return o(this,void 0,void 0,function*(){let t=yield this.version.dataCore.documetationJobs(this.version,e,1);if(0===t.length)return{status:"Idle",jobId:null,exporterId:null};let n=t[0];return"InProgress"===n.status?{status:"InProgress",jobId:n.id,exporterId:n.exporterId}:{status:"Idle",jobId:null,exporterId:null}})}}},4680(e,t,n){var o=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))(function(r,i){function s(e){try{l(o.next(e))}catch(e){i(e)}}function a(e){try{l(o.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}l((o=o.apply(e,t||[])).next())})};Object.defineProperty(t,"__esModule",{value:!0}),t.Supernova=void 0;const r=n(4223),i=n(5005),s=n(5526),a=n(1782),l=n(8648),u=n(4860),d=n(2556),c=n(6095),p=n(8510),h=n(4055);t.Supernova=class{constructor(e,t=null,n=null,o=null,r=null,i=null,a=!1,l=null,u=null){this.useResolutionCache=!0,this.previewMode=!1,this.apiKey=e,this.apiUrl=null!=t?t:s.Configuration.apiUrlForDefaultEnvironment(),this.apiVersion=s.Configuration.apiVersionForDefaultEnvironment(),this.proxyUrl=null!=i?i:null,this.customFetchLib=null!=u?u:null,this.requestHook=null!=n?n:null,this.debugRequestObserver=null!=o?o:null,this.debugResponseObserver=null!=r?r:null,this.previewMode=a,this.jobId=l,this.rebuildBridge()}me(){return o(this,void 0,void 0,function*(){let e=(yield this.dataBridge.getDSMGenericDataFromEndpoint("users/me")).result.user;if(!e)throw d.SupernovaError.fromSDKError("Unable to retrieve current sdk user");return new h.User(e)})}workspaces(){return o(this,void 0,void 0,function*(){let e=(yield this.dataBridge.getDSMGenericDataFromEndpoint("users/me")).result.user;if(!e)throw d.SupernovaError.fromSDKError("Unable to retrieve current sdk user");const t=`users/${e.id}/workspaces`;let n=(yield this.dataBridge.getDSMGenericDataFromEndpoint(t)).result.membership;if(!n)throw d.SupernovaError.fromSDKError("Unable to retrieve available workspaces");let o=new Array;for(let e of n){let t=new u.Workspace(this,e.workspace);o.push(t)}return o})}workspace(e){return o(this,void 0,void 0,function*(){const t=`workspaces/${e}`;let n=(yield this.dataBridge.getDSMGenericDataFromEndpoint(t)).result.workspace;if(!n)throw d.SupernovaError.fromSDKError(`Unable to retrieve workspace with id ${e}`);return new u.Workspace(this,n)})}designSystems(e){return o(this,void 0,void 0,function*(){const t=`workspaces/${e}/design-systems`;let n=(yield this.dataBridge.getDSMGenericDataFromEndpoint(t)).result.designSystems;if(!n)throw d.SupernovaError.fromSDKError(`Unable to retrieve design systems for workspace id ${e}`);let o=new Array;for(let e of n){let t=new a.DesignSystem(this,e);o.push(t)}return o})}designSystem(e){return o(this,void 0,void 0,function*(){const t=`design-systems/${e}`;let n=(yield this.dataBridge.getDSMGenericDataFromEndpoint(t)).result.designSystem;if(!n)throw d.SupernovaError.fromSDKError(`Unable to retrieve design system for id ${e}`);return new a.DesignSystem(this,n)})}activeDesignSystemVersion(e){return o(this,void 0,void 0,function*(){let t=yield this.designSystem(e);const n=`design-systems/${e}/versions`;let o=(yield this.dataBridge.getDSMGenericDataFromEndpoint(n)).result.designSystemVersions;if(!o)throw d.SupernovaError.fromSDKError(`Unable to retrieve active version for design system id ${e}`);for(let e of o)if(!1===e.isReadonly)return new l.DesignSystemVersion(this,t,e);throw d.SupernovaError.fromSDKError(`Unable to retrieve active version for design system id ${e} - no version is currently active in selected design system`)})}designSystemVersions(e){return o(this,void 0,void 0,function*(){let t=yield this.designSystem(e);const n=`design-systems/${e}/versions`;let o=(yield this.dataBridge.getDSMGenericDataFromEndpoint(n)).result.designSystemVersions;if(!o)throw d.SupernovaError.fromSDKError(`Unable to retrieve active version for design system id ${e}`);let r=new Array;for(let e of o){let n=new l.DesignSystemVersion(this,t,e);r.push(n)}return r})}designSystemVersion(e,t){return o(this,void 0,void 0,function*(){let n=yield this.designSystem(e);const o=`design-systems/${e}/versions/${t}`;let r=(yield this.dataBridge.getDSMGenericDataFromEndpoint(o)).result.designSystemVersion;if(!r)throw d.SupernovaError.fromSDKError(`Unable to retrieve design system version for id ${t}`);return new l.DesignSystemVersion(this,n,r)})}designSystemSources(e){return o(this,void 0,void 0,function*(){const t=`design-systems/${e}/sources`;let n=(yield this.dataBridge.getDSMGenericDataFromEndpoint(t)).result.sources;if(!n)throw d.SupernovaError.fromSDKError(`Unable to retrieve design system sources for id ${e}`);return n.map(e=>new p.Source(e))})}exporters(e){return o(this,void 0,void 0,function*(){const t=`codegen/workspaces/${e}/exporters`;let n=(yield this.dataBridge.getDSMGenericDataFromEndpoint(t)).result.exporters;if(!n)throw d.SupernovaError.fromSDKError(`Unable to retrieve exporters for workspace id ${e}`);return n.map(e=>new c.Exporter(e))})}setResolutionCacheEnabled(e){this.useResolutionCache=e,this.dataBridge.cache=e}rebuildBridge(){this.dataBridge=new r.DataBridge({cache:this.useResolutionCache,apiUrl:this.apiUrl,apiVersion:this.apiVersion,accessToken:this.apiKey,target:null,requestHook:this.requestHook,debugRequestObserver:this.debugRequestObserver,debugResponseObserver:this.debugResponseObserver,proxyUrl:this.proxyUrl,customFetchLib:this.customFetchLib})}newDataCore(){let e=new r.DataBridge({cache:this.useResolutionCache,apiUrl:this.apiUrl,apiVersion:this.apiVersion,accessToken:this.apiKey,target:null,requestHook:this.requestHook,debugRequestObserver:this.debugRequestObserver,debugResponseObserver:this.debugResponseObserver,proxyUrl:this.proxyUrl,customFetchLib:this.customFetchLib});return new i.DataCore(e)}}},4860(e,t){var n=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))(function(r,i){function s(e){try{l(o.next(e))}catch(e){i(e)}}function a(e){try{l(o.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}l((o=o.apply(e,t||[])).next())})};Object.defineProperty(t,"__esModule",{value:!0}),t.Workspace=void 0,t.Workspace=class{constructor(e,t){this.engine=e,this.id=t.id,this.handle=t.profile.handle,this.name=t.profile.name,this.engine=e}designSystems(){return n(this,void 0,void 0,function*(){return this.engine.designSystems(this.id)})}exporters(){return n(this,void 0,void 0,function*(){return this.engine.exporters(this.id)})}}},5526(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.Configuration=void 0,t.Configuration=class{static apiUrlForDefaultEnvironment(){return"https://api.supernova.io/api"}static apiVersionForDefaultEnvironment(){return"0.2"}}},4223(e,t,n){var o=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))(function(r,i){function s(e){try{l(o.next(e))}catch(e){i(e)}}function a(e){try{l(o.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}l((o=o.apply(e,t||[])).next())})},r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.DataBridge=void 0;const i=n(3688),s=r(n(4229)).default;t.DataBridge=class{constructor(e){var t,n,o,r,s;this.previewMode=!1,this.jobId=null,this.cache=e.cache,this.authToken=e.accessToken,this.apiUrl=e.apiUrl,this.apiVersion=e.apiVersion,this.target=e.target,this.proxyAgent=e.proxyUrl?new i.HttpsProxyAgent(e.proxyUrl):null,this.customFetchLib=null!==(t=e.customFetchLib)&&void 0!==t?t:null,this.requestHook=e.requestHook,this.debugRequestObserver=null!==(n=e.debugRequestObserver)&&void 0!==n?n:null,this.debugResponseObserver=null!==(o=e.debugResponseObserver)&&void 0!==o?o:null,this.previewMode=null!==(r=e.previewMode)&&void 0!==r&&r,this.jobId=null!==(s=e.jobId)&&void 0!==s?s:null}getDSMGenericDataFromEndpoint(e){return o(this,void 0,void 0,function*(){let t=`${this.dsGenericRequestURL()}/${e}`;return this.getDataForAuthenticatedEndpoint(t)})}getDSMDataFromEndpoint(e,t,n){return o(this,void 0,void 0,function*(){let o=`${this.dsDataRequestURL(e,t)}/${n}`;return this.getDataForAuthenticatedEndpoint(o)})}getFetchInvoker(){return this.customFetchLib?this.customFetchLib:s}buildRequestConfig(e,t,n){return o(this,void 0,void 0,function*(){const o={url:e,method:t,timeout:12e4,headers:{"Content-Type":"application/json",Connection:"close","x-sn-exporter-preview":this.previewMode?"true":void 0,"x-sn-export-job":this.jobId?this.jobId:void 0,"x-sn-sdk-version":"legacy"},body:void 0,fetchProps:void 0};n&&(o.body=n);let r=!1;if(this.requestHook){const e=yield this.requestHook(o);e&&e.skipDefaultAuth&&(r=!0),e&&e.fetchProps&&(o.fetchProps=e.fetchProps)}if(!r){const e=this.authToken;o.headers.Authorization=`Bearer ${e}`}return o})}getDataForAuthenticatedEndpoint(e){return o(this,void 0,void 0,function*(){const t=yield this.buildRequestConfig(e,"GET"),n=Date.now()+Math.random().toString(36).substring(2),r=yield this.getFetchInvoker();this.debugRequestObserver&&this.debugRequestObserver({requestUrl:e,requestMethod:"GET",requestId:n});const i=this.debugResponseObserver?Date.now():0;return new Promise((s,a)=>{try{r(e,Object.assign({method:"GET",headers:t.headers,agent:this.proxyAgent},t.fetchProps)).then(e=>o(this,void 0,void 0,function*(){if(!e.ok){let t=yield e.json();throw t?new Error(JSON.stringify(t)):new Error(yield e.text())}return e.json()})).then(t=>{var o;null===(o=this.debugResponseObserver)||void 0===o||o.call(this,{requestUrl:e,executionTime:Date.now()-i,response:t,requestId:n}),s(t)}).catch(t=>{var o;null===(o=this.debugResponseObserver)||void 0===o||o.call(this,{requestUrl:e,executionTime:Date.now()-i,error:{message:null==t?void 0:t.message,stack:null==t?void 0:t.stack},requestId:n}),a(t)})}catch(e){a(e)}})})}postDSMDataToEndpoint(e,t,n,r,i=!1){return o(this,void 0,void 0,function*(){let o=`${this.dsDataRequestURL(e,t)}/${n}`;return this.postDataForAuthenticatedEndpoint(o,r,i)})}postDSMDataToGenericEndpoint(e,t,n=!1){return o(this,void 0,void 0,function*(){let o=`${this.dsGenericRequestURL()}/${e}`;return this.postDataForAuthenticatedEndpoint(o,t,n)})}postDataForAuthenticatedEndpoint(e,t,n=!1){return o(this,void 0,void 0,function*(){const r=n?"PUT":"POST",i=yield this.buildRequestConfig(e,r,t),s=Date.now()+Math.random().toString(36).substring(2),a=yield this.getFetchInvoker();this.debugRequestObserver&&this.debugRequestObserver({requestUrl:e,requestMethod:r,requestId:s});const l=this.debugResponseObserver?Date.now():0;return new Promise((t,n)=>{try{a(e,Object.assign({method:r,headers:i.headers,agent:this.proxyAgent,body:JSON.stringify(i.body)},i.fetchProps)).then(e=>o(this,void 0,void 0,function*(){if(!e.ok){let t=yield e.json();throw t?new Error(JSON.stringify(t)):new Error(yield e.text())}return e.json()})).then(n=>{var o;null===(o=this.debugResponseObserver)||void 0===o||o.call(this,{requestUrl:e,executionTime:Date.now()-l,response:n,requestId:s}),t(n)}).catch(t=>{var o;null===(o=this.debugResponseObserver)||void 0===o||o.call(this,{requestUrl:e,executionTime:Date.now()-l,error:{message:null==t?void 0:t.message,stack:null==t?void 0:t.stack},requestId:s}),n(t)})}catch(e){n(e)}})})}dsGenericRequestURL(){return`${this.apiUrl}`}dsWorkspaceRequestURL(e){return`${this.apiUrl}/workspaces/${e}`}dsDataRequestURL(e,t){return`${this.apiUrl}/design-systems/${e}/versions/${t}`}dsMetadataRequestURL(e){return`${this.apiUrl}/design-systems/${e}`}dsVersionRequestURL(e){return`${this.apiUrl}/design-systems/${e}/versions`}}},5005(e,t,n){var o=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))(function(r,i){function s(e){try{l(o.next(e))}catch(e){i(e)}}function a(e){try{l(o.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}l((o=o.apply(e,t||[])).next())})};Object.defineProperty(t,"__esModule",{value:!0}),t.DataCore=void 0;const r=n(645),i=n(5162),s=n(2275),a=n(3180),l=n(6936),u=n(2867),d=n(7042),c=n(5659),p=n(6478),h=n(4483),m=n(6095),v=n(6756),f=n(4542),g=n(8752),T=n(7729),k=n(2520);t.DataCore=class{constructor(e){this.bridge=e,this.tokensSynced=!1,this.tokens=new Array,this.tokenGroupsSynced=!1,this.tokenGroups=new Array,this.themesSynced=!1,this.themes=new Array,this.componentsSynced=!1,this.components=new Array,this.documentationItemsSynced=!1,this.documentationItems=new Array,this.exporterCustomBlocksSynced=!1,this.exporterCustomBlocks=new Array,this.designComponentAssetSynced=!1,this.designComponents=new Array,this.assets=new Array,this.designComponentAssetGroupsSynced=!1,this.designComponentGroups=new Array,this.assetGroups=new Array,this.elementDataViewsSynced=!1,this.elementPropertiesSynced=!1,this.elementProperties=new Array,this.elementDataViews=new Array,this.documentationSynced=!1,this.documentation=null}currentWorkspaceHandle(e){return o(this,void 0,void 0,function*(){const t=`workspaces/${e}`;return(yield this.bridge.getDSMGenericDataFromEndpoint(t)).result.workspace.profile.handle})}currentDeployedDocumentationUrl(e,t){return o(this,void 0,void 0,function*(){const n=`design-systems/${e}/versions/${t}/documentation/url`;let o=(yield this.bridge.getDSMGenericDataFromEndpoint(n)).result.url;return null!=o?o:void 0})}currentDesignSystemThemes(e,t){return o(this,void 0,void 0,function*(){return this.themesSynced||(yield this.updateThemesData(e,t)),this.themes})}getKeyValueStorageData(e,t){return o(this,void 0,void 0,function*(){const n=t.map(e=>encodeURIComponent(e)).join(","),o=`design-systems/${e}/metadata?keys=${n}`;return(yield this.bridge.getDSMGenericDataFromEndpoint(o)).result.metadata})}setKeyValueStorageData(e,t){return o(this,void 0,void 0,function*(){const n=`design-systems/${e}/metadata`;return yield this.bridge.postDSMDataToGenericEndpoint(n,{metadata:t},!0)})}currentDesignSystemTokens(e,t,n){return o(this,void 0,void 0,function*(){return this.tokensSynced&&!n||(yield this.updateTokenData(e,t)),this.tokens})}currentDesignSystemTokenGroups(e,t){return o(this,void 0,void 0,function*(){return this.tokenGroupsSynced||(yield this.updateTokenGroupData(e,t)),this.tokenGroups})}currentDesignSystemElementProperties(e,t,n){return o(this,void 0,void 0,function*(){return this.elementPropertiesSynced&&!n||(yield this.updateElementData(e,t)),this.elementProperties})}currentDesignSystemElementDataViews(e,t,n){return o(this,void 0,void 0,function*(){return this.elementDataViewsSynced&&!n||(yield this.updateElementData(e,t)),this.elementDataViews})}currentDesignSystemAssets(e,t){return o(this,void 0,void 0,function*(){return this.designComponentAssetSynced||(yield this.updateDesignComponentAndAssetData(e,t)),this.assets})}currentDesignSystemAssetGroups(e,t){return o(this,void 0,void 0,function*(){return this.designComponentAssetSynced||(yield this.updateDesignComponentAndAssetData(e,t)),this.designComponentAssetGroupsSynced||(yield this.updateDesignComponentAndAssetGroupData(e,t)),this.assetGroups})}renderAssetsForConfiguration(e,t,n,r,s,a){return o(this,void 0,void 0,function*(){let o={settings:[{prefix:"",suffix:"",scale:a,format:s}],persistentIds:n.map(e=>e.id)};const l=(yield this.bridge.postDSMDataToEndpoint(e,t.id,"components/assets/download-list",o)).result.items,u=new Map;for(const e of l)u.set(e.assetId,e);if(Array.from(u.entries()).length!==n.length)throw new Error("Number of rendered assets doesn't align with number of requested assets");const d=new Map;for(const e of n)d.set(e.id,e);let c=[],p=new Map;for(const e of n){const t=u.get(e.id);let n;for(let t of r)if(t.assetIds.includes(e.id)){n=t;break}let o=this.assetPath(e,n);if(p.get(o)||p.set(o,0),!n)throw new Error("Each asset must be assigned to some group");let s=new i.RenderedAsset(t,e,n,p.get(o));p.set(o,p.get(o)+1),c.push(s)}return c})}assetPath(e,t){let n=[e.name];for(;t;)n.push(t.name),t=t.parent;return n.reverse().join("/")}currentDesignSystemComponents(e,t){return o(this,void 0,void 0,function*(){return this.componentsSynced||(yield this.updateComponentData(e,t)),this.components})}currentDesignSystemDesignComponents(e,t){return o(this,void 0,void 0,function*(){return this.designComponentAssetSynced||(yield this.updateDesignComponentAndAssetData(e,t)),this.designComponents})}currentDesignSystemDesignComponentGroups(e,t){return o(this,void 0,void 0,function*(){return this.designComponentAssetSynced||(yield this.updateDesignComponentAndAssetData(e,t)),this.designComponentAssetGroupsSynced||(yield this.updateDesignComponentAndAssetGroupData(e,t)),this.designComponentGroups})}currentDesignSystemDocumentationItems(e,t,n){return o(this,void 0,void 0,function*(){let o=yield this.currentExporterCustomBlocks(e.id,t),r=(yield this.currentDesignSystemDocumentation(e,t)).settings;return this.documentationItemsSynced||(yield this.updateDocumentationItemData(e.id,t,n,o,r)),this.documentationItems})}currentDesignSystemDocumentation(e,t){return o(this,void 0,void 0,function*(){return this.documentationSynced||(yield this.updateDocumentationData(e,t)),this.documentation})}currentExporterCustomBlocks(e,t){return o(this,void 0,void 0,function*(){return this.exporterCustomBlocksSynced||(yield this.updateExporterCustomBlocksData(e,t)),this.exporterCustomBlocks})}currentExporterConfigurationProperties(e,t,n,r){return o(this,void 0,void 0,function*(){let o=yield this.getExporter(e,n,r),i=yield this.getExporterConfigurationPropertyUserValues(t,n,r);for(let e of o.contributes.configuration)for(let t of i)e.key===t.key&&e.updateValue(t.value);return o.contributes.configuration})}currentExporterBlockVariants(e,t,n,r){return o(this,void 0,void 0,function*(){return(yield this.getExporter(e,n,r)).contributes.blockVariants})}updateElementData(e,t){return o(this,void 0,void 0,function*(){const n=yield this.getElementData(e,t);this.elementDataViews=n.views,this.elementProperties=n.properties,this.bridge.cache&&(this.elementDataViewsSynced=!0,this.elementPropertiesSynced=!0)})}getElementData(e,t){return o(this,void 0,void 0,function*(){const n=yield this.getRawElementPropertyData(e,t);let o=n.properties.map(e=>new T.ElementProperty(e)),r=n.views.map(e=>new g.ElementDataView(e)),i=r.filter(e=>e.isDefault&&e.targetElementType===T.ElementPropertyTargetElementType.component)[0],s=new Map;for(let e of i.columns)e.propertyDefinitionId&&s.set(e.propertyDefinitionId,i.columns.indexOf(e));return o=o.sort((e,t)=>s.get(e.persistentId)-s.get(t.persistentId)),{views:r,properties:o}})}updateDocumentationData(e,t){return o(this,void 0,void 0,function*(){this.documentation=yield this.getDocumentation(e,t),this.bridge.cache&&(this.documentationSynced=!0)})}getDocumentation(e,t){return o(this,void 0,void 0,function*(){let n=(yield this.bridge.getDSMDataFromEndpoint(e.id,t.id,"documentation")).result.documentation,o=yield this.getNPMRegistry(e,t);return new h.Documentation(t,e,n,o)})}getNPMRegistry(e,t){return o(this,void 0,void 0,function*(){try{const t=`workspaces/${e.workspaceId}/npm-registry`;let n=(yield this.bridge.getDSMGenericDataFromEndpoint(t)).result.npmRegistrySettings;return n?new f.WorkspaceNPMRegistry(n):null}catch(e){return null}})}updateExporterCustomBlocksData(e,t){return o(this,void 0,void 0,function*(){this.exporterCustomBlocks=yield this.getExporterCustomBlocks(e,t),this.bridge.cache&&(this.exporterCustomBlocksSynced=!0)})}getExporterCustomBlocks(e,t){return o(this,void 0,void 0,function*(){let n=yield this.getExporterCustomBlockData(e,t);return yield this.resolveExporterCustomBlockData(n)})}getExporterCustomBlockData(e,t){return o(this,void 0,void 0,function*(){return(yield this.bridge.getDSMDataFromEndpoint(e,t.id,"documentation/custom-blocks")).result.customBlocks})}resolveExporterCustomBlockData(e){return o(this,void 0,void 0,function*(){return e.map(e=>new a.ExporterCustomBlock(e))})}getExporterConfigurationPropertyUserValues(e,t,n){return o(this,void 0,void 0,function*(){return yield this.getExporterConfigurationPropertiesUserValuesData(e,t,n)})}getExporterConfigurationPropertiesUserValuesData(e,t,n){return o(this,void 0,void 0,function*(){const n=`design-systems/${e}/exporter-properties/${t}`;return(yield this.bridge.getDSMGenericDataFromEndpoint(n)).result.items})}getExporter(e,t,n){return o(this,void 0,void 0,function*(){let n=yield this.getExporterData(e,t);return yield this.resolveExporterData(n)})}getExporterData(e,t){return o(this,void 0,void 0,function*(){const n=`codegen/workspaces/${e}/exporters/${t}`;return(yield this.bridge.getDSMGenericDataFromEndpoint(n)).result.exporter})}resolveExporterData(e){return o(this,void 0,void 0,function*(){return new m.Exporter(e)})}updateTokenData(e,t){return o(this,void 0,void 0,function*(){this.tokens=yield this.getTokens(e,t),this.bridge.cache&&(this.tokensSynced=!0)})}getTokens(e,t){return o(this,void 0,void 0,function*(){let n=yield this.getTokenGroups(e,t),o=yield Promise.all([this.getRawTokenData(e,t),this.getRawElementPropertyData(e,t),this.getRawElementPropertyValuesData(e,t)]),r=o[0],i=o[1],s=yield o[2];return yield this.resolveTokenData(r,i.properties,i.views,s,n,t)})}getRawTokenData(e,t){return o(this,void 0,void 0,function*(){return(yield this.bridge.getDSMDataFromEndpoint(e,t.id,"tokens")).result.tokens})}resolveTokenData(e,t,n,r,i,s){return o(this,void 0,void 0,function*(){return new p.TokenResolver(s).resolveTokenData(e,i,t,n,r)})}updateTokenGroupData(e,t){return o(this,void 0,void 0,function*(){this.tokenGroups=yield this.getTokenGroups(e,t),this.bridge.cache&&(this.tokenGroupsSynced=!0)})}getTokenGroups(e,t){return o(this,void 0,void 0,function*(){let n=yield this.getRawTokenGroupData(e,t);return yield this.resolveTokenGroupData(n)})}getRawTokenGroupData(e,t){return o(this,void 0,void 0,function*(){return(yield this.bridge.getDSMDataFromEndpoint(e,t.id,"token-groups")).result.groups})}resolveTokenGroupData(e){return o(this,void 0,void 0,function*(){let t=new c.TokenGroupResolver;return yield t.resolveGroupData(e)})}updateThemesData(e,t){return o(this,void 0,void 0,function*(){this.themes=yield this.getThemes(e,t),this.bridge.cache&&(this.themesSynced=!0)})}getThemes(e,t){return o(this,void 0,void 0,function*(){let n=yield this.currentDesignSystemTokens(e,t),o=yield this.currentDesignSystemTokenGroups(e,t),r=yield this.getRawThemeData(e,t);return yield this.resolveThemeData(r,n,o,t)})}getRawThemeData(e,t){return o(this,void 0,void 0,function*(){return(yield this.bridge.getDSMDataFromEndpoint(e,t.id,"themes")).result.themes})}resolveThemeData(e,t,n,r){return o(this,void 0,void 0,function*(){let o=new Array;for(let i of e){let s=new p.TokenResolver(r).resolveThemeData(i,t,n,e);o.push(s)}return o})}updateComponentData(e,t){return o(this,void 0,void 0,function*(){let n=yield this.getComponents(e,t);this.components=n,this.bridge.cache&&(this.componentsSynced=!0)})}getComponents(e,t){return o(this,void 0,void 0,function*(){let n=yield Promise.all([this.getRawComponentData(e,t),this.getRawElementPropertyData(e,t),this.getRawElementPropertyValuesData(e,t)]),o=n[0],r=n[1],i=n[2];return yield this.resolveComponentData(o,r.properties,r.views,i,t)})}getRawComponentData(e,t){return o(this,void 0,void 0,function*(){return(yield this.bridge.getDSMDataFromEndpoint(e,t.id,"design-system-components")).result.designSystemComponents})}getRawElementPropertyData(e,t){return o(this,void 0,void 0,function*(){return{properties:(yield this.bridge.getDSMDataFromEndpoint(e,t.id,"element-properties/definitions")).result.definitions,views:(yield this.bridge.getDSMDataFromEndpoint(e,t.id,"element-data-views")).result.elementDataViews}})}getRawElementPropertyValuesData(e,t){return o(this,void 0,void 0,function*(){return(yield this.bridge.getDSMDataFromEndpoint(e,t.id,"element-properties/values")).result.values})}resolveComponentData(e,t,n,r,i){return o(this,void 0,void 0,function*(){let o=new v.ComponentResolver;return yield o.resolveComponentData(e,t,n,r)})}updateDesignComponentAndAssetData(e,t){return o(this,void 0,void 0,function*(){let n=yield this.getDesignComponentsAndAssets(e,t);this.resolveDesignComponentSetData(n.designComponents),this.designComponents=n.designComponents,this.assets=n.assets,this.bridge.cache&&(this.designComponentAssetSynced=!0)})}getDesignComponentsAndAssets(e,t){return o(this,void 0,void 0,function*(){let n=yield this.getRawDesignComponentAndAssetData(e,t);return yield this.resolveDesignComponentAndAssetData(n,t)})}getRawDesignComponentAndAssetData(e,t){return o(this,void 0,void 0,function*(){return(yield this.bridge.getDSMDataFromEndpoint(e,t.id,"components")).result.components})}resolveDesignComponentAndAssetData(e,t){return o(this,void 0,void 0,function*(){let n=[],o=t.designSystem,i=yield o.sources();for(let t of e)n.push(new s.DesignComponent(t,i));let a=new Map;for(let t of e)t.exportProperties.isAsset&&a.set(t.meta.name.toLowerCase(),0);let l=[];for(let t of e){let e=t.meta.name.toLowerCase();t.exportProperties.isAsset&&(l.push(new r.Asset(t,a.get(e),i)),a.set(e,a.get(e)+1))}return{designComponents:n,assets:l}})}updateDesignComponentAndAssetGroupData(e,t){return o(this,void 0,void 0,function*(){let n=yield this.getDesignComponentAndAssetGroups(e,t,this.designComponents,this.assets);this.designComponentGroups=n.designComponentGroups,this.assetGroups=n.assetGroups,this.bridge.cache&&(this.designComponentAssetGroupsSynced=!0)})}getDesignComponentAndAssetGroups(e,t,n,r){return o(this,void 0,void 0,function*(){let o=yield this.getRawDesignComponentAndAssetGroupData(e,t);return{designComponentGroups:this.resolveDesignComponentGroupData(o,n),assetGroups:this.resolveAssetGroupData(o,r)}})}getRawDesignComponentAndAssetGroupData(e,t){return o(this,void 0,void 0,function*(){return(yield this.bridge.getDSMDataFromEndpoint(e,t.id,"component-groups")).result.groups})}resolveDesignComponentGroupData(e,t){return new u.DesignComponentGroupResolver(t).resolveGroupData(e)}resolveDesignComponentSetData(e){new k.DesignComponentSetResolver(e).resolveComponentSets()}resolveAssetGroupData(e,t){return new l.AssetGroupResolver(t).resolveGroupData(e)}updateDocumentationItemData(e,t,n,r,i){return o(this,void 0,void 0,function*(){this.documentationItems=yield this.getDocumentationItems(e,t,n,r,i),this.bridge.cache&&(this.documentationItemsSynced=!0)})}getDocumentationItems(e,t,n,r,i){return o(this,void 0,void 0,function*(){let o=yield this.getRawDocumentationItemData(e,t,n),s=yield this.currentWorkspaceHandle(t.designSystem.workspaceId);const a=yield this.currentDeployedDocumentationUrl(t.designSystem.id,t.id);return yield this.resolveDocumentationItemData(o.pageDetails,o.groupDetails,r,i,t,s,a)})}getRawDocumentationItemData(e,t,n){return o(this,void 0,void 0,function*(){const o="documentation/all"+(n?`?exportJobId=${n}`:"");let r=(yield this.bridge.getDSMDataFromEndpoint(e,t.id,o)).result;return{pageDetails:r.pages,groupDetails:r.groups}})}resolveDocumentationItemData(e,t,n,r,i,s,a){return o(this,void 0,void 0,function*(){let o=new d.DocumentationItemResolver(n,r,i,s,a);return yield o.resolveItemData(e,t)})}getTokenStudioData(e,t){return o(this,void 0,void 0,function*(){return(yield this.bridge.getDSMDataFromEndpoint(e,t.id,"bff/token-studio")).result})}writeTokenData(e,t,n,r,i){return o(this,void 0,void 0,function*(){const o={tokens:n,tokenGroups:r,bulkDelete:{tokenIds:i.map(e=>e.versionedId)}};return yield this.bridge.postDSMDataToEndpoint(e,t.id,"bff/import",o)})}writeTokenThemeData(e,t,n){return o(this,void 0,void 0,function*(){const o=`themes/${n.id}`,r=n;return(yield this.bridge.postDSMDataToEndpoint(e,t.id,o,r,!0)).theme})}writeTokenStudioJSONData(e,t,n){return o(this,void 0,void 0,function*(){return yield this.bridge.postDSMDataToEndpoint(e,t.id,"bff/token-studio",n)})}documetationJobs(e,t,n=10){return o(this,void 0,void 0,function*(){const o=`codegen/workspaces/${e.designSystem.workspaceId}/jobs?designSystemVersionId=${e.id}&destinations[]=documentation&docsEnvironment=${t}&offset=0&limit=${n}`;return(yield this.bridge.getDSMGenericDataFromEndpoint(o)).result.jobs})}publishDocumentation(e,t){return o(this,void 0,void 0,function*(){const n=`codegen/workspaces/${e.designSystem.workspaceId}/jobs/documentation`,o={designSystemId:e.designSystem.id,designSystemVersionId:e.id,environment:t};let r,i=(yield this.bridge.postDSMDataToGenericEndpoint(n,o,!1)).result;if("InProgress"===i.job.status||"Success"===i.job.status)r="Queued";else{if("Failed"!==i.job.status)throw new Error(`Unsupported status ${i.job.status}`);r="Failure"}return{status:r,jobId:i.job.id,exporterId:i.job.exporterId}})}}},2556(e,t){var n;Object.defineProperty(t,"__esModule",{value:!0}),t.SupernovaError=void 0,function(e){e.responseError="response",e.requestError="request",e.computeError="compute",e.processingError="processing"}(n||(n={}));class o extends Error{constructor(e,t){super(e),this.status=null,this.label=null,this.type=t}static fromSDKError(e){return new o(e,n.computeError)}static fromProcessingError(e){return new o(e,n.processingError)}}t.SupernovaError=o},6936(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.AssetGroupResolver=void 0;const o=n(9055);t.AssetGroupResolver=class{constructor(e){this.assets=e}resolveGroupData(e){var t=new Map,n=new Map,r=this.assets.map(e=>e.id);for(let r of e){let e=new o.AssetGroup(r);t.set(r.persistentId,r),n.set(r.persistentId,e)}for(let t of e){let e=new Array,o=n.get(t.persistentId);for(let i of t.childrenIds){let t=n.get(i);t?o.addChild(t):r.includes(i)&&e.push(i)}o.assetIds=e}let i=Array.from(n.values());return this.recomputePaths(i),this.recomputeParents(i),this.reorderGroupsByRoots(i)}recomputePaths(e){for(let t of e)t.isRoot&&this.recomputePathsFromRoot(t,[]);for(let t of e)t.path.shift()}recomputePathsFromRoot(e,t){let n=t.concat(e.name);for(let t of e.subgroups)t.path=n.concat(),this.recomputePathsFromRoot(t,n)}reorderGroupsByRoots(e){let t=new Array,n=e.filter(e=>e.isRoot);for(const e of n)t=t.concat(this.traverseSortGroup(e));return t}traverseSortGroup(e){let t=new Array;t.push(e);let n=e.subgroups.sort((t,n)=>e.childrenIds.indexOf(t.id)-e.childrenIds.indexOf(n.id));for(let e of n)t=t.concat(this.traverseSortGroup(e));return t}recomputeParents(e){for(let t of e)t.isRoot&&(this.recomputeParentsFromRoot(t),t.parent=null)}recomputeParentsFromRoot(e){for(let t of e.subgroups)t.setParent(e),this.recomputeParentsFromRoot(t)}}},6756(e,t,n){var o=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))(function(r,i){function s(e){try{l(o.next(e))}catch(e){i(e)}}function a(e){try{l(o.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}l((o=o.apply(e,t||[])).next())})};Object.defineProperty(t,"__esModule",{value:!0}),t.ComponentResolver=void 0;const r=n(305),i=n(8752),s=n(6112),a=n(1690);t.ComponentResolver=class{constructor(){}resolveComponentData(e,t,n,l){return o(this,void 0,void 0,function*(){let o=t.map(e=>new s.ElementProperty(e)).filter(e=>e.targetElementType===s.ElementPropertyTargetElementType.component),u=l.map(e=>new a.ElementPropertyValue(e)),d=n.map(e=>new i.ElementDataView(e)).filter(e=>e.isDefault&&e.targetElementType===s.ElementPropertyTargetElementType.component)[0],c=new Map;for(let e of d.columns)e.propertyDefinitionId&&c.set(e.propertyDefinitionId,d.columns.indexOf(e));return o=o.sort((e,t)=>c.get(e.persistentId)-c.get(t.persistentId)),e.map(e=>new r.Component(e,o,u))})}}},2867(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.DesignComponentGroupResolver=void 0;const o=n(7072);t.DesignComponentGroupResolver=class{constructor(e){this.designComponents=e}resolveComponentSets(){const e=new Map;this.designComponents.forEach(t=>e.set(t.id,t)),this.designComponents.forEach(t=>{t.childrenIds.map(t=>e.get(t)).filter(e=>!!e)})}resolveGroupData(e){var t=new Map,n=new Map;for(let r of e){let e=new o.DesignComponentGroup(r);t.set(r.persistentId,r),n.set(r.persistentId,e)}for(let t of e){let e=new Array,o=n.get(t.persistentId);for(let r of t.childrenIds){let t=n.get(r);t?o.addChild(t):e.push(r)}o.componentIds=e}let r=Array.from(n.values());return this.recomputePaths(r),this.recomputeParents(r),this.reorderGroupsByRoots(r)}recomputePaths(e){for(let t of e)t.isRoot&&this.recomputePathsFromRoot(t,[]);for(let t of e)t.path.shift()}recomputePathsFromRoot(e,t){let n=t.concat(e.name);for(let t of e.subgroups)t.path=n.concat(),this.recomputePathsFromRoot(t,n)}reorderGroupsByRoots(e){let t=new Array,n=e.filter(e=>e.isRoot);for(const e of n)t=t.concat(this.traverseSortGroup(e));return t}traverseSortGroup(e){let t=new Array;t.push(e);let n=e.subgroups.sort((t,n)=>e.childrenIds.indexOf(t.id)-e.childrenIds.indexOf(n.id));for(let e of n)t=t.concat(this.traverseSortGroup(e));return t}recomputeParents(e){for(let t of e)t.isRoot&&(this.recomputeParentsFromRoot(t),t.parent=null)}recomputeParentsFromRoot(e){for(let t of e.subgroups)t.setParent(e),this.recomputeParentsFromRoot(t)}}},2520(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.DesignComponentSetResolver=void 0,t.DesignComponentSetResolver=class{constructor(e){this.designComponents=e}resolveComponentSets(){const e=new Map;this.designComponents.forEach(t=>e.set(t.id,t)),this.designComponents.forEach(t=>{const n=t.childrenIds.map(t=>e.get(t)).filter(e=>!!e);t.addChildren(n)})}}},7042(e,t,n){var o=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))(function(r,i){function s(e){try{l(o.next(e))}catch(e){i(e)}}function a(e){try{l(o.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}l((o=o.apply(e,t||[])).next())})};Object.defineProperty(t,"__esModule",{value:!0}),t.DocumentationItemResolver=void 0;const r=n(8219),i=n(6497),s=n(577),a=n(9834);t.DocumentationItemResolver=class{constructor(e,t,n,o,r){this.hashedItems=new Map,this.resolvedItems=new Map,this.flattenedBlocksOfPage=e=>{let t=e.blocks;for(let n of e.blocks)t=t.concat(this.flattenedBlocksOfBlock(n));return t},this.flattenedBlocksOfBlock=e=>{let t=e.children;for(let n of e.children)t=t.concat(this.flattenedBlocksOfBlock(n));return t},this.customBlocks=e,this.configuration=t,this.version=n,this.workspaceHandle=o,this.designSystem=n.designSystem,this.docsUrl=r}resolveItemData(e,t){return o(this,void 0,void 0,function*(){let n;for(let e of t)e.type=s.DocumentationItemType.group,this.hashedItems.set(e.persis