@agimon-ai/po-cloudflare 0.0.2-alpha.7 → 0.0.2-alpha.71

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 (355) hide show
  1. package/README.md +64 -241
  2. package/container/Dockerfile +27 -0
  3. package/dist/{BrowserWebSocketTransport-C2SC2VeJ.js → BrowserWebSocketTransport-B4heNdrp.js} +1 -1
  4. package/dist/{NodeWebSocketTransport-CKilJesa.js → NodeWebSocketTransport-BCiOXUEz.js} +2 -2
  5. package/dist/{abort-signals-Bkmp_euQ.js → abort-signals-C8CttjsR.js} +1 -1
  6. package/dist/agent-CEqvgRl6.js +3878 -0
  7. package/dist/{anthropic-messages-CkYm8M3V.js → anthropic-messages-DCLLLNuM.js} +292 -64
  8. package/dist/apiContracts-DaOpUHnu.js +1719 -0
  9. package/dist/{approval-CQ3ZuoTy.js → approval-DXPV7Vm5.js} +15 -2
  10. package/dist/{approvalPrompt-CylV3C84.js → approvalPrompt-CBaxjb_g.js} +1 -2
  11. package/dist/approvalSession-C9bg7tPo.js +132 -0
  12. package/dist/artifactFiles-5KwXIxYf.js +1 -0
  13. package/dist/artifactsApi-bg2wMYWg.js +200 -0
  14. package/dist/assets/assets/{CodeEditorView-D4q94XH-.js → CodeEditorView-CfrVwzvL.js} +2 -2
  15. package/dist/assets/assets/{abnfDiagram-WEYOIA3C-C85p4OYZ.js → abnfDiagram-WEYOIA3C-B80H4Cm4.js} +2 -2
  16. package/dist/assets/assets/{architecture-WOLXFQ4H-Bt_NOdwE.js → architecture-WOLXFQ4H-Dr4hXaql.js} +1 -1
  17. package/dist/assets/assets/{architectureDiagram-ZHVYKT53-DzH1GKMm.js → architectureDiagram-ZHVYKT53-DWyt7oXu.js} +2 -2
  18. package/dist/assets/assets/{blockDiagram-RJAE7QA3-BmWU34j3.js → blockDiagram-RJAE7QA3-OxNTLdmi.js} +2 -2
  19. package/dist/assets/assets/{c4Diagram-XDPPPE54-BpGOdOuo.js → c4Diagram-XDPPPE54-B4YtcH0s.js} +2 -2
  20. package/dist/assets/assets/channel-bXj00dGj.js +2 -0
  21. package/dist/assets/assets/{chunk-2E7WHVMD-AycP1cXU.js → chunk-2E7WHVMD-CD6FFMOX.js} +2 -2
  22. package/dist/assets/assets/{chunk-4EMNKR2T-DX-DrZzc.js → chunk-4EMNKR2T-CEIoX5oo.js} +2 -2
  23. package/dist/assets/assets/{chunk-55XCU76K-BdwnLWzI.js → chunk-55XCU76K-CD3t0IJi.js} +2 -2
  24. package/dist/assets/assets/{chunk-7S6XSTFO-D-RBAwAn.js → chunk-7S6XSTFO-Cyt75UCF.js} +2 -2
  25. package/dist/assets/assets/{chunk-AQDTSKZB-CCxNNhKs.js → chunk-AQDTSKZB-DRtqYBj9.js} +2 -2
  26. package/dist/assets/assets/{chunk-DSNLSHJZ-D2hGwWm1.js → chunk-DSNLSHJZ-C8Fx2F8s.js} +2 -2
  27. package/dist/assets/assets/{chunk-HAGFOTED-BPi-cqGh.js → chunk-HAGFOTED-wOLWRRnd.js} +2 -2
  28. package/dist/assets/assets/{chunk-HNE4Q36P-D-r1ChHT.js → chunk-HNE4Q36P-CurJg4Hf.js} +2 -2
  29. package/dist/assets/assets/{chunk-NQOKRVIF-RgmZCAdn.js → chunk-NQOKRVIF-Dzcc5nOG.js} +2 -2
  30. package/dist/assets/assets/{chunk-UHW7PFBP-B-Hul-rZ.js → chunk-UHW7PFBP-B_ULFf2h.js} +2 -2
  31. package/dist/assets/assets/{chunk-VQ5W62QI-D1zlXCt8.js → chunk-VQ5W62QI-DH0VY4_p.js} +2 -2
  32. package/dist/assets/assets/{chunk-WQQL4CDK-CtjIbVJn.js → chunk-WQQL4CDK-DNxfLyXM.js} +2 -2
  33. package/dist/assets/assets/chunk-XXDRQBXY-B2bMWgN9.js +2 -0
  34. package/dist/assets/assets/{chunk-YZO67HFG-BQOgXG99.js → chunk-YZO67HFG-COuMUh9U.js} +2 -2
  35. package/dist/assets/assets/{chunk-ZAUX2LTX-CsDDxmqv.js → chunk-ZAUX2LTX-BJrCnubF.js} +2 -2
  36. package/dist/assets/assets/{chunk-ZCHMQSOR-deyEYMjx.js → chunk-ZCHMQSOR-D1lFKPtk.js} +2 -2
  37. package/dist/assets/assets/{classDiagram-v2-4MYWR3UA-DVJHeFlq.js → classDiagram-v2-4MYWR3UA-DfZIbyVL.js} +2 -2
  38. package/dist/assets/assets/{cose-bilkent-JH36ORCC-ipcN28Fw.js → cose-bilkent-JH36ORCC-CpGhv9_S.js} +2 -2
  39. package/dist/assets/assets/{cynefin-EF2NZ3EQ-s9ZkPF55.js → cynefin-EF2NZ3EQ-Cxdc6nQl.js} +1 -1
  40. package/dist/assets/assets/{cynefinDiagram-WF24UDRP-Ksr2qjsS.js → cynefinDiagram-WF24UDRP-qoj0w3lp.js} +2 -2
  41. package/dist/assets/assets/{dagre-NK4GIZVX-2_Wl-XEW.js → dagre-NK4GIZVX-DL6QbNDS.js} +2 -2
  42. package/dist/assets/assets/{diagram-CBK3MWTC-C7PeyT7l.js → diagram-CBK3MWTC-CJB3jq1_.js} +2 -2
  43. package/dist/assets/assets/{diagram-I5XIIV2D-DPYzeKdj.js → diagram-I5XIIV2D-4cPOxCxF.js} +2 -2
  44. package/dist/assets/assets/{diagram-ODIL2UCW-DHw1cAmn.js → diagram-ODIL2UCW-BG3-jAxE.js} +2 -2
  45. package/dist/assets/assets/{diagram-PFBEJUXE-C2wA8i-1.js → diagram-PFBEJUXE-Bx8dFaXj.js} +2 -2
  46. package/dist/assets/assets/{diagram-RJA3I4VV-tM3moCIs.js → diagram-RJA3I4VV-CUUHND91.js} +2 -2
  47. package/dist/assets/assets/{diagram-TYUNFSNR-CInyJxF7.js → diagram-TYUNFSNR-BDMoN-kr.js} +2 -2
  48. package/dist/assets/assets/{dist-BDqjNLTC.js → dist-5AxNm-uy.js} +2 -2
  49. package/dist/assets/assets/{dist-hpZIQBl4.js → dist-9_Rmyj2I.js} +2 -2
  50. package/dist/assets/assets/{dist-DSLprmec.js → dist-BE3CLKv4.js} +2 -2
  51. package/dist/assets/assets/{dist-BASEd5LC.js → dist-BfNCu-7x.js} +2 -2
  52. package/dist/assets/assets/{dist-BuYBvf4F.js → dist-BjI0b36Z.js} +2 -2
  53. package/dist/assets/assets/{dist-DUS0U_ge.js → dist-CM7b5P9a.js} +2 -2
  54. package/dist/assets/assets/{dist-CeOy6PjJ.js → dist-Ccxb9U1G.js} +2 -2
  55. package/dist/assets/assets/{dist-ChXoRSS6.js → dist-CjCWP21A.js} +2 -2
  56. package/dist/assets/assets/{dist-07dRlnp1.js → dist-DSTAktnR.js} +2 -2
  57. package/dist/assets/assets/{ebnfDiagram-V4P3TTPT-4nZgqaSt.js → ebnfDiagram-V4P3TTPT-BivOMXZb.js} +2 -2
  58. package/dist/assets/assets/{elk-QONTBCTQ-nFh54c1Q.js → elk-QONTBCTQ-CrJ1Qpy_.js} +2 -2
  59. package/dist/assets/assets/{erDiagram-KYQIGQAA-CIQ0_IgZ.js → erDiagram-KYQIGQAA-w9Bqp4sV.js} +2 -2
  60. package/dist/assets/assets/{eventmodeling-K75KTNOO-Cw4BlbYP.js → eventmodeling-K75KTNOO-CBjFM3kV.js} +1 -1
  61. package/dist/assets/assets/flowDiagram-IUGLLWBU-C6Fnfgm0.js +1 -0
  62. package/dist/assets/assets/{ganttDiagram-R7GPNTJY-C97qoUpX.js → ganttDiagram-R7GPNTJY-CsWtGaqD.js} +2 -2
  63. package/dist/assets/assets/{gitGraph-VSP46ZUC-B8HWVkEX.js → gitGraph-VSP46ZUC-DsBSV9_h.js} +1 -1
  64. package/dist/assets/assets/{gitGraphDiagram-PDYL7XHY-B4Js56_8.js → gitGraphDiagram-PDYL7XHY-D5GxuYHW.js} +2 -2
  65. package/dist/assets/assets/index-CNDyKUDF.css +1 -0
  66. package/dist/assets/assets/index-DWDYnZsq.js +256 -0
  67. package/dist/assets/assets/{info-OHQRW6UA-A4qythhA.js → info-OHQRW6UA-C7x5dSJu.js} +1 -1
  68. package/dist/assets/assets/{infoDiagram-MVDRKAX5-BSNwG9yI.js → infoDiagram-MVDRKAX5-CwpI-uAa.js} +2 -2
  69. package/dist/assets/assets/{ishikawaDiagram-HPEHV2GE-D4gU-3RA.js → ishikawaDiagram-HPEHV2GE-DAa7J5G6.js} +2 -2
  70. package/dist/assets/assets/{journeyDiagram-BOSHW7O7-CxxDrw7o.js → journeyDiagram-BOSHW7O7-BmiZnxE_.js} +2 -2
  71. package/dist/assets/assets/{kanban-definition-FNSA4HC5-DUxQv3v0.js → kanban-definition-FNSA4HC5-DUR_mA3L.js} +2 -2
  72. package/dist/assets/assets/{line-BKODXUmk.js → line-DHY49wSg.js} +2 -2
  73. package/dist/assets/assets/{linear-Cm5uyUun.js → linear-pTo-a9xT.js} +2 -2
  74. package/dist/assets/assets/{mermaid-parser.core-CYst2kCg.js → mermaid-parser.core-DMg3hN3T.js} +4 -4
  75. package/dist/assets/assets/{mermaid.core-B4Qq8SMa.js → mermaid.core-DKtPCltA.js} +5 -5
  76. package/dist/assets/assets/{mindmap-definition-6OY57UG3-CZFvUTIM.js → mindmap-definition-6OY57UG3-DwTkFbnV.js} +2 -2
  77. package/dist/assets/assets/{packet-JDAUHWVQ-DZMlaiuy.js → packet-JDAUHWVQ-Tu9TrQ1x.js} +1 -1
  78. package/dist/assets/assets/{pegDiagram-ECIUJNBX-BjM668dT.js → pegDiagram-ECIUJNBX-B7My4tsz.js} +2 -2
  79. package/dist/assets/assets/{pie-XZMESJXO-CmpJ6vb8.js → pie-XZMESJXO-QPQm5Gdx.js} +1 -1
  80. package/dist/assets/assets/{pieDiagram-GNMPY74T-BCA9DCDe.js → pieDiagram-GNMPY74T-Bv-zAD_z.js} +2 -2
  81. package/dist/assets/assets/{quadrantDiagram-D57K4MC3-CUnpC-Rl.js → quadrantDiagram-D57K4MC3-HTjoGQPd.js} +2 -2
  82. package/dist/assets/assets/{radar-ABXABTNO-C9x42-KP.js → radar-ABXABTNO-LDBlEoFo.js} +1 -1
  83. package/dist/assets/assets/{railroad-I3PHUGI6-CLvHKrsC.js → railroad-I3PHUGI6-Dy3_ymgZ.js} +1 -1
  84. package/dist/assets/assets/{railroad-abnf-LNEFI6M7-B0LGF3gx.js → railroad-abnf-LNEFI6M7-QLVvYs6e.js} +1 -1
  85. package/dist/assets/assets/{railroad-ebnf-DWYD2UWJ-SKnYapAj.js → railroad-ebnf-DWYD2UWJ-CFRlv9a8.js} +1 -1
  86. package/dist/assets/assets/{railroad-peg-JR7BVNR7-wsUpPloN.js → railroad-peg-JR7BVNR7-BOlq3d9c.js} +1 -1
  87. package/dist/assets/assets/{railroadDiagram-Y72NRBL7-BYJtosKO.js → railroadDiagram-Y72NRBL7-Chg32HoU.js} +2 -2
  88. package/dist/assets/assets/{requirementDiagram-EQYSW5RA-YYdoWMnl.js → requirementDiagram-EQYSW5RA-VenIs_eg.js} +2 -2
  89. package/dist/assets/assets/{sankeyDiagram-SY24JHO5-DtZyCTdM.js → sankeyDiagram-SY24JHO5-BdByqMKF.js} +2 -2
  90. package/dist/assets/assets/{sequenceDiagram-BLEHNHQU-BPE8f413.js → sequenceDiagram-BLEHNHQU-D3Do4GJE.js} +2 -2
  91. package/dist/assets/assets/{src-BNTOLq2G.js → src-DmfN-DA-.js} +2 -2
  92. package/dist/assets/assets/{stateDiagram-v2-A6IESKWZ-9f8Ow4Fl.js → stateDiagram-v2-A6IESKWZ-CZkRbPlf.js} +2 -2
  93. package/dist/assets/assets/{swimlanes-B3ENRKFQ-DdAEbxGp.js → swimlanes-B3ENRKFQ-DRTdF9AF.js} +2 -2
  94. package/dist/assets/assets/swimlanesDiagram-AYQRV4AK-BYr_4JUb.js +9 -0
  95. package/dist/assets/assets/{timeline-definition-JXYKGLGB-DJNGd2mU.js → timeline-definition-JXYKGLGB-BVcuws_M.js} +2 -2
  96. package/dist/assets/assets/{treeView-D4JQ5SDB-BHONoCCw.js → treeView-D4JQ5SDB-BLtOJGqO.js} +1 -1
  97. package/dist/assets/assets/{treemap-SAJKECNS-pOaYkxq7.js → treemap-SAJKECNS-Dn3BWJ4v.js} +1 -1
  98. package/dist/assets/assets/{usecaseDiagram-WPOLBNNX-C3eDYL9v.js → usecaseDiagram-WPOLBNNX-CBExIKDY.js} +2 -2
  99. package/dist/assets/assets/{vennDiagram-Q3Y3IDCW-CJi1xfsR.js → vennDiagram-Q3Y3IDCW-C6FIx2L4.js} +2 -2
  100. package/dist/assets/assets/{wardley-7MLQ67FV-CEy4w7Ir.js → wardley-7MLQ67FV-Cjj2xSBp.js} +1 -1
  101. package/dist/assets/assets/{wardleyDiagram-IVAIDKWA-DfdLMMpN.js → wardleyDiagram-IVAIDKWA-sQPCBCFK.js} +2 -2
  102. package/dist/assets/assets/{webpack-v8XGbQTa.js → webpack-DDCA0aDL.js} +2 -2
  103. package/dist/assets/assets/{xychartDiagram-4URNHDU4-Aw-Ix4uC.js → xychartDiagram-4URNHDU4-bZ4rifSw.js} +2 -2
  104. package/dist/assets/bundle-asset-policy.json +1 -1
  105. package/dist/assets/index.html +8 -2
  106. package/dist/assets/mascot/cta-provider.png +0 -0
  107. package/dist/assets/mascot/cta-sign-in.png +0 -0
  108. package/dist/assets/plugins/assets/base-GzIOAd-t.css +2 -0
  109. package/dist/assets/plugins/assets/browserCaptureWorklet-Droj0fW0-Droj0fW0.js +13 -0
  110. package/dist/assets/plugins/assets/day-bottom-left-5um-x02r-5um-x02r.webp +0 -0
  111. package/dist/assets/plugins/assets/day-grain-CvEuNhlI-CvEuNhlI.webp +0 -0
  112. package/dist/assets/plugins/assets/day-right-C9W-XtjV-C9W-XtjV.webp +0 -0
  113. package/dist/assets/plugins/assets/day-top-left-B544Eq9J-B544Eq9J.webp +0 -0
  114. package/dist/assets/plugins/assets/night-bottom-left-N03ST5Uz-N03ST5Uz.webp +0 -0
  115. package/dist/assets/plugins/assets/night-grain-BY9q-tNN-BY9q-tNN.webp +0 -0
  116. package/dist/assets/plugins/assets/night-right-C6Denrqj-C6Denrqj.webp +0 -0
  117. package/dist/assets/plugins/assets/night-top-left-KOou6UxY-KOou6UxY.webp +0 -0
  118. package/dist/assets/plugins/assets/sileroVadWorker-D894njUe-DjN_BMWf.mjs +110 -0
  119. package/dist/assets/plugins/assets/silero_vad_v6.2.1-SjbCxFXk-SjbCxFXk.onnx +0 -0
  120. package/dist/assets/plugins/chunks/po-web-runtime-D8FIos2q.js +1 -0
  121. package/dist/assets/plugins/chunks/schemas-DVQ8BvvP.js +55 -0
  122. package/dist/assets/plugins/compositions.json +1 -1
  123. package/dist/assets/plugins/slots/approval.09e72f36-DxS_uibk.js +2 -0
  124. package/dist/assets/plugins/slots/artifacts.50b639bb-Cp37TAkd.js +1 -0
  125. package/dist/assets/plugins/slots/author.ea449ace-Ds9Y-tjN.js +93 -0
  126. package/dist/assets/plugins/slots/autocompact.6f428144-CDZpN7I7.js +1 -0
  127. package/dist/assets/plugins/slots/backdrop-bamboo.6e4c928d-qbifuMc6.js +1 -0
  128. package/dist/assets/plugins/slots/browse.fa1f1a50-CVYvo1M5.js +1 -0
  129. package/dist/assets/plugins/slots/builtin-tools.75108f21-Cq1ljoL-.js +7 -0
  130. package/dist/assets/plugins/slots/calendar.d8b70190-BBjpOs1v.js +2 -0
  131. package/dist/assets/plugins/slots/codemode.c58fb583-DOR6OR7R.js +11 -0
  132. package/dist/assets/plugins/slots/domain.753f9f92-CJrXxig9.js +1 -0
  133. package/dist/assets/plugins/slots/edit.804fec90-BFF7_xN9.js +7 -0
  134. package/dist/assets/plugins/slots/files.66ffc636-CzOlZrRm.js +2 -0
  135. package/dist/assets/plugins/slots/goal.45dffa01-BtQBp3sw.js +1 -0
  136. package/dist/assets/plugins/slots/grep.98262cff-9bUDfjyT.js +1 -0
  137. package/dist/assets/plugins/slots/help.5fbd20f7-B4-y6gYK.js +3 -0
  138. package/dist/assets/plugins/slots/log.cb964209-BRPa3cVs.js +4 -0
  139. package/dist/assets/plugins/slots/mcp.82cc1ff5-CFtzPkPC.js +55 -0
  140. package/dist/assets/plugins/slots/plan.3852ba52-CH59Ff49.js +3 -0
  141. package/dist/assets/plugins/slots/profile.ab16dcec-0e9fWWyE.js +1 -0
  142. package/dist/assets/plugins/slots/prompts.ae48c07a-BTqYnBX5.js +38 -0
  143. package/dist/assets/plugins/slots/read.4560591a-C7fMXDEH.js +1 -0
  144. package/dist/assets/plugins/slots/runner.6e494d59-CqrpqhW9.js +9 -0
  145. package/dist/assets/plugins/slots/scaffold.d87a6ee0-9qY5gkYW.js +1 -0
  146. package/dist/assets/plugins/slots/session-mcp.2be84084-Cf0cqopp.js +2 -0
  147. package/dist/assets/plugins/slots/sessions.6f47cb4c-B1_eqPJQ.js +1 -0
  148. package/dist/assets/plugins/slots/skill.62a0a1b3-D-SKX8iw.js +4 -0
  149. package/dist/assets/plugins/slots/space.65a27e5a-fbLHc-DX.js +1 -0
  150. package/dist/assets/plugins/slots/subagents.8bb9992c-Cm_YMEnn.js +7 -0
  151. package/dist/assets/plugins/slots/template-advanced.59f3f98a-L0WOM4JT.js +1 -0
  152. package/dist/assets/plugins/slots/template-desktop.0f0b8491-By9BZlaL.js +7 -0
  153. package/dist/assets/plugins/slots/template-elegant.0e3b0acf-El05x7HK.js +1 -0
  154. package/dist/assets/plugins/slots/vault.3cbfcdc3-DpU_65Wy.js +1 -0
  155. package/dist/assets/plugins/slots/voice.a952113d-CvcuL__m.js +1 -0
  156. package/dist/assets/plugins/slots/web-search.65013836-NVh9fdvE.js +1 -0
  157. package/dist/assets/plugins/slots/workflows.cbc5c5c0-OLKSY9PE.js +16 -0
  158. package/dist/assets/pwa/pwa.js +12 -12
  159. package/dist/assets/pwa/sw.js +58 -4
  160. package/dist/{atomicJson-wczZBXQP.js → atomicJson-XYtxz032.js} +2 -3
  161. package/dist/{azure-openai-config-DHMgdIa-.js → azure-openai-config-S-quxzTC.js} +2 -2
  162. package/dist/{azure-openai-responses-CTgRdQ4m.js → azure-openai-responses-DdpV5zh7.js} +13 -13
  163. package/dist/backgroundWork-Bv0ib_lY.js +49 -0
  164. package/dist/{layeredConfig-xmTHGrw8.js → browser-DwY5dXHX.js} +21 -983
  165. package/dist/{browser-EJ5_ffnN.js → browser-IsHIcvFg.js} +1 -1
  166. package/dist/browser-ks_k-6KA.js +36 -0
  167. package/dist/calendarSetup-CI3AACVo.js +3892 -0
  168. package/dist/childProcess-Cv8rJuUf.js +32 -0
  169. package/dist/childSession-BrDCrNtL.js +25 -0
  170. package/dist/{classifier-shared-jXm-plIK.js → classifier-shared-DFprgrML.js} +5 -5
  171. package/dist/{cloudflare-workers-ai-system-one-B0wH6HU5.js → cloudflare-workers-ai-system-one-B0MD19yZ.js} +3 -3
  172. package/dist/{codemode-CFVDmyGm.js → codemode-LpcMFMYM.js} +1 -1
  173. package/dist/coerce-DM9YrILC.js +13 -0
  174. package/dist/config-DeWkdjj7.js +1372 -0
  175. package/dist/contextContributions-C1bsEJef.js +13 -0
  176. package/dist/contracts-CW8o6Xyi.js +19 -0
  177. package/dist/contracts-WRa9e98H.js +40 -0
  178. package/dist/cordisHost-_-jtkneB.js +25 -0
  179. package/dist/delegation-B2rBgv8A.js +100 -0
  180. package/dist/{diagnostics-DPTP-yrt.js → diagnostics-BY5LXbHJ.js} +2 -2
  181. package/dist/{dist-BVBi6VMV.js → dist-B2ArMqge.js} +1 -1
  182. package/dist/{server-Cg07O2W6.js → dist-C6IqjC-m.js} +1 -546
  183. package/dist/{dist-PDDFdqDX.js → dist-CDz5dYMj.js} +1 -1
  184. package/dist/{dist-Dvx5mlIR.js → dist-kgi2Ix1y.js} +16 -3
  185. package/dist/{emscripten-module.cloudflare-D4Bc9Ykz.js → emscripten-module.cloudflare-B4fhfquU.js} +1 -1
  186. package/dist/{env-api-keys-CAnjjnsR.js → env-api-keys-BgCPpU9t.js} +1 -1
  187. package/dist/{error-body-DQZRsyL5.js → error-body-CeumezyR.js} +26 -4
  188. package/dist/esm-BKJy3O9-.js +1553 -0
  189. package/dist/{remoteMcp-DqE2xFWS.js → exports-BEEgtkya.js} +1588 -714
  190. package/dist/{exports-LjvSY7Y6.js → exports-CBp_9dVk.js} +47 -28
  191. package/dist/exports-CRjRvvX0.js +34 -0
  192. package/dist/exports-Cg0wxflf.js +1 -0
  193. package/dist/exports-Ct56PRB9.js +46 -0
  194. package/dist/extensionFile-B940JOEn.js +121 -0
  195. package/dist/{factory-Cs8iaUtc.js → factory-BU0cZY0I.js} +1 -1
  196. package/dist/{github-copilot-headers-DpQQAh-s.js → github-copilot-headers-Cq9pnpl2.js} +1 -1
  197. package/dist/{google-generative-ai-BTTOo5RQ.js → google-generative-ai-DmbUlCGv.js} +9 -9
  198. package/dist/{google-shared-S7bqOccz.js → google-shared-Diz2uk39.js} +6 -6
  199. package/dist/{google-vertex-BcMU_DMb.js → google-vertex-CGCpI9Po.js} +10 -10
  200. package/dist/{domains-B6Ae4swm.js → harnessState-Df--jB5z.js} +162 -42
  201. package/dist/{harnessStore-Ccbia9_u.js → harnessStore-DInwiLYb.js} +4 -5
  202. package/dist/{hash-B3RRpLS2.js → hash-IQBoLxOB.js} +1 -1
  203. package/dist/{headers-BEuxFxDI.js → headers-Dkgiqogr.js} +1 -1
  204. package/dist/help-C9UGKetC.js +100 -0
  205. package/dist/home-kwZFHqOx.js +60 -0
  206. package/dist/http-BekstF5S.js +64 -0
  207. package/dist/hubChannel-Dldv3EEb.js +32 -0
  208. package/dist/hubRevisions-BPoC6quI.js +364 -0
  209. package/dist/{identity-BIeAyilV.js → identity-BzB1N-Sn.js} +3 -3
  210. package/dist/index.edge-BiVQ9LoZ.js +198 -0
  211. package/dist/index.edge-CSGx6QOL.js +56 -0
  212. package/dist/index.edge-ClLTmPFz.js +191 -0
  213. package/dist/index.edge-CzoLWbyl.js +238 -0
  214. package/dist/index.edge-D1biKw71.js +946 -0
  215. package/dist/index.edge-D2RirEwK.js +14 -0
  216. package/dist/iso-BGFmgtky.js +27 -0
  217. package/dist/{kysely-adapter-D51abb3q.js → kysely-adapter-D8KUrWxm.js} +1 -1
  218. package/dist/liquid.browser-1BcykmIN.js +4596 -0
  219. package/dist/manualTranscription-DN56fzgj.js +96 -0
  220. package/dist/{mcpProjection-BXiECnW0.js → mcpProjection-D2U50Pel.js} +1 -2
  221. package/dist/meta-CVgfTHQP.js +1030 -0
  222. package/dist/migrations-DJBPDwSR.js +32 -0
  223. package/dist/{mistral-conversations-DN8VSERk.js → mistral-conversations-Bv_m1MRF.js} +12 -12
  224. package/dist/modeDefinition-Di95_IiU.js +44 -0
  225. package/dist/{models-D6d73jcW.js → models-D50yN8Ag.js} +41 -46
  226. package/dist/{node-UuMT2C3q.js → node-B4kSjHeD.js} +2 -2
  227. package/dist/{node-DytJOfYf.js → node-CBLSc-YH.js} +1 -1
  228. package/dist/notification-DjxbNoMR.js +143 -0
  229. package/dist/{openai-bt3ZRBZv.js → openai-D6Q-l6hT.js} +187 -187
  230. package/dist/{openai-codex-responses-cL36x0ml.js → openai-codex-responses-BnoiTqYV.js} +21 -25
  231. package/dist/{openai-completions-BWsTNYyT.js → openai-completions-C68qs5rI.js} +26 -19
  232. package/dist/{openai-decisions-Dfn_KgQd.js → openai-decisions-BSxU_aoV.js} +3 -3
  233. package/dist/{openai-responses-aa0LoyCJ.js → openai-responses-D6hXen-k.js} +17 -15
  234. package/dist/{openai-responses-shared-H-jH5SlM.js → openai-responses-shared-BD8K7FAC.js} +7 -7
  235. package/dist/{openrouter-cost-D99Qqcs6.js → openrouter-cost-BPam8wyW.js} +1 -1
  236. package/dist/{openrouter-images-BpwVpALC.js → openrouter-images-DylXiHy7.js} +7 -7
  237. package/dist/{hubChannel-Dn5NMpvu.js → packageApi-DYkaxP59.js} +33 -42
  238. package/dist/photon_rs_bg.wasm +0 -0
  239. package/dist/{pi-messages-BHAIkYBj.js → pi-messages-DaIlYYlO.js} +6 -6
  240. package/dist/piConfig-5tRPD0ov.js +126 -0
  241. package/dist/piSettings-ekBG5OeF.js +1 -0
  242. package/dist/platform-CQahdzpG.js +138 -0
  243. package/dist/pluginCatalog-BAALyedS.js +30 -0
  244. package/dist/pluginContributions-Be9EnCAW.js +16 -0
  245. package/dist/pluginProtocol-7_gVUeM9.js +1 -0
  246. package/dist/pluginProtocol-DVIfJnav.js +135 -0
  247. package/dist/portableConfig-0tnk9anb.js +49 -0
  248. package/dist/presetConfig-n-oiNd3h.js +541 -0
  249. package/dist/profileSources-D1rymC97.js +537 -0
  250. package/dist/{protocol-DUeE0Q8z.js → protocol-Cri0GpZR.js} +1 -2
  251. package/dist/{provider-env-DgfpjgTa.js → provider-env-DJb40UF7.js} +2 -2
  252. package/dist/{provider-retry-ChD-K2Gv.js → provider-retry-jpvs7ixx.js} +1 -1
  253. package/dist/{puppeteer-cloudflare-B-GHrPGO.js → puppeteer-cloudflare-D4l8smMS.js} +3 -3
  254. package/dist/{server-BWJmxCrm.js → readiness-Ydw5zrKy.js} +4 -169
  255. package/dist/{rolldown-runtime-B-lAHAz2.js → rolldown-runtime-DbVrKiKs.js} +1 -1
  256. package/dist/{sanitize-unicode-Dl4ROF7y.js → sanitize-unicode-B1ZFaEtf.js} +1 -1
  257. package/dist/scaffoldRegistry-CeFe3Pf0.js +1240 -0
  258. package/dist/{schemas-Vj8-rCR4.js → schemas-D2dRon18.js} +1901 -53
  259. package/dist/server-AKM07WcM.js +466 -0
  260. package/dist/server-B0tM5Ygf.js +1300 -0
  261. package/dist/server-B8-vStCx.js +1116 -0
  262. package/dist/server-BAbdiL38.js +15108 -0
  263. package/dist/server-BCZ_R3kX.js +3326 -0
  264. package/dist/server-BGKAeB3M.js +492 -0
  265. package/dist/server-BIQhg1jS.js +26985 -0
  266. package/dist/server-BcPD_6a2.js +1533 -0
  267. package/dist/server-BeoA0QB-.js +580 -0
  268. package/dist/server-BsgvOpBF.js +24 -0
  269. package/dist/server-BtnOqSB5.js +156 -0
  270. package/dist/server-C-HBjWRo.js +2800 -0
  271. package/dist/{server-CWg0m_wq.js → server-C0Lt6nTt.js} +269 -1062
  272. package/dist/server-C8NPfG1H.js +148 -0
  273. package/dist/server-CKkaxOc0.js +978 -0
  274. package/dist/server-CMaWF5UA.js +1379 -0
  275. package/dist/server-CQPI6jIa.js +295 -0
  276. package/dist/{server-BhYE7Vqk.js → server-CQmb0lYL.js} +114 -176
  277. package/dist/server-CWR34Vx6.js +1884 -0
  278. package/dist/server-CZiAy2v5.js +641 -0
  279. package/dist/server-Cjtr0oVJ.js +584 -0
  280. package/dist/server-CkJQJ3Oo.js +571 -0
  281. package/dist/server-ClQQGtsI.js +679 -0
  282. package/dist/server-Cy2FhGBm.js +1744 -0
  283. package/dist/server-D8yEblCB.js +24 -0
  284. package/dist/server-DF0YIUeI.js +9603 -0
  285. package/dist/server-DRFESCq1.js +1527 -0
  286. package/dist/{server-zkcrP99W.js → server-Df1defzp.js} +89 -87
  287. package/dist/server-DgZd_TuT.js +189 -0
  288. package/dist/server-Dkc9Kth2.js +1830 -0
  289. package/dist/server-DlRePYOB.js +343 -0
  290. package/dist/{server-BpPEzRes.js → server-_HZm8wEC.js} +654 -745
  291. package/dist/{server-yABhJa2K.js → server-_jWkMESg.js} +60 -39
  292. package/dist/server-lgV6liTt.js +140 -0
  293. package/dist/server-nHPXbRDA.js +742 -0
  294. package/dist/server-p7qANgrf.js +877 -0
  295. package/dist/server-vhmQi3co.js +112 -0
  296. package/dist/{server-SA0dsIJ2.js → server-w1aKMZOs.js} +3 -10
  297. package/dist/serverPlugin-4nI5J6Zt.js +39622 -0
  298. package/dist/session-resources-BvR3cwiH.js +10 -0
  299. package/dist/{sessionConfig-DgnPcGBu.js → sessionConfig-UMlgu98q.js} +926 -844
  300. package/dist/{simple-options-DWrW31_K.js → simple-options-Cp5p46f9.js} +13 -6
  301. package/dist/space-C3Wnli1l.js +92 -0
  302. package/dist/sse-XlzXs1es.js +151 -0
  303. package/dist/{streaming-json-t4rzNHEp.js → streaming-json-CZyrX_Ux.js} +6 -6
  304. package/dist/{system-one-shared-DLVLdzYL.js → system-one-shared-Du6bka0h.js} +3 -3
  305. package/dist/{notification-valMY1zH.js → telemetry-CrTcxeA5.js} +2 -93
  306. package/dist/{transform-messages-CjTSwW9q.js → transform-messages-CBj9g2mx.js} +3 -16
  307. package/dist/truncate-M3KbFyVj.js +89 -0
  308. package/dist/{server-BXjfQYeU.js → type-DppaYz6F.js} +955 -1187
  309. package/dist/type-yokaDI_F.js +7 -0
  310. package/dist/{typesafe-system-one-DBVcjcUQ.js → typesafe-system-one-C7YFgvrX.js} +3 -3
  311. package/dist/{uuid-mkNGilLv.js → uuid-BVI0BZsx.js} +1 -1
  312. package/dist/{validation-BLnxgJU_.js → validation-QWuk6kwJ.js} +79 -74
  313. package/dist/vaultSettings-Bq8wkbDv.js +292 -0
  314. package/dist/voiceTools-BdJyfzwB.js +246 -0
  315. package/dist/web-B2sdV-F2.js +4 -0
  316. package/dist/worker.js +97821 -72579
  317. package/dist/workflow-DTCt4n6k.js +171 -0
  318. package/dist/workflowServices-RlswfHWp.js +300 -0
  319. package/package.json +55 -25
  320. package/wrangler.jsonc +16 -3
  321. package/dist/apiContracts-sG5b90Qa.js +0 -4451
  322. package/dist/assets/assets/channel-BOT7In0s.js +0 -2
  323. package/dist/assets/assets/chunk-XXDRQBXY-Dp9-QbR6.js +0 -2
  324. package/dist/assets/assets/flowDiagram-IUGLLWBU-B9D9uWwn.js +0 -1
  325. package/dist/assets/assets/index-BlPEYpuN.css +0 -1
  326. package/dist/assets/assets/index-DS9w_Q1B.js +0 -155
  327. package/dist/assets/assets/swimlanesDiagram-AYQRV4AK-CyUKtW7v.js +0 -9
  328. package/dist/assets/plugins/assets/base-DyDpY0zD.css +0 -2
  329. package/dist/assets/plugins/chunks/po-web-runtime-4JiBsb_c.js +0 -1
  330. package/dist/assets/plugins/slots/approval.09e72f36-DwFz-UMh.js +0 -2
  331. package/dist/assets/plugins/slots/artifacts.50b639bb-CUtFC806.js +0 -1
  332. package/dist/assets/plugins/slots/builtin-tools.75108f21-B69GLfY_.js +0 -7
  333. package/dist/assets/plugins/slots/codemode.c58fb583-C0Gmb7_s.js +0 -9
  334. package/dist/assets/plugins/slots/domain.753f9f92-BTBYRLkE.js +0 -1
  335. package/dist/assets/plugins/slots/mcp.82cc1ff5-Ecacjn0a.js +0 -109
  336. package/dist/assets/plugins/slots/profile.ab16dcec-DIVXNHmh.js +0 -1
  337. package/dist/assets/plugins/slots/skill.62a0a1b3-BNr7DmPH.js +0 -4
  338. package/dist/backgroundWork-CSpsJ-Rg.js +0 -25
  339. package/dist/contextProjection-DDIQRgN4.js +0 -188
  340. package/dist/extensionFile-CacKVegY.js +0 -409
  341. package/dist/harnessState-gmzJcPGt.js +0 -88
  342. package/dist/harnessStore-Ch6hdYYe.js +0 -1
  343. package/dist/index.edge-BgSx_gRO.js +0 -45
  344. package/dist/majorModes-CCnwAjfF.js +0 -333
  345. package/dist/majorModes-DNQbxkpt.js +0 -1
  346. package/dist/piSettings-B6fsgIBA.js +0 -1
  347. package/dist/platform-Bs2_X_dK.js +0 -16
  348. package/dist/platformFiles-CCGujP9o.js +0 -39
  349. package/dist/server-5hLs7M43.js +0 -656
  350. package/dist/server-B3iqBHOP.js +0 -118
  351. package/dist/server-Dv0EKLwc.js +0 -108
  352. package/dist/server-Y5A21sJf.js +0 -591
  353. package/dist/server-a1K226XK.js +0 -279
  354. package/dist/serverPlugin-DUc4gGep.js +0 -7279
  355. package/dist/value-Bd477RDX.js +0 -2247
@@ -0,0 +1,4596 @@
1
+ //#region ../../../node_modules/.pnpm/liquidjs@10.30.0/node_modules/liquidjs/dist/liquid.browser.mjs
2
+ var Token = class {
3
+ constructor(kind, input, begin, end, file) {
4
+ this.kind = kind;
5
+ this.input = input;
6
+ this.begin = begin;
7
+ this.end = end;
8
+ this.file = file;
9
+ }
10
+ getText() {
11
+ return this.input.slice(this.begin, this.end);
12
+ }
13
+ getPosition() {
14
+ let [row, col] = [1, 1];
15
+ for (let i = 0; i < this.begin; i++) if (this.input[i] === "\n") {
16
+ row++;
17
+ col = 1;
18
+ } else col++;
19
+ return [row, col];
20
+ }
21
+ size() {
22
+ return this.end - this.begin;
23
+ }
24
+ };
25
+ var Drop = class {
26
+ liquidMethodMissing(key, context) {}
27
+ };
28
+ const toString$1 = Object.prototype.toString;
29
+ const toLowerCase = String.prototype.toLowerCase;
30
+ const hasOwnProperty = Object.hasOwnProperty;
31
+ function isString(value) {
32
+ return typeof value === "string";
33
+ }
34
+ function isFunction(value) {
35
+ return typeof value === "function";
36
+ }
37
+ function isPromise(val) {
38
+ return val && isFunction(val.then);
39
+ }
40
+ function isIterator(val) {
41
+ return val && isFunction(val.next) && isFunction(val.throw) && isFunction(val.return);
42
+ }
43
+ function stringify(value) {
44
+ value = toValue(value);
45
+ if (isString(value)) return value;
46
+ if (isNil(value)) return "";
47
+ if (isArray(value)) return value.map((x) => stringify(x)).join("");
48
+ return String(value);
49
+ }
50
+ function readArrayElement(arr, index, ownPropertyOnly) {
51
+ if (index < 0) index = arr.length + index;
52
+ if (ownPropertyOnly && !hasOwnProperty.call(arr, index)) return void 0;
53
+ return arr[index];
54
+ }
55
+ function toEnumerable(val) {
56
+ val = toValue(val);
57
+ if (isArray(val)) return val;
58
+ if (isString(val) && val.length > 0) return [val];
59
+ if (isIterable(val)) return Array.from(val);
60
+ if (isObject(val)) return Object.keys(val).map((key) => [key, val[key]]);
61
+ return [];
62
+ }
63
+ function toArray(val) {
64
+ val = toValue(val);
65
+ if (isNil(val)) return [];
66
+ if (isArray(val)) return val;
67
+ return [val];
68
+ }
69
+ function toValue(value) {
70
+ return value instanceof Drop && isFunction(value.valueOf) ? value.valueOf() : value;
71
+ }
72
+ function toNumber(value) {
73
+ return +toValue(value) || 0;
74
+ }
75
+ function isNumber(value) {
76
+ return typeof value === "number";
77
+ }
78
+ function toLiquid(value) {
79
+ if (value && isFunction(value.toLiquid)) return toLiquid(value.toLiquid());
80
+ return value;
81
+ }
82
+ function isNil(value) {
83
+ return value == null;
84
+ }
85
+ function isUndefined(value) {
86
+ return value === void 0;
87
+ }
88
+ function isArray(value) {
89
+ return toString$1.call(value) === "[object Array]";
90
+ }
91
+ function isArrayLike(value) {
92
+ return value && isNumber(value.length);
93
+ }
94
+ function isIterable(value) {
95
+ return isObject(value) && Symbol.iterator in value;
96
+ }
97
+ function forOwn(obj, iteratee) {
98
+ obj = obj || {};
99
+ for (const k in obj) if (hasOwnProperty.call(obj, k)) {
100
+ if (iteratee(obj[k], k, obj) === false) break;
101
+ }
102
+ return obj;
103
+ }
104
+ function last(arr) {
105
+ return arr[arr.length - 1];
106
+ }
107
+ function isObject(value) {
108
+ const type = typeof value;
109
+ return value !== null && (type === "object" || type === "function");
110
+ }
111
+ function range(start, stop, step = 1) {
112
+ const arr = [];
113
+ for (let i = start; i < stop; i += step) arr.push(i);
114
+ return arr;
115
+ }
116
+ function padStart(str, length, ch = " ") {
117
+ return pad(str, length, ch, (str, ch) => ch + str);
118
+ }
119
+ function padEnd(str, length, ch = " ") {
120
+ return pad(str, length, ch, (str, ch) => str + ch);
121
+ }
122
+ function pad(str, length, ch, add) {
123
+ str = String(str);
124
+ const n = length - str.length;
125
+ if (n <= 0) return str;
126
+ return add(str, ch.repeat(n));
127
+ }
128
+ function identify(val) {
129
+ return val;
130
+ }
131
+ function changeCase(str) {
132
+ return [...str].some((ch) => ch >= "a" && ch <= "z") ? str.toUpperCase() : str.toLowerCase();
133
+ }
134
+ function ellipsis(str, N) {
135
+ return str.length > N ? str.slice(0, N - 3) + "..." : str;
136
+ }
137
+ function orderedCompare(a, b) {
138
+ if (isNil(a) && isNil(b)) return 0;
139
+ if (isNil(a)) return 1;
140
+ if (isNil(b)) return -1;
141
+ if (a < b) return -1;
142
+ if (a > b) return 1;
143
+ return 0;
144
+ }
145
+ function caseInsensitiveCompare(a, b) {
146
+ if (isNil(a) && isNil(b)) return 0;
147
+ if (isNil(a)) return 1;
148
+ if (isNil(b)) return -1;
149
+ a = toLowerCase.call(a);
150
+ b = toLowerCase.call(b);
151
+ if (a < b) return -1;
152
+ if (a > b) return 1;
153
+ return 0;
154
+ }
155
+ function argumentsToValue(fn) {
156
+ return function(...args) {
157
+ return fn.call(this, ...args.map(toValue));
158
+ };
159
+ }
160
+ function argumentsToNumber(fn) {
161
+ return function(...args) {
162
+ return fn.call(this, ...args.map(toNumber));
163
+ };
164
+ }
165
+ /** Return an array containing unique elements from _array_. Works with nested arrays and objects. */
166
+ function* strictUniq(array) {
167
+ const seen = /* @__PURE__ */ new Set();
168
+ for (const element of array) {
169
+ const key = JSON.stringify(element);
170
+ if (!seen.has(key)) {
171
+ seen.add(key);
172
+ yield element;
173
+ }
174
+ }
175
+ }
176
+ /**
177
+ * targeting ES5, extends Error won't create a proper prototype chain, need a trait to keep track of classes
178
+ */
179
+ const TRAIT = "__liquidClass__";
180
+ var LiquidError = class extends Error {
181
+ constructor(err, token) {
182
+ /**
183
+ * note: for ES5 targeting, `this` will be replaced by return value of Error(),
184
+ * thus everything on `this` will be lost, avoid calling `LiquidError` methods here
185
+ */
186
+ super(typeof err === "string" ? err : err.message);
187
+ this.context = "";
188
+ if (typeof err !== "string") Object.defineProperty(this, "originalError", {
189
+ value: err,
190
+ enumerable: false
191
+ });
192
+ Object.defineProperty(this, "token", {
193
+ value: token,
194
+ enumerable: false
195
+ });
196
+ Object.defineProperty(this, TRAIT, {
197
+ value: "LiquidError",
198
+ enumerable: false
199
+ });
200
+ }
201
+ update() {
202
+ Object.defineProperty(this, "context", {
203
+ value: mkContext(this.token),
204
+ enumerable: false
205
+ });
206
+ this.message = mkMessage(this.message, this.token);
207
+ this.stack = this.message + "\n" + this.context + "\n" + this.stack;
208
+ if (this.originalError) this.stack += "\nFrom " + this.originalError.stack;
209
+ }
210
+ static is(obj) {
211
+ return (obj === null || obj === void 0 ? void 0 : obj[TRAIT]) === "LiquidError";
212
+ }
213
+ };
214
+ var TokenizationError = class extends LiquidError {
215
+ constructor(message, token) {
216
+ super(message, token);
217
+ this.name = "TokenizationError";
218
+ super.update();
219
+ }
220
+ };
221
+ var ParseError = class extends LiquidError {
222
+ constructor(err, token) {
223
+ super(err, token);
224
+ this.name = "ParseError";
225
+ this.message = err.message;
226
+ super.update();
227
+ }
228
+ };
229
+ var RenderError = class extends LiquidError {
230
+ constructor(err, tpl) {
231
+ super(err, tpl.token);
232
+ this.name = "RenderError";
233
+ this.message = err.message;
234
+ super.update();
235
+ }
236
+ static is(obj) {
237
+ return obj.name === "RenderError";
238
+ }
239
+ };
240
+ var LiquidErrors = class extends LiquidError {
241
+ constructor(errors) {
242
+ super(errors[0], errors[0].token);
243
+ this.errors = errors;
244
+ this.name = "LiquidErrors";
245
+ const s = errors.length > 1 ? "s" : "";
246
+ this.message = `${errors.length} error${s} found`;
247
+ super.update();
248
+ }
249
+ static is(obj) {
250
+ return obj.name === "LiquidErrors";
251
+ }
252
+ };
253
+ var UndefinedVariableError = class extends LiquidError {
254
+ constructor(err, token) {
255
+ super(err, token);
256
+ this.name = "UndefinedVariableError";
257
+ this.message = err.message;
258
+ super.update();
259
+ }
260
+ };
261
+ var InternalUndefinedVariableError = class extends Error {
262
+ constructor(variableName) {
263
+ super(`undefined variable: ${variableName}`);
264
+ this.name = "InternalUndefinedVariableError";
265
+ this.variableName = variableName;
266
+ }
267
+ };
268
+ var AssertionError = class extends Error {
269
+ constructor(message) {
270
+ super(message);
271
+ this.name = "AssertionError";
272
+ this.message = message + "";
273
+ }
274
+ };
275
+ function mkContext(token) {
276
+ const [line, col] = token.getPosition();
277
+ const lines = token.input.split("\n");
278
+ const begin = Math.max(line - 2, 1);
279
+ const end = Math.min(line + 3, lines.length);
280
+ return range(begin, end + 1).map((lineNumber) => {
281
+ let text = `${lineNumber === line ? ">> " : " "}${padStart(String(lineNumber), String(end).length)}| `;
282
+ const colIndicator = lineNumber === line ? "\n" + padStart("^", col + text.length) : "";
283
+ text += lines[lineNumber - 1];
284
+ text += colIndicator;
285
+ return text;
286
+ }).join("\n");
287
+ }
288
+ function mkMessage(msg, token) {
289
+ if (token.file) msg += `, file:${token.file}`;
290
+ const [line, col] = token.getPosition();
291
+ msg += `, line:${line}, col:${col}`;
292
+ return msg;
293
+ }
294
+ const TYPES = [
295
+ 0,
296
+ 0,
297
+ 0,
298
+ 0,
299
+ 0,
300
+ 0,
301
+ 0,
302
+ 0,
303
+ 0,
304
+ 20,
305
+ 4,
306
+ 4,
307
+ 4,
308
+ 20,
309
+ 0,
310
+ 0,
311
+ 0,
312
+ 0,
313
+ 0,
314
+ 0,
315
+ 0,
316
+ 0,
317
+ 0,
318
+ 0,
319
+ 0,
320
+ 0,
321
+ 0,
322
+ 0,
323
+ 0,
324
+ 0,
325
+ 0,
326
+ 0,
327
+ 20,
328
+ 2,
329
+ 8,
330
+ 0,
331
+ 0,
332
+ 0,
333
+ 0,
334
+ 8,
335
+ 0,
336
+ 0,
337
+ 0,
338
+ 64,
339
+ 0,
340
+ 65,
341
+ 0,
342
+ 0,
343
+ 33,
344
+ 33,
345
+ 33,
346
+ 33,
347
+ 33,
348
+ 33,
349
+ 33,
350
+ 33,
351
+ 33,
352
+ 33,
353
+ 0,
354
+ 0,
355
+ 2,
356
+ 2,
357
+ 2,
358
+ 1,
359
+ 0,
360
+ 1,
361
+ 1,
362
+ 1,
363
+ 1,
364
+ 1,
365
+ 1,
366
+ 1,
367
+ 1,
368
+ 1,
369
+ 1,
370
+ 1,
371
+ 1,
372
+ 1,
373
+ 1,
374
+ 1,
375
+ 1,
376
+ 1,
377
+ 1,
378
+ 1,
379
+ 1,
380
+ 1,
381
+ 1,
382
+ 1,
383
+ 1,
384
+ 1,
385
+ 1,
386
+ 0,
387
+ 0,
388
+ 0,
389
+ 0,
390
+ 1,
391
+ 0,
392
+ 1,
393
+ 1,
394
+ 1,
395
+ 1,
396
+ 1,
397
+ 1,
398
+ 1,
399
+ 1,
400
+ 1,
401
+ 1,
402
+ 1,
403
+ 1,
404
+ 1,
405
+ 1,
406
+ 1,
407
+ 1,
408
+ 1,
409
+ 1,
410
+ 1,
411
+ 1,
412
+ 1,
413
+ 1,
414
+ 1,
415
+ 1,
416
+ 1,
417
+ 1,
418
+ 0,
419
+ 0,
420
+ 0,
421
+ 0,
422
+ 0
423
+ ];
424
+ const WORD = 1;
425
+ const BLANK = 4;
426
+ const QUOTE = 8;
427
+ const INLINE_BLANK = 16;
428
+ const NUMBER = 32;
429
+ const SIGN = 64;
430
+ const PUNCTUATION = 128;
431
+ function isWord(char) {
432
+ const code = char.charCodeAt(0);
433
+ return code >= 128 ? !TYPES[code] : !!(TYPES[code] & WORD);
434
+ }
435
+ TYPES[160] = TYPES[5760] = TYPES[6158] = TYPES[8192] = TYPES[8193] = TYPES[8194] = TYPES[8195] = TYPES[8196] = TYPES[8197] = TYPES[8198] = TYPES[8199] = TYPES[8200] = TYPES[8201] = TYPES[8202] = TYPES[8232] = TYPES[8233] = TYPES[8239] = TYPES[8287] = TYPES[12288] = BLANK;
436
+ TYPES[8220] = TYPES[8221] = PUNCTUATION;
437
+ function assert(predicate, message) {
438
+ if (!predicate) throw new AssertionError(typeof message === "function" ? message() : message || `expect ${predicate} to be true`);
439
+ }
440
+ function assertEmpty(predicate, message = `unexpected ${JSON.stringify(predicate)}`) {
441
+ assert(!predicate, message);
442
+ }
443
+ var NullDrop = class extends Drop {
444
+ *equals(value) {
445
+ return isNil(yield toValue(value));
446
+ }
447
+ gt() {
448
+ return false;
449
+ }
450
+ geq() {
451
+ return false;
452
+ }
453
+ lt() {
454
+ return false;
455
+ }
456
+ leq() {
457
+ return false;
458
+ }
459
+ valueOf() {
460
+ return null;
461
+ }
462
+ };
463
+ var EmptyDrop = class EmptyDrop extends Drop {
464
+ *equals(value) {
465
+ if (value instanceof EmptyDrop) return false;
466
+ value = yield toValue(value);
467
+ if (isString(value) || isArray(value)) return value.length === 0;
468
+ if (isObject(value)) return Object.keys(value).length === 0;
469
+ return false;
470
+ }
471
+ gt() {
472
+ return false;
473
+ }
474
+ geq() {
475
+ return false;
476
+ }
477
+ lt() {
478
+ return false;
479
+ }
480
+ leq() {
481
+ return false;
482
+ }
483
+ valueOf() {
484
+ return "";
485
+ }
486
+ static is(value) {
487
+ return value instanceof EmptyDrop;
488
+ }
489
+ };
490
+ var BlankDrop = class BlankDrop extends EmptyDrop {
491
+ *equals(value) {
492
+ if (value === false) return true;
493
+ if (isNil(yield toValue(value))) return true;
494
+ if (isString(value)) return /^\s*$/.test(value);
495
+ return yield super.equals(value);
496
+ }
497
+ static is(value) {
498
+ return value instanceof BlankDrop;
499
+ }
500
+ };
501
+ var ForloopDrop = class extends Drop {
502
+ constructor(length, collection, variable) {
503
+ super();
504
+ this.i = 0;
505
+ this.length = length;
506
+ this.name = `${variable}-${collection}`;
507
+ }
508
+ next() {
509
+ this.i++;
510
+ }
511
+ index0() {
512
+ return this.i;
513
+ }
514
+ index() {
515
+ return this.i + 1;
516
+ }
517
+ first() {
518
+ return this.i === 0;
519
+ }
520
+ last() {
521
+ return this.i === this.length - 1;
522
+ }
523
+ rindex() {
524
+ return this.length - this.i;
525
+ }
526
+ rindex0() {
527
+ return this.length - this.i - 1;
528
+ }
529
+ valueOf() {
530
+ return JSON.stringify(this);
531
+ }
532
+ };
533
+ var SimpleEmitter = class {
534
+ constructor() {
535
+ this.buffer = "";
536
+ }
537
+ write(html) {
538
+ this.buffer += stringify(html);
539
+ }
540
+ };
541
+ var StreamedEmitter = class {
542
+ constructor() {
543
+ this.buffer = "";
544
+ this.stream = null;
545
+ throw new Error("streaming not supported in browser");
546
+ }
547
+ };
548
+ var KeepingTypeEmitter = class {
549
+ constructor() {
550
+ this.buffer = "";
551
+ }
552
+ write(html) {
553
+ html = toValue(html);
554
+ if (typeof html !== "string" && this.buffer === "") this.buffer = html;
555
+ else this.buffer = stringify(this.buffer) + stringify(html);
556
+ }
557
+ };
558
+ var BlockDrop = class extends Drop {
559
+ constructor(superBlockRender = () => "") {
560
+ super();
561
+ this.superBlockRender = superBlockRender;
562
+ }
563
+ /**
564
+ * Provide parent access in child block by
565
+ * {{ block.super }}
566
+ */
567
+ *super() {
568
+ const emitter = new SimpleEmitter();
569
+ yield this.superBlockRender(emitter);
570
+ return emitter.buffer;
571
+ }
572
+ };
573
+ function isComparable(arg) {
574
+ return arg && isFunction(arg.equals) && isFunction(arg.gt) && isFunction(arg.geq) && isFunction(arg.lt) && isFunction(arg.leq);
575
+ }
576
+ const nil = new NullDrop();
577
+ const literalValues = {
578
+ "true": true,
579
+ "false": false,
580
+ "nil": nil,
581
+ "null": nil,
582
+ "empty": new EmptyDrop(),
583
+ "blank": new BlankDrop()
584
+ };
585
+ const trieCache = /* @__PURE__ */ new WeakMap();
586
+ function createTrie(input) {
587
+ const cached = trieCache.get(input);
588
+ if (cached) return cached;
589
+ const trie = {};
590
+ for (const [name, data] of Object.entries(input)) {
591
+ let node = trie;
592
+ for (let i = 0; i < name.length; i++) {
593
+ const c = name[i];
594
+ node[c] = node[c] || {};
595
+ if (i === name.length - 1 && isWord(name[i])) node[c].needBoundary = true;
596
+ node = node[c];
597
+ }
598
+ node.data = data;
599
+ node.end = true;
600
+ }
601
+ trieCache.set(input, trie);
602
+ return trie;
603
+ }
604
+ /******************************************************************************
605
+ Copyright (c) Microsoft Corporation.
606
+
607
+ Permission to use, copy, modify, and/or distribute this software for any
608
+ purpose with or without fee is hereby granted.
609
+
610
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
611
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
612
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
613
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
614
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
615
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
616
+ PERFORMANCE OF THIS SOFTWARE.
617
+ ***************************************************************************** */
618
+ var __assign = function() {
619
+ __assign = Object.assign || function __assign(t) {
620
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
621
+ s = arguments[i];
622
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
623
+ }
624
+ return t;
625
+ };
626
+ return __assign.apply(this, arguments);
627
+ };
628
+ function __awaiter(thisArg, _arguments, P, generator) {
629
+ function adopt(value) {
630
+ return value instanceof P ? value : new P(function(resolve) {
631
+ resolve(value);
632
+ });
633
+ }
634
+ return new (P || (P = Promise))(function(resolve, reject) {
635
+ function fulfilled(value) {
636
+ try {
637
+ step(generator.next(value));
638
+ } catch (e) {
639
+ reject(e);
640
+ }
641
+ }
642
+ function rejected(value) {
643
+ try {
644
+ step(generator["throw"](value));
645
+ } catch (e) {
646
+ reject(e);
647
+ }
648
+ }
649
+ function step(result) {
650
+ result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
651
+ }
652
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
653
+ });
654
+ }
655
+ function toLiquidAsync(asyncFn, syncFn) {
656
+ const syncImpl = syncFn || asyncFn;
657
+ return (sync, ...args) => {
658
+ return sync ? syncImpl(...args) : asyncFn(...args);
659
+ };
660
+ }
661
+ function toPromise(val) {
662
+ return __awaiter(this, void 0, void 0, function* () {
663
+ if (!isIterator(val)) return val;
664
+ let value;
665
+ let done = false;
666
+ let next = "next";
667
+ do {
668
+ const state = val[next](value);
669
+ done = !!state.done;
670
+ value = state.value;
671
+ next = "next";
672
+ try {
673
+ if (isIterator(value)) value = toPromise(value);
674
+ if (isPromise(value)) value = yield value;
675
+ } catch (err) {
676
+ next = "throw";
677
+ value = err;
678
+ }
679
+ } while (!done);
680
+ return value;
681
+ });
682
+ }
683
+ function toValueSync(val) {
684
+ if (!isIterator(val)) return val;
685
+ let value;
686
+ let done = false;
687
+ let next = "next";
688
+ do {
689
+ const state = val[next](value);
690
+ done = !!state.done;
691
+ value = state.value;
692
+ next = "next";
693
+ if (isIterator(value)) try {
694
+ value = toValueSync(value);
695
+ } catch (err) {
696
+ next = "throw";
697
+ value = err;
698
+ }
699
+ } while (!done);
700
+ return value;
701
+ }
702
+ const rFormat = /%([-_0^#:]+)?(\d+)?([EO])?(.)/;
703
+ function daysInMonth(d) {
704
+ return [
705
+ 31,
706
+ isLeapYear(d) ? 29 : 28,
707
+ 31,
708
+ 30,
709
+ 31,
710
+ 30,
711
+ 31,
712
+ 31,
713
+ 30,
714
+ 31,
715
+ 30,
716
+ 31
717
+ ];
718
+ }
719
+ function getDayOfYear(d) {
720
+ let num = 0;
721
+ for (let i = 0; i < d.getMonth(); ++i) num += daysInMonth(d)[i];
722
+ return num + d.getDate();
723
+ }
724
+ function getWeekOfYear(d, startDay) {
725
+ const daysSinceStartDay = (d.getDay() - startDay + 7) % 7;
726
+ return String(Math.floor((getDayOfYear(d) - 1 - daysSinceStartDay + 7) / 7));
727
+ }
728
+ function isLeapYear(d) {
729
+ const year = d.getFullYear();
730
+ return !!((year & 3) === 0 && (year % 100 || year % 400 === 0 && year));
731
+ }
732
+ function ordinal(d) {
733
+ const date = d.getDate();
734
+ if ([
735
+ 11,
736
+ 12,
737
+ 13
738
+ ].includes(date)) return "th";
739
+ switch (date % 10) {
740
+ case 1: return "st";
741
+ case 2: return "nd";
742
+ case 3: return "rd";
743
+ default: return "th";
744
+ }
745
+ }
746
+ function century(d) {
747
+ return Math.floor(d.getFullYear() / 100);
748
+ }
749
+ const padWidths = {
750
+ C: 2,
751
+ d: 2,
752
+ e: 2,
753
+ H: 2,
754
+ I: 2,
755
+ j: 3,
756
+ k: 2,
757
+ l: 2,
758
+ L: 3,
759
+ m: 2,
760
+ M: 2,
761
+ S: 2,
762
+ U: 2,
763
+ W: 2,
764
+ y: 2
765
+ };
766
+ const padSpaceChars = /* @__PURE__ */ new Set("aAbBceklpP");
767
+ function getTimezoneOffset(d, opts) {
768
+ const nOffset = Math.abs(d.getTimezoneOffset());
769
+ const h = Math.floor(nOffset / 60);
770
+ const m = nOffset % 60;
771
+ return (d.getTimezoneOffset() > 0 ? "-" : "+") + padStart(h, 2, "0") + (opts.flags[":"] ? ":" : "") + padStart(m, 2, "0");
772
+ }
773
+ const formatCodes = {
774
+ a: (d) => d.getShortWeekdayName(),
775
+ A: (d) => d.getLongWeekdayName(),
776
+ b: (d) => d.getShortMonthName(),
777
+ B: (d) => d.getLongMonthName(),
778
+ c: (d) => d.toLocaleString(),
779
+ C: (d) => century(d),
780
+ d: (d) => d.getDate(),
781
+ e: (d) => d.getDate(),
782
+ H: (d) => d.getHours(),
783
+ I: (d) => String(d.getHours() % 12 || 12),
784
+ j: (d) => getDayOfYear(d),
785
+ k: (d) => d.getHours(),
786
+ l: (d) => String(d.getHours() % 12 || 12),
787
+ L: (d) => d.getMilliseconds(),
788
+ m: (d) => d.getMonth() + 1,
789
+ M: (d) => d.getMinutes(),
790
+ N: (d, opts) => {
791
+ var _a;
792
+ const width = Number(opts.width) || 9;
793
+ const str = padStart(String(d.getMilliseconds()), 3, "0").slice(0, width);
794
+ (_a = opts.memoryLimit) === null || _a === void 0 || _a.use(width - str.length);
795
+ return padEnd(str, width, "0");
796
+ },
797
+ p: (d) => d.getHours() < 12 ? "AM" : "PM",
798
+ P: (d) => d.getHours() < 12 ? "am" : "pm",
799
+ q: (d) => ordinal(d),
800
+ s: (d) => Math.floor(d.dateValue() / 1e3),
801
+ S: (d) => d.getSeconds(),
802
+ u: (d) => d.getDay() || 7,
803
+ U: (d) => getWeekOfYear(d, 0),
804
+ w: (d) => d.getDay(),
805
+ W: (d) => getWeekOfYear(d, 1),
806
+ x: (d) => d.toLocaleDateString(),
807
+ X: (d) => d.toLocaleTimeString(),
808
+ y: (d) => (d.getFullYear() % 100 + 100) % 100,
809
+ Y: (d) => d.getFullYear(),
810
+ z: getTimezoneOffset,
811
+ Z: (d, opts) => d.getTimeZoneName() || getTimezoneOffset(d, opts),
812
+ "t": () => " ",
813
+ "n": () => "\n",
814
+ "%": () => "%"
815
+ };
816
+ formatCodes.h = formatCodes.b;
817
+ function strftime(d, formatStr, memoryLimit) {
818
+ let output = "";
819
+ let remaining = formatStr;
820
+ let match;
821
+ while (match = rFormat.exec(remaining)) {
822
+ output += remaining.slice(0, match.index);
823
+ remaining = remaining.slice(match.index + match[0].length);
824
+ output += format(d, match, memoryLimit);
825
+ }
826
+ return output + remaining;
827
+ }
828
+ function format(d, match, memoryLimit) {
829
+ const [input, flagStr = "", width, modifier, conversion] = match;
830
+ const convert = formatCodes[conversion];
831
+ if (!convert) return input;
832
+ const flags = {};
833
+ for (const flag of flagStr) flags[flag] = true;
834
+ let ret = String(convert(d, {
835
+ flags,
836
+ width,
837
+ modifier,
838
+ memoryLimit
839
+ }));
840
+ let padChar = padSpaceChars.has(conversion) ? " " : "0";
841
+ let padWidth = Number(width) || padWidths[conversion] || 0;
842
+ if (flags["^"]) ret = ret.toUpperCase();
843
+ else if (flags["#"]) ret = changeCase(ret);
844
+ if (flags["_"]) padChar = " ";
845
+ else if (flags["0"]) padChar = "0";
846
+ if (flags["-"]) padWidth = 0;
847
+ memoryLimit === null || memoryLimit === void 0 || memoryLimit.use(Number(padWidth) - ret.length);
848
+ return padStart(ret, padWidth, padChar);
849
+ }
850
+ function getDateTimeFormat() {
851
+ return typeof Intl !== "undefined" ? Intl.DateTimeFormat : void 0;
852
+ }
853
+ const OneMinute = 6e4;
854
+ /**
855
+ * Need support both ISO8601 and RFC2822 as in major browsers & NodeJS
856
+ * RFC2822: https://datatracker.ietf.org/doc/html/rfc2822#section-3.3
857
+ */
858
+ const TIMEZONE_PATTERN = /([zZ]|([+-])(\d{2}):?(\d{2}))$/;
859
+ const monthNames = [
860
+ "January",
861
+ "February",
862
+ "March",
863
+ "April",
864
+ "May",
865
+ "June",
866
+ "July",
867
+ "August",
868
+ "September",
869
+ "October",
870
+ "November",
871
+ "December"
872
+ ];
873
+ const monthNamesShort = monthNames.map((name) => name.slice(0, 3));
874
+ const dayNames = [
875
+ "Sunday",
876
+ "Monday",
877
+ "Tuesday",
878
+ "Wednesday",
879
+ "Thursday",
880
+ "Friday",
881
+ "Saturday"
882
+ ];
883
+ const dayNamesShort = dayNames.map((name) => name.slice(0, 3));
884
+ /**
885
+ * A date implementation with timezone info, just like Ruby date
886
+ *
887
+ * Implementation:
888
+ * - create a Date offset by it's timezone difference, avoiding overriding a bunch of methods
889
+ * - rewrite getTimezoneOffset() to trick strftime
890
+ */
891
+ var LiquidDate = class LiquidDate {
892
+ constructor(init, locale, timezone) {
893
+ this.locale = locale;
894
+ this.DateTimeFormat = getDateTimeFormat();
895
+ this.date = new Date(init);
896
+ this.timezoneFixed = timezone !== void 0;
897
+ if (timezone === void 0) timezone = this.date.getTimezoneOffset();
898
+ this.timezoneOffset = isString(timezone) ? LiquidDate.getTimezoneOffset(timezone, this.date) : timezone;
899
+ this.timezoneName = isString(timezone) ? timezone : "";
900
+ const diff = (this.date.getTimezoneOffset() - this.timezoneOffset) * OneMinute;
901
+ const time = this.date.getTime() + diff;
902
+ this.displayDate = new Date(time);
903
+ }
904
+ getTime() {
905
+ return this.displayDate.getTime();
906
+ }
907
+ /**
908
+ * The underlying UTC timestamp in milliseconds, unaffected by the display
909
+ * timezone. Use this (not `getTime()`) for timezone-invariant values like
910
+ * `%s`: `getTime()` reads `displayDate`, which is deliberately shifted by
911
+ * the display timezone offset so wall-clock getters can delegate to Date.
912
+ */
913
+ dateValue() {
914
+ return this.date.getTime();
915
+ }
916
+ getMilliseconds() {
917
+ return this.displayDate.getMilliseconds();
918
+ }
919
+ getSeconds() {
920
+ return this.displayDate.getSeconds();
921
+ }
922
+ getMinutes() {
923
+ return this.displayDate.getMinutes();
924
+ }
925
+ getHours() {
926
+ return this.displayDate.getHours();
927
+ }
928
+ getDay() {
929
+ return this.displayDate.getDay();
930
+ }
931
+ getDate() {
932
+ return this.displayDate.getDate();
933
+ }
934
+ getMonth() {
935
+ return this.displayDate.getMonth();
936
+ }
937
+ getFullYear() {
938
+ return this.displayDate.getFullYear();
939
+ }
940
+ toLocaleString(locale, init) {
941
+ if (init === null || init === void 0 ? void 0 : init.timeZone) return this.date.toLocaleString(locale, init);
942
+ return this.displayDate.toLocaleString(locale, init);
943
+ }
944
+ toLocaleTimeString(locale) {
945
+ return this.displayDate.toLocaleTimeString(locale);
946
+ }
947
+ toLocaleDateString(locale) {
948
+ return this.displayDate.toLocaleDateString(locale);
949
+ }
950
+ getTimezoneOffset() {
951
+ return this.timezoneOffset;
952
+ }
953
+ getTimeZoneName() {
954
+ if (this.timezoneFixed) return this.timezoneName;
955
+ if (!this.DateTimeFormat) return;
956
+ return this.DateTimeFormat().resolvedOptions().timeZone;
957
+ }
958
+ getLongMonthName() {
959
+ var _a;
960
+ return (_a = this.format({ month: "long" })) !== null && _a !== void 0 ? _a : monthNames[this.getMonth()];
961
+ }
962
+ getShortMonthName() {
963
+ var _a;
964
+ return (_a = this.format({ month: "short" })) !== null && _a !== void 0 ? _a : monthNamesShort[this.getMonth()];
965
+ }
966
+ getLongWeekdayName() {
967
+ var _a;
968
+ return (_a = this.format({ weekday: "long" })) !== null && _a !== void 0 ? _a : dayNames[this.displayDate.getDay()];
969
+ }
970
+ getShortWeekdayName() {
971
+ var _a;
972
+ return (_a = this.format({ weekday: "short" })) !== null && _a !== void 0 ? _a : dayNamesShort[this.displayDate.getDay()];
973
+ }
974
+ valid() {
975
+ return !isNaN(this.getTime());
976
+ }
977
+ format(options) {
978
+ return this.DateTimeFormat && this.DateTimeFormat(this.locale, options).format(this.displayDate);
979
+ }
980
+ /**
981
+ * Create a Date object fixed to it's declared Timezone. Both
982
+ * - 2021-08-06T02:29:00.000Z and
983
+ * - 2021-08-06T02:29:00.000+08:00
984
+ * will always be displayed as
985
+ * - 2021-08-06 02:29:00
986
+ * regardless timezoneOffset in JavaScript realm
987
+ *
988
+ * The implementation hack:
989
+ * Instead of calling `.getMonth()`/`.getUTCMonth()` respect to `preserveTimezones`,
990
+ * we create a different Date to trick strftime, it's both simpler and more performant.
991
+ * Given that a template is expected to be parsed fewer times than rendered.
992
+ */
993
+ static createDateFixedToTimezone(dateString, locale) {
994
+ const m = dateString.match(TIMEZONE_PATTERN);
995
+ if (m && m[1] === "Z") return new LiquidDate(+new Date(dateString), locale, 0);
996
+ if (m && m[2] && m[3] && m[4]) {
997
+ const [, , sign, hours, minutes] = m;
998
+ const offset = (sign === "+" ? -1 : 1) * (parseInt(hours, 10) * 60 + parseInt(minutes, 10));
999
+ return new LiquidDate(+new Date(dateString), locale, offset);
1000
+ }
1001
+ return new LiquidDate(dateString, locale);
1002
+ }
1003
+ static getTimezoneOffset(timezoneName, date) {
1004
+ const localDateString = date.toLocaleString("en-US", { timeZone: timezoneName });
1005
+ const utcDateString = date.toLocaleString("en-US", { timeZone: "UTC" });
1006
+ const localDate = new Date(localDateString);
1007
+ return (+new Date(utcDateString) - +localDate) / 6e4;
1008
+ }
1009
+ };
1010
+ var Limiter = class {
1011
+ constructor(resource, limit) {
1012
+ this.base = 0;
1013
+ this.message = `${resource} limit exceeded`;
1014
+ this.limit = limit;
1015
+ }
1016
+ use(count) {
1017
+ if (+count > 0) {
1018
+ assert(this.base + +count <= this.limit, this.message);
1019
+ this.base += +count;
1020
+ }
1021
+ }
1022
+ check(count) {
1023
+ if (+count > 0) assert(+count <= this.limit, this.message);
1024
+ }
1025
+ };
1026
+ var DelimitedToken = class extends Token {
1027
+ constructor(kind, [contentBegin, contentEnd], input, begin, end, trimLeft, trimRight, file) {
1028
+ super(kind, input, begin, end, file);
1029
+ this.trimLeft = false;
1030
+ this.trimRight = false;
1031
+ const tl = input[contentBegin] === "-";
1032
+ const tr = input[contentEnd - 1] === "-";
1033
+ let l = tl ? contentBegin + 1 : contentBegin;
1034
+ let r = tr ? contentEnd - 1 : contentEnd;
1035
+ while (l < r && TYPES[input.charCodeAt(l)] & BLANK) l++;
1036
+ while (r > l && TYPES[input.charCodeAt(r - 1)] & BLANK) r--;
1037
+ this.contentRange = [l, r];
1038
+ this.trimLeft = tl || trimLeft;
1039
+ this.trimRight = tr || trimRight;
1040
+ }
1041
+ get content() {
1042
+ return this.input.slice(this.contentRange[0], this.contentRange[1]);
1043
+ }
1044
+ };
1045
+ var TagToken = class extends DelimitedToken {
1046
+ constructor(input, begin, end, options, file) {
1047
+ const { trimTagLeft, trimTagRight, tagDelimiterLeft, tagDelimiterRight } = options;
1048
+ const [valueBegin, valueEnd] = [begin + tagDelimiterLeft.length, end - tagDelimiterRight.length];
1049
+ super(TokenKind.Tag, [valueBegin, valueEnd], input, begin, end, trimTagLeft, trimTagRight, file);
1050
+ this.tokenizer = new Tokenizer(input, options.operators, file, this.contentRange, options.groupedExpressions);
1051
+ this.name = this.tokenizer.readTagName();
1052
+ this.tokenizer.assert(this.name, `illegal tag syntax, tag name expected`);
1053
+ this.tokenizer.skipBlank();
1054
+ this.args = this.tokenizer.input.slice(this.tokenizer.p, this.contentRange[1]);
1055
+ }
1056
+ };
1057
+ var OutputToken = class extends DelimitedToken {
1058
+ constructor(input, begin, end, options, file) {
1059
+ const { trimOutputLeft, trimOutputRight, outputDelimiterLeft, outputDelimiterRight } = options;
1060
+ const valueRange = [begin + outputDelimiterLeft.length, end - outputDelimiterRight.length];
1061
+ super(TokenKind.Output, valueRange, input, begin, end, trimOutputLeft, trimOutputRight, file);
1062
+ }
1063
+ };
1064
+ var HTMLToken = class extends Token {
1065
+ constructor(input, begin, end, file) {
1066
+ super(TokenKind.HTML, input, begin, end, file);
1067
+ this.input = input;
1068
+ this.begin = begin;
1069
+ this.end = end;
1070
+ this.file = file;
1071
+ this.trimLeft = 0;
1072
+ this.trimRight = 0;
1073
+ }
1074
+ getContent() {
1075
+ return this.input.slice(this.begin + this.trimLeft, this.end - this.trimRight);
1076
+ }
1077
+ };
1078
+ var NumberToken = class extends Token {
1079
+ constructor(input, begin, end, file) {
1080
+ super(TokenKind.Number, input, begin, end, file);
1081
+ this.input = input;
1082
+ this.begin = begin;
1083
+ this.end = end;
1084
+ this.file = file;
1085
+ this.content = Number(this.getText());
1086
+ }
1087
+ };
1088
+ var IdentifierToken = class extends Token {
1089
+ constructor(input, begin, end, file) {
1090
+ super(TokenKind.Word, input, begin, end, file);
1091
+ this.input = input;
1092
+ this.begin = begin;
1093
+ this.end = end;
1094
+ this.file = file;
1095
+ this.content = this.getText();
1096
+ }
1097
+ };
1098
+ var LiteralToken = class extends Token {
1099
+ constructor(input, begin, end, file) {
1100
+ super(TokenKind.Literal, input, begin, end, file);
1101
+ this.input = input;
1102
+ this.begin = begin;
1103
+ this.end = end;
1104
+ this.file = file;
1105
+ this.literal = this.getText();
1106
+ this.content = literalValues[this.literal];
1107
+ }
1108
+ };
1109
+ const operatorPrecedences = {
1110
+ "==": 2,
1111
+ "!=": 2,
1112
+ ">": 2,
1113
+ "<": 2,
1114
+ ">=": 2,
1115
+ "<=": 2,
1116
+ "contains": 2,
1117
+ "not": 1,
1118
+ "and": 0,
1119
+ "or": 0
1120
+ };
1121
+ const operatorTypes = {
1122
+ "==": 0,
1123
+ "!=": 0,
1124
+ ">": 0,
1125
+ "<": 0,
1126
+ ">=": 0,
1127
+ "<=": 0,
1128
+ "contains": 0,
1129
+ "not": 1,
1130
+ "and": 0,
1131
+ "or": 0
1132
+ };
1133
+ var OperatorToken = class extends Token {
1134
+ constructor(input, begin, end, file) {
1135
+ super(TokenKind.Operator, input, begin, end, file);
1136
+ this.input = input;
1137
+ this.begin = begin;
1138
+ this.end = end;
1139
+ this.file = file;
1140
+ this.operator = this.getText();
1141
+ }
1142
+ getPrecedence() {
1143
+ return this.operator in operatorPrecedences ? operatorPrecedences[this.operator] : 1;
1144
+ }
1145
+ };
1146
+ var PropertyAccessToken = class extends Token {
1147
+ constructor(variable, props, input, begin, end, file) {
1148
+ super(TokenKind.PropertyAccess, input, begin, end, file);
1149
+ this.variable = variable;
1150
+ this.props = props;
1151
+ }
1152
+ };
1153
+ var FilterToken = class extends Token {
1154
+ constructor(name, args, input, begin, end, file) {
1155
+ super(TokenKind.Filter, input, begin, end, file);
1156
+ this.name = name;
1157
+ this.args = args;
1158
+ }
1159
+ };
1160
+ var HashToken = class extends Token {
1161
+ constructor(input, begin, end, name, value, file) {
1162
+ super(TokenKind.Hash, input, begin, end, file);
1163
+ this.input = input;
1164
+ this.begin = begin;
1165
+ this.end = end;
1166
+ this.name = name;
1167
+ this.value = value;
1168
+ this.file = file;
1169
+ }
1170
+ };
1171
+ const rHex = /[\da-fA-F]/;
1172
+ const rOct = /[0-7]/;
1173
+ const escapeChar = {
1174
+ b: "\b",
1175
+ f: "\f",
1176
+ n: "\n",
1177
+ r: "\r",
1178
+ t: " ",
1179
+ v: "\v"
1180
+ };
1181
+ function hexVal(c) {
1182
+ const code = c.charCodeAt(0);
1183
+ if (code >= 97) return code - 87;
1184
+ if (code >= 65) return code - 55;
1185
+ return code - 48;
1186
+ }
1187
+ function parseStringLiteral(str) {
1188
+ let ret = "";
1189
+ for (let i = 1; i < str.length - 1; i++) {
1190
+ if (str[i] !== "\\") {
1191
+ ret += str[i];
1192
+ continue;
1193
+ }
1194
+ if (escapeChar[str[i + 1]] !== void 0) ret += escapeChar[str[++i]];
1195
+ else if (str[i + 1] === "u") {
1196
+ let val = 0;
1197
+ let j = i + 2;
1198
+ while (j <= i + 5 && rHex.test(str[j])) val = val * 16 + hexVal(str[j++]);
1199
+ i = j - 1;
1200
+ ret += String.fromCharCode(val);
1201
+ } else if (!rOct.test(str[i + 1])) ret += str[++i];
1202
+ else {
1203
+ let j = i + 1;
1204
+ let val = 0;
1205
+ while (j <= i + 3 && rOct.test(str[j])) val = val * 8 + hexVal(str[j++]);
1206
+ i = j - 1;
1207
+ ret += String.fromCharCode(val);
1208
+ }
1209
+ }
1210
+ return ret;
1211
+ }
1212
+ var QuotedToken = class extends Token {
1213
+ constructor(input, begin, end, file) {
1214
+ super(TokenKind.Quoted, input, begin, end, file);
1215
+ this.input = input;
1216
+ this.begin = begin;
1217
+ this.end = end;
1218
+ this.file = file;
1219
+ this.content = parseStringLiteral(this.getText());
1220
+ }
1221
+ };
1222
+ var RangeToken = class extends Token {
1223
+ constructor(input, begin, end, lhs, rhs, file) {
1224
+ super(TokenKind.Range, input, begin, end, file);
1225
+ this.input = input;
1226
+ this.begin = begin;
1227
+ this.end = end;
1228
+ this.lhs = lhs;
1229
+ this.rhs = rhs;
1230
+ this.file = file;
1231
+ }
1232
+ };
1233
+ /**
1234
+ * LiquidTagToken is different from TagToken by not having delimiters `{%` or `%}`
1235
+ */
1236
+ var LiquidTagToken = class extends DelimitedToken {
1237
+ constructor(input, begin, end, options, file) {
1238
+ super(TokenKind.Tag, [begin, end], input, begin, end, false, false, file);
1239
+ this.tokenizer = new Tokenizer(input, options.operators, file, this.contentRange, options.groupedExpressions);
1240
+ this.name = this.tokenizer.readTagName();
1241
+ this.tokenizer.assert(this.name, "illegal liquid tag syntax");
1242
+ this.tokenizer.skipBlank();
1243
+ }
1244
+ get args() {
1245
+ return this.tokenizer.input.slice(this.tokenizer.p, this.contentRange[1]);
1246
+ }
1247
+ };
1248
+ /**
1249
+ * value expression with optional filters
1250
+ * e.g.
1251
+ * {% assign foo="bar" | append: "coo" %}
1252
+ */
1253
+ var FilteredValueToken = class extends Token {
1254
+ constructor(initial, filters, input, begin, end, file) {
1255
+ super(TokenKind.FilteredValue, input, begin, end, file);
1256
+ this.initial = initial;
1257
+ this.filters = filters;
1258
+ this.input = input;
1259
+ this.begin = begin;
1260
+ this.end = end;
1261
+ this.file = file;
1262
+ }
1263
+ };
1264
+ const polyfill = { now: () => Date.now() };
1265
+ function getPerformance() {
1266
+ return typeof global === "object" && global.performance || typeof window === "object" && window.performance || polyfill;
1267
+ }
1268
+ var Render = class {
1269
+ renderTemplatesToNodeStream(templates, ctx) {
1270
+ const emitter = new StreamedEmitter();
1271
+ Promise.resolve().then(() => toPromise(this.renderTemplates(templates, ctx, emitter))).then(() => emitter.end(), (err) => emitter.error(err));
1272
+ return emitter.stream;
1273
+ }
1274
+ *renderTemplates(templates, ctx, emitter) {
1275
+ if (!emitter) emitter = ctx.opts.keepOutputType ? new KeepingTypeEmitter() : new SimpleEmitter();
1276
+ ctx.renderLimit.check(getPerformance().now());
1277
+ const errors = [];
1278
+ for (const tpl of templates) {
1279
+ ctx.renderLimit.check(getPerformance().now());
1280
+ try {
1281
+ const html = yield tpl.render(ctx, emitter);
1282
+ html && emitter.write(html);
1283
+ if (ctx.breakCalled || ctx.continueCalled) break;
1284
+ } catch (e) {
1285
+ const err = LiquidError.is(e) ? e : new RenderError(e, tpl);
1286
+ if (ctx.opts.catchAllErrors) errors.push(err);
1287
+ else throw err;
1288
+ }
1289
+ }
1290
+ if (errors.length) throw new LiquidErrors(errors);
1291
+ return emitter.buffer;
1292
+ }
1293
+ };
1294
+ function isKeyValuePair(arr) {
1295
+ return isArray(arr);
1296
+ }
1297
+ var Filter = class {
1298
+ constructor(token, options, liquid) {
1299
+ this.token = token;
1300
+ this.name = token.name;
1301
+ this.handler = isFunction(options) ? options : isFunction(options === null || options === void 0 ? void 0 : options.handler) ? options.handler : identify;
1302
+ this.raw = !isFunction(options) && !!(options === null || options === void 0 ? void 0 : options.raw);
1303
+ this.args = token.args;
1304
+ this.liquid = liquid;
1305
+ }
1306
+ *render(value, context) {
1307
+ const argv = [];
1308
+ for (const arg of this.args) if (isKeyValuePair(arg)) argv.push([arg[0], yield evalToken(arg[1], context)]);
1309
+ else argv.push(yield evalToken(arg, context));
1310
+ return yield this.handler.apply({
1311
+ context,
1312
+ token: this.token,
1313
+ liquid: this.liquid
1314
+ }, [value, ...argv]);
1315
+ }
1316
+ };
1317
+ var Expression = class {
1318
+ constructor(tokens) {
1319
+ this.postfix = [...toPostfix(tokens)];
1320
+ }
1321
+ *evaluate(ctx, lenient) {
1322
+ assert(ctx, "unable to evaluate: context not defined");
1323
+ const operands = [];
1324
+ for (const token of this.postfix) if (isOperatorToken(token)) {
1325
+ const r = operands.pop();
1326
+ let result;
1327
+ if (operatorTypes[token.operator] === 1) result = yield ctx.opts.operators[token.operator](r, ctx);
1328
+ else {
1329
+ const l = operands.pop();
1330
+ result = yield ctx.opts.operators[token.operator](l, r, ctx);
1331
+ }
1332
+ operands.push(result);
1333
+ } else operands.push(yield evalToken(token, ctx, lenient));
1334
+ return operands[0];
1335
+ }
1336
+ valid() {
1337
+ return !!this.postfix.length;
1338
+ }
1339
+ };
1340
+ /**
1341
+ * Evaluate `token`, preserving Drops.
1342
+ * Operators use this so `Comparable` drops (`empty`, `nil`, `blank`) and custom drops
1343
+ * are compared as drops rather than as their `valueOf()` result.
1344
+ */
1345
+ function* evalToken(token, ctx, lenient = false) {
1346
+ if (!token) return;
1347
+ if ("content" in token) return token.content;
1348
+ if (isPropertyAccessToken(token)) return yield evalPropertyAccessToken(token, ctx, lenient);
1349
+ if (isRangeToken(token)) return yield evalRangeToken(token, ctx);
1350
+ if (isFilteredValueToken(token)) return yield evalFilteredValueToken(token, ctx, lenient);
1351
+ }
1352
+ function* evalFilteredValueToken(token, ctx, lenient) {
1353
+ assert(ctx.liquid, "FilteredValueToken evaluation requires liquid instance in context");
1354
+ lenient = lenient || ctx.opts.lenientIf && token.filters.length > 0 && token.filters[0].name === "default";
1355
+ let val = yield token.initial.evaluate(ctx, lenient);
1356
+ for (const filterToken of token.filters) {
1357
+ const filterImpl = ctx.liquid.filters[filterToken.name];
1358
+ assert(filterImpl || !ctx.liquid.options.strictFilters, () => `undefined filter: ${filterToken.name}`);
1359
+ val = yield new Filter(filterToken, filterImpl, ctx.liquid).render(val, ctx);
1360
+ }
1361
+ return val;
1362
+ }
1363
+ /**
1364
+ * Evaluate `token` to the value filters and tags consume.
1365
+ * Awaits a promise returned by `Drop.valueOf()`.
1366
+ */
1367
+ function* evalTokenValue(token, ctx, lenient = false) {
1368
+ return yield toValue(yield evalToken(token, ctx, lenient));
1369
+ }
1370
+ function* evalPropertyAccessToken(token, ctx, lenient) {
1371
+ const props = [];
1372
+ for (const prop of token.props) props.push(yield evalTokenValue(prop, ctx, false));
1373
+ try {
1374
+ if (token.variable) {
1375
+ const variable = yield evalToken(token.variable, ctx, lenient);
1376
+ return yield ctx._getFromScope(variable, props);
1377
+ } else return yield ctx._get(props);
1378
+ } catch (e) {
1379
+ if (lenient && e.name === "InternalUndefinedVariableError") return null;
1380
+ throw new UndefinedVariableError(e, token);
1381
+ }
1382
+ }
1383
+ function evalQuotedToken(token) {
1384
+ return token.content;
1385
+ }
1386
+ function* evalRangeToken(token, ctx) {
1387
+ const low = yield evalTokenValue(token.lhs, ctx);
1388
+ const high = yield evalTokenValue(token.rhs, ctx);
1389
+ ctx.memoryLimit.use(high - low + 1);
1390
+ return range(+low, +high + 1);
1391
+ }
1392
+ function* toPostfix(tokens) {
1393
+ const ops = [];
1394
+ for (const token of tokens) if (isOperatorToken(token)) {
1395
+ while (ops.length && ops[ops.length - 1].getPrecedence() > token.getPrecedence()) yield ops.pop();
1396
+ ops.push(token);
1397
+ } else yield token;
1398
+ while (ops.length) yield ops.pop();
1399
+ }
1400
+ function isTruthy(val, ctx) {
1401
+ return !isFalsy(val, ctx);
1402
+ }
1403
+ function isFalsy(val, ctx) {
1404
+ val = toValue(val);
1405
+ if (ctx.opts.jsTruthy) return !val;
1406
+ else return val === false || void 0 === val || val === null;
1407
+ }
1408
+ const defaultOperators = {
1409
+ "==": function* (l, r) {
1410
+ return yield equals(l, r);
1411
+ },
1412
+ "!=": function* (l, r) {
1413
+ return !(yield equals(l, r));
1414
+ },
1415
+ ">": function* (l, r) {
1416
+ if (isComparable(l)) return yield l.gt(r);
1417
+ if (isComparable(r)) return yield r.lt(l);
1418
+ return (yield toValue(l)) > (yield toValue(r));
1419
+ },
1420
+ "<": function* (l, r) {
1421
+ if (isComparable(l)) return yield l.lt(r);
1422
+ if (isComparable(r)) return yield r.gt(l);
1423
+ return (yield toValue(l)) < (yield toValue(r));
1424
+ },
1425
+ ">=": function* (l, r) {
1426
+ if (isComparable(l)) return yield l.geq(r);
1427
+ if (isComparable(r)) return yield r.leq(l);
1428
+ return (yield toValue(l)) >= (yield toValue(r));
1429
+ },
1430
+ "<=": function* (l, r) {
1431
+ if (isComparable(l)) return yield l.leq(r);
1432
+ if (isComparable(r)) return yield r.geq(l);
1433
+ return (yield toValue(l)) <= (yield toValue(r));
1434
+ },
1435
+ "contains": function* (l, r) {
1436
+ l = yield toValue(l);
1437
+ if (isArray(l)) return yield arrayIncludes(l, r);
1438
+ if (isFunction(l === null || l === void 0 ? void 0 : l.indexOf)) return l.indexOf(yield toValue(r)) > -1;
1439
+ return false;
1440
+ },
1441
+ "not": function* (v, ctx) {
1442
+ return isFalsy(yield toValue(v), ctx);
1443
+ },
1444
+ "and": function* (l, r, ctx) {
1445
+ return isTruthy(yield toValue(l), ctx) && isTruthy(yield toValue(r), ctx);
1446
+ },
1447
+ "or": function* (l, r, ctx) {
1448
+ return isTruthy(yield toValue(l), ctx) || isTruthy(yield toValue(r), ctx);
1449
+ }
1450
+ };
1451
+ function* equals(lhs, rhs) {
1452
+ if (isComparable(lhs)) return yield lhs.equals(rhs);
1453
+ if (isComparable(rhs)) return yield rhs.equals(lhs);
1454
+ lhs = yield toValue(lhs);
1455
+ rhs = yield toValue(rhs);
1456
+ if (isArray(lhs)) return isArray(rhs) && (yield arrayEquals(lhs, rhs));
1457
+ return lhs === rhs;
1458
+ }
1459
+ function* arrayEquals(lhs, rhs) {
1460
+ if (lhs.length !== rhs.length) return false;
1461
+ for (let i = 0; i < lhs.length; i++) if (!(yield equals(lhs[i], rhs[i]))) return false;
1462
+ return true;
1463
+ }
1464
+ function* arrayIncludes(arr, item) {
1465
+ for (const value of arr) if (yield equals(value, item)) return true;
1466
+ return false;
1467
+ }
1468
+ var Node = class {
1469
+ constructor(key, value, next, prev) {
1470
+ this.key = key;
1471
+ this.value = value;
1472
+ this.next = next;
1473
+ this.prev = prev;
1474
+ }
1475
+ };
1476
+ var LRU = class {
1477
+ constructor(limit, size = 0) {
1478
+ this.limit = limit;
1479
+ this.size = size;
1480
+ this.cache = {};
1481
+ this.head = new Node("HEAD", null, null, null);
1482
+ this.tail = new Node("TAIL", null, null, null);
1483
+ this.head.next = this.tail;
1484
+ this.tail.prev = this.head;
1485
+ }
1486
+ write(key, value) {
1487
+ if (this.cache[key]) this.cache[key].value = value;
1488
+ else {
1489
+ const node = new Node(key, value, this.head.next, this.head);
1490
+ this.head.next.prev = node;
1491
+ this.head.next = node;
1492
+ this.cache[key] = node;
1493
+ this.size++;
1494
+ this.ensureLimit();
1495
+ }
1496
+ }
1497
+ read(key) {
1498
+ if (!this.cache[key]) return;
1499
+ const { value } = this.cache[key];
1500
+ this.remove(key);
1501
+ this.write(key, value);
1502
+ return value;
1503
+ }
1504
+ remove(key) {
1505
+ const node = this.cache[key];
1506
+ node.prev.next = node.next;
1507
+ node.next.prev = node.prev;
1508
+ delete this.cache[key];
1509
+ this.size--;
1510
+ }
1511
+ clear() {
1512
+ this.head.next = this.tail;
1513
+ this.tail.prev = this.head;
1514
+ this.size = 0;
1515
+ this.cache = {};
1516
+ }
1517
+ ensureLimit() {
1518
+ if (this.size > this.limit) this.remove(this.tail.prev.key);
1519
+ }
1520
+ };
1521
+ function domResolve(root, path) {
1522
+ const base = document.createElement("base");
1523
+ base.href = root;
1524
+ const head = document.getElementsByTagName("head")[0];
1525
+ head.insertBefore(base, head.firstChild);
1526
+ const a = document.createElement("a");
1527
+ a.href = path;
1528
+ const resolved = a.href;
1529
+ head.removeChild(base);
1530
+ return resolved;
1531
+ }
1532
+ function resolve(root, filepath, ext) {
1533
+ if (root.length && last(root) !== "/") root += "/";
1534
+ return domResolve(root, filepath).replace(/^(\w+:\/\/[^/]+)(\/[^?]+)/, (str, origin, path) => {
1535
+ const last = path.split("/").pop();
1536
+ if (/\.\w+$/.test(last)) return str;
1537
+ return origin + path + ext;
1538
+ });
1539
+ }
1540
+ function readFile(url) {
1541
+ return __awaiter(this, void 0, void 0, function* () {
1542
+ return new Promise((resolve, reject) => {
1543
+ const xhr = new XMLHttpRequest();
1544
+ xhr.onload = () => {
1545
+ if (xhr.status >= 200 && xhr.status < 300) resolve(xhr.responseText);
1546
+ else reject(new Error(xhr.statusText));
1547
+ };
1548
+ xhr.onerror = () => {
1549
+ reject(/* @__PURE__ */ new Error("An error occurred whilst receiving the response."));
1550
+ };
1551
+ xhr.open("GET", url);
1552
+ xhr.send();
1553
+ });
1554
+ });
1555
+ }
1556
+ function readFileSync(url) {
1557
+ const xhr = new XMLHttpRequest();
1558
+ xhr.open("GET", url, false);
1559
+ xhr.send();
1560
+ if (xhr.status < 200 || xhr.status >= 300) throw new Error(xhr.statusText);
1561
+ return xhr.responseText;
1562
+ }
1563
+ function exists(filepath) {
1564
+ return __awaiter(this, void 0, void 0, function* () {
1565
+ return true;
1566
+ });
1567
+ }
1568
+ function existsSync(filepath) {
1569
+ return true;
1570
+ }
1571
+ function dirname(filepath) {
1572
+ return domResolve(filepath, ".");
1573
+ }
1574
+ var fs = /*#__PURE__*/ Object.freeze({
1575
+ __proto__: null,
1576
+ resolve,
1577
+ readFile,
1578
+ readFileSync,
1579
+ exists,
1580
+ existsSync,
1581
+ dirname,
1582
+ sep: "/"
1583
+ });
1584
+ function chargeJsonReplacerValue(memoryLimit, val) {
1585
+ if (typeof val === "string") memoryLimit.use(val.length);
1586
+ else if (val === null || typeof val === "number" || typeof val === "boolean") memoryLimit.use(JSON.stringify(val).length);
1587
+ else if (Array.isArray(val)) memoryLimit.use(val.length + 1);
1588
+ else if (typeof val === "object") memoryLimit.use(2);
1589
+ }
1590
+ function defaultFilter(value, defaultValue, ...args) {
1591
+ value = toValue(value);
1592
+ if (isArray(value) || isString(value)) return value.length ? value : defaultValue;
1593
+ if (value === false && new Map(args).get("allow_false")) return false;
1594
+ return isFalsy(value, this.context) ? defaultValue : value;
1595
+ }
1596
+ function json(value, space = 0) {
1597
+ const memoryLimit = this.context.memoryLimit;
1598
+ return JSON.stringify(value, (_key, val) => {
1599
+ chargeJsonReplacerValue(memoryLimit, val);
1600
+ return val;
1601
+ }, space);
1602
+ }
1603
+ function inspect(value, space = 0) {
1604
+ const memoryLimit = this.context.memoryLimit;
1605
+ const ancestors = [];
1606
+ return JSON.stringify(value, function(_key, value) {
1607
+ if (typeof value !== "object" || value === null) {
1608
+ chargeJsonReplacerValue(memoryLimit, value);
1609
+ return value;
1610
+ }
1611
+ while (ancestors.length > 0 && ancestors[ancestors.length - 1] !== this) ancestors.pop();
1612
+ if (ancestors.includes(value)) {
1613
+ memoryLimit.use(10);
1614
+ return "[Circular]";
1615
+ }
1616
+ ancestors.push(value);
1617
+ chargeJsonReplacerValue(memoryLimit, value);
1618
+ return value;
1619
+ }, space);
1620
+ }
1621
+ function to_integer(value) {
1622
+ return Number(value);
1623
+ }
1624
+ var misc = {
1625
+ default: defaultFilter,
1626
+ raw: {
1627
+ raw: true,
1628
+ handler: identify
1629
+ },
1630
+ jsonify: json,
1631
+ to_integer,
1632
+ json,
1633
+ inspect
1634
+ };
1635
+ const escapeMap = {
1636
+ "&": "&amp;",
1637
+ "<": "&lt;",
1638
+ ">": "&gt;",
1639
+ "\"": "&#34;",
1640
+ "'": "&#39;"
1641
+ };
1642
+ const unescapeMap = {
1643
+ "&amp;": "&",
1644
+ "&lt;": "<",
1645
+ "&gt;": ">",
1646
+ "&#34;": "\"",
1647
+ "&#39;": "'"
1648
+ };
1649
+ function escape(str) {
1650
+ str = stringify(str);
1651
+ this.context.memoryLimit.use(str.length);
1652
+ return str.replace(/&|<|>|"|'/g, (m) => escapeMap[m]);
1653
+ }
1654
+ function xml_escape(str) {
1655
+ return escape.call(this, str);
1656
+ }
1657
+ function unescape(str) {
1658
+ str = stringify(str);
1659
+ this.context.memoryLimit.use(str.length);
1660
+ return str.replace(/&(amp|lt|gt|#34|#39);/g, (m) => unescapeMap[m]);
1661
+ }
1662
+ function escape_once(str) {
1663
+ return escape.call(this, unescape.call(this, str));
1664
+ }
1665
+ function newline_to_br(v) {
1666
+ const str = stringify(v);
1667
+ this.context.memoryLimit.use(str.length);
1668
+ return str.replace(/\r?\n/gm, "<br />\n");
1669
+ }
1670
+ function strip_html(v) {
1671
+ const str = stringify(v);
1672
+ this.context.memoryLimit.use(str.length);
1673
+ const blocks = /* @__PURE__ */ new Map([
1674
+ ["<script", "<\/script>"],
1675
+ ["<style", "</style>"],
1676
+ ["<!--", "-->"],
1677
+ ["<", ">"]
1678
+ ]);
1679
+ let out = "";
1680
+ let i = 0;
1681
+ while (i < str.length) {
1682
+ const lt = str.indexOf("<", i);
1683
+ if (lt < 0) return out + str.slice(i);
1684
+ out += str.slice(i, lt);
1685
+ for (const [opener, closer] of blocks) {
1686
+ if (!str.startsWith(opener, lt)) continue;
1687
+ const e = str.indexOf(closer, lt + opener.length);
1688
+ if (e >= 0) {
1689
+ i = e + closer.length;
1690
+ break;
1691
+ }
1692
+ blocks.delete(opener);
1693
+ }
1694
+ if (i <= lt) return out + str.slice(lt);
1695
+ }
1696
+ return out;
1697
+ }
1698
+ var htmlFilters = /*#__PURE__*/ Object.freeze({
1699
+ __proto__: null,
1700
+ escape,
1701
+ xml_escape,
1702
+ escape_once,
1703
+ newline_to_br,
1704
+ strip_html
1705
+ });
1706
+ var MapFS = class {
1707
+ constructor(mapping) {
1708
+ this.mapping = mapping;
1709
+ this.sep = "/";
1710
+ }
1711
+ exists(filepath) {
1712
+ return __awaiter(this, void 0, void 0, function* () {
1713
+ return this.existsSync(filepath);
1714
+ });
1715
+ }
1716
+ existsSync(filepath) {
1717
+ return !isNil(this.mapping[filepath]);
1718
+ }
1719
+ readFile(filepath) {
1720
+ return __awaiter(this, void 0, void 0, function* () {
1721
+ return this.readFileSync(filepath);
1722
+ });
1723
+ }
1724
+ readFileSync(filepath) {
1725
+ const content = this.mapping[filepath];
1726
+ if (isNil(content)) throw new Error(`ENOENT: ${filepath}`);
1727
+ return content;
1728
+ }
1729
+ dirname(filepath) {
1730
+ const segments = filepath.split(this.sep);
1731
+ segments.pop();
1732
+ return segments.join(this.sep);
1733
+ }
1734
+ resolve(dir, file, ext) {
1735
+ file += ext;
1736
+ if (dir === ".") return file;
1737
+ const segments = dir.split(/\/+/);
1738
+ for (const segment of file.split(this.sep)) if (segment === "." || segment === "") continue;
1739
+ else if (segment === "..") {
1740
+ if (segments.length > 1 || segments[0] !== "") segments.pop();
1741
+ } else segments.push(segment);
1742
+ return segments.join(this.sep);
1743
+ }
1744
+ };
1745
+ const defaultOptions = {
1746
+ root: ["."],
1747
+ layouts: ["."],
1748
+ partials: ["."],
1749
+ relativeReference: true,
1750
+ jekyllInclude: false,
1751
+ keyValueSeparator: ":",
1752
+ cache: void 0,
1753
+ extname: "",
1754
+ fs,
1755
+ dynamicPartials: true,
1756
+ jsTruthy: false,
1757
+ dateFormat: "%A, %B %-e, %Y at %-l:%M %P %z",
1758
+ locale: "",
1759
+ trimTagRight: false,
1760
+ trimTagLeft: false,
1761
+ trimOutputRight: false,
1762
+ trimOutputLeft: false,
1763
+ greedy: true,
1764
+ tagDelimiterLeft: "{%",
1765
+ tagDelimiterRight: "%}",
1766
+ outputDelimiterLeft: "{{",
1767
+ outputDelimiterRight: "}}",
1768
+ preserveTimezones: false,
1769
+ strictFilters: false,
1770
+ strictVariables: false,
1771
+ ownPropertyOnly: true,
1772
+ lenientIf: false,
1773
+ globals: {},
1774
+ keepOutputType: false,
1775
+ operators: defaultOperators,
1776
+ groupedExpressions: false,
1777
+ memoryLimit: Infinity,
1778
+ parseLimit: Infinity,
1779
+ renderLimit: Infinity
1780
+ };
1781
+ function normalize(options) {
1782
+ var _a, _b;
1783
+ if (options.hasOwnProperty("root")) {
1784
+ if (!options.hasOwnProperty("partials")) options.partials = options.root;
1785
+ if (!options.hasOwnProperty("layouts")) options.layouts = options.root;
1786
+ }
1787
+ if (options.hasOwnProperty("cache")) {
1788
+ let cache;
1789
+ if (typeof options.cache === "number") cache = options.cache > 0 ? new LRU(options.cache) : void 0;
1790
+ else if (typeof options.cache === "object") cache = options.cache;
1791
+ else cache = options.cache ? new LRU(1024) : void 0;
1792
+ options.cache = cache;
1793
+ }
1794
+ options = Object.assign(Object.assign(Object.assign({}, defaultOptions), options.jekyllInclude ? { dynamicPartials: false } : {}), options);
1795
+ if ((!options.fs.dirname || !options.fs.sep) && options.relativeReference) {
1796
+ console.warn("[LiquidJS] `fs.dirname` and `fs.sep` are required for relativeReference, set relativeReference to `false` to suppress this warning");
1797
+ options.relativeReference = false;
1798
+ }
1799
+ options.root = normalizeDirectoryList(options.root);
1800
+ options.partials = normalizeDirectoryList(options.partials);
1801
+ options.layouts = normalizeDirectoryList(options.layouts);
1802
+ options.outputEscape = options.outputEscape && getOutputEscapeFunction(options.outputEscape);
1803
+ if (!options.locale) options.locale = (_b = (_a = getDateTimeFormat()) === null || _a === void 0 ? void 0 : _a().resolvedOptions().locale) !== null && _b !== void 0 ? _b : "en-US";
1804
+ if (options.templates) {
1805
+ options.fs = new MapFS(options.templates);
1806
+ options.relativeReference = true;
1807
+ options.root = options.partials = options.layouts = ".";
1808
+ }
1809
+ return options;
1810
+ }
1811
+ function getOutputEscapeFunction(nameOrFunction) {
1812
+ if (nameOrFunction === "escape") return escape;
1813
+ if (nameOrFunction === "json") return misc.json;
1814
+ assert(isFunction(nameOrFunction), "`outputEscape` need to be of type string or function");
1815
+ return nameOrFunction;
1816
+ }
1817
+ function normalizeDirectoryList(value) {
1818
+ let list = [];
1819
+ if (isArray(value)) list = value;
1820
+ if (isString(value)) list = [value];
1821
+ return list;
1822
+ }
1823
+ function whiteSpaceCtrl(tokens, options) {
1824
+ let inRaw = false;
1825
+ for (let i = 0; i < tokens.length; i++) {
1826
+ const token = tokens[i];
1827
+ if (!isDelimitedToken(token)) continue;
1828
+ if (!inRaw && token.trimLeft) trimLeft(tokens[i - 1], options.greedy);
1829
+ if (isTagToken(token)) {
1830
+ if (token.name === "raw") inRaw = true;
1831
+ else if (token.name === "endraw") inRaw = false;
1832
+ }
1833
+ if (!inRaw && token.trimRight) trimRight(tokens[i + 1], options.greedy);
1834
+ }
1835
+ }
1836
+ function trimLeft(token, greedy) {
1837
+ if (!token || !isHTMLToken(token)) return;
1838
+ const mask = greedy ? BLANK : INLINE_BLANK;
1839
+ while (TYPES[token.input.charCodeAt(token.end - 1 - token.trimRight)] & mask) token.trimRight++;
1840
+ }
1841
+ function trimRight(token, greedy) {
1842
+ if (!token || !isHTMLToken(token)) return;
1843
+ const mask = greedy ? BLANK : INLINE_BLANK;
1844
+ while (TYPES[token.input.charCodeAt(token.begin + token.trimLeft)] & mask) token.trimLeft++;
1845
+ if (token.input.charAt(token.begin + token.trimLeft) === "\n") token.trimLeft++;
1846
+ }
1847
+ var Tokenizer = class {
1848
+ constructor(input, operators = defaultOptions.operators, file, range, groupedExpressions = false) {
1849
+ this.input = input;
1850
+ this.file = file;
1851
+ this.rawBeginAt = -1;
1852
+ this.p = range ? range[0] : 0;
1853
+ this.N = range ? range[1] : input.length;
1854
+ this.opTrie = createTrie(operators);
1855
+ this.literalTrie = createTrie(literalValues);
1856
+ this.groupedExpressions = groupedExpressions;
1857
+ }
1858
+ readExpression() {
1859
+ return new Expression(this.readExpressionTokens());
1860
+ }
1861
+ *readExpressionTokens() {
1862
+ while (this.p < this.N) {
1863
+ const operator = this.readOperator();
1864
+ if (operator) {
1865
+ yield operator;
1866
+ continue;
1867
+ }
1868
+ const operand = this.readValue();
1869
+ if (operand) {
1870
+ yield operand;
1871
+ continue;
1872
+ }
1873
+ return;
1874
+ }
1875
+ }
1876
+ readOperator() {
1877
+ this.skipBlank();
1878
+ const end = this.matchTrie(this.opTrie);
1879
+ if (end === -1) return;
1880
+ return new OperatorToken(this.input, this.p, this.p = end, this.file);
1881
+ }
1882
+ matchTrie(trie) {
1883
+ let node = trie;
1884
+ let i = this.p;
1885
+ let info;
1886
+ while (node[this.input[i]] && i < this.N) {
1887
+ node = node[this.input[i++]];
1888
+ if (node["end"]) info = node;
1889
+ }
1890
+ if (!info) return -1;
1891
+ if (info["needBoundary"] && isWord(this.peek(i - this.p))) return -1;
1892
+ return i;
1893
+ }
1894
+ readFilteredValue() {
1895
+ const begin = this.p;
1896
+ const initial = this.readExpression();
1897
+ this.assert(initial.valid(), `invalid value expression: ${this.snapshot()}`);
1898
+ return new FilteredValueToken(initial, this.readFilters(), this.input, begin, this.p, this.file);
1899
+ }
1900
+ readFilters() {
1901
+ const filters = [];
1902
+ while (true) {
1903
+ const filter = this.readFilter();
1904
+ if (!filter) return filters;
1905
+ filters.push(filter);
1906
+ }
1907
+ }
1908
+ readFilter() {
1909
+ this.skipBlank();
1910
+ if (this.end()) return null;
1911
+ if (this.peek() === ")") return null;
1912
+ this.assert(this.read() === "|", `expected "|" before filter`);
1913
+ const name = this.readIdentifier();
1914
+ if (!name.size()) {
1915
+ this.assert(this.end(), `expected filter name`);
1916
+ return null;
1917
+ }
1918
+ const args = [];
1919
+ this.skipBlank();
1920
+ if (this.peek() === ":") do {
1921
+ ++this.p;
1922
+ const arg = this.readFilterArg();
1923
+ arg && args.push(arg);
1924
+ this.skipBlank();
1925
+ this.assert(this.end() || this.peek() === "," || this.peek() === "|" || this.peek() === ")", () => `unexpected character ${this.snapshot()}`);
1926
+ } while (this.peek() === ",");
1927
+ else if (this.peek() === "|" || this.peek() === ")" || this.end());
1928
+ else throw this.error("expected \":\" after filter name");
1929
+ return new FilterToken(name.getText(), args, this.input, name.begin, this.p, this.file);
1930
+ }
1931
+ readFilterArg() {
1932
+ const key = this.readValue();
1933
+ if (!key) return;
1934
+ this.skipBlank();
1935
+ if (this.peek() !== ":") return key;
1936
+ ++this.p;
1937
+ const value = this.readValue();
1938
+ return [key.getText(), value];
1939
+ }
1940
+ readTopLevelTokens(options = defaultOptions) {
1941
+ const tokens = [];
1942
+ while (this.p < this.N) {
1943
+ const token = this.readTopLevelToken(options);
1944
+ tokens.push(token);
1945
+ }
1946
+ whiteSpaceCtrl(tokens, options);
1947
+ return tokens;
1948
+ }
1949
+ readTopLevelToken(options) {
1950
+ const { tagDelimiterLeft, outputDelimiterLeft } = options;
1951
+ if (this.rawBeginAt > -1) return this.readEndrawOrRawContent(options);
1952
+ if (this.match(tagDelimiterLeft)) return this.readTagToken(options);
1953
+ if (this.match(outputDelimiterLeft)) return this.readOutputToken(options);
1954
+ return this.readHTMLToken([tagDelimiterLeft, outputDelimiterLeft]);
1955
+ }
1956
+ readHTMLToken(stopStrings) {
1957
+ const begin = this.p;
1958
+ while (this.p < this.N) {
1959
+ if (stopStrings.some((str) => this.match(str))) break;
1960
+ ++this.p;
1961
+ }
1962
+ return new HTMLToken(this.input, begin, this.p, this.file);
1963
+ }
1964
+ readTagToken(options) {
1965
+ const { file, input } = this;
1966
+ const begin = this.p;
1967
+ if (this.readToDelimiter(options.tagDelimiterRight) === -1) throw this.error(`tag ${this.snapshot(begin)} not closed`, begin);
1968
+ const token = new TagToken(input, begin, this.p, options, file);
1969
+ if (token.name === "raw") this.rawBeginAt = begin;
1970
+ return token;
1971
+ }
1972
+ readToDelimiter(delimiter, respectQuoted = false) {
1973
+ this.skipBlank();
1974
+ while (this.p < this.N) {
1975
+ if (respectQuoted && this.peekType() & QUOTE) {
1976
+ this.readQuoted();
1977
+ continue;
1978
+ }
1979
+ ++this.p;
1980
+ if (this.rmatch(delimiter)) return this.p;
1981
+ }
1982
+ return -1;
1983
+ }
1984
+ readOutputToken(options = defaultOptions) {
1985
+ const { file, input } = this;
1986
+ const { outputDelimiterRight } = options;
1987
+ const begin = this.p;
1988
+ if (this.readToDelimiter(outputDelimiterRight, true) === -1) throw this.error(`output ${this.snapshot(begin)} not closed`, begin);
1989
+ return new OutputToken(input, begin, this.p, options, file);
1990
+ }
1991
+ readEndrawOrRawContent(options) {
1992
+ const { tagDelimiterLeft, tagDelimiterRight } = options;
1993
+ const begin = this.p;
1994
+ let leftPos = this.readTo(tagDelimiterLeft) - tagDelimiterLeft.length;
1995
+ while (this.p < this.N) {
1996
+ if (this.readIdentifier().getText() !== "endraw") {
1997
+ leftPos = this.readTo(tagDelimiterLeft) - tagDelimiterLeft.length;
1998
+ continue;
1999
+ }
2000
+ while (this.p <= this.N) {
2001
+ if (this.rmatch(tagDelimiterRight)) {
2002
+ const end = this.p;
2003
+ if (begin === leftPos) {
2004
+ this.rawBeginAt = -1;
2005
+ return new TagToken(this.input, begin, end, options, this.file);
2006
+ } else {
2007
+ this.p = leftPos;
2008
+ return new HTMLToken(this.input, begin, leftPos, this.file);
2009
+ }
2010
+ }
2011
+ if (this.rmatch(tagDelimiterLeft)) break;
2012
+ this.p++;
2013
+ }
2014
+ }
2015
+ throw this.error(`raw ${this.snapshot(this.rawBeginAt)} not closed`, begin);
2016
+ }
2017
+ readLiquidTagTokens(options = defaultOptions) {
2018
+ const tokens = [];
2019
+ while (this.p < this.N) {
2020
+ const token = this.readLiquidTagToken(options);
2021
+ token && tokens.push(token);
2022
+ }
2023
+ return tokens;
2024
+ }
2025
+ readLiquidTagToken(options) {
2026
+ this.skipBlank();
2027
+ if (this.end()) return;
2028
+ const begin = this.p;
2029
+ this.readToDelimiter("\n");
2030
+ const end = this.p;
2031
+ return new LiquidTagToken(this.input, begin, end, options, this.file);
2032
+ }
2033
+ error(msg, pos = this.p) {
2034
+ return new TokenizationError(msg, new IdentifierToken(this.input, pos, this.N, this.file));
2035
+ }
2036
+ assert(pred, msg, pos) {
2037
+ if (!pred) throw this.error(typeof msg === "function" ? msg() : msg, pos);
2038
+ }
2039
+ snapshot(begin = this.p) {
2040
+ return JSON.stringify(ellipsis(this.input.slice(begin, this.N), 32));
2041
+ }
2042
+ /**
2043
+ * @deprecated use #readIdentifier instead
2044
+ */
2045
+ readWord() {
2046
+ return this.readIdentifier();
2047
+ }
2048
+ readIdentifier() {
2049
+ this.skipBlank();
2050
+ const begin = this.p;
2051
+ while (!this.end() && isWord(this.peek())) ++this.p;
2052
+ return new IdentifierToken(this.input, begin, this.p, this.file);
2053
+ }
2054
+ readNonEmptyIdentifier() {
2055
+ const id = this.readIdentifier();
2056
+ return id.size() ? id : void 0;
2057
+ }
2058
+ readTagName() {
2059
+ this.skipBlank();
2060
+ if (this.input[this.p] === "#") return this.input.slice(this.p, ++this.p);
2061
+ return this.readIdentifier().getText();
2062
+ }
2063
+ readHashes(jekyllStyle) {
2064
+ const hashes = [];
2065
+ while (true) {
2066
+ const hash = this.readHash(jekyllStyle);
2067
+ if (!hash) return hashes;
2068
+ hashes.push(hash);
2069
+ }
2070
+ }
2071
+ readHash(jekyllStyle) {
2072
+ this.skipBlank();
2073
+ if (this.peek() === ",") ++this.p;
2074
+ const begin = this.p;
2075
+ const name = this.readNonEmptyIdentifier();
2076
+ if (!name) return;
2077
+ let value;
2078
+ this.skipBlank();
2079
+ const sep = isString(jekyllStyle) ? jekyllStyle : jekyllStyle ? "=" : ":";
2080
+ if (this.peek() === sep) {
2081
+ ++this.p;
2082
+ value = this.readValue();
2083
+ }
2084
+ return new HashToken(this.input, begin, this.p, name, value, this.file);
2085
+ }
2086
+ remaining() {
2087
+ return this.input.slice(this.p, this.N);
2088
+ }
2089
+ advance(step = 1) {
2090
+ this.p += step;
2091
+ }
2092
+ end() {
2093
+ return this.p >= this.N;
2094
+ }
2095
+ read() {
2096
+ return this.input[this.p++];
2097
+ }
2098
+ readTo(end) {
2099
+ while (this.p < this.N) {
2100
+ ++this.p;
2101
+ if (this.rmatch(end)) return this.p;
2102
+ }
2103
+ return -1;
2104
+ }
2105
+ readValue() {
2106
+ this.skipBlank();
2107
+ const begin = this.p;
2108
+ let variable = this.readLiteral() || this.readQuoted() || this.readNumber();
2109
+ if (!variable && this.peek() === "(") variable = this.readGroupOrRange();
2110
+ const props = this.readProperties(!variable);
2111
+ if (!props.length) return variable;
2112
+ return new PropertyAccessToken(variable, props, this.input, begin, this.p);
2113
+ }
2114
+ readScopeValue() {
2115
+ this.skipBlank();
2116
+ const begin = this.p;
2117
+ const props = this.readProperties();
2118
+ if (!props.length) return void 0;
2119
+ return new PropertyAccessToken(void 0, props, this.input, begin, this.p);
2120
+ }
2121
+ readProperties(isBegin = true) {
2122
+ const props = [];
2123
+ while (true) {
2124
+ if (this.peek() === "[") {
2125
+ this.p++;
2126
+ const prop = this.readValue() || new IdentifierToken(this.input, this.p, this.p, this.file);
2127
+ this.assert(this.readTo("]") !== -1, "[ not closed");
2128
+ props.push(prop);
2129
+ continue;
2130
+ }
2131
+ if (isBegin && !props.length) {
2132
+ const prop = this.readNonEmptyIdentifier();
2133
+ if (prop) {
2134
+ props.push(prop);
2135
+ continue;
2136
+ }
2137
+ }
2138
+ if (this.peek() === "." && this.peek(1) !== ".") {
2139
+ this.p++;
2140
+ const prop = this.readNonEmptyIdentifier();
2141
+ if (!prop) break;
2142
+ props.push(prop);
2143
+ continue;
2144
+ }
2145
+ break;
2146
+ }
2147
+ return props;
2148
+ }
2149
+ readNumber() {
2150
+ this.skipBlank();
2151
+ let decimalFound = false;
2152
+ let digitFound = false;
2153
+ let n = 0;
2154
+ if (this.peekType() & SIGN) n++;
2155
+ while (this.p + n <= this.N) if (this.peekType(n) & NUMBER) {
2156
+ digitFound = true;
2157
+ n++;
2158
+ } else if (this.peek(n) === "." && this.peek(n + 1) !== ".") {
2159
+ if (decimalFound || !digitFound) return;
2160
+ decimalFound = true;
2161
+ n++;
2162
+ } else break;
2163
+ if (digitFound && !isWord(this.peek(n))) {
2164
+ const num = new NumberToken(this.input, this.p, this.p + n, this.file);
2165
+ this.advance(n);
2166
+ return num;
2167
+ }
2168
+ }
2169
+ readLiteral() {
2170
+ this.skipBlank();
2171
+ const end = this.matchTrie(this.literalTrie);
2172
+ if (end === -1) return;
2173
+ const literal = new LiteralToken(this.input, this.p, end, this.file);
2174
+ this.p = end;
2175
+ return literal;
2176
+ }
2177
+ readGroupOrRange() {
2178
+ this.skipBlank();
2179
+ const begin = this.p;
2180
+ if (this.peek() !== "(") return;
2181
+ ++this.p;
2182
+ const lhs = this.readValueOrThrow();
2183
+ this.skipBlank();
2184
+ if (this.peek() === "." && this.peek(1) === ".") {
2185
+ this.p += 2;
2186
+ const rhs = this.readValueOrThrow();
2187
+ this.skipBlank();
2188
+ this.assert(this.read() === ")", "invalid range syntax");
2189
+ return new RangeToken(this.input, begin, this.p, lhs, rhs, this.file);
2190
+ }
2191
+ if (this.groupedExpressions) {
2192
+ const initial = new Expression([lhs, ...this.readExpressionTokens()]);
2193
+ this.assert(initial.valid(), () => `invalid value expression: ${this.snapshot()}`);
2194
+ const filters = this.readFilters();
2195
+ this.skipBlank();
2196
+ this.assert(this.read() === ")", "unbalanced parentheses");
2197
+ return new FilteredValueToken(initial, filters, this.input, begin, this.p, this.file);
2198
+ }
2199
+ throw this.error("invalid range syntax");
2200
+ }
2201
+ readValueOrThrow() {
2202
+ const value = this.readValue();
2203
+ this.assert(value, () => `unexpected token ${this.snapshot()}, value expected`);
2204
+ return value;
2205
+ }
2206
+ readQuoted() {
2207
+ this.skipBlank();
2208
+ const begin = this.p;
2209
+ if (!(this.peekType() & QUOTE)) return;
2210
+ ++this.p;
2211
+ let escaped = false;
2212
+ while (this.p < this.N) {
2213
+ ++this.p;
2214
+ if (this.input[this.p - 1] === this.input[begin] && !escaped) break;
2215
+ if (escaped) escaped = false;
2216
+ else if (this.input[this.p - 1] === "\\") escaped = true;
2217
+ }
2218
+ return new QuotedToken(this.input, begin, this.p, this.file);
2219
+ }
2220
+ *readFileNameTemplate(options) {
2221
+ const { outputDelimiterLeft } = options;
2222
+ const htmlStopStrings = [
2223
+ ",",
2224
+ " ",
2225
+ "\r",
2226
+ "\n",
2227
+ " ",
2228
+ outputDelimiterLeft
2229
+ ];
2230
+ const htmlStopStringSet = new Set(htmlStopStrings);
2231
+ while (this.p < this.N && !htmlStopStringSet.has(this.peek())) yield this.match(outputDelimiterLeft) ? this.readOutputToken(options) : this.readHTMLToken(htmlStopStrings);
2232
+ }
2233
+ match(word) {
2234
+ for (let i = 0; i < word.length; i++) if (word[i] !== this.input[this.p + i]) return false;
2235
+ return true;
2236
+ }
2237
+ rmatch(pattern) {
2238
+ for (let i = 0; i < pattern.length; i++) if (pattern[pattern.length - 1 - i] !== this.input[this.p - 1 - i]) return false;
2239
+ return true;
2240
+ }
2241
+ peekType(n = 0) {
2242
+ return this.p + n >= this.N ? 0 : TYPES[this.input.charCodeAt(this.p + n)];
2243
+ }
2244
+ peek(n = 0) {
2245
+ return this.p + n >= this.N ? "" : this.input[this.p + n];
2246
+ }
2247
+ skipBlank() {
2248
+ while (this.peekType() & BLANK) ++this.p;
2249
+ }
2250
+ };
2251
+ var ParseStream = class {
2252
+ constructor(tokens, parseToken) {
2253
+ this.handlers = {};
2254
+ this.stopRequested = false;
2255
+ this.tokens = tokens;
2256
+ this.parseToken = parseToken;
2257
+ }
2258
+ on(name, cb) {
2259
+ this.handlers[name] = cb;
2260
+ return this;
2261
+ }
2262
+ trigger(event, arg) {
2263
+ const h = this.handlers[event];
2264
+ return h ? (h.call(this, arg), true) : false;
2265
+ }
2266
+ start() {
2267
+ this.trigger("start");
2268
+ let token;
2269
+ while (!this.stopRequested && (token = this.tokens.shift())) {
2270
+ if (this.trigger("token", token)) continue;
2271
+ if (isTagToken(token) && this.trigger(`tag:${token.name}`, token)) continue;
2272
+ const template = this.parseToken(token, this.tokens);
2273
+ this.trigger("template", template);
2274
+ }
2275
+ if (!this.stopRequested) this.trigger("end");
2276
+ return this;
2277
+ }
2278
+ stop() {
2279
+ this.stopRequested = true;
2280
+ return this;
2281
+ }
2282
+ };
2283
+ var TemplateImpl = class {
2284
+ constructor(token) {
2285
+ this.token = token;
2286
+ }
2287
+ };
2288
+ var Tag = class extends TemplateImpl {
2289
+ constructor(token, remainTokens, liquid) {
2290
+ super(token);
2291
+ this.name = token.name;
2292
+ this.liquid = liquid;
2293
+ this.tokenizer = token.tokenizer;
2294
+ }
2295
+ };
2296
+ /**
2297
+ * Key-Value Pairs Representing Tag Arguments
2298
+ * Example:
2299
+ * For the markup `, foo:'bar', coo:2 reversed %}`,
2300
+ * hash['foo'] === 'bar'
2301
+ * hash['coo'] === 2
2302
+ * hash['reversed'] === undefined
2303
+ */
2304
+ var Hash = class {
2305
+ constructor(input, jekyllStyle) {
2306
+ this.hash = {};
2307
+ const tokenizer = input instanceof Tokenizer ? input : new Tokenizer(input, {});
2308
+ for (const hash of tokenizer.readHashes(jekyllStyle)) this.hash[hash.name.content] = hash.value;
2309
+ }
2310
+ *render(ctx) {
2311
+ const hash = {};
2312
+ for (const key of Object.keys(this.hash)) hash[key] = this.hash[key] === void 0 ? true : yield evalToken(this.hash[key], ctx);
2313
+ return hash;
2314
+ }
2315
+ };
2316
+ function createTagClass(options) {
2317
+ return class extends Tag {
2318
+ constructor(token, tokens, liquid) {
2319
+ super(token, tokens, liquid);
2320
+ if (isFunction(options.parse)) options.parse.call(this, token, tokens);
2321
+ }
2322
+ *render(ctx, emitter) {
2323
+ const hash = yield new Hash(this.token.args, ctx.opts.keyValueSeparator).render(ctx);
2324
+ return yield options.render.call(this, ctx, emitter, hash);
2325
+ }
2326
+ };
2327
+ }
2328
+ var Value = class {
2329
+ /**
2330
+ * @param str the value to be valuated, eg.: "foobar" | truncate: 3
2331
+ */
2332
+ constructor(input, liquid) {
2333
+ this.filters = [];
2334
+ const token = typeof input === "string" ? new Tokenizer(input, liquid.options.operators, void 0, void 0, liquid.options.groupedExpressions).readFilteredValue() : input;
2335
+ this.initial = token.initial;
2336
+ this.filters = token.filters.map((token) => new Filter(token, this.getFilter(liquid, token.name), liquid));
2337
+ }
2338
+ *value(ctx, lenient) {
2339
+ lenient = lenient || ctx.opts.lenientIf && this.filters.length > 0 && this.filters[0].name === "default";
2340
+ let val = yield this.initial.evaluate(ctx, lenient);
2341
+ for (const filter of this.filters) val = yield filter.render(val, ctx);
2342
+ return val;
2343
+ }
2344
+ getFilter(liquid, name) {
2345
+ const impl = liquid.filters[name];
2346
+ assert(impl || !liquid.options.strictFilters, () => `undefined filter: ${name}`);
2347
+ return impl;
2348
+ }
2349
+ };
2350
+ var Output = class extends TemplateImpl {
2351
+ constructor(token, liquid) {
2352
+ var _a;
2353
+ super(token);
2354
+ const tokenizer = new Tokenizer(token.input, liquid.options.operators, token.file, token.contentRange, liquid.options.groupedExpressions);
2355
+ this.value = new Value(tokenizer.readFilteredValue(), liquid);
2356
+ const filters = this.value.filters;
2357
+ const outputEscape = liquid.options.outputEscape;
2358
+ if (!((_a = filters[filters.length - 1]) === null || _a === void 0 ? void 0 : _a.raw) && outputEscape) {
2359
+ const token = new FilterToken(toString.call(outputEscape), [], "", 0, 0);
2360
+ filters.push(new Filter(token, outputEscape, liquid));
2361
+ }
2362
+ }
2363
+ *render(ctx, emitter) {
2364
+ const val = yield toValue(yield this.value.value(ctx, false));
2365
+ emitter.write(val);
2366
+ }
2367
+ *arguments() {
2368
+ yield this.value;
2369
+ }
2370
+ };
2371
+ var HTML = class extends TemplateImpl {
2372
+ constructor(token) {
2373
+ super(token);
2374
+ this.str = token.getContent();
2375
+ }
2376
+ *render(ctx, emitter) {
2377
+ emitter.write(this.str);
2378
+ }
2379
+ };
2380
+ /**
2381
+ * A variable's segments and location, which can be coerced to a string.
2382
+ */
2383
+ var Variable = class Variable {
2384
+ constructor(segments, location) {
2385
+ this.segments = segments;
2386
+ this.location = location;
2387
+ }
2388
+ toString() {
2389
+ return segmentsString(this.segments, true);
2390
+ }
2391
+ /** Return this variable's segments as an array, possibly with nested arrays for nested paths. */
2392
+ toArray() {
2393
+ function* _visit(...segments) {
2394
+ for (const segment of segments) if (segment instanceof Variable) yield Array.from(_visit(...segment.segments));
2395
+ else yield segment;
2396
+ }
2397
+ return Array.from(_visit(...this.segments));
2398
+ }
2399
+ };
2400
+ /**
2401
+ * Group variables by the string representation of their root segment.
2402
+ */
2403
+ var VariableMap = class {
2404
+ constructor() {
2405
+ this.map = /* @__PURE__ */ new Map();
2406
+ }
2407
+ get(key) {
2408
+ const k = segmentsString([key.segments[0]]);
2409
+ if (!this.map.has(k)) this.map.set(k, []);
2410
+ return this.map.get(k);
2411
+ }
2412
+ has(key) {
2413
+ return this.map.has(segmentsString([key.segments[0]]));
2414
+ }
2415
+ push(variable) {
2416
+ this.get(variable).push(variable);
2417
+ }
2418
+ asObject() {
2419
+ return Object.fromEntries(this.map);
2420
+ }
2421
+ };
2422
+ const defaultStaticAnalysisOptions = { partials: true };
2423
+ function* _analyze(templates, partials, sync) {
2424
+ const variables = new VariableMap();
2425
+ const globals = new VariableMap();
2426
+ const locals = new VariableMap();
2427
+ const rootScope = new DummyScope(/* @__PURE__ */ new Set());
2428
+ const seen = /* @__PURE__ */ new Set();
2429
+ function updateVariables(variable, scope) {
2430
+ variables.push(variable);
2431
+ const aliased = scope.alias(variable);
2432
+ if (aliased !== void 0) {
2433
+ const root = aliased.segments[0];
2434
+ if (isString(root) && !rootScope.has(root)) globals.push(aliased);
2435
+ } else {
2436
+ const root = variable.segments[0];
2437
+ if (isString(root) && !scope.has(root)) globals.push(variable);
2438
+ }
2439
+ for (const segment of variable.segments) if (segment instanceof Variable) updateVariables(segment, scope);
2440
+ }
2441
+ function* visit(template, scope) {
2442
+ if (template.arguments) for (const arg of template.arguments()) for (const variable of extractVariables(arg)) updateVariables(variable, scope);
2443
+ if (template.localScope) for (const ident of template.localScope()) {
2444
+ scope.add(ident.content);
2445
+ scope.deleteAlias(ident.content);
2446
+ const [row, col] = ident.getPosition();
2447
+ locals.push(new Variable([ident.content], {
2448
+ row,
2449
+ col,
2450
+ file: ident.file
2451
+ }));
2452
+ }
2453
+ if (template.children) {
2454
+ if (template.partialScope) {
2455
+ const partial = template.partialScope();
2456
+ if (partial === void 0) {
2457
+ for (const child of yield template.children(partials, sync)) yield visit(child, scope);
2458
+ return;
2459
+ }
2460
+ if (seen.has(partial.name)) return;
2461
+ const partialScopeNames = /* @__PURE__ */ new Set();
2462
+ const partialScope = partial.isolated ? new DummyScope(partialScopeNames) : scope.push(partialScopeNames);
2463
+ for (const name of partial.scope) if (isString(name)) partialScopeNames.add(name);
2464
+ else {
2465
+ const [alias, argument] = name;
2466
+ partialScopeNames.add(alias);
2467
+ const variables = Array.from(extractVariables(argument));
2468
+ if (variables.length) partialScope.setAlias(alias, variables[0].segments);
2469
+ }
2470
+ for (const child of yield template.children(partials, sync)) {
2471
+ yield visit(child, partialScope);
2472
+ seen.add(partial.name);
2473
+ }
2474
+ partialScope.pop();
2475
+ } else {
2476
+ if (template.blockScope) scope.push(new Set(template.blockScope()));
2477
+ for (const child of yield template.children(partials, sync)) yield visit(child, scope);
2478
+ if (template.blockScope) scope.pop();
2479
+ }
2480
+ }
2481
+ }
2482
+ for (const template of templates) yield visit(template, rootScope);
2483
+ return {
2484
+ variables: variables.asObject(),
2485
+ globals: globals.asObject(),
2486
+ locals: locals.asObject()
2487
+ };
2488
+ }
2489
+ /**
2490
+ * Statically analyze a template and report variable usage.
2491
+ */
2492
+ function analyze(template, options = {}) {
2493
+ return toPromise(_analyze(template, Object.assign(Object.assign({}, defaultStaticAnalysisOptions), options).partials, false));
2494
+ }
2495
+ /**
2496
+ * Statically analyze a template and report variable usage.
2497
+ */
2498
+ function analyzeSync(template, options = {}) {
2499
+ return toValueSync(_analyze(template, Object.assign(Object.assign({}, defaultStaticAnalysisOptions), options).partials, true));
2500
+ }
2501
+ /**
2502
+ * A stack to manage scopes while traversing templates during static analysis.
2503
+ */
2504
+ var DummyScope = class {
2505
+ constructor(globals) {
2506
+ this.stack = [{
2507
+ names: globals,
2508
+ aliases: /* @__PURE__ */ new Map()
2509
+ }];
2510
+ }
2511
+ /** Return true if `name` is in scope. */
2512
+ has(name) {
2513
+ for (const scope of this.stack) if (scope.names.has(name)) return true;
2514
+ return false;
2515
+ }
2516
+ push(scope) {
2517
+ this.stack.push({
2518
+ names: scope,
2519
+ aliases: /* @__PURE__ */ new Map()
2520
+ });
2521
+ return this;
2522
+ }
2523
+ pop() {
2524
+ var _a;
2525
+ return (_a = this.stack.pop()) === null || _a === void 0 ? void 0 : _a.names;
2526
+ }
2527
+ add(name) {
2528
+ this.stack[0].names.add(name);
2529
+ }
2530
+ /** Return the variable that `variable` aliases, or `variable` if it doesn't alias anything. */
2531
+ alias(variable) {
2532
+ const root = variable.segments[0];
2533
+ if (!isString(root)) return void 0;
2534
+ const alias = this.getAlias(root);
2535
+ if (alias === void 0) return void 0;
2536
+ return new Variable([...alias, ...variable.segments.slice(1)], variable.location);
2537
+ }
2538
+ setAlias(from, to) {
2539
+ this.stack[this.stack.length - 1].aliases.set(from, to);
2540
+ }
2541
+ deleteAlias(name) {
2542
+ this.stack[this.stack.length - 1].aliases.delete(name);
2543
+ }
2544
+ getAlias(name) {
2545
+ for (const scope of this.stack) {
2546
+ if (scope.aliases.has(name)) return scope.aliases.get(name);
2547
+ if (scope.names.has(name)) return;
2548
+ }
2549
+ }
2550
+ };
2551
+ function* extractVariables(value) {
2552
+ if (isValueToken(value)) yield* extractValueTokenVariables(value);
2553
+ else if (value instanceof Value) yield* extractFilteredValueVariables(value);
2554
+ }
2555
+ function* extractFilteredValueVariables(value) {
2556
+ for (const token of value.initial.postfix) if (isValueToken(token)) yield* extractValueTokenVariables(token);
2557
+ for (const filter of value.filters) for (const arg of filter.args) if (isKeyValuePair(arg) && arg[1]) yield* extractValueTokenVariables(arg[1]);
2558
+ else if (isValueToken(arg)) yield* extractValueTokenVariables(arg);
2559
+ }
2560
+ function* extractValueTokenVariables(token) {
2561
+ if (isRangeToken(token)) {
2562
+ yield* extractValueTokenVariables(token.lhs);
2563
+ yield* extractValueTokenVariables(token.rhs);
2564
+ } else if (isFilteredValueToken(token)) yield* extractGroupedExpressionTokenVariables(token);
2565
+ else if (isPropertyAccessToken(token)) yield extractPropertyAccessVariable(token);
2566
+ }
2567
+ function* extractGroupedExpressionTokenVariables(token) {
2568
+ if (!isFilteredValueToken(token)) return;
2569
+ for (const t of token.initial.postfix) if (isValueToken(t)) yield* extractValueTokenVariables(t);
2570
+ for (const filter of token.filters) for (const arg of filter.args) if (isKeyValuePair(arg) && arg[1]) yield* extractValueTokenVariables(arg[1]);
2571
+ else if (isValueToken(arg)) yield* extractValueTokenVariables(arg);
2572
+ }
2573
+ function extractPropertyAccessVariable(token) {
2574
+ const segments = [];
2575
+ let file = token.file;
2576
+ const root = token.props[0];
2577
+ file = file || root.file;
2578
+ if (isQuotedToken(root) || isNumberToken(root) || isWordToken(root)) segments.push(root.content);
2579
+ else if (isPropertyAccessToken(root)) segments.push(...extractPropertyAccessVariable(root).segments);
2580
+ for (const prop of token.props.slice(1)) {
2581
+ file = file || prop.file;
2582
+ if (isQuotedToken(prop) || isNumberToken(prop) || isWordToken(prop)) segments.push(prop.content);
2583
+ else if (isPropertyAccessToken(prop)) segments.push(extractPropertyAccessVariable(prop));
2584
+ }
2585
+ const [row, col] = token.getPosition();
2586
+ return new Variable(segments, {
2587
+ row,
2588
+ col,
2589
+ file
2590
+ });
2591
+ }
2592
+ const RE_PROPERTY = /^[\u0080-\uFFFFa-zA-Z_][\u0080-\uFFFFa-zA-Z0-9_-]*$/;
2593
+ /**
2594
+ * Return a string representation of segments using dot notation where possible.
2595
+ * @param segments - The property names and array indices that make up a path to a variable.
2596
+ * @param bracketedRoot - If false (the default), don't surround the root segment with square brackets.
2597
+ */
2598
+ function segmentsString(segments, bracketedRoot = false) {
2599
+ const buf = [];
2600
+ const root = segments[0];
2601
+ if (isString(root)) {
2602
+ if (!bracketedRoot || root.match(RE_PROPERTY)) buf.push(`${root}`);
2603
+ else buf.push(`['${root}']`);
2604
+ }
2605
+ for (const segment of segments.slice(1)) if (segment instanceof Variable) buf.push(`[${segmentsString(segment.segments)}]`);
2606
+ else if (isString(segment)) {
2607
+ if (segment.match(RE_PROPERTY)) buf.push(`.${segment}`);
2608
+ else buf.push(`['${segment}']`);
2609
+ } else buf.push(`[${segment}]`);
2610
+ return buf.join("");
2611
+ }
2612
+ var LookupType;
2613
+ (function(LookupType) {
2614
+ LookupType["Partials"] = "partials";
2615
+ LookupType["Layouts"] = "layouts";
2616
+ LookupType["Root"] = "root";
2617
+ })(LookupType || (LookupType = {}));
2618
+ var Loader = class {
2619
+ constructor(options) {
2620
+ var _a, _b, _c, _d;
2621
+ this.options = options;
2622
+ if (options.relativeReference) {
2623
+ const sep = options.fs.sep;
2624
+ assert(sep, "`fs.sep` is required for relative reference");
2625
+ const prefixes = [
2626
+ "." + sep,
2627
+ ".." + sep,
2628
+ "./",
2629
+ "../"
2630
+ ];
2631
+ this.shouldLoadRelative = (referencedFile) => prefixes.some((prefix) => referencedFile.startsWith(prefix));
2632
+ } else this.shouldLoadRelative = (_referencedFile) => false;
2633
+ const fs = options.fs;
2634
+ this.contains = toLiquidAsync(((_a = fs.contains) === null || _a === void 0 ? void 0 : _a.bind(fs)) || (() => __awaiter(this, void 0, void 0, function* () {
2635
+ return true;
2636
+ })), ((_b = fs.containsSync) === null || _b === void 0 ? void 0 : _b.bind(fs)) || (() => true));
2637
+ this.exists = toLiquidAsync(((_c = fs.exists) === null || _c === void 0 ? void 0 : _c.bind(fs)) || (() => __awaiter(this, void 0, void 0, function* () {
2638
+ return false;
2639
+ })), (_d = fs.existsSync) === null || _d === void 0 ? void 0 : _d.bind(fs));
2640
+ }
2641
+ *lookup(file, type, sync, currentFile) {
2642
+ const dirs = this.options[type];
2643
+ for (const filepath of this.candidates(file, dirs, currentFile)) {
2644
+ let allowed = false;
2645
+ for (const dir of dirs) if (yield this.contains(!!sync, dir, filepath)) {
2646
+ allowed = true;
2647
+ break;
2648
+ }
2649
+ if (!allowed) continue;
2650
+ if (yield this.exists(!!sync, filepath)) return filepath;
2651
+ }
2652
+ throw this.lookupError(file, dirs);
2653
+ }
2654
+ *candidates(file, dirs, currentFile) {
2655
+ const { fs, extname } = this.options;
2656
+ if (this.shouldLoadRelative(file) && currentFile) yield fs.resolve(this.dirname(currentFile), file, extname);
2657
+ for (const dir of dirs) yield fs.resolve(dir, file, extname);
2658
+ if (fs.fallback !== void 0) {
2659
+ const filepath = fs.fallback(file);
2660
+ if (filepath !== void 0) yield filepath;
2661
+ }
2662
+ }
2663
+ dirname(path) {
2664
+ const fs = this.options.fs;
2665
+ assert(fs.dirname, "`fs.dirname` is required for relative reference");
2666
+ return fs.dirname(path);
2667
+ }
2668
+ lookupError(file, roots) {
2669
+ const err = /* @__PURE__ */ new Error("ENOENT");
2670
+ err.message = `ENOENT: Failed to lookup "${file}" in "${roots}"`;
2671
+ err.code = "ENOENT";
2672
+ return err;
2673
+ }
2674
+ };
2675
+ var Parser = class {
2676
+ constructor(liquid) {
2677
+ var _a, _b;
2678
+ this.liquid = liquid;
2679
+ this.cache = this.liquid.options.cache;
2680
+ this.fs = this.liquid.options.fs;
2681
+ this.parseFile = this.cache ? this._parseFileCached : this._parseFile;
2682
+ this.loader = new Loader(this.liquid.options);
2683
+ this.parseLimit = new Limiter("parse length", liquid.options.parseLimit);
2684
+ this.readFile = toLiquidAsync(((_a = this.fs.readFile) === null || _a === void 0 ? void 0 : _a.bind(this.fs)) || (() => __awaiter(this, void 0, void 0, function* () {
2685
+ throw new Error("readFile not implemented");
2686
+ })), (_b = this.fs.readFileSync) === null || _b === void 0 ? void 0 : _b.bind(this.fs));
2687
+ }
2688
+ parse(html, filepath) {
2689
+ html = String(html);
2690
+ this.parseLimit.use(html.length);
2691
+ const tokens = new Tokenizer(html, this.liquid.options.operators, filepath, void 0, this.liquid.options.groupedExpressions).readTopLevelTokens(this.liquid.options);
2692
+ return this.parseTokens(tokens);
2693
+ }
2694
+ parseTokens(tokens) {
2695
+ let token;
2696
+ const templates = [];
2697
+ const errors = [];
2698
+ while (token = tokens.shift()) try {
2699
+ templates.push(this.parseToken(token, tokens));
2700
+ } catch (err) {
2701
+ if (this.liquid.options.catchAllErrors) errors.push(err);
2702
+ else throw err;
2703
+ }
2704
+ if (errors.length) throw new LiquidErrors(errors);
2705
+ return templates;
2706
+ }
2707
+ parseToken(token, remainTokens) {
2708
+ try {
2709
+ if (isTagToken(token)) {
2710
+ const TagClass = this.liquid.tags[token.name];
2711
+ assert(TagClass, `tag "${token.name}" not found`);
2712
+ return new TagClass(token, remainTokens, this.liquid, this);
2713
+ }
2714
+ if (isOutputToken(token)) return new Output(token, this.liquid);
2715
+ return new HTML(token);
2716
+ } catch (e) {
2717
+ if (LiquidError.is(e)) throw e;
2718
+ throw new ParseError(e, token);
2719
+ }
2720
+ }
2721
+ parseStream(tokens) {
2722
+ return new ParseStream(tokens, (token, tokens) => this.parseToken(token, tokens));
2723
+ }
2724
+ *_parseFileCached(file, sync, type = LookupType.Root, currentFile) {
2725
+ const cache = this.cache;
2726
+ const key = this.loader.shouldLoadRelative(file) ? currentFile + "," + file : type + ":" + file;
2727
+ const tpls = yield cache.read(key);
2728
+ if (tpls) return tpls;
2729
+ const task = this._parseFile(file, sync, type, currentFile);
2730
+ const taskOrTpl = sync ? yield task : toPromise(task);
2731
+ cache.write(key, taskOrTpl);
2732
+ try {
2733
+ return yield taskOrTpl;
2734
+ } catch (err) {
2735
+ cache.remove(key);
2736
+ throw err;
2737
+ }
2738
+ }
2739
+ *_parseFile(file, sync, type = LookupType.Root, currentFile) {
2740
+ const filepath = yield this.loader.lookup(file, type, sync, currentFile);
2741
+ return this.parse(yield this.readFile(!!sync, filepath), filepath);
2742
+ }
2743
+ };
2744
+ var TokenKind;
2745
+ (function(TokenKind) {
2746
+ TokenKind[TokenKind["Number"] = 1] = "Number";
2747
+ TokenKind[TokenKind["Literal"] = 2] = "Literal";
2748
+ TokenKind[TokenKind["Tag"] = 4] = "Tag";
2749
+ TokenKind[TokenKind["Output"] = 8] = "Output";
2750
+ TokenKind[TokenKind["HTML"] = 16] = "HTML";
2751
+ TokenKind[TokenKind["Filter"] = 32] = "Filter";
2752
+ TokenKind[TokenKind["Hash"] = 64] = "Hash";
2753
+ TokenKind[TokenKind["PropertyAccess"] = 128] = "PropertyAccess";
2754
+ TokenKind[TokenKind["Word"] = 256] = "Word";
2755
+ TokenKind[TokenKind["Range"] = 512] = "Range";
2756
+ TokenKind[TokenKind["Quoted"] = 1024] = "Quoted";
2757
+ TokenKind[TokenKind["Operator"] = 2048] = "Operator";
2758
+ TokenKind[TokenKind["FilteredValue"] = 4096] = "FilteredValue";
2759
+ TokenKind[TokenKind["GroupedExpression"] = 8192] = "GroupedExpression";
2760
+ TokenKind[TokenKind["Delimited"] = 12] = "Delimited";
2761
+ })(TokenKind || (TokenKind = {}));
2762
+ function isDelimitedToken(val) {
2763
+ return !!(getKind(val) & TokenKind.Delimited);
2764
+ }
2765
+ function isOperatorToken(val) {
2766
+ return getKind(val) === TokenKind.Operator;
2767
+ }
2768
+ function isHTMLToken(val) {
2769
+ return getKind(val) === TokenKind.HTML;
2770
+ }
2771
+ function isOutputToken(val) {
2772
+ return getKind(val) === TokenKind.Output;
2773
+ }
2774
+ function isTagToken(val) {
2775
+ return getKind(val) === TokenKind.Tag;
2776
+ }
2777
+ function isQuotedToken(val) {
2778
+ return getKind(val) === TokenKind.Quoted;
2779
+ }
2780
+ function isNumberToken(val) {
2781
+ return getKind(val) === TokenKind.Number;
2782
+ }
2783
+ function isPropertyAccessToken(val) {
2784
+ return getKind(val) === TokenKind.PropertyAccess;
2785
+ }
2786
+ function isWordToken(val) {
2787
+ return getKind(val) === TokenKind.Word;
2788
+ }
2789
+ function isRangeToken(val) {
2790
+ return getKind(val) === TokenKind.Range;
2791
+ }
2792
+ function isFilteredValueToken(val) {
2793
+ return getKind(val) === TokenKind.FilteredValue;
2794
+ }
2795
+ function isValueToken(val) {
2796
+ return (getKind(val) & 5763) > 0;
2797
+ }
2798
+ function getKind(val) {
2799
+ return val ? val.kind : -1;
2800
+ }
2801
+ function createScope(from) {
2802
+ const scope = Object.create(null);
2803
+ if (from) Object.assign(scope, from);
2804
+ return scope;
2805
+ }
2806
+ var Context = class Context {
2807
+ constructor(env = {}, opts = defaultOptions, renderOptions = {}, { memoryLimit, renderLimit, liquid } = {}) {
2808
+ var _a, _b, _c, _d, _e;
2809
+ /**
2810
+ * insert a Context-level empty scope,
2811
+ * for tags like `{% capture %}` `{% assign %}` to operate
2812
+ */
2813
+ this.scopes = [createScope()];
2814
+ this.registers = {};
2815
+ this.breakCalled = false;
2816
+ this.continueCalled = false;
2817
+ this.sync = !!renderOptions.sync;
2818
+ this.opts = opts;
2819
+ this.globals = (_a = renderOptions.globals) !== null && _a !== void 0 ? _a : opts.globals;
2820
+ this.environments = isObject(env) ? env : Object(env);
2821
+ this.strictVariables = (_b = renderOptions.strictVariables) !== null && _b !== void 0 ? _b : this.opts.strictVariables;
2822
+ this.ownPropertyOnly = (_c = renderOptions.ownPropertyOnly) !== null && _c !== void 0 ? _c : opts.ownPropertyOnly;
2823
+ this.memoryLimit = memoryLimit !== null && memoryLimit !== void 0 ? memoryLimit : new Limiter("memory alloc", (_d = renderOptions.memoryLimit) !== null && _d !== void 0 ? _d : opts.memoryLimit);
2824
+ this.renderLimit = renderLimit !== null && renderLimit !== void 0 ? renderLimit : new Limiter("template render", getPerformance().now() + ((_e = renderOptions.renderLimit) !== null && _e !== void 0 ? _e : opts.renderLimit));
2825
+ this.liquid = liquid;
2826
+ }
2827
+ getRegister(key, defaultValue = void 0) {
2828
+ return this.registers[key] = this.registers[key] || defaultValue;
2829
+ }
2830
+ setRegister(key, value) {
2831
+ return this.registers[key] = value;
2832
+ }
2833
+ saveRegister(...keys) {
2834
+ return keys.map((key) => [key, this.getRegister(key)]);
2835
+ }
2836
+ restoreRegister(keyValues) {
2837
+ return keyValues.forEach(([key, value]) => this.setRegister(key, value));
2838
+ }
2839
+ getAll() {
2840
+ return [
2841
+ this.globals,
2842
+ this.environments,
2843
+ ...this.scopes
2844
+ ].reduce((ctx, val) => __assign(ctx, val), {});
2845
+ }
2846
+ /**
2847
+ * @deprecated use `_get()` or `getSync()` instead
2848
+ */
2849
+ get(paths) {
2850
+ return this.getSync(paths);
2851
+ }
2852
+ getSync(paths) {
2853
+ return toValueSync(this._get(paths));
2854
+ }
2855
+ *_get(paths) {
2856
+ const scope = this.findScope(paths[0]);
2857
+ return yield this._getFromScope(scope, paths);
2858
+ }
2859
+ /**
2860
+ * @deprecated use `_get()` instead
2861
+ */
2862
+ getFromScope(scope, paths) {
2863
+ return toValueSync(this._getFromScope(scope, paths));
2864
+ }
2865
+ *_getFromScope(scope, paths, strictVariables = this.strictVariables) {
2866
+ if (isString(paths)) paths = paths.split(".");
2867
+ for (let i = 0; i < paths.length; i++) {
2868
+ scope = yield this.readProperty(scope, paths[i]);
2869
+ if (strictVariables && isUndefined(scope)) throw new InternalUndefinedVariableError(paths.slice(0, i + 1).join("."));
2870
+ }
2871
+ return scope;
2872
+ }
2873
+ push(ctx) {
2874
+ return this.scopes.push(ctx);
2875
+ }
2876
+ pop() {
2877
+ return this.scopes.pop();
2878
+ }
2879
+ bottom() {
2880
+ return this.scopes[0];
2881
+ }
2882
+ spawn(scope = {}) {
2883
+ return new Context(scope, this.opts, {
2884
+ sync: this.sync,
2885
+ globals: this.globals,
2886
+ strictVariables: this.strictVariables,
2887
+ ownPropertyOnly: this.ownPropertyOnly
2888
+ }, {
2889
+ renderLimit: this.renderLimit,
2890
+ memoryLimit: this.memoryLimit,
2891
+ liquid: this.liquid
2892
+ });
2893
+ }
2894
+ findScope(key) {
2895
+ for (let i = this.scopes.length - 1; i >= 0; i--) {
2896
+ const candidate = this.scopes[i];
2897
+ if (key in candidate) return candidate;
2898
+ }
2899
+ if (key in this.environments) return this.environments;
2900
+ return this.globals;
2901
+ }
2902
+ readProperty(obj, key) {
2903
+ obj = toLiquid(obj);
2904
+ key = toValue(key);
2905
+ if (isNil(obj)) return obj;
2906
+ if (isArray(obj) && isNumber(key)) return readArrayElement(obj, key, this.ownPropertyOnly);
2907
+ const value = readJSProperty(obj, key, this.ownPropertyOnly);
2908
+ if (value === void 0 && obj instanceof Drop) return obj.liquidMethodMissing(key, this);
2909
+ if (isFunction(value)) return value.call(obj);
2910
+ if (key === "size") return readSize(obj);
2911
+ else if (key === "first") return readFirst(obj, this.ownPropertyOnly);
2912
+ else if (key === "last") return readLast(obj, this.ownPropertyOnly);
2913
+ return value;
2914
+ }
2915
+ };
2916
+ function readJSProperty(obj, key, ownPropertyOnly) {
2917
+ if (ownPropertyOnly && !hasOwnProperty.call(obj, key) && !(obj instanceof Drop)) return void 0;
2918
+ return obj[key];
2919
+ }
2920
+ function readFirst(obj, ownPropertyOnly) {
2921
+ if (isArray(obj)) return readArrayElement(obj, 0, ownPropertyOnly);
2922
+ return readJSProperty(obj, "first", ownPropertyOnly);
2923
+ }
2924
+ function readLast(obj, ownPropertyOnly) {
2925
+ if (isArray(obj)) return readArrayElement(obj, -1, ownPropertyOnly);
2926
+ return readJSProperty(obj, "last", ownPropertyOnly);
2927
+ }
2928
+ function readSize(obj) {
2929
+ if (hasOwnProperty.call(obj, "size") || obj["size"] !== void 0) return obj["size"];
2930
+ if (isArray(obj) || isString(obj)) return obj.length;
2931
+ if (typeof obj === "object") return Object.keys(obj).length;
2932
+ }
2933
+ var BlockMode;
2934
+ (function(BlockMode) {
2935
+ BlockMode[BlockMode["OUTPUT"] = 0] = "OUTPUT";
2936
+ BlockMode[BlockMode["STORE"] = 1] = "STORE";
2937
+ })(BlockMode || (BlockMode = {}));
2938
+ const abs = argumentsToNumber(Math.abs);
2939
+ const at_least = argumentsToNumber(Math.max);
2940
+ const at_most = argumentsToNumber(Math.min);
2941
+ const ceil = argumentsToNumber(Math.ceil);
2942
+ const divided_by = argumentsToNumber((dividend, divisor, integerArithmetic = false) => integerArithmetic ? Math.floor(dividend / divisor) : dividend / divisor);
2943
+ const floor = argumentsToNumber(Math.floor);
2944
+ const minus = argumentsToNumber((v, arg) => v - arg);
2945
+ const plus = argumentsToNumber((lhs, rhs) => lhs + rhs);
2946
+ const modulo = argumentsToNumber((v, arg) => (v % arg + arg) % arg);
2947
+ const times = argumentsToNumber((v, arg) => v * arg);
2948
+ function round(v, arg = 0) {
2949
+ v = toNumber(v);
2950
+ arg = toNumber(arg);
2951
+ const amp = Math.pow(10, arg);
2952
+ const scaled = v * amp * (1 + Number.EPSILON);
2953
+ return Math.round(scaled) / amp;
2954
+ }
2955
+ var mathFilters = /*#__PURE__*/ Object.freeze({
2956
+ __proto__: null,
2957
+ abs,
2958
+ at_least,
2959
+ at_most,
2960
+ ceil,
2961
+ divided_by,
2962
+ floor,
2963
+ minus,
2964
+ plus,
2965
+ modulo,
2966
+ times,
2967
+ round
2968
+ });
2969
+ const url_decode = (x) => decodeURIComponent(stringify(x).replace(/\+/g, " "));
2970
+ const url_encode = (x) => encodeURIComponent(stringify(x)).replace(/%20/g, "+");
2971
+ const cgi_escape = (x) => encodeURIComponent(stringify(x)).replace(/%20/g, "+").replace(/[!'()*]/g, (c) => "%" + c.charCodeAt(0).toString(16).toUpperCase());
2972
+ const uri_escape = (x) => encodeURI(stringify(x)).replace(/%5B/g, "[").replace(/%5D/g, "]");
2973
+ const rSlugifyDefault = /[^\p{M}\p{L}\p{Nd}]+/gu;
2974
+ const rSlugifyReplacers = {
2975
+ "raw": /\s+/g,
2976
+ "default": rSlugifyDefault,
2977
+ "pretty": /[^\p{M}\p{L}\p{Nd}._~!$&'()+,;=@]+/gu,
2978
+ "ascii": /[^A-Za-z0-9]+/g,
2979
+ "latin": rSlugifyDefault,
2980
+ "none": null
2981
+ };
2982
+ function slugify(str, mode = "default", cased = false) {
2983
+ str = stringify(str);
2984
+ const replacer = rSlugifyReplacers[mode];
2985
+ if (replacer) {
2986
+ if (mode === "latin") str = removeAccents(str);
2987
+ str = str.replace(replacer, "-").replace(/^-|-$/g, "");
2988
+ }
2989
+ return cased ? str : str.toLowerCase();
2990
+ }
2991
+ function removeAccents(str) {
2992
+ return str.replace(/[àáâãäå]/g, "a").replace(/[æ]/g, "ae").replace(/[ç]/g, "c").replace(/[èéêë]/g, "e").replace(/[ìíîï]/g, "i").replace(/[ð]/g, "d").replace(/[ñ]/g, "n").replace(/[òóôõöø]/g, "o").replace(/[ùúûü]/g, "u").replace(/[ýÿ]/g, "y").replace(/[ß]/g, "ss").replace(/[œ]/g, "oe").replace(/[þ]/g, "th").replace(/[ẞ]/g, "SS").replace(/[Œ]/g, "OE").replace(/[Þ]/g, "TH");
2993
+ }
2994
+ var urlFilters = /*#__PURE__*/ Object.freeze({
2995
+ __proto__: null,
2996
+ url_decode,
2997
+ url_encode,
2998
+ cgi_escape,
2999
+ uri_escape,
3000
+ slugify
3001
+ });
3002
+ const join = argumentsToValue(function(v, arg) {
3003
+ const array = toArray(v);
3004
+ const sep = isNil(arg) ? " " : stringify(arg);
3005
+ let outputSize = sep.length * Math.max(array.length - 1, 0);
3006
+ for (let i = 0; i < array.length; i++) outputSize += String(array[i]).length;
3007
+ this.context.memoryLimit.use(outputSize);
3008
+ return Array.prototype.join.call(array, sep);
3009
+ });
3010
+ const last$1 = argumentsToValue(function(v) {
3011
+ return isArrayLike(v) ? readArrayElement(v, -1, this.context.ownPropertyOnly) : "";
3012
+ });
3013
+ const first = argumentsToValue(function(v) {
3014
+ return isArrayLike(v) ? readArrayElement(v, 0, this.context.ownPropertyOnly) : "";
3015
+ });
3016
+ const reverse = argumentsToValue(function(v) {
3017
+ const array = toArray(v);
3018
+ this.context.memoryLimit.use(array.length);
3019
+ return [...array].reverse();
3020
+ });
3021
+ function* sortBy(arr, property, comparator) {
3022
+ const values = [];
3023
+ const array = toArray(arr);
3024
+ this.context.memoryLimit.use(array.length);
3025
+ for (const item of array) values.push([item, property ? yield this.context._getFromScope(item, stringify(property).split("."), false) : item]);
3026
+ return values.sort((lhs, rhs) => comparator(lhs[1], rhs[1])).map((tuple) => tuple[0]);
3027
+ }
3028
+ function* sort(arr, property) {
3029
+ return yield* sortBy.call(this, arr, property, orderedCompare);
3030
+ }
3031
+ function* sort_natural(arr, property) {
3032
+ return yield* sortBy.call(this, arr, property, caseInsensitiveCompare);
3033
+ }
3034
+ const size = (v) => v && v.length || 0;
3035
+ function* map(arr, property) {
3036
+ const results = [];
3037
+ const array = toArray(arr);
3038
+ this.context.memoryLimit.use(array.length);
3039
+ for (const item of array) results.push(yield this.context._getFromScope(item, stringify(property), false));
3040
+ return results;
3041
+ }
3042
+ function* sum(arr, property) {
3043
+ let sum = 0;
3044
+ const array = toArray(arr);
3045
+ for (const item of array) {
3046
+ const data = Number(property ? yield this.context._getFromScope(item, stringify(property), false) : item);
3047
+ sum += Number.isNaN(data) ? 0 : data;
3048
+ }
3049
+ return sum;
3050
+ }
3051
+ function compact(arr) {
3052
+ const array = toArray(arr);
3053
+ this.context.memoryLimit.use(array.length);
3054
+ return Array.prototype.filter.call(array, (x) => !isNil(toValue(x)));
3055
+ }
3056
+ function concat(v, arg = []) {
3057
+ const lhs = toArray(v);
3058
+ const rhs = toArray(arg);
3059
+ this.context.memoryLimit.use(lhs.length + rhs.length);
3060
+ return Array.prototype.concat.call(lhs, rhs);
3061
+ }
3062
+ function push(v, arg) {
3063
+ return concat.call(this, v, [arg]);
3064
+ }
3065
+ function unshift(v, arg) {
3066
+ const array = toArray(v);
3067
+ this.context.memoryLimit.use(array.length);
3068
+ const clone = [...array];
3069
+ clone.unshift(arg);
3070
+ return clone;
3071
+ }
3072
+ function pop(v) {
3073
+ const array = toArray(v);
3074
+ this.context.memoryLimit.use(array.length);
3075
+ const clone = [...array];
3076
+ clone.pop();
3077
+ return clone;
3078
+ }
3079
+ function shift(v) {
3080
+ const array = toArray(v);
3081
+ this.context.memoryLimit.use(array.length);
3082
+ const clone = [...array];
3083
+ clone.shift();
3084
+ return clone;
3085
+ }
3086
+ function slice(v, begin, length = 1) {
3087
+ v = toValue(v);
3088
+ if (isNil(v)) return [];
3089
+ if (!isArray(v)) v = stringify(v);
3090
+ begin = begin < 0 ? v.length + begin : begin;
3091
+ if (begin < 0 || length < 0) return isArray(v) ? [] : "";
3092
+ this.context.memoryLimit.use(length);
3093
+ return isArray(v) ? Array.prototype.slice.call(v, begin, begin + length) : String.prototype.slice.call(v, begin, begin + length);
3094
+ }
3095
+ function* matches(value, expected) {
3096
+ if (this.context.opts.jekyllWhere) {
3097
+ if (EmptyDrop.is(expected)) return yield equals(value, expected);
3098
+ if (isArray(value)) return yield arrayIncludes(value, expected);
3099
+ return yield equals(value, expected);
3100
+ }
3101
+ if (expected === void 0) return isTruthy(value, this.context);
3102
+ return yield equals(value, expected);
3103
+ }
3104
+ function* filter(include, arr, property, expected) {
3105
+ arr = toArray(arr);
3106
+ this.context.memoryLimit.use(arr.length);
3107
+ const token = new Tokenizer(stringify(property)).readScopeValue();
3108
+ const result = [];
3109
+ for (const item of arr) {
3110
+ const value = yield evalToken(token, this.context.spawn(item));
3111
+ if ((yield matches.call(this, value, expected)) === include) result.push(item);
3112
+ }
3113
+ return result;
3114
+ }
3115
+ function* filter_exp(include, arr, itemName, exp) {
3116
+ const filtered = [];
3117
+ const keyTemplate = new Value(stringify(exp), this.liquid);
3118
+ const array = toArray(arr);
3119
+ this.context.memoryLimit.use(array.length);
3120
+ for (const item of array) {
3121
+ this.context.push({ [itemName]: item });
3122
+ const value = yield keyTemplate.value(this.context);
3123
+ this.context.pop();
3124
+ if (value === include) filtered.push(item);
3125
+ }
3126
+ return filtered;
3127
+ }
3128
+ function* where(arr, property, expected) {
3129
+ return yield* filter.call(this, true, arr, property, expected);
3130
+ }
3131
+ function* reject(arr, property, expected) {
3132
+ return yield* filter.call(this, false, arr, property, expected);
3133
+ }
3134
+ function* where_exp(arr, itemName, exp) {
3135
+ return yield* filter_exp.call(this, true, arr, itemName, exp);
3136
+ }
3137
+ function* reject_exp(arr, itemName, exp) {
3138
+ return yield* filter_exp.call(this, false, arr, itemName, exp);
3139
+ }
3140
+ function* group_by(arr, property) {
3141
+ const map = /* @__PURE__ */ new Map();
3142
+ arr = toEnumerable(arr);
3143
+ const token = new Tokenizer(stringify(property)).readScopeValue();
3144
+ this.context.memoryLimit.use(arr.length);
3145
+ for (const item of arr) {
3146
+ const key = yield evalToken(token, this.context.spawn(item));
3147
+ if (!map.has(key)) map.set(key, []);
3148
+ map.get(key).push(item);
3149
+ }
3150
+ return [...map.entries()].map(([name, items]) => ({
3151
+ name,
3152
+ items
3153
+ }));
3154
+ }
3155
+ function* group_by_exp(arr, itemName, exp) {
3156
+ const map = /* @__PURE__ */ new Map();
3157
+ const keyTemplate = new Value(stringify(exp), this.liquid);
3158
+ arr = toEnumerable(arr);
3159
+ this.context.memoryLimit.use(arr.length);
3160
+ for (const item of arr) {
3161
+ this.context.push({ [itemName]: item });
3162
+ const key = yield keyTemplate.value(this.context);
3163
+ this.context.pop();
3164
+ if (!map.has(key)) map.set(key, []);
3165
+ map.get(key).push(item);
3166
+ }
3167
+ return [...map.entries()].map(([name, items]) => ({
3168
+ name,
3169
+ items
3170
+ }));
3171
+ }
3172
+ function* search(arr, property, expected) {
3173
+ const token = new Tokenizer(stringify(property)).readScopeValue();
3174
+ const array = toArray(arr);
3175
+ for (let index = 0; index < array.length; index++) {
3176
+ const value = yield evalToken(token, this.context.spawn(array[index]));
3177
+ if (yield matches.call(this, value, expected)) return [index, array[index]];
3178
+ }
3179
+ }
3180
+ function* search_exp(arr, itemName, exp) {
3181
+ const predicate = new Value(stringify(exp), this.liquid);
3182
+ const array = toArray(arr);
3183
+ for (let index = 0; index < array.length; index++) {
3184
+ this.context.push({ [itemName]: array[index] });
3185
+ const value = yield predicate.value(this.context);
3186
+ this.context.pop();
3187
+ if (value) return [index, array[index]];
3188
+ }
3189
+ }
3190
+ function* has(arr, property, expected) {
3191
+ return !!(yield* search.call(this, arr, property, expected));
3192
+ }
3193
+ function* has_exp(arr, itemName, exp) {
3194
+ return !!(yield* search_exp.call(this, arr, itemName, exp));
3195
+ }
3196
+ function* find_index(arr, property, expected) {
3197
+ const result = yield* search.call(this, arr, property, expected);
3198
+ return result ? result[0] : void 0;
3199
+ }
3200
+ function* find_index_exp(arr, itemName, exp) {
3201
+ const result = yield* search_exp.call(this, arr, itemName, exp);
3202
+ return result ? result[0] : void 0;
3203
+ }
3204
+ function* find(arr, property, expected) {
3205
+ const result = yield* search.call(this, arr, property, expected);
3206
+ return result ? result[1] : void 0;
3207
+ }
3208
+ function* find_exp(arr, itemName, exp) {
3209
+ const result = yield* search_exp.call(this, arr, itemName, exp);
3210
+ return result ? result[1] : void 0;
3211
+ }
3212
+ function uniq(arr) {
3213
+ arr = toArray(arr);
3214
+ this.context.memoryLimit.use(arr.length);
3215
+ return [...new Set(arr)];
3216
+ }
3217
+ function sample(v, count = 1) {
3218
+ v = toValue(v);
3219
+ if (isNil(v)) return [];
3220
+ if (!isArray(v)) v = stringify(v);
3221
+ this.context.memoryLimit.use(v.length);
3222
+ const shuffled = [...v].sort(() => Math.random() - .5);
3223
+ if (count === 1) return shuffled[0];
3224
+ return shuffled.slice(0, count);
3225
+ }
3226
+ var arrayFilters = /*#__PURE__*/ Object.freeze({
3227
+ __proto__: null,
3228
+ join,
3229
+ last: last$1,
3230
+ first,
3231
+ reverse,
3232
+ sort,
3233
+ sort_natural,
3234
+ size,
3235
+ map,
3236
+ sum,
3237
+ compact,
3238
+ concat,
3239
+ push,
3240
+ unshift,
3241
+ pop,
3242
+ shift,
3243
+ slice,
3244
+ where,
3245
+ reject,
3246
+ where_exp,
3247
+ reject_exp,
3248
+ group_by,
3249
+ group_by_exp,
3250
+ has,
3251
+ has_exp,
3252
+ find_index,
3253
+ find_index_exp,
3254
+ find,
3255
+ find_exp,
3256
+ uniq,
3257
+ sample
3258
+ });
3259
+ function date(v, format, timezoneOffset) {
3260
+ var _a, _b;
3261
+ const size = ((_a = v === null || v === void 0 ? void 0 : v.length) !== null && _a !== void 0 ? _a : 0) + ((_b = timezoneOffset === null || timezoneOffset === void 0 ? void 0 : timezoneOffset.length) !== null && _b !== void 0 ? _b : 0);
3262
+ this.context.memoryLimit.use(size);
3263
+ const date = parseDate(v, this.context.opts, timezoneOffset);
3264
+ if (!date) return v;
3265
+ format = toValue(format);
3266
+ format = isNil(format) ? this.context.opts.dateFormat : stringify(format);
3267
+ this.context.memoryLimit.use(format.length);
3268
+ return strftime(date, format, this.context.memoryLimit);
3269
+ }
3270
+ function date_to_xmlschema(v) {
3271
+ return date.call(this, v, "%Y-%m-%dT%H:%M:%S%:z");
3272
+ }
3273
+ function date_to_rfc822(v) {
3274
+ return date.call(this, v, "%a, %d %b %Y %H:%M:%S %z");
3275
+ }
3276
+ function date_to_string(v, type, style) {
3277
+ return stringify_date.call(this, v, "%b", type, style);
3278
+ }
3279
+ function date_to_long_string(v, type, style) {
3280
+ return stringify_date.call(this, v, "%B", type, style);
3281
+ }
3282
+ function stringify_date(v, month_type, type, style) {
3283
+ const date = parseDate(v, this.context.opts);
3284
+ if (!date) return v;
3285
+ const ml = this.context.memoryLimit;
3286
+ if (type === "ordinal") {
3287
+ const d = date.getDate();
3288
+ return style === "US" ? strftime(date, `${month_type} ${d}%q, %Y`, ml) : strftime(date, `${d}%q ${month_type} %Y`, ml);
3289
+ }
3290
+ return strftime(date, `%d ${month_type} %Y`, ml);
3291
+ }
3292
+ function parseDate(v, opts, timezoneOffset) {
3293
+ let date;
3294
+ const defaultTimezoneOffset = timezoneOffset !== null && timezoneOffset !== void 0 ? timezoneOffset : opts.timezoneOffset;
3295
+ const locale = opts.locale;
3296
+ v = toValue(v);
3297
+ if (isNil(v)) return;
3298
+ else if (v === "now" || v === "today") date = new LiquidDate(Date.now(), locale, defaultTimezoneOffset);
3299
+ else if (isNumber(v)) date = new LiquidDate(v * 1e3, locale, defaultTimezoneOffset);
3300
+ else if (isString(v)) {
3301
+ if (/^\d+$/.test(v)) date = new LiquidDate(+v * 1e3, locale, defaultTimezoneOffset);
3302
+ else if (opts.preserveTimezones && timezoneOffset === void 0) date = LiquidDate.createDateFixedToTimezone(v, locale);
3303
+ else date = new LiquidDate(v, locale, defaultTimezoneOffset);
3304
+ } else date = new LiquidDate(v, locale, defaultTimezoneOffset);
3305
+ return date.valid() ? date : void 0;
3306
+ }
3307
+ var dateFilters = /*#__PURE__*/ Object.freeze({
3308
+ __proto__: null,
3309
+ date,
3310
+ date_to_xmlschema,
3311
+ date_to_rfc822,
3312
+ date_to_string,
3313
+ date_to_long_string
3314
+ });
3315
+ /**
3316
+ * String related filters
3317
+ *
3318
+ * * prefer stringify() to String() since `undefined`, `null` should eval ''
3319
+ */
3320
+ const rCJKWord = /[\u4E00-\u9FFF\uF900-\uFAFF\u3400-\u4DBF\u3040-\u309F\u30A0-\u30FF\uAC00-\uD7AF]/gu;
3321
+ const rNonCJKWord = /[^\u4E00-\u9FFF\uF900-\uFAFF\u3400-\u4DBF\u3040-\u309F\u30A0-\u30FF\uAC00-\uD7AF\s]+/gu;
3322
+ function append(v, arg) {
3323
+ assert(arguments.length === 2, "append expect 2 arguments");
3324
+ const lhs = stringify(v);
3325
+ const rhs = stringify(arg);
3326
+ this.context.memoryLimit.use(lhs.length + rhs.length);
3327
+ return lhs + rhs;
3328
+ }
3329
+ function prepend(v, arg) {
3330
+ assert(arguments.length === 2, "prepend expect 2 arguments");
3331
+ const lhs = stringify(v);
3332
+ const rhs = stringify(arg);
3333
+ this.context.memoryLimit.use(lhs.length + rhs.length);
3334
+ return rhs + lhs;
3335
+ }
3336
+ function getTrimStart(str, chars) {
3337
+ let start = 0;
3338
+ for (const char of str) {
3339
+ if (!chars.has(char)) break;
3340
+ start += char.length;
3341
+ }
3342
+ return start;
3343
+ }
3344
+ function getTrimEnd(str, chars, start = 0) {
3345
+ let end = str.length;
3346
+ while (end > start) {
3347
+ const size = end - start >= 2 && str.codePointAt(end - 2) > 65535 ? 2 : 1;
3348
+ if (!chars.has(str.slice(end - size, end))) break;
3349
+ end -= size;
3350
+ }
3351
+ return end;
3352
+ }
3353
+ function lstrip(v, chars) {
3354
+ const str = stringify(v);
3355
+ this.context.memoryLimit.use(str.length);
3356
+ if (chars) {
3357
+ chars = stringify(chars);
3358
+ this.context.memoryLimit.use(chars.length);
3359
+ return str.slice(getTrimStart(str, new Set(chars)));
3360
+ }
3361
+ return str.trimStart();
3362
+ }
3363
+ function downcase(v) {
3364
+ const str = stringify(v);
3365
+ this.context.memoryLimit.use(str.length);
3366
+ return str.toLowerCase();
3367
+ }
3368
+ function upcase(v) {
3369
+ const str = stringify(v);
3370
+ this.context.memoryLimit.use(str.length);
3371
+ return stringify(str).toUpperCase();
3372
+ }
3373
+ function remove(v, arg) {
3374
+ const str = stringify(v);
3375
+ arg = stringify(arg);
3376
+ this.context.memoryLimit.use(str.length + arg.length);
3377
+ return str.split(arg).join("");
3378
+ }
3379
+ function remove_first(v, l) {
3380
+ const str = stringify(v);
3381
+ l = stringify(l);
3382
+ this.context.memoryLimit.use(str.length + l.length);
3383
+ return str.replace(l, "");
3384
+ }
3385
+ function remove_last(v, l) {
3386
+ const str = stringify(v);
3387
+ const pattern = stringify(l);
3388
+ this.context.memoryLimit.use(str.length + pattern.length);
3389
+ const index = str.lastIndexOf(pattern);
3390
+ if (index === -1) return str;
3391
+ return str.substring(0, index) + str.substring(index + pattern.length);
3392
+ }
3393
+ function rstrip(str, chars) {
3394
+ str = stringify(str);
3395
+ this.context.memoryLimit.use(str.length);
3396
+ if (chars) {
3397
+ chars = stringify(chars);
3398
+ this.context.memoryLimit.use(chars.length);
3399
+ return str.slice(0, getTrimEnd(str, new Set(chars)));
3400
+ }
3401
+ return str.trimEnd();
3402
+ }
3403
+ function split(v, arg) {
3404
+ const str = stringify(v);
3405
+ this.context.memoryLimit.use(str.length);
3406
+ const arr = str.split(stringify(arg));
3407
+ while (arr.length && arr[arr.length - 1] === "") arr.pop();
3408
+ return arr;
3409
+ }
3410
+ function strip(v, chars) {
3411
+ const str = stringify(v);
3412
+ this.context.memoryLimit.use(str.length);
3413
+ if (chars) {
3414
+ const set = new Set(stringify(chars));
3415
+ this.context.memoryLimit.use(set.size);
3416
+ const start = getTrimStart(str, set);
3417
+ return str.slice(start, getTrimEnd(str, set, start));
3418
+ }
3419
+ return str.trim();
3420
+ }
3421
+ function strip_newlines(v) {
3422
+ const str = stringify(v);
3423
+ this.context.memoryLimit.use(str.length);
3424
+ return str.replace(/\r?\n/gm, "");
3425
+ }
3426
+ function squish(v) {
3427
+ const str = stringify(v);
3428
+ this.context.memoryLimit.use(str.length);
3429
+ return str.replace(/\s+/g, " ").trim();
3430
+ }
3431
+ function capitalize(str) {
3432
+ str = stringify(str);
3433
+ this.context.memoryLimit.use(str.length);
3434
+ return str.charAt(0).toUpperCase() + str.slice(1).toLowerCase();
3435
+ }
3436
+ function replace(v, pattern, replacement) {
3437
+ const str = stringify(v);
3438
+ pattern = stringify(pattern);
3439
+ replacement = stringify(replacement);
3440
+ const parts = str.split(pattern);
3441
+ const outputSize = str.length + (parts.length - 1) * (replacement.length - pattern.length);
3442
+ this.context.memoryLimit.use(outputSize);
3443
+ return parts.join(replacement);
3444
+ }
3445
+ function replace_first(v, arg1, arg2) {
3446
+ const str = stringify(v);
3447
+ arg1 = stringify(arg1);
3448
+ arg2 = stringify(arg2);
3449
+ this.context.memoryLimit.use(str.length + arg1.length + arg2.length);
3450
+ return str.replace(arg1, () => arg2);
3451
+ }
3452
+ function replace_last(v, arg1, arg2) {
3453
+ const str = stringify(v);
3454
+ const pattern = stringify(arg1);
3455
+ const replacement = stringify(arg2);
3456
+ this.context.memoryLimit.use(str.length + pattern.length + replacement.length);
3457
+ const index = str.lastIndexOf(pattern);
3458
+ if (index === -1) return str;
3459
+ return str.substring(0, index) + replacement + str.substring(index + pattern.length);
3460
+ }
3461
+ function truncate(v, l = 50, o = "...") {
3462
+ const str = stringify(v);
3463
+ o = stringify(o);
3464
+ this.context.memoryLimit.use(str.length + o.length);
3465
+ if (str.length <= l) return v;
3466
+ return str.substring(0, l - o.length) + o;
3467
+ }
3468
+ function truncatewords(v, words = 15, o = "...") {
3469
+ const str = stringify(v);
3470
+ o = stringify(o);
3471
+ this.context.memoryLimit.use(str.length + o.length);
3472
+ const arr = str.trimStart().split(/\s+/);
3473
+ if (words <= 0) words = 1;
3474
+ let ret = arr.slice(0, words).join(" ");
3475
+ if (arr.length >= words) ret += o;
3476
+ return ret;
3477
+ }
3478
+ function normalize_whitespace(v) {
3479
+ const str = stringify(v);
3480
+ this.context.memoryLimit.use(str.length);
3481
+ return str.replace(/\s+/g, " ");
3482
+ }
3483
+ function number_of_words(input, mode) {
3484
+ const str = stringify(input);
3485
+ this.context.memoryLimit.use(str.length);
3486
+ input = str.trim();
3487
+ if (!input) return 0;
3488
+ switch (mode) {
3489
+ case "cjk": return (input.match(rCJKWord) || []).length + (input.match(rNonCJKWord) || []).length;
3490
+ case "auto": return rCJKWord.test(input) ? input.match(rCJKWord).length + (input.match(rNonCJKWord) || []).length : input.split(/\s+/).length;
3491
+ default: return input.split(/\s+/).length;
3492
+ }
3493
+ }
3494
+ function array_to_sentence_string(array, connector = "and") {
3495
+ connector = stringify(connector);
3496
+ let outputSize = connector.length + array.length * 2;
3497
+ for (let i = 0; i < array.length; i++) outputSize += stringify(array[i]).length;
3498
+ this.context.memoryLimit.use(outputSize);
3499
+ switch (array.length) {
3500
+ case 0: return "";
3501
+ case 1: return array[0];
3502
+ case 2: return `${array[0]} ${connector} ${array[1]}`;
3503
+ default: return `${array.slice(0, -1).join(", ")}, ${connector} ${array[array.length - 1]}`;
3504
+ }
3505
+ }
3506
+ var stringFilters = /*#__PURE__*/ Object.freeze({
3507
+ __proto__: null,
3508
+ append,
3509
+ prepend,
3510
+ lstrip,
3511
+ downcase,
3512
+ upcase,
3513
+ remove,
3514
+ remove_first,
3515
+ remove_last,
3516
+ rstrip,
3517
+ split,
3518
+ strip,
3519
+ strip_newlines,
3520
+ squish,
3521
+ capitalize,
3522
+ replace,
3523
+ replace_first,
3524
+ replace_last,
3525
+ truncate,
3526
+ truncatewords,
3527
+ normalize_whitespace,
3528
+ number_of_words,
3529
+ array_to_sentence_string
3530
+ });
3531
+ function base64Encode(str) {
3532
+ const bytes = new TextEncoder().encode(str);
3533
+ let binary = "";
3534
+ for (let i = 0; i < bytes.length; i += 32768) binary += String.fromCharCode(...bytes.subarray(i, i + 32768));
3535
+ return btoa(binary);
3536
+ }
3537
+ function base64Decode(str) {
3538
+ return new TextDecoder().decode(Uint8Array.from(atob(str), (c) => c.charCodeAt(0)));
3539
+ }
3540
+ /**
3541
+ * Base64 related filters
3542
+ *
3543
+ * Implements base64_encode and base64_decode filters for Shopify compatibility
3544
+ */
3545
+ function base64_encode(value) {
3546
+ if (typeof Buffer !== "undefined" && Buffer.isBuffer(value)) {
3547
+ this.context.memoryLimit.use(value.byteLength);
3548
+ return value.toString("base64");
3549
+ }
3550
+ const str = stringify(value);
3551
+ this.context.memoryLimit.use(str.length);
3552
+ return base64Encode(str);
3553
+ }
3554
+ function base64_decode(value) {
3555
+ const str = stringify(value);
3556
+ this.context.memoryLimit.use(str.length);
3557
+ return base64Decode(str);
3558
+ }
3559
+ var base64Filters = /*#__PURE__*/ Object.freeze({
3560
+ __proto__: null,
3561
+ base64_encode,
3562
+ base64_decode
3563
+ });
3564
+ function bufferToHex(buffer) {
3565
+ const bytes = new Uint8Array(buffer);
3566
+ let hex = "";
3567
+ for (let i = 0; i < bytes.length; i++) hex += bytes[i].toString(16).padStart(2, "0");
3568
+ return hex;
3569
+ }
3570
+ function sha256(str) {
3571
+ return __awaiter(this, void 0, void 0, function* () {
3572
+ const data = new TextEncoder().encode(str);
3573
+ return bufferToHex(yield crypto.subtle.digest("SHA-256", data));
3574
+ });
3575
+ }
3576
+ function hmacSha256(str, key) {
3577
+ return __awaiter(this, void 0, void 0, function* () {
3578
+ const encoder = new TextEncoder();
3579
+ const cryptoKey = yield crypto.subtle.importKey("raw", encoder.encode(key), {
3580
+ name: "HMAC",
3581
+ hash: "SHA-256"
3582
+ }, false, ["sign"]);
3583
+ return bufferToHex(yield crypto.subtle.sign("HMAC", cryptoKey, encoder.encode(str)));
3584
+ });
3585
+ }
3586
+ /**
3587
+ * Crypto related filters
3588
+ *
3589
+ * Implements sha256 and hmac_sha256 filters for Shopify compatibility
3590
+ */
3591
+ function sha256$1(value) {
3592
+ const str = stringify(value);
3593
+ this.context.memoryLimit.use(str.length);
3594
+ return sha256(str);
3595
+ }
3596
+ function hmac_sha256(value, key) {
3597
+ const str = stringify(value);
3598
+ const keyStr = stringify(key);
3599
+ this.context.memoryLimit.use(str.length + keyStr.length);
3600
+ return hmacSha256(str, keyStr);
3601
+ }
3602
+ var cryptoFilters = /*#__PURE__*/ Object.freeze({
3603
+ __proto__: null,
3604
+ sha256: sha256$1,
3605
+ hmac_sha256
3606
+ });
3607
+ const filters = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, htmlFilters), mathFilters), urlFilters), arrayFilters), dateFilters), stringFilters), base64Filters), cryptoFilters), misc);
3608
+ var AssignTag = class extends Tag {
3609
+ constructor(token, remainTokens, liquid) {
3610
+ super(token, remainTokens, liquid);
3611
+ this.identifier = this.tokenizer.readIdentifier();
3612
+ this.key = this.identifier.content;
3613
+ this.tokenizer.assert(this.key, "expected variable name");
3614
+ this.tokenizer.skipBlank();
3615
+ this.tokenizer.assert(this.tokenizer.peek() === "=", "expected \"=\"");
3616
+ this.tokenizer.advance();
3617
+ this.value = new Value(this.tokenizer.readFilteredValue(), this.liquid);
3618
+ }
3619
+ *render(ctx) {
3620
+ ctx.bottom()[this.key] = yield this.value.value(ctx, this.liquid.options.lenientIf);
3621
+ }
3622
+ *arguments() {
3623
+ yield this.value;
3624
+ }
3625
+ *localScope() {
3626
+ yield this.identifier;
3627
+ }
3628
+ };
3629
+ const MODIFIERS = [
3630
+ "offset",
3631
+ "limit",
3632
+ "reversed"
3633
+ ];
3634
+ var ForTag = class extends Tag {
3635
+ constructor(token, remainTokens, liquid, parser) {
3636
+ super(token, remainTokens, liquid);
3637
+ const variable = this.tokenizer.readIdentifier();
3638
+ const inStr = this.tokenizer.readIdentifier();
3639
+ const collection = this.tokenizer.readValue();
3640
+ if (!variable.size() || inStr.content !== "in" || !collection) throw new Error(`illegal tag: ${token.getText()}`);
3641
+ this.variable = variable.content;
3642
+ this.collection = collection;
3643
+ this.hash = new Hash(this.tokenizer, liquid.options.keyValueSeparator);
3644
+ this.templates = [];
3645
+ this.elseTemplates = [];
3646
+ let p;
3647
+ const stream = parser.parseStream(remainTokens).on("start", () => p = this.templates).on("tag:else", (tag) => {
3648
+ assertEmpty(tag.args);
3649
+ p = this.elseTemplates;
3650
+ }).on("tag:endfor", (tag) => {
3651
+ assertEmpty(tag.args);
3652
+ stream.stop();
3653
+ }).on("template", (tpl) => p.push(tpl)).on("end", () => {
3654
+ throw new Error(`tag ${token.getText()} not closed`);
3655
+ });
3656
+ stream.start();
3657
+ }
3658
+ *render(ctx, emitter) {
3659
+ const r = this.liquid.renderer;
3660
+ let collection = toEnumerable(yield evalToken(this.collection, ctx));
3661
+ if (!collection.length) {
3662
+ yield r.renderTemplates(this.elseTemplates, ctx, emitter);
3663
+ return;
3664
+ }
3665
+ const continueKey = "continue-" + this.variable + "-" + this.collection.getText();
3666
+ ctx.push(createScope({ continue: ctx.getRegister(continueKey, {}) }));
3667
+ const hash = yield this.hash.render(ctx);
3668
+ ctx.pop();
3669
+ collection = (this.liquid.options.orderedFilterParameters ? Object.keys(hash).filter((x) => MODIFIERS.includes(x)) : MODIFIERS.filter((x) => hash[x] !== void 0)).reduce((collection, modifier) => {
3670
+ if (modifier === "offset") return offset(collection, hash["offset"]);
3671
+ if (modifier === "limit") return limit(collection, hash["limit"]);
3672
+ return reversed(collection);
3673
+ }, collection);
3674
+ ctx.setRegister(continueKey, (hash["offset"] || 0) + collection.length);
3675
+ const scope = createScope({ forloop: new ForloopDrop(collection.length, this.collection.getText(), this.variable) });
3676
+ ctx.push(scope);
3677
+ for (const item of collection) {
3678
+ scope[this.variable] = item;
3679
+ ctx.continueCalled = ctx.breakCalled = false;
3680
+ yield r.renderTemplates(this.templates, ctx, emitter);
3681
+ if (ctx.breakCalled) break;
3682
+ scope.forloop.next();
3683
+ }
3684
+ ctx.continueCalled = ctx.breakCalled = false;
3685
+ ctx.pop();
3686
+ }
3687
+ *children() {
3688
+ const templates = this.templates.slice();
3689
+ if (this.elseTemplates) templates.push(...this.elseTemplates);
3690
+ return templates;
3691
+ }
3692
+ *arguments() {
3693
+ yield this.collection;
3694
+ for (const v of Object.values(this.hash.hash)) if (isValueToken(v)) yield v;
3695
+ }
3696
+ blockScope() {
3697
+ return [this.variable, "forloop"];
3698
+ }
3699
+ };
3700
+ function reversed(arr) {
3701
+ return [...arr].reverse();
3702
+ }
3703
+ function offset(arr, count) {
3704
+ return arr.slice(count);
3705
+ }
3706
+ function limit(arr, count) {
3707
+ return arr.slice(0, count);
3708
+ }
3709
+ var CaptureTag = class extends Tag {
3710
+ constructor(tagToken, remainTokens, liquid, parser) {
3711
+ super(tagToken, remainTokens, liquid);
3712
+ this.templates = [];
3713
+ this.identifier = this.readVariable();
3714
+ this.variable = this.identifier.content;
3715
+ while (remainTokens.length) {
3716
+ const token = remainTokens.shift();
3717
+ if (isTagToken(token) && token.name === "endcapture") return;
3718
+ this.templates.push(parser.parseToken(token, remainTokens));
3719
+ }
3720
+ throw new Error(`tag ${tagToken.getText()} not closed`);
3721
+ }
3722
+ readVariable() {
3723
+ let ident = this.tokenizer.readIdentifier();
3724
+ if (ident.content) return ident;
3725
+ ident = this.tokenizer.readQuoted();
3726
+ if (ident) return ident;
3727
+ throw this.tokenizer.error("invalid capture name");
3728
+ }
3729
+ *render(ctx) {
3730
+ const html = yield this.liquid.renderer.renderTemplates(this.templates, ctx);
3731
+ ctx.bottom()[this.variable] = html;
3732
+ }
3733
+ *children() {
3734
+ return this.templates;
3735
+ }
3736
+ *localScope() {
3737
+ yield this.identifier;
3738
+ }
3739
+ };
3740
+ var CaseTag = class extends Tag {
3741
+ constructor(tagToken, remainTokens, liquid, parser) {
3742
+ super(tagToken, remainTokens, liquid);
3743
+ this.branches = [];
3744
+ this.elseTemplates = [];
3745
+ this.value = new Value(this.tokenizer.readFilteredValue(), this.liquid);
3746
+ this.elseTemplates = [];
3747
+ let p = [];
3748
+ let elseCount = 0;
3749
+ const stream = parser.parseStream(remainTokens).on("tag:when", (token) => {
3750
+ if (elseCount > 0) return;
3751
+ p = [];
3752
+ const values = [];
3753
+ while (!token.tokenizer.end()) {
3754
+ values.push(token.tokenizer.readValueOrThrow());
3755
+ token.tokenizer.skipBlank();
3756
+ if (token.tokenizer.peek() === ",") token.tokenizer.readTo(",");
3757
+ else token.tokenizer.readTo("or");
3758
+ }
3759
+ this.branches.push({
3760
+ values,
3761
+ templates: p
3762
+ });
3763
+ }).on("tag:else", () => {
3764
+ elseCount++;
3765
+ p = this.elseTemplates;
3766
+ }).on("tag:endcase", () => stream.stop()).on("template", (tpl) => {
3767
+ if (p !== this.elseTemplates || elseCount === 1) p.push(tpl);
3768
+ }).on("end", () => {
3769
+ throw new Error(`tag ${tagToken.getText()} not closed`);
3770
+ });
3771
+ stream.start();
3772
+ }
3773
+ *render(ctx, emitter) {
3774
+ const r = this.liquid.renderer;
3775
+ const target = yield toValue(yield this.value.value(ctx, ctx.opts.lenientIf));
3776
+ let branchHit = false;
3777
+ for (const branch of this.branches) for (const valueToken of branch.values) if (yield equals(target, yield evalToken(valueToken, ctx, ctx.opts.lenientIf))) {
3778
+ yield r.renderTemplates(branch.templates, ctx, emitter);
3779
+ branchHit = true;
3780
+ break;
3781
+ }
3782
+ if (!branchHit) yield r.renderTemplates(this.elseTemplates, ctx, emitter);
3783
+ }
3784
+ *arguments() {
3785
+ yield this.value;
3786
+ yield* this.branches.flatMap((b) => b.values);
3787
+ }
3788
+ *children() {
3789
+ const templates = this.branches.flatMap((b) => b.templates);
3790
+ if (this.elseTemplates) templates.push(...this.elseTemplates);
3791
+ return templates;
3792
+ }
3793
+ };
3794
+ var CommentTag = class extends Tag {
3795
+ constructor(tagToken, remainTokens, liquid) {
3796
+ super(tagToken, remainTokens, liquid);
3797
+ while (remainTokens.length) {
3798
+ const token = remainTokens.shift();
3799
+ if (isTagToken(token) && token.name === "endcomment") return;
3800
+ }
3801
+ throw new Error(`tag ${tagToken.getText()} not closed`);
3802
+ }
3803
+ render() {}
3804
+ };
3805
+ var RenderTag = class extends Tag {
3806
+ constructor(token, remainTokens, liquid, parser) {
3807
+ super(token, remainTokens, liquid);
3808
+ const tokenizer = this.tokenizer;
3809
+ this.file = parseFilePath(tokenizer, this.liquid, parser);
3810
+ this.currentFile = token.file;
3811
+ while (!tokenizer.end()) {
3812
+ tokenizer.skipBlank();
3813
+ const begin = tokenizer.p;
3814
+ const keyword = tokenizer.readIdentifier();
3815
+ if (keyword.content === "with" || keyword.content === "for") {
3816
+ tokenizer.skipBlank();
3817
+ if (tokenizer.peek() !== ":") {
3818
+ const value = tokenizer.readValue();
3819
+ if (value) {
3820
+ const beforeAs = tokenizer.p;
3821
+ const asStr = tokenizer.readIdentifier();
3822
+ let alias;
3823
+ if (asStr.content === "as") alias = tokenizer.readIdentifier();
3824
+ else tokenizer.p = beforeAs;
3825
+ const binding = {
3826
+ value,
3827
+ alias: alias && alias.content
3828
+ };
3829
+ if (keyword.content === "with") this.with = binding;
3830
+ else this.forBinding = binding;
3831
+ tokenizer.skipBlank();
3832
+ if (tokenizer.peek() === ",") tokenizer.advance();
3833
+ continue;
3834
+ }
3835
+ }
3836
+ }
3837
+ /**
3838
+ * restore cursor if with/for not matched
3839
+ */
3840
+ tokenizer.p = begin;
3841
+ break;
3842
+ }
3843
+ this.hash = new Hash(tokenizer, liquid.options.keyValueSeparator);
3844
+ }
3845
+ *render(ctx, emitter) {
3846
+ const { liquid, hash } = this;
3847
+ const filepath = yield renderFilePath(this.file, ctx, liquid);
3848
+ assert(filepath, () => `illegal file path "${filepath}"`);
3849
+ const childCtx = ctx.spawn();
3850
+ const scope = childCtx.bottom();
3851
+ __assign(scope, yield hash.render(ctx));
3852
+ if (this.with) {
3853
+ const { value, alias } = this.with;
3854
+ scope[alias || filepath] = yield evalToken(value, ctx);
3855
+ }
3856
+ if (this.forBinding) {
3857
+ const { value, alias } = this.forBinding;
3858
+ const collection = toEnumerable(yield evalToken(value, ctx));
3859
+ scope["forloop"] = new ForloopDrop(collection.length, value.getText(), alias);
3860
+ for (const item of collection) {
3861
+ scope[alias] = item;
3862
+ const templates = yield liquid._parsePartialFile(filepath, childCtx.sync, this.currentFile);
3863
+ yield liquid.renderer.renderTemplates(templates, childCtx, emitter);
3864
+ scope["forloop"].next();
3865
+ }
3866
+ } else {
3867
+ const templates = yield liquid._parsePartialFile(filepath, childCtx.sync, this.currentFile);
3868
+ yield liquid.renderer.renderTemplates(templates, childCtx, emitter);
3869
+ }
3870
+ }
3871
+ *children(partials, sync) {
3872
+ if (partials && isString(this.file)) return yield this.liquid._parsePartialFile(this.file, sync, this.currentFile);
3873
+ return [];
3874
+ }
3875
+ partialScope() {
3876
+ if (isString(this.file)) {
3877
+ const names = Object.keys(this.hash.hash);
3878
+ if (this.with) {
3879
+ const { value, alias } = this.with;
3880
+ if (isString(alias)) names.push([alias, value]);
3881
+ else if (isString(this.file)) names.push([this.file, value]);
3882
+ }
3883
+ if (this.forBinding) {
3884
+ const { value, alias } = this.forBinding;
3885
+ if (isString(alias)) names.push([alias, value]);
3886
+ else if (isString(this.file)) names.push([this.file, value]);
3887
+ }
3888
+ return {
3889
+ name: this.file,
3890
+ isolated: true,
3891
+ scope: names
3892
+ };
3893
+ }
3894
+ }
3895
+ *arguments() {
3896
+ for (const v of Object.values(this.hash.hash)) if (isValueToken(v)) yield v;
3897
+ if (this.with) {
3898
+ const { value } = this.with;
3899
+ if (isValueToken(value)) yield value;
3900
+ }
3901
+ if (this.forBinding) {
3902
+ const { value } = this.forBinding;
3903
+ if (isValueToken(value)) yield value;
3904
+ }
3905
+ }
3906
+ };
3907
+ /**
3908
+ * @return null for "none",
3909
+ * @return Template[] for quoted with tags and/or filters
3910
+ * @return Token for expression (not quoted)
3911
+ * @throws TypeError if cannot read next token
3912
+ */
3913
+ function parseFilePath(tokenizer, liquid, parser) {
3914
+ if (liquid.options.dynamicPartials) {
3915
+ const file = tokenizer.readValue();
3916
+ tokenizer.assert(file, "illegal file path");
3917
+ if (file.getText() === "none") return;
3918
+ if (isQuotedToken(file)) return optimize(parser.parse(evalQuotedToken(file)));
3919
+ return file;
3920
+ }
3921
+ const tokens = [...tokenizer.readFileNameTemplate(liquid.options)];
3922
+ const templates = optimize(parser.parseTokens(tokens));
3923
+ return templates === "none" ? void 0 : templates;
3924
+ }
3925
+ function optimize(templates) {
3926
+ if (templates.length === 1 && isHTMLToken(templates[0].token)) return templates[0].token.getContent();
3927
+ return templates;
3928
+ }
3929
+ function* renderFilePath(file, ctx, liquid) {
3930
+ if (typeof file === "string") return file;
3931
+ if (Array.isArray(file)) return liquid.renderer.renderTemplates(file, ctx);
3932
+ return yield evalToken(file, ctx);
3933
+ }
3934
+ var IncludeTag = class extends Tag {
3935
+ constructor(token, remainTokens, liquid, parser) {
3936
+ super(token, remainTokens, liquid);
3937
+ const { tokenizer } = token;
3938
+ this.file = parseFilePath(tokenizer, this.liquid, parser);
3939
+ this.currentFile = token.file;
3940
+ const begin = tokenizer.p;
3941
+ if (tokenizer.readIdentifier().content === "with") {
3942
+ tokenizer.skipBlank();
3943
+ if (tokenizer.peek() !== ":") this.withVar = tokenizer.readValue();
3944
+ else tokenizer.p = begin;
3945
+ } else tokenizer.p = begin;
3946
+ this.hash = new Hash(tokenizer, liquid.options.jekyllInclude || liquid.options.keyValueSeparator);
3947
+ }
3948
+ *render(ctx, emitter) {
3949
+ const { liquid, hash, withVar } = this;
3950
+ const { renderer } = liquid;
3951
+ const filepath = yield renderFilePath(this.file, ctx, liquid);
3952
+ assert(filepath, () => `illegal file path "${filepath}"`);
3953
+ const saved = ctx.saveRegister("blocks", "blockMode");
3954
+ ctx.setRegister("blocks", {});
3955
+ ctx.setRegister("blockMode", BlockMode.OUTPUT);
3956
+ const scope = createScope(yield hash.render(ctx));
3957
+ if (withVar) scope[filepath] = yield evalToken(withVar, ctx);
3958
+ const templates = yield liquid._parsePartialFile(filepath, ctx.sync, this.currentFile);
3959
+ ctx.push(ctx.opts.jekyllInclude ? createScope({ include: scope }) : scope);
3960
+ yield renderer.renderTemplates(templates, ctx, emitter);
3961
+ ctx.pop();
3962
+ ctx.restoreRegister(saved);
3963
+ }
3964
+ *children(partials, sync) {
3965
+ if (partials && isString(this.file)) return yield this.liquid._parsePartialFile(this.file, sync, this.currentFile);
3966
+ return [];
3967
+ }
3968
+ partialScope() {
3969
+ if (isString(this.file)) {
3970
+ let names;
3971
+ if (this.liquid.options.jekyllInclude) names = ["include"];
3972
+ else {
3973
+ names = Object.keys(this.hash.hash);
3974
+ if (this.withVar) names.push([this.file, this.withVar]);
3975
+ }
3976
+ return {
3977
+ name: this.file,
3978
+ isolated: false,
3979
+ scope: names
3980
+ };
3981
+ }
3982
+ }
3983
+ *arguments() {
3984
+ yield* Object.values(this.hash.hash).filter(isValueToken);
3985
+ if (isValueToken(this.file)) yield this.file;
3986
+ if (isValueToken(this.withVar)) yield this.withVar;
3987
+ }
3988
+ };
3989
+ var DecrementTag = class extends Tag {
3990
+ constructor(token, remainTokens, liquid) {
3991
+ super(token, remainTokens, liquid);
3992
+ this.identifier = this.tokenizer.readIdentifier();
3993
+ this.variable = this.identifier.content;
3994
+ }
3995
+ render(context, emitter) {
3996
+ const scope = context.environments;
3997
+ if (!isNumber(scope[this.variable])) scope[this.variable] = 0;
3998
+ emitter.write(stringify(--scope[this.variable]));
3999
+ }
4000
+ *localScope() {
4001
+ yield this.identifier;
4002
+ }
4003
+ };
4004
+ var CycleTag = class extends Tag {
4005
+ constructor(token, remainTokens, liquid) {
4006
+ super(token, remainTokens, liquid);
4007
+ this.candidates = [];
4008
+ const group = this.tokenizer.readValue();
4009
+ this.tokenizer.skipBlank();
4010
+ if (group) {
4011
+ if (this.tokenizer.peek() === ":") {
4012
+ this.group = group;
4013
+ this.tokenizer.advance();
4014
+ } else this.candidates.push(group);
4015
+ }
4016
+ while (!this.tokenizer.end()) {
4017
+ const value = this.tokenizer.readValue();
4018
+ if (value) this.candidates.push(value);
4019
+ this.tokenizer.readTo(",");
4020
+ }
4021
+ this.tokenizer.assert(this.candidates.length, () => `empty candidates: "${token.getText()}"`);
4022
+ }
4023
+ *render(ctx, emitter) {
4024
+ const fingerprint = `cycle:${yield evalToken(this.group, ctx)}:` + this.candidates.join(",");
4025
+ const groups = ctx.getRegister("cycle", {});
4026
+ let idx = groups[fingerprint];
4027
+ if (idx === void 0) idx = groups[fingerprint] = 0;
4028
+ const candidate = this.candidates[idx];
4029
+ idx = (idx + 1) % this.candidates.length;
4030
+ groups[fingerprint] = idx;
4031
+ return yield evalToken(candidate, ctx);
4032
+ }
4033
+ *arguments() {
4034
+ yield* this.candidates;
4035
+ if (this.group) yield this.group;
4036
+ }
4037
+ };
4038
+ var IfTag = class extends Tag {
4039
+ constructor(tagToken, remainTokens, liquid, parser) {
4040
+ super(tagToken, remainTokens, liquid);
4041
+ this.branches = [];
4042
+ let p = [];
4043
+ parser.parseStream(remainTokens).on("start", () => this.branches.push({
4044
+ value: new Value(tagToken.tokenizer.readFilteredValue(), this.liquid),
4045
+ templates: p = []
4046
+ })).on("tag:elsif", (token) => {
4047
+ assert(!this.elseTemplates, "unexpected elsif after else");
4048
+ this.branches.push({
4049
+ value: new Value(token.tokenizer.readFilteredValue(), this.liquid),
4050
+ templates: p = []
4051
+ });
4052
+ }).on("tag:else", (tag) => {
4053
+ assertEmpty(tag.args);
4054
+ assert(!this.elseTemplates, "duplicated else");
4055
+ p = this.elseTemplates = [];
4056
+ }).on("tag:endif", function(tag) {
4057
+ assertEmpty(tag.args);
4058
+ this.stop();
4059
+ }).on("template", (tpl) => p.push(tpl)).on("end", () => {
4060
+ throw new Error(`tag ${tagToken.getText()} not closed`);
4061
+ }).start();
4062
+ }
4063
+ *render(ctx, emitter) {
4064
+ const r = this.liquid.renderer;
4065
+ for (const { value, templates } of this.branches) if (isTruthy(yield toValue(yield value.value(ctx, ctx.opts.lenientIf)), ctx)) {
4066
+ yield r.renderTemplates(templates, ctx, emitter);
4067
+ return;
4068
+ }
4069
+ yield r.renderTemplates(this.elseTemplates || [], ctx, emitter);
4070
+ }
4071
+ *children() {
4072
+ const templates = this.branches.flatMap((b) => b.templates);
4073
+ if (this.elseTemplates) templates.push(...this.elseTemplates);
4074
+ return templates;
4075
+ }
4076
+ arguments() {
4077
+ return this.branches.map((b) => b.value);
4078
+ }
4079
+ };
4080
+ var IncrementTag = class extends Tag {
4081
+ constructor(token, remainTokens, liquid) {
4082
+ super(token, remainTokens, liquid);
4083
+ this.identifier = this.tokenizer.readIdentifier();
4084
+ this.variable = this.identifier.content;
4085
+ }
4086
+ render(context, emitter) {
4087
+ const scope = context.environments;
4088
+ if (!isNumber(scope[this.variable])) scope[this.variable] = 0;
4089
+ const val = scope[this.variable];
4090
+ scope[this.variable]++;
4091
+ emitter.write(stringify(val));
4092
+ }
4093
+ *localScope() {
4094
+ yield this.identifier;
4095
+ }
4096
+ };
4097
+ var LayoutTag = class extends Tag {
4098
+ constructor(token, remainTokens, liquid, parser) {
4099
+ super(token, remainTokens, liquid);
4100
+ this.file = parseFilePath(this.tokenizer, this.liquid, parser);
4101
+ this.currentFile = token.file;
4102
+ this.args = new Hash(this.tokenizer, liquid.options.keyValueSeparator);
4103
+ this.templates = parser.parseTokens(remainTokens);
4104
+ }
4105
+ *render(ctx, emitter) {
4106
+ const { liquid, args, file } = this;
4107
+ const { renderer } = liquid;
4108
+ if (file === void 0) {
4109
+ ctx.setRegister("blockMode", BlockMode.OUTPUT);
4110
+ yield renderer.renderTemplates(this.templates, ctx, emitter);
4111
+ return;
4112
+ }
4113
+ const filepath = yield renderFilePath(this.file, ctx, liquid);
4114
+ assert(filepath, () => `illegal file path "${filepath}"`);
4115
+ const templates = yield liquid._parseLayoutFile(filepath, ctx.sync, this.currentFile);
4116
+ ctx.setRegister("blockMode", BlockMode.STORE);
4117
+ const html = yield renderer.renderTemplates(this.templates, ctx);
4118
+ const blocks = ctx.getRegister("blocks", {});
4119
+ if (blocks[""] === void 0) blocks[""] = (parent, emitter) => emitter.write(html);
4120
+ ctx.setRegister("blockMode", BlockMode.OUTPUT);
4121
+ ctx.push(createScope(yield args.render(ctx)));
4122
+ yield renderer.renderTemplates(templates, ctx, emitter);
4123
+ ctx.pop();
4124
+ }
4125
+ *children(partials) {
4126
+ const templates = this.templates.slice();
4127
+ if (partials && isString(this.file)) templates.push(...yield this.liquid._parsePartialFile(this.file, true, this.currentFile));
4128
+ return templates;
4129
+ }
4130
+ *arguments() {
4131
+ for (const v of Object.values(this.args.hash)) if (isValueToken(v)) yield v;
4132
+ if (isValueToken(this.file)) yield this.file;
4133
+ }
4134
+ partialScope() {
4135
+ if (isString(this.file)) return {
4136
+ name: this.file,
4137
+ isolated: false,
4138
+ scope: Object.keys(this.args.hash)
4139
+ };
4140
+ }
4141
+ };
4142
+ var BlockTag = class extends Tag {
4143
+ constructor(token, remainTokens, liquid, parser) {
4144
+ super(token, remainTokens, liquid);
4145
+ this.templates = [];
4146
+ const match = /\w+/.exec(token.args);
4147
+ this.block = match ? match[0] : "";
4148
+ while (remainTokens.length) {
4149
+ const token = remainTokens.shift();
4150
+ if (isTagToken(token) && token.name === "endblock") return;
4151
+ const template = parser.parseToken(token, remainTokens);
4152
+ this.templates.push(template);
4153
+ }
4154
+ throw new Error(`tag ${token.getText()} not closed`);
4155
+ }
4156
+ *render(ctx, emitter) {
4157
+ const blockRender = this.getBlockRender(ctx);
4158
+ if (ctx.getRegister("blockMode") === BlockMode.STORE) ctx.getRegister("blocks", {})[this.block] = blockRender;
4159
+ else yield blockRender(new BlockDrop(), emitter);
4160
+ }
4161
+ getBlockRender(ctx) {
4162
+ const self = this;
4163
+ const { liquid, templates } = this;
4164
+ const renderChild = ctx.getRegister("blocks", {})[this.block];
4165
+ const renderCurrent = function* (superBlock, emitter) {
4166
+ const stack = ctx.getRegister("blockStack", []);
4167
+ if (stack.includes(self)) throw new Error("block tag cannot be nested");
4168
+ stack.push(self);
4169
+ ctx.push(createScope({ block: superBlock }));
4170
+ yield liquid.renderer.renderTemplates(templates, ctx, emitter);
4171
+ ctx.pop();
4172
+ stack.pop();
4173
+ };
4174
+ return renderChild ? (superBlock, emitter) => renderChild(new BlockDrop((emitter) => renderCurrent(superBlock, emitter)), emitter) : renderCurrent;
4175
+ }
4176
+ *children() {
4177
+ return this.templates;
4178
+ }
4179
+ blockScope() {
4180
+ return ["block"];
4181
+ }
4182
+ };
4183
+ var RawTag = class extends Tag {
4184
+ constructor(tagToken, remainTokens, liquid) {
4185
+ super(tagToken, remainTokens, liquid);
4186
+ this.tokens = [];
4187
+ while (remainTokens.length) {
4188
+ const token = remainTokens.shift();
4189
+ if (isTagToken(token) && token.name === "endraw") return;
4190
+ this.tokens.push(token);
4191
+ }
4192
+ throw new Error(`tag ${tagToken.getText()} not closed`);
4193
+ }
4194
+ render() {
4195
+ return this.tokens.map((token) => token.getText()).join("");
4196
+ }
4197
+ };
4198
+ var TablerowloopDrop = class extends ForloopDrop {
4199
+ constructor(length, cols, collection, variable) {
4200
+ super(length, collection, variable);
4201
+ this.length = length;
4202
+ this.cols = cols;
4203
+ }
4204
+ row() {
4205
+ return Math.floor(this.i / this.cols) + 1;
4206
+ }
4207
+ col0() {
4208
+ return this.i % this.cols;
4209
+ }
4210
+ col() {
4211
+ return this.col0() + 1;
4212
+ }
4213
+ col_first() {
4214
+ return this.col0() === 0;
4215
+ }
4216
+ col_last() {
4217
+ return this.col() === this.cols;
4218
+ }
4219
+ };
4220
+ var TablerowTag = class extends Tag {
4221
+ constructor(tagToken, remainTokens, liquid, parser) {
4222
+ super(tagToken, remainTokens, liquid);
4223
+ const variable = this.tokenizer.readIdentifier();
4224
+ this.tokenizer.skipBlank();
4225
+ const predicate = this.tokenizer.readIdentifier();
4226
+ const collectionToken = this.tokenizer.readValue();
4227
+ if (predicate.content !== "in" || !collectionToken) throw new Error(`illegal tag: ${tagToken.getText()}`);
4228
+ this.variable = variable.content;
4229
+ this.collection = collectionToken;
4230
+ this.args = new Hash(this.tokenizer, liquid.options.keyValueSeparator);
4231
+ this.templates = [];
4232
+ let p;
4233
+ const stream = parser.parseStream(remainTokens).on("start", () => p = this.templates).on("tag:endtablerow", () => stream.stop()).on("template", (tpl) => p.push(tpl)).on("end", () => {
4234
+ throw new Error(`tag ${tagToken.getText()} not closed`);
4235
+ });
4236
+ stream.start();
4237
+ }
4238
+ *render(ctx, emitter) {
4239
+ let collection = toEnumerable(yield evalToken(this.collection, ctx));
4240
+ const args = yield this.args.render(ctx);
4241
+ const offset = args.offset || 0;
4242
+ const limit = args.limit === void 0 ? collection.length : args.limit;
4243
+ collection = collection.slice(offset, offset + limit);
4244
+ const cols = args.cols || collection.length;
4245
+ const r = this.liquid.renderer;
4246
+ const tablerowloop = new TablerowloopDrop(collection.length, cols, this.collection.getText(), this.variable);
4247
+ const scope = createScope({ tablerowloop });
4248
+ ctx.push(scope);
4249
+ for (let idx = 0; idx < collection.length; idx++, tablerowloop.next()) {
4250
+ scope[this.variable] = collection[idx];
4251
+ if (tablerowloop.col0() === 0) {
4252
+ if (tablerowloop.row() !== 1) emitter.write("</tr>");
4253
+ emitter.write(`<tr class="row${tablerowloop.row()}">`);
4254
+ }
4255
+ emitter.write(`<td class="col${tablerowloop.col()}">`);
4256
+ yield r.renderTemplates(this.templates, ctx, emitter);
4257
+ emitter.write("</td>");
4258
+ }
4259
+ if (collection.length) emitter.write("</tr>");
4260
+ ctx.pop();
4261
+ }
4262
+ *children() {
4263
+ return this.templates;
4264
+ }
4265
+ *arguments() {
4266
+ yield this.collection;
4267
+ for (const v of Object.values(this.args.hash)) if (isValueToken(v)) yield v;
4268
+ }
4269
+ blockScope() {
4270
+ return [this.variable, "tablerowloop"];
4271
+ }
4272
+ };
4273
+ var UnlessTag = class extends Tag {
4274
+ constructor(tagToken, remainTokens, liquid, parser) {
4275
+ super(tagToken, remainTokens, liquid);
4276
+ this.branches = [];
4277
+ this.elseTemplates = [];
4278
+ let p = [];
4279
+ let elseCount = 0;
4280
+ parser.parseStream(remainTokens).on("start", () => this.branches.push({
4281
+ value: new Value(tagToken.tokenizer.readFilteredValue(), this.liquid),
4282
+ test: isFalsy,
4283
+ templates: p = []
4284
+ })).on("tag:elsif", (token) => {
4285
+ if (elseCount > 0) {
4286
+ p = [];
4287
+ return;
4288
+ }
4289
+ this.branches.push({
4290
+ value: new Value(token.tokenizer.readFilteredValue(), this.liquid),
4291
+ test: isTruthy,
4292
+ templates: p = []
4293
+ });
4294
+ }).on("tag:else", () => {
4295
+ elseCount++;
4296
+ p = this.elseTemplates;
4297
+ }).on("tag:endunless", function() {
4298
+ this.stop();
4299
+ }).on("template", (tpl) => {
4300
+ if (p !== this.elseTemplates || elseCount === 1) p.push(tpl);
4301
+ }).on("end", () => {
4302
+ throw new Error(`tag ${tagToken.getText()} not closed`);
4303
+ }).start();
4304
+ }
4305
+ *render(ctx, emitter) {
4306
+ const r = this.liquid.renderer;
4307
+ for (const { value, test, templates } of this.branches) if (test(yield toValue(yield value.value(ctx, ctx.opts.lenientIf)), ctx)) {
4308
+ yield r.renderTemplates(templates, ctx, emitter);
4309
+ return;
4310
+ }
4311
+ yield r.renderTemplates(this.elseTemplates, ctx, emitter);
4312
+ }
4313
+ *children() {
4314
+ const children = this.branches.flatMap((b) => b.templates);
4315
+ if (this.elseTemplates) children.push(...this.elseTemplates);
4316
+ return children;
4317
+ }
4318
+ arguments() {
4319
+ return this.branches.map((b) => b.value);
4320
+ }
4321
+ };
4322
+ var BreakTag = class extends Tag {
4323
+ render(ctx, _emitter) {
4324
+ ctx.breakCalled = true;
4325
+ }
4326
+ };
4327
+ var ContinueTag = class extends Tag {
4328
+ render(ctx, _emitter) {
4329
+ ctx.continueCalled = true;
4330
+ }
4331
+ };
4332
+ var EchoTag = class extends Tag {
4333
+ constructor(token, remainTokens, liquid) {
4334
+ super(token, remainTokens, liquid);
4335
+ this.tokenizer.skipBlank();
4336
+ if (!this.tokenizer.end()) this.value = new Value(this.tokenizer.readFilteredValue(), this.liquid);
4337
+ }
4338
+ *render(ctx, emitter) {
4339
+ if (!this.value) return;
4340
+ const val = yield toValue(yield this.value.value(ctx, false));
4341
+ emitter.write(val);
4342
+ }
4343
+ *arguments() {
4344
+ if (this.value) yield this.value;
4345
+ }
4346
+ };
4347
+ var LiquidTag = class extends Tag {
4348
+ constructor(token, remainTokens, liquid, parser) {
4349
+ super(token, remainTokens, liquid);
4350
+ const tokens = this.tokenizer.readLiquidTagTokens(this.liquid.options);
4351
+ this.templates = parser.parseTokens(tokens);
4352
+ }
4353
+ *render(ctx, emitter) {
4354
+ yield this.liquid.renderer.renderTemplates(this.templates, ctx, emitter);
4355
+ }
4356
+ *children() {
4357
+ return this.templates;
4358
+ }
4359
+ };
4360
+ var InlineCommentTag = class extends Tag {
4361
+ constructor(tagToken, remainTokens, liquid) {
4362
+ super(tagToken, remainTokens, liquid);
4363
+ if (tagToken.args.search(/\n\s*[^#\s]/g) !== -1) throw new Error("every line of an inline comment must start with a '#' character");
4364
+ }
4365
+ render() {}
4366
+ };
4367
+ const tags = {
4368
+ assign: AssignTag,
4369
+ "for": ForTag,
4370
+ capture: CaptureTag,
4371
+ "case": CaseTag,
4372
+ comment: CommentTag,
4373
+ include: IncludeTag,
4374
+ render: RenderTag,
4375
+ decrement: DecrementTag,
4376
+ increment: IncrementTag,
4377
+ cycle: CycleTag,
4378
+ "if": IfTag,
4379
+ layout: LayoutTag,
4380
+ block: BlockTag,
4381
+ raw: RawTag,
4382
+ tablerow: TablerowTag,
4383
+ unless: UnlessTag,
4384
+ "break": BreakTag,
4385
+ "continue": ContinueTag,
4386
+ echo: EchoTag,
4387
+ liquid: LiquidTag,
4388
+ "#": InlineCommentTag
4389
+ };
4390
+ var Liquid = class Liquid {
4391
+ constructor(opts = {}) {
4392
+ this.renderer = new Render();
4393
+ this.filters = Object.create(null);
4394
+ this.tags = Object.create(null);
4395
+ this.options = normalize(opts);
4396
+ this.parser = new Parser(this);
4397
+ forOwn(tags, (conf, name) => this.registerTag(name, conf));
4398
+ forOwn(filters, (handler, name) => this.registerFilter(name, handler));
4399
+ }
4400
+ parse(html, filepath) {
4401
+ return new Parser(this).parse(html, filepath);
4402
+ }
4403
+ _render(tpl, scope, renderOptions) {
4404
+ const ctx = scope instanceof Context ? scope : new Context(scope, this.options, renderOptions, { liquid: this });
4405
+ return this.renderer.renderTemplates(tpl, ctx);
4406
+ }
4407
+ render(tpl, scope, renderOptions) {
4408
+ return __awaiter(this, void 0, void 0, function* () {
4409
+ return toPromise(this._render(tpl, scope, Object.assign(Object.assign({}, renderOptions), { sync: false })));
4410
+ });
4411
+ }
4412
+ renderSync(tpl, scope, renderOptions) {
4413
+ return toValueSync(this._render(tpl, scope, Object.assign(Object.assign({}, renderOptions), { sync: true })));
4414
+ }
4415
+ renderToNodeStream(tpl, scope, renderOptions = {}) {
4416
+ const ctx = new Context(scope, this.options, renderOptions, { liquid: this });
4417
+ return this.renderer.renderTemplatesToNodeStream(tpl, ctx);
4418
+ }
4419
+ _parseAndRender(html, scope, renderOptions) {
4420
+ const tpl = this.parse(html);
4421
+ return this._render(tpl, scope, renderOptions);
4422
+ }
4423
+ parseAndRender(html, scope, renderOptions) {
4424
+ return __awaiter(this, void 0, void 0, function* () {
4425
+ return toPromise(this._parseAndRender(html, scope, Object.assign(Object.assign({}, renderOptions), { sync: false })));
4426
+ });
4427
+ }
4428
+ parseAndRenderSync(html, scope, renderOptions) {
4429
+ return toValueSync(this._parseAndRender(html, scope, Object.assign(Object.assign({}, renderOptions), { sync: true })));
4430
+ }
4431
+ _parsePartialFile(file, sync, currentFile) {
4432
+ return new Parser(this).parseFile(file, sync, LookupType.Partials, currentFile);
4433
+ }
4434
+ _parseLayoutFile(file, sync, currentFile) {
4435
+ return new Parser(this).parseFile(file, sync, LookupType.Layouts, currentFile);
4436
+ }
4437
+ _parseFile(file, sync, lookupType, currentFile) {
4438
+ return new Parser(this).parseFile(file, sync, lookupType, currentFile);
4439
+ }
4440
+ parseFile(file, lookupType) {
4441
+ return __awaiter(this, void 0, void 0, function* () {
4442
+ return toPromise(new Parser(this).parseFile(file, false, lookupType));
4443
+ });
4444
+ }
4445
+ parseFileSync(file, lookupType) {
4446
+ return toValueSync(new Parser(this).parseFile(file, true, lookupType));
4447
+ }
4448
+ *_renderFile(file, ctx, renderFileOptions) {
4449
+ const templates = yield this._parseFile(file, renderFileOptions.sync, renderFileOptions.lookupType);
4450
+ return yield this._render(templates, ctx, renderFileOptions);
4451
+ }
4452
+ renderFile(file, ctx, renderFileOptions) {
4453
+ return __awaiter(this, void 0, void 0, function* () {
4454
+ return toPromise(this._renderFile(file, ctx, Object.assign(Object.assign({}, renderFileOptions), { sync: false })));
4455
+ });
4456
+ }
4457
+ renderFileSync(file, ctx, renderFileOptions) {
4458
+ return toValueSync(this._renderFile(file, ctx, Object.assign(Object.assign({}, renderFileOptions), { sync: true })));
4459
+ }
4460
+ renderFileToNodeStream(file, scope, renderOptions) {
4461
+ return __awaiter(this, void 0, void 0, function* () {
4462
+ const templates = yield this.parseFile(file);
4463
+ return this.renderToNodeStream(templates, scope, renderOptions);
4464
+ });
4465
+ }
4466
+ _evalValue(str, scope) {
4467
+ const value = new Value(str, this);
4468
+ const ctx = scope instanceof Context ? scope : new Context(scope, this.options, {}, { liquid: this });
4469
+ return value.value(ctx);
4470
+ }
4471
+ evalValue(str, scope) {
4472
+ return __awaiter(this, void 0, void 0, function* () {
4473
+ return toPromise(this._evalValue(str, scope));
4474
+ });
4475
+ }
4476
+ evalValueSync(str, scope) {
4477
+ return toValueSync(this._evalValue(str, scope));
4478
+ }
4479
+ registerFilter(name, filter) {
4480
+ this.filters[name] = filter;
4481
+ }
4482
+ unregisterFilter(name) {
4483
+ delete this.filters[name];
4484
+ }
4485
+ registerTag(name, tag) {
4486
+ this.tags[name] = isFunction(tag) ? tag : createTagClass(tag);
4487
+ }
4488
+ plugin(plugin) {
4489
+ return plugin.call(this, Liquid);
4490
+ }
4491
+ express() {
4492
+ const self = this;
4493
+ let firstCall = true;
4494
+ return function(filePath, ctx, callback) {
4495
+ if (firstCall) {
4496
+ firstCall = false;
4497
+ const dirs = normalizeDirectoryList(this.root);
4498
+ self.options.root.unshift(...dirs);
4499
+ self.options.layouts.unshift(...dirs);
4500
+ self.options.partials.unshift(...dirs);
4501
+ }
4502
+ self.renderFile(filePath, ctx).then((html) => callback(null, html), callback);
4503
+ };
4504
+ }
4505
+ analyze(template, options = {}) {
4506
+ return __awaiter(this, void 0, void 0, function* () {
4507
+ return analyze(template, options);
4508
+ });
4509
+ }
4510
+ analyzeSync(template, options = {}) {
4511
+ return analyzeSync(template, options);
4512
+ }
4513
+ parseAndAnalyze(html, filename, options = {}) {
4514
+ return __awaiter(this, void 0, void 0, function* () {
4515
+ return analyze(this.parse(html, filename), options);
4516
+ });
4517
+ }
4518
+ parseAndAnalyzeSync(html, filename, options = {}) {
4519
+ return analyzeSync(this.parse(html, filename), options);
4520
+ }
4521
+ /** Return an array of all variables without their properties. */
4522
+ variables(template, options = {}) {
4523
+ return __awaiter(this, void 0, void 0, function* () {
4524
+ const analysis = yield analyze(isString(template) ? this.parse(template) : template, options);
4525
+ return Object.keys(analysis.variables);
4526
+ });
4527
+ }
4528
+ /** Return an array of all variables without their properties. */
4529
+ variablesSync(template, options = {}) {
4530
+ const analysis = analyzeSync(isString(template) ? this.parse(template) : template, options);
4531
+ return Object.keys(analysis.variables);
4532
+ }
4533
+ /** Return an array of all variables including their properties/paths. */
4534
+ fullVariables(template, options = {}) {
4535
+ return __awaiter(this, void 0, void 0, function* () {
4536
+ const analysis = yield analyze(isString(template) ? this.parse(template) : template, options);
4537
+ return Array.from(new Set(Object.values(analysis.variables).flatMap((a) => a.map((v) => String(v)))));
4538
+ });
4539
+ }
4540
+ /** Return an array of all variables including their properties/paths. */
4541
+ fullVariablesSync(template, options = {}) {
4542
+ const analysis = analyzeSync(isString(template) ? this.parse(template) : template, options);
4543
+ return Array.from(new Set(Object.values(analysis.variables).flatMap((a) => a.map((v) => String(v)))));
4544
+ }
4545
+ /** Return an array of all variables, each as an array of properties/segments. */
4546
+ variableSegments(template, options = {}) {
4547
+ return __awaiter(this, void 0, void 0, function* () {
4548
+ const analysis = yield analyze(isString(template) ? this.parse(template) : template, options);
4549
+ return Array.from(strictUniq(Object.values(analysis.variables).flatMap((a) => a.map((v) => v.toArray()))));
4550
+ });
4551
+ }
4552
+ /** Return an array of all variables, each as an array of properties/segments. */
4553
+ variableSegmentsSync(template, options = {}) {
4554
+ const analysis = analyzeSync(isString(template) ? this.parse(template) : template, options);
4555
+ return Array.from(strictUniq(Object.values(analysis.variables).flatMap((a) => a.map((v) => v.toArray()))));
4556
+ }
4557
+ /** Return an array of all expected context variables without their properties. */
4558
+ globalVariables(template, options = {}) {
4559
+ return __awaiter(this, void 0, void 0, function* () {
4560
+ const analysis = yield analyze(isString(template) ? this.parse(template) : template, options);
4561
+ return Object.keys(analysis.globals);
4562
+ });
4563
+ }
4564
+ /** Return an array of all expected context variables without their properties. */
4565
+ globalVariablesSync(template, options = {}) {
4566
+ const analysis = analyzeSync(isString(template) ? this.parse(template) : template, options);
4567
+ return Object.keys(analysis.globals);
4568
+ }
4569
+ /** Return an array of all expected context variables including their properties/paths. */
4570
+ globalFullVariables(template, options = {}) {
4571
+ return __awaiter(this, void 0, void 0, function* () {
4572
+ const analysis = yield analyze(isString(template) ? this.parse(template) : template, options);
4573
+ return Array.from(new Set(Object.values(analysis.globals).flatMap((a) => a.map((v) => String(v)))));
4574
+ });
4575
+ }
4576
+ /** Return an array of all expected context variables including their properties/paths. */
4577
+ globalFullVariablesSync(template, options = {}) {
4578
+ const analysis = analyzeSync(isString(template) ? this.parse(template) : template, options);
4579
+ return Array.from(new Set(Object.values(analysis.globals).flatMap((a) => a.map((v) => String(v)))));
4580
+ }
4581
+ /** Return an array of all expected context variables, each as an array of properties/segments. */
4582
+ globalVariableSegments(template, options = {}) {
4583
+ return __awaiter(this, void 0, void 0, function* () {
4584
+ const analysis = yield analyze(isString(template) ? this.parse(template) : template, options);
4585
+ return Array.from(strictUniq(Object.values(analysis.globals).flatMap((a) => a.map((v) => v.toArray()))));
4586
+ });
4587
+ }
4588
+ /** Return an array of all expected context variables, each as an array of properties/segments. */
4589
+ globalVariableSegmentsSync(template, options = {}) {
4590
+ const analysis = analyzeSync(isString(template) ? this.parse(template) : template, options);
4591
+ return Array.from(strictUniq(Object.values(analysis.globals).flatMap((a) => a.map((v) => v.toArray()))));
4592
+ }
4593
+ };
4594
+ /* istanbul ignore file */
4595
+ //#endregion
4596
+ export { Liquid as t };