Repository: holoviz/panel

Issue:
Error raised when removing last tab for pn.Tabs component
#### ALL software version info
Im currently on the panel 1.0.2 version

#### Description of expected behavior and the observed behavior
If i close the last tab of a Tabs component, no error should be thrown.
#### Complete, minimal, self-contained example code that reproduces the issue
```python
import panel as pn


pn.extension()

tabs = pn.Tabs(
    ("MyTab", "Hello"),
    ("MyOtherTab", "Hello2"),
    closable=True
)

tabs.servable()

```


#### Stack traceback and/or browser JavaScript console output
```
2023-05-23 09:50:01,867 ERROR: panel.reactive - Callback failed for object named "Tabs00121" changing properties {'active': -1, 'objects': []} 
Traceback (most recent call last):
  File "C:\Users\R2D2\PycharmProjects\pythonProject\abahatchi\venv\lib\site-packages\panel\reactive.py", line 379, in _process_events
    self.param.update(**self_events)
  File "C:\Users\R2D2\PycharmProjects\pythonProject\abahatchi\venv\lib\site-packages\param\parameterized.py", line 1895, in update
    setattr(self_or_cls, k, v)
  File "C:\Users\R2D2\PycharmProjects\pythonProject\abahatchi\venv\lib\site-packages\param\parameterized.py", line 367, in _f
    instance_param.__set__(obj, val)
  File "C:\Users\R2D2\PycharmProjects\pythonProject\abahatchi\venv\lib\site-packages\param\parameterized.py", line 369, in _f
    return f(self, obj, val)
  File "C:\Users\R2D2\PycharmProjects\pythonProject\abahatchi\venv\lib\site-packages\param\__init__.py", line 625, in __set__
    super(Dynamic,self).__set__(obj,val)
  File "C:\Users\R2D2\PycharmProjects\pythonProject\abahatchi\venv\lib\site-packages\param\parameterized.py", line 369, in _f
    return f(self, obj, val)
  File "C:\Users\R2D2\PycharmProjects\pythonProject\abahatchi\venv\lib\site-packages\param\parameterized.py", line 1201, in __set__
    self._validate(val)
  File "C:\Users\R2D2\PycharmProjects\pythonProject\abahatchi\venv\lib\site-packages\param\__init__.py", line 947, in _validate
    self._validate_bounds(val, self.bounds, self.inclusive_bounds)
  File "C:\Users\R2D2\PycharmProjects\pythonProject\abahatchi\venv\lib\site-packages\param\__init__.py", line 920, in _validate_bounds
    raise ValueError("Parameter %r must be at least %s, "
ValueError: Parameter 'active' must be at least 0, not -1.
2023-05-23 09:50:01,872 Exception in callback functools.partial(<bound method IOLoop._discard_future_result of <tornado.platform.asyncio.AsyncIOMainLoop object at 0x000001A7A707EEE0>>, <Task finished name='Task-123' coro=<Server
Session.with_document_locked() done, defined at C:\Users\R2D2\PycharmProjects\pythonProject\abahatchi\venv\lib\site-packages\bokeh\server\session.py:77> exception=ValueError("Parameter 'active' must be at least 0, not -1.")>)   
Traceback (most recent call last):
  File "C:\Users\R2D2\PycharmProjects\pythonProject\abahatchi\venv\lib\site-packages\tornado\ioloop.py", line 738, in _run_callback
    ret = callback()
  File "C:\Users\R2D2\PycharmProjects\pythonProject\abahatchi\venv\lib\site-packages\tornado\ioloop.py", line 762, in _discard_future_result
  File "C:\Users\R2D2\PycharmProjects\pythonProject\abahatchi\venv\lib\site-packages\param\parameterized.py", line 367, in _f
    instance_param.__set__(obj, val)
  File "C:\Users\R2D2\PycharmProjects\pythonProject\abahatchi\venv\lib\site-packages\param\parameterized.py", line 369, in _f
    return f(self, obj, val)
  File "C:\Users\R2D2\PycharmProjects\pythonProject\abahatchi\venv\lib\site-packages\param\__init__.py", line 625, in __set__
    super(Dynamic,self).__set__(obj,val)
  File "C:\Users\R2D2\PycharmProjects\pythonProject\abahatchi\venv\lib\site-packages\param\parameterized.py", line 369, in _f
    return f(self, obj, val)
  File "C:\Users\R2D2\PycharmProjects\pythonProject\abahatchi\venv\lib\site-packages\param\parameterized.py", line 1201, in __set__
    self._validate(val)
  File "C:\Users\R2D2\PycharmProjects\pythonProject\abahatchi\venv\lib\site-packages\param\__init__.py", line 947, in _validate
    self._validate_bounds(val, self.bounds, self.inclusive_bounds)
  File "C:\Users\R2D2\PycharmProjects\pythonProject\abahatchi\venv\lib\site-packages\param\__init__.py", line 920, in _validate_bounds
    raise ValueError("Parameter %r must be at least %s, "
ValueError: Parameter 'active' must be at least 0, not -1.

```


Setting closable=True for a Tabs component and them closing all tabs, raises an error.
This should not happen, as it breaks the compnent. Adding tabs dynamically after that does not work



Discussion:

Resolving patch:
diff --git a/panel/layout/tabs.py b/panel/layout/tabs.py
--- a/panel/layout/tabs.py
+++ b/panel/layout/tabs.py
@@ -76,11 +76,12 @@ class Tabs(NamedListPanel):
     def __init__(self, *objects, **params):
         super().__init__(*objects, **params)
         self._rendered = defaultdict(dict)
-        self.param.active.bounds = (0, len(self)-1)
+        self.param.active.bounds = (-1, len(self)-1)
         self.param.watch(self._update_active, ['dynamic', 'active'])
 
     def _update_names(self, event):
-        self.param.active.bounds = (0, len(event.new)-1)
+        # No active tabs will have a value of -1
+        self.param.active.bounds = (-1, len(event.new)-1)
         super()._update_names(event)
 
     def _cleanup(self, root: Model | None = None) -> None:


Test patch: