@farm.js/core 0.1.26 → 0.1.27

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 (171) hide show
  1. package/dist/agent-runtime.d.mts +7 -9
  2. package/dist/agent-runtime.d.ts +7 -9
  3. package/dist/api/client.cjs +3 -3
  4. package/dist/api/client.d.mts +4 -5
  5. package/dist/api/client.d.ts +4 -5
  6. package/dist/api/client.mjs +2 -2
  7. package/dist/api/route-manager.cjs +6 -5
  8. package/dist/api/route-manager.d.mts +6 -8
  9. package/dist/api/route-manager.d.ts +6 -8
  10. package/dist/api/route-manager.mjs +5 -4
  11. package/dist/api/runtime.cjs +10 -4
  12. package/dist/api/runtime.d.mts +35 -3
  13. package/dist/api/runtime.d.ts +35 -3
  14. package/dist/api/runtime.mjs +9 -3
  15. package/dist/{api-client-Cx54IR5g.d.mts → api-client-BjMmY8OD.d.mts} +2 -3
  16. package/dist/{api-client-DykpaKcY.d.ts → api-client-CyFtZFJ4.d.ts} +2 -3
  17. package/dist/api.cjs +9 -8
  18. package/dist/api.d.mts +8 -10
  19. package/dist/api.d.ts +8 -10
  20. package/dist/api.mjs +9 -8
  21. package/dist/{app-29vG5tmY.d.mts → app-BfzZdjgX.d.mts} +3 -4
  22. package/dist/{app-Cx71s_PT.d.ts → app-CXK7Prrt.d.ts} +3 -4
  23. package/dist/app-markdown.cjs +10 -4
  24. package/dist/app-markdown.d.mts +8 -10
  25. package/dist/app-markdown.d.ts +8 -10
  26. package/dist/app-markdown.mjs +9 -3
  27. package/dist/{chunk-74RZNRY6.mjs → chunk-3PTVHMLD.mjs} +1 -1
  28. package/dist/{chunk-OFKG57MZ.mjs → chunk-4FHDV7VM.mjs} +2 -2
  29. package/dist/{chunk-KLSSO6YD.mjs → chunk-4UNKCNSL.mjs} +1 -1
  30. package/dist/chunk-5MKEDGLD.cjs +53 -0
  31. package/dist/{chunk-2CT6XUNO.cjs → chunk-DQMTHWPI.cjs} +4 -4
  32. package/dist/{chunk-ALIFMS4A.cjs → chunk-FOT7LZEO.cjs} +1 -1
  33. package/dist/{chunk-DU2CASV6.mjs → chunk-FPW4W3VW.mjs} +1 -1
  34. package/dist/{chunk-RCYINC4A.cjs → chunk-HF5SIACK.cjs} +3 -3
  35. package/dist/{chunk-ARXCHQLX.mjs → chunk-HG237IEY.mjs} +4 -4
  36. package/dist/{chunk-BD2U4ZL6.cjs → chunk-JQGDQO2I.cjs} +8 -8
  37. package/dist/{chunk-RAI7NULA.mjs → chunk-JT25KHDI.mjs} +1 -1
  38. package/dist/{chunk-WFPRVVF2.cjs → chunk-KAERLFD3.cjs} +16 -11
  39. package/dist/{chunk-H7CJRJ4L.cjs → chunk-LAHZ7LZA.cjs} +16 -16
  40. package/dist/{chunk-JM5GQL4H.mjs → chunk-MBFURXAC.mjs} +1 -1
  41. package/dist/{chunk-QLXEYIAW.cjs → chunk-NPFGGBM5.cjs} +13 -13
  42. package/dist/{chunk-VZWO3XVL.mjs → chunk-O2LV5XDG.mjs} +2 -2
  43. package/dist/chunk-O6XNAMBV.mjs +53 -0
  44. package/dist/{chunk-UXQXGB5A.mjs → chunk-OGHTEYXS.mjs} +11 -10
  45. package/dist/{chunk-OOIL3BWR.mjs → chunk-POXI72VV.mjs} +12 -0
  46. package/dist/{chunk-QGG336NI.mjs → chunk-Q4BHBO6V.mjs} +1 -1
  47. package/dist/{chunk-3WSWXPYM.cjs → chunk-QI7WQSMI.cjs} +4 -4
  48. package/dist/{chunk-PPIW3MH6.mjs → chunk-QQQNJS2E.mjs} +1 -1
  49. package/dist/{chunk-W2HZKYES.cjs → chunk-TDWFCC2T.cjs} +2 -2
  50. package/dist/{chunk-3TQG7CGC.cjs → chunk-UNSKL6BI.cjs} +78 -77
  51. package/dist/{chunk-QPPQHB6X.mjs → chunk-UWTQTZFN.mjs} +17 -11
  52. package/dist/{chunk-YMUH2BLR.mjs → chunk-WIVTGKLY.mjs} +7 -2
  53. package/dist/{chunk-QJ4D3UKJ.cjs → chunk-WJKVTJJR.cjs} +4 -4
  54. package/dist/{chunk-OAVTUMJP.cjs → chunk-YXM74XOW.cjs} +9 -9
  55. package/dist/{chunk-SZ4LYNUX.cjs → chunk-YZBV7733.cjs} +82 -76
  56. package/dist/{chunk-QIH2HD6H.cjs → chunk-ZSO5GWGD.cjs} +33 -21
  57. package/dist/{client-plugins-B8RPJnot.d.mts → client-plugins-1GS4zubE.d.mts} +1799 -1623
  58. package/dist/{client-plugins-bPBf4haK.d.ts → client-plugins-B1Za6F5x.d.ts} +1799 -1623
  59. package/dist/client-plugins.d.mts +7 -9
  60. package/dist/client-plugins.d.ts +7 -9
  61. package/dist/client.cjs +4 -4
  62. package/dist/client.d.mts +9 -11
  63. package/dist/client.d.ts +9 -11
  64. package/dist/client.mjs +3 -3
  65. package/dist/config.d.mts +7 -9
  66. package/dist/config.d.ts +7 -9
  67. package/dist/{devtools-5D4ZDRPR.mjs → devtools-6RN6KHTW.mjs} +6 -3
  68. package/dist/{devtools-QZJEUOJW.cjs → devtools-CQJ3H6MX.cjs} +7 -4
  69. package/dist/docs.cjs +9 -6
  70. package/dist/docs.mjs +8 -5
  71. package/dist/{endpoint-1zA994xL.d.ts → endpoint-CA-TNX60.d.ts} +1 -1
  72. package/dist/{endpoint-DAc96i93.d.mts → endpoint-CCHFqyTE.d.mts} +1 -1
  73. package/dist/index.cjs +21 -20
  74. package/dist/index.d.mts +15 -17
  75. package/dist/index.d.ts +15 -17
  76. package/dist/index.mjs +21 -20
  77. package/dist/{integration-api-BbaiokCC.d.ts → integration-api-0y4FXJpC.d.mts} +128 -1
  78. package/dist/{integration-api-BbaiokCC.d.mts → integration-api-BPJo5oXb.d.ts} +128 -1
  79. package/dist/integrations.d.mts +7 -9
  80. package/dist/integrations.d.ts +7 -9
  81. package/dist/internal/app-markdown-runtime.cjs +9 -3
  82. package/dist/internal/app-markdown-runtime.d.mts +8 -9
  83. package/dist/internal/app-markdown-runtime.d.ts +8 -9
  84. package/dist/internal/app-markdown-runtime.mjs +8 -2
  85. package/dist/internal/build-runtime.cjs +17 -16
  86. package/dist/internal/build-runtime.d.mts +9 -11
  87. package/dist/internal/build-runtime.d.ts +9 -11
  88. package/dist/internal/build-runtime.mjs +16 -15
  89. package/dist/internal/cli-runtime.cjs +8 -5
  90. package/dist/internal/cli-runtime.mjs +7 -4
  91. package/dist/internal/client-error-overlay.cjs +4 -4
  92. package/dist/internal/client-error-overlay.mjs +1 -1
  93. package/dist/internal/compression-runtime.d.mts +7 -9
  94. package/dist/internal/compression-runtime.d.ts +7 -9
  95. package/dist/internal/config-runtime.cjs +7 -4
  96. package/dist/internal/config-runtime.d.mts +8 -10
  97. package/dist/internal/config-runtime.d.ts +8 -10
  98. package/dist/internal/config-runtime.mjs +6 -3
  99. package/dist/internal/product-telemetry-runtime.cjs +2 -2
  100. package/dist/internal/product-telemetry-runtime.mjs +1 -1
  101. package/dist/internal/production-runtime.cjs +7 -5
  102. package/dist/internal/production-runtime.d.mts +12 -14
  103. package/dist/internal/production-runtime.d.ts +12 -14
  104. package/dist/internal/production-runtime.mjs +6 -4
  105. package/dist/markdown.cjs +8 -2
  106. package/dist/markdown.d.mts +35 -153
  107. package/dist/markdown.d.ts +35 -153
  108. package/dist/markdown.mjs +7 -1
  109. package/dist/{metadata-CzBP4Mfp.d.ts → metadata-7LKgQEWF.d.ts} +1 -1
  110. package/dist/{metadata-C3na4CBj.d.mts → metadata-B9mCxKgp.d.mts} +1 -1
  111. package/dist/middleware.d.mts +8 -10
  112. package/dist/middleware.d.ts +8 -10
  113. package/dist/navigation.d.mts +9 -11
  114. package/dist/navigation.d.ts +9 -11
  115. package/dist/{nitro-ZKLGOTVY.mjs → nitro-NAKCRVHX.mjs} +4 -3
  116. package/dist/{nitro-KQDU7CFE.cjs → nitro-VYDZGYFY.cjs} +4 -3
  117. package/dist/plugin.cjs +13 -12
  118. package/dist/plugin.d.mts +8 -10
  119. package/dist/plugin.d.ts +8 -10
  120. package/dist/plugin.mjs +12 -11
  121. package/dist/{production-runtime-CYg4wM4E.d.ts → production-runtime-B3xnY6fI.d.ts} +1 -1
  122. package/dist/{production-runtime-DP94hPGe.d.mts → production-runtime-DramhI0c.d.mts} +1 -1
  123. package/dist/{render-plan-Bl6Fzg5z.d.ts → render-plan-CpW32tOL.d.ts} +1 -1
  124. package/dist/{render-plan-CKAJg0jC.d.mts → render-plan-CtQB-zHS.d.mts} +1 -1
  125. package/dist/renderer-client.d.mts +5 -7
  126. package/dist/renderer-client.d.ts +5 -7
  127. package/dist/{request-CR-Bp1Px.d.ts → request-BVGGeQv4.d.ts} +1 -1
  128. package/dist/{request-CrBCcPZZ.d.mts → request-DlLVBKe3.d.mts} +1 -1
  129. package/dist/request.d.mts +8 -10
  130. package/dist/request.d.ts +8 -10
  131. package/dist/{route-rendering-CZH5FegB.d.ts → route-rendering-BdEldajn.d.ts} +1 -1
  132. package/dist/{route-rendering-C1NAHo-C.d.mts → route-rendering-DChYLNdh.d.mts} +1 -1
  133. package/dist/{router-Cg_kD3Bd.d.ts → router-D0Az-1Nu.d.ts} +1 -1
  134. package/dist/{router-B57eDJ3u.d.mts → router-D5htHn_M.d.mts} +1 -1
  135. package/dist/routes.d.mts +5 -7
  136. package/dist/routes.d.ts +5 -7
  137. package/dist/server-fn-client.d.mts +3 -4
  138. package/dist/server-fn-client.d.ts +3 -4
  139. package/dist/server-fn.d.mts +1 -1
  140. package/dist/server-fn.d.ts +1 -1
  141. package/dist/server-plugins.d.mts +7 -9
  142. package/dist/server-plugins.d.ts +7 -9
  143. package/dist/server-query-client.d.mts +1 -1
  144. package/dist/server-query-client.d.ts +1 -1
  145. package/dist/server-query.d.mts +1 -1
  146. package/dist/server-query.d.ts +1 -1
  147. package/dist/server.cjs +198 -104
  148. package/dist/server.d.mts +12 -14
  149. package/dist/server.d.ts +12 -14
  150. package/dist/server.mjs +184 -90
  151. package/dist/{spa-router-DTdbuinx.d.mts → spa-router-DVfSJZ5o.d.mts} +2 -2
  152. package/dist/{spa-router-BstQUO6Q.d.ts → spa-router-DmwP_7QL.d.ts} +2 -2
  153. package/dist/testing.cjs +6 -5
  154. package/dist/testing.d.mts +6 -8
  155. package/dist/testing.d.ts +6 -8
  156. package/dist/testing.mjs +5 -4
  157. package/dist/{utils-CS3ZLnEJ.d.mts → utils-B_Rmr0-n.d.mts} +1 -1
  158. package/dist/{utils-D3rdsIvM.d.ts → utils-Dv0OuLtF.d.ts} +1 -1
  159. package/dist/version.cjs +2 -2
  160. package/dist/version.mjs +1 -1
  161. package/dist/vite.cjs +13 -12
  162. package/dist/vite.d.mts +7 -9
  163. package/dist/vite.d.ts +7 -9
  164. package/dist/vite.mjs +12 -11
  165. package/package.json +1 -1
  166. package/dist/route-B0XrsrFk.d.mts +0 -128
  167. package/dist/route-DOEpbyWZ.d.ts +0 -128
  168. package/dist/{chunk-GDUYXFIS.mjs → chunk-6EG7U4NF.mjs} +3 -3
  169. package/dist/{chunk-YAOX43YI.cjs → chunk-C7OUJ6JI.cjs} +2 -2
  170. package/dist/{chunk-IXTFU4PL.cjs → chunk-NL3ZSMZB.cjs} +2 -2
  171. package/dist/{chunk-L6V3P73N.mjs → chunk-UOXGA6TO.mjs} +4 -4
@@ -3,6 +3,12 @@
3
3
  var _chunkJ63ZH5OQcjs = require('./chunk-J63ZH5OQ.cjs');
4
4
 
5
5
 
6
+ var _chunk5MKEDGLDcjs = require('./chunk-5MKEDGLD.cjs');
7
+
8
+
9
+ var _chunkI57LW5VZcjs = require('./chunk-I57LW5VZ.cjs');
10
+
11
+
6
12
  var _chunkS3JO3N4Hcjs = require('./chunk-S3JO3N4H.cjs');
7
13
 
8
14
  // src/markdown-view.ts
@@ -392,9 +398,15 @@ async function createMarkdownMirrorResponse(options) {
392
398
  const html = await pageResponse.text();
393
399
  const markdownPath = target.pathname === "/" ? "/index.md" : `${target.pathname}.md`;
394
400
  const actions = extractFarmPageActions(html, pageUrl);
401
+ for (const form of actions) {
402
+ if (!_optionalChain([form, 'access', _11 => _11.action, 'optionalAccess', _12 => _12.startsWith, 'call', _13 => _13("/")])) continue;
403
+ const pathname = new URL(form.action, pageUrl.origin).pathname;
404
+ const tool = _nullishCoalesce(_chunk5MKEDGLDcjs._findFarmMCPEndpointTool.call(void 0, form.method, pathname, options.apiServerBasePath), () => ( _chunk5MKEDGLDcjs._findFarmMCPEndpointTool.call(void 0, form.method, _chunkI57LW5VZcjs.stripFarmBasePath.call(void 0, pathname), options.apiServerBasePath)));
405
+ if (tool) form.tool = tool;
406
+ }
395
407
  const markdown = htmlToMarkdown(html, {
396
- title: _optionalChain([target, 'access', _11 => _11.route, 'optionalAccess', _12 => _12.title]),
397
- includeMetadata: _nullishCoalesce(_optionalChain([options, 'access', _13 => _13.config, 'optionalAccess', _14 => _14.includeMetadata]), () => ( true)),
408
+ title: _optionalChain([target, 'access', _14 => _14.route, 'optionalAccess', _15 => _15.title]),
409
+ includeMetadata: _nullishCoalesce(_optionalChain([options, 'access', _16 => _16.config, 'optionalAccess', _17 => _17.includeMetadata]), () => ( true)),
398
410
  sourcePath: target.pathname,
399
411
  actionsPath: actions.length > 0 ? `${markdownPath}?actions` : void 0
400
412
  });
@@ -406,17 +418,17 @@ async function createMarkdownMirrorResponse(options) {
406
418
  if (!hasMarkdownExtension) {
407
419
  headersOut.set("Vary", "Accept");
408
420
  }
409
- for (const token of _nullishCoalesce(_optionalChain([pageResponse, 'access', _15 => _15.headers, 'access', _16 => _16.get, 'call', _17 => _17("vary"), 'optionalAccess', _18 => _18.split, 'call', _19 => _19(",")]), () => ( []))) {
421
+ for (const token of _nullishCoalesce(_optionalChain([pageResponse, 'access', _18 => _18.headers, 'access', _19 => _19.get, 'call', _20 => _20("vary"), 'optionalAccess', _21 => _21.split, 'call', _22 => _22(",")]), () => ( []))) {
410
422
  const name = token.trim();
411
423
  if (name && name.toLowerCase() !== "accept") appendHeaderToken(headersOut, "Vary", name);
412
424
  }
413
425
  const pageCacheControl = pageResponse.headers.get("cache-control");
414
- const cache = _nullishCoalesce(_nullishCoalesce(_optionalChain([target, 'access', _20 => _20.route, 'optionalAccess', _21 => _21.cache]), () => ( _optionalChain([options, 'access', _22 => _22.config, 'optionalAccess', _23 => _23.cache]))), () => ( false));
426
+ const cache = _nullishCoalesce(_nullishCoalesce(_optionalChain([target, 'access', _23 => _23.route, 'optionalAccess', _24 => _24.cache]), () => ( _optionalChain([options, 'access', _25 => _25.config, 'optionalAccess', _26 => _26.cache]))), () => ( false));
415
427
  headersOut.set(
416
428
  "Cache-Control",
417
429
  pageCacheControl && isPrivateCacheControl(pageCacheControl) ? pageCacheControl : createMarkdownCacheHeader(cache)
418
430
  );
419
- const robots = [pageResponse.headers.get("x-robots-tag"), readHtmlMetaContent(html, "robots")].filter((value) => Boolean(_optionalChain([value, 'optionalAccess', _24 => _24.trim, 'call', _25 => _25()]))).join(", ");
431
+ const robots = [pageResponse.headers.get("x-robots-tag"), readHtmlMetaContent(html, "robots")].filter((value) => Boolean(_optionalChain([value, 'optionalAccess', _27 => _27.trim, 'call', _28 => _28()]))).join(", ");
420
432
  if (robots) headersOut.set("X-Robots-Tag", robots);
421
433
  const canonical = readHtmlCanonicalHref(html);
422
434
  if (canonical) {
@@ -673,7 +685,7 @@ function getFarmMarkdownAlternatePath(config, pathname) {
673
685
  }
674
686
  _chunkS3JO3N4Hcjs.__name.call(void 0, getFarmMarkdownAlternatePath, "getFarmMarkdownAlternatePath");
675
687
  function isFarmMarkdownMirrorExposed(config, pathname) {
676
- if (!_optionalChain([config, 'optionalAccess', _26 => _26.enabled])) return false;
688
+ if (!_optionalChain([config, 'optionalAccess', _29 => _29.enabled])) return false;
677
689
  return config.expose === true || findExposedMarkdownRoute(config, pathname) !== null;
678
690
  }
679
691
  _chunkS3JO3N4Hcjs.__name.call(void 0, isFarmMarkdownMirrorExposed, "isFarmMarkdownMirrorExposed");
@@ -766,7 +778,7 @@ function extractHtmlBody(html) {
766
778
  const body = rootMatch ? rootMatch[1] : bodyMatch ? bodyMatch[1] : html;
767
779
  const main = extractFirstElementContent(body, ["main"]);
768
780
  if (main !== void 0) return main;
769
- const articles = _nullishCoalesce(_optionalChain([body, 'access', _27 => _27.match, 'call', _28 => _28(/<article\b/gi), 'optionalAccess', _29 => _29.length]), () => ( 0));
781
+ const articles = _nullishCoalesce(_optionalChain([body, 'access', _30 => _30.match, 'call', _31 => _31(/<article\b/gi), 'optionalAccess', _32 => _32.length]), () => ( 0));
770
782
  return articles === 1 ? _nullishCoalesce(extractFirstElementContent(body, ["article"]), () => ( body)) : body;
771
783
  }
772
784
  _chunkS3JO3N4Hcjs.__name.call(void 0, extractHtmlBody, "extractHtmlBody");
@@ -782,7 +794,7 @@ function extractFirstElementContent(html, tagNames) {
782
794
  _chunkS3JO3N4Hcjs.__name.call(void 0, extractFirstElementContent, "extractFirstElementContent");
783
795
  function readHtmlMetaContent(html, name) {
784
796
  for (const match of html.matchAll(/<meta\b([^>]*)>/gi)) {
785
- if (_optionalChain([readHtmlAttribute, 'call', _30 => _30(match[1], "name"), 'optionalAccess', _31 => _31.toLowerCase, 'call', _32 => _32()]) === name) {
797
+ if (_optionalChain([readHtmlAttribute, 'call', _33 => _33(match[1], "name"), 'optionalAccess', _34 => _34.toLowerCase, 'call', _35 => _35()]) === name) {
786
798
  return readHtmlAttribute(match[1], "content");
787
799
  }
788
800
  }
@@ -791,8 +803,8 @@ function readHtmlMetaContent(html, name) {
791
803
  _chunkS3JO3N4Hcjs.__name.call(void 0, readHtmlMetaContent, "readHtmlMetaContent");
792
804
  function readHtmlCanonicalHref(html) {
793
805
  for (const match of html.matchAll(/<link\b([^>]*)>/gi)) {
794
- const rel = _optionalChain([readHtmlAttribute, 'call', _33 => _33(match[1], "rel"), 'optionalAccess', _34 => _34.toLowerCase, 'call', _35 => _35(), 'access', _36 => _36.split, 'call', _37 => _37(/\s+/)]);
795
- if (_optionalChain([rel, 'optionalAccess', _38 => _38.includes, 'call', _39 => _39("canonical")])) return readHtmlAttribute(match[1], "href");
806
+ const rel = _optionalChain([readHtmlAttribute, 'call', _36 => _36(match[1], "rel"), 'optionalAccess', _37 => _37.toLowerCase, 'call', _38 => _38(), 'access', _39 => _39.split, 'call', _40 => _40(/\s+/)]);
807
+ if (_optionalChain([rel, 'optionalAccess', _41 => _41.includes, 'call', _42 => _42("canonical")])) return readHtmlAttribute(match[1], "href");
796
808
  }
797
809
  return void 0;
798
810
  }
@@ -819,7 +831,7 @@ function extractFarmPageActions(html, pageUrl) {
819
831
  }
820
832
  _chunkS3JO3N4Hcjs.__name.call(void 0, extractFarmPageActions, "extractFarmPageActions");
821
833
  function readPageForm(attributes, content, pageUrl, labelsFor) {
822
- const method = _optionalChain([readDecodedAttribute, 'call', _40 => _40(attributes, "method"), 'optionalAccess', _41 => _41.trim, 'call', _42 => _42(), 'access', _43 => _43.toLowerCase, 'call', _44 => _44()]);
834
+ const method = _optionalChain([readDecodedAttribute, 'call', _43 => _43(attributes, "method"), 'optionalAccess', _44 => _44.trim, 'call', _45 => _45(), 'access', _46 => _46.toLowerCase, 'call', _47 => _47()]);
823
835
  if (method === "dialog") return void 0;
824
836
  const target = resolveFormTarget(readDecodedAttribute(attributes, "action"), pageUrl);
825
837
  const form = {
@@ -829,11 +841,11 @@ function readPageForm(attributes, content, pageUrl, labelsFor) {
829
841
  submit: []
830
842
  };
831
843
  const name = _nullishCoalesce(_nullishCoalesce(readDecodedAttribute(attributes, "aria-label"), () => ( readDecodedAttribute(attributes, "name"))), () => ( readDecodedAttribute(attributes, "id")));
832
- if (_optionalChain([name, 'optionalAccess', _45 => _45.trim, 'call', _46 => _46()])) form.name = name.trim();
844
+ if (_optionalChain([name, 'optionalAccess', _48 => _48.trim, 'call', _49 => _49()])) form.name = name.trim();
833
845
  if (target) form.action = target;
834
846
  else form.requiresJavaScript = true;
835
847
  if (form.method === "POST") {
836
- const enctype = _optionalChain([readDecodedAttribute, 'call', _47 => _47(attributes, "enctype"), 'optionalAccess', _48 => _48.trim, 'call', _49 => _49(), 'access', _50 => _50.toLowerCase, 'call', _51 => _51()]);
848
+ const enctype = _optionalChain([readDecodedAttribute, 'call', _50 => _50(attributes, "enctype"), 'optionalAccess', _51 => _51.trim, 'call', _52 => _52(), 'access', _53 => _53.toLowerCase, 'call', _54 => _54()]);
837
849
  form.enctype = enctype && FORM_ENCTYPES.has(enctype) ? enctype : "application/x-www-form-urlencoded";
838
850
  }
839
851
  const wrappingLabels = [...content.matchAll(/<label\b[^>]*>([\s\S]*?)<\/label>/gi)].map(
@@ -844,13 +856,13 @@ function readPageForm(attributes, content, pageUrl, labelsFor) {
844
856
  })
845
857
  );
846
858
  const labelOf = /* @__PURE__ */ _chunkS3JO3N4Hcjs.__name.call(void 0, (controlAttributes, index) => {
847
- const aria = _optionalChain([readDecodedAttribute, 'call', _52 => _52(controlAttributes, "aria-label"), 'optionalAccess', _53 => _53.trim, 'call', _54 => _54()]);
859
+ const aria = _optionalChain([readDecodedAttribute, 'call', _55 => _55(controlAttributes, "aria-label"), 'optionalAccess', _56 => _56.trim, 'call', _57 => _57()]);
848
860
  if (aria) return aria;
849
861
  const id = readDecodedAttribute(controlAttributes, "id");
850
862
  const forLabel = id ? labelsFor.get(id) : void 0;
851
863
  if (forLabel) return forLabel;
852
864
  const wrapping = wrappingLabels.find((label) => label.start < index && index < label.end);
853
- return _optionalChain([wrapping, 'optionalAccess', _55 => _55.text]) || void 0;
865
+ return _optionalChain([wrapping, 'optionalAccess', _58 => _58.text]) || void 0;
854
866
  }, "labelOf");
855
867
  const groups = /* @__PURE__ */ new Map();
856
868
  const controls = /<(input)\b([^>]*)>|<(select|textarea|button)\b([^>]*)>([\s\S]*?)<\/\3>/gi;
@@ -861,7 +873,7 @@ function readPageForm(attributes, content, pageUrl, labelsFor) {
861
873
  if (hasHtmlAttribute(controlAttributes, "disabled")) continue;
862
874
  const label = labelOf(controlAttributes, match.index);
863
875
  const fieldName = readDecodedAttribute(controlAttributes, "name");
864
- const typeAttribute = _optionalChain([readDecodedAttribute, 'call', _56 => _56(controlAttributes, "type"), 'optionalAccess', _57 => _57.trim, 'call', _58 => _58(), 'access', _59 => _59.toLowerCase, 'call', _60 => _60()]);
876
+ const typeAttribute = _optionalChain([readDecodedAttribute, 'call', _59 => _59(controlAttributes, "type"), 'optionalAccess', _60 => _60.trim, 'call', _61 => _61(), 'access', _62 => _62.toLowerCase, 'call', _63 => _63()]);
865
877
  const type = tag === "input" ? _nullishCoalesce(typeAttribute, () => ( "text")) : tag === "button" ? _nullishCoalesce(typeAttribute, () => ( "submit")) : tag;
866
878
  if (tag === "button" && !["button", "reset"].includes(type) || tag === "input" && (type === "submit" || type === "image")) {
867
879
  const submit = {
@@ -875,7 +887,7 @@ function readPageForm(attributes, content, pageUrl, labelsFor) {
875
887
  const resolved = resolveFormTarget(formAction, pageUrl);
876
888
  if (resolved) submit.action = resolved;
877
889
  }
878
- const formMethod = _optionalChain([readDecodedAttribute, 'call', _61 => _61(controlAttributes, "formmethod"), 'optionalAccess', _62 => _62.toLowerCase, 'call', _63 => _63()]);
890
+ const formMethod = _optionalChain([readDecodedAttribute, 'call', _64 => _64(controlAttributes, "formmethod"), 'optionalAccess', _65 => _65.toLowerCase, 'call', _66 => _66()]);
879
891
  if (formMethod === "get" || formMethod === "post") submit.method = formMethod.toUpperCase();
880
892
  form.submit.push(submit);
881
893
  continue;
@@ -954,7 +966,7 @@ _chunkS3JO3N4Hcjs.__name.call(void 0, readPageForm, "readPageForm");
954
966
  function resolveFormTarget(action, pageUrl) {
955
967
  let target;
956
968
  try {
957
- target = new URL(_optionalChain([action, 'optionalAccess', _64 => _64.trim, 'call', _65 => _65()]) || pageUrl.href, pageUrl);
969
+ target = new URL(_optionalChain([action, 'optionalAccess', _67 => _67.trim, 'call', _68 => _68()]) || pageUrl.href, pageUrl);
958
970
  } catch (e4) {
959
971
  return void 0;
960
972
  }
@@ -986,7 +998,7 @@ function readHtmlAttribute(attributes, name) {
986
998
  _chunkS3JO3N4Hcjs.__name.call(void 0, readHtmlAttribute, "readHtmlAttribute");
987
999
  function readCodeLanguage(attributesList) {
988
1000
  for (const attributes of attributesList) {
989
- const language = _nullishCoalesce(_nullishCoalesce(readHtmlAttribute(attributes, "data-language"), () => ( readHtmlAttribute(attributes, "data-lang"))), () => ( _optionalChain([readHtmlAttribute, 'call', _66 => _66(attributes, "class"), 'optionalAccess', _67 => _67.match, 'call', _68 => _68(/(?:^|\s)lang(?:uage)?-(\S+)/), 'optionalAccess', _69 => _69[1]])));
1001
+ const language = _nullishCoalesce(_nullishCoalesce(readHtmlAttribute(attributes, "data-language"), () => ( readHtmlAttribute(attributes, "data-lang"))), () => ( _optionalChain([readHtmlAttribute, 'call', _69 => _69(attributes, "class"), 'optionalAccess', _70 => _70.match, 'call', _71 => _71(/(?:^|\s)lang(?:uage)?-(\S+)/), 'optionalAccess', _72 => _72[1]])));
990
1002
  if (language && /^[\w#+.-]+$/.test(language)) return language;
991
1003
  }
992
1004
  return void 0;
@@ -1099,7 +1111,7 @@ function matchClosingTags(html) {
1099
1111
  while (match = tags.exec(html)) {
1100
1112
  const name = match[2].toLowerCase();
1101
1113
  if (match[1]) {
1102
- const start = _optionalChain([open, 'access', _70 => _70.get, 'call', _71 => _71(name), 'optionalAccess', _72 => _72.pop, 'call', _73 => _73()]);
1114
+ const start = _optionalChain([open, 'access', _73 => _73.get, 'call', _74 => _74(name), 'optionalAccess', _75 => _75.pop, 'call', _76 => _76()]);
1103
1115
  if (start !== void 0) closes.set(start, match.index + match[0].length);
1104
1116
  } else if (!VOID_TAGS.has(name) && !isSelfClosingTag(match[0])) {
1105
1117
  let starts = open.get(name);
@@ -1134,7 +1146,7 @@ function resolveStreamedBoundaries(html, { boundaries, placeholders }) {
1134
1146
  let cursor = 0;
1135
1147
  let match;
1136
1148
  while (match = openingTag.exec(html)) {
1137
- const id = _optionalChain([/\sid="([^"]*)"/, 'access', _74 => _74.exec, 'call', _75 => _75(match[2]), 'optionalAccess', _76 => _76[1]]);
1149
+ const id = _optionalChain([/\sid="([^"]*)"/, 'access', _77 => _77.exec, 'call', _78 => _78(match[2]), 'optionalAccess', _79 => _79[1]]);
1138
1150
  if (!id || !wanted.has(id) || segments.has(id)) continue;
1139
1151
  const close = closingTags.get(match.index);
1140
1152
  if (close === void 0) continue;