/* esm.sh - yaml@2.9.1/browser/dist/nodes/YAMLSeq */
import{createNode as c}from"../doc/createNode.mjs";import{stringifyCollection as d}from"../stringify/stringifyCollection.mjs";import{Collection as p}from"./Collection.mjs";import{SEQ as h,isScalar as m}from"./identity.mjs";import{isScalarValue as g}from"./Scalar.mjs";import{toJS as S}from"./toJS.mjs";var l=class extends p{static get tagName(){return"tag:yaml.org,2002:seq"}constructor(t){super(h,t),this.items=[]}add(t){this.items.push(t)}delete(t){let e=f(t);return typeof e!="number"?!1:this.items.splice(e,1).length>0}get(t,e){let i=f(t);if(typeof i!="number")return;let r=this.items[i];return!e&&m(r)?r.value:r}has(t){let e=f(t);return typeof e=="number"&&e<this.items.length}set(t,e){let i=f(t);if(typeof i!="number")throw new Error(`Expected a valid index, not ${t}.`);let r=this.items[i];m(r)&&g(e)?r.value=e:this.items[i]=e}toJSON(t,e){let i=[];e?.onCreate&&e.onCreate(i);let r=0;for(let s of this.items)i.push(S(s,String(r++),e));return i}toString(t,e,i){return t?d(this,t,{blockItemPrefix:"- ",flowChars:{start:"[",end:"]"},itemIndent:(t.indent||"")+"  ",onChompKeep:i,onComment:e}):JSON.stringify(this)}static from(t,e,i){let{replacer:r}=i,s=new this(t);if(e&&Symbol.iterator in Object(e)){let u=0;for(let o of e){if(typeof r=="function"){let a=e instanceof Set?o:String(u++);o=r.call(e,a,o)}s.items.push(c(o,void 0,i))}}return s}};function f(n){let t=m(n)?n.value:n;return t&&typeof t=="string"&&(t=Number(t)),typeof t=="number"&&Number.isInteger(t)&&t>=0?t:null}export{l as YAMLSeq};
//# sourceMappingURL=YAMLSeq.mjs.map