Liferay.Loader.define("portal-workflow-kaleo-designer-web@5.0.85/designer/js/definition-builder/source-builder/xmlDefinition",["module","exports","require","./constants","./xmlSchemaUtil","./xmlUtil"],(function(e,t,o){window;{Object.defineProperty(t,"__esModule",{value:!0}),t.default=c;var i=o("./constants"),s=r(o("./xmlSchemaUtil")),a=r(o("./xmlUtil"));function r(e){return e&&e.__esModule?e:{default:e}}let e;function c(t){const o=this;e={};const i=o.sanitizeDefinitionXML(t.value);if(!i||a.default.validateDefinition(i)){const e=new DOMParser;o.definitionDoc=e.parseFromString(i,"text/xml")}}c.prototype={forEachField(e){const t=this;i.COL_TYPES_FIELD.forEach((o=>{const i=t.translate(o);e&&!i.error&&e.call(t,o,i)}))},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,o,i){return o=o||"recipients",i=i||"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(o,i)],resultListLocator:t||"notification"}}},getSchemaTaskTimers(e,t){const o=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"}},o.getSchemaActions("timerActions","timer-action"),o.getSchemaAssignments("reassignments","reassignments"),o.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,o){e[t]=o},translate(e){const t=this,o={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(o,t.definitionDoc)},updateXMLNamespace(e){const t=this,o=/(<workflow-definition)[^>]*(>)/.exec(e);if(o){const e=/xmlns="([^"]*)"/.exec(o),i=/xmlns:xsi="([^"]*)"/.exec(o),s=/xsi:schemaLocation="([^"]*)"/.exec(o);e&&i&&s&&t.set("xmlNamespace",{xmlns:e[1],"xmlns:xsi":i[1],"xsi:schemaLocation":s[1]})}}}}}));
//# sourceMappingURL=xmlDefinition.js.map