UNPKG

@accordproject/concerto-core

Version:

Core Implementation for the Concerto Modeling Language

2 lines • 472 kB
/*! For license information please see concerto-core.js.LICENSE.txt */ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports["concerto-core"]=t():e["concerto-core"]=t()}(self,(()=>(()=>{var e={3348:(e,t,r)=>{"use strict";const n=r(3954);e.exports={MetaModelUtil:n,MetaModelNamespace:"concerto.metamodel@1.0.0"}},4702:e=>{"use strict";e.exports='/*\n * Licensed under the Apache License, Version 2.0 (the "License");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an "AS IS" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n@DotNetNamespace("AccordProject.Concerto.Metamodel")\nnamespace concerto.metamodel@1.0.0\n\nconcept Position {\n o Integer line\n o Integer column\n o Integer offset\n}\n\nconcept Range {\n o Position start\n o Position end\n o String source optional\n}\n\nconcept TypeIdentifier {\n o String name\n o String namespace optional\n}\n\nabstract concept DecoratorLiteral {\n o Range location optional\n}\n\nconcept DecoratorString extends DecoratorLiteral {\n o String value\n}\n\nconcept DecoratorNumber extends DecoratorLiteral {\n o Double value\n}\n\nconcept DecoratorBoolean extends DecoratorLiteral {\n o Boolean value\n}\n\nconcept DecoratorTypeReference extends DecoratorLiteral {\n o TypeIdentifier type\n o Boolean isArray default=false\n}\n\nconcept Decorator {\n o String name\n o DecoratorLiteral[] arguments optional\n o Range location optional\n}\n\nconcept Identified {\n}\n\nconcept IdentifiedBy extends Identified {\n o String name\n}\n\nabstract concept Declaration {\n o String name regex=/^(\\p{Lu}|\\p{Ll}|\\p{Lt}|\\p{Lm}|\\p{Lo}|\\p{Nl}|\\$|_|\\\\u[0-9A-Fa-f]{4})(?:\\p{Lu}|\\p{Ll}|\\p{Lt}|\\p{Lm}|\\p{Lo}|\\p{Nl}|\\$|_|\\\\u[0-9A-Fa-f]{4}|\\p{Mn}|\\p{Mc}|\\p{Nd}|\\p{Pc}|\\u200C|\\u200D)*$/u\n o Decorator[] decorators optional\n o Range location optional\n}\n\nabstract concept MapKeyType {\n o Decorator[] decorators optional\n o Range location optional\n}\n\nabstract concept MapValueType {\n o Decorator[] decorators optional\n o Range location optional\n}\n\nconcept MapDeclaration extends Declaration {\n o MapKeyType key\n o MapValueType value\n}\n\nconcept StringMapKeyType extends MapKeyType {}\nconcept DateTimeMapKeyType extends MapKeyType {}\n\nconcept ObjectMapKeyType extends MapKeyType {\n o TypeIdentifier type\n}\n\nconcept BooleanMapValueType extends MapValueType {}\nconcept DateTimeMapValueType extends MapValueType {}\nconcept StringMapValueType extends MapValueType {}\nconcept IntegerMapValueType extends MapValueType {}\nconcept LongMapValueType extends MapValueType {}\nconcept DoubleMapValueType extends MapValueType {}\n\nconcept ObjectMapValueType extends MapValueType {\n o TypeIdentifier type\n}\n\nconcept RelationshipMapValueType extends MapValueType {\n o TypeIdentifier type\n}\n\nconcept EnumDeclaration extends Declaration {\n o EnumProperty[] properties\n}\n\nconcept EnumProperty {\n o String name regex=/^(\\p{Lu}|\\p{Ll}|\\p{Lt}|\\p{Lm}|\\p{Lo}|\\p{Nl}|\\$|_|\\\\u[0-9A-Fa-f]{4})(?:\\p{Lu}|\\p{Ll}|\\p{Lt}|\\p{Lm}|\\p{Lo}|\\p{Nl}|\\$|_|\\\\u[0-9A-Fa-f]{4}|\\p{Mn}|\\p{Mc}|\\p{Nd}|\\p{Pc}|\\u200C|\\u200D)*$/u\n o Decorator[] decorators optional\n o Range location optional\n}\n\nconcept ConceptDeclaration extends Declaration {\n o Boolean isAbstract default=false\n o Identified identified optional\n o TypeIdentifier superType optional\n o Property[] properties\n}\n\nconcept AssetDeclaration extends ConceptDeclaration {\n}\n\nconcept ParticipantDeclaration extends ConceptDeclaration {\n}\n\nconcept TransactionDeclaration extends ConceptDeclaration {\n}\n\nconcept EventDeclaration extends ConceptDeclaration {\n}\n\nabstract concept Property {\n o String name regex=/^(\\p{Lu}|\\p{Ll}|\\p{Lt}|\\p{Lm}|\\p{Lo}|\\p{Nl}|\\$|_|\\\\u[0-9A-Fa-f]{4})(?:\\p{Lu}|\\p{Ll}|\\p{Lt}|\\p{Lm}|\\p{Lo}|\\p{Nl}|\\$|_|\\\\u[0-9A-Fa-f]{4}|\\p{Mn}|\\p{Mc}|\\p{Nd}|\\p{Pc}|\\u200C|\\u200D)*$/u\n o Boolean isArray default=false\n o Boolean isOptional default=false\n o Decorator[] decorators optional\n o Range location optional\n}\n\nconcept RelationshipProperty extends Property {\n o TypeIdentifier type\n}\n\nconcept ObjectProperty extends Property {\n o String defaultValue optional\n o TypeIdentifier type\n}\n\nconcept BooleanProperty extends Property {\n o Boolean defaultValue optional\n}\n\nconcept DateTimeProperty extends Property {\n}\n\nconcept StringProperty extends Property {\n o String defaultValue optional\n o StringRegexValidator validator optional\n o StringLengthValidator lengthValidator optional\n}\n\nconcept StringRegexValidator {\n o String pattern\n o String flags\n}\n\nconcept StringLengthValidator {\n o Integer minLength optional\n o Integer maxLength optional\n}\n\nconcept DoubleProperty extends Property {\n o Double defaultValue optional\n o DoubleDomainValidator validator optional\n}\n\nconcept DoubleDomainValidator {\n o Double lower optional\n o Double upper optional\n}\n\nconcept IntegerProperty extends Property {\n o Integer defaultValue optional\n o IntegerDomainValidator validator optional\n}\n\nconcept IntegerDomainValidator {\n o Integer lower optional\n o Integer upper optional\n}\n\nconcept LongProperty extends Property {\n o Long defaultValue optional\n o LongDomainValidator validator optional\n}\n\nconcept LongDomainValidator {\n o Long lower optional\n o Long upper optional\n}\n\nconcept AliasedType{\n o String name\n o String aliasedName\n}\nabstract concept Import {\n o String namespace\n o String uri optional\n}\n\nconcept ImportAll extends Import {\n}\n\nconcept ImportType extends Import {\n o String name\n}\n\nconcept ImportTypes extends Import {\n o String[] types\n o AliasedType[] aliasedTypes optional\n}\n\nconcept Model {\n o String namespace\n o String sourceUri optional\n o String concertoVersion optional\n o Import[] imports optional\n o Declaration[] declarations optional\n o Decorator[] decorators optional\n}\n\nconcept Models {\n o Model[] models\n}\n\nabstract concept ScalarDeclaration extends Declaration {\n}\n\nconcept BooleanScalar extends ScalarDeclaration {\n o Boolean defaultValue optional\n}\n\nconcept IntegerScalar extends ScalarDeclaration {\n o Integer defaultValue optional\n o IntegerDomainValidator validator optional\n}\n\nconcept LongScalar extends ScalarDeclaration {\n o Long defaultValue optional\n o LongDomainValidator validator optional\n}\n\nconcept DoubleScalar extends ScalarDeclaration {\n o Double defaultValue optional\n o DoubleDomainValidator validator optional\n}\n\nconcept StringScalar extends ScalarDeclaration {\n o String defaultValue optional\n o StringRegexValidator validator optional\n o StringLengthValidator lengthValidator optional\n}\n\nconcept DateTimeScalar extends ScalarDeclaration {\n o String defaultValue optional\n}\n'},3954:(e,t,r)=>{"use strict";const n=r(4865),a="concerto.metamodel@1.0.0",o=r(4702);function s(e,t){return e.declarations.find((e=>e.name===t))}function i(e,t){if(!t[e])throw new Error(`Name ${e} not found`);return t[e].namespace}function c(e,t){switch((e.decorators||[]).forEach((e=>{c(e,t)})),e.$class){case`${a}.Model`:(e.declarations||[]).forEach((e=>{c(e,t)}));break;case`${a}.AssetDeclaration`:case`${a}.ConceptDeclaration`:case`${a}.EventDeclaration`:case`${a}.TransactionDeclaration`:case`${a}.ParticipantDeclaration`:if(e.superType){const r=e.superType.name;e.superType.namespace=i(r,t),e.superType.name=t[r].name,t[r]?.resolvedName&&(e.superType.resolvedName=t[r].resolvedName)}(e.properties||[]).forEach((e=>{c(e,t)}));break;case`${a}.MapDeclaration`:c(e.key,t),c(e.value,t);break;case`${a}.Decorator`:(e.arguments||[]).forEach((e=>{c(e,t)}));break;case`${a}.EnumProperty`:case`${a}.ObjectProperty`:case`${a}.RelationshipProperty`:case`${a}.DecoratorTypeReference`:case`${a}.ObjectMapKeyType`:case`${a}.ObjectMapValueType`:e.type.namespace=i(e.type.name,t),e.type.name=t[e.type.name].name,t[e.type.name]?.resolvedName&&(e.type.resolvedName=t[e.type.name].resolvedName);break;case`${a}.StringScalar`:case`${a}.BooleanScalar`:case`${a}.DateTimeScalar`:case`${a}.DoubleScalar`:case`${a}.LongScalar`:case`${a}.IntegerScalar`:e.namespace=i(e.name,t),e.name=t[e.name].name}return e}function l(e,t){const r=JSON.parse(JSON.stringify(t)),n=function(e,t){const r="concerto@1.0.0",n={Concept:{namespace:r,name:"Concept"},Asset:{namespace:r,name:"Asset"},Participant:{namespace:r,name:"Participant"},Transaction:{namespace:r,name:"Transaction"},Event:{namespace:r,name:"Event"}};return(t.imports||[]).forEach((t=>{const r=t.namespace,o=function(e,t){return e.models.find((e=>e.namespace===t))}(e,r);if(t.$class===`${a}.ImportType`){if(!s(o,t.name))throw new Error(`Declaration ${t.name} in namespace ${r} not found`);n[t.name]={namespace:r,name:t.name}}else if(t.$class===`${a}.ImportTypes`){const e=t.aliasedTypes?new Map(t.aliasedTypes.map((({name:e,aliasedName:t})=>[e,t]))):new Map;t.types.forEach((t=>{const a=e.get(t)||t;if(!s(o,t))throw new Error(`Declaration ${t} in namespace ${r} not found`);n[a]=a!==t?{namespace:r,name:a,resolvedName:t}:{namespace:r,name:t}}))}else(o.declarations||[]).forEach((e=>{n[e.name]={namespace:r,name:e.name}}))})),(t.declarations||[]).forEach((e=>{n[e.name]={namespace:t.namespace,name:e.name}})),n}(e,t);return c(r,n),r}function u(e){const t=[];switch(e.$class){case`${a}.ImportAll`:t.push(`${e.namespace}.*`);break;case`${a}.ImportType`:t.push(`${e.namespace}.${e.name}`);break;case`${a}.ImportTypes`:e.types.forEach((r=>{t.push(`${e.namespace}.${r}`)}));break;default:throw new Error(`Unrecognized imports ${e.$class}`)}return t}e.exports={metaModelAst:n,metaModelCto:o,resolveLocalNames:l,resolveLocalNamesForAll:function(e){const t={$class:`${a}.Models`,models:[]};return e.models.forEach((r=>{const n=l(e,r);t.models.push(n)})),t},importFullyQualifiedNames:u,getExternalImports:function(e){const t={};return e.imports&&e.imports.forEach((e=>{const r=u(e);e.uri&&(t[r[0]]=e.uri)})),t}}},3832:(e,t,r)=>{"use strict";const n=r(5558),{DefaultFileLoader:a,FileDownloader:o,ModelWriter:s}=r(8487),{MetaModelUtil:i,MetaModelNamespace:c}=r(3348),l=r(1595),u=r(2438),p=r(1861),d=r(6226),m=r(1768),h=r(3673),f=r(5477),{getRootModel:g}=r(6128),{getDecoratorModel:y}=r(1051),v=r(5430);void 0===r.g&&(r(5437),r(953),r(9869),r(3135),r(6341),r(8088),r(2302),r(7337),r(3218),r(745));const $=r(7833)("concerto:BaseModelManager"),A=(e,t)=>({ast:t,definitions:null,fileName:e}),b={missingDecorator:void 0,invalidDecorator:void 0},T=["concerto@1.0.0","concerto","concerto.decorator@1.0.0"];class C{constructor(e,t){this.processFile=t||A,this.modelFiles={},this.factory=new l(this),this.serializer=new h(this.factory,this,e),this.decoratorFactories=[],this.strict=!!e?.strict,this.options=e,this.addDecoratorModel(),this.addRootModel(),this.decoratorValidation=e?.decoratorValidation?e?.decoratorValidation:b,this.enableMapType=!!e?.enableMapType,this.importAliasing="true"==={NODE_ENV:"production"}?.IMPORT_ALIASING||!!e?.importAliasing,this.metamodelModelFile=new d(this,i.metaModelAst,void 0,c),e?.addMetamodel&&this.addModelFile(this.metamodelModelFile)}isModelManager(){return!0}isStrict(){return this.strict}isAliasedTypeEnabled(){return this.importAliasing}addRootModel(){const{rootModelAst:e,rootModelCto:t,rootModelFile:r}=g(!0),n=new d(this,e,t,r);if(this.strict)this.addModelFile(n,t,r,!0);else{this.addModelFile(n,t,r,!0);const e=g(!1),a=new d(this,e.rootModelAst,e.rootModelCto,e.rootModelFile);this.addModelFile(a,e.rootModelCto,e.rootModelFile,!0)}}addDecoratorModel(){const{decoratorModelAst:e,decoratorModelCto:t,decoratorModelFile:r}=y(),n=new d(this,e,t,r);this.addModelFile(n,t,r,!0)}accept(e,t){return e.visit(this,t)}validateModelFile(e,t){if("string"==typeof e){const{ast:r}=this.processFile(t,e);new d(this,r,e,t).validate()}else e.validate()}_throwAlreadyExists(e){const t=this.modelFiles[e.getNamespace()].getName(),r=t?` in file ${t}`:"",n=e.getName()?` specified in file ${e.getName()}`:"";let a=`Namespace ${e.getNamespace()}${n} is already declared${r}`;throw new Error(a)}addModelFile(e,t,r,n){if($("addModelFile","addModelFile",e,r),this.isStrict()&&!e.getVersion())throw new Error("Cannot add an unversioned namespace when 'strict' is true");return this.modelFiles[e.getNamespace()]?this._throwAlreadyExists(e):(n||(this.options?.metamodelValidation&&this.validateAst(e),e.validate()),this.modelFiles[e.getNamespace()]=e),e}validateAst(e){const{version:t}=m.parseNamespace(m.getNamespace(e.getAst().$class)),{version:r}=m.parseNamespace(c);if(t!==r)throw new v(`Model file version ${t} does not match metamodel version ${r}`);const n=!!this.getModelFile(c);n||this.addModelFile(this.metamodelModelFile,void 0,c,!0);try{this.getSerializer().fromJSON(e.getAst())}catch(e){if(this.isStrict())throw new v(e.message);console.warn("Invalid metamodel found. This will throw an exception in a future release. ",e.message)}n||this.deleteModelFile(c)}addModel(e,t,r,n){$("addModel","addModel",e,r);const{ast:a,definitions:o}=this.processFile(r,e),s=t||o,i=new d(this,a,s,r);return this.addModelFile(i,s,r,n),i}updateModelFile(e,t,r){if($("updateModelFile","updateModelFile",e,t),"string"==typeof e){const{ast:n}=this.processFile(t,e);let a=new d(this,n,e,t);return this.updateModelFile(a,t,r)}if(!this.modelFiles[e.getNamespace()])throw new Error(`Model file for namespace ${e.getNamespace()} not found`);return r||e.validate(),this.modelFiles[e.getNamespace()]=e,e}deleteModelFile(e){if(!this.modelFiles[e])throw new Error("Model file does not exist");delete this.modelFiles[e]}addModelFiles(e,t,r){const n="addModelFiles";$(n,"addModelFiles",e,t);const a={};Object.assign(a,this.modelFiles);let o=[];try{for(let r=0;r<e.length;r++){const n=e[r];let a,s=null;if(t&&(s=t[r]),"string"==typeof n){const{ast:e}=this.processFile(s,n);a=new d(this,e,n,s)}else a=n;this.modelFiles[a.getNamespace()]?this._throwAlreadyExists(a):(this.modelFiles[a.getNamespace()]=a,o.push(a))}return r||this.validateModelFiles(),o}catch(e){throw this.modelFiles={},Object.assign(this.modelFiles,a),e}finally{$(n,o)}}validateModelFiles(){for(let e in this.modelFiles)this.modelFiles[e].validate()}async updateExternalModels(e,t){$("updateExternalModels","updateExternalModels",e),t||(t=new o(new a(this.processFile),(e=>i.getExternalImports(e.ast))));const r={};Object.assign(r,this.modelFiles);try{const r=await t.downloadExternalDependencies(this.getModelFiles(),e),n=[];return r.forEach((e=>{const t=new d(this,e.ast,e.definitions,e.fileName);this.modelFiles[t.getNamespace()]?n.push(this.updateModelFile(t,t.getName(),!0)):n.push(this.addModelFile(t,null,t.getName(),!0))})),this.validateModelFiles(),n}catch(e){throw this.modelFiles={},Object.assign(this.modelFiles,r),e}}writeModelsToFileSystem(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};s.writeModelsToFileSystem(this.getModelFiles(),e,t)}getDecoratorValidation(){return this.decoratorValidation}getModelFiles(e){let t=Object.keys(this.modelFiles),r=[];for(let n=0;n<t.length;n++){const a=t[n];!e&&T.includes(a)||r.push(this.modelFiles[a])}return r}getModels(e){const t=this.getModelFiles();let r=[];const a=Object.assign({includeExternalModels:!0},e);return t.forEach((function(e){if(e.isExternal()&&!a.includeExternalModels)return;let t;if("UNKNOWN"!==e.fileName&&null!==e.fileName&&e.fileName){let r=e.fileName;t=n.basename(r)}else t=e.namespace+".cto";r.push({name:t,content:e.definitions})})),r}resolveType(e,t){if(m.isPrimitiveType(t))return t;let r=m.getNamespace(t),n=this.getModelFile(r);if(!n){let r=u.messageFormatter("modelmanager-resolvetype-nonsfortype");throw new p(r({type:t,context:e}))}if(n.isLocalType(t))return t;let a=u.messageFormatter("modelmanager-resolvetype-notypeinnsforcontext");throw new p(a({context:e,type:t,namespace:n.getNamespace()}))}clearModelFiles(){this.modelFiles={},this.addDecoratorModel(),this.addRootModel()}getModelFile(e){return this.modelFiles[e]}getModelFileByFileName(e){return this.getModelFiles().filter((t=>t.getName()===e))[0]}getNamespaces(){return Object.keys(this.modelFiles)}getType(e){const t=m.getNamespace(e),r=this.getModelFile(t);if(!r){const t=u.messageFormatter("modelmanager-gettype-noregisteredns");throw new f(e,t({type:e}))}const n=r.getType(e);if(!n){const r=u.messageFormatter("modelmanager-gettype-notypeinns");throw new f(e,r({type:m.getShortName(e),namespace:t}))}return n}getAssetDeclarations(){return this.getModelFiles().reduce(((e,t)=>e.concat(t.getAssetDeclarations())),[])}getTransactionDeclarations(){return this.getModelFiles().reduce(((e,t)=>e.concat(t.getTransactionDeclarations())),[])}getEventDeclarations(){return this.getModelFiles().reduce(((e,t)=>e.concat(t.getEventDeclarations())),[])}getParticipantDeclarations(){return this.getModelFiles().reduce(((e,t)=>e.concat(t.getParticipantDeclarations())),[])}getMapDeclarations(){return this.getModelFiles().reduce(((e,t)=>e.concat(t.getMapDeclarations())),[])}getEnumDeclarations(){return this.getModelFiles().reduce(((e,t)=>e.concat(t.getEnumDeclarations())),[])}getConceptDeclarations(){return this.getModelFiles().reduce(((e,t)=>e.concat(t.getConceptDeclarations())),[])}getFactory(){return this.factory}getSerializer(){return this.serializer}getDecoratorFactories(){return this.decoratorFactories}addDecoratorFactory(e){this.decoratorFactories.push(e)}derivesFrom(e,t){let r=this.getType(e);for(;r;){if(r.getFullyQualifiedName()===t)return!0;r=r.getSuperTypeDeclaration()}return!1}resolveMetaModel(e){const t=this.getAst(!1,!0);return i.resolveLocalNames(t,e)}fromAst(e){this.clearModelFiles(),e.models.forEach((e=>{if(!T.includes(e.namespace)){const t=new d(this,e);this.addModelFile(t,null,null,!0)}})),this.validateModelFiles()}getAst(e,t){const r={$class:`${c}.Models`,models:[]};return this.getModelFiles(t).forEach((t=>{let n=t.getAst();e&&(n=this.resolveMetaModel(n)),r.models.push(n)})),r}filter(e){const t=new C({...this.options},this.processFile),r=[];let n=Object.values(this.modelFiles).map((n=>n.filter(e,t,r))).filter(Boolean);n=n.filter((e=>!e.isSystemModelFile()));const a=n.map((e=>{const t=e.getAst();let n=!1;return r.forEach((r=>{const a=m.getNamespace(r);if(!a.startsWith("concerto@")&&"concerto"!==a&&e.getImports().includes(r)){const e=m.getShortName(r),a=m.getNamespace(r);t.imports=t.imports.filter((t=>{const r="ImportType"===m.getShortName(t.$class)&&t.name===e&&t.namespace===a;return r&&(n=!0),!r})),t.imports.forEach((t=>{t.namespace===a&&"ImportTypes"===m.getShortName(t.$class)&&(t.types=t.types.filter((t=>{const r=t===e;return r&&(n=!0),!r})))}))}})),n?new d(this,t,void 0,e.fileName):e}));return t.addModelFiles(a),t}}e.exports=C},7662:(e,t,r)=>{"use strict";const n=r(9472),a="resource",{TypedStack:o}=r(8487),s=r(3561);void 0===r.g&&r(9481),e.exports=class{constructor(e){this.modelManager=e}validate(e,t){const r=this.getTypeDeclaration(e),n={};n.stack=new o(e);const a=new s(this,t);r.accept(a,n)}getModelManager(){return this.modelManager}isObject(e){return"object"==typeof e&&e.$class}getTypeDeclaration(e){if(!e.$class)throw new Error("Input object does not have a $class attribute.");return this.modelManager.getType(e.$class)}getIdentifier(e){const t=this.getTypeDeclaration(e).getIdentifierFieldName();if(!t)throw new Error(`Object does not have an identifier: ${JSON.stringify(e)}`);return e[t]}isIdentifiable(e){const t=this.getTypeDeclaration(e);return!t.isSystemIdentified()&&null!==t.getIdentifierFieldName()}isRelationship(e){return"string"==typeof e&&e.startsWith(`${a}:`)}setIdentifier(e,t){const r=this.getTypeDeclaration(e).getIdentifierFieldName(),n=JSON.parse(JSON.stringify(e));return n[r]=t,n}getFullyQualifiedIdentifier(e){return this.getTypeDeclaration(e),`${e.$class}#${this.getIdentifier(e)}`}toURI(e){return this.getTypeDeclaration(e),`${a}:${e.$class}#${encodeURI(this.getIdentifier(e))}`}fromURI(e){let t;try{t=n.parse(e)}catch(t){throw new Error("Invalid URI: "+e)}const r=t.protocol;if(r&&r!==a)throw new Error("Invalid URI scheme: "+e);if(t.username||t.password||t.port||t.query)throw new Error("Invalid resource URI format: "+e);return{typeDeclaration:this.getTypeDeclaration({$class:t.path}),id:decodeURIComponent(t.fragment)}}getType(e){return this.getTypeDeclaration(e).getName()}getNamespace(e){return this.getTypeDeclaration(e).getNamespace()}}},7624:(e,t,r)=>{"use strict";const n=r(3464),a=r(7657);n.extend(a);const o=r(4491);n.extend(o);const s=r(3221);n.extend(s);const i=r(279);n.extend(i),e.exports={setCurrentTime:function(e,t){const r="number"==typeof t?t:n().utcOffset(),a=e?n.utc(e):n().utc();if(!a.isValid())throw new Error(`Current time '${e}' is not in standard UTC format`);const o=a.utcOffset(r);if(!o.isValid())throw new Error(`Cannot set current time to '${e}' with UTC offset '${t}'`);return{currentTime:o,utcOffset:r}}}},8298:(e,t,r)=>{"use strict";const n=r(9481),a=r(1768),{MetaModelNamespace:o}=r(3348);class s{static Action={EXTRACT_ALL:0,EXTRACT_VOCAB:1,EXTRACT_NON_VOCAB:2};constructor(e,t,r,n){let a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:s.Action.EXTRACT_ALL;this.extractionDictionary={},this.removeDecoratorsFromModel=e,this.locale=t,this.dcs_version=r,this.sourceModelAst=n,this.updatedModelAst=n,this.action=Object.values(s.Action).includes(a)?a:s.Action.EXTRACT_ALL}isVocabDecorator(e){return"Term"===e||e.startsWith("Term_")}constructDCSDictionary(e,t,r){const n={declaration:r?.declaration||"",property:r?.property||"",mapElement:r?.mapElement||"",dcs:JSON.stringify(t)};this.extractionDictionary[e]&&Array.isArray(this.extractionDictionary[e])?this.extractionDictionary[e].push(n):this.extractionDictionary[e]=[n]}transformNonVocabularyDecorators(e,t,r){const{name:n,version:o}=a.parseNamespace(t),s=n,i=o;if(e?.length>0){const t={$class:`org.accordproject.decoratorcommands@${this.dcs_version}.DecoratorCommandSet`,name:s,version:i,commands:e};r.push(t)}return r}transformVocabularyDecorators(e,t,r){if(Object.keys(e).length>0){let n="";n+=`locale: ${this.locale}\n`,n+=`namespace: ${t}\n`,n+="declarations:\n",Object.keys(e).forEach((t=>{e[t].term&&(n+=` - ${t}: ${e[t].term}\n`);const r=Object.keys(e[t]).filter((e=>"term"!==e&&"propertyVocabs"!==e));r.length>0&&(e[t].term||(n+=` - ${t}: ${t}\n`),r.forEach((r=>{n+=` ${r}: ${e[t][r]}\n`}))),e[t].propertyVocabs&&Object.keys(e[t].propertyVocabs).length>0&&(e[t].term||0!==r.length||(n+=` - ${t}: ${t}\n`),n+=" properties:\n",Object.keys(e[t].propertyVocabs).forEach((r=>{n+=` - ${r}: ${e[t].propertyVocabs[r].term||""}\n`,Object.keys(e[t].propertyVocabs[r]).filter((e=>"term"!==e)).forEach((a=>{n+=` ${a}: ${e[t].propertyVocabs[r][a]}\n`}))})))})),r.push(n)}return r}constructTarget(e,t){const r={$class:`org.accordproject.decoratorcommands@${this.dcs_version}.CommandTarget`,namespace:e};return t.declaration&&""!==t.declaration&&(r.declaration=t.declaration),t.property&&""!==t.property&&(r.property=t.property),t.mapElement&&""!==t.mapElement&&(r.mapElement=t.mapElement),r}parseNonVocabularyDecorators(e,t,r,n){const a={$class:"concerto.metamodel@1.0.0.Decorator",name:t.name};if(t.arguments){const e=t.arguments.map((e=>({$class:e.$class,value:e.value})));a.arguments=e}let o={$class:`org.accordproject.decoratorcommands@${r}.Command`,type:"UPSERT",target:n,decorator:a};return e.push(o),e}parseVocabularies(e,t,r){if(e[t.declaration]=e[t.declaration]||{propertyVocabs:{}},""!==t.property)if(e[t.declaration].propertyVocabs[t.property]||(e[t.declaration].propertyVocabs[t.property]={}),"Term"===r.name)e[t.declaration].propertyVocabs[t.property].term=r.arguments[0].value;else{const n=r.name.split("Term_")[1];e[t.declaration].propertyVocabs[t.property][n]=r.arguments[0].value}else if(""!==t.mapElement)if(e[t.declaration].propertyVocabs[t.mapElement]||(e[t.declaration].propertyVocabs[t.mapElement]={}),"Term"===r.name)e[t.declaration].propertyVocabs[t.mapElement].term=r.arguments[0].value;else{const n=r.name.split("Term_")[1];e[t.declaration].propertyVocabs[t.mapElement][n]=r.arguments[0].value}else if("Term"===r.name)e[t.declaration].term=r.arguments[0].value;else{const n=r.name.split("Term_")[1];e[t.declaration][n]=r.arguments[0].value}return e}transformDecoratorsAndVocabularies(){let e=[],t=[];return Object.keys(this.extractionDictionary).forEach((r=>{const n=this.extractionDictionary[r];let a=[],o={};n.forEach((e=>{const t=JSON.parse(e.dcs),n=this.constructTarget(r,e);t.forEach((t=>{const r=this.isVocabDecorator(t.name);r||this.action===s.Action.EXTRACT_VOCAB||(a=this.parseNonVocabularyDecorators(a,t,this.dcs_version,n)),r&&this.action!==s.Action.EXTRACT_NON_VOCAB&&(o=this.parseVocabularies(o,e,t))}))})),this.action!==s.Action.EXTRACT_VOCAB&&(e=this.transformNonVocabularyDecorators(a,r,e)),this.action!==s.Action.EXTRACT_NON_VOCAB&&(t=this.transformVocabularyDecorators(o,r,t))})),{decoratorCommandSet:e,vocabularies:t}}filterOutDecorators(e){return this.removeDecoratorsFromModel?this.action===s.Action.EXTRACT_ALL?void 0:this.action===s.Action.EXTRACT_VOCAB?e.filter((e=>!this.isVocabDecorator(e.name))):e.filter((e=>this.isVocabDecorator(e.name))):e}processMapDeclaration(e,t){if(e.key&&e.key.decorators){const r={declaration:e.name,mapElement:"KEY"};this.constructDCSDictionary(t,e.key.decorators,r),e.key.decorators=this.filterOutDecorators(e.key.decorators)}if(e.value&&e.value.decorators){const r={declaration:e.name,mapElement:"VALUE"};this.constructDCSDictionary(t,e.value.decorators,r),e.value.decorators=this.filterOutDecorators(e.value.decorators)}return e}processProperties(e,t,r){return e.map((e=>{if(e.decorators){const n={declaration:t,property:e.name};this.constructDCSDictionary(r,e.decorators,n),e.decorators=this.filterOutDecorators(e.decorators)}return e}))}processDeclarations(e,t){return e.map((e=>{if(e.decorators){const r={declaration:e.name};this.constructDCSDictionary(t,e.decorators,r),e.decorators=this.filterOutDecorators(e.decorators)}if(e.$class===`${o}.MapDeclaration`&&(e=this.processMapDeclaration(e,t)),e.properties){const r=this.processProperties(e.properties,e.name,t);e.properties=r}return e}))}processModels(){const e=this.sourceModelAst.models.map((e=>{e?.decorators?.length>0&&(this.constructDCSDictionary(e.namespace,e.decorators,{}),e.decorators=this.filterOutDecorators(e.decorators));const t=this.processDeclarations(e.declarations,e.namespace);return e.declarations=t,e}));this.updatedModelAst={...this.updatedModelAst,models:e}}extract(){this.processModels();const e=new n;e.fromAst(this.updatedModelAst);const t=this.transformDecoratorsAndVocabularies();return{updatedModelManager:e,decoratorCommandSet:t.decoratorCommandSet,vocabularies:t.vocabularies}}}e.exports=s},6033:(e,t,r)=>{"use strict";const n=r(9481),a=r(3673),o=r(1595),s=r(1768),{MetaModelNamespace:i}=r(3348),c=r(2722),l=r(8298),{Warning:u,ErrorCodes:p}=r(8487);void 0===r.g&&r(6226);const d="0.4.0",m="concerto version \"^3.0.0\"\nnamespace org.accordproject.decoratorcommands@0.4.0\n\nimport concerto.metamodel@1.0.0.Decorator\n\n/**\n * A reference to an existing named & versioned DecoratorCommandSet\n */\nconcept DecoratorCommandSetReference {\n o String name\n o String version\n}\n\n/**\n * Whether to upsert or append the decorator\n */\nenum CommandType {\n o UPSERT\n o APPEND\n}\n\n/**\n * Which models elements to add the decorator to. Any null\n * elements are 'wildcards'.\n */\nconcept CommandTarget {\n o String namespace optional\n o String declaration optional\n o String property optional\n o String[] properties optional // property and properties are mutually exclusive\n o String type optional\n o MapElement mapElement optional\n}\n\n/**\n * Map Declaration elements which might be used as a target\n */\nenum MapElement {\n o KEY\n o VALUE\n o KEY_VALUE\n}\n\n/**\n * Applies a decorator to a given target\n */\nconcept Command {\n o CommandTarget target\n o Decorator decorator\n o CommandType type\n o String decoratorNamespace optional\n}\n\n/**\n * A named and versioned set of commands. Includes are supported for modularity/reuse.\n */\nconcept DecoratorCommandSet {\n o String name\n o String version\n o DecoratorCommandSetReference[] includes optional // not yet supported\n o Command[] commands\n}\n";class h{constructor(e,t){this.command=e,this.index=t}getCommand(){return this.command}getIndex(){return this.index}}class f{static validate(e,t){const r=new n({strict:!0,metamodelValidation:!0,addMetamodel:!0});t&&r.addModelFiles(t),r.addCTOModel(m,"decoratorcommands@0.3.0.cto");const s=new o(r);return new a(s,r).fromJSON(e),r}static migrateTo(e,t){if(e instanceof Object)for(let r in e){if("$class"===r&&e[r].includes("org.accordproject.decoratorcommands")){const t=s.getNamespace(e.$class);e[r]=e[r].replace(s.parseNamespace(t).version,d)}(e[r]instanceof Object||e[r]instanceof Array)&&this.migrateTo(e[r],t)}return e}static canMigrate(e,t){const r=s.parseNamespace(s.getNamespace(e.$class)).version;return c.major(r)===c.major(t)&&c.minor(r)<c.minor(t)}static addDcsWithIndexToMap(e,t,r){const n=e.get(t);n?n.push(r):e.set(t,[r])}static getDecoratorMaps(e){const t=new Map,r=new Map,n=new Map,a=new Map,o=new Map;return e.commands.map(((e,s)=>{const i=new h(e,s);switch(!0){case!!e?.target?.type:this.addDcsWithIndexToMap(o,e.target.type,i);break;case!!e?.target?.property:this.addDcsWithIndexToMap(n,e.target.property,i);break;case!!e?.target?.properties:e.target.properties.forEach((e=>{this.addDcsWithIndexToMap(n,e,i)}));break;case!!e?.target?.mapElement:this.addDcsWithIndexToMap(a,e.target.mapElement,i);break;case!!e?.target?.declaration:this.addDcsWithIndexToMap(r,e.target.declaration,i);break;case!!e?.target?.namespace:this.addDcsWithIndexToMap(t,e.target.namespace,i)}})),{namespaceCommandsMap:t,declarationCommandsMap:r,propertyCommandsMap:n,mapElementCommandsMap:a,typeCommandsMap:o}}static migrateAndValidate(e,t,r,s,i){if(r&&this.canMigrate(t,d)&&(t=this.migrateTo(t,d)),s){const r=new n({strict:!0,metamodelValidation:!0,addMetamodel:!0,enableMapType:!!e?.enableMapType,importAliasing:e.isAliasedTypeEnabled()});r.addModelFiles(e.getModelFiles()),r.addCTOModel(m,"decoratorcommands@0.4.0.cto");const s=new o(r);new a(s,r).fromJSON(t),i&&t.commands.forEach((e=>{f.validateCommand(r,e)}))}}static pushMapValues(e,t,r){const n=t.get(r);n&&e.push(...n)}static decorateModels(e,t,r){this.migrateAndValidate(e,t,r?.migrate,r?.validate,r?.validateCommands);const a=t.commands.map((e=>[{$class:`${i}.ImportType`,name:e.decorator.name,namespace:e.decorator.namespace?e.decorator.namespace:r?.defaultNamespace}].concat(e.decorator.arguments?e.decorator.arguments?.filter((e=>e.type)).map((e=>({$class:`${i}.ImportType`,name:e.type.name,namespace:e.type.namespace?e.type.namespace:r?.defaultNamespace}))):[]))).flat().filter((e=>e.namespace)),{namespaceCommandsMap:o,declarationCommandsMap:c,propertyCommandsMap:l,mapElementCommandsMap:u,typeCommandsMap:p}=this.getDecoratorMaps(t),d=e.getAst(!0,!0),m=JSON.parse(JSON.stringify(d));m.models.forEach((e=>{const t=a.filter((t=>t.namespace!==e.namespace));e.imports=e.imports?e.imports.concat(t):t,e.declarations.forEach((t=>{const n=[],{name:a,$class:d}=t;this.pushMapValues(n,c,a),this.pushMapValues(n,o,e.namespace);const m=s.parseNamespace(e.namespace).name;if(this.pushMapValues(n,o,m),this.pushMapValues(n,p,d),n.sort(((e,t)=>e.getIndex()-t.getIndex())).forEach((n=>{this.executeCommand(e.namespace,t,n.getCommand(),null,r),this.isNamespaceTargetEnabled(r?.enableDcsNamespaceTarget)&&this.executeNamespaceCommand(e,n.getCommand())})),d===`${i}.MapDeclaration`){const r=[];this.pushMapValues(r,p,t.key.$class),this.pushMapValues(r,p,t.value.$class),this.pushMapValues(r,u,"KEY"),this.pushMapValues(r,u,"VALUE"),this.pushMapValues(r,u,"KEY_VALUE"),r.sort(((e,t)=>e.getIndex()-t.getIndex())).forEach((r=>{this.executeCommand(e.namespace,t,r.getCommand())}))}t.properties&&t.properties.forEach((r=>{const n=[],{name:a,$class:o}=r;this.pushMapValues(n,l,a),this.pushMapValues(n,p,o),n.sort(((e,t)=>e.getIndex()-t.getIndex())).forEach((n=>{this.executeCommand(e.namespace,t,n.getCommand(),r)}))}))}))}));const h=!!e?.enableMapType,f=new n({strict:e.isStrict(),enableMapType:h,importAliasing:e.isAliasedTypeEnabled(),decoratorValidation:e.getDecoratorValidation()});return f.fromAst(m),f}static extractDecorators(e,t){t={removeDecoratorsFromModel:!1,locale:"en",...t};const r=e.getAst(!0,!0),n=new l(t.removeDecoratorsFromModel,t.locale,d,r,l.Action.EXTRACT_ALL).extract();return{modelManager:n.updatedModelManager,decoratorCommandSet:n.decoratorCommandSet,vocabularies:n.vocabularies}}static extractVocabularies(e,t){t={removeDecoratorsFromModel:!1,locale:"en",...t};const r=e.getAst(!0,!0),n=new l(t.removeDecoratorsFromModel,t.locale,d,r,l.Action.EXTRACT_VOCAB).extract();return{modelManager:n.updatedModelManager,vocabularies:n.vocabularies}}static extractNonVocabDecorators(e,t){t={removeDecoratorsFromModel:!1,locale:"en",...t};const r=e.getAst(!0),n=new l(t.removeDecoratorsFromModel,t.locale,d,r,l.Action.EXTRACT_NON_VOCAB).extract();return{modelManager:n.updatedModelManager,decoratorCommandSet:n.decoratorCommandSet}}static validateCommand(e,t){t.target.type&&e.resolveType("DecoratorCommand.type",t.target.type);let r=null;if(t.target.namespace&&(r=e.getModelFile(t.target.namespace),!r)){const{name:n,version:a}=s.parseNamespace(t.target.namespace);a||(r=e.getModelFiles().find((e=>function(e,t){const{name:r}=s.parseNamespace(e.getNamespace());return r===t}(e,n))))}if(t.target.namespace&&!r)throw new Error(`Decorator Command references namespace "${t.target.namespace}" which does not exist: ${JSON.stringify(t,null,2)}`);if(t.target.namespace&&t.target.declaration&&e.resolveType("DecoratorCommand.target.declaration",`${r.getNamespace()}.${t.target.declaration}`),t.target.properties&&t.target.property)throw new Error("Decorator Command references both property and properties. You must either reference a single property or a list of properites.");if(t.target.namespace&&t.target.declaration&&t.target.property&&!e.getType(`${r.getNamespace()}.${t.target.declaration}`).getProperty(t.target.property))throw new Error(`Decorator Command references property "${t.target.namespace}.${t.target.declaration}.${t.target.property}" which does not exist.`);if(t.target.namespace&&t.target.declaration&&t.target.properties){const n=e.getType(`${r.getNamespace()}.${t.target.declaration}`);t.target.properties.forEach((e=>{if(!n.getProperty(e))throw new Error(`Decorator Command references property "${t.target.namespace}.${t.target.declaration}.${e}" which does not exist.`)}))}}static applyDecoratorForMapElement(e,t,r,n,a){const o="KEY"===e?r.key:r.value;t.type?this.falsyOrEqual(t.type,o.$class)&&this.applyDecorator(o,n,a):this.applyDecorator(o,n,a)}static falsyOrEqual(e,t){return Array.isArray(e)?function(e,t){const r=new Set(e),n=new Set(t),a=new Set([...r].filter((e=>n.has(e))));return Array.from(a)}(e,t).length>0:!e||t.includes(e)}static applyDecorator(e,t,r){if("UPSERT"===t){let t=!1;if(e.decorators)for(let n=0;n<e.decorators.length;n++)e.decorators[n].name===r.name&&(e.decorators[n]=r,t=!0);t||(e.decorators?e.decorators.push(r):e.decorators=[r])}else{if("APPEND"!==t)throw new Error(`Unknown command type ${t}`);e.decorators?e.decorators.push(r):e.decorators=[r]}}static executeNamespaceCommand(e,t){const{target:r,decorator:n,type:a}=t;if(2===Object.keys(r).length&&r.namespace){const{name:t}=s.parseNamespace(e.namespace);this.falsyOrEqual(r.namespace,[e.namespace,t])&&this.applyDecorator(e,a,n)}}static executeCommand(e,t,r,n,a){const{target:o,decorator:c,type:l}=r,{name:u}=s.parseNamespace(e);if(this.falsyOrEqual(o.namespace,[e,u])&&this.falsyOrEqual(o.declaration,[t.name]))if(t.$class===`${i}.MapDeclaration`)if(o.mapElement)switch(o.mapElement){case"KEY":case"VALUE":this.applyDecoratorForMapElement(o.mapElement,o,t,l,c);break;case"KEY_VALUE":this.applyDecoratorForMapElement("KEY",o,t,l,c),this.applyDecoratorForMapElement("VALUE",o,t,l,c)}else o.type?(this.falsyOrEqual(o.type,t.key.$class)&&this.applyDecorator(t.key,l,c),this.falsyOrEqual(o.type,t.value.$class)&&this.applyDecorator(t.value,l,c)):this.checkForNamespaceTargetAndApplyDecorator(t,l,c,o,a?.enableDcsNamespaceTarget);else o.property||o.properties||o.type?n&&this.executePropertyCommand(n,r):this.checkForNamespaceTargetAndApplyDecorator(t,l,c,o,a?.enableDcsNamespaceTarget)}static executePropertyCommand(e,t){const{target:r,decorator:n,type:a}=t;(r.properties||r.property||r.type)&&this.falsyOrEqual(r.property?r.property:r.properties,[e.name])&&this.falsyOrEqual(r.type,[e.$class])&&this.applyDecorator(e,a,n)}static checkForNamespaceTargetAndApplyDecorator(e,t,r,n,a){this.isNamespaceTargetEnabled(a)?n.declaration&&this.applyDecorator(e,t,r):this.applyDecorator(e,t,r)}static isNamespaceTargetEnabled(e){return!(!e&&"true"!=={NODE_ENV:"production"}.ENABLE_DCS_NAMESPACE_TARGET&&(u.printDeprecationWarning("Functionality for namespace targeted Decorator Command Sets has changed. Using namespace targets to apply decorators on all declarations in a namespace will be deprecated soon.",p.DEPRECATION_WARNING,p.CONCERTO_DEPRECATION_001,"Please refer to https://concerto.accordproject.org/deprecation/001"),1))}}e.exports=f},1051:(e,t,r)=>{"use strict";const n=r(480);e.exports={getDecoratorModel:function(){return{decoratorModelFile:"concerto_decorator_1.0.0.cto",decoratorModelCto:"namespace concerto.decorator@1.0.0\n abstract concept Decorator {}\n concept DotNetNamespace extends Decorator {\n o String namespace\n }",decoratorModelAst:JSON.parse(JSON.stringify(n))}}}},1595:(e,t,r)=>{"use strict";const{TypedStack:n}=r(8487),a=r(7833)("concerto:Factory"),o=r(2438),s=r(1768),i=r(6422),c=r(7854),l=r(2552),u=r(6113),p=r(7755),d=r(289),m=r(182),h=r(3464),f=r(7657);h.extend(f),void 0===r.g&&r(9481);class g{static newId(){return m.v4()}constructor(e){this.modelManager=e}newResource(e,t,r,n){n=n||{};const i=s.getFullyQualifiedName(e,t),c=this.modelManager.getType(i);if(c.isAbstract()){let r=o.messageFormatter("factory-newinstance-abstracttype");throw new Error(r({namespace:e,type:t}))}let u=c.getIdentifierFieldName();if(c.isSystemIdentified()&&(r=null==r?g.newId():r),u){if("string"!=typeof r){let r=o.messageFormatter("factory-newinstance-invalididentifier");throw new Error(r({namespace:e,type:t}))}if(0===r.trim().length){let r=o.messageFormatter("factory-newinstance-missingidentifier");throw new Error(r({namespace:e,type:t}))}if(r){let e=c.getProperty(u);if(e?.isTypeScalar?.()&&(e=e.getScalarField()),e?.validator?.regex&&!1===e.validator?.regex.test(r))throw new Error("Provided id does not match regex: "+e?.validator?.regex)}}else if(r)throw new Error("Type is not identifiable "+c.getFullyQualifiedName());let m=null,f=null;return(c.isTransaction()||c.isEvent())&&(f=h.utc()),m=n.disableValidation?new p(this.modelManager,c,e,t,r,f):new d(this.modelManager,c,e,t,r,f,new l),m.assignFieldDefaults(),this.initializeNewObject(m,c,n),u&&(m[u]=r),a("newResource","Factory.newResource created ",r||"valid"),m}newConcept(e,t,r,n){return this.newResource(e,t,r,n)}newRelationship(e,t,r){const n=s.getFullyQualifiedName(e,t),a=this.modelManager.getType(n);if(!a.isIdentified())throw new Error(`Cannot create a relationship to ${n}, it is not identifiable.`);return new u(this.modelManager,a,e,t,r)}newTransaction(e,t,r,n){if(!e)throw new Error("ns not specified");if(!t)throw new Error("type not specified");let a=this.newResource(e,t,r,n);if(!a.getClassDeclaration().isTransaction())throw new Error(a.getClassDeclaration().getFullyQualifiedName()+" is not a transaction");return a}newEvent(e,t,r,n){if(!e)throw new Error("ns not specified");if(!t)throw new Error("type not specified");let a=this.newResource(e,t,r,n);if(!a.getClassDeclaration().isEvent())throw new Error(a.getClassDeclaration().getFullyQualifiedName()+" is not an event");return a}initializeNewObject(e,t,r){const a=this.parseGenerateOptions(r);if(a){a.stack=new n(e),a.seen=[e.getFullyQualifiedType()];const r=new i;t.accept(r,a)}}parseGenerateOptions(e){if(!e.generate)return null;const t={};return t.modelManager=this.modelManager,t.factory=this,/^empty$/i.test(e.generate)?t.valueGenerator=c.empty():t.valueGenerator=c.sample(),t.includeOptionalFields=!!e.includeOptionalFields,t}}e.exports=g},2438:(e,t,r)=>{"use strict";const n=r(8168);function a(e){return function(t){let r=n.en[e];for(let e in t)r=r.replace(new RegExp(`\\{${e}\\}`,"g"),t[e]);return r}}function o(e){return n.en[e]}function s(e){return{messageFormatter:a,formatMessage:o}}s.messageFormatter=a,s.formatMessage=o,e.exports=s},953:(e,t,r)=>{"use strict";const n=r(8058);void 0===r.g&&r(6226),e.exports=class extends n{constructor(e,t){super(e,t)}declarationKind(){return"AssetDeclaration"}}},9869:(e,t,r)=>{"use strict";const{MetaModelNamespace:n}=r(3348),a=r(5437),o=r(8171),s=r(1529),i=r(2438),c=r(1861),l=r(4471),u=r(6099),p=r(1768);void 0===r.g&&r(9852),e.exports=class extends a{process(){if(super.process(),this.properties=[],this.superType=null,this.superTypeDeclaration=null,this.idField=null,this.timestamped=!1,this.abstract=!1,this.type=this.ast.$class,this.ast.isAbstract&&(this.abstract=!0),this.ast.superType?this.superType=this.ast.superType.name:this.modelFile.isSystemModelFile()&&"Concept"===this.name||(this.superType="Concept"),this.ast.identified&&(this.ast.identified.$class===`${n}.IdentifiedBy`?this.idField=this.ast.identified.name:(this.idField="$identifier",this.addIdentifierField())),!Array.isArray(this.ast.properties)){let e=i.messageFormatter("classdeclaration-validate-undefined-properties");throw new c(e({class:this.name}),this.modelFile,this.ast.location)}for(let e=0;e<this.ast.properties.length;e++){let t=this.ast.properties[e];if(p.isSystemProperty(t.name))throw new c(`Invalid field name '${t.name}'`,this.modelFile,this.ast.location);if(t.$class===`${n}.RelationshipProperty`)this.properties.push(new u(this,t));else if(t.$class===`${n}.EnumProperty`)this.properties.push(new o(this,t));else{if(t.$class!==`${n}.BooleanProperty`&&t.$class!==`${n}.StringProperty`&&t.$class!==`${n}.IntegerProperty`&&t.$class!==`${n}.LongProperty`&&t.$class!==`${n}.DoubleProperty`&&t.$class!==`${n}.DateTimeProperty`&&t.$class!==`${n}.ObjectProperty`){let e=i.messageFormatter("classdeclaration-process-unrecmodelelem");throw new c(e({type:t.$class}),this.modelFile,this.ast.location)}this.properties.push(new s(this,t))}}"concerto@1.0.0.Transaction"!==this.fqn&&"concerto@1.0.0.Event"!==this.fqn||this.addTimestampField()}addTimestampField(){const e={};e.$class=`${n}.DateTimeProperty`,e.name="$timestamp",this.properties.push(new s(this,e))}addIdentifierField(){const e={};e.$class=`${n}.StringProperty`,e.name="$identifier",this.properties.push(new s(this,e))}_resolveSuperType(){if(!this.superType)return null;this.superTypeDeclaration=null;let e=null;if(this.getModelFile().isImportedType(this.superType)){let t=this.getModelFile().resolveImport(this.superType);e=this.modelFile.getModelManager().getType(t)}else e=this.getModelFile().getType(this.superType);if(!e)throw new c("Could not find super type "+this.superType,this.modelFile,this.ast.location);if("ConceptDeclaration"!==e.declarationKind()&&this.declarationKind()!==e.declarationKind())throw new c(`${this.declarationKind()} (${this.getName()}) cannot extend ${e.declarationKind()} (${e.getName()})`,this.modelFile,this.ast.location);return this.superTypeDeclaration=e,e}validate(){if(super.validate(),null!==this.superType){if(this.superType===this.name&&!["Asset","Concept","Event","Participant","Transaction"].includes(this.superType)){let e=i("en").messageFormatter("classdeclaration-validate-selfextending");throw new c(e({class:this.name}),this.modelFile,this.ast.location)}this._resolveSuperType()}if(this.idField){const e=this.getProperty(this.idField);if(!e){let e=i("en").messageFormatter("classdeclaration-validate-identifiernotproperty");throw new c(e({class:this.name,idField:this.idField}),this.modelFile,this.ast.location)}{const t="String"===e.getType(),r=e.getParent().getModelFile().getType(e.getType()),n=null!==r&&r.isScalarDeclaration?.()&&"String"===r.getType?.();if(!t&&!n){let e=i("en").messageFormatter("classdeclaration-validate-identifiernotstring");throw new c(e({class:this.name,idField:this.idField}),this.modelFile,this.ast.location)}if(e.isOptional())throw new c("Identifying fields cannot be optional.",this.modelFile,this.ast.location);if(this.superType){const e=this.getModelFile().getType(this.superType);if(e&&e.isIdentified())if(this.isSystemIdentified()){if(!e.isSystemIdentified())throw new c(`Super class ${e.getFullyQualifiedName()} has an explicit identifier ${e.getIdentifierFieldName()} that cannot be redeclared.`,this.modelFile,this.ast.location)}else if(e.isExplicitlyIdentified())throw new c(`Super class ${e.getFullyQualifiedName()} has an explicit identifier ${e.getIdentifierFieldName()} that cannot be redeclared.`,this.modelFile,this.ast.location)}}}const e=this.getProperties(),t=new Set;e.forEach((e=>{const r=e.getName();if(t.has(r)){const e=i("en").messageFormatter("classdeclaration-validate-duplicatefieldname");throw new c(e({class:this.name,fieldName:r}),this.modelFile,this.ast.location)}t.add(r)}));for(let t=0;t<e.length;t++){let r=e[t];if(r.isPrimitive()||this.isEnum()||r.getNamespace()===this.getNamespace())r.validate(this);else{const e=r.getFullyQualifiedTypeName(),t=this.modelFile.getModelManager().getType(e);r.validate(t)}}}isAbstract(){return this.abstract}isIdentified(){return!!this.getIdentifierFieldName()}isSystemIdentified(){return"$identifier"===this.getIdentifierFieldName()}isExplicitlyIdentified(){return!!this.idField&&"$identifier"!==this.idField}getIdentifierFieldName(){if(this.idField)return this.idField;if(this.getSuperType()){let e=this.getModelFile().getLocalType(this.getSuperType());return e||(e=this.modelFile.getModelManager().getType(this.getSuperType())),e.getIdentifierFieldName()}return null}getOwnProperty(e){for(let t=0;t<this.properties.length;t++){const r=this.properties[t];if(r.getName()===e)return r}return null}getOwnProperties(){return this.properties}getSuperType(){const e=this.getSuperTypeDeclaration();return e?e.getFullyQualifiedName():null}getSuperTypeDeclaration(){return this.superType?this.superTypeDeclaration?this.superTypeDeclaration:this._resolveSuperType():null}getAssignableClassDeclarations(){const e=new Set,t=this.getModelFile().getModelManager(),r=new l(t).getClassDeclarations(),n=new Map;r.forEach((e=>{const t=e.getSuperType();if(t){const r=n.get(t)||new Set;r.add(e),n.set(t,r)}}));const a=t=>{t.forEach((t=>{e.add(t);const r=t.getFullyQualifiedName(),o=n.get(r);o&&a(o)}))};return a([this]),Array.from(e)}getDirectSubclasses(){const e=this.getModelFile().getModelManager(),t=new l(e).getClassDeclarations(),r=new Map;t.forEach((e=>{const t=e.getSuperType();if(t){const n=r.get(t)||new Set;n.add(e),r.set(t,n)}}));const n=this.getFullyQualifiedName(),a=r.get(n);return a?Array.from(a):[]}getAllSuperTypeDeclarations(){const e=[];for(let t=this;t=t.getSuperTypeDeclaration();)e.push(t);return e}getProperty(e){let t=this.getOwnProperty(e),r=null;if(null===t&&null!==this.superType){if(this.getModelFile().isImportedType(this.superType)){let e=this.getModelFile().resolveImport(this.superType);r=this.modelFile.getModelManager().getType(e)}else r=this.getModelFile().getType(this.superType);t=r.getProperty(e)}return t}getProperties(){let e=this.getOwnProperties(),t=null;if(null!==this.superType){if(this.getModelFile().isImportedType(this.superType)){let e=this.getModelFile().resolveImport(this.superType);t=this.modelFile.getModelManager().getType(e)}else t=this.getModelFile().getType(this.superType);if(!t)throw new c("Could not find super type "+this.superType,this.modelFile,this.ast.location);e=e.concat(t.getProperties())}return e}getNestedProperty(e){const t=e.split(".");let r=this,n=null;for(let a=0;a<t.length;a++){if(n=r.getProperty(t[a]),null===n)throw new c("Property "+t[a]+" does not exist on "+r.getFullyQualifiedName(),this.modelFile,this.ast.location);if(a<t.length-1){if(n.isPrimitive()||n.isTypeEnum())throw new Error("Property "+t[a]+" is a primitive or enum. Invalid property path: "+e);r=r.getModelFile().getModelManager().getType(n.getFullyQualifiedTypeName())}}return n}toString(){let e="";return this.superType&&(e=" super="+this.superType),"ClassDeclaration {id="+this.getFullyQualifiedName()+e+" enum="+this.isEnum()+" abstract="+this.isAbstract()+"}"}isAsset(){return this.type===`${n}.AssetDeclaration`}isParticipant(){return this.type===`${n}.ParticipantDeclaration`}isTransaction(){return this.type===`${n}.TransactionDeclaration`}isEvent(){return this.type===`${n}.EventDeclaration`}isConcept(){return this.type===`${n}.ConceptDeclaration`}isEnum(){return this.type===`${n}.EnumDeclaration`}isMapDeclaration(){return this.type===`${n}.MapDeclaration`}isClassDeclaration(){return!0}}},6341:(e,t,r)=>{"use strict";const n=r(9869);void 0===r.g&&r(6226),e.exports=class extends n{constructor(e,t){super(e,t)}declarationKind(){return"ConceptDeclaration"}}},5437:(e,t,r)=>{"use strict";const n=r(7688),a=r(1768),o=r(1861);void 0===r.g&&r(6226),e.exports=class extends n{constructor(e,t){super(t),this.modelFile=e,this.process()}process(){if(super.process(),!a.isValidIdentifier(this.ast.name))throw new o(`Invalid class name '${this.ast.name}'`,this.modelFile,this.ast.location);this.name=this.ast.name,this.fqn=a.getFullyQualifiedName(this.modelFile.getNamespace(),this.name)}getModelFile(){return this.