@mohsinonxrm/pptb-commandbar-studio 0.9.0 → 0.10.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. package/CHANGELOG.md +167 -0
  2. package/README.md +16 -14
  3. package/dist/assets/BulkPublishModal-9_XxYmS2.js +2 -0
  4. package/dist/assets/CommandEditorPanel-BtBG8540.js +1 -0
  5. package/dist/assets/CommandPalette-C2YXN_gD.js +1 -0
  6. package/dist/assets/CompareView-Beq5V68_.js +11 -0
  7. package/dist/assets/CrmParameterEditor-DfZv5BuF.js +1 -0
  8. package/dist/assets/EditorDrawer-D0K8zHVK.js +2 -0
  9. package/dist/assets/HideInsteadOfDeleteModal-C4AKxh50.js +1 -0
  10. package/dist/assets/IconPickerModal-B9UeIP7Z.js +1 -0
  11. package/dist/assets/ImportXmlModal-Cf75oVpN.js +1 -0
  12. package/dist/assets/{MonacoEditor-CEYP9b6u.js → MonacoEditor-B3J81C8F.js} +2 -2
  13. package/dist/assets/NewButtonModal-DhGNLWEW.js +1 -0
  14. package/dist/assets/NewGroupModal-CMLOZ15C.js +1 -0
  15. package/dist/assets/NewTabModal-N7FF7DT1.js +1 -0
  16. package/dist/assets/RuleEditorPanel-C9CcMM1s.js +1 -0
  17. package/dist/assets/ScriptView-B0ILfTWe.js +1 -0
  18. package/dist/assets/TabDisplayRulesPanel-DVMEaWWv.js +1 -0
  19. package/dist/assets/TitleTranslationsView-C68zJcNK.js +1 -0
  20. package/dist/assets/TranslationsView-BZXsG_LU.js +1 -0
  21. package/dist/assets/WebResourceBrowser-DEXq2SCy.js +1 -0
  22. package/dist/assets/XmlView-DEUwTHCt.js +2 -0
  23. package/dist/assets/crmParameters-Dxz06tk4.js +1 -0
  24. package/dist/assets/{dnd-iy5K5XAJ.js → dnd-C19d6Mn0.js} +1 -1
  25. package/dist/assets/fluent-ui-BThr2m8u.js +59 -0
  26. package/dist/assets/index-Df9NSpg6.js +136 -0
  27. package/dist/assets/index-browser-Bmt9T2GD.js +2 -0
  28. package/dist/assets/languages-CGjPBPNA.js +1 -0
  29. package/dist/assets/{monaco-cQE5XS3B.js → monaco-DzBcrxae.js} +1 -1
  30. package/dist/assets/monacoSetup-BRltj-y7.js +1 -0
  31. package/dist/assets/publishService-CKoTOngS.js +36 -0
  32. package/dist/assets/ribbonXsdCheck-CJBpxpVm.js +1923 -0
  33. package/dist/assets/{server.browser-DTeSoizu.js → server.browser-BokSAg1N.js} +1 -1
  34. package/dist/assets/useReplaceWebResourceConfirm-BUfgdCRQ.js +1 -0
  35. package/dist/assets/{useStableKeys-49o4VnxU.js → useStableKeys-EsghhjoV.js} +1 -1
  36. package/dist/assets/xmlValidator-Dki8Hf7Y.js +3 -0
  37. package/dist/assets/xmllint-CcuGSrO9.wasm +0 -0
  38. package/dist/assets/xmllint-browser-C85XrDSU.js +4 -0
  39. package/dist/icons/icon.svg +11 -4
  40. package/dist/index.html +3 -3
  41. package/package.json +2 -1
  42. package/dist/assets/BulkPublishModal-BWRed6Fv.js +0 -36
  43. package/dist/assets/CommandEditorPanel-B7W3Sqiu.js +0 -1
  44. package/dist/assets/CommandPalette-Fc4MPKvd.js +0 -1
  45. package/dist/assets/CompareView-D1FOwnU1.js +0 -7
  46. package/dist/assets/CrmParameterEditor-DO6Rt764.js +0 -1
  47. package/dist/assets/EditorDrawer-BtFb9OzQ.js +0 -2
  48. package/dist/assets/HideInsteadOfDeleteModal-fdtkLfSG.js +0 -1
  49. package/dist/assets/IconPickerModal-FyQ9ud3R.js +0 -1
  50. package/dist/assets/ImportXmlModal-BZq0Iglk.js +0 -1
  51. package/dist/assets/NewButtonModal-5nQ-f2by.js +0 -1
  52. package/dist/assets/NewGroupModal-vEuxSpnD.js +0 -1
  53. package/dist/assets/NewTabModal-DNzMru8E.js +0 -1
  54. package/dist/assets/RuleEditorPanel-B0u4b6vi.js +0 -1
  55. package/dist/assets/ScriptView-Ct4i8Jja.js +0 -1
  56. package/dist/assets/TabDisplayRulesPanel-HMmGkIxe.js +0 -1
  57. package/dist/assets/TranslationsView-DT4Ce3_W.js +0 -1
  58. package/dist/assets/WebResourceBrowser-L3R7UTNR.js +0 -1
  59. package/dist/assets/XmlView-CyLtgYex.js +0 -2
  60. package/dist/assets/crmParameters-rgfZhhzN.js +0 -1
  61. package/dist/assets/fluent-ui-CQyNN9H3.js +0 -59
  62. package/dist/assets/index-D7TexD30.js +0 -136
  63. package/dist/assets/monacoSetup-BIq1zGyP.js +0 -1
  64. package/dist/assets/ruleKinds-BKTUiZ1-.js +0 -1
  65. package/dist/assets/useReplaceWebResourceConfirm-BdTw98QF.js +0 -1
  66. package/dist/assets/xmlValidator-xIq-x9Ub.js +0 -3
@@ -1 +0,0 @@
1
- import{l as o,m as e,W as a,a as n}from"./monaco-cQE5XS3B.js";import"./fluent-ui-CQyNN9H3.js";import"./preload-helper-PPVm8Dsz.js";o.config({monaco:e});self.MonacoEnvironment={getWorker(p,r){return r==="typescript"||r==="javascript"?new a:new n}};
@@ -1 +0,0 @@
1
- const u={CommandClientTypeRule:"Client (Unified Interface / legacy)",CrmClientTypeRule:"Client (web / Outlook)",CrmOfflineAccessStateRule:"Offline access",CrmOutlookClientTypeRule:"Outlook client",CrmOutlookClientVersionRule:"Outlook client version",CustomRule:"Your JavaScript",DeviceTypeRule:"Device",EntityPrivilegeRule:"Table privilege",EntityPropertyRule:"Table property",EntityRule:"Table",FeatureControlRule:"Feature control bit",FormEntityContextRule:"Form's table",FormStateRule:"Form state",FormTypeRule:"Form type",HideForTabletExperienceRule:"Hide on tablets",MiscellaneousPrivilegeRule:"Other privilege",OptionSetRule:"Choice value",OrganizationSettingRule:"Organization setting",OrRule:"Any of (Or)",OutlookItemTrackingRule:"Outlook item tracking",OutlookRenderTypeRule:"Outlook or web",OutlookVersionRule:"Outlook version",PageRule:"Page address",RawRule:"Other rule (kept as XML)",RecordPrivilegeRule:"Record privilege",ReferencingAttributeRequiredRule:"Referencing column required",RelationshipTypeRule:"Relationship type",SelectionCountRule:"Selected records",SkuRule:"Deployment (online / on-premises)",ValueRule:"Column value"},n=[{label:"Client and device",kinds:["CommandClientTypeRule","CrmClientTypeRule","DeviceTypeRule","CrmOutlookClientVersionRule"]},{label:"Form",kinds:["FormStateRule","FormTypeRule","FormEntityContextRule"]},{label:"Table",kinds:["EntityRule","EntityPrivilegeRule","EntityPropertyRule","OptionSetRule"]},{label:"Selection and record",kinds:["SelectionCountRule","ValueRule","RecordPrivilegeRule"]},{label:"Other",kinds:["MiscellaneousPrivilegeRule","OrganizationSettingRule","FeatureControlRule","PageRule","SkuRule","HideForTabletExperienceRule","RelationshipTypeRule","ReferencingAttributeRequiredRule"]},{label:"Outlook",kinds:["CrmOfflineAccessStateRule","CrmOutlookClientTypeRule","OutlookItemTrackingRule","OutlookRenderTypeRule","OutlookVersionRule"]},{label:"Combine steps",kinds:["OrRule"]},{label:"Your code",kinds:["CustomRule"]}],o=new Set(["CustomRule","OutlookItemTrackingRule","RecordPrivilegeRule","SelectionCountRule"]),l=new Set(["CrmOutlookClientVersionRule","DeviceTypeRule","EntityPrivilegeRule","EntityPropertyRule","FeatureControlRule","FormEntityContextRule","FormTypeRule","HideForTabletExperienceRule","MiscellaneousPrivilegeRule","OptionSetRule","OrganizationSettingRule","OutlookRenderTypeRule","ReferencingAttributeRequiredRule","RelationshipTypeRule"]),r=new Set([...Array.from(l),"HideIfNetBreezeNotAvailableRule","HideIfServiceMetadataAvailableRule","HideIfSharepointS2SConfigurationEnabledRule","HideIfExportToExcelNotEnabledRule","IsExportToExcelOnlineEnabledRule","HideIfDisabledForMobileRule","HideIfHybridSSSNotEnabledRule","HideIfEmailSignatureNotEnabledRule","HideIfReverseHybridSSSNotEnabledRule","HideIfDelveNotAvailableRule","HideIfTestExchangeServerNotEnabledRule","HideIfSSSTroubleshootingNotEnabledRule","HideIfCurrentUserIsNotSystemAdministratorRule","HideIfPowerBITileNotAvailableRule","HideIfProcessActiveRule","HideIfProcessInactiveRule","HideIfProcessUnificationIsDisabledRule","HideIfO365UserDoesNotHaveExchangeSubscriptionsRule","HideIfEmailIsApprovedByAdminRule","HideIfUserIsNotTenantAdminRule","HideIfEmailIsApprovedByAdminBasedOnESPRule","HideIfProductRecommendationsNotEnabledRule"]);function R(e,t,i=!1){return e==="RawRule"||i&&e==="OrRule"?!1:t==="enable"?!l.has(e):!o.has(e)}export{r as D,o as E,n as R,u as a,R as i};
@@ -1 +0,0 @@
1
- import{r,j as e,D as g,f as x,g as m,h,n as j,t as f,c as l,o as y,k as o}from"./fluent-ui-CQyNN9H3.js";import{S as b,at as k}from"./index-D7TexD30.js";function w(){const[n,t]=r.useState(null),c=r.useRef(null),d=b(a=>a.connectionVersion),s=r.useCallback(a=>{c.current?.(a),c.current=null,t(null)},[]),p=r.useCallback(a=>new Promise(i=>{c.current?.("cancel"),c.current=i,t({name:a.name,managed:a.managed})}),[]);r.useEffect(()=>()=>s("cancel"),[d,s]);const u=e.jsx(g,{open:n!==null,onOpenChange:(a,i)=>!i.open&&s("cancel"),children:e.jsx(x,{style:{maxWidth:520},children:e.jsxs(m,{children:[e.jsx(h,{children:n?.managed?"Use the existing web resource?":"Replace the existing web resource?"}),e.jsxs(j,{style:{display:"flex",flexDirection:"column",gap:f.spacingVerticalS},children:[n?.managed?e.jsxs(l,{children:["A managed web resource named ",e.jsx("strong",{children:n.name})," already exists. It can't be replaced: keep it as it is, or rename the file and upload it again."]}):e.jsxs(l,{children:["A web resource named ",e.jsx("strong",{children:n?.name})," already exists. Replacing it changes its content everywhere it is used (other ribbons, forms, apps)."]}),e.jsx(k,{prefix:"In"})]}),e.jsxs(y,{children:[e.jsx(o,{appearance:"secondary",onClick:()=>s("cancel"),children:"Cancel"}),e.jsx(o,{appearance:n?.managed?"primary":"secondary",onClick:()=>s("keep"),children:"Keep existing"}),!n?.managed&&e.jsx(o,{appearance:"primary",onClick:()=>s("replace"),children:"Replace"})]})]})})});return{onExisting:p,dialog:u}}export{w as u};
@@ -1,3 +0,0 @@
1
- import{af as v,ag as ie,ah as re,ai as V,aj as le,p as ce}from"./index-D7TexD30.js";import{D as ue,E as me}from"./ruleKinds-BKTUiZ1-.js";import{C as de,i as fe}from"./crmParameters-rgfZhhzN.js";const pe=/^[a-zA-Z_$][a-zA-Z_$0-9.]*$/,he=/^[a-zA-Z_][a-zA-Z_0-9]*$/,ge=/^[+-]?\d+$/,be=/^[+-]?(\d+(\.\d*)?|\.\d+)$/,H=/^(true|false|1|0)$/,W={JavaScriptFunction:["FunctionName","Library"],Url:["Address"],CustomRule:["FunctionName","Library"],CommandClientTypeRule:["Type"],CrmClientTypeRule:["Type"],CrmOfflineAccessStateRule:["State"],CrmOutlookClientTypeRule:["Type"],CrmOutlookClientVersionRule:["Major"],DeviceTypeRule:["Type"],EntityPrivilegeRule:["PrivilegeType","PrivilegeDepth"],EntityPropertyRule:["PropertyName","PropertyValue"],FeatureControlRule:["FeatureControlBit","ExpectedValue"],FormEntityContextRule:["EntityName"],FormStateRule:["State"],FormTypeRule:["Type"],MiscellaneousPrivilegeRule:["PrivilegeName"],OptionSetRule:["OptionSet","StateCode","ObjectTypeCode"],OrganizationSettingRule:["Setting"],OutlookItemTrackingRule:["TrackedInCrm"],OutlookRenderTypeRule:["Type"],OutlookVersionRule:["Version"],PageRule:["Address"],RecordPrivilegeRule:["PrivilegeType"],RelationshipTypeRule:["AppliesTo"],SkuRule:["Sku"],ValueRule:["Field","Value"],BoolParameter:["Value"],CrmParameter:["Value"],DecimalParameter:["Value"],IntParameter:["Value"],StringParameter:["Value"]},ye=new Set(["ValueRule.Value","StringParameter.Value"]),$e={SelectionCountRule:["Minimum","Maximum"],CrmOutlookClientVersionRule:["Major","Minor","Build","Revision"],IntParameter:["Value"],Url:["WinMode"]},Ae={DecimalParameter:["Value"]},Re={BoolParameter:["Value"],Url:["PassParams"],OutlookItemTrackingRule:["TrackedInCrm"],EntityPropertyRule:["PropertyValue"],FeatureControlRule:["ExpectedValue"],RelationshipTypeRule:["AllowCustomRelationship","AllowSystemRelationship"]},Se=["Default","InvertResult"],Ie=new Set(["BoolParameter","CrmParameter","DecimalParameter","IntParameter","StringParameter"]),O=s=>Array.from(s.children);function q(s,l,g){const u=[],f=s.tagName;for(const p of W[f]??[]){const m=s.getAttribute(p);(m===null||!m.trim()&&!ye.has(`${f}.${p}`))&&u.push(`${l}: ${f} has no ${p}`)}const b=(p,m,i)=>{for(const d of p??[]){const R=s.getAttribute(d);R===null||R===""&&W[f]?.includes(d)||m.test(R.trim())||u.push(`${l}: ${f} ${d}="${R}" is not ${i}`)}};if(b($e[f],ge,"a whole number"),b(Ae[f],be,"a number"),b(Re[f],H,"true or false"),g&&b(Se,H,"true or false"),f==="JavaScriptFunction"||f==="CustomRule"){const p=s.getAttribute("FunctionName");p?.trim()&&!pe.test(p)&&u.push(`${l}: FunctionName "${p}" isn't a JavaScript function name (letters, digits, _, $ and dots)`)}if((f==="JavaScriptFunction"||f==="CustomRule")&&/^\$webresource:\s*$/i.test(s.getAttribute("Library")??"")&&u.push(`${l}: ${f} Library names no web resource`),f==="EntityRule"){const p=s.getAttribute("Context");p!==null&&!he.test(p)&&u.push(`${l}: EntityRule Context "${p}" isn't valid`)}f==="Url"&&/^https?:\/\/$/i.test(s.getAttribute("Address")?.trim()??"")&&u.push(`${l}: Url has no address`);for(const p of O(s).filter(m=>Ie.has(m.tagName)))f==="Url"&&!p.getAttribute("Name")?.trim()&&u.push(`${l}: a ${p.tagName} of the Url has no Name`),f!=="Url"&&p.hasAttribute("Name")&&u.push(`${l}: a ${p.tagName} of ${f} can't have a Name`),u.push(...q(p,l,!1));return u}function we(s){const l=s.getAttribute("Id")??"";if(s.tagName==="CommandDefinition"){const b=`Command ${l}`,p=O(s).find(m=>m.tagName==="Actions");return O(p??s).filter(m=>m.tagName==="JavaScriptFunction"||m.tagName==="Url").flatMap(m=>q(m,b,!1))}if(s.tagName!=="EnableRule"&&s.tagName!=="DisplayRule")return[];const g=`${s.tagName==="EnableRule"?"Enable":"Display"} rule ${l}`,u=O(s);if(u.length===0)return[`${g} has no steps — add one, or remove the rule from its commands`];const f=[];for(const b of u){if(b.tagName!=="OrRule"){f.push(...q(b,g,!0));continue}const p=O(b).filter(m=>m.tagName==="Or");p.length<2&&f.push(`${g}: an OrRule needs at least 2 alternatives (it has ${p.length})`);for(const m of p){const i=O(m);i.length===0&&f.push(`${g}: an alternative of its OrRule has no steps`);for(const d of i)d.tagName==="OrRule"?f.push(`${g}: an OrRule can't contain another OrRule`):f.push(...q(d,g,!0))}}return f}const Ne=["Mscrm.HideOnModern","Mscrm.ShowOnlyOnModern"];function E(s,l){const g=s.indexOf(l);return g<0?void 0:`Line ${s.slice(0,g).split(/\r?\n/).length}`}function _e(s,l,g){const u=[],b=new DOMParser().parseFromString(s,"application/xml"),p=b.querySelector("parsererror");if(p){const i=(p.textContent??"").replace(/This page contains the following errors:/i,"").replace(/Below is a rendering of the page up to the first error\.?/i,"").trim()||"Unknown",d=i.match(/line\s+(\d+)/i);return u.push({message:`XML parse error: ${i}`,lineHint:d?`Line ${d[1]}`:void 0}),u}const m=new Set([]);return b.querySelectorAll("[Id]").forEach(i=>{const d=i.getAttribute("Id")??"";if(/\s/.test(d)){const R=E(s,`Id="${d}"`);u.push({message:`Element ID "${d}" contains invalid whitespace characters`,elementId:d,lineHint:R})}}),b.querySelectorAll("[LabelText]").forEach(i=>{const d=i.getAttribute("LabelText")??"",R=d.match(/^\$LocLabels:(.+)$/);if(R&&m.size>0&&!m.has(R[1])){const $=i.getAttribute("Id")??"",S=E(s,$?`Id="${$}"`:`LabelText="${d}"`);u.push({message:`Button label reference "$LocLabels:${R[1]}" has no matching LocLabel entry`,elementId:$||void 0,lineHint:S})}}),(s.includes("& ")||s.includes(`&
2
- `))&&u.push({message:'URL may contain an unescaped "&" — all ampersands in XML must be written as &amp;',lineHint:E(s,"& ")??E(s,`&
3
- `)}),b.querySelectorAll("Group").forEach(i=>{const d=[];i.querySelectorAll(":scope > Controls > Button, :scope > Controls > FlyoutAnchor, :scope > Controls > SplitButton").forEach(R=>{const $=parseInt(R.getAttribute("Sequence")??"0",10);if(d.includes($)){const S=i.getAttribute("Id")??"?";u.push({message:`Two elements share Sequence "${$}" in group "${S}"`,elementId:S,lineHint:E(s,`Sequence="${$}"`)})}d.push($)})}),u.push(...Ee(b,s)),u}const X=new Set(["BoolParameter","CrmParameter","DecimalParameter","IntParameter","StringParameter"]);function A(s){return Array.from(s.children)}function te(s,l){return l==="enable"?ue.has(s):me.has(s)}function Ee(s,l){const g=[],u=(m,i,d)=>g.push({message:m,elementId:d,lineHint:E(l,i)}),f=(m,i,d)=>g.push({message:m,elementId:d,lineHint:E(l,i),severity:"warning"}),b=s.querySelector("RibbonDiffXml > RuleDefinitions"),p=[{tag:"EnableRule",label:"Enable",container:"enable"},{tag:"DisplayRule",label:"Display",container:"display"}];for(const{tag:m,label:i,container:d}of p)b?.querySelectorAll(`:scope > ${m}s > ${m}`).forEach(R=>{const $=R.getAttribute("Id")??"",S=A(R);S.length===0&&u(`${i} rule "${$}" has no steps — the schema requires at least one`,`Id="${$}"`,$);const D=I=>{te(I.tagName,d)&&f(`${i} rule "${$}" contains ${I.tagName}, which RibbonTypes.xsd only allows in ${d==="enable"?"display":"enable"} rules`,`<${I.tagName}`,$)};for(const I of S){if(I.tagName!=="OrRule"){D(I);continue}const T=A(I);T.filter(w=>w.tagName==="Or").length<2&&u(`OrRule in ${i.toLowerCase()} rule "${$}" needs at least 2 <Or> children (found ${T.filter(w=>w.tagName==="Or").length})`,"<OrRule",$);for(const w of T){const C=A(w);C.length===0&&u(`Empty <Or> in rule "${$}"`,"<Or",$);for(const L of C)L.tagName==="OrRule"?u(`Rule "${$}": an <Or> cannot contain another OrRule`,"<OrRule",$):D(L)}}});return b||s.querySelectorAll("OrRule").forEach(m=>{const i=m.querySelectorAll(":scope > Or").length;i<2&&u(`OrRule requires at least 2 <Or> children (found ${i})`,"<OrRule")}),s.querySelectorAll("JavaScriptFunction, CustomRule").forEach(m=>{for(const i of A(m)){if(!X.has(i.tagName))continue;i.hasAttribute("Name")&&u(`${i.tagName} inside <${m.tagName}> must not have a Name attribute (only <Url> parameters are named)`,`<${i.tagName} Name=`);const d=i.getAttribute("Value")??"";i.tagName==="CrmParameter"&&!de.has(d)&&u(`CrmParameter Value "${d}" is not a valid CrmParameterValue`,`Value="${d}"`)}}),s.querySelectorAll("Url").forEach(m=>{for(const i of A(m)){if(!X.has(i.tagName))continue;i.getAttribute("Name")||u(`${i.tagName} inside <Url> requires a Name (the query-string key)`,`<${i.tagName}`);const d=i.getAttribute("Value")??"";i.tagName==="CrmParameter"&&!fe(d)&&u(`CrmParameter Value "${d}" is not allowed in a <Url> action (CrmNamedParameterValue)`,`Value="${d}"`)}}),s.querySelector("RibbonDiffXml > Scalings")&&u('<Scalings> is not allowed in RibbonDiffXml — scaling changes are CustomActions with Location="{tabId}.Scaling._children"',"<Scalings"),s.querySelectorAll("CustomAction > CommandUIDefinition > Tab").forEach(m=>{const i=m.getAttribute("Id")??"",d=A(m).map(S=>S.tagName),R=d.indexOf("Scaling"),$=d.indexOf("Groups");(R<0||$>=0&&R>$)&&u(`Tab "${i}" needs a <Scaling Id> element before <Groups>`,`Id="${i}"`,i)}),s.querySelectorAll("TabDisplayRule > DisplayRules").forEach(()=>{u("TabDisplayRule rules must be direct children — remove the <DisplayRules> wrapper","<TabDisplayRule")}),g}const Te=["LabelText","ToolTipTitle","ToolTipDescription","Alt","Title","Description"],Ce=new Set(["powerFx","customApi"]),Le={powerFx:"Power Fx",customApi:"Custom API"};function ve(s){return[...new Set(s.actions.map(l=>l.kind).filter(l=>Ce.has(l)))]}const K=/^\$LocLabels:(.+)$/,ne=/^\$webresource:([^?#]+)/i,J=new Set(["ModernImage","Image16by16","Image32by32"]),Q=new Set(["Tab","Group"]),oe=new Set(["main_system_library.js"]),Oe=new Set(["FlyoutAnchor","SplitButton"]),Pe=new Set(["Button","FlyoutAnchor","SplitButton","TextBox","ComboBox","CheckBox"]),Y=/^(.+)\.Scaling\._children$/,Z=s=>/^(Mscrm|Microsoft)\./.test(s);function ae(s){const l=[],g=[],u=new DOMParser;for(const f of Object.keys(s))for(const[b,p]of s[f]){const m=u.parseFromString(p,"application/xml");if(m.querySelector("parsererror")){g.push({severity:"error",code:"xml-parse",message:`${f} element ${b} is not well-formed XML`,elementId:b});continue}l.push({part:f,key:`${f}:${b}`,el:m.documentElement})}return{elements:l,errors:g}}function N(s){return[s,...Array.from(s.getElementsByTagName("*"))]}function se(s){return typeof s=="string"?ce(s):s}function Be(s){let l;try{l=se(s)}catch{return[]}const g=new Map;for(const{el:u}of ae(l).elements)for(const f of N(u))for(const b of Array.from(f.attributes)){const p=ne.exec(b.value.trim())?.[1],m=p?.toLowerCase();p&&m&&!oe.has(m)&&!g.has(m)&&g.set(m,p)}return[...g.values()]}const ee=s=>{const l=s.trim();return l&&!l.includes(".")?`Mscrm.Templates.${l}`:l};function qe(s,l={}){let g;try{g=se(s)}catch(e){return[{severity:"error",code:"xml-parse",message:e instanceof Error?e.message:String(e)}]}const{elements:u,errors:f}=ae(g),b=l.changedKeys?new Set(l.changedKeys):null,p=e=>!b||b.has(e),m=new Set(l.newKeys??[]),i=(e,n,t,a,o=!1)=>{const r=(Array.isArray(n)?n:[n]).some(p);f.push({severity:o||!r?"warning":"error",code:e,message:r?t:`${t} (already in the published customizations)`,elementId:a})},d=u.filter(e=>e.part==="customActions"),R=u.filter(e=>e.part==="commandDefinitions");for(const{part:e,key:n,el:t}of u)if(!(e!=="commandDefinitions"&&e!=="enableRules"&&e!=="displayRules"))for(const a of we(t))i("schema",n,a,t.getAttribute("Id")??void 0);const $=new Map((l.commands??[]).map(e=>[e.id,e]));for(const{key:e,el:n}of R){const t=n.getAttribute("Id")??"",a=$.get(t);if(!a||!p(e))continue;const o=ve(a);o.length!==0&&i("dropped-action",e,`Command ${t} has a ${o.map(r=>Le[r]??r).join(" / ")} action — classic ribbon commands can't run it, so it would be dropped; remove the action`,t)}const S=new Set;for(const{el:e}of d)if(e.tagName==="CustomAction")for(const n of Array.from(e.getElementsByTagName("*")))n.getAttribute("Command")===v&&S.add(n.getAttribute("Id")??"");for(const{key:e,el:n}of d){if(n.tagName!=="HideCustomAction")continue;const t=n.getAttribute("Location")??"";!S.has(t)&&!ie({id:t,commandId:v})||i("open-record-hidden",e,`${t} is hidden, but it carries the record open override (${v}) — Unified Interface may then open records as usual or fail to open them; unhide it, or turn the override off`,t,!0)}for(const{key:e,el:n}of R){if(n.getAttribute("Id")!==v)continue;const t=A(n).filter(o=>o.tagName==="DisplayRules").flatMap(o=>A(o).map(r=>r.getAttribute("Id")??r.tagName));if(t.length===0)continue;const a=t.includes("Mscrm.HideOnModern")?Ne.filter(o=>t.includes(o)):[];i("open-record-hidden",e,`${v} has display rules (${t.join(", ")})${a.length>0?` — ${a.join(" + ")} hide its button`:""}: where they hide the "Open record" button, the record open override may stop working; the button must stay shown`,v,!0)}for(const{key:e,el:n}of d)for(const t of Array.from(n.getElementsByTagName("*"))){if(!Oe.has(t.tagName)||A(t).some(o=>o.tagName==="Menu"))continue;const a=t.getAttribute("Id")??"";if(re(t.getAttribute("PopulateDynamically"))){t.getAttribute("PopulateQueryCommand")?.trim()||i("menu-missing",e,`${t.tagName} ${a} is populated dynamically but has no PopulateQueryCommand — its drop-down may stay empty`,a,!0);continue}i("menu-missing",e,`${t.tagName} ${a} has no <Menu> — it would publish as an empty drop-down`,a)}const D=new Set(l.menuControlsIds??[]);for(const{key:e,el:n}of d){const t=n.getAttribute("Location")??"",a=t.endsWith("._children")&&D.has(t.slice(0,-10));for(const o of Array.from(n.getElementsByTagName("*"))){const r=a||!!o.parentElement?.closest("Menu");for(const c of Te){const y=o.getAttribute(c);if(!y?.startsWith("$LocLabels:"))continue;const h=y.slice(11);h.length<=V||i("label-id-length",e,`${o.tagName} ${o.getAttribute("Id")??""} uses label ${h} (${h.length} characters)`+(r?`: a menu item's label id may have at most ${V} characters, or the publish fails after the import — give the control a shorter id`:`: label ids over ${V} characters fail inside menus; consider a shorter control id`),o.getAttribute("Id")??void 0,!r)}}}if(l.known?.commandIds){const e=new Set([...g.commandDefinitions.keys(),...l.known.commandIds]);for(const{key:n,el:t}of d)for(const a of Array.from(t.getElementsByTagName("*")))if(!Q.has(a.tagName))for(const o of["Command","PopulateQueryCommand"]){const r=a.getAttribute(o);if(!r||e.has(r))continue;const c=a.getAttribute("Id")??"";i("undefined-command",n,`${a.tagName} ${c} uses ${o==="Command"?"command":"PopulateQueryCommand"} ${r}, which is defined neither in the customizations nor in the loaded ribbon`,c,Z(r))}}const I={EnableRule:l.known?.enableRuleIds?new Set([...g.enableRules.keys(),...l.known.enableRuleIds]):null,DisplayRule:l.known?.displayRuleIds?new Set([...g.displayRules.keys(),...l.known.displayRuleIds]):null};for(const{key:e,el:n}of R){const t=n.getAttribute("Id")??"",a=A(n).filter(o=>o.tagName==="EnableRules"||o.tagName==="DisplayRules").flatMap(A);for(const o of a){const r=I[o.tagName],c=o.getAttribute("Id");!r||!c||r.has(c)||i("undefined-rule",e,`Command ${t} uses ${o.tagName==="EnableRule"?"enable":"display"} rule ${c}, which is defined neither in the customizations nor in the loaded ribbon`,t,Z(c))}}for(const{part:e,key:n,el:t}of u){if(e!=="enableRules"&&e!=="displayRules")continue;const a=e==="enableRules"?"enable":"display",o=t.getAttribute("Id")??"",r=A(t).flatMap(c=>c.tagName==="OrRule"?A(c).filter(y=>y.tagName==="Or").flatMap(A):[c]);for(const c of r)te(c.tagName,a)&&i("rule-placement",n,`${a==="enable"?"Enable":"Display"} rule ${o} contains ${c.tagName}, which the ribbon schema only allows in ${a==="enable"?"display":"enable"} rules`,o,!0)}const T=new Set;for(const e of Object.values(l.loadedAttributes??{}))for(const n of Object.values(e))K.test(n)&&T.add(n);for(const{key:e,el:n}of u)if(n.tagName!=="LocLabel")for(const t of N(n))for(const a of Array.from(t.attributes)){const o=K.exec(a.value)?.[1];if(!o||g.locLabels.has(o))continue;const r=t.getAttribute("Id")??void 0;r&&l.loadedAttributes?.[r]?.[a.name]===a.value||T.has(a.value)||i("loclabel-missing",e,`${[t.tagName,r,a.name].filter(Boolean).join(" ")} references $LocLabels:${o}, which has no <LocLabel> in these customizations — the text won't resolve unless another solution defines the label`,r,!0)}const w=new Map;for(const{key:e,el:n}of d){const t=n.getAttribute("Location")??"",a=n.getAttribute("Sequence");if(n.tagName!=="CustomAction"||!t.endsWith("._children")||!a)continue;const o=`${t}|${a}`;w.set(o,[...w.get(o)??[],{key:e,id:n.getAttribute("Id")??e}])}for(const[e,n]of w){if(n.length<2||!n.some(o=>p(o.key)))continue;const[t,a]=e.split("|");i("duplicate-sequence",n.map(o=>o.key),`${n.map(o=>o.id).join(" and ")} have the same Sequence (${a}) in ${t} — their order isn't defined; give one another Sequence`,n[0].id,!0)}for(const{key:e,el:n}of u)for(const t of N(n))for(const a of Array.from(t.attributes)){if(a.name!=="Library"&&!J.has(a.name))continue;const o=/^\/?WebResources\/(.+)$/i.exec(a.value.trim())?.[1];o&&i("webresource-path",e,`${t.tagName} ${t.getAttribute("Id")??""} ${a.name} is the path ${a.value} — use $webresource:${o}, the only form that makes the solution depend on the web resource`.replace(/\s+/g," "),t.getAttribute("Id")??void 0,!0)}if(l.webResources){const e=new Set;for(const{el:n}of u)for(const t of N(n))for(const a of Array.from(t.attributes)){const o=ne.exec(a.value.trim())?.[1],r=o?.toLowerCase();if(!o||!r||oe.has(r)||e.has(r))continue;const c=l.webResources[r];if(!c)continue;const y=t.getAttribute("Id")??void 0;c.exists?!c.inSolution&&!c.managed&&(e.add(r),f.push({severity:"warning",code:"webresource-not-in-solution",message:`Web resource ${o} isn't in the selected solution — the ribbon won't import into another environment without it`,elementId:y})):(e.add(r),f.push({severity:"warning",code:"webresource-missing",message:`Web resource ${o} (${t.tagName} ${a.name}) doesn't exist in this environment — ${J.has(a.name)?"the button will show no icon":"the action or rule that loads it will fail when it runs"}`,elementId:y}))}}const C=new Map,L=e=>{let n=C.get(e);return n||C.set(e,n=new Map),n};for(const[e,n]of Object.entries(l.tabScaling??{})){for(const t of n.maxSizes)L(e).set(t.id,{...t,tag:"MaxSize"});for(const t of n.scales)L(e).set(t.id,{...t,tag:"Scale"})}const F=new Map(Object.entries(l.groupTemplates??{}).map(([e,n])=>[e,ee(n)])),z=new Map(Object.entries(l.templateLayouts??{}));for(const{part:e,el:n}of u)if(e==="templates")for(const t of N(n).filter(a=>a.tagName==="GroupTemplate")){const a=A(t).filter(o=>o.tagName==="Layout").map(o=>o.getAttribute("Title")??"");z.set(t.getAttribute("Id")??"",a)}const j=[];for(const{key:e,el:n}of d){for(const r of Array.from(n.getElementsByTagName("Group"))){const c=r.getAttribute("Template");c&&F.set(r.getAttribute("Id")??"",ee(c))}const t=[],a=Y.exec(n.getAttribute("Location")??"")?.[1],o=A(n).find(r=>r.tagName==="CommandUIDefinition");if(a&&o)for(const r of A(o))t.push([a,r]);for(const r of Array.from(n.getElementsByTagName("Tab")))for(const c of A(r).filter(y=>y.tagName==="Scaling"))for(const y of A(c))t.push([r.getAttribute("Id")??"",y]);for(const[r,c]of t){if(c.tagName!=="MaxSize"&&c.tagName!=="Scale")continue;const y={id:c.getAttribute("Id")??"",tag:c.tagName,groupId:c.getAttribute("GroupId")??"",size:c.getAttribute("Size")??"",sequence:parseInt(c.getAttribute("Sequence")??"",10),key:e};L(r).set(y.id,y),j.push(y)}}for(const[e,n]of C){const t=new Map;for(const a of n.values())Number.isNaN(a.sequence)||t.set(a.sequence,[...t.get(a.sequence)??[],a]);for(const[a,o]of t){const r=[...new Set(o.flatMap(h=>h.key?[h.key]:[]))];if(o.length<2||r.length===0)continue;const c=o.find(h=>h.key&&h.tag==="MaxSize"&&h.id===`${h.groupId}.MaxSize`),y=c?`move group ${c.groupId} to another position (its MaxSize takes the group's Sequence; #66 picks a free one automatically)`:"give each step its own Sequence";i("scaling-collision",r,`Scaling of tab ${e}: ${o.map(h=>`${h.tag} ${h.id}`).join(" and ")} have the same Sequence ${a} — Unified Interface then drops every custom control of the table; ${y}`,o.find(h=>h.key)?.id)}}for(const e of j){const n=F.get(e.groupId),t=n?z.get(n):void 0;!t?.length||t.includes(e.size)||i("scaling-size",e.key??[],`${e.tag} ${e.id} has Size "${e.size}", which isn't a layout of template ${n} used by group ${e.groupId} (${t.join(", ")})`,e.id,!0)}const x=new Set(l.known?.elementIds??[]),M=new Map;for(const{key:e,el:n}of d){if(!(n.getAttribute("Location")??"").endsWith("._children"))continue;const t=A(n).find(o=>o.tagName==="CommandUIDefinition"),a=t?A(t)[0]:void 0;if(!(!a||a.tagName==="MaxSize"||a.tagName==="Scale"))for(const o of N(a)){const r=o.getAttribute("Id");if(!r||o.closest("Scaling"))continue;const c=M.get(r)??[];c.includes(e)||M.set(r,[...c,e])}}for(const[e,n]of M)n.length>1?i("duplicate-id",n,`Id ${e} is added by more than one CustomAction (${n.map(t=>t.replace(/^customActions:ca:/,"")).join(", ")})`,e):m.has(n[0])&&x.has(e)&&i("duplicate-id",n,`Id ${e} is added as a new element, but the ribbon already has an element with this id`,e);if(l.places){const{entityLogicalName:e,tabByCollection:n}=l.places,t=new Set(["Mscrm.Tabs",`Mscrm.SubGrid.${e}.ContextualTabs`]);for(const{key:a,el:o}of d){const r=o.getAttribute("Location")??"",c=/^(.+)\._children$/.exec(r)?.[1];if(!c||Y.test(r)||!p(a))continue;const y=A(o).find(k=>k.tagName==="CommandUIDefinition"),h=y?A(y)[0]:void 0,P=h?.getAttribute("Id")??"";if(!h||!P||!(Pe.has(h.tagName)||Q.has(h.tagName)))continue;const B=c.split("{!EntityLogicalName}").join(e),U=n[B];if(U!==void 0){le(U)&&i("orphan-location",a,`${h.tagName} ${P} is added to ${c}, on the tab ${U}: Unified Interface doesn't show that tab and the ribbon doesn't return what is added there, so it won't show anywhere — add it to the table's main tab instead`,P,!0);continue}const G=k=>k.replace(/\.(Controls|Groups)$/,"");t.has(B)||[c,B,G(c),G(B)].some(k=>M.has(k))||i("orphan-location",a,`${h.tagName} ${P} is added at ${r}, but this table's ribbon has no ${c} — it won't show anywhere (check the Location, or move it to an existing group)`,P,!0)}}const _=l.publisherPrefix?.trim().toLowerCase();if(_&&m.size>0){const e=new Set([...x,...l.known?.commandIds??[],...l.known?.enableRuleIds??[],...l.known?.displayRuleIds??[]]),n=o=>{const r=o.split(".");for(let c=r.length;c>0;c--)if(e.has(r.slice(0,c).join(".")))return!0;return!1},t=o=>{const r=o.toLowerCase();return r.startsWith(`${_}.`)||r.startsWith(`${_}_`)},a=new Set;for(const{part:o,key:r,el:c}of u)if(!(!m.has(r)||o==="templates"||o==="tabDisplayRules"))for(const y of N(c)){if(y!==c&&y.closest("Actions, EnableRules, DisplayRules, EnableRule, DisplayRule"))continue;const h=y.getAttribute("Id")??y.getAttribute("HideActionId");!h||a.has(h)||t(h)||n(h)||(a.add(h),f.push({severity:"warning",code:"id-prefix",message:`${y.tagName} id ${h} doesn't start with the publisher prefix "${_}." — ids without it can collide with other solutions`,elementId:h}))}}return f}export{_e as a,qe as v,Be as w};