shopify 3.94.3 → 4.0.0

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 (295) hide show
  1. package/bin/run.js +5 -1
  2. package/dist/analytics-6IHHYAV6.js +1 -0
  3. package/dist/analytics-KKVP5DT3.js +1 -0
  4. package/dist/bootstrap.d.ts +5 -0
  5. package/dist/bootstrap.js +3 -0
  6. package/dist/chunk-22PCRFG4.js +1 -0
  7. package/dist/chunk-26D72ZNV.js +1 -0
  8. package/dist/chunk-2APPXD5Z.js +2 -0
  9. package/dist/chunk-2I4PRX2I.js +1 -0
  10. package/dist/chunk-2VQJQ36C.js +103 -0
  11. package/dist/chunk-323UTVMM.js +1 -0
  12. package/dist/chunk-3DQIVE24.js +9 -0
  13. package/dist/chunk-3F6NZK7S.js +2 -0
  14. package/dist/chunk-3LVGAQB4.js +1 -0
  15. package/dist/chunk-3TNEIDOD.js +1 -0
  16. package/dist/chunk-3VZEETAV.js +1 -0
  17. package/dist/chunk-4G7J6HIV.js +1 -0
  18. package/dist/chunk-4HHXSMD7.js +10 -0
  19. package/dist/chunk-4LNCYIS3.js +1 -0
  20. package/dist/chunk-4ZGSSQC6.js +1 -0
  21. package/dist/chunk-52GC6XUT.js +1 -0
  22. package/dist/chunk-5CH3B62S.js +2 -0
  23. package/dist/chunk-5Y7GIF2W.js +1 -0
  24. package/dist/chunk-66RJ5T7A.js +102 -0
  25. package/dist/chunk-6B53BWJW.js +1 -0
  26. package/dist/chunk-6BMMB2UO.js +1 -0
  27. package/dist/chunk-6HBRBQAN.js +6 -0
  28. package/dist/chunk-6M3ZYNGO.js +451 -0
  29. package/dist/chunk-6TZAAS5H.js +1 -0
  30. package/dist/chunk-72F3YBNA.js +1 -0
  31. package/dist/chunk-74HYYXXE.js +17 -0
  32. package/dist/chunk-75VPUOC5.js +1 -0
  33. package/dist/chunk-7BGM2GAH.js +1 -0
  34. package/dist/chunk-7UYZQN4V.js +18 -0
  35. package/dist/chunk-A74GETYC.js +1 -0
  36. package/dist/chunk-AIV5RI3X.js +1 -0
  37. package/dist/chunk-ALKTLKQ6.js +5 -0
  38. package/dist/chunk-B2EHO7ZC.js +847 -0
  39. package/dist/chunk-B2IVY4V5.js +1 -0
  40. package/dist/chunk-BDVAE5MS.js +28 -0
  41. package/dist/chunk-CERXUPGC.js +14 -0
  42. package/dist/chunk-D3TSJA5S.js +1 -0
  43. package/dist/chunk-D6JARNEH.js +1 -0
  44. package/dist/chunk-DFMQWJQ3.js +3 -0
  45. package/dist/chunk-DJONKJSZ.js +1 -0
  46. package/dist/chunk-DJQVNH7P.js +567 -0
  47. package/dist/chunk-DU4WR4OP.js +1 -0
  48. package/dist/chunk-ELVFJ7BR.js +4 -0
  49. package/dist/chunk-ELYP4KFP.js +8 -0
  50. package/dist/chunk-FFQ5EWII.js +294 -0
  51. package/dist/chunk-FUOIGXI4.js +1 -0
  52. package/dist/chunk-GD7FWXJ5.js +2 -0
  53. package/dist/chunk-GFEAKSGV.js +374 -0
  54. package/dist/chunk-GFJ7UV74.js +1 -0
  55. package/dist/chunk-GNPS5SBU.js +1 -0
  56. package/dist/chunk-GOJ2QHSR.js +1 -0
  57. package/dist/chunk-HSK7YMRE.js +359 -0
  58. package/dist/chunk-HUZUORYM.js +19 -0
  59. package/dist/chunk-HZA6IAA4.js +1 -0
  60. package/dist/chunk-IASVAERO.js +1 -0
  61. package/dist/chunk-IIIVWD4R.js +1 -0
  62. package/dist/chunk-INEU4XKS.js +6 -0
  63. package/dist/chunk-IOLVEXM6.js +1 -0
  64. package/dist/chunk-IU2ZQ6TE.js +2 -0
  65. package/dist/chunk-IX5ICOBV.js +7 -0
  66. package/dist/chunk-J3KVONB3.js +6 -0
  67. package/dist/chunk-JGXWQULI.js +1 -0
  68. package/dist/chunk-JHPRFW5B.js +19 -0
  69. package/dist/chunk-JLBH7RCF.js +4 -0
  70. package/dist/chunk-JPGO36XP.js +1 -0
  71. package/dist/chunk-JUVAGMIH.js +1 -0
  72. package/dist/chunk-JVIKCGDY.js +1 -0
  73. package/dist/chunk-K2WUCOQJ.js +32 -0
  74. package/dist/chunk-K5YV6UVF.js +4 -0
  75. package/dist/chunk-KBQ4LGFB.js +1 -0
  76. package/dist/chunk-KGXQS7LS.js +1 -0
  77. package/dist/chunk-KL5Z3T6L.js +1 -0
  78. package/dist/chunk-KLMDWDT2.js +1 -0
  79. package/dist/chunk-KNVM7N3U.js +1 -0
  80. package/dist/chunk-KWJ562F2.js +12 -0
  81. package/dist/chunk-LALIKZPS.js +5 -0
  82. package/dist/chunk-LAZJ47DZ.js +6 -0
  83. package/dist/chunk-LDGAHMS7.js +159 -0
  84. package/dist/chunk-LNHLDRC5.js +1 -0
  85. package/dist/chunk-LW7U753G.js +1 -0
  86. package/dist/chunk-LX3ZOW52.js +12 -0
  87. package/dist/chunk-LXFJDCNG.js +1 -0
  88. package/dist/chunk-MBAFWQSZ.js +7 -0
  89. package/dist/chunk-MOA33ZFO.js +1 -0
  90. package/dist/chunk-MQNYGGAM.js +1 -0
  91. package/dist/chunk-N5YIPQ6J.js +1 -0
  92. package/dist/chunk-N7RBSKYT.js +1 -0
  93. package/dist/chunk-NF2ABOOU.js +1 -0
  94. package/dist/chunk-NRAFVIU3.js +1 -0
  95. package/dist/chunk-OCOY5MV2.js +1 -0
  96. package/dist/chunk-ODNGDO4H.js +50 -0
  97. package/dist/chunk-OHY4ZL3U.js +2 -0
  98. package/dist/chunk-OLZHWPZP.js +1 -0
  99. package/dist/chunk-OUOYKNMY.js +1 -0
  100. package/dist/chunk-OXPWCC7I.js +64 -0
  101. package/dist/chunk-P5VVOLGV.js +1 -0
  102. package/dist/chunk-P6XE4MH5.js +1 -0
  103. package/dist/chunk-P7R7FBY2.js +3 -0
  104. package/dist/chunk-PD5ZHJWI.js +1 -0
  105. package/dist/chunk-PIBY5DDZ.js +1 -0
  106. package/dist/chunk-Q7ING5F5.js +1 -0
  107. package/dist/chunk-QFWIDATO.js +1 -0
  108. package/dist/chunk-QRRNOVJ3.js +1 -0
  109. package/dist/chunk-QSTEVZFQ.js +1 -0
  110. package/dist/chunk-R466TU3N.js +2 -0
  111. package/dist/chunk-RF2DPBA6.js +1 -0
  112. package/dist/chunk-RFG5RMPL.js +1 -0
  113. package/dist/chunk-RM5SJJN6.js +559 -0
  114. package/dist/chunk-RVNMVBPM.js +1 -0
  115. package/dist/chunk-SBEZBZM7.js +144 -0
  116. package/dist/chunk-SGQ6D3LU.js +15 -0
  117. package/dist/chunk-SRCQVUMC.js +1 -0
  118. package/dist/chunk-TFSBQ4RY.js +5 -0
  119. package/dist/chunk-TQYMC7TH.js +1 -0
  120. package/dist/chunk-UGDBJTLP.js +6 -0
  121. package/dist/chunk-UGXYQ23Y.js +1411 -0
  122. package/dist/chunk-UWJ73J4B.js +1 -0
  123. package/dist/chunk-V2CNCPIE.js +2 -0
  124. package/dist/chunk-VBUZWRUL.js +1 -0
  125. package/dist/chunk-VS3T5YOG.js +264 -0
  126. package/dist/chunk-VWYM4OWK.js +1 -0
  127. package/dist/chunk-VY6SNDKW.js +3 -0
  128. package/dist/chunk-WDC3KIZT.js +2 -0
  129. package/dist/chunk-WFXRSKRK.js +1 -0
  130. package/dist/chunk-WXVZJJOR.js +16 -0
  131. package/dist/chunk-WZBSLU4Q.js +6 -0
  132. package/dist/chunk-XBXMPFXM.js +1 -0
  133. package/dist/chunk-XEFQQPL4.js +1 -0
  134. package/dist/chunk-XLELNRFF.js +3 -0
  135. package/dist/chunk-XNO6DZYP.js +1 -0
  136. package/dist/chunk-Y5JKV2AI.js +1 -0
  137. package/dist/chunk-YC6G4MHD.js +3 -0
  138. package/dist/chunk-YI232QLS.js +1 -0
  139. package/dist/chunk-YMWHHINU.js +1 -0
  140. package/dist/chunk-YOZNRLFC.js +1 -0
  141. package/dist/chunk-YZDDTYTU.js +11 -0
  142. package/dist/chunk-Z35BTAM6.js +2 -0
  143. package/dist/chunk-ZR76GGZ6.js +5 -0
  144. package/dist/chunk-ZTMSBSYD.js +1 -0
  145. package/dist/chunk-ZV6NCNI4.js +586 -0
  146. package/dist/chunk-ZVJVDCIM.js +1 -0
  147. package/dist/cli/commands/app/app-logs/sources.js +2 -0
  148. package/dist/cli/commands/app/build.js +1 -0
  149. package/dist/cli/commands/app/bulk/cancel.js +1 -0
  150. package/dist/cli/commands/app/bulk/execute.js +9 -0
  151. package/dist/cli/commands/app/bulk/status.js +5 -0
  152. package/dist/cli/commands/app/config/link.js +4 -0
  153. package/dist/cli/commands/app/config/pull.js +1 -0
  154. package/dist/cli/commands/app/config/use.js +1 -0
  155. package/dist/cli/commands/app/config/validate.js +3 -0
  156. package/dist/cli/commands/app/demo/watcher.js +1 -0
  157. package/dist/cli/commands/app/deploy.js +22 -0
  158. package/dist/cli/commands/app/dev/clean.js +5 -0
  159. package/dist/cli/commands/app/dev.js +320 -0
  160. package/dist/cli/commands/app/env/pull.js +11 -0
  161. package/dist/cli/commands/app/env/show.js +1 -0
  162. package/dist/cli/commands/app/execute.js +1 -0
  163. package/dist/cli/commands/app/function/build.js +1 -0
  164. package/dist/cli/commands/app/function/info.js +16 -0
  165. package/dist/cli/commands/app/function/replay.js +5 -0
  166. package/dist/cli/commands/app/function/run.js +1 -0
  167. package/dist/cli/commands/app/function/schema.js +1 -0
  168. package/dist/cli/commands/app/function/typegen.js +1 -0
  169. package/dist/cli/commands/app/generate/extension.js +5 -0
  170. package/dist/cli/commands/app/import-custom-data-definitions.js +4 -0
  171. package/dist/cli/commands/app/import-extensions.js +1 -0
  172. package/dist/cli/commands/app/info.js +11 -0
  173. package/dist/cli/commands/app/init.js +10 -0
  174. package/dist/cli/commands/app/logs.js +2 -0
  175. package/dist/cli/commands/app/release.js +4 -0
  176. package/dist/cli/commands/app/versions/list.js +1 -0
  177. package/dist/cli/commands/app/webhook/trigger.js +25 -0
  178. package/dist/cli/commands/auth/login.js +1 -20
  179. package/dist/cli/commands/auth/logout.js +1 -12
  180. package/dist/cli/commands/cache/clear.js +1 -11
  181. package/dist/cli/commands/config/autoupgrade/constants.d.ts +0 -1
  182. package/dist/cli/commands/config/autoupgrade/constants.js +1 -6
  183. package/dist/cli/commands/config/autoupgrade/off.js +1 -22
  184. package/dist/cli/commands/config/autoupgrade/on.js +1 -22
  185. package/dist/cli/commands/config/autoupgrade/status.js +1 -30
  186. package/dist/cli/commands/debug/command-flags.js +1 -79
  187. package/dist/cli/commands/docs/generate.js +1 -157
  188. package/dist/cli/commands/doctor-release/doctor-release.js +1 -25
  189. package/dist/cli/commands/doctor-release/theme/index.js +1 -56
  190. package/dist/cli/commands/help.js +1 -26
  191. package/dist/cli/commands/kitchen-sink/async.js +1 -16
  192. package/dist/cli/commands/kitchen-sink/index.js +1 -21
  193. package/dist/cli/commands/kitchen-sink/prompts.js +1 -16
  194. package/dist/cli/commands/kitchen-sink/static.js +1 -16
  195. package/dist/cli/commands/notifications/generate.js +1 -11
  196. package/dist/cli/commands/notifications/list.js +1 -33
  197. package/dist/cli/commands/organization/list.js +1 -0
  198. package/dist/cli/commands/search.js +1 -27
  199. package/dist/cli/commands/theme/check.js +1 -0
  200. package/dist/cli/commands/theme/console.js +15 -0
  201. package/dist/cli/commands/theme/delete.js +7 -0
  202. package/dist/cli/commands/theme/dev.js +26 -0
  203. package/dist/cli/commands/theme/duplicate.js +32 -0
  204. package/dist/cli/commands/theme/info.js +1 -0
  205. package/dist/cli/commands/theme/init.js +8 -0
  206. package/dist/cli/commands/theme/language-server.js +1 -0
  207. package/dist/cli/commands/theme/list.js +1 -0
  208. package/dist/cli/commands/theme/metafields/pull.js +3 -0
  209. package/dist/cli/commands/theme/open.js +8 -0
  210. package/dist/cli/commands/theme/package.js +7 -0
  211. package/dist/cli/commands/theme/preview.js +1 -0
  212. package/dist/cli/commands/theme/profile.js +3 -0
  213. package/dist/cli/commands/theme/publish.js +7 -0
  214. package/dist/cli/commands/theme/pull.js +3 -0
  215. package/dist/cli/commands/theme/push.js +28 -0
  216. package/dist/cli/commands/theme/rename.js +6 -0
  217. package/dist/cli/commands/theme/share.js +3 -0
  218. package/dist/cli/commands/upgrade.js +1 -17
  219. package/dist/cli/commands/version.js +1 -10
  220. package/dist/command-registry.d.ts +8 -0
  221. package/dist/command-registry.js +1 -0
  222. package/dist/conf-store-U5ZITKJN.js +1 -0
  223. package/dist/custom-oclif-loader-DVFFWCBV.js +1 -0
  224. package/dist/deprecations-TU5UQJVV.js +1 -0
  225. package/dist/dist-2Z5TND4U.js +1 -0
  226. package/dist/dist-GYHFDHKP.js +1 -0
  227. package/dist/environments-Z5PR7DSI.js +1 -0
  228. package/dist/error-IJGNYKZ3.js +1 -0
  229. package/dist/error-handler-WSCGNS2P.js +1 -0
  230. package/dist/fs-5BDEA2KD.js +1 -0
  231. package/dist/hooks/app-init.d.ts +9 -0
  232. package/dist/hooks/app-init.js +1 -0
  233. package/dist/hooks/did-you-mean.d.ts +1 -0
  234. package/dist/hooks/did-you-mean.js +1 -0
  235. package/dist/hooks/hydrogen-init.d.ts +7 -0
  236. package/dist/hooks/hydrogen-init.js +1 -0
  237. package/dist/hooks/plugin-plugins.d.ts +1 -0
  238. package/dist/hooks/plugin-plugins.js +1 -0
  239. package/dist/hooks/postrun.js +1 -1
  240. package/dist/hooks/prerun.js +1 -1
  241. package/dist/hooks/public-metadata.d.ts +1 -0
  242. package/dist/hooks/public-metadata.js +1 -0
  243. package/dist/hooks/sensitive-metadata.d.ts +1 -0
  244. package/dist/hooks/sensitive-metadata.js +1 -0
  245. package/dist/hooks/tunnel-provider.d.ts +1 -0
  246. package/dist/hooks/tunnel-provider.js +1 -0
  247. package/dist/hooks/tunnel-start.d.ts +1 -0
  248. package/dist/hooks/tunnel-start.js +1 -0
  249. package/dist/http-proxy-node16-Q5DZMBHC.js +38 -0
  250. package/dist/index.js +254 -3668
  251. package/dist/is-global-V4ZRHQG2.js +1 -0
  252. package/dist/latest-version-EFWBOTWM.js +49 -0
  253. package/dist/lib-5L7UKDEK.js +1 -0
  254. package/dist/lib-C3VO2BQW.js +1 -0
  255. package/dist/lib-QB6I6CTC.js +1 -0
  256. package/dist/local-6QPX4GCJ.js +1 -0
  257. package/dist/local-storage-JLXBZVWO.js +1 -0
  258. package/dist/metadata-UDMOTRS7.js +1 -0
  259. package/dist/{morph-DQREIZD2.js → morph-EMYAITFM.js} +1 -1
  260. package/dist/node-package-manager-HAFRYGUM.js +1 -0
  261. package/dist/notifications-system-MP7WDOCS.js +1 -0
  262. package/dist/npa-ICFSA3NL.js +1 -0
  263. package/dist/output-YGMHXEIS.js +1 -0
  264. package/dist/{path-HUAU3YBW.js → path-CWUNINMX.js} +1 -1
  265. package/dist/{prettier-PGDJ5B7I.js → prettier-NVRHEAFO.js} +1 -1
  266. package/dist/system-KLXD4FXF.js +1 -0
  267. package/dist/tsconfig.tsbuildinfo +1 -1
  268. package/dist/typescript-K5CWIA4V.js +1 -0
  269. package/dist/ui-GHG3UGB3.js +1 -0
  270. package/dist/upgrade-OPZGPM5J.js +1 -0
  271. package/dist/version-D5PJZIRW.js +1 -0
  272. package/dist/version-KRQBMYCH.js +1 -0
  273. package/dist/workerd-L2EJKIAQ.js +18 -0
  274. package/oclif.manifest.json +5247 -6056
  275. package/package.json +17 -41
  276. package/dist/chunk-45T5XUIM.js +0 -1
  277. package/dist/chunk-52KHWFYF.js +0 -1
  278. package/dist/chunk-66TIGB4U.js +0 -415
  279. package/dist/chunk-675GKVCB.js +0 -3
  280. package/dist/chunk-7ES6PV7M.js +0 -847
  281. package/dist/chunk-BF7JM4FH.js +0 -396
  282. package/dist/chunk-FU2Y2M3M.js +0 -5
  283. package/dist/chunk-IDQ4X47Z.js +0 -3
  284. package/dist/chunk-JBSYWYIP.js +0 -2
  285. package/dist/chunk-PBKIXB7L.js +0 -63
  286. package/dist/chunk-SVA22NZQ.js +0 -607
  287. package/dist/error-handler-LC7FITE7.js +0 -1
  288. package/dist/http-proxy-node16-TTURN6MD.js +0 -38
  289. package/dist/lib-3WHF5XD3.js +0 -1
  290. package/dist/local-TWIGLQ7X.js +0 -1
  291. package/dist/node-package-manager-3UCLJPGW.js +0 -1
  292. package/dist/npa-OKDXXRCU.js +0 -1
  293. package/dist/ui-UYE67X4Y.js +0 -1
  294. package/dist/workerd-37BZZEVW.js +0 -18
  295. /package/dist/{chunk-KADPE3PY.js → chunk-7MUKLZOL.js} +0 -0
@@ -0,0 +1 @@
1
+ import{h as m}from"./chunk-RFG5RMPL.js";import{d as h}from"./chunk-JPGO36XP.js";import{g as i}from"./chunk-VPRTJUIN.js";i();var s=["live","unpublished","development"];async function A(r){let e=r.storeFqdn,t=(await m(r)).filter(c);if(t.length===0)throw new h(`There are no themes in the ${e} store`);return t.sort(p)}function c(r){return s.includes(r.role)}function p(r,e){return s.indexOf(r.role)-s.indexOf(e.role)}i();function R(r,e,t){return T(r,e,t)??d(r,e,t)}function T(r,e,t){let o=t.role;if(!o)return;let n=`No themes on the store ${r} match the role "${o}"`;return a(e,l=>l.role===o).orThrow(n)}function d(r,e,t){return t.themeIdentifiers.flatMap(n=>{let l=`No themes on the store ${r} match the ID or name "${n}"`;return a(e,u=>`${u.id}`===n||u.name.toLowerCase()===n.toLowerCase()?!0:g(u.name.toLowerCase(),n.toLowerCase())).orThrow(l)})}function a(r,e){let t=r.filter(e);return t.length>0?{orThrow:o=>t}:{orThrow:o=>{throw new h(o)}}}var f=class{constructor(e){this.queryProps=e}get role(){for(let e of s)if(this.queryProps[e])return e}get themeIdentifiers(){return[this.queryProps.theme,this.queryProps.themes].flat().filter(t=>!!t)}any(){return Object.values(this.queryProps).some(e=>e?.length!==void 0?e.length>0:!!e)}};function g(r,e){let t=e.replace(/(^\*)|(\*$)/g,"");return e.startsWith("*")&&e.endsWith("*")?r.includes(t):e.startsWith("*")?r.endsWith(t):e.endsWith("*")?r.startsWith(t):!1}export{s as a,A as b,R as c,f as d};
@@ -0,0 +1,144 @@
1
+ import{A as Bt,B as Io,C as J,D as To,E as ko,F as Fo,G as $t,K as Mo,L as Do,M as Ro,N as Oo,O as Uo,P as Bo,Q as $o,S as Lo,T as jo,V as No,X as Wo,a as bn,b as z,c as Oe,g as Ot,h as Eo,i as Cn,j as wn,l as Ut,m as So,n as ye,o as Po,p as En,q as vo,r as R,s as Ue,t as Be,u as Ao,v as ie,w as $e,x as k,y as oe,z as he}from"./chunk-DJQVNH7P.js";import{a as go,b as Pp,c as vp,d as yo,e as ho,f as _o,g as xn,h as xo,i as bo,j as nt,k as Co,l as Ap,m as Rt,n as wo}from"./chunk-66RJ5T7A.js";import{a as fo,b as mo}from"./chunk-ELYP4KFP.js";import{b as uo,o as Sp}from"./chunk-7MUKLZOL.js";import{a as Ep}from"./chunk-VBUZWRUL.js";import{a as lo}from"./chunk-R466TU3N.js";import{aa as wp}from"./chunk-UGXYQ23Y.js";import{a as co}from"./chunk-TQYMC7TH.js";import{b as tt,c as U}from"./chunk-HUZUORYM.js";import{a as ao}from"./chunk-XLELNRFF.js";import{$ as It,H as Wi,I as Vi,N as zi,Z as fe,_ as me,aa as Ji,ba as W,da as Ze,ea as qi,j as Bi,n as $i,p as Li,r as p,t as ji,z as Ni}from"./chunk-B2EHO7ZC.js";import{m as Tt,n as Ki,s as Hi,t as Gi,w as kt,x as Yi}from"./chunk-LAZJ47DZ.js";import{a as le,b as ve}from"./chunk-XNO6DZYP.js";import{b as gn}from"./chunk-4HHXSMD7.js";import{b as po}from"./chunk-YZDDTYTU.js";import{a as Ye,c as Ui,d as At}from"./chunk-JUVAGMIH.js";import{A as $,B as De,D as eo,F as et,G as to,I as no,O as ge,R as io,u as Qe,v as Xe,w as Ft,x as Qi,z as Xi}from"./chunk-BDVAE5MS.js";import{a as Zi,f as yn}from"./chunk-IASVAERO.js";import{d as b,f as V,g as Q}from"./chunk-JPGO36XP.js";import{$ as mn,$a as te,Ba as Fi,Ea as de,Ga as Et,Gb as v,Hb as Mt,Ib as A,Ka as Mi,L as Pe,La as Di,N as Ii,Nb as Re,O as un,Oa as St,P as dn,Pa as Ri,Pb as Dt,Qb as S,Rb as ue,Ta as w,Tb as ro,Ua as H,Ub as so,W as He,Wa as D,Xa as Oi,Y as j,Z as fn,ba as bt,bb as Pt,db as vt,ea as Ti,fa as Me,ka as Ct,ma as F,na as ce,oa as Ge,pa as N,qa as wt,tb as ne,ua as B,va as ki,wa as Z}from"./chunk-GFEAKSGV.js";import{m as hn,n as _n,o as oo}from"./chunk-YC6G4MHD.js";import{a as Ke}from"./chunk-N7RBSKYT.js";import{d as y,e as Se,f as pe,g as I,h as Pi,i as P,j as T,k as _t,l as vi,n as xt,s as Ai,t as ln}from"./chunk-IU2ZQ6TE.js";import{a as Si,e as qe,g as u}from"./chunk-VPRTJUIN.js";u();import{pipeline as Ip}from"stream/promises";import Vo from"node:stream/promises";import*as zo from"node:zlib";import{fileURLToPath as An}from"node:url";var Jo="9.1.2",qo="7.0.1",Ko="3",Tp="123.0.0",Ho="1.0.2",Go="2.0.1";function Yo(e){return e==="0"||e==="1"?{functionRunner:"7.0.1",javy:"4.0.0",javyPlugin:"1"}:e==="2"?{functionRunner:Jo,javy:qo,javyPlugin:Ko}:null}var it=class{constructor(t,n,i,o,r=`v${n}`){this.name=t,this.version=n,this.release=r,this.supportsWindowsOnArm=o;let s;s=`${t}-${n}`,s=process.platform==="win32"?`${s}.exe`:s,this.path=y(P(An(import.meta.url)),"..","bin",s),this.gitHubRepo=i}downloadUrl(t,n){let i,o;switch(t.toLowerCase()){case"darwin":i="macos";break;case"linux":i="linux";break;case"win32":i="windows";break;default:throw Error(`Unsupported platform ${t}`)}switch(n.toLowerCase()){case"arm":case"arm64":o="arm";break;case"ia32":case"x64":o="x86_64";break;default:throw Error(`Unsupported architecture ${n}`)}let r=`${o}-${i}`,s=["arm-linux","arm-macos","x86_64-macos","x86_64-windows","x86_64-linux"];if(this.supportsWindowsOnArm&&s.push("arm-windows"),!s.includes(r))throw Error(`Unsupported platform/architecture combination ${t}/${n}`);return`https://github.com/${this.gitHubRepo}/releases/download/${this.release}/${this.name}-${r}-v${this.version}.gz`}async processResponse(t,n){return Fp(t,n)}},Pn=class{constructor(t){this.name=`shopify_functions_javy_v${t}`,this.version=t,this.path=y(P(An(import.meta.url)),"..","bin",`shopify_functions_javy_v${t}.wasm`)}downloadUrl(t,n){return`https://cdn.shopify.com/shopifycloud/shopify-functions-javy-plugin/shopify_functions_javy_v${this.version}.wasm`}async processResponse(t,n){return Ip(t,n)}},vn=class{constructor(t,n){this.name=t,this.version=n,this.path=y(P(An(import.meta.url)),"..","bin",t)}downloadUrl(t,n){return`https://cdn.jsdelivr.net/npm/binaryen@${this.version}/bin/wasm-opt`}async processResponse(t,n){await Vo.pipeline(t,n)}},Sn;function In(e=qo){return new it("javy",e,"bytecodealliance/javy",kt(e,">=7.0.0"))}function Tn(e=Ko){return new Pn(e)}function Zd(e=Jo){return new it("function-runner",e,"Shopify/function-runner",kt(e,">=9.1.1"))}function ot(){return Sn||(Sn=new vn("wasm-opt.cjs",Tp)),Sn}function Zo(e){return new it("shopify-function-trampoline",e,"Shopify/shopify-function-wasm-api",kt(e,">=2.0.1"),`shopify_function_trampoline/v${e}`)}var Lt=new Map;async function Ae(e){if(await w(e.path)&&!Lt.has(e.path))return;let n=Lt.get(e.path);if(n){await n;return}let i=kp(e);Lt.set(e.path,i);try{await i}finally{Lt.delete(e.path)}}async function kp(e){let t=e.downloadUrl(process.platform,process.arch);S(`Downloading ${e.name} ${e.version} from ${t} to ${e.path}`);let n=P(e.path);await w(n)||await Z(n),await go(async()=>{let i=await $i(t,void 0,"slow-request");if(i.status!==200)throw new Error(`Downloading ${e.name} failed with status code of ${i.status}`);let o=i.body;if(o===null)throw new Error(`Downloading ${e.name} failed with empty response body`);await Ct(async r=>{let s=y(r,"binary"),a=Di(s);await e.processResponse(o,a),await Ri(s,509),await St(s,e.path,{overwrite:!0})})},async()=>{},2)}async function Fp(e,t){let n=zo.createGunzip();await Vo.pipeline(e,n,t)}u();import{build as Xo}from"esbuild";var Mp="2",rt=class extends b{constructor(t){super(t,A`Make sure you have a compatible version of the ${v.yellow("@shopify/shopify_function")} library installed.`,[A`Add ${v.green(`"@shopify/shopify_function": "~${Mp}.0.0"`)} to the dependencies section of the package.json file in your function's directory, if not already present.`.value,"Run your package manager's install command to update dependencies."])}};async function er(e,t){let n=$p(e),i=n.length===0?Bp:new kn(n),o=await nr(e);return t.useTasks?Rp(e,t,i,o):Dp(e,t,i,o)}async function Dp(e,t,n,i){t.signal?.aborted||(t.stdout.write(`Building function ${e.localIdentifier}...`),t.stdout.write(`Building GraphQL types...
2
+ `),await st(e,t)),t.signal?.aborted||(t.stdout.write(`Bundling JS function...
3
+ `),await n.bundle(e,t)),t.signal?.aborted||(t.stdout.write(`Running javy...
4
+ `),await n.compile(e,t,i)),t.signal?.aborted||t.stdout.write(`Done!
5
+ `)}async function Rp(e,t,n,i){await eo([{title:"Building GraphQL types",task:async()=>{await st(e,t)}},{title:"Bundling JS function",task:async()=>{await n.bundle(e,t)}},{title:"Running javy",task:async()=>{await n.compile(e,t,i)}}])}async function st(e,t){if(e.typegenCommand){let i=e.typegenCommand.split(" ");return yn("cmd_all_timing_network_ms")(async()=>ge(i[0],i.slice(1),{cwd:e.directory,stdout:t.stdout,stderr:t.stderr,signal:t.signal}))}if(!e.isJavaScript)throw new b("No typegen_command specified. Set build.typegen_command in your function extension TOML to generate GraphQL types for non-JavaScript functions.");let n=await Ki(e.directory,"graphql-code-generator","--config","package.json");return yn("cmd_all_timing_network_ms")(async()=>ge(n.command,n.args,{cwd:e.directory,stderr:t.stderr,signal:t.signal}))}async function tr(e){let t=await te("node_modules/@shopify/shopify_function/index.ts",{type:"file",cwd:e.directory}),n=await te("node_modules/@shopify/shopify_function/run.ts",{type:"file",cwd:e.directory});if(!t||!n)throw new rt("Could not find the Shopify Functions JavaScript library.");if(!e.entrySourceFilePath)throw new b("Could not find your function entry point. It must be in src/index.js or src/index.ts");return t}async function nr(e){let t=await te("node_modules/@shopify/shopify_function/package.json",{type:"file",cwd:e.directory});if(!t)throw new rt("Could not find the Shopify Functions JavaScript library.");let i=JSON.parse(await F(t)).version.split(".")[0],o=Yo(i);if(o===null)throw new rt("The installed version of the Shopify Functions JavaScript library is not compatible with this version of Shopify CLI.");return o}async function Op(e,t,n=process.env){let i=await tr(e),o={...ir(e.directory,e.entrySourceFilePath,t.app.dotenv?.variables??{},n),entryPoints:[i]};return Xo(o)}function ir(e,t,n,i=process.env){let o=me(i,(c,d)=>Ot.test(d)&&c),r={...n,...o},s=Object.keys(r||{}).reduce((c,d)=>({...c,[`process.env.${d}`]:JSON.stringify(r[d])}),{});return{outfile:y(e,"dist/function.js"),alias:{"user-function":t},define:s,logLevel:"silent",bundle:!0,legalComments:"none",target:"es2022",format:"esm"}}async function or(e){let t=ot();await Ae(t);let n=P(ot().path),i="node",o=[ot().name,e,"-Oz","--enable-bulk-memory","--enable-multimemory","--enable-nontrapping-float-to-int","--strip-debug","-o",e];S(`Wasm binary: ${ot().name}`),S("Optimizing this wasm binary using wasm-opt."),await ge(i,o,{cwd:n})}async function rr(e){let t,n=await Up(e);if(n.includes("shopify_function_v1")?t=Ho:n.includes("shopify_function_v2")&&(t=Go),!t)return;let i=Zo(t);await Ae(i);let o=i.path,r=["-i",e,"-o",e];S(`Applying trampoline to the wasm binary with command: ${o} ${r.join(" ")}`),await ge(o,r)}async function Up(e){let t=new Uint8Array(ce(e));if(!WebAssembly.validate(t))return[];let i=new WebAssembly.Module(t),o=WebAssembly.Module.imports(i);return[...new Set(o.map(r=>r.module))]}async function sr(e,t,n,i=[]){let o=In(n.javy),r=Tn(n.javyPlugin);await Promise.all([Ae(o),Ae(r)]);let s=["build","-C","dynamic","-C",`plugin=${r.path}`,...i,"-o",e.outputPath,"dist/function.js"];return ge(o.path,s,{cwd:e.directory,stdout:"inherit",stderr:"inherit",signal:t.signal})}async function yf(e){let n=e.allExtensions.filter(a=>a.features.includes("function")&&a.isJavaScript).map(a=>nr(a)),i=await Promise.all(n),o=new Set,r=new Set;i.forEach(a=>{o.add(a.javy),r.add(a.javyPlugin)});let s=[];o.forEach(a=>{s.push(Ae(In(a)))}),r.forEach(a=>{s.push(Ae(Tn(a)))}),await Promise.all(s)}var Bp={async bundle(e,t){return Op(e,t)},async compile(e,t,n){return sr(e,t,n)}},Qo="shopify-function",kn=class{constructor(t){this.exports=t}async bundle(t,n,i=process.env){await tr(t);let o=this.entrypointContents;S("Generating dist/function.js using generated module:"),S(o);let r={...ir(t.directory,t.entrySourceFilePath,n.app.dotenv?.variables??{},i),stdin:{contents:o,loader:"ts",resolveDir:t.directory}};return Xo(r)}async compile(t,n,i){let o=this.wit;return S("Generating world to use with Javy:"),S(o),Ct(async r=>{let s=y(r,"javy-world.wit");return await B(s,o),sr(t,n,i,["-C",`wit=${s}`,"-C",`wit-world=${Qo}`])})}get wit(){let t=this.exports.map(n=>`export %${mn(n)}: func();`);return`package function:impl;
6
+
7
+ world ${Qo} {
8
+ ${t.join(`
9
+ `)}
10
+ }`}get entrypointContents(){let t=`
11
+ import __runFunction from "@shopify/shopify_function/run"`,n=this.exports.map(i=>{let o=fn(i),r=fn(`run-${i}`);return`
12
+ import { ${o} as ${r} } from "user-function"
13
+ export function ${o}() { return __runFunction(${r}) }`});return`${t}
14
+ ${n.join(`
15
+ `)}`}};function $p(e){let t=e.configuration.targeting??[],n=t.filter(r=>!r.export),i=t.filter(r=>!!r.export);if(t.length>1&&n.length>0)throw new Error(`Can't infer export name for targets:
16
+ ${n.map(({target:r})=>`- '${r}'`).join(`
17
+ `)}
18
+ All targets must have an export when multiple targets are present.`);let o=i.filter(r=>!r.export.match(/^[a-z0-9-]+$/));if(o.length>0){let r=[],s=o.map(a=>`'${a.export}'`);throw r.push(`Invalid export names: ${s.join(", ")}.
19
+
20
+ The TOML's exports must be kebab-case (lowercase, hyphen or numbers) to comply with WebAssembly's Component Model.
21
+
22
+ JavaScript exports with camelCase names are automatically mapped to kebab-case Wasm exports.
23
+ `),r.push("Suggested TOML changes:"),o.forEach(a=>{let c=a.export;r.push(`- Change export for '${a.target}' to '${mn(c)}'.`)}),new Error(r.join(`
24
+ `))}return i.map(r=>r.export)}u();function ar(e,t){return async n=>{let i=await e.appsForOrg(t,n);return{apps:i.apps,hasMorePages:i.hasMorePages}}}u();var Lp=Zi({cmd_app_warning_api_key_deprecation_displayed:!1}),q=Lp;u();u();import{deflate as jp}from"node:zlib";import{promisify as Np}from"node:util";var Wp=Np(jp);async function Vp(e){let t=await F(e),n=Buffer.byteLength(t),o=(await Wp(Buffer.from(t))).byteLength;return{path:e,rawBytes:n,compressedBytes:o}}function pr(e){return e>=1024*1024?`${(e/(1024*1024)).toFixed(2)} MB`:`${(e/1024).toFixed(1)} KB`}async function cr(e){try{let{rawBytes:t,compressedBytes:n}=await Vp(e);return` (${pr(t)} original, ~${pr(n)} compressed)`}catch(t){return S(`Failed to get bundle size for ${e}: ${t}`),""}}u();u();import{createInterface as zp}from"readline";var Jp=[".git",".hg",".bzr",".svn","_darcs","CVS",".sublime-(project|workspace)",".DS_Store",".sass-cache","Thumbs.db","desktop.ini","config.yml","node_modules",".gitkeep",".shopifyignore","*.toml"];async function Le(e){let n=y(e.directory,".shopifyignore"),i=Jp.map(o=>y("*",o));if(H(n)){let o=await qp(n);i.push(...o)}return D("*/*",{absolute:!0,cwd:e.directory,ignore:i})}function qp(e){return new Promise((t,n)=>{let i=[],o=zp({input:Mi(e),crlfDelay:1/0});o.on("line",r=>{let s=r.trim();s.length>0&&!s.startsWith("#")&&i.push(s)}),o.on("close",()=>{t(i)}),o.on("error",r=>{n(r)})})}import{context as Kp,formatMessagesSync as lr}from"esbuild";var ur=qe(Pp(),1);async function Fn(e,t=process.env){let n=Yp(e,t),i=await Kp(n),o=await i.rebuild();Gp(o,e),await Hp(o,e.outputPath),await i.dispose()}async function dr(e,t){t.stdout.write(`Bundling theme extension ${e.localIdentifier}...`);let n=await Le(e);await Promise.all(n.map(function(i){let o=I(e.directory,i),r=y(e.outputPath,o);if(i!==r)return N(i,r)}))}async function Hp(e,t){if(!e?.metafile)return;let{dir:n,name:i}=vi(t),o=y(n,`${i}.metafile.json`);try{await B(o,JSON.stringify(e.metafile))}catch(r){ue(`Failed to write metafile to ${o}: ${r}`)}}function Gp(e,t){let n=e?.warnings??[],i=e?.errors??[];n.length>0&&lr(n,{kind:"warning"}).forEach(r=>{t.stdout.write(r)}),i.length>0&&lr(i,{kind:"error"}).forEach(r=>{t.stderr.write(r)})}function Yp(e,t=process.env){let n=me(t,(s,a)=>Ot.test(a)&&s),i={...e.env,...n},o=Object.keys(i||{}).reduce((s,a)=>({...s,[`process.env.${a}`]:JSON.stringify(i[a])}),{"process.env.NODE_ENV":JSON.stringify(e.environment)}),r={outfile:e.outputPath,stdin:e.stdin,bundle:!0,define:o,jsx:"automatic",logLevel:e.logLevel??"error",loader:{".esnext":"ts",".js":"jsx"},legalComments:"none",minify:e.minify,plugins:Zp(e.stdin.resolveDir,t),target:"es6",resolveExtensions:[".tsx",".ts",".js",".json",".esnext",".mjs",".ejs"]};if(e.sourceMaps&&(r.sourcemap=!0,r.sourceRoot=`${e.stdin.resolveDir}/src`),e.environment==="production"&&(r.metafile=!0),e.environment==="development"){let s=i[bn.disableMinificationOnDev];r.minify=!Ke(s),r.logLevel="silent"}return r}function Zp(e,t=process.env){let n=[ur.default.default()],i=Ke(t[bn.skipEsbuildReactDedeuplication]);if(e&&!i){let o;try{o=Si.resolve("react",{paths:[e]})}catch{S(`Unable to load React in ${e}, skipping React de-duplication`)}o&&(S(`Deduplicating React dependency for ${e}, using ${o}`),n.push(Qp(o)))}return n}function Qp(e){return{name:"shopify:deduplicate-react",setup({onResolve:t}){t({filter:/^react$/},n=>({path:e}))}}}u();var jt="# api_version: ";function Yf(e,t){return`${jt}${t}
25
+
26
+ ${e}`}async function Xp(e){if(!await w(e)){S(`Could not determine api_version: schema file not found at ${e}.`);return}let n=(await F(e)).split(`
27
+ `,1)[0];if(n.startsWith(jt))return n.slice(jt.length).trim();S(`Could not determine api_version from ${e}: missing '${jt}' marker on the first line.`)}async function fr({directory:e,localIdentifier:t,apiVersion:n}){let i=y(e,"schema.graphql"),o=await Xp(i);if(o!==void 0&&o!==n)throw new b(A`The ${v.cyan("schema.graphql")} file for ${v.cyan(t)} was generated for api_version ${v.yellow(o)} but your function is now on api_version ${v.yellow(n)}.`,A`Run ${v.genericShellCommand("shopify app function schema")} to refresh it.`)}var mr=qe(vp(),1);async function gr(e,t){t.stdout.write(`Bundling UI extension ${e.localIdentifier}...`);let n=t.app.dotenv?.variables??{};t.appURL&&(n.APP_URL=t.appURL);let i=t.buildDirectory??"",o=y(e.directory,i,e.outputRelativePath),{main:r,assets:s}=e.getBundleExtensionStdinContent(),a=performance.now();try{await Fn({minify:!0,outputPath:o,stdin:{contents:r,resolveDir:e.directory,loader:"tsx"},environment:t.environment,env:n,stderr:t.stderr,stdout:t.stdout,sourceMaps:e.isSourceMapGeneratingExtension}),s&&await Promise.all(s.map(async l=>{await Fn({minify:!0,outputPath:y(P(o),l.outputFileName),stdin:{contents:l.content,resolveDir:e.directory,loader:"tsx"},environment:t.environment,env:n,stderr:t.stderr,stdout:t.stdout})}))}catch(l){let f=l.message??"Unknown error occurred",_=new b(`Failed to bundle extension ${e.localIdentifier}. Please check the extension source code for errors.`,f);throw _.errors=l.errors,_}await e.buildValidation({outputPath:o});let c=Math.round(performance.now()-a),d=await cr(o);return t.stdout.write(`${e.localIdentifier} successfully built in ${c}ms${d}`),o}async function yr(e,t){let n=y(e.directory,".build-lock"),i;try{i=await mr.default.lock(e.directory,{retries:20,lockfilePath:n})}catch(o){throw S(`Failed to acquire function build lock: ${o.message}`),new b("Failed to build function.","This is likely due to another in-progress build.",["Ensure there are no other function builds in-progress.","Delete the `.build-lock` file in your function directory."])}try{let o=e.configuration,r=e.outputPath,s=o.build?.path??e.outputRelativePath;e.outputPath=y(e.directory,s),await fr({directory:e.directory,localIdentifier:e.localIdentifier,apiVersion:o.api_version}),e.isJavaScript?await ec(e,t):await tc(e,t);let a=e.configuration.build?.wasm_opt;H(e.outputPath)&&a&&await or(e.outputPath),H(e.outputPath)&&await rr(e.outputPath);let c=y(e.directory,e.outputRelativePath);H(e.outputPath)&&r!==e.outputPath&&r!==c&&P(r)!==P(e.outputPath)&&await Mn(e.outputPath,r)}catch(o){if(o instanceof b)throw o;let r=o.message??"Unknown error occurred",s=new b("Failed to build function.",r);throw s.errors=o.errors,s}finally{await i()}}async function Mn(e,t){S(`Converting WASM from ${e} to base64 in ${t}`);let n=await F(e,{encoding:"base64"});await wt(t),await B(t,n)}async function ec(e,t){return e.buildCommand?(e.typegenCommand&&await st(e,t),hr(e.buildCommand,e,t)):er(e,t)}async function tc(e,t){if(!e.buildCommand)throw t.stderr.write(`The function extension ${e.localIdentifier} doesn't have a build command or it's empty`),t.stderr.write(`
28
+ Edit the shopify.function.extension.toml configuration file and set how to build the extension.
29
+
30
+ [build]
31
+ command = "{COMMAND}"
32
+
33
+ Note that the command must output a dist/index.wasm file.
34
+ `),new V;return e.typegenCommand&&await st(e,t),hr(e.buildCommand,e,t)}async function hr(e,t,n){let i=e.split(" ");n.stdout.write(`Building function ${t.localIdentifier}...`),await ge(i[0],i.slice(1),{stdout:n.stdout,stderr:n.stderr,cwd:t.directory,signal:n.signal})}u();var _r="shopify.app*.toml",nc=/^shopify\.app(\.[-\w]+)?\.toml$/,ic="*.extension.toml",oc="shopify.web.toml",xr="extensions/*",br="**/node_modules/**",rc=".env*",at=class e{static async load(t){let n=await sc(t),i=[],o=await ac(n,i);if(o.length===0)throw new b(`Could not find a Shopify app TOML file in ${n}`);let r=new Set;for(let x of o){let C=x.content.extension_directories;if(Array.isArray(C))for(let E of C)r.add(E);else r.add(xr)}let s=await pc(n,[...r],i),a=new Set;for(let x of o){let C=x.content.web_directories;if(Array.isArray(C))for(let E of C)a.add(E)}let c=await cc(n,a.size>0?[...a]:void 0,i),d=y(n,"package.json"),l=await w(d),f=l?await Tt(n):"unknown",_=l?await Hi(d):{},g=l?await Gi(n):!1,m=await lc(n),h=await uc(n);return new e({directory:n,packageManager:f,nodeDependencies:_,usesWorkspaces:g,appConfigFiles:o,extensionConfigFiles:s,webConfigFiles:c,dotenvFiles:m,hiddenConfigRaw:h,errors:i})}constructor(t){this.directory=t.directory,this.packageManager=t.packageManager,this.nodeDependencies=t.nodeDependencies,this.usesWorkspaces=t.usesWorkspaces,this.appConfigFiles=t.appConfigFiles,this.extensionConfigFiles=t.extensionConfigFiles,this.webConfigFiles=t.webConfigFiles,this.dotenvFiles=t.dotenvFiles,this.hiddenConfigRaw=t.hiddenConfigRaw,this.errors=t.errors}appConfigByName(t){return this.appConfigFiles.find(n=>T(n.path)===t)}appConfigByClientId(t){return this.appConfigFiles.find(n=>n.content.client_id===t)}get defaultAppConfig(){return this.appConfigByName(z.app)}};async function sc(e){let t=await te(async n=>{if((await D(y(n,_r))).length>0)return n},{cwd:e,type:"directory"});if(!t)throw new b(`Could not find a Shopify app configuration file. Looked in ${e} and parent directories.`);return t}async function ac(e,t){let n=y(e,_r),o=(await D(n)).filter(r=>nc.test(T(r)));return Dn(o,t)}async function pc(e,t,n){let o=(t.length>0?t:[xr]).map(s=>y(e,s,ic));o.push(`!${y(e,br)}`);let r=await D(o);return Dn(r,n)}async function cc(e,t,n){let o=(t??["**"]).map(s=>y(e,s,oc));o.push(`!${y(e,br)}`);let r=await D(o);return Dn(r,n)}async function Dn(e,t){let n=[];return await Promise.all(e.map(async i=>{try{n.push(await U.read(i))}catch(o){let r=o instanceof tt?o:new tt(i,`Failed to read ${i}`),s=new U(i,{});s.errors.push(r),n.push(s),t.push(r)}})),n}async function lc(e){let t=y(e,rc),i=(await D(t,{dot:!0})).filter(s=>{let a=T(s);return a===".env"||/^\.env\.[\w-]+$/.test(a)}),o=await Promise.all(i.map(async s=>{try{let a=await fo(s);return[T(s),a]}catch{return}})),r=new Map;for(let s of o)s&&r.set(s[0],s[1]);return r}async function uc(e){let t=y(e,z.hiddenFolder,z.hiddenConfig);try{if(await w(t)){let n=await F(t);return JSON.parse(n)}}catch{}return{}}u();u();u();u();function dc(e,t){return t}async function Nt(e,t,n){let i={};try{let s=await F(e);i=JSON.parse(s)}catch{}let o={[t]:n},r=fe(i,o,dc);await B(e,JSON.stringify(r,null,2))}var fc=p.array(p.string()).optional().transform(mc).transform(gc);function mc(e){return e?.map(t=>t.replace(/[\/\\]+$/,""))}function gc(e){return e?.map(t=>t.replace(/([^\*])\*$/,"$1**"))}var pt=p.object({client_id:p.string(),build:p.object({automatically_update_urls_on_dev:p.boolean().optional(),dev_store_url:p.string().optional(),include_config_on_deploy:p.boolean().optional()}).optional(),extension_directories:fc,web_directories:p.array(p.string()).optional()}).passthrough();function Sr(e,t=!0){let n=e.reduce((i,o)=>o.contributeToAppConfigurationSchema(i),pt);return t?n.passthrough():e.length>0?n.strict():n}function Rn(e){return e.access_scopes?.scopes??""}function Vt(e){let t=Rn(e);return t.length?t.split(",").map(n=>n.trim()):[]}function yc(e){return y(e,z.hiddenFolder,z.hiddenConfig)}function On(e){let t=Object.keys(pt.shape).concat("organization_id");return Object.keys(e).filter(n=>!t.includes(n))}var Cr=p.preprocess(Cn,p.string()),wr=p.object({auth_callback_path:p.union([Cr,Cr.array()]).optional(),webhooks_path:p.preprocess(Cn,p.string()).optional(),port:p.number().max(65536).min(0).optional(),commands:p.object({build:p.string().optional(),predev:p.string().optional(),dev:p.string()}),name:p.string().optional(),hmr_server:p.object({http_paths:p.string().array()}).optional()}),Er=p.enum(["frontend","backend","background"]).default("frontend"),Pr=p.union([wr.extend({roles:p.array(Er)}),wr.extend({type:Er})]),Wt=class{constructor({name:t,directory:n,configPath:i,configuration:o,webs:r,modules:s,dotenv:a,errors:c,specifications:d,configSchema:l,remoteFlags:f,hiddenConfig:_,devApplicationURLs:g}){this.idEnvironmentVariableName="SHOPIFY_API_KEY";this.name=t,this.directory=n,this.configPath=i,this.configuration=o,this.webs=r,this.dotenv=a,this.realExtensions=s,this.errors=c??new lt,this.specifications=d,this.configSchema=l??pt,this.remoteFlags=f??[],this._hiddenConfig=_,g&&this.setDevApplicationURLs(g)}get allExtensions(){return this.includeConfigOnDeploy===!1?this.nonConfigExtensions:this.realExtensions}get nonConfigExtensions(){return this.realExtensions.filter(t=>!t.isAppConfigExtension)}get draftableExtensions(){return this.realExtensions.filter(t=>t.isUUIDStrategyExtension||t.specification.identifier===Bt)}setDevApplicationURLs(t){this.patchAppConfiguration(t),this.realExtensions.forEach(n=>n.patchWithAppDevURLs(t))}async manifest(t){let n=await Promise.all(this.realExtensions.map(async i=>{let o=await i.deployConfig({apiKey:String(this.configuration.client_id??""),appConfiguration:this.configuration});return{type:i.externalType,handle:i.handle,uid:i.uid,uuid:t?.extensions[i.localIdentifier],assets:i.uid,target:i.contextValue,config:o??{}}}));return{name:this.name,handle:"",modules:Pe(n)}}get hiddenConfig(){return this._hiddenConfig}getLogsDir(){return y(this.directory,".shopify","logs")}async updateHiddenConfig(t){if(!this.configuration.client_id)return;this._hiddenConfig=fe(this.hiddenConfig,t);let n=yc(this.directory);await Nt(n,String(this.configuration.client_id),this.hiddenConfig)}async preDeployValidation(){this.validateWebhookLegacyFlowCompatibility();let t=this.allExtensions.filter(i=>i.isFunctionExtension&&i.configuration.ui?.handle);if(t.length>0){let i=hc(t,this.allExtensions);if(i)throw new b("Invalid function configuration",i.join(`
35
+ `))}let n=this.allExtensions.filter(i=>i.isEditorExtensionCollection);if(n.length>0){let i=_c(n,this.allExtensions);if(i)throw new b("Invalid editor extension collection configuration",i.join(`
36
+
37
+ `))}await Promise.all(this.allExtensions.map(i=>i.preDeployValidation()))}extensionsForType(t){return this.allExtensions.filter(n=>n.type===t.identifier||n.type===t.externalIdentifier)}updateExtensionUUIDS(t){this.allExtensions.forEach(n=>{n.devUUID=t[n.localIdentifier]??n.devUUID})}appIsLaunchable(){let t=this.webs.find(i=>re(i,"frontend")),n=this.webs.find(i=>re(i,"backend"));return!!(t??n)}get appIsEmbedded(){return this.configuration.embedded}creationDefaultOptions(){return{isLaunchable:this.appIsLaunchable(),scopesArray:Vt(this.configuration),name:this.name,isEmbedded:this.appIsEmbedded,directory:this.directory}}removeExtension(t){this.realExtensions=this.realExtensions.filter(n=>n.uid!==t)}async generateExtensionTypes(){let t=new Map;await Promise.all(this.allExtensions.map(n=>n.contributeToSharedTypeFile(t))),t.forEach((n,i)=>{let o=H(i);if(n.size===0){o&&Fi(i);return}let r=o?ce(i).toString():"",s=[`import '@shopify/ui-extensions';
38
+ `,...Array.from(n)].join(`
39
+ `);r!==s&&ki(i,s)})}get includeConfigOnDeploy(){return this.configuration.build?.include_config_on_deploy}patchAppConfiguration(t){this.devApplicationURLs=t,this.configuration.application_url=t.applicationUrl,t.appProxy&&(this.configuration.app_proxy={url:t.appProxy.proxyUrl,subpath:t.appProxy.proxySubPath,prefix:t.appProxy.proxySubPathPrefix}),this.configuration.auth?.redirect_urls&&(this.configuration.auth.redirect_urls=t.redirectUrlWhitelist)}validateWebhookLegacyFlowCompatibility(){let t=this.configuration.webhooks?.subscriptions?.some(i=>i.topics&&i.topics.length>0)??!1,n=this.configuration.access_scopes?.use_legacy_install_flow===!0;if(t&&n)throw new b("App-specific webhook subscriptions are not supported when use_legacy_install_flow is enabled.",`To use app-specific webhooks, you need to:
40
+ 1. Remove 'use_legacy_install_flow = true' from your configuration
41
+ 2. Run 'shopify app deploy' to sync your scopes with the Developer Dashboard
42
+
43
+ Alternatively, continue using shop-specific webhooks with the legacy install flow.
44
+
45
+ Learn more: https://shopify.dev/docs/apps/build/authentication-authorization/app-installation`)}};function hc(e,t){let n=[];return e.forEach(i=>{let o=i.configuration.ui.handle,r=vr(t,o);r?r.type!=="ui_extension"&&n.push(`[${i.name}] - Local app must contain one extension of type 'ui_extension' and handle '${o}'`):n.push(`[${i.name}] - Local app must contain a ui_extension with handle '${o}'`)}),n.length>0?n:void 0}function _c(e,t){let n=[],i=["ui_extension"];return e.forEach(o=>{o.configuration.inCollection.forEach(r=>{let s=vr(t,r.handle);s?i.includes(s.specification.identifier)?s.specification.identifier==="ui_extension"&&s.configuration.extension_points.forEach(c=>{c.target.startsWith("admin.")&&n.push(`[${o.handle}] editor extension collection: Remove extension '${s.configuration.handle}' with target '${c.target}' from this collection. This extension target is not supported in collections.`)}):n.push(`[${o.handle}] editor extension collection: Remove extension of type '${s.specification.identifier}' from this collection. This extension type is not supported in collections.`):n.push(`[${o.handle}] editor extension collection: Add extension with handle '${r.handle}' to local app. Local app must include extension with handle '${r.handle}'.`)})}),n.length>0?n:void 0}function vr(e,t){return e.find(n=>n.handle===t)}async function $m(e){let t=e.dependency;if(t)return ct(t,e.directory)}async function ct(e,t){let n=e.replace("-react","").split("/"),i=y("node_modules",n[0],n[1],"package.json"),o=await te(i,{cwd:t,type:"file",allowSymlinks:!0});if(!o)return"not_found";o=await Ge(o);let r=await Yi(o);return r.version?{name:e,version:r.version}:"not_found"}u();function xc(e){if(!e?.length)return null;let t=null,n=-1;for(let i of e){if(!i.issues?.length)continue;let o=0,r=0,s=0;for(let c of i.issues)c.message?.includes("Required")||c.message?.includes("required")?o++:c.message?.includes("Expected")&&c.message?.includes("received")?r++:s++;let a;o>0?a=1e3-o*10-r-s:r>0?a=100-r*5-s:a=50-s,a>n&&(n=a,t=i)}return t}function Ar(e){let t=[];for(let n of e)if(n.code==="invalid_union"&&n.unionErrors){let i=xc(n.unionErrors);if(i?.issues?.length)for(let o of i.issues)t.push({path:o.path,message:o.message,code:n.code});else t.push({path:n.path,message:n.message??"Configuration doesn't match any expected format",code:n.code})}else t.push({path:n.path,message:n.message??"Unknown error",code:n.code});return t}u();var Ir=/^shopify\.app(\.[-\w]+)?\.toml$/;function X(e){return e?zt(e)?e:`shopify.app.${j(e)}.toml`:z.app}function ut(e){return T(e).match(Ir)?.[1]?.slice(1)}function zt(e){return!!Ir.test(e)}u();u();u();u();u();u();u();async function je(e,t,n){let[i,o]=await Promise.all([Ge(e),Ge(t)]),r=I(o,i);if(r.split(/[/\\]/,1)[0]===".."||Pi(r))throw new b(`Asset path '${n}' resolves outside the app directory.`,`Asset sources must be inside the app folder. Resolved to: ${i}`)}async function kr(e){let{key:t,baseDir:n,outputDir:i,context:o,appDirectory:r,destination:s,usedBasenames:a=new Set,preserveFilePaths:c=!1}=e,{stdout:d}=o.options,l=Jt(o.extension.configuration,t),f;typeof l=="string"?f=[l]:Array.isArray(l)?f=l.filter(x=>typeof x=="string"):f=[];for(let x of f)if(x.trim()==="")throw new b(`'${t}' can't be empty.`);if(f.length===0)return S(`No value for configKey '${t}', skipping
46
+ `,d),{filesCopied:0,pathMap:new Map};let _=s?y(i,s):i,g=[...new Set(f)],m=new Map,h=0;for(let x of g){let C=y(n,x);if(!await w(C))throw new Error(A`Couldn't find ${v.path(C)}\n Please check the path '${x}' in your configuration`.value);await je(C,r,x);let M=await de(C),Y=_;if(M){let K=await D(["**/*"],{cwd:C,absolute:!1}),ae=K.map(Ee=>I(i,y(Y,Ee)));if(c)for(let Ee of K)Tr(T(Ee),x,a);await vt(C,Y),d.write(`Included '${x}'
47
+ `);for(let Ee of K)a.add(T(Ee));m.set(x,ae),h+=K.length}else{await Z(Y);let K=T(C),ae;c?(Tr(K,x,a),ae=K):ae=bc(K,a),a.add(ae);let Ee=I(i,y(Y,ae)),Cp=y(Y,ae);await N(C,Cp),d.write(`Included '${x}'
48
+ `),m.set(x,Ee),h+=1}}return{filesCopied:h,pathMap:m}}function Tr(e,t,n){if(n.has(e))throw new b(`File collision: '${e}' from '${t}' would overwrite a file copied from a different source. Rename or relocate the conflicting file.`)}function bc(e,t){if(!t.has(e))return e;let n=_t(e),i=n?e.slice(0,-n.length):e,o=1e3,r=1;for(;t.has(`${i}-${r}${n}`);)if(r++,r>o)throw new Error(`Unable to find unique basename for '${e}' after ${o} attempts`);return`${i}-${r}${n}`}function Un(e){return e.split(".").map(t=>{let n=t.endsWith("[]");return{name:n?t.slice(0,-2):t,flatten:n}})}function Jt(e,t){let n=e;for(let{name:i,flatten:o}of Un(t)){if(n==null)return;if(Array.isArray(n)){let r=n.map(s=>s!==null&&typeof s=="object"?s[i]:void 0).filter(s=>s!==void 0);n=r.length>0?r:void 0}else if(typeof n=="object")n=n[i];else return;if(o){if(!Array.isArray(n))return;n=n.flat(1)}}return n}function Ln(e){return _t(e)?P(e):e}async function Fr(e,t,n,i){let{extension:o,options:r}=t,s=[],a=[];for(let l of e)typeof l.anchor=="string"&&typeof l.groupBy=="string"?s.push(l):a.push(l);if(s.length===0&&a.length===0&&i.length===0)return;let c={};for(let l of a){let f=Ec(l.key),_=Jt(o.configuration,l.key);_!=null&&(c[f]=qt(_,n))}let d=new Map;for(let l of s){let f=`${l.anchor}||${l.groupBy}`,_=d.get(f);_?_.push(l):d.set(f,[l])}for(let l of d.values()){let{anchor:f,groupBy:_}=l[0],g=Jt(o.configuration,f);if(Array.isArray(g))for(let m of g){if(m===null||typeof m!="object"||Array.isArray(m))continue;let h=m,x=h[_];if(typeof x!="string")continue;let C=l.map(Y=>{let K=Cc(Y.key,f),ae=Bn(h,K);return qt(ae,n)});C.some($n)&&r.stdout.write(`Warning: manifest entry '${x}' contains unresolved paths \u2014 source files may be missing
49
+ `);let M=c[x]??{};c[x]=wc([M,...C])}}if(i.length>0&&(c.files=i),Object.keys(c).length===0){r.stdout.write(`Warning: no manifest entries produced \u2014 skipping manifest.json
50
+ `);return}await jn(t,c)}async function jn(e,t){let n=Ln(e.extension.outputPath),i=y(n,"manifest.json");await w(n)||await Z(n);let o={};if(await w(i))try{let r=await F(i);o=JSON.parse(r)}catch{S(`Warning: could not parse existing manifest.json, starting fresh
51
+ `,e.options.stdout)}for(let[r,s]of Object.entries(t)){let a=o[r];a&&typeof a=="object"&&!Array.isArray(a)&&typeof s=="object"&&!Array.isArray(s)?o[r]={...a,...s}:o[r]=s}await B(i,JSON.stringify(o,null,2)),S(`Updated manifest.json in ${n}
52
+ `,e.options.stdout)}function Cc(e,t){if(t===e)return"";let n=`${t}.`;return e.startsWith(n)?e.slice(n.length):e}function Bn(e,t){if(t==="")return e;let n=Un(t),[i,...o]=n;if(!i)return e;let r=o.map(a=>`${a.name}${a.flatten?"[]":""}`).join("."),s=e[i.name];if(i.flatten){if(!Array.isArray(s))return{[i.name]:s};let a=s.map(c=>r?Bn(c,r):c);return{[i.name]:a}}return r&&s!==null&&s!==void 0&&typeof s=="object"&&!Array.isArray(s)?{[i.name]:Bn(s,r)}:{[i.name]:s}}function wc(e){return Object.assign({},...e)}function qt(e,t){if(typeof e=="string")return(e.startsWith(".")||e.includes("/")||e.includes("\\")||t.has(e)?t.get(e):void 0)??e;if(Array.isArray(e))return e.map(n=>qt(n,t));if(e!==null&&typeof e=="object"){let n={};for(let[i,o]of Object.entries(e))n[i]=qt(o,t);return n}return e}function Ec(e){let t=e.split(".").at(-1)??e;return t.endsWith("[]")?t.slice(0,-2):t}function $n(e){return typeof e=="string"?e.startsWith("./")||e.startsWith("../"):Array.isArray(e)?e.some($n):e!==null&&typeof e=="object"?Object.values(e).some($n):!1}u();async function Mr(e,t){let{sourceDir:n,outputDir:i,patterns:o,ignore:r,appDirectory:s,sourceDirConfigValue:a}=e;if(!await w(n))return{filesCopied:0,outputPaths:[]};await je(n,s,a);let c=await D(o,{absolute:!0,cwd:n,ignore:r});if(c.length===0)return{filesCopied:0,outputPaths:[]};await Z(i);let d=c,l=await Promise.all(d.map(async g=>{let m=I(n,g),h=y(i,m);return I(i,h).startsWith("..")?(t.stdout.write(`Warning: skipping '${g}' - resolved destination is outside the output directory
53
+ `),{count:0,path:null}):g===h?{count:0,path:null}:(await Z(P(h)),await N(g,h),{count:1,path:m})})),f=l.reduce((g,m)=>g+m.count,0),_=l.flatMap(g=>g.path===null?[]:[g.path]);return t.stdout.write(`Included ${f} file(s)
54
+ `),{filesCopied:f,outputPaths:_}}u();async function Dr(e,t){let{source:n,destination:i,baseDir:o,outputDir:r,appDirectory:s}=e,a=y(o,n);if(!await w(a))throw new Error(`Source does not exist: ${a}`);await je(a,s,n);let c=await de(a),d,l;if(i===void 0?(d=y(r,T(a)),l=`Included ${n}
55
+ `):(d=y(r,i),l=`Included ${n}
56
+ `),c){let f=await D(["**/*"],{cwd:a,absolute:!1});await vt(a,d),t.stdout.write(l);let _=I(r,d),g=_?f.map(m=>y(_,m)):f;return{filesCopied:f.length,outputPaths:g}}return await Z(P(d)),await N(a,d),t.stdout.write(l),{filesCopied:1,outputPaths:[I(r,d)]}}var Sc=p.object({type:p.literal("pattern"),baseDir:p.string().optional(),include:p.array(p.string()).default(["**/*"]),ignore:p.array(p.string()).optional(),destination:p.string().optional()}),Pc=p.object({type:p.literal("static"),source:p.string(),destination:p.string().optional()}),vc=p.object({type:p.literal("configKey"),key:p.string(),destination:p.string().optional(),anchor:p.string().optional(),groupBy:p.string().optional(),preserveFilePaths:p.boolean().default(!1)}),Ac=p.discriminatedUnion("type",[Sc,Pc,vc]),Ic=p.object({inclusions:p.array(Ac),generatesAssetsManifest:p.boolean().default(!1)}).strict().superRefine((e,t)=>{for(let[n,i]of e.inclusions.entries())if(i.type==="configKey"){let o=i.anchor!==void 0,r=i.groupBy!==void 0;o!==r&&t.addIssue({code:p.ZodIssueCode.custom,message:"`anchor` and `groupBy` must both be set or both be omitted",path:["inclusions",n]})}});async function Rr(e,t){let n=Ic.parse(e.config),{extension:i,options:o}=t,r=Ln(i.outputPath),s=o.app.directory,a=new Map,c=new Set,d=0;for(let g of n.inclusions){if(g.type!=="configKey")continue;let m=E=>o.stdout.write(E),h=g.destination?ln(g.destination,m):void 0,x=h===""?void 0:h,C=await kr({key:g.key,baseDir:i.directory,outputDir:r,context:t,appDirectory:s,destination:x,usedBasenames:c,preserveFilePaths:g.preserveFilePaths});C.pathMap.forEach((E,M)=>a.set(M,E)),d+=C.filesCopied}let l=await Promise.all(n.inclusions.filter(g=>g.type!=="configKey").map(async g=>{let m=C=>o.stdout.write(C),h=g.destination?ln(g.destination,m):void 0,x=h===""?void 0:h;if(g.type==="pattern"){let C=g.baseDir?y(i.directory,g.baseDir):i.directory,E=x?y(r,x):r,M=await Mr({sourceDir:C,outputDir:E,patterns:g.include,ignore:g.ignore??[],appDirectory:s,sourceDirConfigValue:g.baseDir??"."},o),Y=x?M.outputPaths.map(K=>y(x,K)):M.outputPaths;return{filesCopied:M.filesCopied,outputPaths:Y}}if(g.type==="static")return Dr({source:g.source,destination:x,baseDir:i.directory,outputDir:r,appDirectory:s},o)})),f=n.generatesAssetsManifest?l.flatMap(g=>g?.outputPaths??[]):[],_=[d,...l.map(g=>g?.filesCopied??0)];if(n.generatesAssetsManifest){let g=n.inclusions.filter(m=>m.type==="configKey");await Fr(g,t,a,f)}return{filesCopied:_.reduce((g,m)=>g+(m??0),0)}}u();u();var _e=qe(wp(),1);function Tc(e,t,n){let i=_e.path.fsPath(e),s=ce(i).toString().split(`
57
+ `).slice(t,n+1),a=s.length===1;return s.map((c,d)=>{let l=t+d+1,f=a?c.trim():c;return`${l} ${f}`}).join(`
58
+ `)}function kc(e){switch(e){case _e.Severity.ERROR:return{error:`
59
+ [error]:`};case _e.Severity.WARNING:return{warn:`
60
+ [warning]:`};case _e.Severity.INFO:return{info:`
61
+ [info]:`}}}function Fc(e){return e.map((n,i)=>{let{message:o,uri:r,start:s,end:a,check:c,severity:d}=n,l=Tc(r,s.line,a.line),f=i===e.length-1?"":`
62
+
63
+ `;return[kc(d),{bold:c},{subdued:`
64
+ ${o}`},`
65
+
66
+ ${l}`,f]}).flat()}async function Or(e){let n=await(0,_e.check)(e,"theme-check:theme-app-extension"),i=Fc(n);return so(i)}async function Ur(e,t){let{extension:n,options:i}=t;i.stdout.write("Running theme check on your Theme app extension...");let o=await Or(n.directory);o&&i.stdout.write(o)}u();async function Br(e,t){let{extension:n,options:i}=t;i.stdout.write(`Bundling theme extension ${n.localIdentifier}...`);let o=await Le(n);return await Promise.all(o.map(async r=>{let s=I(n.directory,r),a=y(n.outputPath,s);r!==a&&await N(r,a)})),{filesCopied:o.length}}u();async function $r(e,t){let n=t.extension.configuration;t.options.buildDirectory=e.config?.bundleFolder??void 0;let i=await gr(t.extension,t.options),o=P(i),r=e.config?.bundleFolder?y(P(t.extension.outputPath),e.config.bundleFolder):P(t.extension.outputPath);if(pe(o)===pe(r)||(await N(o,r),!e.config?.generatesAssetsManifest)||!Array.isArray(n.extension_points))return;let s=n.extension_points.filter(c=>typeof c=="object"&&c.build_manifest),a=Mc(s,e.config?.bundleFolder);Object.keys(a).length>0&&await jn(t,a)}function Mc(e,t){let n={};for(let{target:i,build_manifest:o}of e){if(!o?.assets)continue;let r={};for(let[s,a]of Object.entries(o.assets))a?.filepath&&(r[s]=t?y(t,a.filepath):a.filepath);Object.keys(r).length>0&&(n[i]=r)}return n}u();async function Lr(e,t){return yr(t.extension,t.options)}u();async function jr(e,t){let{extension:n}=t;if(await w(n.outputPath)&&await de(n.outputPath))throw new Error(`outputPath '${n.outputPath}' is a directory \u2014 expected a file path for the tax stub`);await wt(n.outputPath),await B(n.outputPath,"(()=>{})();")}async function Nr(e,t){switch(e.type){case"include_assets":return Rr(e,t);case"build_theme":return Ur(e,t);case"bundle_theme":return Br(e,t);case"bundle_ui":return $r(e,t);case"build_function":return Lr(e,t);case"create_tax_stub":return jr(e,t);default:throw new Error(`Unknown build step type: ${e.type}`)}}async function Wr(e,t){let n=Date.now();try{let i=await Nr(e,t);return{id:e.id,success:!0,duration:Date.now()-n,output:i}}catch(i){let o=i;if(e.continueOnError)return t.options.stderr.write(`Warning: Step "${e.name}" failed but continuing: ${o.message}
67
+ `),{id:e.id,success:!1,duration:Date.now()-n,error:o};throw o.message=`Build step "${e.name}" failed: ${o.message}`,o}}var Dc=["**/node_modules/**","**/.git/**","**/*.test.*","**/dist/**","**/*.swp","**/generated/**","**/.gitignore"],Kt=class{get graphQLType(){return(this.specification.graphQLType??this.specification.identifier).toUpperCase()}get type(){return this.specification.identifier}get humanName(){return this.specification.externalName}get name(){return this.configuration.name??this.specification.externalName}get dependency(){return this.specification.dependency}get externalType(){return this.specification.externalIdentifier}get surface(){return this.specification.surface}get isPreviewable(){return this.features.includes("ui_preview")}get isThemeExtension(){return this.features.includes("theme")}get isFunctionExtension(){return this.features.includes("function")}get isESBuildExtension(){return this.features.includes("esbuild")}get isSourceMapGeneratingExtension(){return this.features.includes("generates_source_maps")}get isAppConfigExtension(){return this.specification.experience==="configuration"}get isFlow(){return this.specification.identifier.includes("flow")}get isEditorExtensionCollection(){return this.specification.identifier==="editor_extension_collection"}get hasDeploySteps(){return this.specification.clientSteps?.some(t=>t.lifecycle==="deploy"&&t.steps.length>0)??!1}get features(){return this.specification.appModuleFeatures(this.configuration)}get outputFileName(){return T(this.outputRelativePath)}get outputRelativePath(){return this.specification.getOutputRelativePath?.(this)??""}constructor(t){this.configuration=t.configuration,this.configurationPath=t.configurationPath,this.entrySourceFilePath=t.entryPath??"",this.directory=t.directory,this.specification=t.specification,this.handle=this.buildHandle(),this.localIdentifier=this.handle,this.idEnvironmentVariableName=`SHOPIFY_${bt(this.localIdentifier)}_ID`,this.outputPath=y(this.directory,this.outputRelativePath),this.uid=this.buildUIDFromStrategy(),this.devUUID=`dev-${this.uid}`}get draftMessages(){if(this.isAppConfigExtension)return{successMessage:void 0,errorMessage:void 0};let t=`Draft updated successfully for extension: ${this.localIdentifier}`,n=`Error updating extension draft for ${this.localIdentifier}`;return{successMessage:t,errorMessage:n}}get isUUIDStrategyExtension(){return this.specification.uidStrategy==="uuid"}get isSingleStrategyExtension(){return this.specification.uidStrategy==="single"}get isDynamicStrategyExtension(){return this.specification.uidStrategy==="dynamic"}get outputPrefix(){return this.handle}isSentToMetrics(){return!this.isAppConfigExtension}isReturnedAsInfo(){return!this.isAppConfigExtension}async deployConfig({apiKey:t,appConfiguration:n}){let i=await this.specification.deployConfig?.(this.configuration,this.directory,t,void 0),o=this.specification.transformLocalToRemote?.(this.configuration,n),r=i??o??void 0;return r&&Object.keys(r).length>0?r:void 0}validate(){return this.specification.validate?this.specification.validate(this.configuration,this.configurationPath,this.directory):Promise.resolve(le(void 0))}preDeployValidation(){return this.specification.preDeployValidation?this.specification.preDeployValidation(this):Promise.resolve()}buildValidation({outputPath:t}){return this.specification.buildValidation?this.specification.buildValidation(this,t):Promise.resolve()}async keepBuiltSourcemapsLocally(t){if(!this.isSourceMapGeneratingExtension)return Promise.resolve();let i=(await D(`**/${this.handle}.js.map`,{cwd:t,absolute:!0,followSymbolicLinks:!1}))[0];if(i===void 0)return Promise.resolve();let o=y(this.directory,I(t,i));await St(i,o,{overwrite:!0}),S(`Source map for ${this.localIdentifier} created: ${o}`)}async publishURL(t){let n=await ji(),i=this.specification.partnersWebIdentifier;return`https://${n}/${t.orgId}/apps/${t.appId}/extensions/${i}/${t.extensionId}`}getOutputFolderId(t){return t??this.uid}getBundleExtensionStdinContent(){return this.specification.getBundleExtensionStdinContent?this.specification.getBundleExtensionStdinContent(this.configuration):{main:`import '.${this.entrySourceFilePath.replace(this.directory,"")}';`}}shouldFetchCartUrl(){return this.features.includes("cart_url")}hasExtensionPointTarget(t){return this.specification.hasExtensionPointTarget?.(this.configuration,t)??!1}get buildCommand(){return this.configuration.build?.command}get typegenCommand(){return this.configuration.build?.typegen_command}devSessionDefaultWatchPaths(){if(this.specification.identifier==="ui_extension"){let{main:t,assets:n}=this.getBundleExtensionStdinContent(),i=xn(t,this.directory),o=n?.flatMap(r=>xn(r.content,this.directory))??[];return i.concat(...o)}return[this.entrySourceFilePath]}get devSessionWatchConfig(){return this.specification.devSessionWatchConfig?this.specification.devSessionWatchConfig(this):this.isAppConfigExtension?{paths:[]}:void 0}async watchConfigurationPaths(){if(this.isAppConfigExtension)return[this.configurationPath];{let t=[];return await w(y(this.directory,"locales"))&&t.push(y(this.directory,"locales","**.json")),t.push(y(this.directory,"**.toml")),t}}get inputQueryPath(){return y(this.directory,"input.graphql")}get isJavaScript(){return!!(this.entrySourceFilePath.endsWith(".js")||this.entrySourceFilePath.endsWith(".ts"))}async build(t){let{clientSteps:n=[]}=this.specification,i={extension:this,options:t,stepResults:new Map},o=n.find(r=>r.lifecycle==="deploy")?.steps??[];for(let r of o){let s=await Wr(r,i);i.stepResults.set(r.id,s)}}async buildForBundle(t,n,i){this.outputPath=this.getOutputPathForDirectory(n,i),await this.build(t);let o=y(n,this.getOutputFolderId(i));await this.keepBuiltSourcemapsLocally(o)}async copyIntoBundle(t,n,i){let o=this.outputPath;this.outputPath=this.getOutputPathForDirectory(n,i),this.isThemeExtension?await dr(this,t):this.hasDeploySteps&&(S(`Will copy pre-built file from ${o} to ${this.outputPath}`),await w(o)&&(await N(o,this.outputPath),this.isFunctionExtension&&await Mn(this.outputPath,this.outputPath)))}getOutputPathForDirectory(t,n){let i=this.getOutputFolderId(n);return y(t,i,this.outputRelativePath)}get singleTarget(){let t=W(this.configuration,"targeting")??[];if(t.length===1)return t[0]?.target}get contextValue(){let t=this.singleTarget??"";return this.isFlow&&(t=this.configuration.handle??""),t}async bundleConfig({identifiers:t,developerPlatformClient:n,apiKey:i,appConfiguration:o}){let r=await this.deployConfig({apiKey:i,appConfiguration:o});if(!r)return;let s={config:JSON.stringify(r),context:this.contextValue,handle:this.handle},a=this.isUUIDStrategyExtension?t.extensions[this.localIdentifier]:t.extensionsNonUuidManaged[this.localIdentifier];return{...s,uid:this.uid,uuid:a,specificationIdentifier:n.toExtensionGraphQLType(this.graphQLType)}}async getDevSessionUpdateMessages(){if(this.specification.getDevSessionUpdateMessages)return this.specification.getDevSessionUpdateMessages(this.configuration)}patchWithAppDevURLs(t){this.specification.patchWithAppDevURLs&&this.specification.patchWithAppDevURLs(this.configuration,t)}async contributeToSharedTypeFile(t){await this.specification.contributeToSharedTypeFile?.(this,t)}watchPatterns(){let t=this.devSessionWatchConfig;return{paths:t?.paths??["**/*"],ignore:t?.ignore??Dc}}watchedFiles(){let t=[],{paths:n,ignore:i}=this.watchPatterns(),o=n.flatMap(r=>Oi(r,{cwd:this.directory,absolute:!0,followSymbolicLinks:!1,ignore:i}));if(t.push(...o.flat()),!this.devSessionWatchConfig){let r=this.scanImports();t.push(...r)}return[...new Set(t.map(r=>Se(r)))]}async rescanImports(){let t=this.cachedImportPaths;return this.cachedImportPaths=void 0,yo(),this.scanImports(),t!==this.cachedImportPaths}scanImports(){if(this.cachedImportPaths!==void 0)return this.cachedImportPaths;if(Ke(process.env.SHOPIFY_CLI_DISABLE_IMPORT_SCANNING))return this.cachedImportPaths=[],this.cachedImportPaths;try{let t=performance.now(),n=this.devSessionDefaultWatchPaths(),i=n.flatMap(a=>ho(a).map(c=>Se(pe(c))));this.cachedImportPaths=Ii(i)??[];let o=Math.round(performance.now()-t),r=_o(),s=r?` (cache: ${r.directImports} parsed, ${r.fileExists} stats)`:"";return S(`Import scan for "${this.handle}": ${n.length} entries, ${this.cachedImportPaths.length} files, ${o}ms${s}`),this.cachedImportPaths}catch(t){return S(`Failed to scan imports for extension ${this.handle}: ${t}`),this.cachedImportPaths=[],this.cachedImportPaths}}buildHandle(){switch(this.specification.uidStrategy){case"single":return this.specification.identifier;case"uuid":return this.configuration.handle??j(this.name??"");case"dynamic":if("topic"in this.configuration&&"uri"in this.configuration){let t=this.configuration,n=`${t.topic}${t.uri}${t.filter}`;return Ye(n).substring(0,Ut)}else return At(JSON.stringify(this.configuration))}}buildUIDFromStrategy(){switch(this.specification.uidStrategy){case"single":return this.specification.identifier;case"uuid":return this.configuration.uid??At(this.handle);case"dynamic":if("topic"in this.configuration&&"uri"in this.configuration){let t=this.configuration;return`${t.topic}::${t.filter}::${t.uri}`.substring(0,So)}else return At(JSON.stringify(this.configuration))}}};u();async function Vr(e,t=""){let n=Rc(t),i=await et(n);for(;await w(y(e,Ht(i)))&&await $({message:`Configuration file ${Ht(i)} already exists. Do you want to choose a different configuration name?`,confirmationMessage:"Yes, I'll choose a different name",cancellationMessage:"No, overwrite my existing configuration file"});)i=await et(n);return Ht(i)}function Ht(e,t=!1){let n=j(e);return n===""?"shopify.app.toml":`shopify.app.${t?ne.cyan(n):n}.toml`}async function Nn(e){return D(y(e,"shopify.app*.toml"))}async function zr(e){let t=(await Nn(e)).map(i=>T(i));if(t.length===0)return ve("Could not find any shopify.app.toml file in the directory.");if(t.length===1)return le(t[0]);let n=await Xi({message:"Configuration file",choices:t.map(i=>({label:i,value:i}))});return le(n)}function Rc(e){return{message:"Configuration file name:",initialAnswer:e,validate:Oc,preview:t=>`${Ht(t,!0)} will be generated in your root directory`}}function Oc(e){if(j(e).length>238)return"The file name is too long."}u();u();function xe(e,t){return!t||!e.startsWith("/")?e:`${J(t)}${e}`}var Ne="webhook_subscription",Uc=p.object({topic:p.string(),actions:p.array(p.string({invalid_type_error:"Value must be a string"})).optional(),api_version:p.string(),uri:p.preprocess(J,To,{required_error:"Missing value at"}),include_fields:p.array(p.string({invalid_type_error:"Value must be a string"})).optional(),filter:p.string({invalid_type_error:"Value must be a string"}).optional(),payload_query:p.string({invalid_type_error:"Value must be a string"}).trim().min(1).optional(),name:p.string({invalid_type_error:"Value must be a string"}).trim().min(1).max(50).optional()});function Bc(e){let{api_version:t,topic:n,...i}=e;return{webhooks:{subscriptions:[{topics:[n],...i}]}}}var $c={forward:(e,t)=>{let n=e,i;return"application_url"in t&&(i=t?.application_url),{...n,uri:xe(n.uri,i)}},reverse:Bc},Lc=oe({identifier:Ne,schema:Uc,transformConfig:$c,uidStrategy:"dynamic"}),Jr=Lc;u();u();u();import{readdirSync as jc}from"fs";async function Gt(e){if(!e||!await de(e))return{};let t={},n=jc(e);return await Promise.all(n.map(async i=>{if(zt(i)){let o=y(e,i),s=(await U.read(o)).content;s.client_id&&(t[s.client_id]=i)}})),t}u();var qr;function Wn(){return qr??=new gn({projectName:"shopify-cli-app"}),qr}function Yt(e,t=Wn()){let n=Se(e);return S(A`Reading cached app information for directory ${v.path(n)}...`),t.get(n)}function We(e,t=Wn()){e.directory=Se(e.directory),S(A`Storing app information for directory ${v.path(e.directory)}:${v.json(e)}`);let n=t.get(e.directory);n?t.set(e.directory,{...n,...e}):t.set(e.directory,e)}function Hr(e,t=Wn()){let n=Se(e),i=t.get(n);i&&t.set(n,{...i,configFile:void 0})}var Kr;function Gr(){return Kr??=new gn({projectName:"shopify-cli-app-command"}),Kr}function Yr(e){let t=process.env.COMMAND_RUN_ID;if(!t)return;let n=Gr(),i=n.get(t);n.set(t,{...i,...e})}function Zt(){let e=process.env.COMMAND_RUN_ID;return e?Gr().get(e):void 0}function Zr(e){Yr({tomls:e})}function Qr(e){Yr({selectedToml:e})}async function Xr(e){if(e.length===1)return e[0];let n=new Set(e.map(r=>r.businessName)).size<e.length,i=e.map(r=>({label:n?`${r.businessName} (${r.id})`:r.businessName,value:r.id})),o=await De({message:"Which organization is this work for?",choices:i});return e.find(r=>r.id===o)}async function es(e,t,n,i){let o=await Gt(i?.directory);o&&Zr(o);let r=c=>o[c?.apiKey]?{label:`${c.title} (${o[c.apiKey]})`,value:c.apiKey}:{label:c.title,value:c.apiKey},s=t,a=await De({message:"Which existing app is this for?",choices:s.map(r),hasMorePages:n,search:async c=>{let d=await e(c);return s=d.apps,{data:s.map(r),meta:{hasNextPage:d.hasMorePages}}}});return s.find(c=>c.apiKey===a)}async function yh({stores:e,hasMorePages:t=!1,onSearchForStoresByName:n,showDomainOnPrompt:i=!0}){if(e.length===0)return;if(e.length===1)return Dt(`Using your default dev store, ${e[0].shopName}, to preview your project.`),e[0];let o=c=>{let d=c.shopName;return i&&c.shopDomain&&(d=`${c.shopName} (${c.shopDomain})`),{label:d,value:c.shopId}},r=e,s={};n&&(s.search=async c=>{let d=await n(c);return r=d.stores,{data:r.map(o),meta:{hasNextPage:d.hasMorePages}}});let a=await De({message:"Which store would you like to use to view your project?",choices:r.map(o),hasMorePages:t,...s});return r.find(c=>c.shopId===a)}async function hh(){return $({message:"Make this store transfer-disabled? For security, once you use a dev store to preview an app locally, the store can never be transferred to a merchant to use as a production store.",confirmationMessage:"Yes, make this store transfer-disabled permanently",cancellationMessage:"No, select another store",defaultValue:!1})}async function ts(e){return et({message:"App name",defaultValue:e,validate:t=>{if(t.length===0)return"App name can't be empty";if(t.length>wn)return`Enter a shorter name (${wn} character max.)`;if(t.includes("shopify"))return`Name can't contain "shopify." Enter another name.`}})}async function _h(e){return $({message:"Finished creating a dev store?",confirmationMessage:`Yes, ${e.businessName} has a new dev store`,cancellationMessage:"No, cancel dev"})}async function ns(){return $({message:"Create this project as a new app on Shopify?",confirmationMessage:"Yes, create it as a new app",cancellationMessage:"No, connect it to an existing app"})}function is(e,t,n,i){return e?Wc(t,i):Nc(t,n)}function Nc(e,t){return $({message:"Have Shopify automatically update your app's URL in order to create a preview experience?",confirmationMessage:"Yes, automatically update",cancellationMessage:"No, never",infoTable:{"Current app URL":[e],"Current redirect URLs":t}})}function Wc(e,t){let n=["application_url","redirect_urls"];t.appProxy?.proxyUrl&&n.push("app_proxy");let i={"Currently released app URL":[e],"=> Dev URL":[t.applicationUrl],"Affected configurations":n};return $({message:"Have Shopify override your app URLs when running `app dev` against your dev store? This won't affect your app on other stores",confirmationMessage:"Yes, automatically update",cancellationMessage:"No, never",infoTable:i})}function xh(){return $({message:"--use-localhost requires a certificate for `localhost`. Generate it now?",confirmationMessage:"Yes, use mkcert to generate it",cancellationMessage:"No, I'll run `app dev` again without `--use-localhost`"})}async function Fh(e){if(e.noTunnelUseLocalhost)return{frontendUrl:"https://localhost",frontendPort:e.port,usingLocalhost:!0};let t=4040,n="",i=e.noTunnelUseLocalhost;if(_n())return n=`https://${_n()}-${t}.${oo()}`,{frontendUrl:n,frontendPort:t,usingLocalhost:i};if(hn()){let o=hn()?.replace("https://","");return n=`https://${t}-${o}`,{frontendUrl:n,frontendPort:t,usingLocalhost:i}}if(e.tunnelUrl){let o=e.tunnelUrl.match(/(https:\/\/[^:]+):([0-9]+)/);if(!o)throw new b(`Invalid tunnel URL: ${e.tunnelUrl}`,'Valid format: "https://my-tunnel-url:port"');return t=Number(o[2]),n=o[1],{frontendUrl:n,frontendPort:t,usingLocalhost:i}}return e.tunnelClient&&(t=e.tunnelClient.port,n=await Vc(e.tunnelClient)),{frontendUrl:n,frontendPort:t,usingLocalhost:i}}async function Vc(e){return new Promise((t,n)=>{let i=0,o=async()=>{let s=e.getTunnelStatus();if(S(`Polling tunnel status for ${e.provider} (attempt ${i}): ${s.status}`),s.status==="error")return n(new b(s.message,s.tryMessage));s.status==="connected"?t(s.url):(i+=1,r())},r=()=>{setTimeout(o,500)};o()})}function os(e,t,n){let i;t&&t.length>0?i=(Array.isArray(t)?t:[t]).reduce((s,a)=>(a&&a.length>0&&s.push(`${e}${a}`),s),[]):i=[`${e}/auth/callback`,`${e}/auth/shopify/callback`,`${e}/api/auth/callback`];let o=n?{appProxy:{proxyUrl:zc(xe(n.url,e),e),proxySubPath:n.subpath,proxySubPathPrefix:n.prefix}}:{};return{applicationUrl:e,redirectUrlWhitelist:i,...o}}function zc(e,t){let n=new URL(e),i=new URL(t);return n.host=i.host,n.toString().replace(/\/$/,"")}async function Mh(e,t,n,i){let o={apiKey:t,...e},r=await n.updateURLs(o);if(r.appUpdate.userErrors.length>0){let s=r.appUpdate.userErrors.map(a=>a.message).join(", ");throw new b(s)}if(i&&i.configuration.client_id===t){let s=await U.read(i.configPath),a={application_url:e.applicationUrl,auth:{redirect_urls:e.redirectUrlWhitelist}};e.appProxy&&(a.app_proxy={url:e.appProxy.proxyUrl,subpath:e.appProxy.proxySubPath,prefix:e.appProxy.proxySubPathPrefix}),await s.patch(a)}}async function Dh(e){let t={applicationUrl:e?.application_url??"",redirectUrlWhitelist:e?.auth?.redirect_urls??[]};return e?.app_proxy&&(t.appProxy={proxyUrl:e?.app_proxy.url,proxySubPath:e?.app_proxy.subpath,proxySubPathPrefix:e?.app_proxy.prefix}),t}async function Rh(e){if(e.localApp&&e.localApp.configuration.client_id!==e.apiKey||(e.newApp??!io()))return!0;let t=e.cachedUpdateURLs===!0;if(e.cachedUpdateURLs===void 0)if(t=await is(e.developerPlatformClient.supportsDevSessions,e.currentURLs.applicationUrl,e.currentURLs.redirectUrlWhitelist,e.newURLs),e.localApp){let n=e.localApp.configuration;n.build={...n.build,automatically_update_urls_on_dev:t},await(await U.read(e.localApp.configPath)).patch({build:{automatically_update_urls_on_dev:t}})}else We({directory:e.appDirectory,updateURLs:t});return t}async function Oh(e,t,n){let i=await Li(e,"tunnel_start",{port:t,provider:n}),o=Object.values(i).filter(s=>!s?.isErr()||s.error.type!=="invalid-provider");if(o.length>1)throw new Q(`Multiple tunnel plugins for ${n} found`);let r=o[0];if(!r)throw new Q(`We couldn't find the ${n} tunnel plugin`);if(r.isErr())throw new b(`${n} failed to start the tunnel.
68
+ ${r.error.message}`,["What to try:",{list:{items:[["Try to run the command again"],["Add the flag",{command:"--tunnel-url {URL}"},"to use a custom tunnel URL"]]}}]);return r.value}u();u();async function Vn({directory:e,configName:t,warningContent:n,shouldRenderSuccess:i=!0,reset:o=!1}){if(o){Hr(e);let a=await Tt(e);Xe({headline:"Cleared current configuration.",body:["In order to set a new current configuration, please run",{command:Mt(a,"shopify app config use CONFIG_NAME")},{char:"."}]});return}n&&Ft(n);let r=(await Jc(e,t)).valueOrAbort(),{activeConfig:s}=await ee(e,r);return zn(s.file.content,{configFileName:r,directory:e}),i&&Xe({headline:`Using configuration file ${r}`}),r}function zn(e,t){let{configFileName:n,directory:i}=t;if(e.client_id)We({directory:i,configFile:n});else throw new b(`Configuration file ${n} needs a client_id.`)}async function Jc(e,t){if(t){let n=X(t);return await w(y(e,n))?le(n):ve(`Could not find configuration file ${n}`)}return zr(e)}async function rs(e,t,n){let i=t,o=Yt(e.directory)?.configFile,r=o?y(e.directory,o):null,s=!!(!i&&r&&!H(r));if(s&&!n?.skipPrompts){let l={headline:`Couldn't find ${o}`,body:["If you have multiple config files, select a new one. If you only have one config file, it's been selected as your default."]};i=await Vn({directory:e.directory,warningContent:l,shouldRenderSuccess:!1})}i=i??(s?void 0:o);let a;t?a="flag":i?a="cached":a="default";let c=X(i),d=e.appConfigByName(c);if(!d)throw new b(A`Couldn't find ${c} in ${v.path(e.directory)}.`);return qc(e,d,a)}async function qc(e,t,n){let i=typeof t.content.client_id=="string"?t.content.client_id:void 0,o=!!i&&i!=="",r=Qt(e,t.path),s=await Xt(e,i);return{file:t,source:n,isLinked:o,dotenv:r,hiddenConfig:s}}var ps=qe(Ep(),1);function dt(e){return e.path?.length?`[${e.path.join(".")}]: ${e.message}`:e.message}async function Kn(e,t,n){let i=n;if(!i)try{i=(await U.read(t)).content}catch(o){if(o instanceof tt)return{errors:[{file:t,message:o.message}]};throw o}return cs(e,t,i)}function cs(e,t,n){let i=e.safeParse(n);return i.success?{data:i.data}:{errors:Ar(i.error.issues).map(o=>({file:t,message:o.message,path:o.path,code:o.code}))}}function ss(e,t,n){let i=e.parseConfigurationObject(n);switch(i.state){case"ok":return{data:i.data};case"error":return{errors:i.errors.map(o=>({file:t,message:o.message??"Unknown error",path:o.path}))}}}var lt=class{constructor(){this.errors=[]}addError(t){this.errors.push(t)}addErrors(t){this.errors.push(...t)}getErrors(t){return t?this.errors.filter(n=>n.file===t):[...this.errors]}isEmpty(){return this.errors.length===0}};async function V_(e){if(!((await Nn(e)).length>0))throw new b(A`Couldn't find an app toml file at ${v.path(e)}, is this an app directory?`)}async function z_(e,t){let{project:n,activeConfig:i}=await ee(e),o=i.file.content,r=qn(n,i.file),s=await Promise.all(r.map(f=>ls(f.path,f.content))),a=s.flatMap(f=>f.errors??[]);if(a.length>0)throw new b(a.map(dt).join(`
69
+ `));let d=s.filter(f=>"web"in f).map(f=>f.web).some(f=>re(f,"frontend")||re(f,"backend")),l=Vt(o);return{isLaunchable:d,scopesArray:l,name:t,directory:n.directory,isEmbedded:d}}async function ls(e,t){let n=await Kn(Pr,e,t);if(n.errors)return{errors:n.errors};let i=n.data,o=new Set("roles"in i?i.roles:[]);"type"in i&&o.add(i.type);let{type:r,...s}={...i,roles:Array.from(o),type:void 0};return{web:{directory:P(e),configuration:s,framework:await bo(P(e))}}}async function us(e){let{project:t,activeConfig:n}=await ee(e.directory,e.userProvidedConfigName,e.skipPrompts?{skipPrompts:!0}:void 0);return Ve({project:t,activeConfig:n,specifications:e.specifications,remoteFlags:e.remoteFlags,ignoreUnknownExtensions:e.ignoreUnknownExtensions})}async function Ve(e){let{project:t,activeConfig:n,specifications:i,remoteFlags:o=[],ignoreUnknownExtensions:r,reloadState:s,clientIdOverride:a}=e,c={...n.file.content};a&&(c.client_id=a);let l=Sr(i),f=n.file.path,_=T(f),g=await Kn(l,f,c);if(g.errors){let Y=g.errors.map(dt).join(`
70
+ `);throw new b(`Validation errors in ${f}:
71
+
72
+ ${Y}`)}let m=g.data,h=Yc(t.appConfigFiles,{[_]:m.client_id}),x=!1;try{x=await Hc(t.directory,f)}catch{}let C={allClientIdsByConfigName:h,usesLinkedConfig:!0,name:_,gitTracked:x,source:n.source,usesCliManagedUrls:m.build?.automatically_update_urls_on_dev},E={directory:t.directory,configPath:f,configuration:m,configurationLoadResultMetadata:C,configSchema:l,specifications:i,remoteFlags:o};return new Jn({ignoreUnknownExtensions:r,loadedConfiguration:E,project:t,reloadState:s}).loaded()}function Kc(e){return e.access_scopes?.scopes??""}async function ds(e){try{let{project:t,activeConfig:n}=await ee(e.directory,e.configName,e.skipPrompts?{skipPrompts:!0}:void 0),i=await Ve({project:t,activeConfig:n,specifications:e.specifications,remoteFlags:e.remoteFlags});return{state:"loaded-app",app:i,configuration:i.configuration,packageManager:t.packageManager}}catch{try{let t=await at.load(e.directory),{configurationPath:n}=await Gc(t.directory,e.configName),o=(await U.read(n)).content;return{state:"loaded-template",rawConfig:o,scopes:Kc(o),appDirectory:t.directory,packageManager:t.packageManager}}catch{return{state:"error"}}}}async function J_(e){let{project:t,activeConfig:n}=await ee(e.directory,T(e.configPath)),i={extensionDevUUIDs:new Map(e.allExtensions.map(r=>[r.handle,r.devUUID])),previousDevURLs:e.devApplicationURLs},o=await Ve({project:t,activeConfig:n,specifications:e.specifications,remoteFlags:e.remoteFlags??[],reloadState:i});if(!o.errors.isEmpty()){let r=o.errors.getErrors();throw new b(A`${v.errorText("Validation errors")}:\n\n${r.map(dt).join(`
73
+ `)}`)}return o}function fs(e){let t=ut(e);return t?`${Oe.production}.${t}`:Oe.production}var Jn=class{constructor({ignoreUnknownExtensions:t,loadedConfiguration:n,reloadState:i,project:o}){this.errors=new lt;this.ignoreUnknownExtensions=t??!1,this.specifications=n.specifications,this.remoteFlags=n.remoteFlags,this.loadedConfiguration=n,this.reloadState=i,this.project=o}get activeConfigFile(){let t=this.loadedConfiguration.configPath;return this.project.appConfigFiles.find(n=>n.path===t)}async loaded(){let{configuration:t,directory:n,configPath:i,configurationLoadResultMetadata:o,configSchema:r}=this.loadedConfiguration;await el(o);let s=Qt(this.project,i),a=await this.loadExtensions(n,t),c=t.name,l=t.handle??c??"",f=await Xt(this.project,t.client_id);this.reloadState||await xo(n,this.project.nodeDependencies);let{webs:_,usedCustomLayout:g}=await this.loadWebs(n,t.web_directories),m=new Wt({name:l,directory:n,configPath:i,configuration:t,webs:_,modules:a,dotenv:s,errors:this.errors,specifications:this.specifications,configSchema:r,remoteFlags:this.remoteFlags,hiddenConfig:f,devApplicationURLs:this.getDevApplicationURLs(t,_)}),h=m.realExtensions.map(x=>x.type);return await ao(h),await Qc(m,this.project.usesWorkspaces,{usedCustomLayoutForWeb:g,usedCustomLayoutForExtensions:t.extension_directories!==void 0}),await m.generateExtensionTypes(),m}async loadWebs(t,n){let i=this.activeConfigFile,o=i?qn(this.project,i):this.project.webConfigFiles,r=o.map(l=>l.path),s=await Promise.all(o.map(l=>ls(l.path,l.content))),a=[];for(let l of s)l.errors?this.errors.addErrors(l.errors):a.push(l.web);this.validateWebs(a);let c=r.every(l=>I(t,l).startsWith("web/"));return{webs:a,usedCustomLayout:n!==void 0||!c}}findSpecificationForType(t){return this.specifications.find(n=>n.identifier===t||n.externalIdentifier===t||n.additionalIdentifiers?.includes(t))}validateWebs(t){["backend","frontend"].forEach(n=>{let i=t.filter(o=>o.configuration.roles.includes(n));if(i.length>1){let o=i.map(a=>y(a.directory,z.web)),r=o.map(a=>` ${a}`).join(`
74
+ `),s=o[o.length-1];this.errors.addError({file:s,message:`You can only have one "web" configuration file with the ${n} role in your app.
75
+
76
+ Conflicting configurations found at:
77
+ ${r}`})}})}async createExtensionInstance(t,n,i,o){let r=this.findSpecificationForType(t),s,a=!1;if(r)a=!0;else{if(this.ignoreUnknownExtensions)return;this.errors.addError({file:i,message:`Invalid extension type "${t}" in "${xt(i)}"`});return}let c=ss(r,i,n);if(c.errors){this.errors.addErrors(c.errors);return}let d=c.data;a&&(s=await this.findEntryPath(o,r));let l=new Kt({configuration:d,configurationPath:i,entryPath:s,directory:o,specification:r});if(this.reloadState&&d.handle){let f=this.reloadState.extensionDevUUIDs.get(d.handle);f&&(l.devUUID=f)}if(a){let f=await l.validate();f.isErr()&&this.errors.addError({file:i,message:ro(f.error).trim()})}return l}async loadExtensions(t,n){if(this.specifications.length===0)return[];let i=await this.createExtensionInstances(t),o=await this.createConfigExtensionInstances(t,n),r=this.createWebhookSubscriptionInstances(t,n),s=await Promise.all([...i,...o,...r]),a=Pe(s.flat()),c=new Set;return a.forEach(d=>{if(d.handle&&c.has(d.handle)){let l=a.filter(_=>_.handle===d.handle),f=Ti(l.map(_=>_.name));this.errors.addError({file:d.configurationPath,message:`Duplicated handle "${d.handle}" in extensions ${f}. Handle needs to be unique per extension.`})}else d.handle&&c.add(d.handle)}),a}async createExtensionInstances(t){let n=this.activeConfigFile;return(n?as(this.project,n):this.project.extensionConfigFiles).map(async o=>{let r=o.path,s=P(r),a=o.content,c=Po.safeParse(a);if(!c.success)return this.errors.addError({file:r,message:`Invalid extension configuration at ${I(t,r)}`}),[];let{extensions:d,type:l}=c.data;if(d){let f=await Kn(Ao,r,o.content);if(f.errors)return this.errors.addErrors(f.errors),[];let _=f.data,g=_.extensions.map(async m=>{let h={..._,...m};return h.handle||(this.errors.addError({file:r,message:`Missing handle for extension "${h.name}" at ${I(t,r)}`}),h.handle="unknown-handle"),this.createExtensionInstance(h.type,h,r,s)});return Promise.all(g)}else{if(l)return this.createExtensionInstance(l,a,r,s);this.errors.addError({file:r,message:`Invalid extension type at "${I(t,r)}". Please specify a type.`});return}})}createWebhookSubscriptionInstances(t,n){let i=this.loadedConfiguration.configPath,o=this.findSpecificationForType(Ne);if(!o)return[];let r=cs($t,i,n);if(r.errors)return this.errors.addErrors(r.errors),[];let{api_version:s,subscriptions:a=[]}=r.data.webhooks;return Pe(a.flatMap(l=>{let{uri:f,topics:_,compliance_topics:g,...m}=l;return _?.map(h=>({api_version:s,uri:f,topic:h,...m}))})).map(async l=>this.createExtensionInstance(o.identifier,l,i,t))}async createConfigExtensionInstances(t,n){let i=this.loadedConfiguration.configPath,o=await Promise.all(this.specifications.filter(s=>$e(s)).filter(s=>s.identifier!==Ne).map(async s=>{let a=ss(s,i,n);if(a.errors)return this.errors.addErrors(a.errors),[null,[]];let c=a.data;return Object.keys(c).length===0?[null,Object.keys(c)]:[await this.createExtensionInstance(s.identifier,c,i,t).then(l=>this.validateConfigurationExtensionInstance(n.client_id,n,l)),Object.keys(c)]})),r=Object.keys(n).filter(s=>!o.some(([a,c])=>c.includes(s))).filter(s=>![...Object.keys(pt.shape),"organization_id"].includes(s));return r.length>0&&!this.ignoreUnknownExtensions&&this.errors.addError({file:i,message:`Unsupported section(s) in app configuration: ${r.sort().join(", ")}`}),o.filter(([s])=>s).map(([s])=>s)}async validateConfigurationExtensionInstance(t,n,i){return i&&await i.deployConfig({apiKey:t,appConfiguration:n})?i:void 0}async findEntryPath(t,n){let i;return n.appModuleFeatures().includes("single_js_entry_path")?(i=(await Promise.all(["index"].flatMap(o=>[`${o}.js`,`${o}.jsx`,`${o}.ts`,`${o}.tsx`]).flatMap(o=>[`src/${o}`,o]).map(o=>y(t,o)).map(async o=>await w(o)?o:void 0))).find(o=>o!==void 0),i||this.errors.addError({file:t,message:`Couldn't find an index.{js,jsx,ts,tsx} file in the directories ${t} or ${y(t,"src")}`})):n.identifier==="function"&&(i=(await Promise.all(["src/index.js","src/index.ts","src/main.rs"].map(o=>y(t,o)).map(async o=>await w(o)?o:void 0))).find(o=>o!==void 0)),i}getDevApplicationURLs(t,n){let i=this.reloadState?.previousDevURLs;return i&&os(i.applicationUrl,n.map(({configuration:o})=>o.auth_callback_path).find(o=>o),t.app_proxy)}};async function ee(e,t,n){let i=await at.load(e),o=await rs(i,t,n);return{project:i,activeConfig:o}}async function Hc(e,t){let n=y(e,".gitignore");if(!H(n))return!0;let i=await F(n),o=ps.default.default().add(i),r=I(e,t);return!o.ignores(r)}async function Gc(e,t){let n=X(t),i=y(e,n);if(await w(i))return{configurationPath:i,configurationFileName:n};throw new b(A`Couldn't find ${n} in ${v.path(e)}.`)}function Yc(e,t){let n=e.map(i=>{let o=T(i.path);if(t[o]!==void 0&&typeof t[o]=="string")return[o,t[o]];let r=i.content.client_id;if(typeof r=="string"&&r!=="")return[o,r]}).filter(i=>i!==void 0);return Object.fromEntries(n)}async function Zc(e){let t=e.filter(a=>re(a,"backend")),n=e.filter(a=>re(a,"frontend"));if(t.length>1){S("Unable to decide project type as multiple web backends");return}else{if(t.length===0&&n.length>0)return"frontend";if(!t[0]){S("Unable to decide project type as no web backend");return}}let{directory:i}=t[0],o=y(i,"package.json"),r=y(i,"Gemfile"),s=y(i,"composer.json");if(await w(o))return"node";if(await w(r))return"ruby";if(await w(s))return"php"}function re(e,t){return e.configuration.roles.includes(t)}async function Qc(e,t,n){let i=e.webs,o=e.allExtensions.filter(c=>c.isSentToMetrics()),r=e.name,s=e.directory,a=Vt(e.configuration).sort();await Xc(i,o,n,r,s,a,t)}async function Xc(e,t,n,i,o,r,s){await q.addPublicMetadata(async()=>{let a=await Zc(e),c=t.filter(x=>x.isFunctionExtension).length,d=t.filter(x=>x.isESBuildExtension).length,l=t.filter(x=>x.isThemeExtension).length,f=t.length,_=e.filter(x=>re(x,"backend")).length,g=_===1?e.filter(x=>re(x,"backend"))[0]?.framework:void 0,m=e.filter(x=>re(x,"frontend")).length,h={};for(let x of t)h[x.type]===void 0?h[x.type]=1:h[x.type]++;return{project_type:a,app_extensions_any:f>0,app_extensions_breakdown:JSON.stringify(h),app_extensions_count:f,app_extensions_custom_layout:n.usedCustomLayoutForExtensions,app_extensions_function_any:c>0,app_extensions_function_count:c,app_extensions_theme_any:l>0,app_extensions_theme_count:l,app_extensions_ui_any:d>0,app_extensions_ui_count:d,app_name_hash:Ye(i),app_path_hash:Ye(o),app_scopes:JSON.stringify(r),app_web_backend_any:_>0,app_web_backend_count:_,app_web_custom_layout:n.usedCustomLayoutForWeb,app_web_framework:g,app_web_frontend_any:m>0,app_web_frontend_count:m,env_package_manager_workspaces:s}}),await q.addSensitiveMetadata(async()=>({app_name:i}))}async function el(e){await q.addPublicMetadata(async()=>({cmd_app_all_configs_any:Object.keys(e.allClientIdsByConfigName).length>0,cmd_app_all_configs_clients:JSON.stringify(e.allClientIdsByConfigName),cmd_app_linked_config_used:e.usesLinkedConfig,...e.usesLinkedConfig?{cmd_app_linked_config_name:e.name,cmd_app_linked_config_git_tracked:e.gitTracked,cmd_app_linked_config_source:e.source,cmd_app_linked_config_uses_cli_managed_urls:e.usesCliManagedUrls}:{}}))}u();var tl="project.json";async function Hn(e){let t=await lo(e),n=y(t,tl);return await w(n)||await B(n,JSON.stringify({})),n}function Qt(e,t){let n=ut(t);if(n){let i=`${Oe.production}.${n}`;return e.dotenvFiles.get(i)}return e.dotenvFiles.get(Oe.production)}async function Xt(e,t){if(!t||typeof t!="string")return{};await Hn(e.directory);let n=e.hiddenConfigRaw,i=n[t];if(i&&typeof i=="object")return i;if(typeof n.dev_store_url=="string"){try{let o=await Hn(e.directory);await Nt(o,t,{dev_store_url:n.dev_store_url})}catch{}return{dev_store_url:n.dev_store_url}}return{}}function as(e,t){let n=t.content.extension_directories,o=(Array.isArray(n)&&n.length>0?n:["extensions/*"]).map(r=>`${r}/*.extension.toml`);return e.extensionConfigFiles.filter(r=>{let s=I(e.directory,r.path).replace(/\\/g,"/");return o.some(a=>Pt(s,a))})}function qn(e,t){let n=t.content.web_directories;if(!Array.isArray(n)||n.length===0)return e.webConfigFiles;let i=n.map(o=>`${o}/shopify.web.toml`);return e.webConfigFiles.filter(o=>{let r=I(e.directory,o.path).replace(/\\/g,"/");return i.some(s=>Pt(r,s))})}function sx(e,t){let n=t.content.extension_directories,i=(Array.isArray(n)&&n.length>0?n:["extensions/*"]).map(a=>`${a}/*.extension.toml`),o=t.content.web_directories,r=Array.isArray(o)&&o.length>0?o.map(a=>`${a}/shopify.web.toml`):["**/shopify.web.toml"],s=[...i,...r];return e.errors.filter(a=>{if(a.path===t.path)return!0;let c=I(e.directory,a.path).replace(/\\/g,"/");return s.some(d=>Pt(c,d))})}u();u();var ms=2,nl=["This may happen if:"," \u2022 Running in an unstable environment (container restart, resource limits)"," \u2022 Network interruption during app fetching","","Try running the command again. If the issue persists:"," \u2022 Check system resources and stability"," \u2022 Try running outside of containers/WSL if applicable"," \u2022 Report this issue with the error details and a verbose log"].filter(Boolean).join(`
78
+ `);async function gs(e,t,n,i,o){let r=e.length===0;if(r||(r=await ns()),r){let s=await ts(o.name);return i.createApp(n,{...o,name:s})}else{let a=Zt()?.tomls??{};for(let d=0;d<ms;d++){let l=await es(ar(i,n.id),e,t,{directory:o.directory});if(l){let f=a[l.apiKey];f&&Qr(f);let _=await i.appFromIdentifiers(l.apiKey);if(_)return _}else{d<ms-1&&Re("App selection failed. Retrying...");continue}}let c=["Unable to select an app: the selection prompt failed multiple times.","",`Available apps: ${e.length}`].join(`
79
+ `);throw new Q(c,nl)}}u();u();u();u();async function ys(e,t,n="extension"){return $({message:`Match ${e.handle} (local name) with ${t.title} (name on Shopify Partners, ID: ${t.id})?`,confirmationMessage:`Yes, match to existing ${n}`,cancellationMessage:`No, create as a new ${n}`})}async function hs(e,t){let n=t.map(o=>({label:`Match it to ${o.title} (ID: ${o.id} on Shopify Partners)`,value:o.uuid}));n.push({label:"Create new extension",value:"create"});let i=await De({message:`How would you like to deploy your "${e.handle}"?`,choices:n});return t.find(o=>o.uuid===i)}async function Ie(e,t=!0){let n=e.map(({local:a})=>`"${a.handle}"`).join(", "),i=e.map(({remote:a})=>a.type.toLocaleLowerCase()),o=i.filter((a,c)=>i.indexOf(a)===c).map(a=>`"${a}"`).join(", "),r=e.map(({local:a})=>`"${a.type}"`).join(", ");Qe({headline:"Extension migrations can't be undone.",body:`Your ${n} configuration has been updated. Migrating gives you access to new features and won't impact the end user experience. All previous extension versions will reflect this change.`});let s=t?`Yes, confirm migration from ${o} to ${r}`:"Yes, confirm migration";return $({message:`Migrate ${n}?`,confirmationMessage:s,cancellationMessage:"No, cancel"})}async function _s(e){let t={},n=e.remote,i=e.local;for(let o of e.local){let r=n.filter(a=>a.type===o.graphQLType);if(r.length===0)continue;let s=await hs(o,r);s&&(t[o.localIdentifier]=s.uuid,n=n.filter(a=>a.uuid!==s.uuid),i=i.filter(a=>a.localIdentifier!==o.localIdentifier))}return{identifiers:t,toCreate:i,onlyRemote:n}}u();var il=(e,t)=>(t.type.toLowerCase()===e.graphQLType.toLowerCase()||t.type.toLowerCase()===e.externalType.toLowerCase()||t.type.toLowerCase()===e.type.toLowerCase())&&j(t.title)===j(e.handle);function xs(e,t){let n=un(e,l=>[l.graphQLType,l.handle]),i=un(t,l=>[l.type,l.title]),o={};n.forEach(l=>{let f=i.find(_=>il(l,_));f&&(o[l.localIdentifier]=f.uuid)});let r=e.filter(l=>!o[l.localIdentifier]),s=t.filter(l=>!Object.values(o).includes(l.uuid)),{toConfirm:a,toCreate:c,toManualMatch:d}=sl(r,s);return{matched:o,toCreate:c,toConfirm:a,toManualMatch:d}}function ol(e,t,n){let i={},o=[],r={};e.forEach(g=>{let m=t.find(x=>x.id===g.uid),h=t.find(x=>x.uuid===n[g.localIdentifier]);m?i[g.localIdentifier]=m.id:h&&h.id.length===0?r[g.localIdentifier]=h.uuid:o.push(g)});let s=t.filter(g=>!Object.values(r).includes(g.uuid)&&!Object.values(i).includes(g.id)&&g.id.length===0),{matched:a,toCreate:c,toConfirm:d,toManualMatch:l}=xs(o,s),f={...r,...a},_=e.filter(g=>f[g.localIdentifier]);return rl(_),{matched:{...i,...f},toCreate:c,toConfirm:d,toManualMatch:l}}function rl(e){if(e.length===0)return;let t=[ne.cyan,ne.magenta,ne.blue,ne.green,ne.yellow,ne.red],n=e.reduce((i,o)=>Math.max(i,o.handle.length),0);Re(`Generating extension IDs
80
+ `),e.forEach((i,o)=>{let r=t[o%t.length]??ne.white;Re(`${r(i.handle.padStart(n))} | Added ID: ${i.uid}`)}),Re(`
81
+ `)}function sl(e,t){let n=nt(e,"graphQLType"),i=Object.values(me(n,(g,m)=>g.length===1)).flat(),o=t.map(g=>({...g,type:g.type.toLowerCase()})),r=nt(o,"type"),s=me(r,(g,m)=>g.length===1),a=[],c=[];for(let g of i){let m=s[g.graphQLType.toLowerCase()];m&&m[0]?a.push({local:g,remote:m[0]}):c.push(g)}let d=dn(e,i),l=dn(o,a.map(g=>g.remote)),[f,_]=Co(d,g=>l.map(m=>m.type.toLowerCase()).includes(g.graphQLType.toLowerCase()));return c.push(..._),{toCreate:c,toConfirm:a,toManualMatch:{local:f,remote:l}}}async function bs(e,t,n,i){let o=i.supportsAtomicDeployments,r=Gn(e,n),s=Object.values(r),a=m=>t.some(h=>h.type!==i.toExtensionGraphQLType(m.graphQLType)?!1:r[m.localIdentifier]===h.uuid),c=e.filter(m=>!a(m)),d=t.filter(m=>!s.includes(m.uuid)),{matched:l,toCreate:f,toConfirm:_,toManualMatch:g}=o?ol(e,t,r):xs(c,d);return{identifiers:{...r,...l},toConfirm:_,toCreate:f,toManualMatch:g}}function Gn(e,t){let n=e.map(i=>i.localIdentifier);return me(t,(i,o)=>n.includes(o))}u();async function Yn(e,t,n,i,o){let r={apiKey:e,type:t,title:n,config:JSON.stringify({}),context:o??null,handle:n},s=await i.createExtension(r);if(s.extensionCreate.userErrors?.length>0){let a=s.extensionCreate.userErrors.map(c=>c.message).join(", ");throw new b(a)}return s.extensionCreate.extensionRegistration}u();async function Cs(e){let{extensionsToMigrate:t,appId:n,remoteExtensions:i,migrationClient:o}=e;return await Promise.all(t.map(({remote:r})=>al({apiKey:n,registrationId:void 0,registrationUuid:r.uuid,migrationClient:o}))),i.map(r=>t.some(({remote:s})=>s.uuid===r.uuid)?{...r,type:"UI_EXTENSION"}:r)}async function al(e){let{apiKey:t,registrationId:n,registrationUuid:i,migrationClient:o}=e,r={apiKey:t,registrationId:n,registrationUuid:i},s=await o.migrateToUiExtension(r);if(s?.migrateToUiExtension?.userErrors?.length>0){let a=s.migrateToUiExtension.userErrors.map(c=>c.message).join(", ");throw new b(a)}if(!s?.migrateToUiExtension?.migratedToUiExtension)throw new b("Couldn't migrate to UI extension")}u();async function ws(e){let{extensionsToMigrate:t,appId:n,remoteExtensions:i,migrationClient:o}=e;await Promise.all(t.map(({remote:a})=>pl({apiKey:n,registrationId:void 0,registrationUuid:a.uuid,migrationClient:o})));let r=new Map([["flow_action_definition","FLOW_ACTION"],["flow_trigger_definition","FLOW_TRIGGER"]]),s=t.map(({remote:a})=>a.uuid);return i.filter(a=>s.includes(a.uuid)).map(a=>({...a,type:r.get(a.type)??a.type}))}async function pl(e){let{apiKey:t,registrationId:n,registrationUuid:i,migrationClient:o}=e,r={apiKey:t,registrationId:n,registrationUuid:i},s=await o.migrateFlowExtension(r);if(s?.migrateFlowExtension?.userErrors?.length>0){let a=s.migrateFlowExtension.userErrors.map(c=>c.message).join(", ");throw new b(a)}if(!s?.migrateFlowExtension?.migratedFlowExtension)throw new b("Couldn't migrate to Flow extension");return n}u();var Es={payments_extension:["payments_app","payments_app_credit_card","payments_app_custom_credit_card","payments_app_custom_onsite","payments_app_redeemable"]},Ss={marketing_activity:["marketing_activity_extension"]},Ps={flow_action:["flow_action_definition"],flow_trigger:["flow_trigger_definition"],flow_trigger_lifecycle_callback:["flow_trigger_discovery_webhook"]},vs={ui_extension:["CHECKOUT_UI_EXTENSION","POS_UI_EXTENSION"]},As={subscription_link_extension:["subscription_link"]},Is={admin_link:["app_link","bulk_action"]};function Te(e,t,n,i){let o=Gn(e,n),r=Object.keys(i),s=Object.values(i).flat(),a=e.filter(l=>r.includes(l.type)),c=t.filter(l=>s.includes(l.type)),d=new Map;return c.forEach(l=>{d.set(l.uuid,l),d.set(j(l.title.substring(0,Ut)),l)}),a.reduce((l,f)=>{let _=o[f.localIdentifier]??"unknown",g=d.get(_)??d.get(f.localIdentifier.toLowerCase()),m=i[f.type]?.includes(g?.type??"undefined");return g&&m&&l.push({local:f,remote:g}),l},[])}async function ft(e){let{extensionsToMigrate:t,appId:n,type:i,remoteExtensions:o,migrationClient:r}=e;await Promise.all(t.map(({remote:a})=>cl({apiKey:n,registrationId:void 0,registrationUuid:a.uuid,type:i,migrationClient:r})));let s=t.map(({remote:a})=>a.uuid);return o.filter(a=>s.includes(a.uuid)).map(a=>({...a,type:i.toUpperCase()}))}async function cl(e){let{apiKey:t,registrationId:n,registrationUuid:i,type:o,migrationClient:r}=e,s={apiKey:t,registrationId:n,registrationUuid:i,type:o},a=await r.migrateAppModule(s);if(a?.migrateAppModule?.userErrors?.length>0){let c=a.migrateAppModule.userErrors.map(d=>d.message).join(", ");throw new b(c)}if(!a?.migrateAppModule?.migratedAppModule)throw new b(`Couldn't migrate to app module ${o}`);return n}async function Ts(e,{extensionRegistrations:t,dashboardManagedExtensionRegistrations:n}){let i=t,o=e.envIdentifiers.extensions??{},r=e.app.allExtensions.filter(E=>!E.isAppConfigExtension),s=Te(r,i,o,vs),a=Te(r,n,o,Ps),c=Te(r,n,o,Es),d=Te(r,n,o,Ss),l=Te(r,n,o,As),f=Te(r,n,o,Is),g=e.developerPlatformClient.clientName==="partners"?e.developerPlatformClient:Mo.getInstance(),m=!1;if(s.length>0){if(!await Ie(s))throw new V;i=await Cs({extensionsToMigrate:s,appId:e.appId,remoteExtensions:i,migrationClient:g}),m=!0}if(a.length>0){if(!await Ie(a,!1))throw new V;let M=await ws({extensionsToMigrate:a,appId:e.appId,remoteExtensions:n,migrationClient:g});i=i.concat(M),m=!0}if(d.length>0){if(!await Ie(d,!1))throw new V;let M=await ft({extensionsToMigrate:d,appId:e.appId,type:"marketing_activity",remoteExtensions:n,migrationClient:g});i=i.concat(M),m=!0}if(c.length>0){if(!await Ie(c,!1))throw new V;let M=await ft({extensionsToMigrate:c,appId:e.appId,type:"payments_extension",remoteExtensions:n,migrationClient:g});i=i.concat(M),m=!0}if(l.length>0){if(!await Ie(l,!1))throw new V;let M=await ft({extensionsToMigrate:l,appId:e.appId,type:"subscription_link_extension",remoteExtensions:n,migrationClient:g});i=i.concat(M),m=!0}if(f.length>0){if(!await Ie(f,!1))throw new V;let M=await ft({extensionsToMigrate:f,appId:e.appId,type:"admin_link",remoteExtensions:n,migrationClient:g});i=i.concat(M),m=!0}let h=await bs(r,i,o,e.developerPlatformClient),x=h.identifiers,C=h.toCreate??[];for(let E of h.toConfirm)await ys(E.local,E.remote)?x[E.local.localIdentifier]=E.remote.uuid:C.push(E.local);if(h.toManualMatch.local.length>0){let E=await _s(h.toManualMatch);x={...x,...E.identifiers},C.push(...E.toCreate)}return{validMatches:x,extensionsToCreate:C,dashboardOnlyExtensions:n,didMigrateDashboardExtensions:m}}async function ks(e,t,n,{validMatches:i,extensionsToCreate:o}){let{uuidUidStrategyExtensions:r,singleAndDynamicStrategyExtensions:s}=fl(t,n,e.app.specifications||[]),{extensionsNonUuidManaged:a,extensionsIdsNonUuidManaged:c}=await dl(s,e.app,e.appId,e.includeDraftExtensions,e.developerPlatformClient),d={};if(o.length>0){let l=await Fs(o,e.appId,e.developerPlatformClient);for(let[f,_]of Object.entries(l))i[f]=_.uuid,d[f]=_.id}for(let[l,f]of Object.entries(i)){let _=r.find(g=>g.uuid===f);_&&(d[l]=_.id)}return{extensions:i,extensionIds:{...d,...c},extensionsNonUuidManaged:a}}function ll(e,t){let n=e.activeVersion?.config,i=n?JSON.parse(n):{},o=t.configuration,r=i.uri??"";return i.topic===o.topic&&r.endsWith(o.uri)&&i.filter===o.filter}function ul(e,t,n,i,o,r){n.forEach(s=>{let a=e.filter(d=>d.type===t.toExtensionGraphQLType(s.graphQLType)),c;s.isSingleStrategyExtension&&a.length===1?c=a[0]:s.isDynamicStrategyExtension&&(c=a.find(d=>ll(d,s))),c?(o[s.localIdentifier]=c.uuid,r[s.localIdentifier]=c.id):i.push(s)})}async function dl(e,t,n,i=!1,o){let r=i?t.draftableExtensions:t.allExtensions;r=r.filter(d=>!d.isUUIDStrategyExtension);let s=[],a={},c={};if(ul(e,o,r,s,a,c),s.length>0){let d=await Fs(s,n,o,!1);for(let[l,f]of Object.entries(d))a[l]=f.uuid,c[l]=f.id}return{extensionsNonUuidManaged:a,extensionsIdsNonUuidManaged:c}}async function Fs(e,t,n,i=!0){let o={};for(let r of e)if(n.supportsAtomicDeployments)o[r.localIdentifier]={id:r.uid,uuid:r.uid,type:r.type,title:r.handle};else{let s=await Yn(t,r.graphQLType,r.handle,n,r.contextValue);i&&Dt(`Created extension ${r.handle}.`),o[r.localIdentifier]=s}return o}function fl(e,t,n){let i=n.filter(a=>a.uidStrategy==="dynamic").map(a=>a.identifier),r=nt(e,a=>i.includes(a.type.toLowerCase())),s=t.concat(r.true??[]);return{uuidUidStrategyExtensions:r.false??[],singleAndDynamicStrategyExtensions:s}}u();u();async function Ms(e,t,n){let i=await ml(e,t,n),{app:{versionsDiff:o}}=await n.appVersionsDiff(e,{versionId:i.uuid,appVersionId:i.id});return{versionsDiff:o,versionDetails:i}}async function ml(e,t,n){try{return await n.appVersionByTag(e,t)}catch{throw Qi({headline:"Version couldn't be released.",body:["Version",{userInput:t},"could not be found."]}),new V}}u();function gl(e,t){return t?e.find(i=>i.identifier===t||i.externalIdentifier===t||i.additionalIdentifiers?.includes(t))?.uidStrategy:void 0}async function en(e,t,n,i,o){let s=(o??await t.activeAppVersion(e))?.appModuleVersions.filter(c=>gl(n,c.specification?.identifier)!=="uuid")??[];return s.length===0?void 0:Zn(s,n,i)}function Zn(e,t,n){let i={},o=t.filter($e);return e.forEach(r=>{let s=o.find(c=>c.identifier===r.specification?.identifier.toLowerCase());if(!s)return;let a=r.config;a&&(i=fe(i,s.transformRemoteToLocal?.(a,{flags:n})??a))}),{...i}}u();async function Ds(e,t){S(`Writing app configuration to ${t}`);let n=hl(structuredClone(e)),i=Qn(n),o=new U(t,{});await o.replace(i),await o.transformRaw(yl)}function Qn(e){if(e==null)return e;if(Array.isArray(e))return e.map(Qn);if(typeof e=="object"){let t={};for(let[n,i]of Object.entries(e)){let o=Qn(i);typeof o=="object"&&o!==null&&!Array.isArray(o)&&Object.keys(o).length===0||(t[n]=o)}return t}return e}var ke=(e,t)=>{if(e==null)return null;if(e instanceof p.ZodNullable||e instanceof p.ZodOptional)return ke(e.unwrap(),t);if(e instanceof p.ZodArray)return t.map(n=>ke(e.element,n));if(e instanceof p.ZodEffects)return ke(e._def.schema,t);if(e instanceof p.ZodObject){let n=Object.entries(e.shape),i=t,o={};n.forEach(([s,a])=>{if(i!==void 0&&i[s]!==void 0){let c=ke(a,i[s]);!(c instanceof Array)&&c instanceof Object&&Object.keys(c).length===0&&(c=void 0),o={...o,[s]:c}}});let r=["scopes"];return Object.entries(i).filter(([s])=>!r.includes(s)).sort(([s,a])=>s.localeCompare(s)).forEach(([s,a])=>{n.map(([c])=>c).includes(s)||(o={...o,[s]:a})}),o}return t};function yl(e){let t=`# Learn more about configuring your app at https://shopify.dev/docs/apps/tools/cli/configuration
82
+ `,n=`
83
+ # Learn more at https://shopify.dev/docs/apps/tools/cli/configuration#access_scopes`,i=e.split(/(\r\n|\r|\n)/);return i.unshift(`
84
+ `),i.unshift(t),i.forEach((o,r)=>{o==="[access_scopes]"&&i.splice(r+1,0,n)}),i.join("")}function hl(e){let t=e.webhooks;if(Array.isArray(t?.subscriptions)&&t.subscriptions.length){let n=J(e?.application_url);t.subscriptions=Fo(t.subscriptions),t.subscriptions=t.subscriptions.map(({uri:i,...o})=>({uri:n&&i.includes(n)?i.replace(n,""):i,...o}))}return e}u();function Rs(){let e=["Your app has extensions which need to be assigned",{command:"uid"},"identifiers."],t=["You must first map IDs to your existing extensions by running",{command:"shopify app deploy"},"interactively, without",{command:"--allow-updates"},"or",{command:"--allow-deletes"},", to finish the migration."],n={title:"Reference",body:{list:{items:[{link:{label:"Migrating from the Partner Dashboard",url:"https://shopify.dev/docs/apps/build/dev-dashboard/migrate-from-partners"}}]}}};throw new b(e,void 0,[t],[n])}function Fe(e,t){return{title:e,uid:t,experience:"extension"}}function mt(e){return{title:e,uid:void 0,experience:"dashboard"}}async function Us(e){let t=await Os(e);e.force&&!e.developerPlatformClient.supportsDashboardManagedExtensions&&t.app.extensionRegistrations.filter(r=>!r.id).length>0&&Rs();let n=await Ts(e,t.app);if(n.didMigrateDashboardExtensions){let o=await e.developerPlatformClient.activeAppVersion(e.remoteApp);e.activeAppVersion=o}n.dashboardOnlyExtensions.length>0&&(t=await Os({...e,activeAppVersion:void 0}));let i=Cl(n);return e.release&&(i=await wl(e.developerPlatformClient,e.remoteApp,n.validMatches,n.extensionsToCreate,n.dashboardOnlyExtensions,e.app.specifications??[],e.activeAppVersion)??i),{extensionIdentifiersBreakdown:i,extensionsToConfirm:n,remoteExtensionsRegistrations:t.app}}async function Lb(e,t,n){let{versionsDiff:i,versionDetails:o}=await Ms(t,n,e),r=c=>c.filter(d=>d.specification.experience==="extension"&&d.specification.identifier!=="webhook_subscription").map(d=>Fe(d.registrationTitle,void 0)),s=c=>c.filter(d=>d.specification.options.managementExperience==="dashboard").map(d=>mt(d.registrationTitle));return{extensionIdentifiersBreakdown:{onlyRemote:[...r(i.removed),...s(i.removed)],toCreate:[...r(i.added),...s(i.added)],toUpdate:[],unchanged:[...r(i.updated),...s(i.updated)]},versionDetails:o}}async function Bs({developerPlatformClient:e,remoteApp:t,localApp:n,versionAppModules:i,release:o,activeAppVersion:r}){if(n.allExtensions.filter(s=>s.isAppConfigExtension).length!==0)return o?xl(e,t,n,i,r):_l(n)}function _l(e){return{existingFieldNames:On(e.configuration),existingUpdatedFieldNames:[],newFieldNames:[],deletedFieldNames:[]}}async function Os(e){return e.developerPlatformClient.appExtensionRegistrations(e.remoteApp,e.activeAppVersion)}async function xl(e,t,n,i,o){let r=await en(t,e,n.specifications??[],n.remoteFlags,o)??{},s=i?Zn(i,n.specifications??[],n.remoteFlags):n.configuration;s?.webhooks?.subscriptions?.length&&(s.webhooks.subscriptions=s.webhooks.subscriptions.map(h=>(h.uri.startsWith("/")&&(h.uri=`${J(s.application_url)}${h.uri}`),h)),s.webhooks.subscriptions.sort((h,x)=>{let C=h.uri+(h.topics?.sort().join(",")??""),E=x.uri+(x.topics?.sort().join(",")??"");return C.localeCompare(E)}),r.webhooks?.subscriptions?.sort((h,x)=>{let C=h.uri+(h.topics?.sort().join(",")??""),E=x.uri+(x.topics?.sort().join(",")??"");return C.localeCompare(E)}));let a=bl(s,r,n.configSchema),c=On(s),d=a?.baselineFieldNames??[],l=a?.updatedFieldNames??[],f=c.filter(h=>!d.includes(h)&&!l.includes(h)),_=c.filter(h=>d.includes(h)&&l.includes(h)),g=l.filter(h=>!d.includes(h)&&c.includes(h)),m=d.filter(h=>!l.includes(h)&&h!=="handle");return{existingFieldNames:f,existingUpdatedFieldNames:_,newFieldNames:g,deletedFieldNames:m}}function bl(e,t,n){let[i,o]=Ji({...ke(n,e),build:void 0},{...ke(n,t),build:void 0});if(It(i,o))return;let r=s=>Object.entries(s).filter(([a,c])=>c!==void 0).map(([a])=>a);return{updatedFieldNames:r(i),baselineFieldNames:r(o)}}function Cl({validMatches:e,extensionsToCreate:t,dashboardOnlyExtensions:n}){let i=Object.keys(e).map(s=>Fe(s,void 0)),o=t.map(s=>Fe(s.localIdentifier,void 0)),r=n.filter(s=>!Object.values(e).includes(s.uuid)).map(s=>mt(s.title));return{onlyRemote:[],toCreate:[],toUpdate:[],unchanged:[...i,...o,...r]}}async function wl(e,t,n,i,o,r,s){let a=s??await e.activeAppVersion(t);if(!a)return;let c=El(a,n,i,r,e),d=o.filter(f=>!Object.values(n).includes(f.uuid)&&!i.map(_=>_.localIdentifier).includes(f.uuid)),l=Sl(d,a);return{onlyRemote:[...c.onlyRemote,...l.onlyRemote],toCreate:[...c.toCreate,...l.toCreate],toUpdate:[...c.toUpdate,...l.toUpdate],unchanged:[...c.unchanged,...l.unchanged]}}function El(e,t,n,i,o){let r=e?.appModuleVersions.filter(m=>{let h=i.find(x=>x.identifier===m.specification?.identifier||x.externalIdentifier===m.specification?.identifier);return h&&!$e(h)});function s(m,h){let x=m.registrationUuid===h,C=m.registrationId===h,E=m.registrationId.length===0;return o.supportsAtomicDeployments?C||E&&x:x}let a=Object.entries(t).filter(([m,h])=>r.some(x=>s(x,h))).map(([m,h])=>m),c=r.filter(m=>m.registrationId===""),d=a.filter(m=>c.some(h=>h.registrationUuid===t[m])),l=a.filter(m=>!c.some(h=>h.registrationUuid===t[m])),f=Object.entries(t).filter(([m,h])=>!r.some(x=>s(x,h))).map(([m,h])=>({title:m,uid:h}));return n.map(m=>({title:m.localIdentifier,uid:m.uid})).forEach(m=>{let h=f.findIndex(x=>x.title===m.title);h===-1?f.push(m):f[h]=m}),{onlyRemote:r.filter(m=>!Object.values(t).some(h=>s(m,h))&&!n.map(h=>h.localIdentifier).some(h=>s(m,h))).map(m=>({title:m.registrationTitle,uid:m.registrationId})).map(({title:m,uid:h})=>Fe(m,h)),toCreate:f.map(({title:m,uid:h})=>Fe(m,h)),toUpdate:d.map(m=>Fe(m,void 0)),unchanged:l.map(m=>Fe(m,void 0))}}function Sl(e,t){let n=t?.appModuleVersions.filter(d=>d.specification.options.managementExperience==="dashboard")||[],i=d=>!e.map(l=>l.uuid).includes(d.registrationUuid),o=n.filter(i).map(d=>mt(d.registrationTitle)),r=d=>n.map(l=>l.registrationUuid).includes(d.uuid),s=d=>!r(d),a=e.filter(s).map(d=>mt(d.title)),c=e.filter(r).map(d=>mt(d.title));return{onlyRemote:o,toCreate:a,toUpdate:[],unchanged:c}}u();u();var Pl={bullet:"+",color:"green",suffix:"(new)"},vl={color:"#FF8800",suffix:"(updated)"},Al={bullet:"-",color:"red",suffix:"(removed)"};function ei(e){return[...e.new.map(t=>Xn(t,Pl)),...e.updated?e.updated.map(t=>Xn(t,vl)):[],...e.unchanged,...e.removed.map(t=>Xn(t,Al))]}function Xn(e,t){let n=typeof e=="string"?[e,{subdued:t.suffix??""}]:e;return{...t.bullet?{bullet:t.bullet}:{},item:n,color:t.color}}function Il({force:e,allowUpdates:t,allowDeletes:n,extensionIdentifiersBreakdown:i,configExtensionIdentifiersBreakdown:o}){if(e||t&&n)return!0;let r=i.onlyRemote.length>0,s=(o?.deletedFieldNames.length??0)>0,a=r||s,c=i.toCreate.length>0||i.toUpdate.length>0,d=(o?.newFieldNames.length??0)>0||(o?.existingUpdatedFieldNames.length??0)>0,l=c||d;if(t&&!a||n&&!l)return!0;if(!no()&&(a||l)){let f=[];throw l&&f.push("--allow-updates"),a&&f.push("--allow-deletes"),new b("This deployment includes changes that require confirmation.",["Run the command with",{command:f.join(" ")},"to deploy without confirmation."])}return!1}async function $s({force:e,allowUpdates:t,allowDeletes:n,extensionIdentifiersBreakdown:i,configExtensionIdentifiersBreakdown:o,appTitle:r,release:s,installCount:a}){if(await q.addPublicMetadata(()=>Ml(o)),Il({force:e,allowUpdates:t,allowDeletes:n,extensionIdentifiersBreakdown:i,configExtensionIdentifiersBreakdown:o}))return!0;let d=await kl(i),l=await Fl(s,o);return Tl({appTitle:r,extensionsContentPrompt:d,configContentPrompt:l,release:s,installCount:a})}async function Tl({appTitle:e,extensionsContentPrompt:{extensionsInfoTable:t,hasDeletedExtensions:n},configContentPrompt:i,release:o,installCount:r}){let s=new Date().valueOf(),a=!0,c=[];i&&c.push(i.configInfoTable.items.length===0?{...i.configInfoTable,emptyItemsText:"No changes",items:[]}:i.configInfoTable);let d=e!==void 0&&n;t?c.push(d?{...t,helperText:"Removing extensions can permanently delete app user data"}:t):c.push({header:"Extensions:",emptyItemsText:"None",items:[]});let l=`${o?"Release":"Create"} a new version${e?` of ${e}`:""}?`,f=n&&r!==void 0&&r>0;d?a=await to({message:l,infoTable:c,confirmation:e,...f?{warningItem:["This release removes extensions and related data from",{error:r.toString()},`app installations.
85
+ Use caution as this may include production data on live stores.`]}:{}}):a=await $({message:l,infoTable:c,confirmationMessage:`Yes, ${o?"release":"create"} this new version`,cancellationMessage:"No, cancel"});let _=new Date().valueOf()-s;return await q.addPublicMetadata(()=>({cmd_deploy_confirm_cancelled:!a,cmd_deploy_confirm_time_to_complete_ms:_})),a}async function kl(e){let{onlyRemote:t,toCreate:n,toUpdate:i,unchanged:o}=e,r=(l,f)=>{switch(l.experience){case"dashboard":return[l.title,{subdued:`(${f}from Partner Dashboard)`}];case"extension":return l.uid&&l.uid.length>0?`${l.title} (uid: ${l.uid})`:l.title}},s,a={new:n.map(l=>r(l,"new, ")),unchanged:o.map(l=>r(l,"")),updated:i.map(l=>r(l,"updated, ")),removed:t.map(l=>r(l,"removed, "))},c=ei(a),d=t.length>0;return c.length>0&&(s={header:"Extensions:",items:c}),await q.addPublicMetadata(()=>({cmd_deploy_confirm_new_registrations:n.length,cmd_deploy_confirm_updated_registrations:i.length,cmd_deploy_confirm_removed_registrations:t.length})),{extensionsInfoTable:s,hasDeletedExtensions:d}}async function Fl(e,t){if(!t)return;let{existingFieldNames:n,existingUpdatedFieldNames:i,newFieldNames:o,deletedFieldNames:r}=t,a=ei({new:o,updated:i,unchanged:n,removed:r});return{configInfoTable:{header:"Configuration:",items:o.length>0||i.length>0||r.length>0||!e?a:[]}}}function Ml(e){if(!e)return{cmd_deploy_include_config_used:!1};let{existingFieldNames:t,existingUpdatedFieldNames:n,newFieldNames:i,deletedFieldNames:o}=e,r=[...n,...i,...t];return{cmd_deploy_include_config_used:!0,...r.length>0?{cmd_deploy_config_modules_breakdown:JSON.stringify(r.sort())}:{},...n.length>0?{cmd_deploy_config_modules_updated:JSON.stringify(n.sort())}:{},...i.length>0?{cmd_deploy_config_modules_added:JSON.stringify(i.sort())}:{},...o.length>0?{cmd_deploy_config_modules_deleted:JSON.stringify(o.sort())}:{}}}async function Ls(e){let{extensionIdentifiersBreakdown:t,extensionsToConfirm:n,remoteExtensionsRegistrations:i}=await Us(e),o=await Bs({developerPlatformClient:e.developerPlatformClient,apiKey:e.appId,localApp:e.app,remoteApp:e.remoteApp,release:e.release,activeAppVersion:e.activeAppVersion}),r=t.onlyRemote.length>0&&!e.force&&!(e.allowUpdates&&e.allowDeletes),s;if(r)try{s=await e.developerPlatformClient.appInstallCount({id:e.remoteApp.id,apiKey:e.remoteApp.apiKey,organizationId:e.remoteApp.organizationId})}catch{s=void 0}if(!await $s({extensionIdentifiersBreakdown:t,configExtensionIdentifiersBreakdown:o,appTitle:e.remoteApp?.title,release:e.release,force:e.force,allowUpdates:e.allowUpdates,allowDeletes:e.allowDeletes,installCount:s}))throw new V;let c=await ks(e,i.extensionRegistrations,i.configurationRegistrations,n);return{app:e.appId,extensions:c.extensions,extensionIds:c.extensionIds,extensionsNonUuidManaged:c.extensionsNonUuidManaged}}u();function js({appName:e,org:t,devStores:n,updateURLs:i,includeConfigOnDeploy:o,messages:r}){let s=[`App: ${e}`];t&&s.unshift(`Org: ${t}`),n&&n.length>0&&n.forEach(c=>s.push(`Dev store: ${c}`)),i&&s.push(`Update URLs: ${i}`),o!==void 0&&s.push(`Include config: ${o?"Yes":"No"}`);let a=[{list:{items:s}}];if(r&&r.length)for(let c=0;c<r.length;c++){let d=r[c];if(!d||d.length===0)continue;let l=c===0?`
86
+ `:`
87
+
88
+ `;a=a.concat(l,d)}return a}u();async function Ns({app:e,identifiers:t,command:n,developerPlatformClient:i},o=process.env){let r=e.dotenv;r??={path:y(e.directory,fs(e.configPath)),variables:{}};let s={...e.dotenv?.variables??{}};o[e.idEnvironmentVariableName]||(s[e.idEnvironmentVariableName]=t.app),Object.keys(t.extensions).forEach(d=>{let l=`SHOPIFY_${bt(d)}_ID`;o[l]||(s[l]=t.extensions[d])});let c=!It(r.variables,s)&&(n==="deploy"||n==="release")&&!i.supportsAtomicDeployments||n==="import-extensions";if(r.variables=s,c){let l=await w(r.path)?await F(r.path):"",f=mo(l,s);await B(r.path,f),e.dotenv=r}return e}function Ws({app:e},t=process.env){let n={...e.dotenv?.variables,...t},i={},o=r=>{Object.keys(n).includes(r.idEnvironmentVariableName)&&(i[r.localIdentifier]=n[r.idEnvironmentVariableName])};return e.allExtensions.forEach(o),{app:n[e.idEnvironmentVariableName],extensions:i}}var Vs=e=>({message:A`Invalid Client ID: ${e}`,tryMessage:A`You can find the Client ID in the app settings in the Developer Dashboard.`}),zs=["You can pass",{command:"--reset"},"to your command to reset your app configuration."],Rl=(e,t=!1)=>[{list:{title:"Next steps:",items:["Check that your account has permission to develop apps for this organization or contact the owner of the organization to grant you permission",["Run",{command:"shopify auth login"},"to log into a different",t?"organization":"account","than",{bold:e}],["Pass",{command:"--reset"},"to your command to create a new app"]]}}],tn=async e=>{let t=Lo(),n;for(let i of t)try{if(n=await i.appFromIdentifiers(e.apiKey),n)break}catch(o){if("statusCode"in o&&o.statusCode===404)continue;throw o}if(!n){let i=await t[0]?.accountInfo()??{type:"UnknownAccount"},o="Unknown account",r=!1;throw Vi(i)?(o=i.orgName,r=!0):Wi(i)&&(o=i.email),new b(["No app with client ID",{command:e.apiKey},"found"],Rl(o,r))}return n};async function $C(e){let{reset:t,force:n,noRelease:i,app:o,remoteApp:r,developerPlatformClient:s,organization:a}=e,c=await s.activeAppVersion(r),d=await Ol({app:o,reset:t,force:n,developerPlatformClient:s});qs({org:a.businessName,appName:r.title,appDotEnv:o.dotenv?.path,configFile:T(o.configPath),includeConfigOnDeploy:d,messages:[zs]});let l=await Ls({app:o,appId:r.apiKey,appName:r.title,force:n,release:!i,developerPlatformClient:s,envIdentifiers:Ws({app:o}),remoteApp:r,activeAppVersion:c,allowUpdates:e.allowUpdates,allowDeletes:e.allowDeletes});await Ns({app:o,identifiers:l,command:"deploy",developerPlatformClient:s});let f=!1;return s.supportsAtomicDeployments&&c&&(f=c.appModuleVersions.some(_=>!_.registrationId)),{identifiers:l,didMigrateExtensionsToDevDash:f}}async function Ol({app:e,reset:t,force:n,developerPlatformClient:i}){if(i.supportsAtomicDeployments){await Ul(e);return}let o=e.includeConfigOnDeploy;if(t&&(o=void 0),n&&o===void 0){let r=["You must specify a value for",{command:"include_config_on_deploy"},"in your TOML file. Including configuration will be required very soon."],s=["Run",{command:"shopify app deploy"},"interactively, without",{command:"--allow-updates"},"or",{command:"--allow-deletes"},"."];throw new b(r,s)}return n||o===!0?o:Ll({appDirectory:e.directory,localApp:e})}async function Ul(e){let t=e.configuration.build?.include_config_on_deploy;if(t===void 0)return;await(await U.read(e.configPath)).remove("build.include_config_on_deploy"),t?Bl():$l()}function Bl(){Qe({headline:"Your configuration file has been modified",body:["The `include_config_on_deploy` field is no longer supported, since all apps must now include configuration on deploy. It has been removed from your configuration file."],link:{label:"See Shopify CLI documentation.",url:"https://shopify.dev/docs/apps/build/cli-for-apps/app-configuration#build"}})}function $l(){Ft({headline:"Configuration is now included on deploy",body:["The `include_config_on_deploy` field is no longer supported and has been removed from your configuration file. Review this file to ensure it's up to date with the correct configuration."],link:{label:"See Shopify CLI documentation.",url:"https://shopify.dev/docs/apps/build/cli-for-apps/app-configuration#build"}})}async function Ll(e){let t=await jl(e.localApp.configPath);return e.localApp.configuration.build={...e.localApp.configuration.build,include_config_on_deploy:t},await(await U.read(e.localApp.configPath)).patch({build:{include_config_on_deploy:t}}),await q.addPublicMetadata(()=>({cmd_deploy_confirm_include_config_used:t})),t}function jl(e){return $({message:`Include \`${T(e)}\` configuration on \`deploy\`? Soon, this will no longer be optional and configuration will be included on every deploy.`,confirmationMessage:"Yes, always (Recommended)",cancellationMessage:"No, not now"})}async function Js(e){let t=await Nl(),n=jo({organization:t}),{organization:i,apps:o,hasMorePages:r}=await n.orgAndApps(t.id),s=await gs(o,r,i,n,e);return await ti(s,n.organizationSource),s}async function Nl(){let e=await No();return await Xr(e)}function LC({organization:e,app:t,remoteApp:n,selectedStore:i,tunnelMode:o}){if(Ai())return;let r="Not yet configured",s=t.configuration.build?.automatically_update_urls_on_dev;s!==void 0&&(r=s?"Yes":"No");let a=[zs];o==="use-localhost"&&a.push(["Note:",{command:"--use-localhost"},"is not compatible with Shopify features which directly invoke your app","(such as Webhooks, App proxy, and Flow actions), or those which require testing your app from another","device (such as POS)."]),qs({org:e.businessName,appName:n.title,devStore:i.shopDomain,updateURLs:r,configFile:T(t.configPath),messages:a})}function qs({org:e,appName:t,devStore:n,updateURLs:i,configFile:o,appDotEnv:r,includeConfigOnDeploy:s,messages:a}){let c=[];n&&c.push(n);let d=(r&&T(r))??(o&&X(o));Qe({headline:o?`Using ${d} for default values:`:"Using these settings:",body:js({appName:t,org:e,devStores:c,updateURLs:i,includeConfigOnDeploy:s,messages:a})})}async function ti(e,t){let i={[t==="BusinessPlatform"?"business_platform_id":"partner_id"]:He(e.organizationId)};await q.addPublicMetadata(()=>({...i,api_key:e.apiKey}))}async function jC({apiKey:e,developerPlatformClient:t}){return Ks({apiKey:e,developerPlatformClient:t,enabled:!0})}async function NC({apiKey:e,developerPlatformClient:t}){await Ks({apiKey:e,developerPlatformClient:t,enabled:!1})}async function Ks({apiKey:e,developerPlatformClient:t,enabled:n}){let i={input:{apiKey:e,enabled:n}},r=(await t.updateDeveloperPreview(i)).developmentStorePreviewUpdate.userErrors;return!r||r.length===0}u();u();u();u();var Wl=Be.extend({app_proxy:p.object({url:p.preprocess(J,Eo(p.string({invalid_type_error:"Value must be string"}))),subpath:p.string({invalid_type_error:"Value must be a string"}),prefix:p.string({invalid_type_error:"Value must be a string"})}).optional()}),ni="app_proxy",Vl={forward:(e,t)=>{let n=e;if(!n.app_proxy)return{};let i;return"application_url"in t&&(i=t?.application_url),{url:xe(n.app_proxy.url,i),subpath:n.app_proxy.subpath,prefix:n.app_proxy.prefix}},reverse:e=>{let t=e;return{app_proxy:{url:J(t.url),subpath:t.subpath,prefix:t.prefix}}}},zl=oe({identifier:ni,schema:Wl,transformConfig:Vl,getDevSessionUpdateMessages:async e=>e.app_proxy?[`Using URL: ${e.app_proxy.url}`,"Any changes to prefix and subpath will only apply to new installs"]:[],patchWithAppDevURLs:(e,t)=>{t.appProxy&&(e.app_proxy={url:t.appProxy.proxyUrl,subpath:t.appProxy.proxySubPath,prefix:t.appProxy.proxySubPathPrefix})}}),Hs=zl;u();var Jl=Be.extend({pos:p.object({embedded:p.boolean({invalid_type_error:"Value must be Boolean"})}).optional()}),ii="point_of_sale",ql={embedded:"pos.embedded"},Kl=oe({identifier:ii,schema:Jl,transformConfig:ql}),Gs=Kl;u();u();function Ys(e,t){let n=e;if(!n.events?.subscription)return e;let i;return t&&"application_url"in t&&(i=t?.application_url),{...n,events:{...n.events,subscription:n.events.subscription.map(o=>({...o,uri:xe(o.uri,i)}))}}}function Zs(e){let t=W(e,"events"),n=W(t,"api_version"),o=W(t,"subscription")?.map(s=>{let{identifier:a,...c}=s;return c});return{events:n??o?{api_version:n,subscription:o}:{}}}var oi="events",Hl={forward:Ys,reverse:e=>Zs(e)},Gl=Be.extend({events:p.any().optional()}),Yl=oe({identifier:oi,schema:Gl,transformConfig:Hl}),Qs=Yl;u();var Zl={forward:Xl,reverse:e=>eu(e)},si="privacy_compliance_webhooks",Ql=oe({identifier:si,schema:$t,transformConfig:Zl}),Xs=Ql;function Xl(e,t){let n=W(e,"webhooks"),i;"application_url"in t&&(i=t?.application_url);let o=qi({customers_redact_url:ri(tu(n),i),customers_data_request_url:ri(nu(n),i),shop_redact_url:ri(iu(n),i)});if(Object.keys(o).length===0)return o;{let{api_version:r}=n;return{api_version:r,...o}}}function eu(e){let t=W(e,"customers_redact_url"),n=W(e,"customers_data_request_url"),i=W(e,"shop_redact_url"),o=[];return n&&o.push({compliance_topics:["customers/data_request"],uri:n}),t&&o.push({compliance_topics:["customers/redact"],uri:t}),i&&o.push({compliance_topics:["shop/redact"],uri:i}),o.length===0?{}:{webhooks:{subscriptions:ko(o),privacy_compliance:void 0}}}function ai(e,t){return e.subscriptions?.find(n=>n.compliance_topics?.includes(t))?.uri}function ri(e,t){return t&&e?.startsWith("/")?`${J(t)}${e}`:e}function tu(e){return ai(e,"customers/redact")??e?.privacy_compliance?.customer_deletion_url}function nu(e){return ai(e,"customers/data_request")??e?.privacy_compliance?.customer_data_request_url}function iu(e){return ai(e,"shop/redact")??e?.privacy_compliance?.shop_deletion_url}u();var ou="@shopify/post-purchase-ui-extensions",ru=R.extend({metafields:p.array(ye).optional()}),su=k({identifier:"checkout_post_purchase",dependency:ou,partnersWebIdentifier:"post_purchase",schema:ru,appModuleFeatures:e=>["ui_preview","cart_url","esbuild","single_js_entry_path"],getOutputRelativePath:e=>`dist/${e.handle}.js`,clientSteps:[{lifecycle:"deploy",steps:[{id:"bundle-ui",name:"Bundle UI Extension",type:"bundle_ui",config:{}}]}],deployConfig:async(e,t)=>({metafields:e.metafields??[]})}),ea=su;u();var au="@shopify/checkout-ui-extensions",pu=R.extend({name:p.string(),extension_points:p.array(p.string()).optional(),metafields:p.array(ye).optional(),settings:p.object({fields:p.any().optional()}).optional()}),cu=k({identifier:"checkout_ui_extension",dependency:au,schema:pu,appModuleFeatures:e=>["ui_preview","cart_url","esbuild","single_js_entry_path","generates_source_maps"],getOutputRelativePath:e=>`dist/${e.handle}.js`,clientSteps:[{lifecycle:"deploy",steps:[{id:"bundle-ui",name:"Bundle UI Extension",type:"bundle_ui",config:{}}]}],deployConfig:async(e,t)=>({extension_points:e.extension_points,capabilities:e.capabilities,supported_features:e.supported_features,metafields:e.metafields??[],name:e.name,settings:e.settings,localization:await ie(t,"checkout_ui")})}),ta=cu;u();u();u();var L={customer_reference:"customer_reference",order_reference:"order_reference",product_reference:"product_reference",marketing_activity_reference:"marketing_activity_reference",abandonment_reference:"abandonment_reference",company_reference:"company_reference",company_contact_reference:"company_contact_reference"},$w=["customer","order","product","marketing_activity","abandonment","company","company_contact"],na=[L.customer_reference,L.order_reference,L.product_reference,L.company_reference,L.company_contact_reference],ia=[L.customer_reference,L.order_reference,L.product_reference,L.marketing_activity_reference,L.abandonment_reference,L.company_reference,L.company_contact_reference],O={boolean:"boolean",email:"email",multiLineText:"multi_line_text_field",int:"number_integer",singleLineText:"single_line_text_field",url:"url",decimal:"number_decimal",schemaTypeReference:"schema_type_reference"},oa=[[O.boolean,"checkbox"],[O.email,"email"],[O.multiLineText,"text-multi-line"],[O.int,"int"],[O.singleLineText,"text-single-line"],[O.url,"url"],[O.decimal,"number"],[O.schemaTypeReference,"schema-type-reference"]],lu=[O.boolean,O.email,O.multiLineText,O.int,O.singleLineText,O.url,O.decimal],uu=[O.boolean,O.email,O.singleLineText,O.url,O.decimal,O.schemaTypeReference],ra=oa.filter(([e])=>lu.includes(e)),sa=oa.filter(([e])=>uu.includes(e));u();u();var nn=async(e,t)=>{if(!t)return"";let n=await D(y(e,t));if(n.length>1)throw new Error("Multiple files found for schema path");if(n.length===0)throw new Error("No file found for schema path");return F(n[0])};u();var du=new Map(ra),fu=new Map(sa),mu=(e,t)=>{let n=t==="flow_action"?du:fu,i=pi(e.type),o=i?n.get("schema_type_reference"):n.get(e.type);if(typeof e.key!="string")throw new b(`key property must be specified for non-commerce object fields in ${JSON.stringify(e)}`);if(!o)throw new b(`Field type ${e.type} is not supported on Flow ${t==="flow_action"?"Actions":"Triggers"}`);let r={name:e.key,description:e.description,uiType:o};return t==="flow_action"&&(r.label=e.name,r.required=e.required),i&&(r.typeRefName=e.type.replace("schema.","")),r},gu=(e,t)=>{if(t==="flow_trigger"&&!na.includes(e.type))throw new b(`Commerce object ${e.type} is not supported for Flow Triggers`);if(t==="flow_action"&&!ia.includes(e.type))throw new b(`Commerce object ${e.type} is not supported for Flow Actions`);let n=e.type.replace("_reference",""),i={name:`${n}_id`,uiType:t==="flow_action"?"commerce-object-id":n,description:e.description};return n==="marketing_activity"&&(i.uiType="marketing-activity-id",i.marketingActivityCreateUrl=e.marketingActivityCreateUrl,i.marketingActivityDeleteUrl=e.marketingActivityDeleteUrl),t==="flow_action"&&(i.label=`${Me(n)} ID`,i.required=e.required),i},on=(e,t)=>t?t.map(i=>Object.keys(L).includes(i.type)?gu(i,e):mu(i,e)):[];var ci=vo.extend({key:p.string().regex(/^[a-zA-Z\s]*$/,{message:"String must contain only alphabetic characters and spaces"}).optional()}),yu=Ue.extend({type:p.literal("flow_trigger"),name:p.string(),schema:p.string().optional(),settings:p.object({fields:p.array(ci).optional()}).optional()}).refine(e=>{let t=e.settings?.fields??[],n=t.every((o,r)=>rn(o,"flow_trigger",e.handle,r)),i=pa(t,e.schema);return n&&i}),hu=k({identifier:"flow_trigger",schema:yu,appModuleFeatures:e=>[],deployConfig:async(e,t)=>({title:e.name,description:e.description,fields:on("flow_trigger",e.settings?.fields),schema_patch:await nn(t,e.schema)})}),aa=hu;function ca(e,t,n,i){let o=`'${e}' property must be a string for 'field[${i}]' ${JSON.stringify(t)} of flow extension '${n}'`;return{required_error:o,invalid_type_error:o}}var li=p.object({type:p.string(),description:p.string().optional()}).strict(),rn=(e,t,n,i)=>{let o=Object.keys(L).includes(e.type);return o?o?li.extend({required:p.boolean().optional(),marketingActivityCreateUrl:p.string().optional(),marketingActivityDeleteUrl:p.string().optional()}).parse(e):li.parse(e):t==="flow_action"?li.extend({key:p.string(ca("key",e,n,i)),name:p.string(ca("name",e,n,i)),required:p.boolean().optional()}).parse(e):ci.parse(e)},gt=e=>e.startsWith("https://"),pi=e=>e.startsWith("schema."),la=(e,t,n)=>{if(e||t){if(!e)throw new p.ZodError([{code:p.ZodIssueCode.custom,path:["extensions[0].config_page_url"],message:"To set a custom configuration page a `config_page_url` must be specified."}]);if(!t)throw new p.ZodError([{code:p.ZodIssueCode.custom,path:["extensions[0].config_page_preview_url"],message:"To set a custom configuration page a `config_page_preview_url` must be specified."}]);if(!n)throw new p.ZodError([{code:p.ZodIssueCode.custom,path:["extensions[0].validation_url"],message:"To set a custom configuration page a `validation_url` must be specified."}])}return!0},pa=(e,t)=>{if(e.some(n=>pi(n.type))&&!t)throw new p.ZodError([{code:p.ZodIssueCode.custom,path:["extensions[0].schema"],message:"To reference schema types a `schema` must be specified."}]);return!0},ua=(e,t)=>{if(e||t){if(!e)throw new p.ZodError([{code:p.ZodIssueCode.custom,path:["extensions[0].return_type_ref"],message:"When uploading a schema a `return_type_ref` must be specified."}]);if(!t)throw new p.ZodError([{code:p.ZodIssueCode.custom,path:["extensions[0].schema"],message:"To set a return type a `schema` must be specified."}])}return!0};var _u=Ue.extend({type:p.literal("flow_action"),name:p.string(),runtime_url:p.string().url().refine(gt),validation_url:p.string().url().refine(gt).optional(),config_page_url:p.string().url().refine(gt).optional(),config_page_preview_url:p.string().url().refine(gt).optional(),schema:p.string().optional(),return_type_ref:p.string().optional()}).refine(e=>{let t=la(e.config_page_url,e.config_page_preview_url,e.validation_url),i=(e.settings?.fields??[]).every((r,s)=>rn(r,"flow_action",e.handle,s)),o=ua(e.return_type_ref,e.schema);return t&&i&&o}),xu=k({identifier:"flow_action",schema:_u,appModuleFeatures:e=>[],deployConfig:async(e,t)=>({title:e.name,description:e.description,url:e.runtime_url,fields:on("flow_action",e.settings?.fields),validation_url:e.validation_url,custom_configuration_page_url:e.config_page_url,custom_configuration_page_preview_url:e.config_page_preview_url,schema_patch:await nn(t,e.schema),return_type_ref:e.return_type_ref})}),da=xu;u();import bu from"fs";var fa=["buyer_experience","customers","fulfillment","inventory_and_merch","loyalty","orders","promotion","risk","b2b","payment_reminders","custom_data","error_monitoring"],Cu=["capture_at_fulfillment"],wu=Ue.extend({type:p.literal("flow_template"),name:p.string(),description:p.string().max(1024),template:p.object({categories:p.array(p.string().refine(e=>fa.concat(Cu).includes(e),e=>({message:`${e} is not a valid category. Valid categories include: ${fa.join(", ")}.`}))),module:p.string(),require_app:p.boolean().optional(),discoverable:p.boolean().optional(),allow_one_click_activate:p.boolean().optional(),enabled:p.boolean().optional()})}),Eu=k({identifier:"flow_template",schema:wu,appModuleFeatures:e=>["ui_preview"],clientSteps:[{lifecycle:"deploy",steps:[{id:"copy-files",name:"Copy Files",type:"include_assets",config:{inclusions:[{type:"pattern",include:["**/*.flow","**/*.json","**/*.toml"]}]}}]}],deployConfig:async(e,t)=>({template_handle:e.handle,name:e.name,description:e.description,categories:e.template.categories,require_app:e.template.require_app,discoverable:e.template.discoverable,allow_one_click_activate:e.template.allow_one_click_activate,enabled:e.template.enabled,definition:await Su(t,e.template.module),localization:await ie(t,e.name)})});async function Su(e,t){let i=(await D(y(e,t)))[0];if(!i)throw new b(`Missing flow file with the path ${y(e,t)}`);return bu.readFileSync(i,"base64")}var ma=Eu;u();var Pu=R.extend({build:p.object({command:p.string().transform(e=>e.trim()===""?void 0:e).optional(),path:p.string().optional(),watch:p.union([p.string(),p.string().array()]).optional(),wasm_opt:p.boolean().optional().default(!0),typegen_command:p.string().transform(e=>e.trim()===""?void 0:e).optional()}).optional(),name:p.string(),type:p.string(),configuration_ui:p.boolean().optional().default(!0),ui:p.object({enable_create:p.boolean().optional(),paths:p.object({create:p.string(),details:p.string()}).optional(),handle:p.string().optional()}).optional(),api_version:p.string(),input:p.object({variables:p.object({namespace:p.string(),key:p.string()}).optional()}).optional(),targeting:p.array(p.object({target:p.string(),input_query:p.string().optional(),export:p.string().optional()})).optional()}),vu=k({identifier:"function",additionalIdentifiers:["order_discounts","cart_checkout_validation","cart_transform","delivery_customization","payment_customization","product_discounts","shipping_discounts","fulfillment_constraints","order_routing_location_rule","local_pickup_delivery_option_generator","pickup_point_delivery_option_generator"],schema:Pu,appModuleFeatures:e=>["function"],getOutputRelativePath:e=>y("dist","index.wasm"),devSessionWatchConfig:e=>{let t=e.configuration;if(!t.build||!t.build.watch)return;let n=[t.build.watch].flat().map(i=>y(e.directory,i));return n.push(y(e.directory,"locales","**.json")),n.push(y(e.directory,"**","!(.)*.graphql")),n.push(y(e.directory,"**.toml")),{paths:n}},clientSteps:[{lifecycle:"deploy",steps:[{id:"build-function",name:"Build Function",type:"build_function",config:{}}]}],deployConfig:async(e,t,n)=>{let i,o=Ui(),r=y(t,"input.graphql");await w(r)&&(i=await F(r));let s=e.targeting&&await Promise.all(e.targeting.map(async c=>{let d;return c.input_query&&(d=await Au(y(t,c.input_query))),{handle:c.target,export:c.export,input_query:d}})),a;return e.ui?.paths&&(a={app_bridge:{details_path:e.ui.paths.details,create_path:e.ui.paths.create}}),e.ui?.handle!==void 0&&(a={...a,ui_extension_handle:e.ui.handle}),{title:e.name,module_id:o,description:e.description,app_key:n,api_type:e.type==="function"?void 0:e.type,api_version:e.api_version,input_query:i,input_query_variables:e.input?.variables?{single_json_metafield:e.input.variables}:void 0,ui:a,enable_creation_ui:e.ui?.enable_create??!0,localization:await ie(t,"function"),targets:s}},preDeployValidation:async e=>{if(!await w(e.outputPath))throw new b(A`The function extension "${e.handle}" hasn't compiled the wasm in the expected path: ${e.outputPath}`,"Make sure the build command outputs the wasm in the expected directory.")}});async function Au(e){if(await w(e))return F(e);throw new b(`No input query file at ${e}.`,"Create the file or remove the line referencing it in the extension's TOML.")}var ga=vu;u();u();u();var ya=50,G=R.extend({api_version:p.string(),payment_session_url:p.string().url(),refund_session_url:p.string().url().optional(),capture_session_url:p.string().url().optional(),void_session_url:p.string().url().optional(),supported_countries:p.array(p.string()),supported_payment_methods:p.array(p.string()),test_mode_available:p.boolean(),merchant_label:p.string().max(ya),input:p.object({metafield_identifiers:p.object({namespace:p.string(),key:p.string()}).optional()}).optional()}),be=p.object({buyer_label:p.string().max(ya).optional(),buyer_label_translations:p.array(p.object({locale:p.string(),label:p.string()})).optional()}),ze=p.object({supports_installments:p.boolean(),supports_deferred_payments:p.boolean()}),sn=p.object({multiple_capture:p.boolean().optional()}),Ce=p.object({confirmation_callback_url:p.string().url().optional(),supports_3ds:p.boolean()}),se=p.object({supported_buyer_contexts:p.array(p.object({currency:p.string(),countries:p.array(p.string()).nonempty().optional()}).strict()).optional().refine(e=>e===void 0||e.every(t=>t.countries)||e.every(t=>!t.countries),{message:"Must all be defined with only a currency, or must all be defined with a currency plus countries -- a mixture of the two is not allowed"})});var ui="payments.offsite.render",ha=G.merge(be).merge(ze).merge(Ce).merge(sn).merge(se).extend({targeting:p.array(p.object({target:p.literal(ui)})).length(1),supports_oversell_protection:p.boolean().optional()}).refine(e=>!e.supports_oversell_protection||e.confirmation_callback_url,{message:"Property required when supports_oversell_protection is true",path:["confirmation_callback_url"]}).refine(e=>e.supports_installments===e.supports_deferred_payments,{message:"supports_installments and supports_deferred_payments must be the same"});function qE(e){return{api_version:e.api_version,payment_session_url:e.start_payment_session_url,refund_session_url:e.start_refund_session_url,capture_session_url:e.start_capture_session_url,void_session_url:e.start_void_session_url,confirmation_callback_url:e.confirmation_callback_url,multiple_capture:e.multiple_capture,merchant_label:e.merchant_label,supported_countries:e.supported_countries,supported_payment_methods:e.supported_payment_methods,supported_buyer_contexts:e.supported_buyer_contexts,test_mode_available:e.test_mode_available,buyer_label:e.default_buyer_label,buyer_label_translations:e.buyer_label_to_locale,supports_oversell_protection:e.supports_oversell_protection,supports_3ds:e.supports_3ds,supports_deferred_payments:e.supports_deferred_payments,supports_installments:e.supports_installments}}async function _a(e){return{api_version:e.api_version,start_payment_session_url:e.payment_session_url,start_refund_session_url:e.refund_session_url,start_capture_session_url:e.capture_session_url,start_void_session_url:e.void_session_url,confirmation_callback_url:e.confirmation_callback_url,multiple_capture:e.multiple_capture,merchant_label:e.merchant_label,supported_countries:e.supported_countries,supported_payment_methods:e.supported_payment_methods,supported_buyer_contexts:e.supported_buyer_contexts,test_mode_available:e.test_mode_available,default_buyer_label:e.buyer_label,buyer_label_to_locale:e.buyer_label_translations,supports_oversell_protection:e.supports_oversell_protection,supports_3ds:e.supports_3ds,supports_deferred_payments:e.supports_deferred_payments,supports_installments:e.supports_installments}}u();u();function we(e,t){let n=e.ui_extension_handle;if(n||!("ui_extension_registration_uuid"in e))return n;let i=t.find(o=>o.uuid===e.ui_extension_registration_uuid)?.title;return i?j(i):n}var di="payments.redeemable.render",xa=G.merge(be).merge(se).extend({targeting:p.array(p.object({target:p.literal(di)})).length(1),api_version:p.string(),balance_url:p.string().url(),ui_extension_handle:p.string().optional(),checkout_payment_method_fields:p.array(p.object({type:p.union([p.literal("string"),p.literal("number"),p.literal("boolean")]),required:p.boolean(),key:p.string()})).optional()});function nS(e,t){let n=we(e,t);return{api_version:e.api_version,payment_session_url:e.start_payment_session_url,refund_session_url:e.start_refund_session_url,capture_session_url:e.start_capture_session_url,void_session_url:e.start_void_session_url,merchant_label:e.merchant_label,supported_countries:e.supported_countries,supported_payment_methods:e.supported_payment_methods,supported_buyer_contexts:e.supported_buyer_contexts,test_mode_available:e.test_mode_available,buyer_label:e.default_buyer_label,buyer_label_translations:e.buyer_label_to_locale,balance_url:e.balance_url,checkout_payment_method_fields:e.checkout_payment_method_fields?.map(i=>({key:i.key,type:i.type,required:i.required})),ui_extension_handle:n}}async function ba(e){let t=e.supported_payment_methods[0]==="gift-card"?"gift_card":null;return{api_version:e.api_version,start_payment_session_url:e.payment_session_url,start_refund_session_url:e.refund_session_url,start_capture_session_url:e.capture_session_url,start_void_session_url:e.void_session_url,merchant_label:e.merchant_label,supported_countries:e.supported_countries,supported_payment_methods:e.supported_payment_methods,supported_buyer_contexts:e.supported_buyer_contexts,test_mode_available:e.test_mode_available,default_buyer_label:e.buyer_label,buyer_label_to_locale:e.buyer_label_translations,balance_url:e.balance_url,redeemable_type:t,checkout_payment_method_fields:e.checkout_payment_method_fields,ui_extension_handle:e.ui_extension_handle}}u();var fi="payments.custom-onsite.render",Ca=7,wa=G.merge(be).merge(ze).merge(Ce).merge(se).extend({targeting:p.array(p.object({target:p.literal(fi)})).length(1),update_payment_session_url:p.string().url().optional(),multiple_capture:p.boolean().optional(),supports_oversell_protection:p.boolean().optional(),modal_payment_method_fields:p.array(p.object({})).optional(),ui_extension_handle:p.string().optional(),start_verification_session_url:p.string().url().optional(),checkout_payment_method_fields:p.array(p.object({type:p.union([p.literal("string"),p.literal("number"),p.literal("boolean")]),required:p.boolean(),key:p.string()})).max(Ca,`The extension can't have more than ${Ca} checkout_payment_method_fields`).optional()}).refine(e=>e.supports_installments===e.supports_deferred_payments,{message:"supports_installments and supports_deferred_payments must be the same"});function cS(e,t){let n=we(e,t);return{api_version:e.api_version,payment_session_url:e.start_payment_session_url,refund_session_url:e.start_refund_session_url,capture_session_url:e.start_capture_session_url,void_session_url:e.start_void_session_url,confirmation_callback_url:e.confirmation_callback_url,update_payment_session_url:e.update_payment_session_url,start_verification_session_url:e.start_verification_session_url,merchant_label:e.merchant_label,supports_oversell_protection:e.supports_oversell_protection,supports_3ds:e.supports_3ds,supports_installments:e.supports_installments,supports_deferred_payments:e.supports_deferred_payments,supported_countries:e.supported_countries,supported_payment_methods:e.supported_payment_methods,supported_buyer_contexts:e.supported_buyer_contexts,test_mode_available:e.test_mode_available,multiple_capture:e.multiple_capture,buyer_label:e.default_buyer_label,buyer_label_translations:e.buyer_label_to_locale,checkout_payment_method_fields:e.checkout_payment_method_fields,modal_payment_method_fields:e.modal_payment_method_fields,ui_extension_handle:n}}async function Ea(e){return{api_version:e.api_version,start_payment_session_url:e.payment_session_url,start_refund_session_url:e.refund_session_url,start_capture_session_url:e.capture_session_url,start_void_session_url:e.void_session_url,confirmation_callback_url:e.confirmation_callback_url,update_payment_session_url:e.update_payment_session_url,start_verification_session_url:e.start_verification_session_url,merchant_label:e.merchant_label,supports_oversell_protection:e.supports_oversell_protection,supports_3ds:e.supports_3ds,supports_installments:e.supports_installments,supports_deferred_payments:e.supports_deferred_payments,supported_countries:e.supported_countries,supported_payment_methods:e.supported_payment_methods,supported_buyer_contexts:e.supported_buyer_contexts,test_mode_available:e.test_mode_available,multiple_capture:e.multiple_capture,default_buyer_label:e.buyer_label,buyer_label_to_locale:e.buyer_label_translations,checkout_payment_method_fields:e.checkout_payment_method_fields,modal_payment_method_fields:e.modal_payment_method_fields,ui_extension_handle:e.ui_extension_handle}}u();var mi="payments.custom-credit-card.render",Sa=7,Pa=G.merge(be).merge(Ce).merge(se).required({refund_session_url:!0,capture_session_url:!0,void_session_url:!0}).extend({targeting:p.array(p.object({target:p.literal(mi)})).length(1),api_version:p.string(),multiple_capture:p.boolean(),checkout_hosted_fields:p.array(p.string()).optional(),ui_extension_handle:p.string().optional(),encryption_certificate_fingerprint:p.string(),checkout_payment_method_fields:p.array(p.object({type:p.union([p.literal("string"),p.literal("number"),p.literal("boolean")]),required:p.boolean(),key:p.string()})).max(Sa,`The extension can't have more than ${Sa} checkout_payment_method_fields`).optional()});function yS(e,t){let n=we(e,t);return{api_version:e.api_version,payment_session_url:e.start_payment_session_url,refund_session_url:e.start_refund_session_url,capture_session_url:e.start_capture_session_url,void_session_url:e.start_void_session_url,confirmation_callback_url:e.confirmation_callback_url,merchant_label:e.merchant_label,supports_3ds:e.supports_3ds,supported_countries:e.supported_countries,supported_payment_methods:e.supported_payment_methods,supported_buyer_contexts:e.supported_buyer_contexts,buyer_label:e.default_buyer_label,buyer_label_translations:e.buyer_label_to_locale,encryption_certificate_fingerprint:e.encryption_certificate.fingerprint,test_mode_available:e.test_mode_available,multiple_capture:e.multiple_capture,checkout_payment_method_fields:e.checkout_payment_method_fields,checkout_hosted_fields:e.checkout_hosted_fields,ui_extension_handle:n}}async function va(e){return{api_version:e.api_version,start_payment_session_url:e.payment_session_url,start_refund_session_url:e.refund_session_url,start_capture_session_url:e.capture_session_url,start_void_session_url:e.void_session_url,confirmation_callback_url:e.confirmation_callback_url,merchant_label:e.merchant_label,supports_3ds:e.supports_3ds,supported_countries:e.supported_countries,supported_buyer_contexts:e.supported_buyer_contexts,default_buyer_label:e.buyer_label,buyer_label_to_locale:e.buyer_label_translations,encryption_certificate_fingerprint:e.encryption_certificate_fingerprint,supported_payment_methods:e.supported_payment_methods,test_mode_available:e.test_mode_available,multiple_capture:e.multiple_capture,checkout_payment_method_fields:e.checkout_payment_method_fields,checkout_hosted_fields:e.checkout_hosted_fields,ui_extension_handle:e.ui_extension_handle}}u();var gi="payments.credit-card.render",Aa=7,Ia=G.merge(ze).merge(Ce).merge(sn).merge(se).required({refund_session_url:!0,capture_session_url:!0,void_session_url:!0}).extend({targeting:p.array(p.object({target:p.literal(gi)})).length(1),verification_session_url:p.string().url().optional(),ui_extension_handle:p.string().optional(),supports_moto:p.boolean({required_error:"supports_moto is required",invalid_type_error:"Value must be Boolean"}),encryption_certificate_fingerprint:p.string(),checkout_payment_method_fields:p.array(p.object({type:p.union([p.literal("string"),p.literal("number"),p.literal("boolean")]),required:p.boolean(),key:p.string()})).max(Aa,`The extension can't have more than ${Aa} checkout_payment_method_fields`).optional()}).refine(e=>!e.supports_3ds||e.confirmation_callback_url,{message:"Property required when supports_3ds is true",path:["confirmation_callback_url"]}).refine(e=>e.supports_installments===e.supports_deferred_payments,{message:"supports_installments and supports_deferred_payments must be the same"});function ES(e,t){let n=we(e,t);return{api_version:e.api_version,payment_session_url:e.start_payment_session_url,refund_session_url:e.start_refund_session_url,capture_session_url:e.start_capture_session_url,void_session_url:e.start_void_session_url,confirmation_callback_url:e.confirmation_callback_url,multiple_capture:e.multiple_capture,merchant_label:e.merchant_label,supported_countries:e.supported_countries,supported_payment_methods:e.supported_payment_methods,supported_buyer_contexts:e.supported_buyer_contexts,test_mode_available:e.test_mode_available,supports_3ds:e.supports_3ds,supports_moto:e.supports_moto,supports_deferred_payments:e.supports_deferred_payments,supports_installments:e.supports_installments,verification_session_url:e.start_verification_session_url,encryption_certificate_fingerprint:e.encryption_certificate.fingerprint,checkout_payment_method_fields:e.checkout_payment_method_fields,ui_extension_handle:n}}async function Ta(e){return{api_version:e.api_version,start_payment_session_url:e.payment_session_url,start_refund_session_url:e.refund_session_url,start_capture_session_url:e.capture_session_url,start_void_session_url:e.void_session_url,confirmation_callback_url:e.confirmation_callback_url,multiple_capture:e.multiple_capture,merchant_label:e.merchant_label,supported_countries:e.supported_countries,supported_payment_methods:e.supported_payment_methods,supported_buyer_contexts:e.supported_buyer_contexts,test_mode_available:e.test_mode_available,supports_3ds:e.supports_3ds,supports_moto:e.supports_moto,supports_deferred_payments:e.supports_deferred_payments,encryption_certificate_fingerprint:e.encryption_certificate_fingerprint,supports_installments:e.supports_installments,start_verification_session_url:e.verification_session_url,checkout_payment_method_fields:e.checkout_payment_method_fields,ui_extension_handle:e.ui_extension_handle}}u();var yi="payments.card-present.render",ka=G.required({refund_session_url:!0,capture_session_url:!0,void_session_url:!0}).extend({targeting:p.array(p.object({target:p.literal(yi)})).length(1),sync_terminal_transaction_result_url:p.string().url().optional()});function TS(e){return{api_version:e.api_version,payment_session_url:e.start_payment_session_url,refund_session_url:e.start_refund_session_url,capture_session_url:e.start_capture_session_url,void_session_url:e.start_void_session_url,sync_terminal_transaction_result_url:e.sync_terminal_transaction_result_url,merchant_label:e.merchant_label,supported_countries:e.supported_countries,supported_payment_methods:e.supported_payment_methods,test_mode_available:e.test_mode_available}}async function Fa(e){return{api_version:e.api_version,start_payment_session_url:e.payment_session_url,start_refund_session_url:e.refund_session_url,start_capture_session_url:e.capture_session_url,start_void_session_url:e.void_session_url,sync_terminal_transaction_result_url:e.sync_terminal_transaction_result_url,merchant_label:e.merchant_label,supported_countries:e.supported_countries,supported_payment_methods:e.supported_payment_methods,test_mode_available:e.test_mode_available}}var Iu=p.union([ha,xa,wa,Pa,Ia,ka]),Tu=k({identifier:"payments_extension",schema:Iu,appModuleFeatures:e=>[],deployConfig:async(e,t)=>{switch(e.targeting[0]?.target){case ui:return _a(e);case di:return ba(e);case gi:return Ta(e);case fi:return Ea(e);case mi:return va(e);case yi:return Fa(e);default:return{}}}}),Ma=Tu;u();var hi="@shopify/retail-ui-extensions",ku=R.extend({name:p.string()}),Fu=k({identifier:"pos_ui_extension",dependency:hi,schema:ku,appModuleFeatures:e=>["ui_preview","esbuild","single_js_entry_path"],getOutputRelativePath:e=>`dist/${e.handle}.js`,clientSteps:[{lifecycle:"deploy",steps:[{id:"bundle-ui",name:"Bundle UI Extension",type:"bundle_ui",config:{}}]}],deployConfig:async(e,t)=>{let n=await ct(hi,t);if(n==="not_found")throw new Q(`Dependency ${hi} not found`);return{name:e.name,description:e.description,renderer_version:n?.version}}}),Da=Fu;u();var _i="@shopify/admin-ui-extensions",Mu=k({identifier:"product_subscription",additionalIdentifiers:["subscription_management"],dependency:_i,graphQLType:"subscription_management",schema:R,appModuleFeatures:e=>["ui_preview","esbuild","single_js_entry_path"],getOutputRelativePath:e=>`dist/${e.handle}.js`,clientSteps:[{lifecycle:"deploy",steps:[{id:"bundle-ui",name:"Bundle UI Extension",type:"bundle_ui",config:{}}]}],deployConfig:async(e,t)=>{let n=await ct(_i,t);if(n==="not_found")throw new Q(`Dependency ${_i} not found`);return{renderer_version:n?.version}}}),Ra=Mu;u();var Du=p.object({key:p.string()}),Ru=R.extend({production_api_base_url:p.string(),benchmark_api_base_url:p.string().optional(),calculate_taxes_api_endpoint:p.string(),input:p.object({metafield_identifiers:p.object({namespace:p.string(),key:p.string()}).optional()}).optional(),metafields:p.array(ye).optional(),cart_line_properties:p.array(Du).optional()}),Ou=k({identifier:"tax_calculation",schema:Ru,appModuleFeatures:e=>[],getOutputRelativePath:e=>y("dist",`${e.handle}.js`),clientSteps:[{lifecycle:"deploy",steps:[{id:"create-tax-stub",name:"Create Tax Stub",type:"create_tax_stub",config:{}}]}],deployConfig:async(e,t)=>({production_api_base_url:e.production_api_base_url,benchmark_api_base_url:e.benchmark_api_base_url,calculate_taxes_api_endpoint:e.calculate_taxes_api_endpoint,metafields:e.metafields,cart_line_properties:e.cart_line_properties,api_version:e.api_version,metafield_identifiers:e.input?.metafield_identifiers})}),Oa=Ou;u();var Uu=k({identifier:"theme",schema:R,partnersWebIdentifier:"theme_app_extension",graphQLType:"theme_app_extension",clientSteps:[{lifecycle:"deploy",steps:[{id:"build-theme",name:"Build Theme Extension",type:"build_theme",config:{}},{id:"bundle-theme",name:"Bundle Theme Extension",type:"bundle_theme",config:{}}]}],appModuleFeatures:e=>["theme"],deployConfig:async()=>({theme_extension:{files:{}}}),preDeployValidation:async e=>Lu(e)}),ja=Uu,xi=1024,Na=xi*1024,Wa=10,Bu=Wa*Na,Va=500,$u=Va*xi,Ua=[".jpg",".jpeg",".json",".js",".css",".png",".svg",".wasm"],Ba=[".json"],za={assets:{validator:new RegExp(`${Ua.join("|")}$`),failureMessage:e=>`Only these filetypes are supported in assets: ${Ua.join(", ")}`},blocks:{validator:/.liquid$/,failureMessage:e=>"Only .liquid files are allowed in blocks."},locales:{validator:new RegExp(`${Ba.join("|")}$`),failureMessage:e=>`Only these filetypes are supported in locales: ${Ba.join(", ")}`},snippets:{validator:/.liquid$/,failureMessage:e=>"Only .liquid files are allowed in snippets."}},$a=Object.keys(za);async function Lu(e){let t=await Le(e),n=[],i=[];await Promise.all(t.map(async o=>{let r=I(e.directory,o),s=P(r);Wu(r,s);let a=await Et(o);i.push(a),["blocks","snippets"].includes(s)&&n.push(a)})),ju(La(i)),Nu(La(n))}function ju(e){if(e>Bu){let t=`${(e/Na).toFixed(2)} MB`;throw new b(`Your theme app extension exceeds the file size limit (${Wa} MB). It's currently ${t}.`,"Reduce your total file size and try again.")}}function Nu(e){if(e>$u){let t=`${(e/xi).toFixed(2)} kB`;throw new b(`Your theme app extension exceeds the total liquid file size limit (${Va} kB). It's currently ${t}.`,"Reduce your total file size and try again.")}}function Wu(e,t){if(!$a.includes(t))throw new b(A`Your theme app extension includes files in an unsupported directory, ${v.path(t)}`,`Make sure all theme app extension files are in the supported directories: ${$a.join(", ")}`);let n=za[t];if(!e.match(n.validator))throw new b(`Invalid filename in your theme app extension: ${e}
89
+ ${n.failureMessage(e)}`)}function La(e){return e.reduce((t,n)=>t+n,0)}u();u();var Ka=qe(Ap(),1);import{createRequire as Vu}from"module";async function bi(){let e=await import("./typescript-K5CWIA4V.js");return e.default??e}var Ja=Vu(import.meta.url),qa="@shopify/ui-extensions";function zu(e){let t=e.toLowerCase().replace(/(::|\.).+$/,"");switch(t){case"purchase":return"checkout";case"pos":return"point-of-sale";default:return t}}function Ci(e){let t=e[0];return t?`${qa}/${zu(t)}`:qa}function yt(e){let[t,n]=e.split("-");return!t||!n?null:{year:parseInt(t,10),month:parseInt(n,10)}}async function Ju(e){let t=await bi(),n=t.findConfigFile(e,t.sys.fileExists.bind(t.sys),"tsconfig.json");if(!n)return{compilerOptions:{},configPath:void 0};let i=t.readConfigFile(n,t.sys.readFile.bind(t.sys));return i.error?{compilerOptions:{},configPath:n}:{compilerOptions:t.parseJsonConfigFileContent(i.config,t.sys,P(n)).options,configPath:n}}async function qu(e,t){if(!e.startsWith("./")&&!e.startsWith("../"))return null;let n=pe(t,e),i=["",".js",".jsx",".ts",".tsx"];for(let o of i){let r=n+o;if(await w(r)&&!r.includes("node_modules"))return r}for(let o of[".js",".jsx",".ts",".tsx"]){let r=y(n,`index${o}`);if(await w(r)&&!r.includes("node_modules"))return r}return null}async function Ku(e){try{let t=await bi(),n=ce(e).toString(),i=[],{compilerOptions:o}=await Ju(e),r=t.ScriptKind.JSX;e.endsWith(".ts")?r=t.ScriptKind.TS:e.endsWith(".tsx")&&(r=t.ScriptKind.TSX);let s=t.createSourceFile(e,n,t.ScriptTarget.Latest,!0,r),a=new Set,c=[],d=l=>{if(t.isImportDeclaration(l)&&l.moduleSpecifier&&t.isStringLiteral(l.moduleSpecifier))c.push(l.moduleSpecifier.text);else if(t.isCallExpression(l)&&l.expression.kind===t.SyntaxKind.ImportKeyword){let f=l.arguments[0];f&&t.isStringLiteral(f)&&c.push(f.text)}else t.isExportDeclaration(l)&&l.moduleSpecifier&&t.isStringLiteral(l.moduleSpecifier)&&c.push(l.moduleSpecifier.text);t.forEachChild(l,d)};d(s);for(let l of c){if(!l||a.has(l))continue;a.add(l);let f=t.resolveModuleName(l,e,o,t.sys);if(f.resolvedModule?.resolvedFileName){let _=f.resolvedModule.resolvedFileName;_.includes("node_modules")||i.push(_)}else{let _=await qu(l,P(e));_&&i.push(_)}}return i}catch(t){if(t instanceof b)throw t;return[]}}async function an(e,t=new Set){if(t.has(e))return[];t.add(e);let n=await Ku(e),i=[...n];for(let o of n){let r=await an(o,t);i.push(...r)}return[...new Set(i)]}async function Hu(e){let t;try{t=ce(e).toString()}catch{return!1}let n=await bi(),i=n.createSourceFile(e,t,n.ScriptTarget.Latest,!0,n.ScriptKind.TS),o=!1,r=s=>{if(!o){if(n.isExportDeclaration(s)&&s.exportClause&&n.isNamedExports(s.exportClause)){for(let a of s.exportClause.elements)if(a.name.text==="ShopifyGlobal"){o=!0;return}}n.forEachChild(s,r)}};return r(i),o}async function Gu(e,t){let n=async i=>{let o=`import('@shopify/ui-extensions/${i}').Api`,r=t.get(i);return r&&await Hu(r)?`${o} & import('@shopify/ui-extensions/${i}').ShopifyGlobal`:o};return e.length===1?n(e[0]??""):e.length>1?`(${(await Promise.all(e.map(n))).join(" | ")})`:null}async function Yu(e,t,{includesTools:n,includesIntents:i},o){let r=await Gu(e,t);if(!r)return null;if(!n&&!i)return r;let s=r;return i&&(s=`import('${o}').WithGeneratedIntents<${s}, ShopifyGeneratedIntentVariants>`),n&&(s=`import('${o}').WithGeneratedTools<${s}, ShopifyTools>`),s}async function Ha({fullPath:e,typeFilePath:t,targets:n,apiVersion:i,toolsTypeDefinition:o,intentsTypeDefinition:r}){try{let s=new Map,a=!!o,c=!!r;for(let g of n)try{let m=Ja.resolve(`@shopify/ui-extensions/${g}`,{paths:[e,t]});s.set(g,m)}catch{let{year:h,month:x}=yt(i)??{year:2025,month:10};throw new b(`Type reference for ${g} could not be found. You might be using the wrong @shopify/ui-extensions version.`,`Fix the error by ensuring you have the correct version of @shopify/ui-extensions, for example ~${h}.${x}.0, in your dependencies.`)}let d=Ci(n);if(a||c)try{Ja.resolve(d,{paths:[e,t]})}catch{let{year:m,month:h}=yt(i)??{year:2025,month:10};throw new b(`Type reference for ${d} could not be found. You might be using the wrong @shopify/ui-extensions version.`,`Fix the error by ensuring you have the correct version of @shopify/ui-extensions, for example ~${m}.${h}.0, in your dependencies.`)}let l=xt(e,P(t)),f=await Yu(n,s,{includesTools:a,includesIntents:c},d);return f?["//@ts-ignore",`declare module './${l}' {`,...o?[o]:[],...r?[r]:[],` const shopify: ${f};`," const globalThis: { shopify: typeof shopify };","}",""].join(`
90
+ `):null}catch(s){if(s instanceof b)throw s;let{year:a,month:c}=yt(i)??{year:2025,month:10};throw new b("Type reference could not be found. You might be using the wrong @shopify/ui-extensions version.",`Fix the error by ensuring you have the correct version of @shopify/ui-extensions, for example ~${a}.${c}.0, in your dependencies.`)}}async function Ga(e,t){let n=P(e),i=await te("tsconfig.json",{cwd:n,type:"file"});if(i){let o=pe(i),r=pe(t);if(o.startsWith(r))return P(i)}}var Zu=p.object({name:p.string(),description:p.string(),inputSchema:p.object({}).passthrough(),outputSchema:p.object({}).passthrough().optional()}),Ya=p.array(Zu),Za=p.object({value:p.object({}).passthrough().optional(),inputSchema:p.object({}).passthrough(),outputSchema:p.object({}).passthrough().optional()});function Qu(e){return Me(`${e.action} ${e.type}`.replace(/[^a-zA-Z0-9]+/g," "))}async function Qa(e,{generatedTypesHelperImportPath:t}){if(e.length===0)return"";let n=new Set,i=e.map(async s=>{let a=`${s.action}:${s.type}`;if(n.has(a))throw new b(`Intent "${a}" is defined multiple times. Intents must be unique within a target.`);n.add(a);let c=Qu(s),d=`${c}IntentInput`,l=`${c}IntentValue`,f=`${c}IntentOutput`,_=`${c}IntentRequest`,g=await ht(d,s.inputSchema),m=await ht(l,s.valueSchema),h=await ht(f,s.outputSchema),x=`interface ${_} {
91
+ action: ${JSON.stringify(s.action)};
92
+ type: ${JSON.stringify(s.type)};
93
+ data: ${d};
94
+ value?: ${l};
95
+ }`;return{inputType:g,valueType:m,outputType:h,requestType:x,requestTypeName:_,outputTypeName:f}}),o=await Promise.all(i),r=o.map(({requestTypeName:s,outputTypeName:a})=>` | import('${t}').ShopifyGeneratedIntentVariant<${s}, ${a}>`).join(`
96
+ `);return`${o.map(({inputType:s,valueType:a,outputType:c,requestType:d})=>`${s}
97
+ ${a}
98
+ ${c}
99
+ ${d}`).join(`
100
+
101
+ `)}
102
+
103
+ type ShopifyGeneratedIntentVariants =
104
+ ${r}
105
+ `}async function Xa(e){if(e.length===0)return"";let t=new Set,n=e.map(async r=>{if(t.has(r.name))throw new b(`Tool name "${r.name}" is defined multiple times. Tool names must be unique within a tools file.`);t.add(r.name);let s=Me(`${r.name}Input`),a=await ht(s,r.inputSchema),c=Me(`${r.name}Output`),d=await ht(c,r.outputSchema);return{name:r.name,description:r.description,inputType:a,outputType:d,inputTypeName:s,outputTypeName:c}}),i=await Promise.all(n),o=i.map(({name:r,description:s,inputTypeName:a,outputTypeName:c})=>` /**
106
+ ${s.replace(/\*\//g,"*\\/").split(`
107
+ `).map(l=>` * ${l}`).join(`
108
+ `)}
109
+ */
110
+ register(name: '${r}', handler: (input: ${a}) => ${c} | Promise<${c}>): () => void;`).join(`
111
+ `);return`${i.map(({inputType:r,outputType:s})=>`${r}
112
+ ${s}`).join(`
113
+ `)}
114
+ interface ShopifyTools {
115
+ ${o}
116
+ }
117
+ `}function Xu(e,t){return e.replace(/^(interface|type|enum)\s+[A-Za-z0-9_]+/,`$1 ${t}`)}async function ht(e,t){if(!t)return`type ${e} = unknown`;let n=await(0,Ka.compile)(t,e,{bannerComment:""}),i=n.startsWith("export ")?n.slice(7):n;return Xu(i,e)}u();u();u();var ep=Bi`
118
+ query {
119
+ products(first: 1, query: "published_status:published") {
120
+ edges {
121
+ node {
122
+ id
123
+ variants(first: 1) {
124
+ edges {
125
+ node {
126
+ id
127
+ }
128
+ }
129
+ }
130
+ }
131
+ }
132
+ }
133
+ }
134
+ `;async function tp(e){let t=await zi(e),n=await co(ep,t);if(n.products.edges.length===0){let s=`https://${Ni(e)}/admin/products/new`,a=A`${v.link("Add a product",s,`You can add a new product here: ${s}`)}`.value;throw new b("Could not find a product variant",`Your store needs to have at least one product to test a 'checkout_ui' extension.
135
+
136
+ ${a}`)}return n.products.edges[0].node.variants.edges[0].node.id.split("/").pop()}async function VP(e,t,n){return e.filter(r=>r.shouldFetchCartUrl()).length>0?n||`/cart/${await tp(t)}:1`:void 0}function np(e){let t=e.toLowerCase().replace(/(::|\.).+$/,""),n=e.split(".")[1];switch(t){case"purchase":return n==="post"?"post_purchase":"checkout";case"customer-account":return"customer-accounts";case"pos":return"point_of_sale";default:return t}}u();Sp();async function ip(e,t){return uo.format(e,t)}var ed="@shopify/checkout-ui-extensions",td=e=>e.extension_points!==void 0||e.targeting!==void 0,rp="No extension targets defined, add a `targeting` field to your configuration",nd=R.extend({name:p.string(),type:p.literal("ui_extension"),extension_points:En.optional(),targeting:En.optional(),metafields:p.array(ye).optional()}).refine(e=>td(e),rp).transform(e=>{let t=(e.targeting??e.extension_points??[]).map(n=>{let i={assets:{main:{filepath:`${e.handle}.js`,module:n.module},...n.should_render?.module?{should_render:{filepath:`${e.handle}-conditions.js`,module:n.should_render.module}}:null}};return{target:n.target,module:n.module,metafields:n.metafields??e.metafields??[],default_placement_reference:n.default_placement,urls:n.urls??{},capabilities:n.capabilities,preloads:n.preloads??{},build_manifest:i,tools:n.tools,instructions:n.instructions,intents:n.intents,assets:n.assets}});return{...e,extension_points:t}}),id=k({identifier:"ui_extension",dependency:ed,schema:nd,getOutputRelativePath:e=>`${e.handle}.js`,clientSteps:[{lifecycle:"deploy",steps:[{id:"bundle-ui",name:"Bundle UI Extension",type:"bundle_ui",config:{generatesAssetsManifest:!0,bundleFolder:"dist/"}},{id:"include-ui-extension-assets",name:"Include UI Extension Assets",type:"include_assets",config:{generatesAssetsManifest:!0,inclusions:[{type:"configKey",anchor:"extension_points[]",groupBy:"target",key:"extension_points[].assets"},{type:"configKey",anchor:"extension_points[]",groupBy:"target",key:"extension_points[].tools"},{type:"configKey",anchor:"extension_points[]",groupBy:"target",key:"extension_points[].instructions"},{type:"configKey",anchor:"extension_points[]",groupBy:"target",key:"extension_points[].intents[].schema"}]}}]}],appModuleFeatures:e=>{let t=["ui_preview","esbuild","generates_source_maps"];return e?.extension_points?.find(i=>np(i.target)==="checkout")!==void 0?[...t,"cart_url"]:t},validate:async(e,t,n)=>ad(n,e.extension_points,t),deployConfig:async(e,t)=>{let n=e.extension_points?.map(od)??[];return{api_version:e.api_version,extension_points:n,capabilities:e.capabilities,supported_features:e.supported_features,name:e.name,description:e.description,settings:e.settings,localization:await ie(t,e.type)}},getBundleExtensionStdinContent:e=>{let t=op(e),n=e.extension_points||[],i=n.map(({target:s,module:a},c)=>t?`import Target_${c} from '${a}';shopify.extend('${s}', (...args) => Target_${c}(...args));`:`import '${a}';`).join(`
137
+ `),o={};n.forEach(s=>{let a=pd(s,t);a&&(o.should_render=a)});let r=Object.values(o);return{main:i,...r.length?{assets:r}:{}}},hasExtensionPointTarget:(e,t)=>e.extension_points?.find(n=>n.target===t)!==void 0,contributeToSharedTypeFile:async(e,t)=>{if(!op(e.configuration))return;let{configuration:n}=e,i=new Map,o=new Map,r=new Map;for await(let s of n.extension_points){let a=y(e.directory,s.module);if(!await w(a))continue;let d=i.get(a)??[];if(d.push(s.target),i.set(a,d),s.tools&&o.set(a,s.tools),s.intents?.length){let l=r.get(a)??[];l.push(...s.intents),r.set(a,l)}if(s.build_manifest.assets.should_render?.module){let l=y(e.directory,s.build_manifest.assets.should_render.module);if(await w(l)){let _=i.get(l)??[];_.push(wi(s.target)),i.set(l,_)}}}for await(let s of n.extension_points){let a=y(e.directory,s.module);if(!await w(a))continue;let d=await an(a);for(let l of d){let f=i.get(l)??[];f.push(s.target),i.set(l,f)}if(s.build_manifest.assets.should_render?.module){let l=y(e.directory,s.build_manifest.assets.should_render.module);if(await w(l)){let _=await an(l);for(let g of _){let m=i.get(g)??[];m.push(wi(s.target)),i.set(g,m)}}}}for await(let[s,a]of i.entries()){let c=await Ga(s,e.directory);if(!c)continue;let d=y(c,"shopify.d.ts"),l=[...new Set(a)],f=Ci(l);try{let _=o.get(s),g="";if(_)try{let C=await sp(e.directory,_,Ya);C.status==="ok"?g=await Xa(C.data):C.status==="invalid"&&ue(`Invalid tools definition in "${_}": ${C.issues}`)}catch(C){ue(`Failed to create tools type definition for tools file "${_}": ${C instanceof Error?C.message:"Unknown error"}`)}let m=r.get(s),h="";if(m?.length){let C=await rd(e.directory,m);if(C.length>0)try{h=await Qa(C,{generatedTypesHelperImportPath:f})}catch(E){if(E instanceof b)throw E;ue(`Failed to create intent type definition for intent schema files "${m.map(M=>M.schema).join(", ")}": ${E instanceof Error?E.message:"Unknown error"}`)}}let x=await Ha({fullPath:s,typeFilePath:d,targets:l,apiVersion:n.api_version,toolsTypeDefinition:g,intentsTypeDefinition:h});if(x){let C=t.get(d)??new Set;x=await ip(x,{parser:"typescript",singleQuote:!0}),C.add(x),t.set(d,C)}}catch(_){if(n.extension_points.some(m=>y(e.directory,m.module)===s||m.build_manifest.assets.should_render?.module&&y(e.directory,m.build_manifest.assets.should_render.module)===s))throw _}}}});function od(e){return{...e,build_manifest:{...e.build_manifest,assets:Object.fromEntries(Object.entries(e.build_manifest.assets).map(([t,n])=>[t,{...n,filepath:y("dist",n.filepath)}]))}}}async function sp(e,t,n){let i=y(e,t);if(!await w(i))return{status:"missing"};let r=await F(i),s=n.safeParse(JSON.parse(r));return s.success?{status:"ok",data:s.data}:{status:"invalid",issues:s.error.issues.map(a=>a.message).join(", ")}}async function rd(e,t){let n=await Promise.all(t.map(async o=>{try{let r=await sp(e,o.schema,Za);return r.status==="missing"?(ue(`Intent schema file "${o.schema}" was not found. Skipping intent type generation.`),null):r.status==="invalid"?(ue(`Invalid intent schema in "${o.schema}": ${r.issues}`),null):{action:o.action,type:o.type,inputSchema:r.data.inputSchema,valueSchema:r.data.value,outputSchema:r.data.outputSchema}}catch(r){return ue(`Failed to create intent type definition for intent schema file "${o.schema}": ${r instanceof Error?r.message:"Unknown error"}`),null}})),i=[];for(let o of n)o&&i.push(o);return i}async function sd(e,t,n,i){if(!t)return;let o=y(e,t);return await w(o)?void 0:A`Couldn't find ${v.path(o)}
138
+ Please check the ${i} path for ${n}`.value}async function ad(e,t,n){let i=[],o=[],r=[];if(!t||t.length===0)return ve(rp);for await(let s of t){let{module:a,target:c}=s,d=await sd(e,a,c,"module");d&&i.push(d),o.includes(c)?r.push(c):o.push(c)}return r.length&&i.push(`Duplicate targets found: ${r.join(", ")}
139
+ Extension point targets must be unique`),i.length?(i.push(`Please check the configuration in ${n}`),ve(i.join(`
140
+
141
+ `))):le({})}function op(e){let t=e.api_version;if(!t)return!1;let{year:n,month:i}=yt(t)??{year:0,month:0};return n>2025||n===2025&&i>=10}function wi(e){return e.replace(/\.render$/,".should-render")}function pd(e,t){let n=e.build_manifest.assets.should_render;if(n)return{identifier:"should_render",outputFileName:n.filepath,content:t?`import shouldRender from '${n.module}';shopify.extend('${wi(e.target)}', (...args) => shouldRender(...args));`:`import '${n.module}'`}}var ap=id;u();var pp=1024,cp=128,cd=cp*pp,ld="@shopify/web-pixels-extension",ud=R.extend({runtime_context:p.string(),version:p.string().optional(),configuration:p.any(),customer_privacy:p.object({analytics:p.boolean(),preferences:p.boolean(),marketing:p.boolean(),sale_of_data:p.enum(["enabled","disabled","ldu"])}).optional(),settings:p.any()}),dd=k({identifier:"web_pixel_extension",dependency:ld,partnersWebIdentifier:"web_pixel",schema:ud,appModuleFeatures:e=>["esbuild","single_js_entry_path"],getOutputRelativePath:e=>`dist/${e.handle}.js`,clientSteps:[{lifecycle:"deploy",steps:[{id:"bundle-ui",name:"Bundle UI Extension",type:"bundle_ui",config:{}}]}],deployConfig:async(e,t)=>({runtime_context:e.runtime_context,customer_privacy:e.customer_privacy,runtime_configuration_definition:e.settings}),buildValidation:async(e,t)=>{let n=await Et(t);if(n>cd){let i=`${(n/pp).toFixed(2)} kB`;throw new b(`Your web pixel extension exceeds the total file size limit (${cp} kB). It's currently ${i}.`,"Reduce your total file size and try again.")}},preDeployValidation:async e=>{if(e.configuration.configuration)throw new b("The property configuration is deprecated and no longer supported.","It has been replaced by settings.");return Promise.resolve()}}),lp=dd;u();var fd=p.object({handle:p.string()}),md=R.extend({name:p.string(),include:p.array(fd).optional(),includes:p.array(p.string()).optional(),type:p.literal("editor_extension_collection")}).transform(e=>{let t=e.includes?.map(i=>({handle:i}))??[],n=e.include??[];return{...e,inCollection:[...t,...n]}}),gd=k({identifier:"editor_extension_collection",schema:md,appModuleFeatures:e=>[],deployConfig:async(e,t)=>({name:e.name,handle:e.handle,in_collection:e.inCollection,localization:await ie(t,e.name)})}),up=gd;u();var dp="specifications",yd=["json","toml","yaml","yml","svg"],hd=he({identifier:"channel_config",uidStrategy:"single",experience:"extension",clientSteps:[{lifecycle:"deploy",steps:[{id:"copy-files",name:"Copy Files",type:"include_assets",config:{inclusions:[{type:"pattern",baseDir:dp,destination:dp,include:yd.map(e=>`**/*.${e}`)}]}}]}],appModuleFeatures:()=>[]}),fp=hd;u();var mp="icons",_d=["svg"],xd=he({identifier:"order_attribution_config",uidStrategy:"single",experience:"extension",clientSteps:[{lifecycle:"deploy",steps:[{id:"copy-files",name:"Copy Files",type:"include_assets",config:{inclusions:[{type:"pattern",baseDir:mp,destination:mp,include:_d.map(e=>`**/*.${e}`)}]}}]}],appModuleFeatures:()=>[]}),gp=xd;u();var bd=he({identifier:"admin_link",uidStrategy:"uuid",experience:"extension",clientSteps:[{lifecycle:"deploy",steps:[{id:"include-admin-link-assets",name:"Include Admin Link Assets",type:"include_assets",config:{generatesAssetsManifest:!0,inclusions:[{type:"configKey",anchor:"targeting[]",groupBy:"target",key:"targeting[].tools"},{type:"configKey",anchor:"targeting[]",groupBy:"target",key:"targeting[].instructions"},{type:"configKey",anchor:"targeting[]",groupBy:"target",key:"targeting[].intents[].schema"}]}}]}],appModuleFeatures:()=>["localization","ui_preview"]}),yp=bd;var hp=[Oo,Bt,Bo,Ne,oi,si,ni,ii,Do];async function Je(){let e=(t,n)=>hp.indexOf(t.identifier)-hp.indexOf(n.identifier);return Cd().sort(e)}function Cd(){let e=[Io,Ro,Hs,Uo,Gs,Xs,$o,Jr,Qs],t=[ea,ta,da,ma,aa,ga,Ma,Da,Ra,Oa,ja,ap,lp,up,fp,gp,yp];return[...e,...t]}u();var wd={type:{type:"string"},handle:{type:"string"},uid:{type:"string"},path:{type:"string"},extensions:{}};async function _p(e,t,n="strip"){let i=t?.jsonSchema;if(i===void 0||Ze(JSON.parse(i)))return e.parseConfigurationObject;let o=await Rt(i);o.properties={...wd,...o.properties};let r=e.identifier;return a=>{let c=e.parseConfigurationObject(a),l=(c.state==="ok"?c.data:void 0)??a,f=wo(l,o,n,r),_=c.errors??[];f.state==="error"&&(_=_.concat(f.errors));let g=new Set;return _=_.filter(m=>{let h=JSON.stringify({path:m.path,message:m.message});return g.has(h)?!1:(g.add(h),!0)}),c.state!=="ok"||_.length>0?{state:"error",data:void 0,errors:_}:{state:"ok",data:f.data,errors:void 0}}}async function pn({developerPlatformClient:e,app:t}){let i=(await e.specifications(t)).filter(s=>["extension","configuration"].includes(s.experience)).map(s=>(s.identifier==="theme_app_extension"&&(s.identifier="theme"),s.identifier==="subscription_management"&&(s.identifier="product_subscription"),s.identifier==="checkout_post_purchase"&&(s.surface="post_purchase"),s.identifier==="webhook_subscription"&&(s.experience="configuration",s.uidStrategy="dynamic"),s)),o=await Je();return[...await Ed(o,i)]}async function Ed(e,t){let n=t.map(async s=>{let a=e.find(l=>l.identifier===s.identifier);if(!a&&s.validationSchema?.jsonSchema&&(a=await Pd(s,s.validationSchema)),!a)return;let c=Sd(a,s),d=await _p(c,s.validationSchema,c.experience==="extension"?"fail":"strip");return{...c,parseConfigurationObject:d}}),i=Pe(await Promise.all(n)),o=e.filter(s=>!i.find(a=>a.identifier===s.identifier));o.length>0&&S(`The following extension specifications were defined locally but not found in the remote specifications: ${o.map(s=>s.identifier).sort().join(", ")}`);let r=t.filter(s=>!i.find(a=>a.identifier===s.identifier));return r.length>0&&S(`The following extension specifications were found in the remote specifications but not defined locally: ${r.map(s=>s.identifier).sort().join(", ")}`),i}function Sd(e,t){return{...e,loadedRemoteSpecs:!0,externalName:t.externalName,externalIdentifier:t.externalIdentifier,experience:t.experience,registrationLimit:t.registrationLimit,uidStrategy:t.uidStrategy,surface:t.surface??e.surface}}async function Pd(e,t){let i=(await Rt(t.jsonSchema)).properties?.localization!==void 0;return{...he({identifier:e.identifier,uidStrategy:e.uidStrategy,experience:e.experience,appModuleFeatures:()=>i?["localization"]:[]}),loadedRemoteSpecs:!0}}async function cn(e,t=!0){let{remoteApp:n,appDirectory:i,developerPlatformClient:o}=await vd(e),r=await pn({developerPlatformClient:o,app:n}),s=n.flags,a=await Id(e,r,s,n.apiKey),c=await Td(n,e,{appDirectory:a.appDirectory});await ti(n,o.organizationSource);let d=await kd({configFileName:c,remoteApp:n,developerPlatformClient:o,specifications:r,flags:s,appDirectory:i,localAppOptions:a});return t&&Md(c,d.name,a.packageManager),{remoteApp:n,configFileName:c,configuration:d}}async function vd(e){let{creationOptions:t,appDirectory:n}=await Ad(e),i=n??e.directory;if(e.apiKey){let s=await tn({apiKey:e.apiKey});if(!s){let a=Vs(e.apiKey);throw new b(a.message,a.tryMessage)}return e.isNewApp&&(s.newApp=!0),{remoteApp:s,appDirectory:i,developerPlatformClient:s.developerPlatformClient}}let o=await Js({...t,directory:i}),r=o.developerPlatformClient;return{remoteApp:o,appDirectory:i,developerPlatformClient:r}}async function Ad(e){let t={isLaunchable:!1,scopesArray:[],name:"",directory:e.directory,isEmbedded:!1};try{let n=await us({specifications:await Je(),directory:e.directory,userProvidedConfigName:e.configName,remoteFlags:void 0,skipPrompts:!0});return{creationOptions:n.creationDefaultOptions(),appDirectory:n.directory}}catch{return{creationOptions:t}}}async function Id(e,t,n,i){let o=await ds({directory:e.directory,configName:e.configName,specifications:t,remoteFlags:n,skipPrompts:!0});switch(o.state){case"loaded-app":{let{app:r,configuration:s}=o;return s.client_id===i||e.isNewApp?{state:"reusable-current-app",scopes:Rn(s),localAppIdMatchedRemote:!0,existingBuildOptions:s.build,existingConfig:{...s},appDirectory:r.directory,packageManager:o.packageManager}:{state:"unable-to-reuse-current-config",scopes:"",localAppIdMatchedRemote:!0,appDirectory:void 0,existingBuildOptions:void 0,existingConfig:void 0,packageManager:"npm"}}case"loaded-template":return{state:"reusable-current-app",scopes:o.scopes,localAppIdMatchedRemote:!0,existingBuildOptions:void 0,existingConfig:o.rawConfig,appDirectory:o.appDirectory,packageManager:o.packageManager};case"error":return{state:"unable-to-load-config",scopes:"",localAppIdMatchedRemote:!1,appDirectory:void 0,existingBuildOptions:void 0,existingConfig:void 0,packageManager:"npm"}}}async function Td(e,t,n){if(t.configName)return X(t.configName);let i=Zt();if(i?.selectedToml)return i.selectedToml;let o=await Gt(t.directory),r=o[e.apiKey];return r||(Ze(o)?"shopify.app.toml":Vr(n.appDirectory??t.directory,e.title))}async function kd(e){let{remoteApp:t,developerPlatformClient:n,specifications:i,flags:o,configFileName:r,appDirectory:s,localAppOptions:a}=e,c=y(s,r),d=await en(t,n,i,o);if(!d){let _=a.scopes;d=Dd(t,_)}let l=(_,g)=>g,f={...fe({...a.existingConfig??{}},{client_id:t.apiKey,...d},l),build:Fd({existingBuildOptions:a.existingBuildOptions,linkedAppAndClientIdFromFileAreInSync:a.localAppIdMatchedRemote,linkedAppWasNewlyCreated:!!t.newApp,defaultToUpdateUrlsOnDev:n.supportsDevSessions})};return delete f.scopes,await Ds(f,c),zn(f,{configFileName:r,directory:s}),f}function Fd(e){let{existingBuildOptions:t,linkedAppAndClientIdFromFileAreInSync:n,linkedAppWasNewlyCreated:i,defaultToUpdateUrlsOnDev:o}=e,r={...i?{include_config_on_deploy:!0}:{},...o&&i?{automatically_update_urls_on_dev:!0}:{},...n?t:{}};if(!Ze(r))return r}function Md(e,t,n){Xe({headline:`${e} is now linked to "${t}" on Shopify`,body:`Using ${e} as your default config.`,nextSteps:[[`Make updates to ${e} in your local project`],["To upload your config, run",{command:Mt(n,"shopify app deploy")}]],reference:[{link:{label:"App configuration",url:"https://shopify.dev/docs/apps/tools/cli/configuration"}}]})}function Dd(e,t){return{...Ld(e),...$d(e),...Ud(e),...Bd(t,e),...Od(e),...Rd(e)}}function Rd(e){let t={application_url:e.applicationUrl?.replace(/\/$/,"")??"",embedded:e.embedded??!0};return e.preferencesUrl?{...t,app_preferences:{url:e.preferencesUrl}}:{...t}}function Od(e){return e.appProxy?.url?{app_proxy:{url:e.appProxy.url,subpath:e.appProxy.subPath,prefix:e.appProxy.subPathPrefix}}:{}}function Ud(e){let t=e.gdprWebhooks?.customerDataRequestUrl??e.gdprWebhooks?.customerDeletionUrl??e.gdprWebhooks?.shopDeletionUrl,n={privacy_compliance:{customer_data_request_url:e.gdprWebhooks?.customerDataRequestUrl,customer_deletion_url:e.gdprWebhooks?.customerDeletionUrl,shop_deletion_url:e.gdprWebhooks?.shopDeletionUrl}};return{webhooks:{api_version:e.webhookApiVersion??"2023-07",...t?n:{}}}}function Bd(e,t){let n={};return t.requestedAccessScopes?n={scopes:t.requestedAccessScopes.join(",")}:e===""?n={use_legacy_install_flow:!0}:n={scopes:e,use_legacy_install_flow:!0},{auth:{redirect_urls:t.redirectUrlWhitelist??[]},access_scopes:n}}function $d(e){return{pos:{embedded:e.posEmbedded??!1}}}function Ld(e){return{name:e.title}}u();u();async function xp(e,t){if(t.supportsAtomicDeployments)for(let n of e)await jd(n)}async function jd(e){if(!e.isUUIDStrategyExtension||e.configuration.uid)return;let t=await U.read(e.configurationPath),n=W(t.content,"extensions");if(!("uid"in t.content)){if(n){let i=n.find(o=>o.handle===e.handle);if(i&&"uid"in i)return}if(n){let i=e.handle;await t.transformRaw(o=>{let r=new RegExp(`(\\n?(\\s*)handle\\s*=\\s*"${i}")`);return o.replace(r,`$1
142
+ $2uid = "${e.uid}"`)})}else await t.patch({uid:e.uid})}}function bp(e){let t=dt(e);return A`${v.errorText("Validation error")} in ${v.path(e.file)}:\n\n${t}`}async function mI({directory:e,clientId:t,forceRelink:n,userProvidedConfigName:i,unsafeTolerateErrors:o=!1}){let r,s,a;if(n){let x=await cn({directory:e,apiKey:t});a=x.remoteApp;let C=await ee(e,x.configFileName);r=C.project,s=C.activeConfig}else{let x=await ee(e,i);if(r=x.project,s=x.activeConfig,s.file.errors.length>0)throw new b(s.file.errors.map(C=>C.message).join(`
143
+ `));if(!s.isLinked){let C=await cn({directory:e,apiKey:t,configName:T(s.file.path)});a=C.remoteApp;let E=await ee(e,C.configFileName);r=E.project,s=E.activeConfig}}let c=s.file.content.client_id;if(typeof c!="string"||c.length===0)throw new Q(`Active config at ${s.file.path} is marked as linked but has no client_id`);a??=await tn({apiKey:t??c});let l=a.developerPlatformClient,f=await Wo(a.organizationId,l),_=await pn({developerPlatformClient:l,app:a}),g=await Ve({project:r,activeConfig:s,specifications:_,remoteFlags:a.flags,clientIdOverride:t&&t!==c?t:void 0});if(!o&&!g.errors.isEmpty())throw new b(bp(g.errors.getErrors()[0]));let m=Yt(e),h=a.apiKey===g.configuration.client_id;return(!m||h)&&We({appId:a.apiKey,title:a.title,directory:e,orgId:a.organizationId}),await Nd(a,f,n),g.errors.isEmpty()&&await xp(g.allExtensions,l),{project:r,activeConfig:s,app:g,remoteApp:a,developerPlatformClient:l,specifications:_,organization:f}}async function Nd(e,t,n){let i;t.source==="BusinessPlatform"?i={business_platform_id:He(t.id)}:i={partner_id:He(t.id)},await q.addPublicMetadata(()=>({...i,api_key:e.apiKey,cmd_app_reset_used:n}))}async function gI({directory:e,userProvidedConfigName:t}){let{project:n,activeConfig:i}=await ee(e,t);if(i.file.errors.length>0)throw new b(i.file.errors.map(s=>s.message).join(`
144
+ `));let o=await Je(),r=await Ve({project:n,activeConfig:i,specifications:o,ignoreUnknownExtensions:!0});if(!r.errors.isEmpty())throw new b(bp(r.errors.getErrors()[0]));return{app:r,project:n}}u();var Ei=class extends po{environmentsFilename(){return z.appEnvironments}};export{Zd as a,Ae as b,Mp as c,st as d,nr as e,yf as f,ar as g,Rn as h,Vt as i,$m as j,X as k,q as l,Le as m,Yf as n,yr as o,Ln as p,Yt as q,We as r,Fh as s,os as t,Mh as u,Dh as v,Rh as w,Oh as x,at as y,sx as z,Vn as A,rs as B,dt as C,V_ as D,z_ as E,J_ as F,fs as G,re as H,Gt as I,es as J,yh as K,hh as L,ts as M,_h as N,ns as O,xh as P,en as Q,Rs as R,Lb as S,Bs as T,$s as U,Ls as V,js as W,Ns as X,Ws as Y,zs as Z,tn as _,$C as $,Nl as aa,LC as ba,qs as ca,ti as da,jC as ea,NC as fa,Ks as ga,$w as ha,oa as ia,ui as ja,qE as ka,di as la,nS as ma,fi as na,cS as oa,mi as pa,yS as qa,gi as ra,ES as sa,yi as ta,TS as ua,VP as va,np as wa,pn as xa,cn as ya,Id as za,kd as Aa,mI as Ba,gI as Ca,Ei as Da};