/**
 * Minified by jsDelivr using Terser v5.39.0.
 * Original file: /npm/@iconify/tailwind4@1.2.3/lib/plugin.js
 *
 * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
 */
import plugin from"tailwindcss/plugin";import{getDynamicCSSRules}from"./plugins/dynamic.js";import{getCSSComponentsForPlugin,getCSSRulesForPlugin}from"./plugins/preparsed.js";import{importDirectorySync,cleanupSVG,parseColors,runSVGO,isEmptyColor}from"@iconify/tools";function getBooleanValue(e,r){switch(e){case!0:case"1":case"true":return!0;case!1:case"0":case"false":return!1}return r??!1}function getFloatValue(e,r){if("number"==typeof e)return e;if("string"==typeof e){const o=parseFloat(e);return isNaN(o)?r:o}return r}const exportedPlugin=plugin.withOptions((e=>{const r={},o={};return Object.entries(e??{}).forEach((([e,t])=>{switch(e){case"prefix":return!1===t&&(r.prefix=""),void("string"==typeof t&&(r.prefix=t));case"overrideOnly":case"override-only":case"overrideonly":return void(r.overrideOnly=getBooleanValue(t,r.overrideOnly??!1));case"prefixes":return"string"==typeof t?void(o.prefixes=[t]):Array.isArray(t)?void(o.prefixes=t):void 0;case"iconSelector":case"icon-selector":case"iconselector":return void("string"==typeof t&&(o.iconSelector=t));case"maskSelector":case"mask-selector":case"maskselector":return void("string"==typeof t&&(o.maskSelector=t));case"backgroundSelector":case"background-selector":case"backgroundselector":return void("string"==typeof t&&(o.backgroundSelector=t));case"icon-sets":case"iconSets":case"iconsets":const e=parseCssObject("icon-sets",["from-json","from-folder"],t).map((({key:e,value:r,type:o})=>"from-folder"===o?[e,iconSetFromFolder(r)]:[e,r])),s=Object.fromEntries(e);return o.iconSets=s,void(r.iconSets=s);case"varName":case"var-name":case"varname":return void("string"==typeof t&&(o.varName=t));case"square":return void(o.square=getBooleanValue(t,o.square??!0));case"scale":{const e=getFloatValue(t,r.scale??1);return r.scale=e,void(o.scale=e)}}})),({matchComponents:e,addComponents:t,addUtilities:s})=>{const n=r.prefix??"icon";n&&e({[n]:e=>{try{const t=getDynamicCSSRules(e,r);return o.square&&t.width&&t.width!==t.height&&(t.height?t.width=t.height:delete t.width),t}catch(e){return console.warn(e.message),{}}}}),o.prefixes&&(t(getCSSComponentsForPlugin(o)),s(getCSSRulesForPlugin(o)))}})),parseCssObject=(e,r,o)=>{if("string"==typeof o)return parseCssObject(e,r,[o]);const t=`Invalid ${e} property: ${o}\nallowed values: ${r.map((e=>`${e}(key1, value1)`)).join(", ")};`;if(o.constructor!==Array)throw new Error(t);return o.map((e=>{const o=e.match(new RegExp(`^(${r.join("|")})\\((.*)\\s*,\\s*(.*)\\)$`));if(!o)throw new Error(t);const s=o[1];return{key:parseCssString(o[2]),value:parseCssString(o[3]),type:s}}))},parseCssString=e=>{const r=e.match(/^['"]?([^'"]+)['"]?$/);return r?r[1]:e},iconSetFromFolder=e=>{const r=importDirectorySync(e);return r.forEachSync(((e,o)=>{if("icon"!==o)return;const t=r.toSVG(e);if(t){try{cleanupSVG(t);const e=parseColors(t),r=e.colors.filter((e=>"string"==typeof e||!isEmptyColor(e)));r.length+(e.hasUnsetColor?1:0)<2&&parseColors(t,{defaultColor:"currentColor",callback:(e,r,o)=>!o||isEmptyColor(o)?r:"currentColor"}),runSVGO(t)}catch(o){return console.error(`Error parsing ${e}:`,o),void r.remove(e)}r.fromSVG(e,t)}else r.remove(e)})),r.export()};export default exportedPlugin;
//# sourceMappingURL=/sm/b86232f3275ea6bb701aff5862956b4d5e657d08db33ff9712cd5e3d8825df99.map