@ppdostudio/ppdo-cli 0.0.0-stage → 1.0.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 (130) hide show
  1. package/CHANGELOG.md +66 -0
  2. package/LICENSE +114 -0
  3. package/README.md +362 -3
  4. package/THIRD-PARTY-NOTICES +25 -0
  5. package/dist/bin.js +5 -0
  6. package/dist/chunks/ado-XAHQWYNQ.js +103 -0
  7. package/dist/chunks/api-7RAWLIQV.js +2 -0
  8. package/dist/chunks/api-KN24TLH6.js +2 -0
  9. package/dist/chunks/auth-VZSJMSMF.js +6 -0
  10. package/dist/chunks/azCli-AEZK2RBQ.js +2 -0
  11. package/dist/chunks/batch-EZPKLWEI.js +4 -0
  12. package/dist/chunks/build-LSQEAEFK.js +4 -0
  13. package/dist/chunks/bulk-7FZCDH5U.js +2 -0
  14. package/dist/chunks/chunk-4KP27OCL.js +2 -0
  15. package/dist/chunks/chunk-5SBBTR3Y.js +2 -0
  16. package/dist/chunks/chunk-B4FPKDMH.js +2 -0
  17. package/dist/chunks/chunk-BALEFXOL.js +29 -0
  18. package/dist/chunks/chunk-BCAXUZIO.js +2 -0
  19. package/dist/chunks/chunk-BODUSF3V.js +2 -0
  20. package/dist/chunks/chunk-C42MGXRN.js +2 -0
  21. package/dist/chunks/chunk-DVQ7OYIJ.js +2 -0
  22. package/dist/chunks/chunk-GE3XBV3K.js +2 -0
  23. package/dist/chunks/chunk-H4OY4EFC.js +3 -0
  24. package/dist/chunks/chunk-HIW2K6OP.js +4 -0
  25. package/dist/chunks/chunk-I3TMFYRJ.js +194 -0
  26. package/dist/chunks/chunk-J4R6QXW7.js +2 -0
  27. package/dist/chunks/chunk-JAGU2NM5.js +2 -0
  28. package/dist/chunks/chunk-JEAIFLEN.js +51 -0
  29. package/dist/chunks/chunk-KBQYSAJX.js +2 -0
  30. package/dist/chunks/chunk-LB7WNZVK.js +5 -0
  31. package/dist/chunks/chunk-LL4XQ3L7.js +4 -0
  32. package/dist/chunks/chunk-MBNUMAAZ.js +2 -0
  33. package/dist/chunks/chunk-MGZDEW3X.js +8 -0
  34. package/dist/chunks/chunk-MK6QZ4ES.js +2 -0
  35. package/dist/chunks/chunk-MTF66YXU.js +2 -0
  36. package/dist/chunks/chunk-MZEUD7ET.js +6 -0
  37. package/dist/chunks/chunk-OXZG44O5.js +2 -0
  38. package/dist/chunks/chunk-PYTSDUPY.js +2 -0
  39. package/dist/chunks/chunk-QMTPHZLQ.js +2 -0
  40. package/dist/chunks/chunk-RC5VPVGC.js +2 -0
  41. package/dist/chunks/chunk-S4KF5Z3S.js +10 -0
  42. package/dist/chunks/chunk-STWQDANK.js +5 -0
  43. package/dist/chunks/chunk-TADCW6ZI.js +2 -0
  44. package/dist/chunks/chunk-TM3M633T.js +3 -0
  45. package/dist/chunks/chunk-TQLZ3TRU.js +2 -0
  46. package/dist/chunks/chunk-TXVNEV3M.js +3 -0
  47. package/dist/chunks/chunk-TZSB4PR7.js +4 -0
  48. package/dist/chunks/chunk-UCTMKA2J.js +4 -0
  49. package/dist/chunks/chunk-WIA546AL.js +13 -0
  50. package/dist/chunks/chunk-WMDKJRDC.js +2 -0
  51. package/dist/chunks/chunk-WNQERCOO.js +2 -0
  52. package/dist/chunks/chunk-WXOTXJNG.js +3 -0
  53. package/dist/chunks/chunk-ZHHVG47C.js +2 -0
  54. package/dist/chunks/chunk-ZNJ4DRCA.js +2 -0
  55. package/dist/chunks/chunk-ZUXLC5VX.js +2 -0
  56. package/dist/chunks/commands-GRWX32IX.js +2 -0
  57. package/dist/chunks/component-TCL43QXZ.js +2 -0
  58. package/dist/chunks/components-LRHXR5HR.js +2 -0
  59. package/dist/chunks/config-UKI5TBH5.js +2 -0
  60. package/dist/chunks/connection-QNXMJGHZ.js +2 -0
  61. package/dist/chunks/connref-U3CMQ64O.js +2 -0
  62. package/dist/chunks/customizations-VNEASPWI.js +7 -0
  63. package/dist/chunks/dependency-U6OQA5PS.js +3 -0
  64. package/dist/chunks/discovery-IWAWXXWF.js +2 -0
  65. package/dist/chunks/dist-ILNYGTM2.js +136 -0
  66. package/dist/chunks/dv-C45WDXRG.js +192 -0
  67. package/dist/chunks/env-GL5ZPAZI.js +5 -0
  68. package/dist/chunks/environment-FPS4AFM5.js +2 -0
  69. package/dist/chunks/environments-VZWNFJYE.js +2 -0
  70. package/dist/chunks/envvar-52V6K6LF.js +2 -0
  71. package/dist/chunks/esm-Z4QMBGAD.js +2 -0
  72. package/dist/chunks/fanout-Q3656CCP.js +2 -0
  73. package/dist/chunks/fetchxml-FWUQZP4M.js +6 -0
  74. package/dist/chunks/functions-SNCK2IYV.js +2 -0
  75. package/dist/chunks/graph-OK24IOUV.js +5 -0
  76. package/dist/chunks/group-TLGLTTUG.js +6 -0
  77. package/dist/chunks/history-67SQS54S.js +2 -0
  78. package/dist/chunks/identity-SRTOEQVC.js +2 -0
  79. package/dist/chunks/jobs-2ZPBDDHT.js +2 -0
  80. package/dist/chunks/lifecycle-OJRM7K2I.js +2 -0
  81. package/dist/chunks/main-HOYSLMHZ.js +4 -0
  82. package/dist/chunks/metadata-WYVJ7NP7.js +2 -0
  83. package/dist/chunks/metadataCreate-PBA3KH3A.js +2 -0
  84. package/dist/chunks/msalUser-3PBGT655.js +2 -0
  85. package/dist/chunks/names-ZRM6SAYU.js +2 -0
  86. package/dist/chunks/pack-3OYGV36R.js +2 -0
  87. package/dist/chunks/pat-KGOBISLG.js +2 -0
  88. package/dist/chunks/pipelines-62CVDRXV.js +4 -0
  89. package/dist/chunks/plan-ALLKT2QZ.js +2 -0
  90. package/dist/chunks/plugins-SBMDFXVA.js +4 -0
  91. package/dist/chunks/policies-BZR5437X.js +2 -0
  92. package/dist/chunks/pools-I4NVR67Z.js +2 -0
  93. package/dist/chunks/process-WS76WV3T.js +2 -0
  94. package/dist/chunks/project-HSZLY2AY.js +2 -0
  95. package/dist/chunks/projects-GXIQO7HV.js +4 -0
  96. package/dist/chunks/protect-X2J7LU7X.js +2 -0
  97. package/dist/chunks/provider-FN7TXWRE.js +2 -0
  98. package/dist/chunks/prs-F2EVQJRV.js +2 -0
  99. package/dist/chunks/records-7IQET422.js +2 -0
  100. package/dist/chunks/run-APD3TRCW.js +2 -0
  101. package/dist/chunks/run-G2MVOV3C.js +3 -0
  102. package/dist/chunks/run-H2OLE76P.js +2 -0
  103. package/dist/chunks/run-ICS4FNZA.js +3 -0
  104. package/dist/chunks/run-KP2SNX2A.js +3 -0
  105. package/dist/chunks/run-LNEOCXZA.js +2 -0
  106. package/dist/chunks/run-SB4QN5Q4.js +2 -0
  107. package/dist/chunks/run-XRPU3YZF.js +2 -0
  108. package/dist/chunks/runtime-MIU5CS5B.js +2 -0
  109. package/dist/chunks/security-RC3EI7CZ.js +2 -0
  110. package/dist/chunks/service-4VHAPTA6.js +2 -0
  111. package/dist/chunks/service-RFKOKM72.js +2 -0
  112. package/dist/chunks/services-4BORTJPM.js +2 -0
  113. package/dist/chunks/skills-6O2GSTU4.js +2 -0
  114. package/dist/chunks/solution-3WUUDYF3.js +2 -0
  115. package/dist/chunks/solutionExport-GTBTHG2D.js +2 -0
  116. package/dist/chunks/solutionfiles-VWZHFZZ6.js +2 -0
  117. package/dist/chunks/spn-2RZJLCML.js +2 -0
  118. package/dist/chunks/tokenCache-TQFT6LAD.js +2 -0
  119. package/dist/chunks/unpack-HUH7OJMP.js +2 -0
  120. package/dist/chunks/users-JIBQKPYA.js +2 -0
  121. package/dist/chunks/vargroups-Q2KG7LHR.js +2 -0
  122. package/dist/chunks/whoami-V54TCLT5.js +2 -0
  123. package/dist/chunks/workitems-UG5O3EGB.js +2 -0
  124. package/dist/chunks/xmldoc-B2HUNTVK.js +2 -0
  125. package/package.json +57 -6
  126. package/schema/ppdo-cli.schema.json +132 -0
  127. package/skills/README.md +12 -0
  128. package/skills/ppdo-cli/SKILL.md +84 -0
  129. package/skills/ppdo-cli-dataverse/SKILL.md +302 -0
  130. package/skills/ppdo-cli-devops/SKILL.md +150 -0
@@ -0,0 +1,2 @@
1
+ import { createRequire as __cr } from 'node:module'; const require = __cr(import.meta.url);
2
+ import{createRequire as Xn}from"module";var $n=Xn("/"),yr,dr,jr,jn=";var __w=require('worker_threads');__w.parentPort.on('message',function(m){onmessage({data:m})}),postMessage=function(m,t){__w.parentPort.postMessage(m,t)},close=process.exit;self=global";try{yr=$n("worker_threads"),dr=yr.Worker,jr=yr.isMarkedAsUntransferable}catch{}var bn=dr?function(n,r,t,e,i){var a=!1,o=new dr(n+jn,{eval:!0}).on("error",function(s){return i(s,null)}).on("message",function(s){return i(null,s)}).on("exit",function(s){s&&!a&&i(new Error("exited with code "+s),null)});return jr&&(e=e.filter(function(s){return!jr(s)})),o.postMessage(t,e),o.terminate=function(){return a=!0,dr.prototype.terminate.call(o)},o}:function(n,r,t,e,i){setImmediate(function(){return i(new Error("async operations unsupported - update to Node 12+ (or Node 10-11 with the --experimental-worker CLI flag)"),null)});var a=function(){};return{terminate:a,postMessage:a}},S=Uint8Array,Y=Uint16Array,Zr=Int32Array,xr=new S([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),zr=new S([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),Ir=new S([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Sn=function(n,r){for(var t=new Y(31),e=0;e<31;++e)t[e]=r+=1<<n[e-1];for(var i=new Zr(t[30]),e=1;e<30;++e)for(var a=t[e];a<t[e+1];++a)i[a]=a-t[e]<<5|e;return{b:t,r:i}},yr=Sn(xr,2),sn=yr.b,Wr=yr.r;sn[28]=258,Wr[258]=28;var Un=Sn(zr,0),Fn=Un.b,br=Un.r,Br=new Y(32768);for(I=0;I<32768;++I)er=(I&43690)>>1|(I&21845)<<1,er=(er&52428)>>2|(er&13107)<<2,er=(er&61680)>>4|(er&3855)<<4,Br[I]=((er&65280)>>8|(er&255)<<8)>>1;var er,I,X=(function(n,r,t){for(var e=n.length,i=0,a=new Y(r);i<e;++i)n[i]&&++a[n[i]-1];var o=new Y(r);for(i=1;i<r;++i)o[i]=o[i-1]+a[i-1]<<1;var s;if(t){s=new Y(1<<r);var l=15-r;for(i=0;i<e;++i)if(n[i])for(var f=i<<4|n[i],h=r-n[i],u=o[n[i]-1]++<<h,v=u|(1<<h)-1;u<=v;++u)s[Br[u]>>l]=f}else for(s=new Y(e),i=0;i<e;++i)n[i]&&(s[i]=Br[o[n[i]-1]++]>>15-n[i]);return s}),ir=new S(288);for(I=0;I<144;++I)ir[I]=8;var I;for(I=144;I<256;++I)ir[I]=9;var I;for(I=256;I<280;++I)ir[I]=7;var I;for(I=280;I<288;++I)ir[I]=8;var I,wr=new S(32);for(I=0;I<32;++I)wr[I]=5;var I,Cn=X(ir,9,0),Dn=X(ir,9,1),Tn=X(wr,5,0),In=X(wr,5,1),kr=function(n){for(var r=n[0],t=1;t<n.length;++t)n[t]>r&&(r=n[t]);return r},Q=function(n,r,t){var e=r/8|0;return(n[e]|n[e+1]<<8)>>(r&7)&t},Hr=function(n,r){var t=r/8|0;return(n[t]|n[t+1]<<8|n[t+2]<<16)>>(r&7)},Ar=function(n){return(n+7)/8|0},$=function(n,r,t){return(r==null||r<0)&&(r=0),(t==null||t>n.length)&&(t=n.length),new S(n.subarray(r,t))},ft={UnexpectedEOF:0,InvalidBlockType:1,InvalidLengthLiteral:2,InvalidDistance:3,StreamFinished:4,NoStreamHandler:5,InvalidHeader:6,NoCallback:7,InvalidUTF8:8,ExtraFieldTooLong:9,InvalidDate:10,FilenameTooLong:11,StreamFinishing:12,InvalidZipData:13,UnknownCompressionMethod:14},Bn=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],c=function(n,r,t){var e=new Error(r||Bn[n]);if(e.code=n,Error.captureStackTrace&&Error.captureStackTrace(e,c),!t)throw e;return e},Er=function(n,r,t,e){var i=n.length,a=e?e.length:0;if(!i||r.f&&!r.l)return t||new S(0);var o=!t,s=o||r.i!=2,l=r.i;o&&(t=new S(i*3));var f=function(Dr){var Tr=t.length;if(Dr>Tr){var cr=new S(Math.max(Tr*2,Dr));cr.set(t),t=cr}},h=r.f||0,u=r.p||0,v=r.b||0,M=r.l,m=r.d,A=r.m,p=r.n,x=i*8;do{if(!M){h=Q(n,u,1);var U=Q(n,u+1,3);if(u+=3,U)if(U==1)M=Dn,m=In,A=9,p=5;else if(U==2){var E=Q(n,u,31)+257,F=Q(n,u+10,15)+4,w=E+Q(n,u+5,31)+1;u+=14;for(var g=new S(w),q=new S(19),D=0;D<F;++D)q[Ir[D]]=Q(n,u+D*3,7);u+=F*3;for(var G=kr(q),H=(1<<G)-1,P=X(q,G,1),D=0;D<w;){var d=P[Q(n,u,H)];u+=d&15;var z=d>>4;if(z<16)g[D++]=z;else{var Z=0,C=0;for(z==16?(C=3+Q(n,u,3),u+=2,Z=g[D-1]):z==17?(C=3+Q(n,u,7),u+=3):z==18&&(C=11+Q(n,u,127),u+=7);C--;)g[D++]=Z}}var L=g.subarray(0,E),k=g.subarray(E);A=kr(L),p=kr(k),M=X(L,A,1),m=X(k,p,1)}else c(1);else{var z=Ar(u)+4,y=n[z-4]|n[z-3]<<8,B=z+y;if(B>i){l&&c(0);break}s&&f(v+y),t.set(n.subarray(z,B),v),r.b=v+=y,r.p=u=B*8,r.f=h;continue}if(u>x){l&&c(0);break}}s&&f(v+131072);for(var ar=(1<<A)-1,J=(1<<p)-1,b=u;;b=u){var Z=M[Hr(n,u)&ar],W=Z>>4;if(u+=Z&15,u>x){l&&c(0);break}if(Z||c(2),W<256)t[v++]=W;else if(W==256){b=u,M=null;break}else{var R=W-254;if(W>264){var D=W-257,N=xr[D];R=Q(n,u,(1<<N)-1)+sn[D],u+=N}var rr=m[Hr(n,u)&J],lr=rr>>4;rr||c(3),u+=rr&15;var k=Fn[lr];if(lr>3){var N=zr[lr];k+=Hr(n,u)&(1<<N)-1,u+=N}if(u>x){l&&c(0);break}s&&f(v+131072);var vr=v+R;if(v<k){var Or=a-k,Pr=Math.min(k,vr);for(Or+v<0&&c(3);v<Pr;++v)t[v]=e[Or+v]}for(;v<vr;++v)t[v]=t[v-k]}}r.l=M,r.p=b,r.b=v,r.f=h,M&&(h=1,r.m=A,r.d=m,r.n=p)}while(!h);return v!=t.length&&o?$(t,0,v):t.subarray(0,v)},nr=function(n,r,t){t<<=r&7;var e=r/8|0;n[e]|=t,n[e+1]|=t>>8},pr=function(n,r,t){t<<=r&7;var e=r/8|0;n[e]|=t,n[e+1]|=t>>8,n[e+2]|=t>>16},Lr=function(n,r){for(var t=[],e=0;e<n.length;++e)n[e]&&t.push({s:e,f:n[e]});var i=t.length,a=t.slice();if(!i)return{t:tr,l:0};if(i==1){var o=new S(t[0].s+1);return o[t[0].s]=1,{t:o,l:1}}t.sort(function(B,E){return B.f-E.f}),t.push({s:-1,f:25001});var s=t[0],l=t[1],f=0,h=1,u=2;for(t[0]={s:-1,f:s.f+l.f,l:s,r:l};h!=i-1;)s=t[t[f].f<t[u].f?f++:u++],l=t[f!=h&&t[f].f<t[u].f?f++:u++],t[h++]={s:-1,f:s.f+l.f,l:s,r:l};for(var v=a[0].s,e=1;e<i;++e)a[e].s>v&&(v=a[e].s);var M=new Y(v+1),m=Rr(t[h-1],M,0);if(m>r){var e=0,A=0,p=m-r,x=1<<p;for(a.sort(function(E,F){return M[F.s]-M[E.s]||E.f-F.f});e<i;++e){var U=a[e].s;if(M[U]>r)A+=x-(1<<m-M[U]),M[U]=r;else break}for(A>>=p;A>0;){var z=a[e].s;M[z]<r?A-=1<<r-M[z]++-1:++e}for(;e>=0&&A;--e){var y=a[e].s;M[y]==r&&(--M[y],++A)}m=r}return{t:new S(M),l:m}},Rr=function(n,r,t){return n.s==-1?Math.max(Rr(n.l,r,t+1),Rr(n.r,r,t+1)):r[n.s]=t},_r=function(n){for(var r=n.length;r&&!n[--r];);for(var t=new Y(++r),e=0,i=n[0],a=1,o=function(l){t[e++]=l},s=1;s<=r;++s)if(n[s]==i&&s!=r)++a;else{if(!i&&a>2){for(;a>138;a-=138)o(32754);a>2&&(o(a>10?a-11<<5|28690:a-3<<5|12305),a=0)}else if(a>3){for(o(i),--a;a>6;a-=6)o(8304);a>2&&(o(a-3<<5|8208),a=0)}for(;a--;)o(i);a=1,i=n[s]}return{c:t.subarray(0,e),n:r}},gr=function(n,r){for(var t=0,e=0;e<r.length;++e)t+=n[e]*r[e];return t},Jr=function(n,r,t){var e=t.length,i=Ar(r+2);n[i]=e&255,n[i+1]=e>>8,n[i+2]=n[i]^255,n[i+3]=n[i+1]^255;for(var a=0;a<e;++a)n[i+a+4]=t[a];return(i+4+e)*8},rn=function(n,r,t,e,i,a,o,s,l,f,h){nr(r,h++,t),++i[256];for(var u=Lr(i,15),v=u.t,M=u.l,m=Lr(a,15),A=m.t,p=m.l,x=_r(v),U=x.c,z=x.n,y=_r(A),B=y.c,E=y.n,F=new Y(19),w=0;w<U.length;++w)++F[U[w]&31];for(var w=0;w<B.length;++w)++F[B[w]&31];for(var g=Lr(F,7),q=g.t,D=g.l,G=19;G>4&&!q[Ir[G-1]];--G);var H=f+5<<3,P=gr(i,ir)+gr(a,wr)+o,d=gr(i,v)+gr(a,A)+o+14+3*G+gr(F,q)+2*F[16]+3*F[17]+7*F[18];if(l>=0&&H<=P&&H<=d)return Jr(r,h,n.subarray(l,l+f));var Z,C,L,k;if(nr(r,h,1+(d<P)),h+=2,d<P){Z=X(v,M,0),C=v,L=X(A,p,0),k=A;var ar=X(q,D,0);nr(r,h,z-257),nr(r,h+5,E-1),nr(r,h+10,G-4),h+=14;for(var w=0;w<G;++w)nr(r,h+3*w,q[Ir[w]]);h+=3*G;for(var J=[U,B],b=0;b<2;++b)for(var W=J[b],w=0;w<W.length;++w){var R=W[w]&31;nr(r,h,ar[R]),h+=q[R],R>15&&(nr(r,h,W[w]>>5&127),h+=W[w]>>12)}}else Z=Cn,C=ir,L=Tn,k=wr;for(var w=0;w<s;++w){var N=e[w];if(N>255){var R=N>>18&31;pr(r,h,Z[R+257]),h+=C[R+257],R>7&&(nr(r,h,N>>23&31),h+=xr[R]);var rr=N&31;pr(r,h,L[rr]),h+=k[rr],rr>3&&(pr(r,h,N>>5&8191),h+=zr[rr])}else pr(r,h,Z[N]),h+=C[N]}return pr(r,h,Z[256]),h+C[256]},Zn=new Zr([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),tr=new S(0),En=function(n,r,t,e,i,a){var o=a.z||n.length,s=new S(e+o+5*(1+Math.ceil(o/7e3))+i),l=s.subarray(e,s.length-i),f=a.l,h=(a.r||0)&7;if(r){h&&(l[0]=a.r>>3);for(var u=Zn[r-1],v=u>>13,M=u&8191,m=(1<<t)-1,A=a.p||new Y(32768),p=a.h||new Y(m+1),x=Math.ceil(t/3),U=2*x,z=function(Xr){return(n[Xr]^n[Xr+1]<<x^n[Xr+2]<<U)&m},y=new Zr(25e3),B=new Y(288),E=new Y(32),F=0,w=0,g=a.i||0,q=0,D=a.w||0,G=0;g+2<o;++g){var H=z(g),P=g&32767,d=p[H];if(A[P]=d,p[H]=P,D<=g){var Z=o-g;if((F>7e3||q>24576)&&(Z>423||!f)){h=rn(n,l,0,y,B,E,w,q,G,g-G,h),q=F=w=0,G=g;for(var C=0;C<286;++C)B[C]=0;for(var C=0;C<30;++C)E[C]=0}var L=2,k=0,ar=M,J=P-d&32767;if(Z>2&&H==z(g-J))for(var b=Math.min(v,Z)-1,W=Math.min(32767,g),R=Math.min(258,Z);J<=W&&--ar&&P!=d;){if(n[g+L]==n[g+L-J]){for(var N=0;N<R&&n[g+N]==n[g+N-J];++N);if(N>L){if(L=N,k=J,N>b)break;for(var rr=Math.min(J,N-2),lr=0,C=0;C<rr;++C){var vr=g-J+C&32767,Or=A[vr],Pr=vr-Or&32767;Pr>lr&&(lr=Pr,d=vr)}}}P=d,d=A[P],J+=P-d&32767}if(k){y[q++]=268435456|Wr[L]<<18|br[k];var Dr=Wr[L]&31,Tr=br[k]&31;w+=xr[Dr]+zr[Tr],++B[257+Dr],++E[Tr],D=g+L,++F}else y[q++]=n[g],++B[n[g]]}}for(g=Math.max(g,D);g<o;++g)y[q++]=n[g],++B[n[g]];h=rn(n,l,f,y,B,E,w,q,G,g-G,h),f||(a.r=h&7|l[h/8|0]<<3,h-=7,a.h=p,a.p=A,a.i=g,a.w=D)}else{for(var g=a.w||0;g<o+f;g+=65535){var cr=g+65535;cr>=o&&(l[h/8|0]=f,cr=o),h=Jr(l,h+1,n.subarray(g,cr))}a.i=o}return $(s,0,e+Ar(h)+i)},qn=(function(){for(var n=new Int32Array(256),r=0;r<256;++r){for(var t=r,e=9;--e;)t=(t&1&&-306674912)^t>>>1;n[r]=t}return n})(),Mr=function(){var n=-1;return{p:function(r){for(var t=n,e=0;e<r.length;++e)t=qn[t&255^r[e]]^t>>>8;n=t},d:function(){return~n}}},Kr=function(){var n=1,r=0;return{p:function(t){for(var e=n,i=r,a=t.length|0,o=0;o!=a;){for(var s=Math.min(o+2655,a);o<s;++o)i+=e+=t[o];e=(e&65535)+15*(e>>16),i=(i&65535)+15*(i>>16)}n=e,r=i},d:function(){return n%=65521,r%=65521,(n&255)<<24|(n&65280)<<8|(r&255)<<8|r>>8}}},hr=function(n,r,t,e,i){if(!i&&(i={l:1},r.dictionary)){var a=r.dictionary.subarray(-32768),o=new S(a.length+n.length);o.set(a),o.set(n,a.length),n=o,i.w=a.length}return En(n,r.level==null?6:r.level,r.mem==null?i.l?Math.ceil(Math.max(8,Math.min(13,Math.log(n.length)))*1.5):20:12+r.mem,t,e,i)},qr=function(n,r){var t={};for(var e in n)t[e]=n[e];for(var e in r)t[e]=r[e];return t},yn=function(n,r,t){for(var e=n(),i=n.toString(),a=i.slice(i.indexOf("[")+1,i.lastIndexOf("]")).replace(/\s+/g,"").split(","),o=0;o<e.length;++o){var s=e[o],l=a[o];if(typeof s=="function"){r+=";"+l+"=";var f=s.toString();if(s.prototype)if(f.indexOf("[native code]")!=-1){var h=f.indexOf(" ",8)+1;r+=f.slice(h,f.indexOf("(",h))}else{r+=f;for(var u in s.prototype)r+=";"+l+".prototype."+u+"="+s.prototype[u].toString()}else r+=f}else t[l]=s}return r},Nr=[],_n=function(n){var r=[];for(var t in n)n[t].buffer&&r.push((n[t]=new n[t].constructor(n[t])).buffer);return r},Gn=function(n,r,t,e){if(!Nr[t]){for(var i="",a={},o=n.length-1,s=0;s<o;++s)i=yn(n[s],i,a);Nr[t]={c:yn(n[o],i,a),e:a}}var l=qr({},Nr[t].e);return bn(Nr[t].c+";onmessage=function(e){for(var k in e.data)self[k]=e.data[k];onmessage="+r.toString()+"}",t,l,_n(l),e)},Sr=function(){return[S,Y,Zr,xr,zr,Ir,sn,Fn,Dn,In,Br,Bn,X,kr,Q,Hr,Ar,$,c,Er,Gr,sr,fn]},Ur=function(){return[S,Y,Zr,xr,zr,Ir,Wr,br,Cn,ir,Tn,wr,Br,Zn,tr,X,nr,pr,Lr,Rr,_r,gr,Jr,rn,Ar,$,En,hr,Qr,sr]},On=function(){return[hn,ln,T,Mr,qn]},Pn=function(){return[un,kn]},Nn=function(){return[vn,T,Kr]},dn=function(){return[cn]},sr=function(n){return postMessage(n,[n.buffer])},fn=function(n){return n&&{out:n.size&&new S(n.size),dictionary:n.dictionary}},Fr=function(n,r,t,e,i,a){var o=Gn(t,e,i,function(s,l){o.terminate(),a(s,l)});return o.postMessage([n,r],r.consume?[n.buffer]:[]),function(){o.terminate()}},j=function(n){return n.ondata=function(r,t){return postMessage([r,t],[r.buffer])},function(r){r.data[0]?(n.push(r.data[0],r.data[1]),postMessage([r.data[0].length])):n.flush(r.data[1])}},Cr=function(n,r,t,e,i,a,o){var s,l=Gn(n,e,i,function(f,h){f?(l.terminate(),r.ondata.call(r,f)):Array.isArray(h)?h.length==1?(r.queuedSize-=h[0],r.ondrain&&r.ondrain(h[0])):(h[1]&&l.terminate(),r.ondata.call(r,f,h[0],h[1])):o(h)});l.postMessage(t),r.queuedSize=0,r.push=function(f,h){r.ondata||c(5),s&&r.ondata(c(4,0,1),null,!!h),r.queuedSize+=f.length,l.postMessage([f,s=h],f.buffer instanceof ArrayBuffer?[f.buffer]:[])},r.terminate=function(){l.terminate()},a&&(r.flush=function(f){l.postMessage([0,f])})},V=function(n,r){return n[r]|n[r+1]<<8},O=function(n,r){return(n[r]|n[r+1]<<8|n[r+2]<<16|n[r+3]<<24)>>>0},$r=function(n,r){return O(n,r)+O(n,r+4)*4294967296},T=function(n,r,t){for(;t;++r)n[r]=t,t>>>=8},hn=function(n,r){var t=r.filename;if(n[0]=31,n[1]=139,n[2]=8,n[8]=r.level<2?4:r.level==9?2:0,n[9]=3,r.mtime!=0&&T(n,4,Math.floor(new Date(r.mtime||Date.now())/1e3)),t){n[3]=8;for(var e=0;e<=t.length;++e)n[e+10]=t.charCodeAt(e)}},un=function(n){(n[0]!=31||n[1]!=139||n[2]!=8)&&c(6,"invalid gzip data");var r=n[3],t=10;r&4&&(t+=(n[10]|n[11]<<8)+2);for(var e=(r>>3&1)+(r>>4&1);e>0;e-=!n[t++]);return t+(r&2)},kn=function(n){var r=n.length;return(n[r-4]|n[r-3]<<8|n[r-2]<<16|n[r-1]<<24)>>>0},ln=function(n){return 10+(n.filename?n.filename.length+1:0)},vn=function(n,r){var t=r.level,e=t==0?0:t<6?1:t==9?3:2;if(n[0]=120,n[1]=e<<6|(r.dictionary&&32),n[1]|=31-(n[0]<<8|n[1])%31,r.dictionary){var i=Kr();i.p(r.dictionary),T(n,2,i.d())}},cn=function(n,r){return((n[0]&15)!=8||n[0]>>4>7||(n[0]<<8|n[1])%31)&&c(6,"invalid zlib data"),(n[1]>>5&1)==+!r&&c(6,"invalid zlib data: "+(n[1]&32?"need":"unexpected")+" dictionary"),(n[1]>>3&4)+2};function ur(n,r){return typeof n=="function"&&(r=n,n={}),this.ondata=r,n}var _=(function(){function n(r,t){if(typeof r=="function"&&(t=r,r={}),this.ondata=t,this.o=r||{},this.s={l:0,i:32768,w:32768,z:32768},this.b=new S(98304),this.o.dictionary){var e=this.o.dictionary.subarray(-32768);this.b.set(e,32768-e.length),this.s.i=32768-e.length}}return n.prototype.p=function(r,t){this.ondata(hr(r,this.o,0,0,this.s),t)},n.prototype.push=function(r,t){this.ondata||c(5),this.s.l&&c(4);var e=r.length+this.s.z;if(e>this.b.length){if(e>2*this.b.length-32768){var i=new S(e&-32768);i.set(this.b.subarray(0,this.s.z)),this.b=i}var a=this.b.length-this.s.z;this.b.set(r.subarray(0,a),this.s.z),this.s.z=this.b.length,this.p(this.b,!1),this.b.set(this.b.subarray(-32768)),this.b.set(r.subarray(a),32768),this.s.z=r.length-a+32768,this.s.i=32766,this.s.w=32768}else this.b.set(r,this.s.z),this.s.z+=r.length;this.s.l=t&1,(this.s.z>this.s.w+8191||t)&&(this.p(this.b,t||!1),this.s.w=this.s.i,this.s.i-=2),t&&(this.s=this.o={},this.b=tr)},n.prototype.flush=function(r){if(this.ondata||c(5),this.s.l&&c(4),this.p(this.b,!1),this.s.w=this.s.i,this.s.i-=2,r){var t=new S(6);t[0]=this.s.r>>3;var e=Jr(t,this.s.r,tr);this.s.r=0,this.ondata(t.subarray(0,e>>3),!1)}},n})();var rt=(function(){function n(r,t){Cr([Ur,function(){return[j,_]}],this,ur.call(this,r,t),function(e){var i=new _(e.data);onmessage=j(i)},6,1)}return n})();function nt(n,r,t){return t||(t=r,r={}),typeof t!="function"&&c(7),Fr(n,r,[Ur],function(e){return sr(Qr(e.data[0],e.data[1]))},0,t)}function Qr(n,r){return hr(n,r||{},0,0)}var K=(function(){function n(r,t){typeof r=="function"&&(t=r,r={}),this.ondata=t;var e=r&&r.dictionary&&r.dictionary.subarray(-32768);this.s={i:0,b:e?e.length:0},this.o=new S(32768),this.p=new S(0),e&&this.o.set(e)}return n.prototype.e=function(r){if(this.ondata||c(5),this.d&&c(4),!this.p.length)this.p=r;else if(r.length){var t=new S(this.p.length+r.length);t.set(this.p),t.set(r,this.p.length),this.p=t}},n.prototype.c=function(r){this.s.i=+(this.d=r||!1);var t=this.s.b,e=Er(this.p,this.s,this.o);this.ondata($(e,t,this.s.b),this.d),this.o=$(e,this.s.b-32768),this.s.b=this.o.length,this.p=$(this.p,this.s.p/8|0),this.s.p&=7},n.prototype.push=function(r,t){this.e(r),this.c(t)},n})();var Hn=(function(){function n(r,t){Cr([Sr,function(){return[j,K]}],this,ur.call(this,r,t),function(e){var i=new K(e.data);onmessage=j(i)},7,0)}return n})();function Ln(n,r,t){return t||(t=r,r={}),typeof t!="function"&&c(7),Fr(n,r,[Sr],function(e){return sr(Gr(e.data[0],fn(e.data[1])))},1,t)}function Gr(n,r){return Er(n,{i:2},r&&r.out,r&&r.dictionary)}var wn=(function(){function n(r,t){this.c=Mr(),this.l=0,this.v=1,_.call(this,r,t)}return n.prototype.push=function(r,t){this.c.p(r),this.l+=r.length,_.prototype.push.call(this,r,t)},n.prototype.p=function(r,t){var e=hr(r,this.o,this.v&&ln(this.o),t&&8,this.s);this.v&&(hn(e,this.o),this.v=0),t&&(T(e,e.length-8,this.c.d()),T(e,e.length-4,this.l)),this.ondata(e,t)},n.prototype.flush=function(r){_.prototype.flush.call(this,r)},n})();var ht=(function(){function n(r,t){Cr([Ur,On,function(){return[j,_,wn]}],this,ur.call(this,r,t),function(e){var i=new wn(e.data);onmessage=j(i)},8,1)}return n})();function ut(n,r,t){return t||(t=r,r={}),typeof t!="function"&&c(7),Fr(n,r,[Ur,On,function(){return[mn]}],function(e){return sr(mn(e.data[0],e.data[1]))},2,t)}function mn(n,r){r||(r={});var t=Mr(),e=n.length;t.p(n);var i=hr(n,r,ln(r),8),a=i.length;return hn(i,r),T(i,a-8,t.d()),T(i,a-4,e),i}var nn=(function(){function n(r,t){this.v=1,this.r=0,K.call(this,r,t)}return n.prototype.push=function(r,t){if(K.prototype.e.call(this,r),this.r+=r.length,this.v){var e=this.p.subarray(this.v-1),i=e.length>3?un(e):4;if(i>e.length){if(!t)return}else this.v>1&&this.onmember&&this.onmember(this.r-e.length);this.p=e.subarray(i),this.v=0}K.prototype.c.call(this,0),this.s.f&&!this.s.l?(this.v=Ar(this.s.p)+9,this.s={i:0},this.o=new S(0),this.push(new S(0),t)):t&&K.prototype.c.call(this,t)},n})();var tt=(function(){function n(r,t){var e=this;Cr([Sr,Pn,function(){return[j,K,nn]}],this,ur.call(this,r,t),function(i){var a=new nn(i.data);a.onmember=function(o){return postMessage(o)},onmessage=j(a)},9,0,function(i){return e.onmember&&e.onmember(i)})}return n})();function et(n,r,t){return t||(t=r,r={}),typeof t!="function"&&c(7),Fr(n,r,[Sr,Pn,function(){return[tn]}],function(e){return sr(tn(e.data[0],e.data[1]))},3,t)}function tn(n,r){var t=un(n);return t+8>n.length&&c(6,"invalid gzip data"),Er(n.subarray(t,-8),{i:2},r&&r.out||new S(kn(n)),r&&r.dictionary)}var xn=(function(){function n(r,t){this.c=Kr(),this.v=1,_.call(this,r,t)}return n.prototype.push=function(r,t){this.c.p(r),_.prototype.push.call(this,r,t)},n.prototype.p=function(r,t){var e=hr(r,this.o,this.v&&(this.o.dictionary?6:2),t&&4,this.s);this.v&&(vn(e,this.o),this.v=0),t&&T(e,e.length-4,this.c.d()),this.ondata(e,t)},n.prototype.flush=function(r){_.prototype.flush.call(this,r)},n})();var lt=(function(){function n(r,t){Cr([Ur,Nn,function(){return[j,_,xn]}],this,ur.call(this,r,t),function(e){var i=new xn(e.data);onmessage=j(i)},10,1)}return n})();function vt(n,r,t){return t||(t=r,r={}),typeof t!="function"&&c(7),Fr(n,r,[Ur,Nn,function(){return[zn]}],function(e){return sr(zn(e.data[0],e.data[1]))},4,t)}function zn(n,r){r||(r={});var t=Kr();t.p(n);var e=hr(n,r,r.dictionary?6:2,4);return vn(e,r),T(e,e.length-4,t.d()),e}var en=(function(){function n(r,t){K.call(this,r,t),this.v=r&&r.dictionary?2:1}return n.prototype.push=function(r,t){if(K.prototype.e.call(this,r),this.v){if(this.p.length<6&&!t)return;this.p=this.p.subarray(cn(this.p,this.v-1)),this.v=0}t&&(this.p.length<4&&c(6,"invalid zlib data"),this.p=this.p.subarray(0,-4)),K.prototype.c.call(this,t)},n})();var it=(function(){function n(r,t){Cr([Sr,dn,function(){return[j,K,en]}],this,ur.call(this,r,t),function(e){var i=new en(e.data);onmessage=j(i)},11,0)}return n})();function at(n,r,t){return t||(t=r,r={}),typeof t!="function"&&c(7),Fr(n,r,[Sr,dn,function(){return[an]}],function(e){return sr(an(e.data[0],fn(e.data[1])))},5,t)}function an(n,r){return Er(n.subarray(cn(n,r&&r.dictionary),-4),{i:2},r&&r.out,r&&r.dictionary)}var An=(function(){function n(r,t){this.o=ur.call(this,r,t)||{},this.G=nn,this.I=K,this.Z=en}return n.prototype.i=function(){var r=this;this.s.ondata=function(t,e){r.ondata(t,e)}},n.prototype.push=function(r,t){if(this.ondata||c(5),this.s)this.s.push(r,t);else{if(this.p&&this.p.length){var e=new S(this.p.length+r.length);e.set(this.p),e.set(r,this.p.length)}else this.p=r;this.p.length>2&&(this.s=this.p[0]==31&&this.p[1]==139&&this.p[2]==8?new this.G(this.o):(this.p[0]&15)!=8||this.p[0]>>4>7||(this.p[0]<<8|this.p[1])%31?new this.I(this.o):new this.Z(this.o),this.i(),this.s.push(this.p,t),this.p=null)}},n})();var ct=(function(){function n(r,t){An.call(this,r,t),this.queuedSize=0,this.G=tt,this.I=Hn,this.Z=it}return n.prototype.i=function(){var r=this;this.s.ondata=function(t,e,i){r.ondata(t,e,i)},this.s.ondrain=function(t){r.queuedSize-=t,r.ondrain&&r.ondrain(t)}},n.prototype.push=function(r,t){this.queuedSize+=r.length,An.prototype.push.call(this,r,t)},n})();function pt(n,r,t){return t||(t=r,r={}),typeof t!="function"&&c(7),n[0]==31&&n[1]==139&&n[2]==8?et(n,r,t):(n[0]&15)!=8||n[0]>>4>7||(n[0]<<8|n[1])%31?Ln(n,r,t):at(n,r,t)}function gt(n,r){return n[0]==31&&n[1]==139&&n[2]==8?tn(n,r):(n[0]&15)!=8||n[0]>>4>7||(n[0]<<8|n[1])%31?Gr(n,r):an(n,r)}var pn=function(n,r,t,e){for(var i in n){var a=n[i],o=r+i,s=e;Array.isArray(a)&&(s=qr(e,a[1]),a=a[0]),ArrayBuffer.isView(a)?t[o]=[a,s]:(t[o+="/"]=[new S(0),s],pn(a,o,t,e))}},Mn=typeof TextEncoder<"u"&&new TextEncoder,on=typeof TextDecoder<"u"&&new TextDecoder,Wn=0;try{on.decode(tr,{stream:!0}),Wn=1}catch{}var Rn=function(n){for(var r="",t=0;;){var e=n[t++],i=(e>127)+(e>223)+(e>239);if(t+i>n.length)return{s:r,r:$(n,t-1)};i?i==3?(e=((e&15)<<18|(n[t++]&63)<<12|(n[t++]&63)<<6|n[t++]&63)-65536,r+=String.fromCharCode(55296|e>>10,56320|e&1023)):i&1?r+=String.fromCharCode((e&31)<<6|n[t++]&63):r+=String.fromCharCode((e&15)<<12|(n[t++]&63)<<6|n[t++]&63):r+=String.fromCharCode(e)}},yt=(function(){function n(r){this.ondata=r,Wn?this.t=new TextDecoder:this.p=tr}return n.prototype.push=function(r,t){if(this.ondata||c(5),t=!!t,this.t){this.ondata(this.t.decode(r,{stream:!0}),t),t&&(this.t.decode().length&&c(8),this.t=null);return}this.p||c(4);var e=new S(this.p.length+r.length);e.set(this.p),e.set(r,this.p.length);var i=Rn(e),a=i.s,o=i.r;t?(o.length&&c(8),this.p=null):this.p=o,this.ondata(a,t)},n})();var wt=(function(){function n(r){this.ondata=r}return n.prototype.push=function(r,t){this.ondata||c(5),this.d&&c(4),this.ondata(fr(r),this.d=t||!1)},n})();function fr(n,r){if(r){for(var t=new S(n.length),e=0;e<n.length;++e)t[e]=n.charCodeAt(e);return t}if(Mn)return Mn.encode(n);for(var i=n.length,a=new S(n.length+(n.length>>1)),o=0,s=function(h){a[o++]=h},e=0;e<i;++e){if(o+5>a.length){var l=new S(o+8+(i-e<<1));l.set(a),a=l}var f=n.charCodeAt(e);f<128||r?s(f):f<2048?(s(192|f>>6),s(128|f&63)):f>55295&&f<57344?(f=65536+(f&1047552)|n.charCodeAt(++e)&1023,s(240|f>>18),s(128|f>>12&63),s(128|f>>6&63),s(128|f&63)):(s(224|f>>12),s(128|f>>6&63),s(128|f&63))}return $(a,0,o)}function Vn(n,r){if(r){for(var t="",e=0;e<n.length;e+=16384)t+=String.fromCharCode.apply(null,n.subarray(e,e+16384));return t}else{if(on)return on.decode(n);var i=Rn(n),a=i.s,t=i.r;return t.length&&c(8),a}}var Yn=function(n){return n==1?3:n<6?2:n==9?1:0},Jn=function(n,r){return r+30+V(n,r+26)+V(n,r+28)},Kn=function(n,r,t){var e=V(n,r+28),i=V(n,r+30),a=Vn(n.subarray(r+46,r+46+e),!(V(n,r+8)&2048)),o=r+46+e,s=Qn(n,o,i,t,O(n,r+20),O(n,r+24),O(n,r+42)),l=s[0],f=s[1],h=s[2];return[V(n,r+10),l,f,a,o+i+V(n,r+32),h]},Qn=function(n,r,t,e,i,a,o){var s=i==4294967295,l=a==4294967295,f=o==4294967295,h=r+t,u=s+l+f;if(e&&u){for(;r+4<h;r+=4+V(n,r+2))if(V(n,r)==1)return[s?$r(n,r+4+8*l):i,l?$r(n,r+4):a,f?$r(n,r+4+8*(l+s)):o,1];e<2&&c(13)}return[i,a,o,0]},or=function(n){var r=0;if(n)for(var t in n){var e=n[t].length;e>65535&&c(9),r+=e+4}return r},mr=function(n,r,t,e,i,a,o,s){var l=e.length,f=t.extra,h=s&&s.length,u=or(f);T(n,r,o!=null?33639248:67324752),r+=4,o!=null&&(n[r++]=20,n[r++]=t.os),n[r]=20,r+=2,n[r++]=t.flag<<1|(a<0&&8),n[r++]=i&&8,n[r++]=t.compression&255,n[r++]=t.compression>>8;var v=new Date(t.mtime==null?Date.now():t.mtime),M=v.getFullYear()-1980;if((M<0||M>119)&&c(10),T(n,r,M<<25|v.getMonth()+1<<21|v.getDate()<<16|v.getHours()<<11|v.getMinutes()<<5|v.getSeconds()>>1),r+=4,a!=-1&&(T(n,r,t.crc),T(n,r+4,a<0?-a-2:a),T(n,r+8,t.size)),T(n,r+12,l),T(n,r+14,u),r+=16,o!=null&&(T(n,r,h),T(n,r+6,t.attrs),T(n,r+10,o),r+=14),n.set(e,r),r+=l,u)for(var m in f){var A=f[m],p=A.length;T(n,r,+m),T(n,r+2,p),n.set(A,r+4),r+=4+p}return h&&(n.set(s,r),r+=h),r},gn=function(n,r,t,e,i){T(n,r,101010256),T(n,r+8,t),T(n,r+10,t),T(n,r+12,e),T(n,r+16,i)},Vr=(function(){function n(r){this.filename=r,this.c=Mr(),this.size=0,this.compression=0}return n.prototype.process=function(r,t){this.ondata(null,r,t)},n.prototype.push=function(r,t){this.ondata||c(5),this.c.p(r),this.size+=r.length,t&&(this.crc=this.c.d()),this.process(r,t||!1)},n})();var mt=(function(){function n(r,t){var e=this;t||(t={}),Vr.call(this,r),this.d=new _(t,function(i,a){e.ondata(null,i,a)}),this.compression=8,this.flag=Yn(t.level)}return n.prototype.process=function(r,t){try{this.d.push(r,t)}catch(e){this.ondata(e,null,t)}},n.prototype.push=function(r,t){Vr.prototype.push.call(this,r,t)},n})();var xt=(function(){function n(r,t){var e=this;t||(t={}),Vr.call(this,r),this.d=new rt(t,function(i,a,o){e.ondata(i,a,o)}),this.compression=8,this.flag=Yn(t.level),this.terminate=this.d.terminate}return n.prototype.process=function(r,t){this.d.push(r,t)},n.prototype.push=function(r,t){Vr.prototype.push.call(this,r,t)},n})();var zt=(function(){function n(r){this.ondata=r,this.u=[],this.d=1}return n.prototype.add=function(r){var t=this;if(this.ondata||c(5),this.d&2)this.ondata(c(4+(this.d&1)*8,0,1),null,!1);else{var e=fr(r.filename),i=e.length,a=r.comment,o=a&&fr(a),s=i!=r.filename.length||o&&a.length!=o.length,l=i+or(r.extra)+30;i>65535&&this.ondata(c(11,0,1),null,!1);var f=new S(l);mr(f,0,r,e,s,-1);var h=[f],u=function(){for(var p=0,x=h;p<x.length;p++){var U=x[p];t.ondata(null,U,!1)}h=[]},v=this.d;this.d=0;var M=this.u.length,m=qr(r,{f:e,u:s,o,t:function(){r.terminate&&r.terminate()},r:function(){if(u(),v){var p=t.u[M+1];p?p.r():t.d=1}v=1}}),A=0;r.ondata=function(p,x,U){if(p)t.ondata(p,x,U),t.terminate();else if(A+=x.length,h.push(x),U){var z=new S(16);T(z,0,134695760),T(z,4,r.crc),T(z,8,A),T(z,12,r.size),h.push(z),m.c=A,m.b=l+A+16,m.crc=r.crc,m.size=r.size,v&&m.r(),v=1}else v&&u()},this.u.push(m)}},n.prototype.end=function(){var r=this;if(this.d&2){this.ondata(c(4+(this.d&1)*8,0,1),null,!0);return}this.d?this.e():this.u.push({r:function(){r.d&1&&(r.u.splice(-1,1),r.e())},t:function(){}}),this.d=3},n.prototype.e=function(){for(var r=0,t=0,e=0,i=0,a=this.u;i<a.length;i++){var o=a[i];e+=46+o.f.length+or(o.extra)+(o.o?o.o.length:0)}for(var s=new S(e+22),l=0,f=this.u;l<f.length;l++){var o=f[l];mr(s,r,o,o.f,o.u,-o.c-2,t,o.o),r+=46+o.f.length+or(o.extra)+(o.o?o.o.length:0),t+=o.b}gn(s,r,this.u.length,e,t),this.ondata(null,s,!0),this.d=2},n.prototype.terminate=function(){for(var r=0,t=this.u;r<t.length;r++){var e=t[r];e.t()}this.d=2},n})();function At(n,r,t){t||(t=r,r={}),typeof t!="function"&&c(7);var e={};pn(n,"",e,r);var i=Object.keys(e),a=i.length,o=0,s=0,l=a,f=new Array(a),h=[],u=function(){for(var p=0;p<h.length;++p)h[p]()},v=function(p,x){Yr(function(){t(p,x)})};Yr(function(){v=t});var M=function(){var p=new S(s+22),x=o,U=s-o;s=0;for(var z=0;z<l;++z){var y=f[z];try{var B=y.c.length;mr(p,s,y,y.f,y.u,B);var E=30+y.f.length+or(y.extra),F=s+E;p.set(y.c,F),mr(p,o,y,y.f,y.u,B,s,y.m),o+=16+E+(y.m?y.m.length:0),s=F+B}catch(w){return v(w,null)}}gn(p,o,f.length,U,x),v(null,p)};a||M();for(var m=function(p){var x=i[p],U=e[x],z=U[0],y=U[1],B=Mr(),E=z.length;B.p(z);var F=fr(x),w=F.length,g=y.comment,q=g&&fr(g),D=q&&q.length,G=or(y.extra),H=y.level==0?0:8,P=function(d,Z){if(d)u(),v(d,null);else{var C=Z.length;f[p]=qr(y,{size:E,crc:B.d(),c:Z,f:F,m:q,u:w!=x.length||q&&g.length!=D,compression:H}),o+=30+w+G+C,s+=76+2*(w+G)+(D||0)+C,--a||M()}};if(w>65535&&P(c(11,0,1),null),!H)P(null,z);else if(E<16e4)try{P(null,Qr(z,y))}catch(d){P(d,null)}else h.push(nt(z,y,P))},A=0;A<l;++A)m(A);return u}function Mt(n,r){r||(r={});var t={},e=[];pn(n,"",t,r);var i=0,a=0;for(var o in t){var s=t[o],l=s[0],f=s[1],h=f.level==0?0:8,u=fr(o),v=u.length,M=f.comment,m=M&&fr(M),A=m&&m.length,p=or(f.extra);v>65535&&c(11);var x=h?Qr(l,f):l,U=x.length,z=Mr();z.p(l),e.push(qr(f,{size:l.length,crc:z.d(),c:x,f:u,m,u:v!=o.length||m&&M.length!=A,o:i,compression:h})),i+=30+v+p+U,a+=76+2*(v+p)+(A||0)+U}for(var y=new S(a+22),B=i,E=a-i,F=0;F<e.length;++F){var u=e[F];mr(y,u.o,u,u.f,u.u,u.c.length);var w=30+u.f.length+or(u.extra);y.set(u.c,u.o+w),mr(y,i,u,u.f,u.u,u.c.length,u.o,u.m),i+=16+w+(u.m?u.m.length:0)}return gn(y,i,e.length,E,B),y}var ot=(function(){function n(){}return n.prototype.push=function(r,t){this.ondata(null,r,t)},n.compression=0,n})();var St=(function(){function n(){var r=this;this.i=new K(function(t,e){r.ondata(null,t,e)})}return n.prototype.push=function(r,t){try{this.i.push(r,t)}catch(e){this.ondata(e,null,t)}},n.compression=8,n})();var Ut=(function(){function n(r,t){var e=this;t<32e4?this.i=new K(function(i,a){e.ondata(null,i,a)}):(this.i=new Hn(function(i,a,o){e.ondata(i,a,o)}),this.terminate=this.i.terminate)}return n.prototype.push=function(r,t){this.i.terminate&&(r=$(r,0)),this.i.push(r,t)},n.compression=8,n})();var Ft=(function(){function n(r){this.onfile=r,this.k=[],this.o={0:ot},this.p=tr}return n.prototype.push=function(r,t){var e=this;if(this.onfile||c(5),this.p||c(4),this.c>0){var i=Math.min(this.c,r.length),a=r.subarray(0,i);if(this.c-=i,this.d?this.d.push(a,!this.c):this.k[0].push(a),r=r.subarray(i),r.length)return this.push(r,t)}else{var o=0,s=0,l=void 0,f=void 0;this.p.length?r.length?(f=new S(this.p.length+r.length),f.set(this.p),f.set(r,this.p.length)):f=this.p:f=r;for(var h=f.length,u=this.c,v=u&&this.d,M=function(){var x=O(f,s);if(x==67324752){o=1,l=s,m.d=null,m.c=0;var U=V(f,s+6),z=V(f,s+8),y=U&2048,B=U&8,E=V(f,s+26),F=V(f,s+28);if(h>s+30+E+F){var w=[];m.k.unshift(w),o=2;var g=O(f,s+18),q=O(f,s+22),D=Vn(f.subarray(s+30,s+=30+E),!y),G=Qn(f,s,F,2,g,q,0),H=G[0],P=G[1],d=G[3];B&&(H=-1-d),s+=F,m.c=H;var Z,C={name:D,compression:z,start:function(){if(C.ondata||c(5),!H)C.ondata(null,tr,!0);else{var L=e.o[z];L||C.ondata(c(14,"unknown compression type "+z,1),null,!1),Z=H<0?new L(D):new L(D,H,P),Z.ondata=function(b,W,R){C.ondata(b,W,R)};for(var k=0,ar=w;k<ar.length;k++){var J=ar[k];Z.push(J,!1)}e.k[0]==w&&e.c?e.d=Z:Z.push(tr,!0)}},terminate:function(){Z&&Z.terminate&&Z.terminate()}};H>=0&&(C.size=H,C.originalSize=P),m.onfile(C)}return"break"}else if(u){if(x==134695760)return l=s+=12+(u==-2&&8),o=3,m.c=0,"break";if(x==33639248)return l=s-=4,o=3,m.c=0,"break"}},m=this;s<h-4;++s){var A=M();if(A==="break")break}if(this.p=tr,u<0){var p=o?f.subarray(0,l-12-(u==-2&&8)-(O(f,l-16)==134695760&&4)):f.subarray(0,s);v?v.push(p,!!o):this.k[+(o==2)].push(p)}if(o&2)return this.push(f.subarray(s),t);this.p=f.subarray(s)}t&&(this.c&&c(13),this.p=null)},n.prototype.register=function(r){this.o[r.compression]=r},n})();var Yr=typeof queueMicrotask=="function"?queueMicrotask:typeof setTimeout=="function"?setTimeout:function(n){n()};function Ct(n,r,t){t||(t=r,r={}),typeof t!="function"&&c(7);var e=[],i=function(){for(var p=0;p<e.length;++p)e[p]()},a={},o=function(p,x){Yr(function(){t(p,x)})};Yr(function(){o=t});for(var s=n.length-22;O(n,s)!=101010256;--s)if(!s||n.length-s>65558)return o(c(13,0,1),null),i;var l=V(n,s+8);if(l){var f=l,h=O(n,s+16),u=O(n,s-20)==117853008;if(u){var v=O(n,s-12);u=O(n,v)==101075792,u&&(f=l=O(n,v+32),h=O(n,v+48))}for(var M=r&&r.filter,m=function(p){var x=Kn(n,h,u),U=x[0],z=x[1],y=x[2],B=x[3],E=x[4],F=x[5],w=Jn(n,F);h=E;var g=function(D,G){D?(i(),o(D,null)):(G&&(a[B]=G),--l||o(null,a))};if(!M||M({name:B,size:z,originalSize:y,compression:U}))if(!U)g(null,$(n,w,w+z));else if(U==8){var q=n.subarray(w,w+z);if(y<524288||z>.8*y)try{g(null,Gr(q,{out:new S(y)}))}catch(D){g(D,null)}else e.push(Ln(q,{size:y},g))}else g(c(14,"unknown compression type "+U,1),null);else g(null,null)},A=0;A<f;++A)m(A)}else o(null,{});return i}function Dt(n,r){for(var t={},e=n.length-22;O(n,e)!=101010256;--e)(!e||n.length-e>65558)&&c(13);var i=V(n,e+8);if(!i)return{};var a=O(n,e+16),o=O(n,e-20)==117853008;if(o){var s=O(n,e-12);o=O(n,s)==101075792,o&&(i=O(n,s+32),a=O(n,s+48))}for(var l=r&&r.filter,f=0;f<i;++f){var h=Kn(n,a,o),u=h[0],v=h[1],M=h[2],m=h[3],A=h[4],p=h[5],x=Jn(n,p);a=A,(!l||l({name:m,size:v,originalSize:M,compression:u}))&&(u?u==8?t[m]=Gr(n.subarray(x,x+v),{out:new S(M)}):c(14,"unknown compression type "+u):t[m]=$(n,x,x+v))}return t}export{ft as a,_ as b,rt as c,nt as d,Qr as e,K as f,Hn as g,Ln as h,Gr as i,wn as j,ht as k,ut as l,mn as m,nn as n,tt as o,et as p,tn as q,xn as r,lt as s,vt as t,zn as u,en as v,it as w,at as x,an as y,An as z,ct as A,pt as B,gt as C,yt as D,wt as E,fr as F,Vn as G,Vr as H,mt as I,xt as J,zt as K,At as L,Mt as M,ot as N,St as O,Ut as P,Ft as Q,Ct as R,Dt as S};
@@ -0,0 +1,2 @@
1
+ import { createRequire as __cr } from 'node:module'; const require = __cr(import.meta.url);
2
+ import{a as q}from"./chunk-ZUXLC5VX.js";import{C as c,D as S,F as T,G as b,I as j,d as l,i as E,k as f,l as u,n as a,o,p as h,s as C,w as x}from"./chunk-TXVNEV3M.js";import{x as w}from"./chunk-BALEFXOL.js";import{b as p}from"./chunk-5SBBTR3Y.js";import{e as R}from"./chunk-S4KF5Z3S.js";import{a as y,f as $}from"./chunk-WXOTXJNG.js";var P="name,operationtype,statecode,statuscode,message,friendlymessage,createdon,startedon,completedon",g=3,D=30,_=31,F=32,v={waiting:"statecode eq 0",suspended:"statecode eq 1",running:"statecode eq 2",succeeded:"statuscode eq 30",failed:"statuscode eq 31",canceled:"statuscode eq 32"};async function m(e,t,s){let n=await t.request("GET",`asyncoperations(${l(s)})`,{params:[["$select",P]],headers:{Prefer:`odata.include-annotations="${f}"`}});return A(h(n.json()))}function A(e){let t={id:o(e,"asyncoperationid"),name:o(e,"name"),operation:a(o(e,`operationtype${u}`),o(e,"operationtype")),state:a(o(e,`statecode${u}`),o(e,"statecode")),status:a(o(e,`statuscode${u}`),o(e,"statuscode")),statecode:o(e,"statecode"),statuscode:o(e,"statuscode"),message:a(o(e,"friendlymessage"),o(e,"message")),created:o(e,"createdon"),started:o(e,"startedon"),completed:o(e,"completedon")};return C(t)}async function B(e,t,s){return q(()=>m(e,t,s),n=>o(n,"statecode")===g,{timeout:e.timeout||3600,describe:n=>`job ${s}: ${r(o(n,"status"))}`,log:R})}function r(e){return e==null?"None":e===!0?"True":e===!1?"False":String(e)}function L(e,t=null){if(o(e,"statuscode")!==D){let s="status"in e?r(e.status):"failed";throw new y(`system job ${s.toLowerCase()}: ${r(a(o(e,"message"),"no message"))}`,{service:"dataverse",code:r(o(e,"statuscode")),...t!==null?{hint:t}:{}})}}async function z(e){let t=await c(e);await e.emit(await m(e,t,String(e.args.id)))}async function J(e){let t=await c(e),s=await B(e,t,String(e.args.id));await e.emit(s),L(s)}async function K(e){let t=e.args,s=await c(e),n=[];t.state&&n.push(v[String(t.state)]),t.name&&n.push(E("name",String(t.name))),typeof t.type=="number"&&n.push(`operationtype eq ${t.type}`),t.since&&n.push(`createdon ge ${w(String(t.since))}`);let i=[["$select",P],["$orderby","createdon desc"]];n.length&&i.push(["$filter",n.join(" and ")]),p(e,s,"GET","asyncoperations",null);let[d]=await j(e,s,"asyncoperations",i,b(`odata.include-annotations="${f}"`),x(t),"jobs");await e.emit(d.map(A))}async function Q(e){let t=await c(e),s=l(String(e.args.id)),n=`asyncoperations(${s})`,i=T({statecode:g,statuscode:F});p(e,t,"PATCH",n,i);let d=await t.lookups(()=>m(e,t,s));if(o(d,"statecode")===g)throw new $(`job ${s} has already finished (${r(o(d,"status"))})`,{service:"dataverse"});await S(e,t,"PATCH",n,{body:i,headers:{"If-Match":"*"}}),await e.emit(await m(e,t,s))}export{P as a,g as b,D as c,_ as d,F as e,v as f,m as g,A as h,B as i,L as j,z as k,J as l,K as m,Q as n};
@@ -0,0 +1,10 @@
1
+ import { createRequire as __cr } from 'node:module'; const require = __cr(import.meta.url);
2
+ import{b as p,i as m,j as c}from"./chunk-WXOTXJNG.js";var w=["json","ndjson","table","tsv"],g=60,b="\u2026";function R(n,r){for(let o of[n,process.env.PPDEVOPS_OUTPUT,r])if(o){if(!w.includes(o))throw new p(`unknown output format '${o}'`,{hint:`use one of: ${w.join(", ")}`});return o}return"json"}function l(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)}async function u(n){n&&(process.stdout.write(n)||await new Promise(r=>process.stdout.once("drain",r)))}async function h(n,r="json"){if(n===void 0&&(n=null),r==="json")await u(m(n,2)+`
3
+ `);else if(r==="ndjson"){let o=Array.isArray(n)?n:[n];await u(o.map(t=>c(t)+`
4
+ `).join(""))}else{let o=k(n);await u(r==="table"?P(o):S(o))}}async function E(n,r="json"){if(r==="ndjson"){let t=0;for await(let s of n)await u(c(s)+`
5
+ `),t++;return t}let o=[];for await(let t of n)o.push(t);return await h(o,r),o.length}function k(n){return l(n)&&Array.isArray(n.value)&&(n=n.value),l(n)?Object.entries(n).filter(([r])=>!r.startsWith("@odata.")).map(([r,o])=>({key:r,value:o})):Array.isArray(n)?n.map(r=>l(r)?r:{value:r}):[{value:n}]}function d(n){if(n==null)return"";let r;return typeof n=="object"?r=c(n,!1):typeof n=="boolean"?r=n?"True":"False":r=String(n),r.replace(/[\t\r\n]/g," ")}function j(n){let r=[];for(let o of n)for(let t of Object.keys(o))!r.includes(t)&&!t.startsWith("@odata.")&&r.push(t);return r}function f(n){let r=0;for(let o of n)r++;return r}function y(n,r){return n+" ".repeat(Math.max(0,r-f(n)))}function x(n){return f(n)<=g?n:[...n].slice(0,g-1).join("")+b}function P(n){if(!n.length)return"";let r=j(n),o=n.map(e=>r.map(i=>x(d(e[i])))),t=r.map((e,i)=>Math.max(f(e),...o.map(a=>f(a[i]??"")))),s=[r.map((e,i)=>y(e.toUpperCase(),t[i]??0)).join(" ").trimEnd()];for(let e of o)s.push(e.map((i,a)=>y(i,t[a]??0)).join(" ").trimEnd());return s.join(`
6
+ `)+`
7
+ `}function S(n){if(!n.length)return"";let r=j(n);return[r.join(" "),...n.map(t=>r.map(s=>d(t[s])).join(" "))].join(`
8
+ `)+`
9
+ `}var A=()=>"";function v(n){A=n}function O(n){process.env.PPDEVOPS_QUIET!=="1"&&process.stderr.write(A()+n+`
10
+ `)}export{R as a,h as b,E as c,v as d,O as e};
@@ -0,0 +1,5 @@
1
+ import { createRequire as __cr } from 'node:module'; const require = __cr(import.meta.url);
2
+ import{b as w}from"./chunk-TQLZ3TRU.js";import{e as R}from"./chunk-S4KF5Z3S.js";import{b as a}from"./chunk-WXOTXJNG.js";import{existsSync as M,readFileSync as W,realpathSync as Y,statSync as q}from"node:fs";import{basename as K,dirname as T,join as f,resolve as Q}from"node:path";var X=/^[a-z0-9][a-z0-9_-]*$/,A=["broker","browser","device_code","az_cli","spn","pat"],O=["read-only","read-write","full"],nn={"read-only":0,"read-write":1,full:2},I=["dataverse","devops"],wn={dv:"dataverse",dataverse:"dataverse",ado:"devops",devops:"devops"},h={dataverse:"Dataverse",devops:"DevOps"},z={dataverse:"PPDEVOPS_DATAVERSE",devops:"PPDEVOPS_DEVOPS"},N=".ppdo-cli.json",tn="config.toml",F=".ppdevops.toml",en="PPDEVOPS_CLIENT_SECRET",on="04b07795-8ddb-461a-bbee-02f9e1bf7b46",k=/^[A-Za-z0-9](?:[A-Za-z0-9-]{0,48}[A-Za-z0-9])?$/,rn=/^[A-Za-z_][A-Za-z0-9_]*$/;function yn(i,n){if(!X.test(i??""))throw new a(`invalid ${n} name '${i}'`,{hint:"use lowercase letters, digits, '-' and '_' (start with a letter or digit)"});return i}function g(i){return typeof i=="object"&&i!==null&&!Array.isArray(i)}function d(i,n){let t=i[n];return typeof t=="string"?t:null}var C=[["tenant","tenant"],["username","username"],["method","method"],["client_id","clientId"],["config_dir","configDir"],["secret_env","secretEnv"],["certificate","certificate"],["organization","organization"],["pat_env","patEnv"]],y=class i{name;tenant;username;method;clientId;configDir;secretEnv;certificate;organization;patEnv;ephemeral=!1;constructor(n,t){this.name=n,this.tenant=t.tenant,this.username=t.username??null,this.method=t.method,this.clientId=t.clientId??null,this.configDir=t.configDir??null,this.secretEnv=t.secretEnv??null,this.certificate=t.certificate??null,this.organization=t.organization??null,this.patEnv=t.patEnv??null}get effectiveClientId(){return this.clientId||on}account(){return JSON.stringify(C.map(([,n])=>this[n]))}toDict(){let n={};for(let[t,o]of C)this[o]!==null&&this[o]!==""&&(n[t]=this[o]);return n}static fromDict(n,t){return new i(n,{tenant:d(t,"tenant")??"",username:d(t,"username"),method:d(t,"method")??"browser",clientId:d(t,"client_id"),configDir:d(t,"config_dir"),secretEnv:d(t,"secret_env"),certificate:d(t,"certificate"),organization:d(t,"organization"),patEnv:d(t,"pat_env")})}clone(){let n=new i(this.name,this);return n.ephemeral=this.ephemeral,n}},$=class i{name;identity;mode;constructor(n,t=null,o="read-only"){this.name=n,this.identity=t,this.mode=o}clone(){return new i(this.name,this.identity,this.mode)}},m=class i{name;group;service;url;org;project;constructor(n,t,o,e={}){this.name=n,this.group=t,this.service=o,this.url=e.url??null,this.org=e.org??null,this.project=e.project??null}get endpoint(){return this.service==="dataverse"?this.url??"":[this.org,this.project].filter(n=>n).join("/")}spec(){return this.service==="dataverse"?{url:this.url}:{org:this.org,project:this.project}}toDict(){return{[this.service]:this.endpoint}}static fromDict(n,t,o){let e=d(o,"dataverse");if(e!==null)return new i(n,t,"dataverse",{url:e});let r=d(o,"devops");if(r!==null){let s=r.indexOf("/"),c=s<0?r:r.slice(0,s),l=s<0?"":r.slice(s+1);return new i(n,t,"devops",{org:c,project:l||null})}throw new a(`environment '${n}' in group '${t}' needs 'dataverse = "<url>"' or 'devops = "<org>/<project>"'`)}clone(){return new i(this.name,this.group,this.service,this)}};function x(i){return i?i instanceof Map?new Map(i):new Map(Object.entries(i)):new Map}function U(i){if(!g(i))return i;let n={};for(let[t,o]of Object.entries(i))o!=null&&(n[t]=U(o));return n}function V(i){let n;try{n=W(i)}catch(e){if(e.code==="ENOENT")return null;throw e}let t;try{t=new TextDecoder("utf-8",{fatal:!0}).decode(n)}catch{throw new a(`cannot read ${i}: not valid UTF-8`,{hint:"fix or delete the file"})}let o;try{o=JSON.parse(t)}catch(e){throw new a(`cannot read ${i}: ${e.message}`,{hint:"fix or delete the file"})}if(!g(o))throw new a(`cannot read ${i}: expected a JSON object`,{hint:"fix or delete the file"});return o}var L=new Set;function G(i,n){L.has(i)||(L.add(i),R(`ignored ${i}: ppdo-cli now reads ${K(i)===F?N:"config.json"}; ${n}`))}function S(i,n,t){let o=i[n];if(o==null)return{};if(!g(o))throw new a(`cannot read ${t}: '${n}' must be an object`,{hint:"fix or delete the file"});return o}var j=class i{identities;groups;environments;current;output;schema;path;constructor(n={}){this.identities=x(n.identities),this.groups=x(n.groups),this.environments=x(n.environments),this.current={...n.current??{}},this.output=n.output??null,this.schema=n.schema??null,this.path=n.path??null}static async load(n=w()){let t=V(n);if(t)return i.fromData(t,n);let o=f(T(n),tn);return D(o)&&G(o,"set up again with ppdo-cli identity add, group add and env add"),new i({path:n})}static fromData(n,t=null){let o=t??"the config",e=new Map,r=new Map;for(let[u,p]of Object.entries(S(n,"groups",o))){let b=g(p)?p:{};e.set(u,new $(u,d(b,"identity"),d(b,"mode")??"read-only"));for(let[v,P]of Object.entries(S(b,"environments",o))){if(r.has(v))throw new a(`environment '${v}' is in more than one group`,{hint:`fix ${o}`});r.set(v,m.fromDict(v,u,g(P)?P:{}))}}let s=new Map;for(let[u,p]of Object.entries(S(n,"identities",o)))s.set(u,y.fromDict(u,g(p)?p:{}));let c={};for(let u of I){let p=d(n,`current-${u}`);p&&(c[u]=p)}let l=new i({identities:s,groups:e,environments:r,current:c,output:d(n,"output"),schema:d(n,"$schema"),path:t});return l.checkFile(o),l}checkFile(n){let t={hint:`fix ${n}`};for(let e of this.identities.values())if(!A.includes(e.method))throw new a(`identity '${e.name}' has method '${e.method}'; use one of: ${A.join(", ")}`,t);for(let e of this.groups.values())if(!O.includes(e.mode))throw new a(`group '${e.name}' has mode '${e.mode}'; use one of: ${O.join(", ")}`,t);let o=new Map;for(let e of this.environments.values()){let r=`${e.service}
3
+ ${e.endpoint.toLowerCase()}`,s=o.get(r);if(s!==void 0)throw new a(`${e.endpoint} is both environment '${s}' and '${e.name}'`,{hint:`an environment belongs to one group, so it has one account and one mode; keep one of them in ${n}`});o.set(r,e.name)}this.checkPat(n)}checkPat(n){let t=n?`fix ${n}`:"a PAT identity is for one Azure DevOps organization: see ppdo-cli identity show <name>",o=n?`; fix ${n}`:"";for(let e of this.identities.values()){let r=`identity '${e.name}'`;if(e.method!=="pat"){if(e.organization!==null||e.patEnv!==null)throw new a(`${r}: 'organization' and 'pat_env' are for method 'pat' only`,{hint:t});continue}if(!e.organization||!k.test(e.organization))throw new a(`${r} (method 'pat') needs 'organization': an Azure DevOps organization name`,{hint:t});if(!e.username)throw new a(`${r} (method 'pat') needs 'username': the account the PAT belongs to`,{hint:t});if(e.clientId!==null||e.configDir!==null||e.secretEnv!==null||e.certificate!==null)throw new a(`${r}: 'client_id', 'config_dir', 'secret_env' and 'certificate' don't apply to method 'pat'`,{hint:t});if(e.patEnv!==null&&!rn.test(e.patEnv))throw new a(`${r}: 'pat_env' must be an environment variable name`,{hint:t})}for(let e of this.groups.values()){let r=e.identity?this.identities.get(e.identity):void 0;if(!r||r.method!=="pat")continue;let s=(r.organization??"").toLowerCase();for(let c of this.members(e.name)){if(c.service!=="devops")throw new a(`group '${e.name}' uses PAT identity '${r.name}', so it can't hold Dataverse environment '${c.name}'`,{hint:"a PAT reaches Azure DevOps only: put the environment in a group with another identity"+o});if(!c.org||!k.test(c.org)||c.org.toLowerCase()!==s)throw new a(`group '${e.name}' uses PAT identity '${r.name}' for organization '${r.organization}', so it can't hold '${c.name}' (${c.endpoint})`,{hint:"a PAT is for one organization: use another group and identity for this one"+o})}}}toDict(){let n={};for(let e of this.groups.values()){let r={identity:e.identity,mode:e.mode},s={};for(let c of this.members(e.name))s[c.name]=c.toDict();Object.keys(s).length&&(r.environments=s),n[e.name]=r}let t={};for(let[e,r]of this.identities)t[e]=r.toDict();let o={$schema:this.schema};for(let e of I)o[`current-${e}`]=this.current[e]??null;return o.output=this.output,o.identities=t,o.groups=n,o}async dumps(){let n=U(this.toDict());for(let t of["identities","groups"])g(n[t])&&!Object.keys(n[t]).length&&delete n[t];return JSON.stringify(n,null,2)+`
4
+ `}async save(){let{atomicWrite:n}=await import("./protect-X2J7LU7X.js");n(this.path??w(),await this.dumps())}static async edit(n){let{withFileLock:t}=await import("./protect-X2J7LU7X.js"),o=w();return t(o,async()=>{let e=await i.load(o),r=await n(e);return await e.save(),r})}clone(){let n=t=>new Map([...t].map(([o,e])=>[o,e.clone()]));return new i({identities:n(this.identities),groups:n(this.groups),environments:n(this.environments),current:this.current,output:this.output,schema:this.schema,path:this.path})}validate(){let n=new Map;for(let t of this.environments.values()){this.group(t.group);let o=`${t.service}
5
+ ${t.endpoint.toLowerCase()}`,e=n.get(o);if(e!==void 0)throw new a(`${t.endpoint} is already environment '${e}'`,{hint:`an environment belongs to one group; move it instead: ppdo-cli env move ${e} --to <group>`});n.set(o,t.name)}for(let t of this.groups.values())t.identity&&this.identity(t.identity);this.checkPat(null)}identity(n){let t=this.identities.get(n);if(!t)throw new a(`no identity named '${n}'`,{hint:"run: ppdo-cli identity list"});return t}group(n){let t=this.groups.get(n);if(!t)throw new a(`no group named '${n}'`,{hint:"run: ppdo-cli group list"});return t}environment(n){let t=this.environments.get(n);if(!t)throw new a(`no environment named '${n}'`,{hint:"run: ppdo-cli env list"});return t}members(n){return[...this.environments.values()].filter(t=>t.group===n)}};function _(i){let n=new Map;for(let t of i.environments.values()){let o=i.groups.get(t.group),e=o&&o.identity?i.identities.get(o.identity):void 0;if(!o||!e)continue;let r=JSON.stringify([t.service,t.endpoint.toLowerCase(),e.account()]),s=nn[o.mode]??0;s>=(n.get(r)?.[0]??-1)&&n.set(r,[s,t.name])}return n}function $n(i,n){let t=_(i),o=[];for(let[e,[r,s]]of _(n))if(r>(t.get(e)?.[0]??0)){let c=n.environment(s),l=n.group(c.group),u=n.identity(l.identity??""),p=l.mode==="full"?"write and delete":"write";o.push(`agents could ${p} in '${s}' (${c.endpoint}) as ${u.username||u.name} (group '${l.name}', ${l.mode})`)}return o}function J(i){let n=Q(i??process.cwd());try{return Y(n)}catch{return n}}function Z(i){let n=[i];for(let t=T(i);t!==n[n.length-1];t=T(t))n.push(t);return n}function D(i){try{return q(i).isFile()}catch{return!1}}async function sn(i){let n=Z(J(i)),t=n.findIndex(e=>M(f(e,".git"))),o=t>=0?n.slice(0,t+1):n.slice(0,1);for(let e of o){let r=f(e,N);if(!D(r)){let l=f(e,F);D(l)&&G(l,"pin again with ppdo-cli env pin <env>");continue}let s;try{s=V(r)}catch(l){throw l instanceof a?new a(l.message):l}if(!s)continue;let c={};for(let l of I){let u=s[l];typeof u=="string"&&u&&(c[l]=u)}if(!Object.keys(c).length)throw new a(`${r} names no environment`,{hint:'expected {"dataverse": "<env>"} and/or {"devops": "<env>"}; run: ppdo-cli env pin <env>'});return[c,r]}return null}function En(i){for(let n of Z(J(i)))if(M(f(n,".git")))return n;return null}var E=class{env;group;source;app;constructor(n,t,o,e=!1){this.env=n,this.group=t,this.source=o,this.app=e}get mode(){return this.group.mode}};function B(i){return!!i&&i.includes("://")}function an(i){return`run: ppdo-cli env list --service ${i==="devops"?"ado":"dv"}`}async function bn(i,n,t){let[o,e]=await H(i,n,t);if(B(o))throw new a(`'${o}' is a URL; a URL target needs --client-id and --tenant`,{hint:"or pass an environment name (see ppdo-cli env list)"});let r=i.environment(o);if(r.service!==n)throw new a(`environment '${o}' is a ${h[r.service]} environment, not ${h[n]}`,{hint:an(n)});return new E(r,i.group(r.group),e)}async function H(i,n,t){let o,e="",r=process.env[z[n]];if(t)[o,e]=[t,"flag"];else if(r)[o,e]=[r,`env ${z[n]}`];else{let s=await sn();s&&s[0][n]?[o,e]=[s[0][n],`file ${s[1]}`]:i.current[n]&&([o,e]=[i.current[n],`global current-${n}`])}if(!o)throw new a(`no ${h[n]} environment selected`,{hint:"pass --env <name>, or run: ppdo-cli env use <name> (see ppdo-cli env list)"});return[o,e]}var cn=[["clientId","--client-id"],["tenant","--tenant"],["certificate","--certificate"],["mode","--mode"]];function xn(i){let n=cn.filter(([t])=>i[t]);if(!n.length)return!1;if(!n.some(([t])=>t==="clientId")){let t=n.map(([,o])=>o).join(", ");throw new a(`${t} ${n.length===1?"applies":"apply"} only with --client-id`,{hint:"a configured environment's mode comes from its group (ppdo-cli group list)"})}if(!i.tenant)throw new a("--client-id needs --tenant <id|domain>");if(i.identity)throw new a("use --identity or --client-id, not both");return!0}function ln(i){let n=String(i.clientId).trim(),t=i.certificate?String(i.certificate):null,o=new y(`app:${n}`,{tenant:String(i.tenant).trim(),username:null,method:"spn",clientId:n,secretEnv:t?null:en,certificate:t});return o.ephemeral=!0,o}function un(i){if(!i.includes("://"))return null;let n;try{n=new URL(i.trim())}catch{throw new a(`'${i}' is not a dev.azure.com URL`)}let t=n.hostname.toLowerCase(),o=n.pathname.split("/").filter(c=>c).map(c=>decodeURIComponent(c)),e,r;if(t==="dev.azure.com"&&o.length)e=o[0]??"",r=o.slice(1);else if(t.endsWith(".visualstudio.com"))e=t.split(".")[0]??"",r=o,r[0]?.toLowerCase()==="defaultcollection"&&(r=r.slice(1));else throw new a(`'${i}' is not a dev.azure.com URL`);let s=r[0];return[e,s&&!s.startsWith("_")?s:null]}function dn(i,n){if(i==="dataverse"){let r=pn(n);return new m(r.slice(r.indexOf("://")+3),"app","dataverse",{url:r})}let t=un(n);if(!t)throw new a(`'${n}' is not a dev.azure.com URL`);let[o,e]=t;return new m([o,e].filter(r=>r).join("/"),"app","devops",{org:o,project:e})}async function Sn(i,n,t){let o=typeof t.env=="string"?t.env:null,[e,r]=await H(i,n,o),s;if(B(e))s=dn(n,e);else if(s=i.environment(e),s.service!==n)throw new a(`environment '${e}' is a ${h[s.service]} environment, not ${h[n]}`);let c=new $("app",null,typeof t.mode=="string"&&t.mode?t.mode:"read-only");return[new E(s,c,r,!0),ln(t)]}function Tn(i,n,t){if(t)return[i.identity(t),"flag"];let o=process.env.PPDEVOPS_IDENTITY;if(o)return[i.identity(o),"env PPDEVOPS_IDENTITY"];let e=n.group.identity;if(!e)throw new a(`group '${n.group.name}' has no identity`,{hint:`run: ppdo-cli group update ${n.group.name} --identity <name>`});return[i.identity(e),`group ${n.group.name}`]}function pn(i){let n=i.trim();n.includes("://")||(n="https://"+n);let t=null;try{t=new URL(n)}catch{t=null}if(!t||t.protocol!=="https:"||!t.hostname)throw new a(`invalid Dataverse URL '${n}'`,{hint:"use https://<org>.crm.dynamics.com"});return`https://${t.hostname.toLowerCase()}`}export{X as a,A as b,O as c,nn as d,I as e,wn as f,h as g,z as h,N as i,en as j,on as k,k as l,rn as m,yn as n,y as o,$ as p,m as q,V as r,j as s,_ as t,$n as u,sn as v,En as w,E as x,B as y,bn as z,xn as A,ln as B,un as C,dn as D,Sn as E,Tn as F,pn as G};
@@ -0,0 +1,2 @@
1
+ import { createRequire as __cr } from 'node:module'; const require = __cr(import.meta.url);
2
+ import{$ as z,T as q,X as R,Y as u,Z as V,aa as $,da as E,ea as M,ja as F,jb as G}from"./chunk-TZSB4PR7.js";import{a as _}from"./chunk-C42MGXRN.js";import{g as N}from"./chunk-ZNJ4DRCA.js";import{e as U,f as v,h as B,k as D,n as k}from"./chunk-WIA546AL.js";import{S as H}from"./chunk-QMTPHZLQ.js";import{readFileSync as Q}from"node:fs";var L="Unmanaged",b="Managed",w="Both",ee=new Map([["0",L],["1",b],["2",w],["unmanaged",L],["managed",b],["both",w]]),O=class{constructor(n,t){this.name=n;this.data=t}},ne=new TextDecoder("utf-8",{ignoreBOM:!0});function W(e){return e>=48&&e<=57||e>=65&&e<=70||e>=97&&e<=102}function te(e){let n=e.split("%");if(n.length===1)return e;let t=[],i=o=>{for(let r=0;r<o.length;r++)t.push(o.charCodeAt(r))};i(n[0]);for(let o of n.slice(1))o.length>=2&&W(o.charCodeAt(0))&&W(o.charCodeAt(1))?(t.push(parseInt(o.slice(0,2),16)),i(o.slice(2))):(t.push(37),i(o));return ne.decode(Uint8Array.from(t))}function S(e){if(!e.includes("%"))return e;let n=[],t=/[\x00-\x7f]+/g,i=0;for(let o=t.exec(e);o!==null;o=t.exec(e))n.push(e.slice(i,o.index)),n.push(te(o[0])),i=o.index+o[0].length;return n.push(e.slice(i)),n.join("")}function Z(e){return N(S(e)).replaceAll("\\","/").toUpperCase()}var A=class{doc;manifest;uniqueName;baseLocale;packageVersion;orgVersion;version;packageType;constructor(n){let t=n.root;if(!t.isNamed("ImportExportXml"))throw new u("solution.xml has no ImportExportXml root");let i=t.element("SolutionManifest");if(i===null)throw new u("solution.xml has no SolutionManifest");if(this.doc=n,this.manifest=i,this.uniqueName=i.element("UniqueName")!==null?F(i,"UniqueName"):null,!this.uniqueName)throw new u("the required element '/ImportExportXml/SolutionManifest/UniqueName' is missing from solution.xml");if(this.baseLocale=t.get("languagecode")??null,!this.baseLocale)throw new u("the required element '/ImportExportXml[@languagecode]' is missing from solution.xml");if(!t.get("generatedBy"))throw new u("the required element '/ImportExportXml[@generatedBy]' is missing from solution.xml");if(i.element("Publisher")===null)throw new u("the required element '/ImportExportXml/SolutionManifest/Publisher' is missing from solution.xml");this.packageVersion=K(t.get("SolutionPackageVersion")),this.orgVersion=K(t.get("version"));let o=i.element("Version");this.version=o!==null?o.value:null;let r=i.element("Managed");if(r===null)throw new u("solution.xml has no SolutionManifest/Managed");let a=ee.get(V(r.value).toLowerCase());if(a===void 0)throw new u(`unknown package type in solution.xml: ${z(r.value)}`);this.packageType=a}};function K(e){if(!e)return[];let n=[];for(let t of e.split(".")){let i=$(t);if(i===null)return[];n.push(i)}return n}var x=class{kind="unpack";plan;mapping;packageType;both;isManagedPackage;isManaged=!1;packageVersion=[];ignore;parts=new Map;registry;constructor(n,t,i,o=[],r=null){this.plan=n,this.mapping=r,this.packageType=t,this.both=t===w,this.isManagedPackage=i,this.ignore=[...o],this.registry=new G(this)}zipFile(n){return n==null?null:this.parts.get(Z(n))??null}zipFiles(){return this.parts.values()}mapped(n){return this.mapping===null||!this.mapping.maps(n)?!1:(this.plan.keepFile(n),!0)}};function j(e){let n=typeof e=="string"?Q(e):e,t=[],i=new Set,o;try{o=H(n,{filter:p=>{let l=p.name;if(l.endsWith("/")||l==="[Content_Types].xml")return!1;let f=l.startsWith("/")?l:"/"+l.replaceAll("\\","/"),y=S(f).toUpperCase();if(y!=="/SOLUTION.XML"&&y!=="/CUSTOMIZATIONS.XML"){let m=Z(f);if(i.has(m))return!1;i.add(m)}return t.push(l),!0}})}catch(p){let l=typeof e=="string"?e:"<bytes>";throw new u(`not a solution zip: ${l}`,{cause:p})}let r=null,a=null,g=new Map;for(let p of t){let l=o[p],f=p.startsWith("/")?p:"/"+p.replaceAll("\\","/"),y=S(f).toUpperCase();if(y==="/SOLUTION.XML")r=l;else if(y==="/CUSTOMIZATIONS.XML")a=l;else{let m=Z(f);g.has(m)||g.set(m,new O(S(f),l))}}if(r===null)throw new u("the solution zip has no /solution.xml");if(a===null)throw new u("the solution zip has no /customizations.xml");return[r,a,g]}function I(e,n){let[t,i,o]=j(n);e.parts=o;let r=new A(k(t));if(e.packageVersion=r.packageVersion,e.isManaged=r.packageType===b,!e.both&&r.packageType!==e.packageType)throw new u(`the solution is ${r.packageType.toLowerCase()}, not ${e.packageType.toLowerCase()}`);let a=k(i),g=a.root,p=new U(g.name,g.attrs.map(([s,c])=>[s,c]),null,{ns:g.ns,scope:g.scope}),l=[],f=e.registry;for(let s of B(g,void 0,!1)){let c=f.forElement(s),d=null;c!==null&&(d=c.createComponents(s),d.comps.length&&l.push(d));let h;c===null||c.ctype===q&&d!==null&&!d.comps.length?h=s.clone():h=new U(s.name,null,null,{ns:s.ns,scope:s.scope}),D(p,h)}let y=new v(p,a.standalone),m=e.plan,C=new Set(R.map(s=>s.toLowerCase()));for(let s of l){let c=f.forCollection(s);if(c!==null){s.elementName.toLowerCase()==="customcontrols"&&e.ignore.length&&(s.comps=s.comps.filter(d=>!e.ignore.some(h=>(d.name||"").includes(h))));for(let d of c.unshardedDirs())C.add(d.toLowerCase());(!(e.both&&e.isManaged)||c.differentInManaged)&&c.write(s)}}m.xml("Other/Customizations.xml",y);let Y=r.manifest;e.both&&Y.element("Managed").setValue("2");let P=M(r.doc.root.descendants("RootComponents"));P!==null&&P.replaceNodes(E(P.elements("RootComponent"),s=>s.get("type"),s=>s.get("schemaName"),s=>s.get("id")));let T=M(r.doc.root.descendants("MissingDependencies"));T!==null&&T.replaceNodes(E(T.elements("MissingDependency"),s=>X(s)?.get("type"),s=>X(s)?.get("schemaName"),s=>X(s)?.get("id.schemaname"))),m.xml("Other/Solution.xml",r.doc);let J=e.ignore.map(s=>s.toUpperCase());for(let[s,c]of e.parts){let d=s.indexOf("/",1);if(d>0&&!C.has(s.slice(0,d).toLowerCase())&&!J.some(h=>s.includes(h))){let h=N(c.name);e.mapped(h)||m.bytes(h,c.data)}}return r}function X(e){return M(e.descendants())}function oe(e){let n=e.lastIndexOf(".");if(n>0){for(let t=0;t<n;t++)if(e[t]!==".")return[e.slice(0,n),e.slice(n)]}return[e,""]}function se(e){let n=process.platform==="win32",t=C=>C==="/"||n&&C==="\\",i=n&&/^[A-Za-z]:/.test(e)?e.slice(0,2):"",o=e.slice(i.length),r=o.length;for(;r>0&&!t(o[r-1]);)r--;let a=o.slice(0,r),g=o.slice(r),p=a.length;for(;p>0&&t(a[p-1]);)p--;p>0&&(a=a.slice(0,p));let l=i+a,[f,y]=oe(g);if(f.endsWith("_managed"))throw new u("give the unmanaged zip when unpacking both; its managed twin is found beside it");let m=`${f}_managed${y}`;return l?t(l[l.length-1])||n&&l===i?l+m:l+(n?"\\":"/")+m:m}function ie(e){let[n]=j(e);return new A(k(n)).packageType}function fe(e,n=null,t={}){let i=[...t.ignore??[]],o=t.mapping??null,r=t.managedZip??null,a=new _;if(n===null&&(n=ie(e)),n===w){if(r===null){if(typeof e!="string")throw new u("unpacking both from bytes needs the managed zip too");r=se(e)}let p=I(new x(a,w,!1,i,o),e),l=I(new x(a,w,!0,i,o),r).packageType;if(p.packageType!==L||l!==b)throw new u("unpacking both needs the unmanaged zip and its _managed twin");return[a,p]}let g=I(new x(a,n,n===b,i,o),e);return[a,g]}export{L as a,b,w as c,O as d,S as e,Z as f,A as g,x as h,j as i,I as j,se as k,ie as l,fe as m};
@@ -0,0 +1,3 @@
1
+ import { createRequire as __cr } from 'node:module'; const require = __cr(import.meta.url);
2
+ import{a as e,b as n,c as o}from"./chunk-S4KF5Z3S.js";var i=class{args;sink;configPromise;formatPromise;constructor(r,t=null){this.args=r,this.sink=t}get verbose(){return!!this.args.verbose}get dryRun(){return!!this.args.dryRun}get timeout(){let r=this.args.timeout;return typeof r=="number"?r:void 0}config(){return this.configPromise??=import("./config-UKI5TBH5.js").then(({Config:r})=>r.load())}format(){return this.formatPromise??=this.resolveFormat()}async resolveFormat(){if(this.sink!==null)return"json";let r=this.args.output;return typeof r=="string"&&r?e(r):e(null,(await this.config()).output)}async emit(r){if(this.sink!==null){this.sink.push(r);return}await n(r,await this.format())}async emitStream(r){if(this.sink!==null){let t=[];for await(let s of r)t.push(s);return this.sink.push(t),t.length}return o(r,await this.format())}log(r){this.verbose&&process.stderr.write(r+`
3
+ `)}async client(r){let{clientFor:t}=await import("./services-4BORTJPM.js");return t(this,r)}};export{i as a};
@@ -0,0 +1,2 @@
1
+ import { createRequire as __cr } from 'node:module'; const require = __cr(import.meta.url);
2
+ import{homedir as t}from"node:os";import{join as r}from"node:path";var s="ppdo-cli";function i(){let o=process.env.PPDEVOPS_CONFIG_DIR;if(o)return o;if(process.platform==="win32"){let e=process.env.APPDATA;if(e)return r(e,s)}let n=process.env.XDG_CONFIG_HOME;return r(n||r(t(),".config"),s)}function p(){let o=process.env.PPDEVOPS_STATE_DIR;if(o)return o;if(process.platform==="win32"){let e=process.env.LOCALAPPDATA;if(e)return r(e,s)}let n=process.env.XDG_STATE_HOME;return r(n||r(t(),".local","state"),s)}function u(){return r(i(),"config.json")}export{p as a,u as b};
@@ -0,0 +1,3 @@
1
+ import { createRequire as __cr } from 'node:module'; const require = __cr(import.meta.url);
2
+ import{a as q}from"./chunk-UCTMKA2J.js";import{b as B,e as S,i as C,y as P}from"./chunk-BALEFXOL.js";import{a as L}from"./chunk-J4R6QXW7.js";import{b as O,c as E}from"./chunk-5SBBTR3Y.js";import{e as j}from"./chunk-S4KF5Z3S.js";import{b as d,g as k}from"./chunk-WXOTXJNG.js";var G=/^[A-Za-z_][A-Za-z0-9_]{0,127}\n?$/,K=/^[A-Za-z_][A-Za-z0-9_.]{0,255}\n?$/,J=/^\{?[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}\}?\n?$/,M=/^-?\d+(\.\d+)?\n?$/;function b(n,e="name",t=!1){if(!(t?K:G).test(n||""))throw new d(`invalid ${e} '${n??"None"}'`,{hint:"use the logical/entity set name: letters, digits, '_'"});return n}function x(n){return J.test(n)}function I(n,e){let t=0,r=n.length;for(;t<r&&e.includes(n[t]);)t++;for(;r>t&&e.includes(n[r-1]);)r--;return n.slice(t,r)}function R(n){return I(n,"{}").toLowerCase()}function w(n){return"'"+n.split("'").join("''")+"'"}function Z(n,e){return e?n:x(n)?R(n):w(n)}function g(n){return I(n,`
3
+ \r\v\f`)}function V(n){if(n=g(n),x(n))return`(${R(n)})`;let e=[];for(let t of Q(n)){let r=!1,s,o,u=t.indexOf(":="),i=t.indexOf("=");if(u>=0)s=t.slice(0,u),o=t.slice(u+2),r=!0;else if(i>=0)s=t.slice(0,i),o=t.slice(i+1);else throw new d(`invalid key '${n}'`,{hint:"use a GUID, name=value, or name:=123 for numbers"});if(b(g(s),"key attribute"),r&&!M.test(g(o))&&!x(g(o)))throw new d(`'${s}:=${o}' must be a number or GUID`,{hint:`use ${s}=${o} for text`});e.push(`${g(s)}=${Z(r?g(o):o,r)}`)}return"("+e.join(",")+")"}var W=/^\s*[A-Za-z_][A-Za-z0-9_]*\s*:?=/;function Q(n){let e=[],t="";for(let r of n.split(","))t&&W.test(r)?(e.push(t),t=r):t=t?`${t},${r}`:r;return t&&e.push(t),e}function cn(n,e){return b(n,"entity set name"),n+L(V(e),"(),'=:")}function X(n,e=!1){if(e)return w(n);let t=g(n);if(t.slice(0,1)===""||"[{".includes(t.slice(0,1)))try{return JSON.parse(t),t}catch{}return t==="true"||t==="false"||t==="null"||M.test(t)?t:x(t)?R(t):t.startsWith("Microsoft.Dynamics.CRM.")&&t.includes("'")?t:w(n)}function fn(n,e,t=new Set){if(b(n,"function name",!0),!e.length)return[`${n}()`,[]];let r=[],s=[];return e.forEach(([o,u],i)=>{b(o,"parameter name"),r.push(`${o}=@p${i+1}`),s.push([`@p${i+1}`,X(u,t.has(o))])}),[`${n}(${r.join(",")})`,s]}function pn(n,e){for(let l of n.split("/"))b(l,"column name");let t=g(e);if(!t.includes("*"))return`${n} eq ${w(t)}`;let r=t.split("*"),s=r[0],o=r[r.length-1],u=r.slice(1,-1).filter(l=>l),i=[];s&&i.push(`startswith(${n},${w(s)})`),o&&i.push(`endswith(${n},${w(o)})`);for(let l of u)i.push(`contains(${n},${w(l)})`);return i.join(" and ")||`${n} ne null`}var A=100,_=5e3,xn="OData.Community.Display.V1.FormattedValue",bn="@OData.Community.Display.V1.FormattedValue";function $(n){return n==null||n===!1||n===0||n===""||Number.isNaN(n)?!1:Array.isArray(n)?n.length>0:n instanceof Map||n instanceof Set?n.size>0:typeof n=="object"?Object.keys(n).length>0:!0}function Rn(n,e){return $(n)?n:e}function v(n,e){if(typeof n!="object"||n===null||Array.isArray(n))return null;let t=n[e];return t===void 0?null:t}function F(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)&&$(n)?n:{}}function H(n){return Array.isArray(n)?n:[]}function $n(n){let e={};for(let[t,r]of Object.entries(n))r!=null&&(e[t]=r);return e}function An(n){let e={};for(let[t,r]of Object.entries(n))r!=null&&r!==""&&(e[t]=r);return e}function z(n,e){if(Array.isArray(n)&&Array.isArray(e)){for(let s=0;s<Math.min(n.length,e.length);s++){let o=z(n[s],e[s]);if(o)return o}return n.length-e.length}if(typeof n=="string"&&typeof e=="string"){let s=[...n],o=[...e];for(let u=0;u<Math.min(s.length,o.length);u++){let i=s[u].codePointAt(0)-o[u].codePointAt(0);if(i)return i}return s.length-o.length}let t=Number(n),r=Number(e);return t<r?-1:t>r?1:0}function nn(n,e,t=!1){let r=[...n];return r.sort((s,o)=>(t?-1:1)*z(e(s),e(o))),r}function Tn(n){return[...new Set(n)]}function Sn(n){return n.addOption(new S("--limit <n>",`return at most n rows (default ${A})`).argParser(C)).option("--all","return every row (no cap)")}function jn(n){if(n.all)return null;let e=n.limit;return typeof e=="number"&&e>0?e:A}var D={sync:"CustomSync",async:"CustomAsync",all:"CustomSync,CustomAsync"};function tn(n,e,t){let r=new S(n,e);return r.argParser(en(t)),r}function en(n){return e=>{if(!n.includes(e))throw new B(`invalid choice: '${e}' (choose from ${n.join(", ")})`);return e}}function On(n){return n.addOption(tn("--bypass-plugins <sync|async|all>","skip custom synchronous and/or asynchronous logic (plugins, classic workflows; not cloud flows); needs a full-mode group",Object.keys(D))).option("--bypass-step <step-id>[,...]","skip only these plugin steps")}function kn(n,e=!1,t="request body: @file.json, - for stdin, or inline JSON"){return e?n.requiredOption("--body <@file|-|json>",t):n.option("--body <@file|-|json>",t)}function Bn(n,e,t=!1,r=null){let s=r?{hint:`run: ppdo-cli ${r} --help`}:{},o=Object.keys(e).filter(u=>n[u]!==void 0&&n[u]!==!1&&n[u]!==null);if(o.length>1)throw new d(`argument ${e[o[1]]}: not allowed with argument ${e[o[0]]}`,s);if(t&&!o.length)throw new d(`one of the arguments ${Object.values(e).join(" ")} is required`,s)}function Cn(n){return n.client("dataverse")}function Pn(n,e,t,r,s={}){return O(n,e,t,r,s.body??null,s.cls??null),e.request(t,r,{params:s.params??null,headers:s.headers??null,body:s.body??null,saveTo:s.saveTo??null,check:s.check??!0})}function rn(n){return F(n.json())}function En(n){return Buffer.from(JSON.stringify(n),"utf8")}function Ln(...n){let e=n.filter(t=>!!t);return e.length?{Prefer:e.join(", ")}:{}}async function*on(n,e,t=null,r=null){let{nextLink:s}=await import("./service-RFKOKM72.js"),o=await n.request("GET",e,{params:t,headers:r});for(;;){yield o;let u=s(o);if(!u)return;o=await n.request("GET",u,{headers:r})}}async function N(n,e,t,r=null,s=null,o=A,u="rows"){let i=[],l={},a=!1,f=o?Math.min(_,o+1):_,m={...s??{}},h=m.Prefer;(h??"").includes("maxpagesize")||(m.Prefer=[h,`odata.maxpagesize=${f}`].filter(c=>c).join(", "));for await(let c of on(e,t,r,m)){let p=rn(c);if(!$(l)){l={};for(let[y,T]of Object.entries(p))y!=="value"&&(l[y]=T)}for(let y of H(p.value)){if(o!==null&&i.length>=o){a=!0;break}i.push(y)}if(a)break;if(o!==null&&i.length>=o){a="@odata.nextLink"in p;break}}return a&&j(`showing the first ${o} ${u}; pass --limit n or --all for more`),[i,l]}async function qn(n,e,t,r,s,o,u=null,i=A,l="rows",a=null){if(s===null)return(await N(n,e,t,o,u,i,l))[0];let f=[],m=o.find(([c])=>c==="$filter")?.[1]??null,h=o.filter(([c])=>c!=="$filter"&&c!=="$orderby");for(let c=0;c<s.length;c+=50){let p="("+s.slice(c,c+50).map(y=>`${r} eq ${y}`).join(" or ")+")";m&&(p+=` and (${m})`),f=f.concat((await N(n,e,t,[...h,["$filter",p]],u,null,l))[0])}return a&&(f=nn(f,a)),i!==null&&f.length>i&&(j(`showing the first ${i} ${l}; pass --limit n or --all for more`),f=f.slice(0,i)),f}function Mn(n){let e=n.header("odata-entityid")||"",t=/\(([0-9a-fA-F-]{36})\)\s*$/.exec(e);return t?t[1]:null}function In(n){if(typeof n=="object"&&n!==null&&!Array.isArray(n)){let e=F(n.UserLocalizedLabel);if($(e.Label))return e.Label;for(let t of H(n.LocalizedLabels))if($(v(t,"Label")))return t.Label}return null}function _n(n,e){let t=n.args,r={},s=t.bypassPlugins;typeof s=="string"&&s&&(r["MSCRM.BypassBusinessLogicExecution"]=D[s]);let o=t.bypassStep;if(typeof o=="string"&&o){let i=o.split(",").map(a=>g(a)).filter(a=>a),l=i.filter(a=>!x(a));if(l.length)throw new d(`--bypass-step takes plugin step ids, got '${l[0]}'`);r["MSCRM.BypassBusinessLogicExecutionStepIds"]=i.map(a=>R(a)).join(",")}let u=e.target;if(Object.keys(r).length&&u.mode!=="full")throw new k(`blocked: skipping plugins needs mode 'full'; mode is '${u.mode}'`,{service:"dataverse",hint:E(u)});return r}async function Nn(n,e=!1){if(n==null){if(e)throw new d("--body is required");return null}let t=P(String(n));try{q(un(t.toString("utf8")))}catch(r){throw new d(`--body is not valid JSON: ${r.message}`,{hint:"pass a file with --body @file.json"})}return t}var sn="\uFEFF";function un(n){return n.startsWith(sn)?n.slice(1):n}function Un(n){return typeof n=="string"?n:null}var U=1e3;async function*Fn(n,e,t,r,s){let o=await import("./batch-EZPKLWEI.js"),u=e.service.origin;for(let i=0;i<t.length;i+=U){let l=t.slice(i,i+U),[a,f,m]=o.build(l,u,r),h=Buffer.from(f,"utf8");O(n,e,"POST","$batch",h);let c={"Content-Type":`multipart/mixed; boundary=${a}`};s&&(c.Prefer="odata.continue-on-error");let p=await e.request("POST","$batch",{headers:c,body:h,check:!1});if(p.status>=400&&!(p.header("content-type")||"").includes("multipart"))throw e.service.error(p);let y=/boundary=([^\s;]+)/.exec(p.header("content-type")||""),T=y?o.parse(p.text,y[1]):[];yield[i,l,o.distribute(m,T,l.length)]}}export{b as a,x as b,I as c,R as d,w as e,g as f,cn as g,fn as h,pn as i,_ as j,xn as k,bn as l,$ as m,Rn as n,v as o,F as p,H as q,$n as r,An as s,nn as t,Tn as u,Sn as v,jn as w,tn as x,en as y,On as z,kn as A,Bn as B,Cn as C,Pn as D,rn as E,En as F,Ln as G,on as H,N as I,qn as J,Mn as K,In as L,_n as M,Nn as N,un as O,Un as P,Fn as Q};
@@ -0,0 +1,4 @@
1
+ import { createRequire as __cr } from 'node:module'; const require = __cr(import.meta.url);
2
+ import{a as Ae,b as m,c as E,d as N,e as z,f as M,g as I}from"./chunk-ZNJ4DRCA.js";import{a as gt,e as p,h as F,i as ht,j as q,k as w,l as xt,o as Ie}from"./chunk-WIA546AL.js";var vt=`
3
+ \v\f\r _-,;:!?.'"()[]{}@*/\\&#%\`^+<=>|~$`,L=new Map;for(let i=0;i<vt.length;i++)L.set(vt[i],i+1);for(let i=0;i<10;i++)L.set(String(i),100+i);for(let i=0;i<26;i++){let e=String.fromCharCode(97+i);L.set(e,200+i),L.set(e.toUpperCase(),200+i)}function Ot(i){return i!==i.toLowerCase()&&i===i.toUpperCase()}function Fe(i){let e=[],t=[];for(let n of i){let r=L.get(n);if(r===void 0){let l=n.toLowerCase();r=l?1e3+l.codePointAt(0):1e3}e.push(r),t.push(Ot(n)?1:0)}return{prim:e,tert:t}}function G(i,e){let t=Math.min(i.length,e.length);for(let n=0;n<t;n++)if(i[n]!==e[n])return i[n]<e[n]?-1:1;return i.length-e.length}function yt(i,e){let t=i==null,n=e==null;if(t||n)return t===n?0:t?-1:1;let r=Fe(i),l=Fe(e);return G(r.prim,l.prim)||G(r.tert,l.tert)}function Me(i,e){let t=[...i].map(n=>{let r=e(n);return{item:n,k:r==null?null:Fe(r)}});return t.sort((n,r)=>n.k===null||r.k===null?n.k===r.k?0:n.k===null?-1:1:G(n.k.prim,r.k.prim)||G(n.k.tert,r.k.tert)),t.map(n=>n.item)}var j=1,K=9,T=10,H=20,R=29,Z=31,U=36,Q=46,J=50,ee=60,te=61,ne=62,ie=63,re=64,oe=66,le=70,k=80,B=81,_=91,se=92,ae=95,ce=161,st=169,at=172,de=181,me=183,X=200,ue=201,fe=202,pe=209,ge=210,he=211,ct=300,dt=371,xe=380,mt=400,ut=401,ft=431,pt=432,ve=511,ye=660,Pe=41,Ee=25,Ce=101,Ne=80001,we=99999,Dt=new Map([[j,"Entity"],[K,"OptionSet"],[T,"EntityRelationship"],[H,"Role"],[R,"Workflow"],[Z,"Report"],[U,"Template"],[Q,"EntityMap"],[J,"RibbonCustomization"],[ee,"Dashboard"],[te,"WebResource"],[ne,"SiteMap"],[ie,"ConnectionRole"],[re,"ComplexControl"],[oe,"CustomControl"],[le,"FieldSecurityProfile"],[k,"AppModule"],[B,"AppModuleSiteMap"],[_,"PluginAssembly"],[se,"SdkMessageProcessingStep"],[ae,"ServiceEndpoint"],[ce,"MobileOfflineProfile"],[st,"ProfileRule"],[at,"ChannelAccessProfile"],[de,"EntityDataProvider"],[me,"EntityDataSource"],[X,"EntityPrivilege"],[ue,"SdkMessage"],[fe,"SdkMessageFilter"],[pe,"StoredProcedure"],[ge,"WebWizard"],[he,"Dialogs"],[ct,"CanvasApp"],[dt,"Connector"],[xe,"EnvironmentVariableDefinition"],[mt,"AITemplate"],[ut,"AIModel"],[ft,"AttributeImageConfiguration"],[pt,"EntityImageConfiguration"],[ve,"TeamTemplate"],[ye,"InteractionCentricDashboard"],[Pe,"SyncAttributeMappingProfile"],[Ee,"OrganizationSettings"],[Ce,"ServicePlans"],[Ne,"ServicePlanAppModules"],[we,"GenericComponent"]]),It=new Map([[j,["Entities","$(PrimaryName)/Entity.xml"]],[K,["OptionSets","$(PrimaryName)"]],[T,["Other","Relationships.xml"]],[ne,["Other","$(type)$(managed).xml"]],[J,["Other","$(type).xml"]],[H,["Roles","$(PrimaryName)"]],[ie,["Other","$(type)s.xml"]],[ee,["Dashboards","$(PrimaryName)"]],[le,["Other","$(type)s.xml"]],[te,["WebResources","$(PrimaryName)"]],[R,["Workflows","Workflows.xml"]],[_,["PluginAssemblies","PluginAssemblies.xml"]],[se,["SdkMessageProcessingSteps","$(PrimaryName)"]],[ae,["PluginAssemblies","$(type)s.xml"]],[Z,["Reports","$(type)"]],[U,["Templates","$(PrimaryName).xml"]],[Q,["Other","$(type)s.xml"]],[st,["ChannelAccess","ProfileRules/$(PrimaryName)"]],[at,["ChannelAccess","Profiles/$(PrimaryName)"]],[ue,["SdkMessages","$(PrimaryName)"]],[re,["ComplexControls","$(PrimaryName).xml"]],[he,["Dialogs","$(PrimaryName).xml"]],[pe,["StoredProcedures","$(type)"]],[k,["AppModules","$(PrimaryName)/AppModule$(managed).xml"]],[B,["AppModuleSiteMaps","$(PrimaryName)/AppModuleSiteMap$(managed).xml"]],[X,["EntityPrivileges","$(type)"]],[ge,["WebWizards","$(PrimaryName).xml"]],[fe,["Maps","$(PrimaryName).xml"]],[de,["EntityDataProviders","$(PrimaryName).xml"]],[me,["EntityDataSources","$(PrimaryName).xml"]],[ye,["InteractionCentricDashboards","$(PrimaryName)"]],[ve,["TeamTemplates","$(PrimaryName)"]],[Pe,["SyncAttributeMappingProfiles","$(PrimaryName)"]],[ce,["MobileOfflineProfiles","$(PrimaryName)"]],[oe,["Controls","$(PrimaryName)"]],[xe,["EnvironmentVariables","$(PrimaryName).xml"]],[dt,["$(ComponentsRootName)","$(PrimaryName).xml"]],[Ee,["OrganizationSettings","_legacy/$(PrimaryName).meta.xml"]],[ct,["CanvasApps","$(PrimaryName).meta.xml"]],[ut,["aimodels","$(PrimaryName)/aimodel.yml"]],[mt,["aitemplates","$(PrimaryName)/aitemplate.yml"]],[pt,["entityimageconfigs","$(PrimaryName)/entityimageconfiguration.yml"]],[ft,["attributeimageconfigs","$(PrimaryName)/attributeimageconfiguration.yml"]],[Ce,["ServicePlans","ServicePlans.xml"]],[Ne,["ServicePlans","ServicePlanAppModules.xml"]],[we,["$(ComponentsRootName)","$(PrimaryName).meta.xml"]]]);function Te(i){let e=It.get(i);if(e===void 0)throw new Error(`no layout for component type ${i}`);return e}function Pt(i){let e=Dt.get(i);if(e===void 0)throw new Error(`no type name for component type ${i}`);return e}var jt=new Set([...It.values()].map(([i])=>i)),Nn=["Other","Resources","bin","obj","solutions","publishers","entityrelationships","modernflows"],Et=/\$\(.+?\)/g,C=class extends Error{},ke=new Set([9,10,11,12,13,28,29,30,31,32,133,160,5760,8192,8193,8194,8195,8196,8197,8198,8199,8200,8201,8202,8232,8233,8239,8287,12288]);function S(i){let e=0,t=i.length;for(;e<t&&ke.has(i.charCodeAt(e));)e++;for(;t>e&&ke.has(i.charCodeAt(t-1));)t--;return i.slice(e,t)}function Ut(i,e){let t=0,n=i.length;for(;t<n&&e.includes(i[t]);)t++;for(;n>t&&e.includes(i[n-1]);)n--;return i.slice(t,n)}function A(i){return i==null?"None":String(i)}var Bt=/^[\p{C}\p{Z}]$/u;function Y(i,e){return i.toString(16).padStart(e,"0")}function Ft(i){let e=i.includes("'")&&!i.includes('"')?'"':"'",t=e;for(let n of i){let r=n.codePointAt(0);n===e||n==="\\"?t+="\\"+n:n===" "?t+="\\t":n===`
4
+ `?t+="\\n":n==="\r"?t+="\\r":r<32||r===127?t+="\\x"+Y(r,2):r<127?t+=n:Bt.test(n)?r<=255?t+="\\x"+Y(r,2):r<=65535?t+="\\u"+Y(r,4):t+="\\U"+Y(r,8):t+=n}return t+e}var Ct=new RegExp("^\\p{Nd}$","u");function Mt(i){let e="";for(let t of i){let n=t.codePointAt(0);if(n<128)e+=t;else if(ke.has(n))e+=" ";else if(Ct.test(t)){let r=n;for(;Ct.test(String.fromCodePoint(r-1));)r--;e+=String((n-r)%10)}else e+="?"}return e.replace(/^[ \t\n\v\f\r]+/,"").replace(/[ \t\n\v\f\r]+$/,"")}function Tt(i){let e=Mt(i);return/^[+-]?[0-9]+(?:_[0-9]+)*$/.test(e)?Number(e.replaceAll("_","")):null}function _t(i,e){let t=Math.min(i.length,e.length);for(let n=0;n<t;n++)if(i[n]!==e[n])return i[n]<e[n]?-1:1;return i.length-e.length}function Nt(i,e){let t=0,n=0;for(;t<i.length&&n<e.length;){let r=i.codePointAt(t),l=e.codePointAt(n);if(r!==l)return r<l?-1:1;t+=r>65535?2:1,n+=l>65535?2:1}return(t<i.length?1:0)-(n<e.length?1:0)}function Xt(i,...e){return[...i].sort((t,n)=>{for(let r of e){let l=yt(r(t),r(n));if(l!==0)return l}return 0})}function Vt(i){for(let e of i)return e;return null}function Wt(i){let e=i.replaceAll("urn:","").replaceAll("uuid:","");if(e=Ut(e,"{}").replaceAll("-",""),[...e].length!==32)return null;let t=Mt(e),n=!1;(t[0]==="+"||t[0]==="-")&&(n=t[0]==="-",t=t.slice(1));let r=!1;if(/^0[xX]/.test(t)&&(t=t.slice(2),r=!0),!(r?/^_?[0-9a-fA-F]+(?:_[0-9a-fA-F]+)*$/:/^[0-9a-fA-F]+(?:_[0-9a-fA-F]+)*$/).test(t))return null;let o=BigInt("0x"+t.replaceAll("_",""));return n&&(o=-o),o<0n||o>=1n<<128n?null:o}function v(i){if(i==null)return null;let e=Wt(S(i));if(e===null)throw new C(`not a GUID: ${Ft(i)}`);let t=e.toString(16).padStart(32,"0");return`${t.slice(0,8)}-${t.slice(8,12)}-${t.slice(12,16)}-${t.slice(16,20)}-${t.slice(20)}`}var kt=new Int8Array(128).fill(-1);{let i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(let e=0;e<i.length;e++)kt[i.charCodeAt(e)]=e}function zt(i){for(let l=0;l<i.length;l++)if(i.charCodeAt(l)>127)throw new Error("string argument should contain only ASCII characters");let e=[],t=0,n=0,r=0;for(let l=0;l<i.length;l++){let o=i.charCodeAt(l);if(o===61){if(t>=2&&t+ ++r>=4)return Uint8Array.from(e);continue}let s=kt[o];if(!(s<0))switch(r=0,t){case 0:t=1,n=s;break;case 1:t=2,e.push((n<<2|s>>4)&255),n=s&15;break;case 2:t=3,e.push((n<<4|s>>2)&255),n=s&3;break;default:t=0,e.push((n<<6|s)&255),n=0;break}}if(t!==0)throw t===1?new Error(`Invalid base64-encoded string: number of data characters (${Math.floor(e.length/3)*4+1}) cannot be 1 more than a multiple of 4`):new Error("Incorrect padding");return Uint8Array.from(e)}function qt(i){return Buffer.from(i.buffer,i.byteOffset,i.byteLength).toString("base64")}function Gt(i){return"{"+(i||"00000000-0000-0000-0000-000000000000")+"}"}function Rt(i,e){if(i==null||!e)return null;let t=i.element(e);return t===null&&(t=i.element(e.toLowerCase())),t}function d(i,e,t=!1,n=null){let r=Rt(i,e);if(r===null){if(t)throw new C(`cannot find child element ${e} of element ${i.name}`);return n}return r.value}function f(i,e,t=!1,n=null){let r=i.get(e);if(r===void 0){if(t)throw new C(`cannot find attribute ${e} of element ${i.name}`);return n}return r}function V(i){let e=i.get("unmodified");return e!==void 0&&(e.toLowerCase()==="true"||e==="1")}var g=class{type;name;id;el;fileName;diskFileName;sourceType;constructor(e,t,n={}){this.type=e,this.el=t,this.name=n.name??null,this.id=n.id??null,this.fileName=n.fileName??null,this.sourceType=n.sourceType??null;let r=n.diskFileName??null;r===null&&this.fileName!==null&&(r=I(this.fileName.replaceAll("\\","/"))),this.diskFileName=r}},Re=class{constructor(e,t,n){this.type=e;this.el=t;this.comps=n}get elementName(){return this.el.local}},x=class{constructor(e){this.ctx=e}element="";ctype=we;single=!1;individual=!1;fileBacked=!1;collection=!1;differentInManaged=!1;newFormatOnly=!1;parentTag=null;childTag=null;get uctx(){if(this.ctx.kind!=="unpack")throw new Error("an unpack step ran with a pack context");return this.ctx}get pctx(){if(this.ctx.kind!=="pack")throw new Error("a pack step ran with an unpack context");return this.ctx}createComponents(e){let t=[];if(this.single){let n=this.create(e);n!==null&&t.push(n)}else for(let n of this.componentElements(e)){let r=this.create(n);r!==null&&t.push(r),this.ctype===R&&e.element("Workflow")!==null&&d(n,"ImageFileName")&&t.push(this.createImage(n))}return t=Me(t,n=>n.name),new Re(this.ctype,e,t)}componentElements(e){return F(e)}create(e){throw new Error("not implemented")}createImage(e){throw new Error("not implemented")}unshardedDirs(){return new Set([Te(this.ctype)[0]])}needManagedName(e){return!1}path(e,t,n=null,r=null){r===null&&(r=this.ctx.isManaged);let[l,o]=Te(e),s=Ae(t),a=c=>c==="$(ComponentsRootName)"?n!==null?n:c:c==="$(PrimaryName)"?s??c:c==="$(type)"?Pt(e):c==="$(managed)"?r?"_managed":"":c;return m(l.replace(Et,a),o.replace(Et,a))}write(e){let t=this.uctx;if(!e.comps.length||t.both&&t.isManaged&&!this.differentInManaged)return;let n=t.plan;if(this.individual)for(let r of e.comps)n.xml(this.path(r.type,r.name),r.el);else if(this.fileBacked)for(let r of e.comps)this.writeFile(r);else if(this.collection)for(let r of e.comps)n.xml(this.path(e.type,r.name!==null?r.name:Gt(r.id)),r.el);else n.xml(this.path(e.type,null),e.el)}writeFile(e){if(!e.fileName||!S(e.fileName))return;let t=this.uctx,n=t.plan;e.name!=="EntityImages"&&n.xml(e.diskFileName+".data.xml",e.el);let r=t.zipFile(e.fileName);r!==null&&!t.mapped(e.diskFileName)&&n.bytes(e.diskFileName,r.data)}writeFolder(e,t,n){let r=this.uctx,l=r.plan;for(let o of F(t)){let s=Rt(o,n);if(s===null)continue;let a=m(e,s.value);if(r.isManagedPackage&&this.differentInManaged&&this.needManagedName(t))a+="_managed";else if(r.both&&r.isManaged)continue;if(S(z(a))||(a=M(a,".xml")),this.parentTag&&this.childTag)this.writeLcidMerged(a,o);else if(o.local==="privilegeobjecttypecodes"){let c=new p("privilegeobjecttypecodeslists"),u=l.readXml(a);if(u!==null&&u.isNamed("privilegeobjecttypecodeslists"))for(let h of u.elements("privilegeobjecttypecodes"))c.append(h);c.append(o),l.xml(a,c)}else l.xml(a,o)}}writeLcidMerged(e,t){let n=this.uctx.plan,r=this.parentTag,l=this.childTag,o=new p(r),s=t.get("donotuseinLCID")!==void 0?"donotuseinLCID":t.get("useinLCID")!==void 0?"useinLCID":null;if(s!==null){let a=n.readXml(e);if(a!==null){let c;a.isNamed(r)?c=a.elements(l):c=a.isNamed(l)?[a]:[];for(let u of c){let h=u.get(s),b=t.get(s);(h===void 0||b===void 0||h!==b)&&o.append(u)}}}w(o,t),n.xml(e,o)}writeSubfolders(e,t,n,r){for(let l of F(t)){let o=f(l,n,!0);this.writeFolder(m(e,t.local,o),l,r)}}read(){let e=this.pctx,t=this.path(this.ctype,null);if(e.exists(t))return this.createComponents(e.load(t));if(this.fileBacked&&e.isdir(N(t))){let n=new p(this.element);this.readFiles(e.filesIn(N(t),"*.data.xml"),n);let r=this.createComponents(n);return this.loadFiles(r),r}if(this.collection){let n=new p(this.element);return this.readFolder(Te(this.ctype)[0],n),this.createComponents(n)}return null}readFiles(e,t){let n=this.pctx;for(let r of e){if(z(r).toLowerCase()===".xaml"||!n.exists(r))continue;let l=n.load(r);if(this.parentTag&&t.local===this.parentTag){if(l.local===this.parentTag&&l.hasElements())for(let o of l.elements(this.childTag??void 0))w(t,o);else l.local===this.childTag&&w(t,l);continue}w(t,l),t.parent!==null&&q(t.parent,t)}return t}readFolder(e,t){let n=this.pctx;if(t===null||!n.isdir(e))return;let r=n.isManagedPackage&&this.needManagedName(t),l=n.filesIn(e,"*.*"),o=l.filter(s=>D(s).toLowerCase().endsWith("_managed")===r);if(r&&n.unmanagedForManaged){let s=new Set(o.map(a=>D(a).toLowerCase()));o=o.concat(l.filter(a=>!D(a).toLowerCase().endsWith("_managed")&&!s.has(D(a).toLowerCase()+"_managed")))}o=Me(o,s=>s.replaceAll("/","\\")),this.readFiles(o,t)}loadFiles(e){let t=this.pctx;for(let n of e.comps)n.fileName&&S(n.fileName)&&t.addFile(n.fileName,t.readComponentFile(n))}pathPreferManaged(e,t){let n=this.pctx,r=this.path(e,t,null,n.isManagedPackage);if(n.isManagedPackage&&!n.exists(r)){let l=this.path(e,t,null,!1);n.unmanagedForManaged?r=l:n.exists(l)&&n.warn(`${Pt(e)}/${t}: no ${E(r)}, only ${E(l)}`)}return r}};function D(i){let e=E(i),t=e.lastIndexOf(".");return t<0?e:e.slice(0,t)}function y(i,e,t,n,r={}){return class extends x{element=i;ctype=e;single=t==="single";collection=t==="collection";differentInManaged=r.differentInManaged??!1;create(l){return n(l)}}}function P(i,e,t=null){return n=>new g(i,n,{name:e?e(n):null,id:t?t(n):null})}var Yt=y("optionsets",K,"collection",P(K,i=>f(i,"Name",!0))),Kt=y("Roles",H,"collection",P(H,i=>f(i,"name"),i=>v(f(i,"id")))),Ht=y("Dashboards",ee,"collection",P(ee,i=>d(i,"FormId",!0),i=>v(d(i,"FormId")))),Zt=y("InteractionCentricDashboards",ye,"collection",P(ye,i=>d(i,"FormId",!0),i=>v(d(i,"FormId")))),Qt=y("Dialogs",he,"collection",P(he,i=>d(i,"FormId",!0),i=>v(d(i,"FormId")))),Jt=y("SdkMessageProcessingSteps",se,"collection",P(se,null,i=>v(f(i,"SdkMessageProcessingStepId",!0)))),en=y("SdkMessages",ue,"collection",P(ue,i=>d(i,"Name"),i=>v(d(i,"SdkMessageId",!0)))),tn=y("ComplexControls",re,"collection",P(re,i=>d(i,"name"),i=>v(f(i,"id")))),nn=y("Maps",fe,"collection",P(fe,i=>f(i,"Name",!0))),rn=y("WebWizards",ge,"collection",P(ge,null,i=>v(d(i,"WebWizardId",!0)))),on=y("EntityDataProviders",de,"collection",P(de,null,i=>v(d(i,"EntityDataProviderId",!0)))),ln=y("EntityDataSources",me,"collection",P(me,null,i=>v(f(i,"EntityDataSourceId",!0)))),sn=y("TeamTemplates",ve,"collection",P(ve,i=>d(i,"TeamTemplateId",!0),i=>v(d(i,"TeamTemplateId")))),an=y("SyncAttributeMappingProfiles",Pe,"collection",P(Pe,i=>d(i,"syncattributemappingprofileidunique",!0),i=>v(d(i,"syncattributemappingprofileidunique"))),{differentInManaged:!0}),cn=y("MobileOfflineProfiles",ce,"collection",P(ce,i=>f(i,"Name"),i=>v(f(i,"MobileOfflineProfileId",!0)))),be=class extends x{individual=!0;SUBFOLDER="";ID="";create(e){return new g(this.ctype,e,{name:f(e,"Name",!0),id:v(f(e,this.ID))})}read(){let e=m("ChannelAccess",this.SUBFOLDER);if(!this.pctx.isdir(e))return null;let t=this.readFiles(this.pctx.filesIn(e,"*.xml",!1),new p(this.element));return this.createComponents(t)}},$e=class extends be{element="ChannelAccessProfileRules";ctype=st;SUBFOLDER="ProfileRules";ID="ChannelAccessProfileRuleId"},Oe=class extends be{element="ChannelAccessProfiles";ctype=at;SUBFOLDER="Profiles";ID="ChannelAccessProfileId"},Le=class extends x{element="AppModuleSiteMaps";ctype=B;individual=!0;differentInManaged=!0;create(e){return new g(B,e,{name:d(e,"SiteMapUniqueName",!0)})}needManagedName(e){return!0}read(){let e=this.pctx,t=new p(this.element);for(let n of e.dirsIn("AppModuleSiteMaps")){let r=this.pathPreferManaged(B,E(n));e.exists(r)&&t.append(e.load(r))}return this.createComponents(t)}},dn=y("FieldSecurityProfiles",le,"plain",P(le,i=>f(i,"name",!0),i=>v(f(i,"fieldsecurityprofileid")))),mn=y("EntityMaps",Q,"plain",P(Q,i=>`${d(i,"EntitySource",!0)},${d(i,"EntityTarget",!0)}`)),un=y("ServiceEndpoints",ae,"plain",P(ae,i=>f(i,"Name",!0),i=>v(f(i,"ServiceEndpointId")))),fn=y("RibbonDiffXml",J,"single",i=>new g(J,i,{name:":RibbonDiffXml"})),pn=y("serviceplans",Ce,"single",i=>new g(Ce,i,{name:"serviceplans"})),gn=y("serviceplanappmodulesset",Ne,"single",i=>new g(Ne,i,{name:"serviceplanappmodulesset"})),De=class extends x{element="ConnectionRoles";ctype=ie;componentElements(e){let t=e.element("ConnectionRoles");return t!==null?t.elements():[]}create(e){return new g(ie,e,{id:v(d(e,"connectionroleid",!0))})}},je=class extends x{element="SiteMap";ctype=ne;single=!0;differentInManaged=!0;create(e){return e.hasElements()?new g(ne,e,{name:"SiteMap"}):null}needManagedName(e){return!0}},$=class extends x{collection=!0;newFormatOnly=!0},Ue=class extends ${element="AIModels";ctype=ut},Be=class extends ${element="AITemplates";ctype=mt},_e=class extends ${element="EntityImageConfigs";ctype=pt},Xe=class extends ${element="AttributeImageConfigs";ctype=ft},Ve=class extends x{element="Entities";ctype=j;individual=!0;differentInManaged=!0;create(e){return new g(j,e,{name:d(e,"Name",!0)})}unshardedDirs(){return new Set(["Entities","Formulas"])}needManagedName(e){return e.local==="forms"}write(e){let t=this.uctx;if(t.both&&t.isManaged&&!this.differentInManaged)return;let n=t.plan;for(let r of e.comps){let l=r.el,o=this.path(j,r.name),s=N(o);for(let c of l.descendants("FormulaDefinitionFileName")){let u=c.value,h=t.zipFile(u);if(h===null)throw new C(`entity '${A(r.name)}' references formula file '${u}', but the file is not in the solution zip`);n.bytes(m(s,u.slice(1)),h.data)}let a=xt(l);for(let c of F(l)){this.parentTag=this.childTag=null;let u=c.local,h;if(u==="FormXml")[this.parentTag,this.childTag]=["forms","systemform"],this.writeSubfolders(s,c,"type","formid"),h=new p("FormXml");else if(u==="SavedQueries"){[this.parentTag,this.childTag]=["savedqueries","savedquery"];let b=ht(c,"savedqueries");b!==null&&this.writeFolder(m(s,"SavedQueries"),b,"savedqueryid"),h=new p("SavedQueries")}else u==="Visualizations"?(this.writeFolder(m(s,"Visualizations"),c,"savedqueryvisualizationid"),h=new p("Visualizations")):u==="RibbonDiffXml"?(n.xml(m(s,"RibbonDiff.xml"),c),h=c.shallow()):h=c;w(a,h)}n.xml(o,a)}this.parentTag=this.childTag=null}read(){let e=this.pctx,t=new p("Entities");for(let n of e.dirsIn("Entities")){let r=this.readEntity(n);r!==null&&w(t,r)}return this.createComponents(t)}readEntity(e){let t=this.pctx;if(!t.exists(m(e,"Entity.xml")))return null;let n=t.load(m(e,"Entity.xml"));this.readForms(m(e,"FormXml"),n.element("FormXml"));let r=n.element("SavedQueries");if(r!==null){[this.parentTag,this.childTag]=["savedqueries","savedquery"];let o=new p("savedqueries");r.append(o),this.readFolder(m(e,"SavedQueries"),o)}if(this.readFolder(m(e,"Visualizations"),n.element("Visualizations")),t.exists(m(e,"RibbonDiff.xml"))){let o=t.load(m(e,"RibbonDiff.xml")),s=n.elements().find(c=>c.name===o.name)??null;if(s===null)throw new C(`${e}/Entity.xml has no ${o.name} for RibbonDiff.xml`);let a=n.kids.indexOf(s);s.parent=null,o.parent=n,n.kids[a]=o,q(n,o)}let l=m(e,"Formulas");if(t.isdir(l))for(let o of t.filesIn(l,"*.*",!1)){let s=z(o);(s===".xaml"||s===".yaml")&&t.addFile("Formulas/"+E(o),t.readFile(o),E(o))}return n}readForms(e,t){let n=this.pctx;if(t===null||!n.isdir(e))return;[this.parentTag,this.childTag]=["forms","systemform"];let r=[];for(let o of n.dirsIn(e)){let s=new p("forms",[["type",E(o)]]);this.readFolder(o,s),r.push(s)}let l=o=>{let s=o.element("systemform"),a=s!==null?s.element("formid"):null,c=s!==null&&a!==null?a.value:"";return[o.get("type")||"",s!==null,c]};r.sort((o,s)=>{let[a,c,u]=l(o),[h,b,Se]=l(s);return Nt(a,h)||Number(c)-Number(b)||Nt(u,Se)});for(let o of r)o.hasElements()&&w(t,o)}},We=class extends x{element="EntityRelationships";ctype=T;individual=!0;create(e){return new g(T,e,{name:f(e,"Name",!0)})}write(e){let t=this.uctx.plan,n=this.path(T,null),r=m(N(n),"Relationships"),l=e.el.clone(),o=new Map;for(let s of F(l,"EntityRelationship",!1)){let a=hn(s),c=o.get(a);c===void 0&&(c=new p(l.local),o.set(a,c)),w(c,s.clone()),s.removeNodes(),q(l,s)}for(let[s,a]of o)t.xml(m(r,M(s,".xml")),a);t.xml(n,l)}read(){let e=this.pctx,t=this.path(T,null);if(!e.exists(t))return null;let n=e.load(t),r=new Map,l=m(N(t),"Relationships");if(e.isdir(l))for(let o of e.filesIn(l,"*.xml",!1))for(let s of F(e.load(o),"EntityRelationship")){let a=f(s,"Name",!0);if(r.has(a))throw new C(`relationship ${a} is in more than one file`);r.set(a,s)}for(let o of n.elements("EntityRelationship")){let s=r.get(f(o,"Name",!0));if(s!==void 0){if(o.hasElements())throw new C(`relationship ${A(o.get("Name"))} is in more than one file`);for(let a of s.elements())o.append(a)}}return this.createComponents(n)}};function hn(i){let e=d(i,"EntityRelationshipType",!0);if(e==="ManyToMany")return d(i,"FirstEntityName",!0);if(e==="OneToMany")return d(i,"ReferencedEntityName",!0);throw new C(`unknown relationship type '${e}'`)}var ze=class extends x{element="WebResources";ctype=te;fileBacked=!0;create(e){let t=d(e,"Name",!0);return new g(te,e,{name:t,id:v(d(e,"WebResourceId",!0)),fileName:d(e,"FileName"),diskFileName:m("WebResources",t)})}},qe=class extends x{element="Workflows";ctype=R;fileBacked=!0;create(e){let t=new g(R,e,{name:f(e,"Name"),id:v(f(e,"WorkflowId",!0))});if(!V(e)){let n=d(e,"XamlFileName");if(n===null&&(n=d(e,"JsonFileName")),n===null)throw new C(`cannot find the definition file of workflow ${A(t.name||t.id)}`);t.fileName=n,t.diskFileName=m("Workflows",d(e,"LanguageCode",!1,""),E(n))}return t}createImage(e){let t=new g(R,null,{name:"EntityImages",id:null});if(!V(e)){let n=d(e,"ImageFileName",!0);t.fileName=n,t.diskFileName=m("EntityImages",d(e,"LanguageCode",!1,""),E(n))}return t}},Ge=class extends x{element="SolutionPluginAssemblies";ctype=_;fileBacked=!0;create(e){let t=new g(_,e,{name:f(e,"FullName"),fileName:d(e,"FileName")});if(_t(this.ctx.packageVersion,[9,0])>=0){t.id=v(f(e,"PluginAssemblyId",!0));let n=d(e,"SourceType");if(n!==null&&n!==""){let r=Tt(n);if(r===null)throw new Error(`invalid literal for int() with base 10: ${Ft(n)}`);t.sourceType=r}else t.sourceType=0}return t}writeFile(e){let t=this.uctx,n=t.plan;if(e.fileName&&S(e.fileName)){n.xml(e.diskFileName+".data.xml",e.el);let r=t.zipFile(e.fileName),l=e.name?e.name.split(",")[0]:"";r!==null&&!t.ignore.includes(l)&&!t.mapped(e.diskFileName)&&n.bytes(e.diskFileName,r.data)}else e.sourceType===3&&e.name&&n.xml(m("PluginAssembliesExternal",`${e.name.split(",")[0]}-${A(e.id)}`)+".data.xml",e.el)}read(){let e=this.pctx,t=this.path(_,null);if(e.exists(t))return this.createComponents(e.load(t));if(!e.isdir("PluginAssemblies"))return null;let n=e.filesIn("PluginAssemblies","*.data.xml");e.isdir("PluginAssembliesExternal")&&(n=n.concat(e.filesIn("PluginAssembliesExternal","*.data.xml")));let r=this.readFiles(n,new p(this.element)),l=this.createComponents(r);return this.loadFiles(l),l}},Ye=class extends x{element="StoredProcedures";ctype=pe;fileBacked=!0;create(e){let t=f(e,"name");return new g(pe,e,{name:t,fileName:d(e,"file"),diskFileName:m("StoredProcedures",`${A(t)}.sql`)})}},Ke=class extends x{element="Reports";ctype=Z;fileBacked=!0;componentElements(e){return e.elements("Report")}create(e){let t=d(e,"reportid",!0),n=new g(Z,e,{name:d(e,"name"),id:v(t)}),r=Tt(d(e,"reporttypecode",!0))??-1;return V(e)||(n.fileName=r===3?`UrlLinkedReport-${A(n.id)}`:d(e,"ExportedFileName"),n.diskFileName=m("Reports",d(e,"languagecode",!1,""),t,r===3?"UrlLinkedReport.txt":d(e,"filename",!0))),n}write(e){let t=this.uctx.plan;for(let n of["ReportSignatureIdMappings","ReportLinks"]){let r=e.el.element(n);r!==null&&t.xml(m("Reports",n+".xml"),r)}super.write(e)}read(){let e=this.pctx;if(!e.isdir("Reports"))return null;let t=this.readFiles(e.filesIn("Reports","*.data.xml"),new p(this.element)),n=this.createComponents(t);for(let o of n.comps){let s=d(o.el,"reporttypecode",!0);o.fileName&&S(o.fileName)&&s!=="3"&&e.addFile(o.fileName,e.readComponentFile(o))}let r=m("Reports","ReportSignatureIdMappings.xml");if(e.exists(r)){let o=e.load(r);n.el.kids.unshift(o),o.parent=n.el,n.el.empty=!1}let l=m("Reports","ReportLinks.xml");return e.exists(l)&&n.el.append(e.load(l)),n}},He=class extends x{element="CustomControls";ctype=oe;fileBacked=!0;create(e){let t=S(d(e,"FileName",!0)),n=new g(oe,e,{fileName:t,diskFileName:I(t)});return n.name=this.primaryName(t),n}writeFile(e){super.writeFile(e);let t=this.uctx,n=e.fileName,r=n.split("/").slice(0,3).join("/").replaceAll("\\","/").toLowerCase(),l=E(n);for(let o of t.zipFiles())o.name.toLowerCase().startsWith(r)&&!E(o.name).includes(l)&&t.plan.bytes(I(o.name),o.data)}read(){let e=this.pctx,t=e.isdir("Controls")?e.filesIn("Controls","ControlManifest.xml").filter(o=>N(N(o)).toLowerCase()==="controls"):[],n=new p(this.element),r=[];for(let o of t)if(e.exists(o+".data.xml"))r.push(o+".data.xml");else{let s=E(N(o));e.warn(`control ${s} has no ${E(o)}.data.xml; generating its metadata`),w(n,Ie(`<CustomControl xmlns:xsi="${gt}"><Name>${s}.xml</Name><FileName>/Controls/${s}/ControlManifest.xml</FileName></CustomControl>`))}this.readFiles(r,n);let l=this.createComponents(n);for(let o of l.comps){let s=o.fileName,a=o.diskFileName;e.addFile(s,e.readComponentFile(o));let c=N(a),u=s.split("/").slice(0,3).join("/").replaceAll("\\","/"),h=E(a);for(let b of e.filesIn(c,"*.*")){if(E(b).includes(h))continue;let Se=b.slice(c.length+1);e.addFile(`${u}/${Se}`,e.readBytes(b))}}return l}primaryName(e){let t=this.ctx.zipFile(e),n=t!==null?t.data:this.pctx.tryReadBytes(I(e));if(n===null)return"";let r=Ie(n).element("control");return r===null?"":`${f(r,"namespace",!0)}.${f(r,"constructor",!0)}`}},Ze=class extends x{element="EntityPrivileges";ctype=X;single=!0;create(e){return new g(X,e)}write(e){let t=this.uctx;if(!(t.both&&t.isManaged))for(let n of e.comps){let r=n.el,l=this.path(X,n.name),o=N(l),s=r.shallow();for(let a of r.elements())a.local==="privileges"?(this.writeFolder(m(o,"privileges"),a,"PrivilegeId"),s.append(new p("privileges"))):a.local==="privilegeobjecttypecodeslist"?(this.writeFolder(m(o,"privilegeobjecttypecodes"),a,"PrivilegeId"),s.append(new p("privilegeobjecttypecodeslist"))):s.append(a);t.plan.xml(l,s)}}read(){let e=this.pctx,t=new p(this.element),n="EntityPrivileges";return e.isdir(n)&&e.exists(m(n,"EntityPrivilege.xml"))&&(t=e.load(m(n,"EntityPrivilege.xml")),this.readFolder(m(n,"privileges"),t.element("privileges")),this.readFolder(m(n,"privilegeobjecttypecodes"),t.element("privilegeobjecttypecodeslist"))),this.createComponents(t)}},Qe=class extends x{element="EnvironmentVariables";ctype=xe;single=!0;VALUES="/environment_variable_values.json";create(e){return new g(xe,e,{name:"EnvironmentVariables"})}write(e){let t=this.uctx;if(!(!e.comps.length||t.both&&t.isManaged)){for(let n of F(e.comps[0].el)){let r=xn(n);t.plan.xml(m("EnvironmentVariables",M(Ae(r),".xml")),n)}for(let n of t.zipFiles())if(n.name.startsWith(this.VALUES)){t.plan.bytes(m("EnvironmentVariables","environment_variable_values.json"),n.data);break}}}read(){let e=this.pctx;if(!e.isdir("EnvironmentVariables"))return null;let t=this.readFiles(e.filesIn("EnvironmentVariables","*.xml"),new p(this.element)),n=this.createComponents(t),r=m("EnvironmentVariables","environment_variable_values.json");return e.exists(r)&&e.addFile(this.VALUES,e.readFile(r)),n}};function xn(i){let e=i.get("schemaname")??null;if(e===null&&(e=d(i,"SchemaName")),e===null&&(e=d(i,"Name")),e===null)throw new C("cannot find the name of an environment variable (schemaname attribute or SchemaName element)");return e}var Je=class extends x{element="Templates";ctype=U;individual=!0;SUB=["KBArticleTemplates","EmailTemplates","ContractTemplates","MailMergeTemplates"];create(e){return new g(U,e,{name:e.local})}write(e){let t=this.uctx;if(!(!e.comps.length||t.both&&t.isManaged))for(let n of e.comps){let r=n.el,l=this.path(U,n.name),o=St.get(r.local);if(o===void 0){t.plan.xml(l,r);continue}let s=r.clone(),a=N(l);for(let c of s.elements())V(c)||o.write(t,c,bt(o,c,a));t.plan.xml(l,s)}}read(){let e=this.pctx,t=new p(this.element);if(e.isdir("Templates"))for(let n of this.SUB){let r=m("Templates",n+".xml");if(!e.exists(r))continue;let l=e.load(r),o=St.get(n);if(o!==void 0)for(let s of l.elements())V(s)||o.read(e,s,bt(o,s,"Templates"));t.append(l)}return this.createComponents(t)}};function bt(i,e,t){return m(t,i.ROOT,d(e,"languagecode",!1,""),d(e,i.ID,!0))}var W=class{static ID="";static ROOT="";static PARTS=[];static write(e,t,n){for(let[r,l]of this.PARTS){e.plan.text(m(n,M(r,l)),d(t,r,!0));let o=t.element(r);if(o===null)throw new C(`cannot find child element ${r} of element ${t.name}`);o.setValue(null)}}static read(e,t,n){for(let[r,l]of this.PARTS)if(!d(t,r,!0)){let o=e.readText(m(n,M(r,l)));t.element(r).setValue(o)}}},et=class extends W{static ID="kbarticletemplateid";static ROOT="KbArticleDocuments";static PARTS=[["structurexml",".xml"],["formatxml",".xsl"]]},tt=class extends W{static ID="templateid";static ROOT="EmailDocuments";static PARTS=[["subject",".xsl"],["subjectpresentationxml",".xml"],["body",".xsl"],["presentationxml",".xml"]];static write(e,t,n){super.write(e,t,n);let r=t.element("ActivityMimeAttachments");if(r!==null)for(let l of r.elements("ActivityMimeAttachment")){let o=d(l,"SolutionAttachmentsFileName");if(o&&S(o)){let s=e.zipFile(o);s!==null&&e.plan.bytes(wt(l,o),s.data)}}}static read(e,t,n){super.read(e,t,n);let r=t.element("ActivityMimeAttachments");if(r!==null)for(let l of r.elements("ActivityMimeAttachment")){let o=d(l,"SolutionAttachmentsFileName");o&&S(o)&&e.addFile(o,e.readBytes(wt(l,o)))}}};function wt(i,e){let t=I(e),n=d(i,"filename");return n&&S(n)&&(t=m(N(t),n)),t}var nt=class extends W{static ID="mailmergetemplateid";static ROOT="MailMergeDocuments";static write(e,t,n){let r=d(t,"filename");r&&(e.plan.bytes(m(n,r),zt(d(t,"body",!0))),t.element("body").setValue(null))}static read(e,t,n){let r=d(t,"filename");if(!r||d(t,"body"))return;let l=e.readBytes(m(n,r));t.element("body").setValue(qt(l));let o=t.element("filesize");if(o===null)throw new C("cannot find child element filesize of a mail merge template");o.setValue(String(l.length))}},St=new Map([["KBArticleTemplates",et],["EmailTemplates",tt],["MailMergeTemplates",nt]]),it=class extends x{element="AppModules";ctype=k;individual=!0;differentInManaged=!0;create(e){return new g(k,e,{name:d(e,"UniqueName",!0)})}needManagedName(e){return!0}write(e){let t=this.uctx.plan;for(let n of e.comps){let r=n.el,l=this.path(k,n.name),o=N(l),s=r.shallow();for(let a of r.elements()){if(a.local==="AppConfig"){let c=a.element("NavigationSettings");c!==null&&(this.writeFolder(m(o,"NavigationSettings"),c,"NavigationSettingId"),c.hasElements()&&c.remove())}else a.local==="AppModuleComponents"&&a.replaceNodes(Xt(a.elements("AppModuleComponent"),c=>c.get("type"),c=>c.get("schemaName")));s.append(a)}t.xml(l,s)}}read(){let e=this.pctx,t=new p(this.element);for(let n of e.dirsIn("AppModules")){let r=this.pathPreferManaged(k,D(n));if(!e.exists(r))continue;let l=e.load(r),o=l.element("AppConfig"),s=m(n,"NavigationSettings");if(o!==null&&e.isdir(s)){let a=new p("NavigationSettings");for(let c of e.filesIn(s,"*.xml",!1))a.append(e.load(c));o.append(a)}t.append(l)}return this.createComponents(t)}},vn=new Set(["solutioncomponentattributeconfigurations","solutioncomponentrelationshipconfiguration","solutioncomponentconfigurations","serviceplans","bots","botcomponents","appelements"].map(i=>i.toLowerCase()));function $t(i){if(i==null)return null;for(let e of[d(i,"Name"),i.get("Name"),d(i,"SchemaName"),d(i,"name"),i.get("name"),d(i,"schemaName")])if(e)return e;return null}var O=class extends x{individual=!0;extension=".meta.xml";compositeFolderName;explicit=new Map;constructor(e,t,n=we,r=null){super(e),this.element=t,this.ctype=n,this.compositeFolderName=r||t}get compositeFolder(){return this.compositeFolderName}unshardedDirs(){return new Set([this.compositeFolder,this.element])}create(e){return this.explicit.clear(),vn.has(this.element.toLowerCase())?null:new g(this.ctype,e,{name:$t(e)})}write(e){if(!e.comps.length)return;let t=this.uctx;if(!(t.both&&t.isManaged&&!this.differentInManaged)){this.beforeWrite(e);for(let n of e.comps){t.plan.xml(this.path(n.type,n.name,this.element),n.el);for(let r of this.associated(n.name))t.plan.bytes(this.localFile(r.name),r.data)}}}beforeWrite(e){}associated(e){let t=this.explicit.get(e);if(t!==void 0){let r=new Set(t);return[...this.ctx.zipFiles()].filter(l=>r.has(l.name))}let n=`/${this.compositeFolder}/${e!==null?e:""}`;return[...this.ctx.zipFiles()].filter(r=>r.name.startsWith(n))}localFile(e){let t=e.split("/"),n=t.length<2?e:t.slice(2).join("/");return m(this.element,n)}read(){let e=this.pctx,t=this.element;if(!e.isdir(t))return null;let n=e.filesIn(t,"*"+this.extension),r=this.createComponents(this.readFiles(n,new p(this.element))),l=e.filesIn(t,"*").filter(o=>!o.endsWith(this.extension));this.findComposites(r);for(let o of r.comps){let s=o.name!==null?this.explicit.get(o.name):void 0,a;if(s!==void 0)a=s.map(c=>I(c));else{let c=`${t}/${A(o.name)}`;a=l.filter(u=>u.startsWith(c))}for(let c of a){let u=c.includes("/")?c.slice(c.indexOf("/")+1):c,h=`/${this.compositeFolder}/${u}`;e.addFile(h,e.readFile(c,!0,I(h)))}}return r}findComposites(e){}},rt=class extends O{extension=".xml";constructor(e){super(e,"Connectors",dt,"Connector")}},ot=class extends O{constructor(e){super(e,"OrganizationSettings",Ee,"OrganizationSettings")}unshardedDirs(){return new Set(["OrganizationSettings\\_legacy"])}create(e){return new g(Ee,e,{name:e.local})}},lt=class extends O{COMPOSITES=["BackgroundImageUri","DocumentUri"];CODE_APP_COMPOSITES=["BackgroundImageUri","CodeAppPackageUris"];constructor(e){super(e,"CanvasApps",ct,"CanvasApps")}beforeWrite(e){this.findComposites(e)}findComposites(e){for(let t of e.comps){let n=t.el,r=[],l=Vt(n.descendants("CanvasAppType")),o=l!==null?l.value:"";for(let s of o==="4"?this.CODE_APP_COMPOSITES:this.COMPOSITES){let a=[...n.descendants(s)];if(!(!a.length&&o==="4"&&s==="BackgroundImageUri")){if(a.length!==1)throw new C(`missing or more than one '${s}' in canvas app ${A(t.name)}; can't find its files`);if(s==="CodeAppPackageUris"){for(let c of a[0].elements("CodeAppPackageUri")){let u=c.value,h=u.indexOf("_ContentType_");r.push(h>0?u.slice(0,h):u)}continue}r.push(a[0].value)}}for(let s of n.descendants("AdditionalUris"))for(let a of s.elements("AdditionalUri"))r.push(a.value);if(this.explicit.has(t.name))throw new C(`two canvas apps are named ${A(t.name)}`);this.explicit.set(t.name,r)}}},yn=[Ve,Yt,We,je,fn,Kt,De,Ht,dn,ze,qe,Ge,Jt,un,Ke,Je,mn,$e,Oe,en,tn,Qt,Ye,it,Le,Ze,rn,nn,on,ln,Zt,sn,an,cn,He,Qe,rt,ot,lt,Ue,Be,_e,Xe,pn,gn],At=class{constructor(e){this.ctx=e;for(let t of yn){let n=new t(e);this.byElement.set(n.element,n),this.byType.set(n.ctype,n)}}byElement=new Map;byType=new Map;generic=new Map;active(e){return e!==void 0&&!e.newFormatOnly}forElement(e,t=!1){let n=this.byElement.get(e.local);return this.active(n)?n:this.genericFor(e.local,t?null:e,t)}forCollection(e){let t=this.byType.get(e.type);return this.active(t)?t:this.genericFor(e.elementName,null,!0)}genericFor(e,t,n){if(jt.has(e)||!n&&$t(t.elements()[0]??null)===null)return null;let r=this.generic.get(e);return r===void 0&&(r=new O(this.ctx,e),this.generic.set(e,r)),r}};export{j as a,K as b,T as c,H as d,R as e,Z as f,U as g,Q as h,J as i,ee as j,te as k,ne as l,ie as m,re as n,oe as o,le as p,k as q,B as r,_ as s,se as t,ae as u,ce as v,st as w,at as x,de as y,me as z,X as A,ue as B,fe as C,pe as D,ge as E,he as F,ct as G,dt as H,xe as I,mt as J,ut as K,ft as L,pt as M,ve as N,ye as O,Pe as P,Ee as Q,Ce as R,Ne as S,we as T,Dt as U,It as V,jt as W,Nn as X,C as Y,S as Z,A as _,Ft as $,Tt as aa,_t as ba,Nt as ca,Xt as da,Vt as ea,v as fa,zt as ga,Gt as ha,Rt as ia,d as ja,f as ka,V as la,g as ma,Re as na,x as oa,Yt as pa,Kt as qa,Ht as ra,Zt as sa,Qt as ta,Jt as ua,en as va,tn as wa,nn as xa,rn as ya,on as za,ln as Aa,sn as Ba,an as Ca,cn as Da,$e as Ea,Oe as Fa,Le as Ga,dn as Ha,mn as Ia,un as Ja,fn as Ka,pn as La,gn as Ma,De as Na,je as Oa,Ue as Pa,Be as Qa,_e as Ra,Xe as Sa,Ve as Ta,We as Ua,ze as Va,qe as Wa,Ge as Xa,Ye as Ya,Ke as Za,He as _a,Ze as $a,Qe as ab,Je as bb,it as cb,$t as db,O as eb,rt as fb,ot as gb,lt as hb,yn as ib,At as jb};
@@ -0,0 +1,4 @@
1
+ import { createRequire as __cr } from 'node:module'; const require = __cr(import.meta.url);
2
+ var g=`
3
+ \r`,i=/-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][-+]?\d+)?/y,s='"\\/bfnrt',o=class extends Error{constructor(t,e){super(t);this.msg=t;this.pos=e}};function h(r,n,t){let e=1,c=-1;for(let l=0;l<t&&l<r.length;l++)r[l]===`
4
+ `&&(e++,c=l);return`${n}: line ${e} column ${t-c} (char ${t})`}function u(r,n){for(;n<r.length&&g.includes(r[n]);)n++;return n}function a(r,n){let t=n;for(;;){if(t>=r.length)throw new o("Unterminated string starting at",n-1);let e=r[t];if(e==='"')return t+1;if(e==="\\"){if(t++,t>=r.length)throw new o("Unterminated string starting at",n-1);let c=r[t];if(c==="u"){let l=r.slice(t+1,t+5);if(l.length<4||t+5>=r.length+1||!/^[0-9a-fA-F]{4}$/.test(l))throw new o("Invalid \\uXXXX escape",t);t+=5;continue}if(!s.includes(c))throw new o("Invalid \\escape",t-1);t++;continue}if(e.charCodeAt(0)<=31)throw new o("Invalid control character at",t);t++}}function f(r,n){let t=r[n];if(t==='"')return a(r,n+1);if(t==="{")return w(r,n+1);if(t==="[")return d(r,n+1);for(let c of["null","true","false","NaN","Infinity","-Infinity"])if(r.startsWith(c,n))return n+c.length;i.lastIndex=n;let e=i.exec(r);if(e&&e[0].length&&e[0]!=="-")return n+e[0].length;throw new o("Expecting value",n)}function w(r,n){if(n=u(r,n),r[n]==="}")return n+1;for(;;){if(r[n]!=='"')throw new o("Expecting property name enclosed in double quotes",n);if(n=u(r,a(r,n+1)),r[n]!==":")throw new o("Expecting ':' delimiter",n);if(n=u(r,n+1),n=u(r,f(r,n)),r[n]==="}")return n+1;if(r[n]!==",")throw new o("Expecting ',' delimiter",n);n=u(r,n+1)}}function d(r,n){if(n=u(r,n),r[n]==="]")return n+1;for(;;){if(n=u(r,f(r,n)),r[n]==="]")return n+1;if(r[n]!==",")throw new o("Expecting ',' delimiter",n);n=u(r,n+1)}}function m(r){try{let n=f(r,u(r,0));if(n=u(r,n),n!==r.length)throw new o("Extra data",n);return null}catch(n){if(n instanceof o)return h(r,n.msg,n.pos);throw n}}function b(r){try{return JSON.parse(r)}catch(n){let t=m(r);if(t===null)return JSON.parse(r.replace(/-?\bInfinity\b|\bNaN\b/g,"null"));let e=new SyntaxError(t);throw e.cause=n,e}}export{b as a};
@@ -0,0 +1,13 @@
1
+ import { createRequire as __cr } from 'node:module'; const require = __cr(import.meta.url);
2
+ import{readFileSync as G}from"node:fs";var dt="http://www.w3.org/2001/XMLSchema-instance",K="http://www.w3.org/XML/1998/namespace",N=`\r
3
+ `,Z=Uint8Array.of(239,187,191),E=class{constructor(t){this.value=t}},v=class{constructor(t){this.value=t}},I=class{constructor(t,n){this.target=t;this.data=n}},b=class e{name;attrs;kids;empty;ns;scope;parent=null;constructor(t,n,s,i={}){this.name=t,this.attrs=n??[],this.kids=s??[],this.empty=i.empty??this.kids.length===0,this.ns=i.ns??"",this.scope=i.scope??null;for(let a of this.kids)a instanceof e&&(a.parent=this)}get local(){let t=this.name.indexOf(":");return t<0?this.name:this.name.slice(t+1)}isNamed(t){return this.name===t&&!this.ns}elements(t){let n=[];for(let s of this.kids)s instanceof e&&(t===void 0||s.name===t&&!s.ns)&&n.push(s);return n}element(t){for(let n of this.kids)if(n instanceof e&&n.name===t&&!n.ns)return n;return null}*descendants(t){let n=[{kids:this.kids,i:0}];for(;n.length;){let s=n[n.length-1];if(s.i>=s.kids.length){n.pop();continue}let i=s.kids[s.i++];i instanceof e&&((t===void 0||i.name===t&&!i.ns)&&(yield i),n.push({kids:i.kids,i:0}))}}get(t,n){for(let s of this.attrs)if(s[0]===t)return s[1];return n}hasElements(){return this.kids.some(t=>t instanceof e)}get value(){if(this.kids.length===1&&typeof this.kids[0]=="string")return this.kids[0];let t=[],n=s=>{for(let i of s)typeof i=="string"?t.push(i):i instanceof E?t.push(i.value):i instanceof e&&n(i.kids)};return n(this.kids),t.join("")}setValue(t){this.kids=t?[t]:[],this.empty=!1}setAttr(t,n){for(let s=0;s<this.attrs.length;s++){let i=this.attrs[s];if(i[0]===t){n==null?this.attrs.splice(s,1):i[1]=n;return}}n!=null&&this.attrs.push([t,n])}append(t){if(t instanceof e){let n=t.parent!==null?t.clone():t;n.parent=this,t=n}this.kids.push(t),this.empty=!1}removeNodes(){for(let t of this.kids)t instanceof e&&(t.parent=null);this.kids=[],this.empty=!0}replaceNodes(t){let n=[...t];this.removeNodes();for(let s of n)s instanceof e&&(s.parent=null),this.append(s)}remove(){let t=this.parent;if(t!==null){let n=t.kids.indexOf(this);n>=0&&t.kids.splice(n,1),this.parent=null}}clone(){let t=new e(this.name,null,null,{empty:this.empty,ns:this.ns,scope:this.scope});t.attrs=this.attrs.map(([s,i])=>[s,i]);let n=[];for(let s of this.kids)if(s instanceof e){let i=s.clone();i.parent=t,n.push(i)}else n.push(s);return t.kids=n,t}shallow(t=!1){return new e(this.name,t?this.attrs.map(([n,s])=>[n,s]):[],null,{ns:this.ns,scope:this.scope})}nsAttrs(){return this.attrs.filter(t=>t[0]==="xmlns"||t[0].startsWith("xmlns:"))}},T=class{constructor(t,n=null){this.root=t;this.standalone=n}};function D(e,t){for(let[n,s]of t)e.setAttr(n,s)}function ht(e,t,n=!0){let s=e.nsAttrs().map(([i,a])=>[i,a]);return e.elements(t).map(i=>{let a=n?i.clone():i;return D(a,s),a})}function pt(e,t,n=!0){let s=e.nsAttrs().map(([r,d])=>[r,d]),i=e.element(t);if(i===null)return null;let a=n?i.clone():i;return D(a,s),a}function _(e,t){let n=t.nsAttrs().map(([s,i])=>[s,i]);if(n.length){D(e,n);for(let[s]of n)t.setAttr(s,null)}}function gt(e,t){e.append(t),_(e,e.kids[e.kids.length-1])}function mt(e){let t=new b(e.local,null,null,{ns:e.ns,scope:e.scope});return D(t,e.nsAttrs().map(([n,s])=>[n,s])),t}var u=class extends Error{},tt=new TextDecoder("utf-8",{fatal:!0});function A(e){return e===32||e===9||e===10||e===13}function P(e){for(let t=0;t<e.length;t++)if(!A(e.charCodeAt(t)))return!1;return!0}var et={amp:"&",lt:"<",gt:">",quot:'"',apos:"'"};function z(e,t){let n=e.indexOf("&");if(n<0)return e;let s=[],i=0;for(;n>=0;){let a=e.indexOf(";",n+1);if(a<0)throw new u(`unterminated reference near offset ${t+n}`);s.push(e.slice(i,n));let r=e.slice(n+1,a);if(r.charCodeAt(0)===35){let p=r.charCodeAt(1)===120?parseInt(r.slice(2),16):parseInt(r.slice(1),10);if(!Number.isFinite(p)||p<0||p>1114111)throw new u(`bad character reference &${r}; near offset ${t+n}`);s.push(String.fromCodePoint(p))}else{let d=et[r];if(d===void 0)throw new u(`undefined entity &${r}; near offset ${t+n}`);s.push(d)}i=a+1,n=e.indexOf("&",i)}return s.push(e.slice(i)),s.join("")}function nt(e,t){let n=e;for(let s=0;s<n.length;s++){let i=n.charCodeAt(s);if(i===9||i===10){n=n.replace(/[\t\n]/g," ");break}}return z(n,t)}function V(e){return A(e)||e===47||e===62||e===61||Number.isNaN(e)}function st(e){return e.length>=3&&e[0]===239&&e[1]===187&&e[2]===191?e.subarray(3):e}function j(e){let t=typeof e=="string"?e:tt.decode(st(e));t.indexOf("\r")>=0&&(t=t.replace(/\r\n?/g,`
4
+ `));let n=t.length,s=0,i=null,a=null,r=[],d=[new Map([["xml",K]])],p=[!1];if(t.startsWith("<?xml")&&A(t.charCodeAt(5))){let o=t.indexOf("?>",5);if(o<0)throw new u("unterminated XML declaration");let m=t.slice(5,o),w=/encoding\s*=\s*["']([^"']*)["']/.exec(m)?.[1];if(w&&!/^utf-?8$/i.test(w))throw new u(`unsupported encoding '${w}'`);let l=/standalone\s*=\s*["']([^"']*)["']/.exec(m)?.[1];l!==void 0&&(i=l==="yes"?"yes":"no"),s=o+2}let c=o=>{r.length&&r[r.length-1].kids.push(o)};for(;s<n;){let o=t.indexOf("<",s),m=o<0?n:o;if(m>s){if(r.length){let f=t.slice(s,m),h=z(f,s);if(!(P(h)&&!p[p.length-1]&&f.indexOf("&")<0)){let g=r[r.length-1],x=g.kids[g.kids.length-1];typeof x=="string"?g.kids[g.kids.length-1]=x+h:g.kids.push(h)}}else if(!P(t.slice(s,m)))throw new u(`text outside the root element near offset ${s}`)}if(o<0)break;let w=t.charCodeAt(o+1);if(w===47){let f=t.indexOf(">",o+2);if(f<0)throw new u(`unterminated end tag near offset ${o}`);let h=t.slice(o+2,f).trimEnd(),g=r.pop();if(!g||g.name!==h)throw new u(`mismatched end tag </${h}> near offset ${o}`);d.pop(),p.pop(),s=f+1;continue}if(w===33){if(t.startsWith("<!--",o)){let f=t.indexOf("-->",o+4);if(f<0)throw new u(`unterminated comment near offset ${o}`);c(new v(t.slice(o+4,f))),s=f+3;continue}if(t.startsWith("<![CDATA[",o)){let f=t.indexOf("]]>",o+9);if(f<0)throw new u(`unterminated CDATA section near offset ${o}`);c(new E(t.slice(o+9,f))),s=f+3;continue}throw new u(`unsupported markup near offset ${o} (DTDs are not supported)`)}if(w===63){let f=t.indexOf("?>",o+2);if(f<0)throw new u(`unterminated processing instruction near offset ${o}`);let h=t.slice(o+2,f),g=0;for(;g<h.length&&!A(h.charCodeAt(g));)g++;let x=g;for(;x<h.length&&A(h.charCodeAt(x));)x++;c(new I(h.slice(0,g),h.slice(x))),s=f+2;continue}let l=o+1;for(;l<n&&!V(t.charCodeAt(l));)l++;let k=t.slice(o+1,l);if(!k)throw new u(`bad start tag near offset ${o}`);let O=[],q=!1;for(;;){for(;l<n&&A(t.charCodeAt(l));)l++;let f=t.charCodeAt(l);if(f===62){l++;break}if(f===47&&t.charCodeAt(l+1)===62){q=!0,l+=2;break}if(l>=n)throw new u(`unterminated start tag <${k} near offset ${o}`);let h=l;for(;l<n&&!V(t.charCodeAt(l));)l++;let g=t.slice(h,l);for(;l<n&&A(t.charCodeAt(l));)l++;if(!g||t.charCodeAt(l)!==61)throw new u(`bad attribute in <${k} near offset ${h}`);for(l++;l<n&&A(t.charCodeAt(l));)l++;let x=t.charCodeAt(l);if(x!==34&&x!==39)throw new u(`unquoted attribute value near offset ${l}`);let S=t.indexOf(x===34?'"':"'",l+1);if(S<0)throw new u(`unterminated attribute value near offset ${l}`);for(let Y of O)if(Y[0]===g)throw new u(`duplicate attribute '${g}' near offset ${h}`);O.push([g,nt(t.slice(l+1,S),l+1)]),l=S+1}let y=d[d.length-1],M,C=null;for(let[f,h]of O)f.startsWith("xmlns")&&(f.length===5||f.charCodeAt(5)===58)?(C??=new Map(y),C.set(f.length===5?"":f.slice(6),h)):f==="xml:space"&&(M=h);C!==null&&(y=C);let F=k.indexOf(":"),Q=(F>0?y.get(k.slice(0,F)):y.get(""))??"",$=new b(k,O,[],{empty:!1,ns:Q,scope:y});if(r.length){let f=r[r.length-1];$.parent=f,f.kids.push($)}else if(a===null)a=$;else throw new u(`second root element <${k}> near offset ${o}`);q?$.empty=!0:(r.push($),d.push(y),p.push(M===void 0?p[p.length-1]:M==="preserve")),s=l}if(r.length)throw new u(`unclosed element <${r[r.length-1].name}>`);if(a===null)throw new u("no root element");return new T(a,i)}function it(e){return j(e).root}function xt(e){return j(G(e)).root}function At(e){return j(G(e))}function rt(e){return e.indexOf("&")>=0&&(e=e.replaceAll("&","&amp;")),e.indexOf("<")>=0&&(e=e.replaceAll("<","&lt;")),e.indexOf(">")>=0&&(e=e.replaceAll(">","&gt;")),e.indexOf("\r")>=0&&(e=e.replaceAll(`\r
5
+ `,`
6
+ `).replaceAll("\r",`
7
+ `)),e.indexOf(`
8
+ `)>=0&&(e=e.replaceAll(`
9
+ `,N)),e}var ot={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;"," ":"&#x9;","\n":"&#xA;","\r":"&#xD;"},R=/[&<>"\t\n\r]/g;function U(e){return R.lastIndex=0,R.test(e)?e.replace(R,t=>ot[t]):e}function B(e){return e.replaceAll(`\r
10
+ `,`
11
+ `).replaceAll("\r",`
12
+ `).replaceAll(`
13
+ `,N)}var L=class e{out=[];atText=!0;mixed=!1;level=0;indent(){this.out.push(N+" ".repeat(this.level))}element(t,n){let s=this.out;!this.mixed&&!this.atText&&this.indent(),this.level++;let i=this.mixed;s.push("<"+t.name);let a=n,r=null;for(let[c,o]of t.attrs)(c==="xmlns"||c.startsWith("xmlns:"))&&(r??=new Map(n),r.set(c==="xmlns"?"":c.slice(6),o)),s.push(` ${c}="${U(o)}"`);r!==null&&(a=r);let d=e.missing(t,a);if(d.length){let c=new Map(a);for(let[o,m]of d)c.set(o,m),s.push(o===""?` xmlns="${U(m)}"`:` xmlns:${o}="${U(m)}"`);a=c}if(t.empty&&!t.kids.length){this.level--,s.push(" />"),this.mixed=i,this.atText=!1;return}s.push(">");let p=!1;for(let c of t.kids)typeof c=="string"?(this.mixed=!0,s.push(rt(c)),this.atText=!0):c instanceof b?this.element(c,a):c instanceof E?(this.mixed=!0,s.push("<![CDATA["+B(c.value).replaceAll("]]>","]]]]><![CDATA[>")+"]]>"),this.atText=!0):c instanceof v?(!this.mixed&&!this.atText&&this.indent(),s.push("<!--"+B(c.value)+"-->"),this.atText=!1):(!this.mixed&&!this.atText&&this.indent(),s.push(c.data?`<?${c.target} ${B(c.data)}?>`:`<?${c.target}?>`),this.atText=!1),p=!0;this.level--,!this.mixed&&p&&!this.atText&&this.indent(),this.mixed=i,s.push(`</${t.name}>`),this.atText=!1}static missing(t,n){let s=[],i=t.name,a=i.indexOf(":"),r=a>0?i.slice(0,a):"";if((n.get(r)??"")!==t.ns&&(r||t.ns||n.get(""))&&s.push([r,t.ns]),t.scope!==null)for(let[d]of t.attrs){let p=d.indexOf(":");if(p>0){let c=d.slice(0,p);if(c==="xmlns"||c==="xml")continue;let o=t.scope.get(c);o!==void 0&&n.get(c)!==o&&s.every(([m])=>m!==c)&&s.push([c,o])}}return s}};function H(e,t={}){let n=new L;if(t.declaration??!0){let i=t.standalone?` standalone="${t.standalone}"`:"";n.out.push(`<?xml version="1.0" encoding="utf-8"${i}?>`),n.atText=!1}let s=e instanceof T?e.root:e;return n.element(s,new Map([["xml",K]])),n.out.join("")}function J(e){let t=Buffer.from(e,"utf8"),n=new Uint8Array(t.length+3);return n.set(Z,0),n.set(t,3),n}function wt(e){let t=e instanceof T?e.standalone:null;return J(H(e,{standalone:t}))}function kt(e){return J(e)}var X=N,lt={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","\n":"&#xA;","\r":"&#xD;"},at=/[&<>"\n\r]/g,ct={"&":"&amp;","<":"&lt;",">":"&gt;"},ft=/[&<>]/g,W=class{out=[];element(t,n,s){let i=this.out;i.length&&!s&&i.push(X+" ".repeat(n-1)),i.push("<"+t.name);for(let[r,d]of t.attrs)i.push(` ${r}="${d.replace(at,p=>lt[p])}"`);if(t.empty&&!t.kids.length){i.push(" />");return}i.push(">");let a=!1;for(let r of t.kids)typeof r=="string"?(a=!0,i.push(r.replace(ft,d=>ct[d]))):r instanceof b?this.element(r,n+1,a):r instanceof E?(a=!0,i.push("<![CDATA["+r.value+"]]>")):(a||i.push(X+" ".repeat(n)),r instanceof v?i.push("<!--"+r.value+"-->"):i.push(r.data?`<?${r.target} ${r.data}?>`:`<?${r.target}?>`));a||i.push(X+" ".repeat(n-1)),i.push(`</${t.name}>`)}};function yt(e){let t=it(H(e,{declaration:!1})),n=new W;return n.element(t,1,!1),Buffer.from(n.out.join(""),"utf8")}export{dt as a,E as b,v as c,I as d,b as e,T as f,D as g,ht as h,pt as i,_ as j,gt as k,mt as l,u as m,j as n,it as o,xt as p,At as q,U as r,H as s,wt as t,kt as u,yt as v};
@@ -0,0 +1,2 @@
1
+ import { createRequire as __cr } from 'node:module'; const require = __cr(import.meta.url);
2
+ var _="1.0.0-beta.1";export{_ as a};
@@ -0,0 +1,2 @@
1
+ import { createRequire as __cr } from 'node:module'; const require = __cr(import.meta.url);
2
+ import{b as d,c as a}from"./chunk-4KP27OCL.js";import{c,g as u}from"./chunk-J4R6QXW7.js";var f="/api/data/v9.2/",g=/\r?\n\s+at /,y="\u2026";function p(e,n=1e3){if(!e)return e;let t=g.exec(e);t&&(e=e.slice(0,t.index)),e=e.trim();let r=[...e];return r.length<=n?e:r.slice(0,n-1).join("")+y}function s(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}var h=class extends d{name="dataverse";origin;host;constructor(n){super(),this.origin=(n.url??"").replace(/\/+$/,""),this.host=u(this.origin).host}scope(){return this.origin+"/.default"}url(n,t){let r;return n.includes("://")?r=n:n.startsWith("/")?r=this.origin+n:r=this.origin+f+n,t&&t.length&&(r+=(r.includes("?")?"&":"?")+c(t,"$'(),/:@*")),r}allowed(n){let t=u(n);return t.scheme==="https"&&!!t.host&&t.host===this.host}defaultHeaders(){return{Accept:"application/json","OData-MaxVersion":"4.0","OData-Version":"4.0"}}requestId(n){return n.header("x-ms-service-request-id")||n.header("req_id")}error(n){let t=null,r=null,l=null;if(n.body.length)try{let i=n.json(),o=s(i)&&s(i.error)?i.error:{};t=typeof o.code=="string"?o.code:null,r=p(typeof o.message=="string"?o.message:null)}catch{r=n.text.trim().slice(0,500)||null}if(n.status===401){let i=n.header("401_error_reason");r=r||(i?`unauthorised: ${i}`:"unauthorised"),l="the token was rejected; check the identity's tenant, then run: ppdo-cli auth login <identity>";let o=/login\.microsoftonline\.com\/([0-9a-fA-F-]{36})\//.exec(n.header("www-authenticate")??"");o&&(l=`the token was rejected; this environment's tenant is ${o[1]}. Check the identity's tenant, then run: ppdo-cli auth login <identity>`)}return a(this.name,n,t,r,this.requestId(n),l)}};function k(e){let n=e.isJson?e.json():null;if(!s(n))return null;let t=n["@odata.nextLink"];return typeof t=="string"&&t?t:null}function j(e){let n=e.isJson?e.json():null;return s(n)&&Array.isArray(n.value)?n.value:n!=null?[n]:[]}export{f as a,p as b,h as c,k as d,j as e};
@@ -0,0 +1,3 @@
1
+ import { createRequire as __cr } from 'node:module'; const require = __cr(import.meta.url);
2
+ var n=class extends Error{exitCode;hint;service;status;code;requestId;constructor(t,r={},o=1){super(t),this.name=new.target.name,this.exitCode=r.exitCode??o,this.hint=r.hint,this.service=r.service,this.status=r.status,this.code=r.code,this.requestId=r.requestId}envelope(){let t={error:this.message};return this.service!==void 0&&(t.service=this.service),this.status!==void 0&&(t.status=this.status),this.code!==void 0&&(t.code=this.code),this.requestId!==void 0&&(t.request_id=this.requestId),this.hint!==void 0&&(t.hint=this.hint),t}},c=class extends n{constructor(t,r={}){super(t,r,2)}},u=class extends n{constructor(t,r={}){super(t,r,3)}},d=class extends n{constructor(t,r={}){super(t,r,4)}},p=class extends n{constructor(t,r={}){super(t,r,5)}},a=class extends n{constructor(t,r={}){super(t,r,6)}},f=class extends n{constructor(t,r={}){super(t,r,7)}},g=class extends n{constructor(t,r={}){super(t,r,8)}},x="\\u",h=new RegExp("[^\0-\x7F]","g");function D(e,t){return JSON.stringify(e,null,t).replace(h,r=>x+r.charCodeAt(0).toString(16).padStart(4,"0"))}function l(e){return e.replace(h,t=>x+t.charCodeAt(0).toString(16).padStart(4,"0"))}function E(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function C(e,t=!0){let r=s(e);return t?l(r):r}function s(e){if(Array.isArray(e))return"["+e.map(t=>s(t===void 0?null:t)).join(", ")+"]";if(E(e)){let t=e.toJSON;if(typeof t=="function")return s(t.call(e));let r=[];for(let[o,i]of Object.entries(e))i===void 0||typeof i=="function"||r.push(JSON.stringify(o)+": "+s(i));return"{"+r.join(", ")+"}"}return JSON.stringify(e)??"null"}function O(e){return process.stderr.write(C(e.envelope())+`
3
+ `),e.exitCode}export{n as a,c as b,u as c,d,p as e,a as f,f as g,g as h,D as i,C as j,O as k};
@@ -0,0 +1,2 @@
1
+ import { createRequire as __cr } from 'node:module'; const require = __cr(import.meta.url);
2
+ var g=Object.create;var e=Object.defineProperty;var h=Object.getOwnPropertyDescriptor;var i=Object.getOwnPropertyNames;var j=Object.getPrototypeOf,k=Object.prototype.hasOwnProperty;var m=(a=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(a,{get:(b,c)=>(typeof require<"u"?require:b)[c]}):a)(function(a){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+a+'" is not supported')});var n=(a,b)=>()=>(b||a((b={exports:{}}).exports,b),b.exports),o=(a,b)=>{for(var c in b)e(a,c,{get:b[c],enumerable:!0})},l=(a,b,c,f)=>{if(b&&typeof b=="object"||typeof b=="function")for(let d of i(b))!k.call(a,d)&&d!==c&&e(a,d,{get:()=>b[d],enumerable:!(f=h(b,d))||f.enumerable});return a};var p=(a,b,c)=>(c=a!=null?g(j(a)):{},l(b||!a||!a.__esModule?e(c,"default",{value:a,enumerable:!0}):c,a));export{m as a,n as b,o as c,p as d};
@@ -0,0 +1,2 @@
1
+ import { createRequire as __cr } from 'node:module'; const require = __cr(import.meta.url);
2
+ var r=new Set(['"',"<",">","|",":","*","?","\\","/"]);for(let n=0;n<32;n++)r.add(String.fromCharCode(n));function s(n){if(!n)return n;let e=null;for(let t=0;t<n.length;t++){let i=n[t];r.has(i)?(e??=n.slice(0,t),e+="_"):e!==null&&(e+=i)}return e??n}function o(...n){let e="";for(let t of n){if(t==null)throw new Error("path part is null");t=t.replaceAll("\\","/"),t&&(t.startsWith("/")&&(t=t.replace(/^\/+/,""),!t)||(e&&!e.endsWith("/")&&(e+="/"),e+=t))}return e}function l(n){let e=Math.max(n.lastIndexOf("/"),n.lastIndexOf("\\"));return n.slice(e+1)}function u(n){let e=Math.max(n.lastIndexOf("/"),n.lastIndexOf("\\"));return e>=0?n.slice(0,e):""}function f(n){let e=l(n),t=e.lastIndexOf(".");return t<0||t===e.length-1?"":e.slice(t)}function c(n,e){let t=l(n),i=t.lastIndexOf(".");return i>=0&&(n=n.slice(0,n.length-t.length+i)),n+e}function g(n){return n.replace(/^[/\\]+/,"")}function d(n){if(n.replaceAll("\\","/").split("/").includes("..")||n.length>1&&n[1]===":")throw new Error(`path leaves the solution folder: ${n}`);return n}export{s as a,o as b,l as c,u as d,f as e,c as f,g,d as h};
@@ -0,0 +1,2 @@
1
+ import { createRequire as __cr } from 'node:module'; const require = __cr(import.meta.url);
2
+ import{a}from"./chunk-WXOTXJNG.js";async function g(l,s,t={}){let i=t.timeout??3600,n=t.interval??3,m=t.maxInterval??15,c=t.hint??"raise --timeout, or check later with the job/run id",u=performance.now()/1e3+i,o=null;for(;;){let r=await l();if(s(r))return r;if(t.describe&&t.log){let e=t.describe(r);e!==o&&(t.log(e),o=e)}if(performance.now()/1e3+n>u)throw new a(`still running after ${Math.trunc(i)}s`,{hint:c});await new Promise(e=>setTimeout(e,n*1e3)),n=Math.min(m,n*1.5)}}export{g as a};
@@ -0,0 +1,2 @@
1
+ import { createRequire as __cr } from 'node:module'; const require = __cr(import.meta.url);
2
+ import{r as o}from"./chunk-BALEFXOL.js";import"./chunk-WXOTXJNG.js";import"./chunk-ZHHVG47C.js";function r(m){o(m,"commands","L","list every command with its class (R/W/D/M/L)").argument("[group]","only this command group, e.g. dv or ado").argKey("group","only").option("--json","same as -o json (the default)").handler(async a=>(await import("./run-H2OLE76P.js")).commands(a))}export{r as register};
@@ -0,0 +1,2 @@
1
+ import { createRequire as __cr } from 'node:module'; const require = __cr(import.meta.url);
2
+ import{a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p}from"./chunk-PYTSDUPY.js";import"./chunk-TXVNEV3M.js";import"./chunk-UCTMKA2J.js";import"./chunk-BALEFXOL.js";import"./chunk-J4R6QXW7.js";import"./chunk-5SBBTR3Y.js";import"./chunk-S4KF5Z3S.js";import"./chunk-WXOTXJNG.js";import"./chunk-ZHHVG47C.js";export{e as DEPENDENCY_TYPES,d as LABELS,b as METADATA_LOGICAL,a as METADATA_NAMES,c as TABLES,f as UNPUBLISHED,k as changes,n as customizable,m as dependencies,j as label,g as layerName,l as layers,p as removeActive,i as tableMeta,h as tableName,o as unpublished};
@@ -0,0 +1,2 @@
1
+ import { createRequire as __cr } from 'node:module'; const require = __cr(import.meta.url);
2
+ import{$,$a,A,Aa,B,Ba,C,Ca,D,Da,E,Ea,F,Fa,G,Ga,H,Ha,I,Ia,J,Ja,K,Ka,L,La,M,Ma,N,Na,O,Oa,P,Pa,Q,Qa,R,Ra,S,Sa,T,Ta,U,Ua,V,Va,W,Wa,X,Xa,Y,Ya,Z,Za,_,_a,a,aa,ab,b,ba,bb,c,ca,cb,d,da,db,e,ea,eb,f,fa,fb,g,ga,gb,h,ha,hb,i,ia,ib,j,ja,jb,k,ka,l,la,m,ma,n,na,o,oa,p,pa,q,qa,r,ra,s,sa,t,ta,u,ua,v,va,w,wa,x,xa,y,ya,z,za}from"./chunk-TZSB4PR7.js";import"./chunk-ZNJ4DRCA.js";import"./chunk-WIA546AL.js";import"./chunk-ZHHVG47C.js";export{K as AIMODEL,Pa as AIModelProcessor,J as AITEMPLATE,Qa as AITemplateProcessor,q as APPMODULE,r as APPMODULESITEMAP,L as ATTRIMAGE,cb as AppModuleProcessor,Ga as AppModuleSiteMapProcessor,Sa as AttributeImageProcessor,X as BASE_UNSHARDED,G as CANVASAPP,x as CHANNELPROFILE,n as COMPLEXCONTROL,m as CONNECTIONROLE,H as CONNECTOR,o as CUSTOMCONTROL,hb as CanvasAppProcessor,Fa as ChannelProfileProcessor,na as Collection,ma as Comp,wa as ComplexControlProcessor,Na as ConnectionRoleProcessor,fb as ConnectorProcessor,_a as CustomControlProcessor,j as DASHBOARD,y as DATAPROVIDER,z as DATASOURCE,F as DIALOG,ra as DashboardProcessor,za as DataProviderProcessor,Aa as DataSourceProcessor,ta as DialogProcessor,a as ENTITY,M as ENTITYIMAGE,h as ENTITYMAP,A as ENTITYPRIVILEGE,I as ENVVAR,Ra as EntityImageProcessor,Ia as EntityMapProcessor,$a as EntityPrivilegeProcessor,Ta as EntityProcessor,ab as EnvVarProcessor,p as FIELDSECURITY,Ha as FieldSecurityProcessor,T as GENERIC,eb as GenericProcessor,O as ICDASHBOARD,sa as ICDashboardProcessor,xa as ImportMapsProcessor,W as KNOWN_FOLDERS,V as LAYOUT,v as MOBILEOFFLINE,Da as MobileOfflineProcessor,b as OPTIONSET,Q as ORGSETTINGS,pa as OptionSetProcessor,gb as OrgSettingsProcessor,s as PLUGINASSEMBLY,w as PROFILERULE,Y as PackError,Xa as PluginAssemblyProcessor,oa as Processor,Ea as ProfileRuleProcessor,c as RELATIONSHIP,f as REPORT,i as RIBBON,d as ROLE,jb as Registry,Ua as RelationshipProcessor,Za as ReportProcessor,Ka as RibbonProcessor,qa as RoleProcessor,C as SDKFILTER,B as SDKMESSAGE,t as SDKSTEP,u as SERVICEENDPOINT,S as SERVICEPLANAPPS,R as SERVICEPLANS,l as SITEMAP,ib as SPECIFIC,D as STOREDPROC,P as SYNCPROFILE,va as SdkMessageProcessor,ua as SdkStepProcessor,Ja as ServiceEndpointProcessor,Ma as ServicePlanAppsProcessor,La as ServicePlanProcessor,Oa as SiteMapProcessor,Ya as StoredProcedureProcessor,Ca as SyncProfileProcessor,N as TEAMTEMPLATE,g as TEMPLATE,U as TYPE_NAMES,Ba as TeamTemplateProcessor,bb as TemplateProcessor,k as WEBRESOURCE,E as WEBWIZARD,e as WORKFLOW,Va as WebResourceProcessor,ya as WebWizardProcessor,Wa as WorkflowProcessor,ka as attr,ga as b64decode,ha as braced,ia as child,ja as childValue,ca as compareStr,ba as compareVersion,ea as first,fa as guid,la as isUnmodified,db as probeName,aa as pyInt,$ as pyRepr,_ as pyStr,Z as pyStrip,da as sortByKeys};
@@ -0,0 +1,2 @@
1
+ import { createRequire as __cr } from 'node:module'; const require = __cr(import.meta.url);
2
+ import{A,B,C,D,E,F,G,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z}from"./chunk-STWQDANK.js";import"./chunk-TQLZ3TRU.js";import"./chunk-S4KF5Z3S.js";import"./chunk-WXOTXJNG.js";import"./chunk-ZHHVG47C.js";export{s as Config,k as DEFAULT_CLIENT_ID,m as ENV_NAME_RE,h as ENV_VARS,q as Environment,p as Group,o as Identity,g as LABELS,b as METHODS,c as MODES,a as NAME_RE,l as ORG_RE,i as PIN_FILE,d as RANK,x as Resolved,j as SECRET_ENV,e as SERVICES,f as SERVICE_ALIASES,B as appIdentity,A as appRequested,n as checkName,C as devopsUrlScope,v as findPin,w as gitRoot,t as grants,y as isUrl,G as normaliseDataverseUrl,r as readJsonFile,E as resolveApp,z as resolveEnv,F as resolveIdentity,D as urlEnvironment,u as widening};
@@ -0,0 +1,2 @@
1
+ import { createRequire as __cr } from 'node:module'; const require = __cr(import.meta.url);
2
+ import{C as _,D as M,E as D,I as G,P as L,m as j,n as h,o as s,p as u,q as v,r as N,t as P,w as O}from"./chunk-TXVNEV3M.js";import"./chunk-UCTMKA2J.js";import"./chunk-BALEFXOL.js";import{b as T,c as $,d as b}from"./chunk-4KP27OCL.js";import{c as I,g as q}from"./chunk-J4R6QXW7.js";import{b as E}from"./chunk-5SBBTR3Y.js";import"./chunk-WMDKJRDC.js";import"./chunk-H4OY4EFC.js";import"./chunk-TQLZ3TRU.js";import{e as A}from"./chunk-S4KF5Z3S.js";import"./chunk-WXOTXJNG.js";import"./chunk-ZHHVG47C.js";var z="api.powerapps.com",J="2016-11-01";function B(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)}var R=class extends T{name="powerapps";scope(){return"https://service.powerapps.com//.default"}url(e,t){let r=e.includes("://")?e:`https://${z}/${e.replace(/^\/+/,"")}`,a=[...t??[]];return!r.includes("api-version=")&&!a.some(([c])=>c==="api-version")&&a.push(["api-version",J]),a.length&&(r+=(r.includes("?")?"&":"?")+I(a,"$'(),/:@*")),r}allowed(e){let t=q(e);return t.scheme==="https"&&t.host===z}requestId(e){return e.header("x-ms-request-id")||e.header("x-ms-correlation-request-id")}error(e){let t=null,r=null;try{let a=e.json(),c=B(a)&&B(a.error)?a.error:{};t=typeof c.code=="string"?c.code:null,r=typeof c.message=="string"?c.message:null}catch{r=e.text.trim().slice(0,300)||null}return $(this.name,e,t,r,this.requestId(e))}};async function F(n,e){let t=new R,r=e.identity;if(!r)throw new Error("the Dataverse client has no identity");let{getToken:a}=await import("./provider-FN7TXWRE.js"),c=new b(t,n,d=>a(r,t.scope(),{forceRefresh:d,log:p=>n.log(p)}));return c.target=e.target,c.identity=r,c}function K(n){let e=n.trim(),t=e.slice(e.lastIndexOf("/")+1);return t.startsWith("shared_")?t:"shared_"+t}async function re(n){let e=n.args,t=await _(n),r=D(await M(n,t,"GET","RetrieveCurrentOrganization(AccessType=Microsoft.Dynamics.CRM.EndpointAccessType'Default')")),c=u(r.Detail).EnvironmentId,[d]=await G(n,t,"connectionreferences",[["$select","connectionreferencelogicalname,connectionid"],["$filter","connectionid ne null"]],null,null),p=new Map;for(let o of d){let i=String(o.connectionid).toLowerCase();p.has(i)||p.set(i,[]),p.get(i).push(o.connectionreferencelogicalname)}let f=await F(n,t),C=L(e.connector),x=C?`providers/Microsoft.PowerApps/apis/${K(C)}/connections`:"providers/Microsoft.PowerApps/connections";E(n,f,"GET",x,null);let H=[["$filter",`environment eq '${c}'`]],g=[],S=await f.request("GET",x,{params:H});for(;;){let o=u(S.json());g=g.concat(v(o.value));let i=o.nextLink;if(!i)break;S=await f.request("GET",String(i))}let l=[];for(let o of g){let i=u(s(o,"properties")),V=v(i.statuses).map(w=>s(w,"status")).filter(w=>j(w)),y=u(i.createdBy),k=s(i,"apiId")||"",W={id:s(o,"name"),connector:k.slice(k.lastIndexOf("/")+1)||null,display_name:s(i,"displayName"),status:V.join(", ")||null,account:s(i,"accountName"),created_by:h(h(s(y,"userPrincipalName"),s(y,"email")),s(y,"displayName")),created:s(i,"createdTime"),references:p.get(String(s(o,"name")||"").toLowerCase())??[]};l.push(N(W))}e.unused&&(l=l.filter(o=>!o.references.length)),l=P(l,o=>[String(s(o,"connector")||""),String(s(o,"display_name")||"").toLowerCase()]);let m=O(e);m!==null&&l.length>m&&(A(`showing the first ${m} connections; pass --limit n or --all for more`),l=l.slice(0,m)),await n.emit(l)}export{K as connectorName,re as list};
@@ -0,0 +1,2 @@
1
+ import { createRequire as __cr } from 'node:module'; const require = __cr(import.meta.url);
2
+ import{d as P,e as T,f as k}from"./chunk-OXZG44O5.js";import"./chunk-RC5VPVGC.js";import"./chunk-ZUXLC5VX.js";import{C as l,D as g,E as j,F as E,J as L,P as w,b as v,d as R,e as $,f as C,i as b,o as s,q as x,w as _}from"./chunk-TXVNEV3M.js";import"./chunk-UCTMKA2J.js";import"./chunk-BALEFXOL.js";import"./chunk-J4R6QXW7.js";import{b as p}from"./chunk-5SBBTR3Y.js";import"./chunk-S4KF5Z3S.js";import{a as y,b as u,d as m}from"./chunk-WXOTXJNG.js";import"./chunk-ZHHVG47C.js";var I="connectionreferencelogicalname,connectionreferencedisplayname,connectorid,connectionid,_customconnectorid_value,ismanaged,statecode,description,modifiedon";function q(n){return n.slice(n.lastIndexOf("/")+1)}function d(n,o=!1){let e=s(n,"connectorid")||"",t={name:s(n,"connectionreferencelogicalname"),display_name:s(n,"connectionreferencedisplayname"),connector:q(e)||null,connection:s(n,"connectionid"),managed:s(n,"ismanaged"),id:s(n,"connectionreferenceid")};if(o){Object.assign(t,{connector_id:e||null,custom_connector_id:s(n,"_customconnectorid_value"),description:s(n,"description"),active:s(n,"statecode")===0,modified:s(n,"modifiedon")});let i={};for(let[c,r]of Object.entries(t))(r!==null||c==="connection")&&(i[c]=r);t=i}return t}async function h(n,o,e){let t=v(e),i=t?"connectionreferenceid":"connectionreferencelogicalname",c=t?R(e):$(e),r=await g(n,o,"GET","connectionreferences",{params:[["$select",I],["$filter",`${i} eq ${c}`]]}),a=x(j(r).value);if(!a.length)throw new m(`no connection reference '${e}'`,{service:"dataverse",hint:"run: ppdo-cli dv connref list --name '*<part of the name>*'"});return a[0]}async function U(n){let o=n.args,e=await l(n);p(n,e,"GET","connectionreferences",null);let t=null,i=w(o.solution);i&&(t=await k(n,e,P(i),await T(n,e,"connectionreference")));let c=[],r=w(o.name);r&&c.push(b("connectionreferencelogicalname",r)),o.unbound&&c.push("connectionid eq null");let a=[["$select",I],["$orderby","connectionreferencelogicalname"]];c.length&&a.push(["$filter",c.join(" and ")]);let S=await L(n,e,"connectionreferences","connectionreferenceid",t,a,null,_(o),"connection references",f=>String(s(f,"connectionreferencelogicalname")||"").toLowerCase());await n.emit(S.map(f=>d(f)))}async function M(n){let o=await l(n);await n.emit(d(await h(n,o,String(n.args.name)),!0))}function A(n,o){let e=(C(n).split("?",1)[0]??"").split("/").filter(c=>c),t=e[e.length-1];if(t!==void 0&&["details","edit"].includes(t.toLowerCase())&&e.pop(),!e.length)throw new u("--connection is empty");let i=e.length>=2?e[e.length-2]:"";if(i.startsWith("shared_")&&o&&i.toLowerCase()!==o.toLowerCase())throw new u(`'${n}' is a ${i} connection; this reference needs ${o}`);return e[e.length-1]}async function W(n){let o=n.args,e=await l(n);p(n,e,"PATCH","connectionreferences",Buffer.from("{}"));let t=await e.lookups(()=>h(n,e,String(o.name))),i=d(t).connector,c=A(String(o.connection),i);try{await g(n,e,"PATCH",`connectionreferences(${t.connectionreferenceid})`,{body:E({connectionid:c}),headers:{"If-Match":"*"}})}catch(r){throw!(r instanceof y)||r.exitCode===0||!r.message.includes("ConnectionNotFound")&&!r.message.includes("RouteNotFound")?r:new m(`no connection '${c}' for ${i??"None"} that you can use`,{service:"dataverse",hint:"the connection must exist in this environment, be for the same connector, and be yours or shared with you; its id is the last part of its URL in Power Automate > Connections"})}await n.emit(d(await h(n,e,t.connectionreferenceid),!0))}export{A as connectionId,h as find,M as get,U as list,W as set,d as shape};
@@ -0,0 +1,7 @@
1
+ import { createRequire as __cr } from 'node:module'; const require = __cr(import.meta.url);
2
+ import{C as E,D as $,E as I,F as O,I as ue,J as $e,K as Y,O as Re,P as f,a as xe,b as se,d as ae,e as B,f as re,i as le,m as ce,n as U,o as m,p as ve,q as _,r as R,t as F,w as V}from"./chunk-TXVNEV3M.js";import"./chunk-UCTMKA2J.js";import{y as he}from"./chunk-BALEFXOL.js";import{a as be}from"./chunk-J4R6QXW7.js";import{b as q}from"./chunk-5SBBTR3Y.js";import"./chunk-S4KF5Z3S.js";import{a as ye,b as v,d as oe}from"./chunk-WXOTXJNG.js";import"./chunk-ZHHVG47C.js";import{randomUUID as De}from"node:crypto";import{readFileSync as He,writeFileSync as qe}from"node:fs";import{extname as Ue}from"node:path";var M=class extends Error{},de=class{tag;attrib;text=null;tail=null;children=[];constructor(t,i){this.tag=t,this.attrib=i??new Map}get(t,i=null){return this.attrib.has(t)?this.attrib.get(t):i}set(t,i){this.attrib.set(t,i)}[Symbol.iterator](){return this.children[Symbol.iterator]()}find(t){return this.findall(t)[0]??null}findall(t){let i=[this];for(let n of t.split("/")){let o=[];for(let s of i)for(let a of s.children)(n==="*"||a.tag===n)&&o.push(a);i=o}return i}*iter(t){(t===void 0||this.tag===t)&&(yield this);for(let i of this.children)yield*i.iter(t)}},Ee={amp:"&",lt:"<",gt:">",quot:'"',apos:"'"};function z(e){return e===" "||e===" "||e===`
3
+ `||e==="\r"}function G(e){return e!==void 0&&(/[A-Za-z0-9_.:-]/.test(e)||e.charCodeAt(0)>=183)}function L(e){let t=e.replace(/\r\n?/g,`
4
+ `),i=t.length,n=(c,x)=>{let l=t.slice(0,Math.min(x,i)),g=l.split(`
5
+ `).length,b=x-(l.lastIndexOf(`
6
+ `)+1);throw new M(`${c}: line ${g}, column ${b}`)},o=(c,x,l)=>{let g="";for(let b=0;b<c.length;b++){let k=c[b];if(k==="&"){let S=c.indexOf(";",b+1);S<0&&n("not well-formed (invalid token)",x+b);let j=c.slice(b+1,S);if(j.startsWith("#")){let N=j[1]==="x"?parseInt(j.slice(2),16):parseInt(j.slice(1),10);Number.isFinite(N)||n("not well-formed (invalid token)",x+b),g+=String.fromCodePoint(N)}else j in Ee?g+=Ee[j]:n("undefined entity",x+b);b=S}else k==="<"&&l?n("not well-formed (invalid token)",x+b):l&&(k===" "||k===`
7
+ `)?g+=" ":g+=k}return g},s=[],a=[new Map],r=null,u=null,d=!1,y=c=>{c&&u!==null&&(d?u.tail=(u.tail??"")+c:u.text=(u.text??"")+c)},w=(c,x,l)=>{let g=c.indexOf(":");if(g>0){let k=x.get(c.slice(0,g));return k!==void 0?`{${k}}${c.slice(g+1)}`:c}if(l)return c;let b=x.get("");return b?`{${b}}${c}`:c},h=0;if(t.startsWith("<?xml")){let c=t.indexOf("?>");c<0&&n("unclosed token",0),h=c+2}for(;h<i;){let c=t.indexOf("<",h),x=c<0?i:c;if(x>h){let p=t.slice(h,x);s.length?y(o(p,h,!1)):p.trim()&&n(r?"junk after document element":"syntax error",h+p.search(/\S/))}if(c<0)break;if(!s.length&&r&&!t.startsWith("<!--",c)&&!t.startsWith("<?",c)&&n("junk after document element",c),t.startsWith("<!--",c)){let p=t.indexOf("-->",c+4);p<0&&n("unclosed token",c),h=p+3;continue}if(t.startsWith("<![CDATA[",c)){let p=t.indexOf("]]>",c+9);p<0&&n("unclosed CDATA section",c),s.length||n("syntax error",c),y(t.slice(c+9,p)),h=p+3;continue}if(t.startsWith("<?",c)){let p=t.indexOf("?>",c+2);p<0&&n("unclosed token",c),h=p+2;continue}if(t.startsWith("<!",c)&&n("not well-formed (invalid token)",c),t[c+1]==="/"){let p=c+2;for(;p<i&&G(t[p]);)p++;let P=t.slice(c+2,p);for(;p<i&&z(t[p]);)p++;p>=i&&n("unclosed token",c),t[p]!==">"&&n("not well-formed (invalid token)",p);let A=s[s.length-1];(!A||A.tag!==w(P,a[a.length-1],!1))&&n("mismatched tag",c+2),u=s.pop(),d=!0,a.pop(),h=p+1;continue}let l=c+1;for((!G(t[l])||/[0-9.\-]/.test(t[l]))&&n("not well-formed (invalid token)",l);l<i&&G(t[l]);)l++;let g=t.slice(c+1,l),b=[],k=!1;for(;;){let p=l;for(;l<i&&z(t[l]);)l++;if(l>=i&&n("unclosed token",c),t[l]===">"){l++;break}if(t[l]==="/"){t[l+1]!==">"&&n("not well-formed (invalid token)",l),k=!0,l+=2;break}(l===p||!G(t[l]))&&n("not well-formed (invalid token)",l);let P=l;for(;l<i&&G(t[l]);)l++;let A=t.slice(P,l);for(;l<i&&z(t[l]);)l++;for(t[l]!=="="&&n("not well-formed (invalid token)",l),l++;l<i&&z(t[l]);)l++;let ne=t[l];ne!=='"'&&ne!=="'"&&n("not well-formed (invalid token)",l);let ie=t.indexOf(ne,l+1);ie<0&&n("unclosed token",c),b.some(([Xe])=>Xe===A)&&n("duplicate attribute",P),b.push([A,o(t.slice(l+1,ie),l+1,!0)]),l=ie+1}let S=a[a.length-1];if(b.some(([p])=>p==="xmlns"||p.startsWith("xmlns:"))){S=new Map(S);for(let[p,P]of b)p==="xmlns"?S.set("",P):p.startsWith("xmlns:")&&S.set(p.slice(6),P)}let j=new Map;for(let[p,P]of b)p!=="xmlns"&&!p.startsWith("xmlns:")&&j.set(w(p,S,!0),P);let N=new de(w(g,S,!1),j);s.length?s[s.length-1].children.push(N):r===null?r=N:n("junk after document element",c),u=N,d=!1,k?d=!0:(s.push(N),a.push(S)),h=l}return(s.length||r===null)&&n("no element found",i),r}function ke(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function Se(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/\r/g,"&#13;").replace(/\n/g,"&#10;").replace(/\t/g,"&#09;")}function Te(e){let t=new Map,i=s=>{if(!s.startsWith("{"))return s;let a=s.indexOf("}"),r=s.slice(1,a),u=t.get(r);return u===void 0&&(u=`ns${t.size}`,t.set(r,u)),`${u}:${s.slice(a+1)}`};for(let s of e.iter()){i(s.tag);for(let a of s.attrib.keys())i(a)}let n=[],o=(s,a)=>{if(n.push("<"+i(s.tag)),a)for(let[r,u]of[...t].sort((d,y)=>d[1]<y[1]?-1:1))n.push(` xmlns:${u}="${Se(r)}"`);for(let[r,u]of s.attrib)n.push(` ${i(r)}="${Se(u)}"`);if(s.text||s.children.length){n.push(">"),s.text&&n.push(ke(s.text));for(let r of s.children)o(r,!1);n.push(`</${i(s.tag)}>`)}else n.push(" />");s.tail&&!a&&n.push(ke(s.tail))};return o(e,!0),n.join("")}var Ce=new Map([[0,"public"],[1,"advanced-find"],[2,"associated"],[4,"quick-find"],[8,"reporting"],[16,"offline-filters"],[64,"lookup"],[128,"appointment-book"],[256,"outlook-filters"],[512,"address-book-filters"],[1024,"main-without-subject"],[2048,"other"],[4096,"interactive-workflow"],[8192,"offline-template"],[16384,"custom-defined"]]),Oe=new Map([[0,"dashboard"],[2,"main"],[5,"mobile"],[6,"quick-view"],[7,"quick-create"],[11,"card"],[12,"main-interactive"]]),je={main:2,"quick-create":7,"quick-view":6,card:11},pe=new Map([[1,"html"],[2,"css"],[3,"js"],[4,"xml"],[5,"png"],[6,"jpg"],[7,"gif"],[8,"xap"],[9,"xsl"],[10,"ico"],[11,"svg"],[12,"resx"]]),Ve={".htm":1,".html":1,".css":2,".js":3,".xml":4,".png":5,".jpg":6,".jpeg":6,".gif":7,".xap":8,".xsl":9,".xslt":9,".ico":10,".svg":11,".resx":12},Ye=new Set([1,2,3,4,9,11,12]),ze="{4273EDBD-AC1D-40d3-9FB2-095C621B552D}",Me="name,returnedtypecode,querytype,isdefault,statecode,ismanaged,description,savedqueryid",Ne="name,objecttypecode,type,formactivationstate,isdefault,ismanaged,description,formid",Ie="name,displayname,webresourcetype,ismanaged,description,modifiedon,webresourceid",D=Buffer.from("{}");function K(e,t){for(let[i,n]of e)if(n===t)return i;throw new Error(`unknown type ${t}`)}function ge(e,t){return typeof t=="number"&&e.has(t)?e.get(t):t}function T(e){return e.publish===!1}function W(e){return typeof e!="string"||!e?null:Re(he(e).toString("utf8"))}function me(e,t,i){let n;try{n=L(re(e))}catch(o){throw o instanceof M?new v(`the ${i} is not well-formed XML: ${o.message}`):o}if(n.tag!==t)throw new v(`the ${i} must have a <${t}> root, not <${n.tag}>`);return n}async function C(e,t,i,n,o){let s=await $(e,t,"GET",`${i}(${n})/Microsoft.Dynamics.CRM.RetrieveUnpublished()`,{params:[["$select",o]]});return I(s)}async function Q(e,t,i){xe(i,"table logical name");let n=I(await $(e,t,"GET",`EntityDefinitions(LogicalName='${i}')`,{params:[["$select","LogicalName,EntitySetName,ObjectTypeCode,PrimaryIdAttribute,PrimaryNameAttribute"]]})),o=I(await $(e,t,"GET",`EntityDefinitions(LogicalName='${i}')/Attributes`,{params:[["$select","LogicalName"]]}));return n.attributes=new Set(_(o.value).map(s=>s.LogicalName)),n}async function H(e,t,i){let n=[];i.table&&n.push(`<entities><entity>${i.table}</entity></entities>`),i.webresource&&n.push(`<webresources><webresource>{${i.webresource}}</webresource></webresources>`);let o={ParameterXml:"<importexportxml>"+n.join("")+"</importexportxml>"};await $(e,t,"POST","PublishXml",{body:O(o)})}async function Be(e,t,i,n,o,s,a,r,u){let d=se(a)?`${n} eq ${ae(a)}`:`name eq ${B(a)}`;r&&(d+=` and ${o} eq ${B(r)}`);let y=_(I(await $(e,t,"GET",i,{params:[["$select",s],["$filter",d]]})).value);if(!y.length)throw new oe(`no ${u} '${a}'`+(r?` on ${r}`:""),{service:"dataverse",hint:`run: ppdo-cli dv ${u} list <table>`});if(y.length>1)throw new v(`${y.length} ${u}s are named '${a}'`,{hint:"pass --table, or use an id: "+y.slice(0,5).map(w=>w[n]).join(", ")});return y[0]}async function we(e,t,i){if(!i)return{};let{find:n}=await import("./solution-3WUUDYF3.js");return await n(e,t,i),{"MSCRM.SolutionUniqueName":i}}function Je(e){let t=e.get("attribute"),i=e.get("operator"),n=e.findall("value").map(a=>a.text),o=e.get("value")!==null?e.get("value"):n.length?n.map(a=>a??"None").join(","):null;return`${e.get("entityname")?`${e.get("entityname")}.`:""}${t??"None"} ${i??"None"}`+(o!==null?` ${o}`:"")}function Le(e){if(e===null)return null;let t=` ${e.get("type","and")} `;return e.children.filter(n=>n.tag==="condition"||n.tag==="filter").map(n=>n.tag==="condition"?Je(n):`(${Le(n)??"None"})`).filter(n=>n).join(t)||null}function Ae(e,t){let i={};try{let s=L(e||"").find("entity");s!==null&&(i.sort=s.findall("order").map(a=>(a.get("descending")==="true"?"-":"")+(a.get("attribute")||a.get("alias")||"")),i.filter=Le(s.find("filter")),i.links=[...s.iter("link-entity")].map(a=>({table:a.get("name"),alias:a.get("alias"),from:a.get("from"),to:a.get("to"),type:a.get("link-type","inner")})))}catch(o){if(!(o instanceof M))throw o;i.fetch_error="not well-formed"}try{let o=L(t||"");i.columns=[...o.iter("cell")].map(s=>{let a=s.get("width");return{name:s.get("name"),width:/^[0-9]+$/.test(a||"")?parseInt(a,10):a}})}catch(o){if(!(o instanceof M))throw o;i.layout_error="not well-formed"}let n={};for(let[o,s]of Object.entries(i))s!==null&&!(Array.isArray(s)&&!s.length)&&(n[o]=s);return n}async function _e(e,t,i,n,o){let a=me(n,"fetch","FetchXML").find("entity");if(a===null||a.get("name")!==i)throw new v(`the FetchXML's <entity name> must be ${i}`);let r=me(o,"grid","layout XML"),u=new Set(a.findall("attribute").map(g=>g.get("name"))),d=a.find("all-attributes")!==null,y=new Set([...a.iter("link-entity")].map(g=>g.get("alias")).filter(g=>g)),w=[];for(let g of r.iter("cell")){let b=g.get("name")||"";b.includes(".")?y.has(b.slice(0,b.indexOf(".")))||w.push(b):!d&&!u.has(b)&&w.push(b)}if(w.length)throw new v("layout columns not in the query: "+w.join(", "),{hint:"add <attribute name=...> (or the link-entity alias) to the FetchXML"});let h=e,c=t,x=await Q(h,c,i),l=L(re(n));for(let g of["page","paging-cookie","top"])l.attrib.delete(g);l.set("count","1");try{await c.request("GET",`${x.EntitySetName}?fetchXml=`+be(Te(l),""))}catch(g){throw g instanceof ye?new v(`the FetchXML doesn't run: ${g.message}`):g}}function ee(e){return R({name:m(e,"name"),table:m(e,"returnedtypecode"),type:ge(Ce,m(e,"querytype")),default:U(m(e,"isdefault"),null),state:m(e,"statecode")===1?"inactive":"active",managed:m(e,"ismanaged"),id:m(e,"savedqueryid")})}async function ft(e){let t=e.args,i=await E(e);q(e,i,"GET","savedqueries",null);let n=[`returnedtypecode eq ${B(String(t.table))}`];f(t.type)&&n.push(`querytype eq ${K(Ce,f(t.type))}`),f(t.name)&&n.push(le("name",f(t.name)));let[o]=await ue(e,i,"savedqueries",[["$select",Me],["$filter",n.join(" and ")],["$orderby","name"]],null,V(t),"views");await e.emit(o.map(ee))}function J(e,t,i,n){return Be(e,t,"savedqueries","savedqueryid","returnedtypecode",Me,i,n,"view")}function Fe(e,t){qe(e,t,"utf8")}async function pt(e){let t=e.args,i=await E(e),n=await J(e,i,String(t.view),f(t.table)),o=await C(e,i,"savedqueries",n.savedqueryid,"fetchxml,layoutxml,name,description"),s={...ee(n),description:m(o,"description"),...Ae(m(o,"fetchxml"),m(o,"layoutxml"))};for(let[a,r]of[[f(t.saveFetchxml),"fetchxml"],[f(t.saveLayoutxml),"layoutxml"]])a&&(Fe(a,m(o,r)||""),(s.saved??=[]).push(a));await e.emit(R(s))}function Ze(e){let t=e.PrimaryNameAttribute,i=e.PrimaryIdAttribute,n=e.ObjectTypeCode,o='<filter type="and"><condition attribute="statecode" operator="eq" value="0" /></filter>',s=`<fetch version="1.0" mapping="logical"><entity name="${e.LogicalName}"><attribute name="${t}" /><attribute name="${i}" /><order attribute="${t}" descending="false" />${o}</entity></fetch>`;e.attributes.has("statecode")||(s=s.split(o).join(""));let a=`<grid name="resultset" object="${n}" jump="${t}" select="1" icon="1" preview="1"><row name="result" id="${i}"><cell name="${t}" width="300" /></row></grid>`;return[s,a]}async function gt(e){let t=e.args,i=String(t.table),n=await E(e);q(e,n,"POST","savedqueries",D);let o=W(t.fetchxml),s=W(t.layoutxml),a=await n.lookups(async()=>{let y=await Q(e,n,i);if(f(t.copy)){let w=await J(e,n,f(t.copy),i),h=await C(e,n,"savedqueries",w.savedqueryid,"fetchxml,layoutxml");o=o||m(h,"fetchxml"),s=s||m(h,"layoutxml")}if(!o||!s){let[w,h]=Ze(y);o=o||w,s=s||h}return await _e(e,n,i,o,s),we(e,n,f(t.solution))}),r={name:t.name,returnedtypecode:i,querytype:0,fetchxml:o,layoutxml:s};f(t.description)&&(r.description=t.description);let u=await $(e,n,"POST","savedqueries",{body:O(r),headers:a}),d=Y(u);T(t)||await H(e,n,{table:i}),await e.emit({...ee(await J(e,n,String(d),null)),published:!T(t)})}async function wt(e){let t=e.args,i=f(t.name),n=f(t.description);if(!(i||n!==null||t.fetchxml||t.layoutxml))throw new v("nothing to update",{hint:"pass --name, --description, --fetchxml or --layoutxml"});let o=await E(e);q(e,o,"PATCH","savedqueries",D);let s=W(t.fetchxml),a=W(t.layoutxml),r=await o.lookups(async()=>{let y=await J(e,o,String(t.view),f(t.table));if(s||a){let w=await C(e,o,"savedqueries",y.savedqueryid,"fetchxml,layoutxml");await _e(e,o,y.returnedtypecode,s||m(w,"fetchxml")||"",a||m(w,"layoutxml")||"")}return y}),u=R({name:i,description:n,fetchxml:s,layoutxml:a});await $(e,o,"PATCH",`savedqueries(${r.savedqueryid})`,{body:O(u),headers:{"If-Match":"*"}}),T(t)||await H(e,o,{table:r.returnedtypecode});let d=await C(e,o,"savedqueries",r.savedqueryid,"fetchxml,layoutxml,name");await e.emit({...ee({...r,name:m(d,"name")||m(r,"name")}),changed:F(Object.keys(u),y=>y),published:!T(t),...Ae(m(d,"fetchxml"),m(d,"layoutxml"))})}function Pe(e){if(e===null)return null;let t=e.find("labels/label");return t!==null?t.get("description"):null}function Ge(e){let t;try{t=L(e||"")}catch(r){if(r instanceof M)return{form_error:"not well-formed"};throw r}let i=[];for(let r of t.iter("tab")){let u=[];for(let d of r.iter("section")){let y=[...d.iter("control")].map(w=>w.get("datafieldname")||w.get("id"));u.push(R({name:d.get("name"),label:Pe(d),visible:d.get("visible")!=="false"?null:!1,fields:y}))}i.push(R({name:r.get("name"),label:Pe(r),visible:r.get("visible")!=="false"?null:!1,sections:u}))}let n=t.find("header"),o=[...t.iter("Library")].map(r=>r.get("name")),s={tabs:i,header:n!==null?[...n.iter("control")].map(r=>r.get("datafieldname")||r.get("id")):null,libraries:o.length?o:null},a={};for(let[r,u]of Object.entries(s))ce(u)&&(a[r]=u);return a}async function We(e,t,i,n){let o=me(n,"form","form XML"),s=[...o.iter("control")].map(d=>d.get("id")).filter(d=>!!d),a=F(new Set(s.filter(d=>s.indexOf(d)!==s.lastIndexOf(d))),d=>d);if(a.length)throw new v("control ids used more than once: "+a.join(", "));let r=(await Q(e,t,i)).attributes,u=F(new Set([...o.iter("control")].map(d=>d.get("datafieldname")).filter(d=>!!d&&!r.has(d.toLowerCase()))),d=>d);if(u.length)throw new v(`fields not on ${i}: `+u.join(", "))}function te(e){return R({name:m(e,"name"),table:m(e,"objecttypecode"),type:ge(Oe,m(e,"type")),default:U(m(e,"isdefault"),null),state:m(e,"formactivationstate")===0?"inactive":"active",managed:m(e,"ismanaged"),id:m(e,"formid")})}async function yt(e){let t=e.args,i=await E(e);q(e,i,"GET","systemforms",null);let n=[`objecttypecode eq ${B(String(t.table))}`];f(t.type)&&n.push(`type eq ${K(Oe,f(t.type))}`);let[o]=await ue(e,i,"systemforms",[["$select",Ne],["$filter",n.join(" and ")],["$orderby","name"]],null,V(t),"forms");await e.emit(o.map(te))}function X(e,t,i,n){return Be(e,t,"systemforms","formid","objecttypecode",Ne,i,n,"form")}async function ht(e){let t=e.args,i=await E(e),n=await X(e,i,String(t.form),f(t.table)),o=await C(e,i,"systemforms",n.formid,"formxml,description"),s={...te(n),description:m(o,"description"),...Ge(m(o,"formxml"))},a=f(t.save);a&&(Fe(a,m(o,"formxml")||""),s.saved=a),await e.emit(R(s))}function Ke(e,t){let i=()=>"{"+De()+"}",n=e.PrimaryNameAttribute;return`<form><tabs><tab name="general" id="${i()}" verticallayout="true" showlabel="true" expanded="true"><labels><label description="General" languagecode="${t}" /></labels><columns><column width="100%"><sections><section name="general_section" id="${i()}" showlabel="false" showbar="false" columns="1"><labels><label description="General" languagecode="${t}" /></labels><rows><row><cell id="${i()}"><labels><label description="Name" languagecode="${t}" /></labels><control id="${n}" classid="${ze}" datafieldname="${n}" disabled="false" /></cell></row></rows></section></sections></column></columns></tab></tabs></form>`}async function bt(e){let t=e.args,i=String(t.table),n=f(t.type),o=await E(e);q(e,o,"POST","systemforms",D);let[s,a,r]=await o.lookups(async()=>{let w=await Q(e,o,i),h,c;if(f(t.copy)){let x=await X(e,o,f(t.copy),i);h=m(await C(e,o,"systemforms",x.formid,"formxml"),"formxml")||"",c=n?je[n]:m(x,"type")}else{let x=I(await $(e,o,"GET","organizations",{params:[["$select","languagecode"]]})).value,l=U(m(ce(x)?_(x)[0]:{},"languagecode"),1033);h=Ke(w,l),c=je[n||"main"]}return await We(e,o,i,h),[h,c,await we(e,o,f(t.solution))]}),u={name:t.name,objecttypecode:i,type:a??null,formxml:s};f(t.description)&&(u.description=t.description);let d=await $(e,o,"POST","systemforms",{body:O(u),headers:r}),y=Y(d);T(t)||await H(e,o,{table:i}),await e.emit({...te(await X(e,o,String(y),null)),published:!T(t)})}async function xt(e){let t=e.args,i=f(t.name),n=f(t.description),o=f(t.state);if(!(i||n!==null||o||t.body))throw new v("nothing to update",{hint:"pass --name, --description, --state or --body"});let s=await E(e);q(e,s,"PATCH","systemforms",D);let a=W(t.body),r=await s.lookups(async()=>{let w=await X(e,s,String(t.form),f(t.table));if(o==="inactive"&&m(w,"type")!==2)throw new v("only main forms can be made inactive");return a&&await We(e,s,w.objecttypecode,a),w}),u=R({name:i,description:n,formxml:a,formactivationstate:o==="active"?1:o==="inactive"?0:null});await $(e,s,"PATCH",`systemforms(${r.formid})`,{body:O(u),headers:{"If-Match":"*"}}),T(t)||await H(e,s,{table:r.objecttypecode});let d=await X(e,s,r.formid,null),y=await C(e,s,"systemforms",r.formid,"formxml,name");await e.emit({...te({...d,name:m(y,"name")||m(d,"name")}),changed:F(Object.keys(u),w=>w),published:!T(t),...Ge(m(y,"formxml"))})}function Z(e){return R({name:m(e,"name"),display_name:m(e,"displayname"),type:ge(pe,m(e,"webresourcetype")),managed:m(e,"ismanaged"),modified:m(e,"modifiedon"),id:m(e,"webresourceid")})}async function vt(e){let t=e.args,i=await E(e);q(e,i,"GET","webresourceset",null);let n=f(t.solution),o=null;if(n){let{names:u,objectIds:d}=await import("./solution-3WUUDYF3.js");o=await d(e,i,u(n),61)}let s=t.hidden?[]:["ishidden/Value eq false"];f(t.name)&&s.push(le("name",f(t.name))),f(t.type)&&s.push(`webresourcetype eq ${K(pe,f(t.type))}`);let a=[["$select",Ie],["$orderby","name"]];s.length&&a.push(["$filter",s.join(" and ")]);let r=await $e(e,i,"webresourceset","webresourceid",o,a,null,V(t),"web resources",u=>(m(u,"name")||"").toLowerCase());await e.emit(r.map(Z))}async function fe(e,t,i){let n=se(i)?`webresourceid eq ${ae(i)}`:`name eq ${B(i)}`,o=_(I(await $(e,t,"GET","webresourceset",{params:[["$select",Ie],["$filter",n]]})).value);return o.length?o[0]:null}async function $t(e){let t=e.args,i=String(t.name),n=await E(e),o=await fe(e,n,i);if(!o)throw new oe(`no web resource '${i}'`,{service:"dataverse",hint:"run: ppdo-cli dv webresource list --name '*<part>*'"});let s=await C(e,n,"webresourceset",o.webresourceid,"content,description"),a=Buffer.from(m(s,"content")||"","base64"),r={...Z(o),description:m(s,"description"),bytes:a.length},u=f(t.save);u?(qe(u,a),r.saved=u):Ye.has(m(o,"webresourcetype"))?r.content=a.toString("utf8"):r.hint="binary content: pass --save <file>",await e.emit(R(r))}var Qe={ENOENT:"No such file or directory",EACCES:"Permission denied",EPERM:"Operation not permitted",EISDIR:"Is a directory"};async function Rt(e){let t=e.args,i=String(t.file),n=String(t.name),o;try{o=He(i)}catch(l){let g=l;throw new v(`cannot read ${i}: ${Qe[g.code??""]??g.message}`)}let s=o.toString("base64"),a=f(t.type),r=a?K(pe,a):Ve[Ue(i).toLowerCase()];if(r===void 0)throw new v(`can't tell the web resource type from '${i}'`,{hint:"pass --type"});if(!n.split("/",1)[0].includes("_"))throw new v(`'${n}' has no publisher prefix`,{hint:"e.g. contoso_/scripts/app.js"});let u=await E(e);q(e,u,"POST","webresourceset",D);let[d,y,w]=await u.lookups(async()=>{let l=await fe(e,u,n),g=l?m(await C(e,u,"webresourceset",l.webresourceid,"content"),"content"):null;return[l,g,await we(e,u,f(t.solution))]}),h=R({displayname:f(t.displayName),description:f(t.description)});if(d&&y===s&&!Object.keys(h).length){await e.emit({...Z(d),action:"unchanged",published:!1});return}let c,x;if(d)await $(e,u,"PATCH",`webresourceset(${d.webresourceid})`,{headers:{"If-Match":"*",...w},body:O({content:s,...h})}),c=d.webresourceid,x="updated";else{let l={name:n,webresourcetype:r,content:s,displayname:f(t.displayName)||n.slice(n.lastIndexOf("/")+1),...h},g=await $(e,u,"POST","webresourceset",{body:O(l),headers:w});c=Y(g),x="created"}T(t)||await H(e,u,{webresource:c}),await e.emit({...Z(ve(await fe(e,u,String(c)))),action:x,bytes:o.length,published:!T(t)})}export{je as CREATE_FORM_TYPES,Oe as FORM_TYPES,Ce as VIEW_TYPES,Ve as WR_EXTENSIONS,pe as WR_TYPES,We as checkForm,_e as checkView,X as findForm,J as findView,fe as findWebresource,bt as formCreate,ht as formGet,yt as formList,Ge as formSummary,xt as formUpdate,H as publish,we as solutionHeaders,Q as tableInfo,gt as viewCreate,pt as viewGet,ft as viewList,Ae as viewSummary,wt as viewUpdate,$t as wrGet,vt as wrList,Rt as wrPush};