UNPKG

@sap/generator-fiori

Version:

Create an SAPUI5 application using SAP Fiori elements or a freestyle approach

1 lines 48.8 kB
"use strict";exports.id=7971,exports.ids=[7971],exports.modules={38075(e,t,n){n.d(t,{Uy:()=>generate});var i=n(64812),o=n(90718),a=n(29473),r=n(85263),l=n(48161),s=n(76760),c=n(7083),g=n(73136);const u=(0,s.dirname)((0,g.fileURLToPath)(require("node:url").pathToFileURL(__filename).href));function getTemplatePath(e=""){return(0,s.join)(u,"../templates",e)}var d=n(72117);const p="\t",m={"page/custom/1.94/ext/View.xml":{getData:(e,t)=>({ids:{page:e(t?.name??"Page")}})},"page/custom/1.84/ext/View.xml":{getData:(e,t)=>({ids:{page:e(t?.name??"Page")}})},"common/FragmentWithForm.xml":{getData:e=>({ids:{formElement:e("FormElement")}})},"common/FragmentWithVBox.xml":{getData:e=>({ids:{vbox:e("VBox")}})},"view/ext/CustomViewWithTable.xml":{getData:e=>({ids:{table:e("Table")}})},"filter/fragment.xml":{getData:e=>{const t=e("Item"),n=e("Item",[t]),i=e("Item",[t,n]);return{ids:{comboBox:e("ComboBox"),item1:t,item2:n,item3:i}}}},"building-block/rich-text-editor-button-groups/View.xml":{getData:(e,t)=>{const n={},i=[];return(t?.buttonGroups||t?.data?.buttonGroups||[]).forEach((t,o)=>{const a=e("ButtonGroup",i);n[o]=t.id??a,t.id||i.push(a)}),{ids:n}}},"building-block/custom-column/View.xml":{getData:e=>({ids:{column:e("TableColumn")}})}};async function getFragmentAndViewFiles(e,t){const n=await(0,d.r7)(".xml",e,[".git","node_modules","dist","annotations","localService"],t),i=[".fragment.xml",".view.xml"];return n.filter(e=>i.some(t=>e.endsWith(t)))}function createIdGenerator(e={}){const{basePath:t,fsEditor:n,fileContentCache:i=[]}=e,createGenerator=e=>(t,n=[])=>function generateUniqueElementId(e,t,n=[]){if(!n.includes(e)&&(0,c.yU)(e,t))return e;for(let i=1;i<1e3;i++){const o=`${e}${i}`;if(!n.includes(o)&&(0,c.yU)(o,t))return o}throw new Error(`Failed to generate unique ID for base '${e}' after 1000 attempts`)}(t,e,n);return i.length>0?createGenerator(i):n&&t?getFragmentAndViewFiles(t,n).then(e=>{const t=e.map(e=>n.read(e).toString());return createGenerator(t)}):createGenerator([])}const f={noGlob:!0};function detectTabSpacing(e){let t;const n=new Set([" ",p]),i=e.split(/\r\n|\n/).find(e=>n.has(e[0]));return i&&(t=function getLineTabInfo(e){let t;const n=e.startsWith(p)?p:" ";for(let i=0;i<e.length;i++)if(e[i]!==n){t={size:i,useTabSymbol:n===p};break}return t}(i)),t}function extendJSON(e,t){const{filepath:n,content:i,replacer:o}=t,a=function getJsonSpace(e,t,n){n||(n=detectTabSpacing(e.read(t)));let i;return n&&(i=n.useTabSymbol?p.repeat(n.size||1):n.size),i}(e,n,t.tabInfo);e.extendJSON(n,JSON.parse(i),o,a)}function copyTpl(e,t,n,i,o){const a=getRelativeTemplateComponentPath(t),r=m[a];if(o&&r?.getData){const e=r.getData(o,i);i={...i,...e}}e.copyTpl(t,n,i,void 0,f)}function getRelativeTemplateComponentPath(e){const t=(0,s.normalize)(e),n=`${s.sep}templates${s.sep}`,i=t.indexOf(n);if(-1===i)return e;return t.substring(i+n.length).split(s.sep).join("/")}var h,b=n(69972);function insertTextAtAbsolutePosition(e,t,n){if(n<0)return t;const i=Math.max(n-1,0);for(;i>0&&void 0===t[i];)t+=" ";return`${t.slice(0,n)}${e}${t.slice(n)}`}async function getManifestPath(e,t){return(0,s.join)(await(0,c.vv)(e,t),"manifest.json")}async function getManifest(e,t,n=!0){const i=await getManifestPath(e,t);if(n&&!t.exists(i))throw new Error(`Invalid project folder. Cannot find required file ${i}`);return{path:i,content:t.readJSON(i)}}function validateDependenciesLibs(e,t){const n=e["sap.ui5"]?.dependencies?.libs;return!t.length||t.some(e=>void 0!==n?.[e])}async function validateBasePath(e,t,n=["sap.fe.templates"]){t||(t=(0,o.v)((0,i.v)()));const a=await getManifestPath(e,t);if(!t.exists(a))throw new Error(`Invalid project folder. Cannot find required file ${a}`);if(!validateDependenciesLibs(t.readJSON(a),n))throw 1===n.length?new Error(`Dependency ${n[0]} is missing in the manifest.json. Fiori elements FPM requires the SAP FE libraries.`):new Error(`All of the dependencies ${n.join(", ")} are missing in the manifest.json. Fiori elements FPM requires the SAP FE libraries.`);return!0}function getErrorMessage(e){return e instanceof Error?e.message:String(e)}!function(e){e.ListReport="ListReport",e.ObjectPage="ObjectPage",e.CustomPage="CustomPage"}(h||(h={}));function setCommonDefaults(e,t,n){return e.folder=e.folder||`ext/${e.name[0].toLocaleLowerCase()+e.name.substring(1)}`,e.ns=`${n["sap.app"].id}.${e.folder.replace(/[/\\]/g,".")}`,e.path=(0,s.join)((0,s.dirname)(t),e.folder),e}function getDefaultFragmentContent(e,t,n,i=!1,o=!1){const a=function getDefaultFragmentContentData(e,t,n,i=!1,o=!1,a=!0){let r,l;if(n){const s=n.split("."),c=s.pop();l=`core:require="{ handler: '${s.join("/")}${i?".controller":""}'}"`;const g=[];a&&g.push(l),o?(g.push(`value="${e}"`),g.push(`change="handler.${c}"`),r=`<Input id="${t("Input")}" ${g.join(" ")} />`):(g.push(`text="${e}"`),g.push(`press="handler.${c}"`),r=`<Button id="${t("Button")}" ${g.join(" ")} />`)}else r=o?`<Input id="${t("Input")}" value="${e}" />`:`<Text id="${t("Text")}" text="${e}" />`;return{content:r,requireAttribute:l}}(e,t,n,i,o);return a.content}const y=":?query:";function generateRoutePattern(e,t,n){const i=[];if(n?.sourcePage&&n.navEntity){const o=e.find(e=>e.name===n.sourcePage);if(!o?.pattern)throw new Error("Navigation source invalid");{const e=o.pattern.replace(y,"");e?(i.push(e),i.push("/"),i.push(n.navEntity)):i.push(t)}}else e.length>0&&i.push(t);return n?.navKey&&i.push(`({${n?.navEntity??t}Key})`),i.push(y),i.join("")}function generateRouteTarget(e,t,n,i){if(i?.sourcePage){const o=e.find(e=>e.name===i.sourcePage);if(n&&o?.target?.constructor===Array&&o.target.length<3)return[...o.target,t]}return n?[t]:t}function getManifestJsonExtensionHelper(e){return(t,n)=>{switch(t){case"routing":n.routes??=[];break;case"routes":{const t=n;t.push({name:e.id??`${e.entity}${e.name}`,pattern:generateRoutePattern(t,e.entity,e.navigation),target:generateRouteTarget(t,e.id??`${e.entity}${e.name}`,e.fcl,e.navigation)});break}}return n}}async function validatePageConfig(e,t,n,i=[]){if(await validateBasePath(e,n,i),t.navigation?.sourcePage){const{content:i}=await getManifest(e,n);if(!i["sap.ui5"]?.routing?.targets?.[t.navigation.sourcePage])throw new Error(`Could not find navigation source ${t.navigation.sourcePage}!`);const o={};i["sap.ui5"]?.routing?.routes?.constructor===Array?i["sap.ui5"].routing.routes.forEach(e=>{o[e.name]=e}):Object.assign(o,i["sap.ui5"]?.routing?.routes??{});const a=o[t.navigation.sourcePage];if(!a?.pattern||!a.target)throw new Error(`Invalid routing configuration for navigation source ${t.navigation.sourcePage}!`)}return n}var P,v=n(76489),w=n(99861);!function(e){e.FilterBar="filter-bar",e.Chart="chart",e.CustomFilterField="custom-filter-field",e.CustomFormField="custom-form-field",e.Field="field",e.Form="form",e.Page="page",e.Table="table",e.CustomColumn="custom-column",e.RichTextEditor="rich-text-editor",e.RichTextEditorButtonGroups="rich-text-editor-button-groups",e.Action="action"}(P||(P={}));const T="absolute",B="relative";var C,x;!function(e){e.FilterBar="filter-bar",e.Form="form",e.Chart="chart",e.Table="table",e.Page="page",e.BuildingBlocks="building-blocks",e.RichTextEditor="rich-text-editor",e.RichTextEditorButtonGroups="rich-text-editor-button-groups"}(C||(C={})),function(e){e.JSON="json",e.CDS="cds",e.XML="xml",e.JS="javascript",e.TS="typescript",e.ABAPCDS="abapCds"}(x||(x={}));const augmentXpathWithLocalNames=e=>{const t=[];for(const n of e.split("/"))t.push(""===n||n.includes(":")?n:`*[local-name()='${n}']`);return t.join("/")};function xml_getErrorMessage(e){return e instanceof Error?e.message:String(e)}function getOrAddNamespace(e,t="sap.fe.macros",n="macros"){const i=e.documentElement,o=function findNamespacePrefix(e,t){for(const n of Array.from(e.attributes))if(n.value===t){if("xmlns"===n.name)return"";if(n.name.startsWith("xmlns:"))return n.name.split(":")[1]}return null}(i,t);return null!==o?o:(i.setAttributeNS("http://www.w3.org/2000/xmlns/",""===n?"xmlns":`xmlns:${n}`,t),n)}var E=n(68801);const F={prompts:{super:{buildingBlockType:{message:"Select a building block",choices:{chart:"Chart",filterBar:"Filter Bar",table:"Table"}},manifestGroup:{manifestLibrariesTitle:"Manifest Libraries",manifestLibrariesDescription:["In order for macros to work, we need to ensure that the sap.fe.macros library is maintained in manifest.json. Please see the code snippet."]}},common:{id:{existingIdValidation:"An element with this ID already exists",defaultPlaceholder:"Enter a building block ID"},service:{defaultPlaceholder:"Select a service"},entity:{defaultPlaceholder:"Select an entity"},aggregationPath:{defaultPlaceholder:"Select an aggregation path"},filterBar:{defaultPlaceholder:"Enter a new filter bar ID"},viewOrFragmentPath:{defaultPlaceholder:"Select a view or fragment file"},bindingContextType:{option:{relative:"Relative",absolute:"Absolute"}},validation:{errorMessage:{input:"Please enter a value",select:"Please select a value"}},targetProperty:{defaultPlaceholder:"Select a target property"}},chart:{chartBuildingBlockPropertiesTitle:"Chart Building Block Properties",chartBuildingBlockPropertiesDescription:["Select the `View or Fragment File` where you would like to insert the chart building block and provide a `Building Block ID` to identify the chart.","Select an `Entity Set`, and a `Chart Annotation` you would like to use for the chart building block.","Select an `Aggregation Path` to determine where you would like the chart to be placed on the page."],chartVisualizationPropertiesTitle:"Chart Visualization Properties",chartVisualizationPropertiesDescription:["Configure your chart using the properties below."],chartConfigureEventsTitle:"Configure Events",chartConfigureEventsDescription:["Configure the below properties to react to events. Event handler methods are invoked when an event occurs."],id:{message:"Building Block ID",validation:"An ID is required to generate the chart building block"},aggregation:"Aggregation Path",entity:"Entity",service:"Service",viewOrFragmentPath:{message:"View or Fragment File",validation:"A View or Fragment is required to generate the chart building block"},contextPath:"Enter the context path used in the page",metaPath:"Enter the relative path of the property in the meta model",filterBar:{message:"Associated Filter Bar ID",validation:"Enter the ID of the filter bar building block associated with the chart",placeholder:"Select or enter a filter bar ID",inputPlaceholder:"Enter a new filter bar ID"},bindingContextType:"Binding Context Path Type",personalization:{message:"Chart Personalization",choices:{type:"Type",item:"Item",sort:"Sort"},placeholder:"Select chart personalization"},selectionMode:{message:"Selection Mode",choices:{single:"Single",multiple:"Multiple"}},selectionChange:"Selection Change Event",selectionChangePlaceholder:"Enter a function to be executed",qualifier:"Chart Annotation Path",qualifierPlaceholder:"Select a chart annotation path",valuesDependentOnEntityTypeInfo:"Values are dependent on entity set"},filterBar:{filterBarBuildingBlockPropertiesTitle:"Filter Bar Building Block Properties",filterBarBuildingBlockPropertiesDescription:["Select the `View or Fragment File` where you would like to insert the filter bar building block and provide a `Building Block ID` to identify the filter bar.","Select an `Entity Set`, and a `Selection Field Annotation` you would like to use for the filter bar building block.","Select an `Aggregation Path` to determine where you would like the filter bar to be placed on the page."],filterBarConfigureEventsTitle:"Configure Events",filterBarConfigureEventsDescription:["Configure the below properties to react to events. Event handler methods are invoked when an event occurs."],id:{message:"Building Block ID",validation:"An ID is required to generate the filter bar building block"},viewOrFragmentPath:{message:"View or Fragment File",validation:"A View or Fragment is required to generate the filterbar building block"},entity:"Entity",service:"Service",metaPath:"Enter the relative path of the property in the meta model",filterChanged:"Filter Changed Event",filterChangedPlaceholder:"Enter a function to be executed",search:"Search Event",searchPlaceholder:"Enter a function to be executed",qualifier:"Selection Field Annotation Path",qualifierPlaceholder:"Select a selection field annotation path",aggregation:"Aggregation Path",valuesDependentOnEntityTypeInfo:"Values are dependent on entity set",bindingContextType:"Binding Context Path Type"},form:{aggregation:"Aggregation Path",bindingContextType:"Binding Context",entity:"Entity",formBuildingBlockPropertiesTitle:"Properties of the Form Building Block",formBuildingBlockPropertiesDescription:["Select the `View or Fragment File` where you want to insert the Form building block and provide a `Building Block ID` to identify the form.","Select an `Entity Set`, and a `Field Group Annotation` you want to use for the Form building block.","Select an `Aggregation Path` to determine where you want the form to appear on the page.","Provide a `Form Title` to be displayed."],formVisualizationPropertiesTitle:"Form Visualization Properties",formVisualizationPropertiesDescription:["Configure your form using the properties below."],id:{message:"Building Block ID",validation:"An ID is required to generate the Form building block."},qualifier:"FieldGroup Annotation Path",qualifierPlaceholder:"Select a FieldGroup annotation path",viewOrFragmentPath:{message:"View or Fragment File",validate:"A View or Fragment is required to generate the Form building block."},service:"Service",title:{message:"Form Title",validation:"Enter a Form Title",translationAnnotation:"Title of the Form"},valuesDependentOnEntityTypeInfo:"Values are dependent on entity set"},table:{tableBuildingBlockPropertiesTitle:"Table Building Block Properties",tableBuildingBlockPropertiesDescription:["Select the `View or Fragment File` where you would like to insert the table building block and provide a `Building Block ID` to identify the table.","Select an `Entity Set`, and a `Line Item Annotation` you would like to use for the table building block.","Select an `Aggregation Path` to determine where you would like the table to appear on the page.","Provide the Associated Filter Bar ID if you want to link the table to an existing filter bar."],tableVisualizationPropertiesTitle:"Table Visualization Properties",tableVisualizationPropertiesDescription:["Configure your table using the properties below."],viewOrFragmentPath:{message:"View or Fragment File",validation:"A View or Fragment is required to generate the table building block"},id:{message:"Building Block ID",validation:"An ID is required to generate the table building block"},bindingContextType:"Binding Context Path Type",entity:"Entity",service:"Service",qualifier:"Line Item Annotation Path",qualifierPlaceholder:"Select a line item annotation path",aggregation:"Aggregation Path",filterBar:{message:"Associated Filter Bar ID",validation:"Enter the ID of the filter bar building block associated with the table",placeholder:"Select or enter a filter bar ID",inputPlaceholder:"Enter a new filter bar ID"},tableType:{message:"Table Type"},selectionMode:{message:"Select a Selection Mode",choices:{multiple:"Multiple",single:"Single",auto:"Auto",none:"None"}},headerVisible:"Display Header",header:{message:"Table Header Text",validation:"Enter a Table Header Text",translationAnnotation:"Header of the table"},personalization:{message:"Table Personalization",choices:{Sort:"Sort",Column:"Column",Filter:"Filter"}},tableVariantManagement:"Select a Table Variant Management",readOnlyMode:"Enable Read Only Mode",autoColumnWidth:"Enable Auto Column Width",dataExport:"Enable Data Export",fullScreenMode:"Enable Full Screen Mode",pasteFromClipboard:"Enable Paste From Clipboard",tableSearchableToggle:"Table Searchable Toggle",valuesDependentOnEntityTypeInfo:"Values are dependent on entity set"},richTextEditor:{id:{message:"Building Block ID",validation:"An ID is required to generate the Rich Text Editor building block."},viewOrFragmentPath:{message:"View or Fragment File",validation:"A view or fragment is required to generate the Rich Text Editor building block."},bindingContextType:"Binding Context",relativeBindingDisabledTooltip:"There are no suitable entities available for relative binding.",valueSource:"Value Source",entitySet:"Entity",targetProperty:"Target Property",aggregation:"Aggregation Path"},richTextEditorButtonGroups:{message:"Buttons",choices:{"font-style":"Font Style (Bold, Italic, Underline, and Strikethrough)",font:"Font Settings (Family, Size, and Colors)",clipboard:"Clipboard (Cut, Copy, and Paste)",structure:"List Structure (Bullets, Numbers, and Indentation)",undo:"Undo/Redo",insert:"Insert (Image, and Emoticons)",link:"Link (Add, and Remove Links)","text-align":"Text Alignment (Left, Center, Right, and Justify)",table:"Table",styleselect:"Style Select"},viewOrFragmentPath:{message:"View or Fragment File",validation:"A view or fragment is required to generate the Rich Text Editor Button Groups building block."},aggregation:"Aggregation Path",replaceDefaultButtonGroupsHint:"Adding button groups replaces the default button groups in the Rich Text Editor with your chosen configuration."},page:{id:{message:"Building Block ID",validation:"An ID is required to generate the page building block."},viewOrFragmentPath:{message:"View or Fragment File",validation:"A View or Fragment is required to generate the page building block."},aggregation:"Aggregation Path",title:{message:"Page Title",validation:"Enter a Page Title",translationAnnotation:"Title of the Page."},description:{message:"Page Description",validation:"Enter a Page Description",translationAnnotation:"Description of the Page."}}},pageBuildingBlock:{minUi5VersionRequirement:"The Page building block feature requires SAPUI5 1.136.0 or higher. The current version is {{ minUI5Version }}, so the Page building block will not be added."},richTextEditorBuildingBlock:{minUi5VersionRequirement:"The Rich Text Editor building block feature requires SAPUI5 1.117.0 or higher. The current version is {{ minUI5Version }}, so the Rich Text Editor building block will not be added."}},A={buildingBlock:"fe-fpm-writer-building-block"},k=E.createInstance();function translate(e,t){return(n,i)=>k.t(`${e}:${t??""}${n}`,i)}const S={name:"event",jsName:"oEvent",description:"the event object provided by the event provider.",importType:"UI5Event",importSource:"sap/ui/base/Event"};function applyEventHandlerConfiguration(e,t,n,i,o=[S]){const{controllerSuffix:a,typescript:r,templatePath:c="common/EventHandler"}=i;let g,{eventHandlerFnName:u="onPress"}=i;if("string"==typeof n)return n;let d="",p=t.name,m=p;"object"==typeof n&&(d=n.controllerPrefix,n.fnName&&(u=n.fnName),g=n.insertScript,n.fileName&&(p=n.fileName,m=function getFileName(e,t){let n;return n=t&&e.endsWith(".controller")?e.replace(".controller",""):e,n}(p,d)));const f=r?"ts":"js",h=(0,s.join)(t.path||"",`${p}${a?".controller":""}.${f}`);if(e.exists(h)){if(g){let t=e.read(h);t="object"==typeof g.position?function insertTextAtPosition(e,t,n){if(n.line<0||n.character<0)return t;const i=t.split(/\r\n|\n/);let o=i[n.line];for(;void 0===o;)i.push(""),o=i[n.line];return i[n.line]=insertTextAtAbsolutePosition(e,i[n.line],n.character),i.join(l.EOL)}(g.fragment,t,g.position):insertTextAtAbsolutePosition(g.fragment,t,g.position),e.write(h,t)}}else copyTpl(e,getTemplatePath(`${c}.${f}`),h,{eventHandlerFnName:u,parameters:o,...t});const b=`${t.ns}.${m}.${u}`;return d?`${d}.${b}`:`${b}`}const D=[{name:"font-style",buttons:"bold,italic,underline,strikethrough"},{name:"clipboard",buttons:"cut,copy,paste"},{name:"structure",buttons:"bullist,numlist,outdent,indent"},{name:"font",buttons:"fontfamily,fontsize,forecolor,backcolor"},{name:"undo",buttons:"undo,redo"},{name:"insert",buttons:"image,emoticons"},{name:"link",buttons:"link,unlink"},{name:"text-align",buttons:"alignleft,aligncenter,alignright,alignjustify"},{name:"table",buttons:"table"},{name:"styleselect",buttons:"styleselect"}],I={[P.CustomColumn]:{aggregationConfig:{aggregationName:"columns",elementName:"Column"},templateFile:"common/Fragment.xml",namespace:{uri:"sap.fe.macros.table",prefix:"macrosTable"},processor:function processCustomColumn(e,t){const{fs:n,viewPath:i}=t;if(!isBuildingBlockType(e,P.CustomColumn))throw new Error("Expected CustomColumn building block data");const o=getBuildingBlockConfig(P.CustomColumn),a=e.embededFragment;let r;a.eventHandler&&(r=applyEventHandlerConfiguration(n,a,a.eventHandler,{controllerSuffix:!1,typescript:a.typescript}),a.eventHandler=r);a.content=getDefaultFragmentContent("Sample Text",e.generateId,r),i&&!n.exists(i)&&n.copyTpl(getTemplatePath(o.templateFile),i,a)}},[P.CustomFilterField]:{aggregationConfig:{aggregationName:"filterFields",elementName:"FilterField"},templateFile:"filter/fragment.xml",namespace:{uri:"sap.fe.macros.filterBar",prefix:"macros"},processor:function processCustomFilterField(e,t){const{fs:n,viewPath:i,embeddedFragment:o}=t;if(!isBuildingBlockType(e,P.CustomFilterField))throw new Error("Expected CustomFilterField building block data");if(!o)throw new Error("EmbeddedFragment is required for CustomFilterField");const a=getBuildingBlockConfig(P.CustomFilterField);let r={label:e.label,property:e.property,required:e.required??!1,position:e.position,eventHandler:e.embededFragment?.eventHandler,ns:o.ns,name:o.name,path:o.path};r.eventHandler&&(r.eventHandler=applyEventHandlerConfiguration(n,r,r.eventHandler,{controllerSuffix:!1,typescript:e.embededFragment?.typescript,templatePath:"filter/Controller"}));const l=a.templateFile,s=m[l];if(s?.getData){const t=s.getData(e.generateId);r={...r,...t}}i&&!n.exists(i)&&n.copyTpl(getTemplatePath(a.templateFile),i,r)}},[P.CustomFormField]:{aggregationConfig:{aggregationName:"fields",elementName:"FormElement"},templateFile:"common/Fragment.xml",namespace:{uri:"sap.fe.macros",prefix:"macros"},processor:function processCustomFormField(e,t){const{fs:n,viewPath:i}=t;if(!isBuildingBlockType(e,P.CustomFormField))throw new Error("Expected CustomFormField building block data");if(!e.embededFragment)throw new Error("EmbeddedFragment is required for CustomFormField");const o=getBuildingBlockConfig(P.CustomFormField),a=e.embededFragment;let r;a.eventHandler&&(r=applyEventHandlerConfiguration(n,a,a.eventHandler,{controllerSuffix:!1,typescript:a.typescript}),a.eventHandler=r);a.content??=getDefaultFragmentContent("Custom Form Field Content",e.generateId,r),i&&!n.exists(i)&&n.copyTpl(getTemplatePath(o.templateFile),i,a)}},[P.RichTextEditorButtonGroups]:{aggregationConfig:{aggregationName:"buttonGroups",elementName:"ButtonGroup"},namespace:{uri:"sap.fe.macros",prefix:"macros"},processor:function processRichTextEditorButtonGroups(e,t){const{xmlDocument:n,updatedAggregationPath:i,hasAggregation:o}=t;if(!isBuildingBlockType(e,P.RichTextEditorButtonGroups)&&!isBuildingBlockType(e,P.RichTextEditor))throw new Error("Expected RichTextEditorButtonGroups or RichTextEditor building block data");const a=new Map;if(o&&n&&i){const e=w.useNamespaces(n.firstChild._nsMap)(i,n);if(e.length>0){const t=e[0],n=getBuildingBlockConfig(P.RichTextEditorButtonGroups);Array.from(t.childNodes).filter(e=>1===e.nodeType&&e.localName===n.aggregationConfig.elementName).forEach(e=>{const t=function extractButtonGroupConfig(e){const t=e.getAttribute("name"),n=e.getAttribute("buttons");if(!t||!n)return;const i={name:t,buttons:n};n&&(i.buttons=n);const o=e.getAttribute("visible");o&&(i.visible="true"===o);const a=e.getAttribute("priority");a&&(i.priority=Number.parseInt(a,10));const r=e.getAttribute("customToolbarPriority");r&&(i.customToolbarPriority=Number.parseInt(r,10));const l=e.getAttribute("row");l&&(i.row=Number.parseInt(l,10));const s=e.getAttribute("id");s&&(i.id=s);return i}(e);t&&a.set(t.name,t)});const i=e[0];i.parentNode?.removeChild(i)}}e.buttonGroups=function mergeButtonGroups(e,t){let n=function getNextCustomToolbarPriority(e){const t=Array.from(e.values()).map(e=>e.customToolbarPriority).filter(e=>"number"==typeof e);return t.length>0?Math.max(...t)+1:1}(e);return t.buttonGroups?.map(t=>{const i=D.find(e=>e.name===t.name);if(!i)throw new Error(`Unknown button group: ${t.name}`);const o=e.get(t.name),a=Object.keys(t).some(e=>"name"!==e&&void 0!==t[e]);let r=t.customToolbarPriority;return void 0!==r||o?void 0!==o?.customToolbarPriority&&(r=o.customToolbarPriority):r=n++,o&&!a?{...o,customToolbarPriority:r}:{name:t.name,buttons:t.buttons??i.buttons,visible:t.visible,priority:t.priority,customToolbarPriority:r,row:t.row,id:t.id}})}(a,e)}},[P.Action]:{aggregationConfig:{aggregationName:"actions",elementName:"Action"},namespace:{uri:"sap.fe.macros.table",prefix:"macrosTable"},processor:function processAction(e,t){const{fs:n}=t;if(!isBuildingBlockType(e,P.Action))throw new Error("Expected Action building block data");const i=e.embeddedAction;if("object"==typeof i.eventHandler){const e=applyEventHandlerConfiguration(n,i,i.eventHandler,{typescript:i.typescript}),o=i.eventHandler?i.eventHandler.fnName:e;if(i.eventHandler.fileName?.includes(".controller"))i.eventHandler={fnName:`.${o}`};else{let e;if(i.eventHandler.fileName){const n=t.embeddedAction?.ns?.split(".").join("/");e=s.posix.join(n??"",i.eventHandler.fileName)}i.eventHandler={fnName:`handler.${o}`,fileName:e}}}}}};function getBuildingBlockConfig(e){const t=I[e];if(!t)throw new Error(`No configuration found for building block type: ${e}`);return t}function isBuildingBlockType(e,t){return e.buildingBlockType===t}function updateAggregationPath(e,t,n,i){const o=w.useNamespaces(e.firstChild._nsMap),a=o(t,e);if(!a||!Array.isArray(a)||0===a.length)return{updatedAggregationPath:t,hasElement:!1};const r=a[0],l=o(`./*[local-name()='${n.aggregationName}']`,r);if(l&&Array.isArray(l)&&l.length>0)return{updatedAggregationPath:t+`/${getOrAddNamespace(e,i?.uri)}:${n.aggregationName}`,hasElement:!0};{const e=o(`./*[local-name()='${n.elementName}']`,r);if(e&&Array.isArray(e)&&e.length>0)return{updatedAggregationPath:t,hasElement:!0}}return{updatedAggregationPath:t,hasElement:!1}}const N="REPLACE_WITH_BUILDING_BLOCK_ID",$="REPLACE_WITH_ENTITY",O="REPLACE_WITH_A_QUALIFIER";async function generateBuildingBlock(e,t,n){const{viewOrFragmentPath:a,aggregationPath:l,buildingBlockData:g,allowAutoAddDependencyLib:u=!0}=t;n??=(0,o.v)((0,i.v)()),await validateBasePath(e,n,[]);const d=t.buildingBlockData.generateId??await createIdGenerator({basePath:e,fsEditor:n});if(!n.exists((0,s.join)(e,a)))throw new Error(`Invalid view path ${a}.`);const{path:p,content:m}=await getManifest(e,n),f=getUI5XmlDocument(e,a,n),{updatedAggregationPath:h,processedBuildingBlockData:y,hasAggregation:T,aggregationNamespace:B}=function processBuildingBlock(e,t,n,i,o,a){let r,l,c=o,g=!1,u="macrosTable";const d=I[e.buildingBlockType];if(!d)return{updatedAggregationPath:c,processedBuildingBlockData:e,hasAggregation:g,aggregationNamespace:u};if(isBuildingBlockType(e,P.RichTextEditorButtonGroups)||isBuildingBlockType(e,P.RichTextEditor)){const n=updateAggregationPath(t,o,{aggregationName:d.aggregationConfig.aggregationName,elementName:d.aggregationConfig.elementName},{uri:d.namespace.uri,prefix:d.namespace.prefix}),i={fs:a,xmlDocument:t,updatedAggregationPath:n.updatedAggregationPath,hasAggregation:n.hasElement};d.processor(e,i),u=getOrAddNamespace(t,d.namespace.uri,d.namespace.prefix)}if((isBuildingBlockType(e,P.CustomColumn)||isBuildingBlockType(e,P.CustomFilterField)||isBuildingBlockType(e,P.CustomFormField))&&e.embededFragment){r=setCommonDefaults(e.embededFragment,n,i),l=(0,s.join)(r.path,`${r.fragmentFile??r.name}.fragment.xml`);const p={fs:a,viewPath:l,embeddedFragment:r};d.processor(e,p);const m=updateAggregationPath(t,o,{aggregationName:d.aggregationConfig.aggregationName,elementName:d.aggregationConfig.elementName});c=m.updatedAggregationPath,g=m.hasElement,u=getOrAddNamespace(t,d.namespace.uri,d.namespace.prefix)}if(isBuildingBlockType(e,P.Action)&&e.embeddedAction){const r=updateAggregationPath(t,o,{aggregationName:d.aggregationConfig.aggregationName,elementName:d.aggregationConfig.elementName}),l={fs:a,xmlDocument:t,updatedAggregationPath:r.updatedAggregationPath,hasAggregation:r.hasElement,embeddedAction:setCommonDefaults(e.embeddedAction,n,i)};d.processor(e,l),c=r.updatedAggregationPath,g=r.hasElement,getOrAddNamespace(t,d.namespace.uri,d.namespace.prefix)}return{updatedAggregationPath:c,processedBuildingBlockData:e,hasAggregation:g,aggregationNamespace:u}}({...g,generateId:d},f,p,m,l,n),C=function getTemplateDocument(e,t,n,i,o){const a=getTemplateContent(e,t,i,n,void 0,o),errorHandler=(e,t)=>{throw new Error(`Unable to parse template file with building block data. Details: [${e}] - ${t}`)};let r;try{r=new b.DOMParser({errorHandler}).parseFromString(a,"text/xml")}catch(e){throw new Error(`Unable to parse template file with building block data. Details: ${getErrorMessage(e)}`)}return r}({...y,generateId:d},f,n,m,{hasAggregation:T,aggregationNamespace:B});if(g.buildingBlockType===P.RichTextEditor||g.buildingBlockType===P.RichTextEditorButtonGroups){const e=m?(0,r.coerce)((0,c.qL)(m)):void 0;if(e&&(0,r.lt)(e,"1.117.0")){const t=translate(A.buildingBlock,"richTextEditorBuildingBlock.");throw new Error(`${t("minUi5VersionRequirement",{minUI5Version:e})}`)}getOrAddNamespace(f,"sap.fe.macros.richtexteditor","richtexteditor")}if(n=function updateViewFile(e,t,n,i,o,a,r=!1){const l=w.useNamespaces(i.firstChild._nsMap)(n,i);if(!(l&&Array.isArray(l)&&l.length>0))throw new Error(`Aggregation control not found ${n}.`);{const n=l[0],c=i.importNode(o.documentElement,!0);r?n.parentNode?.replaceChild(c,n):n.appendChild(c);const g=(new b.e).serializeToString(i);a.write((0,s.join)(e,t),v(g))}return a}(e,a,h,f,C,n,t.replace),u&&m&&!validateDependenciesLibs(m,["sap.fe.macros"])){const t=await getManifestPath(e,n),i=await getManifestContent(n),o=n.read(t);extendJSON(n,{filepath:t,content:i,tabInfo:detectTabSpacing(o)})}return n}function getUI5XmlDocument(e,t,n){let i;try{i=n.read((0,s.join)(e,t))}catch(e){throw new Error(`Unable to read xml view file. Details: ${getErrorMessage(e)}`)}const errorHandler=(e,t)=>{throw new Error(`Unable to parse xml view file. Details: [${e}] - ${t}`)};let o;try{o=new b.DOMParser({errorHandler}).parseFromString(i,"text/xml")}catch(e){throw new Error(`Unable to parse xml view file. Details: ${getErrorMessage(e)}`)}return o}function getMetaPath(e,t,n,i){if(!t)return function getDefaultMetaPath(e,t){return e?{metaPath:t?`/${O}`:"",contextPath:t?$:""}:{metaPath:t?`/${$}/${O}`:""}}(e,n);const{bindingContextType:o=T,alwaysAbsolutePath:a=!0}=t;let{entitySet:r,qualifier:l}=t;r=r||(n?$:"");const s=l||(n?O:"");if(e){const e=s.split("/");return l=e.pop(),{metaPath:l,contextPath:e.length?`/${r}/${e.join("/")}`:`/${r}`}}if(i){return{metaPath:`${o===T?"/":""}${r}/${i}`}}return{metaPath:o===T||a?`/${r}/${s}`:s}}function getTemplateContent(e,t,n,i,o,l){const s=getTemplatePath(`/building-block/${e.buildingBlockType}/View.xml`);if("object"==typeof e.metaPath||void 0===e.metaPath){const t=n?(0,r.coerce)((0,c.qL)(n)):void 0;let i;e.buildingBlockType!==P.RichTextEditor&&e.buildingBlockType!==P.CustomFormField||!("targetProperty"in e)||"string"!=typeof e.targetProperty||(i=e.targetProperty);const a=getMetaPath(e.buildingBlockType===P.Chart||!(!t||!(0,r.lt)(t,"1.97.0")),e.metaPath,o,i);!(e={...e,metaPath:a.metaPath}).contextPath&&a.contextPath&&(e.contextPath=a.contextPath)}e.id||(e.id=N);const g=getRelativeTemplateComponentPath(s),u=m[g];let d={macrosNamespace:t?getOrAddNamespace(t,"sap.fe.macros","macros"):"macros",data:e,config:l};if(u?.getData){const t=u.getData(e.generateId,e);d={...d,...t}}return(0,a.render)(i.read(s),d,{})}async function getManifestContent(e,t="sap.fe.macros"){const n=getTemplatePath("/building-block/common/manifest.json");return(0,a.render)(e.read(n),{libraries:{[t]:{}}})}async function getSerializedFileContent(e,t,n){const a={},{buildingBlockData:r,viewOrFragmentPath:l,allowAutoAddDependencyLib:c=!0}=t;if(!r?.buildingBlockType)return{};n=n??(0,o.v)((0,i.v)());const g=l?getUI5XmlDocument(e,l,n):void 0,{content:u,path:d}=await getManifest(e,n,!1),p=getTemplateContent(r,g,u,n,!0),m=function getFilePathProps(e,t){return t?{fileName:(0,s.parse)(t).base,relativePath:t,fullPath:(0,s.join)(e,t)}:{}}(e,l);if(a.viewOrFragmentPath={content:p,language:x.XML,filePathProps:m},c){const t=await getManifestContent(n);a.manifest={content:t,language:x.JSON,filePathProps:{fileName:(0,s.parse)(d).base,relativePath:(0,s.relative)(e,d),fullPath:d}}}return a}function isCapProject(e){return["CAPJava","CAPNodejs"].includes(e.projectType)}var j=n(91125),M=n(69942);async function getAnnotationService(e,t,n,i=!0){const o=await async function getMappedServiceName(e,t,n){let i=t;if(["CAPJava","CAPNodejs"].includes(e.projectType)){const t=getMainService(e,n);t&&(i=await(0,c.ld)(e.root,e.apps[n]?.services?.[t].uri??""))}return i}(e,t,n),a=await M.gR.createService(e,o,n);return i&&await a.sync(),a}function getMergedMetadata(e){const t=e.getSchema();return(0,j.convert)(t)}function getMainService(e,t){let n;if(void 0===t){const t=Object.keys(e.apps);n=e.apps[t[0]].mainService}else{const i=e.apps[t];if(!i)throw new Error("ERROR_INVALID_APP_ID");n=i.mainService}return n??"mainService"}async function getEntitySets(e,t){const n=await(async(e,t,n)=>getMergedMetadata(await getAnnotationService(e,t,n)))(e,getMainService(e,t),t);return Array.from(n.entitySets)}async function getAnnotationPathQualifiers(e,t,n,i,o,a=!1){const r={};try{const l=await getAnnotationService(e,getMainService(e,t),t),s=getMergedMetadata(l).entitySets.by_name(n),c=s?.entityType;c&&function getAnnotationPathQualifiersForEntityType(e,t,n,i,o){"absolute"===o.type?addAnnotationPathQualifierToResult(e,"",t,n,i):"relative"===o.type&&e.navigationProperties.forEach(e=>{"EntityType"===e.targetType?._type&&"SiblingEntity"!==e.name&&(!o.isCollection||o.isCollection&&e.isCollection)&&addAnnotationPathQualifierToResult(e.targetType,e.name,t,n,i)})}(c,i,r,a,o)}catch(e){throw new Error(`An error occurred while reading the annotation path qualifiers. Details: ${e}`)}return r}function addAnnotationPathQualifierToResult(e,t,n,i,o=!1){n.forEach(n=>{const[a,r]=function getAnnotationTermAlias(e){const[,,,t,,n]=e.split(".");return[t,n]}(n),l=n.substring(0,n.lastIndexOf(".")),s=e.annotations[a];s&&Object.entries(s).forEach(([e,n])=>{if(e.startsWith(r)){const e=n.qualifier?"#"+n.qualifier:"",s=""+(t?t+"/":"");i[`${s}@${a}.${r}`+e]=`${s}@${o?l:a}.${r}`+e}})})}const R={};async function loadEntitySets(e){const{project:t,appId:n}=e;if(!t||0===Object.keys(t).length)throw new Error("Project is undefined. Cannot fetch entity sets.");const i=JSON.stringify(t)+":"+n;return R[i]||(R[i]=await getEntitySets(t,n)),R[i]}function getEntitySetOptions(e,t,n){const i=e.find(e=>e.name===t);if(!i)return e;if(n===B){let e=i?.entityType?.navigationProperties?.filter(e=>!1===e.isCollection)??[];return e=e.filter(e=>!["DraftAdministrativeData","SiblingEntity"].includes(e.name)),e}return[i]}function getBindingContextTypeChoices(e=!1){const t=translate(A.buildingBlock,"prompts.");return[{name:t("common.bindingContextType.option.absolute"),value:T},{name:t("common.bindingContextType.option.relative"),value:B,...e?{disabled:!0,title:t("richTextEditor.relativeBindingDisabledTooltip")}:{}}]}function resolveBindingContextTypeChoices(e){const{project:t}=e;return t?async()=>{const t=await loadEntitySets(e),{pageContextEntitySet:n}=e.options??{};if(!n)return getBindingContextTypeChoices();return getEntitySetOptions(t,n,B).length?getBindingContextTypeChoices():getBindingContextTypeChoices(!0)}:getBindingContextTypeChoices()}async function getButtonGroupsChoices(e,t){const{project:n,appPath:i,fs:o}=e;if(!n)return[];let a=new Set;if(t.viewOrFragmentPath){const e=(0,s.join)(i,t.viewOrFragmentPath);a=await async function getExistingButtonGroups(e,t,n){const i=new Set;try{const o=n.read(e),errorHandler=(e,t)=>{throw new Error(`Unable to parse the xml view file. Details: [${e}] - ${t}`)},a=new b.DOMParser({errorHandler}).parseFromString(o,"text/xml"),r=a.firstChild?._nsMap||{},l=w.useNamespaces(r)(t,a);if(0===l.length)return i;const s=l[0],c=Array.from(s.childNodes).find(e=>1===e.nodeType&&"buttonGroups"===e.localName);if(!c)return i;Array.from(c.childNodes).filter(e=>1===e.nodeType&&"ButtonGroup"===e.localName).forEach(e=>{const t=e.getAttribute("name");t&&i.add(t)})}catch(e){throw new Error(`An error occurred while reading button groups. Details: ${xml_getErrorMessage(e)}`)}return i}(e,t.aggregationPath,o)}const r=!a||0===a.size,l=translate(A.buildingBlock,"prompts.richTextEditorButtonGroups.");return D.map(e=>{const t=l(`choices.${e.name}`);return{name:t,value:e.name,hidden:!r&&a.has(e.name),checked:a.has(e.name),title:t}})}!async function initI18n(){await k.init({resources:{en:{[A.buildingBlock]:F}},lng:"en",fallbackLng:"en",defaultNS:A.buildingBlock,ns:[A.buildingBlock],showSupportNotice:!1})}();const V=translate(A.buildingBlock,"prompts.common.");function getBooleanPrompt(e){const{guiOptions:t}=e;return{...e,type:"list",choices:[{name:"False",value:!1},{name:"True",value:!0}],guiOptions:{...t,selectType:"static"}}}function getAnnotationPathQualifierPrompt(e,t={},n=[]){const{project:i,appId:o}=e,{guiOptions:a}=t;return{...t,type:"list",name:"buildingBlockData.metaPath.qualifier",choices:i?async e=>{const{entitySet:t,bindingContextType:a}=e.buildingBlockData?.metaPath??{};if(!t)return[];const r=a?{type:a,isCollection:e.buildingBlockData.buildingBlockType===P.Table}:{type:"absolute"},l=transformChoices(await getAnnotationPathQualifiers(i,o,t,n,r,!0));if(t&&!l.length)throw new Error(`Couldn't find any existing annotations for term ${n.join(",")}. Please add ${n.join(",")} annotation/s`);return l}:[],guiOptions:{...a,selectType:"dynamic"}}}function getViewOrFragmentPathPrompt(e,t,n={}){const{fs:i,project:o,appPath:a}=e,{guiOptions:r}=n;return{...n,type:"list",name:"viewOrFragmentPath",choices:o?async()=>transformChoices((await getFragmentAndViewFiles(a,i)).map(e=>(0,s.relative)(a,e))):[],validate:e=>!(o&&!e)||t,guiOptions:{...r,selectType:"dynamic",placeholder:r?.placeholder??V("viewOrFragmentPath.defaultPlaceholder")}}}async function getCAPServicePrompt(e,t={}){const{project:n,appId:i}=e,{guiOptions:o}=t,a=n?await getCAPServiceChoices(n,i):[],r=1===a.length?a[0].value:void 0;return{...t,type:"list",name:"service",choices:n?getCAPServiceChoices.bind(null,n,i):[],default:r,guiOptions:{...o,selectType:"dynamic",placeholder:o?.placeholder??V("service.defaultPlaceholder")}}}function getEntityPrompt(e,t={}){const{project:n}=e,{pageContextEntitySet:i}=e.options??{},{guiOptions:o}=t;return{...t,type:"list",name:"buildingBlockData.metaPath.entitySet",choices:n?async t=>{const n=await loadEntitySets(e);if(!i)return transformChoices(n.map(e=>e.name));const o=t?.buildingBlockData?.metaPath.bindingContextType??T,a=getEntitySetOptions(n,i,o);return transformChoices((a.length>0?a:[]).map(e=>e.name))}:[],guiOptions:{...o,selectType:"dynamic",placeholder:o?.placeholder??V("entity.defaultPlaceholder")}}}function getTargetPropertiesPrompt(e,t={}){const{project:n}=e,i=e.options?.pageContextEntitySet??"",{guiOptions:o}=t;return{...t,type:"list",name:"buildingBlockData.targetProperty",choices:n?async t=>{const n=await loadEntitySets(e),{bindingContextType:o,entitySet:a}=t?.buildingBlockData?.metaPath??{};if(!a)return[];const r=function resolveEntitySetTargets(e,t,n,i){const o=t||i,a=e.find(e=>e.name===o);if(!i)return[];if(n===B&&i){const t=a?.entityType?.navigationProperties?.find(e=>e.name===i),n=e.find(e=>e.entityTypeName===t?.targetTypeName);return n?.entityType?.entityProperties??[]}return a?.entityType?.entityProperties??[]}(n,i,o,a);return transformChoices(r.map(e=>e.name))}:[],guiOptions:{...o,selectType:"dynamic",placeholder:o?.placeholder??V("targetProperty.defaultPlaceholder")}}}async function getCAPServiceChoices(e,t){const n=e.apps[t]?.services,i={};for(const o of Object.keys(n)){i[await(0,c.ld)(e.root,e.apps[t].services[o]?.uri??"")]=o}return transformChoices(i)}function getAggregationPathPrompt(e,t={}){const{fs:n,project:i,appPath:o}=e,{guiOptions:a}=t;return{...t,type:"list",name:"aggregationPath",choices:i?e=>{const{viewOrFragmentPath:t}=e;if(t){const{inputChoices:e,pageMacroDefinition:i}=function getXPathStringsForXmlFile(e,t){const n={};let i;try{const o=t.read(e),errorHandler=(e,t)=>{throw new Error(`Unable to parse the xml view file. Details: [${e}] - ${t}`)},a=new b.DOMParser({errorHandler}).parseFromString(o,"text/xml"),r=[{parentNode:"",node:a.firstChild}],l=getOrAddNamespace(a);i=l?`${l}:Page`:"macros:Page";let s=!1;for(;r&&r.length>0;){const{parentNode:e,node:t}=r.shift();if(!t)continue;s=Array.from(t.childNodes).some(e=>e.nodeType===e.ELEMENT_NODE&&"Page"===e.localName&&e.nodeName===i),s||(n[`${e}/${t.nodeName}`]=augmentXpathWithLocalNames(`${e}/${t.nodeName}`));const o=Array.from(t.childNodes);for(const n of o)n.nodeType===n.ELEMENT_NODE&&r.push({parentNode:`${e}/${t.nodeName}`,node:n})}}catch(e){throw new Error(`An error occurred while parsing the view or fragment xml. Details: ${xml_getErrorMessage(e)}`)}return{inputChoices:n,pageMacroDefinition:i}}((0,s.join)(o,t),n),a=transformChoices(e,!1,Object.keys(e).find(e=>e.endsWith(`/${i}`)));if(!a.length)throw new Error("Failed while fetching the aggregation path.");return a}return[]}:[],guiOptions:{...a,selectType:"dynamic",placeholder:a?.placeholder??V("aggregationPath.defaultPlaceholder")}}}function transformChoices(e,t=!0,n){let i=[];return Array.isArray(e)?(e=[...new Set(e)],t?[...e].sort((e,t)=>e.localeCompare(t)):e):(i=Object.entries(e).map(([e,t])=>e===n?{name:e,value:t,checked:!0}:{name:e,value:t}),t&&(i=i.sort((e,t)=>e.name.localeCompare(t.name))),i)}function getFilterBarIdPrompt(e,t){const{fs:n,project:i,appPath:o}=e,{guiOptions:a}=t,r={...t,type:"input",name:"buildingBlockData.filterBar",guiOptions:{...a,placeholder:a?.placeholder??V("filterBar.defaultPlaceholder")}};return"input"===t.type?r:{...r,type:"list",choices:i?async e=>e.viewOrFragmentPath?transformChoices(await async function getFilterBarIdsInFile(e,t){const n=[],i=t.read(e),o=new b.DOMParser({errorHandler:(e,t)=>{throw new Error(`Unable to parse the xml view file. Details: [${e}] - ${t}`)}}).parseFromString(i,"text/xml"),a=Array.from(o.getElementsByTagName("macros:FilterBar"));for(const e of a){const t=e.getAttributeNode("id")?.value;t&&n.push(t)}return n}((0,s.join)(o,e.viewOrFragmentPath),n)):[]:[],guiOptions:{...r.guiOptions,selectType:"dynamic"}}}function getBindingContextTypePrompt(e={}){const{guiOptions:t}=e;return{...e,type:"list",name:"buildingBlockData.metaPath.bindingContextType",choices:e.choices??[{name:V("bindingContextType.option.absolute"),value:"absolute"},{name:V("bindingContextType.option.relative"),value:"relative"}],guiOptions:{...t,selectType:"function"==typeof e.choices?"dynamic":"static"}}}function getBuildingBlockIdPrompt(e,t,n={}){const{fs:i,project:o,appPath:a}=e,{guiOptions:r}=n;return{...n,type:"input",name:"buildingBlockData.id",validate:(e,n)=>!o||(e?!(n?.viewOrFragmentPath&&!function isElementIdAvailable(e,t,n){const i=e.read(t).toString(),o=new b.DOMParser({errorHandler:()=>{}}).parseFromString(i,"text/xml");return!o.documentElement||!o.getElementById(n)}(i,(0,s.join)(a,n.viewOrFragmentPath),e))||V("id.existingIdValidation"):t),guiOptions:{...r,placeholder:r?.placeholder??V("id.defaultPlaceholder")}}}function enhanceData(e,t,n){const i=n.readJSON(t),o=!!e.folder,a=setCommonDefaults(e,t,i);o||(a.folder="ext/view",a.ns=`${i["sap.app"].id}.ext.view`,a.path=(0,s.join)((0,s.dirname)(t),"ext/view")),a.template="sap.fe.core.fpm",a.settings=function initializeTargetSettings(e,t){const n=t?{...t}:{};n.navigation??={};const i=(0,r.coerce)(e.minUI5Version);return!i||(0,r.gte)(i,"1.94.0")?n.contextPath=e.contextPath??`/${e.entity}`:n.entitySet=e.entity,n}(e),a.libraries=function getLibraryDependencies(e){const t={};switch(e){case h.CustomPage:t["sap.fe.core"]={};break;case h.ListReport:case h.ObjectPage:t["sap.fe.templates"]={}}return t}(h.CustomPage);const l=function getFclConfig(e,t){const n={};if("sap.f.routing.Router"===e["sap.ui5"]?.routing?.config?.routerClass)if(n.fcl=!0,t){const i=(e["sap.ui5"]?.routing?.routes||[]).find(e=>e.name===t?.sourcePage);n.controlAggregation=(i?.target??[]).length>1?"endColumnPages":"midColumnPages"}else n.controlAggregation="beginColumnPages";return n}(i,a.navigation);return a.fcl=l.fcl,a.controlAggregation=l.controlAggregation,void 0===a.view&&(a.view={title:a.name}),a}async function generate(e,t,n,l){n??=(0,o.v)((0,i.v)()),function validateVersion(e){const t=(0,r.coerce)(e);if(t&&(0,r.lt)(t,"1.84.0"))throw new Error("SAP Fiori elements for OData v4 is only supported starting with SAPUI5 1.84.");return!0}(t.minUI5Version),await validatePageConfig(e,t,n,[]);const c=await getManifestPath(e,n),g=await createIdGenerator({basePath:e,fsEditor:n}),u=enhanceData(t,c,n),d=function getTemplateRoot(e){const t=(0,r.coerce)(e);return!t||(0,r.gte)(t,"1.94.0")?getTemplatePath("/page/custom/1.94"):getTemplatePath("/page/custom/1.84")}(t.minUI5Version);extendJSON(n,{filepath:c,content:(0,a.render)(n.read((0,s.join)(d,"manifest.json")),u,{}),replacer:getManifestJsonExtensionHelper(u),tabInfo:t.tabInfo});const p=(0,s.join)(u.path,`${u.name}.view.xml`);if(!n.exists(p)){copyTpl(n,(0,s.join)(d,"ext/View.xml"),p,u,g);const t=n.readJSON(c),i="i18n/i18n.properties",o=t?.["sap.ui5"]?.models?.i18n?.uri,r=(0,s.join)(e,"webapp",o??i),l=(0,s.join)(d,"i18n","i18n.properties");n.exists(r)?n.append(r,(0,a.render)(n.read(l),u,{})):copyTpl(n,l,r,u)}t.pageBuildingBlockTitle&&await async function handlePageBuildingBlock(e,t,n,i,o,a){const l=(0,r.coerce)(t.minUI5Version),c=translate(A.buildingBlock,"pageBuildingBlock.");if(l&&(0,r.lt)(l.version,"1.136.0"))return void a?.warn(c("minUi5VersionRequirement",{minUI5Version:t.minUI5Version}));const g=o("Page");await generateBuildingBlock(e,{viewOrFragmentPath:(0,s.relative)(e,n),aggregationPath:augmentXpathWithLocalNames("/mvc:View/Page"),replace:!0,buildingBlockData:{id:g,buildingBlockType:P.Page,generateId:o,title:t.pageBuildingBlockTitle}},i)}(e,{pageBuildingBlockTitle:t.pageBuildingBlockTitle,minUI5Version:t.minUI5Version},p,n,g,l);const m=t.typescript?"ts":"js",f=(0,s.join)(u.path,`${u.name}.controller.${m}`);return n.exists(f)||copyTpl(n,(0,s.join)(d,`ext/Controller.${m}`),f,u),t.typescript&&function addExtensionTypes(e,t,n){const i=(0,r.minor)((0,r.coerce)(t)??"1.108.0"),o=(0,s.join)(e,"/webapp/ext/sap.fe.d.ts");i<108&&102!==i&&!n.exists(o)&&copyTpl(n,getTemplatePath("common/sap.fe.d.ts"),o,{version:i})}(e,t.minUI5Version,n),n}var L,q,H,U;!function(e){e.header="header",e.body="body",e.footer="footer",e.section="@com.sap.vocabularies.UI.v1.FieldGroup",e.table="@com.sap.vocabularies.UI.v1.LineItem"}(L||(L={})),function(e){e.header="header",e.body="body",e.section="@com.sap.vocabularies.UI.v1.FieldGroup",e.table="@com.sap.vocabularies.UI.v1.LineItem"}(q||(q={})),function(e){e.Heroes="Heroes",e.Decoration="Decoration",e.Workers="Workers",e.LongRunners="LongRunners"}(H||(H={})),function(e){e.Default="Default",e.NotAdaptableVisibility="not-adaptable-visibility",e.NotAdaptable="not-adaptable",e.NotAdaptableTree="not-adaptable-tree",e.NotRemovable="not-removable"}(U||(U={}));const getManifestPromptsGroup=()=>{const e=translate(A.buildingBlock,"prompts.super.manifestGroup.");return{id:"manifestLibraries",title:e("manifestLibrariesTitle"),description:e("manifestLibrariesDescription",{returnObjects:!0})}};const G=getManifestPromptsGroup(),z="Chart",_="absolute",J="chartBuildingBlockProperties",W="chartVisualizationProperties",Q="chartConfigureEvents";const X=getManifestPromptsGroup(),K="FilterBar",Y="absolute",Z="filterBarBuildingBlockProperties",ee="filterConfigureEvents";var te=n(50702);const ne=getManifestPromptsGroup(),ie="formBuildingBlockProperties",oe="Form",ae="absolute";const re=getManifestPromptsGroup(),le="tableBuildingBlockProperties",se="tableVisualizationProperties",ce="Table",ge="ResponsiveTable",ue="Single",de=!0,pe="None",me=!1,fe=!1,he=!1,be=!1,ye=!1,Pe=!0,ve="absolute";const we=translate(A.buildingBlock,"prompts.richTextEditorButtonGroups.");C.Chart,C.Table,C.FilterBar,C.Form,C.BuildingBlocks,C.Page,C.RichTextEditor,C.RichTextEditorButtonGroups,C.Chart,C.Table,C.FilterBar,C.Form,C.RichTextEditor,C.RichTextEditorButtonGroups,C.Page,C.Chart,C.Table,C.FilterBar,C.Form,C.RichTextEditor,C.RichTextEditorButtonGroups,C.Page;var Te;!function(e){e.ObjectPage="ObjectPage",e.ListReport="ListReport"}(Te||(Te={}));const Be="sap.fe.templates.ListReport.ListReportController";new Map([[Te.ListReport,Be],[Te.ObjectPage,"sap.fe.templates.ObjectPage.ObjectPageController"]])}};