@mohsinonxrm/pptb-commandbar-studio 0.9.0-beta.2 → 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 +242 -2
  2. package/README.md +16 -14
  3. package/SECURITY.md +4 -4
  4. package/dist/assets/BulkPublishModal-9_XxYmS2.js +2 -0
  5. package/dist/assets/CommandEditorPanel-BtBG8540.js +1 -0
  6. package/dist/assets/CommandPalette-C2YXN_gD.js +1 -0
  7. package/dist/assets/CompareView-Beq5V68_.js +11 -0
  8. package/dist/assets/CrmParameterEditor-DfZv5BuF.js +1 -0
  9. package/dist/assets/EditorDrawer-D0K8zHVK.js +2 -0
  10. package/dist/assets/HideInsteadOfDeleteModal-C4AKxh50.js +1 -0
  11. package/dist/assets/IconPickerModal-B9UeIP7Z.js +1 -0
  12. package/dist/assets/ImportXmlModal-Cf75oVpN.js +1 -0
  13. package/dist/assets/{MonacoEditor-DweI16yt.js → MonacoEditor-B3J81C8F.js} +2 -2
  14. package/dist/assets/NewButtonModal-DhGNLWEW.js +1 -0
  15. package/dist/assets/NewGroupModal-CMLOZ15C.js +1 -0
  16. package/dist/assets/NewTabModal-N7FF7DT1.js +1 -0
  17. package/dist/assets/RuleEditorPanel-C9CcMM1s.js +1 -0
  18. package/dist/assets/ScriptView-B0ILfTWe.js +1 -0
  19. package/dist/assets/TabDisplayRulesPanel-DVMEaWWv.js +1 -0
  20. package/dist/assets/TitleTranslationsView-C68zJcNK.js +1 -0
  21. package/dist/assets/TranslationsView-BZXsG_LU.js +1 -0
  22. package/dist/assets/WebResourceBrowser-DEXq2SCy.js +1 -0
  23. package/dist/assets/XmlView-DEUwTHCt.js +2 -0
  24. package/dist/assets/crmParameters-Dxz06tk4.js +1 -0
  25. package/dist/assets/{dnd-iy5K5XAJ.js → dnd-C19d6Mn0.js} +1 -1
  26. package/dist/assets/fluent-ui-BThr2m8u.js +59 -0
  27. package/dist/assets/index-Df9NSpg6.js +136 -0
  28. package/dist/assets/index-browser-Bmt9T2GD.js +2 -0
  29. package/dist/assets/languages-CGjPBPNA.js +1 -0
  30. package/dist/assets/{monaco-cQE5XS3B.js → monaco-DzBcrxae.js} +1 -1
  31. package/dist/assets/monacoSetup-BRltj-y7.js +1 -0
  32. package/dist/assets/publishService-CKoTOngS.js +36 -0
  33. package/dist/assets/ribbonXsdCheck-CJBpxpVm.js +1923 -0
  34. package/dist/assets/{server.browser-DTeSoizu.js → server.browser-BokSAg1N.js} +1 -1
  35. package/dist/assets/useReplaceWebResourceConfirm-BUfgdCRQ.js +1 -0
  36. package/dist/assets/{useStableKeys-49o4VnxU.js → useStableKeys-EsghhjoV.js} +1 -1
  37. package/dist/assets/xmlValidator-Dki8Hf7Y.js +3 -0
  38. package/dist/assets/xmllint-CcuGSrO9.wasm +0 -0
  39. package/dist/assets/xmllint-browser-C85XrDSU.js +4 -0
  40. package/dist/index.html +3 -3
  41. package/package.json +2 -1
  42. package/dist/assets/BulkPublishModal-DjdSDcWe.js +0 -36
  43. package/dist/assets/CommandEditorPanel-DYsxUTOk.js +0 -1
  44. package/dist/assets/CommandPalette-DihgRpHI.js +0 -1
  45. package/dist/assets/CompareView-CdQo0D6e.js +0 -7
  46. package/dist/assets/CrmParameterEditor-DO6Rt764.js +0 -1
  47. package/dist/assets/EditorDrawer-Cid60F3b.js +0 -2
  48. package/dist/assets/HideInsteadOfDeleteModal-Bk_foggy.js +0 -1
  49. package/dist/assets/IconPickerModal-CW_pvpVS.js +0 -1
  50. package/dist/assets/ImportXmlModal-BcszuTi-.js +0 -1
  51. package/dist/assets/NewButtonModal-C2fAUuZI.js +0 -1
  52. package/dist/assets/NewGroupModal-BDr4DPBs.js +0 -1
  53. package/dist/assets/NewTabModal-CYc1fc2A.js +0 -1
  54. package/dist/assets/RuleEditorPanel-BxGrJYo4.js +0 -1
  55. package/dist/assets/ScriptView-tkdIK4sg.js +0 -1
  56. package/dist/assets/TabDisplayRulesPanel-S_AxUWfB.js +0 -1
  57. package/dist/assets/TranslationsView-DZIGE2pC.js +0 -1
  58. package/dist/assets/WebResourceBrowser-Dc3kBMvH.js +0 -1
  59. package/dist/assets/XmlView-B0weY9hR.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-DRTwBo4g.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-BhU1AM5L.js +0 -1
  66. package/dist/assets/xmlValidator-CnbyWxHe.js +0 -3
@@ -0,0 +1,2 @@
1
+ const u={MiB:16,GiB:16384,defaultInitialMemoryPages:256,defaultMaxMemoryPages:512,max:65536};function d(e,t){return Array.isArray(e)||(e=[e]),e.map((r,n)=>typeof r=="string"?{fileName:`file_${n}.${t}`,contents:r}:r)}function y(e){const t=d(e.xml,"xml"),r=e.extension||"schema";p(["schema","relaxng"],"extension",r);const n=d(e.schema||[],"xsd"),l=d(e.preload||[],"xml");if(!e.disableFileNameValidation){for(const s of t.concat(n))if(/(^|\s)-/.test(s.fileName))throw new Error(`Invalid file name "${s.fileName}" that would be interpreted as a command line option.`)}const i=e.normalization||"";p(["","format","c14n"],"normalization",i);const f=t.concat(n,l);let a=[];if(n.forEach(function(s){a.push(`--${r}`),a.push(s.fileName)}),i?a.push(`--${i}`):a.push("--noout"),e.stream&&a.push("--stream"),t.forEach(function(s){a.push(s.fileName)}),e.modifyArguments&&(a=e.modifyArguments(a),!Array.isArray(a)))throw new Error("modifyArguments must return an array of arguments");const m={inputFiles:f,args:a,initialMemory:e.initialMemoryPages||u.defaultInitialMemoryPages,maxMemory:e.maxMemoryPages||u.defaultMaxMemoryPages};return v(m),m}function h(e){return e===0?!0:e===3||e===4?!1:null}function p(e,t,r){if(!e.includes(r)){const n=typeof r=="string"?`"${r}"`:r;throw new Error(`Invalid value for option ${t}: ${n}`)}}function v({initialMemory:e,maxMemory:t}){if(e<0||t<e||t>u.max)throw new Error(`Invalid memory options. Expected 0 < initialMemoryPages (${e}) <= maxMemoryPages (${t}) <= 4GiB (${u.max})`)}function x(e){return e.split(`
2
+ `).slice(0,-2).map(r=>{const[n,l,...i]=r.split(":");return n&&l&&i.length?{rawMessage:r,message:i.join(":").trim(),loc:{fileName:n,lineNumber:parseInt(l)}}:{rawMessage:r,message:r,loc:null}}).filter(r=>!(!r.loc&&r.rawMessage.trim().endsWith(" validates")))}const w="xmllint-wasm";function M(e){const t=y(e);t[w]=!0;var r;return new Promise(function(l,i){function f(s){var o=s.data;if(!o||o[w]!==!0)return;const c=h(o.exitCode);if(c===null){const g=new Error(o.stderr);g.code=o.exitCode,i(g)}else l({valid:c,normalized:o.stdout,errors:c?[]:x(o.stderr),rawOutput:o.stderr})}function a(s){i(s)}r=new Worker(new URL(""+new URL("xmllint-browser-C85XrDSU.js",import.meta.url).href,import.meta.url),{type:"module"});var m=r.addEventListener.bind(r);m("message",f),m("error",a),r.postMessage(t)}).finally(()=>{if(r)return r.terminate()})}export{u as memoryPages,M as validateXML};
@@ -0,0 +1 @@
1
+ const n={1033:"English (United States)",1031:"German",1034:"Spanish (traditional)",1036:"French",1040:"Italian",1041:"Japanese",1042:"Korean",1043:"Dutch",1044:"Norwegian",1045:"Polish",1046:"Portuguese (Brazil)",1049:"Russian",1053:"Swedish",1054:"Thai",1055:"Turkish",1057:"Indonesian",1058:"Ukrainian",1066:"Vietnamese",2052:"Chinese (Simplified)",3082:"Spanish (Spain)"},e=a=>n[a]??`Language ${a}`;export{n as L,e as l};
@@ -1,4 +1,4 @@
1
- import{r as Gt,W as vv}from"./fluent-ui-CQyNN9H3.js";import{_ as XR}from"./preload-helper-PPVm8Dsz.js";function LU(o,e){(e==null||e>o.length)&&(e=o.length);for(var t=0,i=Array(e);t<e;t++)i[t]=o[t];return i}function rle(o){if(Array.isArray(o))return o}function ale(o,e,t){return(e=fle(e))in o?Object.defineProperty(o,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):o[e]=t,o}function lle(o,e){var t=o==null?null:typeof Symbol<"u"&&o[Symbol.iterator]||o["@@iterator"];if(t!=null){var i,n,s,r,a=[],l=!0,c=!1;try{if(s=(t=t.call(o)).next,e!==0)for(;!(l=(i=s.call(t)).done)&&(a.push(i.value),a.length!==e);l=!0);}catch(d){c=!0,n=d}finally{try{if(!l&&t.return!=null&&(r=t.return(),Object(r)!==r))return}finally{if(c)throw n}}return a}}function cle(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
1
+ import{r as Gt,W as vv}from"./fluent-ui-BThr2m8u.js";import{_ as XR}from"./preload-helper-PPVm8Dsz.js";function LU(o,e){(e==null||e>o.length)&&(e=o.length);for(var t=0,i=Array(e);t<e;t++)i[t]=o[t];return i}function rle(o){if(Array.isArray(o))return o}function ale(o,e,t){return(e=fle(e))in o?Object.defineProperty(o,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):o[e]=t,o}function lle(o,e){var t=o==null?null:typeof Symbol<"u"&&o[Symbol.iterator]||o["@@iterator"];if(t!=null){var i,n,s,r,a=[],l=!0,c=!1;try{if(s=(t=t.call(o)).next,e!==0)for(;!(l=(i=s.call(t)).done)&&(a.push(i.value),a.length!==e);l=!0);}catch(d){c=!0,n=d}finally{try{if(!l&&t.return!=null&&(r=t.return(),Object(r)!==r))return}finally{if(c)throw n}}return a}}function cle(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
2
2
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function xU(o,e){var t=Object.keys(o);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(o);e&&(i=i.filter(function(n){return Object.getOwnPropertyDescriptor(o,n).enumerable})),t.push.apply(t,i)}return t}function IU(o){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?xU(Object(t),!0).forEach(function(i){ale(o,i,t[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(o,Object.getOwnPropertyDescriptors(t)):xU(Object(t)).forEach(function(i){Object.defineProperty(o,i,Object.getOwnPropertyDescriptor(t,i))})}return o}function dle(o,e){if(o==null)return{};var t,i,n=hle(o,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(o);for(i=0;i<s.length;i++)t=s[i],e.indexOf(t)===-1&&{}.propertyIsEnumerable.call(o,t)&&(n[t]=o[t])}return n}function hle(o,e){if(o==null)return{};var t={};for(var i in o)if({}.hasOwnProperty.call(o,i)){if(e.indexOf(i)!==-1)continue;t[i]=o[i]}return t}function ule(o,e){return rle(o)||lle(o,e)||ple(o,e)||cle()}function gle(o,e){if(typeof o!="object"||!o)return o;var t=o[Symbol.toPrimitive];if(t!==void 0){var i=t.call(o,e);if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(o)}function fle(o){var e=gle(o,"string");return typeof e=="symbol"?e:e+""}function ple(o,e){if(o){if(typeof o=="string")return LU(o,e);var t={}.toString.call(o).slice(8,-1);return t==="Object"&&o.constructor&&(t=o.constructor.name),t==="Map"||t==="Set"?Array.from(o):t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?LU(o,e):void 0}}function mle(o,e,t){return e in o?Object.defineProperty(o,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):o[e]=t,o}function kU(o,e){var t=Object.keys(o);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(o);e&&(i=i.filter(function(n){return Object.getOwnPropertyDescriptor(o,n).enumerable})),t.push.apply(t,i)}return t}function DU(o){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?kU(Object(t),!0).forEach(function(i){mle(o,i,t[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(o,Object.getOwnPropertyDescriptors(t)):kU(Object(t)).forEach(function(i){Object.defineProperty(o,i,Object.getOwnPropertyDescriptor(t,i))})}return o}function _le(){for(var o=arguments.length,e=new Array(o),t=0;t<o;t++)e[t]=arguments[t];return function(i){return e.reduceRight(function(n,s){return s(n)},i)}}function L1(o){return function e(){for(var t=this,i=arguments.length,n=new Array(i),s=0;s<i;s++)n[s]=arguments[s];return n.length>=o.length?o.apply(this,n):function(){for(var r=arguments.length,a=new Array(r),l=0;l<r;l++)a[l]=arguments[l];return e.apply(t,[].concat(n,a))}}}function Tk(o){return{}.toString.call(o).includes("Object")}function ble(o){return!Object.keys(o).length}function u0(o){return typeof o=="function"}function vle(o,e){return Object.prototype.hasOwnProperty.call(o,e)}function Cle(o,e){return Tk(e)||Zu("changeType"),Object.keys(e).some(function(t){return!vle(o,t)})&&Zu("changeField"),e}function wle(o){u0(o)||Zu("selectorType")}function Sle(o){u0(o)||Tk(o)||Zu("handlerType"),Tk(o)&&Object.values(o).some(function(e){return!u0(e)})&&Zu("handlersType")}function yle(o){o||Zu("initialIsRequired"),Tk(o)||Zu("initialType"),ble(o)&&Zu("initialContent")}function Lle(o,e){throw new Error(o[e]||o.default)}var xle={initialIsRequired:"initial state is required",initialType:"initial state should be an object",initialContent:"initial state shouldn't be an empty object",handlerType:"handler should be an object or a function",handlersType:"all handlers should be a functions",selectorType:"selector should be a function",changeType:"provided value of changes should be an object",changeField:'it seams you want to change a field in the state which is not specified in the "initial" state',default:"an unknown error accured in `state-local` package"},Zu=L1(Lle)(xle),mx={changes:Cle,selector:wle,handler:Sle,initial:yle};function Ile(o){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};mx.initial(o),mx.handler(e);var t={current:o},i=L1(Ele)(t,e),n=L1(Dle)(t),s=L1(mx.changes)(o),r=L1(kle)(t);function a(){var c=arguments.length>0&&arguments[0]!==void 0?arguments[0]:function(d){return d};return mx.selector(c),c(t.current)}function l(c){_le(i,n,s,r)(c)}return[a,l]}function kle(o,e){return u0(e)?e(o.current):e}function Dle(o,e){return o.current=DU(DU({},o.current),e),e}function Ele(o,e,t){return u0(e)?e(o.current):Object.keys(t).forEach(function(i){var n;return(n=e[i])===null||n===void 0?void 0:n.call(e,o.current[i])}),t}var Nle={create:Ile},Tle={paths:{vs:"https://cdn.jsdelivr.net/npm/monaco-editor@0.55.1/min/vs"}};function Rle(o){return function e(){for(var t=this,i=arguments.length,n=new Array(i),s=0;s<i;s++)n[s]=arguments[s];return n.length>=o.length?o.apply(this,n):function(){for(var r=arguments.length,a=new Array(r),l=0;l<r;l++)a[l]=arguments[l];return e.apply(t,[].concat(n,a))}}}function Mle(o){return{}.toString.call(o).includes("Object")}function Ale(o){return o||EU("configIsRequired"),Mle(o)||EU("configType"),o.urls?(Ple(),{paths:{vs:o.urls.monacoBase}}):o}function Ple(){console.warn(RX.deprecation)}function Ole(o,e){throw new Error(o[e]||o.default)}var RX={configIsRequired:"the configuration object is required",configType:"the configuration object should be an object",default:"an unknown error accured in `@monaco-editor/loader` package",deprecation:`Deprecation warning!
3
3
  You are using deprecated way of configuration.
4
4
 
@@ -0,0 +1 @@
1
+ import{l as o,m as e,W as a,a as n}from"./monaco-DzBcrxae.js";import"./fluent-ui-BThr2m8u.js";import"./preload-helper-PPVm8Dsz.js";o.config({monaco:e});self.MonacoEnvironment={getWorker(p,r){return r==="typescript"||r==="javascript"?new a:new n}};
@@ -0,0 +1,36 @@
1
+ import{an as F,ao as Te,ap as Pe,ai as Ne,aq as G,ar as Le,as as je,at as Me,au as ze,av as Oe,aw as ne,ax as Ue,ay as Xe,az as qe,aA as Be,q as Z,B as We,aB as Ke,aC as Fe,aD as ie,aE as Je,aF as Ve,aG as Y,ak as Ge,aH as Ye,aI as be,w as pe,k as X,aJ as _e,aK as He,aL as ae,aM as Ze,aN as _,aO as Qe,aP as re,aQ as D,aR as J,aS as et,aT as ge}from"./index-Df9NSpg6.js";import{w as tt,a as ye}from"./xmlValidator-Dki8Hf7Y.js";let le=0;async function we(e){const t=typeof window<"u"?window.toolboxAPI:void 0;le++===0&&await ce(()=>t?.preventClose?.());try{return await e()}finally{--le===0&&await ce(()=>t?.releasePreventClose?.())}}const ot=2e3;async function ce(e){let t;try{await Promise.race([e(),new Promise(o=>t=setTimeout(o,ot))])}catch{}finally{clearTimeout(t)}}const nt={quot:'"',apos:"'",lt:"<",gt:">",amp:"&"};function st(e){return e.replace(/&(?:#x([0-9a-f]+)|#(\d+)|(quot|apos|lt|gt|amp));/gi,(t,o,n,i)=>{if(i)return nt[i.toLowerCase()];const s=o?parseInt(o,16):Number(n);try{return String.fromCodePoint(s)}catch{return t}})}function T(e,t){const o=e.match(new RegExp(`\\s${t}="([^"]*)"`));return o?st(o[1]):null}function Q(e){if(!e)return null;const t=(e.match(/<result\s[^>]*>/g)??[]).find(i=>T(i,"result")==="failure");if(!t)return null;const o=T(t,"errorcode"),n=T(t,"errortext")||"no reason given";return`Dataverse couldn't import the solution${o?` (${o})`:""}: ${n}`}function de(e,t,o){const n=e.indexOf(o,t);return e.slice(t,n===-1?void 0:n).match(/<result\s[^>]*>/g)??[]}function ue(e){const t=e.find(o=>T(o,"result")!=="success");if(t){const o=T(t,"errorcode")??"",n=T(t,"errortext")??"unknown error";return{ok:!1,message:`Dataverse rejected the ribbon (${o}): ${n}`}}return null}function it(e,t){if(!e)return{ok:!1,message:"The import job returned no result data, so the ribbon import could not be verified."};if(t.kind==="application"){const s=e.search(/<ribbon\s[^>]*processed="true"/);return s===-1?{ok:!1,message:Q(e)??"Import completed, but Dataverse did not process the application ribbon."}:ue(de(e,s,"</ribbon>"))??{ok:!0,message:"Application ribbon imported."}}const o=new Set(t.names.filter(Boolean).map(s=>s.toLowerCase())),n=/<entityRibbon\s[^>]*>/g;let i;for(;i=n.exec(e);){const s=(T(i[0],"id")??"").toLowerCase();if(o.has(s))return T(i[0],"processed")!=="true"?{ok:!1,message:`Dataverse did not process the ribbon for ${s}.`}:ue(de(e,i.index,"</entityRibbon>"))??{ok:!0,message:`Ribbon for ${s} imported.`}}return{ok:!1,message:Q(e)??`Import completed, but Dataverse did not apply a ribbon for ${t.names.join(" / ")} (no entityRibbon result in the import job). Nothing was changed.`}}const E=window.dataverseAPI;async function at(e,t,o){await o("The import");const n=await E.execute({operationName:"ImportSolutionAsync",operationType:"action",parameters:{CustomizationFile:e,ImportJobId:t,OverwriteUnmanagedCustomizations:!0,PublishWorkflows:!1}}),i=n?.AsyncOperationId;if(!i)throw new Error("ImportSolutionAsync did not return AsyncOperationId.");const s=n?.ImportJobKey,l=s&&rt.test(s)?s.replace(/[{}]/g,"").toLowerCase():t;return l!==t.toLowerCase()&&X.getState().logWarn("publish",`Dataverse created import job ${l}, not ${t} as asked: verifying ${l}.`),{asyncOperationId:i,importJobId:l}}const rt=/^\{?[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\}?$/i;function lt(e){const t=e.replace(/^You cancelled the publish\.\s*/,"").trim();return t?` ${t}`:""}const L=3,H=30,O=32;class ee extends Error{constructor(t,o,n=!1){super(t),this.importJobId=o,this.mayStillFinish=n,this.name="PublishCancelledError"}importJobId;mayStillFinish}function te(e){return Ce(e)!==null}function vt(e){return Ce(e)?.mayStillFinish===!0}function Ce(e){for(let t=e,o=0;t instanceof Error&&o<5;t=t.cause,o++)if(t.name==="PublishCancelledError")return t;return null}function $e(e){for(let t=e,o=0;t instanceof Error&&o<5;t=t.cause,o++){const n=t.importJobId;if(typeof n=="string"&&n)return n}}function U(e,t){return e instanceof Error&&!$e(e)&&Object.assign(e,{importJobId:t}),e}function ct(e){const t=e instanceof Error?e.message:String(e);return/0x80040217|does not exist|not found/i.test(t)}async function xt(e){try{return(await V(E.retrieve("importjob",e,["data"]),3e4))?.data||null}catch(t){if(ct(t))return null;throw t}}function Ie(e,t,o,n){return new Promise((i,s)=>{if(t?.aborted)return s(o());let l;const c=()=>{clearTimeout(l),s(o())};t?.addEventListener("abort",c,{once:!0});const d=()=>{t?.removeEventListener("abort",c),i()};n?n(e).then(d,d):l=setTimeout(d,e)})}function Re(e,t,o,n=3e4){const i=V(E.retrieve("asyncoperation",e,["statecode","statuscode","message","friendlymessage"]),n);return t?new Promise((s,l)=>{if(t.aborted)return l(o());const c=()=>l(o());t.addEventListener("abort",c,{once:!0}),i.then(d=>{t.removeEventListener("abort",c),s(d)},d=>{t.removeEventListener("abort",c),l(d)})}):i}function me(e){const t=e.friendlymessage?.trim();if(t)return t;const o=(e.message??"").replace(/^\s*Exception type:[^\r\n]*\r?\n/i,"").replace(/^\s*Message:\s*/i,"").split(/\r?\n/),n=o.findIndex((s,l)=>l>0&&/^\s*(at\s|Stack ?Trace|Server stack trace|Inner ?Exception|Detail:|-{2,})/i.test(s));let i=(n===-1?o:o.slice(0,n)).join(" ").replace(/\s+/g," ").trim();return i.length>500&&(i=`${i.slice(0,500)}…`),i||`status ${e.statuscode??"unknown"}`}async function fe(e,t){const o=X.getState(),n=async()=>{try{return await Re(e,void 0,()=>new Error,1e4)}catch{return null}},i=await n();if(i?.statecode===L)return i;try{await t("Cancelling the import"),await V(E.update("asyncoperation",e,{statecode:L,statuscode:O}),15e3),o.logInfo("publish",`Asked Dataverse to cancel the import (system job ${e}).`)}catch(s){o.logWarn("publish",`Dataverse didn't cancel the import (system job ${e}): ${s instanceof Error?s.message:String(s)}`)}return n()}async function dt(e){const{asyncOperationId:t,importJobId:o,signal:n}=e,i=e.now??Date.now,s=X.getState(),l=()=>new ee("cancelled",o),c=async(b,f)=>{const u=me(b);return J(u)?new Error(u):J(b.message??"")?new Error(b.message??""):U(await ve(new Error(`${f}: ${u}`),o),o)},d=i();let $=0,C=0;for(;;){let b=null;try{b=await Re(t,n,l),C=0}catch(f){if(te(f))break;if(++C>=3)throw U(new Error(`Couldn't read the import's progress (${f instanceof Error?f.message:String(f)}). Dataverse may still finish it: check Solutions › History for import job ${o} before you publish again.`,{cause:f}),o)}if(b?.statecode===L){if(b.statuscode===H)return;throw await c(b,b.statuscode===O?"The import was cancelled in Dataverse":"The import failed")}if(i()-d>=e.timeoutMs){const f=e.timeoutMs>=6e4?`${Math.round(e.timeoutMs/6e4)} minutes`:`${Math.round(e.timeoutMs/1e3)} seconds`;s.logWarn("publish",`The import didn't finish within ${f}: asking Dataverse to cancel it.`);const u=await fe(t,e.guard);if(u?.statecode===L&&u.statuscode===H)return;throw u?.statecode===L&&u.statuscode!==O?await c(u,"The import failed"):U(new Error(`The import didn't finish within ${f}, so Command Bar Studio stopped waiting for it`+(u?.statuscode===O?" and Dataverse cancelled it.":`. Dataverse may still finish it: check Solutions › History for import job ${o} before you publish again.`)),o)}$++,$%10===0&&e.onProgress?.(`Still importing… (${Math.round((i()-d)/1e3)} s)`);try{await Ie(e.pollMs,n,l)}catch{break}}s.logWarn("publish","Publish cancelled: asking Dataverse to cancel the import.");const g=await fe(t,e.guard),y=g?.statecode!==L,p=y||!g?`Command Bar Studio stopped waiting, but Dataverse may still finish the import: check Solutions › History for import job ${o} before you publish again.`:g.statuscode===O?"Dataverse cancelled the import.":g.statuscode===H?"The import had already finished, so your changes are imported but not published.":`The import had already failed: ${me(g)}`;throw new ee(`You cancelled the publish. ${p}`,o,y)}async function ve(e,t){try{const o=await V(E.retrieve("importjob",t,["data"]),1e4),n=Q(o?.data),i=e instanceof Error?e.message:String(e),s=n?.replace(/^[^:]*: /,"");return!n||s&&i.includes(s)?e:new Error(`${i} — ${n}`,{cause:e})}catch{return e}}async function ut(e,t){await t("Publishing");const o=e.map(n=>`<entity>${D(n)}</entity>`).join("");return E.execute({operationName:"PublishXml",operationType:"action",parameters:{ParameterXml:`<importexportxml><entities>${o}</entities></importexportxml>`}})}async function xe(e){const t=e.entity?.logicalName??"{!EntityLogicalName}",o={deletedContainerIds:e.plan.deletedContainerIds??[],movedButtons:e.plan.movedButtons??[],editedLocLabelIds:e.plan.editedLocLabelIds??[],editedTabIds:e.plan.editedTabIds??[],resequencedTabs:e.plan.resequencedTabs??[],resequencedGroups:e.plan.resequencedGroups??[]},n=e.locLabels.filter(r=>o.editedLocLabelIds.includes(r.id)),i=e.languageCode??1033;for(const r of e.plan.renamedLabels??[]){const a=n.find(w=>w.id===r.id)??e.locLabels.find(w=>w.id===r.id),h=[{languageCode:i,description:r.text},...(a?.titles??[]).filter(w=>w.languageCode!==i)],m=n.findIndex(w=>w.id===r.id);m>=0?n[m]={id:r.id,titles:h}:n.push({id:r.id,titles:h})}let s=n.length?F(`<RibbonDiffXml><LocLabels>${n.map(Te).join("")}</LocLabels></RibbonDiffXml>`):Pe();for(const r of e.locations){const a=Ne({current:r.current,baseline:r.baseline,commands:e.commands,enableRules:e.enableRules,displayRules:e.displayRules,locLabels:e.locLabels,entityLogicalName:t,location:r.current.location,languageCode:e.languageCode});s=G(s,F(a))}const l=[],c=[];for(const r of e.locations)for(const a of r.current.tabs){if(!o.editedTabIds.includes(a.id))continue;if(a.tabDisplayRules.length>0){const m=Le(a,e.entity===null);m&&c.push(m)}const h=new Set(a.tabDisplayRules.map(m=>m.tabCommand));for(const m of r.baseline.tabs.find(w=>w.id===a.id)?.tabDisplayRules??[])h.has(m.tabCommand)||l.push(m.tabCommand)}c.length>0&&(s=G(s,F(`<RibbonDiffXml><RuleDefinitions><TabDisplayRules>${c.join("")}</TabDisplayRules></RuleDefinitions></RibbonDiffXml>`)));const d=[...e.commands.filter(r=>e.plan.editedCommandIds.includes(r.id)).map(je)],$={enable:e.enableRules.filter(r=>e.plan.editedEnableRuleIds.includes(r.id)).map(ze),display:e.displayRules.filter(r=>e.plan.editedDisplayRuleIds.includes(r.id)).map(Me)};(d.length||$.enable.length||$.display.length)&&(s=G(s,F(`<RibbonDiffXml><CommandDefinitions>${d.join("")}</CommandDefinitions><RuleDefinitions><DisplayRules>${$.display.join("")}</DisplayRules><EnableRules>${$.enable.join("")}</EnableRules></RuleDefinitions></RibbonDiffXml>`)));const C=(r,a)=>{for(const h of Array.from(r.keys()))a.includes(h)||r.delete(h)},g=e.locations.flatMap(r=>r.current.tabs.filter(a=>!r.baseline.tabs.some(h=>h.id===a.id)).map(Oe));C(s.commandDefinitions,[...e.plan.editedCommandIds,...g]),C(s.enableRules,e.plan.editedEnableRuleIds),C(s.displayRules,e.plan.editedDisplayRuleIds);const y=await ne(e.entity?.logicalName??null),p=Ue(y),b=e.plan.deletedButtonIds.filter(r=>!p.has(r));if(b.length>0)throw new Error(`Can't delete ${b.join(", ")}: not defined in this entity's unmanaged customizations (it comes from a managed solution or the platform). Undo the delete and hide the button instead.`);const f=Xe(y),u=o.deletedContainerIds.filter(r=>!f.has(r));if(u.length>0)throw new Error(`Can't delete ${u.join(", ")}: not added by this entity's unmanaged customizations (it comes from a managed solution or the platform). Undo the delete.`);const I=o.movedButtons.filter(r=>!p.has(r.id)).map(r=>r.id);if(I.length>0)throw new Error(`Can't move ${I.join(", ")}: not defined in this entity's unmanaged customizations. Undo the move.`);const R=qe(y),k=(e.plan.uncustomisedCommandIds??[]).filter(r=>y.commandDefinitions.has(r)&&!Be(r,R));if(k.length>0)throw new Error(`Can't uncustomise ${k.join(", ")}: it is your own command (your customizations' buttons use it and no other solution defines it), so removing it would leave those buttons without a command. Undo the uncustomise.`);const j=new Set;for(const r of e.locations)for(const a of r.current.tabs)for(const h of a.groups)for(const m of Z(h))for(const w of We(m))j.add(w);const q=e.plan.uncustomisedCommandIds??[],M=new Set,N=new Set;for(const r of e.commands)if(!(!j.has(r.id)||q.includes(r.id))){r.enableRules.forEach(a=>M.add(a)),r.displayRules.forEach(a=>N.add(a));for(const a of r.rawRuleRefs??[]){const h=/^\s*<(EnableRule|DisplayRule)\b[^>]*?\sId="([^"]+)"/.exec(a.xml);h&&(h[1]==="EnableRule"?M:N).add(h[2])}}let v=Ke(y,s,{retainedCommandIds:j,editedCommandIds:e.plan.editedCommandIds,editedEnableRuleIds:e.plan.editedEnableRuleIds,editedDisplayRuleIds:e.plan.editedDisplayRuleIds,deletedControlIds:e.plan.deletedButtonIds,unhiddenControlIds:e.plan.unhiddenButtonIds,deletedContainerIds:o.deletedContainerIds,movedControls:o.movedButtons,resequencedContainers:[...o.resequencedTabs,...o.resequencedGroups],removedTabCommands:l,uncustomisedCommandIds:q,retainedEnableRuleIds:M,retainedDisplayRuleIds:N});for(const r of e.plan.renamedLabels??[])r.newLabel&&(v=Fe(v,r.containerId,`$LocLabels:${r.id}`));const B=new Set([...ie(y),...ie(v)].map(r=>r.id)),z={};for(const r of e.locations)for(const[a,h]of Object.entries(r.baseline.scalingByTab??{}))z[a]={maxSizes:h.maxSizes.filter(m=>!B.has(m.id)).map(m=>m.sequence),scales:h.scales.filter(m=>!B.has(m.id)).map(m=>m.sequence)};const A=Je(v,z);if(A.problems.length>0)throw new Error(`Not published: ${A.problems.join("; ")}.`);return v=A.parts,{scalingChanges:A.changes,xml:Ge(v),parts:v,elementCount:Y(v),preservedCount:Y(y),changedCount:Y(s),changedKeys:Ve(y,v),newKeys:Object.keys(v).flatMap(r=>Array.from(v[r].keys()).filter(a=>!y[r].has(a)).map(a=>`${r}:${a}`)),layerDefinitionIds:{commandIds:Array.from(y.commandDefinitions.keys()),enableRuleIds:Array.from(y.enableRules.keys()),displayRuleIds:Array.from(y.displayRules.keys())},layer:y}}function De(e,t){const o=[],n={},i={},s={},l={},c={},d=new Set,$=new Set,C=new Set;for(const{current:p,baseline:b}of e.locations)for(const f of[b,p])for(const u of f.tabs)for(const I of u.groups)for(const R of Z(I))for(const k of R.menu?.sections??[])C.add(k.controlsId);for(const{current:p,baseline:b}of e.locations){Object.assign(s,b.templateLayouts),Object.assign(l,b.templateAliases);for(const f of b.tabs){o.push(f.id),f.label&&(c[f.id]={Title:f.label});for(const u of f.groups){d.add(u.id),o.push(u.id),u.label&&(c[u.id]={Title:u.label,Label:u.label});for(const I of Z(u))o.push(I.id),I.source&&(c[I.id]=I.source.attributes)}}for(const f of p.tabs)for(const u of f.groups)$.add(u.id);for(const f of[b,p])for(const u of f.tabs)for(const I of u.groups)I.template&&(i[I.id]=I.template)}const g=p=>d.has(p.groupId)&&!$.has(p.groupId);for(const{baseline:p}of e.locations)for(const[b,f]of Object.entries(p.scalingByTab??{}))n[b]={...f,maxSizes:f.maxSizes.filter(u=>!g(u)),scales:f.scales.filter(u=>!g(u))};const y=(p,b)=>{if(!p)return;const f=new Set(b??[]);return p.map(u=>u.id).filter(u=>!f.has(u))};return{changedKeys:t.changedKeys,newKeys:t.newKeys,commands:e.commands,known:{commandIds:y(e.baselineCommands,t.layerDefinitionIds?.commandIds),enableRuleIds:y(e.baselineEnableRules,t.layerDefinitionIds?.enableRuleIds),displayRuleIds:y(e.baselineDisplayRules,t.layerDefinitionIds?.displayRuleIds),elementIds:o},loadedAttributes:c,publisherPrefix:e.publisherPrefix,tabScaling:n,groupTemplates:i,templateLayouts:s,templateAliases:l,menuControlsIds:C,...e.entity?{places:{entityLogicalName:e.entity.logicalName,tabByCollection:Object.fromEntries(Ye(e.locations.map(p=>p.baseline),e.entity.logicalName))}}:{}}}function V(e,t){return new Promise((o,n)=>{const i=setTimeout(()=>n(new Error(`it didn't finish within ${Math.round(t/1e3)} s`)),t);e.then(s=>{clearTimeout(i),o(s)},s=>{clearTimeout(i),n(s)})})}async function Dt(e,t={}){const o=await xe(e),n=De(e,o),i=[],s=tt(o.parts);if(t.lookupWebResources&&s.length>0)try{n.webResources=await t.lookupWebResources(s)}catch(l){i.push({severity:"warning",code:"webresource-lookup",message:`Couldn't check the ${s.length} referenced web resource(s): ${l instanceof Error?l.message:String(l)}`})}return{findings:[...ye(o.parts,n),...i],xml:o.xml,changedKeys:o.changedKeys}}async function mt(e,t,o={}){const n=o.attempts??3,i=o.contentKeys??[];let s={missing:[],unexpected:[],differing:[]};for(let c=0;c<n;c++){c>0&&await new Promise(d=>setTimeout(d,o.delayMs??5e3));try{s=ge(t,await ne(e),{contentKeys:i})}catch(d){return{ok:!1,missing:[],unexpected:[],differing:[],message:`Couldn't read the published ribbon layer to verify it (${d instanceof Error?d.message:String(d)}).`}}if(s.missing.length===0&&s.unexpected.length===0&&s.differing.length===0){const d=i.length;return{ok:!0,...s,message:"Verified: the published ribbon layer has every element that was imported"+(d>0?`, and the ${d} element(s) this publish changed have the imported content.`:".")}}}const l=c=>c.slice(0,5).join(", ")+(c.length>5?", …":"");return{ok:!1,...s,message:"The published ribbon layer doesn't match what was imported"+(s.missing.length?`; missing: ${l(s.missing)}`:"")+(s.unexpected.length?`; unexpected: ${l(s.unexpected)}`:"")+(s.differing.length?`; different content: ${l(s.differing)}`:"")+". Reload the entity and check before publishing again."}}class oe extends Error{constructor(t,o,n=!1){const i=n?"another solution import ran in the environment meanwhile, and what it changed may not be published yet":Ee(o);super(n?`${t}'s ribbon customizations may have changed in Dataverse since you started publishing: ${i}. Importing could overwrite that change, so nothing was imported. Publish again: the entity is published first, so the change is kept.`:`${t}'s ribbon customizations changed in Dataverse since you started publishing (${i}): other ribbon changes for it were published meanwhile, from another session, tool or solution import. Importing would overwrite that change, so nothing was imported. Reload the entity to get the change, then publish again.`),this.scopeLabel=t,this.changes=o,this.importRan=n,this.name="RibbonLayerChangedError",this.summary=i}scopeLabel;changes;importRan;summary}function Ee(e){const t=o=>o.slice(0,5).join(", ")+(o.length>5?", …":"");return[e.unexpected.length?`added: ${t(e.unexpected)}`:"",e.missing.length?`removed: ${t(e.missing)}`:"",e.differing.length?`changed: ${t(e.differing)}`:""].filter(Boolean).join("; ")}function ft(e){const t=e instanceof Error?e.message:String(e);return/there is (?:another|a previous) \[(\w+)\] running/i.exec(t)?.[1]??null}const ht=e=>Object.keys(e).flatMap(t=>Array.from(e[t].keys()).map(o=>`${t}:${o}`));function Se(e,t){const o=[],n=[],i=[];for(const s of Object.keys(e)){for(const[l,c]of e[s]){const d=t[s].get(l);d===void 0?o.push(`${s}:${l}`):d!==c&&i.push(`${s}:${l}`)}for(const l of t[s].keys())e[s].has(l)||n.push(`${s}:${l}`)}return{missing:o,unexpected:n,differing:i}}const ke=e=>e.missing.length+e.unexpected.length+e.differing.length>0;async function bt(e,t,o,n){const i=n.kind==="imported"?n.attempts??3:1;let s={missing:[],unexpected:[],differing:[]};for(let l=0;l<i;l++){l>0&&n.kind==="imported"&&await new Promise(d=>setTimeout(d,n.delayMs??5e3));const c=await ne(e);if(s=n.kind==="read"?Se(o,c):ge(o,c,{contentKeys:ht(o)}),!ke(s))return}throw new oe(t,s)}function Et(e,t){return we(()=>pt(e,t)).finally(()=>be({afterPublish:!0}))}async function pt(e,t){const o=e.guard??pe(),n=X.getState(),i=e.entity?e.entity.logicalName:"Application ribbon",s=e.signal;let l="before";const c=()=>new ee(l==="before"?"You cancelled the publish before anything was imported.":l==="imported"?"You cancelled the publish after the import: your changes are imported but not published.":"You cancelled the publish."),d=()=>{if(s?.aborted)throw c()},$={onProgress:t,...e.busy,sleep:a=>Ie(a,s,c,e.busy?.sleep)},C=e.entity===null;if(C&&!e.ribbonCustomizationIds?.length)throw new Error("The selected solution does not contain Application Ribbons. Add it in make.powerapps.com (Solutions → your solution → Add existing → Application Ribbons) and reload the solution.");const g=async(a="Publishing customizations…")=>{d(),t?.(a),await re("Publish",async()=>{C?(await o("Publishing"),await E.execute({operationName:"PublishXml",operationType:"action",parameters:{ParameterXml:"<importexportxml><ribbons><ribbon></ribbon></ribbons></importexportxml>"}})):await ut([e.entity.logicalName],o)},$)},y=e.languageCode??await _e(),p=async a=>{t?.(`Reading existing ribbon customizations for ${i}…`),a&&n.logInfo("publish",`Reading unmanaged ribbon layer for ${i}.`);const h=await xe({...e,languageCode:y}),m=ye(h.parts,De({...e,publisherPrefix:e.solution.publisherPrefix},h)),w=m.filter(x=>x.severity==="error");if(a||w.length>0){n.logInfo("publish",`RibbonDiffXml for ${i}: ${h.preservedCount} existing element(s) preserved, ${h.changedCount} element(s) from this session, ${h.elementCount} total.`);for(const x of h.scalingChanges)n.logWarn("publish",Qe(x));for(const x of m)x.severity==="warning"&&n.logWarn("publish",x.message)}if(w.length>0){for(const x of w)n.logError("publish",x.message);throw new Error(`The pre-publish check found ${w.length} error(s), so nothing was imported: `+w.map(x=>x.message).join("; "))}return h},b=e.publishCustomizations!==!1?await p(!1):null;t?.("Checking that no other solution operation is running…"),await He($);const f=await yt(e.solution);let u=!1;const I=a=>(b&&!u&&a instanceof Error&&(a.message+=` (${i} was published first, so customizations imported elsewhere for it and not yet published are now published.)`),a);if(b){n.logInfo("publish",`Publishing ${i} first, so ribbon changes imported elsewhere but not yet published are kept.`);try{await g(`Publishing ${i} first (keeps changes imported elsewhere but not published)…`)}catch(a){throw a instanceof Error&&!te(a)&&(a.message=`Publishing ${i} first failed, so nothing was imported: ${a.message}`),a}}let R;if(s?.aborted)throw I(c());try{R=await p(!0)}catch(a){throw b&&a instanceof Error&&!a.message.startsWith("The pre-publish check")&&(a.message=`${i}'s customizations changed when it was published first (changes imported elsewhere and not yet published): ${a.message} Reload the entity to get them, then publish again.`),I(a)}if(b){const a=Se(b.layer,R.layer);ke(a)&&n.logInfo("publish",`Publishing ${i} first published ribbon changes imported elsewhere (${Ee(a)}); they are kept.`)}const k=e.entity?.schemaName||e.entity?.logicalName||"",j=C?ae({applicationRibbonDiffXml:R.xml}):ae({entities:[{schemaName:k,localizedName:e.entity?.displayName||k,ribbonDiffXml:R.xml}]}),q=C?[{type:50,schemaName:":RibbonDiffXml",behavior:0}]:[{type:1,schemaName:e.entity.logicalName,behavior:2}],M=$t({...e.solution,languageCode:y,rootComponents:q,details:f});t?.("Packaging solution ZIP…");const N=Ze({"customizations.xml":_(j),"solution.xml":_(M),"[Content_Types].xml":_('<?xml version="1.0" encoding="utf-8"?><Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types"><Default Extension="xml" ContentType="application/xml"/></Types>')});let v="";for(let a=0;a<N.length;a++)v+=String.fromCharCode(N[a]);const B=btoa(v),z=async(a,h)=>{t?.(`Importing ${i} ribbon${a}…`);let m="",w,x=!1;const se=P=>(ft(P)?.toLowerCase()==="import"&&(x=!0),P);try{await re("Import",async()=>{if(d(),await o("Importing"),x)throw new oe(i,{missing:[],unexpected:[],differing:[]},!0);await bt(e.entity?.logicalName??null,i,h.layer,h.as),d(),m=crypto.randomUUID(),n.logInfo("publish",`Importing solution${a} (import job ${m})…`);let K;try{K=await at(B,m,o)}catch(S){throw J(S)?se(S):S instanceof et?S:await ve(S,m)}m=K.importJobId,w=m,n.logInfo("publish",`Import running as system job ${K.asyncOperationId}; waiting for it to finish.`);try{await dt({asyncOperationId:K.asyncOperationId,importJobId:m,guard:o,signal:s,pollMs:e.importPollMs??2e3,timeoutMs:e.importTimeoutMs??10*6e4,onProgress:t})}catch(S){throw J(S)?(w=void 0,se(S)):S}u=!0},$),t?.("Verifying the import…");const P=await E.retrieve("importjob",m,["data"]),W=it(P.data,C?{kind:"application"}:{kind:"entity",names:[k,e.entity.logicalName]});if(!W.ok)throw n.logError("publish",W.message),new Error(W.message);return n.logInfo("publish",W.message),m}catch(P){throw w?U(P,w):P}};let A;try{A=await z("",{layer:R.layer,as:{kind:"read"}})}catch(a){throw I(a)}l="imported";let r;if(e.publishCustomizations!==!1){try{await g()}catch(a){throw U(a,A)}l="published";{n.logInfo("publish","Refreshing Unified Interface command-bar metadata (second import of the same package)…");try{await z(" (refreshing Unified Interface metadata)",{layer:R.parts,as:{kind:"imported",delayMs:e.verifyDelayMs}}),await g()}catch(a){if(a instanceof oe)r={ok:!1,...a.changes,message:`Your changes were imported and published, but ${i}'s ribbon customizations changed in Dataverse after that (${a.summary}): other changes were published meanwhile. They weren't imported a second time to refresh Unified Interface's command-bar metadata, since that would overwrite the other change, so new or changed buttons may not appear in the app until the entity's ribbon is published again. Reload the entity to see the other change.`},n.logWarn("publish",r.message);else{const h=a instanceof Error?a.message:String(a);r={ok:!1,missing:[],unexpected:[],differing:[],importJobId:$e(a),message:(te(a)?"Your changes were imported and published, but you cancelled the second import, which refreshes Unified Interface's command-bar metadata."+lt(h):`Your changes were imported and published, but refreshing Unified Interface's command-bar metadata failed (${h}).`)+` New or changed buttons may not appear in the app until ${C?"the application ribbon":"the entity's ribbon"} is published again, or for up to about 25 minutes.`},n.logWarn("publish",r.message)}}}r||(t?.("Verifying the published ribbon…"),r=await mt(e.entity?.logicalName??null,R.parts,{delayMs:e.verifyDelayMs,contentKeys:R.changedKeys}),r.ok?n.logInfo("publish",r.message):n.logWarn("publish",r.message))}else n.logWarn("publish","Imported without publishing. New or changed buttons appear in Unified Interface only after you publish from Command Bar Studio (which re-imports once to refresh the command-bar metadata).");return t?.(e.publishCustomizations!==!1?`${i} ribbon published.`:`${i} ribbon imported (not published).`),{elementCount:R.elementCount,preservedCount:R.preservedCount,importJobId:A,verification:r,parts:R.parts,changedKeys:R.changedKeys}}function St(e,t){return we(()=>gt(e,t)).finally(()=>be({afterPublish:!0}))}async function gt(e,t){const o=t?.guard??pe(),n=X.getState(),i=t?.pollIntervalMs??2e3,s=t?.timeoutMs??600*1e3;e?.("Starting asynchronous publish (PublishAllXmlAsync)..."),n.logInfo("publish","Calling PublishAllXmlAsync action."),await o("Publishing");const c=(await E.execute({operationName:"PublishAllXmlAsync",operationType:"action"}))?.AsyncOperationId;if(!c)throw new Error("PublishAllXmlAsync did not return AsyncOperationId.");n.logInfo("publish",`PublishAllXmlAsync job id: ${c}`),e?.("Async publish job started. Waiting for completion...");const d=Date.now();let $=0,C;for(;Date.now()-d<s;){$+=1;const g=await E.retrieve("asyncoperation",c,["asyncoperationid","statecode","statuscode","name","message","friendlymessage","completedon"]);if(C=g.statuscode,g.statecode===3||!!g.completedon){if(typeof g.statuscode=="number"&&g.statuscode!==30){const p=g.friendlymessage||g.message||`statuscode=${g.statuscode}`;throw new Error(`Asynchronous publish failed: ${p}`)}return e?.("Asynchronous publish completed successfully."),n.logInfo("publish",`PublishAllXmlAsync completed in ${$} poll(s).`),{asyncOperationId:c,statusCode:g.statuscode}}e?.(`Waiting for async publish job... (poll ${$})`),await new Promise(p=>setTimeout(p,i))}throw new Error(`Asynchronous publish timed out after ${Math.round(s/1e3)} seconds (last status: ${C??"unknown"}).`)}const Ae=[["AddressTypeCode","addresstypecode"],["City","city"],["County","county"],["Country","country"],["Fax","fax"],["FreightTermsCode","freighttermscode"],["Latitude","latitude"],["Line1","line1"],["Line2","line2"],["Line3","line3"],["Longitude","longitude"],["Name","name"],["PostalCode","postalcode"],["PostOfficeBox","postofficebox"],["PrimaryContactName","primarycontactname"],["ShippingMethodCode","shippingmethodcode"],["StateOrProvince","stateorprovince"],["Telephone1","telephone1"],["Telephone2","telephone2"],["Telephone3","telephone3"],["UPSZone","upszone"],["UTCOffset","utcoffset"],["UTCConversionTimeZoneCode","utcconversiontimezonecode"]];async function yt(e){let t;try{t=(await E.queryData(`solutions?$select=description&$expand=publisherid&$filter=uniquename eq '${e.uniqueName.replace(/'/g,"''")}'`)).value?.[0]}catch(l){throw new Error(`Couldn't read solution ${e.uniqueName} and its publisher (${l instanceof Error?l.message:String(l)}), so nothing was imported: an import without them would clear the publisher's details.`)}const o=t?.publisherid;if(!t||!o)throw new Error(`Couldn't read solution ${e.uniqueName} and its publisher, so nothing was imported: an import without them would clear the publisher's details.`);const n=o.customizationoptionvalueprefix;if(typeof n!="number")throw new Error(`Couldn't read the option-value prefix of publisher ${e.publisherUniqueName}, so nothing was imported: a wrong one would change the publisher.`);const i=l=>typeof l=="string"?l:"",s=[1,2].map(l=>Object.fromEntries(Ae.map(([,c])=>[c,o[`address${l}_${c}`]]).filter(([,c])=>c!=null&&c!==""))).map((l,c)=>({number:c+1,...l}));return{solutionDescription:i(t.description),publisherDescription:i(o.description),publisherEmail:i(o.emailaddress),publisherWebsite:i(o.supportingwebsiteurl),publisherOptionValuePrefix:n,publisherAddresses:s.filter(l=>Object.keys(l).length>1)}}const wt=e=>D(e).replace(/\r/g,"&#xD;").replace(/\n/g,"&#xA;").replace(/\t/g,"&#x9;"),he=(e,t)=>e?`<Descriptions>
2
+ <Description description="${wt(e)}" languagecode="${t}"/>
3
+ </Descriptions>`:"<Descriptions/>",Ct=e=>e.length===0?"<Addresses/>":`<Addresses>${e.map(t=>`
4
+ <Address>
5
+ <AddressNumber>${t.number}</AddressNumber>${Ae.filter(([,o])=>o in t).map(([o,n])=>`
6
+ <${o}>${D(String(t[n]))}</${o}>`).join("")}
7
+ </Address>`).join("")}
8
+ </Addresses>`;function $t(e){const t=e.publisherUniqueName?.trim()||"DefaultPublisher",o=e.publisherName?.trim()||t,n=e.publisherPrefix?.trim()||"new",i=e.languageCode||1033,s=e.friendlyName?.trim()||e.uniqueName,l=e.rootComponents.length===0?"<RootComponents/>":`<RootComponents>
9
+ ${e.rootComponents.map(c=>{const d=[`type="${c.type}"`];return c.schemaName&&d.push(`schemaName="${D(c.schemaName)}"`),c.id&&d.push(`id="{${D(c.id)}}"`),d.push(`behavior="${c.behavior}"`),`<RootComponent ${d.join(" ")} />`}).join(`
10
+ `)}
11
+ </RootComponents>`;return`<?xml version="1.0" encoding="utf-8"?>
12
+ <ImportExportXml version="9.1.0.0" SolutionPackageVersion="9.1" languagecode="${i}" generatedBy="CommandBarStudio">
13
+ <SolutionManifest>
14
+ <UniqueName>${D(e.uniqueName)}</UniqueName>
15
+ <LocalizedNames>
16
+ <LocalizedName description="${D(s)}" languagecode="${i}"/>
17
+ </LocalizedNames>
18
+ ${he(e.details.solutionDescription,i)}
19
+ <Version>${D(e.version)}</Version>
20
+ <Managed>0</Managed>
21
+ <Publisher>
22
+ <UniqueName>${D(t)}</UniqueName>
23
+ <LocalizedNames>
24
+ <LocalizedName description="${D(o)}" languagecode="${i}"/>
25
+ </LocalizedNames>
26
+ ${he(e.details.publisherDescription,i)}
27
+ <EMailAddress>${D(e.details.publisherEmail)}</EMailAddress>
28
+ <SupportingWebsiteUrl>${D(e.details.publisherWebsite)}</SupportingWebsiteUrl>
29
+ <CustomizationPrefix>${D(n)}</CustomizationPrefix>
30
+ <CustomizationOptionValuePrefix>${e.details.publisherOptionValuePrefix}</CustomizationOptionValuePrefix>
31
+ ${Ct(e.details.publisherAddresses)}
32
+ </Publisher>
33
+ ${l}
34
+ <MissingDependencies/>
35
+ </SolutionManifest>
36
+ </ImportExportXml>`}export{we as a,vt as b,Dt as c,$e as d,St as e,xt as f,xe as g,te as i,Et as p,V as w};