@bigbinary/neetoui 6.5.11-beta.1 → 6.5.12

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 (187) hide show
  1. package/dist/Accordion.js +1 -1
  2. package/dist/ActionDropdown.js +4 -4
  3. package/dist/Alert.js +5 -5
  4. package/dist/Avatar.js +10 -3
  5. package/dist/Avatar.js.map +1 -1
  6. package/dist/Button.js +3 -4
  7. package/dist/Button.js.map +1 -1
  8. package/dist/Checkbox.js +3 -3
  9. package/dist/ColorPicker.js +9 -8
  10. package/dist/ColorPicker.js.map +1 -1
  11. package/dist/DatePicker.js +3 -3
  12. package/dist/DateTimePicker.js +6 -7
  13. package/dist/DateTimePicker.js.map +1 -1
  14. package/dist/Dropdown.js +4 -4
  15. package/dist/Input.js +3 -3
  16. package/dist/Kbd.js +1 -2
  17. package/dist/Kbd.js.map +1 -1
  18. package/dist/Label.js +1 -2
  19. package/dist/Label.js.map +1 -1
  20. package/dist/Modal.js +5 -5
  21. package/dist/MultiEmailInput.js +5 -6
  22. package/dist/MultiEmailInput.js.map +1 -1
  23. package/dist/NoData.js +2 -3
  24. package/dist/NoData.js.map +1 -1
  25. package/dist/Pagination.js +3 -2
  26. package/dist/Pagination.js.map +1 -1
  27. package/dist/Pane.js +5 -5
  28. package/dist/Popover.js +1 -2
  29. package/dist/Popover.js.map +1 -1
  30. package/dist/Radio.js +3 -3
  31. package/dist/Select.js +183 -30
  32. package/dist/Select.js.map +1 -1
  33. package/dist/Sidebar.js +3 -4
  34. package/dist/Sidebar.js.map +1 -1
  35. package/dist/Slider.js +3 -3
  36. package/dist/Switch.js +3 -3
  37. package/dist/Table.js +4527 -391
  38. package/dist/Table.js.map +1 -1
  39. package/dist/Textarea.js +3 -3
  40. package/dist/TimePicker.js +3 -3
  41. package/dist/TimePickerInput.js +7 -8
  42. package/dist/TimePickerInput.js.map +1 -1
  43. package/dist/Toastr.js +1654 -3
  44. package/dist/Toastr.js.map +1 -1
  45. package/dist/Tooltip.js +1 -2
  46. package/dist/Tooltip.js.map +1 -1
  47. package/dist/Tree.js +2 -1
  48. package/dist/Tree.js.map +1 -1
  49. package/dist/TreeSelect.js +3 -3
  50. package/dist/_commonjsHelpers-ced4e05c.js +29 -0
  51. package/dist/_commonjsHelpers-ced4e05c.js.map +1 -0
  52. package/dist/cjs/Accordion.js +14 -14
  53. package/dist/cjs/Accordion.js.map +1 -1
  54. package/dist/cjs/ActionDropdown.js +4 -4
  55. package/dist/cjs/Alert.js +5 -5
  56. package/dist/cjs/Avatar.js +11 -5
  57. package/dist/cjs/Avatar.js.map +1 -1
  58. package/dist/cjs/Button.js +11 -12
  59. package/dist/cjs/Button.js.map +1 -1
  60. package/dist/cjs/Checkbox.js +3 -3
  61. package/dist/cjs/ColorPicker.js +8 -7
  62. package/dist/cjs/ColorPicker.js.map +1 -1
  63. package/dist/cjs/DatePicker.js +3 -3
  64. package/dist/cjs/DateTimePicker.js +6 -7
  65. package/dist/cjs/DateTimePicker.js.map +1 -1
  66. package/dist/cjs/Dropdown.js +4 -4
  67. package/dist/cjs/Input.js +3 -3
  68. package/dist/cjs/Kbd.js +1 -2
  69. package/dist/cjs/Kbd.js.map +1 -1
  70. package/dist/cjs/Label.js +1 -2
  71. package/dist/cjs/Label.js.map +1 -1
  72. package/dist/cjs/Modal.js +5 -5
  73. package/dist/cjs/MultiEmailInput.js +13 -15
  74. package/dist/cjs/MultiEmailInput.js.map +1 -1
  75. package/dist/cjs/NoData.js +2 -3
  76. package/dist/cjs/NoData.js.map +1 -1
  77. package/dist/cjs/Pagination.js +3 -2
  78. package/dist/cjs/Pagination.js.map +1 -1
  79. package/dist/cjs/Pane.js +5 -5
  80. package/dist/cjs/Popover.js +1 -2
  81. package/dist/cjs/Popover.js.map +1 -1
  82. package/dist/cjs/Radio.js +3 -3
  83. package/dist/cjs/Select.js +193 -26
  84. package/dist/cjs/Select.js.map +1 -1
  85. package/dist/cjs/Sidebar.js +3 -4
  86. package/dist/cjs/Sidebar.js.map +1 -1
  87. package/dist/cjs/Slider.js +3 -3
  88. package/dist/cjs/Switch.js +3 -3
  89. package/dist/cjs/Table.js +4551 -415
  90. package/dist/cjs/Table.js.map +1 -1
  91. package/dist/cjs/Textarea.js +3 -3
  92. package/dist/cjs/TimePicker.js +3 -3
  93. package/dist/cjs/TimePickerInput.js +7 -8
  94. package/dist/cjs/TimePickerInput.js.map +1 -1
  95. package/dist/cjs/Toastr.js +1657 -6
  96. package/dist/cjs/Toastr.js.map +1 -1
  97. package/dist/cjs/Tooltip.js +1 -2
  98. package/dist/cjs/Tooltip.js.map +1 -1
  99. package/dist/cjs/Tree.js +2 -1
  100. package/dist/cjs/Tree.js.map +1 -1
  101. package/dist/cjs/TreeSelect.js +3 -3
  102. package/dist/cjs/_commonjsHelpers-44e4a143.js +33 -0
  103. package/dist/cjs/_commonjsHelpers-44e4a143.js.map +1 -0
  104. package/dist/cjs/formik/ActionBlock.js +2 -3
  105. package/dist/cjs/formik/ActionBlock.js.map +1 -1
  106. package/dist/cjs/formik/BlockNavigation.js +5 -5
  107. package/dist/cjs/formik/Button.js +2 -3
  108. package/dist/cjs/formik/Button.js.map +1 -1
  109. package/dist/cjs/formik/Checkbox.js +3 -3
  110. package/dist/cjs/formik/Input.js +3 -3
  111. package/dist/cjs/formik/MultiEmailInput.js +5 -6
  112. package/dist/cjs/formik/MultiEmailInput.js.map +1 -1
  113. package/dist/cjs/formik/Radio.js +3 -3
  114. package/dist/cjs/formik/Select.js +5 -8
  115. package/dist/cjs/formik/Select.js.map +1 -1
  116. package/dist/cjs/formik/Slider.js +3 -3
  117. package/dist/cjs/formik/Switch.js +3 -3
  118. package/dist/cjs/formik/Textarea.js +3 -3
  119. package/dist/cjs/formik/TreeSelect.js +3 -3
  120. package/dist/cjs/formik/index.js +6 -9
  121. package/dist/cjs/formik/index.js.map +1 -1
  122. package/dist/cjs/index-0e68cfff.js +3934 -0
  123. package/dist/cjs/index-0e68cfff.js.map +1 -0
  124. package/dist/cjs/index-1ad9d2c1.js +9176 -0
  125. package/dist/cjs/index-1ad9d2c1.js.map +1 -0
  126. package/dist/cjs/{index-6e09c7bc.js → index-68589e5c.js} +7 -9
  127. package/dist/cjs/{index-6e09c7bc.js.map → index-68589e5c.js.map} +1 -1
  128. package/dist/cjs/index-a780bb4a.js +3841 -0
  129. package/dist/cjs/index-a780bb4a.js.map +1 -0
  130. package/dist/cjs/index.css +1 -1
  131. package/dist/cjs/index.js +8 -18
  132. package/dist/cjs/index.js.map +1 -1
  133. package/dist/cjs/layouts.js +3 -4
  134. package/dist/cjs/layouts.js.map +1 -1
  135. package/dist/cjs/react-select-creatable.esm-b39742a3.js +6675 -0
  136. package/dist/cjs/react-select-creatable.esm-b39742a3.js.map +1 -0
  137. package/dist/cjs/{useOverlayManager-359ed795.js → useOverlayManager-b8f5f220.js} +2 -2
  138. package/dist/cjs/{useOverlayManager-359ed795.js.map → useOverlayManager-b8f5f220.js.map} +1 -1
  139. package/dist/cjs/{useQueryParams-14f054b3.js → useQueryParams-dcfba9f0.js} +2 -2
  140. package/dist/cjs/{useQueryParams-14f054b3.js.map → useQueryParams-dcfba9f0.js.map} +1 -1
  141. package/dist/formik/ActionBlock.js +2 -3
  142. package/dist/formik/ActionBlock.js.map +1 -1
  143. package/dist/formik/BlockNavigation.js +5 -5
  144. package/dist/formik/Button.js +2 -3
  145. package/dist/formik/Button.js.map +1 -1
  146. package/dist/formik/Checkbox.js +3 -3
  147. package/dist/formik/Input.js +3 -3
  148. package/dist/formik/MultiEmailInput.js +5 -6
  149. package/dist/formik/MultiEmailInput.js.map +1 -1
  150. package/dist/formik/Radio.js +3 -3
  151. package/dist/formik/Select.js +5 -8
  152. package/dist/formik/Select.js.map +1 -1
  153. package/dist/formik/Slider.js +3 -3
  154. package/dist/formik/Switch.js +3 -3
  155. package/dist/formik/Textarea.js +3 -3
  156. package/dist/formik/TreeSelect.js +3 -3
  157. package/dist/formik/index.js +6 -9
  158. package/dist/formik/index.js.map +1 -1
  159. package/dist/index-2123b5e9.js +3927 -0
  160. package/dist/index-2123b5e9.js.map +1 -0
  161. package/dist/index-4883abd9.js +3834 -0
  162. package/dist/index-4883abd9.js.map +1 -0
  163. package/dist/index-75a336d9.js +9151 -0
  164. package/dist/index-75a336d9.js.map +1 -0
  165. package/dist/{index-c8d9113c.js → index-c3d336a5.js} +3 -4
  166. package/dist/index-c3d336a5.js.map +1 -0
  167. package/dist/index.css +1 -1
  168. package/dist/index.js +8 -18
  169. package/dist/index.js.map +1 -1
  170. package/dist/layouts.js +3 -4
  171. package/dist/layouts.js.map +1 -1
  172. package/dist/react-select-creatable.esm-93affeca.js +6644 -0
  173. package/dist/react-select-creatable.esm-93affeca.js.map +1 -0
  174. package/dist/{useOverlayManager-95a474d5.js → useOverlayManager-8651b46d.js} +2 -2
  175. package/dist/{useOverlayManager-95a474d5.js.map → useOverlayManager-8651b46d.js.map} +1 -1
  176. package/dist/{useQueryParams-4e7ddcf8.js → useQueryParams-5059df24.js} +2 -2
  177. package/dist/{useQueryParams-4e7ddcf8.js.map → useQueryParams-5059df24.js.map} +1 -1
  178. package/package.json +2 -13
  179. package/dist/cjs/index-773961dd.js +0 -453
  180. package/dist/cjs/index-773961dd.js.map +0 -1
  181. package/dist/cjs/index-b1ac86d6.js +0 -258
  182. package/dist/cjs/index-b1ac86d6.js.map +0 -1
  183. package/dist/index-b3a8dd29.js +0 -249
  184. package/dist/index-b3a8dd29.js.map +0 -1
  185. package/dist/index-c442518b.js +0 -445
  186. package/dist/index-c442518b.js.map +0 -1
  187. package/dist/index-c8d9113c.js.map +0 -1
package/dist/Toastr.js CHANGED
@@ -8,13 +8,1664 @@ import React__default from 'react';
8
8
  import { t } from 'i18next';
9
9
  import { Close, CheckCircle, Warning, CloseCircle, Info } from '@bigbinary/neeto-icons';
10
10
  import { Slide, toast } from 'react-toastify';
11
- import { n as noop, U as UniqueArray } from './index-c8d9113c.js';
12
- import { Options, options, tokenize } from 'linkifyjs';
11
+ import { n as noop$1, U as UniqueArray } from './index-c3d336a5.js';
13
12
  import './createClass-601a36b2.js';
13
+ import './_commonjsHelpers-ced4e05c.js';
14
14
  import '@bigbinary/neeto-cist';
15
15
  import 'util';
16
16
  import 'ramda';
17
17
 
18
+ // THIS FILE IS AUTOMATICALLY GENERATED DO NOT EDIT DIRECTLY
19
+ // See update-tlds.js for encoding/decoding format
20
+ // https://data.iana.org/TLD/tlds-alpha-by-domain.txt
21
+ const encodedTlds = 'aaa1rp3barth4b0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0faromeo7ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4vianca6w0s2x0a2z0ure5ba0by2idu3namex3narepublic11d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2ntley5rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re2s2c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y0eats7k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0cast4mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking0channel11l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dabur3d1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3nlop4pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t0isalat7u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0at2delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d0network8tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntdoor4ier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2o0dyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0ardian6cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5gtv3iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0eles2s3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6logistics9properties14fh2g1h1i0a1ds2m1nder2le4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3ncaster5ia3d0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4de2k2psy3ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0cys3drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7serati6ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rckmsd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic3tual5v1w1x1y1z2na0b1goya4me2tura4vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rthwesternmutual14on4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9dnavy5lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3ssagens7y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0america6xi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0stone5umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cher3ks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0a1b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp2w2ell3ia1ksha5oes2p0ping5uji3w0time7i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ffany5ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0channel7ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lkswagen7vo3te1ing3o2yage5u0elos6wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2olterskluwer11odside6rk0s2ld3w2s1tc1f3xbox3erox4finity6ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2';
22
+ // Internationalized domain names containing non-ASCII
23
+ const encodedUtlds = 'ελ1υ2бг1ел3дети4ею2католик6ом3мкд2он1сква6онлайн5рг3рус2ф2сайт3рб3укр3қаз3հայ3ישראל5קום3ابوظبي5تصالات6رامكو5لاردن4بحرين5جزائر5سعودية6عليان5مغرب5مارات5یران5بارت2زار4يتك3ھارت5تونس4سودان3رية5شبكة4عراق2ب2مان4فلسطين6قطر3كاثوليك6وم3مصر2ليسيا5وريتانيا7قع4همراه5پاکستان7ڀارت4कॉम3नेट3भारत0म्3ोत5संगठन5বাংলা5ভারত2ৰত4ਭਾਰਤ4ભારત4ଭାରତ4இந்தியா6லங்கை6சிங்கப்பூர்11భారత్5ಭಾರತ4ഭാരതം5ලංකා4คอม3ไทย3ລາວ3გე2みんな3アマゾン4クラウド4グーグル4コム2ストア3セール3ファッション6ポイント4世界2中信1国1國1文网3亚马逊3企业2佛山2信息2健康2八卦2公司1益2台湾1灣2商城1店1标2嘉里0大酒店5在线2大拿2天主教3娱乐2家電2广东2微博2慈善2我爱你3手机2招聘2政务1府2新加坡2闻2时尚2書籍2机构2淡马锡3游戏2澳門2点看2移动2组织机构4网址1店1站1络2联通2谷歌2购物2通販2集团2電訊盈科4飞利浦3食品2餐厅2香格里拉3港2닷넷1컴2삼성2한국2';
24
+
25
+ /**
26
+ * @template A
27
+ * @template B
28
+ * @param {A} target
29
+ * @param {B} properties
30
+ * @return {A & B}
31
+ */
32
+ const assign = (target, properties) => {
33
+ for (const key in properties) {
34
+ target[key] = properties[key];
35
+ }
36
+ return target;
37
+ };
38
+
39
+ /**
40
+ * Finite State Machine generation utilities
41
+ */
42
+
43
+ /**
44
+ * @template T
45
+ * @typedef {{ [group: string]: T[] }} Collections
46
+ */
47
+
48
+ /**
49
+ * @typedef {{ [group: string]: true }} Flags
50
+ */
51
+
52
+ // Keys in scanner Collections instances
53
+ const numeric = 'numeric';
54
+ const ascii = 'ascii';
55
+ const alpha = 'alpha';
56
+ const asciinumeric = 'asciinumeric';
57
+ const alphanumeric = 'alphanumeric';
58
+ const domain = 'domain';
59
+ const emoji = 'emoji';
60
+ const scheme = 'scheme';
61
+ const slashscheme = 'slashscheme';
62
+ const whitespace = 'whitespace';
63
+
64
+ /**
65
+ * @template T
66
+ * @param {string} name
67
+ * @param {Collections<T>} groups to register in
68
+ * @returns {T[]} Current list of tokens in the given collection
69
+ */
70
+ function registerGroup(name, groups) {
71
+ if (!(name in groups)) {
72
+ groups[name] = [];
73
+ }
74
+ return groups[name];
75
+ }
76
+
77
+ /**
78
+ * @template T
79
+ * @param {T} t token to add
80
+ * @param {Collections<T>} groups
81
+ * @param {Flags} flags
82
+ */
83
+ function addToGroups(t, flags, groups) {
84
+ if (flags[numeric]) {
85
+ flags[asciinumeric] = true;
86
+ flags[alphanumeric] = true;
87
+ }
88
+ if (flags[ascii]) {
89
+ flags[asciinumeric] = true;
90
+ flags[alpha] = true;
91
+ }
92
+ if (flags[asciinumeric]) {
93
+ flags[alphanumeric] = true;
94
+ }
95
+ if (flags[alpha]) {
96
+ flags[alphanumeric] = true;
97
+ }
98
+ if (flags[alphanumeric]) {
99
+ flags[domain] = true;
100
+ }
101
+ if (flags[emoji]) {
102
+ flags[domain] = true;
103
+ }
104
+ for (const k in flags) {
105
+ const group = registerGroup(k, groups);
106
+ if (group.indexOf(t) < 0) {
107
+ group.push(t);
108
+ }
109
+ }
110
+ }
111
+
112
+ /**
113
+ * @template T
114
+ * @param {T} t token to check
115
+ * @param {Collections<T>} groups
116
+ * @returns {Flags} group flags that contain this token
117
+ */
118
+ function flagsForToken(t, groups) {
119
+ const result = {};
120
+ for (const c in groups) {
121
+ if (groups[c].indexOf(t) >= 0) {
122
+ result[c] = true;
123
+ }
124
+ }
125
+ return result;
126
+ }
127
+
128
+ /**
129
+ * @template T
130
+ * @typedef {null | T } Transition
131
+ */
132
+
133
+ /**
134
+ * Define a basic state machine state. j is the list of character transitions,
135
+ * jr is the list of regex-match transitions, jd is the default state to
136
+ * transition to t is the accepting token type, if any. If this is the terminal
137
+ * state, then it does not emit a token.
138
+ *
139
+ * The template type T represents the type of the token this state accepts. This
140
+ * should be a string (such as of the token exports in `text.js`) or a
141
+ * MultiToken subclass (from `multi.js`)
142
+ *
143
+ * @template T
144
+ * @param {T} [token] Token that this state emits
145
+ */
146
+ function State(token) {
147
+ if (token === void 0) {
148
+ token = null;
149
+ }
150
+ // this.n = null; // DEBUG: State name
151
+ /** @type {{ [input: string]: State<T> }} j */
152
+ this.j = {}; // IMPLEMENTATION 1
153
+ // this.j = []; // IMPLEMENTATION 2
154
+ /** @type {[RegExp, State<T>][]} jr */
155
+ this.jr = [];
156
+ /** @type {?State<T>} jd */
157
+ this.jd = null;
158
+ /** @type {?T} t */
159
+ this.t = token;
160
+ }
161
+
162
+ /**
163
+ * Scanner token groups
164
+ * @type Collections<string>
165
+ */
166
+ State.groups = {};
167
+ State.prototype = {
168
+ accepts() {
169
+ return !!this.t;
170
+ },
171
+ /**
172
+ * Follow an existing transition from the given input to the next state.
173
+ * Does not mutate.
174
+ * @param {string} input character or token type to transition on
175
+ * @returns {?State<T>} the next state, if any
176
+ */
177
+ go(input) {
178
+ const state = this;
179
+ const nextState = state.j[input];
180
+ if (nextState) {
181
+ return nextState;
182
+ }
183
+ for (let i = 0; i < state.jr.length; i++) {
184
+ const regex = state.jr[i][0];
185
+ const nextState = state.jr[i][1]; // note: might be empty to prevent default jump
186
+ if (nextState && regex.test(input)) {
187
+ return nextState;
188
+ }
189
+ }
190
+ // Nowhere left to jump! Return default, if any
191
+ return state.jd;
192
+ },
193
+ /**
194
+ * Whether the state has a transition for the given input. Set the second
195
+ * argument to true to only look for an exact match (and not a default or
196
+ * regular-expression-based transition)
197
+ * @param {string} input
198
+ * @param {boolean} exactOnly
199
+ */
200
+ has(input, exactOnly) {
201
+ if (exactOnly === void 0) {
202
+ exactOnly = false;
203
+ }
204
+ return exactOnly ? input in this.j : !!this.go(input);
205
+ },
206
+ /**
207
+ * Short for "transition all"; create a transition from the array of items
208
+ * in the given list to the same final resulting state.
209
+ * @param {string | string[]} inputs Group of inputs to transition on
210
+ * @param {Transition<T> | State<T>} [next] Transition options
211
+ * @param {Flags} [flags] Collections flags to add token to
212
+ * @param {Collections<T>} [groups] Master list of token groups
213
+ */
214
+ ta(inputs, next, flags, groups) {
215
+ for (let i = 0; i < inputs.length; i++) {
216
+ this.tt(inputs[i], next, flags, groups);
217
+ }
218
+ },
219
+ /**
220
+ * Short for "take regexp transition"; defines a transition for this state
221
+ * when it encounters a token which matches the given regular expression
222
+ * @param {RegExp} regexp Regular expression transition (populate first)
223
+ * @param {T | State<T>} [next] Transition options
224
+ * @param {Flags} [flags] Collections flags to add token to
225
+ * @param {Collections<T>} [groups] Master list of token groups
226
+ * @returns {State<T>} taken after the given input
227
+ */
228
+ tr(regexp, next, flags, groups) {
229
+ groups = groups || State.groups;
230
+ let nextState;
231
+ if (next && next.j) {
232
+ nextState = next;
233
+ } else {
234
+ // Token with maybe token groups
235
+ nextState = new State(next);
236
+ if (flags && groups) {
237
+ addToGroups(next, flags, groups);
238
+ }
239
+ }
240
+ this.jr.push([regexp, nextState]);
241
+ return nextState;
242
+ },
243
+ /**
244
+ * Short for "take transitions", will take as many sequential transitions as
245
+ * the length of the given input and returns the
246
+ * resulting final state.
247
+ * @param {string | string[]} input
248
+ * @param {T | State<T>} [next] Transition options
249
+ * @param {Flags} [flags] Collections flags to add token to
250
+ * @param {Collections<T>} [groups] Master list of token groups
251
+ * @returns {State<T>} taken after the given input
252
+ */
253
+ ts(input, next, flags, groups) {
254
+ let state = this;
255
+ const len = input.length;
256
+ if (!len) {
257
+ return state;
258
+ }
259
+ for (let i = 0; i < len - 1; i++) {
260
+ state = state.tt(input[i]);
261
+ }
262
+ return state.tt(input[len - 1], next, flags, groups);
263
+ },
264
+ /**
265
+ * Short for "take transition", this is a method for building/working with
266
+ * state machines.
267
+ *
268
+ * If a state already exists for the given input, returns it.
269
+ *
270
+ * If a token is specified, that state will emit that token when reached by
271
+ * the linkify engine.
272
+ *
273
+ * If no state exists, it will be initialized with some default transitions
274
+ * that resemble existing default transitions.
275
+ *
276
+ * If a state is given for the second argument, that state will be
277
+ * transitioned to on the given input regardless of what that input
278
+ * previously did.
279
+ *
280
+ * Specify a token group flags to define groups that this token belongs to.
281
+ * The token will be added to corresponding entires in the given groups
282
+ * object.
283
+ *
284
+ * @param {string} input character, token type to transition on
285
+ * @param {T | State<T>} [next] Transition options
286
+ * @param {Flags} [flags] Collections flags to add token to
287
+ * @param {Collections<T>} [groups] Master list of groups
288
+ * @returns {State<T>} taken after the given input
289
+ */
290
+ tt(input, next, flags, groups) {
291
+ groups = groups || State.groups;
292
+ const state = this;
293
+
294
+ // Check if existing state given, just a basic transition
295
+ if (next && next.j) {
296
+ state.j[input] = next;
297
+ return next;
298
+ }
299
+ const t = next;
300
+
301
+ // Take the transition with the usual default mechanisms and use that as
302
+ // a template for creating the next state
303
+ let nextState,
304
+ templateState = state.go(input);
305
+ if (templateState) {
306
+ nextState = new State();
307
+ assign(nextState.j, templateState.j);
308
+ nextState.jr.push.apply(nextState.jr, templateState.jr);
309
+ nextState.jd = templateState.jd;
310
+ nextState.t = templateState.t;
311
+ } else {
312
+ nextState = new State();
313
+ }
314
+ if (t) {
315
+ // Ensure newly token is in the same groups as the old token
316
+ if (groups) {
317
+ if (nextState.t && typeof nextState.t === 'string') {
318
+ const allFlags = assign(flagsForToken(nextState.t, groups), flags);
319
+ addToGroups(t, allFlags, groups);
320
+ } else if (flags) {
321
+ addToGroups(t, flags, groups);
322
+ }
323
+ }
324
+ nextState.t = t; // overwrite anything that was previously there
325
+ }
326
+
327
+ state.j[input] = nextState;
328
+ return nextState;
329
+ }
330
+ };
331
+
332
+ // Helper functions to improve minification (not exported outside linkifyjs module)
333
+
334
+ /**
335
+ * @template T
336
+ * @param {State<T>} state
337
+ * @param {string | string[]} input
338
+ * @param {Flags} [flags]
339
+ * @param {Collections<T>} [groups]
340
+ */
341
+ const ta = (state, input, next, flags, groups) => state.ta(input, next, flags, groups);
342
+
343
+ /**
344
+ * @template T
345
+ * @param {State<T>} state
346
+ * @param {RegExp} regexp
347
+ * @param {T | State<T>} [next]
348
+ * @param {Flags} [flags]
349
+ * @param {Collections<T>} [groups]
350
+ */
351
+ const tr = (state, regexp, next, flags, groups) => state.tr(regexp, next, flags, groups);
352
+
353
+ /**
354
+ * @template T
355
+ * @param {State<T>} state
356
+ * @param {string | string[]} input
357
+ * @param {T | State<T>} [next]
358
+ * @param {Flags} [flags]
359
+ * @param {Collections<T>} [groups]
360
+ */
361
+ const ts = (state, input, next, flags, groups) => state.ts(input, next, flags, groups);
362
+
363
+ /**
364
+ * @template T
365
+ * @param {State<T>} state
366
+ * @param {string} input
367
+ * @param {T | State<T>} [next]
368
+ * @param {Collections<T>} [groups]
369
+ * @param {Flags} [flags]
370
+ */
371
+ const tt = (state, input, next, flags, groups) => state.tt(input, next, flags, groups);
372
+
373
+ /******************************************************************************
374
+ Text Tokens
375
+ Identifiers for token outputs from the regexp scanner
376
+ ******************************************************************************/
377
+
378
+ // A valid web domain token
379
+ const WORD = 'WORD'; // only contains a-z
380
+ const UWORD = 'UWORD'; // contains letters other than a-z, used for IDN
381
+
382
+ // Special case of word
383
+ const LOCALHOST = 'LOCALHOST';
384
+
385
+ // Valid top-level domain, special case of WORD (see tlds.js)
386
+ const TLD = 'TLD';
387
+
388
+ // Valid IDN TLD, special case of UWORD (see tlds.js)
389
+ const UTLD = 'UTLD';
390
+
391
+ // The scheme portion of a web URI protocol. Supported types include: `mailto`,
392
+ // `file`, and user-defined custom protocols. Limited to schemes that contain
393
+ // only letters
394
+ const SCHEME = 'SCHEME';
395
+
396
+ // Similar to SCHEME, except makes distinction for schemes that must always be
397
+ // followed by `://`, not just `:`. Supported types include `http`, `https`,
398
+ // `ftp`, `ftps`
399
+ const SLASH_SCHEME = 'SLASH_SCHEME';
400
+
401
+ // Any sequence of digits 0-9
402
+ const NUM = 'NUM';
403
+
404
+ // Any number of consecutive whitespace characters that are not newline
405
+ const WS = 'WS';
406
+
407
+ // New line (unix style)
408
+ const NL$1 = 'NL'; // \n
409
+
410
+ // Opening/closing bracket classes
411
+ const OPENBRACE = 'OPENBRACE'; // {
412
+ const OPENBRACKET = 'OPENBRACKET'; // [
413
+ const OPENANGLEBRACKET = 'OPENANGLEBRACKET'; // <
414
+ const OPENPAREN = 'OPENPAREN'; // (
415
+ const CLOSEBRACE = 'CLOSEBRACE'; // }
416
+ const CLOSEBRACKET = 'CLOSEBRACKET'; // ]
417
+ const CLOSEANGLEBRACKET = 'CLOSEANGLEBRACKET'; // >
418
+ const CLOSEPAREN = 'CLOSEPAREN'; // )
419
+
420
+ // Various symbols
421
+ const AMPERSAND = 'AMPERSAND'; // &
422
+ const APOSTROPHE = 'APOSTROPHE'; // '
423
+ const ASTERISK = 'ASTERISK'; // *
424
+ const AT = 'AT'; // @
425
+ const BACKSLASH = 'BACKSLASH'; // \
426
+ const BACKTICK = 'BACKTICK'; // `
427
+ const CARET = 'CARET'; // ^
428
+ const COLON = 'COLON'; // :
429
+ const COMMA = 'COMMA'; // ,
430
+ const DOLLAR = 'DOLLAR'; // $
431
+ const DOT = 'DOT'; // .
432
+ const EQUALS = 'EQUALS'; // =
433
+ const EXCLAMATION = 'EXCLAMATION'; // !
434
+ const HYPHEN = 'HYPHEN'; // -
435
+ const PERCENT = 'PERCENT'; // %
436
+ const PIPE = 'PIPE'; // |
437
+ const PLUS = 'PLUS'; // +
438
+ const POUND = 'POUND'; // #
439
+ const QUERY = 'QUERY'; // ?
440
+ const QUOTE = 'QUOTE'; // "
441
+
442
+ const SEMI = 'SEMI'; // ;
443
+ const SLASH = 'SLASH'; // /
444
+ const TILDE = 'TILDE'; // ~
445
+ const UNDERSCORE = 'UNDERSCORE'; // _
446
+
447
+ // Emoji symbol
448
+ const EMOJI$1 = 'EMOJI';
449
+
450
+ // Default token - anything that is not one of the above
451
+ const SYM = 'SYM';
452
+
453
+ var tk = /*#__PURE__*/Object.freeze({
454
+ __proto__: null,
455
+ WORD: WORD,
456
+ UWORD: UWORD,
457
+ LOCALHOST: LOCALHOST,
458
+ TLD: TLD,
459
+ UTLD: UTLD,
460
+ SCHEME: SCHEME,
461
+ SLASH_SCHEME: SLASH_SCHEME,
462
+ NUM: NUM,
463
+ WS: WS,
464
+ NL: NL$1,
465
+ OPENBRACE: OPENBRACE,
466
+ OPENBRACKET: OPENBRACKET,
467
+ OPENANGLEBRACKET: OPENANGLEBRACKET,
468
+ OPENPAREN: OPENPAREN,
469
+ CLOSEBRACE: CLOSEBRACE,
470
+ CLOSEBRACKET: CLOSEBRACKET,
471
+ CLOSEANGLEBRACKET: CLOSEANGLEBRACKET,
472
+ CLOSEPAREN: CLOSEPAREN,
473
+ AMPERSAND: AMPERSAND,
474
+ APOSTROPHE: APOSTROPHE,
475
+ ASTERISK: ASTERISK,
476
+ AT: AT,
477
+ BACKSLASH: BACKSLASH,
478
+ BACKTICK: BACKTICK,
479
+ CARET: CARET,
480
+ COLON: COLON,
481
+ COMMA: COMMA,
482
+ DOLLAR: DOLLAR,
483
+ DOT: DOT,
484
+ EQUALS: EQUALS,
485
+ EXCLAMATION: EXCLAMATION,
486
+ HYPHEN: HYPHEN,
487
+ PERCENT: PERCENT,
488
+ PIPE: PIPE,
489
+ PLUS: PLUS,
490
+ POUND: POUND,
491
+ QUERY: QUERY,
492
+ QUOTE: QUOTE,
493
+ SEMI: SEMI,
494
+ SLASH: SLASH,
495
+ TILDE: TILDE,
496
+ UNDERSCORE: UNDERSCORE,
497
+ EMOJI: EMOJI$1,
498
+ SYM: SYM
499
+ });
500
+
501
+ // Note that these two Unicode ones expand into a really big one with Babel
502
+ const ASCII_LETTER = /[a-z]/;
503
+ const LETTER = /\p{L}/u; // Any Unicode character with letter data type
504
+ const EMOJI = /\p{Emoji}/u; // Any Unicode emoji character
505
+ const DIGIT = /\d/;
506
+ const SPACE = /\s/;
507
+
508
+ /**
509
+ The scanner provides an interface that takes a string of text as input, and
510
+ outputs an array of tokens instances that can be used for easy URL parsing.
511
+ */
512
+ const NL = '\n'; // New line character
513
+ const EMOJI_VARIATION = '\ufe0f'; // Variation selector, follows heart and others
514
+ const EMOJI_JOINER = '\u200d'; // zero-width joiner
515
+
516
+ let tlds = null,
517
+ utlds = null; // don't change so only have to be computed once
518
+
519
+ /**
520
+ * Scanner output token:
521
+ * - `t` is the token name (e.g., 'NUM', 'EMOJI', 'TLD')
522
+ * - `v` is the value of the token (e.g., '123', '❤️', 'com')
523
+ * - `s` is the start index of the token in the original string
524
+ * - `e` is the end index of the token in the original string
525
+ * @typedef {{t: string, v: string, s: number, e: number}} Token
526
+ */
527
+
528
+ /**
529
+ * @template T
530
+ * @typedef {{ [collection: string]: T[] }} Collections
531
+ */
532
+
533
+ /**
534
+ * Initialize the scanner character-based state machine for the given start
535
+ * state
536
+ * @param {[string, boolean][]} customSchemes List of custom schemes, where each
537
+ * item is a length-2 tuple with the first element set to the string scheme, and
538
+ * the second element set to `true` if the `://` after the scheme is optional
539
+ */
540
+ function init$2(customSchemes) {
541
+ if (customSchemes === void 0) {
542
+ customSchemes = [];
543
+ }
544
+ // Frequently used states (name argument removed during minification)
545
+ /** @type Collections<string> */
546
+ const groups = {}; // of tokens
547
+ State.groups = groups;
548
+ /** @type State<string> */
549
+ const Start = new State();
550
+ if (tlds == null) {
551
+ tlds = decodeTlds(encodedTlds);
552
+ }
553
+ if (utlds == null) {
554
+ utlds = decodeTlds(encodedUtlds);
555
+ }
556
+
557
+ // States for special URL symbols that accept immediately after start
558
+ tt(Start, "'", APOSTROPHE);
559
+ tt(Start, '{', OPENBRACE);
560
+ tt(Start, '[', OPENBRACKET);
561
+ tt(Start, '<', OPENANGLEBRACKET);
562
+ tt(Start, '(', OPENPAREN);
563
+ tt(Start, '}', CLOSEBRACE);
564
+ tt(Start, ']', CLOSEBRACKET);
565
+ tt(Start, '>', CLOSEANGLEBRACKET);
566
+ tt(Start, ')', CLOSEPAREN);
567
+ tt(Start, '&', AMPERSAND);
568
+ tt(Start, '*', ASTERISK);
569
+ tt(Start, '@', AT);
570
+ tt(Start, '`', BACKTICK);
571
+ tt(Start, '^', CARET);
572
+ tt(Start, ':', COLON);
573
+ tt(Start, ',', COMMA);
574
+ tt(Start, '$', DOLLAR);
575
+ tt(Start, '.', DOT);
576
+ tt(Start, '=', EQUALS);
577
+ tt(Start, '!', EXCLAMATION);
578
+ tt(Start, '-', HYPHEN);
579
+ tt(Start, '%', PERCENT);
580
+ tt(Start, '|', PIPE);
581
+ tt(Start, '+', PLUS);
582
+ tt(Start, '#', POUND);
583
+ tt(Start, '?', QUERY);
584
+ tt(Start, '"', QUOTE);
585
+ tt(Start, '/', SLASH);
586
+ tt(Start, ';', SEMI);
587
+ tt(Start, '~', TILDE);
588
+ tt(Start, '_', UNDERSCORE);
589
+ tt(Start, '\\', BACKSLASH);
590
+ const Num = tr(Start, DIGIT, NUM, {
591
+ [numeric]: true
592
+ });
593
+ tr(Num, DIGIT, Num);
594
+
595
+ // State which emits a word token
596
+ const Word = tr(Start, ASCII_LETTER, WORD, {
597
+ [ascii]: true
598
+ });
599
+ tr(Word, ASCII_LETTER, Word);
600
+
601
+ // Same as previous, but specific to non-fsm.ascii alphabet words
602
+ const UWord = tr(Start, LETTER, UWORD, {
603
+ [alpha]: true
604
+ });
605
+ tr(UWord, ASCII_LETTER); // Non-accepting
606
+ tr(UWord, LETTER, UWord);
607
+
608
+ // Whitespace jumps
609
+ // Tokens of only non-newline whitespace are arbitrarily long
610
+ // If any whitespace except newline, more whitespace!
611
+ const Ws = tr(Start, SPACE, WS, {
612
+ [whitespace]: true
613
+ });
614
+ tt(Start, NL, NL$1, {
615
+ [whitespace]: true
616
+ });
617
+ tt(Ws, NL); // non-accepting state to avoid mixing whitespaces
618
+ tr(Ws, SPACE, Ws);
619
+
620
+ // Emoji tokens. They are not grouped by the scanner except in cases where a
621
+ // zero-width joiner is present
622
+ const Emoji = tr(Start, EMOJI, EMOJI$1, {
623
+ [emoji]: true
624
+ });
625
+ tr(Emoji, EMOJI, Emoji);
626
+ tt(Emoji, EMOJI_VARIATION, Emoji);
627
+ // tt(Start, EMOJI_VARIATION, Emoji); // This one is sketchy
628
+
629
+ const EmojiJoiner = tt(Emoji, EMOJI_JOINER);
630
+ tr(EmojiJoiner, EMOJI, Emoji);
631
+ // tt(EmojiJoiner, EMOJI_VARIATION, Emoji); // also sketchy
632
+
633
+ // Generates states for top-level domains
634
+ // Note that this is most accurate when tlds are in alphabetical order
635
+ const wordjr = [[ASCII_LETTER, Word]];
636
+ const uwordjr = [[ASCII_LETTER, null], [LETTER, UWord]];
637
+ for (let i = 0; i < tlds.length; i++) {
638
+ fastts(Start, tlds[i], TLD, WORD, wordjr);
639
+ }
640
+ for (let i = 0; i < utlds.length; i++) {
641
+ fastts(Start, utlds[i], UTLD, UWORD, uwordjr);
642
+ }
643
+ addToGroups(TLD, {
644
+ tld: true,
645
+ ascii: true
646
+ }, groups);
647
+ addToGroups(UTLD, {
648
+ utld: true,
649
+ alpha: true
650
+ }, groups);
651
+
652
+ // Collect the states generated by different protocols. NOTE: If any new TLDs
653
+ // get added that are also protocols, set the token to be the same as the
654
+ // protocol to ensure parsing works as expected.
655
+ fastts(Start, 'file', SCHEME, WORD, wordjr);
656
+ fastts(Start, 'mailto', SCHEME, WORD, wordjr);
657
+ fastts(Start, 'http', SLASH_SCHEME, WORD, wordjr);
658
+ fastts(Start, 'https', SLASH_SCHEME, WORD, wordjr);
659
+ fastts(Start, 'ftp', SLASH_SCHEME, WORD, wordjr);
660
+ fastts(Start, 'ftps', SLASH_SCHEME, WORD, wordjr);
661
+ addToGroups(SCHEME, {
662
+ scheme: true,
663
+ ascii: true
664
+ }, groups);
665
+ addToGroups(SLASH_SCHEME, {
666
+ slashscheme: true,
667
+ ascii: true
668
+ }, groups);
669
+
670
+ // Register custom schemes. Assumes each scheme is asciinumeric with hyphens
671
+ customSchemes = customSchemes.sort((a, b) => a[0] > b[0] ? 1 : -1);
672
+ for (let i = 0; i < customSchemes.length; i++) {
673
+ const sch = customSchemes[i][0];
674
+ const optionalSlashSlash = customSchemes[i][1];
675
+ const flags = optionalSlashSlash ? {
676
+ [scheme]: true
677
+ } : {
678
+ [slashscheme]: true
679
+ };
680
+ if (sch.indexOf('-') >= 0) {
681
+ flags[domain] = true;
682
+ } else if (!ASCII_LETTER.test(sch)) {
683
+ flags[numeric] = true; // numbers only
684
+ } else if (DIGIT.test(sch)) {
685
+ flags[asciinumeric] = true;
686
+ } else {
687
+ flags[ascii] = true;
688
+ }
689
+ ts(Start, sch, sch, flags);
690
+ }
691
+
692
+ // Localhost token
693
+ ts(Start, 'localhost', LOCALHOST, {
694
+ ascii: true
695
+ });
696
+
697
+ // Set default transition for start state (some symbol)
698
+ Start.jd = new State(SYM);
699
+ return {
700
+ start: Start,
701
+ tokens: assign({
702
+ groups
703
+ }, tk)
704
+ };
705
+ }
706
+
707
+ /**
708
+ Given a string, returns an array of TOKEN instances representing the
709
+ composition of that string.
710
+
711
+ @method run
712
+ @param {State<string>} start scanner starting state
713
+ @param {string} str input string to scan
714
+ @return {Token[]} list of tokens, each with a type and value
715
+ */
716
+ function run$1(start, str) {
717
+ // State machine is not case sensitive, so input is tokenized in lowercased
718
+ // form (still returns regular case). Uses selective `toLowerCase` because
719
+ // lowercasing the entire string causes the length and character position to
720
+ // vary in some non-English strings with V8-based runtimes.
721
+ const iterable = stringToArray(str.replace(/[A-Z]/g, c => c.toLowerCase()));
722
+ const charCount = iterable.length; // <= len if there are emojis, etc
723
+ const tokens = []; // return value
724
+
725
+ // cursor through the string itself, accounting for characters that have
726
+ // width with length 2 such as emojis
727
+ let cursor = 0;
728
+
729
+ // Cursor through the array-representation of the string
730
+ let charCursor = 0;
731
+
732
+ // Tokenize the string
733
+ while (charCursor < charCount) {
734
+ let state = start;
735
+ let nextState = null;
736
+ let tokenLength = 0;
737
+ let latestAccepting = null;
738
+ let sinceAccepts = -1;
739
+ let charsSinceAccepts = -1;
740
+ while (charCursor < charCount && (nextState = state.go(iterable[charCursor]))) {
741
+ state = nextState;
742
+
743
+ // Keep track of the latest accepting state
744
+ if (state.accepts()) {
745
+ sinceAccepts = 0;
746
+ charsSinceAccepts = 0;
747
+ latestAccepting = state;
748
+ } else if (sinceAccepts >= 0) {
749
+ sinceAccepts += iterable[charCursor].length;
750
+ charsSinceAccepts++;
751
+ }
752
+ tokenLength += iterable[charCursor].length;
753
+ cursor += iterable[charCursor].length;
754
+ charCursor++;
755
+ }
756
+
757
+ // Roll back to the latest accepting state
758
+ cursor -= sinceAccepts;
759
+ charCursor -= charsSinceAccepts;
760
+ tokenLength -= sinceAccepts;
761
+
762
+ // No more jumps, just make a new token from the last accepting one
763
+ tokens.push({
764
+ t: latestAccepting.t,
765
+ // token type/name
766
+ v: str.slice(cursor - tokenLength, cursor),
767
+ // string value
768
+ s: cursor - tokenLength,
769
+ // start index
770
+ e: cursor // end index (excluding)
771
+ });
772
+ }
773
+
774
+ return tokens;
775
+ }
776
+
777
+ /**
778
+ * Convert a String to an Array of characters, taking into account that some
779
+ * characters like emojis take up two string indexes.
780
+ *
781
+ * Adapted from core-js (MIT license)
782
+ * https://github.com/zloirock/core-js/blob/2d69cf5f99ab3ea3463c395df81e5a15b68f49d9/packages/core-js/internals/string-multibyte.js
783
+ *
784
+ * @function stringToArray
785
+ * @param {string} str
786
+ * @returns {string[]}
787
+ */
788
+ function stringToArray(str) {
789
+ const result = [];
790
+ const len = str.length;
791
+ let index = 0;
792
+ while (index < len) {
793
+ let first = str.charCodeAt(index);
794
+ let second;
795
+ let char = first < 0xd800 || first > 0xdbff || index + 1 === len || (second = str.charCodeAt(index + 1)) < 0xdc00 || second > 0xdfff ? str[index] // single character
796
+ : str.slice(index, index + 2); // two-index characters
797
+ result.push(char);
798
+ index += char.length;
799
+ }
800
+ return result;
801
+ }
802
+
803
+ /**
804
+ * Fast version of ts function for when transition defaults are well known
805
+ * @param {State<string>} state
806
+ * @param {string} input
807
+ * @param {string} t
808
+ * @param {string} defaultt
809
+ * @param {[RegExp, State<string>][]} jr
810
+ * @returns {State<string>}
811
+ */
812
+ function fastts(state, input, t, defaultt, jr) {
813
+ let next;
814
+ const len = input.length;
815
+ for (let i = 0; i < len - 1; i++) {
816
+ const char = input[i];
817
+ if (state.j[char]) {
818
+ next = state.j[char];
819
+ } else {
820
+ next = new State(defaultt);
821
+ next.jr = jr.slice();
822
+ state.j[char] = next;
823
+ }
824
+ state = next;
825
+ }
826
+ next = new State(t);
827
+ next.jr = jr.slice();
828
+ state.j[input[len - 1]] = next;
829
+ return next;
830
+ }
831
+
832
+ /**
833
+ * Converts a string of Top-Level Domain names encoded in update-tlds.js back
834
+ * into a list of strings.
835
+ * @param {str} encoded encoded TLDs string
836
+ * @returns {str[]} original TLDs list
837
+ */
838
+ function decodeTlds(encoded) {
839
+ const words = [];
840
+ const stack = [];
841
+ let i = 0;
842
+ let digits = '0123456789';
843
+ while (i < encoded.length) {
844
+ let popDigitCount = 0;
845
+ while (digits.indexOf(encoded[i + popDigitCount]) >= 0) {
846
+ popDigitCount++; // encountered some digits, have to pop to go one level up trie
847
+ }
848
+
849
+ if (popDigitCount > 0) {
850
+ words.push(stack.join('')); // whatever preceded the pop digits must be a word
851
+ for (let popCount = parseInt(encoded.substring(i, i + popDigitCount), 10); popCount > 0; popCount--) {
852
+ stack.pop();
853
+ }
854
+ i += popDigitCount;
855
+ } else {
856
+ stack.push(encoded[i]); // drop down a level into the trie
857
+ i++;
858
+ }
859
+ }
860
+ return words;
861
+ }
862
+
863
+ /**
864
+ * An object where each key is a valid DOM Event Name such as `click` or `focus`
865
+ * and each value is an event handler function.
866
+ *
867
+ * https://developer.mozilla.org/en-US/docs/Web/API/Element#events
868
+ * @typedef {?{ [event: string]: Function }} EventListeners
869
+ */
870
+
871
+ /**
872
+ * All formatted properties required to render a link, including `tagName`,
873
+ * `attributes`, `content` and `eventListeners`.
874
+ * @typedef {{ tagName: any, attributes: {[attr: string]: any}, content: string,
875
+ * eventListeners: EventListeners }} IntermediateRepresentation
876
+ */
877
+
878
+ /**
879
+ * Specify either an object described by the template type `O` or a function.
880
+ *
881
+ * The function takes a string value (usually the link's href attribute), the
882
+ * link type (`'url'`, `'hashtag`', etc.) and an internal token representation
883
+ * of the link. It should return an object of the template type `O`
884
+ * @template O
885
+ * @typedef {O | ((value: string, type: string, token: MultiToken) => O)} OptObj
886
+ */
887
+
888
+ /**
889
+ * Specify either a function described by template type `F` or an object.
890
+ *
891
+ * Each key in the object should be a link type (`'url'`, `'hashtag`', etc.). Each
892
+ * value should be a function with template type `F` that is called when the
893
+ * corresponding link type is encountered.
894
+ * @template F
895
+ * @typedef {F | { [type: string]: F}} OptFn
896
+ */
897
+
898
+ /**
899
+ * Specify either a value with template type `V`, a function that returns `V` or
900
+ * an object where each value resolves to `V`.
901
+ *
902
+ * The function takes a string value (usually the link's href attribute), the
903
+ * link type (`'url'`, `'hashtag`', etc.) and an internal token representation
904
+ * of the link. It should return an object of the template type `V`
905
+ *
906
+ * For the object, each key should be a link type (`'url'`, `'hashtag`', etc.).
907
+ * Each value should either have type `V` or a function that returns V. This
908
+ * function similarly takes a string value and a token.
909
+ *
910
+ * Example valid types for `Opt<string>`:
911
+ *
912
+ * ```js
913
+ * 'hello'
914
+ * (value, type, token) => 'world'
915
+ * { url: 'hello', email: (value, token) => 'world'}
916
+ * ```
917
+ * @template V
918
+ * @typedef {V | ((value: string, type: string, token: MultiToken) => V) | { [type: string]: V | ((value: string, token: MultiToken) => V) }} Opt
919
+ */
920
+
921
+ /**
922
+ * See available options: https://linkify.js.org/docs/options.html
923
+ * @typedef {{
924
+ * defaultProtocol?: string,
925
+ * events?: OptObj<EventListeners>,
926
+ * format?: Opt<string>,
927
+ * formatHref?: Opt<string>,
928
+ * nl2br?: boolean,
929
+ * tagName?: Opt<any>,
930
+ * target?: Opt<string>,
931
+ * rel?: Opt<string>,
932
+ * validate?: Opt<boolean>,
933
+ * truncate?: Opt<number>,
934
+ * className?: Opt<string>,
935
+ * attributes?: OptObj<({ [attr: string]: any })>,
936
+ * ignoreTags?: string[],
937
+ * render?: OptFn<((ir: IntermediateRepresentation) => any)>
938
+ * }} Opts
939
+ */
940
+
941
+ /**
942
+ * @type Required<Opts>
943
+ */
944
+ const defaults = {
945
+ defaultProtocol: 'http',
946
+ events: null,
947
+ format: noop,
948
+ formatHref: noop,
949
+ nl2br: false,
950
+ tagName: 'a',
951
+ target: null,
952
+ rel: null,
953
+ validate: true,
954
+ truncate: Infinity,
955
+ className: null,
956
+ attributes: null,
957
+ ignoreTags: [],
958
+ render: null
959
+ };
960
+
961
+ /**
962
+ * Utility class for linkify interfaces to apply specified
963
+ * {@link Opts formatting and rendering options}.
964
+ *
965
+ * @param {Opts | Options} [opts] Option value overrides.
966
+ * @param {(ir: IntermediateRepresentation) => any} [defaultRender] (For
967
+ * internal use) default render function that determines how to generate an
968
+ * HTML element based on a link token's derived tagName, attributes and HTML.
969
+ * Similar to render option
970
+ */
971
+ function Options(opts, defaultRender) {
972
+ if (defaultRender === void 0) {
973
+ defaultRender = null;
974
+ }
975
+ let o = assign({}, defaults);
976
+ if (opts) {
977
+ o = assign(o, opts instanceof Options ? opts.o : opts);
978
+ }
979
+
980
+ // Ensure all ignored tags are uppercase
981
+ const ignoredTags = o.ignoreTags;
982
+ const uppercaseIgnoredTags = [];
983
+ for (let i = 0; i < ignoredTags.length; i++) {
984
+ uppercaseIgnoredTags.push(ignoredTags[i].toUpperCase());
985
+ }
986
+ /** @protected */
987
+ this.o = o;
988
+ if (defaultRender) {
989
+ this.defaultRender = defaultRender;
990
+ }
991
+ this.ignoreTags = uppercaseIgnoredTags;
992
+ }
993
+ Options.prototype = {
994
+ o: defaults,
995
+ /**
996
+ * @type string[]
997
+ */
998
+ ignoreTags: [],
999
+ /**
1000
+ * @param {IntermediateRepresentation} ir
1001
+ * @returns {any}
1002
+ */
1003
+ defaultRender(ir) {
1004
+ return ir;
1005
+ },
1006
+ /**
1007
+ * Returns true or false based on whether a token should be displayed as a
1008
+ * link based on the user options.
1009
+ * @param {MultiToken} token
1010
+ * @returns {boolean}
1011
+ */
1012
+ check(token) {
1013
+ return this.get('validate', token.toString(), token);
1014
+ },
1015
+ // Private methods
1016
+
1017
+ /**
1018
+ * Resolve an option's value based on the value of the option and the given
1019
+ * params. If operator and token are specified and the target option is
1020
+ * callable, automatically calls the function with the given argument.
1021
+ * @template {keyof Opts} K
1022
+ * @param {K} key Name of option to use
1023
+ * @param {string} [operator] will be passed to the target option if it's a
1024
+ * function. If not specified, RAW function value gets returned
1025
+ * @param {MultiToken} [token] The token from linkify.tokenize
1026
+ * @returns {Opts[K] | any}
1027
+ */
1028
+ get(key, operator, token) {
1029
+ const isCallable = operator != null;
1030
+ let option = this.o[key];
1031
+ if (!option) {
1032
+ return option;
1033
+ }
1034
+ if (typeof option === 'object') {
1035
+ option = token.t in option ? option[token.t] : defaults[key];
1036
+ if (typeof option === 'function' && isCallable) {
1037
+ option = option(operator, token);
1038
+ }
1039
+ } else if (typeof option === 'function' && isCallable) {
1040
+ option = option(operator, token.t, token);
1041
+ }
1042
+ return option;
1043
+ },
1044
+ /**
1045
+ * @template {keyof Opts} L
1046
+ * @param {L} key Name of options object to use
1047
+ * @param {string} [operator]
1048
+ * @param {MultiToken} [token]
1049
+ * @returns {Opts[L] | any}
1050
+ */
1051
+ getObj(key, operator, token) {
1052
+ let obj = this.o[key];
1053
+ if (typeof obj === 'function' && operator != null) {
1054
+ obj = obj(operator, token.t, token);
1055
+ }
1056
+ return obj;
1057
+ },
1058
+ /**
1059
+ * Convert the given token to a rendered element that may be added to the
1060
+ * calling-interface's DOM
1061
+ * @param {MultiToken} token Token to render to an HTML element
1062
+ * @returns {any} Render result; e.g., HTML string, DOM element, React
1063
+ * Component, etc.
1064
+ */
1065
+ render(token) {
1066
+ const ir = token.render(this); // intermediate representation
1067
+ const renderFn = this.get('render', null, token) || this.defaultRender;
1068
+ return renderFn(ir, token.t, token);
1069
+ }
1070
+ };
1071
+ function noop(val) {
1072
+ return val;
1073
+ }
1074
+
1075
+ var options = /*#__PURE__*/Object.freeze({
1076
+ __proto__: null,
1077
+ defaults: defaults,
1078
+ Options: Options,
1079
+ assign: assign
1080
+ });
1081
+
1082
+ /******************************************************************************
1083
+ Multi-Tokens
1084
+ Tokens composed of arrays of TextTokens
1085
+ ******************************************************************************/
1086
+
1087
+ /**
1088
+ * @param {string} value
1089
+ * @param {Token[]} tokens
1090
+ */
1091
+ function MultiToken(value, tokens) {
1092
+ this.t = 'token';
1093
+ this.v = value;
1094
+ this.tk = tokens;
1095
+ }
1096
+
1097
+ /**
1098
+ * Abstract class used for manufacturing tokens of text tokens. That is rather
1099
+ * than the value for a token being a small string of text, it's value an array
1100
+ * of text tokens.
1101
+ *
1102
+ * Used for grouping together URLs, emails, hashtags, and other potential
1103
+ * creations.
1104
+ * @class MultiToken
1105
+ * @property {string} t
1106
+ * @property {string} v
1107
+ * @property {Token[]} tk
1108
+ * @abstract
1109
+ */
1110
+ MultiToken.prototype = {
1111
+ isLink: false,
1112
+ /**
1113
+ * Return the string this token represents.
1114
+ * @return {string}
1115
+ */
1116
+ toString() {
1117
+ return this.v;
1118
+ },
1119
+ /**
1120
+ * What should the value for this token be in the `href` HTML attribute?
1121
+ * Returns the `.toString` value by default.
1122
+ * @param {string} [scheme]
1123
+ * @return {string}
1124
+ */
1125
+ toHref(scheme) {
1126
+ return this.toString();
1127
+ },
1128
+ /**
1129
+ * @param {Options} options Formatting options
1130
+ * @returns {string}
1131
+ */
1132
+ toFormattedString(options) {
1133
+ const val = this.toString();
1134
+ const truncate = options.get('truncate', val, this);
1135
+ const formatted = options.get('format', val, this);
1136
+ return truncate && formatted.length > truncate ? formatted.substring(0, truncate) + '…' : formatted;
1137
+ },
1138
+ /**
1139
+ *
1140
+ * @param {Options} options
1141
+ * @returns {string}
1142
+ */
1143
+ toFormattedHref(options) {
1144
+ return options.get('formatHref', this.toHref(options.get('defaultProtocol')), this);
1145
+ },
1146
+ /**
1147
+ * The start index of this token in the original input string
1148
+ * @returns {number}
1149
+ */
1150
+ startIndex() {
1151
+ return this.tk[0].s;
1152
+ },
1153
+ /**
1154
+ * The end index of this token in the original input string (up to this
1155
+ * index but not including it)
1156
+ * @returns {number}
1157
+ */
1158
+ endIndex() {
1159
+ return this.tk[this.tk.length - 1].e;
1160
+ },
1161
+ /**
1162
+ Returns an object of relevant values for this token, which includes keys
1163
+ * type - Kind of token ('url', 'email', etc.)
1164
+ * value - Original text
1165
+ * href - The value that should be added to the anchor tag's href
1166
+ attribute
1167
+ @method toObject
1168
+ @param {string} [protocol] `'http'` by default
1169
+ */
1170
+ toObject(protocol) {
1171
+ if (protocol === void 0) {
1172
+ protocol = defaults.defaultProtocol;
1173
+ }
1174
+ return {
1175
+ type: this.t,
1176
+ value: this.toString(),
1177
+ isLink: this.isLink,
1178
+ href: this.toHref(protocol),
1179
+ start: this.startIndex(),
1180
+ end: this.endIndex()
1181
+ };
1182
+ },
1183
+ /**
1184
+ *
1185
+ * @param {Options} options Formatting option
1186
+ */
1187
+ toFormattedObject(options) {
1188
+ return {
1189
+ type: this.t,
1190
+ value: this.toFormattedString(options),
1191
+ isLink: this.isLink,
1192
+ href: this.toFormattedHref(options),
1193
+ start: this.startIndex(),
1194
+ end: this.endIndex()
1195
+ };
1196
+ },
1197
+ /**
1198
+ * Whether this token should be rendered as a link according to the given options
1199
+ * @param {Options} options
1200
+ * @returns {boolean}
1201
+ */
1202
+ validate(options) {
1203
+ return options.get('validate', this.toString(), this);
1204
+ },
1205
+ /**
1206
+ * Return an object that represents how this link should be rendered.
1207
+ * @param {Options} options Formattinng options
1208
+ */
1209
+ render(options) {
1210
+ const token = this;
1211
+ const href = this.toHref(options.get('defaultProtocol'));
1212
+ const formattedHref = options.get('formatHref', href, this);
1213
+ const tagName = options.get('tagName', href, token);
1214
+ const content = this.toFormattedString(options);
1215
+ const attributes = {};
1216
+ const className = options.get('className', href, token);
1217
+ const target = options.get('target', href, token);
1218
+ const rel = options.get('rel', href, token);
1219
+ const attrs = options.getObj('attributes', href, token);
1220
+ const eventListeners = options.getObj('events', href, token);
1221
+ attributes.href = formattedHref;
1222
+ if (className) {
1223
+ attributes.class = className;
1224
+ }
1225
+ if (target) {
1226
+ attributes.target = target;
1227
+ }
1228
+ if (rel) {
1229
+ attributes.rel = rel;
1230
+ }
1231
+ if (attrs) {
1232
+ assign(attributes, attrs);
1233
+ }
1234
+ return {
1235
+ tagName,
1236
+ attributes,
1237
+ content,
1238
+ eventListeners
1239
+ };
1240
+ }
1241
+ };
1242
+
1243
+ /**
1244
+ * Create a new token that can be emitted by the parser state machine
1245
+ * @param {string} type readable type of the token
1246
+ * @param {object} props properties to assign or override, including isLink = true or false
1247
+ * @returns {new (value: string, tokens: Token[]) => MultiToken} new token class
1248
+ */
1249
+ function createTokenClass(type, props) {
1250
+ class Token extends MultiToken {
1251
+ constructor(value, tokens) {
1252
+ super(value, tokens);
1253
+ this.t = type;
1254
+ }
1255
+ }
1256
+ for (const p in props) {
1257
+ Token.prototype[p] = props[p];
1258
+ }
1259
+ Token.t = type;
1260
+ return Token;
1261
+ }
1262
+
1263
+ /**
1264
+ Represents a list of tokens making up a valid email address
1265
+ */
1266
+ const Email = createTokenClass('email', {
1267
+ isLink: true,
1268
+ toHref() {
1269
+ return 'mailto:' + this.toString();
1270
+ }
1271
+ });
1272
+
1273
+ /**
1274
+ Represents some plain text
1275
+ */
1276
+ const Text = createTokenClass('text');
1277
+
1278
+ /**
1279
+ Multi-linebreak token - represents a line break
1280
+ @class Nl
1281
+ */
1282
+ const Nl = createTokenClass('nl');
1283
+
1284
+ /**
1285
+ Represents a list of text tokens making up a valid URL
1286
+ @class Url
1287
+ */
1288
+ const Url = createTokenClass('url', {
1289
+ isLink: true,
1290
+ /**
1291
+ Lowercases relevant parts of the domain and adds the protocol if
1292
+ required. Note that this will not escape unsafe HTML characters in the
1293
+ URL.
1294
+ @param {string} [scheme] default scheme (e.g., 'https')
1295
+ @return {string} the full href
1296
+ */
1297
+ toHref(scheme) {
1298
+ if (scheme === void 0) {
1299
+ scheme = defaults.defaultProtocol;
1300
+ }
1301
+ // Check if already has a prefix scheme
1302
+ return this.hasProtocol() ? this.v : `${scheme}://${this.v}`;
1303
+ },
1304
+ /**
1305
+ * Check whether this URL token has a protocol
1306
+ * @return {boolean}
1307
+ */
1308
+ hasProtocol() {
1309
+ const tokens = this.tk;
1310
+ return tokens.length >= 2 && tokens[0].t !== LOCALHOST && tokens[1].t === COLON;
1311
+ }
1312
+ });
1313
+
1314
+ /**
1315
+ Not exactly parser, more like the second-stage scanner (although we can
1316
+ theoretically hotswap the code here with a real parser in the future... but
1317
+ for a little URL-finding utility abstract syntax trees may be a little
1318
+ overkill).
1319
+
1320
+ URL format: http://en.wikipedia.org/wiki/URI_scheme
1321
+ Email format: http://en.wikipedia.org/wiki/EmailAddress (links to RFC in
1322
+ reference)
1323
+
1324
+ @module linkify
1325
+ @submodule parser
1326
+ @main run
1327
+ */
1328
+ const makeState = arg => new State(arg);
1329
+
1330
+ /**
1331
+ * Generate the parser multi token-based state machine
1332
+ * @param {{ groups: Collections<string> }} tokens
1333
+ */
1334
+ function init$1(_ref) {
1335
+ let {
1336
+ groups
1337
+ } = _ref;
1338
+ // Types of characters the URL can definitely end in
1339
+ const qsAccepting = groups.domain.concat([AMPERSAND, ASTERISK, AT, BACKSLASH, BACKTICK, CARET, DOLLAR, EQUALS, HYPHEN, NUM, PERCENT, PIPE, PLUS, POUND, SLASH, SYM, TILDE, UNDERSCORE]);
1340
+
1341
+ // Types of tokens that can follow a URL and be part of the query string
1342
+ // but cannot be the very last characters
1343
+ // Characters that cannot appear in the URL at all should be excluded
1344
+ const qsNonAccepting = [APOSTROPHE, CLOSEANGLEBRACKET, CLOSEBRACE, CLOSEBRACKET, CLOSEPAREN, COLON, COMMA, DOT, EXCLAMATION, OPENANGLEBRACKET, OPENBRACE, OPENBRACKET, OPENPAREN, QUERY, QUOTE, SEMI];
1345
+
1346
+ // For addresses without the mailto prefix
1347
+ // Tokens allowed in the localpart of the email
1348
+ const localpartAccepting = [AMPERSAND, APOSTROPHE, ASTERISK, BACKSLASH, BACKTICK, CARET, CLOSEBRACE, DOLLAR, EQUALS, HYPHEN, OPENBRACE, PERCENT, PIPE, PLUS, POUND, QUERY, SLASH, SYM, TILDE, UNDERSCORE];
1349
+
1350
+ // The universal starting state.
1351
+ /**
1352
+ * @type State<Token>
1353
+ */
1354
+ const Start = makeState();
1355
+ const Localpart = tt(Start, TILDE); // Local part of the email address
1356
+ ta(Localpart, localpartAccepting, Localpart);
1357
+ ta(Localpart, groups.domain, Localpart);
1358
+ const Domain = makeState(),
1359
+ Scheme = makeState(),
1360
+ SlashScheme = makeState();
1361
+ ta(Start, groups.domain, Domain); // parsed string ends with a potential domain name (A)
1362
+ ta(Start, groups.scheme, Scheme); // e.g., 'mailto'
1363
+ ta(Start, groups.slashscheme, SlashScheme); // e.g., 'http'
1364
+
1365
+ ta(Domain, localpartAccepting, Localpart);
1366
+ ta(Domain, groups.domain, Domain);
1367
+ const LocalpartAt = tt(Domain, AT); // Local part of the email address plus @
1368
+
1369
+ tt(Localpart, AT, LocalpartAt); // close to an email address now
1370
+
1371
+ // Local part of an email address can be e.g. 'http' or 'mailto'
1372
+ tt(Scheme, AT, LocalpartAt);
1373
+ tt(SlashScheme, AT, LocalpartAt);
1374
+ const LocalpartDot = tt(Localpart, DOT); // Local part of the email address plus '.' (localpart cannot end in .)
1375
+ ta(LocalpartDot, localpartAccepting, Localpart);
1376
+ ta(LocalpartDot, groups.domain, Localpart);
1377
+ const EmailDomain = makeState();
1378
+ ta(LocalpartAt, groups.domain, EmailDomain); // parsed string starts with local email info + @ with a potential domain name
1379
+ ta(EmailDomain, groups.domain, EmailDomain);
1380
+ const EmailDomainDot = tt(EmailDomain, DOT); // domain followed by DOT
1381
+ ta(EmailDomainDot, groups.domain, EmailDomain);
1382
+ const Email$1 = makeState(Email); // Possible email address (could have more tlds)
1383
+ ta(EmailDomainDot, groups.tld, Email$1);
1384
+ ta(EmailDomainDot, groups.utld, Email$1);
1385
+ tt(LocalpartAt, LOCALHOST, Email$1);
1386
+
1387
+ // Hyphen can jump back to a domain name
1388
+ const EmailDomainHyphen = tt(EmailDomain, HYPHEN); // parsed string starts with local email info + @ with a potential domain name
1389
+ ta(EmailDomainHyphen, groups.domain, EmailDomain);
1390
+ ta(Email$1, groups.domain, EmailDomain);
1391
+ tt(Email$1, DOT, EmailDomainDot);
1392
+ tt(Email$1, HYPHEN, EmailDomainHyphen);
1393
+
1394
+ // Final possible email states
1395
+ const EmailColon = tt(Email$1, COLON); // URL followed by colon (potential port number here)
1396
+ /*const EmailColonPort = */
1397
+ ta(EmailColon, groups.numeric, Email); // URL followed by colon and port numner
1398
+
1399
+ // Account for dots and hyphens. Hyphens are usually parts of domain names
1400
+ // (but not TLDs)
1401
+ const DomainHyphen = tt(Domain, HYPHEN); // domain followed by hyphen
1402
+ const DomainDot = tt(Domain, DOT); // domain followed by DOT
1403
+ ta(DomainHyphen, groups.domain, Domain);
1404
+ ta(DomainDot, localpartAccepting, Localpart);
1405
+ ta(DomainDot, groups.domain, Domain);
1406
+ const DomainDotTld = makeState(Url); // Simplest possible URL with no query string
1407
+ ta(DomainDot, groups.tld, DomainDotTld);
1408
+ ta(DomainDot, groups.utld, DomainDotTld);
1409
+ ta(DomainDotTld, groups.domain, Domain);
1410
+ ta(DomainDotTld, localpartAccepting, Localpart);
1411
+ tt(DomainDotTld, DOT, DomainDot);
1412
+ tt(DomainDotTld, HYPHEN, DomainHyphen);
1413
+ tt(DomainDotTld, AT, LocalpartAt);
1414
+ const DomainDotTldColon = tt(DomainDotTld, COLON); // URL followed by colon (potential port number here)
1415
+ const DomainDotTldColonPort = makeState(Url); // TLD followed by a port number
1416
+ ta(DomainDotTldColon, groups.numeric, DomainDotTldColonPort);
1417
+
1418
+ // Long URL with optional port and maybe query string
1419
+ const Url$1 = makeState(Url);
1420
+
1421
+ // URL with extra symbols at the end, followed by an opening bracket
1422
+ const UrlNonaccept = makeState(); // URL followed by some symbols (will not be part of the final URL)
1423
+
1424
+ // Query strings
1425
+ ta(Url$1, qsAccepting, Url$1);
1426
+ ta(Url$1, qsNonAccepting, UrlNonaccept);
1427
+ ta(UrlNonaccept, qsAccepting, Url$1);
1428
+ ta(UrlNonaccept, qsNonAccepting, UrlNonaccept);
1429
+
1430
+ // Become real URLs after `SLASH` or `COLON NUM SLASH`
1431
+ // Here works with or without scheme:// prefix
1432
+ tt(DomainDotTld, SLASH, Url$1);
1433
+ tt(DomainDotTldColonPort, SLASH, Url$1);
1434
+
1435
+ // Note that domains that begin with schemes are treated slighly differently
1436
+ const SchemeColon = tt(Scheme, COLON); // e.g., 'mailto:'
1437
+ const SlashSchemeColon = tt(SlashScheme, COLON); // e.g., 'http:'
1438
+ const SlashSchemeColonSlash = tt(SlashSchemeColon, SLASH); // e.g., 'http:/'
1439
+
1440
+ const UriPrefix = tt(SlashSchemeColonSlash, SLASH); // e.g., 'http://'
1441
+
1442
+ // Scheme states can transition to domain states
1443
+ ta(Scheme, groups.domain, Domain);
1444
+ tt(Scheme, DOT, DomainDot);
1445
+ tt(Scheme, HYPHEN, DomainHyphen);
1446
+ ta(SlashScheme, groups.domain, Domain);
1447
+ tt(SlashScheme, DOT, DomainDot);
1448
+ tt(SlashScheme, HYPHEN, DomainHyphen);
1449
+
1450
+ // Force URL with scheme prefix followed by anything sane
1451
+ ta(SchemeColon, groups.domain, Url$1);
1452
+ tt(SchemeColon, SLASH, Url$1);
1453
+ ta(UriPrefix, groups.domain, Url$1);
1454
+ ta(UriPrefix, qsAccepting, Url$1);
1455
+ tt(UriPrefix, SLASH, Url$1);
1456
+
1457
+ // URL, followed by an opening bracket
1458
+ const UrlOpenbrace = tt(Url$1, OPENBRACE); // URL followed by {
1459
+ const UrlOpenbracket = tt(Url$1, OPENBRACKET); // URL followed by [
1460
+ const UrlOpenanglebracket = tt(Url$1, OPENANGLEBRACKET); // URL followed by <
1461
+ const UrlOpenparen = tt(Url$1, OPENPAREN); // URL followed by (
1462
+
1463
+ tt(UrlNonaccept, OPENBRACE, UrlOpenbrace);
1464
+ tt(UrlNonaccept, OPENBRACKET, UrlOpenbracket);
1465
+ tt(UrlNonaccept, OPENANGLEBRACKET, UrlOpenanglebracket);
1466
+ tt(UrlNonaccept, OPENPAREN, UrlOpenparen);
1467
+
1468
+ // Closing bracket component. This character WILL be included in the URL
1469
+ tt(UrlOpenbrace, CLOSEBRACE, Url$1);
1470
+ tt(UrlOpenbracket, CLOSEBRACKET, Url$1);
1471
+ tt(UrlOpenanglebracket, CLOSEANGLEBRACKET, Url$1);
1472
+ tt(UrlOpenparen, CLOSEPAREN, Url$1);
1473
+ tt(UrlOpenbrace, CLOSEBRACE, Url$1);
1474
+
1475
+ // URL that beings with an opening bracket, followed by a symbols.
1476
+ // Note that the final state can still be `UrlOpenbrace` (if the URL only
1477
+ // has a single opening bracket for some reason).
1478
+ const UrlOpenbraceQ = makeState(Url); // URL followed by { and some symbols that the URL can end it
1479
+ const UrlOpenbracketQ = makeState(Url); // URL followed by [ and some symbols that the URL can end it
1480
+ const UrlOpenanglebracketQ = makeState(Url); // URL followed by < and some symbols that the URL can end it
1481
+ const UrlOpenparenQ = makeState(Url); // URL followed by ( and some symbols that the URL can end it
1482
+ ta(UrlOpenbrace, qsAccepting, UrlOpenbraceQ);
1483
+ ta(UrlOpenbracket, qsAccepting, UrlOpenbracketQ);
1484
+ ta(UrlOpenanglebracket, qsAccepting, UrlOpenanglebracketQ);
1485
+ ta(UrlOpenparen, qsAccepting, UrlOpenparenQ);
1486
+ const UrlOpenbraceSyms = makeState(); // UrlOpenbrace followed by some symbols it cannot end it
1487
+ const UrlOpenbracketSyms = makeState(); // UrlOpenbracketQ followed by some symbols it cannot end it
1488
+ const UrlOpenanglebracketSyms = makeState(); // UrlOpenanglebracketQ followed by some symbols it cannot end it
1489
+ const UrlOpenparenSyms = makeState(); // UrlOpenparenQ followed by some symbols it cannot end it
1490
+ ta(UrlOpenbrace, qsNonAccepting);
1491
+ ta(UrlOpenbracket, qsNonAccepting);
1492
+ ta(UrlOpenanglebracket, qsNonAccepting);
1493
+ ta(UrlOpenparen, qsNonAccepting);
1494
+
1495
+ // URL that begins with an opening bracket, followed by some symbols
1496
+ ta(UrlOpenbraceQ, qsAccepting, UrlOpenbraceQ);
1497
+ ta(UrlOpenbracketQ, qsAccepting, UrlOpenbracketQ);
1498
+ ta(UrlOpenanglebracketQ, qsAccepting, UrlOpenanglebracketQ);
1499
+ ta(UrlOpenparenQ, qsAccepting, UrlOpenparenQ);
1500
+ ta(UrlOpenbraceQ, qsNonAccepting, UrlOpenbraceQ);
1501
+ ta(UrlOpenbracketQ, qsNonAccepting, UrlOpenbracketQ);
1502
+ ta(UrlOpenanglebracketQ, qsNonAccepting, UrlOpenanglebracketQ);
1503
+ ta(UrlOpenparenQ, qsNonAccepting, UrlOpenparenQ);
1504
+ ta(UrlOpenbraceSyms, qsAccepting, UrlOpenbraceSyms);
1505
+ ta(UrlOpenbracketSyms, qsAccepting, UrlOpenbracketQ);
1506
+ ta(UrlOpenanglebracketSyms, qsAccepting, UrlOpenanglebracketQ);
1507
+ ta(UrlOpenparenSyms, qsAccepting, UrlOpenparenQ);
1508
+ ta(UrlOpenbraceSyms, qsNonAccepting, UrlOpenbraceSyms);
1509
+ ta(UrlOpenbracketSyms, qsNonAccepting, UrlOpenbracketSyms);
1510
+ ta(UrlOpenanglebracketSyms, qsNonAccepting, UrlOpenanglebracketSyms);
1511
+ ta(UrlOpenparenSyms, qsNonAccepting, UrlOpenparenSyms);
1512
+
1513
+ // Close brace/bracket to become regular URL
1514
+ tt(UrlOpenbracketQ, CLOSEBRACKET, Url$1);
1515
+ tt(UrlOpenanglebracketQ, CLOSEANGLEBRACKET, Url$1);
1516
+ tt(UrlOpenparenQ, CLOSEPAREN, Url$1);
1517
+ tt(UrlOpenbraceQ, CLOSEBRACE, Url$1);
1518
+ tt(UrlOpenbracketSyms, CLOSEBRACKET, Url$1);
1519
+ tt(UrlOpenanglebracketSyms, CLOSEANGLEBRACKET, Url$1);
1520
+ tt(UrlOpenparenSyms, CLOSEPAREN, Url$1);
1521
+ tt(UrlOpenbraceSyms, CLOSEPAREN, Url$1);
1522
+ tt(Start, LOCALHOST, DomainDotTld); // localhost is a valid URL state
1523
+ tt(Start, NL$1, Nl); // single new line
1524
+
1525
+ return {
1526
+ start: Start,
1527
+ tokens: tk
1528
+ };
1529
+ }
1530
+
1531
+ /**
1532
+ * Run the parser state machine on a list of scanned string-based tokens to
1533
+ * create a list of multi tokens, each of which represents a URL, email address,
1534
+ * plain text, etc.
1535
+ *
1536
+ * @param {State<MultiToken>} start parser start state
1537
+ * @param {string} input the original input used to generate the given tokens
1538
+ * @param {Token[]} tokens list of scanned tokens
1539
+ * @returns {MultiToken[]}
1540
+ */
1541
+ function run(start, input, tokens) {
1542
+ let len = tokens.length;
1543
+ let cursor = 0;
1544
+ let multis = [];
1545
+ let textTokens = [];
1546
+ while (cursor < len) {
1547
+ let state = start;
1548
+ let secondState = null;
1549
+ let nextState = null;
1550
+ let multiLength = 0;
1551
+ let latestAccepting = null;
1552
+ let sinceAccepts = -1;
1553
+ while (cursor < len && !(secondState = state.go(tokens[cursor].t))) {
1554
+ // Starting tokens with nowhere to jump to.
1555
+ // Consider these to be just plain text
1556
+ textTokens.push(tokens[cursor++]);
1557
+ }
1558
+ while (cursor < len && (nextState = secondState || state.go(tokens[cursor].t))) {
1559
+ // Get the next state
1560
+ secondState = null;
1561
+ state = nextState;
1562
+
1563
+ // Keep track of the latest accepting state
1564
+ if (state.accepts()) {
1565
+ sinceAccepts = 0;
1566
+ latestAccepting = state;
1567
+ } else if (sinceAccepts >= 0) {
1568
+ sinceAccepts++;
1569
+ }
1570
+ cursor++;
1571
+ multiLength++;
1572
+ }
1573
+ if (sinceAccepts < 0) {
1574
+ // No accepting state was found, part of a regular text token add
1575
+ // the first text token to the text tokens array and try again from
1576
+ // the next
1577
+ cursor -= multiLength;
1578
+ if (cursor < len) {
1579
+ textTokens.push(tokens[cursor]);
1580
+ cursor++;
1581
+ }
1582
+ } else {
1583
+ // Accepting state!
1584
+ // First close off the textTokens (if available)
1585
+ if (textTokens.length > 0) {
1586
+ multis.push(initMultiToken(Text, input, textTokens));
1587
+ textTokens = [];
1588
+ }
1589
+
1590
+ // Roll back to the latest accepting state
1591
+ cursor -= sinceAccepts;
1592
+ multiLength -= sinceAccepts;
1593
+
1594
+ // Create a new multitoken
1595
+ const Multi = latestAccepting.t;
1596
+ const subtokens = tokens.slice(cursor - multiLength, cursor);
1597
+ multis.push(initMultiToken(Multi, input, subtokens));
1598
+ }
1599
+ }
1600
+
1601
+ // Finally close off the textTokens (if available)
1602
+ if (textTokens.length > 0) {
1603
+ multis.push(initMultiToken(Text, input, textTokens));
1604
+ }
1605
+ return multis;
1606
+ }
1607
+
1608
+ /**
1609
+ * Utility function for instantiating a new multitoken with all the relevant
1610
+ * fields during parsing.
1611
+ * @param {new (value: string, tokens: Token[]) => MultiToken} Multi class to instantiate
1612
+ * @param {string} input original input string
1613
+ * @param {Token[]} tokens consecutive tokens scanned from input string
1614
+ * @returns {MultiToken}
1615
+ */
1616
+ function initMultiToken(Multi, input, tokens) {
1617
+ const startIdx = tokens[0].s;
1618
+ const endIdx = tokens[tokens.length - 1].e;
1619
+ const value = input.slice(startIdx, endIdx);
1620
+ return new Multi(value, tokens);
1621
+ }
1622
+
1623
+ // Side-effect initialization state
1624
+ const INIT = {
1625
+ scanner: null,
1626
+ parser: null,
1627
+ tokenQueue: [],
1628
+ pluginQueue: [],
1629
+ customSchemes: [],
1630
+ initialized: false
1631
+ };
1632
+
1633
+ /**
1634
+ * Initialize the linkify state machine. Called automatically the first time
1635
+ * linkify is called on a string, but may be called manually as well.
1636
+ */
1637
+ function init() {
1638
+ // Initialize scanner state machine and plugins
1639
+ INIT.scanner = init$2(INIT.customSchemes);
1640
+ for (let i = 0; i < INIT.tokenQueue.length; i++) {
1641
+ INIT.tokenQueue[i][1]({
1642
+ scanner: INIT.scanner
1643
+ });
1644
+ }
1645
+
1646
+ // Initialize parser state machine and plugins
1647
+ INIT.parser = init$1(INIT.scanner.tokens);
1648
+ for (let i = 0; i < INIT.pluginQueue.length; i++) {
1649
+ INIT.pluginQueue[i][1]({
1650
+ scanner: INIT.scanner,
1651
+ parser: INIT.parser
1652
+ });
1653
+ }
1654
+ INIT.initialized = true;
1655
+ }
1656
+
1657
+ /**
1658
+ * Parse a string into tokens that represent linkable and non-linkable sub-components
1659
+ * @param {string} str
1660
+ * @return {MultiToken[]} tokens
1661
+ */
1662
+ function tokenize(str) {
1663
+ if (!INIT.initialized) {
1664
+ init();
1665
+ }
1666
+ return run(INIT.parser.start, str, run$1(INIT.scanner.start, str));
1667
+ }
1668
+
18
1669
  /**
19
1670
  * Given a string, converts to an array of valid React components
20
1671
  * (which may include strings)
@@ -137,7 +1788,7 @@ var Toast = function Toast(_ref) {
137
1788
  _ref$buttonLabel = _ref.buttonLabel,
138
1789
  buttonLabel = _ref$buttonLabel === void 0 ? "" : _ref$buttonLabel,
139
1790
  _ref$onClick = _ref.onClick,
140
- _onClick = _ref$onClick === void 0 ? noop : _ref$onClick;
1791
+ _onClick = _ref$onClick === void 0 ? noop$1 : _ref$onClick;
141
1792
  return /*#__PURE__*/React__default.createElement("div", {
142
1793
  "data-cy": "toastr-message-container",
143
1794
  "data-test": "toastr-".concat(type, "-container")