Liferay.Loader.define("portal-workflow-kaleo-designer-web@5.0.92/designer/js/definition-builder/source-builder/xmlDefinition",["module","exports","require","./constants","./xmlSchemaUtil","./xmlUtil"],(function(e,t,i){window;{Object.defineProperty(t,"__esModule",{value:!0}),t.default=XMLDefinition;var o=i("./constants"),s=_interopRequireDefault(i("./xmlSchemaUtil")),a=_interopRequireDefault(i("./xmlUtil"));function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}let e;function XMLDefinition(t){const i=this;e={};const o=i.sanitizeDefinitionXML(t.value);if(!o||a.default.validateDefinition(o)){const e=new DOMParser;i.definitionDoc=e.parseFromString(o,"text/xml")}}XMLDefinition.prototype={forEachField(e){const t=this;o.COL_TYPES_FIELD.forEach((i=>{const o=t.translate(i);e&&!o.error&&e.call(t,i,o)}))},getDefinitionMetadata(){return s.default.applySchema({metaFields:{description:"//workflow-definition/description",name:"//workflow-definition/name",version:"//workflow-definition/version"}},this.definitionDoc).meta},getSchemaActions:(e,t)=>({key:e||"actions",schema:{resultFields:[{key:"description",locator:"description"},{key:"executionType",locator:"execution-type"},{key:"name",locator:"name"},{key:"priority",locator:"priority"},{key:"script",locator:"script"},{key:"scriptLanguage",locator:"script-language"}],resultListLocator:t||"action"}}),getSchemaAssignments:(e,t)=>({key:e||"assignments",schema:{resultFields:[{key:"address",locator:"address"},{key:"resourceActions",schema:{resultFields:[{key:"resourceAction",locator:"resource-action"}],resultListLocator:"resource-actions"}},{key:"roleId",schema:{resultFields:[{key:"roleId",locator:"role-id"},{key:"roleNameAC",locator:"role-name-ac"}],resultListLocator:"role"}},{key:"roleType",schema:{resultFields:[{key:"autoCreate",locator:"auto-create"},{key:"roleName",locator:"name"},{key:"roleType",locator:"role-type"}],resultListLocator:"role"}},{key:"scriptedAssignment",schema:{resultFields:[{key:"script",locator:"script"},{key:"scriptLanguage",locator:"script-language"}],resultListLocator:"scripted-assignment"}},{key:"scriptedRecipient",schema:{resultFields:[{key:"script",locator:"script"},{key:"scriptLanguage",locator:"script-language"}],resultListLocator:"scripted-recipient"}},{key:"taskAssignees",locator:"assignees"},{key:"user",schema:{resultFields:[{key:"emailAddress",locator:"email-address"},{key:"fullName",locator:"full-name"},{key:"screenName",locator:"screen-name"},{key:"userId",locator:"user-id"}],resultListLocator:"user"}},{key:"receptionType",locator:"@receptionType"}],resultListLocator:t||"assignments"}}),getSchemaNotifications(e,t,i,o){return i=i||"recipients",o=o||"recipients",{key:e||"notifications",schema:{resultFields:[{key:"description",locator:"description"},{key:"executionType",locator:"execution-type"},{key:"name",locator:"name"},{key:"notificationTypes",schema:{resultFields:[{key:"notificationType",locator:"."}],resultListLocator:"notification-type"}},{key:"template",locator:"template"},{key:"templateLanguage",locator:"template-language"},this.getSchemaAssignments(i,o)],resultListLocator:t||"notification"}}},getSchemaTaskTimers(e,t){const i=this;return{key:e||"taskTimers",schema:{resultFields:[{key:"blocking",locator:"blocking"},{key:"delay",schema:{resultFields:[{key:"duration",locator:"duration"},{key:"scale",locator:"scale"}],resultListLocator:"delay"}},{key:"description",locator:"description"},{key:"name",locator:"name"},{key:"recurrence",schema:{resultFields:[{key:"duration",locator:"duration"},{key:"scale",locator:"scale"}],resultListLocator:"recurrence"}},i.getSchemaActions("timerActions","timer-action"),i.getSchemaAssignments("reassignments","reassignments"),i.getSchemaNotifications("timerNotifications","timer-notification")],resultListLocator:t||"task-timer"}}},sanitizeDefinitionXML(e){return e=(e=(e=decodeURIComponent(e)).replace(/\s*(<!\[CDATA\[)/g,"$1")).replace(/(\]\]>)\s*/g,"$1"),this.updateXMLNamespace(e),e.replace(/(<workflow-definition)[^>]*(>)/,"$1$2")},set(t,i){e[t]=i},translate(e){const t=this,i={resultFields:["description","id","initial",{key:"labels",locator:"labels"},"metadata","name","script",{key:"scriptLanguage",locator:"script-language"},{key:"transitions",locator:"transitions"},t.getSchemaActions(),t.getSchemaAssignments(),t.getSchemaNotifications(),t.getSchemaTaskTimers()],resultListLocator:e};return s.default.applySchema(i,t.definitionDoc)},updateXMLNamespace(e){const t=this,i=/(<workflow-definition)[^>]*(>)/.exec(e);if(i){const e=/xmlns="([^"]*)"/.exec(i),o=/xmlns:xsi="([^"]*)"/.exec(i),s=/xsi:schemaLocation="([^"]*)"/.exec(i);e&&o&&s&&t.set("xmlNamespace",{xmlns:e[1],"xmlns:xsi":o[1],"xsi:schemaLocation":s[1]})}}}}}));
//# sourceMappingURL=xmlDefinition.js.map