@jucie.io/cli 1.0.11 → 1.0.20

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 (629) hide show
  1. package/dist/jucie.js +223 -163
  2. package/dist/stage/chunks/addAction-3QC2Z4ZR.js +1 -0
  3. package/dist/stage/chunks/addAnimationBinding-N3UW27JM.js +1 -0
  4. package/dist/stage/chunks/addAttribute-MEJIGMHV.js +1 -0
  5. package/dist/stage/chunks/addComponent-AQQI46C3.js +1 -0
  6. package/dist/stage/chunks/addComputed-2JNIUCEP.js +1 -0
  7. package/dist/stage/chunks/addEvent-PN6P6KR5.js +1 -0
  8. package/dist/stage/chunks/addLifecycleHook-D2UKKFVW.js +1 -0
  9. package/dist/stage/chunks/addNode-UXIXDXSD.js +1 -0
  10. package/dist/stage/chunks/addOption-AFCUFOT7.js +1 -0
  11. package/dist/stage/chunks/addParamToRoute-6LOHCID7.js +1 -0
  12. package/dist/stage/chunks/addState-RSEYKWQO.js +1 -0
  13. package/dist/stage/chunks/addStore-AK2FTEON.js +1 -0
  14. package/dist/stage/chunks/addToken-35LUBJPE.js +1 -0
  15. package/dist/stage/chunks/addTree-CU7MJAKT.js +1 -0
  16. package/dist/stage/chunks/addValue-LIQSHZFR.js +1 -0
  17. package/dist/stage/chunks/{aiAttachmentContracts-4GX7AD4P.js → aiAttachmentContracts-KGD3EHZQ.js} +1 -1
  18. package/dist/stage/chunks/{aiMessagesContracts-3IZEU24J.js → aiMessagesContracts-QWUORKI3.js} +1 -1
  19. package/dist/stage/chunks/aiRelay-LW2UZKRR.js +1 -0
  20. package/dist/stage/chunks/{aiSessionContracts-SCDHZZA3.js → aiSessionContracts-RQKGQY4N.js} +1 -1
  21. package/dist/stage/chunks/assets-5J5INILR.js +1 -0
  22. package/dist/stage/chunks/capture-VQE5664P.js +1 -0
  23. package/dist/stage/chunks/{chunk-GG4NWMR6.js → chunk-2JXGTRSC.js} +1 -1
  24. package/dist/stage/chunks/{chunk-BS35FNXF.js → chunk-3GPQ3HYG.js} +1 -1
  25. package/dist/stage/chunks/chunk-3KR3JD5T.js +1 -0
  26. package/dist/stage/chunks/chunk-457GNGEV.js +1 -0
  27. package/dist/stage/chunks/chunk-4KXBOJIC.js +1 -0
  28. package/dist/stage/chunks/chunk-4UJAZNZX.js +1 -0
  29. package/dist/stage/chunks/{chunk-TS6FANUG.js → chunk-5N7NET6A.js} +1 -1
  30. package/dist/stage/chunks/chunk-5RVLCYPU.js +1 -0
  31. package/dist/stage/chunks/chunk-6JNM2JPA.js +1 -0
  32. package/dist/stage/chunks/{chunk-SRRJXNKG.js → chunk-7C53OCBB.js} +1 -1
  33. package/dist/stage/chunks/chunk-7DIGILX7.js +1 -0
  34. package/dist/stage/chunks/{chunk-LOMYBRPE.js → chunk-7H7BUWZP.js} +1 -1
  35. package/dist/stage/chunks/chunk-7SM7WG53.js +1 -0
  36. package/dist/stage/chunks/{chunk-6ZZBJPN5.js → chunk-A7T3U7OZ.js} +1 -1
  37. package/dist/stage/chunks/chunk-AOLXVYBO.js +1 -0
  38. package/dist/stage/chunks/{chunk-OB6WEYNB.js → chunk-ATDHO5ME.js} +1 -1
  39. package/dist/stage/chunks/{chunk-V4F2T2VR.js → chunk-BCDDG7CW.js} +1 -1
  40. package/dist/stage/chunks/chunk-CB4COXKW.js +1 -0
  41. package/dist/stage/chunks/{chunk-4XNQRZ5E.js → chunk-CM6UENYI.js} +1 -1
  42. package/dist/stage/chunks/{chunk-K6PCHHH7.js → chunk-CVWMERPH.js} +1 -1
  43. package/dist/stage/chunks/{chunk-XKEDVW6X.js → chunk-DDCGP5GM.js} +1 -1
  44. package/dist/stage/chunks/chunk-DOGIABU3.js +1 -0
  45. package/dist/stage/chunks/{chunk-SMO45CB3.js → chunk-DUMMXI6I.js} +1 -1
  46. package/dist/stage/chunks/{chunk-HI7ALMQD.js → chunk-E3LBHSMZ.js} +1 -1
  47. package/dist/stage/chunks/chunk-E7JXTPFA.js +1 -0
  48. package/dist/stage/chunks/chunk-GBE5QYRO.js +1 -0
  49. package/dist/stage/chunks/{chunk-BEYPHEBR.js → chunk-GFV4SJGI.js} +1 -1
  50. package/dist/stage/chunks/{chunk-NYG3CJEJ.js → chunk-GILBTTLF.js} +1 -1
  51. package/dist/stage/chunks/chunk-GPV2ZFME.js +1 -0
  52. package/dist/stage/chunks/chunk-HBNF34QX.js +1 -0
  53. package/dist/stage/chunks/{chunk-GIVV5ZCM.js → chunk-HREW6EFQ.js} +1 -1
  54. package/dist/stage/chunks/chunk-HZ7KMV42.js +1 -0
  55. package/dist/stage/chunks/{chunk-U2OFNNHI.js → chunk-HZXJUIIX.js} +1 -1
  56. package/dist/stage/chunks/{chunk-5SOTDESD.js → chunk-IE6IKN6P.js} +1 -1
  57. package/dist/stage/chunks/chunk-IWO4MU2F.js +1 -0
  58. package/dist/stage/chunks/chunk-J7XIIFXF.js +1 -0
  59. package/dist/stage/chunks/chunk-JG62FTV2.js +1 -0
  60. package/dist/stage/chunks/{chunk-L7VQYHXR.js → chunk-JGELXWD3.js} +1 -1
  61. package/dist/stage/chunks/chunk-JKJRK7ER.js +1 -0
  62. package/dist/stage/chunks/{chunk-PU3DZ3MV.js → chunk-JPPPL527.js} +1 -1
  63. package/dist/stage/chunks/chunk-JRCZXEL2.js +1 -0
  64. package/dist/stage/chunks/{chunk-ODSNVDNS.js → chunk-K33QXMAS.js} +1 -1
  65. package/dist/stage/chunks/{chunk-EPBR3BES.js → chunk-K4R2DLAT.js} +1 -1
  66. package/dist/stage/chunks/{chunk-C3DY5XVP.js → chunk-MA3WBBC6.js} +1 -1
  67. package/dist/stage/chunks/chunk-MHU6JTZC.js +1 -0
  68. package/dist/stage/chunks/{chunk-D6NZE747.js → chunk-MO2MHTOQ.js} +1 -1
  69. package/dist/stage/chunks/chunk-MQKISAKO.js +1 -0
  70. package/dist/stage/chunks/{chunk-ARGFDBBK.js → chunk-ND3BSJOS.js} +1 -1
  71. package/dist/stage/chunks/chunk-NGQ7GQSH.js +1 -0
  72. package/dist/stage/chunks/{chunk-VQ7C6EUZ.js → chunk-NM4FV6YK.js} +1 -1
  73. package/dist/stage/chunks/chunk-NOHQVE3L.js +1 -0
  74. package/dist/stage/chunks/{chunk-MLL2ANA6.js → chunk-O6ZKHW5L.js} +1 -1
  75. package/dist/stage/chunks/{chunk-GDGHGTYN.js → chunk-PBDA5G7U.js} +1 -1
  76. package/dist/stage/chunks/{chunk-RZ74UWF3.js → chunk-PBDSKQIQ.js} +1 -1
  77. package/dist/stage/chunks/chunk-PJFVW637.js +1 -0
  78. package/dist/stage/chunks/{chunk-AJVQKPCQ.js → chunk-PRXT2NXZ.js} +1 -1
  79. package/dist/stage/chunks/chunk-QAUB5H3S.js +1 -0
  80. package/dist/stage/chunks/{chunk-BVAPODQ7.js → chunk-QDH6OIAL.js} +1 -1
  81. package/dist/stage/chunks/{chunk-TEUB5MUS.js → chunk-QM4IVTLC.js} +1 -1
  82. package/dist/stage/chunks/chunk-QUWCLSNF.js +1 -0
  83. package/dist/stage/chunks/{chunk-P3WBUN2B.js → chunk-QVOXRLEG.js} +1 -1
  84. package/dist/stage/chunks/chunk-RAHM76FI.js +1 -0
  85. package/dist/stage/chunks/chunk-RONEQF2M.js +1 -0
  86. package/dist/stage/chunks/{chunk-V7BNWQS6.js → chunk-RPTOBIKP.js} +1 -1
  87. package/dist/stage/chunks/{chunk-LR6DSVPP.js → chunk-RSWDPV5U.js} +1 -1
  88. package/dist/stage/chunks/chunk-SSSTBYOF.js +1 -0
  89. package/dist/stage/chunks/{chunk-OPVVANFS.js → chunk-SV2PSWLZ.js} +1 -1
  90. package/dist/stage/chunks/{chunk-LKQDYABR.js → chunk-TDXJNI7H.js} +1 -1
  91. package/dist/stage/chunks/chunk-TFGNKPAQ.js +1 -0
  92. package/dist/stage/chunks/chunk-TYA35RCB.js +1 -0
  93. package/dist/stage/chunks/{chunk-TBDEUSP4.js → chunk-UJZNQZVK.js} +1 -1
  94. package/dist/stage/chunks/{chunk-5PUPZLDN.js → chunk-UN7EZPD7.js} +1 -1
  95. package/dist/stage/chunks/chunk-UOBNXO4G.js +1 -0
  96. package/dist/stage/chunks/chunk-UVV4NANW.js +97 -0
  97. package/dist/stage/chunks/{chunk-5OOKGI32.js → chunk-V5TNO5LS.js} +1 -1
  98. package/dist/stage/chunks/chunk-VHRU6H4C.js +1 -0
  99. package/dist/stage/chunks/chunk-VP2XJ5UI.js +1 -0
  100. package/dist/stage/chunks/{chunk-ZCAGAEP2.js → chunk-VQDQA3ID.js} +1 -1
  101. package/dist/stage/chunks/chunk-VZJTFJZN.js +1 -0
  102. package/dist/stage/chunks/chunk-WCL6XNDN.js +1 -0
  103. package/dist/stage/chunks/chunk-WKUYNMPE.js +1 -0
  104. package/dist/stage/chunks/chunk-WWWIZ7VG.js +1 -0
  105. package/dist/stage/chunks/{chunk-QG2BGE2O.js → chunk-X2R3VYWI.js} +1 -1
  106. package/dist/stage/chunks/{chunk-CVDUFBBG.js → chunk-X5HHNNED.js} +1 -1
  107. package/dist/stage/chunks/{chunk-ZEWKYCOX.js → chunk-X5INDUEQ.js} +1 -1
  108. package/dist/stage/chunks/chunk-XBUV5F3F.js +1 -0
  109. package/dist/stage/chunks/{chunk-HBEWYDHO.js → chunk-XPWU54SD.js} +1 -1
  110. package/dist/stage/chunks/chunk-YFURTAAV.js +1 -0
  111. package/dist/stage/chunks/chunk-YRI4I37X.js +1 -0
  112. package/dist/stage/chunks/chunk-ZCUNR3XN.js +1 -0
  113. package/dist/stage/chunks/clearDestination-TFFJZYZU.js +1 -0
  114. package/dist/stage/chunks/clearName-LAT5C4G3.js +1 -0
  115. package/dist/stage/chunks/clearOptionsExpression-QHE4GD2Y.js +1 -0
  116. package/dist/stage/chunks/clearRender-XEMKLRCM.js +1 -0
  117. package/dist/stage/chunks/clearRepeat-OJXLCGGV.js +1 -0
  118. package/dist/stage/chunks/contentEditor-H4QUMYKV.js +1 -0
  119. package/dist/stage/chunks/createAction-X7WWJ6BN.js +1 -0
  120. package/dist/stage/chunks/createAnimation-TYRSVQNL.js +1 -0
  121. package/dist/stage/chunks/createComputed-NVI2BGGF.js +1 -0
  122. package/dist/stage/chunks/createTextContent-R4ZOE6SM.js +1 -0
  123. package/dist/stage/chunks/createValue-GRZQQ5RR.js +1 -0
  124. package/dist/stage/chunks/design-2S7QAGYM.js +15 -0
  125. package/dist/stage/chunks/dev-PZI3DDXQ.js +1 -0
  126. package/dist/stage/chunks/disconnectNode-RRO6QPMX.js +1 -0
  127. package/dist/stage/chunks/{history-BNHS2T3X.js → history-5FAKKGJY.js} +1 -1
  128. package/dist/stage/chunks/{id-T5EU463K.js → id-G47WSCWG.js} +1 -1
  129. package/dist/stage/chunks/main-GPY4VWAB.js +1 -0
  130. package/dist/stage/chunks/{main-TUNP7F4N.js → main-OLXPOBOM.js} +1 -1
  131. package/dist/stage/chunks/{main-DDWQFH23.js → main-QADVRVCC.js} +1 -1
  132. package/dist/stage/chunks/main-RMI3HY2B.js +1 -0
  133. package/dist/stage/chunks/moveNodeToLastChildOf-SGHEMUMS.js +1 -0
  134. package/dist/stage/chunks/{nodeGraph-ZXVLUHBH.js → nodeGraph-UGMYCUUO.js} +1 -1
  135. package/dist/stage/chunks/{normalizeEventName-6HVMB5GN.js → normalizeEventName-Y34QRO25.js} +1 -1
  136. package/dist/stage/chunks/preview-UBVA3QQU.js +1 -0
  137. package/dist/stage/chunks/removeAction-UIZVYC4K.js +1 -0
  138. package/dist/stage/chunks/removeAnimationBinding-PD2IRVQZ.js +1 -0
  139. package/dist/stage/chunks/removeAttribute-HCDVVDSZ.js +1 -0
  140. package/dist/stage/chunks/removeComputed-2UWAXEAM.js +1 -0
  141. package/dist/stage/chunks/removeEvent-GBW7REQV.js +1 -0
  142. package/dist/stage/chunks/removeLifecycleHook-V4BK7NPV.js +1 -0
  143. package/dist/stage/chunks/removeNode-H7TWCLTZ.js +1 -0
  144. package/dist/stage/chunks/removeOption-4SMMGXLO.js +1 -0
  145. package/dist/stage/chunks/removeParamFromRoute-2Q2PYYP5.js +1 -0
  146. package/dist/stage/chunks/removeState-X4UQTIPT.js +1 -0
  147. package/dist/stage/chunks/removeStore-B3WQQP3D.js +1 -0
  148. package/dist/stage/chunks/removeToken-3QTFHQF6.js +1 -0
  149. package/dist/stage/chunks/removeValue-QIQBSOHR.js +1 -0
  150. package/dist/stage/chunks/setDestination-26OTLIOX.js +1 -0
  151. package/dist/stage/chunks/setHomePage-GBSAVDQC.js +1 -0
  152. package/dist/stage/chunks/setHtmlId-PZQQWCXU.js +1 -0
  153. package/dist/stage/chunks/setName-C26SXODP.js +1 -0
  154. package/dist/stage/chunks/setNodeLayout-PZMYT6M2.js +1 -0
  155. package/dist/stage/chunks/setOptionsExpression-PQ3JOVEW.js +1 -0
  156. package/dist/stage/chunks/setRender-MNCOTE35.js +1 -0
  157. package/dist/stage/chunks/setRepeat-GIOC7YT4.js +1 -0
  158. package/dist/stage/chunks/setTagName-FA7BMEUS.js +1 -0
  159. package/dist/stage/chunks/updateAction-TUQLHSJE.js +1 -0
  160. package/dist/stage/chunks/updateAnimationBinding-I3AQNLO2.js +1 -0
  161. package/dist/stage/chunks/updateAttribute-TLLDGUPR.js +1 -0
  162. package/dist/stage/chunks/updateBounds-KL4N7VYO.js +1 -0
  163. package/dist/stage/chunks/updateComputed-JGJIIC4A.js +1 -0
  164. package/dist/stage/chunks/updateEvent-YOKH67TX.js +1 -0
  165. package/dist/stage/chunks/updateHtml-Z4XI7SYU.js +1 -0
  166. package/dist/stage/chunks/updateLifecycleHook-4555YGGM.js +1 -0
  167. package/dist/stage/chunks/updateOption-YUFQYF43.js +1 -0
  168. package/dist/stage/chunks/updateRoute-42OSDVLS.js +1 -0
  169. package/dist/stage/chunks/updateState-3RQX5YED.js +1 -0
  170. package/dist/stage/chunks/updateStyle-I5NO4TOV.js +1 -0
  171. package/dist/stage/chunks/updateToken-AFJYTJ7R.js +1 -0
  172. package/dist/stage/chunks/updateValue-XGRBUCOT.js +1 -0
  173. package/dist/stage/chunks/{user-LKHAFHX4.js → user-CK5IAVFH.js} +1 -1
  174. package/dist/stage/chunks/{validateStorePayload-PJ5AD64S.js → validateStorePayload-3HAVFGVL.js} +1 -1
  175. package/dist/stage/chunks/{viewport-ANZ3RTUP.js → viewport-CQRIOXC6.js} +1 -1
  176. package/dist/stage/chunks/window-7JZPBAP7.js +1 -0
  177. package/dist/stage/design.js +1 -1
  178. package/dist/stage/dev.js +1 -1
  179. package/dist/stage/preview.js +1 -1
  180. package/dist/stage/prod.js +1 -1
  181. package/dist/stage-bundles/preact/chunks/addComponent-3JC5NC3Y.js +1 -0
  182. package/dist/stage-bundles/preact/chunks/addNode-QXU2P4AE.js +1 -0
  183. package/dist/stage-bundles/preact/chunks/addTree-S73GXWZP.js +1 -0
  184. package/dist/stage-bundles/{vue/chunks/aiAttachmentContracts-V3EW4BHI.js → preact/chunks/aiAttachmentContracts-7LLE57FI.js} +1 -1
  185. package/dist/stage-bundles/{vue/chunks/aiMessagesContracts-ZGHZJ7EU.js → preact/chunks/aiMessagesContracts-RAR7ENH4.js} +1 -1
  186. package/dist/stage-bundles/preact/chunks/aiRelay-C6ZJ3PUF.js +1 -0
  187. package/dist/stage-bundles/preact/chunks/{aiSessionContracts-WAMOGHSG.js → aiSessionContracts-NHU57TUZ.js} +1 -1
  188. package/dist/stage-bundles/preact/chunks/assets-6LM3GVQU.js +1 -0
  189. package/dist/stage-bundles/preact/chunks/capture-ON3BO6WE.js +1 -0
  190. package/dist/stage-bundles/preact/chunks/chunk-2Z2RXHNK.js +1 -0
  191. package/dist/stage-bundles/preact/chunks/chunk-3WCN6R5H.js +1 -0
  192. package/dist/stage-bundles/preact/chunks/chunk-45YNKT2X.js +1 -0
  193. package/dist/stage-bundles/preact/chunks/chunk-4Q5R44ZZ.js +1 -0
  194. package/dist/stage-bundles/preact/chunks/chunk-7I5TQOE2.js +1 -0
  195. package/dist/stage-bundles/preact/chunks/chunk-7YVQSQRP.js +1 -0
  196. package/dist/stage-bundles/preact/chunks/chunk-AOGIMUZ2.js +103 -0
  197. package/dist/stage-bundles/preact/chunks/chunk-BGQJ5B3Q.js +1 -0
  198. package/dist/stage-bundles/preact/chunks/chunk-CGCD6S33.js +6 -0
  199. package/dist/stage-bundles/preact/chunks/chunk-DWW3567Q.js +1 -0
  200. package/dist/stage-bundles/preact/chunks/chunk-G3PYA3EU.js +1 -0
  201. package/dist/stage-bundles/preact/chunks/chunk-H5NHEM4C.js +1 -0
  202. package/dist/stage-bundles/preact/chunks/chunk-IG2Y3H6O.js +1 -0
  203. package/dist/stage-bundles/preact/chunks/chunk-IWTWZA3T.js +1 -0
  204. package/dist/stage-bundles/preact/chunks/chunk-LXD22ETU.js +1 -0
  205. package/dist/stage-bundles/preact/chunks/chunk-M577WNTV.js +1 -0
  206. package/dist/stage-bundles/preact/chunks/chunk-NFKUJQZH.js +1 -0
  207. package/dist/stage-bundles/preact/chunks/chunk-NKDO4J6J.js +1 -0
  208. package/dist/stage-bundles/preact/chunks/chunk-SCJKRPIZ.js +1 -0
  209. package/dist/stage-bundles/preact/chunks/{chunk-O24ISLGT.js → chunk-ULVFWUAU.js} +1 -1
  210. package/dist/stage-bundles/preact/chunks/contentEditor-7BYCT3TH.js +1 -0
  211. package/dist/stage-bundles/preact/chunks/design-3DHGUCPX.js +15 -0
  212. package/dist/stage-bundles/preact/chunks/{history-VAAFKC4E.js → history-CMF3VYTT.js} +1 -1
  213. package/dist/stage-bundles/preact/chunks/main-3VRCGPRY.js +1 -0
  214. package/dist/stage-bundles/preact/chunks/{main-KFGWT6OT.js → main-DH4JOS22.js} +1 -1
  215. package/dist/stage-bundles/preact/chunks/{main-MVCLW2IY.js → main-FAFZABOS.js} +1 -1
  216. package/dist/stage-bundles/preact/chunks/main-S7RT75O6.js +1 -0
  217. package/dist/stage-bundles/preact/chunks/moveNodeToLastChildOf-CWSWITHI.js +1 -0
  218. package/dist/stage-bundles/preact/chunks/{nodeGraph-JS64VAAQ.js → nodeGraph-UNI2HUNX.js} +1 -1
  219. package/dist/stage-bundles/preact/chunks/preview-YOYSHYJF.js +1 -0
  220. package/dist/stage-bundles/preact/chunks/setNodeLayout-KQVZJBYW.js +1 -0
  221. package/dist/stage-bundles/preact/chunks/{user-FCPIGR7X.js → user-H5DKMGWA.js} +1 -1
  222. package/dist/stage-bundles/preact/chunks/{viewport-LLBH2LJW.js → viewport-ZRWTVYC3.js} +1 -1
  223. package/dist/stage-bundles/preact/chunks/window-IMPT5I3D.js +1 -0
  224. package/dist/stage-bundles/preact/entry.js +1 -1
  225. package/dist/stage-bundles/preact/framework-compat.js +1 -1
  226. package/dist/stage-bundles/preact/framework-hooks.js +1 -1
  227. package/dist/stage-bundles/preact/framework-jsx-runtime.js +1 -1
  228. package/dist/stage-bundles/preact/framework.js +1 -1
  229. package/dist/stage-bundles/preact/sdk.js +1 -1
  230. package/dist/stage-bundles/react/chunks/{addAction-BMIMOFKC.js → addAction-EGLGEGTS.js} +1 -1
  231. package/dist/stage-bundles/react/chunks/addAnimationBinding-WCB5VZLU.js +1 -0
  232. package/dist/stage-bundles/react/chunks/{addAttribute-2WJG6MQQ.js → addAttribute-2MZ3OFUE.js} +1 -1
  233. package/dist/stage-bundles/react/chunks/addComponent-3JC5NC3Y.js +1 -0
  234. package/dist/stage-bundles/react/chunks/{addComputed-WNYOBBU3.js → addComputed-7JLBFD6I.js} +1 -1
  235. package/dist/stage-bundles/react/chunks/{addEvent-KKSUEWJZ.js → addEvent-HOBNKM2F.js} +1 -1
  236. package/dist/stage-bundles/react/chunks/{addLifecycleHook-KXJ6HEKQ.js → addLifecycleHook-GHYL7FRH.js} +1 -1
  237. package/dist/stage-bundles/react/chunks/addNode-QXU2P4AE.js +1 -0
  238. package/dist/stage-bundles/react/chunks/{addOption-6OBUAJDH.js → addOption-PVXGN7AJ.js} +1 -1
  239. package/dist/stage-bundles/react/chunks/addParamToRoute-VL2VOFZS.js +1 -0
  240. package/dist/stage-bundles/react/chunks/{addState-BH7Q5V6N.js → addState-U2NWEGWV.js} +1 -1
  241. package/dist/stage-bundles/react/chunks/addStore-AQMFKH33.js +1 -0
  242. package/dist/stage-bundles/react/chunks/{addToken-DFONVP3M.js → addToken-XF2FFA52.js} +1 -1
  243. package/dist/stage-bundles/react/chunks/addTree-S73GXWZP.js +1 -0
  244. package/dist/stage-bundles/react/chunks/{addValue-6SJ7KR7G.js → addValue-O7YXXMST.js} +1 -1
  245. package/dist/stage-bundles/{preact/chunks/aiAttachmentContracts-V3EW4BHI.js → react/chunks/aiAttachmentContracts-7LLE57FI.js} +1 -1
  246. package/dist/stage-bundles/{preact/chunks/aiMessagesContracts-ZGHZJ7EU.js → react/chunks/aiMessagesContracts-RAR7ENH4.js} +1 -1
  247. package/dist/stage-bundles/react/chunks/aiRelay-C6ZJ3PUF.js +1 -0
  248. package/dist/stage-bundles/{vue/chunks/aiSessionContracts-WAMOGHSG.js → react/chunks/aiSessionContracts-NHU57TUZ.js} +1 -1
  249. package/dist/stage-bundles/react/chunks/assets-6LM3GVQU.js +1 -0
  250. package/dist/stage-bundles/react/chunks/capture-6GFKGXIT.js +1 -0
  251. package/dist/stage-bundles/react/chunks/chunk-2Z2RXHNK.js +1 -0
  252. package/dist/stage-bundles/react/chunks/chunk-3WCN6R5H.js +1 -0
  253. package/dist/stage-bundles/react/chunks/chunk-45YNKT2X.js +1 -0
  254. package/dist/stage-bundles/react/chunks/chunk-4Q5R44ZZ.js +1 -0
  255. package/dist/stage-bundles/react/chunks/chunk-7I5TQOE2.js +1 -0
  256. package/dist/stage-bundles/react/chunks/chunk-7YVQSQRP.js +1 -0
  257. package/dist/stage-bundles/react/chunks/chunk-BGQJ5B3Q.js +1 -0
  258. package/dist/stage-bundles/react/chunks/chunk-CGCD6S33.js +6 -0
  259. package/dist/stage-bundles/react/chunks/chunk-G3PYA3EU.js +1 -0
  260. package/dist/stage-bundles/react/chunks/{chunk-5HITMZZP.js → chunk-G5RN6RXS.js} +1 -1
  261. package/dist/stage-bundles/react/chunks/chunk-HJOMUN4M.js +49 -0
  262. package/dist/stage-bundles/react/chunks/chunk-IG2Y3H6O.js +1 -0
  263. package/dist/stage-bundles/react/chunks/chunk-IWTWZA3T.js +1 -0
  264. package/dist/stage-bundles/react/chunks/{chunk-FCMIFWSU.js → chunk-KLPU3QNW.js} +1 -1
  265. package/dist/stage-bundles/react/chunks/chunk-LXD22ETU.js +1 -0
  266. package/dist/stage-bundles/react/chunks/chunk-M577WNTV.js +1 -0
  267. package/dist/stage-bundles/react/chunks/chunk-NFKUJQZH.js +1 -0
  268. package/dist/stage-bundles/react/chunks/chunk-NKDO4J6J.js +1 -0
  269. package/dist/stage-bundles/react/chunks/{chunk-76SRFCJO.js → chunk-P3ZDKQWG.js} +1 -1
  270. package/dist/stage-bundles/react/chunks/chunk-SCJKRPIZ.js +1 -0
  271. package/dist/stage-bundles/react/chunks/chunk-U66LRTNF.js +1 -0
  272. package/dist/stage-bundles/react/chunks/chunk-UCLSDDOL.js +1 -0
  273. package/dist/stage-bundles/{vue/chunks/chunk-O24ISLGT.js → react/chunks/chunk-ULVFWUAU.js} +1 -1
  274. package/dist/stage-bundles/react/chunks/clearDestination-IGKNL7FN.js +1 -0
  275. package/dist/stage-bundles/react/chunks/clearName-HJ7ZTHBU.js +1 -0
  276. package/dist/stage-bundles/react/chunks/clearOptionsExpression-NZQFL64E.js +1 -0
  277. package/dist/stage-bundles/react/chunks/clearRender-NPVDTNFA.js +1 -0
  278. package/dist/stage-bundles/react/chunks/clearRepeat-7YFYZODP.js +1 -0
  279. package/dist/stage-bundles/react/chunks/contentEditor-7BYCT3TH.js +1 -0
  280. package/dist/stage-bundles/react/chunks/{createAction-ITB7SY4A.js → createAction-73YUTK3T.js} +1 -1
  281. package/dist/stage-bundles/react/chunks/createAnimation-2WQSMYT5.js +1 -0
  282. package/dist/stage-bundles/react/chunks/{createComputed-BMWO4U4T.js → createComputed-DMX7CJA3.js} +1 -1
  283. package/dist/stage-bundles/react/chunks/{createTextContent-ZVU57TXU.js → createTextContent-4Z4YATBO.js} +1 -1
  284. package/dist/stage-bundles/react/chunks/createValue-DXQSLOBG.js +1 -0
  285. package/dist/stage-bundles/react/chunks/design-6KSNU4OK.js +15 -0
  286. package/dist/stage-bundles/react/chunks/{disconnectNode-PNUX55O2.js → disconnectNode-2CLWVIQP.js} +1 -1
  287. package/dist/stage-bundles/{vue/chunks/history-VAAFKC4E.js → react/chunks/history-CMF3VYTT.js} +1 -1
  288. package/dist/stage-bundles/react/chunks/{id-UUBDNSND.js → id-ZIAZZ5AS.js} +1 -1
  289. package/dist/stage-bundles/react/chunks/main-3VRCGPRY.js +1 -0
  290. package/dist/stage-bundles/{vue/chunks/main-KFGWT6OT.js → react/chunks/main-DH4JOS22.js} +1 -1
  291. package/dist/stage-bundles/react/chunks/{main-XBZULJGK.js → main-FAFZABOS.js} +1 -1
  292. package/dist/stage-bundles/react/chunks/main-S7RT75O6.js +1 -0
  293. package/dist/stage-bundles/react/chunks/moveNodeToLastChildOf-CWSWITHI.js +1 -0
  294. package/dist/stage-bundles/{vue/chunks/nodeGraph-JS64VAAQ.js → react/chunks/nodeGraph-UNI2HUNX.js} +1 -1
  295. package/dist/stage-bundles/react/chunks/{normalizeEventName-3CSULWE4.js → normalizeEventName-SNBYJDUY.js} +1 -1
  296. package/dist/stage-bundles/react/chunks/preview-KOCHK3AH.js +1 -0
  297. package/dist/stage-bundles/react/chunks/removeAction-T4M5EJN7.js +1 -0
  298. package/dist/stage-bundles/react/chunks/removeAnimationBinding-AIISPC33.js +1 -0
  299. package/dist/stage-bundles/react/chunks/removeAttribute-DCKZLM55.js +1 -0
  300. package/dist/stage-bundles/react/chunks/removeComputed-WSA5GNVZ.js +1 -0
  301. package/dist/stage-bundles/react/chunks/removeEvent-2YZ55HD6.js +1 -0
  302. package/dist/stage-bundles/react/chunks/removeLifecycleHook-SBPJNF5P.js +1 -0
  303. package/dist/stage-bundles/react/chunks/{removeNode-QSDSWHNG.js → removeNode-5HXQ63V3.js} +1 -1
  304. package/dist/stage-bundles/react/chunks/removeOption-SYIFB4XW.js +1 -0
  305. package/dist/stage-bundles/react/chunks/removeParamFromRoute-HAYP3WTT.js +1 -0
  306. package/dist/stage-bundles/react/chunks/removeState-SGJVQ66N.js +1 -0
  307. package/dist/stage-bundles/react/chunks/removeStore-YVBTGA3I.js +1 -0
  308. package/dist/stage-bundles/react/chunks/removeToken-AIDV7DUM.js +1 -0
  309. package/dist/stage-bundles/react/chunks/removeValue-UP5ZFN3U.js +1 -0
  310. package/dist/stage-bundles/react/chunks/setDestination-NCPAVIIK.js +1 -0
  311. package/dist/stage-bundles/react/chunks/setHomePage-O2JYOG6H.js +1 -0
  312. package/dist/stage-bundles/react/chunks/setHtmlId-2W7YW47O.js +1 -0
  313. package/dist/stage-bundles/react/chunks/setName-NKRZPBGG.js +1 -0
  314. package/dist/stage-bundles/react/chunks/setNodeLayout-KQVZJBYW.js +1 -0
  315. package/dist/stage-bundles/react/chunks/{setOptionsExpression-3MOFK54D.js → setOptionsExpression-K5EQXJEY.js} +1 -1
  316. package/dist/stage-bundles/react/chunks/{setRender-WJRTHRML.js → setRender-7XMGQ7ZK.js} +1 -1
  317. package/dist/stage-bundles/react/chunks/{setRepeat-JD6QROHI.js → setRepeat-WN4WZJUN.js} +1 -1
  318. package/dist/stage-bundles/react/chunks/setTagName-U6UJNJLE.js +1 -0
  319. package/dist/stage-bundles/react/chunks/{updateAction-ZW4KGOAQ.js → updateAction-3KSR6ZIJ.js} +1 -1
  320. package/dist/stage-bundles/react/chunks/updateAnimationBinding-HVVHLFBO.js +1 -0
  321. package/dist/stage-bundles/react/chunks/{updateAttribute-HFPDXXBZ.js → updateAttribute-XXZL2P43.js} +1 -1
  322. package/dist/stage-bundles/react/chunks/updateBounds-5M7YQRO3.js +1 -0
  323. package/dist/stage-bundles/react/chunks/{updateComputed-OOBDA4XY.js → updateComputed-7QA6XZIC.js} +1 -1
  324. package/dist/stage-bundles/react/chunks/{updateEvent-LCGAPMAI.js → updateEvent-R52PL2G4.js} +1 -1
  325. package/dist/stage-bundles/react/chunks/updateHtml-YBJJSWQW.js +1 -0
  326. package/dist/stage-bundles/react/chunks/{updateLifecycleHook-RCS2QC44.js → updateLifecycleHook-4RA2U4TR.js} +1 -1
  327. package/dist/stage-bundles/react/chunks/{updateOption-PPZLK4X3.js → updateOption-5U23ZUWV.js} +1 -1
  328. package/dist/stage-bundles/react/chunks/updateRoute-TFQFFFSZ.js +1 -0
  329. package/dist/stage-bundles/react/chunks/{updateState-LRZJPENX.js → updateState-JCUSBQOL.js} +1 -1
  330. package/dist/stage-bundles/react/chunks/updateStyle-JASLFXVX.js +1 -0
  331. package/dist/stage-bundles/react/chunks/updateToken-24P2P2SF.js +1 -0
  332. package/dist/stage-bundles/react/chunks/{updateValue-NTA7TSYR.js → updateValue-TSVJM3PO.js} +1 -1
  333. package/dist/stage-bundles/{vue/chunks/user-FCPIGR7X.js → react/chunks/user-H5DKMGWA.js} +1 -1
  334. package/dist/stage-bundles/react/chunks/{validateStorePayload-VVQBPX4I.js → validateStorePayload-HCBPC7HR.js} +1 -1
  335. package/dist/stage-bundles/{vue/chunks/viewport-LLBH2LJW.js → react/chunks/viewport-ZRWTVYC3.js} +1 -1
  336. package/dist/stage-bundles/react/chunks/window-IMPT5I3D.js +1 -0
  337. package/dist/stage-bundles/react/entry.js +1 -1
  338. package/dist/stage-bundles/react/framework-dom-client.js +1 -1
  339. package/dist/stage-bundles/react/framework-dom.js +1 -1
  340. package/dist/stage-bundles/react/framework-jsx-runtime.js +1 -1
  341. package/dist/stage-bundles/react/framework.js +1 -1
  342. package/dist/stage-bundles/react/sdk.js +1 -1
  343. package/dist/stage-bundles/vue/chunks/addComponent-NG2BML2S.js +1 -0
  344. package/dist/stage-bundles/vue/chunks/addNode-UNXHE5VL.js +1 -0
  345. package/dist/stage-bundles/vue/chunks/addTree-MFMYQTGN.js +1 -0
  346. package/dist/stage-bundles/{react/chunks/aiAttachmentContracts-IIM7E4TZ.js → vue/chunks/aiAttachmentContracts-7LLE57FI.js} +1 -1
  347. package/dist/stage-bundles/{react/chunks/aiMessagesContracts-LVR4HAGR.js → vue/chunks/aiMessagesContracts-RAR7ENH4.js} +1 -1
  348. package/dist/stage-bundles/vue/chunks/aiRelay-C6ZJ3PUF.js +1 -0
  349. package/dist/stage-bundles/{react/chunks/aiSessionContracts-MWOX56DC.js → vue/chunks/aiSessionContracts-NHU57TUZ.js} +1 -1
  350. package/dist/stage-bundles/vue/chunks/assets-6LM3GVQU.js +1 -0
  351. package/dist/stage-bundles/vue/chunks/capture-XURVK5HZ.js +1 -0
  352. package/dist/stage-bundles/vue/chunks/chunk-2Z2RXHNK.js +1 -0
  353. package/dist/stage-bundles/vue/chunks/chunk-4M7L75C7.js +1 -0
  354. package/dist/stage-bundles/vue/chunks/chunk-4Q5R44ZZ.js +1 -0
  355. package/dist/stage-bundles/vue/chunks/chunk-7YVQSQRP.js +1 -0
  356. package/dist/stage-bundles/vue/chunks/chunk-BJPSGTXJ.js +1 -0
  357. package/dist/stage-bundles/vue/chunks/chunk-CGCD6S33.js +6 -0
  358. package/dist/stage-bundles/vue/chunks/chunk-F7DSZRND.js +1 -0
  359. package/dist/stage-bundles/vue/chunks/chunk-GW7KMMRR.js +1 -0
  360. package/dist/stage-bundles/vue/chunks/chunk-HYSOOJLT.js +1 -0
  361. package/dist/stage-bundles/vue/chunks/chunk-IG2Y3H6O.js +1 -0
  362. package/dist/stage-bundles/vue/chunks/chunk-IWTWZA3T.js +1 -0
  363. package/dist/stage-bundles/vue/chunks/chunk-K5IR3PSI.js +1 -0
  364. package/dist/stage-bundles/vue/chunks/chunk-LXD22ETU.js +1 -0
  365. package/dist/stage-bundles/vue/chunks/chunk-NFKUJQZH.js +1 -0
  366. package/dist/stage-bundles/vue/chunks/chunk-NKDO4J6J.js +1 -0
  367. package/dist/stage-bundles/vue/chunks/chunk-QFJRB6B2.js +103 -0
  368. package/dist/stage-bundles/vue/chunks/chunk-SCJKRPIZ.js +1 -0
  369. package/dist/stage-bundles/{react/chunks/chunk-PPHD3O2M.js → vue/chunks/chunk-ULVFWUAU.js} +1 -1
  370. package/dist/stage-bundles/vue/chunks/chunk-USKXWFBI.js +1 -0
  371. package/dist/stage-bundles/vue/chunks/contentEditor-7BYCT3TH.js +1 -0
  372. package/dist/stage-bundles/vue/chunks/design-4GTDZLD2.js +15 -0
  373. package/dist/stage-bundles/{react/chunks/history-7CH6VXP4.js → vue/chunks/history-CMF3VYTT.js} +1 -1
  374. package/dist/stage-bundles/vue/chunks/main-4HW35P75.js +1 -0
  375. package/dist/stage-bundles/vue/chunks/main-BVDJS6IT.js +1 -0
  376. package/dist/stage-bundles/{react/chunks/main-D4CUN7NH.js → vue/chunks/main-DH4JOS22.js} +1 -1
  377. package/dist/stage-bundles/vue/chunks/{main-HQ4XJKUM.js → main-PALLSI3C.js} +1 -1
  378. package/dist/stage-bundles/vue/chunks/moveNodeToLastChildOf-BLKABBSO.js +1 -0
  379. package/dist/stage-bundles/{react/chunks/nodeGraph-2AX6JUZ4.js → vue/chunks/nodeGraph-UNI2HUNX.js} +1 -1
  380. package/dist/stage-bundles/vue/chunks/preview-QUDMZGVG.js +1 -0
  381. package/dist/stage-bundles/vue/chunks/setNodeLayout-KQVZJBYW.js +1 -0
  382. package/dist/stage-bundles/{react/chunks/user-3YXEQVFB.js → vue/chunks/user-H5DKMGWA.js} +1 -1
  383. package/dist/stage-bundles/vue/chunks/viewport-ZRWTVYC3.js +1 -0
  384. package/dist/stage-bundles/vue/chunks/window-IMPT5I3D.js +1 -0
  385. package/dist/stage-bundles/vue/entry.js +1 -1
  386. package/dist/stage-bundles/vue/framework-jsx-runtime.js +1 -1
  387. package/dist/stage-bundles/vue/framework.js +1 -1
  388. package/dist/stage-bundles/vue/sdk.js +1 -1
  389. package/dist/stage-src/dev/entry.js +8 -17
  390. package/dist/stage-src/dev/server.js +77 -24
  391. package/dist/stage-src/preview/bootstrap.js +0 -2
  392. package/package.json +16 -21
  393. package/dist/stage/chunks/addAction-FSI6BXB4.js +0 -1
  394. package/dist/stage/chunks/addAnimationBinding-Y4VROY4L.js +0 -1
  395. package/dist/stage/chunks/addAttribute-ZPJGNPHK.js +0 -1
  396. package/dist/stage/chunks/addComponent-VWD6O7CQ.js +0 -1
  397. package/dist/stage/chunks/addComputed-FQVHDUIE.js +0 -1
  398. package/dist/stage/chunks/addEvent-54ZE2DVJ.js +0 -1
  399. package/dist/stage/chunks/addLifecycleHook-VCCSTQ3G.js +0 -1
  400. package/dist/stage/chunks/addNode-IWTESHU3.js +0 -1
  401. package/dist/stage/chunks/addOption-ISGTUY6U.js +0 -1
  402. package/dist/stage/chunks/addParamToRoute-CRDV7MVF.js +0 -1
  403. package/dist/stage/chunks/addState-N3MBR533.js +0 -1
  404. package/dist/stage/chunks/addStore-PHY52777.js +0 -1
  405. package/dist/stage/chunks/addToken-QSTDKYFU.js +0 -1
  406. package/dist/stage/chunks/addValue-NBDF57UK.js +0 -1
  407. package/dist/stage/chunks/aiRelay-FDHMGC33.js +0 -1
  408. package/dist/stage/chunks/assets-RXVS3AKR.js +0 -1
  409. package/dist/stage/chunks/capture-XQFI2T7B.js +0 -1
  410. package/dist/stage/chunks/chunk-2YZN7IFG.js +0 -1
  411. package/dist/stage/chunks/chunk-32WBU6VH.js +0 -1
  412. package/dist/stage/chunks/chunk-33W74KNB.js +0 -37
  413. package/dist/stage/chunks/chunk-45CXRNTO.js +0 -1
  414. package/dist/stage/chunks/chunk-45LFQ7GZ.js +0 -1
  415. package/dist/stage/chunks/chunk-4MTM6BM7.js +0 -1
  416. package/dist/stage/chunks/chunk-4Y2YKFNP.js +0 -1
  417. package/dist/stage/chunks/chunk-55KIFGBN.js +0 -1
  418. package/dist/stage/chunks/chunk-5GOTVZFC.js +0 -1
  419. package/dist/stage/chunks/chunk-6EIGTDJQ.js +0 -1
  420. package/dist/stage/chunks/chunk-7L4V7JRT.js +0 -1
  421. package/dist/stage/chunks/chunk-D3V5OTLH.js +0 -1
  422. package/dist/stage/chunks/chunk-DCOWKGJI.js +0 -1
  423. package/dist/stage/chunks/chunk-DSKLC3WF.js +0 -1
  424. package/dist/stage/chunks/chunk-EO7UBT4B.js +0 -1
  425. package/dist/stage/chunks/chunk-FSECMWCM.js +0 -1
  426. package/dist/stage/chunks/chunk-FTRUORC5.js +0 -1
  427. package/dist/stage/chunks/chunk-G37FCH35.js +0 -1
  428. package/dist/stage/chunks/chunk-GURTWV7H.js +0 -1
  429. package/dist/stage/chunks/chunk-H3VC542J.js +0 -1
  430. package/dist/stage/chunks/chunk-IERYKQMJ.js +0 -1
  431. package/dist/stage/chunks/chunk-IEXI4PPB.js +0 -1
  432. package/dist/stage/chunks/chunk-K7MC6G4X.js +0 -1
  433. package/dist/stage/chunks/chunk-KCVDFPJI.js +0 -1
  434. package/dist/stage/chunks/chunk-L4CU73MS.js +0 -1
  435. package/dist/stage/chunks/chunk-LOILFK74.js +0 -55
  436. package/dist/stage/chunks/chunk-MXIF2FGR.js +0 -1
  437. package/dist/stage/chunks/chunk-OWARHUEW.js +0 -1
  438. package/dist/stage/chunks/chunk-P4ODI2G4.js +0 -1
  439. package/dist/stage/chunks/chunk-PUPSHZWC.js +0 -1
  440. package/dist/stage/chunks/chunk-QTBRJH2Q.js +0 -1
  441. package/dist/stage/chunks/chunk-SECM4LZZ.js +0 -1
  442. package/dist/stage/chunks/chunk-TAMEB64F.js +0 -1
  443. package/dist/stage/chunks/chunk-TIIQLNVN.js +0 -1
  444. package/dist/stage/chunks/chunk-U3IV5DRQ.js +0 -1
  445. package/dist/stage/chunks/chunk-X6HJCJ3C.js +0 -1
  446. package/dist/stage/chunks/chunk-YMUEID4R.js +0 -1
  447. package/dist/stage/chunks/chunk-YN5VQBDN.js +0 -1
  448. package/dist/stage/chunks/chunk-YZBMJY7E.js +0 -1
  449. package/dist/stage/chunks/clearDestination-P3FTW7VJ.js +0 -1
  450. package/dist/stage/chunks/clearName-EUYRSZED.js +0 -1
  451. package/dist/stage/chunks/clearOptionsExpression-DF4IPDKH.js +0 -1
  452. package/dist/stage/chunks/clearRender-IUKXUT2E.js +0 -1
  453. package/dist/stage/chunks/clearRepeat-HR5C5VWU.js +0 -1
  454. package/dist/stage/chunks/contentEditor-PCXXWARK.js +0 -1
  455. package/dist/stage/chunks/createAction-XVCUAVTP.js +0 -1
  456. package/dist/stage/chunks/createAnimation-YAXYGTZ2.js +0 -1
  457. package/dist/stage/chunks/createComputed-6XPJKJMP.js +0 -1
  458. package/dist/stage/chunks/createTextContent-BL7YGYP5.js +0 -1
  459. package/dist/stage/chunks/createValue-QMG7LOR4.js +0 -1
  460. package/dist/stage/chunks/design-SPZTUDPC.js +0 -15
  461. package/dist/stage/chunks/dev-24ZWZ22W.js +0 -1
  462. package/dist/stage/chunks/disconnectNode-OY65I4GB.js +0 -1
  463. package/dist/stage/chunks/main-BLNWJ3UJ.js +0 -1
  464. package/dist/stage/chunks/main-NTDWDKF7.js +0 -1
  465. package/dist/stage/chunks/moveNodeToLastChildOf-PRI4OYRB.js +0 -1
  466. package/dist/stage/chunks/normalizeLayoutContext-OIXYBNTH.js +0 -1
  467. package/dist/stage/chunks/preview-EIG4E5G5.js +0 -1
  468. package/dist/stage/chunks/react-G5SWVCZA.js +0 -1
  469. package/dist/stage/chunks/removeAction-H3EDG2CG.js +0 -1
  470. package/dist/stage/chunks/removeAnimationBinding-JRXL2AOH.js +0 -1
  471. package/dist/stage/chunks/removeAttribute-6RYM7MYC.js +0 -1
  472. package/dist/stage/chunks/removeComputed-3HL3BXKY.js +0 -1
  473. package/dist/stage/chunks/removeEvent-CP3SVSHQ.js +0 -1
  474. package/dist/stage/chunks/removeLifecycleHook-Q76BUDFU.js +0 -1
  475. package/dist/stage/chunks/removeNode-OFMYW2LY.js +0 -1
  476. package/dist/stage/chunks/removeOption-Y6QYTQ7C.js +0 -1
  477. package/dist/stage/chunks/removeParamFromRoute-MHUMB7RO.js +0 -1
  478. package/dist/stage/chunks/removeState-HEDFV7HD.js +0 -1
  479. package/dist/stage/chunks/removeStore-BQDKUY3I.js +0 -1
  480. package/dist/stage/chunks/removeToken-6K5JDRMK.js +0 -1
  481. package/dist/stage/chunks/removeValue-OTRFOOIB.js +0 -1
  482. package/dist/stage/chunks/setDestination-3H4RDE7F.js +0 -1
  483. package/dist/stage/chunks/setHomePage-UZUWIELK.js +0 -1
  484. package/dist/stage/chunks/setHtmlId-V2DQ2Z6D.js +0 -1
  485. package/dist/stage/chunks/setName-QKDRLH7I.js +0 -1
  486. package/dist/stage/chunks/setNodeLayout-O53CNHES.js +0 -1
  487. package/dist/stage/chunks/setOptionsExpression-4NFPAI24.js +0 -1
  488. package/dist/stage/chunks/setRender-XQJWRRYD.js +0 -1
  489. package/dist/stage/chunks/setRepeat-PAW7YMSY.js +0 -1
  490. package/dist/stage/chunks/setTagName-Y7O7I6SO.js +0 -1
  491. package/dist/stage/chunks/updateAction-XSXILF2R.js +0 -1
  492. package/dist/stage/chunks/updateAnimationBinding-LQTVD3O6.js +0 -1
  493. package/dist/stage/chunks/updateAttribute-5MWAVQAV.js +0 -1
  494. package/dist/stage/chunks/updateBounds-3L2AJ72O.js +0 -1
  495. package/dist/stage/chunks/updateComputed-UALAJ4RF.js +0 -1
  496. package/dist/stage/chunks/updateEvent-NXMQSGDQ.js +0 -1
  497. package/dist/stage/chunks/updateHtml-AEMCHPUQ.js +0 -1
  498. package/dist/stage/chunks/updateLifecycleHook-6MCUOVJH.js +0 -1
  499. package/dist/stage/chunks/updateOption-JCNXPYXP.js +0 -1
  500. package/dist/stage/chunks/updateRoute-CI3GOLVJ.js +0 -1
  501. package/dist/stage/chunks/updateState-QJID3WQV.js +0 -1
  502. package/dist/stage/chunks/updateStyle-FR7K7R73.js +0 -1
  503. package/dist/stage/chunks/updateToken-JX6R3YU7.js +0 -1
  504. package/dist/stage/chunks/updateValue-2B5ZNGZI.js +0 -1
  505. package/dist/stage/chunks/window-RFC7WGLM.js +0 -1
  506. package/dist/stage-bundles/preact/chunks/addComponent-Y2AQ2FGZ.js +0 -1
  507. package/dist/stage-bundles/preact/chunks/addNode-2E5QNYOA.js +0 -1
  508. package/dist/stage-bundles/preact/chunks/aiRelay-WDZAC42R.js +0 -1
  509. package/dist/stage-bundles/preact/chunks/assets-NU56BTDG.js +0 -1
  510. package/dist/stage-bundles/preact/chunks/capture-XBPXL4U7.js +0 -1
  511. package/dist/stage-bundles/preact/chunks/chunk-2BGFXNGU.js +0 -1
  512. package/dist/stage-bundles/preact/chunks/chunk-34CHXN5I.js +0 -1
  513. package/dist/stage-bundles/preact/chunks/chunk-67H474GN.js +0 -1
  514. package/dist/stage-bundles/preact/chunks/chunk-ACPGC7BJ.js +0 -1
  515. package/dist/stage-bundles/preact/chunks/chunk-E4RDZ324.js +0 -1
  516. package/dist/stage-bundles/preact/chunks/chunk-FCRFPWU3.js +0 -97
  517. package/dist/stage-bundles/preact/chunks/chunk-JHWED3SX.js +0 -1
  518. package/dist/stage-bundles/preact/chunks/chunk-JRXMDYLE.js +0 -1
  519. package/dist/stage-bundles/preact/chunks/chunk-KISNK4R4.js +0 -1
  520. package/dist/stage-bundles/preact/chunks/chunk-LEELNBJC.js +0 -1
  521. package/dist/stage-bundles/preact/chunks/chunk-LHON3DKO.js +0 -1
  522. package/dist/stage-bundles/preact/chunks/chunk-PYIGBTL4.js +0 -6
  523. package/dist/stage-bundles/preact/chunks/chunk-QKFDVU2Q.js +0 -1
  524. package/dist/stage-bundles/preact/chunks/chunk-UQFZUWFP.js +0 -1
  525. package/dist/stage-bundles/preact/chunks/contentEditor-6WQFOUKV.js +0 -1
  526. package/dist/stage-bundles/preact/chunks/design-QOLOMJCH.js +0 -15
  527. package/dist/stage-bundles/preact/chunks/main-K2WJEG5C.js +0 -1
  528. package/dist/stage-bundles/preact/chunks/main-ZXFODV6O.js +0 -1
  529. package/dist/stage-bundles/preact/chunks/moveNodeToLastChildOf-OZ6F2NPU.js +0 -1
  530. package/dist/stage-bundles/preact/chunks/normalizeLayoutContext-WRK6FVHM.js +0 -1
  531. package/dist/stage-bundles/preact/chunks/preact-NBJKI6EE.js +0 -1
  532. package/dist/stage-bundles/preact/chunks/preview-AFX7D63A.js +0 -1
  533. package/dist/stage-bundles/preact/chunks/setNodeLayout-QNVAVAMX.js +0 -1
  534. package/dist/stage-bundles/preact/chunks/window-TFWZNZUJ.js +0 -1
  535. package/dist/stage-bundles/react/chunks/addAnimationBinding-7TFETALG.js +0 -1
  536. package/dist/stage-bundles/react/chunks/addComponent-P7BXPI75.js +0 -1
  537. package/dist/stage-bundles/react/chunks/addNode-4MPFG7L5.js +0 -1
  538. package/dist/stage-bundles/react/chunks/addParamToRoute-VX2GDCCP.js +0 -1
  539. package/dist/stage-bundles/react/chunks/addStore-F3E5UJ5H.js +0 -1
  540. package/dist/stage-bundles/react/chunks/aiRelay-3CLWLKMV.js +0 -1
  541. package/dist/stage-bundles/react/chunks/assets-UN6U4NZV.js +0 -1
  542. package/dist/stage-bundles/react/chunks/capture-5GIKSRCZ.js +0 -1
  543. package/dist/stage-bundles/react/chunks/chunk-2BGFXNGU.js +0 -1
  544. package/dist/stage-bundles/react/chunks/chunk-32U4X4HZ.js +0 -6
  545. package/dist/stage-bundles/react/chunks/chunk-34CHXN5I.js +0 -1
  546. package/dist/stage-bundles/react/chunks/chunk-5OEIZ3PD.js +0 -1
  547. package/dist/stage-bundles/react/chunks/chunk-ADVOIRI5.js +0 -43
  548. package/dist/stage-bundles/react/chunks/chunk-ATUQUJRM.js +0 -1
  549. package/dist/stage-bundles/react/chunks/chunk-BXIWQYSY.js +0 -1
  550. package/dist/stage-bundles/react/chunks/chunk-GYBL4LBC.js +0 -1
  551. package/dist/stage-bundles/react/chunks/chunk-HLPDOSGP.js +0 -1
  552. package/dist/stage-bundles/react/chunks/chunk-KISNK4R4.js +0 -1
  553. package/dist/stage-bundles/react/chunks/chunk-NDUX5RLD.js +0 -1
  554. package/dist/stage-bundles/react/chunks/chunk-PSQ4TIJA.js +0 -1
  555. package/dist/stage-bundles/react/chunks/chunk-QKFDVU2Q.js +0 -1
  556. package/dist/stage-bundles/react/chunks/chunk-UQFZUWFP.js +0 -1
  557. package/dist/stage-bundles/react/chunks/clearDestination-ESJ4RTEB.js +0 -1
  558. package/dist/stage-bundles/react/chunks/clearName-XLFUSVVX.js +0 -1
  559. package/dist/stage-bundles/react/chunks/clearOptionsExpression-T5UZGD3M.js +0 -1
  560. package/dist/stage-bundles/react/chunks/clearRender-QOV6MKSA.js +0 -1
  561. package/dist/stage-bundles/react/chunks/clearRepeat-KGDHK6I5.js +0 -1
  562. package/dist/stage-bundles/react/chunks/contentEditor-VQUII3R3.js +0 -1
  563. package/dist/stage-bundles/react/chunks/createAnimation-5GYHDNS4.js +0 -1
  564. package/dist/stage-bundles/react/chunks/createValue-Q2VRKXEI.js +0 -1
  565. package/dist/stage-bundles/react/chunks/design-Z6J5JRDV.js +0 -15
  566. package/dist/stage-bundles/react/chunks/main-OAJ3EVVU.js +0 -1
  567. package/dist/stage-bundles/react/chunks/main-WER4YJAR.js +0 -1
  568. package/dist/stage-bundles/react/chunks/moveNodeToLastChildOf-DQR5GURK.js +0 -1
  569. package/dist/stage-bundles/react/chunks/normalizeLayoutContext-34DZRL3Q.js +0 -1
  570. package/dist/stage-bundles/react/chunks/preview-5V5GS6PZ.js +0 -1
  571. package/dist/stage-bundles/react/chunks/react-YDAQ4KLN.js +0 -1
  572. package/dist/stage-bundles/react/chunks/removeAction-7V4VV5SS.js +0 -1
  573. package/dist/stage-bundles/react/chunks/removeAnimationBinding-26LUMVXH.js +0 -1
  574. package/dist/stage-bundles/react/chunks/removeAttribute-AZK5TQQM.js +0 -1
  575. package/dist/stage-bundles/react/chunks/removeComputed-HIYYBG3M.js +0 -1
  576. package/dist/stage-bundles/react/chunks/removeEvent-A7AUWPIF.js +0 -1
  577. package/dist/stage-bundles/react/chunks/removeLifecycleHook-Z5ZHFYSE.js +0 -1
  578. package/dist/stage-bundles/react/chunks/removeOption-7JZTAHTB.js +0 -1
  579. package/dist/stage-bundles/react/chunks/removeParamFromRoute-JBZOXNDA.js +0 -1
  580. package/dist/stage-bundles/react/chunks/removeState-RIXJ6YEL.js +0 -1
  581. package/dist/stage-bundles/react/chunks/removeStore-PKBJRCYZ.js +0 -1
  582. package/dist/stage-bundles/react/chunks/removeToken-WRU2GN7O.js +0 -1
  583. package/dist/stage-bundles/react/chunks/removeValue-KRNKQVF5.js +0 -1
  584. package/dist/stage-bundles/react/chunks/setDestination-DUGBRV24.js +0 -1
  585. package/dist/stage-bundles/react/chunks/setHomePage-GJLGWZHJ.js +0 -1
  586. package/dist/stage-bundles/react/chunks/setHtmlId-F5SPBYD7.js +0 -1
  587. package/dist/stage-bundles/react/chunks/setName-DAQAN7JR.js +0 -1
  588. package/dist/stage-bundles/react/chunks/setNodeLayout-X4PQKKZT.js +0 -1
  589. package/dist/stage-bundles/react/chunks/setTagName-42MJSWMZ.js +0 -1
  590. package/dist/stage-bundles/react/chunks/updateAnimationBinding-QETT3JF2.js +0 -1
  591. package/dist/stage-bundles/react/chunks/updateBounds-HOTYUCG4.js +0 -1
  592. package/dist/stage-bundles/react/chunks/updateHtml-VQAIKLEG.js +0 -1
  593. package/dist/stage-bundles/react/chunks/updateRoute-FPAKZBCT.js +0 -1
  594. package/dist/stage-bundles/react/chunks/updateStyle-M7YKN6C4.js +0 -1
  595. package/dist/stage-bundles/react/chunks/updateToken-LOI6M4XH.js +0 -1
  596. package/dist/stage-bundles/react/chunks/viewport-7ICM5NZY.js +0 -1
  597. package/dist/stage-bundles/react/chunks/window-SG66BA4O.js +0 -1
  598. package/dist/stage-bundles/vue/chunks/addComponent-Y2AQ2FGZ.js +0 -1
  599. package/dist/stage-bundles/vue/chunks/addNode-5OXCF22G.js +0 -1
  600. package/dist/stage-bundles/vue/chunks/aiRelay-WDZAC42R.js +0 -1
  601. package/dist/stage-bundles/vue/chunks/assets-NU56BTDG.js +0 -1
  602. package/dist/stage-bundles/vue/chunks/capture-UZVRGVM7.js +0 -1
  603. package/dist/stage-bundles/vue/chunks/chunk-7CCYKDAJ.js +0 -97
  604. package/dist/stage-bundles/vue/chunks/chunk-ACPGC7BJ.js +0 -1
  605. package/dist/stage-bundles/vue/chunks/chunk-FYWE2MO5.js +0 -1
  606. package/dist/stage-bundles/vue/chunks/chunk-ILXSVZXQ.js +0 -1
  607. package/dist/stage-bundles/vue/chunks/chunk-IZT2KVTW.js +0 -1
  608. package/dist/stage-bundles/vue/chunks/chunk-JRXMDYLE.js +0 -1
  609. package/dist/stage-bundles/vue/chunks/chunk-PYIGBTL4.js +0 -6
  610. package/dist/stage-bundles/vue/chunks/chunk-QKFDVU2Q.js +0 -1
  611. package/dist/stage-bundles/vue/chunks/chunk-RMSX6LWP.js +0 -1
  612. package/dist/stage-bundles/vue/chunks/chunk-TSL6VG3R.js +0 -1
  613. package/dist/stage-bundles/vue/chunks/chunk-TTTOAB6J.js +0 -1
  614. package/dist/stage-bundles/vue/chunks/chunk-UDTKG2KI.js +0 -1
  615. package/dist/stage-bundles/vue/chunks/chunk-UIC3GAEE.js +0 -1
  616. package/dist/stage-bundles/vue/chunks/contentEditor-EUDU6PBV.js +0 -1
  617. package/dist/stage-bundles/vue/chunks/design-LU5XWCLC.js +0 -15
  618. package/dist/stage-bundles/vue/chunks/main-R652XLC3.js +0 -1
  619. package/dist/stage-bundles/vue/chunks/main-X6SC5JYU.js +0 -1
  620. package/dist/stage-bundles/vue/chunks/moveNodeToLastChildOf-H4TZ5UMP.js +0 -1
  621. package/dist/stage-bundles/vue/chunks/normalizeLayoutContext-KGEMYC4Y.js +0 -1
  622. package/dist/stage-bundles/vue/chunks/preview-52FXOKBF.js +0 -1
  623. package/dist/stage-bundles/vue/chunks/setNodeLayout-GY4G7UZR.js +0 -1
  624. package/dist/stage-bundles/vue/chunks/vue-62USAR6D.js +0 -1
  625. package/dist/stage-bundles/vue/chunks/window-TFWZNZUJ.js +0 -1
  626. package/dist/stage-src/preview/routes/js.js +0 -100
  627. package/dist/stage-src/preview/routes/preview.js +0 -21
  628. package/dist/stage-src/preview/server.js +0 -99
  629. package/dist/stage-src/preview/views/index.js +0 -18
package/dist/jucie.js CHANGED
@@ -1,47 +1,34 @@
1
1
  #!/usr/bin/env node
2
- var SL=Object.create;var Na=Object.defineProperty;var kL=Object.getOwnPropertyDescriptor;var $L=Object.getOwnPropertyNames;var EL=Object.getPrototypeOf,NL=Object.prototype.hasOwnProperty;var TL=(e,t,r)=>t in e?Na(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var i=(e,t)=>Na(e,"name",{value:t,configurable:!0});var f=(e,t)=>()=>(e&&(t=e(e=0)),t);var D=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),R=(e,t)=>{for(var r in t)Na(e,r,{get:t[r],enumerable:!0})},zL=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of $L(t))!NL.call(e,o)&&o!==r&&Na(e,o,{get:()=>t[o],enumerable:!(n=kL(t,o))||n.enumerable});return e};var Hk=(e,t,r)=>(r=e!=null?SL(EL(e)):{},zL(t||!e||!e.__esModule?Na(r,"default",{value:e,enumerable:!0}):r,e));var Te=(e,t,r)=>(TL(e,typeof t!="symbol"?t+"":t,r),r),dh=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)};var y=(e,t,r)=>(dh(e,t,"read from private field"),r?r.call(e):t.get(e)),k=(e,t,r)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,r)},O=(e,t,r,n)=>(dh(e,t,"write to private field"),n?n.call(e,r):t.set(e,r),r);var E=(e,t,r)=>(dh(e,t,"access private method"),r);function Vk(e,t,r){let n=r??"default";if(e.set([t,".activeBreakpoint"],n),n!=="default")e.push([t,"locked"],"width");else{let s=(e.get([t,"locked"])??[]).indexOf("width");s!==-1&&e.splice([t,"locked"],s,1)}}var Gk=f(()=>{i(Vk,"setActiveBreakpoint")});function Wk(e,t){e.remove([t,".activeBreakpoint"])}var Kk=f(()=>{i(Wk,"clearActiveBreakpoint")});import{defineContracts as DL}from"@jucie.io/engine-message";var ML,Jk=f(()=>{Gk();Kk();ML=DL("node:breakpoint",e=>{let t=e("state")?.ref(["nodes"])??null;if(!t)throw new Error("Node cache not found");return{set:{namespace:"scene-graph",schema:["String","Number"],handler:(r,n)=>{Vk(t,r,n)}},clear:{namespace:"scene-graph",schema:["String"],handler:r=>{Wk(t,r)}}}})});function gu(e){return typeof e=="string"&&e.includes("{{")}function gh(e){if(!gu(e))return null;let t=e.match(/^\{\{(.+)\}\}$/);return t?t[1].trim():null}function Ta(e){if(!e)return[];let t=e.matchAll(/(?<![.\w])([a-zA-Z_$][\w]*)/g);return[...new Set([...t].map(n=>n[1]))].filter(n=>!ZL.has(n))}var ZL,yh=f(()=>{ZL=new Set(["true","false","null","undefined","this","return","if","else","for","while","function","var","let","const","new","typeof","instanceof","Array","Object","String","Number","Boolean","Date","Math","JSON","console","window","document"]);i(gu,"hasExpression");i(gh,"parseExpression");i(Ta,"parseDependencies")});var LL,xh,Yk=f(()=>{LL="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict",xh=i((e=21)=>{let t="",r=e|0;for(;r-- >0;)t+=LL[Math.random()*64|0];return t},"nanoid")});var Xk={};R(Xk,{clearGeneratedIds:()=>o4,createActorId:()=>WL,createAnimationId:()=>GL,createAssetId:()=>BL,createChannelId:()=>VL,createDescriptorId:()=>wh,createDocumentId:()=>KL,createId:()=>UL,createLongId:()=>QL,createMessageRequestId:()=>YL,createNodeId:()=>za,createPortId:()=>JL,createSceneId:()=>qL,createSecureId:()=>t4,createSpaceId:()=>HL,createStoreId:()=>XL,createTokenId:()=>vh,createUuid:()=>e4,getGeneratedIds:()=>s4,isIdGenerated:()=>i4,isValidId:()=>n4,loadExistingIds:()=>c4,parseId:()=>r4,removeGeneratedId:()=>a4});function FL(){let e=po[yu]++,t=Math.random().toString(36).slice(2,4);return`${po[_h]}${e}${t}`}function Je(e="",t={}){let{short:r=!1,length:n=21,customLength:o=null}=t,s,a=0,c=100;do{if(r){let l=FL();s=e?`${e}_${l}`:l}else if(o){let l=xh(o);s=e?`${e}_${l}`:l}else{let l=xh(n);s=e?`${e}_${l}`:l}if(a++,a>c)throw new Error(`Failed to generate unique ID after ${c} attempts`)}while(In.has(s));return In.add(s),s}function r4(e){let[t]=e.split("_");return{type:t,id:e}}function n4(e,t={}){let{short:r=!1,length:n=21,customLength:o=null}=t;if(typeof e!="string")return!1;if(!e.includes("_"))return r?e.length>=10&&e.length<=12:e.length===n;let[s,a]=e.split("_");return r?a.length>=10&&a.length<=12:o?a.length===o:a.length===n}function o4(){In.clear()}function s4(){return Array.from(In)}function i4(e){return In.has(e)}function a4(e){return In.delete(e)}function c4(e){Array.isArray(e)&&(e.forEach(t=>{typeof t=="string"&&In.add(t)}),po[yu]=In.size)}var po,yu,_h,In,UL,qL,HL,BL,VL,za,GL,vh,WL,KL,JL,YL,XL,wh,QL,e4,t4,Ca=f(()=>{Yk();po=globalThis,yu=Symbol.for("\u26D4\uFE0Funique-id-counter"),_h=Symbol.for("\u26D4\uFE0Funique-id-session");po[yu]||(po[yu]=0);po[_h]||(po[_h]=Math.random().toString(36).slice(2,6));In=new Set;i(FL,"createBaseId");i(Je,"generateId");UL=i((e={})=>Je("",{short:!0,...e}),"createId"),qL=i((e={})=>Je("sc",e),"createSceneId"),HL=i((e={})=>Je("sp",e),"createSpaceId"),BL=i((e={})=>Je("as",e),"createAssetId"),VL=i((e={})=>Je("ch",e),"createChannelId"),za=i((e={})=>Je("nd",{short:!0,...e}),"createNodeId"),GL=i((e={})=>Je("anim",{short:!0,...e}),"createAnimationId"),vh=i((e={})=>Je("tok",{short:!0,...e}),"createTokenId"),WL=i((e={})=>Je("actor",e),"createActorId"),KL=i((e={})=>Je("doc",e),"createDocumentId"),JL=i((e={})=>Je("port",e),"createPortId"),YL=i((e={})=>Je("msgReq",e),"createMessageRequestId"),XL=i((e={})=>Je("str",e),"createStoreId"),wh=i((e={})=>Je("desc",e),"createDescriptorId"),QL=i((e={})=>Je("",{length:32,...e}),"createLongId"),e4=i((e={})=>Je("uuid",{customLength:36,...e}),"createUuid"),t4=i((e={})=>Je("sec",{customLength:64,...e}),"createSecureId");i(r4,"parseId");i(n4,"isValidId");i(o4,"clearGeneratedIds");i(s4,"getGeneratedIds");i(i4,"isIdGenerated");i(a4,"removeGeneratedId");i(c4,"loadExistingIds")});var xu=f(()=>{Ca()});function p4(e){if(e==null||e==="")return null;try{return new Function("ctx","event",e),null}catch{try{return new Function(`return (${e})`),null}catch(r){return r.message}}}function f4(e){if(e==null||e==="")return null;try{return new Function("ctx",e),null}catch{try{return new Function("ctx",`return (${e})`),null}catch(r){return r.message}}}function m4(e){return e==null?null:!Array.isArray(e)||e.length===0?"binding must be a non-empty array of strings":e.every(t=>typeof t=="string"&&t.length>0)?null:"every segment in binding must be a non-empty string"}function h4(e){let t={...e,error:null};switch(t.mode){case"code":t.error=p4(t.code);break;case"computed":t.error=f4(t.computed);break;case"binding":t.error=m4(t.binding);break;case"value":default:break}return t}function Se(e={}){let t=d4();return e.id||(e.id=wh()),e.name!=null&&(t.name=e.name),e.value!==void 0&&(t.value=e.value),e.binding!=null&&(t.binding=e.binding),e.computed!=null&&(t.computed=e.computed),e.code!=null&&(t.code=e.code),e.mode&&l4.has(e.mode)&&(t.mode=e.mode),t.mode==="computed"&&!t.computed&&(t.computed=u4),t.mode==="code"&&!t.code&&(t.code=_u),t.mode==="computed"&&t.computed&&(t.dependencies=Ta(t.computed)),e.removable===!1&&(t.removable=!1),h4(t)}var l4,u4,_u,d4,Ht=f(()=>{yh();xu();l4=new Set(["value","binding","computed","code"]),u4=`function (ctx) {
2
+ var M9=Object.create;var bc=Object.defineProperty;var Z9=Object.getOwnPropertyDescriptor;var L9=Object.getOwnPropertyNames;var F9=Object.getPrototypeOf,U9=Object.prototype.hasOwnProperty;var q9=(e,t,r)=>t in e?bc(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var i=(e,t)=>bc(e,"name",{value:t,configurable:!0});var f=(e,t)=>()=>(e&&(t=e(e=0)),t);var F=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),C=(e,t)=>{for(var r in t)bc(e,r,{get:t[r],enumerable:!0})},B9=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of L9(t))!U9.call(e,o)&&o!==r&&bc(e,o,{get:()=>t[o],enumerable:!(n=Z9(t,o))||n.enumerable});return e};var _N=(e,t,r)=>(r=e!=null?M9(F9(e)):{},B9(t||!e||!e.__esModule?bc(r,"default",{value:e,enumerable:!0}):r,e));var _e=(e,t,r)=>(q9(e,typeof t!="symbol"?t+"":t,r),r),fy=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)};var y=(e,t,r)=>(fy(e,t,"read from private field"),r?r.call(e):t.get(e)),$=(e,t,r)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,r)},O=(e,t,r,n)=>(fy(e,t,"write to private field"),n?n.call(e,r):t.set(e,r),r);var vN=(e,t,r,n)=>({set _(o){O(e,t,o,r)},get _(){return y(e,t,n)}}),k=(e,t,r)=>(fy(e,t,"access private method"),r);function bN(e,t,r){let n=r??"default";if(e.set([t,".activeBreakpoint"],n),n!=="default")e.push([t,"locked"],"width");else{let s=(e.get([t,"locked"])??[]).indexOf("width");s!==-1&&e.splice([t,"locked"],s,1)}}var SN=f(()=>{i(bN,"setActiveBreakpoint")});function kN(e,t){e.remove([t,".activeBreakpoint"])}var $N=f(()=>{i(kN,"clearActiveBreakpoint")});import{defineContracts as X9}from"@jucie.io/engine-message";var Q9,EN=f(()=>{SN();$N();Q9=X9("node:breakpoint",e=>{let t=e("state")?.ref(["nodes"])??null;if(!t)throw new Error("Node cache not found");return{set:{namespace:"scene-graph",schema:["String","Number"],handler:(r,n)=>{bN(t,r,n)}},clear:{namespace:"scene-graph",schema:["String"],handler:r=>{kN(t,r)}}}})});function Bd(e){return typeof e=="string"&&e.includes("{{")}function xy(e){if(!Bd(e))return null;let t=e.match(/^\{\{(.+)\}\}$/);return t?t[1].trim():null}function Sc(e){if(!e)return[];let t=e.matchAll(/(?<![.\w])([a-zA-Z_$][\w]*)/g);return[...new Set([...t].map(n=>n[1]))].filter(n=>!eq.has(n))}var eq,_y=f(()=>{eq=new Set(["true","false","null","undefined","this","return","if","else","for","while","function","var","let","const","new","typeof","instanceof","Array","Object","String","Number","Boolean","Date","Math","JSON","console","window","document"]);i(Bd,"hasExpression");i(xy,"parseExpression");i(Sc,"parseDependencies")});var tq,vy,NN=f(()=>{tq="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict",vy=i((e=21)=>{let t="",r=e|0;for(;r-- >0;)t+=tq[Math.random()*64|0];return t},"nanoid")});var TN={};C(TN,{clearGeneratedIds:()=>_q,createActorId:()=>lq,createAnimationId:()=>cq,createAssetId:()=>iq,createChannelId:()=>aq,createDescriptorId:()=>Sy,createDocumentId:()=>uq,createId:()=>nq,createLongId:()=>mq,createMessageRequestId:()=>pq,createNodeId:()=>kc,createPortId:()=>dq,createSceneId:()=>oq,createSecureId:()=>gq,createSpaceId:()=>sq,createStoreId:()=>fq,createTokenId:()=>by,createUuid:()=>hq,getGeneratedIds:()=>vq,isIdGenerated:()=>wq,isValidId:()=>xq,loadExistingIds:()=>Sq,parseId:()=>yq,removeGeneratedId:()=>bq});function rq(){let e=Zo[Hd]++,t=Math.random().toString(36).slice(2,4);return`${Zo[wy]}${e}${t}`}function Qe(e="",t={}){let{short:r=!1,length:n=21,customLength:o=null}=t,s,a=0,c=100;do{if(r){let l=rq();s=e?`${e}_${l}`:l}else if(o){let l=vy(o);s=e?`${e}_${l}`:l}else{let l=vy(n);s=e?`${e}_${l}`:l}if(a++,a>c)throw new Error(`Failed to generate unique ID after ${c} attempts`)}while(Wn.has(s));return Wn.add(s),s}function yq(e){let[t]=e.split("_");return{type:t,id:e}}function xq(e,t={}){let{short:r=!1,length:n=21,customLength:o=null}=t;if(typeof e!="string")return!1;if(!e.includes("_"))return r?e.length>=10&&e.length<=12:e.length===n;let[s,a]=e.split("_");return r?a.length>=10&&a.length<=12:o?a.length===o:a.length===n}function _q(){Wn.clear()}function vq(){return Array.from(Wn)}function wq(e){return Wn.has(e)}function bq(e){return Wn.delete(e)}function Sq(e){Array.isArray(e)&&(e.forEach(t=>{typeof t=="string"&&Wn.add(t)}),Zo[Hd]=Wn.size)}var Zo,Hd,wy,Wn,nq,oq,sq,iq,aq,kc,cq,by,lq,uq,dq,pq,fq,Sy,mq,hq,gq,$c=f(()=>{NN();Zo=globalThis,Hd=Symbol.for("\u26D4\uFE0Funique-id-counter"),wy=Symbol.for("\u26D4\uFE0Funique-id-session");Zo[Hd]||(Zo[Hd]=0);Zo[wy]||(Zo[wy]=Math.random().toString(36).slice(2,6));Wn=new Set;i(rq,"createBaseId");i(Qe,"generateId");nq=i((e={})=>Qe("",{short:!0,...e}),"createId"),oq=i((e={})=>Qe("sc",e),"createSceneId"),sq=i((e={})=>Qe("sp",e),"createSpaceId"),iq=i((e={})=>Qe("as",e),"createAssetId"),aq=i((e={})=>Qe("ch",e),"createChannelId"),kc=i((e={})=>Qe("nd",{short:!0,...e}),"createNodeId"),cq=i((e={})=>Qe("anim",{short:!0,...e}),"createAnimationId"),by=i((e={})=>Qe("tok",{short:!0,...e}),"createTokenId"),lq=i((e={})=>Qe("actor",e),"createActorId"),uq=i((e={})=>Qe("doc",e),"createDocumentId"),dq=i((e={})=>Qe("port",e),"createPortId"),pq=i((e={})=>Qe("msgReq",e),"createMessageRequestId"),fq=i((e={})=>Qe("str",e),"createStoreId"),Sy=i((e={})=>Qe("desc",e),"createDescriptorId"),mq=i((e={})=>Qe("",{length:32,...e}),"createLongId"),hq=i((e={})=>Qe("uuid",{customLength:36,...e}),"createUuid"),gq=i((e={})=>Qe("sec",{customLength:64,...e}),"createSecureId");i(yq,"parseId");i(xq,"isValidId");i(_q,"clearGeneratedIds");i(vq,"getGeneratedIds");i(wq,"isIdGenerated");i(bq,"removeGeneratedId");i(Sq,"loadExistingIds")});var Vd=f(()=>{$c()});function Nq(e){if(e==null||e==="")return null;try{return new Function("ctx","event",e),null}catch{try{return new Function(`return (${e})`),null}catch(r){return r.message}}}function Tq(e){if(e==null||e==="")return null;try{return new Function("ctx",e),null}catch{try{return new Function("ctx",`return (${e})`),null}catch(r){return r.message}}}function zq(e){return e==null?null:!Array.isArray(e)||e.length===0?"binding must be a non-empty array of strings":e.every(t=>typeof t=="string"&&t.length>0)?null:"every segment in binding must be a non-empty string"}function Cq(e){let t={...e,error:null};switch(t.mode){case"code":t.error=Nq(t.code);break;case"computed":t.error=Tq(t.computed);break;case"binding":t.error=zq(t.binding);break;case"value":default:break}return t}function Ne(e={}){let t=Eq();return e.id||(e.id=Sy()),e.name!=null&&(t.name=e.name),e.value!==void 0&&(t.value=e.value),e.binding!=null&&(t.binding=e.binding),e.computed!=null&&(t.computed=e.computed),e.code!=null&&(t.code=e.code),e.mode&&kq.has(e.mode)&&(t.mode=e.mode),t.mode==="computed"&&!t.computed&&(t.computed=$q),t.mode==="code"&&!t.code&&(t.code=Gd),t.mode==="computed"&&t.computed&&(t.dependencies=Sc(t.computed)),e.removable===!1&&(t.removable=!1),Cq(t)}var kq,$q,Gd,Eq,Kt=f(()=>{_y();Vd();kq=new Set(["value","binding","computed","code"]),$q=`function (ctx) {
3
3
  return true
4
- }`,_u=`function (ctx, event) {
4
+ }`,Gd=`function (ctx, event) {
5
5
 
6
- }`,d4=i(()=>({name:null,mode:"value",value:null,binding:null,computed:null,code:null,error:null,removable:!0}),"DEFAULTS");i(p4,"validateCode");i(f4,"validateComputed");i(m4,"validateBinding");i(h4,"validateDescriptor");i(Se,"createDescriptor")});function vu({name:e,mode:t,...r}={}){return Se({name:e,mode:t??"value",...r})}var bh=f(()=>{Ht();i(vu,"createClassName")});function Qk(e,t,r={}){let n=typeof r=="string"?{value:r}:r;return e.push([t,"className"],vu({mode:"value",...n}))}var e$=f(()=>{bh();i(Qk,"addClassName")});function t$(e,t,r,n){return e.setWhere([t,"className"],{value:r},vu(n))}var r$=f(()=>{bh();i(t$,"updateClassName")});function n$(e,t,r){return e.removeWhere([t,"className"],{value:r})}var o$=f(()=>{i(n$,"removeClassName")});import{defineContracts as g4}from"@jucie.io/engine-message";var y4,s$=f(()=>{e$();r$();o$();y4=g4("node:className",e=>{let t=e("state")?.ref(["nodes"])??null;if(!t)throw new Error("Node cache not found");return{add:{namespace:"scene-graph",schema:["String","String"],handler:(r,n)=>Qk(t,r,n)},update:{namespace:"scene-graph",schema:["String","String","Object"],handler:(r,n,o)=>t$(t,r,n,o)},remove:{namespace:"scene-graph",schema:["String","String"],handler:(r,n)=>n$(t,r,n)}}})});function _t(e,t){return e.has([t])}var Rs=f(()=>{i(_t,"nodeExists")});var i$={};R(i$,{disconnectNode:()=>Jr});function Jr(e,t){if(!t||!_t(e,t))return!1;e.update(["app","children"],(n=[])=>n.filter(o=>o!==t)),e.update(["temp","children"],(n=[])=>n.filter(o=>o!==t));let r=e.findWhen("children","includes",t);return r&&e.update(r,(n=[])=>n.filter(o=>o!==t)),!0}var Ia=f(()=>{Rs();i(Jr,"disconnectNode")});function dr(e,t,r=[]){let n=e.get([t,"children"])||[];for(let o of n)r.push(o),r=dr(e,o,r);return r}var Os=f(()=>{i(dr,"findDescendantIds")});var As,wu=f(()=>{As=i(e=>structuredClone?structuredClone(e):JSON.parse(JSON.stringify(e)),"clone")});function a$(e,t){let r=t.flatMap(o=>dr(e,o));t.forEach(o=>{Jr(e,o)}),t=[...t,...r];let n={};for(let o of t)n[o]=e.remove([o]);return As(n)}var c$=f(()=>{Ia();Os();wu();i(a$,"cutNodes")});function l$(e,t){let r=t.flatMap(o=>dr(e,o));t=[...t,...r];let n={};for(let o of t){let s=e.get([o]);s&&(n[o]=s)}return As(n)}var u$=f(()=>{Os();wu();i(l$,"copyNodes")});function bu(e,t){return e.update(["temp","children"],(r=[])=>r.indexOf(t)===-1?[...r,t]:r),!0}var Sh=f(()=>{i(bu,"moveNodeToTemp")});function d$(e,t){let r=e.get([t,"layout"]);if(r&&r!=="none")return r;let n=e.get([t,"style","default","display"]);return n==="flex"||n==="grid"?n:"none"}var p$=f(()=>{i(d$,"getLayoutContext")});function Su(e,t,r){let n=e.get([t,"style"]);if(!(!n||!r.length))for(let o in n){let s=n[o];if(!(!s||typeof s!="object")){for(let a of r)a in s&&e.remove([t,"style",o,a]);for(let a in s){if(!a.startsWith(":")&&!a.startsWith("&."))continue;let c=s[a];if(!(!c||typeof c!="object"))for(let l of r)l in c&&e.remove([t,"style",o,a,l])}}}}var kh=f(()=>{i(Su,"stripStyleProperties")});function f$(e,t){Su(e,t,x4)}var x4,m$=f(()=>{kh();x4=["top","left","right","bottom"];i(f$,"stripPositionalStyles")});function $h(){return{layout:"none",draggable:!0,resizable:!0,selectable:!0,locked:[],anchor:[],dimensions:[],expandedStyles:[],childrenType:"children"}}var h$=f(()=>{i($h,"defaultNodeBehavior")});function js(e){if(e===g$||e==null)return g$;let t=String(e);return t.startsWith("@")?t:`@${t}`}var g$,ku=f(()=>{g$="default";i(js,"toBpKey")});var Eh={};R(Eh,{updateStyle:()=>Pa});function Ds(e){return e!=null&&e!=="auto"}function Pa(e,t,r,{breakpoint:n="default",interactionState:o,anchor:s}={}){let a=js(n),c=o??e.get([t,".interactionState"])??[],l={};for(let u of _4)u in r&&(l[u]=r[u],delete r[u]);for(let u of v4)delete r[u];return s=s??e.get([t,"anchor"]),e.update([t,"style",a],(u={})=>{let d={...u,...l};if(s)for(let p of w4)s.includes(p)||delete d[p];return Ds(d.left)&&Ds(d.right)&&!("width"in l)&&Ds(d.width)&&delete d.width,Ds(d.top)&&Ds(d.bottom)&&!("height"in l)&&Ds(d.height)&&delete d.height,d}),e.update([t,"style",a,...c],(u={})=>({...u,...r})),e.get([t,"style",a])}var _4,v4,w4,Ms=f(()=>{ku();_4=["top","left","right","bottom","width","height"],v4=["display","position"];i(Ds,"isConstrainedEdge");w4=["top","left","right","bottom"];i(Pa,"updateStyle")});var Nh={};R(Nh,{updateBounds:()=>Ra});function Ra(e,t,r){let n=e.get([t,"bounds"])??{};return e.set([t,"bounds"],{...n,...r})}var Oa=f(()=>{i(Ra,"updateBounds")});function y$(e,t){return e?t?e.filter(r=>!t.includes(r)):e:[]}var x$=f(()=>{i(y$,"arrayDiff")});function _$(e,t,r){let n=e.get([t,"anchor"]),o=y$(n,r);return o.length&&Su(e,t,o),e.set([t,"anchor"],r),!0}var v$=f(()=>{x$();kh();i(_$,"updateAnchor")});function Bt(e,t){return e.remove([t,".position"])}var Zs=f(()=>{i(Bt,"clearPosition")});function Yr(e,t,r,n){if(!r||typeof r!="object")return;let o=Object.keys(r).sort();for(let s of o){let a=r[s];switch(s){case"style":{let c=r?.anchor;Pa(e,t,a,{breakpoint:n,anchor:c}),Bt(e,t);break}case"bounds":Ra(e,t,a);break;case"anchor":_$(e,t,a);break;default:e.set([t,s],a);break}}}function w$(e,t,r={}){let n={...$h(),...r};for(let o of Object.keys(n))e.set([t,o],n[o])}function b$(e,t){let r=$h();for(let n of Object.keys(r))e.set([t,n],r[n]);e.set([t,"hidden"],void 0),e.set([t,"isComponentRoot"],void 0)}var Aa=f(()=>{h$();Ms();Oa();v$();Zs();i(Yr,"applyNodePatch");i(w$,"setNodeBehavior");i(b$,"resetNodeBehavior")});var S$={};R(S$,{normalizeLayoutContext:()=>Ye});function Ye(e,t,r){if(d$(e,r)!=="none"){f$(e,t),Yr(e,t,{anchor:[],dimensions:[]});return}let o=e.get([t,"anchor"]);(!o||!o.length)&&Yr(e,t,{anchor:["top","left"],dimensions:["width","height"]})}var Xr=f(()=>{p$();m$();Aa();i(Ye,"normalizeLayoutContext")});function Rt(e,t){return e.update(["app","children"],(r=[])=>r.indexOf(t)===-1?[...r,t]:r),Ye(e,t,"app"),!0}var fo=f(()=>{Xr();i(Rt,"moveNodeToRoot")});function $u(e,t){return e.has([t])?e.get(["app","children"])?.includes(t)?"root":e.get(["temp","children"])?.includes(t)?"temp":e.get(["components","children"])?.includes(t)?"components":"nested":null}var Th=f(()=>{i($u,"getNodeLevel")});function Tr(e,t,r,n){let o=e.get([t]);if(!o||!o.bounds)return!0;if(n==="instance")return!1;let s=o.type==="component";if(n==="root"||n==="temp")return!s;if(n==="after"||n==="before"){let a=$u(e,r);return s?a==="components":a==="root"||a==="temp"}return n==="firstChildOf"||n==="lastChildOf"?s?r==="components":r==="app"||r==="temp":!1}var Ls=f(()=>{Th();i(Tr,"canMoveFrame")});function k$(e){return e?e.ex&&e.ex in Fs?Fs[e.ex]:e.tagName&&e.tagName in Fs?Fs[e.tagName]:e.type&&e.type in Fs?Fs[e.type]:e.childrenType??null:null}var Fs,$$=f(()=>{Fs={layout:"*",div:"*",section:"*",header:"*",footer:"*",article:"*",main:"*",aside:"*",nav:"*",form:"*",template:"*",text:"text",heading:"text",h1:"text",h2:"text",h3:"text",h4:"text",h5:"text",h6:"text",paragraph:"text",p:"text",span:"text",label:"text",blockquote:"text",pre:"text",codeElement:"text",strong:"text",em:"text",small:"text",mark:"text",ul:["li"],ol:["li"],li:"*",dl:["dt","dd"],dt:"text",dd:"text",table:["thead","tbody","tfoot","tr"],thead:["tr"],tbody:["tr"],tfoot:["tr"],tr:["td","th"],td:"*",th:"*",interactive:"text",button:"text",a:"text",summary:"text",details:"*",dialog:"*",input:null,checkbox:null,radio:null,email:null,password:null,phone:null,color:null,date:null,file:null,hidden:null,number:null,range:null,search:null,textInput:null,select:"options",textarea:"text",media:null,img:null,audio:null,iframe:null,video:"*",figure:"*",figcaption:"text",fieldset:"*",legend:"text",meter:null,progress:null,slot:"*",frame:"*",component:"children"};i(k$,"getChildrenType")});function Vt(e,t,r=null){if(t==="app"||t==="temp"||t==="components")return!0;let n=k$(e.get([t]));return!n||n==="text"?!1:n==="*"||n==="children"||n==="options"?!0:Array.isArray(n)?r===null?!0:n.includes(r):!1}var mo=f(()=>{$$();i(Vt,"canAcceptChildren")});var E$={};R(E$,{moveNodeToLastChildOf:()=>Qr});function Qr(e,t,r){if(!_t(e,r)||!_t(e,t))return;let n=e.get([t,"ex"])??e.get([t,"type"]);if(Vt(e,r,n)){if(!Tr(e,t,r,"lastChildOf")){Rt(e,t);return}return e.update([r,"children"],(o=[])=>{let s=o.indexOf(t);if(s!==-1){let a=[...o];return a.splice(s,1),[...a,t]}return[...o,t]}),Ye(e,t,r),!0}}var Us=f(()=>{Ls();mo();Rs();fo();Xr();i(Qr,"moveNodeToLastChildOf")});function qs(e,t,r){if(!Tr(e,t,r,"after")){Rt(e,t);return}if(e.get(["app","children"])?.includes(r))return e.update(["app","children"],(c=[])=>{let l=c.indexOf(r);if(l===-1)return[...c,t];let u=[...c];return u.splice(l+1,0,t),u}),Ye(e,t,"app"),!0;let o=e.findWhen("children","includes",r);if(!o)return new Error("Failed to move node after: parent not found");let s=o[0],a=e.get([t,"ex"])??e.get([t,"type"]);if(Vt(e,s,a))return e.update(o,(c=[])=>{let l=c.indexOf(r);if(l===-1)return[...c,t];let u=[...c];return u.splice(l+1,0,t),u}),Ye(e,t,s),!0}var Eu=f(()=>{Ls();mo();fo();Xr();i(qs,"moveNodeAfter")});function Nu(e,t,r){if(!Tr(e,t,r,"before")){Rt(e,t);return}if(e.get(["app","children"])?.includes(r))return Rt(e,t),!0;let o=e.findWhen("children","includes",r);if(!o)return new Error("Failed to move node before: parent not found");let s=o[0],a=e.get([t,"ex"])??e.get([t,"type"]);if(Vt(e,s,a))return e.update(o,(c=[])=>{let l=c.indexOf(r);if(l===-1)return[t,...c];let u=[...c];return u.splice(l,0,t),u}),Ye(e,t,s),!0}var zh=f(()=>{fo();Ls();mo();Xr();i(Nu,"moveNodeBefore")});function ja(e){let t=Object.keys(e),r={},n=new Map;t.forEach(c=>{let l=za();n.set(c,l)}),t.forEach(c=>{let l=n.get(c),d={...e[c]};d.children&&Array.isArray(d.children)&&(d.children=d.children.map(p=>n.get(p)||null).filter(p=>p!==null)),d.slots&&Array.isArray(d.slots)&&(d.slots=d.slots.map(p=>({...p,id:n.get(p.id)??p.id,children:(p.children||[]).map(h=>n.get(h)??h)}))),d.type==="frame"&&(d.route=d.route?{...d.route,path:`${l}`}:{path:`${l}`}),r[l]=d});let o=Object.keys(r),s=new Set;return Object.values(r).forEach(c=>{c.children&&Array.isArray(c.children)&&c.children.forEach(l=>{l&&s.add(l)})}),[o.filter(c=>!s.has(c)),r]}var Tu=f(()=>{Ca();i(ja,"cloneNodes")});function zu(e,t,{parent:r,after:n,before:o,root:s,temp:a}={}){let[c,l]=ja(t);for(let[u,d]of Object.entries(l))e.set(u,d);if(a)for(let u of c)bu(e,u);if(s)for(let u of c)Rt(e,u);if(r)for(let u of c)Qr(e,u,r);if(n)for(let u of c)qs(e,u,n),n=u;if(o)for(let u of c)Nu(e,u,o),o=u;return c}var Ch=f(()=>{Sh();fo();Us();Eu();zh();Tu();i(zu,"pasteNodes")});function Cu(e,t){let r=dr(e,t),n=[t,...r],o={};for(let s of n){let a=e.get([s]);a&&(o[s]=a)}return As(o)}var Ih=f(()=>{Os();wu();i(Cu,"copyNode")});function Iu(e,t){let r=[];for(let n of t){let o=Cu(e,n);r=r.concat(zu(e,o,{after:n}))}return r}var Ph=f(()=>{Ih();Ch();i(Iu,"duplicateNodes")});function Gt(e,t){let r=e.get([t,"locked"]);return!r||!r.includes("*")}var Hs=f(()=>{i(Gt,"canEditNode")});import{defineContracts as b4}from"@jucie.io/engine-message";var S4,N$=f(()=>{c$();u$();Ch();Ph();Hs();Xr();S4=b4("node:clipboard",e=>{let t=e("state")?.ref(["nodes"])??null;if(!t)throw new Error("Node cache not found");return{cut:{namespace:"scene-graph",schema:["Array"],handler:r=>{let n=r.filter(s=>Gt(t,s));return n.length===0?{}:a$(t,n)}},copy:{namespace:"scene-graph",schema:["Array"],handler:r=>l$(t,r)},paste:{namespace:"scene-graph",schema:["Object","Object"],handler:(r,n)=>{let o=zu(t,r,n);if(n.parent)for(let s of o)Ye(t,s,n.parent);return o}},duplicate:{namespace:"scene-graph",schema:["Array","Object","Object"],handler:(r,n,o)=>{let s=Iu(t,r,n);o&&typeof o=="function"&&o(s)}}}})});function T$(e,t,r){return e.set([t,"contextName"],r)}var z$=f(()=>{i(T$,"setContextName")});function C$(e,t,r){return e.set([t,"contextName"],r)}var I$=f(()=>{i(C$,"updateContextName")});function P$(e,t){return e.remove([t,"contextName"])}var R$=f(()=>{i(P$,"clearContextName")});import{defineContracts as k4}from"@jucie.io/engine-message";var $4,O$=f(()=>{z$();I$();R$();$4=k4("node:contextName",e=>{let t=e("state")?.ref(["nodes"])??null;if(!t)throw new Error("Node cache not found");return{set:{schema:["String","String"],handler:(r,n)=>{T$(t,r,n)},namespace:"scene-graph"},update:{schema:["String","String"],handler:(r,n)=>{C$(t,r,n)},namespace:"scene-graph"},clear:{schema:["String"],handler:r=>{P$(t,r)},namespace:"scene-graph"}}})});function Pu({name:e,mode:t,...r}={}){return Se({name:e,mode:t??"binding",...r})}var Rh=f(()=>{Ht();i(Pu,"createState")});var A$={};R(A$,{addState:()=>Oh});function Oh(e,t,r){return e.unshift([t,"states"],Pu({name:r}))}var Ah=f(()=>{Rh();i(Oh,"addState")});var j$={};R(j$,{updateState:()=>jh});function jh(e,t,r,n){return e.setWhere([t,"states"],{name:r},Pu(n))}var Dh=f(()=>{Rh();i(jh,"updateState")});var D$={};R(D$,{removeState:()=>Mh});function Mh(e,t,r){return e.removeWhere([t,"states"],{name:r})}var Zh=f(()=>{i(Mh,"removeState")});import{defineContracts as E4}from"@jucie.io/engine-message";var N4,M$=f(()=>{Ah();Dh();Zh();N4=E4("node:state",e=>{let t=e("state")?.ref(["nodes"])??null;if(!t)throw new Error("Node cache not found");return{add:{namespace:"scene-graph",schema:["String","String"],handler:(r,n)=>Oh(t,r,n)},update:{namespace:"scene-graph",schema:["String","String","Object"],handler:(r,n,o)=>jh(t,r,n,o)},remove:{namespace:"scene-graph",schema:["String","String"],handler:(r,n)=>Mh(t,r,n)}}})});var Z$,L$=f(()=>{Z$={__version:1,type:"node",render:{name:null,mode:"value",value:!0,binding:null,computed:null,code:null,error:null},name:null,layout:"none",draggable:!0,resizable:!0,selectable:!0,locked:[],anchor:[],dimensions:[],expandedStyles:[],childrenType:null,repeat:null,contextName:null,attributes:[],events:[],className:[],states:[],lifecycle:[],animations:[],style:{}}});var F$,U$=f(()=>{F$={type:"element",ex:"node",style:{default:{}}}});var q$,H$=f(()=>{q$={type:"container",ex:"node",childrenType:"*",bounds:{width:0,height:0,x:0,y:0},breakpoints:[{name:"Mobile",type:"mobile",min:320,editable:!1},{name:"Tablet",type:"mobile",min:768,editable:!1},{name:"Desktop",type:"desktop",min:1280,editable:!1}]}});var Lh={};R(Lh,{article:()=>R4,aside:()=>A4,div:()=>z4,footer:()=>P4,form:()=>D4,header:()=>I4,layout:()=>T4,main:()=>O4,nav:()=>j4,section:()=>C4,template:()=>M4});var T4,z4,C4,I4,P4,R4,O4,A4,j4,D4,M4,B$=f(()=>{T4={ex:"element",anchor:["top","left"],dimensions:["width","height"],childrenType:"*",children:[]},z4={ex:"layout",tagName:"div"},C4={ex:"layout",tagName:"section"},I4={ex:"layout",tagName:"header"},P4={ex:"layout",tagName:"footer"},R4={ex:"layout",tagName:"article"},O4={ex:"layout",tagName:"main"},A4={ex:"layout",tagName:"aside"},j4={ex:"layout",tagName:"nav"},D4={ex:"layout",tagName:"form"},M4={ex:"layout",tagName:"template",html:"<div>HTML template</div>",style:{default:{width:"250px",height:"100px"}}}});var Fh={};R(Fh,{createTextContent:()=>ye});function Z4(e){if(typeof e=="string"){let t=e.trim();return t?[t]:null}if(Array.isArray(e)){let t=e.filter(r=>typeof r=="string"&&r.trim());return t.length>0?t:null}return null}function ye({value:e="",mode:t,specificPatterns:r,...n}={}){let o=Z4(r);return{...Se({mode:t??"value",value:e,...n}),...o?{specificPatterns:o}:{}}}var en=f(()=>{Ht();i(Z4,"normalizeSpecificPatterns");i(ye,"createTextContent")});var Uh={};R(Uh,{blockquote:()=>X4,br:()=>iF,codeElement:()=>eF,em:()=>rF,h1:()=>U4,h2:()=>q4,h3:()=>H4,h4:()=>B4,h5:()=>V4,h6:()=>G4,heading:()=>F4,hr:()=>sF,label:()=>Y4,mark:()=>oF,p:()=>K4,paragraph:()=>W4,pre:()=>Q4,small:()=>nF,span:()=>J4,strong:()=>tF,text:()=>L4});var L4,F4,U4,q4,H4,B4,V4,G4,W4,K4,J4,Y4,X4,Q4,eF,tF,rF,nF,oF,sF,iF,V$=f(()=>{en();L4={ex:"element",anchor:["top","left"],dimensions:["width"],childrenType:"text",textContent:ye({value:""})},F4={ex:"text",textContent:ye({value:""}),style:{default:{margin:"0"}}},U4={ex:"heading",tagName:"h1",textContent:ye({value:"Heading 1"})},q4={ex:"heading",tagName:"h2",textContent:ye({value:"Heading 2"})},H4={ex:"heading",tagName:"h3",textContent:ye({value:"Heading 3"})},B4={ex:"heading",tagName:"h4",textContent:ye({value:"Heading 4"})},V4={ex:"heading",tagName:"h5",textContent:ye({value:"Heading 5"})},G4={ex:"heading",tagName:"h6",textContent:ye({value:"Heading 6"})},W4={ex:"text",textContent:ye({value:"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua."}),style:{default:{margin:"0"}}},K4={ex:"paragraph",tagName:"p"},J4={ex:"text",tagName:"span",textContent:ye({value:"Lorem ipsum"})},Y4={ex:"text",tagName:"label",textContent:ye({value:"Label text"})},X4={ex:"text",tagName:"blockquote",textContent:ye({value:"Blockquote text"})},Q4={ex:"text",tagName:"pre",textContent:ye({value:"Preformatted text"})},eF={ex:"text",tagName:"code",textContent:ye({value:"code"})},tF={ex:"text",tagName:"strong",textContent:ye({value:"Bold text"})},rF={ex:"text",tagName:"em",textContent:ye({value:"Emphasized text"})},nF={ex:"text",tagName:"small",textContent:ye({value:"Small text"})},oF={ex:"text",tagName:"mark",textContent:ye({value:"Highlighted text"})},sF={ex:"element",tagName:"hr",anchor:["top","left"],dimensions:["width"],childrenType:"none"},iF={ex:"element",tagName:"br",anchor:["top","left"],dimensions:["width"],childrenType:"none"}});var qh={};R(qh,{a:()=>lF,button:()=>cF,details:()=>uF,dialog:()=>pF,interactive:()=>aF,summary:()=>dF});var aF,cF,lF,uF,dF,pF,G$=f(()=>{en();aF={ex:"element",interactive:!0,childrenType:"text",anchor:["top","left"],style:{default:{width:"auto",height:"auto",cursor:"pointer"}}},cF={ex:"interactive",tagName:"button",dimensions:["width","height"],textContent:ye({value:"Button text"}),style:{default:{"background-color":"#e9e9e9",border:"1px solid #d5d5d5","border-radius":"4px",padding:"6px 12px",width:"120px",height:"auto"}}},lF={ex:"interactive",tagName:"a",textContent:ye({value:"Link text"}),destination:{type:"page",id:null,path:null,target:null,replace:!1,params:null,query:null}},uF={ex:"interactive",tagName:"details",childrenType:"*",dimensions:["width","height"],style:{default:{cursor:"default"}}},dF={ex:"interactive",tagName:"summary",textContent:ye({value:"Summary text"})},pF={ex:"interactive",tagName:"dialog",childrenType:"*",dimensions:["width","height"],style:{default:{cursor:"default",width:"300px",height:"200px"}}}});var Bh={};R(Bh,{checkbox:()=>kF,color:()=>bF,date:()=>SF,email:()=>gF,file:()=>EF,hidden:()=>NF,input:()=>mF,number:()=>xF,password:()=>yF,phone:()=>vF,radio:()=>$F,range:()=>wF,search:()=>_F,select:()=>TF,textInput:()=>hF,textarea:()=>zF});var Ot,fF,At,zr,Hh,mF,hF,gF,yF,xF,_F,vF,wF,bF,SF,kF,$F,EF,NF,TF,zF,W$=f(()=>{Ht();Ot=i(e=>Se({name:"type",mode:"value",value:e,removable:!1}),"type"),fF=i(()=>Se({name:"value",mode:"value",value:"",removable:!1}),"value"),At=i(()=>Se({name:"model",mode:"binding",binding:null,removable:!0}),"model"),zr=i(()=>Se({name:"onInput",mode:"code",code:_u,removable:!1}),"onInput"),Hh=i(()=>Se({name:"onChange",mode:"code",code:_u,removable:!1}),"onChange"),mF={ex:"element",tagName:"input",anchor:["top","left"],dimensions:["width"],childrenType:"none",style:{default:{width:"auto",height:"auto"}}},hF={ex:"input",attributes:[Ot("text"),At()],events:[zr()]},gF={ex:"input",attributes:[Ot("email"),At()],events:[zr()]},yF={ex:"input",attributes:[Ot("password"),At()],events:[zr()]},xF={ex:"input",attributes:[Ot("number"),At()],events:[zr()]},_F={ex:"input",attributes:[Ot("search"),At()],events:[zr()]},vF={ex:"input",attributes:[Ot("tel"),At()],events:[zr()]},wF={ex:"input",attributes:[Ot("range"),At()],events:[zr()]},bF={ex:"input",attributes:[Ot("color"),At()],events:[zr()]},SF={ex:"input",attributes:[Ot("date"),At()],events:[zr()]},kF={ex:"input",attributes:[Ot("checkbox"),At()],events:[Hh()]},$F={ex:"input",attributes:[Ot("radio"),At()],events:[Hh()]},EF={ex:"input",attributes:[Ot("file")]},NF={ex:"input",attributes:[Ot("hidden"),fF()]},TF={ex:"input",tagName:"select",childrenType:"options",attributes:[At()],events:[Hh()]},zF={ex:"input",tagName:"textarea",childrenType:"text",dimensions:["width","height"],attributes:[At()],events:[zr()]}});var Vh={};R(Vh,{audio:()=>PF,figcaption:()=>AF,figure:()=>OF,iframe:()=>jF,img:()=>IF,media:()=>CF,video:()=>RF});var K$,CF,IF,PF,RF,OF,AF,jF,J$=f(()=>{Ht();K$=Se({name:"controls",mode:"value",value:!0,removable:!1}),CF={ex:"element",anchor:["top","left"],dimensions:["width","height"],style:{default:{display:"block",width:"auto",height:"auto","object-fit":"contain"}}},IF={ex:"media",tagName:"img",childrenType:"none"},PF={ex:"media",tagName:"audio",childrenType:"none",dimensions:["width"],attributes:[K$],style:{default:{width:"320px"}}},RF={ex:"media",tagName:"video",childrenType:"*",attributes:[K$],style:{default:{width:"320px",height:"240px"}}},OF={ex:"media",tagName:"figure",childrenType:"*",dimensions:["width","height"],style:{default:{width:"auto",height:"auto",margin:"0"}}},AF={ex:"media",tagName:"figcaption",childrenType:"text"},jF={ex:"media",tagName:"iframe",childrenType:"none",dimensions:["width","height"]}});var Gh={};R(Gh,{dd:()=>UF,dl:()=>LF,dt:()=>FF,li:()=>ZF,ol:()=>DF,ul:()=>MF});var DF,MF,ZF,LF,FF,UF,Y$=f(()=>{DF={ex:"element",tagName:"ol",anchor:["top","left"],dimensions:["width"],childrenType:["li"],children:[]},MF={ex:"element",tagName:"ul",anchor:["top","left"],dimensions:["width"],childrenType:["li"],children:[]},ZF={ex:"element",tagName:"li",anchor:["top","left"],dimensions:["width"],childrenType:"*"},LF={ex:"element",tagName:"dl",anchor:["top","left"],dimensions:["width"],childrenType:["dt","dd"],children:[]},FF={ex:"element",tagName:"dt",anchor:["top","left"],dimensions:["width"],childrenType:"text"},UF={ex:"element",tagName:"dd",anchor:["top","left"],dimensions:["width"],childrenType:"text"}});var Wh={};R(Wh,{table:()=>qF,tbody:()=>BF,td:()=>KF,tfoot:()=>VF,th:()=>WF,thead:()=>HF,tr:()=>GF});var qF,HF,BF,VF,GF,WF,KF,X$=f(()=>{qF={ex:"element",tagName:"table",anchor:["top","left"],dimensions:["width"],childrenType:["thead","tbody","tfoot","tr"],children:[]},HF={ex:"element",tagName:"thead",childrenType:["tr"],children:[]},BF={ex:"element",tagName:"tbody",childrenType:["tr"],children:[]},VF={ex:"element",tagName:"tfoot",childrenType:["tr"],children:[]},GF={ex:"element",tagName:"tr",childrenType:["td","th"],children:[]},WF={ex:"element",tagName:"th",childrenType:"*"},KF={ex:"element",tagName:"td",childrenType:"*"}});var Kh={};R(Kh,{fieldset:()=>JF,legend:()=>YF,meter:()=>XF,progress:()=>QF});var JF,YF,XF,QF,Q$=f(()=>{JF={ex:"element",tagName:"fieldset",anchor:["top","left"],dimensions:["width","height"],childrenType:"children",style:{default:{border:"1px solid #cccccc",padding:"16px"}}},YF={ex:"element",tagName:"legend",childrenType:"text"},XF={ex:"element",tagName:"meter",childrenType:"none"},QF={ex:"element",tagName:"progress",childrenType:"none"}});var Jh={};R(Jh,{slot:()=>e9});var e9,eE=f(()=>{e9={type:"slot",ex:"element",tagName:"slot",anchor:["top","left"],dimensions:["width","height"],childrenType:"*"}});var tE,rE=f(()=>{tE={type:"frame",ex:"container",tagName:"div",bounds:{top:0,left:0,width:360,height:740,x:void 0,y:void 0},style:{default:{background:"white"}},children:[],route:{path:null}}});var nE,oE=f(()=>{nE={type:"instance",ex:"node",component:null,library:null,props:[],childrenType:"component"}});var sE,iE=f(()=>{sE={type:"code",ex:"node",body:"",language:"js",params:[],returns:null}});var aE,cE=f(()=>{aE={type:"animation",ex:"node",scope:"node",name:null,duration:300,easing:"ease",fill:"none",direction:"normal",iterations:1,delay:0,endDelay:0,iterationStart:0,composite:"replace",keyframes:[]}});var lE,uE=f(()=>{lE={type:"component",ex:"container",name:"",library:"local",props:[],emits:[],data:[],children:[]}});var dE,pE=f(()=>{dE={type:"graphic",ex:"node",tagName:"div",props:{},template:[],style:{default:{margin:"0",width:"100px",height:"100px"}}}});var ho,Ru=f(()=>{L$();U$();H$();B$();V$();G$();W$();J$();Y$();X$();Q$();eE();rE();oE();iE();cE();uE();pE();Xh();ju();ho={node:Z$,element:F$,container:q$,...Lh,...Uh,...qh,...Bh,...Vh,...Gh,...Wh,...Kh,...Jh,frame:tE,instance:nE,code:sE,animation:aE,component:lE,graphic:dE}});function Ou(e){let t=[],r=e;for(;r&&ho[r];)t.push(r),r=ho[r].ex;return t}function Au(e){return ho[e]?.ex??null}function Bs(e){return!!ho[e]}function Yh(e){let t=e?.ex??e?.type;for(let r of Ou(t))if(t9.has(r))return r;return null}var t9,Xh=f(()=>{Ru();i(Ou,"chainOf");i(Au,"baseOf");i(Bs,"isKnownType");t9=new Set(["element","container","frame","instance","component","slot","animation","graphic","code","node"]);i(Yh,"categoryOf")});function r9(e,t){let r=new Map(e.map(n=>[n.name,n]));for(let n of t)r.set(n.name,n);return Array.from(r.values())}function fE(e,t){let r=Ou(e).reverse(),n=[];for(let o of r){let s=ho[o];s?.[t]&&(n=r9(n,s[t]))}return n}function Vs(e,t={}){if(!Bs(e))throw new Error(`createNode: unknown prototype "${e}". Did you mean to register it first?`);let r=Yh({type:e}),n=r===e?{type:e,...t}:{type:r,ex:e,...t};if(!n.attributes){let o=fE(e,"attributes");o.length&&(n.attributes=o.map(s=>({...s})))}if(!n.events){let o=fE(e,"events");o.length&&(n.events=o.map(s=>({...s})))}return[za(),n]}var ju=f(()=>{xu();Xh();Ru();i(r9,"mergeByName");i(fE,"resolveDescriptors");i(Vs,"createNode")});function Da(e){return Du.find(t=>t.key===e)??null}function Qh(){return Du.map(e=>e.key)}function Ma(e,t={}){if(e==="custom")return{name:t.name||"Custom",bounds:{width:t.width??mE.width,height:t.height??mE.height,x:0,y:0}};let r=Da(e);if(!r)throw new Error(`Unknown frame preset "${e}". Available: ${Qh().join(", ")}`);return{name:e,bounds:{width:r.width,height:r.height,x:0,y:0}}}var Du,mE,go=f(()=>{Du=[{key:"iPhone 15",category:"phone",width:393,height:852},{key:"iPhone SE",category:"phone",width:375,height:667},{key:"Pixel 8",category:"phone",width:412,height:915},{key:"Galaxy S24",category:"phone",width:360,height:780},{key:"iPad Air",category:"tablet",width:820,height:1180},{key:"iPad Mini",category:"tablet",width:768,height:1024},{key:"Surface Pro",category:"tablet",width:912,height:1368},{key:"Desktop",category:"desktop",width:1280,height:800},{key:"Desktop Large",category:"desktop",width:1920,height:1080},{key:"custom",category:"custom",width:null,height:null}];i(Da,"getFramePreset");i(Qh,"getAvailableFrames");mE={width:360,height:740,x:0,y:0};i(Ma,"createFrameOverrides")});function n9(e={}){let t=e.frame??e.viewport;if(!t)return e;let{frame:r,viewport:n,width:o,height:s,name:a,bounds:c,...l}=e,{name:u,bounds:d}=Ma(t,{name:a,width:o,height:s});return{...l,frame:t,name:u,bounds:{x:c?.x??d.x??0,y:c?.y??d.y??0,width:c?.width??d.width,height:c?.height??d.height}}}function Pn(e,t,r={}){let n=t==="frame"?n9(r):r,[o,s]=Vs(t,n);return t==="frame"&&(s.route={path:`${o}`}),e.set([o],s),o}var Za=f(()=>{ju();go();i(n9,"buildFrameNodeProps");i(Pn,"createNodeEntry")});var tg={};R(tg,{addNode:()=>eg});function eg(e,t,r,n="app"){let o=Pn(e,t,r);return Qr(e,o,n),o}var Mu=f(()=>{Za();Us();i(eg,"addNode")});function hE(e,t,r){let n=Pn(e,t,r);return bu(e,n),n}var gE=f(()=>{Za();Sh();i(hE,"addTemp")});function s9(e,t){let r=e.get([t,"children"])??[],n=0;for(let o of r){let s=e.get([o]);if(s?.type!=="slot")continue;let a=o9.exec(s.name??"");a&&(n=Math.max(n,Number(a[1])))}return`Slot ${n+1}`}function yE(e,t,r={}){let n=r.name??s9(e,t),o=Pn(e,"slot",{...r,name:n});return e.update([t,"children"],(s=[])=>[...s,o]),o}var o9,xE=f(()=>{Za();o9=/^Slot (\d+)$/;i(s9,"nextSlotName");i(yE,"addSlot")});function _E(e,t,r){if(!_t(e,t)||!_t(e,r))return!1;let n=e.findWhen("children","includes",t);return n?(e.update(n,(o=[])=>o.map(s=>s===t?r:s)),!0):!1}var vE=f(()=>{Rs();i(_E,"replaceNode")});var bE={};R(bE,{addComponent:()=>rg});function a9(e,t,r,n){let o=e.get([t,"style"]);if(!o)return;let s=new Set(n??[]);for(let a in o){let c=o[a];if(!c||typeof c!="object")continue;let l={},u=!1;for(let d of wE)d in c&&s.has(d)&&(l[d]=c[d],u=!0);u&&(e.update([r,"style",a],(d={})=>({...d,...l})),e.update([t,"style",a],(d={})=>{let p={...d};for(let h of i9)delete p[h];return p}))}}function rg(e,t,r,n=null){let o=e.get([t,".position"]),s=e.get([t,"anchor"]),a=e.get([t,"dimensions"]),c=Cu(e,t),[l,u]=ja(c),d=l[0];for(let[x,v]of Object.entries(u))e.set([x],v);let[p,h]=Vs("component",{children:[d],name:r,bounds:n}),[m,g]=Vs("instance",{component:p});e.set([p],h),e.set([m],g),e.update(["components","children"],(x=[])=>x.indexOf(p)===-1?[...x,p]:x),_E(e,t,m);let _=dr(e,t);for(let x of _)e.remove([x]);return e.remove([t]),o&&e.set([m,".position"],o),s&&e.set([m,"anchor"],s),a&&e.set([m,"dimensions"],a),a9(e,d,m,s),e.set([d,"isComponentRoot"],!0),e.set([d,"anchor"],[]),m}var wE,i9,ng=f(()=>{ju();vE();Ih();Tu();Os();wE=["top","left","right","bottom"],i9=[...wE];i(a9,"migratePositionalStyles");i(rg,"addComponent")});import{defineContracts as c9}from"@jucie.io/engine-message";var l9,SE=f(()=>{Mu();Us();Eu();gE();xE();Ph();ng();Zs();Ms();Za();l9=c9("node:add",e=>{let t=e("state")?.ref(["nodes"])??null;if(!t)throw new Error("Node cache not found");return{element:{namespace:"scene-graph",schema:["String","Object","Object"],handler:(r,n,o)=>{if(r==="slot")return[yE(t,o?.parent??"app",n)];let s=Pn(t,r,n);return o?.after?qs(t,s,o.after):Qr(t,s,o?.parent??"app"),[s]}},tempNode:{namespace:"scene-graph",schema:["String","Object"],handler:(r,n)=>[hE(t,r,n)]},component:{namespace:"scene-graph",schema:["String","String","Object"],handler:(r,n,o)=>[rg(t,r,n,o)]},duplicates:{namespace:"scene-graph",schema:["Array"],handler:r=>{for(let o of r)Bt(t,o);return Iu(t,r)}},images:{namespace:"scene-graph",schema:["Array"],handler:r=>{let n=[],o=t.batch();for(let s of r){let a=eg(t,"element",{tagName:"img",attributes:[{name:"src",value:s.url},{name:"alt",value:s.meta.name}]});n.push(a)}return o(),n}}}})});function Zu({name:e,mode:t,...r}={}){return Se({name:e,mode:t??"binding",...r})}var og=f(()=>{Ht();i(Zu,"createEvent")});var kE={};R(kE,{addEvent:()=>sg});function sg(e,t,r){return e.unshift([t,"events"],Zu({name:r}))}var ig=f(()=>{og();i(sg,"addEvent")});var cg={};R(cg,{updateEvent:()=>ag});function ag(e,t,r,n){return e.setWhere([t,"events"],{name:r},Zu(n))}var Lu=f(()=>{og();i(ag,"updateEvent")});var $E={};R($E,{removeEvent:()=>lg});function lg(e,t,r){return e.removeWhere([t,"events"],{name:r})}var ug=f(()=>{i(lg,"removeEvent")});import{defineContracts as u9}from"@jucie.io/engine-message";var d9,EE=f(()=>{ig();Lu();ug();d9=u9("node:event",e=>{let t=e("state")?.ref(["nodes"])??null;if(!t)throw new Error("Node cache not found");return{add:{namespace:"scene-graph",schema:["String","String"],handler:(r,n)=>sg(t,r,n)},update:{namespace:"scene-graph",schema:["String","String","Object"],handler:(r,n,o)=>ag(t,r,n,o)},remove:{namespace:"scene-graph",schema:["String","String"],handler:(r,n)=>lg(t,r,n)}}})});function Fu({name:e,mode:t,...r}={}){return Se({name:e,mode:t??"value",...r})}var dg=f(()=>{Ht();i(Fu,"createAttribute")});var NE={};R(NE,{removeAttribute:()=>La});function La(e,t,r){typeof e.removeAllWhere=="function"?e.removeAllWhere([t,"attributes"],{name:r}):e.removeWhere([t,"attributes"],{name:r})}var Uu=f(()=>{i(La,"removeAttribute")});function qu(e,t,r){if(!p9.has(r))return[];let n=r==="model"?["value","checked"]:["model"],o=[];for(let s of n)(e.get([t,"attributes"])??[]).some(c=>c.name===s)&&(La(e,t,s),o.push(s));return e.get([t,"model"])!=null&&e.remove([t,"model"]),o}var p9,pg=f(()=>{Uu();p9=new Set(["model","value","checked"]);i(qu,"clearValueChannelConflict")});var TE={};R(TE,{addAttribute:()=>fg});function fg(e,t,r={}){let o=Fu(typeof r=="string"?{name:r}:r);return o.name&&qu(e,t,o.name),e.unshift([t,"attributes"],o)}var mg=f(()=>{dg();pg();i(fg,"addAttribute")});var zE={};R(zE,{updateAttribute:()=>hg});function hg(e,t,r,n){let o=Fu(n),s=o.name??r;qu(e,t,s),e.findWhere([t,"attributes"],{name:r})!==void 0?e.setWhere([t,"attributes"],{name:r},o):e.push([t,"attributes"],o)}var gg=f(()=>{dg();pg();i(hg,"updateAttribute")});import{defineContracts as f9}from"@jucie.io/engine-message";var m9,CE=f(()=>{mg();gg();Uu();m9=f9("node:attribute",e=>{let t=e("state")?.ref(["nodes"])??null;if(!t)throw new Error("Node cache not found");return{add:{namespace:"scene-graph",schema:["String","String"],handler:(r,n)=>fg(t,r,n)},update:{namespace:"scene-graph",schema:["String","String","Object"],handler:(r,n,o)=>hg(t,r,n,o)},remove:{namespace:"scene-graph",schema:["String","String"],handler:(r,n)=>La(t,r,n)}}})});function Fa({name:e,mode:t,...r}={}){return Se({name:e,mode:t??"value",...r})}var Hu=f(()=>{Ht();i(Fa,"createProp")});function IE(e,t,r={}){let o=Fa(typeof r=="string"?{name:r}:r);return e.unshift([t,"props"],o)}var PE=f(()=>{Hu();i(IE,"addProp")});function RE(e,t,r,n){let o=Fa(n);e.findWhere([t,"props"],{name:r})!==void 0?e.setWhere([t,"props"],{name:r},o):e.push([t,"props"],o)}var OE=f(()=>{Hu();i(RE,"updateProp")});function AE(e,t,r){typeof e.removeAllWhere=="function"?e.removeAllWhere([t,"props"],{name:r}):e.removeWhere([t,"props"],{name:r})}var jE=f(()=>{i(AE,"removeProp")});import{defineContracts as h9}from"@jucie.io/engine-message";var g9,DE=f(()=>{PE();OE();jE();g9=h9("node:prop",e=>{let t=e("state")?.ref(["nodes"])??null;if(!t)throw new Error("Node cache not found");return{add:{namespace:"scene-graph",schema:["String","Object"],handler:(r,n)=>IE(t,r,n)},update:{namespace:"scene-graph",schema:["String","String","Object"],handler:(r,n,o)=>RE(t,r,n,o)},remove:{namespace:"scene-graph",schema:["String","String"],handler:(r,n)=>AE(t,r,n)}}})});function ME(e,t,r,n){console.log("updateSlot",e,t,r,n),e.updateWhere([t,"slots"],{id:r},o=>{switch(console.log("currentSlot",o,"updatedSlot",n),o.childrenType){case"text":return{...o,textContent:Se(n)};default:return o}})}var ZE=f(()=>{en();Ht();i(ME,"updateSlot")});function LE(e=[]){if(!Array.isArray(e))return[];let t=[];for(let r of e){if(!r||typeof r=="string"||!r.id)continue;let n=r.childrenType??"children";if(r.required===!0||n==="text"&&r.textContent!=null){if(n==="text"){let s=r.textContent?.value??"";t.push({id:r.id,name:r.name,childrenType:"text",textContent:ye({value:s}),children:null});continue}t.push({id:r.id,name:r.name,childrenType:n,textContent:null,children:[]})}}return t}function yg(e=[],t=[]){let r=Array.isArray(e)?[...e]:[],n=new Set(r.map(o=>o?.id).filter(Boolean));for(let o of LE(t))n.has(o.id)||(r.push(o),n.add(o.id));return r}var xg=f(()=>{en();i(LE,"buildSlotsFromMeta");i(yg,"mergeMissingSlotsFromMeta")});function FE(e,t,r=[]){if(!t)return;let n=e.get([t,"slots"])??[],o=yg(n,r),s=new Set(n.map(c=>c?.id).filter(Boolean));o.some(c=>c?.id&&!s.has(c.id))&&e.set([t,"slots"],o)}var UE=f(()=>{xg();i(FE,"ensureSlotsFromMeta")});import{defineContracts as y9}from"@jucie.io/engine-message";var x9,qE=f(()=>{ZE();UE();x9=y9("node:slot",e=>{let t=e("state")?.ref(["nodes"])??null;if(!t)throw new Error("Node cache not found");return{update:{namespace:"scene-graph",schema:["String","String","Object"],handler:(r,n,o)=>{console.log("updateSlot",r,n,o),ME(t,r,n,o)}},ensureFromMeta:{namespace:"scene-graph",schema:["String","Array"],handler:(r,n)=>{FE(t,r,n)}}}})});var HE={};R(HE,{updateHtml:()=>_g});function _g(e,t,r){return e.set([t,"html"],r)}var vg=f(()=>{i(_g,"updateHtml")});import{defineContracts as _9}from"@jucie.io/engine-message";var v9,BE=f(()=>{vg();v9=_9("node:html",e=>{let t=e("state")?.ref(["nodes"])??null;if(!t)throw new Error("Node cache not found");return{update:{schema:["String","String"],handler:(r,n)=>{_g(t,r,n)},namespace:"scene-graph"}}})});function Bu({path:e=null,target:t=null,id:r=null,type:n="url",replace:o=!1,params:s=[],query:a=null}){return{path:e,target:t,id:r,type:n,replace:o,params:s,query:a}}var wg=f(()=>{i(Bu,"createDestination")});function VE(e,t,r){return e.update([t,"destination"],(n={})=>Bu({...n,...r}))}var GE=f(()=>{wg();i(VE,"updateDestination")});var WE={};R(WE,{setDestination:()=>bg});function bg(e,t,r={}){return e.set([t,"destination"],Bu(r))}var Sg=f(()=>{wg();i(bg,"setDestination")});var KE={};R(KE,{clearDestination:()=>kg});function kg(e,t){return e.remove([t,"destination"])}var $g=f(()=>{i(kg,"clearDestination")});import{defineContracts as w9}from"@jucie.io/engine-message";var b9,JE=f(()=>{GE();Sg();$g();b9=w9("node:destination",e=>{let t=e("state")?.ref(["nodes"])??null;if(!t)throw new Error("Node cache not found");return{set:{namespace:"scene-graph",schema:["String","Object"],handler:(r,n={})=>{bg(t,r,n)}},update:{namespace:"scene-graph",schema:["String","Object"],handler:(r,n)=>{VE(t,r,n)}},remove:{namespace:"scene-graph",schema:["String"],handler:r=>{kg(t,r)}}}})});function YE(e,t,r){return e.update([t,".position"],(n={x:0,y:0})=>({...n,...r}))}var XE=f(()=>{i(YE,"updatePosition")});import{defineContracts as S9}from"@jucie.io/engine-message";var k9,QE=f(()=>{Zs();XE();k9=S9("node:drag",e=>{let t=e("state"),r=t?.ref(["nodes"])??null,n=null;if(!t||!r)throw new Error("State or node cache not found");return{start:{namespace:"scene-graph",handler:()=>n=t.history?.group()},apply:{namespace:"scene-graph",schema:["Array"],handler:o=>{for(let[s,a]of o)s&&a[".position"]&&YE(r,s,a[".position"])}},end:{namespace:"scene-graph",schema:["Array"],handler:o=>{for(let s of o)s&&Bt(r,s);n?(n("Drag nodes"),n=null):t.history?.commit("Drag nodes")}},clear:{namespace:"scene-graph",schema:["Array"],handler:o=>{for(let s of o)s&&Bt(r,s);n&&(n(),n=null)}}}})});function Vu({key:e,mode:t,binding:r=null,code:n=""}){return{key:e,mode:t??"binding",binding:r,code:n}}var Eg=f(()=>{i(Vu,"createLifecycleHook")});var eN={};R(eN,{addLifecycleHook:()=>Ng});function Ng(e,t,r){return e.unshift([t,"lifecycle"],Vu({key:r}))}var Tg=f(()=>{Eg();i(Ng,"addLifecycleHook")});var Cg={};R(Cg,{updateLifecycleHook:()=>zg});function zg(e,t,r,n){return e.setWhere([t,"lifecycle"],{key:r},Vu(n))}var Gu=f(()=>{Eg();i(zg,"updateLifecycleHook")});var tN={};R(tN,{removeLifecycleHook:()=>Ig});function Ig(e,t,r){return e.removeWhere([t,"lifecycle"],{key:r})}var Pg=f(()=>{i(Ig,"removeLifecycleHook")});import{defineContracts as $9}from"@jucie.io/engine-message";var E9,rN=f(()=>{Tg();Gu();Pg();E9=$9("node:lifecycle",e=>{let t=e("state")?.ref(["nodes"])??null;if(!t)throw new Error("Node cache not found");return{add:{namespace:"scene-graph",schema:["String","String"],handler:(r,n)=>Ng(t,r,n)},update:{namespace:"scene-graph",schema:["String","String","Object"],handler:(r,n,o)=>zg(t,r,n,o)},remove:{namespace:"scene-graph",schema:["String","String"],handler:(r,n)=>Ig(t,r,n)}}})});function nN(e,t,r){if(!(e.get([t,".interactionState"])??[]).includes(r))return e.push([t,".interactionState"],r)}var oN=f(()=>{i(nN,"addInteractionState")});function sN(e,t,r){let o=(e.get([t,".interactionState"])??[]).indexOf(r);if(o!==-1)return e.splice([t,".interactionState"],o,1)}var iN=f(()=>{i(sN,"removeInteractionState")});function aN(e,t){e.remove([t,".interactionState"])}var cN=f(()=>{i(aN,"clearInteractionState")});import{defineContracts as N9}from"@jucie.io/engine-message";var T9,lN=f(()=>{oN();iN();cN();T9=N9("node:interactionState",e=>{let t=e("state")?.ref(["nodes"])??null;if(!t)throw new Error("Node cache not found");return{add:{schema:["String","String"],namespace:"scene-graph",handler:(r,n)=>{nN(t,r,n)}},remove:{namespace:"scene-graph",schema:["String","String"],handler:(r,n)=>{sN(t,r,n)}},clear:{namespace:"scene-graph",schema:["String"],handler:r=>{aN(t,r)}}}})});import{defineContracts as z9}from"@jucie.io/engine-message";var C9,uN=f(()=>{Zs();Aa();Hs();C9=z9("node:patch",e=>{let[t,r]=e("state","sceneCompiler"),n=t?.ref(["nodes"])??null,o=null;if(!t||!n)throw new Error("State or node cache not found");return{start:{namespace:"scene-graph",schema:"*",handler:()=>{o=t.history?.group()}},apply:{namespace:"scene-graph",schema:["Array"],handler:s=>{let a=t.batch();for(let[c,l]of s){if(!c||!l||!Gt(n,c))continue;let u=r.getActiveBreakpoint(c);Yr(n,c,l,u)}a()}},end:{namespace:"scene-graph",schema:["String"],handler:(s="Patch")=>{o?(o(s),o=null):t.history?.commit(s)}},clear:{namespace:"scene-graph",schema:["Array"],handler:s=>{for(let a of s)a&&Bt(n,a);o&&(o(),o=null)}}}})});import{defineContracts as I9}from"@jucie.io/engine-message";var P9,dN=f(()=>{Aa();P9=I9("node:behavior",e=>{let t=e("state")?.ref(["nodes"])??null;if(!t)throw new Error("Node cache not found");return{set:{schema:["String","Object"],handler:(r,n)=>{w$(t,r,n)},namespace:"scene-graph"},update:{schema:["Array"],handler:r=>{for(let[n,o]of r)Yr(t,n,o)},namespace:"scene-graph"},clear:{schema:["String"],handler:r=>{b$(t,r)},namespace:"scene-graph"}}})});function Wu(e,t,r,{breakpoint:n="default",interactionState:o}={}){let s=js(n),a=o??e.get([t,".interactionState"])??[];return e.remove([t,"style",s,...a,r])}var Rg=f(()=>{ku();i(Wu,"removeStyle")});function pN(e,t,r){e.update([t,"style","default"],(n={})=>({...n,display:r}))}var fN=f(()=>{i(pN,"setDisplayMode")});var Ag={};R(Ag,{setNodeLayout:()=>Og});function Og(e,t,r){let n=r==null||r===""?"none":r;Yr(e,t,{layout:n}),n==="none"?Wu(e,t,"display"):mN[n]&&pN(e,t,mN[n]);let o=e.get([t,"children"])??[];for(let s of o)Ye(e,s,t);if(e.get([t,"type"])==="slot"){let s=e.findAllWhen("id","is",t);for(let a of s){let c=e.get(a.slice(0,-1));console.log("slotEntry",c);for(let l of c?.children??[])Ye(e,l,t)}}return{id:t,layout:n,childrenUpdated:o.length}}var mN,Ku=f(()=>{Aa();Xr();Rg();fN();mN={block:"block",flex:"flex",grid:"grid"};i(Og,"setNodeLayout")});import{defineContracts as R9}from"@jucie.io/engine-message";var O9,hN=f(()=>{Ku();Hs();O9=R9("node:layout",e=>{let t=e("state")?.ref(["nodes"])??null;if(!t)throw new Error("Node cache not found");return{set:{schema:["String","String"],handler:(r,n)=>{if(Gt(t,r))return Og(t,r,n)},namespace:"scene-graph"}}})});function gN({id:e=null,name:t=void 0,children:r=[]}={}){return{id:e,name:t,children:r}}var yN=f(()=>{i(gN,"createSlotChild")});function A9(e,t,{before:r,after:n}={}){if(e.includes(t))return e;if(r){let o=e.indexOf(r);if(o===-1)return[t,...e];let s=[...e];return s.splice(o,0,t),s}if(n){let o=e.indexOf(n);if(o===-1)return[...e,t];let s=[...e];return s.splice(o+1,0,t),s}return[...e,t]}function xN(e,t,r,{slotId:n=null,name:o=void 0,before:s,after:a}={}){if(_t(e,r)&&_t(e,t)){if(!Tr(e,t,r,"lastChildOf")){Rt(e,t);return}return e.update([r,"slots"],(c=[])=>{let l=c.findIndex(h=>h.id===n);if(l===-1)return[...c,gN({id:n,name:o,children:[t]})];let u=c[l],d=u.children||[],p=[...c];return p[l]={...u,children:A9(d,t,{before:s,after:a})},p}),Ye(e,t,n||r),!0}}var _N=f(()=>{yN();Ls();Rs();fo();Xr();i(A9,"insertIntoSlotChildren");i(xN,"moveNodeToSlotChildOf")});function Ju(e,t){if(!t)return;let r=i(o=>{if(!e.has([o]))return;let s=e.get([o,"slots"]);!Array.isArray(s)||!s.length||e.update([o,"slots"],(a=[])=>{let c=!1,l=a.map(u=>{let d=u.children||[];return d.includes(t)?(c=!0,{...u,children:d.filter(p=>p!==t)}):u});return c?l:a})},"stripFromSlots");r("app"),r("temp");let n=i(o=>{for(let s of o||[])e.has([s])&&(r(s),n(e.get([s,"children"])||[]))},"visit");n(e.get(["app","children"])),n(e.get(["temp","children"]))}var jg=f(()=>{i(Ju,"removeNodeIdFromAllInstanceSlots")});function vN(e,t,r,n){if(!_t(e,t)||!_t(e,r))return!1;let o=e.get([t,"ex"])??e.get([t,"type"]);return!(!Vt(e,r,o)||!Tr(e,t,r,n))}var wN=f(()=>{Rs();mo();Ls();i(vN,"canNestUnder")});import{defineContracts as j9}from"@jucie.io/engine-message";var D9,bN=f(()=>{Us();_N();zh();Eu();fo();Ia();jg();Zs();wN();Hs();Th();D9=j9("node:move",e=>{let t=e("state")?.ref(["nodes"])??null;if(!t)throw new Error("Node cache not found");return{apply:{namespace:"scene-graph",schema:["Array","Object"],handler:(r,n)=>{console.log("moveContracts",r,n);let o=r.filter(c=>Gt(t,c)),s=[],a=[];for(let c of o)n.before||n.after||n.instance?s.push(c):n.parent?vN(t,c,n.parent,"lastChildOf")?s.push(c):$u(t,c)==="temp"&&a.push(c):s.push(c);if(!(s.length===0&&a.length===0)){for(let c of s)Jr(t,c),Bt(t,c),Ju(t,c);if(n.instance)for(let c of s)xN(t,c,n.instance,{slotId:n.slotId,name:n.name,before:n.before,after:n.after});else if(n.before)for(let c of s)Nu(t,c,n.before);else if(n.after)for(let c of s)qs(t,c,n.after);else if(n.parent)for(let c of s)Qr(t,c,n.parent);for(let c of a)Jr(t,c),Bt(t,c),Rt(t,c)}}}}})});var SN={};R(SN,{setName:()=>Dg});function Dg(e,t,r){return e.set([t,"name"],r)}var Mg=f(()=>{i(Dg,"setName")});function kN(e,t,r){return e.set([t,"name"],r)}var $N=f(()=>{i(kN,"updateName")});var Lg={};R(Lg,{clearName:()=>Zg});function Zg(e,t){return e.remove([t,"name"])}var Yu=f(()=>{i(Zg,"clearName")});import{defineContracts as M9}from"@jucie.io/engine-message";var Z9,EN=f(()=>{Mg();$N();Yu();Z9=M9("node:name",e=>{let t=e("state")?.ref(["nodes"])??null;if(!t)throw new Error("Node cache not found");return{set:{schema:["String","String"],handler:(r,n)=>{Dg(t,r,n)},namespace:"scene-graph"},update:{schema:["String","String"],handler:(r,n)=>{console.log("updateName",r,n),kN(t,r,n)},namespace:"scene-graph"},clear:{schema:["String"],handler:r=>{Zg(t,r)},namespace:"scene-graph"}}})});function Ua({value:e,label:t}){return{value:e,label:t||e}}var Xu=f(()=>{i(Ua,"createOption")});var NN={};R(NN,{addOption:()=>Fg});function Fg(e,t,{value:r,label:n}){return e.push([t,"options","set"],Ua({value:r,label:n}))}var Ug=f(()=>{Xu();i(Fg,"addOption")});var TN={};R(TN,{updateOption:()=>qg});function qg(e,t,r,{value:n,label:o}){let s=Ua({value:n,label:o});return e.findWhere([t,"options","set"],{value:r})===void 0?e.push([t,"options","set"],s):e.setWhere([t,"options","set"],{value:r},s)}var Hg=f(()=>{Xu();i(qg,"updateOption")});var zN={};R(zN,{removeOption:()=>Bg});function Bg(e,t,r){return e.removeWhere([t,"options","set"],{value:r})}var Vg=f(()=>{i(Bg,"removeOption")});var CN={};R(CN,{setOptionsExpression:()=>Gg});function Qu(e){let t=gu(e)?gh(e):null;return{value:(e??"").trim(),expression:t,dependencies:t?Ta(t):[]}}function Gg(e,t,{binding:r,valueKey:n,labelKey:o}){let s=gu(r)?gh(r):null;return e.update([t,"options"],(a={})=>({...a,type:"binding",binding:r??a.binding,expression:s??a.expression,dependencies:s?Ta(s):a.dependencies??[],valueKey:n!==void 0?Qu(n):a.valueKey??Qu("value"),labelKey:o!==void 0?Qu(o):a.labelKey??Qu("label")}))}var Wg=f(()=>{yh();i(Qu,"parseField");i(Gg,"setOptionsExpression")});var IN={};R(IN,{clearOptionsExpression:()=>Kg});function Kg(e,t){return e.update([t,"options"],(r={})=>({...r,type:"set",binding:null,expression:null,dependencies:[],valueKey:{value:"value",expression:null,dependencies:[]},labelKey:{value:"label",expression:null,dependencies:[]}}))}var Jg=f(()=>{i(Kg,"clearOptionsExpression")});import{defineContracts as L9}from"@jucie.io/engine-message";var F9,PN=f(()=>{Ug();Hg();Vg();Wg();Jg();F9=L9("node:options",e=>{let t=e("state")?.ref(["nodes"])??null;if(!t)throw new Error("Node cache not found");return{add:{schema:["String","Object"],handler:(r,n)=>{Fg(t,r,n)},namespace:"scene-graph"},update:{schema:["String","String","Object"],handler:(r,n,o)=>{qg(t,r,n,o)},namespace:"scene-graph"},remove:{schema:["String","String"],handler:(r,n)=>{Bg(t,r,n)},namespace:"scene-graph"},setExpression:{schema:["String","Object"],handler:(r,n)=>{Gg(t,r,n)},namespace:"scene-graph"},clearExpression:{schema:["String"],handler:r=>{Kg(t,r)},namespace:"scene-graph"}}})});import{defineContracts as U9}from"@jucie.io/engine-message";var q9,RN=f(()=>{q9=U9("node:order",e=>{let t=e("state")?.ref(["nodes"])??null;if(!t)throw new Error("Node cache not found");return{bringToFront:{schema:["Array"],handler:r=>{for(let n of r){let o=t.findWhen("children","includes",n);o&&t.update(o,(s=[])=>[...s.filter(c=>c!==n),n])}},namespace:"scene-graph"},sendToBack:{schema:["Array"],handler:r=>{for(let n of r){let o=t.findWhen("children","includes",n);o&&t.update(o,(s=[])=>{let a=s.filter(c=>c!==n);return[n,...a]})}},namespace:"scene-graph"},moveForward:{schema:["Array"],handler:r=>{for(let n of r){let o=t.findWhen("children","includes",n);o&&t.update(o,(s=[])=>{let a=s.indexOf(n);if(a===-1||a===s.length-1)return s;let c=[...s];return[c[a],c[a+1]]=[c[a+1],c[a]],c})}},namespace:"scene-graph"},moveBackward:{schema:["Array"],handler:r=>{for(let n of r){let o=t.findWhen("children","includes",n);o&&t.update(o,(s=[])=>{let a=s.indexOf(n);if(a===-1||a===0)return s;let c=[...s];return[c[a],c[a-1]]=[c[a-1],c[a]],c})}},namespace:"scene-graph"}}})});var ON={};R(ON,{removeNode:()=>Yg});function Yg(e,t){let r=dr(e,t);for(let o of[t,...r])Ju(e,o);Jr(e,t);let n={};for(let o of r)Jr(e,o),n[o]=e.remove(o);return n[t]=e.remove([t]),[t,n]}var Xg=f(()=>{Ia();Os();jg();i(Yg,"removeNode")});import{defineContracts as H9}from"@jucie.io/engine-message";var B9,AN=f(()=>{Xg();B9=H9("node:remove",e=>{let t=e("state")?.ref(["nodes"])??null;if(!t)throw new Error("Node cache not found");return{nodes:{namespace:"scene-graph",schema:["Array"],handler:r=>{for(let n of r)Yg(t,n)}}}})});function ed({mode:e,...t}={}){return Se({mode:e??"value",...t})}var Qg=f(()=>{Ht();i(ed,"createRender")});var jN={};R(jN,{setRender:()=>ey});function ey(e,t,r={}){return e.set([t,"render"],ed(r))}var ty=f(()=>{Qg();i(ey,"setRender")});function DN(e,t,r){return e.update([t,"render"],(n={})=>ed({...n,...r}))}var MN=f(()=>{Qg();i(DN,"updateRender")});var ZN={};R(ZN,{clearRender:()=>ry});function ry(e,t){return e.remove([t,"render"])}var ny=f(()=>{i(ry,"clearRender")});import{defineContracts as V9}from"@jucie.io/engine-message";var G9,LN=f(()=>{ty();MN();ny();G9=V9("node:render",e=>{let t=e("state")?.ref(["nodes"])??null;if(!t)throw new Error("Node cache not found");return{set:{schema:["String","Object"],handler:(r,n)=>{ey(t,r,n)},namespace:"scene-graph"},update:{schema:["String","Object"],handler:(r,n)=>{DN(t,r,n)},namespace:"scene-graph"},clear:{schema:["String"],handler:r=>{ry(t,r)},namespace:"scene-graph"}}})});function td({descriptor:e,keyOn:t=null,key:r="$key",as:n="$item",index:o="$index"}={}){return{descriptor:Se(e),keyOn:t,key:r,as:n,index:o}}var oy=f(()=>{Ht();i(td,"createRepeat")});var FN={};R(FN,{setRepeat:()=>qa});function qa(e,t,r={}){return e.set([t,"repeat"],td(r))}var rd=f(()=>{oy();i(qa,"setRepeat")});function UN(e,t,r){return e.update([t,"repeat"],(n={})=>td({...n,...r}))}var qN=f(()=>{oy();i(UN,"updateRepeat")});var HN={};R(HN,{clearRepeat:()=>Ha});function Ha(e,t){return e.remove([t,"repeat"])}var nd=f(()=>{i(Ha,"clearRepeat")});function BN(e,t){return e.get([t,"repeat"])?e:qa(e,t,{})}var VN=f(()=>{rd();i(BN,"enableRepeat")});function GN(e,t){return Ha(e,t)}var WN=f(()=>{nd();i(GN,"disableRepeat")});import{defineContracts as W9}from"@jucie.io/engine-message";var K9,KN=f(()=>{rd();qN();nd();VN();WN();K9=W9("node:repeat",e=>{let t=e("state")?.ref(["nodes"])??null;if(!t)throw new Error("Node cache not found");return{set:{schema:["String","Object"],handler:(r,n)=>{qa(t,r,n)},namespace:"scene-graph"},update:{schema:["String","Object"],handler:(r,n)=>{UN(t,r,n)},namespace:"scene-graph"},clear:{schema:["String"],handler:r=>{Ha(t,r)},namespace:"scene-graph"},enable:{schema:["String"],handler:r=>{BN(t,r)},namespace:"scene-graph"},disable:{schema:["String"],handler:r=>{GN(t,r)},namespace:"scene-graph"}}})});function JN({path:e=null,params:t=[]}={}){return{path:e,params:t}}var YN=f(()=>{i(JN,"createRoute")});var XN={};R(XN,{updateRoute:()=>sy});function sy(e,t,r){return e.update([t,"route"],(n={})=>JN({...n,...r}))}var iy=f(()=>{YN();i(sy,"updateRoute")});function QN({key:e=null,optional:t=!1}={}){return{key:e,optional:t}}var e1=f(()=>{i(QN,"createParam")});var t1={};R(t1,{addParamToRoute:()=>ay});function ay(e,t){return e.push([t,"route","params"],QN())}var cy=f(()=>{e1();i(ay,"addParamToRoute")});var r1={};R(r1,{removeParamFromRoute:()=>ly});function ly(e,t,r){return e.splice([t,"route","params"],r,1)}var uy=f(()=>{i(ly,"removeParamFromRoute")});var n1={};R(n1,{setHomePage:()=>dy});function dy(e,t,r){e.findAllWhen("home","is",!0).forEach(n=>{e.set(n,!1);let o=[...n.slice(0,-1),"path"];e.set(o,t)}),r&&(e.set([t,"route","home"],!0),e.set([t,"route","path"],"/"))}var py=f(()=>{i(dy,"setHomePage")});import{defineContracts as J9}from"@jucie.io/engine-message";var Y9,o1=f(()=>{iy();cy();uy();py();Y9=J9("node:route",e=>{let t=e("state")?.ref(["nodes"])??null;if(!t)throw new Error("Node cache not found");return{update:{schema:["String","Object"],namespace:"scene-graph",handler:(r,n)=>{sy(t,r,n)}},addParam:{schema:["String"],namespace:"scene-graph",handler:r=>{ay(t,r)}},removeParam:{namespace:"scene-graph",schema:["String","Number"],handler:(r,n)=>{ly(t,r,n)}},setHomePage:{schema:["String","Boolean"],namespace:"scene-graph",handler:(r,n)=>{dy(t,r,n)}}}})});function s1(e,t,{breakpoint:r="default",interactionState:n=[]}={}){let o=js(r);return e.remove([t,"style",o,...n])}var i1=f(()=>{ku();i(s1,"clearStyle")});function od(e,t){let n=e.get([t])?.type;return n==="frame"||n==="component"||n==="viewport"}var a1=f(()=>{i(od,"isContainerNode")});import{defineContracts as X9}from"@jucie.io/engine-message";var Q9,c1=f(()=>{Ms();Rg();i1();Hs();a1();Q9=X9("node:style",e=>{let[t,r]=e("state","sceneCompiler"),n=t?.ref(["nodes"])??null;return{update:{schema:["Object"],handler:o=>{for(let[s,a]of Object.entries(o)){if(!Gt(n,s))continue;delete a.position;let c=od(n,s)?"default":r.getActiveBreakpoint(s);Pa(n,s,a,{breakpoint:c})}},namespace:"scene-graph"},remove:{schema:["Array","Array"],handler:(o,s)=>{for(let a of o){if(!Gt(n,a))continue;let c=od(n,a)?"default":r.getActiveBreakpoint(a);for(let l of s)Wu(n,a,l,{breakpoint:c})}},namespace:"scene-graph"},clear:{schema:["Array"],handler:o=>{for(let s of o){if(!Gt(n,s))continue;let a=od(n,s)?"default":r.getActiveBreakpoint(s);a==="default"||a==null||s1(n,s,{breakpoint:a})}},namespace:"scene-graph"}}})});var l1={};R(l1,{setTagName:()=>fy});function fy(e,t,r){return e.set([t,"tagName"],r)}var my=f(()=>{i(fy,"setTagName")});function u1(e,t,r){return e.set([t,"tagName"],r)}var d1=f(()=>{i(u1,"updateTagName")});function p1(e,t){return e.remove([t,"tagName"])}var f1=f(()=>{i(p1,"clearTagName")});import{defineContracts as eU}from"@jucie.io/engine-message";var tU,m1=f(()=>{my();d1();f1();tU=eU("node:tagName",e=>{let t=e("state")?.ref(["nodes"])??null;if(!t)throw new Error("Node cache not found");return{set:{schema:["String","String"],handler:(r,n)=>{fy(t,r,n)},namespace:"scene-graph"},update:{schema:["String","String"],handler:(r,n)=>{u1(t,r,n)},namespace:"scene-graph"},clear:{schema:["String"],handler:r=>{p1(t,r)},namespace:"scene-graph"}}})});function h1(e,t,r){if(Vt(e,t))return;let n="",o;return typeof r=="string"?n=r:r!=null&&typeof r=="object"&&(n=r.value??"",Object.prototype.hasOwnProperty.call(r,"specificPatterns")&&(o=r.specificPatterns)),e.set([t,"textContent"],ye({value:n,specificPatterns:o}))}var g1=f(()=>{en();mo();i(h1,"setTextContent")});function y1(e,t,r={}){if(Vt(e,t))return;let n=typeof r=="string"?{value:r}:r;return e.update([t,"textContent"],(o={})=>{let s={...o,...n};return!Object.prototype.hasOwnProperty.call(n,"specificPatterns")&&o.specificPatterns!==void 0&&(s.specificPatterns=o.specificPatterns),ye(s)})}var x1=f(()=>{en();mo();i(y1,"updateTextContent")});function _1(e,t){return e.remove([t,"textContent"])}var v1=f(()=>{i(_1,"clearTextContent")});function Ba(e,t,r=!0){return e.set([t,".editingTextContent"],r)}var w1=f(()=>{i(Ba,"setEditingTextContent")});function b1(e,t){return e.remove([t,".editingTextContent"])}var S1=f(()=>{i(b1,"removeEditingTextContent")});import{defineContracts as rU}from"@jucie.io/engine-message";var nU,k1=f(()=>{g1();x1();v1();w1();S1();nU=rU("node:textContent",e=>{let t=e("state")?.ref(["nodes"])??null;if(!t)throw new Error("Node cache not found");let r=null;return{set:{schema:["String","Object"],handler:(n,o)=>{h1(t,n,o)},namespace:"scene-graph"},update:{schema:["String","Object"],handler:(n,o)=>{y1(t,n,o)},namespace:"scene-graph"},clear:{schema:["String"],handler:n=>{_1(t,n)},namespace:"scene-graph"},"editing:enable":{schema:["String"],namespace:"scene-graph",handler:n=>(r&&(Ba(t,r,!1),r=null),r=n,Ba(t,n,!0),!0)},"editing:disable":{schema:"*",namespace:"scene-graph",handler:n=>(n?Ba(t,n,!1):r&&(Ba(t,r,!1),r=null),r=null,!0)},"editing:remove":{schema:["String"],namespace:"scene-graph",handler:n=>(b1(t,n),!0)}}})});function $1(e,t,r){return e.set([t,"type"],r)}var E1=f(()=>{i($1,"setType")});function N1(e,t,r){return e.set([t,"type"],r)}var T1=f(()=>{i(N1,"updateType")});function z1(e,t){return e.remove([t,"type"])}var C1=f(()=>{i(z1,"clearType")});import{defineContracts as oU}from"@jucie.io/engine-message";var sU,I1=f(()=>{E1();T1();C1();sU=oU("node:type",e=>{let t=e("state")?.ref(["nodes"])??null;if(!t)throw new Error("Node cache not found");return{set:{schema:["String","String"],handler:(r,n)=>{$1(t,r,n)},namespace:"scene-graph"},update:{schema:["String","String"],handler:(r,n)=>{N1(t,r,n)},namespace:"scene-graph"},clear:{schema:["String"],handler:r=>{z1(t,r)},namespace:"scene-graph"}}})});function Va(e,t,r,n={}){let{name:o,bounds:s}=Ma(r,n),a=e.get([t,"bounds"])??{};e.set([t,"frame"],r),e.set([t,"name"],o),e.update([t,"bounds"],()=>({...a,width:s.width,height:s.height}))}var hy=f(()=>{go();i(Va,"setFramePreset")});function P1(e,t,{name:r,width:n,height:o}){if(r==="custom"){Va(e,t,"custom",{name:r,width:n,height:o});return}if(!Da(r))return new Error(`Invalid viewport name "${r}"`);Va(e,t,r)}var R1=f(()=>{go();hy();i(P1,"setViewport")});function O1(e,t){return e.set([t,"frame"],void 0),e.remove([t,"viewport"])}var A1=f(()=>{i(O1,"clearViewport")});import{defineContracts as iU}from"@jucie.io/engine-message";var aU,j1=f(()=>{R1();hy();Oa();A1();aU=iU("node:viewport",e=>{let t=e("state")?.ref(["nodes"])??null;if(!t)throw new Error("Node cache not found");return{set:{schema:["String","Object"],handler:(r,n)=>{P1(t,r,n)},namespace:"scene-graph"},setPreset:{schema:["String","String","Object"],handler:(r,n,o={})=>{Va(t,r,n,o)},namespace:"scene-graph"},update:{schema:["String","Object"],handler:(r,n)=>{Ra(t,r,n)},namespace:"scene-graph"},clear:{schema:["String"],handler:r=>{O1(t,r)},namespace:"scene-graph"}}})});var D1={};R(D1,{setHtmlId:()=>gy});function gy(e,t,r){return e.set([t,"id"],r)}var yy=f(()=>{i(gy,"setHtmlId")});function M1(e,t){return e.remove([t,"id"])}var Z1=f(()=>{i(M1,"clearHtmlId")});import{defineContracts as cU}from"@jucie.io/engine-message";var lU,L1=f(()=>{yy();Z1();lU=cU("node:id",e=>{let t=e("state")?.ref(["nodes"])??null;if(!t)throw new Error("Node cache not found");return{set:{namespace:"scene-graph",schema:["String","String"],handler:(r,n)=>{gy(t,r,n)}},clear:{namespace:"scene-graph",schema:["String"],handler:r=>{M1(t,r)}}}})});var F1=f(()=>{});var xy=f(()=>{});var U1=f(()=>{xy()});var q1=f(()=>{});var H1=f(()=>{});var B1=f(()=>{});var V1=f(()=>{});var C=f(()=>{F1();U1();xy();q1();H1();B1();V1()});var Gs=f(()=>{});var Wt=f(()=>{Gs();C()});var Ga=f(()=>{Wt();C()});var G1=f(()=>{Ga();C()});var W1=f(()=>{Ga();C()});var K1=f(()=>{Ga();C()});var J1=f(()=>{Ga();C()});var Y1=f(()=>{G1();W1();K1();J1()});var yo=f(()=>{Wt();C()});var X1=f(()=>{yo();C()});var Q1=f(()=>{yo();C()});var eT=f(()=>{yo();C()});var tT=f(()=>{yo();C()});var rT=f(()=>{yo();C()});var nT=f(()=>{yo();C()});var oT=f(()=>{X1();Q1();eT();tT();rT();nT()});var Xe=f(()=>{Wt();C()});var sT=f(()=>{Xe();C()});var iT=f(()=>{Xe();C()});var aT=f(()=>{Xe();C()});var cT=f(()=>{Xe();C()});var lT=f(()=>{Xe();C()});var uT=f(()=>{Xe();C()});var dT=f(()=>{Xe();C()});var pT=f(()=>{Xe();C()});var fT=f(()=>{Xe();C()});var mT=f(()=>{Xe();C()});var hT=f(()=>{Xe();C()});var gT=f(()=>{Xe();C()});var yT=f(()=>{Xe();C()});var xT=f(()=>{Xe();C()});var _T=f(()=>{Xe();C()});var vT=f(()=>{Xe();C()});var wT=f(()=>{sT();iT();aT();cT();lT();uT();dT();pT();fT();mT();hT();gT();yT();xT();_T();vT()});var Ws=f(()=>{Wt();C()});var bT=f(()=>{Ws();C()});var ST=f(()=>{Ws();C()});var kT=f(()=>{Ws();C()});var $T=f(()=>{Ws();C()});var ET=f(()=>{Ws();C()});var NT=f(()=>{bT();ST();kT();$T();ET()});var pr=f(()=>{Wt();C()});var TT=f(()=>{pr();C()});var zT=f(()=>{pr();C()});var CT=f(()=>{pr();C()});var IT=f(()=>{pr();C()});var PT=f(()=>{pr();C()});var RT=f(()=>{pr();C()});var OT=f(()=>{pr();C()});var AT=f(()=>{pr();C()});var jT=f(()=>{pr();C()});var DT=f(()=>{pr();C()});var MT=f(()=>{TT();zT();CT();IT();PT();RT();OT();AT();jT();DT()});var xo=f(()=>{Wt();C()});var ZT=f(()=>{xo();C()});var LT=f(()=>{xo();C()});var FT=f(()=>{xo();C()});var UT=f(()=>{xo();C()});var qT=f(()=>{xo();C()});var HT=f(()=>{xo();C()});var BT=f(()=>{ZT();LT();FT();UT();qT();HT()});var Ks=f(()=>{Wt();C()});var VT=f(()=>{Ks();C()});var GT=f(()=>{Ks();C()});var WT=f(()=>{Ks();C()});var KT=f(()=>{Ks();C()});var JT=f(()=>{Ks();C()});var Kt=f(()=>{Wt();C()});var YT=f(()=>{Kt();C()});var XT=f(()=>{VT();GT();WT();KT();JT();YT()});var Rn=f(()=>{Wt();C()});var QT=f(()=>{Rn();C()});var ez=f(()=>{Rn();C()});var tz=f(()=>{Rn();C()});var rz=f(()=>{Rn();C()});var nz=f(()=>{Rn();C()});var oz=f(()=>{Rn();C()});var sz=f(()=>{Rn();C()});var iz=f(()=>{QT();ez();tz();rz();nz();oz();sz()});var az=f(()=>{Kt();C()});var cz=f(()=>{Kt();C()});var lz=f(()=>{Kt();C()});var uz=f(()=>{Kt();C()});var dz=f(()=>{Kt();C()});var pz=f(()=>{Kt();C()});var fz=f(()=>{Kt();C()});var mz=f(()=>{Kt();C()});var hz=f(()=>{Kt();C()});var gz=f(()=>{Kt();C()});var yz=f(()=>{Wt();C()});var xz=f(()=>{Wt();C()});var _z=f(()=>{az();cz();lz();uz();dz();pz();fz();mz();hz();gz();yz();xz()});var vz=f(()=>{C();Y1();oT();wT();NT();MT();BT();XT();iz();_z()});var wz=f(()=>{go()});var bz=f(()=>{Gs();C()});var Sz=f(()=>{C();bz()});var cd=f(()=>{C();Gs()});var $z=f(()=>{C();cd()});var Ez=f(()=>{C();cd()});var Nz=f(()=>{C()});var Tz=f(()=>{C();cd()});var zz=f(()=>{C();$z();Ez();Nz();Tz()});var Cz=f(()=>{Gs();C()});var Iz=f(()=>{Cz();C()});var Pz=f(()=>{C();Iz()});var Rz=f(()=>{});var Oz=f(()=>{Rz()});var Az=f(()=>{Gs();C()});var jz=f(()=>{vz();wz();Sz();zz();Pz();Oz();Az()});var Dz,Mz=f(()=>{Dz=[{type:"element",displayName:"Fieldset",category:"form",swapGroup:null,keywords:["form"],tagName:"fieldset"},{type:"element",displayName:"Legend",category:"form",swapGroup:null,keywords:["form"],tagName:"legend"},{type:"element",displayName:"Progress",category:"form",swapGroup:null,keywords:["form"],tagName:"progress"},{type:"element",displayName:"Meter",category:"form",swapGroup:null,keywords:["form"],tagName:"meter"}]});var Zz,Lz=f(()=>{Zz=[{type:"element",displayName:"Heading 1",keywords:["headings"],category:"headings",swapGroup:"headings",tagName:"h1"},{type:"element",displayName:"Heading 2",keywords:["headings"],category:"headings",swapGroup:"headings",tagName:"h2"},{type:"element",displayName:"Heading 3",keywords:["headings"],category:"headings",swapGroup:"headings",tagName:"h3"},{type:"element",displayName:"Heading 4",keywords:["headings"],category:"headings",swapGroup:"headings",tagName:"h4"},{type:"element",displayName:"Heading 5",keywords:["headings"],category:"headings",swapGroup:"headings",tagName:"h5"},{type:"element",displayName:"Heading 6",keywords:["headings"],category:"headings",swapGroup:"headings",tagName:"h6"}]});var Fz,Uz=f(()=>{Fz=[{type:"element",displayName:"Radio",category:"inputs",swapGroup:null,keywords:["inputs"],tagName:"radio"},{type:"element",displayName:"Text",category:"inputs",swapGroup:null,keywords:["inputs"],tagName:"text"},{type:"element",displayName:"Checkbox",category:"inputs",swapGroup:null,keywords:["inputs"],tagName:"checkbox"},{type:"element",displayName:"Phone",category:"inputs",swapGroup:null,keywords:["inputs"],tagName:"phone"},{type:"element",displayName:"Email",category:"inputs",swapGroup:null,keywords:["inputs"],tagName:"email"},{type:"element",displayName:"Password",category:"inputs",swapGroup:null,keywords:["inputs"],tagName:"password"},{type:"element",displayName:"Select",category:"inputs",swapGroup:null,keywords:["inputs"],tagName:"select"},{type:"element",displayName:"Textarea",category:"inputs",swapGroup:null,keywords:["inputs"],tagName:"textarea"},{type:"element",displayName:"Number",category:"inputs",swapGroup:null,keywords:["inputs"],tagName:"number"},{type:"element",displayName:"Date",category:"inputs",swapGroup:null,keywords:["inputs"],tagName:"date"},{type:"element",displayName:"Range",category:"inputs",swapGroup:null,keywords:["inputs"],tagName:"range"},{type:"element",displayName:"File Upload",category:"inputs",swapGroup:null,keywords:["inputs"],tagName:"file"},{type:"element",displayName:"Search",category:"inputs",swapGroup:null,keywords:["inputs"],tagName:"search"},{type:"element",displayName:"Color Picker",category:"inputs",swapGroup:null,keywords:["inputs"],tagName:"color"},{type:"element",displayName:"Hidden",category:"inputs",swapGroup:null,keywords:["inputs"],tagName:"hidden"}]});var qz,Hz=f(()=>{qz=[{type:"element",displayName:"Button",category:"interactive",swapGroup:"interactive",keywords:["interactive"],tagName:"button"},{type:"element",displayName:"Link",category:"interactive",swapGroup:"interactive",keywords:["interactive"],tagName:"a"},{type:"element",displayName:"Details",category:"interactive",swapGroup:null,keywords:["interactive"],tagName:"details"},{type:"element",displayName:"Summary",category:"interactive",swapGroup:null,keywords:["interactive"],tagName:"summary"},{type:"element",displayName:"Dialog",category:"interactive",swapGroup:null,keywords:["interactive"],tagName:"dialog"}]});var Bz,Vz=f(()=>{Bz=[{type:"element",displayName:"Aside",category:"layout",swapGroup:"layout",keywords:["layout"],tagName:"aside"},{type:"element",displayName:"Footer",category:"layout",swapGroup:"layout",keywords:["layout"],tagName:"footer"},{type:"element",displayName:"Form",category:"layout",swapGroup:"layout",keywords:["layout"],tagName:"form"},{type:"element",displayName:"Header",category:"layout",swapGroup:"layout",keywords:["layout"],tagName:"header"},{type:"element",displayName:"Main",category:"layout",swapGroup:"layout",keywords:["layout"],tagName:"main"},{type:"element",displayName:"Section",category:"layout",swapGroup:"layout",keywords:["layout"],tagName:"section"},{type:"element",displayName:"Article",category:"layout",swapGroup:"layout",keywords:["layout"],tagName:"article"},{type:"element",displayName:"Nav",category:"layout",swapGroup:"layout",keywords:["layout"],tagName:"nav"},{type:"element",displayName:"Div",category:"layout",swapGroup:"layout",keywords:["layout"],tagName:"div"},{type:"element",displayName:"Template",category:"layout",swapGroup:"layout",keywords:["layout"],tagName:"template"}]});var Gz,Wz=f(()=>{Gz=[{type:"element",displayName:"Ordered List",category:"lists",swapGroup:"list-container",keywords:["lists"],tagName:"ol"},{type:"element",displayName:"Unordered List",category:"lists",swapGroup:"list-container",keywords:["lists"],tagName:"ul"},{type:"element",displayName:"List Item",category:"lists",swapGroup:null,keywords:["lists"],tagName:"li"},{type:"element",displayName:"Definition List",category:"lists",swapGroup:"list-container",keywords:["lists"],tagName:"dl"},{type:"element",displayName:"Definition Term",category:"lists",swapGroup:null,keywords:["lists"],tagName:"dt"},{type:"element",displayName:"Definition Description",category:"lists",swapGroup:null,keywords:["lists"],tagName:"dd"}]});var Kz,Jz=f(()=>{Kz=[{type:"element",displayName:"Image",category:"media",swapGroup:null,keywords:["media"],tagName:"img"},{type:"element",displayName:"Video",category:"media",swapGroup:null,keywords:["media"],tagName:"video"},{type:"element",displayName:"Audio",category:"media",swapGroup:null,keywords:["media"],tagName:"audio"},{type:"element",displayName:"Iframe",category:"media",swapGroup:null,keywords:["media"],tagName:"iframe"},{type:"element",displayName:"Figure",category:"media",swapGroup:null,keywords:["media"],tagName:"figure"},{type:"element",displayName:"Figcaption",category:"media",swapGroup:null,keywords:["media"],tagName:"figcaption"}]});var Yz,Xz=f(()=>{Yz=[{type:"element",displayName:"Table",category:"tables",swapGroup:null,keywords:["tables"],tagName:"table"},{type:"element",displayName:"Table Head",category:"tables",swapGroup:null,keywords:["tables"],tagName:"thead"},{type:"element",displayName:"Table Body",category:"tables",swapGroup:null,keywords:["tables"],tagName:"tbody"},{type:"element",displayName:"Table Foot",category:"tables",swapGroup:null,keywords:["tables"],tagName:"tfoot"},{type:"element",displayName:"Table Row",category:"tables",swapGroup:null,keywords:["tables"],tagName:"tr"},{type:"element",displayName:"Table Header Cell",category:"tables",swapGroup:null,keywords:["tables"],tagName:"th"},{type:"element",displayName:"Table Cell",category:"tables",swapGroup:null,keywords:["tables"],tagName:"td"}]});var Qz,eC=f(()=>{Qz=[{type:"element",displayName:"Paragraph",category:"text",swapGroup:"text",keywords:["text"],tagName:"p"},{type:"element",displayName:"Label",category:"text",swapGroup:"text",keywords:["text"],tagName:"label"},{type:"element",displayName:"Span",category:"text",swapGroup:"text",keywords:["text"],tagName:"span"},{type:"element",displayName:"Blockquote",category:"text",swapGroup:null,keywords:["text"],tagName:"blockquote"},{type:"element",displayName:"Preformatted",category:"text",swapGroup:null,keywords:["text"],tagName:"pre"},{type:"element",displayName:"Code",category:"text",swapGroup:"text",keywords:["text"],tagName:"code"},{type:"element",displayName:"Strong",category:"text",swapGroup:"text",keywords:["text"],tagName:"strong"},{type:"element",displayName:"Emphasis",category:"text",swapGroup:"text",keywords:["text"],tagName:"em"},{type:"element",displayName:"Small",category:"text",swapGroup:"text",keywords:["text"],tagName:"small"},{type:"element",displayName:"Mark",category:"text",swapGroup:null,keywords:["text"],tagName:"mark"},{type:"element",displayName:"Horizontal Rule",category:"text",swapGroup:null,keywords:["text","divider"],tagName:"hr"},{type:"element",displayName:"Line Break",category:"text",swapGroup:null,keywords:["text"],tagName:"br"}]});var tC,rC=f(()=>{tC=[{type:"slot",displayName:"Slot",category:"special",keywords:["slot","placeholder","component","template"],tagName:"slot"}]});var vU,nC=f(()=>{Mz();Lz();Uz();Hz();Vz();Wz();Jz();Xz();eC();rC();vU=[...Bz,...Zz,...Fz,...qz,...Gz,...Kz,...Qz,...Dz,...Yz,...tC]});var oC=f(()=>{});var sC=f(()=>{jz();Tu();Xu();Hu();xg();go();nC();oC()});var iC=f(()=>{Jk();s$();N$();O$();M$();SE();EE();CE();DE();qE();BE();JE();QE();rN();lN();uN();dN();hN();bN();EN();PN();RN();AN();LN();KN();o1();c1();m1();k1();I1();j1();L1();sC()});function ld(){return`function () {
6
+ }`,Eq=i(()=>({name:null,mode:"value",value:null,binding:null,computed:null,code:null,error:null,removable:!0}),"DEFAULTS");i(Nq,"validateCode");i(Tq,"validateComputed");i(zq,"validateBinding");i(Cq,"validateDescriptor");i(Ne,"createDescriptor")});function Wd({name:e,mode:t,...r}={}){return Ne({name:e,mode:t??"value",...r})}var ky=f(()=>{Kt();i(Wd,"createClassName")});function Jd(e,t,r={}){let n=typeof r=="string"?{value:r}:r;return e.push([t,"className"],Wd({mode:"value",...n}))}var $y=f(()=>{ky();i(Jd,"addClassName")});function zN(e,t,r,n){return e.setWhere([t,"className"],{value:r},Wd(n))}var CN=f(()=>{ky();i(zN,"updateClassName")});function IN(e,t,r){return e.removeWhere([t,"className"],{value:r})}var PN=f(()=>{i(IN,"removeClassName")});import{defineContracts as Iq}from"@jucie.io/engine-message";var Pq,ON=f(()=>{$y();CN();PN();Pq=Iq("node:className",e=>{let t=e("state")?.ref(["nodes"])??null;if(!t)throw new Error("Node cache not found");return{add:{namespace:"scene-graph",schema:["String","String"],handler:(r,n)=>Jd(t,r,n)},update:{namespace:"scene-graph",schema:["String","String","Object"],handler:(r,n,o)=>zN(t,r,n,o)},remove:{namespace:"scene-graph",schema:["String","String"],handler:(r,n)=>IN(t,r,n)}}})});function $t(e,t){return e.has([t])}var vi=f(()=>{i($t,"nodeExists")});var AN={};C(AN,{disconnectNode:()=>yr});function yr(e,t){if(!t||!$t(e,t))return!1;e.update(["app","children"],(n=[])=>n.filter(o=>o!==t)),e.update(["temp","children"],(n=[])=>n.filter(o=>o!==t));let r=e.findWhen("children","includes",t);return r&&e.update(r,(n=[])=>n.filter(o=>o!==t)),!0}var wi=f(()=>{vi();i(yr,"disconnectNode")});function xr(e,t,r=[]){let n=e.get([t,"children"])||[];for(let o of n)r.push(o),r=xr(e,o,r);return r}var bi=f(()=>{i(xr,"findDescendantIds")});var Si,Kd=f(()=>{Si=i(e=>structuredClone?structuredClone(e):JSON.parse(JSON.stringify(e)),"clone")});function RN(e,t){let r=t.flatMap(o=>xr(e,o));t.forEach(o=>{yr(e,o)}),t=[...t,...r];let n={};for(let o of t)n[o]=e.remove([o]);return Si(n)}var jN=f(()=>{wi();bi();Kd();i(RN,"cutNodes")});function DN(e,t){let r=t.flatMap(o=>xr(e,o));t=[...t,...r];let n={};for(let o of t){let s=e.get([o]);s&&(n[o]=s)}return Si(n)}var MN=f(()=>{bi();Kd();i(DN,"copyNodes")});function Yd(e,t){return e.update(["temp","children"],(r=[])=>r.indexOf(t)===-1?[...r,t]:r),!0}var Ey=f(()=>{i(Yd,"moveNodeToTemp")});function ZN(e,t){let r=e.get([t,"layout"]);if(r&&r!=="none")return r;let n=e.get([t,"style","default","display"]);return n==="flex"||n==="grid"?n:"none"}var LN=f(()=>{i(ZN,"getLayoutContext")});function FN(e){return Oq.has(e)}var Oq,UN=f(()=>{Oq=new Set(["app","temp","components"]);i(FN,"shouldHaveBounds")});function Xd(e,t,r){let n=e.get([t,"style"]);if(!(!n||!r.length))for(let o in n){let s=n[o];if(!(!s||typeof s!="object")){for(let a of r)a in s&&e.remove([t,"style",o,a]);for(let a in s){if(!a.startsWith(":")&&!a.startsWith("&."))continue;let c=s[a];if(!(!c||typeof c!="object"))for(let l of r)l in c&&e.remove([t,"style",o,a,l])}}}}var Ny=f(()=>{i(Xd,"stripStyleProperties")});function Qd(e,t){Xd(e,t,Aq)}var Aq,Ty=f(()=>{Ny();Aq=["top","left","right","bottom"];i(Qd,"stripPositionalStyles")});function zy(){return{layout:"none",draggable:!0,resizable:!0,selectable:!0,locked:[],anchor:[],dimensions:[],expandedStyles:[],childrenType:"children"}}var qN=f(()=>{i(zy,"defaultNodeBehavior")});function ki(e){if(e===BN||e==null)return BN;let t=String(e);return t.startsWith("@")?t:`@${t}`}var BN,ep=f(()=>{BN="default";i(ki,"toBpKey")});var HN={};C(HN,{updateStyle:()=>un});function $i(e){return e!=null&&e!=="auto"}function un(e,t,r,{breakpoint:n="default",interactionState:o,anchor:s}={}){let a=ki(n),c=o??e.get([t,".interactionState"])??[],l={};for(let u of Rq)u in r&&(l[u]=r[u],delete r[u]);for(let u of jq)delete r[u];return s=s??e.get([t,"anchor"]),e.update([t,"style",a],(u={})=>{let d={...u,...l};if(s)for(let p of Dq)s.includes(p)||delete d[p];return $i(d.left)&&$i(d.right)&&!("width"in l)&&$i(d.width)&&delete d.width,$i(d.top)&&$i(d.bottom)&&!("height"in l)&&$i(d.height)&&delete d.height,d}),e.update([t,"style",a,...c],(u={})=>({...u,...r})),e.get([t,"style",a])}var Rq,jq,Dq,Lo=f(()=>{ep();Rq=["top","left","right","bottom","width","height"],jq=["display","position"];i($i,"isConstrainedEdge");Dq=["top","left","right","bottom"];i(un,"updateStyle")});var Cy={};C(Cy,{updateBounds:()=>Ec});function Ec(e,t,r){let n=e.get([t,"bounds"])??{};return e.set([t,"bounds"],{...n,...r})}var Nc=f(()=>{i(Ec,"updateBounds")});function VN(e,t){return e?t?e.filter(r=>!t.includes(r)):e:[]}var GN=f(()=>{i(VN,"arrayDiff")});function WN(e,t,r){let n=e.get([t,"anchor"]),o=VN(n,r);return o.length&&Xd(e,t,o),e.set([t,"anchor"],r),!0}var JN=f(()=>{GN();Ny();i(WN,"updateAnchor")});function Yt(e,t){return e.remove([t,".position"])}var Ei=f(()=>{i(Yt,"clearPosition")});function dn(e,t,r,n){if(!r||typeof r!="object")return;let o=Object.keys(r).sort();for(let s of o){let a=r[s];switch(s){case"style":{let c=r?.anchor;un(e,t,a,{breakpoint:n,anchor:c}),Yt(e,t);break}case"bounds":Ec(e,t,a);break;case"anchor":WN(e,t,a);break;default:e.set([t,s],a);break}}}function KN(e,t,r={}){let n={...zy(),...r};for(let o of Object.keys(n))e.set([t,o],n[o])}function YN(e,t){let r=zy();for(let n of Object.keys(r))e.set([t,n],r[n]);e.set([t,"hidden"],void 0)}var Tc=f(()=>{qN();Lo();Nc();JN();Ei();i(dn,"applyNodePatch");i(KN,"setNodeBehavior");i(YN,"resetNodeBehavior")});function Je(e,t,r){if(FN(r)||e.remove([t,"bounds"]),ZN(e,r)!=="none"){Qd(e,t),dn(e,t,{anchor:[],dimensions:[]});return}let o=e.get([t,"anchor"]);(!o||!o.length)&&dn(e,t,{anchor:["top","left"],dimensions:["width","height"]})}var pn=f(()=>{LN();UN();Ty();Tc();i(Je,"normalizeLayoutContext")});function Mt(e,t){return e.update(["app","children"],(r=[])=>r.indexOf(t)===-1?[...r,t]:r),Je(e,t,"app"),!0}var Fo=f(()=>{pn();i(Mt,"moveNodeToRoot")});function Ni(e,t){return e.has([t])?e.get(["app","children"])?.includes(t)?"root":e.get(["temp","children"])?.includes(t)?"temp":e.get(["components","children"])?.includes(t)?"components":"nested":null}var tp=f(()=>{i(Ni,"getNodeLevel")});function Mr(e,t,r,n){let o=e.get([t]),s=o?.type;if(!o||!(s==="frame"||s==="component"||s==="viewport"))return!0;if(n==="instance")return!1;let c=o.type==="component";if(n==="root"||n==="temp")return!c;if(n==="after"||n==="before"){let l=Ni(e,r);return c?l==="components":l==="root"||l==="temp"}return n==="firstChildOf"||n==="lastChildOf"?c?r==="components":r==="app"||r==="temp":!1}var Ti=f(()=>{tp();i(Mr,"canMoveFrame")});function XN(e){return e?e.ex&&e.ex in zi?zi[e.ex]:e.tagName&&e.tagName in zi?zi[e.tagName]:e.type&&e.type in zi?zi[e.type]:e.childrenType??null:null}var zi,QN=f(()=>{zi={layout:"*",div:"*",section:"*",header:"*",footer:"*",article:"*",main:"*",aside:"*",nav:"*",form:"*",template:"*",text:"text",heading:"text",h1:"text",h2:"text",h3:"text",h4:"text",h5:"text",h6:"text",paragraph:"text",p:"text",span:"text",label:"text",blockquote:"text",pre:"text",codeElement:"text",strong:"text",em:"text",small:"text",mark:"text",ul:["li"],ol:["li"],li:"*",dl:["dt","dd"],dt:"text",dd:"text",table:["thead","tbody","tfoot","tr"],thead:["tr"],tbody:["tr"],tfoot:["tr"],tr:["td","th"],td:"*",th:"*",interactive:"text",button:"text",a:"text",summary:"text",details:"*",dialog:"*",input:null,checkbox:null,radio:null,email:null,password:null,phone:null,color:null,date:null,file:null,hidden:null,number:null,range:null,search:null,textInput:null,select:"options",textarea:"text",media:null,img:null,audio:null,iframe:null,video:"*",figure:"*",figcaption:"text",fieldset:"*",legend:"text",meter:null,progress:null,slot:"*",frame:"*",component:"children"};i(XN,"getChildrenType")});function Xt(e,t,r=null){if(t==="app"||t==="temp"||t==="components")return!0;let n=XN(e.get([t]));return!n||n==="text"?!1:n==="*"||n==="children"||n==="options"?!0:Array.isArray(n)?r===null?!0:n.includes(r):!1}var Uo=f(()=>{QN();i(Xt,"canAcceptChildren")});var e1={};C(e1,{moveNodeToLastChildOf:()=>Zr});function Zr(e,t,r){if(!$t(e,r)||!$t(e,t))return;let n=e.get([t,"ex"])??e.get([t,"type"]);if(Xt(e,r,n)){if(!Mr(e,t,r,"lastChildOf")){Mt(e,t);return}return e.update([r,"children"],(o=[])=>{let s=o.indexOf(t);if(s!==-1){let a=[...o];return a.splice(s,1),[...a,t]}return[...o,t]}),Je(e,t,r),!0}}var Ci=f(()=>{Ti();Uo();vi();Fo();pn();i(Zr,"moveNodeToLastChildOf")});function Ii(e,t,r){if(!Mr(e,t,r,"after")){Mt(e,t);return}if(e.get(["app","children"])?.includes(r))return e.update(["app","children"],(c=[])=>{let l=c.indexOf(r);if(l===-1)return[...c,t];let u=[...c];return u.splice(l+1,0,t),u}),Je(e,t,"app"),!0;let o=e.findWhen("children","includes",r);if(!o)return new Error("Failed to move node after: parent not found");let s=o[0],a=e.get([t,"ex"])??e.get([t,"type"]);if(Xt(e,s,a))return e.update(o,(c=[])=>{let l=c.indexOf(r);if(l===-1)return[...c,t];let u=[...c];return u.splice(l+1,0,t),u}),Je(e,t,s),!0}var rp=f(()=>{Ti();Uo();Fo();pn();i(Ii,"moveNodeAfter")});function np(e,t,r){if(!Mr(e,t,r,"before")){Mt(e,t);return}if(e.get(["app","children"])?.includes(r))return Mt(e,t),!0;let o=e.findWhen("children","includes",r);if(!o)return new Error("Failed to move node before: parent not found");let s=o[0],a=e.get([t,"ex"])??e.get([t,"type"]);if(Xt(e,s,a))return e.update(o,(c=[])=>{let l=c.indexOf(r);if(l===-1)return[t,...c];let u=[...c];return u.splice(l,0,t),u}),Je(e,t,s),!0}var Iy=f(()=>{Fo();Ti();Uo();pn();i(np,"moveNodeBefore")});function qo(e){let t=Object.keys(e),r={},n=new Map;t.forEach(c=>{let l=kc();n.set(c,l)}),t.forEach(c=>{let l=n.get(c),d={...e[c]};d.children&&Array.isArray(d.children)&&(d.children=d.children.map(p=>n.get(p)||null).filter(p=>p!==null)),d.slots&&Array.isArray(d.slots)&&(d.slots=d.slots.map(p=>({...p,id:n.get(p.id)??p.id,children:(p.children||[]).map(m=>n.get(m)??m)}))),d.type==="frame"&&(d.route=d.route?{...d.route,path:`${l}`}:{path:`${l}`}),r[l]=d});let o=Object.keys(r),s=new Set;return Object.values(r).forEach(c=>{c.children&&Array.isArray(c.children)&&c.children.forEach(l=>{l&&s.add(l)})}),[o.filter(c=>!s.has(c)),r]}var zc=f(()=>{$c();i(qo,"cloneNodes")});function op(e,t,{parent:r,after:n,before:o,root:s,temp:a}={}){let[c,l]=qo(t);for(let[m,h]of Object.entries(l))e.set(m,h);let u=[],d=[];for(let m of c)l[m]?.type==="component"?u.push(m):d.push(m);if(d.length>0)for(let m of u)Zr(e,m,"components");else d.push(...u);if(a)for(let m of d)Yd(e,m);if(s)for(let m of d)Mt(e,m);if(r)for(let m of d)Zr(e,m,r);if(n)for(let m of d)Ii(e,m,n),n=m;if(o)for(let m of d)np(e,m,o),o=m;return d}var Py=f(()=>{Ey();Fo();Ci();rp();Iy();zc();i(op,"pasteNodes")});function Pi(e,t){let r=xr(e,t),n=[t,...r],o={};for(let s of n){let a=e.get([s]);a&&(o[s]=a)}return Si(o)}var sp=f(()=>{bi();Kd();i(Pi,"copyNode")});function ip(e,t){let r=[];for(let n of t){let o=Pi(e,n);r=r.concat(op(e,o,{after:n}))}return r}var Oy=f(()=>{sp();Py();i(ip,"duplicateNodes")});function Qt(e,t){let r=e.get([t,"locked"]);return!r||!r.includes("*")}var Oi=f(()=>{i(Qt,"canEditNode")});import{defineContracts as Mq}from"@jucie.io/engine-message";var Zq,t1=f(()=>{jN();MN();Py();Oy();Oi();pn();Zq=Mq("node:clipboard",e=>{let t=e("state")?.ref(["nodes"])??null;if(!t)throw new Error("Node cache not found");return{cut:{namespace:"scene-graph",schema:["Array"],handler:r=>{let n=r.filter(s=>Qt(t,s));return n.length===0?{}:RN(t,n)}},copy:{namespace:"scene-graph",schema:["Array"],handler:r=>DN(t,r)},paste:{namespace:"scene-graph",schema:["Object","Object"],handler:(r,n)=>{let o=op(t,r,n);if(n.parent)for(let s of o)Je(t,s,n.parent);return o}},duplicate:{namespace:"scene-graph",schema:["Array","Object","Object"],handler:(r,n,o)=>{let s=ip(t,r,n);o&&typeof o=="function"&&o(s)}}}})});function r1(e,t,r){return e.set([t,"contextName"],r)}var n1=f(()=>{i(r1,"setContextName")});function o1(e,t,r){return e.set([t,"contextName"],r)}var s1=f(()=>{i(o1,"updateContextName")});function i1(e,t){return e.remove([t,"contextName"])}var a1=f(()=>{i(i1,"clearContextName")});import{defineContracts as Lq}from"@jucie.io/engine-message";var Fq,c1=f(()=>{n1();s1();a1();Fq=Lq("node:contextName",e=>{let t=e("state")?.ref(["nodes"])??null;if(!t)throw new Error("Node cache not found");return{set:{schema:["String","String"],handler:(r,n)=>{r1(t,r,n)},namespace:"scene-graph"},update:{schema:["String","String"],handler:(r,n)=>{o1(t,r,n)},namespace:"scene-graph"},clear:{schema:["String"],handler:r=>{i1(t,r)},namespace:"scene-graph"}}})});function ap({name:e,mode:t,...r}={}){return Ne({name:e,mode:t??"binding",...r})}var Ay=f(()=>{Kt();i(ap,"createState")});var l1={};C(l1,{addState:()=>Ry});function Ry(e,t,r){return e.unshift([t,"states"],ap({name:r}))}var jy=f(()=>{Ay();i(Ry,"addState")});var u1={};C(u1,{updateState:()=>Dy});function Dy(e,t,r,n){return e.setWhere([t,"states"],{name:r},ap(n))}var My=f(()=>{Ay();i(Dy,"updateState")});var d1={};C(d1,{removeState:()=>Zy});function Zy(e,t,r){return e.removeWhere([t,"states"],{name:r})}var Ly=f(()=>{i(Zy,"removeState")});import{defineContracts as Uq}from"@jucie.io/engine-message";var qq,p1=f(()=>{jy();My();Ly();qq=Uq("node:state",e=>{let t=e("state")?.ref(["nodes"])??null;if(!t)throw new Error("Node cache not found");return{add:{namespace:"scene-graph",schema:["String","String"],handler:(r,n)=>Ry(t,r,n)},update:{namespace:"scene-graph",schema:["String","String","Object"],handler:(r,n,o)=>Dy(t,r,n,o)},remove:{namespace:"scene-graph",schema:["String","String"],handler:(r,n)=>Zy(t,r,n)}}})});var f1,m1=f(()=>{f1={__version:1,type:"node",render:{name:null,mode:"value",value:!0,binding:null,computed:null,code:null,error:null},name:null,layout:"none",draggable:!0,resizable:!0,selectable:!0,locked:[],anchor:[],dimensions:[],expandedStyles:[],childrenType:null,repeat:null,contextName:null,attributes:[],events:[],className:[],states:[],lifecycle:[],animations:[],style:{}}});var h1,g1=f(()=>{h1={type:"element",ex:"node",style:{default:{}}}});var y1,x1=f(()=>{y1={type:"container",ex:"node",childrenType:"*",bounds:{width:0,height:0,x:0,y:0}}});var Fy={};C(Fy,{article:()=>Jq,aside:()=>Yq,div:()=>Hq,footer:()=>Wq,form:()=>Qq,header:()=>Gq,layout:()=>Bq,main:()=>Kq,nav:()=>Xq,section:()=>Vq,template:()=>e6});var Bq,Hq,Vq,Gq,Wq,Jq,Kq,Yq,Xq,Qq,e6,_1=f(()=>{Bq={ex:"element",anchor:["top","left"],dimensions:["width","height"],childrenType:"*",children:[]},Hq={ex:"layout",tagName:"div"},Vq={ex:"layout",tagName:"section"},Gq={ex:"layout",tagName:"header"},Wq={ex:"layout",tagName:"footer"},Jq={ex:"layout",tagName:"article"},Kq={ex:"layout",tagName:"main"},Yq={ex:"layout",tagName:"aside"},Xq={ex:"layout",tagName:"nav"},Qq={ex:"layout",tagName:"form"},e6={ex:"layout",tagName:"template",html:"<div>HTML template</div>",style:{default:{width:"250px",height:"100px"}}}});var v1={};C(v1,{createTextContent:()=>ye});function t6(e){if(typeof e=="string"){let t=e.trim();return t?[t]:null}if(Array.isArray(e)){let t=e.filter(r=>typeof r=="string"&&r.trim());return t.length>0?t:null}return null}function ye({value:e="",mode:t,specificPatterns:r,...n}={}){let o=t6(r);return{...Ne({mode:t??"value",value:e,...n}),...o?{specificPatterns:o}:{}}}var fn=f(()=>{Kt();i(t6,"normalizeSpecificPatterns");i(ye,"createTextContent")});var Uy={};C(Uy,{blockquote:()=>m6,br:()=>b6,codeElement:()=>g6,em:()=>x6,h1:()=>o6,h2:()=>s6,h3:()=>i6,h4:()=>a6,h5:()=>c6,h6:()=>l6,heading:()=>n6,hr:()=>w6,label:()=>f6,mark:()=>v6,p:()=>d6,paragraph:()=>u6,pre:()=>h6,small:()=>_6,span:()=>p6,strong:()=>y6,text:()=>r6});var r6,n6,o6,s6,i6,a6,c6,l6,u6,d6,p6,f6,m6,h6,g6,y6,x6,_6,v6,w6,b6,w1=f(()=>{fn();r6={ex:"element",anchor:["top","left"],dimensions:["width"],childrenType:"text",textContent:ye({value:""})},n6={ex:"text",textContent:ye({value:""}),style:{default:{margin:"0"}}},o6={ex:"heading",tagName:"h1",textContent:ye({value:"Heading 1"})},s6={ex:"heading",tagName:"h2",textContent:ye({value:"Heading 2"})},i6={ex:"heading",tagName:"h3",textContent:ye({value:"Heading 3"})},a6={ex:"heading",tagName:"h4",textContent:ye({value:"Heading 4"})},c6={ex:"heading",tagName:"h5",textContent:ye({value:"Heading 5"})},l6={ex:"heading",tagName:"h6",textContent:ye({value:"Heading 6"})},u6={ex:"text",textContent:ye({value:"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua."}),style:{default:{margin:"0"}}},d6={ex:"paragraph",tagName:"p"},p6={ex:"text",tagName:"span",textContent:ye({value:"Lorem ipsum"})},f6={ex:"text",tagName:"label",textContent:ye({value:"Label text"})},m6={ex:"text",tagName:"blockquote",textContent:ye({value:"Blockquote text"})},h6={ex:"text",tagName:"pre",textContent:ye({value:"Preformatted text"})},g6={ex:"text",tagName:"code",textContent:ye({value:"code"})},y6={ex:"text",tagName:"strong",textContent:ye({value:"Bold text"})},x6={ex:"text",tagName:"em",textContent:ye({value:"Emphasized text"})},_6={ex:"text",tagName:"small",textContent:ye({value:"Small text"})},v6={ex:"text",tagName:"mark",textContent:ye({value:"Highlighted text"})},w6={ex:"element",tagName:"hr",anchor:["top","left"],dimensions:["width"],childrenType:"none"},b6={ex:"element",tagName:"br",anchor:["top","left"],dimensions:["width"],childrenType:"none"}});var qy={};C(qy,{a:()=>$6,button:()=>k6,details:()=>E6,dialog:()=>T6,interactive:()=>S6,summary:()=>N6});var S6,k6,$6,E6,N6,T6,b1=f(()=>{fn();S6={ex:"element",interactive:!0,childrenType:"text",anchor:["top","left"],style:{default:{width:"auto",height:"auto",cursor:"pointer"}}},k6={ex:"interactive",tagName:"button",dimensions:["width","height"],textContent:ye({value:"Button text"}),style:{default:{"background-color":"#e9e9e9",border:"1px solid #d5d5d5","border-radius":"4px",padding:"6px 12px",width:"120px",height:"auto"}}},$6={ex:"interactive",tagName:"a",textContent:ye({value:"Link text"}),destination:{type:"page",id:null,path:null,target:null,replace:!1,params:null,query:null}},E6={ex:"interactive",tagName:"details",childrenType:"*",dimensions:["width","height"],style:{default:{cursor:"default"}}},N6={ex:"interactive",tagName:"summary",textContent:ye({value:"Summary text"})},T6={ex:"interactive",tagName:"dialog",childrenType:"*",dimensions:["width","height"],style:{default:{cursor:"default",width:"300px",height:"200px"}}}});var Hy={};C(Hy,{checkbox:()=>L6,color:()=>M6,date:()=>Z6,email:()=>P6,file:()=>U6,hidden:()=>q6,input:()=>C6,number:()=>A6,password:()=>O6,phone:()=>j6,radio:()=>F6,range:()=>D6,search:()=>R6,select:()=>B6,textInput:()=>I6,textarea:()=>H6});var Zt,z6,Lt,Lr,By,C6,I6,P6,O6,A6,R6,j6,D6,M6,Z6,L6,F6,U6,q6,B6,H6,S1=f(()=>{Kt();Zt=i(e=>Ne({name:"type",mode:"value",value:e,removable:!1}),"type"),z6=i(()=>Ne({name:"value",mode:"value",value:"",removable:!1}),"value"),Lt=i(()=>Ne({name:"model",mode:"binding",binding:null,removable:!0}),"model"),Lr=i(()=>Ne({name:"onInput",mode:"code",code:Gd,removable:!1}),"onInput"),By=i(()=>Ne({name:"onChange",mode:"code",code:Gd,removable:!1}),"onChange"),C6={ex:"element",tagName:"input",anchor:["top","left"],dimensions:["width"],childrenType:"none",style:{default:{width:"auto",height:"auto"}}},I6={ex:"input",attributes:[Zt("text"),Lt()],events:[Lr()]},P6={ex:"input",attributes:[Zt("email"),Lt()],events:[Lr()]},O6={ex:"input",attributes:[Zt("password"),Lt()],events:[Lr()]},A6={ex:"input",attributes:[Zt("number"),Lt()],events:[Lr()]},R6={ex:"input",attributes:[Zt("search"),Lt()],events:[Lr()]},j6={ex:"input",attributes:[Zt("tel"),Lt()],events:[Lr()]},D6={ex:"input",attributes:[Zt("range"),Lt()],events:[Lr()]},M6={ex:"input",attributes:[Zt("color"),Lt()],events:[Lr()]},Z6={ex:"input",attributes:[Zt("date"),Lt()],events:[Lr()]},L6={ex:"input",attributes:[Zt("checkbox"),Lt()],events:[By()]},F6={ex:"input",attributes:[Zt("radio"),Lt()],events:[By()]},U6={ex:"input",attributes:[Zt("file")]},q6={ex:"input",attributes:[Zt("hidden"),z6()]},B6={ex:"input",tagName:"select",childrenType:"options",attributes:[Lt()],events:[By()]},H6={ex:"input",tagName:"textarea",childrenType:"text",dimensions:["width","height"],attributes:[Lt()],events:[Lr()]}});var Vy={};C(Vy,{audio:()=>W6,figcaption:()=>Y6,figure:()=>K6,iframe:()=>X6,img:()=>G6,media:()=>V6,video:()=>J6});var k1,V6,G6,W6,J6,K6,Y6,X6,$1=f(()=>{Kt();k1=Ne({name:"controls",mode:"value",value:!0,removable:!1}),V6={ex:"element",anchor:["top","left"],dimensions:["width","height"],style:{default:{display:"block",width:"auto",height:"auto","object-fit":"contain"}}},G6={ex:"media",tagName:"img",childrenType:"none"},W6={ex:"media",tagName:"audio",childrenType:"none",dimensions:["width"],attributes:[k1],style:{default:{width:"320px"}}},J6={ex:"media",tagName:"video",childrenType:"*",attributes:[k1],style:{default:{width:"320px",height:"240px"}}},K6={ex:"media",tagName:"figure",childrenType:"*",dimensions:["width","height"],style:{default:{width:"auto",height:"auto",margin:"0"}}},Y6={ex:"media",tagName:"figcaption",childrenType:"text"},X6={ex:"media",tagName:"iframe",childrenType:"none",dimensions:["width","height"]}});var Gy={};C(Gy,{dd:()=>o3,dl:()=>r3,dt:()=>n3,li:()=>t3,ol:()=>Q6,ul:()=>e3});var Q6,e3,t3,r3,n3,o3,E1=f(()=>{Q6={ex:"element",tagName:"ol",anchor:["top","left"],dimensions:["width"],childrenType:["li"],children:[]},e3={ex:"element",tagName:"ul",anchor:["top","left"],dimensions:["width"],childrenType:["li"],children:[]},t3={ex:"element",tagName:"li",anchor:["top","left"],dimensions:["width"],childrenType:"text"},r3={ex:"element",tagName:"dl",anchor:["top","left"],dimensions:["width"],childrenType:["dt","dd"],children:[]},n3={ex:"element",tagName:"dt",anchor:["top","left"],dimensions:["width"],childrenType:"text"},o3={ex:"element",tagName:"dd",anchor:["top","left"],dimensions:["width"],childrenType:"text"}});var Wy={};C(Wy,{table:()=>s3,tbody:()=>a3,td:()=>d3,tfoot:()=>c3,th:()=>u3,thead:()=>i3,tr:()=>l3});var s3,i3,a3,c3,l3,u3,d3,N1=f(()=>{s3={ex:"element",tagName:"table",anchor:["top","left"],dimensions:["width"],childrenType:["thead","tbody","tfoot","tr"],children:[]},i3={ex:"element",tagName:"thead",childrenType:["tr"],children:[]},a3={ex:"element",tagName:"tbody",childrenType:["tr"],children:[]},c3={ex:"element",tagName:"tfoot",childrenType:["tr"],children:[]},l3={ex:"element",tagName:"tr",childrenType:["td","th"],children:[]},u3={ex:"element",tagName:"th",childrenType:"*"},d3={ex:"element",tagName:"td",childrenType:"*"}});var Jy={};C(Jy,{fieldset:()=>p3,legend:()=>f3,meter:()=>m3,progress:()=>h3});var p3,f3,m3,h3,T1=f(()=>{p3={ex:"element",tagName:"fieldset",anchor:["top","left"],dimensions:["width","height"],childrenType:"children",style:{default:{border:"1px solid #cccccc",padding:"16px"}}},f3={ex:"element",tagName:"legend",childrenType:"text"},m3={ex:"element",tagName:"meter",childrenType:"none"},h3={ex:"element",tagName:"progress",childrenType:"none"}});var Ky={};C(Ky,{slot:()=>g3});var g3,z1=f(()=>{g3={type:"slot",ex:"element",tagName:"slot",anchor:["top","left"],dimensions:["width","height"],childrenType:"*"}});var C1,I1=f(()=>{C1={type:"frame",ex:"container",tagName:"div",bounds:{top:0,left:0,width:360,height:740,x:void 0,y:void 0},style:{default:{background:"white"}},children:[],route:{path:null}}});var P1,O1=f(()=>{P1={type:"instance",ex:"node",component:null,library:null,props:[],childrenType:"component"}});var A1,R1=f(()=>{A1={type:"code",ex:"node",body:"",language:"js",params:[],returns:null}});var j1,D1=f(()=>{j1={type:"animation",ex:"node",scope:"node",name:null,duration:300,easing:"ease",fill:"none",direction:"normal",iterations:1,delay:0,endDelay:0,iterationStart:0,composite:"replace",keyframes:[]}});var M1,Z1=f(()=>{M1={type:"component",ex:"container",name:"",library:"local",props:[],emits:[],data:[],children:[]}});var L1,F1=f(()=>{L1={type:"graphic",ex:"node",tagName:"div",props:{},template:[],style:{default:{margin:"0",width:"100px",height:"100px"}}}});var Bo,cp=f(()=>{m1();g1();x1();_1();w1();b1();S1();$1();E1();N1();T1();z1();I1();O1();R1();D1();Z1();F1();Xy();dp();Bo={node:f1,element:h1,container:y1,...Fy,...Uy,...qy,...Hy,...Vy,...Gy,...Wy,...Jy,...Ky,frame:C1,instance:P1,code:A1,animation:j1,component:M1,graphic:L1}});function lp(e){let t=[],r=e;for(;r&&Bo[r];)t.push(r),r=Bo[r].ex;return t}function up(e){return Bo[e]?.ex??null}function Ai(e){return!!Bo[e]}function Yy(e){let t=e?.ex??e?.type;for(let r of lp(t))if(y3.has(r))return r;return null}var y3,Xy=f(()=>{cp();i(lp,"chainOf");i(up,"baseOf");i(Ai,"isKnownType");y3=new Set(["element","container","frame","instance","component","slot","animation","graphic","code","node"]);i(Yy,"categoryOf")});function x3(e,t){let r=new Map(e.map(n=>[n.name,n]));for(let n of t)r.set(n.name,n);return Array.from(r.values())}function U1(e,t){let r=lp(e).reverse(),n=[];for(let o of r){let s=Bo[o];s?.[t]&&(n=x3(n,s[t]))}return n}function Ho(e,t={}){if(!Ai(e))throw new Error(`createNode: unknown prototype "${e}". Did you mean to register it first?`);let r=Yy({type:e}),n=r===e?{type:e,...t}:{type:r,ex:e,...t};if(!n.attributes){let o=U1(e,"attributes");o.length&&(n.attributes=o.map(s=>({...s})))}if(!n.events){let o=U1(e,"events");o.length&&(n.events=o.map(s=>({...s})))}return[kc(),n]}var dp=f(()=>{Vd();Xy();cp();i(x3,"mergeByName");i(U1,"resolveDescriptors");i(Ho,"createNode")});function Vo(e){return pp.find(t=>t.key===e)??null}function Qy(){return pp.map(e=>e.key)}function Cc(e,t={}){if(e==="custom")return{name:t.name||"Custom",bounds:{width:t.width??q1.width,height:t.height??q1.height,x:0,y:0}};let r=Vo(e);if(!r)throw new Error(`Unknown frame preset "${e}". Available: ${Qy().join(", ")}`);return{name:e,bounds:{width:r.width,height:r.height,x:0,y:0}}}var pp,q1,Go=f(()=>{pp=[{key:"iPhone 15",category:"phone",width:393,height:852},{key:"iPhone SE",category:"phone",width:375,height:667},{key:"Pixel 8",category:"phone",width:412,height:915},{key:"Galaxy S24",category:"phone",width:360,height:780},{key:"iPad Air",category:"tablet",width:820,height:1180},{key:"iPad Mini",category:"tablet",width:768,height:1024},{key:"Surface Pro",category:"tablet",width:912,height:1368},{key:"Desktop",category:"desktop",width:1280,height:800},{key:"Desktop Large",category:"desktop",width:1920,height:1080},{key:"custom",category:"custom",width:null,height:null}];i(Vo,"getFramePreset");i(Qy,"getAvailableFrames");q1={width:360,height:740,x:0,y:0};i(Cc,"createFrameOverrides")});function B1(e={}){let t=e.frame??e.viewport;if(!t)return e;let{frame:r,viewport:n,width:o,height:s,name:a,bounds:c,...l}=e,{name:u,bounds:d}=Cc(t,{name:a,width:o,height:s});return{...l,frame:t,name:u,bounds:{x:c?.x??d.x??0,y:c?.y??d.y??0,width:c?.width??d.width,height:c?.height??d.height}}}function fp(e={}){let[t,r]=Ho("frame",B1(e));return r.route={path:`${t}`},[t,r]}function Jn(e,t,r={}){let[n,o]=t==="frame"?fp(r):Ho(t,r);return e.set([n],o),n}var Ri=f(()=>{dp();Go();i(B1,"buildFrameNodeProps");i(fp,"createFrameNode");i(Jn,"createNodeEntry")});var H1={};C(H1,{addNode:()=>Ic});function Ic(e,t,r,n="app"){let o=Jn(e,t,r);return Zr(e,o,n),o}var mp=f(()=>{Ri();Ci();i(Ic,"addNode")});function V1(e,t,r){let n=Jn(e,t,r);return Yd(e,n),n}var G1=f(()=>{Ri();Ey();i(V1,"addTemp")});function v3(e,t){let r=e.get([t,"children"])??[],n=0;for(let o of r){let s=e.get([o]);if(s?.type!=="slot")continue;let a=_3.exec(s.name??"");a&&(n=Math.max(n,Number(a[1])))}return`Slot ${n+1}`}function W1(e,t,r={}){let n=r.name??v3(e,t),o=Jn(e,"slot",{...r,name:n});return e.update([t,"children"],(s=[])=>[...s,o]),o}var _3,J1=f(()=>{Ri();_3=/^Slot (\d+)$/;i(v3,"nextSlotName");i(W1,"addSlot")});function hp(e,t,r){if(!$t(e,t)||!$t(e,r))return!1;let n=e.findWhen("children","includes",t);return n?(e.update(n,(o=[])=>o.map(s=>s===t?r:s)),!0):!1}var ex=f(()=>{vi();i(hp,"replaceNode")});function K1(e,t){let n=e.get([t])?.type;return n==="frame"||n==="viewport"}var Y1=f(()=>{i(K1,"isFrameNode")});var tT={};C(tT,{addComponent:()=>tx});function b3(e,t,r,n){let o=e.get([t,"style"]);if(!o)return;let s=new Set(n??[]);for(let a in o){let c=o[a];if(!c||typeof c!="object")continue;let l={},u=!1;for(let d of eT)d in c&&s.has(d)&&(l[d]=c[d],u=!0);u&&(e.update([r,"style",a],(d={})=>({...d,...l})),e.update([t,"style",a],(d={})=>{let p={...d};for(let m of w3)delete p[m];return p}))}}function X1(e,t){Qd(e,t),e.remove([t,".position"]),e.remove([t,"bounds"]),e.set([t,"anchor"],[]),un(e,t,{width:"100%",height:"100%"})}function Q1(e,t){let r=xr(e,t);for(let n of r)e.remove([n]);e.remove([t])}function tx(e,t,r,n=null){let o=Ni(e,t),s=o==="root"||o==="temp",a=K1(e,t),c=e.get([t,".position"]),l=e.get([t,"anchor"]),u=e.get([t,"dimensions"]),d=Pi(e,t),[p,m]=qo(d),h=p[0],g,_=null;if(a){g=[...m[h]?.children??[]];for(let[E,I]of Object.entries(m))E!==h&&e.set([E],I)}else{_=p[0];for(let[E,I]of Object.entries(m))e.set([E],I);g=[_]}let x=n??e.get([t,"bounds"])??null,v={children:g,name:r};x&&(v.bounds=x);let[b,w]=Ho("component",v);e.set([b],w),e.update(["components","children"],(E=[])=>E.indexOf(b)===-1?[...E,b]:E);let S=null;if(s)yr(e,t),Q1(e,t),_&&X1(e,_);else{let[E,I]=Ho("instance",{component:b});S=E,e.set([S],I),hp(e,t,S),Q1(e,t),c&&e.set([S,".position"],c),l&&e.set([S,"anchor"],l),u&&e.set([S,"dimensions"],u),_&&(b3(e,_,S,l),X1(e,_))}return{componentId:b,instanceId:S}}var eT,w3,rx=f(()=>{dp();ex();sp();zc();bi();tp();Y1();Ty();Lo();wi();eT=["top","left","right","bottom"],w3=[...eT];i(b3,"migratePositionalStyles");i(X1,"fitClonedRoot");i(Q1,"removeOriginalTree");i(tx,"addComponent")});function gp(e,t,r,{breakpoint:n="default",interactionState:o}={}){let s=ki(n),a=o??e.get([t,".interactionState"])??[];return e.remove([t,"style",s,...a,r])}var nx=f(()=>{ep();i(gp,"removeStyle")});function rT(e,t,r){e.update([t,"style","default"],(n={})=>({...n,display:r}))}var nT=f(()=>{i(rT,"setDisplayMode")});var sT={};C(sT,{setNodeLayout:()=>Pc});function Pc(e,t,r){let n=r==null||r===""?"none":r;dn(e,t,{layout:n}),n==="none"?gp(e,t,"display"):oT[n]&&rT(e,t,oT[n]);let o=e.get([t,"children"])??[];for(let s of o)Je(e,s,t);if(e.get([t,"type"])==="slot"){let s=e.findAllWhen("id","is",t);for(let a of s){let c=e.get(a.slice(0,-1));for(let l of c?.children??[])Je(e,l,t)}}return{id:t,layout:n,childrenUpdated:o.length}}var oT,yp=f(()=>{Tc();pn();nx();nT();oT={block:"block",flex:"flex",grid:"grid"};i(Pc,"setNodeLayout")});function xp({name:e,mode:t,...r}={}){return Ne({name:e,mode:t??"value",...r})}var ox=f(()=>{Kt();i(xp,"createAttribute")});var iT={};C(iT,{removeAttribute:()=>Oc});function Oc(e,t,r){typeof e.removeAllWhere=="function"?e.removeAllWhere([t,"attributes"],{name:r}):e.removeWhere([t,"attributes"],{name:r})}var _p=f(()=>{i(Oc,"removeAttribute")});function vp(e,t,r){if(!S3.has(r))return[];let n=r==="model"?["value","checked"]:["model"],o=[];for(let s of n)(e.get([t,"attributes"])??[]).some(c=>c.name===s)&&(Oc(e,t,s),o.push(s));return e.get([t,"model"])!=null&&e.remove([t,"model"]),o}var S3,sx=f(()=>{_p();S3=new Set(["model","value","checked"]);i(vp,"clearValueChannelConflict")});var aT={};C(aT,{updateAttribute:()=>Ac});function Ac(e,t,r,n){let o=xp(n),s=o.name??r;vp(e,t,s),e.findWhere([t,"attributes"],{name:r})!==void 0?e.setWhere([t,"attributes"],{name:r},o):e.push([t,"attributes"],o)}var wp=f(()=>{ox();sx();i(Ac,"updateAttribute")});var cT={};C(cT,{addTree:()=>ix});function ix(e,t,r="app",n={}){let{onWarn:o}=n,s=[],a={},c=i((u,d)=>{let{type:p,children:m,styles:h,style:g,text:_,ref:x,bounds:v,attributes:b,className:w,layout:S,specificPatterns:E,...I}=u,z=Ic(e,p,I,d);if(s.push(z),x&&(a[x]=z),p==="frame"&&v){let{x:J,y:te}=v,Ve=e.get([z,"bounds"])??{};e.set([z,"bounds"],{...Ve,...J!=null?{x:J}:{},...te!=null?{y:te}:{}})}let M=I.name;if(M&&e.set([z,"name"],M),Array.isArray(b))for(let J of b)J?.name&&Ac(e,z,J.name,J);if(Array.isArray(w))for(let J of w)typeof J=="string"&&J.trim()&&Jd(e,z,J.trim());let D=h||g;D&&Object.keys(D).length>0&&un(e,z,{...D});let Z=D?.display??e.get([z,"style","default","display"]),H=S??(Z==="flex"||Z==="grid"?Z:null),ce=H!=null&&H!=="none";if(ce)try{Pc(e,z,H)}catch(J){o?.("setNodeLayout failed for parent",{id:z,error:J.message})}return _&&!(m?.length>0)&&e.set([z,"textContent"],ye({value:_,specificPatterns:E})),m&&m.length>0&&m.forEach(J=>{if(H==="flex"||H==="grid"){let Ve=J.styles||J.style||{};Ve.position!=="absolute"&&(J={...J,styles:{width:"auto",height:"auto",top:"auto",left:"auto",...Ve}})}let te=c(J,z);ce&&Je(e,te,z)}),z},"createRecursive");return{rootId:c(t,r),createdIds:s,treeMap:a}}var ax=f(()=>{mp();Lo();yp();pn();wp();$y();fn();i(ix,"addTree")});import{defineContracts as k3}from"@jucie.io/engine-message";var $3,lT=f(()=>{mp();Ci();rp();G1();J1();Oy();rx();ax();Ei();Lo();Ri();$3=k3("node:add",e=>{let t=e("state")?.ref(["nodes"])??null;if(!t)throw new Error("Node cache not found");return{element:{namespace:"scene-graph",schema:["String","Object","Object"],handler:(r,n,o)=>{if(r==="slot")return[W1(t,o?.parent??"app",n)];let s=Jn(t,r,n);return o?.after?Ii(t,s,o.after):Zr(t,s,o?.parent??"app"),[s]}},tree:{namespace:"scene-graph",schema:["Object","String"],handler:(r,n)=>{let o=t.batch();try{return ix(t,r,n??"app")}finally{o()}}},tempNode:{namespace:"scene-graph",schema:["String","Object"],handler:(r,n)=>[V1(t,r,n)]},component:{namespace:"scene-graph",schema:["String","String","Object"],handler:(r,n,o)=>{let{componentId:s,instanceId:a}=tx(t,r,n,o);return[a??s]}},duplicates:{namespace:"scene-graph",schema:["Array"],handler:r=>{for(let o of r)Yt(t,o);return ip(t,r)}},images:{namespace:"scene-graph",schema:["Array"],handler:r=>{let n=[],o=t.batch();for(let s of r){let a=Ic(t,"img",{name:s.meta.name,attributes:[{name:"src",value:s.url},{name:"alt",value:s.meta.name}]});n.push(a)}return o(),n}}}})});function bp({name:e,mode:t,...r}={}){return Ne({name:e,mode:t??"binding",...r})}var cx=f(()=>{Kt();i(bp,"createEvent")});var uT={};C(uT,{addEvent:()=>lx});function lx(e,t,r){return e.unshift([t,"events"],bp({name:r}))}var ux=f(()=>{cx();i(lx,"addEvent")});var px={};C(px,{updateEvent:()=>dx});function dx(e,t,r,n){return e.setWhere([t,"events"],{name:r},bp(n))}var Sp=f(()=>{cx();i(dx,"updateEvent")});var dT={};C(dT,{removeEvent:()=>fx});function fx(e,t,r){return e.removeWhere([t,"events"],{name:r})}var mx=f(()=>{i(fx,"removeEvent")});import{defineContracts as E3}from"@jucie.io/engine-message";var N3,pT=f(()=>{ux();Sp();mx();N3=E3("node:event",e=>{let t=e("state")?.ref(["nodes"])??null;if(!t)throw new Error("Node cache not found");return{add:{namespace:"scene-graph",schema:["String","String"],handler:(r,n)=>lx(t,r,n)},update:{namespace:"scene-graph",schema:["String","String","Object"],handler:(r,n,o)=>dx(t,r,n,o)},remove:{namespace:"scene-graph",schema:["String","String"],handler:(r,n)=>fx(t,r,n)}}})});var fT={};C(fT,{addAttribute:()=>hx});function hx(e,t,r={}){let o=xp(typeof r=="string"?{name:r}:r);return o.name&&vp(e,t,o.name),e.unshift([t,"attributes"],o)}var gx=f(()=>{ox();sx();i(hx,"addAttribute")});import{defineContracts as T3}from"@jucie.io/engine-message";var z3,mT=f(()=>{gx();wp();_p();z3=T3("node:attribute",e=>{let t=e("state")?.ref(["nodes"])??null;if(!t)throw new Error("Node cache not found");return{add:{namespace:"scene-graph",schema:["String","String"],handler:(r,n)=>hx(t,r,n)},update:{namespace:"scene-graph",schema:["String","String","Object"],handler:(r,n,o)=>Ac(t,r,n,o)},remove:{namespace:"scene-graph",schema:["String","String"],handler:(r,n)=>Oc(t,r,n)}}})});function Rc({name:e,mode:t,...r}={}){return Ne({name:e,mode:t??"value",...r})}var kp=f(()=>{Kt();i(Rc,"createProp")});function hT(e,t,r={}){let o=Rc(typeof r=="string"?{name:r}:r);return e.unshift([t,"props"],o)}var gT=f(()=>{kp();i(hT,"addProp")});function yT(e,t,r,n){let o=Rc(n);e.findWhere([t,"props"],{name:r})!==void 0?e.setWhere([t,"props"],{name:r},o):e.push([t,"props"],o)}var xT=f(()=>{kp();i(yT,"updateProp")});function _T(e,t,r){typeof e.removeAllWhere=="function"?e.removeAllWhere([t,"props"],{name:r}):e.removeWhere([t,"props"],{name:r})}var vT=f(()=>{i(_T,"removeProp")});import{defineContracts as C3}from"@jucie.io/engine-message";var I3,wT=f(()=>{gT();xT();vT();I3=C3("node:prop",e=>{let t=e("state")?.ref(["nodes"])??null;if(!t)throw new Error("Node cache not found");return{add:{namespace:"scene-graph",schema:["String","Object"],handler:(r,n)=>hT(t,r,n)},update:{namespace:"scene-graph",schema:["String","String","Object"],handler:(r,n,o)=>yT(t,r,n,o)},remove:{namespace:"scene-graph",schema:["String","String"],handler:(r,n)=>_T(t,r,n)}}})});function bT(e,t,r,n){e.updateWhere([t,"slots"],{id:r},o=>{switch(o.childrenType){case"text":return{...o,textContent:Ne(n)};default:return o}})}var ST=f(()=>{fn();Kt();i(bT,"updateSlot")});function kT(e=[]){if(!Array.isArray(e))return[];let t=[];for(let r of e){if(!r||typeof r=="string"||!r.id)continue;let n=r.childrenType??"children";if(r.required===!0||n==="text"&&r.textContent!=null){if(n==="text"){let s=r.textContent?.value??"";t.push({id:r.id,name:r.name,childrenType:"text",textContent:ye({value:s}),children:null});continue}t.push({id:r.id,name:r.name,childrenType:n,textContent:null,children:[]})}}return t}function yx(e=[],t=[]){let r=Array.isArray(e)?[...e]:[],n=new Set(r.map(o=>o?.id).filter(Boolean));for(let o of kT(t))n.has(o.id)||(r.push(o),n.add(o.id));return r}var xx=f(()=>{fn();i(kT,"buildSlotsFromMeta");i(yx,"mergeMissingSlotsFromMeta")});function $T(e,t,r=[]){if(!t)return;let n=e.get([t,"slots"])??[],o=yx(n,r),s=new Set(n.map(c=>c?.id).filter(Boolean));o.some(c=>c?.id&&!s.has(c.id))&&e.set([t,"slots"],o)}var ET=f(()=>{xx();i($T,"ensureSlotsFromMeta")});import{defineContracts as P3}from"@jucie.io/engine-message";var O3,NT=f(()=>{ST();ET();O3=P3("node:slot",e=>{let t=e("state")?.ref(["nodes"])??null;if(!t)throw new Error("Node cache not found");return{update:{namespace:"scene-graph",schema:["String","String","Object"],handler:(r,n,o)=>{bT(t,r,n,o)}},ensureFromMeta:{namespace:"scene-graph",schema:["String","Array"],handler:(r,n)=>{$T(t,r,n)}}}})});var TT={};C(TT,{updateHtml:()=>_x});function _x(e,t,r){return e.set([t,"html"],r)}var vx=f(()=>{i(_x,"updateHtml")});import{defineContracts as A3}from"@jucie.io/engine-message";var R3,zT=f(()=>{vx();R3=A3("node:html",e=>{let t=e("state")?.ref(["nodes"])??null;if(!t)throw new Error("Node cache not found");return{update:{schema:["String","String"],handler:(r,n)=>{_x(t,r,n)},namespace:"scene-graph"}}})});function $p({path:e=null,target:t=null,id:r=null,type:n="url",replace:o=!1,params:s=[],query:a=null}){return{path:e,target:t,id:r,type:n,replace:o,params:s,query:a}}var wx=f(()=>{i($p,"createDestination")});function CT(e,t,r){return e.update([t,"destination"],(n={})=>$p({...n,...r}))}var IT=f(()=>{wx();i(CT,"updateDestination")});var PT={};C(PT,{setDestination:()=>bx});function bx(e,t,r={}){return e.set([t,"destination"],$p(r))}var Sx=f(()=>{wx();i(bx,"setDestination")});var OT={};C(OT,{clearDestination:()=>kx});function kx(e,t){return e.remove([t,"destination"])}var $x=f(()=>{i(kx,"clearDestination")});import{defineContracts as j3}from"@jucie.io/engine-message";var D3,AT=f(()=>{IT();Sx();$x();D3=j3("node:destination",e=>{let t=e("state")?.ref(["nodes"])??null;if(!t)throw new Error("Node cache not found");return{set:{namespace:"scene-graph",schema:["String","Object"],handler:(r,n={})=>{bx(t,r,n)}},update:{namespace:"scene-graph",schema:["String","Object"],handler:(r,n)=>{CT(t,r,n)}},remove:{namespace:"scene-graph",schema:["String"],handler:r=>{kx(t,r)}}}})});function RT(e,t,r){return e.update([t,".position"],(n={x:0,y:0})=>({...n,...r}))}var jT=f(()=>{i(RT,"updatePosition")});import{defineContracts as M3}from"@jucie.io/engine-message";var Z3,DT=f(()=>{Ei();jT();Z3=M3("node:drag",e=>{let t=e("state"),r=t?.ref(["nodes"])??null,n=null;if(!t||!r)throw new Error("State or node cache not found");return{start:{namespace:"scene-graph",handler:()=>n=t.history?.group()},apply:{namespace:"scene-graph",schema:["Array"],handler:o=>{for(let[s,a]of o)s&&a[".position"]&&RT(r,s,a[".position"])}},end:{namespace:"scene-graph",schema:["Array"],handler:o=>{for(let s of o)s&&Yt(r,s);n?(n("Drag nodes"),n=null):t.history?.commit("Drag nodes")}},clear:{namespace:"scene-graph",schema:["Array"],handler:o=>{for(let s of o)s&&Yt(r,s);n&&(n(),n=null)}}}})});function Ep({key:e,mode:t,binding:r=null,code:n=""}){return{key:e,mode:t??"binding",binding:r,code:n}}var Ex=f(()=>{i(Ep,"createLifecycleHook")});var MT={};C(MT,{addLifecycleHook:()=>Nx});function Nx(e,t,r){return e.unshift([t,"lifecycle"],Ep({key:r}))}var Tx=f(()=>{Ex();i(Nx,"addLifecycleHook")});var Cx={};C(Cx,{updateLifecycleHook:()=>zx});function zx(e,t,r,n){return e.setWhere([t,"lifecycle"],{key:r},Ep(n))}var Np=f(()=>{Ex();i(zx,"updateLifecycleHook")});var ZT={};C(ZT,{removeLifecycleHook:()=>Ix});function Ix(e,t,r){return e.removeWhere([t,"lifecycle"],{key:r})}var Px=f(()=>{i(Ix,"removeLifecycleHook")});import{defineContracts as L3}from"@jucie.io/engine-message";var F3,LT=f(()=>{Tx();Np();Px();F3=L3("node:lifecycle",e=>{let t=e("state")?.ref(["nodes"])??null;if(!t)throw new Error("Node cache not found");return{add:{namespace:"scene-graph",schema:["String","String"],handler:(r,n)=>Nx(t,r,n)},update:{namespace:"scene-graph",schema:["String","String","Object"],handler:(r,n,o)=>zx(t,r,n,o)},remove:{namespace:"scene-graph",schema:["String","String"],handler:(r,n)=>Ix(t,r,n)}}})});function FT(e,t,r){if(!(e.get([t,".interactionState"])??[]).includes(r))return e.push([t,".interactionState"],r)}var UT=f(()=>{i(FT,"addInteractionState")});function qT(e,t,r){let o=(e.get([t,".interactionState"])??[]).indexOf(r);if(o!==-1)return e.splice([t,".interactionState"],o,1)}var BT=f(()=>{i(qT,"removeInteractionState")});function HT(e,t){e.remove([t,".interactionState"])}var VT=f(()=>{i(HT,"clearInteractionState")});import{defineContracts as U3}from"@jucie.io/engine-message";var q3,GT=f(()=>{UT();BT();VT();q3=U3("node:interactionState",e=>{let t=e("state")?.ref(["nodes"])??null;if(!t)throw new Error("Node cache not found");return{add:{schema:["String","String"],namespace:"scene-graph",handler:(r,n)=>{FT(t,r,n)}},remove:{namespace:"scene-graph",schema:["String","String"],handler:(r,n)=>{qT(t,r,n)}},clear:{namespace:"scene-graph",schema:["String"],handler:r=>{HT(t,r)}}}})});import{defineContracts as B3}from"@jucie.io/engine-message";var H3,WT=f(()=>{Ei();Tc();Oi();H3=B3("node:patch",e=>{let[t,r]=e("state","sceneCompiler"),n=t?.ref(["nodes"])??null,o=null;if(!t||!n)throw new Error("State or node cache not found");return{start:{namespace:"scene-graph",schema:"*",handler:()=>{o=t.history?.group()}},apply:{namespace:"scene-graph",schema:["Array"],handler:s=>{let a=t.batch();for(let[c,l]of s){if(!c||!l||!Qt(n,c))continue;let u=r.getActiveBreakpoint(c);dn(n,c,l,u)}a()}},end:{namespace:"scene-graph",schema:["String"],handler:(s="Patch")=>{o?(o(s),o=null):t.history?.commit(s)}},clear:{namespace:"scene-graph",schema:["Array"],handler:s=>{for(let a of s)a&&Yt(n,a);o&&(o(),o=null)}}}})});import{defineContracts as V3}from"@jucie.io/engine-message";var G3,JT=f(()=>{Tc();G3=V3("node:behavior",e=>{let t=e("state")?.ref(["nodes"])??null;if(!t)throw new Error("Node cache not found");return{set:{schema:["String","Object"],handler:(r,n)=>{KN(t,r,n)},namespace:"scene-graph"},update:{schema:["Array"],handler:r=>{for(let[n,o]of r)dn(t,n,o)},namespace:"scene-graph"},clear:{schema:["String"],handler:r=>{YN(t,r)},namespace:"scene-graph"}}})});import{defineContracts as W3}from"@jucie.io/engine-message";var J3,KT=f(()=>{yp();Oi();J3=W3("node:layout",e=>{let t=e("state")?.ref(["nodes"])??null;if(!t)throw new Error("Node cache not found");return{set:{schema:["String","String"],handler:(r,n)=>{if(Qt(t,r))return Pc(t,r,n)},namespace:"scene-graph"}}})});function YT({id:e=null,name:t=void 0,children:r=[]}={}){return{id:e,name:t,children:r}}var XT=f(()=>{i(YT,"createSlotChild")});function K3(e,t,{before:r,after:n}={}){if(e.includes(t))return e;if(r){let o=e.indexOf(r);if(o===-1)return[t,...e];let s=[...e];return s.splice(o,0,t),s}if(n){let o=e.indexOf(n);if(o===-1)return[...e,t];let s=[...e];return s.splice(o+1,0,t),s}return[...e,t]}function QT(e,t,r,{slotId:n=null,name:o=void 0,before:s,after:a}={}){if($t(e,r)&&$t(e,t)){if(!Mr(e,t,r,"lastChildOf")){Mt(e,t);return}return e.update([r,"slots"],(c=[])=>{let l=c.findIndex(m=>m.id===n);if(l===-1)return[...c,YT({id:n,name:o,children:[t]})];let u=c[l],d=u.children||[],p=[...c];return p[l]={...u,children:K3(d,t,{before:s,after:a})},p}),Je(e,t,n||r),!0}}var ez=f(()=>{XT();Ti();vi();Fo();pn();i(K3,"insertIntoSlotChildren");i(QT,"moveNodeToSlotChildOf")});function Tp(e,t){if(!t)return;let r=i(o=>{if(!e.has([o]))return;let s=e.get([o,"slots"]);!Array.isArray(s)||!s.length||e.update([o,"slots"],(a=[])=>{let c=!1,l=a.map(u=>{let d=u.children||[];return d.includes(t)?(c=!0,{...u,children:d.filter(p=>p!==t)}):u});return c?l:a})},"stripFromSlots");r("app"),r("temp");let n=i(o=>{for(let s of o||[])e.has([s])&&(r(s),n(e.get([s,"children"])||[]))},"visit");n(e.get(["app","children"])),n(e.get(["temp","children"]))}var Ox=f(()=>{i(Tp,"removeNodeIdFromAllInstanceSlots")});function tz(e,t,r,n){if(!$t(e,t)||!$t(e,r))return!1;let o=e.get([t,"ex"])??e.get([t,"type"]);return!(!Xt(e,r,o)||!Mr(e,t,r,n))}var rz=f(()=>{vi();Uo();Ti();i(tz,"canNestUnder")});import{defineContracts as Y3}from"@jucie.io/engine-message";var X3,nz=f(()=>{Ci();ez();Iy();rp();Fo();wi();Ox();Ei();rz();Oi();tp();X3=Y3("node:move",e=>{let t=e("state")?.ref(["nodes"])??null;if(!t)throw new Error("Node cache not found");return{apply:{namespace:"scene-graph",schema:["Array","Object"],handler:(r,n)=>{let o=r.filter(c=>Qt(t,c)),s=[],a=[];for(let c of o)n.before||n.after||n.instance?s.push(c):n.parent?tz(t,c,n.parent,"lastChildOf")?s.push(c):Ni(t,c)==="temp"&&a.push(c):s.push(c);if(!(s.length===0&&a.length===0)){for(let c of s)yr(t,c),Yt(t,c),Tp(t,c);if(n.instance)for(let c of s)QT(t,c,n.instance,{slotId:n.slotId,name:n.name,before:n.before,after:n.after});else if(n.before)for(let c of s)np(t,c,n.before);else if(n.after)for(let c of s)Ii(t,c,n.after);else if(n.parent)for(let c of s)Zr(t,c,n.parent);for(let c of a)yr(t,c),Yt(t,c),Mt(t,c)}}}}})});var oz={};C(oz,{setName:()=>Ax});function Ax(e,t,r){return e.set([t,"name"],r)}var Rx=f(()=>{i(Ax,"setName")});function sz(e,t,r){return e.set([t,"name"],r)}var iz=f(()=>{i(sz,"updateName")});var Dx={};C(Dx,{clearName:()=>jx});function jx(e,t){return e.remove([t,"name"])}var zp=f(()=>{i(jx,"clearName")});import{defineContracts as Q3}from"@jucie.io/engine-message";var eB,az=f(()=>{Rx();iz();zp();eB=Q3("node:name",e=>{let t=e("state")?.ref(["nodes"])??null;if(!t)throw new Error("Node cache not found");return{set:{schema:["String","String"],handler:(r,n)=>{Ax(t,r,n)},namespace:"scene-graph"},update:{schema:["String","String"],handler:(r,n)=>{sz(t,r,n)},namespace:"scene-graph"},clear:{schema:["String"],handler:r=>{jx(t,r)},namespace:"scene-graph"}}})});function jc({value:e,label:t}){return{value:e,label:t||e}}var Cp=f(()=>{i(jc,"createOption")});var cz={};C(cz,{addOption:()=>Mx});function Mx(e,t,{value:r,label:n}){return e.push([t,"options","set"],jc({value:r,label:n}))}var Zx=f(()=>{Cp();i(Mx,"addOption")});var lz={};C(lz,{updateOption:()=>Lx});function Lx(e,t,r,{value:n,label:o}){let s=jc({value:n,label:o});return e.findWhere([t,"options","set"],{value:r})===void 0?e.push([t,"options","set"],s):e.setWhere([t,"options","set"],{value:r},s)}var Fx=f(()=>{Cp();i(Lx,"updateOption")});var uz={};C(uz,{removeOption:()=>Ux});function Ux(e,t,r){return e.removeWhere([t,"options","set"],{value:r})}var qx=f(()=>{i(Ux,"removeOption")});var dz={};C(dz,{setOptionsExpression:()=>Bx});function Ip(e){let t=Bd(e)?xy(e):null;return{value:(e??"").trim(),expression:t,dependencies:t?Sc(t):[]}}function Bx(e,t,{binding:r,valueKey:n,labelKey:o}){let s=Bd(r)?xy(r):null;return e.update([t,"options"],(a={})=>({...a,type:"binding",binding:r??a.binding,expression:s??a.expression,dependencies:s?Sc(s):a.dependencies??[],valueKey:n!==void 0?Ip(n):a.valueKey??Ip("value"),labelKey:o!==void 0?Ip(o):a.labelKey??Ip("label")}))}var Hx=f(()=>{_y();i(Ip,"parseField");i(Bx,"setOptionsExpression")});var pz={};C(pz,{clearOptionsExpression:()=>Vx});function Vx(e,t){return e.update([t,"options"],(r={})=>({...r,type:"set",binding:null,expression:null,dependencies:[],valueKey:{value:"value",expression:null,dependencies:[]},labelKey:{value:"label",expression:null,dependencies:[]}}))}var Gx=f(()=>{i(Vx,"clearOptionsExpression")});import{defineContracts as tB}from"@jucie.io/engine-message";var rB,fz=f(()=>{Zx();Fx();qx();Hx();Gx();rB=tB("node:options",e=>{let t=e("state")?.ref(["nodes"])??null;if(!t)throw new Error("Node cache not found");return{add:{schema:["String","Object"],handler:(r,n)=>{Mx(t,r,n)},namespace:"scene-graph"},update:{schema:["String","String","Object"],handler:(r,n,o)=>{Lx(t,r,n,o)},namespace:"scene-graph"},remove:{schema:["String","String"],handler:(r,n)=>{Ux(t,r,n)},namespace:"scene-graph"},setExpression:{schema:["String","Object"],handler:(r,n)=>{Bx(t,r,n)},namespace:"scene-graph"},clearExpression:{schema:["String"],handler:r=>{Vx(t,r)},namespace:"scene-graph"}}})});import{defineContracts as nB}from"@jucie.io/engine-message";var oB,mz=f(()=>{oB=nB("node:order",e=>{let t=e("state")?.ref(["nodes"])??null;if(!t)throw new Error("Node cache not found");return{bringToFront:{schema:["Array"],handler:r=>{for(let n of r){let o=t.findWhen("children","includes",n);o&&t.update(o,(s=[])=>[...s.filter(c=>c!==n),n])}},namespace:"scene-graph"},sendToBack:{schema:["Array"],handler:r=>{for(let n of r){let o=t.findWhen("children","includes",n);o&&t.update(o,(s=[])=>{let a=s.filter(c=>c!==n);return[n,...a]})}},namespace:"scene-graph"},moveForward:{schema:["Array"],handler:r=>{for(let n of r){let o=t.findWhen("children","includes",n);o&&t.update(o,(s=[])=>{let a=s.indexOf(n);if(a===-1||a===s.length-1)return s;let c=[...s];return[c[a],c[a+1]]=[c[a+1],c[a]],c})}},namespace:"scene-graph"},moveBackward:{schema:["Array"],handler:r=>{for(let n of r){let o=t.findWhen("children","includes",n);o&&t.update(o,(s=[])=>{let a=s.indexOf(n);if(a===-1||a===0)return s;let c=[...s];return[c[a],c[a-1]]=[c[a-1],c[a]],c})}},namespace:"scene-graph"}}})});var hz={};C(hz,{removeNode:()=>Wx});function Wx(e,t){let r=xr(e,t);for(let o of[t,...r])Tp(e,o);yr(e,t);let n={};for(let o of r)yr(e,o),n[o]=e.remove(o);return n[t]=e.remove([t]),[t,n]}var Jx=f(()=>{wi();bi();Ox();i(Wx,"removeNode")});function Kx(e,t,r){let n=new Set(Array.isArray(r)?r:[r]),o=[];function s(c){if(e.has([c])){let u=e.get([c,"type"]);n.has(u)&&o.push(c)}let l=e.get([c,"children"])||[];for(let u of l)s(u)}i(s,"visit");let a=e.get([t,"children"])||[];for(let c of a)s(c);return o}var gz=f(()=>{i(Kx,"findDescendantsOfType")});function yz(e,t){let r=e.get([t,"children"])||[];if(r.length===0)return[];let n=[...Kx(e,"app","instance"),...Kx(e,"temp","instance")].filter(s=>e.get([s,"component"])===t);if(n.length===0)return[];let o=[];for(let s of n){let a=e.get([s,".position"]),c=e.get([s,"anchor"]),l=e.get([s,"dimensions"]),u=e.get([s,"style"]),d={};for(let g of r)Object.assign(d,Pi(e,g));let[p,m]=qo(d);for(let[g,_]of Object.entries(m))e.set([g],_);let h;if(p.length===1)h=p[0];else{h=p[0];for(let g=1;g<p.length;g++)e.update([h,"children"],(_=[])=>[..._,p[g]])}a&&e.set([h,".position"],a),c&&e.set([h,"anchor"],c),l&&e.set([h,"dimensions"],l),u&&e.update([h,"style"],(g={})=>{let _={...g};for(let x in u)_[x]={..._[x]||{},...u[x]};return _}),hp(e,s,h),e.remove([s]),o.push(h)}return o}var xz=f(()=>{sp();zc();ex();gz();i(yz,"dissolveComponent")});import{defineContracts as sB}from"@jucie.io/engine-message";var iB,_z=f(()=>{Jx();xz();iB=sB("node:remove",e=>{let t=e("state")?.ref(["nodes"])??null;if(!t)throw new Error("Node cache not found");return{nodes:{namespace:"scene-graph",schema:["Array"],handler:r=>{for(let n of r)t.get([n,"type"])==="component"&&yz(t,n),Wx(t,n)}}}})});function Pp({mode:e,...t}={}){return Ne({mode:e??"value",...t})}var Yx=f(()=>{Kt();i(Pp,"createRender")});var vz={};C(vz,{setRender:()=>Xx});function Xx(e,t,r={}){return e.set([t,"render"],Pp(r))}var Qx=f(()=>{Yx();i(Xx,"setRender")});function wz(e,t,r){return e.update([t,"render"],(n={})=>Pp({...n,...r}))}var bz=f(()=>{Yx();i(wz,"updateRender")});var Sz={};C(Sz,{clearRender:()=>e_});function e_(e,t){return e.remove([t,"render"])}var t_=f(()=>{i(e_,"clearRender")});import{defineContracts as aB}from"@jucie.io/engine-message";var cB,kz=f(()=>{Qx();bz();t_();cB=aB("node:render",e=>{let t=e("state")?.ref(["nodes"])??null;if(!t)throw new Error("Node cache not found");return{set:{schema:["String","Object"],handler:(r,n)=>{Xx(t,r,n)},namespace:"scene-graph"},update:{schema:["String","Object"],handler:(r,n)=>{wz(t,r,n)},namespace:"scene-graph"},clear:{schema:["String"],handler:r=>{e_(t,r)},namespace:"scene-graph"}}})});function Op({descriptor:e,keyOn:t=null,key:r="$key",as:n="$item",index:o="$index"}={}){return{descriptor:Ne(e),keyOn:t,key:r,as:n,index:o}}var r_=f(()=>{Kt();i(Op,"createRepeat")});var $z={};C($z,{setRepeat:()=>Dc});function Dc(e,t,r={}){return e.set([t,"repeat"],Op(r))}var Ap=f(()=>{r_();i(Dc,"setRepeat")});function Ez(e,t,r){return e.update([t,"repeat"],(n={})=>Op({...n,...r}))}var Nz=f(()=>{r_();i(Ez,"updateRepeat")});var Tz={};C(Tz,{clearRepeat:()=>Mc});function Mc(e,t){return e.remove([t,"repeat"])}var Rp=f(()=>{i(Mc,"clearRepeat")});function zz(e,t){return e.get([t,"repeat"])?e:Dc(e,t,{})}var Cz=f(()=>{Ap();i(zz,"enableRepeat")});function Iz(e,t){return Mc(e,t)}var Pz=f(()=>{Rp();i(Iz,"disableRepeat")});import{defineContracts as lB}from"@jucie.io/engine-message";var uB,Oz=f(()=>{Ap();Nz();Rp();Cz();Pz();uB=lB("node:repeat",e=>{let t=e("state")?.ref(["nodes"])??null;if(!t)throw new Error("Node cache not found");return{set:{schema:["String","Object"],handler:(r,n)=>{Dc(t,r,n)},namespace:"scene-graph"},update:{schema:["String","Object"],handler:(r,n)=>{Ez(t,r,n)},namespace:"scene-graph"},clear:{schema:["String"],handler:r=>{Mc(t,r)},namespace:"scene-graph"},enable:{schema:["String"],handler:r=>{zz(t,r)},namespace:"scene-graph"},disable:{schema:["String"],handler:r=>{Iz(t,r)},namespace:"scene-graph"}}})});function Az({path:e=null,params:t=[]}={}){return{path:e,params:t}}var Rz=f(()=>{i(Az,"createRoute")});var jz={};C(jz,{updateRoute:()=>n_});function n_(e,t,r){return e.update([t,"route"],(n={})=>Az({...n,...r}))}var o_=f(()=>{Rz();i(n_,"updateRoute")});function Dz({key:e=null,optional:t=!1}={}){return{key:e,optional:t}}var Mz=f(()=>{i(Dz,"createParam")});var Zz={};C(Zz,{addParamToRoute:()=>s_});function s_(e,t){return e.push([t,"route","params"],Dz())}var i_=f(()=>{Mz();i(s_,"addParamToRoute")});var Lz={};C(Lz,{removeParamFromRoute:()=>a_});function a_(e,t,r){return e.splice([t,"route","params"],r,1)}var c_=f(()=>{i(a_,"removeParamFromRoute")});var Fz={};C(Fz,{setHomePage:()=>l_});function l_(e,t,r){e.findAllWhen("home","is",!0).forEach(n=>{e.set(n,!1);let o=[...n.slice(0,-1),"path"];e.set(o,t)}),r&&(e.set([t,"route","home"],!0),e.set([t,"route","path"],"/"))}var u_=f(()=>{i(l_,"setHomePage")});import{defineContracts as dB}from"@jucie.io/engine-message";var pB,Uz=f(()=>{o_();i_();c_();u_();pB=dB("node:route",e=>{let t=e("state")?.ref(["nodes"])??null;if(!t)throw new Error("Node cache not found");return{update:{schema:["String","Object"],namespace:"scene-graph",handler:(r,n)=>{n_(t,r,n)}},addParam:{schema:["String"],namespace:"scene-graph",handler:r=>{s_(t,r)}},removeParam:{namespace:"scene-graph",schema:["String","Number"],handler:(r,n)=>{a_(t,r,n)}},setHomePage:{schema:["String","Boolean"],namespace:"scene-graph",handler:(r,n)=>{l_(t,r,n)}}}})});function qz(e,t,{breakpoint:r="default",interactionState:n=[]}={}){let o=ki(r);return e.remove([t,"style",o,...n])}var Bz=f(()=>{ep();i(qz,"clearStyle")});function jp(e,t){let r=e.get([t]),n=r?.type;return n==="frame"||n==="component"||n==="viewport"||!!r?.bounds}var Hz=f(()=>{i(jp,"isContainerNode")});import{defineContracts as fB}from"@jucie.io/engine-message";var mB,Vz=f(()=>{Lo();nx();Bz();Oi();Hz();mB=fB("node:style",e=>{let[t,r]=e("state","sceneCompiler"),n=t?.ref(["nodes"])??null;return{update:{schema:["Object"],handler:o=>{for(let[s,a]of Object.entries(o)){if(!Qt(n,s))continue;delete a.position;let c=jp(n,s)?"default":r.getActiveBreakpoint(s);un(n,s,a,{breakpoint:c})}},namespace:"scene-graph"},remove:{schema:["Array","Array"],handler:(o,s)=>{for(let a of o){if(!Qt(n,a))continue;let c=jp(n,a)?"default":r.getActiveBreakpoint(a);for(let l of s)gp(n,a,l,{breakpoint:c})}},namespace:"scene-graph"},clear:{schema:["Array"],handler:o=>{for(let s of o){if(!Qt(n,s))continue;let a=jp(n,s)?"default":r.getActiveBreakpoint(s);a==="default"||a==null||qz(n,s,{breakpoint:a})}},namespace:"scene-graph"}}})});var Gz={};C(Gz,{setTagName:()=>d_});function d_(e,t,r){return e.set([t,"tagName"],r)}var p_=f(()=>{i(d_,"setTagName")});function Wz(e,t,r){return e.set([t,"tagName"],r)}var Jz=f(()=>{i(Wz,"updateTagName")});function Kz(e,t){return e.remove([t,"tagName"])}var Yz=f(()=>{i(Kz,"clearTagName")});import{defineContracts as hB}from"@jucie.io/engine-message";var gB,Xz=f(()=>{p_();Jz();Yz();gB=hB("node:tagName",e=>{let t=e("state")?.ref(["nodes"])??null;if(!t)throw new Error("Node cache not found");return{set:{schema:["String","String"],handler:(r,n)=>{d_(t,r,n)},namespace:"scene-graph"},update:{schema:["String","String"],handler:(r,n)=>{Wz(t,r,n)},namespace:"scene-graph"},clear:{schema:["String"],handler:r=>{Kz(t,r)},namespace:"scene-graph"}}})});function Qz(e,t,r){if(Xt(e,t))return;let n="",o;return typeof r=="string"?n=r:r!=null&&typeof r=="object"&&(n=r.value??"",Object.prototype.hasOwnProperty.call(r,"specificPatterns")&&(o=r.specificPatterns)),e.set([t,"textContent"],ye({value:n,specificPatterns:o}))}var eC=f(()=>{fn();Uo();i(Qz,"setTextContent")});function tC(e,t,r={}){if(Xt(e,t))return;let n=typeof r=="string"?{value:r}:r;return e.update([t,"textContent"],(o={})=>{let s={...o,...n};return!Object.prototype.hasOwnProperty.call(n,"specificPatterns")&&o.specificPatterns!==void 0&&(s.specificPatterns=o.specificPatterns),ye(s)})}var rC=f(()=>{fn();Uo();i(tC,"updateTextContent")});function nC(e,t){return e.remove([t,"textContent"])}var oC=f(()=>{i(nC,"clearTextContent")});function Zc(e,t,r=!0){return e.set([t,".editingTextContent"],r)}var sC=f(()=>{i(Zc,"setEditingTextContent")});function iC(e,t){return e.remove([t,".editingTextContent"])}var aC=f(()=>{i(iC,"removeEditingTextContent")});import{defineContracts as yB}from"@jucie.io/engine-message";var xB,cC=f(()=>{eC();rC();oC();sC();aC();xB=yB("node:textContent",e=>{let t=e("state")?.ref(["nodes"])??null;if(!t)throw new Error("Node cache not found");let r=null;return{set:{schema:["String","Object"],handler:(n,o)=>{Qz(t,n,o)},namespace:"scene-graph"},update:{schema:["String","Object"],handler:(n,o)=>{tC(t,n,o)},namespace:"scene-graph"},clear:{schema:["String"],handler:n=>{nC(t,n)},namespace:"scene-graph"},"editing:enable":{schema:["String"],namespace:"scene-graph",handler:n=>(r&&(Zc(t,r,!1),r=null),r=n,Zc(t,n,!0),!0)},"editing:disable":{schema:"*",namespace:"scene-graph",handler:n=>(n?Zc(t,n,!1):r&&(Zc(t,r,!1),r=null),r=null,!0)},"editing:remove":{schema:["String"],namespace:"scene-graph",handler:n=>(iC(t,n),!0)}}})});function lC(e,t,r){if(Array.isArray(r))return e.set([t,"textSegments"],r)}var uC=f(()=>{i(lC,"setTextSegments")});function dC(e,t,r){if(Array.isArray(r))return e.set([t,"textSegments"],r)}var pC=f(()=>{i(dC,"updateTextSegments")});function fC(e,t){return e.remove([t,"textSegments"])}var mC=f(()=>{i(fC,"clearTextSegments")});import{defineContracts as _B}from"@jucie.io/engine-message";var vB,hC=f(()=>{uC();pC();mC();vB=_B("node:textSegments",e=>{let t=e("state")?.ref(["nodes"])??null;if(!t)throw new Error("Node cache not found");return{set:{schema:["String","Array"],handler:(r,n)=>{lC(t,r,n)},namespace:"scene-graph"},update:{schema:["String","Array"],handler:(r,n)=>{dC(t,r,n)},namespace:"scene-graph"},clear:{schema:["String"],handler:r=>{fC(t,r)},namespace:"scene-graph"}}})});function gC(e,t,r){return e.set([t,"type"],r)}var yC=f(()=>{i(gC,"setType")});function xC(e,t,r){return e.set([t,"type"],r)}var _C=f(()=>{i(xC,"updateType")});function vC(e,t){return e.remove([t,"type"])}var wC=f(()=>{i(vC,"clearType")});import{defineContracts as wB}from"@jucie.io/engine-message";var bB,bC=f(()=>{yC();_C();wC();bB=wB("node:type",e=>{let t=e("state")?.ref(["nodes"])??null;if(!t)throw new Error("Node cache not found");return{set:{schema:["String","String"],handler:(r,n)=>{gC(t,r,n)},namespace:"scene-graph"},update:{schema:["String","String"],handler:(r,n)=>{xC(t,r,n)},namespace:"scene-graph"},clear:{schema:["String"],handler:r=>{vC(t,r)},namespace:"scene-graph"}}})});function Lc(e,t,r,n={}){let{name:o,bounds:s}=Cc(r,n),a=e.get([t,"bounds"])??{};e.set([t,"frame"],r),e.set([t,"name"],o),e.update([t,"bounds"],()=>({...a,width:s.width,height:s.height}))}var f_=f(()=>{Go();i(Lc,"setFramePreset")});function SC(e,t,{name:r,width:n,height:o}){if(r==="custom"){Lc(e,t,"custom",{name:r,width:n,height:o});return}if(!Vo(r))return new Error(`Invalid viewport name "${r}"`);Lc(e,t,r)}var kC=f(()=>{Go();f_();i(SC,"setViewport")});function $C(e,t){return e.set([t,"frame"],void 0),e.remove([t,"viewport"])}var EC=f(()=>{i($C,"clearViewport")});import{defineContracts as SB}from"@jucie.io/engine-message";var kB,NC=f(()=>{kC();f_();Nc();EC();kB=SB("node:viewport",e=>{let t=e("state")?.ref(["nodes"])??null;if(!t)throw new Error("Node cache not found");return{set:{schema:["String","Object"],handler:(r,n)=>{SC(t,r,n)},namespace:"scene-graph"},setPreset:{schema:["String","String","Object"],handler:(r,n,o={})=>{Lc(t,r,n,o)},namespace:"scene-graph"},update:{schema:["String","Object"],handler:(r,n)=>{Ec(t,r,n)},namespace:"scene-graph"},clear:{schema:["String"],handler:r=>{$C(t,r)},namespace:"scene-graph"}}})});var TC={};C(TC,{setHtmlId:()=>m_});function m_(e,t,r){return e.set([t,"id"],r)}var h_=f(()=>{i(m_,"setHtmlId")});function zC(e,t){return e.remove([t,"id"])}var CC=f(()=>{i(zC,"clearHtmlId")});import{defineContracts as $B}from"@jucie.io/engine-message";var EB,IC=f(()=>{h_();CC();EB=$B("node:id",e=>{let t=e("state")?.ref(["nodes"])??null;if(!t)throw new Error("Node cache not found");return{set:{namespace:"scene-graph",schema:["String","String"],handler:(r,n)=>{m_(t,r,n)}},clear:{namespace:"scene-graph",schema:["String"],handler:r=>{zC(t,r)}}}})});var PC=f(()=>{});var g_=f(()=>{});var OC=f(()=>{g_()});var AC=f(()=>{});var RC=f(()=>{});var jC=f(()=>{});var DC=f(()=>{});var MC=f(()=>{});var A=f(()=>{PC();OC();g_();AC();RC();jC();DC();MC()});var ji=f(()=>{});var er=f(()=>{ji();A()});var Fc=f(()=>{er();A()});var ZC=f(()=>{Fc();A()});var LC=f(()=>{Fc();A()});var FC=f(()=>{Fc();A()});var UC=f(()=>{Fc();A()});var qC=f(()=>{ZC();LC();FC();UC()});var Wo=f(()=>{er();A()});var BC=f(()=>{Wo();A()});var HC=f(()=>{Wo();A()});var VC=f(()=>{Wo();A()});var GC=f(()=>{Wo();A()});var WC=f(()=>{Wo();A()});var JC=f(()=>{Wo();A()});var KC=f(()=>{BC();HC();VC();GC();WC();JC()});var et=f(()=>{er();A()});var YC=f(()=>{et();A()});var XC=f(()=>{et();A()});var QC=f(()=>{et();A()});var eI=f(()=>{et();A()});var tI=f(()=>{et();A()});var rI=f(()=>{et();A()});var nI=f(()=>{et();A()});var oI=f(()=>{et();A()});var sI=f(()=>{et();A()});var iI=f(()=>{et();A()});var aI=f(()=>{et();A()});var cI=f(()=>{et();A()});var lI=f(()=>{et();A()});var uI=f(()=>{et();A()});var dI=f(()=>{et();A()});var pI=f(()=>{et();A()});var fI=f(()=>{YC();XC();QC();eI();tI();rI();nI();oI();sI();iI();aI();cI();lI();uI();dI();pI()});var Di=f(()=>{er();A()});var mI=f(()=>{Di();A()});var hI=f(()=>{Di();A()});var gI=f(()=>{Di();A()});var yI=f(()=>{Di();A()});var xI=f(()=>{Di();A()});var _I=f(()=>{mI();hI();gI();yI();xI()});var _r=f(()=>{er();A()});var vI=f(()=>{_r();A()});var wI=f(()=>{_r();A()});var bI=f(()=>{_r();A()});var SI=f(()=>{_r();A()});var kI=f(()=>{_r();A()});var $I=f(()=>{_r();A()});var EI=f(()=>{_r();A()});var NI=f(()=>{_r();A()});var TI=f(()=>{_r();A()});var zI=f(()=>{_r();A()});var CI=f(()=>{vI();wI();bI();SI();kI();$I();EI();NI();TI();zI()});var Jo=f(()=>{er();A()});var II=f(()=>{Jo();A()});var PI=f(()=>{Jo();A()});var OI=f(()=>{Jo();A()});var AI=f(()=>{Jo();A()});var RI=f(()=>{Jo();A()});var jI=f(()=>{Jo();A()});var DI=f(()=>{II();PI();OI();AI();RI();jI()});var Mi=f(()=>{er();A()});var MI=f(()=>{Mi();A()});var ZI=f(()=>{Mi();A()});var LI=f(()=>{Mi();A()});var FI=f(()=>{Mi();A()});var UI=f(()=>{Mi();A()});var tr=f(()=>{er();A()});var qI=f(()=>{tr();A()});var BI=f(()=>{MI();ZI();LI();FI();UI();qI()});var Kn=f(()=>{er();A()});var HI=f(()=>{Kn();A()});var VI=f(()=>{Kn();A()});var GI=f(()=>{Kn();A()});var WI=f(()=>{Kn();A()});var JI=f(()=>{Kn();A()});var KI=f(()=>{Kn();A()});var YI=f(()=>{Kn();A()});var XI=f(()=>{HI();VI();GI();WI();JI();KI();YI()});var QI=f(()=>{tr();A()});var eP=f(()=>{tr();A()});var tP=f(()=>{tr();A()});var rP=f(()=>{tr();A()});var nP=f(()=>{tr();A()});var oP=f(()=>{tr();A()});var sP=f(()=>{tr();A()});var iP=f(()=>{tr();A()});var aP=f(()=>{tr();A()});var cP=f(()=>{tr();A()});var lP=f(()=>{er();A()});var uP=f(()=>{er();A()});var dP=f(()=>{QI();eP();tP();rP();nP();oP();sP();iP();aP();cP();lP();uP()});var pP=f(()=>{A();qC();KC();fI();_I();CI();DI();BI();XI();dP()});var fP=f(()=>{Go()});var mP=f(()=>{ji();A()});var hP=f(()=>{A();mP()});var Lp=f(()=>{A();ji()});var yP=f(()=>{A();Lp()});var xP=f(()=>{A();Lp()});var _P=f(()=>{A()});var vP=f(()=>{A();Lp()});var wP=f(()=>{A();yP();xP();_P();vP()});var bP=f(()=>{});var SP=f(()=>{ji();A();bP()});var kP=f(()=>{SP();A()});var $P=f(()=>{A();kP()});var EP=f(()=>{});var NP=f(()=>{EP()});var TP=f(()=>{ji();A()});var zP=f(()=>{pP();fP();hP();wP();$P();NP();TP()});var CP,IP=f(()=>{CP=[{type:"element",displayName:"Fieldset",category:"form",swapGroup:null,keywords:["form"],tagName:"fieldset"},{type:"element",displayName:"Legend",category:"form",swapGroup:null,keywords:["form"],tagName:"legend"},{type:"element",displayName:"Progress",category:"form",swapGroup:null,keywords:["form"],tagName:"progress"},{type:"element",displayName:"Meter",category:"form",swapGroup:null,keywords:["form"],tagName:"meter"}]});var PP,OP=f(()=>{PP=[{type:"element",displayName:"Heading 1",keywords:["headings"],category:"headings",swapGroup:"headings",tagName:"h1"},{type:"element",displayName:"Heading 2",keywords:["headings"],category:"headings",swapGroup:"headings",tagName:"h2"},{type:"element",displayName:"Heading 3",keywords:["headings"],category:"headings",swapGroup:"headings",tagName:"h3"},{type:"element",displayName:"Heading 4",keywords:["headings"],category:"headings",swapGroup:"headings",tagName:"h4"},{type:"element",displayName:"Heading 5",keywords:["headings"],category:"headings",swapGroup:"headings",tagName:"h5"},{type:"element",displayName:"Heading 6",keywords:["headings"],category:"headings",swapGroup:"headings",tagName:"h6"}]});var AP,RP=f(()=>{AP=[{type:"element",displayName:"Radio",category:"inputs",swapGroup:null,keywords:["inputs"],tagName:"radio"},{type:"element",displayName:"Text",category:"inputs",swapGroup:null,keywords:["inputs"],tagName:"text"},{type:"element",displayName:"Checkbox",category:"inputs",swapGroup:null,keywords:["inputs"],tagName:"checkbox"},{type:"element",displayName:"Phone",category:"inputs",swapGroup:null,keywords:["inputs"],tagName:"phone"},{type:"element",displayName:"Email",category:"inputs",swapGroup:null,keywords:["inputs"],tagName:"email"},{type:"element",displayName:"Password",category:"inputs",swapGroup:null,keywords:["inputs"],tagName:"password"},{type:"element",displayName:"Select",category:"inputs",swapGroup:null,keywords:["inputs"],tagName:"select"},{type:"element",displayName:"Textarea",category:"inputs",swapGroup:null,keywords:["inputs"],tagName:"textarea"},{type:"element",displayName:"Number",category:"inputs",swapGroup:null,keywords:["inputs"],tagName:"number"},{type:"element",displayName:"Date",category:"inputs",swapGroup:null,keywords:["inputs"],tagName:"date"},{type:"element",displayName:"Range",category:"inputs",swapGroup:null,keywords:["inputs"],tagName:"range"},{type:"element",displayName:"File Upload",category:"inputs",swapGroup:null,keywords:["inputs"],tagName:"file"},{type:"element",displayName:"Search",category:"inputs",swapGroup:null,keywords:["inputs"],tagName:"search"},{type:"element",displayName:"Color Picker",category:"inputs",swapGroup:null,keywords:["inputs"],tagName:"color"},{type:"element",displayName:"Hidden",category:"inputs",swapGroup:null,keywords:["inputs"],tagName:"hidden"}]});var jP,DP=f(()=>{jP=[{type:"element",displayName:"Button",category:"interactive",swapGroup:"interactive",keywords:["interactive"],tagName:"button"},{type:"element",displayName:"Link",category:"interactive",swapGroup:"interactive",keywords:["interactive"],tagName:"a"},{type:"element",displayName:"Details",category:"interactive",swapGroup:null,keywords:["interactive"],tagName:"details"},{type:"element",displayName:"Summary",category:"interactive",swapGroup:null,keywords:["interactive"],tagName:"summary"},{type:"element",displayName:"Dialog",category:"interactive",swapGroup:null,keywords:["interactive"],tagName:"dialog"}]});var MP,ZP=f(()=>{MP=[{type:"element",displayName:"Aside",category:"layout",swapGroup:"layout",keywords:["layout"],tagName:"aside"},{type:"element",displayName:"Footer",category:"layout",swapGroup:"layout",keywords:["layout"],tagName:"footer"},{type:"element",displayName:"Form",category:"layout",swapGroup:"layout",keywords:["layout"],tagName:"form"},{type:"element",displayName:"Header",category:"layout",swapGroup:"layout",keywords:["layout"],tagName:"header"},{type:"element",displayName:"Main",category:"layout",swapGroup:"layout",keywords:["layout"],tagName:"main"},{type:"element",displayName:"Section",category:"layout",swapGroup:"layout",keywords:["layout"],tagName:"section"},{type:"element",displayName:"Article",category:"layout",swapGroup:"layout",keywords:["layout"],tagName:"article"},{type:"element",displayName:"Nav",category:"layout",swapGroup:"layout",keywords:["layout"],tagName:"nav"},{type:"element",displayName:"Div",category:"layout",swapGroup:"layout",keywords:["layout"],tagName:"div"},{type:"element",displayName:"Template",category:"layout",swapGroup:"layout",keywords:["layout"],tagName:"template"}]});var LP,FP=f(()=>{LP=[{type:"element",displayName:"Ordered List",category:"lists",swapGroup:"list-container",keywords:["lists"],tagName:"ol"},{type:"element",displayName:"Unordered List",category:"lists",swapGroup:"list-container",keywords:["lists"],tagName:"ul"},{type:"element",displayName:"List Item",category:"lists",swapGroup:null,keywords:["lists"],tagName:"li"},{type:"element",displayName:"Definition List",category:"lists",swapGroup:"list-container",keywords:["lists"],tagName:"dl"},{type:"element",displayName:"Definition Term",category:"lists",swapGroup:null,keywords:["lists"],tagName:"dt"},{type:"element",displayName:"Definition Description",category:"lists",swapGroup:null,keywords:["lists"],tagName:"dd"}]});var UP,qP=f(()=>{UP=[{type:"element",displayName:"Image",category:"media",swapGroup:null,keywords:["media"],tagName:"img"},{type:"element",displayName:"Video",category:"media",swapGroup:null,keywords:["media"],tagName:"video"},{type:"element",displayName:"Audio",category:"media",swapGroup:null,keywords:["media"],tagName:"audio"},{type:"element",displayName:"Iframe",category:"media",swapGroup:null,keywords:["media"],tagName:"iframe"},{type:"element",displayName:"Figure",category:"media",swapGroup:null,keywords:["media"],tagName:"figure"},{type:"element",displayName:"Figcaption",category:"media",swapGroup:null,keywords:["media"],tagName:"figcaption"}]});var BP,HP=f(()=>{BP=[{type:"element",displayName:"Table",category:"tables",swapGroup:null,keywords:["tables"],tagName:"table"},{type:"element",displayName:"Table Head",category:"tables",swapGroup:null,keywords:["tables"],tagName:"thead"},{type:"element",displayName:"Table Body",category:"tables",swapGroup:null,keywords:["tables"],tagName:"tbody"},{type:"element",displayName:"Table Foot",category:"tables",swapGroup:null,keywords:["tables"],tagName:"tfoot"},{type:"element",displayName:"Table Row",category:"tables",swapGroup:null,keywords:["tables"],tagName:"tr"},{type:"element",displayName:"Table Header Cell",category:"tables",swapGroup:null,keywords:["tables"],tagName:"th"},{type:"element",displayName:"Table Cell",category:"tables",swapGroup:null,keywords:["tables"],tagName:"td"}]});var VP,GP=f(()=>{VP=[{type:"element",displayName:"Paragraph",category:"text",swapGroup:"text",keywords:["text"],tagName:"p"},{type:"element",displayName:"Label",category:"text",swapGroup:"text",keywords:["text"],tagName:"label"},{type:"element",displayName:"Span",category:"text",swapGroup:"text",keywords:["text"],tagName:"span"},{type:"element",displayName:"Blockquote",category:"text",swapGroup:null,keywords:["text"],tagName:"blockquote"},{type:"element",displayName:"Preformatted",category:"text",swapGroup:null,keywords:["text"],tagName:"pre"},{type:"element",displayName:"Code",category:"text",swapGroup:"text",keywords:["text"],tagName:"code"},{type:"element",displayName:"Strong",category:"text",swapGroup:"text",keywords:["text"],tagName:"strong"},{type:"element",displayName:"Emphasis",category:"text",swapGroup:"text",keywords:["text"],tagName:"em"},{type:"element",displayName:"Small",category:"text",swapGroup:"text",keywords:["text"],tagName:"small"},{type:"element",displayName:"Mark",category:"text",swapGroup:null,keywords:["text"],tagName:"mark"},{type:"element",displayName:"Horizontal Rule",category:"text",swapGroup:null,keywords:["text","divider"],tagName:"hr"},{type:"element",displayName:"Line Break",category:"text",swapGroup:null,keywords:["text"],tagName:"br"}]});var WP,JP=f(()=>{WP=[{type:"slot",displayName:"Slot",category:"special",keywords:["slot","placeholder","component","template"],tagName:"slot"}]});var DB,KP=f(()=>{IP();OP();RP();DP();ZP();FP();qP();HP();GP();JP();DB=[...MP,...PP,...AP,...jP,...LP,...UP,...VP,...CP,...BP,...WP]});var YP=f(()=>{});var XP=f(()=>{zP();zc();Cp();kp();xx();Go();KP();YP()});var QP=f(()=>{EN();ON();t1();c1();p1();lT();pT();mT();wT();NT();zT();AT();DT();LT();GT();WT();JT();KT();nz();az();fz();mz();_z();kz();Oz();Uz();Vz();Xz();cC();hC();bC();NC();IC();XP()});function Fp(){return`function () {
7
7
  // Store state, computed, and actions are available on this
8
- }`}var vy=f(()=>{i(ld,"createCode")});var aC={};R(aC,{createAction:()=>Ja});function Ja({name:e,code:t=ld()}){return{name:e,code:t}}var ud=f(()=>{vy();i(Ja,"createAction")});var cC={};R(cC,{addAction:()=>wy});function wy(e,t){return e.update([t,"actions"],(r=[])=>{let n=`action${r.length+1}`;return r.some(o=>o.name===n)||r.unshift(Ja({name:n})),r})}var by=f(()=>{ud();i(wy,"addAction")});var ky={};R(ky,{updateAction:()=>Sy});function Sy(e,t,r,n){return e.update([t,"actions"],(o=[])=>(o[r]&&(o[r]=Ja(n)),o))}var dd=f(()=>{ud();i(Sy,"updateAction")});var lC={};R(lC,{removeAction:()=>$y});function $y(e,t,r){return e.update([t,"actions"],(n=[])=>(n[r]&&n.splice(r,1),n))}var Ey=f(()=>{i($y,"removeAction")});import{defineContracts as wU}from"@jucie.io/engine-message";var bU,uC=f(()=>{by();dd();Ey();bU=wU("store:action",e=>{let t=e("state")?.ref(["stores"])??null;if(!t)throw new Error("Stores not found");return{add:{namespace:"scene-graph",schema:["String"],handler:r=>wy(t,r)},update:{namespace:"scene-graph",schema:["String","Number","Object"],handler:(r,n,o)=>Sy(t,r,n,o)},remove:{namespace:"scene-graph",schema:["String","Number"],handler:(r,n)=>$y(t,r,n)}}})});var dC={};R(dC,{createComputed:()=>Ya});function Ya({name:e,code:t=ld()}){return{name:e,code:t}}var pd=f(()=>{vy();i(Ya,"createComputed")});var pC={};R(pC,{addComputed:()=>Ny});function Ny(e,t){return e.update([t,"computed"],(r=[])=>{let n=`computed${r.length+1}`;return r.some(o=>o.name===n)||r.unshift(Ya({name:n})),r})}var Ty=f(()=>{pd();i(Ny,"addComputed")});var Cy={};R(Cy,{updateComputed:()=>zy});function zy(e,t,r,n){return e.update([t,"computed"],(o=[])=>(o[r]&&(o[r]=Ya(n)),o))}var fd=f(()=>{pd();i(zy,"updateComputed")});var fC={};R(fC,{removeComputed:()=>Iy});function Iy(e,t,r){return e.update([t,"computed"],(n=[])=>(n[r]&&n.splice(r,1),n))}var Py=f(()=>{i(Iy,"removeComputed")});import{defineContracts as SU}from"@jucie.io/engine-message";var kU,mC=f(()=>{Ty();fd();Py();kU=SU("store:computed",e=>{let t=e("state")?.ref(["stores"])??null;if(!t)throw new Error("Stores not found");return{add:{schema:["String"],namespace:"scene-graph",handler:r=>{Ny(t,r)}},update:{schema:["String","Number","Object"],namespace:"scene-graph",handler:(r,n,o)=>{zy(t,r,n,o)}},remove:{schema:["String","Number"],namespace:"scene-graph",handler:(r,n)=>{Iy(t,r,n)}}}})});var hC={};R(hC,{createValue:()=>Xa});function Xa({key:e,type:t,value:r=""}){return{key:e,type:t,value:r}}var md=f(()=>{i(Xa,"createValue")});var gC={};R(gC,{addValue:()=>Ry});function Ry(e,t,r){return e.update([t,"state"],(n=[])=>{let o=`state${n.length+1}`;return n.some(s=>s.key===o)||n.unshift(Xa({key:o,type:r||"string",value:""})),n})}var Oy=f(()=>{md();i(Ry,"addValue")});var jy={};R(jy,{updateValue:()=>Ay});function Ay(e,t,r,n){return e.update([t,"state"],(o=[])=>(o[r]&&(o[r]=Xa(n)),o))}var hd=f(()=>{md();i(Ay,"updateValue")});var yC={};R(yC,{removeValue:()=>Dy});function Dy(e,t,r){return e.update([t,"state"],(n=[])=>(n[r]&&n.splice(r,1),n))}var My=f(()=>{i(Dy,"removeValue")});import{defineContracts as $U}from"@jucie.io/engine-message";var EU,xC=f(()=>{Oy();hd();My();EU=$U("store:state",e=>{let t=e("state")?.ref(["stores"])??null;if(!t)throw new Error("Stores not found");return{add:{schema:["String","String"],namespace:"scene-graph",handler:(r,n)=>{Ry(t,r,n)}},update:{schema:["String","Number","Object"],namespace:"scene-graph",handler:(r,n,o)=>{Ay(t,r,n,o)}},remove:{schema:["String","Number"],namespace:"scene-graph",handler:(r,n)=>{Dy(t,r,n)}}}})});function _C({name:e,code:t="",state:r=[],computed:n=[],actions:o=[]}){return{name:e,code:t,state:r,computed:n,actions:o}}var vC=f(()=>{i(_C,"createStore")});var wC={};R(wC,{addStore:()=>Zy});function Zy(e,t){let r=_C({name:t});return e.set([t],r),t}var Ly=f(()=>{vC();i(Zy,"addStore")});var bC={};R(bC,{removeStore:()=>Fy});function Fy(e,t){return e.remove([t])}var Uy=f(()=>{i(Fy,"removeStore")});import{defineContracts as NU}from"@jucie.io/engine-message";var TU,SC=f(()=>{Ly();Uy();TU=NU("store",e=>{let t=e("state")?.ref(["stores"])??null;if(!t)throw new Error("Stores not found");return{get:{namespace:"scene-graph",handler:r=>r?t.get([r]):t.get()??{}},add:{schema:["String"],namespace:"scene-graph",handler:r=>Zy(t,r)},remove:{schema:["String"],namespace:"scene-graph",handler:r=>{Fy(t,r)}}}})});var kC=f(()=>{uC();mC();xC();SC()});var $C=f(()=>{});var EC=f(()=>{});var _o,gd,NC=f(()=>{_o={type:"root",children:[],meta:{childrenType:"children"}},gd="3ec180328381108048f8882a9a6c41c1baf0763af128710bee612ce0f6d3315a"});var TC,zC=f(()=>{TC=[{type:"aside",displayName:"Aside",category:"layout",swapGroup:"layout",keywords:["layout"],tagName:"aside"},{type:"footer",displayName:"Footer",category:"layout",swapGroup:"layout",keywords:["layout"],tagName:"footer"},{type:"form",displayName:"Form",category:"layout",swapGroup:"layout",keywords:["layout"],tagName:"form"},{type:"header",displayName:"Header",category:"layout",swapGroup:"layout",keywords:["layout"],tagName:"header"},{type:"main",displayName:"Main",category:"layout",swapGroup:"layout",keywords:["layout"],tagName:"main"},{type:"section",displayName:"Section",category:"layout",swapGroup:"layout",keywords:["layout"],tagName:"section"},{type:"article",displayName:"Article",category:"layout",swapGroup:"layout",keywords:["layout"],tagName:"article"},{type:"nav",displayName:"Nav",category:"layout",swapGroup:"layout",keywords:["layout"],tagName:"nav"},{type:"div",displayName:"Div",category:"layout",swapGroup:"layout",keywords:["layout"],tagName:"div"},{type:"template",displayName:"Template",category:"layout",swapGroup:"layout",keywords:["layout"],tagName:"template"}]});var CC,IC=f(()=>{CC=[{type:"h1",displayName:"Heading 1",keywords:["headings"],category:"headings",swapGroup:"headings",tagName:"h1"},{type:"h2",displayName:"Heading 2",keywords:["headings"],category:"headings",swapGroup:"headings",tagName:"h2"},{type:"h3",displayName:"Heading 3",keywords:["headings"],category:"headings",swapGroup:"headings",tagName:"h3"},{type:"h4",displayName:"Heading 4",keywords:["headings"],category:"headings",swapGroup:"headings",tagName:"h4"},{type:"h5",displayName:"Heading 5",keywords:["headings"],category:"headings",swapGroup:"headings",tagName:"h5"},{type:"h6",displayName:"Heading 6",keywords:["headings"],category:"headings",swapGroup:"headings",tagName:"h6"},{type:"p",displayName:"Paragraph",category:"text",swapGroup:"text",keywords:["text"],tagName:"p"},{type:"label",displayName:"Label",category:"text",swapGroup:"text",keywords:["text"],tagName:"label"},{type:"span",displayName:"Span",category:"text",swapGroup:"text",keywords:["text"],tagName:"span"},{type:"blockquote",displayName:"Blockquote",category:"text",swapGroup:null,keywords:["text"],tagName:"blockquote"},{type:"pre",displayName:"Preformatted",category:"text",swapGroup:null,keywords:["text"],tagName:"pre"},{type:"codeElement",displayName:"Code",category:"text",swapGroup:"text",keywords:["text"],tagName:"code"},{type:"strong",displayName:"Strong",category:"text",swapGroup:"text",keywords:["text"],tagName:"strong"},{type:"em",displayName:"Emphasis",category:"text",swapGroup:"text",keywords:["text"],tagName:"em"},{type:"small",displayName:"Small",category:"text",swapGroup:"text",keywords:["text"],tagName:"small"},{type:"mark",displayName:"Mark",category:"text",swapGroup:null,keywords:["text"],tagName:"mark"},{type:"hr",displayName:"Horizontal Rule",category:"text",swapGroup:null,keywords:["text","divider"],tagName:"hr"},{type:"br",displayName:"Line Break",category:"text",swapGroup:null,keywords:["text"],tagName:"br"}]});var PC,RC=f(()=>{PC=[{type:"button",displayName:"Button",category:"interactive",swapGroup:"interactive",keywords:["interactive"],tagName:"button"},{type:"a",displayName:"Link",category:"interactive",swapGroup:"interactive",keywords:["interactive"],tagName:"a"},{type:"details",displayName:"Details",category:"interactive",swapGroup:null,keywords:["interactive"],tagName:"details"},{type:"summary",displayName:"Summary",category:"interactive",swapGroup:null,keywords:["interactive"],tagName:"summary"},{type:"dialog",displayName:"Dialog",category:"interactive",swapGroup:null,keywords:["interactive"],tagName:"dialog"}]});var OC,AC=f(()=>{OC=[{type:"radio",displayName:"Radio",category:"inputs",swapGroup:null,keywords:["inputs"],tagName:"input"},{type:"textInput",displayName:"Text",category:"inputs",swapGroup:null,keywords:["inputs"],tagName:"input"},{type:"checkbox",displayName:"Checkbox",category:"inputs",swapGroup:null,keywords:["inputs"],tagName:"input"},{type:"phone",displayName:"Phone",category:"inputs",swapGroup:null,keywords:["inputs"],tagName:"input"},{type:"email",displayName:"Email",category:"inputs",swapGroup:null,keywords:["inputs"],tagName:"input"},{type:"password",displayName:"Password",category:"inputs",swapGroup:null,keywords:["inputs"],tagName:"input"},{type:"select",displayName:"Select",category:"inputs",swapGroup:null,keywords:["inputs"],tagName:"select"},{type:"textarea",displayName:"Textarea",category:"inputs",swapGroup:null,keywords:["inputs"],tagName:"textarea"},{type:"number",displayName:"Number",category:"inputs",swapGroup:null,keywords:["inputs"],tagName:"input"},{type:"date",displayName:"Date",category:"inputs",swapGroup:null,keywords:["inputs"],tagName:"input"},{type:"range",displayName:"Range",category:"inputs",swapGroup:null,keywords:["inputs"],tagName:"input"},{type:"file",displayName:"File Upload",category:"inputs",swapGroup:null,keywords:["inputs"],tagName:"input"},{type:"search",displayName:"Search",category:"inputs",swapGroup:null,keywords:["inputs"],tagName:"input"},{type:"color",displayName:"Color Picker",category:"inputs",swapGroup:null,keywords:["inputs"],tagName:"input"},{type:"hidden",displayName:"Hidden",category:"inputs",swapGroup:null,keywords:["inputs"],tagName:"input"}]});var jC,DC=f(()=>{jC=[{type:"img",displayName:"Image",category:"media",swapGroup:null,keywords:["media"],tagName:"img"},{type:"video",displayName:"Video",category:"media",swapGroup:null,keywords:["media"],tagName:"video"},{type:"audio",displayName:"Audio",category:"media",swapGroup:null,keywords:["media"],tagName:"audio"},{type:"iframe",displayName:"Iframe",category:"media",swapGroup:null,keywords:["media"],tagName:"iframe"},{type:"figure",displayName:"Figure",category:"media",swapGroup:null,keywords:["media"],tagName:"figure"},{type:"figcaption",displayName:"Figcaption",category:"media",swapGroup:null,keywords:["media"],tagName:"figcaption"}]});var MC,ZC=f(()=>{MC=[{type:"ol",displayName:"Ordered List",category:"lists",swapGroup:"list-container",keywords:["lists"],tagName:"ol"},{type:"ul",displayName:"Unordered List",category:"lists",swapGroup:"list-container",keywords:["lists"],tagName:"ul"},{type:"li",displayName:"List Item",category:"lists",swapGroup:null,keywords:["lists"],tagName:"li"},{type:"dl",displayName:"Definition List",category:"lists",swapGroup:"list-container",keywords:["lists"],tagName:"dl"},{type:"dt",displayName:"Definition Term",category:"lists",swapGroup:null,keywords:["lists"],tagName:"dt"},{type:"dd",displayName:"Definition Description",category:"lists",swapGroup:null,keywords:["lists"],tagName:"dd"}]});var LC,FC=f(()=>{LC=[{type:"table",displayName:"Table",category:"tables",swapGroup:null,keywords:["tables"],tagName:"table"},{type:"thead",displayName:"Table Head",category:"tables",swapGroup:null,keywords:["tables"],tagName:"thead"},{type:"tbody",displayName:"Table Body",category:"tables",swapGroup:null,keywords:["tables"],tagName:"tbody"},{type:"tfoot",displayName:"Table Foot",category:"tables",swapGroup:null,keywords:["tables"],tagName:"tfoot"},{type:"tr",displayName:"Table Row",category:"tables",swapGroup:null,keywords:["tables"],tagName:"tr"},{type:"th",displayName:"Table Header Cell",category:"tables",swapGroup:null,keywords:["tables"],tagName:"th"},{type:"td",displayName:"Table Cell",category:"tables",swapGroup:null,keywords:["tables"],tagName:"td"}]});var UC,qC=f(()=>{UC=[{type:"fieldset",displayName:"Fieldset",category:"form",swapGroup:null,keywords:["form"],tagName:"fieldset"},{type:"legend",displayName:"Legend",category:"form",swapGroup:null,keywords:["form"],tagName:"legend"},{type:"meter",displayName:"Meter",category:"form",swapGroup:null,keywords:["form"],tagName:"meter"},{type:"progress",displayName:"Progress",category:"form",swapGroup:null,keywords:["form"],tagName:"progress"}]});var HC,BC=f(()=>{HC=[{type:"slot",displayName:"Slot",category:"special",swapGroup:null,keywords:["slot","placeholder","component","template"],tagName:"slot"}]});var r$e,qy=f(()=>{iC();kC();xu();$C();go();EC();NC();zC();IC();RC();AC();DC();ZC();FC();qC();BC();r$e=[...TC,...CC,...PC,...OC,...jC,...MC,...LC,...UC,...HC]});import{createHash as VU}from"crypto";function Qa(e){let t=typeof e=="string"?e:JSON.stringify(e,GU);return VU("sha256").update(t).digest("hex")}function GU(e,t){return e.startsWith(".")?void 0:t}var wd=f(()=>{i(Qa,"generateCID");i(GU,"filterDotKeys")});var fr,Xy,ec,XC=f(()=>{Xy=class Xy{constructor(t={}){k(this,fr,new Map);t&&Object.entries(t).forEach(([r,n])=>{y(this,fr).set(r,n)})}get(t){return y(this,fr).get(t)}set(t,r){y(this,fr).set(t,r)}has(t){return y(this,fr).has(t)}delete(t){y(this,fr).delete(t)}toObject(){return Object.fromEntries(y(this,fr))}getAllRids(){return Array.from(y(this,fr).keys())}pointsTo(t,r){return y(this,fr).get(t)===r}};fr=new WeakMap,i(Xy,"NodePointers");ec=Xy});function QC(e,t){return JSON.stringify({cid:e,data:t},(r,n)=>{if(!r.startsWith("."))return n})}var wo,mr,rc,Ys,bo,Pr,Jt,Yt,nc,Xs,rn,vo,So,tc,Qs,bd,Qy,WU,kd,eI,ex,Sd,tI=f(()=>{XC();wd();i(QC,"packLine");ex=class ex{constructor({name:t,dir:r,defaultRoots:n={},branch:o="main",getStore:s,storage:a}={}){k(this,rn);k(this,So);k(this,Qs);k(this,Qy);k(this,kd);k(this,wo,void 0);k(this,mr,void 0);k(this,rc,void 0);k(this,Ys,void 0);k(this,bo,void 0);k(this,Pr,void 0);k(this,Jt,new Map);k(this,Yt,new ec);k(this,nc,void 0);k(this,Xs,void 0);O(this,wo,t),O(this,mr,r?`${r}/${t}`:t),O(this,rc,n),O(this,Ys,o),O(this,nc,s),O(this,Xs,a),O(this,bo,`${y(this,mr)}/${t}.pack`),O(this,Pr,`${y(this,mr)}/index-${o}.jsonl`)}get name(){return y(this,wo)}get currentBranch(){return y(this,Ys)}get storageOpts(){return y(this,Xs)}async loadData(){let t=await E(this,Qs,bd).call(this,y(this,bo));y(this,Jt).clear();for(let a of t.trim().split(`
9
- `).filter(Boolean))try{let{cid:c,data:l}=JSON.parse(a);y(this,Jt).set(c,l)}catch{}let r=await E(this,Qs,bd).call(this,y(this,Pr)),n={};for(let a of r.trim().split(`
10
- `).filter(Boolean))try{let c=JSON.parse(a);for(let[l,u]of Object.entries(c))u==null?delete n[l]:n[l]=u}catch{}let o={},s={...y(this,rc)};for(let[a,c]of Object.entries(n)){if(!c||typeof c!="string")continue;let l=y(this,Jt).get(c);l!==void 0?(s[a]=l,o[a]=c):console.warn(`[CAS:${y(this,wo)}] CID not found for key "${a}" \u2014 pointer will be dropped`)}return O(this,Yt,new ec(o)),console.log(`[CAS:${y(this,wo)}] Loaded ${Object.keys(s).length} entries`),s}async put(t,r){await this.putBatch(new Map([[t,r]]))}async putBatch(t){let r="",n="";for(let[o,s]of t){if(!o||o==="undefined"||typeof o!="string")continue;let a=Qa(s);!a||typeof a!="string"||(y(this,Jt).has(a)||(y(this,Jt).set(a,s),r+=QC(a,s)+`
11
- `),y(this,Yt).pointsTo(o,a)||(y(this,Yt).set(o,a),n+=JSON.stringify({[o]:a})+`
12
- `))}r&&await E(this,So,tc).call(this,y(this,bo),r),n&&await E(this,So,tc).call(this,y(this,Pr),n)}buffered({delay:t=500}={}){let r=new Map,n=null,o=null,s=i(async()=>{if(clearTimeout(n),n=null,r.size===0)return;let c=new Map(r);r.clear(),o&&await o,o=this.putBatch(c).finally(()=>{o=null}),await o},"flush");return{put:i((c,l)=>{r.set(c,l),clearTimeout(n),n=setTimeout(()=>{s()},t)},"put"),flush:s}}async remove(t){if(!t||t==="undefined")return;y(this,Yt).get(t)&&await E(this,kd,eI).call(this,t)}switchBranch(t){O(this,Ys,t),O(this,Pr,`${y(this,mr)}/index-${t}.jsonl`)}async createBranch(t){let r=await E(this,rn,vo).call(this),n=`${y(this,mr)}/index-${t}.jsonl`,o=y(this,Yt).toObject(),s=Object.entries(o).map(([a,c])=>JSON.stringify({[a]:c})).join(`
8
+ }`}var x_=f(()=>{i(Fp,"createCode")});var eO={};C(eO,{createAction:()=>Bc});function Bc({name:e,code:t=Fp()}){return{name:e,code:t}}var Up=f(()=>{x_();i(Bc,"createAction")});var tO={};C(tO,{addAction:()=>__});function __(e,t){return e.update([t,"actions"],(r=[])=>{let n=`action${r.length+1}`;return r.some(o=>o.name===n)||r.unshift(Bc({name:n})),r})}var v_=f(()=>{Up();i(__,"addAction")});var b_={};C(b_,{updateAction:()=>w_});function w_(e,t,r,n){return e.update([t,"actions"],(o=[])=>(o[r]&&(o[r]=Bc(n)),o))}var qp=f(()=>{Up();i(w_,"updateAction")});var rO={};C(rO,{removeAction:()=>S_});function S_(e,t,r){return e.update([t,"actions"],(n=[])=>(n[r]&&n.splice(r,1),n))}var k_=f(()=>{i(S_,"removeAction")});import{defineContracts as MB}from"@jucie.io/engine-message";var ZB,nO=f(()=>{v_();qp();k_();ZB=MB("store:action",e=>{let t=e("state")?.ref([".stores"])??null;if(!t)throw new Error("Stores not found");return{add:{namespace:"scene-graph",schema:["String"],handler:r=>__(t,r)},update:{namespace:"scene-graph",schema:["String","Number","Object"],handler:(r,n,o)=>w_(t,r,n,o)},remove:{namespace:"scene-graph",schema:["String","Number"],handler:(r,n)=>S_(t,r,n)}}})});var oO={};C(oO,{createComputed:()=>Hc});function Hc({name:e,code:t=Fp()}){return{name:e,code:t}}var Bp=f(()=>{x_();i(Hc,"createComputed")});var sO={};C(sO,{addComputed:()=>$_});function $_(e,t){return e.update([t,"computed"],(r=[])=>{let n=`computed${r.length+1}`;return r.some(o=>o.name===n)||r.unshift(Hc({name:n})),r})}var E_=f(()=>{Bp();i($_,"addComputed")});var T_={};C(T_,{updateComputed:()=>N_});function N_(e,t,r,n){return e.update([t,"computed"],(o=[])=>(o[r]&&(o[r]=Hc(n)),o))}var Hp=f(()=>{Bp();i(N_,"updateComputed")});var iO={};C(iO,{removeComputed:()=>z_});function z_(e,t,r){return e.update([t,"computed"],(n=[])=>(n[r]&&n.splice(r,1),n))}var C_=f(()=>{i(z_,"removeComputed")});import{defineContracts as LB}from"@jucie.io/engine-message";var FB,aO=f(()=>{E_();Hp();C_();FB=LB("store:computed",e=>{let t=e("state")?.ref([".stores"])??null;if(!t)throw new Error("Stores not found");return{add:{schema:["String"],namespace:"scene-graph",handler:r=>{$_(t,r)}},update:{schema:["String","Number","Object"],namespace:"scene-graph",handler:(r,n,o)=>{N_(t,r,n,o)}},remove:{schema:["String","Number"],namespace:"scene-graph",handler:(r,n)=>{z_(t,r,n)}}}})});var cO={};C(cO,{createValue:()=>Vc});function Vc({key:e,type:t,value:r=""}){return{key:e,type:t,value:r}}var Vp=f(()=>{i(Vc,"createValue")});var lO={};C(lO,{addValue:()=>I_});function I_(e,t,r){return e.update([t,"state"],(n=[])=>{let o=`state${n.length+1}`;return n.some(s=>s.key===o)||n.unshift(Vc({key:o,type:r||"string",value:""})),n})}var P_=f(()=>{Vp();i(I_,"addValue")});var A_={};C(A_,{updateValue:()=>O_});function O_(e,t,r,n){return e.update([t,"state"],(o=[])=>(o[r]&&(o[r]=Vc(n)),o))}var Gp=f(()=>{Vp();i(O_,"updateValue")});var uO={};C(uO,{removeValue:()=>R_});function R_(e,t,r){return e.update([t,"state"],(n=[])=>(n[r]&&n.splice(r,1),n))}var j_=f(()=>{i(R_,"removeValue")});import{defineContracts as UB}from"@jucie.io/engine-message";var qB,dO=f(()=>{P_();Gp();j_();qB=UB("store:state",e=>{let t=e("state")?.ref([".stores"])??null;if(!t)throw new Error("Stores not found");return{add:{schema:["String","String"],namespace:"scene-graph",handler:(r,n)=>{I_(t,r,n)}},update:{schema:["String","Number","Object"],namespace:"scene-graph",handler:(r,n,o)=>{O_(t,r,n,o)}},remove:{schema:["String","Number"],namespace:"scene-graph",handler:(r,n)=>{R_(t,r,n)}}}})});function pO({name:e,code:t="",state:r=[],computed:n=[],actions:o=[]}){return{name:e,code:t,state:r,computed:n,actions:o}}var fO=f(()=>{i(pO,"createStore")});var mO={};C(mO,{addStore:()=>D_});function D_(e,t){let r=pO({name:t});return e.set([t],r),t}var M_=f(()=>{fO();i(D_,"addStore")});var hO={};C(hO,{removeStore:()=>Z_});function Z_(e,t){return e.remove([t])}var L_=f(()=>{i(Z_,"removeStore")});import{defineContracts as BB}from"@jucie.io/engine-message";var HB,gO=f(()=>{M_();L_();HB=BB("store",e=>{let t=e("state")?.ref([".stores"])??null;if(!t)throw new Error("Stores not found");return{get:{namespace:"scene-graph",handler:r=>r?t.get([r]):t.get()??{}},add:{schema:["String"],namespace:"scene-graph",handler:r=>D_(t,r)},remove:{schema:["String"],namespace:"scene-graph",handler:r=>{Z_(t,r)}}}})});var yO=f(()=>{nO();aO();dO();gO()});var xO=f(()=>{});var _O=f(()=>{});var Yn,Wp,vO=f(()=>{Yn={type:"root",children:[],meta:{childrenType:"children"}},Wp="3ec180328381108048f8882a9a6c41c1baf0763af128710bee612ce0f6d3315a"});var wO,bO=f(()=>{wO=[{type:"aside",displayName:"Aside",category:"layout",swapGroup:"layout",keywords:["layout"],tagName:"aside"},{type:"footer",displayName:"Footer",category:"layout",swapGroup:"layout",keywords:["layout"],tagName:"footer"},{type:"form",displayName:"Form",category:"layout",swapGroup:"layout",keywords:["layout"],tagName:"form"},{type:"header",displayName:"Header",category:"layout",swapGroup:"layout",keywords:["layout"],tagName:"header"},{type:"main",displayName:"Main",category:"layout",swapGroup:"layout",keywords:["layout"],tagName:"main"},{type:"section",displayName:"Section",category:"layout",swapGroup:"layout",keywords:["layout"],tagName:"section"},{type:"article",displayName:"Article",category:"layout",swapGroup:"layout",keywords:["layout"],tagName:"article"},{type:"nav",displayName:"Nav",category:"layout",swapGroup:"layout",keywords:["layout"],tagName:"nav"},{type:"div",displayName:"Div",category:"layout",swapGroup:"layout",keywords:["layout"],tagName:"div"},{type:"template",displayName:"Template",category:"layout",swapGroup:"layout",keywords:["layout"],tagName:"template"}]});var SO,kO=f(()=>{SO=[{type:"h1",displayName:"Heading 1",keywords:["headings"],category:"headings",swapGroup:"headings",tagName:"h1"},{type:"h2",displayName:"Heading 2",keywords:["headings"],category:"headings",swapGroup:"headings",tagName:"h2"},{type:"h3",displayName:"Heading 3",keywords:["headings"],category:"headings",swapGroup:"headings",tagName:"h3"},{type:"h4",displayName:"Heading 4",keywords:["headings"],category:"headings",swapGroup:"headings",tagName:"h4"},{type:"h5",displayName:"Heading 5",keywords:["headings"],category:"headings",swapGroup:"headings",tagName:"h5"},{type:"h6",displayName:"Heading 6",keywords:["headings"],category:"headings",swapGroup:"headings",tagName:"h6"},{type:"p",displayName:"Paragraph",category:"text",swapGroup:"text",keywords:["text"],tagName:"p"},{type:"label",displayName:"Label",category:"text",swapGroup:"text",keywords:["text"],tagName:"label"},{type:"span",displayName:"Span",category:"text",swapGroup:"text",keywords:["text"],tagName:"span"},{type:"blockquote",displayName:"Blockquote",category:"text",swapGroup:null,keywords:["text"],tagName:"blockquote"},{type:"pre",displayName:"Preformatted",category:"text",swapGroup:null,keywords:["text"],tagName:"pre"},{type:"codeElement",displayName:"Code",category:"text",swapGroup:"text",keywords:["text"],tagName:"code"},{type:"strong",displayName:"Strong",category:"text",swapGroup:"text",keywords:["text"],tagName:"strong"},{type:"em",displayName:"Emphasis",category:"text",swapGroup:"text",keywords:["text"],tagName:"em"},{type:"small",displayName:"Small",category:"text",swapGroup:"text",keywords:["text"],tagName:"small"},{type:"mark",displayName:"Mark",category:"text",swapGroup:null,keywords:["text"],tagName:"mark"},{type:"hr",displayName:"Horizontal Rule",category:"text",swapGroup:null,keywords:["text","divider"],tagName:"hr"},{type:"br",displayName:"Line Break",category:"text",swapGroup:null,keywords:["text"],tagName:"br"}]});var $O,EO=f(()=>{$O=[{type:"button",displayName:"Button",category:"interactive",swapGroup:"interactive",keywords:["interactive"],tagName:"button"},{type:"a",displayName:"Link",category:"interactive",swapGroup:"interactive",keywords:["interactive"],tagName:"a"},{type:"details",displayName:"Details",category:"interactive",swapGroup:null,keywords:["interactive"],tagName:"details"},{type:"summary",displayName:"Summary",category:"interactive",swapGroup:null,keywords:["interactive"],tagName:"summary"},{type:"dialog",displayName:"Dialog",category:"interactive",swapGroup:null,keywords:["interactive"],tagName:"dialog"}]});var NO,TO=f(()=>{NO=[{type:"radio",displayName:"Radio",category:"inputs",swapGroup:null,keywords:["inputs"],tagName:"input"},{type:"textInput",displayName:"Text",category:"inputs",swapGroup:null,keywords:["inputs"],tagName:"input"},{type:"checkbox",displayName:"Checkbox",category:"inputs",swapGroup:null,keywords:["inputs"],tagName:"input"},{type:"phone",displayName:"Phone",category:"inputs",swapGroup:null,keywords:["inputs"],tagName:"input"},{type:"email",displayName:"Email",category:"inputs",swapGroup:null,keywords:["inputs"],tagName:"input"},{type:"password",displayName:"Password",category:"inputs",swapGroup:null,keywords:["inputs"],tagName:"input"},{type:"select",displayName:"Select",category:"inputs",swapGroup:null,keywords:["inputs"],tagName:"select"},{type:"textarea",displayName:"Textarea",category:"inputs",swapGroup:null,keywords:["inputs"],tagName:"textarea"},{type:"number",displayName:"Number",category:"inputs",swapGroup:null,keywords:["inputs"],tagName:"input"},{type:"date",displayName:"Date",category:"inputs",swapGroup:null,keywords:["inputs"],tagName:"input"},{type:"range",displayName:"Range",category:"inputs",swapGroup:null,keywords:["inputs"],tagName:"input"},{type:"file",displayName:"File Upload",category:"inputs",swapGroup:null,keywords:["inputs"],tagName:"input"},{type:"search",displayName:"Search",category:"inputs",swapGroup:null,keywords:["inputs"],tagName:"input"},{type:"color",displayName:"Color Picker",category:"inputs",swapGroup:null,keywords:["inputs"],tagName:"input"},{type:"hidden",displayName:"Hidden",category:"inputs",swapGroup:null,keywords:["inputs"],tagName:"input"}]});var zO,CO=f(()=>{zO=[{type:"img",displayName:"Image",category:"media",swapGroup:null,keywords:["media"],tagName:"img"},{type:"video",displayName:"Video",category:"media",swapGroup:null,keywords:["media"],tagName:"video"},{type:"audio",displayName:"Audio",category:"media",swapGroup:null,keywords:["media"],tagName:"audio"},{type:"iframe",displayName:"Iframe",category:"media",swapGroup:null,keywords:["media"],tagName:"iframe"},{type:"figure",displayName:"Figure",category:"media",swapGroup:null,keywords:["media"],tagName:"figure"},{type:"figcaption",displayName:"Figcaption",category:"media",swapGroup:null,keywords:["media"],tagName:"figcaption"}]});var IO,PO=f(()=>{IO=[{type:"ol",displayName:"Ordered List",category:"lists",swapGroup:"list-container",keywords:["lists"],tagName:"ol"},{type:"ul",displayName:"Unordered List",category:"lists",swapGroup:"list-container",keywords:["lists"],tagName:"ul"},{type:"li",displayName:"List Item",category:"lists",swapGroup:null,keywords:["lists"],tagName:"li"},{type:"dl",displayName:"Definition List",category:"lists",swapGroup:"list-container",keywords:["lists"],tagName:"dl"},{type:"dt",displayName:"Definition Term",category:"lists",swapGroup:null,keywords:["lists"],tagName:"dt"},{type:"dd",displayName:"Definition Description",category:"lists",swapGroup:null,keywords:["lists"],tagName:"dd"}]});var OO,AO=f(()=>{OO=[{type:"table",displayName:"Table",category:"tables",swapGroup:null,keywords:["tables"],tagName:"table"},{type:"thead",displayName:"Table Head",category:"tables",swapGroup:null,keywords:["tables"],tagName:"thead"},{type:"tbody",displayName:"Table Body",category:"tables",swapGroup:null,keywords:["tables"],tagName:"tbody"},{type:"tfoot",displayName:"Table Foot",category:"tables",swapGroup:null,keywords:["tables"],tagName:"tfoot"},{type:"tr",displayName:"Table Row",category:"tables",swapGroup:null,keywords:["tables"],tagName:"tr"},{type:"th",displayName:"Table Header Cell",category:"tables",swapGroup:null,keywords:["tables"],tagName:"th"},{type:"td",displayName:"Table Cell",category:"tables",swapGroup:null,keywords:["tables"],tagName:"td"}]});var RO,jO=f(()=>{RO=[{type:"fieldset",displayName:"Fieldset",category:"form",swapGroup:null,keywords:["form"],tagName:"fieldset"},{type:"legend",displayName:"Legend",category:"form",swapGroup:null,keywords:["form"],tagName:"legend"},{type:"meter",displayName:"Meter",category:"form",swapGroup:null,keywords:["form"],tagName:"meter"},{type:"progress",displayName:"Progress",category:"form",swapGroup:null,keywords:["form"],tagName:"progress"}]});var DO,MO=f(()=>{DO=[{type:"slot",displayName:"Slot",category:"special",swapGroup:null,keywords:["slot","placeholder","component","template"],tagName:"slot"}]});var QCe,F_=f(()=>{QP();yO();Vd();xO();Go();_O();vO();Ri();bO();kO();EO();TO();CO();PO();AO();jO();MO();QCe=[...wO,...SO,...$O,...NO,...zO,...IO,...OO,...RO,...DO]});import{createHash as pH}from"crypto";function Gc(e){let t=typeof e=="string"?e:JSON.stringify(e,fH);return pH("sha256").update(t).digest("hex")}function fH(e,t){return e.startsWith(".")?void 0:t}var Qp=f(()=>{i(Gc,"generateCID");i(fH,"filterDotKeys")});var vr,X_,Wc,VO=f(()=>{X_=class X_{constructor(t={}){$(this,vr,new Map);t&&Object.entries(t).forEach(([r,n])=>{y(this,vr).set(r,n)})}get(t){return y(this,vr).get(t)}set(t,r){y(this,vr).set(t,r)}has(t){return y(this,vr).has(t)}delete(t){y(this,vr).delete(t)}toObject(){return Object.fromEntries(y(this,vr))}getAllRids(){return Array.from(y(this,vr).keys())}pointsTo(t,r){return y(this,vr).get(t)===r}};vr=new WeakMap,i(X_,"NodePointers");Wc=X_});function GO(e,t){return JSON.stringify({cid:e,data:t},(r,n)=>{if(!r.startsWith("."))return n})}var Yo,wr,Kc,Li,Xo,qr,rr,nr,Yc,Fi,hn,Ko,Qo,Jc,Ui,ef,Q_,mH,rf,WO,ev,tf,JO=f(()=>{VO();Qp();i(GO,"packLine");ev=class ev{constructor({name:t,dir:r,defaultRoots:n={},branch:o="main",getStore:s,storage:a}={}){$(this,hn);$(this,Qo);$(this,Ui);$(this,Q_);$(this,rf);$(this,Yo,void 0);$(this,wr,void 0);$(this,Kc,void 0);$(this,Li,void 0);$(this,Xo,void 0);$(this,qr,void 0);$(this,rr,new Map);$(this,nr,new Wc);$(this,Yc,void 0);$(this,Fi,void 0);O(this,Yo,t),O(this,wr,r?`${r}/${t}`:t),O(this,Kc,n),O(this,Li,o),O(this,Yc,s),O(this,Fi,a),O(this,Xo,`${y(this,wr)}/${t}.pack`),O(this,qr,`${y(this,wr)}/index-${o}.jsonl`)}get name(){return y(this,Yo)}get currentBranch(){return y(this,Li)}get storageOpts(){return y(this,Fi)}async loadData(){let t=await k(this,Ui,ef).call(this,y(this,Xo));y(this,rr).clear();for(let a of t.trim().split(`
9
+ `).filter(Boolean))try{let{cid:c,data:l}=JSON.parse(a);y(this,rr).set(c,l)}catch{}let r=await k(this,Ui,ef).call(this,y(this,qr)),n={};for(let a of r.trim().split(`
10
+ `).filter(Boolean))try{let c=JSON.parse(a);for(let[l,u]of Object.entries(c))u==null?delete n[l]:n[l]=u}catch{}let o={},s={...y(this,Kc)};for(let[a,c]of Object.entries(n)){if(!c||typeof c!="string")continue;let l=y(this,rr).get(c);l!==void 0?(s[a]=l,o[a]=c):console.warn(`[CAS:${y(this,Yo)}] CID not found for key "${a}" \u2014 pointer will be dropped`)}return O(this,nr,new Wc(o)),console.log(`[CAS:${y(this,Yo)}] Loaded ${Object.keys(s).length} entries`),s}async put(t,r){await this.putBatch(new Map([[t,r]]))}async putBatch(t){let r="",n="";for(let[o,s]of t){if(!o||o==="undefined"||typeof o!="string")continue;let a=Gc(s);!a||typeof a!="string"||(y(this,rr).has(a)||(y(this,rr).set(a,s),r+=GO(a,s)+`
11
+ `),y(this,nr).pointsTo(o,a)||(y(this,nr).set(o,a),n+=JSON.stringify({[o]:a})+`
12
+ `))}r&&await k(this,Qo,Jc).call(this,y(this,Xo),r),n&&await k(this,Qo,Jc).call(this,y(this,qr),n)}buffered({delay:t=500}={}){let r=new Map,n=null,o=null,s=i(async()=>{if(clearTimeout(n),n=null,r.size===0)return;let c=new Map(r);r.clear(),o&&await o,o=this.putBatch(c).finally(()=>{o=null}),await o},"flush");return{put:i((c,l)=>{r.set(c,l),clearTimeout(n),n=setTimeout(()=>{s()},t)},"put"),flush:s}}async remove(t){if(!t||t==="undefined")return;y(this,nr).get(t)&&await k(this,rf,WO).call(this,t)}switchBranch(t){O(this,Li,t),O(this,qr,`${y(this,wr)}/index-${t}.jsonl`)}async createBranch(t){let r=await k(this,hn,Ko).call(this),n=`${y(this,wr)}/index-${t}.jsonl`,o=y(this,nr).toObject(),s=Object.entries(o).map(([a,c])=>JSON.stringify({[a]:c})).join(`
13
13
  `);await r.write(n,s?s+`
14
- `:"")}async listBranchNames(){let r=await(await E(this,rn,vo).call(this)).listKeys(),n=`${y(this,mr)}/index-`,o=".jsonl";return r.filter(s=>s.startsWith(n)&&s.endsWith(o)).map(s=>s.slice(n.length,-o.length))}async deleteBranchIndex(t){let r=await E(this,rn,vo).call(this),n=`${y(this,mr)}/index-${t}.jsonl`;await r.exists(n)&&await r.delete(n)}async garbageCollect(t={dryRun:!1}){let r=await E(this,rn,vo).call(this),n=y(this,Yt).toObject(),o=Object.entries(n).filter(([,u])=>u!=null);if(!t.dryRun){let u=o.map(([d,p])=>JSON.stringify({[d]:p})).join(`
15
- `);await r.write(y(this,Pr),u?u+`
16
- `:"")}let s=await this.listBranchNames(),a=new Set;for(let u of s){let d=await E(this,Qs,bd).call(this,`${y(this,mr)}/index-${u}.jsonl`);for(let p of d.trim().split(`
17
- `).filter(Boolean))try{let h=JSON.parse(p);Object.values(h).forEach(m=>{m&&a.add(m)})}catch{}}let l=[...y(this,Jt).keys()].filter(u=>!a.has(u));if(!t.dryRun&&l.length>0){for(let d of l)y(this,Jt).delete(d);let u=[...y(this,Jt).entries()].map(([d,p])=>QC(d,p)).join(`
18
- `);await r.write(y(this,bo),u?u+`
19
- `:"")}return{deleted:l.length,kept:y(this,Jt).size}}};wo=new WeakMap,mr=new WeakMap,rc=new WeakMap,Ys=new WeakMap,bo=new WeakMap,Pr=new WeakMap,Jt=new WeakMap,Yt=new WeakMap,nc=new WeakMap,Xs=new WeakMap,rn=new WeakSet,vo=i(async function(){return y(this,nc).call(this,y(this,Xs))},"#store"),So=new WeakSet,tc=i(async function(t,r){let n=await E(this,rn,vo).call(this);if(typeof n.append=="function"){await n.append(t,r);return}let o=await n.exists(t)?await n.read(t):"",s=typeof o=="string"?o:String(o??"");await n.write(t,s+r)},"#append"),Qs=new WeakSet,bd=i(async function(t){let r=await E(this,rn,vo).call(this);if(!await r.exists(t))return"";let n=await r.read(t);return n==null?"":typeof n=="string"?n:String(n)},"#softRead"),Qy=new WeakSet,WU=i(async function(t,r){!t||!r||y(this,Yt).pointsTo(t,r)||(y(this,Yt).set(t,r),await E(this,So,tc).call(this,y(this,Pr),JSON.stringify({[t]:r})+`
20
- `))},"#setPointer"),kd=new WeakSet,eI=i(async function(t){t&&(y(this,Yt).delete(t),await E(this,So,tc).call(this,y(this,Pr),JSON.stringify({[t]:null})+`
21
- `))},"#deletePointer"),i(ex,"CASNamespace");Sd=ex});import{createDefinition as KU}from"@jucie.io/engine";var tx,On,rx=f(()=>{tx="CAS_CONFIG",On=KU(tx,[Object])});function rI(e){if(!e||typeof e!="object"||Array.isArray(e))throw new Error("CAS config.namespaces must be an object keyed by namespace name");return Object.entries(e).map(([t,r={}])=>{if(!t)throw new Error("CAS namespace config requires a name");if(r&&typeof r=="object"&&!Array.isArray(r)){let{name:n,...o}=r;if(n&&n!==t)throw new Error(`CAS namespace key "${t}" conflicts with opts.name "${n}"`);return{name:t,...o}}return{name:t}})}function nI(e){if(!e||typeof e!="object"||Array.isArray(e))throw new Error("CAS namespace config must be a plain object with a name");if(!e.name||typeof e.name!="string")throw new Error("CAS namespace config requires a name");return e}var oI=f(()=>{i(rI,"parseNamespaces");i(nI,"parseNamespaceObject")});import{ServiceProvider as JU,definitionType as YU}from"@jucie.io/engine";import{StorageServer as XU}from"@jucie.io/engine-storage/server";var nx,hr,it,ic,ac,ei,ti,An,cc,lc,ox,Nd,sI,uc,sx,dc,ix,ri,$d,ko,oc,$o,sc,ni,Ed,pc,ax,Td,iI,zd,nn,aI=f(()=>{wd();tI();rx();oI();nx="branches.json",zd=class zd extends JU{constructor(){super(...arguments);k(this,lc);k(this,Nd);k(this,uc);k(this,dc);k(this,ri);k(this,ko);k(this,$o);k(this,ni);k(this,pc);k(this,Td);k(this,hr,"main");k(this,it,new Map);k(this,ic,new Map);k(this,ac,new Set);k(this,ei,[]);k(this,ti,null);k(this,An,null);k(this,cc,!1)}initialize(){O(this,hr,this.config.branch||"main");let r=rI(this.config.namespaces??{});for(let n of r)E(this,ko,oc).call(this,n);this.config.configs?.length&&E(this,lc,ox).call(this,...this.config.configs)}actions(){return{generateCID:r=>Qa(r),namespace:(r,n)=>this.namespace(r,n),load:()=>this.load(),put:(r,n,o)=>this.put(r,n,o),remove:(r,n)=>this.remove(r,n),listNamespaces:()=>this.listNamespaces(),garbageCollect:r=>this.runGarbageCollection(r),createBranch:(r,n)=>this.createBranch(r,n),switchBranch:r=>this.switchBranch(r),listBranches:()=>this.listBranches(),getCurrentBranch:()=>y(this,hr),deleteBranch:r=>this.deleteBranch(r),use:(...r)=>E(this,lc,ox).call(this,...r),setup:()=>this.runSetup(),dispose:()=>E(this,dc,ix).call(this)}}listNamespaces(){return[...y(this,it).keys()]}runSetup(){for(let[r,n]of y(this,ic))E(this,uc,sx).call(this,r,n);return{dispose:()=>E(this,dc,ix).call(this)}}async put(r,n,o){await E(this,ri,$d).call(this,r).put(n,o)}async remove(r,n){await E(this,ri,$d).call(this,r).remove(n)}async namespace(r,n={}){if(!r||typeof r!="string")throw new Error("CAS.namespace requires a name string");if(y(this,it).has(r))return r;if(E(this,ko,oc).call(this,{name:r,...n}),y(this,cc)){let s=await y(this,it).get(r).loadData();return{name:r,data:s}}return r}async load(){console.time("\u23F1\uFE0F Total load");try{await E(this,$o,sc).call(this);for(let n of y(this,it).values())await n.loadData();await this.runGarbageCollection();let r={};for(let n of y(this,it).values())r[n.name]=await n.loadData();return O(this,cc,!0),console.timeEnd("\u23F1\uFE0F Total load"),r}catch(r){throw console.warn("\u26A0\uFE0F Could not load CAS data:",r.message),r}}async createBranch(r,n){if(!r||r.includes("/")||r.includes("\\"))throw new Error(`Invalid branch name: ${r}`);for(let o of y(this,it).values())await o.createBranch(r);return await E(this,Td,iI).call(this,r,{displayName:n||r,created:new Date().toISOString(),createdFrom:y(this,hr)}),console.log(`\u{1F33F} Created branch '${r}' from '${y(this,hr)}'`),r}async switchBranch(r){O(this,hr,r);for(let n of y(this,it).values())n.switchBranch(r);return console.log(`\u{1F500} Switched to branch '${r}'`),r}async listBranches(){let r=[...y(this,it).values()][0];if(!r)return[];let n=await r.listBranchNames(),o=await E(this,ni,Ed).call(this);return n.map(s=>({name:s,current:s===y(this,hr),...o[s]}))}async deleteBranch(r){if(r===y(this,hr))throw new Error(`Cannot delete current branch '${r}'`);for(let o of y(this,it).values())await o.deleteBranchIndex(r);let n=await E(this,ni,Ed).call(this);return delete n[r],await E(this,pc,ax).call(this,n),console.log(`\u{1F5D1}\uFE0F Deleted branch '${r}'`),r}async runGarbageCollection(r={dryRun:!1}){console.log("\u{1F9F9} Starting garbage collection...");let n={};for(let o of y(this,it).values())n[o.name]=await o.garbageCollect(r),console.log(`\u2705 GC [${o.name}]: removed ${n[o.name].deleted}, kept ${n[o.name].kept}`);return n}};hr=new WeakMap,it=new WeakMap,ic=new WeakMap,ac=new WeakMap,ei=new WeakMap,ti=new WeakMap,An=new WeakMap,cc=new WeakMap,lc=new WeakSet,ox=i(function(...r){for(let n of r){let o=YU(n);if(o===tx){E(this,Nd,sI).call(this,n);continue}if(n&&typeof n=="object"){E(this,ko,oc).call(this,nI(n));continue}throw new Error(`CAS.use() expects casConfig definitions or namespace objects, got "${o??typeof n}"`)}},"#useConfigs"),Nd=new WeakSet,sI=i(function(r){let n=r._name;if(!n||typeof n!="string")throw new Error("casConfig definition requires a name (first argument to defineCasConfig)");let o=r(this.inject.bind(this));y(this,ic).set(n,o),E(this,ko,oc).call(this,{name:n,dir:o.dir,defaultRoots:o.defaultRoots??{},storage:o.storage}),E(this,uc,sx).call(this,n,o)},"#resolveDefinition"),uc=new WeakSet,sx=i(function(r,n){if(typeof n.setup!="function"||y(this,ac).has(r))return;let o={put:(a,c)=>this.put(r,a,c),remove:a=>this.remove(r,a),buffered:a=>E(this,ri,$d).call(this,r).buffered(a)},s=n.setup(o);typeof s=="function"&&y(this,ei).push(s),y(this,ac).add(r)},"#runSetupFor"),dc=new WeakSet,ix=i(function(){for(let r of y(this,ei))r();O(this,ei,[])},"#disposeAll"),ri=new WeakSet,$d=i(function(r){let n=y(this,it).get(r);if(!n)throw new Error(`CAS namespace "${r}" is not registered`);return n},"#getNamespace"),ko=new WeakSet,oc=i(function({name:r,dir:n,defaultRoots:o={},storage:s}={}){if(!r)throw new Error("CAS namespace config requires a name");if(y(this,it).has(r))return;let a=new Sd({name:r,dir:n,defaultRoots:o,branch:y(this,hr),storage:s,getStore:c=>E(this,$o,sc).call(this,c??s)});y(this,it).set(r,a)},"#registerSync"),$o=new WeakSet,sc=i(async function(r){let n=r??null;if(!n&&y(this,ti))return y(this,ti);if(!n&&y(this,An))return y(this,An);let o=i(async()=>{let s=this.inject("storage");if(!s)throw new Error("CAS requires the Storage service. Install StorageServer/StorageClient and configure storage.");let a=n??this.config.storage;!a&&this.config.sceneGraph&&(a={name:"scene",provider:"local",root:this.config.sceneGraph});let c;if(typeof a=="string")c=s.use(a);else if(a&&typeof a=="object"){let{name:l="scene",provider:u="local",mode:d="path",...p}=a;s.has(l)||await s.create(l,u,{...p,mode:d}),c=s.use(l)}else c=s.use();return n||O(this,ti,c),c},"resolve");return n?o():(O(this,An,o().catch(s=>{throw O(this,An,null),s})),y(this,An))},"#ensureStore"),ni=new WeakSet,Ed=i(async function(){try{let r=await E(this,$o,sc).call(this);if(!await r.exists(nx))return{};let n=await r.read(nx),o=typeof n=="string"?n:String(n);return JSON.parse(o)}catch{return{}}},"#loadBranchesMetadata"),pc=new WeakSet,ax=i(async function(r){await(await E(this,$o,sc).call(this)).write(nx,JSON.stringify(r,null,2))},"#saveBranchesMetadata"),Td=new WeakSet,iI=i(async function(r,n){let o=await E(this,ni,Ed).call(this);o[r]={...o[r],...n},await E(this,pc,ax).call(this,o)},"#updateBranchMetadata"),i(zd,"CAS"),Te(zd,"manifest",{name:"CAS",namespace:"cas",dependencies:[XU]});nn=zd});var oi=f(()=>{aI();wd();rx()});import{ServiceProvider as QU}from"@jucie.io/engine";import{Matcher as e6}from"@jucie.io/state-matcher";import{watch as t6}from"chokidar";import{readFile as r6,writeFile as n6,mkdir as o6,access as s6,constants as i6,unlink as a6}from"fs/promises";import{glob as c6}from"glob";import si from"path";import*as jn from"recast";import{createHash as l6}from"crypto";import{parse as cI}from"@babel/parser";var ke,lI,ii,fc,Eo,on,Oe,sn,Cd,an,uI=f(()=>{({builders:ke,namedTypes:lI}=jn.types),Cd=class Cd extends QU{constructor(){super(...arguments);k(this,ii,new Set);k(this,fc,new Set);k(this,Eo,new Set);k(this,on,null);k(this,Oe,null);k(this,sn,new Map)}initialize(r){let n=r("state");!n||!n.matcher||n.matcher||n.use(e6)}actions(){return{start:()=>this.start(),build:()=>this.build(),scanDirectory:r=>this.scanDirectory(r),watchDirectory:r=>this.watchDirectory(r),stopWatching:()=>this.stopWatching(),parse:r=>this.parse(r),generate:r=>this.generate(r),generateHash:r=>this.generateHash(r),parseAndStore:(r,n)=>this.parseAndStore(r,n),writeFile:(r,n)=>this.writeFile(r,n),removeFile:r=>this.removeFile(r),getStore:r=>this.inject("state")?.get(["stores",r]),getAllStores:()=>this.inject("state")?.get(["stores"])}}async generateHash(r){let n=l6("sha256"),o=r;return o.charCodeAt(0)===65279&&(o=o.slice(1)),o=o.replace(/\r\n/g,`
22
- `),o=o.normalize("NFC"),n.update(o),n.digest("hex")}async start(r){try{if(O(this,Oe,r||this.config.stores),!y(this,Oe))throw new Error("StoreParser start error: Base directory not defined");await this.scanDirectory(y(this,Oe)),this.watchDirectory(y(this,Oe));let n=this.inject("state"),o=n?.get(["stores"]);return n&&(!o||Object.keys(o).length===0)&&n.set(["stores","default"],{}),this}catch(n){return console.error("StoreParser start error",n),null}}async build(){return O(this,Oe,this.config.stores),await this.scanDirectory(y(this,Oe)),this.inject("state").get(["stores"])}async scanDirectory(r){O(this,Oe,r||this.config.stores),console.log("\u{1F50D} Scanning directory:",y(this,Oe));let n=await this.findAllStoreFiles(y(this,Oe));for(let o of n){let s=this.extractStoreName(o,y(this,Oe));await this.parseAndStore(o,s)}return console.log(`\u{1F4C2} Scanned ${n.length} store file(s)`),this.inject("state").get(["stores"])}async findAllStoreFiles(r){return c6.sync(`${r}/**/*.{js,mjs,ts}`,{ignore:"**/node_modules/**"})}watchDirectory(r){return O(this,Oe,r||this.config.stores),console.log("\u{1F50D} Watching directory:",y(this,Oe)),O(this,on,t6(y(this,Oe),{ignored:/(^|[\/\\])\../,persistent:!0,ignoreInitial:!1,awaitWriteFinish:{stabilityThreshold:100,pollInterval:50}})),y(this,on).on("add",n=>this.handleFileAdded(n)).on("change",n=>this.handleFileChanged(n)).on("unlink",n=>this.handleFileDeleted(n)),this.inject("state").matcher.createMatcher(["stores"],async n=>{if(!n)return;let o=Object.entries(n);for(let[s,a]of o){if(!a){await this.removeFile(s);continue}try{let c=this.generate(a);await this.writeFile(s,c)}catch(c){console.error(`\u26A0\uFE0F Skipped writing store "${s}": ${c.message}`)}}}),console.log(`\u{1F441}\uFE0F Watching directory: ${r}`),y(this,on)}async handleFileAdded(r){if(console.log("\u{1F50D} File added:",r),!this.isValidStoreFile(r))return;let n=this.extractStoreName(r,y(this,Oe));if(y(this,fc).has(n)){y(this,fc).delete(n);return}else await this.parseAndStore(r,n);console.log(`\u2795 Added store: ${n}`)}async handleFileChanged(r){if(console.log("\u{1F50D} File changed:",r),!this.isValidStoreFile(r))return;let n=this.extractStoreName(r,y(this,Oe));y(this,ii).has(n)?y(this,ii).delete(n):await this.parseAndStore(r,n),console.log(`\u{1F504} Updated store: ${n}`)}handleFileDeleted(r){console.log("\u{1F50D} File deleted:",r);let n=this.extractStoreName(r,y(this,Oe));if(y(this,sn).delete(n),y(this,Eo).has(n)){y(this,Eo).delete(n);return}else this.inject("state")?.remove(["stores",n]);console.log(`\u2796 Removed store: ${n}`)}async parseAndStore(r,n){try{let o=await r6(r,"utf8"),s=await this.generateHash(o),a=y(this,sn).get(n);if(s===a){console.log(`\u23ED\uFE0F Skipped parsing ${n} (no content change)`);return}let c=this.parse(o),l=this.inject("state");return l&&l.set(["stores",n],c),y(this,sn).set(n,s),c}catch(o){return console.error(` \u2717 Failed to parse ${n}:`,o.message),null}}extractStoreName(r,n){return si.relative(n,r).replace(/\.(js|mjs|ts)$/,"").replace(/\\/g,"/")}isValidStoreFile(r){let n=[".js",".mjs",".ts"],o=si.extname(r);return n.includes(o)}stopWatching(){y(this,on)&&(y(this,on).close(),O(this,on,null),console.log("\u{1F6D1} Store watcher stopped"))}async fileExists(r){try{return await s6(si.join(y(this,Oe),`${r}.js`),i6.F_OK),!0}catch{return!1}}async writeFile(r,n){try{if(!r||!y(this,Oe))return;let o=await this.generateHash(n),s=y(this,sn).get(r);if(o===s){console.log(`\u23ED\uFE0F Skipped writing ${r} (no content change)`);return}let a=si.join(y(this,Oe),`${r}.js`);console.log("\u{1F50D} Writing store file to:",a),y(this,ii).add(r),await o6(si.dirname(a),{recursive:!0}),await n6(a,n,"utf8"),y(this,sn).set(r,o),console.log(`\u{1F4BE} Wrote store file: ${r}`)}catch(o){throw console.trace(`Failed to write store file: ${r}:`,o.message),new Error(`Failed to write store file: ${r}: ${o.message}`)}}async removeFile(r){if(!r||!y(this,Oe))return;let n=si.join(y(this,Oe),`${r}.js`);try{y(this,Eo).add(r),await a6(n),y(this,sn).delete(r),console.log(`\u{1F5D1}\uFE0F Removed store file: ${r}`)}catch(o){throw y(this,Eo).delete(r),console.error(`Failed to remove store file: ${r}:`,o.message),new Error(`Failed to remove store file: ${r}: ${o.message}`)}}parse(r){let n={};try{let s=jn.parse(r,{parser:{parse(c){return cI(c,{sourceType:"module",plugins:["optionalChaining","nullishCoalescingOperator"]})}}}).program.body.find(c=>lI.ExportDefaultDeclaration.check(c));if(!s||!lI.ObjectExpression.check(s.declaration))throw new Error("No export default object found");return s.declaration.properties.forEach(c=>{if(!c||c.type!=="ObjectProperty")return;let l=c.key.name,u=c.value;l==="state"&&c.value.type==="ObjectExpression"?n.state=this.extractState(u):l==="computed"&&c.value.type==="ObjectExpression"?n.computed=this.extractFunctions(u):l==="actions"&&c.value.type==="ObjectExpression"&&(n.actions=this.extractFunctions(u))}),n}catch(o){throw console.error("Failed to parse store code:",o.message),new Error(`Invalid store code: ${o.message}`)}}generate(r){try{let n=this.buildAST(r);return jn.print(n,{tabWidth:2,quote:"single",trailingComma:!1}).code}catch(n){throw console.error("Failed to generate store code:",n.message),new Error(`Code generation failed: ${n.message}`)}}buildAST(r){let n=[];if(r.state?.length>0){let a=this.buildStateObject(r.state);n.push(ke.property("init",ke.identifier("state"),a))}if(r.computed?.length>0){let a=this.buildFunctionsObject(r.computed);n.push(ke.property("init",ke.identifier("computed"),a))}if(r.actions?.length>0){let a=this.buildFunctionsObject(r.actions);n.push(ke.property("init",ke.identifier("actions"),a))}let o=ke.objectExpression(n),s=ke.exportDefaultDeclaration(o);return ke.program([s])}buildStateObject(r){let n=r.map(o=>{let s=this.valueToASTNode(o.value),a=[ke.property("init",ke.identifier("type"),ke.literal(o.type)),ke.property("init",ke.identifier("default"),s)],c=ke.objectExpression(a);return ke.property("init",ke.identifier(o.key),c)});return ke.objectExpression(n)}valueToASTNode(r){if(Array.isArray(r))return ke.arrayExpression(r.map(n=>this.valueToASTNode(n)));if(typeof r=="object"&&r!==null){let n=Object.entries(r).map(([o,s])=>ke.property("init",ke.identifier(o),this.valueToASTNode(s)));return ke.objectExpression(n)}else return ke.literal(r)}buildFunctionsObject(r){let n=r.map(o=>{let a=jn.parse(`(${o.code})`,{parser:{parse(c){return cI(c,{sourceType:"module",plugins:["optionalChaining","nullishCoalescingOperator"]})}}}).program.body[0].expression;return a.extra&&(a.extra.parenthesized=!1),ke.property("init",ke.identifier(o.name),a)});return ke.objectExpression(n)}extractState(r){return r.properties.map(n=>{let o=n.key.name,s=n.value,a="string",c="";return s.type==="ObjectExpression"&&s.properties.forEach(l=>{l.key.name==="type"&&(l.value.type==="StringLiteral"||l.value.type==="Literal")&&(a=l.value.value),l.key.name==="default"&&(c=this.getLiteralValue(l.value))}),{key:o,type:a,value:c}})}extractFunctions(r){return r.properties.map(n=>{let o=n.key.name,s=n.value,a=jn.print(s).code;return{name:o,code:a}})}getLiteralValue(r){if(r.type==="StringLiteral"||r.type==="NumericLiteral"||r.type==="BooleanLiteral"||r.type==="Literal")return r.value;if(r.type==="NullLiteral")return null;if(r.type==="ArrayExpression")return r.elements.map(n=>this.getLiteralValue(n));if(r.type==="ObjectExpression"){let n={};return r.properties.forEach(o=>{if(o.type==="ObjectProperty"||o.type==="Property"){let s=o.key.name||o.key.value;n[s]=this.getLiteralValue(o.value)}}),n}return""}};ii=new WeakMap,fc=new WeakMap,Eo=new WeakMap,on=new WeakMap,Oe=new WeakMap,sn=new WeakMap,i(Cd,"StoreParser"),Te(Cd,"manifest",{name:"StoreParser",namespace:"storeParser"});an=Cd});var Id=f(()=>{uI()});import{GLOBAL_TAG as cx}from"@jucie.io/state/lib/TOKENS.js";import{createChange as u6}from"@jucie.io/state/lib/change.js";import{Plugin as d6}from"@jucie.io/state/Plugin";import{traverse as p6}from"@jucie.io/state/lib/tree/traverse.js";import{encodePath as dI,decodeAddress as lx}from"@jucie.io/state/lib/pathEncoder.js";import{createMarker as pI,dispatch as ux}from"@jucie.io/state/lib/marker.js";var f6,m6,mc,ci,gc,Ue,Ge,jt,gr,cn,Xt,No,To,ln,zo,un,Co,Od,fI,Ad,mI,xc,dx,_c,px,vc,fx,Io,hc,jd,hI,wc,mx,Dd,gI,Md,yI,Zd,xI,bc,hx,Sc,gx,li,Pd,Ld,_I,kc,yx,ui,Rd,Fd,vI,ai,yc,wI=f(()=>{f6=typeof window<"u"&&typeof window.document<"u",m6=typeof process<"u"&&process.versions?.node,mc=0,ci="entry",gc="tombstone",ai=class ai extends d6{constructor(){super(...arguments);k(this,Od);k(this,Ad);k(this,xc);k(this,_c);k(this,vc);k(this,Io);k(this,jd);k(this,wc);k(this,Dd);k(this,Md);k(this,Zd);k(this,bc);k(this,Sc);k(this,li);k(this,Ld);k(this,kc);k(this,ui);k(this,Fd);k(this,Ue,new Map);k(this,Ge,new Map);k(this,jt,new Set);k(this,gr,[]);k(this,cn,!1);k(this,Xt,!1);k(this,No,null);k(this,To,void 0);k(this,ln,new Set);k(this,zo,!1);k(this,un,new Set);k(this,Co,!1);Te(this,"onTombstoneConflict",null)}initialize(r,n){O(this,cn,!1),O(this,No,n.actorId??n.userId??null),O(this,To,Date.now())}get batchSize(){return this.options.batchSize}actions(){return{addChangeListener:r=>this.addChangeListener(r),removeChangeListener:r=>this.removeChangeListener(r),addLedgerListener:r=>this.addLedgerListener(r),removeLedgerListener:r=>this.removeLedgerListener(r),kill:(...r)=>this.kill(r),resurrect:(...r)=>this.resurrect(r),snapshot:()=>this.snapshot(),hydrate:r=>this.hydrate(r),merge:r=>this.merge(r),apply:r=>this.apply(r),getStats:()=>this.getStats()}}onStateChange(r,n){y(this,Xt)||(ux(r,{global:o=>y(this,gr).push({marker:o,change:n}),path:o=>y(this,gr).push({marker:o,change:n}),ephemeral:()=>{}}),E(this,bc,hx).call(this))}addChangeListener(r){return y(this,ln).add(r),y(this,ln).size>0&&O(this,zo,!0),()=>this.removeChangeListener(r)}removeChangeListener(r){y(this,ln).delete(r),y(this,ln).size===0&&O(this,zo,!1)}addLedgerListener(r){return y(this,un).add(r),y(this,un).size>0&&O(this,Co,!0),()=>this.removeLedgerListener(r)}removeLedgerListener(r){y(this,un).delete(r),y(this,un).size===0&&O(this,Co,!1)}getEntry(r){return y(this,Ue).get(dI(r))}getTombstone(r){return y(this,Ge).get(dI(r))}snapshot(){return{state:this.state.get(),ledger:Object.fromEntries(y(this,Ue)),tombstones:Object.fromEntries(y(this,Ge))}}hydrate({state:r,ledger:n={},tombstones:o={}}={}){O(this,Xt,!0);try{O(this,gr,[]),r!==void 0&&this.state.load(r),O(this,Ue,E(this,Io,hc).call(this,n)),O(this,Ge,E(this,Io,hc).call(this,o)),E(this,Dd,gI).call(this),E(this,li,Pd).call(this),O(this,gr,[])}finally{O(this,Xt,!1)}return this}apply(r){if(!r?.length)return[];let n=[],o=[];O(this,Xt,!0);try{for(let s of r){let[a,c,l,u]=s;if(!(!c||!a)){if(a===gc){y(this,Ge).set(c,u),y(this,jt).add(c),E(this,vc,fx).call(this,c),l&&o.push(l),n.push(s);continue}a!==ci||!u||E(this,wc,mx).call(this,c,u)&&(y(this,Ue).set(c,u),l&&o.push(l),n.push(s))}}o.length>0&&this.state.apply(o),E(this,li,Pd).call(this)}finally{O(this,Xt,!1)}return n.length>0&&E(this,ui,Rd).call(this,n),n}merge({state:r,ledger:n={},tombstones:o={}}={}){if(!r&&!n&&!o)return this.state;O(this,Xt,!0);try{for(let[s,a]of E(this,Io,hc).call(this,n)){if(s===cx||lx(s)===cx||!E(this,wc,mx).call(this,s,a))continue;y(this,Ue).set(s,a);let c=lx(s),l=r?p6(r,c):void 0;l!==void 0&&this.state.set(c,l)}for(let[s,a]of E(this,Io,hc).call(this,o)){if(!E(this,jd,hI).call(this,s,a))continue;let c=lx(s);this.state.remove(c),y(this,Ge).set(s,a),y(this,jt).add(s)}E(this,li,Pd).call(this)}finally{O(this,Xt,!1)}return this.state}reset(){y(this,Ue).clear(),y(this,Ge).clear(),y(this,jt).clear(),O(this,gr,[]),O(this,cn,!1),O(this,No,null),O(this,To,Date.now()),y(this,ln).clear(),O(this,zo,!1),y(this,un).clear(),O(this,Co,!1)}getStats(){return{entriesCount:y(this,Ue).size,tombstonesCount:y(this,Ge).size,tombstoneIndexCount:y(this,jt).size,changeQueueCount:y(this,gr).length,isProcessing:y(this,cn),actorId:y(this,No),sessionEpoch:y(this,To),globalClock:mc}}kill(r){let n=pI(r);return ux(n,{global:()=>{throw new Error("Cannot kill global state")},path:({path:o,address:s})=>{O(this,Xt,!0);try{let a=this.state.remove(o),c=E(this,Od,fI).call(this,s,a),l=u6(n,"remove",void 0,a),u=[gc,s,l,c];return E(this,kc,yx).call(this,[u]),E(this,ui,Rd).call(this,[u]),a}finally{O(this,Xt,!1)}},error:o=>console.error(o)})}resurrect(r){try{let n=pI(r),o=E(this,Ad,mI).call(this,n.address);if(!o)throw new Error(`No tombstone found for path: ${n.path.join(".")}`);let s=JSON.parse(o.data);return this.state.set(n.path,s),s}catch(n){console.error(n);return}}};Ue=new WeakMap,Ge=new WeakMap,jt=new WeakMap,gr=new WeakMap,cn=new WeakMap,Xt=new WeakMap,No=new WeakMap,To=new WeakMap,ln=new WeakMap,zo=new WeakMap,un=new WeakMap,Co=new WeakMap,Od=new WeakSet,fI=i(function(r,n){let o={data:JSON.stringify(n),timestamp:Date.now()};return y(this,Ge).set(r,o),y(this,jt).add(r),E(this,vc,fx).call(this,r),E(this,Ld,_I).call(this),o},"#createTombstone"),Ad=new WeakSet,mI=i(function(r){let n=y(this,Ge).get(r);if(n)return y(this,Ge).delete(r),y(this,jt).delete(r),n},"#removeTombstone"),xc=new WeakSet,dx=i(function(r,n){if(!r)return-1;if(!n)return 1;let[o,s,a,c]=r,[l,u,d,p]=n;return o!==l?o>l?1:-1:s!==u?s>u?1:-1:a!==d?a>d?1:-1:c!==p?String(c??"").localeCompare(String(p??"")):0},"#compareEntries"),_c=new WeakSet,px=i(function(r){if(y(this,jt).has(r))return!0;let n=r.length;for(;n=r.lastIndexOf(".",n-1),n!==-1;)if(y(this,jt).has(r.slice(0,n)))return!0;return!1},"#isPathTombstoned"),vc=new WeakSet,fx=i(function(r){let n=[];for(let[o]of y(this,Ue))(o===r||o.startsWith(r))&&n.push(o);for(let o of n)y(this,Ue).delete(o)},"#removeEntriesUnderPath"),Io=new WeakSet,hc=i(function(r){return r?r instanceof Map?new Map(r):Array.isArray(r)?new Map(r):typeof r=="object"?new Map(Object.entries(r)):new Map:new Map},"#toMap"),jd=new WeakSet,hI=i(function(r,n){let o=y(this,Ue).get(r),s=y(this,Ge).get(r);return!!(!s&&!o||s&&n.timestamp>s.timestamp||o&&!s)},"#shouldApplyTombstone"),wc=new WeakSet,mx=i(function(r,n){if(E(this,_c,px).call(this,r))return!1;let o=y(this,Ue).get(r);return E(this,xc,dx).call(this,n,o)>0},"#shouldApplyRemoteEntry"),Dd=new WeakSet,gI=i(function(){y(this,jt).clear();for(let[r]of y(this,Ge))y(this,jt).add(r)},"#rebuildTombstoneIndexes"),Md=new WeakSet,yI=i(function(r){f6&&"requestIdleCallback"in window?window.requestIdleCallback(r,{timeout:50}):m6?setImmediate(r):setTimeout(r,0)},"#scheduleIdle"),Zd=new WeakSet,xI=i(function(r){let n=!1;Promise.resolve().then(()=>{n||(n=!0,r())}),setTimeout(()=>{n||(n=!0,r())},0)},"#scheduleNextTick"),bc=new WeakSet,hx=i(function(){y(this,cn)||(O(this,cn,!0),E(this,Zd,xI).call(this,()=>{let r=y(this,gr).splice(0,this.options.batchSize||ai.options.batchSize),n=[],o=[];for(let{marker:s,change:a}of r)ux(s,{global:()=>{let c=E(this,Sc,gx).call(this,s.address);n.push([ci,cx,a,c])},path:({path:c})=>{if(E(this,_c,px).call(this,s.address)){o.push(c);return}let l=E(this,Sc,gx).call(this,s.address);n.push([ci,s.address,a,l])}});o.length>0&&E(this,Md,yI).call(this,()=>E(this,Fd,vI).call(this,this.state,o)),E(this,kc,yx).call(this,n),E(this,ui,Rd).call(this,n),O(this,cn,!1),y(this,gr).length>0&&E(this,bc,hx).call(this)}))},"#scheduleRecord"),Sc=new WeakSet,gx=i(function(r){let n=y(this,Ue).get(r);y(this,Ue).delete(r);let a=[(n?n[0]:0)+1,mc++,y(this,To),y(this,No)];if(y(this,Ue).set(r,a),y(this,Ue).size>this.options.maxSize){let c=y(this,Ue).size-this.options.maxSize,l=Array.from(y(this,Ue).entries()).sort((u,d)=>E(this,xc,dx).call(this,u[1],d[1]));for(let u=0;u<c;u++)y(this,Ue).delete(l[u][0])}return a},"#updateLedger"),li=new WeakSet,Pd=i(function(){let r=-1;for(let n of y(this,Ue).values())n&&n[1]>r&&(r=n[1]);mc=mc>r?mc+1:r+1},"#continueGlobalClock"),Ld=new WeakSet,_I=i(function(){let o=Date.now();for(let[s,{timestamp:a}]of y(this,Ge))(y(this,Ge).size>1e3||o-a>2592e6)&&y(this,Ge).delete(s)},"#checkTombstoneSize"),kc=new WeakSet,yx=i(function(r){y(this,zo)&&y(this,ln).forEach(n=>n(r))},"#callChangeListeners"),ui=new WeakSet,Rd=i(function(r){y(this,Co)&&y(this,un).forEach(n=>n(r))},"#callLedgerListeners"),Fd=new WeakSet,vI=i(function(r,n){for(let o of n)try{r.remove(o)}catch(s){console.warn(`Tombstone cleanup failed for path ${o.join(".")}:`,s.message)}},"#cleanupTombstoneConflicts"),Te(ai,"name","ledger"),Te(ai,"options",{actorId:null,userId:null,maxSize:1e4,batchSize:100}),Te(ai,"empty",{ledger:[],tombstones:[]});yc=ai});var xx=f(()=>{wI()});var di,pi,Ud=f(()=>{oi();xx();di=On("ledger",e=>({dir:".jucie/ledger",defaultRoots:{},setup(t){let r=e("state"),{put:n,flush:o}=t.buffered(),s=r.ledger.addLedgerListener(a=>{for(let[c,l,,u]of a)c===ci&&n(l,u)});return()=>{o(),s()}}})),pi=On("tombstones",e=>({dir:".jucie/ledger",defaultRoots:{},setup(t){let r=e("state"),{put:n,flush:o}=t.buffered(),s=r.ledger.addLedgerListener(a=>{for(let[c,l,,u]of a)c===gc&&n(l,u)});return()=>{o(),s()}}}))});var fi,mi,hi,qd=f(()=>{oi();qy();fi=On("nodes",e=>({dir:"src/sceneGraph",defaultRoots:{app:_o,temp:_o,components:_o},setup(t){let r=e("state"),{put:n,flush:o}=t.buffered(),s=r.matcher.createMatcher(["nodes"],async a=>{if(a)for(let[c,l]of Object.entries(a))l?n(c,l):await t.remove(c)});return()=>{o(),s()}}})),mi=On("animations",e=>({dir:"src/sceneGraph",defaultRoots:{},setup(t){let r=e("state"),{put:n,flush:o}=t.buffered(),s=r.matcher.createMatcher(["animations"],async a=>{if(a)for(let[c,l]of Object.entries(a))l?n(c,l):await t.remove(c)});return()=>{o(),s()}}})),hi=On("tokens",e=>({dir:"src/sceneGraph",defaultRoots:{},setup(t){let r=e("state"),{put:n,flush:o}=t.buffered(),s=r.matcher.createMatcher(["tokens"],async a=>{if(a)for(let[c,l]of Object.entries(a))l?n(c,l):await t.remove(c)});return()=>{o(),s()}}}))});import{ServiceProvider as h6}from"@jucie.io/engine";import{readFile as $c,writeFile as _x,readdir as g6,cp as y6,mkdir as Ec,stat as x6,unlink as _6}from"fs/promises";import{join as Po,relative as v6,extname as w6,basename as Hd,dirname as b6}from"path";import{existsSync as vx}from"fs";import{watch as S6}from"chokidar";import{glob as k6}from"glob";import{createHash as $6}from"crypto";import E6 from"image-size";var dn,pn,gi,Nc,yi,qe,Bd,Ro,bI=f(()=>{Bd=class Bd extends h6{constructor(){super(...arguments);k(this,dn,null);k(this,pn,new Map);k(this,gi,new Set);k(this,Nc,new Set);k(this,yi,new Set);k(this,qe,null)}initialize(){this.validateConfig()}actions(){return{copyAssets:()=>this.copyAssets(),processHtml:()=>this.processHtml(),build:r=>this.build(r),watch:()=>this.watch(),scanDirectory:r=>this.scanDirectory(r),watchDirectory:r=>this.watchDirectory(r),stopWatching:()=>this.stopWatching(),parseAssetFile:r=>this.parseAssetFile(r),saveUploadedFile:(r,n)=>this.saveUploadedFile(r,n),deleteAsset:r=>this.deleteAsset(r),generateHash:r=>this.generateHash(r),getAllAssets:()=>this.inject("state")?.get(["assets"])}}validateConfig(){let{projectRoot:r,outdir:n}=this.config;if(!r)throw new Error("[StaticAssets] projectRoot is required in config");if(!n)throw new Error("[StaticAssets] outdir is required in config");console.log("[StaticAssets] Service initialized"),console.log(` Project root: ${r}`),console.log(` Output directory: ${n}`)}async copyAssets(){let{assets:r,outdir:n}=this.config;console.log(`
23
- \u{1F4CB} Copying static assets...`);try{if(!r||!vx(r))return console.log(" \u26A0\uFE0F No assets directory found, skipping asset copy"),{success:!0,fileCount:0,skipped:!0};console.log(` Source: ${r}`);let o=Po(n,"assets");await Ec(o,{recursive:!0}),console.log(` Target: ${o}`),console.log(" Copying files..."),await y6(r,o,{recursive:!0,force:!0,errorOnExist:!1});let s=await this.countFiles(o);return console.log(` \u2705 Copied ${s} asset file(s)`),{success:!0,fileCount:s,source:r,target:o}}catch(o){throw console.error(" \u274C Failed to copy assets:",o.message),new Error(`[StaticAssets] Asset copy failed: ${o.message}`)}}async processHtml({fontLinks:r=""}={}){let{projectRoot:n,outdir:o,name:s}=this.config,a=this.config.htmlTemplate||Po(n,"index.html");console.log(`
24
- \u{1F4C4} Processing HTML template...`),console.log(` Template: ${a}`);try{if(!vx(a))return console.log(" \u26A0\uFE0F Template not found, creating default HTML"),await this.createDefaultHtml(o,s,{fontLinks:r});console.log(" Reading template...");let c=await $c(a,"utf8");console.log(" Processing template variables..."),c=this.processTemplate(c,this.config),console.log(" Injecting meta tags..."),c=this.injectMetaTags(c,this.config),r&&(console.log(" Injecting font links..."),c=this.injectFontLinks(c,r)),console.log(" Validating HTML structure..."),this.validateHtml(c);let l=Po(o,"index.html");return await Ec(o,{recursive:!0}),await _x(l,c,"utf8"),console.log(` \u2705 HTML processed and written to ${l}`),{success:!0,usedDefault:!1,outputPath:l,templatePath:a}}catch(c){throw console.error(" \u274C Failed to process HTML:",c.message),new Error(`[StaticAssets] HTML processing failed: ${c.message}`)}}processTemplate(r,n){let o={PROJECT_NAME:n.name||"Jucie App",TITLE:n.html?.title||n.title||n.name||"Jucie App",DESCRIPTION:n.html?.description||n.description||"",FRAMEWORK:n.framework||"react",MODE:n.env||"production",BASE_URL:n.baseUrl||"/",LANG:n.html?.lang||"en",THEME_COLOR:n.html?.themeColor||"#000000"},s=r;for(let[a,c]of Object.entries(o))s=s.replace(new RegExp(`%${a}%`,"g"),c);for(let[a,c]of Object.entries(o))s=s.replace(new RegExp(`\\{\\{${a}\\}\\}`,"g"),c);return s}injectMetaTags(r,n){let{html:o={}}=n,s=[];if((o.description||n.description)&&s.push(`<meta name="description" content="${o.description||n.description}" />`),o.themeColor&&s.push(`<meta name="theme-color" content="${o.themeColor}" />`),o.meta&&Array.isArray(o.meta))for(let a of o.meta){let c=Object.entries(a).map(([l,u])=>`${l}="${u}"`).join(" ");s.push(`<meta ${c} />`)}if(s.length>0&&!r.includes("<!-- meta-injected -->")){let a=s.join(`
25
- `);r=r.replace("</head>",` ${a}
26
- <!-- meta-injected -->
27
- </head>`)}return r}injectFontLinks(r,n){if(!n||r.includes("<!-- fonts-injected -->"))return r;let o=n.split(`
28
- `).map(s=>` ${s}`).join(`
29
- `);return r.replace("</head>",`${o}
30
- <!-- fonts-injected -->
31
- </head>`)}validateHtml(r){let n=[{pattern:/<div[^>]*id=["']app["']/,message:'Missing <div id="app"></div>'},{pattern:/type=["']module["']/,message:"Missing module script tag"},{pattern:/src=["']\/main\.js["']/,message:"Missing main.js reference"}];for(let{pattern:o,message:s}of n)o.test(r)||console.warn(` \u26A0\uFE0F ${s}`)}async createDefaultHtml(r,n,{fontLinks:o=""}={}){let{name:s,html:a={}}=this.config,c=o?`${o.split(`
32
- `).map(u=>` ${u}`).join(`
33
- `)}
34
- <!-- fonts-injected -->
35
- `:"",l=`<!DOCTYPE html>
36
- <html lang="${a.lang||"en"}">
14
+ `:"")}async listBranchNames(){let r=await(await k(this,hn,Ko).call(this)).listKeys(),n=`${y(this,wr)}/index-`,o=".jsonl";return r.filter(s=>s.startsWith(n)&&s.endsWith(o)).map(s=>s.slice(n.length,-o.length))}async deleteBranchIndex(t){let r=await k(this,hn,Ko).call(this),n=`${y(this,wr)}/index-${t}.jsonl`;await r.exists(n)&&await r.delete(n)}async garbageCollect(t={dryRun:!1}){let r=await k(this,hn,Ko).call(this),n=y(this,nr).toObject(),o=Object.entries(n).filter(([,u])=>u!=null);if(!t.dryRun){let u=o.map(([d,p])=>JSON.stringify({[d]:p})).join(`
15
+ `);await r.write(y(this,qr),u?u+`
16
+ `:"")}let s=await this.listBranchNames(),a=new Set;for(let u of s){let d=await k(this,Ui,ef).call(this,`${y(this,wr)}/index-${u}.jsonl`);for(let p of d.trim().split(`
17
+ `).filter(Boolean))try{let m=JSON.parse(p);Object.values(m).forEach(h=>{h&&a.add(h)})}catch{}}let l=[...y(this,rr).keys()].filter(u=>!a.has(u));if(!t.dryRun&&l.length>0){for(let d of l)y(this,rr).delete(d);let u=[...y(this,rr).entries()].map(([d,p])=>GO(d,p)).join(`
18
+ `);await r.write(y(this,Xo),u?u+`
19
+ `:"")}return{deleted:l.length,kept:y(this,rr).size}}};Yo=new WeakMap,wr=new WeakMap,Kc=new WeakMap,Li=new WeakMap,Xo=new WeakMap,qr=new WeakMap,rr=new WeakMap,nr=new WeakMap,Yc=new WeakMap,Fi=new WeakMap,hn=new WeakSet,Ko=i(async function(){return y(this,Yc).call(this,y(this,Fi))},"#store"),Qo=new WeakSet,Jc=i(async function(t,r){let n=await k(this,hn,Ko).call(this);if(typeof n.append=="function"){await n.append(t,r);return}let o=await n.exists(t)?await n.read(t):"",s=typeof o=="string"?o:String(o??"");await n.write(t,s+r)},"#append"),Ui=new WeakSet,ef=i(async function(t){let r=await k(this,hn,Ko).call(this);if(!await r.exists(t))return"";let n=await r.read(t);return n==null?"":typeof n=="string"?n:String(n)},"#softRead"),Q_=new WeakSet,mH=i(async function(t,r){!t||!r||y(this,nr).pointsTo(t,r)||(y(this,nr).set(t,r),await k(this,Qo,Jc).call(this,y(this,qr),JSON.stringify({[t]:r})+`
20
+ `))},"#setPointer"),rf=new WeakSet,WO=i(async function(t){t&&(y(this,nr).delete(t),await k(this,Qo,Jc).call(this,y(this,qr),JSON.stringify({[t]:null})+`
21
+ `))},"#deletePointer"),i(ev,"CASNamespace");tf=ev});import{createDefinition as hH}from"@jucie.io/engine";var tv,Xn,rv=f(()=>{tv="CAS_CONFIG",Xn=hH(tv,[Object])});function KO(e){if(!e||typeof e!="object"||Array.isArray(e))throw new Error("CAS config.namespaces must be an object keyed by namespace name");return Object.entries(e).map(([t,r={}])=>{if(!t)throw new Error("CAS namespace config requires a name");if(r&&typeof r=="object"&&!Array.isArray(r)){let{name:n,...o}=r;if(n&&n!==t)throw new Error(`CAS namespace key "${t}" conflicts with opts.name "${n}"`);return{name:t,...o}}return{name:t}})}function YO(e){if(!e||typeof e!="object"||Array.isArray(e))throw new Error("CAS namespace config must be a plain object with a name");if(!e.name||typeof e.name!="string")throw new Error("CAS namespace config requires a name");return e}var XO=f(()=>{i(KO,"parseNamespaces");i(YO,"parseNamespaceObject")});import{ServiceProvider as gH,definitionType as yH}from"@jucie.io/engine";import{Storage as xH}from"@jucie.io/engine-storage";import{LocalProvider as QO}from"@jucie.io/engine-storage/providers/local";var nv,br,lt,el,tl,qi,Bi,Qn,rl,nl,ov,sf,eA,ol,sv,sl,iv,Hi,nf,es,Xc,ts,Qc,Vi,of,il,av,af,tA,cf,gn,rA=f(()=>{Qp();JO();rv();XO();nv="branches.json",cf=class cf extends gH{constructor(){super(...arguments);$(this,nl);$(this,sf);$(this,ol);$(this,sl);$(this,Hi);$(this,es);$(this,ts);$(this,Vi);$(this,il);$(this,af);$(this,br,"main");$(this,lt,new Map);$(this,el,new Map);$(this,tl,new Set);$(this,qi,[]);$(this,Bi,null);$(this,Qn,null);$(this,rl,!1)}initialize(){O(this,br,this.config.branch||"main");let r=KO(this.config.namespaces??{});for(let n of r)k(this,es,Xc).call(this,n);this.config.configs?.length&&k(this,nl,ov).call(this,...this.config.configs)}actions(){return{generateCID:r=>Gc(r),namespace:(r,n)=>this.namespace(r,n),load:()=>this.load(),put:(r,n,o)=>this.put(r,n,o),remove:(r,n)=>this.remove(r,n),listNamespaces:()=>this.listNamespaces(),garbageCollect:r=>this.runGarbageCollection(r),createBranch:(r,n)=>this.createBranch(r,n),switchBranch:r=>this.switchBranch(r),listBranches:()=>this.listBranches(),getCurrentBranch:()=>y(this,br),deleteBranch:r=>this.deleteBranch(r),use:(...r)=>k(this,nl,ov).call(this,...r),setup:()=>this.runSetup(),dispose:()=>k(this,sl,iv).call(this)}}listNamespaces(){return[...y(this,lt).keys()]}runSetup(){for(let[r,n]of y(this,el))k(this,ol,sv).call(this,r,n);return{dispose:()=>k(this,sl,iv).call(this)}}async put(r,n,o){await k(this,Hi,nf).call(this,r).put(n,o)}async remove(r,n){await k(this,Hi,nf).call(this,r).remove(n)}async namespace(r,n={}){if(!r||typeof r!="string")throw new Error("CAS.namespace requires a name string");if(y(this,lt).has(r))return r;if(k(this,es,Xc).call(this,{name:r,...n}),y(this,rl)){let s=await y(this,lt).get(r).loadData();return{name:r,data:s}}return r}async load(){console.time("\u23F1\uFE0F Total load");try{await k(this,ts,Qc).call(this);for(let n of y(this,lt).values())await n.loadData();await this.runGarbageCollection();let r={};for(let n of y(this,lt).values())r[n.name]=await n.loadData();return O(this,rl,!0),console.timeEnd("\u23F1\uFE0F Total load"),r}catch(r){throw console.warn("\u26A0\uFE0F Could not load CAS data:",r.message),r}}async createBranch(r,n){if(!r||r.includes("/")||r.includes("\\"))throw new Error(`Invalid branch name: ${r}`);for(let o of y(this,lt).values())await o.createBranch(r);return await k(this,af,tA).call(this,r,{displayName:n||r,created:new Date().toISOString(),createdFrom:y(this,br)}),console.log(`\u{1F33F} Created branch '${r}' from '${y(this,br)}'`),r}async switchBranch(r){O(this,br,r);for(let n of y(this,lt).values())n.switchBranch(r);return console.log(`\u{1F500} Switched to branch '${r}'`),r}async listBranches(){let r=[...y(this,lt).values()][0];if(!r)return[];let n=await r.listBranchNames(),o=await k(this,Vi,of).call(this);return n.map(s=>({name:s,current:s===y(this,br),...o[s]}))}async deleteBranch(r){if(r===y(this,br))throw new Error(`Cannot delete current branch '${r}'`);for(let o of y(this,lt).values())await o.deleteBranchIndex(r);let n=await k(this,Vi,of).call(this);return delete n[r],await k(this,il,av).call(this,n),console.log(`\u{1F5D1}\uFE0F Deleted branch '${r}'`),r}async runGarbageCollection(r={dryRun:!1}){console.log("\u{1F9F9} Starting garbage collection...");let n={};for(let o of y(this,lt).values())n[o.name]=await o.garbageCollect(r),console.log(`\u2705 GC [${o.name}]: removed ${n[o.name].deleted}, kept ${n[o.name].kept}`);return n}};br=new WeakMap,lt=new WeakMap,el=new WeakMap,tl=new WeakMap,qi=new WeakMap,Bi=new WeakMap,Qn=new WeakMap,rl=new WeakMap,nl=new WeakSet,ov=i(function(...r){for(let n of r){let o=yH(n);if(o===tv){k(this,sf,eA).call(this,n);continue}if(n&&typeof n=="object"){k(this,es,Xc).call(this,YO(n));continue}throw new Error(`CAS.use() expects casConfig definitions or namespace objects, got "${o??typeof n}"`)}},"#useConfigs"),sf=new WeakSet,eA=i(function(r){let n=r._name;if(!n||typeof n!="string")throw new Error("casConfig definition requires a name (first argument to defineCasConfig)");let o=r(this.inject.bind(this));y(this,el).set(n,o),k(this,es,Xc).call(this,{name:n,dir:o.dir,defaultRoots:o.defaultRoots??{},storage:o.storage}),k(this,ol,sv).call(this,n,o)},"#resolveDefinition"),ol=new WeakSet,sv=i(function(r,n){if(typeof n.setup!="function"||y(this,tl).has(r))return;let o={put:(a,c)=>this.put(r,a,c),remove:a=>this.remove(r,a),buffered:a=>k(this,Hi,nf).call(this,r).buffered(a)},s=n.setup(o);typeof s=="function"&&y(this,qi).push(s),y(this,tl).add(r)},"#runSetupFor"),sl=new WeakSet,iv=i(function(){for(let r of y(this,qi))r();O(this,qi,[])},"#disposeAll"),Hi=new WeakSet,nf=i(function(r){let n=y(this,lt).get(r);if(!n)throw new Error(`CAS namespace "${r}" is not registered`);return n},"#getNamespace"),es=new WeakSet,Xc=i(function({name:r,dir:n,defaultRoots:o={},storage:s}={}){if(!r)throw new Error("CAS namespace config requires a name");if(y(this,lt).has(r))return;let a=new tf({name:r,dir:n,defaultRoots:o,branch:y(this,br),storage:s,getStore:c=>k(this,ts,Qc).call(this,c??s)});y(this,lt).set(r,a)},"#registerSync"),ts=new WeakSet,Qc=i(async function(r){let n=r??null;if(!n&&y(this,Bi))return y(this,Bi);if(!n&&y(this,Qn))return y(this,Qn);let o=i(async()=>{let s=this.inject("storage");if(!s)throw new Error("CAS requires the Storage service. Install Storage and configure storage.");let a=n??this.config.storage;!a&&this.config.sceneGraph&&(a={name:"scene",provider:QO,root:this.config.sceneGraph});let c;if(typeof a=="string")c=s.use(a);else if(a&&typeof a=="object"){let{name:l="scene",provider:u=QO,mode:d="path",...p}=a;s.has(l)||await s.create(l,u,{...p,mode:d}),c=s.use(l)}else c=s.use();return n||O(this,Bi,c),c},"resolve");return n?o():(O(this,Qn,o().catch(s=>{throw O(this,Qn,null),s})),y(this,Qn))},"#ensureStore"),Vi=new WeakSet,of=i(async function(){try{let r=await k(this,ts,Qc).call(this);if(!await r.exists(nv))return{};let n=await r.read(nv),o=typeof n=="string"?n:String(n);return JSON.parse(o)}catch{return{}}},"#loadBranchesMetadata"),il=new WeakSet,av=i(async function(r){await(await k(this,ts,Qc).call(this)).write(nv,JSON.stringify(r,null,2))},"#saveBranchesMetadata"),af=new WeakSet,tA=i(async function(r,n){let o=await k(this,Vi,of).call(this);o[r]={...o[r],...n},await k(this,il,av).call(this,o)},"#updateBranchMetadata"),i(cf,"CAS"),_e(cf,"manifest",{name:"CAS",namespace:"cas",dependencies:[xH]});gn=cf});var Gi=f(()=>{rA();Qp();rv()});import{ServiceProvider as _H}from"@jucie.io/engine";import{watch as vH}from"chokidar";import{readFile as wH,writeFile as bH,mkdir as SH,access as kH,constants as $H,unlink as EH}from"fs/promises";import{glob as NH}from"glob";import Wi from"path";import*as eo from"recast";import{createHash as TH}from"crypto";import{parse as nA}from"@babel/parser";var Te,oA,Ji,al,rs,yn,De,xn,or,ns,Ki,lf,cl,cv,uf,_n,sA=f(()=>{({builders:Te,namedTypes:oA}=eo.types),uf=class uf extends _H{constructor(){super(...arguments);$(this,Ki);$(this,cl);$(this,Ji,new Set);$(this,al,new Set);$(this,rs,new Set);$(this,yn,null);$(this,De,null);$(this,xn,new Map);$(this,or,new Map);$(this,ns,[])}actions(){return{start:()=>this.start(),build:()=>this.build(),scanDirectory:r=>this.scanDirectory(r),watchDirectory:r=>this.watchDirectory(r),stopWatching:()=>this.stopWatching(),parse:r=>this.parse(r),generate:r=>this.generate(r),generateHash:r=>this.generateHash(r),parseAndStore:(r,n)=>this.parseAndStore(r,n),write:(r,n)=>this.write(r,n),writeAll:r=>this.writeAll(r),writeFile:(r,n)=>this.writeFile(r,n),removeFile:r=>this.removeFile(r),onChange:r=>(y(this,ns).push(r),()=>{O(this,ns,y(this,ns).filter(n=>n!==r))}),getStore:r=>y(this,or).get(r),getAllStores:()=>Object.fromEntries(y(this,or))}}async generateHash(r){let n=TH("sha256"),o=r;return o.charCodeAt(0)===65279&&(o=o.slice(1)),o=o.replace(/\r\n/g,`
22
+ `),o=o.normalize("NFC"),n.update(o),n.digest("hex")}async start(r){try{if(O(this,De,r||this.config.stores),!y(this,De))throw new Error("StoreParser start error: Base directory not defined");return await this.scanDirectory(y(this,De)),this.watchDirectory(y(this,De)),this}catch(n){return console.error("StoreParser start error",n),null}}async build(){return O(this,De,this.config.stores),await this.scanDirectory(y(this,De)),Object.fromEntries(y(this,or))}async scanDirectory(r){O(this,De,r||this.config.stores),console.log("\u{1F50D} Scanning directory:",y(this,De));let n=await this.findAllStoreFiles(y(this,De));for(let s of n){let a=this.extractStoreName(s,y(this,De));await k(this,cl,cv).call(this,s,a)}console.log(`\u{1F4C2} Scanned ${n.length} store file(s)`);let o=Object.fromEntries(y(this,or));return k(this,Ki,lf).call(this,"loaded",{stores:o}),o}async findAllStoreFiles(r){return NH.sync(`${r}/**/*.{js,mjs,ts}`,{ignore:"**/node_modules/**"})}watchDirectory(r){return O(this,De,r||this.config.stores),console.log("\u{1F50D} Watching directory:",y(this,De)),O(this,yn,vH(y(this,De),{ignored:/(^|[\/\\])\../,persistent:!0,ignoreInitial:!1,awaitWriteFinish:{stabilityThreshold:100,pollInterval:50}})),y(this,yn).on("add",n=>this.handleFileAdded(n)).on("change",n=>this.handleFileChanged(n)).on("unlink",n=>this.handleFileDeleted(n)),console.log(`\u{1F441}\uFE0F Watching directory: ${r}`),y(this,yn)}async handleFileAdded(r){if(console.log("\u{1F50D} File added:",r),!this.isValidStoreFile(r))return;let n=this.extractStoreName(r,y(this,De));if(y(this,al).has(n)){y(this,al).delete(n);return}else await this.parseAndStore(r,n);console.log(`\u2795 Added store: ${n}`)}async handleFileChanged(r){if(console.log("\u{1F50D} File changed:",r),!this.isValidStoreFile(r))return;let n=this.extractStoreName(r,y(this,De));y(this,Ji).has(n)?y(this,Ji).delete(n):await this.parseAndStore(r,n),console.log(`\u{1F504} Updated store: ${n}`)}handleFileDeleted(r){console.log("\u{1F50D} File deleted:",r);let n=this.extractStoreName(r,y(this,De));if(y(this,xn).delete(n),y(this,rs).has(n)){y(this,rs).delete(n);return}y(this,or).delete(n),k(this,Ki,lf).call(this,"deleted",{name:n}),console.log(`\u2796 Removed store: ${n}`)}async parseAndStore(r,n){let o=await k(this,cl,cv).call(this,r,n);return o?(k(this,Ki,lf).call(this,o.isNew?"added":"changed",{name:n,store:o.storeData}),o.storeData):null}extractStoreName(r,n){return Wi.relative(n,r).replace(/\.(js|mjs|ts)$/,"").replace(/\\/g,"/")}isValidStoreFile(r){let n=[".js",".mjs",".ts"],o=Wi.extname(r);return n.includes(o)}stopWatching(){y(this,yn)&&(y(this,yn).close(),O(this,yn,null),console.log("\u{1F6D1} Store watcher stopped"))}async fileExists(r){try{return await kH(Wi.join(y(this,De),`${r}.js`),$H.F_OK),!0}catch{return!1}}async write(r,n){let o=this.generate(n);await this.writeFile(r,o),y(this,or).set(r,n)}async writeAll(r){if(r)for(let[n,o]of Object.entries(r))try{o?await this.write(n,o):await this.removeFile(n)}catch(s){console.error(`\u26A0\uFE0F Skipped writing store "${n}": ${s.message}`)}}async writeFile(r,n){try{if(!r||!y(this,De))return;let o=await this.generateHash(n),s=y(this,xn).get(r);if(o===s){console.log(`\u23ED\uFE0F Skipped writing ${r} (no content change)`);return}let a=Wi.join(y(this,De),`${r}.js`);console.log("\u{1F50D} Writing store file to:",a),y(this,Ji).add(r),await SH(Wi.dirname(a),{recursive:!0}),await bH(a,n,"utf8"),y(this,xn).set(r,o),console.log(`\u{1F4BE} Wrote store file: ${r}`)}catch(o){throw console.trace(`Failed to write store file: ${r}:`,o.message),new Error(`Failed to write store file: ${r}: ${o.message}`)}}async removeFile(r){if(!r||!y(this,De))return;let n=Wi.join(y(this,De),`${r}.js`);try{y(this,rs).add(r),await EH(n),y(this,xn).delete(r),y(this,or).delete(r),console.log(`\u{1F5D1}\uFE0F Removed store file: ${r}`)}catch(o){throw y(this,rs).delete(r),console.error(`Failed to remove store file: ${r}:`,o.message),new Error(`Failed to remove store file: ${r}: ${o.message}`)}}parse(r){let n={};try{let s=eo.parse(r,{parser:{parse(c){return nA(c,{sourceType:"module",plugins:["optionalChaining","nullishCoalescingOperator"]})}}}).program.body.find(c=>oA.ExportDefaultDeclaration.check(c));if(!s||!oA.ObjectExpression.check(s.declaration))throw new Error("No export default object found");return s.declaration.properties.forEach(c=>{if(!c||c.type!=="ObjectProperty")return;let l=c.key.name,u=c.value;l==="state"&&c.value.type==="ObjectExpression"?n.state=this.extractState(u):l==="computed"&&c.value.type==="ObjectExpression"?n.computed=this.extractFunctions(u):l==="actions"&&c.value.type==="ObjectExpression"&&(n.actions=this.extractFunctions(u))}),n}catch(o){throw console.error("Failed to parse store code:",o.message),new Error(`Invalid store code: ${o.message}`)}}generate(r){try{let n=this.buildAST(r);return eo.print(n,{tabWidth:2,quote:"single",trailingComma:!1}).code}catch(n){throw console.error("Failed to generate store code:",n.message),new Error(`Code generation failed: ${n.message}`)}}buildAST(r){let n=[];if(r.state?.length>0){let a=this.buildStateObject(r.state);n.push(Te.property("init",Te.identifier("state"),a))}if(r.computed?.length>0){let a=this.buildFunctionsObject(r.computed);n.push(Te.property("init",Te.identifier("computed"),a))}if(r.actions?.length>0){let a=this.buildFunctionsObject(r.actions);n.push(Te.property("init",Te.identifier("actions"),a))}let o=Te.objectExpression(n),s=Te.exportDefaultDeclaration(o);return Te.program([s])}buildStateObject(r){let n=r.map(o=>{let s=this.valueToASTNode(o.value),a=[Te.property("init",Te.identifier("type"),Te.literal(o.type)),Te.property("init",Te.identifier("default"),s)],c=Te.objectExpression(a);return Te.property("init",Te.identifier(o.key),c)});return Te.objectExpression(n)}valueToASTNode(r){if(Array.isArray(r))return Te.arrayExpression(r.map(n=>this.valueToASTNode(n)));if(typeof r=="object"&&r!==null){let n=Object.entries(r).map(([o,s])=>Te.property("init",Te.identifier(o),this.valueToASTNode(s)));return Te.objectExpression(n)}else return Te.literal(r)}buildFunctionsObject(r){let n=r.map(o=>{let a=eo.parse(`(${o.code})`,{parser:{parse(c){return nA(c,{sourceType:"module",plugins:["optionalChaining","nullishCoalescingOperator"]})}}}).program.body[0].expression;return a.extra&&(a.extra.parenthesized=!1),Te.property("init",Te.identifier(o.name),a)});return Te.objectExpression(n)}extractState(r){return r.properties.map(n=>{let o=n.key.name,s=n.value,a="string",c="";return s.type==="ObjectExpression"&&s.properties.forEach(l=>{l.key.name==="type"&&(l.value.type==="StringLiteral"||l.value.type==="Literal")&&(a=l.value.value),l.key.name==="default"&&(c=this.getLiteralValue(l.value))}),{key:o,type:a,value:c}})}extractFunctions(r){return r.properties.map(n=>{let o=n.key.name,s=n.value,a=eo.print(s).code;return{name:o,code:a}})}getLiteralValue(r){if(r.type==="StringLiteral"||r.type==="NumericLiteral"||r.type==="BooleanLiteral"||r.type==="Literal")return r.value;if(r.type==="NullLiteral")return null;if(r.type==="ArrayExpression")return r.elements.map(n=>this.getLiteralValue(n));if(r.type==="ObjectExpression"){let n={};return r.properties.forEach(o=>{if(o.type==="ObjectProperty"||o.type==="Property"){let s=o.key.name||o.key.value;n[s]=this.getLiteralValue(o.value)}}),n}return""}};Ji=new WeakMap,al=new WeakMap,rs=new WeakMap,yn=new WeakMap,De=new WeakMap,xn=new WeakMap,or=new WeakMap,ns=new WeakMap,Ki=new WeakSet,lf=i(function(r,n){for(let o of y(this,ns))o({type:r,...n})},"#emit"),cl=new WeakSet,cv=i(async function(r,n){try{let o=await wH(r,"utf8"),s=await this.generateHash(o),a=y(this,xn).get(n);if(s===a)return console.log(`\u23ED\uFE0F Skipped parsing ${n} (no content change)`),null;let c=this.parse(o),l=!y(this,or).has(n);return y(this,or).set(n,c),y(this,xn).set(n,s),{storeData:c,isNew:l}}catch(o){return console.error(` \u2717 Failed to parse ${n}:`,o.message),null}},"#parseFile"),i(uf,"StoreParser"),_e(uf,"manifest",{name:"StoreParser",namespace:"storeParser"});_n=uf});var df=f(()=>{sA()});import{GLOBAL_TAG as lv}from"@jucie.io/state/lib/TOKENS.js";import{createChange as zH}from"@jucie.io/state/lib/change.js";import{Plugin as CH}from"@jucie.io/state/Plugin";import{traverse as IH}from"@jucie.io/state/lib/tree/traverse.js";import{encodePath as iA,decodeAddress as uv}from"@jucie.io/state/lib/pathEncoder.js";import{createMarker as aA,dispatch as dv}from"@jucie.io/state/lib/marker.js";var PH,OH,ll,Xi,dl,Be,Ke,Ft,Sr,vn,sr,os,ss,wn,is,bn,as,mf,cA,hf,lA,fl,pv,ml,fv,hl,mv,cs,ul,gf,uA,gl,hv,yf,dA,xf,pA,_f,fA,yl,gv,xl,yv,Qi,pf,vf,mA,_l,xv,ea,ff,wf,hA,Yi,pl,gA=f(()=>{PH=typeof window<"u"&&typeof window.document<"u",OH=typeof process<"u"&&process.versions?.node,ll=0,Xi="entry",dl="tombstone",Yi=class Yi extends CH{constructor(){super(...arguments);$(this,mf);$(this,hf);$(this,fl);$(this,ml);$(this,hl);$(this,cs);$(this,gf);$(this,gl);$(this,yf);$(this,xf);$(this,_f);$(this,yl);$(this,xl);$(this,Qi);$(this,vf);$(this,_l);$(this,ea);$(this,wf);$(this,Be,new Map);$(this,Ke,new Map);$(this,Ft,new Set);$(this,Sr,[]);$(this,vn,!1);$(this,sr,!1);$(this,os,null);$(this,ss,void 0);$(this,wn,new Set);$(this,is,!1);$(this,bn,new Set);$(this,as,!1);_e(this,"onTombstoneConflict",null)}initialize(r,n){O(this,vn,!1),O(this,os,n.actorId??n.userId??null),O(this,ss,Date.now())}get batchSize(){return this.options.batchSize}actions(){return{addChangeListener:r=>this.addChangeListener(r),removeChangeListener:r=>this.removeChangeListener(r),addLedgerListener:r=>this.addLedgerListener(r),removeLedgerListener:r=>this.removeLedgerListener(r),kill:(...r)=>this.kill(r),resurrect:(...r)=>this.resurrect(r),snapshot:()=>this.snapshot(),hydrate:r=>this.hydrate(r),merge:r=>this.merge(r),apply:r=>this.apply(r),getStats:()=>this.getStats()}}onStateChange(r,n){y(this,sr)||(dv(r,{global:o=>y(this,Sr).push({marker:o,change:n}),path:o=>y(this,Sr).push({marker:o,change:n}),ephemeral:()=>{}}),k(this,yl,gv).call(this))}addChangeListener(r){return y(this,wn).add(r),y(this,wn).size>0&&O(this,is,!0),()=>this.removeChangeListener(r)}removeChangeListener(r){y(this,wn).delete(r),y(this,wn).size===0&&O(this,is,!1)}addLedgerListener(r){return y(this,bn).add(r),y(this,bn).size>0&&O(this,as,!0),()=>this.removeLedgerListener(r)}removeLedgerListener(r){y(this,bn).delete(r),y(this,bn).size===0&&O(this,as,!1)}getEntry(r){return y(this,Be).get(iA(r))}getTombstone(r){return y(this,Ke).get(iA(r))}snapshot(){return{state:this.state.get(),ledger:Object.fromEntries(y(this,Be)),tombstones:Object.fromEntries(y(this,Ke))}}hydrate({state:r,ledger:n={},tombstones:o={}}={}){O(this,sr,!0);try{O(this,Sr,[]),r!==void 0&&this.state.load(r),O(this,Be,k(this,cs,ul).call(this,n)),O(this,Ke,k(this,cs,ul).call(this,o)),k(this,yf,dA).call(this),k(this,Qi,pf).call(this),O(this,Sr,[])}finally{O(this,sr,!1)}return this}apply(r){if(!r?.length)return[];let n=[],o=[];O(this,sr,!0);try{for(let s of r){let[a,c,l,u]=s;if(!(!c||!a)){if(a===dl){y(this,Ke).set(c,u),y(this,Ft).add(c),k(this,hl,mv).call(this,c),l&&o.push(l),n.push(s);continue}a!==Xi||!u||k(this,gl,hv).call(this,c,u)&&(y(this,Be).set(c,u),l&&o.push(l),n.push(s))}}o.length>0&&this.state.apply(o),k(this,Qi,pf).call(this)}finally{O(this,sr,!1)}return n.length>0&&k(this,ea,ff).call(this,n),n}merge({state:r,ledger:n={},tombstones:o={}}={}){if(!r&&!n&&!o)return this.state;O(this,sr,!0);try{for(let[s,a]of k(this,cs,ul).call(this,n)){if(s===lv||uv(s)===lv||!k(this,gl,hv).call(this,s,a))continue;y(this,Be).set(s,a);let c=uv(s),l=r?IH(r,c):void 0;l!==void 0&&this.state.set(c,l)}for(let[s,a]of k(this,cs,ul).call(this,o)){if(!k(this,gf,uA).call(this,s,a))continue;let c=uv(s);this.state.remove(c),y(this,Ke).set(s,a),y(this,Ft).add(s)}k(this,Qi,pf).call(this)}finally{O(this,sr,!1)}return this.state}reset(){y(this,Be).clear(),y(this,Ke).clear(),y(this,Ft).clear(),O(this,Sr,[]),O(this,vn,!1),O(this,os,null),O(this,ss,Date.now()),y(this,wn).clear(),O(this,is,!1),y(this,bn).clear(),O(this,as,!1)}getStats(){return{entriesCount:y(this,Be).size,tombstonesCount:y(this,Ke).size,tombstoneIndexCount:y(this,Ft).size,changeQueueCount:y(this,Sr).length,isProcessing:y(this,vn),actorId:y(this,os),sessionEpoch:y(this,ss),globalClock:ll}}kill(r){let n=aA(r);return dv(n,{global:()=>{throw new Error("Cannot kill global state")},path:({path:o,address:s})=>{O(this,sr,!0);try{let a=this.state.remove(o),c=k(this,mf,cA).call(this,s,a),l=zH(n,"remove",void 0,a),u=[dl,s,l,c];return k(this,_l,xv).call(this,[u]),k(this,ea,ff).call(this,[u]),a}finally{O(this,sr,!1)}},error:o=>console.error(o)})}resurrect(r){try{let n=aA(r),o=k(this,hf,lA).call(this,n.address);if(!o)throw new Error(`No tombstone found for path: ${n.path.join(".")}`);let s=JSON.parse(o.data);return this.state.set(n.path,s),s}catch(n){console.error(n);return}}};Be=new WeakMap,Ke=new WeakMap,Ft=new WeakMap,Sr=new WeakMap,vn=new WeakMap,sr=new WeakMap,os=new WeakMap,ss=new WeakMap,wn=new WeakMap,is=new WeakMap,bn=new WeakMap,as=new WeakMap,mf=new WeakSet,cA=i(function(r,n){let o={data:JSON.stringify(n),timestamp:Date.now()};return y(this,Ke).set(r,o),y(this,Ft).add(r),k(this,hl,mv).call(this,r),k(this,vf,mA).call(this),o},"#createTombstone"),hf=new WeakSet,lA=i(function(r){let n=y(this,Ke).get(r);if(n)return y(this,Ke).delete(r),y(this,Ft).delete(r),n},"#removeTombstone"),fl=new WeakSet,pv=i(function(r,n){if(!r)return-1;if(!n)return 1;let[o,s,a,c]=r,[l,u,d,p]=n;return o!==l?o>l?1:-1:s!==u?s>u?1:-1:a!==d?a>d?1:-1:c!==p?String(c??"").localeCompare(String(p??"")):0},"#compareEntries"),ml=new WeakSet,fv=i(function(r){if(y(this,Ft).has(r))return!0;let n=r.length;for(;n=r.lastIndexOf(".",n-1),n!==-1;)if(y(this,Ft).has(r.slice(0,n)))return!0;return!1},"#isPathTombstoned"),hl=new WeakSet,mv=i(function(r){let n=[];for(let[o]of y(this,Be))(o===r||o.startsWith(r))&&n.push(o);for(let o of n)y(this,Be).delete(o)},"#removeEntriesUnderPath"),cs=new WeakSet,ul=i(function(r){return r?r instanceof Map?new Map(r):Array.isArray(r)?new Map(r):typeof r=="object"?new Map(Object.entries(r)):new Map:new Map},"#toMap"),gf=new WeakSet,uA=i(function(r,n){let o=y(this,Be).get(r),s=y(this,Ke).get(r);return!!(!s&&!o||s&&n.timestamp>s.timestamp||o&&!s)},"#shouldApplyTombstone"),gl=new WeakSet,hv=i(function(r,n){if(k(this,ml,fv).call(this,r))return!1;let o=y(this,Be).get(r);return k(this,fl,pv).call(this,n,o)>0},"#shouldApplyRemoteEntry"),yf=new WeakSet,dA=i(function(){y(this,Ft).clear();for(let[r]of y(this,Ke))y(this,Ft).add(r)},"#rebuildTombstoneIndexes"),xf=new WeakSet,pA=i(function(r){PH&&"requestIdleCallback"in window?window.requestIdleCallback(r,{timeout:50}):OH?setImmediate(r):setTimeout(r,0)},"#scheduleIdle"),_f=new WeakSet,fA=i(function(r){let n=!1;Promise.resolve().then(()=>{n||(n=!0,r())}),setTimeout(()=>{n||(n=!0,r())},0)},"#scheduleNextTick"),yl=new WeakSet,gv=i(function(){y(this,vn)||(O(this,vn,!0),k(this,_f,fA).call(this,()=>{let r=y(this,Sr).splice(0,this.options.batchSize||Yi.options.batchSize),n=[],o=[];for(let{marker:s,change:a}of r)dv(s,{global:()=>{let c=k(this,xl,yv).call(this,s.address);n.push([Xi,lv,a,c])},path:({path:c})=>{if(k(this,ml,fv).call(this,s.address)){o.push(c);return}let l=k(this,xl,yv).call(this,s.address);n.push([Xi,s.address,a,l])}});o.length>0&&k(this,xf,pA).call(this,()=>k(this,wf,hA).call(this,this.state,o)),k(this,_l,xv).call(this,n),k(this,ea,ff).call(this,n),O(this,vn,!1),y(this,Sr).length>0&&k(this,yl,gv).call(this)}))},"#scheduleRecord"),xl=new WeakSet,yv=i(function(r){let n=y(this,Be).get(r);y(this,Be).delete(r);let a=[(n?n[0]:0)+1,ll++,y(this,ss),y(this,os)];if(y(this,Be).set(r,a),y(this,Be).size>this.options.maxSize){let c=y(this,Be).size-this.options.maxSize,l=Array.from(y(this,Be).entries()).sort((u,d)=>k(this,fl,pv).call(this,u[1],d[1]));for(let u=0;u<c;u++)y(this,Be).delete(l[u][0])}return a},"#updateLedger"),Qi=new WeakSet,pf=i(function(){let r=-1;for(let n of y(this,Be).values())n&&n[1]>r&&(r=n[1]);ll=ll>r?ll+1:r+1},"#continueGlobalClock"),vf=new WeakSet,mA=i(function(){let o=Date.now();for(let[s,{timestamp:a}]of y(this,Ke))(y(this,Ke).size>1e3||o-a>2592e6)&&y(this,Ke).delete(s)},"#checkTombstoneSize"),_l=new WeakSet,xv=i(function(r){y(this,is)&&y(this,wn).forEach(n=>n(r))},"#callChangeListeners"),ea=new WeakSet,ff=i(function(r){y(this,as)&&y(this,bn).forEach(n=>n(r))},"#callLedgerListeners"),wf=new WeakSet,hA=i(function(r,n){for(let o of n)try{r.remove(o)}catch(s){console.warn(`Tombstone cleanup failed for path ${o.join(".")}:`,s.message)}},"#cleanupTombstoneConflicts"),_e(Yi,"name","ledger"),_e(Yi,"options",{actorId:null,userId:null,maxSize:1e4,batchSize:100}),_e(Yi,"empty",{ledger:[],tombstones:[]});pl=Yi});var _v=f(()=>{gA()});var ta,ra,bf=f(()=>{Gi();_v();ta=Xn("ledger",e=>({dir:".jucie/ledger",defaultRoots:{},setup(t){let r=e("state");if(!r.ledger)return;let{put:n,flush:o}=t.buffered(),s=r.ledger.addLedgerListener(a=>{for(let[c,l,,u]of a)c===Xi&&n(l,u)});return()=>{o(),s()}}})),ra=Xn("tombstones",e=>({dir:".jucie/ledger",defaultRoots:{},setup(t){let r=e("state");if(!r.ledger)return;let{put:n,flush:o}=t.buffered(),s=r.ledger.addLedgerListener(a=>{for(let[c,l,,u]of a)c===dl&&n(l,u)});return()=>{o(),s()}}}))});var na,oa,sa,Sf=f(()=>{Gi();F_();na=Xn("nodes",e=>({dir:"src/sceneGraph",defaultRoots:{app:Yn,temp:Yn,components:Yn},setup(t){let r=e("state"),{put:n,flush:o}=t.buffered(),s=r.matcher.createMatcher(["nodes"],async a=>{if(a)for(let[c,l]of Object.entries(a))l?n(c,l):await t.remove(c)});return()=>{o(),s()}}})),oa=Xn("animations",e=>({dir:"src/sceneGraph",defaultRoots:{},setup(t){let r=e("state"),{put:n,flush:o}=t.buffered(),s=r.matcher.createMatcher(["animations"],async a=>{if(a)for(let[c,l]of Object.entries(a))l?n(c,l):await t.remove(c)});return()=>{o(),s()}}})),sa=Xn("tokens",e=>({dir:"src/sceneGraph",defaultRoots:{},setup(t){let r=e("state"),{put:n,flush:o}=t.buffered(),s=r.matcher.createMatcher(["tokens"],async a=>{if(a)for(let[c,l]of Object.entries(a))l?n(c,l):await t.remove(c)});return()=>{o(),s()}}}))});import{ServiceProvider as AH}from"@jucie.io/engine";import{readFile as kf,writeFile as RH,mkdir as yA,stat as jH,unlink as DH}from"fs/promises";import{resolve as xA,sep as MH,relative as _A,extname as $f,basename as vl,dirname as vA}from"path";import{existsSync as wA}from"fs";import{watch as ZH}from"chokidar";import{glob as LH}from"glob";import{createHash as FH}from"crypto";import bA from"image-size";var Sn,kn,ia,Sl,aa,be,us,ds,$n,ls,ps,wl,Ut,kr,Ef,SA,Nf,bl,kA=f(()=>{Nf=class Nf extends AH{constructor(){super(...arguments);$(this,$n);$(this,ps);$(this,Ut);$(this,Ef);$(this,Sn,null);$(this,kn,new Map);$(this,ia,new Set);$(this,Sl,new Set);$(this,aa,new Set);$(this,be,null);$(this,us,null);$(this,ds,[])}initialize(){O(this,be,this.config.assets)}actions(){return{watch:r=>this.watch(r),scanDirectory:r=>this.scanDirectory(r),stopWatching:()=>this.stopWatching(),parseAssetFile:r=>this.parseAssetFile(r),saveUploadedFile:(r,n)=>this.saveUploadedFile(r,n),deleteAsset:r=>this.deleteAsset(r),checkFileExists:r=>this.checkFileExists(r),getNextAvailableName:r=>this.getNextAvailableName(r),generateHash:r=>this.generateHash(r),onChange:r=>(y(this,ds).push(r),()=>{O(this,ds,y(this,ds).filter(n=>n!==r))})}}async watch(r){O(this,be,r||this.config.assets),await this.scanDirectory(y(this,be)),this.config.watch&&this.watchDirectory(y(this,be))}async scanDirectory(r){O(this,be,r||this.config.assets);let n=await k(this,ps,wl).call(this);if(n)return k(this,Ef,SA).call(this,n);if(!wA(y(this,be)))return await yA(y(this,be),{recursive:!0}),k(this,Ut,kr).call(this,"loaded",{}),{};let o=this.findAllAssetFiles(y(this,be)),s={};for(let a of o)try{let c=await this.parseAssetFile(a);if(c){s[c.id]=c;let l=await kf(a),u=await this.generateHash(l);y(this,kn).set(a,u)}}catch(c){console.warn(` Failed to parse ${a}:`,c.message)}return k(this,Ut,kr).call(this,"loaded",s),s}findAllAssetFiles(r){return LH.sync(`${r}/**/*.*`,{ignore:["**/node_modules/**","**/.gitkeep","**/.*"],nodir:!0})}async parseAssetFile(r){try{y(this,be)||O(this,be,this.config.assets);let n=await jH(r),o=_A(y(this,be),r).replace(/\\/g,"/"),s=$f(r).slice(1),a=vl(r),c=await kf(r),l=await this.generateHash(c),u=this.getMimeType(s),d=this.getAssetType(s),p={id:o,name:a,path:o,hash:l,url:`/assets/${o}`,extension:s,size:n.size,mimeType:u,type:d,lastModified:n.mtime.toISOString()};if(d==="image")try{let m=bA(r);p.dimensions={width:m.width,height:m.height}}catch{}return p}catch(n){return console.error(` Error parsing asset file ${r}:`,n.message),null}}watchDirectory(r){return O(this,be,r||this.config.assets),O(this,Sn,ZH(y(this,be),{ignored:/(^|[\/\\])\../,persistent:!0,ignoreInitial:!0,awaitWriteFinish:{stabilityThreshold:100,pollInterval:50}})),y(this,Sn).on("add",n=>this.handleFileAdded(n)).on("change",n=>this.handleFileChanged(n)).on("unlink",n=>this.handleFileDeleted(n)),y(this,Sn)}async handleFileAdded(r){if(!this.isValidAssetFile(r))return;if(y(this,ia).has(r)){y(this,ia).delete(r);return}let n=await this.parseAssetFile(r);if(n){let o=await kf(r),s=await this.generateHash(o);y(this,kn).set(r,s),k(this,Ut,kr).call(this,"added",n)}}async handleFileChanged(r){if(!this.isValidAssetFile(r))return;if(y(this,Sl).has(r)){y(this,Sl).delete(r);return}let n=await kf(r),o=await this.generateHash(n),s=y(this,kn).get(r);if(o===s)return;let a=await this.parseAssetFile(r);a&&(y(this,kn).set(r,o),k(this,Ut,kr).call(this,"changed",a))}async handleFileDeleted(r){if(y(this,aa).has(r)){y(this,aa).delete(r);return}y(this,be)||O(this,be,this.config.assets);let n=_A(y(this,be),r).replace(/\\/g,"/");y(this,kn).delete(r),n&&!n.startsWith("..")&&k(this,Ut,kr).call(this,"deleted",{id:n,path:n})}async saveUploadedFile(r,n){y(this,be)||O(this,be,this.config.assets);let o=n.name,s=await k(this,ps,wl).call(this);if(s){let l=o.replace(/\\/g,"/");k(this,$n,ls).call(this,l),await s.write(l,r);let u=$f(o).slice(1),d=await this.generateHash(r),p={id:l,name:vl(o),path:l,hash:d,url:`/assets/${l}`,extension:u,size:r.length,mimeType:this.getMimeType(u),type:this.getAssetType(u),lastModified:new Date().toISOString()};if(p.type==="image")try{let m=bA(r);p.dimensions={width:m.width,height:m.height}}catch{}return k(this,Ut,kr).call(this,"added",p),p}let a=k(this,$n,ls).call(this,o);y(this,ia).add(a),await yA(vA(a),{recursive:!0}),await RH(a,r);let c=await this.parseAssetFile(a);return c&&k(this,Ut,kr).call(this,"added",c),c}async checkFileExists(r){let n=await k(this,ps,wl).call(this);return n?(k(this,$n,ls).call(this,r),n.exists(r.replace(/\\/g,"/"))):wA(k(this,$n,ls).call(this,r))}async getNextAvailableName(r){if(y(this,be)||O(this,be,this.config.assets),!await this.checkFileExists(r))return r;let n=$f(r),o=vl(r,n),s=vA(r),a=s==="."?"":`${s.replace(/\\/g,"/")}/`,c=1,l;do l=`${a}${o}-${c}${n}`,c++;while(await this.checkFileExists(l));return l}async deleteAsset(r){y(this,be)||O(this,be,this.config.assets);let n=r.replace(/\\/g,"/"),o=await k(this,ps,wl).call(this);if(o){k(this,$n,ls).call(this,n),await o.delete(n),k(this,Ut,kr).call(this,"deleted",{id:n,path:n});return}let s=k(this,$n,ls).call(this,n);y(this,aa).add(s),await DH(s),y(this,kn).delete(s),k(this,Ut,kr).call(this,"deleted",{id:n,path:n})}stopWatching(){y(this,Sn)&&(y(this,Sn).close(),O(this,Sn,null))}async generateHash(r){let n=FH("sha256"),o=r;return typeof r=="string"&&(o.charCodeAt(0)===65279&&(o=o.slice(1)),o=o.replace(/\r\n/g,`
23
+ `).normalize("NFC")),n.update(o),n.digest("hex")}getMimeType(r){return{jpg:"image/jpeg",jpeg:"image/jpeg",png:"image/png",gif:"image/gif",svg:"image/svg+xml",webp:"image/webp",ico:"image/x-icon",mp4:"video/mp4",webm:"video/webm",ogg:"video/ogg",mov:"video/quicktime",mp3:"audio/mpeg",wav:"audio/wav",oga:"audio/ogg",pdf:"application/pdf",doc:"application/msword",docx:"application/vnd.openxmlformats-officedocument.wordprocessingml.document",woff:"font/woff",woff2:"font/woff2",ttf:"font/ttf",otf:"font/otf",json:"application/json",txt:"text/plain",css:"text/css",js:"text/javascript"}[r.toLowerCase()]||"application/octet-stream"}getAssetType(r){let n=r.toLowerCase();return["jpg","jpeg","png","gif","svg","webp","ico"].includes(n)?"image":["mp4","webm","ogg","mov"].includes(n)?"video":["mp3","wav","ogg"].includes(n)?"audio":["pdf","doc","docx"].includes(n)?"document":["woff","woff2","ttf","otf"].includes(n)?"font":"other"}isValidAssetFile(r){let n=vl(r);return!(n.startsWith(".")||r.includes("node_modules")||n===".gitkeep")}};Sn=new WeakMap,kn=new WeakMap,ia=new WeakMap,Sl=new WeakMap,aa=new WeakMap,be=new WeakMap,us=new WeakMap,ds=new WeakMap,$n=new WeakSet,ls=i(function(r){y(this,be)||O(this,be,this.config.assets);let n=xA(y(this,be)),o=r.replace(/\\/g,"/"),s=xA(n,o);if(s!==n&&!s.startsWith(n+MH))throw new Error(`Path traversal rejected: ${r}`);return s},"#safePath"),ps=new WeakSet,wl=i(async function(){if(y(this,us))return y(this,us);let r=this.inject("storage");if(!r)return null;let n=this.config.storageProvider;if(!n)return null;let o="assets";return r.has(o)||await r.create(o,n,{...this.config.storageConfig??{},mode:"path"}),O(this,us,r.use(o)),y(this,us)},"#storage"),Ut=new WeakSet,kr=i(function(r,n){for(let o of y(this,ds))o({type:r,asset:n})},"#emit"),Ef=new WeakSet,SA=i(async function(r){let n=await r.listDataKeys(),o={};for(let s of n){if(s.startsWith(".")||s.includes("node_modules"))continue;let a=$f(s).slice(1);if(!a)continue;let c=vl(s),l=s.replace(/\\/g,"/");o[l]={id:l,name:c,path:l,url:`/assets/${l}`,extension:a,mimeType:this.getMimeType(a),type:this.getAssetType(a)}}return k(this,Ut,kr).call(this,"loaded",o),o},"#scanFromStorage"),i(Nf,"Assets"),_e(Nf,"manifest",{name:"Assets",namespace:"assets",version:"1.0.0"});bl=Nf});import{ServiceProvider as UH}from"@jucie.io/engine";import{readdir as qH,cp as BH,mkdir as HH}from"fs/promises";import{join as $A}from"path";import{existsSync as VH}from"fs";var Tf,kl,EA=f(()=>{Tf=class Tf extends UH{initialize(){let{projectRoot:t,outdir:r}=this.config;if(!t)throw new Error("[BuildAssets] projectRoot is required in config");if(!r)throw new Error("[BuildAssets] outdir is required in config")}actions(){return{copyAssets:()=>this.copyAssets(),build:t=>this.build(t)}}async copyAssets(){let{assets:t,outdir:r}=this.config;try{if(!t||!VH(t))return{success:!0,fileCount:0,skipped:!0};let n=$A(r,"assets");return await HH(n,{recursive:!0}),await BH(t,n,{recursive:!0,force:!0,errorOnExist:!1}),{success:!0,fileCount:await this.countFiles(n),source:t,target:n}}catch(n){throw new Error(`[BuildAssets] Asset copy failed: ${n.message}`)}}async countFiles(t){try{let r=await qH(t,{withFileTypes:!0}),n=0;for(let o of r)o.isFile()?n++:o.isDirectory()&&(n+=await this.countFiles($A(t,o.name)));return n}catch{return 0}}async build(){return{success:!0,assets:await this.copyAssets()}}};i(Tf,"BuildAssets"),_e(Tf,"manifest",{name:"Build Assets",namespace:"buildAssets",version:"1.0.0"});kl=Tf});var vv=f(()=>{kA();EA()});import{createDefinition as NA}from"@jucie.io/engine";var wv,bv,fs,ms,zf=f(()=>{wv="HTML_TEMPLATE",bv="HTML_FRAGMENT",fs=NA(wv,[Object]),ms=NA(bv,[Object])});function to(e){return{[ca]:String(e)}}function Cf(e){return e!=null&&e[ca]!==void 0}function ro(e,...t){let r="";for(let n=0;n<e.length;n++)if(r+=e[n],n<t.length){let o=t[n];r+=Cf(o)?o[ca]:String(o).replace(/[&<>"']/g,s=>GH[s])}return r}function If(e){return e==null?"":Cf(e)?e[ca]:String(e)}function Sv(e,t=`
24
+ `){let r=e.filter(n=>n!=null&&n!=="").map(n=>Cf(n)?n[ca]:String(n)).filter(n=>n!=="");return to(r.join(t))}var GH,ca,kv=f(()=>{GH={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},ca=Symbol.for("engine-html.raw");i(to,"raw");i(Cf,"isRaw");i(ro,"html");i(If,"unwrap");i(Sv,"joinHtml")});var TA,zA=f(()=>{zf();TA=fs("app",()=>({slots:["head","body:end"],mounts:["app"],scripts:["/main.js"],render:({html:e,config:t,data:r,slot:n})=>e`<!DOCTYPE html>
25
+ <html lang="${r.lang??t.lang??"en"}">
37
26
  <head>
38
27
  <meta charset="UTF-8" />
39
28
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
40
- <title>${a.title||s||"Jucie App"}</title>
41
- ${a.description?`<meta name="description" content="${a.description}" />`:""}
42
- ${a.themeColor?`<meta name="theme-color" content="${a.themeColor}" />`:""}
43
- ${a.favicon?`<link rel="icon" href="${a.favicon}" />`:""}
44
- ${c} <style>
29
+ <title>${r.title??t.title??"App"}</title>
30
+ ${n("head")}
31
+ <style>
45
32
  *, *::before, *::after { box-sizing: border-box; }
46
33
  html, body { margin: 0; padding: 0; }
47
34
  </style>
@@ -49,31 +36,49 @@ ${c} <style>
49
36
  <body>
50
37
  <div id="app" data-rid="app" data-node-id="app"></div>
51
38
  <script type="module" src="/main.js"></script>
39
+ ${n("body:end")}
52
40
  </body>
53
- </html>`;return await Ec(r,{recursive:!0}),await _x(Po(r,"index.html"),l,"utf8"),{success:!0,usedDefault:!0}}async countFiles(r){try{let n=await g6(r,{withFileTypes:!0}),o=0;for(let s of n)s.isFile()?o++:s.isDirectory()&&(o+=await this.countFiles(Po(r,s.name)));return o}catch(n){return console.warn(` \u26A0\uFE0F Error counting files in ${r}:`,n.message),0}}async build({fontLinks:r=""}={}){console.log(`
54
- \u{1F3A8} Processing static assets...`);try{let n=await this.copyAssets(),o=await this.processHtml({fontLinks:r});return console.log(`
55
- \u2705 Static assets processed successfully`),{success:!0,assets:n,html:o}}catch(n){throw console.error(`
56
- \u274C Static assets processing failed:`,n.message),n}}async watch(r){return O(this,qe,r||this.config.assets),console.log("\u{1F441}\uFE0F Starting asset watcher..."),console.log(` Assets directory: ${y(this,qe)}`),await this.scanDirectory(y(this,qe)),this.watchDirectory(y(this,qe)),this.inject("state")?.get(["assets"])}async scanDirectory(r){O(this,qe,r||this.config.assets),console.log("\u{1F50D} Scanning assets directory:",y(this,qe));try{if(!vx(y(this,qe)))return console.log(" \u26A0\uFE0F Assets directory not found, creating it..."),await Ec(y(this,qe),{recursive:!0}),{};let n=await this.findAllAssetFiles(y(this,qe)),o={};for(let a of n)try{let c=await this.parseAssetFile(a);if(c){o[c.id]=c;let l=await $c(a),u=await this.generateHash(l);y(this,pn).set(a,u)}}catch(c){console.warn(` \u26A0\uFE0F Failed to parse ${a}:`,c.message)}let s=this.inject("state");return s&&s.set(["assets"],o),console.log(`\u{1F4C2} Scanned ${n.length} asset file(s)`),o}catch(n){throw console.error(" \u274C Failed to scan directory:",n.message),n}}async findAllAssetFiles(r){return k6.sync(`${r}/**/*.*`,{ignore:["**/node_modules/**","**/.gitkeep","**/.*"],nodir:!0})}async parseAssetFile(r){try{y(this,qe)||O(this,qe,this.config.assets);let n=await x6(r),o=v6(y(this,qe),r).replace(/\\/g,"/"),s=w6(r).slice(1),a=Hd(r),c=await $c(r),l=await this.generateHash(c),u=this.getMimeType(s),d=this.getAssetType(s),p={id:o,name:a,path:o,hash:l,url:`/assets/${o}`,extension:s,size:n.size,mimeType:u,type:d,lastModified:n.mtime.toISOString()};if(d==="image")try{let h=E6(r);p.dimensions={width:h.width,height:h.height}}catch{console.warn(` \u26A0\uFE0F Could not get dimensions for ${a}`)}return p}catch(n){return console.error(` \u274C Error parsing asset file ${r}:`,n.message),null}}watchDirectory(r){return O(this,qe,r||this.config.assets),console.log("\u{1F441}\uFE0F Watching assets directory:",y(this,qe)),O(this,dn,S6(y(this,qe),{ignored:/(^|[\/\\])\../,persistent:!0,ignoreInitial:!0,awaitWriteFinish:{stabilityThreshold:100,pollInterval:50}})),y(this,dn).on("add",n=>this.handleFileAdded(n)).on("change",n=>this.handleFileChanged(n)).on("unlink",n=>this.handleFileDeleted(n)),y(this,dn)}async handleFileAdded(r){if(console.log("\u{1F50D} File added:",r),!this.isValidAssetFile(r))return;if(y(this,gi).has(r)){y(this,gi).delete(r);return}let n=await this.parseAssetFile(r);if(n){let o=this.inject("state");o&&o.set(["assets",n.id],n);let s=await $c(r),a=await this.generateHash(s);y(this,pn).set(r,a),console.log(`\u2795 Added asset: ${n.name}`)}}async handleFileChanged(r){if(console.log("\u{1F50D} File changed:",r),!this.isValidAssetFile(r))return;if(y(this,Nc).has(r)){y(this,Nc).delete(r);return}let n=await $c(r),o=await this.generateHash(n),s=y(this,pn).get(r);if(o===s){console.log(`\u23ED\uFE0F Skipped ${Hd(r)} (no content change)`);return}let a=await this.parseAssetFile(r);if(a){let c=this.inject("state");c&&c.set(["assets",a.id],a),y(this,pn).set(r,o),console.log(`\u{1F504} Updated asset: ${a.name}`)}}async handleFileDeleted(r){console.log("\u{1F50D} File deleted:",r);let n=Hd(r);if(y(this,yi).has(r)){y(this,yi).delete(r);return}let o=this.inject("state");if(o){let s=o.get(["assets"])||{},a=Object.keys(s).find(c=>s[c].name===n);a&&o.remove(["assets",a])}y(this,pn).delete(r),console.log(`\u2796 Removed asset: ${n}`)}async saveUploadedFile(r,n){try{y(this,qe)||O(this,qe,this.config.assets);let o=n.name,s=Po(y(this,qe),o);y(this,gi).add(s),await Ec(b6(s),{recursive:!0}),await _x(s,r),console.log(`\u{1F4BE} Saved uploaded file: ${o}`);let a=await this.parseAssetFile(s);if(a){let c=this.inject("state");c&&c.set(["assets",a.id],a)}return a}catch(o){throw console.error(" \u274C Failed to save uploaded file:",o.message),o}}async deleteAsset(r){try{let n=Po(y(this,qe),r);y(this,yi).add(n),await _6(n),y(this,pn).delete(n),console.log(`\u{1F5D1}\uFE0F Deleted asset: ${r}`)}catch(n){throw console.error(` \u274C Failed to delete asset ${r}:`,n.message),n}}stopWatching(){y(this,dn)&&(y(this,dn).close(),O(this,dn,null),console.log("\u{1F6D1} Asset watcher stopped"))}async generateHash(r){let n=$6("sha256"),o=r;return typeof r=="string"&&(o.charCodeAt(0)===65279&&(o=o.slice(1)),o=o.replace(/\r\n/g,`
57
- `),o=o.normalize("NFC")),n.update(o),n.digest("hex")}getMimeType(r){return{jpg:"image/jpeg",jpeg:"image/jpeg",png:"image/png",gif:"image/gif",svg:"image/svg+xml",webp:"image/webp",ico:"image/x-icon",mp4:"video/mp4",webm:"video/webm",ogg:"video/ogg",mov:"video/quicktime",mp3:"audio/mpeg",wav:"audio/wav",oga:"audio/ogg",pdf:"application/pdf",doc:"application/msword",docx:"application/vnd.openxmlformats-officedocument.wordprocessingml.document",woff:"font/woff",woff2:"font/woff2",ttf:"font/ttf",otf:"font/otf",json:"application/json",txt:"text/plain",css:"text/css",js:"text/javascript"}[r.toLowerCase()]||"application/octet-stream"}getAssetType(r){let n=["jpg","jpeg","png","gif","svg","webp","ico"],o=["mp4","webm","ogg","mov"],s=["mp3","wav","ogg"],a=["pdf","doc","docx"],c=["woff","woff2","ttf","otf"],l=r.toLowerCase();return n.includes(l)?"image":o.includes(l)?"video":s.includes(l)?"audio":a.includes(l)?"document":c.includes(l)?"font":"other"}isValidAssetFile(r){let n=Hd(r);return!(n.startsWith(".")||r.includes("node_modules")||n===".gitkeep")}};dn=new WeakMap,pn=new WeakMap,gi=new WeakMap,Nc=new WeakMap,yi=new WeakMap,qe=new WeakMap,i(Bd,"StaticAssets"),Te(Bd,"manifest",{name:"Static Assets",namespace:"staticAssets",version:"1.0.0",description:"Handles static asset copying and HTML processing for builds"});Ro=Bd});var wx=f(()=>{bI()});var sp,Ex=f(()=>{sp=["fs","path","crypto","stream","http","https","url","querystring","child_process","os","util","zlib","node:crypto","node:http","node:util","node:fs","node:path","firebase-admin","@google-cloud/*","@fastify/*","google-auth-library","google-gax","gtoken","gcp-metadata","teeny-request","jwks-rsa","agent-base","@aws-sdk/client-s3"]});var _i,ip=f(()=>{_i={".js":"jsx",".ts":"ts",".tsx":"tsx",".d.ts":"ts"}});function vi(e){return e==="preact"?"preact":e==="vue"?"vue":"react"}var ap=f(()=>{i(vi,"jsxImportSource")});function wi({framework:e="react",nodeEnv:t,baseUrl:r="/"}={}){let n={"process.env.NODE_ENV":JSON.stringify(t??process.env.NODE_ENV??"development"),"process.env.BASE_URL":JSON.stringify(r),"process.env.JUCIE_FRAMEWORK":JSON.stringify(e)};return process.env.AI_SERVER_URL!==void 0&&(n["process.env.AI_SERVER_URL"]=JSON.stringify(process.env.AI_SERVER_URL)),n}var cp=f(()=>{i(wi,"envDefines")});function lp(e){return e?(Array.isArray(e)?e:[e]).map(r=>typeof r=="string"?{type:"directory",path:r}:r&&typeof r=="object"&&r.name&&r.from?{type:"library",name:r.name,from:r.from,manifest:r.manifest||null}:(console.warn("[jucie] Invalid components entry (skipped):",r),null)).filter(Boolean):[]}var Nx=f(()=>{i(lp,"normalizeEntries")});function AI(e){return JSON.stringify(String(e).replaceAll("\\","/"))}function jI({components:e,libraries:t}){let r=e.map(l=>`import ${l.exportName} from './${l.fileName}';`),n=t.flatMap(l=>{let u=[`import * as _${l.name}Raw from ${AI(l.from)};`];return l.manifest&&u.push(`import ${l.name}Manifest from ${AI(l.manifest)};`),u}),o=e.map(l=>{let u=JSON.stringify(l.meta,null,2).split(`
41
+ </html>`}))});import{ServiceProvider as WH,definitionType as JH}from"@jucie.io/engine";import{readFile as KH,writeFile as YH,mkdir as XH}from"fs/promises";import{existsSync as QH}from"fs";import{join as e5}from"path";function r5(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var t5,hs,no,Pf,Of,CA,Af,IA,$l,$v,Rf,PA,El,Ev,jf,En,OA=f(()=>{zf();kv();zA();t5=[["<!--","-->"],["<script","</script>"],["<style","</style>"]],jf=class jf extends WH{constructor(){super(...arguments);$(this,Of);$(this,Af);$(this,$l);$(this,Rf);$(this,El);$(this,hs,new Map);$(this,no,new Map);$(this,Pf,0)}initialize(){this.addTemplate(TA),this.use(...this.config.templates??[],...this.config.fragments??[])}actions(){return{use:(...r)=>this.use(...r),useFile:(r,n)=>this.useFile(r,n),render:(r,n)=>this.render(r,n),renderer:r=>n=>this.render(r,n),write:(r,n)=>this.write(r,n),list:()=>this.list(),fragments:()=>this.fragments()}}use(...r){for(let n of r){let o=JH(n);if(o===wv){this.addTemplate(n);continue}if(o===bv){this.addFragment(n);continue}throw new Error(`html.use() expects defineHtml or defineHtmlFragment definitions, got "${o??typeof n}"`)}return this}addTemplate(r){let n=r._name;if(!n||typeof n!="string")throw new Error("html template definition requires a name (first argument to defineHtml)");let o={name:n,strict:!0,...r(this.inject)};if(typeof o.render!="function")throw new Error(`html template "${n}" must return a render() function`);for(let s of o.fragments??[])this.addFragment(s);for(let s of o.warnings??[])k(this,El,Ev).call(this,`[html] "${n}": ${s}`);return y(this,hs).set(n,o),n}addFragment(r){let n=r._name;if(!n||typeof n!="string")throw new Error("html fragment definition requires a name (first argument to defineHtmlFragment)");let o=r(this.inject);if(!o.slot)throw new Error(`html fragment "${n}" must declare a slot`);if(typeof o.render!="function")throw new Error(`html fragment "${n}" must return a render() function`);let s=y(this,no).get(n);return y(this,no).set(n,{...o,order:o.order??0,seq:s?s.seq:vN(this,Pf)._++}),n}async useFile(r,{name:n="file",...o}={}){if(!r||!QH(r))return null;let s=await KH(r,"utf8");return this.addTemplate(this.compile(s,{...o,name:n,sourcePath:r}))}list(){return[...y(this,hs).keys()]}template(r){return y(this,hs).get(r)}fragments(){return[...y(this,no)].map(([r,n])=>({name:r,slot:n.slot,order:n.order}))}forSlot(r){return[...y(this,no)].filter(([,n])=>n.slot===r).sort((n,o)=>n[1].order-o[1].order||n[1].seq-o[1].seq)}render(r,n={}){let o=y(this,hs).get(r);if(!o){let c=this.list().join(", ")||"none";throw new Error(`html template "${r}" is not registered (registered: ${c})`)}let{output:s,problems:a}=this.renderModule(o,n);if(a.length){let c=`[html] "${r}":
42
+ - ${a.join(`
43
+ - `)}`;if(o.strict)throw new Error(c);k(this,El,Ev).call(this,c)}return s}renderModule(r,n={}){let o=new Set,s=k(this,Of,CA).call(this,r,n,o),a=r.render(s);return{output:a,used:o,problems:this.validate(a,r,o)}}validate(r,n={},o=new Set){let s=[];/<!DOCTYPE\s+html/i.test(r)||s.push("missing <!DOCTYPE html>");for(let c of n.mounts??[])new RegExp(`<[^>]*id=["']${r5(c)}["']`).test(r)||s.push(`missing mount element <div id="${c}"></div>`);for(let c of n.scripts??[])!r.includes(`src="${c}"`)&&!r.includes(`src='${c}'`)&&s.push(`missing script reference "${c}"`);(n.scripts??[]).length&&!/type=["']module["']/.test(r)&&s.push("missing module script tag");for(let c of n.slots??[])o.has(c)||s.push(`declared slot "${c}" was never rendered`);let a=new Set(n.slots??[]);for(let[c,l]of y(this,no))a.has(l.slot)||s.push(`fragment "${c}" targets slot "${l.slot}", which this template does not declare`);return s}async write(r,{outdir:n=this.config.outdir,filename:o="index.html",data:s}={}){if(!n)throw new Error("[html] write() requires an outdir (config.outdir or opts.outdir)");let a=this.render(r,s);await XH(n,{recursive:!0});let c=e5(n,o);return await YH(c,a,"utf8"),{success:!0,template:r,outputPath:c}}compile(r,{name:n="file",vars:o={},mounts:s=[],scripts:a=[],suppressOn:c={},sourcePath:l=null}={}){let u=[],d=[];for(let[g,_]of Object.entries(c))r.includes(g)&&(d.push(_),u.push(`template already contains "${g}"; the "${_}" fragment is suppressed`));let p=k(this,Af,IA).call(this,r,o),m=k(this,$l,$v).call(this,p,"</head>","first"),h=k(this,$l,$v).call(this,p,"</body>","last");return m===null&&u.push("no </head> found; head content will be appended before </body>"),h===null&&u.push("no </body> found; body content will be appended at the end of the document"),fs(n,()=>({slots:["head","body:end"],mounts:s,scripts:a,strict:!1,suppress:d,warnings:u,sourcePath:l,render:g=>{let _=[],x=If(g.slot("head")),v=If(g.slot("body:end"));return x&&_.push([m??h??p.length,x]),v&&_.push([h??p.length,v]),k(this,Rf,PA).call(this,p,_)}}))}};hs=new WeakMap,no=new WeakMap,Pf=new WeakMap,Of=new WeakSet,CA=i(function(r,n,o){let s=new Set(r.slots??[]),a=new Set(r.suppress??[]),c={config:this.config,data:n,inject:this.inject,html:ro,raw:to,slot:l=>{if(!s.has(l))throw new Error(`[html] template "${r.name}" rendered undeclared slot "${l}"`);return o.add(l),Sv(this.forSlot(l).filter(([u])=>!a.has(u)).map(([u,d])=>d.render({...c,fragment:u})))}};return c},"#context"),Af=new WeakSet,IA=i(function(r,n){let o=r;for(let[s,a]of Object.entries(n)){let c=ro`${a}`;o=o.split(`%${s}%`).join(c),o=o.split(`{{${s}}}`).join(c)}return o},"#substitute"),$l=new WeakSet,$v=i(function(r,n,o){let s=r.toLowerCase(),a=[],c=0;for(;c<s.length;){let d=t5.find(([p])=>s.startsWith(p,c));if(d){let p=s.indexOf(d[1],c+d[0].length);c=p===-1?s.length:p+d[1].length;continue}if(s.startsWith(n,c)){a.push(c),c+=n.length;continue}c++}if(!a.length)return null;let l=o==="last"?a[a.length-1]:a[0],u=r.lastIndexOf(`
44
+ `,l);return u===-1?0:u+1},"#locateInsert"),Rf=new WeakSet,PA=i(function(r,n){let o=r;for(let[s,a]of[...n].sort((c,l)=>l[0]-c[0])){let c=/^[ \t]*/.exec(o.slice(s))?.[0]??"",l=a.split(`
45
+ `).map(u=>`${c}${u}`).join(`
46
+ `);o=`${o.slice(0,s)}${l}
47
+ ${o.slice(s)}`}return o},"#applyInserts"),El=new WeakSet,Ev=i(function(r){let n=this.inject("log");n?.warn?n.warn(r):console.warn(r)},"#warn"),i(jf,"Html"),_e(jf,"manifest",{name:"Html",namespace:"html",version:"1.0.0"});En=jf;i(r5,"escapeRegExp")});var oo=f(()=>{OA();zf()});import{readdir as n5}from"fs/promises";import{existsSync as o5}from"fs";import{join as s5}from"path";import{pathToFileURL as i5}from"url";async function la(e,{mounts:t=["app"],scripts:r=["/main.js"],onWarn:n}={}){if(!e||!o5(e))return[];let s=(await n5(e,{withFileTypes:!0})).filter(c=>c.isFile()&&c.name.endsWith(".js")).map(c=>c.name).sort(),a=[];for(let c of s){let l=c.slice(0,-3),u=s5(e,c),d;try{d=await import(i5(u).href)}catch(p){n?.(`[views] failed to load "${c}": ${p.message}`);continue}if(typeof d.default!="function"){n?.(`[views] "${c}" must default-export a render function; skipping`);continue}a.push(fs(l,()=>({slots:d.slots??a5,mounts:d.mounts??t,scripts:d.scripts??r,strict:!1,sourcePath:u,render:d.default})))}return a}var a5,Mf=f(()=>{oo();a5=["head","body:end"];i(la,"loadViews")});var da,Xf=f(()=>{da=["fs","path","crypto","stream","http","https","url","querystring","child_process","os","util","zlib","node:crypto","node:http","node:util","node:fs","node:path","firebase-admin","@google-cloud/*","@fastify/*","google-auth-library","google-gax","gtoken","gcp-metadata","teeny-request","jwks-rsa","agent-base","@aws-sdk/client-s3"]});var pa,Qf=f(()=>{pa={".js":"jsx",".ts":"ts",".tsx":"tsx",".d.ts":"ts"}});function fa(e){return e==="preact"?"preact":e==="vue"?"vue":"react"}var em=f(()=>{i(fa,"jsxImportSource")});var Tn,tm=f(()=>{Tn={vue:{framework:"vue","framework-jsx-runtime":"vue/jsx-runtime"},react:{framework:"react","framework-jsx-runtime":"react/jsx-runtime","framework-dom":"react-dom","framework-dom-client":"react-dom/client"},preact:{framework:"preact","framework-jsx-runtime":"preact/jsx-runtime","framework-hooks":"preact/hooks","framework-compat":"preact/compat"}}});import{createRequire as y5}from"module";import{dirname as x5}from"path";function v5(e){let t=e.split("/");return e.startsWith("@")?t.slice(0,2).join("/"):t[0]}function rm(e="react"){let t=Tn[e]??Tn.react,r={};for(let n of new Set(Object.values(t).map(v5)))try{r[n]=x5(_5.resolve(`${n}/package.json`))}catch{}return r}var _5,Iv=f(()=>{tm();_5=y5(import.meta.url);i(v5,"packageName");i(rm,"frameworkAlias")});function ma({framework:e="react",nodeEnv:t,baseUrl:r="/"}={}){let n={"process.env.NODE_ENV":JSON.stringify(t??process.env.NODE_ENV??"development"),"process.env.BASE_URL":JSON.stringify(r),"process.env.JUCIE_FRAMEWORK":JSON.stringify(e)};return process.env.AI_SERVER_URL!==void 0&&(n["process.env.AI_SERVER_URL"]=JSON.stringify(process.env.AI_SERVER_URL)),n}var nm=f(()=>{i(ma,"envDefines")});function io(e){return e?(Array.isArray(e)?e:[e]).map(r=>typeof r=="string"?{type:"directory",path:r}:r&&typeof r=="object"&&r.name&&r.from?{type:"library",name:r.name,from:r.from,manifest:r.manifest||null}:(console.warn("[jucie] Invalid components entry (skipped):",r),null)).filter(Boolean):[]}var Il=f(()=>{i(io,"normalizeEntries")});function KA(e){return JSON.stringify(String(e).replaceAll("\\","/"))}function YA({components:e,libraries:t}){let r=e.map(l=>`import ${l.exportName} from './${l.fileName}';`),n=t.flatMap(l=>{let u=[`import * as _${l.name}Raw from ${KA(l.from)};`];return l.manifest&&u.push(`import ${l.name}Manifest from ${KA(l.manifest)};`),u}),o=e.map(l=>{let u=JSON.stringify(l.meta,null,2).split(`
58
48
  `).join(`
59
- `);return` ${l.exportName}: ${u}`}),s=e.map(l=>` ${l.exportName}`),a=t.map(l=>l.manifest?[`const ${l.name}Components = Object.fromEntries(`,` Object.keys(${l.name}Manifest)`,` .filter(key => key in _${l.name}Raw)`,` .map(key => [key, _${l.name}Raw[key]])`,");"].join(`
49
+ `);return` ${l.fileName.endsWith(".jux")?`'.jux-${l.name}'`:l.exportName}: ${u}`}),s=e.map(l=>l.fileName.endsWith(".jux")?` '.jux-${l.name}': ${l.exportName}`:` ${l.exportName}`),a=t.map(l=>l.manifest?[`const ${l.name}Components = Object.fromEntries(`,` Object.keys(${l.name}Manifest)`,` .filter(key => key in _${l.name}Raw)`,` .map(key => [key, _${l.name}Raw[key]])`,");"].join(`
60
50
  `):`const ${l.name}Components = _${l.name}Raw;`),c=t.map(l=>` ${l.name}: { components: ${l.name}Components, manifest: ${l.manifest?`${l.name}Manifest`:"null"} }`);return["// Local component imports",...r,"","// Library imports",...n,"","// Local components object","const localComponents = {",s.join(`,
61
51
  `),"};","","// Local component manifest (built at scan time)","const localManifest = {",o.join(`,
62
52
  `),"};","","// Library component objects (manifest-filtered or raw)",...a,"","// Unified namespace map","export default {"," local: { components: localComponents, manifest: localManifest },",...c.map(l=>` ${l.trimStart()},`),"};"].join(`
63
- `).trim()}var DI=f(()=>{i(AI,"toImportSpecifier");i(jI,"getContents")});import{join as L6}from"path";import{readdirSync as F6,existsSync as U6,statSync as q6}from"fs";function MI(e){return U6(e)?F6(e).filter(r=>{if(!r.endsWith(".js")||r==="index.js")return!1;let n=L6(e,r);return q6(n).isFile()}).map(r=>{let n=r.replace(".js",""),s=n.split(/[-_]/).map(c=>c.charAt(0).toUpperCase()+c.slice(1)).join("")||n.charAt(0).toUpperCase()+n.slice(1),a={displayName:s.replace(/([A-Z])/g," $1").trim(),category:"components",keywords:[n,"component"],tagName:n};return{fileName:r,name:n,exportName:s,meta:a}}):[]}var ZI=f(()=>{i(MI,"scanComponentsDirectory")});import{existsSync as LI}from"fs";import{defineEsPlugin as H6}from"@jucie.io/engine-esbuild";var bi,up=f(()=>{Nx();DI();ZI();bi=H6("resolve-components",(e,t)=>r=>{r.onResolve({filter:/^@components$/},()=>({path:"@components",namespace:"components-dir"})),r.onLoad({filter:/.*/,namespace:"components-dir"},()=>{let n=lp(t.components||t.componentsDir),o=n.filter(d=>d.type==="directory"),s=n.filter(d=>d.type==="library"),a=o.flatMap(d=>MI(d.path)),l=o.find(d=>LI(d.path))?.path||t.root||process.cwd();return{contents:jI({components:a,libraries:s}),loader:"js",resolveDir:l,watchDirs:o.map(d=>d.path).filter(d=>LI(d))}})})});var FI=f(()=>{});import{createRequire as B6}from"module";import{defineEsPlugin as V6}from"@jucie.io/engine-esbuild";var G6,UI,dp,Tx=f(()=>{FI();G6=B6(import.meta.url),UI={react:"@packages/jucie-sdk/react",vue:"@packages/jucie-sdk/vue",preact:"@packages/jucie-sdk/preact",angular:"@packages/jucie-sdk/angular"},dp=V6("resolve-sdk",(e,t)=>{let r=e("cache");return n=>{n.onResolve({filter:/^jucie:sdk$/},()=>{let o=r.get(["jucieConfig","framework"])||t?.framework||"react",s=UI[o]||UI.react;return{path:G6.resolve(s),external:!1}})}})});import{join as W6}from"path";import{existsSync as K6}from"fs";import{defineEsPlugin as J6}from"@jucie.io/engine-esbuild";var Y6,Si,pp=f(()=>{Y6=`export const __jucieMainStub = true;
64
- `,Si=J6("resolve-main",e=>{let t=e("cache");return r=>{r.onResolve({filter:/^jucie:main$/},()=>{let n=t.get(["jucieConfig","projectRoot"])||process.cwd(),o=W6(n,"src","main.js");return K6(o)?{path:o,external:!1}:{path:"virtual:jucie-main",namespace:"jucie-main"}}),r.onLoad({filter:/.*/,namespace:"jucie-main"},()=>({contents:Y6,loader:"js"}))}})});import{defineEsPlugin as X6}from"@jucie.io/engine-esbuild";var fp,zx=f(()=>{fp=X6("resolve-scene",e=>{let t=e("state");return r=>{r.onResolve({filter:/^jucie:scene$/},()=>({path:"virtual:scene",namespace:"scene"})),r.onLoad({filter:/.*/,namespace:"scene"},()=>({contents:`export const scene = ${JSON.stringify(t.get())};`,loader:"js"}))}})});import{defineEsConfig as lB}from"@jucie.io/engine-esbuild";import{dirname as uB,join as dB}from"path";import{fileURLToPath as pB}from"url";var fB,xR,_R=f(()=>{Ex();ip();ap();cp();fB=dB(uB(pB(import.meta.url)),"../../modes/design/entry.js"),xR=lB("runtimeConfig",(e,t)=>({entryPoints:[{in:fB,out:t.entryOut??"entry"}],bundle:!0,format:"esm",platform:"browser",sourcemap:t.sourcemap??!0,sourcesContent:t.sourcemap??!0,target:t.target??["es2020"],minify:t.minify??!1,jsx:"automatic",jsxImportSource:vi(t.framework),loader:_i,define:wi({framework:t.framework,nodeEnv:t.nodeEnv,baseUrl:t.baseUrl}),treeShaking:!0,splitting:!0,chunkNames:"chunks/[name]-[hash]",assetNames:"assets/[name]-[hash]",external:sp,outExtension:{".js":".js",".css":".css"}}))});import{defineEsPlugin as mB}from"@jucie.io/engine-esbuild";var Np,c_=f(()=>{Np=mB("on-rebuild",e=>{let t=e("cache"),r=e("log");return n=>{n.onEnd(()=>{let o=t.get(["sseClients"]);try{if(!o)return;for(let s of o)s.write(`event: change
53
+ `).trim()}var XA=f(()=>{i(KA,"toImportSpecifier");i(YA,"getContents")});import{join as $5}from"path";import{readdirSync as E5,existsSync as N5,statSync as T5}from"fs";function QA(e,{framework:t}={}){if(!N5(e))return[];let r=t==="vue"?[".js",".vue",".jux"]:[".js",".jux"];return E5(e).filter(o=>{if(!r.some(c=>o.endsWith(c))||o==="index.js")return!1;let s=$5(e,o);return T5(s).isFile()}).map(o=>{let s=o.replace(/\.(js|vue|jux)$/,""),c=s.split(/[-_]/).map(u=>u.charAt(0).toUpperCase()+u.slice(1)).join("")||s.charAt(0).toUpperCase()+s.slice(1),l={displayName:c.replace(/([A-Z])/g," $1").trim(),category:"components",keywords:[s,"component"],tagName:s};return{fileName:o,name:s,exportName:c,meta:l}})}var eR=f(()=>{i(QA,"scanComponentsDirectory")});var Pv={};C(Pv,{resolveComponents:()=>Pl});import{existsSync as tR}from"fs";import{defineEsPlugin as z5}from"@jucie.io/engine-esbuild";var Pl,Ol=f(()=>{Il();XA();eR();Pl=z5("resolve-components",(e,t)=>r=>{r.onResolve({filter:/^@components$/},()=>({path:"@components",namespace:"components-dir"})),r.onLoad({filter:/.*/,namespace:"components-dir"},()=>{let n=io(t.components||t.componentsDir),o=n.filter(d=>d.type==="directory"),s=n.filter(d=>d.type==="library"),a=o.flatMap(d=>QA(d.path,{framework:t.framework})),l=o.find(d=>tR(d.path))?.path||t.root||process.cwd();return{contents:YA({components:a,libraries:s}),loader:"js",resolveDir:l,watchDirs:o.map(d=>d.path).filter(d=>tR(d))}})})});import{parse as C5}from"@babel/parser";function I5(e,t){let r=e;for(let n of[...t].sort((o,s)=>s.start-o.start||s.end-o.end))r=r.slice(0,n.start)+n.text+r.slice(n.end);return r}function oR(e,{filename:t="component.js"}={}){let r;try{r=C5(e,{sourceType:"module",plugins:["jsx"],errorRecovery:!1})}catch(g){return{code:e,changed:!1,warning:null,parseError:g}}let n=r.program,o=n.body.find(g=>g.type==="ExportDefaultDeclaration");if(!o)return{code:e,changed:!1,warning:null};let s=P5(n,o);if(!s.fn)return{code:e,changed:!1,warning:Ov(t,o,s.reason)};let a=R5(s.fn);if(a.unsupported)return{code:e,changed:!1,warning:Ov(t,a.unsupported.node,a.unsupported.reason)};let c=[];for(let g of a.elements){let _=D5(g);if(_!=="cooperative"){if(_==="host"){c.push(g);continue}return{code:e,changed:!1,warning:Ov(t,g,_)}}}if(!c.length&&s.alreadyWrapped)return{code:e,changed:!1,warning:null};let l=[],u=sR(n),d=M5(n),p=u.Jucie,m=u.defineJucieComponent,h=[];c.length&&!p&&(p=rR("Jucie",d),h.push(p==="Jucie"?"Jucie":`Jucie as ${p}`)),!s.alreadyWrapped&&!m&&(m=rR("defineJucieComponent",d),h.push(m==="defineJucieComponent"?"defineJucieComponent":`defineJucieComponent as ${m}`));for(let g of c){let _=g.openingElement.name;if(l.push({start:_.start,end:_.end,text:`${p}.${_.name}`}),g.closingElement){let x=g.closingElement.name;l.push({start:x.start,end:x.end,text:`${p}.${x.name}`})}}return s.alreadyWrapped||(s.markerName?l.push({start:e.length,end:e.length,text:`
54
+ ${m}(${s.markerName});
55
+ `}):(l.push({start:s.wrapStart,end:s.wrapStart,text:`${m}(`}),l.push({start:s.wrapEnd,end:s.wrapEnd,text:")"}))),h.length&&l.push({start:0,end:0,text:`import { ${h.join(", ")} } from '${nR}';`}),{code:I5(e,l),changed:!0,warning:null}}function P5(e,t){let r=t.declaration;if(r.type==="CallExpression"&&O5(e,r)){let n=r.arguments[0];return n&&om(n)?{fn:n,alreadyWrapped:!0,markerName:null}:{fn:null,alreadyWrapped:!0,reason:null,skip:!0}}if(r.type==="FunctionDeclaration")return r.id?{fn:r,alreadyWrapped:!1,markerName:r.id.name}:{fn:r,alreadyWrapped:!1,markerName:null,wrapStart:r.start,wrapEnd:r.end};if(om(r))return{fn:r,alreadyWrapped:!1,markerName:null,wrapStart:r.start,wrapEnd:r.end};if(r.type==="Identifier"){let n=A5(e,r.name);return n?{fn:n,alreadyWrapped:!1,markerName:r.name}:{fn:null,reason:"its default export is not a component defined in this file"}}return{fn:null,reason:"its default export is not a function component"}}function O5(e,t){if(t.callee.type!=="Identifier")return!1;let r=sR(e).defineJucieComponent;return t.callee.name===r||t.callee.name==="defineJucieComponent"}function A5(e,t){for(let r of e.body){if(r.type==="FunctionDeclaration"&&r.id?.name===t)return r;if(r.type==="VariableDeclaration"){for(let n of r.declarations)if(n.id.type==="Identifier"&&n.id.name===t&&n.init&&om(n.init))return n.init}}return null}function om(e){return e.type==="FunctionDeclaration"||e.type==="FunctionExpression"||e.type==="ArrowFunctionExpression"}function R5(e){let t=[],r=null,n=i(o=>{if(!(r||!o))switch(o.type){case"JSXElement":t.push(o);return;case"ConditionalExpression":n(o.consequent),n(o.alternate);return;case"LogicalExpression":o.operator!=="&&"&&n(o.left),n(o.right);return;case"NullLiteral":return;case"StringLiteral":case"NumericLiteral":case"BooleanLiteral":r={node:o,reason:"it renders a bare value with no root element"};return;case"Identifier":if(o.name==="undefined")return;r={node:o,reason:"its root element cannot be determined statically"};return;case"JSXFragment":r={node:o,reason:"it renders a fragment, which has no single root element"};return;default:r={node:o,reason:"its root element cannot be determined statically"}}},"consider");if(e.body.type!=="BlockStatement")return n(e.body),{elements:t,unsupported:r};for(let o of j5(e.body))n(o);return{elements:t,unsupported:r}}function j5(e){let t=[],r=i(n=>{if(!(!n||typeof n!="object")){if(Array.isArray(n)){n.forEach(r);return}if(typeof n.type=="string"&&!om(n)){if(n.type==="ReturnStatement"){n.argument&&t.push(n.argument);return}for(let o in n)o==="type"||o==="start"||o==="end"||o==="loc"||o==="range"||r(n[o])}}},"visit");return r(e),t}function D5(e){let t=e.openingElement.name;return t.type==="JSXMemberExpression"?t.object?.type==="JSXIdentifier"&&t.object.name==="Jucie"?"cooperative":"its root is a component, so styling and selection cannot attach to it":t.type!=="JSXIdentifier"?"its root element cannot be determined statically":/^[a-z]/.test(t.name)?"host":"its root is a component, so styling and selection cannot attach to it"}function sR(e){let t={};for(let r of e.body)if(!(r.type!=="ImportDeclaration"||r.source.value!==nR))for(let n of r.specifiers)n.type==="ImportSpecifier"&&(t[n.imported.name]=n.local.name);return t}function M5(e){let t=new Set;for(let r of e.body)if(r.type==="ImportDeclaration")for(let n of r.specifiers)t.add(n.local.name);else if(r.type==="FunctionDeclaration"||r.type==="ClassDeclaration")r.id&&t.add(r.id.name);else if(r.type==="VariableDeclaration")for(let n of r.declarations)Al(n.id,t);return t}function Al(e,t){if(e)switch(e.type){case"Identifier":t.add(e.name);return;case"ObjectPattern":e.properties.forEach(r=>Al(r.value??r.argument,t));return;case"ArrayPattern":e.elements.forEach(r=>Al(r,t));return;case"AssignmentPattern":Al(e.left,t);return;case"RestElement":Al(e.argument,t);return;default:}}function rR(e,t){if(!t.has(e))return e;let r=0,n=`_${e}`;for(;t.has(n);)n=`_${e}${r++}`;return n}function Ov(e,t,r){return r?{text:`[jucie] This component cannot receive styling or canvas selection because ${r}. Use a <Jucie.div> (or any <Jucie.*> tag) as its root element.`,location:{file:e,line:t?.loc?.start?.line??1,column:t?.loc?.start?.column??0}}:null}var nR,iR=f(()=>{nR="jucie:sdk";i(I5,"splice");i(oR,"transformCooperativeRoot");i(P5,"resolveExportTarget");i(O5,"isDefineCall");i(A5,"findTopLevelFunction");i(om,"isFunction");i(R5,"collectRootExpressions");i(j5,"collectReturnArguments");i(D5,"classifyRoot");i(sR,"existingSdkBindings");i(M5,"topLevelNames");i(Al,"collectPatternNames");i(rR,"freeName");i(Ov,"warn")});var Av={};C(Av,{cooperativeRoots:()=>Rl});import{readFileSync as Z5}from"fs";import{resolve as aR,dirname as L5,basename as F5}from"path";import{defineEsPlugin as U5}from"@jucie.io/engine-esbuild";var Rl,jl=f(()=>{Il();iR();Rl=U5("cooperative-roots",(e,t)=>r=>{if(t.framework!=="react")return;let n=t.projectRoot||t.root||process.cwd(),o=io(t.components||t.componentsDir).filter(s=>s.type==="directory").map(s=>aR(n,s.path));o.length&&r.onLoad({filter:/\.js$/},s=>{let a=aR(s.path);if(F5(a)==="index.js"||!o.includes(L5(a)))return null;let c;try{c=Z5(a,"utf8")}catch{return null}let{code:l,changed:u,warning:d}=oR(c,{filename:a});return!u&&!d?null:{contents:u?l:c,loader:"jsx",warnings:d?[d]:[]}})})});function cR(e,{filename:t,id:r,sfc:n}){let{descriptor:o,errors:s}=n.parse(e,{filename:t});if(s?.length)return{errors:s.map(x=>Rv(x,t))};let{template:a,script:c,scriptSetup:l,styles:u}=o;if(a?.lang&&a.lang!=="html")return{errors:[{text:`[jucie] <template lang="${a.lang}"> is not supported.`,location:{file:t}}]};let d=c?.lang||l?.lang||"js";if(d!=="js"&&d!=="ts")return{errors:[{text:`[jucie] <script lang="${d}"> is not supported.`,location:{file:t}}]};let p=u.some(x=>x.scoped),m=`data-v-${r}`,h=[],g;if(c||l){let x;try{x=n.compileScript(o,{id:r,inlineTemplate:!1})}catch(b){return{errors:[{text:`[jucie] ${b.message}`,location:{file:t}}]}}g=x.bindings;let v=d==="ts"?["typescript"]:[];h.push(n.rewriteDefault(x.content,"__sfc_main__",v))}else h.push("const __sfc_main__ = {};");if(a){let x=n.compileTemplate({source:a.content,filename:t,id:r,scoped:p,slotted:o.slotted,compilerOptions:{bindingMetadata:g,scopeId:p?m:void 0}});if(x.errors?.length)return{errors:x.errors.map(v=>Rv(v,t))};h.push(x.code),h.push("__sfc_main__.render = render;")}let _=[];for(let x of u){if(x.module)return{errors:[{text:"[jucie] <style module> is not supported.",location:{file:t}}]};let v=n.compileStyle({source:x.content,filename:t,id:r,scoped:x.scoped});if(v.errors?.length)return{errors:v.errors.map(b=>Rv(b,t))};_.push(v.code)}return p&&h.push(`__sfc_main__.__scopeId = ${JSON.stringify(m)};`),_.length&&h.push(q5(r,_.join(`
56
+ `))),h.push(`__sfc_main__.__file = ${JSON.stringify(t)};`),h.push("export default __sfc_main__;"),{code:h.join(`
57
+ `),loader:d==="ts"?"ts":"js"}}function q5(e,t){return["(() => {"," if (typeof document === 'undefined') return;",` const key = ${JSON.stringify(e)};`,' const existing = document.head.querySelector(`style[data-jucie-sfc="${key}"]`);'," const el = existing ?? document.createElement('style');",' el.setAttribute("data-jucie-sfc", key);',` el.textContent = ${JSON.stringify(t)};`," if (!existing) document.head.appendChild(el);","})();"].join(`
58
+ `)}function Rv(e,t){let r=e.loc?.start;return{text:`[jucie] ${e.message??String(e)}`,location:{file:t,line:r?.line??1,column:r?.column??0}}}var lR=f(()=>{i(cR,"compileVueSfc");i(q5,"styleInjection");i(Rv,"formatError")});var jv={};C(jv,{vueSfc:()=>Dl});import{readFileSync as B5}from"fs";import{createHash as H5}from"crypto";import{createRequire as V5}from"module";import{resolve as uR,dirname as dR,join as G5,relative as pR}from"path";import{defineEsPlugin as W5}from"@jucie.io/engine-esbuild";function J5(e){let t=[e?G5(e,"package.json"):null,import.meta.url];for(let r of t)if(r)try{return V5(r)(fR)}catch{}return null}var fR,Dl,Ml=f(()=>{Il();lR();fR="@vue/compiler-sfc";i(J5,"loadSfcCompiler");Dl=W5("vue-sfc",(e,t)=>r=>{if(t.framework!=="vue")return;let n=t.projectRoot||t.root||process.cwd(),o=io(t.components||t.componentsDir).filter(c=>c.type==="directory").map(c=>uR(n,c.path));if(!o.length)return;let s,a=!1;r.onLoad({filter:/\.vue$/},c=>{let l=uR(c.path);if(!o.includes(dR(l)))return null;if(!s&&!a&&(s=J5(n),a=!s),a)return{errors:[{text:`[jucie] Cannot compile ${pR(n,l)}: ${fR} could not be resolved. Install vue in the project (it depends on the matching compiler).`,location:{file:l}}]};let u;try{u=B5(l,"utf8")}catch(g){return{errors:[{text:`[jucie] Could not read ${l}: ${g.message}`,location:{file:l}}]}}let d=H5("sha256").update(pR(n,l)).digest("hex").slice(0,8),{code:p,loader:m,errors:h}=cR(u,{filename:l,id:d,sfc:s});return h?{errors:h}:{contents:p,loader:m,resolveDir:dR(l)}})})});function Zl(e){let t={script:null,template:null,style:null},r;for(;(r=K5.exec(e))!==null;){let n=r[1].toLowerCase(),o=(r[2]||"").trim(),s=r[3];n==="script"?t.script={content:s,attrs:o}:n==="template"?t.template={content:s,attrs:o}:n==="style"&&(t.style={content:s,attrs:o,scoped:/\bscoped\b/.test(o)})}return t}var K5,sm=f(()=>{K5=/<(script|template|style)(\s[^>]*)?>([^]*?)<\/\1>/gi;i(Zl,"parseSFC")});function X5(e){let t=[],r=0;for(;r<e.length;){if(e[r]==="<"){if(e.slice(r,r+4)==="<!--"){let h=e.indexOf("-->",r+4);r=h===-1?e.length:h+3;continue}if(e[r+1]==="/"){let h=e.indexOf(">",r+2),g=e.slice(r+2,h).trim().toLowerCase();t.push({type:"close",tag:g}),r=h+1;continue}let a=Q5(e,r),c=e.slice(r+1,a),l=c.endsWith("/")||!1,u=l?c.slice(0,-1):c,{tag:d,attrs:p}=eV(u),m=Y5.has(d)||l;t.push({type:"open",tag:d,attrs:p,selfClose:m}),m&&t.push({type:"close",tag:d}),r=a+1;continue}let n=e.indexOf("<",r),s=(n===-1?e.slice(r):e.slice(r,n)).trim();s&&t.push({type:"text",value:s}),r=n===-1?e.length:n}return t}function Q5(e,t){let r=null;for(let n=t+1;n<e.length;n++){let o=e[n];if(r){o===r&&(r=null);continue}if(o==='"'||o==="'"){r=o;continue}if(o===">")return n}return e.length-1}function eV(e){let t=e.search(/\s/);if(t===-1)return{tag:e.toLowerCase(),attrs:{}};let r=e.slice(0,t).toLowerCase(),n=e.slice(t).trim(),o=rV(n);return{tag:r,attrs:o}}function rV(e){let t={},r;for(;(r=tV.exec(e))!==null;)t[r[1]]=r[2]??r[3]??r[4]??!0;return t}function nV(e){let t={tag:"__root",children:[]},r=[t];for(let n of e){let o=r[r.length-1];if(n.type==="open"){let s={tag:n.tag,attrs:n.attrs,children:[]};o.children.push(s),n.selfClose||r.push(s)}else n.type==="close"?r.length>1&&r[r.length-1].tag===n.tag&&r.pop():n.type==="text"&&o.children.push({tag:"__text",value:n.value})}return t}function gR(e){return oV.some(t=>e.startsWith(t))}function sV(e){return/^\s*function\s*\(/.test(e)||/^\s*\(.*\)\s*=>/.test(e)}function aV(e){return iV[e]||`on${e.charAt(0).toUpperCase()}${e.slice(1)}`}function mR(e){let t=[],r=0;for(;r<e.length;){let n=e.indexOf("{{",r);if(n===-1){let s=e.slice(r);s&&t.push({type:"static",value:s});break}n>r&&t.push({type:"static",value:e.slice(r,n)});let o=e.indexOf("}}",n+2);if(o===-1){t.push({type:"static",value:e.slice(n)});break}t.push({type:"expr",value:e.slice(n+2,o).trim()}),r=o+2}return t}function tt(e,t={}){return{mode:e,value:t.value??null,binding:t.binding??null,computed:t.computed??null,code:t.code??null,error:null,...t.name!=null?{name:t.name}:{}}}function Dv(e=!0){return tt("value",{value:e})}function hR(e,t){return e=e.trim(),t.has(e)?tt("binding",{binding:e}):gR(e)?tt("binding",{binding:e}):tt("binding",{binding:e})}function Ll(e,t=new Set,r={}){let n=r.componentName||"component",o=r.componentRef||n,s=0;function a(){return`.jux-${n}-${s++}`}i(a,"nextId");let c=X5(e),l=nV(c),u={};function d(v){if(v.tag==="__text")return m(v.value);if(v.tag==="slot")return p(v);let b=a(),w=v.attrs||{},S=[];if(w.class)for(let J of w.class.split(/\s+/).filter(Boolean))S.push(tt("value",{value:J}));let E=[];for(let[J,te]of Object.entries(w)){if(!J.startsWith("@"))continue;let Ve=J.slice(1),Dr=aV(Ve);sV(te)?E.push(tt("code",{name:Dr,code:te})):t.has(te)?E.push(tt("binding",{name:Dr,binding:te})):gR(te)?E.push(tt("binding",{name:Dr,binding:te})):/^[a-zA-Z_$][\w$]*$/.test(te)?E.push(tt("binding",{name:Dr,binding:te})):E.push(tt("code",{name:Dr,code:`function(ctx, event) { ${te} }`}))}let I=[];if(w["j-model"]){let J=w["j-model"];I.push(tt("binding",{name:"model",binding:J}))}for(let[J,te]of Object.entries(w))if(!(J.startsWith("@")||J.startsWith("j-")||J==="class"||J==="id"))if(typeof te=="string"&&te.includes("{{")){let Ve=mR(te);if(Ve.length===1&&Ve[0].type==="expr"){let Dr=hR(Ve[0].value,t);I.push({...Dr,name:J})}else I.push(tt("value",{name:J,value:te}))}else typeof te=="string"&&I.push(tt("value",{name:J,value:te}));let z;if(w["j-if"]){let J=w["j-if"];t.has(J)?z=tt("binding",{binding:J}):z=tt("binding",{binding:J})}else z=Dv(!0);let M=null;if(w["j-repeat"]){let te=w["j-repeat"].match(/^(.+?)\s+as\s+(\$\w+)$/);te&&(M={binding:te[1].trim(),as:te[2]})}let D=[],Z=null;for(let J of v.children){let te=d(J);te&&(te.inline?Z=te.textContent:D.push(te.id))}let H=null;Z?H="text":D.length>0&&(H="children");let ce={type:"element",tagName:v.tag,render:z,layout:"none",childrenType:H,className:S,events:E,attributes:I,states:[],style:{}};return w.id&&(ce.id=w.id),Z&&(ce.textContent=Z),D.length&&(ce.children=D),M&&(ce.repeat=M),u[b]=ce,{id:b}}i(d,"emitNode");function p(v){let b=a(),w=[];for(let S of v.children||[]){let E=d(S);E&&!E.inline&&w.push(E.id)}return u[b]={type:"slot",tagName:"slot",render:Dv(!0),layout:"none",childrenType:w.length?"children":null,children:w.length?w:void 0,className:[],events:[],attributes:[],states:[],style:{}},{id:b}}i(p,"emitSlot");function m(v){let b=mR(v);if(b.length===1&&b[0].type==="static")return{inline:!0,textContent:tt("value",{value:b[0].value})};if(b.length===1&&b[0].type==="expr")return{inline:!0,textContent:hR(b[0].value,t)};let w=b.map(S=>S.type==="static"?S.value:`{{${S.value}}}`).join("");return{inline:!0,textContent:tt("binding",{binding:w})}}i(m,"handleText");let h=l.children,g=[];for(let v of h){let b=d(v);b&&!b.inline&&g.push(b.id)}let _=g;if(g.length>1){let v=a();u[v]={type:"element",tagName:"div",render:Dv(!0),layout:"none",childrenType:"children",children:g,className:[],events:[],attributes:[],states:[],style:{}},_=[v]}let x=`.jux-${n}`;return u[x]={type:"component",name:n,component:o,childrenType:_.length?"children":null,children:_},{nodes:u,rootId:x}}var Y5,tV,oV,iV,im=f(()=>{Y5=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr","slot"]);i(X5,"tokenize");i(Q5,"findTagEnd");i(eV,"parseTag");tV=/([^\s=]+)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|(\S+)))?/g;i(rV,"parseAttrs");i(nV,"buildAST");oV=["$store.","$router.","$item","$index","$key","ctx."];i(gR,"isCtxPath");i(sV,"isInlineFunction");iV={click:"onClick",dblclick:"onDblclick",mousedown:"onMousedown",mouseup:"onMouseup",mousemove:"onMousemove",mouseenter:"onMouseenter",mouseleave:"onMouseleave",keydown:"onKeydown",keyup:"onKeyup",keypress:"onKeypress",focus:"onFocus",blur:"onBlur",input:"onInput",change:"onChange",submit:"onSubmit",scroll:"onScroll",resize:"onResize",contextmenu:"onContextmenu",touchstart:"onTouchstart",touchend:"onTouchend",touchmove:"onTouchmove",drag:"onDrag",dragstart:"onDragstart",dragend:"onDragend",dragover:"onDragover",drop:"onDrop"};i(aV,"eventName");i(mR,"parseMustache");i(tt,"makeDescriptor");i(Dv,"makeRender");i(hR,"resolveExpr");i(Ll,"compileTemplate")});function Fl(e){let t=new Set,r=e.split(`
59
+ `);for(let o of r){let s=o.trim(),a=s.match(/^(?:export\s+)?function\s+([a-zA-Z_$][\w$]*)\s*\(/);if(a){t.add(a[1]);continue}let c=s.match(/^(?:export\s+)?(?:const|let|var)\s+([a-zA-Z_$][\w$]*)\s*=/);if(c){t.add(c[1]);continue}let l=s.match(/^(?:export\s+)?(?:const|let|var)\s+\[([^\]]+)\]\s*=/);if(l){let d=l[1].split(",").map(p=>p.trim()).filter(Boolean);for(let p of d){let m=p.replace("...","").trim();/^[a-zA-Z_$][\w$]*$/.test(m)&&t.add(m)}continue}let u=s.match(/^(?:export\s+)?(?:const|let|var)\s+\{([^}]+)\}\s*=/);if(u){let d=u[1].split(",").map(p=>{let m=p.split(":");return(m[m.length-1]||"").trim()}).filter(Boolean);for(let p of d){let m=p.replace("...","").trim();/^[a-zA-Z_$][\w$]*$/.test(m)&&t.add(m)}continue}}let n=cV.filter(o=>e.includes(o));return{localNames:t,usedReactiveImports:n}}var cV,am=f(()=>{cV=["createSignal","createComputed","createBinding","createSubscriber","createSource","defineStore","addEffect","onDirty"];i(Fl,"analyzeScript")});function Mv(e){return!e||!e.content.trim()?null:{css:e.content.trim(),scoped:e.scoped??!0}}var Zv=f(()=>{i(Mv,"extractStyle")});function Lv({scriptBody:e,usedReactiveImports:t,localNames:r,nodes:n,style:o}){let s=[];t.length>0&&(s.push(`import { ${t.join(", ")} } from '@jucie.io/reactive';`),s.push(""));let a=Array.from(r).join(", "),c=JSON.stringify(n,null,2),l=o?JSON.stringify(o):"null";if(s.push("export default function setup(props) {"),e.trim()){for(let u of e.split(`
60
+ `))s.push(` ${u}`);s.push("")}return s.push(" return {"),s.push(" __jux: true,"),s.push(` locals: { ${a} },`),s.push(` nodes: ${lV(c,4)},`),s.push(` style: ${l},`),s.push(" };"),s.push("}"),s.push("setup.__jux = true;"),s.join(`
61
+ `)}function lV(e,t){let r=" ".repeat(t);return e.split(`
62
+ `).map((n,o)=>o===0?n:r+n).join(`
63
+ `)}var Fv=f(()=>{i(Lv,"emit");i(lV,"indent")});function yR(e,t={}){let r=Zl(e),n=r.script?.content??"",{localNames:o,usedReactiveImports:s}=Fl(n),a=r.template?.content??"",{nodes:c}=Ll(a,o),l=Mv(r.style);return{code:Lv({scriptBody:n,usedReactiveImports:s,localNames:o,nodes:c,style:l})}}var xR=f(()=>{sm();im();am();Zv();Fv();sm();im();am();Zv();Fv();i(yR,"compileJux")});var Uv={};C(Uv,{resolveJux:()=>Ul});import{readFileSync as uV}from"fs";import{resolve as _R,dirname as vR,basename as dV,relative as pV}from"path";import{defineEsPlugin as fV}from"@jucie.io/engine-esbuild";var Ul,ql=f(()=>{Il();xR();Ul=fV("resolve-jux",(e,t)=>r=>{let n=t.projectRoot||t.root||process.cwd(),o=io(t.components||t.componentsDir).filter(s=>s.type==="directory").map(s=>_R(n,s.path));o.length&&r.onLoad({filter:/\.jux$/},s=>{let a=_R(s.path);if(dV(a)==="index.jux"||!o.includes(vR(a)))return null;let c;try{c=uV(a,"utf8")}catch(u){return{errors:[{text:`[jucie] Could not read ${pV(n,a)}: ${u.message}`,location:{file:a}}]}}let{code:l}=yR(c,{filename:a});return{contents:l,loader:"js",resolveDir:vR(a)}})})});var qv,wR=f(()=>{qv={vue:"vue",react:"react",preact:"preact"}});var kR={};C(kR,{resolveSdk:()=>Bl,resolveSdkBundled:()=>gV});import{createRequire as mV}from"module";import{defineEsPlugin as hV}from"@jucie.io/engine-esbuild";function gV(e="react"){let r=`@packages/jucie-sdk/${qv[e]||qv.react}`;return{name:"resolve-sdk-bundled",setup(n){n.onResolve({filter:/^jucie:sdk$/},()=>({path:SR.resolve(r),external:!1}))}}}var SR,bR,Bl,cm=f(()=>{wR();SR=mV(import.meta.url),bR={react:"@packages/jucie-sdk/react",vue:"@packages/jucie-sdk/vue",preact:"@packages/jucie-sdk/preact",angular:"@packages/jucie-sdk/angular"},Bl=hV("resolve-sdk",(e,t)=>{let r=e("cache");return n=>{n.onResolve({filter:/^jucie:sdk$/},()=>{let o=r.get(["jucieConfig","framework"])||t?.framework||"react",s=bR[o]||bR.react;return{path:SR.resolve(s),external:!1}})}});i(gV,"resolveSdkBundled")});var Bv={};C(Bv,{resolveMain:()=>Hl});import{join as yV}from"path";import{existsSync as xV}from"fs";import{defineEsPlugin as _V}from"@jucie.io/engine-esbuild";var vV,Hl,Vl=f(()=>{vV=`export const __jucieMainStub = true;
64
+ `,Hl=_V("resolve-main",e=>{let t=e("cache");return r=>{r.onResolve({filter:/^jucie:main$/},()=>{let n=t.get(["jucieConfig","projectRoot"])||process.cwd(),o=yV(n,"src","main.js");return xV(o)?{path:o,external:!1}:{path:"virtual:jucie-main",namespace:"jucie-main"}}),r.onLoad({filter:/.*/,namespace:"jucie-main"},()=>({contents:vV,loader:"js"}))}})});var Hv={};C(Hv,{resolveScene:()=>Gl});import{defineEsPlugin as wV}from"@jucie.io/engine-esbuild";var Gl,Wl=f(()=>{Gl=wV("resolve-scene",e=>{let t=e("state");return r=>{r.onResolve({filter:/^jucie:scene$/},()=>({path:"virtual:scene",namespace:"scene"})),r.onLoad({filter:/.*/,namespace:"scene"},()=>({contents:`export const scene = ${JSON.stringify(t.get())};`,loader:"js"}))}})});var Vv={};C(Vv,{resolveConfig:()=>Jl});import{defineEsPlugin as bV}from"@jucie.io/engine-esbuild";var Jl,Kl=f(()=>{Jl=bV("resolve-config",e=>{let t=e("cache");return r=>{r.onResolve({filter:/^jucie:config$/},()=>({path:"virtual:config",namespace:"config"})),r.onLoad({filter:/.*/,namespace:"config"},()=>({contents:`export const jucieConfig = ${JSON.stringify(t.get(["jucieConfig"]))};`,loader:"js"}))}})});var eD={};C(eD,{runtimeConfig:()=>$w});import{defineEsConfig as PW}from"@jucie.io/engine-esbuild";import{dirname as OW,join as AW}from"path";import{fileURLToPath as RW}from"url";var jW,$w,Ew=f(()=>{Xf();Qf();em();Iv();nm();jW=AW(OW(RW(import.meta.url)),"../../modes/design/entry.js"),$w=PW("runtimeConfig",(e,t)=>({entryPoints:[{in:jW,out:t.entryOut??"entry"}],bundle:!0,format:"esm",platform:"browser",sourcemap:t.sourcemap??!0,sourcesContent:t.sourcemap??!0,target:t.target??["es2020"],minify:t.minify??!1,jsx:"automatic",jsxImportSource:fa(t.framework),loader:pa,alias:t.alias??t.esbuild?.alias??rm(t.framework),define:ma({framework:t.framework,nodeEnv:t.nodeEnv,baseUrl:t.baseUrl}),treeShaking:!0,splitting:!0,chunkNames:"chunks/[name]-[hash]",assetNames:"assets/[name]-[hash]",external:da,outExtension:{".js":".js",".css":".css"}}))});var tD={};C(tD,{onRebuild:()=>Nw});import{defineEsPlugin as DW}from"@jucie.io/engine-esbuild";var Nw,Tw=f(()=>{Nw=DW("on-rebuild",e=>{let t=e("cache"),r=e("log");return n=>{n.onEnd(()=>{let o=t.get(["sseClients"]);try{if(!o)return;for(let s of o)s.write(`event: change
65
65
  data: {}
66
66
 
67
- `)}catch(s){r.error("SSE broadcast failed",{error:s.message})}})}})});import{defineEsPlugin as hB}from"@jucie.io/engine-esbuild";function gB(e){let t=e.location;return t?`${e.text} (${t.file}:${t.line}:${t.column})`:e.text}function Tp({onFirstBuild:e}={}){return hB("build-status",t=>{let r=t("log"),n=!0;return o=>{o.onEnd(s=>{let a=(s.errors??[]).map(gB);a.length&&r.error("stage bundle build failed",{errors:a}),n&&(n=!1,e?.({errors:a}))})}})}var l_=f(()=>{i(gB,"formatError");i(Tp,"buildStatus")});function zp(e,{onFirstBuild:t}={}){e.esBuild.use(xR,bi,Si,dp,fp,Np,Tp({onFirstBuild:t}))}var u_=f(()=>{_R();up();pp();Tx();zx();c_();l_();i(zp,"watchDevCombined")});import{defineEsConfig as yB}from"@jucie.io/engine-esbuild";var vR,wR=f(()=>{ip();ap();cp();vR=yB("projectConfig",(e,t)=>({entryPoints:[{in:"@components",out:"components"},{in:"jucie:main",out:"user-main"}],bundle:!0,format:"esm",platform:"browser",sourcemap:!0,sourcesContent:!0,target:["es2020"],jsx:"automatic",jsxImportSource:vi(t.framework),loader:_i,define:wi({framework:t.framework}),treeShaking:!0,splitting:!1,outExtension:{".js":".js",".css":".css"}}))});var Ri,d_=f(()=>{Ri={vue:{framework:"vue","framework-jsx-runtime":"vue/jsx-runtime"},react:{framework:"react","framework-jsx-runtime":"react/jsx-runtime","framework-dom":"react-dom","framework-dom-client":"react-dom/client"},preact:{framework:"preact","framework-jsx-runtime":"preact/jsx-runtime","framework-hooks":"preact/hooks","framework-compat":"preact/compat"}}});function bR(e){let t=Ri[e]||Ri.react,r={};for(let[n,o]of Object.entries(t))r[o]=`/${n}.js`;return r}var SR=f(()=>{d_();i(bR,"frameworkUrlMap")});import{defineEsPlugin as xB}from"@jucie.io/engine-esbuild";function _B(e){return e.replace(/[.*+?^${}()|[\]\\/]/g,"\\$&")}var kR,$R=f(()=>{SR();i(_B,"escapeRegex");kR=xB("external-framework",e=>{let t=e("cache");return r=>{let n=t.get(["jucieConfig","framework"])||"react",o=bR(n),s=new RegExp(`^(${Object.keys(o).map(_B).join("|")})$`);r.onResolve({filter:s},a=>({path:o[a.path],external:!0})),r.onResolve({filter:/^jucie:sdk$/},()=>({path:"/sdk.js",external:!0}))}})});function Cp(e,{onFirstBuild:t}={}){e.esBuild.use(vR,bi,Si,kR,Np,Tp({onFirstBuild:t}))}var p_=f(()=>{wR();up();pp();$R();c_();l_();i(Cp,"watchProject")});import{existsSync as ER,readdirSync as vB}from"fs";import{join as wB}from"path";function Ip(e){let t=lp(e.components||e.componentsDir);if(t.some(o=>o.type==="library")||t.some(o=>o.type==="directory"&&ER(o.path)&&vB(o.path).some(s=>s.endsWith(".js")&&s!=="index.js")))return!0;let n=e.projectRoot||process.cwd();return ER(wB(n,"src","main.js"))}var f_=f(()=>{Nx();i(Ip,"hasProjectCode")});import{existsSync as NR}from"fs";import{join as m_}from"path";function TR(e){return NR(m_(e,"entry.js"))||NR(m_(e,"main.js"))}function Pp(e,t="react"){if(!e)return null;let r=m_(e,t);return TR(r)?r:TR(e)?e:null}var h_=f(()=>{i(TR,"hasRuntimeBundle");i(Pp,"resolvePrebuiltStageDir")});function Rp(e){return{[g_]:String(e)}}function zR(e,...t){let r="";for(let n=0;n<e.length;n++)if(r+=e[n],n<t.length){let o=t[n];r+=o&&o[g_]!==void 0?o[g_]:String(o).replace(/[&<>"']/g,s=>bB[s])}return r}var bB,g_,CR=f(()=>{bB={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},g_=Symbol("html.raw");i(Rp,"raw");i(zR,"html")});function SB(e){return!e||!Object.keys(e).length?"":`<script type="importmap">
67
+ `)}catch(s){r.error("SSE broadcast failed",{error:s.message})}})}})});var rD,nD=f(()=>{oo();rD=ms("hmr",()=>({slot:"body:end",render:({data:e,raw:t})=>t(`<script>
68
+ if (typeof EventSource !== 'undefined') {
69
+ const es = new EventSource(${JSON.stringify(e.hmrPath??"/hmr")});
70
+ es.addEventListener('change', () => { location.reload(); });
71
+ }
72
+ </script>`)}))});var zw=f(()=>{kv()});function MW(e){return!e||!Object.keys(e).length?"":`<script type="importmap">
68
73
  ${JSON.stringify({imports:e},null,2)}
69
- </script>`}var Jc,y_=f(()=>{CR();i(SB,"renderImportMap");Jc=i(({title:e,scriptSrc:t,stylesheets:r=[],importMap:n=null,hmrPath:o="/hmr"})=>zR`<!DOCTYPE html>
74
+ </script>`}var hu,Cw=f(()=>{zw();i(MW,"renderImportMap");hu=i(({title:e,scriptSrc:t,stylesheets:r=[],importMap:n=null,hmrPath:o="/hmr"})=>ro`<!DOCTYPE html>
70
75
  <html lang="en">
71
76
  <head>
72
77
  <meta charset="UTF-8" />
73
78
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
74
79
  <title>${e}</title>
75
- ${Rp(SB(n))}
76
- ${Rp(r.map(s=>`<link rel="stylesheet" href="${s}">`).join(`
80
+ ${to(MW(n))}
81
+ ${to(r.map(s=>`<link rel="stylesheet" href="${s}">`).join(`
77
82
  `))}
78
83
  <style>
79
84
  * { box-sizing: border-box; }
@@ -85,6 +90,23 @@ ${JSON.stringify({imports:e},null,2)}
85
90
  body { position: absolute; top: 0; left: 0; will-change: transform; backface-visibility: hidden; transform-style: preserve-3d; }
86
91
  #app, #temp, #components { display: contents; }
87
92
  #app > *, #temp > *, #components > * { position: absolute !important; }
93
+ .descriptor-pill {
94
+ display: inline; vertical-align: baseline;
95
+ position: relative; cursor: pointer; user-select: all;
96
+ line-height: 0; color: transparent;
97
+ letter-spacing: 0; word-spacing: 0;
98
+ }
99
+ .descriptor-pill::before {
100
+ content: attr(data-label);
101
+ background: rgba(124, 109, 224, 0.18);
102
+ border: 1px solid rgba(124, 109, 224, 0.3);
103
+ color: #c4bbf0; font-family: monospace;
104
+ white-space: nowrap; vertical-align: middle;
105
+ }
106
+ .descriptor-pill:hover::before {
107
+ background: rgba(124, 109, 224, 0.28);
108
+ border-color: rgba(124, 109, 224, 0.45);
109
+ }
88
110
  </style>
89
111
  </head>
90
112
  <body>
@@ -94,95 +116,123 @@ ${JSON.stringify({imports:e},null,2)}
94
116
  <script type="module" src="${t}"></script>
95
117
  <script>
96
118
  if (typeof EventSource !== 'undefined') {
97
- const es = new EventSource(${Rp(JSON.stringify(o))});
119
+ const es = new EventSource(${to(JSON.stringify(o))});
98
120
  es.addEventListener('change', () => { location.reload(); });
99
121
  }
100
122
  </script>
101
123
  </body>
102
- </html>`,"default")});import{defineRoutes as kB}from"@jucie.io/engine-server";import{join as $B}from"path";function Oi(e,{stylesheets:t}={}){return kB((r,n)=>{let o=r("log");function s(a){try{let c=typeof t=="function"?t():t??[];return a.html(e({title:`${n.name||"Jucie App"}`,scriptSrc:"/main.js",stylesheets:c}))}catch(c){return o.error("render failed",{error:c.message}),a.text("Internal Server Error",500)}}return i(s,"renderShell"),[{method:"get",path:"/assets/*",handler:({respond:a,req:c})=>{let l=c.path.replace("/assets/",""),u=decodeURIComponent(l),d=$B(n.assets,u);return a.file(d)}},{method:"get",path:"/",handler:({respond:a})=>s(a)},{method:"get",path:"/*",handler:({respond:a})=>s(a)}]})}var x_=f(()=>{i(Oi,"shellRoutes")});import{defineRoutes as EB}from"@jucie.io/engine-server";import{resolve as Op,join as Ap}from"path";import{existsSync as jp}from"fs";function zB(e){let t=Ap(e,"entry.js");if(jp(t))return t;let r=Ap(e,"main.js");return jp(r)?r:t}function Yc(e="design"){return EB((t,r)=>{let n=t("log"),o=r.prebuiltStageDir||null,s=r.framework||"react",a=[{method:"get",path:"/main.js",handler:({respond:c})=>{try{let l=o?zB(o):Op(r.outdir,"entry.js");return c.file(l)}catch(l){return n.error("failed to serve main.js",{error:l.message}),c.text("Internal Server Error",500)}}},{method:"get",path:"/chunks/*",handler:({respond:c,req:l})=>{try{let u=o||Op(r.outdir);return c.file(Ap(u,l.path.slice(1)))}catch(u){return n.error("failed to serve chunk",{error:u.message,path:l.path}),c.text("Internal Server Error",500)}}},{method:"get",path:"/config.json",handler:({respond:c})=>c.json({name:r.name??null,version:r.version??null,framework:s,metadata:r.metadata??null,mode:r.mode??e})},{method:"get",path:"/hmr",handler:({res:c,respond:l})=>{let u=t("cache");try{if(c.setHeader("Content-Type","text/event-stream"),c.setHeader("Cache-Control","no-cache"),c.setHeader("Connection","keep-alive"),c.write(`: connected
124
+ </html>`,"default")});import{defineRoutes as ZW}from"@jucie.io/engine-server";import{join as LW}from"path";function ka(e,{stylesheets:t}={}){return ZW((r,n)=>{let o=r("log");function s(a){try{let c=typeof t=="function"?t():t??[];return a.html(e({title:`${n.name||"Jucie App"}`,scriptSrc:"/main.js",stylesheets:c}))}catch(c){return o.error("render failed",{error:c.message}),a.text("Internal Server Error",500)}}return i(s,"renderShell"),[{method:"get",path:"/assets/*",handler:({respond:a,req:c})=>{let l=c.path.replace("/assets/",""),u=decodeURIComponent(l),d=LW(n.assets,u);return a.file(d)}},{method:"get",path:"/",handler:({respond:a})=>s(a)},{method:"get",path:"/*",handler:({respond:a})=>s(a)}]})}var Iw=f(()=>{i(ka,"shellRoutes")});var sD={};C(sD,{default:()=>bm});import{defineRoutes as FW}from"@jucie.io/engine-server";import{resolve as Pw,join as oD}from"path";function UW(e){let t=Tn[e]??Tn.react;return[...Object.keys(t),"sdk"].flatMap(r=>[`${r}.js`,`${r}.js.map`])}function bm(e="design"){return FW((t,r)=>{let n=t("log");return[{method:"get",path:"/main.js",handler:({respond:o})=>{try{return o.file(Pw(r.outdir,"entry.js"))}catch(s){return n.error("failed to serve main.js",{error:s.message}),o.text("Internal Server Error",500)}}},{method:"get",path:"/chunks/*",handler:({respond:o,req:s})=>{try{return o.file(oD(Pw(r.outdir),s.path.slice(1)))}catch(a){return n.error("failed to serve chunk",{error:a.message,path:s.path}),o.text("Internal Server Error",500)}}},{method:"get",path:"/config.json",handler:({respond:o})=>o.json({name:r.name??null,version:r.version??null,framework:r.framework||"react",metadata:r.metadata??null,mode:r.mode??e})},{method:"get",path:"/hmr",handler:({res:o,respond:s})=>{let a=t("cache");try{if(o.setHeader("Content-Type","text/event-stream"),o.setHeader("Cache-Control","no-cache"),o.setHeader("Connection","keep-alive"),o.write(`: connected
125
+
126
+ `),a){let c=a.get("sseClients")||new Set;c.add(o),o.on("close",()=>c.delete(o)),a.set(["sseClients"],c)}return s.handled()}catch(c){n.error("HMR connection failed",{error:c.message})}}},...UW(r.framework||"react").map(o=>({method:"get",path:`/${o}`,handler:({respond:s})=>{try{return s.file(oD(Pw(r.outdir),o))}catch(a){return n.error("failed to serve runtime entry",{error:a.message,file:o}),s.text("Internal Server Error",500)}}}))]})}var Ow=f(()=>{tm();i(UW,"runtimeEntryFiles");i(bm,"jsRoutes")});var iD={};C(iD,{createDevServer:()=>KW});import{Result as qW}from"@jucie.io/result";import{Engine as BW}from"@jucie.io/engine";import{Server as HW}from"@jucie.io/engine-server";import{State as VW}from"@jucie.io/engine-state";import{Matcher as GW}from"@jucie.io/state-matcher";import{EsBuild as WW}from"@jucie.io/engine-esbuild";import{LocalProvider as JW}from"@jucie.io/engine-storage/providers/local";async function KW(e={}){let t={error(){},warn(){},info(){},debug(){}},r=null;try{let n=e.framework||"react",o=await la(e.views,{onWarn:m=>console.warn(` \u26A0\uFE0F ${m}`)});r=BW.create().install(En.configure({...e,templates:o,fragments:[rD]}),VW.configure({plugins:[GW]}),HW.configure(e),gn.configure({storage:{name:"state",provider:e.storageProvider??JW,root:e.projectRoot??e.sceneGraph,mode:"path",...e.storageConfig??{}},branch:e.branch||"main",namespaces:e.namespaces??{},configs:[ta,ra,na,oa,sa]}),_n.configure(e),WW.configure(e)),t=r.log.child({ns:"stage:dev"}),r.cache.set(["jucieConfig"],e),r.esBuild.use($w,Jl,Pl,Rl,Dl,Ul,Hl,Bl,Gl,Nw);let s=r.html.list().includes("index")?r.html.renderer("index"):hu;r.server.use(bm("dev"),ka(s));let a={"access-control-allow-origin":"*","access-control-allow-methods":"GET, POST, PUT, DELETE, OPTIONS","access-control-allow-headers":"content-type, authorization"};r.server.hooks({onRequest:({req:m,respond:h})=>{if(m.method==="OPTIONS")return h.text("",204,a)},onSend:(m,h)=>{h&&(h.headers={...a,...h.headers})}}),await r.server.listen();let c=await r.cas.load(),{ledger:l,ledgerTombstones:u,...d}=c;r.state.load(d),r.storeParser.onChange(m=>{if(m.type==="loaded"){for(let[h,g]of Object.entries(m.stores))r.state.set([".stores",h],g);return}if(m.type==="deleted"){r.state.remove([".stores",m.name]);return}r.state.set([".stores",m.name],m.store)}),r.state.matcher.createMatcher([".stores"],m=>r.storeParser.writeAll(m)),await r.storeParser.start(),Object.keys(r.storeParser.getAllStores()).length===0&&r.state.set([".stores","default"],{});let{errors:p}=await r.esBuild.watch();if(p?.length)throw new Error(`Stage bundle failed to build:
127
+ ${p.map(m=>m.text).join(`
128
+ `)}`);return t.info("dev server started",{port:r.server.getHttpServer().address().port}),{type:"cli",basePath:`http://localhost:${r.server.getHttpServer().address().port}`,view:e.view||"preview",nodeId:null,name:e.name||null}}catch(n){t.error("dev server failed",{error:n.message,stack:n.stack});try{await r?.server?.stop()}catch{}return qW.failure(n)}}var aD=f(()=>{Gi();df();bf();Sf();Ew();Kl();Ol();jl();Ml();ql();Vl();cm();Wl();Tw();oo();Mf();nD();Cw();Iw();Ow();i(KW,"createDevServer")});import{ServiceProvider as tJ}from"@jucie.io/engine";import{watch as rJ}from"chokidar";import{readFile as nJ}from"fs/promises";import{readdirSync as oJ,existsSync as sJ,statSync as iJ}from"fs";import{join as uD,basename as Rw}from"path";var po,Pe,Es,Nr,$a,Sm,km,dD,yu,jw,$m,pD,xu,Dw,Em,gu,fD=f(()=>{sm();im();am();Em=class Em extends tJ{constructor(){super(...arguments);$(this,$a);$(this,km);$(this,yu);$(this,$m);$(this,xu);$(this,po,null);$(this,Pe,null);$(this,Es,[]);$(this,Nr,new Map)}actions(){return{start:()=>this.start(),build:()=>this.build(),parse:(r,n)=>this.parse(r,n),stopWatching:()=>this.stopWatching(),onChange:r=>(y(this,Es).push(r),()=>{O(this,Es,y(this,Es).filter(n=>n!==r))}),getAllNodes:()=>this.getAllNodes(),getNodeIds:r=>this.getNodeIds(r),getComponentNames:()=>[...y(this,Nr).keys()]}}async start(r){try{return O(this,Pe,r||k(this,km,dD).call(this)),y(this,Pe)?(console.log(`jux: starting \u2014 ${y(this,Pe)}`),await this.scanDirectory(y(this,Pe)),this.watchDirectory(y(this,Pe)),this):(console.log("jux: no components directory configured, skipping"),this)}catch(n){return console.error("jux: start error",n),null}}async build(){return O(this,Pe,this.config.components),y(this,Pe)?(await this.scanDirectory(y(this,Pe)),this.getAllNodes()):{}}async scanDirectory(r){if(O(this,Pe,r||y(this,Pe)),!y(this,Pe))return console.log("jux: no components directory set, skipping scan"),{};if(!sJ(y(this,Pe)))return console.log(`jux: components directory does not exist yet: ${y(this,Pe)}`),{};let n=oJ(y(this,Pe)).filter(a=>a.endsWith(".jux")&&a!=="index.jux").filter(a=>iJ(uD(y(this,Pe),a)).isFile());console.log(`jux: scanning ${n.length} component(s) in ${y(this,Pe)}`);for(let a of n){let c=uD(y(this,Pe),a),l=Rw(a,".jux");await k(this,xu,Dw).call(this,c,l)}let o=this.getAllNodes(),s=Object.keys(o).length;return console.log(`jux: scan complete \u2014 ${y(this,Nr).size} component(s), ${s} node(s)`),k(this,$a,Sm).call(this,"loaded",{nodes:o}),o}watchDirectory(r){O(this,Pe,r||y(this,Pe)),y(this,Pe)&&(console.log(`jux: watching ${y(this,Pe)}`),O(this,po,rJ(y(this,Pe),{ignored:/(^|[\/\\])\../,persistent:!0,ignoreInitial:!0,awaitWriteFinish:{stabilityThreshold:100,pollInterval:50}})),y(this,po).on("add",n=>k(this,yu,jw).call(this,n,"add")).on("change",n=>k(this,yu,jw).call(this,n,"change")).on("unlink",n=>k(this,$m,pD).call(this,n)))}stopWatching(){y(this,po)&&(y(this,po).close(),O(this,po,null))}parse(r,n){let{script:o,template:s}=Zl(r);if(!s?.content)return y(this,Nr).delete(n),{};let{localNames:a}=Fl(o?.content??""),{nodes:c}=Ll(s.content,a,{componentName:n});return y(this,Nr).set(n,new Map(Object.entries(c))),c}getAllNodes(){let r={};for(let n of y(this,Nr).values())for(let[o,s]of n)r[o]=s;return r}getNodeIds(r){let n=y(this,Nr).get(r);return n?[...n.keys()]:[]}};po=new WeakMap,Pe=new WeakMap,Es=new WeakMap,Nr=new WeakMap,$a=new WeakSet,Sm=i(function(r,n){for(let o of y(this,Es))o({type:r,...n})},"#emit"),km=new WeakSet,dD=i(function(){let r=this.config.components;return r?typeof r=="string"?r:Array.isArray(r)?r.find(o=>typeof o=="string")??null:null:null},"#resolveComponentsDir"),yu=new WeakSet,jw=i(async function(r,n){if(!r.endsWith(".jux"))return;let o=Rw(r,".jux"),s=this.getNodeIds(o);await k(this,xu,Dw).call(this,r,o);let a=Object.fromEntries(y(this,Nr).get(o)??new Map),c=Object.keys(a).length;console.log(`jux: ${n} ${o} \u2014 ${c} node(s)`),k(this,$a,Sm).call(this,"updated",{name:o,nodes:a,prevNodeIds:s})},"#handleFile"),$m=new WeakSet,pD=i(function(r){if(!r.endsWith(".jux"))return;let n=Rw(r,".jux"),o=this.getNodeIds(n);y(this,Nr).delete(n),console.log(`jux: deleted ${n} \u2014 removing ${o.length} node(s)`),k(this,$a,Sm).call(this,"deleted",{name:n,nodeIds:o})},"#handleDeleted"),xu=new WeakSet,Dw=i(async function(r,n){try{let o=await nJ(r,"utf8");this.parse(o,n)}catch(o){console.error(`jux: failed to parse ${n}:`,o.message)}},"#parseFile"),i(Em,"JuxParser"),_e(Em,"manifest",{name:"JuxParser",namespace:"juxParser",version:"1.0.0"});gu=Em});var mD=f(()=>{fD()});var hD,gD=f(()=>{zw();hD=i(({title:e,scriptSrc:t})=>ro`<!DOCTYPE html>
129
+ <html lang="en">
130
+ <head>
131
+ <meta charset="UTF-8" />
132
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
133
+ <title>${e}</title>
134
+ <style>
135
+ * { box-sizing: border-box; }
136
+ body, html { font-family: Helvetica, Arial, sans-serif; margin: 0; padding: 0; }
137
+ body {
138
+ min-width: 100vw;
139
+ min-height: 100vh;
140
+ overflow: auto;
141
+ }
142
+ </style>
143
+ </head>
144
+ <body>
145
+ <div id="app" data-rid="app" data-node-id="app"></div>
146
+ <script type="module" src="${t}"></script>
147
+ </body>
148
+ </html>`,"default")});import{defineContracts as aJ}from"@jucie.io/engine-socket/server";var yD,xD=f(()=>{yD=aJ("ledger",e=>{let t=e("state");return{sync:{handler:(r,n)=>{t.ledger.apply(r),n.broadcast("ledger:apply",r)}},requestSnapshot:{handler:()=>t.ledger.snapshot()}}})});import{defineContracts as cJ}from"@jucie.io/engine-socket/server";var _D,vD=f(()=>{_D=cJ("presence",e=>{let t=e("cache");return{pointer:{handler:(r,n)=>{let s=(t.get(["presence","users"])??{})[n.id];s&&(s.pointer=r,n.broadcast("presence:update",n.id,s))}},selection:{handler:(r,n)=>{let s=(t.get(["presence","users"])??{})[n.id];s&&(s.selectedIds=r,n.broadcast("presence:update",n.id,s))}}}})});import{defineContracts as lJ}from"@jucie.io/engine-socket/server";var wD,bD=f(()=>{wD=lJ("assets",e=>{let[t,r]=e("assets","cache");return{requestSnapshot:{handler:()=>r.get(["assets"])??{}},check:{handler:async n=>{try{let o=await t.checkFileExists(n),s=o?await t.getNextAvailableName(n):n;return{exists:o,filename:n,nextAvailable:s}}catch(o){return{exists:!1,error:o.message}}}},upload:{timeoutMs:6e4,handler:async(n,o)=>{try{let s=Buffer.isBuffer(o)?o:(o instanceof Uint8Array||o instanceof ArrayBuffer,Buffer.from(o)),a=await t.saveUploadedFile(s,n);return{success:!0,id:a.id,url:a.url,asset:a}}catch(s){return console.error("[assets] upload failed:",s.message),{success:!1,error:s.message}}}},delete:{handler:async n=>{try{return await t.deleteAsset(n),{success:!0,path:n}}catch(o){return{success:!1,error:o.message}}}}}})});import{defineContracts as uJ}from"@jucie.io/engine-socket/server";var SD,kD=f(()=>{SD=uJ("stores",e=>{let t=e("state");return{sync:{handler:r=>{if(r)for(let[n,o]of Object.entries(r))o?t.set([".stores",n],o):t.remove([".stores",n])}},requestSnapshot:{handler:()=>t.get([".stores"])??{}}}})});var $D=f(()=>{});import{ServiceProvider as dJ}from"@jucie.io/engine";import{readFile as pJ}from"fs/promises";import{basename as fJ}from"path";function ED(e){let t=new Set,r=/\.([a-zA-Z_][\w-]*)/g,n;for(;n=r.exec(e);)t.add(n[1]);return[...t].sort()}async function mJ(e,t){let r=[];for(let n of e)try{if(typeof n=="string"){let s=await(await fetch(n)).text();r.push({url:n,type:"remote",classNames:ED(s)})}else if(n&&typeof n=="object"&&n.path){let o=await pJ(n.path,"utf-8");r.push({name:n.name??null,path:n.path,type:"local",classNames:ED(o)})}}catch(o){t.warn("failed to load library",{entry:n,error:o.message})}return r}var In,Tm,Nm,ND=f(()=>{Tm=class Tm extends dJ{constructor(){super(...arguments);$(this,In,[])}actions(){return{load:()=>this.load(),getEntries:()=>y(this,In),getClassNames:()=>y(this,In).flatMap(r=>r.classNames),findLocal:r=>y(this,In).find(n=>n.type==="local"&&fJ(n.path)===r)}}async load(){let r=this.config.libraries??[],n=this.inject("log")?.child({ns:"libraries"})??{warn(){},info(){}};O(this,In,await mJ(r,n));let o=this.inject("state");if(o){let s=y(this,In).flatMap(a=>a.classNames);o.set(["libraryClassNames"],s)}return y(this,In)}};In=new WeakMap,i(Tm,"Libraries"),_e(Tm,"manifest",{name:"Libraries",namespace:"libraries",version:"1.0.0",description:"Manages CSS library loading, class name extraction, and serving"});Nm=Tm;i(ED,"extractClassNames");i(mJ,"normalizeLibraries")});var TD={};C(TD,{Libraries:()=>Nm});var zD=f(()=>{ND()});var CD={};C(CD,{default:()=>gJ});import{defineRoutes as hJ}from"@jucie.io/engine-server";var gJ,ID=f(()=>{gJ=hJ("libraries",e=>{let t=e("libraries");return[{method:"get",path:"/:filename",handler:({respond:r,req:n})=>{let o=t.findLocal(n.params.filename);return o?r.file(o.path):r.text("Not found",404)}},{method:"get",path:"/classnames",handler:({respond:r})=>{let n=t.getClassNames(),o=[...new Set(n)].sort();return r.json({classNames:o})}}]})});var PD={};C(PD,{componentsConfig:()=>xJ});import{defineEsConfig as yJ}from"@jucie.io/engine-esbuild";var xJ,OD=f(()=>{Xf();Qf();em();nm();xJ=yJ("componentsConfig",(e,t)=>({entryPoints:[{in:"@components",out:"components"},{in:"jucie:main",out:"user-main"}],bundle:!0,format:"esm",platform:"browser",target:t.target??["es2020"],outdir:t.componentsOutdir,...t.projectRoot?{absWorkingDir:t.projectRoot}:{},sourcemap:t.sourcemap??!0,sourcesContent:t.sourcemap??!0,minify:t.minify??!1,jsx:"automatic",jsxImportSource:fa(t.framework),jsxDev:!1,loader:pa,define:ma({framework:t.framework,nodeEnv:t.nodeEnv,baseUrl:t.baseUrl}),treeShaking:!0,splitting:!0,chunkNames:"project-chunks/[name]-[hash]",assetNames:"project-assets/[name]-[hash]",external:da,outExtension:{".js":".js",".css":".css"},logLevel:"silent"}))});function AD(e){let t=Tn[e]||Tn.react,r={};for(let[n,o]of Object.entries(t))r[o]=`/${n}.js`;return r}var RD=f(()=>{tm();i(AD,"frameworkUrlMap")});var jD={};C(jD,{externalFramework:()=>wJ});import{defineEsPlugin as _J}from"@jucie.io/engine-esbuild";function vJ(e){return e.replace(/[.*+?^${}()|[\]\\/]/g,"\\$&")}var wJ,DD=f(()=>{RD();i(vJ,"escapeRegex");wJ=_J("external-framework",e=>{let t=e("cache");return r=>{let n=t.get(["jucieConfig","framework"])||"react",o=AD(n),s=new RegExp(`^(${Object.keys(o).map(vJ).join("|")})$`);r.onResolve({filter:s},a=>({path:o[a.path],external:!0})),r.onResolve({filter:/^jucie:sdk$/},()=>({path:"/sdk.js",external:!0}))}})});var MD={};C(MD,{onBuildResult:()=>SJ});import{defineEsPlugin as bJ}from"@jucie.io/engine-esbuild";var SJ,ZD=f(()=>{SJ=bJ("on-build-result",e=>{let t=e("cache"),r=e("log");return n=>{n.onEnd(o=>{let s=(o.errors??[]).map(u=>({text:u.text,file:u.location?.file??null,line:u.location?.line??null,column:u.location?.column??null,lineText:u.location?.lineText??null}));t.set(["componentsBuild","errors"],s),s.length&&r?.warn?.("project components failed to build",{count:s.length});let a=t.get(["sseClients"]);if(!a)return;let c=s.length?"build-error":"change",l=s.length?JSON.stringify({errors:s}):"{}";for(let u of a)try{u.write(`event: ${c}
149
+ data: ${l}
103
150
 
104
- `),u){let d=u.get("sseClients")||new Set;d.add(c),c.on("close",()=>d.delete(c)),u.set(["sseClients"],d)}return l.handled()}catch(d){n.error("HMR connection failed",{error:d.message})}}}];if(o){let c=Ri[s]||Ri.react;for(let l of[...Object.keys(c),"sdk"])a.push({method:"get",path:`/${l}.js`,handler:({respond:u})=>u.file(Ap(o,`${l}.js`))});a.push({method:"get",path:"/components.js",handler:({respond:l})=>{let u=Op(r.outdir,"components.js");return jp(u)?l.file(u):l.text(NB,200,IR)}}),a.push({method:"get",path:"/user-main.js",handler:({respond:l})=>{let u=Op(r.outdir,"user-main.js");return jp(u)?l.file(u):l.text(TB,200,IR)}})}return a})}var IR,NB,TB,__=f(()=>{d_();IR={"content-type":"text/javascript; charset=utf-8"},NB=`export default {};
105
- `,TB=`export const __jucieMainStub = true;
106
- `;i(zB,"prebuiltRuntimePath");i(Yc,"jsRoutes")});var PR={};R(PR,{createDevServer:()=>jB});import{Result as CB}from"@jucie.io/result";import{Engine as IB}from"@jucie.io/engine";import{Server as PB}from"@jucie.io/engine-server";import{State as RB}from"@jucie.io/engine-state";import{Matcher as OB}from"@jucie.io/state-matcher";import{EsBuild as AB}from"@jucie.io/engine-esbuild";async function jB(e={}){let t={error(){},warn(){},info(){},debug(){}},r=null;try{let n=e.framework||"react";e.prebuiltStageDir=Pp(e.stageBundles,n),r=IB.create().install(RB.configure({plugins:[OB]}),PB.configure(e),nn.configure({storage:{name:"state",provider:e.storageProvider??"local",root:e.projectRoot??e.sceneGraph,mode:"path",...e.storageConfig??{}},branch:e.branch||"main",namespaces:e.namespaces??{},configs:[di,pi,fi,mi,hi]}),an.configure(e),AB.configure(e)),t=r.log.child({ns:"stage:dev"}),r.cache.set(["jucieConfig"],e);let o=e.prebuiltStageDir?Ip(e):!0,s,a=new Promise(h=>{s=h});e.prebuiltStageDir?o&&Cp(r,{onFirstBuild:s}):zp(r,{onFirstBuild:s}),r.server.use(Yc("dev"),Oi(Jc));let c={"access-control-allow-origin":"*","access-control-allow-methods":"GET, POST, PUT, DELETE, OPTIONS","access-control-allow-headers":"content-type, authorization"};r.server.hooks({onRequest:({req:h,respond:m})=>{if(h.method==="OPTIONS")return m.text("",204,c)},onSend:(h,m)=>{m&&(m.headers={...c,...m.headers})}}),await r.server.listen();let l=await r.cas.load(),{ledger:u,ledgerTombstones:d,...p}=l;if(r.state.load(p),await r.storeParser.start(),o){await r.esBuild.watch();let h=await a;if(h.errors.length)throw new Error(`Stage bundle failed to build:
107
- ${h.errors.join(`
108
- `)}`)}return t.info("dev server started",{port:r.server.getHttpServer().address().port}),{basePath:`http://localhost:${r.server.getHttpServer().address().port}`,view:e.view||"preview",env:e.env||"dev",nodeId:null,name:e.name||null}}catch(n){t.error("dev server failed",{error:n.message,stack:n.stack});try{await r?.server?.stop()}catch{}return CB.failure(n)}}var RR=f(()=>{oi();Id();Ud();qd();u_();p_();f_();h_();y_();x_();__();i(jB,"createDevServer")});import{defineContracts as FB}from"@jucie.io/engine-socket/server";var jR,DR=f(()=>{jR=FB("ledger",e=>{let t=e("state");return{sync:{handler:(r,n)=>{t.ledger.apply(r),n.broadcast("ledger:apply",r)}}}})});import{defineContracts as UB}from"@jucie.io/engine-socket/server";var MR,ZR=f(()=>{MR=UB("presence",e=>{let t=e("cache");return{pointer:{handler:(r,n)=>{let s=(t.get(["presence","users"])??{})[n.id];s&&(s.pointer=r,n.broadcast("presence:update",n.id,s))}},selection:{handler:(r,n)=>{let s=(t.get(["presence","users"])??{})[n.id];s&&(s.selectedIds=r,n.broadcast("presence:update",n.id,s))}}}})});import{defineContracts as qB}from"@jucie.io/engine-socket/server";var LR,FR=f(()=>{LR=qB("assets",e=>{let t=e("staticAssets");return{check:{handler:async r=>{try{let n=await t.checkFileExists(r),o=n?await t.getNextAvailableName(r):r;return{exists:n,filename:r,nextAvailable:o}}catch(n){return{exists:!1,error:n.message}}}},upload:{timeoutMs:6e4,handler:async(r,n)=>{try{let o=Buffer.from(n),s=await t.saveUploadedFile(o,r);return{success:!0,id:s.id,url:s.url,asset:s}}catch(o){return{success:!1,error:o.message}}}}}})});import{defineContracts as HB}from"@jucie.io/engine-socket/server";async function Dp(e,t=null){let[r,n]=e("aiHistory","socket"),o=await r.listSessions();return t?t.publish("ai:sessions:list",o):n.broadcast("ai:sessions:list",o),o}var UR,Mp=f(()=>{i(Dp,"pushAiSessionsList");UR=HB("ai:sessions",e=>{let t=e("aiHistory");return{refresh:{handler:async(r,n)=>{let o=await t.listSessions();return n.publish("ai:sessions:list",o),o}}}})});import{defineContracts as BB}from"@jucie.io/engine-socket/server";var qR,HR=f(()=>{Mp();qR=BB("ai:session",e=>{let t=e("aiHistory");return{create:{handler:async()=>{try{return await t.createSession()}catch(r){return{error:r.message}}}},delete:{handler:async r=>{try{let n=await t.deleteSession(r);return await Dp(e),n}catch(n){return{error:n.message}}}},"messages:get":{handler:async r=>{try{let n=await t.getMessages(r);return{id:r,messages:n}}catch(n){return{error:n.message}}}},"attachment:save":{timeoutMs:3e4,handler:async(r,{name:n,mimeType:o,data:s})=>{try{return await t.saveAttachment(r,{name:n,mimeType:o,data:s})}catch(a){return{error:a.message}}}}}})});import{defineContracts as VB}from"@jucie.io/engine-socket/server";function VR(e){Un.get(e)?.abort(),Un.delete(e)}var Un,BR,GR=f(()=>{Mp();Un=new Map,BR=VB("ai:agent",e=>{let[t,r]=e("aiAgent","log");return{run:{timeoutMs:18e4,handler:async({prompt:n,sessionId:o,token:s,attachments:a}={},c)=>{Un.get(c.id)?.abort();let l=new AbortController;Un.set(c.id,l);try{let u=await t.run({prompt:n,sessionId:o,token:s,attachments:a,signal:l.signal,getContext:(d={})=>c.ask("ai:stage:context:capture",d),execute:d=>c.ask("ai:stage:operations:execute",{batch:d},{timeoutMs:6e4}),onProgress:d=>c.publish("ai:agent:progress",d)});return c.publish("ai:agent:response",{...u,sessionId:o}),u}catch(u){throw r.error("ai agent failed",{error:u.message}),c.publish("ai:agent:response",{error:u.message,sessionId:o}),u}finally{Un.get(c.id)===l&&Un.delete(c.id),await Dp(e)}}},stop:{handler:(n,o)=>{Un.get(o.id)?.abort(),Un.delete(o.id)}}}});i(VR,"abortAiRun")});import{ServiceProvider as GB}from"@jucie.io/engine";import{readFile as WB}from"fs/promises";import{basename as KB}from"path";function WR(e){let t=new Set,r=/\.([a-zA-Z_][\w-]*)/g,n;for(;n=r.exec(e);)t.add(n[1]);return[...t].sort()}async function JB(e,t){let r=[];for(let n of e)try{if(typeof n=="string"){let s=await(await fetch(n)).text();r.push({url:n,type:"remote",classNames:WR(s)})}else if(n&&typeof n=="object"&&n.path){let o=await WB(n.path,"utf-8");r.push({name:n.name??null,path:n.path,type:"local",classNames:WR(o)})}}catch(o){t.warn("failed to load library",{entry:n,error:o.message})}return r}var gn,Lp,Zp,KR=f(()=>{Lp=class Lp extends GB{constructor(){super(...arguments);k(this,gn,[])}actions(){return{load:()=>this.load(),getEntries:()=>y(this,gn),getClassNames:()=>y(this,gn).flatMap(r=>r.classNames),findLocal:r=>y(this,gn).find(n=>n.type==="local"&&KB(n.path)===r)}}async load(){let r=this.config.libraries??[],n=this.inject("log")?.child({ns:"libraries"})??{warn(){},info(){}};O(this,gn,await JB(r,n));let o=this.inject("state");if(o){let s=y(this,gn).flatMap(a=>a.classNames);o.set(["libraryClassNames"],s)}return y(this,gn)}};gn=new WeakMap,i(Lp,"Libraries"),Te(Lp,"manifest",{name:"Libraries",namespace:"libraries",version:"1.0.0",description:"Manages CSS library loading, class name extraction, and serving"});Zp=Lp;i(WR,"extractClassNames");i(JB,"normalizeLibraries")});var JR={};R(JR,{Libraries:()=>Zp});var YR=f(()=>{KR()});import{ServiceProvider as YB}from"@jucie.io/engine";var XB,XR,Ai,ji,Fp,qp,Up,QR=f(()=>{XB=0,XR=60*60*1e3,qp=class qp extends YB{constructor(){super(...arguments);k(this,ji);k(this,Ai,null)}setup({defineActions:r}){let n=this,o=parseInt(n.config.rateLimit??XB,10),s=n.config.serverApiKey;r(()=>({async authorize(a){var h;if(n.config.skipAuth)return{apiKey:s,user:null};let c=a.req.headers.authorization?.split(" ")[1];if(!c)return{apiKey:s,user:null};let u=await n.inject("auth").validateToken(c);if(!u.isValid)return{denied:!0,status:401,reason:u.error};let p=await n.inject("users").findOrCreate(u.userId);if(p.api_key)return{apiKey:p.api_key,user:p};if(o>0){await E(h=n,ji,Fp).call(h);let{sql:m}=n.inject("db"),g=new Date(Date.now()-XR),[{count:_}]=await m`
109
- SELECT COUNT(*)::int as count FROM usage_logs
110
- WHERE user_id = ${p.id} AND created_at > ${g}
111
- `;if(_>=o)return{denied:!0,status:429,reason:`Rate limit exceeded (${o}/hour). Add your own API key or purchase credits.`}}return s?{apiKey:s,user:p}:{denied:!0,status:402,reason:"No API key configured. Add your own Anthropic API key in settings."}},async logUsage({userId:a,inputTokens:c,outputTokens:l,cacheWriteTokens:u,cacheReadTokens:d,model:p}){var m;if(!a)return;await(await E(m=n,ji,Fp).call(m))`
112
- INSERT INTO usage_logs (user_id, input_tokens, output_tokens, cache_write_tokens, cache_read_tokens, model)
113
- VALUES (${a}, ${c}, ${l}, ${u??0}, ${d??0}, ${p})
114
- `},async getUsage(a,c=XR){var p;let l=await E(p=n,ji,Fp).call(p),u=new Date(Date.now()-c),[d]=await l`
115
- SELECT
116
- COUNT(*)::int as requests,
117
- COALESCE(SUM(input_tokens), 0)::int as total_input,
118
- COALESCE(SUM(output_tokens), 0)::int as total_output
119
- FROM usage_logs
120
- WHERE user_id = ${a} AND created_at > ${u}
121
- `;return d}}))}};Ai=new WeakMap,ji=new WeakSet,Fp=i(async function(){let{sql:r}=this.inject("db");return y(this,Ai)||O(this,Ai,r`
122
- CREATE TABLE IF NOT EXISTS usage_logs (
123
- id SERIAL PRIMARY KEY,
124
- user_id TEXT NOT NULL,
125
- input_tokens INTEGER NOT NULL DEFAULT 0,
126
- output_tokens INTEGER NOT NULL DEFAULT 0,
127
- cache_write_tokens INTEGER NOT NULL DEFAULT 0,
128
- cache_read_tokens INTEGER NOT NULL DEFAULT 0,
129
- model TEXT,
130
- created_at TIMESTAMPTZ DEFAULT now()
131
- )
132
- `.then(()=>r`
133
- CREATE INDEX IF NOT EXISTS idx_usage_user_created ON usage_logs(user_id, created_at)
134
- `).then(()=>!0)),await y(this,Ai),r},"#ensureTable"),i(qp,"AiGatewayService"),Te(qp,"manifest",{name:"AiGatewayService",namespace:"gateway",version:"1.0.0",description:"AI request authorization, rate limiting, and usage logging"});Up=qp});import{ServiceProvider as QB}from"@jucie.io/engine";var yn,xn,Bo,_n,Ho,Vp,eO,Gp,tO,Di,Hp,Xc,w_,Wp,Bp,rO=f(()=>{Wp=class Wp extends QB{constructor(){super(...arguments);k(this,_n);k(this,Vp);k(this,Gp);k(this,Di);k(this,Xc);k(this,yn,new Set);k(this,xn,new Set);k(this,Bo,new Set)}async initialize(r,n){console.log("AiChat: Initializing")}getters(){return{lastMessage:()=>y(this,xn).size>0?Array.from(y(this,xn)).pop():null,lastError:()=>y(this,Bo).size>0?Array.from(y(this,Bo)).pop():null,allMessages:()=>Array.from(y(this,xn)),allErrors:()=>Array.from(y(this,Bo)),operationsMetadata:()=>y(this,_n,Ho).operationsMetadata}}actions(r,n){return{subscribe:o=>{if(typeof o!="function")throw new Error("Subscriber must be a function");return y(this,yn).add(o),()=>y(this,yn).delete(o)},unsubscribe:o=>{if(typeof o!="function")throw new Error("Subscriber must be a function");if(!y(this,yn).has(o))throw new Error("Subscriber not found");y(this,yn).delete(o)},use:(...o)=>(y(this,_n,Ho).use(...o),this),executeOperation:(o,s,a)=>y(this,_n,Ho).executeOperation(o,s,a),executeBatch:o=>y(this,_n,Ho).executeBatch(o),clearHistory:()=>{y(this,xn).clear(),console.log("AiChat: History cleared")},sendMessage:async(o,s)=>{let a=E(this,Vp,eO).call(this);E(this,Di,Hp).call(this,{type:"user",text:o.prompt,timestamp:Date.now()});try{let c={...o.context,availableOperations:y(this,_n,Ho).operationsMetadata},l={"Content-Type":"application/json"};n.token&&(l.Authorization=`Bearer ${n.token}`);let u=await fetch(`${n.aiServerUrl}`,{method:"POST",headers:l,body:JSON.stringify({...o,context:c,history:a})}),d=await u.json();if(u.ok){let h=d.content;if(typeof h=="string")try{h=JSON.parse(h)}catch{h={message:h}}if(E(this,Gp,tO).call(this,h)){let m=await y(this,_n,Ho).executeBatch(h);return m.message=h.message,E(this,Di,Hp).call(this,{type:"ai",text:h.message||h.description,operations:m,operationsSummary:h.operations.map(g=>({type:g.type,args:g.args,ref:g.ref})),timestamp:Date.now()}),s&&s(m),m}return E(this,Di,Hp).call(this,{type:"ai",text:h.message||h,timestamp:Date.now()}),s&&s(h),h}let p=d.error??`Server error ${u.status}`;throw E(this,Xc,w_).call(this,p),new Error(p,{cause:u})}catch(c){throw E(this,Xc,w_).call(this,c.message),new Error(c.message,{cause:c})}}}}};yn=new WeakMap,xn=new WeakMap,Bo=new WeakMap,_n=new WeakSet,Ho=i(function(){return this.inject("aiOps")},"#ops"),Vp=new WeakSet,eO=i(function(){return Array.from(y(this,xn)).slice(-20).map(o=>{let s={role:o.type==="user"?"user":"assistant",content:o.text};return o.operations&&(s.hadOperations=!0,s.operationsSummary=o.operationsSummary),s})},"#buildHistory"),Gp=new WeakSet,tO=i(function(r){return r&&typeof r=="object"&&Array.isArray(r.operations)&&r.operations.length>0},"#isOperationsBatch"),Di=new WeakSet,Hp=i(function(r){y(this,xn).add(r),y(this,yn).forEach(n=>n(r))},"#addMessage"),Xc=new WeakSet,w_=i(function(r){y(this,Bo).add(r),y(this,yn).forEach(n=>n(r))},"#addError"),i(Wp,"AiChat"),Te(Wp,"manifest",{name:"AiChat",namespace:"aiChat",version:"1.0.0",description:"Ai chat service",author:"",license:"MIT",homepage:""});Bp=Wp});import{createDefinition as e5}from"@jucie.io/engine";function Mr(e){let t=e._name,r=e();return{namespace:t,operations:Object.entries(r).map(([n,o])=>({name:n,fullName:`${t}:${n}`,alias:o.alias||null,mcpName:o.mcpName||null,description:o.description||"",schema:o.schema||[],examples:o.examples||[],returns:o.returns||"Object"}))}}function Kp(e,t,r){if(!Array.isArray(t)||t.length===0)return!0;let n=t[0];if(typeof n!="object"||Array.isArray(n))return console.warn(`Schema for ${r} should be an object with named parameters`),!0;for(let[o,s]of Object.entries(n)){let a=typeof s=="string"&&s.endsWith("?"),c=a?s.slice(0,-1):s,l=e[o];if(!(o in e)||l===void 0){if(a)continue;throw new Error(`Missing required parameter "${o}" in ${r}`)}let u=Array.isArray(l)?"Array":l===null?"Null":typeof l=="object"?"Object":l.constructor.name;if(u!==c&&c!=="Any")throw new Error(`Parameter "${o}" in ${r} must be of type ${c}, got ${u}`)}return!0}var bt,Qc=f(()=>{bt=e5("AI_OPERATIONS",[Object]);i(Mr,"extractOperationsMetadata");i(Kp,"validateOperationArgs")});function Jp(e){let t=n5(e);return[t5,...t.map(r5)]}function r5(e){let t=e.operations.map(r=>{let n=Array.isArray(r.schema)?r.schema[0]:null,o=n&&typeof n=="object"?Object.entries(n).map(([a,c])=>`${a}: ${c}`).join(", "):"",s=r.examples?.[0]?`
135
- Example: ${JSON.stringify(r.examples[0].args)}`:"";return` ${r.name} \u2014 ${r.description}
151
+ `)}catch{}})}})});function Na(e={}){return{input:e.input_tokens??e.input??0,output:e.output_tokens??e.output??0,cacheWrite:e.cache_creation_input_tokens??e.cacheWrite??0,cacheRead:e.cache_read_input_tokens??e.cacheRead??0}}function HD(e){let t=Na(e);return t.input+t.output+t.cacheWrite+t.cacheRead}function Ns(e,t=null){let r=Na(e),n=Mw[t]??LD;return(r.input*n.input+r.cacheWrite*n.input*FD+r.cacheRead*n.input*UD+r.output*n.output)/1e6}function _u(e){let t=String(e??"").toLowerCase();return qD.includes(t)?t:BD}function vu(e,t=new Date){let r=new Date(t),n,o;switch(_u(e)){case"hour":n=new Date(Date.UTC(r.getUTCFullYear(),r.getUTCMonth(),r.getUTCDate(),r.getUTCHours())),o=new Date(n.getTime()+60*60*1e3);break;case"day":n=new Date(Date.UTC(r.getUTCFullYear(),r.getUTCMonth(),r.getUTCDate())),o=new Date(n.getTime()+24*60*60*1e3);break;case"month":default:n=new Date(Date.UTC(r.getUTCFullYear(),r.getUTCMonth(),1)),o=new Date(Date.UTC(r.getUTCFullYear(),r.getUTCMonth()+1,1));break}return{start:n,end:o}}function Ta({tokens:e,requests:t,costUsd:r}={}){let n=Na(e);return{used:HD(n),requests:t??0,tokens:n,cost:{usedUsd:Jr(r??0)}}}function kJ(e,t){if(!e)return null;let r=Jr(Ea(e.balanceMicros??0));return{balanceUsd:r,grantedUsd:Jr(Ea(e.grantedMicros??0)),purchasedUsd:Jr(Ea(e.purchasedMicros??0)),adjustedUsd:Jr(Ea(e.adjustedMicros??0)),spentUsd:Jr(Ea(e.spentMicros??0)),lowBalance:r<=t}}function Lw({window:e,org:t=null,credit:r=null,tokens:n,requests:o,costUsd:s,mine:a=null,lowBalanceUsd:c=wu,windDownGraceUsd:l=Cm,now:u=new Date}){let d=_u(e),{start:p,end:m}=vu(d,u),h=Na(n),g=kJ(r,c);return{scope:t?"org":"user",org:t?{id:t.id,name:t.name,personal:!!t.personal}:null,currency:"usd",credit:g,exhausted:g?g.balanceUsd<=0:!1,lowBalanceUsd:c,windDownGraceUsd:l,window:d,windowStart:p.toISOString(),resetsAt:m.toISOString(),requests:o??0,tokens:h,cost:{usedUsd:Jr(s??0)},mine:a?Ta(a):null}}function $J(e,t,r=null){if(!e||!t)return e;let n=Na(t),o=Ns(n,r),s=i(u=>({input:u.input+n.input,output:u.output+n.output,cacheWrite:u.cacheWrite+n.cacheWrite,cacheRead:u.cacheRead+n.cacheRead}),"addTokens"),a=s(e.tokens),c=e.mine?Ta({tokens:s(e.mine.tokens),requests:(e.mine.requests??0)+1,costUsd:e.mine.cost.usedUsd+o}):null,l=e.credit??null;if(l){let u=Jr(l.balanceUsd-o);l={...l,balanceUsd:u,spentUsd:Jr(l.spentUsd+o),lowBalance:u<=(e.lowBalanceUsd??wu)}}return{...e,credit:l,exhausted:l?l.balanceUsd<=0:!1,requests:(e.requests??0)+1,tokens:a,cost:{usedUsd:Jr(e.cost.usedUsd+o)},mine:c}}function za(e){return e?.org&&!e.org.personal?`Out of AI credit for ${e.org.name}. An owner can add credit in Settings \u2192 AI usage.`:"Out of AI credit. Add credit in Settings \u2192 AI usage."}function Jr(e){return Number(Number(e).toFixed(4))}var Mw,LD,FD,UD,qD,BD,Zw,zm,Ea,wu,Cm,Im=f(()=>{Mw={"claude-sonnet-4-6":{input:3,output:15},"claude-sonnet-5":{input:2,output:10},"claude-opus-5":{input:5,output:25}},LD=Mw["claude-sonnet-4-6"],FD=1.25,UD=.1,qD=["hour","day","month"],BD="month";i(Na,"normalizeUsage");i(HD,"billedTokens");i(Ns,"estimateCostUsd");i(_u,"normalizeWindow");i(vu,"windowBounds");i(Ta,"shapeShare");Zw=1e6,zm=i(e=>Math.round(Number(e)*Zw),"usdToMicros"),Ea=i(e=>Number(e)/Zw,"microsToUsd"),wu=1,Cm=.25;i(kJ,"shapeCredit");i(Lw,"shapeBudget");i($J,"applyUsage");i(za,"budgetExhaustedMessage");i(Jr,"round4")});import{ServiceProvider as EJ}from"@jucie.io/engine";var Fw,Om,Pm,VD=f(()=>{Im();Fw=i((e,t)=>{let r=Number(e);return e==null||e===""||Number.isNaN(r)?t:r},"numberOr"),Om=class Om extends EJ{setup({defineActions:t}){let r=this,n=Fw(r.config.freeGrantUsd,5),o=Fw(r.config.windDownGraceUsd,Cm),s=Fw(r.config.lowBalanceUsd,wu),a=_u(r.config.budgetWindow),c=r.config.serverApiKey,l=i(async _=>{if(r.config.skipAuth)return{user:null,org:null};let x=_.req.headers.authorization?.split(" ")[1];if(!x)return{user:null,org:null};let b=await r.inject("auth").validateToken(x);if(!b.isValid)return{denied:!0,status:401,reason:b.error};let S=await r.inject("users").findOrCreate(b.userId),E=_.req.org??null;if(!E){let I=r.inject("orgs");if(I){let z=_.req.headers["x-jucie-org"];if(z){if(E=await I.getOrgForUser(z,S.id),!E)return{denied:!0,status:403,reason:"Forbidden"}}else S.default_org_id&&(E=await I.getOrgForUser(S.default_org_id,S.id));if(!E){let M=await I.findOrCreatePersonal(S.id);E=M?{...M,role:"owner"}:null}}}return{user:S,org:E}},"identify"),u=i(async(_,x)=>{let{sql:v}=r.inject("db");return v`
152
+ SELECT
153
+ user_id,
154
+ model,
155
+ COUNT(*)::int AS requests,
156
+ COALESCE(SUM(input_tokens), 0)::float8 AS input,
157
+ COALESCE(SUM(output_tokens), 0)::float8 AS output,
158
+ COALESCE(SUM(cache_write_tokens), 0)::float8 AS cache_write,
159
+ COALESCE(SUM(cache_read_tokens), 0)::float8 AS cache_read
160
+ FROM usage_logs
161
+ WHERE org_id = ${_} AND created_at >= ${x}
162
+ GROUP BY user_id, model
163
+ `},"readWindow"),d=i(()=>({tokens:{input:0,output:0,cacheWrite:0,cacheRead:0},requests:0,costUsd:0}),"emptyShare"),p=i((_,x)=>{let v={input:x.input,output:x.output,cacheWrite:x.cache_write,cacheRead:x.cache_read};return _.tokens.input+=v.input,_.tokens.output+=v.output,_.tokens.cacheWrite+=v.cacheWrite,_.tokens.cacheRead+=v.cacheRead,_.requests+=x.requests,_.costUsd+=Ns(v,x.model),_},"addRow"),m=i(_=>({id:_.id,name:_.name,personal:!!_.personal_owner_id}),"orgSummary"),h=i(async({org:_,user:x},v=new Date)=>{let b=r.inject("credits"),{start:w}=vu(a,v);await b?.ensureFreeGrant?.(_,zm(n));let[S,E]=await Promise.all([u(_.id,w),b?.balance?.(_.id)??null]),I=d(),z=d();for(let M of S)p(I,M),x&&M.user_id===x.id&&p(z,M);return Lw({window:a,org:m(_),credit:E,tokens:I.tokens,requests:I.requests,costUsd:I.costUsd,mine:x?z:null,lowBalanceUsd:s,windDownGraceUsd:o,now:v})},"getBudget"),g=i(async({org:_},x=new Date)=>{let v=r.inject("orgs"),{start:b,end:w}=vu(a,x),S=await u(_.id,b),E=new Map;for(let D of S)E.has(D.user_id)||E.set(D.user_id,d()),p(E.get(D.user_id),D);let I=await v?.listMembers?.(_.id)??[],z=new Set,M=I.map(D=>(z.add(D.user_id),{userId:D.user_id,email:D.email??null,role:D.role,...Ta(E.get(D.user_id)??d())}));for(let[D,Z]of E)z.has(D)||M.push({userId:D,email:null,role:null,...Ta(Z)});return M.sort((D,Z)=>Z.cost.usedUsd-D.cost.usedUsd||Z.used-D.used),{window:a,windowStart:b.toISOString(),resetsAt:w.toISOString(),org:m(_),members:M}},"getMemberUsage");t(()=>({identify:l,getBudget:h,getMemberUsage:g,async authorize(_){let x=await l(_);if(x.denied)return x;let{user:v,org:b}=x;if(!v)return{apiKey:c,user:null,org:null,budget:null,windDown:!1};if(v.api_key)return{apiKey:v.api_key,user:v,org:b,budget:null,windDown:!1};if(!b)return{apiKey:c,user:v,org:null,budget:null,windDown:!1};let w=await h({org:b,user:v}),S=_.req.body?.windDown===!0;if(w.exhausted){let E=w.credit&&w.credit.balanceUsd>-o;if(!(S&&E))return{denied:!0,status:429,reason:za(w),budget:w}}return c?{apiKey:c,user:v,org:b,budget:w,windDown:S&&w.exhausted}:{denied:!0,status:402,reason:"No API key configured. Add your own Anthropic API key in settings.",budget:w}},async logUsage({userId:_,orgId:x=null,inputTokens:v,outputTokens:b,cacheWriteTokens:w,cacheReadTokens:S,model:E}){if(!_)return;let I={input:v??0,output:b??0,cacheWrite:w??0,cacheRead:S??0},z=zm(Ns(I,E)),{sql:M}=r.inject("db");await M`
164
+ INSERT INTO usage_logs (user_id, org_id, input_tokens, output_tokens, cache_write_tokens, cache_read_tokens, model, cost_micros)
165
+ VALUES (${_}, ${x}, ${I.input}, ${I.output}, ${I.cacheWrite}, ${I.cacheRead}, ${E}, ${z})
166
+ `}}))}};i(Om,"AiGatewayService"),_e(Om,"manifest",{name:"AiGatewayService",namespace:"gateway",version:"3.0.0",description:"AI request authorization against the organization credit balance, and usage logging"});Pm=Om});import{ServiceProvider as NJ}from"@jucie.io/engine";var Pn,On,zs,An,Ts,jm,GD,Dm,WD,Ca,Am,bu,Uw,Mm,Rm,JD=f(()=>{Mm=class Mm extends NJ{constructor(){super(...arguments);$(this,An);$(this,jm);$(this,Dm);$(this,Ca);$(this,bu);$(this,Pn,new Set);$(this,On,new Set);$(this,zs,new Set)}async initialize(r,n){console.log("AiChat: Initializing")}getters(){return{lastMessage:()=>y(this,On).size>0?Array.from(y(this,On)).pop():null,lastError:()=>y(this,zs).size>0?Array.from(y(this,zs)).pop():null,allMessages:()=>Array.from(y(this,On)),allErrors:()=>Array.from(y(this,zs)),operationsMetadata:()=>y(this,An,Ts).operationsMetadata}}actions(r,n){return{subscribe:o=>{if(typeof o!="function")throw new Error("Subscriber must be a function");return y(this,Pn).add(o),()=>y(this,Pn).delete(o)},unsubscribe:o=>{if(typeof o!="function")throw new Error("Subscriber must be a function");if(!y(this,Pn).has(o))throw new Error("Subscriber not found");y(this,Pn).delete(o)},use:(...o)=>(y(this,An,Ts).use(...o),this),executeOperation:(o,s,a)=>y(this,An,Ts).executeOperation(o,s,a),executeBatch:o=>y(this,An,Ts).executeBatch(o),clearHistory:()=>{y(this,On).clear(),console.log("AiChat: History cleared")},sendMessage:async(o,s)=>{let a=k(this,jm,GD).call(this);k(this,Ca,Am).call(this,{type:"user",text:o.prompt,timestamp:Date.now()});try{let c={...o.context,availableOperations:y(this,An,Ts).operationsMetadata},l={"Content-Type":"application/json"};n.token&&(l.Authorization=`Bearer ${n.token}`);let u=await fetch(`${n.aiServerUrl}`,{method:"POST",headers:l,body:JSON.stringify({...o,context:c,history:a})}),d=await u.json();if(u.ok){let m=d.content;if(typeof m=="string")try{m=JSON.parse(m)}catch{m={message:m}}if(k(this,Dm,WD).call(this,m)){let h=await y(this,An,Ts).executeBatch(m);return h.message=m.message,k(this,Ca,Am).call(this,{type:"ai",text:m.message||m.description,operations:h,operationsSummary:m.operations.map(g=>({type:g.type,args:g.args,ref:g.ref})),timestamp:Date.now()}),s&&s(h),h}return k(this,Ca,Am).call(this,{type:"ai",text:m.message||m,timestamp:Date.now()}),s&&s(m),m}let p=d.error??`Server error ${u.status}`;throw k(this,bu,Uw).call(this,p),new Error(p,{cause:u})}catch(c){throw k(this,bu,Uw).call(this,c.message),new Error(c.message,{cause:c})}}}}};Pn=new WeakMap,On=new WeakMap,zs=new WeakMap,An=new WeakSet,Ts=i(function(){return this.inject("aiOps")},"#ops"),jm=new WeakSet,GD=i(function(){return Array.from(y(this,On)).slice(-20).map(o=>{let s={role:o.type==="user"?"user":"assistant",content:o.text};return o.operations&&(s.hadOperations=!0,s.operationsSummary=o.operationsSummary),s})},"#buildHistory"),Dm=new WeakSet,WD=i(function(r){return r&&typeof r=="object"&&Array.isArray(r.operations)&&r.operations.length>0},"#isOperationsBatch"),Ca=new WeakSet,Am=i(function(r){y(this,On).add(r),y(this,Pn).forEach(n=>n(r))},"#addMessage"),bu=new WeakSet,Uw=i(function(r){y(this,zs).add(r),y(this,Pn).forEach(n=>n(r))},"#addError"),i(Mm,"AiChat"),_e(Mm,"manifest",{name:"AiChat",namespace:"aiChat",version:"1.0.0",description:"Ai chat service",author:"",license:"MIT",homepage:""});Rm=Mm});import{createDefinition as TJ}from"@jucie.io/engine";function Kr(e){let t=e._name,r=e();return{namespace:t,operations:Object.entries(r).map(([n,o])=>({name:n,fullName:`${t}:${n}`,alias:o.alias||null,mcpName:o.mcpName||null,description:o.description||"",schema:o.schema||[],examples:o.examples||[],returns:o.returns||"Object"}))}}function Zm(e,t,r){if(!Array.isArray(t)||t.length===0)return!0;let n=t[0];if(typeof n!="object"||Array.isArray(n))return console.warn(`Schema for ${r} should be an object with named parameters`),!0;for(let[o,s]of Object.entries(n)){let a=typeof s=="string"&&s.endsWith("?"),c=a?s.slice(0,-1):s,l=e[o];if(!(o in e)||l===void 0){if(a)continue;throw new Error(`Missing required parameter "${o}" in ${r}`)}let u=Array.isArray(l)?"Array":l===null?"Null":typeof l=="object"?"Object":l.constructor.name;if(u!==c&&c!=="Any")throw new Error(`Parameter "${o}" in ${r} must be of type ${c}, got ${u}`)}return!0}var Tt,Su=f(()=>{Tt=TJ("AI_OPERATIONS",[Object]);i(Kr,"extractOperationsMetadata");i(Zm,"validateOperationArgs")});function Lm(e){let t=OJ(e);return[CJ,IJ,...t.map(PJ)]}function PJ(e){let t=e.operations.map(r=>{let n=Array.isArray(r.schema)?r.schema[0]:null,o=n&&typeof n=="object"?Object.entries(n).map(([a,c])=>`${a}: ${c}`).join(", "):"",s=(r.examples??[]).slice(0,zJ).map(a=>{let c=a.description?` \u2014 ${a.description}`:"";return`
167
+ Example: ${JSON.stringify(a.args)}${c}`}).join("");return` ${r.name} \u2014 ${r.description}
136
168
  Args: { ${o} }${s}`}).join(`
137
169
 
138
- `);return{name:e.namespace,description:`${e.namespace} operations. Pass "op" as the operation name and "args" matching that op's schema.
170
+ `);return{name:e.namespace,description:`${e.namespace} operations. Put every operation for the current step in "ops" \u2014 they run in order, and {{ref}} values set by one are resolved for later ones. Batch aggressively: one call with ten operations costs a fraction of ten calls with one. You still see the re-rendered scene after each call.
171
+
172
+ ${t}`,input_schema:{type:"object",properties:{ops:{type:"array",description:"Operations to run, in order. Preferred over the single-operation form below.",items:{type:"object",properties:{op:{type:"string",description:`Operation name within ${e.namespace}`},args:{type:"object",description:"Arguments matching the operation's schema. A JSON object, not a string containing JSON."},ref:{type:"string",description:"Optional {{name}} reference for cross-operation use"}},required:["op","args"]}},op:{type:"string",description:`Single operation name within ${e.namespace}. Use "ops" instead when running more than one.`},args:{type:"object",description:"Arguments matching the operation's schema (single-operation form). A JSON object, not a string containing JSON."},ref:{type:"string",description:"Optional {{name}} reference for cross-operation use (single-operation form)"},message:{type:"string",description:"Short explanation of what you are doing (1 sentence)"}}}}}function OJ(e){return!Array.isArray(e)||e.length===0?[]:e[0]?.namespace&&Array.isArray(e[0]?.operations)?e:e.map(t=>Kr(t))}var zJ,CJ,IJ,qw=f(()=>{Su();zJ=2,CJ={name:"respond",description:"Send a conversational response to the user. Use this for greetings, questions, clarifications, status updates, or when the build task is fully complete.",input_schema:{type:"object",properties:{message:{type:"string",description:"Your conversational response to the user"}},required:["message"]}},IJ={name:"screenshot",description:"Render the current scene and look at it. Captures the full scrollable page, scaled to fit one review image when content is very tall. The JSX returned after each edit shows structure; a screenshot shows what the user will actually see. Use it to check your own work \u2014 after building a section, whenever layout could be wrong (overlapping elements, content overflowing its container, text the same colour as its background, collapsed or stretched spacing), and before you finish. Cheap relative to rebuilding something that turned out broken.",input_schema:{type:"object",properties:{reason:{type:"string",description:"What you are checking for (one short sentence)"},frameIds:{type:"array",items:{type:"string"},description:"Frame node ids to capture. Omit to capture every frame \u2014 prefer naming the frame you just changed."},fullPage:{type:"boolean",description:"Include all scroll-hidden content (default true). Set false for a viewport-only shot when checking a small visible region."}}}};i(Lm,"buildAnthropicTools");i(PJ,"buildNamespaceTool");i(OJ,"normalizeNamespaces")});import{ServiceProvider as AJ}from"@jucie.io/engine";var RJ,fo,Ia,mo,Yr,Um,KD,qm,YD,Bm,Fm,XD=f(()=>{Su();qw();RJ=new Set(["parent","parentId","nodeId"]),Bm=class Bm extends AJ{constructor(){super(...arguments);$(this,Um);$(this,qm);$(this,fo,new Map);$(this,Ia,[]);$(this,mo,new Map);$(this,Yr,new Map)}getters(){return{operationsMetadata:()=>this.getOperationsMetadata(),anthropicTools:()=>this.getAnthropicTools()}}actions(){return{use:(...r)=>{for(let n of r)k(this,Um,KD).call(this,n);return this},has:r=>y(this,fo).has(r),resolveType:r=>this.resolveType(r),describeUnresolved:r=>this.describeUnresolved(r),executeOperation:(r,n,o)=>this.executeOperation(r,n,o),executeBatch:r=>this.executeBatch(r)}}resolveType(r){return typeof r!="string"||!r?null:r.includes(":")?y(this,fo).has(r)?r:null:y(this,mo).get(r)??y(this,Yr).get(r)??null}describeUnresolved(r){if(this.resolveType(r))return null;if(typeof r=="string"&&!r.includes(":")&&y(this,Yr).has(r)&&y(this,Yr).get(r)===null){let n=[];for(let[s,a]of y(this,fo))a.name===r&&n.push(a.alias?`${s} (alias: ${a.alias})`:s);let o=n.length?n.join(" or "):r;return`Ambiguous operation: "${r}". Use ${o}.`}return`Unknown operation: ${r}`}getOperationsMetadata(){return y(this,Ia).map(r=>Kr(r))}getAnthropicTools(){return Lm(y(this,Ia))}async executeOperation(r,n,o=null){let s=this.resolveType(r),a=y(this,fo).get(s);if(!a)throw new Error(this.describeUnresolved(r));try{Zm(n,a.schema,r)}catch(c){throw console.error(`Validation failed for ${r}:`,c),c}try{return{result:await a.handler(n),ref:o}}catch(c){throw console.error(`Handler failed for ${r}:`,c),c}}async executeBatch(r){let{operations:n,description:o,expectation:s}=r;console.log("AiOperations: Executing batch",{count:n.length,description:o});let a=new Map,c=[],l=[];try{for(let u=0;u<n.length;u++){let d=n[u];console.log(`AiOperations: Executing [${u+1}/${n.length}] ${d.type}`);let p=k(this,qm,YD).call(this,d.args,a),{result:m}=await this.executeOperation(d.type,p,d.ref),h=m.id??m.rootId;if(d.ref&&h&&(a.set(d.ref,h),l.push(h)),m.treeMap)for(let[g,_]of Object.entries(m.treeMap))a.set(g,_),l.push(_);m.createdIds?.length&&l.push(...m.createdIds),c.push({operation:d.type,success:!0,result:m})}return console.log("AiOperations: Execution complete",{total:n.length,successful:c.length,createdIds:l}),{success:!0,description:o,expectation:s,results:c,createdIds:l,refMap:Object.fromEntries(a)}}catch(u){return console.error("AiOperations: Batch execution failed",u),{success:!1,description:o,error:u.message,failedAt:c.length,results:c}}}};fo=new WeakMap,Ia=new WeakMap,mo=new WeakMap,Yr=new WeakMap,Um=new WeakSet,KD=i(function(r){let n=this.inject("log");if(!r||typeof r!="function")throw new Error("Operation factory must be a function");let o=r._name;if(!o)throw new Error("Operation factory must have a _name property (use defineAiOperations)");n.info(`AiOperations: Registering operations for namespace "${o}"`),y(this,Ia).push(r);let s=r(this.inject);for(let[a,c]of Object.entries(s)){let{handler:l,schema:u,description:d,examples:p,returns:m,alias:h}=c,g=`${o}:${a}`;if(!l||typeof l!="function")throw new Error(`Operation ${g} must have a handler function`);d||console.warn(`Operation ${g} missing description`),y(this,fo).set(g,{namespace:o,name:a,handler:l,schema:u||[],description:d||"",examples:p||[],returns:m||"Object",alias:h||null}),h&&(y(this,mo).has(h)&&y(this,mo).get(h)!==g&&console.warn(`AiOperations: alias "${h}" already registered for ${y(this,mo).get(h)}, overriding with ${g}`),y(this,mo).set(h,g)),y(this,Yr).has(a)&&y(this,Yr).get(a)!==g?y(this,Yr).set(a,null):y(this,Yr).set(a,g)}},"#setupOperations"),qm=new WeakSet,YD=i(function(r,n){return r&&JSON.parse(JSON.stringify(r),(o,s)=>{if(o==="ref")return s;if(typeof s=="string"&&s.match(/^\{\{.*\}\}$/)){let a=n.get(s)??n.get(s.replace(/\.[^}]+(?=\}\}$)/,""));if(a)return a;if(RJ.has(o))throw new Error(`Unresolved reference "${s}" in "${o}". {{refs}} only resolve within the same tool call \u2014 use the real node id reported by the previous operation.`);return s}return s})},"#resolveReferences"),i(Bm,"AiOperations"),_e(Bm,"manifest",{name:"AiOperations",namespace:"aiOps",version:"1.0.0",description:"AI operation registry and executor",author:"",license:"MIT",homepage:""});Fm=Bm});function Hm(e){let t=jJ(e),r=["Run multiple scene operations in a single round-trip. Use this instead of calling individual tools one-by-one whenever you have independent operations.","",'Each operation is an object with an "op" field plus its parameters:',""];for(let n of t){r.push(` ${n.namespace.toUpperCase()}`);for(let o of n.operations){let s=Array.isArray(o.schema)?o.schema[0]:null,a=s&&typeof s=="object"?Object.entries(s).map(([l,u])=>`${l}: ${u}`).join(", "):"",c=o.alias??o.name;r.push(` { op: "${c}"${a?`, ${a}`:""} }`)}r.push("")}return r.push("Returns an array of results in the same order as the input.","",'REFERENCES: add ref: "{{myRef}}" to a create operation, then use "{{myRef}}" as a value (e.g. parent or nodeId) in later operations of the SAME batch \u2014 it resolves to the created node id.'),r.join(`
173
+ `)}function jJ(e){return!Array.isArray(e)||e.length===0?[]:e[0]?.namespace&&Array.isArray(e[0]?.operations)?e:e.map(t=>Kr(t))}var QD=f(()=>{Su();i(Hm,"buildBatchDescription");i(jJ,"normalizeNamespaces")});var eM={};C(eM,{AiChat:()=>Rm,AiGatewayService:()=>Pm,AiOperations:()=>Fm,BUDGET_WINDOWS:()=>qD,CACHE_READ_MULTIPLIER:()=>UD,CACHE_WRITE_MULTIPLIER:()=>FD,DEFAULT_BUDGET_WINDOW:()=>BD,DEFAULT_LOW_BALANCE_USD:()=>wu,DEFAULT_RATE:()=>LD,DEFAULT_WIND_DOWN_GRACE_USD:()=>Cm,MICROS_PER_USD:()=>Zw,MODEL_RATES:()=>Mw,applyUsage:()=>$J,billedTokens:()=>HD,budgetExhaustedMessage:()=>za,buildAnthropicTools:()=>Lm,buildBatchDescription:()=>Hm,defineAiOperations:()=>Tt,estimateCostUsd:()=>Ns,extractOperationsMetadata:()=>Kr,microsToUsd:()=>Ea,normalizeUsage:()=>Na,normalizeWindow:()=>_u,shapeBudget:()=>Lw,shapeShare:()=>Ta,usdToMicros:()=>zm,validateOperationArgs:()=>Zm,windowBounds:()=>vu});var Rn=f(()=>{VD();JD();XD();Su();qw();QD();Im()});import{ServiceProvider as DJ}from"@jucie.io/engine";var MJ,ZJ,Bw,LJ,FJ,UJ,Gm,tM,ku,Hw,Wm,rM,Jm,nM,Km,oM,Ym,sM,Xm,iM,Qm,aM,eh,cM,th,lM,rh,uM,nh,dM,oh,pM,sh,fM,$u,Vw,jn,Cs,ih,mM,Eu,Gw,Nu,Ww,ah,Vm,hM=f(()=>{Im();MJ=40,ZJ=10,Bw=3,LJ=2,FJ=3,UJ=12,ah=class ah extends DJ{constructor(){super(...arguments);$(this,Gm);$(this,ku);$(this,Wm);$(this,Jm);$(this,Km);$(this,Ym);$(this,Xm);$(this,Qm);$(this,eh);$(this,th);$(this,rh);$(this,nh);$(this,oh);$(this,sh);$(this,$u);$(this,jn);$(this,ih);$(this,Eu);$(this,Nu)}actions(r,n){return{run:o=>this.run(o,n)}}async run({prompt:r,sessionId:n=null,token:o=null,orgId:s=null,attachments:a=[],getContext:c,execute:l=null,captureScreenshot:u=null,signal:d=null,onProgress:p=i(()=>{},"onProgress")},m){let h=this.inject("aiOps"),g=this.inject("aiHistory"),_=m.maxIterations??MJ,x=m.resyncEvery??ZJ,v=m.tokenBudget??null,b=l??(ht=>h.executeBatch(ht)),w=h.anthropicTools,S=m.playbook??null,E=n?await g.buildHistory(n):[],I=i(ht=>n?g.appendMessage(n,ht):Promise.resolve(),"record"),z=[],M=k(this,sh,fM).call(this),D=null,Z=i(async()=>{let ht="Run stopped.";return await I({type:"ai",text:ht,timestamp:Date.now()}),{stopped:!0,message:ht,createdIds:z,usage:M,budget:D}},"stopped"),H={type:"user",text:r,timestamp:Date.now()};if(a?.length&&(H.attachments=a),await I(H),d?.aborted)return Z();let ce=await c({awaitRender:!1}),J=a?.length?await g.buildHistory(n).then(ht=>ht.at(-1)?.content??r):r,te=[],Ve=0,Dr=0,Fd=0,yi=Date.now(),jo=[];for(let ht=0;ht<_;ht++){let R9=Date.now();if(d?.aborted)return Z();let Do;try{Do=await k(this,Eu,Gw).call(this,{prompt:J,context:ce,history:E,turns:te,tools:w,playbook:S,token:o??m.token,orgId:s,signal:d},m)}catch(Ee){if(Ee.name==="AbortError"||d?.aborted)return Z();throw Ee}if(k(this,$u,Vw).call(this,M,Do.usage,Do.model),Do.budget&&(D=Do.budget),d?.aborted)return Z();let gt=Do.content,xi=k(this,Nu,Ww).call(this,gt),vc=Array.isArray(gt?.screenshots)?gt.screenshots:[],_i=Array.isArray(gt?.invalid)?gt.invalid:[];if(!xi&&_i.length>0){if(Fd+=1,Fd>=FJ){let Ee=`The AI produced malformed operations ${Fd} turns in a row. Last error: ${_i[0].reason}`;return await I({type:"ai",text:Ee,timestamp:Date.now()}),k(this,jn,Cs).call(this,r,jo,yi,"malformed",M),{error:Ee,createdIds:z,usage:M,budget:D}}}else xi&&(Fd=0);if(!xi&&vc.length===0&&_i.length===0){let Ee=gt.message??(typeof gt=="string"?gt:"Done.");return await I({type:"ai",text:Ee,timestamp:Date.now()}),k(this,jn,Cs).call(this,r,jo,yi,"complete",M),{message:Ee,createdIds:z,usage:M,budget:D,exhausted:!!D?.exhausted}}let ln={success:!0,results:[],createdIds:[]};if(xi)if(ln=await b(gt),z.push(...ln.createdIds??[]),await I({type:"ai",text:gt.message||gt.description,operationsSummary:gt.operations.map(Ee=>({type:Ee.type,args:Ee.args,ref:Ee.ref})),timestamp:Date.now()}),p({message:gt.message,iteration:ht+1,maxIterations:_,createdIds:ln.createdIds,usage:{...M},budget:D}),ln.success)Ve=0;else{Ve+=1;let Ee=`Batch failed at operation ${ln.failedAt}: ${ln.error}`;if(await I({type:"ai",text:Ee,timestamp:Date.now()}),Ve>=3)return k(this,jn,Cs).call(this,r,jo,yi,"failed",M),{error:Ee,createdIds:z,usage:M,budget:D}}if(jo.push({iteration:ht+1,operations:xi?gt.operations.length:0,screenshots:vc.length,..._i.length?{malformed:_i.length}:{},durationMs:Date.now()-R9}),d?.aborted)return Z();let yN=vc.length?await k(this,Jm,nM).call(this,u,vc,Dr):[];Dr+=yN.filter(Ee=>Ee.error).length;let xN=!!D?.exhausted,wc;if(xN)wc=k(this,Qm,aM).call(this,r);else if(xi){let Ee=!ln.success||(ht+1)%x===0;wc=await k(this,oh,pM).call(this,{getContext:c,wantsResync:Ee,aiOps:h,result:ln,prompt:r})}else _i.length&&!vc.length?wc=k(this,Ym,sM).call(this,r,h):wc=k(this,Xm,iM).call(this,r);let{blocks:j9,toolBlocks:D9}=k(this,Gm,tM).call(this,Do,gt,ht);if(te.push({role:"assistant",content:j9}),te.push({role:"user",content:k(this,Wm,rM).call(this,{toolBlocks:D9,result:ln,shots:yN,feedback:wc})}),xN){let Ee=await k(this,eh,cM).call(this,{taskPrompt:J,context:ce,history:E,turns:te,tools:w,playbook:S,token:o??m.token,orgId:s,signal:d,usage:M,executeBatch:b,record:I,allCreatedIds:z},m);return k(this,jn,Cs).call(this,r,jo,yi,"credit_exhausted",M),{message:Ee.message,createdIds:z,usage:M,budget:Ee.budget??D,exhausted:!0,windDown:Ee.windDown}}if(v&&M.billedTokens>=v){let Ee=`Token budget reached (${M.billedTokens.toLocaleString()} of ${v.toLocaleString()}). ${z.length} element(s) created \u2014 ask me to continue if you want more.`;return await I({type:"ai",text:Ee,timestamp:Date.now()}),k(this,jn,Cs).call(this,r,jo,yi,"budget_reached",M),{message:Ee,createdIds:z,usage:M,budget:D,budgetReached:!0}}}let gN="Iteration limit reached.";return await I({type:"ai",text:gN,timestamp:Date.now()}),k(this,jn,Cs).call(this,r,jo,yi,"limit_reached",M),{message:gN,createdIds:z,usage:M,budget:D}}};Gm=new WeakSet,tM=i(function(r,n,o){if(Array.isArray(r.blocks)&&r.blocks.length>0)return{blocks:r.blocks,toolBlocks:r.toolBlocks??k(this,ku,Hw).call(this,r.blocks)};let s=(n.operations??[]).map((a,c)=>{let l=a.type.indexOf(":");return{type:"tool_use",id:`i${o}_${c}`,name:l>=0?a.type.slice(0,l):"node",input:{op:l>=0?a.type.slice(l+1):a.type,args:a.args??{},...a.ref?{ref:a.ref}:{},...c===0&&n.message?{message:n.message}:{}}}});for(let a of n.screenshots??[])s.push({type:"tool_use",id:a.id??`i${o}_shot`,name:"screenshot",input:a.reason?{reason:a.reason}:{}});return{blocks:s,toolBlocks:k(this,ku,Hw).call(this,s)}},"#assistantTurn"),ku=new WeakSet,Hw=i(function(r){return r.filter(n=>n.type==="tool_use").map(n=>({id:n.id,name:n.name,opCount:n.name==="respond"||n.name==="screenshot"?0:Array.isArray(n.input?.ops)?n.input.ops.length:1}))},"#describeBlocks"),Wm=new WeakSet,rM=i(function({toolBlocks:r,result:n,shots:o=[],feedback:s}){let a=n.results??[],c=n.success?1/0:n.failedAt??a.length,l=[],u=0;for(let d of r){let p=u,m=u+d.opCount;if(u=m,d.invalid){l.push({type:"tool_result",tool_use_id:d.id,content:`Not executed \u2014 ${d.invalid}`,is_error:!0});continue}if(d.name==="screenshot"){l.push({type:"tool_result",tool_use_id:d.id,...k(this,Km,oM).call(this,o.find(h=>h.id===d.id))});continue}if(d.opCount===0){l.push({type:"tool_result",tool_use_id:d.id,content:"Displayed to user."});continue}if(m<=c){let h=a.slice(p,m),g=h.map(_=>k(this,rh,uM).call(this,_)).filter(Boolean);l.push({type:"tool_result",tool_use_id:d.id,content:g.length?`${h.length} operation(s) applied.
174
+ ${g.join(`
175
+ `)}`:`${h.length} operation(s) applied.`});continue}if(p<=c){l.push({type:"tool_result",tool_use_id:d.id,content:`Failed: ${n.error}`,is_error:!0});continue}l.push({type:"tool_result",tool_use_id:d.id,content:"Not executed \u2014 an earlier operation in this batch failed.",is_error:!0})}return s&&l.push({type:"text",text:s}),l},"#buildToolResults"),Jm=new WeakSet,nM=i(async function(r,n,o=0){if(typeof r!="function")return n.map(a=>({id:a.id,error:"Screenshot capture is unavailable in this session. Continue without it."}));if(o>=LJ)return n.map(a=>({id:a.id,error:`Screenshot capture has failed ${o} times and is disabled for the rest of this run. Do not call screenshot again \u2014 verify from the JSX and continue.`}));let s=[];for(let a of n)try{let c=await r({frameIds:a.frameIds??null,limit:Bw,fullPage:a.fullPage??!0,...a.maxWidth!=null?{maxWidth:a.maxWidth}:{},...a.maxHeight!=null?{maxHeight:a.maxHeight}:{}}),l=c?.frames??[];s.push({id:a.id,frames:l.slice(0,Bw),dropped:c?.dropped??Math.max(0,l.length-Bw),missing:c?.missing??null})}catch(c){s.push({id:a.id,error:c.message})}return s},"#capture"),Km=new WeakSet,oM=i(function(r){if(!r||r.error)return{content:`Screenshot failed: ${r?.error??"no result returned"}`,is_error:!0};let n=[];for(let o of r.frames??[]){let s=String(o.imageData??""),a=s.match(/^data:(image\/\w+);base64,(.+)$/s),c=a?.[1]??"image/jpeg",l=a?.[2]??s;if(l){if(n.push({type:"text",text:`Frame "${o.name??o.id}" (${o.id})`}),o.scaled&&o.scale!=null){let u=Math.round(o.scale*100);n.push({type:"text",text:`Page scaled to ${u}% to fit one review image (natural ${o.naturalSize?.width??"?"}\xD7${o.naturalSize?.height??"?"}).`})}n.push({type:"image",source:{type:"base64",media_type:c,data:l}})}}return n.length===0?{content:"No frames were captured \u2014 the scene may not have any frame nodes yet."}:(r.dropped>0&&n.push({type:"text",text:`${r.dropped} further frame(s) were not captured. Pass frameIds to target the frame you care about.`}),r.missing?.length&&n.push({type:"text",text:`These frame ids do not exist: ${r.missing.join(", ")}.`}),{content:n})},"#screenshotResult"),Ym=new WeakSet,sM=i(function(r,n){return["None of those tool calls ran, so the scene is unchanged.","Send `args` as a JSON object \u2014 not a string containing JSON, and not a partially quoted fragment. Put every operation for the step in the `ops` array.",`Valid operation types:
176
+ ${n.operationsMetadata.flatMap(s=>s.operations.map(a=>` ${a.fullName}`)).join(`
177
+ `)}`,`Original task: "${r}". Reissue the operations correctly.`].join(`
178
+
179
+ `)},"#malformedNote"),Xm=new WeakSet,iM=i(function(r){return`Original task: "${r}". Act on what you see: fix anything wrong, then continue until the task is fully complete. Only call respond when you are done.`},"#continuationNote"),Qm=new WeakSet,aM=i(function(r){return`The organization's AI credit is exhausted. This is your final turn for the task "${r}": finish the current step as well as you can, make no further tool calls beyond what is essential, then call respond with what is done and what remains.`},"#windDownNote"),eh=new WeakSet,cM=i(async function({taskPrompt:r,context:n,history:o,turns:s,tools:a,playbook:c,token:l,orgId:u,signal:d,usage:p,executeBatch:m,record:h,allCreatedIds:g},_){let x;try{x=await k(this,Eu,Gw).call(this,{prompt:r,context:n,history:o,turns:s,tools:a,playbook:c,token:l,orgId:u,signal:d,windDown:!0},_)}catch(S){let E=S.budget??null,I=E?za(E):"Out of AI credit. Add credit in Settings \u2192 AI usage.";return await h({type:"ai",text:I,timestamp:Date.now()}),{message:I,budget:E,windDown:!1}}k(this,$u,Vw).call(this,p,x.usage,x.model);let v=x.content;if(k(this,Nu,Ww).call(this,v)){let S=await m(v);g.push(...S.createdIds??[])}let w=`${v?.message??(typeof v=="string"?v:"Stopped: out of AI credit.")}
180
+
181
+ ${za(x.budget??{})}`;return await h({type:"ai",text:w,timestamp:Date.now()}),{message:w,budget:x.budget??null,windDown:!0}},"#windDown"),th=new WeakSet,lM=i(function(r){return[...new Set([...r.createdIds??[],...(r.results??[]).flatMap(n=>k(this,nh,dM).call(this,n))])]},"#touchedIds"),rh=new WeakSet,uM=i(function(r){let n=r?.result;if(!n)return null;let o=r.operation??"operation";if(n.rootId){let s=n.createdIds?.length??0,a=[`${o} \u2192 root ${n.rootId} (${s} node${s===1?"":"s"} created)`],c=Object.entries(n.treeMap??{}).map(([l,u])=>`${l}=${u}`);if(c.length){let l=c.slice(0,UJ),u=c.length-l.length;a.push(`named: ${l.join(", ")}${u>0?` (+${u} more)`:""}`)}return a.join(`
182
+ `)}return n.movedTo?`${o} \u2192 ${n.id} moved into ${n.movedTo}`:n.id?`${o} \u2192 ${n.id}`:null},"#describeResult"),nh=new WeakSet,dM=i(function(r){let n=r?.result;if(!n)return[];let o=[];return n.id&&o.push(n.id),n.rootId&&o.push(n.rootId),Array.isArray(n.createdIds)&&o.push(...n.createdIds),o},"#idsFrom"),oh=new WeakSet,pM=i(async function({getContext:r,wantsResync:n,aiOps:o,result:s,prompt:a}){let c=[];if(!s.success){let u=o.operationsMetadata.flatMap(d=>d.operations.map(p=>` ${p.fullName}`)).join(`
183
+ `);c.push(`Valid operation types:
184
+ ${u}`),c.push("Retry the failed and remaining operations using only valid operation types.")}let l=null;try{l=await r({awaitRender:!0,delta:!n,focusIds:k(this,th,lM).call(this,s)})}catch{}return l?.delta?(l.changedJsx&&c.push(`Scene changes:
185
+ ${l.changedJsx}`),l.removedIds?.length&&c.push(`Removed: ${l.removedIds.join(", ")}`),!l.changedJsx&&!l.removedIds?.length&&c.push("No rendered change detected.")):l?.jsx&&c.push(`Full scene resync:
186
+ ${l.jsx}`),c.push(`Original task: "${a}".
139
187
 
140
- ${t}`,input_schema:{type:"object",properties:{op:{type:"string",description:`Operation name within ${e.namespace}`},args:{type:"object",description:"Arguments matching the operation's schema"},ref:{type:"string",description:"Optional {{name}} reference for cross-operation use"},message:{type:"string",description:"Short explanation of what you are doing (1 sentence)"}},required:["op","args"]}}}function n5(e){return!Array.isArray(e)||e.length===0?[]:e[0]?.namespace&&Array.isArray(e[0]?.operations)?e:e.map(t=>Mr(t))}var t5,b_=f(()=>{Qc();t5={name:"respond",description:"Send a conversational response to the user. Use this for greetings, questions, clarifications, status updates, or when the build task is fully complete.",input_schema:{type:"object",properties:{message:{type:"string",description:"Your conversational response to the user"}},required:["message"]}};i(Jp,"buildAnthropicTools");i(r5,"buildNamespaceTool");i(n5,"normalizeNamespaces")});import{ServiceProvider as o5}from"@jucie.io/engine";var qn,Mi,Hn,Zr,Xp,nO,Qp,oO,ef,Yp,sO=f(()=>{Qc();b_();ef=class ef extends o5{constructor(){super(...arguments);k(this,Xp);k(this,Qp);k(this,qn,new Map);k(this,Mi,[]);k(this,Hn,new Map);k(this,Zr,new Map)}getters(){return{operationsMetadata:()=>this.getOperationsMetadata(),anthropicTools:()=>this.getAnthropicTools()}}actions(){return{use:(...r)=>{for(let n of r)E(this,Xp,nO).call(this,n);return this},has:r=>y(this,qn).has(r),resolveType:r=>this.resolveType(r),describeUnresolved:r=>this.describeUnresolved(r),executeOperation:(r,n,o)=>this.executeOperation(r,n,o),executeBatch:r=>this.executeBatch(r)}}resolveType(r){return typeof r!="string"||!r?null:r.includes(":")?y(this,qn).has(r)?r:null:y(this,Hn).get(r)??y(this,Zr).get(r)??null}describeUnresolved(r){if(this.resolveType(r))return null;if(typeof r=="string"&&!r.includes(":")&&y(this,Zr).has(r)&&y(this,Zr).get(r)===null){let n=[];for(let[s,a]of y(this,qn))a.name===r&&n.push(a.alias?`${s} (alias: ${a.alias})`:s);let o=n.length?n.join(" or "):r;return`Ambiguous operation: "${r}". Use ${o}.`}return`Unknown operation: ${r}`}getOperationsMetadata(){return y(this,Mi).map(r=>Mr(r))}getAnthropicTools(){return Jp(y(this,Mi))}async executeOperation(r,n,o=null){let s=this.resolveType(r),a=y(this,qn).get(s);if(!a)throw new Error(this.describeUnresolved(r));try{Kp(n,a.schema,r)}catch(c){throw console.error(`Validation failed for ${r}:`,c),c}try{return{result:await a.handler(n),ref:o}}catch(c){throw console.error(`Handler failed for ${r}:`,c),c}}async executeBatch(r){let{operations:n,description:o,expectation:s}=r;console.log("AiOperations: Executing batch",{count:n.length,description:o});let a=new Map,c=[],l=[];try{for(let u=0;u<n.length;u++){let d=n[u];console.log(`AiOperations: Executing [${u+1}/${n.length}] ${d.type}`);let p=E(this,Qp,oO).call(this,d.args,a),{result:h}=await this.executeOperation(d.type,p,d.ref),m=h.id??h.rootId;if(d.ref&&m&&(a.set(d.ref,m),l.push(m)),h.treeMap)for(let[g,_]of Object.entries(h.treeMap))a.set(g,_),l.push(_);h.createdIds?.length&&l.push(...h.createdIds),c.push({operation:d.type,success:!0,result:h})}return console.log("AiOperations: Execution complete",{total:n.length,successful:c.length,createdIds:l}),{success:!0,description:o,expectation:s,results:c,createdIds:l,refMap:Object.fromEntries(a)}}catch(u){return console.error("AiOperations: Batch execution failed",u),{success:!1,description:o,error:u.message,failedAt:c.length,results:c}}}};qn=new WeakMap,Mi=new WeakMap,Hn=new WeakMap,Zr=new WeakMap,Xp=new WeakSet,nO=i(function(r){let n=this.inject("log");if(!r||typeof r!="function")throw new Error("Operation factory must be a function");let o=r._name;if(!o)throw new Error("Operation factory must have a _name property (use defineAiOperations)");n.info(`AiOperations: Registering operations for namespace "${o}"`),y(this,Mi).push(r);let s=r(this.inject);for(let[a,c]of Object.entries(s)){let{handler:l,schema:u,description:d,examples:p,returns:h,alias:m}=c,g=`${o}:${a}`;if(!l||typeof l!="function")throw new Error(`Operation ${g} must have a handler function`);d||console.warn(`Operation ${g} missing description`),y(this,qn).set(g,{namespace:o,name:a,handler:l,schema:u||[],description:d||"",examples:p||[],returns:h||"Object",alias:m||null}),m&&(y(this,Hn).has(m)&&y(this,Hn).get(m)!==g&&console.warn(`AiOperations: alias "${m}" already registered for ${y(this,Hn).get(m)}, overriding with ${g}`),y(this,Hn).set(m,g)),y(this,Zr).has(a)&&y(this,Zr).get(a)!==g?y(this,Zr).set(a,null):y(this,Zr).set(a,g)}},"#setupOperations"),Qp=new WeakSet,oO=i(function(r,n){return r&&JSON.parse(JSON.stringify(r),(o,s)=>o==="ref"?s:typeof s=="string"&&s.match(/^\{\{.*\}\}$/)?n.get(s)??n.get(s.replace(/\.[^}]+(?=\}\}$)/,""))??s:s)},"#resolveReferences"),i(ef,"AiOperations"),Te(ef,"manifest",{name:"AiOperations",namespace:"aiOps",version:"1.0.0",description:"AI operation registry and executor",author:"",license:"MIT",homepage:""});Yp=ef});function tf(e){let t=s5(e),r=["Run multiple scene operations in a single round-trip. Use this instead of calling individual tools one-by-one whenever you have independent operations.","",'Each operation is an object with an "op" field plus its parameters:',""];for(let n of t){r.push(` ${n.namespace.toUpperCase()}`);for(let o of n.operations){let s=Array.isArray(o.schema)?o.schema[0]:null,a=s&&typeof s=="object"?Object.entries(s).map(([l,u])=>`${l}: ${u}`).join(", "):"",c=o.alias??o.name;r.push(` { op: "${c}"${a?`, ${a}`:""} }`)}r.push("")}return r.push("Returns an array of results in the same order as the input.","",'REFERENCES: add ref: "{{myRef}}" to a create operation, then use "{{myRef}}" as a value (e.g. parent or nodeId) in later operations of the SAME batch \u2014 it resolves to the created node id.'),r.join(`
141
- `)}function s5(e){return!Array.isArray(e)||e.length===0?[]:e[0]?.namespace&&Array.isArray(e[0]?.operations)?e:e.map(t=>Mr(t))}var iO=f(()=>{Qc();i(tf,"buildBatchDescription");i(s5,"normalizeNamespaces")});var aO={};R(aO,{AiChat:()=>Bp,AiGatewayService:()=>Up,AiOperations:()=>Yp,buildAnthropicTools:()=>Jp,buildBatchDescription:()=>tf,defineAiOperations:()=>bt,extractOperationsMetadata:()=>Mr,validateOperationArgs:()=>Kp});var vn=f(()=>{QR();rO();sO();Qc();b_();iO()});import{ServiceProvider as i5}from"@jucie.io/engine";var a5,el,S_,nf,cO,of,lO,sf,uO,af,rf,dO=f(()=>{a5=20,af=class af extends i5{constructor(){super(...arguments);k(this,el);k(this,nf);k(this,of);k(this,sf)}actions(r,n){return{run:o=>this.run(o,n)}}async run({prompt:r,sessionId:n=null,token:o=null,attachments:s=[],getContext:a,execute:c=null,signal:l=null,onProgress:u=i(()=>{},"onProgress")},d){let p=this.inject("aiOps"),h=this.inject("aiHistory"),m=d.maxIterations??a5,g=c??(se=>p.executeBatch(se)),_=p.anthropicTools,x=d.playbook??null,v=n?await h.buildHistory(n):[],w=i(se=>n?h.appendMessage(n,se):Promise.resolve(),"record"),b=[],S=i(async()=>{let se="Run stopped.";return await w({type:"ai",text:se,timestamp:Date.now()}),{stopped:!0,message:se,createdIds:b}},"stopped"),T={type:"user",text:r,timestamp:Date.now()};if(s?.length&&(T.attachments=s),await w(T),l?.aborted)return S();let K=await a({awaitRender:!1}),A=s?.length?await h.buildHistory(n).then(se=>se.at(-1)?.content??r):r,Y=0,W=Date.now(),L=[];for(let se=0;se<m;se++){let ur=Date.now();if(l?.aborted)return S();let be;try{be=await E(this,of,lO).call(this,{prompt:A,context:{...K,availableOperations:p.operationsMetadata},history:v,tools:_,playbook:x,token:o??d.token,signal:l},d)}catch(Fe){if(Fe.name==="AbortError"||l?.aborted)return S();throw Fe}if(l?.aborted)return S();if(!E(this,sf,uO).call(this,be)){let Fe=be.message??(typeof be=="string"?be:"Done.");return await w({type:"ai",text:Fe,timestamp:Date.now()}),E(this,el,S_).call(this,r,L,W,"complete"),{message:Fe,createdIds:b}}let Re=await g(be);if(b.push(...Re.createdIds??[]),L.push({iteration:se+1,operations:be.operations.length,durationMs:Date.now()-ur,tokens:be.usage??null}),await w({type:"ai",text:be.message||be.description,operationsSummary:be.operations.map(Fe=>({type:Fe.type,args:Fe.args,ref:Fe.ref})),timestamp:Date.now()}),v.push({role:"user",content:A},{role:"assistant",content:be.message||be.description||"",hadOperations:!0,operationsSummary:be.operations.map(Fe=>({type:Fe.type,args:Fe.args,ref:Fe.ref}))}),u({message:be.message,iteration:se+1,maxIterations:m,createdIds:Re.createdIds}),!Re.success){let Fe=`Batch failed at operation ${Re.failedAt}: ${Re.error}`;if(await w({type:"ai",text:Fe,timestamp:Date.now()}),Y+=1,Y>=3)return{error:Fe,createdIds:b};let Ps=p.operationsMetadata.flatMap(wL=>wL.operations.map(bL=>` ${bL.fullName}`)).join(`
142
- `);K=await a({awaitRender:!1}),A=`ERROR: ${Fe}
188
+ Check what came back against what you intended before moving on: nodes that did not get created, wrong nesting, styles applied to the wrong node, layout that will not render as intended. Fix problems now rather than building on top of them. When structure alone cannot tell you whether it looks right, call screenshot and look.
143
189
 
144
- Valid operation types:
145
- ${Ps}
190
+ Continue until the task is fully complete, then call respond.`),c.join(`
146
191
 
147
- Retry the failed and remaining operations using only valid operation types.
148
- Original task: "${r}"`;continue}if(Y=0,l?.aborted)return S();K=await a({awaitRender:!0}),A=`${Re.results.length} operation(s) applied. Original task: "${r}". Review the updated scene and continue building until the task is fully complete. Only call respond when you are done.`}let X="Iteration limit reached.";return await w({type:"ai",text:X,timestamp:Date.now()}),E(this,el,S_).call(this,r,L,W,"limit_reached"),{message:X,createdIds:b}}};el=new WeakSet,S_=i(function(r,n,o,s){let a=n.reduce((u,d)=>u+d.operations,0),c=n.reduce((u,d)=>d.tokens?u+(d.tokens.input_tokens??0)+(d.tokens.output_tokens??0):u,0),l={reason:s,prompt:r.substring(0,120),iterations:n.length,totalOperations:a,totalDurationMs:Date.now()-o,totalTokens:c||void 0,timestamp:Date.now(),perIteration:n.map(u=>({i:u.iteration,ops:u.operations,ms:u.durationMs,...u.tokens?{tokens:u.tokens}:{}}))};console.log("[AiAgent] run complete",JSON.stringify(l,null,2)),E(this,nf,cO).call(this,l).catch(()=>{})},"#logRunSummary"),nf=new WeakSet,cO=i(async function(r){let o=await this.inject("aiHistory").getRunLogDir(),{appendFile:s}=await import("fs/promises"),{join:a}=await import("path");await s(a(o,"runs.jsonl"),JSON.stringify(r)+`
149
- `)},"#persistRunLog"),of=new WeakSet,lO=i(async function({prompt:r,context:n,history:o,tools:s=null,playbook:a=null,token:c,signal:l=null},u){let d={"Content-Type":"application/json"};c&&(d.Authorization=`Bearer ${c}`);let p;try{p=await fetch(u.aiServerUrl,{method:"POST",headers:d,body:JSON.stringify({prompt:r,context:n,history:o,tools:s,playbook:a}),signal:l??void 0})}catch(g){throw g}let h=await p.json();if(!p.ok)throw new Error(h.error??`AI server error ${p.status}`);let m=h.content;if(typeof m=="string")try{m=JSON.parse(m)}catch{m={message:m}}return h.usage&&typeof m=="object"&&(m.usage=h.usage),m},"#request"),sf=new WeakSet,uO=i(function(r){return r&&typeof r=="object"&&Array.isArray(r.operations)&&r.operations.length>0},"#isOperationsBatch"),i(af,"AiAgent"),Te(af,"manifest",{name:"AiAgent",namespace:"aiAgent",version:"1.0.0",description:"Server-side AI agent loop"});rf=af});import{ServiceProvider as c5}from"@jucie.io/engine";import{mkdir as k_,readdir as $_,readFile as E_,appendFile as l5,writeFile as pO,unlink as fO,stat as mO,rm as u5}from"fs/promises";import{join as Zi,basename as d5,extname as p5}from"path";import{randomUUID as hO}from"crypto";var f5,gO,m5,Li,Fi,wn,Vo,N_,h5,Go,tl,Wo,rl,lf,yO,uf,xO,df,cf,_O=f(()=>{f5=20,gO=1e5,m5=new Set(["image/jpeg","image/png","image/gif","image/webp"]),df=class df extends c5{constructor(){super(...arguments);k(this,wn);k(this,N_);k(this,Go);k(this,Wo);k(this,lf);k(this,uf);k(this,Li,null);k(this,Fi,null)}actions(r,n){return{listSessions:()=>this.listSessions(n),createSession:()=>this.createSession(n),deleteSession:o=>this.deleteSession(o,n),getMessages:o=>this.getMessages(o,n),appendMessage:(o,s)=>this.appendMessage(o,s,n),buildHistory:(o,s)=>this.buildHistory(o,n,s),getRunLogDir:()=>E(this,wn,Vo).call(this,n),saveAttachment:(o,s)=>this.saveAttachment(o,s,n),listAttachments:o=>this.listAttachments(o,n),deleteAttachment:(o,s)=>this.deleteAttachment(o,s,n)}}async listSessions(r){let n=await E(this,wn,Vo).call(this,r),o=(await $_(n)).filter(a=>a.endsWith(".jsonl"));return(await Promise.all(o.map(async a=>{let c=a.slice(0,-6),l=Zi(n,a),[u,d]=await Promise.all([mO(l),this.getMessages(c,r)]),p=d.find(h=>h.type==="user");return{id:c,title:p?.text?.slice(0,80)??"New chat",createdAt:d[0]?.timestamp??u.birthtimeMs,updatedAt:d[d.length-1]?.timestamp??u.mtimeMs,messageCount:d.length}}))).sort((a,c)=>c.updatedAt-a.updatedAt)}async createSession(r){await E(this,wn,Vo).call(this,r);let n=hO();return await pO(E(this,Go,tl).call(this,n,r),""),{id:n}}async deleteSession(r,n){if(await E(this,wn,Vo).call(this,n),await fO(E(this,Go,tl).call(this,r,n)).catch(()=>{}),n.assetsDir){let o=E(this,Wo,rl).call(this,r,n);await u5(o,{recursive:!0,force:!0}).catch(()=>{})}return{id:r,deleted:!0}}async getMessages(r,n){await E(this,wn,Vo).call(this,n);let o;try{o=await E_(E(this,Go,tl).call(this,r,n),"utf8")}catch(s){if(s.code==="ENOENT")return[];throw s}return o.split(`
150
- `).filter(Boolean).map(s=>{try{return JSON.parse(s)}catch{return null}}).filter(Boolean)}async appendMessage(r,n,o){return await E(this,wn,Vo).call(this,o),await l5(E(this,Go,tl).call(this,r,o),JSON.stringify(n)+`
151
- `),n}async saveAttachment(r,{name:n,mimeType:o,data:s},a){if(!a.assetsDir)throw new Error("assetsDir not configured");let c=E(this,Wo,rl).call(this,r,a);await k_(c,{recursive:!0});let l=hO(),u=d5(n).replace(/[^a-zA-Z0-9._-]/g,"_"),d=`${l}-${u}`,p=Zi(c,d),h=Buffer.isBuffer(s)?s:Buffer.from(s,"base64");return await pO(p,h),{id:l,name:u,path:p,mimeType:o||"application/octet-stream",size:h.length}}async listAttachments(r,n){if(!n.assetsDir)return[];let o=E(this,Wo,rl).call(this,r,n);try{let s=await $_(o);return Promise.all(s.filter(a=>!a.startsWith(".")).map(async a=>{let c=Zi(o,a),l=await mO(c),u=a.indexOf("-");return{id:u>0?a.slice(0,u):a,name:u>0?a.slice(u+1):a,path:c,size:l.size}}))}catch(s){if(s.code==="ENOENT")return[];throw s}}async deleteAttachment(r,n,o){if(!o.assetsDir)throw new Error("assetsDir not configured");let s=E(this,Wo,rl).call(this,r,o),c=(await $_(s).catch(()=>[])).find(l=>l.startsWith(n));return c&&await fO(Zi(s,c)),{id:n,deleted:!!c}}async buildHistory(r,n,o=f5){let s=await this.getMessages(r,n),a=[];for(let c of s.slice(-o))if(c.type==="user"){let l=await E(this,lf,yO).call(this,c,n);a.push({role:"user",content:l})}else{let l={role:"assistant",content:c.text};c.operationsSummary&&(l.hadOperations=!0,l.operationsSummary=c.operationsSummary),a.push(l)}return a}};Li=new WeakMap,Fi=new WeakMap,wn=new WeakSet,Vo=i(async function(r){return y(this,Li)||O(this,Li,k_(r.dir,{recursive:!0})),await y(this,Li),r.dir},"#ensureDir"),N_=new WeakSet,h5=i(async function(r){return r.assetsDir?(y(this,Fi)||O(this,Fi,k_(r.assetsDir,{recursive:!0})),await y(this,Fi),r.assetsDir):null},"#ensureAssetsDir"),Go=new WeakSet,tl=i(function(r,n){if(!/^[a-zA-Z0-9_-]+$/.test(r))throw new Error(`Invalid session id: ${r}`);return Zi(n.dir,`${r}.jsonl`)},"#pathFor"),Wo=new WeakSet,rl=i(function(r,n){if(!/^[a-zA-Z0-9_-]+$/.test(r))throw new Error(`Invalid session id: ${r}`);return Zi(n.assetsDir,r)},"#sessionAssetsDir"),lf=new WeakSet,yO=i(async function(r,n){if(!r.attachments?.length)return r.text;let o=[{type:"text",text:r.text}];for(let s of r.attachments)try{if(m5.has(s.mimeType)){let a=await E_(s.path);o.push({type:"image",source:{type:"base64",media_type:s.mimeType,data:a.toString("base64")}})}else if(s.mimeType?.startsWith("text/")||E(this,uf,xO).call(this,s.name)){let a=await E_(s.path,"utf8");a.length>gO&&(a=a.slice(0,gO)+`
152
- ...[truncated]`),o.push({type:"text",text:`--- ${s.name} ---
153
- ${a}`})}else o.push({type:"text",text:`[attached file: ${s.name}, ${s.mimeType}, ${s.size} bytes]`})}catch{o.push({type:"text",text:`[attachment unavailable: ${s.name}]`})}return o},"#expandUserContent"),uf=new WeakSet,xO=i(function(r){let n=p5(r).toLowerCase();return[".txt",".md",".json",".js",".ts",".jsx",".tsx",".css",".scss",".html",".xml",".yaml",".yml",".toml",".csv",".svg",".vue",".py",".rb",".go",".rs",".sh",".bash",".zsh",".env",".log"].includes(n)},"#isTextExtension"),i(df,"AiHistory"),Te(df,"manifest",{name:"AiHistory",namespace:"aiHistory",version:"1.0.0",description:"Persistent AI chat sessions (jsonl per session)"});cf=df});var vO={};R(vO,{AiAgent:()=>rf,AiHistory:()=>cf});var wO=f(()=>{dO();_O()});var T_,bO=f(()=>{vn();T_=bt("node",e=>({create:{description:'Create a new node in the scene graph. type is a prototype name (e.g. div, header, p, button, frame). Optional props (e.g. name, frame) and parent (defaults to "app").',alias:"create",mcpName:"create_node",schema:[{type:"String",props:"Object?",parent:"String?"}],examples:[{args:{type:"button",parent:"app"},description:"Create a button element"},{args:{type:"nav",parent:"app"},description:"Create a nav element"},{args:{type:"frame",props:{frame:"iPhone SE",name:"Home"}},description:"Create an iPhone SE frame named Home"}],returns:"{ id: String, type: String }",handler:async t=>{let r=e("state"),{addNode:n}=await Promise.resolve().then(()=>(Mu(),tg)),o=r.ref(["nodes"]),{type:s,props:a,parent:c="app"}=t,l=n(o,s,a,c);if(l instanceof Error)throw l;if(s==="frame"){let d=(o.get(["app","children"])??[]).filter(p=>p!==l);if(d.length>0){let p=0;for(let m of d){let g=o.get([m,"bounds"]);g&&(p=Math.max(p,(g.x??0)+(g.width??0)))}let{updateBounds:h}=await Promise.resolve().then(()=>(Oa(),Nh));h(o,l,{x:p+100,y:0})}}return{id:l,type:s}}},updateStyle:{description:'Update styles for a node. Optional breakpoint targets a variant: "@720" (responsive), ":hover" (pseudo-state), "&.is-active" (custom state).',mcpName:"update_style",schema:[{nodeId:"String",styles:"Object",breakpoint:"String?"}],examples:[{args:{nodeId:"nd_123",styles:{"background-color":"#2563eb",padding:"16px","border-radius":"8px"}},description:"Set background, padding, and border radius"},{args:{nodeId:"nd_123",styles:{"background-color":"#1d4ed8"},breakpoint:":hover"},description:"Set hover background"}],returns:"{ id: String, styles: Object }",handler:async t=>{let r=e("state"),{updateStyle:n}=await Promise.resolve().then(()=>(Ms(),Eh)),o=r.ref(["nodes"]),{nodeId:s,styles:a,breakpoint:c}=t,l=["display","position"].filter(h=>h in a),u={};c&&(c.startsWith(":")||c.startsWith("&")?u.interactionState=[c]:u.breakpoint=c);let d=n(o,s,{...a},u),p={id:s,styles:d};return l.length&&(p.warning=`Ignored ${l.join(", ")} \u2014 use node:setAutoLayout to change layout mode.`),p}},updateText:{description:"Set text content for a node. Use {{expression}} syntax for dynamic values.",mcpName:"update_text",schema:[{nodeId:"String",value:"String"}],examples:[{args:{nodeId:"nd_heading",value:"Welcome"},description:'Set static text to "Welcome"'},{args:{nodeId:"nd_label",value:"{{user.name}}"},description:"Set dynamic text with expression"}],returns:"{ id: String, textContent: Object }",handler:async t=>{let r=e("state"),{createTextContent:n}=await Promise.resolve().then(()=>(en(),Fh)),o=r.ref(["nodes"]),{nodeId:s,value:a}=t,c=n({value:a});return o.set([s,"textContent"],c),{id:s,textContent:c}}},move:{description:"Move a node to be the last child of another node",mcpName:"move_node",schema:[{nodeId:"String",parentId:"String"}],examples:[{args:{nodeId:"nd_link",parentId:"nd_nav"},description:"Move link into nav"}],returns:"{ id: String, movedTo: String, success: Boolean }",handler:async t=>{let r=e("state"),{disconnectNode:n}=await Promise.resolve().then(()=>(Ia(),i$)),{moveNodeToLastChildOf:o}=await Promise.resolve().then(()=>(Us(),E$)),s=r.ref(["nodes"]),{nodeId:a,parentId:c}=t;n(s,a);let l=o(s,a,c);return{id:a,movedTo:c,success:l}}},remove:{description:"Remove a node and all its descendants from the scene graph",alias:"removeNode",mcpName:"remove_node",schema:[{nodeId:"String"}],examples:[{args:{nodeId:"nd_old_element"},description:"Remove an element"}],returns:"{ id: String, removed: Boolean, removedNodes: Object }",handler:async t=>{let r=e("state"),{removeNode:n}=await Promise.resolve().then(()=>(Xg(),ON)),o=r.ref(["nodes"]),{nodeId:s}=t,[a,c]=n(o,s);return{id:a,removed:!0,removedNodes:c}}},setAutoLayout:{description:'Set the layout mode of a container node ("none" | "block" | "flex" | "grid"). Sets layout on the parent and the corresponding display style, and normalizes all direct children so they flow correctly. Always use this instead of setting display via updateStyle.',alias:"setLayout",mcpName:"set_layout",schema:[{nodeId:"String",layout:"String"}],examples:[{args:{nodeId:"nd_container",layout:"flex"},description:"Enable flex auto-layout on a container"},{args:{nodeId:"nd_container",layout:"none"},description:"Disable auto-layout, reverting children to absolute positioning"}],returns:"{ id: String, layout: String, childrenUpdated: Number }",handler:async t=>{let r=e("state"),{setNodeLayout:n}=await Promise.resolve().then(()=>(Ku(),Ag)),o=r.ref(["nodes"]),{nodeId:s,layout:a}=t;return n(o,s,a)}},setName:{description:"Set a display name on a node. Names appear in get_scene output and make the tree readable. Pass an empty string to clear back to the default (tag name).",mcpName:"set_name",schema:[{nodeId:"String",name:"String"}],examples:[{args:{nodeId:"nd_123",name:"Hero Section"},description:"Name a section"}],returns:"{ id: String, name: String }",handler:async t=>{let n=e("state").ref(["nodes"]),{nodeId:o,name:s}=t;if(s===""){let{clearName:c}=await Promise.resolve().then(()=>(Yu(),Lg));return c(n,o),{id:o,name:""}}let{setName:a}=await Promise.resolve().then(()=>(Mg(),SN));return a(n,o,s),{id:o,name:s}}},clearName:{description:"Clear the display name from a node, reverting to its tag name.",schema:[{nodeId:"String"}],examples:[{args:{nodeId:"nd_123"},description:"Clear name back to default"}],returns:"{ id: String }",handler:async t=>{let r=e("state"),{clearName:n}=await Promise.resolve().then(()=>(Yu(),Lg)),o=r.ref(["nodes"]),{nodeId:s}=t;return n(o,s),{id:s}}},addComponent:{description:"Convert an existing node into a reusable local component. The node is replaced in-place by an instance; the original tree becomes the component definition. Returns instanceId and componentId.",mcpName:"add_component",schema:[{nodeId:"String",name:"String?"}],examples:[{args:{nodeId:"nd_card",name:"Card"},description:"Convert a card node into a reusable component"}],returns:"{ instanceId: String, componentId: String, name: String }",handler:async t=>{let r=e("state"),{addComponent:n}=await Promise.resolve().then(()=>(ng(),bE)),o=r.ref(["nodes"]),{nodeId:s,name:a=""}=t,c=n(o,s,a),l=o.get([c,"component"]);return{instanceId:c,componentId:l,name:a}}}}))});var z_,SO=f(()=>{vn();z_=bt("tree",e=>({create:{description:'Create a nested tree of nodes recursively (use for complex structures like mobile pages). For frames, parent MUST be "app".',alias:"createTree",schema:[{tree:"Object",parent:"String?"}],examples:[{args:{tree:{type:"frame",name:"Home",frame:"iPhone SE",bounds:{x:0,y:400},styles:{display:"flex","flex-direction":"column",overflow:"hidden"},children:[{type:"header",styles:{padding:"16px"},children:[{type:"h1",text:"App Name"}]},{type:"main",styles:{flex:"1"}},{type:"footer",styles:{padding:"16px"},text:"Footer"}]},parent:"app"},description:"Create mobile page with header, main, footer \u2014 frame is the flex container"}],returns:"{ rootId: String, createdIds: Array, treeMap: Object }",handler:async t=>{let r=e("state"),n=e("log"),{addNode:o}=await Promise.resolve().then(()=>(Mu(),tg)),{updateStyle:s}=await Promise.resolve().then(()=>(Ms(),Eh)),{setNodeLayout:a}=await Promise.resolve().then(()=>(Ku(),Ag)),{normalizeLayoutContext:c}=await Promise.resolve().then(()=>(Xr(),S$)),{createTextContent:l}=await Promise.resolve().then(()=>(en(),Fh)),u=r.ref(["nodes"]),{tree:d,parent:p="app"}=t,h=[],m={},g=i((x,v)=>{let{type:w,children:b,styles:S,style:T,text:K,ref:A,bounds:Y,...W}=x,L=o(u,w,W,v);if(h.push(L),A&&(m[A]=L),w==="frame"&&Y){let{x:Re,y:Fe}=Y,Ps=u.get([L,"bounds"])??{};u.set([L,"bounds"],{...Ps,...Re!=null?{x:Re}:{},...Fe!=null?{y:Fe}:{}})}let X=W.name;X&&u.set([L,"name"],X);let se=S||T;se&&Object.keys(se).length>0&&s(u,L,{...se});let ur=se?.display??u.get([L,"style","default","display"]),be=ur==="flex"||ur==="grid";if(be)try{a(u,L,ur)}catch(Re){n.warn("setNodeLayout failed for parent",{id:L,error:Re.message})}if(K&&!(b?.length>0)){let Re=l({value:K});u.set([L,"textContent"],Re)}return b&&b.length>0&&b.forEach(Re=>{if(be){let Ps=Re.styles||Re.style||{};Ps.position!=="absolute"&&(Re={...Re,styles:{width:"auto",height:"auto",top:"auto",left:"auto",...Ps}})}let Fe=g(Re,L);be&&c(u,Fe,L)}),L},"createRecursive"),_=g(d,p);return{id:_,rootId:_,createdIds:h,treeMap:m,type:"tree"}}}}))});var pf={};R(pf,{normalizeEventName:()=>y5});function y5(e){if(typeof e!="string"||e.length===0)throw new Error('Event name must be a non-empty string. Use React-style names like "onClick" or "onSubmit".');if(g5.has(e))return e;let t=e.toLowerCase(),r=t.startsWith("on")?t.slice(2):t,n=C_[r]??C_[t];if(n)return n;throw new Error(`Unknown event name: "${e}". Use React-style names like "onClick", "onSubmit", or "onMouseEnter".`)}var C_,g5,ff=f(()=>{C_={click:"onClick",dblclick:"onDoubleClick",doubleclick:"onDoubleClick",contextmenu:"onContextMenu",mousedown:"onMouseDown",mouseup:"onMouseUp",mousemove:"onMouseMove",mouseenter:"onMouseEnter",mouseleave:"onMouseLeave",mouseover:"onMouseOver",mouseout:"onMouseOut",drag:"onDrag",dragstart:"onDragStart",dragend:"onDragEnd",dragenter:"onDragEnter",dragleave:"onDragLeave",dragover:"onDragOver",drop:"onDrop",keydown:"onKeyDown",keyup:"onKeyUp",keypress:"onKeyPress",change:"onChange",input:"onInput",submit:"onSubmit",reset:"onReset",focus:"onFocus",blur:"onBlur",invalid:"onInvalid",formdata:"onFormData",touchstart:"onTouchStart",touchmove:"onTouchMove",touchend:"onTouchEnd",touchcancel:"onTouchCancel",wheel:"onWheel",copy:"onCopy",cut:"onCut",paste:"onPaste",abort:"onAbort",canplay:"onCanPlay",canplaythrough:"onCanPlayThrough",durationchange:"onDurationChange",emptied:"onEmptied",ended:"onEnded",loadeddata:"onLoadedData",loadedmetadata:"onLoadedMetadata",loadstart:"onLoadStart",pause:"onPause",play:"onPlay",playing:"onPlaying",progress:"onProgress",ratechange:"onRateChange",seeked:"onSeeked",seeking:"onSeeking",stalled:"onStalled",suspend:"onSuspend",timeupdate:"onTimeUpdate",volumechange:"onVolumeChange",waiting:"onWaiting",animationstart:"onAnimationStart",animationend:"onAnimationEnd",animationiteration:"onAnimationIteration",transitionend:"onTransitionEnd",load:"onLoad",error:"onError",scroll:"onScroll",scrollend:"onScrollEnd",resize:"onResize",select:"onSelect",toggle:"onToggle",afterprint:"onAfterPrint",beforeprint:"onBeforePrint",beforeunload:"onBeforeUnload",hashchange:"onHashChange",languagechange:"onLanguageChange",message:"onMessage",messageerror:"onMessageError",offline:"onOffline",online:"onOnline",pagehide:"onPageHide",pageshow:"onPageShow",popstate:"onPopState",rejectionhandled:"onRejectionHandled",storage:"onStorage",unhandledrejection:"onUnhandledRejection",unload:"onUnload",auxclick:"onAuxClick",beforematch:"onBeforeMatch",beforetoggle:"onBeforeToggle",cancel:"onCancel",close:"onClose",contextlost:"onContextLost",contextrestored:"onContextRestored",cuechange:"onCueChange",securitypolicyviolation:"onSecurityPolicyViolation",slotchange:"onSlotChange"},g5=new Set(Object.values(C_));i(y5,"normalizeEventName")});var I_,kO=f(()=>{vn();I_=bt("behavior",e=>({addEvent:{description:'Add or replace an event handler on a node (replaces any existing handler with the same name). Event names use React-style onX format (onClick, onSubmit, onInput, onChange, onMouseEnter, etc.); lowercase names like "click" or "submit" are auto-normalized. Use binding for zero-arg store actions (e.g. "$store.myStore.doSomething"); use code when you need arguments or complex logic \u2014 code MUST be a complete function expression: function (ctx, event) { ... }. Access stores inside the handler via ctx.$store.<storeName>.',mcpName:"add_event",schema:[{nodeId:"String",name:"String",binding:"String?",code:"String?",mode:"String?"}],examples:[{args:{nodeId:"nd_btn",name:"onClick",binding:"$store.default.increment"},description:"Call store action on click"},{args:{nodeId:"nd_btn",name:"onClick",code:`function (ctx, event) {
192
+ `)},"#captureFeedback"),sh=new WeakSet,fM=i(function(){return{requests:0,input:0,output:0,cacheRead:0,cacheWrite:0,billedTokens:0,estimatedCostUsd:0,model:null}},"#newUsage"),$u=new WeakSet,Vw=i(function(r,n,o){if(!n)return;let s=n.input_tokens??0,a=n.output_tokens??0,c=n.cache_creation_input_tokens??0,l=n.cache_read_input_tokens??0;r.requests+=1,r.input+=s,r.output+=a,r.cacheWrite+=c,r.cacheRead+=l,r.billedTokens+=s+a+c+l,o&&(r.model=o),r.estimatedCostUsd+=Ns({input:s,output:a,cacheWrite:c,cacheRead:l},o??r.model)},"#accumulateUsage"),jn=new WeakSet,Cs=i(function(r,n,o,s,a){let c=n.reduce((p,m)=>p+m.operations,0),l=a.cacheRead+a.cacheWrite+a.input,u=l>0?a.cacheRead/l:0,d={reason:s,prompt:r.substring(0,120),iterations:n.length,totalOperations:c,totalDurationMs:Date.now()-o,timestamp:Date.now(),usage:{...a,cacheHitRate:Number(u.toFixed(3)),estimatedCostUsd:Number(a.estimatedCostUsd.toFixed(4))},perIteration:n.map(p=>({i:p.iteration,ops:p.operations,...p.screenshots?{shots:p.screenshots}:{},ms:p.durationMs}))};console.log("[AiAgent] run complete",JSON.stringify(d,null,2)),k(this,ih,mM).call(this,d).catch(()=>{})},"#logRunSummary"),ih=new WeakSet,mM=i(async function(r){let o=await this.inject("aiHistory").getRunLogDir(),{appendFile:s}=await import("fs/promises"),{join:a}=await import("path");await s(a(o,"runs.jsonl"),JSON.stringify(r)+`
193
+ `)},"#persistRunLog"),Eu=new WeakSet,Gw=i(async function({prompt:r,context:n,history:o,turns:s=[],tools:a=null,playbook:c=null,token:l,orgId:u=null,signal:d=null,windDown:p=!1},m){let h={"Content-Type":"application/json"};l&&(h.Authorization=`Bearer ${l}`),u&&(h["X-Jucie-Org"]=u);let g=await fetch(m.aiServerUrl,{method:"POST",headers:h,body:JSON.stringify({prompt:r,context:n,history:o,turns:s,tools:a,playbook:c,...p?{windDown:!0}:{}}),signal:d??void 0}),_=await g.json().catch(()=>({}));if(!g.ok){let v=_.error??`HTTP ${g.status}`,b=new Error(`AI request failed (${g.status}): ${v}`);throw b.status=g.status,b.budget=_.budget??null,b}let x=_.content;if(typeof x=="string")try{x=JSON.parse(x)}catch{x={message:x}}return{content:x,blocks:_.blocks??null,toolBlocks:_.toolBlocks??null,usage:_.usage??null,model:_.model??null,budget:_.budget??null}},"#request"),Nu=new WeakSet,Ww=i(function(r){return r&&typeof r=="object"&&Array.isArray(r.operations)&&r.operations.length>0},"#isOperationsBatch"),i(ah,"AiAgent"),_e(ah,"manifest",{name:"AiAgent",namespace:"aiAgent",version:"1.0.0",description:"Server-side AI agent loop"});Vm=ah});import{ServiceProvider as qJ}from"@jucie.io/engine";import{mkdir as Jw,readdir as ch,readFile as Kw,appendFile as BJ,writeFile as gM,unlink as yM,stat as xM,rm as HJ}from"fs/promises";import{join as ho,basename as VJ,extname as _M}from"path";import{randomUUID as vM}from"crypto";import{existsSync as GJ}from"fs";function XJ(e){return YJ[e.toLowerCase()]||"application/octet-stream"}var WJ,JJ,wM,KJ,YJ,Pa,Oa,Dn,Is,Yw,QJ,Os,Tu,Mn,Ps,uh,bM,dh,SM,ph,kM,fh,lh,$M=f(()=>{WJ=20,JJ="runs.jsonl",wM=1e5,KJ=new Set(["image/jpeg","image/png","image/gif","image/webp"]),YJ={".jpg":"image/jpeg",".jpeg":"image/jpeg",".png":"image/png",".gif":"image/gif",".webp":"image/webp",".svg":"image/svg+xml",".txt":"text/plain",".md":"text/markdown",".json":"application/json",".pdf":"application/pdf"};i(XJ,"mimeFromExt");fh=class fh extends qJ{constructor(){super(...arguments);$(this,Dn);$(this,Yw);$(this,Os);$(this,Mn);$(this,uh);$(this,dh);$(this,ph);$(this,Pa,null);$(this,Oa,null)}actions(r,n){return{listSessions:()=>this.listSessions(n),createSession:()=>this.createSession(n),deleteSession:o=>this.deleteSession(o,n),getMessages:o=>this.getMessages(o,n),appendMessage:(o,s)=>this.appendMessage(o,s,n),buildHistory:(o,s)=>this.buildHistory(o,n,s),getRunLogDir:()=>k(this,Dn,Is).call(this,n),saveAttachment:(o,s)=>this.saveAttachment(o,s,n),listAttachments:o=>this.listAttachments(o,n),getAttachment:(o,s)=>this.getAttachment(o,s,n),deleteAttachment:(o,s)=>this.deleteAttachment(o,s,n)}}async listSessions(r){let n=await k(this,Dn,Is).call(this,r),o=(await ch(n)).filter(a=>a.endsWith(".jsonl")).filter(a=>a!==JJ);return(await Promise.all(o.map(async a=>{let c=a.slice(0,-6),l=ho(n,a),[u,d]=await Promise.all([xM(l),this.getMessages(c,r)]),p=d.find(m=>m.type==="user");return{id:c,title:p?.text?.slice(0,80)??"New chat",createdAt:d[0]?.timestamp??u.birthtimeMs,updatedAt:d[d.length-1]?.timestamp??u.mtimeMs,messageCount:d.length}}))).sort((a,c)=>c.updatedAt-a.updatedAt)}async createSession(r){await k(this,Dn,Is).call(this,r);let n=vM();return await gM(k(this,Os,Tu).call(this,n,r),""),{id:n}}async deleteSession(r,n){if(await k(this,Dn,Is).call(this,n),await yM(k(this,Os,Tu).call(this,r,n)).catch(()=>{}),n.attachmentsDir){let o=k(this,Mn,Ps).call(this,r,n);await HJ(o,{recursive:!0,force:!0}).catch(()=>{})}return{id:r,deleted:!0}}async getMessages(r,n){await k(this,Dn,Is).call(this,n);let o;try{o=await Kw(k(this,Os,Tu).call(this,r,n),"utf8")}catch(s){if(s.code==="ENOENT")return[];throw s}return o.split(`
194
+ `).filter(Boolean).map(s=>{try{return JSON.parse(s)}catch{return null}}).filter(Boolean)}async appendMessage(r,n,o){return await k(this,Dn,Is).call(this,o),await BJ(k(this,Os,Tu).call(this,r,o),JSON.stringify(n)+`
195
+ `),n}async saveAttachment(r,{name:n,mimeType:o,data:s},a){if(!a.attachmentsDir)throw new Error("attachmentsDir not configured");let c=k(this,Mn,Ps).call(this,r,a);await Jw(c,{recursive:!0});let l=vM(),u=VJ(n).replace(/[^a-zA-Z0-9._-]/g,"_"),d=`${l}-${u}`,p=ho(c,d),m=Buffer.isBuffer(s)?s:Buffer.from(s,"base64");return await gM(p,m),{id:l,name:u,path:p,mimeType:o||"application/octet-stream",size:m.length}}async listAttachments(r,n){if(!n.attachmentsDir)return[];let o=k(this,Mn,Ps).call(this,r,n);try{let s=await ch(o);return Promise.all(s.filter(a=>!a.startsWith(".")).map(async a=>{let c=ho(o,a),l=await xM(c),u=a.indexOf("-");return{id:u>0?a.slice(0,u):a,name:u>0?a.slice(u+1):a,path:c,size:l.size}}))}catch(s){if(s.code==="ENOENT")return[];throw s}}async deleteAttachment(r,n,o){if(!o.attachmentsDir)throw new Error("attachmentsDir not configured");let s=k(this,Mn,Ps).call(this,r,o),c=(await ch(s).catch(()=>[])).find(l=>l.startsWith(n));return c&&await yM(ho(s,c)),{id:n,deleted:!!c}}async getAttachment(r,n,o){if(!o.attachmentsDir||!/^[a-zA-Z0-9_-]+$/.test(n))return null;let s=k(this,Mn,Ps).call(this,r,o),c=(await ch(s).catch(()=>[])).find(p=>p.startsWith(`${n}-`)||p===n);if(!c)return null;let l=c.indexOf("-"),u=l>0?c.slice(l+1):c,d=ho(s,c);return{id:n,name:u,path:d,mimeType:XJ(_M(u))}}async buildHistory(r,n,o=WJ){let s=await this.getMessages(r,n),a=[],c=Math.max(0,s.length-o);for(let l=c;l<s.length;l++){let u=s[l];if(u.type==="user"){let d=await k(this,dh,SM).call(this,u,r,n);a.push({role:"user",content:d,seq:l})}else{let d={role:"assistant",content:u.text,seq:l};u.operationsSummary&&(d.hadOperations=!0,d.operationsSummary=u.operationsSummary),a.push(d)}}return a}};Pa=new WeakMap,Oa=new WeakMap,Dn=new WeakSet,Is=i(async function(r){return y(this,Pa)||O(this,Pa,Jw(r.dir,{recursive:!0})),await y(this,Pa),r.dir},"#ensureDir"),Yw=new WeakSet,QJ=i(async function(r){return r.attachmentsDir?(y(this,Oa)||O(this,Oa,Jw(r.attachmentsDir,{recursive:!0})),await y(this,Oa),r.attachmentsDir):null},"#ensureAttachmentsDir"),Os=new WeakSet,Tu=i(function(r,n){if(!/^[a-zA-Z0-9_-]+$/.test(r))throw new Error(`Invalid session id: ${r}`);return ho(n.dir,`${r}.jsonl`)},"#pathFor"),Mn=new WeakSet,Ps=i(function(r,n){if(!/^[a-zA-Z0-9_-]+$/.test(r))throw new Error(`Invalid session id: ${r}`);return ho(n.attachmentsDir,r)},"#sessionAttachmentsDir"),uh=new WeakSet,bM=i(function(r,n,o){if(o.attachmentsDir&&r.id&&r.name){let s=ho(k(this,Mn,Ps).call(this,n,o),`${r.id}-${r.name}`);if(GJ(s))return s}return r.path},"#attachmentPath"),dh=new WeakSet,SM=i(async function(r,n,o){if(!r.attachments?.length)return r.text;let s=[{type:"text",text:r.text}];for(let a of r.attachments)try{let c=k(this,uh,bM).call(this,a,n,o);if(KJ.has(a.mimeType)){let l=await Kw(c);s.push({type:"image",source:{type:"base64",media_type:a.mimeType,data:l.toString("base64")}})}else if(a.mimeType?.startsWith("text/")||k(this,ph,kM).call(this,a.name)){let l=await Kw(c,"utf8");l.length>wM&&(l=l.slice(0,wM)+`
196
+ ...[truncated]`),s.push({type:"text",text:`--- ${a.name} ---
197
+ ${l}`})}else s.push({type:"text",text:`[attached file: ${a.name}, ${a.mimeType}, ${a.size} bytes]`})}catch{s.push({type:"text",text:`[attachment unavailable: ${a.name}]`})}return s},"#expandUserContent"),ph=new WeakSet,kM=i(function(r){let n=_M(r).toLowerCase();return[".txt",".md",".json",".js",".ts",".jsx",".tsx",".css",".scss",".html",".xml",".yaml",".yml",".toml",".csv",".svg",".vue",".py",".rb",".go",".rs",".sh",".bash",".zsh",".env",".log"].includes(n)},"#isTextExtension"),i(fh,"AiHistory"),_e(fh,"manifest",{name:"AiHistory",namespace:"aiHistory",version:"1.0.0",description:"Persistent AI chat sessions (jsonl per session)"});lh=fh});var EM={};C(EM,{AiAgent:()=>Vm,AiHistory:()=>lh});var NM=f(()=>{hM();$M()});var Xw,TM=f(()=>{Rn();Xw=Tt("node",e=>({create:{description:'Create a new node in the scene graph. type is a prototype name (e.g. div, header, p, button, frame). Optional props (e.g. name, frame). parent is the id of the container to create the node INSIDE \u2014 always pass it when a container exists. It falls back to "app" (the canvas root), which is only correct for frames; creating at the root and moving the node afterwards costs two operations instead of one and re-renders the scene twice.',alias:"create",mcpName:"create_node",schema:[{type:"String",props:"Object?",parent:"String?"}],examples:[{args:{type:"button",parent:"nd_hero"},description:"Create a button inside an existing container \u2014 pass that container id as parent"},{args:{type:"frame",props:{frame:"iPhone SE",name:"Home"},parent:"app"},description:"Frames are the exception \u2014 they belong at the canvas root"},{args:{type:"nav",parent:"nd_header"},description:"Create a nav inside an existing header"}],returns:"{ id: String, type: String }",handler:async t=>{let r=e("state"),{addNode:n}=await Promise.resolve().then(()=>(mp(),H1)),o=r.ref(["nodes"]),{type:s,props:a,parent:c="app"}=t,l=n(o,s,a,c);if(l instanceof Error)throw l;if(s==="frame"){let d=(o.get(["app","children"])??[]).filter(p=>p!==l);if(d.length>0){let p=0;for(let h of d){let g=o.get([h,"bounds"]);g&&(p=Math.max(p,(g.x??0)+(g.width??0)))}let{updateBounds:m}=await Promise.resolve().then(()=>(Nc(),Cy));m(o,l,{x:p+100,y:0})}}return{id:l,type:s}}},updateStyle:{description:'Update styles for a node. Optional breakpoint targets a variant: "@720" (responsive), ":hover" (pseudo-state), "&.is-active" (custom state).',mcpName:"update_style",schema:[{nodeId:"String",styles:"Object",breakpoint:"String?"}],examples:[{args:{nodeId:"nd_123",styles:{"background-color":"#2563eb",padding:"16px","border-radius":"8px"}},description:"Set background, padding, and border radius"},{args:{nodeId:"nd_123",styles:{"background-color":"#1d4ed8"},breakpoint:":hover"},description:"Set hover background"}],returns:"{ id: String, styles: Object }",handler:async t=>{let r=e("state"),{updateStyle:n}=await Promise.resolve().then(()=>(Lo(),HN)),o=r.ref(["nodes"]),{nodeId:s,styles:a,breakpoint:c}=t,l=["display","position"].filter(m=>m in a),u={};c&&(c.startsWith(":")||c.startsWith("&")?u.interactionState=[c]:u.breakpoint=c);let d=n(o,s,{...a},u),p={id:s,styles:d};return l.length&&(p.warning=`Ignored ${l.join(", ")} \u2014 use node:setAutoLayout to change layout mode.`),p}},updateText:{description:"Set text content for a node. Use {{expression}} syntax for dynamic values.",mcpName:"update_text",schema:[{nodeId:"String",value:"String"}],examples:[{args:{nodeId:"nd_heading",value:"Welcome"},description:'Set static text to "Welcome"'},{args:{nodeId:"nd_label",value:"{{user.name}}"},description:"Set dynamic text with expression"}],returns:"{ id: String, textContent: Object }",handler:async t=>{let r=e("state"),{createTextContent:n}=await Promise.resolve().then(()=>(fn(),v1)),o=r.ref(["nodes"]),{nodeId:s,value:a}=t,c=n({value:a});return o.set([s,"textContent"],c),{id:s,textContent:c}}},move:{description:"Move a node to be the last child of another node",mcpName:"move_node",schema:[{nodeId:"String",parentId:"String"}],examples:[{args:{nodeId:"nd_link",parentId:"nd_nav"},description:"Move link into nav"}],returns:"{ id: String, movedTo: String, success: Boolean }",handler:async t=>{let r=e("state"),{disconnectNode:n}=await Promise.resolve().then(()=>(wi(),AN)),{moveNodeToLastChildOf:o}=await Promise.resolve().then(()=>(Ci(),e1)),s=r.ref(["nodes"]),{nodeId:a,parentId:c}=t;n(s,a);let l=o(s,a,c);return{id:a,movedTo:c,success:l}}},remove:{description:"Remove a node and all its descendants from the scene graph",alias:"removeNode",mcpName:"remove_node",schema:[{nodeId:"String"}],examples:[{args:{nodeId:"nd_old_element"},description:"Remove an element"}],returns:"{ id: String, removed: Boolean, removedNodes: Object }",handler:async t=>{let r=e("state"),{removeNode:n}=await Promise.resolve().then(()=>(Jx(),hz)),o=r.ref(["nodes"]),{nodeId:s}=t,[a,c]=n(o,s);return{id:a,removed:!0,removedNodes:c}}},setAutoLayout:{description:'Set the layout mode of a container node ("none" | "block" | "flex" | "grid"). Sets layout on the parent and the corresponding display style, and normalizes all direct children so they flow correctly. Always use this instead of setting display via updateStyle.',alias:"setLayout",mcpName:"set_layout",schema:[{nodeId:"String",layout:"String"}],examples:[{args:{nodeId:"nd_container",layout:"flex"},description:"Enable flex auto-layout on a container"},{args:{nodeId:"nd_container",layout:"none"},description:"Disable auto-layout, reverting children to absolute positioning"}],returns:"{ id: String, layout: String, childrenUpdated: Number }",handler:async t=>{let r=e("state"),{setNodeLayout:n}=await Promise.resolve().then(()=>(yp(),sT)),o=r.ref(["nodes"]),{nodeId:s,layout:a}=t;return n(o,s,a)}},setName:{description:"Set a display name on a node. Names appear in get_scene output and make the tree readable. Pass an empty string to clear back to the default (tag name).",mcpName:"set_name",schema:[{nodeId:"String",name:"String"}],examples:[{args:{nodeId:"nd_123",name:"Hero Section"},description:"Name a section"}],returns:"{ id: String, name: String }",handler:async t=>{let n=e("state").ref(["nodes"]),{nodeId:o,name:s}=t;if(s===""){let{clearName:c}=await Promise.resolve().then(()=>(zp(),Dx));return c(n,o),{id:o,name:""}}let{setName:a}=await Promise.resolve().then(()=>(Rx(),oz));return a(n,o,s),{id:o,name:s}}},clearName:{description:"Clear the display name from a node, reverting to its tag name.",schema:[{nodeId:"String"}],examples:[{args:{nodeId:"nd_123"},description:"Clear name back to default"}],returns:"{ id: String }",handler:async t=>{let r=e("state"),{clearName:n}=await Promise.resolve().then(()=>(zp(),Dx)),o=r.ref(["nodes"]),{nodeId:s}=t;return n(o,s),{id:s}}},addComponent:{description:"Convert an existing node into a reusable local component. Nested nodes are replaced in-place by an instance; direct children of app/temp become the component artboard only (no instance). Returns componentId and instanceId (null when promoted from app/temp).",mcpName:"add_component",schema:[{nodeId:"String",name:"String?"}],examples:[{args:{nodeId:"nd_card",name:"Card"},description:"Convert a card node into a reusable component"}],returns:"{ instanceId: String | null, componentId: String, name: String }",handler:async t=>{let r=e("state"),{addComponent:n}=await Promise.resolve().then(()=>(rx(),tT)),o=r.ref(["nodes"]),{nodeId:s,name:a=""}=t,{componentId:c,instanceId:l}=n(o,s,a);return{instanceId:l,componentId:c,name:a}}}}))});var Qw,zM=f(()=>{Rn();Qw=Tt("tree",e=>({create:{description:'Create a nested tree of nodes recursively (use for complex structures like page sections). FRAMES are the only tree that belongs at the root \u2014 they MUST have parent "app". Every other tree must be created directly into its container by passing that container id as parent. Never create at the root and move afterwards: that costs two operations per node and re-renders the scene twice.',alias:"createTree",schema:[{tree:"Object",parent:"String?"}],examples:[{args:{tree:{type:"frame",name:"Home",frame:"iPhone SE",bounds:{x:0,y:400},styles:{display:"flex","flex-direction":"column",overflow:"hidden"},children:[{type:"header",styles:{padding:"16px"},children:[{type:"h1",text:"App Name"}]},{type:"main",styles:{flex:"1"}},{type:"footer",styles:{padding:"16px"},text:"Footer"}]},parent:"app"},description:'A FRAME goes at the canvas root \u2014 parent "app"'},{args:{tree:{type:"section",name:"Hero Section",styles:{display:"flex","flex-direction":"column",gap:"24px",padding:"64px"},children:[{type:"h1",name:"Headline",text:"Build faster"},{type:"p",name:"Subheadline",text:"Ship in minutes, not weeks."},{type:"button",name:"CTA Button",text:"Get started"}]},parent:"nd_home_frame"},description:"Everything that is NOT a frame is created directly inside its container \u2014 pass the container id, do not create at the root and move it"}],returns:"{ rootId: String, createdIds: Array, treeMap: Object }",handler:async t=>{let r=e("state"),n=e("log"),{addTree:o}=await Promise.resolve().then(()=>(ax(),cT)),s=r.ref(["nodes"]),{tree:a,parent:c="app"}=t,{rootId:l,createdIds:u,treeMap:d}=o(s,a,c,{onWarn:(p,m)=>n.warn(p,m)});return{id:l,rootId:l,createdIds:u,treeMap:d,type:"tree"}}}}))});var mh={};C(mh,{normalizeEventName:()=>tK});function tK(e){if(typeof e!="string"||e.length===0)throw new Error('Event name must be a non-empty string. Use React-style names like "onClick" or "onSubmit".');if(eK.has(e))return e;let t=e.toLowerCase(),r=t.startsWith("on")?t.slice(2):t,n=eb[r]??eb[t];if(n)return n;throw new Error(`Unknown event name: "${e}". Use React-style names like "onClick", "onSubmit", or "onMouseEnter".`)}var eb,eK,hh=f(()=>{eb={click:"onClick",dblclick:"onDoubleClick",doubleclick:"onDoubleClick",contextmenu:"onContextMenu",mousedown:"onMouseDown",mouseup:"onMouseUp",mousemove:"onMouseMove",mouseenter:"onMouseEnter",mouseleave:"onMouseLeave",mouseover:"onMouseOver",mouseout:"onMouseOut",drag:"onDrag",dragstart:"onDragStart",dragend:"onDragEnd",dragenter:"onDragEnter",dragleave:"onDragLeave",dragover:"onDragOver",drop:"onDrop",keydown:"onKeyDown",keyup:"onKeyUp",keypress:"onKeyPress",change:"onChange",input:"onInput",submit:"onSubmit",reset:"onReset",focus:"onFocus",blur:"onBlur",invalid:"onInvalid",formdata:"onFormData",touchstart:"onTouchStart",touchmove:"onTouchMove",touchend:"onTouchEnd",touchcancel:"onTouchCancel",wheel:"onWheel",copy:"onCopy",cut:"onCut",paste:"onPaste",abort:"onAbort",canplay:"onCanPlay",canplaythrough:"onCanPlayThrough",durationchange:"onDurationChange",emptied:"onEmptied",ended:"onEnded",loadeddata:"onLoadedData",loadedmetadata:"onLoadedMetadata",loadstart:"onLoadStart",pause:"onPause",play:"onPlay",playing:"onPlaying",progress:"onProgress",ratechange:"onRateChange",seeked:"onSeeked",seeking:"onSeeking",stalled:"onStalled",suspend:"onSuspend",timeupdate:"onTimeUpdate",volumechange:"onVolumeChange",waiting:"onWaiting",animationstart:"onAnimationStart",animationend:"onAnimationEnd",animationiteration:"onAnimationIteration",transitionend:"onTransitionEnd",load:"onLoad",error:"onError",scroll:"onScroll",scrollend:"onScrollEnd",resize:"onResize",select:"onSelect",toggle:"onToggle",afterprint:"onAfterPrint",beforeprint:"onBeforePrint",beforeunload:"onBeforeUnload",hashchange:"onHashChange",languagechange:"onLanguageChange",message:"onMessage",messageerror:"onMessageError",offline:"onOffline",online:"onOnline",pagehide:"onPageHide",pageshow:"onPageShow",popstate:"onPopState",rejectionhandled:"onRejectionHandled",storage:"onStorage",unhandledrejection:"onUnhandledRejection",unload:"onUnload",auxclick:"onAuxClick",beforematch:"onBeforeMatch",beforetoggle:"onBeforeToggle",cancel:"onCancel",close:"onClose",contextlost:"onContextLost",contextrestored:"onContextRestored",cuechange:"onCueChange",securitypolicyviolation:"onSecurityPolicyViolation",slotchange:"onSlotChange"},eK=new Set(Object.values(eb));i(tK,"normalizeEventName")});var tb,CM=f(()=>{Rn();tb=Tt("behavior",e=>({addEvent:{description:'Add or replace an event handler on a node (replaces any existing handler with the same name). Event names use React-style onX format (onClick, onSubmit, onInput, onChange, onMouseEnter, etc.); lowercase names like "click" or "submit" are auto-normalized. Use binding for zero-arg store actions (e.g. "$store.myStore.doSomething"); use code when you need arguments or complex logic \u2014 code MUST be a complete function expression: function (ctx, event) { ... }. Access stores inside the handler via ctx.$store.<storeName>.',mcpName:"add_event",schema:[{nodeId:"String",name:"String",binding:"String?",code:"String?",mode:"String?"}],examples:[{args:{nodeId:"nd_btn",name:"onClick",binding:"$store.default.increment"},description:"Call store action on click"},{args:{nodeId:"nd_btn",name:"onClick",code:`function (ctx, event) {
154
198
  ctx.$store.todo.items.push({ text: ctx.$store.todo.newTodo, done: false })
155
199
  ctx.$store.todo.newTodo = ""
156
200
  }`},description:"Add click handler with code"},{args:{nodeId:"nd_form",name:"onSubmit",code:`function (ctx, event) {
157
201
  event.preventDefault()
158
- }`},description:"Prevent default on form submit"}],returns:"{ id: String, name: String }",handler:async t=>{let r=e("state"),{addEvent:n}=await Promise.resolve().then(()=>(ig(),kE)),{updateEvent:o}=await Promise.resolve().then(()=>(Lu(),cg)),{normalizeEventName:s}=await Promise.resolve().then(()=>(ff(),pf)),a=r.ref(["nodes"]),{nodeId:c,name:l,binding:u,code:d,mode:p}=t,h=s(l);if((a.get([c,"events"])??[]).find(_=>_.name===h)||n(a,c,h),u!==void 0){let _=(a.get([c,"events"])??[]).find(x=>x.name===h)??{name:h};o(a,c,h,{..._,mode:"binding",binding:u.split("."),code:null})}else if(d!==void 0){let _=(a.get([c,"events"])??[]).find(x=>x.name===h)??{name:h};o(a,c,h,{..._,mode:p??"code",code:d,binding:null})}return{id:c,name:h}}},updateEvent:{description:"Update an existing event handler by name",schema:[{nodeId:"String",name:"String",event:"Object"}],examples:[{args:{nodeId:"nd_btn",name:"onClick",event:{mode:"code",code:'alert("hi")'}},description:"Update onClick handler"}],returns:"{ id: String, name: String }",handler:async t=>{let r=e("state"),{updateEvent:n}=await Promise.resolve().then(()=>(Lu(),cg)),{normalizeEventName:o}=await Promise.resolve().then(()=>(ff(),pf)),s=r.ref(["nodes"]),{nodeId:a,name:c,event:l}=t,u=o(c),d=l?.name!==void 0?{...l,name:o(l.name)}:{...l,name:u};return n(s,a,u,d),{id:a,name:u}}},removeEvent:{description:"Remove an event handler by name",schema:[{nodeId:"String",name:"String"}],examples:[{args:{nodeId:"nd_btn",name:"onClick"},description:"Remove onClick handler"}],returns:"{ id: String, name: String }",handler:async t=>{let r=e("state"),{removeEvent:n}=await Promise.resolve().then(()=>(ug(),$E)),{normalizeEventName:o}=await Promise.resolve().then(()=>(ff(),pf)),s=r.ref(["nodes"]),{nodeId:a,name:c}=t,l=o(c);return n(s,a,l),{id:a,name:l}}},updateRoute:{description:"Set the route path on a frame node for multi-page navigation",schema:[{nodeId:"String",route:"Any"}],examples:[{args:{nodeId:"nd_frame",route:"/about"},description:"Set route path"},{args:{nodeId:"nd_frame",route:{path:"/users/:id"}},description:"Set route with params"}],returns:"{ id: String, route: Object }",handler:async t=>{let r=e("state"),{updateRoute:n}=await Promise.resolve().then(()=>(iy(),XN)),o=r.ref(["nodes"]),{nodeId:s,route:a}=t,c=typeof a=="string"?{path:a}:a;return n(o,s,c),{id:s,route:c}}},setHomePage:{description:"Mark a frame as the home page (root route)",schema:[{nodeId:"String",isHomePage:"Any"}],examples:[{args:{nodeId:"nd_frame",isHomePage:!0},description:"Set as home page"}],returns:"{ id: String, isHomePage: Any }",handler:async t=>{let r=e("state"),{setHomePage:n}=await Promise.resolve().then(()=>(py(),n1)),o=r.ref(["nodes"]),{nodeId:s,isHomePage:a}=t;return n(o,s,a),{id:s,isHomePage:a}}},setDestination:{description:"Set a navigation destination on a link or button node",schema:[{nodeId:"String",destination:"Any"}],examples:[{args:{nodeId:"nd_link",destination:"/about"},description:"Navigate to /about on click"}],returns:"{ id: String, destination: Object }",handler:async t=>{let r=e("state"),{setDestination:n}=await Promise.resolve().then(()=>(Sg(),WE)),o=r.ref(["nodes"]),{nodeId:s,destination:a}=t,c=typeof a=="string"?{path:a}:a;return n(o,s,c),{id:s,destination:c}}},clearDestination:{description:"Remove the navigation destination from a node",schema:[{nodeId:"String"}],examples:[{args:{nodeId:"nd_link"},description:"Clear navigation destination"}],returns:"{ id: String }",handler:async t=>{let r=e("state"),{clearDestination:n}=await Promise.resolve().then(()=>($g(),KE)),o=r.ref(["nodes"]),{nodeId:s}=t;return n(o,s),{id:s}}},setRepeat:{description:'Repeat a node for each item in a data binding (loop). binding is a dot-path on ctx (e.g. "$store.todo.items").',schema:[{nodeId:"String",binding:"String",as:"String?",index:"String?",key:"Any?",keyOn:"Any?"}],examples:[{args:{nodeId:"nd_card",binding:"$store.todo.items",as:"$item"},description:"Repeat card for each item in the todo store"}],returns:"{ id: String, binding: String }",handler:async t=>{let r=e("state"),{setRepeat:n}=await Promise.resolve().then(()=>(rd(),FN)),o=r.ref(["nodes"]),{nodeId:s,binding:a,as:c,index:l,key:u,keyOn:d}=t,p=a.split(".");return n(o,s,{descriptor:{mode:"binding",binding:p},as:c,index:l,key:u,keyOn:d}),{id:s,binding:a}}},clearRepeat:{description:"Remove repeat binding from a node",schema:[{nodeId:"String"}],examples:[{args:{nodeId:"nd_card"},description:"Stop repeating"}],returns:"{ id: String }",handler:async t=>{let r=e("state"),{clearRepeat:n}=await Promise.resolve().then(()=>(nd(),HN)),o=r.ref(["nodes"]),{nodeId:s}=t;return n(o,s),{id:s}}},setRender:{description:'Conditionally show/hide a node based on an expression. Pass an expression that uses ctx (e.g. "ctx.$store.user.isAdmin"); it is wrapped as a computed function automatically. Stores are at ctx.$store.<name>; loop vars at ctx.$item / ctx.$index.',schema:[{nodeId:"String",value:"String"}],examples:[{args:{nodeId:"nd_admin",value:"ctx.$store.user.isAdmin"},description:"Show only for admins"}],returns:"{ id: String, value: String }",handler:async t=>{let r=e("state"),{setRender:n}=await Promise.resolve().then(()=>(ty(),jN)),o=r.ref(["nodes"]),{nodeId:s,value:a}=t,c=`function (ctx) {
202
+ }`},description:"Prevent default on form submit"}],returns:"{ id: String, name: String }",handler:async t=>{let r=e("state"),{addEvent:n}=await Promise.resolve().then(()=>(ux(),uT)),{updateEvent:o}=await Promise.resolve().then(()=>(Sp(),px)),{normalizeEventName:s}=await Promise.resolve().then(()=>(hh(),mh)),a=r.ref(["nodes"]),{nodeId:c,name:l,binding:u,code:d,mode:p}=t,m=s(l);if((a.get([c,"events"])??[]).find(_=>_.name===m)||n(a,c,m),u!==void 0){let _=(a.get([c,"events"])??[]).find(x=>x.name===m)??{name:m};o(a,c,m,{..._,mode:"binding",binding:u.split("."),code:null})}else if(d!==void 0){let _=(a.get([c,"events"])??[]).find(x=>x.name===m)??{name:m};o(a,c,m,{..._,mode:p??"code",code:d,binding:null})}return{id:c,name:m}}},updateEvent:{description:"Update an existing event handler by name",schema:[{nodeId:"String",name:"String",event:"Object"}],examples:[{args:{nodeId:"nd_btn",name:"onClick",event:{mode:"code",code:'alert("hi")'}},description:"Update onClick handler"}],returns:"{ id: String, name: String }",handler:async t=>{let r=e("state"),{updateEvent:n}=await Promise.resolve().then(()=>(Sp(),px)),{normalizeEventName:o}=await Promise.resolve().then(()=>(hh(),mh)),s=r.ref(["nodes"]),{nodeId:a,name:c,event:l}=t,u=o(c),d=l?.name!==void 0?{...l,name:o(l.name)}:{...l,name:u};return n(s,a,u,d),{id:a,name:u}}},removeEvent:{description:"Remove an event handler by name",schema:[{nodeId:"String",name:"String"}],examples:[{args:{nodeId:"nd_btn",name:"onClick"},description:"Remove onClick handler"}],returns:"{ id: String, name: String }",handler:async t=>{let r=e("state"),{removeEvent:n}=await Promise.resolve().then(()=>(mx(),dT)),{normalizeEventName:o}=await Promise.resolve().then(()=>(hh(),mh)),s=r.ref(["nodes"]),{nodeId:a,name:c}=t,l=o(c);return n(s,a,l),{id:a,name:l}}},updateRoute:{description:"Set the route path on a frame node for multi-page navigation",schema:[{nodeId:"String",route:"Any"}],examples:[{args:{nodeId:"nd_frame",route:"/about"},description:"Set route path"},{args:{nodeId:"nd_frame",route:{path:"/users/:id"}},description:"Set route with params"}],returns:"{ id: String, route: Object }",handler:async t=>{let r=e("state"),{updateRoute:n}=await Promise.resolve().then(()=>(o_(),jz)),o=r.ref(["nodes"]),{nodeId:s,route:a}=t,c=typeof a=="string"?{path:a}:a;return n(o,s,c),{id:s,route:c}}},setHomePage:{description:"Mark a frame as the home page (root route)",schema:[{nodeId:"String",isHomePage:"Any"}],examples:[{args:{nodeId:"nd_frame",isHomePage:!0},description:"Set as home page"}],returns:"{ id: String, isHomePage: Any }",handler:async t=>{let r=e("state"),{setHomePage:n}=await Promise.resolve().then(()=>(u_(),Fz)),o=r.ref(["nodes"]),{nodeId:s,isHomePage:a}=t;return n(o,s,a),{id:s,isHomePage:a}}},setDestination:{description:"Set a navigation destination on a link or button node",schema:[{nodeId:"String",destination:"Any"}],examples:[{args:{nodeId:"nd_link",destination:"/about"},description:"Navigate to /about on click"}],returns:"{ id: String, destination: Object }",handler:async t=>{let r=e("state"),{setDestination:n}=await Promise.resolve().then(()=>(Sx(),PT)),o=r.ref(["nodes"]),{nodeId:s,destination:a}=t,c=typeof a=="string"?{path:a}:a;return n(o,s,c),{id:s,destination:c}}},clearDestination:{description:"Remove the navigation destination from a node",schema:[{nodeId:"String"}],examples:[{args:{nodeId:"nd_link"},description:"Clear navigation destination"}],returns:"{ id: String }",handler:async t=>{let r=e("state"),{clearDestination:n}=await Promise.resolve().then(()=>($x(),OT)),o=r.ref(["nodes"]),{nodeId:s}=t;return n(o,s),{id:s}}},setRepeat:{description:'Repeat a node for each item in a data binding (loop). binding is a dot-path on ctx (e.g. "$store.todo.items").',schema:[{nodeId:"String",binding:"String",as:"String?",index:"String?",key:"Any?",keyOn:"Any?"}],examples:[{args:{nodeId:"nd_card",binding:"$store.todo.items",as:"$item"},description:"Repeat card for each item in the todo store"}],returns:"{ id: String, binding: String }",handler:async t=>{let r=e("state"),{setRepeat:n}=await Promise.resolve().then(()=>(Ap(),$z)),o=r.ref(["nodes"]),{nodeId:s,binding:a,as:c,index:l,key:u,keyOn:d}=t,p=a.split(".");return n(o,s,{descriptor:{mode:"binding",binding:p},as:c,index:l,key:u,keyOn:d}),{id:s,binding:a}}},clearRepeat:{description:"Remove repeat binding from a node",schema:[{nodeId:"String"}],examples:[{args:{nodeId:"nd_card"},description:"Stop repeating"}],returns:"{ id: String }",handler:async t=>{let r=e("state"),{clearRepeat:n}=await Promise.resolve().then(()=>(Rp(),Tz)),o=r.ref(["nodes"]),{nodeId:s}=t;return n(o,s),{id:s}}},setRender:{description:'Conditionally show/hide a node based on an expression. Pass an expression that uses ctx (e.g. "ctx.$store.user.isAdmin"); it is wrapped as a computed function automatically. Stores are at ctx.$store.<name>; loop vars at ctx.$item / ctx.$index.',schema:[{nodeId:"String",value:"String"}],examples:[{args:{nodeId:"nd_admin",value:"ctx.$store.user.isAdmin"},description:"Show only for admins"}],returns:"{ id: String, value: String }",handler:async t=>{let r=e("state"),{setRender:n}=await Promise.resolve().then(()=>(Qx(),vz)),o=r.ref(["nodes"]),{nodeId:s,value:a}=t,c=`function (ctx) {
159
203
  return ${a}
160
- }`;return n(o,s,{mode:"computed",computed:c}),{id:s,value:a}}},clearRender:{description:"Remove conditional rendering from a node (always show)",schema:[{nodeId:"String"}],examples:[{args:{nodeId:"nd_admin"},description:"Always render"}],returns:"{ id: String }",handler:async t=>{let r=e("state"),{clearRender:n}=await Promise.resolve().then(()=>(ny(),ZN)),o=r.ref(["nodes"]),{nodeId:s}=t;return n(o,s),{id:s}}},addState:{description:'Register a custom state class on a node (e.g. "is-active"). Style it with updateStyle breakpoint "&.is-active".',schema:[{nodeId:"String",stateName:"String"}],examples:[{args:{nodeId:"nd_tab",stateName:"is-active"},description:"Add active state"}],returns:"{ id: String, stateName: String }",handler:async t=>{let r=e("state"),{addState:n}=await Promise.resolve().then(()=>(Ah(),A$)),o=r.ref(["nodes"]),{nodeId:s,stateName:a}=t;return n(o,s,a),{id:s,stateName:a}}},updateState:{description:"Set the expression that controls when a state is active",schema:[{nodeId:"String",stateName:"String",expression:"String"}],examples:[{args:{nodeId:"nd_tab",stateName:"is-active",expression:'$router.currentRoute?.path === "/"'},description:"Activate on home route"}],returns:"{ id: String, stateName: String }",handler:async t=>{let r=e("state"),{updateState:n}=await Promise.resolve().then(()=>(Dh(),j$)),o=r.ref(["nodes"]),{nodeId:s,stateName:a,expression:c}=t;return n(o,s,a,{name:a,mode:"computed",computed:c??null}),{id:s,stateName:a}}},removeState:{description:"Remove a custom state from a node",schema:[{nodeId:"String",stateName:"String"}],examples:[{args:{nodeId:"nd_tab",stateName:"is-active"},description:"Remove active state"}],returns:"{ id: String, stateName: String }",handler:async t=>{let r=e("state"),{removeState:n}=await Promise.resolve().then(()=>(Zh(),D$)),o=r.ref(["nodes"]),{nodeId:s,stateName:a}=t;return n(o,s,a),{id:s,stateName:a}}},updateBounds:{description:"Update the position and size of a node",schema:[{nodeId:"String",bounds:"Object"}],examples:[{args:{nodeId:"nd_frame",bounds:{x:500,y:0,width:375,height:667}},description:"Position a frame"}],returns:"{ id: String, bounds: Object }",handler:async t=>{let r=e("state"),{updateBounds:n}=await Promise.resolve().then(()=>(Oa(),Nh)),o=r.ref(["nodes"]),{nodeId:s,bounds:a}=t;return n(o,s,a),{id:s,bounds:a}}},setHtmlId:{description:"Set the HTML id attribute on a node",schema:[{nodeId:"String",id:"String"}],examples:[{args:{nodeId:"nd_section",id:"hero-section"},description:"Set HTML id for anchor links"}],returns:"{ id: String, htmlId: String }",handler:async t=>{let r=e("state"),{setHtmlId:n}=await Promise.resolve().then(()=>(yy(),D1)),o=r.ref(["nodes"]),{nodeId:s,id:a}=t;return n(o,s,a),{id:s,htmlId:a}}},addAttribute:{description:"Add a custom HTML attribute to a node",schema:[{nodeId:"String",name:"String",value:"Any?",mode:"String?"}],examples:[{args:{nodeId:"nd_img",name:"src",value:"/hero.png"},description:"Set image source"},{args:{nodeId:"nd_img",name:"alt",value:"Hero image"},description:"Set alt text"}],returns:"{ id: String, name: String }",handler:async t=>{let r=e("state"),{addAttribute:n}=await Promise.resolve().then(()=>(mg(),TE)),o=r.ref(["nodes"]),{nodeId:s,name:a,value:c,mode:l}=t;return n(o,s,{name:a,value:c,mode:l}),{id:s,name:a}}},updateAttribute:{description:'Update or upsert an attribute by name. For two-way input binding use name "model", mode "binding", and binding "$store.path". model XOR value/checked \u2014 setting model clears value and checked; setting value or checked clears model.',schema:[{nodeId:"String",name:"String",mode:"String?",value:"Any?",binding:"Any?",computed:"String?",code:"String?"}],examples:[{args:{nodeId:"nd_img",name:"src",value:"/new-hero.png"},description:"Change image source"},{args:{nodeId:"nd_email",name:"model",mode:"binding",binding:"$store.form.email"},description:"Two-way bind input to store"}],returns:"{ id: String, name: String }",handler:async t=>{let r=e("state"),{updateAttribute:n}=await Promise.resolve().then(()=>(gg(),zE)),o=r.ref(["nodes"]),{nodeId:s,...a}=t;return typeof a.binding=="string"&&(a.binding=a.binding.split(".")),a.name==="model"&&a.mode==null&&(a.mode="binding"),n(o,s,a.name,a),{id:s,name:a.name}}},removeAttribute:{description:"Remove an attribute by name",schema:[{nodeId:"String",name:"String"}],examples:[{args:{nodeId:"nd_img",name:"src"},description:"Remove src attribute"}],returns:"{ id: String, name: String }",handler:async t=>{let r=e("state"),{removeAttribute:n}=await Promise.resolve().then(()=>(Uu(),NE)),o=r.ref(["nodes"]),{nodeId:s,name:a}=t;return n(o,s,a),{id:s,name:a}}},addLifecycleHook:{description:'Add a lifecycle hook to a node (mount, unmount, update). mode is "code" with a code string, or "binding" with a store action binding.',schema:[{nodeId:"String",key:"String",code:"String?",binding:"String?"}],examples:[{args:{nodeId:"nd_page",key:"mount",code:'console.log("mounted")'},description:"Run code on mount"},{args:{nodeId:"nd_page",key:"mount",binding:"cart.load"},description:"Call a store action on mount"}],returns:"{ id: String, key: String }",handler:async t=>{let r=e("state"),{addLifecycleHook:n}=await Promise.resolve().then(()=>(Tg(),eN)),{updateLifecycleHook:o}=await Promise.resolve().then(()=>(Gu(),Cg)),s=r.ref(["nodes"]),{nodeId:a,key:c,code:l,binding:u}=t;return n(s,a,c),(l!==void 0||u!==void 0)&&o(s,a,c,{key:c,mode:l!==void 0?"code":"binding",code:l??"",binding:u??null}),{id:a,key:c}}},updateLifecycleHook:{description:"Update a lifecycle hook by key. hook may include key, mode, code, binding.",schema:[{nodeId:"String",key:"String",hook:"Object"}],returns:"{ id: String, key: String }",handler:async t=>{let r=e("state"),{updateLifecycleHook:n}=await Promise.resolve().then(()=>(Gu(),Cg)),o=r.ref(["nodes"]),{nodeId:s,key:a,hook:c}=t,l=(o.get([s,"lifecycle"])??[]).find(u=>u.key===a)??{key:a};return n(o,s,a,{...l,...c}),{id:s,key:a}}},removeLifecycleHook:{description:"Remove a lifecycle hook by key.",schema:[{nodeId:"String",key:"String"}],returns:"{ id: String, key: String }",handler:async t=>{let r=e("state"),{removeLifecycleHook:n}=await Promise.resolve().then(()=>(Pg(),tN));return n(r.ref(["nodes"]),t.nodeId,t.key),{id:t.nodeId,key:t.key}}},addOption:{description:"Add a static option to a select node.",schema:[{nodeId:"String",value:"String",label:"String?"}],examples:[{args:{nodeId:"nd_select",value:"us",label:"United States"},description:"Add a select option"}],returns:"{ id: String, value: String }",handler:async t=>{let r=e("state"),{addOption:n}=await Promise.resolve().then(()=>(Ug(),NN)),o=r.ref(["nodes"]),{nodeId:s,value:a,label:c}=t;return n(o,s,{value:a,label:c??a}),{id:s,value:a}}},updateOption:{description:"Update a select option by its current value. Pass the old value to look up, and optionally a new value/label.",schema:[{nodeId:"String",value:"String",newValue:"String?",label:"String?"}],returns:"{ id: String, value: String }",handler:async t=>{let r=e("state"),{updateOption:n}=await Promise.resolve().then(()=>(Hg(),TN)),o=r.ref(["nodes"]),{nodeId:s,value:a,newValue:c,label:l}=t,u=c??a;return n(o,s,a,{value:u,label:l??u}),{id:s,value:u}}},removeOption:{description:"Remove a select option by value.",schema:[{nodeId:"String",value:"String"}],returns:"{ id: String, value: String }",handler:async t=>{let r=e("state"),{removeOption:n}=await Promise.resolve().then(()=>(Vg(),zN));return n(r.ref(["nodes"]),t.nodeId,t.value),{id:t.nodeId,value:t.value}}},setOptionsExpression:{description:"Bind a select node's options to a data expression instead of a static list. binding is a {{expression}} returning an array; valueKey/labelKey pick fields from each item.",schema:[{nodeId:"String",binding:"String",valueKey:"String?",labelKey:"String?"}],examples:[{args:{nodeId:"nd_select",binding:"{{countries}}",valueKey:"code",labelKey:"name"},description:"Populate options from a store"}],returns:"{ id: String }",handler:async t=>{let r=e("state"),{setOptionsExpression:n}=await Promise.resolve().then(()=>(Wg(),CN)),o=r.ref(["nodes"]),{nodeId:s,binding:a,valueKey:c,labelKey:l}=t;return n(o,s,{binding:a,valueKey:c,labelKey:l}),{id:s}}},clearOptionsExpression:{description:"Switch a select node back to its static options list.",schema:[{nodeId:"String"}],returns:"{ id: String }",handler:async t=>{let r=e("state"),{clearOptionsExpression:n}=await Promise.resolve().then(()=>(Jg(),IN));return n(r.ref(["nodes"]),t.nodeId),{id:t.nodeId}}},setTagName:{description:"Change the HTML tag of an element node (e.g. div to section).",mcpName:"set_tag_name",schema:[{nodeId:"String",tagName:"String"}],examples:[{args:{nodeId:"nd_box",tagName:"section"},description:"Make a div semantic"}],returns:"{ id: String, tagName: String }",handler:async t=>{let r=e("state"),{setTagName:n}=await Promise.resolve().then(()=>(my(),l1)),o=r.ref(["nodes"]),{nodeId:s,tagName:a}=t;return n(o,s,a),{id:s,tagName:a}}},updateHtml:{description:"Set the inner HTML of a template node (raw HTML embed).",schema:[{nodeId:"String",html:"String"}],returns:"{ id: String }",handler:async t=>{let r=e("state"),{updateHtml:n}=await Promise.resolve().then(()=>(vg(),HE));return n(r.ref(["nodes"]),t.nodeId,t.html),{id:t.nodeId}}},addRouteParam:{description:"Add a route parameter to a frame route (e.g. an :id segment). Set key to name it; optional marks it optional.",schema:[{nodeId:"String",key:"String?",optional:"Boolean?"}],examples:[{args:{nodeId:"nd_frame",key:"id"},description:"Add an :id param to the route"}],returns:"{ id: String, index: Number }",handler:async t=>{let r=e("state"),{addParamToRoute:n}=await Promise.resolve().then(()=>(cy(),t1)),o=r.ref(["nodes"]),{nodeId:s,key:a,optional:c}=t;n(o,s);let u=(o.get([s,"route","params"])??[]).length-1;return(a!==void 0||c!==void 0)&&o.set([s,"route","params",u],{key:a??null,optional:c??!1}),{id:s,index:u}}},removeRouteParam:{description:"Remove a route parameter from a frame route by index.",schema:[{nodeId:"String",index:"Number"}],returns:"{ id: String, index: Number }",handler:async t=>{let r=e("state"),{removeParamFromRoute:n}=await Promise.resolve().then(()=>(uy(),r1));return n(r.ref(["nodes"]),t.nodeId,t.index),{id:t.nodeId,index:t.index}}}}))});var $O,EO=f(()=>{$O=i(()=>({$value:null,$type:"color",$path:null}),"tokenDefaults")});var NO={};R(NO,{addToken:()=>x5});function x5(e,t={}){let r=vh();return e.set([r],{...$O(),...t}),r}var TO=f(()=>{Ca();EO();i(x5,"addToken")});var zO={};R(zO,{updateToken:()=>_5});function _5(e,t,r){if(e.get([t]))for(let[o,s]of Object.entries(r))e.set([t,o],s)}var CO=f(()=>{i(_5,"updateToken")});var IO={};R(IO,{removeToken:()=>v5});function v5(e,t){let r=e.get([t]);return e.remove([t]),r}var PO=f(()=>{i(v5,"removeToken")});var P_,RO=f(()=>{vn();P_=bt("token",e=>({create:{description:'Create a design token. path is the token name (e.g. "color/primary"), type is the token kind (color, dimension, fontFamily, etc.), value is the CSS value. Reference tokens in styles via the slugged path (slashes/dots become dashes): path "color/primary" \u2192 var(--color-primary).',mcpName:"create_token",schema:[{path:"String",value:"String",type:"String?"}],examples:[{args:{path:"color/primary",value:"#3B82F6",type:"color"},description:"Create a primary color token"},{args:{path:"spacing/lg",value:"24px",type:"dimension"},description:"Create a spacing token"}],returns:"{ id: String, path: String }",handler:async t=>{let r=e("state"),{addToken:n}=await Promise.resolve().then(()=>(TO(),NO)),o=r.ref(["tokens"]),{path:s,value:a,type:c}=t;return{id:n(o,{$path:s,$value:a,...c!==void 0?{$type:c}:{}}),path:s}}},update:{description:"Update a design token. changes may include path, value, or type.",mcpName:"update_token",schema:[{tokenId:"String",changes:"Object"}],examples:[{args:{tokenId:"tk_abc",changes:{value:"#EF4444"}},description:"Change a token value"}],returns:"{ id: String }",handler:async t=>{let r=e("state"),{updateToken:n}=await Promise.resolve().then(()=>(CO(),zO)),o=r.ref(["tokens"]),{tokenId:s,changes:a={}}=t,c={};return a.path!==void 0&&(c.$path=a.path),a.value!==void 0&&(c.$value=a.value),a.type!==void 0&&(c.$type=a.type),n(o,s,c),{id:s}}},delete:{description:"Delete a design token by id.",mcpName:"delete_token",schema:[{tokenId:"String"}],examples:[{args:{tokenId:"tk_abc"},description:"Delete a token"}],returns:"{ id: String }",handler:async t=>{let r=e("state"),{removeToken:n}=await Promise.resolve().then(()=>(PO(),IO)),o=r.ref(["tokens"]);return n(o,t.tokenId),{id:t.tokenId}}}}))});var AO={};R(AO,{validateStorePayload:()=>b5});function w5(e){return typeof e=="string"&&/^\s*function\b/.test(e)}function b5(e){let t=[];if(!e||typeof e!="object"||Array.isArray(e))throw new Error("store payload must be an object");(typeof e.name!="string"||!e.name.trim())&&t.push("name must be a non-empty string"),e.state!==void 0&&(Array.isArray(e.state)?e.state.forEach((r,n)=>{if(!r||typeof r!="object"||Array.isArray(r)){t.push(`state[${n}] must be an object`);return}(typeof r.key!="string"||!r.key.trim())&&t.push(`state[${n}].key must be a non-empty string`),(typeof r.type!="string"||!OO.has(r.type))&&t.push(`state[${n}].type must be one of ${[...OO].join("|")}`)}):t.push("state must be an array"));for(let r of["computed","actions"])if(e[r]!==void 0){if(!Array.isArray(e[r])){t.push(`${r} must be an array`);continue}e[r].forEach((n,o)=>{if(!n||typeof n!="object"||Array.isArray(n)){t.push(`${r}[${o}] must be an object`);return}(typeof n.name!="string"||!n.name.trim())&&t.push(`${r}[${o}].name must be a non-empty string`),w5(n.code)||t.push(`${r}[${o}].code must be a function expression string (e.g. function () { ... })`)})}if(t.length)throw new Error(`Invalid store payload:
204
+ }`;return n(o,s,{mode:"computed",computed:c}),{id:s,value:a}}},clearRender:{description:"Remove conditional rendering from a node (always show)",schema:[{nodeId:"String"}],examples:[{args:{nodeId:"nd_admin"},description:"Always render"}],returns:"{ id: String }",handler:async t=>{let r=e("state"),{clearRender:n}=await Promise.resolve().then(()=>(t_(),Sz)),o=r.ref(["nodes"]),{nodeId:s}=t;return n(o,s),{id:s}}},addState:{description:'Register a custom state class on a node (e.g. "is-active"). Style it with updateStyle breakpoint "&.is-active".',schema:[{nodeId:"String",stateName:"String"}],examples:[{args:{nodeId:"nd_tab",stateName:"is-active"},description:"Add active state"}],returns:"{ id: String, stateName: String }",handler:async t=>{let r=e("state"),{addState:n}=await Promise.resolve().then(()=>(jy(),l1)),o=r.ref(["nodes"]),{nodeId:s,stateName:a}=t;return n(o,s,a),{id:s,stateName:a}}},updateState:{description:"Set the expression that controls when a state is active",schema:[{nodeId:"String",stateName:"String",expression:"String"}],examples:[{args:{nodeId:"nd_tab",stateName:"is-active",expression:'$router.currentRoute?.path === "/"'},description:"Activate on home route"}],returns:"{ id: String, stateName: String }",handler:async t=>{let r=e("state"),{updateState:n}=await Promise.resolve().then(()=>(My(),u1)),o=r.ref(["nodes"]),{nodeId:s,stateName:a,expression:c}=t;return n(o,s,a,{name:a,mode:"computed",computed:c??null}),{id:s,stateName:a}}},removeState:{description:"Remove a custom state from a node",schema:[{nodeId:"String",stateName:"String"}],examples:[{args:{nodeId:"nd_tab",stateName:"is-active"},description:"Remove active state"}],returns:"{ id: String, stateName: String }",handler:async t=>{let r=e("state"),{removeState:n}=await Promise.resolve().then(()=>(Ly(),d1)),o=r.ref(["nodes"]),{nodeId:s,stateName:a}=t;return n(o,s,a),{id:s,stateName:a}}},updateBounds:{description:"Update the position and size of a node",schema:[{nodeId:"String",bounds:"Object"}],examples:[{args:{nodeId:"nd_frame",bounds:{x:500,y:0,width:375,height:667}},description:"Position a frame"}],returns:"{ id: String, bounds: Object }",handler:async t=>{let r=e("state"),{updateBounds:n}=await Promise.resolve().then(()=>(Nc(),Cy)),o=r.ref(["nodes"]),{nodeId:s,bounds:a}=t;return n(o,s,a),{id:s,bounds:a}}},setHtmlId:{description:"Set the HTML id attribute on a node",schema:[{nodeId:"String",id:"String"}],examples:[{args:{nodeId:"nd_section",id:"hero-section"},description:"Set HTML id for anchor links"}],returns:"{ id: String, htmlId: String }",handler:async t=>{let r=e("state"),{setHtmlId:n}=await Promise.resolve().then(()=>(h_(),TC)),o=r.ref(["nodes"]),{nodeId:s,id:a}=t;return n(o,s,a),{id:s,htmlId:a}}},addAttribute:{description:"Add a custom HTML attribute to a node",schema:[{nodeId:"String",name:"String",value:"Any?",mode:"String?"}],examples:[{args:{nodeId:"nd_img",name:"src",value:"/hero.png"},description:"Set image source"},{args:{nodeId:"nd_img",name:"alt",value:"Hero image"},description:"Set alt text"}],returns:"{ id: String, name: String }",handler:async t=>{let r=e("state"),{addAttribute:n}=await Promise.resolve().then(()=>(gx(),fT)),o=r.ref(["nodes"]),{nodeId:s,name:a,value:c,mode:l}=t;return n(o,s,{name:a,value:c,mode:l}),{id:s,name:a}}},updateAttribute:{description:'Update or upsert an attribute by name. For two-way input binding use name "model", mode "binding", and binding "$store.path". model XOR value/checked \u2014 setting model clears value and checked; setting value or checked clears model.',schema:[{nodeId:"String",name:"String",mode:"String?",value:"Any?",binding:"Any?",computed:"String?",code:"String?"}],examples:[{args:{nodeId:"nd_img",name:"src",value:"/new-hero.png"},description:"Change image source"},{args:{nodeId:"nd_email",name:"model",mode:"binding",binding:"$store.form.email"},description:"Two-way bind input to store"}],returns:"{ id: String, name: String }",handler:async t=>{let r=e("state"),{updateAttribute:n}=await Promise.resolve().then(()=>(wp(),aT)),o=r.ref(["nodes"]),{nodeId:s,...a}=t;return typeof a.binding=="string"&&(a.binding=a.binding.split(".")),a.name==="model"&&a.mode==null&&(a.mode="binding"),n(o,s,a.name,a),{id:s,name:a.name}}},removeAttribute:{description:"Remove an attribute by name",schema:[{nodeId:"String",name:"String"}],examples:[{args:{nodeId:"nd_img",name:"src"},description:"Remove src attribute"}],returns:"{ id: String, name: String }",handler:async t=>{let r=e("state"),{removeAttribute:n}=await Promise.resolve().then(()=>(_p(),iT)),o=r.ref(["nodes"]),{nodeId:s,name:a}=t;return n(o,s,a),{id:s,name:a}}},addLifecycleHook:{description:'Add a lifecycle hook to a node (mount, unmount, update). mode is "code" with a code string, or "binding" with a store action binding.',schema:[{nodeId:"String",key:"String",code:"String?",binding:"String?"}],examples:[{args:{nodeId:"nd_page",key:"mount",code:'console.log("mounted")'},description:"Run code on mount"},{args:{nodeId:"nd_page",key:"mount",binding:"cart.load"},description:"Call a store action on mount"}],returns:"{ id: String, key: String }",handler:async t=>{let r=e("state"),{addLifecycleHook:n}=await Promise.resolve().then(()=>(Tx(),MT)),{updateLifecycleHook:o}=await Promise.resolve().then(()=>(Np(),Cx)),s=r.ref(["nodes"]),{nodeId:a,key:c,code:l,binding:u}=t;return n(s,a,c),(l!==void 0||u!==void 0)&&o(s,a,c,{key:c,mode:l!==void 0?"code":"binding",code:l??"",binding:u??null}),{id:a,key:c}}},updateLifecycleHook:{description:"Update a lifecycle hook by key. hook may include key, mode, code, binding.",schema:[{nodeId:"String",key:"String",hook:"Object"}],returns:"{ id: String, key: String }",handler:async t=>{let r=e("state"),{updateLifecycleHook:n}=await Promise.resolve().then(()=>(Np(),Cx)),o=r.ref(["nodes"]),{nodeId:s,key:a,hook:c}=t,l=(o.get([s,"lifecycle"])??[]).find(u=>u.key===a)??{key:a};return n(o,s,a,{...l,...c}),{id:s,key:a}}},removeLifecycleHook:{description:"Remove a lifecycle hook by key.",schema:[{nodeId:"String",key:"String"}],returns:"{ id: String, key: String }",handler:async t=>{let r=e("state"),{removeLifecycleHook:n}=await Promise.resolve().then(()=>(Px(),ZT));return n(r.ref(["nodes"]),t.nodeId,t.key),{id:t.nodeId,key:t.key}}},addOption:{description:"Add a static option to a select node.",schema:[{nodeId:"String",value:"String",label:"String?"}],examples:[{args:{nodeId:"nd_select",value:"us",label:"United States"},description:"Add a select option"}],returns:"{ id: String, value: String }",handler:async t=>{let r=e("state"),{addOption:n}=await Promise.resolve().then(()=>(Zx(),cz)),o=r.ref(["nodes"]),{nodeId:s,value:a,label:c}=t;return n(o,s,{value:a,label:c??a}),{id:s,value:a}}},updateOption:{description:"Update a select option by its current value. Pass the old value to look up, and optionally a new value/label.",schema:[{nodeId:"String",value:"String",newValue:"String?",label:"String?"}],returns:"{ id: String, value: String }",handler:async t=>{let r=e("state"),{updateOption:n}=await Promise.resolve().then(()=>(Fx(),lz)),o=r.ref(["nodes"]),{nodeId:s,value:a,newValue:c,label:l}=t,u=c??a;return n(o,s,a,{value:u,label:l??u}),{id:s,value:u}}},removeOption:{description:"Remove a select option by value.",schema:[{nodeId:"String",value:"String"}],returns:"{ id: String, value: String }",handler:async t=>{let r=e("state"),{removeOption:n}=await Promise.resolve().then(()=>(qx(),uz));return n(r.ref(["nodes"]),t.nodeId,t.value),{id:t.nodeId,value:t.value}}},setOptionsExpression:{description:"Bind a select node's options to a data expression instead of a static list. binding is a {{expression}} returning an array; valueKey/labelKey pick fields from each item.",schema:[{nodeId:"String",binding:"String",valueKey:"String?",labelKey:"String?"}],examples:[{args:{nodeId:"nd_select",binding:"{{countries}}",valueKey:"code",labelKey:"name"},description:"Populate options from a store"}],returns:"{ id: String }",handler:async t=>{let r=e("state"),{setOptionsExpression:n}=await Promise.resolve().then(()=>(Hx(),dz)),o=r.ref(["nodes"]),{nodeId:s,binding:a,valueKey:c,labelKey:l}=t;return n(o,s,{binding:a,valueKey:c,labelKey:l}),{id:s}}},clearOptionsExpression:{description:"Switch a select node back to its static options list.",schema:[{nodeId:"String"}],returns:"{ id: String }",handler:async t=>{let r=e("state"),{clearOptionsExpression:n}=await Promise.resolve().then(()=>(Gx(),pz));return n(r.ref(["nodes"]),t.nodeId),{id:t.nodeId}}},setTagName:{description:"Change the HTML tag of an element node (e.g. div to section).",mcpName:"set_tag_name",schema:[{nodeId:"String",tagName:"String"}],examples:[{args:{nodeId:"nd_box",tagName:"section"},description:"Make a div semantic"}],returns:"{ id: String, tagName: String }",handler:async t=>{let r=e("state"),{setTagName:n}=await Promise.resolve().then(()=>(p_(),Gz)),o=r.ref(["nodes"]),{nodeId:s,tagName:a}=t;return n(o,s,a),{id:s,tagName:a}}},updateHtml:{description:"Set the inner HTML of a template node (raw HTML embed).",schema:[{nodeId:"String",html:"String"}],returns:"{ id: String }",handler:async t=>{let r=e("state"),{updateHtml:n}=await Promise.resolve().then(()=>(vx(),TT));return n(r.ref(["nodes"]),t.nodeId,t.html),{id:t.nodeId}}},addRouteParam:{description:"Add a route parameter to a frame route (e.g. an :id segment). Set key to name it; optional marks it optional.",schema:[{nodeId:"String",key:"String?",optional:"Boolean?"}],examples:[{args:{nodeId:"nd_frame",key:"id"},description:"Add an :id param to the route"}],returns:"{ id: String, index: Number }",handler:async t=>{let r=e("state"),{addParamToRoute:n}=await Promise.resolve().then(()=>(i_(),Zz)),o=r.ref(["nodes"]),{nodeId:s,key:a,optional:c}=t;n(o,s);let u=(o.get([s,"route","params"])??[]).length-1;return(a!==void 0||c!==void 0)&&o.set([s,"route","params",u],{key:a??null,optional:c??!1}),{id:s,index:u}}},removeRouteParam:{description:"Remove a route parameter from a frame route by index.",schema:[{nodeId:"String",index:"Number"}],returns:"{ id: String, index: Number }",handler:async t=>{let r=e("state"),{removeParamFromRoute:n}=await Promise.resolve().then(()=>(c_(),Lz));return n(r.ref(["nodes"]),t.nodeId,t.index),{id:t.nodeId,index:t.index}}}}))});var IM,PM=f(()=>{IM=i(()=>({$value:null,$type:"color",$path:null}),"tokenDefaults")});var OM={};C(OM,{addToken:()=>rK});function rK(e,t={}){let r=by();return e.set([r],{...IM(),...t}),r}var AM=f(()=>{$c();PM();i(rK,"addToken")});var RM={};C(RM,{updateToken:()=>nK});function nK(e,t,r){if(e.get([t]))for(let[o,s]of Object.entries(r))e.set([t,o],s)}var jM=f(()=>{i(nK,"updateToken")});var DM={};C(DM,{removeToken:()=>oK});function oK(e,t){let r=e.get([t]);return e.remove([t]),r}var MM=f(()=>{i(oK,"removeToken")});var rb,ZM=f(()=>{Rn();rb=Tt("token",e=>({create:{description:'Create a design token. path is the token name (e.g. "color/primary"), type is the token kind (color, dimension, fontFamily, etc.), value is the CSS value. Reference tokens in styles via the slugged path (slashes/dots become dashes): path "color/primary" \u2192 var(--color-primary).',mcpName:"create_token",schema:[{path:"String",value:"String",type:"String?"}],examples:[{args:{path:"color/primary",value:"#3B82F6",type:"color"},description:"Create a primary color token"},{args:{path:"spacing/lg",value:"24px",type:"dimension"},description:"Create a spacing token"}],returns:"{ id: String, path: String }",handler:async t=>{let r=e("state"),{addToken:n}=await Promise.resolve().then(()=>(AM(),OM)),o=r.ref(["tokens"]),{path:s,value:a,type:c}=t;return{id:n(o,{$path:s,$value:a,...c!==void 0?{$type:c}:{}}),path:s}}},update:{description:"Update a design token. changes may include path, value, or type.",mcpName:"update_token",schema:[{tokenId:"String",changes:"Object"}],examples:[{args:{tokenId:"tk_abc",changes:{value:"#EF4444"}},description:"Change a token value"}],returns:"{ id: String }",handler:async t=>{let r=e("state"),{updateToken:n}=await Promise.resolve().then(()=>(jM(),RM)),o=r.ref(["tokens"]),{tokenId:s,changes:a={}}=t,c={};return a.path!==void 0&&(c.$path=a.path),a.value!==void 0&&(c.$value=a.value),a.type!==void 0&&(c.$type=a.type),n(o,s,c),{id:s}}},delete:{description:"Delete a design token by id.",mcpName:"delete_token",schema:[{tokenId:"String"}],examples:[{args:{tokenId:"tk_abc"},description:"Delete a token"}],returns:"{ id: String }",handler:async t=>{let r=e("state"),{removeToken:n}=await Promise.resolve().then(()=>(MM(),DM)),o=r.ref(["tokens"]);return n(o,t.tokenId),{id:t.tokenId}}}}))});var FM={};C(FM,{validateStorePayload:()=>iK});function sK(e){return typeof e=="string"&&/^\s*function\b/.test(e)}function iK(e){let t=[];if(!e||typeof e!="object"||Array.isArray(e))throw new Error("store payload must be an object");(typeof e.name!="string"||!e.name.trim())&&t.push("name must be a non-empty string"),e.state!==void 0&&(Array.isArray(e.state)?e.state.forEach((r,n)=>{if(!r||typeof r!="object"||Array.isArray(r)){t.push(`state[${n}] must be an object`);return}(typeof r.key!="string"||!r.key.trim())&&t.push(`state[${n}].key must be a non-empty string`),(typeof r.type!="string"||!LM.has(r.type))&&t.push(`state[${n}].type must be one of ${[...LM].join("|")}`)}):t.push("state must be an array"));for(let r of["computed","actions"])if(e[r]!==void 0){if(!Array.isArray(e[r])){t.push(`${r} must be an array`);continue}e[r].forEach((n,o)=>{if(!n||typeof n!="object"||Array.isArray(n)){t.push(`${r}[${o}] must be an object`);return}(typeof n.name!="string"||!n.name.trim())&&t.push(`${r}[${o}].name must be a non-empty string`),sK(n.code)||t.push(`${r}[${o}].code must be a function expression string (e.g. function () { ... })`)})}if(t.length)throw new Error(`Invalid store payload:
161
205
  - ${t.join(`
162
- - `)}`);return!0}var OO,jO=f(()=>{OO=new Set(["string","number","boolean","array","object"]);i(w5,"isFunctionCode");i(b5,"validateStorePayload")});function R_(e,t){if(e==null||typeof e!="string")return e;switch(t){case"number":return e===""?0:Number(e);case"boolean":return e==="true"||e==="1";case"array":case"object":if(!e||e==="")return t==="array"?[]:{};try{return JSON.parse(e)}catch{return t==="array"?[]:{}}default:return e}}function Ui(e,{key:t,name:r,index:n}){let o=t??r;return o!==void 0?e.findIndex(s=>(s.key??s.name)===o):n??-1}var O_,DO=f(()=>{vn();i(R_,"coerceValue");i(Ui,"resolveIndex");O_=bt("store",e=>({create:{description:"Create a data store. Stores hold reactive values, computed properties, and actions that nodes can bind to (via repeat, model, render, or {{expressions}}). The store id is its name. Optionally pass state/computed/actions arrays to seed the store in one call. Store actions and computed use this for state (e.g. function () { this.items = []; }), not a context first argument.",alias:"createStore",mcpName:"create_store",schema:[{name:"String",state:"Array?",computed:"Array?",actions:"Array?"}],examples:[{args:{name:"todo",state:[{key:"newText",type:"string",value:""},{key:"items",type:"array",value:[]}],actions:[{name:"addTodo",code:'function () { const text = this.newText.trim(); if (!text) return; this.items = [...this.items, { text, done: false }]; this.newText = ""; }'}]},description:"Create a todo store with state and actions in one call"}],returns:"{ id: String }",handler:async t=>{let r=e("state"),{validateStorePayload:n}=await Promise.resolve().then(()=>(jO(),AO)),{addStore:o}=await Promise.resolve().then(()=>(Ly(),wC)),{createValue:s}=await Promise.resolve().then(()=>(md(),hC)),{createComputed:a}=await Promise.resolve().then(()=>(pd(),dC)),{createAction:c}=await Promise.resolve().then(()=>(ud(),aC));n(t);let l=r.ref(["stores"]),u=o(l,t.name);return t.state?.length&&l.set([u,"state"],t.state.map(d=>s({key:d.key,type:d.type,value:R_(d.value,d.type)}))),t.computed?.length&&l.set([u,"computed"],t.computed.map(d=>a({name:d.name,code:d.code}))),t.actions?.length&&l.set([u,"actions"],t.actions.map(d=>c({name:d.name,code:d.code}))),{id:u}}},remove:{description:"Remove a data store and everything in it.",alias:"removeStore",schema:[{storeId:"String"}],returns:"{ id: String }",handler:async t=>{let r=e("state"),{removeStore:n}=await Promise.resolve().then(()=>(Uy(),bC));return n(r.ref(["stores"]),t.storeId),{id:t.storeId}}},addValue:{description:"Add a reactive value to a store. key is the value name, type is string/number/boolean/array/object, value is the initial value.",mcpName:"add_store_value",schema:[{storeId:"String",key:"String?",type:"String?",value:"String?"}],examples:[{args:{storeId:"cart",key:"items",type:"array",value:"[]"},description:"Add an items array to the cart store"}],returns:"{ storeId: String, key: String, index: Number }",handler:async t=>{let r=e("state"),{addValue:n}=await Promise.resolve().then(()=>(Oy(),gC)),{updateValue:o}=await Promise.resolve().then(()=>(hd(),jy)),s=r.ref(["stores"]),{storeId:a,key:c,type:l,value:u}=t;n(s,a,l);let d=s.get([a,"state"])??[],p=0,h=d[p];if(c!==void 0||u!==void 0){let m=l??h.type;o(s,a,p,{key:c??h.key,type:m,value:R_(u??h.value,m)})}return{storeId:a,key:c??h.key,index:p}}},updateValue:{description:"Update a store value by key (or index). changes may include key, type, value.",schema:[{storeId:"String",key:"String?",index:"Number?",changes:"Object"}],examples:[{args:{storeId:"cart",key:"items",changes:{value:'[{"id":1}]'}},description:"Set the items value"}],returns:"{ storeId: String, index: Number }",handler:async t=>{let r=e("state"),{updateValue:n}=await Promise.resolve().then(()=>(hd(),jy)),o=r.ref(["stores"]),{storeId:s,changes:a={}}=t,c=o.get([s,"state"])??[],l=Ui(c,t);if(l<0)throw new Error(`store value not found: ${t.key??t.index} in ${s}`);let u={...c[l],...a};return a.value!==void 0&&(u.value=R_(u.value,u.type)),n(o,s,l,u),{storeId:s,index:l}}},removeValue:{description:"Remove a store value by key (or index).",schema:[{storeId:"String",key:"String?",index:"Number?"}],returns:"{ storeId: String, index: Number }",handler:async t=>{let r=e("state"),{removeValue:n}=await Promise.resolve().then(()=>(My(),yC)),o=r.ref(["stores"]),s=o.get([t.storeId,"state"])??[],a=Ui(s,t);if(a<0)throw new Error(`store value not found: ${t.key??t.index} in ${t.storeId}`);return n(o,t.storeId,a),{storeId:t.storeId,index:a}}},addComputed:{description:"Add a computed property to a store. code is a function body string: function () { ... } with store state available on this (e.g. this.items).",schema:[{storeId:"String",name:"String?",code:"String?"}],examples:[{args:{storeId:"cart",name:"total",code:"function () { return this.items.reduce((s, i) => s + i.price, 0); }"},description:"Add a cart total computed"}],returns:"{ storeId: String, name: String, index: Number }",handler:async t=>{let r=e("state"),{addComputed:n}=await Promise.resolve().then(()=>(Ty(),pC)),{updateComputed:o}=await Promise.resolve().then(()=>(fd(),Cy)),s=r.ref(["stores"]),{storeId:a,name:c,code:l}=t;n(s,a);let u=s.get([a,"computed"])??[],d=0,p=u[d];return(c!==void 0||l!==void 0)&&o(s,a,d,{name:c??p.name,code:l??p.code}),{storeId:a,name:c??p.name,index:d}}},updateComputed:{description:"Update a store computed property by name (or index). changes may include name, code.",schema:[{storeId:"String",name:"String?",index:"Number?",changes:"Object"}],returns:"{ storeId: String, index: Number }",handler:async t=>{let r=e("state"),{updateComputed:n}=await Promise.resolve().then(()=>(fd(),Cy)),o=r.ref(["stores"]),{storeId:s,changes:a={}}=t,c=o.get([s,"computed"])??[],l=Ui(c,t);if(l<0)throw new Error(`store computed not found: ${t.name??t.index} in ${s}`);return n(o,s,l,{...c[l],...a}),{storeId:s,index:l}}},removeComputed:{description:"Remove a store computed property by name (or index).",schema:[{storeId:"String",name:"String?",index:"Number?"}],returns:"{ storeId: String, index: Number }",handler:async t=>{let r=e("state"),{removeComputed:n}=await Promise.resolve().then(()=>(Py(),fC)),o=r.ref(["stores"]),s=o.get([t.storeId,"computed"])??[],a=Ui(s,t);if(a<0)throw new Error(`store computed not found: ${t.name??t.index} in ${t.storeId}`);return n(o,t.storeId,a),{storeId:t.storeId,index:a}}},addAction:{description:"Add an action to a store. code is a function body string: function () { ... } that can read and mutate store values via this (e.g. this.items).",schema:[{storeId:"String",name:"String?",code:"String?"}],examples:[{args:{storeId:"cart",name:"clear",code:"function () { this.items = []; }"},description:"Add a clear-cart action"}],returns:"{ storeId: String, name: String, index: Number }",handler:async t=>{let r=e("state"),{addAction:n}=await Promise.resolve().then(()=>(by(),cC)),{updateAction:o}=await Promise.resolve().then(()=>(dd(),ky)),s=r.ref(["stores"]),{storeId:a,name:c,code:l}=t;n(s,a);let u=s.get([a,"actions"])??[],d=0,p=u[d];return(c!==void 0||l!==void 0)&&o(s,a,d,{name:c??p.name,code:l??p.code}),{storeId:a,name:c??p.name,index:d}}},updateAction:{description:"Update a store action by name (or index). changes may include name, code.",schema:[{storeId:"String",name:"String?",index:"Number?",changes:"Object"}],returns:"{ storeId: String, index: Number }",handler:async t=>{let r=e("state"),{updateAction:n}=await Promise.resolve().then(()=>(dd(),ky)),o=r.ref(["stores"]),{storeId:s,changes:a={}}=t,c=o.get([s,"actions"])??[],l=Ui(c,t);if(l<0)throw new Error(`store action not found: ${t.name??t.index} in ${s}`);return n(o,s,l,{...c[l],...a}),{storeId:s,index:l}}},removeAction:{description:"Remove a store action by name (or index).",schema:[{storeId:"String",name:"String?",index:"Number?"}],returns:"{ storeId: String, index: Number }",handler:async t=>{let r=e("state"),{removeAction:n}=await Promise.resolve().then(()=>(Ey(),lC)),o=r.ref(["stores"]),s=o.get([t.storeId,"actions"])??[],a=Ui(s,t);if(a<0)throw new Error(`store action not found: ${t.name??t.index} in ${t.storeId}`);return n(o,t.storeId,a),{storeId:t.storeId,index:a}}}}))});var MO,ZO=f(()=>{MO=i(()=>({__version:1,type:"animation",scope:"node",name:null,duration:300,easing:"ease",fill:"none",direction:"normal",iterations:1,delay:0,endDelay:0,iterationStart:0,composite:"replace",keyframes:[]}),"animationDefaults")});var LO={};R(LO,{createAnimation:()=>S5});function S5(e={}){return{...MO(),...Object.fromEntries(Object.entries(e).filter(([,r])=>r!==void 0))}}var FO=f(()=>{ZO();i(S5,"createAnimation")});var UO={};R(UO,{addAnimationBinding:()=>k5});function k5(e,t,r){e.push([t,"animations"],r)}var qO=f(()=>{i(k5,"addAnimationBinding")});var HO={};R(HO,{removeAnimationBinding:()=>$5});function $5(e,t,r){e.removeWhere([t,"animations"],{id:r})}var BO=f(()=>{i($5,"removeAnimationBinding")});var VO={};R(VO,{updateAnimationBinding:()=>E5});function E5(e,t,r,n){let o=e.findWhere([t,"animations"],{id:r});if(o===void 0)return;let s={...o,...n};e.setWhere([t,"animations"],{id:r},s)}var GO=f(()=>{i(E5,"updateAnimationBinding")});var A_,WO=f(()=>{vn();A_=bt("animation",e=>({create:{description:'Create an animation asset. keyframes is a Web Animations API keyframe array (e.g. [{ opacity: 0 }, { opacity: 1 }]). scope is "project" (reusable) or "node". Bind it to nodes with animation:bind.',mcpName:"create_animation",schema:[{name:"String",keyframes:"Array",duration:"Number?",easing:"String?",iterations:"Number?",fill:"String?",scope:"String?"}],examples:[{args:{name:"Fade In",keyframes:[{opacity:0},{opacity:1}],duration:400,easing:"ease-out",scope:"project"},description:"Create a reusable fade-in animation"}],returns:"{ id: String, name: String }",handler:async t=>{let r=e("state"),{createAnimation:n}=await Promise.resolve().then(()=>(FO(),LO)),{createAnimationId:o}=await Promise.resolve().then(()=>(Ca(),Xk)),s=r.ref(["animations"]),{name:a,keyframes:c,duration:l,easing:u,iterations:d,fill:p,scope:h}=t,m=o();return s.set([m],n({name:a,keyframes:c,duration:l,easing:u,iterations:d,fill:p,scope:h??"project"})),{id:m,name:a}}},update:{description:"Update an animation asset. changes may include name, keyframes, duration, easing, iterations, fill, direction, delay.",schema:[{animationId:"String",changes:"Object"}],examples:[{args:{animationId:"anim_abc",changes:{duration:600}},description:"Slow an animation down"}],returns:"{ id: String }",handler:async t=>{let n=e("state").ref(["animations"]),{animationId:o,changes:s={}}=t;if(!n.get([o]))throw new Error(`animation not found: ${o}`);for(let[c,l]of Object.entries(s))n.set([o,c],l);return{id:o}}},delete:{description:"Delete an animation asset by id. Does not remove bindings that reference it.",schema:[{animationId:"String"}],returns:"{ id: String }",handler:async t=>(e("state").ref(["animations"]).remove([t.animationId]),{id:t.animationId})},bind:{description:'Bind an animation to a node. play is the trigger: "mount", "click", "hover", etc. Set reverse to a trigger to play backwards on that event.',mcpName:"bind_animation",schema:[{nodeId:"String",animationId:"String",play:"String?",reverse:"String?"}],examples:[{args:{nodeId:"nd_hero",animationId:"anim_abc",play:"mount"},description:"Fade the hero in on mount"}],returns:"{ nodeId: String, animationId: String, index: Number }",handler:async t=>{let r=e("state"),{addAnimationBinding:n}=await Promise.resolve().then(()=>(qO(),UO)),o=r.ref(["nodes"]),{nodeId:s,animationId:a,play:c,reverse:l}=t,u={id:a,play:c??"mount"};return l!==void 0&&(u.reverse=l),n(o,s,u),{nodeId:s,animationId:a}}},unbind:{description:"Remove an animation binding from a node by animation id.",schema:[{nodeId:"String",animationId:"String"}],returns:"{ nodeId: String, animationId: String }",handler:async t=>{let r=e("state"),{removeAnimationBinding:n}=await Promise.resolve().then(()=>(BO(),HO));return n(r.ref(["nodes"]),t.nodeId,t.animationId),{nodeId:t.nodeId,animationId:t.animationId}}},updateBinding:{description:"Update an animation binding on a node by animation id. binding may include play, reverse, or id.",schema:[{nodeId:"String",animationId:"String",binding:"Object"}],returns:"{ nodeId: String, animationId: String }",handler:async t=>{let r=e("state"),{updateAnimationBinding:n}=await Promise.resolve().then(()=>(GO(),VO));return n(r.ref(["nodes"]),t.nodeId,t.animationId,t.binding),{nodeId:t.nodeId,animationId:t.animationId}}}}))});var D_={};R(D_,{allOperations:()=>j_,animationOperations:()=>A_,behaviorOperations:()=>I_,nodeOperations:()=>T_,storeOperations:()=>O_,tokenOperations:()=>P_,treeOperations:()=>z_});var j_,mf=f(()=>{bO();SO();kO();RO();DO();WO();j_=[T_,z_,I_,P_,O_,A_]});var YO={};R(YO,{loadAllPlaybook:()=>R5,loadPlaybook:()=>P5});import{readFileSync as KO,readdirSync as N5}from"fs";import{join as JO,dirname as T5}from"path";import{fileURLToPath as z5}from"url";function P5(e=I5){return e.map(t=>{let r=JO(M_,t.endsWith(".md")?t:`${t}.md`);return KO(r,"utf-8")}).join(`
206
+ - `)}`);return!0}var LM,UM=f(()=>{LM=new Set(["string","number","boolean","array","object"]);i(sK,"isFunctionCode");i(iK,"validateStorePayload")});function nb(e,t){if(e==null||typeof e!="string")return e;switch(t){case"number":return e===""?0:Number(e);case"boolean":return e==="true"||e==="1";case"array":case"object":if(!e||e==="")return t==="array"?[]:{};try{return JSON.parse(e)}catch{return t==="array"?[]:{}}default:return e}}function Aa(e,{key:t,name:r,index:n}){let o=t??r;return o!==void 0?e.findIndex(s=>(s.key??s.name)===o):n??-1}var ob,qM=f(()=>{Rn();i(nb,"coerceValue");i(Aa,"resolveIndex");ob=Tt("store",e=>({create:{description:"Create a data store. Stores hold reactive values, computed properties, and actions that nodes can bind to (via repeat, model, render, or {{expressions}}). The store id is its name. Optionally pass state/computed/actions arrays to seed the store in one call. Store actions and computed use this for state (e.g. function () { this.items = []; }), not a context first argument.",alias:"createStore",mcpName:"create_store",schema:[{name:"String",state:"Array?",computed:"Array?",actions:"Array?"}],examples:[{args:{name:"todo",state:[{key:"newText",type:"string",value:""},{key:"items",type:"array",value:[]}],actions:[{name:"addTodo",code:'function () { const text = this.newText.trim(); if (!text) return; this.items = [...this.items, { text, done: false }]; this.newText = ""; }'}]},description:"Create a todo store with state and actions in one call"}],returns:"{ id: String }",handler:async t=>{let r=e("state"),{validateStorePayload:n}=await Promise.resolve().then(()=>(UM(),FM)),{addStore:o}=await Promise.resolve().then(()=>(M_(),mO)),{createValue:s}=await Promise.resolve().then(()=>(Vp(),cO)),{createComputed:a}=await Promise.resolve().then(()=>(Bp(),oO)),{createAction:c}=await Promise.resolve().then(()=>(Up(),eO));n(t);let l=r.ref([".stores"]),u=o(l,t.name);return t.state?.length&&l.set([u,"state"],t.state.map(d=>s({key:d.key,type:d.type,value:nb(d.value,d.type)}))),t.computed?.length&&l.set([u,"computed"],t.computed.map(d=>a({name:d.name,code:d.code}))),t.actions?.length&&l.set([u,"actions"],t.actions.map(d=>c({name:d.name,code:d.code}))),{id:u}}},remove:{description:"Remove a data store and everything in it.",alias:"removeStore",schema:[{storeId:"String"}],returns:"{ id: String }",handler:async t=>{let r=e("state"),{removeStore:n}=await Promise.resolve().then(()=>(L_(),hO));return n(r.ref([".stores"]),t.storeId),{id:t.storeId}}},addValue:{description:"Add a reactive value to a store. key is the value name, type is string/number/boolean/array/object, value is the initial value.",mcpName:"add_store_value",schema:[{storeId:"String",key:"String?",type:"String?",value:"String?"}],examples:[{args:{storeId:"cart",key:"items",type:"array",value:"[]"},description:"Add an items array to the cart store"}],returns:"{ storeId: String, key: String, index: Number }",handler:async t=>{let r=e("state"),{addValue:n}=await Promise.resolve().then(()=>(P_(),lO)),{updateValue:o}=await Promise.resolve().then(()=>(Gp(),A_)),s=r.ref([".stores"]),{storeId:a,key:c,type:l,value:u}=t;n(s,a,l);let d=s.get([a,"state"])??[],p=0,m=d[p];if(c!==void 0||u!==void 0){let h=l??m.type;o(s,a,p,{key:c??m.key,type:h,value:nb(u??m.value,h)})}return{storeId:a,key:c??m.key,index:p}}},updateValue:{description:"Update a store value by key (or index). changes may include key, type, value.",schema:[{storeId:"String",key:"String?",index:"Number?",changes:"Object"}],examples:[{args:{storeId:"cart",key:"items",changes:{value:'[{"id":1}]'}},description:"Set the items value"}],returns:"{ storeId: String, index: Number }",handler:async t=>{let r=e("state"),{updateValue:n}=await Promise.resolve().then(()=>(Gp(),A_)),o=r.ref([".stores"]),{storeId:s,changes:a={}}=t,c=o.get([s,"state"])??[],l=Aa(c,t);if(l<0)throw new Error(`store value not found: ${t.key??t.index} in ${s}`);let u={...c[l],...a};return a.value!==void 0&&(u.value=nb(u.value,u.type)),n(o,s,l,u),{storeId:s,index:l}}},removeValue:{description:"Remove a store value by key (or index).",schema:[{storeId:"String",key:"String?",index:"Number?"}],returns:"{ storeId: String, index: Number }",handler:async t=>{let r=e("state"),{removeValue:n}=await Promise.resolve().then(()=>(j_(),uO)),o=r.ref([".stores"]),s=o.get([t.storeId,"state"])??[],a=Aa(s,t);if(a<0)throw new Error(`store value not found: ${t.key??t.index} in ${t.storeId}`);return n(o,t.storeId,a),{storeId:t.storeId,index:a}}},addComputed:{description:"Add a computed property to a store. code is a function body string: function () { ... } with store state available on this (e.g. this.items).",schema:[{storeId:"String",name:"String?",code:"String?"}],examples:[{args:{storeId:"cart",name:"total",code:"function () { return this.items.reduce((s, i) => s + i.price, 0); }"},description:"Add a cart total computed"}],returns:"{ storeId: String, name: String, index: Number }",handler:async t=>{let r=e("state"),{addComputed:n}=await Promise.resolve().then(()=>(E_(),sO)),{updateComputed:o}=await Promise.resolve().then(()=>(Hp(),T_)),s=r.ref([".stores"]),{storeId:a,name:c,code:l}=t;n(s,a);let u=s.get([a,"computed"])??[],d=0,p=u[d];return(c!==void 0||l!==void 0)&&o(s,a,d,{name:c??p.name,code:l??p.code}),{storeId:a,name:c??p.name,index:d}}},updateComputed:{description:"Update a store computed property by name (or index). changes may include name, code.",schema:[{storeId:"String",name:"String?",index:"Number?",changes:"Object"}],returns:"{ storeId: String, index: Number }",handler:async t=>{let r=e("state"),{updateComputed:n}=await Promise.resolve().then(()=>(Hp(),T_)),o=r.ref([".stores"]),{storeId:s,changes:a={}}=t,c=o.get([s,"computed"])??[],l=Aa(c,t);if(l<0)throw new Error(`store computed not found: ${t.name??t.index} in ${s}`);return n(o,s,l,{...c[l],...a}),{storeId:s,index:l}}},removeComputed:{description:"Remove a store computed property by name (or index).",schema:[{storeId:"String",name:"String?",index:"Number?"}],returns:"{ storeId: String, index: Number }",handler:async t=>{let r=e("state"),{removeComputed:n}=await Promise.resolve().then(()=>(C_(),iO)),o=r.ref([".stores"]),s=o.get([t.storeId,"computed"])??[],a=Aa(s,t);if(a<0)throw new Error(`store computed not found: ${t.name??t.index} in ${t.storeId}`);return n(o,t.storeId,a),{storeId:t.storeId,index:a}}},addAction:{description:"Add an action to a store. code is a function body string: function () { ... } that can read and mutate store values via this (e.g. this.items).",schema:[{storeId:"String",name:"String?",code:"String?"}],examples:[{args:{storeId:"cart",name:"clear",code:"function () { this.items = []; }"},description:"Add a clear-cart action"}],returns:"{ storeId: String, name: String, index: Number }",handler:async t=>{let r=e("state"),{addAction:n}=await Promise.resolve().then(()=>(v_(),tO)),{updateAction:o}=await Promise.resolve().then(()=>(qp(),b_)),s=r.ref([".stores"]),{storeId:a,name:c,code:l}=t;n(s,a);let u=s.get([a,"actions"])??[],d=0,p=u[d];return(c!==void 0||l!==void 0)&&o(s,a,d,{name:c??p.name,code:l??p.code}),{storeId:a,name:c??p.name,index:d}}},updateAction:{description:"Update a store action by name (or index). changes may include name, code.",schema:[{storeId:"String",name:"String?",index:"Number?",changes:"Object"}],returns:"{ storeId: String, index: Number }",handler:async t=>{let r=e("state"),{updateAction:n}=await Promise.resolve().then(()=>(qp(),b_)),o=r.ref([".stores"]),{storeId:s,changes:a={}}=t,c=o.get([s,"actions"])??[],l=Aa(c,t);if(l<0)throw new Error(`store action not found: ${t.name??t.index} in ${s}`);return n(o,s,l,{...c[l],...a}),{storeId:s,index:l}}},removeAction:{description:"Remove a store action by name (or index).",schema:[{storeId:"String",name:"String?",index:"Number?"}],returns:"{ storeId: String, index: Number }",handler:async t=>{let r=e("state"),{removeAction:n}=await Promise.resolve().then(()=>(k_(),rO)),o=r.ref([".stores"]),s=o.get([t.storeId,"actions"])??[],a=Aa(s,t);if(a<0)throw new Error(`store action not found: ${t.name??t.index} in ${t.storeId}`);return n(o,t.storeId,a),{storeId:t.storeId,index:a}}}}))});var BM,HM=f(()=>{BM=i(()=>({__version:1,type:"animation",scope:"node",name:null,duration:300,easing:"ease",fill:"none",direction:"normal",iterations:1,delay:0,endDelay:0,iterationStart:0,composite:"replace",keyframes:[]}),"animationDefaults")});var VM={};C(VM,{createAnimation:()=>aK});function aK(e={}){return{...BM(),...Object.fromEntries(Object.entries(e).filter(([,r])=>r!==void 0))}}var GM=f(()=>{HM();i(aK,"createAnimation")});var WM={};C(WM,{addAnimationBinding:()=>cK});function cK(e,t,r){e.push([t,"animations"],r)}var JM=f(()=>{i(cK,"addAnimationBinding")});var KM={};C(KM,{removeAnimationBinding:()=>lK});function lK(e,t,r){e.removeWhere([t,"animations"],{id:r})}var YM=f(()=>{i(lK,"removeAnimationBinding")});var XM={};C(XM,{updateAnimationBinding:()=>uK});function uK(e,t,r,n){let o=e.findWhere([t,"animations"],{id:r});if(o===void 0)return;let s={...o,...n};e.setWhere([t,"animations"],{id:r},s)}var QM=f(()=>{i(uK,"updateAnimationBinding")});var sb,e2=f(()=>{Rn();sb=Tt("animation",e=>({create:{description:'Create an animation asset. keyframes is a Web Animations API keyframe array (e.g. [{ opacity: 0 }, { opacity: 1 }]). scope is "project" (reusable) or "node". Bind it to nodes with animation:bind.',mcpName:"create_animation",schema:[{name:"String",keyframes:"Array",duration:"Number?",easing:"String?",iterations:"Number?",fill:"String?",scope:"String?"}],examples:[{args:{name:"Fade In",keyframes:[{opacity:0},{opacity:1}],duration:400,easing:"ease-out",scope:"project"},description:"Create a reusable fade-in animation"}],returns:"{ id: String, name: String }",handler:async t=>{let r=e("state"),{createAnimation:n}=await Promise.resolve().then(()=>(GM(),VM)),{createAnimationId:o}=await Promise.resolve().then(()=>($c(),TN)),s=r.ref(["animations"]),{name:a,keyframes:c,duration:l,easing:u,iterations:d,fill:p,scope:m}=t,h=o();return s.set([h],n({name:a,keyframes:c,duration:l,easing:u,iterations:d,fill:p,scope:m??"project"})),{id:h,name:a}}},update:{description:"Update an animation asset. changes may include name, keyframes, duration, easing, iterations, fill, direction, delay.",schema:[{animationId:"String",changes:"Object"}],examples:[{args:{animationId:"anim_abc",changes:{duration:600}},description:"Slow an animation down"}],returns:"{ id: String }",handler:async t=>{let n=e("state").ref(["animations"]),{animationId:o,changes:s={}}=t;if(!n.get([o]))throw new Error(`animation not found: ${o}`);for(let[c,l]of Object.entries(s))n.set([o,c],l);return{id:o}}},delete:{description:"Delete an animation asset by id. Does not remove bindings that reference it.",schema:[{animationId:"String"}],returns:"{ id: String }",handler:async t=>(e("state").ref(["animations"]).remove([t.animationId]),{id:t.animationId})},bind:{description:'Bind an animation to a node. play is the trigger: "mount", "click", "hover", etc. Set reverse to a trigger to play backwards on that event.',mcpName:"bind_animation",schema:[{nodeId:"String",animationId:"String",play:"String?",reverse:"String?"}],examples:[{args:{nodeId:"nd_hero",animationId:"anim_abc",play:"mount"},description:"Fade the hero in on mount"}],returns:"{ nodeId: String, animationId: String, index: Number }",handler:async t=>{let r=e("state"),{addAnimationBinding:n}=await Promise.resolve().then(()=>(JM(),WM)),o=r.ref(["nodes"]),{nodeId:s,animationId:a,play:c,reverse:l}=t,u={id:a,play:c??"mount"};return l!==void 0&&(u.reverse=l),n(o,s,u),{nodeId:s,animationId:a}}},unbind:{description:"Remove an animation binding from a node by animation id.",schema:[{nodeId:"String",animationId:"String"}],returns:"{ nodeId: String, animationId: String }",handler:async t=>{let r=e("state"),{removeAnimationBinding:n}=await Promise.resolve().then(()=>(YM(),KM));return n(r.ref(["nodes"]),t.nodeId,t.animationId),{nodeId:t.nodeId,animationId:t.animationId}}},updateBinding:{description:"Update an animation binding on a node by animation id. binding may include play, reverse, or id.",schema:[{nodeId:"String",animationId:"String",binding:"Object"}],returns:"{ nodeId: String, animationId: String }",handler:async t=>{let r=e("state"),{updateAnimationBinding:n}=await Promise.resolve().then(()=>(QM(),XM));return n(r.ref(["nodes"]),t.nodeId,t.animationId,t.binding),{nodeId:t.nodeId,animationId:t.animationId}}}}))});var t2={};C(t2,{allOperations:()=>ib,animationOperations:()=>sb,behaviorOperations:()=>tb,nodeOperations:()=>Xw,storeOperations:()=>ob,tokenOperations:()=>rb,treeOperations:()=>Qw});var ib,ab=f(()=>{TM();zM();CM();ZM();qM();e2();ib=[Xw,Qw,tb,rb,ob,sb]});var r2={};C(r2,{default:()=>pK});import{defineRoutes as dK}from"@jucie.io/engine-server";var pK,n2=f(()=>{pK=dK("ai",e=>{let t=e("log"),r=e("aiHistory"),n=i((o,s,a=500)=>(t.error("ai chats route failed",{error:s.message}),o.json({error:s.message},a)),"fail");return[{method:"get",path:"/chats",handler:async({respond:o})=>{try{return o.json({sessions:await r.listSessions()})}catch(s){return n(o,s)}}},{method:"post",path:"/chats",handler:async({respond:o})=>{try{return o.json(await r.createSession())}catch(s){return n(o,s)}}},{method:"get",path:"/chats/:id",handler:async({req:o,respond:s})=>{try{let a=await r.getMessages(o.params.id);return s.json({id:o.params.id,messages:a})}catch(a){return n(s,a)}}},{method:"delete",path:"/chats/:id",handler:async({req:o,respond:s})=>{try{return s.json(await r.deleteSession(o.params.id))}catch(a){return n(s,a)}}},{method:"post",path:"/chats/:id/attachments",handler:async({req:o,respond:s})=>{try{let{name:a,mimeType:c,data:l}=o.body;if(!a||!l)return s.json({error:"name and data (base64) are required"},400);let u=await r.saveAttachment(o.params.id,{name:a,mimeType:c,data:l});return s.json(u)}catch(a){return n(s,a)}}},{method:"get",path:"/chats/:id/attachments",handler:async({req:o,respond:s})=>{try{let a=await r.listAttachments(o.params.id);return s.json({files:a})}catch(a){return n(s,a)}}},{method:"get",path:"/chats/:id/attachments/:fileId",handler:async({req:o,respond:s})=>{try{let a=await r.getAttachment(o.params.id,o.params.fileId);return a?s.file(a.path,200,{"Content-Type":a.mimeType}):s.json({error:"Not found"},404)}catch(a){return n(s,a)}}},{method:"delete",path:"/chats/:id/attachments/:fileId",handler:async({req:o,respond:s})=>{try{return s.json(await r.deleteAttachment(o.params.id,o.params.fileId))}catch(a){return n(s,a)}}}]})});var i2={};C(i2,{loadAllPlaybook:()=>_K,loadPlaybook:()=>xK});import{readFileSync as o2,readdirSync as fK}from"fs";import{join as s2,dirname as mK}from"path";import{fileURLToPath as hK}from"url";function xK(e=yK){return e.map(t=>{let r=s2(cb,t.endsWith(".md")?t:`${t}.md`);return o2(r,"utf-8")}).join(`
163
207
 
164
- `)}function R5(){return N5(M_).filter(e=>e.endsWith(".md")).sort().map(e=>KO(JO(M_,e),"utf-8")).join(`
208
+ `)}function _K(){return fK(cb).filter(e=>e.endsWith(".md")).sort().map(e=>o2(s2(cb,e),"utf-8")).join(`
165
209
 
166
- `)}var C5,M_,I5,XO=f(()=>{C5=T5(z5(import.meta.url)),M_=C5,I5=["elements.md","layout.md","interactivity.md","workflow.md"];i(P5,"loadPlaybook");i(R5,"loadAllPlaybook")});var QO={};R(QO,{default:()=>j5});import{defineRoutes as O5}from"@jucie.io/engine-server";function A5(e,t,{maxDepth:r=1/0}={}){let n=" ",o=i((x,v)=>{let w=n.repeat(v);return x.split(`
167
- `).map(b=>w+b).join(`
168
- `)},"indent"),s=i(x=>String(x).replace(/"/g,"&quot;"),"esc"),a=i(x=>String(x).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;"),"escText"),c=i(x=>Math.round(x??0),"r"),l=i(x=>`${c(x.x)},${c(x.y)},${c(x.width)}x${c(x.height)}`,"formatBounds"),u=i(x=>{let v=i(b=>!b||typeof b!="object"?"":Object.entries(b).map(([S,T])=>`${S}: ${T}`).join("; "),"cssDecls"),w=[];x.default&&w.push(v(x.default));for(let b of Object.keys(x)){if(b==="default")continue;let S=v(x[b]);S&&w.push(`${b}: { ${S} }`)}return w.filter(Boolean).join(" | ")},"formatStyle"),d=i(x=>Array.isArray(x)?x.join("."):x??"","formatBinding"),p=i(x=>x.map(v=>{let w=v.key??v.name??v.event;if(!w)return null;if(v.mode==="binding"||v.binding){let S=d(v.binding);return S?`${w}=${S}`:w}let b=v.code??v.expression??v.value??v.handler??"";return b?`${w}=${b}`:w}).filter(Boolean).join(", "),"formatEvents"),h=i(x=>x.map(v=>{let w=v.key??v.name;if(!w)return null;if(v.mode==="binding"||v.binding){let S=d(v.binding);return S?`${w}=${S}`:w}let b=v.expression?`{{${v.expression}}}`:v.value??"";return b!==""?`${w}=${b}`:w}).filter(Boolean).join(", "),"formatAttrs"),m=i((x,v)=>{let w=[],b=x.id??v;if(b&&w.push(`id="${s(b)}"`),x.name&&w.push(`name="${s(x.name)}"`),x.bounds&&w.push(`bounds="${l(x.bounds)}"`),x.style&&Object.keys(x.style).length){let S=u(x.style);S&&w.push(`style="${s(S)}"`)}return x.events?.length&&w.push(`events="${s(p(x.events))}"`),x.attributes?.length&&w.push(`attrs="${s(h(x.attributes))}"`),x.className?.length&&w.push(`class="${x.className.join(" ")}"`),x.repeat&&w.push(`repeat="${s(JSON.stringify(x.repeat))}"`),x.component&&w.push(`component="${s(x.component)}"`),x.library&&w.push(`library="${s(x.library)}"`),x.props&&Object.keys(x.props).length&&w.push(`props="${s(JSON.stringify(x.props))}"`),x.route?.path&&w.push(`route="${s(x.route.path)}"`),x.render?.value&&w.push(`render="{{${s(x.render.value)}}}"`),x.destination?.path&&w.push(`dest="${s(x.destination.path)}"`),w.length?" "+w.join(" "):""},"buildAttrString"),g=i(x=>{let v=e[x];if(!v)return null;if(v.ex&&e[v.ex]){let w=g(v.ex);if(!w)return v;let{ex:b,...S}=v;return Object.assign({},w,S)}return v},"resolveNode"),_=i((x,v)=>{let w=e[x],b=g(x);if(!b)return`<!-- missing: ${x} -->`;let S,T;if(b.type==="element"){let se=w?.ex&&Bs(w.ex)?w.ex:b.type;S=se,T=Au(se)}else if(b.type){S=b.type;let se=w?.ex&&Bs(w.ex)?w.ex:b.type;T=Au(se)}else S=x,T=null;let K=T?`${S}:${T}`:S,A=m(b,x),Y=b.textContent?.value||null,W=Array.isArray(b.children)?b.children:[];if(!(W.length>0||Y!=null&&Y!==""))return`<${K}${A} />`;if(v>=r){let se=W.length?`<\u22EF${W.length} children>`:"<\u22EFtext>";return`<${K}${A}>${se}</${K}>`}if(Y!=null&&Y!==""&&W.length===0)return`<${K}${A}>${a(Y)}</${K}>`;let X=W.map(se=>o(_(se,v+1),1)).join(`
169
- `);return`<${K}${A}>
170
- ${X}
171
- </${K}>`},"renderNode");return _(t,0)}var j5,eA=f(()=>{Ru();i(A5,"projectJsx");j5=O5(e=>{let t=e("log");return[{method:"get",path:"/mcp/screenshot",handler:async({respond:r})=>{let s=[...e("cache").get(["connections"])??new Set][0];if(!s)return r.json({error:"no stage connected"},503);try{let a=await s.ask("screenshot:capture");return r.json(a)}catch(a){return r.json({error:a.message},504)}}},{method:"get",path:"/mcp/scene",handler:({req:r,respond:n})=>{try{let o=e("state"),s=r.query.root??"app",a=r.query.depth!=null?Number(r.query.depth):1/0,c=o.get(["nodes"]);if(!c)return n.json({error:"no scene loaded"},503);let l=A5(c,s,{maxDepth:a});return n.json({jsx:l})}catch(o){return t.error("mcp /scene failed",{error:o.message}),n.json({error:o.message},500)}}},{method:"get",path:"/mcp/tools",handler:({respond:r})=>{try{let n=e("aiOps");return r.json({namespaces:n.operationsMetadata})}catch(n){return t.error("mcp /tools failed",{error:n.message}),r.json({error:n.message},500)}}},{method:"post",path:"/mcp/operations",handler:async({req:r,respond:n})=>{try{let o=e("aiOps"),{operations:s=[]}=r.body??{},a=i(x=>{if(x.op){let v=o.resolveType(x.op);if(!v)return{error:o.describeUnresolved(x.op)};let{op:w,ref:b,...S}=x;return{type:v,args:S,ref:b}}if(typeof x.type=="string"){let v=o.resolveType(x.type);return v?{type:v,args:x.args??{},ref:x.ref}:{error:o.describeUnresolved(x.type)}}return{error:`unknown op: ${x.op??x.type}`}},"translate"),c=s.map(a),l=c.filter(x=>x.error),d={operations:c.filter(x=>!x.error)},m=[...e("cache").get(["connections"])??new Set][0],g;if(m)try{g=await m.ask("ai:stage:operations:execute",{batch:d},{timeoutMs:3e3})}catch(x){t.warn("mcp /operations: stage execute failed, falling back to server",{error:x.message}),g=await o.executeBatch(d)}else g=await o.executeBatch(d);let _=g.results.map(x=>x.result);return l.length&&l.forEach(x=>{t.warn("mcp /operations: unresolved op",{error:x.error}),_.push({error:x.error})}),n.json({results:_})}catch(o){return t.error("mcp /operations failed",{error:o.message}),n.json({error:o.message},500)}}}]})});var tA={};R(tA,{default:()=>M5});import{defineRoutes as D5}from"@jucie.io/engine-server";var M5,rA=f(()=>{M5=D5(e=>{let t=e("log"),r=e("aiHistory"),n=i((o,s,a=500)=>(t.error("ai chats route failed",{error:s.message}),o.json({error:s.message},a)),"fail");return[{method:"get",path:"/ai/chats",handler:async({respond:o})=>{try{return o.json({sessions:await r.listSessions()})}catch(s){return n(o,s)}}},{method:"post",path:"/ai/chats",handler:async({respond:o})=>{try{return o.json(await r.createSession())}catch(s){return n(o,s)}}},{method:"get",path:"/ai/chats/:id",handler:async({req:o,respond:s})=>{try{let a=await r.getMessages(o.params.id);return s.json({id:o.params.id,messages:a})}catch(a){return n(s,a)}}},{method:"delete",path:"/ai/chats/:id",handler:async({req:o,respond:s})=>{try{return s.json(await r.deleteSession(o.params.id))}catch(a){return n(s,a)}}},{method:"post",path:"/ai/chats/:id/assets",handler:async({req:o,respond:s})=>{try{let{name:a,mimeType:c,data:l}=o.body;if(!a||!l)return s.json({error:"name and data (base64) are required"},400);let u=await r.saveAttachment(o.params.id,{name:a,mimeType:c,data:l});return s.json(u)}catch(a){return n(s,a)}}},{method:"get",path:"/ai/chats/:id/assets",handler:async({req:o,respond:s})=>{try{let a=await r.listAttachments(o.params.id);return s.json({files:a})}catch(a){return n(s,a)}}},{method:"delete",path:"/ai/chats/:id/assets/:fileId",handler:async({req:o,respond:s})=>{try{return s.json(await r.deleteAttachment(o.params.id,o.params.fileId))}catch(a){return n(s,a)}}}]})});var nA={};R(nA,{default:()=>L5});import{defineRoutes as Z5}from"@jucie.io/engine-server";var L5,oA=f(()=>{L5=Z5(e=>{let t=e("libraries");return[{method:"get",path:"/libraries/:filename",handler:({respond:r,req:n})=>{let o=t.findLocal(n.params.filename);return o?r.file(o.path):r.text("Not found",404)}},{method:"get",path:"/api/libraries",handler:({respond:r})=>{let n=t.getClassNames(),o=[...new Set(n)].sort();return r.json({classNames:o})}}]})});var aA={};R(aA,{createDesignServer:()=>W5});import{Result as F5}from"@jucie.io/result";import{join as sA}from"path";import{Engine as U5}from"@jucie.io/engine";import{Server as q5}from"@jucie.io/engine-server";import{SocketServer as H5}from"@jucie.io/engine-socket/server";import{State as B5}from"@jucie.io/engine-state";import{Matcher as V5}from"@jucie.io/state-matcher";import{OnChange as G5}from"@jucie.io/state-on-change";async function W5(e={}){let t={error(){},warn(){},info(){},debug(){}},r=null;try{let n={},o=0,s=e.serve!==!1,a=e.ai!==!1,c=e.libraries!==!1,l=e.framework||"react";e.prebuiltStageDir=Pp(e.stageBundles,l);let u=[B5.configure({plugins:[yc.configure({actorId:"server"}),V5,G5]}),q5.configure(e),H5.configure({path:"/socket",maxPayloadBytes:5e7,heartbeatMs:3e4,...e.socket}),nn.configure({storage:{name:"state",provider:e.storageProvider??"local",root:e.projectRoot??e.sceneGraph,mode:"path",...e.storageConfig??{}},branch:e.branch||"main",namespaces:e.namespaces??{},configs:[di,pi,fi,mi,hi]}),an.configure(e),Ro.configure(e)];if(c){let{Libraries:v}=await Promise.resolve().then(()=>(YR(),JR));u.push(v.configure(e))}if(s){let{EsBuild:v}=await import("@jucie.io/engine-esbuild");u.push(v.configure(e))}if(a){let{AiOperations:v}=await Promise.resolve().then(()=>(vn(),aO)),{AiAgent:w,AiHistory:b}=await Promise.resolve().then(()=>(wO(),vO)),{allOperations:S}=await Promise.resolve().then(()=>(mf(),D_)),{loadPlaybook:T}=await Promise.resolve().then(()=>(XO(),YO));u.push(v,w.configure({aiServerUrl:e.aiServerUrl??process.env.AI_SERVER_URL??"https://ai.jucie.app/ai/generate",playbook:T()}),b.configure({dir:sA(e.projectRoot??process.cwd(),".jucie","chats"),assetsDir:sA(e.projectRoot??process.cwd(),".jucie","assets")}))}if(r=U5.create().install(...u),a){let{allOperations:v}=await Promise.resolve().then(()=>(mf(),D_));r.aiOps.use(...v)}t=r.log.child({ns:"stage:design"}),r.cache.set(["jucieConfig"],e),r.cache.set(["connections"],new Set),r.cache.set(["presence","users"],n);let d=!1,p=null;if(s){d=e.prebuiltStageDir?Ip(e):!0;let v;p=new Promise(w=>{v=w}),e.prebuiltStageDir?d&&Cp(r,{onFirstBuild:v}):zp(r,{onFirstBuild:v})}let h=[];if(s&&h.push(Yc("design")),a){let v=(await Promise.resolve().then(()=>(eA(),QO))).default,w=(await Promise.resolve().then(()=>(rA(),tA))).default;h.push(v,w)}if(c){let v=(await Promise.resolve().then(()=>(oA(),nA))).default;h.push(v)}if(s){let v=c?()=>r.libraries.getEntries().map(w=>w.type==="remote"?w.url:`/libraries/${w.path.split("/").pop()}`):void 0;h.push(Oi(Jc,{stylesheets:v}))}else h.push(Oi(Jc));r.server.use(...h);let m={"access-control-allow-origin":"*","access-control-allow-methods":"GET, POST, PUT, DELETE, OPTIONS","access-control-allow-headers":"content-type, authorization"};r.server.hooks({onRequest:({req:v,respond:w})=>{if(v.method==="OPTIONS")return w.text("",204,m)},onSend:(v,w)=>{w&&(w.headers={...m,...w.headers})}}),await r.server.listen(),await r.socket.start(),c&&await r.libraries.load(),await r.staticAssets.watch();let{ledger:g,tombstones:_,...x}=await r.cas.load();if(r.state.ledger.hydrate({state:x,ledger:g,tombstones:_}),await r.storeParser.start(),s&&d){await r.esBuild.watch();let v=await p;if(v.errors.length)throw new Error(`Stage bundle failed to build:
172
- ${v.errors.join(`
173
- `)}`)}return r.socket.use(jR,MR,LR),a&&r.socket.use(UR,qR,BR),r.socket.onConnection(async v=>{let w=r.cache.get(["connections"]);w.add(v);let b=iA[o%iA.length];o++;let S={name:`User ${w.size}`,color:b,position:{x:0,y:0},selection:[]};if(n[v.id]=S,v.publish("design:load",r.state.ledger.snapshot()),Object.keys(n).length>1&&v.publish("presence:snapshot",n),v.broadcast("presence:join",v.id,S),a){let T=await r.aiHistory.listSessions();v.publish("ai:sessions:list",T)}t.info("socket connected",{id:v.id})}),r.socket.onDisconnection(v=>{VR(v.id);let w=r.cache.get(["connections"]),b=v.id;delete n[b],w.delete(v),r.socket.broadcast("presence:leave",b),t.info("socket disconnected",{id:b})}),r.socket.onError(v=>t.error("socket error",{error:v?.message??v})),{basePath:`http://localhost:${r.server.getHttpServer().address().port}`,view:e.view||"design",env:e.env||"dev",nodeId:null,name:e.name||null,engine:r}}catch(n){t.error("design server failed",{error:n.message,stack:n.stack});try{await r?.server?.stop()}catch{}return F5.failure(n)}}var iA,cA=f(()=>{xx();oi();Id();wx();u_();p_();f_();h_();y_();x_();__();Ud();qd();DR();ZR();FR();Mp();HR();GR();iA=["#3B82F6","#EF4444","#10B981","#8B5CF6","#EC4899","#F97316","#06B6D4","#6366F1"];i(W5,"createDesignServer")});var Ml=D(me=>{"use strict";Object.defineProperty(me,"__esModule",{value:!0});me.regexpCode=me.getEsmExportName=me.getProperty=me.safeStringify=me.stringify=me.strConcat=me.addCodeArg=me.str=me._=me.nil=me._Code=me.Name=me.IDENTIFIER=me._CodeOrName=void 0;var t0=class t0{};i(t0,"_CodeOrName");var jl=t0;me._CodeOrName=jl;me.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;var r0=class r0 extends jl{constructor(t){if(super(),!me.IDENTIFIER.test(t))throw new Error("CodeGen: name must be a valid identifier");this.str=t}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}};i(r0,"Name");var _s=r0;me.Name=_s;var n0=class n0 extends jl{constructor(t){super(),this._items=typeof t=="string"?[t]:t}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;let t=this._items[0];return t===""||t==='""'}get str(){var t;return(t=this._str)!==null&&t!==void 0?t:this._str=this._items.reduce((r,n)=>`${r}${n}`,"")}get names(){var t;return(t=this._names)!==null&&t!==void 0?t:this._names=this._items.reduce((r,n)=>(n instanceof _s&&(r[n.str]=(r[n.str]||0)+1),r),{})}};i(n0,"_Code");var ir=n0;me._Code=ir;me.nil=new ir("");function sM(e,...t){let r=[e[0]],n=0;for(;n<t.length;)e0(r,t[n]),r.push(e[++n]);return new ir(r)}i(sM,"_");me._=sM;var Qb=new ir("+");function iM(e,...t){let r=[Dl(e[0])],n=0;for(;n<t.length;)r.push(Qb),e0(r,t[n]),r.push(Qb,Dl(e[++n]));return QK(r),new ir(r)}i(iM,"str");me.str=iM;function e0(e,t){t instanceof ir?e.push(...t._items):t instanceof _s?e.push(t):e.push(rJ(t))}i(e0,"addCodeArg");me.addCodeArg=e0;function QK(e){let t=1;for(;t<e.length-1;){if(e[t]===Qb){let r=eJ(e[t-1],e[t+1]);if(r!==void 0){e.splice(t-1,3,r);continue}e[t++]="+"}t++}}i(QK,"optimize");function eJ(e,t){if(t==='""')return e;if(e==='""')return t;if(typeof e=="string")return t instanceof _s||e[e.length-1]!=='"'?void 0:typeof t!="string"?`${e.slice(0,-1)}${t}"`:t[0]==='"'?e.slice(0,-1)+t.slice(1):void 0;if(typeof t=="string"&&t[0]==='"'&&!(e instanceof _s))return`"${e}${t.slice(1)}`}i(eJ,"mergeExprItems");function tJ(e,t){return t.emptyStr()?e:e.emptyStr()?t:iM`${e}${t}`}i(tJ,"strConcat");me.strConcat=tJ;function rJ(e){return typeof e=="number"||typeof e=="boolean"||e===null?e:Dl(Array.isArray(e)?e.join(","):e)}i(rJ,"interpolate");function nJ(e){return new ir(Dl(e))}i(nJ,"stringify");me.stringify=nJ;function Dl(e){return JSON.stringify(e).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}i(Dl,"safeStringify");me.safeStringify=Dl;function oJ(e){return typeof e=="string"&&me.IDENTIFIER.test(e)?new ir(`.${e}`):sM`[${e}]`}i(oJ,"getProperty");me.getProperty=oJ;function sJ(e){if(typeof e=="string"&&me.IDENTIFIER.test(e))return new ir(`${e}`);throw new Error(`CodeGen: invalid export name: ${e}, use explicit $id name mapping`)}i(sJ,"getEsmExportName");me.getEsmExportName=sJ;function iJ(e){return new ir(e.toString())}i(iJ,"regexpCode");me.regexpCode=iJ});var u0=D(Tt=>{"use strict";Object.defineProperty(Tt,"__esModule",{value:!0});Tt.ValueScope=Tt.ValueScopeName=Tt.Scope=Tt.varKinds=Tt.UsedValueState=void 0;var Nt=Ml(),i0=class i0 extends Error{constructor(t){super(`CodeGen: "code" for ${t} not defined`),this.value=t.value}};i(i0,"ValueError");var o0=i0,wm;(function(e){e[e.Started=0]="Started",e[e.Completed=1]="Completed"})(wm||(Tt.UsedValueState=wm={}));Tt.varKinds={const:new Nt.Name("const"),let:new Nt.Name("let"),var:new Nt.Name("var")};var a0=class a0{constructor({prefixes:t,parent:r}={}){this._names={},this._prefixes=t,this._parent=r}toName(t){return t instanceof Nt.Name?t:this.name(t)}name(t){return new Nt.Name(this._newName(t))}_newName(t){let r=this._names[t]||this._nameGroup(t);return`${t}${r.index++}`}_nameGroup(t){var r,n;if(!((n=(r=this._parent)===null||r===void 0?void 0:r._prefixes)===null||n===void 0)&&n.has(t)||this._prefixes&&!this._prefixes.has(t))throw new Error(`CodeGen: prefix "${t}" is not allowed in this scope`);return this._names[t]={prefix:t,index:0}}};i(a0,"Scope");var bm=a0;Tt.Scope=bm;var c0=class c0 extends Nt.Name{constructor(t,r){super(r),this.prefix=t}setValue(t,{property:r,itemIndex:n}){this.value=t,this.scopePath=(0,Nt._)`.${new Nt.Name(r)}[${n}]`}};i(c0,"ValueScopeName");var Sm=c0;Tt.ValueScopeName=Sm;var aJ=(0,Nt._)`\n`,l0=class l0 extends bm{constructor(t){super(t),this._values={},this._scope=t.scope,this.opts={...t,_n:t.lines?aJ:Nt.nil}}get(){return this._scope}name(t){return new Sm(t,this._newName(t))}value(t,r){var n;if(r.ref===void 0)throw new Error("CodeGen: ref must be passed in value");let o=this.toName(t),{prefix:s}=o,a=(n=r.key)!==null&&n!==void 0?n:r.ref,c=this._values[s];if(c){let d=c.get(a);if(d)return d}else c=this._values[s]=new Map;c.set(a,o);let l=this._scope[s]||(this._scope[s]=[]),u=l.length;return l[u]=r.ref,o.setValue(r,{property:s,itemIndex:u}),o}getValue(t,r){let n=this._values[t];if(n)return n.get(r)}scopeRefs(t,r=this._values){return this._reduceValues(r,n=>{if(n.scopePath===void 0)throw new Error(`CodeGen: name "${n}" has no value`);return(0,Nt._)`${t}${n.scopePath}`})}scopeCode(t=this._values,r,n){return this._reduceValues(t,o=>{if(o.value===void 0)throw new Error(`CodeGen: name "${o}" has no value`);return o.value.code},r,n)}_reduceValues(t,r,n={},o){let s=Nt.nil;for(let a in t){let c=t[a];if(!c)continue;let l=n[a]=n[a]||new Map;c.forEach(u=>{if(l.has(u))return;l.set(u,wm.Started);let d=r(u);if(d){let p=this.opts.es5?Tt.varKinds.var:Tt.varKinds.const;s=(0,Nt._)`${s}${p} ${u} = ${d};${this.opts._n}`}else if(d=o?.(u))s=(0,Nt._)`${s}${d}${this.opts._n}`;else throw new o0(u);l.set(u,wm.Completed)})}return s}};i(l0,"ValueScope");var s0=l0;Tt.ValueScope=s0});var ne=D(oe=>{"use strict";Object.defineProperty(oe,"__esModule",{value:!0});oe.or=oe.and=oe.not=oe.CodeGen=oe.operators=oe.varKinds=oe.ValueScopeName=oe.ValueScope=oe.Scope=oe.Name=oe.regexpCode=oe.stringify=oe.getProperty=oe.nil=oe.strConcat=oe.str=oe._=void 0;var de=Ml(),Sr=u0(),to=Ml();Object.defineProperty(oe,"_",{enumerable:!0,get:function(){return to._}});Object.defineProperty(oe,"str",{enumerable:!0,get:function(){return to.str}});Object.defineProperty(oe,"strConcat",{enumerable:!0,get:function(){return to.strConcat}});Object.defineProperty(oe,"nil",{enumerable:!0,get:function(){return to.nil}});Object.defineProperty(oe,"getProperty",{enumerable:!0,get:function(){return to.getProperty}});Object.defineProperty(oe,"stringify",{enumerable:!0,get:function(){return to.stringify}});Object.defineProperty(oe,"regexpCode",{enumerable:!0,get:function(){return to.regexpCode}});Object.defineProperty(oe,"Name",{enumerable:!0,get:function(){return to.Name}});var Nm=u0();Object.defineProperty(oe,"Scope",{enumerable:!0,get:function(){return Nm.Scope}});Object.defineProperty(oe,"ValueScope",{enumerable:!0,get:function(){return Nm.ValueScope}});Object.defineProperty(oe,"ValueScopeName",{enumerable:!0,get:function(){return Nm.ValueScopeName}});Object.defineProperty(oe,"varKinds",{enumerable:!0,get:function(){return Nm.varKinds}});oe.operators={GT:new de._Code(">"),GTE:new de._Code(">="),LT:new de._Code("<"),LTE:new de._Code("<="),EQ:new de._Code("==="),NEQ:new de._Code("!=="),NOT:new de._Code("!"),OR:new de._Code("||"),AND:new de._Code("&&"),ADD:new de._Code("+")};var S0=class S0{optimizeNodes(){return this}optimizeNames(t,r){return this}};i(S0,"Node");var Nn=S0,k0=class k0 extends Nn{constructor(t,r,n){super(),this.varKind=t,this.name=r,this.rhs=n}render({es5:t,_n:r}){let n=t?Sr.varKinds.var:this.varKind,o=this.rhs===void 0?"":` = ${this.rhs}`;return`${n} ${this.name}${o};`+r}optimizeNames(t,r){if(t[this.name.str])return this.rhs&&(this.rhs=da(this.rhs,t,r)),this}get names(){return this.rhs instanceof de._CodeOrName?this.rhs.names:{}}};i(k0,"Def");var d0=k0,$0=class $0 extends Nn{constructor(t,r,n){super(),this.lhs=t,this.rhs=r,this.sideEffects=n}render({_n:t}){return`${this.lhs} = ${this.rhs};`+t}optimizeNames(t,r){if(!(this.lhs instanceof de.Name&&!t[this.lhs.str]&&!this.sideEffects))return this.rhs=da(this.rhs,t,r),this}get names(){let t=this.lhs instanceof de.Name?{}:{...this.lhs.names};return Em(t,this.rhs)}};i($0,"Assign");var km=$0,E0=class E0 extends km{constructor(t,r,n,o){super(t,n,o),this.op=r}render({_n:t}){return`${this.lhs} ${this.op}= ${this.rhs};`+t}};i(E0,"AssignOp");var p0=E0,N0=class N0 extends Nn{constructor(t){super(),this.label=t,this.names={}}render({_n:t}){return`${this.label}:`+t}};i(N0,"Label");var f0=N0,T0=class T0 extends Nn{constructor(t){super(),this.label=t,this.names={}}render({_n:t}){return`break${this.label?` ${this.label}`:""};`+t}};i(T0,"Break");var m0=T0,z0=class z0 extends Nn{constructor(t){super(),this.error=t}render({_n:t}){return`throw ${this.error};`+t}get names(){return this.error.names}};i(z0,"Throw");var h0=z0,C0=class C0 extends Nn{constructor(t){super(),this.code=t}render({_n:t}){return`${this.code};`+t}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(t,r){return this.code=da(this.code,t,r),this}get names(){return this.code instanceof de._CodeOrName?this.code.names:{}}};i(C0,"AnyCode");var g0=C0,I0=class I0 extends Nn{constructor(t=[]){super(),this.nodes=t}render(t){return this.nodes.reduce((r,n)=>r+n.render(t),"")}optimizeNodes(){let{nodes:t}=this,r=t.length;for(;r--;){let n=t[r].optimizeNodes();Array.isArray(n)?t.splice(r,1,...n):n?t[r]=n:t.splice(r,1)}return t.length>0?this:void 0}optimizeNames(t,r){let{nodes:n}=this,o=n.length;for(;o--;){let s=n[o];s.optimizeNames(t,r)||(cJ(t,s.names),n.splice(o,1))}return n.length>0?this:void 0}get names(){return this.nodes.reduce((t,r)=>bs(t,r.names),{})}};i(I0,"ParentNode");var Zl=I0,P0=class P0 extends Zl{render(t){return"{"+t._n+super.render(t)+"}"+t._n}};i(P0,"BlockNode");var Tn=P0,R0=class R0 extends Zl{};i(R0,"Root");var y0=R0,O0=class O0 extends Tn{};i(O0,"Else");var ua=O0;ua.kind="else";var la=class la extends Tn{constructor(t,r){super(r),this.condition=t}render(t){let r=`if(${this.condition})`+super.render(t);return this.else&&(r+="else "+this.else.render(t)),r}optimizeNodes(){super.optimizeNodes();let t=this.condition;if(t===!0)return this.nodes;let r=this.else;if(r){let n=r.optimizeNodes();r=this.else=Array.isArray(n)?new ua(n):n}if(r)return t===!1?r instanceof la?r:r.nodes:this.nodes.length?this:new la(aM(t),r instanceof la?[r]:r.nodes);if(!(t===!1||!this.nodes.length))return this}optimizeNames(t,r){var n;if(this.else=(n=this.else)===null||n===void 0?void 0:n.optimizeNames(t,r),!!(super.optimizeNames(t,r)||this.else))return this.condition=da(this.condition,t,r),this}get names(){let t=super.names;return Em(t,this.condition),this.else&&bs(t,this.else.names),t}};i(la,"If");var vs=la;vs.kind="if";var A0=class A0 extends Tn{};i(A0,"For");var ws=A0;ws.kind="for";var j0=class j0 extends ws{constructor(t){super(),this.iteration=t}render(t){return`for(${this.iteration})`+super.render(t)}optimizeNames(t,r){if(super.optimizeNames(t,r))return this.iteration=da(this.iteration,t,r),this}get names(){return bs(super.names,this.iteration.names)}};i(j0,"ForLoop");var x0=j0,D0=class D0 extends ws{constructor(t,r,n,o){super(),this.varKind=t,this.name=r,this.from=n,this.to=o}render(t){let r=t.es5?Sr.varKinds.var:this.varKind,{name:n,from:o,to:s}=this;return`for(${r} ${n}=${o}; ${n}<${s}; ${n}++)`+super.render(t)}get names(){let t=Em(super.names,this.from);return Em(t,this.to)}};i(D0,"ForRange");var _0=D0,M0=class M0 extends ws{constructor(t,r,n,o){super(),this.loop=t,this.varKind=r,this.name=n,this.iterable=o}render(t){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(t)}optimizeNames(t,r){if(super.optimizeNames(t,r))return this.iterable=da(this.iterable,t,r),this}get names(){return bs(super.names,this.iterable.names)}};i(M0,"ForIter");var $m=M0,Z0=class Z0 extends Tn{constructor(t,r,n){super(),this.name=t,this.args=r,this.async=n}render(t){return`${this.async?"async ":""}function ${this.name}(${this.args})`+super.render(t)}};i(Z0,"Func");var Ll=Z0;Ll.kind="func";var L0=class L0 extends Zl{render(t){return"return "+super.render(t)}};i(L0,"Return");var Fl=L0;Fl.kind="return";var F0=class F0 extends Tn{render(t){let r="try"+super.render(t);return this.catch&&(r+=this.catch.render(t)),this.finally&&(r+=this.finally.render(t)),r}optimizeNodes(){var t,r;return super.optimizeNodes(),(t=this.catch)===null||t===void 0||t.optimizeNodes(),(r=this.finally)===null||r===void 0||r.optimizeNodes(),this}optimizeNames(t,r){var n,o;return super.optimizeNames(t,r),(n=this.catch)===null||n===void 0||n.optimizeNames(t,r),(o=this.finally)===null||o===void 0||o.optimizeNames(t,r),this}get names(){let t=super.names;return this.catch&&bs(t,this.catch.names),this.finally&&bs(t,this.finally.names),t}};i(F0,"Try");var v0=F0,U0=class U0 extends Tn{constructor(t){super(),this.error=t}render(t){return`catch(${this.error})`+super.render(t)}};i(U0,"Catch");var Ul=U0;Ul.kind="catch";var q0=class q0 extends Tn{render(t){return"finally"+super.render(t)}};i(q0,"Finally");var ql=q0;ql.kind="finally";var H0=class H0{constructor(t,r={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...r,_n:r.lines?`
174
- `:""},this._extScope=t,this._scope=new Sr.Scope({parent:t}),this._nodes=[new y0]}toString(){return this._root.render(this.opts)}name(t){return this._scope.name(t)}scopeName(t){return this._extScope.name(t)}scopeValue(t,r){let n=this._extScope.value(t,r);return(this._values[n.prefix]||(this._values[n.prefix]=new Set)).add(n),n}getScopeValue(t,r){return this._extScope.getValue(t,r)}scopeRefs(t){return this._extScope.scopeRefs(t,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def(t,r,n,o){let s=this._scope.toName(r);return n!==void 0&&o&&(this._constants[s.str]=n),this._leafNode(new d0(t,s,n)),s}const(t,r,n){return this._def(Sr.varKinds.const,t,r,n)}let(t,r,n){return this._def(Sr.varKinds.let,t,r,n)}var(t,r,n){return this._def(Sr.varKinds.var,t,r,n)}assign(t,r,n){return this._leafNode(new km(t,r,n))}add(t,r){return this._leafNode(new p0(t,oe.operators.ADD,r))}code(t){return typeof t=="function"?t():t!==de.nil&&this._leafNode(new g0(t)),this}object(...t){let r=["{"];for(let[n,o]of t)r.length>1&&r.push(","),r.push(n),(n!==o||this.opts.es5)&&(r.push(":"),(0,de.addCodeArg)(r,o));return r.push("}"),new de._Code(r)}if(t,r,n){if(this._blockNode(new vs(t)),r&&n)this.code(r).else().code(n).endIf();else if(r)this.code(r).endIf();else if(n)throw new Error('CodeGen: "else" body without "then" body');return this}elseIf(t){return this._elseNode(new vs(t))}else(){return this._elseNode(new ua)}endIf(){return this._endBlockNode(vs,ua)}_for(t,r){return this._blockNode(t),r&&this.code(r).endFor(),this}for(t,r){return this._for(new x0(t),r)}forRange(t,r,n,o,s=this.opts.es5?Sr.varKinds.var:Sr.varKinds.let){let a=this._scope.toName(t);return this._for(new _0(s,a,r,n),()=>o(a))}forOf(t,r,n,o=Sr.varKinds.const){let s=this._scope.toName(t);if(this.opts.es5){let a=r instanceof de.Name?r:this.var("_arr",r);return this.forRange("_i",0,(0,de._)`${a}.length`,c=>{this.var(s,(0,de._)`${a}[${c}]`),n(s)})}return this._for(new $m("of",o,s,r),()=>n(s))}forIn(t,r,n,o=this.opts.es5?Sr.varKinds.var:Sr.varKinds.const){if(this.opts.ownProperties)return this.forOf(t,(0,de._)`Object.keys(${r})`,n);let s=this._scope.toName(t);return this._for(new $m("in",o,s,r),()=>n(s))}endFor(){return this._endBlockNode(ws)}label(t){return this._leafNode(new f0(t))}break(t){return this._leafNode(new m0(t))}return(t){let r=new Fl;if(this._blockNode(r),this.code(t),r.nodes.length!==1)throw new Error('CodeGen: "return" should have one node');return this._endBlockNode(Fl)}try(t,r,n){if(!r&&!n)throw new Error('CodeGen: "try" without "catch" and "finally"');let o=new v0;if(this._blockNode(o),this.code(t),r){let s=this.name("e");this._currNode=o.catch=new Ul(s),r(s)}return n&&(this._currNode=o.finally=new ql,this.code(n)),this._endBlockNode(Ul,ql)}throw(t){return this._leafNode(new h0(t))}block(t,r){return this._blockStarts.push(this._nodes.length),t&&this.code(t).endBlock(r),this}endBlock(t){let r=this._blockStarts.pop();if(r===void 0)throw new Error("CodeGen: not in self-balancing block");let n=this._nodes.length-r;if(n<0||t!==void 0&&n!==t)throw new Error(`CodeGen: wrong number of nodes: ${n} vs ${t} expected`);return this._nodes.length=r,this}func(t,r=de.nil,n,o){return this._blockNode(new Ll(t,r,n)),o&&this.code(o).endFunc(),this}endFunc(){return this._endBlockNode(Ll)}optimize(t=1){for(;t-- >0;)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants)}_leafNode(t){return this._currNode.nodes.push(t),this}_blockNode(t){this._currNode.nodes.push(t),this._nodes.push(t)}_endBlockNode(t,r){let n=this._currNode;if(n instanceof t||r&&n instanceof r)return this._nodes.pop(),this;throw new Error(`CodeGen: not in block "${r?`${t.kind}/${r.kind}`:t.kind}"`)}_elseNode(t){let r=this._currNode;if(!(r instanceof vs))throw new Error('CodeGen: "else" without "if"');return this._currNode=r.else=t,this}get _root(){return this._nodes[0]}get _currNode(){let t=this._nodes;return t[t.length-1]}set _currNode(t){let r=this._nodes;r[r.length-1]=t}};i(H0,"CodeGen");var w0=H0;oe.CodeGen=w0;function bs(e,t){for(let r in t)e[r]=(e[r]||0)+(t[r]||0);return e}i(bs,"addNames");function Em(e,t){return t instanceof de._CodeOrName?bs(e,t.names):e}i(Em,"addExprNames");function da(e,t,r){if(e instanceof de.Name)return n(e);if(!o(e))return e;return new de._Code(e._items.reduce((s,a)=>(a instanceof de.Name&&(a=n(a)),a instanceof de._Code?s.push(...a._items):s.push(a),s),[]));function n(s){let a=r[s.str];return a===void 0||t[s.str]!==1?s:(delete t[s.str],a)}function o(s){return s instanceof de._Code&&s._items.some(a=>a instanceof de.Name&&t[a.str]===1&&r[a.str]!==void 0)}}i(da,"optimizeExpr");function cJ(e,t){for(let r in t)e[r]=(e[r]||0)-(t[r]||0)}i(cJ,"subtractNames");function aM(e){return typeof e=="boolean"||typeof e=="number"||e===null?!e:(0,de._)`!${b0(e)}`}i(aM,"not");oe.not=aM;var lJ=cM(oe.operators.AND);function uJ(...e){return e.reduce(lJ)}i(uJ,"and");oe.and=uJ;var dJ=cM(oe.operators.OR);function pJ(...e){return e.reduce(dJ)}i(pJ,"or");oe.or=pJ;function cM(e){return(t,r)=>t===de.nil?r:r===de.nil?t:(0,de._)`${b0(t)} ${e} ${b0(r)}`}i(cM,"mappend");function b0(e){return e instanceof de.Name?e:(0,de._)`(${e})`}i(b0,"par")});var pe=D(ie=>{"use strict";Object.defineProperty(ie,"__esModule",{value:!0});ie.checkStrictMode=ie.getErrorPath=ie.Type=ie.useFunc=ie.setEvaluated=ie.evaluatedPropsToName=ie.mergeEvaluated=ie.eachItem=ie.unescapeJsonPointer=ie.escapeJsonPointer=ie.escapeFragment=ie.unescapeFragment=ie.schemaRefOrVal=ie.schemaHasRulesButRef=ie.schemaHasRules=ie.checkUnknownRules=ie.alwaysValidSchema=ie.toHash=void 0;var we=ne(),fJ=Ml();function mJ(e){let t={};for(let r of e)t[r]=!0;return t}i(mJ,"toHash");ie.toHash=mJ;function hJ(e,t){return typeof t=="boolean"?t:Object.keys(t).length===0?!0:(dM(e,t),!pM(t,e.self.RULES.all))}i(hJ,"alwaysValidSchema");ie.alwaysValidSchema=hJ;function dM(e,t=e.schema){let{opts:r,self:n}=e;if(!r.strictSchema||typeof t=="boolean")return;let o=n.RULES.keywords;for(let s in t)o[s]||hM(e,`unknown keyword: "${s}"`)}i(dM,"checkUnknownRules");ie.checkUnknownRules=dM;function pM(e,t){if(typeof e=="boolean")return!e;for(let r in e)if(t[r])return!0;return!1}i(pM,"schemaHasRules");ie.schemaHasRules=pM;function gJ(e,t){if(typeof e=="boolean")return!e;for(let r in e)if(r!=="$ref"&&t.all[r])return!0;return!1}i(gJ,"schemaHasRulesButRef");ie.schemaHasRulesButRef=gJ;function yJ({topSchemaRef:e,schemaPath:t},r,n,o){if(!o){if(typeof r=="number"||typeof r=="boolean")return r;if(typeof r=="string")return(0,we._)`${r}`}return(0,we._)`${e}${t}${(0,we.getProperty)(n)}`}i(yJ,"schemaRefOrVal");ie.schemaRefOrVal=yJ;function xJ(e){return fM(decodeURIComponent(e))}i(xJ,"unescapeFragment");ie.unescapeFragment=xJ;function _J(e){return encodeURIComponent(V0(e))}i(_J,"escapeFragment");ie.escapeFragment=_J;function V0(e){return typeof e=="number"?`${e}`:e.replace(/~/g,"~0").replace(/\//g,"~1")}i(V0,"escapeJsonPointer");ie.escapeJsonPointer=V0;function fM(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}i(fM,"unescapeJsonPointer");ie.unescapeJsonPointer=fM;function vJ(e,t){if(Array.isArray(e))for(let r of e)t(r);else t(e)}i(vJ,"eachItem");ie.eachItem=vJ;function lM({mergeNames:e,mergeToName:t,mergeValues:r,resultToName:n}){return(o,s,a,c)=>{let l=a===void 0?s:a instanceof we.Name?(s instanceof we.Name?e(o,s,a):t(o,s,a),a):s instanceof we.Name?(t(o,a,s),s):r(s,a);return c===we.Name&&!(l instanceof we.Name)?n(o,l):l}}i(lM,"makeMergeEvaluated");ie.mergeEvaluated={props:lM({mergeNames:(e,t,r)=>e.if((0,we._)`${r} !== true && ${t} !== undefined`,()=>{e.if((0,we._)`${t} === true`,()=>e.assign(r,!0),()=>e.assign(r,(0,we._)`${r} || {}`).code((0,we._)`Object.assign(${r}, ${t})`))}),mergeToName:(e,t,r)=>e.if((0,we._)`${r} !== true`,()=>{t===!0?e.assign(r,!0):(e.assign(r,(0,we._)`${r} || {}`),G0(e,r,t))}),mergeValues:(e,t)=>e===!0?!0:{...e,...t},resultToName:mM}),items:lM({mergeNames:(e,t,r)=>e.if((0,we._)`${r} !== true && ${t} !== undefined`,()=>e.assign(r,(0,we._)`${t} === true ? true : ${r} > ${t} ? ${r} : ${t}`)),mergeToName:(e,t,r)=>e.if((0,we._)`${r} !== true`,()=>e.assign(r,t===!0?!0:(0,we._)`${r} > ${t} ? ${r} : ${t}`)),mergeValues:(e,t)=>e===!0?!0:Math.max(e,t),resultToName:(e,t)=>e.var("items",t)})};function mM(e,t){if(t===!0)return e.var("props",!0);let r=e.var("props",(0,we._)`{}`);return t!==void 0&&G0(e,r,t),r}i(mM,"evaluatedPropsToName");ie.evaluatedPropsToName=mM;function G0(e,t,r){Object.keys(r).forEach(n=>e.assign((0,we._)`${t}${(0,we.getProperty)(n)}`,!0))}i(G0,"setEvaluated");ie.setEvaluated=G0;var uM={};function wJ(e,t){return e.scopeValue("func",{ref:t,code:uM[t.code]||(uM[t.code]=new fJ._Code(t.code))})}i(wJ,"useFunc");ie.useFunc=wJ;var B0;(function(e){e[e.Num=0]="Num",e[e.Str=1]="Str"})(B0||(ie.Type=B0={}));function bJ(e,t,r){if(e instanceof we.Name){let n=t===B0.Num;return r?n?(0,we._)`"[" + ${e} + "]"`:(0,we._)`"['" + ${e} + "']"`:n?(0,we._)`"/" + ${e}`:(0,we._)`"/" + ${e}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return r?(0,we.getProperty)(e).toString():"/"+V0(e)}i(bJ,"getErrorPath");ie.getErrorPath=bJ;function hM(e,t,r=e.opts.strictSchema){if(r){if(t=`strict mode: ${t}`,r===!0)throw new Error(t);e.self.logger.warn(t)}}i(hM,"checkStrictMode");ie.checkStrictMode=hM});var zn=D(W0=>{"use strict";Object.defineProperty(W0,"__esModule",{value:!0});var ct=ne(),SJ={data:new ct.Name("data"),valCxt:new ct.Name("valCxt"),instancePath:new ct.Name("instancePath"),parentData:new ct.Name("parentData"),parentDataProperty:new ct.Name("parentDataProperty"),rootData:new ct.Name("rootData"),dynamicAnchors:new ct.Name("dynamicAnchors"),vErrors:new ct.Name("vErrors"),errors:new ct.Name("errors"),this:new ct.Name("this"),self:new ct.Name("self"),scope:new ct.Name("scope"),json:new ct.Name("json"),jsonPos:new ct.Name("jsonPos"),jsonLen:new ct.Name("jsonLen"),jsonPart:new ct.Name("jsonPart")};W0.default=SJ});var Hl=D(lt=>{"use strict";Object.defineProperty(lt,"__esModule",{value:!0});lt.extendErrors=lt.resetErrorsCount=lt.reportExtraError=lt.reportError=lt.keyword$DataError=lt.keywordError=void 0;var fe=ne(),Tm=pe(),yt=zn();lt.keywordError={message:({keyword:e})=>(0,fe.str)`must pass "${e}" keyword validation`};lt.keyword$DataError={message:({keyword:e,schemaType:t})=>t?(0,fe.str)`"${e}" keyword must be ${t} ($data)`:(0,fe.str)`"${e}" keyword is invalid ($data)`};function kJ(e,t=lt.keywordError,r,n){let{it:o}=e,{gen:s,compositeRule:a,allErrors:c}=o,l=xM(e,t,r);n??(a||c)?gM(s,l):yM(o,(0,fe._)`[${l}]`)}i(kJ,"reportError");lt.reportError=kJ;function $J(e,t=lt.keywordError,r){let{it:n}=e,{gen:o,compositeRule:s,allErrors:a}=n,c=xM(e,t,r);gM(o,c),s||a||yM(n,yt.default.vErrors)}i($J,"reportExtraError");lt.reportExtraError=$J;function EJ(e,t){e.assign(yt.default.errors,t),e.if((0,fe._)`${yt.default.vErrors} !== null`,()=>e.if(t,()=>e.assign((0,fe._)`${yt.default.vErrors}.length`,t),()=>e.assign(yt.default.vErrors,null)))}i(EJ,"resetErrorsCount");lt.resetErrorsCount=EJ;function NJ({gen:e,keyword:t,schemaValue:r,data:n,errsCount:o,it:s}){if(o===void 0)throw new Error("ajv implementation error");let a=e.name("err");e.forRange("i",o,yt.default.errors,c=>{e.const(a,(0,fe._)`${yt.default.vErrors}[${c}]`),e.if((0,fe._)`${a}.instancePath === undefined`,()=>e.assign((0,fe._)`${a}.instancePath`,(0,fe.strConcat)(yt.default.instancePath,s.errorPath))),e.assign((0,fe._)`${a}.schemaPath`,(0,fe.str)`${s.errSchemaPath}/${t}`),s.opts.verbose&&(e.assign((0,fe._)`${a}.schema`,r),e.assign((0,fe._)`${a}.data`,n))})}i(NJ,"extendErrors");lt.extendErrors=NJ;function gM(e,t){let r=e.const("err",t);e.if((0,fe._)`${yt.default.vErrors} === null`,()=>e.assign(yt.default.vErrors,(0,fe._)`[${r}]`),(0,fe._)`${yt.default.vErrors}.push(${r})`),e.code((0,fe._)`${yt.default.errors}++`)}i(gM,"addError");function yM(e,t){let{gen:r,validateName:n,schemaEnv:o}=e;o.$async?r.throw((0,fe._)`new ${e.ValidationError}(${t})`):(r.assign((0,fe._)`${n}.errors`,t),r.return(!1))}i(yM,"returnErrors");var Ss={keyword:new fe.Name("keyword"),schemaPath:new fe.Name("schemaPath"),params:new fe.Name("params"),propertyName:new fe.Name("propertyName"),message:new fe.Name("message"),schema:new fe.Name("schema"),parentSchema:new fe.Name("parentSchema")};function xM(e,t,r){let{createErrors:n}=e.it;return n===!1?(0,fe._)`{}`:TJ(e,t,r)}i(xM,"errorObjectCode");function TJ(e,t,r={}){let{gen:n,it:o}=e,s=[zJ(o,r),CJ(e,r)];return IJ(e,t,s),n.object(...s)}i(TJ,"errorObject");function zJ({errorPath:e},{instancePath:t}){let r=t?(0,fe.str)`${e}${(0,Tm.getErrorPath)(t,Tm.Type.Str)}`:e;return[yt.default.instancePath,(0,fe.strConcat)(yt.default.instancePath,r)]}i(zJ,"errorInstancePath");function CJ({keyword:e,it:{errSchemaPath:t}},{schemaPath:r,parentSchema:n}){let o=n?t:(0,fe.str)`${t}/${e}`;return r&&(o=(0,fe.str)`${o}${(0,Tm.getErrorPath)(r,Tm.Type.Str)}`),[Ss.schemaPath,o]}i(CJ,"errorSchemaPath");function IJ(e,{params:t,message:r},n){let{keyword:o,data:s,schemaValue:a,it:c}=e,{opts:l,propertyName:u,topSchemaRef:d,schemaPath:p}=c;n.push([Ss.keyword,o],[Ss.params,typeof t=="function"?t(e):t||(0,fe._)`{}`]),l.messages&&n.push([Ss.message,typeof r=="function"?r(e):r]),l.verbose&&n.push([Ss.schema,a],[Ss.parentSchema,(0,fe._)`${d}${p}`],[yt.default.data,s]),u&&n.push([Ss.propertyName,u])}i(IJ,"extraErrorProps")});var vM=D(pa=>{"use strict";Object.defineProperty(pa,"__esModule",{value:!0});pa.boolOrEmptySchema=pa.topBoolOrEmptySchema=void 0;var PJ=Hl(),RJ=ne(),OJ=zn(),AJ={message:"boolean schema is false"};function jJ(e){let{gen:t,schema:r,validateName:n}=e;r===!1?_M(e,!1):typeof r=="object"&&r.$async===!0?t.return(OJ.default.data):(t.assign((0,RJ._)`${n}.errors`,null),t.return(!0))}i(jJ,"topBoolOrEmptySchema");pa.topBoolOrEmptySchema=jJ;function DJ(e,t){let{gen:r,schema:n}=e;n===!1?(r.var(t,!1),_M(e)):r.var(t,!0)}i(DJ,"boolOrEmptySchema");pa.boolOrEmptySchema=DJ;function _M(e,t){let{gen:r,data:n}=e,o={gen:r,keyword:"false schema",data:n,schema:!1,schemaCode:!1,schemaValue:!1,params:{},it:e};(0,PJ.reportError)(o,AJ,void 0,t)}i(_M,"falseSchemaError")});var K0=D(fa=>{"use strict";Object.defineProperty(fa,"__esModule",{value:!0});fa.getRules=fa.isJSONType=void 0;var MJ=["string","number","integer","boolean","null","object","array"],ZJ=new Set(MJ);function LJ(e){return typeof e=="string"&&ZJ.has(e)}i(LJ,"isJSONType");fa.isJSONType=LJ;function FJ(){let e={number:{type:"number",rules:[]},string:{type:"string",rules:[]},array:{type:"array",rules:[]},object:{type:"object",rules:[]}};return{types:{...e,integer:!0,boolean:!0,null:!0},rules:[{rules:[]},e.number,e.string,e.array,e.object],post:{rules:[]},all:{},keywords:{}}}i(FJ,"getRules");fa.getRules=FJ});var J0=D(ro=>{"use strict";Object.defineProperty(ro,"__esModule",{value:!0});ro.shouldUseRule=ro.shouldUseGroup=ro.schemaHasRulesForType=void 0;function UJ({schema:e,self:t},r){let n=t.RULES.types[r];return n&&n!==!0&&wM(e,n)}i(UJ,"schemaHasRulesForType");ro.schemaHasRulesForType=UJ;function wM(e,t){return t.rules.some(r=>bM(e,r))}i(wM,"shouldUseGroup");ro.shouldUseGroup=wM;function bM(e,t){var r;return e[t.keyword]!==void 0||((r=t.definition.implements)===null||r===void 0?void 0:r.some(n=>e[n]!==void 0))}i(bM,"shouldUseRule");ro.shouldUseRule=bM});var Bl=D(ut=>{"use strict";Object.defineProperty(ut,"__esModule",{value:!0});ut.reportTypeError=ut.checkDataTypes=ut.checkDataType=ut.coerceAndCheckDataType=ut.getJSONTypes=ut.getSchemaTypes=ut.DataType=void 0;var qJ=K0(),HJ=J0(),BJ=Hl(),te=ne(),SM=pe(),ma;(function(e){e[e.Correct=0]="Correct",e[e.Wrong=1]="Wrong"})(ma||(ut.DataType=ma={}));function VJ(e){let t=kM(e.type);if(t.includes("null")){if(e.nullable===!1)throw new Error("type: null contradicts nullable: false")}else{if(!t.length&&e.nullable!==void 0)throw new Error('"nullable" cannot be used without "type"');e.nullable===!0&&t.push("null")}return t}i(VJ,"getSchemaTypes");ut.getSchemaTypes=VJ;function kM(e){let t=Array.isArray(e)?e:e?[e]:[];if(t.every(qJ.isJSONType))return t;throw new Error("type must be JSONType or JSONType[]: "+t.join(","))}i(kM,"getJSONTypes");ut.getJSONTypes=kM;function GJ(e,t){let{gen:r,data:n,opts:o}=e,s=WJ(t,o.coerceTypes),a=t.length>0&&!(s.length===0&&t.length===1&&(0,HJ.schemaHasRulesForType)(e,t[0]));if(a){let c=X0(t,n,o.strictNumbers,ma.Wrong);r.if(c,()=>{s.length?KJ(e,t,s):Q0(e)})}return a}i(GJ,"coerceAndCheckDataType");ut.coerceAndCheckDataType=GJ;var $M=new Set(["string","number","integer","boolean","null"]);function WJ(e,t){return t?e.filter(r=>$M.has(r)||t==="array"&&r==="array"):[]}i(WJ,"coerceToTypes");function KJ(e,t,r){let{gen:n,data:o,opts:s}=e,a=n.let("dataType",(0,te._)`typeof ${o}`),c=n.let("coerced",(0,te._)`undefined`);s.coerceTypes==="array"&&n.if((0,te._)`${a} == 'object' && Array.isArray(${o}) && ${o}.length == 1`,()=>n.assign(o,(0,te._)`${o}[0]`).assign(a,(0,te._)`typeof ${o}`).if(X0(t,o,s.strictNumbers),()=>n.assign(c,o))),n.if((0,te._)`${c} !== undefined`);for(let u of r)($M.has(u)||u==="array"&&s.coerceTypes==="array")&&l(u);n.else(),Q0(e),n.endIf(),n.if((0,te._)`${c} !== undefined`,()=>{n.assign(o,c),JJ(e,c)});function l(u){switch(u){case"string":n.elseIf((0,te._)`${a} == "number" || ${a} == "boolean"`).assign(c,(0,te._)`"" + ${o}`).elseIf((0,te._)`${o} === null`).assign(c,(0,te._)`""`);return;case"number":n.elseIf((0,te._)`${a} == "boolean" || ${o} === null
175
- || (${a} == "string" && ${o} && ${o} == +${o})`).assign(c,(0,te._)`+${o}`);return;case"integer":n.elseIf((0,te._)`${a} === "boolean" || ${o} === null
176
- || (${a} === "string" && ${o} && ${o} == +${o} && !(${o} % 1))`).assign(c,(0,te._)`+${o}`);return;case"boolean":n.elseIf((0,te._)`${o} === "false" || ${o} === 0 || ${o} === null`).assign(c,!1).elseIf((0,te._)`${o} === "true" || ${o} === 1`).assign(c,!0);return;case"null":n.elseIf((0,te._)`${o} === "" || ${o} === 0 || ${o} === false`),n.assign(c,null);return;case"array":n.elseIf((0,te._)`${a} === "string" || ${a} === "number"
177
- || ${a} === "boolean" || ${o} === null`).assign(c,(0,te._)`[${o}]`)}}i(l,"coerceSpecificType")}i(KJ,"coerceData");function JJ({gen:e,parentData:t,parentDataProperty:r},n){e.if((0,te._)`${t} !== undefined`,()=>e.assign((0,te._)`${t}[${r}]`,n))}i(JJ,"assignParentData");function Y0(e,t,r,n=ma.Correct){let o=n===ma.Correct?te.operators.EQ:te.operators.NEQ,s;switch(e){case"null":return(0,te._)`${t} ${o} null`;case"array":s=(0,te._)`Array.isArray(${t})`;break;case"object":s=(0,te._)`${t} && typeof ${t} == "object" && !Array.isArray(${t})`;break;case"integer":s=a((0,te._)`!(${t} % 1) && !isNaN(${t})`);break;case"number":s=a();break;default:return(0,te._)`typeof ${t} ${o} ${e}`}return n===ma.Correct?s:(0,te.not)(s);function a(c=te.nil){return(0,te.and)((0,te._)`typeof ${t} == "number"`,c,r?(0,te._)`isFinite(${t})`:te.nil)}}i(Y0,"checkDataType");ut.checkDataType=Y0;function X0(e,t,r,n){if(e.length===1)return Y0(e[0],t,r,n);let o,s=(0,SM.toHash)(e);if(s.array&&s.object){let a=(0,te._)`typeof ${t} != "object"`;o=s.null?a:(0,te._)`!${t} || ${a}`,delete s.null,delete s.array,delete s.object}else o=te.nil;s.number&&delete s.integer;for(let a in s)o=(0,te.and)(o,Y0(a,t,r,n));return o}i(X0,"checkDataTypes");ut.checkDataTypes=X0;var YJ={message:({schema:e})=>`must be ${e}`,params:({schema:e,schemaValue:t})=>typeof e=="string"?(0,te._)`{type: ${e}}`:(0,te._)`{type: ${t}}`};function Q0(e){let t=XJ(e);(0,BJ.reportError)(t,YJ)}i(Q0,"reportTypeError");ut.reportTypeError=Q0;function XJ(e){let{gen:t,data:r,schema:n}=e,o=(0,SM.schemaRefOrVal)(e,n,"type");return{gen:t,keyword:"type",data:r,schema:n.type,schemaCode:o,schemaValue:o,parentSchema:n,params:{},it:e}}i(XJ,"getTypeErrorContext")});var NM=D(zm=>{"use strict";Object.defineProperty(zm,"__esModule",{value:!0});zm.assignDefaults=void 0;var ha=ne(),QJ=pe();function e7(e,t){let{properties:r,items:n}=e.schema;if(t==="object"&&r)for(let o in r)EM(e,o,r[o].default);else t==="array"&&Array.isArray(n)&&n.forEach((o,s)=>EM(e,s,o.default))}i(e7,"assignDefaults");zm.assignDefaults=e7;function EM(e,t,r){let{gen:n,compositeRule:o,data:s,opts:a}=e;if(r===void 0)return;let c=(0,ha._)`${s}${(0,ha.getProperty)(t)}`;if(o){(0,QJ.checkStrictMode)(e,`default is ignored for: ${c}`);return}let l=(0,ha._)`${c} === undefined`;a.useDefaults==="empty"&&(l=(0,ha._)`${l} || ${c} === null || ${c} === ""`),n.if(l,(0,ha._)`${c} = ${(0,ha.stringify)(r)}`)}i(EM,"assignDefault")});var ar=D(ve=>{"use strict";Object.defineProperty(ve,"__esModule",{value:!0});ve.validateUnion=ve.validateArray=ve.usePattern=ve.callValidateCode=ve.schemaProperties=ve.allSchemaProperties=ve.noPropertyInData=ve.propertyInData=ve.isOwnProperty=ve.hasPropFunc=ve.reportMissingProp=ve.checkMissingProp=ve.checkReportMissingProp=void 0;var Ie=ne(),eS=pe(),no=zn(),t7=pe();function r7(e,t){let{gen:r,data:n,it:o}=e;r.if(rS(r,n,t,o.opts.ownProperties),()=>{e.setParams({missingProperty:(0,Ie._)`${t}`},!0),e.error()})}i(r7,"checkReportMissingProp");ve.checkReportMissingProp=r7;function n7({gen:e,data:t,it:{opts:r}},n,o){return(0,Ie.or)(...n.map(s=>(0,Ie.and)(rS(e,t,s,r.ownProperties),(0,Ie._)`${o} = ${s}`)))}i(n7,"checkMissingProp");ve.checkMissingProp=n7;function o7(e,t){e.setParams({missingProperty:t},!0),e.error()}i(o7,"reportMissingProp");ve.reportMissingProp=o7;function TM(e){return e.scopeValue("func",{ref:Object.prototype.hasOwnProperty,code:(0,Ie._)`Object.prototype.hasOwnProperty`})}i(TM,"hasPropFunc");ve.hasPropFunc=TM;function tS(e,t,r){return(0,Ie._)`${TM(e)}.call(${t}, ${r})`}i(tS,"isOwnProperty");ve.isOwnProperty=tS;function s7(e,t,r,n){let o=(0,Ie._)`${t}${(0,Ie.getProperty)(r)} !== undefined`;return n?(0,Ie._)`${o} && ${tS(e,t,r)}`:o}i(s7,"propertyInData");ve.propertyInData=s7;function rS(e,t,r,n){let o=(0,Ie._)`${t}${(0,Ie.getProperty)(r)} === undefined`;return n?(0,Ie.or)(o,(0,Ie.not)(tS(e,t,r))):o}i(rS,"noPropertyInData");ve.noPropertyInData=rS;function zM(e){return e?Object.keys(e).filter(t=>t!=="__proto__"):[]}i(zM,"allSchemaProperties");ve.allSchemaProperties=zM;function i7(e,t){return zM(t).filter(r=>!(0,eS.alwaysValidSchema)(e,t[r]))}i(i7,"schemaProperties");ve.schemaProperties=i7;function a7({schemaCode:e,data:t,it:{gen:r,topSchemaRef:n,schemaPath:o,errorPath:s},it:a},c,l,u){let d=u?(0,Ie._)`${e}, ${t}, ${n}${o}`:t,p=[[no.default.instancePath,(0,Ie.strConcat)(no.default.instancePath,s)],[no.default.parentData,a.parentData],[no.default.parentDataProperty,a.parentDataProperty],[no.default.rootData,no.default.rootData]];a.opts.dynamicRef&&p.push([no.default.dynamicAnchors,no.default.dynamicAnchors]);let h=(0,Ie._)`${d}, ${r.object(...p)}`;return l!==Ie.nil?(0,Ie._)`${c}.call(${l}, ${h})`:(0,Ie._)`${c}(${h})`}i(a7,"callValidateCode");ve.callValidateCode=a7;var c7=(0,Ie._)`new RegExp`;function l7({gen:e,it:{opts:t}},r){let n=t.unicodeRegExp?"u":"",{regExp:o}=t.code,s=o(r,n);return e.scopeValue("pattern",{key:s.toString(),ref:s,code:(0,Ie._)`${o.code==="new RegExp"?c7:(0,t7.useFunc)(e,o)}(${r}, ${n})`})}i(l7,"usePattern");ve.usePattern=l7;function u7(e){let{gen:t,data:r,keyword:n,it:o}=e,s=t.name("valid");if(o.allErrors){let c=t.let("valid",!0);return a(()=>t.assign(c,!1)),c}return t.var(s,!0),a(()=>t.break()),s;function a(c){let l=t.const("len",(0,Ie._)`${r}.length`);t.forRange("i",0,l,u=>{e.subschema({keyword:n,dataProp:u,dataPropType:eS.Type.Num},s),t.if((0,Ie.not)(s),c)})}i(a,"validateItems")}i(u7,"validateArray");ve.validateArray=u7;function d7(e){let{gen:t,schema:r,keyword:n,it:o}=e;if(!Array.isArray(r))throw new Error("ajv implementation error");if(r.some(l=>(0,eS.alwaysValidSchema)(o,l))&&!o.opts.unevaluated)return;let a=t.let("valid",!1),c=t.name("_valid");t.block(()=>r.forEach((l,u)=>{let d=e.subschema({keyword:n,schemaProp:u,compositeRule:!0},c);t.assign(a,(0,Ie._)`${a} || ${c}`),e.mergeValidEvaluated(d,c)||t.if((0,Ie.not)(a))})),e.result(a,()=>e.reset(),()=>e.error(!0))}i(d7,"validateUnion");ve.validateUnion=d7});var PM=D(Br=>{"use strict";Object.defineProperty(Br,"__esModule",{value:!0});Br.validateKeywordUsage=Br.validSchemaType=Br.funcKeywordCode=Br.macroKeywordCode=void 0;var xt=ne(),ks=zn(),p7=ar(),f7=Hl();function m7(e,t){let{gen:r,keyword:n,schema:o,parentSchema:s,it:a}=e,c=t.macro.call(a.self,o,s,a),l=IM(r,n,c);a.opts.validateSchema!==!1&&a.self.validateSchema(c,!0);let u=r.name("valid");e.subschema({schema:c,schemaPath:xt.nil,errSchemaPath:`${a.errSchemaPath}/${n}`,topSchemaRef:l,compositeRule:!0},u),e.pass(u,()=>e.error(!0))}i(m7,"macroKeywordCode");Br.macroKeywordCode=m7;function h7(e,t){var r;let{gen:n,keyword:o,schema:s,parentSchema:a,$data:c,it:l}=e;y7(l,t);let u=!c&&t.compile?t.compile.call(l.self,s,a,l):t.validate,d=IM(n,o,u),p=n.let("valid");e.block$data(p,h),e.ok((r=t.valid)!==null&&r!==void 0?r:p);function h(){if(t.errors===!1)_(),t.modifying&&CM(e),x(()=>e.error());else{let v=t.async?m():g();t.modifying&&CM(e),x(()=>g7(e,v))}}i(h,"validateKeyword");function m(){let v=n.let("ruleErrs",null);return n.try(()=>_((0,xt._)`await `),w=>n.assign(p,!1).if((0,xt._)`${w} instanceof ${l.ValidationError}`,()=>n.assign(v,(0,xt._)`${w}.errors`),()=>n.throw(w))),v}i(m,"validateAsync");function g(){let v=(0,xt._)`${d}.errors`;return n.assign(v,null),_(xt.nil),v}i(g,"validateSync");function _(v=t.async?(0,xt._)`await `:xt.nil){let w=l.opts.passContext?ks.default.this:ks.default.self,b=!("compile"in t&&!c||t.schema===!1);n.assign(p,(0,xt._)`${v}${(0,p7.callValidateCode)(e,d,w,b)}`,t.modifying)}i(_,"assignValid");function x(v){var w;n.if((0,xt.not)((w=t.valid)!==null&&w!==void 0?w:p),v)}i(x,"reportErrs")}i(h7,"funcKeywordCode");Br.funcKeywordCode=h7;function CM(e){let{gen:t,data:r,it:n}=e;t.if(n.parentData,()=>t.assign(r,(0,xt._)`${n.parentData}[${n.parentDataProperty}]`))}i(CM,"modifyData");function g7(e,t){let{gen:r}=e;r.if((0,xt._)`Array.isArray(${t})`,()=>{r.assign(ks.default.vErrors,(0,xt._)`${ks.default.vErrors} === null ? ${t} : ${ks.default.vErrors}.concat(${t})`).assign(ks.default.errors,(0,xt._)`${ks.default.vErrors}.length`),(0,f7.extendErrors)(e)},()=>e.error())}i(g7,"addErrs");function y7({schemaEnv:e},t){if(t.async&&!e.$async)throw new Error("async keyword in sync schema")}i(y7,"checkAsyncKeyword");function IM(e,t,r){if(r===void 0)throw new Error(`keyword "${t}" failed to compile`);return e.scopeValue("keyword",typeof r=="function"?{ref:r}:{ref:r,code:(0,xt.stringify)(r)})}i(IM,"useKeyword");function x7(e,t,r=!1){return!t.length||t.some(n=>n==="array"?Array.isArray(e):n==="object"?e&&typeof e=="object"&&!Array.isArray(e):typeof e==n||r&&typeof e>"u")}i(x7,"validSchemaType");Br.validSchemaType=x7;function _7({schema:e,opts:t,self:r,errSchemaPath:n},o,s){if(Array.isArray(o.keyword)?!o.keyword.includes(s):o.keyword!==s)throw new Error("ajv implementation error");let a=o.dependencies;if(a?.some(c=>!Object.prototype.hasOwnProperty.call(e,c)))throw new Error(`parent schema must have dependencies of ${s}: ${a.join(",")}`);if(o.validateSchema&&!o.validateSchema(e[s])){let l=`keyword "${s}" value is invalid at path "${n}": `+r.errorsText(o.validateSchema.errors);if(t.validateSchema==="log")r.logger.error(l);else throw new Error(l)}}i(_7,"validateKeywordUsage");Br.validateKeywordUsage=_7});var OM=D(oo=>{"use strict";Object.defineProperty(oo,"__esModule",{value:!0});oo.extendSubschemaMode=oo.extendSubschemaData=oo.getSubschema=void 0;var Vr=ne(),RM=pe();function v7(e,{keyword:t,schemaProp:r,schema:n,schemaPath:o,errSchemaPath:s,topSchemaRef:a}){if(t!==void 0&&n!==void 0)throw new Error('both "keyword" and "schema" passed, only one allowed');if(t!==void 0){let c=e.schema[t];return r===void 0?{schema:c,schemaPath:(0,Vr._)`${e.schemaPath}${(0,Vr.getProperty)(t)}`,errSchemaPath:`${e.errSchemaPath}/${t}`}:{schema:c[r],schemaPath:(0,Vr._)`${e.schemaPath}${(0,Vr.getProperty)(t)}${(0,Vr.getProperty)(r)}`,errSchemaPath:`${e.errSchemaPath}/${t}/${(0,RM.escapeFragment)(r)}`}}if(n!==void 0){if(o===void 0||s===void 0||a===void 0)throw new Error('"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"');return{schema:n,schemaPath:o,topSchemaRef:a,errSchemaPath:s}}throw new Error('either "keyword" or "schema" must be passed')}i(v7,"getSubschema");oo.getSubschema=v7;function w7(e,t,{dataProp:r,dataPropType:n,data:o,dataTypes:s,propertyName:a}){if(o!==void 0&&r!==void 0)throw new Error('both "data" and "dataProp" passed, only one allowed');let{gen:c}=t;if(r!==void 0){let{errorPath:u,dataPathArr:d,opts:p}=t,h=c.let("data",(0,Vr._)`${t.data}${(0,Vr.getProperty)(r)}`,!0);l(h),e.errorPath=(0,Vr.str)`${u}${(0,RM.getErrorPath)(r,n,p.jsPropertySyntax)}`,e.parentDataProperty=(0,Vr._)`${r}`,e.dataPathArr=[...d,e.parentDataProperty]}if(o!==void 0){let u=o instanceof Vr.Name?o:c.let("data",o,!0);l(u),a!==void 0&&(e.propertyName=a)}s&&(e.dataTypes=s);function l(u){e.data=u,e.dataLevel=t.dataLevel+1,e.dataTypes=[],t.definedProperties=new Set,e.parentData=t.data,e.dataNames=[...t.dataNames,u]}i(l,"dataContextProps")}i(w7,"extendSubschemaData");oo.extendSubschemaData=w7;function b7(e,{jtdDiscriminator:t,jtdMetadata:r,compositeRule:n,createErrors:o,allErrors:s}){n!==void 0&&(e.compositeRule=n),o!==void 0&&(e.createErrors=o),s!==void 0&&(e.allErrors=s),e.jtdDiscriminator=t,e.jtdMetadata=r}i(b7,"extendSubschemaMode");oo.extendSubschemaMode=b7});var nS=D((a2e,AM)=>{"use strict";AM.exports=i(function e(t,r){if(t===r)return!0;if(t&&r&&typeof t=="object"&&typeof r=="object"){if(t.constructor!==r.constructor)return!1;var n,o,s;if(Array.isArray(t)){if(n=t.length,n!=r.length)return!1;for(o=n;o--!==0;)if(!e(t[o],r[o]))return!1;return!0}if(t.constructor===RegExp)return t.source===r.source&&t.flags===r.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===r.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===r.toString();if(s=Object.keys(t),n=s.length,n!==Object.keys(r).length)return!1;for(o=n;o--!==0;)if(!Object.prototype.hasOwnProperty.call(r,s[o]))return!1;for(o=n;o--!==0;){var a=s[o];if(!e(t[a],r[a]))return!1}return!0}return t!==t&&r!==r},"equal")});var DM=D((l2e,jM)=>{"use strict";var so=jM.exports=function(e,t,r){typeof t=="function"&&(r=t,t={}),r=t.cb||r;var n=typeof r=="function"?r:r.pre||function(){},o=r.post||function(){};Cm(t,n,o,e,"",e)};so.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0,if:!0,then:!0,else:!0};so.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0};so.propsKeywords={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependencies:!0};so.skipKeywords={default:!0,enum:!0,const:!0,required:!0,maximum:!0,minimum:!0,exclusiveMaximum:!0,exclusiveMinimum:!0,multipleOf:!0,maxLength:!0,minLength:!0,pattern:!0,format:!0,maxItems:!0,minItems:!0,uniqueItems:!0,maxProperties:!0,minProperties:!0};function Cm(e,t,r,n,o,s,a,c,l,u){if(n&&typeof n=="object"&&!Array.isArray(n)){t(n,o,s,a,c,l,u);for(var d in n){var p=n[d];if(Array.isArray(p)){if(d in so.arrayKeywords)for(var h=0;h<p.length;h++)Cm(e,t,r,p[h],o+"/"+d+"/"+h,s,o,d,n,h)}else if(d in so.propsKeywords){if(p&&typeof p=="object")for(var m in p)Cm(e,t,r,p[m],o+"/"+d+"/"+S7(m),s,o,d,n,m)}else(d in so.keywords||e.allKeys&&!(d in so.skipKeywords))&&Cm(e,t,r,p,o+"/"+d,s,o,d,n)}r(n,o,s,a,c,l,u)}}i(Cm,"_traverse");function S7(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}i(S7,"escapeJsonPtr")});var Vl=D(zt=>{"use strict";Object.defineProperty(zt,"__esModule",{value:!0});zt.getSchemaRefs=zt.resolveUrl=zt.normalizeId=zt._getFullPath=zt.getFullPath=zt.inlineRef=void 0;var k7=pe(),$7=nS(),E7=DM(),N7=new Set(["type","format","pattern","maxLength","minLength","maxProperties","minProperties","maxItems","minItems","maximum","minimum","uniqueItems","multipleOf","required","enum","const"]);function T7(e,t=!0){return typeof e=="boolean"?!0:t===!0?!oS(e):t?MM(e)<=t:!1}i(T7,"inlineRef");zt.inlineRef=T7;var z7=new Set(["$ref","$recursiveRef","$recursiveAnchor","$dynamicRef","$dynamicAnchor"]);function oS(e){for(let t in e){if(z7.has(t))return!0;let r=e[t];if(Array.isArray(r)&&r.some(oS)||typeof r=="object"&&oS(r))return!0}return!1}i(oS,"hasRef");function MM(e){let t=0;for(let r in e){if(r==="$ref")return 1/0;if(t++,!N7.has(r)&&(typeof e[r]=="object"&&(0,k7.eachItem)(e[r],n=>t+=MM(n)),t===1/0))return 1/0}return t}i(MM,"countKeys");function ZM(e,t="",r){r!==!1&&(t=ga(t));let n=e.parse(t);return LM(e,n)}i(ZM,"getFullPath");zt.getFullPath=ZM;function LM(e,t){return e.serialize(t).split("#")[0]+"#"}i(LM,"_getFullPath");zt._getFullPath=LM;var C7=/#\/?$/;function ga(e){return e?e.replace(C7,""):""}i(ga,"normalizeId");zt.normalizeId=ga;function I7(e,t,r){return r=ga(r),e.resolve(t,r)}i(I7,"resolveUrl");zt.resolveUrl=I7;var P7=/^[a-z_][-a-z0-9._]*$/i;function R7(e,t){if(typeof e=="boolean")return{};let{schemaId:r,uriResolver:n}=this.opts,o=ga(e[r]||t),s={"":o},a=ZM(n,o,!1),c={},l=new Set;return E7(e,{allKeys:!0},(p,h,m,g)=>{if(g===void 0)return;let _=a+h,x=s[g];typeof p[r]=="string"&&(x=v.call(this,p[r])),w.call(this,p.$anchor),w.call(this,p.$dynamicAnchor),s[h]=x;function v(b){let S=this.opts.uriResolver.resolve;if(b=ga(x?S(x,b):b),l.has(b))throw d(b);l.add(b);let T=this.refs[b];return typeof T=="string"&&(T=this.refs[T]),typeof T=="object"?u(p,T.schema,b):b!==ga(_)&&(b[0]==="#"?(u(p,c[b],b),c[b]=p):this.refs[b]=_),b}i(v,"addRef");function w(b){if(typeof b=="string"){if(!P7.test(b))throw new Error(`invalid anchor "${b}"`);v.call(this,`#${b}`)}}i(w,"addAnchor")}),c;function u(p,h,m){if(h!==void 0&&!$7(p,h))throw d(m)}i(u,"checkAmbiguosRef");function d(p){return new Error(`reference "${p}" resolves to more than one schema`)}i(d,"ambiguos")}i(R7,"getSchemaRefs");zt.getSchemaRefs=R7});var Kl=D(io=>{"use strict";Object.defineProperty(io,"__esModule",{value:!0});io.getData=io.KeywordCxt=io.validateFunctionCode=void 0;var BM=vM(),FM=Bl(),iS=J0(),Im=Bl(),O7=NM(),Wl=PM(),sS=OM(),H=ne(),Q=zn(),A7=Vl(),Cn=pe(),Gl=Hl();function j7(e){if(WM(e)&&(KM(e),GM(e))){Z7(e);return}VM(e,()=>(0,BM.topBoolOrEmptySchema)(e))}i(j7,"validateFunctionCode");io.validateFunctionCode=j7;function VM({gen:e,validateName:t,schema:r,schemaEnv:n,opts:o},s){o.code.es5?e.func(t,(0,H._)`${Q.default.data}, ${Q.default.valCxt}`,n.$async,()=>{e.code((0,H._)`"use strict"; ${UM(r,o)}`),M7(e,o),e.code(s)}):e.func(t,(0,H._)`${Q.default.data}, ${D7(o)}`,n.$async,()=>e.code(UM(r,o)).code(s))}i(VM,"validateFunction");function D7(e){return(0,H._)`{${Q.default.instancePath}="", ${Q.default.parentData}, ${Q.default.parentDataProperty}, ${Q.default.rootData}=${Q.default.data}${e.dynamicRef?(0,H._)`, ${Q.default.dynamicAnchors}={}`:H.nil}}={}`}i(D7,"destructureValCxt");function M7(e,t){e.if(Q.default.valCxt,()=>{e.var(Q.default.instancePath,(0,H._)`${Q.default.valCxt}.${Q.default.instancePath}`),e.var(Q.default.parentData,(0,H._)`${Q.default.valCxt}.${Q.default.parentData}`),e.var(Q.default.parentDataProperty,(0,H._)`${Q.default.valCxt}.${Q.default.parentDataProperty}`),e.var(Q.default.rootData,(0,H._)`${Q.default.valCxt}.${Q.default.rootData}`),t.dynamicRef&&e.var(Q.default.dynamicAnchors,(0,H._)`${Q.default.valCxt}.${Q.default.dynamicAnchors}`)},()=>{e.var(Q.default.instancePath,(0,H._)`""`),e.var(Q.default.parentData,(0,H._)`undefined`),e.var(Q.default.parentDataProperty,(0,H._)`undefined`),e.var(Q.default.rootData,Q.default.data),t.dynamicRef&&e.var(Q.default.dynamicAnchors,(0,H._)`{}`)})}i(M7,"destructureValCxtES5");function Z7(e){let{schema:t,opts:r,gen:n}=e;VM(e,()=>{r.$comment&&t.$comment&&YM(e),H7(e),n.let(Q.default.vErrors,null),n.let(Q.default.errors,0),r.unevaluated&&L7(e),JM(e),G7(e)})}i(Z7,"topSchemaObjCode");function L7(e){let{gen:t,validateName:r}=e;e.evaluated=t.const("evaluated",(0,H._)`${r}.evaluated`),t.if((0,H._)`${e.evaluated}.dynamicProps`,()=>t.assign((0,H._)`${e.evaluated}.props`,(0,H._)`undefined`)),t.if((0,H._)`${e.evaluated}.dynamicItems`,()=>t.assign((0,H._)`${e.evaluated}.items`,(0,H._)`undefined`))}i(L7,"resetEvaluated");function UM(e,t){let r=typeof e=="object"&&e[t.schemaId];return r&&(t.code.source||t.code.process)?(0,H._)`/*# sourceURL=${r} */`:H.nil}i(UM,"funcSourceUrl");function F7(e,t){if(WM(e)&&(KM(e),GM(e))){U7(e,t);return}(0,BM.boolOrEmptySchema)(e,t)}i(F7,"subschemaCode");function GM({schema:e,self:t}){if(typeof e=="boolean")return!e;for(let r in e)if(t.RULES.all[r])return!0;return!1}i(GM,"schemaCxtHasRules");function WM(e){return typeof e.schema!="boolean"}i(WM,"isSchemaObj");function U7(e,t){let{schema:r,gen:n,opts:o}=e;o.$comment&&r.$comment&&YM(e),B7(e),V7(e);let s=n.const("_errs",Q.default.errors);JM(e,s),n.var(t,(0,H._)`${s} === ${Q.default.errors}`)}i(U7,"subSchemaObjCode");function KM(e){(0,Cn.checkUnknownRules)(e),q7(e)}i(KM,"checkKeywords");function JM(e,t){if(e.opts.jtd)return qM(e,[],!1,t);let r=(0,FM.getSchemaTypes)(e.schema),n=(0,FM.coerceAndCheckDataType)(e,r);qM(e,r,!n,t)}i(JM,"typeAndKeywords");function q7(e){let{schema:t,errSchemaPath:r,opts:n,self:o}=e;t.$ref&&n.ignoreKeywordsWithRef&&(0,Cn.schemaHasRulesButRef)(t,o.RULES)&&o.logger.warn(`$ref: keywords ignored in schema at path "${r}"`)}i(q7,"checkRefsAndKeywords");function H7(e){let{schema:t,opts:r}=e;t.default!==void 0&&r.useDefaults&&r.strictSchema&&(0,Cn.checkStrictMode)(e,"default is ignored in the schema root")}i(H7,"checkNoDefault");function B7(e){let t=e.schema[e.opts.schemaId];t&&(e.baseId=(0,A7.resolveUrl)(e.opts.uriResolver,e.baseId,t))}i(B7,"updateContext");function V7(e){if(e.schema.$async&&!e.schemaEnv.$async)throw new Error("async schema in sync schema")}i(V7,"checkAsyncSchema");function YM({gen:e,schemaEnv:t,schema:r,errSchemaPath:n,opts:o}){let s=r.$comment;if(o.$comment===!0)e.code((0,H._)`${Q.default.self}.logger.log(${s})`);else if(typeof o.$comment=="function"){let a=(0,H.str)`${n}/$comment`,c=e.scopeValue("root",{ref:t.root});e.code((0,H._)`${Q.default.self}.opts.$comment(${s}, ${a}, ${c}.schema)`)}}i(YM,"commentKeyword");function G7(e){let{gen:t,schemaEnv:r,validateName:n,ValidationError:o,opts:s}=e;r.$async?t.if((0,H._)`${Q.default.errors} === 0`,()=>t.return(Q.default.data),()=>t.throw((0,H._)`new ${o}(${Q.default.vErrors})`)):(t.assign((0,H._)`${n}.errors`,Q.default.vErrors),s.unevaluated&&W7(e),t.return((0,H._)`${Q.default.errors} === 0`))}i(G7,"returnResults");function W7({gen:e,evaluated:t,props:r,items:n}){r instanceof H.Name&&e.assign((0,H._)`${t}.props`,r),n instanceof H.Name&&e.assign((0,H._)`${t}.items`,n)}i(W7,"assignEvaluated");function qM(e,t,r,n){let{gen:o,schema:s,data:a,allErrors:c,opts:l,self:u}=e,{RULES:d}=u;if(s.$ref&&(l.ignoreKeywordsWithRef||!(0,Cn.schemaHasRulesButRef)(s,d))){o.block(()=>QM(e,"$ref",d.all.$ref.definition));return}l.jtd||K7(e,t),o.block(()=>{for(let h of d.rules)p(h);p(d.post)});function p(h){(0,iS.shouldUseGroup)(s,h)&&(h.type?(o.if((0,Im.checkDataType)(h.type,a,l.strictNumbers)),HM(e,h),t.length===1&&t[0]===h.type&&r&&(o.else(),(0,Im.reportTypeError)(e)),o.endIf()):HM(e,h),c||o.if((0,H._)`${Q.default.errors} === ${n||0}`))}i(p,"groupKeywords")}i(qM,"schemaKeywords");function HM(e,t){let{gen:r,schema:n,opts:{useDefaults:o}}=e;o&&(0,O7.assignDefaults)(e,t.type),r.block(()=>{for(let s of t.rules)(0,iS.shouldUseRule)(n,s)&&QM(e,s.keyword,s.definition,t.type)})}i(HM,"iterateKeywords");function K7(e,t){e.schemaEnv.meta||!e.opts.strictTypes||(J7(e,t),e.opts.allowUnionTypes||Y7(e,t),X7(e,e.dataTypes))}i(K7,"checkStrictTypes");function J7(e,t){if(t.length){if(!e.dataTypes.length){e.dataTypes=t;return}t.forEach(r=>{XM(e.dataTypes,r)||aS(e,`type "${r}" not allowed by context "${e.dataTypes.join(",")}"`)}),eY(e,t)}}i(J7,"checkContextTypes");function Y7(e,t){t.length>1&&!(t.length===2&&t.includes("null"))&&aS(e,"use allowUnionTypes to allow union type keyword")}i(Y7,"checkMultipleTypes");function X7(e,t){let r=e.self.RULES.all;for(let n in r){let o=r[n];if(typeof o=="object"&&(0,iS.shouldUseRule)(e.schema,o)){let{type:s}=o.definition;s.length&&!s.some(a=>Q7(t,a))&&aS(e,`missing type "${s.join(",")}" for keyword "${n}"`)}}}i(X7,"checkKeywordTypes");function Q7(e,t){return e.includes(t)||t==="number"&&e.includes("integer")}i(Q7,"hasApplicableType");function XM(e,t){return e.includes(t)||t==="integer"&&e.includes("number")}i(XM,"includesType");function eY(e,t){let r=[];for(let n of e.dataTypes)XM(t,n)?r.push(n):t.includes("integer")&&n==="number"&&r.push("integer");e.dataTypes=r}i(eY,"narrowSchemaTypes");function aS(e,t){let r=e.schemaEnv.baseId+e.errSchemaPath;t+=` at "${r}" (strictTypes)`,(0,Cn.checkStrictMode)(e,t,e.opts.strictTypes)}i(aS,"strictTypesError");var cS=class cS{constructor(t,r,n){if((0,Wl.validateKeywordUsage)(t,r,n),this.gen=t.gen,this.allErrors=t.allErrors,this.keyword=n,this.data=t.data,this.schema=t.schema[n],this.$data=r.$data&&t.opts.$data&&this.schema&&this.schema.$data,this.schemaValue=(0,Cn.schemaRefOrVal)(t,this.schema,n,this.$data),this.schemaType=r.schemaType,this.parentSchema=t.schema,this.params={},this.it=t,this.def=r,this.$data)this.schemaCode=t.gen.const("vSchema",e2(this.$data,t));else if(this.schemaCode=this.schemaValue,!(0,Wl.validSchemaType)(this.schema,r.schemaType,r.allowUndefined))throw new Error(`${n} value must be ${JSON.stringify(r.schemaType)}`);("code"in r?r.trackErrors:r.errors!==!1)&&(this.errsCount=t.gen.const("_errs",Q.default.errors))}result(t,r,n){this.failResult((0,H.not)(t),r,n)}failResult(t,r,n){this.gen.if(t),n?n():this.error(),r?(this.gen.else(),r(),this.allErrors&&this.gen.endIf()):this.allErrors?this.gen.endIf():this.gen.else()}pass(t,r){this.failResult((0,H.not)(t),void 0,r)}fail(t){if(t===void 0){this.error(),this.allErrors||this.gen.if(!1);return}this.gen.if(t),this.error(),this.allErrors?this.gen.endIf():this.gen.else()}fail$data(t){if(!this.$data)return this.fail(t);let{schemaCode:r}=this;this.fail((0,H._)`${r} !== undefined && (${(0,H.or)(this.invalid$data(),t)})`)}error(t,r,n){if(r){this.setParams(r),this._error(t,n),this.setParams({});return}this._error(t,n)}_error(t,r){(t?Gl.reportExtraError:Gl.reportError)(this,this.def.error,r)}$dataError(){(0,Gl.reportError)(this,this.def.$dataError||Gl.keyword$DataError)}reset(){if(this.errsCount===void 0)throw new Error('add "trackErrors" to keyword definition');(0,Gl.resetErrorsCount)(this.gen,this.errsCount)}ok(t){this.allErrors||this.gen.if(t)}setParams(t,r){r?Object.assign(this.params,t):this.params=t}block$data(t,r,n=H.nil){this.gen.block(()=>{this.check$data(t,n),r()})}check$data(t=H.nil,r=H.nil){if(!this.$data)return;let{gen:n,schemaCode:o,schemaType:s,def:a}=this;n.if((0,H.or)((0,H._)`${o} === undefined`,r)),t!==H.nil&&n.assign(t,!0),(s.length||a.validateSchema)&&(n.elseIf(this.invalid$data()),this.$dataError(),t!==H.nil&&n.assign(t,!1)),n.else()}invalid$data(){let{gen:t,schemaCode:r,schemaType:n,def:o,it:s}=this;return(0,H.or)(a(),c());function a(){if(n.length){if(!(r instanceof H.Name))throw new Error("ajv implementation error");let l=Array.isArray(n)?n:[n];return(0,H._)`${(0,Im.checkDataTypes)(l,r,s.opts.strictNumbers,Im.DataType.Wrong)}`}return H.nil}function c(){if(o.validateSchema){let l=t.scopeValue("validate$data",{ref:o.validateSchema});return(0,H._)`!${l}(${r})`}return H.nil}}subschema(t,r){let n=(0,sS.getSubschema)(this.it,t);(0,sS.extendSubschemaData)(n,this.it,t),(0,sS.extendSubschemaMode)(n,t);let o={...this.it,...n,items:void 0,props:void 0};return F7(o,r),o}mergeEvaluated(t,r){let{it:n,gen:o}=this;n.opts.unevaluated&&(n.props!==!0&&t.props!==void 0&&(n.props=Cn.mergeEvaluated.props(o,t.props,n.props,r)),n.items!==!0&&t.items!==void 0&&(n.items=Cn.mergeEvaluated.items(o,t.items,n.items,r)))}mergeValidEvaluated(t,r){let{it:n,gen:o}=this;if(n.opts.unevaluated&&(n.props!==!0||n.items!==!0))return o.if(r,()=>this.mergeEvaluated(t,H.Name)),!0}};i(cS,"KeywordCxt");var Pm=cS;io.KeywordCxt=Pm;function QM(e,t,r,n){let o=new Pm(e,r,t);"code"in r?r.code(o,n):o.$data&&r.validate?(0,Wl.funcKeywordCode)(o,r):"macro"in r?(0,Wl.macroKeywordCode)(o,r):(r.compile||r.validate)&&(0,Wl.funcKeywordCode)(o,r)}i(QM,"keywordCode");var tY=/^\/(?:[^~]|~0|~1)*$/,rY=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function e2(e,{dataLevel:t,dataNames:r,dataPathArr:n}){let o,s;if(e==="")return Q.default.rootData;if(e[0]==="/"){if(!tY.test(e))throw new Error(`Invalid JSON-pointer: ${e}`);o=e,s=Q.default.rootData}else{let u=rY.exec(e);if(!u)throw new Error(`Invalid JSON-pointer: ${e}`);let d=+u[1];if(o=u[2],o==="#"){if(d>=t)throw new Error(l("property/index",d));return n[t-d]}if(d>t)throw new Error(l("data",d));if(s=r[t-d],!o)return s}let a=s,c=o.split("/");for(let u of c)u&&(s=(0,H._)`${s}${(0,H.getProperty)((0,Cn.unescapeJsonPointer)(u))}`,a=(0,H._)`${a} && ${s}`);return a;function l(u,d){return`Cannot access ${u} ${d} levels up, current level is ${t}`}}i(e2,"getData");io.getData=e2});var Rm=D(uS=>{"use strict";Object.defineProperty(uS,"__esModule",{value:!0});var dS=class dS extends Error{constructor(t){super("validation failed"),this.errors=t,this.ajv=this.validation=!0}};i(dS,"ValidationError");var lS=dS;uS.default=lS});var Jl=D(mS=>{"use strict";Object.defineProperty(mS,"__esModule",{value:!0});var pS=Vl(),hS=class hS extends Error{constructor(t,r,n,o){super(o||`can't resolve reference ${n} from id ${r}`),this.missingRef=(0,pS.resolveUrl)(t,r,n),this.missingSchema=(0,pS.normalizeId)((0,pS.getFullPath)(t,this.missingRef))}};i(hS,"MissingRefError");var fS=hS;mS.default=fS});var Am=D(cr=>{"use strict";Object.defineProperty(cr,"__esModule",{value:!0});cr.resolveSchema=cr.getCompilingSchema=cr.resolveRef=cr.compileSchema=cr.SchemaEnv=void 0;var kr=ne(),nY=Rm(),$s=zn(),$r=Vl(),t2=pe(),oY=Kl(),xS=class xS{constructor(t){var r;this.refs={},this.dynamicAnchors={};let n;typeof t.schema=="object"&&(n=t.schema),this.schema=t.schema,this.schemaId=t.schemaId,this.root=t.root||this,this.baseId=(r=t.baseId)!==null&&r!==void 0?r:(0,$r.normalizeId)(n?.[t.schemaId||"$id"]),this.schemaPath=t.schemaPath,this.localRefs=t.localRefs,this.meta=t.meta,this.$async=n?.$async,this.refs={}}};i(xS,"SchemaEnv");var ya=xS;cr.SchemaEnv=ya;function yS(e){let t=r2.call(this,e);if(t)return t;let r=(0,$r.getFullPath)(this.opts.uriResolver,e.root.baseId),{es5:n,lines:o}=this.opts.code,{ownProperties:s}=this.opts,a=new kr.CodeGen(this.scope,{es5:n,lines:o,ownProperties:s}),c;e.$async&&(c=a.scopeValue("Error",{ref:nY.default,code:(0,kr._)`require("ajv/dist/runtime/validation_error").default`}));let l=a.scopeName("validate");e.validateName=l;let u={gen:a,allErrors:this.opts.allErrors,data:$s.default.data,parentData:$s.default.parentData,parentDataProperty:$s.default.parentDataProperty,dataNames:[$s.default.data],dataPathArr:[kr.nil],dataLevel:0,dataTypes:[],definedProperties:new Set,topSchemaRef:a.scopeValue("schema",this.opts.code.source===!0?{ref:e.schema,code:(0,kr.stringify)(e.schema)}:{ref:e.schema}),validateName:l,ValidationError:c,schema:e.schema,schemaEnv:e,rootId:r,baseId:e.baseId||r,schemaPath:kr.nil,errSchemaPath:e.schemaPath||(this.opts.jtd?"":"#"),errorPath:(0,kr._)`""`,opts:this.opts,self:this},d;try{this._compilations.add(e),(0,oY.validateFunctionCode)(u),a.optimize(this.opts.code.optimize);let p=a.toString();d=`${a.scopeRefs($s.default.scope)}return ${p}`,this.opts.code.process&&(d=this.opts.code.process(d,e));let m=new Function(`${$s.default.self}`,`${$s.default.scope}`,d)(this,this.scope.get());if(this.scope.value(l,{ref:m}),m.errors=null,m.schema=e.schema,m.schemaEnv=e,e.$async&&(m.$async=!0),this.opts.code.source===!0&&(m.source={validateName:l,validateCode:p,scopeValues:a._values}),this.opts.unevaluated){let{props:g,items:_}=u;m.evaluated={props:g instanceof kr.Name?void 0:g,items:_ instanceof kr.Name?void 0:_,dynamicProps:g instanceof kr.Name,dynamicItems:_ instanceof kr.Name},m.source&&(m.source.evaluated=(0,kr.stringify)(m.evaluated))}return e.validate=m,e}catch(p){throw delete e.validate,delete e.validateName,d&&this.logger.error("Error compiling schema, function code:",d),p}finally{this._compilations.delete(e)}}i(yS,"compileSchema");cr.compileSchema=yS;function sY(e,t,r){var n;r=(0,$r.resolveUrl)(this.opts.uriResolver,t,r);let o=e.refs[r];if(o)return o;let s=cY.call(this,e,r);if(s===void 0){let a=(n=e.localRefs)===null||n===void 0?void 0:n[r],{schemaId:c}=this.opts;a&&(s=new ya({schema:a,schemaId:c,root:e,baseId:t}))}if(s!==void 0)return e.refs[r]=iY.call(this,s)}i(sY,"resolveRef");cr.resolveRef=sY;function iY(e){return(0,$r.inlineRef)(e.schema,this.opts.inlineRefs)?e.schema:e.validate?e:yS.call(this,e)}i(iY,"inlineOrCompile");function r2(e){for(let t of this._compilations)if(aY(t,e))return t}i(r2,"getCompilingSchema");cr.getCompilingSchema=r2;function aY(e,t){return e.schema===t.schema&&e.root===t.root&&e.baseId===t.baseId}i(aY,"sameSchemaEnv");function cY(e,t){let r;for(;typeof(r=this.refs[t])=="string";)t=r;return r||this.schemas[t]||Om.call(this,e,t)}i(cY,"resolve");function Om(e,t){let r=this.opts.uriResolver.parse(t),n=(0,$r._getFullPath)(this.opts.uriResolver,r),o=(0,$r.getFullPath)(this.opts.uriResolver,e.baseId,void 0);if(Object.keys(e.schema).length>0&&n===o)return gS.call(this,r,e);let s=(0,$r.normalizeId)(n),a=this.refs[s]||this.schemas[s];if(typeof a=="string"){let c=Om.call(this,e,a);return typeof c?.schema!="object"?void 0:gS.call(this,r,c)}if(typeof a?.schema=="object"){if(a.validate||yS.call(this,a),s===(0,$r.normalizeId)(t)){let{schema:c}=a,{schemaId:l}=this.opts,u=c[l];return u&&(o=(0,$r.resolveUrl)(this.opts.uriResolver,o,u)),new ya({schema:c,schemaId:l,root:e,baseId:o})}return gS.call(this,r,a)}}i(Om,"resolveSchema");cr.resolveSchema=Om;var lY=new Set(["properties","patternProperties","enum","dependencies","definitions"]);function gS(e,{baseId:t,schema:r,root:n}){var o;if(((o=e.fragment)===null||o===void 0?void 0:o[0])!=="/")return;for(let c of e.fragment.slice(1).split("/")){if(typeof r=="boolean")return;let l=r[(0,t2.unescapeFragment)(c)];if(l===void 0)return;r=l;let u=typeof r=="object"&&r[this.opts.schemaId];!lY.has(c)&&u&&(t=(0,$r.resolveUrl)(this.opts.uriResolver,t,u))}let s;if(typeof r!="boolean"&&r.$ref&&!(0,t2.schemaHasRulesButRef)(r,this.RULES)){let c=(0,$r.resolveUrl)(this.opts.uriResolver,t,r.$ref);s=Om.call(this,n,c)}let{schemaId:a}=this.opts;if(s=s||new ya({schema:r,schemaId:a,root:n,baseId:t}),s.schema!==s.root.schema)return s}i(gS,"getJsonPointer")});var n2=D((w2e,uY)=>{uY.exports={$id:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#",description:"Meta-schema for $data reference (JSON AnySchema extension proposal)",type:"object",required:["$data"],properties:{$data:{type:"string",anyOf:[{format:"relative-json-pointer"},{format:"json-pointer"}]}},additionalProperties:!1}});var kS=D((b2e,u2)=>{"use strict";var dY=RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu),vS=RegExp.prototype.test.bind(/^(?:(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)$/u),Es=RegExp.prototype.test.bind(/^[\da-f]{2}$/iu),wS=RegExp.prototype.test.bind(/^[\da-z\-._~]$/iu),s2=RegExp.prototype.test.bind(/^[A-Za-z0-9\-._~!$&'()*+,;=:@/]$/u),bS=RegExp.prototype.test.bind(/^[A-Za-z0-9\-._~!$&'()*+,;=:@/?]$/u),pY=RegExp.prototype.test.bind(/^[A-Za-z0-9\-._~!$&'()*+,;=:]$/u),Ct=new Array(256);{let e="0123456789ABCDEF";for(let t=0;t<256;t++)Ct[t]="%"+e[t>>4]+e[t&15]}function dt(e){return e<2048?Ct[192|e>>6]+Ct[128|e&63]:e<65536?Ct[224|e>>12]+Ct[128|e>>6&63]+Ct[128|e&63]:Ct[240|e>>18]+Ct[128|e>>12&63]+Ct[128|e>>6&63]+Ct[128|e&63]}i(dt,"percentEncodeNonAscii");function fY(e){let t="",r=0,n=0;for(n=0;n<e.length;n++)if(r=e[n].charCodeAt(0),r!==48){if(!(r>=48&&r<=57||r>=65&&r<=70||r>=97&&r<=102))return"";t+=e[n];break}for(n+=1;n<e.length;n++){if(r=e[n].charCodeAt(0),!(r>=48&&r<=57||r>=65&&r<=70||r>=97&&r<=102))return"";t+=e[n]}return t}i(fY,"stringArrayToHexStripped");var mY=RegExp.prototype.test.bind(/^[\dA-Fa-f]{1,4}$/),hY=RegExp.prototype.test.bind(/^[vV][\dA-Fa-f]+\.[A-Za-z\d\-._~!$&'()*+,;=:]+$/),gY=RegExp.prototype.test.bind(/^[A-Za-z\d\-._~]$/),yY=RegExp.prototype.test.bind(/[^!"$&'()*+,\-.;=_`a-z{}~]/u);function xY(e){if(e.length===0)return!1;for(let t=0;t<e.length;t++)if(!gY(e[t])){if(e[t]==="%"&&t+2<e.length&&Es(e.slice(t+1,t+3))){t+=2;continue}return!1}return!0}i(xY,"isZoneIdentifier");function o2(e){let t=-1,r=0,n=-1,o=0;for(let c=0;c<e.length;c++)e[c]==="0"?(n===-1&&(n=c),o++,o>r&&(r=o,t=n)):(n=-1,o=0);if(r<2)return e.join(":");let s=e.slice(0,t).join(":"),a=e.slice(t+r).join(":");return s+"::"+a}i(o2,"compressIPv6ZeroRun");function _Y(e){let t=e.indexOf("::");if(t!==-1&&e.indexOf("::",t+1)!==-1)return;let r=t===-1?e.split(":"):e.slice(0,t).split(":"),n=t===-1?[]:e.slice(t+2).split(":");t!==-1&&(r.length===1&&r[0]===""&&(r.length=0),n.length===1&&n[0]===""&&(n.length=0));let o=r.concat(n),s=0;for(let c=0;c<o.length;c++){let l=o[c];if(l==="")return;if(l.indexOf(".")!==-1){if(c!==o.length-1||t!==-1&&n.length===0||!vS(l))return;s+=2;continue}if(!mY(l))return;o[c]=parseInt(l,16).toString(16),s++}if(t===-1)return s!==8?void 0:o2(o);if(s>=8)return;let a=o.slice(0,r.length);for(let c=s;c<8;c++)a.push("0");for(let c=r.length;c<o.length;c++)a.push(o[c]);return o2(a)}i(_Y,"normalizeIPv6Address");function _S(e){let t=e[0]==="["&&e[e.length-1]==="]";if((e[0]==="["||e[e.length-1]==="]")&&!t)return{host:e,isIPV6:!1,error:!0};let n=t?e.slice(1,-1):e;if(t&&hY(n))return n=n.toLowerCase(),{host:`[${n}]`,escapedHost:n,isIPV6:!1,isIPVFuture:!0};if(vY(n,":")<2)return{host:e,isIPV6:!1,error:t};let o="",s=n.indexOf("%");if(s!==-1){let c=n.slice(s,s+3).toLowerCase()==="%25"?3:1;if(o=n.slice(s+c),!xY(o))return{host:e,isIPV6:!1,error:!0};n=n.slice(0,s)}let a=_Y(n);return a===void 0?{host:e,isIPV6:!1,error:!0}:{host:a+(o?"%"+o:""),escapedHost:a+(o?"%25"+o:""),isIPV6:!0}}i(_S,"normalizeIPv6");function vY(e,t){let r=0;for(let n=0;n<e.length;n++)e[n]===t&&r++;return r}i(vY,"findToken");function wY(e){let t=e,r=[],n=-1,o=0;for(;o=t.length;){if(o===1){if(t===".")break;if(t==="/"){r.push("/");break}else{r.push(t);break}}else if(o===2){if(t[0]==="."){if(t[1]===".")break;if(t[1]==="/"){t=t.slice(2);continue}}else if(t[0]==="/"&&(t[1]==="."||t[1]==="/")){r.push("/");break}}else if(o===3&&t==="/.."){r.length!==0&&r.pop(),r.push("/");break}if(t[0]==="."){if(t[1]==="."){if(t[2]==="/"){t=t.slice(3);continue}}else if(t[1]==="/"){t=t.slice(2);continue}}else if(t[0]==="/"&&t[1]==="."){if(t[2]==="/"){t=t.slice(2);continue}else if(t[2]==="."&&t[3]==="/"){t=t.slice(3),r.length!==0&&r.pop();continue}}if((n=t.indexOf("/",1))===-1){r.push(t);break}else r.push(t.slice(0,n)),t=t.slice(n)}return r.join("")}i(wY,"removeDotSegments");var bY={"@":"%40","/":"%2F","?":"%3F","#":"%23",":":"%3A"},SY=/[@/?#:]/g,kY=/[@/?#]/g;function i2(e,t){let r=t?kY:SY;return r.lastIndex=0,e.replace(r,n=>bY[n])}i(i2,"reescapeHostDelimiters");function a2(e,t=!1){if(e.indexOf("%")===-1)return e;let r="";for(let n=0;n<e.length;n++){if(e[n]==="%"&&n+2<e.length){let o=e.slice(n+1,n+3);if(Es(o)){let s=o.toUpperCase(),a=String.fromCharCode(parseInt(s,16));t&&wS(a)?r+=a:r+="%"+s,n+=2;continue}}r+=e[n]}return r}i(a2,"normalizePercentEncoding");function $Y(e){let t="";for(let r=0;r<e.length;r++){let n=e[r];if(n==="%"&&r+2<e.length){let o=e.slice(r+1,r+3);if(Es(o)){let s=o.toUpperCase(),a=String.fromCharCode(parseInt(s,16));a!=="."&&wS(a)?t+=a:t+="%"+s,r+=2;continue}}if(s2(n))t+=n;else{let o=e.charCodeAt(r);if(o<128)t+=l2(o)?n:Ct[o];else if(o<55296||o>57343)t+=dt(o);else if(o<=56319&&r+1<e.length){let s=e.charCodeAt(r+1);s>=56320&&s<=57343?(t+=dt(65536+(o-55296<<10)+(s-56320)),r++):t+=dt(65533)}else t+=dt(65533)}}return t}i($Y,"normalizePathEncoding");function EY(e,t=!1){let r="",n=t&&e[0]!=="/";for(let o=0;o<e.length;o++){let s=e[o];if(s==="%"&&o+2<e.length){let a=e.slice(o+1,o+3);if(Es(a)){r+="%"+a.toUpperCase(),o+=2;continue}}if(s==="/"&&(n=!1),s2(s)&&(s!==":"||!n))r+=s;else{let a=e.charCodeAt(o);if(a<128)r+=Ct[a];else if(a<55296||a>57343)r+=dt(a);else if(a<=56319&&o+1<e.length){let c=e.charCodeAt(o+1);c>=56320&&c<=57343?(r+=dt(65536+(a-55296<<10)+(c-56320)),o++):r+=dt(65533)}else r+=dt(65533)}}return r}i(EY,"serializePathEncoding");function SS(e,t){let r="";for(let n=0;n<e.length;n++){let o=e[n];if(o==="%"&&n+2<e.length){let s=e.slice(n+1,n+3);if(Es(s)){r+="%"+s.toUpperCase(),n+=2;continue}}if(t(o))r+=o;else{let s=e.charCodeAt(n);if(s<128)r+=Ct[s];else if(s<55296||s>57343)r+=dt(s);else if(s<=56319&&n+1<e.length){let a=e.charCodeAt(n+1);a>=56320&&a<=57343?(r+=dt(65536+(s-55296<<10)+(a-56320)),n++):r+=dt(65533)}else r+=dt(65533)}}return r}i(SS,"encodeComponent");function c2(e){return SS(e,pY)}i(c2,"encodeUserinfo");function NY(e){return SS(e,bS)}i(NY,"encodeQuery");function TY(e){return SS(e,bS)}i(TY,"encodeFragment");function l2(e){return e>=48&&e<=57||e>=65&&e<=90||e>=97&&e<=122||e===42||e===43||e===45||e===46||e===47||e===64||e===95}i(l2,"isEscapeSafe");function zY(e){let t="";for(let r=0;r<e.length;r++){let n=e[r];if(n==="%"&&r+2<e.length){let o=e.slice(r+1,r+3);if(Es(o)){let s=o.toUpperCase(),a=String.fromCharCode(parseInt(s,16));wS(a)?t+=a:t+="%"+s,r+=2;continue}}if(bS(n))t+=n;else{let o=e.charCodeAt(r);if(o<128)t+=l2(o)?n:Ct[o];else if(o<55296||o>57343)t+=dt(o);else if(o<=56319&&r+1<e.length){let s=e.charCodeAt(r+1);s>=56320&&s<=57343?(t+=dt(65536+(o-55296<<10)+(s-56320)),r++):t+=dt(65533)}else t+=dt(65533)}}return t}i(zY,"normalizeQueryFragmentEncoding");function CY(e){let t="";for(let r=0;r<e.length;r++){if(e[r]==="%"&&r+2<e.length){let n=e.slice(r+1,r+3);if(Es(n)){t+="%"+n.toUpperCase(),r+=2;continue}}t+=escape(e[r])}return t}i(CY,"escapePreservingEscapes");function IY(e){let t=[];if(e.userinfo!==void 0&&(t.push(c2(e.userinfo)),t.push("@")),e.host!==void 0){let r=e.host;if(!vS(r)){let n=_S(r);n.isIPV6!==!0&&n.isIPVFuture!==!0&&(r=a2(r,!0),n=_S(r)),n.isIPV6===!0||n.isIPVFuture===!0?r=`[${n.escapedHost}]`:r=i2(r,!1)}t.push(r)}return(typeof e.port=="number"||typeof e.port=="string")&&(t.push(":"),t.push(String(e.port))),t.length?t.join(""):void 0}i(IY,"recomposeAuthority");u2.exports={nonSimpleDomain:yY,recomposeAuthority:IY,reescapeHostDelimiters:i2,normalizePercentEncoding:a2,normalizePathEncoding:$Y,serializePathEncoding:EY,normalizeQueryFragmentEncoding:zY,encodeUserinfo:c2,encodeQuery:NY,encodeFragment:TY,escapePreservingEscapes:CY,removeDotSegments:wY,isIPv4:vS,isUUID:dY,normalizeIPv6:_S,stringArrayToHexStripped:fY}});var h2=D((k2e,m2)=>{"use strict";var{isUUID:PY}=kS(),RY=/^([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-./:;=@]|%[\da-f]{2})+)$/iu,OY=["http","https","ws","wss","urn","urn:uuid"];function AY(e){return OY.indexOf(e)!==-1}i(AY,"isValidSchemeName");function $S(e){return e.secure===!0?!0:e.secure===!1?!1:e.scheme?e.scheme.length===3&&(e.scheme[0]==="w"||e.scheme[0]==="W")&&(e.scheme[1]==="s"||e.scheme[1]==="S")&&(e.scheme[2]==="s"||e.scheme[2]==="S"):!1}i($S,"wsIsSecure");function d2(e){return e.host||(e.error=e.error||"HTTP URIs must have a host."),e}i(d2,"httpParse");function p2(e){let t=String(e.scheme).toLowerCase()==="https";return(e.port===(t?443:80)||e.port==="")&&(e.port=void 0),e.path||(e.path="/"),e}i(p2,"httpSerialize");function jY(e){return e.secure=$S(e),e.resourceName=(e.path||"/")+(e.query?"?"+e.query:""),e.path=void 0,e.query=void 0,e}i(jY,"wsParse");function DY(e){if((e.port===($S(e)?443:80)||e.port==="")&&(e.port=void 0),typeof e.secure=="boolean"&&(e.scheme=e.secure?"wss":"ws",e.secure=void 0),e.resourceName){let t=e.resourceName.indexOf("?"),r=t===-1?e.resourceName:e.resourceName.slice(0,t);e.path=r&&r!=="/"?r:void 0,e.query=t===-1?void 0:e.resourceName.slice(t+1),e.resourceName=void 0}return e.fragment=void 0,e}i(DY,"wsSerialize");function MY(e,t){if(!e.path)return e.error="URN can not be parsed",e;let r=e.path.match(RY);if(r&&r[0]===e.path){let n=t.scheme||e.scheme||"urn";e.nid=r[1].toLowerCase(),e.nss=r[2];let o=`${n}:${t.nid||e.nid}`,s=ES(o);e.path=void 0,s&&(e=s.parse(e,t))}else e.error=e.error||"URN can not be parsed.";return e}i(MY,"urnParse");function ZY(e,t){if(e.nid===void 0)throw new Error("URN without nid cannot be serialized");let r=t.scheme||e.scheme||"urn",n=e.nid.toLowerCase(),o=`${r}:${t.nid||n}`,s=ES(o);s&&(e=s.serialize(e,t));let a=e,c=e.nss;return a.path=`${n||t.nid}:${c}`,t.skipEscape=!0,a}i(ZY,"urnSerialize");function LY(e,t){let r=e;return r.uuid=r.nss,r.nss=void 0,!t.tolerant&&(!r.uuid||!PY(r.uuid))&&(r.error=r.error||"UUID is not valid."),r}i(LY,"urnuuidParse");function FY(e){let t=e;return t.nss=(e.uuid||"").toLowerCase(),t}i(FY,"urnuuidSerialize");var f2={scheme:"http",domainHost:!0,parse:d2,serialize:p2},UY={scheme:"https",domainHost:f2.domainHost,parse:d2,serialize:p2},jm={scheme:"ws",domainHost:!0,parse:jY,serialize:DY},qY={scheme:"wss",domainHost:jm.domainHost,parse:jm.parse,serialize:jm.serialize},HY={scheme:"urn",parse:MY,serialize:ZY,skipNormalize:!0},BY={scheme:"urn:uuid",parse:LY,serialize:FY,skipNormalize:!0},Dm={http:f2,https:UY,ws:jm,wss:qY,urn:HY,"urn:uuid":BY};Object.setPrototypeOf(Dm,null);function ES(e){return e&&(Dm[e]||Dm[e.toLowerCase()])||void 0}i(ES,"getSchemeHandler");m2.exports={wsIsSecure:$S,SCHEMES:Dm,isValidSchemeName:AY,getSchemeHandler:ES}});var z2=D((E2e,Lm)=>{"use strict";var{normalizeIPv6:v2,removeDotSegments:Xl,recomposeAuthority:VY,normalizePercentEncoding:w2,normalizePathEncoding:GY,serializePathEncoding:g2,normalizeQueryFragmentEncoding:y2,encodeQuery:WY,encodeFragment:KY,reescapeHostDelimiters:JY,isIPv4:b2,nonSimpleDomain:YY}=kS(),{SCHEMES:S2,getSchemeHandler:NS}=h2(),k2=/^[A-Za-z][A-Za-z0-9+.-]*$/u,$2="URI scheme is malformed.";function x2(e){let t=unescape(String(e));if(!k2.test(t))throw new TypeError($2);return t}i(x2,"decodeValidScheme");function XY(e,t){return typeof e=="string"?e=iX(e,t):typeof e=="object"&&(e=Zm(Ns(e,t),t)),e}i(XY,"normalize");function QY(e,t,r){let n=r?Object.assign({scheme:"null"},r):{scheme:"null"},{parsed:o,malformedAuthorityOrPort:s,malformedPercentEncoding:a,malformedSchemeSpecific:c,malformedHost:l,malformedScheme:u}=Mm(e,n),{parsed:d,malformedAuthorityOrPort:p,malformedPercentEncoding:h,malformedSchemeSpecific:m,malformedHost:g,malformedScheme:_}=Mm(t,n);if(s||p||a||h||c||m||l||g||u||_)throw new Error(o.error||d.error||"URI is malformed.");let x=E2(o,d,n,!0),v=NS(r&&r.scheme||x.scheme),w=x.host,b=w!==void 0&&w!==""&&(b2(w)||v2(w).isIPV6);N2(x,r||{},v,b);let S=w&&w.indexOf("%")!==-1&&!/\P{ASCII}/u.test(w);if(x.error&&!S)throw new Error(x.error);return n.skipEscape=!0,Ns(x,n)}i(QY,"resolve");function E2(e,t,r,n){let o={};return n||(e=Zm(Ns(e,r),r),t=Zm(Ns(t,r),r)),r=r||{},!r.tolerant&&t.scheme?(o.scheme=t.scheme,o.userinfo=t.userinfo,o.host=t.host,o.port=t.port,o.path=Xl(t.path||""),o.query=t.query):(t.userinfo!==void 0||t.host!==void 0||t.port!==void 0?(o.userinfo=t.userinfo,o.host=t.host,o.port=t.port,o.path=Xl(t.path||""),o.query=t.query):(t.path?(t.path[0]==="/"?o.path=Xl(t.path):((e.userinfo!==void 0||e.host!==void 0||e.port!==void 0)&&!e.path?o.path="/"+t.path:e.path?o.path=e.path.slice(0,e.path.lastIndexOf("/")+1)+t.path:o.path=t.path,o.path=Xl(o.path)),o.query=t.query):(o.path=e.path,t.query!==void 0?o.query=t.query:o.query=e.query),o.userinfo=e.userinfo,o.host=e.host,o.port=e.port),o.scheme=e.scheme),o.fragment=t.fragment,o}i(E2,"resolveComponent");function eX(e,t,r){let n=_2(e,r),o=_2(t,r);return n!==void 0&&o!==void 0&&n===o}i(eX,"equal");function Ns(e,t){let r={host:e.host,scheme:e.scheme,userinfo:e.userinfo,port:e.port,path:e.path,query:e.query,nid:e.nid,nss:e.nss,uuid:e.uuid,fragment:e.fragment,reference:e.reference,resourceName:e.resourceName,secure:e.secure,error:""},n=Object.assign({},t),o=[];r.scheme&&(r.scheme=x2(r.scheme));let s=NS(n.scheme||r.scheme);s&&s.serialize&&s.serialize(r,n);let a=r.userinfo!==void 0||r.host!==void 0||r.port!==void 0,c=!n.skipEscape&&r.scheme===void 0&&!a;r.path!==void 0&&(n.skipEscape?r.path=w2(r.path):r.path=g2(r.path,c)),n.reference!=="suffix"&&r.scheme&&(r.scheme=x2(r.scheme),o.push(r.scheme,":"));let l=VY(r);if(l!==void 0&&(n.reference!=="suffix"&&o.push("//"),o.push(l),r.path&&r.path[0]!=="/"&&o.push("/")),r.path!==void 0){let u=r.path;!n.absolutePath&&(!s||!s.absolutePath)&&(u=Xl(u)),c&&(u=g2(u,!0)),l===void 0&&u[0]==="/"&&u[1]==="/"&&(u="/%2F"+u.slice(2)),o.push(u)}return r.query!==void 0&&o.push("?",WY(r.query)),r.fragment!==void 0&&o.push("#",KY(r.fragment)),o.join("")}i(Ns,"serialize");var tX=/^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u,rX=/^(?:[^#/:?]+:)?\/\/([^/?#]*)/,nX=/^(?:[^#/:?]+:)?([/\\\t\n\r]*)/;function oX(e,t){if(t[2]!==void 0&&e.path&&e.path[0]!=="/")return'URI path must start with "/" when authority is present.';if(typeof e.port=="number"&&(e.port<0||e.port>65535))return"URI port is malformed."}i(oX,"getParseError");function Yl(e){if(e===void 0)return!1;let t=e.indexOf("%");for(;t!==-1;){if(t+2>=e.length||!/^[\da-f]{2}$/iu.test(e.slice(t+1,t+3)))return!0;t=e.indexOf("%",t+3)}return!1}i(Yl,"hasMalformedPercentEncoding");function sX(e){let t=e[4];return Yl(e[3])||t!==void 0&&!(t[0]==="["&&t[t.length-1]==="]")&&Yl(t)||Yl(e[6])||Yl(e[7])||Yl(e[8])}i(sX,"hasMalformedComponentPercentEncoding");function N2(e,t,r,n){if(!t.unicodeSupport&&(!r||!r.unicodeSupport)&&e.host&&e.host[0]!=="["&&(t.domainHost||r&&r.domainHost)&&n===!1&&YY(e.host))try{e.host=new URL("http://"+e.host).hostname}catch(o){return e.error=e.error||"Host's domain name can not be converted to ASCII: "+o,!0}return!1}i(N2,"canonicalizeHost");function Mm(e,t){let r=Object.assign({},t),n={scheme:void 0,userinfo:void 0,host:"",port:void 0,path:"",query:void 0,fragment:void 0},o=!1,s=!1,a=!1,c=!1,l=!1,u=!1,d=!1;r.reference==="suffix"&&(r.scheme?e=r.scheme+":"+e:e="//"+e);let p=e.match(rX);p!==null&&p[1].indexOf("\\")!==-1&&(n.error="URI authority must not contain a literal backslash.",o=!0);let h=e.match(nX);if(h!==null){let g=h[1],_=g.replace(/[\t\n\r]/g,"");_.length>=2&&(_.slice(0,2)!=="//"?(n.error=n.error||"URI authority must not contain a literal backslash.",o=!0):g.length!==_.length&&(n.error=n.error||"URI authority introducer must not contain whitespace.",o=!0))}let m=e.match(tX);if(m){if(n.scheme=m[1],n.userinfo=m[3],n.host=m[4],n.port=parseInt(m[5],10),n.path=m[6]||"",n.query=m[7],n.fragment=m[8],n.scheme!==void 0){let x=unescape(n.scheme);k2.test(x)?n.scheme=x.toLowerCase():(n.error=n.error||$2,u=!0)}s=sX(m),s&&(n.error=n.error||"URI contains malformed percent-encoding."),isNaN(n.port)&&(n.port=m[5]);let g=oX(n,m);if(g!==void 0&&(n.error=n.error||g,o=!0),n.host)if(b2(n.host)===!1){let v=n.host[0]==="["&&n.host[n.host.length-1]==="]",w=v2(n.host);d=w.isIPV6||w.isIPVFuture===!0,l=v&&w.error===!0,n.host=d?w.host:w.host.toLowerCase(),l&&(n.error=n.error||"URI host is malformed.",o=!0)}else d=!0;n.scheme===void 0&&n.userinfo===void 0&&n.host===void 0&&n.port===void 0&&n.query===void 0&&!n.path?n.reference="same-document":n.scheme===void 0?n.reference="relative":n.fragment===void 0?n.reference="absolute":n.reference="uri",r.reference&&r.reference!=="suffix"&&r.reference!==n.reference&&(n.error=n.error||"URI is not a "+r.reference+" reference.");let _=NS(r.scheme||n.scheme);if(c=N2(n,r,_,d),!_||_&&!_.skipNormalize){if(e.indexOf("%")!==-1&&n.host!==void 0&&!l){let x=d?n.host:w2(n.host,!0);n.host=JY(x,d)}n.path&&(n.path=GY(n.path)),n.query&&(n.query=y2(n.query)),n.fragment&&(n.fragment=y2(n.fragment))}_&&_.parse&&(_.parse(n,r),_===S2.urn&&n.nid===void 0&&(a=!0))}else n.error=n.error||"URI can not be parsed.";return{parsed:n,malformedAuthorityOrPort:o,malformedPercentEncoding:s,malformedSchemeSpecific:a,malformedHost:c,malformedScheme:u}}i(Mm,"parseWithStatus");function Zm(e,t){return Mm(e,t).parsed}i(Zm,"parse");function iX(e,t){return T2(e,t).normalized}i(iX,"normalizeString");function T2(e,t){let{parsed:r,malformedAuthorityOrPort:n,malformedPercentEncoding:o,malformedSchemeSpecific:s,malformedHost:a,malformedScheme:c}=Mm(e,t);return{normalized:n||o||s||a||c?e:Ns(r,t),malformedAuthorityOrPort:n,malformedPercentEncoding:o,malformedSchemeSpecific:s,malformedHost:a,malformedScheme:c}}i(T2,"normalizeStringWithStatus");function _2(e,t){if(typeof e!="string"&&typeof e!="object")return;let r;try{r=typeof e=="string"?e:Ns(e,t)}catch{return}let{normalized:n,malformedAuthorityOrPort:o,malformedPercentEncoding:s,malformedSchemeSpecific:a,malformedHost:c,malformedScheme:l}=T2(r,t);return o||s||a||c||l?void 0:n}i(_2,"normalizeComparableURI");var TS={SCHEMES:S2,normalize:XY,resolve:QY,resolveComponent:E2,equal:eX,serialize:Ns,parse:Zm};Lm.exports=TS;Lm.exports.default=TS;Lm.exports.fastUri=TS});var I2=D(zS=>{"use strict";Object.defineProperty(zS,"__esModule",{value:!0});var C2=z2();C2.code='require("ajv/dist/runtime/uri").default';zS.default=C2});var Z2=D(ot=>{"use strict";Object.defineProperty(ot,"__esModule",{value:!0});ot.CodeGen=ot.Name=ot.nil=ot.stringify=ot.str=ot._=ot.KeywordCxt=void 0;var aX=Kl();Object.defineProperty(ot,"KeywordCxt",{enumerable:!0,get:function(){return aX.KeywordCxt}});var xa=ne();Object.defineProperty(ot,"_",{enumerable:!0,get:function(){return xa._}});Object.defineProperty(ot,"str",{enumerable:!0,get:function(){return xa.str}});Object.defineProperty(ot,"stringify",{enumerable:!0,get:function(){return xa.stringify}});Object.defineProperty(ot,"nil",{enumerable:!0,get:function(){return xa.nil}});Object.defineProperty(ot,"Name",{enumerable:!0,get:function(){return xa.Name}});Object.defineProperty(ot,"CodeGen",{enumerable:!0,get:function(){return xa.CodeGen}});var cX=Rm(),j2=Jl(),lX=K0(),Ql=Am(),uX=ne(),eu=Vl(),Fm=Bl(),IS=pe(),P2=n2(),dX=I2(),D2=i((e,t)=>new RegExp(e,t),"defaultRegExp");D2.code="new RegExp";var pX=["removeAdditional","useDefaults","coerceTypes"],fX=new Set(["validate","serialize","parse","wrapper","root","schema","keyword","pattern","formats","validate$data","func","obj","Error"]),mX={errorDataPath:"",format:"`validateFormats: false` can be used instead.",nullable:'"nullable" keyword is supported by default.',jsonPointers:"Deprecated jsPropertySyntax can be used instead.",extendRefs:"Deprecated ignoreKeywordsWithRef can be used instead.",missingRefs:"Pass empty schema with $id that should be ignored to ajv.addSchema.",processCode:"Use option `code: {process: (code, schemaEnv: object) => string}`",sourceCode:"Use option `code: {source: true}`",strictDefaults:"It is default now, see option `strict`.",strictKeywords:"It is default now, see option `strict`.",uniqueItems:'"uniqueItems" keyword is always validated.',unknownFormats:"Disable strict mode or pass `true` to `ajv.addFormat` (or `formats` option).",cache:"Map is used as cache, schema object as key.",serialize:"Map is used as cache, schema object as key.",ajvErrors:"It is default now."},hX={ignoreKeywordsWithRef:"",jsPropertySyntax:"",unicode:'"minLength"/"maxLength" account for unicode characters by default.'},R2=200;function gX(e){var t,r,n,o,s,a,c,l,u,d,p,h,m,g,_,x,v,w,b,S,T,K,A,Y,W;let L=e.strict,X=(t=e.code)===null||t===void 0?void 0:t.optimize,se=X===!0||X===void 0?1:X||0,ur=(n=(r=e.code)===null||r===void 0?void 0:r.regExp)!==null&&n!==void 0?n:D2,be=(o=e.uriResolver)!==null&&o!==void 0?o:dX.default;return{strictSchema:(a=(s=e.strictSchema)!==null&&s!==void 0?s:L)!==null&&a!==void 0?a:!0,strictNumbers:(l=(c=e.strictNumbers)!==null&&c!==void 0?c:L)!==null&&l!==void 0?l:!0,strictTypes:(d=(u=e.strictTypes)!==null&&u!==void 0?u:L)!==null&&d!==void 0?d:"log",strictTuples:(h=(p=e.strictTuples)!==null&&p!==void 0?p:L)!==null&&h!==void 0?h:"log",strictRequired:(g=(m=e.strictRequired)!==null&&m!==void 0?m:L)!==null&&g!==void 0?g:!1,code:e.code?{...e.code,optimize:se,regExp:ur}:{optimize:se,regExp:ur},loopRequired:(_=e.loopRequired)!==null&&_!==void 0?_:R2,loopEnum:(x=e.loopEnum)!==null&&x!==void 0?x:R2,meta:(v=e.meta)!==null&&v!==void 0?v:!0,messages:(w=e.messages)!==null&&w!==void 0?w:!0,inlineRefs:(b=e.inlineRefs)!==null&&b!==void 0?b:!0,schemaId:(S=e.schemaId)!==null&&S!==void 0?S:"$id",addUsedSchema:(T=e.addUsedSchema)!==null&&T!==void 0?T:!0,validateSchema:(K=e.validateSchema)!==null&&K!==void 0?K:!0,validateFormats:(A=e.validateFormats)!==null&&A!==void 0?A:!0,unicodeRegExp:(Y=e.unicodeRegExp)!==null&&Y!==void 0?Y:!0,int32range:(W=e.int32range)!==null&&W!==void 0?W:!0,uriResolver:be}}i(gX,"requiredOptions");var PS=class PS{constructor(t={}){this.schemas={},this.refs={},this.formats=Object.create(null),this._compilations=new Set,this._loading={},this._cache=new Map,t=this.opts={...t,...gX(t)};let{es5:r,lines:n}=this.opts.code;this.scope=new uX.ValueScope({scope:{},prefixes:fX,es5:r,lines:n}),this.logger=bX(t.logger);let o=t.validateFormats;t.validateFormats=!1,this.RULES=(0,lX.getRules)(),O2.call(this,mX,t,"NOT SUPPORTED"),O2.call(this,hX,t,"DEPRECATED","warn"),this._metaOpts=vX.call(this),t.formats&&xX.call(this),this._addVocabularies(),this._addDefaultMetaSchema(),t.keywords&&_X.call(this,t.keywords),typeof t.meta=="object"&&this.addMetaSchema(t.meta),yX.call(this),t.validateFormats=o}_addVocabularies(){this.addKeyword("$async")}_addDefaultMetaSchema(){let{$data:t,meta:r,schemaId:n}=this.opts,o=P2;n==="id"&&(o={...P2},o.id=o.$id,delete o.$id),r&&t&&this.addMetaSchema(o,o[n],!1)}defaultMeta(){let{meta:t,schemaId:r}=this.opts;return this.opts.defaultMeta=typeof t=="object"?t[r]||t:void 0}validate(t,r){let n;if(typeof t=="string"){if(n=this.getSchema(t),!n)throw new Error(`no schema with key or ref "${t}"`)}else n=this.compile(t);let o=n(r);return"$async"in n||(this.errors=n.errors),o}compile(t,r){let n=this._addSchema(t,r);return n.validate||this._compileSchemaEnv(n)}compileAsync(t,r){if(typeof this.opts.loadSchema!="function")throw new Error("options.loadSchema should be a function");let{loadSchema:n}=this.opts;return o.call(this,t,r);async function o(d,p){await s.call(this,d.$schema);let h=this._addSchema(d,p);return h.validate||a.call(this,h)}async function s(d){d&&!this.getSchema(d)&&await o.call(this,{$ref:d},!0)}async function a(d){try{return this._compileSchemaEnv(d)}catch(p){if(!(p instanceof j2.default))throw p;return c.call(this,p),await l.call(this,p.missingSchema),a.call(this,d)}}function c({missingSchema:d,missingRef:p}){if(this.refs[d])throw new Error(`AnySchema ${d} is loaded but ${p} cannot be resolved`)}async function l(d){let p=await u.call(this,d);this.refs[d]||await s.call(this,p.$schema),this.refs[d]||this.addSchema(p,d,r)}async function u(d){let p=this._loading[d];if(p)return p;try{return await(this._loading[d]=n(d))}finally{delete this._loading[d]}}}addSchema(t,r,n,o=this.opts.validateSchema){if(Array.isArray(t)){for(let a of t)this.addSchema(a,void 0,n,o);return this}let s;if(typeof t=="object"){let{schemaId:a}=this.opts;if(s=t[a],s!==void 0&&typeof s!="string")throw new Error(`schema ${a} must be string`)}return r=(0,eu.normalizeId)(r||s),this._checkUnique(r),this.schemas[r]=this._addSchema(t,n,r,o,!0),this}addMetaSchema(t,r,n=this.opts.validateSchema){return this.addSchema(t,r,!0,n),this}validateSchema(t,r){if(typeof t=="boolean")return!0;let n;if(n=t.$schema,n!==void 0&&typeof n!="string")throw new Error("$schema must be a string");if(n=n||this.opts.defaultMeta||this.defaultMeta(),!n)return this.logger.warn("meta-schema not available"),this.errors=null,!0;let o=this.validate(n,t);if(!o&&r){let s="schema is invalid: "+this.errorsText();if(this.opts.validateSchema==="log")this.logger.error(s);else throw new Error(s)}return o}getSchema(t){let r;for(;typeof(r=A2.call(this,t))=="string";)t=r;if(r===void 0){let{schemaId:n}=this.opts,o=new Ql.SchemaEnv({schema:{},schemaId:n});if(r=Ql.resolveSchema.call(this,o,t),!r)return;this.refs[t]=r}return r.validate||this._compileSchemaEnv(r)}removeSchema(t){if(t instanceof RegExp)return this._removeAllSchemas(this.schemas,t),this._removeAllSchemas(this.refs,t),this;switch(typeof t){case"undefined":return this._removeAllSchemas(this.schemas),this._removeAllSchemas(this.refs),this._cache.clear(),this;case"string":{let r=A2.call(this,t);return typeof r=="object"&&this._cache.delete(r.schema),delete this.schemas[t],delete this.refs[t],this}case"object":{let r=t;this._cache.delete(r);let n=t[this.opts.schemaId];return n&&(n=(0,eu.normalizeId)(n),delete this.schemas[n],delete this.refs[n]),this}default:throw new Error("ajv.removeSchema: invalid parameter")}}addVocabulary(t){for(let r of t)this.addKeyword(r);return this}addKeyword(t,r){let n;if(typeof t=="string")n=t,typeof r=="object"&&(this.logger.warn("these parameters are deprecated, see docs for addKeyword"),r.keyword=n);else if(typeof t=="object"&&r===void 0){if(r=t,n=r.keyword,Array.isArray(n)&&!n.length)throw new Error("addKeywords: keyword must be string or non-empty array")}else throw new Error("invalid addKeywords parameters");if(kX.call(this,n,r),!r)return(0,IS.eachItem)(n,s=>CS.call(this,s)),this;EX.call(this,r);let o={...r,type:(0,Fm.getJSONTypes)(r.type),schemaType:(0,Fm.getJSONTypes)(r.schemaType)};return(0,IS.eachItem)(n,o.type.length===0?s=>CS.call(this,s,o):s=>o.type.forEach(a=>CS.call(this,s,o,a))),this}getKeyword(t){let r=this.RULES.all[t];return typeof r=="object"?r.definition:!!r}removeKeyword(t){let{RULES:r}=this;delete r.keywords[t],delete r.all[t];for(let n of r.rules){let o=n.rules.findIndex(s=>s.keyword===t);o>=0&&n.rules.splice(o,1)}return this}addFormat(t,r){return typeof r=="string"&&(r=new RegExp(r)),this.formats[t]=r,this}errorsText(t=this.errors,{separator:r=", ",dataVar:n="data"}={}){return!t||t.length===0?"No errors":t.map(o=>`${n}${o.instancePath} ${o.message}`).reduce((o,s)=>o+r+s)}$dataMetaSchema(t,r){let n=this.RULES.all;t=JSON.parse(JSON.stringify(t));for(let o of r){let s=o.split("/").slice(1),a=t;for(let c of s)a=a[c];for(let c in n){let l=n[c];if(typeof l!="object")continue;let{$data:u}=l.definition,d=a[c];u&&d&&(a[c]=M2(d))}}return t}_removeAllSchemas(t,r){for(let n in t){let o=t[n];(!r||r.test(n))&&(typeof o=="string"?delete t[n]:o&&!o.meta&&(this._cache.delete(o.schema),delete t[n]))}}_addSchema(t,r,n,o=this.opts.validateSchema,s=this.opts.addUsedSchema){let a,{schemaId:c}=this.opts;if(typeof t=="object")a=t[c];else{if(this.opts.jtd)throw new Error("schema must be object");if(typeof t!="boolean")throw new Error("schema must be object or boolean")}let l=this._cache.get(t);if(l!==void 0)return l;n=(0,eu.normalizeId)(a||n);let u=eu.getSchemaRefs.call(this,t,n);return l=new Ql.SchemaEnv({schema:t,schemaId:c,meta:r,baseId:n,localRefs:u}),this._cache.set(l.schema,l),s&&!n.startsWith("#")&&(n&&this._checkUnique(n),this.refs[n]=l),o&&this.validateSchema(t,!0),l}_checkUnique(t){if(this.schemas[t]||this.refs[t])throw new Error(`schema with key or id "${t}" already exists`)}_compileSchemaEnv(t){if(t.meta?this._compileMetaSchema(t):Ql.compileSchema.call(this,t),!t.validate)throw new Error("ajv implementation error");return t.validate}_compileMetaSchema(t){let r=this.opts;this.opts=this._metaOpts;try{Ql.compileSchema.call(this,t)}finally{this.opts=r}}};i(PS,"Ajv");var tu=PS;tu.ValidationError=cX.default;tu.MissingRefError=j2.default;ot.default=tu;function O2(e,t,r,n="error"){for(let o in e){let s=o;s in t&&this.logger[n](`${r}: option ${o}. ${e[s]}`)}}i(O2,"checkOptions");function A2(e){return e=(0,eu.normalizeId)(e),this.schemas[e]||this.refs[e]}i(A2,"getSchEnv");function yX(){let e=this.opts.schemas;if(e)if(Array.isArray(e))this.addSchema(e);else for(let t in e)this.addSchema(e[t],t)}i(yX,"addInitialSchemas");function xX(){for(let e in this.opts.formats){let t=this.opts.formats[e];t&&this.addFormat(e,t)}}i(xX,"addInitialFormats");function _X(e){if(Array.isArray(e)){this.addVocabulary(e);return}this.logger.warn("keywords option as map is deprecated, pass array");for(let t in e){let r=e[t];r.keyword||(r.keyword=t),this.addKeyword(r)}}i(_X,"addInitialKeywords");function vX(){let e={...this.opts};for(let t of pX)delete e[t];return e}i(vX,"getMetaSchemaOptions");var wX={log(){},warn(){},error(){}};function bX(e){if(e===!1)return wX;if(e===void 0)return console;if(e.log&&e.warn&&e.error)return e;throw new Error("logger must implement log, warn and error methods")}i(bX,"getLogger");var SX=/^[a-z_$][a-z0-9_$:-]*$/i;function kX(e,t){let{RULES:r}=this;if((0,IS.eachItem)(e,n=>{if(r.keywords[n])throw new Error(`Keyword ${n} is already defined`);if(!SX.test(n))throw new Error(`Keyword ${n} has invalid name`)}),!!t&&t.$data&&!("code"in t||"validate"in t))throw new Error('$data keyword must have "code" or "validate" function')}i(kX,"checkKeyword");function CS(e,t,r){var n;let o=t?.post;if(r&&o)throw new Error('keyword with "post" flag cannot have "type"');let{RULES:s}=this,a=o?s.post:s.rules.find(({type:l})=>l===r);if(a||(a={type:r,rules:[]},s.rules.push(a)),s.keywords[e]=!0,!t)return;let c={keyword:e,definition:{...t,type:(0,Fm.getJSONTypes)(t.type),schemaType:(0,Fm.getJSONTypes)(t.schemaType)}};t.before?$X.call(this,a,c,t.before):a.rules.push(c),s.all[e]=c,(n=t.implements)===null||n===void 0||n.forEach(l=>this.addKeyword(l))}i(CS,"addRule");function $X(e,t,r){let n=e.rules.findIndex(o=>o.keyword===r);n>=0?e.rules.splice(n,0,t):(e.rules.push(t),this.logger.warn(`rule ${r} is not defined`))}i($X,"addBeforeRule");function EX(e){let{metaSchema:t}=e;t!==void 0&&(e.$data&&this.opts.$data&&(t=M2(t)),e.validateSchema=this.compile(t,!0))}i(EX,"keywordMetaschema");var NX={$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"};function M2(e){return{anyOf:[e,NX]}}i(M2,"schemaOrData")});var L2=D(RS=>{"use strict";Object.defineProperty(RS,"__esModule",{value:!0});var TX={keyword:"id",code(){throw new Error('NOT SUPPORTED: keyword "id", use "$id" for schema ID')}};RS.default=TX});var H2=D(Ts=>{"use strict";Object.defineProperty(Ts,"__esModule",{value:!0});Ts.callRef=Ts.getValidate=void 0;var zX=Jl(),F2=ar(),It=ne(),_a=zn(),U2=Am(),Um=pe(),CX={keyword:"$ref",schemaType:"string",code(e){let{gen:t,schema:r,it:n}=e,{baseId:o,schemaEnv:s,validateName:a,opts:c,self:l}=n,{root:u}=s;if((r==="#"||r==="#/")&&o===u.baseId)return p();let d=U2.resolveRef.call(l,u,o,r);if(d===void 0)throw new zX.default(n.opts.uriResolver,o,r);if(d instanceof U2.SchemaEnv)return h(d);return m(d);function p(){if(s===u)return qm(e,a,s,s.$async);let g=t.scopeValue("root",{ref:u});return qm(e,(0,It._)`${g}.validate`,u,u.$async)}function h(g){let _=q2(e,g);qm(e,_,g,g.$async)}function m(g){let _=t.scopeValue("schema",c.code.source===!0?{ref:g,code:(0,It.stringify)(g)}:{ref:g}),x=t.name("valid"),v=e.subschema({schema:g,dataTypes:[],schemaPath:It.nil,topSchemaRef:_,errSchemaPath:r},x);e.mergeEvaluated(v),e.ok(x)}}};function q2(e,t){let{gen:r}=e;return t.validate?r.scopeValue("validate",{ref:t.validate}):(0,It._)`${r.scopeValue("wrapper",{ref:t})}.validate`}i(q2,"getValidate");Ts.getValidate=q2;function qm(e,t,r,n){let{gen:o,it:s}=e,{allErrors:a,schemaEnv:c,opts:l}=s,u=l.passContext?_a.default.this:It.nil;n?d():p();function d(){if(!c.$async)throw new Error("async schema referenced by sync schema");let g=o.let("valid");o.try(()=>{o.code((0,It._)`await ${(0,F2.callValidateCode)(e,t,u)}`),m(t),a||o.assign(g,!0)},_=>{o.if((0,It._)`!(${_} instanceof ${s.ValidationError})`,()=>o.throw(_)),h(_),a||o.assign(g,!1)}),e.ok(g)}i(d,"callAsyncRef");function p(){e.result((0,F2.callValidateCode)(e,t,u),()=>m(t),()=>h(t))}i(p,"callSyncRef");function h(g){let _=(0,It._)`${g}.errors`;o.assign(_a.default.vErrors,(0,It._)`${_a.default.vErrors} === null ? ${_} : ${_a.default.vErrors}.concat(${_})`),o.assign(_a.default.errors,(0,It._)`${_a.default.vErrors}.length`)}i(h,"addErrorsFrom");function m(g){var _;if(!s.opts.unevaluated)return;let x=(_=r?.validate)===null||_===void 0?void 0:_.evaluated;if(s.props!==!0)if(x&&!x.dynamicProps)x.props!==void 0&&(s.props=Um.mergeEvaluated.props(o,x.props,s.props));else{let v=o.var("props",(0,It._)`${g}.evaluated.props`);s.props=Um.mergeEvaluated.props(o,v,s.props,It.Name)}if(s.items!==!0)if(x&&!x.dynamicItems)x.items!==void 0&&(s.items=Um.mergeEvaluated.items(o,x.items,s.items));else{let v=o.var("items",(0,It._)`${g}.evaluated.items`);s.items=Um.mergeEvaluated.items(o,v,s.items,It.Name)}}i(m,"addEvaluatedFrom")}i(qm,"callRef");Ts.callRef=qm;Ts.default=CX});var B2=D(OS=>{"use strict";Object.defineProperty(OS,"__esModule",{value:!0});var IX=L2(),PX=H2(),RX=["$schema","$id","$defs","$vocabulary",{keyword:"$comment"},"definitions",IX.default,PX.default];OS.default=RX});var V2=D(AS=>{"use strict";Object.defineProperty(AS,"__esModule",{value:!0});var Hm=ne(),ao=Hm.operators,Bm={maximum:{okStr:"<=",ok:ao.LTE,fail:ao.GT},minimum:{okStr:">=",ok:ao.GTE,fail:ao.LT},exclusiveMaximum:{okStr:"<",ok:ao.LT,fail:ao.GTE},exclusiveMinimum:{okStr:">",ok:ao.GT,fail:ao.LTE}},OX={message:({keyword:e,schemaCode:t})=>(0,Hm.str)`must be ${Bm[e].okStr} ${t}`,params:({keyword:e,schemaCode:t})=>(0,Hm._)`{comparison: ${Bm[e].okStr}, limit: ${t}}`},AX={keyword:Object.keys(Bm),type:"number",schemaType:"number",$data:!0,error:OX,code(e){let{keyword:t,data:r,schemaCode:n}=e;e.fail$data((0,Hm._)`${r} ${Bm[t].fail} ${n} || isNaN(${r})`)}};AS.default=AX});var G2=D(jS=>{"use strict";Object.defineProperty(jS,"__esModule",{value:!0});var ru=ne(),jX={message:({schemaCode:e})=>(0,ru.str)`must be multiple of ${e}`,params:({schemaCode:e})=>(0,ru._)`{multipleOf: ${e}}`},DX={keyword:"multipleOf",type:"number",schemaType:"number",$data:!0,error:jX,code(e){let{gen:t,data:r,schemaCode:n,it:o}=e,s=o.opts.multipleOfPrecision,a=t.let("res"),c=s?(0,ru._)`Math.abs(Math.round(${a}) - ${a}) > 1e-${s}`:(0,ru._)`${a} !== parseInt(${a})`;e.fail$data((0,ru._)`(${n} === 0 || (${a} = ${r}/${n}, ${c}))`)}};jS.default=DX});var K2=D(DS=>{"use strict";Object.defineProperty(DS,"__esModule",{value:!0});function W2(e){let t=e.length,r=0,n=0,o;for(;n<t;)r++,o=e.charCodeAt(n++),o>=55296&&o<=56319&&n<t&&(o=e.charCodeAt(n),(o&64512)===56320&&n++);return r}i(W2,"ucs2length");DS.default=W2;W2.code='require("ajv/dist/runtime/ucs2length").default'});var J2=D(MS=>{"use strict";Object.defineProperty(MS,"__esModule",{value:!0});var zs=ne(),MX=pe(),ZX=K2(),LX={message({keyword:e,schemaCode:t}){let r=e==="maxLength"?"more":"fewer";return(0,zs.str)`must NOT have ${r} than ${t} characters`},params:({schemaCode:e})=>(0,zs._)`{limit: ${e}}`},FX={keyword:["maxLength","minLength"],type:"string",schemaType:"number",$data:!0,error:LX,code(e){let{keyword:t,data:r,schemaCode:n,it:o}=e,s=t==="maxLength"?zs.operators.GT:zs.operators.LT,a=o.opts.unicode===!1?(0,zs._)`${r}.length`:(0,zs._)`${(0,MX.useFunc)(e.gen,ZX.default)}(${r})`;e.fail$data((0,zs._)`${a} ${s} ${n}`)}};MS.default=FX});var Y2=D(ZS=>{"use strict";Object.defineProperty(ZS,"__esModule",{value:!0});var UX=ar(),qX=pe(),va=ne(),HX={message:({schemaCode:e})=>(0,va.str)`must match pattern "${e}"`,params:({schemaCode:e})=>(0,va._)`{pattern: ${e}}`},BX={keyword:"pattern",type:"string",schemaType:"string",$data:!0,error:HX,code(e){let{gen:t,data:r,$data:n,schema:o,schemaCode:s,it:a}=e,c=a.opts.unicodeRegExp?"u":"";if(n){let{regExp:l}=a.opts.code,u=l.code==="new RegExp"?(0,va._)`new RegExp`:(0,qX.useFunc)(t,l),d=t.let("valid");t.try(()=>t.assign(d,(0,va._)`${u}(${s}, ${c}).test(${r})`),()=>t.assign(d,!1)),e.fail$data((0,va._)`!${d}`)}else{let l=(0,UX.usePattern)(e,o);e.fail$data((0,va._)`!${l}.test(${r})`)}}};ZS.default=BX});var X2=D(LS=>{"use strict";Object.defineProperty(LS,"__esModule",{value:!0});var nu=ne(),VX={message({keyword:e,schemaCode:t}){let r=e==="maxProperties"?"more":"fewer";return(0,nu.str)`must NOT have ${r} than ${t} properties`},params:({schemaCode:e})=>(0,nu._)`{limit: ${e}}`},GX={keyword:["maxProperties","minProperties"],type:"object",schemaType:"number",$data:!0,error:VX,code(e){let{keyword:t,data:r,schemaCode:n}=e,o=t==="maxProperties"?nu.operators.GT:nu.operators.LT;e.fail$data((0,nu._)`Object.keys(${r}).length ${o} ${n}`)}};LS.default=GX});var Q2=D(FS=>{"use strict";Object.defineProperty(FS,"__esModule",{value:!0});var ou=ar(),su=ne(),WX=pe(),KX={message:({params:{missingProperty:e}})=>(0,su.str)`must have required property '${e}'`,params:({params:{missingProperty:e}})=>(0,su._)`{missingProperty: ${e}}`},JX={keyword:"required",type:"object",schemaType:"array",$data:!0,error:KX,code(e){let{gen:t,schema:r,schemaCode:n,data:o,$data:s,it:a}=e,{opts:c}=a;if(!s&&r.length===0)return;let l=r.length>=c.loopRequired;if(a.allErrors?u():d(),c.strictRequired){let m=e.parentSchema.properties,{definedProperties:g}=e.it;for(let _ of r)if(m?.[_]===void 0&&!g.has(_)){let x=a.schemaEnv.baseId+a.errSchemaPath,v=`required property "${_}" is not defined at "${x}" (strictRequired)`;(0,WX.checkStrictMode)(a,v,a.opts.strictRequired)}}function u(){if(l||s)e.block$data(su.nil,p);else for(let m of r)(0,ou.checkReportMissingProp)(e,m)}i(u,"allErrorsMode");function d(){let m=t.let("missing");if(l||s){let g=t.let("valid",!0);e.block$data(g,()=>h(m,g)),e.ok(g)}else t.if((0,ou.checkMissingProp)(e,r,m)),(0,ou.reportMissingProp)(e,m),t.else()}i(d,"exitOnErrorMode");function p(){t.forOf("prop",n,m=>{e.setParams({missingProperty:m}),t.if((0,ou.noPropertyInData)(t,o,m,c.ownProperties),()=>e.error())})}i(p,"loopAllRequired");function h(m,g){e.setParams({missingProperty:m}),t.forOf(m,n,()=>{t.assign(g,(0,ou.propertyInData)(t,o,m,c.ownProperties)),t.if((0,su.not)(g),()=>{e.error(),t.break()})},su.nil)}i(h,"loopUntilMissing")}};FS.default=JX});var eZ=D(US=>{"use strict";Object.defineProperty(US,"__esModule",{value:!0});var iu=ne(),YX={message({keyword:e,schemaCode:t}){let r=e==="maxItems"?"more":"fewer";return(0,iu.str)`must NOT have ${r} than ${t} items`},params:({schemaCode:e})=>(0,iu._)`{limit: ${e}}`},XX={keyword:["maxItems","minItems"],type:"array",schemaType:"number",$data:!0,error:YX,code(e){let{keyword:t,data:r,schemaCode:n}=e,o=t==="maxItems"?iu.operators.GT:iu.operators.LT;e.fail$data((0,iu._)`${r}.length ${o} ${n}`)}};US.default=XX});var Vm=D(qS=>{"use strict";Object.defineProperty(qS,"__esModule",{value:!0});var tZ=nS();tZ.code='require("ajv/dist/runtime/equal").default';qS.default=tZ});var rZ=D(BS=>{"use strict";Object.defineProperty(BS,"__esModule",{value:!0});var HS=Bl(),st=ne(),QX=pe(),eQ=Vm(),tQ={message:({params:{i:e,j:t}})=>(0,st.str)`must NOT have duplicate items (items ## ${t} and ${e} are identical)`,params:({params:{i:e,j:t}})=>(0,st._)`{i: ${e}, j: ${t}}`},rQ={keyword:"uniqueItems",type:"array",schemaType:"boolean",$data:!0,error:tQ,code(e){let{gen:t,data:r,$data:n,schema:o,parentSchema:s,schemaCode:a,it:c}=e;if(!n&&!o)return;let l=t.let("valid"),u=s.items?(0,HS.getSchemaTypes)(s.items):[];e.block$data(l,d,(0,st._)`${a} === false`),e.ok(l);function d(){let g=t.let("i",(0,st._)`${r}.length`),_=t.let("j");e.setParams({i:g,j:_}),t.assign(l,!0),t.if((0,st._)`${g} > 1`,()=>(p()?h:m)(g,_))}i(d,"validateUniqueItems");function p(){return u.length>0&&!u.some(g=>g==="object"||g==="array")}i(p,"canOptimize");function h(g,_){let x=t.name("item"),v=(0,HS.checkDataTypes)(u,x,c.opts.strictNumbers,HS.DataType.Wrong),w=t.const("indices",(0,st._)`{}`);t.for((0,st._)`;${g}--;`,()=>{t.let(x,(0,st._)`${r}[${g}]`),t.if(v,(0,st._)`continue`),u.length>1&&t.if((0,st._)`typeof ${x} == "string"`,(0,st._)`${x} += "_"`),t.if((0,st._)`typeof ${w}[${x}] == "number"`,()=>{t.assign(_,(0,st._)`${w}[${x}]`),e.error(),t.assign(l,!1).break()}).code((0,st._)`${w}[${x}] = ${g}`)})}i(h,"loopN");function m(g,_){let x=(0,QX.useFunc)(t,eQ.default),v=t.name("outer");t.label(v).for((0,st._)`;${g}--;`,()=>t.for((0,st._)`${_} = ${g}; ${_}--;`,()=>t.if((0,st._)`${x}(${r}[${g}], ${r}[${_}])`,()=>{e.error(),t.assign(l,!1).break(v)})))}i(m,"loopN2")}};BS.default=rQ});var nZ=D(GS=>{"use strict";Object.defineProperty(GS,"__esModule",{value:!0});var VS=ne(),nQ=pe(),oQ=Vm(),sQ={message:"must be equal to constant",params:({schemaCode:e})=>(0,VS._)`{allowedValue: ${e}}`},iQ={keyword:"const",$data:!0,error:sQ,code(e){let{gen:t,data:r,$data:n,schemaCode:o,schema:s}=e;n||s&&typeof s=="object"?e.fail$data((0,VS._)`!${(0,nQ.useFunc)(t,oQ.default)}(${r}, ${o})`):e.fail((0,VS._)`${s} !== ${r}`)}};GS.default=iQ});var oZ=D(WS=>{"use strict";Object.defineProperty(WS,"__esModule",{value:!0});var au=ne(),aQ=pe(),cQ=Vm(),lQ={message:"must be equal to one of the allowed values",params:({schemaCode:e})=>(0,au._)`{allowedValues: ${e}}`},uQ={keyword:"enum",schemaType:"array",$data:!0,error:lQ,code(e){let{gen:t,data:r,$data:n,schema:o,schemaCode:s,it:a}=e;if(!n&&o.length===0)throw new Error("enum must have non-empty array");let c=o.length>=a.opts.loopEnum,l,u=i(()=>l??(l=(0,aQ.useFunc)(t,cQ.default)),"getEql"),d;if(c||n)d=t.let("valid"),e.block$data(d,p);else{if(!Array.isArray(o))throw new Error("ajv implementation error");let m=t.const("vSchema",s);d=(0,au.or)(...o.map((g,_)=>h(m,_)))}e.pass(d);function p(){t.assign(d,!1),t.forOf("v",s,m=>t.if((0,au._)`${u()}(${r}, ${m})`,()=>t.assign(d,!0).break()))}i(p,"loopEnum");function h(m,g){let _=o[g];return typeof _=="object"&&_!==null?(0,au._)`${u()}(${r}, ${m}[${g}])`:(0,au._)`${r} === ${_}`}i(h,"equalCode")}};WS.default=uQ});var sZ=D(KS=>{"use strict";Object.defineProperty(KS,"__esModule",{value:!0});var dQ=V2(),pQ=G2(),fQ=J2(),mQ=Y2(),hQ=X2(),gQ=Q2(),yQ=eZ(),xQ=rZ(),_Q=nZ(),vQ=oZ(),wQ=[dQ.default,pQ.default,fQ.default,mQ.default,hQ.default,gQ.default,yQ.default,xQ.default,{keyword:"type",schemaType:["string","array"]},{keyword:"nullable",schemaType:"boolean"},_Q.default,vQ.default];KS.default=wQ});var YS=D(cu=>{"use strict";Object.defineProperty(cu,"__esModule",{value:!0});cu.validateAdditionalItems=void 0;var Cs=ne(),JS=pe(),bQ={message:({params:{len:e}})=>(0,Cs.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0,Cs._)`{limit: ${e}}`},SQ={keyword:"additionalItems",type:"array",schemaType:["boolean","object"],before:"uniqueItems",error:bQ,code(e){let{parentSchema:t,it:r}=e,{items:n}=t;if(!Array.isArray(n)){(0,JS.checkStrictMode)(r,'"additionalItems" is ignored when "items" is not an array of schemas');return}iZ(e,n)}};function iZ(e,t){let{gen:r,schema:n,data:o,keyword:s,it:a}=e;a.items=!0;let c=r.const("len",(0,Cs._)`${o}.length`);if(n===!1)e.setParams({len:t.length}),e.pass((0,Cs._)`${c} <= ${t.length}`);else if(typeof n=="object"&&!(0,JS.alwaysValidSchema)(a,n)){let u=r.var("valid",(0,Cs._)`${c} <= ${t.length}`);r.if((0,Cs.not)(u),()=>l(u)),e.ok(u)}function l(u){r.forRange("i",t.length,c,d=>{e.subschema({keyword:s,dataProp:d,dataPropType:JS.Type.Num},u),a.allErrors||r.if((0,Cs.not)(u),()=>r.break())})}i(l,"validateItems")}i(iZ,"validateAdditionalItems");cu.validateAdditionalItems=iZ;cu.default=SQ});var XS=D(lu=>{"use strict";Object.defineProperty(lu,"__esModule",{value:!0});lu.validateTuple=void 0;var aZ=ne(),Gm=pe(),kQ=ar(),$Q={keyword:"items",type:"array",schemaType:["object","array","boolean"],before:"uniqueItems",code(e){let{schema:t,it:r}=e;if(Array.isArray(t))return cZ(e,"additionalItems",t);r.items=!0,!(0,Gm.alwaysValidSchema)(r,t)&&e.ok((0,kQ.validateArray)(e))}};function cZ(e,t,r=e.schema){let{gen:n,parentSchema:o,data:s,keyword:a,it:c}=e;d(o),c.opts.unevaluated&&r.length&&c.items!==!0&&(c.items=Gm.mergeEvaluated.items(n,r.length,c.items));let l=n.name("valid"),u=n.const("len",(0,aZ._)`${s}.length`);r.forEach((p,h)=>{(0,Gm.alwaysValidSchema)(c,p)||(n.if((0,aZ._)`${u} > ${h}`,()=>e.subschema({keyword:a,schemaProp:h,dataProp:h},l)),e.ok(l))});function d(p){let{opts:h,errSchemaPath:m}=c,g=r.length,_=g===p.minItems&&(g===p.maxItems||p[t]===!1);if(h.strictTuples&&!_){let x=`"${a}" is ${g}-tuple, but minItems or maxItems/${t} are not specified or different at path "${m}"`;(0,Gm.checkStrictMode)(c,x,h.strictTuples)}}i(d,"checkStrictTuple")}i(cZ,"validateTuple");lu.validateTuple=cZ;lu.default=$Q});var lZ=D(QS=>{"use strict";Object.defineProperty(QS,"__esModule",{value:!0});var EQ=XS(),NQ={keyword:"prefixItems",type:"array",schemaType:["array"],before:"uniqueItems",code:e=>(0,EQ.validateTuple)(e,"items")};QS.default=NQ});var dZ=D(ek=>{"use strict";Object.defineProperty(ek,"__esModule",{value:!0});var uZ=ne(),TQ=pe(),zQ=ar(),CQ=YS(),IQ={message:({params:{len:e}})=>(0,uZ.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0,uZ._)`{limit: ${e}}`},PQ={keyword:"items",type:"array",schemaType:["object","boolean"],before:"uniqueItems",error:IQ,code(e){let{schema:t,parentSchema:r,it:n}=e,{prefixItems:o}=r;n.items=!0,!(0,TQ.alwaysValidSchema)(n,t)&&(o?(0,CQ.validateAdditionalItems)(e,o):e.ok((0,zQ.validateArray)(e)))}};ek.default=PQ});var pZ=D(tk=>{"use strict";Object.defineProperty(tk,"__esModule",{value:!0});var lr=ne(),Wm=pe(),RQ={message:({params:{min:e,max:t}})=>t===void 0?(0,lr.str)`must contain at least ${e} valid item(s)`:(0,lr.str)`must contain at least ${e} and no more than ${t} valid item(s)`,params:({params:{min:e,max:t}})=>t===void 0?(0,lr._)`{minContains: ${e}}`:(0,lr._)`{minContains: ${e}, maxContains: ${t}}`},OQ={keyword:"contains",type:"array",schemaType:["object","boolean"],before:"uniqueItems",trackErrors:!0,error:RQ,code(e){let{gen:t,schema:r,parentSchema:n,data:o,it:s}=e,a,c,{minContains:l,maxContains:u}=n;s.opts.next?(a=l===void 0?1:l,c=u):a=1;let d=t.const("len",(0,lr._)`${o}.length`);if(e.setParams({min:a,max:c}),c===void 0&&a===0){(0,Wm.checkStrictMode)(s,'"minContains" == 0 without "maxContains": "contains" keyword ignored');return}if(c!==void 0&&a>c){(0,Wm.checkStrictMode)(s,'"minContains" > "maxContains" is always invalid'),e.fail();return}if((0,Wm.alwaysValidSchema)(s,r)){let _=(0,lr._)`${d} >= ${a}`;c!==void 0&&(_=(0,lr._)`${_} && ${d} <= ${c}`),e.pass(_);return}s.items=!0;let p=t.name("valid");c===void 0&&a===1?m(p,()=>t.if(p,()=>t.break())):a===0?(t.let(p,!0),c!==void 0&&t.if((0,lr._)`${o}.length > 0`,h)):(t.let(p,!1),h()),e.result(p,()=>e.reset());function h(){let _=t.name("_valid"),x=t.let("count",0);m(_,()=>t.if(_,()=>g(x)))}i(h,"validateItemsWithCount");function m(_,x){t.forRange("i",0,d,v=>{e.subschema({keyword:"contains",dataProp:v,dataPropType:Wm.Type.Num,compositeRule:!0},_),x()})}i(m,"validateItems");function g(_){t.code((0,lr._)`${_}++`),c===void 0?t.if((0,lr._)`${_} >= ${a}`,()=>t.assign(p,!0).break()):(t.if((0,lr._)`${_} > ${c}`,()=>t.assign(p,!1).break()),a===1?t.assign(p,!0):t.if((0,lr._)`${_} >= ${a}`,()=>t.assign(p,!0)))}i(g,"checkLimits")}};tk.default=OQ});var hZ=D(Gr=>{"use strict";Object.defineProperty(Gr,"__esModule",{value:!0});Gr.validateSchemaDeps=Gr.validatePropertyDeps=Gr.error=void 0;var rk=ne(),AQ=pe(),uu=ar();Gr.error={message:({params:{property:e,depsCount:t,deps:r}})=>{let n=t===1?"property":"properties";return(0,rk.str)`must have ${n} ${r} when property ${e} is present`},params:({params:{property:e,depsCount:t,deps:r,missingProperty:n}})=>(0,rk._)`{property: ${e},
210
+ `)}var gK,cb,yK,a2=f(()=>{gK=mK(hK(import.meta.url)),cb=gK,yK=["elements.md","layout.md","interactivity.md","workflow.md"];i(xK,"loadPlaybook");i(_K,"loadAllPlaybook")});var c2={};C(c2,{aiSessionsServerContracts:()=>wK,pushAiSessionsList:()=>zu});import{defineContracts as vK}from"@jucie.io/engine-socket/server";async function zu(e,t=null){let[r,n]=e("aiHistory","socket"),o=await r.listSessions();return t?t.publish("ai:sessions:set",o):n.broadcast("ai:sessions:set",o),o}var wK,gh=f(()=>{i(zu,"pushAiSessionsList");wK=vK("ai:sessions",e=>{let t=e("aiHistory");return{refresh:{handler:async(r,n)=>{let o=await t.listSessions();return n.publish("ai:sessions:set",o),o}}}})});var l2={};C(l2,{aiSessionServerContracts:()=>SK});import{defineContracts as bK}from"@jucie.io/engine-socket/server";var SK,u2=f(()=>{gh();SK=bK("ai:session",e=>{let t=e("aiHistory");return{create:{handler:async()=>{try{return await t.createSession()}catch(r){return{error:r.message}}}},delete:{handler:async r=>{try{let n=await t.deleteSession(r);return await zu(e),n}catch(n){return{error:n.message}}}},"messages:get":{handler:async r=>{try{let n=await t.getMessages(r);return{id:r,messages:n}}catch(n){return{error:n.message}}}},"attachment:save":{timeoutMs:3e4,handler:async(r,{name:n,mimeType:o,data:s})=>{try{return await t.saveAttachment(r,{name:n,mimeType:o,data:s})}catch(a){return{error:a.message}}}}}})});var d2={};C(d2,{abortAiRun:()=>EK,aiAgentServerContracts:()=>$K});import{defineContracts as kK}from"@jucie.io/engine-socket/server";function EK(e){go.get(e)?.abort(),go.delete(e)}var go,$K,p2=f(()=>{gh();go=new Map,$K=kK("ai:agent",e=>{let[t,r]=e("aiAgent","log");return{run:{timeoutMs:36e5,handler:async({prompt:n,sessionId:o,token:s,orgId:a=null,attachments:c}={},l)=>{go.get(l.id)?.abort();let u=new AbortController;go.set(l.id,u);try{let d=await t.run({prompt:n,sessionId:o,token:s,orgId:a,attachments:c,signal:u.signal,getContext:(p={})=>l.ask("ai:stage:context:capture",p),captureScreenshot:(p={})=>l.ask("screenshot:capture",p,{timeoutMs:12e4}),execute:p=>l.ask("ai:stage:operations:execute",{batch:p},{timeoutMs:6e4}),onProgress:p=>l.publish("ai:agent:progress",p)});return l.publish("ai:agent:response",{...d,sessionId:o}),d}catch(d){throw r.error("ai agent failed",{error:d.message}),l.publish("ai:agent:response",{error:d.message,status:d.status??null,budget:d.budget??null,sessionId:o}),d}finally{go.get(l.id)===u&&go.delete(l.id),await zu(e)}}},stop:{handler:(n,o)=>{go.get(o.id)?.abort(),go.delete(o.id)}}}});i(EK,"abortAiRun")});var f2={};C(f2,{default:()=>zK});import{defineRoutes as NK}from"@jucie.io/engine-server";function TK(e,t,{maxDepth:r=1/0}={}){let n=" ",o=i((x,v)=>{let b=n.repeat(v);return x.split(`
211
+ `).map(w=>b+w).join(`
212
+ `)},"indent"),s=i(x=>String(x).replace(/"/g,"&quot;"),"esc"),a=i(x=>String(x).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;"),"escText"),c=i(x=>Math.round(x??0),"r"),l=i(x=>`${c(x.x)},${c(x.y)},${c(x.width)}x${c(x.height)}`,"formatBounds"),u=i(x=>{let v=i(w=>!w||typeof w!="object"?"":Object.entries(w).map(([S,E])=>`${S}: ${E}`).join("; "),"cssDecls"),b=[];x.default&&b.push(v(x.default));for(let w of Object.keys(x)){if(w==="default")continue;let S=v(x[w]);S&&b.push(`${w}: { ${S} }`)}return b.filter(Boolean).join(" | ")},"formatStyle"),d=i(x=>Array.isArray(x)?x.join("."):x??"","formatBinding"),p=i(x=>x.map(v=>{let b=v.key??v.name??v.event;if(!b)return null;if(v.mode==="binding"||v.binding){let S=d(v.binding);return S?`${b}=${S}`:b}let w=v.code??v.expression??v.value??v.handler??"";return w?`${b}=${w}`:b}).filter(Boolean).join(", "),"formatEvents"),m=i(x=>x.map(v=>{let b=v.key??v.name;if(!b)return null;if(v.mode==="binding"||v.binding){let S=d(v.binding);return S?`${b}=${S}`:b}let w=v.expression?`{{${v.expression}}}`:v.value??"";return w!==""?`${b}=${w}`:b}).filter(Boolean).join(", "),"formatAttrs"),h=i((x,v)=>{let b=[],w=x.id??v;if(w&&b.push(`id="${s(w)}"`),x.name&&b.push(`name="${s(x.name)}"`),x.bounds&&b.push(`bounds="${l(x.bounds)}"`),x.style&&Object.keys(x.style).length){let S=u(x.style);S&&b.push(`style="${s(S)}"`)}return x.events?.length&&b.push(`events="${s(p(x.events))}"`),x.attributes?.length&&b.push(`attrs="${s(m(x.attributes))}"`),x.className?.length&&b.push(`class="${x.className.join(" ")}"`),x.repeat&&b.push(`repeat="${s(JSON.stringify(x.repeat))}"`),x.component&&b.push(`component="${s(x.component)}"`),x.library&&b.push(`library="${s(x.library)}"`),x.props&&Object.keys(x.props).length&&b.push(`props="${s(JSON.stringify(x.props))}"`),x.route?.path&&b.push(`route="${s(x.route.path)}"`),x.render?.value&&b.push(`render="{{${s(x.render.value)}}}"`),x.destination?.path&&b.push(`dest="${s(x.destination.path)}"`),b.length?" "+b.join(" "):""},"buildAttrString"),g=i(x=>{let v=e[x];if(!v)return null;if(v.ex&&e[v.ex]){let b=g(v.ex);if(!b)return v;let{ex:w,...S}=v;return Object.assign({},b,S)}return v},"resolveNode"),_=i((x,v)=>{let b=e[x],w=g(x);if(!w)return`<!-- missing: ${x} -->`;let S,E;if(w.type==="element"){let ce=b?.ex&&Ai(b.ex)?b.ex:w.type;S=ce,E=up(ce)}else if(w.type){S=w.type;let ce=b?.ex&&Ai(b.ex)?b.ex:w.type;E=up(ce)}else S=x,E=null;let I=E?`${S}:${E}`:S,z=h(w,x),M=w.textContent?.value||null,D=Array.isArray(w.children)?w.children:[];if(!(D.length>0||M!=null&&M!==""))return`<${I}${z} />`;if(v>=r){let ce=D.length?`<\u22EF${D.length} children>`:"<\u22EFtext>";return`<${I}${z}>${ce}</${I}>`}if(M!=null&&M!==""&&D.length===0)return`<${I}${z}>${a(M)}</${I}>`;let H=D.map(ce=>o(_(ce,v+1),1)).join(`
213
+ `);return`<${I}${z}>
214
+ ${H}
215
+ </${I}>`},"renderNode");return _(t,0)}var zK,m2=f(()=>{cp();i(TK,"projectJsx");zK=NK("mcp",e=>{let t=e("log");return[{method:"get",path:"/screenshot",handler:async({respond:r})=>{let s=[...e("cache").get(["connections"])??new Set][0];if(!s)return r.json({error:"no stage connected"},503);try{let a=await s.ask("screenshot:capture");return r.json(a)}catch(a){return r.json({error:a.message},504)}}},{method:"get",path:"/scene",handler:({req:r,respond:n})=>{try{let o=e("state"),s=r.query.root??"app",a=r.query.depth!=null?Number(r.query.depth):1/0,c=o.get(["nodes"]);if(!c)return n.json({error:"no scene loaded"},503);let l=TK(c,s,{maxDepth:a});return n.json({jsx:l})}catch(o){return t.error("mcp /scene failed",{error:o.message}),n.json({error:o.message},500)}}},{method:"get",path:"/tools",handler:({respond:r})=>{try{let n=e("aiOps");return r.json({namespaces:n.operationsMetadata})}catch(n){return t.error("mcp /tools failed",{error:n.message}),r.json({error:n.message},500)}}},{method:"post",path:"/operations",handler:async({req:r,respond:n})=>{try{let o=e("aiOps"),{operations:s=[]}=r.body??{},a=i(x=>{if(x.op){let v=o.resolveType(x.op);if(!v)return{error:o.describeUnresolved(x.op)};let{op:b,ref:w,...S}=x;return{type:v,args:S,ref:w}}if(typeof x.type=="string"){let v=o.resolveType(x.type);return v?{type:v,args:x.args??{},ref:x.ref}:{error:o.describeUnresolved(x.type)}}return{error:`unknown op: ${x.op??x.type}`}},"translate"),c=s.map(a),l=c.filter(x=>x.error),d={operations:c.filter(x=>!x.error)},h=[...e("cache").get(["connections"])??new Set][0],g;if(h)try{g=await h.ask("ai:stage:operations:execute",{batch:d},{timeoutMs:3e3})}catch(x){t.warn("mcp /operations: stage execute failed, falling back to server",{error:x.message}),g=await o.executeBatch(d)}else g=await o.executeBatch(d);let _=g.results.map(x=>x.result);return l.length&&l.forEach(x=>{t.warn("mcp /operations: unresolved op",{error:x.error}),_.push({error:x.error})}),n.json({results:_})}catch(o){return t.error("mcp /operations failed",{error:o.message}),n.json({error:o.message},500)}}}]})});var h2={};C(h2,{default:()=>IK});import{defineRoutes as CK}from"@jucie.io/engine-server";var IK,g2=f(()=>{IK=CK("scene",e=>{let t=e("state");return[{method:"get",path:"/snapshot",handler:({respond:r})=>r.json(t.ledger.snapshot())}]})});var x2={};C(x2,{default:()=>y2});import{defineRoutes as PK}from"@jucie.io/engine-server";import{join as lb,resolve as OK}from"path";import{existsSync as AK}from"fs";function MK(e,t){if(!t.length)return e;let r=t.map(n=>` ${n.file??"?"}:${n.line??"?"} ${n.text}`).join(`
216
+ `);return`console.error(${JSON.stringify(`[jucie] project components failed to build:
217
+ ${r}`)});
218
+ ${e}`}function y2({componentsOutdir:e}){let t=OK(e);return PK(r=>{let n=r("log"),o=r("cache"),s=i(()=>o?.get(["componentsBuild","errors"])??[],"errors"),a=i((u,d)=>({respond:p})=>{let m=lb(t,u);return AK(m)?p.file(m):p.text(MK(d,s()),200,RK)},"entry"),c=i(u=>({respond:d})=>d.file(lb(t,u)),"sibling"),l=i(({respond:u,req:d})=>{let p=d.path.slice(1);return p.includes("..")||p.includes("\0")?(n?.warn?.("rejected suspicious project asset path",{path:d.path}),u.text("Not Found",404)):u.file(lb(t,p))},"fromOutdir");return[{method:"get",path:"/components.js",handler:a("components.js",jK)},{method:"get",path:"/components.js.map",handler:c("components.js.map")},{method:"get",path:"/user-main.js",handler:a("user-main.js",DK)},{method:"get",path:"/user-main.js.map",handler:c("user-main.js.map")},{method:"get",path:"/project-chunks/*",handler:l},{method:"get",path:"/project-assets/*",handler:l},{method:"get",path:"/build-status",handler:({respond:u})=>u.json({errors:s()})}]})}var RK,jK,DK,_2=f(()=>{RK={"content-type":"application/javascript"},jK=`export default { local: { components: {}, manifest: {} } };
219
+ `,DK=`export const __jucieMainStub = true;
220
+ `;i(MK,"fallbackModule");i(y2,"componentsRoutes")});var w2={};C(w2,{createDesignServer:()=>YK});import{Result as LK}from"@jucie.io/result";import{existsSync as ub,renameSync as FK}from"fs";import{join as Ra}from"path";import{Engine as UK}from"@jucie.io/engine";import{Server as qK,defineRoutes as BK}from"@jucie.io/engine-server";import{SocketServer as HK}from"@jucie.io/engine-socket/server";import{State as VK}from"@jucie.io/engine-state";import{Matcher as GK}from"@jucie.io/state-matcher";import{OnChange as WK}from"@jucie.io/state-on-change";import{LocalProvider as JK}from"@jucie.io/engine-storage/providers/local";function KK(e){let t=Ra(e,".jucie","attachments"),r=Ra(e,".jucie","assets");if(ub(r)&&!ub(t))try{FK(r,t)}catch{}return t}async function YK(e={}){let t={error(){},warn(){},info(){},debug(){}},r=null,n=null;try{let o={},s=0,a=e.framework||"react",c=e.stageBundles&&ub(Ra(e.stageBundles,a)),l=!c&&e.serve!==!1,u=e.ai!==!1,d=e.mcp!==!1&&u,p=e.libraries!==!1;c&&(e.outdir=Ra(e.stageBundles,a));let m=c?e.componentsOutdir??Ra(e.projectRoot??process.cwd(),".jucie","cache","components"):null,h=await la(e.views,{onWarn:w=>console.warn(` \u26A0\uFE0F ${w}`)});if(r=UK.create().install(VK.configure({state:{},plugins:[pl.configure({actorId:"server"}),GK,WK]}),En.configure({...e,templates:h}),qK.configure(e),HK.configure({path:"/socket",maxPayloadBytes:5e7,heartbeatMs:3e4,...e.socket}),gn.configure({storage:{name:"state",provider:e.storageProvider??JK,root:e.projectRoot??e.sceneGraph,mode:"path",...e.storageConfig??{}},branch:e.branch||"main",namespaces:e.namespaces??{},configs:[ta,ra,na,oa,sa]}),_n.configure(e),gu.configure(e),bl.configure({...e,watch:!0})),r.cache.set(["jucieConfig"],e),r.cache.set(["connections"],new Set),r.cache.set(["presence","users"],o),t=r.log.child({ns:"stage:design"}),p){let{Libraries:w}=await Promise.resolve().then(()=>(zD(),TD)),S=(await Promise.resolve().then(()=>(ID(),CD))).default;r.install(w.configure(e)),r.server.use(S)}if(l){let{EsBuild:w}=await import("@jucie.io/engine-esbuild"),{runtimeConfig:S}=await Promise.resolve().then(()=>(Ew(),eD)),{resolveConfig:E}=await Promise.resolve().then(()=>(Kl(),Vv)),{resolveComponents:I}=await Promise.resolve().then(()=>(Ol(),Pv)),{cooperativeRoots:z}=await Promise.resolve().then(()=>(jl(),Av)),{vueSfc:M}=await Promise.resolve().then(()=>(Ml(),jv)),{resolveJux:D}=await Promise.resolve().then(()=>(ql(),Uv)),{resolveMain:Z}=await Promise.resolve().then(()=>(Vl(),Bv)),{resolveSdk:H}=await Promise.resolve().then(()=>(cm(),kR)),{resolveScene:ce}=await Promise.resolve().then(()=>(Wl(),Hv)),{onRebuild:J}=await Promise.resolve().then(()=>(Tw(),tD));r.install(w.configure(e)),r.esBuild.use(S,E,I,z,M,D,Z,H,ce,J)}else if(c){let{EsBuild:w}=await import("@jucie.io/engine-esbuild"),{componentsConfig:S}=await Promise.resolve().then(()=>(OD(),PD)),{externalFramework:E}=await Promise.resolve().then(()=>(DD(),jD)),{resolveComponents:I}=await Promise.resolve().then(()=>(Ol(),Pv)),{cooperativeRoots:z}=await Promise.resolve().then(()=>(jl(),Av)),{vueSfc:M}=await Promise.resolve().then(()=>(Ml(),jv)),{resolveJux:D}=await Promise.resolve().then(()=>(ql(),Uv)),{resolveMain:Z}=await Promise.resolve().then(()=>(Vl(),Bv)),{resolveConfig:H}=await Promise.resolve().then(()=>(Kl(),Vv)),{resolveScene:ce}=await Promise.resolve().then(()=>(Wl(),Hv)),{onBuildResult:J}=await Promise.resolve().then(()=>(ZD(),MD));r.install(w.configure({...e,...e.esbuild??{},outdir:m,componentsOutdir:m})),r.esBuild.use(S,E,I,z,M,D,Z,H,ce,J)}if(u){let w=e.projectRoot??process.cwd(),{AiOperations:S}=await Promise.resolve().then(()=>(Rn(),eM)),{AiAgent:E,AiHistory:I}=await Promise.resolve().then(()=>(NM(),EM)),{allOperations:z}=await Promise.resolve().then(()=>(ab(),t2)),M=(await Promise.resolve().then(()=>(n2(),r2))).default,{loadPlaybook:D}=await Promise.resolve().then(()=>(a2(),i2)),{aiSessionsServerContracts:Z}=await Promise.resolve().then(()=>(gh(),c2)),{aiSessionServerContracts:H}=await Promise.resolve().then(()=>(u2(),l2)),{aiAgentServerContracts:ce,abortAiRun:J}=await Promise.resolve().then(()=>(p2(),d2));if(r.install(S,E.configure({aiServerUrl:e.aiServerUrl??process.env.AI_SERVER_URL??"https://ai.jucie.app/ai/generate",playbook:D(),maxIterations:40,tokenBudget:5e6}),I.configure({dir:Ra(w,".jucie","chats"),attachmentsDir:KK(w)})),r.aiOps.use(...z),r.server.use(M),r.socket.use(Z,H,ce),n=J,d){let te=(await Promise.resolve().then(()=>(m2(),f2))).default;r.server.use(te)}}if(l||c){let w=(await Promise.resolve().then(()=>(Ow(),sD))).default,S=(await Promise.resolve().then(()=>(g2(),h2))).default;if(r.server.use(w("design"),S),c){let I=(await Promise.resolve().then(()=>(_2(),x2))).default;r.server.use(I({componentsOutdir:m}))}let E=p?()=>r.libraries.getEntries().map(I=>I.type==="remote"?I.url:`/libraries/${I.path.split("/").pop()}`):void 0;r.server.use(ka(hu,{stylesheets:E}))}else r.server.use(ka(hu));let g=r.html.list().includes("index")?r.html.renderer("index"):hD;r.server.use(BK((w,S)=>[{method:"get",path:"/preview",handler:({respond:E})=>E.html(g({title:S.name||"Preview",scriptSrc:"/main.js"}))},{method:"get",path:"/preview/*",handler:({respond:E})=>E.html(g({title:S.name||"Preview",scriptSrc:"/main.js"}))}]));let _={"access-control-allow-origin":"*","access-control-allow-methods":"GET, POST, PUT, DELETE, OPTIONS","access-control-allow-headers":"content-type, authorization"};r.server.hooks({onRequest:({req:w,respond:S})=>{if(w.method==="OPTIONS")return S.text("",204,_)},onSend:(w,S)=>{S&&(S.headers={..._,...S.headers})}}),await r.server.listen(),await r.socket.start(),p&&await r.libraries.load();let{ledger:x,tombstones:v,...b}=await r.cas.load();if(r.state.ledger.hydrate({state:b,ledger:x,tombstones:v}),r.assets.onChange(({type:w,asset:S})=>{if(w==="loaded"){r.cache.set(["assets"],S),r.socket.broadcast("assets:set",S);return}let E=r.cache.get(["assets"])??{};w==="deleted"?(delete E[S.id],r.cache.set(["assets"],E),r.socket.broadcast("assets:remove",S.id)):(E[S.id]=S,r.cache.set(["assets"],E),r.socket.broadcast("assets:update",{[S.id]:S}))}),await r.assets.watch(),r.storeParser.onChange(w=>{if(w.type==="loaded"){for(let[S,E]of Object.entries(w.stores))r.state.set([".stores",S],E);return}if(w.type==="deleted"){r.state.remove([".stores",w.name]);return}r.state.set([".stores",w.name],w.store)}),r.state.matcher.createMatcher([".stores"],w=>{r.socket.broadcast("stores:set",w??{})}),r.state.matcher.createMatcher([".stores"],w=>r.storeParser.writeAll(w)),await r.storeParser.start(),r.juxParser.onChange(w=>{if(w.type==="loaded"){for(let[S,E]of Object.entries(w.nodes))r.state.set(["nodes",S],E);return}if(w.type==="deleted"){for(let S of w.nodeIds)r.state.remove(["nodes",S]);return}if(w.prevNodeIds){let S=new Set(Object.keys(w.nodes));for(let E of w.prevNodeIds)S.has(E)||r.state.remove(["nodes",E])}for(let[S,E]of Object.entries(w.nodes))r.state.set(["nodes",S],E)}),await r.juxParser.start(),Object.keys(r.storeParser.getAllStores()).length===0&&r.state.set([".stores","default"],{}),l){let w=await r.esBuild.watch();if(!w)throw new Error("esBuild.watch() returned no result. The esbuild binary for this platform may be missing \u2014 try reinstalling dependencies.");if(w.errors?.length)throw new Error(`Stage bundle failed to build:
221
+ ${w.errors.map(S=>S.text).join(`
222
+ `)}`)}if(c){t.info("compiling project components",{outdir:m});try{await r.esBuild.watch()}catch(w){t.warn("project components failed to build",{error:w.message})}}return r.socket.use(yD,_D,wD,SD),r.socket.onConnection(async w=>{let S=r.cache.get(["connections"]);S.add(w);let E=v2[s%v2.length];s++;let I={name:`User ${S.size}`,color:E,position:{x:0,y:0},selection:[]};o[w.id]=I,Object.keys(o).length>1&&w.publish("presence:snapshot",o),w.broadcast("presence:join",w.id,I),t.info("socket connected",{id:w.id})}),r.socket.onDisconnection(w=>{n?.(w.id);let S=r.cache.get(["connections"]),E=w.id;delete o[E],S.delete(w),r.socket.broadcast("presence:leave",E),t.info("socket disconnected",{id:E})}),r.socket.onError(w=>t.error("socket error",{error:w?.message??w,stack:w?.stack})),{type:"cli",basePath:`http://localhost:${r.server.getHttpServer().address().port}`,view:e.view||"design",nodeId:null,name:e.name||null,engine:r}}catch(o){t.error("design server failed",{error:o.message,stack:o.stack});try{await r?.server?.stop()}catch{}return LK.failure(o)}}var v2,b2=f(()=>{_v();Gi();df();mD();vv();oo();Mf();Cw();gD();Iw();bf();Sf();xD();vD();bD();kD();$D();v2=["#3B82F6","#EF4444","#10B981","#8B5CF6","#EC4899","#F97316","#06B6D4","#6366F1"];i(KK,"migrateLegacyAttachments");i(YK,"createDesignServer")});var dd=F(ge=>{"use strict";Object.defineProperty(ge,"__esModule",{value:!0});ge.regexpCode=ge.getEsmExportName=ge.getProperty=ge.safeStringify=ge.stringify=ge.strConcat=ge.addCodeArg=ge.str=ge._=ge.nil=ge._Code=ge.Name=ge.IDENTIFIER=ge._CodeOrName=void 0;var Nk=class Nk{};i(Nk,"_CodeOrName");var ld=Nk;ge._CodeOrName=ld;ge.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;var Tk=class Tk extends ld{constructor(t){if(super(),!ge.IDENTIFIER.test(t))throw new Error("CodeGen: name must be a valid identifier");this.str=t}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}};i(Tk,"Name");var oi=Tk;ge.Name=oi;var zk=class zk extends ld{constructor(t){super(),this._items=typeof t=="string"?[t]:t}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;let t=this._items[0];return t===""||t==='""'}get str(){var t;return(t=this._str)!==null&&t!==void 0?t:this._str=this._items.reduce((r,n)=>`${r}${n}`,"")}get names(){var t;return(t=this._names)!==null&&t!==void 0?t:this._names=this._items.reduce((r,n)=>(n instanceof oi&&(r[n.str]=(r[n.str]||0)+1),r),{})}};i(zk,"_Code");var fr=zk;ge._Code=fr;ge.nil=new fr("");function _F(e,...t){let r=[e[0]],n=0;for(;n<t.length;)Ek(r,t[n]),r.push(e[++n]);return new fr(r)}i(_F,"_");ge._=_F;var $k=new fr("+");function vF(e,...t){let r=[ud(e[0])],n=0;for(;n<t.length;)r.push($k),Ek(r,t[n]),r.push($k,ud(e[++n]));return rte(r),new fr(r)}i(vF,"str");ge.str=vF;function Ek(e,t){t instanceof fr?e.push(...t._items):t instanceof oi?e.push(t):e.push(ste(t))}i(Ek,"addCodeArg");ge.addCodeArg=Ek;function rte(e){let t=1;for(;t<e.length-1;){if(e[t]===$k){let r=nte(e[t-1],e[t+1]);if(r!==void 0){e.splice(t-1,3,r);continue}e[t++]="+"}t++}}i(rte,"optimize");function nte(e,t){if(t==='""')return e;if(e==='""')return t;if(typeof e=="string")return t instanceof oi||e[e.length-1]!=='"'?void 0:typeof t!="string"?`${e.slice(0,-1)}${t}"`:t[0]==='"'?e.slice(0,-1)+t.slice(1):void 0;if(typeof t=="string"&&t[0]==='"'&&!(e instanceof oi))return`"${e}${t.slice(1)}`}i(nte,"mergeExprItems");function ote(e,t){return t.emptyStr()?e:e.emptyStr()?t:vF`${e}${t}`}i(ote,"strConcat");ge.strConcat=ote;function ste(e){return typeof e=="number"||typeof e=="boolean"||e===null?e:ud(Array.isArray(e)?e.join(","):e)}i(ste,"interpolate");function ite(e){return new fr(ud(e))}i(ite,"stringify");ge.stringify=ite;function ud(e){return JSON.stringify(e).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}i(ud,"safeStringify");ge.safeStringify=ud;function ate(e){return typeof e=="string"&&ge.IDENTIFIER.test(e)?new fr(`.${e}`):_F`[${e}]`}i(ate,"getProperty");ge.getProperty=ate;function cte(e){if(typeof e=="string"&&ge.IDENTIFIER.test(e))return new fr(`${e}`);throw new Error(`CodeGen: invalid export name: ${e}, use explicit $id name mapping`)}i(cte,"getEsmExportName");ge.getEsmExportName=cte;function lte(e){return new fr(e.toString())}i(lte,"regexpCode");ge.regexpCode=lte});var jk=F(At=>{"use strict";Object.defineProperty(At,"__esModule",{value:!0});At.ValueScope=At.ValueScopeName=At.Scope=At.varKinds=At.UsedValueState=void 0;var Ot=dd(),Pk=class Pk extends Error{constructor(t){super(`CodeGen: "code" for ${t} not defined`),this.value=t.value}};i(Pk,"ValueError");var Ck=Pk,Sg;(function(e){e[e.Started=0]="Started",e[e.Completed=1]="Completed"})(Sg||(At.UsedValueState=Sg={}));At.varKinds={const:new Ot.Name("const"),let:new Ot.Name("let"),var:new Ot.Name("var")};var Ok=class Ok{constructor({prefixes:t,parent:r}={}){this._names={},this._prefixes=t,this._parent=r}toName(t){return t instanceof Ot.Name?t:this.name(t)}name(t){return new Ot.Name(this._newName(t))}_newName(t){let r=this._names[t]||this._nameGroup(t);return`${t}${r.index++}`}_nameGroup(t){var r,n;if(!((n=(r=this._parent)===null||r===void 0?void 0:r._prefixes)===null||n===void 0)&&n.has(t)||this._prefixes&&!this._prefixes.has(t))throw new Error(`CodeGen: prefix "${t}" is not allowed in this scope`);return this._names[t]={prefix:t,index:0}}};i(Ok,"Scope");var kg=Ok;At.Scope=kg;var Ak=class Ak extends Ot.Name{constructor(t,r){super(r),this.prefix=t}setValue(t,{property:r,itemIndex:n}){this.value=t,this.scopePath=(0,Ot._)`.${new Ot.Name(r)}[${n}]`}};i(Ak,"ValueScopeName");var $g=Ak;At.ValueScopeName=$g;var ute=(0,Ot._)`\n`,Rk=class Rk extends kg{constructor(t){super(t),this._values={},this._scope=t.scope,this.opts={...t,_n:t.lines?ute:Ot.nil}}get(){return this._scope}name(t){return new $g(t,this._newName(t))}value(t,r){var n;if(r.ref===void 0)throw new Error("CodeGen: ref must be passed in value");let o=this.toName(t),{prefix:s}=o,a=(n=r.key)!==null&&n!==void 0?n:r.ref,c=this._values[s];if(c){let d=c.get(a);if(d)return d}else c=this._values[s]=new Map;c.set(a,o);let l=this._scope[s]||(this._scope[s]=[]),u=l.length;return l[u]=r.ref,o.setValue(r,{property:s,itemIndex:u}),o}getValue(t,r){let n=this._values[t];if(n)return n.get(r)}scopeRefs(t,r=this._values){return this._reduceValues(r,n=>{if(n.scopePath===void 0)throw new Error(`CodeGen: name "${n}" has no value`);return(0,Ot._)`${t}${n.scopePath}`})}scopeCode(t=this._values,r,n){return this._reduceValues(t,o=>{if(o.value===void 0)throw new Error(`CodeGen: name "${o}" has no value`);return o.value.code},r,n)}_reduceValues(t,r,n={},o){let s=Ot.nil;for(let a in t){let c=t[a];if(!c)continue;let l=n[a]=n[a]||new Map;c.forEach(u=>{if(l.has(u))return;l.set(u,Sg.Started);let d=r(u);if(d){let p=this.opts.es5?At.varKinds.var:At.varKinds.const;s=(0,Ot._)`${s}${p} ${u} = ${d};${this.opts._n}`}else if(d=o?.(u))s=(0,Ot._)`${s}${d}${this.opts._n}`;else throw new Ck(u);l.set(u,Sg.Completed)})}return s}};i(Rk,"ValueScope");var Ik=Rk;At.ValueScope=Ik});var se=F(ie=>{"use strict";Object.defineProperty(ie,"__esModule",{value:!0});ie.or=ie.and=ie.not=ie.CodeGen=ie.operators=ie.varKinds=ie.ValueScopeName=ie.ValueScope=ie.Scope=ie.Name=ie.regexpCode=ie.stringify=ie.getProperty=ie.nil=ie.strConcat=ie.str=ie._=void 0;var fe=dd(),Pr=jk(),No=dd();Object.defineProperty(ie,"_",{enumerable:!0,get:function(){return No._}});Object.defineProperty(ie,"str",{enumerable:!0,get:function(){return No.str}});Object.defineProperty(ie,"strConcat",{enumerable:!0,get:function(){return No.strConcat}});Object.defineProperty(ie,"nil",{enumerable:!0,get:function(){return No.nil}});Object.defineProperty(ie,"getProperty",{enumerable:!0,get:function(){return No.getProperty}});Object.defineProperty(ie,"stringify",{enumerable:!0,get:function(){return No.stringify}});Object.defineProperty(ie,"regexpCode",{enumerable:!0,get:function(){return No.regexpCode}});Object.defineProperty(ie,"Name",{enumerable:!0,get:function(){return No.Name}});var zg=jk();Object.defineProperty(ie,"Scope",{enumerable:!0,get:function(){return zg.Scope}});Object.defineProperty(ie,"ValueScope",{enumerable:!0,get:function(){return zg.ValueScope}});Object.defineProperty(ie,"ValueScopeName",{enumerable:!0,get:function(){return zg.ValueScopeName}});Object.defineProperty(ie,"varKinds",{enumerable:!0,get:function(){return zg.varKinds}});ie.operators={GT:new fe._Code(">"),GTE:new fe._Code(">="),LT:new fe._Code("<"),LTE:new fe._Code("<="),EQ:new fe._Code("==="),NEQ:new fe._Code("!=="),NOT:new fe._Code("!"),OR:new fe._Code("||"),AND:new fe._Code("&&"),ADD:new fe._Code("+")};var Jk=class Jk{optimizeNodes(){return this}optimizeNames(t,r){return this}};i(Jk,"Node");var Bn=Jk,Kk=class Kk extends Bn{constructor(t,r,n){super(),this.varKind=t,this.name=r,this.rhs=n}render({es5:t,_n:r}){let n=t?Pr.varKinds.var:this.varKind,o=this.rhs===void 0?"":` = ${this.rhs}`;return`${n} ${this.name}${o};`+r}optimizeNames(t,r){if(t[this.name.str])return this.rhs&&(this.rhs=oc(this.rhs,t,r)),this}get names(){return this.rhs instanceof fe._CodeOrName?this.rhs.names:{}}};i(Kk,"Def");var Dk=Kk,Yk=class Yk extends Bn{constructor(t,r,n){super(),this.lhs=t,this.rhs=r,this.sideEffects=n}render({_n:t}){return`${this.lhs} = ${this.rhs};`+t}optimizeNames(t,r){if(!(this.lhs instanceof fe.Name&&!t[this.lhs.str]&&!this.sideEffects))return this.rhs=oc(this.rhs,t,r),this}get names(){let t=this.lhs instanceof fe.Name?{}:{...this.lhs.names};return Tg(t,this.rhs)}};i(Yk,"Assign");var Eg=Yk,Xk=class Xk extends Eg{constructor(t,r,n,o){super(t,n,o),this.op=r}render({_n:t}){return`${this.lhs} ${this.op}= ${this.rhs};`+t}};i(Xk,"AssignOp");var Mk=Xk,Qk=class Qk extends Bn{constructor(t){super(),this.label=t,this.names={}}render({_n:t}){return`${this.label}:`+t}};i(Qk,"Label");var Zk=Qk,e$=class e$ extends Bn{constructor(t){super(),this.label=t,this.names={}}render({_n:t}){return`break${this.label?` ${this.label}`:""};`+t}};i(e$,"Break");var Lk=e$,t$=class t$ extends Bn{constructor(t){super(),this.error=t}render({_n:t}){return`throw ${this.error};`+t}get names(){return this.error.names}};i(t$,"Throw");var Fk=t$,r$=class r$ extends Bn{constructor(t){super(),this.code=t}render({_n:t}){return`${this.code};`+t}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(t,r){return this.code=oc(this.code,t,r),this}get names(){return this.code instanceof fe._CodeOrName?this.code.names:{}}};i(r$,"AnyCode");var Uk=r$,n$=class n$ extends Bn{constructor(t=[]){super(),this.nodes=t}render(t){return this.nodes.reduce((r,n)=>r+n.render(t),"")}optimizeNodes(){let{nodes:t}=this,r=t.length;for(;r--;){let n=t[r].optimizeNodes();Array.isArray(n)?t.splice(r,1,...n):n?t[r]=n:t.splice(r,1)}return t.length>0?this:void 0}optimizeNames(t,r){let{nodes:n}=this,o=n.length;for(;o--;){let s=n[o];s.optimizeNames(t,r)||(dte(t,s.names),n.splice(o,1))}return n.length>0?this:void 0}get names(){return this.nodes.reduce((t,r)=>ai(t,r.names),{})}};i(n$,"ParentNode");var pd=n$,o$=class o$ extends pd{render(t){return"{"+t._n+super.render(t)+"}"+t._n}};i(o$,"BlockNode");var Hn=o$,s$=class s$ extends pd{};i(s$,"Root");var qk=s$,i$=class i$ extends Hn{};i(i$,"Else");var nc=i$;nc.kind="else";var rc=class rc extends Hn{constructor(t,r){super(r),this.condition=t}render(t){let r=`if(${this.condition})`+super.render(t);return this.else&&(r+="else "+this.else.render(t)),r}optimizeNodes(){super.optimizeNodes();let t=this.condition;if(t===!0)return this.nodes;let r=this.else;if(r){let n=r.optimizeNodes();r=this.else=Array.isArray(n)?new nc(n):n}if(r)return t===!1?r instanceof rc?r:r.nodes:this.nodes.length?this:new rc(wF(t),r instanceof rc?[r]:r.nodes);if(!(t===!1||!this.nodes.length))return this}optimizeNames(t,r){var n;if(this.else=(n=this.else)===null||n===void 0?void 0:n.optimizeNames(t,r),!!(super.optimizeNames(t,r)||this.else))return this.condition=oc(this.condition,t,r),this}get names(){let t=super.names;return Tg(t,this.condition),this.else&&ai(t,this.else.names),t}};i(rc,"If");var si=rc;si.kind="if";var a$=class a$ extends Hn{};i(a$,"For");var ii=a$;ii.kind="for";var c$=class c$ extends ii{constructor(t){super(),this.iteration=t}render(t){return`for(${this.iteration})`+super.render(t)}optimizeNames(t,r){if(super.optimizeNames(t,r))return this.iteration=oc(this.iteration,t,r),this}get names(){return ai(super.names,this.iteration.names)}};i(c$,"ForLoop");var Bk=c$,l$=class l$ extends ii{constructor(t,r,n,o){super(),this.varKind=t,this.name=r,this.from=n,this.to=o}render(t){let r=t.es5?Pr.varKinds.var:this.varKind,{name:n,from:o,to:s}=this;return`for(${r} ${n}=${o}; ${n}<${s}; ${n}++)`+super.render(t)}get names(){let t=Tg(super.names,this.from);return Tg(t,this.to)}};i(l$,"ForRange");var Hk=l$,u$=class u$ extends ii{constructor(t,r,n,o){super(),this.loop=t,this.varKind=r,this.name=n,this.iterable=o}render(t){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(t)}optimizeNames(t,r){if(super.optimizeNames(t,r))return this.iterable=oc(this.iterable,t,r),this}get names(){return ai(super.names,this.iterable.names)}};i(u$,"ForIter");var Ng=u$,d$=class d$ extends Hn{constructor(t,r,n){super(),this.name=t,this.args=r,this.async=n}render(t){return`${this.async?"async ":""}function ${this.name}(${this.args})`+super.render(t)}};i(d$,"Func");var fd=d$;fd.kind="func";var p$=class p$ extends pd{render(t){return"return "+super.render(t)}};i(p$,"Return");var md=p$;md.kind="return";var f$=class f$ extends Hn{render(t){let r="try"+super.render(t);return this.catch&&(r+=this.catch.render(t)),this.finally&&(r+=this.finally.render(t)),r}optimizeNodes(){var t,r;return super.optimizeNodes(),(t=this.catch)===null||t===void 0||t.optimizeNodes(),(r=this.finally)===null||r===void 0||r.optimizeNodes(),this}optimizeNames(t,r){var n,o;return super.optimizeNames(t,r),(n=this.catch)===null||n===void 0||n.optimizeNames(t,r),(o=this.finally)===null||o===void 0||o.optimizeNames(t,r),this}get names(){let t=super.names;return this.catch&&ai(t,this.catch.names),this.finally&&ai(t,this.finally.names),t}};i(f$,"Try");var Vk=f$,m$=class m$ extends Hn{constructor(t){super(),this.error=t}render(t){return`catch(${this.error})`+super.render(t)}};i(m$,"Catch");var hd=m$;hd.kind="catch";var h$=class h$ extends Hn{render(t){return"finally"+super.render(t)}};i(h$,"Finally");var gd=h$;gd.kind="finally";var g$=class g${constructor(t,r={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...r,_n:r.lines?`
223
+ `:""},this._extScope=t,this._scope=new Pr.Scope({parent:t}),this._nodes=[new qk]}toString(){return this._root.render(this.opts)}name(t){return this._scope.name(t)}scopeName(t){return this._extScope.name(t)}scopeValue(t,r){let n=this._extScope.value(t,r);return(this._values[n.prefix]||(this._values[n.prefix]=new Set)).add(n),n}getScopeValue(t,r){return this._extScope.getValue(t,r)}scopeRefs(t){return this._extScope.scopeRefs(t,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def(t,r,n,o){let s=this._scope.toName(r);return n!==void 0&&o&&(this._constants[s.str]=n),this._leafNode(new Dk(t,s,n)),s}const(t,r,n){return this._def(Pr.varKinds.const,t,r,n)}let(t,r,n){return this._def(Pr.varKinds.let,t,r,n)}var(t,r,n){return this._def(Pr.varKinds.var,t,r,n)}assign(t,r,n){return this._leafNode(new Eg(t,r,n))}add(t,r){return this._leafNode(new Mk(t,ie.operators.ADD,r))}code(t){return typeof t=="function"?t():t!==fe.nil&&this._leafNode(new Uk(t)),this}object(...t){let r=["{"];for(let[n,o]of t)r.length>1&&r.push(","),r.push(n),(n!==o||this.opts.es5)&&(r.push(":"),(0,fe.addCodeArg)(r,o));return r.push("}"),new fe._Code(r)}if(t,r,n){if(this._blockNode(new si(t)),r&&n)this.code(r).else().code(n).endIf();else if(r)this.code(r).endIf();else if(n)throw new Error('CodeGen: "else" body without "then" body');return this}elseIf(t){return this._elseNode(new si(t))}else(){return this._elseNode(new nc)}endIf(){return this._endBlockNode(si,nc)}_for(t,r){return this._blockNode(t),r&&this.code(r).endFor(),this}for(t,r){return this._for(new Bk(t),r)}forRange(t,r,n,o,s=this.opts.es5?Pr.varKinds.var:Pr.varKinds.let){let a=this._scope.toName(t);return this._for(new Hk(s,a,r,n),()=>o(a))}forOf(t,r,n,o=Pr.varKinds.const){let s=this._scope.toName(t);if(this.opts.es5){let a=r instanceof fe.Name?r:this.var("_arr",r);return this.forRange("_i",0,(0,fe._)`${a}.length`,c=>{this.var(s,(0,fe._)`${a}[${c}]`),n(s)})}return this._for(new Ng("of",o,s,r),()=>n(s))}forIn(t,r,n,o=this.opts.es5?Pr.varKinds.var:Pr.varKinds.const){if(this.opts.ownProperties)return this.forOf(t,(0,fe._)`Object.keys(${r})`,n);let s=this._scope.toName(t);return this._for(new Ng("in",o,s,r),()=>n(s))}endFor(){return this._endBlockNode(ii)}label(t){return this._leafNode(new Zk(t))}break(t){return this._leafNode(new Lk(t))}return(t){let r=new md;if(this._blockNode(r),this.code(t),r.nodes.length!==1)throw new Error('CodeGen: "return" should have one node');return this._endBlockNode(md)}try(t,r,n){if(!r&&!n)throw new Error('CodeGen: "try" without "catch" and "finally"');let o=new Vk;if(this._blockNode(o),this.code(t),r){let s=this.name("e");this._currNode=o.catch=new hd(s),r(s)}return n&&(this._currNode=o.finally=new gd,this.code(n)),this._endBlockNode(hd,gd)}throw(t){return this._leafNode(new Fk(t))}block(t,r){return this._blockStarts.push(this._nodes.length),t&&this.code(t).endBlock(r),this}endBlock(t){let r=this._blockStarts.pop();if(r===void 0)throw new Error("CodeGen: not in self-balancing block");let n=this._nodes.length-r;if(n<0||t!==void 0&&n!==t)throw new Error(`CodeGen: wrong number of nodes: ${n} vs ${t} expected`);return this._nodes.length=r,this}func(t,r=fe.nil,n,o){return this._blockNode(new fd(t,r,n)),o&&this.code(o).endFunc(),this}endFunc(){return this._endBlockNode(fd)}optimize(t=1){for(;t-- >0;)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants)}_leafNode(t){return this._currNode.nodes.push(t),this}_blockNode(t){this._currNode.nodes.push(t),this._nodes.push(t)}_endBlockNode(t,r){let n=this._currNode;if(n instanceof t||r&&n instanceof r)return this._nodes.pop(),this;throw new Error(`CodeGen: not in block "${r?`${t.kind}/${r.kind}`:t.kind}"`)}_elseNode(t){let r=this._currNode;if(!(r instanceof si))throw new Error('CodeGen: "else" without "if"');return this._currNode=r.else=t,this}get _root(){return this._nodes[0]}get _currNode(){let t=this._nodes;return t[t.length-1]}set _currNode(t){let r=this._nodes;r[r.length-1]=t}};i(g$,"CodeGen");var Gk=g$;ie.CodeGen=Gk;function ai(e,t){for(let r in t)e[r]=(e[r]||0)+(t[r]||0);return e}i(ai,"addNames");function Tg(e,t){return t instanceof fe._CodeOrName?ai(e,t.names):e}i(Tg,"addExprNames");function oc(e,t,r){if(e instanceof fe.Name)return n(e);if(!o(e))return e;return new fe._Code(e._items.reduce((s,a)=>(a instanceof fe.Name&&(a=n(a)),a instanceof fe._Code?s.push(...a._items):s.push(a),s),[]));function n(s){let a=r[s.str];return a===void 0||t[s.str]!==1?s:(delete t[s.str],a)}function o(s){return s instanceof fe._Code&&s._items.some(a=>a instanceof fe.Name&&t[a.str]===1&&r[a.str]!==void 0)}}i(oc,"optimizeExpr");function dte(e,t){for(let r in t)e[r]=(e[r]||0)-(t[r]||0)}i(dte,"subtractNames");function wF(e){return typeof e=="boolean"||typeof e=="number"||e===null?!e:(0,fe._)`!${Wk(e)}`}i(wF,"not");ie.not=wF;var pte=bF(ie.operators.AND);function fte(...e){return e.reduce(pte)}i(fte,"and");ie.and=fte;var mte=bF(ie.operators.OR);function hte(...e){return e.reduce(mte)}i(hte,"or");ie.or=hte;function bF(e){return(t,r)=>t===fe.nil?r:r===fe.nil?t:(0,fe._)`${Wk(t)} ${e} ${Wk(r)}`}i(bF,"mappend");function Wk(e){return e instanceof fe.Name?e:(0,fe._)`(${e})`}i(Wk,"par")});var me=F(ae=>{"use strict";Object.defineProperty(ae,"__esModule",{value:!0});ae.checkStrictMode=ae.getErrorPath=ae.Type=ae.useFunc=ae.setEvaluated=ae.evaluatedPropsToName=ae.mergeEvaluated=ae.eachItem=ae.unescapeJsonPointer=ae.escapeJsonPointer=ae.escapeFragment=ae.unescapeFragment=ae.schemaRefOrVal=ae.schemaHasRulesButRef=ae.schemaHasRules=ae.checkUnknownRules=ae.alwaysValidSchema=ae.toHash=void 0;var $e=se(),gte=dd();function yte(e){let t={};for(let r of e)t[r]=!0;return t}i(yte,"toHash");ae.toHash=yte;function xte(e,t){return typeof t=="boolean"?t:Object.keys(t).length===0?!0:($F(e,t),!EF(t,e.self.RULES.all))}i(xte,"alwaysValidSchema");ae.alwaysValidSchema=xte;function $F(e,t=e.schema){let{opts:r,self:n}=e;if(!r.strictSchema||typeof t=="boolean")return;let o=n.RULES.keywords;for(let s in t)o[s]||zF(e,`unknown keyword: "${s}"`)}i($F,"checkUnknownRules");ae.checkUnknownRules=$F;function EF(e,t){if(typeof e=="boolean")return!e;for(let r in e)if(t[r])return!0;return!1}i(EF,"schemaHasRules");ae.schemaHasRules=EF;function _te(e,t){if(typeof e=="boolean")return!e;for(let r in e)if(r!=="$ref"&&t.all[r])return!0;return!1}i(_te,"schemaHasRulesButRef");ae.schemaHasRulesButRef=_te;function vte({topSchemaRef:e,schemaPath:t},r,n,o){if(!o){if(typeof r=="number"||typeof r=="boolean")return r;if(typeof r=="string")return(0,$e._)`${r}`}return(0,$e._)`${e}${t}${(0,$e.getProperty)(n)}`}i(vte,"schemaRefOrVal");ae.schemaRefOrVal=vte;function wte(e){return NF(decodeURIComponent(e))}i(wte,"unescapeFragment");ae.unescapeFragment=wte;function bte(e){return encodeURIComponent(x$(e))}i(bte,"escapeFragment");ae.escapeFragment=bte;function x$(e){return typeof e=="number"?`${e}`:e.replace(/~/g,"~0").replace(/\//g,"~1")}i(x$,"escapeJsonPointer");ae.escapeJsonPointer=x$;function NF(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}i(NF,"unescapeJsonPointer");ae.unescapeJsonPointer=NF;function Ste(e,t){if(Array.isArray(e))for(let r of e)t(r);else t(e)}i(Ste,"eachItem");ae.eachItem=Ste;function SF({mergeNames:e,mergeToName:t,mergeValues:r,resultToName:n}){return(o,s,a,c)=>{let l=a===void 0?s:a instanceof $e.Name?(s instanceof $e.Name?e(o,s,a):t(o,s,a),a):s instanceof $e.Name?(t(o,a,s),s):r(s,a);return c===$e.Name&&!(l instanceof $e.Name)?n(o,l):l}}i(SF,"makeMergeEvaluated");ae.mergeEvaluated={props:SF({mergeNames:(e,t,r)=>e.if((0,$e._)`${r} !== true && ${t} !== undefined`,()=>{e.if((0,$e._)`${t} === true`,()=>e.assign(r,!0),()=>e.assign(r,(0,$e._)`${r} || {}`).code((0,$e._)`Object.assign(${r}, ${t})`))}),mergeToName:(e,t,r)=>e.if((0,$e._)`${r} !== true`,()=>{t===!0?e.assign(r,!0):(e.assign(r,(0,$e._)`${r} || {}`),_$(e,r,t))}),mergeValues:(e,t)=>e===!0?!0:{...e,...t},resultToName:TF}),items:SF({mergeNames:(e,t,r)=>e.if((0,$e._)`${r} !== true && ${t} !== undefined`,()=>e.assign(r,(0,$e._)`${t} === true ? true : ${r} > ${t} ? ${r} : ${t}`)),mergeToName:(e,t,r)=>e.if((0,$e._)`${r} !== true`,()=>e.assign(r,t===!0?!0:(0,$e._)`${r} > ${t} ? ${r} : ${t}`)),mergeValues:(e,t)=>e===!0?!0:Math.max(e,t),resultToName:(e,t)=>e.var("items",t)})};function TF(e,t){if(t===!0)return e.var("props",!0);let r=e.var("props",(0,$e._)`{}`);return t!==void 0&&_$(e,r,t),r}i(TF,"evaluatedPropsToName");ae.evaluatedPropsToName=TF;function _$(e,t,r){Object.keys(r).forEach(n=>e.assign((0,$e._)`${t}${(0,$e.getProperty)(n)}`,!0))}i(_$,"setEvaluated");ae.setEvaluated=_$;var kF={};function kte(e,t){return e.scopeValue("func",{ref:t,code:kF[t.code]||(kF[t.code]=new gte._Code(t.code))})}i(kte,"useFunc");ae.useFunc=kte;var y$;(function(e){e[e.Num=0]="Num",e[e.Str=1]="Str"})(y$||(ae.Type=y$={}));function $te(e,t,r){if(e instanceof $e.Name){let n=t===y$.Num;return r?n?(0,$e._)`"[" + ${e} + "]"`:(0,$e._)`"['" + ${e} + "']"`:n?(0,$e._)`"/" + ${e}`:(0,$e._)`"/" + ${e}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return r?(0,$e.getProperty)(e).toString():"/"+x$(e)}i($te,"getErrorPath");ae.getErrorPath=$te;function zF(e,t,r=e.opts.strictSchema){if(r){if(t=`strict mode: ${t}`,r===!0)throw new Error(t);e.self.logger.warn(t)}}i(zF,"checkStrictMode");ae.checkStrictMode=zF});var Vn=F(v$=>{"use strict";Object.defineProperty(v$,"__esModule",{value:!0});var dt=se(),Ete={data:new dt.Name("data"),valCxt:new dt.Name("valCxt"),instancePath:new dt.Name("instancePath"),parentData:new dt.Name("parentData"),parentDataProperty:new dt.Name("parentDataProperty"),rootData:new dt.Name("rootData"),dynamicAnchors:new dt.Name("dynamicAnchors"),vErrors:new dt.Name("vErrors"),errors:new dt.Name("errors"),this:new dt.Name("this"),self:new dt.Name("self"),scope:new dt.Name("scope"),json:new dt.Name("json"),jsonPos:new dt.Name("jsonPos"),jsonLen:new dt.Name("jsonLen"),jsonPart:new dt.Name("jsonPart")};v$.default=Ete});var yd=F(pt=>{"use strict";Object.defineProperty(pt,"__esModule",{value:!0});pt.extendErrors=pt.resetErrorsCount=pt.reportExtraError=pt.reportError=pt.keyword$DataError=pt.keywordError=void 0;var he=se(),Cg=me(),St=Vn();pt.keywordError={message:({keyword:e})=>(0,he.str)`must pass "${e}" keyword validation`};pt.keyword$DataError={message:({keyword:e,schemaType:t})=>t?(0,he.str)`"${e}" keyword must be ${t} ($data)`:(0,he.str)`"${e}" keyword is invalid ($data)`};function Nte(e,t=pt.keywordError,r,n){let{it:o}=e,{gen:s,compositeRule:a,allErrors:c}=o,l=PF(e,t,r);n??(a||c)?CF(s,l):IF(o,(0,he._)`[${l}]`)}i(Nte,"reportError");pt.reportError=Nte;function Tte(e,t=pt.keywordError,r){let{it:n}=e,{gen:o,compositeRule:s,allErrors:a}=n,c=PF(e,t,r);CF(o,c),s||a||IF(n,St.default.vErrors)}i(Tte,"reportExtraError");pt.reportExtraError=Tte;function zte(e,t){e.assign(St.default.errors,t),e.if((0,he._)`${St.default.vErrors} !== null`,()=>e.if(t,()=>e.assign((0,he._)`${St.default.vErrors}.length`,t),()=>e.assign(St.default.vErrors,null)))}i(zte,"resetErrorsCount");pt.resetErrorsCount=zte;function Cte({gen:e,keyword:t,schemaValue:r,data:n,errsCount:o,it:s}){if(o===void 0)throw new Error("ajv implementation error");let a=e.name("err");e.forRange("i",o,St.default.errors,c=>{e.const(a,(0,he._)`${St.default.vErrors}[${c}]`),e.if((0,he._)`${a}.instancePath === undefined`,()=>e.assign((0,he._)`${a}.instancePath`,(0,he.strConcat)(St.default.instancePath,s.errorPath))),e.assign((0,he._)`${a}.schemaPath`,(0,he.str)`${s.errSchemaPath}/${t}`),s.opts.verbose&&(e.assign((0,he._)`${a}.schema`,r),e.assign((0,he._)`${a}.data`,n))})}i(Cte,"extendErrors");pt.extendErrors=Cte;function CF(e,t){let r=e.const("err",t);e.if((0,he._)`${St.default.vErrors} === null`,()=>e.assign(St.default.vErrors,(0,he._)`[${r}]`),(0,he._)`${St.default.vErrors}.push(${r})`),e.code((0,he._)`${St.default.errors}++`)}i(CF,"addError");function IF(e,t){let{gen:r,validateName:n,schemaEnv:o}=e;o.$async?r.throw((0,he._)`new ${e.ValidationError}(${t})`):(r.assign((0,he._)`${n}.errors`,t),r.return(!1))}i(IF,"returnErrors");var ci={keyword:new he.Name("keyword"),schemaPath:new he.Name("schemaPath"),params:new he.Name("params"),propertyName:new he.Name("propertyName"),message:new he.Name("message"),schema:new he.Name("schema"),parentSchema:new he.Name("parentSchema")};function PF(e,t,r){let{createErrors:n}=e.it;return n===!1?(0,he._)`{}`:Ite(e,t,r)}i(PF,"errorObjectCode");function Ite(e,t,r={}){let{gen:n,it:o}=e,s=[Pte(o,r),Ote(e,r)];return Ate(e,t,s),n.object(...s)}i(Ite,"errorObject");function Pte({errorPath:e},{instancePath:t}){let r=t?(0,he.str)`${e}${(0,Cg.getErrorPath)(t,Cg.Type.Str)}`:e;return[St.default.instancePath,(0,he.strConcat)(St.default.instancePath,r)]}i(Pte,"errorInstancePath");function Ote({keyword:e,it:{errSchemaPath:t}},{schemaPath:r,parentSchema:n}){let o=n?t:(0,he.str)`${t}/${e}`;return r&&(o=(0,he.str)`${o}${(0,Cg.getErrorPath)(r,Cg.Type.Str)}`),[ci.schemaPath,o]}i(Ote,"errorSchemaPath");function Ate(e,{params:t,message:r},n){let{keyword:o,data:s,schemaValue:a,it:c}=e,{opts:l,propertyName:u,topSchemaRef:d,schemaPath:p}=c;n.push([ci.keyword,o],[ci.params,typeof t=="function"?t(e):t||(0,he._)`{}`]),l.messages&&n.push([ci.message,typeof r=="function"?r(e):r]),l.verbose&&n.push([ci.schema,a],[ci.parentSchema,(0,he._)`${d}${p}`],[St.default.data,s]),u&&n.push([ci.propertyName,u])}i(Ate,"extraErrorProps")});var AF=F(sc=>{"use strict";Object.defineProperty(sc,"__esModule",{value:!0});sc.boolOrEmptySchema=sc.topBoolOrEmptySchema=void 0;var Rte=yd(),jte=se(),Dte=Vn(),Mte={message:"boolean schema is false"};function Zte(e){let{gen:t,schema:r,validateName:n}=e;r===!1?OF(e,!1):typeof r=="object"&&r.$async===!0?t.return(Dte.default.data):(t.assign((0,jte._)`${n}.errors`,null),t.return(!0))}i(Zte,"topBoolOrEmptySchema");sc.topBoolOrEmptySchema=Zte;function Lte(e,t){let{gen:r,schema:n}=e;n===!1?(r.var(t,!1),OF(e)):r.var(t,!0)}i(Lte,"boolOrEmptySchema");sc.boolOrEmptySchema=Lte;function OF(e,t){let{gen:r,data:n}=e,o={gen:r,keyword:"false schema",data:n,schema:!1,schemaCode:!1,schemaValue:!1,params:{},it:e};(0,Rte.reportError)(o,Mte,void 0,t)}i(OF,"falseSchemaError")});var w$=F(ic=>{"use strict";Object.defineProperty(ic,"__esModule",{value:!0});ic.getRules=ic.isJSONType=void 0;var Fte=["string","number","integer","boolean","null","object","array"],Ute=new Set(Fte);function qte(e){return typeof e=="string"&&Ute.has(e)}i(qte,"isJSONType");ic.isJSONType=qte;function Bte(){let e={number:{type:"number",rules:[]},string:{type:"string",rules:[]},array:{type:"array",rules:[]},object:{type:"object",rules:[]}};return{types:{...e,integer:!0,boolean:!0,null:!0},rules:[{rules:[]},e.number,e.string,e.array,e.object],post:{rules:[]},all:{},keywords:{}}}i(Bte,"getRules");ic.getRules=Bte});var b$=F(To=>{"use strict";Object.defineProperty(To,"__esModule",{value:!0});To.shouldUseRule=To.shouldUseGroup=To.schemaHasRulesForType=void 0;function Hte({schema:e,self:t},r){let n=t.RULES.types[r];return n&&n!==!0&&RF(e,n)}i(Hte,"schemaHasRulesForType");To.schemaHasRulesForType=Hte;function RF(e,t){return t.rules.some(r=>jF(e,r))}i(RF,"shouldUseGroup");To.shouldUseGroup=RF;function jF(e,t){var r;return e[t.keyword]!==void 0||((r=t.definition.implements)===null||r===void 0?void 0:r.some(n=>e[n]!==void 0))}i(jF,"shouldUseRule");To.shouldUseRule=jF});var xd=F(ft=>{"use strict";Object.defineProperty(ft,"__esModule",{value:!0});ft.reportTypeError=ft.checkDataTypes=ft.checkDataType=ft.coerceAndCheckDataType=ft.getJSONTypes=ft.getSchemaTypes=ft.DataType=void 0;var Vte=w$(),Gte=b$(),Wte=yd(),ne=se(),DF=me(),ac;(function(e){e[e.Correct=0]="Correct",e[e.Wrong=1]="Wrong"})(ac||(ft.DataType=ac={}));function Jte(e){let t=MF(e.type);if(t.includes("null")){if(e.nullable===!1)throw new Error("type: null contradicts nullable: false")}else{if(!t.length&&e.nullable!==void 0)throw new Error('"nullable" cannot be used without "type"');e.nullable===!0&&t.push("null")}return t}i(Jte,"getSchemaTypes");ft.getSchemaTypes=Jte;function MF(e){let t=Array.isArray(e)?e:e?[e]:[];if(t.every(Vte.isJSONType))return t;throw new Error("type must be JSONType or JSONType[]: "+t.join(","))}i(MF,"getJSONTypes");ft.getJSONTypes=MF;function Kte(e,t){let{gen:r,data:n,opts:o}=e,s=Yte(t,o.coerceTypes),a=t.length>0&&!(s.length===0&&t.length===1&&(0,Gte.schemaHasRulesForType)(e,t[0]));if(a){let c=k$(t,n,o.strictNumbers,ac.Wrong);r.if(c,()=>{s.length?Xte(e,t,s):$$(e)})}return a}i(Kte,"coerceAndCheckDataType");ft.coerceAndCheckDataType=Kte;var ZF=new Set(["string","number","integer","boolean","null"]);function Yte(e,t){return t?e.filter(r=>ZF.has(r)||t==="array"&&r==="array"):[]}i(Yte,"coerceToTypes");function Xte(e,t,r){let{gen:n,data:o,opts:s}=e,a=n.let("dataType",(0,ne._)`typeof ${o}`),c=n.let("coerced",(0,ne._)`undefined`);s.coerceTypes==="array"&&n.if((0,ne._)`${a} == 'object' && Array.isArray(${o}) && ${o}.length == 1`,()=>n.assign(o,(0,ne._)`${o}[0]`).assign(a,(0,ne._)`typeof ${o}`).if(k$(t,o,s.strictNumbers),()=>n.assign(c,o))),n.if((0,ne._)`${c} !== undefined`);for(let u of r)(ZF.has(u)||u==="array"&&s.coerceTypes==="array")&&l(u);n.else(),$$(e),n.endIf(),n.if((0,ne._)`${c} !== undefined`,()=>{n.assign(o,c),Qte(e,c)});function l(u){switch(u){case"string":n.elseIf((0,ne._)`${a} == "number" || ${a} == "boolean"`).assign(c,(0,ne._)`"" + ${o}`).elseIf((0,ne._)`${o} === null`).assign(c,(0,ne._)`""`);return;case"number":n.elseIf((0,ne._)`${a} == "boolean" || ${o} === null
224
+ || (${a} == "string" && ${o} && ${o} == +${o})`).assign(c,(0,ne._)`+${o}`);return;case"integer":n.elseIf((0,ne._)`${a} === "boolean" || ${o} === null
225
+ || (${a} === "string" && ${o} && ${o} == +${o} && !(${o} % 1))`).assign(c,(0,ne._)`+${o}`);return;case"boolean":n.elseIf((0,ne._)`${o} === "false" || ${o} === 0 || ${o} === null`).assign(c,!1).elseIf((0,ne._)`${o} === "true" || ${o} === 1`).assign(c,!0);return;case"null":n.elseIf((0,ne._)`${o} === "" || ${o} === 0 || ${o} === false`),n.assign(c,null);return;case"array":n.elseIf((0,ne._)`${a} === "string" || ${a} === "number"
226
+ || ${a} === "boolean" || ${o} === null`).assign(c,(0,ne._)`[${o}]`)}}i(l,"coerceSpecificType")}i(Xte,"coerceData");function Qte({gen:e,parentData:t,parentDataProperty:r},n){e.if((0,ne._)`${t} !== undefined`,()=>e.assign((0,ne._)`${t}[${r}]`,n))}i(Qte,"assignParentData");function S$(e,t,r,n=ac.Correct){let o=n===ac.Correct?ne.operators.EQ:ne.operators.NEQ,s;switch(e){case"null":return(0,ne._)`${t} ${o} null`;case"array":s=(0,ne._)`Array.isArray(${t})`;break;case"object":s=(0,ne._)`${t} && typeof ${t} == "object" && !Array.isArray(${t})`;break;case"integer":s=a((0,ne._)`!(${t} % 1) && !isNaN(${t})`);break;case"number":s=a();break;default:return(0,ne._)`typeof ${t} ${o} ${e}`}return n===ac.Correct?s:(0,ne.not)(s);function a(c=ne.nil){return(0,ne.and)((0,ne._)`typeof ${t} == "number"`,c,r?(0,ne._)`isFinite(${t})`:ne.nil)}}i(S$,"checkDataType");ft.checkDataType=S$;function k$(e,t,r,n){if(e.length===1)return S$(e[0],t,r,n);let o,s=(0,DF.toHash)(e);if(s.array&&s.object){let a=(0,ne._)`typeof ${t} != "object"`;o=s.null?a:(0,ne._)`!${t} || ${a}`,delete s.null,delete s.array,delete s.object}else o=ne.nil;s.number&&delete s.integer;for(let a in s)o=(0,ne.and)(o,S$(a,t,r,n));return o}i(k$,"checkDataTypes");ft.checkDataTypes=k$;var ere={message:({schema:e})=>`must be ${e}`,params:({schema:e,schemaValue:t})=>typeof e=="string"?(0,ne._)`{type: ${e}}`:(0,ne._)`{type: ${t}}`};function $$(e){let t=tre(e);(0,Wte.reportError)(t,ere)}i($$,"reportTypeError");ft.reportTypeError=$$;function tre(e){let{gen:t,data:r,schema:n}=e,o=(0,DF.schemaRefOrVal)(e,n,"type");return{gen:t,keyword:"type",data:r,schema:n.type,schemaCode:o,schemaValue:o,parentSchema:n,params:{},it:e}}i(tre,"getTypeErrorContext")});var FF=F(Ig=>{"use strict";Object.defineProperty(Ig,"__esModule",{value:!0});Ig.assignDefaults=void 0;var cc=se(),rre=me();function nre(e,t){let{properties:r,items:n}=e.schema;if(t==="object"&&r)for(let o in r)LF(e,o,r[o].default);else t==="array"&&Array.isArray(n)&&n.forEach((o,s)=>LF(e,s,o.default))}i(nre,"assignDefaults");Ig.assignDefaults=nre;function LF(e,t,r){let{gen:n,compositeRule:o,data:s,opts:a}=e;if(r===void 0)return;let c=(0,cc._)`${s}${(0,cc.getProperty)(t)}`;if(o){(0,rre.checkStrictMode)(e,`default is ignored for: ${c}`);return}let l=(0,cc._)`${c} === undefined`;a.useDefaults==="empty"&&(l=(0,cc._)`${l} || ${c} === null || ${c} === ""`),n.if(l,(0,cc._)`${c} = ${(0,cc.stringify)(r)}`)}i(LF,"assignDefault")});var mr=F(ke=>{"use strict";Object.defineProperty(ke,"__esModule",{value:!0});ke.validateUnion=ke.validateArray=ke.usePattern=ke.callValidateCode=ke.schemaProperties=ke.allSchemaProperties=ke.noPropertyInData=ke.propertyInData=ke.isOwnProperty=ke.hasPropFunc=ke.reportMissingProp=ke.checkMissingProp=ke.checkReportMissingProp=void 0;var Re=se(),E$=me(),zo=Vn(),ore=me();function sre(e,t){let{gen:r,data:n,it:o}=e;r.if(T$(r,n,t,o.opts.ownProperties),()=>{e.setParams({missingProperty:(0,Re._)`${t}`},!0),e.error()})}i(sre,"checkReportMissingProp");ke.checkReportMissingProp=sre;function ire({gen:e,data:t,it:{opts:r}},n,o){return(0,Re.or)(...n.map(s=>(0,Re.and)(T$(e,t,s,r.ownProperties),(0,Re._)`${o} = ${s}`)))}i(ire,"checkMissingProp");ke.checkMissingProp=ire;function are(e,t){e.setParams({missingProperty:t},!0),e.error()}i(are,"reportMissingProp");ke.reportMissingProp=are;function UF(e){return e.scopeValue("func",{ref:Object.prototype.hasOwnProperty,code:(0,Re._)`Object.prototype.hasOwnProperty`})}i(UF,"hasPropFunc");ke.hasPropFunc=UF;function N$(e,t,r){return(0,Re._)`${UF(e)}.call(${t}, ${r})`}i(N$,"isOwnProperty");ke.isOwnProperty=N$;function cre(e,t,r,n){let o=(0,Re._)`${t}${(0,Re.getProperty)(r)} !== undefined`;return n?(0,Re._)`${o} && ${N$(e,t,r)}`:o}i(cre,"propertyInData");ke.propertyInData=cre;function T$(e,t,r,n){let o=(0,Re._)`${t}${(0,Re.getProperty)(r)} === undefined`;return n?(0,Re.or)(o,(0,Re.not)(N$(e,t,r))):o}i(T$,"noPropertyInData");ke.noPropertyInData=T$;function qF(e){return e?Object.keys(e).filter(t=>t!=="__proto__"):[]}i(qF,"allSchemaProperties");ke.allSchemaProperties=qF;function lre(e,t){return qF(t).filter(r=>!(0,E$.alwaysValidSchema)(e,t[r]))}i(lre,"schemaProperties");ke.schemaProperties=lre;function ure({schemaCode:e,data:t,it:{gen:r,topSchemaRef:n,schemaPath:o,errorPath:s},it:a},c,l,u){let d=u?(0,Re._)`${e}, ${t}, ${n}${o}`:t,p=[[zo.default.instancePath,(0,Re.strConcat)(zo.default.instancePath,s)],[zo.default.parentData,a.parentData],[zo.default.parentDataProperty,a.parentDataProperty],[zo.default.rootData,zo.default.rootData]];a.opts.dynamicRef&&p.push([zo.default.dynamicAnchors,zo.default.dynamicAnchors]);let m=(0,Re._)`${d}, ${r.object(...p)}`;return l!==Re.nil?(0,Re._)`${c}.call(${l}, ${m})`:(0,Re._)`${c}(${m})`}i(ure,"callValidateCode");ke.callValidateCode=ure;var dre=(0,Re._)`new RegExp`;function pre({gen:e,it:{opts:t}},r){let n=t.unicodeRegExp?"u":"",{regExp:o}=t.code,s=o(r,n);return e.scopeValue("pattern",{key:s.toString(),ref:s,code:(0,Re._)`${o.code==="new RegExp"?dre:(0,ore.useFunc)(e,o)}(${r}, ${n})`})}i(pre,"usePattern");ke.usePattern=pre;function fre(e){let{gen:t,data:r,keyword:n,it:o}=e,s=t.name("valid");if(o.allErrors){let c=t.let("valid",!0);return a(()=>t.assign(c,!1)),c}return t.var(s,!0),a(()=>t.break()),s;function a(c){let l=t.const("len",(0,Re._)`${r}.length`);t.forRange("i",0,l,u=>{e.subschema({keyword:n,dataProp:u,dataPropType:E$.Type.Num},s),t.if((0,Re.not)(s),c)})}i(a,"validateItems")}i(fre,"validateArray");ke.validateArray=fre;function mre(e){let{gen:t,schema:r,keyword:n,it:o}=e;if(!Array.isArray(r))throw new Error("ajv implementation error");if(r.some(l=>(0,E$.alwaysValidSchema)(o,l))&&!o.opts.unevaluated)return;let a=t.let("valid",!1),c=t.name("_valid");t.block(()=>r.forEach((l,u)=>{let d=e.subschema({keyword:n,schemaProp:u,compositeRule:!0},c);t.assign(a,(0,Re._)`${a} || ${c}`),e.mergeValidEvaluated(d,c)||t.if((0,Re.not)(a))})),e.result(a,()=>e.reset(),()=>e.error(!0))}i(mre,"validateUnion");ke.validateUnion=mre});var VF=F(nn=>{"use strict";Object.defineProperty(nn,"__esModule",{value:!0});nn.validateKeywordUsage=nn.validSchemaType=nn.funcKeywordCode=nn.macroKeywordCode=void 0;var kt=se(),li=Vn(),hre=mr(),gre=yd();function yre(e,t){let{gen:r,keyword:n,schema:o,parentSchema:s,it:a}=e,c=t.macro.call(a.self,o,s,a),l=HF(r,n,c);a.opts.validateSchema!==!1&&a.self.validateSchema(c,!0);let u=r.name("valid");e.subschema({schema:c,schemaPath:kt.nil,errSchemaPath:`${a.errSchemaPath}/${n}`,topSchemaRef:l,compositeRule:!0},u),e.pass(u,()=>e.error(!0))}i(yre,"macroKeywordCode");nn.macroKeywordCode=yre;function xre(e,t){var r;let{gen:n,keyword:o,schema:s,parentSchema:a,$data:c,it:l}=e;vre(l,t);let u=!c&&t.compile?t.compile.call(l.self,s,a,l):t.validate,d=HF(n,o,u),p=n.let("valid");e.block$data(p,m),e.ok((r=t.valid)!==null&&r!==void 0?r:p);function m(){if(t.errors===!1)_(),t.modifying&&BF(e),x(()=>e.error());else{let v=t.async?h():g();t.modifying&&BF(e),x(()=>_re(e,v))}}i(m,"validateKeyword");function h(){let v=n.let("ruleErrs",null);return n.try(()=>_((0,kt._)`await `),b=>n.assign(p,!1).if((0,kt._)`${b} instanceof ${l.ValidationError}`,()=>n.assign(v,(0,kt._)`${b}.errors`),()=>n.throw(b))),v}i(h,"validateAsync");function g(){let v=(0,kt._)`${d}.errors`;return n.assign(v,null),_(kt.nil),v}i(g,"validateSync");function _(v=t.async?(0,kt._)`await `:kt.nil){let b=l.opts.passContext?li.default.this:li.default.self,w=!("compile"in t&&!c||t.schema===!1);n.assign(p,(0,kt._)`${v}${(0,hre.callValidateCode)(e,d,b,w)}`,t.modifying)}i(_,"assignValid");function x(v){var b;n.if((0,kt.not)((b=t.valid)!==null&&b!==void 0?b:p),v)}i(x,"reportErrs")}i(xre,"funcKeywordCode");nn.funcKeywordCode=xre;function BF(e){let{gen:t,data:r,it:n}=e;t.if(n.parentData,()=>t.assign(r,(0,kt._)`${n.parentData}[${n.parentDataProperty}]`))}i(BF,"modifyData");function _re(e,t){let{gen:r}=e;r.if((0,kt._)`Array.isArray(${t})`,()=>{r.assign(li.default.vErrors,(0,kt._)`${li.default.vErrors} === null ? ${t} : ${li.default.vErrors}.concat(${t})`).assign(li.default.errors,(0,kt._)`${li.default.vErrors}.length`),(0,gre.extendErrors)(e)},()=>e.error())}i(_re,"addErrs");function vre({schemaEnv:e},t){if(t.async&&!e.$async)throw new Error("async keyword in sync schema")}i(vre,"checkAsyncKeyword");function HF(e,t,r){if(r===void 0)throw new Error(`keyword "${t}" failed to compile`);return e.scopeValue("keyword",typeof r=="function"?{ref:r}:{ref:r,code:(0,kt.stringify)(r)})}i(HF,"useKeyword");function wre(e,t,r=!1){return!t.length||t.some(n=>n==="array"?Array.isArray(e):n==="object"?e&&typeof e=="object"&&!Array.isArray(e):typeof e==n||r&&typeof e>"u")}i(wre,"validSchemaType");nn.validSchemaType=wre;function bre({schema:e,opts:t,self:r,errSchemaPath:n},o,s){if(Array.isArray(o.keyword)?!o.keyword.includes(s):o.keyword!==s)throw new Error("ajv implementation error");let a=o.dependencies;if(a?.some(c=>!Object.prototype.hasOwnProperty.call(e,c)))throw new Error(`parent schema must have dependencies of ${s}: ${a.join(",")}`);if(o.validateSchema&&!o.validateSchema(e[s])){let l=`keyword "${s}" value is invalid at path "${n}": `+r.errorsText(o.validateSchema.errors);if(t.validateSchema==="log")r.logger.error(l);else throw new Error(l)}}i(bre,"validateKeywordUsage");nn.validateKeywordUsage=bre});var WF=F(Co=>{"use strict";Object.defineProperty(Co,"__esModule",{value:!0});Co.extendSubschemaMode=Co.extendSubschemaData=Co.getSubschema=void 0;var on=se(),GF=me();function Sre(e,{keyword:t,schemaProp:r,schema:n,schemaPath:o,errSchemaPath:s,topSchemaRef:a}){if(t!==void 0&&n!==void 0)throw new Error('both "keyword" and "schema" passed, only one allowed');if(t!==void 0){let c=e.schema[t];return r===void 0?{schema:c,schemaPath:(0,on._)`${e.schemaPath}${(0,on.getProperty)(t)}`,errSchemaPath:`${e.errSchemaPath}/${t}`}:{schema:c[r],schemaPath:(0,on._)`${e.schemaPath}${(0,on.getProperty)(t)}${(0,on.getProperty)(r)}`,errSchemaPath:`${e.errSchemaPath}/${t}/${(0,GF.escapeFragment)(r)}`}}if(n!==void 0){if(o===void 0||s===void 0||a===void 0)throw new Error('"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"');return{schema:n,schemaPath:o,topSchemaRef:a,errSchemaPath:s}}throw new Error('either "keyword" or "schema" must be passed')}i(Sre,"getSubschema");Co.getSubschema=Sre;function kre(e,t,{dataProp:r,dataPropType:n,data:o,dataTypes:s,propertyName:a}){if(o!==void 0&&r!==void 0)throw new Error('both "data" and "dataProp" passed, only one allowed');let{gen:c}=t;if(r!==void 0){let{errorPath:u,dataPathArr:d,opts:p}=t,m=c.let("data",(0,on._)`${t.data}${(0,on.getProperty)(r)}`,!0);l(m),e.errorPath=(0,on.str)`${u}${(0,GF.getErrorPath)(r,n,p.jsPropertySyntax)}`,e.parentDataProperty=(0,on._)`${r}`,e.dataPathArr=[...d,e.parentDataProperty]}if(o!==void 0){let u=o instanceof on.Name?o:c.let("data",o,!0);l(u),a!==void 0&&(e.propertyName=a)}s&&(e.dataTypes=s);function l(u){e.data=u,e.dataLevel=t.dataLevel+1,e.dataTypes=[],t.definedProperties=new Set,e.parentData=t.data,e.dataNames=[...t.dataNames,u]}i(l,"dataContextProps")}i(kre,"extendSubschemaData");Co.extendSubschemaData=kre;function $re(e,{jtdDiscriminator:t,jtdMetadata:r,compositeRule:n,createErrors:o,allErrors:s}){n!==void 0&&(e.compositeRule=n),o!==void 0&&(e.createErrors=o),s!==void 0&&(e.allErrors=s),e.jtdDiscriminator=t,e.jtdMetadata=r}i($re,"extendSubschemaMode");Co.extendSubschemaMode=$re});var z$=F((i3e,JF)=>{"use strict";JF.exports=i(function e(t,r){if(t===r)return!0;if(t&&r&&typeof t=="object"&&typeof r=="object"){if(t.constructor!==r.constructor)return!1;var n,o,s;if(Array.isArray(t)){if(n=t.length,n!=r.length)return!1;for(o=n;o--!==0;)if(!e(t[o],r[o]))return!1;return!0}if(t.constructor===RegExp)return t.source===r.source&&t.flags===r.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===r.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===r.toString();if(s=Object.keys(t),n=s.length,n!==Object.keys(r).length)return!1;for(o=n;o--!==0;)if(!Object.prototype.hasOwnProperty.call(r,s[o]))return!1;for(o=n;o--!==0;){var a=s[o];if(!e(t[a],r[a]))return!1}return!0}return t!==t&&r!==r},"equal")});var YF=F((c3e,KF)=>{"use strict";var Io=KF.exports=function(e,t,r){typeof t=="function"&&(r=t,t={}),r=t.cb||r;var n=typeof r=="function"?r:r.pre||function(){},o=r.post||function(){};Pg(t,n,o,e,"",e)};Io.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0,if:!0,then:!0,else:!0};Io.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0};Io.propsKeywords={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependencies:!0};Io.skipKeywords={default:!0,enum:!0,const:!0,required:!0,maximum:!0,minimum:!0,exclusiveMaximum:!0,exclusiveMinimum:!0,multipleOf:!0,maxLength:!0,minLength:!0,pattern:!0,format:!0,maxItems:!0,minItems:!0,uniqueItems:!0,maxProperties:!0,minProperties:!0};function Pg(e,t,r,n,o,s,a,c,l,u){if(n&&typeof n=="object"&&!Array.isArray(n)){t(n,o,s,a,c,l,u);for(var d in n){var p=n[d];if(Array.isArray(p)){if(d in Io.arrayKeywords)for(var m=0;m<p.length;m++)Pg(e,t,r,p[m],o+"/"+d+"/"+m,s,o,d,n,m)}else if(d in Io.propsKeywords){if(p&&typeof p=="object")for(var h in p)Pg(e,t,r,p[h],o+"/"+d+"/"+Ere(h),s,o,d,n,h)}else(d in Io.keywords||e.allKeys&&!(d in Io.skipKeywords))&&Pg(e,t,r,p,o+"/"+d,s,o,d,n)}r(n,o,s,a,c,l,u)}}i(Pg,"_traverse");function Ere(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}i(Ere,"escapeJsonPtr")});var _d=F(Rt=>{"use strict";Object.defineProperty(Rt,"__esModule",{value:!0});Rt.getSchemaRefs=Rt.resolveUrl=Rt.normalizeId=Rt._getFullPath=Rt.getFullPath=Rt.inlineRef=void 0;var Nre=me(),Tre=z$(),zre=YF(),Cre=new Set(["type","format","pattern","maxLength","minLength","maxProperties","minProperties","maxItems","minItems","maximum","minimum","uniqueItems","multipleOf","required","enum","const"]);function Ire(e,t=!0){return typeof e=="boolean"?!0:t===!0?!C$(e):t?XF(e)<=t:!1}i(Ire,"inlineRef");Rt.inlineRef=Ire;var Pre=new Set(["$ref","$recursiveRef","$recursiveAnchor","$dynamicRef","$dynamicAnchor"]);function C$(e){for(let t in e){if(Pre.has(t))return!0;let r=e[t];if(Array.isArray(r)&&r.some(C$)||typeof r=="object"&&C$(r))return!0}return!1}i(C$,"hasRef");function XF(e){let t=0;for(let r in e){if(r==="$ref")return 1/0;if(t++,!Cre.has(r)&&(typeof e[r]=="object"&&(0,Nre.eachItem)(e[r],n=>t+=XF(n)),t===1/0))return 1/0}return t}i(XF,"countKeys");function QF(e,t="",r){r!==!1&&(t=lc(t));let n=e.parse(t);return e4(e,n)}i(QF,"getFullPath");Rt.getFullPath=QF;function e4(e,t){return e.serialize(t).split("#")[0]+"#"}i(e4,"_getFullPath");Rt._getFullPath=e4;var Ore=/#\/?$/;function lc(e){return e?e.replace(Ore,""):""}i(lc,"normalizeId");Rt.normalizeId=lc;function Are(e,t,r){return r=lc(r),e.resolve(t,r)}i(Are,"resolveUrl");Rt.resolveUrl=Are;var Rre=/^[a-z_][-a-z0-9._]*$/i;function jre(e,t){if(typeof e=="boolean")return{};let{schemaId:r,uriResolver:n}=this.opts,o=lc(e[r]||t),s={"":o},a=QF(n,o,!1),c={},l=new Set;return zre(e,{allKeys:!0},(p,m,h,g)=>{if(g===void 0)return;let _=a+m,x=s[g];typeof p[r]=="string"&&(x=v.call(this,p[r])),b.call(this,p.$anchor),b.call(this,p.$dynamicAnchor),s[m]=x;function v(w){let S=this.opts.uriResolver.resolve;if(w=lc(x?S(x,w):w),l.has(w))throw d(w);l.add(w);let E=this.refs[w];return typeof E=="string"&&(E=this.refs[E]),typeof E=="object"?u(p,E.schema,w):w!==lc(_)&&(w[0]==="#"?(u(p,c[w],w),c[w]=p):this.refs[w]=_),w}i(v,"addRef");function b(w){if(typeof w=="string"){if(!Rre.test(w))throw new Error(`invalid anchor "${w}"`);v.call(this,`#${w}`)}}i(b,"addAnchor")}),c;function u(p,m,h){if(m!==void 0&&!Tre(p,m))throw d(h)}i(u,"checkAmbiguosRef");function d(p){return new Error(`reference "${p}" resolves to more than one schema`)}i(d,"ambiguos")}i(jre,"getSchemaRefs");Rt.getSchemaRefs=jre});var bd=F(Po=>{"use strict";Object.defineProperty(Po,"__esModule",{value:!0});Po.getData=Po.KeywordCxt=Po.validateFunctionCode=void 0;var s4=AF(),t4=xd(),P$=b$(),Og=xd(),Dre=FF(),wd=VF(),I$=WF(),W=se(),ee=Vn(),Mre=_d(),Gn=me(),vd=yd();function Zre(e){if(c4(e)&&(l4(e),a4(e))){Ure(e);return}i4(e,()=>(0,s4.topBoolOrEmptySchema)(e))}i(Zre,"validateFunctionCode");Po.validateFunctionCode=Zre;function i4({gen:e,validateName:t,schema:r,schemaEnv:n,opts:o},s){o.code.es5?e.func(t,(0,W._)`${ee.default.data}, ${ee.default.valCxt}`,n.$async,()=>{e.code((0,W._)`"use strict"; ${r4(r,o)}`),Fre(e,o),e.code(s)}):e.func(t,(0,W._)`${ee.default.data}, ${Lre(o)}`,n.$async,()=>e.code(r4(r,o)).code(s))}i(i4,"validateFunction");function Lre(e){return(0,W._)`{${ee.default.instancePath}="", ${ee.default.parentData}, ${ee.default.parentDataProperty}, ${ee.default.rootData}=${ee.default.data}${e.dynamicRef?(0,W._)`, ${ee.default.dynamicAnchors}={}`:W.nil}}={}`}i(Lre,"destructureValCxt");function Fre(e,t){e.if(ee.default.valCxt,()=>{e.var(ee.default.instancePath,(0,W._)`${ee.default.valCxt}.${ee.default.instancePath}`),e.var(ee.default.parentData,(0,W._)`${ee.default.valCxt}.${ee.default.parentData}`),e.var(ee.default.parentDataProperty,(0,W._)`${ee.default.valCxt}.${ee.default.parentDataProperty}`),e.var(ee.default.rootData,(0,W._)`${ee.default.valCxt}.${ee.default.rootData}`),t.dynamicRef&&e.var(ee.default.dynamicAnchors,(0,W._)`${ee.default.valCxt}.${ee.default.dynamicAnchors}`)},()=>{e.var(ee.default.instancePath,(0,W._)`""`),e.var(ee.default.parentData,(0,W._)`undefined`),e.var(ee.default.parentDataProperty,(0,W._)`undefined`),e.var(ee.default.rootData,ee.default.data),t.dynamicRef&&e.var(ee.default.dynamicAnchors,(0,W._)`{}`)})}i(Fre,"destructureValCxtES5");function Ure(e){let{schema:t,opts:r,gen:n}=e;i4(e,()=>{r.$comment&&t.$comment&&d4(e),Gre(e),n.let(ee.default.vErrors,null),n.let(ee.default.errors,0),r.unevaluated&&qre(e),u4(e),Kre(e)})}i(Ure,"topSchemaObjCode");function qre(e){let{gen:t,validateName:r}=e;e.evaluated=t.const("evaluated",(0,W._)`${r}.evaluated`),t.if((0,W._)`${e.evaluated}.dynamicProps`,()=>t.assign((0,W._)`${e.evaluated}.props`,(0,W._)`undefined`)),t.if((0,W._)`${e.evaluated}.dynamicItems`,()=>t.assign((0,W._)`${e.evaluated}.items`,(0,W._)`undefined`))}i(qre,"resetEvaluated");function r4(e,t){let r=typeof e=="object"&&e[t.schemaId];return r&&(t.code.source||t.code.process)?(0,W._)`/*# sourceURL=${r} */`:W.nil}i(r4,"funcSourceUrl");function Bre(e,t){if(c4(e)&&(l4(e),a4(e))){Hre(e,t);return}(0,s4.boolOrEmptySchema)(e,t)}i(Bre,"subschemaCode");function a4({schema:e,self:t}){if(typeof e=="boolean")return!e;for(let r in e)if(t.RULES.all[r])return!0;return!1}i(a4,"schemaCxtHasRules");function c4(e){return typeof e.schema!="boolean"}i(c4,"isSchemaObj");function Hre(e,t){let{schema:r,gen:n,opts:o}=e;o.$comment&&r.$comment&&d4(e),Wre(e),Jre(e);let s=n.const("_errs",ee.default.errors);u4(e,s),n.var(t,(0,W._)`${s} === ${ee.default.errors}`)}i(Hre,"subSchemaObjCode");function l4(e){(0,Gn.checkUnknownRules)(e),Vre(e)}i(l4,"checkKeywords");function u4(e,t){if(e.opts.jtd)return n4(e,[],!1,t);let r=(0,t4.getSchemaTypes)(e.schema),n=(0,t4.coerceAndCheckDataType)(e,r);n4(e,r,!n,t)}i(u4,"typeAndKeywords");function Vre(e){let{schema:t,errSchemaPath:r,opts:n,self:o}=e;t.$ref&&n.ignoreKeywordsWithRef&&(0,Gn.schemaHasRulesButRef)(t,o.RULES)&&o.logger.warn(`$ref: keywords ignored in schema at path "${r}"`)}i(Vre,"checkRefsAndKeywords");function Gre(e){let{schema:t,opts:r}=e;t.default!==void 0&&r.useDefaults&&r.strictSchema&&(0,Gn.checkStrictMode)(e,"default is ignored in the schema root")}i(Gre,"checkNoDefault");function Wre(e){let t=e.schema[e.opts.schemaId];t&&(e.baseId=(0,Mre.resolveUrl)(e.opts.uriResolver,e.baseId,t))}i(Wre,"updateContext");function Jre(e){if(e.schema.$async&&!e.schemaEnv.$async)throw new Error("async schema in sync schema")}i(Jre,"checkAsyncSchema");function d4({gen:e,schemaEnv:t,schema:r,errSchemaPath:n,opts:o}){let s=r.$comment;if(o.$comment===!0)e.code((0,W._)`${ee.default.self}.logger.log(${s})`);else if(typeof o.$comment=="function"){let a=(0,W.str)`${n}/$comment`,c=e.scopeValue("root",{ref:t.root});e.code((0,W._)`${ee.default.self}.opts.$comment(${s}, ${a}, ${c}.schema)`)}}i(d4,"commentKeyword");function Kre(e){let{gen:t,schemaEnv:r,validateName:n,ValidationError:o,opts:s}=e;r.$async?t.if((0,W._)`${ee.default.errors} === 0`,()=>t.return(ee.default.data),()=>t.throw((0,W._)`new ${o}(${ee.default.vErrors})`)):(t.assign((0,W._)`${n}.errors`,ee.default.vErrors),s.unevaluated&&Yre(e),t.return((0,W._)`${ee.default.errors} === 0`))}i(Kre,"returnResults");function Yre({gen:e,evaluated:t,props:r,items:n}){r instanceof W.Name&&e.assign((0,W._)`${t}.props`,r),n instanceof W.Name&&e.assign((0,W._)`${t}.items`,n)}i(Yre,"assignEvaluated");function n4(e,t,r,n){let{gen:o,schema:s,data:a,allErrors:c,opts:l,self:u}=e,{RULES:d}=u;if(s.$ref&&(l.ignoreKeywordsWithRef||!(0,Gn.schemaHasRulesButRef)(s,d))){o.block(()=>f4(e,"$ref",d.all.$ref.definition));return}l.jtd||Xre(e,t),o.block(()=>{for(let m of d.rules)p(m);p(d.post)});function p(m){(0,P$.shouldUseGroup)(s,m)&&(m.type?(o.if((0,Og.checkDataType)(m.type,a,l.strictNumbers)),o4(e,m),t.length===1&&t[0]===m.type&&r&&(o.else(),(0,Og.reportTypeError)(e)),o.endIf()):o4(e,m),c||o.if((0,W._)`${ee.default.errors} === ${n||0}`))}i(p,"groupKeywords")}i(n4,"schemaKeywords");function o4(e,t){let{gen:r,schema:n,opts:{useDefaults:o}}=e;o&&(0,Dre.assignDefaults)(e,t.type),r.block(()=>{for(let s of t.rules)(0,P$.shouldUseRule)(n,s)&&f4(e,s.keyword,s.definition,t.type)})}i(o4,"iterateKeywords");function Xre(e,t){e.schemaEnv.meta||!e.opts.strictTypes||(Qre(e,t),e.opts.allowUnionTypes||ene(e,t),tne(e,e.dataTypes))}i(Xre,"checkStrictTypes");function Qre(e,t){if(t.length){if(!e.dataTypes.length){e.dataTypes=t;return}t.forEach(r=>{p4(e.dataTypes,r)||O$(e,`type "${r}" not allowed by context "${e.dataTypes.join(",")}"`)}),nne(e,t)}}i(Qre,"checkContextTypes");function ene(e,t){t.length>1&&!(t.length===2&&t.includes("null"))&&O$(e,"use allowUnionTypes to allow union type keyword")}i(ene,"checkMultipleTypes");function tne(e,t){let r=e.self.RULES.all;for(let n in r){let o=r[n];if(typeof o=="object"&&(0,P$.shouldUseRule)(e.schema,o)){let{type:s}=o.definition;s.length&&!s.some(a=>rne(t,a))&&O$(e,`missing type "${s.join(",")}" for keyword "${n}"`)}}}i(tne,"checkKeywordTypes");function rne(e,t){return e.includes(t)||t==="number"&&e.includes("integer")}i(rne,"hasApplicableType");function p4(e,t){return e.includes(t)||t==="integer"&&e.includes("number")}i(p4,"includesType");function nne(e,t){let r=[];for(let n of e.dataTypes)p4(t,n)?r.push(n):t.includes("integer")&&n==="number"&&r.push("integer");e.dataTypes=r}i(nne,"narrowSchemaTypes");function O$(e,t){let r=e.schemaEnv.baseId+e.errSchemaPath;t+=` at "${r}" (strictTypes)`,(0,Gn.checkStrictMode)(e,t,e.opts.strictTypes)}i(O$,"strictTypesError");var A$=class A${constructor(t,r,n){if((0,wd.validateKeywordUsage)(t,r,n),this.gen=t.gen,this.allErrors=t.allErrors,this.keyword=n,this.data=t.data,this.schema=t.schema[n],this.$data=r.$data&&t.opts.$data&&this.schema&&this.schema.$data,this.schemaValue=(0,Gn.schemaRefOrVal)(t,this.schema,n,this.$data),this.schemaType=r.schemaType,this.parentSchema=t.schema,this.params={},this.it=t,this.def=r,this.$data)this.schemaCode=t.gen.const("vSchema",m4(this.$data,t));else if(this.schemaCode=this.schemaValue,!(0,wd.validSchemaType)(this.schema,r.schemaType,r.allowUndefined))throw new Error(`${n} value must be ${JSON.stringify(r.schemaType)}`);("code"in r?r.trackErrors:r.errors!==!1)&&(this.errsCount=t.gen.const("_errs",ee.default.errors))}result(t,r,n){this.failResult((0,W.not)(t),r,n)}failResult(t,r,n){this.gen.if(t),n?n():this.error(),r?(this.gen.else(),r(),this.allErrors&&this.gen.endIf()):this.allErrors?this.gen.endIf():this.gen.else()}pass(t,r){this.failResult((0,W.not)(t),void 0,r)}fail(t){if(t===void 0){this.error(),this.allErrors||this.gen.if(!1);return}this.gen.if(t),this.error(),this.allErrors?this.gen.endIf():this.gen.else()}fail$data(t){if(!this.$data)return this.fail(t);let{schemaCode:r}=this;this.fail((0,W._)`${r} !== undefined && (${(0,W.or)(this.invalid$data(),t)})`)}error(t,r,n){if(r){this.setParams(r),this._error(t,n),this.setParams({});return}this._error(t,n)}_error(t,r){(t?vd.reportExtraError:vd.reportError)(this,this.def.error,r)}$dataError(){(0,vd.reportError)(this,this.def.$dataError||vd.keyword$DataError)}reset(){if(this.errsCount===void 0)throw new Error('add "trackErrors" to keyword definition');(0,vd.resetErrorsCount)(this.gen,this.errsCount)}ok(t){this.allErrors||this.gen.if(t)}setParams(t,r){r?Object.assign(this.params,t):this.params=t}block$data(t,r,n=W.nil){this.gen.block(()=>{this.check$data(t,n),r()})}check$data(t=W.nil,r=W.nil){if(!this.$data)return;let{gen:n,schemaCode:o,schemaType:s,def:a}=this;n.if((0,W.or)((0,W._)`${o} === undefined`,r)),t!==W.nil&&n.assign(t,!0),(s.length||a.validateSchema)&&(n.elseIf(this.invalid$data()),this.$dataError(),t!==W.nil&&n.assign(t,!1)),n.else()}invalid$data(){let{gen:t,schemaCode:r,schemaType:n,def:o,it:s}=this;return(0,W.or)(a(),c());function a(){if(n.length){if(!(r instanceof W.Name))throw new Error("ajv implementation error");let l=Array.isArray(n)?n:[n];return(0,W._)`${(0,Og.checkDataTypes)(l,r,s.opts.strictNumbers,Og.DataType.Wrong)}`}return W.nil}function c(){if(o.validateSchema){let l=t.scopeValue("validate$data",{ref:o.validateSchema});return(0,W._)`!${l}(${r})`}return W.nil}}subschema(t,r){let n=(0,I$.getSubschema)(this.it,t);(0,I$.extendSubschemaData)(n,this.it,t),(0,I$.extendSubschemaMode)(n,t);let o={...this.it,...n,items:void 0,props:void 0};return Bre(o,r),o}mergeEvaluated(t,r){let{it:n,gen:o}=this;n.opts.unevaluated&&(n.props!==!0&&t.props!==void 0&&(n.props=Gn.mergeEvaluated.props(o,t.props,n.props,r)),n.items!==!0&&t.items!==void 0&&(n.items=Gn.mergeEvaluated.items(o,t.items,n.items,r)))}mergeValidEvaluated(t,r){let{it:n,gen:o}=this;if(n.opts.unevaluated&&(n.props!==!0||n.items!==!0))return o.if(r,()=>this.mergeEvaluated(t,W.Name)),!0}};i(A$,"KeywordCxt");var Ag=A$;Po.KeywordCxt=Ag;function f4(e,t,r,n){let o=new Ag(e,r,t);"code"in r?r.code(o,n):o.$data&&r.validate?(0,wd.funcKeywordCode)(o,r):"macro"in r?(0,wd.macroKeywordCode)(o,r):(r.compile||r.validate)&&(0,wd.funcKeywordCode)(o,r)}i(f4,"keywordCode");var one=/^\/(?:[^~]|~0|~1)*$/,sne=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function m4(e,{dataLevel:t,dataNames:r,dataPathArr:n}){let o,s;if(e==="")return ee.default.rootData;if(e[0]==="/"){if(!one.test(e))throw new Error(`Invalid JSON-pointer: ${e}`);o=e,s=ee.default.rootData}else{let u=sne.exec(e);if(!u)throw new Error(`Invalid JSON-pointer: ${e}`);let d=+u[1];if(o=u[2],o==="#"){if(d>=t)throw new Error(l("property/index",d));return n[t-d]}if(d>t)throw new Error(l("data",d));if(s=r[t-d],!o)return s}let a=s,c=o.split("/");for(let u of c)u&&(s=(0,W._)`${s}${(0,W.getProperty)((0,Gn.unescapeJsonPointer)(u))}`,a=(0,W._)`${a} && ${s}`);return a;function l(u,d){return`Cannot access ${u} ${d} levels up, current level is ${t}`}}i(m4,"getData");Po.getData=m4});var Rg=F(j$=>{"use strict";Object.defineProperty(j$,"__esModule",{value:!0});var D$=class D$ extends Error{constructor(t){super("validation failed"),this.errors=t,this.ajv=this.validation=!0}};i(D$,"ValidationError");var R$=D$;j$.default=R$});var Sd=F(L$=>{"use strict";Object.defineProperty(L$,"__esModule",{value:!0});var M$=_d(),F$=class F$ extends Error{constructor(t,r,n,o){super(o||`can't resolve reference ${n} from id ${r}`),this.missingRef=(0,M$.resolveUrl)(t,r,n),this.missingSchema=(0,M$.normalizeId)((0,M$.getFullPath)(t,this.missingRef))}};i(F$,"MissingRefError");var Z$=F$;L$.default=Z$});var Dg=F(hr=>{"use strict";Object.defineProperty(hr,"__esModule",{value:!0});hr.resolveSchema=hr.getCompilingSchema=hr.resolveRef=hr.compileSchema=hr.SchemaEnv=void 0;var Or=se(),ine=Rg(),ui=Vn(),Ar=_d(),h4=me(),ane=bd(),B$=class B${constructor(t){var r;this.refs={},this.dynamicAnchors={};let n;typeof t.schema=="object"&&(n=t.schema),this.schema=t.schema,this.schemaId=t.schemaId,this.root=t.root||this,this.baseId=(r=t.baseId)!==null&&r!==void 0?r:(0,Ar.normalizeId)(n?.[t.schemaId||"$id"]),this.schemaPath=t.schemaPath,this.localRefs=t.localRefs,this.meta=t.meta,this.$async=n?.$async,this.refs={}}};i(B$,"SchemaEnv");var uc=B$;hr.SchemaEnv=uc;function q$(e){let t=g4.call(this,e);if(t)return t;let r=(0,Ar.getFullPath)(this.opts.uriResolver,e.root.baseId),{es5:n,lines:o}=this.opts.code,{ownProperties:s}=this.opts,a=new Or.CodeGen(this.scope,{es5:n,lines:o,ownProperties:s}),c;e.$async&&(c=a.scopeValue("Error",{ref:ine.default,code:(0,Or._)`require("ajv/dist/runtime/validation_error").default`}));let l=a.scopeName("validate");e.validateName=l;let u={gen:a,allErrors:this.opts.allErrors,data:ui.default.data,parentData:ui.default.parentData,parentDataProperty:ui.default.parentDataProperty,dataNames:[ui.default.data],dataPathArr:[Or.nil],dataLevel:0,dataTypes:[],definedProperties:new Set,topSchemaRef:a.scopeValue("schema",this.opts.code.source===!0?{ref:e.schema,code:(0,Or.stringify)(e.schema)}:{ref:e.schema}),validateName:l,ValidationError:c,schema:e.schema,schemaEnv:e,rootId:r,baseId:e.baseId||r,schemaPath:Or.nil,errSchemaPath:e.schemaPath||(this.opts.jtd?"":"#"),errorPath:(0,Or._)`""`,opts:this.opts,self:this},d;try{this._compilations.add(e),(0,ane.validateFunctionCode)(u),a.optimize(this.opts.code.optimize);let p=a.toString();d=`${a.scopeRefs(ui.default.scope)}return ${p}`,this.opts.code.process&&(d=this.opts.code.process(d,e));let h=new Function(`${ui.default.self}`,`${ui.default.scope}`,d)(this,this.scope.get());if(this.scope.value(l,{ref:h}),h.errors=null,h.schema=e.schema,h.schemaEnv=e,e.$async&&(h.$async=!0),this.opts.code.source===!0&&(h.source={validateName:l,validateCode:p,scopeValues:a._values}),this.opts.unevaluated){let{props:g,items:_}=u;h.evaluated={props:g instanceof Or.Name?void 0:g,items:_ instanceof Or.Name?void 0:_,dynamicProps:g instanceof Or.Name,dynamicItems:_ instanceof Or.Name},h.source&&(h.source.evaluated=(0,Or.stringify)(h.evaluated))}return e.validate=h,e}catch(p){throw delete e.validate,delete e.validateName,d&&this.logger.error("Error compiling schema, function code:",d),p}finally{this._compilations.delete(e)}}i(q$,"compileSchema");hr.compileSchema=q$;function cne(e,t,r){var n;r=(0,Ar.resolveUrl)(this.opts.uriResolver,t,r);let o=e.refs[r];if(o)return o;let s=dne.call(this,e,r);if(s===void 0){let a=(n=e.localRefs)===null||n===void 0?void 0:n[r],{schemaId:c}=this.opts;a&&(s=new uc({schema:a,schemaId:c,root:e,baseId:t}))}if(s!==void 0)return e.refs[r]=lne.call(this,s)}i(cne,"resolveRef");hr.resolveRef=cne;function lne(e){return(0,Ar.inlineRef)(e.schema,this.opts.inlineRefs)?e.schema:e.validate?e:q$.call(this,e)}i(lne,"inlineOrCompile");function g4(e){for(let t of this._compilations)if(une(t,e))return t}i(g4,"getCompilingSchema");hr.getCompilingSchema=g4;function une(e,t){return e.schema===t.schema&&e.root===t.root&&e.baseId===t.baseId}i(une,"sameSchemaEnv");function dne(e,t){let r;for(;typeof(r=this.refs[t])=="string";)t=r;return r||this.schemas[t]||jg.call(this,e,t)}i(dne,"resolve");function jg(e,t){let r=this.opts.uriResolver.parse(t),n=(0,Ar._getFullPath)(this.opts.uriResolver,r),o=(0,Ar.getFullPath)(this.opts.uriResolver,e.baseId,void 0);if(Object.keys(e.schema).length>0&&n===o)return U$.call(this,r,e);let s=(0,Ar.normalizeId)(n),a=this.refs[s]||this.schemas[s];if(typeof a=="string"){let c=jg.call(this,e,a);return typeof c?.schema!="object"?void 0:U$.call(this,r,c)}if(typeof a?.schema=="object"){if(a.validate||q$.call(this,a),s===(0,Ar.normalizeId)(t)){let{schema:c}=a,{schemaId:l}=this.opts,u=c[l];return u&&(o=(0,Ar.resolveUrl)(this.opts.uriResolver,o,u)),new uc({schema:c,schemaId:l,root:e,baseId:o})}return U$.call(this,r,a)}}i(jg,"resolveSchema");hr.resolveSchema=jg;var pne=new Set(["properties","patternProperties","enum","dependencies","definitions"]);function U$(e,{baseId:t,schema:r,root:n}){var o;if(((o=e.fragment)===null||o===void 0?void 0:o[0])!=="/")return;for(let c of e.fragment.slice(1).split("/")){if(typeof r=="boolean")return;let l=r[(0,h4.unescapeFragment)(c)];if(l===void 0)return;r=l;let u=typeof r=="object"&&r[this.opts.schemaId];!pne.has(c)&&u&&(t=(0,Ar.resolveUrl)(this.opts.uriResolver,t,u))}let s;if(typeof r!="boolean"&&r.$ref&&!(0,h4.schemaHasRulesButRef)(r,this.RULES)){let c=(0,Ar.resolveUrl)(this.opts.uriResolver,t,r.$ref);s=jg.call(this,n,c)}let{schemaId:a}=this.opts;if(s=s||new uc({schema:r,schemaId:a,root:n,baseId:t}),s.schema!==s.root.schema)return s}i(U$,"getJsonPointer")});var y4=F((v3e,fne)=>{fne.exports={$id:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#",description:"Meta-schema for $data reference (JSON AnySchema extension proposal)",type:"object",required:["$data"],properties:{$data:{type:"string",anyOf:[{format:"relative-json-pointer"},{format:"json-pointer"}]}},additionalProperties:!1}});var K$=F((w3e,k4)=>{"use strict";var mne=RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu),V$=RegExp.prototype.test.bind(/^(?:(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)$/u),di=RegExp.prototype.test.bind(/^[\da-f]{2}$/iu),G$=RegExp.prototype.test.bind(/^[\da-z\-._~]$/iu),_4=RegExp.prototype.test.bind(/^[A-Za-z0-9\-._~!$&'()*+,;=:@/]$/u),W$=RegExp.prototype.test.bind(/^[A-Za-z0-9\-._~!$&'()*+,;=:@/?]$/u),hne=RegExp.prototype.test.bind(/^[A-Za-z0-9\-._~!$&'()*+,;=:]$/u),jt=new Array(256);{let e="0123456789ABCDEF";for(let t=0;t<256;t++)jt[t]="%"+e[t>>4]+e[t&15]}function mt(e){return e<2048?jt[192|e>>6]+jt[128|e&63]:e<65536?jt[224|e>>12]+jt[128|e>>6&63]+jt[128|e&63]:jt[240|e>>18]+jt[128|e>>12&63]+jt[128|e>>6&63]+jt[128|e&63]}i(mt,"percentEncodeNonAscii");function gne(e){let t="",r=0,n=0;for(n=0;n<e.length;n++)if(r=e[n].charCodeAt(0),r!==48){if(!(r>=48&&r<=57||r>=65&&r<=70||r>=97&&r<=102))return"";t+=e[n];break}for(n+=1;n<e.length;n++){if(r=e[n].charCodeAt(0),!(r>=48&&r<=57||r>=65&&r<=70||r>=97&&r<=102))return"";t+=e[n]}return t}i(gne,"stringArrayToHexStripped");var yne=RegExp.prototype.test.bind(/^[\dA-Fa-f]{1,4}$/),xne=RegExp.prototype.test.bind(/^[vV][\dA-Fa-f]+\.[A-Za-z\d\-._~!$&'()*+,;=:]+$/),_ne=RegExp.prototype.test.bind(/^[A-Za-z\d\-._~]$/),vne=RegExp.prototype.test.bind(/[^!"$&'()*+,\-.;=_`a-z{}~]/u);function wne(e){if(e.length===0)return!1;for(let t=0;t<e.length;t++)if(!_ne(e[t])){if(e[t]==="%"&&t+2<e.length&&di(e.slice(t+1,t+3))){t+=2;continue}return!1}return!0}i(wne,"isZoneIdentifier");function x4(e){let t=-1,r=0,n=-1,o=0;for(let c=0;c<e.length;c++)e[c]==="0"?(n===-1&&(n=c),o++,o>r&&(r=o,t=n)):(n=-1,o=0);if(r<2)return e.join(":");let s=e.slice(0,t).join(":"),a=e.slice(t+r).join(":");return s+"::"+a}i(x4,"compressIPv6ZeroRun");function bne(e){let t=e.indexOf("::");if(t!==-1&&e.indexOf("::",t+1)!==-1)return;let r=t===-1?e.split(":"):e.slice(0,t).split(":"),n=t===-1?[]:e.slice(t+2).split(":");t!==-1&&(r.length===1&&r[0]===""&&(r.length=0),n.length===1&&n[0]===""&&(n.length=0));let o=r.concat(n),s=0;for(let c=0;c<o.length;c++){let l=o[c];if(l==="")return;if(l.indexOf(".")!==-1){if(c!==o.length-1||t!==-1&&n.length===0||!V$(l))return;s+=2;continue}if(!yne(l))return;o[c]=parseInt(l,16).toString(16),s++}if(t===-1)return s!==8?void 0:x4(o);if(s>=8)return;let a=o.slice(0,r.length);for(let c=s;c<8;c++)a.push("0");for(let c=r.length;c<o.length;c++)a.push(o[c]);return x4(a)}i(bne,"normalizeIPv6Address");function H$(e){let t=e[0]==="["&&e[e.length-1]==="]";if((e[0]==="["||e[e.length-1]==="]")&&!t)return{host:e,isIPV6:!1,error:!0};let n=t?e.slice(1,-1):e;if(t&&xne(n))return n=n.toLowerCase(),{host:`[${n}]`,escapedHost:n,isIPV6:!1,isIPVFuture:!0};if(Sne(n,":")<2)return{host:e,isIPV6:!1,error:t};let o="",s=n.indexOf("%");if(s!==-1){let c=n.slice(s,s+3).toLowerCase()==="%25"?3:1;if(o=n.slice(s+c),!wne(o))return{host:e,isIPV6:!1,error:!0};n=n.slice(0,s)}let a=bne(n);return a===void 0?{host:e,isIPV6:!1,error:!0}:{host:a+(o?"%"+o:""),escapedHost:a+(o?"%25"+o:""),isIPV6:!0}}i(H$,"normalizeIPv6");function Sne(e,t){let r=0;for(let n=0;n<e.length;n++)e[n]===t&&r++;return r}i(Sne,"findToken");function kne(e){let t=e,r=[],n=-1,o=0;for(;o=t.length;){if(o===1){if(t===".")break;if(t==="/"){r.push("/");break}else{r.push(t);break}}else if(o===2){if(t[0]==="."){if(t[1]===".")break;if(t[1]==="/"){t=t.slice(2);continue}}else if(t[0]==="/"&&(t[1]==="."||t[1]==="/")){r.push("/");break}}else if(o===3&&t==="/.."){r.length!==0&&r.pop(),r.push("/");break}if(t[0]==="."){if(t[1]==="."){if(t[2]==="/"){t=t.slice(3);continue}}else if(t[1]==="/"){t=t.slice(2);continue}}else if(t[0]==="/"&&t[1]==="."){if(t[2]==="/"){t=t.slice(2);continue}else if(t[2]==="."&&t[3]==="/"){t=t.slice(3),r.length!==0&&r.pop();continue}}if((n=t.indexOf("/",1))===-1){r.push(t);break}else r.push(t.slice(0,n)),t=t.slice(n)}return r.join("")}i(kne,"removeDotSegments");var $ne={"@":"%40","/":"%2F","?":"%3F","#":"%23",":":"%3A"},Ene=/[@/?#:]/g,Nne=/[@/?#]/g;function v4(e,t){let r=t?Nne:Ene;return r.lastIndex=0,e.replace(r,n=>$ne[n])}i(v4,"reescapeHostDelimiters");function w4(e,t=!1){if(e.indexOf("%")===-1)return e;let r="";for(let n=0;n<e.length;n++){if(e[n]==="%"&&n+2<e.length){let o=e.slice(n+1,n+3);if(di(o)){let s=o.toUpperCase(),a=String.fromCharCode(parseInt(s,16));t&&G$(a)?r+=a:r+="%"+s,n+=2;continue}}r+=e[n]}return r}i(w4,"normalizePercentEncoding");function Tne(e){let t="";for(let r=0;r<e.length;r++){let n=e[r];if(n==="%"&&r+2<e.length){let o=e.slice(r+1,r+3);if(di(o)){let s=o.toUpperCase(),a=String.fromCharCode(parseInt(s,16));a!=="."&&G$(a)?t+=a:t+="%"+s,r+=2;continue}}if(_4(n))t+=n;else{let o=e.charCodeAt(r);if(o<128)t+=S4(o)?n:jt[o];else if(o<55296||o>57343)t+=mt(o);else if(o<=56319&&r+1<e.length){let s=e.charCodeAt(r+1);s>=56320&&s<=57343?(t+=mt(65536+(o-55296<<10)+(s-56320)),r++):t+=mt(65533)}else t+=mt(65533)}}return t}i(Tne,"normalizePathEncoding");function zne(e,t=!1){let r="",n=t&&e[0]!=="/";for(let o=0;o<e.length;o++){let s=e[o];if(s==="%"&&o+2<e.length){let a=e.slice(o+1,o+3);if(di(a)){r+="%"+a.toUpperCase(),o+=2;continue}}if(s==="/"&&(n=!1),_4(s)&&(s!==":"||!n))r+=s;else{let a=e.charCodeAt(o);if(a<128)r+=jt[a];else if(a<55296||a>57343)r+=mt(a);else if(a<=56319&&o+1<e.length){let c=e.charCodeAt(o+1);c>=56320&&c<=57343?(r+=mt(65536+(a-55296<<10)+(c-56320)),o++):r+=mt(65533)}else r+=mt(65533)}}return r}i(zne,"serializePathEncoding");function J$(e,t){let r="";for(let n=0;n<e.length;n++){let o=e[n];if(o==="%"&&n+2<e.length){let s=e.slice(n+1,n+3);if(di(s)){r+="%"+s.toUpperCase(),n+=2;continue}}if(t(o))r+=o;else{let s=e.charCodeAt(n);if(s<128)r+=jt[s];else if(s<55296||s>57343)r+=mt(s);else if(s<=56319&&n+1<e.length){let a=e.charCodeAt(n+1);a>=56320&&a<=57343?(r+=mt(65536+(s-55296<<10)+(a-56320)),n++):r+=mt(65533)}else r+=mt(65533)}}return r}i(J$,"encodeComponent");function b4(e){return J$(e,hne)}i(b4,"encodeUserinfo");function Cne(e){return J$(e,W$)}i(Cne,"encodeQuery");function Ine(e){return J$(e,W$)}i(Ine,"encodeFragment");function S4(e){return e>=48&&e<=57||e>=65&&e<=90||e>=97&&e<=122||e===42||e===43||e===45||e===46||e===47||e===64||e===95}i(S4,"isEscapeSafe");function Pne(e){let t="";for(let r=0;r<e.length;r++){let n=e[r];if(n==="%"&&r+2<e.length){let o=e.slice(r+1,r+3);if(di(o)){let s=o.toUpperCase(),a=String.fromCharCode(parseInt(s,16));G$(a)?t+=a:t+="%"+s,r+=2;continue}}if(W$(n))t+=n;else{let o=e.charCodeAt(r);if(o<128)t+=S4(o)?n:jt[o];else if(o<55296||o>57343)t+=mt(o);else if(o<=56319&&r+1<e.length){let s=e.charCodeAt(r+1);s>=56320&&s<=57343?(t+=mt(65536+(o-55296<<10)+(s-56320)),r++):t+=mt(65533)}else t+=mt(65533)}}return t}i(Pne,"normalizeQueryFragmentEncoding");function One(e){let t="";for(let r=0;r<e.length;r++){if(e[r]==="%"&&r+2<e.length){let n=e.slice(r+1,r+3);if(di(n)){t+="%"+n.toUpperCase(),r+=2;continue}}t+=escape(e[r])}return t}i(One,"escapePreservingEscapes");function Ane(e){let t=[];if(e.userinfo!==void 0&&(t.push(b4(e.userinfo)),t.push("@")),e.host!==void 0){let r=e.host;if(!V$(r)){let n=H$(r);n.isIPV6!==!0&&n.isIPVFuture!==!0&&(r=w4(r,!0),n=H$(r)),n.isIPV6===!0||n.isIPVFuture===!0?r=`[${n.escapedHost}]`:r=v4(r,!1)}t.push(r)}return(typeof e.port=="number"||typeof e.port=="string")&&(t.push(":"),t.push(String(e.port))),t.length?t.join(""):void 0}i(Ane,"recomposeAuthority");k4.exports={nonSimpleDomain:vne,recomposeAuthority:Ane,reescapeHostDelimiters:v4,normalizePercentEncoding:w4,normalizePathEncoding:Tne,serializePathEncoding:zne,normalizeQueryFragmentEncoding:Pne,encodeUserinfo:b4,encodeQuery:Cne,encodeFragment:Ine,escapePreservingEscapes:One,removeDotSegments:kne,isIPv4:V$,isUUID:mne,normalizeIPv6:H$,stringArrayToHexStripped:gne}});var z4=F((S3e,T4)=>{"use strict";var{isUUID:Rne}=K$(),jne=/^([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-./:;=@]|%[\da-f]{2})+)$/iu,Dne=["http","https","ws","wss","urn","urn:uuid"];function Mne(e){return Dne.indexOf(e)!==-1}i(Mne,"isValidSchemeName");function Y$(e){return e.secure===!0?!0:e.secure===!1?!1:e.scheme?e.scheme.length===3&&(e.scheme[0]==="w"||e.scheme[0]==="W")&&(e.scheme[1]==="s"||e.scheme[1]==="S")&&(e.scheme[2]==="s"||e.scheme[2]==="S"):!1}i(Y$,"wsIsSecure");function $4(e){return e.host||(e.error=e.error||"HTTP URIs must have a host."),e}i($4,"httpParse");function E4(e){let t=String(e.scheme).toLowerCase()==="https";return(e.port===(t?443:80)||e.port==="")&&(e.port=void 0),e.path||(e.path="/"),e}i(E4,"httpSerialize");function Zne(e){return e.secure=Y$(e),e.resourceName=(e.path||"/")+(e.query?"?"+e.query:""),e.path=void 0,e.query=void 0,e}i(Zne,"wsParse");function Lne(e){if((e.port===(Y$(e)?443:80)||e.port==="")&&(e.port=void 0),typeof e.secure=="boolean"&&(e.scheme=e.secure?"wss":"ws",e.secure=void 0),e.resourceName){let t=e.resourceName.indexOf("?"),r=t===-1?e.resourceName:e.resourceName.slice(0,t);e.path=r&&r!=="/"?r:void 0,e.query=t===-1?void 0:e.resourceName.slice(t+1),e.resourceName=void 0}return e.fragment=void 0,e}i(Lne,"wsSerialize");function Fne(e,t){if(!e.path)return e.error="URN can not be parsed",e;let r=e.path.match(jne);if(r&&r[0]===e.path){let n=t.scheme||e.scheme||"urn";e.nid=r[1].toLowerCase(),e.nss=r[2];let o=`${n}:${t.nid||e.nid}`,s=X$(o);e.path=void 0,s&&(e=s.parse(e,t))}else e.error=e.error||"URN can not be parsed.";return e}i(Fne,"urnParse");function Une(e,t){if(e.nid===void 0)throw new Error("URN without nid cannot be serialized");let r=t.scheme||e.scheme||"urn",n=e.nid.toLowerCase(),o=`${r}:${t.nid||n}`,s=X$(o);s&&(e=s.serialize(e,t));let a=e,c=e.nss;return a.path=`${n||t.nid}:${c}`,t.skipEscape=!0,a}i(Une,"urnSerialize");function qne(e,t){let r=e;return r.uuid=r.nss,r.nss=void 0,!t.tolerant&&(!r.uuid||!Rne(r.uuid))&&(r.error=r.error||"UUID is not valid."),r}i(qne,"urnuuidParse");function Bne(e){let t=e;return t.nss=(e.uuid||"").toLowerCase(),t}i(Bne,"urnuuidSerialize");var N4={scheme:"http",domainHost:!0,parse:$4,serialize:E4},Hne={scheme:"https",domainHost:N4.domainHost,parse:$4,serialize:E4},Mg={scheme:"ws",domainHost:!0,parse:Zne,serialize:Lne},Vne={scheme:"wss",domainHost:Mg.domainHost,parse:Mg.parse,serialize:Mg.serialize},Gne={scheme:"urn",parse:Fne,serialize:Une,skipNormalize:!0},Wne={scheme:"urn:uuid",parse:qne,serialize:Bne,skipNormalize:!0},Zg={http:N4,https:Hne,ws:Mg,wss:Vne,urn:Gne,"urn:uuid":Wne};Object.setPrototypeOf(Zg,null);function X$(e){return e&&(Zg[e]||Zg[e.toLowerCase()])||void 0}i(X$,"getSchemeHandler");T4.exports={wsIsSecure:Y$,SCHEMES:Zg,isValidSchemeName:Mne,getSchemeHandler:X$}});var q4=F(($3e,Ug)=>{"use strict";var{normalizeIPv6:A4,removeDotSegments:$d,recomposeAuthority:Jne,normalizePercentEncoding:R4,normalizePathEncoding:Kne,serializePathEncoding:C4,normalizeQueryFragmentEncoding:I4,encodeQuery:Yne,encodeFragment:Xne,reescapeHostDelimiters:Qne,isIPv4:j4,nonSimpleDomain:eoe}=K$(),{SCHEMES:D4,getSchemeHandler:Q$}=z4(),M4=/^[A-Za-z][A-Za-z0-9+.-]*$/u,Z4="URI scheme is malformed.";function P4(e){let t=unescape(String(e));if(!M4.test(t))throw new TypeError(Z4);return t}i(P4,"decodeValidScheme");function toe(e,t){return typeof e=="string"?e=loe(e,t):typeof e=="object"&&(e=Fg(pi(e,t),t)),e}i(toe,"normalize");function roe(e,t,r){let n=r?Object.assign({scheme:"null"},r):{scheme:"null"},{parsed:o,malformedAuthorityOrPort:s,malformedPercentEncoding:a,malformedSchemeSpecific:c,malformedHost:l,malformedScheme:u}=Lg(e,n),{parsed:d,malformedAuthorityOrPort:p,malformedPercentEncoding:m,malformedSchemeSpecific:h,malformedHost:g,malformedScheme:_}=Lg(t,n);if(s||p||a||m||c||h||l||g||u||_)throw new Error(o.error||d.error||"URI is malformed.");let x=L4(o,d,n,!0),v=Q$(r&&r.scheme||x.scheme),b=x.host,w=b!==void 0&&b!==""&&(j4(b)||A4(b).isIPV6);F4(x,r||{},v,w);let S=b&&b.indexOf("%")!==-1&&!/\P{ASCII}/u.test(b);if(x.error&&!S)throw new Error(x.error);return n.skipEscape=!0,pi(x,n)}i(roe,"resolve");function L4(e,t,r,n){let o={};return n||(e=Fg(pi(e,r),r),t=Fg(pi(t,r),r)),r=r||{},!r.tolerant&&t.scheme?(o.scheme=t.scheme,o.userinfo=t.userinfo,o.host=t.host,o.port=t.port,o.path=$d(t.path||""),o.query=t.query):(t.userinfo!==void 0||t.host!==void 0||t.port!==void 0?(o.userinfo=t.userinfo,o.host=t.host,o.port=t.port,o.path=$d(t.path||""),o.query=t.query):(t.path?(t.path[0]==="/"?o.path=$d(t.path):((e.userinfo!==void 0||e.host!==void 0||e.port!==void 0)&&!e.path?o.path="/"+t.path:e.path?o.path=e.path.slice(0,e.path.lastIndexOf("/")+1)+t.path:o.path=t.path,o.path=$d(o.path)),o.query=t.query):(o.path=e.path,t.query!==void 0?o.query=t.query:o.query=e.query),o.userinfo=e.userinfo,o.host=e.host,o.port=e.port),o.scheme=e.scheme),o.fragment=t.fragment,o}i(L4,"resolveComponent");function noe(e,t,r){let n=O4(e,r),o=O4(t,r);return n!==void 0&&o!==void 0&&n===o}i(noe,"equal");function pi(e,t){let r={host:e.host,scheme:e.scheme,userinfo:e.userinfo,port:e.port,path:e.path,query:e.query,nid:e.nid,nss:e.nss,uuid:e.uuid,fragment:e.fragment,reference:e.reference,resourceName:e.resourceName,secure:e.secure,error:""},n=Object.assign({},t),o=[];r.scheme&&(r.scheme=P4(r.scheme));let s=Q$(n.scheme||r.scheme);s&&s.serialize&&s.serialize(r,n);let a=r.userinfo!==void 0||r.host!==void 0||r.port!==void 0,c=!n.skipEscape&&r.scheme===void 0&&!a;r.path!==void 0&&(n.skipEscape?r.path=R4(r.path):r.path=C4(r.path,c)),n.reference!=="suffix"&&r.scheme&&(r.scheme=P4(r.scheme),o.push(r.scheme,":"));let l=Jne(r);if(l!==void 0&&(n.reference!=="suffix"&&o.push("//"),o.push(l),r.path&&r.path[0]!=="/"&&o.push("/")),r.path!==void 0){let u=r.path;!n.absolutePath&&(!s||!s.absolutePath)&&(u=$d(u)),c&&(u=C4(u,!0)),l===void 0&&u[0]==="/"&&u[1]==="/"&&(u="/%2F"+u.slice(2)),o.push(u)}return r.query!==void 0&&o.push("?",Yne(r.query)),r.fragment!==void 0&&o.push("#",Xne(r.fragment)),o.join("")}i(pi,"serialize");var ooe=/^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u,soe=/^(?:[^#/:?]+:)?\/\/([^/?#]*)/,ioe=/^(?:[^#/:?]+:)?([/\\\t\n\r]*)/;function aoe(e,t){if(t[2]!==void 0&&e.path&&e.path[0]!=="/")return'URI path must start with "/" when authority is present.';if(typeof e.port=="number"&&(e.port<0||e.port>65535))return"URI port is malformed."}i(aoe,"getParseError");function kd(e){if(e===void 0)return!1;let t=e.indexOf("%");for(;t!==-1;){if(t+2>=e.length||!/^[\da-f]{2}$/iu.test(e.slice(t+1,t+3)))return!0;t=e.indexOf("%",t+3)}return!1}i(kd,"hasMalformedPercentEncoding");function coe(e){let t=e[4];return kd(e[3])||t!==void 0&&!(t[0]==="["&&t[t.length-1]==="]")&&kd(t)||kd(e[6])||kd(e[7])||kd(e[8])}i(coe,"hasMalformedComponentPercentEncoding");function F4(e,t,r,n){if(!t.unicodeSupport&&(!r||!r.unicodeSupport)&&e.host&&e.host[0]!=="["&&(t.domainHost||r&&r.domainHost)&&n===!1&&eoe(e.host))try{e.host=new URL("http://"+e.host).hostname}catch(o){return e.error=e.error||"Host's domain name can not be converted to ASCII: "+o,!0}return!1}i(F4,"canonicalizeHost");function Lg(e,t){let r=Object.assign({},t),n={scheme:void 0,userinfo:void 0,host:"",port:void 0,path:"",query:void 0,fragment:void 0},o=!1,s=!1,a=!1,c=!1,l=!1,u=!1,d=!1;r.reference==="suffix"&&(r.scheme?e=r.scheme+":"+e:e="//"+e);let p=e.match(soe);p!==null&&p[1].indexOf("\\")!==-1&&(n.error="URI authority must not contain a literal backslash.",o=!0);let m=e.match(ioe);if(m!==null){let g=m[1],_=g.replace(/[\t\n\r]/g,"");_.length>=2&&(_.slice(0,2)!=="//"?(n.error=n.error||"URI authority must not contain a literal backslash.",o=!0):g.length!==_.length&&(n.error=n.error||"URI authority introducer must not contain whitespace.",o=!0))}let h=e.match(ooe);if(h){if(n.scheme=h[1],n.userinfo=h[3],n.host=h[4],n.port=parseInt(h[5],10),n.path=h[6]||"",n.query=h[7],n.fragment=h[8],n.scheme!==void 0){let x=unescape(n.scheme);M4.test(x)?n.scheme=x.toLowerCase():(n.error=n.error||Z4,u=!0)}s=coe(h),s&&(n.error=n.error||"URI contains malformed percent-encoding."),isNaN(n.port)&&(n.port=h[5]);let g=aoe(n,h);if(g!==void 0&&(n.error=n.error||g,o=!0),n.host)if(j4(n.host)===!1){let v=n.host[0]==="["&&n.host[n.host.length-1]==="]",b=A4(n.host);d=b.isIPV6||b.isIPVFuture===!0,l=v&&b.error===!0,n.host=d?b.host:b.host.toLowerCase(),l&&(n.error=n.error||"URI host is malformed.",o=!0)}else d=!0;n.scheme===void 0&&n.userinfo===void 0&&n.host===void 0&&n.port===void 0&&n.query===void 0&&!n.path?n.reference="same-document":n.scheme===void 0?n.reference="relative":n.fragment===void 0?n.reference="absolute":n.reference="uri",r.reference&&r.reference!=="suffix"&&r.reference!==n.reference&&(n.error=n.error||"URI is not a "+r.reference+" reference.");let _=Q$(r.scheme||n.scheme);if(c=F4(n,r,_,d),!_||_&&!_.skipNormalize){if(e.indexOf("%")!==-1&&n.host!==void 0&&!l){let x=d?n.host:R4(n.host,!0);n.host=Qne(x,d)}n.path&&(n.path=Kne(n.path)),n.query&&(n.query=I4(n.query)),n.fragment&&(n.fragment=I4(n.fragment))}_&&_.parse&&(_.parse(n,r),_===D4.urn&&n.nid===void 0&&(a=!0))}else n.error=n.error||"URI can not be parsed.";return{parsed:n,malformedAuthorityOrPort:o,malformedPercentEncoding:s,malformedSchemeSpecific:a,malformedHost:c,malformedScheme:u}}i(Lg,"parseWithStatus");function Fg(e,t){return Lg(e,t).parsed}i(Fg,"parse");function loe(e,t){return U4(e,t).normalized}i(loe,"normalizeString");function U4(e,t){let{parsed:r,malformedAuthorityOrPort:n,malformedPercentEncoding:o,malformedSchemeSpecific:s,malformedHost:a,malformedScheme:c}=Lg(e,t);return{normalized:n||o||s||a||c?e:pi(r,t),malformedAuthorityOrPort:n,malformedPercentEncoding:o,malformedSchemeSpecific:s,malformedHost:a,malformedScheme:c}}i(U4,"normalizeStringWithStatus");function O4(e,t){if(typeof e!="string"&&typeof e!="object")return;let r;try{r=typeof e=="string"?e:pi(e,t)}catch{return}let{normalized:n,malformedAuthorityOrPort:o,malformedPercentEncoding:s,malformedSchemeSpecific:a,malformedHost:c,malformedScheme:l}=U4(r,t);return o||s||a||c||l?void 0:n}i(O4,"normalizeComparableURI");var eE={SCHEMES:D4,normalize:toe,resolve:roe,resolveComponent:L4,equal:noe,serialize:pi,parse:Fg};Ug.exports=eE;Ug.exports.default=eE;Ug.exports.fastUri=eE});var H4=F(tE=>{"use strict";Object.defineProperty(tE,"__esModule",{value:!0});var B4=q4();B4.code='require("ajv/dist/runtime/uri").default';tE.default=B4});var Q4=F(at=>{"use strict";Object.defineProperty(at,"__esModule",{value:!0});at.CodeGen=at.Name=at.nil=at.stringify=at.str=at._=at.KeywordCxt=void 0;var uoe=bd();Object.defineProperty(at,"KeywordCxt",{enumerable:!0,get:function(){return uoe.KeywordCxt}});var dc=se();Object.defineProperty(at,"_",{enumerable:!0,get:function(){return dc._}});Object.defineProperty(at,"str",{enumerable:!0,get:function(){return dc.str}});Object.defineProperty(at,"stringify",{enumerable:!0,get:function(){return dc.stringify}});Object.defineProperty(at,"nil",{enumerable:!0,get:function(){return dc.nil}});Object.defineProperty(at,"Name",{enumerable:!0,get:function(){return dc.Name}});Object.defineProperty(at,"CodeGen",{enumerable:!0,get:function(){return dc.CodeGen}});var doe=Rg(),K4=Sd(),poe=w$(),Ed=Dg(),foe=se(),Nd=_d(),qg=xd(),nE=me(),V4=y4(),moe=H4(),Y4=i((e,t)=>new RegExp(e,t),"defaultRegExp");Y4.code="new RegExp";var hoe=["removeAdditional","useDefaults","coerceTypes"],goe=new Set(["validate","serialize","parse","wrapper","root","schema","keyword","pattern","formats","validate$data","func","obj","Error"]),yoe={errorDataPath:"",format:"`validateFormats: false` can be used instead.",nullable:'"nullable" keyword is supported by default.',jsonPointers:"Deprecated jsPropertySyntax can be used instead.",extendRefs:"Deprecated ignoreKeywordsWithRef can be used instead.",missingRefs:"Pass empty schema with $id that should be ignored to ajv.addSchema.",processCode:"Use option `code: {process: (code, schemaEnv: object) => string}`",sourceCode:"Use option `code: {source: true}`",strictDefaults:"It is default now, see option `strict`.",strictKeywords:"It is default now, see option `strict`.",uniqueItems:'"uniqueItems" keyword is always validated.',unknownFormats:"Disable strict mode or pass `true` to `ajv.addFormat` (or `formats` option).",cache:"Map is used as cache, schema object as key.",serialize:"Map is used as cache, schema object as key.",ajvErrors:"It is default now."},xoe={ignoreKeywordsWithRef:"",jsPropertySyntax:"",unicode:'"minLength"/"maxLength" account for unicode characters by default.'},G4=200;function _oe(e){var t,r,n,o,s,a,c,l,u,d,p,m,h,g,_,x,v,b,w,S,E,I,z,M,D;let Z=e.strict,H=(t=e.code)===null||t===void 0?void 0:t.optimize,ce=H===!0||H===void 0?1:H||0,J=(n=(r=e.code)===null||r===void 0?void 0:r.regExp)!==null&&n!==void 0?n:Y4,te=(o=e.uriResolver)!==null&&o!==void 0?o:moe.default;return{strictSchema:(a=(s=e.strictSchema)!==null&&s!==void 0?s:Z)!==null&&a!==void 0?a:!0,strictNumbers:(l=(c=e.strictNumbers)!==null&&c!==void 0?c:Z)!==null&&l!==void 0?l:!0,strictTypes:(d=(u=e.strictTypes)!==null&&u!==void 0?u:Z)!==null&&d!==void 0?d:"log",strictTuples:(m=(p=e.strictTuples)!==null&&p!==void 0?p:Z)!==null&&m!==void 0?m:"log",strictRequired:(g=(h=e.strictRequired)!==null&&h!==void 0?h:Z)!==null&&g!==void 0?g:!1,code:e.code?{...e.code,optimize:ce,regExp:J}:{optimize:ce,regExp:J},loopRequired:(_=e.loopRequired)!==null&&_!==void 0?_:G4,loopEnum:(x=e.loopEnum)!==null&&x!==void 0?x:G4,meta:(v=e.meta)!==null&&v!==void 0?v:!0,messages:(b=e.messages)!==null&&b!==void 0?b:!0,inlineRefs:(w=e.inlineRefs)!==null&&w!==void 0?w:!0,schemaId:(S=e.schemaId)!==null&&S!==void 0?S:"$id",addUsedSchema:(E=e.addUsedSchema)!==null&&E!==void 0?E:!0,validateSchema:(I=e.validateSchema)!==null&&I!==void 0?I:!0,validateFormats:(z=e.validateFormats)!==null&&z!==void 0?z:!0,unicodeRegExp:(M=e.unicodeRegExp)!==null&&M!==void 0?M:!0,int32range:(D=e.int32range)!==null&&D!==void 0?D:!0,uriResolver:te}}i(_oe,"requiredOptions");var oE=class oE{constructor(t={}){this.schemas={},this.refs={},this.formats=Object.create(null),this._compilations=new Set,this._loading={},this._cache=new Map,t=this.opts={...t,..._oe(t)};let{es5:r,lines:n}=this.opts.code;this.scope=new foe.ValueScope({scope:{},prefixes:goe,es5:r,lines:n}),this.logger=$oe(t.logger);let o=t.validateFormats;t.validateFormats=!1,this.RULES=(0,poe.getRules)(),W4.call(this,yoe,t,"NOT SUPPORTED"),W4.call(this,xoe,t,"DEPRECATED","warn"),this._metaOpts=Soe.call(this),t.formats&&woe.call(this),this._addVocabularies(),this._addDefaultMetaSchema(),t.keywords&&boe.call(this,t.keywords),typeof t.meta=="object"&&this.addMetaSchema(t.meta),voe.call(this),t.validateFormats=o}_addVocabularies(){this.addKeyword("$async")}_addDefaultMetaSchema(){let{$data:t,meta:r,schemaId:n}=this.opts,o=V4;n==="id"&&(o={...V4},o.id=o.$id,delete o.$id),r&&t&&this.addMetaSchema(o,o[n],!1)}defaultMeta(){let{meta:t,schemaId:r}=this.opts;return this.opts.defaultMeta=typeof t=="object"?t[r]||t:void 0}validate(t,r){let n;if(typeof t=="string"){if(n=this.getSchema(t),!n)throw new Error(`no schema with key or ref "${t}"`)}else n=this.compile(t);let o=n(r);return"$async"in n||(this.errors=n.errors),o}compile(t,r){let n=this._addSchema(t,r);return n.validate||this._compileSchemaEnv(n)}compileAsync(t,r){if(typeof this.opts.loadSchema!="function")throw new Error("options.loadSchema should be a function");let{loadSchema:n}=this.opts;return o.call(this,t,r);async function o(d,p){await s.call(this,d.$schema);let m=this._addSchema(d,p);return m.validate||a.call(this,m)}async function s(d){d&&!this.getSchema(d)&&await o.call(this,{$ref:d},!0)}async function a(d){try{return this._compileSchemaEnv(d)}catch(p){if(!(p instanceof K4.default))throw p;return c.call(this,p),await l.call(this,p.missingSchema),a.call(this,d)}}function c({missingSchema:d,missingRef:p}){if(this.refs[d])throw new Error(`AnySchema ${d} is loaded but ${p} cannot be resolved`)}async function l(d){let p=await u.call(this,d);this.refs[d]||await s.call(this,p.$schema),this.refs[d]||this.addSchema(p,d,r)}async function u(d){let p=this._loading[d];if(p)return p;try{return await(this._loading[d]=n(d))}finally{delete this._loading[d]}}}addSchema(t,r,n,o=this.opts.validateSchema){if(Array.isArray(t)){for(let a of t)this.addSchema(a,void 0,n,o);return this}let s;if(typeof t=="object"){let{schemaId:a}=this.opts;if(s=t[a],s!==void 0&&typeof s!="string")throw new Error(`schema ${a} must be string`)}return r=(0,Nd.normalizeId)(r||s),this._checkUnique(r),this.schemas[r]=this._addSchema(t,n,r,o,!0),this}addMetaSchema(t,r,n=this.opts.validateSchema){return this.addSchema(t,r,!0,n),this}validateSchema(t,r){if(typeof t=="boolean")return!0;let n;if(n=t.$schema,n!==void 0&&typeof n!="string")throw new Error("$schema must be a string");if(n=n||this.opts.defaultMeta||this.defaultMeta(),!n)return this.logger.warn("meta-schema not available"),this.errors=null,!0;let o=this.validate(n,t);if(!o&&r){let s="schema is invalid: "+this.errorsText();if(this.opts.validateSchema==="log")this.logger.error(s);else throw new Error(s)}return o}getSchema(t){let r;for(;typeof(r=J4.call(this,t))=="string";)t=r;if(r===void 0){let{schemaId:n}=this.opts,o=new Ed.SchemaEnv({schema:{},schemaId:n});if(r=Ed.resolveSchema.call(this,o,t),!r)return;this.refs[t]=r}return r.validate||this._compileSchemaEnv(r)}removeSchema(t){if(t instanceof RegExp)return this._removeAllSchemas(this.schemas,t),this._removeAllSchemas(this.refs,t),this;switch(typeof t){case"undefined":return this._removeAllSchemas(this.schemas),this._removeAllSchemas(this.refs),this._cache.clear(),this;case"string":{let r=J4.call(this,t);return typeof r=="object"&&this._cache.delete(r.schema),delete this.schemas[t],delete this.refs[t],this}case"object":{let r=t;this._cache.delete(r);let n=t[this.opts.schemaId];return n&&(n=(0,Nd.normalizeId)(n),delete this.schemas[n],delete this.refs[n]),this}default:throw new Error("ajv.removeSchema: invalid parameter")}}addVocabulary(t){for(let r of t)this.addKeyword(r);return this}addKeyword(t,r){let n;if(typeof t=="string")n=t,typeof r=="object"&&(this.logger.warn("these parameters are deprecated, see docs for addKeyword"),r.keyword=n);else if(typeof t=="object"&&r===void 0){if(r=t,n=r.keyword,Array.isArray(n)&&!n.length)throw new Error("addKeywords: keyword must be string or non-empty array")}else throw new Error("invalid addKeywords parameters");if(Noe.call(this,n,r),!r)return(0,nE.eachItem)(n,s=>rE.call(this,s)),this;zoe.call(this,r);let o={...r,type:(0,qg.getJSONTypes)(r.type),schemaType:(0,qg.getJSONTypes)(r.schemaType)};return(0,nE.eachItem)(n,o.type.length===0?s=>rE.call(this,s,o):s=>o.type.forEach(a=>rE.call(this,s,o,a))),this}getKeyword(t){let r=this.RULES.all[t];return typeof r=="object"?r.definition:!!r}removeKeyword(t){let{RULES:r}=this;delete r.keywords[t],delete r.all[t];for(let n of r.rules){let o=n.rules.findIndex(s=>s.keyword===t);o>=0&&n.rules.splice(o,1)}return this}addFormat(t,r){return typeof r=="string"&&(r=new RegExp(r)),this.formats[t]=r,this}errorsText(t=this.errors,{separator:r=", ",dataVar:n="data"}={}){return!t||t.length===0?"No errors":t.map(o=>`${n}${o.instancePath} ${o.message}`).reduce((o,s)=>o+r+s)}$dataMetaSchema(t,r){let n=this.RULES.all;t=JSON.parse(JSON.stringify(t));for(let o of r){let s=o.split("/").slice(1),a=t;for(let c of s)a=a[c];for(let c in n){let l=n[c];if(typeof l!="object")continue;let{$data:u}=l.definition,d=a[c];u&&d&&(a[c]=X4(d))}}return t}_removeAllSchemas(t,r){for(let n in t){let o=t[n];(!r||r.test(n))&&(typeof o=="string"?delete t[n]:o&&!o.meta&&(this._cache.delete(o.schema),delete t[n]))}}_addSchema(t,r,n,o=this.opts.validateSchema,s=this.opts.addUsedSchema){let a,{schemaId:c}=this.opts;if(typeof t=="object")a=t[c];else{if(this.opts.jtd)throw new Error("schema must be object");if(typeof t!="boolean")throw new Error("schema must be object or boolean")}let l=this._cache.get(t);if(l!==void 0)return l;n=(0,Nd.normalizeId)(a||n);let u=Nd.getSchemaRefs.call(this,t,n);return l=new Ed.SchemaEnv({schema:t,schemaId:c,meta:r,baseId:n,localRefs:u}),this._cache.set(l.schema,l),s&&!n.startsWith("#")&&(n&&this._checkUnique(n),this.refs[n]=l),o&&this.validateSchema(t,!0),l}_checkUnique(t){if(this.schemas[t]||this.refs[t])throw new Error(`schema with key or id "${t}" already exists`)}_compileSchemaEnv(t){if(t.meta?this._compileMetaSchema(t):Ed.compileSchema.call(this,t),!t.validate)throw new Error("ajv implementation error");return t.validate}_compileMetaSchema(t){let r=this.opts;this.opts=this._metaOpts;try{Ed.compileSchema.call(this,t)}finally{this.opts=r}}};i(oE,"Ajv");var Td=oE;Td.ValidationError=doe.default;Td.MissingRefError=K4.default;at.default=Td;function W4(e,t,r,n="error"){for(let o in e){let s=o;s in t&&this.logger[n](`${r}: option ${o}. ${e[s]}`)}}i(W4,"checkOptions");function J4(e){return e=(0,Nd.normalizeId)(e),this.schemas[e]||this.refs[e]}i(J4,"getSchEnv");function voe(){let e=this.opts.schemas;if(e)if(Array.isArray(e))this.addSchema(e);else for(let t in e)this.addSchema(e[t],t)}i(voe,"addInitialSchemas");function woe(){for(let e in this.opts.formats){let t=this.opts.formats[e];t&&this.addFormat(e,t)}}i(woe,"addInitialFormats");function boe(e){if(Array.isArray(e)){this.addVocabulary(e);return}this.logger.warn("keywords option as map is deprecated, pass array");for(let t in e){let r=e[t];r.keyword||(r.keyword=t),this.addKeyword(r)}}i(boe,"addInitialKeywords");function Soe(){let e={...this.opts};for(let t of hoe)delete e[t];return e}i(Soe,"getMetaSchemaOptions");var koe={log(){},warn(){},error(){}};function $oe(e){if(e===!1)return koe;if(e===void 0)return console;if(e.log&&e.warn&&e.error)return e;throw new Error("logger must implement log, warn and error methods")}i($oe,"getLogger");var Eoe=/^[a-z_$][a-z0-9_$:-]*$/i;function Noe(e,t){let{RULES:r}=this;if((0,nE.eachItem)(e,n=>{if(r.keywords[n])throw new Error(`Keyword ${n} is already defined`);if(!Eoe.test(n))throw new Error(`Keyword ${n} has invalid name`)}),!!t&&t.$data&&!("code"in t||"validate"in t))throw new Error('$data keyword must have "code" or "validate" function')}i(Noe,"checkKeyword");function rE(e,t,r){var n;let o=t?.post;if(r&&o)throw new Error('keyword with "post" flag cannot have "type"');let{RULES:s}=this,a=o?s.post:s.rules.find(({type:l})=>l===r);if(a||(a={type:r,rules:[]},s.rules.push(a)),s.keywords[e]=!0,!t)return;let c={keyword:e,definition:{...t,type:(0,qg.getJSONTypes)(t.type),schemaType:(0,qg.getJSONTypes)(t.schemaType)}};t.before?Toe.call(this,a,c,t.before):a.rules.push(c),s.all[e]=c,(n=t.implements)===null||n===void 0||n.forEach(l=>this.addKeyword(l))}i(rE,"addRule");function Toe(e,t,r){let n=e.rules.findIndex(o=>o.keyword===r);n>=0?e.rules.splice(n,0,t):(e.rules.push(t),this.logger.warn(`rule ${r} is not defined`))}i(Toe,"addBeforeRule");function zoe(e){let{metaSchema:t}=e;t!==void 0&&(e.$data&&this.opts.$data&&(t=X4(t)),e.validateSchema=this.compile(t,!0))}i(zoe,"keywordMetaschema");var Coe={$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"};function X4(e){return{anyOf:[e,Coe]}}i(X4,"schemaOrData")});var eU=F(sE=>{"use strict";Object.defineProperty(sE,"__esModule",{value:!0});var Ioe={keyword:"id",code(){throw new Error('NOT SUPPORTED: keyword "id", use "$id" for schema ID')}};sE.default=Ioe});var oU=F(fi=>{"use strict";Object.defineProperty(fi,"__esModule",{value:!0});fi.callRef=fi.getValidate=void 0;var Poe=Sd(),tU=mr(),Dt=se(),pc=Vn(),rU=Dg(),Bg=me(),Ooe={keyword:"$ref",schemaType:"string",code(e){let{gen:t,schema:r,it:n}=e,{baseId:o,schemaEnv:s,validateName:a,opts:c,self:l}=n,{root:u}=s;if((r==="#"||r==="#/")&&o===u.baseId)return p();let d=rU.resolveRef.call(l,u,o,r);if(d===void 0)throw new Poe.default(n.opts.uriResolver,o,r);if(d instanceof rU.SchemaEnv)return m(d);return h(d);function p(){if(s===u)return Hg(e,a,s,s.$async);let g=t.scopeValue("root",{ref:u});return Hg(e,(0,Dt._)`${g}.validate`,u,u.$async)}function m(g){let _=nU(e,g);Hg(e,_,g,g.$async)}function h(g){let _=t.scopeValue("schema",c.code.source===!0?{ref:g,code:(0,Dt.stringify)(g)}:{ref:g}),x=t.name("valid"),v=e.subschema({schema:g,dataTypes:[],schemaPath:Dt.nil,topSchemaRef:_,errSchemaPath:r},x);e.mergeEvaluated(v),e.ok(x)}}};function nU(e,t){let{gen:r}=e;return t.validate?r.scopeValue("validate",{ref:t.validate}):(0,Dt._)`${r.scopeValue("wrapper",{ref:t})}.validate`}i(nU,"getValidate");fi.getValidate=nU;function Hg(e,t,r,n){let{gen:o,it:s}=e,{allErrors:a,schemaEnv:c,opts:l}=s,u=l.passContext?pc.default.this:Dt.nil;n?d():p();function d(){if(!c.$async)throw new Error("async schema referenced by sync schema");let g=o.let("valid");o.try(()=>{o.code((0,Dt._)`await ${(0,tU.callValidateCode)(e,t,u)}`),h(t),a||o.assign(g,!0)},_=>{o.if((0,Dt._)`!(${_} instanceof ${s.ValidationError})`,()=>o.throw(_)),m(_),a||o.assign(g,!1)}),e.ok(g)}i(d,"callAsyncRef");function p(){e.result((0,tU.callValidateCode)(e,t,u),()=>h(t),()=>m(t))}i(p,"callSyncRef");function m(g){let _=(0,Dt._)`${g}.errors`;o.assign(pc.default.vErrors,(0,Dt._)`${pc.default.vErrors} === null ? ${_} : ${pc.default.vErrors}.concat(${_})`),o.assign(pc.default.errors,(0,Dt._)`${pc.default.vErrors}.length`)}i(m,"addErrorsFrom");function h(g){var _;if(!s.opts.unevaluated)return;let x=(_=r?.validate)===null||_===void 0?void 0:_.evaluated;if(s.props!==!0)if(x&&!x.dynamicProps)x.props!==void 0&&(s.props=Bg.mergeEvaluated.props(o,x.props,s.props));else{let v=o.var("props",(0,Dt._)`${g}.evaluated.props`);s.props=Bg.mergeEvaluated.props(o,v,s.props,Dt.Name)}if(s.items!==!0)if(x&&!x.dynamicItems)x.items!==void 0&&(s.items=Bg.mergeEvaluated.items(o,x.items,s.items));else{let v=o.var("items",(0,Dt._)`${g}.evaluated.items`);s.items=Bg.mergeEvaluated.items(o,v,s.items,Dt.Name)}}i(h,"addEvaluatedFrom")}i(Hg,"callRef");fi.callRef=Hg;fi.default=Ooe});var sU=F(iE=>{"use strict";Object.defineProperty(iE,"__esModule",{value:!0});var Aoe=eU(),Roe=oU(),joe=["$schema","$id","$defs","$vocabulary",{keyword:"$comment"},"definitions",Aoe.default,Roe.default];iE.default=joe});var iU=F(aE=>{"use strict";Object.defineProperty(aE,"__esModule",{value:!0});var Vg=se(),Oo=Vg.operators,Gg={maximum:{okStr:"<=",ok:Oo.LTE,fail:Oo.GT},minimum:{okStr:">=",ok:Oo.GTE,fail:Oo.LT},exclusiveMaximum:{okStr:"<",ok:Oo.LT,fail:Oo.GTE},exclusiveMinimum:{okStr:">",ok:Oo.GT,fail:Oo.LTE}},Doe={message:({keyword:e,schemaCode:t})=>(0,Vg.str)`must be ${Gg[e].okStr} ${t}`,params:({keyword:e,schemaCode:t})=>(0,Vg._)`{comparison: ${Gg[e].okStr}, limit: ${t}}`},Moe={keyword:Object.keys(Gg),type:"number",schemaType:"number",$data:!0,error:Doe,code(e){let{keyword:t,data:r,schemaCode:n}=e;e.fail$data((0,Vg._)`${r} ${Gg[t].fail} ${n} || isNaN(${r})`)}};aE.default=Moe});var aU=F(cE=>{"use strict";Object.defineProperty(cE,"__esModule",{value:!0});var zd=se(),Zoe={message:({schemaCode:e})=>(0,zd.str)`must be multiple of ${e}`,params:({schemaCode:e})=>(0,zd._)`{multipleOf: ${e}}`},Loe={keyword:"multipleOf",type:"number",schemaType:"number",$data:!0,error:Zoe,code(e){let{gen:t,data:r,schemaCode:n,it:o}=e,s=o.opts.multipleOfPrecision,a=t.let("res"),c=s?(0,zd._)`Math.abs(Math.round(${a}) - ${a}) > 1e-${s}`:(0,zd._)`${a} !== parseInt(${a})`;e.fail$data((0,zd._)`(${n} === 0 || (${a} = ${r}/${n}, ${c}))`)}};cE.default=Loe});var lU=F(lE=>{"use strict";Object.defineProperty(lE,"__esModule",{value:!0});function cU(e){let t=e.length,r=0,n=0,o;for(;n<t;)r++,o=e.charCodeAt(n++),o>=55296&&o<=56319&&n<t&&(o=e.charCodeAt(n),(o&64512)===56320&&n++);return r}i(cU,"ucs2length");lE.default=cU;cU.code='require("ajv/dist/runtime/ucs2length").default'});var uU=F(uE=>{"use strict";Object.defineProperty(uE,"__esModule",{value:!0});var mi=se(),Foe=me(),Uoe=lU(),qoe={message({keyword:e,schemaCode:t}){let r=e==="maxLength"?"more":"fewer";return(0,mi.str)`must NOT have ${r} than ${t} characters`},params:({schemaCode:e})=>(0,mi._)`{limit: ${e}}`},Boe={keyword:["maxLength","minLength"],type:"string",schemaType:"number",$data:!0,error:qoe,code(e){let{keyword:t,data:r,schemaCode:n,it:o}=e,s=t==="maxLength"?mi.operators.GT:mi.operators.LT,a=o.opts.unicode===!1?(0,mi._)`${r}.length`:(0,mi._)`${(0,Foe.useFunc)(e.gen,Uoe.default)}(${r})`;e.fail$data((0,mi._)`${a} ${s} ${n}`)}};uE.default=Boe});var dU=F(dE=>{"use strict";Object.defineProperty(dE,"__esModule",{value:!0});var Hoe=mr(),Voe=me(),fc=se(),Goe={message:({schemaCode:e})=>(0,fc.str)`must match pattern "${e}"`,params:({schemaCode:e})=>(0,fc._)`{pattern: ${e}}`},Woe={keyword:"pattern",type:"string",schemaType:"string",$data:!0,error:Goe,code(e){let{gen:t,data:r,$data:n,schema:o,schemaCode:s,it:a}=e,c=a.opts.unicodeRegExp?"u":"";if(n){let{regExp:l}=a.opts.code,u=l.code==="new RegExp"?(0,fc._)`new RegExp`:(0,Voe.useFunc)(t,l),d=t.let("valid");t.try(()=>t.assign(d,(0,fc._)`${u}(${s}, ${c}).test(${r})`),()=>t.assign(d,!1)),e.fail$data((0,fc._)`!${d}`)}else{let l=(0,Hoe.usePattern)(e,o);e.fail$data((0,fc._)`!${l}.test(${r})`)}}};dE.default=Woe});var pU=F(pE=>{"use strict";Object.defineProperty(pE,"__esModule",{value:!0});var Cd=se(),Joe={message({keyword:e,schemaCode:t}){let r=e==="maxProperties"?"more":"fewer";return(0,Cd.str)`must NOT have ${r} than ${t} properties`},params:({schemaCode:e})=>(0,Cd._)`{limit: ${e}}`},Koe={keyword:["maxProperties","minProperties"],type:"object",schemaType:"number",$data:!0,error:Joe,code(e){let{keyword:t,data:r,schemaCode:n}=e,o=t==="maxProperties"?Cd.operators.GT:Cd.operators.LT;e.fail$data((0,Cd._)`Object.keys(${r}).length ${o} ${n}`)}};pE.default=Koe});var fU=F(fE=>{"use strict";Object.defineProperty(fE,"__esModule",{value:!0});var Id=mr(),Pd=se(),Yoe=me(),Xoe={message:({params:{missingProperty:e}})=>(0,Pd.str)`must have required property '${e}'`,params:({params:{missingProperty:e}})=>(0,Pd._)`{missingProperty: ${e}}`},Qoe={keyword:"required",type:"object",schemaType:"array",$data:!0,error:Xoe,code(e){let{gen:t,schema:r,schemaCode:n,data:o,$data:s,it:a}=e,{opts:c}=a;if(!s&&r.length===0)return;let l=r.length>=c.loopRequired;if(a.allErrors?u():d(),c.strictRequired){let h=e.parentSchema.properties,{definedProperties:g}=e.it;for(let _ of r)if(h?.[_]===void 0&&!g.has(_)){let x=a.schemaEnv.baseId+a.errSchemaPath,v=`required property "${_}" is not defined at "${x}" (strictRequired)`;(0,Yoe.checkStrictMode)(a,v,a.opts.strictRequired)}}function u(){if(l||s)e.block$data(Pd.nil,p);else for(let h of r)(0,Id.checkReportMissingProp)(e,h)}i(u,"allErrorsMode");function d(){let h=t.let("missing");if(l||s){let g=t.let("valid",!0);e.block$data(g,()=>m(h,g)),e.ok(g)}else t.if((0,Id.checkMissingProp)(e,r,h)),(0,Id.reportMissingProp)(e,h),t.else()}i(d,"exitOnErrorMode");function p(){t.forOf("prop",n,h=>{e.setParams({missingProperty:h}),t.if((0,Id.noPropertyInData)(t,o,h,c.ownProperties),()=>e.error())})}i(p,"loopAllRequired");function m(h,g){e.setParams({missingProperty:h}),t.forOf(h,n,()=>{t.assign(g,(0,Id.propertyInData)(t,o,h,c.ownProperties)),t.if((0,Pd.not)(g),()=>{e.error(),t.break()})},Pd.nil)}i(m,"loopUntilMissing")}};fE.default=Qoe});var mU=F(mE=>{"use strict";Object.defineProperty(mE,"__esModule",{value:!0});var Od=se(),ese={message({keyword:e,schemaCode:t}){let r=e==="maxItems"?"more":"fewer";return(0,Od.str)`must NOT have ${r} than ${t} items`},params:({schemaCode:e})=>(0,Od._)`{limit: ${e}}`},tse={keyword:["maxItems","minItems"],type:"array",schemaType:"number",$data:!0,error:ese,code(e){let{keyword:t,data:r,schemaCode:n}=e,o=t==="maxItems"?Od.operators.GT:Od.operators.LT;e.fail$data((0,Od._)`${r}.length ${o} ${n}`)}};mE.default=tse});var Wg=F(hE=>{"use strict";Object.defineProperty(hE,"__esModule",{value:!0});var hU=z$();hU.code='require("ajv/dist/runtime/equal").default';hE.default=hU});var gU=F(yE=>{"use strict";Object.defineProperty(yE,"__esModule",{value:!0});var gE=xd(),ct=se(),rse=me(),nse=Wg(),ose={message:({params:{i:e,j:t}})=>(0,ct.str)`must NOT have duplicate items (items ## ${t} and ${e} are identical)`,params:({params:{i:e,j:t}})=>(0,ct._)`{i: ${e}, j: ${t}}`},sse={keyword:"uniqueItems",type:"array",schemaType:"boolean",$data:!0,error:ose,code(e){let{gen:t,data:r,$data:n,schema:o,parentSchema:s,schemaCode:a,it:c}=e;if(!n&&!o)return;let l=t.let("valid"),u=s.items?(0,gE.getSchemaTypes)(s.items):[];e.block$data(l,d,(0,ct._)`${a} === false`),e.ok(l);function d(){let g=t.let("i",(0,ct._)`${r}.length`),_=t.let("j");e.setParams({i:g,j:_}),t.assign(l,!0),t.if((0,ct._)`${g} > 1`,()=>(p()?m:h)(g,_))}i(d,"validateUniqueItems");function p(){return u.length>0&&!u.some(g=>g==="object"||g==="array")}i(p,"canOptimize");function m(g,_){let x=t.name("item"),v=(0,gE.checkDataTypes)(u,x,c.opts.strictNumbers,gE.DataType.Wrong),b=t.const("indices",(0,ct._)`{}`);t.for((0,ct._)`;${g}--;`,()=>{t.let(x,(0,ct._)`${r}[${g}]`),t.if(v,(0,ct._)`continue`),u.length>1&&t.if((0,ct._)`typeof ${x} == "string"`,(0,ct._)`${x} += "_"`),t.if((0,ct._)`typeof ${b}[${x}] == "number"`,()=>{t.assign(_,(0,ct._)`${b}[${x}]`),e.error(),t.assign(l,!1).break()}).code((0,ct._)`${b}[${x}] = ${g}`)})}i(m,"loopN");function h(g,_){let x=(0,rse.useFunc)(t,nse.default),v=t.name("outer");t.label(v).for((0,ct._)`;${g}--;`,()=>t.for((0,ct._)`${_} = ${g}; ${_}--;`,()=>t.if((0,ct._)`${x}(${r}[${g}], ${r}[${_}])`,()=>{e.error(),t.assign(l,!1).break(v)})))}i(h,"loopN2")}};yE.default=sse});var yU=F(_E=>{"use strict";Object.defineProperty(_E,"__esModule",{value:!0});var xE=se(),ise=me(),ase=Wg(),cse={message:"must be equal to constant",params:({schemaCode:e})=>(0,xE._)`{allowedValue: ${e}}`},lse={keyword:"const",$data:!0,error:cse,code(e){let{gen:t,data:r,$data:n,schemaCode:o,schema:s}=e;n||s&&typeof s=="object"?e.fail$data((0,xE._)`!${(0,ise.useFunc)(t,ase.default)}(${r}, ${o})`):e.fail((0,xE._)`${s} !== ${r}`)}};_E.default=lse});var xU=F(vE=>{"use strict";Object.defineProperty(vE,"__esModule",{value:!0});var Ad=se(),use=me(),dse=Wg(),pse={message:"must be equal to one of the allowed values",params:({schemaCode:e})=>(0,Ad._)`{allowedValues: ${e}}`},fse={keyword:"enum",schemaType:"array",$data:!0,error:pse,code(e){let{gen:t,data:r,$data:n,schema:o,schemaCode:s,it:a}=e;if(!n&&o.length===0)throw new Error("enum must have non-empty array");let c=o.length>=a.opts.loopEnum,l,u=i(()=>l??(l=(0,use.useFunc)(t,dse.default)),"getEql"),d;if(c||n)d=t.let("valid"),e.block$data(d,p);else{if(!Array.isArray(o))throw new Error("ajv implementation error");let h=t.const("vSchema",s);d=(0,Ad.or)(...o.map((g,_)=>m(h,_)))}e.pass(d);function p(){t.assign(d,!1),t.forOf("v",s,h=>t.if((0,Ad._)`${u()}(${r}, ${h})`,()=>t.assign(d,!0).break()))}i(p,"loopEnum");function m(h,g){let _=o[g];return typeof _=="object"&&_!==null?(0,Ad._)`${u()}(${r}, ${h}[${g}])`:(0,Ad._)`${r} === ${_}`}i(m,"equalCode")}};vE.default=fse});var _U=F(wE=>{"use strict";Object.defineProperty(wE,"__esModule",{value:!0});var mse=iU(),hse=aU(),gse=uU(),yse=dU(),xse=pU(),_se=fU(),vse=mU(),wse=gU(),bse=yU(),Sse=xU(),kse=[mse.default,hse.default,gse.default,yse.default,xse.default,_se.default,vse.default,wse.default,{keyword:"type",schemaType:["string","array"]},{keyword:"nullable",schemaType:"boolean"},bse.default,Sse.default];wE.default=kse});var SE=F(Rd=>{"use strict";Object.defineProperty(Rd,"__esModule",{value:!0});Rd.validateAdditionalItems=void 0;var hi=se(),bE=me(),$se={message:({params:{len:e}})=>(0,hi.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0,hi._)`{limit: ${e}}`},Ese={keyword:"additionalItems",type:"array",schemaType:["boolean","object"],before:"uniqueItems",error:$se,code(e){let{parentSchema:t,it:r}=e,{items:n}=t;if(!Array.isArray(n)){(0,bE.checkStrictMode)(r,'"additionalItems" is ignored when "items" is not an array of schemas');return}vU(e,n)}};function vU(e,t){let{gen:r,schema:n,data:o,keyword:s,it:a}=e;a.items=!0;let c=r.const("len",(0,hi._)`${o}.length`);if(n===!1)e.setParams({len:t.length}),e.pass((0,hi._)`${c} <= ${t.length}`);else if(typeof n=="object"&&!(0,bE.alwaysValidSchema)(a,n)){let u=r.var("valid",(0,hi._)`${c} <= ${t.length}`);r.if((0,hi.not)(u),()=>l(u)),e.ok(u)}function l(u){r.forRange("i",t.length,c,d=>{e.subschema({keyword:s,dataProp:d,dataPropType:bE.Type.Num},u),a.allErrors||r.if((0,hi.not)(u),()=>r.break())})}i(l,"validateItems")}i(vU,"validateAdditionalItems");Rd.validateAdditionalItems=vU;Rd.default=Ese});var kE=F(jd=>{"use strict";Object.defineProperty(jd,"__esModule",{value:!0});jd.validateTuple=void 0;var wU=se(),Jg=me(),Nse=mr(),Tse={keyword:"items",type:"array",schemaType:["object","array","boolean"],before:"uniqueItems",code(e){let{schema:t,it:r}=e;if(Array.isArray(t))return bU(e,"additionalItems",t);r.items=!0,!(0,Jg.alwaysValidSchema)(r,t)&&e.ok((0,Nse.validateArray)(e))}};function bU(e,t,r=e.schema){let{gen:n,parentSchema:o,data:s,keyword:a,it:c}=e;d(o),c.opts.unevaluated&&r.length&&c.items!==!0&&(c.items=Jg.mergeEvaluated.items(n,r.length,c.items));let l=n.name("valid"),u=n.const("len",(0,wU._)`${s}.length`);r.forEach((p,m)=>{(0,Jg.alwaysValidSchema)(c,p)||(n.if((0,wU._)`${u} > ${m}`,()=>e.subschema({keyword:a,schemaProp:m,dataProp:m},l)),e.ok(l))});function d(p){let{opts:m,errSchemaPath:h}=c,g=r.length,_=g===p.minItems&&(g===p.maxItems||p[t]===!1);if(m.strictTuples&&!_){let x=`"${a}" is ${g}-tuple, but minItems or maxItems/${t} are not specified or different at path "${h}"`;(0,Jg.checkStrictMode)(c,x,m.strictTuples)}}i(d,"checkStrictTuple")}i(bU,"validateTuple");jd.validateTuple=bU;jd.default=Tse});var SU=F($E=>{"use strict";Object.defineProperty($E,"__esModule",{value:!0});var zse=kE(),Cse={keyword:"prefixItems",type:"array",schemaType:["array"],before:"uniqueItems",code:e=>(0,zse.validateTuple)(e,"items")};$E.default=Cse});var $U=F(EE=>{"use strict";Object.defineProperty(EE,"__esModule",{value:!0});var kU=se(),Ise=me(),Pse=mr(),Ose=SE(),Ase={message:({params:{len:e}})=>(0,kU.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0,kU._)`{limit: ${e}}`},Rse={keyword:"items",type:"array",schemaType:["object","boolean"],before:"uniqueItems",error:Ase,code(e){let{schema:t,parentSchema:r,it:n}=e,{prefixItems:o}=r;n.items=!0,!(0,Ise.alwaysValidSchema)(n,t)&&(o?(0,Ose.validateAdditionalItems)(e,o):e.ok((0,Pse.validateArray)(e)))}};EE.default=Rse});var EU=F(NE=>{"use strict";Object.defineProperty(NE,"__esModule",{value:!0});var gr=se(),Kg=me(),jse={message:({params:{min:e,max:t}})=>t===void 0?(0,gr.str)`must contain at least ${e} valid item(s)`:(0,gr.str)`must contain at least ${e} and no more than ${t} valid item(s)`,params:({params:{min:e,max:t}})=>t===void 0?(0,gr._)`{minContains: ${e}}`:(0,gr._)`{minContains: ${e}, maxContains: ${t}}`},Dse={keyword:"contains",type:"array",schemaType:["object","boolean"],before:"uniqueItems",trackErrors:!0,error:jse,code(e){let{gen:t,schema:r,parentSchema:n,data:o,it:s}=e,a,c,{minContains:l,maxContains:u}=n;s.opts.next?(a=l===void 0?1:l,c=u):a=1;let d=t.const("len",(0,gr._)`${o}.length`);if(e.setParams({min:a,max:c}),c===void 0&&a===0){(0,Kg.checkStrictMode)(s,'"minContains" == 0 without "maxContains": "contains" keyword ignored');return}if(c!==void 0&&a>c){(0,Kg.checkStrictMode)(s,'"minContains" > "maxContains" is always invalid'),e.fail();return}if((0,Kg.alwaysValidSchema)(s,r)){let _=(0,gr._)`${d} >= ${a}`;c!==void 0&&(_=(0,gr._)`${_} && ${d} <= ${c}`),e.pass(_);return}s.items=!0;let p=t.name("valid");c===void 0&&a===1?h(p,()=>t.if(p,()=>t.break())):a===0?(t.let(p,!0),c!==void 0&&t.if((0,gr._)`${o}.length > 0`,m)):(t.let(p,!1),m()),e.result(p,()=>e.reset());function m(){let _=t.name("_valid"),x=t.let("count",0);h(_,()=>t.if(_,()=>g(x)))}i(m,"validateItemsWithCount");function h(_,x){t.forRange("i",0,d,v=>{e.subschema({keyword:"contains",dataProp:v,dataPropType:Kg.Type.Num,compositeRule:!0},_),x()})}i(h,"validateItems");function g(_){t.code((0,gr._)`${_}++`),c===void 0?t.if((0,gr._)`${_} >= ${a}`,()=>t.assign(p,!0).break()):(t.if((0,gr._)`${_} > ${c}`,()=>t.assign(p,!1).break()),a===1?t.assign(p,!0):t.if((0,gr._)`${_} >= ${a}`,()=>t.assign(p,!0)))}i(g,"checkLimits")}};NE.default=Dse});var zU=F(sn=>{"use strict";Object.defineProperty(sn,"__esModule",{value:!0});sn.validateSchemaDeps=sn.validatePropertyDeps=sn.error=void 0;var TE=se(),Mse=me(),Dd=mr();sn.error={message:({params:{property:e,depsCount:t,deps:r}})=>{let n=t===1?"property":"properties";return(0,TE.str)`must have ${n} ${r} when property ${e} is present`},params:({params:{property:e,depsCount:t,deps:r,missingProperty:n}})=>(0,TE._)`{property: ${e},
178
227
  missingProperty: ${n},
179
228
  depsCount: ${t},
180
- deps: ${r}}`};var jQ={keyword:"dependencies",type:"object",schemaType:"object",error:Gr.error,code(e){let[t,r]=DQ(e);fZ(e,t),mZ(e,r)}};function DQ({schema:e}){let t={},r={};for(let n in e){if(n==="__proto__")continue;let o=Array.isArray(e[n])?t:r;o[n]=e[n]}return[t,r]}i(DQ,"splitDependencies");function fZ(e,t=e.schema){let{gen:r,data:n,it:o}=e;if(Object.keys(t).length===0)return;let s=r.let("missing");for(let a in t){let c=t[a];if(c.length===0)continue;let l=(0,uu.propertyInData)(r,n,a,o.opts.ownProperties);e.setParams({property:a,depsCount:c.length,deps:c.join(", ")}),o.allErrors?r.if(l,()=>{for(let u of c)(0,uu.checkReportMissingProp)(e,u)}):(r.if((0,rk._)`${l} && (${(0,uu.checkMissingProp)(e,c,s)})`),(0,uu.reportMissingProp)(e,s),r.else())}}i(fZ,"validatePropertyDeps");Gr.validatePropertyDeps=fZ;function mZ(e,t=e.schema){let{gen:r,data:n,keyword:o,it:s}=e,a=r.name("valid");for(let c in t)(0,AQ.alwaysValidSchema)(s,t[c])||(r.if((0,uu.propertyInData)(r,n,c,s.opts.ownProperties),()=>{let l=e.subschema({keyword:o,schemaProp:c},a);e.mergeValidEvaluated(l,a)},()=>r.var(a,!0)),e.ok(a))}i(mZ,"validateSchemaDeps");Gr.validateSchemaDeps=mZ;Gr.default=jQ});var yZ=D(nk=>{"use strict";Object.defineProperty(nk,"__esModule",{value:!0});var gZ=ne(),MQ=pe(),ZQ={message:"property name must be valid",params:({params:e})=>(0,gZ._)`{propertyName: ${e.propertyName}}`},LQ={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:ZQ,code(e){let{gen:t,schema:r,data:n,it:o}=e;if((0,MQ.alwaysValidSchema)(o,r))return;let s=t.name("valid");t.forIn("key",n,a=>{e.setParams({propertyName:a}),e.subschema({keyword:"propertyNames",data:a,dataTypes:["string"],propertyName:a,compositeRule:!0},s),t.if((0,gZ.not)(s),()=>{e.error(!0),o.allErrors||t.break()})}),e.ok(s)}};nk.default=LQ});var sk=D(ok=>{"use strict";Object.defineProperty(ok,"__esModule",{value:!0});var Km=ar(),Er=ne(),FQ=zn(),Jm=pe(),UQ={message:"must NOT have additional properties",params:({params:e})=>(0,Er._)`{additionalProperty: ${e.additionalProperty}}`},qQ={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:!0,trackErrors:!0,error:UQ,code(e){let{gen:t,schema:r,parentSchema:n,data:o,errsCount:s,it:a}=e;if(!s)throw new Error("ajv implementation error");let{allErrors:c,opts:l}=a;if(a.props=!0,l.removeAdditional!=="all"&&(0,Jm.alwaysValidSchema)(a,r))return;let u=(0,Km.allSchemaProperties)(n.properties),d=(0,Km.allSchemaProperties)(n.patternProperties);p(),e.ok((0,Er._)`${s} === ${FQ.default.errors}`);function p(){t.forIn("key",o,x=>{!u.length&&!d.length?g(x):t.if(h(x),()=>g(x))})}i(p,"checkAdditionalProperties");function h(x){let v;if(u.length>8){let w=(0,Jm.schemaRefOrVal)(a,n.properties,"properties");v=(0,Km.isOwnProperty)(t,w,x)}else u.length?v=(0,Er.or)(...u.map(w=>(0,Er._)`${x} === ${w}`)):v=Er.nil;return d.length&&(v=(0,Er.or)(v,...d.map(w=>(0,Er._)`${(0,Km.usePattern)(e,w)}.test(${x})`))),(0,Er.not)(v)}i(h,"isAdditional");function m(x){t.code((0,Er._)`delete ${o}[${x}]`)}i(m,"deleteAdditional");function g(x){if(l.removeAdditional==="all"||l.removeAdditional&&r===!1){m(x);return}if(r===!1){e.setParams({additionalProperty:x}),e.error(),c||t.break();return}if(typeof r=="object"&&!(0,Jm.alwaysValidSchema)(a,r)){let v=t.name("valid");l.removeAdditional==="failing"?(_(x,v,!1),t.if((0,Er.not)(v),()=>{e.reset(),m(x)})):(_(x,v),c||t.if((0,Er.not)(v),()=>t.break()))}}i(g,"additionalPropertyCode");function _(x,v,w){let b={keyword:"additionalProperties",dataProp:x,dataPropType:Jm.Type.Str};w===!1&&Object.assign(b,{compositeRule:!0,createErrors:!1,allErrors:!1}),e.subschema(b,v)}i(_,"applyAdditionalSchema")}};ok.default=qQ});var vZ=D(ak=>{"use strict";Object.defineProperty(ak,"__esModule",{value:!0});var HQ=Kl(),xZ=ar(),ik=pe(),_Z=sk(),BQ={keyword:"properties",type:"object",schemaType:"object",code(e){let{gen:t,schema:r,parentSchema:n,data:o,it:s}=e;s.opts.removeAdditional==="all"&&n.additionalProperties===void 0&&_Z.default.code(new HQ.KeywordCxt(s,_Z.default,"additionalProperties"));let a=(0,xZ.allSchemaProperties)(r);for(let p of a)s.definedProperties.add(p);s.opts.unevaluated&&a.length&&s.props!==!0&&(s.props=ik.mergeEvaluated.props(t,(0,ik.toHash)(a),s.props));let c=a.filter(p=>!(0,ik.alwaysValidSchema)(s,r[p]));if(c.length===0)return;let l=t.name("valid");for(let p of c)u(p)?d(p):(t.if((0,xZ.propertyInData)(t,o,p,s.opts.ownProperties)),d(p),s.allErrors||t.else().var(l,!0),t.endIf()),e.it.definedProperties.add(p),e.ok(l);function u(p){return s.opts.useDefaults&&!s.compositeRule&&r[p].default!==void 0}i(u,"hasDefault");function d(p){e.subschema({keyword:"properties",schemaProp:p,dataProp:p},l)}i(d,"applyPropertySchema")}};ak.default=BQ});var kZ=D(ck=>{"use strict";Object.defineProperty(ck,"__esModule",{value:!0});var wZ=ar(),Ym=ne(),bZ=pe(),SZ=pe(),VQ={keyword:"patternProperties",type:"object",schemaType:"object",code(e){let{gen:t,schema:r,data:n,parentSchema:o,it:s}=e,{opts:a}=s,c=(0,wZ.allSchemaProperties)(r),l=c.filter(_=>(0,bZ.alwaysValidSchema)(s,r[_]));if(c.length===0||l.length===c.length&&(!s.opts.unevaluated||s.props===!0))return;let u=a.strictSchema&&!a.allowMatchingProperties&&o.properties,d=t.name("valid");s.props!==!0&&!(s.props instanceof Ym.Name)&&(s.props=(0,SZ.evaluatedPropsToName)(t,s.props));let{props:p}=s;h();function h(){for(let _ of c)u&&m(_),s.allErrors?g(_):(t.var(d,!0),g(_),t.if(d))}i(h,"validatePatternProperties");function m(_){for(let x in u)new RegExp(_).test(x)&&(0,bZ.checkStrictMode)(s,`property ${x} matches pattern ${_} (use allowMatchingProperties)`)}i(m,"checkMatchingProperties");function g(_){t.forIn("key",n,x=>{t.if((0,Ym._)`${(0,wZ.usePattern)(e,_)}.test(${x})`,()=>{let v=l.includes(_);v||e.subschema({keyword:"patternProperties",schemaProp:_,dataProp:x,dataPropType:SZ.Type.Str},d),s.opts.unevaluated&&p!==!0?t.assign((0,Ym._)`${p}[${x}]`,!0):!v&&!s.allErrors&&t.if((0,Ym.not)(d),()=>t.break())})})}i(g,"validateProperties")}};ck.default=VQ});var $Z=D(lk=>{"use strict";Object.defineProperty(lk,"__esModule",{value:!0});var GQ=pe(),WQ={keyword:"not",schemaType:["object","boolean"],trackErrors:!0,code(e){let{gen:t,schema:r,it:n}=e;if((0,GQ.alwaysValidSchema)(n,r)){e.fail();return}let o=t.name("valid");e.subschema({keyword:"not",compositeRule:!0,createErrors:!1,allErrors:!1},o),e.failResult(o,()=>e.reset(),()=>e.error())},error:{message:"must NOT be valid"}};lk.default=WQ});var EZ=D(uk=>{"use strict";Object.defineProperty(uk,"__esModule",{value:!0});var KQ=ar(),JQ={keyword:"anyOf",schemaType:"array",trackErrors:!0,code:KQ.validateUnion,error:{message:"must match a schema in anyOf"}};uk.default=JQ});var NZ=D(dk=>{"use strict";Object.defineProperty(dk,"__esModule",{value:!0});var Xm=ne(),YQ=pe(),XQ={message:"must match exactly one schema in oneOf",params:({params:e})=>(0,Xm._)`{passingSchemas: ${e.passing}}`},QQ={keyword:"oneOf",schemaType:"array",trackErrors:!0,error:XQ,code(e){let{gen:t,schema:r,parentSchema:n,it:o}=e;if(!Array.isArray(r))throw new Error("ajv implementation error");if(o.opts.discriminator&&n.discriminator)return;let s=r,a=t.let("valid",!1),c=t.let("passing",null),l=t.name("_valid");e.setParams({passing:c}),t.block(u),e.result(a,()=>e.reset(),()=>e.error(!0));function u(){s.forEach((d,p)=>{let h;(0,YQ.alwaysValidSchema)(o,d)?t.var(l,!0):h=e.subschema({keyword:"oneOf",schemaProp:p,compositeRule:!0},l),p>0&&t.if((0,Xm._)`${l} && ${a}`).assign(a,!1).assign(c,(0,Xm._)`[${c}, ${p}]`).else(),t.if(l,()=>{t.assign(a,!0),t.assign(c,p),h&&e.mergeEvaluated(h,Xm.Name)})})}i(u,"validateOneOf")}};dk.default=QQ});var TZ=D(pk=>{"use strict";Object.defineProperty(pk,"__esModule",{value:!0});var eee=pe(),tee={keyword:"allOf",schemaType:"array",code(e){let{gen:t,schema:r,it:n}=e;if(!Array.isArray(r))throw new Error("ajv implementation error");let o=t.name("valid");r.forEach((s,a)=>{if((0,eee.alwaysValidSchema)(n,s))return;let c=e.subschema({keyword:"allOf",schemaProp:a},o);e.ok(o),e.mergeEvaluated(c)})}};pk.default=tee});var IZ=D(fk=>{"use strict";Object.defineProperty(fk,"__esModule",{value:!0});var Qm=ne(),CZ=pe(),ree={message:({params:e})=>(0,Qm.str)`must match "${e.ifClause}" schema`,params:({params:e})=>(0,Qm._)`{failingKeyword: ${e.ifClause}}`},nee={keyword:"if",schemaType:["object","boolean"],trackErrors:!0,error:ree,code(e){let{gen:t,parentSchema:r,it:n}=e;r.then===void 0&&r.else===void 0&&(0,CZ.checkStrictMode)(n,'"if" without "then" and "else" is ignored');let o=zZ(n,"then"),s=zZ(n,"else");if(!o&&!s)return;let a=t.let("valid",!0),c=t.name("_valid");if(l(),e.reset(),o&&s){let d=t.let("ifClause");e.setParams({ifClause:d}),t.if(c,u("then",d),u("else",d))}else o?t.if(c,u("then")):t.if((0,Qm.not)(c),u("else"));e.pass(a,()=>e.error(!0));function l(){let d=e.subschema({keyword:"if",compositeRule:!0,createErrors:!1,allErrors:!1},c);e.mergeEvaluated(d)}i(l,"validateIf");function u(d,p){return()=>{let h=e.subschema({keyword:d},c);t.assign(a,c),e.mergeValidEvaluated(h,a),p?t.assign(p,(0,Qm._)`${d}`):e.setParams({ifClause:d})}}i(u,"validateClause")}};function zZ(e,t){let r=e.schema[t];return r!==void 0&&!(0,CZ.alwaysValidSchema)(e,r)}i(zZ,"hasSchema");fk.default=nee});var PZ=D(mk=>{"use strict";Object.defineProperty(mk,"__esModule",{value:!0});var oee=pe(),see={keyword:["then","else"],schemaType:["object","boolean"],code({keyword:e,parentSchema:t,it:r}){t.if===void 0&&(0,oee.checkStrictMode)(r,`"${e}" without "if" is ignored`)}};mk.default=see});var RZ=D(hk=>{"use strict";Object.defineProperty(hk,"__esModule",{value:!0});var iee=YS(),aee=lZ(),cee=XS(),lee=dZ(),uee=pZ(),dee=hZ(),pee=yZ(),fee=sk(),mee=vZ(),hee=kZ(),gee=$Z(),yee=EZ(),xee=NZ(),_ee=TZ(),vee=IZ(),wee=PZ();function bee(e=!1){let t=[gee.default,yee.default,xee.default,_ee.default,vee.default,wee.default,pee.default,fee.default,dee.default,mee.default,hee.default];return e?t.push(aee.default,lee.default):t.push(iee.default,cee.default),t.push(uee.default),t}i(bee,"getApplicator");hk.default=bee});var OZ=D(gk=>{"use strict";Object.defineProperty(gk,"__esModule",{value:!0});var He=ne(),See={message:({schemaCode:e})=>(0,He.str)`must match format "${e}"`,params:({schemaCode:e})=>(0,He._)`{format: ${e}}`},kee={keyword:"format",type:["number","string"],schemaType:"string",$data:!0,error:See,code(e,t){let{gen:r,data:n,$data:o,schema:s,schemaCode:a,it:c}=e,{opts:l,errSchemaPath:u,schemaEnv:d,self:p}=c;if(!l.validateFormats)return;o?h():m();function h(){let g=r.scopeValue("formats",{ref:p.formats,code:l.code.formats}),_=r.const("fDef",(0,He._)`${g}[${a}]`),x=r.let("fType"),v=r.let("format");r.if((0,He._)`typeof ${_} == "object" && !(${_} instanceof RegExp)`,()=>r.assign(x,(0,He._)`${_}.type || "string"`).assign(v,(0,He._)`${_}.validate`),()=>r.assign(x,(0,He._)`"string"`).assign(v,_)),e.fail$data((0,He.or)(w(),b()));function w(){return l.strictSchema===!1?He.nil:(0,He._)`${a} && !${v}`}i(w,"unknownFmt");function b(){let S=d.$async?(0,He._)`(${_}.async ? await ${v}(${n}) : ${v}(${n}))`:(0,He._)`${v}(${n})`,T=(0,He._)`(typeof ${v} == "function" ? ${S} : ${v}.test(${n}))`;return(0,He._)`${v} && ${v} !== true && ${x} === ${t} && !${T}`}i(b,"invalidFmt")}i(h,"validate$DataFormat");function m(){let g=p.formats[s];if(!g){w();return}if(g===!0)return;let[_,x,v]=b(g);_===t&&e.pass(S());function w(){if(l.strictSchema===!1){p.logger.warn(T());return}throw new Error(T());function T(){return`unknown format "${s}" ignored in schema at path "${u}"`}}i(w,"unknownFormat");function b(T){let K=T instanceof RegExp?(0,He.regexpCode)(T):l.code.formats?(0,He._)`${l.code.formats}${(0,He.getProperty)(s)}`:void 0,A=r.scopeValue("formats",{key:s,ref:T,code:K});return typeof T=="object"&&!(T instanceof RegExp)?[T.type||"string",T.validate,(0,He._)`${A}.validate`]:["string",T,A]}i(b,"getFormat");function S(){if(typeof g=="object"&&!(g instanceof RegExp)&&g.async){if(!d.$async)throw new Error("async format in sync schema");return(0,He._)`await ${v}(${n})`}return typeof x=="function"?(0,He._)`${v}(${n})`:(0,He._)`${v}.test(${n})`}i(S,"validCondition")}i(m,"validateFormat")}};gk.default=kee});var AZ=D(yk=>{"use strict";Object.defineProperty(yk,"__esModule",{value:!0});var $ee=OZ(),Eee=[$ee.default];yk.default=Eee});var jZ=D(wa=>{"use strict";Object.defineProperty(wa,"__esModule",{value:!0});wa.contentVocabulary=wa.metadataVocabulary=void 0;wa.metadataVocabulary=["title","description","default","deprecated","readOnly","writeOnly","examples"];wa.contentVocabulary=["contentMediaType","contentEncoding","contentSchema"]});var MZ=D(xk=>{"use strict";Object.defineProperty(xk,"__esModule",{value:!0});var Nee=B2(),Tee=sZ(),zee=RZ(),Cee=AZ(),DZ=jZ(),Iee=[Nee.default,Tee.default,(0,zee.default)(),Cee.default,DZ.metadataVocabulary,DZ.contentVocabulary];xk.default=Iee});var LZ=D(eh=>{"use strict";Object.defineProperty(eh,"__esModule",{value:!0});eh.DiscrError=void 0;var ZZ;(function(e){e.Tag="tag",e.Mapping="mapping"})(ZZ||(eh.DiscrError=ZZ={}))});var UZ=D(vk=>{"use strict";Object.defineProperty(vk,"__esModule",{value:!0});var ba=ne(),_k=LZ(),FZ=Am(),Pee=Jl(),Ree=pe(),Oee={message:({params:{discrError:e,tagName:t}})=>e===_k.DiscrError.Tag?`tag "${t}" must be string`:`value of tag "${t}" must be in oneOf`,params:({params:{discrError:e,tag:t,tagName:r}})=>(0,ba._)`{error: ${e}, tag: ${r}, tagValue: ${t}}`},Aee={keyword:"discriminator",type:"object",schemaType:"object",error:Oee,code(e){let{gen:t,data:r,schema:n,parentSchema:o,it:s}=e,{oneOf:a}=o;if(!s.opts.discriminator)throw new Error("discriminator: requires discriminator option");let c=n.propertyName;if(typeof c!="string")throw new Error("discriminator: requires propertyName");if(n.mapping)throw new Error("discriminator: mapping is not supported");if(!a)throw new Error("discriminator: requires oneOf keyword");let l=t.let("valid",!1),u=t.const("tag",(0,ba._)`${r}${(0,ba.getProperty)(c)}`);t.if((0,ba._)`typeof ${u} == "string"`,()=>d(),()=>e.error(!1,{discrError:_k.DiscrError.Tag,tag:u,tagName:c})),e.ok(l);function d(){let m=h();t.if(!1);for(let g in m)t.elseIf((0,ba._)`${u} === ${g}`),t.assign(l,p(m[g]));t.else(),e.error(!1,{discrError:_k.DiscrError.Mapping,tag:u,tagName:c}),t.endIf()}i(d,"validateMapping");function p(m){let g=t.name("valid"),_=e.subschema({keyword:"oneOf",schemaProp:m},g);return e.mergeEvaluated(_,ba.Name),g}i(p,"applyTagSchema");function h(){var m;let g={},_=v(o),x=!0;for(let S=0;S<a.length;S++){let T=a[S];if(T?.$ref&&!(0,Ree.schemaHasRulesButRef)(T,s.self.RULES)){let A=T.$ref;if(T=FZ.resolveRef.call(s.self,s.schemaEnv.root,s.baseId,A),T instanceof FZ.SchemaEnv&&(T=T.schema),T===void 0)throw new Pee.default(s.opts.uriResolver,s.baseId,A)}let K=(m=T?.properties)===null||m===void 0?void 0:m[c];if(typeof K!="object")throw new Error(`discriminator: oneOf subschemas (or referenced schemas) must have "properties/${c}"`);x=x&&(_||v(T)),w(K,S)}if(!x)throw new Error(`discriminator: "${c}" must be required`);return g;function v({required:S}){return Array.isArray(S)&&S.includes(c)}function w(S,T){if(S.const)b(S.const,T);else if(S.enum)for(let K of S.enum)b(K,T);else throw new Error(`discriminator: "properties/${c}" must have "const" or "enum"`)}function b(S,T){if(typeof S!="string"||S in g)throw new Error(`discriminator: "${c}" values must be unique strings`);g[S]=T}}i(h,"getMapping")}};vk.default=Aee});var qZ=D((RZe,jee)=>{jee.exports={$schema:"http://json-schema.org/draft-07/schema#",$id:"http://json-schema.org/draft-07/schema#",title:"Core schema meta-schema",definitions:{schemaArray:{type:"array",minItems:1,items:{$ref:"#"}},nonNegativeInteger:{type:"integer",minimum:0},nonNegativeIntegerDefault0:{allOf:[{$ref:"#/definitions/nonNegativeInteger"},{default:0}]},simpleTypes:{enum:["array","boolean","integer","null","number","object","string"]},stringArray:{type:"array",items:{type:"string"},uniqueItems:!0,default:[]}},type:["object","boolean"],properties:{$id:{type:"string",format:"uri-reference"},$schema:{type:"string",format:"uri"},$ref:{type:"string",format:"uri-reference"},$comment:{type:"string"},title:{type:"string"},description:{type:"string"},default:!0,readOnly:{type:"boolean",default:!1},examples:{type:"array",items:!0},multipleOf:{type:"number",exclusiveMinimum:0},maximum:{type:"number"},exclusiveMaximum:{type:"number"},minimum:{type:"number"},exclusiveMinimum:{type:"number"},maxLength:{$ref:"#/definitions/nonNegativeInteger"},minLength:{$ref:"#/definitions/nonNegativeIntegerDefault0"},pattern:{type:"string",format:"regex"},additionalItems:{$ref:"#"},items:{anyOf:[{$ref:"#"},{$ref:"#/definitions/schemaArray"}],default:!0},maxItems:{$ref:"#/definitions/nonNegativeInteger"},minItems:{$ref:"#/definitions/nonNegativeIntegerDefault0"},uniqueItems:{type:"boolean",default:!1},contains:{$ref:"#"},maxProperties:{$ref:"#/definitions/nonNegativeInteger"},minProperties:{$ref:"#/definitions/nonNegativeIntegerDefault0"},required:{$ref:"#/definitions/stringArray"},additionalProperties:{$ref:"#"},definitions:{type:"object",additionalProperties:{$ref:"#"},default:{}},properties:{type:"object",additionalProperties:{$ref:"#"},default:{}},patternProperties:{type:"object",additionalProperties:{$ref:"#"},propertyNames:{format:"regex"},default:{}},dependencies:{type:"object",additionalProperties:{anyOf:[{$ref:"#"},{$ref:"#/definitions/stringArray"}]}},propertyNames:{$ref:"#"},const:!0,enum:{type:"array",items:!0,minItems:1,uniqueItems:!0},type:{anyOf:[{$ref:"#/definitions/simpleTypes"},{type:"array",items:{$ref:"#/definitions/simpleTypes"},minItems:1,uniqueItems:!0}]},format:{type:"string"},contentMediaType:{type:"string"},contentEncoding:{type:"string"},if:{$ref:"#"},then:{$ref:"#"},else:{$ref:"#"},allOf:{$ref:"#/definitions/schemaArray"},anyOf:{$ref:"#/definitions/schemaArray"},oneOf:{$ref:"#/definitions/schemaArray"},not:{$ref:"#"}},default:!0}});var Sk=D((Pe,wk)=>{"use strict";Object.defineProperty(Pe,"__esModule",{value:!0});Pe.MissingRefError=Pe.ValidationError=Pe.CodeGen=Pe.Name=Pe.nil=Pe.stringify=Pe.str=Pe._=Pe.KeywordCxt=Pe.Ajv=void 0;var Dee=Z2(),Mee=MZ(),Zee=UZ(),HZ=qZ(),Lee=["/properties"],th="http://json-schema.org/draft-07/schema",bk=class bk extends Dee.default{_addVocabularies(){super._addVocabularies(),Mee.default.forEach(t=>this.addVocabulary(t)),this.opts.discriminator&&this.addKeyword(Zee.default)}_addDefaultMetaSchema(){if(super._addDefaultMetaSchema(),!this.opts.meta)return;let t=this.opts.$data?this.$dataMetaSchema(HZ,Lee):HZ;this.addMetaSchema(t,th,!1),this.refs["http://json-schema.org/schema"]=th}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(th)?th:void 0)}};i(bk,"Ajv");var Sa=bk;Pe.Ajv=Sa;wk.exports=Pe=Sa;wk.exports.Ajv=Sa;Object.defineProperty(Pe,"__esModule",{value:!0});Pe.default=Sa;var Fee=Kl();Object.defineProperty(Pe,"KeywordCxt",{enumerable:!0,get:function(){return Fee.KeywordCxt}});var ka=ne();Object.defineProperty(Pe,"_",{enumerable:!0,get:function(){return ka._}});Object.defineProperty(Pe,"str",{enumerable:!0,get:function(){return ka.str}});Object.defineProperty(Pe,"stringify",{enumerable:!0,get:function(){return ka.stringify}});Object.defineProperty(Pe,"nil",{enumerable:!0,get:function(){return ka.nil}});Object.defineProperty(Pe,"Name",{enumerable:!0,get:function(){return ka.Name}});Object.defineProperty(Pe,"CodeGen",{enumerable:!0,get:function(){return ka.CodeGen}});var Uee=Rm();Object.defineProperty(Pe,"ValidationError",{enumerable:!0,get:function(){return Uee.default}});var qee=Jl();Object.defineProperty(Pe,"MissingRefError",{enumerable:!0,get:function(){return qee.default}})});var XZ=D(Kr=>{"use strict";Object.defineProperty(Kr,"__esModule",{value:!0});Kr.formatNames=Kr.fastFormats=Kr.fullFormats=void 0;function Wr(e,t){return{validate:e,compare:t}}i(Wr,"fmtDef");Kr.fullFormats={date:Wr(WZ,Nk),time:Wr($k(!0),Tk),"date-time":Wr(BZ(!0),JZ),"iso-time":Wr($k(),KZ),"iso-date-time":Wr(BZ(),YZ),duration:/^P(?!$)((\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+S)?)?|(\d+W)?)$/,uri:Kee,"uri-reference":/^(?:[a-z][a-z0-9+\-.]*:)?(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'"()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?(?:\?(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i,"uri-template":/^(?:(?:[^\x00-\x20"'<>%\\^`{|}]|%[0-9a-f]{2})|\{[+#./;?&=,!@|]?(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?(?:,(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?)*\})*$/i,url:/^(?:https?|ftp):\/\/(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z0-9\u{00a1}-\u{ffff}]+-)*[a-z0-9\u{00a1}-\u{ffff}]+)(?:\.(?:[a-z0-9\u{00a1}-\u{ffff}]+-)*[a-z0-9\u{00a1}-\u{ffff}]+)*(?:\.(?:[a-z\u{00a1}-\u{ffff}]{2,})))(?::\d{2,5})?(?:\/[^\s]*)?$/iu,email:/^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i,hostname:/^(?=.{1,253}\.?$)[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[-0-9a-z]{0,61}[0-9a-z])?)*\.?$/i,ipv4:/^(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)$/,ipv6:/^((([0-9a-f]{1,4}:){7}([0-9a-f]{1,4}|:))|(([0-9a-f]{1,4}:){6}(:[0-9a-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){5}(((:[0-9a-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){4}(((:[0-9a-f]{1,4}){1,3})|((:[0-9a-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){3}(((:[0-9a-f]{1,4}){1,4})|((:[0-9a-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){2}(((:[0-9a-f]{1,4}){1,5})|((:[0-9a-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){1}(((:[0-9a-f]{1,4}){1,6})|((:[0-9a-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9a-f]{1,4}){1,7})|((:[0-9a-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))$/i,regex:rte,uuid:/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i,"json-pointer":/^(?:\/(?:[^~/]|~0|~1)*)*$/,"json-pointer-uri-fragment":/^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i,"relative-json-pointer":/^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/,byte:Jee,int32:{type:"number",validate:Qee},int64:{type:"number",validate:ete},float:{type:"number",validate:GZ},double:{type:"number",validate:GZ},password:!0,binary:!0};Kr.fastFormats={...Kr.fullFormats,date:Wr(/^\d\d\d\d-[0-1]\d-[0-3]\d$/,Nk),time:Wr(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,Tk),"date-time":Wr(/^\d\d\d\d-[0-1]\d-[0-3]\dt(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,JZ),"iso-time":Wr(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,KZ),"iso-date-time":Wr(/^\d\d\d\d-[0-1]\d-[0-3]\d[t\s](?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,YZ),uri:/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/)?[^\s]*$/i,"uri-reference":/^(?:(?:[a-z][a-z0-9+\-.]*:)?\/?\/)?(?:[^\\\s#][^\s#]*)?(?:#[^\\\s]*)?$/i,email:/^[a-z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*$/i};Kr.formatNames=Object.keys(Kr.fullFormats);function Hee(e){return e%4===0&&(e%100!==0||e%400===0)}i(Hee,"isLeapYear");var Bee=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,Vee=[0,31,28,31,30,31,30,31,31,30,31,30,31];function WZ(e){let t=Bee.exec(e);if(!t)return!1;let r=+t[1],n=+t[2],o=+t[3];return n>=1&&n<=12&&o>=1&&o<=(n===2&&Hee(r)?29:Vee[n])}i(WZ,"date");function Nk(e,t){if(e&&t)return e>t?1:e<t?-1:0}i(Nk,"compareDate");var kk=/^(\d\d):(\d\d):(\d\d(?:\.\d+)?)(z|([+-])(\d\d)(?::?(\d\d))?)?$/i;function $k(e){return i(function(r){let n=kk.exec(r);if(!n)return!1;let o=+n[1],s=+n[2],a=+n[3],c=n[4],l=n[5]==="-"?-1:1,u=+(n[6]||0),d=+(n[7]||0);if(u>23||d>59||e&&!c)return!1;if(o<=23&&s<=59&&a<60)return!0;let p=s-d*l,h=o-u*l-(p<0?1:0);return(h===23||h===-1)&&(p===59||p===-1)&&a<61},"time")}i($k,"getTime");function Tk(e,t){if(!(e&&t))return;let r=new Date("2020-01-01T"+e).valueOf(),n=new Date("2020-01-01T"+t).valueOf();if(r&&n)return r-n}i(Tk,"compareTime");function KZ(e,t){if(!(e&&t))return;let r=kk.exec(e),n=kk.exec(t);if(r&&n)return e=r[1]+r[2]+r[3],t=n[1]+n[2]+n[3],e>t?1:e<t?-1:0}i(KZ,"compareIsoTime");var Ek=/t|\s/i;function BZ(e){let t=$k(e);return i(function(n){let o=n.split(Ek);return o.length===2&&WZ(o[0])&&t(o[1])},"date_time")}i(BZ,"getDateTime");function JZ(e,t){if(!(e&&t))return;let r=new Date(e).valueOf(),n=new Date(t).valueOf();if(r&&n)return r-n}i(JZ,"compareDateTime");function YZ(e,t){if(!(e&&t))return;let[r,n]=e.split(Ek),[o,s]=t.split(Ek),a=Nk(r,o);if(a!==void 0)return a||Tk(n,s)}i(YZ,"compareIsoDateTime");var Gee=/\/|:/,Wee=/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)(?:\?(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i;function Kee(e){return Gee.test(e)&&Wee.test(e)}i(Kee,"uri");var VZ=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/gm;function Jee(e){return VZ.lastIndex=0,VZ.test(e)}i(Jee,"byte");var Yee=-(2**31),Xee=2**31-1;function Qee(e){return Number.isInteger(e)&&e<=Xee&&e>=Yee}i(Qee,"validateInt32");function ete(e){return Number.isInteger(e)}i(ete,"validateInt64");function GZ(){return!0}i(GZ,"validateNumber");var tte=/[^\\]\\Z/;function rte(e){if(tte.test(e))return!1;try{return new RegExp(e),!0}catch{return!1}}i(rte,"regex")});var QZ=D($a=>{"use strict";Object.defineProperty($a,"__esModule",{value:!0});$a.formatLimitDefinition=void 0;var nte=Sk(),Nr=ne(),co=Nr.operators,rh={formatMaximum:{okStr:"<=",ok:co.LTE,fail:co.GT},formatMinimum:{okStr:">=",ok:co.GTE,fail:co.LT},formatExclusiveMaximum:{okStr:"<",ok:co.LT,fail:co.GTE},formatExclusiveMinimum:{okStr:">",ok:co.GT,fail:co.LTE}},ote={message:({keyword:e,schemaCode:t})=>(0,Nr.str)`should be ${rh[e].okStr} ${t}`,params:({keyword:e,schemaCode:t})=>(0,Nr._)`{comparison: ${rh[e].okStr}, limit: ${t}}`};$a.formatLimitDefinition={keyword:Object.keys(rh),type:"string",schemaType:"string",$data:!0,error:ote,code(e){let{gen:t,data:r,schemaCode:n,keyword:o,it:s}=e,{opts:a,self:c}=s;if(!a.validateFormats)return;let l=new nte.KeywordCxt(s,c.RULES.all.format.definition,"format");l.$data?u():d();function u(){let h=t.scopeValue("formats",{ref:c.formats,code:a.code.formats}),m=t.const("fmt",(0,Nr._)`${h}[${l.schemaCode}]`);e.fail$data((0,Nr.or)((0,Nr._)`typeof ${m} != "object"`,(0,Nr._)`${m} instanceof RegExp`,(0,Nr._)`typeof ${m}.compare != "function"`,p(m)))}i(u,"validate$DataFormat");function d(){let h=l.schema,m=c.formats[h];if(!m||m===!0)return;if(typeof m!="object"||m instanceof RegExp||typeof m.compare!="function")throw new Error(`"${o}": format "${h}" does not define "compare" function`);let g=t.scopeValue("formats",{key:h,ref:m,code:a.code.formats?(0,Nr._)`${a.code.formats}${(0,Nr.getProperty)(h)}`:void 0});e.fail$data(p(g))}i(d,"validateFormat");function p(h){return(0,Nr._)`${h}.compare(${r}, ${n}) ${rh[o].fail} 0`}i(p,"compareCode")},dependencies:["format"]};var ste=i(e=>(e.addKeyword($a.formatLimitDefinition),e),"formatLimitPlugin");$a.default=ste});var nL=D((du,rL)=>{"use strict";Object.defineProperty(du,"__esModule",{value:!0});var Ea=XZ(),ite=QZ(),zk=ne(),eL=new zk.Name("fullFormats"),ate=new zk.Name("fastFormats"),Ck=i((e,t={keywords:!0})=>{if(Array.isArray(t))return tL(e,t,Ea.fullFormats,eL),e;let[r,n]=t.mode==="fast"?[Ea.fastFormats,ate]:[Ea.fullFormats,eL],o=t.formats||Ea.formatNames;return tL(e,o,r,n),t.keywords&&(0,ite.default)(e),e},"formatsPlugin");Ck.get=(e,t="full")=>{let n=(t==="fast"?Ea.fastFormats:Ea.fullFormats)[e];if(!n)throw new Error(`Unknown format "${e}"`);return n};function tL(e,t,r,n){var o,s;(o=(s=e.opts.code).formats)!==null&&o!==void 0||(s.formats=(0,zk._)`require("ajv-formats/dist/formats").${n}`);for(let a of t)e.addFormat(a,r[a])}i(tL,"addFormats");rL.exports=du=Ck;Object.defineProperty(du,"__esModule",{value:!0});du.default=Ck});import{readFileSync as xte}from"fs";import{resolve as _te,dirname as vte}from"path";import{fileURLToPath as wte}from"url";import{resolve as BU}from"path";import{existsSync as CL}from"fs";import{resolve as IL}from"path";function ph(e){return!(!e||typeof e!="string"||!/^(?![@._])[a-z0-9@._-]{1,214}$/.test(e)||e.startsWith(".")||e.startsWith("_")||["node_modules","favicon.ico"].includes(e.toLowerCase()))}i(ph,"isValidProjectName");function fh(e){return CL(IL(e))}i(fh,"projectExists");function mh(e){return e?e.startsWith(".")?"Project name cannot start with a dot (.)":e.startsWith("_")?"Project name cannot start with an underscore (_)":e!==e.toLowerCase()?"Project name must be lowercase":e.includes(" ")?"Project name cannot contain spaces":e.length>214?"Project name must be less than 214 characters":["node_modules","favicon.ico"].includes(e.toLowerCase())?`Project name "${e}" is reserved`:"Project name contains invalid characters. Use only lowercase letters, numbers, hyphens, and underscores":"Project name is required"}i(mh,"getValidationError");import{mkdirSync as UU}from"fs";import{resolve as qU}from"path";import{resolve as Pt,dirname as PL}from"path";function mu(e){if(e==null)return[];if(!Array.isArray(e))throw new Error('Config "deploy" must be an array');return e.map((t,r)=>{if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`Config "deploy[${r}]" must be an object`);if(typeof t.service!="string"||!t.service)throw new Error(`Config "deploy[${r}].service" must be a non-empty string`);let n={service:t.service};if(t.siteId!=null){if(typeof t.siteId!="string")throw new Error(`Config "deploy[${r}].siteId" must be a string`);n.siteId=t.siteId}if(t.url!=null){if(typeof t.url!="string")throw new Error(`Config "deploy[${r}].url" must be a string`);n.url=t.url}return n})}i(mu,"normalizeDeploy");function hh(e,t){if(!e)throw new Error("Config object is required");if(!e.name||typeof e.name!="string")throw new Error('Config must have a "name" field (string)');if(!e.version||typeof e.version!="string")throw new Error('Config must have a "version" field (string)');if(!e.sceneGraph||typeof e.sceneGraph!="string")throw new Error('Config must have a "sceneGraph" field (string path)');if(!e.assets||typeof e.assets!="string")throw new Error('Config must have an "assets" field (string path)');let r=t?PL(t):process.cwd(),n=e.framework??"vue",o={name:e.name,version:e.version,port:e.port??4e3,_studioUrl:e._studioUrl,sceneGraph:e.sceneGraph?Pt(r,e.sceneGraph):Pt(r,"./src/sceneGraph"),assets:e.assets?Pt(r,e.assets):Pt(r,"./src/assets"),stores:e.stores?Pt(r,e.stores):Pt(r,"./src/stores"),components:RL(e.components,r),libraries:OL(e.libraries??e.metadata?.libraries??[],r),metadata:{platform:e.metadata?.platform??n},socket:e.socket??{cors:{},options:{},auth:null},projectRoot:r,framework:n,outdir:Pt(r,e.dist||"dist"),esbuild:e.esbuild??{},deploy:mu(e.deploy)};if(typeof o.port!="number"||o.port<1||o.port>65535)throw new Error('Config "port" must be a number between 1 and 65535');if(typeof o.metadata.platform!="string")throw new Error('Config "metadata.platform" must be a string');if(!Array.isArray(o.libraries))throw new Error('Config "libraries" must be an array');return o}i(hh,"defineConfig");function RL(e,t){let r=Pt(t,"./src/components");return e?typeof e=="string"?Pt(t,e):Array.isArray(e)?e.map(n=>{if(typeof n=="string")return Pt(t,n);if(n&&typeof n=="object"&&n.name&&n.from){let o=n.from.startsWith(".")?Pt(t,n.from):n.from,s=n.manifest?n.manifest.startsWith(".")?Pt(t,n.manifest):n.manifest:null;return{...n,from:o,manifest:s}}return n}):r:r}i(RL,"resolveComponents");function OL(e,t){return Array.isArray(e)?e.map(r=>{if(typeof r=="string")return r;if(r&&typeof r=="object"&&r.path){let n=r.path.startsWith(".")?Pt(t,r.path):r.path;return{...r,path:n}}return r}):[]}i(OL,"resolveLibraries");import{resolve as Bk}from"path";import{pathToFileURL as AL}from"url";async function uo(e){let t;e?t=Bk(process.cwd(),e):t=Bk(process.cwd(),"jucie.config.js");try{let o=(await import(AL(t).href)).default;if(!o)throw new Error("Config file must export a default object");return hh(o,t)}catch(r){throw r.code==="ERR_MODULE_NOT_FOUND"||r.code==="ENOENT"?new Error(`Config file not found: ${t}`):r.message.includes("Config must")||r.message.includes('Config "')?r:new Error(`Failed to load config: ${r.message}`)}}i(uo,"loadConfig");function hu(e){let{name:t,version:r,port:n,framework:o,sceneGraph:s,assets:a,components:c,stores:l,libraries:u,metadata:d,socket:p,dist:h,deploy:m}=e,g={name:t,version:r||"0.0.1"};return n!=null&&(g.port=n),g.framework=o||"vue",g.sceneGraph=s||"./sceneGraph",g.assets=a||"./assets",c!=null&&(g.components=c),l!=null&&(g.stores=l),u!=null&&(g.libraries=u),d!=null&&(g.metadata=d),p!=null&&(g.socket=p),h!=null&&(g.dist=h),g.deploy=Array.isArray(m)?m:[],`export default ${JSON.stringify(g,null,2)}
181
- `}i(hu,"serializeConfig");qy();var VC=["app","temp","components"];function yd(){let e=VC.map(t=>JSON.stringify({[t]:gd})).join(`
182
- `);return[{path:"nodes/nodes.pack",content:`${JSON.stringify({cid:gd,data:_o})}
183
- `},{path:"nodes/index-main.jsonl",content:`${e}
184
- `},{path:"animations/animations.pack",content:""},{path:"animations/index-main.jsonl",content:""},{path:"tokens/tokens.pack",content:""},{path:"tokens/index-main.jsonl",content:""}]}i(yd,"getSceneGraphSeed");function zU(e){return e.toLowerCase().replace(/[^a-z0-9._-]/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"")}i(zU,"slugify");function CU({name:e,cliVersion:t,version:r="0.0.1"}){return`${JSON.stringify({name:e,version:r,type:"module",scripts:{design:"jucie design",dev:"jucie dev",preview:"jucie dev",build:"jucie build"},devDependencies:{"@jucie.io/cli":`^${t}`}},null,2)}
185
- `}i(CU,"createPackageJson");function IU(){return`node_modules/
229
+ deps: ${r}}`};var Zse={keyword:"dependencies",type:"object",schemaType:"object",error:sn.error,code(e){let[t,r]=Lse(e);NU(e,t),TU(e,r)}};function Lse({schema:e}){let t={},r={};for(let n in e){if(n==="__proto__")continue;let o=Array.isArray(e[n])?t:r;o[n]=e[n]}return[t,r]}i(Lse,"splitDependencies");function NU(e,t=e.schema){let{gen:r,data:n,it:o}=e;if(Object.keys(t).length===0)return;let s=r.let("missing");for(let a in t){let c=t[a];if(c.length===0)continue;let l=(0,Dd.propertyInData)(r,n,a,o.opts.ownProperties);e.setParams({property:a,depsCount:c.length,deps:c.join(", ")}),o.allErrors?r.if(l,()=>{for(let u of c)(0,Dd.checkReportMissingProp)(e,u)}):(r.if((0,TE._)`${l} && (${(0,Dd.checkMissingProp)(e,c,s)})`),(0,Dd.reportMissingProp)(e,s),r.else())}}i(NU,"validatePropertyDeps");sn.validatePropertyDeps=NU;function TU(e,t=e.schema){let{gen:r,data:n,keyword:o,it:s}=e,a=r.name("valid");for(let c in t)(0,Mse.alwaysValidSchema)(s,t[c])||(r.if((0,Dd.propertyInData)(r,n,c,s.opts.ownProperties),()=>{let l=e.subschema({keyword:o,schemaProp:c},a);e.mergeValidEvaluated(l,a)},()=>r.var(a,!0)),e.ok(a))}i(TU,"validateSchemaDeps");sn.validateSchemaDeps=TU;sn.default=Zse});var IU=F(zE=>{"use strict";Object.defineProperty(zE,"__esModule",{value:!0});var CU=se(),Fse=me(),Use={message:"property name must be valid",params:({params:e})=>(0,CU._)`{propertyName: ${e.propertyName}}`},qse={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:Use,code(e){let{gen:t,schema:r,data:n,it:o}=e;if((0,Fse.alwaysValidSchema)(o,r))return;let s=t.name("valid");t.forIn("key",n,a=>{e.setParams({propertyName:a}),e.subschema({keyword:"propertyNames",data:a,dataTypes:["string"],propertyName:a,compositeRule:!0},s),t.if((0,CU.not)(s),()=>{e.error(!0),o.allErrors||t.break()})}),e.ok(s)}};zE.default=qse});var IE=F(CE=>{"use strict";Object.defineProperty(CE,"__esModule",{value:!0});var Yg=mr(),Rr=se(),Bse=Vn(),Xg=me(),Hse={message:"must NOT have additional properties",params:({params:e})=>(0,Rr._)`{additionalProperty: ${e.additionalProperty}}`},Vse={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:!0,trackErrors:!0,error:Hse,code(e){let{gen:t,schema:r,parentSchema:n,data:o,errsCount:s,it:a}=e;if(!s)throw new Error("ajv implementation error");let{allErrors:c,opts:l}=a;if(a.props=!0,l.removeAdditional!=="all"&&(0,Xg.alwaysValidSchema)(a,r))return;let u=(0,Yg.allSchemaProperties)(n.properties),d=(0,Yg.allSchemaProperties)(n.patternProperties);p(),e.ok((0,Rr._)`${s} === ${Bse.default.errors}`);function p(){t.forIn("key",o,x=>{!u.length&&!d.length?g(x):t.if(m(x),()=>g(x))})}i(p,"checkAdditionalProperties");function m(x){let v;if(u.length>8){let b=(0,Xg.schemaRefOrVal)(a,n.properties,"properties");v=(0,Yg.isOwnProperty)(t,b,x)}else u.length?v=(0,Rr.or)(...u.map(b=>(0,Rr._)`${x} === ${b}`)):v=Rr.nil;return d.length&&(v=(0,Rr.or)(v,...d.map(b=>(0,Rr._)`${(0,Yg.usePattern)(e,b)}.test(${x})`))),(0,Rr.not)(v)}i(m,"isAdditional");function h(x){t.code((0,Rr._)`delete ${o}[${x}]`)}i(h,"deleteAdditional");function g(x){if(l.removeAdditional==="all"||l.removeAdditional&&r===!1){h(x);return}if(r===!1){e.setParams({additionalProperty:x}),e.error(),c||t.break();return}if(typeof r=="object"&&!(0,Xg.alwaysValidSchema)(a,r)){let v=t.name("valid");l.removeAdditional==="failing"?(_(x,v,!1),t.if((0,Rr.not)(v),()=>{e.reset(),h(x)})):(_(x,v),c||t.if((0,Rr.not)(v),()=>t.break()))}}i(g,"additionalPropertyCode");function _(x,v,b){let w={keyword:"additionalProperties",dataProp:x,dataPropType:Xg.Type.Str};b===!1&&Object.assign(w,{compositeRule:!0,createErrors:!1,allErrors:!1}),e.subschema(w,v)}i(_,"applyAdditionalSchema")}};CE.default=Vse});var AU=F(OE=>{"use strict";Object.defineProperty(OE,"__esModule",{value:!0});var Gse=bd(),PU=mr(),PE=me(),OU=IE(),Wse={keyword:"properties",type:"object",schemaType:"object",code(e){let{gen:t,schema:r,parentSchema:n,data:o,it:s}=e;s.opts.removeAdditional==="all"&&n.additionalProperties===void 0&&OU.default.code(new Gse.KeywordCxt(s,OU.default,"additionalProperties"));let a=(0,PU.allSchemaProperties)(r);for(let p of a)s.definedProperties.add(p);s.opts.unevaluated&&a.length&&s.props!==!0&&(s.props=PE.mergeEvaluated.props(t,(0,PE.toHash)(a),s.props));let c=a.filter(p=>!(0,PE.alwaysValidSchema)(s,r[p]));if(c.length===0)return;let l=t.name("valid");for(let p of c)u(p)?d(p):(t.if((0,PU.propertyInData)(t,o,p,s.opts.ownProperties)),d(p),s.allErrors||t.else().var(l,!0),t.endIf()),e.it.definedProperties.add(p),e.ok(l);function u(p){return s.opts.useDefaults&&!s.compositeRule&&r[p].default!==void 0}i(u,"hasDefault");function d(p){e.subschema({keyword:"properties",schemaProp:p,dataProp:p},l)}i(d,"applyPropertySchema")}};OE.default=Wse});var MU=F(AE=>{"use strict";Object.defineProperty(AE,"__esModule",{value:!0});var RU=mr(),Qg=se(),jU=me(),DU=me(),Jse={keyword:"patternProperties",type:"object",schemaType:"object",code(e){let{gen:t,schema:r,data:n,parentSchema:o,it:s}=e,{opts:a}=s,c=(0,RU.allSchemaProperties)(r),l=c.filter(_=>(0,jU.alwaysValidSchema)(s,r[_]));if(c.length===0||l.length===c.length&&(!s.opts.unevaluated||s.props===!0))return;let u=a.strictSchema&&!a.allowMatchingProperties&&o.properties,d=t.name("valid");s.props!==!0&&!(s.props instanceof Qg.Name)&&(s.props=(0,DU.evaluatedPropsToName)(t,s.props));let{props:p}=s;m();function m(){for(let _ of c)u&&h(_),s.allErrors?g(_):(t.var(d,!0),g(_),t.if(d))}i(m,"validatePatternProperties");function h(_){for(let x in u)new RegExp(_).test(x)&&(0,jU.checkStrictMode)(s,`property ${x} matches pattern ${_} (use allowMatchingProperties)`)}i(h,"checkMatchingProperties");function g(_){t.forIn("key",n,x=>{t.if((0,Qg._)`${(0,RU.usePattern)(e,_)}.test(${x})`,()=>{let v=l.includes(_);v||e.subschema({keyword:"patternProperties",schemaProp:_,dataProp:x,dataPropType:DU.Type.Str},d),s.opts.unevaluated&&p!==!0?t.assign((0,Qg._)`${p}[${x}]`,!0):!v&&!s.allErrors&&t.if((0,Qg.not)(d),()=>t.break())})})}i(g,"validateProperties")}};AE.default=Jse});var ZU=F(RE=>{"use strict";Object.defineProperty(RE,"__esModule",{value:!0});var Kse=me(),Yse={keyword:"not",schemaType:["object","boolean"],trackErrors:!0,code(e){let{gen:t,schema:r,it:n}=e;if((0,Kse.alwaysValidSchema)(n,r)){e.fail();return}let o=t.name("valid");e.subschema({keyword:"not",compositeRule:!0,createErrors:!1,allErrors:!1},o),e.failResult(o,()=>e.reset(),()=>e.error())},error:{message:"must NOT be valid"}};RE.default=Yse});var LU=F(jE=>{"use strict";Object.defineProperty(jE,"__esModule",{value:!0});var Xse=mr(),Qse={keyword:"anyOf",schemaType:"array",trackErrors:!0,code:Xse.validateUnion,error:{message:"must match a schema in anyOf"}};jE.default=Qse});var FU=F(DE=>{"use strict";Object.defineProperty(DE,"__esModule",{value:!0});var ey=se(),eie=me(),tie={message:"must match exactly one schema in oneOf",params:({params:e})=>(0,ey._)`{passingSchemas: ${e.passing}}`},rie={keyword:"oneOf",schemaType:"array",trackErrors:!0,error:tie,code(e){let{gen:t,schema:r,parentSchema:n,it:o}=e;if(!Array.isArray(r))throw new Error("ajv implementation error");if(o.opts.discriminator&&n.discriminator)return;let s=r,a=t.let("valid",!1),c=t.let("passing",null),l=t.name("_valid");e.setParams({passing:c}),t.block(u),e.result(a,()=>e.reset(),()=>e.error(!0));function u(){s.forEach((d,p)=>{let m;(0,eie.alwaysValidSchema)(o,d)?t.var(l,!0):m=e.subschema({keyword:"oneOf",schemaProp:p,compositeRule:!0},l),p>0&&t.if((0,ey._)`${l} && ${a}`).assign(a,!1).assign(c,(0,ey._)`[${c}, ${p}]`).else(),t.if(l,()=>{t.assign(a,!0),t.assign(c,p),m&&e.mergeEvaluated(m,ey.Name)})})}i(u,"validateOneOf")}};DE.default=rie});var UU=F(ME=>{"use strict";Object.defineProperty(ME,"__esModule",{value:!0});var nie=me(),oie={keyword:"allOf",schemaType:"array",code(e){let{gen:t,schema:r,it:n}=e;if(!Array.isArray(r))throw new Error("ajv implementation error");let o=t.name("valid");r.forEach((s,a)=>{if((0,nie.alwaysValidSchema)(n,s))return;let c=e.subschema({keyword:"allOf",schemaProp:a},o);e.ok(o),e.mergeEvaluated(c)})}};ME.default=oie});var HU=F(ZE=>{"use strict";Object.defineProperty(ZE,"__esModule",{value:!0});var ty=se(),BU=me(),sie={message:({params:e})=>(0,ty.str)`must match "${e.ifClause}" schema`,params:({params:e})=>(0,ty._)`{failingKeyword: ${e.ifClause}}`},iie={keyword:"if",schemaType:["object","boolean"],trackErrors:!0,error:sie,code(e){let{gen:t,parentSchema:r,it:n}=e;r.then===void 0&&r.else===void 0&&(0,BU.checkStrictMode)(n,'"if" without "then" and "else" is ignored');let o=qU(n,"then"),s=qU(n,"else");if(!o&&!s)return;let a=t.let("valid",!0),c=t.name("_valid");if(l(),e.reset(),o&&s){let d=t.let("ifClause");e.setParams({ifClause:d}),t.if(c,u("then",d),u("else",d))}else o?t.if(c,u("then")):t.if((0,ty.not)(c),u("else"));e.pass(a,()=>e.error(!0));function l(){let d=e.subschema({keyword:"if",compositeRule:!0,createErrors:!1,allErrors:!1},c);e.mergeEvaluated(d)}i(l,"validateIf");function u(d,p){return()=>{let m=e.subschema({keyword:d},c);t.assign(a,c),e.mergeValidEvaluated(m,a),p?t.assign(p,(0,ty._)`${d}`):e.setParams({ifClause:d})}}i(u,"validateClause")}};function qU(e,t){let r=e.schema[t];return r!==void 0&&!(0,BU.alwaysValidSchema)(e,r)}i(qU,"hasSchema");ZE.default=iie});var VU=F(LE=>{"use strict";Object.defineProperty(LE,"__esModule",{value:!0});var aie=me(),cie={keyword:["then","else"],schemaType:["object","boolean"],code({keyword:e,parentSchema:t,it:r}){t.if===void 0&&(0,aie.checkStrictMode)(r,`"${e}" without "if" is ignored`)}};LE.default=cie});var GU=F(FE=>{"use strict";Object.defineProperty(FE,"__esModule",{value:!0});var lie=SE(),uie=SU(),die=kE(),pie=$U(),fie=EU(),mie=zU(),hie=IU(),gie=IE(),yie=AU(),xie=MU(),_ie=ZU(),vie=LU(),wie=FU(),bie=UU(),Sie=HU(),kie=VU();function $ie(e=!1){let t=[_ie.default,vie.default,wie.default,bie.default,Sie.default,kie.default,hie.default,gie.default,mie.default,yie.default,xie.default];return e?t.push(uie.default,pie.default):t.push(lie.default,die.default),t.push(fie.default),t}i($ie,"getApplicator");FE.default=$ie});var WU=F(UE=>{"use strict";Object.defineProperty(UE,"__esModule",{value:!0});var He=se(),Eie={message:({schemaCode:e})=>(0,He.str)`must match format "${e}"`,params:({schemaCode:e})=>(0,He._)`{format: ${e}}`},Nie={keyword:"format",type:["number","string"],schemaType:"string",$data:!0,error:Eie,code(e,t){let{gen:r,data:n,$data:o,schema:s,schemaCode:a,it:c}=e,{opts:l,errSchemaPath:u,schemaEnv:d,self:p}=c;if(!l.validateFormats)return;o?m():h();function m(){let g=r.scopeValue("formats",{ref:p.formats,code:l.code.formats}),_=r.const("fDef",(0,He._)`${g}[${a}]`),x=r.let("fType"),v=r.let("format");r.if((0,He._)`typeof ${_} == "object" && !(${_} instanceof RegExp)`,()=>r.assign(x,(0,He._)`${_}.type || "string"`).assign(v,(0,He._)`${_}.validate`),()=>r.assign(x,(0,He._)`"string"`).assign(v,_)),e.fail$data((0,He.or)(b(),w()));function b(){return l.strictSchema===!1?He.nil:(0,He._)`${a} && !${v}`}i(b,"unknownFmt");function w(){let S=d.$async?(0,He._)`(${_}.async ? await ${v}(${n}) : ${v}(${n}))`:(0,He._)`${v}(${n})`,E=(0,He._)`(typeof ${v} == "function" ? ${S} : ${v}.test(${n}))`;return(0,He._)`${v} && ${v} !== true && ${x} === ${t} && !${E}`}i(w,"invalidFmt")}i(m,"validate$DataFormat");function h(){let g=p.formats[s];if(!g){b();return}if(g===!0)return;let[_,x,v]=w(g);_===t&&e.pass(S());function b(){if(l.strictSchema===!1){p.logger.warn(E());return}throw new Error(E());function E(){return`unknown format "${s}" ignored in schema at path "${u}"`}}i(b,"unknownFormat");function w(E){let I=E instanceof RegExp?(0,He.regexpCode)(E):l.code.formats?(0,He._)`${l.code.formats}${(0,He.getProperty)(s)}`:void 0,z=r.scopeValue("formats",{key:s,ref:E,code:I});return typeof E=="object"&&!(E instanceof RegExp)?[E.type||"string",E.validate,(0,He._)`${z}.validate`]:["string",E,z]}i(w,"getFormat");function S(){if(typeof g=="object"&&!(g instanceof RegExp)&&g.async){if(!d.$async)throw new Error("async format in sync schema");return(0,He._)`await ${v}(${n})`}return typeof x=="function"?(0,He._)`${v}(${n})`:(0,He._)`${v}.test(${n})`}i(S,"validCondition")}i(h,"validateFormat")}};UE.default=Nie});var JU=F(qE=>{"use strict";Object.defineProperty(qE,"__esModule",{value:!0});var Tie=WU(),zie=[Tie.default];qE.default=zie});var KU=F(mc=>{"use strict";Object.defineProperty(mc,"__esModule",{value:!0});mc.contentVocabulary=mc.metadataVocabulary=void 0;mc.metadataVocabulary=["title","description","default","deprecated","readOnly","writeOnly","examples"];mc.contentVocabulary=["contentMediaType","contentEncoding","contentSchema"]});var XU=F(BE=>{"use strict";Object.defineProperty(BE,"__esModule",{value:!0});var Cie=sU(),Iie=_U(),Pie=GU(),Oie=JU(),YU=KU(),Aie=[Cie.default,Iie.default,(0,Pie.default)(),Oie.default,YU.metadataVocabulary,YU.contentVocabulary];BE.default=Aie});var e9=F(ry=>{"use strict";Object.defineProperty(ry,"__esModule",{value:!0});ry.DiscrError=void 0;var QU;(function(e){e.Tag="tag",e.Mapping="mapping"})(QU||(ry.DiscrError=QU={}))});var r9=F(VE=>{"use strict";Object.defineProperty(VE,"__esModule",{value:!0});var hc=se(),HE=e9(),t9=Dg(),Rie=Sd(),jie=me(),Die={message:({params:{discrError:e,tagName:t}})=>e===HE.DiscrError.Tag?`tag "${t}" must be string`:`value of tag "${t}" must be in oneOf`,params:({params:{discrError:e,tag:t,tagName:r}})=>(0,hc._)`{error: ${e}, tag: ${r}, tagValue: ${t}}`},Mie={keyword:"discriminator",type:"object",schemaType:"object",error:Die,code(e){let{gen:t,data:r,schema:n,parentSchema:o,it:s}=e,{oneOf:a}=o;if(!s.opts.discriminator)throw new Error("discriminator: requires discriminator option");let c=n.propertyName;if(typeof c!="string")throw new Error("discriminator: requires propertyName");if(n.mapping)throw new Error("discriminator: mapping is not supported");if(!a)throw new Error("discriminator: requires oneOf keyword");let l=t.let("valid",!1),u=t.const("tag",(0,hc._)`${r}${(0,hc.getProperty)(c)}`);t.if((0,hc._)`typeof ${u} == "string"`,()=>d(),()=>e.error(!1,{discrError:HE.DiscrError.Tag,tag:u,tagName:c})),e.ok(l);function d(){let h=m();t.if(!1);for(let g in h)t.elseIf((0,hc._)`${u} === ${g}`),t.assign(l,p(h[g]));t.else(),e.error(!1,{discrError:HE.DiscrError.Mapping,tag:u,tagName:c}),t.endIf()}i(d,"validateMapping");function p(h){let g=t.name("valid"),_=e.subschema({keyword:"oneOf",schemaProp:h},g);return e.mergeEvaluated(_,hc.Name),g}i(p,"applyTagSchema");function m(){var h;let g={},_=v(o),x=!0;for(let S=0;S<a.length;S++){let E=a[S];if(E?.$ref&&!(0,jie.schemaHasRulesButRef)(E,s.self.RULES)){let z=E.$ref;if(E=t9.resolveRef.call(s.self,s.schemaEnv.root,s.baseId,z),E instanceof t9.SchemaEnv&&(E=E.schema),E===void 0)throw new Rie.default(s.opts.uriResolver,s.baseId,z)}let I=(h=E?.properties)===null||h===void 0?void 0:h[c];if(typeof I!="object")throw new Error(`discriminator: oneOf subschemas (or referenced schemas) must have "properties/${c}"`);x=x&&(_||v(E)),b(I,S)}if(!x)throw new Error(`discriminator: "${c}" must be required`);return g;function v({required:S}){return Array.isArray(S)&&S.includes(c)}function b(S,E){if(S.const)w(S.const,E);else if(S.enum)for(let I of S.enum)w(I,E);else throw new Error(`discriminator: "properties/${c}" must have "const" or "enum"`)}function w(S,E){if(typeof S!="string"||S in g)throw new Error(`discriminator: "${c}" values must be unique strings`);g[S]=E}}i(m,"getMapping")}};VE.default=Mie});var n9=F((PBe,Zie)=>{Zie.exports={$schema:"http://json-schema.org/draft-07/schema#",$id:"http://json-schema.org/draft-07/schema#",title:"Core schema meta-schema",definitions:{schemaArray:{type:"array",minItems:1,items:{$ref:"#"}},nonNegativeInteger:{type:"integer",minimum:0},nonNegativeIntegerDefault0:{allOf:[{$ref:"#/definitions/nonNegativeInteger"},{default:0}]},simpleTypes:{enum:["array","boolean","integer","null","number","object","string"]},stringArray:{type:"array",items:{type:"string"},uniqueItems:!0,default:[]}},type:["object","boolean"],properties:{$id:{type:"string",format:"uri-reference"},$schema:{type:"string",format:"uri"},$ref:{type:"string",format:"uri-reference"},$comment:{type:"string"},title:{type:"string"},description:{type:"string"},default:!0,readOnly:{type:"boolean",default:!1},examples:{type:"array",items:!0},multipleOf:{type:"number",exclusiveMinimum:0},maximum:{type:"number"},exclusiveMaximum:{type:"number"},minimum:{type:"number"},exclusiveMinimum:{type:"number"},maxLength:{$ref:"#/definitions/nonNegativeInteger"},minLength:{$ref:"#/definitions/nonNegativeIntegerDefault0"},pattern:{type:"string",format:"regex"},additionalItems:{$ref:"#"},items:{anyOf:[{$ref:"#"},{$ref:"#/definitions/schemaArray"}],default:!0},maxItems:{$ref:"#/definitions/nonNegativeInteger"},minItems:{$ref:"#/definitions/nonNegativeIntegerDefault0"},uniqueItems:{type:"boolean",default:!1},contains:{$ref:"#"},maxProperties:{$ref:"#/definitions/nonNegativeInteger"},minProperties:{$ref:"#/definitions/nonNegativeIntegerDefault0"},required:{$ref:"#/definitions/stringArray"},additionalProperties:{$ref:"#"},definitions:{type:"object",additionalProperties:{$ref:"#"},default:{}},properties:{type:"object",additionalProperties:{$ref:"#"},default:{}},patternProperties:{type:"object",additionalProperties:{$ref:"#"},propertyNames:{format:"regex"},default:{}},dependencies:{type:"object",additionalProperties:{anyOf:[{$ref:"#"},{$ref:"#/definitions/stringArray"}]}},propertyNames:{$ref:"#"},const:!0,enum:{type:"array",items:!0,minItems:1,uniqueItems:!0},type:{anyOf:[{$ref:"#/definitions/simpleTypes"},{type:"array",items:{$ref:"#/definitions/simpleTypes"},minItems:1,uniqueItems:!0}]},format:{type:"string"},contentMediaType:{type:"string"},contentEncoding:{type:"string"},if:{$ref:"#"},then:{$ref:"#"},else:{$ref:"#"},allOf:{$ref:"#/definitions/schemaArray"},anyOf:{$ref:"#/definitions/schemaArray"},oneOf:{$ref:"#/definitions/schemaArray"},not:{$ref:"#"}},default:!0}});var JE=F((je,GE)=>{"use strict";Object.defineProperty(je,"__esModule",{value:!0});je.MissingRefError=je.ValidationError=je.CodeGen=je.Name=je.nil=je.stringify=je.str=je._=je.KeywordCxt=je.Ajv=void 0;var Lie=Q4(),Fie=XU(),Uie=r9(),o9=n9(),qie=["/properties"],ny="http://json-schema.org/draft-07/schema",WE=class WE extends Lie.default{_addVocabularies(){super._addVocabularies(),Fie.default.forEach(t=>this.addVocabulary(t)),this.opts.discriminator&&this.addKeyword(Uie.default)}_addDefaultMetaSchema(){if(super._addDefaultMetaSchema(),!this.opts.meta)return;let t=this.opts.$data?this.$dataMetaSchema(o9,qie):o9;this.addMetaSchema(t,ny,!1),this.refs["http://json-schema.org/schema"]=ny}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(ny)?ny:void 0)}};i(WE,"Ajv");var gc=WE;je.Ajv=gc;GE.exports=je=gc;GE.exports.Ajv=gc;Object.defineProperty(je,"__esModule",{value:!0});je.default=gc;var Bie=bd();Object.defineProperty(je,"KeywordCxt",{enumerable:!0,get:function(){return Bie.KeywordCxt}});var yc=se();Object.defineProperty(je,"_",{enumerable:!0,get:function(){return yc._}});Object.defineProperty(je,"str",{enumerable:!0,get:function(){return yc.str}});Object.defineProperty(je,"stringify",{enumerable:!0,get:function(){return yc.stringify}});Object.defineProperty(je,"nil",{enumerable:!0,get:function(){return yc.nil}});Object.defineProperty(je,"Name",{enumerable:!0,get:function(){return yc.Name}});Object.defineProperty(je,"CodeGen",{enumerable:!0,get:function(){return yc.CodeGen}});var Hie=Rg();Object.defineProperty(je,"ValidationError",{enumerable:!0,get:function(){return Hie.default}});var Vie=Sd();Object.defineProperty(je,"MissingRefError",{enumerable:!0,get:function(){return Vie.default}})});var p9=F(cn=>{"use strict";Object.defineProperty(cn,"__esModule",{value:!0});cn.formatNames=cn.fastFormats=cn.fullFormats=void 0;function an(e,t){return{validate:e,compare:t}}i(an,"fmtDef");cn.fullFormats={date:an(c9,QE),time:an(YE(!0),eN),"date-time":an(s9(!0),u9),"iso-time":an(YE(),l9),"iso-date-time":an(s9(),d9),duration:/^P(?!$)((\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+S)?)?|(\d+W)?)$/,uri:Xie,"uri-reference":/^(?:[a-z][a-z0-9+\-.]*:)?(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'"()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?(?:\?(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i,"uri-template":/^(?:(?:[^\x00-\x20"'<>%\\^`{|}]|%[0-9a-f]{2})|\{[+#./;?&=,!@|]?(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?(?:,(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?)*\})*$/i,url:/^(?:https?|ftp):\/\/(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z0-9\u{00a1}-\u{ffff}]+-)*[a-z0-9\u{00a1}-\u{ffff}]+)(?:\.(?:[a-z0-9\u{00a1}-\u{ffff}]+-)*[a-z0-9\u{00a1}-\u{ffff}]+)*(?:\.(?:[a-z\u{00a1}-\u{ffff}]{2,})))(?::\d{2,5})?(?:\/[^\s]*)?$/iu,email:/^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i,hostname:/^(?=.{1,253}\.?$)[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[-0-9a-z]{0,61}[0-9a-z])?)*\.?$/i,ipv4:/^(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)$/,ipv6:/^((([0-9a-f]{1,4}:){7}([0-9a-f]{1,4}|:))|(([0-9a-f]{1,4}:){6}(:[0-9a-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){5}(((:[0-9a-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){4}(((:[0-9a-f]{1,4}){1,3})|((:[0-9a-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){3}(((:[0-9a-f]{1,4}){1,4})|((:[0-9a-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){2}(((:[0-9a-f]{1,4}){1,5})|((:[0-9a-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){1}(((:[0-9a-f]{1,4}){1,6})|((:[0-9a-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9a-f]{1,4}){1,7})|((:[0-9a-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))$/i,regex:sae,uuid:/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i,"json-pointer":/^(?:\/(?:[^~/]|~0|~1)*)*$/,"json-pointer-uri-fragment":/^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i,"relative-json-pointer":/^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/,byte:Qie,int32:{type:"number",validate:rae},int64:{type:"number",validate:nae},float:{type:"number",validate:a9},double:{type:"number",validate:a9},password:!0,binary:!0};cn.fastFormats={...cn.fullFormats,date:an(/^\d\d\d\d-[0-1]\d-[0-3]\d$/,QE),time:an(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,eN),"date-time":an(/^\d\d\d\d-[0-1]\d-[0-3]\dt(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,u9),"iso-time":an(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,l9),"iso-date-time":an(/^\d\d\d\d-[0-1]\d-[0-3]\d[t\s](?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,d9),uri:/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/)?[^\s]*$/i,"uri-reference":/^(?:(?:[a-z][a-z0-9+\-.]*:)?\/?\/)?(?:[^\\\s#][^\s#]*)?(?:#[^\\\s]*)?$/i,email:/^[a-z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*$/i};cn.formatNames=Object.keys(cn.fullFormats);function Gie(e){return e%4===0&&(e%100!==0||e%400===0)}i(Gie,"isLeapYear");var Wie=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,Jie=[0,31,28,31,30,31,30,31,31,30,31,30,31];function c9(e){let t=Wie.exec(e);if(!t)return!1;let r=+t[1],n=+t[2],o=+t[3];return n>=1&&n<=12&&o>=1&&o<=(n===2&&Gie(r)?29:Jie[n])}i(c9,"date");function QE(e,t){if(e&&t)return e>t?1:e<t?-1:0}i(QE,"compareDate");var KE=/^(\d\d):(\d\d):(\d\d(?:\.\d+)?)(z|([+-])(\d\d)(?::?(\d\d))?)?$/i;function YE(e){return i(function(r){let n=KE.exec(r);if(!n)return!1;let o=+n[1],s=+n[2],a=+n[3],c=n[4],l=n[5]==="-"?-1:1,u=+(n[6]||0),d=+(n[7]||0);if(u>23||d>59||e&&!c)return!1;if(o<=23&&s<=59&&a<60)return!0;let p=s-d*l,m=o-u*l-(p<0?1:0);return(m===23||m===-1)&&(p===59||p===-1)&&a<61},"time")}i(YE,"getTime");function eN(e,t){if(!(e&&t))return;let r=new Date("2020-01-01T"+e).valueOf(),n=new Date("2020-01-01T"+t).valueOf();if(r&&n)return r-n}i(eN,"compareTime");function l9(e,t){if(!(e&&t))return;let r=KE.exec(e),n=KE.exec(t);if(r&&n)return e=r[1]+r[2]+r[3],t=n[1]+n[2]+n[3],e>t?1:e<t?-1:0}i(l9,"compareIsoTime");var XE=/t|\s/i;function s9(e){let t=YE(e);return i(function(n){let o=n.split(XE);return o.length===2&&c9(o[0])&&t(o[1])},"date_time")}i(s9,"getDateTime");function u9(e,t){if(!(e&&t))return;let r=new Date(e).valueOf(),n=new Date(t).valueOf();if(r&&n)return r-n}i(u9,"compareDateTime");function d9(e,t){if(!(e&&t))return;let[r,n]=e.split(XE),[o,s]=t.split(XE),a=QE(r,o);if(a!==void 0)return a||eN(n,s)}i(d9,"compareIsoDateTime");var Kie=/\/|:/,Yie=/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)(?:\?(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i;function Xie(e){return Kie.test(e)&&Yie.test(e)}i(Xie,"uri");var i9=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/gm;function Qie(e){return i9.lastIndex=0,i9.test(e)}i(Qie,"byte");var eae=-(2**31),tae=2**31-1;function rae(e){return Number.isInteger(e)&&e<=tae&&e>=eae}i(rae,"validateInt32");function nae(e){return Number.isInteger(e)}i(nae,"validateInt64");function a9(){return!0}i(a9,"validateNumber");var oae=/[^\\]\\Z/;function sae(e){if(oae.test(e))return!1;try{return new RegExp(e),!0}catch{return!1}}i(sae,"regex")});var f9=F(xc=>{"use strict";Object.defineProperty(xc,"__esModule",{value:!0});xc.formatLimitDefinition=void 0;var iae=JE(),jr=se(),Ao=jr.operators,oy={formatMaximum:{okStr:"<=",ok:Ao.LTE,fail:Ao.GT},formatMinimum:{okStr:">=",ok:Ao.GTE,fail:Ao.LT},formatExclusiveMaximum:{okStr:"<",ok:Ao.LT,fail:Ao.GTE},formatExclusiveMinimum:{okStr:">",ok:Ao.GT,fail:Ao.LTE}},aae={message:({keyword:e,schemaCode:t})=>(0,jr.str)`should be ${oy[e].okStr} ${t}`,params:({keyword:e,schemaCode:t})=>(0,jr._)`{comparison: ${oy[e].okStr}, limit: ${t}}`};xc.formatLimitDefinition={keyword:Object.keys(oy),type:"string",schemaType:"string",$data:!0,error:aae,code(e){let{gen:t,data:r,schemaCode:n,keyword:o,it:s}=e,{opts:a,self:c}=s;if(!a.validateFormats)return;let l=new iae.KeywordCxt(s,c.RULES.all.format.definition,"format");l.$data?u():d();function u(){let m=t.scopeValue("formats",{ref:c.formats,code:a.code.formats}),h=t.const("fmt",(0,jr._)`${m}[${l.schemaCode}]`);e.fail$data((0,jr.or)((0,jr._)`typeof ${h} != "object"`,(0,jr._)`${h} instanceof RegExp`,(0,jr._)`typeof ${h}.compare != "function"`,p(h)))}i(u,"validate$DataFormat");function d(){let m=l.schema,h=c.formats[m];if(!h||h===!0)return;if(typeof h!="object"||h instanceof RegExp||typeof h.compare!="function")throw new Error(`"${o}": format "${m}" does not define "compare" function`);let g=t.scopeValue("formats",{key:m,ref:h,code:a.code.formats?(0,jr._)`${a.code.formats}${(0,jr.getProperty)(m)}`:void 0});e.fail$data(p(g))}i(d,"validateFormat");function p(m){return(0,jr._)`${m}.compare(${r}, ${n}) ${oy[o].fail} 0`}i(p,"compareCode")},dependencies:["format"]};var cae=i(e=>(e.addKeyword(xc.formatLimitDefinition),e),"formatLimitPlugin");xc.default=cae});var y9=F((Md,g9)=>{"use strict";Object.defineProperty(Md,"__esModule",{value:!0});var _c=p9(),lae=f9(),tN=se(),m9=new tN.Name("fullFormats"),uae=new tN.Name("fastFormats"),rN=i((e,t={keywords:!0})=>{if(Array.isArray(t))return h9(e,t,_c.fullFormats,m9),e;let[r,n]=t.mode==="fast"?[_c.fastFormats,uae]:[_c.fullFormats,m9],o=t.formats||_c.formatNames;return h9(e,o,r,n),t.keywords&&(0,lae.default)(e),e},"formatsPlugin");rN.get=(e,t="full")=>{let n=(t==="fast"?_c.fastFormats:_c.fullFormats)[e];if(!n)throw new Error(`Unknown format "${e}"`);return n};function h9(e,t,r,n){var o,s;(o=(s=e.opts.code).formats)!==null&&o!==void 0||(s.formats=(0,tN._)`require("ajv-formats/dist/formats").${n}`);for(let a of t)e.addFormat(a,r[a])}i(h9,"addFormats");g9.exports=Md=rN;Object.defineProperty(Md,"__esModule",{value:!0});Md.default=rN});import{readFileSync as wae}from"fs";import{resolve as bae,dirname as Sae}from"path";import{fileURLToPath as kae}from"url";import{resolve as dH}from"path";import{existsSync as H9}from"fs";import{resolve as V9}from"path";function my(e){return!(!e||typeof e!="string"||!/^(?![@._])[a-z0-9@._-]{1,214}$/.test(e)||e.startsWith(".")||e.startsWith("_")||["node_modules","favicon.ico"].includes(e.toLowerCase()))}i(my,"isValidProjectName");function hy(e){return H9(V9(e))}i(hy,"projectExists");function gy(e){return e?e.startsWith(".")?"Project name cannot start with a dot (.)":e.startsWith("_")?"Project name cannot start with an underscore (_)":e!==e.toLowerCase()?"Project name must be lowercase":e.includes(" ")?"Project name cannot contain spaces":e.length>214?"Project name must be less than 214 characters":["node_modules","favicon.ico"].includes(e.toLowerCase())?`Project name "${e}" is reserved`:"Project name contains invalid characters. Use only lowercase letters, numbers, hyphens, and underscores":"Project name is required"}i(gy,"getValidationError");import{mkdirSync as cH}from"fs";import{resolve as lH}from"path";import{resolve as yt,dirname as G9}from"path";function Ud(e){if(e==null)return[];if(!Array.isArray(e))throw new Error('Config "deploy" must be an array');return e.map((t,r)=>{if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`Config "deploy[${r}]" must be an object`);if(typeof t.service!="string"||!t.service)throw new Error(`Config "deploy[${r}].service" must be a non-empty string`);let n={service:t.service};if(t.siteId!=null){if(typeof t.siteId!="string")throw new Error(`Config "deploy[${r}].siteId" must be a string`);n.siteId=t.siteId}if(t.url!=null){if(typeof t.url!="string")throw new Error(`Config "deploy[${r}].url" must be a string`);n.url=t.url}return n})}i(Ud,"normalizeDeploy");function yy(e,t){if(!e)throw new Error("Config object is required");if(!e.name||typeof e.name!="string")throw new Error('Config must have a "name" field (string)');if(!e.version||typeof e.version!="string")throw new Error('Config must have a "version" field (string)');if(!e.sceneGraph||typeof e.sceneGraph!="string")throw new Error('Config must have a "sceneGraph" field (string path)');if(!e.assets||typeof e.assets!="string")throw new Error('Config must have an "assets" field (string path)');let r=t?G9(t):process.cwd(),n=e.framework??"vue",o={name:e.name,version:e.version,port:e.port??4e3,_studioUrl:e._studioUrl,sceneGraph:e.sceneGraph?yt(r,e.sceneGraph):yt(r,"./src/sceneGraph"),assets:e.assets?yt(r,e.assets):yt(r,"./src/assets"),stores:e.stores?yt(r,e.stores):yt(r,"./src/stores"),views:e.views?yt(r,e.views):yt(r,"./src/views"),components:W9(e.components,r),libraries:J9(e.libraries??e.metadata?.libraries??[],r),metadata:{platform:e.metadata?.platform??n},socket:e.socket??{cors:{},options:{},auth:null},html:e.html??{},projectRoot:r,framework:n,outdir:yt(r,e.dist||"dist"),esbuild:e.esbuild??{},deploy:Ud(e.deploy)};if(typeof o.port!="number"||o.port<1||o.port>65535)throw new Error('Config "port" must be a number between 1 and 65535');if(typeof o.metadata.platform!="string")throw new Error('Config "metadata.platform" must be a string');if(!Array.isArray(o.libraries))throw new Error('Config "libraries" must be an array');return o}i(yy,"defineConfig");function W9(e,t){let r=yt(t,"./src/components");return e?typeof e=="string"?yt(t,e):Array.isArray(e)?e.map(n=>{if(typeof n=="string")return yt(t,n);if(n&&typeof n=="object"&&n.name&&n.from){let o=n.from.startsWith(".")?yt(t,n.from):n.from,s=n.manifest?n.manifest.startsWith(".")?yt(t,n.manifest):n.manifest:null;return{...n,from:o,manifest:s}}return n}):r:r}i(W9,"resolveComponents");function J9(e,t){return Array.isArray(e)?e.map(r=>{if(typeof r=="string")return r;if(r&&typeof r=="object"&&r.path){let n=r.path.startsWith(".")?yt(t,r.path):r.path;return{...r,path:n}}return r}):[]}i(J9,"resolveLibraries");import{resolve as wN}from"path";import{pathToFileURL as K9}from"url";async function Mo(e){let t;e?t=wN(process.cwd(),e):t=wN(process.cwd(),"jucie.config.js");try{let o=(await import(K9(t).href)).default;if(!o)throw new Error("Config file must export a default object");return yy(o,t)}catch(r){throw r.code==="ERR_MODULE_NOT_FOUND"||r.code==="ENOENT"?new Error(`Config file not found: ${t}`):r.message.includes("Config must")||r.message.includes('Config "')?r:new Error(`Failed to load config: ${r.message}`)}}i(Mo,"loadConfig");function qd(e){let{name:t,version:r,port:n,framework:o,sceneGraph:s,assets:a,components:c,stores:l,views:u,libraries:d,metadata:p,socket:m,html:h,dist:g,deploy:_,...x}=e,v={name:t,version:r||"0.0.1"};return n!=null&&(v.port=n),v.framework=o||"vue",v.sceneGraph=s||"./sceneGraph",v.assets=a||"./assets",c!=null&&(v.components=c),l!=null&&(v.stores=l),u!=null&&(v.views=u),d!=null&&(v.libraries=d),p!=null&&(v.metadata=p),m!=null&&(v.socket=m),h!=null&&Object.keys(h).length&&(v.html=h),g!=null&&(v.dist=g),v.deploy=Array.isArray(_)?_:[],Object.assign(v,x),`export default ${JSON.stringify(v,null,2)}
230
+ `}i(qd,"serializeConfig");F_();import{createHash as VB}from"crypto";function U_(e){let t=typeof e=="string"?e:JSON.stringify(e,GB);return VB("sha256").update(t).digest("hex")}i(U_,"generateCID");function GB(e,t){return e.startsWith(".")?void 0:t}i(GB,"filterDotKeys");var ZO=["app","temp","components"];function LO(e){return typeof e=="string"&&e!=="custom"&&Vo(e)!==null}i(LO,"isScreenPreset");function q_(e,t){return JSON.stringify({cid:e,data:t})}i(q_,"packLine");function Jp({screen:e}={}){let t=[q_(Wp,Yn)],r=Object.fromEntries(ZO.map(o=>[o,Wp]));if(LO(e)){let[o,s]=fp({frame:e,name:e});s.route={home:!0,path:"/"},s.anchor=["top","left"],s.dimensions=["width","height"];let a={...Yn,children:[o]},c=U_(s),l=U_(a);t.push(q_(c,s),q_(l,a)),r.app=l,r[o]=c}let n=Object.entries(r).map(([o,s])=>JSON.stringify({[o]:s})).join(`
231
+ `);return[{path:"nodes/nodes.pack",content:`${t.join(`
232
+ `)}
233
+ `},{path:"nodes/index-main.jsonl",content:`${n}
234
+ `},{path:"animations/animations.pack",content:""},{path:"animations/index-main.jsonl",content:""},{path:"tokens/tokens.pack",content:""},{path:"tokens/index-main.jsonl",content:""}]}i(Jp,"getSceneGraphSeed");function WB(e){return e.toLowerCase().replace(/[^a-z0-9._-]/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"")}i(WB,"slugify");function JB({name:e,cliVersion:t,version:r="0.0.1"}){return`${JSON.stringify({name:e,version:r,type:"module",scripts:{design:"jucie design",dev:"jucie dev",preview:"jucie dev",build:"jucie build"},devDependencies:{"@jucie.io/cli":`^${t}`}},null,2)}
235
+ `}i(JB,"createPackageJson");function KB(){return`node_modules/
186
236
  dist/
187
237
  .env
188
238
  .env.local
@@ -198,15 +248,23 @@ npm-debug.log*
198
248
  .cache/
199
249
  src/sceneGraph/.cache/
200
250
 
201
- # .jucie/ \u2014 chats and assets are committed as project context
251
+ # .jucie/ \u2014 chats and attachments are committed as project context
202
252
  .jucie/cache/
203
253
  .jucie/mcp-session.json
204
- `}i(IU,"createGitignore");function PU(e){return`<!DOCTYPE html>
205
- <html lang="en">
254
+ `}i(KB,"createGitignore");function YB(e){return`/**
255
+ * The document shell for this project.
256
+ *
257
+ * Receives the \`html\` tagged template \u2014 every interpolated value is escaped, so use
258
+ * \`raw()\` for markup you trust \u2014 plus \`slot()\` for content the build contributes
259
+ * (fonts, meta tags, and the HMR script in dev). No imports needed.
260
+ */
261
+ export default ({ html, slot, data }) => html\`<!DOCTYPE html>
262
+ <html lang="\${data.lang ?? 'en'}">
206
263
  <head>
207
264
  <meta charset="UTF-8" />
208
265
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
209
- <title>${e}</title>
266
+ <title>\${data.title ?? '${e}'}</title>
267
+ \${slot('head')}
210
268
  <style>
211
269
  *, *::before, *::after { box-sizing: border-box; }
212
270
  html, body { margin: 0; padding: 0; }
@@ -215,91 +273,93 @@ src/sceneGraph/.cache/
215
273
  <body>
216
274
  <div id="app" data-rid="app" data-node-id="app"></div>
217
275
  <script type="module" src="/main.js"></script>
276
+ \${slot('body:end')}
218
277
  </body>
219
- </html>
220
- `}i(PU,"createIndexHtml");function Hy({name:e,framework:t="vue",cliVersion:r="0.0.8",version:n="0.0.1"}){let o=zU(e),s=[{path:"package.json",content:CU({name:o,cliVersion:r,version:n})},{path:"jucie.config.js",content:hu({name:o,version:n,port:4e3,framework:t,sceneGraph:"./src/sceneGraph",assets:"./src/assets",components:"./src/components",metadata:{platform:t,libraries:[]},deploy:[]})},{path:".gitignore",content:IU()},{path:"index.html",content:PU(o)},{path:"src/assets/.gitkeep",content:""},{path:"src/components/.gitkeep",content:""},{path:".jucie/chats/.gitkeep",content:""},{path:".jucie/assets/.gitkeep",content:""}];for(let a of yd())s.push({path:`src/sceneGraph/${a.path}`,content:a.content});return s}i(Hy,"createProject");import{mkdirSync as RU,writeFileSync as OU}from"fs";import{resolve as AU,dirname as jU,join as DU}from"path";function xd(e,t){let r=AU(e);for(let{path:n,content:o}of t){let s=DU(r,n);RU(jU(s),{recursive:!0}),OU(s,o,"utf8")}}i(xd,"writeProjectFiles");import{existsSync as By,mkdirSync as MU,readFileSync as ZU,unlinkSync as LU,writeFileSync as FU}from"fs";import{dirname as GC,join as WC,resolve as Vy}from"path";var KC=".jucie/mcp-session.json",JC="jucie.config.js";function Gy(e=process.cwd()){let t=Vy(e);for(;;){let r=WC(t,JC);if(By(r))return{projectRoot:t,configPath:r};let n=GC(t);if(n===t)return null;t=n}}i(Gy,"findProjectRoot");function _d(e){return WC(Vy(e),KC)}i(_d,"getMcpSessionPath");function Wy(e,t){let r=Vy(e),n=_d(r);MU(GC(n),{recursive:!0});let o={port:t.port,url:t.url,projectRoot:t.projectRoot??r,pid:t.pid,startedAt:new Date().toISOString()};return FU(n,`${JSON.stringify(o,null,2)}
221
- `,"utf8"),o}i(Wy,"writeMcpSession");function Ky(e){let t=_d(e);if(!By(t))return null;try{return JSON.parse(ZU(t,"utf8"))}catch{return null}}i(Ky,"readMcpSession");function vd(e){let t=_d(e);if(By(t))try{LU(t)}catch{}}i(vd,"clearMcpSession");function Jy(e){if(!e||typeof e.pid!="number")return!1;try{return process.kill(e.pid,0),!0}catch{return!1}}i(Jy,"isSessionAlive");function HU(e){let t=qU(e);UU(t,{recursive:!0})}i(HU,"createDirectory");function YC(e,t,r={}){HU(t);let n=Hy({name:e,framework:r.framework||"vue",cliVersion:r.cliVersion||"0.0.8"});xd(t,n)}i(YC,"scaffoldProject");async function Yy(e,t={}){if(!ph(e)){let o=mh(e);console.error(`
278
+ </html>\`;
279
+ `}i(YB,"createIndexView");function B_({name:e,framework:t="vue",cliVersion:r="0.0.8",version:n="0.0.1",screen:o}={}){let s=WB(e),a=[{path:"package.json",content:JB({name:s,cliVersion:r,version:n})},{path:"jucie.config.js",content:qd({name:s,version:n,port:4e3,framework:t,sceneGraph:"./src/sceneGraph",assets:"./src/assets",components:"./src/components",metadata:{platform:t,libraries:[]},deploy:[]})},{path:".gitignore",content:KB()},{path:"src/views/index.js",content:YB(s)},{path:"src/assets/.gitkeep",content:""},{path:"src/components/.gitkeep",content:""},{path:".jucie/chats/.gitkeep",content:""},{path:".jucie/attachments/.gitkeep",content:""}];for(let c of Jp({screen:o}))a.push({path:`src/sceneGraph/${c.path}`,content:c.content});return a}i(B_,"createProject");import{mkdirSync as XB,writeFileSync as QB}from"fs";import{resolve as eH,dirname as tH,join as rH}from"path";function Kp(e,t){let r=eH(e);for(let{path:n,content:o}of t){let s=rH(r,n);XB(tH(s),{recursive:!0}),QB(s,o,"utf8")}}i(Kp,"writeProjectFiles");import{parse as EIe}from"@babel/parser";import{existsSync as H_,mkdirSync as oH,readFileSync as sH,unlinkSync as iH,writeFileSync as aH}from"fs";import{dirname as FO,join as UO,resolve as V_}from"path";var qO=".jucie/mcp-session.json",BO="jucie.config.js";function G_(e=process.cwd()){let t=V_(e);for(;;){let r=UO(t,BO);if(H_(r))return{projectRoot:t,configPath:r};let n=FO(t);if(n===t)return null;t=n}}i(G_,"findProjectRoot");function Yp(e){return UO(V_(e),qO)}i(Yp,"getMcpSessionPath");function W_(e,t){let r=V_(e),n=Yp(r);oH(FO(n),{recursive:!0});let o={port:t.port,url:t.url,projectRoot:t.projectRoot??r,pid:t.pid,startedAt:new Date().toISOString()};return aH(n,`${JSON.stringify(o,null,2)}
280
+ `,"utf8"),o}i(W_,"writeMcpSession");function J_(e){let t=Yp(e);if(!H_(t))return null;try{return JSON.parse(sH(t,"utf8"))}catch{return null}}i(J_,"readMcpSession");function Xp(e){let t=Yp(e);if(H_(t))try{iH(t)}catch{}}i(Xp,"clearMcpSession");function K_(e){if(!e||typeof e.pid!="number")return!1;try{return process.kill(e.pid,0),!0}catch{return!1}}i(K_,"isSessionAlive");function uH(e){let t=lH(e);cH(t,{recursive:!0})}i(uH,"createDirectory");function HO(e,t,r={}){uH(t);let n=B_({name:e,framework:r.framework||"vue",cliVersion:r.cliVersion||"0.0.8"});Kp(t,n)}i(HO,"scaffoldProject");async function Y_(e,t={}){if(!my(e)){let o=gy(e);console.error(`
222
281
  \u274C Error: ${o}
223
282
  `),process.exit(1)}let r=["vue","react","preact"];t.framework&&!r.includes(t.framework)&&(console.error(`
224
283
  \u274C Error: Unknown framework "${t.framework}". Use one of: ${r.join(", ")}
225
- `),process.exit(1));let n=BU(process.cwd(),e);fh(n)&&(console.error(`
284
+ `),process.exit(1));let n=dH(process.cwd(),e);hy(n)&&(console.error(`
226
285
  \u274C Error: Directory "${e}" already exists
227
286
  `),process.exit(1));try{console.log(`
228
287
  \u{1F680} Creating Jucie project: ${e}...
229
- `),YC(e,n,{framework:t.framework,cliVersion:t.cliVersion}),console.log(`\u2713 Created Jucie project: ${e}
288
+ `),HO(e,n,{framework:t.framework,cliVersion:t.cliVersion}),console.log(`\u2713 Created Jucie project: ${e}
230
289
  `),console.log("Get started:"),console.log(` cd ${e}`),console.log(" npm install"),console.log(` npm run design
231
290
  `),console.log(`This will start the Jucie dev server and open Studio.
232
291
  `)}catch(o){console.error(`
233
292
  \u274C Error creating project: ${o.message}
234
- `),t.verbose&&console.error(o.stack),process.exit(1)}}i(Yy,"createCommand");import{resolve as VI,join as GI,dirname as cq,isAbsolute as WI}from"path";import{existsSync as lq}from"fs";import{fileURLToPath as uq}from"url";oi();Id();Ud();qd();wx();import{Engine as eq}from"@jucie.io/engine";import{State as tq}from"@jucie.io/engine-state";import{Matcher as rq}from"@jucie.io/state-matcher";import{EsBuild as nq}from"@jucie.io/engine-esbuild";import{ServiceProvider as N6}from"@jucie.io/engine";var T6=new Set(["serif","sans-serif","monospace","cursive","fantasy","system-ui","ui-serif","ui-sans-serif","ui-monospace","ui-rounded","math","emoji","fangsong","Helvetica","Arial","Arial Black","Verdana","Tahoma","Trebuchet MS","Impact","Gill Sans","Times New Roman","Georgia","Palatino","Baskerville","Andal\xE9 Mono","Courier","Courier New","Lucida","Lucida Console","Lucida Sans","Monaco","Bradley Hand","Brush Script MT","Luminari","Comic Sans MS","Segoe UI","Roboto","Helvetica Neue","-apple-system","BlinkMacSystemFont","SF Pro","SF Mono","Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol"]),z6=new Set([...T6].map(e=>e.toLowerCase()));function Dn(e){return z6.has(e.toLowerCase().trim())}i(Dn,"isSystemFont");function xi(e){return!e||typeof e!="string"?[]:e.includes("var(")?[]:e.split(",").map(t=>t.trim().replace(/^['"]|['"]$/g,"")).filter(Boolean).map(C6)}i(xi,"parseFontFamily");function C6(e){let t=e.indexOf("@");if(t===-1){let o=e.trim();return{name:o,source:Dn(o)?"system":null}}let r=e.slice(0,t).trim(),n=e.slice(t+1).trim();return n==="google"?{name:r,source:"google"}:n==="local"?{name:r,source:"local"}:n.startsWith("http://")||n.startsWith("https://")||n.startsWith("/")?{name:r,source:"url",url:n}:{name:r,source:n}}i(C6,"parseSourceDescriptor");function I6(e){return!e||typeof e!="string"||e.includes("var(")?e:e.split(",").map(t=>{let r=t.trim().replace(/^['"]|['"]$/g,""),n=r.indexOf("@"),o=n===-1?r:r.slice(0,n).trim();return o.includes(" ")?`"${o}"`:o}).join(", ")}i(I6,"cleanFontFamily");var P6={thin:"100",hairline:"100","extra-light":"200","ultra-light":"200",light:"300",normal:"400",regular:"400",medium:"500","semi-bold":"600","demi-bold":"600",bold:"700","extra-bold":"800","ultra-bold":"800",black:"900",heavy:"900"};function R6(e){if(!e)return"400";let t=String(e).toLowerCase().trim();return P6[t]??t}i(R6,"normalizeWeight");function O6(e){if(!e)return"0";let t=String(e).toLowerCase().trim();return t==="italic"||t==="oblique"?"1":"0"}i(O6,"normalizeStyle");function Vd(e,t){return`${O6(t)},${R6(e)}`}i(Vd,"toVariant");function A6(e){if(!e||e.size===0)return"";let t=[],r=SI(e);r&&t.push('<link rel="preconnect" href="https://fonts.googleapis.com">','<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>',`<link href="${r}" rel="stylesheet">`);let n=kI(e);return n&&t.push(`<style>
293
+ `),t.verbose&&console.error(o.stack),process.exit(1)}}i(Y_,"createCommand");import{resolve as TR,join as zR,dirname as IV,isAbsolute as CR}from"path";import{existsSync as PV}from"fs";import{fileURLToPath as OV}from"url";Gi();df();bf();Sf();vv();oo();import{Engine as SV}from"@jucie.io/engine";import{State as kV}from"@jucie.io/engine-state";import{Matcher as $V}from"@jucie.io/state-matcher";import{EsBuild as EV}from"@jucie.io/engine-esbuild";import{LocalProvider as NV}from"@jucie.io/engine-storage/providers/local";function Df(e={}){let t=e.html??{};return{projectName:e.name||"Jucie App",title:t.title||e.title||e.name||"Jucie App",description:t.description||e.description||"",framework:e.framework||"react",mode:e.env||e.mode||"production",baseUrl:e.baseUrl||"/",lang:t.lang||"en",themeColor:t.themeColor||"",favicon:t.favicon||"",meta:Array.isArray(t.meta)?t.meta:[]}}i(Df,"resolveDocumentConfig");function AA(e){return{PROJECT_NAME:e.projectName,TITLE:e.title,DESCRIPTION:e.description,FRAMEWORK:e.framework,MODE:e.mode,BASE_URL:e.baseUrl,LANG:e.lang,THEME_COLOR:e.themeColor||"#000000"}}i(AA,"templateVars");var RA={"<!-- fonts-injected -->":"fonts","<!-- meta-injected -->":"meta"};Mf();oo();var jA=ms("fonts",()=>({slot:"head",order:-10,render:({data:e,inject:t,raw:r})=>{let n=e.fontLinks??t("fontResolver")?.buildLinks?.()??"";return n?r(n):""}}));oo();var DA=ms("meta",()=>({slot:"head",order:-20,render:({config:e,html:t})=>{let r=Df(e),n=[];r.description&&n.push(t`<meta name="description" content="${r.description}" />`),r.themeColor&&n.push(t`<meta name="theme-color" content="${r.themeColor}" />`),r.favicon&&n.push(t`<link rel="icon" href="${r.favicon}" />`);for(let o of r.meta){let s=Object.entries(o).map(([a,c])=>t`${a}="${c}"`).join(" ");n.push(`<meta ${s} />`)}return n.join(`
294
+ `)}}));import{ServiceProvider as c5}from"@jucie.io/engine";var l5=new Set(["serif","sans-serif","monospace","cursive","fantasy","system-ui","ui-serif","ui-sans-serif","ui-monospace","ui-rounded","math","emoji","fangsong","Helvetica","Arial","Arial Black","Verdana","Tahoma","Trebuchet MS","Impact","Gill Sans","Times New Roman","Georgia","Palatino","Baskerville","Andal\xE9 Mono","Courier","Courier New","Lucida","Lucida Console","Lucida Sans","Monaco","Bradley Hand","Brush Script MT","Luminari","Comic Sans MS","Segoe UI","Roboto","Helvetica Neue","-apple-system","BlinkMacSystemFont","SF Pro","SF Mono","Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol"]),u5=new Set([...l5].map(e=>e.toLowerCase()));function so(e){return u5.has(e.toLowerCase().trim())}i(so,"isSystemFont");function ua(e){return!e||typeof e!="string"?[]:e.includes("var(")?[]:e.split(",").map(t=>t.trim().replace(/^['"]|['"]$/g,"")).filter(Boolean).map(d5)}i(ua,"parseFontFamily");function d5(e){let t=e.indexOf("@");if(t===-1){let o=e.trim();return{name:o,source:so(o)?"system":null}}let r=e.slice(0,t).trim(),n=e.slice(t+1).trim();return n==="google"?{name:r,source:"google"}:n==="local"?{name:r,source:"local"}:n.startsWith("http://")||n.startsWith("https://")||n.startsWith("/")?{name:r,source:"url",url:n}:{name:r,source:n}}i(d5,"parseSourceDescriptor");function p5(e){return!e||typeof e!="string"||e.includes("var(")?e:e.split(",").map(t=>{let r=t.trim().replace(/^['"]|['"]$/g,""),n=r.indexOf("@"),o=n===-1?r:r.slice(0,n).trim();return o.includes(" ")?`"${o}"`:o}).join(", ")}i(p5,"cleanFontFamily");var f5={thin:"100",hairline:"100","extra-light":"200","ultra-light":"200",light:"300",normal:"400",regular:"400",medium:"500","semi-bold":"600","demi-bold":"600",bold:"700","extra-bold":"800","ultra-bold":"800",black:"900",heavy:"900"};function m5(e){if(!e)return"400";let t=String(e).toLowerCase().trim();return f5[t]??t}i(m5,"normalizeWeight");function h5(e){if(!e)return"0";let t=String(e).toLowerCase().trim();return t==="italic"||t==="oblique"?"1":"0"}i(h5,"normalizeStyle");function Zf(e,t){return`${h5(t)},${m5(e)}`}i(Zf,"toVariant");function g5(e){if(!e||e.size===0)return"";let t=[],r=MA(e);r&&t.push('<link rel="preconnect" href="https://fonts.googleapis.com">','<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>',`<link href="${r}" rel="stylesheet">`);let n=ZA(e);return n&&t.push(`<style>
235
295
  ${n}</style>`),t.join(`
236
- `)}i(A6,"buildFontLinks");function SI(e){let t=[];for(let[r,n]of e){if(n.source!=="google")continue;let o=[...n.variants].sort();if(o.some(a=>a.startsWith("1,")))t.push(`family=${r.replace(/ /g,"+")}:ital,wght@${o.join(";")}`);else{let a=o.map(c=>c.split(",")[1]).sort((c,l)=>Number(c)-Number(l));t.push(`family=${r.replace(/ /g,"+")}:wght@${a.join(";")}`)}}return t.length===0?null:`https://fonts.googleapis.com/css2?${t.join("&")}&display=swap`}i(SI,"buildGoogleUrl");function kI(e){let t=[];for(let[r,n]of e){if(n.source==="google"||!n.url)continue;let o=n.url.split(".").pop()?.toLowerCase(),s={woff2:"woff2",woff:"woff",ttf:"truetype",otf:"opentype"}[o]||"woff2";for(let a of n.variants){let[c,l]=a.split(","),u=c==="1"?"italic":"normal";t.push(` @font-face {
296
+ `)}i(g5,"buildFontLinks");function MA(e){let t=[];for(let[r,n]of e){if(n.source!=="google")continue;let o=[...n.variants].sort();if(o.some(a=>a.startsWith("1,")))t.push(`family=${r.replace(/ /g,"+")}:ital,wght@${o.join(";")}`);else{let a=o.map(c=>c.split(",")[1]).sort((c,l)=>Number(c)-Number(l));t.push(`family=${r.replace(/ /g,"+")}:wght@${a.join(";")}`)}}return t.length===0?null:`https://fonts.googleapis.com/css2?${t.join("&")}&display=swap`}i(MA,"buildGoogleUrl");function ZA(e){let t=[];for(let[r,n]of e){if(n.source==="google"||!n.url)continue;let o=n.url.split(".").pop()?.toLowerCase(),s={woff2:"woff2",woff:"woff",ttf:"truetype",otf:"opentype"}[o]||"woff2";for(let a of n.variants){let[c,l]=a.split(","),u=c==="1"?"italic":"normal";t.push(` @font-face {
237
297
  font-family: "${r}";
238
298
  src: url("${n.url}") format("${s}");
239
299
  font-weight: ${l};
240
300
  font-style: ${u};
241
301
  font-display: swap;
242
302
  }`)}}return t.length>0?t.join(`
243
- `):""}i(kI,"buildFontFaceBlock");function bx(e){return e["font-family"]||e.fontFamily||null}i(bx,"getFamily");function Gd(e){return e["font-weight"]||e.fontWeight||null}i(Gd,"getWeight");function Wd(e){return e["font-style"]||e.fontStyle||null}i(Wd,"getStyle");var ft,vt,yr,xr,Qt,Kd,$I,Jd,EI,Yd,NI,Xd,TI,zc,Sx,Qd,zI,ep,CI,tp,II,fn,Oo,rp,PI,np,RI,Cc,kx,Ic,$x,op=class op extends N6{constructor(){super(...arguments);k(this,Kd);k(this,Jd);k(this,Yd);k(this,Xd);k(this,zc);k(this,Qd);k(this,ep);k(this,tp);k(this,fn);k(this,rp);k(this,np);k(this,Cc);k(this,Ic);k(this,ft,new Map);k(this,vt,null);k(this,yr,null);k(this,xr,null);k(this,Qt,null)}initialize(){O(this,ft,new Map),E(this,Cc,kx).call(this)}actions(){return{resolve:(r,n,o)=>E(this,Kd,$I).call(this,r,n,o),requestFont:(r,n,o)=>E(this,rp,PI).call(this,r,n,o),hasFont:r=>E(this,np,RI).call(this,r),getFonts:()=>y(this,ft),buildLinks:()=>E(this,Jd,EI).call(this)}}getters(){return{contextPaths:()=>[]}}};ft=new WeakMap,vt=new WeakMap,yr=new WeakMap,xr=new WeakMap,Qt=new WeakMap,Kd=new WeakSet,$I=i(function(r,n="400",o="normal"){if(!r||typeof r!="string")return r;let s=xi(r),a=!1;for(let{name:c,source:l,url:u}of s)l==="system"||Dn(c)||E(this,fn,Oo).call(this,c,n,o,l||"google",u)&&(a=!0);return a&&E(this,Ic,$x).call(this),I6(r)},"#resolve"),Jd=new WeakSet,EI=i(function(){return A6(E(this,Yd,NI).call(this))},"#buildLinks"),Yd=new WeakSet,NI=i(function(){O(this,ft,new Map);let r=this.inject("state");E(this,Xd,TI).call(this,r);let n=r.get(["nodes"]);return n?.app&&E(this,zc,Sx).call(this,"app",n,null),y(this,ft)},"#scanFonts"),Xd=new WeakSet,TI=i(function(r){let n=r.get(["tokens"]);if(n){for(let[,o]of Object.entries(n))if(!(!o||o.$type!=="fontFamily"))for(let{name:s,source:a,url:c}of xi(o.$value))a==="system"||Dn(s)||E(this,fn,Oo).call(this,s,"400","normal",a||"google",c)}},"#scanTokens"),zc=new WeakSet,Sx=i(function(r,n,o){let s=n[r];if(!s)return;let{families:a}=E(this,tp,II).call(this,s),c=o;if(a.size>0){for(let[u,d]of a)if(d.variants.size>0)for(let p of d.variants){let[,h]=p.split(","),m=p.startsWith("1,")?"italic":"normal";E(this,fn,Oo).call(this,u,h,m,d.source,d.url)}else E(this,fn,Oo).call(this,u,"400","normal",d.source,d.url);c=E(this,Qd,zI).call(this,s)||[...a.keys()][0]}else if(c)for(let l of E(this,ep,CI).call(this,s)){let u=y(this,ft).get(c),[,d]=l.split(","),p=l.startsWith("1,")?"italic":"normal";E(this,fn,Oo).call(this,c,d,p,u?.source||"google",u?.url)}if(Array.isArray(s.children))for(let l of s.children)E(this,zc,Sx).call(this,l,n,c)},"#walkNode"),Qd=new WeakSet,zI=i(function(r){let n=r?.style?.default;if(!n)return null;let o=bx(n);return o&&xi(o).find(a=>a.source!=="system"&&!Dn(a.name))?.name||null},"#getDefaultFamily"),ep=new WeakSet,CI=i(function(r){if(!r?.style)return[];let n=new Set;for(let[,o]of Object.entries(r.style)){if(!o||typeof o!="object")continue;let s=Gd(o),a=Wd(o);(s||a)&&n.add(Vd(s||"400",a||"normal"));for(let[c,l]of Object.entries(o))if((c.startsWith(":")||c.startsWith("&"))&&l&&typeof l=="object"){let u=Gd(l),d=Wd(l);(u||d)&&n.add(Vd(u||"400",d||"normal"))}}return[...n]},"#extractVariantsOnly"),tp=new WeakSet,II=i(function(r){let n=new Map;if(!r?.style)return{families:n};function o(s,a,c){if(!s)return;let l=xi(s).find(u=>u.source!=="system"&&!Dn(u.name));l&&(n.has(l.name)||n.set(l.name,{source:l.source||"google",url:l.url,variants:new Set}),(a||c)&&n.get(l.name).variants.add(Vd(a||"400",c||"normal")))}i(o,"record");for(let[,s]of Object.entries(r.style))if(!(!s||typeof s!="object")){o(bx(s),Gd(s),Wd(s));for(let[a,c]of Object.entries(s))(a.startsWith(":")||a.startsWith("&"))&&c&&typeof c=="object"&&o(bx(c),Gd(c),Wd(c))}return{families:n}},"#extractNodeFonts"),fn=new WeakSet,Oo=i(function(r,n="400",o="normal",s="google",a){if(!r||Dn(r))return!1;let c=Vd(n,o),l=!1;y(this,ft).has(r)||(y(this,ft).set(r,{source:s||"google",url:a,variants:new Set}),l=!0,console.log("[FontResolver] registered new font:",r,"@"+s));let u=y(this,ft).get(r);return u.variants.has(c)||(u.variants.add(c),l=!0),l},"#registerFont"),rp=new WeakSet,PI=i(function(r,n="400",o="normal"){if(!r||typeof r!="string")return;let s=!1;for(let{name:a,source:c,url:l}of xi(r))c==="system"||Dn(a)||E(this,fn,Oo).call(this,a,n,o,c||"google",l)&&(s=!0);s&&E(this,Ic,$x).call(this)},"#requestFont"),np=new WeakSet,RI=i(function(r){if(!r||typeof r!="string")return!1;let n=xi(r);return n.length===0?y(this,ft).has(r):n.some(({name:o,source:s})=>s!=="system"&&!Dn(o)&&y(this,ft).has(o))},"#hasFont"),Cc=new WeakSet,kx=i(function(){typeof document>"u"||(y(this,xr)||(O(this,xr,document.getElementById("jucie-fonts-preconnect-googleapis")),y(this,xr)||(O(this,xr,document.createElement("link")),y(this,xr).id="jucie-fonts-preconnect-googleapis",y(this,xr).rel="preconnect",y(this,xr).href="https://fonts.googleapis.com",document.head.appendChild(y(this,xr)))),y(this,Qt)||(O(this,Qt,document.getElementById("jucie-fonts-preconnect-gstatic")),y(this,Qt)||(O(this,Qt,document.createElement("link")),y(this,Qt).id="jucie-fonts-preconnect-gstatic",y(this,Qt).rel="preconnect",y(this,Qt).href="https://fonts.gstatic.com",y(this,Qt).crossOrigin="",document.head.appendChild(y(this,Qt)))),y(this,vt)||(O(this,vt,document.getElementById("jucie-fonts")),y(this,vt)||(O(this,vt,document.createElement("link")),y(this,vt).id="jucie-fonts",y(this,vt).rel="stylesheet",document.head.appendChild(y(this,vt)))),y(this,yr)||(O(this,yr,document.getElementById("jucie-fonts-custom")),y(this,yr)||(O(this,yr,document.createElement("style")),y(this,yr).id="jucie-fonts-custom",document.head.appendChild(y(this,yr)))))},"#ensureLinkElements"),Ic=new WeakSet,$x=i(function(){if(typeof document>"u")return;E(this,Cc,kx).call(this);let r=SI(y(this,ft));r?y(this,vt).href!==r&&(y(this,vt).href=r):y(this,vt)&&y(this,vt).removeAttribute("href");let n=kI(y(this,ft));y(this,yr)&&(y(this,yr).textContent=n)},"#updateFontLinks"),i(op,"FontResolver"),Te(op,"manifest",{name:"FontResolver",namespace:"fontResolver"});var Tc=op;Ex();ip();ap();cp();import{defineEsConfig as j6}from"@jucie.io/engine-esbuild";import{dirname as D6,join as M6}from"path";import{fileURLToPath as Z6}from"url";var OI=j6("appConfig",(e,t)=>({entryPoints:[{in:t.appEntry||M6(D6(Z6(import.meta.url)),"../../modes/production/entry.js"),out:t.entryOut??"main"}],bundle:!0,format:"esm",platform:"browser",sourcemap:t.sourcemap??!1,sourcesContent:!!t.sourcemap,minify:t.minify??!1,target:["es2020"],outdir:t.outdir,jsx:"automatic",jsxImportSource:vi(t.framework),loader:_i,define:wi({framework:t.framework,nodeEnv:t.nodeEnv??(t.minify?"production":"development")}),treeShaking:!0,splitting:!0,chunkNames:"chunks/[name]-[hash]",assetNames:"assets/[name]-[hash]",external:sp,outExtension:{".js":".js",".css":".css"}}));up();Tx();pp();zx();import{defineEsPlugin as Q6}from"@jucie.io/engine-esbuild";var qI=Q6("resolve-config",e=>{let t=e("cache");return r=>{r.onResolve({filter:/^jucie:config$/},()=>({path:"virtual:config",namespace:"config"})),r.onLoad({filter:/.*/,namespace:"config"},()=>({contents:`export const jucieConfig = ${JSON.stringify(t.get(["jucieConfig"]))};`,loader:"js"}))}});import{rmSync as oq,mkdirSync as sq,existsSync as HI,statSync as iq}from"fs";import{join as aq}from"path";async function BI(e={}){try{e.outdir&&HI(e.outdir)&&oq(e.outdir,{recursive:!0,force:!0}),e.outdir&&sq(e.outdir,{recursive:!0});let t=eq.create().install(tq.configure({plugins:[rq]}),nn.configure({storage:{name:"state",provider:e.storageProvider??"local",root:e.projectRoot??e.sceneGraph,mode:"path",...e.storageConfig??{}},branch:e.branch||"main",namespaces:e.namespaces??{},configs:[di,pi,fi,mi,hi]}),an.configure(e),nq.configure({...e.esbuild??{},outdir:e.outdir,minify:e.minify??!0,sourcemap:e.sourcemap??!1,stageEntry:e.stageEntry}),Ro.configure(e),Tc.configure(e));t.esBuild.use(OI,bi,dp,Si,fp,qI),t.cache.set(["jucieConfig"],{...e,view:"production",mode:"production",appEntry:e.stageEntry,minify:e.minify??!0,sourcemap:e.sourcemap??!1});let r=await t.cas.load(),{ledger:n,ledgerTombstones:o,...s}=r;t.state.load(s),await t.storeParser.build();let a=t.fontResolver.buildLinks(),c=t.state.get(),l=Object.keys(c.nodes||{}).length,u=Object.keys(c.stores||{}).length;await t.esBuild.build();let d=await t.staticAssets.build({fontLinks:a});t.storeParser.stopWatching();let p="unknown";try{let h=aq(e.outdir,"main.js");HI(h)&&(p=`${(iq(h).size/1024).toFixed(2)} KB`)}catch{}return{success:!0,outdir:e.outdir,stats:{nodeCount:l,storeCount:u,bundleSize:p,assetCount:d.assets.fileCount}}}catch(t){throw console.error(`
244
- \u274C Build failed:`,t),t}}i(BI,"buildForProduction");async function Cx(e={},t={}){try{console.log(`
303
+ `):""}i(ZA,"buildFontFaceBlock");function Nv(e){return e["font-family"]||e.fontFamily||null}i(Nv,"getFamily");function Lf(e){return e["font-weight"]||e.fontWeight||null}i(Lf,"getWeight");function Ff(e){return e["font-style"]||e.fontStyle||null}i(Ff,"getStyle");var _t,Et,$r,Er,ir,Uf,LA,qf,FA,Bf,UA,Hf,qA,Tl,Tv,Vf,BA,Gf,HA,Wf,VA,Nn,gs,Jf,GA,Kf,WA,zl,zv,Cl,Cv,Yf=class Yf extends c5{constructor(){super(...arguments);$(this,Uf);$(this,qf);$(this,Bf);$(this,Hf);$(this,Tl);$(this,Vf);$(this,Gf);$(this,Wf);$(this,Nn);$(this,Jf);$(this,Kf);$(this,zl);$(this,Cl);$(this,_t,new Map);$(this,Et,null);$(this,$r,null);$(this,Er,null);$(this,ir,null)}initialize(){O(this,_t,new Map),k(this,zl,zv).call(this)}actions(){return{resolve:(r,n,o)=>k(this,Uf,LA).call(this,r,n,o),requestFont:(r,n,o)=>k(this,Jf,GA).call(this,r,n,o),hasFont:r=>k(this,Kf,WA).call(this,r),getFonts:()=>y(this,_t),buildLinks:()=>k(this,qf,FA).call(this)}}getters(){return{contextPaths:()=>[]}}};_t=new WeakMap,Et=new WeakMap,$r=new WeakMap,Er=new WeakMap,ir=new WeakMap,Uf=new WeakSet,LA=i(function(r,n="400",o="normal"){if(!r||typeof r!="string")return r;let s=ua(r),a=!1;for(let{name:c,source:l,url:u}of s)l==="system"||so(c)||k(this,Nn,gs).call(this,c,n,o,l||"google",u)&&(a=!0);return a&&k(this,Cl,Cv).call(this),p5(r)},"#resolve"),qf=new WeakSet,FA=i(function(){return g5(k(this,Bf,UA).call(this))},"#buildLinks"),Bf=new WeakSet,UA=i(function(){O(this,_t,new Map);let r=this.inject("state");k(this,Hf,qA).call(this,r);let n=r.get(["nodes"]);return n?.app&&k(this,Tl,Tv).call(this,"app",n,null),y(this,_t)},"#scanFonts"),Hf=new WeakSet,qA=i(function(r){let n=r.get(["tokens"]);if(n){for(let[,o]of Object.entries(n))if(!(!o||o.$type!=="fontFamily"))for(let{name:s,source:a,url:c}of ua(o.$value))a==="system"||so(s)||k(this,Nn,gs).call(this,s,"400","normal",a||"google",c)}},"#scanTokens"),Tl=new WeakSet,Tv=i(function(r,n,o){let s=n[r];if(!s)return;let{families:a}=k(this,Wf,VA).call(this,s),c=o;if(a.size>0){for(let[u,d]of a)if(d.variants.size>0)for(let p of d.variants){let[,m]=p.split(","),h=p.startsWith("1,")?"italic":"normal";k(this,Nn,gs).call(this,u,m,h,d.source,d.url)}else k(this,Nn,gs).call(this,u,"400","normal",d.source,d.url);c=k(this,Vf,BA).call(this,s)||[...a.keys()][0]}else if(c)for(let l of k(this,Gf,HA).call(this,s)){let u=y(this,_t).get(c),[,d]=l.split(","),p=l.startsWith("1,")?"italic":"normal";k(this,Nn,gs).call(this,c,d,p,u?.source||"google",u?.url)}if(Array.isArray(s.children))for(let l of s.children)k(this,Tl,Tv).call(this,l,n,c)},"#walkNode"),Vf=new WeakSet,BA=i(function(r){let n=r?.style?.default;if(!n)return null;let o=Nv(n);return o&&ua(o).find(a=>a.source!=="system"&&!so(a.name))?.name||null},"#getDefaultFamily"),Gf=new WeakSet,HA=i(function(r){if(!r?.style)return[];let n=new Set;for(let[,o]of Object.entries(r.style)){if(!o||typeof o!="object")continue;let s=Lf(o),a=Ff(o);(s||a)&&n.add(Zf(s||"400",a||"normal"));for(let[c,l]of Object.entries(o))if((c.startsWith(":")||c.startsWith("&"))&&l&&typeof l=="object"){let u=Lf(l),d=Ff(l);(u||d)&&n.add(Zf(u||"400",d||"normal"))}}return[...n]},"#extractVariantsOnly"),Wf=new WeakSet,VA=i(function(r){let n=new Map;if(!r?.style)return{families:n};function o(s,a,c){if(!s)return;let l=ua(s).find(u=>u.source!=="system"&&!so(u.name));l&&(n.has(l.name)||n.set(l.name,{source:l.source||"google",url:l.url,variants:new Set}),(a||c)&&n.get(l.name).variants.add(Zf(a||"400",c||"normal")))}i(o,"record");for(let[,s]of Object.entries(r.style))if(!(!s||typeof s!="object")){o(Nv(s),Lf(s),Ff(s));for(let[a,c]of Object.entries(s))(a.startsWith(":")||a.startsWith("&"))&&c&&typeof c=="object"&&o(Nv(c),Lf(c),Ff(c))}return{families:n}},"#extractNodeFonts"),Nn=new WeakSet,gs=i(function(r,n="400",o="normal",s="google",a){if(!r||so(r))return!1;let c=Zf(n,o),l=!1;y(this,_t).has(r)||(y(this,_t).set(r,{source:s||"google",url:a,variants:new Set}),l=!0,console.log("[FontResolver] registered new font:",r,"@"+s));let u=y(this,_t).get(r);return u.variants.has(c)||(u.variants.add(c),l=!0),l},"#registerFont"),Jf=new WeakSet,GA=i(function(r,n="400",o="normal"){if(!r||typeof r!="string")return;let s=!1;for(let{name:a,source:c,url:l}of ua(r))c==="system"||so(a)||k(this,Nn,gs).call(this,a,n,o,c||"google",l)&&(s=!0);s&&k(this,Cl,Cv).call(this)},"#requestFont"),Kf=new WeakSet,WA=i(function(r){if(!r||typeof r!="string")return!1;let n=ua(r);return n.length===0?y(this,_t).has(r):n.some(({name:o,source:s})=>s!=="system"&&!so(o)&&y(this,_t).has(o))},"#hasFont"),zl=new WeakSet,zv=i(function(){typeof document>"u"||(y(this,Er)||(O(this,Er,document.getElementById("jucie-fonts-preconnect-googleapis")),y(this,Er)||(O(this,Er,document.createElement("link")),y(this,Er).id="jucie-fonts-preconnect-googleapis",y(this,Er).rel="preconnect",y(this,Er).href="https://fonts.googleapis.com",document.head.appendChild(y(this,Er)))),y(this,ir)||(O(this,ir,document.getElementById("jucie-fonts-preconnect-gstatic")),y(this,ir)||(O(this,ir,document.createElement("link")),y(this,ir).id="jucie-fonts-preconnect-gstatic",y(this,ir).rel="preconnect",y(this,ir).href="https://fonts.gstatic.com",y(this,ir).crossOrigin="",document.head.appendChild(y(this,ir)))),y(this,Et)||(O(this,Et,document.getElementById("jucie-fonts")),y(this,Et)||(O(this,Et,document.createElement("link")),y(this,Et).id="jucie-fonts",y(this,Et).rel="stylesheet",document.head.appendChild(y(this,Et)))),y(this,$r)||(O(this,$r,document.getElementById("jucie-fonts-custom")),y(this,$r)||(O(this,$r,document.createElement("style")),y(this,$r).id="jucie-fonts-custom",document.head.appendChild(y(this,$r)))))},"#ensureLinkElements"),Cl=new WeakSet,Cv=i(function(){if(typeof document>"u")return;k(this,zl,zv).call(this);let r=MA(y(this,_t));r?y(this,Et).href!==r&&(y(this,Et).href=r):y(this,Et)&&y(this,Et).removeAttribute("href");let n=ZA(y(this,_t));y(this,$r)&&(y(this,$r).textContent=n)},"#updateFontLinks"),i(Yf,"FontResolver"),_e(Yf,"manifest",{name:"FontResolver",namespace:"fontResolver"});var Nl=Yf;Xf();Qf();em();Iv();nm();import{defineEsConfig as w5}from"@jucie.io/engine-esbuild";import{dirname as b5,join as S5}from"path";import{fileURLToPath as k5}from"url";var JA=w5("appConfig",(e,t)=>({entryPoints:[{in:t.appEntry||S5(b5(k5(import.meta.url)),"../../modes/production/entry.js"),out:t.entryOut??"main"}],bundle:!0,format:"esm",platform:"browser",sourcemap:t.sourcemap??!1,sourcesContent:!!t.sourcemap,minify:t.minify??!1,target:["es2020"],outdir:t.outdir,jsx:"automatic",jsxImportSource:fa(t.framework),loader:pa,alias:t.alias??t.esbuild?.alias??rm(t.framework),define:ma({framework:t.framework,nodeEnv:t.nodeEnv??(t.minify?"production":"development")}),treeShaking:!0,splitting:!0,chunkNames:"chunks/[name]-[hash]",assetNames:"assets/[name]-[hash]",external:da,outExtension:{".js":".js",".css":".css"}}));Ol();jl();Ml();ql();cm();Vl();Wl();Kl();import{rmSync as TV,mkdirSync as zV,existsSync as $R,statSync as CV}from"fs";import{join as ER}from"path";async function NR(e={}){try{e.outdir&&$R(e.outdir)&&TV(e.outdir,{recursive:!0,force:!0}),e.outdir&&zV(e.outdir,{recursive:!0});let t=await la(e.views,{onWarn:g=>console.warn(` \u26A0\uFE0F ${g}`)}),r=SV.create().install(kV.configure({plugins:[$V]}),gn.configure({storage:{name:"state",provider:e.storageProvider??NV,root:e.projectRoot??e.sceneGraph,mode:"path",...e.storageConfig??{}},branch:e.branch||"main",namespaces:e.namespaces??{},configs:[ta,ra,na,oa,sa]}),_n.configure(e),EV.configure({...e.esbuild??{},framework:e.framework,outdir:e.outdir,minify:e.minify??!0,sourcemap:e.sourcemap??!1,stageEntry:e.stageEntry}),En.configure({...e,templates:t,fragments:[jA,DA]}),kl.configure(e),Nl.configure(e));r.esBuild.use(JA,Pl,Rl,Dl,Ul,Bl,Hl,Gl,Jl),r.cache.set(["jucieConfig"],{...e,view:"production",mode:"production",appEntry:e.stageEntry,minify:e.minify??!0,sourcemap:e.sourcemap??!1});let n=await r.cas.load(),{ledger:o,ledgerTombstones:s,...a}=n;r.state.load(a),r.storeParser.onChange(g=>{if(g.type==="loaded")for(let[_,x]of Object.entries(g.stores))r.state.set([".stores",_],x)}),await r.storeParser.build();let c=r.state.get(),l=Object.keys(c.nodes||{}).length,u=Object.keys(c.stores||{}).length;await r.esBuild.build();let d=await r.buildAssets.build(),p=Df(e),m=r.html.list().includes("index")?"index":await r.html.useFile(e.htmlTemplate??ER(e.projectRoot,"index.html"),{vars:AA(p),mounts:["app"],scripts:["/main.js"],suppressOn:RA})??"app";await r.html.write(m,{data:{title:p.title,lang:p.lang}}),r.storeParser.stopWatching();let h="unknown";try{let g=ER(e.outdir,"main.js");$R(g)&&(h=`${(CV(g).size/1024).toFixed(2)} KB`)}catch{}return{success:!0,outdir:e.outdir,stats:{nodeCount:l,storeCount:u,bundleSize:h,assetCount:d.assets.fileCount}}}catch(t){throw console.error(`
304
+ \u274C Build failed:`,t),t}}i(NR,"buildForProduction");async function Gv(e={},t={}){try{console.log(`
245
305
  \u{1F528} Building Jucie project for production...
246
- `);let r=e.config||process.env.JUCIE_CONFIG||"jucie.config.js",n=await uo(r),o=e.outdir||e.o,s=o?WI(o)?o:VI(process.cwd(),o):n.outdir,a=e.htmlTemplate,c=a?WI(a)?a:VI(process.cwd(),a):GI(n.projectRoot,"index.html"),l=cq(uq(import.meta.url)),u=GI(l,"stage","prod.js"),d={...n,outdir:s,stageEntry:lq(u)?u:void 0,minify:e.minify??!0,sourcemap:e.sourcemap??!1,analyze:e.analyze??!1,branch:e.branch||e.b||"main",htmlTemplate:c,view:"production",mode:"production"};t.verbose&&(console.log("Build configuration:",d),console.log(""));let p=await BI(d);return p.success&&(console.log(`
306
+ `);let r=e.config||process.env.JUCIE_CONFIG||"jucie.config.js",n=await Mo(r),o=e.outdir||e.o,s=o?CR(o)?o:TR(process.cwd(),o):n.outdir,a=e.htmlTemplate,c=a?CR(a)?a:TR(process.cwd(),a):zR(n.projectRoot,"index.html"),l=IV(OV(import.meta.url)),u=zR(l,"stage","prod.js"),d={...n,outdir:s,stageEntry:PV(u)?u:void 0,minify:e.minify??!0,sourcemap:e.sourcemap??!1,analyze:e.analyze??!1,branch:e.branch||e.b||"main",htmlTemplate:c,view:"production",mode:"production"};t.verbose&&(console.log("Build configuration:",d),console.log(""));let p=await NR(d);return p.success&&(console.log(`
247
307
  \u2705 Build complete!
248
308
  `),console.log(`\u{1F4E6} Output directory: ${p.outdir}`),console.log(`\u{1F4CA} Bundle size: ${p.stats.bundleSize}`),console.log(`\u{1F3AF} Nodes compiled: ${p.stats.nodeCount}`),console.log(`\u{1F4C1} Stores: ${p.stats.storeCount}`),console.log(`\u{1F5BC}\uFE0F Assets copied: ${p.stats.assetCount}`),console.log(`
249
309
  \u{1F4A1} Deploy the dist/ folder to your hosting provider
250
310
  `)),p}catch(r){console.error(`
251
311
  \u274C Build failed: ${r.message}
252
- `),t.verbose&&console.error(r.stack),process.exit(1)}}i(Cx,"buildCommand");import{join as DB,dirname as MB}from"path";import{existsSync as ZB}from"fs";import{execSync as OR}from"child_process";import{fileURLToPath as LB}from"url";import{exec as dq}from"child_process";import{platform as KI}from"os";function Pc(e){let t=KI()==="win32"?`start ${e}`:KI()==="darwin"?`open ${e}`:`xdg-open ${e}`;dq(t)}i(Pc,"openURL");function Ci(e){let t=e.length;for(;--t>=0;)e[t]=0}i(Ci,"zero$1");var pq=0,jP=1,fq=2,mq=3,hq=258,e_=29,Vc=256,Zc=Vc+1+e_,Ei=30,t_=19,DP=2*Zc+1,Ao=15,Ix=16,gq=7,r_=256,MP=16,ZP=17,LP=18,Bx=new Uint8Array([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0]),_p=new Uint8Array([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13]),yq=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),FP=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),xq=512,hn=new Array((Zc+2)*2);Ci(hn);var jc=new Array(Ei*2);Ci(jc);var Lc=new Array(xq);Ci(Lc);var Fc=new Array(hq-mq+1);Ci(Fc);var n_=new Array(e_);Ci(n_);var vp=new Array(Ei);Ci(vp);function Px(e,t,r,n,o){this.static_tree=e,this.extra_bits=t,this.extra_base=r,this.elems=n,this.max_length=o,this.has_stree=e&&e.length}i(Px,"StaticTreeDesc");var UP,qP,HP;function Rx(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}i(Rx,"TreeDesc");var BP=i(e=>e<256?Lc[e]:Lc[256+(e>>>7)],"d_code"),Uc=i((e,t)=>{e.pending_buf[e.pending++]=t&255,e.pending_buf[e.pending++]=t>>>8&255},"put_short"),wt=i((e,t,r)=>{e.bi_valid>Ix-r?(e.bi_buf|=t<<e.bi_valid&65535,Uc(e,e.bi_buf),e.bi_buf=t>>Ix-e.bi_valid,e.bi_valid+=r-Ix):(e.bi_buf|=t<<e.bi_valid&65535,e.bi_valid+=r)},"send_bits"),Ar=i((e,t,r)=>{wt(e,r[t*2],r[t*2+1])},"send_code"),VP=i((e,t)=>{let r=0;do r|=e&1,e>>>=1,r<<=1;while(--t>0);return r>>>1},"bi_reverse"),_q=i(e=>{e.bi_valid===16?(Uc(e,e.bi_buf),e.bi_buf=0,e.bi_valid=0):e.bi_valid>=8&&(e.pending_buf[e.pending++]=e.bi_buf&255,e.bi_buf>>=8,e.bi_valid-=8)},"bi_flush"),vq=i((e,t)=>{let r=t.dyn_tree,n=t.max_code,o=t.stat_desc.static_tree,s=t.stat_desc.has_stree,a=t.stat_desc.extra_bits,c=t.stat_desc.extra_base,l=t.stat_desc.max_length,u,d,p,h,m,g,_=0;for(h=0;h<=Ao;h++)e.bl_count[h]=0;for(r[e.heap[e.heap_max]*2+1]=0,u=e.heap_max+1;u<DP;u++)d=e.heap[u],h=r[r[d*2+1]*2+1]+1,h>l&&(h=l,_++),r[d*2+1]=h,!(d>n)&&(e.bl_count[h]++,m=0,d>=c&&(m=a[d-c]),g=r[d*2],e.opt_len+=g*(h+m),s&&(e.static_len+=g*(o[d*2+1]+m)));if(_!==0){do{for(h=l-1;e.bl_count[h]===0;)h--;e.bl_count[h]--,e.bl_count[h+1]+=2,e.bl_count[l]--,_-=2}while(_>0);for(h=l;h!==0;h--)for(d=e.bl_count[h];d!==0;)p=e.heap[--u],!(p>n)&&(r[p*2+1]!==h&&(e.opt_len+=(h-r[p*2+1])*r[p*2],r[p*2+1]=h),d--)}},"gen_bitlen"),GP=i((e,t,r)=>{let n=new Array(Ao+1),o=0,s,a;for(s=1;s<=Ao;s++)o=o+r[s-1]<<1,n[s]=o;for(a=0;a<=t;a++){let c=e[a*2+1];c!==0&&(e[a*2]=VP(n[c]++,c))}},"gen_codes"),wq=i(()=>{let e,t,r,n,o,s=new Array(Ao+1);for(r=0,n=0;n<e_-1;n++)for(n_[n]=r,e=0;e<1<<Bx[n];e++)Fc[r++]=n;for(Fc[r-1]=n,o=0,n=0;n<16;n++)for(vp[n]=o,e=0;e<1<<_p[n];e++)Lc[o++]=n;for(o>>=7;n<Ei;n++)for(vp[n]=o<<7,e=0;e<1<<_p[n]-7;e++)Lc[256+o++]=n;for(t=0;t<=Ao;t++)s[t]=0;for(e=0;e<=143;)hn[e*2+1]=8,e++,s[8]++;for(;e<=255;)hn[e*2+1]=9,e++,s[9]++;for(;e<=279;)hn[e*2+1]=7,e++,s[7]++;for(;e<=287;)hn[e*2+1]=8,e++,s[8]++;for(GP(hn,Zc+1,s),e=0;e<Ei;e++)jc[e*2+1]=5,jc[e*2]=VP(e,5);UP=new Px(hn,Bx,Vc+1,Zc,Ao),qP=new Px(jc,_p,0,Ei,Ao),HP=new Px(new Array(0),yq,0,t_,gq)},"tr_static_init"),WP=i(e=>{let t;for(t=0;t<Zc;t++)e.dyn_ltree[t*2]=0;for(t=0;t<Ei;t++)e.dyn_dtree[t*2]=0;for(t=0;t<t_;t++)e.bl_tree[t*2]=0;e.dyn_ltree[r_*2]=1,e.opt_len=e.static_len=0,e.sym_next=e.matches=0},"init_block"),KP=i(e=>{e.bi_valid>8?Uc(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0},"bi_windup"),JI=i((e,t,r,n)=>{let o=t*2,s=r*2;return e[o]<e[s]||e[o]===e[s]&&n[t]<=n[r]},"smaller"),Ox=i((e,t,r)=>{let n=e.heap[r],o=r<<1;for(;o<=e.heap_len&&(o<e.heap_len&&JI(t,e.heap[o+1],e.heap[o],e.depth)&&o++,!JI(t,n,e.heap[o],e.depth));)e.heap[r]=e.heap[o],r=o,o<<=1;e.heap[r]=n},"pqdownheap"),YI=i((e,t,r)=>{let n,o,s=0,a,c;if(e.sym_next!==0)do n=e.pending_buf[e.sym_buf+s++]&255,n+=(e.pending_buf[e.sym_buf+s++]&255)<<8,o=e.pending_buf[e.sym_buf+s++],n===0?Ar(e,o,t):(a=Fc[o],Ar(e,a+Vc+1,t),c=Bx[a],c!==0&&(o-=n_[a],wt(e,o,c)),n--,a=BP(n),Ar(e,a,r),c=_p[a],c!==0&&(n-=vp[a],wt(e,n,c)));while(s<e.sym_next);Ar(e,r_,t)},"compress_block"),Vx=i((e,t)=>{let r=t.dyn_tree,n=t.stat_desc.static_tree,o=t.stat_desc.has_stree,s=t.stat_desc.elems,a,c,l=-1,u;for(e.heap_len=0,e.heap_max=DP,a=0;a<s;a++)r[a*2]!==0?(e.heap[++e.heap_len]=l=a,e.depth[a]=0):r[a*2+1]=0;for(;e.heap_len<2;)u=e.heap[++e.heap_len]=l<2?++l:0,r[u*2]=1,e.depth[u]=0,e.opt_len--,o&&(e.static_len-=n[u*2+1]);for(t.max_code=l,a=e.heap_len>>1;a>=1;a--)Ox(e,r,a);u=s;do a=e.heap[1],e.heap[1]=e.heap[e.heap_len--],Ox(e,r,1),c=e.heap[1],e.heap[--e.heap_max]=a,e.heap[--e.heap_max]=c,r[u*2]=r[a*2]+r[c*2],e.depth[u]=(e.depth[a]>=e.depth[c]?e.depth[a]:e.depth[c])+1,r[a*2+1]=r[c*2+1]=u,e.heap[1]=u++,Ox(e,r,1);while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],vq(e,t),GP(r,l,e.bl_count)},"build_tree"),XI=i((e,t,r)=>{let n,o=-1,s,a=t[0*2+1],c=0,l=7,u=4;for(a===0&&(l=138,u=3),t[(r+1)*2+1]=65535,n=0;n<=r;n++)s=a,a=t[(n+1)*2+1],!(++c<l&&s===a)&&(c<u?e.bl_tree[s*2]+=c:s!==0?(s!==o&&e.bl_tree[s*2]++,e.bl_tree[MP*2]++):c<=10?e.bl_tree[ZP*2]++:e.bl_tree[LP*2]++,c=0,o=s,a===0?(l=138,u=3):s===a?(l=6,u=3):(l=7,u=4))},"scan_tree"),QI=i((e,t,r)=>{let n,o=-1,s,a=t[0*2+1],c=0,l=7,u=4;for(a===0&&(l=138,u=3),n=0;n<=r;n++)if(s=a,a=t[(n+1)*2+1],!(++c<l&&s===a)){if(c<u)do Ar(e,s,e.bl_tree);while(--c!==0);else s!==0?(s!==o&&(Ar(e,s,e.bl_tree),c--),Ar(e,MP,e.bl_tree),wt(e,c-3,2)):c<=10?(Ar(e,ZP,e.bl_tree),wt(e,c-3,3)):(Ar(e,LP,e.bl_tree),wt(e,c-11,7));c=0,o=s,a===0?(l=138,u=3):s===a?(l=6,u=3):(l=7,u=4)}},"send_tree"),bq=i(e=>{let t;for(XI(e,e.dyn_ltree,e.l_desc.max_code),XI(e,e.dyn_dtree,e.d_desc.max_code),Vx(e,e.bl_desc),t=t_-1;t>=3&&e.bl_tree[FP[t]*2+1]===0;t--);return e.opt_len+=3*(t+1)+5+5+4,t},"build_bl_tree"),Sq=i((e,t,r,n)=>{let o;for(wt(e,t-257,5),wt(e,r-1,5),wt(e,n-4,4),o=0;o<n;o++)wt(e,e.bl_tree[FP[o]*2+1],3);QI(e,e.dyn_ltree,t-1),QI(e,e.dyn_dtree,r-1)},"send_all_trees"),kq=i(e=>{let t=4093624447,r;for(r=0;r<=31;r++,t>>>=1)if(t&1&&e.dyn_ltree[r*2]!==0)return 0;if(e.dyn_ltree[9*2]!==0||e.dyn_ltree[10*2]!==0||e.dyn_ltree[13*2]!==0)return 1;for(r=32;r<Vc;r++)if(e.dyn_ltree[r*2]!==0)return 1;return 0},"detect_data_type"),eP=!1,$q=i(e=>{eP||(wq(),eP=!0),e.l_desc=new Rx(e.dyn_ltree,UP),e.d_desc=new Rx(e.dyn_dtree,qP),e.bl_desc=new Rx(e.bl_tree,HP),e.bi_buf=0,e.bi_valid=0,WP(e)},"_tr_init$1"),JP=i((e,t,r,n)=>{wt(e,(pq<<1)+(n?1:0),3),KP(e),Uc(e,r),Uc(e,~r),r&&e.pending_buf.set(e.window.subarray(t,t+r),e.pending),e.pending+=r},"_tr_stored_block$1"),Eq=i(e=>{wt(e,jP<<1,3),Ar(e,r_,hn),_q(e)},"_tr_align$1"),Nq=i((e,t,r,n)=>{let o,s,a=0;e.level>0?(e.strm.data_type===2&&(e.strm.data_type=kq(e)),Vx(e,e.l_desc),Vx(e,e.d_desc),a=bq(e),o=e.opt_len+3+7>>>3,s=e.static_len+3+7>>>3,s<=o&&(o=s)):o=s=r+5,r+4<=o&&t!==-1?JP(e,t,r,n):e.strategy===4||s===o?(wt(e,(jP<<1)+(n?1:0),3),YI(e,hn,jc)):(wt(e,(fq<<1)+(n?1:0),3),Sq(e,e.l_desc.max_code+1,e.d_desc.max_code+1,a+1),YI(e,e.dyn_ltree,e.dyn_dtree)),WP(e),n&&KP(e)},"_tr_flush_block$1"),Tq=i((e,t,r)=>(e.pending_buf[e.sym_buf+e.sym_next++]=t,e.pending_buf[e.sym_buf+e.sym_next++]=t>>8,e.pending_buf[e.sym_buf+e.sym_next++]=r,t===0?e.dyn_ltree[r*2]++:(e.matches++,t--,e.dyn_ltree[(Fc[r]+Vc+1)*2]++,e.dyn_dtree[BP(t)*2]++),e.sym_next===e.sym_end),"_tr_tally$1"),zq=$q,Cq=JP,Iq=Nq,Pq=Tq,Rq=Eq,Oq={_tr_init:zq,_tr_stored_block:Cq,_tr_flush_block:Iq,_tr_tally:Pq,_tr_align:Rq},Aq=i((e,t,r,n)=>{let o=e&65535|0,s=e>>>16&65535|0,a=0;for(;r!==0;){a=r>2e3?2e3:r,r-=a;do o=o+t[n++]|0,s=s+o|0;while(--a);o%=65521,s%=65521}return o|s<<16|0},"adler32"),qc=Aq,jq=i(()=>{let e,t=[];for(var r=0;r<256;r++){e=r;for(var n=0;n<8;n++)e=e&1?3988292384^e>>>1:e>>>1;t[r]=e}return t},"makeTable"),Dq=new Uint32Array(jq()),Mq=i((e,t,r,n)=>{let o=Dq,s=n+r;e^=-1;for(let a=n;a<s;a++)e=e>>>8^o[(e^t[a])&255];return e^-1},"crc32"),We=Mq,Mo={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"},Uo={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8},{_tr_init:Zq,_tr_stored_block:Gx,_tr_flush_block:Lq,_tr_tally:Ln,_tr_align:Fq}=Oq,{Z_NO_FLUSH:Fn,Z_PARTIAL_FLUSH:Uq,Z_FULL_FLUSH:qq,Z_FINISH:er,Z_BLOCK:tP,Z_OK:Qe,Z_STREAM_END:rP,Z_STREAM_ERROR:jr,Z_DATA_ERROR:Hq,Z_BUF_ERROR:Ax,Z_DEFAULT_COMPRESSION:Bq,Z_FILTERED:Vq,Z_HUFFMAN_ONLY:mp,Z_RLE:Gq,Z_FIXED:Wq,Z_DEFAULT_STRATEGY:Kq,Z_UNKNOWN:Jq,Z_DEFLATED:Sp}=Uo,Yq=9,Xq=15,Qq=8,e3=29,t3=256,Wx=t3+1+e3,r3=30,n3=19,o3=2*Wx+1,s3=15,he=3,Zn=258,Dr=Zn+he+1,i3=32,Ti=42,o_=57,Kx=69,Jx=73,Yx=91,Xx=103,jo=113,Oc=666,mt=1,Ii=2,Zo=3,Pi=4,a3=3,Do=i((e,t)=>(e.msg=Mo[t],t),"err"),nP=i(e=>e*2-(e>4?9:0),"rank"),Mn=i(e=>{let t=e.length;for(;--t>=0;)e[t]=0},"zero"),c3=i(e=>{let t,r,n,o=e.w_size;t=e.hash_size,n=t;do r=e.head[--n],e.head[n]=r>=o?r-o:0;while(--t);t=o,n=t;do r=e.prev[--n],e.prev[n]=r>=o?r-o:0;while(--t)},"slide_hash"),s_=i((e,t,r)=>(t<<e.hash_shift^r)&e.hash_mask,"HASH"),Lo=i((e,t)=>{let r;if(e.legacy_hash)r=e.ins_h=s_(e,e.ins_h,e.window[t+he-1]);else{let o=e.window,s=o[t]|o[t+1]<<8|o[t+2]<<16|o[t+3]<<24;r=e.ins_h=Math.imul(s,66521)+66521>>>16&e.hash_mask}let n=e.prev[t&e.w_mask]=e.head[r];return e.head[r]=t,n},"INSERT_STRING"),Dt=i(e=>{let t=e.state,r=t.pending;r>e.avail_out&&(r=e.avail_out),r!==0&&(e.output.set(t.pending_buf.subarray(t.pending_out,t.pending_out+r),e.next_out),e.next_out+=r,t.pending_out+=r,e.total_out+=r,e.avail_out-=r,t.pending-=r,t.pending===0&&(t.pending_out=0))},"flush_pending"),Mt=i((e,t)=>{Lq(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,Dt(e.strm)},"flush_block_only"),ge=i((e,t)=>{e.pending_buf[e.pending++]=t},"put_byte"),Rc=i((e,t)=>{e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=t&255},"putShortMSB"),Qx=i((e,t,r,n)=>{let o=e.avail_in;return o>n&&(o=n),o===0?0:(e.avail_in-=o,t.set(e.input.subarray(e.next_in,e.next_in+o),r),e.state.wrap===1?e.adler=qc(e.adler,t,o,r):e.state.wrap===2&&(e.adler=We(e.adler,t,o,r)),e.next_in+=o,e.total_in+=o,o)},"read_buf"),YP=i((e,t)=>{let r=e.max_chain_length,n=e.strstart,o,s,a=e.prev_length,c=e.nice_match,l=e.strstart>e.w_size-Dr?e.strstart-(e.w_size-Dr):0,u=e.window,d=e.w_mask,p=e.prev,h=e.strstart+Zn,m=u[n+a-1],g=u[n+a];e.prev_length>=e.good_match&&(r>>=2),c>e.lookahead&&(c=e.lookahead);do if(o=t,!(u[o+a]!==g||u[o+a-1]!==m||u[o]!==u[n]||u[++o]!==u[n+1])){n+=2,o++;do;while(u[++n]===u[++o]&&u[++n]===u[++o]&&u[++n]===u[++o]&&u[++n]===u[++o]&&u[++n]===u[++o]&&u[++n]===u[++o]&&u[++n]===u[++o]&&u[++n]===u[++o]&&n<h);if(s=Zn-(h-n),n=h-Zn,s>a){if(e.match_start=t,a=s,s>=c)break;m=u[n+a-1],g=u[n+a]}}while((t=p[t&d])>l&&--r!==0);return a<=e.lookahead?a:e.lookahead},"longest_match"),zi=i(e=>{let t=e.w_size,r,n,o;do{if(n=e.window_size-e.lookahead-e.strstart,e.strstart>=t+(t-Dr)&&(e.window.set(e.window.subarray(t,t+t-n),0),e.match_start-=t,e.strstart-=t,e.block_start-=t,e.insert>e.strstart&&(e.insert=e.strstart),c3(e),n+=t),e.strm.avail_in===0)break;if(r=Qx(e.strm,e.window,e.strstart+e.lookahead,n),e.lookahead+=r,e.legacy_hash){if(e.lookahead+e.insert>=he)for(o=e.strstart-e.insert,e.ins_h=e.window[o],e.ins_h=s_(e,e.ins_h,e.window[o+1]);e.insert&&(Lo(e,o),o++,e.insert--,!(e.lookahead+e.insert<he)););}else if(e.lookahead+e.insert>he)for(o=e.strstart-e.insert;e.insert&&(Lo(e,o),o++,e.insert--,!(e.lookahead+e.insert<=he)););}while(e.lookahead<Dr&&e.strm.avail_in!==0)},"fill_window"),XP=i((e,t)=>{let r=e.pending_buf_size-5>e.w_size?e.w_size:e.pending_buf_size-5,n,o,s,a=0,c=e.strm.avail_in;do{if(n=65535,s=e.bi_valid+42>>3,e.strm.avail_out<s||(s=e.strm.avail_out-s,o=e.strstart-e.block_start,n>o+e.strm.avail_in&&(n=o+e.strm.avail_in),n>s&&(n=s),n<r&&(n===0&&t!==er||t===Fn||n!==o+e.strm.avail_in)))break;a=t===er&&n===o+e.strm.avail_in?1:0,Gx(e,0,0,a),e.pending_buf[e.pending-4]=n,e.pending_buf[e.pending-3]=n>>8,e.pending_buf[e.pending-2]=~n,e.pending_buf[e.pending-1]=~n>>8,Dt(e.strm),o&&(o>n&&(o=n),e.strm.output.set(e.window.subarray(e.block_start,e.block_start+o),e.strm.next_out),e.strm.next_out+=o,e.strm.avail_out-=o,e.strm.total_out+=o,e.block_start+=o,n-=o),n&&(Qx(e.strm,e.strm.output,e.strm.next_out,n),e.strm.next_out+=n,e.strm.avail_out-=n,e.strm.total_out+=n)}while(a===0);return c-=e.strm.avail_in,c&&(c>=e.w_size?(e.matches=2,e.window.set(e.strm.input.subarray(e.strm.next_in-e.w_size,e.strm.next_in),0),e.strstart=e.w_size,e.insert=e.strstart):(e.window_size-e.strstart<=c&&(e.strstart-=e.w_size,e.window.set(e.window.subarray(e.w_size,e.w_size+e.strstart),0),e.matches<2&&e.matches++,e.insert>e.strstart&&(e.insert=e.strstart)),e.window.set(e.strm.input.subarray(e.strm.next_in-c,e.strm.next_in),e.strstart),e.strstart+=c,e.insert+=c>e.w_size-e.insert?e.w_size-e.insert:c),e.block_start=e.strstart),e.high_water<e.strstart&&(e.high_water=e.strstart),a?Pi:t!==Fn&&t!==er&&e.strm.avail_in===0&&e.strstart===e.block_start?Ii:(s=e.window_size-e.strstart,e.strm.avail_in>s&&e.block_start>=e.w_size&&(e.block_start-=e.w_size,e.strstart-=e.w_size,e.window.set(e.window.subarray(e.w_size,e.w_size+e.strstart),0),e.matches<2&&e.matches++,s+=e.w_size,e.insert>e.strstart&&(e.insert=e.strstart)),s>e.strm.avail_in&&(s=e.strm.avail_in),s&&(Qx(e.strm,e.window,e.strstart,s),e.strstart+=s,e.insert+=s>e.w_size-e.insert?e.w_size-e.insert:s),e.high_water<e.strstart&&(e.high_water=e.strstart),s=e.bi_valid+42>>3,s=e.pending_buf_size-s>65535?65535:e.pending_buf_size-s,r=s>e.w_size?e.w_size:s,o=e.strstart-e.block_start,(o>=r||(o||t===er)&&t!==Fn&&e.strm.avail_in===0&&o<=s)&&(n=o>s?s:o,a=t===er&&e.strm.avail_in===0&&n===o?1:0,Gx(e,e.block_start,n,a),e.block_start+=n,Dt(e.strm)),a?Zo:mt)},"deflate_stored"),jx=i((e,t)=>{let r,n;for(;;){if(e.lookahead<Dr){if(zi(e),e.lookahead<Dr&&t===Fn)return mt;if(e.lookahead===0)break}if(r=0,e.lookahead>=he&&(r=Lo(e,e.strstart)),r!==0&&e.strstart-r<=e.w_size-Dr&&(e.match_length=YP(e,r)),e.match_length>=he)if(n=Ln(e,e.strstart-e.match_start,e.match_length-he),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=he){e.match_length--;do e.strstart++,r=Lo(e,e.strstart);while(--e.match_length!==0);e.strstart++}else e.strstart+=e.match_length,e.match_length=0,e.legacy_hash&&(e.ins_h=e.window[e.strstart],e.ins_h=s_(e,e.ins_h,e.window[e.strstart+1]));else n=Ln(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(n&&(Mt(e,!1),e.strm.avail_out===0))return mt}return e.insert=e.strstart<he-1?e.strstart:he-1,t===er?(Mt(e,!0),e.strm.avail_out===0?Zo:Pi):e.sym_next&&(Mt(e,!1),e.strm.avail_out===0)?mt:Ii},"deflate_fast"),ki=i((e,t)=>{let r,n,o;for(;;){if(e.lookahead<Dr){if(zi(e),e.lookahead<Dr&&t===Fn)return mt;if(e.lookahead===0)break}if(r=0,e.lookahead>=he&&(r=Lo(e,e.strstart)),e.prev_length=e.match_length,e.prev_match=e.match_start,e.match_length=he-1,r!==0&&e.prev_length<e.max_lazy_match&&e.strstart-r<=e.w_size-Dr&&(e.match_length=YP(e,r),e.match_length<=5&&(e.strategy===Vq||e.match_length===he&&e.strstart-e.match_start>4096)&&(e.match_length=he-1)),e.prev_length>=he&&e.match_length<=e.prev_length){o=e.strstart+e.lookahead-he,n=Ln(e,e.strstart-1-e.prev_match,e.prev_length-he),e.lookahead-=e.prev_length-1,e.prev_length-=2;do++e.strstart<=o&&(r=Lo(e,e.strstart));while(--e.prev_length!==0);if(e.match_available=0,e.match_length=he-1,e.strstart++,n&&(Mt(e,!1),e.strm.avail_out===0))return mt}else if(e.match_available){if(n=Ln(e,0,e.window[e.strstart-1]),n&&Mt(e,!1),e.strstart++,e.lookahead--,e.strm.avail_out===0)return mt}else e.match_available=1,e.strstart++,e.lookahead--}return e.match_available&&(n=Ln(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<he-1?e.strstart:he-1,t===er?(Mt(e,!0),e.strm.avail_out===0?Zo:Pi):e.sym_next&&(Mt(e,!1),e.strm.avail_out===0)?mt:Ii},"deflate_slow"),l3=i((e,t)=>{let r,n,o,s,a=e.window;for(;;){if(e.lookahead<=Zn){if(zi(e),e.lookahead<=Zn&&t===Fn)return mt;if(e.lookahead===0)break}if(e.match_length=0,e.lookahead>=he&&e.strstart>0&&(o=e.strstart-1,n=a[o],n===a[++o]&&n===a[++o]&&n===a[++o])){s=e.strstart+Zn;do;while(n===a[++o]&&n===a[++o]&&n===a[++o]&&n===a[++o]&&n===a[++o]&&n===a[++o]&&n===a[++o]&&n===a[++o]&&o<s);e.match_length=Zn-(s-o),e.match_length>e.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=he?(r=Ln(e,1,e.match_length-he),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(r=Ln(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),r&&(Mt(e,!1),e.strm.avail_out===0))return mt}return e.insert=0,t===er?(Mt(e,!0),e.strm.avail_out===0?Zo:Pi):e.sym_next&&(Mt(e,!1),e.strm.avail_out===0)?mt:Ii},"deflate_rle"),u3=i((e,t)=>{let r;for(;;){if(e.lookahead===0&&(zi(e),e.lookahead===0)){if(t===Fn)return mt;break}if(e.match_length=0,r=Ln(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,r&&(Mt(e,!1),e.strm.avail_out===0))return mt}return e.insert=0,t===er?(Mt(e,!0),e.strm.avail_out===0?Zo:Pi):e.sym_next&&(Mt(e,!1),e.strm.avail_out===0)?mt:Ii},"deflate_huff");function Rr(e,t,r,n,o){this.good_length=e,this.max_lazy=t,this.nice_length=r,this.max_chain=n,this.func=o}i(Rr,"Config");var Ac=[new Rr(0,0,0,0,XP),new Rr(4,4,8,4,jx),new Rr(4,5,16,8,jx),new Rr(4,6,32,32,jx),new Rr(4,4,16,16,ki),new Rr(8,16,32,32,ki),new Rr(8,16,128,128,ki),new Rr(8,32,128,256,ki),new Rr(32,128,258,1024,ki),new Rr(32,258,258,4096,ki)],d3=i(e=>{e.window_size=2*e.w_size,Mn(e.head),e.max_lazy_match=Ac[e.level].max_lazy,e.good_match=Ac[e.level].good_length,e.nice_match=Ac[e.level].nice_length,e.max_chain_length=Ac[e.level].max_chain,e.strstart=0,e.block_start=0,e.lookahead=0,e.insert=0,e.match_length=e.prev_length=he-1,e.match_available=0,e.ins_h=0},"lm_init");function p3(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=Sp,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.legacy_hash=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new Uint16Array(o3*2),this.dyn_dtree=new Uint16Array((2*r3+1)*2),this.bl_tree=new Uint16Array((2*n3+1)*2),Mn(this.dyn_ltree),Mn(this.dyn_dtree),Mn(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(s3+1),this.heap=new Uint16Array(2*Wx+1),Mn(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(2*Wx+1),Mn(this.depth),this.sym_buf=0,this.lit_bufsize=0,this.sym_next=0,this.sym_end=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}i(p3,"DeflateState");var Gc=i(e=>{if(!e)return 1;let t=e.state;return!t||t.strm!==e||t.status!==Ti&&t.status!==o_&&t.status!==Kx&&t.status!==Jx&&t.status!==Yx&&t.status!==Xx&&t.status!==jo&&t.status!==Oc?1:0},"deflateStateCheck"),QP=i(e=>{if(Gc(e))return Do(e,jr);e.total_in=e.total_out=0,e.data_type=Jq;let t=e.state;return t.pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=t.wrap===2?o_:t.wrap?Ti:jo,e.adler=t.wrap===2?0:1,t.last_flush=-2,Zq(t),Qe},"deflateResetKeep"),eR=i(e=>{let t=QP(e);return t===Qe&&d3(e.state),t},"deflateReset"),f3=i((e,t)=>Gc(e)||e.state.wrap!==2?jr:(e.state.gzhead=t,Qe),"deflateSetHeader"),tR=i((e,t,r,n,o,s,a)=>{if(!e)return jr;let c=1;if(t===Bq&&(t=6),n<0?(c=0,n=-n):n>15&&(c=2,n-=16),o<1||o>Yq||r!==Sp||n<8||n>15||t<0||t>9||s<0||s>Wq||n===8&&c!==1)return Do(e,jr);n===8&&(n=9);let l=new p3;return e.state=l,l.strm=e,l.status=Ti,l.wrap=c,l.gzhead=null,l.w_bits=n,l.w_size=1<<l.w_bits,l.w_mask=l.w_size-1,l.legacy_hash=a?1:0,l.hash_bits=o+7,!l.legacy_hash&&l.hash_bits<15&&(l.hash_bits=15),l.hash_size=1<<l.hash_bits,l.hash_mask=l.hash_size-1,l.hash_shift=~~((l.hash_bits+he-1)/he),l.window=new Uint8Array(l.w_size*2),l.head=new Uint16Array(l.hash_size),l.prev=new Uint16Array(l.w_size),l.lit_bufsize=1<<o+6,l.pending_buf_size=l.lit_bufsize*4,l.pending_buf=new Uint8Array(l.pending_buf_size),l.sym_buf=l.lit_bufsize,l.sym_end=(l.lit_bufsize-1)*3,l.level=t,l.strategy=s,l.method=r,eR(e)},"deflateInit2"),m3=i((e,t)=>tR(e,t,Sp,Xq,Qq,Kq),"deflateInit"),h3=i((e,t)=>{if(Gc(e)||t>tP||t<0)return e?Do(e,jr):jr;let r=e.state;if(!e.output||e.avail_in!==0&&!e.input||r.status===Oc&&t!==er)return Do(e,e.avail_out===0?Ax:jr);let n=r.last_flush;if(r.last_flush=t,r.pending!==0){if(Dt(e),e.avail_out===0)return r.last_flush=-1,Qe}else if(e.avail_in===0&&nP(t)<=nP(n)&&t!==er)return Do(e,Ax);if(r.status===Oc&&e.avail_in!==0)return Do(e,Ax);if(r.status===Ti&&r.wrap===0&&(r.status=jo),r.status===Ti){let o=Sp+(r.w_bits-8<<4)<<8,s=-1;if(r.strategy>=mp||r.level<2?s=0:r.level<6?s=1:r.level===6?s=2:s=3,o|=s<<6,r.strstart!==0&&(o|=i3),o+=31-o%31,Rc(r,o),r.strstart!==0&&(Rc(r,e.adler>>>16),Rc(r,e.adler&65535)),e.adler=1,r.status=jo,Dt(e),r.pending!==0)return r.last_flush=-1,Qe}if(r.status===o_){if(e.adler=0,ge(r,31),ge(r,139),ge(r,8),r.gzhead)ge(r,(r.gzhead.text?1:0)+(r.gzhead.hcrc?2:0)+(r.gzhead.extra?4:0)+(r.gzhead.name?8:0)+(r.gzhead.comment?16:0)),ge(r,r.gzhead.time&255),ge(r,r.gzhead.time>>8&255),ge(r,r.gzhead.time>>16&255),ge(r,r.gzhead.time>>24&255),ge(r,r.level===9?2:r.strategy>=mp||r.level<2?4:0),ge(r,r.gzhead.os&255),r.gzhead.extra&&r.gzhead.extra.length&&(ge(r,r.gzhead.extra.length&255),ge(r,r.gzhead.extra.length>>8&255)),r.gzhead.hcrc&&(e.adler=We(e.adler,r.pending_buf,r.pending,0)),r.gzindex=0,r.status=Kx;else if(ge(r,0),ge(r,0),ge(r,0),ge(r,0),ge(r,0),ge(r,r.level===9?2:r.strategy>=mp||r.level<2?4:0),ge(r,a3),r.status=jo,Dt(e),r.pending!==0)return r.last_flush=-1,Qe}if(r.status===Kx){if(r.gzhead.extra){let o=r.pending,s=(r.gzhead.extra.length&65535)-r.gzindex;for(;r.pending+s>r.pending_buf_size;){let c=r.pending_buf_size-r.pending;if(r.pending_buf.set(r.gzhead.extra.subarray(r.gzindex,r.gzindex+c),r.pending),r.pending=r.pending_buf_size,r.gzhead.hcrc&&r.pending>o&&(e.adler=We(e.adler,r.pending_buf,r.pending-o,o)),r.gzindex+=c,Dt(e),r.pending!==0)return r.last_flush=-1,Qe;o=0,s-=c}let a=new Uint8Array(r.gzhead.extra);r.pending_buf.set(a.subarray(r.gzindex,r.gzindex+s),r.pending),r.pending+=s,r.gzhead.hcrc&&r.pending>o&&(e.adler=We(e.adler,r.pending_buf,r.pending-o,o)),r.gzindex=0}r.status=Jx}if(r.status===Jx){if(r.gzhead.name){let o=r.pending,s;do{if(r.pending===r.pending_buf_size){if(r.gzhead.hcrc&&r.pending>o&&(e.adler=We(e.adler,r.pending_buf,r.pending-o,o)),Dt(e),r.pending!==0)return r.last_flush=-1,Qe;o=0}r.gzindex<r.gzhead.name.length?s=r.gzhead.name.charCodeAt(r.gzindex++)&255:s=0,ge(r,s)}while(s!==0);r.gzhead.hcrc&&r.pending>o&&(e.adler=We(e.adler,r.pending_buf,r.pending-o,o)),r.gzindex=0}r.status=Yx}if(r.status===Yx){if(r.gzhead.comment){let o=r.pending,s;do{if(r.pending===r.pending_buf_size){if(r.gzhead.hcrc&&r.pending>o&&(e.adler=We(e.adler,r.pending_buf,r.pending-o,o)),Dt(e),r.pending!==0)return r.last_flush=-1,Qe;o=0}r.gzindex<r.gzhead.comment.length?s=r.gzhead.comment.charCodeAt(r.gzindex++)&255:s=0,ge(r,s)}while(s!==0);r.gzhead.hcrc&&r.pending>o&&(e.adler=We(e.adler,r.pending_buf,r.pending-o,o))}r.status=Xx}if(r.status===Xx){if(r.gzhead.hcrc){if(r.pending+2>r.pending_buf_size&&(Dt(e),r.pending!==0))return r.last_flush=-1,Qe;ge(r,e.adler&255),ge(r,e.adler>>8&255),e.adler=0}if(r.status=jo,Dt(e),r.pending!==0)return r.last_flush=-1,Qe}if(e.avail_in!==0||r.lookahead!==0||t!==Fn&&r.status!==Oc){let o=r.level===0?XP(r,t):r.strategy===mp?u3(r,t):r.strategy===Gq?l3(r,t):Ac[r.level].func(r,t);if((o===Zo||o===Pi)&&(r.status=Oc),o===mt||o===Zo)return e.avail_out===0&&(r.last_flush=-1),Qe;if(o===Ii&&(t===Uq?Fq(r):t!==tP&&(Gx(r,0,0,!1),t===qq&&(Mn(r.head),r.lookahead===0&&(r.strstart=0,r.block_start=0,r.insert=0))),Dt(e),e.avail_out===0))return r.last_flush=-1,Qe}return t!==er?Qe:r.wrap<=0?rP:(r.wrap===2?(ge(r,e.adler&255),ge(r,e.adler>>8&255),ge(r,e.adler>>16&255),ge(r,e.adler>>24&255),ge(r,e.total_in&255),ge(r,e.total_in>>8&255),ge(r,e.total_in>>16&255),ge(r,e.total_in>>24&255)):(Rc(r,e.adler>>>16),Rc(r,e.adler&65535)),Dt(e),r.wrap>0&&(r.wrap=-r.wrap),r.pending!==0?Qe:rP)},"deflate$2"),g3=i(e=>{if(Gc(e))return jr;let t=e.state.status;return e.state=null,t===jo?Do(e,Hq):Qe},"deflateEnd"),y3=i((e,t)=>{let r=t.length;if(Gc(e))return jr;let n=e.state,o=n.wrap;if(o===2||o===1&&n.status!==Ti||n.lookahead)return jr;if(o===1&&(e.adler=qc(e.adler,t,r,0)),n.wrap=0,r>=n.w_size){o===0&&(Mn(n.head),n.strstart=0,n.block_start=0,n.insert=0);let l=new Uint8Array(n.w_size);l.set(t.subarray(r-n.w_size,r),0),t=l,r=n.w_size}let s=e.avail_in,a=e.next_in,c=e.input;for(e.avail_in=r,e.next_in=0,e.input=t,zi(n);n.lookahead>=he;){let l=n.strstart,u=n.lookahead-(he-1);do Lo(n,l),l++;while(--u);n.strstart=l,n.lookahead=he-1,zi(n)}return n.strstart+=n.lookahead,n.block_start=n.strstart,n.insert=n.lookahead,n.lookahead=0,n.match_length=n.prev_length=he-1,n.match_available=0,e.next_in=a,e.input=c,e.avail_in=s,n.wrap=o,Qe},"deflateSetDictionary"),x3=m3,_3=tR,v3=eR,w3=QP,b3=f3,S3=h3,k3=g3,$3=y3,E3="pako deflate (from Nodeca project)",Dc={deflateInit:x3,deflateInit2:_3,deflateReset:v3,deflateResetKeep:w3,deflateSetHeader:b3,deflate:S3,deflateEnd:k3,deflateSetDictionary:$3,deflateInfo:E3},N3=i((e,t)=>Object.prototype.hasOwnProperty.call(e,t),"_has"),T3=i(function(e){let t=Array.prototype.slice.call(arguments,1);for(;t.length;){let r=t.shift();if(r){if(typeof r!="object")throw new TypeError(r+"must be non-object");for(let n in r)N3(r,n)&&(e[n]=r[n])}}return e},"assign"),z3=i(e=>{let t=0;for(let n=0,o=e.length;n<o;n++)t+=e[n].length;let r=new Uint8Array(t);for(let n=0,o=0,s=e.length;n<s;n++){let a=e[n];r.set(a,o),o+=a.length}return r},"flattenChunks"),kp={assign:T3,flattenChunks:z3},rR=!0;try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{rR=!1}var Hc=new Uint8Array(256);for(let e=0;e<256;e++)Hc[e]=e>=252?6:e>=248?5:e>=240?4:e>=224?3:e>=192?2:1;Hc[254]=Hc[255]=1;var C3=i(e=>{if(typeof TextEncoder=="function"&&TextEncoder.prototype.encode)return new TextEncoder().encode(e);let t,r,n,o,s,a=e.length,c=0;for(o=0;o<a;o++)r=e.charCodeAt(o),(r&64512)===55296&&o+1<a&&(n=e.charCodeAt(o+1),(n&64512)===56320&&(r=65536+(r-55296<<10)+(n-56320),o++)),c+=r<128?1:r<2048?2:r<65536?3:4;for(t=new Uint8Array(c),s=0,o=0;s<c;o++)r=e.charCodeAt(o),(r&64512)===55296&&o+1<a&&(n=e.charCodeAt(o+1),(n&64512)===56320&&(r=65536+(r-55296<<10)+(n-56320),o++)),r<128?t[s++]=r:r<2048?(t[s++]=192|r>>>6,t[s++]=128|r&63):r<65536?(t[s++]=224|r>>>12,t[s++]=128|r>>>6&63,t[s++]=128|r&63):(t[s++]=240|r>>>18,t[s++]=128|r>>>12&63,t[s++]=128|r>>>6&63,t[s++]=128|r&63);return t},"string2buf"),I3=i((e,t)=>{if(t<65534&&e.subarray&&rR)return String.fromCharCode.apply(null,e.length===t?e:e.subarray(0,t));let r="";for(let n=0;n<t;n++)r+=String.fromCharCode(e[n]);return r},"buf2binstring"),P3=i((e,t)=>{let r=t||e.length;if(typeof TextDecoder=="function"&&TextDecoder.prototype.decode)return new TextDecoder().decode(e.subarray(0,t));let n,o,s=new Array(r*2);for(o=0,n=0;n<r;){let a=e[n++];if(a<128){s[o++]=a;continue}let c=Hc[a];if(c>4){s[o++]=65533,n+=c-1;continue}for(a&=c===2?31:c===3?15:7;c>1&&n<r;)a=a<<6|e[n++]&63,c--;if(c>1){s[o++]=65533;continue}a<65536?s[o++]=a:(a-=65536,s[o++]=55296|a>>10&1023,s[o++]=56320|a&1023)}return I3(s,o)},"buf2string"),R3=i((e,t)=>{t=t||e.length,t>e.length&&(t=e.length);let r=t-1;for(;r>=0&&(e[r]&192)===128;)r--;return r<0||r===0?t:r+Hc[e[r]]>t?r:t},"utf8border"),Bc={string2buf:C3,buf2string:P3,utf8border:R3};function O3(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}i(O3,"ZStream");var nR=O3,oR=Object.prototype.toString,{Z_NO_FLUSH:A3,Z_SYNC_FLUSH:j3,Z_FULL_FLUSH:D3,Z_FINISH:M3,Z_OK:wp,Z_STREAM_END:Z3,Z_DEFAULT_COMPRESSION:L3,Z_DEFAULT_STRATEGY:F3,Z_DEFLATED:U3}=Uo,q3={level:L3,method:U3,chunkSize:16384,windowBits:15,memLevel:8,strategy:F3,legacyHash:!0};function Wc(e){this.options=kp.assign({},q3,e||{});let t=this.options;t.raw&&t.windowBits>0?t.windowBits=-t.windowBits:t.gzip&&t.windowBits>0&&t.windowBits<16&&(t.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new nR,this.strm.avail_out=0;let r=Dc.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy,t.legacyHash);if(r!==wp)throw new Error(Mo[r]);if(t.header&&Dc.deflateSetHeader(this.strm,t.header),t.dictionary){let n;if(typeof t.dictionary=="string"?n=Bc.string2buf(t.dictionary):oR.call(t.dictionary)==="[object ArrayBuffer]"?n=new Uint8Array(t.dictionary):n=t.dictionary,r=Dc.deflateSetDictionary(this.strm,n),r!==wp)throw new Error(Mo[r]);this._dict_set=!0}}i(Wc,"Deflate$1");Wc.prototype.push=function(e,t){let r=this.strm,n=this.options.chunkSize,o,s;if(this.ended)return!1;for(t===~~t?s=t:s=t===!0?M3:A3,typeof e=="string"?r.input=Bc.string2buf(e):oR.call(e)==="[object ArrayBuffer]"?r.input=new Uint8Array(e):r.input=e,r.next_in=0,r.avail_in=r.input.length;;){if(r.avail_out===0&&(r.output=new Uint8Array(n),r.next_out=0,r.avail_out=n),(s===j3||s===D3)&&r.avail_out<=6){this.onData(r.output.subarray(0,r.next_out)),r.avail_out=0;continue}if(o=Dc.deflate(r,s),o===Z3)return r.next_out>0&&this.onData(r.output.subarray(0,r.next_out)),o=Dc.deflateEnd(this.strm),this.onEnd(o),this.ended=!0,o===wp;if(r.avail_out===0){this.onData(r.output);continue}if(s>0&&r.next_out>0){this.onData(r.output.subarray(0,r.next_out)),r.avail_out=0;continue}if(r.avail_in===0)break}return!0};Wc.prototype.onData=function(e){this.chunks.push(e)};Wc.prototype.onEnd=function(e){e===wp&&(this.result=kp.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};function i_(e,t){let r=new Wc(t);if(r.push(e,!0),r.err)throw r.msg||Mo[r.err];return r.result}i(i_,"deflate$1");function H3(e,t){return t=t||{},t.raw=!0,i_(e,t)}i(H3,"deflateRaw$1");function B3(e,t){return t=t||{},t.gzip=!0,i_(e,t)}i(B3,"gzip$1");var V3=Wc,G3=i_,W3=H3,K3=B3,J3=Uo,Y3={Deflate:V3,deflate:G3,deflateRaw:W3,gzip:K3,constants:J3},hp=16209,X3=16191,Q3=i(function(t,r){let n,o,s,a,c,l,u,d,p,h,m,g,_,x,v,w,b,S,T,K,A,Y,W,L,X=t.state;n=t.next_in,W=t.input,o=n+(t.avail_in-5),s=t.next_out,L=t.output,a=s-(r-t.avail_out),c=s+(t.avail_out-257),l=X.dmax,u=X.wsize,d=X.whave,p=X.wnext,h=X.window,m=X.hold,g=X.bits,_=X.lencode,x=X.distcode,v=(1<<X.lenbits)-1,w=(1<<X.distbits)-1;e:do{g<15&&(m+=W[n++]<<g,g+=8,m+=W[n++]<<g,g+=8),b=_[m&v];t:for(;;){if(S=b>>>24,m>>>=S,g-=S,S=b>>>16&255,S===0)L[s++]=b&65535;else if(S&16){T=b&65535,S&=15,S&&(g<S&&(m+=W[n++]<<g,g+=8),T+=m&(1<<S)-1,m>>>=S,g-=S),g<15&&(m+=W[n++]<<g,g+=8,m+=W[n++]<<g,g+=8),b=x[m&w];r:for(;;){if(S=b>>>24,m>>>=S,g-=S,S=b>>>16&255,S&16){if(K=b&65535,S&=15,g<S&&(m+=W[n++]<<g,g+=8,g<S&&(m+=W[n++]<<g,g+=8)),K+=m&(1<<S)-1,K>l){t.msg="invalid distance too far back",X.mode=hp;break e}if(m>>>=S,g-=S,S=s-a,K>S){if(S=K-S,S>d&&X.sane){t.msg="invalid distance too far back",X.mode=hp;break e}if(A=0,Y=h,p===0){if(A+=u-S,S<T){T-=S;do L[s++]=h[A++];while(--S);A=s-K,Y=L}}else if(p<S){if(A+=u+p-S,S-=p,S<T){T-=S;do L[s++]=h[A++];while(--S);if(A=0,p<T){S=p,T-=S;do L[s++]=h[A++];while(--S);A=s-K,Y=L}}}else if(A+=p-S,S<T){T-=S;do L[s++]=h[A++];while(--S);A=s-K,Y=L}for(;T>2;)L[s++]=Y[A++],L[s++]=Y[A++],L[s++]=Y[A++],T-=3;T&&(L[s++]=Y[A++],T>1&&(L[s++]=Y[A++]))}else{A=s-K;do L[s++]=L[A++],L[s++]=L[A++],L[s++]=L[A++],T-=3;while(T>2);T&&(L[s++]=L[A++],T>1&&(L[s++]=L[A++]))}}else if(S&64){t.msg="invalid distance code",X.mode=hp;break e}else{b=x[(b&65535)+(m&(1<<S)-1)];continue r}break}}else if(S&64)if(S&32){X.mode=X3;break e}else{t.msg="invalid literal/length code",X.mode=hp;break e}else{b=_[(b&65535)+(m&(1<<S)-1)];continue t}break}}while(n<o&&s<c);T=g>>3,n-=T,g-=T<<3,m&=(1<<g)-1,t.next_in=n,t.next_out=s,t.avail_in=n<o?5+(o-n):5-(n-o),t.avail_out=s<c?257+(c-s):257-(s-c),X.hold=m,X.bits=g},"inflate_fast"),$i=15,oP=852,sP=592,iP=0,Dx=1,aP=2,eH=new Uint16Array([3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0]),tH=new Uint8Array([16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,199,75]),rH=new Uint16Array([1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0]),nH=new Uint8Array([16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64]),oH=i((e,t,r,n,o,s,a,c)=>{let l=c.bits,u=0,d=0,p=0,h=0,m=0,g=0,_=0,x=0,v=0,w=0,b,S,T,K,A,Y=null,W,L=new Uint16Array($i+1),X=new Uint16Array($i+1),se=null,ur,be,Re;for(u=0;u<=$i;u++)L[u]=0;for(d=0;d<n;d++)L[t[r+d]]++;for(m=l,h=$i;h>=1&&L[h]===0;h--);if(m>h&&(m=h),h===0)return o[s++]=1<<24|64<<16|0,o[s++]=1<<24|64<<16|0,c.bits=1,0;for(p=1;p<h&&L[p]===0;p++);for(m<p&&(m=p),x=1,u=1;u<=$i;u++)if(x<<=1,x-=L[u],x<0)return-1;if(x>0&&(e===iP||h!==1))return-1;for(X[1]=0,u=1;u<$i;u++)X[u+1]=X[u]+L[u];for(d=0;d<n;d++)t[r+d]!==0&&(a[X[t[r+d]]++]=d);if(e===iP?(Y=se=a,W=20):e===Dx?(Y=eH,se=tH,W=257):(Y=rH,se=nH,W=0),w=0,d=0,u=p,A=s,g=m,_=0,T=-1,v=1<<m,K=v-1,e===Dx&&v>oP||e===aP&&v>sP)return 1;for(;;){ur=u-_,a[d]+1<W?(be=0,Re=a[d]):a[d]>=W?(be=se[a[d]-W],Re=Y[a[d]-W]):(be=96,Re=0),b=1<<u-_,S=1<<g,p=S;do S-=b,o[A+(w>>_)+S]=ur<<24|be<<16|Re|0;while(S!==0);for(b=1<<u-1;w&b;)b>>=1;if(b!==0?(w&=b-1,w+=b):w=0,d++,--L[u]===0){if(u===h)break;u=t[r+a[d]]}if(u>m&&(w&K)!==T){for(_===0&&(_=m),A+=p,g=u-_,x=1<<g;g+_<h&&(x-=L[g+_],!(x<=0));)g++,x<<=1;if(v+=1<<g,e===Dx&&v>oP||e===aP&&v>sP)return 1;T=w&K,o[T]=m<<24|g<<16|A-s|0}}return w!==0&&(o[A+w]=u-_<<24|64<<16|0),c.bits=m,0},"inflate_table"),Mc=oH,sH=0,sR=1,iR=2,{Z_FINISH:cP,Z_BLOCK:iH,Z_TREES:gp,Z_OK:Fo,Z_STREAM_END:aH,Z_NEED_DICT:cH,Z_STREAM_ERROR:tr,Z_DATA_ERROR:aR,Z_MEM_ERROR:cR,Z_BUF_ERROR:lH,Z_DEFLATED:lP}=Uo,$p=16180,uP=16181,dP=16182,pP=16183,fP=16184,mP=16185,hP=16186,gP=16187,yP=16188,xP=16189,bp=16190,mn=16191,Mx=16192,_P=16193,Zx=16194,vP=16195,wP=16196,bP=16197,SP=16198,yp=16199,xp=16200,kP=16201,$P=16202,EP=16203,NP=16204,TP=16205,Lx=16206,zP=16207,CP=16208,Ae=16209,lR=16210,uR=16211,uH=852,dH=592,pH=15,fH=pH,IP=i(e=>(e>>>24&255)+(e>>>8&65280)+((e&65280)<<8)+((e&255)<<24),"zswap32");function mH(){this.strm=null,this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}i(mH,"InflateState");var qo=i(e=>{if(!e)return 1;let t=e.state;return!t||t.strm!==e||t.mode<$p||t.mode>uR?1:0},"inflateStateCheck"),dR=i(e=>{if(qo(e))return tr;let t=e.state;return e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=t.wrap&1),t.mode=$p,t.last=0,t.havedict=0,t.flags=-1,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new Int32Array(uH),t.distcode=t.distdyn=new Int32Array(dH),t.sane=1,t.back=-1,Fo},"inflateResetKeep"),pR=i(e=>{if(qo(e))return tr;let t=e.state;return t.wsize=0,t.whave=0,t.wnext=0,dR(e)},"inflateReset"),fR=i((e,t)=>{let r;if(qo(e))return tr;let n=e.state;return t<0?(r=0,t=-t):(r=(t>>4)+5,t<48&&(t&=15)),t&&(t<8||t>15)?tr:(n.window!==null&&n.wbits!==t&&(n.window=null),n.wrap=r,n.wbits=t,pR(e))},"inflateReset2"),mR=i((e,t)=>{if(!e)return tr;let r=new mH;e.state=r,r.strm=e,r.window=null,r.mode=$p;let n=fR(e,t);return n!==Fo&&(e.state=null),n},"inflateInit2"),hH=i(e=>mR(e,fH),"inflateInit"),PP=!0,Fx,Ux,gH=i(e=>{if(PP){Fx=new Int32Array(512),Ux=new Int32Array(32);let t=0;for(;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for(Mc(sR,e.lens,0,288,Fx,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;Mc(iR,e.lens,0,32,Ux,0,e.work,{bits:5}),PP=!1}e.lencode=Fx,e.lenbits=9,e.distcode=Ux,e.distbits=5},"fixedtables"),hR=i((e,t,r,n)=>{let o,s=e.state;return s.window===null&&(s.window=new Uint8Array(1<<s.wbits)),s.wsize===0&&(s.wsize=1<<s.wbits,s.wnext=0,s.whave=0),n>=s.wsize?(s.window.set(t.subarray(r-s.wsize,r),0),s.wnext=0,s.whave=s.wsize):(o=s.wsize-s.wnext,o>n&&(o=n),s.window.set(t.subarray(r-n,r-n+o),s.wnext),n-=o,n?(s.window.set(t.subarray(r-n,r),0),s.wnext=n,s.whave=s.wsize):(s.wnext+=o,s.wnext===s.wsize&&(s.wnext=0),s.whave<s.wsize&&(s.whave+=o))),0},"updatewindow"),yH=i((e,t)=>{let r,n,o,s,a,c,l,u,d,p,h,m,g,_,x=0,v,w,b,S,T,K,A,Y,W=new Uint8Array(4),L,X,se=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(qo(e)||!e.output||!e.input&&e.avail_in!==0)return tr;r=e.state,r.mode===mn&&(r.mode=Mx),a=e.next_out,o=e.output,l=e.avail_out,s=e.next_in,n=e.input,c=e.avail_in,u=r.hold,d=r.bits,p=c,h=l,Y=Fo;e:for(;;)switch(r.mode){case $p:if(r.wrap===0){r.mode=Mx;break}for(;d<16;){if(c===0)break e;c--,u+=n[s++]<<d,d+=8}if(r.wrap&2&&u===35615){r.wbits===0&&(r.wbits=15),r.check=0,W[0]=u&255,W[1]=u>>>8&255,r.check=We(r.check,W,2,0),u=0,d=0,r.mode=uP;break}if(r.head&&(r.head.done=!1),!(r.wrap&1)||(((u&255)<<8)+(u>>8))%31){e.msg="incorrect header check",r.mode=Ae;break}if((u&15)!==lP){e.msg="unknown compression method",r.mode=Ae;break}if(u>>>=4,d-=4,A=(u&15)+8,r.wbits===0&&(r.wbits=A),A>15||A>r.wbits){e.msg="invalid window size",r.mode=Ae;break}r.dmax=1<<r.wbits,r.flags=0,e.adler=r.check=1,r.mode=u&512?xP:mn,u=0,d=0;break;case uP:for(;d<16;){if(c===0)break e;c--,u+=n[s++]<<d,d+=8}if(r.flags=u,(r.flags&255)!==lP){e.msg="unknown compression method",r.mode=Ae;break}if(r.flags&57344){e.msg="unknown header flags set",r.mode=Ae;break}r.head&&(r.head.text=u>>8&1),r.flags&512&&r.wrap&4&&(W[0]=u&255,W[1]=u>>>8&255,r.check=We(r.check,W,2,0)),u=0,d=0,r.mode=dP;case dP:for(;d<32;){if(c===0)break e;c--,u+=n[s++]<<d,d+=8}r.head&&(r.head.time=u),r.flags&512&&r.wrap&4&&(W[0]=u&255,W[1]=u>>>8&255,W[2]=u>>>16&255,W[3]=u>>>24&255,r.check=We(r.check,W,4,0)),u=0,d=0,r.mode=pP;case pP:for(;d<16;){if(c===0)break e;c--,u+=n[s++]<<d,d+=8}r.head&&(r.head.xflags=u&255,r.head.os=u>>8),r.flags&512&&r.wrap&4&&(W[0]=u&255,W[1]=u>>>8&255,r.check=We(r.check,W,2,0)),u=0,d=0,r.mode=fP;case fP:if(r.flags&1024){for(;d<16;){if(c===0)break e;c--,u+=n[s++]<<d,d+=8}r.length=u,r.head&&(r.head.extra_len=u),r.flags&512&&r.wrap&4&&(W[0]=u&255,W[1]=u>>>8&255,r.check=We(r.check,W,2,0)),u=0,d=0}else r.head&&(r.head.extra=null);r.mode=mP;case mP:if(r.flags&1024&&(m=r.length,m>c&&(m=c),m&&(r.head&&(A=r.head.extra_len-r.length,r.head.extra||(r.head.extra=new Uint8Array(r.head.extra_len)),r.head.extra.set(n.subarray(s,s+m),A)),r.flags&512&&r.wrap&4&&(r.check=We(r.check,n,m,s)),c-=m,s+=m,r.length-=m),r.length))break e;r.length=0,r.mode=hP;case hP:if(r.flags&2048){if(c===0)break e;m=0;do A=n[s+m++],r.head&&A&&r.length<65536&&(r.head.name+=String.fromCharCode(A));while(A&&m<c);if(r.flags&512&&r.wrap&4&&(r.check=We(r.check,n,m,s)),c-=m,s+=m,A)break e}else r.head&&(r.head.name=null);r.length=0,r.mode=gP;case gP:if(r.flags&4096){if(c===0)break e;m=0;do A=n[s+m++],r.head&&A&&r.length<65536&&(r.head.comment+=String.fromCharCode(A));while(A&&m<c);if(r.flags&512&&r.wrap&4&&(r.check=We(r.check,n,m,s)),c-=m,s+=m,A)break e}else r.head&&(r.head.comment=null);r.mode=yP;case yP:if(r.flags&512){for(;d<16;){if(c===0)break e;c--,u+=n[s++]<<d,d+=8}if(r.wrap&4&&u!==(r.check&65535)){e.msg="header crc mismatch",r.mode=Ae;break}u=0,d=0}r.head&&(r.head.hcrc=r.flags>>9&1,r.head.done=!0),e.adler=r.check=0,r.mode=mn;break;case xP:for(;d<32;){if(c===0)break e;c--,u+=n[s++]<<d,d+=8}e.adler=r.check=IP(u),u=0,d=0,r.mode=bp;case bp:if(r.havedict===0)return e.next_out=a,e.avail_out=l,e.next_in=s,e.avail_in=c,r.hold=u,r.bits=d,cH;e.adler=r.check=1,r.mode=mn;case mn:if(t===iH||t===gp)break e;case Mx:if(r.last){u>>>=d&7,d-=d&7,r.mode=Lx;break}for(;d<3;){if(c===0)break e;c--,u+=n[s++]<<d,d+=8}switch(r.last=u&1,u>>>=1,d-=1,u&3){case 0:r.mode=_P;break;case 1:if(gH(r),r.mode=yp,t===gp){u>>>=2,d-=2;break e}break;case 2:r.mode=wP;break;case 3:e.msg="invalid block type",r.mode=Ae}u>>>=2,d-=2;break;case _P:for(u>>>=d&7,d-=d&7;d<32;){if(c===0)break e;c--,u+=n[s++]<<d,d+=8}if((u&65535)!==(u>>>16^65535)){e.msg="invalid stored block lengths",r.mode=Ae;break}if(r.length=u&65535,u=0,d=0,r.mode=Zx,t===gp)break e;case Zx:r.mode=vP;case vP:if(m=r.length,m){if(m>c&&(m=c),m>l&&(m=l),m===0)break e;o.set(n.subarray(s,s+m),a),c-=m,s+=m,l-=m,a+=m,r.length-=m;break}r.mode=mn;break;case wP:for(;d<14;){if(c===0)break e;c--,u+=n[s++]<<d,d+=8}if(r.nlen=(u&31)+257,u>>>=5,d-=5,r.ndist=(u&31)+1,u>>>=5,d-=5,r.ncode=(u&15)+4,u>>>=4,d-=4,r.nlen>286||r.ndist>30){e.msg="too many length or distance symbols",r.mode=Ae;break}r.have=0,r.mode=bP;case bP:for(;r.have<r.ncode;){for(;d<3;){if(c===0)break e;c--,u+=n[s++]<<d,d+=8}r.lens[se[r.have++]]=u&7,u>>>=3,d-=3}for(;r.have<19;)r.lens[se[r.have++]]=0;if(r.lencode=r.lendyn,r.lenbits=7,L={bits:r.lenbits},Y=Mc(sH,r.lens,0,19,r.lencode,0,r.work,L),r.lenbits=L.bits,Y){e.msg="invalid code lengths set",r.mode=Ae;break}r.have=0,r.mode=SP;case SP:for(;r.have<r.nlen+r.ndist;){for(;x=r.lencode[u&(1<<r.lenbits)-1],v=x>>>24,w=x>>>16&255,b=x&65535,!(v<=d);){if(c===0)break e;c--,u+=n[s++]<<d,d+=8}if(b<16)u>>>=v,d-=v,r.lens[r.have++]=b;else{if(b===16){for(X=v+2;d<X;){if(c===0)break e;c--,u+=n[s++]<<d,d+=8}if(u>>>=v,d-=v,r.have===0){e.msg="invalid bit length repeat",r.mode=Ae;break}A=r.lens[r.have-1],m=3+(u&3),u>>>=2,d-=2}else if(b===17){for(X=v+3;d<X;){if(c===0)break e;c--,u+=n[s++]<<d,d+=8}u>>>=v,d-=v,A=0,m=3+(u&7),u>>>=3,d-=3}else{for(X=v+7;d<X;){if(c===0)break e;c--,u+=n[s++]<<d,d+=8}u>>>=v,d-=v,A=0,m=11+(u&127),u>>>=7,d-=7}if(r.have+m>r.nlen+r.ndist){e.msg="invalid bit length repeat",r.mode=Ae;break}for(;m--;)r.lens[r.have++]=A}}if(r.mode===Ae)break;if(r.lens[256]===0){e.msg="invalid code -- missing end-of-block",r.mode=Ae;break}if(r.lenbits=9,L={bits:r.lenbits},Y=Mc(sR,r.lens,0,r.nlen,r.lencode,0,r.work,L),r.lenbits=L.bits,Y){e.msg="invalid literal/lengths set",r.mode=Ae;break}if(r.distbits=6,r.distcode=r.distdyn,L={bits:r.distbits},Y=Mc(iR,r.lens,r.nlen,r.ndist,r.distcode,0,r.work,L),r.distbits=L.bits,Y){e.msg="invalid distances set",r.mode=Ae;break}if(r.mode=yp,t===gp)break e;case yp:r.mode=xp;case xp:if(c>=6&&l>=258){e.next_out=a,e.avail_out=l,e.next_in=s,e.avail_in=c,r.hold=u,r.bits=d,Q3(e,h),a=e.next_out,o=e.output,l=e.avail_out,s=e.next_in,n=e.input,c=e.avail_in,u=r.hold,d=r.bits,r.mode===mn&&(r.back=-1);break}for(r.back=0;x=r.lencode[u&(1<<r.lenbits)-1],v=x>>>24,w=x>>>16&255,b=x&65535,!(v<=d);){if(c===0)break e;c--,u+=n[s++]<<d,d+=8}if(w&&!(w&240)){for(S=v,T=w,K=b;x=r.lencode[K+((u&(1<<S+T)-1)>>S)],v=x>>>24,w=x>>>16&255,b=x&65535,!(S+v<=d);){if(c===0)break e;c--,u+=n[s++]<<d,d+=8}u>>>=S,d-=S,r.back+=S}if(u>>>=v,d-=v,r.back+=v,r.length=b,w===0){r.mode=TP;break}if(w&32){r.back=-1,r.mode=mn;break}if(w&64){e.msg="invalid literal/length code",r.mode=Ae;break}r.extra=w&15,r.mode=kP;case kP:if(r.extra){for(X=r.extra;d<X;){if(c===0)break e;c--,u+=n[s++]<<d,d+=8}r.length+=u&(1<<r.extra)-1,u>>>=r.extra,d-=r.extra,r.back+=r.extra}r.was=r.length,r.mode=$P;case $P:for(;x=r.distcode[u&(1<<r.distbits)-1],v=x>>>24,w=x>>>16&255,b=x&65535,!(v<=d);){if(c===0)break e;c--,u+=n[s++]<<d,d+=8}if(!(w&240)){for(S=v,T=w,K=b;x=r.distcode[K+((u&(1<<S+T)-1)>>S)],v=x>>>24,w=x>>>16&255,b=x&65535,!(S+v<=d);){if(c===0)break e;c--,u+=n[s++]<<d,d+=8}u>>>=S,d-=S,r.back+=S}if(u>>>=v,d-=v,r.back+=v,w&64){e.msg="invalid distance code",r.mode=Ae;break}r.offset=b,r.extra=w&15,r.mode=EP;case EP:if(r.extra){for(X=r.extra;d<X;){if(c===0)break e;c--,u+=n[s++]<<d,d+=8}r.offset+=u&(1<<r.extra)-1,u>>>=r.extra,d-=r.extra,r.back+=r.extra}if(r.offset>r.dmax){e.msg="invalid distance too far back",r.mode=Ae;break}r.mode=NP;case NP:if(l===0)break e;if(m=h-l,r.offset>m){if(m=r.offset-m,m>r.whave&&r.sane){e.msg="invalid distance too far back",r.mode=Ae;break}m>r.wnext?(m-=r.wnext,g=r.wsize-m):g=r.wnext-m,m>r.length&&(m=r.length),_=r.window}else _=o,g=a-r.offset,m=r.length;m>l&&(m=l),l-=m,r.length-=m;do o[a++]=_[g++];while(--m);r.length===0&&(r.mode=xp);break;case TP:if(l===0)break e;o[a++]=r.length,l--,r.mode=xp;break;case Lx:if(r.wrap){for(;d<32;){if(c===0)break e;c--,u|=n[s++]<<d,d+=8}if(h-=l,e.total_out+=h,r.total+=h,r.wrap&4&&h&&(e.adler=r.check=r.flags?We(r.check,o,h,a-h):qc(r.check,o,h,a-h)),h=l,r.wrap&4&&(r.flags?u:IP(u))!==r.check){e.msg="incorrect data check",r.mode=Ae;break}u=0,d=0}r.mode=zP;case zP:if(r.wrap&&r.flags){for(;d<32;){if(c===0)break e;c--,u+=n[s++]<<d,d+=8}if(r.wrap&4&&u!==(r.total&4294967295)){e.msg="incorrect length check",r.mode=Ae;break}u=0,d=0}r.mode=CP;case CP:Y=aH;break e;case Ae:Y=aR;break e;case lR:return cR;case uR:default:return tr}return e.next_out=a,e.avail_out=l,e.next_in=s,e.avail_in=c,r.hold=u,r.bits=d,(r.wsize||h!==e.avail_out&&r.mode<Ae&&(r.mode<Lx||t!==cP))&&hR(e,e.output,e.next_out,h-e.avail_out),p-=e.avail_in,h-=e.avail_out,e.total_in+=p,e.total_out+=h,r.total+=h,r.wrap&4&&h&&(e.adler=r.check=r.flags?We(r.check,o,h,e.next_out-h):qc(r.check,o,h,e.next_out-h)),e.data_type=r.bits+(r.last?64:0)+(r.mode===mn?128:0)+(r.mode===yp||r.mode===Zx?256:0),(p===0&&h===0||t===cP)&&Y===Fo&&(Y=lH),Y},"inflate$2"),xH=i(e=>{if(qo(e))return tr;let t=e.state;return t.window&&(t.window=null),e.state=null,Fo},"inflateEnd"),_H=i((e,t)=>{if(qo(e))return tr;let r=e.state;return r.wrap&2?(r.head=t,t.done=!1,Fo):tr},"inflateGetHeader"),vH=i((e,t)=>{let r=t.length,n,o,s;return qo(e)||(n=e.state,n.wrap!==0&&n.mode!==bp)?tr:n.mode===bp&&(o=1,o=qc(o,t,r,0),o!==n.check)?aR:(s=hR(e,t,r,r),s?(n.mode=lR,cR):(n.havedict=1,Fo))},"inflateSetDictionary"),wH=pR,bH=fR,SH=dR,kH=hH,$H=mR,EH=yH,NH=xH,TH=_H,zH=vH,CH="pako inflate (from Nodeca project)",Or={inflateReset:wH,inflateReset2:bH,inflateResetKeep:SH,inflateInit:kH,inflateInit2:$H,inflate:EH,inflateEnd:NH,inflateGetHeader:TH,inflateSetDictionary:zH,inflateInfo:CH};function IH(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}i(IH,"GZheader");var PH=IH,gR=Object.prototype.toString,{Z_NO_FLUSH:RH,Z_FINISH:RP,Z_OK:Ni,Z_STREAM_END:qx,Z_NEED_DICT:Hx,Z_STREAM_ERROR:OH,Z_DATA_ERROR:OP,Z_MEM_ERROR:AH,Z_BUF_ERROR:AP}=Uo,jH={chunkSize:1024*64,windowBits:15,to:""};function Kc(e){this.options=kp.assign({},jH,e||{});let t=this.options;t.raw&&t.windowBits>=0&&t.windowBits<16&&(t.windowBits=-t.windowBits,t.windowBits===0&&(t.windowBits=-15)),t.windowBits>=0&&t.windowBits<16&&!(e&&e.windowBits)&&(t.windowBits+=32),t.windowBits>15&&t.windowBits<48&&(t.windowBits&15||(t.windowBits|=15)),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new nR,this.strm.avail_out=0;let r=Or.inflateInit2(this.strm,t.windowBits);if(r!==Ni)throw new Error(Mo[r]);if(this.header=new PH,Or.inflateGetHeader(this.strm,this.header),t.dictionary&&(typeof t.dictionary=="string"?t.dictionary=Bc.string2buf(t.dictionary):gR.call(t.dictionary)==="[object ArrayBuffer]"&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(r=Or.inflateSetDictionary(this.strm,t.dictionary),r!==Ni)))throw new Error(Mo[r])}i(Kc,"Inflate$1");Kc.prototype.push=function(e,t){let r=this.strm,n=this.options.chunkSize,o=this.options.dictionary,s,a,c;if(this.ended)return!1;for(t===~~t?a=t:a=t===!0?RP:RH,gR.call(e)==="[object ArrayBuffer]"?r.input=new Uint8Array(e):r.input=e,r.next_in=0,r.avail_in=r.input.length;;){for(r.avail_out===0&&(r.output=new Uint8Array(n),r.next_out=0,r.avail_out=n),s=Or.inflate(r,a),s===Hx&&o&&(s=Or.inflateSetDictionary(r,o),s===Ni?s=Or.inflate(r,a):s===OP&&(s=Hx));r.avail_in>0&&s===qx&&r.state.wrap&2&&r.state.flags!==0&&r.input[r.next_in]!==0;)Or.inflateReset(r),s=Or.inflate(r,a);switch(s){case OH:case OP:case Hx:case AH:return this.onEnd(s),this.ended=!0,!1}if(c=r.avail_out,r.next_out&&(r.avail_out===0||s===qx||a>0))if(this.options.to==="string"){let l=Bc.utf8border(r.output,r.next_out),u=r.next_out-l,d=Bc.buf2string(r.output,l);r.next_out=u,r.avail_out=n-u,u&&r.output.set(r.output.subarray(l,l+u),0),this.onData(d)}else this.onData(r.output.length===r.next_out?r.output:r.output.subarray(0,r.next_out)),r.avail_out=0,r.next_out=0;if(!((s===Ni||s===AP)&&c===0)){if(s===qx)return s=Or.inflateEnd(this.strm),this.onEnd(s),this.ended=!0,!0;if(r.avail_in===0){if(a===RP)return s=Or.inflateEnd(this.strm),this.onEnd(s===Ni?AP:s),this.ended=!0,!1;break}}}return!0};Kc.prototype.onData=function(e){this.chunks.push(e)};Kc.prototype.onEnd=function(e){e===Ni&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=kp.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};function a_(e,t){let r=new Kc(t);if(r.push(e,!0),r.err)throw r.msg||Mo[r.err];return r.result}i(a_,"inflate$1");function DH(e,t){return t=t||{},t.raw=!0,a_(e,t)}i(DH,"inflateRaw$1");var MH=Kc,ZH=a_,LH=DH,FH=a_,UH=Uo,qH={Inflate:MH,inflate:ZH,inflateRaw:LH,ungzip:FH,constants:UH},{Deflate:HH,deflate:BH,deflateRaw:VH,gzip:GH}=Y3,{Inflate:WH,inflate:KH,inflateRaw:JH,ungzip:YH}=qH,XH=HH,QH=BH,eB=VH,tB=GH,rB=WH,nB=KH,oB=JH,sB=YH,iB=Uo,yR={Deflate:XH,deflate:QH,deflateRaw:eB,gzip:tB,Inflate:rB,inflate:nB,inflateRaw:oB,ungzip:sB,constants:iB};function aB(e){let t="";for(let n=0;n<e.length;n+=32768){let o=e.subarray(n,n+32768);t+=String.fromCharCode(...o)}return t}i(aB,"bytesToBinaryString");function cB(e){let t={...e};t.basePath&&(t.basePath=new URL(t.basePath).toString());let r=Object.keys(t).sort(),n={};for(let o of r)n[o]=t[o];return n}i(cB,"canonicalizeView");function Ep(e){let t=cB(e),r=JSON.stringify(t),n=yR.deflate(r),o=aB(n);return btoa(o).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}i(Ep,"encodeId");var AR="io.jucie.studio";async function v_(e={},t={}){try{console.log(`
312
+ `),t.verbose&&console.error(r.stack),process.exit(1)}}i(Gv,"buildCommand");import{join as YW,dirname as XW}from"path";import{existsSync as QW}from"fs";import{execSync as cD}from"child_process";import{fileURLToPath as eJ}from"url";import{exec as AV}from"child_process";import{platform as IR}from"os";function Yl(e){let t=IR()==="win32"?`start ${e}`:IR()==="darwin"?`open ${e}`:`xdg-open ${e}`;AV(t)}i(Yl,"openURL");function wa(e){let t=e.length;for(;--t>=0;)e[t]=0}i(wa,"zero$1");var RV=0,xj=1,jV=2,DV=3,MV=258,yw=29,du=256,ou=du+1+yw,ya=30,xw=19,_j=2*ou+1,ys=15,Wv=16,ZV=7,_w=256,vj=16,wj=17,bj=18,cw=new Uint8Array([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0]),mm=new Uint8Array([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13]),LV=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),Sj=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),FV=512,Cn=new Array((ou+2)*2);wa(Cn);var tu=new Array(ya*2);wa(tu);var su=new Array(FV);wa(su);var iu=new Array(MV-DV+1);wa(iu);var vw=new Array(yw);wa(vw);var hm=new Array(ya);wa(hm);function Jv(e,t,r,n,o){this.static_tree=e,this.extra_bits=t,this.extra_base=r,this.elems=n,this.max_length=o,this.has_stree=e&&e.length}i(Jv,"StaticTreeDesc");var kj,$j,Ej;function Kv(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}i(Kv,"TreeDesc");var Nj=i(e=>e<256?su[e]:su[256+(e>>>7)],"d_code"),au=i((e,t)=>{e.pending_buf[e.pending++]=t&255,e.pending_buf[e.pending++]=t>>>8&255},"put_short"),Nt=i((e,t,r)=>{e.bi_valid>Wv-r?(e.bi_buf|=t<<e.bi_valid&65535,au(e,e.bi_buf),e.bi_buf=t>>Wv-e.bi_valid,e.bi_valid+=r-Wv):(e.bi_buf|=t<<e.bi_valid&65535,e.bi_valid+=r)},"send_bits"),Vr=i((e,t,r)=>{Nt(e,r[t*2],r[t*2+1])},"send_code"),Tj=i((e,t)=>{let r=0;do r|=e&1,e>>>=1,r<<=1;while(--t>0);return r>>>1},"bi_reverse"),UV=i(e=>{e.bi_valid===16?(au(e,e.bi_buf),e.bi_buf=0,e.bi_valid=0):e.bi_valid>=8&&(e.pending_buf[e.pending++]=e.bi_buf&255,e.bi_buf>>=8,e.bi_valid-=8)},"bi_flush"),qV=i((e,t)=>{let r=t.dyn_tree,n=t.max_code,o=t.stat_desc.static_tree,s=t.stat_desc.has_stree,a=t.stat_desc.extra_bits,c=t.stat_desc.extra_base,l=t.stat_desc.max_length,u,d,p,m,h,g,_=0;for(m=0;m<=ys;m++)e.bl_count[m]=0;for(r[e.heap[e.heap_max]*2+1]=0,u=e.heap_max+1;u<_j;u++)d=e.heap[u],m=r[r[d*2+1]*2+1]+1,m>l&&(m=l,_++),r[d*2+1]=m,!(d>n)&&(e.bl_count[m]++,h=0,d>=c&&(h=a[d-c]),g=r[d*2],e.opt_len+=g*(m+h),s&&(e.static_len+=g*(o[d*2+1]+h)));if(_!==0){do{for(m=l-1;e.bl_count[m]===0;)m--;e.bl_count[m]--,e.bl_count[m+1]+=2,e.bl_count[l]--,_-=2}while(_>0);for(m=l;m!==0;m--)for(d=e.bl_count[m];d!==0;)p=e.heap[--u],!(p>n)&&(r[p*2+1]!==m&&(e.opt_len+=(m-r[p*2+1])*r[p*2],r[p*2+1]=m),d--)}},"gen_bitlen"),zj=i((e,t,r)=>{let n=new Array(ys+1),o=0,s,a;for(s=1;s<=ys;s++)o=o+r[s-1]<<1,n[s]=o;for(a=0;a<=t;a++){let c=e[a*2+1];c!==0&&(e[a*2]=Tj(n[c]++,c))}},"gen_codes"),BV=i(()=>{let e,t,r,n,o,s=new Array(ys+1);for(r=0,n=0;n<yw-1;n++)for(vw[n]=r,e=0;e<1<<cw[n];e++)iu[r++]=n;for(iu[r-1]=n,o=0,n=0;n<16;n++)for(hm[n]=o,e=0;e<1<<mm[n];e++)su[o++]=n;for(o>>=7;n<ya;n++)for(hm[n]=o<<7,e=0;e<1<<mm[n]-7;e++)su[256+o++]=n;for(t=0;t<=ys;t++)s[t]=0;for(e=0;e<=143;)Cn[e*2+1]=8,e++,s[8]++;for(;e<=255;)Cn[e*2+1]=9,e++,s[9]++;for(;e<=279;)Cn[e*2+1]=7,e++,s[7]++;for(;e<=287;)Cn[e*2+1]=8,e++,s[8]++;for(zj(Cn,ou+1,s),e=0;e<ya;e++)tu[e*2+1]=5,tu[e*2]=Tj(e,5);kj=new Jv(Cn,cw,du+1,ou,ys),$j=new Jv(tu,mm,0,ya,ys),Ej=new Jv(new Array(0),LV,0,xw,ZV)},"tr_static_init"),Cj=i(e=>{let t;for(t=0;t<ou;t++)e.dyn_ltree[t*2]=0;for(t=0;t<ya;t++)e.dyn_dtree[t*2]=0;for(t=0;t<xw;t++)e.bl_tree[t*2]=0;e.dyn_ltree[_w*2]=1,e.opt_len=e.static_len=0,e.sym_next=e.matches=0},"init_block"),Ij=i(e=>{e.bi_valid>8?au(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0},"bi_windup"),PR=i((e,t,r,n)=>{let o=t*2,s=r*2;return e[o]<e[s]||e[o]===e[s]&&n[t]<=n[r]},"smaller"),Yv=i((e,t,r)=>{let n=e.heap[r],o=r<<1;for(;o<=e.heap_len&&(o<e.heap_len&&PR(t,e.heap[o+1],e.heap[o],e.depth)&&o++,!PR(t,n,e.heap[o],e.depth));)e.heap[r]=e.heap[o],r=o,o<<=1;e.heap[r]=n},"pqdownheap"),OR=i((e,t,r)=>{let n,o,s=0,a,c;if(e.sym_next!==0)do n=e.pending_buf[e.sym_buf+s++]&255,n+=(e.pending_buf[e.sym_buf+s++]&255)<<8,o=e.pending_buf[e.sym_buf+s++],n===0?Vr(e,o,t):(a=iu[o],Vr(e,a+du+1,t),c=cw[a],c!==0&&(o-=vw[a],Nt(e,o,c)),n--,a=Nj(n),Vr(e,a,r),c=mm[a],c!==0&&(n-=hm[a],Nt(e,n,c)));while(s<e.sym_next);Vr(e,_w,t)},"compress_block"),lw=i((e,t)=>{let r=t.dyn_tree,n=t.stat_desc.static_tree,o=t.stat_desc.has_stree,s=t.stat_desc.elems,a,c,l=-1,u;for(e.heap_len=0,e.heap_max=_j,a=0;a<s;a++)r[a*2]!==0?(e.heap[++e.heap_len]=l=a,e.depth[a]=0):r[a*2+1]=0;for(;e.heap_len<2;)u=e.heap[++e.heap_len]=l<2?++l:0,r[u*2]=1,e.depth[u]=0,e.opt_len--,o&&(e.static_len-=n[u*2+1]);for(t.max_code=l,a=e.heap_len>>1;a>=1;a--)Yv(e,r,a);u=s;do a=e.heap[1],e.heap[1]=e.heap[e.heap_len--],Yv(e,r,1),c=e.heap[1],e.heap[--e.heap_max]=a,e.heap[--e.heap_max]=c,r[u*2]=r[a*2]+r[c*2],e.depth[u]=(e.depth[a]>=e.depth[c]?e.depth[a]:e.depth[c])+1,r[a*2+1]=r[c*2+1]=u,e.heap[1]=u++,Yv(e,r,1);while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],qV(e,t),zj(r,l,e.bl_count)},"build_tree"),AR=i((e,t,r)=>{let n,o=-1,s,a=t[0*2+1],c=0,l=7,u=4;for(a===0&&(l=138,u=3),t[(r+1)*2+1]=65535,n=0;n<=r;n++)s=a,a=t[(n+1)*2+1],!(++c<l&&s===a)&&(c<u?e.bl_tree[s*2]+=c:s!==0?(s!==o&&e.bl_tree[s*2]++,e.bl_tree[vj*2]++):c<=10?e.bl_tree[wj*2]++:e.bl_tree[bj*2]++,c=0,o=s,a===0?(l=138,u=3):s===a?(l=6,u=3):(l=7,u=4))},"scan_tree"),RR=i((e,t,r)=>{let n,o=-1,s,a=t[0*2+1],c=0,l=7,u=4;for(a===0&&(l=138,u=3),n=0;n<=r;n++)if(s=a,a=t[(n+1)*2+1],!(++c<l&&s===a)){if(c<u)do Vr(e,s,e.bl_tree);while(--c!==0);else s!==0?(s!==o&&(Vr(e,s,e.bl_tree),c--),Vr(e,vj,e.bl_tree),Nt(e,c-3,2)):c<=10?(Vr(e,wj,e.bl_tree),Nt(e,c-3,3)):(Vr(e,bj,e.bl_tree),Nt(e,c-11,7));c=0,o=s,a===0?(l=138,u=3):s===a?(l=6,u=3):(l=7,u=4)}},"send_tree"),HV=i(e=>{let t;for(AR(e,e.dyn_ltree,e.l_desc.max_code),AR(e,e.dyn_dtree,e.d_desc.max_code),lw(e,e.bl_desc),t=xw-1;t>=3&&e.bl_tree[Sj[t]*2+1]===0;t--);return e.opt_len+=3*(t+1)+5+5+4,t},"build_bl_tree"),VV=i((e,t,r,n)=>{let o;for(Nt(e,t-257,5),Nt(e,r-1,5),Nt(e,n-4,4),o=0;o<n;o++)Nt(e,e.bl_tree[Sj[o]*2+1],3);RR(e,e.dyn_ltree,t-1),RR(e,e.dyn_dtree,r-1)},"send_all_trees"),GV=i(e=>{let t=4093624447,r;for(r=0;r<=31;r++,t>>>=1)if(t&1&&e.dyn_ltree[r*2]!==0)return 0;if(e.dyn_ltree[9*2]!==0||e.dyn_ltree[10*2]!==0||e.dyn_ltree[13*2]!==0)return 1;for(r=32;r<du;r++)if(e.dyn_ltree[r*2]!==0)return 1;return 0},"detect_data_type"),jR=!1,WV=i(e=>{jR||(BV(),jR=!0),e.l_desc=new Kv(e.dyn_ltree,kj),e.d_desc=new Kv(e.dyn_dtree,$j),e.bl_desc=new Kv(e.bl_tree,Ej),e.bi_buf=0,e.bi_valid=0,Cj(e)},"_tr_init$1"),Pj=i((e,t,r,n)=>{Nt(e,(RV<<1)+(n?1:0),3),Ij(e),au(e,r),au(e,~r),r&&e.pending_buf.set(e.window.subarray(t,t+r),e.pending),e.pending+=r},"_tr_stored_block$1"),JV=i(e=>{Nt(e,xj<<1,3),Vr(e,_w,Cn),UV(e)},"_tr_align$1"),KV=i((e,t,r,n)=>{let o,s,a=0;e.level>0?(e.strm.data_type===2&&(e.strm.data_type=GV(e)),lw(e,e.l_desc),lw(e,e.d_desc),a=HV(e),o=e.opt_len+3+7>>>3,s=e.static_len+3+7>>>3,s<=o&&(o=s)):o=s=r+5,r+4<=o&&t!==-1?Pj(e,t,r,n):e.strategy===4||s===o?(Nt(e,(xj<<1)+(n?1:0),3),OR(e,Cn,tu)):(Nt(e,(jV<<1)+(n?1:0),3),VV(e,e.l_desc.max_code+1,e.d_desc.max_code+1,a+1),OR(e,e.dyn_ltree,e.dyn_dtree)),Cj(e),n&&Ij(e)},"_tr_flush_block$1"),YV=i((e,t,r)=>(e.pending_buf[e.sym_buf+e.sym_next++]=t,e.pending_buf[e.sym_buf+e.sym_next++]=t>>8,e.pending_buf[e.sym_buf+e.sym_next++]=r,t===0?e.dyn_ltree[r*2]++:(e.matches++,t--,e.dyn_ltree[(iu[r]+du+1)*2]++,e.dyn_dtree[Nj(t)*2]++),e.sym_next===e.sym_end),"_tr_tally$1"),XV=WV,QV=Pj,e8=KV,t8=YV,r8=JV,n8={_tr_init:XV,_tr_stored_block:QV,_tr_flush_block:e8,_tr_tally:t8,_tr_align:r8},o8=i((e,t,r,n)=>{let o=e&65535|0,s=e>>>16&65535|0,a=0;for(;r!==0;){a=r>2e3?2e3:r,r-=a;do o=o+t[n++]|0,s=s+o|0;while(--a);o%=65521,s%=65521}return o|s<<16|0},"adler32"),cu=o8,s8=i(()=>{let e,t=[];for(var r=0;r<256;r++){e=r;for(var n=0;n<8;n++)e=e&1?3988292384^e>>>1:e>>>1;t[r]=e}return t},"makeTable"),i8=new Uint32Array(s8()),a8=i((e,t,r,n)=>{let o=i8,s=n+r;e^=-1;for(let a=n;a<s;a++)e=e>>>8^o[(e^t[a])&255];return e^-1},"crc32"),Ye=a8,vs={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"},ks={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8},{_tr_init:c8,_tr_stored_block:uw,_tr_flush_block:l8,_tr_tally:lo,_tr_align:u8}=n8,{Z_NO_FLUSH:uo,Z_PARTIAL_FLUSH:d8,Z_FULL_FLUSH:p8,Z_FINISH:ar,Z_BLOCK:DR,Z_OK:rt,Z_STREAM_END:MR,Z_STREAM_ERROR:Gr,Z_DATA_ERROR:f8,Z_BUF_ERROR:Xv,Z_DEFAULT_COMPRESSION:m8,Z_FILTERED:h8,Z_HUFFMAN_ONLY:lm,Z_RLE:g8,Z_FIXED:y8,Z_DEFAULT_STRATEGY:x8,Z_UNKNOWN:_8,Z_DEFLATED:xm}=ks,v8=9,w8=15,b8=8,S8=29,k8=256,dw=k8+1+S8,$8=30,E8=19,N8=2*dw+1,T8=15,xe=3,co=258,Wr=co+xe+1,z8=32,_a=42,ww=57,pw=69,fw=73,mw=91,hw=103,xs=113,Ql=666,vt=1,ba=2,ws=3,Sa=4,C8=3,_s=i((e,t)=>(e.msg=vs[t],t),"err"),ZR=i(e=>e*2-(e>4?9:0),"rank"),ao=i(e=>{let t=e.length;for(;--t>=0;)e[t]=0},"zero"),I8=i(e=>{let t,r,n,o=e.w_size;t=e.hash_size,n=t;do r=e.head[--n],e.head[n]=r>=o?r-o:0;while(--t);t=o,n=t;do r=e.prev[--n],e.prev[n]=r>=o?r-o:0;while(--t)},"slide_hash"),bw=i((e,t,r)=>(t<<e.hash_shift^r)&e.hash_mask,"HASH"),bs=i((e,t)=>{let r;if(e.legacy_hash)r=e.ins_h=bw(e,e.ins_h,e.window[t+xe-1]);else{let o=e.window,s=o[t]|o[t+1]<<8|o[t+2]<<16|o[t+3]<<24;r=e.ins_h=Math.imul(s,66521)+66521>>>16&e.hash_mask}let n=e.prev[t&e.w_mask]=e.head[r];return e.head[r]=t,n},"INSERT_STRING"),qt=i(e=>{let t=e.state,r=t.pending;r>e.avail_out&&(r=e.avail_out),r!==0&&(e.output.set(t.pending_buf.subarray(t.pending_out,t.pending_out+r),e.next_out),e.next_out+=r,t.pending_out+=r,e.total_out+=r,e.avail_out-=r,t.pending-=r,t.pending===0&&(t.pending_out=0))},"flush_pending"),Bt=i((e,t)=>{l8(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,qt(e.strm)},"flush_block_only"),ve=i((e,t)=>{e.pending_buf[e.pending++]=t},"put_byte"),Xl=i((e,t)=>{e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=t&255},"putShortMSB"),gw=i((e,t,r,n)=>{let o=e.avail_in;return o>n&&(o=n),o===0?0:(e.avail_in-=o,t.set(e.input.subarray(e.next_in,e.next_in+o),r),e.state.wrap===1?e.adler=cu(e.adler,t,o,r):e.state.wrap===2&&(e.adler=Ye(e.adler,t,o,r)),e.next_in+=o,e.total_in+=o,o)},"read_buf"),Oj=i((e,t)=>{let r=e.max_chain_length,n=e.strstart,o,s,a=e.prev_length,c=e.nice_match,l=e.strstart>e.w_size-Wr?e.strstart-(e.w_size-Wr):0,u=e.window,d=e.w_mask,p=e.prev,m=e.strstart+co,h=u[n+a-1],g=u[n+a];e.prev_length>=e.good_match&&(r>>=2),c>e.lookahead&&(c=e.lookahead);do if(o=t,!(u[o+a]!==g||u[o+a-1]!==h||u[o]!==u[n]||u[++o]!==u[n+1])){n+=2,o++;do;while(u[++n]===u[++o]&&u[++n]===u[++o]&&u[++n]===u[++o]&&u[++n]===u[++o]&&u[++n]===u[++o]&&u[++n]===u[++o]&&u[++n]===u[++o]&&u[++n]===u[++o]&&n<m);if(s=co-(m-n),n=m-co,s>a){if(e.match_start=t,a=s,s>=c)break;h=u[n+a-1],g=u[n+a]}}while((t=p[t&d])>l&&--r!==0);return a<=e.lookahead?a:e.lookahead},"longest_match"),va=i(e=>{let t=e.w_size,r,n,o;do{if(n=e.window_size-e.lookahead-e.strstart,e.strstart>=t+(t-Wr)&&(e.window.set(e.window.subarray(t,t+t-n),0),e.match_start-=t,e.strstart-=t,e.block_start-=t,e.insert>e.strstart&&(e.insert=e.strstart),I8(e),n+=t),e.strm.avail_in===0)break;if(r=gw(e.strm,e.window,e.strstart+e.lookahead,n),e.lookahead+=r,e.legacy_hash){if(e.lookahead+e.insert>=xe)for(o=e.strstart-e.insert,e.ins_h=e.window[o],e.ins_h=bw(e,e.ins_h,e.window[o+1]);e.insert&&(bs(e,o),o++,e.insert--,!(e.lookahead+e.insert<xe)););}else if(e.lookahead+e.insert>xe)for(o=e.strstart-e.insert;e.insert&&(bs(e,o),o++,e.insert--,!(e.lookahead+e.insert<=xe)););}while(e.lookahead<Wr&&e.strm.avail_in!==0)},"fill_window"),Aj=i((e,t)=>{let r=e.pending_buf_size-5>e.w_size?e.w_size:e.pending_buf_size-5,n,o,s,a=0,c=e.strm.avail_in;do{if(n=65535,s=e.bi_valid+42>>3,e.strm.avail_out<s||(s=e.strm.avail_out-s,o=e.strstart-e.block_start,n>o+e.strm.avail_in&&(n=o+e.strm.avail_in),n>s&&(n=s),n<r&&(n===0&&t!==ar||t===uo||n!==o+e.strm.avail_in)))break;a=t===ar&&n===o+e.strm.avail_in?1:0,uw(e,0,0,a),e.pending_buf[e.pending-4]=n,e.pending_buf[e.pending-3]=n>>8,e.pending_buf[e.pending-2]=~n,e.pending_buf[e.pending-1]=~n>>8,qt(e.strm),o&&(o>n&&(o=n),e.strm.output.set(e.window.subarray(e.block_start,e.block_start+o),e.strm.next_out),e.strm.next_out+=o,e.strm.avail_out-=o,e.strm.total_out+=o,e.block_start+=o,n-=o),n&&(gw(e.strm,e.strm.output,e.strm.next_out,n),e.strm.next_out+=n,e.strm.avail_out-=n,e.strm.total_out+=n)}while(a===0);return c-=e.strm.avail_in,c&&(c>=e.w_size?(e.matches=2,e.window.set(e.strm.input.subarray(e.strm.next_in-e.w_size,e.strm.next_in),0),e.strstart=e.w_size,e.insert=e.strstart):(e.window_size-e.strstart<=c&&(e.strstart-=e.w_size,e.window.set(e.window.subarray(e.w_size,e.w_size+e.strstart),0),e.matches<2&&e.matches++,e.insert>e.strstart&&(e.insert=e.strstart)),e.window.set(e.strm.input.subarray(e.strm.next_in-c,e.strm.next_in),e.strstart),e.strstart+=c,e.insert+=c>e.w_size-e.insert?e.w_size-e.insert:c),e.block_start=e.strstart),e.high_water<e.strstart&&(e.high_water=e.strstart),a?Sa:t!==uo&&t!==ar&&e.strm.avail_in===0&&e.strstart===e.block_start?ba:(s=e.window_size-e.strstart,e.strm.avail_in>s&&e.block_start>=e.w_size&&(e.block_start-=e.w_size,e.strstart-=e.w_size,e.window.set(e.window.subarray(e.w_size,e.w_size+e.strstart),0),e.matches<2&&e.matches++,s+=e.w_size,e.insert>e.strstart&&(e.insert=e.strstart)),s>e.strm.avail_in&&(s=e.strm.avail_in),s&&(gw(e.strm,e.window,e.strstart,s),e.strstart+=s,e.insert+=s>e.w_size-e.insert?e.w_size-e.insert:s),e.high_water<e.strstart&&(e.high_water=e.strstart),s=e.bi_valid+42>>3,s=e.pending_buf_size-s>65535?65535:e.pending_buf_size-s,r=s>e.w_size?e.w_size:s,o=e.strstart-e.block_start,(o>=r||(o||t===ar)&&t!==uo&&e.strm.avail_in===0&&o<=s)&&(n=o>s?s:o,a=t===ar&&e.strm.avail_in===0&&n===o?1:0,uw(e,e.block_start,n,a),e.block_start+=n,qt(e.strm)),a?ws:vt)},"deflate_stored"),Qv=i((e,t)=>{let r,n;for(;;){if(e.lookahead<Wr){if(va(e),e.lookahead<Wr&&t===uo)return vt;if(e.lookahead===0)break}if(r=0,e.lookahead>=xe&&(r=bs(e,e.strstart)),r!==0&&e.strstart-r<=e.w_size-Wr&&(e.match_length=Oj(e,r)),e.match_length>=xe)if(n=lo(e,e.strstart-e.match_start,e.match_length-xe),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=xe){e.match_length--;do e.strstart++,r=bs(e,e.strstart);while(--e.match_length!==0);e.strstart++}else e.strstart+=e.match_length,e.match_length=0,e.legacy_hash&&(e.ins_h=e.window[e.strstart],e.ins_h=bw(e,e.ins_h,e.window[e.strstart+1]));else n=lo(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(n&&(Bt(e,!1),e.strm.avail_out===0))return vt}return e.insert=e.strstart<xe-1?e.strstart:xe-1,t===ar?(Bt(e,!0),e.strm.avail_out===0?ws:Sa):e.sym_next&&(Bt(e,!1),e.strm.avail_out===0)?vt:ba},"deflate_fast"),ha=i((e,t)=>{let r,n,o;for(;;){if(e.lookahead<Wr){if(va(e),e.lookahead<Wr&&t===uo)return vt;if(e.lookahead===0)break}if(r=0,e.lookahead>=xe&&(r=bs(e,e.strstart)),e.prev_length=e.match_length,e.prev_match=e.match_start,e.match_length=xe-1,r!==0&&e.prev_length<e.max_lazy_match&&e.strstart-r<=e.w_size-Wr&&(e.match_length=Oj(e,r),e.match_length<=5&&(e.strategy===h8||e.match_length===xe&&e.strstart-e.match_start>4096)&&(e.match_length=xe-1)),e.prev_length>=xe&&e.match_length<=e.prev_length){o=e.strstart+e.lookahead-xe,n=lo(e,e.strstart-1-e.prev_match,e.prev_length-xe),e.lookahead-=e.prev_length-1,e.prev_length-=2;do++e.strstart<=o&&(r=bs(e,e.strstart));while(--e.prev_length!==0);if(e.match_available=0,e.match_length=xe-1,e.strstart++,n&&(Bt(e,!1),e.strm.avail_out===0))return vt}else if(e.match_available){if(n=lo(e,0,e.window[e.strstart-1]),n&&Bt(e,!1),e.strstart++,e.lookahead--,e.strm.avail_out===0)return vt}else e.match_available=1,e.strstart++,e.lookahead--}return e.match_available&&(n=lo(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<xe-1?e.strstart:xe-1,t===ar?(Bt(e,!0),e.strm.avail_out===0?ws:Sa):e.sym_next&&(Bt(e,!1),e.strm.avail_out===0)?vt:ba},"deflate_slow"),P8=i((e,t)=>{let r,n,o,s,a=e.window;for(;;){if(e.lookahead<=co){if(va(e),e.lookahead<=co&&t===uo)return vt;if(e.lookahead===0)break}if(e.match_length=0,e.lookahead>=xe&&e.strstart>0&&(o=e.strstart-1,n=a[o],n===a[++o]&&n===a[++o]&&n===a[++o])){s=e.strstart+co;do;while(n===a[++o]&&n===a[++o]&&n===a[++o]&&n===a[++o]&&n===a[++o]&&n===a[++o]&&n===a[++o]&&n===a[++o]&&o<s);e.match_length=co-(s-o),e.match_length>e.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=xe?(r=lo(e,1,e.match_length-xe),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(r=lo(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),r&&(Bt(e,!1),e.strm.avail_out===0))return vt}return e.insert=0,t===ar?(Bt(e,!0),e.strm.avail_out===0?ws:Sa):e.sym_next&&(Bt(e,!1),e.strm.avail_out===0)?vt:ba},"deflate_rle"),O8=i((e,t)=>{let r;for(;;){if(e.lookahead===0&&(va(e),e.lookahead===0)){if(t===uo)return vt;break}if(e.match_length=0,r=lo(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,r&&(Bt(e,!1),e.strm.avail_out===0))return vt}return e.insert=0,t===ar?(Bt(e,!0),e.strm.avail_out===0?ws:Sa):e.sym_next&&(Bt(e,!1),e.strm.avail_out===0)?vt:ba},"deflate_huff");function Br(e,t,r,n,o){this.good_length=e,this.max_lazy=t,this.nice_length=r,this.max_chain=n,this.func=o}i(Br,"Config");var eu=[new Br(0,0,0,0,Aj),new Br(4,4,8,4,Qv),new Br(4,5,16,8,Qv),new Br(4,6,32,32,Qv),new Br(4,4,16,16,ha),new Br(8,16,32,32,ha),new Br(8,16,128,128,ha),new Br(8,32,128,256,ha),new Br(32,128,258,1024,ha),new Br(32,258,258,4096,ha)],A8=i(e=>{e.window_size=2*e.w_size,ao(e.head),e.max_lazy_match=eu[e.level].max_lazy,e.good_match=eu[e.level].good_length,e.nice_match=eu[e.level].nice_length,e.max_chain_length=eu[e.level].max_chain,e.strstart=0,e.block_start=0,e.lookahead=0,e.insert=0,e.match_length=e.prev_length=xe-1,e.match_available=0,e.ins_h=0},"lm_init");function R8(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=xm,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.legacy_hash=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new Uint16Array(N8*2),this.dyn_dtree=new Uint16Array((2*$8+1)*2),this.bl_tree=new Uint16Array((2*E8+1)*2),ao(this.dyn_ltree),ao(this.dyn_dtree),ao(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(T8+1),this.heap=new Uint16Array(2*dw+1),ao(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(2*dw+1),ao(this.depth),this.sym_buf=0,this.lit_bufsize=0,this.sym_next=0,this.sym_end=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}i(R8,"DeflateState");var pu=i(e=>{if(!e)return 1;let t=e.state;return!t||t.strm!==e||t.status!==_a&&t.status!==ww&&t.status!==pw&&t.status!==fw&&t.status!==mw&&t.status!==hw&&t.status!==xs&&t.status!==Ql?1:0},"deflateStateCheck"),Rj=i(e=>{if(pu(e))return _s(e,Gr);e.total_in=e.total_out=0,e.data_type=_8;let t=e.state;return t.pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=t.wrap===2?ww:t.wrap?_a:xs,e.adler=t.wrap===2?0:1,t.last_flush=-2,c8(t),rt},"deflateResetKeep"),jj=i(e=>{let t=Rj(e);return t===rt&&A8(e.state),t},"deflateReset"),j8=i((e,t)=>pu(e)||e.state.wrap!==2?Gr:(e.state.gzhead=t,rt),"deflateSetHeader"),Dj=i((e,t,r,n,o,s,a)=>{if(!e)return Gr;let c=1;if(t===m8&&(t=6),n<0?(c=0,n=-n):n>15&&(c=2,n-=16),o<1||o>v8||r!==xm||n<8||n>15||t<0||t>9||s<0||s>y8||n===8&&c!==1)return _s(e,Gr);n===8&&(n=9);let l=new R8;return e.state=l,l.strm=e,l.status=_a,l.wrap=c,l.gzhead=null,l.w_bits=n,l.w_size=1<<l.w_bits,l.w_mask=l.w_size-1,l.legacy_hash=a?1:0,l.hash_bits=o+7,!l.legacy_hash&&l.hash_bits<15&&(l.hash_bits=15),l.hash_size=1<<l.hash_bits,l.hash_mask=l.hash_size-1,l.hash_shift=~~((l.hash_bits+xe-1)/xe),l.window=new Uint8Array(l.w_size*2),l.head=new Uint16Array(l.hash_size),l.prev=new Uint16Array(l.w_size),l.lit_bufsize=1<<o+6,l.pending_buf_size=l.lit_bufsize*4,l.pending_buf=new Uint8Array(l.pending_buf_size),l.sym_buf=l.lit_bufsize,l.sym_end=(l.lit_bufsize-1)*3,l.level=t,l.strategy=s,l.method=r,jj(e)},"deflateInit2"),D8=i((e,t)=>Dj(e,t,xm,w8,b8,x8),"deflateInit"),M8=i((e,t)=>{if(pu(e)||t>DR||t<0)return e?_s(e,Gr):Gr;let r=e.state;if(!e.output||e.avail_in!==0&&!e.input||r.status===Ql&&t!==ar)return _s(e,e.avail_out===0?Xv:Gr);let n=r.last_flush;if(r.last_flush=t,r.pending!==0){if(qt(e),e.avail_out===0)return r.last_flush=-1,rt}else if(e.avail_in===0&&ZR(t)<=ZR(n)&&t!==ar)return _s(e,Xv);if(r.status===Ql&&e.avail_in!==0)return _s(e,Xv);if(r.status===_a&&r.wrap===0&&(r.status=xs),r.status===_a){let o=xm+(r.w_bits-8<<4)<<8,s=-1;if(r.strategy>=lm||r.level<2?s=0:r.level<6?s=1:r.level===6?s=2:s=3,o|=s<<6,r.strstart!==0&&(o|=z8),o+=31-o%31,Xl(r,o),r.strstart!==0&&(Xl(r,e.adler>>>16),Xl(r,e.adler&65535)),e.adler=1,r.status=xs,qt(e),r.pending!==0)return r.last_flush=-1,rt}if(r.status===ww){if(e.adler=0,ve(r,31),ve(r,139),ve(r,8),r.gzhead)ve(r,(r.gzhead.text?1:0)+(r.gzhead.hcrc?2:0)+(r.gzhead.extra?4:0)+(r.gzhead.name?8:0)+(r.gzhead.comment?16:0)),ve(r,r.gzhead.time&255),ve(r,r.gzhead.time>>8&255),ve(r,r.gzhead.time>>16&255),ve(r,r.gzhead.time>>24&255),ve(r,r.level===9?2:r.strategy>=lm||r.level<2?4:0),ve(r,r.gzhead.os&255),r.gzhead.extra&&r.gzhead.extra.length&&(ve(r,r.gzhead.extra.length&255),ve(r,r.gzhead.extra.length>>8&255)),r.gzhead.hcrc&&(e.adler=Ye(e.adler,r.pending_buf,r.pending,0)),r.gzindex=0,r.status=pw;else if(ve(r,0),ve(r,0),ve(r,0),ve(r,0),ve(r,0),ve(r,r.level===9?2:r.strategy>=lm||r.level<2?4:0),ve(r,C8),r.status=xs,qt(e),r.pending!==0)return r.last_flush=-1,rt}if(r.status===pw){if(r.gzhead.extra){let o=r.pending,s=(r.gzhead.extra.length&65535)-r.gzindex;for(;r.pending+s>r.pending_buf_size;){let c=r.pending_buf_size-r.pending;if(r.pending_buf.set(r.gzhead.extra.subarray(r.gzindex,r.gzindex+c),r.pending),r.pending=r.pending_buf_size,r.gzhead.hcrc&&r.pending>o&&(e.adler=Ye(e.adler,r.pending_buf,r.pending-o,o)),r.gzindex+=c,qt(e),r.pending!==0)return r.last_flush=-1,rt;o=0,s-=c}let a=new Uint8Array(r.gzhead.extra);r.pending_buf.set(a.subarray(r.gzindex,r.gzindex+s),r.pending),r.pending+=s,r.gzhead.hcrc&&r.pending>o&&(e.adler=Ye(e.adler,r.pending_buf,r.pending-o,o)),r.gzindex=0}r.status=fw}if(r.status===fw){if(r.gzhead.name){let o=r.pending,s;do{if(r.pending===r.pending_buf_size){if(r.gzhead.hcrc&&r.pending>o&&(e.adler=Ye(e.adler,r.pending_buf,r.pending-o,o)),qt(e),r.pending!==0)return r.last_flush=-1,rt;o=0}r.gzindex<r.gzhead.name.length?s=r.gzhead.name.charCodeAt(r.gzindex++)&255:s=0,ve(r,s)}while(s!==0);r.gzhead.hcrc&&r.pending>o&&(e.adler=Ye(e.adler,r.pending_buf,r.pending-o,o)),r.gzindex=0}r.status=mw}if(r.status===mw){if(r.gzhead.comment){let o=r.pending,s;do{if(r.pending===r.pending_buf_size){if(r.gzhead.hcrc&&r.pending>o&&(e.adler=Ye(e.adler,r.pending_buf,r.pending-o,o)),qt(e),r.pending!==0)return r.last_flush=-1,rt;o=0}r.gzindex<r.gzhead.comment.length?s=r.gzhead.comment.charCodeAt(r.gzindex++)&255:s=0,ve(r,s)}while(s!==0);r.gzhead.hcrc&&r.pending>o&&(e.adler=Ye(e.adler,r.pending_buf,r.pending-o,o))}r.status=hw}if(r.status===hw){if(r.gzhead.hcrc){if(r.pending+2>r.pending_buf_size&&(qt(e),r.pending!==0))return r.last_flush=-1,rt;ve(r,e.adler&255),ve(r,e.adler>>8&255),e.adler=0}if(r.status=xs,qt(e),r.pending!==0)return r.last_flush=-1,rt}if(e.avail_in!==0||r.lookahead!==0||t!==uo&&r.status!==Ql){let o=r.level===0?Aj(r,t):r.strategy===lm?O8(r,t):r.strategy===g8?P8(r,t):eu[r.level].func(r,t);if((o===ws||o===Sa)&&(r.status=Ql),o===vt||o===ws)return e.avail_out===0&&(r.last_flush=-1),rt;if(o===ba&&(t===d8?u8(r):t!==DR&&(uw(r,0,0,!1),t===p8&&(ao(r.head),r.lookahead===0&&(r.strstart=0,r.block_start=0,r.insert=0))),qt(e),e.avail_out===0))return r.last_flush=-1,rt}return t!==ar?rt:r.wrap<=0?MR:(r.wrap===2?(ve(r,e.adler&255),ve(r,e.adler>>8&255),ve(r,e.adler>>16&255),ve(r,e.adler>>24&255),ve(r,e.total_in&255),ve(r,e.total_in>>8&255),ve(r,e.total_in>>16&255),ve(r,e.total_in>>24&255)):(Xl(r,e.adler>>>16),Xl(r,e.adler&65535)),qt(e),r.wrap>0&&(r.wrap=-r.wrap),r.pending!==0?rt:MR)},"deflate$2"),Z8=i(e=>{if(pu(e))return Gr;let t=e.state.status;return e.state=null,t===xs?_s(e,f8):rt},"deflateEnd"),L8=i((e,t)=>{let r=t.length;if(pu(e))return Gr;let n=e.state,o=n.wrap;if(o===2||o===1&&n.status!==_a||n.lookahead)return Gr;if(o===1&&(e.adler=cu(e.adler,t,r,0)),n.wrap=0,r>=n.w_size){o===0&&(ao(n.head),n.strstart=0,n.block_start=0,n.insert=0);let l=new Uint8Array(n.w_size);l.set(t.subarray(r-n.w_size,r),0),t=l,r=n.w_size}let s=e.avail_in,a=e.next_in,c=e.input;for(e.avail_in=r,e.next_in=0,e.input=t,va(n);n.lookahead>=xe;){let l=n.strstart,u=n.lookahead-(xe-1);do bs(n,l),l++;while(--u);n.strstart=l,n.lookahead=xe-1,va(n)}return n.strstart+=n.lookahead,n.block_start=n.strstart,n.insert=n.lookahead,n.lookahead=0,n.match_length=n.prev_length=xe-1,n.match_available=0,e.next_in=a,e.input=c,e.avail_in=s,n.wrap=o,rt},"deflateSetDictionary"),F8=D8,U8=Dj,q8=jj,B8=Rj,H8=j8,V8=M8,G8=Z8,W8=L8,J8="pako deflate (from Nodeca project)",ru={deflateInit:F8,deflateInit2:U8,deflateReset:q8,deflateResetKeep:B8,deflateSetHeader:H8,deflate:V8,deflateEnd:G8,deflateSetDictionary:W8,deflateInfo:J8},K8=i((e,t)=>Object.prototype.hasOwnProperty.call(e,t),"_has"),Y8=i(function(e){let t=Array.prototype.slice.call(arguments,1);for(;t.length;){let r=t.shift();if(r){if(typeof r!="object")throw new TypeError(r+"must be non-object");for(let n in r)K8(r,n)&&(e[n]=r[n])}}return e},"assign"),X8=i(e=>{let t=0;for(let n=0,o=e.length;n<o;n++)t+=e[n].length;let r=new Uint8Array(t);for(let n=0,o=0,s=e.length;n<s;n++){let a=e[n];r.set(a,o),o+=a.length}return r},"flattenChunks"),_m={assign:Y8,flattenChunks:X8},Mj=!0;try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{Mj=!1}var lu=new Uint8Array(256);for(let e=0;e<256;e++)lu[e]=e>=252?6:e>=248?5:e>=240?4:e>=224?3:e>=192?2:1;lu[254]=lu[255]=1;var Q8=i(e=>{if(typeof TextEncoder=="function"&&TextEncoder.prototype.encode)return new TextEncoder().encode(e);let t,r,n,o,s,a=e.length,c=0;for(o=0;o<a;o++)r=e.charCodeAt(o),(r&64512)===55296&&o+1<a&&(n=e.charCodeAt(o+1),(n&64512)===56320&&(r=65536+(r-55296<<10)+(n-56320),o++)),c+=r<128?1:r<2048?2:r<65536?3:4;for(t=new Uint8Array(c),s=0,o=0;s<c;o++)r=e.charCodeAt(o),(r&64512)===55296&&o+1<a&&(n=e.charCodeAt(o+1),(n&64512)===56320&&(r=65536+(r-55296<<10)+(n-56320),o++)),r<128?t[s++]=r:r<2048?(t[s++]=192|r>>>6,t[s++]=128|r&63):r<65536?(t[s++]=224|r>>>12,t[s++]=128|r>>>6&63,t[s++]=128|r&63):(t[s++]=240|r>>>18,t[s++]=128|r>>>12&63,t[s++]=128|r>>>6&63,t[s++]=128|r&63);return t},"string2buf"),eG=i((e,t)=>{if(t<65534&&e.subarray&&Mj)return String.fromCharCode.apply(null,e.length===t?e:e.subarray(0,t));let r="";for(let n=0;n<t;n++)r+=String.fromCharCode(e[n]);return r},"buf2binstring"),tG=i((e,t)=>{let r=t||e.length;if(typeof TextDecoder=="function"&&TextDecoder.prototype.decode)return new TextDecoder().decode(e.subarray(0,t));let n,o,s=new Array(r*2);for(o=0,n=0;n<r;){let a=e[n++];if(a<128){s[o++]=a;continue}let c=lu[a];if(c>4){s[o++]=65533,n+=c-1;continue}for(a&=c===2?31:c===3?15:7;c>1&&n<r;)a=a<<6|e[n++]&63,c--;if(c>1){s[o++]=65533;continue}a<65536?s[o++]=a:(a-=65536,s[o++]=55296|a>>10&1023,s[o++]=56320|a&1023)}return eG(s,o)},"buf2string"),rG=i((e,t)=>{t=t||e.length,t>e.length&&(t=e.length);let r=t-1;for(;r>=0&&(e[r]&192)===128;)r--;return r<0||r===0?t:r+lu[e[r]]>t?r:t},"utf8border"),uu={string2buf:Q8,buf2string:tG,utf8border:rG};function nG(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}i(nG,"ZStream");var Zj=nG,Lj=Object.prototype.toString,{Z_NO_FLUSH:oG,Z_SYNC_FLUSH:sG,Z_FULL_FLUSH:iG,Z_FINISH:aG,Z_OK:gm,Z_STREAM_END:cG,Z_DEFAULT_COMPRESSION:lG,Z_DEFAULT_STRATEGY:uG,Z_DEFLATED:dG}=ks,pG={level:lG,method:dG,chunkSize:16384,windowBits:15,memLevel:8,strategy:uG,legacyHash:!0};function fu(e){this.options=_m.assign({},pG,e||{});let t=this.options;t.raw&&t.windowBits>0?t.windowBits=-t.windowBits:t.gzip&&t.windowBits>0&&t.windowBits<16&&(t.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Zj,this.strm.avail_out=0;let r=ru.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy,t.legacyHash);if(r!==gm)throw new Error(vs[r]);if(t.header&&ru.deflateSetHeader(this.strm,t.header),t.dictionary){let n;if(typeof t.dictionary=="string"?n=uu.string2buf(t.dictionary):Lj.call(t.dictionary)==="[object ArrayBuffer]"?n=new Uint8Array(t.dictionary):n=t.dictionary,r=ru.deflateSetDictionary(this.strm,n),r!==gm)throw new Error(vs[r]);this._dict_set=!0}}i(fu,"Deflate$1");fu.prototype.push=function(e,t){let r=this.strm,n=this.options.chunkSize,o,s;if(this.ended)return!1;for(t===~~t?s=t:s=t===!0?aG:oG,typeof e=="string"?r.input=uu.string2buf(e):Lj.call(e)==="[object ArrayBuffer]"?r.input=new Uint8Array(e):r.input=e,r.next_in=0,r.avail_in=r.input.length;;){if(r.avail_out===0&&(r.output=new Uint8Array(n),r.next_out=0,r.avail_out=n),(s===sG||s===iG)&&r.avail_out<=6){this.onData(r.output.subarray(0,r.next_out)),r.avail_out=0;continue}if(o=ru.deflate(r,s),o===cG)return r.next_out>0&&this.onData(r.output.subarray(0,r.next_out)),o=ru.deflateEnd(this.strm),this.onEnd(o),this.ended=!0,o===gm;if(r.avail_out===0){this.onData(r.output);continue}if(s>0&&r.next_out>0){this.onData(r.output.subarray(0,r.next_out)),r.avail_out=0;continue}if(r.avail_in===0)break}return!0};fu.prototype.onData=function(e){this.chunks.push(e)};fu.prototype.onEnd=function(e){e===gm&&(this.result=_m.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};function Sw(e,t){let r=new fu(t);if(r.push(e,!0),r.err)throw r.msg||vs[r.err];return r.result}i(Sw,"deflate$1");function fG(e,t){return t=t||{},t.raw=!0,Sw(e,t)}i(fG,"deflateRaw$1");function mG(e,t){return t=t||{},t.gzip=!0,Sw(e,t)}i(mG,"gzip$1");var hG=fu,gG=Sw,yG=fG,xG=mG,_G=ks,vG={Deflate:hG,deflate:gG,deflateRaw:yG,gzip:xG,constants:_G},um=16209,wG=16191,bG=i(function(t,r){let n,o,s,a,c,l,u,d,p,m,h,g,_,x,v,b,w,S,E,I,z,M,D,Z,H=t.state;n=t.next_in,D=t.input,o=n+(t.avail_in-5),s=t.next_out,Z=t.output,a=s-(r-t.avail_out),c=s+(t.avail_out-257),l=H.dmax,u=H.wsize,d=H.whave,p=H.wnext,m=H.window,h=H.hold,g=H.bits,_=H.lencode,x=H.distcode,v=(1<<H.lenbits)-1,b=(1<<H.distbits)-1;e:do{g<15&&(h+=D[n++]<<g,g+=8,h+=D[n++]<<g,g+=8),w=_[h&v];t:for(;;){if(S=w>>>24,h>>>=S,g-=S,S=w>>>16&255,S===0)Z[s++]=w&65535;else if(S&16){E=w&65535,S&=15,S&&(g<S&&(h+=D[n++]<<g,g+=8),E+=h&(1<<S)-1,h>>>=S,g-=S),g<15&&(h+=D[n++]<<g,g+=8,h+=D[n++]<<g,g+=8),w=x[h&b];r:for(;;){if(S=w>>>24,h>>>=S,g-=S,S=w>>>16&255,S&16){if(I=w&65535,S&=15,g<S&&(h+=D[n++]<<g,g+=8,g<S&&(h+=D[n++]<<g,g+=8)),I+=h&(1<<S)-1,I>l){t.msg="invalid distance too far back",H.mode=um;break e}if(h>>>=S,g-=S,S=s-a,I>S){if(S=I-S,S>d&&H.sane){t.msg="invalid distance too far back",H.mode=um;break e}if(z=0,M=m,p===0){if(z+=u-S,S<E){E-=S;do Z[s++]=m[z++];while(--S);z=s-I,M=Z}}else if(p<S){if(z+=u+p-S,S-=p,S<E){E-=S;do Z[s++]=m[z++];while(--S);if(z=0,p<E){S=p,E-=S;do Z[s++]=m[z++];while(--S);z=s-I,M=Z}}}else if(z+=p-S,S<E){E-=S;do Z[s++]=m[z++];while(--S);z=s-I,M=Z}for(;E>2;)Z[s++]=M[z++],Z[s++]=M[z++],Z[s++]=M[z++],E-=3;E&&(Z[s++]=M[z++],E>1&&(Z[s++]=M[z++]))}else{z=s-I;do Z[s++]=Z[z++],Z[s++]=Z[z++],Z[s++]=Z[z++],E-=3;while(E>2);E&&(Z[s++]=Z[z++],E>1&&(Z[s++]=Z[z++]))}}else if(S&64){t.msg="invalid distance code",H.mode=um;break e}else{w=x[(w&65535)+(h&(1<<S)-1)];continue r}break}}else if(S&64)if(S&32){H.mode=wG;break e}else{t.msg="invalid literal/length code",H.mode=um;break e}else{w=_[(w&65535)+(h&(1<<S)-1)];continue t}break}}while(n<o&&s<c);E=g>>3,n-=E,g-=E<<3,h&=(1<<g)-1,t.next_in=n,t.next_out=s,t.avail_in=n<o?5+(o-n):5-(n-o),t.avail_out=s<c?257+(c-s):257-(s-c),H.hold=h,H.bits=g},"inflate_fast"),ga=15,LR=852,FR=592,UR=0,ew=1,qR=2,SG=new Uint16Array([3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0]),kG=new Uint8Array([16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,199,75]),$G=new Uint16Array([1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0]),EG=new Uint8Array([16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64]),NG=i((e,t,r,n,o,s,a,c)=>{let l=c.bits,u=0,d=0,p=0,m=0,h=0,g=0,_=0,x=0,v=0,b=0,w,S,E,I,z,M=null,D,Z=new Uint16Array(ga+1),H=new Uint16Array(ga+1),ce=null,J,te,Ve;for(u=0;u<=ga;u++)Z[u]=0;for(d=0;d<n;d++)Z[t[r+d]]++;for(h=l,m=ga;m>=1&&Z[m]===0;m--);if(h>m&&(h=m),m===0)return o[s++]=1<<24|64<<16|0,o[s++]=1<<24|64<<16|0,c.bits=1,0;for(p=1;p<m&&Z[p]===0;p++);for(h<p&&(h=p),x=1,u=1;u<=ga;u++)if(x<<=1,x-=Z[u],x<0)return-1;if(x>0&&(e===UR||m!==1))return-1;for(H[1]=0,u=1;u<ga;u++)H[u+1]=H[u]+Z[u];for(d=0;d<n;d++)t[r+d]!==0&&(a[H[t[r+d]]++]=d);if(e===UR?(M=ce=a,D=20):e===ew?(M=SG,ce=kG,D=257):(M=$G,ce=EG,D=0),b=0,d=0,u=p,z=s,g=h,_=0,E=-1,v=1<<h,I=v-1,e===ew&&v>LR||e===qR&&v>FR)return 1;for(;;){J=u-_,a[d]+1<D?(te=0,Ve=a[d]):a[d]>=D?(te=ce[a[d]-D],Ve=M[a[d]-D]):(te=96,Ve=0),w=1<<u-_,S=1<<g,p=S;do S-=w,o[z+(b>>_)+S]=J<<24|te<<16|Ve|0;while(S!==0);for(w=1<<u-1;b&w;)w>>=1;if(w!==0?(b&=w-1,b+=w):b=0,d++,--Z[u]===0){if(u===m)break;u=t[r+a[d]]}if(u>h&&(b&I)!==E){for(_===0&&(_=h),z+=p,g=u-_,x=1<<g;g+_<m&&(x-=Z[g+_],!(x<=0));)g++,x<<=1;if(v+=1<<g,e===ew&&v>LR||e===qR&&v>FR)return 1;E=b&I,o[E]=h<<24|g<<16|z-s|0}}return b!==0&&(o[z+b]=u-_<<24|64<<16|0),c.bits=h,0},"inflate_table"),nu=NG,TG=0,Fj=1,Uj=2,{Z_FINISH:BR,Z_BLOCK:zG,Z_TREES:dm,Z_OK:Ss,Z_STREAM_END:CG,Z_NEED_DICT:IG,Z_STREAM_ERROR:cr,Z_DATA_ERROR:qj,Z_MEM_ERROR:Bj,Z_BUF_ERROR:PG,Z_DEFLATED:HR}=ks,vm=16180,VR=16181,GR=16182,WR=16183,JR=16184,KR=16185,YR=16186,XR=16187,QR=16188,ej=16189,ym=16190,zn=16191,tw=16192,tj=16193,rw=16194,rj=16195,nj=16196,oj=16197,sj=16198,pm=16199,fm=16200,ij=16201,aj=16202,cj=16203,lj=16204,uj=16205,nw=16206,dj=16207,pj=16208,Me=16209,Hj=16210,Vj=16211,OG=852,AG=592,RG=15,jG=RG,fj=i(e=>(e>>>24&255)+(e>>>8&65280)+((e&65280)<<8)+((e&255)<<24),"zswap32");function DG(){this.strm=null,this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}i(DG,"InflateState");var $s=i(e=>{if(!e)return 1;let t=e.state;return!t||t.strm!==e||t.mode<vm||t.mode>Vj?1:0},"inflateStateCheck"),Gj=i(e=>{if($s(e))return cr;let t=e.state;return e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=t.wrap&1),t.mode=vm,t.last=0,t.havedict=0,t.flags=-1,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new Int32Array(OG),t.distcode=t.distdyn=new Int32Array(AG),t.sane=1,t.back=-1,Ss},"inflateResetKeep"),Wj=i(e=>{if($s(e))return cr;let t=e.state;return t.wsize=0,t.whave=0,t.wnext=0,Gj(e)},"inflateReset"),Jj=i((e,t)=>{let r;if($s(e))return cr;let n=e.state;return t<0?(r=0,t=-t):(r=(t>>4)+5,t<48&&(t&=15)),t&&(t<8||t>15)?cr:(n.window!==null&&n.wbits!==t&&(n.window=null),n.wrap=r,n.wbits=t,Wj(e))},"inflateReset2"),Kj=i((e,t)=>{if(!e)return cr;let r=new DG;e.state=r,r.strm=e,r.window=null,r.mode=vm;let n=Jj(e,t);return n!==Ss&&(e.state=null),n},"inflateInit2"),MG=i(e=>Kj(e,jG),"inflateInit"),mj=!0,ow,sw,ZG=i(e=>{if(mj){ow=new Int32Array(512),sw=new Int32Array(32);let t=0;for(;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for(nu(Fj,e.lens,0,288,ow,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;nu(Uj,e.lens,0,32,sw,0,e.work,{bits:5}),mj=!1}e.lencode=ow,e.lenbits=9,e.distcode=sw,e.distbits=5},"fixedtables"),Yj=i((e,t,r,n)=>{let o,s=e.state;return s.window===null&&(s.window=new Uint8Array(1<<s.wbits)),s.wsize===0&&(s.wsize=1<<s.wbits,s.wnext=0,s.whave=0),n>=s.wsize?(s.window.set(t.subarray(r-s.wsize,r),0),s.wnext=0,s.whave=s.wsize):(o=s.wsize-s.wnext,o>n&&(o=n),s.window.set(t.subarray(r-n,r-n+o),s.wnext),n-=o,n?(s.window.set(t.subarray(r-n,r),0),s.wnext=n,s.whave=s.wsize):(s.wnext+=o,s.wnext===s.wsize&&(s.wnext=0),s.whave<s.wsize&&(s.whave+=o))),0},"updatewindow"),LG=i((e,t)=>{let r,n,o,s,a,c,l,u,d,p,m,h,g,_,x=0,v,b,w,S,E,I,z,M,D=new Uint8Array(4),Z,H,ce=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if($s(e)||!e.output||!e.input&&e.avail_in!==0)return cr;r=e.state,r.mode===zn&&(r.mode=tw),a=e.next_out,o=e.output,l=e.avail_out,s=e.next_in,n=e.input,c=e.avail_in,u=r.hold,d=r.bits,p=c,m=l,M=Ss;e:for(;;)switch(r.mode){case vm:if(r.wrap===0){r.mode=tw;break}for(;d<16;){if(c===0)break e;c--,u+=n[s++]<<d,d+=8}if(r.wrap&2&&u===35615){r.wbits===0&&(r.wbits=15),r.check=0,D[0]=u&255,D[1]=u>>>8&255,r.check=Ye(r.check,D,2,0),u=0,d=0,r.mode=VR;break}if(r.head&&(r.head.done=!1),!(r.wrap&1)||(((u&255)<<8)+(u>>8))%31){e.msg="incorrect header check",r.mode=Me;break}if((u&15)!==HR){e.msg="unknown compression method",r.mode=Me;break}if(u>>>=4,d-=4,z=(u&15)+8,r.wbits===0&&(r.wbits=z),z>15||z>r.wbits){e.msg="invalid window size",r.mode=Me;break}r.dmax=1<<r.wbits,r.flags=0,e.adler=r.check=1,r.mode=u&512?ej:zn,u=0,d=0;break;case VR:for(;d<16;){if(c===0)break e;c--,u+=n[s++]<<d,d+=8}if(r.flags=u,(r.flags&255)!==HR){e.msg="unknown compression method",r.mode=Me;break}if(r.flags&57344){e.msg="unknown header flags set",r.mode=Me;break}r.head&&(r.head.text=u>>8&1),r.flags&512&&r.wrap&4&&(D[0]=u&255,D[1]=u>>>8&255,r.check=Ye(r.check,D,2,0)),u=0,d=0,r.mode=GR;case GR:for(;d<32;){if(c===0)break e;c--,u+=n[s++]<<d,d+=8}r.head&&(r.head.time=u),r.flags&512&&r.wrap&4&&(D[0]=u&255,D[1]=u>>>8&255,D[2]=u>>>16&255,D[3]=u>>>24&255,r.check=Ye(r.check,D,4,0)),u=0,d=0,r.mode=WR;case WR:for(;d<16;){if(c===0)break e;c--,u+=n[s++]<<d,d+=8}r.head&&(r.head.xflags=u&255,r.head.os=u>>8),r.flags&512&&r.wrap&4&&(D[0]=u&255,D[1]=u>>>8&255,r.check=Ye(r.check,D,2,0)),u=0,d=0,r.mode=JR;case JR:if(r.flags&1024){for(;d<16;){if(c===0)break e;c--,u+=n[s++]<<d,d+=8}r.length=u,r.head&&(r.head.extra_len=u),r.flags&512&&r.wrap&4&&(D[0]=u&255,D[1]=u>>>8&255,r.check=Ye(r.check,D,2,0)),u=0,d=0}else r.head&&(r.head.extra=null);r.mode=KR;case KR:if(r.flags&1024&&(h=r.length,h>c&&(h=c),h&&(r.head&&(z=r.head.extra_len-r.length,r.head.extra||(r.head.extra=new Uint8Array(r.head.extra_len)),r.head.extra.set(n.subarray(s,s+h),z)),r.flags&512&&r.wrap&4&&(r.check=Ye(r.check,n,h,s)),c-=h,s+=h,r.length-=h),r.length))break e;r.length=0,r.mode=YR;case YR:if(r.flags&2048){if(c===0)break e;h=0;do z=n[s+h++],r.head&&z&&r.length<65536&&(r.head.name+=String.fromCharCode(z));while(z&&h<c);if(r.flags&512&&r.wrap&4&&(r.check=Ye(r.check,n,h,s)),c-=h,s+=h,z)break e}else r.head&&(r.head.name=null);r.length=0,r.mode=XR;case XR:if(r.flags&4096){if(c===0)break e;h=0;do z=n[s+h++],r.head&&z&&r.length<65536&&(r.head.comment+=String.fromCharCode(z));while(z&&h<c);if(r.flags&512&&r.wrap&4&&(r.check=Ye(r.check,n,h,s)),c-=h,s+=h,z)break e}else r.head&&(r.head.comment=null);r.mode=QR;case QR:if(r.flags&512){for(;d<16;){if(c===0)break e;c--,u+=n[s++]<<d,d+=8}if(r.wrap&4&&u!==(r.check&65535)){e.msg="header crc mismatch",r.mode=Me;break}u=0,d=0}r.head&&(r.head.hcrc=r.flags>>9&1,r.head.done=!0),e.adler=r.check=0,r.mode=zn;break;case ej:for(;d<32;){if(c===0)break e;c--,u+=n[s++]<<d,d+=8}e.adler=r.check=fj(u),u=0,d=0,r.mode=ym;case ym:if(r.havedict===0)return e.next_out=a,e.avail_out=l,e.next_in=s,e.avail_in=c,r.hold=u,r.bits=d,IG;e.adler=r.check=1,r.mode=zn;case zn:if(t===zG||t===dm)break e;case tw:if(r.last){u>>>=d&7,d-=d&7,r.mode=nw;break}for(;d<3;){if(c===0)break e;c--,u+=n[s++]<<d,d+=8}switch(r.last=u&1,u>>>=1,d-=1,u&3){case 0:r.mode=tj;break;case 1:if(ZG(r),r.mode=pm,t===dm){u>>>=2,d-=2;break e}break;case 2:r.mode=nj;break;case 3:e.msg="invalid block type",r.mode=Me}u>>>=2,d-=2;break;case tj:for(u>>>=d&7,d-=d&7;d<32;){if(c===0)break e;c--,u+=n[s++]<<d,d+=8}if((u&65535)!==(u>>>16^65535)){e.msg="invalid stored block lengths",r.mode=Me;break}if(r.length=u&65535,u=0,d=0,r.mode=rw,t===dm)break e;case rw:r.mode=rj;case rj:if(h=r.length,h){if(h>c&&(h=c),h>l&&(h=l),h===0)break e;o.set(n.subarray(s,s+h),a),c-=h,s+=h,l-=h,a+=h,r.length-=h;break}r.mode=zn;break;case nj:for(;d<14;){if(c===0)break e;c--,u+=n[s++]<<d,d+=8}if(r.nlen=(u&31)+257,u>>>=5,d-=5,r.ndist=(u&31)+1,u>>>=5,d-=5,r.ncode=(u&15)+4,u>>>=4,d-=4,r.nlen>286||r.ndist>30){e.msg="too many length or distance symbols",r.mode=Me;break}r.have=0,r.mode=oj;case oj:for(;r.have<r.ncode;){for(;d<3;){if(c===0)break e;c--,u+=n[s++]<<d,d+=8}r.lens[ce[r.have++]]=u&7,u>>>=3,d-=3}for(;r.have<19;)r.lens[ce[r.have++]]=0;if(r.lencode=r.lendyn,r.lenbits=7,Z={bits:r.lenbits},M=nu(TG,r.lens,0,19,r.lencode,0,r.work,Z),r.lenbits=Z.bits,M){e.msg="invalid code lengths set",r.mode=Me;break}r.have=0,r.mode=sj;case sj:for(;r.have<r.nlen+r.ndist;){for(;x=r.lencode[u&(1<<r.lenbits)-1],v=x>>>24,b=x>>>16&255,w=x&65535,!(v<=d);){if(c===0)break e;c--,u+=n[s++]<<d,d+=8}if(w<16)u>>>=v,d-=v,r.lens[r.have++]=w;else{if(w===16){for(H=v+2;d<H;){if(c===0)break e;c--,u+=n[s++]<<d,d+=8}if(u>>>=v,d-=v,r.have===0){e.msg="invalid bit length repeat",r.mode=Me;break}z=r.lens[r.have-1],h=3+(u&3),u>>>=2,d-=2}else if(w===17){for(H=v+3;d<H;){if(c===0)break e;c--,u+=n[s++]<<d,d+=8}u>>>=v,d-=v,z=0,h=3+(u&7),u>>>=3,d-=3}else{for(H=v+7;d<H;){if(c===0)break e;c--,u+=n[s++]<<d,d+=8}u>>>=v,d-=v,z=0,h=11+(u&127),u>>>=7,d-=7}if(r.have+h>r.nlen+r.ndist){e.msg="invalid bit length repeat",r.mode=Me;break}for(;h--;)r.lens[r.have++]=z}}if(r.mode===Me)break;if(r.lens[256]===0){e.msg="invalid code -- missing end-of-block",r.mode=Me;break}if(r.lenbits=9,Z={bits:r.lenbits},M=nu(Fj,r.lens,0,r.nlen,r.lencode,0,r.work,Z),r.lenbits=Z.bits,M){e.msg="invalid literal/lengths set",r.mode=Me;break}if(r.distbits=6,r.distcode=r.distdyn,Z={bits:r.distbits},M=nu(Uj,r.lens,r.nlen,r.ndist,r.distcode,0,r.work,Z),r.distbits=Z.bits,M){e.msg="invalid distances set",r.mode=Me;break}if(r.mode=pm,t===dm)break e;case pm:r.mode=fm;case fm:if(c>=6&&l>=258){e.next_out=a,e.avail_out=l,e.next_in=s,e.avail_in=c,r.hold=u,r.bits=d,bG(e,m),a=e.next_out,o=e.output,l=e.avail_out,s=e.next_in,n=e.input,c=e.avail_in,u=r.hold,d=r.bits,r.mode===zn&&(r.back=-1);break}for(r.back=0;x=r.lencode[u&(1<<r.lenbits)-1],v=x>>>24,b=x>>>16&255,w=x&65535,!(v<=d);){if(c===0)break e;c--,u+=n[s++]<<d,d+=8}if(b&&!(b&240)){for(S=v,E=b,I=w;x=r.lencode[I+((u&(1<<S+E)-1)>>S)],v=x>>>24,b=x>>>16&255,w=x&65535,!(S+v<=d);){if(c===0)break e;c--,u+=n[s++]<<d,d+=8}u>>>=S,d-=S,r.back+=S}if(u>>>=v,d-=v,r.back+=v,r.length=w,b===0){r.mode=uj;break}if(b&32){r.back=-1,r.mode=zn;break}if(b&64){e.msg="invalid literal/length code",r.mode=Me;break}r.extra=b&15,r.mode=ij;case ij:if(r.extra){for(H=r.extra;d<H;){if(c===0)break e;c--,u+=n[s++]<<d,d+=8}r.length+=u&(1<<r.extra)-1,u>>>=r.extra,d-=r.extra,r.back+=r.extra}r.was=r.length,r.mode=aj;case aj:for(;x=r.distcode[u&(1<<r.distbits)-1],v=x>>>24,b=x>>>16&255,w=x&65535,!(v<=d);){if(c===0)break e;c--,u+=n[s++]<<d,d+=8}if(!(b&240)){for(S=v,E=b,I=w;x=r.distcode[I+((u&(1<<S+E)-1)>>S)],v=x>>>24,b=x>>>16&255,w=x&65535,!(S+v<=d);){if(c===0)break e;c--,u+=n[s++]<<d,d+=8}u>>>=S,d-=S,r.back+=S}if(u>>>=v,d-=v,r.back+=v,b&64){e.msg="invalid distance code",r.mode=Me;break}r.offset=w,r.extra=b&15,r.mode=cj;case cj:if(r.extra){for(H=r.extra;d<H;){if(c===0)break e;c--,u+=n[s++]<<d,d+=8}r.offset+=u&(1<<r.extra)-1,u>>>=r.extra,d-=r.extra,r.back+=r.extra}if(r.offset>r.dmax){e.msg="invalid distance too far back",r.mode=Me;break}r.mode=lj;case lj:if(l===0)break e;if(h=m-l,r.offset>h){if(h=r.offset-h,h>r.whave&&r.sane){e.msg="invalid distance too far back",r.mode=Me;break}h>r.wnext?(h-=r.wnext,g=r.wsize-h):g=r.wnext-h,h>r.length&&(h=r.length),_=r.window}else _=o,g=a-r.offset,h=r.length;h>l&&(h=l),l-=h,r.length-=h;do o[a++]=_[g++];while(--h);r.length===0&&(r.mode=fm);break;case uj:if(l===0)break e;o[a++]=r.length,l--,r.mode=fm;break;case nw:if(r.wrap){for(;d<32;){if(c===0)break e;c--,u|=n[s++]<<d,d+=8}if(m-=l,e.total_out+=m,r.total+=m,r.wrap&4&&m&&(e.adler=r.check=r.flags?Ye(r.check,o,m,a-m):cu(r.check,o,m,a-m)),m=l,r.wrap&4&&(r.flags?u:fj(u))!==r.check){e.msg="incorrect data check",r.mode=Me;break}u=0,d=0}r.mode=dj;case dj:if(r.wrap&&r.flags){for(;d<32;){if(c===0)break e;c--,u+=n[s++]<<d,d+=8}if(r.wrap&4&&u!==(r.total&4294967295)){e.msg="incorrect length check",r.mode=Me;break}u=0,d=0}r.mode=pj;case pj:M=CG;break e;case Me:M=qj;break e;case Hj:return Bj;case Vj:default:return cr}return e.next_out=a,e.avail_out=l,e.next_in=s,e.avail_in=c,r.hold=u,r.bits=d,(r.wsize||m!==e.avail_out&&r.mode<Me&&(r.mode<nw||t!==BR))&&Yj(e,e.output,e.next_out,m-e.avail_out),p-=e.avail_in,m-=e.avail_out,e.total_in+=p,e.total_out+=m,r.total+=m,r.wrap&4&&m&&(e.adler=r.check=r.flags?Ye(r.check,o,m,e.next_out-m):cu(r.check,o,m,e.next_out-m)),e.data_type=r.bits+(r.last?64:0)+(r.mode===zn?128:0)+(r.mode===pm||r.mode===rw?256:0),(p===0&&m===0||t===BR)&&M===Ss&&(M=PG),M},"inflate$2"),FG=i(e=>{if($s(e))return cr;let t=e.state;return t.window&&(t.window=null),e.state=null,Ss},"inflateEnd"),UG=i((e,t)=>{if($s(e))return cr;let r=e.state;return r.wrap&2?(r.head=t,t.done=!1,Ss):cr},"inflateGetHeader"),qG=i((e,t)=>{let r=t.length,n,o,s;return $s(e)||(n=e.state,n.wrap!==0&&n.mode!==ym)?cr:n.mode===ym&&(o=1,o=cu(o,t,r,0),o!==n.check)?qj:(s=Yj(e,t,r,r),s?(n.mode=Hj,Bj):(n.havedict=1,Ss))},"inflateSetDictionary"),BG=Wj,HG=Jj,VG=Gj,GG=MG,WG=Kj,JG=LG,KG=FG,YG=UG,XG=qG,QG="pako inflate (from Nodeca project)",Hr={inflateReset:BG,inflateReset2:HG,inflateResetKeep:VG,inflateInit:GG,inflateInit2:WG,inflate:JG,inflateEnd:KG,inflateGetHeader:YG,inflateSetDictionary:XG,inflateInfo:QG};function eW(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}i(eW,"GZheader");var tW=eW,Xj=Object.prototype.toString,{Z_NO_FLUSH:rW,Z_FINISH:hj,Z_OK:xa,Z_STREAM_END:iw,Z_NEED_DICT:aw,Z_STREAM_ERROR:nW,Z_DATA_ERROR:gj,Z_MEM_ERROR:oW,Z_BUF_ERROR:yj}=ks,sW={chunkSize:1024*64,windowBits:15,to:""};function mu(e){this.options=_m.assign({},sW,e||{});let t=this.options;t.raw&&t.windowBits>=0&&t.windowBits<16&&(t.windowBits=-t.windowBits,t.windowBits===0&&(t.windowBits=-15)),t.windowBits>=0&&t.windowBits<16&&!(e&&e.windowBits)&&(t.windowBits+=32),t.windowBits>15&&t.windowBits<48&&(t.windowBits&15||(t.windowBits|=15)),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Zj,this.strm.avail_out=0;let r=Hr.inflateInit2(this.strm,t.windowBits);if(r!==xa)throw new Error(vs[r]);if(this.header=new tW,Hr.inflateGetHeader(this.strm,this.header),t.dictionary&&(typeof t.dictionary=="string"?t.dictionary=uu.string2buf(t.dictionary):Xj.call(t.dictionary)==="[object ArrayBuffer]"&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(r=Hr.inflateSetDictionary(this.strm,t.dictionary),r!==xa)))throw new Error(vs[r])}i(mu,"Inflate$1");mu.prototype.push=function(e,t){let r=this.strm,n=this.options.chunkSize,o=this.options.dictionary,s,a,c;if(this.ended)return!1;for(t===~~t?a=t:a=t===!0?hj:rW,Xj.call(e)==="[object ArrayBuffer]"?r.input=new Uint8Array(e):r.input=e,r.next_in=0,r.avail_in=r.input.length;;){for(r.avail_out===0&&(r.output=new Uint8Array(n),r.next_out=0,r.avail_out=n),s=Hr.inflate(r,a),s===aw&&o&&(s=Hr.inflateSetDictionary(r,o),s===xa?s=Hr.inflate(r,a):s===gj&&(s=aw));r.avail_in>0&&s===iw&&r.state.wrap&2&&r.state.flags!==0&&r.input[r.next_in]!==0;)Hr.inflateReset(r),s=Hr.inflate(r,a);switch(s){case nW:case gj:case aw:case oW:return this.onEnd(s),this.ended=!0,!1}if(c=r.avail_out,r.next_out&&(r.avail_out===0||s===iw||a>0))if(this.options.to==="string"){let l=uu.utf8border(r.output,r.next_out),u=r.next_out-l,d=uu.buf2string(r.output,l);r.next_out=u,r.avail_out=n-u,u&&r.output.set(r.output.subarray(l,l+u),0),this.onData(d)}else this.onData(r.output.length===r.next_out?r.output:r.output.subarray(0,r.next_out)),r.avail_out=0,r.next_out=0;if(!((s===xa||s===yj)&&c===0)){if(s===iw)return s=Hr.inflateEnd(this.strm),this.onEnd(s),this.ended=!0,!0;if(r.avail_in===0){if(a===hj)return s=Hr.inflateEnd(this.strm),this.onEnd(s===xa?yj:s),this.ended=!0,!1;break}}}return!0};mu.prototype.onData=function(e){this.chunks.push(e)};mu.prototype.onEnd=function(e){e===xa&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=_m.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};function kw(e,t){let r=new mu(t);if(r.push(e,!0),r.err)throw r.msg||vs[r.err];return r.result}i(kw,"inflate$1");function iW(e,t){return t=t||{},t.raw=!0,kw(e,t)}i(iW,"inflateRaw$1");var aW=mu,cW=kw,lW=iW,uW=kw,dW=ks,pW={Inflate:aW,inflate:cW,inflateRaw:lW,ungzip:uW,constants:dW},{Deflate:fW,deflate:mW,deflateRaw:hW,gzip:gW}=vG,{Inflate:yW,inflate:xW,inflateRaw:_W,ungzip:vW}=pW,wW=fW,bW=mW,SW=hW,kW=gW,$W=yW,EW=xW,NW=_W,TW=vW,zW=ks,Qj={Deflate:wW,deflate:bW,deflateRaw:SW,gzip:kW,Inflate:$W,inflate:EW,inflateRaw:NW,ungzip:TW,constants:zW};function CW(e){let t="";for(let n=0;n<e.length;n+=32768){let o=e.subarray(n,n+32768);t+=String.fromCharCode(...o)}return t}i(CW,"bytesToBinaryString");function IW(e){let t={...e};t.basePath&&(t.basePath=new URL(t.basePath).toString());let r=Object.keys(t).sort(),n={};for(let o of r)n[o]=t[o];return n}i(IW,"canonicalizeView");function wm(e){let t=IW(e),r=JSON.stringify(t),n=Qj.deflate(r),o=CW(n);return btoa(o).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}i(wm,"encodeId");var lD="io.jucie.studio";async function Aw(e={},t={}){try{console.log(`
253
313
  \u{1F680} Starting Jucie dev server...
254
- `);let r=e.config||process.env.JUCIE_CONFIG||"jucie.config.js",n=await uo(r);t.verbose&&(console.log("Config file path:",r),console.log("Configuration:",n),console.log(""));let o=MB(LB(import.meta.url)),s=DB(o,"stage-bundles"),{createDevServer:a}=await Promise.resolve().then(()=>(RR(),PR)),c=await a({...n,view:"preview",mode:"preview",stageBundles:ZB(s)?s:void 0});if(!c||c.ok===!1){let d=c?.reason||"unknown error";throw new Error(`Dev server failed to start: ${d}`)}let u=`jucie://navigate/${Ep(c)}`;console.log(`\u2728 Dev server running at: ${c.basePath}`),console.log(`\u{1F3A8} Opening Jucie Studio...
255
- `);try{OR(`open -b ${AR} "${u}"`,{stdio:"ignore"}),OR(`osascript -e 'tell application id "${AR}" to activate'`,{stdio:"ignore"})}catch{console.log("\u26A0\uFE0F Jucie Studio is not installed."),console.log(` Download it at https://jucie.app
256
- `),Pc("https://jucie.app")}await new Promise(()=>{})}catch(r){console.error(`
314
+ `);let r=e.config||process.env.JUCIE_CONFIG||"jucie.config.js",n=await Mo(r);t.verbose&&(console.log("Config file path:",r),console.log("Configuration:",n),console.log(""));let o=XW(eJ(import.meta.url)),s=YW(o,"stage-bundles"),{createDevServer:a}=await Promise.resolve().then(()=>(aD(),iD)),c=await a({...n,view:"preview",mode:"preview",stageBundles:QW(s)?s:void 0});if(!c||c.ok===!1){let d=c?.reason||"unknown error";throw new Error(`Dev server failed to start: ${d}`)}let u=`jucie://navigate/${wm(c)}`;console.log(`\u2728 Dev server running at: ${c.basePath}`),console.log(`\u{1F3A8} Opening Jucie Studio...
315
+ `);try{cD(`open -b ${lD} "${u}"`,{stdio:"ignore"}),cD(`osascript -e 'tell application id "${lD}" to activate'`,{stdio:"ignore"})}catch{console.log("\u26A0\uFE0F Jucie Studio is not installed."),console.log(` Download it at https://jucie.app
316
+ `),Yl("https://jucie.app")}await new Promise(()=>{})}catch(r){console.error(`
257
317
  \u274C Dev server failed: ${r.message}
258
- `),t.verbose&&console.error(r.stack),process.exit(1)}}i(v_,"devCommand");import{join as K5,dirname as J5}from"path";import{existsSync as Y5}from"fs";import{execSync as lA}from"child_process";import{fileURLToPath as X5}from"url";var uA="io.jucie.studio";async function Z_(e={},t={}){let r=null;try{console.log(`
318
+ `),t.verbose&&console.error(r.stack),process.exit(1)}}i(Aw,"devCommand");import{join as XK,dirname as QK}from"path";import{existsSync as e7}from"fs";import{execSync as S2}from"child_process";import{fileURLToPath as t7}from"url";var k2="io.jucie.studio";async function db(e={},t={}){let r=null;try{console.log(`
259
319
  \u{1F3A8} Starting Jucie design mode...
260
- `);let n=e.config||process.env.JUCIE_CONFIG||"jucie.config.js",o=await uo(n);r=o.projectRoot,t.verbose&&(console.log("Config file path:",n),console.log("Configuration:",o),console.log(""));let{createDesignServer:s}=await Promise.resolve().then(()=>(cA(),aA)),a=K5(J5(X5(import.meta.url)),"stage-bundles"),c=await s({...o,view:"design",mode:"design",stageBundles:Y5(a)?a:void 0});if(!c||c.ok===!1){let g=c?.reason||"unknown error";throw new Error(`Design server failed to start: ${g}`)}let l=c.basePath,u=Number(new URL(l).port);Wy(r,{port:u,url:l,pid:process.pid,projectRoot:r});let d=!1,p=i(async(g=0)=>{if(!d){d=!0,vd(r);try{await c.engine?.server?.stop()}catch{}process.exit(g)}},"shutdown");process.once("SIGINT",()=>p(130)),process.once("SIGTERM",()=>p(0));let m=`jucie://navigate/${Ep(c)}`;console.log(`\u2728 Design server started at ${l}`),console.log("MCP: run jucie mcp in this project (session written to .jucie/mcp-session.json)"),console.log(`\u{1F3A8} Opening Jucie Studio...
261
- `);try{lA(`open -b ${uA} "${m}"`,{stdio:"ignore"}),lA(`osascript -e 'tell application id "${uA}" to activate'`,{stdio:"ignore"})}catch{console.log("\u26A0\uFE0F Jucie Studio is not installed."),console.log(` Download it at https://jucie.app
262
- `),Pc("https://jucie.app")}await new Promise(()=>{})}catch(n){r&&vd(r),console.error(`
320
+ `);let n=e.config||process.env.JUCIE_CONFIG||"jucie.config.js",o=await Mo(n);r=o.projectRoot,t.verbose&&(console.log("Config file path:",n),console.log("Configuration:",o),console.log(""));let{createDesignServer:s}=await Promise.resolve().then(()=>(b2(),w2)),a=XK(QK(t7(import.meta.url)),"stage-bundles"),c=await s({...o,view:"design",mode:"design",stageBundles:e7(a)?a:void 0});if(!c||c.ok===!1){let g=c?.reason||"unknown error";throw new Error(`Design server failed to start: ${g}`)}let l=c.basePath,u=Number(new URL(l).port);W_(r,{port:u,url:l,pid:process.pid,projectRoot:r});let d=!1,p=i(async(g=0)=>{if(!d){d=!0,Xp(r);try{await c.engine?.server?.stop()}catch{}process.exit(g)}},"shutdown");process.once("SIGINT",()=>p(130)),process.once("SIGTERM",()=>p(0));let h=`jucie://navigate/${wm(c)}`;console.log(`\u2728 Design server started at ${l}`),console.log("MCP: run jucie mcp in this project (session written to .jucie/mcp-session.json)"),console.log(`\u{1F3A8} Opening Jucie Studio...
321
+ `);try{S2(`open -b ${k2} "${h}"`,{stdio:"ignore"}),S2(`osascript -e 'tell application id "${k2}" to activate'`,{stdio:"ignore"})}catch{console.log("\u26A0\uFE0F Jucie Studio is not installed."),console.log(` Download it at https://jucie.app
322
+ `),Yl("https://jucie.app")}await new Promise(()=>{})}catch(n){r&&Xp(r),console.error(`
263
323
  \u274C Design mode failed: ${n.message}
264
- `),t.verbose&&console.error(n.stack),process.exit(1)}}i(Z_,"designCommand");var ze={};R(ze,{BRAND:()=>kV,DIRTY:()=>Ko,EMPTY_PATH:()=>rV,INVALID:()=>V,NEVER:()=>a8,OK:()=>at,ParseStatus:()=>et,Schema:()=>re,ZodAny:()=>Gn,ZodArray:()=>$n,ZodBigInt:()=>Xo,ZodBoolean:()=>Qo,ZodBranded:()=>ll,ZodCatch:()=>us,ZodDate:()=>es,ZodDefault:()=>ls,ZodDiscriminatedUnion:()=>_f,ZodEffects:()=>nr,ZodEnum:()=>as,ZodError:()=>St,ZodFirstPartyTypeKind:()=>P,ZodFunction:()=>wf,ZodIntersection:()=>os,ZodIssueCode:()=>z,ZodLazy:()=>ss,ZodLiteral:()=>is,ZodMap:()=>Ji,ZodNaN:()=>Xi,ZodNativeEnum:()=>cs,ZodNever:()=>_r,ZodNull:()=>rs,ZodNullable:()=>Ur,ZodNumber:()=>Yo,ZodObject:()=>$t,ZodOptional:()=>kt,ZodParsedType:()=>M,ZodPipeline:()=>ul,ZodPromise:()=>Wn,ZodReadonly:()=>ds,ZodRecord:()=>vf,ZodSchema:()=>re,ZodSet:()=>Yi,ZodString:()=>Vn,ZodSymbol:()=>Wi,ZodTransformer:()=>nr,ZodTuple:()=>Fr,ZodType:()=>re,ZodUndefined:()=>ts,ZodUnion:()=>ns,ZodUnknown:()=>kn,ZodVoid:()=>Ki,addIssueToContext:()=>j,any:()=>RV,array:()=>DV,bigint:()=>TV,boolean:()=>wA,coerce:()=>i8,custom:()=>xA,date:()=>zV,datetimeRegex:()=>gA,defaultErrorMap:()=>bn,discriminatedUnion:()=>LV,effect:()=>XV,enum:()=>KV,function:()=>VV,getErrorMap:()=>qi,getParsedType:()=>Lr,instanceof:()=>EV,intersection:()=>FV,isAborted:()=>yf,isAsync:()=>Hi,isDirty:()=>xf,isValid:()=>Bn,late:()=>$V,lazy:()=>GV,literal:()=>WV,makeIssue:()=>nl,map:()=>HV,nan:()=>NV,nativeEnum:()=>JV,never:()=>AV,null:()=>PV,nullable:()=>e8,number:()=>vA,object:()=>q_,objectUtil:()=>L_,oboolean:()=>s8,onumber:()=>o8,optional:()=>QV,ostring:()=>n8,pipeline:()=>r8,preprocess:()=>t8,promise:()=>YV,quotelessJson:()=>Q5,record:()=>qV,set:()=>BV,setErrorMap:()=>tV,strictObject:()=>MV,string:()=>_A,symbol:()=>CV,transformer:()=>XV,tuple:()=>UV,undefined:()=>IV,union:()=>ZV,unknown:()=>OV,util:()=>ae,void:()=>jV});var ae;(function(e){e.assertEqual=o=>{};function t(o){}i(t,"assertIs"),e.assertIs=t;function r(o){throw new Error}i(r,"assertNever"),e.assertNever=r,e.arrayToEnum=o=>{let s={};for(let a of o)s[a]=a;return s},e.getValidEnumValues=o=>{let s=e.objectKeys(o).filter(c=>typeof o[o[c]]!="number"),a={};for(let c of s)a[c]=o[c];return e.objectValues(a)},e.objectValues=o=>e.objectKeys(o).map(function(s){return o[s]}),e.objectKeys=typeof Object.keys=="function"?o=>Object.keys(o):o=>{let s=[];for(let a in o)Object.prototype.hasOwnProperty.call(o,a)&&s.push(a);return s},e.find=(o,s)=>{for(let a of o)if(s(a))return a},e.isInteger=typeof Number.isInteger=="function"?o=>Number.isInteger(o):o=>typeof o=="number"&&Number.isFinite(o)&&Math.floor(o)===o;function n(o,s=" | "){return o.map(a=>typeof a=="string"?`'${a}'`:a).join(s)}i(n,"joinValues"),e.joinValues=n,e.jsonStringifyReplacer=(o,s)=>typeof s=="bigint"?s.toString():s})(ae||(ae={}));var L_;(function(e){e.mergeShapes=(t,r)=>({...t,...r})})(L_||(L_={}));var M=ae.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Lr=i(e=>{switch(typeof e){case"undefined":return M.undefined;case"string":return M.string;case"number":return Number.isNaN(e)?M.nan:M.number;case"boolean":return M.boolean;case"function":return M.function;case"bigint":return M.bigint;case"symbol":return M.symbol;case"object":return Array.isArray(e)?M.array:e===null?M.null:e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?M.promise:typeof Map<"u"&&e instanceof Map?M.map:typeof Set<"u"&&e instanceof Set?M.set:typeof Date<"u"&&e instanceof Date?M.date:M.object;default:return M.unknown}},"getParsedType");var z=ae.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),Q5=i(e=>JSON.stringify(e,null,2).replace(/"([^"]+)":/g,"$1:"),"quotelessJson"),hf=class hf extends Error{get errors(){return this.issues}constructor(t){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};let r=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,r):this.__proto__=r,this.name="ZodError",this.issues=t}format(t){let r=t||function(s){return s.message},n={_errors:[]},o=i(s=>{for(let a of s.issues)if(a.code==="invalid_union")a.unionErrors.map(o);else if(a.code==="invalid_return_type")o(a.returnTypeError);else if(a.code==="invalid_arguments")o(a.argumentsError);else if(a.path.length===0)n._errors.push(r(a));else{let c=n,l=0;for(;l<a.path.length;){let u=a.path[l];l===a.path.length-1?(c[u]=c[u]||{_errors:[]},c[u]._errors.push(r(a))):c[u]=c[u]||{_errors:[]},c=c[u],l++}}},"processError");return o(this),n}static assert(t){if(!(t instanceof hf))throw new Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,ae.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(t=r=>r.message){let r={},n=[];for(let o of this.issues)if(o.path.length>0){let s=o.path[0];r[s]=r[s]||[],r[s].push(t(o))}else n.push(t(o));return{formErrors:n,fieldErrors:r}}get formErrors(){return this.flatten()}};i(hf,"ZodError");var St=hf;St.create=e=>new St(e);var eV=i((e,t)=>{let r;switch(e.code){case z.invalid_type:e.received===M.undefined?r="Required":r=`Expected ${e.expected}, received ${e.received}`;break;case z.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(e.expected,ae.jsonStringifyReplacer)}`;break;case z.unrecognized_keys:r=`Unrecognized key(s) in object: ${ae.joinValues(e.keys,", ")}`;break;case z.invalid_union:r="Invalid input";break;case z.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${ae.joinValues(e.options)}`;break;case z.invalid_enum_value:r=`Invalid enum value. Expected ${ae.joinValues(e.options)}, received '${e.received}'`;break;case z.invalid_arguments:r="Invalid function arguments";break;case z.invalid_return_type:r="Invalid function return type";break;case z.invalid_date:r="Invalid date";break;case z.invalid_string:typeof e.validation=="object"?"includes"in e.validation?(r=`Invalid input: must include "${e.validation.includes}"`,typeof e.validation.position=="number"&&(r=`${r} at one or more positions greater than or equal to ${e.validation.position}`)):"startsWith"in e.validation?r=`Invalid input: must start with "${e.validation.startsWith}"`:"endsWith"in e.validation?r=`Invalid input: must end with "${e.validation.endsWith}"`:ae.assertNever(e.validation):e.validation!=="regex"?r=`Invalid ${e.validation}`:r="Invalid";break;case z.too_small:e.type==="array"?r=`Array must contain ${e.exact?"exactly":e.inclusive?"at least":"more than"} ${e.minimum} element(s)`:e.type==="string"?r=`String must contain ${e.exact?"exactly":e.inclusive?"at least":"over"} ${e.minimum} character(s)`:e.type==="number"?r=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:e.type==="bigint"?r=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:e.type==="date"?r=`Date must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(e.minimum))}`:r="Invalid input";break;case z.too_big:e.type==="array"?r=`Array must contain ${e.exact?"exactly":e.inclusive?"at most":"less than"} ${e.maximum} element(s)`:e.type==="string"?r=`String must contain ${e.exact?"exactly":e.inclusive?"at most":"under"} ${e.maximum} character(s)`:e.type==="number"?r=`Number must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="bigint"?r=`BigInt must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="date"?r=`Date must be ${e.exact?"exactly":e.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(e.maximum))}`:r="Invalid input";break;case z.custom:r="Invalid input";break;case z.invalid_intersection_types:r="Intersection results could not be merged";break;case z.not_multiple_of:r=`Number must be a multiple of ${e.multipleOf}`;break;case z.not_finite:r="Number must be finite";break;default:r=t.defaultError,ae.assertNever(e)}return{message:r}},"errorMap"),bn=eV;var dA=bn;function tV(e){dA=e}i(tV,"setErrorMap");function qi(){return dA}i(qi,"getErrorMap");var nl=i(e=>{let{data:t,path:r,errorMaps:n,issueData:o}=e,s=[...r,...o.path||[]],a={...o,path:s};if(o.message!==void 0)return{...o,path:s,message:o.message};let c="",l=n.filter(u=>!!u).slice().reverse();for(let u of l)c=u(a,{data:t,defaultError:c}).message;return{...o,path:s,message:c}},"makeIssue"),rV=[];function j(e,t){let r=qi(),n=nl({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,r,r===bn?void 0:bn].filter(o=>!!o)});e.common.issues.push(n)}i(j,"addIssueToContext");var gf=class gf{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(t,r){let n=[];for(let o of r){if(o.status==="aborted")return V;o.status==="dirty"&&t.dirty(),n.push(o.value)}return{status:t.value,value:n}}static async mergeObjectAsync(t,r){let n=[];for(let o of r){let s=await o.key,a=await o.value;n.push({key:s,value:a})}return gf.mergeObjectSync(t,n)}static mergeObjectSync(t,r){let n={};for(let o of r){let{key:s,value:a}=o;if(s.status==="aborted"||a.status==="aborted")return V;s.status==="dirty"&&t.dirty(),a.status==="dirty"&&t.dirty(),s.value!=="__proto__"&&(typeof a.value<"u"||o.alwaysSet)&&(n[s.value]=a.value)}return{status:t.value,value:n}}};i(gf,"ParseStatus");var et=gf,V=Object.freeze({status:"aborted"}),Ko=i(e=>({status:"dirty",value:e}),"DIRTY"),at=i(e=>({status:"valid",value:e}),"OK"),yf=i(e=>e.status==="aborted","isAborted"),xf=i(e=>e.status==="dirty","isDirty"),Bn=i(e=>e.status==="valid","isValid"),Hi=i(e=>typeof Promise<"u"&&e instanceof Promise,"isAsync");var F;(function(e){e.errToObj=t=>typeof t=="string"?{message:t}:t||{},e.toString=t=>typeof t=="string"?t:t?.message})(F||(F={}));var H_=class H_{constructor(t,r,n,o){this._cachedPath=[],this.parent=t,this.data=r,this._path=n,this._key=o}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}};i(H_,"ParseInputLazyPath");var rr=H_,pA=i((e,t)=>{if(Bn(t))return{success:!0,data:t.value};if(!e.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let r=new St(e.common.issues);return this._error=r,this._error}}},"handleResult");function ee(e){if(!e)return{};let{errorMap:t,invalid_type_error:r,required_error:n,description:o}=e;if(t&&(r||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return t?{errorMap:t,description:o}:{errorMap:i((a,c)=>{let{message:l}=e;return a.code==="invalid_enum_value"?{message:l??c.defaultError}:typeof c.data>"u"?{message:l??n??c.defaultError}:a.code!=="invalid_type"?{message:c.defaultError}:{message:l??r??c.defaultError}},"customMap"),description:o}}i(ee,"processCreateParams");var B_=class B_{get description(){return this._def.description}_getType(t){return Lr(t.data)}_getOrReturnCtx(t,r){return r||{common:t.parent.common,data:t.data,parsedType:Lr(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}_processInputParams(t){return{status:new et,ctx:{common:t.parent.common,data:t.data,parsedType:Lr(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}}_parseSync(t){let r=this._parse(t);if(Hi(r))throw new Error("Synchronous parse encountered promise.");return r}_parseAsync(t){let r=this._parse(t);return Promise.resolve(r)}parse(t,r){let n=this.safeParse(t,r);if(n.success)return n.data;throw n.error}safeParse(t,r){let n={common:{issues:[],async:r?.async??!1,contextualErrorMap:r?.errorMap},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:Lr(t)},o=this._parseSync({data:t,path:n.path,parent:n});return pA(n,o)}"~validate"(t){let r={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:Lr(t)};if(!this["~standard"].async)try{let n=this._parseSync({data:t,path:[],parent:r});return Bn(n)?{value:n.value}:{issues:r.common.issues}}catch(n){n?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),r.common={issues:[],async:!0}}return this._parseAsync({data:t,path:[],parent:r}).then(n=>Bn(n)?{value:n.value}:{issues:r.common.issues})}async parseAsync(t,r){let n=await this.safeParseAsync(t,r);if(n.success)return n.data;throw n.error}async safeParseAsync(t,r){let n={common:{issues:[],contextualErrorMap:r?.errorMap,async:!0},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:Lr(t)},o=this._parse({data:t,path:n.path,parent:n}),s=await(Hi(o)?o:Promise.resolve(o));return pA(n,s)}refine(t,r){let n=i(o=>typeof r=="string"||typeof r>"u"?{message:r}:typeof r=="function"?r(o):r,"getIssueProperties");return this._refinement((o,s)=>{let a=t(o),c=i(()=>s.addIssue({code:z.custom,...n(o)}),"setError");return typeof Promise<"u"&&a instanceof Promise?a.then(l=>l?!0:(c(),!1)):a?!0:(c(),!1)})}refinement(t,r){return this._refinement((n,o)=>t(n)?!0:(o.addIssue(typeof r=="function"?r(n,o):r),!1))}_refinement(t){return new nr({schema:this,typeName:P.ZodEffects,effect:{type:"refinement",refinement:t}})}superRefine(t){return this._refinement(t)}constructor(t){this.spa=this.safeParseAsync,this._def=t,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:r=>this["~validate"](r)}}optional(){return kt.create(this,this._def)}nullable(){return Ur.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return $n.create(this)}promise(){return Wn.create(this,this._def)}or(t){return ns.create([this,t],this._def)}and(t){return os.create(this,t,this._def)}transform(t){return new nr({...ee(this._def),schema:this,typeName:P.ZodEffects,effect:{type:"transform",transform:t}})}default(t){let r=typeof t=="function"?t:()=>t;return new ls({...ee(this._def),innerType:this,defaultValue:r,typeName:P.ZodDefault})}brand(){return new ll({typeName:P.ZodBranded,type:this,...ee(this._def)})}catch(t){let r=typeof t=="function"?t:()=>t;return new us({...ee(this._def),innerType:this,catchValue:r,typeName:P.ZodCatch})}describe(t){let r=this.constructor;return new r({...this._def,description:t})}pipe(t){return ul.create(this,t)}readonly(){return ds.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}};i(B_,"ZodType");var re=B_,nV=/^c[^\s-]{8,}$/i,oV=/^[0-9a-z]+$/,sV=/^[0-9A-HJKMNP-TV-Z]{26}$/i,iV=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,aV=/^[a-z0-9_-]{21}$/i,cV=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,lV=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,uV=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,dV="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",F_,pV=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,fV=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,mV=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,hV=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,gV=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,yV=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,mA="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",xV=new RegExp(`^${mA}$`);function hA(e){let t="[0-5]\\d";e.precision?t=`${t}\\.\\d{${e.precision}}`:e.precision==null&&(t=`${t}(\\.\\d+)?`);let r=e.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${t})${r}`}i(hA,"timeRegexSource");function _V(e){return new RegExp(`^${hA(e)}$`)}i(_V,"timeRegex");function gA(e){let t=`${mA}T${hA(e)}`,r=[];return r.push(e.local?"Z?":"Z"),e.offset&&r.push("([+-]\\d{2}:?\\d{2})"),t=`${t}(${r.join("|")})`,new RegExp(`^${t}$`)}i(gA,"datetimeRegex");function vV(e,t){return!!((t==="v4"||!t)&&pV.test(e)||(t==="v6"||!t)&&mV.test(e))}i(vV,"isValidIP");function wV(e,t){if(!cV.test(e))return!1;try{let[r]=e.split(".");if(!r)return!1;let n=r.replace(/-/g,"+").replace(/_/g,"/").padEnd(r.length+(4-r.length%4)%4,"="),o=JSON.parse(atob(n));return!(typeof o!="object"||o===null||"typ"in o&&o?.typ!=="JWT"||!o.alg||t&&o.alg!==t)}catch{return!1}}i(wV,"isValidJWT");function bV(e,t){return!!((t==="v4"||!t)&&fV.test(e)||(t==="v6"||!t)&&hV.test(e))}i(bV,"isValidCidr");var Jo=class Jo extends re{_parse(t){if(this._def.coerce&&(t.data=String(t.data)),this._getType(t)!==M.string){let s=this._getOrReturnCtx(t);return j(s,{code:z.invalid_type,expected:M.string,received:s.parsedType}),V}let n=new et,o;for(let s of this._def.checks)if(s.kind==="min")t.data.length<s.value&&(o=this._getOrReturnCtx(t,o),j(o,{code:z.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),n.dirty());else if(s.kind==="max")t.data.length>s.value&&(o=this._getOrReturnCtx(t,o),j(o,{code:z.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),n.dirty());else if(s.kind==="length"){let a=t.data.length>s.value,c=t.data.length<s.value;(a||c)&&(o=this._getOrReturnCtx(t,o),a?j(o,{code:z.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}):c&&j(o,{code:z.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}),n.dirty())}else if(s.kind==="email")uV.test(t.data)||(o=this._getOrReturnCtx(t,o),j(o,{validation:"email",code:z.invalid_string,message:s.message}),n.dirty());else if(s.kind==="emoji")F_||(F_=new RegExp(dV,"u")),F_.test(t.data)||(o=this._getOrReturnCtx(t,o),j(o,{validation:"emoji",code:z.invalid_string,message:s.message}),n.dirty());else if(s.kind==="uuid")iV.test(t.data)||(o=this._getOrReturnCtx(t,o),j(o,{validation:"uuid",code:z.invalid_string,message:s.message}),n.dirty());else if(s.kind==="nanoid")aV.test(t.data)||(o=this._getOrReturnCtx(t,o),j(o,{validation:"nanoid",code:z.invalid_string,message:s.message}),n.dirty());else if(s.kind==="cuid")nV.test(t.data)||(o=this._getOrReturnCtx(t,o),j(o,{validation:"cuid",code:z.invalid_string,message:s.message}),n.dirty());else if(s.kind==="cuid2")oV.test(t.data)||(o=this._getOrReturnCtx(t,o),j(o,{validation:"cuid2",code:z.invalid_string,message:s.message}),n.dirty());else if(s.kind==="ulid")sV.test(t.data)||(o=this._getOrReturnCtx(t,o),j(o,{validation:"ulid",code:z.invalid_string,message:s.message}),n.dirty());else if(s.kind==="url")try{new URL(t.data)}catch{o=this._getOrReturnCtx(t,o),j(o,{validation:"url",code:z.invalid_string,message:s.message}),n.dirty()}else s.kind==="regex"?(s.regex.lastIndex=0,s.regex.test(t.data)||(o=this._getOrReturnCtx(t,o),j(o,{validation:"regex",code:z.invalid_string,message:s.message}),n.dirty())):s.kind==="trim"?t.data=t.data.trim():s.kind==="includes"?t.data.includes(s.value,s.position)||(o=this._getOrReturnCtx(t,o),j(o,{code:z.invalid_string,validation:{includes:s.value,position:s.position},message:s.message}),n.dirty()):s.kind==="toLowerCase"?t.data=t.data.toLowerCase():s.kind==="toUpperCase"?t.data=t.data.toUpperCase():s.kind==="startsWith"?t.data.startsWith(s.value)||(o=this._getOrReturnCtx(t,o),j(o,{code:z.invalid_string,validation:{startsWith:s.value},message:s.message}),n.dirty()):s.kind==="endsWith"?t.data.endsWith(s.value)||(o=this._getOrReturnCtx(t,o),j(o,{code:z.invalid_string,validation:{endsWith:s.value},message:s.message}),n.dirty()):s.kind==="datetime"?gA(s).test(t.data)||(o=this._getOrReturnCtx(t,o),j(o,{code:z.invalid_string,validation:"datetime",message:s.message}),n.dirty()):s.kind==="date"?xV.test(t.data)||(o=this._getOrReturnCtx(t,o),j(o,{code:z.invalid_string,validation:"date",message:s.message}),n.dirty()):s.kind==="time"?_V(s).test(t.data)||(o=this._getOrReturnCtx(t,o),j(o,{code:z.invalid_string,validation:"time",message:s.message}),n.dirty()):s.kind==="duration"?lV.test(t.data)||(o=this._getOrReturnCtx(t,o),j(o,{validation:"duration",code:z.invalid_string,message:s.message}),n.dirty()):s.kind==="ip"?vV(t.data,s.version)||(o=this._getOrReturnCtx(t,o),j(o,{validation:"ip",code:z.invalid_string,message:s.message}),n.dirty()):s.kind==="jwt"?wV(t.data,s.alg)||(o=this._getOrReturnCtx(t,o),j(o,{validation:"jwt",code:z.invalid_string,message:s.message}),n.dirty()):s.kind==="cidr"?bV(t.data,s.version)||(o=this._getOrReturnCtx(t,o),j(o,{validation:"cidr",code:z.invalid_string,message:s.message}),n.dirty()):s.kind==="base64"?gV.test(t.data)||(o=this._getOrReturnCtx(t,o),j(o,{validation:"base64",code:z.invalid_string,message:s.message}),n.dirty()):s.kind==="base64url"?yV.test(t.data)||(o=this._getOrReturnCtx(t,o),j(o,{validation:"base64url",code:z.invalid_string,message:s.message}),n.dirty()):ae.assertNever(s);return{status:n.value,value:t.data}}_regex(t,r,n){return this.refinement(o=>t.test(o),{validation:r,code:z.invalid_string,...F.errToObj(n)})}_addCheck(t){return new Jo({...this._def,checks:[...this._def.checks,t]})}email(t){return this._addCheck({kind:"email",...F.errToObj(t)})}url(t){return this._addCheck({kind:"url",...F.errToObj(t)})}emoji(t){return this._addCheck({kind:"emoji",...F.errToObj(t)})}uuid(t){return this._addCheck({kind:"uuid",...F.errToObj(t)})}nanoid(t){return this._addCheck({kind:"nanoid",...F.errToObj(t)})}cuid(t){return this._addCheck({kind:"cuid",...F.errToObj(t)})}cuid2(t){return this._addCheck({kind:"cuid2",...F.errToObj(t)})}ulid(t){return this._addCheck({kind:"ulid",...F.errToObj(t)})}base64(t){return this._addCheck({kind:"base64",...F.errToObj(t)})}base64url(t){return this._addCheck({kind:"base64url",...F.errToObj(t)})}jwt(t){return this._addCheck({kind:"jwt",...F.errToObj(t)})}ip(t){return this._addCheck({kind:"ip",...F.errToObj(t)})}cidr(t){return this._addCheck({kind:"cidr",...F.errToObj(t)})}datetime(t){return typeof t=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:t}):this._addCheck({kind:"datetime",precision:typeof t?.precision>"u"?null:t?.precision,offset:t?.offset??!1,local:t?.local??!1,...F.errToObj(t?.message)})}date(t){return this._addCheck({kind:"date",message:t})}time(t){return typeof t=="string"?this._addCheck({kind:"time",precision:null,message:t}):this._addCheck({kind:"time",precision:typeof t?.precision>"u"?null:t?.precision,...F.errToObj(t?.message)})}duration(t){return this._addCheck({kind:"duration",...F.errToObj(t)})}regex(t,r){return this._addCheck({kind:"regex",regex:t,...F.errToObj(r)})}includes(t,r){return this._addCheck({kind:"includes",value:t,position:r?.position,...F.errToObj(r?.message)})}startsWith(t,r){return this._addCheck({kind:"startsWith",value:t,...F.errToObj(r)})}endsWith(t,r){return this._addCheck({kind:"endsWith",value:t,...F.errToObj(r)})}min(t,r){return this._addCheck({kind:"min",value:t,...F.errToObj(r)})}max(t,r){return this._addCheck({kind:"max",value:t,...F.errToObj(r)})}length(t,r){return this._addCheck({kind:"length",value:t,...F.errToObj(r)})}nonempty(t){return this.min(1,F.errToObj(t))}trim(){return new Jo({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new Jo({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new Jo({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(t=>t.kind==="datetime")}get isDate(){return!!this._def.checks.find(t=>t.kind==="date")}get isTime(){return!!this._def.checks.find(t=>t.kind==="time")}get isDuration(){return!!this._def.checks.find(t=>t.kind==="duration")}get isEmail(){return!!this._def.checks.find(t=>t.kind==="email")}get isURL(){return!!this._def.checks.find(t=>t.kind==="url")}get isEmoji(){return!!this._def.checks.find(t=>t.kind==="emoji")}get isUUID(){return!!this._def.checks.find(t=>t.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(t=>t.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(t=>t.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(t=>t.kind==="cuid2")}get isULID(){return!!this._def.checks.find(t=>t.kind==="ulid")}get isIP(){return!!this._def.checks.find(t=>t.kind==="ip")}get isCIDR(){return!!this._def.checks.find(t=>t.kind==="cidr")}get isBase64(){return!!this._def.checks.find(t=>t.kind==="base64")}get isBase64url(){return!!this._def.checks.find(t=>t.kind==="base64url")}get minLength(){let t=null;for(let r of this._def.checks)r.kind==="min"&&(t===null||r.value>t)&&(t=r.value);return t}get maxLength(){let t=null;for(let r of this._def.checks)r.kind==="max"&&(t===null||r.value<t)&&(t=r.value);return t}};i(Jo,"ZodString");var Vn=Jo;Vn.create=e=>new Vn({checks:[],typeName:P.ZodString,coerce:e?.coerce??!1,...ee(e)});function SV(e,t){let r=(e.toString().split(".")[1]||"").length,n=(t.toString().split(".")[1]||"").length,o=r>n?r:n,s=Number.parseInt(e.toFixed(o).replace(".","")),a=Number.parseInt(t.toFixed(o).replace(".",""));return s%a/10**o}i(SV,"floatSafeRemainder");var ol=class ol extends re{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(t){if(this._def.coerce&&(t.data=Number(t.data)),this._getType(t)!==M.number){let s=this._getOrReturnCtx(t);return j(s,{code:z.invalid_type,expected:M.number,received:s.parsedType}),V}let n,o=new et;for(let s of this._def.checks)s.kind==="int"?ae.isInteger(t.data)||(n=this._getOrReturnCtx(t,n),j(n,{code:z.invalid_type,expected:"integer",received:"float",message:s.message}),o.dirty()):s.kind==="min"?(s.inclusive?t.data<s.value:t.data<=s.value)&&(n=this._getOrReturnCtx(t,n),j(n,{code:z.too_small,minimum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),o.dirty()):s.kind==="max"?(s.inclusive?t.data>s.value:t.data>=s.value)&&(n=this._getOrReturnCtx(t,n),j(n,{code:z.too_big,maximum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),o.dirty()):s.kind==="multipleOf"?SV(t.data,s.value)!==0&&(n=this._getOrReturnCtx(t,n),j(n,{code:z.not_multiple_of,multipleOf:s.value,message:s.message}),o.dirty()):s.kind==="finite"?Number.isFinite(t.data)||(n=this._getOrReturnCtx(t,n),j(n,{code:z.not_finite,message:s.message}),o.dirty()):ae.assertNever(s);return{status:o.value,value:t.data}}gte(t,r){return this.setLimit("min",t,!0,F.toString(r))}gt(t,r){return this.setLimit("min",t,!1,F.toString(r))}lte(t,r){return this.setLimit("max",t,!0,F.toString(r))}lt(t,r){return this.setLimit("max",t,!1,F.toString(r))}setLimit(t,r,n,o){return new ol({...this._def,checks:[...this._def.checks,{kind:t,value:r,inclusive:n,message:F.toString(o)}]})}_addCheck(t){return new ol({...this._def,checks:[...this._def.checks,t]})}int(t){return this._addCheck({kind:"int",message:F.toString(t)})}positive(t){return this._addCheck({kind:"min",value:0,inclusive:!1,message:F.toString(t)})}negative(t){return this._addCheck({kind:"max",value:0,inclusive:!1,message:F.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:0,inclusive:!0,message:F.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:0,inclusive:!0,message:F.toString(t)})}multipleOf(t,r){return this._addCheck({kind:"multipleOf",value:t,message:F.toString(r)})}finite(t){return this._addCheck({kind:"finite",message:F.toString(t)})}safe(t){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:F.toString(t)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:F.toString(t)})}get minValue(){let t=null;for(let r of this._def.checks)r.kind==="min"&&(t===null||r.value>t)&&(t=r.value);return t}get maxValue(){let t=null;for(let r of this._def.checks)r.kind==="max"&&(t===null||r.value<t)&&(t=r.value);return t}get isInt(){return!!this._def.checks.find(t=>t.kind==="int"||t.kind==="multipleOf"&&ae.isInteger(t.value))}get isFinite(){let t=null,r=null;for(let n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(r===null||n.value>r)&&(r=n.value):n.kind==="max"&&(t===null||n.value<t)&&(t=n.value)}return Number.isFinite(r)&&Number.isFinite(t)}};i(ol,"ZodNumber");var Yo=ol;Yo.create=e=>new Yo({checks:[],typeName:P.ZodNumber,coerce:e?.coerce||!1,...ee(e)});var sl=class sl extends re{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(t){if(this._def.coerce)try{t.data=BigInt(t.data)}catch{return this._getInvalidInput(t)}if(this._getType(t)!==M.bigint)return this._getInvalidInput(t);let n,o=new et;for(let s of this._def.checks)s.kind==="min"?(s.inclusive?t.data<s.value:t.data<=s.value)&&(n=this._getOrReturnCtx(t,n),j(n,{code:z.too_small,type:"bigint",minimum:s.value,inclusive:s.inclusive,message:s.message}),o.dirty()):s.kind==="max"?(s.inclusive?t.data>s.value:t.data>=s.value)&&(n=this._getOrReturnCtx(t,n),j(n,{code:z.too_big,type:"bigint",maximum:s.value,inclusive:s.inclusive,message:s.message}),o.dirty()):s.kind==="multipleOf"?t.data%s.value!==BigInt(0)&&(n=this._getOrReturnCtx(t,n),j(n,{code:z.not_multiple_of,multipleOf:s.value,message:s.message}),o.dirty()):ae.assertNever(s);return{status:o.value,value:t.data}}_getInvalidInput(t){let r=this._getOrReturnCtx(t);return j(r,{code:z.invalid_type,expected:M.bigint,received:r.parsedType}),V}gte(t,r){return this.setLimit("min",t,!0,F.toString(r))}gt(t,r){return this.setLimit("min",t,!1,F.toString(r))}lte(t,r){return this.setLimit("max",t,!0,F.toString(r))}lt(t,r){return this.setLimit("max",t,!1,F.toString(r))}setLimit(t,r,n,o){return new sl({...this._def,checks:[...this._def.checks,{kind:t,value:r,inclusive:n,message:F.toString(o)}]})}_addCheck(t){return new sl({...this._def,checks:[...this._def.checks,t]})}positive(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:F.toString(t)})}negative(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:F.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:F.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:F.toString(t)})}multipleOf(t,r){return this._addCheck({kind:"multipleOf",value:t,message:F.toString(r)})}get minValue(){let t=null;for(let r of this._def.checks)r.kind==="min"&&(t===null||r.value>t)&&(t=r.value);return t}get maxValue(){let t=null;for(let r of this._def.checks)r.kind==="max"&&(t===null||r.value<t)&&(t=r.value);return t}};i(sl,"ZodBigInt");var Xo=sl;Xo.create=e=>new Xo({checks:[],typeName:P.ZodBigInt,coerce:e?.coerce??!1,...ee(e)});var V_=class V_ extends re{_parse(t){if(this._def.coerce&&(t.data=!!t.data),this._getType(t)!==M.boolean){let n=this._getOrReturnCtx(t);return j(n,{code:z.invalid_type,expected:M.boolean,received:n.parsedType}),V}return at(t.data)}};i(V_,"ZodBoolean");var Qo=V_;Qo.create=e=>new Qo({typeName:P.ZodBoolean,coerce:e?.coerce||!1,...ee(e)});var bf=class bf extends re{_parse(t){if(this._def.coerce&&(t.data=new Date(t.data)),this._getType(t)!==M.date){let s=this._getOrReturnCtx(t);return j(s,{code:z.invalid_type,expected:M.date,received:s.parsedType}),V}if(Number.isNaN(t.data.getTime())){let s=this._getOrReturnCtx(t);return j(s,{code:z.invalid_date}),V}let n=new et,o;for(let s of this._def.checks)s.kind==="min"?t.data.getTime()<s.value&&(o=this._getOrReturnCtx(t,o),j(o,{code:z.too_small,message:s.message,inclusive:!0,exact:!1,minimum:s.value,type:"date"}),n.dirty()):s.kind==="max"?t.data.getTime()>s.value&&(o=this._getOrReturnCtx(t,o),j(o,{code:z.too_big,message:s.message,inclusive:!0,exact:!1,maximum:s.value,type:"date"}),n.dirty()):ae.assertNever(s);return{status:n.value,value:new Date(t.data.getTime())}}_addCheck(t){return new bf({...this._def,checks:[...this._def.checks,t]})}min(t,r){return this._addCheck({kind:"min",value:t.getTime(),message:F.toString(r)})}max(t,r){return this._addCheck({kind:"max",value:t.getTime(),message:F.toString(r)})}get minDate(){let t=null;for(let r of this._def.checks)r.kind==="min"&&(t===null||r.value>t)&&(t=r.value);return t!=null?new Date(t):null}get maxDate(){let t=null;for(let r of this._def.checks)r.kind==="max"&&(t===null||r.value<t)&&(t=r.value);return t!=null?new Date(t):null}};i(bf,"ZodDate");var es=bf;es.create=e=>new es({checks:[],coerce:e?.coerce||!1,typeName:P.ZodDate,...ee(e)});var G_=class G_ extends re{_parse(t){if(this._getType(t)!==M.symbol){let n=this._getOrReturnCtx(t);return j(n,{code:z.invalid_type,expected:M.symbol,received:n.parsedType}),V}return at(t.data)}};i(G_,"ZodSymbol");var Wi=G_;Wi.create=e=>new Wi({typeName:P.ZodSymbol,...ee(e)});var W_=class W_ extends re{_parse(t){if(this._getType(t)!==M.undefined){let n=this._getOrReturnCtx(t);return j(n,{code:z.invalid_type,expected:M.undefined,received:n.parsedType}),V}return at(t.data)}};i(W_,"ZodUndefined");var ts=W_;ts.create=e=>new ts({typeName:P.ZodUndefined,...ee(e)});var K_=class K_ extends re{_parse(t){if(this._getType(t)!==M.null){let n=this._getOrReturnCtx(t);return j(n,{code:z.invalid_type,expected:M.null,received:n.parsedType}),V}return at(t.data)}};i(K_,"ZodNull");var rs=K_;rs.create=e=>new rs({typeName:P.ZodNull,...ee(e)});var J_=class J_ extends re{constructor(){super(...arguments),this._any=!0}_parse(t){return at(t.data)}};i(J_,"ZodAny");var Gn=J_;Gn.create=e=>new Gn({typeName:P.ZodAny,...ee(e)});var Y_=class Y_ extends re{constructor(){super(...arguments),this._unknown=!0}_parse(t){return at(t.data)}};i(Y_,"ZodUnknown");var kn=Y_;kn.create=e=>new kn({typeName:P.ZodUnknown,...ee(e)});var X_=class X_ extends re{_parse(t){let r=this._getOrReturnCtx(t);return j(r,{code:z.invalid_type,expected:M.never,received:r.parsedType}),V}};i(X_,"ZodNever");var _r=X_;_r.create=e=>new _r({typeName:P.ZodNever,...ee(e)});var Q_=class Q_ extends re{_parse(t){if(this._getType(t)!==M.undefined){let n=this._getOrReturnCtx(t);return j(n,{code:z.invalid_type,expected:M.void,received:n.parsedType}),V}return at(t.data)}};i(Q_,"ZodVoid");var Ki=Q_;Ki.create=e=>new Ki({typeName:P.ZodVoid,...ee(e)});var Vi=class Vi extends re{_parse(t){let{ctx:r,status:n}=this._processInputParams(t),o=this._def;if(r.parsedType!==M.array)return j(r,{code:z.invalid_type,expected:M.array,received:r.parsedType}),V;if(o.exactLength!==null){let a=r.data.length>o.exactLength.value,c=r.data.length<o.exactLength.value;(a||c)&&(j(r,{code:a?z.too_big:z.too_small,minimum:c?o.exactLength.value:void 0,maximum:a?o.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:o.exactLength.message}),n.dirty())}if(o.minLength!==null&&r.data.length<o.minLength.value&&(j(r,{code:z.too_small,minimum:o.minLength.value,type:"array",inclusive:!0,exact:!1,message:o.minLength.message}),n.dirty()),o.maxLength!==null&&r.data.length>o.maxLength.value&&(j(r,{code:z.too_big,maximum:o.maxLength.value,type:"array",inclusive:!0,exact:!1,message:o.maxLength.message}),n.dirty()),r.common.async)return Promise.all([...r.data].map((a,c)=>o.type._parseAsync(new rr(r,a,r.path,c)))).then(a=>et.mergeArray(n,a));let s=[...r.data].map((a,c)=>o.type._parseSync(new rr(r,a,r.path,c)));return et.mergeArray(n,s)}get element(){return this._def.type}min(t,r){return new Vi({...this._def,minLength:{value:t,message:F.toString(r)}})}max(t,r){return new Vi({...this._def,maxLength:{value:t,message:F.toString(r)}})}length(t,r){return new Vi({...this._def,exactLength:{value:t,message:F.toString(r)}})}nonempty(t){return this.min(1,t)}};i(Vi,"ZodArray");var $n=Vi;$n.create=(e,t)=>new $n({type:e,minLength:null,maxLength:null,exactLength:null,typeName:P.ZodArray,...ee(t)});function Bi(e){if(e instanceof $t){let t={};for(let r in e.shape){let n=e.shape[r];t[r]=kt.create(Bi(n))}return new $t({...e._def,shape:()=>t})}else return e instanceof $n?new $n({...e._def,type:Bi(e.element)}):e instanceof kt?kt.create(Bi(e.unwrap())):e instanceof Ur?Ur.create(Bi(e.unwrap())):e instanceof Fr?Fr.create(e.items.map(t=>Bi(t))):e}i(Bi,"deepPartialify");var Zt=class Zt extends re{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let t=this._def.shape(),r=ae.objectKeys(t);return this._cached={shape:t,keys:r},this._cached}_parse(t){if(this._getType(t)!==M.object){let u=this._getOrReturnCtx(t);return j(u,{code:z.invalid_type,expected:M.object,received:u.parsedType}),V}let{status:n,ctx:o}=this._processInputParams(t),{shape:s,keys:a}=this._getCached(),c=[];if(!(this._def.catchall instanceof _r&&this._def.unknownKeys==="strip"))for(let u in o.data)a.includes(u)||c.push(u);let l=[];for(let u of a){let d=s[u],p=o.data[u];l.push({key:{status:"valid",value:u},value:d._parse(new rr(o,p,o.path,u)),alwaysSet:u in o.data})}if(this._def.catchall instanceof _r){let u=this._def.unknownKeys;if(u==="passthrough")for(let d of c)l.push({key:{status:"valid",value:d},value:{status:"valid",value:o.data[d]}});else if(u==="strict")c.length>0&&(j(o,{code:z.unrecognized_keys,keys:c}),n.dirty());else if(u!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let u=this._def.catchall;for(let d of c){let p=o.data[d];l.push({key:{status:"valid",value:d},value:u._parse(new rr(o,p,o.path,d)),alwaysSet:d in o.data})}}return o.common.async?Promise.resolve().then(async()=>{let u=[];for(let d of l){let p=await d.key,h=await d.value;u.push({key:p,value:h,alwaysSet:d.alwaysSet})}return u}).then(u=>et.mergeObjectSync(n,u)):et.mergeObjectSync(n,l)}get shape(){return this._def.shape()}strict(t){return F.errToObj,new Zt({...this._def,unknownKeys:"strict",...t!==void 0?{errorMap:(r,n)=>{let o=this._def.errorMap?.(r,n).message??n.defaultError;return r.code==="unrecognized_keys"?{message:F.errToObj(t).message??o}:{message:o}}}:{}})}strip(){return new Zt({...this._def,unknownKeys:"strip"})}passthrough(){return new Zt({...this._def,unknownKeys:"passthrough"})}extend(t){return new Zt({...this._def,shape:()=>({...this._def.shape(),...t})})}merge(t){return new Zt({unknownKeys:t._def.unknownKeys,catchall:t._def.catchall,shape:()=>({...this._def.shape(),...t._def.shape()}),typeName:P.ZodObject})}setKey(t,r){return this.augment({[t]:r})}catchall(t){return new Zt({...this._def,catchall:t})}pick(t){let r={};for(let n of ae.objectKeys(t))t[n]&&this.shape[n]&&(r[n]=this.shape[n]);return new Zt({...this._def,shape:()=>r})}omit(t){let r={};for(let n of ae.objectKeys(this.shape))t[n]||(r[n]=this.shape[n]);return new Zt({...this._def,shape:()=>r})}deepPartial(){return Bi(this)}partial(t){let r={};for(let n of ae.objectKeys(this.shape)){let o=this.shape[n];t&&!t[n]?r[n]=o:r[n]=o.optional()}return new Zt({...this._def,shape:()=>r})}required(t){let r={};for(let n of ae.objectKeys(this.shape))if(t&&!t[n])r[n]=this.shape[n];else{let s=this.shape[n];for(;s instanceof kt;)s=s._def.innerType;r[n]=s}return new Zt({...this._def,shape:()=>r})}keyof(){return yA(ae.objectKeys(this.shape))}};i(Zt,"ZodObject");var $t=Zt;$t.create=(e,t)=>new $t({shape:()=>e,unknownKeys:"strip",catchall:_r.create(),typeName:P.ZodObject,...ee(t)});$t.strictCreate=(e,t)=>new $t({shape:()=>e,unknownKeys:"strict",catchall:_r.create(),typeName:P.ZodObject,...ee(t)});$t.lazycreate=(e,t)=>new $t({shape:e,unknownKeys:"strip",catchall:_r.create(),typeName:P.ZodObject,...ee(t)});var ev=class ev extends re{_parse(t){let{ctx:r}=this._processInputParams(t),n=this._def.options;function o(s){for(let c of s)if(c.result.status==="valid")return c.result;for(let c of s)if(c.result.status==="dirty")return r.common.issues.push(...c.ctx.common.issues),c.result;let a=s.map(c=>new St(c.ctx.common.issues));return j(r,{code:z.invalid_union,unionErrors:a}),V}if(i(o,"handleResults"),r.common.async)return Promise.all(n.map(async s=>{let a={...r,common:{...r.common,issues:[]},parent:null};return{result:await s._parseAsync({data:r.data,path:r.path,parent:a}),ctx:a}})).then(o);{let s,a=[];for(let l of n){let u={...r,common:{...r.common,issues:[]},parent:null},d=l._parseSync({data:r.data,path:r.path,parent:u});if(d.status==="valid")return d;d.status==="dirty"&&!s&&(s={result:d,ctx:u}),u.common.issues.length&&a.push(u.common.issues)}if(s)return r.common.issues.push(...s.ctx.common.issues),s.result;let c=a.map(l=>new St(l));return j(r,{code:z.invalid_union,unionErrors:c}),V}}get options(){return this._def.options}};i(ev,"ZodUnion");var ns=ev;ns.create=(e,t)=>new ns({options:e,typeName:P.ZodUnion,...ee(t)});var Sn=i(e=>e instanceof ss?Sn(e.schema):e instanceof nr?Sn(e.innerType()):e instanceof is?[e.value]:e instanceof as?e.options:e instanceof cs?ae.objectValues(e.enum):e instanceof ls?Sn(e._def.innerType):e instanceof ts?[void 0]:e instanceof rs?[null]:e instanceof kt?[void 0,...Sn(e.unwrap())]:e instanceof Ur?[null,...Sn(e.unwrap())]:e instanceof ll||e instanceof ds?Sn(e.unwrap()):e instanceof us?Sn(e._def.innerType):[],"getDiscriminator"),Sf=class Sf extends re{_parse(t){let{ctx:r}=this._processInputParams(t);if(r.parsedType!==M.object)return j(r,{code:z.invalid_type,expected:M.object,received:r.parsedType}),V;let n=this.discriminator,o=r.data[n],s=this.optionsMap.get(o);return s?r.common.async?s._parseAsync({data:r.data,path:r.path,parent:r}):s._parseSync({data:r.data,path:r.path,parent:r}):(j(r,{code:z.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),V)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(t,r,n){let o=new Map;for(let s of r){let a=Sn(s.shape[t]);if(!a.length)throw new Error(`A discriminator value for key \`${t}\` could not be extracted from all schema options`);for(let c of a){if(o.has(c))throw new Error(`Discriminator property ${String(t)} has duplicate value ${String(c)}`);o.set(c,s)}}return new Sf({typeName:P.ZodDiscriminatedUnion,discriminator:t,options:r,optionsMap:o,...ee(n)})}};i(Sf,"ZodDiscriminatedUnion");var _f=Sf;function U_(e,t){let r=Lr(e),n=Lr(t);if(e===t)return{valid:!0,data:e};if(r===M.object&&n===M.object){let o=ae.objectKeys(t),s=ae.objectKeys(e).filter(c=>o.indexOf(c)!==-1),a={...e,...t};for(let c of s){let l=U_(e[c],t[c]);if(!l.valid)return{valid:!1};a[c]=l.data}return{valid:!0,data:a}}else if(r===M.array&&n===M.array){if(e.length!==t.length)return{valid:!1};let o=[];for(let s=0;s<e.length;s++){let a=e[s],c=t[s],l=U_(a,c);if(!l.valid)return{valid:!1};o.push(l.data)}return{valid:!0,data:o}}else return r===M.date&&n===M.date&&+e==+t?{valid:!0,data:e}:{valid:!1}}i(U_,"mergeValues");var tv=class tv extends re{_parse(t){let{status:r,ctx:n}=this._processInputParams(t),o=i((s,a)=>{if(yf(s)||yf(a))return V;let c=U_(s.value,a.value);return c.valid?((xf(s)||xf(a))&&r.dirty(),{status:r.value,value:c.data}):(j(n,{code:z.invalid_intersection_types}),V)},"handleParsed");return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([s,a])=>o(s,a)):o(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}};i(tv,"ZodIntersection");var os=tv;os.create=(e,t,r)=>new os({left:e,right:t,typeName:P.ZodIntersection,...ee(r)});var kf=class kf extends re{_parse(t){let{status:r,ctx:n}=this._processInputParams(t);if(n.parsedType!==M.array)return j(n,{code:z.invalid_type,expected:M.array,received:n.parsedType}),V;if(n.data.length<this._def.items.length)return j(n,{code:z.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),V;!this._def.rest&&n.data.length>this._def.items.length&&(j(n,{code:z.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),r.dirty());let s=[...n.data].map((a,c)=>{let l=this._def.items[c]||this._def.rest;return l?l._parse(new rr(n,a,n.path,c)):null}).filter(a=>!!a);return n.common.async?Promise.all(s).then(a=>et.mergeArray(r,a)):et.mergeArray(r,s)}get items(){return this._def.items}rest(t){return new kf({...this._def,rest:t})}};i(kf,"ZodTuple");var Fr=kf;Fr.create=(e,t)=>{if(!Array.isArray(e))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Fr({items:e,typeName:P.ZodTuple,rest:null,...ee(t)})};var il=class il extends re{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){let{status:r,ctx:n}=this._processInputParams(t);if(n.parsedType!==M.object)return j(n,{code:z.invalid_type,expected:M.object,received:n.parsedType}),V;let o=[],s=this._def.keyType,a=this._def.valueType;for(let c in n.data)o.push({key:s._parse(new rr(n,c,n.path,c)),value:a._parse(new rr(n,n.data[c],n.path,c)),alwaysSet:c in n.data});return n.common.async?et.mergeObjectAsync(r,o):et.mergeObjectSync(r,o)}get element(){return this._def.valueType}static create(t,r,n){return r instanceof re?new il({keyType:t,valueType:r,typeName:P.ZodRecord,...ee(n)}):new il({keyType:Vn.create(),valueType:t,typeName:P.ZodRecord,...ee(r)})}};i(il,"ZodRecord");var vf=il,rv=class rv extends re{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){let{status:r,ctx:n}=this._processInputParams(t);if(n.parsedType!==M.map)return j(n,{code:z.invalid_type,expected:M.map,received:n.parsedType}),V;let o=this._def.keyType,s=this._def.valueType,a=[...n.data.entries()].map(([c,l],u)=>({key:o._parse(new rr(n,c,n.path,[u,"key"])),value:s._parse(new rr(n,l,n.path,[u,"value"]))}));if(n.common.async){let c=new Map;return Promise.resolve().then(async()=>{for(let l of a){let u=await l.key,d=await l.value;if(u.status==="aborted"||d.status==="aborted")return V;(u.status==="dirty"||d.status==="dirty")&&r.dirty(),c.set(u.value,d.value)}return{status:r.value,value:c}})}else{let c=new Map;for(let l of a){let u=l.key,d=l.value;if(u.status==="aborted"||d.status==="aborted")return V;(u.status==="dirty"||d.status==="dirty")&&r.dirty(),c.set(u.value,d.value)}return{status:r.value,value:c}}}};i(rv,"ZodMap");var Ji=rv;Ji.create=(e,t,r)=>new Ji({valueType:t,keyType:e,typeName:P.ZodMap,...ee(r)});var al=class al extends re{_parse(t){let{status:r,ctx:n}=this._processInputParams(t);if(n.parsedType!==M.set)return j(n,{code:z.invalid_type,expected:M.set,received:n.parsedType}),V;let o=this._def;o.minSize!==null&&n.data.size<o.minSize.value&&(j(n,{code:z.too_small,minimum:o.minSize.value,type:"set",inclusive:!0,exact:!1,message:o.minSize.message}),r.dirty()),o.maxSize!==null&&n.data.size>o.maxSize.value&&(j(n,{code:z.too_big,maximum:o.maxSize.value,type:"set",inclusive:!0,exact:!1,message:o.maxSize.message}),r.dirty());let s=this._def.valueType;function a(l){let u=new Set;for(let d of l){if(d.status==="aborted")return V;d.status==="dirty"&&r.dirty(),u.add(d.value)}return{status:r.value,value:u}}i(a,"finalizeSet");let c=[...n.data.values()].map((l,u)=>s._parse(new rr(n,l,n.path,u)));return n.common.async?Promise.all(c).then(l=>a(l)):a(c)}min(t,r){return new al({...this._def,minSize:{value:t,message:F.toString(r)}})}max(t,r){return new al({...this._def,maxSize:{value:t,message:F.toString(r)}})}size(t,r){return this.min(t,r).max(t,r)}nonempty(t){return this.min(1,t)}};i(al,"ZodSet");var Yi=al;Yi.create=(e,t)=>new Yi({valueType:e,minSize:null,maxSize:null,typeName:P.ZodSet,...ee(t)});var Gi=class Gi extends re{constructor(){super(...arguments),this.validate=this.implement}_parse(t){let{ctx:r}=this._processInputParams(t);if(r.parsedType!==M.function)return j(r,{code:z.invalid_type,expected:M.function,received:r.parsedType}),V;function n(c,l){return nl({data:c,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,qi(),bn].filter(u=>!!u),issueData:{code:z.invalid_arguments,argumentsError:l}})}i(n,"makeArgsIssue");function o(c,l){return nl({data:c,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,qi(),bn].filter(u=>!!u),issueData:{code:z.invalid_return_type,returnTypeError:l}})}i(o,"makeReturnsIssue");let s={errorMap:r.common.contextualErrorMap},a=r.data;if(this._def.returns instanceof Wn){let c=this;return at(async function(...l){let u=new St([]),d=await c._def.args.parseAsync(l,s).catch(m=>{throw u.addIssue(n(l,m)),u}),p=await Reflect.apply(a,this,d);return await c._def.returns._def.type.parseAsync(p,s).catch(m=>{throw u.addIssue(o(p,m)),u})})}else{let c=this;return at(function(...l){let u=c._def.args.safeParse(l,s);if(!u.success)throw new St([n(l,u.error)]);let d=Reflect.apply(a,this,u.data),p=c._def.returns.safeParse(d,s);if(!p.success)throw new St([o(d,p.error)]);return p.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...t){return new Gi({...this._def,args:Fr.create(t).rest(kn.create())})}returns(t){return new Gi({...this._def,returns:t})}implement(t){return this.parse(t)}strictImplement(t){return this.parse(t)}static create(t,r,n){return new Gi({args:t||Fr.create([]).rest(kn.create()),returns:r||kn.create(),typeName:P.ZodFunction,...ee(n)})}};i(Gi,"ZodFunction");var wf=Gi,nv=class nv extends re{get schema(){return this._def.getter()}_parse(t){let{ctx:r}=this._processInputParams(t);return this._def.getter()._parse({data:r.data,path:r.path,parent:r})}};i(nv,"ZodLazy");var ss=nv;ss.create=(e,t)=>new ss({getter:e,typeName:P.ZodLazy,...ee(t)});var ov=class ov extends re{_parse(t){if(t.data!==this._def.value){let r=this._getOrReturnCtx(t);return j(r,{received:r.data,code:z.invalid_literal,expected:this._def.value}),V}return{status:"valid",value:t.data}}get value(){return this._def.value}};i(ov,"ZodLiteral");var is=ov;is.create=(e,t)=>new is({value:e,typeName:P.ZodLiteral,...ee(t)});function yA(e,t){return new as({values:e,typeName:P.ZodEnum,...ee(t)})}i(yA,"createZodEnum");var cl=class cl extends re{_parse(t){if(typeof t.data!="string"){let r=this._getOrReturnCtx(t),n=this._def.values;return j(r,{expected:ae.joinValues(n),received:r.parsedType,code:z.invalid_type}),V}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(t.data)){let r=this._getOrReturnCtx(t),n=this._def.values;return j(r,{received:r.data,code:z.invalid_enum_value,options:n}),V}return at(t.data)}get options(){return this._def.values}get enum(){let t={};for(let r of this._def.values)t[r]=r;return t}get Values(){let t={};for(let r of this._def.values)t[r]=r;return t}get Enum(){let t={};for(let r of this._def.values)t[r]=r;return t}extract(t,r=this._def){return cl.create(t,{...this._def,...r})}exclude(t,r=this._def){return cl.create(this.options.filter(n=>!t.includes(n)),{...this._def,...r})}};i(cl,"ZodEnum");var as=cl;as.create=yA;var sv=class sv extends re{_parse(t){let r=ae.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(t);if(n.parsedType!==M.string&&n.parsedType!==M.number){let o=ae.objectValues(r);return j(n,{expected:ae.joinValues(o),received:n.parsedType,code:z.invalid_type}),V}if(this._cache||(this._cache=new Set(ae.getValidEnumValues(this._def.values))),!this._cache.has(t.data)){let o=ae.objectValues(r);return j(n,{received:n.data,code:z.invalid_enum_value,options:o}),V}return at(t.data)}get enum(){return this._def.values}};i(sv,"ZodNativeEnum");var cs=sv;cs.create=(e,t)=>new cs({values:e,typeName:P.ZodNativeEnum,...ee(t)});var iv=class iv extends re{unwrap(){return this._def.type}_parse(t){let{ctx:r}=this._processInputParams(t);if(r.parsedType!==M.promise&&r.common.async===!1)return j(r,{code:z.invalid_type,expected:M.promise,received:r.parsedType}),V;let n=r.parsedType===M.promise?r.data:Promise.resolve(r.data);return at(n.then(o=>this._def.type.parseAsync(o,{path:r.path,errorMap:r.common.contextualErrorMap})))}};i(iv,"ZodPromise");var Wn=iv;Wn.create=(e,t)=>new Wn({type:e,typeName:P.ZodPromise,...ee(t)});var av=class av extends re{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===P.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(t){let{status:r,ctx:n}=this._processInputParams(t),o=this._def.effect||null,s={addIssue:a=>{j(n,a),a.fatal?r.abort():r.dirty()},get path(){return n.path}};if(s.addIssue=s.addIssue.bind(s),o.type==="preprocess"){let a=o.transform(n.data,s);if(n.common.async)return Promise.resolve(a).then(async c=>{if(r.value==="aborted")return V;let l=await this._def.schema._parseAsync({data:c,path:n.path,parent:n});return l.status==="aborted"?V:l.status==="dirty"?Ko(l.value):r.value==="dirty"?Ko(l.value):l});{if(r.value==="aborted")return V;let c=this._def.schema._parseSync({data:a,path:n.path,parent:n});return c.status==="aborted"?V:c.status==="dirty"?Ko(c.value):r.value==="dirty"?Ko(c.value):c}}if(o.type==="refinement"){let a=i(c=>{let l=o.refinement(c,s);if(n.common.async)return Promise.resolve(l);if(l instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return c},"executeRefinement");if(n.common.async===!1){let c=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return c.status==="aborted"?V:(c.status==="dirty"&&r.dirty(),a(c.value),{status:r.value,value:c.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(c=>c.status==="aborted"?V:(c.status==="dirty"&&r.dirty(),a(c.value).then(()=>({status:r.value,value:c.value}))))}if(o.type==="transform")if(n.common.async===!1){let a=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!Bn(a))return V;let c=o.transform(a.value,s);if(c instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:r.value,value:c}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(a=>Bn(a)?Promise.resolve(o.transform(a.value,s)).then(c=>({status:r.value,value:c})):V);ae.assertNever(o)}};i(av,"ZodEffects");var nr=av;nr.create=(e,t,r)=>new nr({schema:e,typeName:P.ZodEffects,effect:t,...ee(r)});nr.createWithPreprocess=(e,t,r)=>new nr({schema:t,effect:{type:"preprocess",transform:e},typeName:P.ZodEffects,...ee(r)});var cv=class cv extends re{_parse(t){return this._getType(t)===M.undefined?at(void 0):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}};i(cv,"ZodOptional");var kt=cv;kt.create=(e,t)=>new kt({innerType:e,typeName:P.ZodOptional,...ee(t)});var lv=class lv extends re{_parse(t){return this._getType(t)===M.null?at(null):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}};i(lv,"ZodNullable");var Ur=lv;Ur.create=(e,t)=>new Ur({innerType:e,typeName:P.ZodNullable,...ee(t)});var uv=class uv extends re{_parse(t){let{ctx:r}=this._processInputParams(t),n=r.data;return r.parsedType===M.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:r.path,parent:r})}removeDefault(){return this._def.innerType}};i(uv,"ZodDefault");var ls=uv;ls.create=(e,t)=>new ls({innerType:e,typeName:P.ZodDefault,defaultValue:typeof t.default=="function"?t.default:()=>t.default,...ee(t)});var dv=class dv extends re{_parse(t){let{ctx:r}=this._processInputParams(t),n={...r,common:{...r.common,issues:[]}},o=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return Hi(o)?o.then(s=>({status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new St(n.common.issues)},input:n.data})})):{status:"valid",value:o.status==="valid"?o.value:this._def.catchValue({get error(){return new St(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}};i(dv,"ZodCatch");var us=dv;us.create=(e,t)=>new us({innerType:e,typeName:P.ZodCatch,catchValue:typeof t.catch=="function"?t.catch:()=>t.catch,...ee(t)});var pv=class pv extends re{_parse(t){if(this._getType(t)!==M.nan){let n=this._getOrReturnCtx(t);return j(n,{code:z.invalid_type,expected:M.nan,received:n.parsedType}),V}return{status:"valid",value:t.data}}};i(pv,"ZodNaN");var Xi=pv;Xi.create=e=>new Xi({typeName:P.ZodNaN,...ee(e)});var kV=Symbol("zod_brand"),fv=class fv extends re{_parse(t){let{ctx:r}=this._processInputParams(t),n=r.data;return this._def.type._parse({data:n,path:r.path,parent:r})}unwrap(){return this._def.type}};i(fv,"ZodBranded");var ll=fv,$f=class $f extends re{_parse(t){let{status:r,ctx:n}=this._processInputParams(t);if(n.common.async)return i(async()=>{let s=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?V:s.status==="dirty"?(r.dirty(),Ko(s.value)):this._def.out._parseAsync({data:s.value,path:n.path,parent:n})},"handleAsync")();{let o=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return o.status==="aborted"?V:o.status==="dirty"?(r.dirty(),{status:"dirty",value:o.value}):this._def.out._parseSync({data:o.value,path:n.path,parent:n})}}static create(t,r){return new $f({in:t,out:r,typeName:P.ZodPipeline})}};i($f,"ZodPipeline");var ul=$f,mv=class mv extends re{_parse(t){let r=this._def.innerType._parse(t),n=i(o=>(Bn(o)&&(o.value=Object.freeze(o.value)),o),"freeze");return Hi(r)?r.then(o=>n(o)):n(r)}unwrap(){return this._def.innerType}};i(mv,"ZodReadonly");var ds=mv;ds.create=(e,t)=>new ds({innerType:e,typeName:P.ZodReadonly,...ee(t)});function fA(e,t){let r=typeof e=="function"?e(t):typeof e=="string"?{message:e}:e;return typeof r=="string"?{message:r}:r}i(fA,"cleanParams");function xA(e,t={},r){return e?Gn.create().superRefine((n,o)=>{let s=e(n);if(s instanceof Promise)return s.then(a=>{if(!a){let c=fA(t,n),l=c.fatal??r??!0;o.addIssue({code:"custom",...c,fatal:l})}});if(!s){let a=fA(t,n),c=a.fatal??r??!0;o.addIssue({code:"custom",...a,fatal:c})}}):Gn.create()}i(xA,"custom");var $V={object:$t.lazycreate},P;(function(e){e.ZodString="ZodString",e.ZodNumber="ZodNumber",e.ZodNaN="ZodNaN",e.ZodBigInt="ZodBigInt",e.ZodBoolean="ZodBoolean",e.ZodDate="ZodDate",e.ZodSymbol="ZodSymbol",e.ZodUndefined="ZodUndefined",e.ZodNull="ZodNull",e.ZodAny="ZodAny",e.ZodUnknown="ZodUnknown",e.ZodNever="ZodNever",e.ZodVoid="ZodVoid",e.ZodArray="ZodArray",e.ZodObject="ZodObject",e.ZodUnion="ZodUnion",e.ZodDiscriminatedUnion="ZodDiscriminatedUnion",e.ZodIntersection="ZodIntersection",e.ZodTuple="ZodTuple",e.ZodRecord="ZodRecord",e.ZodMap="ZodMap",e.ZodSet="ZodSet",e.ZodFunction="ZodFunction",e.ZodLazy="ZodLazy",e.ZodLiteral="ZodLiteral",e.ZodEnum="ZodEnum",e.ZodEffects="ZodEffects",e.ZodNativeEnum="ZodNativeEnum",e.ZodOptional="ZodOptional",e.ZodNullable="ZodNullable",e.ZodDefault="ZodDefault",e.ZodCatch="ZodCatch",e.ZodPromise="ZodPromise",e.ZodBranded="ZodBranded",e.ZodPipeline="ZodPipeline",e.ZodReadonly="ZodReadonly"})(P||(P={}));var EV=i((e,t={message:`Input not instance of ${e.name}`})=>xA(r=>r instanceof e,t),"instanceOfType"),_A=Vn.create,vA=Yo.create,NV=Xi.create,TV=Xo.create,wA=Qo.create,zV=es.create,CV=Wi.create,IV=ts.create,PV=rs.create,RV=Gn.create,OV=kn.create,AV=_r.create,jV=Ki.create,DV=$n.create,q_=$t.create,MV=$t.strictCreate,ZV=ns.create,LV=_f.create,FV=os.create,UV=Fr.create,qV=vf.create,HV=Ji.create,BV=Yi.create,VV=wf.create,GV=ss.create,WV=is.create,KV=as.create,JV=cs.create,YV=Wn.create,XV=nr.create,QV=kt.create,e8=Ur.create,t8=nr.createWithPreprocess,r8=ul.create,n8=i(()=>_A().optional(),"ostring"),o8=i(()=>vA().optional(),"onumber"),s8=i(()=>wA().optional(),"oboolean"),i8={string:e=>Vn.create({...e,coerce:!0}),number:e=>Yo.create({...e,coerce:!0}),boolean:e=>Qo.create({...e,coerce:!0}),bigint:e=>Xo.create({...e,coerce:!0}),date:e=>es.create({...e,coerce:!0})};var a8=V;var c8=Object.freeze({status:"aborted"});function N(e,t,r){function n(l,u){var d;Object.defineProperty(l,"_zod",{value:l._zod??{},enumerable:!1}),(d=l._zod).traits??(d.traits=new Set),l._zod.traits.add(e),t(l,u);for(let p in a.prototype)p in l||Object.defineProperty(l,p,{value:a.prototype[p].bind(l)});l._zod.constr=a,l._zod.def=u}i(n,"init");let o=r?.Parent??Object,c=class c extends o{};i(c,"Definition");let s=c;Object.defineProperty(s,"name",{value:e});function a(l){var u;let d=r?.Parent?new s:this;n(d,l),(u=d._zod).deferred??(u.deferred=[]);for(let p of d._zod.deferred)p();return d}return i(a,"_"),Object.defineProperty(a,"init",{value:n}),Object.defineProperty(a,Symbol.hasInstance,{value:l=>r?.Parent&&l instanceof r.Parent?!0:l?._zod?.traits?.has(e)}),Object.defineProperty(a,"name",{value:e}),a}i(N,"$constructor");var l8=Symbol("zod_brand"),gv=class gv extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}};i(gv,"$ZodAsyncError");var En=gv,Ef={};function Lt(e){return e&&Object.assign(Ef,e),Ef}i(Lt,"config");var ce={};R(ce,{BIGINT_FORMAT_RANGES:()=>SA,Class:()=>yv,NUMBER_FORMAT_RANGES:()=>kv,aborted:()=>fs,allowsEval:()=>wv,assert:()=>m8,assertEqual:()=>u8,assertIs:()=>p8,assertNever:()=>f8,assertNotEqual:()=>d8,assignProp:()=>vv,cached:()=>fl,captureStackTrace:()=>Tf,cleanEnum:()=>N8,cleanRegex:()=>hl,clone:()=>Ft,createTransparentProxy:()=>v8,defineLazy:()=>$e,esc:()=>ps,escapeRegex:()=>Kn,extend:()=>S8,finalizeIssue:()=>vr,floatSafeRemainder:()=>_v,getElementAtPath:()=>h8,getEnumValues:()=>pl,getLengthableOrigin:()=>gl,getParsedType:()=>_8,getSizableOrigin:()=>kA,isObject:()=>Qi,isPlainObject:()=>ea,issue:()=>$v,joinValues:()=>Nf,jsonStringifyReplacer:()=>xv,merge:()=>k8,normalizeParams:()=>G,nullish:()=>ml,numKeys:()=>x8,omit:()=>b8,optionalKeys:()=>Sv,partial:()=>$8,pick:()=>w8,prefixIssues:()=>qr,primitiveTypes:()=>bA,promiseAllObject:()=>g8,propertyKeyTypes:()=>bv,randomString:()=>y8,required:()=>E8,stringifyPrimitive:()=>zf,unwrapMessage:()=>dl});function u8(e){return e}i(u8,"assertEqual");function d8(e){return e}i(d8,"assertNotEqual");function p8(e){}i(p8,"assertIs");function f8(e){throw new Error}i(f8,"assertNever");function m8(e){}i(m8,"assert");function pl(e){let t=Object.values(e).filter(n=>typeof n=="number");return Object.entries(e).filter(([n,o])=>t.indexOf(+n)===-1).map(([n,o])=>o)}i(pl,"getEnumValues");function Nf(e,t="|"){return e.map(r=>zf(r)).join(t)}i(Nf,"joinValues");function xv(e,t){return typeof t=="bigint"?t.toString():t}i(xv,"jsonStringifyReplacer");function fl(e){return{get value(){{let r=e();return Object.defineProperty(this,"value",{value:r}),r}throw new Error("cached value already set")}}}i(fl,"cached");function ml(e){return e==null}i(ml,"nullish");function hl(e){let t=e.startsWith("^")?1:0,r=e.endsWith("$")?e.length-1:e.length;return e.slice(t,r)}i(hl,"cleanRegex");function _v(e,t){let r=(e.toString().split(".")[1]||"").length,n=(t.toString().split(".")[1]||"").length,o=r>n?r:n,s=Number.parseInt(e.toFixed(o).replace(".","")),a=Number.parseInt(t.toFixed(o).replace(".",""));return s%a/10**o}i(_v,"floatSafeRemainder");function $e(e,t,r){Object.defineProperty(e,t,{get(){{let o=r();return e[t]=o,o}throw new Error("cached value already set")},set(o){Object.defineProperty(e,t,{value:o})},configurable:!0})}i($e,"defineLazy");function vv(e,t,r){Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}i(vv,"assignProp");function h8(e,t){return t?t.reduce((r,n)=>r?.[n],e):e}i(h8,"getElementAtPath");function g8(e){let t=Object.keys(e),r=t.map(n=>e[n]);return Promise.all(r).then(n=>{let o={};for(let s=0;s<t.length;s++)o[t[s]]=n[s];return o})}i(g8,"promiseAllObject");function y8(e=10){let t="abcdefghijklmnopqrstuvwxyz",r="";for(let n=0;n<e;n++)r+=t[Math.floor(Math.random()*t.length)];return r}i(y8,"randomString");function ps(e){return JSON.stringify(e)}i(ps,"esc");var Tf=Error.captureStackTrace?Error.captureStackTrace:(...e)=>{};function Qi(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}i(Qi,"isObject");var wv=fl(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{let e=Function;return new e(""),!0}catch{return!1}});function ea(e){if(Qi(e)===!1)return!1;let t=e.constructor;if(t===void 0)return!0;let r=t.prototype;return!(Qi(r)===!1||Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)}i(ea,"isPlainObject");function x8(e){let t=0;for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&t++;return t}i(x8,"numKeys");var _8=i(e=>{let t=typeof e;switch(t){case"undefined":return"undefined";case"string":return"string";case"number":return Number.isNaN(e)?"nan":"number";case"boolean":return"boolean";case"function":return"function";case"bigint":return"bigint";case"symbol":return"symbol";case"object":return Array.isArray(e)?"array":e===null?"null":e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?"promise":typeof Map<"u"&&e instanceof Map?"map":typeof Set<"u"&&e instanceof Set?"set":typeof Date<"u"&&e instanceof Date?"date":typeof File<"u"&&e instanceof File?"file":"object";default:throw new Error(`Unknown data type: ${t}`)}},"getParsedType"),bv=new Set(["string","number","symbol"]),bA=new Set(["string","number","bigint","boolean","symbol","undefined"]);function Kn(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}i(Kn,"escapeRegex");function Ft(e,t,r){let n=new e._zod.constr(t??e._zod.def);return(!t||r?.parent)&&(n._zod.parent=e),n}i(Ft,"clone");function G(e){let t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}i(G,"normalizeParams");function v8(e){let t;return new Proxy({},{get(r,n,o){return t??(t=e()),Reflect.get(t,n,o)},set(r,n,o,s){return t??(t=e()),Reflect.set(t,n,o,s)},has(r,n){return t??(t=e()),Reflect.has(t,n)},deleteProperty(r,n){return t??(t=e()),Reflect.deleteProperty(t,n)},ownKeys(r){return t??(t=e()),Reflect.ownKeys(t)},getOwnPropertyDescriptor(r,n){return t??(t=e()),Reflect.getOwnPropertyDescriptor(t,n)},defineProperty(r,n,o){return t??(t=e()),Reflect.defineProperty(t,n,o)}})}i(v8,"createTransparentProxy");function zf(e){return typeof e=="bigint"?e.toString()+"n":typeof e=="string"?`"${e}"`:`${e}`}i(zf,"stringifyPrimitive");function Sv(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}i(Sv,"optionalKeys");var kv={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},SA={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function w8(e,t){let r={},n=e._zod.def;for(let o in t){if(!(o in n.shape))throw new Error(`Unrecognized key: "${o}"`);t[o]&&(r[o]=n.shape[o])}return Ft(e,{...e._zod.def,shape:r,checks:[]})}i(w8,"pick");function b8(e,t){let r={...e._zod.def.shape},n=e._zod.def;for(let o in t){if(!(o in n.shape))throw new Error(`Unrecognized key: "${o}"`);t[o]&&delete r[o]}return Ft(e,{...e._zod.def,shape:r,checks:[]})}i(b8,"omit");function S8(e,t){if(!ea(t))throw new Error("Invalid input to extend: expected a plain object");let r={...e._zod.def,get shape(){let n={...e._zod.def.shape,...t};return vv(this,"shape",n),n},checks:[]};return Ft(e,r)}i(S8,"extend");function k8(e,t){return Ft(e,{...e._zod.def,get shape(){let r={...e._zod.def.shape,...t._zod.def.shape};return vv(this,"shape",r),r},catchall:t._zod.def.catchall,checks:[]})}i(k8,"merge");function $8(e,t,r){let n=t._zod.def.shape,o={...n};if(r)for(let s in r){if(!(s in n))throw new Error(`Unrecognized key: "${s}"`);r[s]&&(o[s]=e?new e({type:"optional",innerType:n[s]}):n[s])}else for(let s in n)o[s]=e?new e({type:"optional",innerType:n[s]}):n[s];return Ft(t,{...t._zod.def,shape:o,checks:[]})}i($8,"partial");function E8(e,t,r){let n=t._zod.def.shape,o={...n};if(r)for(let s in r){if(!(s in o))throw new Error(`Unrecognized key: "${s}"`);r[s]&&(o[s]=new e({type:"nonoptional",innerType:n[s]}))}else for(let s in n)o[s]=new e({type:"nonoptional",innerType:n[s]});return Ft(t,{...t._zod.def,shape:o,checks:[]})}i(E8,"required");function fs(e,t=0){for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue!==!0)return!0;return!1}i(fs,"aborted");function qr(e,t){return t.map(r=>{var n;return(n=r).path??(n.path=[]),r.path.unshift(e),r})}i(qr,"prefixIssues");function dl(e){return typeof e=="string"?e:e?.message}i(dl,"unwrapMessage");function vr(e,t,r){let n={...e,path:e.path??[]};if(!e.message){let o=dl(e.inst?._zod.def?.error?.(e))??dl(t?.error?.(e))??dl(r.customError?.(e))??dl(r.localeError?.(e))??"Invalid input";n.message=o}return delete n.inst,delete n.continue,t?.reportInput||delete n.input,n}i(vr,"finalizeIssue");function kA(e){return e instanceof Set?"set":e instanceof Map?"map":e instanceof File?"file":"unknown"}i(kA,"getSizableOrigin");function gl(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}i(gl,"getLengthableOrigin");function $v(...e){let[t,r,n]=e;return typeof t=="string"?{message:t,code:"custom",input:r,inst:n}:{...t}}i($v,"issue");function N8(e){return Object.entries(e).filter(([t,r])=>Number.isNaN(Number.parseInt(t,10))).map(t=>t[1])}i(N8,"cleanEnum");var Ev=class Ev{constructor(...t){}};i(Ev,"Class");var yv=Ev;var $A=i((e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),Object.defineProperty(e,"message",{get(){return JSON.stringify(t,xv,2)},enumerable:!0}),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},"initializer"),Cf=N("$ZodError",$A),yl=N("$ZodError",$A,{Parent:Error});function Nv(e,t=r=>r.message){let r={},n=[];for(let o of e.issues)o.path.length>0?(r[o.path[0]]=r[o.path[0]]||[],r[o.path[0]].push(t(o))):n.push(t(o));return{formErrors:n,fieldErrors:r}}i(Nv,"flattenError");function Tv(e,t){let r=t||function(s){return s.message},n={_errors:[]},o=i(s=>{for(let a of s.issues)if(a.code==="invalid_union"&&a.errors.length)a.errors.map(c=>o({issues:c}));else if(a.code==="invalid_key")o({issues:a.issues});else if(a.code==="invalid_element")o({issues:a.issues});else if(a.path.length===0)n._errors.push(r(a));else{let c=n,l=0;for(;l<a.path.length;){let u=a.path[l];l===a.path.length-1?(c[u]=c[u]||{_errors:[]},c[u]._errors.push(r(a))):c[u]=c[u]||{_errors:[]},c=c[u],l++}}},"processError");return o(e),n}i(Tv,"formatError");var zv=i(e=>(t,r,n,o)=>{let s=n?Object.assign(n,{async:!1}):{async:!1},a=t._zod.run({value:r,issues:[]},s);if(a instanceof Promise)throw new En;if(a.issues.length){let c=new(o?.Err??e)(a.issues.map(l=>vr(l,s,Lt())));throw Tf(c,o?.callee),c}return a.value},"_parse"),Cv=zv(yl),Iv=i(e=>async(t,r,n,o)=>{let s=n?Object.assign(n,{async:!0}):{async:!0},a=t._zod.run({value:r,issues:[]},s);if(a instanceof Promise&&(a=await a),a.issues.length){let c=new(o?.Err??e)(a.issues.map(l=>vr(l,s,Lt())));throw Tf(c,o?.callee),c}return a.value},"_parseAsync"),Pv=Iv(yl),Rv=i(e=>(t,r,n)=>{let o=n?{...n,async:!1}:{async:!1},s=t._zod.run({value:r,issues:[]},o);if(s instanceof Promise)throw new En;return s.issues.length?{success:!1,error:new(e??Cf)(s.issues.map(a=>vr(a,o,Lt())))}:{success:!0,data:s.value}},"_safeParse"),ms=Rv(yl),Ov=i(e=>async(t,r,n)=>{let o=n?Object.assign(n,{async:!0}):{async:!0},s=t._zod.run({value:r,issues:[]},o);return s instanceof Promise&&(s=await s),s.issues.length?{success:!1,error:new e(s.issues.map(a=>vr(a,o,Lt())))}:{success:!0,data:s.value}},"_safeParseAsync"),hs=Ov(yl);var EA=/^[cC][^\s-]{8,}$/,NA=/^[0-9a-z]+$/,TA=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,zA=/^[0-9a-vA-V]{20}$/,CA=/^[A-Za-z0-9]{27}$/,IA=/^[a-zA-Z0-9_-]{21}$/,PA=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;var RA=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,Av=i(e=>e?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000)$/,"uuid");var OA=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;var z8="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function AA(){return new RegExp(z8,"u")}i(AA,"emoji");var jA=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,DA=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})$/,MA=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,ZA=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,LA=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,jv=/^[A-Za-z0-9_-]*$/,FA=/^([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+$/;var UA=/^\+(?:[0-9]){6,14}[0-9]$/,qA="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",HA=new RegExp(`^${qA}$`);function BA(e){let t="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof e.precision=="number"?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}i(BA,"timeSource");function VA(e){return new RegExp(`^${BA(e)}$`)}i(VA,"time");function GA(e){let t=BA({precision:e.precision}),r=["Z"];e.local&&r.push(""),e.offset&&r.push("([+-]\\d{2}:\\d{2})");let n=`${t}(?:${r.join("|")})`;return new RegExp(`^${qA}T(?:${n})$`)}i(GA,"datetime");var WA=i(e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},"string");var KA=/^\d+$/,JA=/^-?\d+(?:\.\d+)?/i,YA=/true|false/i,XA=/null/i;var QA=/^[^A-Z]*$/,ej=/^[^a-z]*$/;var tt=N("$ZodCheck",(e,t)=>{var r;e._zod??(e._zod={}),e._zod.def=t,(r=e._zod).onattach??(r.onattach=[])}),tj={number:"number",bigint:"bigint",object:"date"},Dv=N("$ZodCheckLessThan",(e,t)=>{tt.init(e,t);let r=tj[typeof t.value];e._zod.onattach.push(n=>{let o=n._zod.bag,s=(t.inclusive?o.maximum:o.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<s&&(t.inclusive?o.maximum=t.value:o.exclusiveMaximum=t.value)}),e._zod.check=n=>{(t.inclusive?n.value<=t.value:n.value<t.value)||n.issues.push({origin:r,code:"too_big",maximum:t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Mv=N("$ZodCheckGreaterThan",(e,t)=>{tt.init(e,t);let r=tj[typeof t.value];e._zod.onattach.push(n=>{let o=n._zod.bag,s=(t.inclusive?o.minimum:o.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>s&&(t.inclusive?o.minimum=t.value:o.exclusiveMinimum=t.value)}),e._zod.check=n=>{(t.inclusive?n.value>=t.value:n.value>t.value)||n.issues.push({origin:r,code:"too_small",minimum:t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),rj=N("$ZodCheckMultipleOf",(e,t)=>{tt.init(e,t),e._zod.onattach.push(r=>{var n;(n=r._zod.bag).multipleOf??(n.multipleOf=t.value)}),e._zod.check=r=>{if(typeof r.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof r.value=="bigint"?r.value%t.value===BigInt(0):_v(r.value,t.value)===0)||r.issues.push({origin:typeof r.value,code:"not_multiple_of",divisor:t.value,input:r.value,inst:e,continue:!t.abort})}}),nj=N("$ZodCheckNumberFormat",(e,t)=>{tt.init(e,t),t.format=t.format||"float64";let r=t.format?.includes("int"),n=r?"int":"number",[o,s]=kv[t.format];e._zod.onattach.push(a=>{let c=a._zod.bag;c.format=t.format,c.minimum=o,c.maximum=s,r&&(c.pattern=KA)}),e._zod.check=a=>{let c=a.value;if(r){if(!Number.isInteger(c)){a.issues.push({expected:n,format:t.format,code:"invalid_type",input:c,inst:e});return}if(!Number.isSafeInteger(c)){c>0?a.issues.push({input:c,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:n,continue:!t.abort}):a.issues.push({input:c,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:n,continue:!t.abort});return}}c<o&&a.issues.push({origin:"number",input:c,code:"too_small",minimum:o,inclusive:!0,inst:e,continue:!t.abort}),c>s&&a.issues.push({origin:"number",input:c,code:"too_big",maximum:s,inst:e})}});var oj=N("$ZodCheckMaxLength",(e,t)=>{var r;tt.init(e,t),(r=e._zod.def).when??(r.when=n=>{let o=n.value;return!ml(o)&&o.length!==void 0}),e._zod.onattach.push(n=>{let o=n._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<o&&(n._zod.bag.maximum=t.maximum)}),e._zod.check=n=>{let o=n.value;if(o.length<=t.maximum)return;let a=gl(o);n.issues.push({origin:a,code:"too_big",maximum:t.maximum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),sj=N("$ZodCheckMinLength",(e,t)=>{var r;tt.init(e,t),(r=e._zod.def).when??(r.when=n=>{let o=n.value;return!ml(o)&&o.length!==void 0}),e._zod.onattach.push(n=>{let o=n._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>o&&(n._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{let o=n.value;if(o.length>=t.minimum)return;let a=gl(o);n.issues.push({origin:a,code:"too_small",minimum:t.minimum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),ij=N("$ZodCheckLengthEquals",(e,t)=>{var r;tt.init(e,t),(r=e._zod.def).when??(r.when=n=>{let o=n.value;return!ml(o)&&o.length!==void 0}),e._zod.onattach.push(n=>{let o=n._zod.bag;o.minimum=t.length,o.maximum=t.length,o.length=t.length}),e._zod.check=n=>{let o=n.value,s=o.length;if(s===t.length)return;let a=gl(o),c=s>t.length;n.issues.push({origin:a,...c?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),xl=N("$ZodCheckStringFormat",(e,t)=>{var r,n;tt.init(e,t),e._zod.onattach.push(o=>{let s=o._zod.bag;s.format=t.format,t.pattern&&(s.patterns??(s.patterns=new Set),s.patterns.add(t.pattern))}),t.pattern?(r=e._zod).check??(r.check=o=>{t.pattern.lastIndex=0,!t.pattern.test(o.value)&&o.issues.push({origin:"string",code:"invalid_format",format:t.format,input:o.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(n=e._zod).check??(n.check=()=>{})}),aj=N("$ZodCheckRegex",(e,t)=>{xl.init(e,t),e._zod.check=r=>{t.pattern.lastIndex=0,!t.pattern.test(r.value)&&r.issues.push({origin:"string",code:"invalid_format",format:"regex",input:r.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),cj=N("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=QA),xl.init(e,t)}),lj=N("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=ej),xl.init(e,t)}),uj=N("$ZodCheckIncludes",(e,t)=>{tt.init(e,t);let r=Kn(t.includes),n=new RegExp(typeof t.position=="number"?`^.{${t.position}}${r}`:r);t.pattern=n,e._zod.onattach.push(o=>{let s=o._zod.bag;s.patterns??(s.patterns=new Set),s.patterns.add(n)}),e._zod.check=o=>{o.value.includes(t.includes,t.position)||o.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:o.value,inst:e,continue:!t.abort})}}),dj=N("$ZodCheckStartsWith",(e,t)=>{tt.init(e,t);let r=new RegExp(`^${Kn(t.prefix)}.*`);t.pattern??(t.pattern=r),e._zod.onattach.push(n=>{let o=n._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(r)}),e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),pj=N("$ZodCheckEndsWith",(e,t)=>{tt.init(e,t);let r=new RegExp(`.*${Kn(t.suffix)}$`);t.pattern??(t.pattern=r),e._zod.onattach.push(n=>{let o=n._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(r)}),e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}});var fj=N("$ZodCheckOverwrite",(e,t)=>{tt.init(e,t),e._zod.check=r=>{r.value=t.tx(r.value)}});var Zv=class Zv{constructor(t=[]){this.content=[],this.indent=0,this&&(this.args=t)}indented(t){this.indent+=1,t(this),this.indent-=1}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}let n=t.split(`
324
+ `),t.verbose&&console.error(n.stack),process.exit(1)}}i(db,"designCommand");var Oe={};C(Oe,{BRAND:()=>N7,DIRTY:()=>As,EMPTY_PATH:()=>s7,INVALID:()=>Y,NEVER:()=>uY,OK:()=>ut,ParseStatus:()=>nt,Schema:()=>oe,ZodAny:()=>_o,ZodArray:()=>Un,ZodBigInt:()=>Ds,ZodBoolean:()=>Ms,ZodBranded:()=>ju,ZodCatch:()=>Js,ZodDate:()=>Zs,ZodDefault:()=>Ws,ZodDiscriminatedUnion:()=>wh,ZodEffects:()=>ur,ZodEnum:()=>Vs,ZodError:()=>zt,ZodFirstPartyTypeKind:()=>j,ZodFunction:()=>Sh,ZodIntersection:()=>qs,ZodIssueCode:()=>P,ZodLazy:()=>Bs,ZodLiteral:()=>Hs,ZodMap:()=>qa,ZodNaN:()=>Ha,ZodNativeEnum:()=>Gs,ZodNever:()=>Tr,ZodNull:()=>Fs,ZodNullable:()=>en,ZodNumber:()=>js,ZodObject:()=>It,ZodOptional:()=>Ct,ZodParsedType:()=>U,ZodPipeline:()=>Du,ZodPromise:()=>vo,ZodReadonly:()=>Ks,ZodRecord:()=>bh,ZodSchema:()=>oe,ZodSet:()=>Ba,ZodString:()=>xo,ZodSymbol:()=>Fa,ZodTransformer:()=>ur,ZodTuple:()=>Qr,ZodType:()=>oe,ZodUndefined:()=>Ls,ZodUnion:()=>Us,ZodUnknown:()=>Fn,ZodVoid:()=>Ua,addIssueToContext:()=>L,any:()=>j7,array:()=>L7,bigint:()=>I7,boolean:()=>R2,coerce:()=>lY,custom:()=>P2,date:()=>P7,datetimeRegex:()=>C2,defaultErrorMap:()=>Zn,discriminatedUnion:()=>q7,effect:()=>tY,enum:()=>X7,function:()=>J7,getErrorMap:()=>ja,getParsedType:()=>Xr,instanceof:()=>z7,intersection:()=>B7,isAborted:()=>_h,isAsync:()=>Da,isDirty:()=>vh,isValid:()=>yo,late:()=>T7,lazy:()=>K7,literal:()=>Y7,makeIssue:()=>Cu,map:()=>G7,nan:()=>C7,nativeEnum:()=>Q7,never:()=>M7,null:()=>R7,nullable:()=>nY,number:()=>A2,object:()=>hb,objectUtil:()=>pb,oboolean:()=>cY,onumber:()=>aY,optional:()=>rY,ostring:()=>iY,pipeline:()=>sY,preprocess:()=>oY,promise:()=>eY,quotelessJson:()=>r7,record:()=>V7,set:()=>W7,setErrorMap:()=>o7,strictObject:()=>F7,string:()=>O2,symbol:()=>O7,transformer:()=>tY,tuple:()=>H7,undefined:()=>A7,union:()=>U7,unknown:()=>D7,util:()=>le,void:()=>Z7});var le;(function(e){e.assertEqual=o=>{};function t(o){}i(t,"assertIs"),e.assertIs=t;function r(o){throw new Error}i(r,"assertNever"),e.assertNever=r,e.arrayToEnum=o=>{let s={};for(let a of o)s[a]=a;return s},e.getValidEnumValues=o=>{let s=e.objectKeys(o).filter(c=>typeof o[o[c]]!="number"),a={};for(let c of s)a[c]=o[c];return e.objectValues(a)},e.objectValues=o=>e.objectKeys(o).map(function(s){return o[s]}),e.objectKeys=typeof Object.keys=="function"?o=>Object.keys(o):o=>{let s=[];for(let a in o)Object.prototype.hasOwnProperty.call(o,a)&&s.push(a);return s},e.find=(o,s)=>{for(let a of o)if(s(a))return a},e.isInteger=typeof Number.isInteger=="function"?o=>Number.isInteger(o):o=>typeof o=="number"&&Number.isFinite(o)&&Math.floor(o)===o;function n(o,s=" | "){return o.map(a=>typeof a=="string"?`'${a}'`:a).join(s)}i(n,"joinValues"),e.joinValues=n,e.jsonStringifyReplacer=(o,s)=>typeof s=="bigint"?s.toString():s})(le||(le={}));var pb;(function(e){e.mergeShapes=(t,r)=>({...t,...r})})(pb||(pb={}));var U=le.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Xr=i(e=>{switch(typeof e){case"undefined":return U.undefined;case"string":return U.string;case"number":return Number.isNaN(e)?U.nan:U.number;case"boolean":return U.boolean;case"function":return U.function;case"bigint":return U.bigint;case"symbol":return U.symbol;case"object":return Array.isArray(e)?U.array:e===null?U.null:e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?U.promise:typeof Map<"u"&&e instanceof Map?U.map:typeof Set<"u"&&e instanceof Set?U.set:typeof Date<"u"&&e instanceof Date?U.date:U.object;default:return U.unknown}},"getParsedType");var P=le.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),r7=i(e=>JSON.stringify(e,null,2).replace(/"([^"]+)":/g,"$1:"),"quotelessJson"),yh=class yh extends Error{get errors(){return this.issues}constructor(t){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};let r=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,r):this.__proto__=r,this.name="ZodError",this.issues=t}format(t){let r=t||function(s){return s.message},n={_errors:[]},o=i(s=>{for(let a of s.issues)if(a.code==="invalid_union")a.unionErrors.map(o);else if(a.code==="invalid_return_type")o(a.returnTypeError);else if(a.code==="invalid_arguments")o(a.argumentsError);else if(a.path.length===0)n._errors.push(r(a));else{let c=n,l=0;for(;l<a.path.length;){let u=a.path[l];l===a.path.length-1?(c[u]=c[u]||{_errors:[]},c[u]._errors.push(r(a))):c[u]=c[u]||{_errors:[]},c=c[u],l++}}},"processError");return o(this),n}static assert(t){if(!(t instanceof yh))throw new Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,le.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(t=r=>r.message){let r={},n=[];for(let o of this.issues)if(o.path.length>0){let s=o.path[0];r[s]=r[s]||[],r[s].push(t(o))}else n.push(t(o));return{formErrors:n,fieldErrors:r}}get formErrors(){return this.flatten()}};i(yh,"ZodError");var zt=yh;zt.create=e=>new zt(e);var n7=i((e,t)=>{let r;switch(e.code){case P.invalid_type:e.received===U.undefined?r="Required":r=`Expected ${e.expected}, received ${e.received}`;break;case P.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(e.expected,le.jsonStringifyReplacer)}`;break;case P.unrecognized_keys:r=`Unrecognized key(s) in object: ${le.joinValues(e.keys,", ")}`;break;case P.invalid_union:r="Invalid input";break;case P.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${le.joinValues(e.options)}`;break;case P.invalid_enum_value:r=`Invalid enum value. Expected ${le.joinValues(e.options)}, received '${e.received}'`;break;case P.invalid_arguments:r="Invalid function arguments";break;case P.invalid_return_type:r="Invalid function return type";break;case P.invalid_date:r="Invalid date";break;case P.invalid_string:typeof e.validation=="object"?"includes"in e.validation?(r=`Invalid input: must include "${e.validation.includes}"`,typeof e.validation.position=="number"&&(r=`${r} at one or more positions greater than or equal to ${e.validation.position}`)):"startsWith"in e.validation?r=`Invalid input: must start with "${e.validation.startsWith}"`:"endsWith"in e.validation?r=`Invalid input: must end with "${e.validation.endsWith}"`:le.assertNever(e.validation):e.validation!=="regex"?r=`Invalid ${e.validation}`:r="Invalid";break;case P.too_small:e.type==="array"?r=`Array must contain ${e.exact?"exactly":e.inclusive?"at least":"more than"} ${e.minimum} element(s)`:e.type==="string"?r=`String must contain ${e.exact?"exactly":e.inclusive?"at least":"over"} ${e.minimum} character(s)`:e.type==="number"?r=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:e.type==="bigint"?r=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:e.type==="date"?r=`Date must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(e.minimum))}`:r="Invalid input";break;case P.too_big:e.type==="array"?r=`Array must contain ${e.exact?"exactly":e.inclusive?"at most":"less than"} ${e.maximum} element(s)`:e.type==="string"?r=`String must contain ${e.exact?"exactly":e.inclusive?"at most":"under"} ${e.maximum} character(s)`:e.type==="number"?r=`Number must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="bigint"?r=`BigInt must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="date"?r=`Date must be ${e.exact?"exactly":e.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(e.maximum))}`:r="Invalid input";break;case P.custom:r="Invalid input";break;case P.invalid_intersection_types:r="Intersection results could not be merged";break;case P.not_multiple_of:r=`Number must be a multiple of ${e.multipleOf}`;break;case P.not_finite:r="Number must be finite";break;default:r=t.defaultError,le.assertNever(e)}return{message:r}},"errorMap"),Zn=n7;var $2=Zn;function o7(e){$2=e}i(o7,"setErrorMap");function ja(){return $2}i(ja,"getErrorMap");var Cu=i(e=>{let{data:t,path:r,errorMaps:n,issueData:o}=e,s=[...r,...o.path||[]],a={...o,path:s};if(o.message!==void 0)return{...o,path:s,message:o.message};let c="",l=n.filter(u=>!!u).slice().reverse();for(let u of l)c=u(a,{data:t,defaultError:c}).message;return{...o,path:s,message:c}},"makeIssue"),s7=[];function L(e,t){let r=ja(),n=Cu({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,r,r===Zn?void 0:Zn].filter(o=>!!o)});e.common.issues.push(n)}i(L,"addIssueToContext");var xh=class xh{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(t,r){let n=[];for(let o of r){if(o.status==="aborted")return Y;o.status==="dirty"&&t.dirty(),n.push(o.value)}return{status:t.value,value:n}}static async mergeObjectAsync(t,r){let n=[];for(let o of r){let s=await o.key,a=await o.value;n.push({key:s,value:a})}return xh.mergeObjectSync(t,n)}static mergeObjectSync(t,r){let n={};for(let o of r){let{key:s,value:a}=o;if(s.status==="aborted"||a.status==="aborted")return Y;s.status==="dirty"&&t.dirty(),a.status==="dirty"&&t.dirty(),s.value!=="__proto__"&&(typeof a.value<"u"||o.alwaysSet)&&(n[s.value]=a.value)}return{status:t.value,value:n}}};i(xh,"ParseStatus");var nt=xh,Y=Object.freeze({status:"aborted"}),As=i(e=>({status:"dirty",value:e}),"DIRTY"),ut=i(e=>({status:"valid",value:e}),"OK"),_h=i(e=>e.status==="aborted","isAborted"),vh=i(e=>e.status==="dirty","isDirty"),yo=i(e=>e.status==="valid","isValid"),Da=i(e=>typeof Promise<"u"&&e instanceof Promise,"isAsync");var B;(function(e){e.errToObj=t=>typeof t=="string"?{message:t}:t||{},e.toString=t=>typeof t=="string"?t:t?.message})(B||(B={}));var gb=class gb{constructor(t,r,n,o){this._cachedPath=[],this.parent=t,this.data=r,this._path=n,this._key=o}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}};i(gb,"ParseInputLazyPath");var lr=gb,E2=i((e,t)=>{if(yo(t))return{success:!0,data:t.value};if(!e.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let r=new zt(e.common.issues);return this._error=r,this._error}}},"handleResult");function re(e){if(!e)return{};let{errorMap:t,invalid_type_error:r,required_error:n,description:o}=e;if(t&&(r||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return t?{errorMap:t,description:o}:{errorMap:i((a,c)=>{let{message:l}=e;return a.code==="invalid_enum_value"?{message:l??c.defaultError}:typeof c.data>"u"?{message:l??n??c.defaultError}:a.code!=="invalid_type"?{message:c.defaultError}:{message:l??r??c.defaultError}},"customMap"),description:o}}i(re,"processCreateParams");var yb=class yb{get description(){return this._def.description}_getType(t){return Xr(t.data)}_getOrReturnCtx(t,r){return r||{common:t.parent.common,data:t.data,parsedType:Xr(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}_processInputParams(t){return{status:new nt,ctx:{common:t.parent.common,data:t.data,parsedType:Xr(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}}_parseSync(t){let r=this._parse(t);if(Da(r))throw new Error("Synchronous parse encountered promise.");return r}_parseAsync(t){let r=this._parse(t);return Promise.resolve(r)}parse(t,r){let n=this.safeParse(t,r);if(n.success)return n.data;throw n.error}safeParse(t,r){let n={common:{issues:[],async:r?.async??!1,contextualErrorMap:r?.errorMap},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:Xr(t)},o=this._parseSync({data:t,path:n.path,parent:n});return E2(n,o)}"~validate"(t){let r={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:Xr(t)};if(!this["~standard"].async)try{let n=this._parseSync({data:t,path:[],parent:r});return yo(n)?{value:n.value}:{issues:r.common.issues}}catch(n){n?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),r.common={issues:[],async:!0}}return this._parseAsync({data:t,path:[],parent:r}).then(n=>yo(n)?{value:n.value}:{issues:r.common.issues})}async parseAsync(t,r){let n=await this.safeParseAsync(t,r);if(n.success)return n.data;throw n.error}async safeParseAsync(t,r){let n={common:{issues:[],contextualErrorMap:r?.errorMap,async:!0},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:Xr(t)},o=this._parse({data:t,path:n.path,parent:n}),s=await(Da(o)?o:Promise.resolve(o));return E2(n,s)}refine(t,r){let n=i(o=>typeof r=="string"||typeof r>"u"?{message:r}:typeof r=="function"?r(o):r,"getIssueProperties");return this._refinement((o,s)=>{let a=t(o),c=i(()=>s.addIssue({code:P.custom,...n(o)}),"setError");return typeof Promise<"u"&&a instanceof Promise?a.then(l=>l?!0:(c(),!1)):a?!0:(c(),!1)})}refinement(t,r){return this._refinement((n,o)=>t(n)?!0:(o.addIssue(typeof r=="function"?r(n,o):r),!1))}_refinement(t){return new ur({schema:this,typeName:j.ZodEffects,effect:{type:"refinement",refinement:t}})}superRefine(t){return this._refinement(t)}constructor(t){this.spa=this.safeParseAsync,this._def=t,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:r=>this["~validate"](r)}}optional(){return Ct.create(this,this._def)}nullable(){return en.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Un.create(this)}promise(){return vo.create(this,this._def)}or(t){return Us.create([this,t],this._def)}and(t){return qs.create(this,t,this._def)}transform(t){return new ur({...re(this._def),schema:this,typeName:j.ZodEffects,effect:{type:"transform",transform:t}})}default(t){let r=typeof t=="function"?t:()=>t;return new Ws({...re(this._def),innerType:this,defaultValue:r,typeName:j.ZodDefault})}brand(){return new ju({typeName:j.ZodBranded,type:this,...re(this._def)})}catch(t){let r=typeof t=="function"?t:()=>t;return new Js({...re(this._def),innerType:this,catchValue:r,typeName:j.ZodCatch})}describe(t){let r=this.constructor;return new r({...this._def,description:t})}pipe(t){return Du.create(this,t)}readonly(){return Ks.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}};i(yb,"ZodType");var oe=yb,i7=/^c[^\s-]{8,}$/i,a7=/^[0-9a-z]+$/,c7=/^[0-9A-HJKMNP-TV-Z]{26}$/i,l7=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,u7=/^[a-z0-9_-]{21}$/i,d7=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,p7=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,f7=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,m7="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",fb,h7=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,g7=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,y7=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,x7=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,_7=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,v7=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,T2="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",w7=new RegExp(`^${T2}$`);function z2(e){let t="[0-5]\\d";e.precision?t=`${t}\\.\\d{${e.precision}}`:e.precision==null&&(t=`${t}(\\.\\d+)?`);let r=e.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${t})${r}`}i(z2,"timeRegexSource");function b7(e){return new RegExp(`^${z2(e)}$`)}i(b7,"timeRegex");function C2(e){let t=`${T2}T${z2(e)}`,r=[];return r.push(e.local?"Z?":"Z"),e.offset&&r.push("([+-]\\d{2}:?\\d{2})"),t=`${t}(${r.join("|")})`,new RegExp(`^${t}$`)}i(C2,"datetimeRegex");function S7(e,t){return!!((t==="v4"||!t)&&h7.test(e)||(t==="v6"||!t)&&y7.test(e))}i(S7,"isValidIP");function k7(e,t){if(!d7.test(e))return!1;try{let[r]=e.split(".");if(!r)return!1;let n=r.replace(/-/g,"+").replace(/_/g,"/").padEnd(r.length+(4-r.length%4)%4,"="),o=JSON.parse(atob(n));return!(typeof o!="object"||o===null||"typ"in o&&o?.typ!=="JWT"||!o.alg||t&&o.alg!==t)}catch{return!1}}i(k7,"isValidJWT");function $7(e,t){return!!((t==="v4"||!t)&&g7.test(e)||(t==="v6"||!t)&&x7.test(e))}i($7,"isValidCidr");var Rs=class Rs extends oe{_parse(t){if(this._def.coerce&&(t.data=String(t.data)),this._getType(t)!==U.string){let s=this._getOrReturnCtx(t);return L(s,{code:P.invalid_type,expected:U.string,received:s.parsedType}),Y}let n=new nt,o;for(let s of this._def.checks)if(s.kind==="min")t.data.length<s.value&&(o=this._getOrReturnCtx(t,o),L(o,{code:P.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),n.dirty());else if(s.kind==="max")t.data.length>s.value&&(o=this._getOrReturnCtx(t,o),L(o,{code:P.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),n.dirty());else if(s.kind==="length"){let a=t.data.length>s.value,c=t.data.length<s.value;(a||c)&&(o=this._getOrReturnCtx(t,o),a?L(o,{code:P.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}):c&&L(o,{code:P.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}),n.dirty())}else if(s.kind==="email")f7.test(t.data)||(o=this._getOrReturnCtx(t,o),L(o,{validation:"email",code:P.invalid_string,message:s.message}),n.dirty());else if(s.kind==="emoji")fb||(fb=new RegExp(m7,"u")),fb.test(t.data)||(o=this._getOrReturnCtx(t,o),L(o,{validation:"emoji",code:P.invalid_string,message:s.message}),n.dirty());else if(s.kind==="uuid")l7.test(t.data)||(o=this._getOrReturnCtx(t,o),L(o,{validation:"uuid",code:P.invalid_string,message:s.message}),n.dirty());else if(s.kind==="nanoid")u7.test(t.data)||(o=this._getOrReturnCtx(t,o),L(o,{validation:"nanoid",code:P.invalid_string,message:s.message}),n.dirty());else if(s.kind==="cuid")i7.test(t.data)||(o=this._getOrReturnCtx(t,o),L(o,{validation:"cuid",code:P.invalid_string,message:s.message}),n.dirty());else if(s.kind==="cuid2")a7.test(t.data)||(o=this._getOrReturnCtx(t,o),L(o,{validation:"cuid2",code:P.invalid_string,message:s.message}),n.dirty());else if(s.kind==="ulid")c7.test(t.data)||(o=this._getOrReturnCtx(t,o),L(o,{validation:"ulid",code:P.invalid_string,message:s.message}),n.dirty());else if(s.kind==="url")try{new URL(t.data)}catch{o=this._getOrReturnCtx(t,o),L(o,{validation:"url",code:P.invalid_string,message:s.message}),n.dirty()}else s.kind==="regex"?(s.regex.lastIndex=0,s.regex.test(t.data)||(o=this._getOrReturnCtx(t,o),L(o,{validation:"regex",code:P.invalid_string,message:s.message}),n.dirty())):s.kind==="trim"?t.data=t.data.trim():s.kind==="includes"?t.data.includes(s.value,s.position)||(o=this._getOrReturnCtx(t,o),L(o,{code:P.invalid_string,validation:{includes:s.value,position:s.position},message:s.message}),n.dirty()):s.kind==="toLowerCase"?t.data=t.data.toLowerCase():s.kind==="toUpperCase"?t.data=t.data.toUpperCase():s.kind==="startsWith"?t.data.startsWith(s.value)||(o=this._getOrReturnCtx(t,o),L(o,{code:P.invalid_string,validation:{startsWith:s.value},message:s.message}),n.dirty()):s.kind==="endsWith"?t.data.endsWith(s.value)||(o=this._getOrReturnCtx(t,o),L(o,{code:P.invalid_string,validation:{endsWith:s.value},message:s.message}),n.dirty()):s.kind==="datetime"?C2(s).test(t.data)||(o=this._getOrReturnCtx(t,o),L(o,{code:P.invalid_string,validation:"datetime",message:s.message}),n.dirty()):s.kind==="date"?w7.test(t.data)||(o=this._getOrReturnCtx(t,o),L(o,{code:P.invalid_string,validation:"date",message:s.message}),n.dirty()):s.kind==="time"?b7(s).test(t.data)||(o=this._getOrReturnCtx(t,o),L(o,{code:P.invalid_string,validation:"time",message:s.message}),n.dirty()):s.kind==="duration"?p7.test(t.data)||(o=this._getOrReturnCtx(t,o),L(o,{validation:"duration",code:P.invalid_string,message:s.message}),n.dirty()):s.kind==="ip"?S7(t.data,s.version)||(o=this._getOrReturnCtx(t,o),L(o,{validation:"ip",code:P.invalid_string,message:s.message}),n.dirty()):s.kind==="jwt"?k7(t.data,s.alg)||(o=this._getOrReturnCtx(t,o),L(o,{validation:"jwt",code:P.invalid_string,message:s.message}),n.dirty()):s.kind==="cidr"?$7(t.data,s.version)||(o=this._getOrReturnCtx(t,o),L(o,{validation:"cidr",code:P.invalid_string,message:s.message}),n.dirty()):s.kind==="base64"?_7.test(t.data)||(o=this._getOrReturnCtx(t,o),L(o,{validation:"base64",code:P.invalid_string,message:s.message}),n.dirty()):s.kind==="base64url"?v7.test(t.data)||(o=this._getOrReturnCtx(t,o),L(o,{validation:"base64url",code:P.invalid_string,message:s.message}),n.dirty()):le.assertNever(s);return{status:n.value,value:t.data}}_regex(t,r,n){return this.refinement(o=>t.test(o),{validation:r,code:P.invalid_string,...B.errToObj(n)})}_addCheck(t){return new Rs({...this._def,checks:[...this._def.checks,t]})}email(t){return this._addCheck({kind:"email",...B.errToObj(t)})}url(t){return this._addCheck({kind:"url",...B.errToObj(t)})}emoji(t){return this._addCheck({kind:"emoji",...B.errToObj(t)})}uuid(t){return this._addCheck({kind:"uuid",...B.errToObj(t)})}nanoid(t){return this._addCheck({kind:"nanoid",...B.errToObj(t)})}cuid(t){return this._addCheck({kind:"cuid",...B.errToObj(t)})}cuid2(t){return this._addCheck({kind:"cuid2",...B.errToObj(t)})}ulid(t){return this._addCheck({kind:"ulid",...B.errToObj(t)})}base64(t){return this._addCheck({kind:"base64",...B.errToObj(t)})}base64url(t){return this._addCheck({kind:"base64url",...B.errToObj(t)})}jwt(t){return this._addCheck({kind:"jwt",...B.errToObj(t)})}ip(t){return this._addCheck({kind:"ip",...B.errToObj(t)})}cidr(t){return this._addCheck({kind:"cidr",...B.errToObj(t)})}datetime(t){return typeof t=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:t}):this._addCheck({kind:"datetime",precision:typeof t?.precision>"u"?null:t?.precision,offset:t?.offset??!1,local:t?.local??!1,...B.errToObj(t?.message)})}date(t){return this._addCheck({kind:"date",message:t})}time(t){return typeof t=="string"?this._addCheck({kind:"time",precision:null,message:t}):this._addCheck({kind:"time",precision:typeof t?.precision>"u"?null:t?.precision,...B.errToObj(t?.message)})}duration(t){return this._addCheck({kind:"duration",...B.errToObj(t)})}regex(t,r){return this._addCheck({kind:"regex",regex:t,...B.errToObj(r)})}includes(t,r){return this._addCheck({kind:"includes",value:t,position:r?.position,...B.errToObj(r?.message)})}startsWith(t,r){return this._addCheck({kind:"startsWith",value:t,...B.errToObj(r)})}endsWith(t,r){return this._addCheck({kind:"endsWith",value:t,...B.errToObj(r)})}min(t,r){return this._addCheck({kind:"min",value:t,...B.errToObj(r)})}max(t,r){return this._addCheck({kind:"max",value:t,...B.errToObj(r)})}length(t,r){return this._addCheck({kind:"length",value:t,...B.errToObj(r)})}nonempty(t){return this.min(1,B.errToObj(t))}trim(){return new Rs({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new Rs({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new Rs({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(t=>t.kind==="datetime")}get isDate(){return!!this._def.checks.find(t=>t.kind==="date")}get isTime(){return!!this._def.checks.find(t=>t.kind==="time")}get isDuration(){return!!this._def.checks.find(t=>t.kind==="duration")}get isEmail(){return!!this._def.checks.find(t=>t.kind==="email")}get isURL(){return!!this._def.checks.find(t=>t.kind==="url")}get isEmoji(){return!!this._def.checks.find(t=>t.kind==="emoji")}get isUUID(){return!!this._def.checks.find(t=>t.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(t=>t.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(t=>t.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(t=>t.kind==="cuid2")}get isULID(){return!!this._def.checks.find(t=>t.kind==="ulid")}get isIP(){return!!this._def.checks.find(t=>t.kind==="ip")}get isCIDR(){return!!this._def.checks.find(t=>t.kind==="cidr")}get isBase64(){return!!this._def.checks.find(t=>t.kind==="base64")}get isBase64url(){return!!this._def.checks.find(t=>t.kind==="base64url")}get minLength(){let t=null;for(let r of this._def.checks)r.kind==="min"&&(t===null||r.value>t)&&(t=r.value);return t}get maxLength(){let t=null;for(let r of this._def.checks)r.kind==="max"&&(t===null||r.value<t)&&(t=r.value);return t}};i(Rs,"ZodString");var xo=Rs;xo.create=e=>new xo({checks:[],typeName:j.ZodString,coerce:e?.coerce??!1,...re(e)});function E7(e,t){let r=(e.toString().split(".")[1]||"").length,n=(t.toString().split(".")[1]||"").length,o=r>n?r:n,s=Number.parseInt(e.toFixed(o).replace(".","")),a=Number.parseInt(t.toFixed(o).replace(".",""));return s%a/10**o}i(E7,"floatSafeRemainder");var Iu=class Iu extends oe{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(t){if(this._def.coerce&&(t.data=Number(t.data)),this._getType(t)!==U.number){let s=this._getOrReturnCtx(t);return L(s,{code:P.invalid_type,expected:U.number,received:s.parsedType}),Y}let n,o=new nt;for(let s of this._def.checks)s.kind==="int"?le.isInteger(t.data)||(n=this._getOrReturnCtx(t,n),L(n,{code:P.invalid_type,expected:"integer",received:"float",message:s.message}),o.dirty()):s.kind==="min"?(s.inclusive?t.data<s.value:t.data<=s.value)&&(n=this._getOrReturnCtx(t,n),L(n,{code:P.too_small,minimum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),o.dirty()):s.kind==="max"?(s.inclusive?t.data>s.value:t.data>=s.value)&&(n=this._getOrReturnCtx(t,n),L(n,{code:P.too_big,maximum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),o.dirty()):s.kind==="multipleOf"?E7(t.data,s.value)!==0&&(n=this._getOrReturnCtx(t,n),L(n,{code:P.not_multiple_of,multipleOf:s.value,message:s.message}),o.dirty()):s.kind==="finite"?Number.isFinite(t.data)||(n=this._getOrReturnCtx(t,n),L(n,{code:P.not_finite,message:s.message}),o.dirty()):le.assertNever(s);return{status:o.value,value:t.data}}gte(t,r){return this.setLimit("min",t,!0,B.toString(r))}gt(t,r){return this.setLimit("min",t,!1,B.toString(r))}lte(t,r){return this.setLimit("max",t,!0,B.toString(r))}lt(t,r){return this.setLimit("max",t,!1,B.toString(r))}setLimit(t,r,n,o){return new Iu({...this._def,checks:[...this._def.checks,{kind:t,value:r,inclusive:n,message:B.toString(o)}]})}_addCheck(t){return new Iu({...this._def,checks:[...this._def.checks,t]})}int(t){return this._addCheck({kind:"int",message:B.toString(t)})}positive(t){return this._addCheck({kind:"min",value:0,inclusive:!1,message:B.toString(t)})}negative(t){return this._addCheck({kind:"max",value:0,inclusive:!1,message:B.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:0,inclusive:!0,message:B.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:0,inclusive:!0,message:B.toString(t)})}multipleOf(t,r){return this._addCheck({kind:"multipleOf",value:t,message:B.toString(r)})}finite(t){return this._addCheck({kind:"finite",message:B.toString(t)})}safe(t){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:B.toString(t)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:B.toString(t)})}get minValue(){let t=null;for(let r of this._def.checks)r.kind==="min"&&(t===null||r.value>t)&&(t=r.value);return t}get maxValue(){let t=null;for(let r of this._def.checks)r.kind==="max"&&(t===null||r.value<t)&&(t=r.value);return t}get isInt(){return!!this._def.checks.find(t=>t.kind==="int"||t.kind==="multipleOf"&&le.isInteger(t.value))}get isFinite(){let t=null,r=null;for(let n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(r===null||n.value>r)&&(r=n.value):n.kind==="max"&&(t===null||n.value<t)&&(t=n.value)}return Number.isFinite(r)&&Number.isFinite(t)}};i(Iu,"ZodNumber");var js=Iu;js.create=e=>new js({checks:[],typeName:j.ZodNumber,coerce:e?.coerce||!1,...re(e)});var Pu=class Pu extends oe{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(t){if(this._def.coerce)try{t.data=BigInt(t.data)}catch{return this._getInvalidInput(t)}if(this._getType(t)!==U.bigint)return this._getInvalidInput(t);let n,o=new nt;for(let s of this._def.checks)s.kind==="min"?(s.inclusive?t.data<s.value:t.data<=s.value)&&(n=this._getOrReturnCtx(t,n),L(n,{code:P.too_small,type:"bigint",minimum:s.value,inclusive:s.inclusive,message:s.message}),o.dirty()):s.kind==="max"?(s.inclusive?t.data>s.value:t.data>=s.value)&&(n=this._getOrReturnCtx(t,n),L(n,{code:P.too_big,type:"bigint",maximum:s.value,inclusive:s.inclusive,message:s.message}),o.dirty()):s.kind==="multipleOf"?t.data%s.value!==BigInt(0)&&(n=this._getOrReturnCtx(t,n),L(n,{code:P.not_multiple_of,multipleOf:s.value,message:s.message}),o.dirty()):le.assertNever(s);return{status:o.value,value:t.data}}_getInvalidInput(t){let r=this._getOrReturnCtx(t);return L(r,{code:P.invalid_type,expected:U.bigint,received:r.parsedType}),Y}gte(t,r){return this.setLimit("min",t,!0,B.toString(r))}gt(t,r){return this.setLimit("min",t,!1,B.toString(r))}lte(t,r){return this.setLimit("max",t,!0,B.toString(r))}lt(t,r){return this.setLimit("max",t,!1,B.toString(r))}setLimit(t,r,n,o){return new Pu({...this._def,checks:[...this._def.checks,{kind:t,value:r,inclusive:n,message:B.toString(o)}]})}_addCheck(t){return new Pu({...this._def,checks:[...this._def.checks,t]})}positive(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:B.toString(t)})}negative(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:B.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:B.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:B.toString(t)})}multipleOf(t,r){return this._addCheck({kind:"multipleOf",value:t,message:B.toString(r)})}get minValue(){let t=null;for(let r of this._def.checks)r.kind==="min"&&(t===null||r.value>t)&&(t=r.value);return t}get maxValue(){let t=null;for(let r of this._def.checks)r.kind==="max"&&(t===null||r.value<t)&&(t=r.value);return t}};i(Pu,"ZodBigInt");var Ds=Pu;Ds.create=e=>new Ds({checks:[],typeName:j.ZodBigInt,coerce:e?.coerce??!1,...re(e)});var xb=class xb extends oe{_parse(t){if(this._def.coerce&&(t.data=!!t.data),this._getType(t)!==U.boolean){let n=this._getOrReturnCtx(t);return L(n,{code:P.invalid_type,expected:U.boolean,received:n.parsedType}),Y}return ut(t.data)}};i(xb,"ZodBoolean");var Ms=xb;Ms.create=e=>new Ms({typeName:j.ZodBoolean,coerce:e?.coerce||!1,...re(e)});var kh=class kh extends oe{_parse(t){if(this._def.coerce&&(t.data=new Date(t.data)),this._getType(t)!==U.date){let s=this._getOrReturnCtx(t);return L(s,{code:P.invalid_type,expected:U.date,received:s.parsedType}),Y}if(Number.isNaN(t.data.getTime())){let s=this._getOrReturnCtx(t);return L(s,{code:P.invalid_date}),Y}let n=new nt,o;for(let s of this._def.checks)s.kind==="min"?t.data.getTime()<s.value&&(o=this._getOrReturnCtx(t,o),L(o,{code:P.too_small,message:s.message,inclusive:!0,exact:!1,minimum:s.value,type:"date"}),n.dirty()):s.kind==="max"?t.data.getTime()>s.value&&(o=this._getOrReturnCtx(t,o),L(o,{code:P.too_big,message:s.message,inclusive:!0,exact:!1,maximum:s.value,type:"date"}),n.dirty()):le.assertNever(s);return{status:n.value,value:new Date(t.data.getTime())}}_addCheck(t){return new kh({...this._def,checks:[...this._def.checks,t]})}min(t,r){return this._addCheck({kind:"min",value:t.getTime(),message:B.toString(r)})}max(t,r){return this._addCheck({kind:"max",value:t.getTime(),message:B.toString(r)})}get minDate(){let t=null;for(let r of this._def.checks)r.kind==="min"&&(t===null||r.value>t)&&(t=r.value);return t!=null?new Date(t):null}get maxDate(){let t=null;for(let r of this._def.checks)r.kind==="max"&&(t===null||r.value<t)&&(t=r.value);return t!=null?new Date(t):null}};i(kh,"ZodDate");var Zs=kh;Zs.create=e=>new Zs({checks:[],coerce:e?.coerce||!1,typeName:j.ZodDate,...re(e)});var _b=class _b extends oe{_parse(t){if(this._getType(t)!==U.symbol){let n=this._getOrReturnCtx(t);return L(n,{code:P.invalid_type,expected:U.symbol,received:n.parsedType}),Y}return ut(t.data)}};i(_b,"ZodSymbol");var Fa=_b;Fa.create=e=>new Fa({typeName:j.ZodSymbol,...re(e)});var vb=class vb extends oe{_parse(t){if(this._getType(t)!==U.undefined){let n=this._getOrReturnCtx(t);return L(n,{code:P.invalid_type,expected:U.undefined,received:n.parsedType}),Y}return ut(t.data)}};i(vb,"ZodUndefined");var Ls=vb;Ls.create=e=>new Ls({typeName:j.ZodUndefined,...re(e)});var wb=class wb extends oe{_parse(t){if(this._getType(t)!==U.null){let n=this._getOrReturnCtx(t);return L(n,{code:P.invalid_type,expected:U.null,received:n.parsedType}),Y}return ut(t.data)}};i(wb,"ZodNull");var Fs=wb;Fs.create=e=>new Fs({typeName:j.ZodNull,...re(e)});var bb=class bb extends oe{constructor(){super(...arguments),this._any=!0}_parse(t){return ut(t.data)}};i(bb,"ZodAny");var _o=bb;_o.create=e=>new _o({typeName:j.ZodAny,...re(e)});var Sb=class Sb extends oe{constructor(){super(...arguments),this._unknown=!0}_parse(t){return ut(t.data)}};i(Sb,"ZodUnknown");var Fn=Sb;Fn.create=e=>new Fn({typeName:j.ZodUnknown,...re(e)});var kb=class kb extends oe{_parse(t){let r=this._getOrReturnCtx(t);return L(r,{code:P.invalid_type,expected:U.never,received:r.parsedType}),Y}};i(kb,"ZodNever");var Tr=kb;Tr.create=e=>new Tr({typeName:j.ZodNever,...re(e)});var $b=class $b extends oe{_parse(t){if(this._getType(t)!==U.undefined){let n=this._getOrReturnCtx(t);return L(n,{code:P.invalid_type,expected:U.void,received:n.parsedType}),Y}return ut(t.data)}};i($b,"ZodVoid");var Ua=$b;Ua.create=e=>new Ua({typeName:j.ZodVoid,...re(e)});var Za=class Za extends oe{_parse(t){let{ctx:r,status:n}=this._processInputParams(t),o=this._def;if(r.parsedType!==U.array)return L(r,{code:P.invalid_type,expected:U.array,received:r.parsedType}),Y;if(o.exactLength!==null){let a=r.data.length>o.exactLength.value,c=r.data.length<o.exactLength.value;(a||c)&&(L(r,{code:a?P.too_big:P.too_small,minimum:c?o.exactLength.value:void 0,maximum:a?o.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:o.exactLength.message}),n.dirty())}if(o.minLength!==null&&r.data.length<o.minLength.value&&(L(r,{code:P.too_small,minimum:o.minLength.value,type:"array",inclusive:!0,exact:!1,message:o.minLength.message}),n.dirty()),o.maxLength!==null&&r.data.length>o.maxLength.value&&(L(r,{code:P.too_big,maximum:o.maxLength.value,type:"array",inclusive:!0,exact:!1,message:o.maxLength.message}),n.dirty()),r.common.async)return Promise.all([...r.data].map((a,c)=>o.type._parseAsync(new lr(r,a,r.path,c)))).then(a=>nt.mergeArray(n,a));let s=[...r.data].map((a,c)=>o.type._parseSync(new lr(r,a,r.path,c)));return nt.mergeArray(n,s)}get element(){return this._def.type}min(t,r){return new Za({...this._def,minLength:{value:t,message:B.toString(r)}})}max(t,r){return new Za({...this._def,maxLength:{value:t,message:B.toString(r)}})}length(t,r){return new Za({...this._def,exactLength:{value:t,message:B.toString(r)}})}nonempty(t){return this.min(1,t)}};i(Za,"ZodArray");var Un=Za;Un.create=(e,t)=>new Un({type:e,minLength:null,maxLength:null,exactLength:null,typeName:j.ZodArray,...re(t)});function Ma(e){if(e instanceof It){let t={};for(let r in e.shape){let n=e.shape[r];t[r]=Ct.create(Ma(n))}return new It({...e._def,shape:()=>t})}else return e instanceof Un?new Un({...e._def,type:Ma(e.element)}):e instanceof Ct?Ct.create(Ma(e.unwrap())):e instanceof en?en.create(Ma(e.unwrap())):e instanceof Qr?Qr.create(e.items.map(t=>Ma(t))):e}i(Ma,"deepPartialify");var Ht=class Ht extends oe{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let t=this._def.shape(),r=le.objectKeys(t);return this._cached={shape:t,keys:r},this._cached}_parse(t){if(this._getType(t)!==U.object){let u=this._getOrReturnCtx(t);return L(u,{code:P.invalid_type,expected:U.object,received:u.parsedType}),Y}let{status:n,ctx:o}=this._processInputParams(t),{shape:s,keys:a}=this._getCached(),c=[];if(!(this._def.catchall instanceof Tr&&this._def.unknownKeys==="strip"))for(let u in o.data)a.includes(u)||c.push(u);let l=[];for(let u of a){let d=s[u],p=o.data[u];l.push({key:{status:"valid",value:u},value:d._parse(new lr(o,p,o.path,u)),alwaysSet:u in o.data})}if(this._def.catchall instanceof Tr){let u=this._def.unknownKeys;if(u==="passthrough")for(let d of c)l.push({key:{status:"valid",value:d},value:{status:"valid",value:o.data[d]}});else if(u==="strict")c.length>0&&(L(o,{code:P.unrecognized_keys,keys:c}),n.dirty());else if(u!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let u=this._def.catchall;for(let d of c){let p=o.data[d];l.push({key:{status:"valid",value:d},value:u._parse(new lr(o,p,o.path,d)),alwaysSet:d in o.data})}}return o.common.async?Promise.resolve().then(async()=>{let u=[];for(let d of l){let p=await d.key,m=await d.value;u.push({key:p,value:m,alwaysSet:d.alwaysSet})}return u}).then(u=>nt.mergeObjectSync(n,u)):nt.mergeObjectSync(n,l)}get shape(){return this._def.shape()}strict(t){return B.errToObj,new Ht({...this._def,unknownKeys:"strict",...t!==void 0?{errorMap:(r,n)=>{let o=this._def.errorMap?.(r,n).message??n.defaultError;return r.code==="unrecognized_keys"?{message:B.errToObj(t).message??o}:{message:o}}}:{}})}strip(){return new Ht({...this._def,unknownKeys:"strip"})}passthrough(){return new Ht({...this._def,unknownKeys:"passthrough"})}extend(t){return new Ht({...this._def,shape:()=>({...this._def.shape(),...t})})}merge(t){return new Ht({unknownKeys:t._def.unknownKeys,catchall:t._def.catchall,shape:()=>({...this._def.shape(),...t._def.shape()}),typeName:j.ZodObject})}setKey(t,r){return this.augment({[t]:r})}catchall(t){return new Ht({...this._def,catchall:t})}pick(t){let r={};for(let n of le.objectKeys(t))t[n]&&this.shape[n]&&(r[n]=this.shape[n]);return new Ht({...this._def,shape:()=>r})}omit(t){let r={};for(let n of le.objectKeys(this.shape))t[n]||(r[n]=this.shape[n]);return new Ht({...this._def,shape:()=>r})}deepPartial(){return Ma(this)}partial(t){let r={};for(let n of le.objectKeys(this.shape)){let o=this.shape[n];t&&!t[n]?r[n]=o:r[n]=o.optional()}return new Ht({...this._def,shape:()=>r})}required(t){let r={};for(let n of le.objectKeys(this.shape))if(t&&!t[n])r[n]=this.shape[n];else{let s=this.shape[n];for(;s instanceof Ct;)s=s._def.innerType;r[n]=s}return new Ht({...this._def,shape:()=>r})}keyof(){return I2(le.objectKeys(this.shape))}};i(Ht,"ZodObject");var It=Ht;It.create=(e,t)=>new It({shape:()=>e,unknownKeys:"strip",catchall:Tr.create(),typeName:j.ZodObject,...re(t)});It.strictCreate=(e,t)=>new It({shape:()=>e,unknownKeys:"strict",catchall:Tr.create(),typeName:j.ZodObject,...re(t)});It.lazycreate=(e,t)=>new It({shape:e,unknownKeys:"strip",catchall:Tr.create(),typeName:j.ZodObject,...re(t)});var Eb=class Eb extends oe{_parse(t){let{ctx:r}=this._processInputParams(t),n=this._def.options;function o(s){for(let c of s)if(c.result.status==="valid")return c.result;for(let c of s)if(c.result.status==="dirty")return r.common.issues.push(...c.ctx.common.issues),c.result;let a=s.map(c=>new zt(c.ctx.common.issues));return L(r,{code:P.invalid_union,unionErrors:a}),Y}if(i(o,"handleResults"),r.common.async)return Promise.all(n.map(async s=>{let a={...r,common:{...r.common,issues:[]},parent:null};return{result:await s._parseAsync({data:r.data,path:r.path,parent:a}),ctx:a}})).then(o);{let s,a=[];for(let l of n){let u={...r,common:{...r.common,issues:[]},parent:null},d=l._parseSync({data:r.data,path:r.path,parent:u});if(d.status==="valid")return d;d.status==="dirty"&&!s&&(s={result:d,ctx:u}),u.common.issues.length&&a.push(u.common.issues)}if(s)return r.common.issues.push(...s.ctx.common.issues),s.result;let c=a.map(l=>new zt(l));return L(r,{code:P.invalid_union,unionErrors:c}),Y}}get options(){return this._def.options}};i(Eb,"ZodUnion");var Us=Eb;Us.create=(e,t)=>new Us({options:e,typeName:j.ZodUnion,...re(t)});var Ln=i(e=>e instanceof Bs?Ln(e.schema):e instanceof ur?Ln(e.innerType()):e instanceof Hs?[e.value]:e instanceof Vs?e.options:e instanceof Gs?le.objectValues(e.enum):e instanceof Ws?Ln(e._def.innerType):e instanceof Ls?[void 0]:e instanceof Fs?[null]:e instanceof Ct?[void 0,...Ln(e.unwrap())]:e instanceof en?[null,...Ln(e.unwrap())]:e instanceof ju||e instanceof Ks?Ln(e.unwrap()):e instanceof Js?Ln(e._def.innerType):[],"getDiscriminator"),$h=class $h extends oe{_parse(t){let{ctx:r}=this._processInputParams(t);if(r.parsedType!==U.object)return L(r,{code:P.invalid_type,expected:U.object,received:r.parsedType}),Y;let n=this.discriminator,o=r.data[n],s=this.optionsMap.get(o);return s?r.common.async?s._parseAsync({data:r.data,path:r.path,parent:r}):s._parseSync({data:r.data,path:r.path,parent:r}):(L(r,{code:P.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),Y)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(t,r,n){let o=new Map;for(let s of r){let a=Ln(s.shape[t]);if(!a.length)throw new Error(`A discriminator value for key \`${t}\` could not be extracted from all schema options`);for(let c of a){if(o.has(c))throw new Error(`Discriminator property ${String(t)} has duplicate value ${String(c)}`);o.set(c,s)}}return new $h({typeName:j.ZodDiscriminatedUnion,discriminator:t,options:r,optionsMap:o,...re(n)})}};i($h,"ZodDiscriminatedUnion");var wh=$h;function mb(e,t){let r=Xr(e),n=Xr(t);if(e===t)return{valid:!0,data:e};if(r===U.object&&n===U.object){let o=le.objectKeys(t),s=le.objectKeys(e).filter(c=>o.indexOf(c)!==-1),a={...e,...t};for(let c of s){let l=mb(e[c],t[c]);if(!l.valid)return{valid:!1};a[c]=l.data}return{valid:!0,data:a}}else if(r===U.array&&n===U.array){if(e.length!==t.length)return{valid:!1};let o=[];for(let s=0;s<e.length;s++){let a=e[s],c=t[s],l=mb(a,c);if(!l.valid)return{valid:!1};o.push(l.data)}return{valid:!0,data:o}}else return r===U.date&&n===U.date&&+e==+t?{valid:!0,data:e}:{valid:!1}}i(mb,"mergeValues");var Nb=class Nb extends oe{_parse(t){let{status:r,ctx:n}=this._processInputParams(t),o=i((s,a)=>{if(_h(s)||_h(a))return Y;let c=mb(s.value,a.value);return c.valid?((vh(s)||vh(a))&&r.dirty(),{status:r.value,value:c.data}):(L(n,{code:P.invalid_intersection_types}),Y)},"handleParsed");return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([s,a])=>o(s,a)):o(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}};i(Nb,"ZodIntersection");var qs=Nb;qs.create=(e,t,r)=>new qs({left:e,right:t,typeName:j.ZodIntersection,...re(r)});var Eh=class Eh extends oe{_parse(t){let{status:r,ctx:n}=this._processInputParams(t);if(n.parsedType!==U.array)return L(n,{code:P.invalid_type,expected:U.array,received:n.parsedType}),Y;if(n.data.length<this._def.items.length)return L(n,{code:P.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),Y;!this._def.rest&&n.data.length>this._def.items.length&&(L(n,{code:P.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),r.dirty());let s=[...n.data].map((a,c)=>{let l=this._def.items[c]||this._def.rest;return l?l._parse(new lr(n,a,n.path,c)):null}).filter(a=>!!a);return n.common.async?Promise.all(s).then(a=>nt.mergeArray(r,a)):nt.mergeArray(r,s)}get items(){return this._def.items}rest(t){return new Eh({...this._def,rest:t})}};i(Eh,"ZodTuple");var Qr=Eh;Qr.create=(e,t)=>{if(!Array.isArray(e))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Qr({items:e,typeName:j.ZodTuple,rest:null,...re(t)})};var Ou=class Ou extends oe{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){let{status:r,ctx:n}=this._processInputParams(t);if(n.parsedType!==U.object)return L(n,{code:P.invalid_type,expected:U.object,received:n.parsedType}),Y;let o=[],s=this._def.keyType,a=this._def.valueType;for(let c in n.data)o.push({key:s._parse(new lr(n,c,n.path,c)),value:a._parse(new lr(n,n.data[c],n.path,c)),alwaysSet:c in n.data});return n.common.async?nt.mergeObjectAsync(r,o):nt.mergeObjectSync(r,o)}get element(){return this._def.valueType}static create(t,r,n){return r instanceof oe?new Ou({keyType:t,valueType:r,typeName:j.ZodRecord,...re(n)}):new Ou({keyType:xo.create(),valueType:t,typeName:j.ZodRecord,...re(r)})}};i(Ou,"ZodRecord");var bh=Ou,Tb=class Tb extends oe{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){let{status:r,ctx:n}=this._processInputParams(t);if(n.parsedType!==U.map)return L(n,{code:P.invalid_type,expected:U.map,received:n.parsedType}),Y;let o=this._def.keyType,s=this._def.valueType,a=[...n.data.entries()].map(([c,l],u)=>({key:o._parse(new lr(n,c,n.path,[u,"key"])),value:s._parse(new lr(n,l,n.path,[u,"value"]))}));if(n.common.async){let c=new Map;return Promise.resolve().then(async()=>{for(let l of a){let u=await l.key,d=await l.value;if(u.status==="aborted"||d.status==="aborted")return Y;(u.status==="dirty"||d.status==="dirty")&&r.dirty(),c.set(u.value,d.value)}return{status:r.value,value:c}})}else{let c=new Map;for(let l of a){let u=l.key,d=l.value;if(u.status==="aborted"||d.status==="aborted")return Y;(u.status==="dirty"||d.status==="dirty")&&r.dirty(),c.set(u.value,d.value)}return{status:r.value,value:c}}}};i(Tb,"ZodMap");var qa=Tb;qa.create=(e,t,r)=>new qa({valueType:t,keyType:e,typeName:j.ZodMap,...re(r)});var Au=class Au extends oe{_parse(t){let{status:r,ctx:n}=this._processInputParams(t);if(n.parsedType!==U.set)return L(n,{code:P.invalid_type,expected:U.set,received:n.parsedType}),Y;let o=this._def;o.minSize!==null&&n.data.size<o.minSize.value&&(L(n,{code:P.too_small,minimum:o.minSize.value,type:"set",inclusive:!0,exact:!1,message:o.minSize.message}),r.dirty()),o.maxSize!==null&&n.data.size>o.maxSize.value&&(L(n,{code:P.too_big,maximum:o.maxSize.value,type:"set",inclusive:!0,exact:!1,message:o.maxSize.message}),r.dirty());let s=this._def.valueType;function a(l){let u=new Set;for(let d of l){if(d.status==="aborted")return Y;d.status==="dirty"&&r.dirty(),u.add(d.value)}return{status:r.value,value:u}}i(a,"finalizeSet");let c=[...n.data.values()].map((l,u)=>s._parse(new lr(n,l,n.path,u)));return n.common.async?Promise.all(c).then(l=>a(l)):a(c)}min(t,r){return new Au({...this._def,minSize:{value:t,message:B.toString(r)}})}max(t,r){return new Au({...this._def,maxSize:{value:t,message:B.toString(r)}})}size(t,r){return this.min(t,r).max(t,r)}nonempty(t){return this.min(1,t)}};i(Au,"ZodSet");var Ba=Au;Ba.create=(e,t)=>new Ba({valueType:e,minSize:null,maxSize:null,typeName:j.ZodSet,...re(t)});var La=class La extends oe{constructor(){super(...arguments),this.validate=this.implement}_parse(t){let{ctx:r}=this._processInputParams(t);if(r.parsedType!==U.function)return L(r,{code:P.invalid_type,expected:U.function,received:r.parsedType}),Y;function n(c,l){return Cu({data:c,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,ja(),Zn].filter(u=>!!u),issueData:{code:P.invalid_arguments,argumentsError:l}})}i(n,"makeArgsIssue");function o(c,l){return Cu({data:c,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,ja(),Zn].filter(u=>!!u),issueData:{code:P.invalid_return_type,returnTypeError:l}})}i(o,"makeReturnsIssue");let s={errorMap:r.common.contextualErrorMap},a=r.data;if(this._def.returns instanceof vo){let c=this;return ut(async function(...l){let u=new zt([]),d=await c._def.args.parseAsync(l,s).catch(h=>{throw u.addIssue(n(l,h)),u}),p=await Reflect.apply(a,this,d);return await c._def.returns._def.type.parseAsync(p,s).catch(h=>{throw u.addIssue(o(p,h)),u})})}else{let c=this;return ut(function(...l){let u=c._def.args.safeParse(l,s);if(!u.success)throw new zt([n(l,u.error)]);let d=Reflect.apply(a,this,u.data),p=c._def.returns.safeParse(d,s);if(!p.success)throw new zt([o(d,p.error)]);return p.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...t){return new La({...this._def,args:Qr.create(t).rest(Fn.create())})}returns(t){return new La({...this._def,returns:t})}implement(t){return this.parse(t)}strictImplement(t){return this.parse(t)}static create(t,r,n){return new La({args:t||Qr.create([]).rest(Fn.create()),returns:r||Fn.create(),typeName:j.ZodFunction,...re(n)})}};i(La,"ZodFunction");var Sh=La,zb=class zb extends oe{get schema(){return this._def.getter()}_parse(t){let{ctx:r}=this._processInputParams(t);return this._def.getter()._parse({data:r.data,path:r.path,parent:r})}};i(zb,"ZodLazy");var Bs=zb;Bs.create=(e,t)=>new Bs({getter:e,typeName:j.ZodLazy,...re(t)});var Cb=class Cb extends oe{_parse(t){if(t.data!==this._def.value){let r=this._getOrReturnCtx(t);return L(r,{received:r.data,code:P.invalid_literal,expected:this._def.value}),Y}return{status:"valid",value:t.data}}get value(){return this._def.value}};i(Cb,"ZodLiteral");var Hs=Cb;Hs.create=(e,t)=>new Hs({value:e,typeName:j.ZodLiteral,...re(t)});function I2(e,t){return new Vs({values:e,typeName:j.ZodEnum,...re(t)})}i(I2,"createZodEnum");var Ru=class Ru extends oe{_parse(t){if(typeof t.data!="string"){let r=this._getOrReturnCtx(t),n=this._def.values;return L(r,{expected:le.joinValues(n),received:r.parsedType,code:P.invalid_type}),Y}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(t.data)){let r=this._getOrReturnCtx(t),n=this._def.values;return L(r,{received:r.data,code:P.invalid_enum_value,options:n}),Y}return ut(t.data)}get options(){return this._def.values}get enum(){let t={};for(let r of this._def.values)t[r]=r;return t}get Values(){let t={};for(let r of this._def.values)t[r]=r;return t}get Enum(){let t={};for(let r of this._def.values)t[r]=r;return t}extract(t,r=this._def){return Ru.create(t,{...this._def,...r})}exclude(t,r=this._def){return Ru.create(this.options.filter(n=>!t.includes(n)),{...this._def,...r})}};i(Ru,"ZodEnum");var Vs=Ru;Vs.create=I2;var Ib=class Ib extends oe{_parse(t){let r=le.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(t);if(n.parsedType!==U.string&&n.parsedType!==U.number){let o=le.objectValues(r);return L(n,{expected:le.joinValues(o),received:n.parsedType,code:P.invalid_type}),Y}if(this._cache||(this._cache=new Set(le.getValidEnumValues(this._def.values))),!this._cache.has(t.data)){let o=le.objectValues(r);return L(n,{received:n.data,code:P.invalid_enum_value,options:o}),Y}return ut(t.data)}get enum(){return this._def.values}};i(Ib,"ZodNativeEnum");var Gs=Ib;Gs.create=(e,t)=>new Gs({values:e,typeName:j.ZodNativeEnum,...re(t)});var Pb=class Pb extends oe{unwrap(){return this._def.type}_parse(t){let{ctx:r}=this._processInputParams(t);if(r.parsedType!==U.promise&&r.common.async===!1)return L(r,{code:P.invalid_type,expected:U.promise,received:r.parsedType}),Y;let n=r.parsedType===U.promise?r.data:Promise.resolve(r.data);return ut(n.then(o=>this._def.type.parseAsync(o,{path:r.path,errorMap:r.common.contextualErrorMap})))}};i(Pb,"ZodPromise");var vo=Pb;vo.create=(e,t)=>new vo({type:e,typeName:j.ZodPromise,...re(t)});var Ob=class Ob extends oe{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===j.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(t){let{status:r,ctx:n}=this._processInputParams(t),o=this._def.effect||null,s={addIssue:a=>{L(n,a),a.fatal?r.abort():r.dirty()},get path(){return n.path}};if(s.addIssue=s.addIssue.bind(s),o.type==="preprocess"){let a=o.transform(n.data,s);if(n.common.async)return Promise.resolve(a).then(async c=>{if(r.value==="aborted")return Y;let l=await this._def.schema._parseAsync({data:c,path:n.path,parent:n});return l.status==="aborted"?Y:l.status==="dirty"?As(l.value):r.value==="dirty"?As(l.value):l});{if(r.value==="aborted")return Y;let c=this._def.schema._parseSync({data:a,path:n.path,parent:n});return c.status==="aborted"?Y:c.status==="dirty"?As(c.value):r.value==="dirty"?As(c.value):c}}if(o.type==="refinement"){let a=i(c=>{let l=o.refinement(c,s);if(n.common.async)return Promise.resolve(l);if(l instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return c},"executeRefinement");if(n.common.async===!1){let c=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return c.status==="aborted"?Y:(c.status==="dirty"&&r.dirty(),a(c.value),{status:r.value,value:c.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(c=>c.status==="aborted"?Y:(c.status==="dirty"&&r.dirty(),a(c.value).then(()=>({status:r.value,value:c.value}))))}if(o.type==="transform")if(n.common.async===!1){let a=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!yo(a))return Y;let c=o.transform(a.value,s);if(c instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:r.value,value:c}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(a=>yo(a)?Promise.resolve(o.transform(a.value,s)).then(c=>({status:r.value,value:c})):Y);le.assertNever(o)}};i(Ob,"ZodEffects");var ur=Ob;ur.create=(e,t,r)=>new ur({schema:e,typeName:j.ZodEffects,effect:t,...re(r)});ur.createWithPreprocess=(e,t,r)=>new ur({schema:t,effect:{type:"preprocess",transform:e},typeName:j.ZodEffects,...re(r)});var Ab=class Ab extends oe{_parse(t){return this._getType(t)===U.undefined?ut(void 0):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}};i(Ab,"ZodOptional");var Ct=Ab;Ct.create=(e,t)=>new Ct({innerType:e,typeName:j.ZodOptional,...re(t)});var Rb=class Rb extends oe{_parse(t){return this._getType(t)===U.null?ut(null):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}};i(Rb,"ZodNullable");var en=Rb;en.create=(e,t)=>new en({innerType:e,typeName:j.ZodNullable,...re(t)});var jb=class jb extends oe{_parse(t){let{ctx:r}=this._processInputParams(t),n=r.data;return r.parsedType===U.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:r.path,parent:r})}removeDefault(){return this._def.innerType}};i(jb,"ZodDefault");var Ws=jb;Ws.create=(e,t)=>new Ws({innerType:e,typeName:j.ZodDefault,defaultValue:typeof t.default=="function"?t.default:()=>t.default,...re(t)});var Db=class Db extends oe{_parse(t){let{ctx:r}=this._processInputParams(t),n={...r,common:{...r.common,issues:[]}},o=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return Da(o)?o.then(s=>({status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new zt(n.common.issues)},input:n.data})})):{status:"valid",value:o.status==="valid"?o.value:this._def.catchValue({get error(){return new zt(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}};i(Db,"ZodCatch");var Js=Db;Js.create=(e,t)=>new Js({innerType:e,typeName:j.ZodCatch,catchValue:typeof t.catch=="function"?t.catch:()=>t.catch,...re(t)});var Mb=class Mb extends oe{_parse(t){if(this._getType(t)!==U.nan){let n=this._getOrReturnCtx(t);return L(n,{code:P.invalid_type,expected:U.nan,received:n.parsedType}),Y}return{status:"valid",value:t.data}}};i(Mb,"ZodNaN");var Ha=Mb;Ha.create=e=>new Ha({typeName:j.ZodNaN,...re(e)});var N7=Symbol("zod_brand"),Zb=class Zb extends oe{_parse(t){let{ctx:r}=this._processInputParams(t),n=r.data;return this._def.type._parse({data:n,path:r.path,parent:r})}unwrap(){return this._def.type}};i(Zb,"ZodBranded");var ju=Zb,Nh=class Nh extends oe{_parse(t){let{status:r,ctx:n}=this._processInputParams(t);if(n.common.async)return i(async()=>{let s=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?Y:s.status==="dirty"?(r.dirty(),As(s.value)):this._def.out._parseAsync({data:s.value,path:n.path,parent:n})},"handleAsync")();{let o=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return o.status==="aborted"?Y:o.status==="dirty"?(r.dirty(),{status:"dirty",value:o.value}):this._def.out._parseSync({data:o.value,path:n.path,parent:n})}}static create(t,r){return new Nh({in:t,out:r,typeName:j.ZodPipeline})}};i(Nh,"ZodPipeline");var Du=Nh,Lb=class Lb extends oe{_parse(t){let r=this._def.innerType._parse(t),n=i(o=>(yo(o)&&(o.value=Object.freeze(o.value)),o),"freeze");return Da(r)?r.then(o=>n(o)):n(r)}unwrap(){return this._def.innerType}};i(Lb,"ZodReadonly");var Ks=Lb;Ks.create=(e,t)=>new Ks({innerType:e,typeName:j.ZodReadonly,...re(t)});function N2(e,t){let r=typeof e=="function"?e(t):typeof e=="string"?{message:e}:e;return typeof r=="string"?{message:r}:r}i(N2,"cleanParams");function P2(e,t={},r){return e?_o.create().superRefine((n,o)=>{let s=e(n);if(s instanceof Promise)return s.then(a=>{if(!a){let c=N2(t,n),l=c.fatal??r??!0;o.addIssue({code:"custom",...c,fatal:l})}});if(!s){let a=N2(t,n),c=a.fatal??r??!0;o.addIssue({code:"custom",...a,fatal:c})}}):_o.create()}i(P2,"custom");var T7={object:It.lazycreate},j;(function(e){e.ZodString="ZodString",e.ZodNumber="ZodNumber",e.ZodNaN="ZodNaN",e.ZodBigInt="ZodBigInt",e.ZodBoolean="ZodBoolean",e.ZodDate="ZodDate",e.ZodSymbol="ZodSymbol",e.ZodUndefined="ZodUndefined",e.ZodNull="ZodNull",e.ZodAny="ZodAny",e.ZodUnknown="ZodUnknown",e.ZodNever="ZodNever",e.ZodVoid="ZodVoid",e.ZodArray="ZodArray",e.ZodObject="ZodObject",e.ZodUnion="ZodUnion",e.ZodDiscriminatedUnion="ZodDiscriminatedUnion",e.ZodIntersection="ZodIntersection",e.ZodTuple="ZodTuple",e.ZodRecord="ZodRecord",e.ZodMap="ZodMap",e.ZodSet="ZodSet",e.ZodFunction="ZodFunction",e.ZodLazy="ZodLazy",e.ZodLiteral="ZodLiteral",e.ZodEnum="ZodEnum",e.ZodEffects="ZodEffects",e.ZodNativeEnum="ZodNativeEnum",e.ZodOptional="ZodOptional",e.ZodNullable="ZodNullable",e.ZodDefault="ZodDefault",e.ZodCatch="ZodCatch",e.ZodPromise="ZodPromise",e.ZodBranded="ZodBranded",e.ZodPipeline="ZodPipeline",e.ZodReadonly="ZodReadonly"})(j||(j={}));var z7=i((e,t={message:`Input not instance of ${e.name}`})=>P2(r=>r instanceof e,t),"instanceOfType"),O2=xo.create,A2=js.create,C7=Ha.create,I7=Ds.create,R2=Ms.create,P7=Zs.create,O7=Fa.create,A7=Ls.create,R7=Fs.create,j7=_o.create,D7=Fn.create,M7=Tr.create,Z7=Ua.create,L7=Un.create,hb=It.create,F7=It.strictCreate,U7=Us.create,q7=wh.create,B7=qs.create,H7=Qr.create,V7=bh.create,G7=qa.create,W7=Ba.create,J7=Sh.create,K7=Bs.create,Y7=Hs.create,X7=Vs.create,Q7=Gs.create,eY=vo.create,tY=ur.create,rY=Ct.create,nY=en.create,oY=ur.createWithPreprocess,sY=Du.create,iY=i(()=>O2().optional(),"ostring"),aY=i(()=>A2().optional(),"onumber"),cY=i(()=>R2().optional(),"oboolean"),lY={string:e=>xo.create({...e,coerce:!0}),number:e=>js.create({...e,coerce:!0}),boolean:e=>Ms.create({...e,coerce:!0}),bigint:e=>Ds.create({...e,coerce:!0}),date:e=>Zs.create({...e,coerce:!0})};var uY=Y;var dY=Object.freeze({status:"aborted"});function T(e,t,r){function n(l,u){var d;Object.defineProperty(l,"_zod",{value:l._zod??{},enumerable:!1}),(d=l._zod).traits??(d.traits=new Set),l._zod.traits.add(e),t(l,u);for(let p in a.prototype)p in l||Object.defineProperty(l,p,{value:a.prototype[p].bind(l)});l._zod.constr=a,l._zod.def=u}i(n,"init");let o=r?.Parent??Object,c=class c extends o{};i(c,"Definition");let s=c;Object.defineProperty(s,"name",{value:e});function a(l){var u;let d=r?.Parent?new s:this;n(d,l),(u=d._zod).deferred??(u.deferred=[]);for(let p of d._zod.deferred)p();return d}return i(a,"_"),Object.defineProperty(a,"init",{value:n}),Object.defineProperty(a,Symbol.hasInstance,{value:l=>r?.Parent&&l instanceof r.Parent?!0:l?._zod?.traits?.has(e)}),Object.defineProperty(a,"name",{value:e}),a}i(T,"$constructor");var pY=Symbol("zod_brand"),Ub=class Ub extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}};i(Ub,"$ZodAsyncError");var qn=Ub,Th={};function Vt(e){return e&&Object.assign(Th,e),Th}i(Vt,"config");var ue={};C(ue,{BIGINT_FORMAT_RANGES:()=>D2,Class:()=>qb,NUMBER_FORMAT_RANGES:()=>Kb,aborted:()=>Xs,allowsEval:()=>Gb,assert:()=>yY,assertEqual:()=>fY,assertIs:()=>hY,assertNever:()=>gY,assertNotEqual:()=>mY,assignProp:()=>Vb,cached:()=>Lu,captureStackTrace:()=>Ch,cleanEnum:()=>CY,cleanRegex:()=>Uu,clone:()=>Gt,createTransparentProxy:()=>SY,defineLazy:()=>ze,esc:()=>Ys,escapeRegex:()=>wo,extend:()=>EY,finalizeIssue:()=>zr,floatSafeRemainder:()=>Hb,getElementAtPath:()=>xY,getEnumValues:()=>Zu,getLengthableOrigin:()=>qu,getParsedType:()=>bY,getSizableOrigin:()=>M2,isObject:()=>Va,isPlainObject:()=>Ga,issue:()=>Yb,joinValues:()=>zh,jsonStringifyReplacer:()=>Bb,merge:()=>NY,normalizeParams:()=>X,nullish:()=>Fu,numKeys:()=>wY,omit:()=>$Y,optionalKeys:()=>Jb,partial:()=>TY,pick:()=>kY,prefixIssues:()=>tn,primitiveTypes:()=>j2,promiseAllObject:()=>_Y,propertyKeyTypes:()=>Wb,randomString:()=>vY,required:()=>zY,stringifyPrimitive:()=>Ih,unwrapMessage:()=>Mu});function fY(e){return e}i(fY,"assertEqual");function mY(e){return e}i(mY,"assertNotEqual");function hY(e){}i(hY,"assertIs");function gY(e){throw new Error}i(gY,"assertNever");function yY(e){}i(yY,"assert");function Zu(e){let t=Object.values(e).filter(n=>typeof n=="number");return Object.entries(e).filter(([n,o])=>t.indexOf(+n)===-1).map(([n,o])=>o)}i(Zu,"getEnumValues");function zh(e,t="|"){return e.map(r=>Ih(r)).join(t)}i(zh,"joinValues");function Bb(e,t){return typeof t=="bigint"?t.toString():t}i(Bb,"jsonStringifyReplacer");function Lu(e){return{get value(){{let r=e();return Object.defineProperty(this,"value",{value:r}),r}throw new Error("cached value already set")}}}i(Lu,"cached");function Fu(e){return e==null}i(Fu,"nullish");function Uu(e){let t=e.startsWith("^")?1:0,r=e.endsWith("$")?e.length-1:e.length;return e.slice(t,r)}i(Uu,"cleanRegex");function Hb(e,t){let r=(e.toString().split(".")[1]||"").length,n=(t.toString().split(".")[1]||"").length,o=r>n?r:n,s=Number.parseInt(e.toFixed(o).replace(".","")),a=Number.parseInt(t.toFixed(o).replace(".",""));return s%a/10**o}i(Hb,"floatSafeRemainder");function ze(e,t,r){Object.defineProperty(e,t,{get(){{let o=r();return e[t]=o,o}throw new Error("cached value already set")},set(o){Object.defineProperty(e,t,{value:o})},configurable:!0})}i(ze,"defineLazy");function Vb(e,t,r){Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}i(Vb,"assignProp");function xY(e,t){return t?t.reduce((r,n)=>r?.[n],e):e}i(xY,"getElementAtPath");function _Y(e){let t=Object.keys(e),r=t.map(n=>e[n]);return Promise.all(r).then(n=>{let o={};for(let s=0;s<t.length;s++)o[t[s]]=n[s];return o})}i(_Y,"promiseAllObject");function vY(e=10){let t="abcdefghijklmnopqrstuvwxyz",r="";for(let n=0;n<e;n++)r+=t[Math.floor(Math.random()*t.length)];return r}i(vY,"randomString");function Ys(e){return JSON.stringify(e)}i(Ys,"esc");var Ch=Error.captureStackTrace?Error.captureStackTrace:(...e)=>{};function Va(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}i(Va,"isObject");var Gb=Lu(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{let e=Function;return new e(""),!0}catch{return!1}});function Ga(e){if(Va(e)===!1)return!1;let t=e.constructor;if(t===void 0)return!0;let r=t.prototype;return!(Va(r)===!1||Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)}i(Ga,"isPlainObject");function wY(e){let t=0;for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&t++;return t}i(wY,"numKeys");var bY=i(e=>{let t=typeof e;switch(t){case"undefined":return"undefined";case"string":return"string";case"number":return Number.isNaN(e)?"nan":"number";case"boolean":return"boolean";case"function":return"function";case"bigint":return"bigint";case"symbol":return"symbol";case"object":return Array.isArray(e)?"array":e===null?"null":e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?"promise":typeof Map<"u"&&e instanceof Map?"map":typeof Set<"u"&&e instanceof Set?"set":typeof Date<"u"&&e instanceof Date?"date":typeof File<"u"&&e instanceof File?"file":"object";default:throw new Error(`Unknown data type: ${t}`)}},"getParsedType"),Wb=new Set(["string","number","symbol"]),j2=new Set(["string","number","bigint","boolean","symbol","undefined"]);function wo(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}i(wo,"escapeRegex");function Gt(e,t,r){let n=new e._zod.constr(t??e._zod.def);return(!t||r?.parent)&&(n._zod.parent=e),n}i(Gt,"clone");function X(e){let t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}i(X,"normalizeParams");function SY(e){let t;return new Proxy({},{get(r,n,o){return t??(t=e()),Reflect.get(t,n,o)},set(r,n,o,s){return t??(t=e()),Reflect.set(t,n,o,s)},has(r,n){return t??(t=e()),Reflect.has(t,n)},deleteProperty(r,n){return t??(t=e()),Reflect.deleteProperty(t,n)},ownKeys(r){return t??(t=e()),Reflect.ownKeys(t)},getOwnPropertyDescriptor(r,n){return t??(t=e()),Reflect.getOwnPropertyDescriptor(t,n)},defineProperty(r,n,o){return t??(t=e()),Reflect.defineProperty(t,n,o)}})}i(SY,"createTransparentProxy");function Ih(e){return typeof e=="bigint"?e.toString()+"n":typeof e=="string"?`"${e}"`:`${e}`}i(Ih,"stringifyPrimitive");function Jb(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}i(Jb,"optionalKeys");var Kb={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},D2={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function kY(e,t){let r={},n=e._zod.def;for(let o in t){if(!(o in n.shape))throw new Error(`Unrecognized key: "${o}"`);t[o]&&(r[o]=n.shape[o])}return Gt(e,{...e._zod.def,shape:r,checks:[]})}i(kY,"pick");function $Y(e,t){let r={...e._zod.def.shape},n=e._zod.def;for(let o in t){if(!(o in n.shape))throw new Error(`Unrecognized key: "${o}"`);t[o]&&delete r[o]}return Gt(e,{...e._zod.def,shape:r,checks:[]})}i($Y,"omit");function EY(e,t){if(!Ga(t))throw new Error("Invalid input to extend: expected a plain object");let r={...e._zod.def,get shape(){let n={...e._zod.def.shape,...t};return Vb(this,"shape",n),n},checks:[]};return Gt(e,r)}i(EY,"extend");function NY(e,t){return Gt(e,{...e._zod.def,get shape(){let r={...e._zod.def.shape,...t._zod.def.shape};return Vb(this,"shape",r),r},catchall:t._zod.def.catchall,checks:[]})}i(NY,"merge");function TY(e,t,r){let n=t._zod.def.shape,o={...n};if(r)for(let s in r){if(!(s in n))throw new Error(`Unrecognized key: "${s}"`);r[s]&&(o[s]=e?new e({type:"optional",innerType:n[s]}):n[s])}else for(let s in n)o[s]=e?new e({type:"optional",innerType:n[s]}):n[s];return Gt(t,{...t._zod.def,shape:o,checks:[]})}i(TY,"partial");function zY(e,t,r){let n=t._zod.def.shape,o={...n};if(r)for(let s in r){if(!(s in o))throw new Error(`Unrecognized key: "${s}"`);r[s]&&(o[s]=new e({type:"nonoptional",innerType:n[s]}))}else for(let s in n)o[s]=new e({type:"nonoptional",innerType:n[s]});return Gt(t,{...t._zod.def,shape:o,checks:[]})}i(zY,"required");function Xs(e,t=0){for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue!==!0)return!0;return!1}i(Xs,"aborted");function tn(e,t){return t.map(r=>{var n;return(n=r).path??(n.path=[]),r.path.unshift(e),r})}i(tn,"prefixIssues");function Mu(e){return typeof e=="string"?e:e?.message}i(Mu,"unwrapMessage");function zr(e,t,r){let n={...e,path:e.path??[]};if(!e.message){let o=Mu(e.inst?._zod.def?.error?.(e))??Mu(t?.error?.(e))??Mu(r.customError?.(e))??Mu(r.localeError?.(e))??"Invalid input";n.message=o}return delete n.inst,delete n.continue,t?.reportInput||delete n.input,n}i(zr,"finalizeIssue");function M2(e){return e instanceof Set?"set":e instanceof Map?"map":e instanceof File?"file":"unknown"}i(M2,"getSizableOrigin");function qu(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}i(qu,"getLengthableOrigin");function Yb(...e){let[t,r,n]=e;return typeof t=="string"?{message:t,code:"custom",input:r,inst:n}:{...t}}i(Yb,"issue");function CY(e){return Object.entries(e).filter(([t,r])=>Number.isNaN(Number.parseInt(t,10))).map(t=>t[1])}i(CY,"cleanEnum");var Xb=class Xb{constructor(...t){}};i(Xb,"Class");var qb=Xb;var Z2=i((e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),Object.defineProperty(e,"message",{get(){return JSON.stringify(t,Bb,2)},enumerable:!0}),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},"initializer"),Ph=T("$ZodError",Z2),Bu=T("$ZodError",Z2,{Parent:Error});function Qb(e,t=r=>r.message){let r={},n=[];for(let o of e.issues)o.path.length>0?(r[o.path[0]]=r[o.path[0]]||[],r[o.path[0]].push(t(o))):n.push(t(o));return{formErrors:n,fieldErrors:r}}i(Qb,"flattenError");function e0(e,t){let r=t||function(s){return s.message},n={_errors:[]},o=i(s=>{for(let a of s.issues)if(a.code==="invalid_union"&&a.errors.length)a.errors.map(c=>o({issues:c}));else if(a.code==="invalid_key")o({issues:a.issues});else if(a.code==="invalid_element")o({issues:a.issues});else if(a.path.length===0)n._errors.push(r(a));else{let c=n,l=0;for(;l<a.path.length;){let u=a.path[l];l===a.path.length-1?(c[u]=c[u]||{_errors:[]},c[u]._errors.push(r(a))):c[u]=c[u]||{_errors:[]},c=c[u],l++}}},"processError");return o(e),n}i(e0,"formatError");var t0=i(e=>(t,r,n,o)=>{let s=n?Object.assign(n,{async:!1}):{async:!1},a=t._zod.run({value:r,issues:[]},s);if(a instanceof Promise)throw new qn;if(a.issues.length){let c=new(o?.Err??e)(a.issues.map(l=>zr(l,s,Vt())));throw Ch(c,o?.callee),c}return a.value},"_parse"),r0=t0(Bu),n0=i(e=>async(t,r,n,o)=>{let s=n?Object.assign(n,{async:!0}):{async:!0},a=t._zod.run({value:r,issues:[]},s);if(a instanceof Promise&&(a=await a),a.issues.length){let c=new(o?.Err??e)(a.issues.map(l=>zr(l,s,Vt())));throw Ch(c,o?.callee),c}return a.value},"_parseAsync"),o0=n0(Bu),s0=i(e=>(t,r,n)=>{let o=n?{...n,async:!1}:{async:!1},s=t._zod.run({value:r,issues:[]},o);if(s instanceof Promise)throw new qn;return s.issues.length?{success:!1,error:new(e??Ph)(s.issues.map(a=>zr(a,o,Vt())))}:{success:!0,data:s.value}},"_safeParse"),Qs=s0(Bu),i0=i(e=>async(t,r,n)=>{let o=n?Object.assign(n,{async:!0}):{async:!0},s=t._zod.run({value:r,issues:[]},o);return s instanceof Promise&&(s=await s),s.issues.length?{success:!1,error:new e(s.issues.map(a=>zr(a,o,Vt())))}:{success:!0,data:s.value}},"_safeParseAsync"),ei=i0(Bu);var L2=/^[cC][^\s-]{8,}$/,F2=/^[0-9a-z]+$/,U2=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,q2=/^[0-9a-vA-V]{20}$/,B2=/^[A-Za-z0-9]{27}$/,H2=/^[a-zA-Z0-9_-]{21}$/,V2=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;var G2=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,a0=i(e=>e?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000)$/,"uuid");var W2=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;var PY="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function J2(){return new RegExp(PY,"u")}i(J2,"emoji");var K2=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Y2=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})$/,X2=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,Q2=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,eZ=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,c0=/^[A-Za-z0-9_-]*$/,tZ=/^([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+$/;var rZ=/^\+(?:[0-9]){6,14}[0-9]$/,nZ="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",oZ=new RegExp(`^${nZ}$`);function sZ(e){let t="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof e.precision=="number"?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}i(sZ,"timeSource");function iZ(e){return new RegExp(`^${sZ(e)}$`)}i(iZ,"time");function aZ(e){let t=sZ({precision:e.precision}),r=["Z"];e.local&&r.push(""),e.offset&&r.push("([+-]\\d{2}:\\d{2})");let n=`${t}(?:${r.join("|")})`;return new RegExp(`^${nZ}T(?:${n})$`)}i(aZ,"datetime");var cZ=i(e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},"string");var lZ=/^\d+$/,uZ=/^-?\d+(?:\.\d+)?/i,dZ=/true|false/i,pZ=/null/i;var fZ=/^[^A-Z]*$/,mZ=/^[^a-z]*$/;var ot=T("$ZodCheck",(e,t)=>{var r;e._zod??(e._zod={}),e._zod.def=t,(r=e._zod).onattach??(r.onattach=[])}),hZ={number:"number",bigint:"bigint",object:"date"},l0=T("$ZodCheckLessThan",(e,t)=>{ot.init(e,t);let r=hZ[typeof t.value];e._zod.onattach.push(n=>{let o=n._zod.bag,s=(t.inclusive?o.maximum:o.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<s&&(t.inclusive?o.maximum=t.value:o.exclusiveMaximum=t.value)}),e._zod.check=n=>{(t.inclusive?n.value<=t.value:n.value<t.value)||n.issues.push({origin:r,code:"too_big",maximum:t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),u0=T("$ZodCheckGreaterThan",(e,t)=>{ot.init(e,t);let r=hZ[typeof t.value];e._zod.onattach.push(n=>{let o=n._zod.bag,s=(t.inclusive?o.minimum:o.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>s&&(t.inclusive?o.minimum=t.value:o.exclusiveMinimum=t.value)}),e._zod.check=n=>{(t.inclusive?n.value>=t.value:n.value>t.value)||n.issues.push({origin:r,code:"too_small",minimum:t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),gZ=T("$ZodCheckMultipleOf",(e,t)=>{ot.init(e,t),e._zod.onattach.push(r=>{var n;(n=r._zod.bag).multipleOf??(n.multipleOf=t.value)}),e._zod.check=r=>{if(typeof r.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof r.value=="bigint"?r.value%t.value===BigInt(0):Hb(r.value,t.value)===0)||r.issues.push({origin:typeof r.value,code:"not_multiple_of",divisor:t.value,input:r.value,inst:e,continue:!t.abort})}}),yZ=T("$ZodCheckNumberFormat",(e,t)=>{ot.init(e,t),t.format=t.format||"float64";let r=t.format?.includes("int"),n=r?"int":"number",[o,s]=Kb[t.format];e._zod.onattach.push(a=>{let c=a._zod.bag;c.format=t.format,c.minimum=o,c.maximum=s,r&&(c.pattern=lZ)}),e._zod.check=a=>{let c=a.value;if(r){if(!Number.isInteger(c)){a.issues.push({expected:n,format:t.format,code:"invalid_type",input:c,inst:e});return}if(!Number.isSafeInteger(c)){c>0?a.issues.push({input:c,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:n,continue:!t.abort}):a.issues.push({input:c,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:n,continue:!t.abort});return}}c<o&&a.issues.push({origin:"number",input:c,code:"too_small",minimum:o,inclusive:!0,inst:e,continue:!t.abort}),c>s&&a.issues.push({origin:"number",input:c,code:"too_big",maximum:s,inst:e})}});var xZ=T("$ZodCheckMaxLength",(e,t)=>{var r;ot.init(e,t),(r=e._zod.def).when??(r.when=n=>{let o=n.value;return!Fu(o)&&o.length!==void 0}),e._zod.onattach.push(n=>{let o=n._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<o&&(n._zod.bag.maximum=t.maximum)}),e._zod.check=n=>{let o=n.value;if(o.length<=t.maximum)return;let a=qu(o);n.issues.push({origin:a,code:"too_big",maximum:t.maximum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),_Z=T("$ZodCheckMinLength",(e,t)=>{var r;ot.init(e,t),(r=e._zod.def).when??(r.when=n=>{let o=n.value;return!Fu(o)&&o.length!==void 0}),e._zod.onattach.push(n=>{let o=n._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>o&&(n._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{let o=n.value;if(o.length>=t.minimum)return;let a=qu(o);n.issues.push({origin:a,code:"too_small",minimum:t.minimum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),vZ=T("$ZodCheckLengthEquals",(e,t)=>{var r;ot.init(e,t),(r=e._zod.def).when??(r.when=n=>{let o=n.value;return!Fu(o)&&o.length!==void 0}),e._zod.onattach.push(n=>{let o=n._zod.bag;o.minimum=t.length,o.maximum=t.length,o.length=t.length}),e._zod.check=n=>{let o=n.value,s=o.length;if(s===t.length)return;let a=qu(o),c=s>t.length;n.issues.push({origin:a,...c?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),Hu=T("$ZodCheckStringFormat",(e,t)=>{var r,n;ot.init(e,t),e._zod.onattach.push(o=>{let s=o._zod.bag;s.format=t.format,t.pattern&&(s.patterns??(s.patterns=new Set),s.patterns.add(t.pattern))}),t.pattern?(r=e._zod).check??(r.check=o=>{t.pattern.lastIndex=0,!t.pattern.test(o.value)&&o.issues.push({origin:"string",code:"invalid_format",format:t.format,input:o.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(n=e._zod).check??(n.check=()=>{})}),wZ=T("$ZodCheckRegex",(e,t)=>{Hu.init(e,t),e._zod.check=r=>{t.pattern.lastIndex=0,!t.pattern.test(r.value)&&r.issues.push({origin:"string",code:"invalid_format",format:"regex",input:r.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),bZ=T("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=fZ),Hu.init(e,t)}),SZ=T("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=mZ),Hu.init(e,t)}),kZ=T("$ZodCheckIncludes",(e,t)=>{ot.init(e,t);let r=wo(t.includes),n=new RegExp(typeof t.position=="number"?`^.{${t.position}}${r}`:r);t.pattern=n,e._zod.onattach.push(o=>{let s=o._zod.bag;s.patterns??(s.patterns=new Set),s.patterns.add(n)}),e._zod.check=o=>{o.value.includes(t.includes,t.position)||o.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:o.value,inst:e,continue:!t.abort})}}),$Z=T("$ZodCheckStartsWith",(e,t)=>{ot.init(e,t);let r=new RegExp(`^${wo(t.prefix)}.*`);t.pattern??(t.pattern=r),e._zod.onattach.push(n=>{let o=n._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(r)}),e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),EZ=T("$ZodCheckEndsWith",(e,t)=>{ot.init(e,t);let r=new RegExp(`.*${wo(t.suffix)}$`);t.pattern??(t.pattern=r),e._zod.onattach.push(n=>{let o=n._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(r)}),e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}});var NZ=T("$ZodCheckOverwrite",(e,t)=>{ot.init(e,t),e._zod.check=r=>{r.value=t.tx(r.value)}});var d0=class d0{constructor(t=[]){this.content=[],this.indent=0,this&&(this.args=t)}indented(t){this.indent+=1,t(this),this.indent-=1}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}let n=t.split(`
265
325
  `).filter(a=>a),o=Math.min(...n.map(a=>a.length-a.trimStart().length)),s=n.map(a=>a.slice(o)).map(a=>" ".repeat(this.indent*2)+a);for(let a of s)this.content.push(a)}compile(){let t=Function,r=this?.args,o=[...(this?.content??[""]).map(s=>` ${s}`)];return new t(...r,o.join(`
266
- `))}};i(Zv,"Doc");var Pf=Zv;var hj={major:4,minor:0,patch:0};var _e=N("$ZodType",(e,t)=>{var r;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=hj;let n=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&n.unshift(e);for(let o of n)for(let s of o._zod.onattach)s(e);if(n.length===0)(r=e._zod).deferred??(r.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let o=i((s,a,c)=>{let l=fs(s),u;for(let d of a){if(d._zod.def.when){if(!d._zod.def.when(s))continue}else if(l)continue;let p=s.issues.length,h=d._zod.check(s);if(h instanceof Promise&&c?.async===!1)throw new En;if(u||h instanceof Promise)u=(u??Promise.resolve()).then(async()=>{await h,s.issues.length!==p&&(l||(l=fs(s,p)))});else{if(s.issues.length===p)continue;l||(l=fs(s,p))}}return u?u.then(()=>s):s},"runChecks");e._zod.run=(s,a)=>{let c=e._zod.parse(s,a);if(c instanceof Promise){if(a.async===!1)throw new En;return c.then(l=>o(l,n,a))}return o(c,n,a)}}e["~standard"]={validate:o=>{try{let s=ms(e,o);return s.success?{value:s.data}:{issues:s.error?.issues}}catch{return hs(e,o).then(a=>a.success?{value:a.data}:{issues:a.error?.issues})}},vendor:"zod",version:1}}),_l=N("$ZodString",(e,t)=>{_e.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??WA(e._zod.bag),e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=String(r.value)}catch{}return typeof r.value=="string"||r.issues.push({expected:"string",code:"invalid_type",input:r.value,inst:e}),r}}),Ee=N("$ZodStringFormat",(e,t)=>{xl.init(e,t),_l.init(e,t)}),Fv=N("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=RA),Ee.init(e,t)}),Uv=N("$ZodUUID",(e,t)=>{if(t.version){let n={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(n===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=Av(n))}else t.pattern??(t.pattern=Av());Ee.init(e,t)}),qv=N("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=OA),Ee.init(e,t)}),Hv=N("$ZodURL",(e,t)=>{Ee.init(e,t),e._zod.check=r=>{try{let n=r.value,o=new URL(n),s=o.href;t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(o.hostname)||r.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:FA.source,input:r.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(o.protocol.endsWith(":")?o.protocol.slice(0,-1):o.protocol)||r.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:r.value,inst:e,continue:!t.abort})),!n.endsWith("/")&&s.endsWith("/")?r.value=s.slice(0,-1):r.value=s;return}catch{r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:e,continue:!t.abort})}}}),Bv=N("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=AA()),Ee.init(e,t)}),Vv=N("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=IA),Ee.init(e,t)}),Gv=N("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=EA),Ee.init(e,t)}),Wv=N("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=NA),Ee.init(e,t)}),Kv=N("$ZodULID",(e,t)=>{t.pattern??(t.pattern=TA),Ee.init(e,t)}),Jv=N("$ZodXID",(e,t)=>{t.pattern??(t.pattern=zA),Ee.init(e,t)}),Yv=N("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=CA),Ee.init(e,t)}),$j=N("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=GA(t)),Ee.init(e,t)}),Ej=N("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=HA),Ee.init(e,t)}),Nj=N("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=VA(t)),Ee.init(e,t)}),Tj=N("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=PA),Ee.init(e,t)}),Xv=N("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=jA),Ee.init(e,t),e._zod.onattach.push(r=>{let n=r._zod.bag;n.format="ipv4"})}),Qv=N("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=DA),Ee.init(e,t),e._zod.onattach.push(r=>{let n=r._zod.bag;n.format="ipv6"}),e._zod.check=r=>{try{new URL(`http://[${r.value}]`)}catch{r.issues.push({code:"invalid_format",format:"ipv6",input:r.value,inst:e,continue:!t.abort})}}}),ew=N("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=MA),Ee.init(e,t)}),tw=N("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=ZA),Ee.init(e,t),e._zod.check=r=>{let[n,o]=r.value.split("/");try{if(!o)throw new Error;let s=Number(o);if(`${s}`!==o)throw new Error;if(s<0||s>128)throw new Error;new URL(`http://[${n}]`)}catch{r.issues.push({code:"invalid_format",format:"cidrv6",input:r.value,inst:e,continue:!t.abort})}}});function zj(e){if(e==="")return!0;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}i(zj,"isValidBase64");var rw=N("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=LA),Ee.init(e,t),e._zod.onattach.push(r=>{r._zod.bag.contentEncoding="base64"}),e._zod.check=r=>{zj(r.value)||r.issues.push({code:"invalid_format",format:"base64",input:r.value,inst:e,continue:!t.abort})}});function C8(e){if(!jv.test(e))return!1;let t=e.replace(/[-_]/g,n=>n==="-"?"+":"/"),r=t.padEnd(Math.ceil(t.length/4)*4,"=");return zj(r)}i(C8,"isValidBase64URL");var nw=N("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=jv),Ee.init(e,t),e._zod.onattach.push(r=>{r._zod.bag.contentEncoding="base64url"}),e._zod.check=r=>{C8(r.value)||r.issues.push({code:"invalid_format",format:"base64url",input:r.value,inst:e,continue:!t.abort})}}),ow=N("$ZodE164",(e,t)=>{t.pattern??(t.pattern=UA),Ee.init(e,t)});function I8(e,t=null){try{let r=e.split(".");if(r.length!==3)return!1;let[n]=r;if(!n)return!1;let o=JSON.parse(atob(n));return!("typ"in o&&o?.typ!=="JWT"||!o.alg||t&&(!("alg"in o)||o.alg!==t))}catch{return!1}}i(I8,"isValidJWT");var sw=N("$ZodJWT",(e,t)=>{Ee.init(e,t),e._zod.check=r=>{I8(r.value,t.alg)||r.issues.push({code:"invalid_format",format:"jwt",input:r.value,inst:e,continue:!t.abort})}});var Of=N("$ZodNumber",(e,t)=>{_e.init(e,t),e._zod.pattern=e._zod.bag.pattern??JA,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=Number(r.value)}catch{}let o=r.value;if(typeof o=="number"&&!Number.isNaN(o)&&Number.isFinite(o))return r;let s=typeof o=="number"?Number.isNaN(o)?"NaN":Number.isFinite(o)?void 0:"Infinity":void 0;return r.issues.push({expected:"number",code:"invalid_type",input:o,inst:e,...s?{received:s}:{}}),r}}),iw=N("$ZodNumber",(e,t)=>{nj.init(e,t),Of.init(e,t)}),aw=N("$ZodBoolean",(e,t)=>{_e.init(e,t),e._zod.pattern=YA,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=!!r.value}catch{}let o=r.value;return typeof o=="boolean"||r.issues.push({expected:"boolean",code:"invalid_type",input:o,inst:e}),r}});var cw=N("$ZodNull",(e,t)=>{_e.init(e,t),e._zod.pattern=XA,e._zod.values=new Set([null]),e._zod.parse=(r,n)=>{let o=r.value;return o===null||r.issues.push({expected:"null",code:"invalid_type",input:o,inst:e}),r}});var lw=N("$ZodUnknown",(e,t)=>{_e.init(e,t),e._zod.parse=r=>r}),uw=N("$ZodNever",(e,t)=>{_e.init(e,t),e._zod.parse=(r,n)=>(r.issues.push({expected:"never",code:"invalid_type",input:r.value,inst:e}),r)});function gj(e,t,r){e.issues.length&&t.issues.push(...qr(r,e.issues)),t.value[r]=e.value}i(gj,"handleArrayResult");var dw=N("$ZodArray",(e,t)=>{_e.init(e,t),e._zod.parse=(r,n)=>{let o=r.value;if(!Array.isArray(o))return r.issues.push({expected:"array",code:"invalid_type",input:o,inst:e}),r;r.value=Array(o.length);let s=[];for(let a=0;a<o.length;a++){let c=o[a],l=t.element._zod.run({value:c,issues:[]},n);l instanceof Promise?s.push(l.then(u=>gj(u,r,a))):gj(l,r,a)}return s.length?Promise.all(s).then(()=>r):r}});function Rf(e,t,r){e.issues.length&&t.issues.push(...qr(r,e.issues)),t.value[r]=e.value}i(Rf,"handleObjectResult");function yj(e,t,r,n){e.issues.length?n[r]===void 0?r in n?t.value[r]=void 0:t.value[r]=e.value:t.issues.push(...qr(r,e.issues)):e.value===void 0?r in n&&(t.value[r]=void 0):t.value[r]=e.value}i(yj,"handleOptionalObjectResult");var Af=N("$ZodObject",(e,t)=>{_e.init(e,t);let r=fl(()=>{let p=Object.keys(t.shape);for(let m of p)if(!(t.shape[m]instanceof _e))throw new Error(`Invalid element at key "${m}": expected a Zod schema`);let h=Sv(t.shape);return{shape:t.shape,keys:p,keySet:new Set(p),numKeys:p.length,optionalKeys:new Set(h)}});$e(e._zod,"propValues",()=>{let p=t.shape,h={};for(let m in p){let g=p[m]._zod;if(g.values){h[m]??(h[m]=new Set);for(let _ of g.values)h[m].add(_)}}return h});let n=i(p=>{let h=new Pf(["shape","payload","ctx"]),m=r.value,g=i(w=>{let b=ps(w);return`shape[${b}]._zod.run({ value: input[${b}], issues: [] }, ctx)`},"parseStr");h.write("const input = payload.value;");let _=Object.create(null),x=0;for(let w of m.keys)_[w]=`key_${x++}`;h.write("const newResult = {}");for(let w of m.keys)if(m.optionalKeys.has(w)){let b=_[w];h.write(`const ${b} = ${g(w)};`);let S=ps(w);h.write(`
267
- if (${b}.issues.length) {
326
+ `))}};i(d0,"Doc");var Ah=d0;var zZ={major:4,minor:0,patch:0};var Se=T("$ZodType",(e,t)=>{var r;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=zZ;let n=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&n.unshift(e);for(let o of n)for(let s of o._zod.onattach)s(e);if(n.length===0)(r=e._zod).deferred??(r.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let o=i((s,a,c)=>{let l=Xs(s),u;for(let d of a){if(d._zod.def.when){if(!d._zod.def.when(s))continue}else if(l)continue;let p=s.issues.length,m=d._zod.check(s);if(m instanceof Promise&&c?.async===!1)throw new qn;if(u||m instanceof Promise)u=(u??Promise.resolve()).then(async()=>{await m,s.issues.length!==p&&(l||(l=Xs(s,p)))});else{if(s.issues.length===p)continue;l||(l=Xs(s,p))}}return u?u.then(()=>s):s},"runChecks");e._zod.run=(s,a)=>{let c=e._zod.parse(s,a);if(c instanceof Promise){if(a.async===!1)throw new qn;return c.then(l=>o(l,n,a))}return o(c,n,a)}}e["~standard"]={validate:o=>{try{let s=Qs(e,o);return s.success?{value:s.data}:{issues:s.error?.issues}}catch{return ei(e,o).then(a=>a.success?{value:a.data}:{issues:a.error?.issues})}},vendor:"zod",version:1}}),Vu=T("$ZodString",(e,t)=>{Se.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??cZ(e._zod.bag),e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=String(r.value)}catch{}return typeof r.value=="string"||r.issues.push({expected:"string",code:"invalid_type",input:r.value,inst:e}),r}}),Ce=T("$ZodStringFormat",(e,t)=>{Hu.init(e,t),Vu.init(e,t)}),f0=T("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=G2),Ce.init(e,t)}),m0=T("$ZodUUID",(e,t)=>{if(t.version){let n={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(n===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=a0(n))}else t.pattern??(t.pattern=a0());Ce.init(e,t)}),h0=T("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=W2),Ce.init(e,t)}),g0=T("$ZodURL",(e,t)=>{Ce.init(e,t),e._zod.check=r=>{try{let n=r.value,o=new URL(n),s=o.href;t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(o.hostname)||r.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:tZ.source,input:r.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(o.protocol.endsWith(":")?o.protocol.slice(0,-1):o.protocol)||r.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:r.value,inst:e,continue:!t.abort})),!n.endsWith("/")&&s.endsWith("/")?r.value=s.slice(0,-1):r.value=s;return}catch{r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:e,continue:!t.abort})}}}),y0=T("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=J2()),Ce.init(e,t)}),x0=T("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=H2),Ce.init(e,t)}),_0=T("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=L2),Ce.init(e,t)}),v0=T("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=F2),Ce.init(e,t)}),w0=T("$ZodULID",(e,t)=>{t.pattern??(t.pattern=U2),Ce.init(e,t)}),b0=T("$ZodXID",(e,t)=>{t.pattern??(t.pattern=q2),Ce.init(e,t)}),S0=T("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=B2),Ce.init(e,t)}),ZZ=T("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=aZ(t)),Ce.init(e,t)}),LZ=T("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=oZ),Ce.init(e,t)}),FZ=T("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=iZ(t)),Ce.init(e,t)}),UZ=T("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=V2),Ce.init(e,t)}),k0=T("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=K2),Ce.init(e,t),e._zod.onattach.push(r=>{let n=r._zod.bag;n.format="ipv4"})}),$0=T("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=Y2),Ce.init(e,t),e._zod.onattach.push(r=>{let n=r._zod.bag;n.format="ipv6"}),e._zod.check=r=>{try{new URL(`http://[${r.value}]`)}catch{r.issues.push({code:"invalid_format",format:"ipv6",input:r.value,inst:e,continue:!t.abort})}}}),E0=T("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=X2),Ce.init(e,t)}),N0=T("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=Q2),Ce.init(e,t),e._zod.check=r=>{let[n,o]=r.value.split("/");try{if(!o)throw new Error;let s=Number(o);if(`${s}`!==o)throw new Error;if(s<0||s>128)throw new Error;new URL(`http://[${n}]`)}catch{r.issues.push({code:"invalid_format",format:"cidrv6",input:r.value,inst:e,continue:!t.abort})}}});function qZ(e){if(e==="")return!0;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}i(qZ,"isValidBase64");var T0=T("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=eZ),Ce.init(e,t),e._zod.onattach.push(r=>{r._zod.bag.contentEncoding="base64"}),e._zod.check=r=>{qZ(r.value)||r.issues.push({code:"invalid_format",format:"base64",input:r.value,inst:e,continue:!t.abort})}});function OY(e){if(!c0.test(e))return!1;let t=e.replace(/[-_]/g,n=>n==="-"?"+":"/"),r=t.padEnd(Math.ceil(t.length/4)*4,"=");return qZ(r)}i(OY,"isValidBase64URL");var z0=T("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=c0),Ce.init(e,t),e._zod.onattach.push(r=>{r._zod.bag.contentEncoding="base64url"}),e._zod.check=r=>{OY(r.value)||r.issues.push({code:"invalid_format",format:"base64url",input:r.value,inst:e,continue:!t.abort})}}),C0=T("$ZodE164",(e,t)=>{t.pattern??(t.pattern=rZ),Ce.init(e,t)});function AY(e,t=null){try{let r=e.split(".");if(r.length!==3)return!1;let[n]=r;if(!n)return!1;let o=JSON.parse(atob(n));return!("typ"in o&&o?.typ!=="JWT"||!o.alg||t&&(!("alg"in o)||o.alg!==t))}catch{return!1}}i(AY,"isValidJWT");var I0=T("$ZodJWT",(e,t)=>{Ce.init(e,t),e._zod.check=r=>{AY(r.value,t.alg)||r.issues.push({code:"invalid_format",format:"jwt",input:r.value,inst:e,continue:!t.abort})}});var jh=T("$ZodNumber",(e,t)=>{Se.init(e,t),e._zod.pattern=e._zod.bag.pattern??uZ,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=Number(r.value)}catch{}let o=r.value;if(typeof o=="number"&&!Number.isNaN(o)&&Number.isFinite(o))return r;let s=typeof o=="number"?Number.isNaN(o)?"NaN":Number.isFinite(o)?void 0:"Infinity":void 0;return r.issues.push({expected:"number",code:"invalid_type",input:o,inst:e,...s?{received:s}:{}}),r}}),P0=T("$ZodNumber",(e,t)=>{yZ.init(e,t),jh.init(e,t)}),O0=T("$ZodBoolean",(e,t)=>{Se.init(e,t),e._zod.pattern=dZ,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=!!r.value}catch{}let o=r.value;return typeof o=="boolean"||r.issues.push({expected:"boolean",code:"invalid_type",input:o,inst:e}),r}});var A0=T("$ZodNull",(e,t)=>{Se.init(e,t),e._zod.pattern=pZ,e._zod.values=new Set([null]),e._zod.parse=(r,n)=>{let o=r.value;return o===null||r.issues.push({expected:"null",code:"invalid_type",input:o,inst:e}),r}});var R0=T("$ZodUnknown",(e,t)=>{Se.init(e,t),e._zod.parse=r=>r}),j0=T("$ZodNever",(e,t)=>{Se.init(e,t),e._zod.parse=(r,n)=>(r.issues.push({expected:"never",code:"invalid_type",input:r.value,inst:e}),r)});function CZ(e,t,r){e.issues.length&&t.issues.push(...tn(r,e.issues)),t.value[r]=e.value}i(CZ,"handleArrayResult");var D0=T("$ZodArray",(e,t)=>{Se.init(e,t),e._zod.parse=(r,n)=>{let o=r.value;if(!Array.isArray(o))return r.issues.push({expected:"array",code:"invalid_type",input:o,inst:e}),r;r.value=Array(o.length);let s=[];for(let a=0;a<o.length;a++){let c=o[a],l=t.element._zod.run({value:c,issues:[]},n);l instanceof Promise?s.push(l.then(u=>CZ(u,r,a))):CZ(l,r,a)}return s.length?Promise.all(s).then(()=>r):r}});function Rh(e,t,r){e.issues.length&&t.issues.push(...tn(r,e.issues)),t.value[r]=e.value}i(Rh,"handleObjectResult");function IZ(e,t,r,n){e.issues.length?n[r]===void 0?r in n?t.value[r]=void 0:t.value[r]=e.value:t.issues.push(...tn(r,e.issues)):e.value===void 0?r in n&&(t.value[r]=void 0):t.value[r]=e.value}i(IZ,"handleOptionalObjectResult");var Dh=T("$ZodObject",(e,t)=>{Se.init(e,t);let r=Lu(()=>{let p=Object.keys(t.shape);for(let h of p)if(!(t.shape[h]instanceof Se))throw new Error(`Invalid element at key "${h}": expected a Zod schema`);let m=Jb(t.shape);return{shape:t.shape,keys:p,keySet:new Set(p),numKeys:p.length,optionalKeys:new Set(m)}});ze(e._zod,"propValues",()=>{let p=t.shape,m={};for(let h in p){let g=p[h]._zod;if(g.values){m[h]??(m[h]=new Set);for(let _ of g.values)m[h].add(_)}}return m});let n=i(p=>{let m=new Ah(["shape","payload","ctx"]),h=r.value,g=i(b=>{let w=Ys(b);return`shape[${w}]._zod.run({ value: input[${w}], issues: [] }, ctx)`},"parseStr");m.write("const input = payload.value;");let _=Object.create(null),x=0;for(let b of h.keys)_[b]=`key_${x++}`;m.write("const newResult = {}");for(let b of h.keys)if(h.optionalKeys.has(b)){let w=_[b];m.write(`const ${w} = ${g(b)};`);let S=Ys(b);m.write(`
327
+ if (${w}.issues.length) {
268
328
  if (input[${S}] === undefined) {
269
329
  if (${S} in input) {
270
330
  newResult[${S}] = undefined;
271
331
  }
272
332
  } else {
273
333
  payload.issues = payload.issues.concat(
274
- ${b}.issues.map((iss) => ({
334
+ ${w}.issues.map((iss) => ({
275
335
  ...iss,
276
336
  path: iss.path ? [${S}, ...iss.path] : [${S}],
277
337
  }))
278
338
  );
279
339
  }
280
- } else if (${b}.value === undefined) {
340
+ } else if (${w}.value === undefined) {
281
341
  if (${S} in input) newResult[${S}] = undefined;
282
342
  } else {
283
- newResult[${S}] = ${b}.value;
343
+ newResult[${S}] = ${w}.value;
284
344
  }
285
- `)}else{let b=_[w];h.write(`const ${b} = ${g(w)};`),h.write(`
286
- if (${b}.issues.length) payload.issues = payload.issues.concat(${b}.issues.map(iss => ({
345
+ `)}else{let w=_[b];m.write(`const ${w} = ${g(b)};`),m.write(`
346
+ if (${w}.issues.length) payload.issues = payload.issues.concat(${w}.issues.map(iss => ({
287
347
  ...iss,
288
- path: iss.path ? [${ps(w)}, ...iss.path] : [${ps(w)}]
289
- })));`),h.write(`newResult[${ps(w)}] = ${b}.value`)}h.write("payload.value = newResult;"),h.write("return payload;");let v=h.compile();return(w,b)=>v(p,w,b)},"generateFastpass"),o,s=Qi,a=!Ef.jitless,l=a&&wv.value,u=t.catchall,d;e._zod.parse=(p,h)=>{d??(d=r.value);let m=p.value;if(!s(m))return p.issues.push({expected:"object",code:"invalid_type",input:m,inst:e}),p;let g=[];if(a&&l&&h?.async===!1&&h.jitless!==!0)o||(o=n(t.shape)),p=o(p,h);else{p.value={};let b=d.shape;for(let S of d.keys){let T=b[S],K=T._zod.run({value:m[S],issues:[]},h),A=T._zod.optin==="optional"&&T._zod.optout==="optional";K instanceof Promise?g.push(K.then(Y=>A?yj(Y,p,S,m):Rf(Y,p,S))):A?yj(K,p,S,m):Rf(K,p,S)}}if(!u)return g.length?Promise.all(g).then(()=>p):p;let _=[],x=d.keySet,v=u._zod,w=v.def.type;for(let b of Object.keys(m)){if(x.has(b))continue;if(w==="never"){_.push(b);continue}let S=v.run({value:m[b],issues:[]},h);S instanceof Promise?g.push(S.then(T=>Rf(T,p,b))):Rf(S,p,b)}return _.length&&p.issues.push({code:"unrecognized_keys",keys:_,input:m,inst:e}),g.length?Promise.all(g).then(()=>p):p}});function xj(e,t,r,n){for(let o of e)if(o.issues.length===0)return t.value=o.value,t;return t.issues.push({code:"invalid_union",input:t.value,inst:r,errors:e.map(o=>o.issues.map(s=>vr(s,n,Lt())))}),t}i(xj,"handleUnionResults");var jf=N("$ZodUnion",(e,t)=>{_e.init(e,t),$e(e._zod,"optin",()=>t.options.some(r=>r._zod.optin==="optional")?"optional":void 0),$e(e._zod,"optout",()=>t.options.some(r=>r._zod.optout==="optional")?"optional":void 0),$e(e._zod,"values",()=>{if(t.options.every(r=>r._zod.values))return new Set(t.options.flatMap(r=>Array.from(r._zod.values)))}),$e(e._zod,"pattern",()=>{if(t.options.every(r=>r._zod.pattern)){let r=t.options.map(n=>n._zod.pattern);return new RegExp(`^(${r.map(n=>hl(n.source)).join("|")})$`)}}),e._zod.parse=(r,n)=>{let o=!1,s=[];for(let a of t.options){let c=a._zod.run({value:r.value,issues:[]},n);if(c instanceof Promise)s.push(c),o=!0;else{if(c.issues.length===0)return c;s.push(c)}}return o?Promise.all(s).then(a=>xj(a,r,e,n)):xj(s,r,e,n)}}),pw=N("$ZodDiscriminatedUnion",(e,t)=>{jf.init(e,t);let r=e._zod.parse;$e(e._zod,"propValues",()=>{let o={};for(let s of t.options){let a=s._zod.propValues;if(!a||Object.keys(a).length===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(s)}"`);for(let[c,l]of Object.entries(a)){o[c]||(o[c]=new Set);for(let u of l)o[c].add(u)}}return o});let n=fl(()=>{let o=t.options,s=new Map;for(let a of o){let c=a._zod.propValues[t.discriminator];if(!c||c.size===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(a)}"`);for(let l of c){if(s.has(l))throw new Error(`Duplicate discriminator value "${String(l)}"`);s.set(l,a)}}return s});e._zod.parse=(o,s)=>{let a=o.value;if(!Qi(a))return o.issues.push({code:"invalid_type",expected:"object",input:a,inst:e}),o;let c=n.value.get(a?.[t.discriminator]);return c?c._zod.run(o,s):t.unionFallback?r(o,s):(o.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",input:a,path:[t.discriminator],inst:e}),o)}}),fw=N("$ZodIntersection",(e,t)=>{_e.init(e,t),e._zod.parse=(r,n)=>{let o=r.value,s=t.left._zod.run({value:o,issues:[]},n),a=t.right._zod.run({value:o,issues:[]},n);return s instanceof Promise||a instanceof Promise?Promise.all([s,a]).then(([l,u])=>_j(r,l,u)):_j(r,s,a)}});function Lv(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(ea(e)&&ea(t)){let r=Object.keys(t),n=Object.keys(e).filter(s=>r.indexOf(s)!==-1),o={...e,...t};for(let s of n){let a=Lv(e[s],t[s]);if(!a.valid)return{valid:!1,mergeErrorPath:[s,...a.mergeErrorPath]};o[s]=a.data}return{valid:!0,data:o}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let r=[];for(let n=0;n<e.length;n++){let o=e[n],s=t[n],a=Lv(o,s);if(!a.valid)return{valid:!1,mergeErrorPath:[n,...a.mergeErrorPath]};r.push(a.data)}return{valid:!0,data:r}}return{valid:!1,mergeErrorPath:[]}}i(Lv,"mergeValues");function _j(e,t,r){if(t.issues.length&&e.issues.push(...t.issues),r.issues.length&&e.issues.push(...r.issues),fs(e))return e;let n=Lv(t.value,r.value);if(!n.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(n.mergeErrorPath)}`);return e.value=n.data,e}i(_j,"handleIntersectionResults");var mw=N("$ZodRecord",(e,t)=>{_e.init(e,t),e._zod.parse=(r,n)=>{let o=r.value;if(!ea(o))return r.issues.push({expected:"record",code:"invalid_type",input:o,inst:e}),r;let s=[];if(t.keyType._zod.values){let a=t.keyType._zod.values;r.value={};for(let l of a)if(typeof l=="string"||typeof l=="number"||typeof l=="symbol"){let u=t.valueType._zod.run({value:o[l],issues:[]},n);u instanceof Promise?s.push(u.then(d=>{d.issues.length&&r.issues.push(...qr(l,d.issues)),r.value[l]=d.value})):(u.issues.length&&r.issues.push(...qr(l,u.issues)),r.value[l]=u.value)}let c;for(let l in o)a.has(l)||(c=c??[],c.push(l));c&&c.length>0&&r.issues.push({code:"unrecognized_keys",input:o,inst:e,keys:c})}else{r.value={};for(let a of Reflect.ownKeys(o)){if(a==="__proto__")continue;let c=t.keyType._zod.run({value:a,issues:[]},n);if(c instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(c.issues.length){r.issues.push({origin:"record",code:"invalid_key",issues:c.issues.map(u=>vr(u,n,Lt())),input:a,path:[a],inst:e}),r.value[c.value]=c.value;continue}let l=t.valueType._zod.run({value:o[a],issues:[]},n);l instanceof Promise?s.push(l.then(u=>{u.issues.length&&r.issues.push(...qr(a,u.issues)),r.value[c.value]=u.value})):(l.issues.length&&r.issues.push(...qr(a,l.issues)),r.value[c.value]=l.value)}}return s.length?Promise.all(s).then(()=>r):r}});var hw=N("$ZodEnum",(e,t)=>{_e.init(e,t);let r=pl(t.entries);e._zod.values=new Set(r),e._zod.pattern=new RegExp(`^(${r.filter(n=>bv.has(typeof n)).map(n=>typeof n=="string"?Kn(n):n.toString()).join("|")})$`),e._zod.parse=(n,o)=>{let s=n.value;return e._zod.values.has(s)||n.issues.push({code:"invalid_value",values:r,input:s,inst:e}),n}}),gw=N("$ZodLiteral",(e,t)=>{_e.init(e,t),e._zod.values=new Set(t.values),e._zod.pattern=new RegExp(`^(${t.values.map(r=>typeof r=="string"?Kn(r):r?r.toString():String(r)).join("|")})$`),e._zod.parse=(r,n)=>{let o=r.value;return e._zod.values.has(o)||r.issues.push({code:"invalid_value",values:t.values,input:o,inst:e}),r}});var yw=N("$ZodTransform",(e,t)=>{_e.init(e,t),e._zod.parse=(r,n)=>{let o=t.transform(r.value,r);if(n.async)return(o instanceof Promise?o:Promise.resolve(o)).then(a=>(r.value=a,r));if(o instanceof Promise)throw new En;return r.value=o,r}}),xw=N("$ZodOptional",(e,t)=>{_e.init(e,t),e._zod.optin="optional",e._zod.optout="optional",$e(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),$e(e._zod,"pattern",()=>{let r=t.innerType._zod.pattern;return r?new RegExp(`^(${hl(r.source)})?$`):void 0}),e._zod.parse=(r,n)=>t.innerType._zod.optin==="optional"?t.innerType._zod.run(r,n):r.value===void 0?r:t.innerType._zod.run(r,n)}),_w=N("$ZodNullable",(e,t)=>{_e.init(e,t),$e(e._zod,"optin",()=>t.innerType._zod.optin),$e(e._zod,"optout",()=>t.innerType._zod.optout),$e(e._zod,"pattern",()=>{let r=t.innerType._zod.pattern;return r?new RegExp(`^(${hl(r.source)}|null)$`):void 0}),$e(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(r,n)=>r.value===null?r:t.innerType._zod.run(r,n)}),vw=N("$ZodDefault",(e,t)=>{_e.init(e,t),e._zod.optin="optional",$e(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,n)=>{if(r.value===void 0)return r.value=t.defaultValue,r;let o=t.innerType._zod.run(r,n);return o instanceof Promise?o.then(s=>vj(s,t)):vj(o,t)}});function vj(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}i(vj,"handleDefaultResult");var ww=N("$ZodPrefault",(e,t)=>{_e.init(e,t),e._zod.optin="optional",$e(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,n)=>(r.value===void 0&&(r.value=t.defaultValue),t.innerType._zod.run(r,n))}),bw=N("$ZodNonOptional",(e,t)=>{_e.init(e,t),$e(e._zod,"values",()=>{let r=t.innerType._zod.values;return r?new Set([...r].filter(n=>n!==void 0)):void 0}),e._zod.parse=(r,n)=>{let o=t.innerType._zod.run(r,n);return o instanceof Promise?o.then(s=>wj(s,e)):wj(o,e)}});function wj(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}i(wj,"handleNonOptionalResult");var Sw=N("$ZodCatch",(e,t)=>{_e.init(e,t),e._zod.optin="optional",$e(e._zod,"optout",()=>t.innerType._zod.optout),$e(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,n)=>{let o=t.innerType._zod.run(r,n);return o instanceof Promise?o.then(s=>(r.value=s.value,s.issues.length&&(r.value=t.catchValue({...r,error:{issues:s.issues.map(a=>vr(a,n,Lt()))},input:r.value}),r.issues=[]),r)):(r.value=o.value,o.issues.length&&(r.value=t.catchValue({...r,error:{issues:o.issues.map(s=>vr(s,n,Lt()))},input:r.value}),r.issues=[]),r)}});var kw=N("$ZodPipe",(e,t)=>{_e.init(e,t),$e(e._zod,"values",()=>t.in._zod.values),$e(e._zod,"optin",()=>t.in._zod.optin),$e(e._zod,"optout",()=>t.out._zod.optout),e._zod.parse=(r,n)=>{let o=t.in._zod.run(r,n);return o instanceof Promise?o.then(s=>bj(s,t,n)):bj(o,t,n)}});function bj(e,t,r){return fs(e)?e:t.out._zod.run({value:e.value,issues:e.issues},r)}i(bj,"handlePipeResult");var $w=N("$ZodReadonly",(e,t)=>{_e.init(e,t),$e(e._zod,"propValues",()=>t.innerType._zod.propValues),$e(e._zod,"values",()=>t.innerType._zod.values),$e(e._zod,"optin",()=>t.innerType._zod.optin),$e(e._zod,"optout",()=>t.innerType._zod.optout),e._zod.parse=(r,n)=>{let o=t.innerType._zod.run(r,n);return o instanceof Promise?o.then(Sj):Sj(o)}});function Sj(e){return e.value=Object.freeze(e.value),e}i(Sj,"handleReadonlyResult");var Ew=N("$ZodCustom",(e,t)=>{tt.init(e,t),_e.init(e,t),e._zod.parse=(r,n)=>r,e._zod.check=r=>{let n=r.value,o=t.fn(n);if(o instanceof Promise)return o.then(s=>kj(s,r,n,e));kj(o,r,n,e)}});function kj(e,t,r,n){if(!e){let o={code:"custom",input:r,inst:n,path:[...n._zod.def.path??[]],continue:!n._zod.def.abort};n._zod.def.params&&(o.params=n._zod.def.params),t.issues.push($v(o))}}i(kj,"handleRefineResult");var P8=i(e=>{let t=typeof e;switch(t){case"number":return Number.isNaN(e)?"NaN":"number";case"object":{if(Array.isArray(e))return"array";if(e===null)return"null";if(Object.getPrototypeOf(e)!==Object.prototype&&e.constructor)return e.constructor.name}}return t},"parsedType"),R8=i(()=>{let e={string:{unit:"characters",verb:"to have"},file:{unit:"bytes",verb:"to have"},array:{unit:"items",verb:"to have"},set:{unit:"items",verb:"to have"}};function t(n){return e[n]??null}i(t,"getSizing");let r={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",jwt:"JWT",template_literal:"input"};return n=>{switch(n.code){case"invalid_type":return`Invalid input: expected ${n.expected}, received ${P8(n.input)}`;case"invalid_value":return n.values.length===1?`Invalid input: expected ${zf(n.values[0])}`:`Invalid option: expected one of ${Nf(n.values,"|")}`;case"too_big":{let o=n.inclusive?"<=":"<",s=t(n.origin);return s?`Too big: expected ${n.origin??"value"} to have ${o}${n.maximum.toString()} ${s.unit??"elements"}`:`Too big: expected ${n.origin??"value"} to be ${o}${n.maximum.toString()}`}case"too_small":{let o=n.inclusive?">=":">",s=t(n.origin);return s?`Too small: expected ${n.origin} to have ${o}${n.minimum.toString()} ${s.unit}`:`Too small: expected ${n.origin} to be ${o}${n.minimum.toString()}`}case"invalid_format":{let o=n;return o.format==="starts_with"?`Invalid string: must start with "${o.prefix}"`:o.format==="ends_with"?`Invalid string: must end with "${o.suffix}"`:o.format==="includes"?`Invalid string: must include "${o.includes}"`:o.format==="regex"?`Invalid string: must match pattern ${o.pattern}`:`Invalid ${r[o.format]??n.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${n.divisor}`;case"unrecognized_keys":return`Unrecognized key${n.keys.length>1?"s":""}: ${Nf(n.keys,", ")}`;case"invalid_key":return`Invalid key in ${n.origin}`;case"invalid_union":return"Invalid input";case"invalid_element":return`Invalid value in ${n.origin}`;default:return"Invalid input"}}},"error");function Nw(){return{localeError:R8()}}i(Nw,"default");var O8=Symbol("ZodOutput"),A8=Symbol("ZodInput"),Tw=class Tw{constructor(){this._map=new Map,this._idmap=new Map}add(t,...r){let n=r[0];if(this._map.set(t,n),n&&typeof n=="object"&&"id"in n){if(this._idmap.has(n.id))throw new Error(`ID ${n.id} already exists in the registry`);this._idmap.set(n.id,t)}return this}clear(){return this._map=new Map,this._idmap=new Map,this}remove(t){let r=this._map.get(t);return r&&typeof r=="object"&&"id"in r&&this._idmap.delete(r.id),this._map.delete(t),this}get(t){let r=t._zod.parent;if(r){let n={...this.get(r)??{}};return delete n.id,{...n,...this._map.get(t)}}return this._map.get(t)}has(t){return this._map.has(t)}};i(Tw,"$ZodRegistry");var vl=Tw;function Cj(){return new vl}i(Cj,"registry");var Jn=Cj();function zw(e,t){return new e({type:"string",...G(t)})}i(zw,"_string");function Cw(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...G(t)})}i(Cw,"_email");function Df(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...G(t)})}i(Df,"_guid");function Iw(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...G(t)})}i(Iw,"_uuid");function Pw(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...G(t)})}i(Pw,"_uuidv4");function Rw(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...G(t)})}i(Rw,"_uuidv6");function Ow(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...G(t)})}i(Ow,"_uuidv7");function Aw(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...G(t)})}i(Aw,"_url");function jw(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...G(t)})}i(jw,"_emoji");function Dw(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...G(t)})}i(Dw,"_nanoid");function Mw(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...G(t)})}i(Mw,"_cuid");function Zw(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...G(t)})}i(Zw,"_cuid2");function Lw(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...G(t)})}i(Lw,"_ulid");function Fw(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...G(t)})}i(Fw,"_xid");function Uw(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...G(t)})}i(Uw,"_ksuid");function qw(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...G(t)})}i(qw,"_ipv4");function Hw(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...G(t)})}i(Hw,"_ipv6");function Bw(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...G(t)})}i(Bw,"_cidrv4");function Vw(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...G(t)})}i(Vw,"_cidrv6");function Gw(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...G(t)})}i(Gw,"_base64");function Ww(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...G(t)})}i(Ww,"_base64url");function Kw(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...G(t)})}i(Kw,"_e164");function Jw(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...G(t)})}i(Jw,"_jwt");function Ij(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...G(t)})}i(Ij,"_isoDateTime");function Pj(e,t){return new e({type:"string",format:"date",check:"string_format",...G(t)})}i(Pj,"_isoDate");function Rj(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...G(t)})}i(Rj,"_isoTime");function Oj(e,t){return new e({type:"string",format:"duration",check:"string_format",...G(t)})}i(Oj,"_isoDuration");function Yw(e,t){return new e({type:"number",checks:[],...G(t)})}i(Yw,"_number");function Xw(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...G(t)})}i(Xw,"_int");function Qw(e,t){return new e({type:"boolean",...G(t)})}i(Qw,"_boolean");function eb(e,t){return new e({type:"null",...G(t)})}i(eb,"_null");function tb(e){return new e({type:"unknown"})}i(tb,"_unknown");function rb(e,t){return new e({type:"never",...G(t)})}i(rb,"_never");function Mf(e,t){return new Dv({check:"less_than",...G(t),value:e,inclusive:!1})}i(Mf,"_lt");function wl(e,t){return new Dv({check:"less_than",...G(t),value:e,inclusive:!0})}i(wl,"_lte");function Zf(e,t){return new Mv({check:"greater_than",...G(t),value:e,inclusive:!1})}i(Zf,"_gt");function bl(e,t){return new Mv({check:"greater_than",...G(t),value:e,inclusive:!0})}i(bl,"_gte");function Lf(e,t){return new rj({check:"multiple_of",...G(t),value:e})}i(Lf,"_multipleOf");function Ff(e,t){return new oj({check:"max_length",...G(t),maximum:e})}i(Ff,"_maxLength");function ta(e,t){return new sj({check:"min_length",...G(t),minimum:e})}i(ta,"_minLength");function Uf(e,t){return new ij({check:"length_equals",...G(t),length:e})}i(Uf,"_length");function nb(e,t){return new aj({check:"string_format",format:"regex",...G(t),pattern:e})}i(nb,"_regex");function ob(e){return new cj({check:"string_format",format:"lowercase",...G(e)})}i(ob,"_lowercase");function sb(e){return new lj({check:"string_format",format:"uppercase",...G(e)})}i(sb,"_uppercase");function ib(e,t){return new uj({check:"string_format",format:"includes",...G(t),includes:e})}i(ib,"_includes");function ab(e,t){return new dj({check:"string_format",format:"starts_with",...G(t),prefix:e})}i(ab,"_startsWith");function cb(e,t){return new pj({check:"string_format",format:"ends_with",...G(t),suffix:e})}i(cb,"_endsWith");function gs(e){return new fj({check:"overwrite",tx:e})}i(gs,"_overwrite");function lb(e){return gs(t=>t.normalize(e))}i(lb,"_normalize");function ub(){return gs(e=>e.trim())}i(ub,"_trim");function db(){return gs(e=>e.toLowerCase())}i(db,"_toLowerCase");function pb(){return gs(e=>e.toUpperCase())}i(pb,"_toUpperCase");function Aj(e,t,r){return new e({type:"array",element:t,...G(r)})}i(Aj,"_array");function fb(e,t,r){let n=G(r);return n.abort??(n.abort=!0),new e({type:"custom",check:"custom",fn:t,...n})}i(fb,"_custom");function mb(e,t,r){return new e({type:"custom",check:"custom",fn:t,...G(r)})}i(mb,"_refine");var gb=class gb{constructor(t){this.counter=0,this.metadataRegistry=t?.metadata??Jn,this.target=t?.target??"draft-2020-12",this.unrepresentable=t?.unrepresentable??"throw",this.override=t?.override??(()=>{}),this.io=t?.io??"output",this.seen=new Map}process(t,r={path:[],schemaPath:[]}){var n;let o=t._zod.def,s={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},a=this.seen.get(t);if(a)return a.count++,r.schemaPath.includes(t)&&(a.cycle=r.path),a.schema;let c={schema:{},count:1,cycle:void 0,path:r.path};this.seen.set(t,c);let l=t._zod.toJSONSchema?.();if(l)c.schema=l;else{let p={...r,schemaPath:[...r.schemaPath,t],path:r.path},h=t._zod.parent;if(h)c.ref=h,this.process(h,p),this.seen.get(h).isParent=!0;else{let m=c.schema;switch(o.type){case"string":{let g=m;g.type="string";let{minimum:_,maximum:x,format:v,patterns:w,contentEncoding:b}=t._zod.bag;if(typeof _=="number"&&(g.minLength=_),typeof x=="number"&&(g.maxLength=x),v&&(g.format=s[v]??v,g.format===""&&delete g.format),b&&(g.contentEncoding=b),w&&w.size>0){let S=[...w];S.length===1?g.pattern=S[0].source:S.length>1&&(c.schema.allOf=[...S.map(T=>({...this.target==="draft-7"?{type:"string"}:{},pattern:T.source}))])}break}case"number":{let g=m,{minimum:_,maximum:x,format:v,multipleOf:w,exclusiveMaximum:b,exclusiveMinimum:S}=t._zod.bag;typeof v=="string"&&v.includes("int")?g.type="integer":g.type="number",typeof S=="number"&&(g.exclusiveMinimum=S),typeof _=="number"&&(g.minimum=_,typeof S=="number"&&(S>=_?delete g.minimum:delete g.exclusiveMinimum)),typeof b=="number"&&(g.exclusiveMaximum=b),typeof x=="number"&&(g.maximum=x,typeof b=="number"&&(b<=x?delete g.maximum:delete g.exclusiveMaximum)),typeof w=="number"&&(g.multipleOf=w);break}case"boolean":{let g=m;g.type="boolean";break}case"bigint":{if(this.unrepresentable==="throw")throw new Error("BigInt cannot be represented in JSON Schema");break}case"symbol":{if(this.unrepresentable==="throw")throw new Error("Symbols cannot be represented in JSON Schema");break}case"null":{m.type="null";break}case"any":break;case"unknown":break;case"undefined":{if(this.unrepresentable==="throw")throw new Error("Undefined cannot be represented in JSON Schema");break}case"void":{if(this.unrepresentable==="throw")throw new Error("Void cannot be represented in JSON Schema");break}case"never":{m.not={};break}case"date":{if(this.unrepresentable==="throw")throw new Error("Date cannot be represented in JSON Schema");break}case"array":{let g=m,{minimum:_,maximum:x}=t._zod.bag;typeof _=="number"&&(g.minItems=_),typeof x=="number"&&(g.maxItems=x),g.type="array",g.items=this.process(o.element,{...p,path:[...p.path,"items"]});break}case"object":{let g=m;g.type="object",g.properties={};let _=o.shape;for(let w in _)g.properties[w]=this.process(_[w],{...p,path:[...p.path,"properties",w]});let x=new Set(Object.keys(_)),v=new Set([...x].filter(w=>{let b=o.shape[w]._zod;return this.io==="input"?b.optin===void 0:b.optout===void 0}));v.size>0&&(g.required=Array.from(v)),o.catchall?._zod.def.type==="never"?g.additionalProperties=!1:o.catchall?o.catchall&&(g.additionalProperties=this.process(o.catchall,{...p,path:[...p.path,"additionalProperties"]})):this.io==="output"&&(g.additionalProperties=!1);break}case"union":{let g=m;g.anyOf=o.options.map((_,x)=>this.process(_,{...p,path:[...p.path,"anyOf",x]}));break}case"intersection":{let g=m,_=this.process(o.left,{...p,path:[...p.path,"allOf",0]}),x=this.process(o.right,{...p,path:[...p.path,"allOf",1]}),v=i(b=>"allOf"in b&&Object.keys(b).length===1,"isSimpleIntersection"),w=[...v(_)?_.allOf:[_],...v(x)?x.allOf:[x]];g.allOf=w;break}case"tuple":{let g=m;g.type="array";let _=o.items.map((w,b)=>this.process(w,{...p,path:[...p.path,"prefixItems",b]}));if(this.target==="draft-2020-12"?g.prefixItems=_:g.items=_,o.rest){let w=this.process(o.rest,{...p,path:[...p.path,"items"]});this.target==="draft-2020-12"?g.items=w:g.additionalItems=w}o.rest&&(g.items=this.process(o.rest,{...p,path:[...p.path,"items"]}));let{minimum:x,maximum:v}=t._zod.bag;typeof x=="number"&&(g.minItems=x),typeof v=="number"&&(g.maxItems=v);break}case"record":{let g=m;g.type="object",g.propertyNames=this.process(o.keyType,{...p,path:[...p.path,"propertyNames"]}),g.additionalProperties=this.process(o.valueType,{...p,path:[...p.path,"additionalProperties"]});break}case"map":{if(this.unrepresentable==="throw")throw new Error("Map cannot be represented in JSON Schema");break}case"set":{if(this.unrepresentable==="throw")throw new Error("Set cannot be represented in JSON Schema");break}case"enum":{let g=m,_=pl(o.entries);_.every(x=>typeof x=="number")&&(g.type="number"),_.every(x=>typeof x=="string")&&(g.type="string"),g.enum=_;break}case"literal":{let g=m,_=[];for(let x of o.values)if(x===void 0){if(this.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof x=="bigint"){if(this.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");_.push(Number(x))}else _.push(x);if(_.length!==0)if(_.length===1){let x=_[0];g.type=x===null?"null":typeof x,g.const=x}else _.every(x=>typeof x=="number")&&(g.type="number"),_.every(x=>typeof x=="string")&&(g.type="string"),_.every(x=>typeof x=="boolean")&&(g.type="string"),_.every(x=>x===null)&&(g.type="null"),g.enum=_;break}case"file":{let g=m,_={type:"string",format:"binary",contentEncoding:"binary"},{minimum:x,maximum:v,mime:w}=t._zod.bag;x!==void 0&&(_.minLength=x),v!==void 0&&(_.maxLength=v),w?w.length===1?(_.contentMediaType=w[0],Object.assign(g,_)):g.anyOf=w.map(b=>({..._,contentMediaType:b})):Object.assign(g,_);break}case"transform":{if(this.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema");break}case"nullable":{let g=this.process(o.innerType,p);m.anyOf=[g,{type:"null"}];break}case"nonoptional":{this.process(o.innerType,p),c.ref=o.innerType;break}case"success":{let g=m;g.type="boolean";break}case"default":{this.process(o.innerType,p),c.ref=o.innerType,m.default=JSON.parse(JSON.stringify(o.defaultValue));break}case"prefault":{this.process(o.innerType,p),c.ref=o.innerType,this.io==="input"&&(m._prefault=JSON.parse(JSON.stringify(o.defaultValue)));break}case"catch":{this.process(o.innerType,p),c.ref=o.innerType;let g;try{g=o.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}m.default=g;break}case"nan":{if(this.unrepresentable==="throw")throw new Error("NaN cannot be represented in JSON Schema");break}case"template_literal":{let g=m,_=t._zod.pattern;if(!_)throw new Error("Pattern not found in template literal");g.type="string",g.pattern=_.source;break}case"pipe":{let g=this.io==="input"?o.in._zod.def.type==="transform"?o.out:o.in:o.out;this.process(g,p),c.ref=g;break}case"readonly":{this.process(o.innerType,p),c.ref=o.innerType,m.readOnly=!0;break}case"promise":{this.process(o.innerType,p),c.ref=o.innerType;break}case"optional":{this.process(o.innerType,p),c.ref=o.innerType;break}case"lazy":{let g=t._zod.innerType;this.process(g,p),c.ref=g;break}case"custom":{if(this.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema");break}default:}}}let u=this.metadataRegistry.get(t);return u&&Object.assign(c.schema,u),this.io==="input"&&Be(t)&&(delete c.schema.examples,delete c.schema.default),this.io==="input"&&c.schema._prefault&&((n=c.schema).default??(n.default=c.schema._prefault)),delete c.schema._prefault,this.seen.get(t).schema}emit(t,r){let n={cycles:r?.cycles??"ref",reused:r?.reused??"inline",external:r?.external??void 0},o=this.seen.get(t);if(!o)throw new Error("Unprocessed schema. This is a bug in Zod.");let s=i(d=>{let p=this.target==="draft-2020-12"?"$defs":"definitions";if(n.external){let _=n.external.registry.get(d[0])?.id,x=n.external.uri??(w=>w);if(_)return{ref:x(_)};let v=d[1].defId??d[1].schema.id??`schema${this.counter++}`;return d[1].defId=v,{defId:v,ref:`${x("__shared")}#/${p}/${v}`}}if(d[1]===o)return{ref:"#"};let m=`#/${p}/`,g=d[1].schema.id??`__schema${this.counter++}`;return{defId:g,ref:m+g}},"makeURI"),a=i(d=>{if(d[1].schema.$ref)return;let p=d[1],{ref:h,defId:m}=s(d);p.def={...p.schema},m&&(p.defId=m);let g=p.schema;for(let _ in g)delete g[_];g.$ref=h},"extractToDef");if(n.cycles==="throw")for(let d of this.seen.entries()){let p=d[1];if(p.cycle)throw new Error(`Cycle detected: #/${p.cycle?.join("/")}/<root>
348
+ path: iss.path ? [${Ys(b)}, ...iss.path] : [${Ys(b)}]
349
+ })));`),m.write(`newResult[${Ys(b)}] = ${w}.value`)}m.write("payload.value = newResult;"),m.write("return payload;");let v=m.compile();return(b,w)=>v(p,b,w)},"generateFastpass"),o,s=Va,a=!Th.jitless,l=a&&Gb.value,u=t.catchall,d;e._zod.parse=(p,m)=>{d??(d=r.value);let h=p.value;if(!s(h))return p.issues.push({expected:"object",code:"invalid_type",input:h,inst:e}),p;let g=[];if(a&&l&&m?.async===!1&&m.jitless!==!0)o||(o=n(t.shape)),p=o(p,m);else{p.value={};let w=d.shape;for(let S of d.keys){let E=w[S],I=E._zod.run({value:h[S],issues:[]},m),z=E._zod.optin==="optional"&&E._zod.optout==="optional";I instanceof Promise?g.push(I.then(M=>z?IZ(M,p,S,h):Rh(M,p,S))):z?IZ(I,p,S,h):Rh(I,p,S)}}if(!u)return g.length?Promise.all(g).then(()=>p):p;let _=[],x=d.keySet,v=u._zod,b=v.def.type;for(let w of Object.keys(h)){if(x.has(w))continue;if(b==="never"){_.push(w);continue}let S=v.run({value:h[w],issues:[]},m);S instanceof Promise?g.push(S.then(E=>Rh(E,p,w))):Rh(S,p,w)}return _.length&&p.issues.push({code:"unrecognized_keys",keys:_,input:h,inst:e}),g.length?Promise.all(g).then(()=>p):p}});function PZ(e,t,r,n){for(let o of e)if(o.issues.length===0)return t.value=o.value,t;return t.issues.push({code:"invalid_union",input:t.value,inst:r,errors:e.map(o=>o.issues.map(s=>zr(s,n,Vt())))}),t}i(PZ,"handleUnionResults");var Mh=T("$ZodUnion",(e,t)=>{Se.init(e,t),ze(e._zod,"optin",()=>t.options.some(r=>r._zod.optin==="optional")?"optional":void 0),ze(e._zod,"optout",()=>t.options.some(r=>r._zod.optout==="optional")?"optional":void 0),ze(e._zod,"values",()=>{if(t.options.every(r=>r._zod.values))return new Set(t.options.flatMap(r=>Array.from(r._zod.values)))}),ze(e._zod,"pattern",()=>{if(t.options.every(r=>r._zod.pattern)){let r=t.options.map(n=>n._zod.pattern);return new RegExp(`^(${r.map(n=>Uu(n.source)).join("|")})$`)}}),e._zod.parse=(r,n)=>{let o=!1,s=[];for(let a of t.options){let c=a._zod.run({value:r.value,issues:[]},n);if(c instanceof Promise)s.push(c),o=!0;else{if(c.issues.length===0)return c;s.push(c)}}return o?Promise.all(s).then(a=>PZ(a,r,e,n)):PZ(s,r,e,n)}}),M0=T("$ZodDiscriminatedUnion",(e,t)=>{Mh.init(e,t);let r=e._zod.parse;ze(e._zod,"propValues",()=>{let o={};for(let s of t.options){let a=s._zod.propValues;if(!a||Object.keys(a).length===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(s)}"`);for(let[c,l]of Object.entries(a)){o[c]||(o[c]=new Set);for(let u of l)o[c].add(u)}}return o});let n=Lu(()=>{let o=t.options,s=new Map;for(let a of o){let c=a._zod.propValues[t.discriminator];if(!c||c.size===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(a)}"`);for(let l of c){if(s.has(l))throw new Error(`Duplicate discriminator value "${String(l)}"`);s.set(l,a)}}return s});e._zod.parse=(o,s)=>{let a=o.value;if(!Va(a))return o.issues.push({code:"invalid_type",expected:"object",input:a,inst:e}),o;let c=n.value.get(a?.[t.discriminator]);return c?c._zod.run(o,s):t.unionFallback?r(o,s):(o.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",input:a,path:[t.discriminator],inst:e}),o)}}),Z0=T("$ZodIntersection",(e,t)=>{Se.init(e,t),e._zod.parse=(r,n)=>{let o=r.value,s=t.left._zod.run({value:o,issues:[]},n),a=t.right._zod.run({value:o,issues:[]},n);return s instanceof Promise||a instanceof Promise?Promise.all([s,a]).then(([l,u])=>OZ(r,l,u)):OZ(r,s,a)}});function p0(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(Ga(e)&&Ga(t)){let r=Object.keys(t),n=Object.keys(e).filter(s=>r.indexOf(s)!==-1),o={...e,...t};for(let s of n){let a=p0(e[s],t[s]);if(!a.valid)return{valid:!1,mergeErrorPath:[s,...a.mergeErrorPath]};o[s]=a.data}return{valid:!0,data:o}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let r=[];for(let n=0;n<e.length;n++){let o=e[n],s=t[n],a=p0(o,s);if(!a.valid)return{valid:!1,mergeErrorPath:[n,...a.mergeErrorPath]};r.push(a.data)}return{valid:!0,data:r}}return{valid:!1,mergeErrorPath:[]}}i(p0,"mergeValues");function OZ(e,t,r){if(t.issues.length&&e.issues.push(...t.issues),r.issues.length&&e.issues.push(...r.issues),Xs(e))return e;let n=p0(t.value,r.value);if(!n.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(n.mergeErrorPath)}`);return e.value=n.data,e}i(OZ,"handleIntersectionResults");var L0=T("$ZodRecord",(e,t)=>{Se.init(e,t),e._zod.parse=(r,n)=>{let o=r.value;if(!Ga(o))return r.issues.push({expected:"record",code:"invalid_type",input:o,inst:e}),r;let s=[];if(t.keyType._zod.values){let a=t.keyType._zod.values;r.value={};for(let l of a)if(typeof l=="string"||typeof l=="number"||typeof l=="symbol"){let u=t.valueType._zod.run({value:o[l],issues:[]},n);u instanceof Promise?s.push(u.then(d=>{d.issues.length&&r.issues.push(...tn(l,d.issues)),r.value[l]=d.value})):(u.issues.length&&r.issues.push(...tn(l,u.issues)),r.value[l]=u.value)}let c;for(let l in o)a.has(l)||(c=c??[],c.push(l));c&&c.length>0&&r.issues.push({code:"unrecognized_keys",input:o,inst:e,keys:c})}else{r.value={};for(let a of Reflect.ownKeys(o)){if(a==="__proto__")continue;let c=t.keyType._zod.run({value:a,issues:[]},n);if(c instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(c.issues.length){r.issues.push({origin:"record",code:"invalid_key",issues:c.issues.map(u=>zr(u,n,Vt())),input:a,path:[a],inst:e}),r.value[c.value]=c.value;continue}let l=t.valueType._zod.run({value:o[a],issues:[]},n);l instanceof Promise?s.push(l.then(u=>{u.issues.length&&r.issues.push(...tn(a,u.issues)),r.value[c.value]=u.value})):(l.issues.length&&r.issues.push(...tn(a,l.issues)),r.value[c.value]=l.value)}}return s.length?Promise.all(s).then(()=>r):r}});var F0=T("$ZodEnum",(e,t)=>{Se.init(e,t);let r=Zu(t.entries);e._zod.values=new Set(r),e._zod.pattern=new RegExp(`^(${r.filter(n=>Wb.has(typeof n)).map(n=>typeof n=="string"?wo(n):n.toString()).join("|")})$`),e._zod.parse=(n,o)=>{let s=n.value;return e._zod.values.has(s)||n.issues.push({code:"invalid_value",values:r,input:s,inst:e}),n}}),U0=T("$ZodLiteral",(e,t)=>{Se.init(e,t),e._zod.values=new Set(t.values),e._zod.pattern=new RegExp(`^(${t.values.map(r=>typeof r=="string"?wo(r):r?r.toString():String(r)).join("|")})$`),e._zod.parse=(r,n)=>{let o=r.value;return e._zod.values.has(o)||r.issues.push({code:"invalid_value",values:t.values,input:o,inst:e}),r}});var q0=T("$ZodTransform",(e,t)=>{Se.init(e,t),e._zod.parse=(r,n)=>{let o=t.transform(r.value,r);if(n.async)return(o instanceof Promise?o:Promise.resolve(o)).then(a=>(r.value=a,r));if(o instanceof Promise)throw new qn;return r.value=o,r}}),B0=T("$ZodOptional",(e,t)=>{Se.init(e,t),e._zod.optin="optional",e._zod.optout="optional",ze(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),ze(e._zod,"pattern",()=>{let r=t.innerType._zod.pattern;return r?new RegExp(`^(${Uu(r.source)})?$`):void 0}),e._zod.parse=(r,n)=>t.innerType._zod.optin==="optional"?t.innerType._zod.run(r,n):r.value===void 0?r:t.innerType._zod.run(r,n)}),H0=T("$ZodNullable",(e,t)=>{Se.init(e,t),ze(e._zod,"optin",()=>t.innerType._zod.optin),ze(e._zod,"optout",()=>t.innerType._zod.optout),ze(e._zod,"pattern",()=>{let r=t.innerType._zod.pattern;return r?new RegExp(`^(${Uu(r.source)}|null)$`):void 0}),ze(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(r,n)=>r.value===null?r:t.innerType._zod.run(r,n)}),V0=T("$ZodDefault",(e,t)=>{Se.init(e,t),e._zod.optin="optional",ze(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,n)=>{if(r.value===void 0)return r.value=t.defaultValue,r;let o=t.innerType._zod.run(r,n);return o instanceof Promise?o.then(s=>AZ(s,t)):AZ(o,t)}});function AZ(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}i(AZ,"handleDefaultResult");var G0=T("$ZodPrefault",(e,t)=>{Se.init(e,t),e._zod.optin="optional",ze(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,n)=>(r.value===void 0&&(r.value=t.defaultValue),t.innerType._zod.run(r,n))}),W0=T("$ZodNonOptional",(e,t)=>{Se.init(e,t),ze(e._zod,"values",()=>{let r=t.innerType._zod.values;return r?new Set([...r].filter(n=>n!==void 0)):void 0}),e._zod.parse=(r,n)=>{let o=t.innerType._zod.run(r,n);return o instanceof Promise?o.then(s=>RZ(s,e)):RZ(o,e)}});function RZ(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}i(RZ,"handleNonOptionalResult");var J0=T("$ZodCatch",(e,t)=>{Se.init(e,t),e._zod.optin="optional",ze(e._zod,"optout",()=>t.innerType._zod.optout),ze(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,n)=>{let o=t.innerType._zod.run(r,n);return o instanceof Promise?o.then(s=>(r.value=s.value,s.issues.length&&(r.value=t.catchValue({...r,error:{issues:s.issues.map(a=>zr(a,n,Vt()))},input:r.value}),r.issues=[]),r)):(r.value=o.value,o.issues.length&&(r.value=t.catchValue({...r,error:{issues:o.issues.map(s=>zr(s,n,Vt()))},input:r.value}),r.issues=[]),r)}});var K0=T("$ZodPipe",(e,t)=>{Se.init(e,t),ze(e._zod,"values",()=>t.in._zod.values),ze(e._zod,"optin",()=>t.in._zod.optin),ze(e._zod,"optout",()=>t.out._zod.optout),e._zod.parse=(r,n)=>{let o=t.in._zod.run(r,n);return o instanceof Promise?o.then(s=>jZ(s,t,n)):jZ(o,t,n)}});function jZ(e,t,r){return Xs(e)?e:t.out._zod.run({value:e.value,issues:e.issues},r)}i(jZ,"handlePipeResult");var Y0=T("$ZodReadonly",(e,t)=>{Se.init(e,t),ze(e._zod,"propValues",()=>t.innerType._zod.propValues),ze(e._zod,"values",()=>t.innerType._zod.values),ze(e._zod,"optin",()=>t.innerType._zod.optin),ze(e._zod,"optout",()=>t.innerType._zod.optout),e._zod.parse=(r,n)=>{let o=t.innerType._zod.run(r,n);return o instanceof Promise?o.then(DZ):DZ(o)}});function DZ(e){return e.value=Object.freeze(e.value),e}i(DZ,"handleReadonlyResult");var X0=T("$ZodCustom",(e,t)=>{ot.init(e,t),Se.init(e,t),e._zod.parse=(r,n)=>r,e._zod.check=r=>{let n=r.value,o=t.fn(n);if(o instanceof Promise)return o.then(s=>MZ(s,r,n,e));MZ(o,r,n,e)}});function MZ(e,t,r,n){if(!e){let o={code:"custom",input:r,inst:n,path:[...n._zod.def.path??[]],continue:!n._zod.def.abort};n._zod.def.params&&(o.params=n._zod.def.params),t.issues.push(Yb(o))}}i(MZ,"handleRefineResult");var RY=i(e=>{let t=typeof e;switch(t){case"number":return Number.isNaN(e)?"NaN":"number";case"object":{if(Array.isArray(e))return"array";if(e===null)return"null";if(Object.getPrototypeOf(e)!==Object.prototype&&e.constructor)return e.constructor.name}}return t},"parsedType"),jY=i(()=>{let e={string:{unit:"characters",verb:"to have"},file:{unit:"bytes",verb:"to have"},array:{unit:"items",verb:"to have"},set:{unit:"items",verb:"to have"}};function t(n){return e[n]??null}i(t,"getSizing");let r={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",jwt:"JWT",template_literal:"input"};return n=>{switch(n.code){case"invalid_type":return`Invalid input: expected ${n.expected}, received ${RY(n.input)}`;case"invalid_value":return n.values.length===1?`Invalid input: expected ${Ih(n.values[0])}`:`Invalid option: expected one of ${zh(n.values,"|")}`;case"too_big":{let o=n.inclusive?"<=":"<",s=t(n.origin);return s?`Too big: expected ${n.origin??"value"} to have ${o}${n.maximum.toString()} ${s.unit??"elements"}`:`Too big: expected ${n.origin??"value"} to be ${o}${n.maximum.toString()}`}case"too_small":{let o=n.inclusive?">=":">",s=t(n.origin);return s?`Too small: expected ${n.origin} to have ${o}${n.minimum.toString()} ${s.unit}`:`Too small: expected ${n.origin} to be ${o}${n.minimum.toString()}`}case"invalid_format":{let o=n;return o.format==="starts_with"?`Invalid string: must start with "${o.prefix}"`:o.format==="ends_with"?`Invalid string: must end with "${o.suffix}"`:o.format==="includes"?`Invalid string: must include "${o.includes}"`:o.format==="regex"?`Invalid string: must match pattern ${o.pattern}`:`Invalid ${r[o.format]??n.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${n.divisor}`;case"unrecognized_keys":return`Unrecognized key${n.keys.length>1?"s":""}: ${zh(n.keys,", ")}`;case"invalid_key":return`Invalid key in ${n.origin}`;case"invalid_union":return"Invalid input";case"invalid_element":return`Invalid value in ${n.origin}`;default:return"Invalid input"}}},"error");function Q0(){return{localeError:jY()}}i(Q0,"default");var DY=Symbol("ZodOutput"),MY=Symbol("ZodInput"),eS=class eS{constructor(){this._map=new Map,this._idmap=new Map}add(t,...r){let n=r[0];if(this._map.set(t,n),n&&typeof n=="object"&&"id"in n){if(this._idmap.has(n.id))throw new Error(`ID ${n.id} already exists in the registry`);this._idmap.set(n.id,t)}return this}clear(){return this._map=new Map,this._idmap=new Map,this}remove(t){let r=this._map.get(t);return r&&typeof r=="object"&&"id"in r&&this._idmap.delete(r.id),this._map.delete(t),this}get(t){let r=t._zod.parent;if(r){let n={...this.get(r)??{}};return delete n.id,{...n,...this._map.get(t)}}return this._map.get(t)}has(t){return this._map.has(t)}};i(eS,"$ZodRegistry");var Gu=eS;function BZ(){return new Gu}i(BZ,"registry");var bo=BZ();function tS(e,t){return new e({type:"string",...X(t)})}i(tS,"_string");function rS(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...X(t)})}i(rS,"_email");function Zh(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...X(t)})}i(Zh,"_guid");function nS(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...X(t)})}i(nS,"_uuid");function oS(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...X(t)})}i(oS,"_uuidv4");function sS(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...X(t)})}i(sS,"_uuidv6");function iS(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...X(t)})}i(iS,"_uuidv7");function aS(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...X(t)})}i(aS,"_url");function cS(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...X(t)})}i(cS,"_emoji");function lS(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...X(t)})}i(lS,"_nanoid");function uS(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...X(t)})}i(uS,"_cuid");function dS(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...X(t)})}i(dS,"_cuid2");function pS(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...X(t)})}i(pS,"_ulid");function fS(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...X(t)})}i(fS,"_xid");function mS(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...X(t)})}i(mS,"_ksuid");function hS(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...X(t)})}i(hS,"_ipv4");function gS(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...X(t)})}i(gS,"_ipv6");function yS(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...X(t)})}i(yS,"_cidrv4");function xS(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...X(t)})}i(xS,"_cidrv6");function _S(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...X(t)})}i(_S,"_base64");function vS(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...X(t)})}i(vS,"_base64url");function wS(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...X(t)})}i(wS,"_e164");function bS(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...X(t)})}i(bS,"_jwt");function HZ(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...X(t)})}i(HZ,"_isoDateTime");function VZ(e,t){return new e({type:"string",format:"date",check:"string_format",...X(t)})}i(VZ,"_isoDate");function GZ(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...X(t)})}i(GZ,"_isoTime");function WZ(e,t){return new e({type:"string",format:"duration",check:"string_format",...X(t)})}i(WZ,"_isoDuration");function SS(e,t){return new e({type:"number",checks:[],...X(t)})}i(SS,"_number");function kS(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...X(t)})}i(kS,"_int");function $S(e,t){return new e({type:"boolean",...X(t)})}i($S,"_boolean");function ES(e,t){return new e({type:"null",...X(t)})}i(ES,"_null");function NS(e){return new e({type:"unknown"})}i(NS,"_unknown");function TS(e,t){return new e({type:"never",...X(t)})}i(TS,"_never");function Lh(e,t){return new l0({check:"less_than",...X(t),value:e,inclusive:!1})}i(Lh,"_lt");function Wu(e,t){return new l0({check:"less_than",...X(t),value:e,inclusive:!0})}i(Wu,"_lte");function Fh(e,t){return new u0({check:"greater_than",...X(t),value:e,inclusive:!1})}i(Fh,"_gt");function Ju(e,t){return new u0({check:"greater_than",...X(t),value:e,inclusive:!0})}i(Ju,"_gte");function Uh(e,t){return new gZ({check:"multiple_of",...X(t),value:e})}i(Uh,"_multipleOf");function qh(e,t){return new xZ({check:"max_length",...X(t),maximum:e})}i(qh,"_maxLength");function Wa(e,t){return new _Z({check:"min_length",...X(t),minimum:e})}i(Wa,"_minLength");function Bh(e,t){return new vZ({check:"length_equals",...X(t),length:e})}i(Bh,"_length");function zS(e,t){return new wZ({check:"string_format",format:"regex",...X(t),pattern:e})}i(zS,"_regex");function CS(e){return new bZ({check:"string_format",format:"lowercase",...X(e)})}i(CS,"_lowercase");function IS(e){return new SZ({check:"string_format",format:"uppercase",...X(e)})}i(IS,"_uppercase");function PS(e,t){return new kZ({check:"string_format",format:"includes",...X(t),includes:e})}i(PS,"_includes");function OS(e,t){return new $Z({check:"string_format",format:"starts_with",...X(t),prefix:e})}i(OS,"_startsWith");function AS(e,t){return new EZ({check:"string_format",format:"ends_with",...X(t),suffix:e})}i(AS,"_endsWith");function ti(e){return new NZ({check:"overwrite",tx:e})}i(ti,"_overwrite");function RS(e){return ti(t=>t.normalize(e))}i(RS,"_normalize");function jS(){return ti(e=>e.trim())}i(jS,"_trim");function DS(){return ti(e=>e.toLowerCase())}i(DS,"_toLowerCase");function MS(){return ti(e=>e.toUpperCase())}i(MS,"_toUpperCase");function JZ(e,t,r){return new e({type:"array",element:t,...X(r)})}i(JZ,"_array");function ZS(e,t,r){let n=X(r);return n.abort??(n.abort=!0),new e({type:"custom",check:"custom",fn:t,...n})}i(ZS,"_custom");function LS(e,t,r){return new e({type:"custom",check:"custom",fn:t,...X(r)})}i(LS,"_refine");var US=class US{constructor(t){this.counter=0,this.metadataRegistry=t?.metadata??bo,this.target=t?.target??"draft-2020-12",this.unrepresentable=t?.unrepresentable??"throw",this.override=t?.override??(()=>{}),this.io=t?.io??"output",this.seen=new Map}process(t,r={path:[],schemaPath:[]}){var n;let o=t._zod.def,s={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},a=this.seen.get(t);if(a)return a.count++,r.schemaPath.includes(t)&&(a.cycle=r.path),a.schema;let c={schema:{},count:1,cycle:void 0,path:r.path};this.seen.set(t,c);let l=t._zod.toJSONSchema?.();if(l)c.schema=l;else{let p={...r,schemaPath:[...r.schemaPath,t],path:r.path},m=t._zod.parent;if(m)c.ref=m,this.process(m,p),this.seen.get(m).isParent=!0;else{let h=c.schema;switch(o.type){case"string":{let g=h;g.type="string";let{minimum:_,maximum:x,format:v,patterns:b,contentEncoding:w}=t._zod.bag;if(typeof _=="number"&&(g.minLength=_),typeof x=="number"&&(g.maxLength=x),v&&(g.format=s[v]??v,g.format===""&&delete g.format),w&&(g.contentEncoding=w),b&&b.size>0){let S=[...b];S.length===1?g.pattern=S[0].source:S.length>1&&(c.schema.allOf=[...S.map(E=>({...this.target==="draft-7"?{type:"string"}:{},pattern:E.source}))])}break}case"number":{let g=h,{minimum:_,maximum:x,format:v,multipleOf:b,exclusiveMaximum:w,exclusiveMinimum:S}=t._zod.bag;typeof v=="string"&&v.includes("int")?g.type="integer":g.type="number",typeof S=="number"&&(g.exclusiveMinimum=S),typeof _=="number"&&(g.minimum=_,typeof S=="number"&&(S>=_?delete g.minimum:delete g.exclusiveMinimum)),typeof w=="number"&&(g.exclusiveMaximum=w),typeof x=="number"&&(g.maximum=x,typeof w=="number"&&(w<=x?delete g.maximum:delete g.exclusiveMaximum)),typeof b=="number"&&(g.multipleOf=b);break}case"boolean":{let g=h;g.type="boolean";break}case"bigint":{if(this.unrepresentable==="throw")throw new Error("BigInt cannot be represented in JSON Schema");break}case"symbol":{if(this.unrepresentable==="throw")throw new Error("Symbols cannot be represented in JSON Schema");break}case"null":{h.type="null";break}case"any":break;case"unknown":break;case"undefined":{if(this.unrepresentable==="throw")throw new Error("Undefined cannot be represented in JSON Schema");break}case"void":{if(this.unrepresentable==="throw")throw new Error("Void cannot be represented in JSON Schema");break}case"never":{h.not={};break}case"date":{if(this.unrepresentable==="throw")throw new Error("Date cannot be represented in JSON Schema");break}case"array":{let g=h,{minimum:_,maximum:x}=t._zod.bag;typeof _=="number"&&(g.minItems=_),typeof x=="number"&&(g.maxItems=x),g.type="array",g.items=this.process(o.element,{...p,path:[...p.path,"items"]});break}case"object":{let g=h;g.type="object",g.properties={};let _=o.shape;for(let b in _)g.properties[b]=this.process(_[b],{...p,path:[...p.path,"properties",b]});let x=new Set(Object.keys(_)),v=new Set([...x].filter(b=>{let w=o.shape[b]._zod;return this.io==="input"?w.optin===void 0:w.optout===void 0}));v.size>0&&(g.required=Array.from(v)),o.catchall?._zod.def.type==="never"?g.additionalProperties=!1:o.catchall?o.catchall&&(g.additionalProperties=this.process(o.catchall,{...p,path:[...p.path,"additionalProperties"]})):this.io==="output"&&(g.additionalProperties=!1);break}case"union":{let g=h;g.anyOf=o.options.map((_,x)=>this.process(_,{...p,path:[...p.path,"anyOf",x]}));break}case"intersection":{let g=h,_=this.process(o.left,{...p,path:[...p.path,"allOf",0]}),x=this.process(o.right,{...p,path:[...p.path,"allOf",1]}),v=i(w=>"allOf"in w&&Object.keys(w).length===1,"isSimpleIntersection"),b=[...v(_)?_.allOf:[_],...v(x)?x.allOf:[x]];g.allOf=b;break}case"tuple":{let g=h;g.type="array";let _=o.items.map((b,w)=>this.process(b,{...p,path:[...p.path,"prefixItems",w]}));if(this.target==="draft-2020-12"?g.prefixItems=_:g.items=_,o.rest){let b=this.process(o.rest,{...p,path:[...p.path,"items"]});this.target==="draft-2020-12"?g.items=b:g.additionalItems=b}o.rest&&(g.items=this.process(o.rest,{...p,path:[...p.path,"items"]}));let{minimum:x,maximum:v}=t._zod.bag;typeof x=="number"&&(g.minItems=x),typeof v=="number"&&(g.maxItems=v);break}case"record":{let g=h;g.type="object",g.propertyNames=this.process(o.keyType,{...p,path:[...p.path,"propertyNames"]}),g.additionalProperties=this.process(o.valueType,{...p,path:[...p.path,"additionalProperties"]});break}case"map":{if(this.unrepresentable==="throw")throw new Error("Map cannot be represented in JSON Schema");break}case"set":{if(this.unrepresentable==="throw")throw new Error("Set cannot be represented in JSON Schema");break}case"enum":{let g=h,_=Zu(o.entries);_.every(x=>typeof x=="number")&&(g.type="number"),_.every(x=>typeof x=="string")&&(g.type="string"),g.enum=_;break}case"literal":{let g=h,_=[];for(let x of o.values)if(x===void 0){if(this.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof x=="bigint"){if(this.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");_.push(Number(x))}else _.push(x);if(_.length!==0)if(_.length===1){let x=_[0];g.type=x===null?"null":typeof x,g.const=x}else _.every(x=>typeof x=="number")&&(g.type="number"),_.every(x=>typeof x=="string")&&(g.type="string"),_.every(x=>typeof x=="boolean")&&(g.type="string"),_.every(x=>x===null)&&(g.type="null"),g.enum=_;break}case"file":{let g=h,_={type:"string",format:"binary",contentEncoding:"binary"},{minimum:x,maximum:v,mime:b}=t._zod.bag;x!==void 0&&(_.minLength=x),v!==void 0&&(_.maxLength=v),b?b.length===1?(_.contentMediaType=b[0],Object.assign(g,_)):g.anyOf=b.map(w=>({..._,contentMediaType:w})):Object.assign(g,_);break}case"transform":{if(this.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema");break}case"nullable":{let g=this.process(o.innerType,p);h.anyOf=[g,{type:"null"}];break}case"nonoptional":{this.process(o.innerType,p),c.ref=o.innerType;break}case"success":{let g=h;g.type="boolean";break}case"default":{this.process(o.innerType,p),c.ref=o.innerType,h.default=JSON.parse(JSON.stringify(o.defaultValue));break}case"prefault":{this.process(o.innerType,p),c.ref=o.innerType,this.io==="input"&&(h._prefault=JSON.parse(JSON.stringify(o.defaultValue)));break}case"catch":{this.process(o.innerType,p),c.ref=o.innerType;let g;try{g=o.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}h.default=g;break}case"nan":{if(this.unrepresentable==="throw")throw new Error("NaN cannot be represented in JSON Schema");break}case"template_literal":{let g=h,_=t._zod.pattern;if(!_)throw new Error("Pattern not found in template literal");g.type="string",g.pattern=_.source;break}case"pipe":{let g=this.io==="input"?o.in._zod.def.type==="transform"?o.out:o.in:o.out;this.process(g,p),c.ref=g;break}case"readonly":{this.process(o.innerType,p),c.ref=o.innerType,h.readOnly=!0;break}case"promise":{this.process(o.innerType,p),c.ref=o.innerType;break}case"optional":{this.process(o.innerType,p),c.ref=o.innerType;break}case"lazy":{let g=t._zod.innerType;this.process(g,p),c.ref=g;break}case"custom":{if(this.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema");break}default:}}}let u=this.metadataRegistry.get(t);return u&&Object.assign(c.schema,u),this.io==="input"&&Ge(t)&&(delete c.schema.examples,delete c.schema.default),this.io==="input"&&c.schema._prefault&&((n=c.schema).default??(n.default=c.schema._prefault)),delete c.schema._prefault,this.seen.get(t).schema}emit(t,r){let n={cycles:r?.cycles??"ref",reused:r?.reused??"inline",external:r?.external??void 0},o=this.seen.get(t);if(!o)throw new Error("Unprocessed schema. This is a bug in Zod.");let s=i(d=>{let p=this.target==="draft-2020-12"?"$defs":"definitions";if(n.external){let _=n.external.registry.get(d[0])?.id,x=n.external.uri??(b=>b);if(_)return{ref:x(_)};let v=d[1].defId??d[1].schema.id??`schema${this.counter++}`;return d[1].defId=v,{defId:v,ref:`${x("__shared")}#/${p}/${v}`}}if(d[1]===o)return{ref:"#"};let h=`#/${p}/`,g=d[1].schema.id??`__schema${this.counter++}`;return{defId:g,ref:h+g}},"makeURI"),a=i(d=>{if(d[1].schema.$ref)return;let p=d[1],{ref:m,defId:h}=s(d);p.def={...p.schema},h&&(p.defId=h);let g=p.schema;for(let _ in g)delete g[_];g.$ref=m},"extractToDef");if(n.cycles==="throw")for(let d of this.seen.entries()){let p=d[1];if(p.cycle)throw new Error(`Cycle detected: #/${p.cycle?.join("/")}/<root>
290
350
 
291
- Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let d of this.seen.entries()){let p=d[1];if(t===d[0]){a(d);continue}if(n.external){let m=n.external.registry.get(d[0])?.id;if(t!==d[0]&&m){a(d);continue}}if(this.metadataRegistry.get(d[0])?.id){a(d);continue}if(p.cycle){a(d);continue}if(p.count>1&&n.reused==="ref"){a(d);continue}}let c=i((d,p)=>{let h=this.seen.get(d),m=h.def??h.schema,g={...m};if(h.ref===null)return;let _=h.ref;if(h.ref=null,_){c(_,p);let x=this.seen.get(_).schema;x.$ref&&p.target==="draft-7"?(m.allOf=m.allOf??[],m.allOf.push(x)):(Object.assign(m,x),Object.assign(m,g))}h.isParent||this.override({zodSchema:d,jsonSchema:m,path:h.path??[]})},"flattenRef");for(let d of[...this.seen.entries()].reverse())c(d[0],{target:this.target});let l={};if(this.target==="draft-2020-12"?l.$schema="https://json-schema.org/draft/2020-12/schema":this.target==="draft-7"?l.$schema="http://json-schema.org/draft-07/schema#":console.warn(`Invalid target: ${this.target}`),n.external?.uri){let d=n.external.registry.get(t)?.id;if(!d)throw new Error("Schema is missing an `id` property");l.$id=n.external.uri(d)}Object.assign(l,o.def);let u=n.external?.defs??{};for(let d of this.seen.entries()){let p=d[1];p.def&&p.defId&&(u[p.defId]=p.def)}n.external||Object.keys(u).length>0&&(this.target==="draft-2020-12"?l.$defs=u:l.definitions=u);try{return JSON.parse(JSON.stringify(l))}catch{throw new Error("Error converting schema to JSON.")}}};i(gb,"JSONSchemaGenerator");var qf=gb;function hb(e,t){if(e instanceof vl){let n=new qf(t),o={};for(let c of e._idmap.entries()){let[l,u]=c;n.process(u)}let s={},a={registry:e,uri:t?.uri,defs:o};for(let c of e._idmap.entries()){let[l,u]=c;s[l]=n.emit(u,{...t,external:a})}if(Object.keys(o).length>0){let c=n.target==="draft-2020-12"?"$defs":"definitions";s.__shared={[c]:o}}return{schemas:s}}let r=new qf(t);return r.process(e),r.emit(e,t)}i(hb,"toJSONSchema");function Be(e,t){let r=t??{seen:new Set};if(r.seen.has(e))return!1;r.seen.add(e);let o=e._zod.def;switch(o.type){case"string":case"number":case"bigint":case"boolean":case"date":case"symbol":case"undefined":case"null":case"any":case"unknown":case"never":case"void":case"literal":case"enum":case"nan":case"file":case"template_literal":return!1;case"array":return Be(o.element,r);case"object":{for(let s in o.shape)if(Be(o.shape[s],r))return!0;return!1}case"union":{for(let s of o.options)if(Be(s,r))return!0;return!1}case"intersection":return Be(o.left,r)||Be(o.right,r);case"tuple":{for(let s of o.items)if(Be(s,r))return!0;return!!(o.rest&&Be(o.rest,r))}case"record":return Be(o.keyType,r)||Be(o.valueType,r);case"map":return Be(o.keyType,r)||Be(o.valueType,r);case"set":return Be(o.valueType,r);case"promise":case"optional":case"nonoptional":case"nullable":case"readonly":return Be(o.innerType,r);case"lazy":return Be(o.getter(),r);case"default":return Be(o.innerType,r);case"prefault":return Be(o.innerType,r);case"custom":return!1;case"transform":return!0;case"pipe":return Be(o.in,r)||Be(o.out,r);case"success":return!1;case"catch":return!1;default:}throw new Error(`Unknown schema type: ${o.type}`)}i(Be,"isTransforming");var gG=N("ZodMiniType",(e,t)=>{if(!e._zod)throw new Error("Uninitialized schema in ZodMiniType.");_e.init(e,t),e.def=t,e.parse=(r,n)=>Cv(e,r,n,{callee:e.parse}),e.safeParse=(r,n)=>ms(e,r,n),e.parseAsync=async(r,n)=>Pv(e,r,n,{callee:e.parseAsync}),e.safeParseAsync=async(r,n)=>hs(e,r,n),e.check=(...r)=>e.clone({...t,checks:[...t.checks??[],...r.map(n=>typeof n=="function"?{_zod:{check:n,def:{check:"custom"},onattach:[]}}:n)]}),e.clone=(r,n)=>Ft(e,r,n),e.brand=()=>e,e.register=(r,n)=>(r.add(e,n),e)});var yG=N("ZodMiniObject",(e,t)=>{Af.init(e,t),gG.init(e,t),ce.defineLazy(e,"shape",()=>t.shape)});function yb(e,t){let r={type:"object",get shape(){return ce.assignProp(this,"shape",{...e}),this.shape},...ce.normalizeParams(t)};return new yG(r)}i(yb,"object");function Hr(e){return!!e._zod}i(Hr,"isZ4Schema");function xs(e){let t=Object.values(e);if(t.length===0)return yb({});let r=t.every(Hr),n=t.every(o=>!Hr(o));if(r)return yb(e);if(n)return q_(e);throw new Error("Mixed Zod versions detected in object shape.")}i(xs,"objectFromShape");function Yn(e,t){return Hr(e)?ms(e,t):e.safeParse(t)}i(Yn,"safeParse");async function Hf(e,t){return Hr(e)?await hs(e,t):await e.safeParseAsync(t)}i(Hf,"safeParseAsync");function Xn(e){if(!e)return;let t;if(Hr(e)?t=e._zod?.def?.shape:t=e.shape,!!t){if(typeof t=="function")try{return t()}catch{return}return t}}i(Xn,"getObjectShape");function ra(e){if(e){if(typeof e=="object"){let t=e,r=e;if(!t._def&&!r._zod){let n=Object.values(e);if(n.length>0&&n.every(o=>typeof o=="object"&&o!==null&&(o._def!==void 0||o._zod!==void 0||typeof o.parse=="function")))return xs(e)}}if(Hr(e)){let r=e._zod?.def;if(r&&(r.type==="object"||r.shape!==void 0))return e}else if(e.shape!==void 0)return e}}i(ra,"normalizeObjectSchema");function _G(e){return e.length===0?"object root":e.reduce((t,r,n)=>n===0?String(r):typeof r=="number"?`${t}[${r}]`:`${t}.${r}`,"")}i(_G,"getDotPath");function Bf(e){if(e&&typeof e=="object"){if("issues"in e&&Array.isArray(e.issues)&&e.issues.length>0)return e.issues.map(t=>t.path?.length?`${t.message} at ${_G(t.path)}`:t.message).join(`
292
- `);if("message"in e&&typeof e.message=="string")return e.message;try{return JSON.stringify(e)}catch{return String(e)}}return String(e)}i(Bf,"getParseErrorMessage");function Dj(e){return e.description}i(Dj,"getSchemaDescription");function Mj(e){if(Hr(e))return e._zod?.def?.type==="optional";let t=e;return typeof e.isOptional=="function"?e.isOptional():t._def?.typeName==="ZodOptional"}i(Mj,"isSchemaOptional");function na(e){if(Hr(e)){let s=e._zod?.def;if(s){if(s.value!==void 0)return s.value;if(Array.isArray(s.values)&&s.values.length>0)return s.values[0]}}let r=e._def;if(r){if(r.value!==void 0)return r.value;if(Array.isArray(r.values)&&r.values.length>0)return r.values[0]}let n=e.value;if(n!==void 0)return n}i(na,"getLiteralValue");var Sl={};R(Sl,{ZodISODate:()=>Lj,ZodISODateTime:()=>Zj,ZodISODuration:()=>Uj,ZodISOTime:()=>Fj,date:()=>_b,datetime:()=>xb,duration:()=>wb,time:()=>vb});var Zj=N("ZodISODateTime",(e,t)=>{$j.init(e,t),je.init(e,t)});function xb(e){return Ij(Zj,e)}i(xb,"datetime");var Lj=N("ZodISODate",(e,t)=>{Ej.init(e,t),je.init(e,t)});function _b(e){return Pj(Lj,e)}i(_b,"date");var Fj=N("ZodISOTime",(e,t)=>{Nj.init(e,t),je.init(e,t)});function vb(e){return Rj(Fj,e)}i(vb,"time");var Uj=N("ZodISODuration",(e,t)=>{Tj.init(e,t),je.init(e,t)});function wb(e){return Oj(Uj,e)}i(wb,"duration");var qj=i((e,t)=>{Cf.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:r=>Tv(e,r)},flatten:{value:r=>Nv(e,r)},addIssue:{value:r=>e.issues.push(r)},addIssues:{value:r=>e.issues.push(...r)},isEmpty:{get(){return e.issues.length===0}}})},"initializer"),_Oe=N("ZodError",qj),kl=N("ZodError",qj,{Parent:Error});var Hj=zv(kl),Bj=Iv(kl),Vj=Rv(kl),Gj=Ov(kl);var Le=N("ZodType",(e,t)=>(_e.init(e,t),e.def=t,Object.defineProperty(e,"_def",{value:t}),e.check=(...r)=>e.clone({...t,checks:[...t.checks??[],...r.map(n=>typeof n=="function"?{_zod:{check:n,def:{check:"custom"},onattach:[]}}:n)]}),e.clone=(r,n)=>Ft(e,r,n),e.brand=()=>e,e.register=(r,n)=>(r.add(e,n),e),e.parse=(r,n)=>Hj(e,r,n,{callee:e.parse}),e.safeParse=(r,n)=>Vj(e,r,n),e.parseAsync=async(r,n)=>Bj(e,r,n,{callee:e.parseAsync}),e.safeParseAsync=async(r,n)=>Gj(e,r,n),e.spa=e.safeParseAsync,e.refine=(r,n)=>e.check(hW(r,n)),e.superRefine=r=>e.check(gW(r)),e.overwrite=r=>e.check(gs(r)),e.optional=()=>Me(e),e.nullable=()=>Jj(e),e.nullish=()=>Me(Jj(e)),e.nonoptional=r=>cW(e,r),e.array=()=>le(e),e.or=r=>Ce([e,r]),e.and=r=>Gf(e,r),e.transform=r=>Sb(e,rD(r)),e.default=r=>sW(e,r),e.prefault=r=>aW(e,r),e.catch=r=>uW(e,r),e.pipe=r=>Sb(e,r),e.readonly=()=>fW(e),e.describe=r=>{let n=e.clone();return Jn.add(n,{description:r}),n},Object.defineProperty(e,"description",{get(){return Jn.get(e)?.description},configurable:!0}),e.meta=(...r)=>{if(r.length===0)return Jn.get(e);let n=e.clone();return Jn.add(n,r[0]),n},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e)),Yj=N("_ZodString",(e,t)=>{_l.init(e,t),Le.init(e,t);let r=e._zod.bag;e.format=r.format??null,e.minLength=r.minimum??null,e.maxLength=r.maximum??null,e.regex=(...n)=>e.check(nb(...n)),e.includes=(...n)=>e.check(ib(...n)),e.startsWith=(...n)=>e.check(ab(...n)),e.endsWith=(...n)=>e.check(cb(...n)),e.min=(...n)=>e.check(ta(...n)),e.max=(...n)=>e.check(Ff(...n)),e.length=(...n)=>e.check(Uf(...n)),e.nonempty=(...n)=>e.check(ta(1,...n)),e.lowercase=n=>e.check(ob(n)),e.uppercase=n=>e.check(sb(n)),e.trim=()=>e.check(ub()),e.normalize=(...n)=>e.check(lb(...n)),e.toLowerCase=()=>e.check(db()),e.toUpperCase=()=>e.check(pb())}),NG=N("ZodString",(e,t)=>{_l.init(e,t),Yj.init(e,t),e.email=r=>e.check(Cw(TG,r)),e.url=r=>e.check(Aw(zG,r)),e.jwt=r=>e.check(Jw(HG,r)),e.emoji=r=>e.check(jw(CG,r)),e.guid=r=>e.check(Df(Wj,r)),e.uuid=r=>e.check(Iw(Vf,r)),e.uuidv4=r=>e.check(Pw(Vf,r)),e.uuidv6=r=>e.check(Rw(Vf,r)),e.uuidv7=r=>e.check(Ow(Vf,r)),e.nanoid=r=>e.check(Dw(IG,r)),e.guid=r=>e.check(Df(Wj,r)),e.cuid=r=>e.check(Mw(PG,r)),e.cuid2=r=>e.check(Zw(RG,r)),e.ulid=r=>e.check(Lw(OG,r)),e.base64=r=>e.check(Gw(FG,r)),e.base64url=r=>e.check(Ww(UG,r)),e.xid=r=>e.check(Fw(AG,r)),e.ksuid=r=>e.check(Uw(jG,r)),e.ipv4=r=>e.check(qw(DG,r)),e.ipv6=r=>e.check(Hw(MG,r)),e.cidrv4=r=>e.check(Bw(ZG,r)),e.cidrv6=r=>e.check(Vw(LG,r)),e.e164=r=>e.check(Kw(qG,r)),e.datetime=r=>e.check(xb(r)),e.date=r=>e.check(_b(r)),e.time=r=>e.check(vb(r)),e.duration=r=>e.check(wb(r))});function $(e){return zw(NG,e)}i($,"string");var je=N("ZodStringFormat",(e,t)=>{Ee.init(e,t),Yj.init(e,t)}),TG=N("ZodEmail",(e,t)=>{qv.init(e,t),je.init(e,t)});var Wj=N("ZodGUID",(e,t)=>{Fv.init(e,t),je.init(e,t)});var Vf=N("ZodUUID",(e,t)=>{Uv.init(e,t),je.init(e,t)});var zG=N("ZodURL",(e,t)=>{Hv.init(e,t),je.init(e,t)});var CG=N("ZodEmoji",(e,t)=>{Bv.init(e,t),je.init(e,t)});var IG=N("ZodNanoID",(e,t)=>{Vv.init(e,t),je.init(e,t)});var PG=N("ZodCUID",(e,t)=>{Gv.init(e,t),je.init(e,t)});var RG=N("ZodCUID2",(e,t)=>{Wv.init(e,t),je.init(e,t)});var OG=N("ZodULID",(e,t)=>{Kv.init(e,t),je.init(e,t)});var AG=N("ZodXID",(e,t)=>{Jv.init(e,t),je.init(e,t)});var jG=N("ZodKSUID",(e,t)=>{Yv.init(e,t),je.init(e,t)});var DG=N("ZodIPv4",(e,t)=>{Xv.init(e,t),je.init(e,t)});var MG=N("ZodIPv6",(e,t)=>{Qv.init(e,t),je.init(e,t)});var ZG=N("ZodCIDRv4",(e,t)=>{ew.init(e,t),je.init(e,t)});var LG=N("ZodCIDRv6",(e,t)=>{tw.init(e,t),je.init(e,t)});var FG=N("ZodBase64",(e,t)=>{rw.init(e,t),je.init(e,t)});var UG=N("ZodBase64URL",(e,t)=>{nw.init(e,t),je.init(e,t)});var qG=N("ZodE164",(e,t)=>{ow.init(e,t),je.init(e,t)});var HG=N("ZodJWT",(e,t)=>{sw.init(e,t),je.init(e,t)});var Xj=N("ZodNumber",(e,t)=>{Of.init(e,t),Le.init(e,t),e.gt=(n,o)=>e.check(Zf(n,o)),e.gte=(n,o)=>e.check(bl(n,o)),e.min=(n,o)=>e.check(bl(n,o)),e.lt=(n,o)=>e.check(Mf(n,o)),e.lte=(n,o)=>e.check(wl(n,o)),e.max=(n,o)=>e.check(wl(n,o)),e.int=n=>e.check(Kj(n)),e.safe=n=>e.check(Kj(n)),e.positive=n=>e.check(Zf(0,n)),e.nonnegative=n=>e.check(bl(0,n)),e.negative=n=>e.check(Mf(0,n)),e.nonpositive=n=>e.check(wl(0,n)),e.multipleOf=(n,o)=>e.check(Lf(n,o)),e.step=(n,o)=>e.check(Lf(n,o)),e.finite=()=>e;let r=e._zod.bag;e.minValue=Math.max(r.minimum??Number.NEGATIVE_INFINITY,r.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(r.maximum??Number.POSITIVE_INFINITY,r.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(r.format??"").includes("int")||Number.isSafeInteger(r.multipleOf??.5),e.isFinite=!0,e.format=r.format??null});function xe(e){return Yw(Xj,e)}i(xe,"number");var BG=N("ZodNumberFormat",(e,t)=>{iw.init(e,t),Xj.init(e,t)});function Kj(e){return Xw(BG,e)}i(Kj,"int");var VG=N("ZodBoolean",(e,t)=>{aw.init(e,t),Le.init(e,t)});function Ke(e){return Qw(VG,e)}i(Ke,"boolean");var GG=N("ZodNull",(e,t)=>{cw.init(e,t),Le.init(e,t)});function Qj(e){return eb(GG,e)}i(Qj,"_null");var WG=N("ZodUnknown",(e,t)=>{lw.init(e,t),Le.init(e,t)});function De(){return tb(WG)}i(De,"unknown");var KG=N("ZodNever",(e,t)=>{uw.init(e,t),Le.init(e,t)});function JG(e){return rb(KG,e)}i(JG,"never");var YG=N("ZodArray",(e,t)=>{dw.init(e,t),Le.init(e,t),e.element=t.element,e.min=(r,n)=>e.check(ta(r,n)),e.nonempty=r=>e.check(ta(1,r)),e.max=(r,n)=>e.check(Ff(r,n)),e.length=(r,n)=>e.check(Uf(r,n)),e.unwrap=()=>e.element});function le(e,t){return Aj(YG,e,t)}i(le,"array");var eD=N("ZodObject",(e,t)=>{Af.init(e,t),Le.init(e,t),ce.defineLazy(e,"shape",()=>t.shape),e.keyof=()=>Et(Object.keys(e._zod.def.shape)),e.catchall=r=>e.clone({...e._zod.def,catchall:r}),e.passthrough=()=>e.clone({...e._zod.def,catchall:De()}),e.loose=()=>e.clone({...e._zod.def,catchall:De()}),e.strict=()=>e.clone({...e._zod.def,catchall:JG()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=r=>ce.extend(e,r),e.merge=r=>ce.merge(e,r),e.pick=r=>ce.pick(e,r),e.omit=r=>ce.omit(e,r),e.partial=(...r)=>ce.partial(nD,e,r[0]),e.required=(...r)=>ce.required(oD,e,r[0])});function Z(e,t){let r={type:"object",get shape(){return ce.assignProp(this,"shape",{...e}),this.shape},...ce.normalizeParams(t)};return new eD(r)}i(Z,"object");function ht(e,t){return new eD({type:"object",get shape(){return ce.assignProp(this,"shape",{...e}),this.shape},catchall:De(),...ce.normalizeParams(t)})}i(ht,"looseObject");var tD=N("ZodUnion",(e,t)=>{jf.init(e,t),Le.init(e,t),e.options=t.options});function Ce(e,t){return new tD({type:"union",options:e,...ce.normalizeParams(t)})}i(Ce,"union");var XG=N("ZodDiscriminatedUnion",(e,t)=>{tD.init(e,t),pw.init(e,t)});function kb(e,t,r){return new XG({type:"union",options:t,discriminator:e,...ce.normalizeParams(r)})}i(kb,"discriminatedUnion");var QG=N("ZodIntersection",(e,t)=>{fw.init(e,t),Le.init(e,t)});function Gf(e,t){return new QG({type:"intersection",left:e,right:t})}i(Gf,"intersection");var eW=N("ZodRecord",(e,t)=>{mw.init(e,t),Le.init(e,t),e.keyType=t.keyType,e.valueType=t.valueType});function Ne(e,t,r){return new eW({type:"record",keyType:e,valueType:t,...ce.normalizeParams(r)})}i(Ne,"record");var bb=N("ZodEnum",(e,t)=>{hw.init(e,t),Le.init(e,t),e.enum=t.entries,e.options=Object.values(t.entries);let r=new Set(Object.keys(t.entries));e.extract=(n,o)=>{let s={};for(let a of n)if(r.has(a))s[a]=t.entries[a];else throw new Error(`Key ${a} not found in enum`);return new bb({...t,checks:[],...ce.normalizeParams(o),entries:s})},e.exclude=(n,o)=>{let s={...t.entries};for(let a of n)if(r.has(a))delete s[a];else throw new Error(`Key ${a} not found in enum`);return new bb({...t,checks:[],...ce.normalizeParams(o),entries:s})}});function Et(e,t){let r=Array.isArray(e)?Object.fromEntries(e.map(n=>[n,n])):e;return new bb({type:"enum",entries:r,...ce.normalizeParams(t)})}i(Et,"_enum");var tW=N("ZodLiteral",(e,t)=>{gw.init(e,t),Le.init(e,t),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function q(e,t){return new tW({type:"literal",values:Array.isArray(e)?e:[e],...ce.normalizeParams(t)})}i(q,"literal");var rW=N("ZodTransform",(e,t)=>{yw.init(e,t),Le.init(e,t),e._zod.parse=(r,n)=>{r.addIssue=s=>{if(typeof s=="string")r.issues.push(ce.issue(s,r.value,t));else{let a=s;a.fatal&&(a.continue=!1),a.code??(a.code="custom"),a.input??(a.input=r.value),a.inst??(a.inst=e),a.continue??(a.continue=!0),r.issues.push(ce.issue(a))}};let o=t.transform(r.value,r);return o instanceof Promise?o.then(s=>(r.value=s,r)):(r.value=o,r)}});function rD(e){return new rW({type:"transform",transform:e})}i(rD,"transform");var nD=N("ZodOptional",(e,t)=>{xw.init(e,t),Le.init(e,t),e.unwrap=()=>e._zod.def.innerType});function Me(e){return new nD({type:"optional",innerType:e})}i(Me,"optional");var nW=N("ZodNullable",(e,t)=>{_w.init(e,t),Le.init(e,t),e.unwrap=()=>e._zod.def.innerType});function Jj(e){return new nW({type:"nullable",innerType:e})}i(Jj,"nullable");var oW=N("ZodDefault",(e,t)=>{vw.init(e,t),Le.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function sW(e,t){return new oW({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():t}})}i(sW,"_default");var iW=N("ZodPrefault",(e,t)=>{ww.init(e,t),Le.init(e,t),e.unwrap=()=>e._zod.def.innerType});function aW(e,t){return new iW({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():t}})}i(aW,"prefault");var oD=N("ZodNonOptional",(e,t)=>{bw.init(e,t),Le.init(e,t),e.unwrap=()=>e._zod.def.innerType});function cW(e,t){return new oD({type:"nonoptional",innerType:e,...ce.normalizeParams(t)})}i(cW,"nonoptional");var lW=N("ZodCatch",(e,t)=>{Sw.init(e,t),Le.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function uW(e,t){return new lW({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}i(uW,"_catch");var dW=N("ZodPipe",(e,t)=>{kw.init(e,t),Le.init(e,t),e.in=t.in,e.out=t.out});function Sb(e,t){return new dW({type:"pipe",in:e,out:t})}i(Sb,"pipe");var pW=N("ZodReadonly",(e,t)=>{$w.init(e,t),Le.init(e,t)});function fW(e){return new pW({type:"readonly",innerType:e})}i(fW,"readonly");var sD=N("ZodCustom",(e,t)=>{Ew.init(e,t),Le.init(e,t)});function mW(e){let t=new tt({check:"custom"});return t._zod.check=e,t}i(mW,"check");function iD(e,t){return fb(sD,e??(()=>!0),t)}i(iD,"custom");function hW(e,t={}){return mb(sD,e,t)}i(hW,"refine");function gW(e){let t=mW(r=>(r.addIssue=n=>{if(typeof n=="string")r.issues.push(ce.issue(n,r.value,t._zod.def));else{let o=n;o.fatal&&(o.continue=!1),o.code??(o.code="custom"),o.input??(o.input=r.value),o.inst??(o.inst=t),o.continue??(o.continue=!t._zod.def.abort),r.issues.push(ce.issue(o))}},e(r.value,r)));return t}i(gW,"superRefine");function $b(e,t){return Sb(rD(e),t)}i($b,"preprocess");Lt(Nw());var Nb="2025-11-25";var aD=[Nb,"2025-06-18","2025-03-26","2024-11-05","2024-10-07"],Qn="io.modelcontextprotocol/related-task",Jf="2.0",Ve=iD(e=>e!==null&&(typeof e=="object"||typeof e=="function")),cD=Ce([$(),xe().int()]),lD=$(),AOe=ht({ttl:xe().optional(),pollInterval:xe().optional()}),yW=Z({ttl:xe().optional()}),xW=Z({taskId:$()}),Tb=ht({progressToken:cD.optional(),[Qn]:xW.optional()}),Ut=Z({_meta:Tb.optional()}),$l=Ut.extend({task:yW.optional()}),uD=i(e=>$l.safeParse(e).success,"isTaskAugmentedRequestParams"),rt=Z({method:$(),params:Ut.loose().optional()}),or=Z({_meta:Tb.optional()}),sr=Z({method:$(),params:or.loose().optional()}),nt=ht({_meta:Tb.optional()}),Yf=Ce([$(),xe().int()]),dD=Z({jsonrpc:q(Jf),id:Yf,...rt.shape}).strict(),zb=i(e=>dD.safeParse(e).success,"isJSONRPCRequest"),pD=Z({jsonrpc:q(Jf),...sr.shape}).strict(),fD=i(e=>pD.safeParse(e).success,"isJSONRPCNotification"),Cb=Z({jsonrpc:q(Jf),id:Yf,result:nt}).strict(),El=i(e=>Cb.safeParse(e).success,"isJSONRPCResultResponse");var B;(function(e){e[e.ConnectionClosed=-32e3]="ConnectionClosed",e[e.RequestTimeout=-32001]="RequestTimeout",e[e.ParseError=-32700]="ParseError",e[e.InvalidRequest=-32600]="InvalidRequest",e[e.MethodNotFound=-32601]="MethodNotFound",e[e.InvalidParams=-32602]="InvalidParams",e[e.InternalError=-32603]="InternalError",e[e.UrlElicitationRequired=-32042]="UrlElicitationRequired"})(B||(B={}));var Ib=Z({jsonrpc:q(Jf),id:Yf.optional(),error:Z({code:xe().int(),message:$(),data:De().optional()})}).strict();var mD=i(e=>Ib.safeParse(e).success,"isJSONRPCErrorResponse");var hD=Ce([dD,pD,Cb,Ib]),jOe=Ce([Cb,Ib]),Xf=nt.strict(),_W=or.extend({requestId:Yf.optional(),reason:$().optional()}),Qf=sr.extend({method:q("notifications/cancelled"),params:_W}),vW=Z({src:$(),mimeType:$().optional(),sizes:le($()).optional(),theme:Et(["light","dark"]).optional()}),Nl=Z({icons:le(vW).optional()}),oa=Z({name:$(),title:$().optional()}),gD=oa.extend({...oa.shape,...Nl.shape,version:$(),websiteUrl:$().optional(),description:$().optional()}),wW=Gf(Z({applyDefaults:Ke().optional()}),Ne($(),De())),bW=$b(e=>e&&typeof e=="object"&&!Array.isArray(e)&&Object.keys(e).length===0?{form:{}}:e,Gf(Z({form:wW.optional(),url:Ve.optional()}),Ne($(),De()).optional())),SW=ht({list:Ve.optional(),cancel:Ve.optional(),requests:ht({sampling:ht({createMessage:Ve.optional()}).optional(),elicitation:ht({create:Ve.optional()}).optional()}).optional()}),kW=ht({list:Ve.optional(),cancel:Ve.optional(),requests:ht({tools:ht({call:Ve.optional()}).optional()}).optional()}),$W=Z({experimental:Ne($(),Ve).optional(),sampling:Z({context:Ve.optional(),tools:Ve.optional()}).optional(),elicitation:bW.optional(),roots:Z({listChanged:Ke().optional()}).optional(),tasks:SW.optional(),extensions:Ne($(),Ve).optional()}),EW=Ut.extend({protocolVersion:$(),capabilities:$W,clientInfo:gD}),Pb=rt.extend({method:q("initialize"),params:EW});var NW=Z({experimental:Ne($(),Ve).optional(),logging:Ve.optional(),completions:Ve.optional(),prompts:Z({listChanged:Ke().optional()}).optional(),resources:Z({subscribe:Ke().optional(),listChanged:Ke().optional()}).optional(),tools:Z({listChanged:Ke().optional()}).optional(),tasks:kW.optional(),extensions:Ne($(),Ve).optional()}),TW=nt.extend({protocolVersion:$(),capabilities:NW,serverInfo:gD,instructions:$().optional()}),Rb=sr.extend({method:q("notifications/initialized"),params:or.optional()});var em=rt.extend({method:q("ping"),params:Ut.optional()}),zW=Z({progress:xe(),total:Me(xe()),message:Me($())}),CW=Z({...or.shape,...zW.shape,progressToken:cD}),tm=sr.extend({method:q("notifications/progress"),params:CW}),IW=Ut.extend({cursor:lD.optional()}),Tl=rt.extend({params:IW.optional()}),zl=nt.extend({nextCursor:lD.optional()}),PW=Et(["working","input_required","completed","failed","cancelled"]),Cl=Z({taskId:$(),status:PW,ttl:Ce([xe(),Qj()]),createdAt:$(),lastUpdatedAt:$(),pollInterval:Me(xe()),statusMessage:Me($())}),sa=nt.extend({task:Cl}),RW=or.merge(Cl),Il=sr.extend({method:q("notifications/tasks/status"),params:RW}),rm=rt.extend({method:q("tasks/get"),params:Ut.extend({taskId:$()})}),nm=nt.merge(Cl),om=rt.extend({method:q("tasks/result"),params:Ut.extend({taskId:$()})}),DOe=nt.loose(),sm=Tl.extend({method:q("tasks/list")}),im=zl.extend({tasks:le(Cl)}),am=rt.extend({method:q("tasks/cancel"),params:Ut.extend({taskId:$()})}),yD=nt.merge(Cl),xD=Z({uri:$(),mimeType:Me($()),_meta:Ne($(),De()).optional()}),_D=xD.extend({text:$()}),Ob=$().refine(e=>{try{return atob(e),!0}catch{return!1}},{message:"Invalid Base64 string"}),vD=xD.extend({blob:Ob}),Pl=Et(["user","assistant"]),ia=Z({audience:le(Pl).optional(),priority:xe().min(0).max(1).optional(),lastModified:Sl.datetime({offset:!0}).optional()}),wD=Z({...oa.shape,...Nl.shape,uri:$(),description:Me($()),mimeType:Me($()),size:Me(xe()),annotations:ia.optional(),_meta:Me(ht({}))}),OW=Z({...oa.shape,...Nl.shape,uriTemplate:$(),description:Me($()),mimeType:Me($()),annotations:ia.optional(),_meta:Me(ht({}))}),cm=Tl.extend({method:q("resources/list")}),AW=zl.extend({resources:le(wD)}),lm=Tl.extend({method:q("resources/templates/list")}),jW=zl.extend({resourceTemplates:le(OW)}),Ab=Ut.extend({uri:$()}),DW=Ab,um=rt.extend({method:q("resources/read"),params:DW}),MW=nt.extend({contents:le(Ce([_D,vD]))}),ZW=sr.extend({method:q("notifications/resources/list_changed"),params:or.optional()}),LW=Ab,FW=rt.extend({method:q("resources/subscribe"),params:LW}),UW=Ab,qW=rt.extend({method:q("resources/unsubscribe"),params:UW}),HW=or.extend({uri:$()}),BW=sr.extend({method:q("notifications/resources/updated"),params:HW}),VW=Z({name:$(),description:Me($()),required:Me(Ke())}),GW=Z({...oa.shape,...Nl.shape,description:Me($()),arguments:Me(le(VW)),_meta:Me(ht({}))}),dm=Tl.extend({method:q("prompts/list")}),WW=zl.extend({prompts:le(GW)}),KW=Ut.extend({name:$(),arguments:Ne($(),$()).optional()}),pm=rt.extend({method:q("prompts/get"),params:KW}),jb=Z({type:q("text"),text:$(),annotations:ia.optional(),_meta:Ne($(),De()).optional()}),Db=Z({type:q("image"),data:Ob,mimeType:$(),annotations:ia.optional(),_meta:Ne($(),De()).optional()}),Mb=Z({type:q("audio"),data:Ob,mimeType:$(),annotations:ia.optional(),_meta:Ne($(),De()).optional()}),JW=Z({type:q("tool_use"),name:$(),id:$(),input:Ne($(),De()),_meta:Ne($(),De()).optional()}),YW=Z({type:q("resource"),resource:Ce([_D,vD]),annotations:ia.optional(),_meta:Ne($(),De()).optional()}),XW=wD.extend({type:q("resource_link")}),Zb=Ce([jb,Db,Mb,XW,YW]),QW=Z({role:Pl,content:Zb}),eK=nt.extend({description:$().optional(),messages:le(QW)}),tK=sr.extend({method:q("notifications/prompts/list_changed"),params:or.optional()}),rK=Z({title:$().optional(),readOnlyHint:Ke().optional(),destructiveHint:Ke().optional(),idempotentHint:Ke().optional(),openWorldHint:Ke().optional()}),nK=Z({taskSupport:Et(["required","optional","forbidden"]).optional()}),bD=Z({...oa.shape,...Nl.shape,description:$().optional(),inputSchema:Z({type:q("object"),properties:Ne($(),Ve).optional(),required:le($()).optional()}).catchall(De()),outputSchema:Z({type:q("object"),properties:Ne($(),Ve).optional(),required:le($()).optional()}).catchall(De()).optional(),annotations:rK.optional(),execution:nK.optional(),_meta:Ne($(),De()).optional()}),fm=Tl.extend({method:q("tools/list")}),oK=zl.extend({tools:le(bD)}),mm=nt.extend({content:le(Zb).default([]),structuredContent:Ne($(),De()).optional(),isError:Ke().optional()}),MOe=mm.or(nt.extend({toolResult:De()})),sK=$l.extend({name:$(),arguments:Ne($(),De()).optional()}),aa=rt.extend({method:q("tools/call"),params:sK}),iK=sr.extend({method:q("notifications/tools/list_changed"),params:or.optional()}),ZOe=Z({autoRefresh:Ke().default(!0),debounceMs:xe().int().nonnegative().default(300)}),Rl=Et(["debug","info","notice","warning","error","critical","alert","emergency"]),aK=Ut.extend({level:Rl}),Lb=rt.extend({method:q("logging/setLevel"),params:aK}),cK=or.extend({level:Rl,logger:$().optional(),data:De()}),lK=sr.extend({method:q("notifications/message"),params:cK}),uK=Z({name:$().optional()}),dK=Z({hints:le(uK).optional(),costPriority:xe().min(0).max(1).optional(),speedPriority:xe().min(0).max(1).optional(),intelligencePriority:xe().min(0).max(1).optional()}),pK=Z({mode:Et(["auto","required","none"]).optional()}),fK=Z({type:q("tool_result"),toolUseId:$().describe("The unique identifier for the corresponding tool call."),content:le(Zb).default([]),structuredContent:Z({}).loose().optional(),isError:Ke().optional(),_meta:Ne($(),De()).optional()}),mK=kb("type",[jb,Db,Mb]),Wf=kb("type",[jb,Db,Mb,JW,fK]),hK=Z({role:Pl,content:Ce([Wf,le(Wf)]),_meta:Ne($(),De()).optional()}),gK=$l.extend({messages:le(hK),modelPreferences:dK.optional(),systemPrompt:$().optional(),includeContext:Et(["none","thisServer","allServers"]).optional(),temperature:xe().optional(),maxTokens:xe().int(),stopSequences:le($()).optional(),metadata:Ve.optional(),tools:le(bD).optional(),toolChoice:pK.optional()}),yK=rt.extend({method:q("sampling/createMessage"),params:gK}),Ol=nt.extend({model:$(),stopReason:Me(Et(["endTurn","stopSequence","maxTokens"]).or($())),role:Pl,content:mK}),Fb=nt.extend({model:$(),stopReason:Me(Et(["endTurn","stopSequence","maxTokens","toolUse"]).or($())),role:Pl,content:Ce([Wf,le(Wf)])}),xK=Z({type:q("boolean"),title:$().optional(),description:$().optional(),default:Ke().optional()}),_K=Z({type:q("string"),title:$().optional(),description:$().optional(),minLength:xe().optional(),maxLength:xe().optional(),format:Et(["email","uri","date","date-time"]).optional(),default:$().optional()}),vK=Z({type:Et(["number","integer"]),title:$().optional(),description:$().optional(),minimum:xe().optional(),maximum:xe().optional(),default:xe().optional()}),wK=Z({type:q("string"),title:$().optional(),description:$().optional(),enum:le($()),default:$().optional()}),bK=Z({type:q("string"),title:$().optional(),description:$().optional(),oneOf:le(Z({const:$(),title:$()})),default:$().optional()}),SK=Z({type:q("string"),title:$().optional(),description:$().optional(),enum:le($()),enumNames:le($()).optional(),default:$().optional()}),kK=Ce([wK,bK]),$K=Z({type:q("array"),title:$().optional(),description:$().optional(),minItems:xe().optional(),maxItems:xe().optional(),items:Z({type:q("string"),enum:le($())}),default:le($()).optional()}),EK=Z({type:q("array"),title:$().optional(),description:$().optional(),minItems:xe().optional(),maxItems:xe().optional(),items:Z({anyOf:le(Z({const:$(),title:$()}))}),default:le($()).optional()}),NK=Ce([$K,EK]),TK=Ce([SK,kK,NK]),zK=Ce([TK,xK,_K,vK]),CK=$l.extend({mode:q("form").optional(),message:$(),requestedSchema:Z({type:q("object"),properties:Ne($(),zK),required:le($()).optional()})}),IK=$l.extend({mode:q("url"),message:$(),elicitationId:$(),url:$().url()}),PK=Ce([CK,IK]),RK=rt.extend({method:q("elicitation/create"),params:PK}),OK=or.extend({elicitationId:$()}),AK=sr.extend({method:q("notifications/elicitation/complete"),params:OK}),ca=nt.extend({action:Et(["accept","decline","cancel"]),content:$b(e=>e===null?void 0:e,Ne($(),Ce([$(),xe(),Ke(),le($())])).optional())}),jK=Z({type:q("ref/resource"),uri:$()});var DK=Z({type:q("ref/prompt"),name:$()}),MK=Ut.extend({ref:Ce([DK,jK]),argument:Z({name:$(),value:$()}),context:Z({arguments:Ne($(),$()).optional()}).optional()}),hm=rt.extend({method:q("completion/complete"),params:MK});function SD(e){if(e.params.ref.type!=="ref/prompt")throw new TypeError(`Expected CompleteRequestPrompt, but got ${e.params.ref.type}`)}i(SD,"assertCompleteRequestPrompt");function kD(e){if(e.params.ref.type!=="ref/resource")throw new TypeError(`Expected CompleteRequestResourceTemplate, but got ${e.params.ref.type}`)}i(kD,"assertCompleteRequestResourceTemplate");var ZK=nt.extend({completion:ht({values:le($()).max(100),total:Me(xe().int()),hasMore:Me(Ke())})}),LK=Z({uri:$().startsWith("file://"),name:$().optional(),_meta:Ne($(),De()).optional()}),FK=rt.extend({method:q("roots/list"),params:Ut.optional()}),Ub=nt.extend({roots:le(LK)}),UK=sr.extend({method:q("notifications/roots/list_changed"),params:or.optional()}),LOe=Ce([em,Pb,hm,Lb,pm,dm,cm,lm,um,FW,qW,aa,fm,rm,om,sm,am]),FOe=Ce([Qf,tm,Rb,UK,Il]),UOe=Ce([Xf,Ol,Fb,ca,Ub,nm,im,sa]),qOe=Ce([em,yK,RK,FK,rm,om,sm,am]),HOe=Ce([Qf,tm,lK,BW,ZW,iK,tK,Il,AK]),BOe=Ce([Xf,TW,ZK,eK,WW,AW,jW,MW,mm,oK,nm,im,sa]),Kf=class Kf extends Error{constructor(t,r,n){super(`MCP error ${t}: ${r}`),this.code=t,this.data=n,this.name="McpError"}static fromError(t,r,n){if(t===B.UrlElicitationRequired&&n){let o=n;if(o.elicitations)return new Eb(o.elicitations,r)}return new Kf(t,r,n)}};i(Kf,"McpError");var U=Kf,qb=class qb extends U{constructor(t,r=`URL elicitation${t.length>1?"s":""} required`){super(B.UrlElicitationRequired,r,{elicitations:t})}get elicitations(){return this.data?.elicitations??[]}};i(qb,"UrlElicitationRequiredError");var Eb=qb;function eo(e){return e==="completed"||e==="failed"||e==="cancelled"}i(eo,"isTerminal");var ED=Symbol("Let zodToJsonSchema decide on which parser to use");var $D={name:void 0,$refStrategy:"root",basePath:["#"],effectStrategy:"input",pipeStrategy:"all",dateStrategy:"format:date-time",mapStrategy:"entries",removeAdditionalStrategy:"passthrough",allowedAdditionalProperties:!0,rejectedAdditionalProperties:!1,definitionPath:"definitions",target:"jsonSchema7",strictUnions:!1,definitions:{},errorMessages:!1,markdownDescription:!1,patternStrategy:"escape",applyRegexFlags:!1,emailStrategy:"format:email",base64Strategy:"contentEncoding:base64",nameStrategy:"ref",openAiAnyTypeName:"OpenAiAnyType"},ND=i(e=>typeof e=="string"?{...$D,name:e}:{...$D,...e},"getDefaultOptions");var TD=i(e=>{let t=ND(e),r=t.name!==void 0?[...t.basePath,t.definitionPath,t.name]:t.basePath;return{...t,flags:{hasReferencedOpenAiAnyType:!1},currentPath:r,propertyPath:void 0,seen:new Map(Object.entries(t.definitions).map(([n,o])=>[o._def,{def:o._def,path:[...t.basePath,t.definitionPath,n],jsonSchema:void 0}]))}},"getRefs");function Hb(e,t,r,n){n?.errorMessages&&r&&(e.errorMessage={...e.errorMessage,[t]:r})}i(Hb,"addErrorMessage");function ue(e,t,r,n,o){e[t]=r,Hb(e,t,n,o)}i(ue,"setResponseValueAndErrors");var gm=i((e,t)=>{let r=0;for(;r<e.length&&r<t.length&&e[r]===t[r];r++);return[(e.length-r).toString(),...t.slice(r)].join("/")},"getRelativePath");function Ze(e){if(e.target!=="openAi")return{};let t=[...e.basePath,e.definitionPath,e.openAiAnyTypeName];return e.flags.hasReferencedOpenAiAnyType=!0,{$ref:e.$refStrategy==="relative"?gm(t,e.currentPath):t.join("/")}}i(Ze,"parseAnyDef");function zD(e,t){let r={type:"array"};return e.type?._def&&e.type?._def?.typeName!==P.ZodAny&&(r.items=J(e.type._def,{...t,currentPath:[...t.currentPath,"items"]})),e.minLength&&ue(r,"minItems",e.minLength.value,e.minLength.message,t),e.maxLength&&ue(r,"maxItems",e.maxLength.value,e.maxLength.message,t),e.exactLength&&(ue(r,"minItems",e.exactLength.value,e.exactLength.message,t),ue(r,"maxItems",e.exactLength.value,e.exactLength.message,t)),r}i(zD,"parseArrayDef");function CD(e,t){let r={type:"integer",format:"int64"};if(!e.checks)return r;for(let n of e.checks)switch(n.kind){case"min":t.target==="jsonSchema7"?n.inclusive?ue(r,"minimum",n.value,n.message,t):ue(r,"exclusiveMinimum",n.value,n.message,t):(n.inclusive||(r.exclusiveMinimum=!0),ue(r,"minimum",n.value,n.message,t));break;case"max":t.target==="jsonSchema7"?n.inclusive?ue(r,"maximum",n.value,n.message,t):ue(r,"exclusiveMaximum",n.value,n.message,t):(n.inclusive||(r.exclusiveMaximum=!0),ue(r,"maximum",n.value,n.message,t));break;case"multipleOf":ue(r,"multipleOf",n.value,n.message,t);break}return r}i(CD,"parseBigintDef");function ID(){return{type:"boolean"}}i(ID,"parseBooleanDef");function ym(e,t){return J(e.type._def,t)}i(ym,"parseBrandedDef");var PD=i((e,t)=>J(e.innerType._def,t),"parseCatchDef");function Bb(e,t,r){let n=r??t.dateStrategy;if(Array.isArray(n))return{anyOf:n.map((o,s)=>Bb(e,t,o))};switch(n){case"string":case"format:date-time":return{type:"string",format:"date-time"};case"format:date":return{type:"string",format:"date"};case"integer":return qK(e,t)}}i(Bb,"parseDateDef");var qK=i((e,t)=>{let r={type:"integer",format:"unix-time"};if(t.target==="openApi3")return r;for(let n of e.checks)switch(n.kind){case"min":ue(r,"minimum",n.value,n.message,t);break;case"max":ue(r,"maximum",n.value,n.message,t);break}return r},"integerDateParser");function RD(e,t){return{...J(e.innerType._def,t),default:e.defaultValue()}}i(RD,"parseDefaultDef");function OD(e,t){return t.effectStrategy==="input"?J(e.schema._def,t):Ze(t)}i(OD,"parseEffectsDef");function AD(e){return{type:"string",enum:Array.from(e.values)}}i(AD,"parseEnumDef");var HK=i(e=>"type"in e&&e.type==="string"?!1:"allOf"in e,"isJsonSchema7AllOfType");function jD(e,t){let r=[J(e.left._def,{...t,currentPath:[...t.currentPath,"allOf","0"]}),J(e.right._def,{...t,currentPath:[...t.currentPath,"allOf","1"]})].filter(s=>!!s),n=t.target==="jsonSchema2019-09"?{unevaluatedProperties:!1}:void 0,o=[];return r.forEach(s=>{if(HK(s))o.push(...s.allOf),s.unevaluatedProperties===void 0&&(n=void 0);else{let a=s;if("additionalProperties"in s&&s.additionalProperties===!1){let{additionalProperties:c,...l}=s;a=l}else n=void 0;o.push(a)}}),o.length?{allOf:o,...n}:void 0}i(jD,"parseIntersectionDef");function DD(e,t){let r=typeof e.value;return r!=="bigint"&&r!=="number"&&r!=="boolean"&&r!=="string"?{type:Array.isArray(e.value)?"array":"object"}:t.target==="openApi3"?{type:r==="bigint"?"integer":r,enum:[e.value]}:{type:r==="bigint"?"integer":r,const:e.value}}i(DD,"parseLiteralDef");var Vb,wr={cuid:/^[cC][^\s-]{8,}$/,cuid2:/^[0-9a-z]+$/,ulid:/^[0-9A-HJKMNP-TV-Z]{26}$/,email:/^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'+\-\.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9\-]*\.)+[a-zA-Z]{2,}$/,emoji:()=>(Vb===void 0&&(Vb=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),Vb),uuid:/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/,ipv4:/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,ipv4Cidr:/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,ipv6:/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,ipv6Cidr:/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,base64:/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,base64url:/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,nanoid:/^[a-zA-Z0-9_-]{21}$/,jwt:/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/};function xm(e,t){let r={type:"string"};if(e.checks)for(let n of e.checks)switch(n.kind){case"min":ue(r,"minLength",typeof r.minLength=="number"?Math.max(r.minLength,n.value):n.value,n.message,t);break;case"max":ue(r,"maxLength",typeof r.maxLength=="number"?Math.min(r.maxLength,n.value):n.value,n.message,t);break;case"email":switch(t.emailStrategy){case"format:email":br(r,"email",n.message,t);break;case"format:idn-email":br(r,"idn-email",n.message,t);break;case"pattern:zod":gt(r,wr.email,n.message,t);break}break;case"url":br(r,"uri",n.message,t);break;case"uuid":br(r,"uuid",n.message,t);break;case"regex":gt(r,n.regex,n.message,t);break;case"cuid":gt(r,wr.cuid,n.message,t);break;case"cuid2":gt(r,wr.cuid2,n.message,t);break;case"startsWith":gt(r,RegExp(`^${Gb(n.value,t)}`),n.message,t);break;case"endsWith":gt(r,RegExp(`${Gb(n.value,t)}$`),n.message,t);break;case"datetime":br(r,"date-time",n.message,t);break;case"date":br(r,"date",n.message,t);break;case"time":br(r,"time",n.message,t);break;case"duration":br(r,"duration",n.message,t);break;case"length":ue(r,"minLength",typeof r.minLength=="number"?Math.max(r.minLength,n.value):n.value,n.message,t),ue(r,"maxLength",typeof r.maxLength=="number"?Math.min(r.maxLength,n.value):n.value,n.message,t);break;case"includes":{gt(r,RegExp(Gb(n.value,t)),n.message,t);break}case"ip":{n.version!=="v6"&&br(r,"ipv4",n.message,t),n.version!=="v4"&&br(r,"ipv6",n.message,t);break}case"base64url":gt(r,wr.base64url,n.message,t);break;case"jwt":gt(r,wr.jwt,n.message,t);break;case"cidr":{n.version!=="v6"&&gt(r,wr.ipv4Cidr,n.message,t),n.version!=="v4"&&gt(r,wr.ipv6Cidr,n.message,t);break}case"emoji":gt(r,wr.emoji(),n.message,t);break;case"ulid":{gt(r,wr.ulid,n.message,t);break}case"base64":{switch(t.base64Strategy){case"format:binary":{br(r,"binary",n.message,t);break}case"contentEncoding:base64":{ue(r,"contentEncoding","base64",n.message,t);break}case"pattern:zod":{gt(r,wr.base64,n.message,t);break}}break}case"nanoid":gt(r,wr.nanoid,n.message,t);case"toLowerCase":case"toUpperCase":case"trim":break;default:}return r}i(xm,"parseStringDef");function Gb(e,t){return t.patternStrategy==="escape"?VK(e):e}i(Gb,"escapeLiteralCheckValue");var BK=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function VK(e){let t="";for(let r=0;r<e.length;r++)BK.has(e[r])||(t+="\\"),t+=e[r];return t}i(VK,"escapeNonAlphaNumeric");function br(e,t,r,n){e.format||e.anyOf?.some(o=>o.format)?(e.anyOf||(e.anyOf=[]),e.format&&(e.anyOf.push({format:e.format,...e.errorMessage&&n.errorMessages&&{errorMessage:{format:e.errorMessage.format}}}),delete e.format,e.errorMessage&&(delete e.errorMessage.format,Object.keys(e.errorMessage).length===0&&delete e.errorMessage)),e.anyOf.push({format:t,...r&&n.errorMessages&&{errorMessage:{format:r}}})):ue(e,"format",t,r,n)}i(br,"addFormat");function gt(e,t,r,n){e.pattern||e.allOf?.some(o=>o.pattern)?(e.allOf||(e.allOf=[]),e.pattern&&(e.allOf.push({pattern:e.pattern,...e.errorMessage&&n.errorMessages&&{errorMessage:{pattern:e.errorMessage.pattern}}}),delete e.pattern,e.errorMessage&&(delete e.errorMessage.pattern,Object.keys(e.errorMessage).length===0&&delete e.errorMessage)),e.allOf.push({pattern:MD(t,n),...r&&n.errorMessages&&{errorMessage:{pattern:r}}})):ue(e,"pattern",MD(t,n),r,n)}i(gt,"addPattern");function MD(e,t){if(!t.applyRegexFlags||!e.flags)return e.source;let r={i:e.flags.includes("i"),m:e.flags.includes("m"),s:e.flags.includes("s")},n=r.i?e.source.toLowerCase():e.source,o="",s=!1,a=!1,c=!1;for(let l=0;l<n.length;l++){if(s){o+=n[l],s=!1;continue}if(r.i){if(a){if(n[l].match(/[a-z]/)){c?(o+=n[l],o+=`${n[l-2]}-${n[l]}`.toUpperCase(),c=!1):n[l+1]==="-"&&n[l+2]?.match(/[a-z]/)?(o+=n[l],c=!0):o+=`${n[l]}${n[l].toUpperCase()}`;continue}}else if(n[l].match(/[a-z]/)){o+=`[${n[l]}${n[l].toUpperCase()}]`;continue}}if(r.m){if(n[l]==="^"){o+=`(^|(?<=[\r
351
+ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let d of this.seen.entries()){let p=d[1];if(t===d[0]){a(d);continue}if(n.external){let h=n.external.registry.get(d[0])?.id;if(t!==d[0]&&h){a(d);continue}}if(this.metadataRegistry.get(d[0])?.id){a(d);continue}if(p.cycle){a(d);continue}if(p.count>1&&n.reused==="ref"){a(d);continue}}let c=i((d,p)=>{let m=this.seen.get(d),h=m.def??m.schema,g={...h};if(m.ref===null)return;let _=m.ref;if(m.ref=null,_){c(_,p);let x=this.seen.get(_).schema;x.$ref&&p.target==="draft-7"?(h.allOf=h.allOf??[],h.allOf.push(x)):(Object.assign(h,x),Object.assign(h,g))}m.isParent||this.override({zodSchema:d,jsonSchema:h,path:m.path??[]})},"flattenRef");for(let d of[...this.seen.entries()].reverse())c(d[0],{target:this.target});let l={};if(this.target==="draft-2020-12"?l.$schema="https://json-schema.org/draft/2020-12/schema":this.target==="draft-7"?l.$schema="http://json-schema.org/draft-07/schema#":console.warn(`Invalid target: ${this.target}`),n.external?.uri){let d=n.external.registry.get(t)?.id;if(!d)throw new Error("Schema is missing an `id` property");l.$id=n.external.uri(d)}Object.assign(l,o.def);let u=n.external?.defs??{};for(let d of this.seen.entries()){let p=d[1];p.def&&p.defId&&(u[p.defId]=p.def)}n.external||Object.keys(u).length>0&&(this.target==="draft-2020-12"?l.$defs=u:l.definitions=u);try{return JSON.parse(JSON.stringify(l))}catch{throw new Error("Error converting schema to JSON.")}}};i(US,"JSONSchemaGenerator");var Hh=US;function FS(e,t){if(e instanceof Gu){let n=new Hh(t),o={};for(let c of e._idmap.entries()){let[l,u]=c;n.process(u)}let s={},a={registry:e,uri:t?.uri,defs:o};for(let c of e._idmap.entries()){let[l,u]=c;s[l]=n.emit(u,{...t,external:a})}if(Object.keys(o).length>0){let c=n.target==="draft-2020-12"?"$defs":"definitions";s.__shared={[c]:o}}return{schemas:s}}let r=new Hh(t);return r.process(e),r.emit(e,t)}i(FS,"toJSONSchema");function Ge(e,t){let r=t??{seen:new Set};if(r.seen.has(e))return!1;r.seen.add(e);let o=e._zod.def;switch(o.type){case"string":case"number":case"bigint":case"boolean":case"date":case"symbol":case"undefined":case"null":case"any":case"unknown":case"never":case"void":case"literal":case"enum":case"nan":case"file":case"template_literal":return!1;case"array":return Ge(o.element,r);case"object":{for(let s in o.shape)if(Ge(o.shape[s],r))return!0;return!1}case"union":{for(let s of o.options)if(Ge(s,r))return!0;return!1}case"intersection":return Ge(o.left,r)||Ge(o.right,r);case"tuple":{for(let s of o.items)if(Ge(s,r))return!0;return!!(o.rest&&Ge(o.rest,r))}case"record":return Ge(o.keyType,r)||Ge(o.valueType,r);case"map":return Ge(o.keyType,r)||Ge(o.valueType,r);case"set":return Ge(o.valueType,r);case"promise":case"optional":case"nonoptional":case"nullable":case"readonly":return Ge(o.innerType,r);case"lazy":return Ge(o.getter(),r);case"default":return Ge(o.innerType,r);case"prefault":return Ge(o.innerType,r);case"custom":return!1;case"transform":return!0;case"pipe":return Ge(o.in,r)||Ge(o.out,r);case"success":return!1;case"catch":return!1;default:}throw new Error(`Unknown schema type: ${o.type}`)}i(Ge,"isTransforming");var _X=T("ZodMiniType",(e,t)=>{if(!e._zod)throw new Error("Uninitialized schema in ZodMiniType.");Se.init(e,t),e.def=t,e.parse=(r,n)=>r0(e,r,n,{callee:e.parse}),e.safeParse=(r,n)=>Qs(e,r,n),e.parseAsync=async(r,n)=>o0(e,r,n,{callee:e.parseAsync}),e.safeParseAsync=async(r,n)=>ei(e,r,n),e.check=(...r)=>e.clone({...t,checks:[...t.checks??[],...r.map(n=>typeof n=="function"?{_zod:{check:n,def:{check:"custom"},onattach:[]}}:n)]}),e.clone=(r,n)=>Gt(e,r,n),e.brand=()=>e,e.register=(r,n)=>(r.add(e,n),e)});var vX=T("ZodMiniObject",(e,t)=>{Dh.init(e,t),_X.init(e,t),ue.defineLazy(e,"shape",()=>t.shape)});function qS(e,t){let r={type:"object",get shape(){return ue.assignProp(this,"shape",{...e}),this.shape},...ue.normalizeParams(t)};return new vX(r)}i(qS,"object");function rn(e){return!!e._zod}i(rn,"isZ4Schema");function ni(e){let t=Object.values(e);if(t.length===0)return qS({});let r=t.every(rn),n=t.every(o=>!rn(o));if(r)return qS(e);if(n)return hb(e);throw new Error("Mixed Zod versions detected in object shape.")}i(ni,"objectFromShape");function So(e,t){return rn(e)?Qs(e,t):e.safeParse(t)}i(So,"safeParse");async function Vh(e,t){return rn(e)?await ei(e,t):await e.safeParseAsync(t)}i(Vh,"safeParseAsync");function ko(e){if(!e)return;let t;if(rn(e)?t=e._zod?.def?.shape:t=e.shape,!!t){if(typeof t=="function")try{return t()}catch{return}return t}}i(ko,"getObjectShape");function Ja(e){if(e){if(typeof e=="object"){let t=e,r=e;if(!t._def&&!r._zod){let n=Object.values(e);if(n.length>0&&n.every(o=>typeof o=="object"&&o!==null&&(o._def!==void 0||o._zod!==void 0||typeof o.parse=="function")))return ni(e)}}if(rn(e)){let r=e._zod?.def;if(r&&(r.type==="object"||r.shape!==void 0))return e}else if(e.shape!==void 0)return e}}i(Ja,"normalizeObjectSchema");function bX(e){return e.length===0?"object root":e.reduce((t,r,n)=>n===0?String(r):typeof r=="number"?`${t}[${r}]`:`${t}.${r}`,"")}i(bX,"getDotPath");function Gh(e){if(e&&typeof e=="object"){if("issues"in e&&Array.isArray(e.issues)&&e.issues.length>0)return e.issues.map(t=>t.path?.length?`${t.message} at ${bX(t.path)}`:t.message).join(`
352
+ `);if("message"in e&&typeof e.message=="string")return e.message;try{return JSON.stringify(e)}catch{return String(e)}}return String(e)}i(Gh,"getParseErrorMessage");function YZ(e){return e.description}i(YZ,"getSchemaDescription");function XZ(e){if(rn(e))return e._zod?.def?.type==="optional";let t=e;return typeof e.isOptional=="function"?e.isOptional():t._def?.typeName==="ZodOptional"}i(XZ,"isSchemaOptional");function Ka(e){if(rn(e)){let s=e._zod?.def;if(s){if(s.value!==void 0)return s.value;if(Array.isArray(s.values)&&s.values.length>0)return s.values[0]}}let r=e._def;if(r){if(r.value!==void 0)return r.value;if(Array.isArray(r.values)&&r.values.length>0)return r.values[0]}let n=e.value;if(n!==void 0)return n}i(Ka,"getLiteralValue");var Ku={};C(Ku,{ZodISODate:()=>eL,ZodISODateTime:()=>QZ,ZodISODuration:()=>rL,ZodISOTime:()=>tL,date:()=>HS,datetime:()=>BS,duration:()=>GS,time:()=>VS});var QZ=T("ZodISODateTime",(e,t)=>{ZZ.init(e,t),Ze.init(e,t)});function BS(e){return HZ(QZ,e)}i(BS,"datetime");var eL=T("ZodISODate",(e,t)=>{LZ.init(e,t),Ze.init(e,t)});function HS(e){return VZ(eL,e)}i(HS,"date");var tL=T("ZodISOTime",(e,t)=>{FZ.init(e,t),Ze.init(e,t)});function VS(e){return GZ(tL,e)}i(VS,"time");var rL=T("ZodISODuration",(e,t)=>{UZ.init(e,t),Ze.init(e,t)});function GS(e){return WZ(rL,e)}i(GS,"duration");var nL=i((e,t)=>{Ph.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:r=>e0(e,r)},flatten:{value:r=>Qb(e,r)},addIssue:{value:r=>e.issues.push(r)},addIssues:{value:r=>e.issues.push(...r)},isEmpty:{get(){return e.issues.length===0}}})},"initializer"),x4e=T("ZodError",nL),Yu=T("ZodError",nL,{Parent:Error});var oL=t0(Yu),sL=n0(Yu),iL=s0(Yu),aL=i0(Yu);var qe=T("ZodType",(e,t)=>(Se.init(e,t),e.def=t,Object.defineProperty(e,"_def",{value:t}),e.check=(...r)=>e.clone({...t,checks:[...t.checks??[],...r.map(n=>typeof n=="function"?{_zod:{check:n,def:{check:"custom"},onattach:[]}}:n)]}),e.clone=(r,n)=>Gt(e,r,n),e.brand=()=>e,e.register=(r,n)=>(r.add(e,n),e),e.parse=(r,n)=>oL(e,r,n,{callee:e.parse}),e.safeParse=(r,n)=>iL(e,r,n),e.parseAsync=async(r,n)=>sL(e,r,n,{callee:e.parseAsync}),e.safeParseAsync=async(r,n)=>aL(e,r,n),e.spa=e.safeParseAsync,e.refine=(r,n)=>e.check(xQ(r,n)),e.superRefine=r=>e.check(_Q(r)),e.overwrite=r=>e.check(ti(r)),e.optional=()=>Fe(e),e.nullable=()=>uL(e),e.nullish=()=>Fe(uL(e)),e.nonoptional=r=>dQ(e,r),e.array=()=>de(e),e.or=r=>Ae([e,r]),e.and=r=>Jh(e,r),e.transform=r=>JS(e,gL(r)),e.default=r=>cQ(e,r),e.prefault=r=>uQ(e,r),e.catch=r=>fQ(e,r),e.pipe=r=>JS(e,r),e.readonly=()=>gQ(e),e.describe=r=>{let n=e.clone();return bo.add(n,{description:r}),n},Object.defineProperty(e,"description",{get(){return bo.get(e)?.description},configurable:!0}),e.meta=(...r)=>{if(r.length===0)return bo.get(e);let n=e.clone();return bo.add(n,r[0]),n},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e)),dL=T("_ZodString",(e,t)=>{Vu.init(e,t),qe.init(e,t);let r=e._zod.bag;e.format=r.format??null,e.minLength=r.minimum??null,e.maxLength=r.maximum??null,e.regex=(...n)=>e.check(zS(...n)),e.includes=(...n)=>e.check(PS(...n)),e.startsWith=(...n)=>e.check(OS(...n)),e.endsWith=(...n)=>e.check(AS(...n)),e.min=(...n)=>e.check(Wa(...n)),e.max=(...n)=>e.check(qh(...n)),e.length=(...n)=>e.check(Bh(...n)),e.nonempty=(...n)=>e.check(Wa(1,...n)),e.lowercase=n=>e.check(CS(n)),e.uppercase=n=>e.check(IS(n)),e.trim=()=>e.check(jS()),e.normalize=(...n)=>e.check(RS(...n)),e.toLowerCase=()=>e.check(DS()),e.toUpperCase=()=>e.check(MS())}),CX=T("ZodString",(e,t)=>{Vu.init(e,t),dL.init(e,t),e.email=r=>e.check(rS(IX,r)),e.url=r=>e.check(aS(PX,r)),e.jwt=r=>e.check(bS(GX,r)),e.emoji=r=>e.check(cS(OX,r)),e.guid=r=>e.check(Zh(cL,r)),e.uuid=r=>e.check(nS(Wh,r)),e.uuidv4=r=>e.check(oS(Wh,r)),e.uuidv6=r=>e.check(sS(Wh,r)),e.uuidv7=r=>e.check(iS(Wh,r)),e.nanoid=r=>e.check(lS(AX,r)),e.guid=r=>e.check(Zh(cL,r)),e.cuid=r=>e.check(uS(RX,r)),e.cuid2=r=>e.check(dS(jX,r)),e.ulid=r=>e.check(pS(DX,r)),e.base64=r=>e.check(_S(BX,r)),e.base64url=r=>e.check(vS(HX,r)),e.xid=r=>e.check(fS(MX,r)),e.ksuid=r=>e.check(mS(ZX,r)),e.ipv4=r=>e.check(hS(LX,r)),e.ipv6=r=>e.check(gS(FX,r)),e.cidrv4=r=>e.check(yS(UX,r)),e.cidrv6=r=>e.check(xS(qX,r)),e.e164=r=>e.check(wS(VX,r)),e.datetime=r=>e.check(BS(r)),e.date=r=>e.check(HS(r)),e.time=r=>e.check(VS(r)),e.duration=r=>e.check(GS(r))});function N(e){return tS(CX,e)}i(N,"string");var Ze=T("ZodStringFormat",(e,t)=>{Ce.init(e,t),dL.init(e,t)}),IX=T("ZodEmail",(e,t)=>{h0.init(e,t),Ze.init(e,t)});var cL=T("ZodGUID",(e,t)=>{f0.init(e,t),Ze.init(e,t)});var Wh=T("ZodUUID",(e,t)=>{m0.init(e,t),Ze.init(e,t)});var PX=T("ZodURL",(e,t)=>{g0.init(e,t),Ze.init(e,t)});var OX=T("ZodEmoji",(e,t)=>{y0.init(e,t),Ze.init(e,t)});var AX=T("ZodNanoID",(e,t)=>{x0.init(e,t),Ze.init(e,t)});var RX=T("ZodCUID",(e,t)=>{_0.init(e,t),Ze.init(e,t)});var jX=T("ZodCUID2",(e,t)=>{v0.init(e,t),Ze.init(e,t)});var DX=T("ZodULID",(e,t)=>{w0.init(e,t),Ze.init(e,t)});var MX=T("ZodXID",(e,t)=>{b0.init(e,t),Ze.init(e,t)});var ZX=T("ZodKSUID",(e,t)=>{S0.init(e,t),Ze.init(e,t)});var LX=T("ZodIPv4",(e,t)=>{k0.init(e,t),Ze.init(e,t)});var FX=T("ZodIPv6",(e,t)=>{$0.init(e,t),Ze.init(e,t)});var UX=T("ZodCIDRv4",(e,t)=>{E0.init(e,t),Ze.init(e,t)});var qX=T("ZodCIDRv6",(e,t)=>{N0.init(e,t),Ze.init(e,t)});var BX=T("ZodBase64",(e,t)=>{T0.init(e,t),Ze.init(e,t)});var HX=T("ZodBase64URL",(e,t)=>{z0.init(e,t),Ze.init(e,t)});var VX=T("ZodE164",(e,t)=>{C0.init(e,t),Ze.init(e,t)});var GX=T("ZodJWT",(e,t)=>{I0.init(e,t),Ze.init(e,t)});var pL=T("ZodNumber",(e,t)=>{jh.init(e,t),qe.init(e,t),e.gt=(n,o)=>e.check(Fh(n,o)),e.gte=(n,o)=>e.check(Ju(n,o)),e.min=(n,o)=>e.check(Ju(n,o)),e.lt=(n,o)=>e.check(Lh(n,o)),e.lte=(n,o)=>e.check(Wu(n,o)),e.max=(n,o)=>e.check(Wu(n,o)),e.int=n=>e.check(lL(n)),e.safe=n=>e.check(lL(n)),e.positive=n=>e.check(Fh(0,n)),e.nonnegative=n=>e.check(Ju(0,n)),e.negative=n=>e.check(Lh(0,n)),e.nonpositive=n=>e.check(Wu(0,n)),e.multipleOf=(n,o)=>e.check(Uh(n,o)),e.step=(n,o)=>e.check(Uh(n,o)),e.finite=()=>e;let r=e._zod.bag;e.minValue=Math.max(r.minimum??Number.NEGATIVE_INFINITY,r.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(r.maximum??Number.POSITIVE_INFINITY,r.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(r.format??"").includes("int")||Number.isSafeInteger(r.multipleOf??.5),e.isFinite=!0,e.format=r.format??null});function we(e){return SS(pL,e)}i(we,"number");var WX=T("ZodNumberFormat",(e,t)=>{P0.init(e,t),pL.init(e,t)});function lL(e){return kS(WX,e)}i(lL,"int");var JX=T("ZodBoolean",(e,t)=>{O0.init(e,t),qe.init(e,t)});function Xe(e){return $S(JX,e)}i(Xe,"boolean");var KX=T("ZodNull",(e,t)=>{A0.init(e,t),qe.init(e,t)});function fL(e){return ES(KX,e)}i(fL,"_null");var YX=T("ZodUnknown",(e,t)=>{R0.init(e,t),qe.init(e,t)});function Le(){return NS(YX)}i(Le,"unknown");var XX=T("ZodNever",(e,t)=>{j0.init(e,t),qe.init(e,t)});function QX(e){return TS(XX,e)}i(QX,"never");var eQ=T("ZodArray",(e,t)=>{D0.init(e,t),qe.init(e,t),e.element=t.element,e.min=(r,n)=>e.check(Wa(r,n)),e.nonempty=r=>e.check(Wa(1,r)),e.max=(r,n)=>e.check(qh(r,n)),e.length=(r,n)=>e.check(Bh(r,n)),e.unwrap=()=>e.element});function de(e,t){return JZ(eQ,e,t)}i(de,"array");var mL=T("ZodObject",(e,t)=>{Dh.init(e,t),qe.init(e,t),ue.defineLazy(e,"shape",()=>t.shape),e.keyof=()=>Pt(Object.keys(e._zod.def.shape)),e.catchall=r=>e.clone({...e._zod.def,catchall:r}),e.passthrough=()=>e.clone({...e._zod.def,catchall:Le()}),e.loose=()=>e.clone({...e._zod.def,catchall:Le()}),e.strict=()=>e.clone({...e._zod.def,catchall:QX()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=r=>ue.extend(e,r),e.merge=r=>ue.merge(e,r),e.pick=r=>ue.pick(e,r),e.omit=r=>ue.omit(e,r),e.partial=(...r)=>ue.partial(yL,e,r[0]),e.required=(...r)=>ue.required(xL,e,r[0])});function q(e,t){let r={type:"object",get shape(){return ue.assignProp(this,"shape",{...e}),this.shape},...ue.normalizeParams(t)};return new mL(r)}i(q,"object");function wt(e,t){return new mL({type:"object",get shape(){return ue.assignProp(this,"shape",{...e}),this.shape},catchall:Le(),...ue.normalizeParams(t)})}i(wt,"looseObject");var hL=T("ZodUnion",(e,t)=>{Mh.init(e,t),qe.init(e,t),e.options=t.options});function Ae(e,t){return new hL({type:"union",options:e,...ue.normalizeParams(t)})}i(Ae,"union");var tQ=T("ZodDiscriminatedUnion",(e,t)=>{hL.init(e,t),M0.init(e,t)});function KS(e,t,r){return new tQ({type:"union",options:t,discriminator:e,...ue.normalizeParams(r)})}i(KS,"discriminatedUnion");var rQ=T("ZodIntersection",(e,t)=>{Z0.init(e,t),qe.init(e,t)});function Jh(e,t){return new rQ({type:"intersection",left:e,right:t})}i(Jh,"intersection");var nQ=T("ZodRecord",(e,t)=>{L0.init(e,t),qe.init(e,t),e.keyType=t.keyType,e.valueType=t.valueType});function Ie(e,t,r){return new nQ({type:"record",keyType:e,valueType:t,...ue.normalizeParams(r)})}i(Ie,"record");var WS=T("ZodEnum",(e,t)=>{F0.init(e,t),qe.init(e,t),e.enum=t.entries,e.options=Object.values(t.entries);let r=new Set(Object.keys(t.entries));e.extract=(n,o)=>{let s={};for(let a of n)if(r.has(a))s[a]=t.entries[a];else throw new Error(`Key ${a} not found in enum`);return new WS({...t,checks:[],...ue.normalizeParams(o),entries:s})},e.exclude=(n,o)=>{let s={...t.entries};for(let a of n)if(r.has(a))delete s[a];else throw new Error(`Key ${a} not found in enum`);return new WS({...t,checks:[],...ue.normalizeParams(o),entries:s})}});function Pt(e,t){let r=Array.isArray(e)?Object.fromEntries(e.map(n=>[n,n])):e;return new WS({type:"enum",entries:r,...ue.normalizeParams(t)})}i(Pt,"_enum");var oQ=T("ZodLiteral",(e,t)=>{U0.init(e,t),qe.init(e,t),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function G(e,t){return new oQ({type:"literal",values:Array.isArray(e)?e:[e],...ue.normalizeParams(t)})}i(G,"literal");var sQ=T("ZodTransform",(e,t)=>{q0.init(e,t),qe.init(e,t),e._zod.parse=(r,n)=>{r.addIssue=s=>{if(typeof s=="string")r.issues.push(ue.issue(s,r.value,t));else{let a=s;a.fatal&&(a.continue=!1),a.code??(a.code="custom"),a.input??(a.input=r.value),a.inst??(a.inst=e),a.continue??(a.continue=!0),r.issues.push(ue.issue(a))}};let o=t.transform(r.value,r);return o instanceof Promise?o.then(s=>(r.value=s,r)):(r.value=o,r)}});function gL(e){return new sQ({type:"transform",transform:e})}i(gL,"transform");var yL=T("ZodOptional",(e,t)=>{B0.init(e,t),qe.init(e,t),e.unwrap=()=>e._zod.def.innerType});function Fe(e){return new yL({type:"optional",innerType:e})}i(Fe,"optional");var iQ=T("ZodNullable",(e,t)=>{H0.init(e,t),qe.init(e,t),e.unwrap=()=>e._zod.def.innerType});function uL(e){return new iQ({type:"nullable",innerType:e})}i(uL,"nullable");var aQ=T("ZodDefault",(e,t)=>{V0.init(e,t),qe.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function cQ(e,t){return new aQ({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():t}})}i(cQ,"_default");var lQ=T("ZodPrefault",(e,t)=>{G0.init(e,t),qe.init(e,t),e.unwrap=()=>e._zod.def.innerType});function uQ(e,t){return new lQ({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():t}})}i(uQ,"prefault");var xL=T("ZodNonOptional",(e,t)=>{W0.init(e,t),qe.init(e,t),e.unwrap=()=>e._zod.def.innerType});function dQ(e,t){return new xL({type:"nonoptional",innerType:e,...ue.normalizeParams(t)})}i(dQ,"nonoptional");var pQ=T("ZodCatch",(e,t)=>{J0.init(e,t),qe.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function fQ(e,t){return new pQ({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}i(fQ,"_catch");var mQ=T("ZodPipe",(e,t)=>{K0.init(e,t),qe.init(e,t),e.in=t.in,e.out=t.out});function JS(e,t){return new mQ({type:"pipe",in:e,out:t})}i(JS,"pipe");var hQ=T("ZodReadonly",(e,t)=>{Y0.init(e,t),qe.init(e,t)});function gQ(e){return new hQ({type:"readonly",innerType:e})}i(gQ,"readonly");var _L=T("ZodCustom",(e,t)=>{X0.init(e,t),qe.init(e,t)});function yQ(e){let t=new ot({check:"custom"});return t._zod.check=e,t}i(yQ,"check");function vL(e,t){return ZS(_L,e??(()=>!0),t)}i(vL,"custom");function xQ(e,t={}){return LS(_L,e,t)}i(xQ,"refine");function _Q(e){let t=yQ(r=>(r.addIssue=n=>{if(typeof n=="string")r.issues.push(ue.issue(n,r.value,t._zod.def));else{let o=n;o.fatal&&(o.continue=!1),o.code??(o.code="custom"),o.input??(o.input=r.value),o.inst??(o.inst=t),o.continue??(o.continue=!t._zod.def.abort),r.issues.push(ue.issue(o))}},e(r.value,r)));return t}i(_Q,"superRefine");function YS(e,t){return JS(gL(e),t)}i(YS,"preprocess");Vt(Q0());var QS="2025-11-25";var wL=[QS,"2025-06-18","2025-03-26","2024-11-05","2024-10-07"],$o="io.modelcontextprotocol/related-task",Xh="2.0",We=vL(e=>e!==null&&(typeof e=="object"||typeof e=="function")),bL=Ae([N(),we().int()]),SL=N(),A4e=wt({ttl:we().optional(),pollInterval:we().optional()}),vQ=q({ttl:we().optional()}),wQ=q({taskId:N()}),ek=wt({progressToken:bL.optional(),[$o]:wQ.optional()}),Wt=q({_meta:ek.optional()}),Xu=Wt.extend({task:vQ.optional()}),kL=i(e=>Xu.safeParse(e).success,"isTaskAugmentedRequestParams"),st=q({method:N(),params:Wt.loose().optional()}),dr=q({_meta:ek.optional()}),pr=q({method:N(),params:dr.loose().optional()}),it=wt({_meta:ek.optional()}),Qh=Ae([N(),we().int()]),$L=q({jsonrpc:G(Xh),id:Qh,...st.shape}).strict(),tk=i(e=>$L.safeParse(e).success,"isJSONRPCRequest"),EL=q({jsonrpc:G(Xh),...pr.shape}).strict(),NL=i(e=>EL.safeParse(e).success,"isJSONRPCNotification"),rk=q({jsonrpc:G(Xh),id:Qh,result:it}).strict(),Qu=i(e=>rk.safeParse(e).success,"isJSONRPCResultResponse");var K;(function(e){e[e.ConnectionClosed=-32e3]="ConnectionClosed",e[e.RequestTimeout=-32001]="RequestTimeout",e[e.ParseError=-32700]="ParseError",e[e.InvalidRequest=-32600]="InvalidRequest",e[e.MethodNotFound=-32601]="MethodNotFound",e[e.InvalidParams=-32602]="InvalidParams",e[e.InternalError=-32603]="InternalError",e[e.UrlElicitationRequired=-32042]="UrlElicitationRequired"})(K||(K={}));var nk=q({jsonrpc:G(Xh),id:Qh.optional(),error:q({code:we().int(),message:N(),data:Le().optional()})}).strict();var TL=i(e=>nk.safeParse(e).success,"isJSONRPCErrorResponse");var zL=Ae([$L,EL,rk,nk]),R4e=Ae([rk,nk]),eg=it.strict(),bQ=dr.extend({requestId:Qh.optional(),reason:N().optional()}),tg=pr.extend({method:G("notifications/cancelled"),params:bQ}),SQ=q({src:N(),mimeType:N().optional(),sizes:de(N()).optional(),theme:Pt(["light","dark"]).optional()}),ed=q({icons:de(SQ).optional()}),Ya=q({name:N(),title:N().optional()}),CL=Ya.extend({...Ya.shape,...ed.shape,version:N(),websiteUrl:N().optional(),description:N().optional()}),kQ=Jh(q({applyDefaults:Xe().optional()}),Ie(N(),Le())),$Q=YS(e=>e&&typeof e=="object"&&!Array.isArray(e)&&Object.keys(e).length===0?{form:{}}:e,Jh(q({form:kQ.optional(),url:We.optional()}),Ie(N(),Le()).optional())),EQ=wt({list:We.optional(),cancel:We.optional(),requests:wt({sampling:wt({createMessage:We.optional()}).optional(),elicitation:wt({create:We.optional()}).optional()}).optional()}),NQ=wt({list:We.optional(),cancel:We.optional(),requests:wt({tools:wt({call:We.optional()}).optional()}).optional()}),TQ=q({experimental:Ie(N(),We).optional(),sampling:q({context:We.optional(),tools:We.optional()}).optional(),elicitation:$Q.optional(),roots:q({listChanged:Xe().optional()}).optional(),tasks:EQ.optional(),extensions:Ie(N(),We).optional()}),zQ=Wt.extend({protocolVersion:N(),capabilities:TQ,clientInfo:CL}),ok=st.extend({method:G("initialize"),params:zQ});var CQ=q({experimental:Ie(N(),We).optional(),logging:We.optional(),completions:We.optional(),prompts:q({listChanged:Xe().optional()}).optional(),resources:q({subscribe:Xe().optional(),listChanged:Xe().optional()}).optional(),tools:q({listChanged:Xe().optional()}).optional(),tasks:NQ.optional(),extensions:Ie(N(),We).optional()}),IQ=it.extend({protocolVersion:N(),capabilities:CQ,serverInfo:CL,instructions:N().optional()}),sk=pr.extend({method:G("notifications/initialized"),params:dr.optional()});var rg=st.extend({method:G("ping"),params:Wt.optional()}),PQ=q({progress:we(),total:Fe(we()),message:Fe(N())}),OQ=q({...dr.shape,...PQ.shape,progressToken:bL}),ng=pr.extend({method:G("notifications/progress"),params:OQ}),AQ=Wt.extend({cursor:SL.optional()}),td=st.extend({params:AQ.optional()}),rd=it.extend({nextCursor:SL.optional()}),RQ=Pt(["working","input_required","completed","failed","cancelled"]),nd=q({taskId:N(),status:RQ,ttl:Ae([we(),fL()]),createdAt:N(),lastUpdatedAt:N(),pollInterval:Fe(we()),statusMessage:Fe(N())}),Xa=it.extend({task:nd}),jQ=dr.merge(nd),od=pr.extend({method:G("notifications/tasks/status"),params:jQ}),og=st.extend({method:G("tasks/get"),params:Wt.extend({taskId:N()})}),sg=it.merge(nd),ig=st.extend({method:G("tasks/result"),params:Wt.extend({taskId:N()})}),j4e=it.loose(),ag=td.extend({method:G("tasks/list")}),cg=rd.extend({tasks:de(nd)}),lg=st.extend({method:G("tasks/cancel"),params:Wt.extend({taskId:N()})}),IL=it.merge(nd),PL=q({uri:N(),mimeType:Fe(N()),_meta:Ie(N(),Le()).optional()}),OL=PL.extend({text:N()}),ik=N().refine(e=>{try{return atob(e),!0}catch{return!1}},{message:"Invalid Base64 string"}),AL=PL.extend({blob:ik}),sd=Pt(["user","assistant"]),Qa=q({audience:de(sd).optional(),priority:we().min(0).max(1).optional(),lastModified:Ku.datetime({offset:!0}).optional()}),RL=q({...Ya.shape,...ed.shape,uri:N(),description:Fe(N()),mimeType:Fe(N()),size:Fe(we()),annotations:Qa.optional(),_meta:Fe(wt({}))}),DQ=q({...Ya.shape,...ed.shape,uriTemplate:N(),description:Fe(N()),mimeType:Fe(N()),annotations:Qa.optional(),_meta:Fe(wt({}))}),ug=td.extend({method:G("resources/list")}),MQ=rd.extend({resources:de(RL)}),dg=td.extend({method:G("resources/templates/list")}),ZQ=rd.extend({resourceTemplates:de(DQ)}),ak=Wt.extend({uri:N()}),LQ=ak,pg=st.extend({method:G("resources/read"),params:LQ}),FQ=it.extend({contents:de(Ae([OL,AL]))}),UQ=pr.extend({method:G("notifications/resources/list_changed"),params:dr.optional()}),qQ=ak,BQ=st.extend({method:G("resources/subscribe"),params:qQ}),HQ=ak,VQ=st.extend({method:G("resources/unsubscribe"),params:HQ}),GQ=dr.extend({uri:N()}),WQ=pr.extend({method:G("notifications/resources/updated"),params:GQ}),JQ=q({name:N(),description:Fe(N()),required:Fe(Xe())}),KQ=q({...Ya.shape,...ed.shape,description:Fe(N()),arguments:Fe(de(JQ)),_meta:Fe(wt({}))}),fg=td.extend({method:G("prompts/list")}),YQ=rd.extend({prompts:de(KQ)}),XQ=Wt.extend({name:N(),arguments:Ie(N(),N()).optional()}),mg=st.extend({method:G("prompts/get"),params:XQ}),ck=q({type:G("text"),text:N(),annotations:Qa.optional(),_meta:Ie(N(),Le()).optional()}),lk=q({type:G("image"),data:ik,mimeType:N(),annotations:Qa.optional(),_meta:Ie(N(),Le()).optional()}),uk=q({type:G("audio"),data:ik,mimeType:N(),annotations:Qa.optional(),_meta:Ie(N(),Le()).optional()}),QQ=q({type:G("tool_use"),name:N(),id:N(),input:Ie(N(),Le()),_meta:Ie(N(),Le()).optional()}),eee=q({type:G("resource"),resource:Ae([OL,AL]),annotations:Qa.optional(),_meta:Ie(N(),Le()).optional()}),tee=RL.extend({type:G("resource_link")}),dk=Ae([ck,lk,uk,tee,eee]),ree=q({role:sd,content:dk}),nee=it.extend({description:N().optional(),messages:de(ree)}),oee=pr.extend({method:G("notifications/prompts/list_changed"),params:dr.optional()}),see=q({title:N().optional(),readOnlyHint:Xe().optional(),destructiveHint:Xe().optional(),idempotentHint:Xe().optional(),openWorldHint:Xe().optional()}),iee=q({taskSupport:Pt(["required","optional","forbidden"]).optional()}),jL=q({...Ya.shape,...ed.shape,description:N().optional(),inputSchema:q({type:G("object"),properties:Ie(N(),We).optional(),required:de(N()).optional()}).catchall(Le()),outputSchema:q({type:G("object"),properties:Ie(N(),We).optional(),required:de(N()).optional()}).catchall(Le()).optional(),annotations:see.optional(),execution:iee.optional(),_meta:Ie(N(),Le()).optional()}),hg=td.extend({method:G("tools/list")}),aee=rd.extend({tools:de(jL)}),gg=it.extend({content:de(dk).default([]),structuredContent:Ie(N(),Le()).optional(),isError:Xe().optional()}),D4e=gg.or(it.extend({toolResult:Le()})),cee=Xu.extend({name:N(),arguments:Ie(N(),Le()).optional()}),ec=st.extend({method:G("tools/call"),params:cee}),lee=pr.extend({method:G("notifications/tools/list_changed"),params:dr.optional()}),M4e=q({autoRefresh:Xe().default(!0),debounceMs:we().int().nonnegative().default(300)}),id=Pt(["debug","info","notice","warning","error","critical","alert","emergency"]),uee=Wt.extend({level:id}),pk=st.extend({method:G("logging/setLevel"),params:uee}),dee=dr.extend({level:id,logger:N().optional(),data:Le()}),pee=pr.extend({method:G("notifications/message"),params:dee}),fee=q({name:N().optional()}),mee=q({hints:de(fee).optional(),costPriority:we().min(0).max(1).optional(),speedPriority:we().min(0).max(1).optional(),intelligencePriority:we().min(0).max(1).optional()}),hee=q({mode:Pt(["auto","required","none"]).optional()}),gee=q({type:G("tool_result"),toolUseId:N().describe("The unique identifier for the corresponding tool call."),content:de(dk).default([]),structuredContent:q({}).loose().optional(),isError:Xe().optional(),_meta:Ie(N(),Le()).optional()}),yee=KS("type",[ck,lk,uk]),Kh=KS("type",[ck,lk,uk,QQ,gee]),xee=q({role:sd,content:Ae([Kh,de(Kh)]),_meta:Ie(N(),Le()).optional()}),_ee=Xu.extend({messages:de(xee),modelPreferences:mee.optional(),systemPrompt:N().optional(),includeContext:Pt(["none","thisServer","allServers"]).optional(),temperature:we().optional(),maxTokens:we().int(),stopSequences:de(N()).optional(),metadata:We.optional(),tools:de(jL).optional(),toolChoice:hee.optional()}),vee=st.extend({method:G("sampling/createMessage"),params:_ee}),ad=it.extend({model:N(),stopReason:Fe(Pt(["endTurn","stopSequence","maxTokens"]).or(N())),role:sd,content:yee}),fk=it.extend({model:N(),stopReason:Fe(Pt(["endTurn","stopSequence","maxTokens","toolUse"]).or(N())),role:sd,content:Ae([Kh,de(Kh)])}),wee=q({type:G("boolean"),title:N().optional(),description:N().optional(),default:Xe().optional()}),bee=q({type:G("string"),title:N().optional(),description:N().optional(),minLength:we().optional(),maxLength:we().optional(),format:Pt(["email","uri","date","date-time"]).optional(),default:N().optional()}),See=q({type:Pt(["number","integer"]),title:N().optional(),description:N().optional(),minimum:we().optional(),maximum:we().optional(),default:we().optional()}),kee=q({type:G("string"),title:N().optional(),description:N().optional(),enum:de(N()),default:N().optional()}),$ee=q({type:G("string"),title:N().optional(),description:N().optional(),oneOf:de(q({const:N(),title:N()})),default:N().optional()}),Eee=q({type:G("string"),title:N().optional(),description:N().optional(),enum:de(N()),enumNames:de(N()).optional(),default:N().optional()}),Nee=Ae([kee,$ee]),Tee=q({type:G("array"),title:N().optional(),description:N().optional(),minItems:we().optional(),maxItems:we().optional(),items:q({type:G("string"),enum:de(N())}),default:de(N()).optional()}),zee=q({type:G("array"),title:N().optional(),description:N().optional(),minItems:we().optional(),maxItems:we().optional(),items:q({anyOf:de(q({const:N(),title:N()}))}),default:de(N()).optional()}),Cee=Ae([Tee,zee]),Iee=Ae([Eee,Nee,Cee]),Pee=Ae([Iee,wee,bee,See]),Oee=Xu.extend({mode:G("form").optional(),message:N(),requestedSchema:q({type:G("object"),properties:Ie(N(),Pee),required:de(N()).optional()})}),Aee=Xu.extend({mode:G("url"),message:N(),elicitationId:N(),url:N().url()}),Ree=Ae([Oee,Aee]),jee=st.extend({method:G("elicitation/create"),params:Ree}),Dee=dr.extend({elicitationId:N()}),Mee=pr.extend({method:G("notifications/elicitation/complete"),params:Dee}),tc=it.extend({action:Pt(["accept","decline","cancel"]),content:YS(e=>e===null?void 0:e,Ie(N(),Ae([N(),we(),Xe(),de(N())])).optional())}),Zee=q({type:G("ref/resource"),uri:N()});var Lee=q({type:G("ref/prompt"),name:N()}),Fee=Wt.extend({ref:Ae([Lee,Zee]),argument:q({name:N(),value:N()}),context:q({arguments:Ie(N(),N()).optional()}).optional()}),yg=st.extend({method:G("completion/complete"),params:Fee});function DL(e){if(e.params.ref.type!=="ref/prompt")throw new TypeError(`Expected CompleteRequestPrompt, but got ${e.params.ref.type}`)}i(DL,"assertCompleteRequestPrompt");function ML(e){if(e.params.ref.type!=="ref/resource")throw new TypeError(`Expected CompleteRequestResourceTemplate, but got ${e.params.ref.type}`)}i(ML,"assertCompleteRequestResourceTemplate");var Uee=it.extend({completion:wt({values:de(N()).max(100),total:Fe(we().int()),hasMore:Fe(Xe())})}),qee=q({uri:N().startsWith("file://"),name:N().optional(),_meta:Ie(N(),Le()).optional()}),Bee=st.extend({method:G("roots/list"),params:Wt.optional()}),mk=it.extend({roots:de(qee)}),Hee=pr.extend({method:G("notifications/roots/list_changed"),params:dr.optional()}),Z4e=Ae([rg,ok,yg,pk,mg,fg,ug,dg,pg,BQ,VQ,ec,hg,og,ig,ag,lg]),L4e=Ae([tg,ng,sk,Hee,od]),F4e=Ae([eg,ad,fk,tc,mk,sg,cg,Xa]),U4e=Ae([rg,vee,jee,Bee,og,ig,ag,lg]),q4e=Ae([tg,ng,pee,WQ,UQ,lee,oee,od,Mee]),B4e=Ae([eg,IQ,Uee,nee,YQ,MQ,ZQ,FQ,gg,aee,sg,cg,Xa]),Yh=class Yh extends Error{constructor(t,r,n){super(`MCP error ${t}: ${r}`),this.code=t,this.data=n,this.name="McpError"}static fromError(t,r,n){if(t===K.UrlElicitationRequired&&n){let o=n;if(o.elicitations)return new XS(o.elicitations,r)}return new Yh(t,r,n)}};i(Yh,"McpError");var V=Yh,hk=class hk extends V{constructor(t,r=`URL elicitation${t.length>1?"s":""} required`){super(K.UrlElicitationRequired,r,{elicitations:t})}get elicitations(){return this.data?.elicitations??[]}};i(hk,"UrlElicitationRequiredError");var XS=hk;function Eo(e){return e==="completed"||e==="failed"||e==="cancelled"}i(Eo,"isTerminal");var LL=Symbol("Let zodToJsonSchema decide on which parser to use");var ZL={name:void 0,$refStrategy:"root",basePath:["#"],effectStrategy:"input",pipeStrategy:"all",dateStrategy:"format:date-time",mapStrategy:"entries",removeAdditionalStrategy:"passthrough",allowedAdditionalProperties:!0,rejectedAdditionalProperties:!1,definitionPath:"definitions",target:"jsonSchema7",strictUnions:!1,definitions:{},errorMessages:!1,markdownDescription:!1,patternStrategy:"escape",applyRegexFlags:!1,emailStrategy:"format:email",base64Strategy:"contentEncoding:base64",nameStrategy:"ref",openAiAnyTypeName:"OpenAiAnyType"},FL=i(e=>typeof e=="string"?{...ZL,name:e}:{...ZL,...e},"getDefaultOptions");var UL=i(e=>{let t=FL(e),r=t.name!==void 0?[...t.basePath,t.definitionPath,t.name]:t.basePath;return{...t,flags:{hasReferencedOpenAiAnyType:!1},currentPath:r,propertyPath:void 0,seen:new Map(Object.entries(t.definitions).map(([n,o])=>[o._def,{def:o._def,path:[...t.basePath,t.definitionPath,n],jsonSchema:void 0}]))}},"getRefs");function gk(e,t,r,n){n?.errorMessages&&r&&(e.errorMessage={...e.errorMessage,[t]:r})}i(gk,"addErrorMessage");function pe(e,t,r,n,o){e[t]=r,gk(e,t,n,o)}i(pe,"setResponseValueAndErrors");var xg=i((e,t)=>{let r=0;for(;r<e.length&&r<t.length&&e[r]===t[r];r++);return[(e.length-r).toString(),...t.slice(r)].join("/")},"getRelativePath");function Ue(e){if(e.target!=="openAi")return{};let t=[...e.basePath,e.definitionPath,e.openAiAnyTypeName];return e.flags.hasReferencedOpenAiAnyType=!0,{$ref:e.$refStrategy==="relative"?xg(t,e.currentPath):t.join("/")}}i(Ue,"parseAnyDef");function qL(e,t){let r={type:"array"};return e.type?._def&&e.type?._def?.typeName!==j.ZodAny&&(r.items=Q(e.type._def,{...t,currentPath:[...t.currentPath,"items"]})),e.minLength&&pe(r,"minItems",e.minLength.value,e.minLength.message,t),e.maxLength&&pe(r,"maxItems",e.maxLength.value,e.maxLength.message,t),e.exactLength&&(pe(r,"minItems",e.exactLength.value,e.exactLength.message,t),pe(r,"maxItems",e.exactLength.value,e.exactLength.message,t)),r}i(qL,"parseArrayDef");function BL(e,t){let r={type:"integer",format:"int64"};if(!e.checks)return r;for(let n of e.checks)switch(n.kind){case"min":t.target==="jsonSchema7"?n.inclusive?pe(r,"minimum",n.value,n.message,t):pe(r,"exclusiveMinimum",n.value,n.message,t):(n.inclusive||(r.exclusiveMinimum=!0),pe(r,"minimum",n.value,n.message,t));break;case"max":t.target==="jsonSchema7"?n.inclusive?pe(r,"maximum",n.value,n.message,t):pe(r,"exclusiveMaximum",n.value,n.message,t):(n.inclusive||(r.exclusiveMaximum=!0),pe(r,"maximum",n.value,n.message,t));break;case"multipleOf":pe(r,"multipleOf",n.value,n.message,t);break}return r}i(BL,"parseBigintDef");function HL(){return{type:"boolean"}}i(HL,"parseBooleanDef");function _g(e,t){return Q(e.type._def,t)}i(_g,"parseBrandedDef");var VL=i((e,t)=>Q(e.innerType._def,t),"parseCatchDef");function yk(e,t,r){let n=r??t.dateStrategy;if(Array.isArray(n))return{anyOf:n.map((o,s)=>yk(e,t,o))};switch(n){case"string":case"format:date-time":return{type:"string",format:"date-time"};case"format:date":return{type:"string",format:"date"};case"integer":return Vee(e,t)}}i(yk,"parseDateDef");var Vee=i((e,t)=>{let r={type:"integer",format:"unix-time"};if(t.target==="openApi3")return r;for(let n of e.checks)switch(n.kind){case"min":pe(r,"minimum",n.value,n.message,t);break;case"max":pe(r,"maximum",n.value,n.message,t);break}return r},"integerDateParser");function GL(e,t){return{...Q(e.innerType._def,t),default:e.defaultValue()}}i(GL,"parseDefaultDef");function WL(e,t){return t.effectStrategy==="input"?Q(e.schema._def,t):Ue(t)}i(WL,"parseEffectsDef");function JL(e){return{type:"string",enum:Array.from(e.values)}}i(JL,"parseEnumDef");var Gee=i(e=>"type"in e&&e.type==="string"?!1:"allOf"in e,"isJsonSchema7AllOfType");function KL(e,t){let r=[Q(e.left._def,{...t,currentPath:[...t.currentPath,"allOf","0"]}),Q(e.right._def,{...t,currentPath:[...t.currentPath,"allOf","1"]})].filter(s=>!!s),n=t.target==="jsonSchema2019-09"?{unevaluatedProperties:!1}:void 0,o=[];return r.forEach(s=>{if(Gee(s))o.push(...s.allOf),s.unevaluatedProperties===void 0&&(n=void 0);else{let a=s;if("additionalProperties"in s&&s.additionalProperties===!1){let{additionalProperties:c,...l}=s;a=l}else n=void 0;o.push(a)}}),o.length?{allOf:o,...n}:void 0}i(KL,"parseIntersectionDef");function YL(e,t){let r=typeof e.value;return r!=="bigint"&&r!=="number"&&r!=="boolean"&&r!=="string"?{type:Array.isArray(e.value)?"array":"object"}:t.target==="openApi3"?{type:r==="bigint"?"integer":r,enum:[e.value]}:{type:r==="bigint"?"integer":r,const:e.value}}i(YL,"parseLiteralDef");var xk,Cr={cuid:/^[cC][^\s-]{8,}$/,cuid2:/^[0-9a-z]+$/,ulid:/^[0-9A-HJKMNP-TV-Z]{26}$/,email:/^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'+\-\.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9\-]*\.)+[a-zA-Z]{2,}$/,emoji:()=>(xk===void 0&&(xk=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),xk),uuid:/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/,ipv4:/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,ipv4Cidr:/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,ipv6:/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,ipv6Cidr:/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,base64:/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,base64url:/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,nanoid:/^[a-zA-Z0-9_-]{21}$/,jwt:/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/};function vg(e,t){let r={type:"string"};if(e.checks)for(let n of e.checks)switch(n.kind){case"min":pe(r,"minLength",typeof r.minLength=="number"?Math.max(r.minLength,n.value):n.value,n.message,t);break;case"max":pe(r,"maxLength",typeof r.maxLength=="number"?Math.min(r.maxLength,n.value):n.value,n.message,t);break;case"email":switch(t.emailStrategy){case"format:email":Ir(r,"email",n.message,t);break;case"format:idn-email":Ir(r,"idn-email",n.message,t);break;case"pattern:zod":bt(r,Cr.email,n.message,t);break}break;case"url":Ir(r,"uri",n.message,t);break;case"uuid":Ir(r,"uuid",n.message,t);break;case"regex":bt(r,n.regex,n.message,t);break;case"cuid":bt(r,Cr.cuid,n.message,t);break;case"cuid2":bt(r,Cr.cuid2,n.message,t);break;case"startsWith":bt(r,RegExp(`^${_k(n.value,t)}`),n.message,t);break;case"endsWith":bt(r,RegExp(`${_k(n.value,t)}$`),n.message,t);break;case"datetime":Ir(r,"date-time",n.message,t);break;case"date":Ir(r,"date",n.message,t);break;case"time":Ir(r,"time",n.message,t);break;case"duration":Ir(r,"duration",n.message,t);break;case"length":pe(r,"minLength",typeof r.minLength=="number"?Math.max(r.minLength,n.value):n.value,n.message,t),pe(r,"maxLength",typeof r.maxLength=="number"?Math.min(r.maxLength,n.value):n.value,n.message,t);break;case"includes":{bt(r,RegExp(_k(n.value,t)),n.message,t);break}case"ip":{n.version!=="v6"&&Ir(r,"ipv4",n.message,t),n.version!=="v4"&&Ir(r,"ipv6",n.message,t);break}case"base64url":bt(r,Cr.base64url,n.message,t);break;case"jwt":bt(r,Cr.jwt,n.message,t);break;case"cidr":{n.version!=="v6"&&bt(r,Cr.ipv4Cidr,n.message,t),n.version!=="v4"&&bt(r,Cr.ipv6Cidr,n.message,t);break}case"emoji":bt(r,Cr.emoji(),n.message,t);break;case"ulid":{bt(r,Cr.ulid,n.message,t);break}case"base64":{switch(t.base64Strategy){case"format:binary":{Ir(r,"binary",n.message,t);break}case"contentEncoding:base64":{pe(r,"contentEncoding","base64",n.message,t);break}case"pattern:zod":{bt(r,Cr.base64,n.message,t);break}}break}case"nanoid":bt(r,Cr.nanoid,n.message,t);case"toLowerCase":case"toUpperCase":case"trim":break;default:}return r}i(vg,"parseStringDef");function _k(e,t){return t.patternStrategy==="escape"?Jee(e):e}i(_k,"escapeLiteralCheckValue");var Wee=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function Jee(e){let t="";for(let r=0;r<e.length;r++)Wee.has(e[r])||(t+="\\"),t+=e[r];return t}i(Jee,"escapeNonAlphaNumeric");function Ir(e,t,r,n){e.format||e.anyOf?.some(o=>o.format)?(e.anyOf||(e.anyOf=[]),e.format&&(e.anyOf.push({format:e.format,...e.errorMessage&&n.errorMessages&&{errorMessage:{format:e.errorMessage.format}}}),delete e.format,e.errorMessage&&(delete e.errorMessage.format,Object.keys(e.errorMessage).length===0&&delete e.errorMessage)),e.anyOf.push({format:t,...r&&n.errorMessages&&{errorMessage:{format:r}}})):pe(e,"format",t,r,n)}i(Ir,"addFormat");function bt(e,t,r,n){e.pattern||e.allOf?.some(o=>o.pattern)?(e.allOf||(e.allOf=[]),e.pattern&&(e.allOf.push({pattern:e.pattern,...e.errorMessage&&n.errorMessages&&{errorMessage:{pattern:e.errorMessage.pattern}}}),delete e.pattern,e.errorMessage&&(delete e.errorMessage.pattern,Object.keys(e.errorMessage).length===0&&delete e.errorMessage)),e.allOf.push({pattern:XL(t,n),...r&&n.errorMessages&&{errorMessage:{pattern:r}}})):pe(e,"pattern",XL(t,n),r,n)}i(bt,"addPattern");function XL(e,t){if(!t.applyRegexFlags||!e.flags)return e.source;let r={i:e.flags.includes("i"),m:e.flags.includes("m"),s:e.flags.includes("s")},n=r.i?e.source.toLowerCase():e.source,o="",s=!1,a=!1,c=!1;for(let l=0;l<n.length;l++){if(s){o+=n[l],s=!1;continue}if(r.i){if(a){if(n[l].match(/[a-z]/)){c?(o+=n[l],o+=`${n[l-2]}-${n[l]}`.toUpperCase(),c=!1):n[l+1]==="-"&&n[l+2]?.match(/[a-z]/)?(o+=n[l],c=!0):o+=`${n[l]}${n[l].toUpperCase()}`;continue}}else if(n[l].match(/[a-z]/)){o+=`[${n[l]}${n[l].toUpperCase()}]`;continue}}if(r.m){if(n[l]==="^"){o+=`(^|(?<=[\r
293
353
  ]))`;continue}else if(n[l]==="$"){o+=`($|(?=[\r
294
354
  ]))`;continue}}if(r.s&&n[l]==="."){o+=a?`${n[l]}\r
295
355
  `:`[${n[l]}\r
296
- ]`;continue}o+=n[l],n[l]==="\\"?s=!0:a&&n[l]==="]"?a=!1:!a&&n[l]==="["&&(a=!0)}try{new RegExp(o)}catch{return console.warn(`Could not convert regex pattern at ${t.currentPath.join("/")} to a flag-independent form! Falling back to the flag-ignorant source`),e.source}return o}i(MD,"stringifyRegExpWithFlags");function _m(e,t){if(t.target==="openAi"&&console.warn("Warning: OpenAI may not support records in schemas! Try an array of key-value pairs instead."),t.target==="openApi3"&&e.keyType?._def.typeName===P.ZodEnum)return{type:"object",required:e.keyType._def.values,properties:e.keyType._def.values.reduce((n,o)=>({...n,[o]:J(e.valueType._def,{...t,currentPath:[...t.currentPath,"properties",o]})??Ze(t)}),{}),additionalProperties:t.rejectedAdditionalProperties};let r={type:"object",additionalProperties:J(e.valueType._def,{...t,currentPath:[...t.currentPath,"additionalProperties"]})??t.allowedAdditionalProperties};if(t.target==="openApi3")return r;if(e.keyType?._def.typeName===P.ZodString&&e.keyType._def.checks?.length){let{type:n,...o}=xm(e.keyType._def,t);return{...r,propertyNames:o}}else{if(e.keyType?._def.typeName===P.ZodEnum)return{...r,propertyNames:{enum:e.keyType._def.values}};if(e.keyType?._def.typeName===P.ZodBranded&&e.keyType._def.type._def.typeName===P.ZodString&&e.keyType._def.type._def.checks?.length){let{type:n,...o}=ym(e.keyType._def,t);return{...r,propertyNames:o}}}return r}i(_m,"parseRecordDef");function ZD(e,t){if(t.mapStrategy==="record")return _m(e,t);let r=J(e.keyType._def,{...t,currentPath:[...t.currentPath,"items","items","0"]})||Ze(t),n=J(e.valueType._def,{...t,currentPath:[...t.currentPath,"items","items","1"]})||Ze(t);return{type:"array",maxItems:125,items:{type:"array",items:[r,n],minItems:2,maxItems:2}}}i(ZD,"parseMapDef");function LD(e){let t=e.values,n=Object.keys(e.values).filter(s=>typeof t[t[s]]!="number").map(s=>t[s]),o=Array.from(new Set(n.map(s=>typeof s)));return{type:o.length===1?o[0]==="string"?"string":"number":["string","number"],enum:n}}i(LD,"parseNativeEnumDef");function FD(e){return e.target==="openAi"?void 0:{not:Ze({...e,currentPath:[...e.currentPath,"not"]})}}i(FD,"parseNeverDef");function UD(e){return e.target==="openApi3"?{enum:["null"],nullable:!0}:{type:"null"}}i(UD,"parseNullDef");var Al={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"};function HD(e,t){if(t.target==="openApi3")return qD(e,t);let r=e.options instanceof Map?Array.from(e.options.values()):e.options;if(r.every(n=>n._def.typeName in Al&&(!n._def.checks||!n._def.checks.length))){let n=r.reduce((o,s)=>{let a=Al[s._def.typeName];return a&&!o.includes(a)?[...o,a]:o},[]);return{type:n.length>1?n:n[0]}}else if(r.every(n=>n._def.typeName==="ZodLiteral"&&!n.description)){let n=r.reduce((o,s)=>{let a=typeof s._def.value;switch(a){case"string":case"number":case"boolean":return[...o,a];case"bigint":return[...o,"integer"];case"object":if(s._def.value===null)return[...o,"null"];case"symbol":case"undefined":case"function":default:return o}},[]);if(n.length===r.length){let o=n.filter((s,a,c)=>c.indexOf(s)===a);return{type:o.length>1?o:o[0],enum:r.reduce((s,a)=>s.includes(a._def.value)?s:[...s,a._def.value],[])}}}else if(r.every(n=>n._def.typeName==="ZodEnum"))return{type:"string",enum:r.reduce((n,o)=>[...n,...o._def.values.filter(s=>!n.includes(s))],[])};return qD(e,t)}i(HD,"parseUnionDef");var qD=i((e,t)=>{let r=(e.options instanceof Map?Array.from(e.options.values()):e.options).map((n,o)=>J(n._def,{...t,currentPath:[...t.currentPath,"anyOf",`${o}`]})).filter(n=>!!n&&(!t.strictUnions||typeof n=="object"&&Object.keys(n).length>0));return r.length?{anyOf:r}:void 0},"asAnyOf");function BD(e,t){if(["ZodString","ZodNumber","ZodBigInt","ZodBoolean","ZodNull"].includes(e.innerType._def.typeName)&&(!e.innerType._def.checks||!e.innerType._def.checks.length))return t.target==="openApi3"?{type:Al[e.innerType._def.typeName],nullable:!0}:{type:[Al[e.innerType._def.typeName],"null"]};if(t.target==="openApi3"){let n=J(e.innerType._def,{...t,currentPath:[...t.currentPath]});return n&&"$ref"in n?{allOf:[n],nullable:!0}:n&&{...n,nullable:!0}}let r=J(e.innerType._def,{...t,currentPath:[...t.currentPath,"anyOf","0"]});return r&&{anyOf:[r,{type:"null"}]}}i(BD,"parseNullableDef");function VD(e,t){let r={type:"number"};if(!e.checks)return r;for(let n of e.checks)switch(n.kind){case"int":r.type="integer",Hb(r,"type",n.message,t);break;case"min":t.target==="jsonSchema7"?n.inclusive?ue(r,"minimum",n.value,n.message,t):ue(r,"exclusiveMinimum",n.value,n.message,t):(n.inclusive||(r.exclusiveMinimum=!0),ue(r,"minimum",n.value,n.message,t));break;case"max":t.target==="jsonSchema7"?n.inclusive?ue(r,"maximum",n.value,n.message,t):ue(r,"exclusiveMaximum",n.value,n.message,t):(n.inclusive||(r.exclusiveMaximum=!0),ue(r,"maximum",n.value,n.message,t));break;case"multipleOf":ue(r,"multipleOf",n.value,n.message,t);break}return r}i(VD,"parseNumberDef");function GD(e,t){let r=t.target==="openAi",n={type:"object",properties:{}},o=[],s=e.shape();for(let c in s){let l=s[c];if(l===void 0||l._def===void 0)continue;let u=WK(l);u&&r&&(l._def.typeName==="ZodOptional"&&(l=l._def.innerType),l.isNullable()||(l=l.nullable()),u=!1);let d=J(l._def,{...t,currentPath:[...t.currentPath,"properties",c],propertyPath:[...t.currentPath,"properties",c]});d!==void 0&&(n.properties[c]=d,u||o.push(c))}o.length&&(n.required=o);let a=GK(e,t);return a!==void 0&&(n.additionalProperties=a),n}i(GD,"parseObjectDef");function GK(e,t){if(e.catchall._def.typeName!=="ZodNever")return J(e.catchall._def,{...t,currentPath:[...t.currentPath,"additionalProperties"]});switch(e.unknownKeys){case"passthrough":return t.allowedAdditionalProperties;case"strict":return t.rejectedAdditionalProperties;case"strip":return t.removeAdditionalStrategy==="strict"?t.allowedAdditionalProperties:t.rejectedAdditionalProperties}}i(GK,"decideAdditionalProperties");function WK(e){try{return e.isOptional()}catch{return!0}}i(WK,"safeIsOptional");var WD=i((e,t)=>{if(t.currentPath.toString()===t.propertyPath?.toString())return J(e.innerType._def,t);let r=J(e.innerType._def,{...t,currentPath:[...t.currentPath,"anyOf","1"]});return r?{anyOf:[{not:Ze(t)},r]}:Ze(t)},"parseOptionalDef");var KD=i((e,t)=>{if(t.pipeStrategy==="input")return J(e.in._def,t);if(t.pipeStrategy==="output")return J(e.out._def,t);let r=J(e.in._def,{...t,currentPath:[...t.currentPath,"allOf","0"]}),n=J(e.out._def,{...t,currentPath:[...t.currentPath,"allOf",r?"1":"0"]});return{allOf:[r,n].filter(o=>o!==void 0)}},"parsePipelineDef");function JD(e,t){return J(e.type._def,t)}i(JD,"parsePromiseDef");function YD(e,t){let n={type:"array",uniqueItems:!0,items:J(e.valueType._def,{...t,currentPath:[...t.currentPath,"items"]})};return e.minSize&&ue(n,"minItems",e.minSize.value,e.minSize.message,t),e.maxSize&&ue(n,"maxItems",e.maxSize.value,e.maxSize.message,t),n}i(YD,"parseSetDef");function XD(e,t){return e.rest?{type:"array",minItems:e.items.length,items:e.items.map((r,n)=>J(r._def,{...t,currentPath:[...t.currentPath,"items",`${n}`]})).reduce((r,n)=>n===void 0?r:[...r,n],[]),additionalItems:J(e.rest._def,{...t,currentPath:[...t.currentPath,"additionalItems"]})}:{type:"array",minItems:e.items.length,maxItems:e.items.length,items:e.items.map((r,n)=>J(r._def,{...t,currentPath:[...t.currentPath,"items",`${n}`]})).reduce((r,n)=>n===void 0?r:[...r,n],[])}}i(XD,"parseTupleDef");function QD(e){return{not:Ze(e)}}i(QD,"parseUndefinedDef");function eM(e){return Ze(e)}i(eM,"parseUnknownDef");var tM=i((e,t)=>J(e.innerType._def,t),"parseReadonlyDef");var rM=i((e,t,r)=>{switch(t){case P.ZodString:return xm(e,r);case P.ZodNumber:return VD(e,r);case P.ZodObject:return GD(e,r);case P.ZodBigInt:return CD(e,r);case P.ZodBoolean:return ID();case P.ZodDate:return Bb(e,r);case P.ZodUndefined:return QD(r);case P.ZodNull:return UD(r);case P.ZodArray:return zD(e,r);case P.ZodUnion:case P.ZodDiscriminatedUnion:return HD(e,r);case P.ZodIntersection:return jD(e,r);case P.ZodTuple:return XD(e,r);case P.ZodRecord:return _m(e,r);case P.ZodLiteral:return DD(e,r);case P.ZodEnum:return AD(e);case P.ZodNativeEnum:return LD(e);case P.ZodNullable:return BD(e,r);case P.ZodOptional:return WD(e,r);case P.ZodMap:return ZD(e,r);case P.ZodSet:return YD(e,r);case P.ZodLazy:return()=>e.getter()._def;case P.ZodPromise:return JD(e,r);case P.ZodNaN:case P.ZodNever:return FD(r);case P.ZodEffects:return OD(e,r);case P.ZodAny:return Ze(r);case P.ZodUnknown:return eM(r);case P.ZodDefault:return RD(e,r);case P.ZodBranded:return ym(e,r);case P.ZodReadonly:return tM(e,r);case P.ZodCatch:return PD(e,r);case P.ZodPipeline:return KD(e,r);case P.ZodFunction:case P.ZodVoid:case P.ZodSymbol:return;default:return(n=>{})(t)}},"selectParser");function J(e,t,r=!1){let n=t.seen.get(e);if(t.override){let c=t.override?.(e,t,n,r);if(c!==ED)return c}if(n&&!r){let c=KK(n,t);if(c!==void 0)return c}let o={def:e,path:t.currentPath,jsonSchema:void 0};t.seen.set(e,o);let s=rM(e,e.typeName,t),a=typeof s=="function"?J(s(),t):s;if(a&&JK(e,t,a),t.postProcess){let c=t.postProcess(a,e,t);return o.jsonSchema=a,c}return o.jsonSchema=a,a}i(J,"parseDef");var KK=i((e,t)=>{switch(t.$refStrategy){case"root":return{$ref:e.path.join("/")};case"relative":return{$ref:gm(t.currentPath,e.path)};case"none":case"seen":return e.path.length<t.currentPath.length&&e.path.every((r,n)=>t.currentPath[n]===r)?(console.warn(`Recursive reference detected at ${t.currentPath.join("/")}! Defaulting to any`),Ze(t)):t.$refStrategy==="seen"?Ze(t):void 0}},"get$ref"),JK=i((e,t,r)=>(e.description&&(r.description=e.description,t.markdownDescription&&(r.markdownDescription=e.description)),r),"addMeta");var Wb=i((e,t)=>{let r=TD(t),n=typeof t=="object"&&t.definitions?Object.entries(t.definitions).reduce((l,[u,d])=>({...l,[u]:J(d._def,{...r,currentPath:[...r.basePath,r.definitionPath,u]},!0)??Ze(r)}),{}):void 0,o=typeof t=="string"?t:t?.nameStrategy==="title"?void 0:t?.name,s=J(e._def,o===void 0?r:{...r,currentPath:[...r.basePath,r.definitionPath,o]},!1)??Ze(r),a=typeof t=="object"&&t.name!==void 0&&t.nameStrategy==="title"?t.name:void 0;a!==void 0&&(s.title=a),r.flags.hasReferencedOpenAiAnyType&&(n||(n={}),n[r.openAiAnyTypeName]||(n[r.openAiAnyTypeName]={type:["string","number","integer","boolean","array","null"],items:{$ref:r.$refStrategy==="relative"?"1":[...r.basePath,r.definitionPath,r.openAiAnyTypeName].join("/")}}));let c=o===void 0?n?{...s,[r.definitionPath]:n}:s:{$ref:[...r.$refStrategy==="relative"?[]:r.basePath,r.definitionPath,o].join("/"),[r.definitionPath]:{...n,[o]:s}};return r.target==="jsonSchema7"?c.$schema="http://json-schema.org/draft-07/schema#":(r.target==="jsonSchema2019-09"||r.target==="openAi")&&(c.$schema="https://json-schema.org/draft/2019-09/schema#"),r.target==="openAi"&&("anyOf"in c||"oneOf"in c||"allOf"in c||"type"in c&&Array.isArray(c.type))&&console.warn("Warning: OpenAI may not support schemas with unions as roots! Try wrapping it in an object property."),c},"zodToJsonSchema");function YK(e){return!e||e==="jsonSchema7"||e==="draft-7"?"draft-7":e==="jsonSchema2019-09"||e==="draft-2020-12"?"draft-2020-12":"draft-7"}i(YK,"mapMiniTarget");function Kb(e,t){return Hr(e)?hb(e,{target:YK(t?.target),io:t?.pipeStrategy??"input"}):Wb(e,{strictUnions:t?.strictUnions??!0,pipeStrategy:t?.pipeStrategy??"input"})}i(Kb,"toJsonSchemaCompat");function Jb(e){let r=Xn(e)?.method;if(!r)throw new Error("Schema is missing a method literal");let n=na(r);if(typeof n!="string")throw new Error("Schema method literal must be a string");return n}i(Jb,"getMethodLiteral");function Yb(e,t){let r=Yn(e,t);if(!r.success)throw r.error;return r.data}i(Yb,"parseWithCompat");var XK=6e4,Xb=class Xb{constructor(t){this._options=t,this._requestMessageId=0,this._requestHandlers=new Map,this._requestHandlerAbortControllers=new Map,this._notificationHandlers=new Map,this._responseHandlers=new Map,this._progressHandlers=new Map,this._timeoutInfo=new Map,this._pendingDebouncedNotifications=new Set,this._taskProgressTokens=new Map,this._requestResolvers=new Map,this.setNotificationHandler(Qf,r=>{this._oncancel(r)}),this.setNotificationHandler(tm,r=>{this._onprogress(r)}),this.setRequestHandler(em,r=>({})),this._taskStore=t?.taskStore,this._taskMessageQueue=t?.taskMessageQueue,this._taskStore&&(this.setRequestHandler(rm,async(r,n)=>{let o=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!o)throw new U(B.InvalidParams,"Failed to retrieve task: Task not found");return{...o}}),this.setRequestHandler(om,async(r,n)=>{let o=i(async()=>{let s=r.params.taskId;if(this._taskMessageQueue){let c;for(;c=await this._taskMessageQueue.dequeue(s,n.sessionId);){if(c.type==="response"||c.type==="error"){let l=c.message,u=l.id,d=this._requestResolvers.get(u);if(d)if(this._requestResolvers.delete(u),c.type==="response")d(l);else{let p=l,h=new U(p.error.code,p.error.message,p.error.data);d(h)}else{let p=c.type==="response"?"Response":"Error";this._onerror(new Error(`${p} handler missing for request ${u}`))}continue}await this._transport?.send(c.message,{relatedRequestId:n.requestId})}}let a=await this._taskStore.getTask(s,n.sessionId);if(!a)throw new U(B.InvalidParams,`Task not found: ${s}`);if(!eo(a.status))return await this._waitForTaskUpdate(s,n.signal),await o();if(eo(a.status)){let c=await this._taskStore.getTaskResult(s,n.sessionId);return this._clearTaskQueue(s),{...c,_meta:{...c._meta,[Qn]:{taskId:s}}}}return await o()},"handleTaskResult");return await o()}),this.setRequestHandler(sm,async(r,n)=>{try{let{tasks:o,nextCursor:s}=await this._taskStore.listTasks(r.params?.cursor,n.sessionId);return{tasks:o,nextCursor:s,_meta:{}}}catch(o){throw new U(B.InvalidParams,`Failed to list tasks: ${o instanceof Error?o.message:String(o)}`)}}),this.setRequestHandler(am,async(r,n)=>{try{let o=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!o)throw new U(B.InvalidParams,`Task not found: ${r.params.taskId}`);if(eo(o.status))throw new U(B.InvalidParams,`Cannot cancel task in terminal status: ${o.status}`);await this._taskStore.updateTaskStatus(r.params.taskId,"cancelled","Client cancelled task execution.",n.sessionId),this._clearTaskQueue(r.params.taskId);let s=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!s)throw new U(B.InvalidParams,`Task not found after cancellation: ${r.params.taskId}`);return{_meta:{},...s}}catch(o){throw o instanceof U?o:new U(B.InvalidRequest,`Failed to cancel task: ${o instanceof Error?o.message:String(o)}`)}}))}async _oncancel(t){if(!t.params.requestId)return;this._requestHandlerAbortControllers.get(t.params.requestId)?.abort(t.params.reason)}_setupTimeout(t,r,n,o,s=!1){this._timeoutInfo.set(t,{timeoutId:setTimeout(o,r),startTime:Date.now(),timeout:r,maxTotalTimeout:n,resetTimeoutOnProgress:s,onTimeout:o})}_resetTimeout(t){let r=this._timeoutInfo.get(t);if(!r)return!1;let n=Date.now()-r.startTime;if(r.maxTotalTimeout&&n>=r.maxTotalTimeout)throw this._timeoutInfo.delete(t),U.fromError(B.RequestTimeout,"Maximum total timeout exceeded",{maxTotalTimeout:r.maxTotalTimeout,totalElapsed:n});return clearTimeout(r.timeoutId),r.timeoutId=setTimeout(r.onTimeout,r.timeout),!0}_cleanupTimeout(t){let r=this._timeoutInfo.get(t);r&&(clearTimeout(r.timeoutId),this._timeoutInfo.delete(t))}async connect(t){if(this._transport)throw new Error("Already connected to a transport. Call close() before connecting to a new transport, or use a separate Protocol instance per connection.");this._transport=t;let r=this.transport?.onclose;this._transport.onclose=()=>{r?.(),this._onclose()};let n=this.transport?.onerror;this._transport.onerror=s=>{n?.(s),this._onerror(s)};let o=this._transport?.onmessage;this._transport.onmessage=(s,a)=>{o?.(s,a),El(s)||mD(s)?this._onresponse(s):zb(s)?this._onrequest(s,a):fD(s)?this._onnotification(s):this._onerror(new Error(`Unknown message type: ${JSON.stringify(s)}`))},await this._transport.start()}_onclose(){let t=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._taskProgressTokens.clear(),this._pendingDebouncedNotifications.clear();for(let n of this._timeoutInfo.values())clearTimeout(n.timeoutId);this._timeoutInfo.clear();for(let n of this._requestHandlerAbortControllers.values())n.abort();this._requestHandlerAbortControllers.clear();let r=U.fromError(B.ConnectionClosed,"Connection closed");this._transport=void 0,this.onclose?.();for(let n of t.values())n(r)}_onerror(t){this.onerror?.(t)}_onnotification(t){let r=this._notificationHandlers.get(t.method)??this.fallbackNotificationHandler;r!==void 0&&Promise.resolve().then(()=>r(t)).catch(n=>this._onerror(new Error(`Uncaught error in notification handler: ${n}`)))}_onrequest(t,r){let n=this._requestHandlers.get(t.method)??this.fallbackRequestHandler,o=this._transport,s=t.params?._meta?.[Qn]?.taskId;if(n===void 0){let d={jsonrpc:"2.0",id:t.id,error:{code:B.MethodNotFound,message:"Method not found"}};s&&this._taskMessageQueue?this._enqueueTaskMessage(s,{type:"error",message:d,timestamp:Date.now()},o?.sessionId).catch(p=>this._onerror(new Error(`Failed to enqueue error response: ${p}`))):o?.send(d).catch(p=>this._onerror(new Error(`Failed to send an error response: ${p}`)));return}let a=new AbortController;this._requestHandlerAbortControllers.set(t.id,a);let c=uD(t.params)?t.params.task:void 0,l=this._taskStore?this.requestTaskStore(t,o?.sessionId):void 0,u={signal:a.signal,sessionId:o?.sessionId,_meta:t.params?._meta,sendNotification:async d=>{if(a.signal.aborted)return;let p={relatedRequestId:t.id};s&&(p.relatedTask={taskId:s}),await this.notification(d,p)},sendRequest:async(d,p,h)=>{if(a.signal.aborted)throw new U(B.ConnectionClosed,"Request was cancelled");let m={...h,relatedRequestId:t.id};s&&!m.relatedTask&&(m.relatedTask={taskId:s});let g=m.relatedTask?.taskId??s;return g&&l&&await l.updateTaskStatus(g,"input_required"),await this.request(d,p,m)},authInfo:r?.authInfo,requestId:t.id,requestInfo:r?.requestInfo,taskId:s,taskStore:l,taskRequestedTtl:c?.ttl,closeSSEStream:r?.closeSSEStream,closeStandaloneSSEStream:r?.closeStandaloneSSEStream};Promise.resolve().then(()=>{c&&this.assertTaskHandlerCapability(t.method)}).then(()=>n(t,u)).then(async d=>{if(a.signal.aborted)return;let p={result:d,jsonrpc:"2.0",id:t.id};s&&this._taskMessageQueue?await this._enqueueTaskMessage(s,{type:"response",message:p,timestamp:Date.now()},o?.sessionId):await o?.send(p)},async d=>{if(a.signal.aborted)return;let p={jsonrpc:"2.0",id:t.id,error:{code:Number.isSafeInteger(d.code)?d.code:B.InternalError,message:d.message??"Internal error",...d.data!==void 0&&{data:d.data}}};s&&this._taskMessageQueue?await this._enqueueTaskMessage(s,{type:"error",message:p,timestamp:Date.now()},o?.sessionId):await o?.send(p)}).catch(d=>this._onerror(new Error(`Failed to send response: ${d}`))).finally(()=>{this._requestHandlerAbortControllers.get(t.id)===a&&this._requestHandlerAbortControllers.delete(t.id)})}_onprogress(t){let{progressToken:r,...n}=t.params,o=Number(r),s=this._progressHandlers.get(o);if(!s){this._onerror(new Error(`Received a progress notification for an unknown token: ${JSON.stringify(t)}`));return}let a=this._responseHandlers.get(o),c=this._timeoutInfo.get(o);if(c&&a&&c.resetTimeoutOnProgress)try{this._resetTimeout(o)}catch(l){this._responseHandlers.delete(o),this._progressHandlers.delete(o),this._cleanupTimeout(o),a(l);return}s(n)}_onresponse(t){let r=Number(t.id),n=this._requestResolvers.get(r);if(n){if(this._requestResolvers.delete(r),El(t))n(t);else{let a=new U(t.error.code,t.error.message,t.error.data);n(a)}return}let o=this._responseHandlers.get(r);if(o===void 0){this._onerror(new Error(`Received a response for an unknown message ID: ${JSON.stringify(t)}`));return}this._responseHandlers.delete(r),this._cleanupTimeout(r);let s=!1;if(El(t)&&t.result&&typeof t.result=="object"){let a=t.result;if(a.task&&typeof a.task=="object"){let c=a.task;typeof c.taskId=="string"&&(s=!0,this._taskProgressTokens.set(c.taskId,r))}}if(s||this._progressHandlers.delete(r),El(t))o(t);else{let a=U.fromError(t.error.code,t.error.message,t.error.data);o(a)}}get transport(){return this._transport}async close(){await this._transport?.close()}async*requestStream(t,r,n){let{task:o}=n??{};if(!o){try{yield{type:"result",result:await this.request(t,r,n)}}catch(a){yield{type:"error",error:a instanceof U?a:new U(B.InternalError,String(a))}}return}let s;try{let a=await this.request(t,sa,n);if(a.task)s=a.task.taskId,yield{type:"taskCreated",task:a.task};else throw new U(B.InternalError,"Task creation did not return a task");for(;;){let c=await this.getTask({taskId:s},n);if(yield{type:"taskStatus",task:c},eo(c.status)){c.status==="completed"?yield{type:"result",result:await this.getTaskResult({taskId:s},r,n)}:c.status==="failed"?yield{type:"error",error:new U(B.InternalError,`Task ${s} failed`)}:c.status==="cancelled"&&(yield{type:"error",error:new U(B.InternalError,`Task ${s} was cancelled`)});return}if(c.status==="input_required"){yield{type:"result",result:await this.getTaskResult({taskId:s},r,n)};return}let l=c.pollInterval??this._options?.defaultTaskPollInterval??1e3;await new Promise(u=>setTimeout(u,l)),n?.signal?.throwIfAborted()}}catch(a){yield{type:"error",error:a instanceof U?a:new U(B.InternalError,String(a))}}}request(t,r,n){let{relatedRequestId:o,resumptionToken:s,onresumptiontoken:a,task:c,relatedTask:l}=n??{};return new Promise((u,d)=>{let p=i(w=>{d(w)},"earlyReject");if(!this._transport){p(new Error("Not connected"));return}if(this._options?.enforceStrictCapabilities===!0)try{this.assertCapabilityForMethod(t.method),c&&this.assertTaskCapability(t.method)}catch(w){p(w);return}n?.signal?.throwIfAborted();let h=this._requestMessageId++,m={...t,jsonrpc:"2.0",id:h};n?.onprogress&&(this._progressHandlers.set(h,n.onprogress),m.params={...t.params,_meta:{...t.params?._meta||{},progressToken:h}}),c&&(m.params={...m.params,task:c}),l&&(m.params={...m.params,_meta:{...m.params?._meta||{},[Qn]:l}});let g=i(w=>{this._responseHandlers.delete(h),this._progressHandlers.delete(h),this._cleanupTimeout(h),this._transport?.send({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:h,reason:String(w)}},{relatedRequestId:o,resumptionToken:s,onresumptiontoken:a}).catch(S=>this._onerror(new Error(`Failed to send cancellation: ${S}`)));let b=w instanceof U?w:new U(B.RequestTimeout,String(w));d(b)},"cancel");this._responseHandlers.set(h,w=>{if(!n?.signal?.aborted){if(w instanceof Error)return d(w);try{let b=Yn(r,w.result);b.success?u(b.data):d(b.error)}catch(b){d(b)}}}),n?.signal?.addEventListener("abort",()=>{g(n?.signal?.reason)});let _=n?.timeout??XK,x=i(()=>g(U.fromError(B.RequestTimeout,"Request timed out",{timeout:_})),"timeoutHandler");this._setupTimeout(h,_,n?.maxTotalTimeout,x,n?.resetTimeoutOnProgress??!1);let v=l?.taskId;if(v){let w=i(b=>{let S=this._responseHandlers.get(h);S?S(b):this._onerror(new Error(`Response handler missing for side-channeled request ${h}`))},"responseResolver");this._requestResolvers.set(h,w),this._enqueueTaskMessage(v,{type:"request",message:m,timestamp:Date.now()}).catch(b=>{this._cleanupTimeout(h),d(b)})}else this._transport.send(m,{relatedRequestId:o,resumptionToken:s,onresumptiontoken:a}).catch(w=>{this._cleanupTimeout(h),d(w)})})}async getTask(t,r){return this.request({method:"tasks/get",params:t},nm,r)}async getTaskResult(t,r,n){return this.request({method:"tasks/result",params:t},r,n)}async listTasks(t,r){return this.request({method:"tasks/list",params:t},im,r)}async cancelTask(t,r){return this.request({method:"tasks/cancel",params:t},yD,r)}async notification(t,r){if(!this._transport)throw new Error("Not connected");this.assertNotificationCapability(t.method);let n=r?.relatedTask?.taskId;if(n){let c={...t,jsonrpc:"2.0",params:{...t.params,_meta:{...t.params?._meta||{},[Qn]:r.relatedTask}}};await this._enqueueTaskMessage(n,{type:"notification",message:c,timestamp:Date.now()});return}if((this._options?.debouncedNotificationMethods??[]).includes(t.method)&&!t.params&&!r?.relatedRequestId&&!r?.relatedTask){if(this._pendingDebouncedNotifications.has(t.method))return;this._pendingDebouncedNotifications.add(t.method),Promise.resolve().then(()=>{if(this._pendingDebouncedNotifications.delete(t.method),!this._transport)return;let c={...t,jsonrpc:"2.0"};r?.relatedTask&&(c={...c,params:{...c.params,_meta:{...c.params?._meta||{},[Qn]:r.relatedTask}}}),this._transport?.send(c,r).catch(l=>this._onerror(l))});return}let a={...t,jsonrpc:"2.0"};r?.relatedTask&&(a={...a,params:{...a.params,_meta:{...a.params?._meta||{},[Qn]:r.relatedTask}}}),await this._transport.send(a,r)}setRequestHandler(t,r){let n=Jb(t);this.assertRequestHandlerCapability(n),this._requestHandlers.set(n,(o,s)=>{let a=Yb(t,o);return Promise.resolve(r(a,s))})}removeRequestHandler(t){this._requestHandlers.delete(t)}assertCanSetRequestHandler(t){if(this._requestHandlers.has(t))throw new Error(`A request handler for ${t} already exists, which would be overridden`)}setNotificationHandler(t,r){let n=Jb(t);this._notificationHandlers.set(n,o=>{let s=Yb(t,o);return Promise.resolve(r(s))})}removeNotificationHandler(t){this._notificationHandlers.delete(t)}_cleanupTaskProgressHandler(t){let r=this._taskProgressTokens.get(t);r!==void 0&&(this._progressHandlers.delete(r),this._taskProgressTokens.delete(t))}async _enqueueTaskMessage(t,r,n){if(!this._taskStore||!this._taskMessageQueue)throw new Error("Cannot enqueue task message: taskStore and taskMessageQueue are not configured");let o=this._options?.maxTaskQueueSize;await this._taskMessageQueue.enqueue(t,r,n,o)}async _clearTaskQueue(t,r){if(this._taskMessageQueue){let n=await this._taskMessageQueue.dequeueAll(t,r);for(let o of n)if(o.type==="request"&&zb(o.message)){let s=o.message.id,a=this._requestResolvers.get(s);a?(a(new U(B.InternalError,"Task cancelled or completed")),this._requestResolvers.delete(s)):this._onerror(new Error(`Resolver missing for request ${s} during task ${t} cleanup`))}}}async _waitForTaskUpdate(t,r){let n=this._options?.defaultTaskPollInterval??1e3;try{let o=await this._taskStore?.getTask(t);o?.pollInterval&&(n=o.pollInterval)}catch{}return new Promise((o,s)=>{if(r.aborted){s(new U(B.InvalidRequest,"Request cancelled"));return}let a=setTimeout(o,n);r.addEventListener("abort",()=>{clearTimeout(a),s(new U(B.InvalidRequest,"Request cancelled"))},{once:!0})})}requestTaskStore(t,r){let n=this._taskStore;if(!n)throw new Error("No task store configured");return{createTask:async o=>{if(!t)throw new Error("No request provided");return await n.createTask(o,t.id,{method:t.method,params:t.params},r)},getTask:async o=>{let s=await n.getTask(o,r);if(!s)throw new U(B.InvalidParams,"Failed to retrieve task: Task not found");return s},storeTaskResult:async(o,s,a)=>{await n.storeTaskResult(o,s,a,r);let c=await n.getTask(o,r);if(c){let l=Il.parse({method:"notifications/tasks/status",params:c});await this.notification(l),eo(c.status)&&this._cleanupTaskProgressHandler(o)}},getTaskResult:o=>n.getTaskResult(o,r),updateTaskStatus:async(o,s,a)=>{let c=await n.getTask(o,r);if(!c)throw new U(B.InvalidParams,`Task "${o}" not found - it may have been cleaned up`);if(eo(c.status))throw new U(B.InvalidParams,`Cannot update task "${o}" from terminal status "${c.status}" to "${s}". Terminal states (completed, failed, cancelled) cannot transition to other states.`);await n.updateTaskStatus(o,s,a,r);let l=await n.getTask(o,r);if(l){let u=Il.parse({method:"notifications/tasks/status",params:l});await this.notification(u),eo(l.status)&&this._cleanupTaskProgressHandler(o)}},listTasks:o=>n.listTasks(o,r)}}};i(Xb,"Protocol");var vm=Xb;function nM(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}i(nM,"isPlainObject");function oM(e,t){let r={...e};for(let n in t){let o=n,s=t[o];if(s===void 0)continue;let a=r[o];nM(a)&&nM(s)?r[o]={...a,...s}:r[o]=s}return r}i(oM,"mergeCapabilities");var oL=Hk(Sk(),1),sL=Hk(nL(),1);function cte(){let e=new oL.default({strict:!1,validateFormats:!0,validateSchema:!1,allErrors:!0});return(0,sL.default)(e),e}i(cte,"createDefaultAjvInstance");var Ik=class Ik{constructor(t){this._ajv=t??cte()}getValidator(t){let r="$id"in t&&typeof t.$id=="string"?this._ajv.getSchema(t.$id)??this._ajv.compile(t):this._ajv.compile(t);return n=>r(n)?{valid:!0,data:n,errorMessage:void 0}:{valid:!1,data:void 0,errorMessage:this._ajv.errorsText(r.errors)}}};i(Ik,"AjvJsonSchemaValidator");var nh=Ik;var Pk=class Pk{constructor(t){this._server=t}requestStream(t,r,n){return this._server.requestStream(t,r,n)}createMessageStream(t,r){let n=this._server.getClientCapabilities();if((t.tools||t.toolChoice)&&!n?.sampling?.tools)throw new Error("Client does not support sampling tools capability.");if(t.messages.length>0){let o=t.messages[t.messages.length-1],s=Array.isArray(o.content)?o.content:[o.content],a=s.some(d=>d.type==="tool_result"),c=t.messages.length>1?t.messages[t.messages.length-2]:void 0,l=c?Array.isArray(c.content)?c.content:[c.content]:[],u=l.some(d=>d.type==="tool_use");if(a){if(s.some(d=>d.type!=="tool_result"))throw new Error("The last message must contain only tool_result content if any is present");if(!u)throw new Error("tool_result blocks are not matching any tool_use from the previous message")}if(u){let d=new Set(l.filter(h=>h.type==="tool_use").map(h=>h.id)),p=new Set(s.filter(h=>h.type==="tool_result").map(h=>h.toolUseId));if(d.size!==p.size||![...d].every(h=>p.has(h)))throw new Error("ids of tool_result blocks and tool_use blocks from previous message do not match")}}return this.requestStream({method:"sampling/createMessage",params:t},Ol,r)}elicitInputStream(t,r){let n=this._server.getClientCapabilities(),o=t.mode??"form";switch(o){case"url":{if(!n?.elicitation?.url)throw new Error("Client does not support url elicitation.");break}case"form":{if(!n?.elicitation?.form)throw new Error("Client does not support form elicitation.");break}}let s=o==="form"&&t.mode===void 0?{...t,mode:"form"}:t;return this.requestStream({method:"elicitation/create",params:s},ca,r)}async getTask(t,r){return this._server.getTask({taskId:t},r)}async getTaskResult(t,r,n){return this._server.getTaskResult({taskId:t},r,n)}async listTasks(t,r){return this._server.listTasks(t?{cursor:t}:void 0,r)}async cancelTask(t,r){return this._server.cancelTask({taskId:t},r)}};i(Pk,"ExperimentalServerTasks");var oh=Pk;function iL(e,t,r){if(!e)throw new Error(`${r} does not support task creation (required for ${t})`);switch(t){case"tools/call":if(!e.tools?.call)throw new Error(`${r} does not support task creation for tools/call (required for ${t})`);break;default:break}}i(iL,"assertToolsCallTaskCapability");function aL(e,t,r){if(!e)throw new Error(`${r} does not support task creation (required for ${t})`);switch(t){case"sampling/createMessage":if(!e.sampling?.createMessage)throw new Error(`${r} does not support task creation for sampling/createMessage (required for ${t})`);break;case"elicitation/create":if(!e.elicitation?.create)throw new Error(`${r} does not support task creation for elicitation/create (required for ${t})`);break;default:break}}i(aL,"assertClientRequestTaskCapability");var Rk=class Rk extends vm{constructor(t,r){super(r),this._serverInfo=t,this._loggingLevels=new Map,this.LOG_LEVEL_SEVERITY=new Map(Rl.options.map((n,o)=>[n,o])),this.isMessageIgnored=(n,o)=>{let s=this._loggingLevels.get(o);return s?this.LOG_LEVEL_SEVERITY.get(n)<this.LOG_LEVEL_SEVERITY.get(s):!1},this._capabilities=r?.capabilities??{},this._instructions=r?.instructions,this._jsonSchemaValidator=r?.jsonSchemaValidator??new nh,this.setRequestHandler(Pb,n=>this._oninitialize(n)),this.setNotificationHandler(Rb,()=>this.oninitialized?.()),this._capabilities.logging&&this.setRequestHandler(Lb,async(n,o)=>{let s=o.sessionId||o.requestInfo?.headers["mcp-session-id"]||void 0,{level:a}=n.params,c=Rl.safeParse(a);return c.success&&this._loggingLevels.set(s,c.data),{}})}get experimental(){return this._experimental||(this._experimental={tasks:new oh(this)}),this._experimental}registerCapabilities(t){if(this.transport)throw new Error("Cannot register capabilities after connecting to transport");this._capabilities=oM(this._capabilities,t)}setRequestHandler(t,r){let o=Xn(t)?.method;if(!o)throw new Error("Schema is missing a method literal");let s=na(o);if(typeof s!="string")throw new Error("Schema method literal must be a string");if(s==="tools/call"){let c=i(async(l,u)=>{let d=Yn(aa,l);if(!d.success){let g=d.error instanceof Error?d.error.message:String(d.error);throw new U(B.InvalidParams,`Invalid tools/call request: ${g}`)}let{params:p}=d.data,h=await Promise.resolve(r(l,u));if(p.task){let g=Yn(sa,h);if(!g.success){let _=g.error instanceof Error?g.error.message:String(g.error);throw new U(B.InvalidParams,`Invalid task creation result: ${_}`)}return g.data}let m=Yn(mm,h);if(!m.success){let g=m.error instanceof Error?m.error.message:String(m.error);throw new U(B.InvalidParams,`Invalid tools/call result: ${g}`)}return m.data},"wrappedHandler");return super.setRequestHandler(t,c)}return super.setRequestHandler(t,r)}assertCapabilityForMethod(t){switch(t){case"sampling/createMessage":if(!this._clientCapabilities?.sampling)throw new Error(`Client does not support sampling (required for ${t})`);break;case"elicitation/create":if(!this._clientCapabilities?.elicitation)throw new Error(`Client does not support elicitation (required for ${t})`);break;case"roots/list":if(!this._clientCapabilities?.roots)throw new Error(`Client does not support listing roots (required for ${t})`);break;case"ping":break}}assertNotificationCapability(t){switch(t){case"notifications/message":if(!this._capabilities.logging)throw new Error(`Server does not support logging (required for ${t})`);break;case"notifications/resources/updated":case"notifications/resources/list_changed":if(!this._capabilities.resources)throw new Error(`Server does not support notifying about resources (required for ${t})`);break;case"notifications/tools/list_changed":if(!this._capabilities.tools)throw new Error(`Server does not support notifying of tool list changes (required for ${t})`);break;case"notifications/prompts/list_changed":if(!this._capabilities.prompts)throw new Error(`Server does not support notifying of prompt list changes (required for ${t})`);break;case"notifications/elicitation/complete":if(!this._clientCapabilities?.elicitation?.url)throw new Error(`Client does not support URL elicitation (required for ${t})`);break;case"notifications/cancelled":break;case"notifications/progress":break}}assertRequestHandlerCapability(t){if(this._capabilities)switch(t){case"completion/complete":if(!this._capabilities.completions)throw new Error(`Server does not support completions (required for ${t})`);break;case"logging/setLevel":if(!this._capabilities.logging)throw new Error(`Server does not support logging (required for ${t})`);break;case"prompts/get":case"prompts/list":if(!this._capabilities.prompts)throw new Error(`Server does not support prompts (required for ${t})`);break;case"resources/list":case"resources/templates/list":case"resources/read":if(!this._capabilities.resources)throw new Error(`Server does not support resources (required for ${t})`);break;case"tools/call":case"tools/list":if(!this._capabilities.tools)throw new Error(`Server does not support tools (required for ${t})`);break;case"tasks/get":case"tasks/list":case"tasks/result":case"tasks/cancel":if(!this._capabilities.tasks)throw new Error(`Server does not support tasks capability (required for ${t})`);break;case"ping":case"initialize":break}}assertTaskCapability(t){aL(this._clientCapabilities?.tasks?.requests,t,"Client")}assertTaskHandlerCapability(t){this._capabilities&&iL(this._capabilities.tasks?.requests,t,"Server")}async _oninitialize(t){let r=t.params.protocolVersion;return this._clientCapabilities=t.params.capabilities,this._clientVersion=t.params.clientInfo,{protocolVersion:aD.includes(r)?r:Nb,capabilities:this.getCapabilities(),serverInfo:this._serverInfo,...this._instructions&&{instructions:this._instructions}}}getClientCapabilities(){return this._clientCapabilities}getClientVersion(){return this._clientVersion}getCapabilities(){return this._capabilities}async ping(){return this.request({method:"ping"},Xf)}async createMessage(t,r){if((t.tools||t.toolChoice)&&!this._clientCapabilities?.sampling?.tools)throw new Error("Client does not support sampling tools capability.");if(t.messages.length>0){let n=t.messages[t.messages.length-1],o=Array.isArray(n.content)?n.content:[n.content],s=o.some(u=>u.type==="tool_result"),a=t.messages.length>1?t.messages[t.messages.length-2]:void 0,c=a?Array.isArray(a.content)?a.content:[a.content]:[],l=c.some(u=>u.type==="tool_use");if(s){if(o.some(u=>u.type!=="tool_result"))throw new Error("The last message must contain only tool_result content if any is present");if(!l)throw new Error("tool_result blocks are not matching any tool_use from the previous message")}if(l){let u=new Set(c.filter(p=>p.type==="tool_use").map(p=>p.id)),d=new Set(o.filter(p=>p.type==="tool_result").map(p=>p.toolUseId));if(u.size!==d.size||![...u].every(p=>d.has(p)))throw new Error("ids of tool_result blocks and tool_use blocks from previous message do not match")}}return t.tools?this.request({method:"sampling/createMessage",params:t},Fb,r):this.request({method:"sampling/createMessage",params:t},Ol,r)}async elicitInput(t,r){switch(t.mode??"form"){case"url":{if(!this._clientCapabilities?.elicitation?.url)throw new Error("Client does not support url elicitation.");let o=t;return this.request({method:"elicitation/create",params:o},ca,r)}case"form":{if(!this._clientCapabilities?.elicitation?.form)throw new Error("Client does not support form elicitation.");let o=t.mode==="form"?t:{...t,mode:"form"},s=await this.request({method:"elicitation/create",params:o},ca,r);if(s.action==="accept"&&s.content&&o.requestedSchema)try{let c=this._jsonSchemaValidator.getValidator(o.requestedSchema)(s.content);if(!c.valid)throw new U(B.InvalidParams,`Elicitation response content does not match requested schema: ${c.errorMessage}`)}catch(a){throw a instanceof U?a:new U(B.InternalError,`Error validating elicitation response: ${a instanceof Error?a.message:String(a)}`)}return s}}}createElicitationCompletionNotifier(t,r){if(!this._clientCapabilities?.elicitation?.url)throw new Error("Client does not support URL elicitation (required for notifications/elicitation/complete)");return()=>this.notification({method:"notifications/elicitation/complete",params:{elicitationId:t}},r)}async listRoots(t,r){return this.request({method:"roots/list",params:t},Ub,r)}async sendLoggingMessage(t,r){if(this._capabilities.logging&&!this.isMessageIgnored(t.level,r))return this.notification({method:"notifications/message",params:t})}async sendResourceUpdated(t){return this.notification({method:"notifications/resources/updated",params:t})}async sendResourceListChanged(){return this.notification({method:"notifications/resources/list_changed"})}async sendToolListChanged(){return this.notification({method:"notifications/tools/list_changed"})}async sendPromptListChanged(){return this.notification({method:"notifications/prompts/list_changed"})}};i(Rk,"Server");var sh=Rk;var lL=Symbol.for("mcp.completable");function Ok(e){return!!e&&typeof e=="object"&&lL in e}i(Ok,"isCompletable");function uL(e){return e[lL]?.complete}i(uL,"getCompleter");var cL;(function(e){e.Completable="McpCompletable"})(cL||(cL={}));var lte=/^[A-Za-z0-9._-]{1,128}$/;function ute(e){let t=[];if(e.length===0)return{isValid:!1,warnings:["Tool name cannot be empty"]};if(e.length>128)return{isValid:!1,warnings:[`Tool name exceeds maximum length of 128 characters (current: ${e.length})`]};if(e.includes(" ")&&t.push("Tool name contains spaces, which may cause parsing issues"),e.includes(",")&&t.push("Tool name contains commas, which may cause parsing issues"),(e.startsWith("-")||e.endsWith("-"))&&t.push("Tool name starts or ends with a dash, which may cause parsing issues in some contexts"),(e.startsWith(".")||e.endsWith("."))&&t.push("Tool name starts or ends with a dot, which may cause parsing issues in some contexts"),!lte.test(e)){let r=e.split("").filter(n=>!/[A-Za-z0-9._-]/.test(n)).filter((n,o,s)=>s.indexOf(n)===o);return t.push(`Tool name contains invalid characters: ${r.map(n=>`"${n}"`).join(", ")}`,"Allowed characters are: A-Z, a-z, 0-9, underscore (_), dash (-), and dot (.)"),{isValid:!1,warnings:t}}return{isValid:!0,warnings:t}}i(ute,"validateToolName");function dte(e,t){if(t.length>0){console.warn(`Tool name validation warning for "${e}":`);for(let r of t)console.warn(` - ${r}`);console.warn("Tool registration will proceed, but this may cause compatibility issues."),console.warn("Consider updating the tool name to conform to the MCP tool naming standard."),console.warn("See SEP: Specify Format for Tool Names (https://github.com/modelcontextprotocol/modelcontextprotocol/issues/986) for more details.")}}i(dte,"issueToolNameWarning");function Ak(e){let t=ute(e);return dte(e,t.warnings),t.isValid}i(Ak,"validateAndWarnToolName");var jk=class jk{constructor(t){this._mcpServer=t}registerToolTask(t,r,n){let o={taskSupport:"required",...r.execution};if(o.taskSupport==="forbidden")throw new Error(`Cannot register task-based tool '${t}' with taskSupport 'forbidden'. Use registerTool() instead.`);return this._mcpServer._createRegisteredTool(t,r.title,r.description,r.inputSchema,r.outputSchema,r.annotations,o,r._meta,n)}};i(jk,"ExperimentalMcpServerTasks");var ih=jk;var Mk=class Mk{constructor(t,r){this._registeredResources={},this._registeredResourceTemplates={},this._registeredTools={},this._registeredPrompts={},this._toolHandlersInitialized=!1,this._completionHandlerInitialized=!1,this._resourceHandlersInitialized=!1,this._promptHandlersInitialized=!1,this.server=new sh(t,r)}get experimental(){return this._experimental||(this._experimental={tasks:new ih(this)}),this._experimental}async connect(t){return await this.server.connect(t)}async close(){await this.server.close()}setToolRequestHandlers(){this._toolHandlersInitialized||(this.server.assertCanSetRequestHandler(lo(fm)),this.server.assertCanSetRequestHandler(lo(aa)),this.server.registerCapabilities({tools:{listChanged:!0}}),this.server.setRequestHandler(fm,()=>({tools:Object.entries(this._registeredTools).filter(([,t])=>t.enabled).map(([t,r])=>{let n={name:t,title:r.title,description:r.description,inputSchema:(()=>{let o=ra(r.inputSchema);return o?Kb(o,{strictUnions:!0,pipeStrategy:"input"}):pte})(),annotations:r.annotations,execution:r.execution,_meta:r._meta};if(r.outputSchema){let o=ra(r.outputSchema);o&&(n.outputSchema=Kb(o,{strictUnions:!0,pipeStrategy:"output"}))}return n})})),this.server.setRequestHandler(aa,async(t,r)=>{try{let n=this._registeredTools[t.params.name];if(!n)throw new U(B.InvalidParams,`Tool ${t.params.name} not found`);if(!n.enabled)throw new U(B.InvalidParams,`Tool ${t.params.name} disabled`);let o=!!t.params.task,s=n.execution?.taskSupport,a="createTask"in n.handler;if((s==="required"||s==="optional")&&!a)throw new U(B.InternalError,`Tool ${t.params.name} has taskSupport '${s}' but was not registered with registerToolTask`);if(s==="required"&&!o)throw new U(B.MethodNotFound,`Tool ${t.params.name} requires task augmentation (taskSupport: 'required')`);if(s==="optional"&&!o&&a)return await this.handleAutomaticTaskPolling(n,t,r);let c=await this.validateToolInput(n,t.params.arguments,t.params.name),l=await this.executeToolHandler(n,c,r);return o||await this.validateToolOutput(n,l,t.params.name),l}catch(n){if(n instanceof U&&n.code===B.UrlElicitationRequired)throw n;return this.createToolError(n instanceof Error?n.message:String(n))}}),this._toolHandlersInitialized=!0)}createToolError(t){return{content:[{type:"text",text:t}],isError:!0}}async validateToolInput(t,r,n){if(!t.inputSchema)return;let s=ra(t.inputSchema)??t.inputSchema,a=await Hf(s,r);if(!a.success){let c="error"in a?a.error:"Unknown error",l=Bf(c);throw new U(B.InvalidParams,`Input validation error: Invalid arguments for tool ${n}: ${l}`)}return a.data}async validateToolOutput(t,r,n){if(!t.outputSchema||!("content"in r)||r.isError)return;if(!r.structuredContent)throw new U(B.InvalidParams,`Output validation error: Tool ${n} has an output schema but no structured content was provided`);let o=ra(t.outputSchema),s=await Hf(o,r.structuredContent);if(!s.success){let a="error"in s?s.error:"Unknown error",c=Bf(a);throw new U(B.InvalidParams,`Output validation error: Invalid structured content for tool ${n}: ${c}`)}}async executeToolHandler(t,r,n){let o=t.handler;if("createTask"in o){if(!n.taskStore)throw new Error("No task store provided.");let a={...n,taskStore:n.taskStore};if(t.inputSchema){let c=o;return await Promise.resolve(c.createTask(r,a))}else{let c=o;return await Promise.resolve(c.createTask(a))}}if(t.inputSchema){let a=o;return await Promise.resolve(a(r,n))}else{let a=o;return await Promise.resolve(a(n))}}async handleAutomaticTaskPolling(t,r,n){if(!n.taskStore)throw new Error("No task store provided for task-capable tool.");let o=await this.validateToolInput(t,r.params.arguments,r.params.name),s=t.handler,a={...n,taskStore:n.taskStore},c=o?await Promise.resolve(s.createTask(o,a)):await Promise.resolve(s.createTask(a)),l=c.task.taskId,u=c.task,d=u.pollInterval??5e3;for(;u.status!=="completed"&&u.status!=="failed"&&u.status!=="cancelled";){await new Promise(h=>setTimeout(h,d));let p=await n.taskStore.getTask(l);if(!p)throw new U(B.InternalError,`Task ${l} not found during polling`);u=p}return await n.taskStore.getTaskResult(l)}setCompletionRequestHandler(){this._completionHandlerInitialized||(this.server.assertCanSetRequestHandler(lo(hm)),this.server.registerCapabilities({completions:{}}),this.server.setRequestHandler(hm,async t=>{switch(t.params.ref.type){case"ref/prompt":return SD(t),this.handlePromptCompletion(t,t.params.ref);case"ref/resource":return kD(t),this.handleResourceCompletion(t,t.params.ref);default:throw new U(B.InvalidParams,`Invalid completion reference: ${t.params.ref}`)}}),this._completionHandlerInitialized=!0)}async handlePromptCompletion(t,r){let n=this._registeredPrompts[r.name];if(!n)throw new U(B.InvalidParams,`Prompt ${r.name} not found`);if(!n.enabled)throw new U(B.InvalidParams,`Prompt ${r.name} disabled`);if(!n.argsSchema)return pu;let s=Xn(n.argsSchema)?.[t.params.argument.name];if(!Ok(s))return pu;let a=uL(s);if(!a)return pu;let c=await a(t.params.argument.value,t.params.context);return pL(c)}async handleResourceCompletion(t,r){let n=Object.values(this._registeredResourceTemplates).find(a=>a.resourceTemplate.uriTemplate.toString()===r.uri);if(!n){if(this._registeredResources[r.uri])return pu;throw new U(B.InvalidParams,`Resource template ${t.params.ref.uri} not found`)}let o=n.resourceTemplate.completeCallback(t.params.argument.name);if(!o)return pu;let s=await o(t.params.argument.value,t.params.context);return pL(s)}setResourceRequestHandlers(){this._resourceHandlersInitialized||(this.server.assertCanSetRequestHandler(lo(cm)),this.server.assertCanSetRequestHandler(lo(lm)),this.server.assertCanSetRequestHandler(lo(um)),this.server.registerCapabilities({resources:{listChanged:!0}}),this.server.setRequestHandler(cm,async(t,r)=>{let n=Object.entries(this._registeredResources).filter(([s,a])=>a.enabled).map(([s,a])=>({uri:s,name:a.name,...a.metadata})),o=[];for(let s of Object.values(this._registeredResourceTemplates)){if(!s.resourceTemplate.listCallback)continue;let a=await s.resourceTemplate.listCallback(r);for(let c of a.resources)o.push({...s.metadata,...c})}return{resources:[...n,...o]}}),this.server.setRequestHandler(lm,async()=>({resourceTemplates:Object.entries(this._registeredResourceTemplates).map(([r,n])=>({name:r,uriTemplate:n.resourceTemplate.uriTemplate.toString(),...n.metadata}))})),this.server.setRequestHandler(um,async(t,r)=>{let n=new URL(t.params.uri),o=this._registeredResources[n.toString()];if(o){if(!o.enabled)throw new U(B.InvalidParams,`Resource ${n} disabled`);return o.readCallback(n,r)}for(let s of Object.values(this._registeredResourceTemplates)){let a=s.resourceTemplate.uriTemplate.match(n.toString());if(a)return s.readCallback(n,a,r)}throw new U(B.InvalidParams,`Resource ${n} not found`)}),this._resourceHandlersInitialized=!0)}setPromptRequestHandlers(){this._promptHandlersInitialized||(this.server.assertCanSetRequestHandler(lo(dm)),this.server.assertCanSetRequestHandler(lo(pm)),this.server.registerCapabilities({prompts:{listChanged:!0}}),this.server.setRequestHandler(dm,()=>({prompts:Object.entries(this._registeredPrompts).filter(([,t])=>t.enabled).map(([t,r])=>({name:t,title:r.title,description:r.description,arguments:r.argsSchema?fte(r.argsSchema):void 0}))})),this.server.setRequestHandler(pm,async(t,r)=>{let n=this._registeredPrompts[t.params.name];if(!n)throw new U(B.InvalidParams,`Prompt ${t.params.name} not found`);if(!n.enabled)throw new U(B.InvalidParams,`Prompt ${t.params.name} disabled`);if(n.argsSchema){let o=ra(n.argsSchema),s=await Hf(o,t.params.arguments);if(!s.success){let l="error"in s?s.error:"Unknown error",u=Bf(l);throw new U(B.InvalidParams,`Invalid arguments for prompt ${t.params.name}: ${u}`)}let a=s.data,c=n.callback;return await Promise.resolve(c(a,r))}else{let o=n.callback;return await Promise.resolve(o(r))}}),this._promptHandlersInitialized=!0)}resource(t,r,...n){let o;typeof n[0]=="object"&&(o=n.shift());let s=n[0];if(typeof r=="string"){if(this._registeredResources[r])throw new Error(`Resource ${r} is already registered`);let a=this._createRegisteredResource(t,void 0,r,o,s);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),a}else{if(this._registeredResourceTemplates[t])throw new Error(`Resource template ${t} is already registered`);let a=this._createRegisteredResourceTemplate(t,void 0,r,o,s);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),a}}registerResource(t,r,n,o){if(typeof r=="string"){if(this._registeredResources[r])throw new Error(`Resource ${r} is already registered`);let s=this._createRegisteredResource(t,n.title,r,n,o);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),s}else{if(this._registeredResourceTemplates[t])throw new Error(`Resource template ${t} is already registered`);let s=this._createRegisteredResourceTemplate(t,n.title,r,n,o);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),s}}_createRegisteredResource(t,r,n,o,s){let a={name:t,title:r,metadata:o,readCallback:s,enabled:!0,disable:()=>a.update({enabled:!1}),enable:()=>a.update({enabled:!0}),remove:()=>a.update({uri:null}),update:c=>{typeof c.uri<"u"&&c.uri!==n&&(delete this._registeredResources[n],c.uri&&(this._registeredResources[c.uri]=a)),typeof c.name<"u"&&(a.name=c.name),typeof c.title<"u"&&(a.title=c.title),typeof c.metadata<"u"&&(a.metadata=c.metadata),typeof c.callback<"u"&&(a.readCallback=c.callback),typeof c.enabled<"u"&&(a.enabled=c.enabled),this.sendResourceListChanged()}};return this._registeredResources[n]=a,a}_createRegisteredResourceTemplate(t,r,n,o,s){let a={resourceTemplate:n,title:r,metadata:o,readCallback:s,enabled:!0,disable:()=>a.update({enabled:!1}),enable:()=>a.update({enabled:!0}),remove:()=>a.update({name:null}),update:u=>{typeof u.name<"u"&&u.name!==t&&(delete this._registeredResourceTemplates[t],u.name&&(this._registeredResourceTemplates[u.name]=a)),typeof u.title<"u"&&(a.title=u.title),typeof u.template<"u"&&(a.resourceTemplate=u.template),typeof u.metadata<"u"&&(a.metadata=u.metadata),typeof u.callback<"u"&&(a.readCallback=u.callback),typeof u.enabled<"u"&&(a.enabled=u.enabled),this.sendResourceListChanged()}};this._registeredResourceTemplates[t]=a;let c=n.uriTemplate.variableNames;return Array.isArray(c)&&c.some(u=>!!n.completeCallback(u))&&this.setCompletionRequestHandler(),a}_createRegisteredPrompt(t,r,n,o,s){let a={title:r,description:n,argsSchema:o===void 0?void 0:xs(o),callback:s,enabled:!0,disable:()=>a.update({enabled:!1}),enable:()=>a.update({enabled:!0}),remove:()=>a.update({name:null}),update:c=>{typeof c.name<"u"&&c.name!==t&&(delete this._registeredPrompts[t],c.name&&(this._registeredPrompts[c.name]=a)),typeof c.title<"u"&&(a.title=c.title),typeof c.description<"u"&&(a.description=c.description),typeof c.argsSchema<"u"&&(a.argsSchema=xs(c.argsSchema)),typeof c.callback<"u"&&(a.callback=c.callback),typeof c.enabled<"u"&&(a.enabled=c.enabled),this.sendPromptListChanged()}};return this._registeredPrompts[t]=a,o&&Object.values(o).some(l=>{let u=l instanceof kt?l._def?.innerType:l;return Ok(u)})&&this.setCompletionRequestHandler(),a}_createRegisteredTool(t,r,n,o,s,a,c,l,u){Ak(t);let d={title:r,description:n,inputSchema:dL(o),outputSchema:dL(s),annotations:a,execution:c,_meta:l,handler:u,enabled:!0,disable:()=>d.update({enabled:!1}),enable:()=>d.update({enabled:!0}),remove:()=>d.update({name:null}),update:p=>{typeof p.name<"u"&&p.name!==t&&(typeof p.name=="string"&&Ak(p.name),delete this._registeredTools[t],p.name&&(this._registeredTools[p.name]=d)),typeof p.title<"u"&&(d.title=p.title),typeof p.description<"u"&&(d.description=p.description),typeof p.paramsSchema<"u"&&(d.inputSchema=xs(p.paramsSchema)),typeof p.outputSchema<"u"&&(d.outputSchema=xs(p.outputSchema)),typeof p.callback<"u"&&(d.handler=p.callback),typeof p.annotations<"u"&&(d.annotations=p.annotations),typeof p._meta<"u"&&(d._meta=p._meta),typeof p.enabled<"u"&&(d.enabled=p.enabled),this.sendToolListChanged()}};return this._registeredTools[t]=d,this.setToolRequestHandlers(),this.sendToolListChanged(),d}tool(t,...r){if(this._registeredTools[t])throw new Error(`Tool ${t} is already registered`);let n,o,s,a;if(typeof r[0]=="string"&&(n=r.shift()),r.length>1){let l=r[0];if(Dk(l))o=r.shift(),r.length>1&&typeof r[0]=="object"&&r[0]!==null&&!Dk(r[0])&&(a=r.shift());else if(typeof l=="object"&&l!==null){if(Object.values(l).some(u=>typeof u=="object"&&u!==null))throw new Error(`Tool ${t} expected a Zod schema or ToolAnnotations, but received an unrecognized object`);a=r.shift()}}let c=r[0];return this._createRegisteredTool(t,void 0,n,o,s,a,{taskSupport:"forbidden"},void 0,c)}registerTool(t,r,n){if(this._registeredTools[t])throw new Error(`Tool ${t} is already registered`);let{title:o,description:s,inputSchema:a,outputSchema:c,annotations:l,_meta:u}=r;return this._createRegisteredTool(t,o,s,a,c,l,{taskSupport:"forbidden"},u,n)}prompt(t,...r){if(this._registeredPrompts[t])throw new Error(`Prompt ${t} is already registered`);let n;typeof r[0]=="string"&&(n=r.shift());let o;r.length>1&&(o=r.shift());let s=r[0],a=this._createRegisteredPrompt(t,void 0,n,o,s);return this.setPromptRequestHandlers(),this.sendPromptListChanged(),a}registerPrompt(t,r,n){if(this._registeredPrompts[t])throw new Error(`Prompt ${t} is already registered`);let{title:o,description:s,argsSchema:a}=r,c=this._createRegisteredPrompt(t,o,s,a,n);return this.setPromptRequestHandlers(),this.sendPromptListChanged(),c}isConnected(){return this.server.transport!==void 0}async sendLoggingMessage(t,r){return this.server.sendLoggingMessage(t,r)}sendResourceListChanged(){this.isConnected()&&this.server.sendResourceListChanged()}sendToolListChanged(){this.isConnected()&&this.server.sendToolListChanged()}sendPromptListChanged(){this.isConnected()&&this.server.sendPromptListChanged()}};i(Mk,"McpServer");var ah=Mk;var pte={type:"object",properties:{}};function fL(e){return e!==null&&typeof e=="object"&&"parse"in e&&typeof e.parse=="function"&&"safeParse"in e&&typeof e.safeParse=="function"}i(fL,"isZodTypeLike");function mL(e){return"_def"in e||"_zod"in e||fL(e)}i(mL,"isZodSchemaInstance");function Dk(e){return typeof e!="object"||e===null||mL(e)?!1:Object.keys(e).length===0?!0:Object.values(e).some(fL)}i(Dk,"isZodRawShapeCompat");function dL(e){if(e){if(Dk(e))return xs(e);if(!mL(e))throw new Error("inputSchema must be a Zod schema or raw shape, received an unrecognized object");return e}}i(dL,"getZodSchemaObject");function fte(e){let t=Xn(e);return t?Object.entries(t).map(([r,n])=>{let o=Dj(n),s=Mj(n);return{name:r,description:o,required:!s}}):[]}i(fte,"promptArgumentsFromSchema");function lo(e){let r=Xn(e)?.method;if(!r)throw new Error("Schema is missing a method literal");let n=na(r);if(typeof n=="string")return n;throw new Error("Schema method literal must be a string")}i(lo,"getMethodValue");function pL(e){return{completion:{values:e.slice(0,100),total:e.length,hasMore:e.length>100}}}i(pL,"createCompletionResult");var pu={completion:{values:[],hasMore:!1}};import gL from"process";var mte=10*1024*1024,Zk=class Zk{constructor(t){this._maxBufferSize=t?.maxBufferSize??mte}append(t){if((this._buffer?.length??0)+t.length>this._maxBufferSize)throw this.clear(),new Error(`ReadBuffer exceeded maximum size of ${this._maxBufferSize} bytes`);this._buffer=this._buffer?Buffer.concat([this._buffer,t]):t}readMessage(){if(!this._buffer)return null;let t=this._buffer.indexOf(`
297
- `);if(t===-1)return null;let r=this._buffer.toString("utf8",0,t).replace(/\r$/,"");return this._buffer=this._buffer.subarray(t+1),hte(r)}clear(){this._buffer=void 0}};i(Zk,"ReadBuffer");var ch=Zk;function hte(e){return hD.parse(JSON.parse(e))}i(hte,"deserializeMessage");function hL(e){return JSON.stringify(e)+`
298
- `}i(hL,"serializeMessage");var Lk=class Lk{constructor(t=gL.stdin,r=gL.stdout,n){this._stdin=t,this._stdout=r,this._started=!1,this._ondata=o=>{try{this._readBuffer.append(o),this.processReadBuffer()}catch(s){this.onerror?.(s),this.close().catch(()=>{})}},this._onerror=o=>{this.onerror?.(o)},this._readBuffer=new ch({maxBufferSize:n?.maxBufferSize})}async start(){if(this._started)throw new Error("StdioServerTransport already started! If using Server class, note that connect() calls start() automatically.");this._started=!0,this._stdin.on("data",this._ondata),this._stdin.on("error",this._onerror)}processReadBuffer(){for(;;)try{let t=this._readBuffer.readMessage();if(t===null)break;this.onmessage?.(t)}catch(t){this.onerror?.(t)}}async close(){this._stdin.off("data",this._ondata),this._stdin.off("error",this._onerror),this._stdin.listenerCount("data")===0&&this._stdin.pause(),this._readBuffer.clear(),this.onclose?.()}send(t){return new Promise(r=>{let n=hL(t);this._stdout.write(n)?r():this._stdout.once("drain",r)})}};i(Lk,"StdioServerTransport");var lh=Lk;mf();vn();import{resolve as gte}from"path";async function yte(e,t=2e3){let r=new AbortController,n=setTimeout(()=>r.abort(),t);try{return(await fetch(`${e.replace(/\/+$/,"")}/mcp/scene?root=app&depth=0`,{signal:r.signal})).ok}catch{return!1}finally{clearTimeout(n)}}i(yte,"verifyDesignServer");async function yL({projectPath:e}={}){let t=e?{projectRoot:gte(e)}:Gy(process.cwd());if(!t?.projectRoot)throw new Error("Not a Jucie project. Use --project <path>");let r=Ky(t.projectRoot);if(!r)throw new Error("No active design session. Run: jucie design");if(!Jy(r))throw new Error("Design session expired. Run: jucie design");let n=typeof r.url=="string"?r.url:null;if(!n)throw new Error("No active design session. Run: jucie design");if(!await yte(n))throw new Error("Design server not responding. Is jucie design still running?");return{projectRoot:t.projectRoot,url:n}}i(yL,"resolveMcpEndpoint");async function xL(e={}){let t;try{t=await yL({projectPath:e.project})}catch(h){console.error(`
299
- \u274C ${h.message}
300
- `),process.exit(1)}let r=t.url.replace(/\/+$/,"");async function n({root:h="app",depth:m}={}){let g=new URLSearchParams({root:h});m!=null&&g.set("depth",String(m));let _=await fetch(`${r}/mcp/scene?${g}`);if(!_.ok)throw new Error(`design server returned ${_.status}`);return _.json()}i(n,"getScene");async function o(h){let m=await fetch(`${r}/mcp/operations`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({operations:h})});if(!m.ok)throw new Error(`design server returned ${m.status}`);return m.json()}i(o,"postOperations");let s={String:()=>ze.string(),Number:()=>ze.number(),Boolean:()=>ze.boolean(),Object:()=>ze.record(ze.unknown()),Array:()=>ze.array(ze.unknown()),Any:()=>ze.unknown()};function a(h){let m=Array.isArray(h)?h[0]:null;if(!m||typeof m!="object")return{};let g={};for(let[_,x]of Object.entries(m)){let v=typeof x=="string"&&x.endsWith("?"),w=v?x.slice(0,-1):x,b=(s[w]??s.Any)();v&&(b=b.optional()),g[_]=b}return g}i(a,"toZodShape");function c(h){let m=[h.description];if(h.examples?.length){let g=h.examples[0];m.push(`Example args: ${JSON.stringify(g.args)}`)}return h.returns&&m.push(`Returns: ${h.returns}`),m.filter(Boolean).join(`
301
- `)}i(c,"buildToolDescription");let l=new ah({name:"jucie",version:"0.1.0"}),u=i(h=>async m=>{try{return{content:[{type:"text",text:await h(m)}]}}catch(g){return{isError:!0,content:[{type:"text",text:`Error: ${g.message}`}]}}},"tool"),d=j_.map(h=>Mr(h));for(let h of d)for(let m of h.operations)m.mcpName&&l.registerTool(m.mcpName,{description:c(m),inputSchema:a(m.schema)},u(async g=>{let{results:_}=await o([{type:m.fullName,args:g}]);return JSON.stringify(_[0])}));l.registerTool("get_scene",{description:'Read the current scene graph as JSX. Use root="app" for the full tree or a node id for a subtree. depth limits nesting (omit for unlimited).',inputSchema:{root:ze.string().optional().describe("Root node id (default: app)"),depth:ze.number().optional().describe("Max depth to expand (omit for full tree)")}},u(async h=>{let m=await n(h);return m.jsx??m.error??JSON.stringify(m)})),l.registerTool("set_route",{description:"Set the route path on a frame node. Use this to configure multi-page navigation. Pass isHome=true to mark it as the home/root route.",inputSchema:{nodeId:ze.string().describe("Frame node id"),path:ze.string().optional().describe('Route path, e.g. "/dashboard" or "/users/:id"'),isHome:ze.boolean().optional().describe("If true, marks this frame as the home route (path becomes /)")}},u(async({nodeId:h,path:m,isHome:g})=>{let _=[];g?_.push({op:"setHomePage",nodeId:h,isHomePage:!0}):m!==void 0&&_.push({op:"updateRoute",nodeId:h,route:{path:m}});let{results:x}=await o(_);return JSON.stringify(x)})),l.registerTool("set_destination",{description:"Set a navigation destination on a link or button node. When the node is clicked it will navigate to the given path.",inputSchema:{nodeId:ze.string().describe("Target node id (a or button)"),path:ze.string().describe('Route path to navigate to, e.g. "/sign-up"')}},u(async({nodeId:h,path:m})=>{let{results:g}=await o([{op:"setDestination",nodeId:h,destination:{path:m}}]);return JSON.stringify(g[0])})),l.registerTool("create_instance",{description:"Place an instance of a component into the scene. Use componentId (from add_component) for local components. Use component name + library for external library components.",inputSchema:{component:ze.string().describe("Component node id (local) or component name string (library)"),parent:ze.string().describe("Parent node id"),library:ze.string().optional().describe('Library name for external components (e.g. "my-ui"). Omit for local components.'),name:ze.string().optional().describe("Display name for the instance")}},u(async({component:h,parent:m,library:g,name:_})=>{let{results:x}=await o([{op:"create",type:"instance",parent:m,props:{component:h,library:g??null,name:_}}]);return JSON.stringify(x[0])})),l.registerTool("batch",{description:tf(d),inputSchema:{operations:ze.array(ze.record(ze.unknown())).describe("Ordered array of operation objects")}},u(async({operations:h})=>{let{results:m}=await o(h);return JSON.stringify(m)})),l.registerTool("screenshot",{description:"Capture a screenshot of every frame (page) in the current design. Returns one labeled image per frame so you can visually verify each page and correlate it with get_scene output by node id.",inputSchema:{}},async()=>{try{let h=await fetch(`${r}/mcp/screenshot`);if(!h.ok)throw new Error(`screenshot failed: ${h.status}`);let{frames:m,error:g}=await h.json();return g?{isError:!0,content:[{type:"text",text:`Error: ${g}`}]}:m?.length?{content:m.flatMap(x=>[{type:"text",text:`Frame: ${x.name} (id: ${x.id})`},{type:"image",data:x.imageData.replace(/^data:image\/\w+;base64,/,""),mimeType:"image/png"}])}:{isError:!0,content:[{type:"text",text:"No frames found in scene"}]}}catch(h){return{isError:!0,content:[{type:"text",text:`Error: ${h.message}`}]}}});let p=new lh;await l.connect(p)}i(xL,"mcpCommand");var bte=wte(import.meta.url),Ste=vte(bte),qk=JSON.parse(xte(_te(Ste,"../package.json"),"utf8")),qt=process.argv.slice(2),Fk=qt[0],_L=qt[1],Is={help:qt.includes("--help")||qt.includes("-h"),version:qt.includes("--version")||qt.includes("-v"),verbose:qt.includes("--verbose")};function fu(e,t){let r=qt.indexOf(`--${e}`),n=t?qt.indexOf(`-${t}`):-1,o=r!==-1?r:n;if(o!==-1&&qt[o+1]&&!qt[o+1].startsWith("-"))return qt[o+1]}i(fu,"getOption");function Uk(e){return qt.includes(`--${e}`)}i(Uk,"hasFlag");var uh={config:fu("config"),outdir:fu("outdir","o"),branch:fu("branch","b"),framework:fu("framework","f"),minify:Uk("minify")?!0:void 0,sourcemap:Uk("sourcemap"),analyze:Uk("analyze")};function vL(){console.log(`
302
- Jucie CLI v${qk.version}
356
+ ]`;continue}o+=n[l],n[l]==="\\"?s=!0:a&&n[l]==="]"?a=!1:!a&&n[l]==="["&&(a=!0)}try{new RegExp(o)}catch{return console.warn(`Could not convert regex pattern at ${t.currentPath.join("/")} to a flag-independent form! Falling back to the flag-ignorant source`),e.source}return o}i(XL,"stringifyRegExpWithFlags");function wg(e,t){if(t.target==="openAi"&&console.warn("Warning: OpenAI may not support records in schemas! Try an array of key-value pairs instead."),t.target==="openApi3"&&e.keyType?._def.typeName===j.ZodEnum)return{type:"object",required:e.keyType._def.values,properties:e.keyType._def.values.reduce((n,o)=>({...n,[o]:Q(e.valueType._def,{...t,currentPath:[...t.currentPath,"properties",o]})??Ue(t)}),{}),additionalProperties:t.rejectedAdditionalProperties};let r={type:"object",additionalProperties:Q(e.valueType._def,{...t,currentPath:[...t.currentPath,"additionalProperties"]})??t.allowedAdditionalProperties};if(t.target==="openApi3")return r;if(e.keyType?._def.typeName===j.ZodString&&e.keyType._def.checks?.length){let{type:n,...o}=vg(e.keyType._def,t);return{...r,propertyNames:o}}else{if(e.keyType?._def.typeName===j.ZodEnum)return{...r,propertyNames:{enum:e.keyType._def.values}};if(e.keyType?._def.typeName===j.ZodBranded&&e.keyType._def.type._def.typeName===j.ZodString&&e.keyType._def.type._def.checks?.length){let{type:n,...o}=_g(e.keyType._def,t);return{...r,propertyNames:o}}}return r}i(wg,"parseRecordDef");function QL(e,t){if(t.mapStrategy==="record")return wg(e,t);let r=Q(e.keyType._def,{...t,currentPath:[...t.currentPath,"items","items","0"]})||Ue(t),n=Q(e.valueType._def,{...t,currentPath:[...t.currentPath,"items","items","1"]})||Ue(t);return{type:"array",maxItems:125,items:{type:"array",items:[r,n],minItems:2,maxItems:2}}}i(QL,"parseMapDef");function eF(e){let t=e.values,n=Object.keys(e.values).filter(s=>typeof t[t[s]]!="number").map(s=>t[s]),o=Array.from(new Set(n.map(s=>typeof s)));return{type:o.length===1?o[0]==="string"?"string":"number":["string","number"],enum:n}}i(eF,"parseNativeEnumDef");function tF(e){return e.target==="openAi"?void 0:{not:Ue({...e,currentPath:[...e.currentPath,"not"]})}}i(tF,"parseNeverDef");function rF(e){return e.target==="openApi3"?{enum:["null"],nullable:!0}:{type:"null"}}i(rF,"parseNullDef");var cd={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"};function oF(e,t){if(t.target==="openApi3")return nF(e,t);let r=e.options instanceof Map?Array.from(e.options.values()):e.options;if(r.every(n=>n._def.typeName in cd&&(!n._def.checks||!n._def.checks.length))){let n=r.reduce((o,s)=>{let a=cd[s._def.typeName];return a&&!o.includes(a)?[...o,a]:o},[]);return{type:n.length>1?n:n[0]}}else if(r.every(n=>n._def.typeName==="ZodLiteral"&&!n.description)){let n=r.reduce((o,s)=>{let a=typeof s._def.value;switch(a){case"string":case"number":case"boolean":return[...o,a];case"bigint":return[...o,"integer"];case"object":if(s._def.value===null)return[...o,"null"];case"symbol":case"undefined":case"function":default:return o}},[]);if(n.length===r.length){let o=n.filter((s,a,c)=>c.indexOf(s)===a);return{type:o.length>1?o:o[0],enum:r.reduce((s,a)=>s.includes(a._def.value)?s:[...s,a._def.value],[])}}}else if(r.every(n=>n._def.typeName==="ZodEnum"))return{type:"string",enum:r.reduce((n,o)=>[...n,...o._def.values.filter(s=>!n.includes(s))],[])};return nF(e,t)}i(oF,"parseUnionDef");var nF=i((e,t)=>{let r=(e.options instanceof Map?Array.from(e.options.values()):e.options).map((n,o)=>Q(n._def,{...t,currentPath:[...t.currentPath,"anyOf",`${o}`]})).filter(n=>!!n&&(!t.strictUnions||typeof n=="object"&&Object.keys(n).length>0));return r.length?{anyOf:r}:void 0},"asAnyOf");function sF(e,t){if(["ZodString","ZodNumber","ZodBigInt","ZodBoolean","ZodNull"].includes(e.innerType._def.typeName)&&(!e.innerType._def.checks||!e.innerType._def.checks.length))return t.target==="openApi3"?{type:cd[e.innerType._def.typeName],nullable:!0}:{type:[cd[e.innerType._def.typeName],"null"]};if(t.target==="openApi3"){let n=Q(e.innerType._def,{...t,currentPath:[...t.currentPath]});return n&&"$ref"in n?{allOf:[n],nullable:!0}:n&&{...n,nullable:!0}}let r=Q(e.innerType._def,{...t,currentPath:[...t.currentPath,"anyOf","0"]});return r&&{anyOf:[r,{type:"null"}]}}i(sF,"parseNullableDef");function iF(e,t){let r={type:"number"};if(!e.checks)return r;for(let n of e.checks)switch(n.kind){case"int":r.type="integer",gk(r,"type",n.message,t);break;case"min":t.target==="jsonSchema7"?n.inclusive?pe(r,"minimum",n.value,n.message,t):pe(r,"exclusiveMinimum",n.value,n.message,t):(n.inclusive||(r.exclusiveMinimum=!0),pe(r,"minimum",n.value,n.message,t));break;case"max":t.target==="jsonSchema7"?n.inclusive?pe(r,"maximum",n.value,n.message,t):pe(r,"exclusiveMaximum",n.value,n.message,t):(n.inclusive||(r.exclusiveMaximum=!0),pe(r,"maximum",n.value,n.message,t));break;case"multipleOf":pe(r,"multipleOf",n.value,n.message,t);break}return r}i(iF,"parseNumberDef");function aF(e,t){let r=t.target==="openAi",n={type:"object",properties:{}},o=[],s=e.shape();for(let c in s){let l=s[c];if(l===void 0||l._def===void 0)continue;let u=Yee(l);u&&r&&(l._def.typeName==="ZodOptional"&&(l=l._def.innerType),l.isNullable()||(l=l.nullable()),u=!1);let d=Q(l._def,{...t,currentPath:[...t.currentPath,"properties",c],propertyPath:[...t.currentPath,"properties",c]});d!==void 0&&(n.properties[c]=d,u||o.push(c))}o.length&&(n.required=o);let a=Kee(e,t);return a!==void 0&&(n.additionalProperties=a),n}i(aF,"parseObjectDef");function Kee(e,t){if(e.catchall._def.typeName!=="ZodNever")return Q(e.catchall._def,{...t,currentPath:[...t.currentPath,"additionalProperties"]});switch(e.unknownKeys){case"passthrough":return t.allowedAdditionalProperties;case"strict":return t.rejectedAdditionalProperties;case"strip":return t.removeAdditionalStrategy==="strict"?t.allowedAdditionalProperties:t.rejectedAdditionalProperties}}i(Kee,"decideAdditionalProperties");function Yee(e){try{return e.isOptional()}catch{return!0}}i(Yee,"safeIsOptional");var cF=i((e,t)=>{if(t.currentPath.toString()===t.propertyPath?.toString())return Q(e.innerType._def,t);let r=Q(e.innerType._def,{...t,currentPath:[...t.currentPath,"anyOf","1"]});return r?{anyOf:[{not:Ue(t)},r]}:Ue(t)},"parseOptionalDef");var lF=i((e,t)=>{if(t.pipeStrategy==="input")return Q(e.in._def,t);if(t.pipeStrategy==="output")return Q(e.out._def,t);let r=Q(e.in._def,{...t,currentPath:[...t.currentPath,"allOf","0"]}),n=Q(e.out._def,{...t,currentPath:[...t.currentPath,"allOf",r?"1":"0"]});return{allOf:[r,n].filter(o=>o!==void 0)}},"parsePipelineDef");function uF(e,t){return Q(e.type._def,t)}i(uF,"parsePromiseDef");function dF(e,t){let n={type:"array",uniqueItems:!0,items:Q(e.valueType._def,{...t,currentPath:[...t.currentPath,"items"]})};return e.minSize&&pe(n,"minItems",e.minSize.value,e.minSize.message,t),e.maxSize&&pe(n,"maxItems",e.maxSize.value,e.maxSize.message,t),n}i(dF,"parseSetDef");function pF(e,t){return e.rest?{type:"array",minItems:e.items.length,items:e.items.map((r,n)=>Q(r._def,{...t,currentPath:[...t.currentPath,"items",`${n}`]})).reduce((r,n)=>n===void 0?r:[...r,n],[]),additionalItems:Q(e.rest._def,{...t,currentPath:[...t.currentPath,"additionalItems"]})}:{type:"array",minItems:e.items.length,maxItems:e.items.length,items:e.items.map((r,n)=>Q(r._def,{...t,currentPath:[...t.currentPath,"items",`${n}`]})).reduce((r,n)=>n===void 0?r:[...r,n],[])}}i(pF,"parseTupleDef");function fF(e){return{not:Ue(e)}}i(fF,"parseUndefinedDef");function mF(e){return Ue(e)}i(mF,"parseUnknownDef");var hF=i((e,t)=>Q(e.innerType._def,t),"parseReadonlyDef");var gF=i((e,t,r)=>{switch(t){case j.ZodString:return vg(e,r);case j.ZodNumber:return iF(e,r);case j.ZodObject:return aF(e,r);case j.ZodBigInt:return BL(e,r);case j.ZodBoolean:return HL();case j.ZodDate:return yk(e,r);case j.ZodUndefined:return fF(r);case j.ZodNull:return rF(r);case j.ZodArray:return qL(e,r);case j.ZodUnion:case j.ZodDiscriminatedUnion:return oF(e,r);case j.ZodIntersection:return KL(e,r);case j.ZodTuple:return pF(e,r);case j.ZodRecord:return wg(e,r);case j.ZodLiteral:return YL(e,r);case j.ZodEnum:return JL(e);case j.ZodNativeEnum:return eF(e);case j.ZodNullable:return sF(e,r);case j.ZodOptional:return cF(e,r);case j.ZodMap:return QL(e,r);case j.ZodSet:return dF(e,r);case j.ZodLazy:return()=>e.getter()._def;case j.ZodPromise:return uF(e,r);case j.ZodNaN:case j.ZodNever:return tF(r);case j.ZodEffects:return WL(e,r);case j.ZodAny:return Ue(r);case j.ZodUnknown:return mF(r);case j.ZodDefault:return GL(e,r);case j.ZodBranded:return _g(e,r);case j.ZodReadonly:return hF(e,r);case j.ZodCatch:return VL(e,r);case j.ZodPipeline:return lF(e,r);case j.ZodFunction:case j.ZodVoid:case j.ZodSymbol:return;default:return(n=>{})(t)}},"selectParser");function Q(e,t,r=!1){let n=t.seen.get(e);if(t.override){let c=t.override?.(e,t,n,r);if(c!==LL)return c}if(n&&!r){let c=Xee(n,t);if(c!==void 0)return c}let o={def:e,path:t.currentPath,jsonSchema:void 0};t.seen.set(e,o);let s=gF(e,e.typeName,t),a=typeof s=="function"?Q(s(),t):s;if(a&&Qee(e,t,a),t.postProcess){let c=t.postProcess(a,e,t);return o.jsonSchema=a,c}return o.jsonSchema=a,a}i(Q,"parseDef");var Xee=i((e,t)=>{switch(t.$refStrategy){case"root":return{$ref:e.path.join("/")};case"relative":return{$ref:xg(t.currentPath,e.path)};case"none":case"seen":return e.path.length<t.currentPath.length&&e.path.every((r,n)=>t.currentPath[n]===r)?(console.warn(`Recursive reference detected at ${t.currentPath.join("/")}! Defaulting to any`),Ue(t)):t.$refStrategy==="seen"?Ue(t):void 0}},"get$ref"),Qee=i((e,t,r)=>(e.description&&(r.description=e.description,t.markdownDescription&&(r.markdownDescription=e.description)),r),"addMeta");var vk=i((e,t)=>{let r=UL(t),n=typeof t=="object"&&t.definitions?Object.entries(t.definitions).reduce((l,[u,d])=>({...l,[u]:Q(d._def,{...r,currentPath:[...r.basePath,r.definitionPath,u]},!0)??Ue(r)}),{}):void 0,o=typeof t=="string"?t:t?.nameStrategy==="title"?void 0:t?.name,s=Q(e._def,o===void 0?r:{...r,currentPath:[...r.basePath,r.definitionPath,o]},!1)??Ue(r),a=typeof t=="object"&&t.name!==void 0&&t.nameStrategy==="title"?t.name:void 0;a!==void 0&&(s.title=a),r.flags.hasReferencedOpenAiAnyType&&(n||(n={}),n[r.openAiAnyTypeName]||(n[r.openAiAnyTypeName]={type:["string","number","integer","boolean","array","null"],items:{$ref:r.$refStrategy==="relative"?"1":[...r.basePath,r.definitionPath,r.openAiAnyTypeName].join("/")}}));let c=o===void 0?n?{...s,[r.definitionPath]:n}:s:{$ref:[...r.$refStrategy==="relative"?[]:r.basePath,r.definitionPath,o].join("/"),[r.definitionPath]:{...n,[o]:s}};return r.target==="jsonSchema7"?c.$schema="http://json-schema.org/draft-07/schema#":(r.target==="jsonSchema2019-09"||r.target==="openAi")&&(c.$schema="https://json-schema.org/draft/2019-09/schema#"),r.target==="openAi"&&("anyOf"in c||"oneOf"in c||"allOf"in c||"type"in c&&Array.isArray(c.type))&&console.warn("Warning: OpenAI may not support schemas with unions as roots! Try wrapping it in an object property."),c},"zodToJsonSchema");function ete(e){return!e||e==="jsonSchema7"||e==="draft-7"?"draft-7":e==="jsonSchema2019-09"||e==="draft-2020-12"?"draft-2020-12":"draft-7"}i(ete,"mapMiniTarget");function wk(e,t){return rn(e)?FS(e,{target:ete(t?.target),io:t?.pipeStrategy??"input"}):vk(e,{strictUnions:t?.strictUnions??!0,pipeStrategy:t?.pipeStrategy??"input"})}i(wk,"toJsonSchemaCompat");function bk(e){let r=ko(e)?.method;if(!r)throw new Error("Schema is missing a method literal");let n=Ka(r);if(typeof n!="string")throw new Error("Schema method literal must be a string");return n}i(bk,"getMethodLiteral");function Sk(e,t){let r=So(e,t);if(!r.success)throw r.error;return r.data}i(Sk,"parseWithCompat");var tte=6e4,kk=class kk{constructor(t){this._options=t,this._requestMessageId=0,this._requestHandlers=new Map,this._requestHandlerAbortControllers=new Map,this._notificationHandlers=new Map,this._responseHandlers=new Map,this._progressHandlers=new Map,this._timeoutInfo=new Map,this._pendingDebouncedNotifications=new Set,this._taskProgressTokens=new Map,this._requestResolvers=new Map,this.setNotificationHandler(tg,r=>{this._oncancel(r)}),this.setNotificationHandler(ng,r=>{this._onprogress(r)}),this.setRequestHandler(rg,r=>({})),this._taskStore=t?.taskStore,this._taskMessageQueue=t?.taskMessageQueue,this._taskStore&&(this.setRequestHandler(og,async(r,n)=>{let o=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!o)throw new V(K.InvalidParams,"Failed to retrieve task: Task not found");return{...o}}),this.setRequestHandler(ig,async(r,n)=>{let o=i(async()=>{let s=r.params.taskId;if(this._taskMessageQueue){let c;for(;c=await this._taskMessageQueue.dequeue(s,n.sessionId);){if(c.type==="response"||c.type==="error"){let l=c.message,u=l.id,d=this._requestResolvers.get(u);if(d)if(this._requestResolvers.delete(u),c.type==="response")d(l);else{let p=l,m=new V(p.error.code,p.error.message,p.error.data);d(m)}else{let p=c.type==="response"?"Response":"Error";this._onerror(new Error(`${p} handler missing for request ${u}`))}continue}await this._transport?.send(c.message,{relatedRequestId:n.requestId})}}let a=await this._taskStore.getTask(s,n.sessionId);if(!a)throw new V(K.InvalidParams,`Task not found: ${s}`);if(!Eo(a.status))return await this._waitForTaskUpdate(s,n.signal),await o();if(Eo(a.status)){let c=await this._taskStore.getTaskResult(s,n.sessionId);return this._clearTaskQueue(s),{...c,_meta:{...c._meta,[$o]:{taskId:s}}}}return await o()},"handleTaskResult");return await o()}),this.setRequestHandler(ag,async(r,n)=>{try{let{tasks:o,nextCursor:s}=await this._taskStore.listTasks(r.params?.cursor,n.sessionId);return{tasks:o,nextCursor:s,_meta:{}}}catch(o){throw new V(K.InvalidParams,`Failed to list tasks: ${o instanceof Error?o.message:String(o)}`)}}),this.setRequestHandler(lg,async(r,n)=>{try{let o=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!o)throw new V(K.InvalidParams,`Task not found: ${r.params.taskId}`);if(Eo(o.status))throw new V(K.InvalidParams,`Cannot cancel task in terminal status: ${o.status}`);await this._taskStore.updateTaskStatus(r.params.taskId,"cancelled","Client cancelled task execution.",n.sessionId),this._clearTaskQueue(r.params.taskId);let s=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!s)throw new V(K.InvalidParams,`Task not found after cancellation: ${r.params.taskId}`);return{_meta:{},...s}}catch(o){throw o instanceof V?o:new V(K.InvalidRequest,`Failed to cancel task: ${o instanceof Error?o.message:String(o)}`)}}))}async _oncancel(t){if(!t.params.requestId)return;this._requestHandlerAbortControllers.get(t.params.requestId)?.abort(t.params.reason)}_setupTimeout(t,r,n,o,s=!1){this._timeoutInfo.set(t,{timeoutId:setTimeout(o,r),startTime:Date.now(),timeout:r,maxTotalTimeout:n,resetTimeoutOnProgress:s,onTimeout:o})}_resetTimeout(t){let r=this._timeoutInfo.get(t);if(!r)return!1;let n=Date.now()-r.startTime;if(r.maxTotalTimeout&&n>=r.maxTotalTimeout)throw this._timeoutInfo.delete(t),V.fromError(K.RequestTimeout,"Maximum total timeout exceeded",{maxTotalTimeout:r.maxTotalTimeout,totalElapsed:n});return clearTimeout(r.timeoutId),r.timeoutId=setTimeout(r.onTimeout,r.timeout),!0}_cleanupTimeout(t){let r=this._timeoutInfo.get(t);r&&(clearTimeout(r.timeoutId),this._timeoutInfo.delete(t))}async connect(t){if(this._transport)throw new Error("Already connected to a transport. Call close() before connecting to a new transport, or use a separate Protocol instance per connection.");this._transport=t;let r=this.transport?.onclose;this._transport.onclose=()=>{r?.(),this._onclose()};let n=this.transport?.onerror;this._transport.onerror=s=>{n?.(s),this._onerror(s)};let o=this._transport?.onmessage;this._transport.onmessage=(s,a)=>{o?.(s,a),Qu(s)||TL(s)?this._onresponse(s):tk(s)?this._onrequest(s,a):NL(s)?this._onnotification(s):this._onerror(new Error(`Unknown message type: ${JSON.stringify(s)}`))},await this._transport.start()}_onclose(){let t=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._taskProgressTokens.clear(),this._pendingDebouncedNotifications.clear();for(let n of this._timeoutInfo.values())clearTimeout(n.timeoutId);this._timeoutInfo.clear();for(let n of this._requestHandlerAbortControllers.values())n.abort();this._requestHandlerAbortControllers.clear();let r=V.fromError(K.ConnectionClosed,"Connection closed");this._transport=void 0,this.onclose?.();for(let n of t.values())n(r)}_onerror(t){this.onerror?.(t)}_onnotification(t){let r=this._notificationHandlers.get(t.method)??this.fallbackNotificationHandler;r!==void 0&&Promise.resolve().then(()=>r(t)).catch(n=>this._onerror(new Error(`Uncaught error in notification handler: ${n}`)))}_onrequest(t,r){let n=this._requestHandlers.get(t.method)??this.fallbackRequestHandler,o=this._transport,s=t.params?._meta?.[$o]?.taskId;if(n===void 0){let d={jsonrpc:"2.0",id:t.id,error:{code:K.MethodNotFound,message:"Method not found"}};s&&this._taskMessageQueue?this._enqueueTaskMessage(s,{type:"error",message:d,timestamp:Date.now()},o?.sessionId).catch(p=>this._onerror(new Error(`Failed to enqueue error response: ${p}`))):o?.send(d).catch(p=>this._onerror(new Error(`Failed to send an error response: ${p}`)));return}let a=new AbortController;this._requestHandlerAbortControllers.set(t.id,a);let c=kL(t.params)?t.params.task:void 0,l=this._taskStore?this.requestTaskStore(t,o?.sessionId):void 0,u={signal:a.signal,sessionId:o?.sessionId,_meta:t.params?._meta,sendNotification:async d=>{if(a.signal.aborted)return;let p={relatedRequestId:t.id};s&&(p.relatedTask={taskId:s}),await this.notification(d,p)},sendRequest:async(d,p,m)=>{if(a.signal.aborted)throw new V(K.ConnectionClosed,"Request was cancelled");let h={...m,relatedRequestId:t.id};s&&!h.relatedTask&&(h.relatedTask={taskId:s});let g=h.relatedTask?.taskId??s;return g&&l&&await l.updateTaskStatus(g,"input_required"),await this.request(d,p,h)},authInfo:r?.authInfo,requestId:t.id,requestInfo:r?.requestInfo,taskId:s,taskStore:l,taskRequestedTtl:c?.ttl,closeSSEStream:r?.closeSSEStream,closeStandaloneSSEStream:r?.closeStandaloneSSEStream};Promise.resolve().then(()=>{c&&this.assertTaskHandlerCapability(t.method)}).then(()=>n(t,u)).then(async d=>{if(a.signal.aborted)return;let p={result:d,jsonrpc:"2.0",id:t.id};s&&this._taskMessageQueue?await this._enqueueTaskMessage(s,{type:"response",message:p,timestamp:Date.now()},o?.sessionId):await o?.send(p)},async d=>{if(a.signal.aborted)return;let p={jsonrpc:"2.0",id:t.id,error:{code:Number.isSafeInteger(d.code)?d.code:K.InternalError,message:d.message??"Internal error",...d.data!==void 0&&{data:d.data}}};s&&this._taskMessageQueue?await this._enqueueTaskMessage(s,{type:"error",message:p,timestamp:Date.now()},o?.sessionId):await o?.send(p)}).catch(d=>this._onerror(new Error(`Failed to send response: ${d}`))).finally(()=>{this._requestHandlerAbortControllers.get(t.id)===a&&this._requestHandlerAbortControllers.delete(t.id)})}_onprogress(t){let{progressToken:r,...n}=t.params,o=Number(r),s=this._progressHandlers.get(o);if(!s){this._onerror(new Error(`Received a progress notification for an unknown token: ${JSON.stringify(t)}`));return}let a=this._responseHandlers.get(o),c=this._timeoutInfo.get(o);if(c&&a&&c.resetTimeoutOnProgress)try{this._resetTimeout(o)}catch(l){this._responseHandlers.delete(o),this._progressHandlers.delete(o),this._cleanupTimeout(o),a(l);return}s(n)}_onresponse(t){let r=Number(t.id),n=this._requestResolvers.get(r);if(n){if(this._requestResolvers.delete(r),Qu(t))n(t);else{let a=new V(t.error.code,t.error.message,t.error.data);n(a)}return}let o=this._responseHandlers.get(r);if(o===void 0){this._onerror(new Error(`Received a response for an unknown message ID: ${JSON.stringify(t)}`));return}this._responseHandlers.delete(r),this._cleanupTimeout(r);let s=!1;if(Qu(t)&&t.result&&typeof t.result=="object"){let a=t.result;if(a.task&&typeof a.task=="object"){let c=a.task;typeof c.taskId=="string"&&(s=!0,this._taskProgressTokens.set(c.taskId,r))}}if(s||this._progressHandlers.delete(r),Qu(t))o(t);else{let a=V.fromError(t.error.code,t.error.message,t.error.data);o(a)}}get transport(){return this._transport}async close(){await this._transport?.close()}async*requestStream(t,r,n){let{task:o}=n??{};if(!o){try{yield{type:"result",result:await this.request(t,r,n)}}catch(a){yield{type:"error",error:a instanceof V?a:new V(K.InternalError,String(a))}}return}let s;try{let a=await this.request(t,Xa,n);if(a.task)s=a.task.taskId,yield{type:"taskCreated",task:a.task};else throw new V(K.InternalError,"Task creation did not return a task");for(;;){let c=await this.getTask({taskId:s},n);if(yield{type:"taskStatus",task:c},Eo(c.status)){c.status==="completed"?yield{type:"result",result:await this.getTaskResult({taskId:s},r,n)}:c.status==="failed"?yield{type:"error",error:new V(K.InternalError,`Task ${s} failed`)}:c.status==="cancelled"&&(yield{type:"error",error:new V(K.InternalError,`Task ${s} was cancelled`)});return}if(c.status==="input_required"){yield{type:"result",result:await this.getTaskResult({taskId:s},r,n)};return}let l=c.pollInterval??this._options?.defaultTaskPollInterval??1e3;await new Promise(u=>setTimeout(u,l)),n?.signal?.throwIfAborted()}}catch(a){yield{type:"error",error:a instanceof V?a:new V(K.InternalError,String(a))}}}request(t,r,n){let{relatedRequestId:o,resumptionToken:s,onresumptiontoken:a,task:c,relatedTask:l}=n??{};return new Promise((u,d)=>{let p=i(b=>{d(b)},"earlyReject");if(!this._transport){p(new Error("Not connected"));return}if(this._options?.enforceStrictCapabilities===!0)try{this.assertCapabilityForMethod(t.method),c&&this.assertTaskCapability(t.method)}catch(b){p(b);return}n?.signal?.throwIfAborted();let m=this._requestMessageId++,h={...t,jsonrpc:"2.0",id:m};n?.onprogress&&(this._progressHandlers.set(m,n.onprogress),h.params={...t.params,_meta:{...t.params?._meta||{},progressToken:m}}),c&&(h.params={...h.params,task:c}),l&&(h.params={...h.params,_meta:{...h.params?._meta||{},[$o]:l}});let g=i(b=>{this._responseHandlers.delete(m),this._progressHandlers.delete(m),this._cleanupTimeout(m),this._transport?.send({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:m,reason:String(b)}},{relatedRequestId:o,resumptionToken:s,onresumptiontoken:a}).catch(S=>this._onerror(new Error(`Failed to send cancellation: ${S}`)));let w=b instanceof V?b:new V(K.RequestTimeout,String(b));d(w)},"cancel");this._responseHandlers.set(m,b=>{if(!n?.signal?.aborted){if(b instanceof Error)return d(b);try{let w=So(r,b.result);w.success?u(w.data):d(w.error)}catch(w){d(w)}}}),n?.signal?.addEventListener("abort",()=>{g(n?.signal?.reason)});let _=n?.timeout??tte,x=i(()=>g(V.fromError(K.RequestTimeout,"Request timed out",{timeout:_})),"timeoutHandler");this._setupTimeout(m,_,n?.maxTotalTimeout,x,n?.resetTimeoutOnProgress??!1);let v=l?.taskId;if(v){let b=i(w=>{let S=this._responseHandlers.get(m);S?S(w):this._onerror(new Error(`Response handler missing for side-channeled request ${m}`))},"responseResolver");this._requestResolvers.set(m,b),this._enqueueTaskMessage(v,{type:"request",message:h,timestamp:Date.now()}).catch(w=>{this._cleanupTimeout(m),d(w)})}else this._transport.send(h,{relatedRequestId:o,resumptionToken:s,onresumptiontoken:a}).catch(b=>{this._cleanupTimeout(m),d(b)})})}async getTask(t,r){return this.request({method:"tasks/get",params:t},sg,r)}async getTaskResult(t,r,n){return this.request({method:"tasks/result",params:t},r,n)}async listTasks(t,r){return this.request({method:"tasks/list",params:t},cg,r)}async cancelTask(t,r){return this.request({method:"tasks/cancel",params:t},IL,r)}async notification(t,r){if(!this._transport)throw new Error("Not connected");this.assertNotificationCapability(t.method);let n=r?.relatedTask?.taskId;if(n){let c={...t,jsonrpc:"2.0",params:{...t.params,_meta:{...t.params?._meta||{},[$o]:r.relatedTask}}};await this._enqueueTaskMessage(n,{type:"notification",message:c,timestamp:Date.now()});return}if((this._options?.debouncedNotificationMethods??[]).includes(t.method)&&!t.params&&!r?.relatedRequestId&&!r?.relatedTask){if(this._pendingDebouncedNotifications.has(t.method))return;this._pendingDebouncedNotifications.add(t.method),Promise.resolve().then(()=>{if(this._pendingDebouncedNotifications.delete(t.method),!this._transport)return;let c={...t,jsonrpc:"2.0"};r?.relatedTask&&(c={...c,params:{...c.params,_meta:{...c.params?._meta||{},[$o]:r.relatedTask}}}),this._transport?.send(c,r).catch(l=>this._onerror(l))});return}let a={...t,jsonrpc:"2.0"};r?.relatedTask&&(a={...a,params:{...a.params,_meta:{...a.params?._meta||{},[$o]:r.relatedTask}}}),await this._transport.send(a,r)}setRequestHandler(t,r){let n=bk(t);this.assertRequestHandlerCapability(n),this._requestHandlers.set(n,(o,s)=>{let a=Sk(t,o);return Promise.resolve(r(a,s))})}removeRequestHandler(t){this._requestHandlers.delete(t)}assertCanSetRequestHandler(t){if(this._requestHandlers.has(t))throw new Error(`A request handler for ${t} already exists, which would be overridden`)}setNotificationHandler(t,r){let n=bk(t);this._notificationHandlers.set(n,o=>{let s=Sk(t,o);return Promise.resolve(r(s))})}removeNotificationHandler(t){this._notificationHandlers.delete(t)}_cleanupTaskProgressHandler(t){let r=this._taskProgressTokens.get(t);r!==void 0&&(this._progressHandlers.delete(r),this._taskProgressTokens.delete(t))}async _enqueueTaskMessage(t,r,n){if(!this._taskStore||!this._taskMessageQueue)throw new Error("Cannot enqueue task message: taskStore and taskMessageQueue are not configured");let o=this._options?.maxTaskQueueSize;await this._taskMessageQueue.enqueue(t,r,n,o)}async _clearTaskQueue(t,r){if(this._taskMessageQueue){let n=await this._taskMessageQueue.dequeueAll(t,r);for(let o of n)if(o.type==="request"&&tk(o.message)){let s=o.message.id,a=this._requestResolvers.get(s);a?(a(new V(K.InternalError,"Task cancelled or completed")),this._requestResolvers.delete(s)):this._onerror(new Error(`Resolver missing for request ${s} during task ${t} cleanup`))}}}async _waitForTaskUpdate(t,r){let n=this._options?.defaultTaskPollInterval??1e3;try{let o=await this._taskStore?.getTask(t);o?.pollInterval&&(n=o.pollInterval)}catch{}return new Promise((o,s)=>{if(r.aborted){s(new V(K.InvalidRequest,"Request cancelled"));return}let a=setTimeout(o,n);r.addEventListener("abort",()=>{clearTimeout(a),s(new V(K.InvalidRequest,"Request cancelled"))},{once:!0})})}requestTaskStore(t,r){let n=this._taskStore;if(!n)throw new Error("No task store configured");return{createTask:async o=>{if(!t)throw new Error("No request provided");return await n.createTask(o,t.id,{method:t.method,params:t.params},r)},getTask:async o=>{let s=await n.getTask(o,r);if(!s)throw new V(K.InvalidParams,"Failed to retrieve task: Task not found");return s},storeTaskResult:async(o,s,a)=>{await n.storeTaskResult(o,s,a,r);let c=await n.getTask(o,r);if(c){let l=od.parse({method:"notifications/tasks/status",params:c});await this.notification(l),Eo(c.status)&&this._cleanupTaskProgressHandler(o)}},getTaskResult:o=>n.getTaskResult(o,r),updateTaskStatus:async(o,s,a)=>{let c=await n.getTask(o,r);if(!c)throw new V(K.InvalidParams,`Task "${o}" not found - it may have been cleaned up`);if(Eo(c.status))throw new V(K.InvalidParams,`Cannot update task "${o}" from terminal status "${c.status}" to "${s}". Terminal states (completed, failed, cancelled) cannot transition to other states.`);await n.updateTaskStatus(o,s,a,r);let l=await n.getTask(o,r);if(l){let u=od.parse({method:"notifications/tasks/status",params:l});await this.notification(u),Eo(l.status)&&this._cleanupTaskProgressHandler(o)}},listTasks:o=>n.listTasks(o,r)}}};i(kk,"Protocol");var bg=kk;function yF(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}i(yF,"isPlainObject");function xF(e,t){let r={...e};for(let n in t){let o=n,s=t[o];if(s===void 0)continue;let a=r[o];yF(a)&&yF(s)?r[o]={...a,...s}:r[o]=s}return r}i(xF,"mergeCapabilities");var x9=_N(JE(),1),_9=_N(y9(),1);function dae(){let e=new x9.default({strict:!1,validateFormats:!0,validateSchema:!1,allErrors:!0});return(0,_9.default)(e),e}i(dae,"createDefaultAjvInstance");var nN=class nN{constructor(t){this._ajv=t??dae()}getValidator(t){let r="$id"in t&&typeof t.$id=="string"?this._ajv.getSchema(t.$id)??this._ajv.compile(t):this._ajv.compile(t);return n=>r(n)?{valid:!0,data:n,errorMessage:void 0}:{valid:!1,data:void 0,errorMessage:this._ajv.errorsText(r.errors)}}};i(nN,"AjvJsonSchemaValidator");var sy=nN;var oN=class oN{constructor(t){this._server=t}requestStream(t,r,n){return this._server.requestStream(t,r,n)}createMessageStream(t,r){let n=this._server.getClientCapabilities();if((t.tools||t.toolChoice)&&!n?.sampling?.tools)throw new Error("Client does not support sampling tools capability.");if(t.messages.length>0){let o=t.messages[t.messages.length-1],s=Array.isArray(o.content)?o.content:[o.content],a=s.some(d=>d.type==="tool_result"),c=t.messages.length>1?t.messages[t.messages.length-2]:void 0,l=c?Array.isArray(c.content)?c.content:[c.content]:[],u=l.some(d=>d.type==="tool_use");if(a){if(s.some(d=>d.type!=="tool_result"))throw new Error("The last message must contain only tool_result content if any is present");if(!u)throw new Error("tool_result blocks are not matching any tool_use from the previous message")}if(u){let d=new Set(l.filter(m=>m.type==="tool_use").map(m=>m.id)),p=new Set(s.filter(m=>m.type==="tool_result").map(m=>m.toolUseId));if(d.size!==p.size||![...d].every(m=>p.has(m)))throw new Error("ids of tool_result blocks and tool_use blocks from previous message do not match")}}return this.requestStream({method:"sampling/createMessage",params:t},ad,r)}elicitInputStream(t,r){let n=this._server.getClientCapabilities(),o=t.mode??"form";switch(o){case"url":{if(!n?.elicitation?.url)throw new Error("Client does not support url elicitation.");break}case"form":{if(!n?.elicitation?.form)throw new Error("Client does not support form elicitation.");break}}let s=o==="form"&&t.mode===void 0?{...t,mode:"form"}:t;return this.requestStream({method:"elicitation/create",params:s},tc,r)}async getTask(t,r){return this._server.getTask({taskId:t},r)}async getTaskResult(t,r,n){return this._server.getTaskResult({taskId:t},r,n)}async listTasks(t,r){return this._server.listTasks(t?{cursor:t}:void 0,r)}async cancelTask(t,r){return this._server.cancelTask({taskId:t},r)}};i(oN,"ExperimentalServerTasks");var iy=oN;function v9(e,t,r){if(!e)throw new Error(`${r} does not support task creation (required for ${t})`);switch(t){case"tools/call":if(!e.tools?.call)throw new Error(`${r} does not support task creation for tools/call (required for ${t})`);break;default:break}}i(v9,"assertToolsCallTaskCapability");function w9(e,t,r){if(!e)throw new Error(`${r} does not support task creation (required for ${t})`);switch(t){case"sampling/createMessage":if(!e.sampling?.createMessage)throw new Error(`${r} does not support task creation for sampling/createMessage (required for ${t})`);break;case"elicitation/create":if(!e.elicitation?.create)throw new Error(`${r} does not support task creation for elicitation/create (required for ${t})`);break;default:break}}i(w9,"assertClientRequestTaskCapability");var sN=class sN extends bg{constructor(t,r){super(r),this._serverInfo=t,this._loggingLevels=new Map,this.LOG_LEVEL_SEVERITY=new Map(id.options.map((n,o)=>[n,o])),this.isMessageIgnored=(n,o)=>{let s=this._loggingLevels.get(o);return s?this.LOG_LEVEL_SEVERITY.get(n)<this.LOG_LEVEL_SEVERITY.get(s):!1},this._capabilities=r?.capabilities??{},this._instructions=r?.instructions,this._jsonSchemaValidator=r?.jsonSchemaValidator??new sy,this.setRequestHandler(ok,n=>this._oninitialize(n)),this.setNotificationHandler(sk,()=>this.oninitialized?.()),this._capabilities.logging&&this.setRequestHandler(pk,async(n,o)=>{let s=o.sessionId||o.requestInfo?.headers["mcp-session-id"]||void 0,{level:a}=n.params,c=id.safeParse(a);return c.success&&this._loggingLevels.set(s,c.data),{}})}get experimental(){return this._experimental||(this._experimental={tasks:new iy(this)}),this._experimental}registerCapabilities(t){if(this.transport)throw new Error("Cannot register capabilities after connecting to transport");this._capabilities=xF(this._capabilities,t)}setRequestHandler(t,r){let o=ko(t)?.method;if(!o)throw new Error("Schema is missing a method literal");let s=Ka(o);if(typeof s!="string")throw new Error("Schema method literal must be a string");if(s==="tools/call"){let c=i(async(l,u)=>{let d=So(ec,l);if(!d.success){let g=d.error instanceof Error?d.error.message:String(d.error);throw new V(K.InvalidParams,`Invalid tools/call request: ${g}`)}let{params:p}=d.data,m=await Promise.resolve(r(l,u));if(p.task){let g=So(Xa,m);if(!g.success){let _=g.error instanceof Error?g.error.message:String(g.error);throw new V(K.InvalidParams,`Invalid task creation result: ${_}`)}return g.data}let h=So(gg,m);if(!h.success){let g=h.error instanceof Error?h.error.message:String(h.error);throw new V(K.InvalidParams,`Invalid tools/call result: ${g}`)}return h.data},"wrappedHandler");return super.setRequestHandler(t,c)}return super.setRequestHandler(t,r)}assertCapabilityForMethod(t){switch(t){case"sampling/createMessage":if(!this._clientCapabilities?.sampling)throw new Error(`Client does not support sampling (required for ${t})`);break;case"elicitation/create":if(!this._clientCapabilities?.elicitation)throw new Error(`Client does not support elicitation (required for ${t})`);break;case"roots/list":if(!this._clientCapabilities?.roots)throw new Error(`Client does not support listing roots (required for ${t})`);break;case"ping":break}}assertNotificationCapability(t){switch(t){case"notifications/message":if(!this._capabilities.logging)throw new Error(`Server does not support logging (required for ${t})`);break;case"notifications/resources/updated":case"notifications/resources/list_changed":if(!this._capabilities.resources)throw new Error(`Server does not support notifying about resources (required for ${t})`);break;case"notifications/tools/list_changed":if(!this._capabilities.tools)throw new Error(`Server does not support notifying of tool list changes (required for ${t})`);break;case"notifications/prompts/list_changed":if(!this._capabilities.prompts)throw new Error(`Server does not support notifying of prompt list changes (required for ${t})`);break;case"notifications/elicitation/complete":if(!this._clientCapabilities?.elicitation?.url)throw new Error(`Client does not support URL elicitation (required for ${t})`);break;case"notifications/cancelled":break;case"notifications/progress":break}}assertRequestHandlerCapability(t){if(this._capabilities)switch(t){case"completion/complete":if(!this._capabilities.completions)throw new Error(`Server does not support completions (required for ${t})`);break;case"logging/setLevel":if(!this._capabilities.logging)throw new Error(`Server does not support logging (required for ${t})`);break;case"prompts/get":case"prompts/list":if(!this._capabilities.prompts)throw new Error(`Server does not support prompts (required for ${t})`);break;case"resources/list":case"resources/templates/list":case"resources/read":if(!this._capabilities.resources)throw new Error(`Server does not support resources (required for ${t})`);break;case"tools/call":case"tools/list":if(!this._capabilities.tools)throw new Error(`Server does not support tools (required for ${t})`);break;case"tasks/get":case"tasks/list":case"tasks/result":case"tasks/cancel":if(!this._capabilities.tasks)throw new Error(`Server does not support tasks capability (required for ${t})`);break;case"ping":case"initialize":break}}assertTaskCapability(t){w9(this._clientCapabilities?.tasks?.requests,t,"Client")}assertTaskHandlerCapability(t){this._capabilities&&v9(this._capabilities.tasks?.requests,t,"Server")}async _oninitialize(t){let r=t.params.protocolVersion;return this._clientCapabilities=t.params.capabilities,this._clientVersion=t.params.clientInfo,{protocolVersion:wL.includes(r)?r:QS,capabilities:this.getCapabilities(),serverInfo:this._serverInfo,...this._instructions&&{instructions:this._instructions}}}getClientCapabilities(){return this._clientCapabilities}getClientVersion(){return this._clientVersion}getCapabilities(){return this._capabilities}async ping(){return this.request({method:"ping"},eg)}async createMessage(t,r){if((t.tools||t.toolChoice)&&!this._clientCapabilities?.sampling?.tools)throw new Error("Client does not support sampling tools capability.");if(t.messages.length>0){let n=t.messages[t.messages.length-1],o=Array.isArray(n.content)?n.content:[n.content],s=o.some(u=>u.type==="tool_result"),a=t.messages.length>1?t.messages[t.messages.length-2]:void 0,c=a?Array.isArray(a.content)?a.content:[a.content]:[],l=c.some(u=>u.type==="tool_use");if(s){if(o.some(u=>u.type!=="tool_result"))throw new Error("The last message must contain only tool_result content if any is present");if(!l)throw new Error("tool_result blocks are not matching any tool_use from the previous message")}if(l){let u=new Set(c.filter(p=>p.type==="tool_use").map(p=>p.id)),d=new Set(o.filter(p=>p.type==="tool_result").map(p=>p.toolUseId));if(u.size!==d.size||![...u].every(p=>d.has(p)))throw new Error("ids of tool_result blocks and tool_use blocks from previous message do not match")}}return t.tools?this.request({method:"sampling/createMessage",params:t},fk,r):this.request({method:"sampling/createMessage",params:t},ad,r)}async elicitInput(t,r){switch(t.mode??"form"){case"url":{if(!this._clientCapabilities?.elicitation?.url)throw new Error("Client does not support url elicitation.");let o=t;return this.request({method:"elicitation/create",params:o},tc,r)}case"form":{if(!this._clientCapabilities?.elicitation?.form)throw new Error("Client does not support form elicitation.");let o=t.mode==="form"?t:{...t,mode:"form"},s=await this.request({method:"elicitation/create",params:o},tc,r);if(s.action==="accept"&&s.content&&o.requestedSchema)try{let c=this._jsonSchemaValidator.getValidator(o.requestedSchema)(s.content);if(!c.valid)throw new V(K.InvalidParams,`Elicitation response content does not match requested schema: ${c.errorMessage}`)}catch(a){throw a instanceof V?a:new V(K.InternalError,`Error validating elicitation response: ${a instanceof Error?a.message:String(a)}`)}return s}}}createElicitationCompletionNotifier(t,r){if(!this._clientCapabilities?.elicitation?.url)throw new Error("Client does not support URL elicitation (required for notifications/elicitation/complete)");return()=>this.notification({method:"notifications/elicitation/complete",params:{elicitationId:t}},r)}async listRoots(t,r){return this.request({method:"roots/list",params:t},mk,r)}async sendLoggingMessage(t,r){if(this._capabilities.logging&&!this.isMessageIgnored(t.level,r))return this.notification({method:"notifications/message",params:t})}async sendResourceUpdated(t){return this.notification({method:"notifications/resources/updated",params:t})}async sendResourceListChanged(){return this.notification({method:"notifications/resources/list_changed"})}async sendToolListChanged(){return this.notification({method:"notifications/tools/list_changed"})}async sendPromptListChanged(){return this.notification({method:"notifications/prompts/list_changed"})}};i(sN,"Server");var ay=sN;var S9=Symbol.for("mcp.completable");function iN(e){return!!e&&typeof e=="object"&&S9 in e}i(iN,"isCompletable");function k9(e){return e[S9]?.complete}i(k9,"getCompleter");var b9;(function(e){e.Completable="McpCompletable"})(b9||(b9={}));var pae=/^[A-Za-z0-9._-]{1,128}$/;function fae(e){let t=[];if(e.length===0)return{isValid:!1,warnings:["Tool name cannot be empty"]};if(e.length>128)return{isValid:!1,warnings:[`Tool name exceeds maximum length of 128 characters (current: ${e.length})`]};if(e.includes(" ")&&t.push("Tool name contains spaces, which may cause parsing issues"),e.includes(",")&&t.push("Tool name contains commas, which may cause parsing issues"),(e.startsWith("-")||e.endsWith("-"))&&t.push("Tool name starts or ends with a dash, which may cause parsing issues in some contexts"),(e.startsWith(".")||e.endsWith("."))&&t.push("Tool name starts or ends with a dot, which may cause parsing issues in some contexts"),!pae.test(e)){let r=e.split("").filter(n=>!/[A-Za-z0-9._-]/.test(n)).filter((n,o,s)=>s.indexOf(n)===o);return t.push(`Tool name contains invalid characters: ${r.map(n=>`"${n}"`).join(", ")}`,"Allowed characters are: A-Z, a-z, 0-9, underscore (_), dash (-), and dot (.)"),{isValid:!1,warnings:t}}return{isValid:!0,warnings:t}}i(fae,"validateToolName");function mae(e,t){if(t.length>0){console.warn(`Tool name validation warning for "${e}":`);for(let r of t)console.warn(` - ${r}`);console.warn("Tool registration will proceed, but this may cause compatibility issues."),console.warn("Consider updating the tool name to conform to the MCP tool naming standard."),console.warn("See SEP: Specify Format for Tool Names (https://github.com/modelcontextprotocol/modelcontextprotocol/issues/986) for more details.")}}i(mae,"issueToolNameWarning");function aN(e){let t=fae(e);return mae(e,t.warnings),t.isValid}i(aN,"validateAndWarnToolName");var cN=class cN{constructor(t){this._mcpServer=t}registerToolTask(t,r,n){let o={taskSupport:"required",...r.execution};if(o.taskSupport==="forbidden")throw new Error(`Cannot register task-based tool '${t}' with taskSupport 'forbidden'. Use registerTool() instead.`);return this._mcpServer._createRegisteredTool(t,r.title,r.description,r.inputSchema,r.outputSchema,r.annotations,o,r._meta,n)}};i(cN,"ExperimentalMcpServerTasks");var cy=cN;var uN=class uN{constructor(t,r){this._registeredResources={},this._registeredResourceTemplates={},this._registeredTools={},this._registeredPrompts={},this._toolHandlersInitialized=!1,this._completionHandlerInitialized=!1,this._resourceHandlersInitialized=!1,this._promptHandlersInitialized=!1,this.server=new ay(t,r)}get experimental(){return this._experimental||(this._experimental={tasks:new cy(this)}),this._experimental}async connect(t){return await this.server.connect(t)}async close(){await this.server.close()}setToolRequestHandlers(){this._toolHandlersInitialized||(this.server.assertCanSetRequestHandler(Ro(hg)),this.server.assertCanSetRequestHandler(Ro(ec)),this.server.registerCapabilities({tools:{listChanged:!0}}),this.server.setRequestHandler(hg,()=>({tools:Object.entries(this._registeredTools).filter(([,t])=>t.enabled).map(([t,r])=>{let n={name:t,title:r.title,description:r.description,inputSchema:(()=>{let o=Ja(r.inputSchema);return o?wk(o,{strictUnions:!0,pipeStrategy:"input"}):hae})(),annotations:r.annotations,execution:r.execution,_meta:r._meta};if(r.outputSchema){let o=Ja(r.outputSchema);o&&(n.outputSchema=wk(o,{strictUnions:!0,pipeStrategy:"output"}))}return n})})),this.server.setRequestHandler(ec,async(t,r)=>{try{let n=this._registeredTools[t.params.name];if(!n)throw new V(K.InvalidParams,`Tool ${t.params.name} not found`);if(!n.enabled)throw new V(K.InvalidParams,`Tool ${t.params.name} disabled`);let o=!!t.params.task,s=n.execution?.taskSupport,a="createTask"in n.handler;if((s==="required"||s==="optional")&&!a)throw new V(K.InternalError,`Tool ${t.params.name} has taskSupport '${s}' but was not registered with registerToolTask`);if(s==="required"&&!o)throw new V(K.MethodNotFound,`Tool ${t.params.name} requires task augmentation (taskSupport: 'required')`);if(s==="optional"&&!o&&a)return await this.handleAutomaticTaskPolling(n,t,r);let c=await this.validateToolInput(n,t.params.arguments,t.params.name),l=await this.executeToolHandler(n,c,r);return o||await this.validateToolOutput(n,l,t.params.name),l}catch(n){if(n instanceof V&&n.code===K.UrlElicitationRequired)throw n;return this.createToolError(n instanceof Error?n.message:String(n))}}),this._toolHandlersInitialized=!0)}createToolError(t){return{content:[{type:"text",text:t}],isError:!0}}async validateToolInput(t,r,n){if(!t.inputSchema)return;let s=Ja(t.inputSchema)??t.inputSchema,a=await Vh(s,r);if(!a.success){let c="error"in a?a.error:"Unknown error",l=Gh(c);throw new V(K.InvalidParams,`Input validation error: Invalid arguments for tool ${n}: ${l}`)}return a.data}async validateToolOutput(t,r,n){if(!t.outputSchema||!("content"in r)||r.isError)return;if(!r.structuredContent)throw new V(K.InvalidParams,`Output validation error: Tool ${n} has an output schema but no structured content was provided`);let o=Ja(t.outputSchema),s=await Vh(o,r.structuredContent);if(!s.success){let a="error"in s?s.error:"Unknown error",c=Gh(a);throw new V(K.InvalidParams,`Output validation error: Invalid structured content for tool ${n}: ${c}`)}}async executeToolHandler(t,r,n){let o=t.handler;if("createTask"in o){if(!n.taskStore)throw new Error("No task store provided.");let a={...n,taskStore:n.taskStore};if(t.inputSchema){let c=o;return await Promise.resolve(c.createTask(r,a))}else{let c=o;return await Promise.resolve(c.createTask(a))}}if(t.inputSchema){let a=o;return await Promise.resolve(a(r,n))}else{let a=o;return await Promise.resolve(a(n))}}async handleAutomaticTaskPolling(t,r,n){if(!n.taskStore)throw new Error("No task store provided for task-capable tool.");let o=await this.validateToolInput(t,r.params.arguments,r.params.name),s=t.handler,a={...n,taskStore:n.taskStore},c=o?await Promise.resolve(s.createTask(o,a)):await Promise.resolve(s.createTask(a)),l=c.task.taskId,u=c.task,d=u.pollInterval??5e3;for(;u.status!=="completed"&&u.status!=="failed"&&u.status!=="cancelled";){await new Promise(m=>setTimeout(m,d));let p=await n.taskStore.getTask(l);if(!p)throw new V(K.InternalError,`Task ${l} not found during polling`);u=p}return await n.taskStore.getTaskResult(l)}setCompletionRequestHandler(){this._completionHandlerInitialized||(this.server.assertCanSetRequestHandler(Ro(yg)),this.server.registerCapabilities({completions:{}}),this.server.setRequestHandler(yg,async t=>{switch(t.params.ref.type){case"ref/prompt":return DL(t),this.handlePromptCompletion(t,t.params.ref);case"ref/resource":return ML(t),this.handleResourceCompletion(t,t.params.ref);default:throw new V(K.InvalidParams,`Invalid completion reference: ${t.params.ref}`)}}),this._completionHandlerInitialized=!0)}async handlePromptCompletion(t,r){let n=this._registeredPrompts[r.name];if(!n)throw new V(K.InvalidParams,`Prompt ${r.name} not found`);if(!n.enabled)throw new V(K.InvalidParams,`Prompt ${r.name} disabled`);if(!n.argsSchema)return Zd;let s=ko(n.argsSchema)?.[t.params.argument.name];if(!iN(s))return Zd;let a=k9(s);if(!a)return Zd;let c=await a(t.params.argument.value,t.params.context);return E9(c)}async handleResourceCompletion(t,r){let n=Object.values(this._registeredResourceTemplates).find(a=>a.resourceTemplate.uriTemplate.toString()===r.uri);if(!n){if(this._registeredResources[r.uri])return Zd;throw new V(K.InvalidParams,`Resource template ${t.params.ref.uri} not found`)}let o=n.resourceTemplate.completeCallback(t.params.argument.name);if(!o)return Zd;let s=await o(t.params.argument.value,t.params.context);return E9(s)}setResourceRequestHandlers(){this._resourceHandlersInitialized||(this.server.assertCanSetRequestHandler(Ro(ug)),this.server.assertCanSetRequestHandler(Ro(dg)),this.server.assertCanSetRequestHandler(Ro(pg)),this.server.registerCapabilities({resources:{listChanged:!0}}),this.server.setRequestHandler(ug,async(t,r)=>{let n=Object.entries(this._registeredResources).filter(([s,a])=>a.enabled).map(([s,a])=>({uri:s,name:a.name,...a.metadata})),o=[];for(let s of Object.values(this._registeredResourceTemplates)){if(!s.resourceTemplate.listCallback)continue;let a=await s.resourceTemplate.listCallback(r);for(let c of a.resources)o.push({...s.metadata,...c})}return{resources:[...n,...o]}}),this.server.setRequestHandler(dg,async()=>({resourceTemplates:Object.entries(this._registeredResourceTemplates).map(([r,n])=>({name:r,uriTemplate:n.resourceTemplate.uriTemplate.toString(),...n.metadata}))})),this.server.setRequestHandler(pg,async(t,r)=>{let n=new URL(t.params.uri),o=this._registeredResources[n.toString()];if(o){if(!o.enabled)throw new V(K.InvalidParams,`Resource ${n} disabled`);return o.readCallback(n,r)}for(let s of Object.values(this._registeredResourceTemplates)){let a=s.resourceTemplate.uriTemplate.match(n.toString());if(a)return s.readCallback(n,a,r)}throw new V(K.InvalidParams,`Resource ${n} not found`)}),this._resourceHandlersInitialized=!0)}setPromptRequestHandlers(){this._promptHandlersInitialized||(this.server.assertCanSetRequestHandler(Ro(fg)),this.server.assertCanSetRequestHandler(Ro(mg)),this.server.registerCapabilities({prompts:{listChanged:!0}}),this.server.setRequestHandler(fg,()=>({prompts:Object.entries(this._registeredPrompts).filter(([,t])=>t.enabled).map(([t,r])=>({name:t,title:r.title,description:r.description,arguments:r.argsSchema?gae(r.argsSchema):void 0}))})),this.server.setRequestHandler(mg,async(t,r)=>{let n=this._registeredPrompts[t.params.name];if(!n)throw new V(K.InvalidParams,`Prompt ${t.params.name} not found`);if(!n.enabled)throw new V(K.InvalidParams,`Prompt ${t.params.name} disabled`);if(n.argsSchema){let o=Ja(n.argsSchema),s=await Vh(o,t.params.arguments);if(!s.success){let l="error"in s?s.error:"Unknown error",u=Gh(l);throw new V(K.InvalidParams,`Invalid arguments for prompt ${t.params.name}: ${u}`)}let a=s.data,c=n.callback;return await Promise.resolve(c(a,r))}else{let o=n.callback;return await Promise.resolve(o(r))}}),this._promptHandlersInitialized=!0)}resource(t,r,...n){let o;typeof n[0]=="object"&&(o=n.shift());let s=n[0];if(typeof r=="string"){if(this._registeredResources[r])throw new Error(`Resource ${r} is already registered`);let a=this._createRegisteredResource(t,void 0,r,o,s);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),a}else{if(this._registeredResourceTemplates[t])throw new Error(`Resource template ${t} is already registered`);let a=this._createRegisteredResourceTemplate(t,void 0,r,o,s);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),a}}registerResource(t,r,n,o){if(typeof r=="string"){if(this._registeredResources[r])throw new Error(`Resource ${r} is already registered`);let s=this._createRegisteredResource(t,n.title,r,n,o);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),s}else{if(this._registeredResourceTemplates[t])throw new Error(`Resource template ${t} is already registered`);let s=this._createRegisteredResourceTemplate(t,n.title,r,n,o);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),s}}_createRegisteredResource(t,r,n,o,s){let a={name:t,title:r,metadata:o,readCallback:s,enabled:!0,disable:()=>a.update({enabled:!1}),enable:()=>a.update({enabled:!0}),remove:()=>a.update({uri:null}),update:c=>{typeof c.uri<"u"&&c.uri!==n&&(delete this._registeredResources[n],c.uri&&(this._registeredResources[c.uri]=a)),typeof c.name<"u"&&(a.name=c.name),typeof c.title<"u"&&(a.title=c.title),typeof c.metadata<"u"&&(a.metadata=c.metadata),typeof c.callback<"u"&&(a.readCallback=c.callback),typeof c.enabled<"u"&&(a.enabled=c.enabled),this.sendResourceListChanged()}};return this._registeredResources[n]=a,a}_createRegisteredResourceTemplate(t,r,n,o,s){let a={resourceTemplate:n,title:r,metadata:o,readCallback:s,enabled:!0,disable:()=>a.update({enabled:!1}),enable:()=>a.update({enabled:!0}),remove:()=>a.update({name:null}),update:u=>{typeof u.name<"u"&&u.name!==t&&(delete this._registeredResourceTemplates[t],u.name&&(this._registeredResourceTemplates[u.name]=a)),typeof u.title<"u"&&(a.title=u.title),typeof u.template<"u"&&(a.resourceTemplate=u.template),typeof u.metadata<"u"&&(a.metadata=u.metadata),typeof u.callback<"u"&&(a.readCallback=u.callback),typeof u.enabled<"u"&&(a.enabled=u.enabled),this.sendResourceListChanged()}};this._registeredResourceTemplates[t]=a;let c=n.uriTemplate.variableNames;return Array.isArray(c)&&c.some(u=>!!n.completeCallback(u))&&this.setCompletionRequestHandler(),a}_createRegisteredPrompt(t,r,n,o,s){let a={title:r,description:n,argsSchema:o===void 0?void 0:ni(o),callback:s,enabled:!0,disable:()=>a.update({enabled:!1}),enable:()=>a.update({enabled:!0}),remove:()=>a.update({name:null}),update:c=>{typeof c.name<"u"&&c.name!==t&&(delete this._registeredPrompts[t],c.name&&(this._registeredPrompts[c.name]=a)),typeof c.title<"u"&&(a.title=c.title),typeof c.description<"u"&&(a.description=c.description),typeof c.argsSchema<"u"&&(a.argsSchema=ni(c.argsSchema)),typeof c.callback<"u"&&(a.callback=c.callback),typeof c.enabled<"u"&&(a.enabled=c.enabled),this.sendPromptListChanged()}};return this._registeredPrompts[t]=a,o&&Object.values(o).some(l=>{let u=l instanceof Ct?l._def?.innerType:l;return iN(u)})&&this.setCompletionRequestHandler(),a}_createRegisteredTool(t,r,n,o,s,a,c,l,u){aN(t);let d={title:r,description:n,inputSchema:$9(o),outputSchema:$9(s),annotations:a,execution:c,_meta:l,handler:u,enabled:!0,disable:()=>d.update({enabled:!1}),enable:()=>d.update({enabled:!0}),remove:()=>d.update({name:null}),update:p=>{typeof p.name<"u"&&p.name!==t&&(typeof p.name=="string"&&aN(p.name),delete this._registeredTools[t],p.name&&(this._registeredTools[p.name]=d)),typeof p.title<"u"&&(d.title=p.title),typeof p.description<"u"&&(d.description=p.description),typeof p.paramsSchema<"u"&&(d.inputSchema=ni(p.paramsSchema)),typeof p.outputSchema<"u"&&(d.outputSchema=ni(p.outputSchema)),typeof p.callback<"u"&&(d.handler=p.callback),typeof p.annotations<"u"&&(d.annotations=p.annotations),typeof p._meta<"u"&&(d._meta=p._meta),typeof p.enabled<"u"&&(d.enabled=p.enabled),this.sendToolListChanged()}};return this._registeredTools[t]=d,this.setToolRequestHandlers(),this.sendToolListChanged(),d}tool(t,...r){if(this._registeredTools[t])throw new Error(`Tool ${t} is already registered`);let n,o,s,a;if(typeof r[0]=="string"&&(n=r.shift()),r.length>1){let l=r[0];if(lN(l))o=r.shift(),r.length>1&&typeof r[0]=="object"&&r[0]!==null&&!lN(r[0])&&(a=r.shift());else if(typeof l=="object"&&l!==null){if(Object.values(l).some(u=>typeof u=="object"&&u!==null))throw new Error(`Tool ${t} expected a Zod schema or ToolAnnotations, but received an unrecognized object`);a=r.shift()}}let c=r[0];return this._createRegisteredTool(t,void 0,n,o,s,a,{taskSupport:"forbidden"},void 0,c)}registerTool(t,r,n){if(this._registeredTools[t])throw new Error(`Tool ${t} is already registered`);let{title:o,description:s,inputSchema:a,outputSchema:c,annotations:l,_meta:u}=r;return this._createRegisteredTool(t,o,s,a,c,l,{taskSupport:"forbidden"},u,n)}prompt(t,...r){if(this._registeredPrompts[t])throw new Error(`Prompt ${t} is already registered`);let n;typeof r[0]=="string"&&(n=r.shift());let o;r.length>1&&(o=r.shift());let s=r[0],a=this._createRegisteredPrompt(t,void 0,n,o,s);return this.setPromptRequestHandlers(),this.sendPromptListChanged(),a}registerPrompt(t,r,n){if(this._registeredPrompts[t])throw new Error(`Prompt ${t} is already registered`);let{title:o,description:s,argsSchema:a}=r,c=this._createRegisteredPrompt(t,o,s,a,n);return this.setPromptRequestHandlers(),this.sendPromptListChanged(),c}isConnected(){return this.server.transport!==void 0}async sendLoggingMessage(t,r){return this.server.sendLoggingMessage(t,r)}sendResourceListChanged(){this.isConnected()&&this.server.sendResourceListChanged()}sendToolListChanged(){this.isConnected()&&this.server.sendToolListChanged()}sendPromptListChanged(){this.isConnected()&&this.server.sendPromptListChanged()}};i(uN,"McpServer");var ly=uN;var hae={type:"object",properties:{}};function N9(e){return e!==null&&typeof e=="object"&&"parse"in e&&typeof e.parse=="function"&&"safeParse"in e&&typeof e.safeParse=="function"}i(N9,"isZodTypeLike");function T9(e){return"_def"in e||"_zod"in e||N9(e)}i(T9,"isZodSchemaInstance");function lN(e){return typeof e!="object"||e===null||T9(e)?!1:Object.keys(e).length===0?!0:Object.values(e).some(N9)}i(lN,"isZodRawShapeCompat");function $9(e){if(e){if(lN(e))return ni(e);if(!T9(e))throw new Error("inputSchema must be a Zod schema or raw shape, received an unrecognized object");return e}}i($9,"getZodSchemaObject");function gae(e){let t=ko(e);return t?Object.entries(t).map(([r,n])=>{let o=YZ(n),s=XZ(n);return{name:r,description:o,required:!s}}):[]}i(gae,"promptArgumentsFromSchema");function Ro(e){let r=ko(e)?.method;if(!r)throw new Error("Schema is missing a method literal");let n=Ka(r);if(typeof n=="string")return n;throw new Error("Schema method literal must be a string")}i(Ro,"getMethodValue");function E9(e){return{completion:{values:e.slice(0,100),total:e.length,hasMore:e.length>100}}}i(E9,"createCompletionResult");var Zd={completion:{values:[],hasMore:!1}};import C9 from"process";var yae=10*1024*1024,dN=class dN{constructor(t){this._maxBufferSize=t?.maxBufferSize??yae}append(t){if((this._buffer?.length??0)+t.length>this._maxBufferSize)throw this.clear(),new Error(`ReadBuffer exceeded maximum size of ${this._maxBufferSize} bytes`);this._buffer=this._buffer?Buffer.concat([this._buffer,t]):t}readMessage(){if(!this._buffer)return null;let t=this._buffer.indexOf(`
357
+ `);if(t===-1)return null;let r=this._buffer.toString("utf8",0,t).replace(/\r$/,"");return this._buffer=this._buffer.subarray(t+1),xae(r)}clear(){this._buffer=void 0}};i(dN,"ReadBuffer");var uy=dN;function xae(e){return zL.parse(JSON.parse(e))}i(xae,"deserializeMessage");function z9(e){return JSON.stringify(e)+`
358
+ `}i(z9,"serializeMessage");var pN=class pN{constructor(t=C9.stdin,r=C9.stdout,n){this._stdin=t,this._stdout=r,this._started=!1,this._ondata=o=>{try{this._readBuffer.append(o),this.processReadBuffer()}catch(s){this.onerror?.(s),this.close().catch(()=>{})}},this._onerror=o=>{this.onerror?.(o)},this._readBuffer=new uy({maxBufferSize:n?.maxBufferSize})}async start(){if(this._started)throw new Error("StdioServerTransport already started! If using Server class, note that connect() calls start() automatically.");this._started=!0,this._stdin.on("data",this._ondata),this._stdin.on("error",this._onerror)}processReadBuffer(){for(;;)try{let t=this._readBuffer.readMessage();if(t===null)break;this.onmessage?.(t)}catch(t){this.onerror?.(t)}}async close(){this._stdin.off("data",this._ondata),this._stdin.off("error",this._onerror),this._stdin.listenerCount("data")===0&&this._stdin.pause(),this._readBuffer.clear(),this.onclose?.()}send(t){return new Promise(r=>{let n=z9(t);this._stdout.write(n)?r():this._stdout.once("drain",r)})}};i(pN,"StdioServerTransport");var dy=pN;ab();Rn();import{resolve as _ae}from"path";async function vae(e,t=2e3){let r=new AbortController,n=setTimeout(()=>r.abort(),t);try{return(await fetch(`${e.replace(/\/+$/,"")}/mcp/scene?root=app&depth=0`,{signal:r.signal})).ok}catch{return!1}finally{clearTimeout(n)}}i(vae,"verifyDesignServer");async function I9({projectPath:e}={}){let t=e?{projectRoot:_ae(e)}:G_(process.cwd());if(!t?.projectRoot)throw new Error("Not a Jucie project. Use --project <path>");let r=J_(t.projectRoot);if(!r)throw new Error("No active design session. Run: jucie design");if(!K_(r))throw new Error("Design session expired. Run: jucie design");let n=typeof r.url=="string"?r.url:null;if(!n)throw new Error("No active design session. Run: jucie design");if(!await vae(n))throw new Error("Design server not responding. Is jucie design still running?");return{projectRoot:t.projectRoot,url:n}}i(I9,"resolveMcpEndpoint");async function P9(e={}){let t;try{t=await I9({projectPath:e.project})}catch(m){console.error(`
359
+ \u274C ${m.message}
360
+ `),process.exit(1)}let r=t.url.replace(/\/+$/,"");async function n({root:m="app",depth:h}={}){let g=new URLSearchParams({root:m});h!=null&&g.set("depth",String(h));let _=await fetch(`${r}/mcp/scene?${g}`);if(!_.ok)throw new Error(`design server returned ${_.status}`);return _.json()}i(n,"getScene");async function o(m){let h=await fetch(`${r}/mcp/operations`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({operations:m})});if(!h.ok)throw new Error(`design server returned ${h.status}`);return h.json()}i(o,"postOperations");let s={String:()=>Oe.string(),Number:()=>Oe.number(),Boolean:()=>Oe.boolean(),Object:()=>Oe.record(Oe.unknown()),Array:()=>Oe.array(Oe.unknown()),Any:()=>Oe.unknown()};function a(m){let h=Array.isArray(m)?m[0]:null;if(!h||typeof h!="object")return{};let g={};for(let[_,x]of Object.entries(h)){let v=typeof x=="string"&&x.endsWith("?"),b=v?x.slice(0,-1):x,w=(s[b]??s.Any)();v&&(w=w.optional()),g[_]=w}return g}i(a,"toZodShape");function c(m){let h=[m.description];if(m.examples?.length){let g=m.examples[0];h.push(`Example args: ${JSON.stringify(g.args)}`)}return m.returns&&h.push(`Returns: ${m.returns}`),h.filter(Boolean).join(`
361
+ `)}i(c,"buildToolDescription");let l=new ly({name:"jucie",version:"0.1.0"}),u=i(m=>async h=>{try{return{content:[{type:"text",text:await m(h)}]}}catch(g){return{isError:!0,content:[{type:"text",text:`Error: ${g.message}`}]}}},"tool"),d=ib.map(m=>Kr(m));for(let m of d)for(let h of m.operations)h.mcpName&&l.registerTool(h.mcpName,{description:c(h),inputSchema:a(h.schema)},u(async g=>{let{results:_}=await o([{type:h.fullName,args:g}]);return JSON.stringify(_[0])}));l.registerTool("get_scene",{description:'Read the current scene graph as JSX. Use root="app" for the full tree or a node id for a subtree. depth limits nesting (omit for unlimited).',inputSchema:{root:Oe.string().optional().describe("Root node id (default: app)"),depth:Oe.number().optional().describe("Max depth to expand (omit for full tree)")}},u(async m=>{let h=await n(m);return h.jsx??h.error??JSON.stringify(h)})),l.registerTool("set_route",{description:"Set the route path on a frame node. Use this to configure multi-page navigation. Pass isHome=true to mark it as the home/root route.",inputSchema:{nodeId:Oe.string().describe("Frame node id"),path:Oe.string().optional().describe('Route path, e.g. "/dashboard" or "/users/:id"'),isHome:Oe.boolean().optional().describe("If true, marks this frame as the home route (path becomes /)")}},u(async({nodeId:m,path:h,isHome:g})=>{let _=[];g?_.push({op:"setHomePage",nodeId:m,isHomePage:!0}):h!==void 0&&_.push({op:"updateRoute",nodeId:m,route:{path:h}});let{results:x}=await o(_);return JSON.stringify(x)})),l.registerTool("set_destination",{description:"Set a navigation destination on a link or button node. When the node is clicked it will navigate to the given path.",inputSchema:{nodeId:Oe.string().describe("Target node id (a or button)"),path:Oe.string().describe('Route path to navigate to, e.g. "/sign-up"')}},u(async({nodeId:m,path:h})=>{let{results:g}=await o([{op:"setDestination",nodeId:m,destination:{path:h}}]);return JSON.stringify(g[0])})),l.registerTool("create_instance",{description:"Place an instance of a component into the scene. Use componentId (from add_component) for local components. Use component name + library for external library components.",inputSchema:{component:Oe.string().describe("Component node id (local) or component name string (library)"),parent:Oe.string().describe("Parent node id"),library:Oe.string().optional().describe('Library name for external components (e.g. "my-ui"). Omit for local components.'),name:Oe.string().optional().describe("Display name for the instance")}},u(async({component:m,parent:h,library:g,name:_})=>{let{results:x}=await o([{op:"create",type:"instance",parent:h,props:{component:m,library:g??null,name:_}}]);return JSON.stringify(x[0])})),l.registerTool("batch",{description:Hm(d),inputSchema:{operations:Oe.array(Oe.record(Oe.unknown())).describe("Ordered array of operation objects")}},u(async({operations:m})=>{let{results:h}=await o(m);return JSON.stringify(h)})),l.registerTool("screenshot",{description:"Capture a screenshot of every frame (page) in the current design. Returns one labeled image per frame so you can visually verify each page and correlate it with get_scene output by node id.",inputSchema:{}},async()=>{try{let m=await fetch(`${r}/mcp/screenshot`);if(!m.ok)throw new Error(`screenshot failed: ${m.status}`);let{frames:h,error:g}=await m.json();return g?{isError:!0,content:[{type:"text",text:`Error: ${g}`}]}:h?.length?{content:h.flatMap(x=>{let v=String(x.imageData??""),b=v.match(/^data:(image\/\w+);base64,(.+)$/s),w=b?.[1]??"image/jpeg",S=b?.[2]??v;return[{type:"text",text:`Frame: ${x.name} (id: ${x.id})`},{type:"image",data:S,mimeType:w}]})}:{isError:!0,content:[{type:"text",text:"No frames found in scene"}]}}catch(m){return{isError:!0,content:[{type:"text",text:`Error: ${m.message}`}]}}});let p=new dy;await l.connect(p)}i(P9,"mcpCommand");var $ae=kae(import.meta.url),Eae=Sae($ae),hN=JSON.parse(wae(bae(Eae,"../package.json"),"utf8")),Jt=process.argv.slice(2),fN=Jt[0],O9=Jt[1],gi={help:Jt.includes("--help")||Jt.includes("-h"),version:Jt.includes("--version")||Jt.includes("-v"),verbose:Jt.includes("--verbose")};function Ld(e,t){let r=Jt.indexOf(`--${e}`),n=t?Jt.indexOf(`-${t}`):-1,o=r!==-1?r:n;if(o!==-1&&Jt[o+1]&&!Jt[o+1].startsWith("-"))return Jt[o+1]}i(Ld,"getOption");function mN(e){return Jt.includes(`--${e}`)}i(mN,"hasFlag");var py={config:Ld("config"),outdir:Ld("outdir","o"),branch:Ld("branch","b"),framework:Ld("framework","f"),minify:mN("minify")?!0:void 0,sourcemap:mN("sourcemap"),analyze:mN("analyze")};function A9(){console.log(`
362
+ Jucie CLI v${hN.version}
303
363
 
304
364
  Usage:
305
365
  jucie <command> [options]
@@ -332,14 +392,14 @@ Examples:
332
392
  jucie dev
333
393
  jucie build
334
394
  jucie build --outdir ./build --branch main --sourcemap
335
- `)}i(vL,"showHelp");function kte(){console.log(`Jucie CLI v${qk.version}`)}i(kte,"showVersion");async function $te(){Is.version&&(kte(),process.exit(0)),(Is.help||!Fk)&&(vL(),process.exit(0));try{switch(Fk){case"create":_L||(console.error(`
395
+ `)}i(A9,"showHelp");function Nae(){console.log(`Jucie CLI v${hN.version}`)}i(Nae,"showVersion");async function Tae(){gi.version&&(Nae(),process.exit(0)),(gi.help||!fN)&&(A9(),process.exit(0));try{switch(fN){case"create":O9||(console.error(`
336
396
  \u274C Error: Project name is required
337
397
  `),console.log(`Usage: jucie create <project-name>
338
- `),process.exit(1)),await Yy(_L,{...Is,framework:uh.framework,cliVersion:qk.version});break;case"design":await Z_(uh,Is);break;case"dev":await v_(uh,Is);break;case"build":await Cx(uh,Is);break;case"mcp":await xL({project:fu("project")});break;default:console.error(`
339
- \u274C Error: Unknown command "${Fk}"
340
- `),vL(),process.exit(1)}}catch(e){console.trace(`
398
+ `),process.exit(1)),await Y_(O9,{...gi,framework:py.framework,cliVersion:hN.version});break;case"design":await db(py,gi);break;case"dev":await Aw(py,gi);break;case"build":await Gv(py,gi);break;case"mcp":await P9({project:Ld("project")});break;default:console.error(`
399
+ \u274C Error: Unknown command "${fN}"
400
+ `),A9(),process.exit(1)}}catch(e){console.trace(`
341
401
  \u274C Error unknown: ${e.message}
342
- `),Is.verbose&&console.error(e.stack),process.exit(1)}}i($te,"main");$te();
402
+ `),gi.verbose&&console.error(e.stack),process.exit(1)}}i(Tae,"main");Tae();
343
403
  /*! Bundled license information:
344
404
 
345
405
  pako/dist/pako.esm.mjs: