"""Custom node groups"""
import bpy
from .node_arranger import tidy_tree

# docs-special-members: __init__
# no-inherited-members


class NodeGroup:
	"""Generic Node Group"""
	TYPE = 'Compositor'

	def __init__(self, name: str, node_tree: bpy.types.NodeTree):
		"""
		A generic NodeGroup class

		:param name: Name of node group
		:param node_tree: NodeTree to add group to
		"""
		self.name = name
		self.node_tree = node_tree
		self.group = bpy.data.node_groups.new(type=f'{self.TYPE}NodeTree', name=name)

		self.gn = group_node = node_tree.nodes.new(f"{self.TYPE}NodeGroup")
		group_node.node_tree = self.group

		self.input_node = self.group.nodes.new("NodeGroupInput")
		self.output_node = self.group.nodes.new("NodeGroupOutput")

	def tidy(self):
		tidy_tree(self.group)

	@property
	def inputs(self) -> dict:
		"""Input sockets"""
		return self.gn.inputs

	@property
	def outputs(self) -> dict:
		"""Output sockets"""
		return self.gn.outputs

	def input(self, name: str) -> bpy.types.NodeSocket:
		"""Get input socket by name"""
		return self.inputs[name]

	def output(self, name: str) -> bpy.types.NodeSocket:
		"""Get output socket by name"""
		return self.outputs[name]

	def add_node(self, key: str) -> bpy.types.Node:
		"""Create a new node in the group by name"""
		return self.group.nodes.new(key)

	def link(self, from_socket: bpy.types.NodeSocket, to_socket: bpy.types.NodeSocket) -> bpy.types.NodeLink:
		"""
		Link two sockets in the group

		:param from_socket: Socket to link from
		:param to_socket: Socket to link to
		"""
		return self.group.links.new(from_socket, to_socket)

	def __str__(self):
		return f"{self.TYPE}NodeGroup({self.name})"

	def update(self, camera=None, scene=None):
		pass


class CompositorNodeGroup(NodeGroup):
	"""Node Group for use in the compositor"""
	TYPE = 'Compositor'


class ShaderNodeGroup(NodeGroup):
	"""Node Group for use in the shader editor"""
	TYPE = 'Shader'

614e57c5c3456fb627b032c00bbb7c2959225b8d
<mask token>


class NodeGroup:
    <mask token>
    <mask token>
    <mask token>
    <mask token>
    <mask token>
    <mask token>
    <mask token>
    <mask token>
    <mask token>

    def link(self, from_socket: bpy.types.NodeSocket, to_socket: bpy.types.
        NodeSocket) ->bpy.types.NodeLink:
        """
		Link two sockets in the group

		:param from_socket: Socket to link from
		:param to_socket: Socket to link to
		"""
        return self.group.links.new(from_socket, to_socket)

    def __str__(self):
        return f'{self.TYPE}NodeGroup({self.name})'
    <mask token>


class CompositorNodeGroup(NodeGroup):
    """Node Group for use in the compositor"""
    TYPE = 'Compositor'


class ShaderNodeGroup(NodeGroup):
    """Node Group for use in the shader editor"""
    TYPE = 'Shader'

<mask token>


class NodeGroup:
    <mask token>
    <mask token>
    <mask token>
    <mask token>

    @property
    def inputs(self) ->dict:
        """Input sockets"""
        return self.gn.inputs

    @property
    def outputs(self) ->dict:
        """Output sockets"""
        return self.gn.outputs

    def input(self, name: str) ->bpy.types.NodeSocket:
        """Get input socket by name"""
        return self.inputs[name]
    <mask token>

    def add_node(self, key: str) ->bpy.types.Node:
        """Create a new node in the group by name"""
        return self.group.nodes.new(key)

    def link(self, from_socket: bpy.types.NodeSocket, to_socket: bpy.types.
        NodeSocket) ->bpy.types.NodeLink:
        """
		Link two sockets in the group

		:param from_socket: Socket to link from
		:param to_socket: Socket to link to
		"""
        return self.group.links.new(from_socket, to_socket)

    def __str__(self):
        return f'{self.TYPE}NodeGroup({self.name})'

    def update(self, camera=None, scene=None):
        pass


class CompositorNodeGroup(NodeGroup):
    """Node Group for use in the compositor"""
    TYPE = 'Compositor'


class ShaderNodeGroup(NodeGroup):
    """Node Group for use in the shader editor"""
    TYPE = 'Shader'

<mask token>


class NodeGroup:
    <mask token>
    <mask token>
    <mask token>
    <mask token>

    @property
    def inputs(self) ->dict:
        """Input sockets"""
        return self.gn.inputs

    @property
    def outputs(self) ->dict:
        """Output sockets"""
        return self.gn.outputs

    def input(self, name: str) ->bpy.types.NodeSocket:
        """Get input socket by name"""
        return self.inputs[name]

    def output(self, name: str) ->bpy.types.NodeSocket:
        """Get output socket by name"""
        return self.outputs[name]

    def add_node(self, key: str) ->bpy.types.Node:
        """Create a new node in the group by name"""
        return self.group.nodes.new(key)

    def link(self, from_socket: bpy.types.NodeSocket, to_socket: bpy.types.
        NodeSocket) ->bpy.types.NodeLink:
        """
		Link two sockets in the group

		:param from_socket: Socket to link from
		:param to_socket: Socket to link to
		"""
        return self.group.links.new(from_socket, to_socket)

    def __str__(self):
        return f'{self.TYPE}NodeGroup({self.name})'

    def update(self, camera=None, scene=None):
        pass


class CompositorNodeGroup(NodeGroup):
    """Node Group for use in the compositor"""
    TYPE = 'Compositor'


class ShaderNodeGroup(NodeGroup):
    """Node Group for use in the shader editor"""
    TYPE = 'Shader'

<mask token>


class NodeGroup:
    <mask token>
    <mask token>

    def __init__(self, name: str, node_tree: bpy.types.NodeTree):
        """
		A generic NodeGroup class

		:param name: Name of node group
		:param node_tree: NodeTree to add group to
		"""
        self.name = name
        self.node_tree = node_tree
        self.group = bpy.data.node_groups.new(type=f'{self.TYPE}NodeTree',
            name=name)
        self.gn = group_node = node_tree.nodes.new(f'{self.TYPE}NodeGroup')
        group_node.node_tree = self.group
        self.input_node = self.group.nodes.new('NodeGroupInput')
        self.output_node = self.group.nodes.new('NodeGroupOutput')
    <mask token>

    @property
    def inputs(self) ->dict:
        """Input sockets"""
        return self.gn.inputs

    @property
    def outputs(self) ->dict:
        """Output sockets"""
        return self.gn.outputs

    def input(self, name: str) ->bpy.types.NodeSocket:
        """Get input socket by name"""
        return self.inputs[name]

    def output(self, name: str) ->bpy.types.NodeSocket:
        """Get output socket by name"""
        return self.outputs[name]

    def add_node(self, key: str) ->bpy.types.Node:
        """Create a new node in the group by name"""
        return self.group.nodes.new(key)

    def link(self, from_socket: bpy.types.NodeSocket, to_socket: bpy.types.
        NodeSocket) ->bpy.types.NodeLink:
        """
		Link two sockets in the group

		:param from_socket: Socket to link from
		:param to_socket: Socket to link to
		"""
        return self.group.links.new(from_socket, to_socket)

    def __str__(self):
        return f'{self.TYPE}NodeGroup({self.name})'

    def update(self, camera=None, scene=None):
        pass


class CompositorNodeGroup(NodeGroup):
    """Node Group for use in the compositor"""
    TYPE = 'Compositor'


class ShaderNodeGroup(NodeGroup):
    """Node Group for use in the shader editor"""
    TYPE = 'Shader'

"""Custom node groups"""
import bpy
from .node_arranger import tidy_tree

# docs-special-members: __init__
# no-inherited-members


class NodeGroup:
	"""Generic Node Group"""
	TYPE = 'Compositor'

	def __init__(self, name: str, node_tree: bpy.types.NodeTree):
		"""
		A generic NodeGroup class

		:param name: Name of node group
		:param node_tree: NodeTree to add group to
		"""
		self.name = name
		self.node_tree = node_tree
		self.group = bpy.data.node_groups.new(type=f'{self.TYPE}NodeTree', name=name)

		self.gn = group_node = node_tree.nodes.new(f"{self.TYPE}NodeGroup")
		group_node.node_tree = self.group

		self.input_node = self.group.nodes.new("NodeGroupInput")
		self.output_node = self.group.nodes.new("NodeGroupOutput")

	def tidy(self):
		tidy_tree(self.group)

	@property
	def inputs(self) -> dict:
		"""Input sockets"""
		return self.gn.inputs

	@property
	def outputs(self) -> dict:
		"""Output sockets"""
		return self.gn.outputs

	def input(self, name: str) -> bpy.types.NodeSocket:
		"""Get input socket by name"""
		return self.inputs[name]

	def output(self, name: str) -> bpy.types.NodeSocket:
		"""Get output socket by name"""
		return self.outputs[name]

	def add_node(self, key: str) -> bpy.types.Node:
		"""Create a new node in the group by name"""
		return self.group.nodes.new(key)

	def link(self, from_socket: bpy.types.NodeSocket, to_socket: bpy.types.NodeSocket) -> bpy.types.NodeLink:
		"""
		Link two sockets in the group

		:param from_socket: Socket to link from
		:param to_socket: Socket to link to
		"""
		return self.group.links.new(from_socket, to_socket)

	def __str__(self):
		return f"{self.TYPE}NodeGroup({self.name})"

	def update(self, camera=None, scene=None):
		pass


class CompositorNodeGroup(NodeGroup):
	"""Node Group for use in the compositor"""
	TYPE = 'Compositor'


class ShaderNodeGroup(NodeGroup):
	"""Node Group for use in the shader editor"""
	TYPE = 'Shader'
