@maincode-ai/matilda-code 0.21.11 → 0.21.13-nightly.20261026.e0eae1d8c

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 (200) hide show
  1. package/bundled/mainy/SKILL.md +0 -2
  2. package/bundled/mainy/docs/_meta.ts +0 -2
  3. package/bundled/mainy/docs/configuration/auth.md +5 -10
  4. package/bundled/mainy/docs/configuration/model-providers.md +31 -217
  5. package/bundled/mainy/docs/configuration/settings.md +48 -9
  6. package/bundled/mainy/docs/configuration/trusted-folders.md +12 -6
  7. package/bundled/mainy/docs/features/auto-mode.md +1 -1
  8. package/bundled/mainy/docs/features/channels/_meta.ts +0 -3
  9. package/bundled/mainy/docs/features/channels/overview.md +8 -16
  10. package/bundled/mainy/docs/features/commands.md +4 -4
  11. package/bundled/mainy/docs/features/hooks.md +9 -7
  12. package/bundled/mainy/docs/features/language.md +2 -29
  13. package/bundled/mainy/docs/features/sub-agents.md +1 -1
  14. package/bundled/mainy/docs/features/worktree.md +3 -5
  15. package/bundled/mainy/docs/integration-github-action.md +3 -3
  16. package/bundled/mainy/docs/matilda-serve.md +1 -1
  17. package/bundled/mainy/docs/quickstart.md +2 -2
  18. package/bundled/mainy/docs/support/troubleshooting.md +3 -10
  19. package/chunks/agent-4FTU3WN6.js +3 -0
  20. package/chunks/agent-headless-QJUVHPFC.js +3 -0
  21. package/chunks/{askUserQuestion-XWHJY3DM.js → askUserQuestion-QKX4NEFX.js} +1 -1
  22. package/chunks/{ca-EUJBUYX5.js → ca-C2V7I65K.js} +6 -6
  23. package/chunks/{chunk-T4P4KEDW.js → chunk-2ONZZ46N.js} +2 -2
  24. package/chunks/chunk-36K4HBVM.js +7 -0
  25. package/chunks/{chunk-EQGA7LH7.js → chunk-3B2HABK7.js} +1 -1
  26. package/chunks/{chunk-5427BPR2.js → chunk-5NMK4Y7C.js} +1 -1
  27. package/chunks/chunk-5YT4GCK7.js +14 -0
  28. package/chunks/{chunk-MH2P4YXC.js → chunk-62AFAL4I.js} +10 -10
  29. package/chunks/chunk-75KP2FVD.js +81 -0
  30. package/chunks/chunk-7ZODGQO6.js +4 -0
  31. package/chunks/chunk-BZB7HYRC.js +37 -0
  32. package/chunks/{chunk-WHG6N5X2.js → chunk-EXNHJQCD.js} +1 -1
  33. package/chunks/chunk-FCGYRGV4.js +9 -0
  34. package/chunks/chunk-G4YMVWG4.js +8 -0
  35. package/chunks/{chunk-4FVBPNTZ.js → chunk-HDARIAVM.js} +1 -1
  36. package/chunks/{chunk-4YVN5HXG.js → chunk-HM5LCKDB.js} +2 -2
  37. package/chunks/chunk-IIQ5YERM.js +120 -0
  38. package/chunks/chunk-JGJ7BVZN.js +101 -0
  39. package/chunks/{chunk-FFFZ2QMG.js → chunk-JIKQI4MZ.js} +1 -1
  40. package/chunks/{chunk-SPW5DXX4.js → chunk-LHDCAN7Z.js} +1 -1
  41. package/chunks/chunk-LZDHANXA.js +89 -0
  42. package/chunks/{chunk-ELH4YHJR.js → chunk-NOE4UNQN.js} +1 -1
  43. package/chunks/chunk-OEZS5R3S.js +207 -0
  44. package/chunks/{chunk-OOEH6ZSV.js → chunk-PTMCLADZ.js} +1 -1
  45. package/chunks/{chunk-NYEWHSBL.js → chunk-PYZNGIIR.js} +1 -1
  46. package/chunks/chunk-QJJTUDDA.js +56 -0
  47. package/chunks/{chunk-GO2GA2GY.js → chunk-R34HYLL4.js} +1 -1
  48. package/chunks/{chunk-Q55AVE2N.js → chunk-RK4LPGBV.js} +11 -11
  49. package/chunks/{chunk-JXUDKX6D.js → chunk-RYHMPK5G.js} +1 -1
  50. package/chunks/chunk-SR7ARGUY.js +13 -0
  51. package/chunks/chunk-SY6JRCN3.js +2612 -0
  52. package/chunks/chunk-TUKNB5CQ.js +33 -0
  53. package/chunks/{chunk-YMIF2DMT.js → chunk-TZ4FRU6B.js} +1 -1
  54. package/chunks/chunk-U7V7APDV.js +9 -0
  55. package/chunks/{chunk-SNLH42QJ.js → chunk-UVWZ44ZW.js} +1 -1
  56. package/chunks/{chunk-HYVP4472.js → chunk-V6UPUMP3.js} +1 -1
  57. package/chunks/{chunk-4CSSDBOS.js → chunk-VLDZBRTL.js} +10 -10
  58. package/chunks/{computer-use-SXP25RZQ.js → computer-use-OXAMR75N.js} +1 -1
  59. package/chunks/contextCommand-ERLW5VWL.js +3 -0
  60. package/chunks/{cron-create-2UI4AT4Q.js → cron-create-AUDQ6STP.js} +1 -1
  61. package/chunks/{cron-delete-ZB6BOTFF.js → cron-delete-P5HE3PDD.js} +1 -1
  62. package/chunks/{cron-list-YYAXNHB6.js → cron-list-NR5FZBK2.js} +1 -1
  63. package/chunks/{de-DNEPG7S7.js → de-KOUI2CEW.js} +6 -6
  64. package/chunks/{devtools-5JRKK3E7.js → devtools-G5DWLP2N.js} +1 -1
  65. package/chunks/dist-XXTQNTKQ.js +42 -0
  66. package/chunks/dist-ZFZZLIQU.js +3 -0
  67. package/chunks/edit-REFR5ROS.js +43 -0
  68. package/chunks/{en-NOD6KQNM.js → en-RMYRLXC2.js} +4 -4
  69. package/chunks/{enter-worktree-X47BSJLE.js → enter-worktree-WO3DT2G7.js} +1 -1
  70. package/chunks/{enterPlanMode-F22ZNTYJ.js → enterPlanMode-PLRHEU5A.js} +1 -1
  71. package/chunks/{exit-worktree-XY5UMDHX.js → exit-worktree-J5PW6DCV.js} +1 -1
  72. package/chunks/exitPlanMode-KXUPNLCJ.js +120 -0
  73. package/chunks/{fr-2OE5WLJ4.js → fr-R3QF3LA2.js} +5 -5
  74. package/chunks/glob-ZVTVRDQO.js +22 -0
  75. package/chunks/{goal-tools-6QTC3UI7.js → goal-tools-XVKQJL5I.js} +1 -1
  76. package/chunks/{grep-6TTPZ524.js → grep-R7CWUNNE.js} +1 -1
  77. package/chunks/{ja-3B6V5KS7.js → ja-A5OQLXUZ.js} +6 -6
  78. package/chunks/{keychain-token-storage-54BNK6VH.js → keychain-token-storage-IM4UB4P4.js} +1 -1
  79. package/chunks/{ls-YWZU3FYL.js → ls-DEAFYDVV.js} +1 -1
  80. package/chunks/{lsp-4CJDKEEC.js → lsp-DL7W47VY.js} +1 -1
  81. package/chunks/matildaAgentContentGenerator-57EIU5XE.js +8 -0
  82. package/chunks/mcp-client-X7LEGSP3.js +3 -0
  83. package/chunks/monitor-KPWTMH3V.js +32 -0
  84. package/chunks/{multipart-parser-JI75T2O5.js → multipart-parser-FKHYAVGR.js} +1 -1
  85. package/chunks/notebook-edit-3ZH5M2TC.js +17 -0
  86. package/chunks/openaiContentGenerator-6PXSD3T7.js +37 -0
  87. package/chunks/{pt-KP2JCPUY.js → pt-RG3S3KA7.js} +6 -6
  88. package/chunks/read-file-JNS7WRUP.js +3 -0
  89. package/chunks/ripGrep-ICJDGIIV.js +3 -0
  90. package/chunks/{ru-K7IQQKHC.js → ru-5S5HLRT7.js} +5 -5
  91. package/chunks/scheduler-QC2PPMFP.js +8 -0
  92. package/chunks/{send-message-OO2HAKCC.js → send-message-V2WYLN5X.js} +1 -1
  93. package/chunks/{serve-ZQX2WBLF.js → serve-NUVQULZJ.js} +59 -48
  94. package/chunks/shell-5LNI7URE.js +3 -0
  95. package/chunks/{skill-KDM3UUML.js → skill-QFATRHQW.js} +1 -1
  96. package/chunks/src-6UPZ7TVB.js +3 -0
  97. package/chunks/src-LZEU4AYF.js +5 -0
  98. package/chunks/{symbol-search-ALYOX5JN.js → symbol-search-WL6ZHUUN.js} +1 -1
  99. package/chunks/{syntheticOutput-UASKABJH.js → syntheticOutput-3KW6SQAF.js} +1 -1
  100. package/chunks/task-create-PNW5SN27.js +3 -0
  101. package/chunks/{task-detach-I67ZE5MX.js → task-detach-B7PDPFBA.js} +1 -1
  102. package/chunks/task-list-GGZATGK5.js +9 -0
  103. package/chunks/{task-stop-ERI5X4AO.js → task-stop-UKBBE2KG.js} +1 -1
  104. package/chunks/{task-update-CD3W556L.js → task-update-4RHVUBUV.js} +1 -1
  105. package/chunks/{team-create-F4KQRGMB.js → team-create-2TJC3X57.js} +1 -1
  106. package/chunks/team-delete-4UJ7SU65.js +8 -0
  107. package/chunks/todoWrite-NEBVKOSG.js +3 -0
  108. package/chunks/{tool-search-JFCD5W5M.js → tool-search-R5GS64YR.js} +1 -1
  109. package/chunks/tree-sitter-bash-2SWKO5B7.js +3 -0
  110. package/chunks/{web-fetch-REWGIRWQ.js → web-fetch-H3XJMAEF.js} +17 -17
  111. package/chunks/{web-search-OX2DPEVN.js → web-search-Q6RWPEIB.js} +1 -1
  112. package/chunks/{workflow-SEFYGBED.js → workflow-3A7KN3E3.js} +2 -2
  113. package/chunks/write-file-O7Q6SKZC.js +15 -0
  114. package/cli.js +509 -495
  115. package/locales/ca.js +2 -28
  116. package/locales/de.js +2 -28
  117. package/locales/en.js +2 -30
  118. package/locales/fr.js +2 -30
  119. package/locales/ja.js +2 -28
  120. package/locales/pt.js +2 -28
  121. package/locales/ru.js +2 -28
  122. package/package.json +2 -2
  123. package/sandbox-macos-permissive-closed.sb +0 -1
  124. package/sandbox-macos-permissive-open.sb +0 -1
  125. package/sandbox-macos-permissive-proxied.sb +0 -1
  126. package/sandbox-macos-restrictive-closed.sb +3 -1
  127. package/sandbox-macos-restrictive-open.sb +3 -1
  128. package/sandbox-macos-restrictive-proxied.sb +3 -1
  129. package/bundled/mainy/docs/features/channels/dingtalk.md +0 -134
  130. package/bundled/mainy/docs/features/channels/feishu.md +0 -186
  131. package/bundled/mainy/docs/features/channels/weixin.md +0 -106
  132. package/bundled/mainy/docs/integration-jetbrains.md +0 -81
  133. package/bundled/mainy/docs/integration-zed.md +0 -72
  134. package/chunks/agent-ZFZ4HJQC.js +0 -3
  135. package/chunks/agent-headless-KH2BKLP7.js +0 -3
  136. package/chunks/anthropicContentGenerator-IYZILRDW.js +0 -39
  137. package/chunks/chunk-25NCTG5H.js +0 -184
  138. package/chunks/chunk-2HQMJ2IU.js +0 -8
  139. package/chunks/chunk-3YLXGE6T.js +0 -8
  140. package/chunks/chunk-4F4DA5UI.js +0 -8
  141. package/chunks/chunk-4J6DC24J.js +0 -59
  142. package/chunks/chunk-4Q2SNBUH.js +0 -18
  143. package/chunks/chunk-6GBNB5Z2.js +0 -3
  144. package/chunks/chunk-G7R2XEEF.js +0 -7
  145. package/chunks/chunk-GHBKFIHC.js +0 -35
  146. package/chunks/chunk-GUFIMKF5.js +0 -65
  147. package/chunks/chunk-HWOQNYAO.js +0 -27
  148. package/chunks/chunk-LJR4RZZ2.js +0 -3
  149. package/chunks/chunk-NIQK6NX3.js +0 -37
  150. package/chunks/chunk-NVM7W7TG.js +0 -101
  151. package/chunks/chunk-O44XK65C.js +0 -8
  152. package/chunks/chunk-OA56BXPD.js +0 -3
  153. package/chunks/chunk-ODZOYHIC.js +0 -8
  154. package/chunks/chunk-PA6532AY.js +0 -6
  155. package/chunks/chunk-QFNFLE2I.js +0 -2625
  156. package/chunks/chunk-QH7736R5.js +0 -8
  157. package/chunks/chunk-QN6WSWMM.js +0 -9
  158. package/chunks/chunk-QN6Y6NPA.js +0 -3
  159. package/chunks/chunk-RK2AKQAX.js +0 -39
  160. package/chunks/chunk-SDTWBD62.js +0 -8
  161. package/chunks/chunk-SUH3UUWZ.js +0 -25
  162. package/chunks/chunk-U347OO7S.js +0 -9
  163. package/chunks/chunk-UIRBHC5X.js +0 -3
  164. package/chunks/chunk-VI74YQQO.js +0 -8
  165. package/chunks/chunk-VYZOOSMP.js +0 -30
  166. package/chunks/chunk-W5CGKUM4.js +0 -15
  167. package/chunks/chunk-WRQLIPXW.js +0 -113
  168. package/chunks/chunk-WVY2P6WH.js +0 -26
  169. package/chunks/chunk-WZ75OGYY.js +0 -14
  170. package/chunks/chunk-XCFLI3OC.js +0 -9
  171. package/chunks/chunk-XMZIY7XX.js +0 -13
  172. package/chunks/contextCommand-3GN5CAOK.js +0 -3
  173. package/chunks/dist-7UYRLSLE.js +0 -3
  174. package/chunks/dist-ME6647DQ.js +0 -195
  175. package/chunks/dist-P6SLWL5V.js +0 -42
  176. package/chunks/dist-VG3ZDJ2A.js +0 -28
  177. package/chunks/dist-YTCHM57U.js +0 -23
  178. package/chunks/edit-KX6V4PH3.js +0 -39
  179. package/chunks/exitPlanMode-G3QLIWJ4.js +0 -90
  180. package/chunks/fileFromPath-7UCWPD4W.js +0 -3
  181. package/chunks/geminiContentGenerator-EQEGOXOV.js +0 -8
  182. package/chunks/glob-KSBEWI3E.js +0 -22
  183. package/chunks/matildaAgentContentGenerator-OV4U6DJD.js +0 -8
  184. package/chunks/matildaContentGenerator-ETIAWE22.js +0 -8
  185. package/chunks/matildaOAuth2-WOY7ZS43.js +0 -3
  186. package/chunks/monitor-F4K5HOZX.js +0 -32
  187. package/chunks/notebook-edit-TL7CI5EA.js +0 -17
  188. package/chunks/openaiContentGenerator-MGASUFQL.js +0 -3
  189. package/chunks/read-file-6EAPS2KG.js +0 -3
  190. package/chunks/ripGrep-K6SFFUIE.js +0 -3
  191. package/chunks/scheduler-TKWPD4LP.js +0 -8
  192. package/chunks/shell-AZRK5GIO.js +0 -3
  193. package/chunks/src-SGI6VLOS.js +0 -3
  194. package/chunks/src-WZTRMETQ.js +0 -5
  195. package/chunks/task-create-EBJD55TB.js +0 -3
  196. package/chunks/task-list-5BGX4G5N.js +0 -9
  197. package/chunks/team-delete-5U3GBFKJ.js +0 -8
  198. package/chunks/todoWrite-YGG6AZ3A.js +0 -3
  199. package/chunks/tree-sitter-bash-XNCMPQBK.js +0 -3
  200. package/chunks/write-file-UAGVBZMC.js +0 -15
@@ -1,8 +0,0 @@
1
- // Force strict mode and setup for ESM
2
- "use strict";
3
- import{b as r}from"./chunk-GZPNIYVZ.js";import{a as s,d as c}from"./chunk-OWGSC52X.js";var a=c((i,t)=>{r();if(!globalThis.DOMException)try{let{MessageChannel:e}=s("worker_threads"),n=new e().port1,o=new ArrayBuffer;n.postMessage(o,[o,o])}catch(e){e.constructor.name==="DOMException"&&(globalThis.DOMException=e.constructor)}t.exports=globalThis.DOMException});export{a};
4
- /*! Bundled license information:
5
-
6
- node-domexception/index.js:
7
- (*! node-domexception. MIT License. Jimmy Wärting <https://jimmy.warting.se/opensource> *)
8
- */
@@ -1,3 +0,0 @@
1
- // Force strict mode and setup for ESM
2
- "use strict";
3
- import{b as o}from"./chunk-GZPNIYVZ.js";import{d as f}from"./chunk-OWGSC52X.js";var g=f((M,d)=>{o();var n=1e3,t=n*60,c=t*60,a=c*24,m=a*7,y=a*365.25;d.exports=function(e,r){r=r||{};var s=typeof e;if(s==="string"&&e.length>0)return l(e);if(s==="number"&&isFinite(e))return r.long?w(e):v(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))};function l(e){if(e=String(e),!(e.length>100)){var r=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(r){var s=parseFloat(r[1]),i=(r[2]||"ms").toLowerCase();switch(i){case"years":case"year":case"yrs":case"yr":case"y":return s*y;case"weeks":case"week":case"w":return s*m;case"days":case"day":case"d":return s*a;case"hours":case"hour":case"hrs":case"hr":case"h":return s*c;case"minutes":case"minute":case"mins":case"min":case"m":return s*t;case"seconds":case"second":case"secs":case"sec":case"s":return s*n;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return s;default:return}}}}function v(e){var r=Math.abs(e);return r>=a?Math.round(e/a)+"d":r>=c?Math.round(e/c)+"h":r>=t?Math.round(e/t)+"m":r>=n?Math.round(e/n)+"s":e+"ms"}function w(e){var r=Math.abs(e);return r>=a?u(e,r,a,"day"):r>=c?u(e,r,c,"hour"):r>=t?u(e,r,t,"minute"):r>=n?u(e,r,n,"second"):e+" ms"}function u(e,r,s,i){var h=r>=s*1.5;return Math.round(e/s)+" "+i+(h?"s":"")}});export{g as a};
@@ -1,8 +0,0 @@
1
- // Force strict mode and setup for ESM
2
- "use strict";
3
- import{g as w,i as x}from"./chunk-GUFIMKF5.js";import{ba as I}from"./chunk-MH2P4YXC.js";import{b as m}from"./chunk-GZPNIYVZ.js";m();m();var p=I("IMAGE_TOKENIZER"),E=class l{static PIXELS_PER_TOKEN=28*28;static MIN_TOKENS_PER_IMAGE=4;static MAX_TOKENS_PER_IMAGE=16384;static VISION_SPECIAL_TOKENS=2;async extractImageMetadata(t,e){try{if(!x(e))return p.warn(`Unsupported image format: ${e}`),{width:512,height:512,mimeType:e,dataSize:Math.floor(t.length*.75)};let n=t.replace(/^data:[^;]+;base64,/,""),r=Buffer.from(n,"base64"),i=await this.extractDimensions(r,e);return{width:i.width,height:i.height,mimeType:e,dataSize:r.length}}catch(n){return p.warn("Failed to extract image metadata:",n),{width:512,height:512,mimeType:e,dataSize:Math.floor(t.length*.75)}}}async extractDimensions(t,e){return e.includes("png")?this.extractPngDimensions(t):e.includes("jpeg")||e.includes("jpg")?this.extractJpegDimensions(t):e.includes("webp")?this.extractWebpDimensions(t):e.includes("gif")?this.extractGifDimensions(t):e.includes("bmp")?this.extractBmpDimensions(t):e.includes("tiff")?this.extractTiffDimensions(t):e.includes("heic")?this.extractHeicDimensions(t):{width:512,height:512}}extractPngDimensions(t){if(t.length<24)throw new Error("Invalid PNG: buffer too short");let e=t.subarray(0,8),n=Buffer.from([137,80,78,71,13,10,26,10]);if(!e.equals(n))throw new Error("Invalid PNG signature");let r=t.readUInt32BE(16),i=t.readUInt32BE(20);return{width:r,height:i}}extractJpegDimensions(t){if(t.length<4||t[0]!==255||t[1]!==216)throw new Error("Invalid JPEG signature");let e=2;for(;e<t.length-8;){if(t[e]!==255){e++;continue}let n=t[e+1];if(n>=192&&n<=195||n>=197&&n<=199||n>=201&&n<=203||n>=205&&n<=207){let i=t.readUInt16BE(e+5);return{width:t.readUInt16BE(e+7),height:i}}let r=t.readUInt16BE(e+2);e+=2+r}throw new Error("Could not find JPEG dimensions")}extractWebpDimensions(t){if(t.length<30)throw new Error("Invalid WebP: too short");let e=t.subarray(0,4).toString("ascii"),n=t.subarray(8,12).toString("ascii");if(e!=="RIFF"||n!=="WEBP")throw new Error("Invalid WebP signature");let r=t.subarray(12,16).toString("ascii");if(r==="VP8 "){let i=t.readUInt16LE(26)&16383,a=t.readUInt16LE(28)&16383;return{width:i,height:a}}else if(r==="VP8L"){let i=t.readUInt32LE(21),a=(i&16383)+1,s=(i>>14&16383)+1;return{width:a,height:s}}else if(r==="VP8X"){let i=(t.readUInt32LE(24)&16777215)+1,a=(t.readUInt32LE(26)&16777215)+1;return{width:i,height:a}}throw new Error("Unsupported WebP format")}extractGifDimensions(t){if(t.length<10)throw new Error("Invalid GIF: too short");let e=t.subarray(0,6).toString("ascii");if(e!=="GIF87a"&&e!=="GIF89a")throw new Error("Invalid GIF signature");let n=t.readUInt16LE(6),r=t.readUInt16LE(8);return{width:n,height:r}}calculateTokens(t){return this.calculateTokensWithScaling(t.width,t.height)}calculateTokensWithScaling(t,e){let n=Math.round(e/28)*28,r=Math.round(t/28)*28,i=l.MIN_TOKENS_PER_IMAGE*l.PIXELS_PER_TOKEN,a=l.MAX_TOKENS_PER_IMAGE*l.PIXELS_PER_TOKEN;if(n*r>a){let o=Math.sqrt(e*t/a);n=Math.floor(e/o/28)*28,r=Math.floor(t/o/28)*28}else if(n*r<i){let o=Math.sqrt(i/(e*t));n=Math.ceil(e*o/28)*28,r=Math.ceil(t*o/28)*28}return Math.floor(n*r/l.PIXELS_PER_TOKEN)+l.VISION_SPECIAL_TOKENS}async calculateTokensBatch(t){let e=[];for(let{data:n,mimeType:r}of t)try{let i=await this.extractImageMetadata(n,r);e.push(this.calculateTokens(i))}catch(i){p.warn("Error calculating tokens for image:",i),e.push(l.MIN_TOKENS_PER_IMAGE+l.VISION_SPECIAL_TOKENS)}return e}extractBmpDimensions(t){if(t.length<26)throw new Error("Invalid BMP: buffer too short");if(t[0]!==66||t[1]!==77)throw new Error("Invalid BMP signature");let e=t.readUInt32LE(18),n=t.readUInt32LE(22);return{width:e,height:Math.abs(n)}}extractTiffDimensions(t){if(t.length<8)throw new Error("Invalid TIFF: buffer too short");let e=t.subarray(0,2).toString("ascii"),n=e==="II";if(!n&&!(e==="MM"))throw new Error("Invalid TIFF byte order");if((n?t.readUInt16LE(2):t.readUInt16BE(2))!==42)throw new Error("Invalid TIFF magic number");let a=n?t.readUInt32LE(4):t.readUInt32BE(4);if(a>=t.length)throw new Error("Invalid TIFF IFD offset");let s=n?t.readUInt16LE(a):t.readUInt16BE(a),o=0,h=0;for(let g=0;g<s;g++){let c=a+2+g*12;if(c+12>t.length)break;let u=n?t.readUInt16LE(c):t.readUInt16BE(c),f=(n?t.readUInt16LE(c+2):t.readUInt16BE(c+2))===3?n?t.readUInt16LE(c+8):t.readUInt16BE(c+8):n?t.readUInt32LE(c+8):t.readUInt32BE(c+8);if(u===256?o=f:u===257&&(h=f),o>0&&h>0)break}if(o===0||h===0)throw new Error("Could not find TIFF dimensions");return{width:o,height:h}}extractHeicDimensions(t){if(t.length<12)throw new Error("Invalid HEIC: buffer too short");if(t.subarray(4,8).toString("ascii")!=="ftyp")throw new Error("Invalid HEIC: missing ftyp box");let n=t.subarray(8,12).toString("ascii");if(!["heic","heix","hevc","hevx"].includes(n))throw new Error("Invalid HEIC brand");let r=0;for(;r<t.length-8;){let i=t.readUInt32BE(r);if(t.subarray(r+4,r+8).toString("ascii")==="meta"){let o=r+8+4;for(;o<r+i-8;){let h=t.readUInt32BE(o);if(t.subarray(o+4,o+8).toString("ascii")==="ispe"&&o+20<=t.length){let c=t.readUInt32BE(o+12),u=t.readUInt32BE(o+16);return{width:c,height:u}}if(h===0)break;o+=h}}if(i===0)break;r+=i}return p.warn("Could not extract HEIC dimensions, using default"),{width:512,height:512}}};var d=I("TOKENIZER"),T=class{textTokenizer;imageTokenizer;constructor(){this.textTokenizer=new w,this.imageTokenizer=new E}async calculateTokens(t){let e=performance.now();try{let{textContents:n,imageContents:r,audioContents:i,otherContents:a}=this.processAndGroupContents(t);if(n.length===0&&r.length===0&&i.length===0&&a.length===0)return{totalTokens:0,breakdown:{textTokens:0,imageTokens:0,audioTokens:0,otherTokens:0},processingTime:performance.now()-e};let s=await this.calculateTextTokens(n),o=await this.calculateImageTokens(r),h=await this.calculateAudioTokens(i),g=await this.calculateOtherTokens(a),c=s+o+h+g,u=performance.now()-e;return{totalTokens:c,breakdown:{textTokens:s,imageTokens:o,audioTokens:h,otherTokens:g},processingTime:u}}catch(n){d.error("Error calculating tokens:",n);let r=this.calculateFallbackTokens(t);return{totalTokens:r,breakdown:{textTokens:r,imageTokens:0,audioTokens:0,otherTokens:0},processingTime:performance.now()-e}}}async calculateTextTokens(t){if(t.length===0)return 0;try{return await this.textTokenizer.calculateTokens(t.join(""))}catch(e){d.warn("Error calculating text tokens:",e);let n=t.join("").length;return Math.ceil(n/4)}}async calculateImageTokens(t){if(t.length===0)return 0;try{return(await this.imageTokenizer.calculateTokensBatch(t)).reduce((n,r)=>n+r,0)}catch(e){return d.warn("Error calculating image tokens:",e),t.length*6}}async calculateAudioTokens(t){if(t.length===0)return 0;let e=0;for(let n of t)try{let r=Math.floor(n.data.length*.75);e+=Math.max(Math.ceil(r/100),10)}catch(r){d.warn("Error calculating audio tokens:",r),e+=10}return e}async calculateOtherTokens(t){if(t.length===0)return 0;try{return await this.textTokenizer.calculateTokens(t.join(""))}catch(e){d.warn("Error calculating other content tokens:",e);let n=t.join("").length;return Math.ceil(n/4)}}calculateFallbackTokens(t){try{let e=JSON.stringify(t.contents);return Math.ceil(e.length/4)}catch(e){return d.warn("Error in fallback token calculation:",e),100}}processAndGroupContents(t){let e=[],n=[],r=[],i=[];if(!t.contents)return{textContents:e,imageContents:n,audioContents:r,otherContents:i};let a=Array.isArray(t.contents)?t.contents:[t.contents];for(let s of a)this.processContent(s,e,n,r,i);return{textContents:e,imageContents:n,audioContents:r,otherContents:i}}processContent(t,e,n,r,i){if(typeof t=="string"){t.trim()&&e.push(t);return}if("parts"in t&&t.parts){for(let a of t.parts)this.processPart(a,e,n,r,i);return}this.processPart(t,e,n,r,i)}processPart(t,e,n,r,i){if(typeof t=="string"){t.trim()&&e.push(t);return}if("text"in t&&t.text){e.push(t.text);return}if("inlineData"in t&&t.inlineData){let{data:a,mimeType:s}=t.inlineData;if(s&&s.startsWith("image/")){n.push({data:a||"",mimeType:s});return}if(s&&s.startsWith("audio/")){r.push({data:a||"",mimeType:s});return}}if("fileData"in t&&t.fileData){i.push(JSON.stringify(t.fileData));return}if("functionCall"in t&&t.functionCall){i.push(JSON.stringify(t.functionCall));return}if("functionResponse"in t&&t.functionResponse){i.push(JSON.stringify(t.functionResponse));return}try{let a=JSON.stringify(t);a&&a!=="{}"&&i.push(a)}catch(a){d.warn("Failed to serialize unknown part type:",a)}}};m();export{T as a};
4
- /**
5
- * @license
6
- * Copyright 2025 Matilda
7
- * SPDX-License-Identifier: Apache-2.0
8
- */
@@ -1,6 +0,0 @@
1
- // Force strict mode and setup for ESM
2
- "use strict";
3
- import{b as le,d as Cr,e as ge}from"./chunk-XMZIY7XX.js";import{b as h}from"./chunk-GZPNIYVZ.js";import{a as qr,d as O}from"./chunk-OWGSC52X.js";var ze=O((hn,Ke)=>{h();Ke.exports=qr("util").inspect});var j=O((gn,ur)=>{h();var Ae=typeof Map=="function"&&Map.prototype,we=Object.getOwnPropertyDescriptor&&Ae?Object.getOwnPropertyDescriptor(Map.prototype,"size"):null,oe=Ae&&we&&typeof we.get=="function"?we.get:null,Qe=Ae&&Map.prototype.forEach,_e=typeof Set=="function"&&Set.prototype,Se=Object.getOwnPropertyDescriptor&&_e?Object.getOwnPropertyDescriptor(Set.prototype,"size"):null,ue=_e&&Se&&typeof Se.get=="function"?Se.get:null,Ge=_e&&Set.prototype.forEach,Nr=typeof WeakMap=="function"&&WeakMap.prototype,X=Nr?WeakMap.prototype.has:null,Rr=typeof WeakSet=="function"&&WeakSet.prototype,Y=Rr?WeakSet.prototype.has:null,Fr=typeof WeakRef=="function"&&WeakRef.prototype,Ve=Fr?WeakRef.prototype.deref:null,Pr=Boolean.prototype.valueOf,Wr=Object.prototype.toString,Br=Function.prototype.toString,Hr=String.prototype.match,Ie=String.prototype.slice,C=String.prototype.replace,Kr=String.prototype.toUpperCase,Ue=String.prototype.toLowerCase,tr=RegExp.prototype.test,ke=Array.prototype.concat,b=Array.prototype.join,zr=Array.prototype.slice,Je=Math.floor,be=typeof BigInt=="function"?BigInt.prototype.valueOf:null,Oe=Object.getOwnPropertySymbols,xe=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Symbol.prototype.toString:null,Q=typeof Symbol=="function"&&typeof Symbol.iterator=="object",Z=typeof Symbol=="function"&&Symbol.toStringTag&&(typeof Symbol.toStringTag===Q||!0)?Symbol.toStringTag:null,nr=Object.prototype.propertyIsEnumerable,Xe=(typeof Reflect=="function"?Reflect.getPrototypeOf:Object.getPrototypeOf)||([].__proto__===Array.prototype?function(r){return r.__proto__}:null);function Ye(r,e){if(r===1/0||r===-1/0||r!==r||r&&r>-1e3&&r<1e3||tr.call(/e/,e))return e;var t=/[0-9](?=(?:[0-9]{3})+(?![0-9]))/g;if(typeof r=="number"){var n=r<0?-Je(-r):Je(r);if(n!==r){var a=String(n),i=Ie.call(e,a.length+1);return C.call(a,t,"$&_")+"."+C.call(C.call(i,/([0-9]{3})/g,"$&_"),/_$/,"")}}return C.call(e,t,"$&_")}var De=ze(),Ze=De.custom,je=lr(Ze)?Ze:null,ar={__proto__:null,double:'"',single:"'"},Qr={__proto__:null,double:/(["\\])/g,single:/(['\\])/g};ur.exports=function r(e,t,n,a){var i=t||{};if(A(i,"quoteStyle")&&!A(ar,i.quoteStyle))throw new TypeError('option "quoteStyle" must be "single" or "double"');if(A(i,"maxStringLength")&&(typeof i.maxStringLength=="number"?i.maxStringLength<0&&i.maxStringLength!==1/0:i.maxStringLength!==null))throw new TypeError('option "maxStringLength", if provided, must be a positive integer, Infinity, or `null`');var f=A(i,"customInspect")?i.customInspect:!0;if(typeof f!="boolean"&&f!=="symbol")throw new TypeError("option \"customInspect\", if provided, must be `true`, `false`, or `'symbol'`");if(A(i,"indent")&&i.indent!==null&&i.indent!==" "&&!(parseInt(i.indent,10)===i.indent&&i.indent>0))throw new TypeError('option "indent" must be "\\t", an integer > 0, or `null`');if(A(i,"numericSeparator")&&typeof i.numericSeparator!="boolean")throw new TypeError('option "numericSeparator", if provided, must be `true` or `false`');var d=i.numericSeparator;if(typeof e>"u")return"undefined";if(e===null)return"null";if(typeof e=="boolean")return e?"true":"false";if(typeof e=="string")return or(e,i);if(typeof e=="number"){if(e===0)return 1/0/e>0?"0":"-0";var o=String(e);return d?Ye(e,o):o}if(typeof e=="bigint"){var c=String(e)+"n";return d?Ye(e,c):c}var u=typeof i.depth>"u"?5:i.depth;if(typeof n>"u"&&(n=0),n>=u&&u>0&&typeof e=="object")return Me(e)?"[Array]":"[Object]";var s=ot(i,n);if(typeof a>"u")a=[];else if(fr(a,e)>=0)return"[Circular]";function l(E,q,L){if(q&&(a=zr.call(a),a.push(q)),L){var k={depth:i.depth};return A(i,"quoteStyle")&&(k.quoteStyle=i.quoteStyle),r(E,k,n+1,a)}return r(E,i,n+1,a)}if(typeof e=="function"&&!er(e)){var p=jr(e),y=fe(e,l);return"[Function"+(p?": "+p:" (anonymous)")+"]"+(y.length>0?" { "+b.call(y,", ")+" }":"")}if(lr(e)){var g=Q?C.call(String(e),/^(Symbol\(.*\))_[^)]*$/,"$1"):xe.call(e);return typeof e=="object"&&!Q?J(g):g}if(it(e)){for(var S="<"+Ue.call(String(e.nodeName)),_=e.attributes||[],I=0;I<_.length;I++)S+=" "+_[I].name+"="+ir(Gr(_[I].value),"double",i);return S+=">",e.childNodes&&e.childNodes.length&&(S+="..."),S+="</"+Ue.call(String(e.nodeName))+">",S}if(Me(e)){if(e.length===0)return"[]";var v=fe(e,l);return s&&!ft(v)?"["+Le(v,s)+"]":"[ "+b.call(v,", ")+" ]"}if(Ur(e)){var T=fe(e,l);return!("cause"in Error.prototype)&&"cause"in e&&!nr.call(e,"cause")?"{ ["+String(e)+"] "+b.call(ke.call("[cause]: "+l(e.cause),T),", ")+" }":T.length===0?"["+String(e)+"]":"{ ["+String(e)+"] "+b.call(T,", ")+" }"}if(typeof e=="object"&&f){if(je&&typeof e[je]=="function"&&De)return De(e,{depth:u-n});if(f!=="symbol"&&typeof e.inspect=="function")return e.inspect()}if(et(e)){var R=[];return Qe&&Qe.call(e,function(E,q){R.push(l(q,e,!0)+" => "+l(E,e))}),rr("Map",oe.call(e),R,s)}if(nt(e)){var U=[];return Ge&&Ge.call(e,function(E){U.push(l(E,e))}),rr("Set",ue.call(e),U,s)}if(rt(e))return Ee("WeakMap");if(at(e))return Ee("WeakSet");if(tt(e))return Ee("WeakRef");if(Jr(e))return J(l(Number(e)));if(Yr(e))return J(l(be.call(e)));if(Xr(e))return J(Pr.call(e));if(kr(e))return J(l(String(e)));if(typeof window<"u"&&e===window)return"{ [object Window] }";if(typeof globalThis<"u"&&e===globalThis||typeof globalThis<"u"&&e===globalThis)return"{ [object globalThis] }";if(!Vr(e)&&!er(e)){var K=fe(e,l),ae=Xe?Xe(e)===Object.prototype:e instanceof Object||e.constructor===Object,F=e instanceof Object?"":"null prototype",$=!ae&&Z&&Object(e)===e&&Z in e?Ie.call(N(e),8,-1):F?"Object":"",ie=ae||typeof e.constructor!="function"?"":e.constructor.name?e.constructor.name+" ":"",z=ie+($||F?"["+b.call(ke.call([],$||[],F||[]),": ")+"] ":"");return K.length===0?z+"{}":s?z+"{"+Le(K,s)+"}":z+"{ "+b.call(K,", ")+" }"}return String(e)};function ir(r,e,t){var n=t.quoteStyle||e,a=ar[n];return a+r+a}function Gr(r){return C.call(String(r),/"/g,"&quot;")}function W(r){return!Z||!(typeof r=="object"&&(Z in r||typeof r[Z]<"u"))}function Me(r){return N(r)==="[object Array]"&&W(r)}function Vr(r){return N(r)==="[object Date]"&&W(r)}function er(r){return N(r)==="[object RegExp]"&&W(r)}function Ur(r){return N(r)==="[object Error]"&&W(r)}function kr(r){return N(r)==="[object String]"&&W(r)}function Jr(r){return N(r)==="[object Number]"&&W(r)}function Xr(r){return N(r)==="[object Boolean]"&&W(r)}function lr(r){if(Q)return r&&typeof r=="object"&&r instanceof Symbol;if(typeof r=="symbol")return!0;if(!r||typeof r!="object"||!xe)return!1;try{return xe.call(r),!0}catch{}return!1}function Yr(r){if(!r||typeof r!="object"||!be)return!1;try{return be.call(r),!0}catch{}return!1}var Zr=Object.prototype.hasOwnProperty||function(r){return r in this};function A(r,e){return Zr.call(r,e)}function N(r){return Wr.call(r)}function jr(r){if(r.name)return r.name;var e=Hr.call(Br.call(r),/^function\s*([\w$]+)/);return e?e[1]:null}function fr(r,e){if(r.indexOf)return r.indexOf(e);for(var t=0,n=r.length;t<n;t++)if(r[t]===e)return t;return-1}function et(r){if(!oe||!r||typeof r!="object")return!1;try{oe.call(r);try{ue.call(r)}catch{return!0}return r instanceof Map}catch{}return!1}function rt(r){if(!X||!r||typeof r!="object")return!1;try{X.call(r,X);try{Y.call(r,Y)}catch{return!0}return r instanceof WeakMap}catch{}return!1}function tt(r){if(!Ve||!r||typeof r!="object")return!1;try{return Ve.call(r),!0}catch{}return!1}function nt(r){if(!ue||!r||typeof r!="object")return!1;try{ue.call(r);try{oe.call(r)}catch{return!0}return r instanceof Set}catch{}return!1}function at(r){if(!Y||!r||typeof r!="object")return!1;try{Y.call(r,Y);try{X.call(r,X)}catch{return!0}return r instanceof WeakSet}catch{}return!1}function it(r){return!r||typeof r!="object"?!1:typeof HTMLElement<"u"&&r instanceof HTMLElement?!0:typeof r.nodeName=="string"&&typeof r.getAttribute=="function"}function or(r,e){if(r.length>e.maxStringLength){var t=r.length-e.maxStringLength,n="... "+t+" more character"+(t>1?"s":"");return or(Ie.call(r,0,e.maxStringLength),e)+n}var a=Qr[e.quoteStyle||"single"];a.lastIndex=0;var i=C.call(C.call(r,a,"\\$1"),/[\x00-\x1f]/g,lt);return ir(i,"single",e)}function lt(r){var e=r.charCodeAt(0),t={8:"b",9:"t",10:"n",12:"f",13:"r"}[e];return t?"\\"+t:"\\x"+(e<16?"0":"")+Kr.call(e.toString(16))}function J(r){return"Object("+r+")"}function Ee(r){return r+" { ? }"}function rr(r,e,t,n){var a=n?Le(t,n):b.call(t,", ");return r+" ("+e+") {"+a+"}"}function ft(r){for(var e=0;e<r.length;e++)if(fr(r[e],`
4
- `)>=0)return!1;return!0}function ot(r,e){var t;if(r.indent===" ")t=" ";else if(typeof r.indent=="number"&&r.indent>0)t=b.call(Array(r.indent+1)," ");else return null;return{base:t,prev:b.call(Array(e+1),t)}}function Le(r,e){if(r.length===0)return"";var t=`
5
- `+e.prev+e.base;return t+b.call(r,","+t)+`
6
- `+e.prev}function fe(r,e){var t=Me(r),n=[];if(t){n.length=r.length;for(var a=0;a<r.length;a++)n[a]=A(r,a)?e(r[a],r):""}var i=typeof Oe=="function"?Oe(r):[],f;if(Q){f={};for(var d=0;d<i.length;d++)f["$"+i[d]]=i[d]}for(var o in r)A(r,o)&&(t&&String(Number(o))===o&&o<r.length||Q&&f["$"+o]instanceof Symbol||(tr.call(/[^\w$]/,o)?n.push(e(o,r)+": "+e(r[o],r)):n.push(o+": "+e(r[o],r))));if(typeof Oe=="function")for(var c=0;c<i.length;c++)nr.call(r,i[c])&&n.push("["+e(i[c])+"]: "+e(r[i[c]],r));return n}});var pr=O((Sn,cr)=>{"use strict";h();var ut=j(),ct=le(),ce=function(r,e,t){for(var n=r,a;(a=n.next)!=null;n=a)if(a.key===e)return n.next=a.next,t||(a.next=r.next,r.next=a),a},pt=function(r,e){if(r){var t=ce(r,e);return t&&t.value}},st=function(r,e,t){var n=ce(r,e);n?n.value=t:r.next={key:e,next:r.next,value:t}},yt=function(r,e){return r?!!ce(r,e):!1},dt=function(r,e){if(r)return ce(r,e,!0)};cr.exports=function(){var e,t={assert:function(n){if(!t.has(n))throw new ct("Side channel does not contain "+ut(n))},delete:function(n){var a=e&&e.next,i=dt(e,n);return i&&a&&a===i&&(e=void 0),!!i},get:function(n){return pt(e,n)},has:function(n){return yt(e,n)},set:function(n,a){e||(e={next:void 0}),st(e,n,a)}};return t}});var Te=O((En,dr)=>{"use strict";h();var sr=ge(),yr=Cr(),vt=yr([sr("%String.prototype.indexOf%")]);dr.exports=function(e,t){var n=sr(e,!!t);return typeof n=="function"&&vt(e,".prototype.")>-1?yr([n]):n}});var $e=O((xn,hr)=>{"use strict";h();var ht=ge(),ee=Te(),mt=j(),gt=le(),vr=ht("%Map%",!0),wt=ee("Map.prototype.get",!0),St=ee("Map.prototype.set",!0),Ot=ee("Map.prototype.has",!0),Et=ee("Map.prototype.delete",!0),bt=ee("Map.prototype.size",!0);hr.exports=!!vr&&function(){var e,t={assert:function(n){if(!t.has(n))throw new gt("Side channel does not contain "+mt(n))},delete:function(n){if(e){var a=Et(e,n);return bt(e)===0&&(e=void 0),a}return!1},get:function(n){if(e)return wt(e,n)},has:function(n){return e?Ot(e,n):!1},set:function(n,a){e||(e=new vr),St(e,n,a)}};return t}});var gr=O((Mn,mr)=>{"use strict";h();var xt=ge(),se=Te(),Dt=j(),pe=$e(),Mt=le(),G=xt("%WeakMap%",!0),Lt=se("WeakMap.prototype.get",!0),At=se("WeakMap.prototype.set",!0),_t=se("WeakMap.prototype.has",!0),It=se("WeakMap.prototype.delete",!0);mr.exports=G?function(){var e,t,n={assert:function(a){if(!n.has(a))throw new Mt("Side channel does not contain "+Dt(a))},delete:function(a){if(G&&a&&(typeof a=="object"||typeof a=="function")){if(e)return It(e,a)}else if(pe&&t)return t.delete(a);return!1},get:function(a){return G&&a&&(typeof a=="object"||typeof a=="function")&&e?Lt(e,a):t&&t.get(a)},has:function(a){return G&&a&&(typeof a=="object"||typeof a=="function")&&e?_t(e,a):!!t&&t.has(a)},set:function(a,i){G&&a&&(typeof a=="object"||typeof a=="function")?(e||(e=new G),At(e,a,i)):pe&&(t||(t=pe()),t.set(a,i))}};return n}:pe});var qe=O((An,wr)=>{"use strict";h();var Tt=le(),$t=j(),qt=pr(),Ct=$e(),Nt=gr(),Rt=Nt||Ct||qt;wr.exports=function(){var e,t={assert:function(n){if(!t.has(n))throw new Tt("Side channel does not contain "+$t(n))},delete:function(n){return!!e&&e.delete(n)},get:function(n){return e&&e.get(n)},has:function(n){return!!e&&e.has(n)},set:function(n,a){e||(e=Rt()),e.set(n,a)}};return t}});var ye=O((In,Sr)=>{"use strict";h();var Ft=String.prototype.replace,Pt=/%20/g,Ce={RFC1738:"RFC1738",RFC3986:"RFC3986"};Sr.exports={default:Ce.RFC3986,formatters:{RFC1738:function(r){return Ft.call(r,Pt,"+")},RFC3986:function(r){return String(r)}},RFC1738:Ce.RFC1738,RFC3986:Ce.RFC3986}});var Pe=O(($n,Or)=>{"use strict";h();var Wt=ye(),Bt=qe(),Ne=Object.prototype.hasOwnProperty,B=Array.isArray,de=Bt(),V=function(e,t){return de.set(e,t),e},H=function(e){return de.has(e)},re=function(e){return de.get(e)},Fe=function(e,t){de.set(e,t)},x=function(){for(var r=[],e=0;e<256;++e)r[r.length]="%"+((e<16?"0":"")+e.toString(16)).toUpperCase();return r}(),Ht=function(e){for(;e.length>1;){var t=e.pop(),n=t.obj[t.prop];if(B(n)){for(var a=[],i=0;i<n.length;++i)typeof n[i]<"u"&&(a[a.length]=n[i]);t.obj[t.prop]=a}}},te=function(e,t){for(var n=t&&t.plainObjects?{__proto__:null}:{},a=0;a<e.length;++a)typeof e[a]<"u"&&(n[a]=e[a]);return n},Kt=function r(e,t,n){if(!t)return e;if(typeof t!="object"&&typeof t!="function"){if(B(e)){var a=e.length;if(n&&typeof n.arrayLimit=="number"&&a>n.arrayLimit)return V(te(e.concat(t),n),a);e[a]=t}else if(e&&typeof e=="object")if(H(e)){var i=re(e)+1;e[i]=t,Fe(e,i)}else{if(n&&n.strictMerge)return[e,t];(n&&(n.plainObjects||n.allowPrototypes)||!Ne.call(Object.prototype,t))&&(e[t]=!0)}else return[e,t];return e}if(!e||typeof e!="object"){if(H(t)){for(var f=Object.keys(t),d=n&&n.plainObjects?{__proto__:null,0:e}:{0:e},o=0;o<f.length;o++){var c=parseInt(f[o],10);d[c+1]=t[f[o]]}return V(d,re(t)+1)}var u=[e].concat(t);return n&&typeof n.arrayLimit=="number"&&u.length>n.arrayLimit?V(te(u,n),u.length-1):u}var s=e;return B(e)&&!B(t)&&(s=te(e,n)),B(e)&&B(t)?(t.forEach(function(l,p){if(Ne.call(e,p)){var y=e[p];y&&typeof y=="object"&&l&&typeof l=="object"?e[p]=r(y,l,n):e[e.length]=l}else e[p]=l}),e):Object.keys(t).reduce(function(l,p){var y=t[p];if(Ne.call(l,p)?l[p]=r(l[p],y,n):l[p]=y,H(t)&&!H(l)&&V(l,re(t)),H(l)){var g=parseInt(p,10);String(g)===p&&g>=0&&g>re(l)&&Fe(l,g)}return l},s)},zt=function(e,t){return Object.keys(t).reduce(function(n,a){return n[a]=t[a],n},e)},Qt=function(r,e,t){var n=r.replace(/\+/g," ");if(t==="iso-8859-1")return n.replace(/%[0-9a-f]{2}/gi,unescape);try{return decodeURIComponent(n)}catch{return n}},Re=1024,Gt=function(e,t,n,a,i){if(e.length===0)return e;var f=e;if(typeof e=="symbol"?f=Symbol.prototype.toString.call(e):typeof e!="string"&&(f=String(e)),n==="iso-8859-1")return escape(f).replace(/%u[0-9a-f]{4}/gi,function(p){return"%26%23"+parseInt(p.slice(2),16)+"%3B"});for(var d="",o=0;o<f.length;o+=Re){for(var c=f.length>=Re?f.slice(o,o+Re):f,u=[],s=0;s<c.length;++s){var l=c.charCodeAt(s);if(l===45||l===46||l===95||l===126||l>=48&&l<=57||l>=65&&l<=90||l>=97&&l<=122||i===Wt.RFC1738&&(l===40||l===41)){u[u.length]=c.charAt(s);continue}if(l<128){u[u.length]=x[l];continue}if(l<2048){u[u.length]=x[192|l>>6]+x[128|l&63];continue}if(l<55296||l>=57344){u[u.length]=x[224|l>>12]+x[128|l>>6&63]+x[128|l&63];continue}s+=1,l=65536+((l&1023)<<10|c.charCodeAt(s)&1023),u[u.length]=x[240|l>>18]+x[128|l>>12&63]+x[128|l>>6&63]+x[128|l&63]}d+=u.join("")}return d},Vt=function(e){for(var t=[{obj:{o:e},prop:"o"}],n=[],a=0;a<t.length;++a)for(var i=t[a],f=i.obj[i.prop],d=Object.keys(f),o=0;o<d.length;++o){var c=d[o],u=f[c];typeof u=="object"&&u!==null&&n.indexOf(u)===-1&&(t[t.length]={obj:f,prop:c},n[n.length]=u)}return Ht(t),e},Ut=function(e){return Object.prototype.toString.call(e)==="[object RegExp]"},kt=function(e){return!e||typeof e!="object"?!1:!!(e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer(e))},Jt=function(e,t,n,a){if(H(e)){var i=re(e)+1;return e[i]=t,Fe(e,i),e}var f=[].concat(e,t);return f.length>n?V(te(f,{plainObjects:a}),f.length-1):f},Xt=function(e,t){if(B(e)){for(var n=[],a=0;a<e.length;a+=1)n[n.length]=t(e[a]);return n}return t(e)};Or.exports={arrayToObject:te,assign:zt,combine:Jt,compact:Vt,decode:Qt,encode:Gt,isBuffer:kt,isOverflow:H,isRegExp:Ut,markOverflow:V,maybeMap:Xt,merge:Kt}});var Lr=O((Cn,Mr)=>{"use strict";h();var br=qe(),ve=Pe(),ne=ye(),Yt=Object.prototype.hasOwnProperty,xr={brackets:function(e){return e+"[]"},comma:"comma",indices:function(e,t){return e+"["+t+"]"},repeat:function(e){return e}},D=Array.isArray,Zt=Array.prototype.push,Dr=function(r,e){Zt.apply(r,D(e)?e:[e])},jt=Date.prototype.toISOString,Er=ne.default,w={addQueryPrefix:!1,allowDots:!1,allowEmptyArrays:!1,arrayFormat:"indices",charset:"utf-8",charsetSentinel:!1,commaRoundTrip:!1,delimiter:"&",encode:!0,encodeDotInKeys:!1,encoder:ve.encode,encodeValuesOnly:!1,filter:void 0,format:Er,formatter:ne.formatters[Er],indices:!1,serializeDate:function(e){return jt.call(e)},skipNulls:!1,strictNullHandling:!1},en=function(e){return typeof e=="string"||typeof e=="number"||typeof e=="boolean"||typeof e=="symbol"||typeof e=="bigint"},We={},rn=function r(e,t,n,a,i,f,d,o,c,u,s,l,p,y,g,S,_,I){for(var v=e,T=I,R=0,U=!1;(T=T.get(We))!==void 0&&!U;){var K=T.get(e);if(R+=1,typeof K<"u"){if(K===R)throw new RangeError("Cyclic object value");U=!0}typeof T.get(We)>"u"&&(R=0)}if(typeof u=="function"?v=u(t,v):v instanceof Date?v=p(v):n==="comma"&&D(v)&&(v=ve.maybeMap(v,function(P){return P instanceof Date?p(P):P})),v===null){if(f)return g(c&&!S?c(t,w.encoder,_,"key",y):t);v=""}if(en(v)||ve.isBuffer(v)){if(c){var ae=S?t:c(t,w.encoder,_,"key",y);return[g(ae)+"="+g(c(v,w.encoder,_,"value",y))]}return[g(t)+"="+g(String(v))]}var F=[];if(typeof v>"u")return F;var $;if(n==="comma"&&D(v))S&&c&&(v=ve.maybeMap(v,function(P){return P==null?P:c(P)})),$=[{value:v.length>0?v.join(",")||null:void 0}];else if(D(u))$=u;else{var ie=Object.keys(v);$=s?ie.sort(s):ie}var z=o?String(t).replace(/\./g,"%2E"):String(t),E=a&&D(v)&&v.length===1?z+"[]":z;if(i&&D(v)&&v.length===0)return E+"[]";for(var q=0;q<$.length;++q){var L=$[q],k=typeof L=="object"&&L&&typeof L.value<"u"?L.value:v[L];if(!(d&&k===null)){var me=l&&o?String(L).replace(/\./g,"%2E"):String(L),$r=D(v)?typeof n=="function"?n(E,me):E:E+(l?"."+me:"["+me+"]");I.set(e,R);var He=br();He.set(We,I),Dr(F,r(k,$r,n,a,i,f,d,o,n==="comma"&&S&&D(v)?null:c,u,s,l,p,y,g,S,_,He))}}return F},tn=function(e){if(!e)return w;if(typeof e.allowEmptyArrays<"u"&&typeof e.allowEmptyArrays!="boolean")throw new TypeError("`allowEmptyArrays` option can only be `true` or `false`, when provided");if(typeof e.encodeDotInKeys<"u"&&typeof e.encodeDotInKeys!="boolean")throw new TypeError("`encodeDotInKeys` option can only be `true` or `false`, when provided");if(e.encoder!==null&&typeof e.encoder<"u"&&typeof e.encoder!="function")throw new TypeError("Encoder has to be a function.");var t=e.charset||w.charset;if(typeof e.charset<"u"&&e.charset!=="utf-8"&&e.charset!=="iso-8859-1")throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var n=ne.default;if(typeof e.format<"u"){if(!Yt.call(ne.formatters,e.format))throw new TypeError("Unknown format option provided.");n=e.format}var a=ne.formatters[n],i=w.filter;(typeof e.filter=="function"||D(e.filter))&&(i=e.filter);var f;if(e.arrayFormat in xr?f=e.arrayFormat:"indices"in e?f=e.indices?"indices":"repeat":f=w.arrayFormat,"commaRoundTrip"in e&&typeof e.commaRoundTrip!="boolean")throw new TypeError("`commaRoundTrip` must be a boolean, or absent");var d=typeof e.allowDots>"u"?e.encodeDotInKeys===!0?!0:w.allowDots:!!e.allowDots;return{addQueryPrefix:typeof e.addQueryPrefix=="boolean"?e.addQueryPrefix:w.addQueryPrefix,allowDots:d,allowEmptyArrays:typeof e.allowEmptyArrays=="boolean"?!!e.allowEmptyArrays:w.allowEmptyArrays,arrayFormat:f,charset:t,charsetSentinel:typeof e.charsetSentinel=="boolean"?e.charsetSentinel:w.charsetSentinel,commaRoundTrip:!!e.commaRoundTrip,delimiter:typeof e.delimiter>"u"?w.delimiter:e.delimiter,encode:typeof e.encode=="boolean"?e.encode:w.encode,encodeDotInKeys:typeof e.encodeDotInKeys=="boolean"?e.encodeDotInKeys:w.encodeDotInKeys,encoder:typeof e.encoder=="function"?e.encoder:w.encoder,encodeValuesOnly:typeof e.encodeValuesOnly=="boolean"?e.encodeValuesOnly:w.encodeValuesOnly,filter:i,format:n,formatter:a,serializeDate:typeof e.serializeDate=="function"?e.serializeDate:w.serializeDate,skipNulls:typeof e.skipNulls=="boolean"?e.skipNulls:w.skipNulls,sort:typeof e.sort=="function"?e.sort:null,strictNullHandling:typeof e.strictNullHandling=="boolean"?e.strictNullHandling:w.strictNullHandling}};Mr.exports=function(r,e){var t=r,n=tn(e),a,i;typeof n.filter=="function"?(i=n.filter,t=i("",t)):D(n.filter)&&(i=n.filter,a=i);var f=[];if(typeof t!="object"||t===null)return"";var d=xr[n.arrayFormat],o=d==="comma"&&n.commaRoundTrip;a||(a=Object.keys(t)),n.sort&&a.sort(n.sort);for(var c=br(),u=0;u<a.length;++u){var s=a[u];if(!(typeof s>"u"||s===null)){var l=t[s];n.skipNulls&&l===null||Dr(f,rn(l,s,d,o,n.allowEmptyArrays,n.strictNullHandling,n.skipNulls,n.encodeDotInKeys,n.encode?n.encoder:null,n.filter,n.sort,n.allowDots,n.serializeDate,n.format,n.formatter,n.encodeValuesOnly,n.charset,c))}}var p=f.join(n.delimiter),y=n.addQueryPrefix===!0?"?":"";return n.charsetSentinel&&(n.charset==="iso-8859-1"?y+="utf8=%26%2310003%3B"+n.delimiter:y+="utf8=%E2%9C%93"+n.delimiter),p.length>0?y+p:""}});var Ir=O((Rn,_r)=>{"use strict";h();var M=Pe(),he=Object.prototype.hasOwnProperty,Be=Array.isArray,m={allowDots:!1,allowEmptyArrays:!1,allowPrototypes:!1,allowSparse:!1,arrayLimit:20,charset:"utf-8",charsetSentinel:!1,comma:!1,decodeDotInKeys:!1,decoder:M.decode,delimiter:"&",depth:5,duplicates:"combine",ignoreQueryPrefix:!1,interpretNumericEntities:!1,parameterLimit:1e3,parseArrays:!0,plainObjects:!1,strictDepth:!1,strictMerge:!0,strictNullHandling:!1,throwOnLimitExceeded:!1},nn=function(r){return r.replace(/&#(\d+);/g,function(e,t){return String.fromCharCode(parseInt(t,10))})},Ar=function(r,e,t){if(r&&typeof r=="string"&&e.comma&&r.indexOf(",")>-1)return r.split(",");if(e.throwOnLimitExceeded&&t>=e.arrayLimit)throw new RangeError("Array limit exceeded. Only "+e.arrayLimit+" element"+(e.arrayLimit===1?"":"s")+" allowed in an array.");return r},an="utf8=%26%2310003%3B",ln="utf8=%E2%9C%93",fn=function(e,t){var n={__proto__:null},a=t.ignoreQueryPrefix?e.replace(/^\?/,""):e;a=a.replace(/%5B/gi,"[").replace(/%5D/gi,"]");var i=t.parameterLimit===1/0?void 0:t.parameterLimit,f=a.split(t.delimiter,t.throwOnLimitExceeded&&typeof i<"u"?i+1:i);if(t.throwOnLimitExceeded&&typeof i<"u"&&f.length>i)throw new RangeError("Parameter limit exceeded. Only "+i+" parameter"+(i===1?"":"s")+" allowed.");var d=-1,o,c=t.charset;if(t.charsetSentinel)for(o=0;o<f.length;++o)f[o].indexOf("utf8=")===0&&(f[o]===ln?c="utf-8":f[o]===an&&(c="iso-8859-1"),d=o,o=f.length);for(o=0;o<f.length;++o)if(o!==d){var u=f[o],s=u.indexOf("]="),l=s===-1?u.indexOf("="):s+1,p,y;if(l===-1?(p=t.decoder(u,m.decoder,c,"key"),y=t.strictNullHandling?null:""):(p=t.decoder(u.slice(0,l),m.decoder,c,"key"),p!==null&&(y=M.maybeMap(Ar(u.slice(l+1),t,Be(n[p])?n[p].length:0),function(S){return t.decoder(S,m.decoder,c,"value")}))),y&&t.interpretNumericEntities&&c==="iso-8859-1"&&(y=nn(String(y))),u.indexOf("[]=")>-1&&(y=Be(y)?[y]:y),t.comma&&Be(y)&&y.length>t.arrayLimit){if(t.throwOnLimitExceeded)throw new RangeError("Array limit exceeded. Only "+t.arrayLimit+" element"+(t.arrayLimit===1?"":"s")+" allowed in an array.");y=M.combine([],y,t.arrayLimit,t.plainObjects)}if(p!==null){var g=he.call(n,p);g&&(t.duplicates==="combine"||u.indexOf("[]=")>-1)?n[p]=M.combine(n[p],y,t.arrayLimit,t.plainObjects):(!g||t.duplicates==="last")&&(n[p]=y)}}return n},on=function(r,e,t,n){var a=0;if(r.length>0&&r[r.length-1]==="[]"){var i=r.slice(0,-1).join("");a=Array.isArray(e)&&e[i]?e[i].length:0}for(var f=n?e:Ar(e,t,a),d=r.length-1;d>=0;--d){var o,c=r[d];if(c==="[]"&&t.parseArrays)M.isOverflow(f)?o=f:o=t.allowEmptyArrays&&(f===""||t.strictNullHandling&&f===null)?[]:M.combine([],f,t.arrayLimit,t.plainObjects);else{o=t.plainObjects?{__proto__:null}:{};var u=c.charAt(0)==="["&&c.charAt(c.length-1)==="]"?c.slice(1,-1):c,s=t.decodeDotInKeys?u.replace(/%2E/g,"."):u,l=parseInt(s,10),p=!isNaN(l)&&c!==s&&String(l)===s&&l>=0&&t.parseArrays;if(!t.parseArrays&&s==="")o={0:f};else if(p&&l<t.arrayLimit)o=[],o[l]=f;else{if(p&&t.throwOnLimitExceeded)throw new RangeError("Array limit exceeded. Only "+t.arrayLimit+" element"+(t.arrayLimit===1?"":"s")+" allowed in an array.");p?(o[l]=f,M.markOverflow(o,l)):s!=="__proto__"&&(o[s]=f)}}f=o}return f},un=function(e,t){var n=t.allowDots?e.replace(/\.([^.[]+)/g,"[$1]"):e;if(t.depth<=0)return!t.plainObjects&&he.call(Object.prototype,n)&&!t.allowPrototypes?void 0:[n];var a=[],i=n.indexOf("["),f=i>=0?n.slice(0,i):n;if(f){if(!t.plainObjects&&he.call(Object.prototype,f)&&!t.allowPrototypes)return;a[a.length]=f}for(var d=n.length,o=i,c=0;o>=0&&c<t.depth;){for(var u=1,s=o+1,l=-1;s<d&&l<0;){var p=n.charCodeAt(s);p===91?u+=1:p===93&&(u-=1,u===0&&(l=s)),s+=1}if(l<0)return a[a.length]="["+n.slice(o)+"]",a;var y=n.slice(o,l+1),g=y.slice(1,-1);if(!t.plainObjects&&he.call(Object.prototype,g)&&!t.allowPrototypes)return;a[a.length]=y,c+=1,o=n.indexOf("[",l+1)}if(o>=0){if(t.strictDepth===!0)throw new RangeError("Input depth exceeded depth option of "+t.depth+" and strictDepth is true");a[a.length]="["+n.slice(o)+"]"}return a},cn=function(e,t,n,a){if(e){var i=un(e,n);if(i)return on(i,t,n,a)}},pn=function(e){if(!e)return m;if(typeof e.allowEmptyArrays<"u"&&typeof e.allowEmptyArrays!="boolean")throw new TypeError("`allowEmptyArrays` option can only be `true` or `false`, when provided");if(typeof e.decodeDotInKeys<"u"&&typeof e.decodeDotInKeys!="boolean")throw new TypeError("`decodeDotInKeys` option can only be `true` or `false`, when provided");if(e.decoder!==null&&typeof e.decoder<"u"&&typeof e.decoder!="function")throw new TypeError("Decoder has to be a function.");if(typeof e.charset<"u"&&e.charset!=="utf-8"&&e.charset!=="iso-8859-1")throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");if(typeof e.throwOnLimitExceeded<"u"&&typeof e.throwOnLimitExceeded!="boolean")throw new TypeError("`throwOnLimitExceeded` option must be a boolean");var t=typeof e.charset>"u"?m.charset:e.charset,n=typeof e.duplicates>"u"?m.duplicates:e.duplicates;if(n!=="combine"&&n!=="first"&&n!=="last")throw new TypeError("The duplicates option must be either combine, first, or last");var a=typeof e.allowDots>"u"?e.decodeDotInKeys===!0?!0:m.allowDots:!!e.allowDots;return{allowDots:a,allowEmptyArrays:typeof e.allowEmptyArrays=="boolean"?!!e.allowEmptyArrays:m.allowEmptyArrays,allowPrototypes:typeof e.allowPrototypes=="boolean"?e.allowPrototypes:m.allowPrototypes,allowSparse:typeof e.allowSparse=="boolean"?e.allowSparse:m.allowSparse,arrayLimit:typeof e.arrayLimit=="number"?e.arrayLimit:m.arrayLimit,charset:t,charsetSentinel:typeof e.charsetSentinel=="boolean"?e.charsetSentinel:m.charsetSentinel,comma:typeof e.comma=="boolean"?e.comma:m.comma,decodeDotInKeys:typeof e.decodeDotInKeys=="boolean"?e.decodeDotInKeys:m.decodeDotInKeys,decoder:typeof e.decoder=="function"?e.decoder:m.decoder,delimiter:typeof e.delimiter=="string"||M.isRegExp(e.delimiter)?e.delimiter:m.delimiter,depth:typeof e.depth=="number"||e.depth===!1?+e.depth:m.depth,duplicates:n,ignoreQueryPrefix:e.ignoreQueryPrefix===!0,interpretNumericEntities:typeof e.interpretNumericEntities=="boolean"?e.interpretNumericEntities:m.interpretNumericEntities,parameterLimit:typeof e.parameterLimit=="number"?e.parameterLimit:m.parameterLimit,parseArrays:e.parseArrays!==!1,plainObjects:typeof e.plainObjects=="boolean"?e.plainObjects:m.plainObjects,strictDepth:typeof e.strictDepth=="boolean"?!!e.strictDepth:m.strictDepth,strictMerge:typeof e.strictMerge=="boolean"?!!e.strictMerge:m.strictMerge,strictNullHandling:typeof e.strictNullHandling=="boolean"?e.strictNullHandling:m.strictNullHandling,throwOnLimitExceeded:typeof e.throwOnLimitExceeded=="boolean"?e.throwOnLimitExceeded:!1}};_r.exports=function(r,e){var t=pn(e);if(r===""||r===null||typeof r>"u")return t.plainObjects?{__proto__:null}:{};for(var n=typeof r=="string"?fn(r,t):r,a=t.plainObjects?{__proto__:null}:{},i=Object.keys(n),f=0;f<i.length;++f){var d=i[f],o=cn(d,n[d],t,typeof r=="string");a=M.merge(a,o,t)}return t.allowSparse===!0?a:M.compact(a)}});var vn=O((Pn,Tr)=>{"use strict";h();var sn=Lr(),yn=Ir(),dn=ye();Tr.exports={formats:dn,parse:yn,stringify:sn}});export{vn as a};