# Path: lib/iterutils.py
# def pairwise_cyclic(a):
#     import itertools
#     b = itertools.cycle(a)
#     next(b)
#     return zip(a, b)
# 
# def quadwise_cyclic(a1, b1):
#     import itertools
#     a2 = itertools.cycle(a1)
#     next(a2)
#     b2 = itertools.cycle(b1)
#     next(b2)
#     return zip(a2, a1, b1, b2)


from collections.abc import Iterable
from bpy.types import Object
from bmesh.types import BMesh, BMVert, BMEdge, BMFace
from mathutils import Matrix
from .iterutils import pairwise_cyclic, quadwise_cyclic
import bpy
import bmesh
            length += edge.calc_length()

        bm.free()

        # Restore curve
        # ---------------------------

        for k, v in settings.items():
            setattr(ob.data, k, v)

    else:

        curve = ob.data.copy()
        curve.transform(ob.matrix_world)

        length = 0.0

        for spline in curve.splines:
            length += spline.calc_length()

        bpy.data.curves.remove(curve)

    return length


def connect_verts(bm: BMesh, verts: list[BMVert]) -> list[BMEdge]:
    return [bm.edges.new(x) for x in pairwise_cyclic(verts)]


def bridge_verts(bm: BMesh, v1: list[BMVert], v2: list[BMVert]) -> tuple[list[BMEdge], list[BMFace]]:

# Path: lib/iterutils.py
# def pairwise_cyclic(a):
#     import itertools
#     b = itertools.cycle(a)
#     next(b)
#     return zip(a, b)
# 
# def quadwise_cyclic(a1, b1):
#     import itertools
#     a2 = itertools.cycle(a1)
#     next(a2)
#     b2 = itertools.cycle(b1)
#     next(b2)
#     return zip(a2, a1, b1, b2)


# Path: lib/mesh.py
from collections.abc import Iterable
from bpy.types import Object
from bmesh.types import BMesh, BMVert, BMEdge, BMFace
from mathutils import Matrix
from .iterutils import pairwise_cyclic, quadwise_cyclic
import bpy
import bmesh

            length += edge.calc_length()

        bm.free()

        # Restore curve
        # ---------------------------

        for k, v in settings.items():
            setattr(ob.data, k, v)

    else:

        curve = ob.data.copy()
        curve.transform(ob.matrix_world)

        length = 0.0

        for spline in curve.splines:
            length += spline.calc_length()

        bpy.data.curves.remove(curve)

    return length


def connect_verts(bm: BMesh, verts: list[BMVert]) -> list[BMEdge]:
    return [bm.edges.new(x) for x in pairwise_cyclic(verts)]


def bridge_verts(bm: BMesh, v1: list[BMVert], v2: list[BMVert]) -> tuple[list[BMEdge], list[BMFace]]:

    faces = [bm.faces.new(x) for x in quadwise_cyclic(v1, v2)]