@iconify_iconify.js 59 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268
  1. import "./chunk-2LSFTFF7.js";
  2. // node_modules/.pnpm/@iconify+iconify@3.1.0/node_modules/@iconify/iconify/dist/iconify.mjs
  3. var defaultIconDimensions = Object.freeze(
  4. {
  5. left: 0,
  6. top: 0,
  7. width: 16,
  8. height: 16
  9. }
  10. );
  11. var defaultIconTransformations = Object.freeze({
  12. rotate: 0,
  13. vFlip: false,
  14. hFlip: false
  15. });
  16. var defaultIconProps = Object.freeze({
  17. ...defaultIconDimensions,
  18. ...defaultIconTransformations
  19. });
  20. var defaultExtendedIconProps = Object.freeze({
  21. ...defaultIconProps,
  22. body: "",
  23. hidden: false
  24. });
  25. function mergeIconTransformations(obj1, obj2) {
  26. const result = {};
  27. if (!obj1.hFlip !== !obj2.hFlip) {
  28. result.hFlip = true;
  29. }
  30. if (!obj1.vFlip !== !obj2.vFlip) {
  31. result.vFlip = true;
  32. }
  33. const rotate = ((obj1.rotate || 0) + (obj2.rotate || 0)) % 4;
  34. if (rotate) {
  35. result.rotate = rotate;
  36. }
  37. return result;
  38. }
  39. function mergeIconData(parent, child) {
  40. const result = mergeIconTransformations(parent, child);
  41. for (const key in defaultExtendedIconProps) {
  42. if (key in defaultIconTransformations) {
  43. if (key in parent && !(key in result)) {
  44. result[key] = defaultIconTransformations[key];
  45. }
  46. } else if (key in child) {
  47. result[key] = child[key];
  48. } else if (key in parent) {
  49. result[key] = parent[key];
  50. }
  51. }
  52. return result;
  53. }
  54. function getIconsTree(data, names) {
  55. const icons = data.icons;
  56. const aliases = data.aliases || /* @__PURE__ */ Object.create(null);
  57. const resolved = /* @__PURE__ */ Object.create(null);
  58. function resolve(name) {
  59. if (icons[name]) {
  60. return resolved[name] = [];
  61. }
  62. if (!(name in resolved)) {
  63. resolved[name] = null;
  64. const parent = aliases[name] && aliases[name].parent;
  65. const value = parent && resolve(parent);
  66. if (value) {
  67. resolved[name] = [parent].concat(value);
  68. }
  69. }
  70. return resolved[name];
  71. }
  72. (names || Object.keys(icons).concat(Object.keys(aliases))).forEach(resolve);
  73. return resolved;
  74. }
  75. function internalGetIconData(data, name, tree) {
  76. const icons = data.icons;
  77. const aliases = data.aliases || /* @__PURE__ */ Object.create(null);
  78. let currentProps = {};
  79. function parse(name2) {
  80. currentProps = mergeIconData(
  81. icons[name2] || aliases[name2],
  82. currentProps
  83. );
  84. }
  85. parse(name);
  86. tree.forEach(parse);
  87. return mergeIconData(data, currentProps);
  88. }
  89. function parseIconSet(data, callback2) {
  90. const names = [];
  91. if (typeof data !== "object" || typeof data.icons !== "object") {
  92. return names;
  93. }
  94. if (data.not_found instanceof Array) {
  95. data.not_found.forEach((name) => {
  96. callback2(name, null);
  97. names.push(name);
  98. });
  99. }
  100. const tree = getIconsTree(data);
  101. for (const name in tree) {
  102. const item = tree[name];
  103. if (item) {
  104. callback2(name, internalGetIconData(data, name, item));
  105. names.push(name);
  106. }
  107. }
  108. return names;
  109. }
  110. var matchIconName = /^[a-z0-9]+(-[a-z0-9]+)*$/;
  111. var stringToIcon = (value, validate, allowSimpleName, provider = "") => {
  112. const colonSeparated = value.split(":");
  113. if (value.slice(0, 1) === "@") {
  114. if (colonSeparated.length < 2 || colonSeparated.length > 3) {
  115. return null;
  116. }
  117. provider = colonSeparated.shift().slice(1);
  118. }
  119. if (colonSeparated.length > 3 || !colonSeparated.length) {
  120. return null;
  121. }
  122. if (colonSeparated.length > 1) {
  123. const name2 = colonSeparated.pop();
  124. const prefix = colonSeparated.pop();
  125. const result = {
  126. provider: colonSeparated.length > 0 ? colonSeparated[0] : provider,
  127. prefix,
  128. name: name2
  129. };
  130. return validate && !validateIconName(result) ? null : result;
  131. }
  132. const name = colonSeparated[0];
  133. const dashSeparated = name.split("-");
  134. if (dashSeparated.length > 1) {
  135. const result = {
  136. provider,
  137. prefix: dashSeparated.shift(),
  138. name: dashSeparated.join("-")
  139. };
  140. return validate && !validateIconName(result) ? null : result;
  141. }
  142. if (allowSimpleName && provider === "") {
  143. const result = {
  144. provider,
  145. prefix: "",
  146. name
  147. };
  148. return validate && !validateIconName(result, allowSimpleName) ? null : result;
  149. }
  150. return null;
  151. };
  152. var validateIconName = (icon, allowSimpleName) => {
  153. if (!icon) {
  154. return false;
  155. }
  156. return !!((icon.provider === "" || icon.provider.match(matchIconName)) && (allowSimpleName && icon.prefix === "" || icon.prefix.match(matchIconName)) && icon.name.match(matchIconName));
  157. };
  158. var optionalPropertyDefaults = {
  159. provider: "",
  160. aliases: {},
  161. not_found: {},
  162. ...defaultIconDimensions
  163. };
  164. function checkOptionalProps(item, defaults) {
  165. for (const prop in defaults) {
  166. if (prop in item && typeof item[prop] !== typeof defaults[prop]) {
  167. return false;
  168. }
  169. }
  170. return true;
  171. }
  172. function quicklyValidateIconSet(obj) {
  173. if (typeof obj !== "object" || obj === null) {
  174. return null;
  175. }
  176. const data = obj;
  177. if (typeof data.prefix !== "string" || !obj.icons || typeof obj.icons !== "object") {
  178. return null;
  179. }
  180. if (!checkOptionalProps(obj, optionalPropertyDefaults)) {
  181. return null;
  182. }
  183. const icons = data.icons;
  184. for (const name in icons) {
  185. const icon = icons[name];
  186. if (!name.match(matchIconName) || typeof icon.body !== "string" || !checkOptionalProps(
  187. icon,
  188. defaultExtendedIconProps
  189. )) {
  190. return null;
  191. }
  192. }
  193. const aliases = data.aliases || /* @__PURE__ */ Object.create(null);
  194. for (const name in aliases) {
  195. const icon = aliases[name];
  196. const parent = icon.parent;
  197. if (!name.match(matchIconName) || typeof parent !== "string" || !icons[parent] && !aliases[parent] || !checkOptionalProps(
  198. icon,
  199. defaultExtendedIconProps
  200. )) {
  201. return null;
  202. }
  203. }
  204. return data;
  205. }
  206. var dataStorage = /* @__PURE__ */ Object.create(null);
  207. function newStorage(provider, prefix) {
  208. return {
  209. provider,
  210. prefix,
  211. icons: /* @__PURE__ */ Object.create(null),
  212. missing: /* @__PURE__ */ new Set()
  213. };
  214. }
  215. function getStorage(provider, prefix) {
  216. const providerStorage = dataStorage[provider] || (dataStorage[provider] = /* @__PURE__ */ Object.create(null));
  217. return providerStorage[prefix] || (providerStorage[prefix] = newStorage(provider, prefix));
  218. }
  219. function addIconSet(storage2, data) {
  220. if (!quicklyValidateIconSet(data)) {
  221. return [];
  222. }
  223. return parseIconSet(data, (name, icon) => {
  224. if (icon) {
  225. storage2.icons[name] = icon;
  226. } else {
  227. storage2.missing.add(name);
  228. }
  229. });
  230. }
  231. function addIconToStorage(storage2, name, icon) {
  232. try {
  233. if (typeof icon.body === "string") {
  234. storage2.icons[name] = { ...icon };
  235. return true;
  236. }
  237. } catch (err) {
  238. }
  239. return false;
  240. }
  241. function listIcons(provider, prefix) {
  242. let allIcons = [];
  243. const providers = typeof provider === "string" ? [provider] : Object.keys(dataStorage);
  244. providers.forEach((provider2) => {
  245. const prefixes = typeof provider2 === "string" && typeof prefix === "string" ? [prefix] : Object.keys(dataStorage[provider2] || {});
  246. prefixes.forEach((prefix2) => {
  247. const storage2 = getStorage(provider2, prefix2);
  248. allIcons = allIcons.concat(
  249. Object.keys(storage2.icons).map(
  250. (name) => (provider2 !== "" ? "@" + provider2 + ":" : "") + prefix2 + ":" + name
  251. )
  252. );
  253. });
  254. });
  255. return allIcons;
  256. }
  257. var simpleNames = false;
  258. function allowSimpleNames(allow) {
  259. if (typeof allow === "boolean") {
  260. simpleNames = allow;
  261. }
  262. return simpleNames;
  263. }
  264. function getIconData(name) {
  265. const icon = typeof name === "string" ? stringToIcon(name, true, simpleNames) : name;
  266. if (icon) {
  267. const storage2 = getStorage(icon.provider, icon.prefix);
  268. const iconName = icon.name;
  269. return storage2.icons[iconName] || (storage2.missing.has(iconName) ? null : void 0);
  270. }
  271. }
  272. function addIcon(name, data) {
  273. const icon = stringToIcon(name, true, simpleNames);
  274. if (!icon) {
  275. return false;
  276. }
  277. const storage2 = getStorage(icon.provider, icon.prefix);
  278. return addIconToStorage(storage2, icon.name, data);
  279. }
  280. function addCollection(data, provider) {
  281. if (typeof data !== "object") {
  282. return false;
  283. }
  284. if (typeof provider !== "string") {
  285. provider = data.provider || "";
  286. }
  287. if (simpleNames && !provider && !data.prefix) {
  288. let added = false;
  289. if (quicklyValidateIconSet(data)) {
  290. data.prefix = "";
  291. parseIconSet(data, (name, icon) => {
  292. if (icon && addIcon(name, icon)) {
  293. added = true;
  294. }
  295. });
  296. }
  297. return added;
  298. }
  299. const prefix = data.prefix;
  300. if (!validateIconName({
  301. provider,
  302. prefix,
  303. name: "a"
  304. })) {
  305. return false;
  306. }
  307. const storage2 = getStorage(provider, prefix);
  308. return !!addIconSet(storage2, data);
  309. }
  310. function iconExists(name) {
  311. return !!getIconData(name);
  312. }
  313. function getIcon(name) {
  314. const result = getIconData(name);
  315. return result ? {
  316. ...defaultIconProps,
  317. ...result
  318. } : null;
  319. }
  320. var defaultIconSizeCustomisations = Object.freeze({
  321. width: null,
  322. height: null
  323. });
  324. var defaultIconCustomisations = Object.freeze({
  325. ...defaultIconSizeCustomisations,
  326. ...defaultIconTransformations
  327. });
  328. var unitsSplit = /(-?[0-9.]*[0-9]+[0-9.]*)/g;
  329. var unitsTest = /^-?[0-9.]*[0-9]+[0-9.]*$/g;
  330. function calculateSize(size, ratio, precision) {
  331. if (ratio === 1) {
  332. return size;
  333. }
  334. precision = precision || 100;
  335. if (typeof size === "number") {
  336. return Math.ceil(size * ratio * precision) / precision;
  337. }
  338. if (typeof size !== "string") {
  339. return size;
  340. }
  341. const oldParts = size.split(unitsSplit);
  342. if (oldParts === null || !oldParts.length) {
  343. return size;
  344. }
  345. const newParts = [];
  346. let code = oldParts.shift();
  347. let isNumber = unitsTest.test(code);
  348. while (true) {
  349. if (isNumber) {
  350. const num = parseFloat(code);
  351. if (isNaN(num)) {
  352. newParts.push(code);
  353. } else {
  354. newParts.push(Math.ceil(num * ratio * precision) / precision);
  355. }
  356. } else {
  357. newParts.push(code);
  358. }
  359. code = oldParts.shift();
  360. if (code === void 0) {
  361. return newParts.join("");
  362. }
  363. isNumber = !isNumber;
  364. }
  365. }
  366. var isUnsetKeyword = (value) => value === "unset" || value === "undefined" || value === "none";
  367. function iconToSVG(icon, customisations) {
  368. const fullIcon = {
  369. ...defaultIconProps,
  370. ...icon
  371. };
  372. const fullCustomisations = {
  373. ...defaultIconCustomisations,
  374. ...customisations
  375. };
  376. const box = {
  377. left: fullIcon.left,
  378. top: fullIcon.top,
  379. width: fullIcon.width,
  380. height: fullIcon.height
  381. };
  382. let body = fullIcon.body;
  383. [fullIcon, fullCustomisations].forEach((props) => {
  384. const transformations = [];
  385. const hFlip = props.hFlip;
  386. const vFlip = props.vFlip;
  387. let rotation = props.rotate;
  388. if (hFlip) {
  389. if (vFlip) {
  390. rotation += 2;
  391. } else {
  392. transformations.push(
  393. "translate(" + (box.width + box.left).toString() + " " + (0 - box.top).toString() + ")"
  394. );
  395. transformations.push("scale(-1 1)");
  396. box.top = box.left = 0;
  397. }
  398. } else if (vFlip) {
  399. transformations.push(
  400. "translate(" + (0 - box.left).toString() + " " + (box.height + box.top).toString() + ")"
  401. );
  402. transformations.push("scale(1 -1)");
  403. box.top = box.left = 0;
  404. }
  405. let tempValue;
  406. if (rotation < 0) {
  407. rotation -= Math.floor(rotation / 4) * 4;
  408. }
  409. rotation = rotation % 4;
  410. switch (rotation) {
  411. case 1:
  412. tempValue = box.height / 2 + box.top;
  413. transformations.unshift(
  414. "rotate(90 " + tempValue.toString() + " " + tempValue.toString() + ")"
  415. );
  416. break;
  417. case 2:
  418. transformations.unshift(
  419. "rotate(180 " + (box.width / 2 + box.left).toString() + " " + (box.height / 2 + box.top).toString() + ")"
  420. );
  421. break;
  422. case 3:
  423. tempValue = box.width / 2 + box.left;
  424. transformations.unshift(
  425. "rotate(-90 " + tempValue.toString() + " " + tempValue.toString() + ")"
  426. );
  427. break;
  428. }
  429. if (rotation % 2 === 1) {
  430. if (box.left !== box.top) {
  431. tempValue = box.left;
  432. box.left = box.top;
  433. box.top = tempValue;
  434. }
  435. if (box.width !== box.height) {
  436. tempValue = box.width;
  437. box.width = box.height;
  438. box.height = tempValue;
  439. }
  440. }
  441. if (transformations.length) {
  442. body = '<g transform="' + transformations.join(" ") + '">' + body + "</g>";
  443. }
  444. });
  445. const customisationsWidth = fullCustomisations.width;
  446. const customisationsHeight = fullCustomisations.height;
  447. const boxWidth = box.width;
  448. const boxHeight = box.height;
  449. let width;
  450. let height;
  451. if (customisationsWidth === null) {
  452. height = customisationsHeight === null ? "1em" : customisationsHeight === "auto" ? boxHeight : customisationsHeight;
  453. width = calculateSize(height, boxWidth / boxHeight);
  454. } else {
  455. width = customisationsWidth === "auto" ? boxWidth : customisationsWidth;
  456. height = customisationsHeight === null ? calculateSize(width, boxHeight / boxWidth) : customisationsHeight === "auto" ? boxHeight : customisationsHeight;
  457. }
  458. const attributes = {};
  459. const setAttr = (prop, value) => {
  460. if (!isUnsetKeyword(value)) {
  461. attributes[prop] = value.toString();
  462. }
  463. };
  464. setAttr("width", width);
  465. setAttr("height", height);
  466. attributes.viewBox = box.left.toString() + " " + box.top.toString() + " " + boxWidth.toString() + " " + boxHeight.toString();
  467. return {
  468. attributes,
  469. body
  470. };
  471. }
  472. var regex = /\sid="(\S+)"/g;
  473. var randomPrefix = "IconifyId" + Date.now().toString(16) + (Math.random() * 16777216 | 0).toString(16);
  474. var counter = 0;
  475. function replaceIDs(body, prefix = randomPrefix) {
  476. const ids = [];
  477. let match;
  478. while (match = regex.exec(body)) {
  479. ids.push(match[1]);
  480. }
  481. if (!ids.length) {
  482. return body;
  483. }
  484. const suffix = "suffix" + (Math.random() * 16777216 | Date.now()).toString(16);
  485. ids.forEach((id) => {
  486. const newID = typeof prefix === "function" ? prefix(id) : prefix + (counter++).toString();
  487. const escapedID = id.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
  488. body = body.replace(
  489. new RegExp('([#;"])(' + escapedID + ')([")]|\\.[a-z])', "g"),
  490. "$1" + newID + suffix + "$3"
  491. );
  492. });
  493. body = body.replace(new RegExp(suffix, "g"), "");
  494. return body;
  495. }
  496. var browserStorageConfig = {
  497. local: true,
  498. session: true
  499. };
  500. var browserStorageEmptyItems = {
  501. local: /* @__PURE__ */ new Set(),
  502. session: /* @__PURE__ */ new Set()
  503. };
  504. var browserStorageStatus = false;
  505. function setBrowserStorageStatus(status) {
  506. browserStorageStatus = status;
  507. }
  508. var browserCacheVersion = "iconify2";
  509. var browserCachePrefix = "iconify";
  510. var browserCacheCountKey = browserCachePrefix + "-count";
  511. var browserCacheVersionKey = browserCachePrefix + "-version";
  512. var browserStorageHour = 36e5;
  513. var browserStorageCacheExpiration = 168;
  514. function getStoredItem(func, key) {
  515. try {
  516. return func.getItem(key);
  517. } catch (err) {
  518. }
  519. }
  520. function setStoredItem(func, key, value) {
  521. try {
  522. func.setItem(key, value);
  523. return true;
  524. } catch (err) {
  525. }
  526. }
  527. function removeStoredItem(func, key) {
  528. try {
  529. func.removeItem(key);
  530. } catch (err) {
  531. }
  532. }
  533. function setBrowserStorageItemsCount(storage2, value) {
  534. return setStoredItem(storage2, browserCacheCountKey, value.toString());
  535. }
  536. function getBrowserStorageItemsCount(storage2) {
  537. return parseInt(getStoredItem(storage2, browserCacheCountKey)) || 0;
  538. }
  539. var _window = typeof window === "undefined" ? {} : window;
  540. function getBrowserStorage(key) {
  541. const attr = key + "Storage";
  542. try {
  543. if (_window && _window[attr] && typeof _window[attr].length === "number") {
  544. return _window[attr];
  545. }
  546. } catch (err) {
  547. }
  548. browserStorageConfig[key] = false;
  549. }
  550. function iterateBrowserStorage(key, callback2) {
  551. const func = getBrowserStorage(key);
  552. if (!func) {
  553. return;
  554. }
  555. const version = getStoredItem(func, browserCacheVersionKey);
  556. if (version !== browserCacheVersion) {
  557. if (version) {
  558. const total2 = getBrowserStorageItemsCount(func);
  559. for (let i = 0; i < total2; i++) {
  560. removeStoredItem(func, browserCachePrefix + i.toString());
  561. }
  562. }
  563. setStoredItem(func, browserCacheVersionKey, browserCacheVersion);
  564. setBrowserStorageItemsCount(func, 0);
  565. return;
  566. }
  567. const minTime = Math.floor(Date.now() / browserStorageHour) - browserStorageCacheExpiration;
  568. const parseItem = (index) => {
  569. const name = browserCachePrefix + index.toString();
  570. const item = getStoredItem(func, name);
  571. if (typeof item !== "string") {
  572. return;
  573. }
  574. try {
  575. const data = JSON.parse(item);
  576. if (typeof data === "object" && typeof data.cached === "number" && data.cached > minTime && typeof data.provider === "string" && typeof data.data === "object" && typeof data.data.prefix === "string" && callback2(data, index)) {
  577. return true;
  578. }
  579. } catch (err) {
  580. }
  581. removeStoredItem(func, name);
  582. };
  583. let total = getBrowserStorageItemsCount(func);
  584. for (let i = total - 1; i >= 0; i--) {
  585. if (!parseItem(i)) {
  586. if (i === total - 1) {
  587. total--;
  588. setBrowserStorageItemsCount(func, total);
  589. } else {
  590. browserStorageEmptyItems[key].add(i);
  591. }
  592. }
  593. }
  594. }
  595. function initBrowserStorage() {
  596. if (browserStorageStatus) {
  597. return;
  598. }
  599. setBrowserStorageStatus(true);
  600. for (const key in browserStorageConfig) {
  601. iterateBrowserStorage(key, (item) => {
  602. const iconSet = item.data;
  603. const provider = item.provider;
  604. const prefix = iconSet.prefix;
  605. const storage2 = getStorage(
  606. provider,
  607. prefix
  608. );
  609. if (!addIconSet(storage2, iconSet).length) {
  610. return false;
  611. }
  612. const lastModified = iconSet.lastModified || -1;
  613. storage2.lastModifiedCached = storage2.lastModifiedCached ? Math.min(storage2.lastModifiedCached, lastModified) : lastModified;
  614. return true;
  615. });
  616. }
  617. }
  618. function toggleBrowserCache(storage2, value) {
  619. switch (storage2) {
  620. case "local":
  621. case "session":
  622. browserStorageConfig[storage2] = value;
  623. break;
  624. case "all":
  625. for (const key in browserStorageConfig) {
  626. browserStorageConfig[key] = value;
  627. }
  628. break;
  629. }
  630. }
  631. var storage = /* @__PURE__ */ Object.create(null);
  632. function setAPIModule(provider, item) {
  633. storage[provider] = item;
  634. }
  635. function getAPIModule(provider) {
  636. return storage[provider] || storage[""];
  637. }
  638. function createAPIConfig(source) {
  639. let resources;
  640. if (typeof source.resources === "string") {
  641. resources = [source.resources];
  642. } else {
  643. resources = source.resources;
  644. if (!(resources instanceof Array) || !resources.length) {
  645. return null;
  646. }
  647. }
  648. const result = {
  649. resources,
  650. path: source.path || "/",
  651. maxURL: source.maxURL || 500,
  652. rotate: source.rotate || 750,
  653. timeout: source.timeout || 5e3,
  654. random: source.random === true,
  655. index: source.index || 0,
  656. dataAfterTimeout: source.dataAfterTimeout !== false
  657. };
  658. return result;
  659. }
  660. var configStorage = /* @__PURE__ */ Object.create(null);
  661. var fallBackAPISources = [
  662. "https://api.simplesvg.com",
  663. "https://api.unisvg.com"
  664. ];
  665. var fallBackAPI = [];
  666. while (fallBackAPISources.length > 0) {
  667. if (fallBackAPISources.length === 1) {
  668. fallBackAPI.push(fallBackAPISources.shift());
  669. } else {
  670. if (Math.random() > 0.5) {
  671. fallBackAPI.push(fallBackAPISources.shift());
  672. } else {
  673. fallBackAPI.push(fallBackAPISources.pop());
  674. }
  675. }
  676. }
  677. configStorage[""] = createAPIConfig({
  678. resources: ["https://api.iconify.design"].concat(fallBackAPI)
  679. });
  680. function addAPIProvider(provider, customConfig) {
  681. const config = createAPIConfig(customConfig);
  682. if (config === null) {
  683. return false;
  684. }
  685. configStorage[provider] = config;
  686. return true;
  687. }
  688. function getAPIConfig(provider) {
  689. return configStorage[provider];
  690. }
  691. function listAPIProviders() {
  692. return Object.keys(configStorage);
  693. }
  694. var detectFetch = () => {
  695. let callback2;
  696. try {
  697. callback2 = fetch;
  698. if (typeof callback2 === "function") {
  699. return callback2;
  700. }
  701. } catch (err) {
  702. }
  703. };
  704. var fetchModule = detectFetch();
  705. function setFetch(fetch2) {
  706. fetchModule = fetch2;
  707. }
  708. function getFetch() {
  709. return fetchModule;
  710. }
  711. function calculateMaxLength(provider, prefix) {
  712. const config = getAPIConfig(provider);
  713. if (!config) {
  714. return 0;
  715. }
  716. let result;
  717. if (!config.maxURL) {
  718. result = 0;
  719. } else {
  720. let maxHostLength = 0;
  721. config.resources.forEach((item) => {
  722. const host = item;
  723. maxHostLength = Math.max(maxHostLength, host.length);
  724. });
  725. const url = prefix + ".json?icons=";
  726. result = config.maxURL - maxHostLength - config.path.length - url.length;
  727. }
  728. return result;
  729. }
  730. function shouldAbort(status) {
  731. return status === 404;
  732. }
  733. var prepare = (provider, prefix, icons) => {
  734. const results = [];
  735. const maxLength = calculateMaxLength(provider, prefix);
  736. const type = "icons";
  737. let item = {
  738. type,
  739. provider,
  740. prefix,
  741. icons: []
  742. };
  743. let length = 0;
  744. icons.forEach((name, index) => {
  745. length += name.length + 1;
  746. if (length >= maxLength && index > 0) {
  747. results.push(item);
  748. item = {
  749. type,
  750. provider,
  751. prefix,
  752. icons: []
  753. };
  754. length = name.length;
  755. }
  756. item.icons.push(name);
  757. });
  758. results.push(item);
  759. return results;
  760. };
  761. function getPath(provider) {
  762. if (typeof provider === "string") {
  763. const config = getAPIConfig(provider);
  764. if (config) {
  765. return config.path;
  766. }
  767. }
  768. return "/";
  769. }
  770. var send = (host, params, callback2) => {
  771. if (!fetchModule) {
  772. callback2("abort", 424);
  773. return;
  774. }
  775. let path = getPath(params.provider);
  776. switch (params.type) {
  777. case "icons": {
  778. const prefix = params.prefix;
  779. const icons = params.icons;
  780. const iconsList = icons.join(",");
  781. const urlParams = new URLSearchParams({
  782. icons: iconsList
  783. });
  784. path += prefix + ".json?" + urlParams.toString();
  785. break;
  786. }
  787. case "custom": {
  788. const uri = params.uri;
  789. path += uri.slice(0, 1) === "/" ? uri.slice(1) : uri;
  790. break;
  791. }
  792. default:
  793. callback2("abort", 400);
  794. return;
  795. }
  796. let defaultError = 503;
  797. fetchModule(host + path).then((response) => {
  798. const status = response.status;
  799. if (status !== 200) {
  800. setTimeout(() => {
  801. callback2(shouldAbort(status) ? "abort" : "next", status);
  802. });
  803. return;
  804. }
  805. defaultError = 501;
  806. return response.json();
  807. }).then((data) => {
  808. if (typeof data !== "object" || data === null) {
  809. setTimeout(() => {
  810. if (data === 404) {
  811. callback2("abort", data);
  812. } else {
  813. callback2("next", defaultError);
  814. }
  815. });
  816. return;
  817. }
  818. setTimeout(() => {
  819. callback2("success", data);
  820. });
  821. }).catch(() => {
  822. callback2("next", defaultError);
  823. });
  824. };
  825. var fetchAPIModule = {
  826. prepare,
  827. send
  828. };
  829. function sortIcons(icons) {
  830. const result = {
  831. loaded: [],
  832. missing: [],
  833. pending: []
  834. };
  835. const storage2 = /* @__PURE__ */ Object.create(null);
  836. icons.sort((a, b) => {
  837. if (a.provider !== b.provider) {
  838. return a.provider.localeCompare(b.provider);
  839. }
  840. if (a.prefix !== b.prefix) {
  841. return a.prefix.localeCompare(b.prefix);
  842. }
  843. return a.name.localeCompare(b.name);
  844. });
  845. let lastIcon = {
  846. provider: "",
  847. prefix: "",
  848. name: ""
  849. };
  850. icons.forEach((icon) => {
  851. if (lastIcon.name === icon.name && lastIcon.prefix === icon.prefix && lastIcon.provider === icon.provider) {
  852. return;
  853. }
  854. lastIcon = icon;
  855. const provider = icon.provider;
  856. const prefix = icon.prefix;
  857. const name = icon.name;
  858. const providerStorage = storage2[provider] || (storage2[provider] = /* @__PURE__ */ Object.create(null));
  859. const localStorage = providerStorage[prefix] || (providerStorage[prefix] = getStorage(provider, prefix));
  860. let list;
  861. if (name in localStorage.icons) {
  862. list = result.loaded;
  863. } else if (prefix === "" || localStorage.missing.has(name)) {
  864. list = result.missing;
  865. } else {
  866. list = result.pending;
  867. }
  868. const item = {
  869. provider,
  870. prefix,
  871. name
  872. };
  873. list.push(item);
  874. });
  875. return result;
  876. }
  877. function removeCallback(storages, id) {
  878. storages.forEach((storage2) => {
  879. const items = storage2.loaderCallbacks;
  880. if (items) {
  881. storage2.loaderCallbacks = items.filter((row) => row.id !== id);
  882. }
  883. });
  884. }
  885. function updateCallbacks(storage2) {
  886. if (!storage2.pendingCallbacksFlag) {
  887. storage2.pendingCallbacksFlag = true;
  888. setTimeout(() => {
  889. storage2.pendingCallbacksFlag = false;
  890. const items = storage2.loaderCallbacks ? storage2.loaderCallbacks.slice(0) : [];
  891. if (!items.length) {
  892. return;
  893. }
  894. let hasPending = false;
  895. const provider = storage2.provider;
  896. const prefix = storage2.prefix;
  897. items.forEach((item) => {
  898. const icons = item.icons;
  899. const oldLength = icons.pending.length;
  900. icons.pending = icons.pending.filter((icon) => {
  901. if (icon.prefix !== prefix) {
  902. return true;
  903. }
  904. const name = icon.name;
  905. if (storage2.icons[name]) {
  906. icons.loaded.push({
  907. provider,
  908. prefix,
  909. name
  910. });
  911. } else if (storage2.missing.has(name)) {
  912. icons.missing.push({
  913. provider,
  914. prefix,
  915. name
  916. });
  917. } else {
  918. hasPending = true;
  919. return true;
  920. }
  921. return false;
  922. });
  923. if (icons.pending.length !== oldLength) {
  924. if (!hasPending) {
  925. removeCallback([storage2], item.id);
  926. }
  927. item.callback(
  928. icons.loaded.slice(0),
  929. icons.missing.slice(0),
  930. icons.pending.slice(0),
  931. item.abort
  932. );
  933. }
  934. });
  935. });
  936. }
  937. }
  938. var idCounter = 0;
  939. function storeCallback(callback2, icons, pendingSources) {
  940. const id = idCounter++;
  941. const abort = removeCallback.bind(null, pendingSources, id);
  942. if (!icons.pending.length) {
  943. return abort;
  944. }
  945. const item = {
  946. id,
  947. icons,
  948. callback: callback2,
  949. abort
  950. };
  951. pendingSources.forEach((storage2) => {
  952. (storage2.loaderCallbacks || (storage2.loaderCallbacks = [])).push(item);
  953. });
  954. return abort;
  955. }
  956. function listToIcons(list, validate = true, simpleNames2 = false) {
  957. const result = [];
  958. list.forEach((item) => {
  959. const icon = typeof item === "string" ? stringToIcon(item, validate, simpleNames2) : item;
  960. if (icon) {
  961. result.push(icon);
  962. }
  963. });
  964. return result;
  965. }
  966. var defaultConfig = {
  967. resources: [],
  968. index: 0,
  969. timeout: 2e3,
  970. rotate: 750,
  971. random: false,
  972. dataAfterTimeout: false
  973. };
  974. function sendQuery(config, payload, query, done) {
  975. const resourcesCount = config.resources.length;
  976. const startIndex = config.random ? Math.floor(Math.random() * resourcesCount) : config.index;
  977. let resources;
  978. if (config.random) {
  979. let list = config.resources.slice(0);
  980. resources = [];
  981. while (list.length > 1) {
  982. const nextIndex = Math.floor(Math.random() * list.length);
  983. resources.push(list[nextIndex]);
  984. list = list.slice(0, nextIndex).concat(list.slice(nextIndex + 1));
  985. }
  986. resources = resources.concat(list);
  987. } else {
  988. resources = config.resources.slice(startIndex).concat(config.resources.slice(0, startIndex));
  989. }
  990. const startTime = Date.now();
  991. let status = "pending";
  992. let queriesSent = 0;
  993. let lastError;
  994. let timer = null;
  995. let queue = [];
  996. let doneCallbacks = [];
  997. if (typeof done === "function") {
  998. doneCallbacks.push(done);
  999. }
  1000. function resetTimer() {
  1001. if (timer) {
  1002. clearTimeout(timer);
  1003. timer = null;
  1004. }
  1005. }
  1006. function abort() {
  1007. if (status === "pending") {
  1008. status = "aborted";
  1009. }
  1010. resetTimer();
  1011. queue.forEach((item) => {
  1012. if (item.status === "pending") {
  1013. item.status = "aborted";
  1014. }
  1015. });
  1016. queue = [];
  1017. }
  1018. function subscribe(callback2, overwrite) {
  1019. if (overwrite) {
  1020. doneCallbacks = [];
  1021. }
  1022. if (typeof callback2 === "function") {
  1023. doneCallbacks.push(callback2);
  1024. }
  1025. }
  1026. function getQueryStatus() {
  1027. return {
  1028. startTime,
  1029. payload,
  1030. status,
  1031. queriesSent,
  1032. queriesPending: queue.length,
  1033. subscribe,
  1034. abort
  1035. };
  1036. }
  1037. function failQuery() {
  1038. status = "failed";
  1039. doneCallbacks.forEach((callback2) => {
  1040. callback2(void 0, lastError);
  1041. });
  1042. }
  1043. function clearQueue() {
  1044. queue.forEach((item) => {
  1045. if (item.status === "pending") {
  1046. item.status = "aborted";
  1047. }
  1048. });
  1049. queue = [];
  1050. }
  1051. function moduleResponse(item, response, data) {
  1052. const isError = response !== "success";
  1053. queue = queue.filter((queued) => queued !== item);
  1054. switch (status) {
  1055. case "pending":
  1056. break;
  1057. case "failed":
  1058. if (isError || !config.dataAfterTimeout) {
  1059. return;
  1060. }
  1061. break;
  1062. default:
  1063. return;
  1064. }
  1065. if (response === "abort") {
  1066. lastError = data;
  1067. failQuery();
  1068. return;
  1069. }
  1070. if (isError) {
  1071. lastError = data;
  1072. if (!queue.length) {
  1073. if (!resources.length) {
  1074. failQuery();
  1075. } else {
  1076. execNext();
  1077. }
  1078. }
  1079. return;
  1080. }
  1081. resetTimer();
  1082. clearQueue();
  1083. if (!config.random) {
  1084. const index = config.resources.indexOf(item.resource);
  1085. if (index !== -1 && index !== config.index) {
  1086. config.index = index;
  1087. }
  1088. }
  1089. status = "completed";
  1090. doneCallbacks.forEach((callback2) => {
  1091. callback2(data);
  1092. });
  1093. }
  1094. function execNext() {
  1095. if (status !== "pending") {
  1096. return;
  1097. }
  1098. resetTimer();
  1099. const resource = resources.shift();
  1100. if (resource === void 0) {
  1101. if (queue.length) {
  1102. timer = setTimeout(() => {
  1103. resetTimer();
  1104. if (status === "pending") {
  1105. clearQueue();
  1106. failQuery();
  1107. }
  1108. }, config.timeout);
  1109. return;
  1110. }
  1111. failQuery();
  1112. return;
  1113. }
  1114. const item = {
  1115. status: "pending",
  1116. resource,
  1117. callback: (status2, data) => {
  1118. moduleResponse(item, status2, data);
  1119. }
  1120. };
  1121. queue.push(item);
  1122. queriesSent++;
  1123. timer = setTimeout(execNext, config.rotate);
  1124. query(resource, payload, item.callback);
  1125. }
  1126. setTimeout(execNext);
  1127. return getQueryStatus;
  1128. }
  1129. function initRedundancy(cfg) {
  1130. const config = {
  1131. ...defaultConfig,
  1132. ...cfg
  1133. };
  1134. let queries = [];
  1135. function cleanup() {
  1136. queries = queries.filter((item) => item().status === "pending");
  1137. }
  1138. function query(payload, queryCallback, doneCallback) {
  1139. const query2 = sendQuery(
  1140. config,
  1141. payload,
  1142. queryCallback,
  1143. (data, error) => {
  1144. cleanup();
  1145. if (doneCallback) {
  1146. doneCallback(data, error);
  1147. }
  1148. }
  1149. );
  1150. queries.push(query2);
  1151. return query2;
  1152. }
  1153. function find(callback2) {
  1154. return queries.find((value) => {
  1155. return callback2(value);
  1156. }) || null;
  1157. }
  1158. const instance = {
  1159. query,
  1160. find,
  1161. setIndex: (index) => {
  1162. config.index = index;
  1163. },
  1164. getIndex: () => config.index,
  1165. cleanup
  1166. };
  1167. return instance;
  1168. }
  1169. function emptyCallback$1() {
  1170. }
  1171. var redundancyCache = /* @__PURE__ */ Object.create(null);
  1172. function getRedundancyCache(provider) {
  1173. if (!redundancyCache[provider]) {
  1174. const config = getAPIConfig(provider);
  1175. if (!config) {
  1176. return;
  1177. }
  1178. const redundancy = initRedundancy(config);
  1179. const cachedReundancy = {
  1180. config,
  1181. redundancy
  1182. };
  1183. redundancyCache[provider] = cachedReundancy;
  1184. }
  1185. return redundancyCache[provider];
  1186. }
  1187. function sendAPIQuery(target, query, callback2) {
  1188. let redundancy;
  1189. let send2;
  1190. if (typeof target === "string") {
  1191. const api = getAPIModule(target);
  1192. if (!api) {
  1193. callback2(void 0, 424);
  1194. return emptyCallback$1;
  1195. }
  1196. send2 = api.send;
  1197. const cached = getRedundancyCache(target);
  1198. if (cached) {
  1199. redundancy = cached.redundancy;
  1200. }
  1201. } else {
  1202. const config = createAPIConfig(target);
  1203. if (config) {
  1204. redundancy = initRedundancy(config);
  1205. const moduleKey = target.resources ? target.resources[0] : "";
  1206. const api = getAPIModule(moduleKey);
  1207. if (api) {
  1208. send2 = api.send;
  1209. }
  1210. }
  1211. }
  1212. if (!redundancy || !send2) {
  1213. callback2(void 0, 424);
  1214. return emptyCallback$1;
  1215. }
  1216. return redundancy.query(query, send2, callback2)().abort;
  1217. }
  1218. function updateLastModified(storage2, lastModified) {
  1219. const lastValue = storage2.lastModifiedCached;
  1220. if (lastValue && lastValue >= lastModified) {
  1221. return lastValue === lastModified;
  1222. }
  1223. storage2.lastModifiedCached = lastModified;
  1224. if (lastValue) {
  1225. for (const key in browserStorageConfig) {
  1226. iterateBrowserStorage(key, (item) => {
  1227. const iconSet = item.data;
  1228. return item.provider !== storage2.provider || iconSet.prefix !== storage2.prefix || iconSet.lastModified === lastModified;
  1229. });
  1230. }
  1231. }
  1232. return true;
  1233. }
  1234. function storeInBrowserStorage(storage2, data) {
  1235. if (!browserStorageStatus) {
  1236. initBrowserStorage();
  1237. }
  1238. function store(key) {
  1239. let func;
  1240. if (!browserStorageConfig[key] || !(func = getBrowserStorage(key))) {
  1241. return;
  1242. }
  1243. const set = browserStorageEmptyItems[key];
  1244. let index;
  1245. if (set.size) {
  1246. set.delete(index = Array.from(set).shift());
  1247. } else {
  1248. index = getBrowserStorageItemsCount(func);
  1249. if (!setBrowserStorageItemsCount(func, index + 1)) {
  1250. return;
  1251. }
  1252. }
  1253. const item = {
  1254. cached: Math.floor(Date.now() / browserStorageHour),
  1255. provider: storage2.provider,
  1256. data
  1257. };
  1258. return setStoredItem(
  1259. func,
  1260. browserCachePrefix + index.toString(),
  1261. JSON.stringify(item)
  1262. );
  1263. }
  1264. if (data.lastModified && !updateLastModified(storage2, data.lastModified)) {
  1265. return;
  1266. }
  1267. if (!Object.keys(data.icons).length) {
  1268. return;
  1269. }
  1270. if (data.not_found) {
  1271. data = Object.assign({}, data);
  1272. delete data.not_found;
  1273. }
  1274. if (!store("local")) {
  1275. store("session");
  1276. }
  1277. }
  1278. function emptyCallback() {
  1279. }
  1280. function loadedNewIcons(storage2) {
  1281. if (!storage2.iconsLoaderFlag) {
  1282. storage2.iconsLoaderFlag = true;
  1283. setTimeout(() => {
  1284. storage2.iconsLoaderFlag = false;
  1285. updateCallbacks(storage2);
  1286. });
  1287. }
  1288. }
  1289. function loadNewIcons(storage2, icons) {
  1290. if (!storage2.iconsToLoad) {
  1291. storage2.iconsToLoad = icons;
  1292. } else {
  1293. storage2.iconsToLoad = storage2.iconsToLoad.concat(icons).sort();
  1294. }
  1295. if (!storage2.iconsQueueFlag) {
  1296. storage2.iconsQueueFlag = true;
  1297. setTimeout(() => {
  1298. storage2.iconsQueueFlag = false;
  1299. const { provider, prefix } = storage2;
  1300. const icons2 = storage2.iconsToLoad;
  1301. delete storage2.iconsToLoad;
  1302. let api;
  1303. if (!icons2 || !(api = getAPIModule(provider))) {
  1304. return;
  1305. }
  1306. const params = api.prepare(provider, prefix, icons2);
  1307. params.forEach((item) => {
  1308. sendAPIQuery(provider, item, (data) => {
  1309. if (typeof data !== "object") {
  1310. item.icons.forEach((name) => {
  1311. storage2.missing.add(name);
  1312. });
  1313. } else {
  1314. try {
  1315. const parsed = addIconSet(
  1316. storage2,
  1317. data
  1318. );
  1319. if (!parsed.length) {
  1320. return;
  1321. }
  1322. const pending = storage2.pendingIcons;
  1323. if (pending) {
  1324. parsed.forEach((name) => {
  1325. pending.delete(name);
  1326. });
  1327. }
  1328. storeInBrowserStorage(storage2, data);
  1329. } catch (err) {
  1330. console.error(err);
  1331. }
  1332. }
  1333. loadedNewIcons(storage2);
  1334. });
  1335. });
  1336. });
  1337. }
  1338. }
  1339. var isPending = (icon) => {
  1340. const storage2 = getStorage(
  1341. icon.provider,
  1342. icon.prefix
  1343. );
  1344. const pending = storage2.pendingIcons;
  1345. return !!(pending && pending.has(icon.name));
  1346. };
  1347. var loadIcons = (icons, callback2) => {
  1348. const cleanedIcons = listToIcons(icons, true, allowSimpleNames());
  1349. const sortedIcons = sortIcons(cleanedIcons);
  1350. if (!sortedIcons.pending.length) {
  1351. let callCallback = true;
  1352. if (callback2) {
  1353. setTimeout(() => {
  1354. if (callCallback) {
  1355. callback2(
  1356. sortedIcons.loaded,
  1357. sortedIcons.missing,
  1358. sortedIcons.pending,
  1359. emptyCallback
  1360. );
  1361. }
  1362. });
  1363. }
  1364. return () => {
  1365. callCallback = false;
  1366. };
  1367. }
  1368. const newIcons = /* @__PURE__ */ Object.create(null);
  1369. const sources = [];
  1370. let lastProvider, lastPrefix;
  1371. sortedIcons.pending.forEach((icon) => {
  1372. const { provider, prefix } = icon;
  1373. if (prefix === lastPrefix && provider === lastProvider) {
  1374. return;
  1375. }
  1376. lastProvider = provider;
  1377. lastPrefix = prefix;
  1378. sources.push(getStorage(provider, prefix));
  1379. const providerNewIcons = newIcons[provider] || (newIcons[provider] = /* @__PURE__ */ Object.create(null));
  1380. if (!providerNewIcons[prefix]) {
  1381. providerNewIcons[prefix] = [];
  1382. }
  1383. });
  1384. sortedIcons.pending.forEach((icon) => {
  1385. const { provider, prefix, name } = icon;
  1386. const storage2 = getStorage(provider, prefix);
  1387. const pendingQueue = storage2.pendingIcons || (storage2.pendingIcons = /* @__PURE__ */ new Set());
  1388. if (!pendingQueue.has(name)) {
  1389. pendingQueue.add(name);
  1390. newIcons[provider][prefix].push(name);
  1391. }
  1392. });
  1393. sources.forEach((storage2) => {
  1394. const { provider, prefix } = storage2;
  1395. if (newIcons[provider][prefix].length) {
  1396. loadNewIcons(storage2, newIcons[provider][prefix]);
  1397. }
  1398. });
  1399. return callback2 ? storeCallback(callback2, sortedIcons, sources) : emptyCallback;
  1400. };
  1401. var loadIcon = (icon) => {
  1402. return new Promise((fulfill, reject) => {
  1403. const iconObj = typeof icon === "string" ? stringToIcon(icon, true) : icon;
  1404. if (!iconObj) {
  1405. reject(icon);
  1406. return;
  1407. }
  1408. loadIcons([iconObj || icon], (loaded) => {
  1409. if (loaded.length && iconObj) {
  1410. const data = getIconData(iconObj);
  1411. if (data) {
  1412. fulfill({
  1413. ...defaultIconProps,
  1414. ...data
  1415. });
  1416. return;
  1417. }
  1418. }
  1419. reject(icon);
  1420. });
  1421. });
  1422. };
  1423. function mergeCustomisations(defaults, item) {
  1424. const result = {
  1425. ...defaults
  1426. };
  1427. for (const key in item) {
  1428. const value = item[key];
  1429. const valueType = typeof value;
  1430. if (key in defaultIconSizeCustomisations) {
  1431. if (value === null || value && (valueType === "string" || valueType === "number")) {
  1432. result[key] = value;
  1433. }
  1434. } else if (valueType === typeof result[key]) {
  1435. result[key] = key === "rotate" ? value % 4 : value;
  1436. }
  1437. }
  1438. return result;
  1439. }
  1440. var defaultExtendedIconCustomisations = {
  1441. ...defaultIconCustomisations,
  1442. inline: false
  1443. };
  1444. var blockClass = "iconify";
  1445. var inlineClass = "iconify-inline";
  1446. var elementDataProperty = "iconifyData" + Date.now();
  1447. var nodes = [];
  1448. function findRootNode(node) {
  1449. for (let i = 0; i < nodes.length; i++) {
  1450. const item = nodes[i];
  1451. const root = typeof item.node === "function" ? item.node() : item.node;
  1452. if (root === node) {
  1453. return item;
  1454. }
  1455. }
  1456. }
  1457. function addRootNode(root, autoRemove = false) {
  1458. let node = findRootNode(root);
  1459. if (node) {
  1460. if (node.temporary) {
  1461. node.temporary = autoRemove;
  1462. }
  1463. return node;
  1464. }
  1465. node = {
  1466. node: root,
  1467. temporary: autoRemove
  1468. };
  1469. nodes.push(node);
  1470. return node;
  1471. }
  1472. function addBodyNode() {
  1473. if (document.documentElement) {
  1474. return addRootNode(document.documentElement);
  1475. }
  1476. nodes.push({
  1477. node: () => {
  1478. return document.documentElement;
  1479. }
  1480. });
  1481. }
  1482. function removeRootNode(root) {
  1483. nodes = nodes.filter((node) => root !== node && root !== (typeof node.node === "function" ? node.node() : node.node));
  1484. }
  1485. function listRootNodes() {
  1486. return nodes;
  1487. }
  1488. function onReady(callback2) {
  1489. const doc = document;
  1490. if (doc.readyState && doc.readyState !== "loading") {
  1491. callback2();
  1492. } else {
  1493. doc.addEventListener("DOMContentLoaded", callback2);
  1494. }
  1495. }
  1496. var callback = null;
  1497. var observerParams = {
  1498. childList: true,
  1499. subtree: true,
  1500. attributes: true
  1501. };
  1502. function queueScan(node) {
  1503. if (!node.observer) {
  1504. return;
  1505. }
  1506. const observer = node.observer;
  1507. if (!observer.pendingScan) {
  1508. observer.pendingScan = setTimeout(() => {
  1509. delete observer.pendingScan;
  1510. if (callback) {
  1511. callback(node);
  1512. }
  1513. });
  1514. }
  1515. }
  1516. function checkMutations(node, mutations) {
  1517. if (!node.observer) {
  1518. return;
  1519. }
  1520. const observer = node.observer;
  1521. if (!observer.pendingScan) {
  1522. for (let i = 0; i < mutations.length; i++) {
  1523. const item = mutations[i];
  1524. if (
  1525. // Check for added nodes
  1526. item.addedNodes && item.addedNodes.length > 0 || // Check for icon or placeholder with modified attributes
  1527. item.type === "attributes" && item.target[elementDataProperty] !== void 0
  1528. ) {
  1529. if (!observer.paused) {
  1530. queueScan(node);
  1531. }
  1532. return;
  1533. }
  1534. }
  1535. }
  1536. }
  1537. function continueObserving(node, root) {
  1538. node.observer.instance.observe(root, observerParams);
  1539. }
  1540. function startObserver(node) {
  1541. let observer = node.observer;
  1542. if (observer && observer.instance) {
  1543. return;
  1544. }
  1545. const root = typeof node.node === "function" ? node.node() : node.node;
  1546. if (!root || !window) {
  1547. return;
  1548. }
  1549. if (!observer) {
  1550. observer = {
  1551. paused: 0
  1552. };
  1553. node.observer = observer;
  1554. }
  1555. observer.instance = new window.MutationObserver(checkMutations.bind(null, node));
  1556. continueObserving(node, root);
  1557. if (!observer.paused) {
  1558. queueScan(node);
  1559. }
  1560. }
  1561. function startObservers() {
  1562. listRootNodes().forEach(startObserver);
  1563. }
  1564. function stopObserver(node) {
  1565. if (!node.observer) {
  1566. return;
  1567. }
  1568. const observer = node.observer;
  1569. if (observer.pendingScan) {
  1570. clearTimeout(observer.pendingScan);
  1571. delete observer.pendingScan;
  1572. }
  1573. if (observer.instance) {
  1574. observer.instance.disconnect();
  1575. delete observer.instance;
  1576. }
  1577. }
  1578. function initObserver(cb) {
  1579. const isRestart = callback !== null;
  1580. if (callback !== cb) {
  1581. callback = cb;
  1582. if (isRestart) {
  1583. listRootNodes().forEach(stopObserver);
  1584. }
  1585. }
  1586. if (isRestart) {
  1587. startObservers();
  1588. return;
  1589. }
  1590. onReady(startObservers);
  1591. }
  1592. function pauseObservingNode(node) {
  1593. (node ? [node] : listRootNodes()).forEach((node2) => {
  1594. if (!node2.observer) {
  1595. node2.observer = {
  1596. paused: 1
  1597. };
  1598. return;
  1599. }
  1600. const observer = node2.observer;
  1601. observer.paused++;
  1602. if (observer.paused > 1 || !observer.instance) {
  1603. return;
  1604. }
  1605. const instance = observer.instance;
  1606. instance.disconnect();
  1607. });
  1608. }
  1609. function pauseObserver(root) {
  1610. if (root) {
  1611. const node = findRootNode(root);
  1612. if (node) {
  1613. pauseObservingNode(node);
  1614. }
  1615. } else {
  1616. pauseObservingNode();
  1617. }
  1618. }
  1619. function resumeObservingNode(observer) {
  1620. (observer ? [observer] : listRootNodes()).forEach((node) => {
  1621. if (!node.observer) {
  1622. startObserver(node);
  1623. return;
  1624. }
  1625. const observer2 = node.observer;
  1626. if (observer2.paused) {
  1627. observer2.paused--;
  1628. if (!observer2.paused) {
  1629. const root = typeof node.node === "function" ? node.node() : node.node;
  1630. if (!root) {
  1631. return;
  1632. } else if (observer2.instance) {
  1633. continueObserving(node, root);
  1634. } else {
  1635. startObserver(node);
  1636. }
  1637. }
  1638. }
  1639. });
  1640. }
  1641. function resumeObserver(root) {
  1642. if (root) {
  1643. const node = findRootNode(root);
  1644. if (node) {
  1645. resumeObservingNode(node);
  1646. }
  1647. } else {
  1648. resumeObservingNode();
  1649. }
  1650. }
  1651. function observe(root, autoRemove = false) {
  1652. const node = addRootNode(root, autoRemove);
  1653. startObserver(node);
  1654. return node;
  1655. }
  1656. function stopObserving(root) {
  1657. const node = findRootNode(root);
  1658. if (node) {
  1659. stopObserver(node);
  1660. removeRootNode(root);
  1661. }
  1662. }
  1663. function propsChanged(props1, props2) {
  1664. if (props1.name !== props2.name || props1.mode !== props2.mode) {
  1665. return true;
  1666. }
  1667. const customisations1 = props1.customisations;
  1668. const customisations2 = props2.customisations;
  1669. for (const key in defaultExtendedIconCustomisations) {
  1670. if (customisations1[key] !== customisations2[key]) {
  1671. return true;
  1672. }
  1673. }
  1674. return false;
  1675. }
  1676. function rotateFromString(value, defaultValue = 0) {
  1677. const units = value.replace(/^-?[0-9.]*/, "");
  1678. function cleanup(value2) {
  1679. while (value2 < 0) {
  1680. value2 += 4;
  1681. }
  1682. return value2 % 4;
  1683. }
  1684. if (units === "") {
  1685. const num = parseInt(value);
  1686. return isNaN(num) ? 0 : cleanup(num);
  1687. } else if (units !== value) {
  1688. let split = 0;
  1689. switch (units) {
  1690. case "%":
  1691. split = 25;
  1692. break;
  1693. case "deg":
  1694. split = 90;
  1695. }
  1696. if (split) {
  1697. let num = parseFloat(value.slice(0, value.length - units.length));
  1698. if (isNaN(num)) {
  1699. return 0;
  1700. }
  1701. num = num / split;
  1702. return num % 1 === 0 ? cleanup(num) : 0;
  1703. }
  1704. }
  1705. return defaultValue;
  1706. }
  1707. var separator = /[\s,]+/;
  1708. function flipFromString(custom, flip) {
  1709. flip.split(separator).forEach((str) => {
  1710. const value = str.trim();
  1711. switch (value) {
  1712. case "horizontal":
  1713. custom.hFlip = true;
  1714. break;
  1715. case "vertical":
  1716. custom.vFlip = true;
  1717. break;
  1718. }
  1719. });
  1720. }
  1721. var sizeAttributes = ["width", "height"];
  1722. var booleanAttributes = [
  1723. "inline",
  1724. "hFlip",
  1725. "vFlip"
  1726. ];
  1727. function getBooleanAttribute(value, key) {
  1728. if (value === key || value === "true") {
  1729. return true;
  1730. }
  1731. if (value === "" || value === "false") {
  1732. return false;
  1733. }
  1734. return null;
  1735. }
  1736. function getElementProps(element) {
  1737. const name = element.getAttribute("data-icon");
  1738. const icon = typeof name === "string" && stringToIcon(name, true);
  1739. if (!icon) {
  1740. return null;
  1741. }
  1742. const customisations = {
  1743. ...defaultExtendedIconCustomisations,
  1744. inline: element.classList && element.classList.contains(inlineClass)
  1745. };
  1746. sizeAttributes.forEach((attr) => {
  1747. const value = element.getAttribute("data-" + attr);
  1748. if (value) {
  1749. customisations[attr] = value;
  1750. }
  1751. });
  1752. const rotation = element.getAttribute("data-rotate");
  1753. if (typeof rotation === "string") {
  1754. customisations.rotate = rotateFromString(rotation);
  1755. }
  1756. const flip = element.getAttribute("data-flip");
  1757. if (typeof flip === "string") {
  1758. flipFromString(customisations, flip);
  1759. }
  1760. booleanAttributes.forEach((attr) => {
  1761. const key = "data-" + attr;
  1762. const value = getBooleanAttribute(element.getAttribute(key), key);
  1763. if (typeof value === "boolean") {
  1764. customisations[attr] = value;
  1765. }
  1766. });
  1767. const mode = element.getAttribute("data-mode");
  1768. return {
  1769. name,
  1770. icon,
  1771. customisations,
  1772. mode
  1773. };
  1774. }
  1775. var selector = "svg." + blockClass + ", i." + blockClass + ", span." + blockClass + ", i." + inlineClass + ", span." + inlineClass;
  1776. function scanRootNode(root) {
  1777. const nodes2 = [];
  1778. root.querySelectorAll(selector).forEach((node) => {
  1779. const props = node[elementDataProperty] || node.tagName.toLowerCase() !== "svg" ? getElementProps(node) : null;
  1780. if (props) {
  1781. nodes2.push({
  1782. node,
  1783. props
  1784. });
  1785. }
  1786. });
  1787. return nodes2;
  1788. }
  1789. function iconToHTML(body, attributes) {
  1790. let renderAttribsHTML = body.indexOf("xlink:") === -1 ? "" : ' xmlns:xlink="http://www.w3.org/1999/xlink"';
  1791. for (const attr in attributes) {
  1792. renderAttribsHTML += " " + attr + '="' + attributes[attr] + '"';
  1793. }
  1794. return '<svg xmlns="http://www.w3.org/2000/svg"' + renderAttribsHTML + ">" + body + "</svg>";
  1795. }
  1796. function iconClasses(iconName) {
  1797. const classesToAdd = /* @__PURE__ */ new Set(["iconify"]);
  1798. ["provider", "prefix"].forEach((attr) => {
  1799. if (iconName[attr]) {
  1800. classesToAdd.add("iconify--" + iconName[attr]);
  1801. }
  1802. });
  1803. return classesToAdd;
  1804. }
  1805. function applyClasses(svg, classes, previouslyAddedClasses, placeholder) {
  1806. const svgClasses = svg.classList;
  1807. if (placeholder) {
  1808. const placeholderClasses = placeholder.classList;
  1809. Array.from(placeholderClasses).forEach((item) => {
  1810. svgClasses.add(item);
  1811. });
  1812. }
  1813. const addedClasses = [];
  1814. classes.forEach((item) => {
  1815. if (!svgClasses.contains(item)) {
  1816. svgClasses.add(item);
  1817. addedClasses.push(item);
  1818. } else if (previouslyAddedClasses.has(item)) {
  1819. addedClasses.push(item);
  1820. }
  1821. });
  1822. previouslyAddedClasses.forEach((item) => {
  1823. if (!classes.has(item)) {
  1824. svgClasses.remove(item);
  1825. }
  1826. });
  1827. return addedClasses;
  1828. }
  1829. function applyStyle(svg, styles, previouslyAddedStyles) {
  1830. const svgStyle = svg.style;
  1831. (previouslyAddedStyles || []).forEach((prop) => {
  1832. svgStyle.removeProperty(prop);
  1833. });
  1834. const appliedStyles = [];
  1835. for (const prop in styles) {
  1836. if (!svgStyle.getPropertyValue(prop)) {
  1837. appliedStyles.push(prop);
  1838. svgStyle.setProperty(prop, styles[prop]);
  1839. }
  1840. }
  1841. return appliedStyles;
  1842. }
  1843. function renderInlineSVG(element, props, iconData) {
  1844. let span;
  1845. try {
  1846. span = document.createElement("span");
  1847. } catch (err) {
  1848. return element;
  1849. }
  1850. const customisations = props.customisations;
  1851. const renderData = iconToSVG(iconData, customisations);
  1852. const oldData = element[elementDataProperty];
  1853. const html = iconToHTML(replaceIDs(renderData.body), {
  1854. "aria-hidden": "true",
  1855. "role": "img",
  1856. ...renderData.attributes
  1857. });
  1858. span.innerHTML = html;
  1859. const svg = span.childNodes[0];
  1860. const placeholderAttributes = element.attributes;
  1861. for (let i = 0; i < placeholderAttributes.length; i++) {
  1862. const item = placeholderAttributes.item(i);
  1863. const name = item.name;
  1864. if (name !== "class" && !svg.hasAttribute(name)) {
  1865. svg.setAttribute(name, item.value);
  1866. }
  1867. }
  1868. const classesToAdd = iconClasses(props.icon);
  1869. const addedClasses = applyClasses(svg, classesToAdd, new Set(oldData && oldData.addedClasses), element);
  1870. const addedStyles = applyStyle(svg, customisations.inline ? {
  1871. "vertical-align": "-0.125em"
  1872. } : {}, oldData && oldData.addedStyles);
  1873. const newData = {
  1874. ...props,
  1875. status: "loaded",
  1876. addedClasses,
  1877. addedStyles
  1878. };
  1879. svg[elementDataProperty] = newData;
  1880. if (element.parentNode) {
  1881. element.parentNode.replaceChild(svg, element);
  1882. }
  1883. return svg;
  1884. }
  1885. function encodeSVGforURL(svg) {
  1886. return svg.replace(/"/g, "'").replace(/%/g, "%25").replace(/#/g, "%23").replace(/</g, "%3C").replace(/>/g, "%3E").replace(/\s+/g, " ");
  1887. }
  1888. function svgToURL(svg) {
  1889. return 'url("data:image/svg+xml,' + encodeSVGforURL(svg) + '")';
  1890. }
  1891. var commonProps = {
  1892. display: "inline-block"
  1893. };
  1894. var monotoneProps = {
  1895. "background-color": "currentColor"
  1896. };
  1897. var coloredProps = {
  1898. "background-color": "transparent"
  1899. };
  1900. var propsToAdd = {
  1901. image: "var(--svg)",
  1902. repeat: "no-repeat",
  1903. size: "100% 100%"
  1904. };
  1905. var propsToAddTo = {
  1906. "-webkit-mask": monotoneProps,
  1907. "mask": monotoneProps,
  1908. "background": coloredProps
  1909. };
  1910. for (const prefix in propsToAddTo) {
  1911. const list = propsToAddTo[prefix];
  1912. for (const prop in propsToAdd) {
  1913. list[prefix + "-" + prop] = propsToAdd[prop];
  1914. }
  1915. }
  1916. function fixSize(value) {
  1917. return value + (value.match(/^[-0-9.]+$/) ? "px" : "");
  1918. }
  1919. function renderBackground(element, props, iconData, useMask) {
  1920. const customisations = props.customisations;
  1921. const renderData = iconToSVG(iconData, customisations);
  1922. const renderAttribs = renderData.attributes;
  1923. const oldData = element[elementDataProperty];
  1924. const html = iconToHTML(renderData.body, {
  1925. ...renderAttribs,
  1926. width: iconData.width + "",
  1927. height: iconData.height + ""
  1928. });
  1929. const classesToAdd = iconClasses(props.icon);
  1930. const addedClasses = applyClasses(element, classesToAdd, new Set(oldData && oldData.addedClasses));
  1931. const url = svgToURL(html);
  1932. const newStyles = {
  1933. "--svg": url,
  1934. "width": fixSize(renderAttribs.width),
  1935. "height": fixSize(renderAttribs.height),
  1936. ...commonProps,
  1937. ...useMask ? monotoneProps : coloredProps
  1938. };
  1939. if (customisations.inline) {
  1940. newStyles["vertical-align"] = "-0.125em";
  1941. }
  1942. const addedStyles = applyStyle(element, newStyles, oldData && oldData.addedStyles);
  1943. const newData = {
  1944. ...props,
  1945. status: "loaded",
  1946. addedClasses,
  1947. addedStyles
  1948. };
  1949. element[elementDataProperty] = newData;
  1950. return element;
  1951. }
  1952. var scanQueued = false;
  1953. function checkPendingIcons() {
  1954. if (!scanQueued) {
  1955. scanQueued = true;
  1956. setTimeout(() => {
  1957. if (scanQueued) {
  1958. scanQueued = false;
  1959. scanDOM();
  1960. }
  1961. });
  1962. }
  1963. }
  1964. function scanDOM(rootNode, addTempNode = false) {
  1965. const iconsToLoad = /* @__PURE__ */ Object.create(null);
  1966. function getIcon2(icon, load) {
  1967. const { provider, prefix, name } = icon;
  1968. const storage2 = getStorage(provider, prefix);
  1969. const storedIcon = storage2.icons[name];
  1970. if (storedIcon) {
  1971. return {
  1972. status: "loaded",
  1973. icon: storedIcon
  1974. };
  1975. }
  1976. if (storage2.missing.has(name)) {
  1977. return {
  1978. status: "missing"
  1979. };
  1980. }
  1981. if (load && !isPending(icon)) {
  1982. const providerIconsToLoad = iconsToLoad[provider] || (iconsToLoad[provider] = /* @__PURE__ */ Object.create(null));
  1983. const set = providerIconsToLoad[prefix] || (providerIconsToLoad[prefix] = /* @__PURE__ */ new Set());
  1984. set.add(name);
  1985. }
  1986. return {
  1987. status: "loading"
  1988. };
  1989. }
  1990. (rootNode ? [rootNode] : listRootNodes()).forEach((observedNode) => {
  1991. const root = typeof observedNode.node === "function" ? observedNode.node() : observedNode.node;
  1992. if (!root || !root.querySelectorAll) {
  1993. return;
  1994. }
  1995. let hasPlaceholders = false;
  1996. let paused = false;
  1997. function render(element, props, iconData) {
  1998. if (!paused) {
  1999. paused = true;
  2000. pauseObservingNode(observedNode);
  2001. }
  2002. if (element.tagName.toUpperCase() !== "SVG") {
  2003. const mode = props.mode;
  2004. const isMask = mode === "mask" || (mode === "bg" ? false : mode === "style" ? iconData.body.indexOf("currentColor") !== -1 : null);
  2005. if (typeof isMask === "boolean") {
  2006. renderBackground(element, props, {
  2007. ...defaultIconProps,
  2008. ...iconData
  2009. }, isMask);
  2010. return;
  2011. }
  2012. }
  2013. renderInlineSVG(element, props, iconData);
  2014. }
  2015. scanRootNode(root).forEach(({ node, props }) => {
  2016. const oldData = node[elementDataProperty];
  2017. if (!oldData) {
  2018. const { status, icon } = getIcon2(props.icon, true);
  2019. if (icon) {
  2020. render(node, props, icon);
  2021. return;
  2022. }
  2023. hasPlaceholders = hasPlaceholders || status === "loading";
  2024. node[elementDataProperty] = {
  2025. ...props,
  2026. status
  2027. };
  2028. return;
  2029. }
  2030. let item;
  2031. if (!propsChanged(oldData, props)) {
  2032. const oldStatus = oldData.status;
  2033. if (oldStatus !== "loading") {
  2034. return;
  2035. }
  2036. item = getIcon2(props.icon, false);
  2037. if (!item.icon) {
  2038. oldData.status = item.status;
  2039. return;
  2040. }
  2041. } else {
  2042. item = getIcon2(props.icon, oldData.name !== props.name);
  2043. if (!item.icon) {
  2044. hasPlaceholders = hasPlaceholders || item.status === "loading";
  2045. Object.assign(oldData, {
  2046. ...props,
  2047. status: item.status
  2048. });
  2049. return;
  2050. }
  2051. }
  2052. render(node, props, item.icon);
  2053. });
  2054. if (observedNode.temporary && !hasPlaceholders) {
  2055. stopObserving(root);
  2056. } else if (addTempNode && hasPlaceholders) {
  2057. observe(root, true);
  2058. } else if (paused && observedNode.observer) {
  2059. resumeObservingNode(observedNode);
  2060. }
  2061. });
  2062. for (const provider in iconsToLoad) {
  2063. const providerIconsToLoad = iconsToLoad[provider];
  2064. for (const prefix in providerIconsToLoad) {
  2065. const set = providerIconsToLoad[prefix];
  2066. loadIcons(Array.from(set).map((name) => ({
  2067. provider,
  2068. prefix,
  2069. name
  2070. })), checkPendingIcons);
  2071. }
  2072. }
  2073. }
  2074. function scanElement(root) {
  2075. const node = findRootNode(root);
  2076. if (!node) {
  2077. scanDOM({
  2078. node: root,
  2079. temporary: true
  2080. }, true);
  2081. } else {
  2082. scanDOM(node);
  2083. }
  2084. }
  2085. function generateIcon(name, customisations, returnString = false) {
  2086. const iconData = getIconData(name);
  2087. if (!iconData) {
  2088. return null;
  2089. }
  2090. const iconName = stringToIcon(name);
  2091. const changes = mergeCustomisations(defaultExtendedIconCustomisations, customisations || {});
  2092. const result = renderInlineSVG(document.createElement("span"), {
  2093. name,
  2094. icon: iconName,
  2095. customisations: changes
  2096. }, iconData);
  2097. return returnString ? result.outerHTML : result;
  2098. }
  2099. function getVersion() {
  2100. return "3.1.0";
  2101. }
  2102. function renderSVG(name, customisations) {
  2103. return generateIcon(name, customisations, false);
  2104. }
  2105. function renderHTML(name, customisations) {
  2106. return generateIcon(name, customisations, true);
  2107. }
  2108. function renderIcon(name, customisations) {
  2109. const iconData = getIconData(name);
  2110. if (!iconData) {
  2111. return null;
  2112. }
  2113. const changes = mergeCustomisations(defaultExtendedIconCustomisations, customisations || {});
  2114. return iconToSVG(iconData, changes);
  2115. }
  2116. function scan(root) {
  2117. if (root) {
  2118. scanElement(root);
  2119. } else {
  2120. scanDOM();
  2121. }
  2122. }
  2123. if (typeof document !== "undefined" && typeof window !== "undefined") {
  2124. addBodyNode();
  2125. const _window2 = window;
  2126. if (_window2.IconifyPreload !== void 0) {
  2127. const preload = _window2.IconifyPreload;
  2128. const err = "Invalid IconifyPreload syntax.";
  2129. if (typeof preload === "object" && preload !== null) {
  2130. (preload instanceof Array ? preload : [preload]).forEach((item) => {
  2131. try {
  2132. if (
  2133. // Check if item is an object and not null/array
  2134. typeof item !== "object" || item === null || item instanceof Array || // Check for 'icons' and 'prefix'
  2135. typeof item.icons !== "object" || typeof item.prefix !== "string" || // Add icon set
  2136. !addCollection(item)
  2137. ) {
  2138. console.error(err);
  2139. }
  2140. } catch (e) {
  2141. console.error(err);
  2142. }
  2143. });
  2144. }
  2145. }
  2146. setTimeout(() => {
  2147. initObserver(scanDOM);
  2148. scanDOM();
  2149. });
  2150. }
  2151. function enableCache(storage2, enable) {
  2152. toggleBrowserCache(storage2, enable !== false);
  2153. }
  2154. function disableCache(storage2) {
  2155. toggleBrowserCache(storage2, true);
  2156. }
  2157. setAPIModule("", fetchAPIModule);
  2158. if (typeof document !== "undefined" && typeof window !== "undefined") {
  2159. initBrowserStorage();
  2160. const _window2 = window;
  2161. if (_window2.IconifyProviders !== void 0) {
  2162. const providers = _window2.IconifyProviders;
  2163. if (typeof providers === "object" && providers !== null) {
  2164. for (const key in providers) {
  2165. const err = "IconifyProviders[" + key + "] is invalid.";
  2166. try {
  2167. const value = providers[key];
  2168. if (typeof value !== "object" || !value || value.resources === void 0) {
  2169. continue;
  2170. }
  2171. if (!addAPIProvider(key, value)) {
  2172. console.error(err);
  2173. }
  2174. } catch (e) {
  2175. console.error(err);
  2176. }
  2177. }
  2178. }
  2179. }
  2180. }
  2181. var _api = {
  2182. getAPIConfig,
  2183. setAPIModule,
  2184. sendAPIQuery,
  2185. setFetch,
  2186. getFetch,
  2187. listAPIProviders
  2188. };
  2189. var Iconify = {
  2190. // IconifyAPIInternalFunctions
  2191. _api,
  2192. // IconifyAPIFunctions
  2193. addAPIProvider,
  2194. loadIcons,
  2195. loadIcon,
  2196. // IconifyStorageFunctions
  2197. iconExists,
  2198. getIcon,
  2199. listIcons,
  2200. addIcon,
  2201. addCollection,
  2202. // IconifyBuilderFunctions
  2203. replaceIDs,
  2204. calculateSize,
  2205. buildIcon: iconToSVG,
  2206. // IconifyCommonFunctions
  2207. getVersion,
  2208. renderSVG,
  2209. renderHTML,
  2210. renderIcon,
  2211. scan,
  2212. observe,
  2213. stopObserving,
  2214. pauseObserver,
  2215. resumeObserver,
  2216. // IconifyBrowserCacheFunctions
  2217. enableCache,
  2218. disableCache
  2219. };
  2220. try {
  2221. if (self.Iconify === void 0) {
  2222. self.Iconify = Iconify;
  2223. }
  2224. } catch (err) {
  2225. }
  2226. export {
  2227. _api,
  2228. addAPIProvider,
  2229. addCollection,
  2230. addIcon,
  2231. iconToSVG as buildIcon,
  2232. calculateSize,
  2233. Iconify as default,
  2234. disableCache,
  2235. enableCache,
  2236. getIcon,
  2237. getVersion,
  2238. iconExists,
  2239. listIcons,
  2240. loadIcon,
  2241. loadIcons,
  2242. observe,
  2243. pauseObserver,
  2244. renderHTML,
  2245. renderIcon,
  2246. renderSVG,
  2247. replaceIDs,
  2248. resumeObserver,
  2249. scan,
  2250. stopObserving
  2251. };
  2252. /*! Bundled license information:
  2253. @iconify/iconify/dist/iconify.mjs:
  2254. (**
  2255. * (c) Iconify
  2256. *
  2257. * For the full copyright and license information, please view the license.txt or license.gpl.txt
  2258. * files at https://github.com/iconify/iconify
  2259. *
  2260. * Licensed under MIT.
  2261. *
  2262. * @license MIT
  2263. * @version 3.1.0
  2264. *)
  2265. */
  2266. //# sourceMappingURL=@iconify_iconify.js.map