@caspian2026/agent-sdk 0.0.25 → 0.0.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 (362) hide show
  1. package/dist/gateway/index.js +98 -22
  2. package/dist/gateway/worker.js +1005 -982
  3. package/dist/sdk/query.cjs +2 -362
  4. package/dist/sdk/query.js +2 -367
  5. package/package.json +126 -128
  6. package/dist/chunk-04n4fe72.js +0 -107
  7. package/dist/chunk-04ys66ej.js +0 -344
  8. package/dist/chunk-07069jq1.js +0 -30
  9. package/dist/chunk-0731m51q.js +0 -8
  10. package/dist/chunk-086x4ct4.js +0 -26
  11. package/dist/chunk-0btqb97n.js +0 -295
  12. package/dist/chunk-0paqc2yw.js +0 -15
  13. package/dist/chunk-0r1rjydx.js +0 -145
  14. package/dist/chunk-0r5bb9j4.js +0 -477
  15. package/dist/chunk-0t81d427.js +0 -41
  16. package/dist/chunk-0teq2mz0.js +0 -420
  17. package/dist/chunk-0vkfrmqm.js +0 -690
  18. package/dist/chunk-0vp3wfab.js +0 -12
  19. package/dist/chunk-0warp8dx.js +0 -253
  20. package/dist/chunk-0xjaqda8.js +0 -1124
  21. package/dist/chunk-10gzv316.js +0 -62
  22. package/dist/chunk-11pq9n08.js +0 -168
  23. package/dist/chunk-1ae3nt9j.js +0 -31
  24. package/dist/chunk-1fmb0njn.js +0 -396
  25. package/dist/chunk-1gx78081.js +0 -66
  26. package/dist/chunk-1h2famwb.js +0 -49
  27. package/dist/chunk-1ng8xwxz.js +0 -276
  28. package/dist/chunk-1v7jp29h.js +0 -206
  29. package/dist/chunk-1xxy5zhb.js +0 -673
  30. package/dist/chunk-20b73w7w.js +0 -117
  31. package/dist/chunk-20qxd83a.js +0 -1161
  32. package/dist/chunk-2239ny9q.js +0 -90
  33. package/dist/chunk-22d4rnef.js +0 -226
  34. package/dist/chunk-26wtxbdc.js +0 -13870
  35. package/dist/chunk-27225bjh.js +0 -618
  36. package/dist/chunk-2b0e32an.js +0 -5822
  37. package/dist/chunk-2bfa9w1y.js +0 -323
  38. package/dist/chunk-2epq04w1.js +0 -63
  39. package/dist/chunk-2fwze72g.js +0 -24
  40. package/dist/chunk-2gzv8nrw.js +0 -205
  41. package/dist/chunk-2mexte1r.js +0 -349
  42. package/dist/chunk-2mzaqh5g.js +0 -338
  43. package/dist/chunk-2tb6mzfc.js +0 -81
  44. package/dist/chunk-2xq0g43w.js +0 -558
  45. package/dist/chunk-334aeqg9.js +0 -90
  46. package/dist/chunk-34jx4rjd.js +0 -995
  47. package/dist/chunk-35w5nhex.js +0 -132
  48. package/dist/chunk-3c25bcsw.js +0 -17
  49. package/dist/chunk-3eaxj8dg.js +0 -151
  50. package/dist/chunk-3fdgrwd2.js +0 -111
  51. package/dist/chunk-3jw0r58d.js +0 -121
  52. package/dist/chunk-3mgywd32.js +0 -8
  53. package/dist/chunk-3nk79af8.js +0 -8
  54. package/dist/chunk-3vy1jt9p.js +0 -1010
  55. package/dist/chunk-3x78pd4j.js +0 -153
  56. package/dist/chunk-47x3dsmn.js +0 -95
  57. package/dist/chunk-49pqt48n.js +0 -108
  58. package/dist/chunk-4f7m9fjw.js +0 -317
  59. package/dist/chunk-4jm600zv.js +0 -13
  60. package/dist/chunk-4k9d7gxv.js +0 -118
  61. package/dist/chunk-4net8san.js +0 -155
  62. package/dist/chunk-4pbx3g7s.js +0 -26
  63. package/dist/chunk-4v125j4z.js +0 -58
  64. package/dist/chunk-4vxkv5vz.js +0 -1438
  65. package/dist/chunk-51fqpjy3.js +0 -121
  66. package/dist/chunk-52e64f2h.js +0 -439
  67. package/dist/chunk-52e9mdjv.js +0 -684
  68. package/dist/chunk-55raexh7.js +0 -14358
  69. package/dist/chunk-59pq5122.js +0 -269
  70. package/dist/chunk-5bsj67v1.js +0 -349
  71. package/dist/chunk-5ccdsxgy.js +0 -74
  72. package/dist/chunk-5ekyhb1w.js +0 -422
  73. package/dist/chunk-5gcqdn8x.js +0 -867
  74. package/dist/chunk-5h5kx2jd.js +0 -34
  75. package/dist/chunk-5hf3werb.js +0 -193
  76. package/dist/chunk-5n1jc02d.js +0 -87
  77. package/dist/chunk-5wfxvxm8.js +0 -127
  78. package/dist/chunk-5wjebwmn.js +0 -89
  79. package/dist/chunk-5z28bqne.js +0 -6748
  80. package/dist/chunk-5zwsxpjn.js +0 -671
  81. package/dist/chunk-60phw466.js +0 -29
  82. package/dist/chunk-64c1avct.js +0 -13
  83. package/dist/chunk-64r16v22.js +0 -162
  84. package/dist/chunk-65t1r7zs.js +0 -418
  85. package/dist/chunk-66zry909.js +0 -11
  86. package/dist/chunk-67hxjjgc.js +0 -731
  87. package/dist/chunk-68ffk5qa.js +0 -14
  88. package/dist/chunk-69dr6rrd.js +0 -177
  89. package/dist/chunk-69n11zng.js +0 -436
  90. package/dist/chunk-6dj5t602.js +0 -341
  91. package/dist/chunk-6dngjwkh.js +0 -63
  92. package/dist/chunk-6dp8sz55.js +0 -3561
  93. package/dist/chunk-6hqgg0sv.js +0 -103
  94. package/dist/chunk-6nsd9606.js +0 -790
  95. package/dist/chunk-6p0hbwz3.js +0 -65
  96. package/dist/chunk-6ywdv5vg.js +0 -97
  97. package/dist/chunk-6zc758qw.js +0 -640
  98. package/dist/chunk-7aw745vx.js +0 -40175
  99. package/dist/chunk-7fxaphbq.js +0 -116
  100. package/dist/chunk-7sgtxrsc.js +0 -1059
  101. package/dist/chunk-7wm5s02e.js +0 -216
  102. package/dist/chunk-7xdk4109.js +0 -442
  103. package/dist/chunk-7xyswgjh.js +0 -8
  104. package/dist/chunk-83hfzbx3.js +0 -10
  105. package/dist/chunk-87m69h0v.js +0 -219
  106. package/dist/chunk-8g5pe1gr.js +0 -37
  107. package/dist/chunk-8jbw0fnf.js +0 -167
  108. package/dist/chunk-8jf9se66.js +0 -321
  109. package/dist/chunk-8p65embj.js +0 -875
  110. package/dist/chunk-8qrmaff1.js +0 -2669
  111. package/dist/chunk-8r975mwc.js +0 -93
  112. package/dist/chunk-8yhf030a.js +0 -69
  113. package/dist/chunk-93emz367.js +0 -107
  114. package/dist/chunk-948mn975.js +0 -460
  115. package/dist/chunk-99chkt7r.js +0 -54
  116. package/dist/chunk-9f7c1hzz.js +0 -50
  117. package/dist/chunk-9fk9ps1g.js +0 -178
  118. package/dist/chunk-9rh0k0aq.js +0 -90
  119. package/dist/chunk-9x5zgy22.js +0 -12
  120. package/dist/chunk-a0k2vj5b.js +0 -460
  121. package/dist/chunk-a0m57ssq.js +0 -325
  122. package/dist/chunk-a0nsmmz1.js +0 -133
  123. package/dist/chunk-a25jh1v4.js +0 -105
  124. package/dist/chunk-a4j5ekv0.js +0 -83
  125. package/dist/chunk-a8k3zf58.js +0 -313
  126. package/dist/chunk-ah0zarbq.js +0 -260
  127. package/dist/chunk-ase86y73.js +0 -15
  128. package/dist/chunk-b0kf00ff.js +0 -637
  129. package/dist/chunk-b1kcd3ss.js +0 -27
  130. package/dist/chunk-b8kcqqds.js +0 -93
  131. package/dist/chunk-bg4x9ex0.js +0 -21
  132. package/dist/chunk-bh5zqvyc.js +0 -36
  133. package/dist/chunk-bqrkfekw.js +0 -267
  134. package/dist/chunk-brjd9zmk.js +0 -42
  135. package/dist/chunk-byfawrfx.js +0 -121
  136. package/dist/chunk-c6sjhj89.js +0 -1284
  137. package/dist/chunk-c7e5yv0q.js +0 -212
  138. package/dist/chunk-c7jwbe76.js +0 -29030
  139. package/dist/chunk-cb5v8w7k.js +0 -289
  140. package/dist/chunk-cdef9v7b.js +0 -27
  141. package/dist/chunk-cdz5yb0r.js +0 -57
  142. package/dist/chunk-cgfdkzhb.js +0 -12
  143. package/dist/chunk-cgqw4x5z.js +0 -155
  144. package/dist/chunk-cnsj3vq2.js +0 -35
  145. package/dist/chunk-cqxm7ggc.js +0 -123
  146. package/dist/chunk-cxrktb5g.js +0 -51
  147. package/dist/chunk-d089t7dk.js +0 -312
  148. package/dist/chunk-d1z934cp.js +0 -71
  149. package/dist/chunk-d4mdda98.js +0 -94
  150. package/dist/chunk-d7xw8v91.js +0 -332
  151. package/dist/chunk-dc06c3rw.js +0 -1154
  152. package/dist/chunk-ddsjkqs4.js +0 -39
  153. package/dist/chunk-dfzkwynj.js +0 -5368
  154. package/dist/chunk-dnmp7s85.js +0 -20
  155. package/dist/chunk-dqqwjkv3.js +0 -8583
  156. package/dist/chunk-dt2mr4vf.js +0 -2962
  157. package/dist/chunk-dztm97gg.js +0 -150
  158. package/dist/chunk-e0abab5b.js +0 -445
  159. package/dist/chunk-e0ragz46.js +0 -209386
  160. package/dist/chunk-e9w9zc0g.js +0 -392
  161. package/dist/chunk-ebwskmsr.js +0 -107
  162. package/dist/chunk-efztk52j.js +0 -114
  163. package/dist/chunk-ehd8wacx.js +0 -40
  164. package/dist/chunk-ehtwnxpg.js +0 -1591
  165. package/dist/chunk-eqp1rfft.js +0 -17
  166. package/dist/chunk-etdt1xz3.js +0 -19
  167. package/dist/chunk-eva785x8.js +0 -88
  168. package/dist/chunk-ewadzrm8.js +0 -103
  169. package/dist/chunk-f2ajmcav.js +0 -92
  170. package/dist/chunk-fajg8x36.js +0 -8158
  171. package/dist/chunk-fbv4apne.js +0 -51
  172. package/dist/chunk-fcynwjpm.js +0 -1072
  173. package/dist/chunk-fev86f95.js +0 -1052
  174. package/dist/chunk-feyzykye.js +0 -10
  175. package/dist/chunk-ff85rwvc.js +0 -180
  176. package/dist/chunk-fk6ktvg2.js +0 -275
  177. package/dist/chunk-fqak69ft.js +0 -458
  178. package/dist/chunk-fqwas4jk.js +0 -281
  179. package/dist/chunk-fs35fdpj.js +0 -439
  180. package/dist/chunk-fvr3f9s3.js +0 -55
  181. package/dist/chunk-fyc5fepv.js +0 -10
  182. package/dist/chunk-g2g9cwt9.js +0 -54
  183. package/dist/chunk-g4znz46v.js +0 -2335
  184. package/dist/chunk-g5ts4e6k.js +0 -697
  185. package/dist/chunk-g6een9wr.js +0 -654
  186. package/dist/chunk-g7cmtx8r.js +0 -77
  187. package/dist/chunk-g9f19ttm.js +0 -15
  188. package/dist/chunk-gc7ap41t.js +0 -516
  189. package/dist/chunk-gdwdqewd.js +0 -19
  190. package/dist/chunk-gg14h3n4.js +0 -131
  191. package/dist/chunk-gg55fns0.js +0 -6440
  192. package/dist/chunk-gq7zab4e.js +0 -418
  193. package/dist/chunk-gydw3qy3.js +0 -169
  194. package/dist/chunk-gz1e8y1w.js +0 -33
  195. package/dist/chunk-h19r628d.js +0 -91
  196. package/dist/chunk-h2k8mt3z.js +0 -329
  197. package/dist/chunk-h9n54swm.js +0 -27
  198. package/dist/chunk-hakdhagh.js +0 -16606
  199. package/dist/chunk-hc2chp3g.js +0 -308
  200. package/dist/chunk-hemcv9t7.js +0 -153
  201. package/dist/chunk-hm62ntv3.js +0 -20
  202. package/dist/chunk-hmq09ytj.js +0 -100
  203. package/dist/chunk-hmv4hhqt.js +0 -2718
  204. package/dist/chunk-hwfknpxv.js +0 -39
  205. package/dist/chunk-j5bth84e.js +0 -97
  206. package/dist/chunk-j64ga6ta.js +0 -8035
  207. package/dist/chunk-j6v3w4yf.js +0 -244
  208. package/dist/chunk-jc29d2nm.js +0 -130
  209. package/dist/chunk-jd32zbps.js +0 -15
  210. package/dist/chunk-jd4sx4wh.js +0 -594
  211. package/dist/chunk-jha8n8b9.js +0 -33118
  212. package/dist/chunk-jj71qx7m.js +0 -122
  213. package/dist/chunk-jka9vpak.js +0 -114
  214. package/dist/chunk-jkf6ayv0.js +0 -32
  215. package/dist/chunk-jpz6t2tt.js +0 -61
  216. package/dist/chunk-jqt3sw12.js +0 -9114
  217. package/dist/chunk-jswd1q63.js +0 -101
  218. package/dist/chunk-jtc4aa2y.js +0 -1543
  219. package/dist/chunk-jyx3h86z.js +0 -635
  220. package/dist/chunk-jzthz1bx.js +0 -15
  221. package/dist/chunk-k0p9w03v.js +0 -4957
  222. package/dist/chunk-k6x3s7x5.js +0 -211
  223. package/dist/chunk-k7kmvnnx.js +0 -942
  224. package/dist/chunk-k8vp0atq.js +0 -2331
  225. package/dist/chunk-k9vm6x6z.js +0 -257
  226. package/dist/chunk-kb1edvhs.js +0 -120
  227. package/dist/chunk-kbhbe33q.js +0 -113
  228. package/dist/chunk-kgcgpp7z.js +0 -140
  229. package/dist/chunk-kvywbvqs.js +0 -261
  230. package/dist/chunk-kwekc97v.js +0 -18
  231. package/dist/chunk-kwyk9zp1.js +0 -74
  232. package/dist/chunk-ky1z78ve.js +0 -119
  233. package/dist/chunk-mcws22k3.js +0 -42
  234. package/dist/chunk-mr2z79r3.js +0 -1385
  235. package/dist/chunk-mst9nmns.js +0 -642
  236. package/dist/chunk-mswx2nma.js +0 -103
  237. package/dist/chunk-n1e3fjpz.js +0 -266
  238. package/dist/chunk-n6vjp9yg.js +0 -138
  239. package/dist/chunk-n84tqtvv.js +0 -120
  240. package/dist/chunk-n8ssddbw.js +0 -105
  241. package/dist/chunk-na35whkd.js +0 -227
  242. package/dist/chunk-netzwgv1.js +0 -154
  243. package/dist/chunk-ng7j0yy1.js +0 -100
  244. package/dist/chunk-nmgj86tt.js +0 -24
  245. package/dist/chunk-ns7x6xam.js +0 -22820
  246. package/dist/chunk-p7vkh4wx.js +0 -15
  247. package/dist/chunk-p8na2wwp.js +0 -14
  248. package/dist/chunk-pe3rkfp2.js +0 -74
  249. package/dist/chunk-pf0152j3.js +0 -40
  250. package/dist/chunk-pgtnj1mt.js +0 -705
  251. package/dist/chunk-ppwjyveh.js +0 -8
  252. package/dist/chunk-pq5qp2y4.js +0 -388
  253. package/dist/chunk-pqqxdk5f.js +0 -543
  254. package/dist/chunk-ps49ymvj.js +0 -43
  255. package/dist/chunk-pws8gq7m.js +0 -7422
  256. package/dist/chunk-pwwa7s62.js +0 -11
  257. package/dist/chunk-pyq0fabn.js +0 -860
  258. package/dist/chunk-q0p1m40t.js +0 -79
  259. package/dist/chunk-q0vhv550.js +0 -393
  260. package/dist/chunk-q7r0kt08.js +0 -1809
  261. package/dist/chunk-qajrkk97.js +0 -298
  262. package/dist/chunk-qatfdxvd.js +0 -34
  263. package/dist/chunk-qb6k2afy.js +0 -153
  264. package/dist/chunk-qg2qgx8h.js +0 -266
  265. package/dist/chunk-qkczt8cr.js +0 -24
  266. package/dist/chunk-qnfx3qtx.js +0 -617
  267. package/dist/chunk-qp2qdcda.js +0 -100
  268. package/dist/chunk-qtwgzej9.js +0 -85
  269. package/dist/chunk-r1dh0ymt.js +0 -91
  270. package/dist/chunk-r36xvgvv.js +0 -407
  271. package/dist/chunk-r48he8g3.js +0 -251
  272. package/dist/chunk-r63tqmtk.js +0 -146
  273. package/dist/chunk-rbdd3q5k.js +0 -101
  274. package/dist/chunk-rmbbmd3s.js +0 -68
  275. package/dist/chunk-rn0v1hk8.js +0 -34
  276. package/dist/chunk-rnxctq9p.js +0 -1646
  277. package/dist/chunk-rrs2mchs.js +0 -183
  278. package/dist/chunk-rtrybvnp.js +0 -209
  279. package/dist/chunk-rw2wkn45.js +0 -494
  280. package/dist/chunk-s4kzkdhd.js +0 -847
  281. package/dist/chunk-s7a0zn7b.js +0 -55
  282. package/dist/chunk-s8gy4ky9.js +0 -122
  283. package/dist/chunk-s8kj6ajy.js +0 -32
  284. package/dist/chunk-sag785ad.js +0 -283
  285. package/dist/chunk-scqjyben.js +0 -174
  286. package/dist/chunk-sd36yzx8.js +0 -954
  287. package/dist/chunk-sdtqm0nm.js +0 -374
  288. package/dist/chunk-sg60xg0x.js +0 -52
  289. package/dist/chunk-sgpmpn90.js +0 -35
  290. package/dist/chunk-sh02d2qn.js +0 -38
  291. package/dist/chunk-sz9y6z13.js +0 -61
  292. package/dist/chunk-szj5wvdy.js +0 -28
  293. package/dist/chunk-t29a6zb5.js +0 -45
  294. package/dist/chunk-t2b49hcf.js +0 -87
  295. package/dist/chunk-t2wqdppz.js +0 -445
  296. package/dist/chunk-t4khqff1.js +0 -16
  297. package/dist/chunk-t70t2gne.js +0 -121
  298. package/dist/chunk-t9p85zff.js +0 -24
  299. package/dist/chunk-tkrstmwz.js +0 -94
  300. package/dist/chunk-tnyb4exc.js +0 -74
  301. package/dist/chunk-tpn8jsvw.js +0 -71
  302. package/dist/chunk-tt7x5j1q.js +0 -111
  303. package/dist/chunk-tw1p628z.js +0 -984
  304. package/dist/chunk-twvdafcz.js +0 -528
  305. package/dist/chunk-tzwjafgn.js +0 -24
  306. package/dist/chunk-v140t8ay.js +0 -152
  307. package/dist/chunk-v1kzp02e.js +0 -785
  308. package/dist/chunk-v4t6dyyh.js +0 -9076
  309. package/dist/chunk-v78fj8by.js +0 -145
  310. package/dist/chunk-v8kjswxt.js +0 -61
  311. package/dist/chunk-v9smspw2.js +0 -4301
  312. package/dist/chunk-vcfbjkk9.js +0 -201
  313. package/dist/chunk-ve167rcs.js +0 -148
  314. package/dist/chunk-vf612n57.js +0 -472
  315. package/dist/chunk-vhffyae8.js +0 -895
  316. package/dist/chunk-vkhrrvfq.js +0 -44
  317. package/dist/chunk-vybkmfhf.js +0 -91
  318. package/dist/chunk-vyjeh50y.js +0 -2149
  319. package/dist/chunk-w6m6trzq.js +0 -58
  320. package/dist/chunk-w9b6kngq.js +0 -234
  321. package/dist/chunk-wa8yn2p0.js +0 -2007
  322. package/dist/chunk-wanceff6.js +0 -2840
  323. package/dist/chunk-wcze2nea.js +0 -336
  324. package/dist/chunk-wgk9sxk7.js +0 -329
  325. package/dist/chunk-wnxcgfsd.js +0 -253
  326. package/dist/chunk-wyjerrr6.js +0 -565
  327. package/dist/chunk-wz9brkq5.js +0 -60
  328. package/dist/chunk-x47h283a.js +0 -56
  329. package/dist/chunk-x59j3x9c.js +0 -98
  330. package/dist/chunk-x6r4v44b.js +0 -8
  331. package/dist/chunk-x7fdwq3d.js +0 -33
  332. package/dist/chunk-x8d2ehd7.js +0 -19
  333. package/dist/chunk-xeb6075z.js +0 -3435
  334. package/dist/chunk-xfw2pxwd.js +0 -223
  335. package/dist/chunk-xh06jc72.js +0 -200
  336. package/dist/chunk-xhfmdq1y.js +0 -147
  337. package/dist/chunk-xkwyg1d2.js +0 -195
  338. package/dist/chunk-xv3era3s.js +0 -8
  339. package/dist/chunk-xyapc58m.js +0 -87
  340. package/dist/chunk-xzgnc76g.js +0 -107
  341. package/dist/chunk-y1784krc.js +0 -19
  342. package/dist/chunk-y4ca9kqz.js +0 -3830
  343. package/dist/chunk-y9bhjjdz.js +0 -145
  344. package/dist/chunk-yb3bxv3w.js +0 -30
  345. package/dist/chunk-yddek6xk.js +0 -146
  346. package/dist/chunk-ypaq3d12.js +0 -4265
  347. package/dist/chunk-yq8z040g.js +0 -111
  348. package/dist/chunk-yqs481qq.js +0 -1163
  349. package/dist/chunk-ys9a9c9h.js +0 -105
  350. package/dist/chunk-yyex5gsf.js +0 -269
  351. package/dist/chunk-yzn396hn.js +0 -89
  352. package/dist/chunk-z2dp53wn.js +0 -17
  353. package/dist/chunk-zay4xp4n.js +0 -251
  354. package/dist/chunk-zc8bwy57.js +0 -212
  355. package/dist/chunk-zhx88cfx.js +0 -97
  356. package/dist/chunk-zkh6f4ct.js +0 -385
  357. package/dist/chunk-zq56gcca.js +0 -206
  358. package/dist/chunk-zrkefd22.js +0 -490
  359. package/dist/chunk-zs5p0yq1.js +0 -1030
  360. package/dist/chunk-zxh62ved.js +0 -31
  361. package/dist/chunk-zzm33q8x.js +0 -8
  362. package/dist/cli.js +0 -220
@@ -1,4957 +0,0 @@
1
- // @bun
2
- import {
3
- require_detect_libc
4
- } from "./chunk-6dj5t602.js";
5
- import {
6
- require_coerce,
7
- require_gte,
8
- require_satisfies
9
- } from "./chunk-0xjaqda8.js";
10
- import {
11
- __commonJS,
12
- __require
13
- } from "./chunk-qp2qdcda.js";
14
-
15
- // node_modules/.bun/sharp@0.34.5/node_modules/sharp/lib/is.js
16
- var require_is = __commonJS((exports, module) => {
17
- /*!
18
- Copyright 2013 Lovell Fuller and others.
19
- SPDX-License-Identifier: Apache-2.0
20
- */
21
- var defined = (val) => typeof val !== "undefined" && val !== null;
22
- var object = (val) => typeof val === "object";
23
- var plainObject = (val) => Object.prototype.toString.call(val) === "[object Object]";
24
- var fn = (val) => typeof val === "function";
25
- var bool = (val) => typeof val === "boolean";
26
- var buffer = (val) => val instanceof Buffer;
27
- var typedArray = (val) => {
28
- if (defined(val)) {
29
- switch (val.constructor) {
30
- case Uint8Array:
31
- case Uint8ClampedArray:
32
- case Int8Array:
33
- case Uint16Array:
34
- case Int16Array:
35
- case Uint32Array:
36
- case Int32Array:
37
- case Float32Array:
38
- case Float64Array:
39
- return true;
40
- }
41
- }
42
- return false;
43
- };
44
- var arrayBuffer = (val) => val instanceof ArrayBuffer;
45
- var string = (val) => typeof val === "string" && val.length > 0;
46
- var number = (val) => typeof val === "number" && !Number.isNaN(val);
47
- var integer = (val) => Number.isInteger(val);
48
- var inRange = (val, min, max) => val >= min && val <= max;
49
- var inArray = (val, list) => list.includes(val);
50
- var invalidParameterError = (name, expected, actual) => new Error(`Expected ${expected} for ${name} but received ${actual} of type ${typeof actual}`);
51
- var nativeError = (native, context) => {
52
- context.message = native.message;
53
- return context;
54
- };
55
- module.exports = {
56
- defined,
57
- object,
58
- plainObject,
59
- fn,
60
- bool,
61
- buffer,
62
- typedArray,
63
- arrayBuffer,
64
- string,
65
- number,
66
- integer,
67
- inRange,
68
- inArray,
69
- invalidParameterError,
70
- nativeError
71
- };
72
- });
73
-
74
- // node_modules/.bun/sharp@0.34.5/node_modules/sharp/package.json
75
- var require_package = __commonJS((exports, module) => {
76
- module.exports = {
77
- name: "sharp",
78
- description: "High performance Node.js image processing, the fastest module to resize JPEG, PNG, WebP, GIF, AVIF and TIFF images",
79
- version: "0.34.5",
80
- author: "Lovell Fuller <npm@lovell.info>",
81
- homepage: "https://sharp.pixelplumbing.com",
82
- contributors: [
83
- "Pierre Inglebert <pierre.inglebert@gmail.com>",
84
- "Jonathan Ong <jonathanrichardong@gmail.com>",
85
- "Chanon Sajjamanochai <chanon.s@gmail.com>",
86
- "Juliano Julio <julianojulio@gmail.com>",
87
- "Daniel Gasienica <daniel@gasienica.ch>",
88
- "Julian Walker <julian@fiftythree.com>",
89
- "Amit Pitaru <pitaru.amit@gmail.com>",
90
- "Brandon Aaron <hello.brandon@aaron.sh>",
91
- "Andreas Lind <andreas@one.com>",
92
- "Maurus Cuelenaere <mcuelenaere@gmail.com>",
93
- "Linus Unneb\xE4ck <linus@folkdatorn.se>",
94
- "Victor Mateevitsi <mvictoras@gmail.com>",
95
- "Alaric Holloway <alaric.holloway@gmail.com>",
96
- "Bernhard K. Weisshuhn <bkw@codingforce.com>",
97
- "Chris Riley <criley@primedia.com>",
98
- "David Carley <dacarley@gmail.com>",
99
- "John Tobin <john@limelightmobileinc.com>",
100
- "Kenton Gray <kentongray@gmail.com>",
101
- "Felix B\xFCnemann <Felix.Buenemann@gmail.com>",
102
- "Samy Al Zahrani <samyalzahrany@gmail.com>",
103
- "Chintan Thakkar <lemnisk8@gmail.com>",
104
- "F. Orlando Galashan <frulo@gmx.de>",
105
- "Kleis Auke Wolthuizen <info@kleisauke.nl>",
106
- "Matt Hirsch <mhirsch@media.mit.edu>",
107
- "Matthias Thoemmes <thoemmes@gmail.com>",
108
- "Patrick Paskaris <patrick@paskaris.gr>",
109
- "J\xE9r\xE9my Lal <kapouer@melix.org>",
110
- "Rahul Nanwani <r.nanwani@gmail.com>",
111
- "Alice Monday <alice0meta@gmail.com>",
112
- "Kristo Jorgenson <kristo.jorgenson@gmail.com>",
113
- "YvesBos <yves_bos@outlook.com>",
114
- "Guy Maliar <guy@tailorbrands.com>",
115
- "Nicolas Coden <nicolas@ncoden.fr>",
116
- "Matt Parrish <matt.r.parrish@gmail.com>",
117
- "Marcel Bretschneider <marcel.bretschneider@gmail.com>",
118
- "Matthew McEachen <matthew+github@mceachen.org>",
119
- "Jarda Kot\u011B\u0161ovec <jarda.kotesovec@gmail.com>",
120
- "Kenric D'Souza <kenric.dsouza@gmail.com>",
121
- "Oleh Aleinyk <oleg.aleynik@gmail.com>",
122
- "Marcel Bretschneider <marcel.bretschneider@gmail.com>",
123
- "Andrea Bianco <andrea.bianco@unibas.ch>",
124
- "Rik Heywood <rik@rik.org>",
125
- "Thomas Parisot <hi@oncletom.io>",
126
- "Nathan Graves <nathanrgraves+github@gmail.com>",
127
- "Tom Lokhorst <tom@lokhorst.eu>",
128
- "Espen Hovlandsdal <espen@hovlandsdal.com>",
129
- "Sylvain Dumont <sylvain.dumont35@gmail.com>",
130
- "Alun Davies <alun.owain.davies@googlemail.com>",
131
- "Aidan Hoolachan <ajhoolachan21@gmail.com>",
132
- "Axel Eirola <axel.eirola@iki.fi>",
133
- "Freezy <freezy@xbmc.org>",
134
- "Daiz <taneli.vatanen@gmail.com>",
135
- "Julian Aubourg <j@ubourg.net>",
136
- "Keith Belovay <keith@picthrive.com>",
137
- "Michael B. Klein <mbklein@gmail.com>",
138
- "Jordan Prudhomme <jordan@raboland.fr>",
139
- "Ilya Ovdin <iovdin@gmail.com>",
140
- "Andargor <andargor@yahoo.com>",
141
- "Paul Neave <paul.neave@gmail.com>",
142
- "Brendan Kennedy <brenwken@gmail.com>",
143
- "Brychan Bennett-Odlum <git@brychan.io>",
144
- "Edward Silverton <e.silverton@gmail.com>",
145
- "Roman Malieiev <aromaleev@gmail.com>",
146
- "Tomas Szabo <tomas.szabo@deftomat.com>",
147
- "Robert O'Rourke <robert@o-rourke.org>",
148
- "Guillermo Alfonso Varela Chouci\xF1o <guillevch@gmail.com>",
149
- "Christian Flintrup <chr@gigahost.dk>",
150
- "Manan Jadhav <manan@motionden.com>",
151
- "Leon Radley <leon@radley.se>",
152
- "alza54 <alza54@thiocod.in>",
153
- "Jacob Smith <jacob@frende.me>",
154
- "Michael Nutt <michael@nutt.im>",
155
- "Brad Parham <baparham@gmail.com>",
156
- "Taneli Vatanen <taneli.vatanen@gmail.com>",
157
- "Joris Dugu\xE9 <zaruike10@gmail.com>",
158
- "Chris Banks <christopher.bradley.banks@gmail.com>",
159
- "Ompal Singh <ompal.hitm09@gmail.com>",
160
- "Brodan <christopher.hranj@gmail.com>",
161
- "Ankur Parihar <ankur.github@gmail.com>",
162
- "Brahim Ait elhaj <brahima@gmail.com>",
163
- "Mart Jansink <m.jansink@gmail.com>",
164
- "Lachlan Newman <lachnewman007@gmail.com>",
165
- "Dennis Beatty <dennis@dcbeatty.com>",
166
- "Ingvar Stepanyan <me@rreverser.com>",
167
- "Don Denton <don@happycollision.com>"
168
- ],
169
- scripts: {
170
- build: "node install/build.js",
171
- install: "node install/check.js || npm run build",
172
- clean: "rm -rf src/build/ .nyc_output/ coverage/ test/fixtures/output.*",
173
- test: "npm run lint && npm run test-unit",
174
- lint: "npm run lint-cpp && npm run lint-js && npm run lint-types",
175
- "lint-cpp": "cpplint --quiet src/*.h src/*.cc",
176
- "lint-js": "biome lint",
177
- "lint-types": "tsd --files ./test/types/sharp.test-d.ts",
178
- "test-leak": "./test/leak/leak.sh",
179
- "test-unit": "node --experimental-test-coverage test/unit.mjs",
180
- "package-from-local-build": "node npm/from-local-build.js",
181
- "package-release-notes": "node npm/release-notes.js",
182
- "docs-build": "node docs/build.mjs",
183
- "docs-serve": "cd docs && npm start",
184
- "docs-publish": "cd docs && npm run build && npx firebase-tools deploy --project pixelplumbing --only hosting:pixelplumbing-sharp"
185
- },
186
- type: "commonjs",
187
- main: "lib/index.js",
188
- types: "lib/index.d.ts",
189
- files: [
190
- "install",
191
- "lib",
192
- "src/*.{cc,h,gyp}"
193
- ],
194
- repository: {
195
- type: "git",
196
- url: "git://github.com/lovell/sharp.git"
197
- },
198
- keywords: [
199
- "jpeg",
200
- "png",
201
- "webp",
202
- "avif",
203
- "tiff",
204
- "gif",
205
- "svg",
206
- "jp2",
207
- "dzi",
208
- "image",
209
- "resize",
210
- "thumbnail",
211
- "crop",
212
- "embed",
213
- "libvips",
214
- "vips"
215
- ],
216
- dependencies: {
217
- "@img/colour": "^1.0.0",
218
- "detect-libc": "^2.1.2",
219
- semver: "^7.7.3"
220
- },
221
- optionalDependencies: {
222
- "@img/sharp-darwin-arm64": "0.34.5",
223
- "@img/sharp-darwin-x64": "0.34.5",
224
- "@img/sharp-libvips-darwin-arm64": "1.2.4",
225
- "@img/sharp-libvips-darwin-x64": "1.2.4",
226
- "@img/sharp-libvips-linux-arm": "1.2.4",
227
- "@img/sharp-libvips-linux-arm64": "1.2.4",
228
- "@img/sharp-libvips-linux-ppc64": "1.2.4",
229
- "@img/sharp-libvips-linux-riscv64": "1.2.4",
230
- "@img/sharp-libvips-linux-s390x": "1.2.4",
231
- "@img/sharp-libvips-linux-x64": "1.2.4",
232
- "@img/sharp-libvips-linuxmusl-arm64": "1.2.4",
233
- "@img/sharp-libvips-linuxmusl-x64": "1.2.4",
234
- "@img/sharp-linux-arm": "0.34.5",
235
- "@img/sharp-linux-arm64": "0.34.5",
236
- "@img/sharp-linux-ppc64": "0.34.5",
237
- "@img/sharp-linux-riscv64": "0.34.5",
238
- "@img/sharp-linux-s390x": "0.34.5",
239
- "@img/sharp-linux-x64": "0.34.5",
240
- "@img/sharp-linuxmusl-arm64": "0.34.5",
241
- "@img/sharp-linuxmusl-x64": "0.34.5",
242
- "@img/sharp-wasm32": "0.34.5",
243
- "@img/sharp-win32-arm64": "0.34.5",
244
- "@img/sharp-win32-ia32": "0.34.5",
245
- "@img/sharp-win32-x64": "0.34.5"
246
- },
247
- devDependencies: {
248
- "@biomejs/biome": "^2.3.4",
249
- "@cpplint/cli": "^0.1.0",
250
- "@emnapi/runtime": "^1.7.0",
251
- "@img/sharp-libvips-dev": "1.2.4",
252
- "@img/sharp-libvips-dev-wasm32": "1.2.4",
253
- "@img/sharp-libvips-win32-arm64": "1.2.4",
254
- "@img/sharp-libvips-win32-ia32": "1.2.4",
255
- "@img/sharp-libvips-win32-x64": "1.2.4",
256
- "@types/node": "*",
257
- emnapi: "^1.7.0",
258
- "exif-reader": "^2.0.2",
259
- "extract-zip": "^2.0.1",
260
- icc: "^3.0.0",
261
- "jsdoc-to-markdown": "^9.1.3",
262
- "node-addon-api": "^8.5.0",
263
- "node-gyp": "^11.5.0",
264
- "tar-fs": "^3.1.1",
265
- tsd: "^0.33.0"
266
- },
267
- license: "Apache-2.0",
268
- engines: {
269
- node: "^18.17.0 || ^20.3.0 || >=21.0.0"
270
- },
271
- config: {
272
- libvips: ">=8.17.3"
273
- },
274
- funding: {
275
- url: "https://opencollective.com/libvips"
276
- }
277
- };
278
- });
279
-
280
- // node_modules/.bun/sharp@0.34.5/node_modules/sharp/lib/libvips.js
281
- var require_libvips = __commonJS((exports, module) => {
282
- /*!
283
- Copyright 2013 Lovell Fuller and others.
284
- SPDX-License-Identifier: Apache-2.0
285
- */
286
- var { spawnSync } = __require("child_process");
287
- var { createHash } = __require("crypto");
288
- var semverCoerce = require_coerce();
289
- var semverGreaterThanOrEqualTo = require_gte();
290
- var semverSatisfies = require_satisfies();
291
- var detectLibc = require_detect_libc();
292
- var { config, engines, optionalDependencies } = require_package();
293
- var minimumLibvipsVersionLabelled = process.env.npm_package_config_libvips || config.libvips;
294
- var minimumLibvipsVersion = semverCoerce(minimumLibvipsVersionLabelled).version;
295
- var prebuiltPlatforms = [
296
- "darwin-arm64",
297
- "darwin-x64",
298
- "linux-arm",
299
- "linux-arm64",
300
- "linux-ppc64",
301
- "linux-riscv64",
302
- "linux-s390x",
303
- "linux-x64",
304
- "linuxmusl-arm64",
305
- "linuxmusl-x64",
306
- "win32-arm64",
307
- "win32-ia32",
308
- "win32-x64"
309
- ];
310
- var spawnSyncOptions = {
311
- encoding: "utf8",
312
- shell: true
313
- };
314
- var log = (item) => {
315
- if (item instanceof Error) {
316
- console.error(`sharp: Installation error: ${item.message}`);
317
- } else {
318
- console.log(`sharp: ${item}`);
319
- }
320
- };
321
- var runtimeLibc = () => detectLibc.isNonGlibcLinuxSync() ? detectLibc.familySync() : "";
322
- var runtimePlatformArch = () => `${process.platform}${runtimeLibc()}-${process.arch}`;
323
- var buildPlatformArch = () => {
324
- if (isEmscripten()) {
325
- return "wasm32";
326
- }
327
- const { npm_config_arch, npm_config_platform, npm_config_libc } = process.env;
328
- const libc = typeof npm_config_libc === "string" ? npm_config_libc : runtimeLibc();
329
- return `${npm_config_platform || process.platform}${libc}-${npm_config_arch || process.arch}`;
330
- };
331
- var buildSharpLibvipsIncludeDir = () => {
332
- try {
333
- return __require(`@img/sharp-libvips-dev-${buildPlatformArch()}/include`);
334
- } catch {
335
- try {
336
- return (()=>{throw new Error("Cannot require module "+"@img/sharp-libvips-dev/include");})();
337
- } catch {}
338
- }
339
- return "";
340
- };
341
- var buildSharpLibvipsCPlusPlusDir = () => {
342
- try {
343
- return (()=>{throw new Error("Cannot require module "+"@img/sharp-libvips-dev/cplusplus");})();
344
- } catch {}
345
- return "";
346
- };
347
- var buildSharpLibvipsLibDir = () => {
348
- try {
349
- return __require(`@img/sharp-libvips-dev-${buildPlatformArch()}/lib`);
350
- } catch {
351
- try {
352
- return __require(`@img/sharp-libvips-${buildPlatformArch()}/lib`);
353
- } catch {}
354
- }
355
- return "";
356
- };
357
- var isUnsupportedNodeRuntime = () => {
358
- if (process.release?.name === "node" && process.versions) {
359
- if (!semverSatisfies(process.versions.node, engines.node)) {
360
- return { found: process.versions.node, expected: engines.node };
361
- }
362
- }
363
- };
364
- var isEmscripten = () => {
365
- const { CC } = process.env;
366
- return Boolean(CC?.endsWith("/emcc"));
367
- };
368
- var isRosetta = () => {
369
- if (process.platform === "darwin" && process.arch === "x64") {
370
- const translated = spawnSync("sysctl sysctl.proc_translated", spawnSyncOptions).stdout;
371
- return (translated || "").trim() === "sysctl.proc_translated: 1";
372
- }
373
- return false;
374
- };
375
- var sha512 = (s) => createHash("sha512").update(s).digest("hex");
376
- var yarnLocator = () => {
377
- try {
378
- const identHash = sha512(`imgsharp-libvips-${buildPlatformArch()}`);
379
- const npmVersion = semverCoerce(optionalDependencies[`@img/sharp-libvips-${buildPlatformArch()}`], {
380
- includePrerelease: true
381
- }).version;
382
- return sha512(`${identHash}npm:${npmVersion}`).slice(0, 10);
383
- } catch {}
384
- return "";
385
- };
386
- var spawnRebuild = () => spawnSync(`node-gyp rebuild --directory=src ${isEmscripten() ? "--nodedir=emscripten" : ""}`, {
387
- ...spawnSyncOptions,
388
- stdio: "inherit"
389
- }).status;
390
- var globalLibvipsVersion = () => {
391
- if (process.platform !== "win32") {
392
- const globalLibvipsVersion2 = spawnSync("pkg-config --modversion vips-cpp", {
393
- ...spawnSyncOptions,
394
- env: {
395
- ...process.env,
396
- PKG_CONFIG_PATH: pkgConfigPath()
397
- }
398
- }).stdout;
399
- return (globalLibvipsVersion2 || "").trim();
400
- } else {
401
- return "";
402
- }
403
- };
404
- var pkgConfigPath = () => {
405
- if (process.platform !== "win32") {
406
- const brewPkgConfigPath = spawnSync('which brew >/dev/null 2>&1 && brew environment --plain | grep PKG_CONFIG_LIBDIR | cut -d" " -f2', spawnSyncOptions).stdout || "";
407
- return [
408
- brewPkgConfigPath.trim(),
409
- process.env.PKG_CONFIG_PATH,
410
- "/usr/local/lib/pkgconfig",
411
- "/usr/lib/pkgconfig",
412
- "/usr/local/libdata/pkgconfig",
413
- "/usr/libdata/pkgconfig"
414
- ].filter(Boolean).join(":");
415
- } else {
416
- return "";
417
- }
418
- };
419
- var skipSearch = (status, reason, logger) => {
420
- if (logger) {
421
- logger(`Detected ${reason}, skipping search for globally-installed libvips`);
422
- }
423
- return status;
424
- };
425
- var useGlobalLibvips = (logger) => {
426
- if (Boolean(process.env.SHARP_IGNORE_GLOBAL_LIBVIPS) === true) {
427
- return skipSearch(false, "SHARP_IGNORE_GLOBAL_LIBVIPS", logger);
428
- }
429
- if (Boolean(process.env.SHARP_FORCE_GLOBAL_LIBVIPS) === true) {
430
- return skipSearch(true, "SHARP_FORCE_GLOBAL_LIBVIPS", logger);
431
- }
432
- if (isRosetta()) {
433
- return skipSearch(false, "Rosetta", logger);
434
- }
435
- const globalVipsVersion = globalLibvipsVersion();
436
- return !!globalVipsVersion && semverGreaterThanOrEqualTo(globalVipsVersion, minimumLibvipsVersion);
437
- };
438
- module.exports = {
439
- minimumLibvipsVersion,
440
- prebuiltPlatforms,
441
- buildPlatformArch,
442
- buildSharpLibvipsIncludeDir,
443
- buildSharpLibvipsCPlusPlusDir,
444
- buildSharpLibvipsLibDir,
445
- isUnsupportedNodeRuntime,
446
- runtimePlatformArch,
447
- log,
448
- yarnLocator,
449
- spawnRebuild,
450
- globalLibvipsVersion,
451
- pkgConfigPath,
452
- useGlobalLibvips
453
- };
454
- });
455
-
456
- // node_modules/.bun/sharp@0.34.5/node_modules/sharp/lib/sharp.js
457
- var require_sharp = __commonJS((exports, module) => {
458
- /*!
459
- Copyright 2013 Lovell Fuller and others.
460
- SPDX-License-Identifier: Apache-2.0
461
- */
462
- var { familySync, versionSync } = require_detect_libc();
463
- var { runtimePlatformArch, isUnsupportedNodeRuntime, prebuiltPlatforms, minimumLibvipsVersion } = require_libvips();
464
- var runtimePlatform = runtimePlatformArch();
465
- var paths = [
466
- `../src/build/Release/sharp-${runtimePlatform}.node`,
467
- "../src/build/Release/sharp-wasm32.node",
468
- `@img/sharp-${runtimePlatform}/sharp.node`,
469
- "@img/sharp-wasm32/sharp.node"
470
- ];
471
- var path;
472
- var sharp;
473
- var errors = [];
474
- for (path of paths) {
475
- try {
476
- sharp = __require(path);
477
- break;
478
- } catch (err) {
479
- errors.push(err);
480
- }
481
- }
482
- if (sharp && path.startsWith("@img/sharp-linux-x64") && !sharp._isUsingX64V2()) {
483
- const err = new Error("Prebuilt binaries for linux-x64 require v2 microarchitecture");
484
- err.code = "Unsupported CPU";
485
- errors.push(err);
486
- sharp = null;
487
- }
488
- if (sharp) {
489
- module.exports = sharp;
490
- } else {
491
- const [isLinux, isMacOs, isWindows] = ["linux", "darwin", "win32"].map((os) => runtimePlatform.startsWith(os));
492
- const help = [`Could not load the "sharp" module using the ${runtimePlatform} runtime`];
493
- errors.forEach((err) => {
494
- if (err.code !== "MODULE_NOT_FOUND") {
495
- help.push(`${err.code}: ${err.message}`);
496
- }
497
- });
498
- const messages = errors.map((err) => err.message).join(" ");
499
- help.push("Possible solutions:");
500
- if (isUnsupportedNodeRuntime()) {
501
- const { found, expected } = isUnsupportedNodeRuntime();
502
- help.push("- Please upgrade Node.js:", ` Found ${found}`, ` Requires ${expected}`);
503
- } else if (prebuiltPlatforms.includes(runtimePlatform)) {
504
- const [os, cpu] = runtimePlatform.split("-");
505
- const libc = os.endsWith("musl") ? " --libc=musl" : "";
506
- help.push("- Ensure optional dependencies can be installed:", " npm install --include=optional sharp", "- Ensure your package manager supports multi-platform installation:", " See https://sharp.pixelplumbing.com/install#cross-platform", "- Add platform-specific dependencies:", ` npm install --os=${os.replace("musl", "")}${libc} --cpu=${cpu} sharp`);
507
- } else {
508
- help.push(`- Manually install libvips >= ${minimumLibvipsVersion}`, "- Add experimental WebAssembly-based dependencies:", " npm install --cpu=wasm32 sharp", " npm install @img/sharp-wasm32");
509
- }
510
- if (isLinux && /(symbol not found|CXXABI_)/i.test(messages)) {
511
- try {
512
- const { config } = __require(`@img/sharp-libvips-${runtimePlatform}/package`);
513
- const libcFound = `${familySync()} ${versionSync()}`;
514
- const libcRequires = `${config.musl ? "musl" : "glibc"} ${config.musl || config.glibc}`;
515
- help.push("- Update your OS:", ` Found ${libcFound}`, ` Requires ${libcRequires}`);
516
- } catch (_errEngines) {}
517
- }
518
- if (isLinux && /\/snap\/core[0-9]{2}/.test(messages)) {
519
- help.push("- Remove the Node.js Snap, which does not support native modules", " snap remove node");
520
- }
521
- if (isMacOs && /Incompatible library version/.test(messages)) {
522
- help.push("- Update Homebrew:", " brew update && brew upgrade vips");
523
- }
524
- if (errors.some((err) => err.code === "ERR_DLOPEN_DISABLED")) {
525
- help.push("- Run Node.js without using the --no-addons flag");
526
- }
527
- if (isWindows && /The specified procedure could not be found/.test(messages)) {
528
- help.push("- Using the canvas package on Windows?", " See https://sharp.pixelplumbing.com/install#canvas-and-windows", "- Check for outdated versions of sharp in the dependency tree:", " npm ls sharp");
529
- }
530
- help.push("- Consult the installation documentation:", " See https://sharp.pixelplumbing.com/install");
531
- throw new Error(help.join(`
532
- `));
533
- }
534
- });
535
-
536
- // node_modules/.bun/sharp@0.34.5/node_modules/sharp/lib/constructor.js
537
- var require_constructor = __commonJS((exports, module) => {
538
- /*!
539
- Copyright 2013 Lovell Fuller and others.
540
- SPDX-License-Identifier: Apache-2.0
541
- */
542
- var util = __require("util");
543
- var stream = __require("stream");
544
- var is = require_is();
545
- require_sharp();
546
- var debuglog = util.debuglog("sharp");
547
- var queueListener = (queueLength) => {
548
- Sharp.queue.emit("change", queueLength);
549
- };
550
- var Sharp = function(input, options) {
551
- if (arguments.length === 1 && !is.defined(input)) {
552
- throw new Error("Invalid input");
553
- }
554
- if (!(this instanceof Sharp)) {
555
- return new Sharp(input, options);
556
- }
557
- stream.Duplex.call(this);
558
- this.options = {
559
- topOffsetPre: -1,
560
- leftOffsetPre: -1,
561
- widthPre: -1,
562
- heightPre: -1,
563
- topOffsetPost: -1,
564
- leftOffsetPost: -1,
565
- widthPost: -1,
566
- heightPost: -1,
567
- width: -1,
568
- height: -1,
569
- canvas: "crop",
570
- position: 0,
571
- resizeBackground: [0, 0, 0, 255],
572
- angle: 0,
573
- rotationAngle: 0,
574
- rotationBackground: [0, 0, 0, 255],
575
- rotateBefore: false,
576
- orientBefore: false,
577
- flip: false,
578
- flop: false,
579
- extendTop: 0,
580
- extendBottom: 0,
581
- extendLeft: 0,
582
- extendRight: 0,
583
- extendBackground: [0, 0, 0, 255],
584
- extendWith: "background",
585
- withoutEnlargement: false,
586
- withoutReduction: false,
587
- affineMatrix: [],
588
- affineBackground: [0, 0, 0, 255],
589
- affineIdx: 0,
590
- affineIdy: 0,
591
- affineOdx: 0,
592
- affineOdy: 0,
593
- affineInterpolator: this.constructor.interpolators.bilinear,
594
- kernel: "lanczos3",
595
- fastShrinkOnLoad: true,
596
- tint: [-1, 0, 0, 0],
597
- flatten: false,
598
- flattenBackground: [0, 0, 0],
599
- unflatten: false,
600
- negate: false,
601
- negateAlpha: true,
602
- medianSize: 0,
603
- blurSigma: 0,
604
- precision: "integer",
605
- minAmpl: 0.2,
606
- sharpenSigma: 0,
607
- sharpenM1: 1,
608
- sharpenM2: 2,
609
- sharpenX1: 2,
610
- sharpenY2: 10,
611
- sharpenY3: 20,
612
- threshold: 0,
613
- thresholdGrayscale: true,
614
- trimBackground: [],
615
- trimThreshold: -1,
616
- trimLineArt: false,
617
- dilateWidth: 0,
618
- erodeWidth: 0,
619
- gamma: 0,
620
- gammaOut: 0,
621
- greyscale: false,
622
- normalise: false,
623
- normaliseLower: 1,
624
- normaliseUpper: 99,
625
- claheWidth: 0,
626
- claheHeight: 0,
627
- claheMaxSlope: 3,
628
- brightness: 1,
629
- saturation: 1,
630
- hue: 0,
631
- lightness: 0,
632
- booleanBufferIn: null,
633
- booleanFileIn: "",
634
- joinChannelIn: [],
635
- extractChannel: -1,
636
- removeAlpha: false,
637
- ensureAlpha: -1,
638
- colourspace: "srgb",
639
- colourspacePipeline: "last",
640
- composite: [],
641
- fileOut: "",
642
- formatOut: "input",
643
- streamOut: false,
644
- keepMetadata: 0,
645
- withMetadataOrientation: -1,
646
- withMetadataDensity: 0,
647
- withIccProfile: "",
648
- withExif: {},
649
- withExifMerge: true,
650
- withXmp: "",
651
- resolveWithObject: false,
652
- loop: -1,
653
- delay: [],
654
- jpegQuality: 80,
655
- jpegProgressive: false,
656
- jpegChromaSubsampling: "4:2:0",
657
- jpegTrellisQuantisation: false,
658
- jpegOvershootDeringing: false,
659
- jpegOptimiseScans: false,
660
- jpegOptimiseCoding: true,
661
- jpegQuantisationTable: 0,
662
- pngProgressive: false,
663
- pngCompressionLevel: 6,
664
- pngAdaptiveFiltering: false,
665
- pngPalette: false,
666
- pngQuality: 100,
667
- pngEffort: 7,
668
- pngBitdepth: 8,
669
- pngDither: 1,
670
- jp2Quality: 80,
671
- jp2TileHeight: 512,
672
- jp2TileWidth: 512,
673
- jp2Lossless: false,
674
- jp2ChromaSubsampling: "4:4:4",
675
- webpQuality: 80,
676
- webpAlphaQuality: 100,
677
- webpLossless: false,
678
- webpNearLossless: false,
679
- webpSmartSubsample: false,
680
- webpSmartDeblock: false,
681
- webpPreset: "default",
682
- webpEffort: 4,
683
- webpMinSize: false,
684
- webpMixed: false,
685
- gifBitdepth: 8,
686
- gifEffort: 7,
687
- gifDither: 1,
688
- gifInterFrameMaxError: 0,
689
- gifInterPaletteMaxError: 3,
690
- gifKeepDuplicateFrames: false,
691
- gifReuse: true,
692
- gifProgressive: false,
693
- tiffQuality: 80,
694
- tiffCompression: "jpeg",
695
- tiffBigtiff: false,
696
- tiffPredictor: "horizontal",
697
- tiffPyramid: false,
698
- tiffMiniswhite: false,
699
- tiffBitdepth: 8,
700
- tiffTile: false,
701
- tiffTileHeight: 256,
702
- tiffTileWidth: 256,
703
- tiffXres: 1,
704
- tiffYres: 1,
705
- tiffResolutionUnit: "inch",
706
- heifQuality: 50,
707
- heifLossless: false,
708
- heifCompression: "av1",
709
- heifEffort: 4,
710
- heifChromaSubsampling: "4:4:4",
711
- heifBitdepth: 8,
712
- jxlDistance: 1,
713
- jxlDecodingTier: 0,
714
- jxlEffort: 7,
715
- jxlLossless: false,
716
- rawDepth: "uchar",
717
- tileSize: 256,
718
- tileOverlap: 0,
719
- tileContainer: "fs",
720
- tileLayout: "dz",
721
- tileFormat: "last",
722
- tileDepth: "last",
723
- tileAngle: 0,
724
- tileSkipBlanks: -1,
725
- tileBackground: [255, 255, 255, 255],
726
- tileCentre: false,
727
- tileId: "https://example.com/iiif",
728
- tileBasename: "",
729
- timeoutSeconds: 0,
730
- linearA: [],
731
- linearB: [],
732
- pdfBackground: [255, 255, 255, 255],
733
- debuglog: (warning) => {
734
- this.emit("warning", warning);
735
- debuglog(warning);
736
- },
737
- queueListener
738
- };
739
- this.options.input = this._createInputDescriptor(input, options, { allowStream: true });
740
- return this;
741
- };
742
- Object.setPrototypeOf(Sharp.prototype, stream.Duplex.prototype);
743
- Object.setPrototypeOf(Sharp, stream.Duplex);
744
- function clone() {
745
- const clone2 = this.constructor.call();
746
- const { debuglog: debuglog2, queueListener: queueListener2, ...options } = this.options;
747
- clone2.options = structuredClone(options);
748
- clone2.options.debuglog = debuglog2;
749
- clone2.options.queueListener = queueListener2;
750
- if (this._isStreamInput()) {
751
- this.on("finish", () => {
752
- this._flattenBufferIn();
753
- clone2.options.input.buffer = this.options.input.buffer;
754
- clone2.emit("finish");
755
- });
756
- }
757
- return clone2;
758
- }
759
- Object.assign(Sharp.prototype, { clone });
760
- module.exports = Sharp;
761
- });
762
-
763
- // node_modules/.bun/sharp@0.34.5/node_modules/sharp/lib/input.js
764
- var require_input = __commonJS((exports, module) => {
765
- /*!
766
- Copyright 2013 Lovell Fuller and others.
767
- SPDX-License-Identifier: Apache-2.0
768
- */
769
- var is = require_is();
770
- var sharp = require_sharp();
771
- var align = {
772
- left: "low",
773
- top: "low",
774
- low: "low",
775
- center: "centre",
776
- centre: "centre",
777
- right: "high",
778
- bottom: "high",
779
- high: "high"
780
- };
781
- var inputStreamParameters = [
782
- "failOn",
783
- "limitInputPixels",
784
- "unlimited",
785
- "animated",
786
- "autoOrient",
787
- "density",
788
- "ignoreIcc",
789
- "page",
790
- "pages",
791
- "sequentialRead",
792
- "jp2",
793
- "openSlide",
794
- "pdf",
795
- "raw",
796
- "svg",
797
- "tiff",
798
- "failOnError",
799
- "openSlideLevel",
800
- "pdfBackground",
801
- "tiffSubifd"
802
- ];
803
- function _inputOptionsFromObject(obj) {
804
- const params = inputStreamParameters.filter((p) => is.defined(obj[p])).map((p) => [p, obj[p]]);
805
- return params.length ? Object.fromEntries(params) : undefined;
806
- }
807
- function _createInputDescriptor(input, inputOptions, containerOptions) {
808
- const inputDescriptor = {
809
- autoOrient: false,
810
- failOn: "warning",
811
- limitInputPixels: 16383 ** 2,
812
- ignoreIcc: false,
813
- unlimited: false,
814
- sequentialRead: true
815
- };
816
- if (is.string(input)) {
817
- inputDescriptor.file = input;
818
- } else if (is.buffer(input)) {
819
- if (input.length === 0) {
820
- throw Error("Input Buffer is empty");
821
- }
822
- inputDescriptor.buffer = input;
823
- } else if (is.arrayBuffer(input)) {
824
- if (input.byteLength === 0) {
825
- throw Error("Input bit Array is empty");
826
- }
827
- inputDescriptor.buffer = Buffer.from(input, 0, input.byteLength);
828
- } else if (is.typedArray(input)) {
829
- if (input.length === 0) {
830
- throw Error("Input Bit Array is empty");
831
- }
832
- inputDescriptor.buffer = Buffer.from(input.buffer, input.byteOffset, input.byteLength);
833
- } else if (is.plainObject(input) && !is.defined(inputOptions)) {
834
- inputOptions = input;
835
- if (_inputOptionsFromObject(inputOptions)) {
836
- inputDescriptor.buffer = [];
837
- }
838
- } else if (!is.defined(input) && !is.defined(inputOptions) && is.object(containerOptions) && containerOptions.allowStream) {
839
- inputDescriptor.buffer = [];
840
- } else if (Array.isArray(input)) {
841
- if (input.length > 1) {
842
- if (!this.options.joining) {
843
- this.options.joining = true;
844
- this.options.join = input.map((i) => this._createInputDescriptor(i));
845
- } else {
846
- throw new Error("Recursive join is unsupported");
847
- }
848
- } else {
849
- throw new Error("Expected at least two images to join");
850
- }
851
- } else {
852
- throw new Error(`Unsupported input '${input}' of type ${typeof input}${is.defined(inputOptions) ? ` when also providing options of type ${typeof inputOptions}` : ""}`);
853
- }
854
- if (is.object(inputOptions)) {
855
- if (is.defined(inputOptions.failOnError)) {
856
- if (is.bool(inputOptions.failOnError)) {
857
- inputDescriptor.failOn = inputOptions.failOnError ? "warning" : "none";
858
- } else {
859
- throw is.invalidParameterError("failOnError", "boolean", inputOptions.failOnError);
860
- }
861
- }
862
- if (is.defined(inputOptions.failOn)) {
863
- if (is.string(inputOptions.failOn) && is.inArray(inputOptions.failOn, ["none", "truncated", "error", "warning"])) {
864
- inputDescriptor.failOn = inputOptions.failOn;
865
- } else {
866
- throw is.invalidParameterError("failOn", "one of: none, truncated, error, warning", inputOptions.failOn);
867
- }
868
- }
869
- if (is.defined(inputOptions.autoOrient)) {
870
- if (is.bool(inputOptions.autoOrient)) {
871
- inputDescriptor.autoOrient = inputOptions.autoOrient;
872
- } else {
873
- throw is.invalidParameterError("autoOrient", "boolean", inputOptions.autoOrient);
874
- }
875
- }
876
- if (is.defined(inputOptions.density)) {
877
- if (is.inRange(inputOptions.density, 1, 1e5)) {
878
- inputDescriptor.density = inputOptions.density;
879
- } else {
880
- throw is.invalidParameterError("density", "number between 1 and 100000", inputOptions.density);
881
- }
882
- }
883
- if (is.defined(inputOptions.ignoreIcc)) {
884
- if (is.bool(inputOptions.ignoreIcc)) {
885
- inputDescriptor.ignoreIcc = inputOptions.ignoreIcc;
886
- } else {
887
- throw is.invalidParameterError("ignoreIcc", "boolean", inputOptions.ignoreIcc);
888
- }
889
- }
890
- if (is.defined(inputOptions.limitInputPixels)) {
891
- if (is.bool(inputOptions.limitInputPixels)) {
892
- inputDescriptor.limitInputPixels = inputOptions.limitInputPixels ? 16383 ** 2 : 0;
893
- } else if (is.integer(inputOptions.limitInputPixels) && is.inRange(inputOptions.limitInputPixels, 0, Number.MAX_SAFE_INTEGER)) {
894
- inputDescriptor.limitInputPixels = inputOptions.limitInputPixels;
895
- } else {
896
- throw is.invalidParameterError("limitInputPixels", "positive integer", inputOptions.limitInputPixels);
897
- }
898
- }
899
- if (is.defined(inputOptions.unlimited)) {
900
- if (is.bool(inputOptions.unlimited)) {
901
- inputDescriptor.unlimited = inputOptions.unlimited;
902
- } else {
903
- throw is.invalidParameterError("unlimited", "boolean", inputOptions.unlimited);
904
- }
905
- }
906
- if (is.defined(inputOptions.sequentialRead)) {
907
- if (is.bool(inputOptions.sequentialRead)) {
908
- inputDescriptor.sequentialRead = inputOptions.sequentialRead;
909
- } else {
910
- throw is.invalidParameterError("sequentialRead", "boolean", inputOptions.sequentialRead);
911
- }
912
- }
913
- if (is.defined(inputOptions.raw)) {
914
- if (is.object(inputOptions.raw) && is.integer(inputOptions.raw.width) && inputOptions.raw.width > 0 && is.integer(inputOptions.raw.height) && inputOptions.raw.height > 0 && is.integer(inputOptions.raw.channels) && is.inRange(inputOptions.raw.channels, 1, 4)) {
915
- inputDescriptor.rawWidth = inputOptions.raw.width;
916
- inputDescriptor.rawHeight = inputOptions.raw.height;
917
- inputDescriptor.rawChannels = inputOptions.raw.channels;
918
- switch (input.constructor) {
919
- case Uint8Array:
920
- case Uint8ClampedArray:
921
- inputDescriptor.rawDepth = "uchar";
922
- break;
923
- case Int8Array:
924
- inputDescriptor.rawDepth = "char";
925
- break;
926
- case Uint16Array:
927
- inputDescriptor.rawDepth = "ushort";
928
- break;
929
- case Int16Array:
930
- inputDescriptor.rawDepth = "short";
931
- break;
932
- case Uint32Array:
933
- inputDescriptor.rawDepth = "uint";
934
- break;
935
- case Int32Array:
936
- inputDescriptor.rawDepth = "int";
937
- break;
938
- case Float32Array:
939
- inputDescriptor.rawDepth = "float";
940
- break;
941
- case Float64Array:
942
- inputDescriptor.rawDepth = "double";
943
- break;
944
- default:
945
- inputDescriptor.rawDepth = "uchar";
946
- break;
947
- }
948
- } else {
949
- throw new Error("Expected width, height and channels for raw pixel input");
950
- }
951
- inputDescriptor.rawPremultiplied = false;
952
- if (is.defined(inputOptions.raw.premultiplied)) {
953
- if (is.bool(inputOptions.raw.premultiplied)) {
954
- inputDescriptor.rawPremultiplied = inputOptions.raw.premultiplied;
955
- } else {
956
- throw is.invalidParameterError("raw.premultiplied", "boolean", inputOptions.raw.premultiplied);
957
- }
958
- }
959
- inputDescriptor.rawPageHeight = 0;
960
- if (is.defined(inputOptions.raw.pageHeight)) {
961
- if (is.integer(inputOptions.raw.pageHeight) && inputOptions.raw.pageHeight > 0 && inputOptions.raw.pageHeight <= inputOptions.raw.height) {
962
- if (inputOptions.raw.height % inputOptions.raw.pageHeight !== 0) {
963
- throw new Error(`Expected raw.height ${inputOptions.raw.height} to be a multiple of raw.pageHeight ${inputOptions.raw.pageHeight}`);
964
- }
965
- inputDescriptor.rawPageHeight = inputOptions.raw.pageHeight;
966
- } else {
967
- throw is.invalidParameterError("raw.pageHeight", "positive integer", inputOptions.raw.pageHeight);
968
- }
969
- }
970
- }
971
- if (is.defined(inputOptions.animated)) {
972
- if (is.bool(inputOptions.animated)) {
973
- inputDescriptor.pages = inputOptions.animated ? -1 : 1;
974
- } else {
975
- throw is.invalidParameterError("animated", "boolean", inputOptions.animated);
976
- }
977
- }
978
- if (is.defined(inputOptions.pages)) {
979
- if (is.integer(inputOptions.pages) && is.inRange(inputOptions.pages, -1, 1e5)) {
980
- inputDescriptor.pages = inputOptions.pages;
981
- } else {
982
- throw is.invalidParameterError("pages", "integer between -1 and 100000", inputOptions.pages);
983
- }
984
- }
985
- if (is.defined(inputOptions.page)) {
986
- if (is.integer(inputOptions.page) && is.inRange(inputOptions.page, 0, 1e5)) {
987
- inputDescriptor.page = inputOptions.page;
988
- } else {
989
- throw is.invalidParameterError("page", "integer between 0 and 100000", inputOptions.page);
990
- }
991
- }
992
- if (is.object(inputOptions.openSlide) && is.defined(inputOptions.openSlide.level)) {
993
- if (is.integer(inputOptions.openSlide.level) && is.inRange(inputOptions.openSlide.level, 0, 256)) {
994
- inputDescriptor.openSlideLevel = inputOptions.openSlide.level;
995
- } else {
996
- throw is.invalidParameterError("openSlide.level", "integer between 0 and 256", inputOptions.openSlide.level);
997
- }
998
- } else if (is.defined(inputOptions.level)) {
999
- if (is.integer(inputOptions.level) && is.inRange(inputOptions.level, 0, 256)) {
1000
- inputDescriptor.openSlideLevel = inputOptions.level;
1001
- } else {
1002
- throw is.invalidParameterError("level", "integer between 0 and 256", inputOptions.level);
1003
- }
1004
- }
1005
- if (is.object(inputOptions.tiff) && is.defined(inputOptions.tiff.subifd)) {
1006
- if (is.integer(inputOptions.tiff.subifd) && is.inRange(inputOptions.tiff.subifd, -1, 1e5)) {
1007
- inputDescriptor.tiffSubifd = inputOptions.tiff.subifd;
1008
- } else {
1009
- throw is.invalidParameterError("tiff.subifd", "integer between -1 and 100000", inputOptions.tiff.subifd);
1010
- }
1011
- } else if (is.defined(inputOptions.subifd)) {
1012
- if (is.integer(inputOptions.subifd) && is.inRange(inputOptions.subifd, -1, 1e5)) {
1013
- inputDescriptor.tiffSubifd = inputOptions.subifd;
1014
- } else {
1015
- throw is.invalidParameterError("subifd", "integer between -1 and 100000", inputOptions.subifd);
1016
- }
1017
- }
1018
- if (is.object(inputOptions.svg)) {
1019
- if (is.defined(inputOptions.svg.stylesheet)) {
1020
- if (is.string(inputOptions.svg.stylesheet)) {
1021
- inputDescriptor.svgStylesheet = inputOptions.svg.stylesheet;
1022
- } else {
1023
- throw is.invalidParameterError("svg.stylesheet", "string", inputOptions.svg.stylesheet);
1024
- }
1025
- }
1026
- if (is.defined(inputOptions.svg.highBitdepth)) {
1027
- if (is.bool(inputOptions.svg.highBitdepth)) {
1028
- inputDescriptor.svgHighBitdepth = inputOptions.svg.highBitdepth;
1029
- } else {
1030
- throw is.invalidParameterError("svg.highBitdepth", "boolean", inputOptions.svg.highBitdepth);
1031
- }
1032
- }
1033
- }
1034
- if (is.object(inputOptions.pdf) && is.defined(inputOptions.pdf.background)) {
1035
- inputDescriptor.pdfBackground = this._getBackgroundColourOption(inputOptions.pdf.background);
1036
- } else if (is.defined(inputOptions.pdfBackground)) {
1037
- inputDescriptor.pdfBackground = this._getBackgroundColourOption(inputOptions.pdfBackground);
1038
- }
1039
- if (is.object(inputOptions.jp2) && is.defined(inputOptions.jp2.oneshot)) {
1040
- if (is.bool(inputOptions.jp2.oneshot)) {
1041
- inputDescriptor.jp2Oneshot = inputOptions.jp2.oneshot;
1042
- } else {
1043
- throw is.invalidParameterError("jp2.oneshot", "boolean", inputOptions.jp2.oneshot);
1044
- }
1045
- }
1046
- if (is.defined(inputOptions.create)) {
1047
- if (is.object(inputOptions.create) && is.integer(inputOptions.create.width) && inputOptions.create.width > 0 && is.integer(inputOptions.create.height) && inputOptions.create.height > 0 && is.integer(inputOptions.create.channels)) {
1048
- inputDescriptor.createWidth = inputOptions.create.width;
1049
- inputDescriptor.createHeight = inputOptions.create.height;
1050
- inputDescriptor.createChannels = inputOptions.create.channels;
1051
- inputDescriptor.createPageHeight = 0;
1052
- if (is.defined(inputOptions.create.pageHeight)) {
1053
- if (is.integer(inputOptions.create.pageHeight) && inputOptions.create.pageHeight > 0 && inputOptions.create.pageHeight <= inputOptions.create.height) {
1054
- if (inputOptions.create.height % inputOptions.create.pageHeight !== 0) {
1055
- throw new Error(`Expected create.height ${inputOptions.create.height} to be a multiple of create.pageHeight ${inputOptions.create.pageHeight}`);
1056
- }
1057
- inputDescriptor.createPageHeight = inputOptions.create.pageHeight;
1058
- } else {
1059
- throw is.invalidParameterError("create.pageHeight", "positive integer", inputOptions.create.pageHeight);
1060
- }
1061
- }
1062
- if (is.defined(inputOptions.create.noise)) {
1063
- if (!is.object(inputOptions.create.noise)) {
1064
- throw new Error("Expected noise to be an object");
1065
- }
1066
- if (inputOptions.create.noise.type !== "gaussian") {
1067
- throw new Error("Only gaussian noise is supported at the moment");
1068
- }
1069
- inputDescriptor.createNoiseType = inputOptions.create.noise.type;
1070
- if (!is.inRange(inputOptions.create.channels, 1, 4)) {
1071
- throw is.invalidParameterError("create.channels", "number between 1 and 4", inputOptions.create.channels);
1072
- }
1073
- inputDescriptor.createNoiseMean = 128;
1074
- if (is.defined(inputOptions.create.noise.mean)) {
1075
- if (is.number(inputOptions.create.noise.mean) && is.inRange(inputOptions.create.noise.mean, 0, 1e4)) {
1076
- inputDescriptor.createNoiseMean = inputOptions.create.noise.mean;
1077
- } else {
1078
- throw is.invalidParameterError("create.noise.mean", "number between 0 and 10000", inputOptions.create.noise.mean);
1079
- }
1080
- }
1081
- inputDescriptor.createNoiseSigma = 30;
1082
- if (is.defined(inputOptions.create.noise.sigma)) {
1083
- if (is.number(inputOptions.create.noise.sigma) && is.inRange(inputOptions.create.noise.sigma, 0, 1e4)) {
1084
- inputDescriptor.createNoiseSigma = inputOptions.create.noise.sigma;
1085
- } else {
1086
- throw is.invalidParameterError("create.noise.sigma", "number between 0 and 10000", inputOptions.create.noise.sigma);
1087
- }
1088
- }
1089
- } else if (is.defined(inputOptions.create.background)) {
1090
- if (!is.inRange(inputOptions.create.channels, 3, 4)) {
1091
- throw is.invalidParameterError("create.channels", "number between 3 and 4", inputOptions.create.channels);
1092
- }
1093
- inputDescriptor.createBackground = this._getBackgroundColourOption(inputOptions.create.background);
1094
- } else {
1095
- throw new Error("Expected valid noise or background to create a new input image");
1096
- }
1097
- delete inputDescriptor.buffer;
1098
- } else {
1099
- throw new Error("Expected valid width, height and channels to create a new input image");
1100
- }
1101
- }
1102
- if (is.defined(inputOptions.text)) {
1103
- if (is.object(inputOptions.text) && is.string(inputOptions.text.text)) {
1104
- inputDescriptor.textValue = inputOptions.text.text;
1105
- if (is.defined(inputOptions.text.height) && is.defined(inputOptions.text.dpi)) {
1106
- throw new Error("Expected only one of dpi or height");
1107
- }
1108
- if (is.defined(inputOptions.text.font)) {
1109
- if (is.string(inputOptions.text.font)) {
1110
- inputDescriptor.textFont = inputOptions.text.font;
1111
- } else {
1112
- throw is.invalidParameterError("text.font", "string", inputOptions.text.font);
1113
- }
1114
- }
1115
- if (is.defined(inputOptions.text.fontfile)) {
1116
- if (is.string(inputOptions.text.fontfile)) {
1117
- inputDescriptor.textFontfile = inputOptions.text.fontfile;
1118
- } else {
1119
- throw is.invalidParameterError("text.fontfile", "string", inputOptions.text.fontfile);
1120
- }
1121
- }
1122
- if (is.defined(inputOptions.text.width)) {
1123
- if (is.integer(inputOptions.text.width) && inputOptions.text.width > 0) {
1124
- inputDescriptor.textWidth = inputOptions.text.width;
1125
- } else {
1126
- throw is.invalidParameterError("text.width", "positive integer", inputOptions.text.width);
1127
- }
1128
- }
1129
- if (is.defined(inputOptions.text.height)) {
1130
- if (is.integer(inputOptions.text.height) && inputOptions.text.height > 0) {
1131
- inputDescriptor.textHeight = inputOptions.text.height;
1132
- } else {
1133
- throw is.invalidParameterError("text.height", "positive integer", inputOptions.text.height);
1134
- }
1135
- }
1136
- if (is.defined(inputOptions.text.align)) {
1137
- if (is.string(inputOptions.text.align) && is.string(this.constructor.align[inputOptions.text.align])) {
1138
- inputDescriptor.textAlign = this.constructor.align[inputOptions.text.align];
1139
- } else {
1140
- throw is.invalidParameterError("text.align", "valid alignment", inputOptions.text.align);
1141
- }
1142
- }
1143
- if (is.defined(inputOptions.text.justify)) {
1144
- if (is.bool(inputOptions.text.justify)) {
1145
- inputDescriptor.textJustify = inputOptions.text.justify;
1146
- } else {
1147
- throw is.invalidParameterError("text.justify", "boolean", inputOptions.text.justify);
1148
- }
1149
- }
1150
- if (is.defined(inputOptions.text.dpi)) {
1151
- if (is.integer(inputOptions.text.dpi) && is.inRange(inputOptions.text.dpi, 1, 1e6)) {
1152
- inputDescriptor.textDpi = inputOptions.text.dpi;
1153
- } else {
1154
- throw is.invalidParameterError("text.dpi", "integer between 1 and 1000000", inputOptions.text.dpi);
1155
- }
1156
- }
1157
- if (is.defined(inputOptions.text.rgba)) {
1158
- if (is.bool(inputOptions.text.rgba)) {
1159
- inputDescriptor.textRgba = inputOptions.text.rgba;
1160
- } else {
1161
- throw is.invalidParameterError("text.rgba", "bool", inputOptions.text.rgba);
1162
- }
1163
- }
1164
- if (is.defined(inputOptions.text.spacing)) {
1165
- if (is.integer(inputOptions.text.spacing) && is.inRange(inputOptions.text.spacing, -1e6, 1e6)) {
1166
- inputDescriptor.textSpacing = inputOptions.text.spacing;
1167
- } else {
1168
- throw is.invalidParameterError("text.spacing", "integer between -1000000 and 1000000", inputOptions.text.spacing);
1169
- }
1170
- }
1171
- if (is.defined(inputOptions.text.wrap)) {
1172
- if (is.string(inputOptions.text.wrap) && is.inArray(inputOptions.text.wrap, ["word", "char", "word-char", "none"])) {
1173
- inputDescriptor.textWrap = inputOptions.text.wrap;
1174
- } else {
1175
- throw is.invalidParameterError("text.wrap", "one of: word, char, word-char, none", inputOptions.text.wrap);
1176
- }
1177
- }
1178
- delete inputDescriptor.buffer;
1179
- } else {
1180
- throw new Error("Expected a valid string to create an image with text.");
1181
- }
1182
- }
1183
- if (is.defined(inputOptions.join)) {
1184
- if (is.defined(this.options.join)) {
1185
- if (is.defined(inputOptions.join.animated)) {
1186
- if (is.bool(inputOptions.join.animated)) {
1187
- inputDescriptor.joinAnimated = inputOptions.join.animated;
1188
- } else {
1189
- throw is.invalidParameterError("join.animated", "boolean", inputOptions.join.animated);
1190
- }
1191
- }
1192
- if (is.defined(inputOptions.join.across)) {
1193
- if (is.integer(inputOptions.join.across) && is.inRange(inputOptions.join.across, 1, 1e6)) {
1194
- inputDescriptor.joinAcross = inputOptions.join.across;
1195
- } else {
1196
- throw is.invalidParameterError("join.across", "integer between 1 and 100000", inputOptions.join.across);
1197
- }
1198
- }
1199
- if (is.defined(inputOptions.join.shim)) {
1200
- if (is.integer(inputOptions.join.shim) && is.inRange(inputOptions.join.shim, 0, 1e6)) {
1201
- inputDescriptor.joinShim = inputOptions.join.shim;
1202
- } else {
1203
- throw is.invalidParameterError("join.shim", "integer between 0 and 100000", inputOptions.join.shim);
1204
- }
1205
- }
1206
- if (is.defined(inputOptions.join.background)) {
1207
- inputDescriptor.joinBackground = this._getBackgroundColourOption(inputOptions.join.background);
1208
- }
1209
- if (is.defined(inputOptions.join.halign)) {
1210
- if (is.string(inputOptions.join.halign) && is.string(this.constructor.align[inputOptions.join.halign])) {
1211
- inputDescriptor.joinHalign = this.constructor.align[inputOptions.join.halign];
1212
- } else {
1213
- throw is.invalidParameterError("join.halign", "valid alignment", inputOptions.join.halign);
1214
- }
1215
- }
1216
- if (is.defined(inputOptions.join.valign)) {
1217
- if (is.string(inputOptions.join.valign) && is.string(this.constructor.align[inputOptions.join.valign])) {
1218
- inputDescriptor.joinValign = this.constructor.align[inputOptions.join.valign];
1219
- } else {
1220
- throw is.invalidParameterError("join.valign", "valid alignment", inputOptions.join.valign);
1221
- }
1222
- }
1223
- } else {
1224
- throw new Error("Expected input to be an array of images to join");
1225
- }
1226
- }
1227
- } else if (is.defined(inputOptions)) {
1228
- throw new Error(`Invalid input options ${inputOptions}`);
1229
- }
1230
- return inputDescriptor;
1231
- }
1232
- function _write(chunk, _encoding, callback) {
1233
- if (Array.isArray(this.options.input.buffer)) {
1234
- if (is.buffer(chunk)) {
1235
- if (this.options.input.buffer.length === 0) {
1236
- this.on("finish", () => {
1237
- this.streamInFinished = true;
1238
- });
1239
- }
1240
- this.options.input.buffer.push(chunk);
1241
- callback();
1242
- } else {
1243
- callback(new Error("Non-Buffer data on Writable Stream"));
1244
- }
1245
- } else {
1246
- callback(new Error("Unexpected data on Writable Stream"));
1247
- }
1248
- }
1249
- function _flattenBufferIn() {
1250
- if (this._isStreamInput()) {
1251
- this.options.input.buffer = Buffer.concat(this.options.input.buffer);
1252
- }
1253
- }
1254
- function _isStreamInput() {
1255
- return Array.isArray(this.options.input.buffer);
1256
- }
1257
- function metadata(callback) {
1258
- const stack = Error();
1259
- if (is.fn(callback)) {
1260
- if (this._isStreamInput()) {
1261
- this.on("finish", () => {
1262
- this._flattenBufferIn();
1263
- sharp.metadata(this.options, (err, metadata2) => {
1264
- if (err) {
1265
- callback(is.nativeError(err, stack));
1266
- } else {
1267
- callback(null, metadata2);
1268
- }
1269
- });
1270
- });
1271
- } else {
1272
- sharp.metadata(this.options, (err, metadata2) => {
1273
- if (err) {
1274
- callback(is.nativeError(err, stack));
1275
- } else {
1276
- callback(null, metadata2);
1277
- }
1278
- });
1279
- }
1280
- return this;
1281
- } else {
1282
- if (this._isStreamInput()) {
1283
- return new Promise((resolve, reject) => {
1284
- const finished = () => {
1285
- this._flattenBufferIn();
1286
- sharp.metadata(this.options, (err, metadata2) => {
1287
- if (err) {
1288
- reject(is.nativeError(err, stack));
1289
- } else {
1290
- resolve(metadata2);
1291
- }
1292
- });
1293
- };
1294
- if (this.writableFinished) {
1295
- finished();
1296
- } else {
1297
- this.once("finish", finished);
1298
- }
1299
- });
1300
- } else {
1301
- return new Promise((resolve, reject) => {
1302
- sharp.metadata(this.options, (err, metadata2) => {
1303
- if (err) {
1304
- reject(is.nativeError(err, stack));
1305
- } else {
1306
- resolve(metadata2);
1307
- }
1308
- });
1309
- });
1310
- }
1311
- }
1312
- }
1313
- function stats(callback) {
1314
- const stack = Error();
1315
- if (is.fn(callback)) {
1316
- if (this._isStreamInput()) {
1317
- this.on("finish", () => {
1318
- this._flattenBufferIn();
1319
- sharp.stats(this.options, (err, stats2) => {
1320
- if (err) {
1321
- callback(is.nativeError(err, stack));
1322
- } else {
1323
- callback(null, stats2);
1324
- }
1325
- });
1326
- });
1327
- } else {
1328
- sharp.stats(this.options, (err, stats2) => {
1329
- if (err) {
1330
- callback(is.nativeError(err, stack));
1331
- } else {
1332
- callback(null, stats2);
1333
- }
1334
- });
1335
- }
1336
- return this;
1337
- } else {
1338
- if (this._isStreamInput()) {
1339
- return new Promise((resolve, reject) => {
1340
- this.on("finish", function() {
1341
- this._flattenBufferIn();
1342
- sharp.stats(this.options, (err, stats2) => {
1343
- if (err) {
1344
- reject(is.nativeError(err, stack));
1345
- } else {
1346
- resolve(stats2);
1347
- }
1348
- });
1349
- });
1350
- });
1351
- } else {
1352
- return new Promise((resolve, reject) => {
1353
- sharp.stats(this.options, (err, stats2) => {
1354
- if (err) {
1355
- reject(is.nativeError(err, stack));
1356
- } else {
1357
- resolve(stats2);
1358
- }
1359
- });
1360
- });
1361
- }
1362
- }
1363
- }
1364
- module.exports = (Sharp) => {
1365
- Object.assign(Sharp.prototype, {
1366
- _inputOptionsFromObject,
1367
- _createInputDescriptor,
1368
- _write,
1369
- _flattenBufferIn,
1370
- _isStreamInput,
1371
- metadata,
1372
- stats
1373
- });
1374
- Sharp.align = align;
1375
- };
1376
- });
1377
-
1378
- // node_modules/.bun/sharp@0.34.5/node_modules/sharp/lib/resize.js
1379
- var require_resize = __commonJS((exports, module) => {
1380
- /*!
1381
- Copyright 2013 Lovell Fuller and others.
1382
- SPDX-License-Identifier: Apache-2.0
1383
- */
1384
- var is = require_is();
1385
- var gravity = {
1386
- center: 0,
1387
- centre: 0,
1388
- north: 1,
1389
- east: 2,
1390
- south: 3,
1391
- west: 4,
1392
- northeast: 5,
1393
- southeast: 6,
1394
- southwest: 7,
1395
- northwest: 8
1396
- };
1397
- var position = {
1398
- top: 1,
1399
- right: 2,
1400
- bottom: 3,
1401
- left: 4,
1402
- "right top": 5,
1403
- "right bottom": 6,
1404
- "left bottom": 7,
1405
- "left top": 8
1406
- };
1407
- var extendWith = {
1408
- background: "background",
1409
- copy: "copy",
1410
- repeat: "repeat",
1411
- mirror: "mirror"
1412
- };
1413
- var strategy = {
1414
- entropy: 16,
1415
- attention: 17
1416
- };
1417
- var kernel = {
1418
- nearest: "nearest",
1419
- linear: "linear",
1420
- cubic: "cubic",
1421
- mitchell: "mitchell",
1422
- lanczos2: "lanczos2",
1423
- lanczos3: "lanczos3",
1424
- mks2013: "mks2013",
1425
- mks2021: "mks2021"
1426
- };
1427
- var fit = {
1428
- contain: "contain",
1429
- cover: "cover",
1430
- fill: "fill",
1431
- inside: "inside",
1432
- outside: "outside"
1433
- };
1434
- var mapFitToCanvas = {
1435
- contain: "embed",
1436
- cover: "crop",
1437
- fill: "ignore_aspect",
1438
- inside: "max",
1439
- outside: "min"
1440
- };
1441
- function isRotationExpected(options) {
1442
- return options.angle % 360 !== 0 || options.rotationAngle !== 0;
1443
- }
1444
- function isResizeExpected(options) {
1445
- return options.width !== -1 || options.height !== -1;
1446
- }
1447
- function resize(widthOrOptions, height, options) {
1448
- if (isResizeExpected(this.options)) {
1449
- this.options.debuglog("ignoring previous resize options");
1450
- }
1451
- if (this.options.widthPost !== -1) {
1452
- this.options.debuglog("operation order will be: extract, resize, extract");
1453
- }
1454
- if (is.defined(widthOrOptions)) {
1455
- if (is.object(widthOrOptions) && !is.defined(options)) {
1456
- options = widthOrOptions;
1457
- } else if (is.integer(widthOrOptions) && widthOrOptions > 0) {
1458
- this.options.width = widthOrOptions;
1459
- } else {
1460
- throw is.invalidParameterError("width", "positive integer", widthOrOptions);
1461
- }
1462
- } else {
1463
- this.options.width = -1;
1464
- }
1465
- if (is.defined(height)) {
1466
- if (is.integer(height) && height > 0) {
1467
- this.options.height = height;
1468
- } else {
1469
- throw is.invalidParameterError("height", "positive integer", height);
1470
- }
1471
- } else {
1472
- this.options.height = -1;
1473
- }
1474
- if (is.object(options)) {
1475
- if (is.defined(options.width)) {
1476
- if (is.integer(options.width) && options.width > 0) {
1477
- this.options.width = options.width;
1478
- } else {
1479
- throw is.invalidParameterError("width", "positive integer", options.width);
1480
- }
1481
- }
1482
- if (is.defined(options.height)) {
1483
- if (is.integer(options.height) && options.height > 0) {
1484
- this.options.height = options.height;
1485
- } else {
1486
- throw is.invalidParameterError("height", "positive integer", options.height);
1487
- }
1488
- }
1489
- if (is.defined(options.fit)) {
1490
- const canvas = mapFitToCanvas[options.fit];
1491
- if (is.string(canvas)) {
1492
- this.options.canvas = canvas;
1493
- } else {
1494
- throw is.invalidParameterError("fit", "valid fit", options.fit);
1495
- }
1496
- }
1497
- if (is.defined(options.position)) {
1498
- const pos = is.integer(options.position) ? options.position : strategy[options.position] || position[options.position] || gravity[options.position];
1499
- if (is.integer(pos) && (is.inRange(pos, 0, 8) || is.inRange(pos, 16, 17))) {
1500
- this.options.position = pos;
1501
- } else {
1502
- throw is.invalidParameterError("position", "valid position/gravity/strategy", options.position);
1503
- }
1504
- }
1505
- this._setBackgroundColourOption("resizeBackground", options.background);
1506
- if (is.defined(options.kernel)) {
1507
- if (is.string(kernel[options.kernel])) {
1508
- this.options.kernel = kernel[options.kernel];
1509
- } else {
1510
- throw is.invalidParameterError("kernel", "valid kernel name", options.kernel);
1511
- }
1512
- }
1513
- if (is.defined(options.withoutEnlargement)) {
1514
- this._setBooleanOption("withoutEnlargement", options.withoutEnlargement);
1515
- }
1516
- if (is.defined(options.withoutReduction)) {
1517
- this._setBooleanOption("withoutReduction", options.withoutReduction);
1518
- }
1519
- if (is.defined(options.fastShrinkOnLoad)) {
1520
- this._setBooleanOption("fastShrinkOnLoad", options.fastShrinkOnLoad);
1521
- }
1522
- }
1523
- if (isRotationExpected(this.options) && isResizeExpected(this.options)) {
1524
- this.options.rotateBefore = true;
1525
- }
1526
- return this;
1527
- }
1528
- function extend(extend2) {
1529
- if (is.integer(extend2) && extend2 > 0) {
1530
- this.options.extendTop = extend2;
1531
- this.options.extendBottom = extend2;
1532
- this.options.extendLeft = extend2;
1533
- this.options.extendRight = extend2;
1534
- } else if (is.object(extend2)) {
1535
- if (is.defined(extend2.top)) {
1536
- if (is.integer(extend2.top) && extend2.top >= 0) {
1537
- this.options.extendTop = extend2.top;
1538
- } else {
1539
- throw is.invalidParameterError("top", "positive integer", extend2.top);
1540
- }
1541
- }
1542
- if (is.defined(extend2.bottom)) {
1543
- if (is.integer(extend2.bottom) && extend2.bottom >= 0) {
1544
- this.options.extendBottom = extend2.bottom;
1545
- } else {
1546
- throw is.invalidParameterError("bottom", "positive integer", extend2.bottom);
1547
- }
1548
- }
1549
- if (is.defined(extend2.left)) {
1550
- if (is.integer(extend2.left) && extend2.left >= 0) {
1551
- this.options.extendLeft = extend2.left;
1552
- } else {
1553
- throw is.invalidParameterError("left", "positive integer", extend2.left);
1554
- }
1555
- }
1556
- if (is.defined(extend2.right)) {
1557
- if (is.integer(extend2.right) && extend2.right >= 0) {
1558
- this.options.extendRight = extend2.right;
1559
- } else {
1560
- throw is.invalidParameterError("right", "positive integer", extend2.right);
1561
- }
1562
- }
1563
- this._setBackgroundColourOption("extendBackground", extend2.background);
1564
- if (is.defined(extend2.extendWith)) {
1565
- if (is.string(extendWith[extend2.extendWith])) {
1566
- this.options.extendWith = extendWith[extend2.extendWith];
1567
- } else {
1568
- throw is.invalidParameterError("extendWith", "one of: background, copy, repeat, mirror", extend2.extendWith);
1569
- }
1570
- }
1571
- } else {
1572
- throw is.invalidParameterError("extend", "integer or object", extend2);
1573
- }
1574
- return this;
1575
- }
1576
- function extract(options) {
1577
- const suffix = isResizeExpected(this.options) || this.options.widthPre !== -1 ? "Post" : "Pre";
1578
- if (this.options[`width${suffix}`] !== -1) {
1579
- this.options.debuglog("ignoring previous extract options");
1580
- }
1581
- ["left", "top", "width", "height"].forEach(function(name) {
1582
- const value = options[name];
1583
- if (is.integer(value) && value >= 0) {
1584
- this.options[name + (name === "left" || name === "top" ? "Offset" : "") + suffix] = value;
1585
- } else {
1586
- throw is.invalidParameterError(name, "integer", value);
1587
- }
1588
- }, this);
1589
- if (isRotationExpected(this.options) && !isResizeExpected(this.options)) {
1590
- if (this.options.widthPre === -1 || this.options.widthPost === -1) {
1591
- this.options.rotateBefore = true;
1592
- }
1593
- }
1594
- if (this.options.input.autoOrient) {
1595
- this.options.orientBefore = true;
1596
- }
1597
- return this;
1598
- }
1599
- function trim(options) {
1600
- this.options.trimThreshold = 10;
1601
- if (is.defined(options)) {
1602
- if (is.object(options)) {
1603
- if (is.defined(options.background)) {
1604
- this._setBackgroundColourOption("trimBackground", options.background);
1605
- }
1606
- if (is.defined(options.threshold)) {
1607
- if (is.number(options.threshold) && options.threshold >= 0) {
1608
- this.options.trimThreshold = options.threshold;
1609
- } else {
1610
- throw is.invalidParameterError("threshold", "positive number", options.threshold);
1611
- }
1612
- }
1613
- if (is.defined(options.lineArt)) {
1614
- this._setBooleanOption("trimLineArt", options.lineArt);
1615
- }
1616
- } else {
1617
- throw is.invalidParameterError("trim", "object", options);
1618
- }
1619
- }
1620
- if (isRotationExpected(this.options)) {
1621
- this.options.rotateBefore = true;
1622
- }
1623
- return this;
1624
- }
1625
- module.exports = (Sharp) => {
1626
- Object.assign(Sharp.prototype, {
1627
- resize,
1628
- extend,
1629
- extract,
1630
- trim
1631
- });
1632
- Sharp.gravity = gravity;
1633
- Sharp.strategy = strategy;
1634
- Sharp.kernel = kernel;
1635
- Sharp.fit = fit;
1636
- Sharp.position = position;
1637
- };
1638
- });
1639
-
1640
- // node_modules/.bun/sharp@0.34.5/node_modules/sharp/lib/composite.js
1641
- var require_composite = __commonJS((exports, module) => {
1642
- /*!
1643
- Copyright 2013 Lovell Fuller and others.
1644
- SPDX-License-Identifier: Apache-2.0
1645
- */
1646
- var is = require_is();
1647
- var blend = {
1648
- clear: "clear",
1649
- source: "source",
1650
- over: "over",
1651
- in: "in",
1652
- out: "out",
1653
- atop: "atop",
1654
- dest: "dest",
1655
- "dest-over": "dest-over",
1656
- "dest-in": "dest-in",
1657
- "dest-out": "dest-out",
1658
- "dest-atop": "dest-atop",
1659
- xor: "xor",
1660
- add: "add",
1661
- saturate: "saturate",
1662
- multiply: "multiply",
1663
- screen: "screen",
1664
- overlay: "overlay",
1665
- darken: "darken",
1666
- lighten: "lighten",
1667
- "colour-dodge": "colour-dodge",
1668
- "color-dodge": "colour-dodge",
1669
- "colour-burn": "colour-burn",
1670
- "color-burn": "colour-burn",
1671
- "hard-light": "hard-light",
1672
- "soft-light": "soft-light",
1673
- difference: "difference",
1674
- exclusion: "exclusion"
1675
- };
1676
- function composite(images) {
1677
- if (!Array.isArray(images)) {
1678
- throw is.invalidParameterError("images to composite", "array", images);
1679
- }
1680
- this.options.composite = images.map((image) => {
1681
- if (!is.object(image)) {
1682
- throw is.invalidParameterError("image to composite", "object", image);
1683
- }
1684
- const inputOptions = this._inputOptionsFromObject(image);
1685
- const composite2 = {
1686
- input: this._createInputDescriptor(image.input, inputOptions, { allowStream: false }),
1687
- blend: "over",
1688
- tile: false,
1689
- left: 0,
1690
- top: 0,
1691
- hasOffset: false,
1692
- gravity: 0,
1693
- premultiplied: false
1694
- };
1695
- if (is.defined(image.blend)) {
1696
- if (is.string(blend[image.blend])) {
1697
- composite2.blend = blend[image.blend];
1698
- } else {
1699
- throw is.invalidParameterError("blend", "valid blend name", image.blend);
1700
- }
1701
- }
1702
- if (is.defined(image.tile)) {
1703
- if (is.bool(image.tile)) {
1704
- composite2.tile = image.tile;
1705
- } else {
1706
- throw is.invalidParameterError("tile", "boolean", image.tile);
1707
- }
1708
- }
1709
- if (is.defined(image.left)) {
1710
- if (is.integer(image.left)) {
1711
- composite2.left = image.left;
1712
- } else {
1713
- throw is.invalidParameterError("left", "integer", image.left);
1714
- }
1715
- }
1716
- if (is.defined(image.top)) {
1717
- if (is.integer(image.top)) {
1718
- composite2.top = image.top;
1719
- } else {
1720
- throw is.invalidParameterError("top", "integer", image.top);
1721
- }
1722
- }
1723
- if (is.defined(image.top) !== is.defined(image.left)) {
1724
- throw new Error("Expected both left and top to be set");
1725
- } else {
1726
- composite2.hasOffset = is.integer(image.top) && is.integer(image.left);
1727
- }
1728
- if (is.defined(image.gravity)) {
1729
- if (is.integer(image.gravity) && is.inRange(image.gravity, 0, 8)) {
1730
- composite2.gravity = image.gravity;
1731
- } else if (is.string(image.gravity) && is.integer(this.constructor.gravity[image.gravity])) {
1732
- composite2.gravity = this.constructor.gravity[image.gravity];
1733
- } else {
1734
- throw is.invalidParameterError("gravity", "valid gravity", image.gravity);
1735
- }
1736
- }
1737
- if (is.defined(image.premultiplied)) {
1738
- if (is.bool(image.premultiplied)) {
1739
- composite2.premultiplied = image.premultiplied;
1740
- } else {
1741
- throw is.invalidParameterError("premultiplied", "boolean", image.premultiplied);
1742
- }
1743
- }
1744
- return composite2;
1745
- });
1746
- return this;
1747
- }
1748
- module.exports = (Sharp) => {
1749
- Sharp.prototype.composite = composite;
1750
- Sharp.blend = blend;
1751
- };
1752
- });
1753
-
1754
- // node_modules/.bun/sharp@0.34.5/node_modules/sharp/lib/operation.js
1755
- var require_operation = __commonJS((exports, module) => {
1756
- /*!
1757
- Copyright 2013 Lovell Fuller and others.
1758
- SPDX-License-Identifier: Apache-2.0
1759
- */
1760
- var is = require_is();
1761
- var vipsPrecision = {
1762
- integer: "integer",
1763
- float: "float",
1764
- approximate: "approximate"
1765
- };
1766
- function rotate(angle, options) {
1767
- if (!is.defined(angle)) {
1768
- return this.autoOrient();
1769
- }
1770
- if (this.options.angle || this.options.rotationAngle) {
1771
- this.options.debuglog("ignoring previous rotate options");
1772
- this.options.angle = 0;
1773
- this.options.rotationAngle = 0;
1774
- }
1775
- if (is.integer(angle) && !(angle % 90)) {
1776
- this.options.angle = angle;
1777
- } else if (is.number(angle)) {
1778
- this.options.rotationAngle = angle;
1779
- if (is.object(options) && options.background) {
1780
- this._setBackgroundColourOption("rotationBackground", options.background);
1781
- }
1782
- } else {
1783
- throw is.invalidParameterError("angle", "numeric", angle);
1784
- }
1785
- return this;
1786
- }
1787
- function autoOrient() {
1788
- this.options.input.autoOrient = true;
1789
- return this;
1790
- }
1791
- function flip(flip2) {
1792
- this.options.flip = is.bool(flip2) ? flip2 : true;
1793
- return this;
1794
- }
1795
- function flop(flop2) {
1796
- this.options.flop = is.bool(flop2) ? flop2 : true;
1797
- return this;
1798
- }
1799
- function affine(matrix, options) {
1800
- const flatMatrix = [].concat(...matrix);
1801
- if (flatMatrix.length === 4 && flatMatrix.every(is.number)) {
1802
- this.options.affineMatrix = flatMatrix;
1803
- } else {
1804
- throw is.invalidParameterError("matrix", "1x4 or 2x2 array", matrix);
1805
- }
1806
- if (is.defined(options)) {
1807
- if (is.object(options)) {
1808
- this._setBackgroundColourOption("affineBackground", options.background);
1809
- if (is.defined(options.idx)) {
1810
- if (is.number(options.idx)) {
1811
- this.options.affineIdx = options.idx;
1812
- } else {
1813
- throw is.invalidParameterError("options.idx", "number", options.idx);
1814
- }
1815
- }
1816
- if (is.defined(options.idy)) {
1817
- if (is.number(options.idy)) {
1818
- this.options.affineIdy = options.idy;
1819
- } else {
1820
- throw is.invalidParameterError("options.idy", "number", options.idy);
1821
- }
1822
- }
1823
- if (is.defined(options.odx)) {
1824
- if (is.number(options.odx)) {
1825
- this.options.affineOdx = options.odx;
1826
- } else {
1827
- throw is.invalidParameterError("options.odx", "number", options.odx);
1828
- }
1829
- }
1830
- if (is.defined(options.ody)) {
1831
- if (is.number(options.ody)) {
1832
- this.options.affineOdy = options.ody;
1833
- } else {
1834
- throw is.invalidParameterError("options.ody", "number", options.ody);
1835
- }
1836
- }
1837
- if (is.defined(options.interpolator)) {
1838
- if (is.inArray(options.interpolator, Object.values(this.constructor.interpolators))) {
1839
- this.options.affineInterpolator = options.interpolator;
1840
- } else {
1841
- throw is.invalidParameterError("options.interpolator", "valid interpolator name", options.interpolator);
1842
- }
1843
- }
1844
- } else {
1845
- throw is.invalidParameterError("options", "object", options);
1846
- }
1847
- }
1848
- return this;
1849
- }
1850
- function sharpen(options, flat, jagged) {
1851
- if (!is.defined(options)) {
1852
- this.options.sharpenSigma = -1;
1853
- } else if (is.bool(options)) {
1854
- this.options.sharpenSigma = options ? -1 : 0;
1855
- } else if (is.number(options) && is.inRange(options, 0.01, 1e4)) {
1856
- this.options.sharpenSigma = options;
1857
- if (is.defined(flat)) {
1858
- if (is.number(flat) && is.inRange(flat, 0, 1e4)) {
1859
- this.options.sharpenM1 = flat;
1860
- } else {
1861
- throw is.invalidParameterError("flat", "number between 0 and 10000", flat);
1862
- }
1863
- }
1864
- if (is.defined(jagged)) {
1865
- if (is.number(jagged) && is.inRange(jagged, 0, 1e4)) {
1866
- this.options.sharpenM2 = jagged;
1867
- } else {
1868
- throw is.invalidParameterError("jagged", "number between 0 and 10000", jagged);
1869
- }
1870
- }
1871
- } else if (is.plainObject(options)) {
1872
- if (is.number(options.sigma) && is.inRange(options.sigma, 0.000001, 10)) {
1873
- this.options.sharpenSigma = options.sigma;
1874
- } else {
1875
- throw is.invalidParameterError("options.sigma", "number between 0.000001 and 10", options.sigma);
1876
- }
1877
- if (is.defined(options.m1)) {
1878
- if (is.number(options.m1) && is.inRange(options.m1, 0, 1e6)) {
1879
- this.options.sharpenM1 = options.m1;
1880
- } else {
1881
- throw is.invalidParameterError("options.m1", "number between 0 and 1000000", options.m1);
1882
- }
1883
- }
1884
- if (is.defined(options.m2)) {
1885
- if (is.number(options.m2) && is.inRange(options.m2, 0, 1e6)) {
1886
- this.options.sharpenM2 = options.m2;
1887
- } else {
1888
- throw is.invalidParameterError("options.m2", "number between 0 and 1000000", options.m2);
1889
- }
1890
- }
1891
- if (is.defined(options.x1)) {
1892
- if (is.number(options.x1) && is.inRange(options.x1, 0, 1e6)) {
1893
- this.options.sharpenX1 = options.x1;
1894
- } else {
1895
- throw is.invalidParameterError("options.x1", "number between 0 and 1000000", options.x1);
1896
- }
1897
- }
1898
- if (is.defined(options.y2)) {
1899
- if (is.number(options.y2) && is.inRange(options.y2, 0, 1e6)) {
1900
- this.options.sharpenY2 = options.y2;
1901
- } else {
1902
- throw is.invalidParameterError("options.y2", "number between 0 and 1000000", options.y2);
1903
- }
1904
- }
1905
- if (is.defined(options.y3)) {
1906
- if (is.number(options.y3) && is.inRange(options.y3, 0, 1e6)) {
1907
- this.options.sharpenY3 = options.y3;
1908
- } else {
1909
- throw is.invalidParameterError("options.y3", "number between 0 and 1000000", options.y3);
1910
- }
1911
- }
1912
- } else {
1913
- throw is.invalidParameterError("sigma", "number between 0.01 and 10000", options);
1914
- }
1915
- return this;
1916
- }
1917
- function median(size) {
1918
- if (!is.defined(size)) {
1919
- this.options.medianSize = 3;
1920
- } else if (is.integer(size) && is.inRange(size, 1, 1000)) {
1921
- this.options.medianSize = size;
1922
- } else {
1923
- throw is.invalidParameterError("size", "integer between 1 and 1000", size);
1924
- }
1925
- return this;
1926
- }
1927
- function blur(options) {
1928
- let sigma;
1929
- if (is.number(options)) {
1930
- sigma = options;
1931
- } else if (is.plainObject(options)) {
1932
- if (!is.number(options.sigma)) {
1933
- throw is.invalidParameterError("options.sigma", "number between 0.3 and 1000", sigma);
1934
- }
1935
- sigma = options.sigma;
1936
- if ("precision" in options) {
1937
- if (is.string(vipsPrecision[options.precision])) {
1938
- this.options.precision = vipsPrecision[options.precision];
1939
- } else {
1940
- throw is.invalidParameterError("precision", "one of: integer, float, approximate", options.precision);
1941
- }
1942
- }
1943
- if ("minAmplitude" in options) {
1944
- if (is.number(options.minAmplitude) && is.inRange(options.minAmplitude, 0.001, 1)) {
1945
- this.options.minAmpl = options.minAmplitude;
1946
- } else {
1947
- throw is.invalidParameterError("minAmplitude", "number between 0.001 and 1", options.minAmplitude);
1948
- }
1949
- }
1950
- }
1951
- if (!is.defined(options)) {
1952
- this.options.blurSigma = -1;
1953
- } else if (is.bool(options)) {
1954
- this.options.blurSigma = options ? -1 : 0;
1955
- } else if (is.number(sigma) && is.inRange(sigma, 0.3, 1000)) {
1956
- this.options.blurSigma = sigma;
1957
- } else {
1958
- throw is.invalidParameterError("sigma", "number between 0.3 and 1000", sigma);
1959
- }
1960
- return this;
1961
- }
1962
- function dilate(width) {
1963
- if (!is.defined(width)) {
1964
- this.options.dilateWidth = 1;
1965
- } else if (is.integer(width) && width > 0) {
1966
- this.options.dilateWidth = width;
1967
- } else {
1968
- throw is.invalidParameterError("dilate", "positive integer", dilate);
1969
- }
1970
- return this;
1971
- }
1972
- function erode(width) {
1973
- if (!is.defined(width)) {
1974
- this.options.erodeWidth = 1;
1975
- } else if (is.integer(width) && width > 0) {
1976
- this.options.erodeWidth = width;
1977
- } else {
1978
- throw is.invalidParameterError("erode", "positive integer", erode);
1979
- }
1980
- return this;
1981
- }
1982
- function flatten(options) {
1983
- this.options.flatten = is.bool(options) ? options : true;
1984
- if (is.object(options)) {
1985
- this._setBackgroundColourOption("flattenBackground", options.background);
1986
- }
1987
- return this;
1988
- }
1989
- function unflatten() {
1990
- this.options.unflatten = true;
1991
- return this;
1992
- }
1993
- function gamma(gamma2, gammaOut) {
1994
- if (!is.defined(gamma2)) {
1995
- this.options.gamma = 2.2;
1996
- } else if (is.number(gamma2) && is.inRange(gamma2, 1, 3)) {
1997
- this.options.gamma = gamma2;
1998
- } else {
1999
- throw is.invalidParameterError("gamma", "number between 1.0 and 3.0", gamma2);
2000
- }
2001
- if (!is.defined(gammaOut)) {
2002
- this.options.gammaOut = this.options.gamma;
2003
- } else if (is.number(gammaOut) && is.inRange(gammaOut, 1, 3)) {
2004
- this.options.gammaOut = gammaOut;
2005
- } else {
2006
- throw is.invalidParameterError("gammaOut", "number between 1.0 and 3.0", gammaOut);
2007
- }
2008
- return this;
2009
- }
2010
- function negate(options) {
2011
- this.options.negate = is.bool(options) ? options : true;
2012
- if (is.plainObject(options) && "alpha" in options) {
2013
- if (!is.bool(options.alpha)) {
2014
- throw is.invalidParameterError("alpha", "should be boolean value", options.alpha);
2015
- } else {
2016
- this.options.negateAlpha = options.alpha;
2017
- }
2018
- }
2019
- return this;
2020
- }
2021
- function normalise(options) {
2022
- if (is.plainObject(options)) {
2023
- if (is.defined(options.lower)) {
2024
- if (is.number(options.lower) && is.inRange(options.lower, 0, 99)) {
2025
- this.options.normaliseLower = options.lower;
2026
- } else {
2027
- throw is.invalidParameterError("lower", "number between 0 and 99", options.lower);
2028
- }
2029
- }
2030
- if (is.defined(options.upper)) {
2031
- if (is.number(options.upper) && is.inRange(options.upper, 1, 100)) {
2032
- this.options.normaliseUpper = options.upper;
2033
- } else {
2034
- throw is.invalidParameterError("upper", "number between 1 and 100", options.upper);
2035
- }
2036
- }
2037
- }
2038
- if (this.options.normaliseLower >= this.options.normaliseUpper) {
2039
- throw is.invalidParameterError("range", "lower to be less than upper", `${this.options.normaliseLower} >= ${this.options.normaliseUpper}`);
2040
- }
2041
- this.options.normalise = true;
2042
- return this;
2043
- }
2044
- function normalize(options) {
2045
- return this.normalise(options);
2046
- }
2047
- function clahe(options) {
2048
- if (is.plainObject(options)) {
2049
- if (is.integer(options.width) && options.width > 0) {
2050
- this.options.claheWidth = options.width;
2051
- } else {
2052
- throw is.invalidParameterError("width", "integer greater than zero", options.width);
2053
- }
2054
- if (is.integer(options.height) && options.height > 0) {
2055
- this.options.claheHeight = options.height;
2056
- } else {
2057
- throw is.invalidParameterError("height", "integer greater than zero", options.height);
2058
- }
2059
- if (is.defined(options.maxSlope)) {
2060
- if (is.integer(options.maxSlope) && is.inRange(options.maxSlope, 0, 100)) {
2061
- this.options.claheMaxSlope = options.maxSlope;
2062
- } else {
2063
- throw is.invalidParameterError("maxSlope", "integer between 0 and 100", options.maxSlope);
2064
- }
2065
- }
2066
- } else {
2067
- throw is.invalidParameterError("options", "plain object", options);
2068
- }
2069
- return this;
2070
- }
2071
- function convolve(kernel) {
2072
- if (!is.object(kernel) || !Array.isArray(kernel.kernel) || !is.integer(kernel.width) || !is.integer(kernel.height) || !is.inRange(kernel.width, 3, 1001) || !is.inRange(kernel.height, 3, 1001) || kernel.height * kernel.width !== kernel.kernel.length) {
2073
- throw new Error("Invalid convolution kernel");
2074
- }
2075
- if (!is.integer(kernel.scale)) {
2076
- kernel.scale = kernel.kernel.reduce((a, b) => a + b, 0);
2077
- }
2078
- if (kernel.scale < 1) {
2079
- kernel.scale = 1;
2080
- }
2081
- if (!is.integer(kernel.offset)) {
2082
- kernel.offset = 0;
2083
- }
2084
- this.options.convKernel = kernel;
2085
- return this;
2086
- }
2087
- function threshold(threshold2, options) {
2088
- if (!is.defined(threshold2)) {
2089
- this.options.threshold = 128;
2090
- } else if (is.bool(threshold2)) {
2091
- this.options.threshold = threshold2 ? 128 : 0;
2092
- } else if (is.integer(threshold2) && is.inRange(threshold2, 0, 255)) {
2093
- this.options.threshold = threshold2;
2094
- } else {
2095
- throw is.invalidParameterError("threshold", "integer between 0 and 255", threshold2);
2096
- }
2097
- if (!is.object(options) || options.greyscale === true || options.grayscale === true) {
2098
- this.options.thresholdGrayscale = true;
2099
- } else {
2100
- this.options.thresholdGrayscale = false;
2101
- }
2102
- return this;
2103
- }
2104
- function boolean(operand, operator, options) {
2105
- this.options.boolean = this._createInputDescriptor(operand, options);
2106
- if (is.string(operator) && is.inArray(operator, ["and", "or", "eor"])) {
2107
- this.options.booleanOp = operator;
2108
- } else {
2109
- throw is.invalidParameterError("operator", "one of: and, or, eor", operator);
2110
- }
2111
- return this;
2112
- }
2113
- function linear(a, b) {
2114
- if (!is.defined(a) && is.number(b)) {
2115
- a = 1;
2116
- } else if (is.number(a) && !is.defined(b)) {
2117
- b = 0;
2118
- }
2119
- if (!is.defined(a)) {
2120
- this.options.linearA = [];
2121
- } else if (is.number(a)) {
2122
- this.options.linearA = [a];
2123
- } else if (Array.isArray(a) && a.length && a.every(is.number)) {
2124
- this.options.linearA = a;
2125
- } else {
2126
- throw is.invalidParameterError("a", "number or array of numbers", a);
2127
- }
2128
- if (!is.defined(b)) {
2129
- this.options.linearB = [];
2130
- } else if (is.number(b)) {
2131
- this.options.linearB = [b];
2132
- } else if (Array.isArray(b) && b.length && b.every(is.number)) {
2133
- this.options.linearB = b;
2134
- } else {
2135
- throw is.invalidParameterError("b", "number or array of numbers", b);
2136
- }
2137
- if (this.options.linearA.length !== this.options.linearB.length) {
2138
- throw new Error("Expected a and b to be arrays of the same length");
2139
- }
2140
- return this;
2141
- }
2142
- function recomb(inputMatrix) {
2143
- if (!Array.isArray(inputMatrix)) {
2144
- throw is.invalidParameterError("inputMatrix", "array", inputMatrix);
2145
- }
2146
- if (inputMatrix.length !== 3 && inputMatrix.length !== 4) {
2147
- throw is.invalidParameterError("inputMatrix", "3x3 or 4x4 array", inputMatrix.length);
2148
- }
2149
- const recombMatrix = inputMatrix.flat().map(Number);
2150
- if (recombMatrix.length !== 9 && recombMatrix.length !== 16) {
2151
- throw is.invalidParameterError("inputMatrix", "cardinality of 9 or 16", recombMatrix.length);
2152
- }
2153
- this.options.recombMatrix = recombMatrix;
2154
- return this;
2155
- }
2156
- function modulate(options) {
2157
- if (!is.plainObject(options)) {
2158
- throw is.invalidParameterError("options", "plain object", options);
2159
- }
2160
- if ("brightness" in options) {
2161
- if (is.number(options.brightness) && options.brightness >= 0) {
2162
- this.options.brightness = options.brightness;
2163
- } else {
2164
- throw is.invalidParameterError("brightness", "number above zero", options.brightness);
2165
- }
2166
- }
2167
- if ("saturation" in options) {
2168
- if (is.number(options.saturation) && options.saturation >= 0) {
2169
- this.options.saturation = options.saturation;
2170
- } else {
2171
- throw is.invalidParameterError("saturation", "number above zero", options.saturation);
2172
- }
2173
- }
2174
- if ("hue" in options) {
2175
- if (is.integer(options.hue)) {
2176
- this.options.hue = options.hue % 360;
2177
- } else {
2178
- throw is.invalidParameterError("hue", "number", options.hue);
2179
- }
2180
- }
2181
- if ("lightness" in options) {
2182
- if (is.number(options.lightness)) {
2183
- this.options.lightness = options.lightness;
2184
- } else {
2185
- throw is.invalidParameterError("lightness", "number", options.lightness);
2186
- }
2187
- }
2188
- return this;
2189
- }
2190
- module.exports = (Sharp) => {
2191
- Object.assign(Sharp.prototype, {
2192
- autoOrient,
2193
- rotate,
2194
- flip,
2195
- flop,
2196
- affine,
2197
- sharpen,
2198
- erode,
2199
- dilate,
2200
- median,
2201
- blur,
2202
- flatten,
2203
- unflatten,
2204
- gamma,
2205
- negate,
2206
- normalise,
2207
- normalize,
2208
- clahe,
2209
- convolve,
2210
- threshold,
2211
- boolean,
2212
- linear,
2213
- recomb,
2214
- modulate
2215
- });
2216
- };
2217
- });
2218
-
2219
- // node_modules/.bun/@img+colour@1.1.0/node_modules/@img/colour/color.cjs
2220
- var require_color = __commonJS((exports, module) => {
2221
- var __defProp = Object.defineProperty;
2222
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
2223
- var __getOwnPropNames = Object.getOwnPropertyNames;
2224
- var __hasOwnProp = Object.prototype.hasOwnProperty;
2225
- var __export = (target, all) => {
2226
- for (var name in all)
2227
- __defProp(target, name, { get: all[name], enumerable: true });
2228
- };
2229
- var __copyProps = (to, from, except, desc) => {
2230
- if (from && typeof from === "object" || typeof from === "function") {
2231
- for (let key of __getOwnPropNames(from))
2232
- if (!__hasOwnProp.call(to, key) && key !== except)
2233
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
2234
- }
2235
- return to;
2236
- };
2237
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
2238
- var index_exports = {};
2239
- __export(index_exports, {
2240
- default: () => index_default
2241
- });
2242
- module.exports = __toCommonJS(index_exports);
2243
- var colors = {
2244
- aliceblue: [240, 248, 255],
2245
- antiquewhite: [250, 235, 215],
2246
- aqua: [0, 255, 255],
2247
- aquamarine: [127, 255, 212],
2248
- azure: [240, 255, 255],
2249
- beige: [245, 245, 220],
2250
- bisque: [255, 228, 196],
2251
- black: [0, 0, 0],
2252
- blanchedalmond: [255, 235, 205],
2253
- blue: [0, 0, 255],
2254
- blueviolet: [138, 43, 226],
2255
- brown: [165, 42, 42],
2256
- burlywood: [222, 184, 135],
2257
- cadetblue: [95, 158, 160],
2258
- chartreuse: [127, 255, 0],
2259
- chocolate: [210, 105, 30],
2260
- coral: [255, 127, 80],
2261
- cornflowerblue: [100, 149, 237],
2262
- cornsilk: [255, 248, 220],
2263
- crimson: [220, 20, 60],
2264
- cyan: [0, 255, 255],
2265
- darkblue: [0, 0, 139],
2266
- darkcyan: [0, 139, 139],
2267
- darkgoldenrod: [184, 134, 11],
2268
- darkgray: [169, 169, 169],
2269
- darkgreen: [0, 100, 0],
2270
- darkgrey: [169, 169, 169],
2271
- darkkhaki: [189, 183, 107],
2272
- darkmagenta: [139, 0, 139],
2273
- darkolivegreen: [85, 107, 47],
2274
- darkorange: [255, 140, 0],
2275
- darkorchid: [153, 50, 204],
2276
- darkred: [139, 0, 0],
2277
- darksalmon: [233, 150, 122],
2278
- darkseagreen: [143, 188, 143],
2279
- darkslateblue: [72, 61, 139],
2280
- darkslategray: [47, 79, 79],
2281
- darkslategrey: [47, 79, 79],
2282
- darkturquoise: [0, 206, 209],
2283
- darkviolet: [148, 0, 211],
2284
- deeppink: [255, 20, 147],
2285
- deepskyblue: [0, 191, 255],
2286
- dimgray: [105, 105, 105],
2287
- dimgrey: [105, 105, 105],
2288
- dodgerblue: [30, 144, 255],
2289
- firebrick: [178, 34, 34],
2290
- floralwhite: [255, 250, 240],
2291
- forestgreen: [34, 139, 34],
2292
- fuchsia: [255, 0, 255],
2293
- gainsboro: [220, 220, 220],
2294
- ghostwhite: [248, 248, 255],
2295
- gold: [255, 215, 0],
2296
- goldenrod: [218, 165, 32],
2297
- gray: [128, 128, 128],
2298
- green: [0, 128, 0],
2299
- greenyellow: [173, 255, 47],
2300
- grey: [128, 128, 128],
2301
- honeydew: [240, 255, 240],
2302
- hotpink: [255, 105, 180],
2303
- indianred: [205, 92, 92],
2304
- indigo: [75, 0, 130],
2305
- ivory: [255, 255, 240],
2306
- khaki: [240, 230, 140],
2307
- lavender: [230, 230, 250],
2308
- lavenderblush: [255, 240, 245],
2309
- lawngreen: [124, 252, 0],
2310
- lemonchiffon: [255, 250, 205],
2311
- lightblue: [173, 216, 230],
2312
- lightcoral: [240, 128, 128],
2313
- lightcyan: [224, 255, 255],
2314
- lightgoldenrodyellow: [250, 250, 210],
2315
- lightgray: [211, 211, 211],
2316
- lightgreen: [144, 238, 144],
2317
- lightgrey: [211, 211, 211],
2318
- lightpink: [255, 182, 193],
2319
- lightsalmon: [255, 160, 122],
2320
- lightseagreen: [32, 178, 170],
2321
- lightskyblue: [135, 206, 250],
2322
- lightslategray: [119, 136, 153],
2323
- lightslategrey: [119, 136, 153],
2324
- lightsteelblue: [176, 196, 222],
2325
- lightyellow: [255, 255, 224],
2326
- lime: [0, 255, 0],
2327
- limegreen: [50, 205, 50],
2328
- linen: [250, 240, 230],
2329
- magenta: [255, 0, 255],
2330
- maroon: [128, 0, 0],
2331
- mediumaquamarine: [102, 205, 170],
2332
- mediumblue: [0, 0, 205],
2333
- mediumorchid: [186, 85, 211],
2334
- mediumpurple: [147, 112, 219],
2335
- mediumseagreen: [60, 179, 113],
2336
- mediumslateblue: [123, 104, 238],
2337
- mediumspringgreen: [0, 250, 154],
2338
- mediumturquoise: [72, 209, 204],
2339
- mediumvioletred: [199, 21, 133],
2340
- midnightblue: [25, 25, 112],
2341
- mintcream: [245, 255, 250],
2342
- mistyrose: [255, 228, 225],
2343
- moccasin: [255, 228, 181],
2344
- navajowhite: [255, 222, 173],
2345
- navy: [0, 0, 128],
2346
- oldlace: [253, 245, 230],
2347
- olive: [128, 128, 0],
2348
- olivedrab: [107, 142, 35],
2349
- orange: [255, 165, 0],
2350
- orangered: [255, 69, 0],
2351
- orchid: [218, 112, 214],
2352
- palegoldenrod: [238, 232, 170],
2353
- palegreen: [152, 251, 152],
2354
- paleturquoise: [175, 238, 238],
2355
- palevioletred: [219, 112, 147],
2356
- papayawhip: [255, 239, 213],
2357
- peachpuff: [255, 218, 185],
2358
- peru: [205, 133, 63],
2359
- pink: [255, 192, 203],
2360
- plum: [221, 160, 221],
2361
- powderblue: [176, 224, 230],
2362
- purple: [128, 0, 128],
2363
- rebeccapurple: [102, 51, 153],
2364
- red: [255, 0, 0],
2365
- rosybrown: [188, 143, 143],
2366
- royalblue: [65, 105, 225],
2367
- saddlebrown: [139, 69, 19],
2368
- salmon: [250, 128, 114],
2369
- sandybrown: [244, 164, 96],
2370
- seagreen: [46, 139, 87],
2371
- seashell: [255, 245, 238],
2372
- sienna: [160, 82, 45],
2373
- silver: [192, 192, 192],
2374
- skyblue: [135, 206, 235],
2375
- slateblue: [106, 90, 205],
2376
- slategray: [112, 128, 144],
2377
- slategrey: [112, 128, 144],
2378
- snow: [255, 250, 250],
2379
- springgreen: [0, 255, 127],
2380
- steelblue: [70, 130, 180],
2381
- tan: [210, 180, 140],
2382
- teal: [0, 128, 128],
2383
- thistle: [216, 191, 216],
2384
- tomato: [255, 99, 71],
2385
- turquoise: [64, 224, 208],
2386
- violet: [238, 130, 238],
2387
- wheat: [245, 222, 179],
2388
- white: [255, 255, 255],
2389
- whitesmoke: [245, 245, 245],
2390
- yellow: [255, 255, 0],
2391
- yellowgreen: [154, 205, 50]
2392
- };
2393
- for (const key in colors)
2394
- Object.freeze(colors[key]);
2395
- var color_name_default = Object.freeze(colors);
2396
- var reverseNames = /* @__PURE__ */ Object.create(null);
2397
- for (const name in color_name_default) {
2398
- if (Object.hasOwn(color_name_default, name)) {
2399
- reverseNames[color_name_default[name]] = name;
2400
- }
2401
- }
2402
- var cs = {
2403
- to: {},
2404
- get: {}
2405
- };
2406
- cs.get = function(string) {
2407
- const prefix = string.slice(0, 3).toLowerCase();
2408
- let value;
2409
- let model;
2410
- switch (prefix) {
2411
- case "hsl": {
2412
- value = cs.get.hsl(string);
2413
- model = "hsl";
2414
- break;
2415
- }
2416
- case "hwb": {
2417
- value = cs.get.hwb(string);
2418
- model = "hwb";
2419
- break;
2420
- }
2421
- default: {
2422
- value = cs.get.rgb(string);
2423
- model = "rgb";
2424
- break;
2425
- }
2426
- }
2427
- if (!value) {
2428
- return null;
2429
- }
2430
- return { model, value };
2431
- };
2432
- cs.get.rgb = function(string) {
2433
- if (!string) {
2434
- return null;
2435
- }
2436
- const abbr = /^#([a-f\d]{3,4})$/i;
2437
- const hex = /^#([a-f\d]{6})([a-f\d]{2})?$/i;
2438
- const rgba = /^rgba?\(\s*([+-]?(?:\d*\.)?\d+(?:e\d+)?)(?=[\s,])\s*(?:,\s*)?([+-]?(?:\d*\.)?\d+(?:e\d+)?)(?=[\s,])\s*(?:,\s*)?([+-]?(?:\d*\.)?\d+(?:e\d+)?)\s*(?:[\s,|/]\s*([+-]?(?:\d*\.)?\d+(?:e\d+)?)(%?)\s*)?\)$/i;
2439
- const per = /^rgba?\(\s*([+-]?[\d.]+)%\s*,?\s*([+-]?[\d.]+)%\s*,?\s*([+-]?[\d.]+)%\s*(?:[\s,|/]\s*([+-]?[\d.]+)(%?)\s*)?\)$/i;
2440
- const keyword = /^(\w+)$/;
2441
- let rgb = [0, 0, 0, 1];
2442
- let match;
2443
- let i;
2444
- let hexAlpha;
2445
- if (match = string.match(hex)) {
2446
- hexAlpha = match[2];
2447
- match = match[1];
2448
- for (i = 0;i < 3; i++) {
2449
- const i2 = i * 2;
2450
- rgb[i] = Number.parseInt(match.slice(i2, i2 + 2), 16);
2451
- }
2452
- if (hexAlpha) {
2453
- rgb[3] = Number.parseInt(hexAlpha, 16) / 255;
2454
- }
2455
- } else if (match = string.match(abbr)) {
2456
- match = match[1];
2457
- hexAlpha = match[3];
2458
- for (i = 0;i < 3; i++) {
2459
- rgb[i] = Number.parseInt(match[i] + match[i], 16);
2460
- }
2461
- if (hexAlpha) {
2462
- rgb[3] = Number.parseInt(hexAlpha + hexAlpha, 16) / 255;
2463
- }
2464
- } else if (match = string.match(rgba)) {
2465
- for (i = 0;i < 3; i++) {
2466
- rgb[i] = Number.parseFloat(match[i + 1]);
2467
- }
2468
- if (match[4]) {
2469
- rgb[3] = match[5] ? Number.parseFloat(match[4]) * 0.01 : Number.parseFloat(match[4]);
2470
- }
2471
- } else if (match = string.match(per)) {
2472
- for (i = 0;i < 3; i++) {
2473
- rgb[i] = Math.round(Number.parseFloat(match[i + 1]) * 2.55);
2474
- }
2475
- if (match[4]) {
2476
- rgb[3] = match[5] ? Number.parseFloat(match[4]) * 0.01 : Number.parseFloat(match[4]);
2477
- }
2478
- } else if (match = string.toLowerCase().match(keyword)) {
2479
- if (match[1] === "transparent") {
2480
- return [0, 0, 0, 0];
2481
- }
2482
- if (!Object.hasOwn(color_name_default, match[1])) {
2483
- return null;
2484
- }
2485
- rgb = color_name_default[match[1]].slice();
2486
- rgb[3] = 1;
2487
- return rgb;
2488
- } else {
2489
- return null;
2490
- }
2491
- for (i = 0;i < 3; i++) {
2492
- rgb[i] = clamp(rgb[i], 0, 255);
2493
- }
2494
- rgb[3] = clamp(rgb[3], 0, 1);
2495
- return rgb;
2496
- };
2497
- cs.get.hsl = function(string) {
2498
- if (!string) {
2499
- return null;
2500
- }
2501
- const hsl = /^hsla?\(\s*([+-]?(?:\d{0,3}\.)?\d+)(?:deg)?\s*,?\s*([+-]?[\d.]+)%\s*,?\s*([+-]?[\d.]+)%\s*(?:[,|/]\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:e[+-]?\d+)?)\s*)?\)$/i;
2502
- const match = string.match(hsl);
2503
- if (match) {
2504
- const alpha = Number.parseFloat(match[4]);
2505
- const h = (Number.parseFloat(match[1]) % 360 + 360) % 360;
2506
- const s = clamp(Number.parseFloat(match[2]), 0, 100);
2507
- const l = clamp(Number.parseFloat(match[3]), 0, 100);
2508
- const a = clamp(Number.isNaN(alpha) ? 1 : alpha, 0, 1);
2509
- return [h, s, l, a];
2510
- }
2511
- return null;
2512
- };
2513
- cs.get.hwb = function(string) {
2514
- if (!string) {
2515
- return null;
2516
- }
2517
- const hwb = /^hwb\(\s*([+-]?\d{0,3}(?:\.\d+)?)(?:deg)?\s*[\s,]\s*([+-]?[\d.]+)%\s*[\s,]\s*([+-]?[\d.]+)%\s*(?:[\s,]\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:e[+-]?\d+)?)\s*)?\)$/i;
2518
- const match = string.match(hwb);
2519
- if (match) {
2520
- const alpha = Number.parseFloat(match[4]);
2521
- const h = (Number.parseFloat(match[1]) % 360 + 360) % 360;
2522
- const w = clamp(Number.parseFloat(match[2]), 0, 100);
2523
- const b = clamp(Number.parseFloat(match[3]), 0, 100);
2524
- const a = clamp(Number.isNaN(alpha) ? 1 : alpha, 0, 1);
2525
- return [h, w, b, a];
2526
- }
2527
- return null;
2528
- };
2529
- cs.to.hex = function(...rgba) {
2530
- return "#" + hexDouble(rgba[0]) + hexDouble(rgba[1]) + hexDouble(rgba[2]) + (rgba[3] < 1 ? hexDouble(Math.round(rgba[3] * 255)) : "");
2531
- };
2532
- cs.to.rgb = function(...rgba) {
2533
- return rgba.length < 4 || rgba[3] === 1 ? "rgb(" + Math.round(rgba[0]) + ", " + Math.round(rgba[1]) + ", " + Math.round(rgba[2]) + ")" : "rgba(" + Math.round(rgba[0]) + ", " + Math.round(rgba[1]) + ", " + Math.round(rgba[2]) + ", " + rgba[3] + ")";
2534
- };
2535
- cs.to.rgb.percent = function(...rgba) {
2536
- const r = Math.round(rgba[0] / 255 * 100);
2537
- const g = Math.round(rgba[1] / 255 * 100);
2538
- const b = Math.round(rgba[2] / 255 * 100);
2539
- return rgba.length < 4 || rgba[3] === 1 ? "rgb(" + r + "%, " + g + "%, " + b + "%)" : "rgba(" + r + "%, " + g + "%, " + b + "%, " + rgba[3] + ")";
2540
- };
2541
- cs.to.hsl = function(...hsla) {
2542
- return hsla.length < 4 || hsla[3] === 1 ? "hsl(" + hsla[0] + ", " + hsla[1] + "%, " + hsla[2] + "%)" : "hsla(" + hsla[0] + ", " + hsla[1] + "%, " + hsla[2] + "%, " + hsla[3] + ")";
2543
- };
2544
- cs.to.hwb = function(...hwba) {
2545
- let a = "";
2546
- if (hwba.length >= 4 && hwba[3] !== 1) {
2547
- a = ", " + hwba[3];
2548
- }
2549
- return "hwb(" + hwba[0] + ", " + hwba[1] + "%, " + hwba[2] + "%" + a + ")";
2550
- };
2551
- cs.to.keyword = function(...rgb) {
2552
- return reverseNames[rgb.slice(0, 3)];
2553
- };
2554
- function clamp(number_, min, max) {
2555
- return Math.min(Math.max(min, number_), max);
2556
- }
2557
- function hexDouble(number_) {
2558
- const string_ = Math.round(number_).toString(16).toUpperCase();
2559
- return string_.length < 2 ? "0" + string_ : string_;
2560
- }
2561
- var color_string_default = cs;
2562
- var reverseKeywords = {};
2563
- for (const key of Object.keys(color_name_default)) {
2564
- reverseKeywords[color_name_default[key]] = key;
2565
- }
2566
- var convert = {
2567
- rgb: { channels: 3, labels: "rgb" },
2568
- hsl: { channels: 3, labels: "hsl" },
2569
- hsv: { channels: 3, labels: "hsv" },
2570
- hwb: { channels: 3, labels: "hwb" },
2571
- cmyk: { channels: 4, labels: "cmyk" },
2572
- xyz: { channels: 3, labels: "xyz" },
2573
- lab: { channels: 3, labels: "lab" },
2574
- oklab: { channels: 3, labels: ["okl", "oka", "okb"] },
2575
- lch: { channels: 3, labels: "lch" },
2576
- oklch: { channels: 3, labels: ["okl", "okc", "okh"] },
2577
- hex: { channels: 1, labels: ["hex"] },
2578
- keyword: { channels: 1, labels: ["keyword"] },
2579
- ansi16: { channels: 1, labels: ["ansi16"] },
2580
- ansi256: { channels: 1, labels: ["ansi256"] },
2581
- hcg: { channels: 3, labels: ["h", "c", "g"] },
2582
- apple: { channels: 3, labels: ["r16", "g16", "b16"] },
2583
- gray: { channels: 1, labels: ["gray"] }
2584
- };
2585
- var conversions_default = convert;
2586
- var LAB_FT = (6 / 29) ** 3;
2587
- function srgbNonlinearTransform(c) {
2588
- const cc = c > 0.0031308 ? 1.055 * c ** (1 / 2.4) - 0.055 : c * 12.92;
2589
- return Math.min(Math.max(0, cc), 1);
2590
- }
2591
- function srgbNonlinearTransformInv(c) {
2592
- return c > 0.04045 ? ((c + 0.055) / 1.055) ** 2.4 : c / 12.92;
2593
- }
2594
- for (const model of Object.keys(convert)) {
2595
- if (!("channels" in convert[model])) {
2596
- throw new Error("missing channels property: " + model);
2597
- }
2598
- if (!("labels" in convert[model])) {
2599
- throw new Error("missing channel labels property: " + model);
2600
- }
2601
- if (convert[model].labels.length !== convert[model].channels) {
2602
- throw new Error("channel and label counts mismatch: " + model);
2603
- }
2604
- const { channels, labels } = convert[model];
2605
- delete convert[model].channels;
2606
- delete convert[model].labels;
2607
- Object.defineProperty(convert[model], "channels", { value: channels });
2608
- Object.defineProperty(convert[model], "labels", { value: labels });
2609
- }
2610
- convert.rgb.hsl = function(rgb) {
2611
- const r = rgb[0] / 255;
2612
- const g = rgb[1] / 255;
2613
- const b = rgb[2] / 255;
2614
- const min = Math.min(r, g, b);
2615
- const max = Math.max(r, g, b);
2616
- const delta = max - min;
2617
- let h;
2618
- let s;
2619
- switch (max) {
2620
- case min: {
2621
- h = 0;
2622
- break;
2623
- }
2624
- case r: {
2625
- h = (g - b) / delta;
2626
- break;
2627
- }
2628
- case g: {
2629
- h = 2 + (b - r) / delta;
2630
- break;
2631
- }
2632
- case b: {
2633
- h = 4 + (r - g) / delta;
2634
- break;
2635
- }
2636
- }
2637
- h = Math.min(h * 60, 360);
2638
- if (h < 0) {
2639
- h += 360;
2640
- }
2641
- const l = (min + max) / 2;
2642
- if (max === min) {
2643
- s = 0;
2644
- } else if (l <= 0.5) {
2645
- s = delta / (max + min);
2646
- } else {
2647
- s = delta / (2 - max - min);
2648
- }
2649
- return [h, s * 100, l * 100];
2650
- };
2651
- convert.rgb.hsv = function(rgb) {
2652
- let rdif;
2653
- let gdif;
2654
- let bdif;
2655
- let h;
2656
- let s;
2657
- const r = rgb[0] / 255;
2658
- const g = rgb[1] / 255;
2659
- const b = rgb[2] / 255;
2660
- const v = Math.max(r, g, b);
2661
- const diff = v - Math.min(r, g, b);
2662
- const diffc = function(c) {
2663
- return (v - c) / 6 / diff + 1 / 2;
2664
- };
2665
- if (diff === 0) {
2666
- h = 0;
2667
- s = 0;
2668
- } else {
2669
- s = diff / v;
2670
- rdif = diffc(r);
2671
- gdif = diffc(g);
2672
- bdif = diffc(b);
2673
- switch (v) {
2674
- case r: {
2675
- h = bdif - gdif;
2676
- break;
2677
- }
2678
- case g: {
2679
- h = 1 / 3 + rdif - bdif;
2680
- break;
2681
- }
2682
- case b: {
2683
- h = 2 / 3 + gdif - rdif;
2684
- break;
2685
- }
2686
- }
2687
- if (h < 0) {
2688
- h += 1;
2689
- } else if (h > 1) {
2690
- h -= 1;
2691
- }
2692
- }
2693
- return [
2694
- h * 360,
2695
- s * 100,
2696
- v * 100
2697
- ];
2698
- };
2699
- convert.rgb.hwb = function(rgb) {
2700
- const r = rgb[0];
2701
- const g = rgb[1];
2702
- let b = rgb[2];
2703
- const h = convert.rgb.hsl(rgb)[0];
2704
- const w = 1 / 255 * Math.min(r, Math.min(g, b));
2705
- b = 1 - 1 / 255 * Math.max(r, Math.max(g, b));
2706
- return [h, w * 100, b * 100];
2707
- };
2708
- convert.rgb.oklab = function(rgb) {
2709
- const r = srgbNonlinearTransformInv(rgb[0] / 255);
2710
- const g = srgbNonlinearTransformInv(rgb[1] / 255);
2711
- const b = srgbNonlinearTransformInv(rgb[2] / 255);
2712
- const lp = Math.cbrt(0.4122214708 * r + 0.5363325363 * g + 0.0514459929 * b);
2713
- const mp = Math.cbrt(0.2119034982 * r + 0.6806995451 * g + 0.1073969566 * b);
2714
- const sp = Math.cbrt(0.0883024619 * r + 0.2817188376 * g + 0.6299787005 * b);
2715
- const l = 0.2104542553 * lp + 0.793617785 * mp - 0.0040720468 * sp;
2716
- const aa = 1.9779984951 * lp - 2.428592205 * mp + 0.4505937099 * sp;
2717
- const bb = 0.0259040371 * lp + 0.7827717662 * mp - 0.808675766 * sp;
2718
- return [l * 100, aa * 100, bb * 100];
2719
- };
2720
- convert.rgb.cmyk = function(rgb) {
2721
- const r = rgb[0] / 255;
2722
- const g = rgb[1] / 255;
2723
- const b = rgb[2] / 255;
2724
- const k = Math.min(1 - r, 1 - g, 1 - b);
2725
- const c = (1 - r - k) / (1 - k) || 0;
2726
- const m = (1 - g - k) / (1 - k) || 0;
2727
- const y = (1 - b - k) / (1 - k) || 0;
2728
- return [c * 100, m * 100, y * 100, k * 100];
2729
- };
2730
- function comparativeDistance(x, y) {
2731
- return (x[0] - y[0]) ** 2 + (x[1] - y[1]) ** 2 + (x[2] - y[2]) ** 2;
2732
- }
2733
- convert.rgb.keyword = function(rgb) {
2734
- const reversed = reverseKeywords[rgb];
2735
- if (reversed) {
2736
- return reversed;
2737
- }
2738
- let currentClosestDistance = Number.POSITIVE_INFINITY;
2739
- let currentClosestKeyword;
2740
- for (const keyword of Object.keys(color_name_default)) {
2741
- const value = color_name_default[keyword];
2742
- const distance = comparativeDistance(rgb, value);
2743
- if (distance < currentClosestDistance) {
2744
- currentClosestDistance = distance;
2745
- currentClosestKeyword = keyword;
2746
- }
2747
- }
2748
- return currentClosestKeyword;
2749
- };
2750
- convert.keyword.rgb = function(keyword) {
2751
- return [...color_name_default[keyword]];
2752
- };
2753
- convert.rgb.xyz = function(rgb) {
2754
- const r = srgbNonlinearTransformInv(rgb[0] / 255);
2755
- const g = srgbNonlinearTransformInv(rgb[1] / 255);
2756
- const b = srgbNonlinearTransformInv(rgb[2] / 255);
2757
- const x = r * 0.4124564 + g * 0.3575761 + b * 0.1804375;
2758
- const y = r * 0.2126729 + g * 0.7151522 + b * 0.072175;
2759
- const z = r * 0.0193339 + g * 0.119192 + b * 0.9503041;
2760
- return [x * 100, y * 100, z * 100];
2761
- };
2762
- convert.rgb.lab = function(rgb) {
2763
- const xyz = convert.rgb.xyz(rgb);
2764
- let x = xyz[0];
2765
- let y = xyz[1];
2766
- let z = xyz[2];
2767
- x /= 95.047;
2768
- y /= 100;
2769
- z /= 108.883;
2770
- x = x > LAB_FT ? x ** (1 / 3) : 7.787 * x + 16 / 116;
2771
- y = y > LAB_FT ? y ** (1 / 3) : 7.787 * y + 16 / 116;
2772
- z = z > LAB_FT ? z ** (1 / 3) : 7.787 * z + 16 / 116;
2773
- const l = 116 * y - 16;
2774
- const a = 500 * (x - y);
2775
- const b = 200 * (y - z);
2776
- return [l, a, b];
2777
- };
2778
- convert.hsl.rgb = function(hsl) {
2779
- const h = hsl[0] / 360;
2780
- const s = hsl[1] / 100;
2781
- const l = hsl[2] / 100;
2782
- let t3;
2783
- let value;
2784
- if (s === 0) {
2785
- value = l * 255;
2786
- return [value, value, value];
2787
- }
2788
- const t2 = l < 0.5 ? l * (1 + s) : l + s - l * s;
2789
- const t1 = 2 * l - t2;
2790
- const rgb = [0, 0, 0];
2791
- for (let i = 0;i < 3; i++) {
2792
- t3 = h + 1 / 3 * -(i - 1);
2793
- if (t3 < 0) {
2794
- t3++;
2795
- }
2796
- if (t3 > 1) {
2797
- t3--;
2798
- }
2799
- if (6 * t3 < 1) {
2800
- value = t1 + (t2 - t1) * 6 * t3;
2801
- } else if (2 * t3 < 1) {
2802
- value = t2;
2803
- } else if (3 * t3 < 2) {
2804
- value = t1 + (t2 - t1) * (2 / 3 - t3) * 6;
2805
- } else {
2806
- value = t1;
2807
- }
2808
- rgb[i] = value * 255;
2809
- }
2810
- return rgb;
2811
- };
2812
- convert.hsl.hsv = function(hsl) {
2813
- const h = hsl[0];
2814
- let s = hsl[1] / 100;
2815
- let l = hsl[2] / 100;
2816
- let smin = s;
2817
- const lmin = Math.max(l, 0.01);
2818
- l *= 2;
2819
- s *= l <= 1 ? l : 2 - l;
2820
- smin *= lmin <= 1 ? lmin : 2 - lmin;
2821
- const v = (l + s) / 2;
2822
- const sv = l === 0 ? 2 * smin / (lmin + smin) : 2 * s / (l + s);
2823
- return [h, sv * 100, v * 100];
2824
- };
2825
- convert.hsv.rgb = function(hsv) {
2826
- const h = hsv[0] / 60;
2827
- const s = hsv[1] / 100;
2828
- let v = hsv[2] / 100;
2829
- const hi = Math.floor(h) % 6;
2830
- const f = h - Math.floor(h);
2831
- const p = 255 * v * (1 - s);
2832
- const q = 255 * v * (1 - s * f);
2833
- const t = 255 * v * (1 - s * (1 - f));
2834
- v *= 255;
2835
- switch (hi) {
2836
- case 0: {
2837
- return [v, t, p];
2838
- }
2839
- case 1: {
2840
- return [q, v, p];
2841
- }
2842
- case 2: {
2843
- return [p, v, t];
2844
- }
2845
- case 3: {
2846
- return [p, q, v];
2847
- }
2848
- case 4: {
2849
- return [t, p, v];
2850
- }
2851
- case 5: {
2852
- return [v, p, q];
2853
- }
2854
- }
2855
- };
2856
- convert.hsv.hsl = function(hsv) {
2857
- const h = hsv[0];
2858
- const s = hsv[1] / 100;
2859
- const v = hsv[2] / 100;
2860
- const vmin = Math.max(v, 0.01);
2861
- let sl;
2862
- let l;
2863
- l = (2 - s) * v;
2864
- const lmin = (2 - s) * vmin;
2865
- sl = s * vmin;
2866
- sl /= lmin <= 1 ? lmin : 2 - lmin;
2867
- sl = sl || 0;
2868
- l /= 2;
2869
- return [h, sl * 100, l * 100];
2870
- };
2871
- convert.hwb.rgb = function(hwb) {
2872
- const h = hwb[0] / 360;
2873
- let wh = hwb[1] / 100;
2874
- let bl = hwb[2] / 100;
2875
- const ratio = wh + bl;
2876
- let f;
2877
- if (ratio > 1) {
2878
- wh /= ratio;
2879
- bl /= ratio;
2880
- }
2881
- const i = Math.floor(6 * h);
2882
- const v = 1 - bl;
2883
- f = 6 * h - i;
2884
- if ((i & 1) !== 0) {
2885
- f = 1 - f;
2886
- }
2887
- const n = wh + f * (v - wh);
2888
- let r;
2889
- let g;
2890
- let b;
2891
- switch (i) {
2892
- default:
2893
- case 6:
2894
- case 0: {
2895
- r = v;
2896
- g = n;
2897
- b = wh;
2898
- break;
2899
- }
2900
- case 1: {
2901
- r = n;
2902
- g = v;
2903
- b = wh;
2904
- break;
2905
- }
2906
- case 2: {
2907
- r = wh;
2908
- g = v;
2909
- b = n;
2910
- break;
2911
- }
2912
- case 3: {
2913
- r = wh;
2914
- g = n;
2915
- b = v;
2916
- break;
2917
- }
2918
- case 4: {
2919
- r = n;
2920
- g = wh;
2921
- b = v;
2922
- break;
2923
- }
2924
- case 5: {
2925
- r = v;
2926
- g = wh;
2927
- b = n;
2928
- break;
2929
- }
2930
- }
2931
- return [r * 255, g * 255, b * 255];
2932
- };
2933
- convert.cmyk.rgb = function(cmyk) {
2934
- const c = cmyk[0] / 100;
2935
- const m = cmyk[1] / 100;
2936
- const y = cmyk[2] / 100;
2937
- const k = cmyk[3] / 100;
2938
- const r = 1 - Math.min(1, c * (1 - k) + k);
2939
- const g = 1 - Math.min(1, m * (1 - k) + k);
2940
- const b = 1 - Math.min(1, y * (1 - k) + k);
2941
- return [r * 255, g * 255, b * 255];
2942
- };
2943
- convert.xyz.rgb = function(xyz) {
2944
- const x = xyz[0] / 100;
2945
- const y = xyz[1] / 100;
2946
- const z = xyz[2] / 100;
2947
- let r;
2948
- let g;
2949
- let b;
2950
- r = x * 3.2404542 + y * -1.5371385 + z * -0.4985314;
2951
- g = x * -0.969266 + y * 1.8760108 + z * 0.041556;
2952
- b = x * 0.0556434 + y * -0.2040259 + z * 1.0572252;
2953
- r = srgbNonlinearTransform(r);
2954
- g = srgbNonlinearTransform(g);
2955
- b = srgbNonlinearTransform(b);
2956
- return [r * 255, g * 255, b * 255];
2957
- };
2958
- convert.xyz.lab = function(xyz) {
2959
- let x = xyz[0];
2960
- let y = xyz[1];
2961
- let z = xyz[2];
2962
- x /= 95.047;
2963
- y /= 100;
2964
- z /= 108.883;
2965
- x = x > LAB_FT ? x ** (1 / 3) : 7.787 * x + 16 / 116;
2966
- y = y > LAB_FT ? y ** (1 / 3) : 7.787 * y + 16 / 116;
2967
- z = z > LAB_FT ? z ** (1 / 3) : 7.787 * z + 16 / 116;
2968
- const l = 116 * y - 16;
2969
- const a = 500 * (x - y);
2970
- const b = 200 * (y - z);
2971
- return [l, a, b];
2972
- };
2973
- convert.xyz.oklab = function(xyz) {
2974
- const x = xyz[0] / 100;
2975
- const y = xyz[1] / 100;
2976
- const z = xyz[2] / 100;
2977
- const lp = Math.cbrt(0.8189330101 * x + 0.3618667424 * y - 0.1288597137 * z);
2978
- const mp = Math.cbrt(0.0329845436 * x + 0.9293118715 * y + 0.0361456387 * z);
2979
- const sp = Math.cbrt(0.0482003018 * x + 0.2643662691 * y + 0.633851707 * z);
2980
- const l = 0.2104542553 * lp + 0.793617785 * mp - 0.0040720468 * sp;
2981
- const a = 1.9779984951 * lp - 2.428592205 * mp + 0.4505937099 * sp;
2982
- const b = 0.0259040371 * lp + 0.7827717662 * mp - 0.808675766 * sp;
2983
- return [l * 100, a * 100, b * 100];
2984
- };
2985
- convert.oklab.oklch = function(oklab) {
2986
- return convert.lab.lch(oklab);
2987
- };
2988
- convert.oklab.xyz = function(oklab) {
2989
- const ll = oklab[0] / 100;
2990
- const a = oklab[1] / 100;
2991
- const b = oklab[2] / 100;
2992
- const l = (0.999999998 * ll + 0.396337792 * a + 0.215803758 * b) ** 3;
2993
- const m = (1.000000008 * ll - 0.105561342 * a - 0.063854175 * b) ** 3;
2994
- const s = (1.000000055 * ll - 0.089484182 * a - 1.291485538 * b) ** 3;
2995
- const x = 1.227013851 * l - 0.55779998 * m + 0.281256149 * s;
2996
- const y = -0.040580178 * l + 1.11225687 * m - 0.071676679 * s;
2997
- const z = -0.076381285 * l - 0.421481978 * m + 1.58616322 * s;
2998
- return [x * 100, y * 100, z * 100];
2999
- };
3000
- convert.oklab.rgb = function(oklab) {
3001
- const ll = oklab[0] / 100;
3002
- const aa = oklab[1] / 100;
3003
- const bb = oklab[2] / 100;
3004
- const l = (ll + 0.3963377774 * aa + 0.2158037573 * bb) ** 3;
3005
- const m = (ll - 0.1055613458 * aa - 0.0638541728 * bb) ** 3;
3006
- const s = (ll - 0.0894841775 * aa - 1.291485548 * bb) ** 3;
3007
- const r = srgbNonlinearTransform(4.0767416621 * l - 3.3077115913 * m + 0.2309699292 * s);
3008
- const g = srgbNonlinearTransform(-1.2684380046 * l + 2.6097574011 * m - 0.3413193965 * s);
3009
- const b = srgbNonlinearTransform(-0.0041960863 * l - 0.7034186147 * m + 1.707614701 * s);
3010
- return [r * 255, g * 255, b * 255];
3011
- };
3012
- convert.oklch.oklab = function(oklch) {
3013
- return convert.lch.lab(oklch);
3014
- };
3015
- convert.lab.xyz = function(lab) {
3016
- const l = lab[0];
3017
- const a = lab[1];
3018
- const b = lab[2];
3019
- let x;
3020
- let y;
3021
- let z;
3022
- y = (l + 16) / 116;
3023
- x = a / 500 + y;
3024
- z = y - b / 200;
3025
- const y2 = y ** 3;
3026
- const x2 = x ** 3;
3027
- const z2 = z ** 3;
3028
- y = y2 > LAB_FT ? y2 : (y - 16 / 116) / 7.787;
3029
- x = x2 > LAB_FT ? x2 : (x - 16 / 116) / 7.787;
3030
- z = z2 > LAB_FT ? z2 : (z - 16 / 116) / 7.787;
3031
- x *= 95.047;
3032
- y *= 100;
3033
- z *= 108.883;
3034
- return [x, y, z];
3035
- };
3036
- convert.lab.lch = function(lab) {
3037
- const l = lab[0];
3038
- const a = lab[1];
3039
- const b = lab[2];
3040
- let h;
3041
- const hr = Math.atan2(b, a);
3042
- h = hr * 360 / 2 / Math.PI;
3043
- if (h < 0) {
3044
- h += 360;
3045
- }
3046
- const c = Math.sqrt(a * a + b * b);
3047
- return [l, c, h];
3048
- };
3049
- convert.lch.lab = function(lch) {
3050
- const l = lch[0];
3051
- const c = lch[1];
3052
- const h = lch[2];
3053
- const hr = h / 360 * 2 * Math.PI;
3054
- const a = c * Math.cos(hr);
3055
- const b = c * Math.sin(hr);
3056
- return [l, a, b];
3057
- };
3058
- convert.rgb.ansi16 = function(args, saturation = null) {
3059
- const [r, g, b] = args;
3060
- let value = saturation === null ? convert.rgb.hsv(args)[2] : saturation;
3061
- value = Math.round(value / 50);
3062
- if (value === 0) {
3063
- return 30;
3064
- }
3065
- let ansi = 30 + (Math.round(b / 255) << 2 | Math.round(g / 255) << 1 | Math.round(r / 255));
3066
- if (value === 2) {
3067
- ansi += 60;
3068
- }
3069
- return ansi;
3070
- };
3071
- convert.hsv.ansi16 = function(args) {
3072
- return convert.rgb.ansi16(convert.hsv.rgb(args), args[2]);
3073
- };
3074
- convert.rgb.ansi256 = function(args) {
3075
- const r = args[0];
3076
- const g = args[1];
3077
- const b = args[2];
3078
- if (r >> 4 === g >> 4 && g >> 4 === b >> 4) {
3079
- if (r < 8) {
3080
- return 16;
3081
- }
3082
- if (r > 248) {
3083
- return 231;
3084
- }
3085
- return Math.round((r - 8) / 247 * 24) + 232;
3086
- }
3087
- const ansi = 16 + 36 * Math.round(r / 255 * 5) + 6 * Math.round(g / 255 * 5) + Math.round(b / 255 * 5);
3088
- return ansi;
3089
- };
3090
- convert.ansi16.rgb = function(args) {
3091
- args = args[0];
3092
- let color = args % 10;
3093
- if (color === 0 || color === 7) {
3094
- if (args > 50) {
3095
- color += 3.5;
3096
- }
3097
- color = color / 10.5 * 255;
3098
- return [color, color, color];
3099
- }
3100
- const mult = (Math.trunc(args > 50) + 1) * 0.5;
3101
- const r = (color & 1) * mult * 255;
3102
- const g = (color >> 1 & 1) * mult * 255;
3103
- const b = (color >> 2 & 1) * mult * 255;
3104
- return [r, g, b];
3105
- };
3106
- convert.ansi256.rgb = function(args) {
3107
- args = args[0];
3108
- if (args >= 232) {
3109
- const c = (args - 232) * 10 + 8;
3110
- return [c, c, c];
3111
- }
3112
- args -= 16;
3113
- let rem;
3114
- const r = Math.floor(args / 36) / 5 * 255;
3115
- const g = Math.floor((rem = args % 36) / 6) / 5 * 255;
3116
- const b = rem % 6 / 5 * 255;
3117
- return [r, g, b];
3118
- };
3119
- convert.rgb.hex = function(args) {
3120
- const integer = ((Math.round(args[0]) & 255) << 16) + ((Math.round(args[1]) & 255) << 8) + (Math.round(args[2]) & 255);
3121
- const string = integer.toString(16).toUpperCase();
3122
- return "000000".slice(string.length) + string;
3123
- };
3124
- convert.hex.rgb = function(args) {
3125
- const match = args.toString(16).match(/[a-f\d]{6}|[a-f\d]{3}/i);
3126
- if (!match) {
3127
- return [0, 0, 0];
3128
- }
3129
- let colorString = match[0];
3130
- if (match[0].length === 3) {
3131
- colorString = [...colorString].map((char) => char + char).join("");
3132
- }
3133
- const integer = Number.parseInt(colorString, 16);
3134
- const r = integer >> 16 & 255;
3135
- const g = integer >> 8 & 255;
3136
- const b = integer & 255;
3137
- return [r, g, b];
3138
- };
3139
- convert.rgb.hcg = function(rgb) {
3140
- const r = rgb[0] / 255;
3141
- const g = rgb[1] / 255;
3142
- const b = rgb[2] / 255;
3143
- const max = Math.max(Math.max(r, g), b);
3144
- const min = Math.min(Math.min(r, g), b);
3145
- const chroma = max - min;
3146
- let hue;
3147
- const grayscale = chroma < 1 ? min / (1 - chroma) : 0;
3148
- if (chroma <= 0) {
3149
- hue = 0;
3150
- } else if (max === r) {
3151
- hue = (g - b) / chroma % 6;
3152
- } else if (max === g) {
3153
- hue = 2 + (b - r) / chroma;
3154
- } else {
3155
- hue = 4 + (r - g) / chroma;
3156
- }
3157
- hue /= 6;
3158
- hue %= 1;
3159
- return [hue * 360, chroma * 100, grayscale * 100];
3160
- };
3161
- convert.hsl.hcg = function(hsl) {
3162
- const s = hsl[1] / 100;
3163
- const l = hsl[2] / 100;
3164
- const c = l < 0.5 ? 2 * s * l : 2 * s * (1 - l);
3165
- let f = 0;
3166
- if (c < 1) {
3167
- f = (l - 0.5 * c) / (1 - c);
3168
- }
3169
- return [hsl[0], c * 100, f * 100];
3170
- };
3171
- convert.hsv.hcg = function(hsv) {
3172
- const s = hsv[1] / 100;
3173
- const v = hsv[2] / 100;
3174
- const c = s * v;
3175
- let f = 0;
3176
- if (c < 1) {
3177
- f = (v - c) / (1 - c);
3178
- }
3179
- return [hsv[0], c * 100, f * 100];
3180
- };
3181
- convert.hcg.rgb = function(hcg) {
3182
- const h = hcg[0] / 360;
3183
- const c = hcg[1] / 100;
3184
- const g = hcg[2] / 100;
3185
- if (c === 0) {
3186
- return [g * 255, g * 255, g * 255];
3187
- }
3188
- const pure = [0, 0, 0];
3189
- const hi = h % 1 * 6;
3190
- const v = hi % 1;
3191
- const w = 1 - v;
3192
- let mg = 0;
3193
- switch (Math.floor(hi)) {
3194
- case 0: {
3195
- pure[0] = 1;
3196
- pure[1] = v;
3197
- pure[2] = 0;
3198
- break;
3199
- }
3200
- case 1: {
3201
- pure[0] = w;
3202
- pure[1] = 1;
3203
- pure[2] = 0;
3204
- break;
3205
- }
3206
- case 2: {
3207
- pure[0] = 0;
3208
- pure[1] = 1;
3209
- pure[2] = v;
3210
- break;
3211
- }
3212
- case 3: {
3213
- pure[0] = 0;
3214
- pure[1] = w;
3215
- pure[2] = 1;
3216
- break;
3217
- }
3218
- case 4: {
3219
- pure[0] = v;
3220
- pure[1] = 0;
3221
- pure[2] = 1;
3222
- break;
3223
- }
3224
- default: {
3225
- pure[0] = 1;
3226
- pure[1] = 0;
3227
- pure[2] = w;
3228
- }
3229
- }
3230
- mg = (1 - c) * g;
3231
- return [
3232
- (c * pure[0] + mg) * 255,
3233
- (c * pure[1] + mg) * 255,
3234
- (c * pure[2] + mg) * 255
3235
- ];
3236
- };
3237
- convert.hcg.hsv = function(hcg) {
3238
- const c = hcg[1] / 100;
3239
- const g = hcg[2] / 100;
3240
- const v = c + g * (1 - c);
3241
- let f = 0;
3242
- if (v > 0) {
3243
- f = c / v;
3244
- }
3245
- return [hcg[0], f * 100, v * 100];
3246
- };
3247
- convert.hcg.hsl = function(hcg) {
3248
- const c = hcg[1] / 100;
3249
- const g = hcg[2] / 100;
3250
- const l = g * (1 - c) + 0.5 * c;
3251
- let s = 0;
3252
- if (l > 0 && l < 0.5) {
3253
- s = c / (2 * l);
3254
- } else if (l >= 0.5 && l < 1) {
3255
- s = c / (2 * (1 - l));
3256
- }
3257
- return [hcg[0], s * 100, l * 100];
3258
- };
3259
- convert.hcg.hwb = function(hcg) {
3260
- const c = hcg[1] / 100;
3261
- const g = hcg[2] / 100;
3262
- const v = c + g * (1 - c);
3263
- return [hcg[0], (v - c) * 100, (1 - v) * 100];
3264
- };
3265
- convert.hwb.hcg = function(hwb) {
3266
- const w = hwb[1] / 100;
3267
- const b = hwb[2] / 100;
3268
- const v = 1 - b;
3269
- const c = v - w;
3270
- let g = 0;
3271
- if (c < 1) {
3272
- g = (v - c) / (1 - c);
3273
- }
3274
- return [hwb[0], c * 100, g * 100];
3275
- };
3276
- convert.apple.rgb = function(apple) {
3277
- return [apple[0] / 65535 * 255, apple[1] / 65535 * 255, apple[2] / 65535 * 255];
3278
- };
3279
- convert.rgb.apple = function(rgb) {
3280
- return [rgb[0] / 255 * 65535, rgb[1] / 255 * 65535, rgb[2] / 255 * 65535];
3281
- };
3282
- convert.gray.rgb = function(args) {
3283
- return [args[0] / 100 * 255, args[0] / 100 * 255, args[0] / 100 * 255];
3284
- };
3285
- convert.gray.hsl = function(args) {
3286
- return [0, 0, args[0]];
3287
- };
3288
- convert.gray.hsv = convert.gray.hsl;
3289
- convert.gray.hwb = function(gray) {
3290
- return [0, 100, gray[0]];
3291
- };
3292
- convert.gray.cmyk = function(gray) {
3293
- return [0, 0, 0, gray[0]];
3294
- };
3295
- convert.gray.lab = function(gray) {
3296
- return [gray[0], 0, 0];
3297
- };
3298
- convert.gray.hex = function(gray) {
3299
- const value = Math.round(gray[0] / 100 * 255) & 255;
3300
- const integer = (value << 16) + (value << 8) + value;
3301
- const string = integer.toString(16).toUpperCase();
3302
- return "000000".slice(string.length) + string;
3303
- };
3304
- convert.rgb.gray = function(rgb) {
3305
- const value = (rgb[0] + rgb[1] + rgb[2]) / 3;
3306
- return [value / 255 * 100];
3307
- };
3308
- function buildGraph() {
3309
- const graph = {};
3310
- const models2 = Object.keys(conversions_default);
3311
- for (let { length } = models2, i = 0;i < length; i++) {
3312
- graph[models2[i]] = {
3313
- distance: -1,
3314
- parent: null
3315
- };
3316
- }
3317
- return graph;
3318
- }
3319
- function deriveBFS(fromModel) {
3320
- const graph = buildGraph();
3321
- const queue = [fromModel];
3322
- graph[fromModel].distance = 0;
3323
- while (queue.length > 0) {
3324
- const current = queue.pop();
3325
- const adjacents = Object.keys(conversions_default[current]);
3326
- for (let { length } = adjacents, i = 0;i < length; i++) {
3327
- const adjacent = adjacents[i];
3328
- const node = graph[adjacent];
3329
- if (node.distance === -1) {
3330
- node.distance = graph[current].distance + 1;
3331
- node.parent = current;
3332
- queue.unshift(adjacent);
3333
- }
3334
- }
3335
- }
3336
- return graph;
3337
- }
3338
- function link(from, to) {
3339
- return function(args) {
3340
- return to(from(args));
3341
- };
3342
- }
3343
- function wrapConversion(toModel, graph) {
3344
- const path = [graph[toModel].parent, toModel];
3345
- let fn = conversions_default[graph[toModel].parent][toModel];
3346
- let cur = graph[toModel].parent;
3347
- while (graph[cur].parent) {
3348
- path.unshift(graph[cur].parent);
3349
- fn = link(conversions_default[graph[cur].parent][cur], fn);
3350
- cur = graph[cur].parent;
3351
- }
3352
- fn.conversion = path;
3353
- return fn;
3354
- }
3355
- function route(fromModel) {
3356
- const graph = deriveBFS(fromModel);
3357
- const conversion = {};
3358
- const models2 = Object.keys(graph);
3359
- for (let { length } = models2, i = 0;i < length; i++) {
3360
- const toModel = models2[i];
3361
- const node = graph[toModel];
3362
- if (node.parent === null) {
3363
- continue;
3364
- }
3365
- conversion[toModel] = wrapConversion(toModel, graph);
3366
- }
3367
- return conversion;
3368
- }
3369
- var route_default = route;
3370
- var convert2 = {};
3371
- var models = Object.keys(conversions_default);
3372
- function wrapRaw(fn) {
3373
- const wrappedFn = function(...args) {
3374
- const arg0 = args[0];
3375
- if (arg0 === undefined || arg0 === null) {
3376
- return arg0;
3377
- }
3378
- if (arg0.length > 1) {
3379
- args = arg0;
3380
- }
3381
- return fn(args);
3382
- };
3383
- if ("conversion" in fn) {
3384
- wrappedFn.conversion = fn.conversion;
3385
- }
3386
- return wrappedFn;
3387
- }
3388
- function wrapRounded(fn) {
3389
- const wrappedFn = function(...args) {
3390
- const arg0 = args[0];
3391
- if (arg0 === undefined || arg0 === null) {
3392
- return arg0;
3393
- }
3394
- if (arg0.length > 1) {
3395
- args = arg0;
3396
- }
3397
- const result = fn(args);
3398
- if (typeof result === "object") {
3399
- for (let { length } = result, i = 0;i < length; i++) {
3400
- result[i] = Math.round(result[i]);
3401
- }
3402
- }
3403
- return result;
3404
- };
3405
- if ("conversion" in fn) {
3406
- wrappedFn.conversion = fn.conversion;
3407
- }
3408
- return wrappedFn;
3409
- }
3410
- for (const fromModel of models) {
3411
- convert2[fromModel] = {};
3412
- Object.defineProperty(convert2[fromModel], "channels", { value: conversions_default[fromModel].channels });
3413
- Object.defineProperty(convert2[fromModel], "labels", { value: conversions_default[fromModel].labels });
3414
- const routes = route_default(fromModel);
3415
- const routeModels = Object.keys(routes);
3416
- for (const toModel of routeModels) {
3417
- const fn = routes[toModel];
3418
- convert2[fromModel][toModel] = wrapRounded(fn);
3419
- convert2[fromModel][toModel].raw = wrapRaw(fn);
3420
- }
3421
- }
3422
- var color_convert_default = convert2;
3423
- var skippedModels = [
3424
- "keyword",
3425
- "gray",
3426
- "hex"
3427
- ];
3428
- var hashedModelKeys = {};
3429
- for (const model of Object.keys(color_convert_default)) {
3430
- hashedModelKeys[[...color_convert_default[model].labels].sort().join("")] = model;
3431
- }
3432
- var limiters = {};
3433
- function Color(object, model) {
3434
- if (!(this instanceof Color)) {
3435
- return new Color(object, model);
3436
- }
3437
- if (model && model in skippedModels) {
3438
- model = null;
3439
- }
3440
- if (model && !(model in color_convert_default)) {
3441
- throw new Error("Unknown model: " + model);
3442
- }
3443
- let i;
3444
- let channels;
3445
- if (object == null) {
3446
- this.model = "rgb";
3447
- this.color = [0, 0, 0];
3448
- this.valpha = 1;
3449
- } else if (object instanceof Color) {
3450
- this.model = object.model;
3451
- this.color = [...object.color];
3452
- this.valpha = object.valpha;
3453
- } else if (typeof object === "string") {
3454
- const result = color_string_default.get(object);
3455
- if (result === null) {
3456
- throw new Error("Unable to parse color from string: " + object);
3457
- }
3458
- this.model = result.model;
3459
- channels = color_convert_default[this.model].channels;
3460
- this.color = result.value.slice(0, channels);
3461
- this.valpha = typeof result.value[channels] === "number" ? result.value[channels] : 1;
3462
- } else if (object.length > 0) {
3463
- this.model = model || "rgb";
3464
- channels = color_convert_default[this.model].channels;
3465
- const newArray = Array.prototype.slice.call(object, 0, channels);
3466
- this.color = zeroArray(newArray, channels);
3467
- this.valpha = typeof object[channels] === "number" ? object[channels] : 1;
3468
- } else if (typeof object === "number") {
3469
- this.model = "rgb";
3470
- this.color = [
3471
- object >> 16 & 255,
3472
- object >> 8 & 255,
3473
- object & 255
3474
- ];
3475
- this.valpha = 1;
3476
- } else {
3477
- this.valpha = 1;
3478
- const keys = Object.keys(object);
3479
- if ("alpha" in object) {
3480
- keys.splice(keys.indexOf("alpha"), 1);
3481
- this.valpha = typeof object.alpha === "number" ? object.alpha : 0;
3482
- }
3483
- const hashedKeys = keys.sort().join("");
3484
- if (!(hashedKeys in hashedModelKeys)) {
3485
- throw new Error("Unable to parse color from object: " + JSON.stringify(object));
3486
- }
3487
- this.model = hashedModelKeys[hashedKeys];
3488
- const { labels } = color_convert_default[this.model];
3489
- const color = [];
3490
- for (i = 0;i < labels.length; i++) {
3491
- color.push(object[labels[i]]);
3492
- }
3493
- this.color = zeroArray(color);
3494
- }
3495
- if (limiters[this.model]) {
3496
- channels = color_convert_default[this.model].channels;
3497
- for (i = 0;i < channels; i++) {
3498
- const limit = limiters[this.model][i];
3499
- if (limit) {
3500
- this.color[i] = limit(this.color[i]);
3501
- }
3502
- }
3503
- }
3504
- this.valpha = Math.max(0, Math.min(1, this.valpha));
3505
- if (Object.freeze) {
3506
- Object.freeze(this);
3507
- }
3508
- }
3509
- Color.prototype = {
3510
- toString() {
3511
- return this.string();
3512
- },
3513
- toJSON() {
3514
- return this[this.model]();
3515
- },
3516
- string(places) {
3517
- let self = this.model in color_string_default.to ? this : this.rgb();
3518
- self = self.round(typeof places === "number" ? places : 1);
3519
- const arguments_ = self.valpha === 1 ? self.color : [...self.color, this.valpha];
3520
- return color_string_default.to[self.model](...arguments_);
3521
- },
3522
- percentString(places) {
3523
- const self = this.rgb().round(typeof places === "number" ? places : 1);
3524
- const arguments_ = self.valpha === 1 ? self.color : [...self.color, this.valpha];
3525
- return color_string_default.to.rgb.percent(...arguments_);
3526
- },
3527
- array() {
3528
- return this.valpha === 1 ? [...this.color] : [...this.color, this.valpha];
3529
- },
3530
- object() {
3531
- const result = {};
3532
- const { channels } = color_convert_default[this.model];
3533
- const { labels } = color_convert_default[this.model];
3534
- for (let i = 0;i < channels; i++) {
3535
- result[labels[i]] = this.color[i];
3536
- }
3537
- if (this.valpha !== 1) {
3538
- result.alpha = this.valpha;
3539
- }
3540
- return result;
3541
- },
3542
- unitArray() {
3543
- const rgb = this.rgb().color;
3544
- rgb[0] /= 255;
3545
- rgb[1] /= 255;
3546
- rgb[2] /= 255;
3547
- if (this.valpha !== 1) {
3548
- rgb.push(this.valpha);
3549
- }
3550
- return rgb;
3551
- },
3552
- unitObject() {
3553
- const rgb = this.rgb().object();
3554
- rgb.r /= 255;
3555
- rgb.g /= 255;
3556
- rgb.b /= 255;
3557
- if (this.valpha !== 1) {
3558
- rgb.alpha = this.valpha;
3559
- }
3560
- return rgb;
3561
- },
3562
- round(places) {
3563
- places = Math.max(places || 0, 0);
3564
- return new Color([...this.color.map(roundToPlace(places)), this.valpha], this.model);
3565
- },
3566
- alpha(value) {
3567
- if (value !== undefined) {
3568
- return new Color([...this.color, Math.max(0, Math.min(1, value))], this.model);
3569
- }
3570
- return this.valpha;
3571
- },
3572
- red: getset("rgb", 0, maxfn(255)),
3573
- green: getset("rgb", 1, maxfn(255)),
3574
- blue: getset("rgb", 2, maxfn(255)),
3575
- hue: getset(["hsl", "hsv", "hsl", "hwb", "hcg"], 0, (value) => (value % 360 + 360) % 360),
3576
- saturationl: getset("hsl", 1, maxfn(100)),
3577
- lightness: getset("hsl", 2, maxfn(100)),
3578
- saturationv: getset("hsv", 1, maxfn(100)),
3579
- value: getset("hsv", 2, maxfn(100)),
3580
- chroma: getset("hcg", 1, maxfn(100)),
3581
- gray: getset("hcg", 2, maxfn(100)),
3582
- white: getset("hwb", 1, maxfn(100)),
3583
- wblack: getset("hwb", 2, maxfn(100)),
3584
- cyan: getset("cmyk", 0, maxfn(100)),
3585
- magenta: getset("cmyk", 1, maxfn(100)),
3586
- yellow: getset("cmyk", 2, maxfn(100)),
3587
- black: getset("cmyk", 3, maxfn(100)),
3588
- x: getset("xyz", 0, maxfn(95.047)),
3589
- y: getset("xyz", 1, maxfn(100)),
3590
- z: getset("xyz", 2, maxfn(108.833)),
3591
- l: getset("lab", 0, maxfn(100)),
3592
- a: getset("lab", 1),
3593
- b: getset("lab", 2),
3594
- keyword(value) {
3595
- if (value !== undefined) {
3596
- return new Color(value);
3597
- }
3598
- return color_convert_default[this.model].keyword(this.color);
3599
- },
3600
- hex(value) {
3601
- if (value !== undefined) {
3602
- return new Color(value);
3603
- }
3604
- return color_string_default.to.hex(...this.rgb().round().color);
3605
- },
3606
- hexa(value) {
3607
- if (value !== undefined) {
3608
- return new Color(value);
3609
- }
3610
- const rgbArray = this.rgb().round().color;
3611
- let alphaHex = Math.round(this.valpha * 255).toString(16).toUpperCase();
3612
- if (alphaHex.length === 1) {
3613
- alphaHex = "0" + alphaHex;
3614
- }
3615
- return color_string_default.to.hex(...rgbArray) + alphaHex;
3616
- },
3617
- rgbNumber() {
3618
- const rgb = this.rgb().color;
3619
- return (rgb[0] & 255) << 16 | (rgb[1] & 255) << 8 | rgb[2] & 255;
3620
- },
3621
- luminosity() {
3622
- const rgb = this.rgb().color;
3623
- const lum = [];
3624
- for (const [i, element] of rgb.entries()) {
3625
- const chan = element / 255;
3626
- lum[i] = chan <= 0.04045 ? chan / 12.92 : ((chan + 0.055) / 1.055) ** 2.4;
3627
- }
3628
- return 0.2126 * lum[0] + 0.7152 * lum[1] + 0.0722 * lum[2];
3629
- },
3630
- contrast(color2) {
3631
- const lum1 = this.luminosity();
3632
- const lum2 = color2.luminosity();
3633
- if (lum1 > lum2) {
3634
- return (lum1 + 0.05) / (lum2 + 0.05);
3635
- }
3636
- return (lum2 + 0.05) / (lum1 + 0.05);
3637
- },
3638
- level(color2) {
3639
- const contrastRatio = this.contrast(color2);
3640
- if (contrastRatio >= 7) {
3641
- return "AAA";
3642
- }
3643
- return contrastRatio >= 4.5 ? "AA" : "";
3644
- },
3645
- isDark() {
3646
- const rgb = this.rgb().color;
3647
- const yiq = (rgb[0] * 2126 + rgb[1] * 7152 + rgb[2] * 722) / 1e4;
3648
- return yiq < 128;
3649
- },
3650
- isLight() {
3651
- return !this.isDark();
3652
- },
3653
- negate() {
3654
- const rgb = this.rgb();
3655
- for (let i = 0;i < 3; i++) {
3656
- rgb.color[i] = 255 - rgb.color[i];
3657
- }
3658
- return rgb;
3659
- },
3660
- lighten(ratio) {
3661
- const hsl = this.hsl();
3662
- hsl.color[2] += hsl.color[2] * ratio;
3663
- return hsl;
3664
- },
3665
- darken(ratio) {
3666
- const hsl = this.hsl();
3667
- hsl.color[2] -= hsl.color[2] * ratio;
3668
- return hsl;
3669
- },
3670
- saturate(ratio) {
3671
- const hsl = this.hsl();
3672
- hsl.color[1] += hsl.color[1] * ratio;
3673
- return hsl;
3674
- },
3675
- desaturate(ratio) {
3676
- const hsl = this.hsl();
3677
- hsl.color[1] -= hsl.color[1] * ratio;
3678
- return hsl;
3679
- },
3680
- whiten(ratio) {
3681
- const hwb = this.hwb();
3682
- hwb.color[1] += hwb.color[1] * ratio;
3683
- return hwb;
3684
- },
3685
- blacken(ratio) {
3686
- const hwb = this.hwb();
3687
- hwb.color[2] += hwb.color[2] * ratio;
3688
- return hwb;
3689
- },
3690
- grayscale() {
3691
- const rgb = this.rgb().color;
3692
- const value = rgb[0] * 0.3 + rgb[1] * 0.59 + rgb[2] * 0.11;
3693
- return Color.rgb(value, value, value);
3694
- },
3695
- fade(ratio) {
3696
- return this.alpha(this.valpha - this.valpha * ratio);
3697
- },
3698
- opaquer(ratio) {
3699
- return this.alpha(this.valpha + this.valpha * ratio);
3700
- },
3701
- rotate(degrees) {
3702
- const hsl = this.hsl();
3703
- let hue = hsl.color[0];
3704
- hue = (hue + degrees) % 360;
3705
- hue = hue < 0 ? 360 + hue : hue;
3706
- hsl.color[0] = hue;
3707
- return hsl;
3708
- },
3709
- mix(mixinColor, weight) {
3710
- if (!mixinColor || !mixinColor.rgb) {
3711
- throw new Error('Argument to "mix" was not a Color instance, but rather an instance of ' + typeof mixinColor);
3712
- }
3713
- const color1 = mixinColor.rgb();
3714
- const color2 = this.rgb();
3715
- const p = weight === undefined ? 0.5 : weight;
3716
- const w = 2 * p - 1;
3717
- const a = color1.alpha() - color2.alpha();
3718
- const w1 = ((w * a === -1 ? w : (w + a) / (1 + w * a)) + 1) / 2;
3719
- const w2 = 1 - w1;
3720
- return Color.rgb(w1 * color1.red() + w2 * color2.red(), w1 * color1.green() + w2 * color2.green(), w1 * color1.blue() + w2 * color2.blue(), color1.alpha() * p + color2.alpha() * (1 - p));
3721
- }
3722
- };
3723
- for (const model of Object.keys(color_convert_default)) {
3724
- if (skippedModels.includes(model)) {
3725
- continue;
3726
- }
3727
- const { channels } = color_convert_default[model];
3728
- Color.prototype[model] = function(...arguments_) {
3729
- if (this.model === model) {
3730
- return new Color(this);
3731
- }
3732
- if (arguments_.length > 0) {
3733
- return new Color(arguments_, model);
3734
- }
3735
- return new Color([...assertArray(color_convert_default[this.model][model].raw(this.color)), this.valpha], model);
3736
- };
3737
- Color[model] = function(...arguments_) {
3738
- let color = arguments_[0];
3739
- if (typeof color === "number") {
3740
- color = zeroArray(arguments_, channels);
3741
- }
3742
- return new Color(color, model);
3743
- };
3744
- }
3745
- function roundTo(number, places) {
3746
- return Number(number.toFixed(places));
3747
- }
3748
- function roundToPlace(places) {
3749
- return function(number) {
3750
- return roundTo(number, places);
3751
- };
3752
- }
3753
- function getset(model, channel, modifier) {
3754
- model = Array.isArray(model) ? model : [model];
3755
- for (const m of model) {
3756
- (limiters[m] ||= [])[channel] = modifier;
3757
- }
3758
- model = model[0];
3759
- return function(value) {
3760
- let result;
3761
- if (value !== undefined) {
3762
- if (modifier) {
3763
- value = modifier(value);
3764
- }
3765
- result = this[model]();
3766
- result.color[channel] = value;
3767
- return result;
3768
- }
3769
- result = this[model]().color[channel];
3770
- if (modifier) {
3771
- result = modifier(result);
3772
- }
3773
- return result;
3774
- };
3775
- }
3776
- function maxfn(max) {
3777
- return function(v) {
3778
- return Math.max(0, Math.min(max, v));
3779
- };
3780
- }
3781
- function assertArray(value) {
3782
- return Array.isArray(value) ? value : [value];
3783
- }
3784
- function zeroArray(array, length) {
3785
- for (let i = 0;i < length; i++) {
3786
- if (typeof array[i] !== "number") {
3787
- array[i] = 0;
3788
- }
3789
- }
3790
- return array;
3791
- }
3792
- var index_default = Color;
3793
- });
3794
-
3795
- // node_modules/.bun/@img+colour@1.1.0/node_modules/@img/colour/index.cjs
3796
- var require_colour = __commonJS((exports, module) => {
3797
- module.exports = require_color().default;
3798
- });
3799
-
3800
- // node_modules/.bun/sharp@0.34.5/node_modules/sharp/lib/colour.js
3801
- var require_colour2 = __commonJS((exports, module) => {
3802
- /*!
3803
- Copyright 2013 Lovell Fuller and others.
3804
- SPDX-License-Identifier: Apache-2.0
3805
- */
3806
- var color = require_colour();
3807
- var is = require_is();
3808
- var colourspace = {
3809
- multiband: "multiband",
3810
- "b-w": "b-w",
3811
- bw: "b-w",
3812
- cmyk: "cmyk",
3813
- srgb: "srgb"
3814
- };
3815
- function tint(tint2) {
3816
- this._setBackgroundColourOption("tint", tint2);
3817
- return this;
3818
- }
3819
- function greyscale(greyscale2) {
3820
- this.options.greyscale = is.bool(greyscale2) ? greyscale2 : true;
3821
- return this;
3822
- }
3823
- function grayscale(grayscale2) {
3824
- return this.greyscale(grayscale2);
3825
- }
3826
- function pipelineColourspace(colourspace2) {
3827
- if (!is.string(colourspace2)) {
3828
- throw is.invalidParameterError("colourspace", "string", colourspace2);
3829
- }
3830
- this.options.colourspacePipeline = colourspace2;
3831
- return this;
3832
- }
3833
- function pipelineColorspace(colorspace) {
3834
- return this.pipelineColourspace(colorspace);
3835
- }
3836
- function toColourspace(colourspace2) {
3837
- if (!is.string(colourspace2)) {
3838
- throw is.invalidParameterError("colourspace", "string", colourspace2);
3839
- }
3840
- this.options.colourspace = colourspace2;
3841
- return this;
3842
- }
3843
- function toColorspace(colorspace) {
3844
- return this.toColourspace(colorspace);
3845
- }
3846
- function _getBackgroundColourOption(value) {
3847
- if (is.object(value) || is.string(value) && value.length >= 3 && value.length <= 200) {
3848
- const colour = color(value);
3849
- return [
3850
- colour.red(),
3851
- colour.green(),
3852
- colour.blue(),
3853
- Math.round(colour.alpha() * 255)
3854
- ];
3855
- } else {
3856
- throw is.invalidParameterError("background", "object or string", value);
3857
- }
3858
- }
3859
- function _setBackgroundColourOption(key, value) {
3860
- if (is.defined(value)) {
3861
- this.options[key] = _getBackgroundColourOption(value);
3862
- }
3863
- }
3864
- module.exports = (Sharp) => {
3865
- Object.assign(Sharp.prototype, {
3866
- tint,
3867
- greyscale,
3868
- grayscale,
3869
- pipelineColourspace,
3870
- pipelineColorspace,
3871
- toColourspace,
3872
- toColorspace,
3873
- _getBackgroundColourOption,
3874
- _setBackgroundColourOption
3875
- });
3876
- Sharp.colourspace = colourspace;
3877
- Sharp.colorspace = colourspace;
3878
- };
3879
- });
3880
-
3881
- // node_modules/.bun/sharp@0.34.5/node_modules/sharp/lib/channel.js
3882
- var require_channel = __commonJS((exports, module) => {
3883
- /*!
3884
- Copyright 2013 Lovell Fuller and others.
3885
- SPDX-License-Identifier: Apache-2.0
3886
- */
3887
- var is = require_is();
3888
- var bool = {
3889
- and: "and",
3890
- or: "or",
3891
- eor: "eor"
3892
- };
3893
- function removeAlpha() {
3894
- this.options.removeAlpha = true;
3895
- return this;
3896
- }
3897
- function ensureAlpha(alpha) {
3898
- if (is.defined(alpha)) {
3899
- if (is.number(alpha) && is.inRange(alpha, 0, 1)) {
3900
- this.options.ensureAlpha = alpha;
3901
- } else {
3902
- throw is.invalidParameterError("alpha", "number between 0 and 1", alpha);
3903
- }
3904
- } else {
3905
- this.options.ensureAlpha = 1;
3906
- }
3907
- return this;
3908
- }
3909
- function extractChannel(channel) {
3910
- const channelMap = { red: 0, green: 1, blue: 2, alpha: 3 };
3911
- if (Object.keys(channelMap).includes(channel)) {
3912
- channel = channelMap[channel];
3913
- }
3914
- if (is.integer(channel) && is.inRange(channel, 0, 4)) {
3915
- this.options.extractChannel = channel;
3916
- } else {
3917
- throw is.invalidParameterError("channel", "integer or one of: red, green, blue, alpha", channel);
3918
- }
3919
- return this;
3920
- }
3921
- function joinChannel(images, options) {
3922
- if (Array.isArray(images)) {
3923
- images.forEach(function(image) {
3924
- this.options.joinChannelIn.push(this._createInputDescriptor(image, options));
3925
- }, this);
3926
- } else {
3927
- this.options.joinChannelIn.push(this._createInputDescriptor(images, options));
3928
- }
3929
- return this;
3930
- }
3931
- function bandbool(boolOp) {
3932
- if (is.string(boolOp) && is.inArray(boolOp, ["and", "or", "eor"])) {
3933
- this.options.bandBoolOp = boolOp;
3934
- } else {
3935
- throw is.invalidParameterError("boolOp", "one of: and, or, eor", boolOp);
3936
- }
3937
- return this;
3938
- }
3939
- module.exports = (Sharp) => {
3940
- Object.assign(Sharp.prototype, {
3941
- removeAlpha,
3942
- ensureAlpha,
3943
- extractChannel,
3944
- joinChannel,
3945
- bandbool
3946
- });
3947
- Sharp.bool = bool;
3948
- };
3949
- });
3950
-
3951
- // node_modules/.bun/sharp@0.34.5/node_modules/sharp/lib/output.js
3952
- var require_output = __commonJS((exports, module) => {
3953
- /*!
3954
- Copyright 2013 Lovell Fuller and others.
3955
- SPDX-License-Identifier: Apache-2.0
3956
- */
3957
- var path = __require("path");
3958
- var is = require_is();
3959
- var sharp = require_sharp();
3960
- var formats = new Map([
3961
- ["heic", "heif"],
3962
- ["heif", "heif"],
3963
- ["avif", "avif"],
3964
- ["jpeg", "jpeg"],
3965
- ["jpg", "jpeg"],
3966
- ["jpe", "jpeg"],
3967
- ["tile", "tile"],
3968
- ["dz", "tile"],
3969
- ["png", "png"],
3970
- ["raw", "raw"],
3971
- ["tiff", "tiff"],
3972
- ["tif", "tiff"],
3973
- ["webp", "webp"],
3974
- ["gif", "gif"],
3975
- ["jp2", "jp2"],
3976
- ["jpx", "jp2"],
3977
- ["j2k", "jp2"],
3978
- ["j2c", "jp2"],
3979
- ["jxl", "jxl"]
3980
- ]);
3981
- var jp2Regex = /\.(jp[2x]|j2[kc])$/i;
3982
- var errJp2Save = () => new Error("JP2 output requires libvips with support for OpenJPEG");
3983
- var bitdepthFromColourCount = (colours) => 1 << 31 - Math.clz32(Math.ceil(Math.log2(colours)));
3984
- function toFile(fileOut, callback) {
3985
- let err;
3986
- if (!is.string(fileOut)) {
3987
- err = new Error("Missing output file path");
3988
- } else if (is.string(this.options.input.file) && path.resolve(this.options.input.file) === path.resolve(fileOut)) {
3989
- err = new Error("Cannot use same file for input and output");
3990
- } else if (jp2Regex.test(path.extname(fileOut)) && !this.constructor.format.jp2k.output.file) {
3991
- err = errJp2Save();
3992
- }
3993
- if (err) {
3994
- if (is.fn(callback)) {
3995
- callback(err);
3996
- } else {
3997
- return Promise.reject(err);
3998
- }
3999
- } else {
4000
- this.options.fileOut = fileOut;
4001
- const stack = Error();
4002
- return this._pipeline(callback, stack);
4003
- }
4004
- return this;
4005
- }
4006
- function toBuffer(options, callback) {
4007
- if (is.object(options)) {
4008
- this._setBooleanOption("resolveWithObject", options.resolveWithObject);
4009
- } else if (this.options.resolveWithObject) {
4010
- this.options.resolveWithObject = false;
4011
- }
4012
- this.options.fileOut = "";
4013
- const stack = Error();
4014
- return this._pipeline(is.fn(options) ? options : callback, stack);
4015
- }
4016
- function keepExif() {
4017
- this.options.keepMetadata |= 1;
4018
- return this;
4019
- }
4020
- function withExif(exif) {
4021
- if (is.object(exif)) {
4022
- for (const [ifd, entries] of Object.entries(exif)) {
4023
- if (is.object(entries)) {
4024
- for (const [k, v] of Object.entries(entries)) {
4025
- if (is.string(v)) {
4026
- this.options.withExif[`exif-${ifd.toLowerCase()}-${k}`] = v;
4027
- } else {
4028
- throw is.invalidParameterError(`${ifd}.${k}`, "string", v);
4029
- }
4030
- }
4031
- } else {
4032
- throw is.invalidParameterError(ifd, "object", entries);
4033
- }
4034
- }
4035
- } else {
4036
- throw is.invalidParameterError("exif", "object", exif);
4037
- }
4038
- this.options.withExifMerge = false;
4039
- return this.keepExif();
4040
- }
4041
- function withExifMerge(exif) {
4042
- this.withExif(exif);
4043
- this.options.withExifMerge = true;
4044
- return this;
4045
- }
4046
- function keepIccProfile() {
4047
- this.options.keepMetadata |= 8;
4048
- return this;
4049
- }
4050
- function withIccProfile(icc, options) {
4051
- if (is.string(icc)) {
4052
- this.options.withIccProfile = icc;
4053
- } else {
4054
- throw is.invalidParameterError("icc", "string", icc);
4055
- }
4056
- this.keepIccProfile();
4057
- if (is.object(options)) {
4058
- if (is.defined(options.attach)) {
4059
- if (is.bool(options.attach)) {
4060
- if (!options.attach) {
4061
- this.options.keepMetadata &= ~8;
4062
- }
4063
- } else {
4064
- throw is.invalidParameterError("attach", "boolean", options.attach);
4065
- }
4066
- }
4067
- }
4068
- return this;
4069
- }
4070
- function keepXmp() {
4071
- this.options.keepMetadata |= 2;
4072
- return this;
4073
- }
4074
- function withXmp(xmp) {
4075
- if (is.string(xmp) && xmp.length > 0) {
4076
- this.options.withXmp = xmp;
4077
- this.options.keepMetadata |= 2;
4078
- } else {
4079
- throw is.invalidParameterError("xmp", "non-empty string", xmp);
4080
- }
4081
- return this;
4082
- }
4083
- function keepMetadata() {
4084
- this.options.keepMetadata = 31;
4085
- return this;
4086
- }
4087
- function withMetadata(options) {
4088
- this.keepMetadata();
4089
- this.withIccProfile("srgb");
4090
- if (is.object(options)) {
4091
- if (is.defined(options.orientation)) {
4092
- if (is.integer(options.orientation) && is.inRange(options.orientation, 1, 8)) {
4093
- this.options.withMetadataOrientation = options.orientation;
4094
- } else {
4095
- throw is.invalidParameterError("orientation", "integer between 1 and 8", options.orientation);
4096
- }
4097
- }
4098
- if (is.defined(options.density)) {
4099
- if (is.number(options.density) && options.density > 0) {
4100
- this.options.withMetadataDensity = options.density;
4101
- } else {
4102
- throw is.invalidParameterError("density", "positive number", options.density);
4103
- }
4104
- }
4105
- if (is.defined(options.icc)) {
4106
- this.withIccProfile(options.icc);
4107
- }
4108
- if (is.defined(options.exif)) {
4109
- this.withExifMerge(options.exif);
4110
- }
4111
- }
4112
- return this;
4113
- }
4114
- function toFormat(format, options) {
4115
- const actualFormat = formats.get((is.object(format) && is.string(format.id) ? format.id : format).toLowerCase());
4116
- if (!actualFormat) {
4117
- throw is.invalidParameterError("format", `one of: ${[...formats.keys()].join(", ")}`, format);
4118
- }
4119
- return this[actualFormat](options);
4120
- }
4121
- function jpeg(options) {
4122
- if (is.object(options)) {
4123
- if (is.defined(options.quality)) {
4124
- if (is.integer(options.quality) && is.inRange(options.quality, 1, 100)) {
4125
- this.options.jpegQuality = options.quality;
4126
- } else {
4127
- throw is.invalidParameterError("quality", "integer between 1 and 100", options.quality);
4128
- }
4129
- }
4130
- if (is.defined(options.progressive)) {
4131
- this._setBooleanOption("jpegProgressive", options.progressive);
4132
- }
4133
- if (is.defined(options.chromaSubsampling)) {
4134
- if (is.string(options.chromaSubsampling) && is.inArray(options.chromaSubsampling, ["4:2:0", "4:4:4"])) {
4135
- this.options.jpegChromaSubsampling = options.chromaSubsampling;
4136
- } else {
4137
- throw is.invalidParameterError("chromaSubsampling", "one of: 4:2:0, 4:4:4", options.chromaSubsampling);
4138
- }
4139
- }
4140
- const optimiseCoding = is.bool(options.optimizeCoding) ? options.optimizeCoding : options.optimiseCoding;
4141
- if (is.defined(optimiseCoding)) {
4142
- this._setBooleanOption("jpegOptimiseCoding", optimiseCoding);
4143
- }
4144
- if (is.defined(options.mozjpeg)) {
4145
- if (is.bool(options.mozjpeg)) {
4146
- if (options.mozjpeg) {
4147
- this.options.jpegTrellisQuantisation = true;
4148
- this.options.jpegOvershootDeringing = true;
4149
- this.options.jpegOptimiseScans = true;
4150
- this.options.jpegProgressive = true;
4151
- this.options.jpegQuantisationTable = 3;
4152
- }
4153
- } else {
4154
- throw is.invalidParameterError("mozjpeg", "boolean", options.mozjpeg);
4155
- }
4156
- }
4157
- const trellisQuantisation = is.bool(options.trellisQuantization) ? options.trellisQuantization : options.trellisQuantisation;
4158
- if (is.defined(trellisQuantisation)) {
4159
- this._setBooleanOption("jpegTrellisQuantisation", trellisQuantisation);
4160
- }
4161
- if (is.defined(options.overshootDeringing)) {
4162
- this._setBooleanOption("jpegOvershootDeringing", options.overshootDeringing);
4163
- }
4164
- const optimiseScans = is.bool(options.optimizeScans) ? options.optimizeScans : options.optimiseScans;
4165
- if (is.defined(optimiseScans)) {
4166
- this._setBooleanOption("jpegOptimiseScans", optimiseScans);
4167
- if (optimiseScans) {
4168
- this.options.jpegProgressive = true;
4169
- }
4170
- }
4171
- const quantisationTable = is.number(options.quantizationTable) ? options.quantizationTable : options.quantisationTable;
4172
- if (is.defined(quantisationTable)) {
4173
- if (is.integer(quantisationTable) && is.inRange(quantisationTable, 0, 8)) {
4174
- this.options.jpegQuantisationTable = quantisationTable;
4175
- } else {
4176
- throw is.invalidParameterError("quantisationTable", "integer between 0 and 8", quantisationTable);
4177
- }
4178
- }
4179
- }
4180
- return this._updateFormatOut("jpeg", options);
4181
- }
4182
- function png(options) {
4183
- if (is.object(options)) {
4184
- if (is.defined(options.progressive)) {
4185
- this._setBooleanOption("pngProgressive", options.progressive);
4186
- }
4187
- if (is.defined(options.compressionLevel)) {
4188
- if (is.integer(options.compressionLevel) && is.inRange(options.compressionLevel, 0, 9)) {
4189
- this.options.pngCompressionLevel = options.compressionLevel;
4190
- } else {
4191
- throw is.invalidParameterError("compressionLevel", "integer between 0 and 9", options.compressionLevel);
4192
- }
4193
- }
4194
- if (is.defined(options.adaptiveFiltering)) {
4195
- this._setBooleanOption("pngAdaptiveFiltering", options.adaptiveFiltering);
4196
- }
4197
- const colours = options.colours || options.colors;
4198
- if (is.defined(colours)) {
4199
- if (is.integer(colours) && is.inRange(colours, 2, 256)) {
4200
- this.options.pngBitdepth = bitdepthFromColourCount(colours);
4201
- } else {
4202
- throw is.invalidParameterError("colours", "integer between 2 and 256", colours);
4203
- }
4204
- }
4205
- if (is.defined(options.palette)) {
4206
- this._setBooleanOption("pngPalette", options.palette);
4207
- } else if ([options.quality, options.effort, options.colours, options.colors, options.dither].some(is.defined)) {
4208
- this._setBooleanOption("pngPalette", true);
4209
- }
4210
- if (this.options.pngPalette) {
4211
- if (is.defined(options.quality)) {
4212
- if (is.integer(options.quality) && is.inRange(options.quality, 0, 100)) {
4213
- this.options.pngQuality = options.quality;
4214
- } else {
4215
- throw is.invalidParameterError("quality", "integer between 0 and 100", options.quality);
4216
- }
4217
- }
4218
- if (is.defined(options.effort)) {
4219
- if (is.integer(options.effort) && is.inRange(options.effort, 1, 10)) {
4220
- this.options.pngEffort = options.effort;
4221
- } else {
4222
- throw is.invalidParameterError("effort", "integer between 1 and 10", options.effort);
4223
- }
4224
- }
4225
- if (is.defined(options.dither)) {
4226
- if (is.number(options.dither) && is.inRange(options.dither, 0, 1)) {
4227
- this.options.pngDither = options.dither;
4228
- } else {
4229
- throw is.invalidParameterError("dither", "number between 0.0 and 1.0", options.dither);
4230
- }
4231
- }
4232
- }
4233
- }
4234
- return this._updateFormatOut("png", options);
4235
- }
4236
- function webp(options) {
4237
- if (is.object(options)) {
4238
- if (is.defined(options.quality)) {
4239
- if (is.integer(options.quality) && is.inRange(options.quality, 1, 100)) {
4240
- this.options.webpQuality = options.quality;
4241
- } else {
4242
- throw is.invalidParameterError("quality", "integer between 1 and 100", options.quality);
4243
- }
4244
- }
4245
- if (is.defined(options.alphaQuality)) {
4246
- if (is.integer(options.alphaQuality) && is.inRange(options.alphaQuality, 0, 100)) {
4247
- this.options.webpAlphaQuality = options.alphaQuality;
4248
- } else {
4249
- throw is.invalidParameterError("alphaQuality", "integer between 0 and 100", options.alphaQuality);
4250
- }
4251
- }
4252
- if (is.defined(options.lossless)) {
4253
- this._setBooleanOption("webpLossless", options.lossless);
4254
- }
4255
- if (is.defined(options.nearLossless)) {
4256
- this._setBooleanOption("webpNearLossless", options.nearLossless);
4257
- }
4258
- if (is.defined(options.smartSubsample)) {
4259
- this._setBooleanOption("webpSmartSubsample", options.smartSubsample);
4260
- }
4261
- if (is.defined(options.smartDeblock)) {
4262
- this._setBooleanOption("webpSmartDeblock", options.smartDeblock);
4263
- }
4264
- if (is.defined(options.preset)) {
4265
- if (is.string(options.preset) && is.inArray(options.preset, ["default", "photo", "picture", "drawing", "icon", "text"])) {
4266
- this.options.webpPreset = options.preset;
4267
- } else {
4268
- throw is.invalidParameterError("preset", "one of: default, photo, picture, drawing, icon, text", options.preset);
4269
- }
4270
- }
4271
- if (is.defined(options.effort)) {
4272
- if (is.integer(options.effort) && is.inRange(options.effort, 0, 6)) {
4273
- this.options.webpEffort = options.effort;
4274
- } else {
4275
- throw is.invalidParameterError("effort", "integer between 0 and 6", options.effort);
4276
- }
4277
- }
4278
- if (is.defined(options.minSize)) {
4279
- this._setBooleanOption("webpMinSize", options.minSize);
4280
- }
4281
- if (is.defined(options.mixed)) {
4282
- this._setBooleanOption("webpMixed", options.mixed);
4283
- }
4284
- }
4285
- trySetAnimationOptions(options, this.options);
4286
- return this._updateFormatOut("webp", options);
4287
- }
4288
- function gif(options) {
4289
- if (is.object(options)) {
4290
- if (is.defined(options.reuse)) {
4291
- this._setBooleanOption("gifReuse", options.reuse);
4292
- }
4293
- if (is.defined(options.progressive)) {
4294
- this._setBooleanOption("gifProgressive", options.progressive);
4295
- }
4296
- const colours = options.colours || options.colors;
4297
- if (is.defined(colours)) {
4298
- if (is.integer(colours) && is.inRange(colours, 2, 256)) {
4299
- this.options.gifBitdepth = bitdepthFromColourCount(colours);
4300
- } else {
4301
- throw is.invalidParameterError("colours", "integer between 2 and 256", colours);
4302
- }
4303
- }
4304
- if (is.defined(options.effort)) {
4305
- if (is.number(options.effort) && is.inRange(options.effort, 1, 10)) {
4306
- this.options.gifEffort = options.effort;
4307
- } else {
4308
- throw is.invalidParameterError("effort", "integer between 1 and 10", options.effort);
4309
- }
4310
- }
4311
- if (is.defined(options.dither)) {
4312
- if (is.number(options.dither) && is.inRange(options.dither, 0, 1)) {
4313
- this.options.gifDither = options.dither;
4314
- } else {
4315
- throw is.invalidParameterError("dither", "number between 0.0 and 1.0", options.dither);
4316
- }
4317
- }
4318
- if (is.defined(options.interFrameMaxError)) {
4319
- if (is.number(options.interFrameMaxError) && is.inRange(options.interFrameMaxError, 0, 32)) {
4320
- this.options.gifInterFrameMaxError = options.interFrameMaxError;
4321
- } else {
4322
- throw is.invalidParameterError("interFrameMaxError", "number between 0.0 and 32.0", options.interFrameMaxError);
4323
- }
4324
- }
4325
- if (is.defined(options.interPaletteMaxError)) {
4326
- if (is.number(options.interPaletteMaxError) && is.inRange(options.interPaletteMaxError, 0, 256)) {
4327
- this.options.gifInterPaletteMaxError = options.interPaletteMaxError;
4328
- } else {
4329
- throw is.invalidParameterError("interPaletteMaxError", "number between 0.0 and 256.0", options.interPaletteMaxError);
4330
- }
4331
- }
4332
- if (is.defined(options.keepDuplicateFrames)) {
4333
- if (is.bool(options.keepDuplicateFrames)) {
4334
- this._setBooleanOption("gifKeepDuplicateFrames", options.keepDuplicateFrames);
4335
- } else {
4336
- throw is.invalidParameterError("keepDuplicateFrames", "boolean", options.keepDuplicateFrames);
4337
- }
4338
- }
4339
- }
4340
- trySetAnimationOptions(options, this.options);
4341
- return this._updateFormatOut("gif", options);
4342
- }
4343
- function jp2(options) {
4344
- if (!this.constructor.format.jp2k.output.buffer) {
4345
- throw errJp2Save();
4346
- }
4347
- if (is.object(options)) {
4348
- if (is.defined(options.quality)) {
4349
- if (is.integer(options.quality) && is.inRange(options.quality, 1, 100)) {
4350
- this.options.jp2Quality = options.quality;
4351
- } else {
4352
- throw is.invalidParameterError("quality", "integer between 1 and 100", options.quality);
4353
- }
4354
- }
4355
- if (is.defined(options.lossless)) {
4356
- if (is.bool(options.lossless)) {
4357
- this.options.jp2Lossless = options.lossless;
4358
- } else {
4359
- throw is.invalidParameterError("lossless", "boolean", options.lossless);
4360
- }
4361
- }
4362
- if (is.defined(options.tileWidth)) {
4363
- if (is.integer(options.tileWidth) && is.inRange(options.tileWidth, 1, 32768)) {
4364
- this.options.jp2TileWidth = options.tileWidth;
4365
- } else {
4366
- throw is.invalidParameterError("tileWidth", "integer between 1 and 32768", options.tileWidth);
4367
- }
4368
- }
4369
- if (is.defined(options.tileHeight)) {
4370
- if (is.integer(options.tileHeight) && is.inRange(options.tileHeight, 1, 32768)) {
4371
- this.options.jp2TileHeight = options.tileHeight;
4372
- } else {
4373
- throw is.invalidParameterError("tileHeight", "integer between 1 and 32768", options.tileHeight);
4374
- }
4375
- }
4376
- if (is.defined(options.chromaSubsampling)) {
4377
- if (is.string(options.chromaSubsampling) && is.inArray(options.chromaSubsampling, ["4:2:0", "4:4:4"])) {
4378
- this.options.jp2ChromaSubsampling = options.chromaSubsampling;
4379
- } else {
4380
- throw is.invalidParameterError("chromaSubsampling", "one of: 4:2:0, 4:4:4", options.chromaSubsampling);
4381
- }
4382
- }
4383
- }
4384
- return this._updateFormatOut("jp2", options);
4385
- }
4386
- function trySetAnimationOptions(source, target) {
4387
- if (is.object(source) && is.defined(source.loop)) {
4388
- if (is.integer(source.loop) && is.inRange(source.loop, 0, 65535)) {
4389
- target.loop = source.loop;
4390
- } else {
4391
- throw is.invalidParameterError("loop", "integer between 0 and 65535", source.loop);
4392
- }
4393
- }
4394
- if (is.object(source) && is.defined(source.delay)) {
4395
- if (is.integer(source.delay) && is.inRange(source.delay, 0, 65535)) {
4396
- target.delay = [source.delay];
4397
- } else if (Array.isArray(source.delay) && source.delay.every(is.integer) && source.delay.every((v) => is.inRange(v, 0, 65535))) {
4398
- target.delay = source.delay;
4399
- } else {
4400
- throw is.invalidParameterError("delay", "integer or an array of integers between 0 and 65535", source.delay);
4401
- }
4402
- }
4403
- }
4404
- function tiff(options) {
4405
- if (is.object(options)) {
4406
- if (is.defined(options.quality)) {
4407
- if (is.integer(options.quality) && is.inRange(options.quality, 1, 100)) {
4408
- this.options.tiffQuality = options.quality;
4409
- } else {
4410
- throw is.invalidParameterError("quality", "integer between 1 and 100", options.quality);
4411
- }
4412
- }
4413
- if (is.defined(options.bitdepth)) {
4414
- if (is.integer(options.bitdepth) && is.inArray(options.bitdepth, [1, 2, 4, 8])) {
4415
- this.options.tiffBitdepth = options.bitdepth;
4416
- } else {
4417
- throw is.invalidParameterError("bitdepth", "1, 2, 4 or 8", options.bitdepth);
4418
- }
4419
- }
4420
- if (is.defined(options.tile)) {
4421
- this._setBooleanOption("tiffTile", options.tile);
4422
- }
4423
- if (is.defined(options.tileWidth)) {
4424
- if (is.integer(options.tileWidth) && options.tileWidth > 0) {
4425
- this.options.tiffTileWidth = options.tileWidth;
4426
- } else {
4427
- throw is.invalidParameterError("tileWidth", "integer greater than zero", options.tileWidth);
4428
- }
4429
- }
4430
- if (is.defined(options.tileHeight)) {
4431
- if (is.integer(options.tileHeight) && options.tileHeight > 0) {
4432
- this.options.tiffTileHeight = options.tileHeight;
4433
- } else {
4434
- throw is.invalidParameterError("tileHeight", "integer greater than zero", options.tileHeight);
4435
- }
4436
- }
4437
- if (is.defined(options.miniswhite)) {
4438
- this._setBooleanOption("tiffMiniswhite", options.miniswhite);
4439
- }
4440
- if (is.defined(options.pyramid)) {
4441
- this._setBooleanOption("tiffPyramid", options.pyramid);
4442
- }
4443
- if (is.defined(options.xres)) {
4444
- if (is.number(options.xres) && options.xres > 0) {
4445
- this.options.tiffXres = options.xres;
4446
- } else {
4447
- throw is.invalidParameterError("xres", "number greater than zero", options.xres);
4448
- }
4449
- }
4450
- if (is.defined(options.yres)) {
4451
- if (is.number(options.yres) && options.yres > 0) {
4452
- this.options.tiffYres = options.yres;
4453
- } else {
4454
- throw is.invalidParameterError("yres", "number greater than zero", options.yres);
4455
- }
4456
- }
4457
- if (is.defined(options.compression)) {
4458
- if (is.string(options.compression) && is.inArray(options.compression, ["none", "jpeg", "deflate", "packbits", "ccittfax4", "lzw", "webp", "zstd", "jp2k"])) {
4459
- this.options.tiffCompression = options.compression;
4460
- } else {
4461
- throw is.invalidParameterError("compression", "one of: none, jpeg, deflate, packbits, ccittfax4, lzw, webp, zstd, jp2k", options.compression);
4462
- }
4463
- }
4464
- if (is.defined(options.bigtiff)) {
4465
- this._setBooleanOption("tiffBigtiff", options.bigtiff);
4466
- }
4467
- if (is.defined(options.predictor)) {
4468
- if (is.string(options.predictor) && is.inArray(options.predictor, ["none", "horizontal", "float"])) {
4469
- this.options.tiffPredictor = options.predictor;
4470
- } else {
4471
- throw is.invalidParameterError("predictor", "one of: none, horizontal, float", options.predictor);
4472
- }
4473
- }
4474
- if (is.defined(options.resolutionUnit)) {
4475
- if (is.string(options.resolutionUnit) && is.inArray(options.resolutionUnit, ["inch", "cm"])) {
4476
- this.options.tiffResolutionUnit = options.resolutionUnit;
4477
- } else {
4478
- throw is.invalidParameterError("resolutionUnit", "one of: inch, cm", options.resolutionUnit);
4479
- }
4480
- }
4481
- }
4482
- return this._updateFormatOut("tiff", options);
4483
- }
4484
- function avif(options) {
4485
- return this.heif({ ...options, compression: "av1" });
4486
- }
4487
- function heif(options) {
4488
- if (is.object(options)) {
4489
- if (is.string(options.compression) && is.inArray(options.compression, ["av1", "hevc"])) {
4490
- this.options.heifCompression = options.compression;
4491
- } else {
4492
- throw is.invalidParameterError("compression", "one of: av1, hevc", options.compression);
4493
- }
4494
- if (is.defined(options.quality)) {
4495
- if (is.integer(options.quality) && is.inRange(options.quality, 1, 100)) {
4496
- this.options.heifQuality = options.quality;
4497
- } else {
4498
- throw is.invalidParameterError("quality", "integer between 1 and 100", options.quality);
4499
- }
4500
- }
4501
- if (is.defined(options.lossless)) {
4502
- if (is.bool(options.lossless)) {
4503
- this.options.heifLossless = options.lossless;
4504
- } else {
4505
- throw is.invalidParameterError("lossless", "boolean", options.lossless);
4506
- }
4507
- }
4508
- if (is.defined(options.effort)) {
4509
- if (is.integer(options.effort) && is.inRange(options.effort, 0, 9)) {
4510
- this.options.heifEffort = options.effort;
4511
- } else {
4512
- throw is.invalidParameterError("effort", "integer between 0 and 9", options.effort);
4513
- }
4514
- }
4515
- if (is.defined(options.chromaSubsampling)) {
4516
- if (is.string(options.chromaSubsampling) && is.inArray(options.chromaSubsampling, ["4:2:0", "4:4:4"])) {
4517
- this.options.heifChromaSubsampling = options.chromaSubsampling;
4518
- } else {
4519
- throw is.invalidParameterError("chromaSubsampling", "one of: 4:2:0, 4:4:4", options.chromaSubsampling);
4520
- }
4521
- }
4522
- if (is.defined(options.bitdepth)) {
4523
- if (is.integer(options.bitdepth) && is.inArray(options.bitdepth, [8, 10, 12])) {
4524
- if (options.bitdepth !== 8 && this.constructor.versions.heif) {
4525
- throw is.invalidParameterError("bitdepth when using prebuilt binaries", 8, options.bitdepth);
4526
- }
4527
- this.options.heifBitdepth = options.bitdepth;
4528
- } else {
4529
- throw is.invalidParameterError("bitdepth", "8, 10 or 12", options.bitdepth);
4530
- }
4531
- }
4532
- } else {
4533
- throw is.invalidParameterError("options", "Object", options);
4534
- }
4535
- return this._updateFormatOut("heif", options);
4536
- }
4537
- function jxl(options) {
4538
- if (is.object(options)) {
4539
- if (is.defined(options.quality)) {
4540
- if (is.integer(options.quality) && is.inRange(options.quality, 1, 100)) {
4541
- this.options.jxlDistance = options.quality >= 30 ? 0.1 + (100 - options.quality) * 0.09 : 53 / 3000 * options.quality * options.quality - 23 / 20 * options.quality + 25;
4542
- } else {
4543
- throw is.invalidParameterError("quality", "integer between 1 and 100", options.quality);
4544
- }
4545
- } else if (is.defined(options.distance)) {
4546
- if (is.number(options.distance) && is.inRange(options.distance, 0, 15)) {
4547
- this.options.jxlDistance = options.distance;
4548
- } else {
4549
- throw is.invalidParameterError("distance", "number between 0.0 and 15.0", options.distance);
4550
- }
4551
- }
4552
- if (is.defined(options.decodingTier)) {
4553
- if (is.integer(options.decodingTier) && is.inRange(options.decodingTier, 0, 4)) {
4554
- this.options.jxlDecodingTier = options.decodingTier;
4555
- } else {
4556
- throw is.invalidParameterError("decodingTier", "integer between 0 and 4", options.decodingTier);
4557
- }
4558
- }
4559
- if (is.defined(options.lossless)) {
4560
- if (is.bool(options.lossless)) {
4561
- this.options.jxlLossless = options.lossless;
4562
- } else {
4563
- throw is.invalidParameterError("lossless", "boolean", options.lossless);
4564
- }
4565
- }
4566
- if (is.defined(options.effort)) {
4567
- if (is.integer(options.effort) && is.inRange(options.effort, 1, 9)) {
4568
- this.options.jxlEffort = options.effort;
4569
- } else {
4570
- throw is.invalidParameterError("effort", "integer between 1 and 9", options.effort);
4571
- }
4572
- }
4573
- }
4574
- trySetAnimationOptions(options, this.options);
4575
- return this._updateFormatOut("jxl", options);
4576
- }
4577
- function raw(options) {
4578
- if (is.object(options)) {
4579
- if (is.defined(options.depth)) {
4580
- if (is.string(options.depth) && is.inArray(options.depth, ["char", "uchar", "short", "ushort", "int", "uint", "float", "complex", "double", "dpcomplex"])) {
4581
- this.options.rawDepth = options.depth;
4582
- } else {
4583
- throw is.invalidParameterError("depth", "one of: char, uchar, short, ushort, int, uint, float, complex, double, dpcomplex", options.depth);
4584
- }
4585
- }
4586
- }
4587
- return this._updateFormatOut("raw");
4588
- }
4589
- function tile(options) {
4590
- if (is.object(options)) {
4591
- if (is.defined(options.size)) {
4592
- if (is.integer(options.size) && is.inRange(options.size, 1, 8192)) {
4593
- this.options.tileSize = options.size;
4594
- } else {
4595
- throw is.invalidParameterError("size", "integer between 1 and 8192", options.size);
4596
- }
4597
- }
4598
- if (is.defined(options.overlap)) {
4599
- if (is.integer(options.overlap) && is.inRange(options.overlap, 0, 8192)) {
4600
- if (options.overlap > this.options.tileSize) {
4601
- throw is.invalidParameterError("overlap", `<= size (${this.options.tileSize})`, options.overlap);
4602
- }
4603
- this.options.tileOverlap = options.overlap;
4604
- } else {
4605
- throw is.invalidParameterError("overlap", "integer between 0 and 8192", options.overlap);
4606
- }
4607
- }
4608
- if (is.defined(options.container)) {
4609
- if (is.string(options.container) && is.inArray(options.container, ["fs", "zip"])) {
4610
- this.options.tileContainer = options.container;
4611
- } else {
4612
- throw is.invalidParameterError("container", "one of: fs, zip", options.container);
4613
- }
4614
- }
4615
- if (is.defined(options.layout)) {
4616
- if (is.string(options.layout) && is.inArray(options.layout, ["dz", "google", "iiif", "iiif3", "zoomify"])) {
4617
- this.options.tileLayout = options.layout;
4618
- } else {
4619
- throw is.invalidParameterError("layout", "one of: dz, google, iiif, iiif3, zoomify", options.layout);
4620
- }
4621
- }
4622
- if (is.defined(options.angle)) {
4623
- if (is.integer(options.angle) && !(options.angle % 90)) {
4624
- this.options.tileAngle = options.angle;
4625
- } else {
4626
- throw is.invalidParameterError("angle", "positive/negative multiple of 90", options.angle);
4627
- }
4628
- }
4629
- this._setBackgroundColourOption("tileBackground", options.background);
4630
- if (is.defined(options.depth)) {
4631
- if (is.string(options.depth) && is.inArray(options.depth, ["onepixel", "onetile", "one"])) {
4632
- this.options.tileDepth = options.depth;
4633
- } else {
4634
- throw is.invalidParameterError("depth", "one of: onepixel, onetile, one", options.depth);
4635
- }
4636
- }
4637
- if (is.defined(options.skipBlanks)) {
4638
- if (is.integer(options.skipBlanks) && is.inRange(options.skipBlanks, -1, 65535)) {
4639
- this.options.tileSkipBlanks = options.skipBlanks;
4640
- } else {
4641
- throw is.invalidParameterError("skipBlanks", "integer between -1 and 255/65535", options.skipBlanks);
4642
- }
4643
- } else if (is.defined(options.layout) && options.layout === "google") {
4644
- this.options.tileSkipBlanks = 5;
4645
- }
4646
- const centre = is.bool(options.center) ? options.center : options.centre;
4647
- if (is.defined(centre)) {
4648
- this._setBooleanOption("tileCentre", centre);
4649
- }
4650
- if (is.defined(options.id)) {
4651
- if (is.string(options.id)) {
4652
- this.options.tileId = options.id;
4653
- } else {
4654
- throw is.invalidParameterError("id", "string", options.id);
4655
- }
4656
- }
4657
- if (is.defined(options.basename)) {
4658
- if (is.string(options.basename)) {
4659
- this.options.tileBasename = options.basename;
4660
- } else {
4661
- throw is.invalidParameterError("basename", "string", options.basename);
4662
- }
4663
- }
4664
- }
4665
- if (is.inArray(this.options.formatOut, ["jpeg", "png", "webp"])) {
4666
- this.options.tileFormat = this.options.formatOut;
4667
- } else if (this.options.formatOut !== "input") {
4668
- throw is.invalidParameterError("format", "one of: jpeg, png, webp", this.options.formatOut);
4669
- }
4670
- return this._updateFormatOut("dz");
4671
- }
4672
- function timeout(options) {
4673
- if (!is.plainObject(options)) {
4674
- throw is.invalidParameterError("options", "object", options);
4675
- }
4676
- if (is.integer(options.seconds) && is.inRange(options.seconds, 0, 3600)) {
4677
- this.options.timeoutSeconds = options.seconds;
4678
- } else {
4679
- throw is.invalidParameterError("seconds", "integer between 0 and 3600", options.seconds);
4680
- }
4681
- return this;
4682
- }
4683
- function _updateFormatOut(formatOut, options) {
4684
- if (!(is.object(options) && options.force === false)) {
4685
- this.options.formatOut = formatOut;
4686
- }
4687
- return this;
4688
- }
4689
- function _setBooleanOption(key, val) {
4690
- if (is.bool(val)) {
4691
- this.options[key] = val;
4692
- } else {
4693
- throw is.invalidParameterError(key, "boolean", val);
4694
- }
4695
- }
4696
- function _read() {
4697
- if (!this.options.streamOut) {
4698
- this.options.streamOut = true;
4699
- const stack = Error();
4700
- this._pipeline(undefined, stack);
4701
- }
4702
- }
4703
- function _pipeline(callback, stack) {
4704
- if (typeof callback === "function") {
4705
- if (this._isStreamInput()) {
4706
- this.on("finish", () => {
4707
- this._flattenBufferIn();
4708
- sharp.pipeline(this.options, (err, data, info) => {
4709
- if (err) {
4710
- callback(is.nativeError(err, stack));
4711
- } else {
4712
- callback(null, data, info);
4713
- }
4714
- });
4715
- });
4716
- } else {
4717
- sharp.pipeline(this.options, (err, data, info) => {
4718
- if (err) {
4719
- callback(is.nativeError(err, stack));
4720
- } else {
4721
- callback(null, data, info);
4722
- }
4723
- });
4724
- }
4725
- return this;
4726
- } else if (this.options.streamOut) {
4727
- if (this._isStreamInput()) {
4728
- this.once("finish", () => {
4729
- this._flattenBufferIn();
4730
- sharp.pipeline(this.options, (err, data, info) => {
4731
- if (err) {
4732
- this.emit("error", is.nativeError(err, stack));
4733
- } else {
4734
- this.emit("info", info);
4735
- this.push(data);
4736
- }
4737
- this.push(null);
4738
- this.on("end", () => this.emit("close"));
4739
- });
4740
- });
4741
- if (this.streamInFinished) {
4742
- this.emit("finish");
4743
- }
4744
- } else {
4745
- sharp.pipeline(this.options, (err, data, info) => {
4746
- if (err) {
4747
- this.emit("error", is.nativeError(err, stack));
4748
- } else {
4749
- this.emit("info", info);
4750
- this.push(data);
4751
- }
4752
- this.push(null);
4753
- this.on("end", () => this.emit("close"));
4754
- });
4755
- }
4756
- return this;
4757
- } else {
4758
- if (this._isStreamInput()) {
4759
- return new Promise((resolve, reject) => {
4760
- this.once("finish", () => {
4761
- this._flattenBufferIn();
4762
- sharp.pipeline(this.options, (err, data, info) => {
4763
- if (err) {
4764
- reject(is.nativeError(err, stack));
4765
- } else {
4766
- if (this.options.resolveWithObject) {
4767
- resolve({ data, info });
4768
- } else {
4769
- resolve(data);
4770
- }
4771
- }
4772
- });
4773
- });
4774
- });
4775
- } else {
4776
- return new Promise((resolve, reject) => {
4777
- sharp.pipeline(this.options, (err, data, info) => {
4778
- if (err) {
4779
- reject(is.nativeError(err, stack));
4780
- } else {
4781
- if (this.options.resolveWithObject) {
4782
- resolve({ data, info });
4783
- } else {
4784
- resolve(data);
4785
- }
4786
- }
4787
- });
4788
- });
4789
- }
4790
- }
4791
- }
4792
- module.exports = (Sharp) => {
4793
- Object.assign(Sharp.prototype, {
4794
- toFile,
4795
- toBuffer,
4796
- keepExif,
4797
- withExif,
4798
- withExifMerge,
4799
- keepIccProfile,
4800
- withIccProfile,
4801
- keepXmp,
4802
- withXmp,
4803
- keepMetadata,
4804
- withMetadata,
4805
- toFormat,
4806
- jpeg,
4807
- jp2,
4808
- png,
4809
- webp,
4810
- tiff,
4811
- avif,
4812
- heif,
4813
- jxl,
4814
- gif,
4815
- raw,
4816
- tile,
4817
- timeout,
4818
- _updateFormatOut,
4819
- _setBooleanOption,
4820
- _read,
4821
- _pipeline
4822
- });
4823
- };
4824
- });
4825
-
4826
- // node_modules/.bun/sharp@0.34.5/node_modules/sharp/lib/utility.js
4827
- var require_utility = __commonJS((exports, module) => {
4828
- /*!
4829
- Copyright 2013 Lovell Fuller and others.
4830
- SPDX-License-Identifier: Apache-2.0
4831
- */
4832
- var events = __require("events");
4833
- var detectLibc = require_detect_libc();
4834
- var is = require_is();
4835
- var { runtimePlatformArch } = require_libvips();
4836
- var sharp = require_sharp();
4837
- var runtimePlatform = runtimePlatformArch();
4838
- var libvipsVersion = sharp.libvipsVersion();
4839
- var format = sharp.format();
4840
- format.heif.output.alias = ["avif", "heic"];
4841
- format.jpeg.output.alias = ["jpe", "jpg"];
4842
- format.tiff.output.alias = ["tif"];
4843
- format.jp2k.output.alias = ["j2c", "j2k", "jp2", "jpx"];
4844
- var interpolators = {
4845
- nearest: "nearest",
4846
- bilinear: "bilinear",
4847
- bicubic: "bicubic",
4848
- locallyBoundedBicubic: "lbb",
4849
- nohalo: "nohalo",
4850
- vertexSplitQuadraticBasisSpline: "vsqbs"
4851
- };
4852
- var versions = {
4853
- vips: libvipsVersion.semver
4854
- };
4855
- if (!libvipsVersion.isGlobal) {
4856
- if (!libvipsVersion.isWasm) {
4857
- try {
4858
- versions = __require(`@img/sharp-${runtimePlatform}/versions`);
4859
- } catch (_) {
4860
- try {
4861
- versions = __require(`@img/sharp-libvips-${runtimePlatform}/versions`);
4862
- } catch (_2) {}
4863
- }
4864
- } else {
4865
- try {
4866
- versions = (()=>{throw new Error("Cannot require module "+"@img/sharp-wasm32/versions");})();
4867
- } catch (_) {}
4868
- }
4869
- }
4870
- versions.sharp = require_package().version;
4871
- if (versions.heif && format.heif) {
4872
- format.heif.input.fileSuffix = [".avif"];
4873
- format.heif.output.alias = ["avif"];
4874
- }
4875
- function cache(options) {
4876
- if (is.bool(options)) {
4877
- if (options) {
4878
- return sharp.cache(50, 20, 100);
4879
- } else {
4880
- return sharp.cache(0, 0, 0);
4881
- }
4882
- } else if (is.object(options)) {
4883
- return sharp.cache(options.memory, options.files, options.items);
4884
- } else {
4885
- return sharp.cache();
4886
- }
4887
- }
4888
- cache(true);
4889
- function concurrency(concurrency2) {
4890
- return sharp.concurrency(is.integer(concurrency2) ? concurrency2 : null);
4891
- }
4892
- if (detectLibc.familySync() === detectLibc.GLIBC && !sharp._isUsingJemalloc()) {
4893
- sharp.concurrency(1);
4894
- } else if (detectLibc.familySync() === detectLibc.MUSL && sharp.concurrency() === 1024) {
4895
- sharp.concurrency(__require("os").availableParallelism());
4896
- }
4897
- var queue = new events.EventEmitter;
4898
- function counters() {
4899
- return sharp.counters();
4900
- }
4901
- function simd(simd2) {
4902
- return sharp.simd(is.bool(simd2) ? simd2 : null);
4903
- }
4904
- function block(options) {
4905
- if (is.object(options)) {
4906
- if (Array.isArray(options.operation) && options.operation.every(is.string)) {
4907
- sharp.block(options.operation, true);
4908
- } else {
4909
- throw is.invalidParameterError("operation", "Array<string>", options.operation);
4910
- }
4911
- } else {
4912
- throw is.invalidParameterError("options", "object", options);
4913
- }
4914
- }
4915
- function unblock(options) {
4916
- if (is.object(options)) {
4917
- if (Array.isArray(options.operation) && options.operation.every(is.string)) {
4918
- sharp.block(options.operation, false);
4919
- } else {
4920
- throw is.invalidParameterError("operation", "Array<string>", options.operation);
4921
- }
4922
- } else {
4923
- throw is.invalidParameterError("options", "object", options);
4924
- }
4925
- }
4926
- module.exports = (Sharp) => {
4927
- Sharp.cache = cache;
4928
- Sharp.concurrency = concurrency;
4929
- Sharp.counters = counters;
4930
- Sharp.simd = simd;
4931
- Sharp.format = format;
4932
- Sharp.interpolators = interpolators;
4933
- Sharp.versions = versions;
4934
- Sharp.queue = queue;
4935
- Sharp.block = block;
4936
- Sharp.unblock = unblock;
4937
- };
4938
- });
4939
-
4940
- // node_modules/.bun/sharp@0.34.5/node_modules/sharp/lib/index.js
4941
- var require_lib = __commonJS((exports, module) => {
4942
- /*!
4943
- Copyright 2013 Lovell Fuller and others.
4944
- SPDX-License-Identifier: Apache-2.0
4945
- */
4946
- var Sharp = require_constructor();
4947
- require_input()(Sharp);
4948
- require_resize()(Sharp);
4949
- require_composite()(Sharp);
4950
- require_operation()(Sharp);
4951
- require_colour2()(Sharp);
4952
- require_channel()(Sharp);
4953
- require_output()(Sharp);
4954
- require_utility()(Sharp);
4955
- module.exports = Sharp;
4956
- });
4957
- export default require_lib();