import{__require as e}from"../../fill-range/index.mjs";import{__require as r}from"./stringify.mjs";import{__require as t}from"./utils.mjs";var n,o;function i(){if(o)return n;o=1;const i=e(),s=r(),a=t(),p=(e="",r="",t=!1)=>{const n=[];if(e=[].concat(e),!(r=[].concat(r)).length)return e;if(!e.length)return t?a.flatten(r).map(e=>`{${e}}`):r;for(const o of e)if(Array.isArray(o))for(const e of o)n.push(p(e,r,t));else for(let e of r)!0===t&&"string"==typeof e&&(e=`{${e}}`),n.push(Array.isArray(e)?p(o,e,t):o+e);return a.flatten(n)};return n=(e,r={})=>{const t=void 0===r.rangeLimit?1e3:r.rangeLimit,n=(e,o={})=>{e.queue=[];let u=o,l=o.queue;for(;"brace"!==u.type&&"root"!==u.type&&u.parent;)u=u.parent,l=u.queue;if(e.invalid||e.dollar)return void l.push(p(l.pop(),s(e,r)));if("brace"===e.type&&!0!==e.invalid&&2===e.nodes.length)return void l.push(p(l.pop(),["{}"]));if(e.nodes&&e.ranges>0){const n=a.reduce(e.nodes);if(a.exceedsLimit(...n,r.step,t))throw new RangeError("expanded array length exceeds range limit. Use options.rangeLimit to increase or disable the limit.");let o=i(...n,r);return 0===o.length&&(o=s(e,r)),l.push(p(l.pop(),o)),void(e.nodes=[])}const f=a.encloseBrace(e);let c=e.queue,d=e;for(;"brace"!==d.type&&"root"!==d.type&&d.parent;)d=d.parent,c=d.queue;for(let r=0;r<e.nodes.length;r++){const t=e.nodes[r];"comma"!==t.type||"brace"!==e.type?"close"!==t.type?t.value&&"open"!==t.type?c.push(p(c.pop(),t.value)):t.nodes&&n(t,e):l.push(p(l.pop(),c,f)):(1===r&&c.push(""),c.push(""))}return c};return a.flatten(n(e))}}export{i as __require};