diff --git a/app/Http/Controllers/Campaign/GalleryController.php b/app/Http/Controllers/Campaign/GalleryController.php index 00f066b6d3..76707114af 100644 --- a/app/Http/Controllers/Campaign/GalleryController.php +++ b/app/Http/Controllers/Campaign/GalleryController.php @@ -51,7 +51,7 @@ public function show(Campaign $campaign) */ public function store(GalleryImageStore $request, Campaign $campaign) { - $this->authorize('gallery', $campaign); + $this->authorize('create', [Image::class, $campaign]); $images = $this->service ->campaign($campaign) @@ -80,7 +80,7 @@ public function store(GalleryImageStore $request, Campaign $campaign) */ public function edit(Campaign $campaign, Image $image) { - $this->authorize('gallery', $campaign); + $this->authorize('view', [$image, $campaign]); $folders = $this->service->campaign($campaign)->folderList(); @@ -93,7 +93,7 @@ public function edit(Campaign $campaign, Image $image) */ public function update(GalleryImageUpdate $request, Campaign $campaign, Image $image) { - $this->authorize('gallery', $campaign); + $this->authorize('edit', [$image, $campaign]); $originalFolderID = $image->folder_id; $this->service @@ -122,7 +122,7 @@ public function update(GalleryImageUpdate $request, Campaign $campaign, Image $i */ public function destroy(Campaign $campaign, Image $image) { - $this->authorize('gallery', $campaign); + $this->authorize('delete', [$image, $campaign]); $options = [$campaign]; if ($image->folder_id) { diff --git a/app/Http/Controllers/Campaign/RoleController.php b/app/Http/Controllers/Campaign/RoleController.php index dd37678da7..295ad4c244 100644 --- a/app/Http/Controllers/Campaign/RoleController.php +++ b/app/Http/Controllers/Campaign/RoleController.php @@ -8,24 +8,24 @@ use App\Http\Requests\StoreCampaignRole; use App\Models\Campaign; use App\Models\CampaignRole; -use App\Services\PermissionService; +use App\Services\Permissions\RolePermissionService; use Illuminate\Http\Request; class RoleController extends Controller { protected string $view = 'campaigns.roles'; - protected PermissionService $service; + protected RolePermissionService $service; /** * Create a new controller instance. * @return void */ - public function __construct(PermissionService $permissionService) + public function __construct(RolePermissionService $rolePermissionService) { $this->middleware('auth'); $this->middleware('campaign.member'); - $this->service = $permissionService; + $this->service = $rolePermissionService; } /** @@ -111,7 +111,11 @@ public function store(StoreCampaignRole $request, Campaign $campaign) $data = $request->all() + ['campaign_id' => $campaign->id]; $role = CampaignRole::create($data); if ($request->has('duplicate') && $request->get('duplicate') != 0) { - $this->service->role($role)->duplicate($request->get('role_id')); + /** @var CampaignRole $copy */ + $copy = CampaignRole::where('id', $request->get('role_id'))->first(); + if ($copy) { + $copy->duplicate($role); + } } return redirect()->route('campaign_roles.index', $campaign) ->with('success_raw', __($this->view . '.create.success', ['name' => $role->name])); @@ -132,6 +136,7 @@ public function show(Campaign $campaign, CampaignRole $campaignRole) 'role' => $campaignRole, 'campaign' => $campaign, 'members' => $members, + 'permissionService' => $this->service->role($campaignRole) ]); } @@ -176,7 +181,7 @@ public function savePermissions(Request $request, Campaign $campaign, CampaignRo $this->authorize('view', [$campaignRole, $campaign]); $this->authorize('update', $campaignRole); - $campaignRole->savePermissions($request->post('permissions', [])); + $this->service->role($campaignRole)->savePermissions($request->post('permissions', [])); return redirect()->route('campaign_roles.show', [$campaign, 'campaign_role' => $campaignRole]) ->with('success', trans('crud.permissions.success')); @@ -249,7 +254,7 @@ public function toggle(Campaign $campaign, CampaignRole $campaignRole, int $enti abort(404); } - $enabled = $campaignRole->toggle($entityType, $action); + $enabled = $this->service->role($campaignRole)->toggle($entityType, $action); return response()->json([ 'success' => true, 'status' => $enabled, diff --git a/app/Http/Controllers/Summernote/GalleryController.php b/app/Http/Controllers/Summernote/GalleryController.php index 7d47b5ea5e..7c16090204 100644 --- a/app/Http/Controllers/Summernote/GalleryController.php +++ b/app/Http/Controllers/Summernote/GalleryController.php @@ -47,7 +47,9 @@ public function index(Campaign $campaign) 'url' => route('campaign.gallery.summernote', $image->folder_id ? [$campaign, 'folder_id' => $image->folder_id] : [$campaign]), ]; } - $images = Image::where('is_default', false) + $canBrowse = auth()->user()->can('browse', [Image::class, $campaign]); + $images = Image::acl($canBrowse) + ->where('is_default', false) ->orderBy('is_folder', 'desc') ->orderBy('updated_at', 'desc') ->imageFolder($folderId) @@ -85,7 +87,7 @@ public function index(Campaign $campaign) */ public function upload(GalleryImageStore $request, Campaign $campaign): JsonResponse { - $this->authorize('gallery', $campaign); + $this->authorize('create', [Image::class, $campaign]); $images = $this->service ->campaign($campaign) diff --git a/app/Models/CampaignPermission.php b/app/Models/CampaignPermission.php index e1a5234176..32d630329b 100644 --- a/app/Models/CampaignPermission.php +++ b/app/Models/CampaignPermission.php @@ -46,10 +46,10 @@ class CampaignPermission extends Model public const ACTION_GALLERY = 13; public const ACTION_CAMPAIGN = 14; - /** - * @var bool|array - */ - protected $cachedSegments = false; + public const ACTION_GALLERY_BROWSE = 15; + public const ACTION_GALLERY_UPLOAD = 16; + + protected array $cachedSegments; /** @var string[] */ protected $fillable = [ @@ -152,7 +152,7 @@ public function type() protected function segments(): array { - if ($this->cachedSegments === false) { + if (!isset($this->cachedSegments)) { $this->cachedSegments = explode('_', $this->key); } return $this->cachedSegments; @@ -213,4 +213,14 @@ public function invalidKey(): bool $end = last($segments); return is_numeric($end) && empty($this->entity_id); } + + public function isGallery(): bool + { + $galleryPermissions = [ + self::ACTION_GALLERY, + self::ACTION_GALLERY_BROWSE, + self::ACTION_GALLERY_UPLOAD, + ]; + return in_array($this->action, $galleryPermissions); + } } diff --git a/app/Models/CampaignRole.php b/app/Models/CampaignRole.php index ac12b53ff4..d4a72dff9c 100644 --- a/app/Models/CampaignRole.php +++ b/app/Models/CampaignRole.php @@ -8,7 +8,6 @@ use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\HasMany; use Illuminate\Database\Eloquent\Builder; -use Illuminate\Support\Str; /** * Class Attribute @@ -131,49 +130,6 @@ public function rolePermissions() ->whereNull('entity_id'); } - /** - */ - public function savePermissions(array $permissions = []) - { - // Load existing - $existing = []; - foreach ($this->rolePermissions as $permission) { - if (empty($permission->entity_type_id)) { - $existing['campaign_' . $permission->action] = $permission; - continue; - } - $existing[$permission->entity_type_id . '_' . $permission->action] = $permission; - } - - // Loop on submitted form - if (empty($permissions)) { - $permissions = []; - } - - foreach ($permissions as $key => $module) { - // Check if exists$ - if (isset($existing[$key])) { - // Do nothing - unset($existing[$key]); - } else { - $action = Str::after($key, '_'); - if ($module === 'campaign') { - $module = 0; - } - - $this->add($module, (int) $action); - } - } - - // Delete existing that weren't updated - foreach ($existing as $permission) { - // Only delete if it's a "general" and not an entity specific permission - if (!is_numeric($permission->entityId())) { - $permission->delete(); - } - } - } - /** */ public function scopeSearch(Builder $builder, string $search = null): Builder @@ -183,47 +139,19 @@ public function scopeSearch(Builder $builder, string $search = null): Builder } /** - * Toggle an entity's action permission */ - public function toggle(int $entityType, int $action): bool + public function url(string $sub): string { - $perm = $this->permissions() - ->where('entity_type_id', $entityType) - ->where('action', $action) - ->whereNull('entity_id') - ->first(); - - if ($perm) { - $perm->delete(); - return false; - } - - $this->add($entityType, $action); - return true; + return 'campaign_roles.' . $sub; } - /** - * Add a campaign permission for the role - */ - protected function add(int $entityType, int $action): CampaignPermission + public function duplicate(CampaignRole $campaignRole): self { - if ($entityType === 0) { - $entityType = null; + foreach ($this->permissions as $permission) { + $newPermission = $permission->replicate(['campaign_role_id']); + $newPermission->campaign_role_id = $campaignRole->id; + $newPermission->save(); } - return CampaignPermission::create([ - //'key' => $key, - 'campaign_role_id' => $this->id, - //'table_name' => $value, - 'access' => true, - 'action' => $action, - 'entity_type_id' => $entityType - //'campaign_id' => $campaign->id, - ]); - } - /** - */ - public function url(string $sub): string - { - return 'campaign_roles.' . $sub; + return $this; } } diff --git a/app/Models/EntityType.php b/app/Models/EntityType.php index 34760e05f0..f9bb8e8f4f 100644 --- a/app/Models/EntityType.php +++ b/app/Models/EntityType.php @@ -10,9 +10,13 @@ /** * @property int $id * @property string $code + * + * @method static self|Builder exclude(array $ids) */ class EntityType extends Model { + protected string $cachedPluralCode; + public $fillable = [ 'id', 'code', @@ -30,6 +34,11 @@ public function scopeEnabled(Builder $query) ->orderBy('position'); } + public function scopeExclude(Builder $query, array $exclude): Builder + { + return $query->whereNotIn('id', $exclude); + } + /** * Get the class model of the entity type */ @@ -47,6 +56,25 @@ public function name(): string return Module::singular($this->id, __('entities.' . $this->code)); } + /** + * Get the translated name of the entity + */ + public function plural(): string + { + return Module::plural($this->id, __('entities.' . $this->pluralCode())); + } + + /** + * Get the translated name of the entity + */ + public function pluralCode(): string + { + if (isset($this->cachedPluralCode)) { + return $this->cachedPluralCode; + } + return $this->cachedPluralCode = Str::plural($this->code); + } + /** */ public function getNameAttribute(): string diff --git a/app/Models/Image.php b/app/Models/Image.php index 6957382cbb..8d3fc56f3e 100644 --- a/app/Models/Image.php +++ b/app/Models/Image.php @@ -50,6 +50,8 @@ * * * @property int $_usageCount + * + * @method static Builder|self acl(bool $browse) */ class Image extends Model { @@ -225,6 +227,14 @@ public function scopeFolders(Builder $query): Builder ->orderBy('name', 'asc'); } + public function scopeAcl(Builder $query, bool $browse): Builder + { + if (!$browse) { + return $query->where('created_by', auth()->user()->id); + } + return $query; + } + /** */ public function hasNoFolders(): bool diff --git a/app/Models/Quest.php b/app/Models/Quest.php index e7179e67c4..f8ad0f9a70 100644 --- a/app/Models/Quest.php +++ b/app/Models/Quest.php @@ -114,6 +114,7 @@ public function scopePreparedWith(Builder $query): Builder 'entity', 'entity.image', 'entity.calendarDateEvents', + 'entity.calendarDate', 'quests', 'instigator', //'elements', diff --git a/app/Models/Relations/CampaignRelations.php b/app/Models/Relations/CampaignRelations.php index 2f405c04f8..a097a42912 100644 --- a/app/Models/Relations/CampaignRelations.php +++ b/app/Models/Relations/CampaignRelations.php @@ -111,6 +111,14 @@ public function members() return $this->hasMany('App\Models\CampaignUser'); } + public function nonAdmins() + { + return $this + ->members() + ->withoutAdmins() + ->with(['user', 'user.campaignRoles']) + ; + } /** */ public function roles() diff --git a/app/Policies/CampaignPolicy.php b/app/Policies/CampaignPolicy.php index 2673ce12ff..7bd8f22182 100644 --- a/app/Policies/CampaignPolicy.php +++ b/app/Policies/CampaignPolicy.php @@ -213,7 +213,9 @@ public function submissions(?User $user) public function gallery(?User $user, Campaign $campaign): bool { return $user && ( - UserCache::user($user)->admin() || $this->checkPermission(CampaignPermission::ACTION_GALLERY, $user, $campaign) + UserCache::user($user)->admin() || + $this->checkPermission(CampaignPermission::ACTION_GALLERY, $user, $campaign) || + $this->checkPermission(CampaignPermission::ACTION_GALLERY_BROWSE, $user, $campaign) ); } diff --git a/app/Policies/ImagePolicy.php b/app/Policies/ImagePolicy.php new file mode 100644 index 0000000000..bcdaa5f28d --- /dev/null +++ b/app/Policies/ImagePolicy.php @@ -0,0 +1,70 @@ +admin() || + $this->checkPermission(CampaignPermission::ACTION_GALLERY, $user, $campaign) || + $this->checkPermission(CampaignPermission::ACTION_GALLERY_BROWSE, $user, $campaign) + ); + } + + public function create(?User $user, Campaign $campaign): bool + { + return $user && ( + UserCache::user($user)->admin() || + $this->checkPermission(CampaignPermission::ACTION_GALLERY, $user, $campaign) || + $this->checkPermission(CampaignPermission::ACTION_GALLERY_UPLOAD, $user, $campaign) + ); + } + + public function view(?User $user, Image $image, Campaign $campaign): bool + { + return $user && ( + UserCache::user($user)->admin() || + $this->checkPermission(CampaignPermission::ACTION_GALLERY, $user, $campaign) || + $this->checkPermission(CampaignPermission::ACTION_GALLERY_BROWSE, $user, $campaign) || + ($this->checkPermission(CampaignPermission::ACTION_GALLERY_UPLOAD, $user, $campaign) && $image->created_by === $user->id) + ); + } + public function edit(?User $user, Image $image, Campaign $campaign): bool + { + return $user && ( + UserCache::user($user)->admin() || + $this->checkPermission(CampaignPermission::ACTION_GALLERY, $user, $campaign) || + ($this->checkPermission(CampaignPermission::ACTION_GALLERY_UPLOAD, $user, $campaign) && $image->created_by === $user->id) + ); + } + + public function delete(?User $user, Image $image, Campaign $campaign): bool + { + return $this->edit($user, $image, $campaign); + } + + /** + * @return bool + */ + protected function checkPermission(int $action, User $user, Campaign $campaign = null) + { + return EntityPermission::hasPermission(0, $action, $user, null, $campaign); + } +} diff --git a/app/Services/BulkService.php b/app/Services/BulkService.php index efa8ccf4ed..84f1a66fca 100644 --- a/app/Services/BulkService.php +++ b/app/Services/BulkService.php @@ -11,6 +11,7 @@ use App\Services\Entity\MoveService; use App\Services\Entity\TagService; use App\Services\Entity\TransformService; +use App\Services\Permissions\BulkPermissionService; use App\Traits\CampaignAware; use Illuminate\Support\Arr; use Illuminate\Support\Collection; @@ -25,7 +26,7 @@ class BulkService protected EntityService $entityService; - protected PermissionService $permissionService; + protected BulkPermissionService $permissionService; protected TransformService $transformService; @@ -46,7 +47,7 @@ class BulkService public function __construct( EntityService $entityService, - PermissionService $permissionService, + BulkPermissionService $permissionService, TransformService $transformService, MoveService $moveService ) { @@ -129,7 +130,10 @@ public function permissions(array $permissions = [], bool $override = true): int foreach ($this->ids as $id) { $entity = $model->findOrFail($id); if (auth()->user()->can('update', $entity)) { - $this->permissionService->change($permissions, $entity->entity, $override); + $this->permissionService + ->entity($entity->entity) + ->override($override) + ->change($permissions); $this->count++; } } diff --git a/app/Services/PermissionService.php b/app/Services/PermissionService.php index c3a39fd593..5de905b4b2 100644 --- a/app/Services/PermissionService.php +++ b/app/Services/PermissionService.php @@ -2,13 +2,13 @@ namespace App\Services; -use App\Facades\Module; use App\Models\CampaignPermission; use App\Models\CampaignRole; use App\Models\Entity; use App\Traits\CampaignAware; +use App\Traits\RoleAware; +use App\Traits\UserAware; use Illuminate\Support\Arr; -use Illuminate\Support\Str; /** * Class PermissionService @@ -17,17 +17,13 @@ class PermissionService { use CampaignAware; - - /** @var bool|array Users with a role */ - private $users = false; + use RoleAware; + use UserAware; /** @var int */ private $type; - /** @var CampaignRole */ - private $role; - - private null|array $idsToCode = null; + protected int $action; /** * Permissions setup on the campaign @@ -46,172 +42,15 @@ public function type(int $type): self return $this; } - /** - * Set the role - * @return $this - */ - public function role(CampaignRole $role): self + public function action(int $action): self { - $this->role = $role; + $this->action = $action; return $this; } /** - * Get the campaign role permissions. First key is the entity type */ - public function permissions(CampaignRole $role): array - { - $permissions = []; - - $campaignRolePermissions = []; - foreach ($role->rolePermissions as $perm) { - $campaignRolePermissions[$perm->entity_type_id . '_' . $perm->action] = 1; - } - - $entityActions = [ - CampaignPermission::ACTION_READ, CampaignPermission::ACTION_EDIT, - CampaignPermission::ACTION_ADD, CampaignPermission::ACTION_DELETE, - CampaignPermission::ACTION_POSTS, CampaignPermission::ACTION_PERMS - ]; - $icons = [ - CampaignPermission::ACTION_READ => [ - 'fa-solid fa-eye', - 'read', - ], - CampaignPermission::ACTION_EDIT => [ - 'fa-solid fa-pen', - 'edit', - ], - CampaignPermission::ACTION_ADD => [ - 'fa-solid fa-plus-square', - 'add', - ], - CampaignPermission::ACTION_DELETE => [ - 'fa-solid fa-trash-alt', - 'delete', - ], - CampaignPermission::ACTION_POSTS => [ - 'fa-solid fa-file', - 'entity-note', - ], - CampaignPermission::ACTION_PERMS => [ - 'fa-solid fa-cog', - 'permission', - ], - ]; - - // Public actions - if ($role->is_public) { - //$actions = ['read']; - $entityActions = [CampaignPermission::ACTION_READ]; - } - - foreach ($this->entityTypes() as $name => $id) { - foreach ($entityActions as $action) { - if (!isset($permissions[$id])) { - $permissions[$id] = []; - } - $key = "{$id}_{$action}"; - $permissions[$id][] = [ - 'action' => $action, - 'key' => $key, - 'icon' => Arr::first($icons[$action]), - 'label' => Arr::last($icons[$action]), - 'enabled' => isset($campaignRolePermissions[$key]), - ]; - } - } - - return $permissions; - } - - /** - */ - public function entityTypes(): array - { - $types = []; - $excludedEntities = ['bookmark', 'relation']; - - foreach (config('entities.ids') as $name => $id) { - if (in_array($name, $excludedEntities)) { - continue; - } - $types[$name] = $id; - } - - return $types; - } - - /** - * Determine if the loaded role has the permission to do a specific action on the - * specified entity type (->type()) - */ - public function can(int $action = CampaignPermission::ACTION_READ): bool - { - return $this->role->permissions - ->where('entity_type_id', $this->type) - ->where('action', $action) - ->where('access', true) - ->count() === 1; - } - - /** - * Campaign Permissions - */ - public function campaignPermissions(CampaignRole $role): array - { - $permissions = []; - - $campaignRolePermissions = []; - foreach ($role->permissions as $perm) { - if ($perm->entity_type_id) { - continue; - } - $campaignRolePermissions["campaign_" . $perm->action] = 1; - } - - $entityActions = [ - CampaignPermission::ACTION_MANAGE, CampaignPermission::ACTION_DASHBOARD, - CampaignPermission::ACTION_MEMBERS, CampaignPermission::ACTION_GALLERY - ]; - $icons = [ - CampaignPermission::ACTION_MANAGE => [ - 'fa-solid fa-cog', - 'manage', - ], - CampaignPermission::ACTION_DASHBOARD => [ - 'fa-solid fa-columns','dashboard', - ], - CampaignPermission::ACTION_MEMBERS => [ - 'fa-solid fa-users', 'members', - ], - CampaignPermission::ACTION_GALLERY => [ - 'fa-solid fa-image', 'gallery', - ] - ]; - - foreach ($entityActions as $action) { - if (!isset($permissions['campaign'])) { - $permissions['campaign'] = []; - } - $key = "campaign_{$action}"; - $permissions['campaign'][] = [ - 'action' => $action, - //'table' => $table, - 'key' => $key, - 'icon' => Arr::first($icons[$action]), - 'label' => Arr::last($icons[$action]), - 'enabled' => isset($campaignRolePermissions[$key]), - ]; - } - - - return $permissions; - } - - /** - */ - public function saveEntity(array $request, Entity $entity) + public function saveEntity(array $request, Entity $entity): void { // First, let's get all the stuff for this entity $permissions = $this->entityPermissions($entity); @@ -324,126 +163,6 @@ public function saveEntity(array $request, Entity $entity) } } - /** - * @param array $request - */ - public function change($request, Entity $entity, bool $override = true) - { - // First, let's get all the stuff for this entity - $permissions = $this->clearEntityPermissions()->entityPermissions($entity); - - // Next, start looping the data - if (!empty($request['role'])) { - foreach ($request['role'] as $roleId => $data) { - foreach ($data as $perm => $action) { - if ($action == 'allow') { - if (empty($permissions['role'][$roleId][$perm])) { - CampaignPermission::create([ - //'key' => $entity->type() . '_' . $perm . '_' . $entity->child->id, - 'campaign_role_id' => $roleId, - //'campaign_id' => $entity->campaign_id, - //'entity_type_id' => $entity->type_id, - 'entity_id' => $entity->id, - 'misc_id' => $entity->child->id, - 'action' => $perm, - 'access' => true, - ]); - } else { - $permissions['role'][$roleId][$perm]->update(['access' => true]); - unset($permissions['role'][$roleId][$perm]); - } - } elseif ($action == 'remove') { - if (!empty($permissions['role'][$roleId][$perm])) { - $permissions['role'][$roleId][$perm]->delete(); - unset($permissions['role'][$roleId][$perm]); - } - } elseif ($action === 'deny') { - if (empty($permissions['role'][$roleId][$perm])) { - CampaignPermission::create([ - //'key' => $entity->type() . '_' . $perm . '_' . $entity->child->id, - 'campaign_role_id' => $roleId, - //'campaign_id' => $entity->campaign_id, - //'table_name' => $entity->pluralType(), - //'entity_type_id' => $entity->type_id, - 'entity_id' => $entity->id, - 'misc_id' => $entity->child->id, - 'action' => $perm, - 'access' => false, - ]); - } else { - $permissions['role'][$roleId][$perm]->update(['access' => false]); - unset($permissions['role'][$roleId][$perm]); - } - } elseif ($action == 'inherit') { - // Inherit? Remove it if it exists - if (!empty($permissions['role'][$roleId][$perm])) { - $permissions['role'][$roleId][$perm]->delete(); - } - } - } - } - } - if (!empty($request['user'])) { - foreach ($request['user'] as $userId => $data) { - foreach ($data as $perm => $action) { - if ($action == 'allow') { - if (empty($permissions['user'][$userId][$perm])) { - CampaignPermission::create([ - //'key' => $entity->type() . '_' . $perm . '_' . $entity->child->id, - 'user_id' => $userId, - 'campaign_id' => $entity->campaign_id, - 'entity_id' => $entity->id, - //'entity_type_id' => $entity->type_id, - 'misc_id' => $entity->child->id, - 'action' => $perm, - 'access' => true, - ]); - } else { - $permissions['user'][$userId][$perm]->update(['access' => true]); - unset($permissions['user'][$userId][$perm]); - } - } elseif ($action == 'remove') { - if (!empty($permissions['user'][$userId][$perm])) { - $permissions['user'][$userId][$perm]->delete(); - unset($permissions['user'][$userId][$perm]); - } - } elseif ($action === 'deny') { - if (empty($permissions['user'][$userId][$perm])) { - CampaignPermission::create([ - //'key' => $entity->type() . '_' . $perm . '_' . $entity->child->id, - 'user_id' => $userId, - 'campaign_id' => $entity->campaign_id, - //'table_name' => $entity->pluralType(), - 'entity_id' => $entity->id, - //'entity_type_id' => $entity->type_id, - 'misc_id' => $entity->child->id, - 'action' => $perm, - 'access' => false - ]); - } else { - $permissions['user'][$userId][$perm]->update(['access' => false]); - } - } elseif ($action == 'inherit') { - // Inherit? Remove it if it exists - if (!empty($permissions['user'][$userId][$perm])) { - $permissions['user'][$userId][$perm]->delete(); - } - } - } - } - } - - // If the user requested an override, any permissions that was not specifically set will be deleted. - if ($override) { - foreach ($permissions as $type => $data) { - foreach ($data as $user => $actions) { - foreach ($actions as $action => $perm) { - $perm->delete(); - } - } - } - } - } /** * Get the permissions of an entity @@ -466,9 +185,8 @@ public function entityPermissions(Entity $entity): array } /** - * @return $this */ - protected function clearEntityPermissions(): self + public function clearEntityPermissions(): self { unset($this->cachedPermissions); return $this; @@ -476,7 +194,7 @@ protected function clearEntityPermissions(): self /** */ - public function inherited(int $action, int $role = 0, int $user = 0): bool + public function inherited(): bool { if (empty($this->type)) { return false; @@ -509,90 +227,49 @@ public function inherited(int $action, int $role = 0, int $user = 0): bool } } - $key = $this->type . '_' . $action; - if (!empty($role)) { - return Arr::has($this->basePermissions, "roles.{$role}.{$key}"); + $key = $this->type . '_' . $this->action; + if (isset($this->role)) { + return Arr::has($this->basePermissions, "roles.{$this->role->id}.{$key}"); } - return Arr::has($this->basePermissions, "users.{$user}.{$key}"); + return Arr::has($this->basePermissions, "users.{$this->user->id}.{$key}"); } /** */ - public function inheritedRoleName(int $action, int $user): string + public function inheritedRoleName(): string { - $key = $this->type . '_' . $action; - return $this->basePermissions['users'][$user][$key]['role']; + $key = $this->type . '_' . $this->action; + return $this->basePermissions['users'][$this->user->id][$key]['role']; } /** */ - public function inheritedRoleAccess(int $action, int $user): bool + public function inheritedRoleAccess(): bool { - $key = $this->type . '_' . $action; - return $this->basePermissions['users'][$user][$key]['access']; + $key = $this->type . '_' . $this->action; + return $this->basePermissions['users'][$this->user->id][$key]['access']; } /** */ - public function selected(string $type, int $user, int $action): string + public function selected(string $type): string { if (!isset($this->cachedPermissions)) { return 'inherit'; } - $value = Arr::get($this->cachedPermissions, $type . '.' . $user . '.' . $action, null); + $user = isset($this->user) ? $this->user->id : $this->role->id; + $value = Arr::get($this->cachedPermissions, $type . '.' . $user . '.' . $this->action, null); if ($value === null) { return 'inherit'; } return $value->access ? 'allow' : 'deny'; } - /** - * @return array - */ - public function users() - { - if ($this->users === false) { - $this->users = $this->campaign - ->members() - ->withoutAdmins() - ->with(['user', 'user.campaignRoles']) - ->get(); - } - return $this->users; - } - - /** - */ - public function entityType(int $entityType): string + public function reset(): self { - $flip = array_flip(config('entities.ids')); - $plural = Module::plural($flip[$entityType]); - if (!empty($plural)) { - return $plural; - } - return 'entities.' . Str::plural($flip[$entityType]); - } + unset($this->user, $this->role, $this->action); - public function entityTypePlural(int $entityType): string - { - return Str::plural($this->code($entityType)); - } - protected function code(int $entityType): string - { - if ($this->idsToCode === null) { - $this->idsToCode = array_flip(config('entities.ids')); - } - return $this->idsToCode[$entityType]; - } - public function duplicate(int $roleId) - { - $oldRole = CampaignRole::where('id', $roleId)->first(); - foreach ($oldRole->permissions as $permission) { - /** @var CampaignPermission $newPermission */ - $newPermission = $permission->replicate(['campaign_role_id']); - $newPermission->campaign_role_id = $this->role->id; - $newPermission->save(); - } + return $this; } } diff --git a/app/Services/Permissions/BulkPermissionService.php b/app/Services/Permissions/BulkPermissionService.php new file mode 100644 index 0000000000..a3e65586f5 --- /dev/null +++ b/app/Services/Permissions/BulkPermissionService.php @@ -0,0 +1,161 @@ +service = $permissionService; + } + + public function override(bool $override): self + { + $this->override = $override; + return $this; + } + + public function change(array $request): void + { + // First, let's get all the stuff for this entity + $this->permissions = $this->service + ->clearEntityPermissions() + ->entityPermissions($this->entity); + + $this + ->roles($request) + ->users($request) + ->cleanup(); + } + + protected function roles(array $request): self + { + if (empty($request['role'])) { + return $this; + } + foreach ($request['role'] as $roleId => $data) { + foreach ($data as $perm => $action) { + if ($action == 'allow') { + if (empty($this->permissions['role'][$roleId][$perm])) { + CampaignPermission::create([ + 'campaign_role_id' => $roleId, + 'campaign_id' => $this->entity->campaign_id, + 'entity_id' => $this->entity->id, + 'misc_id' => $this->entity->child->id, + 'action' => $perm, + 'access' => true, + ]); + } else { + $this->permissions['role'][$roleId][$perm]->update(['access' => true]); + unset($this->permissions['role'][$roleId][$perm]); + } + } elseif ($action == 'remove') { + if (!empty($this->permissions['role'][$roleId][$perm])) { + $this->permissions['role'][$roleId][$perm]->delete(); + unset($this->permissions['role'][$roleId][$perm]); + } + } elseif ($action === 'deny') { + if (empty($this->permissions['role'][$roleId][$perm])) { + CampaignPermission::create([ + 'campaign_role_id' => $roleId, + 'campaign_id' => $this->entity->campaign_id, + 'entity_id' => $this->entity->id, + 'misc_id' => $this->entity->child->id, + 'action' => $perm, + 'access' => false, + ]); + } else { + $this->permissions['role'][$roleId][$perm]->update(['access' => false]); + unset($this->permissions['role'][$roleId][$perm]); + } + } elseif ($action == 'inherit') { + // Inherit? Remove it if it exists + if (!empty($this->permissions['role'][$roleId][$perm])) { + $this->permissions['role'][$roleId][$perm]->delete(); + } + } + } + } + return $this; + } + protected function users(array $request): self + { + if (empty($request['user'])) { + return $this; + } + foreach ($request['user'] as $userId => $data) { + foreach ($data as $perm => $action) { + if ($action == 'allow') { + if (empty($this->permissions['user'][$userId][$perm])) { + CampaignPermission::create([ + //'key' => $this->entity->type() . '_' . $perm . '_' . $this->entity->child->id, + 'user_id' => $userId, + 'campaign_id' => $this->entity->campaign_id, + 'entity_id' => $this->entity->id, + //'entity_type_id' => $this->entity->type_id, + 'misc_id' => $this->entity->child->id, + 'action' => $perm, + 'access' => true, + ]); + } else { + $this->permissions['user'][$userId][$perm]->update(['access' => true]); + unset($this->permissions['user'][$userId][$perm]); + } + } elseif ($action == 'remove') { + if (!empty($this->permissions['user'][$userId][$perm])) { + $this->permissions['user'][$userId][$perm]->delete(); + unset($this->permissions['user'][$userId][$perm]); + } + } elseif ($action === 'deny') { + if (empty($this->permissions['user'][$userId][$perm])) { + CampaignPermission::create([ + //'key' => $this->entity->type() . '_' . $perm . '_' . $this->entity->child->id, + 'user_id' => $userId, + 'campaign_id' => $this->entity->campaign_id, + //'table_name' => $this->entity->pluralType(), + 'entity_id' => $this->entity->id, + //'entity_type_id' => $this->entity->type_id, + 'misc_id' => $this->entity->child->id, + 'action' => $perm, + 'access' => false + ]); + } else { + $this->permissions['user'][$userId][$perm]->update(['access' => false]); + } + } elseif ($action == 'inherit') { + // Inherit? Remove it if it exists + if (!empty($this->permissions['user'][$userId][$perm])) { + $this->permissions['user'][$userId][$perm]->delete(); + } + } + } + } + return $this; + } + + protected function cleanup(): void + { + // If the user requested an override, any permissions that was not specifically set will be deleted. + if (!$this->override) { + return; + } + foreach ($this->permissions as $type => $data) { + foreach ($data as $user => $actions) { + foreach ($actions as $action => $perm) { + $perm->delete(); + } + } + } + } +} diff --git a/app/Services/Permissions/EntityPermission.php b/app/Services/Permissions/EntityPermission.php index 8478b091c5..17ce66dea3 100644 --- a/app/Services/Permissions/EntityPermission.php +++ b/app/Services/Permissions/EntityPermission.php @@ -10,38 +10,18 @@ use App\Models\MiscModel; use App\User; use Illuminate\Support\Collection; -use Illuminate\Support\Arr; class EntityPermission { - /** - * @var MiscModel - */ - protected $model; - - /** - * @var \Illuminate\Foundation\Application|mixed - */ - protected $app; - - /** - * @var array - */ - protected $cached = []; + protected array $cached = []; - /** - * @var array|bool - */ - protected $roleIds = false; + protected array|bool $roleIds; /** - * @var array|bool|Collection The roles of the user + * The roles of the user */ - protected $roles = []; + protected array|bool|Collection $roles = []; - /** - * @var array Entity Ids - */ protected array $cachedEntityIds = []; /** @@ -50,91 +30,15 @@ class EntityPermission protected $userIsAdmin = null; /** - * @var bool permissions were loaded + * Permissions were loaded */ protected bool $loadedAll = false; /** - * @var int campaign id of the loaded permissions (required for when moving entities between campaigns) + * Campaign id of the loaded permissions (required for when moving entities between campaigns) */ protected int $loadedCampaignId = 0; - /** - * Creates new instance. - */ - public function __construct() - { - $this->app = app(); - } - - /** - * @return bool - */ - public function canView(Entity $entity, Campaign $campaign = null) - { - // Make sure we can see the entity we're trying to show the user. We do it this way because we - // are looping through entities which doesn't allow using the acl trait before hand. - if (auth()->check()) { - return auth()->user()->can('view', $entity->child); - } elseif (!empty($entity->child)) { - return self::hasPermission($entity->type_id, CampaignPermission::ACTION_READ, null, $entity->child, $campaign); - } - return false; - } - - /** - * Get list of entity ids for a given model type that the user can access. - * @param string $action = 'read' - */ - public function entityIds(string $modelName, string $action = 'read'): array - { - // Check if we have this model type at all - $modelIds = Arr::get($this->cachedEntityIds, $modelName, []); - if (empty($modelIds)) { - return []; - } - $ids = []; - foreach ($modelIds as $id => $data) { - if (!is_array($data)) { - // This will throw an error - } - foreach ($data as $perm => $access) { - if ($perm === $action && $access) { - $ids[] = $id; - } - } - } - return $ids; - } - - /** - * Entity IDs the user specifically doesn't have access to - */ - public function deniedEntityIds(string $modelName, string $action = 'read'): array - { - // This function is called in the VisibleTrait of the model, but for example in the search, no permissions are - // already loaded, so we need to call this again to get the user's permissions - $this->loadAllPermissions(auth()->user()); - - // Check if we have this model type at all - $modelIds = Arr::get($this->cachedEntityIds, $modelName, []); - if (empty($modelIds)) { - return []; - } - $ids = []; - foreach ($modelIds as $id => $data) { - if (!is_array($data)) { - // This will throw an error - } - foreach ($data as $perm => $access) { - if ($perm === $action && !$access) { - $ids[] = $id; - } - } - } - return $ids; - } - /** * Determine the permission for a user to interact with an entity * @param MiscModel|Entity|null $entity @@ -192,35 +96,35 @@ public function hasPermission( /** * Check the roles of the user. If the user is an admin, always return true - * @return array|bool */ - protected function getRoleIds(Campaign $campaign, User $user = null) + protected function getRoleIds(Campaign $campaign, User $user = null): array|bool { // If we haven't built a list of roles yet, build it. - if ($this->roleIds === false) { - $this->roles = false; - // If we have a user, get the user's role for this campaign - if ($user) { - $this->roles = UserCache::user($user)->roles(); - } + if (isset($this->roleIds)) { + return $this->roleIds; + } - // If we don't have a user, or our user has no specified role yet, use the public role. - if ($this->roles === false || $this->roles->count() == 0) { - // Use the campaign's public role - $this->roles = $campaign->roles()->where('is_public', true)->get(); - } + $this->roles = false; + // If we have a user, get the user's role for this campaign + if ($user) { + $this->roles = UserCache::user($user)->roles(); + } - // Save all the role ids. If one of them is an admin, stop there. - $this->roleIds = []; - foreach ($this->roles as $role) { - if ($role['is_admin']) { - $this->roleIds = true; - return true; - } - $this->roleIds[] = $role['id']; - } + // If we don't have a user, or our user has no specified role yet, use the public role. + if ($this->roles === false || $this->roles->count() == 0) { + // Use the campaign's public role + $this->roles = $campaign->roles()->where('is_public', true)->get(); } + // Save all the role ids. If one of them is an admin, stop there. + $this->roleIds = []; + foreach ($this->roles as $role) { + if ($role['is_admin']) { + $this->roleIds = true; + return true; + } + $this->roleIds[] = $role['id']; + } return $this->roleIds; } @@ -243,9 +147,8 @@ public function canRole(string $action, string $modelName, $user = null, Campaig /** * It's way easier to just load all permissions of the user once and "cache" them, rather than try and be * optional on each query. - * @return void */ - protected function loadAllPermissions(User $user = null, Campaign $campaign = null) + protected function loadAllPermissions(User $user = null, Campaign $campaign = null): void { // If no campaign was provided, get the one in the url. One is provided when moving entities between campaigns if (empty($campaign)) { @@ -324,7 +227,7 @@ public function resetPermissions(): void // Reset the values keeping score $this->loadedAll = true; $this->cached = []; - $this->roleIds = false; + unset($this->roleIds); $this->userIsAdmin = false; } } diff --git a/app/Services/Permissions/RolePermission.php b/app/Services/Permissions/RolePermission.php index a9e6aaf490..de3d890f88 100644 --- a/app/Services/Permissions/RolePermission.php +++ b/app/Services/Permissions/RolePermission.php @@ -3,38 +3,16 @@ namespace App\Services\Permissions; use App\Models\CampaignPermission; -use App\Models\CampaignRole; +use App\Traits\RoleAware; use Illuminate\Database\Eloquent\Collection; class RolePermission { - /** - * @var \Illuminate\Foundation\Application|mixed - */ - protected $app; + use RoleAware; - protected CampaignRole $role; - - /** */ protected array $permissions = []; - protected array $rolesPermissions = []; - - /** - * - */ - public function __construct() - { - $this->app = app(); - } - /** - * @return $this - */ - public function role(CampaignRole $role): self - { - $this->role = $role; - return $this; - } + protected array $rolesPermissions = []; /** * @return Collection|CampaignPermission[]|array @@ -48,7 +26,7 @@ public function permissions() return $this->permissions[$this->role->id] = $this->role->permissions; } - public function rolesPermissions(array $roles) + public function rolesPermissions(array $roles): mixed { $key = implode('-', $roles); if (isset($this->rolesPermissions[$key])) { diff --git a/app/Services/Permissions/RolePermissionService.php b/app/Services/Permissions/RolePermissionService.php new file mode 100644 index 0000000000..daf0f48bef --- /dev/null +++ b/app/Services/Permissions/RolePermissionService.php @@ -0,0 +1,279 @@ +type = $type; + return $this; + } + + /** + * Get the campaign role permissions. First key is the entity type + */ + public function permissions(): array + { + $permissions = []; + + $campaignRolePermissions = []; + foreach ($this->role->rolePermissions as $perm) { + $campaignRolePermissions[$perm->entity_type_id . '_' . $perm->action] = 1; + } + + $entityActions = [ + CampaignPermission::ACTION_READ, CampaignPermission::ACTION_EDIT, + CampaignPermission::ACTION_ADD, CampaignPermission::ACTION_DELETE, + CampaignPermission::ACTION_POSTS, CampaignPermission::ACTION_PERMS + ]; + $icons = [ + CampaignPermission::ACTION_READ => [ + 'fa-solid fa-eye', + 'read', + ], + CampaignPermission::ACTION_EDIT => [ + 'fa-solid fa-pen', + 'edit', + ], + CampaignPermission::ACTION_ADD => [ + 'fa-solid fa-plus-square', + 'add', + ], + CampaignPermission::ACTION_DELETE => [ + 'fa-solid fa-trash-alt', + 'delete', + ], + CampaignPermission::ACTION_POSTS => [ + 'fa-solid fa-file', + 'entity-note', + ], + CampaignPermission::ACTION_PERMS => [ + 'fa-solid fa-cog', + 'permission', + ], + ]; + + // Public actions + if ($this->role->isPublic()) { + //$actions = ['read']; + $entityActions = [CampaignPermission::ACTION_READ]; + } + + foreach (EntityType::get() as $entityType) { + foreach ($entityActions as $action) { + if (!isset($permissions[$entityType->id])) { + $permissions[$entityType->id] = [ + 'entityType' => $entityType, + 'permissions' => [] + ]; + } + $key = "{$entityType->id}_{$action}"; + $permissions[$entityType->id]['permissions'][] = [ + 'action' => $action, + 'key' => $key, + 'icon' => Arr::first($icons[$action]), + 'label' => Arr::last($icons[$action]), + 'enabled' => isset($campaignRolePermissions[$key]), + ]; + } + } + + return $permissions; + } + /** + * Campaign Permissions + */ + public function campaignPermissions(): array + { + $permissions = []; + + $campaignRolePermissions = []; + foreach ($this->role->permissions as $perm) { + if ($perm->entity_type_id || $perm->isGallery()) { + continue; + } + $campaignRolePermissions["campaign_" . $perm->action] = 1; + } + + $entityActions = [ + CampaignPermission::ACTION_MANAGE, CampaignPermission::ACTION_DASHBOARD, + CampaignPermission::ACTION_MEMBERS + ]; + $icons = [ + CampaignPermission::ACTION_MANAGE => [ + 'fa-solid fa-cog', + 'manage', + ], + CampaignPermission::ACTION_DASHBOARD => [ + 'fa-solid fa-columns','dashboard', + ], + CampaignPermission::ACTION_MEMBERS => [ + 'fa-solid fa-users', 'members', + ], + ]; + + foreach ($entityActions as $action) { + if (!isset($permissions['campaign'])) { + $permissions['campaign'] = []; + } + $key = "campaign_{$action}"; + $permissions['campaign'][] = [ + 'action' => $action, + 'key' => $key, + 'icon' => Arr::first($icons[$action]), + 'label' => Arr::last($icons[$action]), + 'enabled' => isset($campaignRolePermissions[$key]), + ]; + } + return $permissions; + } + + public function galleryPermissions(): array + { + $permissions = []; + + $campaignRolePermissions = []; + foreach ($this->role->permissions as $perm) { + if ($perm->entity_type_id || !$perm->isGallery()) { + continue; + } + $campaignRolePermissions["campaign_" . $perm->action] = 1; + } + + $entityActions = [ + CampaignPermission::ACTION_GALLERY, + CampaignPermission::ACTION_GALLERY_BROWSE, + CampaignPermission::ACTION_GALLERY_UPLOAD + ]; + $icons = [ + CampaignPermission::ACTION_GALLERY => [ + 'fa-solid fa-cog', 'gallery.manage', + ], + CampaignPermission::ACTION_GALLERY_BROWSE => [ + 'fa-solid fa-eye','gallery.browse', + ], + CampaignPermission::ACTION_GALLERY_UPLOAD => [ + 'fa-solid fa-upload', 'gallery.upload', + ], + ]; + + foreach ($entityActions as $action) { + if (!isset($permissions['campaign'])) { + $permissions['campaign'] = []; + } + $key = "campaign_{$action}"; + $permissions['campaign'][] = [ + 'action' => $action, + 'key' => $key, + 'icon' => Arr::first($icons[$action]), + 'label' => Arr::last($icons[$action]), + 'enabled' => isset($campaignRolePermissions[$key]), + ]; + } + return $permissions; + } + + public function savePermissions(array $permissions = []): void + { + // Load existing + $existing = []; + foreach ($this->role->rolePermissions as $permission) { + if (empty($permission->entity_type_id)) { + $existing['campaign_' . $permission->action] = $permission; + continue; + } + $existing[$permission->entity_type_id . '_' . $permission->action] = $permission; + } + + // Loop on submitted form + if (empty($permissions)) { + $permissions = []; + } + + foreach ($permissions as $key => $module) { + // Check if exists$ + if (isset($existing[$key])) { + // Do nothing + unset($existing[$key]); + } else { + $action = Str::after($key, '_'); + if ($module === 'campaign') { + $module = 0; + } + + $this->add($module, (int) $action); + } + } + + // Delete existing that weren't updated + foreach ($existing as $permission) { + // Only delete if it's a "general" and not an entity specific permission + if (!is_numeric($permission->entityId())) { + $permission->delete(); + } + } + } + + /** + * Toggle an entity's action permission + */ + public function toggle(int $entityType, int $action): bool + { + $perm = $this->role->permissions() + ->where('entity_type_id', $entityType) + ->where('action', $action) + ->whereNull('entity_id') + ->first(); + + if ($perm) { + $perm->delete(); + return false; + } + + $this->add($entityType, $action); + return true; + } + + /** + * Determine if the loaded role has the permission to do a specific action on the + * specified entity type (->type()) + */ + public function can(int $action = CampaignPermission::ACTION_READ): bool + { + return $this->role->permissions + ->where('entity_type_id', $this->type) + ->where('action', $action) + ->where('access', true) + ->count() === 1; + } + + /** + * Add a campaign permission for the role + */ + protected function add(int $entityType, int $action): CampaignPermission + { + if ($entityType === 0) { + $entityType = null; + } + return CampaignPermission::create([ + //'key' => $key, + 'campaign_role_id' => $this->role->id, + //'table_name' => $value, + 'access' => true, + 'action' => $action, + 'entity_type_id' => $entityType + //'campaign_id' => $campaign->id, + ]); + } +} diff --git a/app/Services/SidebarService.php b/app/Services/SidebarService.php index db4738d30d..14d49a5445 100644 --- a/app/Services/SidebarService.php +++ b/app/Services/SidebarService.php @@ -524,9 +524,7 @@ public function layout(): array } // Child has permission check? if (isset($child['perm'])) { - if (!auth()->check() || !auth()->user()->can($childName, $this->campaign)) { - continue; - } + $layout[$name]['perm'] = $child['perm']; } // Add route when none is set diff --git a/app/Traits/RoleAware.php b/app/Traits/RoleAware.php new file mode 100644 index 0000000000..c90ff5cea9 --- /dev/null +++ b/app/Traits/RoleAware.php @@ -0,0 +1,16 @@ +role = $role; + return $this; + } +} diff --git a/lang/en/campaigns.php b/lang/en/campaigns.php index 741898704d..8ae7da434a 100644 --- a/lang/en/campaigns.php +++ b/lang/en/campaigns.php @@ -273,7 +273,7 @@ 'campaign_not_public' => 'The public role has permissions but the campaign is private. You can change this setting on the Sharing tab when editing the campaign.', 'empty_role' => 'The role doesn\'t have any members in it yet.', 'role_admin' => 'Members of the :name role can automatically access every entity and feature in the campaign.', - 'role_permissions' => 'Enable the :name role to do the following actions on all entities', + 'role_permissions' => 'Enable the :name role to do the following actions on all entities.', ], 'members' => 'Members', 'modals' => [ @@ -291,7 +291,11 @@ 'delete' => 'Delete', 'edit' => 'Edit', 'entity-note' => 'Post', - 'gallery' => 'Gallery', + 'gallery' => [ + 'manage' => 'Full control', + 'browse' => 'Browse', + 'upload' => 'Upload', + ], 'manage' => 'Manage', 'members' => 'Members', 'permission' => 'Permissions', @@ -303,8 +307,12 @@ 'dashboard' => 'Allow editing the dashboards and dashboard widgets.', 'delete' => 'Allow removing all entities of this type.', 'edit' => 'Allow editing all entities of this type.', - 'entity_note' => 'Allows adding and editing posts even if the member can\'t edit the entity.', - 'gallery' => 'Allow managing the campaign\'s gallery.', + 'entity_note' => 'Allows adding, editing, and deleting posts even if the member can\'t edit the entity.', + 'gallery' => [ + 'manage' => 'Allow everything on the gallery as an admin can, including editing and deleting images.', + 'browse' => 'Allow viewing the gallery, and setting an entity\'s image from the gallery.', + 'upload' => 'Allows uploading images to the gallery. Will only see images they have uploaded if not combined with the browse permission.', + ], 'manage' => 'Allow editing the campaign as a campaign admin would, without allowing the members to delete the campaign.', 'members' => 'Allow inviting new members to the campaign.', 'permission' => 'Allow setting permissions on entities of this type they can edit.', diff --git a/public/build/assets/gallery-2dea31e9.js b/public/build/assets/gallery-2dea31e9.js deleted file mode 100644 index 6bb78d4b2f..0000000000 --- a/public/build/assets/gallery-2dea31e9.js +++ /dev/null @@ -1 +0,0 @@ -import{a as v}from"./index-0b481a1e.js";import"./_commonjsHelpers-725317a4.js";var p,n,i,s,m,o,u,y;let f,g;$(document).ready(function(){E(),D(),c()});function E(){p=$("#gallery-loader"),n=$("#gallery-images"),i=$("#gallery-search"),f=$("#bulk-delete"),g=$("form#gallery-bulk"),o=document.getElementById("gallery-form"),$(".uploader"),s=$(".progress"),$("#file-upload"),m=$(".gallery-error");let r=$("#gallery-config");u=r.data("max"),y=r.data("error"),i.on("blur",function(e){e.preventDefault(),h()}).bind("keydown",function(e){e.key==="Enter"&&(e.preventDefault(),h())}),o.ondrop=e=>{if(e.preventDefault(),e.stopPropagation(),e.dataTransfer.items){let t=new FormData,a=0;if([...e.dataTransfer.items].forEach((d,F)=>{d.kind==="file"&&(t.append("file[]",d.getAsFile()),a++)}),a>u){w();return}let l=$('input[name="folder_id"]');l&&t.append("folder_id",l.val()),b(t),o.classList.remove("drop-shadow","dropping")}else[...e.dataTransfer.files].forEach((t,a)=>{})},o.ondragover=e=>{e.preventDefault(),o.classList.add("drop-shadow","dropping")},o.ondragleave=e=>{o.classList.remove("drop-shadow","dropping")},g.submit(function(e){e.preventDefault();var t=new FormData;$.each($('li[data-selected="1"]'),function(l){t.append("file[]",$(this).data("id"))});let a=$('input[name="folder_id"]');return a&&t.append("folder_id",a.val()),$.ajax({url:$(this).attr("action"),method:"POST",context:this,data:t,cache:!1,contentType:!1,processData:!1}).done(function(l){return $('li[data-selected="1"]').remove(),document.getElementById("bulk-destroy-dialog").close(),f.addClass("btn-disabled"),window.showToast(l.toast),!1}),!1})}function h(){n.hide(),p.show(),$.ajax({url:i.data("url")+"?q="+i.val()}).done(function(r){p.hide(),n.html(r).show(),c()})}function D(){o.onchange=r=>{r.preventDefault();let e=document.getElementById("file-upload");if(e.files.length>u){w();return}var t=new FormData;Array.from(e.files).forEach(l=>{t.append("file[]",l)});let a=$('input[name="folder_id"]');a&&t.append("folder_id",a.val()),b(t)}}const w=()=>{window.showToast(y,"error")},b=r=>{var e={headers:{"Content-Type":"multipart/form-data"},onUploadProgress:function(t){let a=Math.round(t.loaded*100/t.total);$('[role="progressbar"]').css("width",a+"%")}};s.show(),v.post(o.action,r,e).then(function(t){s.hide(),t.data.success&&(t.data.images.forEach(a=>{$("li[data-folder]").last().length===1?$(a).insertAfter($("li[data-folder]").last()):n.prepend(a)}),k(t.data.storage),c())}).catch(function(t){if(s.hide(),t.response&&t.response.data.message){m.text(t.response.data.message).fadeToggle();let a=t.response.data.errors;Object.keys(a).forEach(d=>{window.showToast(a[d],"error")})}c()})};function c(){$("#gallery-images li").unbind("click").on("click",function(r){if(r.shiftKey){if(!$(this).data("id"))return;$(this).toggleClass("border-2 border-blue-500"),$(this).attr("data-selected")==="1"?$(this).attr("data-selected",""):$(this).attr("data-selected",1),T();return}let e=$(this).data("folder");if(e){window.location=e;return}window.openDialog("primary-dialog",$(this).data("url"))})}const T=()=>{$('li[data-selected="1"]').length===0?f.addClass("btn-disabled"):f.removeClass("btn-disabled")},k=r=>{let e=document.getElementById("storage-progress");e.style.width=r.percentage+"%",e.className=r.progress;let t=document.getElementById("storage-used");t.innerHTML=r.used}; diff --git a/public/build/assets/gallery-3fd12283.js b/public/build/assets/gallery-3fd12283.js new file mode 100644 index 0000000000..5144892099 --- /dev/null +++ b/public/build/assets/gallery-3fd12283.js @@ -0,0 +1 @@ +import{a as b}from"./index-0b481a1e.js";import"./_commonjsHelpers-725317a4.js";var u,s,n,d,m,l,p,y;let i,g;$(document).ready(function(){E(),T(),f()});function E(){u=$("#gallery-loader"),s=$("#gallery-images"),n=$("#gallery-search"),i=$("#bulk-delete"),g=$("form#gallery-bulk"),l=document.getElementById("gallery-form"),$(".uploader"),d=$(".progress"),$("#file-upload"),m=$(".gallery-error");let t=$("#gallery-config");p=t.data("max"),y=t.data("error"),n.on("blur",function(a){a.preventDefault(),h()}).bind("keydown",function(a){a.key==="Enter"&&(a.preventDefault(),h())}),D(),g.submit(function(a){a.preventDefault();var e=new FormData;$.each($('li[data-selected="1"]'),function(o){e.append("file[]",$(this).data("id"))});let r=$('input[name="folder_id"]');return r&&e.append("folder_id",r.val()),$.ajax({url:$(this).attr("action"),method:"POST",context:this,data:e,cache:!1,contentType:!1,processData:!1}).done(function(o){return $('li[data-selected="1"]').remove(),document.getElementById("bulk-destroy-dialog").close(),i.addClass("btn-disabled"),window.showToast(o.toast),!1}),!1})}const D=()=>{l&&(l.ondrop=t=>{if(t.preventDefault(),t.stopPropagation(),t.dataTransfer.items){let a=new FormData,e=0;if([...t.dataTransfer.items].forEach((o,c)=>{o.kind==="file"&&(a.append("file[]",o.getAsFile()),e++)}),e>p){w();return}let r=$('input[name="folder_id"]');r&&a.append("folder_id",r.val()),v(a),l.classList.remove("drop-shadow","dropping")}else[...t.dataTransfer.files].forEach((a,e)=>{})},l.ondragover=t=>{t.preventDefault(),l.classList.add("drop-shadow","dropping")},l.ondragleave=t=>{l.classList.remove("drop-shadow","dropping")})};function h(){s.hide(),u.show(),$.ajax({url:n.data("url")+"?q="+n.val()}).done(function(t){u.hide(),s.html(t).show(),f()})}function T(){l&&(l.onchange=t=>{t.preventDefault();let a=document.getElementById("file-upload");if(a.files.length>p){w();return}var e=new FormData;Array.from(a.files).forEach(o=>{e.append("file[]",o)});let r=$('input[name="folder_id"]');r&&e.append("folder_id",r.val()),v(e)})}const w=()=>{window.showToast(y,"error")},v=t=>{var a={headers:{"Content-Type":"multipart/form-data"},onUploadProgress:function(e){let r=Math.round(e.loaded*100/e.total);$('[role="progressbar"]').css("width",r+"%")}};d.show(),b.post(l.action,t,a).then(function(e){d.hide(),e.data.success&&(e.data.images.forEach(r=>{$("li[data-folder]").last().length===1?$(r).insertAfter($("li[data-folder]").last()):s.prepend(r)}),F(e.data.storage),f())}).catch(function(e){if(d.hide(),e.response&&e.response.data.message){m.text(e.response.data.message).fadeToggle();let r=e.response.data.errors;Object.keys(r).forEach(c=>{window.showToast(r[c],"error")})}f()})};function f(){$("#gallery-images li").unbind("click").on("click",function(t){if(t.shiftKey){if(!$(this).data("id"))return;$(this).toggleClass("border-2 border-blue-500"),$(this).attr("data-selected")==="1"?$(this).attr("data-selected",""):$(this).attr("data-selected",1),k();return}let a=$(this).data("folder");if(a){window.location=a;return}window.openDialog("primary-dialog",$(this).data("url"))})}const k=()=>{$('li[data-selected="1"]').length===0?i.addClass("btn-disabled"):i.removeClass("btn-disabled")},F=t=>{let a=document.getElementById("storage-progress");a.style.width=t.percentage+"%",a.className=t.progress;let e=document.getElementById("storage-used");e.innerHTML=t.used}; diff --git a/public/build/assets/relations-5fb6c751.js b/public/build/assets/relations-5fb6c751.js deleted file mode 100644 index 8c00b3d01f..0000000000 --- a/public/build/assets/relations-5fb6c751.js +++ /dev/null @@ -1,47 +0,0 @@ -import{c as zr,g as mc}from"./_commonjsHelpers-725317a4.js";function bc(t){var e=typeof t;return t!=null&&(e=="object"||e=="function")}var Ba=bc,wc=typeof zr=="object"&&zr&&zr.Object===Object&&zr,Ec=wc,xc=Ec,Tc=typeof self=="object"&&self&&self.Object===Object&&self,Cc=xc||Tc||Function("return this")(),Ri=Cc,Dc=Ri,Sc=function(){return Dc.Date.now()},Lc=Sc,Ac=/\s/;function Mc(t){for(var e=t.length;e--&&Ac.test(t.charAt(e)););return e}var Nc=Mc,Oc=Nc,Ic=/^\s+/;function kc(t){return t&&t.slice(0,Oc(t)+1).replace(Ic,"")}var Rc=kc,Pc=Ri,Bc=Pc.Symbol,Zo=Bc,Gs=Zo,al=Object.prototype,Fc=al.hasOwnProperty,zc=al.toString,da=Gs?Gs.toStringTag:void 0;function Gc(t){var e=Fc.call(t,da),r=t[da];try{t[da]=void 0;var n=!0}catch{}var a=zc.call(t);return n&&(e?t[da]=r:delete t[da]),a}var Hc=Gc,qc=Object.prototype,$c=qc.toString;function Vc(t){return $c.call(t)}var Uc=Vc,Hs=Zo,Yc=Hc,Wc=Uc,Xc="[object Null]",_c="[object Undefined]",qs=Hs?Hs.toStringTag:void 0;function Kc(t){return t==null?t===void 0?_c:Xc:qs&&qs in Object(t)?Yc(t):Wc(t)}var il=Kc;function Zc(t){return t!=null&&typeof t=="object"}var Qc=Zc,jc=il,Jc=Qc,eh="[object Symbol]";function th(t){return typeof t=="symbol"||Jc(t)&&jc(t)==eh}var Fa=th,rh=Rc,$s=Ba,nh=Fa,Vs=0/0,ah=/^[-+]0x[0-9a-f]+$/i,ih=/^0b[01]+$/i,oh=/^0o[0-7]+$/i,sh=parseInt;function uh(t){if(typeof t=="number")return t;if(nh(t))return Vs;if($s(t)){var e=typeof t.valueOf=="function"?t.valueOf():t;t=$s(e)?e+"":e}if(typeof t!="string")return t===0?t:+t;t=rh(t);var r=ih.test(t);return r||oh.test(t)?sh(t.slice(2),r?2:8):ah.test(t)?Vs:+t}var lh=uh,fh=Ba,wo=Lc,Us=lh,ch="Expected a function",hh=Math.max,vh=Math.min;function dh(t,e,r){var n,a,i,o,s,u,l=0,f=!1,h=!1,p=!0;if(typeof t!="function")throw new TypeError(ch);e=Us(e)||0,fh(r)&&(f=!!r.leading,h="maxWait"in r,i=h?hh(Us(r.maxWait)||0,e):i,p="trailing"in r?!!r.trailing:p);function d(I){var v=n,L=a;return n=a=void 0,l=I,o=t.apply(L,v),o}function g(I){return l=I,s=setTimeout(b,e),f?d(I):o}function m(I){var v=I-u,L=I-l,D=e-v;return h?vh(D,i-L):D}function w(I){var v=I-u,L=I-l;return u===void 0||v>=e||v<0||h&&L>=i}function b(){var I=wo();if(w(I))return T(I);s=setTimeout(b,m(I))}function T(I){return s=void 0,p&&n?d(I):(n=a=void 0,o)}function E(){s!==void 0&&clearTimeout(s),l=0,n=u=a=s=void 0}function S(){return s===void 0?o:T(wo())}function A(){var I=wo(),v=w(I);if(n=arguments,a=this,u=I,v){if(s===void 0)return g(u);if(h)return clearTimeout(s),s=setTimeout(b,e),d(u)}return s===void 0&&(s=setTimeout(b,e)),o}return A.cancel=E,A.flush=S,A}var gh=dh,ko={},ph={get exports(){return ko},set exports(t){ko=t}},Ro={},yh={get exports(){return Ro},set exports(t){Ro=t}};(function(t,e){(function(){var r,n,a,i,o,s,u,l,f,h,p,d,g,m,w;a=Math.floor,h=Math.min,n=function(b,T){return bT?1:0},f=function(b,T,E,S,A){var I;if(E==null&&(E=0),A==null&&(A=n),E<0)throw new Error("lo must be non-negative");for(S==null&&(S=b.length);EO;0<=O?D++:D--)L.push(D);return L}.apply(this).reverse(),v=[],S=0,A=I.length;SR;0<=R?++L:--L)k.push(o(b,E));return k},m=function(b,T,E,S){var A,I,v;for(S==null&&(S=n),A=b[E];E>T;){if(v=E-1>>1,I=b[v],S(A,I)<0){b[E]=I,E=v;continue}break}return b[E]=A},w=function(b,T,E){var S,A,I,v,L;for(E==null&&(E=n),A=b.length,L=T,I=b[T],S=2*T+1;S-1}var _v=Xv,Kv=Fi;function Zv(t,e){var r=this.__data__,n=Kv(r,t);return n<0?(++this.size,r.push([t,e])):r[n][1]=e,this}var Qv=Zv,jv=Rv,Jv=$v,ed=Yv,td=_v,rd=Qv;function Zn(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e-1&&t%1==0&&tt.length)&&(e=t.length);for(var r=0,n=new Array(e);r"u"?null:window,tu=Mt?Mt.navigator:null;Mt&&Mt.document;var op=Ot(""),dl=Ot({}),sp=Ot(function(){}),up=typeof HTMLElement>"u"?"undefined":Ot(HTMLElement),Ha=function(e){return e&&e.instanceString&&Et(e.instanceString)?e.instanceString():null},Ge=function(e){return e!=null&&Ot(e)==op},Et=function(e){return e!=null&&Ot(e)===sp},dt=function(e){return!ur(e)&&(Array.isArray?Array.isArray(e):e!=null&&e instanceof Array)},ot=function(e){return e!=null&&Ot(e)===dl&&!dt(e)&&e.constructor===Object},lp=function(e){return e!=null&&Ot(e)===dl},Ae=function(e){return e!=null&&Ot(e)===Ot(1)&&!isNaN(e)},fp=function(e){return Ae(e)&&Math.floor(e)===e},xi=function(e){if(up!=="undefined")return e!=null&&e instanceof HTMLElement},ur=function(e){return qa(e)||gl(e)},qa=function(e){return Ha(e)==="collection"&&e._private.single},gl=function(e){return Ha(e)==="collection"&&!e._private.single},rs=function(e){return Ha(e)==="core"},pl=function(e){return Ha(e)==="stylesheet"},cp=function(e){return Ha(e)==="event"},an=function(e){return e==null?!0:!!(e===""||e.match(/^\s+$/))},hp=function(e){return typeof HTMLElement>"u"?!1:e instanceof HTMLElement},vp=function(e){return ot(e)&&Ae(e.x1)&&Ae(e.x2)&&Ae(e.y1)&&Ae(e.y2)},dp=function(e){return lp(e)&&Et(e.then)},gp=function(){return tu&&tu.userAgent.match(/msie|trident|edge/i)},Sa=function(e,r){r||(r=function(){if(arguments.length===1)return arguments[0];if(arguments.length===0)return"undefined";for(var i=[],o=0;or?1:0},xp=function(e,r){return-1*ml(e,r)},$e=Object.assign!=null?Object.assign.bind(Object):function(t){for(var e=arguments,r=1;r1&&(w-=1),w<1/6?g+(m-g)*6*w:w<1/2?m:w<2/3?g+(m-g)*(2/3-w)*6:g}var h=new RegExp("^"+mp+"$").exec(e);if(h){if(n=parseInt(h[1]),n<0?n=(360- -1*n%360)%360:n>360&&(n=n%360),n/=360,a=parseFloat(h[2]),a<0||a>100||(a=a/100,i=parseFloat(h[3]),i<0||i>100)||(i=i/100,o=h[4],o!==void 0&&(o=parseFloat(o),o<0||o>1)))return;if(a===0)s=u=l=Math.round(i*255);else{var p=i<.5?i*(1+a):i+a-i*a,d=2*i-p;s=Math.round(255*f(d,p,n+1/3)),u=Math.round(255*f(d,p,n)),l=Math.round(255*f(d,p,n-1/3))}r=[s,u,l,o]}return r},Dp=function(e){var r,n=new RegExp("^"+pp+"$").exec(e);if(n){r=[];for(var a=[],i=1;i<=3;i++){var o=n[i];if(o[o.length-1]==="%"&&(a[i]=!0),o=parseFloat(o),a[i]&&(o=o/100*255),o<0||o>255)return;r.push(Math.floor(o))}var s=a[1]||a[2]||a[3],u=a[1]&&a[2]&&a[3];if(s&&!u)return;var l=n[4];if(l!==void 0){if(l=parseFloat(l),l<0||l>1)return;r.push(l)}}return r},Sp=function(e){return Ap[e.toLowerCase()]},Lp=function(e){return(dt(e)?e:null)||Sp(e)||Tp(e)||Dp(e)||Cp(e)},Ap={transparent:[0,0,0,0],aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],grey:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]},bl=function(e){for(var r=e.map,n=e.keys,a=n.length,i=0;i1&&arguments[1]!==void 0?arguments[1]:Gn,n=r,a;a=e.next(),!a.done;)n=n*xl+a.value|0;return n},La=function(e){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Gn;return r*xl+e|0},Aa=function(e){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:wa;return(r<<5)+r+e|0},Np=function(e,r){return e*2097152+r},Qr=function(e){return e[0]*2097152+e[1]},ai=function(e,r){return[La(e[0],r[0]),Aa(e[1],r[1])]},Op=function(e,r){var n={value:0,done:!1},a=0,i=e.length,o={next:function(){return a=0&&!(e[a]===r&&(e.splice(a,1),n));a--);},os=function(e){e.splice(0,e.length)},zp=function(e,r){for(var n=0;n"u"?"undefined":Ot(Set))!==Hp?Set:qp,qi=function(e,r){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0;if(e===void 0||r===void 0||!rs(e)){Tt("An element must have a core reference and parameters set");return}var a=r.group;if(a==null&&(r.data&&r.data.source!=null&&r.data.target!=null?a="edges":a="nodes"),a!=="nodes"&&a!=="edges"){Tt("An element must be of type `nodes` or `edges`; you specified `"+a+"`");return}this.length=1,this[0]=this;var i=this._private={cy:e,single:!0,data:r.data||{},position:r.position||{x:0,y:0},autoWidth:void 0,autoHeight:void 0,autoPadding:void 0,compoundBoundsClean:!1,listeners:[],group:a,style:{},rstyle:{},styleCxts:[],styleKeys:{},removed:!0,selected:!!r.selected,selectable:r.selectable===void 0?!0:!!r.selectable,locked:!!r.locked,grabbed:!1,grabbable:r.grabbable===void 0?!0:!!r.grabbable,pannable:r.pannable===void 0?a==="edges":!!r.pannable,active:!1,classes:new jn,animation:{current:[],queue:[]},rscratch:{},scratch:r.scratch||{},edges:[],children:[],parent:r.parent&&r.parent.isNode()?r.parent:null,traversalCache:{},backgrounding:!1,bbCache:null,bbCacheShift:{x:0,y:0},bodyBounds:null,overlayBounds:null,labelBounds:{all:null,source:null,target:null,main:null},arrowBounds:{source:null,target:null,"mid-source":null,"mid-target":null}};if(i.position.x==null&&(i.position.x=0),i.position.y==null&&(i.position.y=0),r.renderedPosition){var o=r.renderedPosition,s=e.pan(),u=e.zoom();i.position={x:(o.x-s.x)/u,y:(o.y-s.y)/u}}var l=[];dt(r.classes)?l=r.classes:Ge(r.classes)&&(l=r.classes.split(/\s+/));for(var f=0,h=l.length;f0;){var I=T.pop(),v=w(I),L=I.id();if(p[L]=v,v!==1/0)for(var D=I.neighborhood().intersect(g),O=0;O0)for(W.unshift(V);h[j];){var K=h[j];W.unshift(K.edge),W.unshift(K.node),X=K.node,j=X.id()}return s.spawn(W)}}}},Up={kruskal:function(e){e=e||function(E){return 1};for(var r=this.byGroup(),n=r.nodes,a=r.edges,i=n.length,o=new Array(i),s=n,u=function(S){for(var A=0;A0;){if(A(),v++,S===f){for(var L=[],D=i,O=f,R=b[O];L.unshift(D),R!=null&&L.unshift(R),D=w[O],D!=null;)O=D.id(),R=b[O];return{found:!0,distance:h[S],path:this.spawn(L),steps:v}}d[S]=!0;for(var k=E._private.edges,z=0;zR&&(g[O]=R,T[O]=D,E[O]=A),!i){var k=D*f+L;!i&&g[k]>R&&(g[k]=R,T[k]=L,E[k]=A)}}}for(var z=0;z1&&arguments[1]!==void 0?arguments[1]:o,ke=E(pe),Re=[],Me=ke;;){if(Me==null)return r.spawn();var ze=T(Me),ye=ze.edge,F=ze.pred;if(Re.unshift(Me[0]),Me.same(Se)&&Re.length>0)break;ye!=null&&Re.unshift(ye),Me=F}return u.spawn(Re)},I=0;I=0;f--){var h=l[f],p=h[1],d=h[2];(r[p]===s&&r[d]===u||r[p]===u&&r[d]===s)&&l.splice(f,1)}for(var g=0;ga;){var i=Math.floor(Math.random()*r.length);r=jp(i,e,r),n--}return r},Jp={kargerStein:function(){var e=this,r=this.byGroup(),n=r.nodes,a=r.edges;a.unmergeBy(function(W){return W.isLoop()});var i=n.length,o=a.length,s=Math.ceil(Math.pow(Math.log(i)/Math.LN2,2)),u=Math.floor(i/Qp);if(i<2){Tt("At least 2 nodes are required for Karger-Stein algorithm");return}for(var l=[],f=0;f1&&arguments[1]!==void 0?arguments[1]:0,n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:e.length,a=1/0,i=r;i1&&arguments[1]!==void 0?arguments[1]:0,n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:e.length,a=-1/0,i=r;i1&&arguments[1]!==void 0?arguments[1]:0,n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:e.length,a=0,i=0,o=r;o1&&arguments[1]!==void 0?arguments[1]:0,n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:e.length,a=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!0,i=arguments.length>4&&arguments[4]!==void 0?arguments[4]:!0,o=arguments.length>5&&arguments[5]!==void 0?arguments[5]:!0;a?e=e.slice(r,n):(n0&&e.splice(0,r));for(var s=0,u=e.length-1;u>=0;u--){var l=e[u];o?isFinite(l)||(e[u]=-1/0,s++):e.splice(u,1)}i&&e.sort(function(p,d){return p-d});var f=e.length,h=Math.floor(f/2);return f%2!==0?e[h+1+s]:(e[h-1+s]+e[h+s])/2},iy=function(e){return Math.PI*e/180},ii=function(e,r){return Math.atan2(r,e)-Math.PI/2},ss=Math.log2||function(t){return Math.log(t)/Math.log(2)},Nl=function(e){return e>0?1:e<0?-1:0},xn=function(e,r){return Math.sqrt(mn(e,r))},mn=function(e,r){var n=r.x-e.x,a=r.y-e.y;return n*n+a*a},oy=function(e){for(var r=e.length,n=0,a=0;a=e.x1&&e.y2>=e.y1)return{x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,w:e.x2-e.x1,h:e.y2-e.y1};if(e.w!=null&&e.h!=null&&e.w>=0&&e.h>=0)return{x1:e.x1,y1:e.y1,x2:e.x1+e.w,y2:e.y1+e.h,w:e.w,h:e.h}}},uy=function(e){return{x1:e.x1,x2:e.x2,w:e.w,y1:e.y1,y2:e.y2,h:e.h}},ly=function(e){e.x1=1/0,e.y1=1/0,e.x2=-1/0,e.y2=-1/0,e.w=0,e.h=0},fy=function(e,r){e.x1=Math.min(e.x1,r.x1),e.x2=Math.max(e.x2,r.x2),e.w=e.x2-e.x1,e.y1=Math.min(e.y1,r.y1),e.y2=Math.max(e.y2,r.y2),e.h=e.y2-e.y1},cy=function(e,r,n){e.x1=Math.min(e.x1,r),e.x2=Math.max(e.x2,r),e.w=e.x2-e.x1,e.y1=Math.min(e.y1,n),e.y2=Math.max(e.y2,n),e.h=e.y2-e.y1},gi=function(e){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;return e.x1-=r,e.x2+=r,e.y1-=r,e.y2+=r,e.w=e.x2-e.x1,e.h=e.y2-e.y1,e},Co=function(e){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[0],n,a,i,o;if(r.length===1)n=a=i=o=r[0];else if(r.length===2)n=i=r[0],o=a=r[1];else if(r.length===4){var s=br(r,4);n=s[0],a=s[1],i=s[2],o=s[3]}return e.x1-=o,e.x2+=a,e.y1-=n,e.y2+=i,e.w=e.x2-e.x1,e.h=e.y2-e.y1,e},ou=function(e,r){e.x1=r.x1,e.y1=r.y1,e.x2=r.x2,e.y2=r.y2,e.w=e.x2-e.x1,e.h=e.y2-e.y1},us=function(e,r){return!(e.x1>r.x2||r.x1>e.x2||e.x2r.y2||r.y1>e.y2)},Wn=function(e,r,n){return e.x1<=r&&r<=e.x2&&e.y1<=n&&n<=e.y2},hy=function(e,r){return Wn(e,r.x,r.y)},Ol=function(e,r){return Wn(e,r.x1,r.y1)&&Wn(e,r.x2,r.y2)},Il=function(e,r,n,a,i,o,s){var u=$a(i,o),l=i/2,f=o/2,h;{var p=n-l+u-s,d=a-f-s,g=n+l-u+s,m=d;if(h=tn(e,r,n,a,p,d,g,m,!1),h.length>0)return h}{var w=n+l+s,b=a-f+u-s,T=w,E=a+f-u+s;if(h=tn(e,r,n,a,w,b,T,E,!1),h.length>0)return h}{var S=n-l+u-s,A=a+f+s,I=n+l-u+s,v=A;if(h=tn(e,r,n,a,S,A,I,v,!1),h.length>0)return h}{var L=n-l-s,D=a-f+u-s,O=L,R=a+f-u+s;if(h=tn(e,r,n,a,L,D,O,R,!1),h.length>0)return h}var k;{var z=n-l+u,B=a-f+u;if(k=Ea(e,r,n,a,z,B,u+s),k.length>0&&k[0]<=z&&k[1]<=B)return[k[0],k[1]]}{var U=n+l-u,H=a-f+u;if(k=Ea(e,r,n,a,U,H,u+s),k.length>0&&k[0]>=U&&k[1]<=H)return[k[0],k[1]]}{var V=n+l-u,W=a+f-u;if(k=Ea(e,r,n,a,V,W,u+s),k.length>0&&k[0]>=V&&k[1]>=W)return[k[0],k[1]]}{var X=n-l+u,j=a+f-u;if(k=Ea(e,r,n,a,X,j,u+s),k.length>0&&k[0]<=X&&k[1]>=j)return[k[0],k[1]]}return[]},vy=function(e,r,n,a,i,o,s){var u=s,l=Math.min(n,i),f=Math.max(n,i),h=Math.min(a,o),p=Math.max(a,o);return l-u<=e&&e<=f+u&&h-u<=r&&r<=p+u},dy=function(e,r,n,a,i,o,s,u,l){var f={x1:Math.min(n,s,i)-l,x2:Math.max(n,s,i)+l,y1:Math.min(a,u,o)-l,y2:Math.max(a,u,o)+l};return!(ef.x2||rf.y2)},gy=function(e,r,n,a){n-=a;var i=r*r-4*e*n;if(i<0)return[];var o=Math.sqrt(i),s=2*e,u=(-r+o)/s,l=(-r-o)/s;return[u,l]},py=function(e,r,n,a,i){var o=1e-5;e===0&&(e=o),r/=e,n/=e,a/=e;var s,u,l,f,h,p,d,g;if(u=(3*n-r*r)/9,l=-(27*a)+r*(9*n-2*(r*r)),l/=54,s=u*u*u+l*l,i[1]=0,d=r/3,s>0){h=l+Math.sqrt(s),h=h<0?-Math.pow(-h,1/3):Math.pow(h,1/3),p=l-Math.sqrt(s),p=p<0?-Math.pow(-p,1/3):Math.pow(p,1/3),i[0]=-d+h+p,d+=(h+p)/2,i[4]=i[2]=-d,d=Math.sqrt(3)*(-p+h)/2,i[3]=d,i[5]=-d;return}if(i[5]=i[3]=0,s===0){g=l<0?-Math.pow(-l,1/3):Math.pow(l,1/3),i[0]=-d+2*g,i[4]=i[2]=-(g+d);return}u=-u,f=u*u*u,f=Math.acos(l/Math.sqrt(f)),g=2*Math.sqrt(u),i[0]=-d+g*Math.cos(f/3),i[2]=-d+g*Math.cos((f+2*Math.PI)/3),i[4]=-d+g*Math.cos((f+4*Math.PI)/3)},yy=function(e,r,n,a,i,o,s,u){var l=1*n*n-4*n*i+2*n*s+4*i*i-4*i*s+s*s+a*a-4*a*o+2*a*u+4*o*o-4*o*u+u*u,f=1*9*n*i-3*n*n-3*n*s-6*i*i+3*i*s+9*a*o-3*a*a-3*a*u-6*o*o+3*o*u,h=1*3*n*n-6*n*i+n*s-n*e+2*i*i+2*i*e-s*e+3*a*a-6*a*o+a*u-a*r+2*o*o+2*o*r-u*r,p=1*n*i-n*n+n*e-i*e+a*o-a*a+a*r-o*r,d=[];py(l,f,h,p,d);for(var g=1e-7,m=[],w=0;w<6;w+=2)Math.abs(d[w+1])=0&&d[w]<=1&&m.push(d[w]);m.push(1),m.push(0);for(var b=-1,T,E,S,A=0;A=0?Sl?(e-i)*(e-i)+(r-o)*(r-o):f-p},or=function(e,r,n){for(var a,i,o,s,u,l=0,f=0;f=e&&e>=o||a<=e&&e<=o)u=(e-a)/(o-a)*(s-i)+i,u>r&&l++;else continue;return l%2!==0},Hr=function(e,r,n,a,i,o,s,u,l){var f=new Array(n.length),h;u[0]!=null?(h=Math.atan(u[1]/u[0]),u[0]<0?h=h+Math.PI/2:h=-h-Math.PI/2):h=u;for(var p=Math.cos(-h),d=Math.sin(-h),g=0;g0){var w=Rl(f,-l);m=kl(w)}else m=f;return or(e,r,m)},by=function(e,r,n,a,i,o,s){for(var u=new Array(n.length),l=o/2,f=s/2,h=ls(o,s),p=h*h,d=0;d=0&&w<=1&&T.push(w),b>=0&&b<=1&&T.push(b),T.length===0)return[];var E=T[0]*u[0]+e,S=T[0]*u[1]+r;if(T.length>1){if(T[0]==T[1])return[E,S];var A=T[1]*u[0]+e,I=T[1]*u[1]+r;return[E,S,A,I]}else return[E,S]},Do=function(e,r,n){return r<=e&&e<=n||n<=e&&e<=r?e:e<=r&&r<=n||n<=r&&r<=e?r:n},tn=function(e,r,n,a,i,o,s,u,l){var f=e-i,h=n-e,p=s-i,d=r-o,g=a-r,m=u-o,w=p*d-m*f,b=h*d-g*f,T=m*h-p*g;if(T!==0){var E=w/T,S=b/T,A=.001,I=0-A,v=1+A;return I<=E&&E<=v&&I<=S&&S<=v?[e+E*h,r+E*g]:l?[e+E*h,r+E*g]:[]}else return w===0||b===0?Do(e,n,s)===s?[s,u]:Do(e,n,i)===i?[i,o]:Do(i,s,n)===n?[n,a]:[]:[]},Oa=function(e,r,n,a,i,o,s,u){var l=[],f,h=new Array(n.length),p=!0;o==null&&(p=!1);var d;if(p){for(var g=0;g0){var m=Rl(h,-u);d=kl(m)}else d=h}else d=n;for(var w,b,T,E,S=0;S2){for(var H=[l[0],l[1]],V=Math.pow(H[0]-e,2)+Math.pow(H[1]-r,2),W=1;Wf&&(f=S)},get:function(E){return l[E]}},p=0;p0?H=U.edgesTo(B)[0]:H=B.edgesTo(U)[0];var V=a(H);B=B.id(),L[B]>L[k]+V&&(L[B]=L[k]+V,D.nodes.indexOf(B)<0?D.push(B):D.updateItem(B),v[B]=0,I[B]=[]),L[B]==L[k]+V&&(v[B]=v[B]+v[k],I[B].push(k))}else for(var W=0;W0;){for(var J=A.pop(),ne=0;ne0&&s.push(n[u]);s.length!==0&&i.push(a.collection(s))}return i},Py=function(e,r){for(var n=0;n5&&arguments[5]!==void 0?arguments[5]:zy,s=a,u,l,f=0;f=2?ga(e,r,n,0,cu,Gy):ga(e,r,n,0,fu)},squaredEuclidean:function(e,r,n){return ga(e,r,n,0,cu)},manhattan:function(e,r,n){return ga(e,r,n,0,fu)},max:function(e,r,n){return ga(e,r,n,-1/0,Hy)}};Xn["squared-euclidean"]=Xn.squaredEuclidean;Xn.squaredeuclidean=Xn.squaredEuclidean;function Vi(t,e,r,n,a,i){var o;return Et(t)?o=t:o=Xn[t]||Xn.euclidean,e===0&&Et(t)?o(a,i):o(e,r,n,a,i)}var qy=$t({k:2,m:2,sensitivityThreshold:1e-4,distance:"euclidean",maxIterations:10,attributes:[],testMode:!1,testCentroids:null}),fs=function(e){return qy(e)},Di=function(e,r,n,a,i){var o=i!=="kMedoids",s=o?function(h){return n[h]}:function(h){return a[h](n)},u=function(p){return a[p](r)},l=n,f=r;return Vi(e,a.length,s,u,l,f)},So=function(e,r,n){for(var a=n.length,i=new Array(a),o=new Array(a),s=new Array(r),u=null,l=0;ln)return!1}return!0},Uy=function(e,r,n){for(var a=0;as&&(s=r[l][f],u=f);i[u].push(e[l])}for(var h=0;h=i.threshold||i.mode==="dendrogram"&&e.length===1)return!1;var g=r[o],m=r[a[o]],w;i.mode==="dendrogram"?w={left:g,right:m,key:g.key}:w={value:g.value.concat(m.value),key:g.key},e[g.index]=w,e.splice(m.index,1),r[g.key]=w;for(var b=0;bn[m.key][T.key]&&(u=n[m.key][T.key])):i.linkage==="max"?(u=n[g.key][T.key],n[g.key][T.key]0&&a.push(i);return a},yu=function(e,r,n){for(var a=[],i=0;is&&(o=l,s=r[i*e+l])}o>0&&a.push(o)}for(var f=0;fl&&(u=f,l=h)}n[i]=o[u]}return a=yu(e,r,n),a},mu=function(e){for(var r=this.cy(),n=this.nodes(),a=am(e),i={},o=0;o=R?(k=R,R=B,z=U):B>k&&(k=B);for(var H=0;H0?1:0;v[D%a.minIterations*s+J]=ne,K+=ne}if(K>0&&(D>=a.minIterations-1||D==a.maxIterations-1)){for(var ie=0,oe=0;oe1||I>1)&&(s=!0),h[E]=[],T.outgoers().forEach(function(L){L.isEdge()&&h[E].push(L.id())})}else p[E]=[void 0,T.target().id()]}):o.forEach(function(T){var E=T.id();if(T.isNode()){var S=T.degree(!0);S%2&&(u?l?s=!0:l=E:u=E),h[E]=[],T.connectedEdges().forEach(function(A){return h[E].push(A.id())})}else p[E]=[T.source().id(),T.target().id()]});var d={found:!1,trail:void 0};if(s)return d;if(l&&u)if(i){if(f&&l!=f)return d;f=l}else{if(f&&l!=f&&u!=f)return d;f||(f=l)}else f||(f=o[0].id());var g=function(E){for(var S=E,A=[E],I,v,L;h[S].length;)I=h[S].shift(),v=p[I][0],L=p[I][1],S!=L?(h[L]=h[L].filter(function(D){return D!=I}),S=L):!i&&S!=v&&(h[v]=h[v].filter(function(D){return D!=I}),S=v),A.unshift(I),A.unshift(S);return A},m=[],w=[];for(w=g(f);w.length!=1;)h[w[0]].length==0?(m.unshift(o.getElementById(w.shift())),m.unshift(o.getElementById(w.shift()))):w=g(w.shift()).concat(w);m.unshift(o.getElementById(w.shift()));for(var b in h)if(h[b].length)return d;return d.found=!0,d.trail=this.spawn(m,!0),d}},ui=function(){var e=this,r={},n=0,a=0,i=[],o=[],s={},u=function(p,d){for(var g=o.length-1,m=[],w=e.spawn();o[g].x!=p||o[g].y!=d;)m.push(o.pop().edge),g--;m.push(o.pop().edge),m.forEach(function(b){var T=b.connectedNodes().intersection(e);w.merge(b),T.forEach(function(E){var S=E.id(),A=E.connectedEdges().intersection(e);w.merge(E),r[S].cutVertex?w.merge(A.filter(function(I){return I.isLoop()})):w.merge(A)})}),i.push(w)},l=function h(p,d,g){p===g&&(a+=1),r[d]={id:n,low:n++,cutVertex:!1};var m=e.getElementById(d).connectedEdges().intersection(e);if(m.size()===0)i.push(e.spawn(e.getElementById(d)));else{var w,b,T,E;m.forEach(function(S){w=S.source().id(),b=S.target().id(),T=w===d?b:w,T!==g&&(E=S.id(),s[E]||(s[E]=!0,o.push({x:d,y:T,edge:S})),T in r?r[d].low=Math.min(r[d].low,r[T].id):(h(p,T,d),r[d].low=Math.min(r[d].low,r[T].low),r[d].id<=r[T].low&&(r[d].cutVertex=!0,u(d,T))))})}};e.forEach(function(h){if(h.isNode()){var p=h.id();p in r||(a=0,l(p,p),r[p].cutVertex=a>1)}});var f=Object.keys(r).filter(function(h){return r[h].cutVertex}).map(function(h){return e.getElementById(h)});return{cut:e.spawn(f),components:i}},hm={hopcroftTarjanBiconnected:ui,htbc:ui,htb:ui,hopcroftTarjanBiconnectedComponents:ui},li=function(){var e=this,r={},n=0,a=[],i=[],o=e.spawn(e),s=function u(l){i.push(l),r[l]={index:n,low:n++,explored:!1};var f=e.getElementById(l).connectedEdges().intersection(e);if(f.forEach(function(m){var w=m.target().id();w!==l&&(w in r||u(w),r[w].explored||(r[l].low=Math.min(r[l].low,r[w].low)))}),r[l].index===r[l].low){for(var h=e.spawn();;){var p=i.pop();if(h.merge(e.getElementById(p)),r[p].low=r[l].index,r[p].explored=!0,p===l)break}var d=h.edgesWith(h),g=h.merge(d);a.push(g),o=o.difference(g)}};return e.forEach(function(u){if(u.isNode()){var l=u.id();l in r||s(l)}}),{cut:o,components:a}},vm={tarjanStronglyConnected:li,tsc:li,tscc:li,tarjanStronglyConnectedComponents:li},ql={};[Ma,Vp,Up,Wp,_p,Zp,Jp,Cy,Vn,Un,Fo,Fy,Zy,rm,lm,cm,hm,vm].forEach(function(t){$e(ql,t)});/*! -Embeddable Minimum Strictly-Compliant Promises/A+ 1.1.1 Thenable -Copyright (c) 2013-2014 Ralf S. Engelschall (http://engelschall.com) -Licensed under The MIT License (http://opensource.org/licenses/MIT) -*/var $l=0,Vl=1,Ul=2,qr=function t(e){if(!(this instanceof t))return new t(e);this.id="Thenable/1.0.7",this.state=$l,this.fulfillValue=void 0,this.rejectReason=void 0,this.onFulfilled=[],this.onRejected=[],this.proxy={then:this.then.bind(this)},typeof e=="function"&&e.call(this,this.fulfill.bind(this),this.reject.bind(this))};qr.prototype={fulfill:function(e){return bu(this,Vl,"fulfillValue",e)},reject:function(e){return bu(this,Ul,"rejectReason",e)},then:function(e,r){var n=this,a=new qr;return n.onFulfilled.push(Eu(e,a,"fulfill")),n.onRejected.push(Eu(r,a,"reject")),Yl(n),a.proxy}};var bu=function(e,r,n,a){return e.state===$l&&(e.state=r,e[n]=a,Yl(e)),e},Yl=function(e){e.state===Vl?wu(e,"onFulfilled",e.fulfillValue):e.state===Ul&&wu(e,"onRejected",e.rejectReason)},wu=function(e,r,n){if(e[r].length!==0){var a=e[r];e[r]=[];var i=function(){for(var s=0;s0}},clearQueue:function(){return function(){var r=this,n=r.length!==void 0,a=n?r:[r],i=this._private.cy||this;if(!i.styleEnabled())return this;for(var o=0;o0&&this.spawn(a).updateStyle().emit("class"),r},addClass:function(e){return this.toggleClass(e,!0)},hasClass:function(e){var r=this[0];return r!=null&&r._private.classes.has(e)},toggleClass:function(e,r){dt(e)||(e=e.match(/\S+/g)||[]);for(var n=this,a=r===void 0,i=[],o=0,s=n.length;o0&&this.spawn(i).updateStyle().emit("class"),n},removeClass:function(e){return this.toggleClass(e,!1)},flashClass:function(e,r){var n=this;if(r==null)r=250;else if(r===0)return n;return n.addClass(e),setTimeout(function(){n.removeClass(e)},r),n}};pi.className=pi.classNames=pi.classes;var it={metaChar:"[\\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\]\\^\\`\\{\\|\\}\\~]",comparatorOp:"=|\\!=|>|>=|<|<=|\\$=|\\^=|\\*=",boolOp:"\\?|\\!|\\^",string:`"(?:\\\\"|[^"])*"|'(?:\\\\'|[^'])*'`,number:Nt,meta:"degree|indegree|outdegree",separator:"\\s*,\\s*",descendant:"\\s+",child:"\\s+>\\s+",subject:"\\$",group:"node|edge|\\*",directedEdge:"\\s+->\\s+",undirectedEdge:"\\s+<->\\s+"};it.variable="(?:[\\w-.]|(?:\\\\"+it.metaChar+"))+";it.className="(?:[\\w-]|(?:\\\\"+it.metaChar+"))+";it.value=it.string+"|"+it.number;it.id=it.variable;(function(){var t,e,r;for(t=it.comparatorOp.split("|"),r=0;r=0)&&e!=="="&&(it.comparatorOp+="|\\!"+e)})();var vt=function(){return{checks:[]}},Ie={GROUP:0,COLLECTION:1,FILTER:2,DATA_COMPARE:3,DATA_EXIST:4,DATA_BOOL:5,META_COMPARE:6,STATE:7,ID:8,CLASS:9,UNDIRECTED_EDGE:10,DIRECTED_EDGE:11,NODE_SOURCE:12,NODE_TARGET:13,NODE_NEIGHBOR:14,CHILD:15,DESCENDANT:16,PARENT:17,ANCESTOR:18,COMPOUND_SPLIT:19,TRUE:20},Go=[{selector:":selected",matches:function(e){return e.selected()}},{selector:":unselected",matches:function(e){return!e.selected()}},{selector:":selectable",matches:function(e){return e.selectable()}},{selector:":unselectable",matches:function(e){return!e.selectable()}},{selector:":locked",matches:function(e){return e.locked()}},{selector:":unlocked",matches:function(e){return!e.locked()}},{selector:":visible",matches:function(e){return e.visible()}},{selector:":hidden",matches:function(e){return!e.visible()}},{selector:":transparent",matches:function(e){return e.transparent()}},{selector:":grabbed",matches:function(e){return e.grabbed()}},{selector:":free",matches:function(e){return!e.grabbed()}},{selector:":removed",matches:function(e){return e.removed()}},{selector:":inside",matches:function(e){return!e.removed()}},{selector:":grabbable",matches:function(e){return e.grabbable()}},{selector:":ungrabbable",matches:function(e){return!e.grabbable()}},{selector:":animated",matches:function(e){return e.animated()}},{selector:":unanimated",matches:function(e){return!e.animated()}},{selector:":parent",matches:function(e){return e.isParent()}},{selector:":childless",matches:function(e){return e.isChildless()}},{selector:":child",matches:function(e){return e.isChild()}},{selector:":orphan",matches:function(e){return e.isOrphan()}},{selector:":nonorphan",matches:function(e){return e.isChild()}},{selector:":compound",matches:function(e){return e.isNode()?e.isParent():e.source().isParent()||e.target().isParent()}},{selector:":loop",matches:function(e){return e.isLoop()}},{selector:":simple",matches:function(e){return e.isSimple()}},{selector:":active",matches:function(e){return e.active()}},{selector:":inactive",matches:function(e){return!e.active()}},{selector:":backgrounding",matches:function(e){return e.backgrounding()}},{selector:":nonbackgrounding",matches:function(e){return!e.backgrounding()}}].sort(function(t,e){return xp(t.selector,e.selector)}),bm=function(){for(var t={},e,r=0;r0&&f.edgeCount>0)return lt("The selector `"+e+"` is invalid because it uses both a compound selector and an edge selector"),!1;if(f.edgeCount>1)return lt("The selector `"+e+"` is invalid because it uses multiple edge selectors"),!1;f.edgeCount===1&<("The selector `"+e+"` is deprecated. Edge selectors do not take effect on changes to source and target nodes after an edge is added, for performance reasons. Use a class or data selector on edges instead, updating the class or data of an edge when your app detects a change in source or target nodes.")}return!0},Dm=function(){if(this.toStringCache!=null)return this.toStringCache;for(var e=function(f){return f??""},r=function(f){return Ge(f)?'"'+f+'"':e(f)},n=function(f){return" "+f+" "},a=function(f,h){var p=f.type,d=f.value;switch(p){case Ie.GROUP:{var g=e(d);return g.substring(0,g.length-1)}case Ie.DATA_COMPARE:{var m=f.field,w=f.operator;return"["+m+n(e(w))+r(d)+"]"}case Ie.DATA_BOOL:{var b=f.operator,T=f.field;return"["+e(b)+T+"]"}case Ie.DATA_EXIST:{var E=f.field;return"["+E+"]"}case Ie.META_COMPARE:{var S=f.operator,A=f.field;return"[["+A+n(e(S))+r(d)+"]]"}case Ie.STATE:return d;case Ie.ID:return"#"+d;case Ie.CLASS:return"."+d;case Ie.PARENT:case Ie.CHILD:return i(f.parent,h)+n(">")+i(f.child,h);case Ie.ANCESTOR:case Ie.DESCENDANT:return i(f.ancestor,h)+" "+i(f.descendant,h);case Ie.COMPOUND_SPLIT:{var I=i(f.left,h),v=i(f.subject,h),L=i(f.right,h);return I+(I.length>0?" ":"")+v+L}case Ie.TRUE:return""}},i=function(f,h){return f.checks.reduce(function(p,d,g){return p+(h===f&&g===0?"$":"")+a(d,h)},"")},o="",s=0;s1&&s=0&&(r=r.replace("!",""),h=!0),r.indexOf("@")>=0&&(r=r.replace("@",""),f=!0),(i||s||f)&&(u=!i&&!o?"":""+e,l=""+n),f&&(e=u=u.toLowerCase(),n=l=l.toLowerCase()),r){case"*=":a=u.indexOf(l)>=0;break;case"$=":a=u.indexOf(l,u.length-l.length)>=0;break;case"^=":a=u.indexOf(l)===0;break;case"=":a=e===n;break;case">":p=!0,a=e>n;break;case">=":p=!0,a=e>=n;break;case"<":p=!0,a=e0;){var f=a.shift();e(f),i.add(f.id()),s&&n(a,i,f)}return t}function Xl(t,e,r){if(r.isParent())for(var n=r._private.children,a=0;a1&&arguments[1]!==void 0?arguments[1]:!0;return hs(this,t,e,Xl)};function _l(t,e,r){if(r.isChild()){var n=r._private.parent;e.has(n.id())||t.push(n)}}_n.forEachUp=function(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0;return hs(this,t,e,_l)};function km(t,e,r){_l(t,e,r),Xl(t,e,r)}_n.forEachUpAndDown=function(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0;return hs(this,t,e,km)};_n.ancestors=_n.parents;var Ia,Kl;Ia=Kl={data:ft.data({field:"data",bindingEvent:"data",allowBinding:!0,allowSetting:!0,settingEvent:"data",settingTriggersEvent:!0,triggerFnName:"trigger",allowGetting:!0,immutableKeys:{id:!0,source:!0,target:!0,parent:!0},updateStyle:!0}),removeData:ft.removeData({field:"data",event:"data",triggerFnName:"trigger",triggerEvent:!0,immutableKeys:{id:!0,source:!0,target:!0,parent:!0},updateStyle:!0}),scratch:ft.data({field:"scratch",bindingEvent:"scratch",allowBinding:!0,allowSetting:!0,settingEvent:"scratch",settingTriggersEvent:!0,triggerFnName:"trigger",allowGetting:!0,updateStyle:!0}),removeScratch:ft.removeData({field:"scratch",event:"scratch",triggerFnName:"trigger",triggerEvent:!0,updateStyle:!0}),rscratch:ft.data({field:"rscratch",allowBinding:!1,allowSetting:!0,settingTriggersEvent:!1,allowGetting:!0}),removeRscratch:ft.removeData({field:"rscratch",triggerEvent:!1}),id:function(){var e=this[0];if(e)return e._private.data.id}};Ia.attr=Ia.data;Ia.removeAttr=Ia.removeData;var Rm=Kl,Ui={};function Lo(t){return function(e){var r=this;if(e===void 0&&(e=!0),r.length!==0)if(r.isNode()&&!r.removed()){for(var n=0,a=r[0],i=a._private.edges,o=0;oe}),minIndegree:Pn("indegree",function(t,e){return te}),minOutdegree:Pn("outdegree",function(t,e){return te})});$e(Ui,{totalDegree:function(e){for(var r=0,n=this.nodes(),a=0;a0,p=h;h&&(f=f[0]);var d=p?f.position():{x:0,y:0};r!==void 0?l.position(e,r+d[e]):i!==void 0&&l.position({x:i.x+d.x,y:i.y+d.y})}else{var g=n.position(),m=s?n.parent():null,w=m&&m.length>0,b=w;w&&(m=m[0]);var T=b?m.position():{x:0,y:0};return i={x:g.x-T.x,y:g.y-T.y},e===void 0?i:i[e]}else if(!o)return;return this}};xr.modelPosition=xr.point=xr.position;xr.modelPositions=xr.points=xr.positions;xr.renderedPoint=xr.renderedPosition;xr.relativePoint=xr.relativePosition;var Pm=Zl,Yn,fn;Yn=fn={};fn.renderedBoundingBox=function(t){var e=this.boundingBox(t),r=this.cy(),n=r.zoom(),a=r.pan(),i=e.x1*n+a.x,o=e.x2*n+a.x,s=e.y1*n+a.y,u=e.y2*n+a.y;return{x1:i,x2:o,y1:s,y2:u,w:o-i,h:u-s}};fn.dirtyCompoundBoundsCache=function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!1,e=this.cy();return!e.styleEnabled()||!e.hasCompoundNodes()?this:(this.forEachUp(function(r){if(r.isParent()){var n=r._private;n.compoundBoundsClean=!1,n.bbCache=null,t||r.emitAndNotify("bounds")}}),this)};fn.updateCompoundBounds=function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!1,e=this.cy();if(!e.styleEnabled()||!e.hasCompoundNodes())return this;if(!t&&e.batching())return this;function r(o){if(!o.isParent())return;var s=o._private,u=o.children(),l=o.pstyle("compound-sizing-wrt-labels").value==="include",f={width:{val:o.pstyle("min-width").pfValue,left:o.pstyle("min-width-bias-left"),right:o.pstyle("min-width-bias-right")},height:{val:o.pstyle("min-height").pfValue,top:o.pstyle("min-height-bias-top"),bottom:o.pstyle("min-height-bias-bottom")}},h=u.boundingBox({includeLabels:l,includeOverlays:!1,useCache:!1}),p=s.position;(h.w===0||h.h===0)&&(h={w:o.pstyle("width").pfValue,h:o.pstyle("height").pfValue},h.x1=p.x-h.w/2,h.x2=p.x+h.w/2,h.y1=p.y-h.h/2,h.y2=p.y+h.h/2);function d(D,O,R){var k=0,z=0,B=O+R;return D>0&&B>0&&(k=O/B*D,z=R/B*D),{biasDiff:k,biasComplementDiff:z}}function g(D,O,R,k){if(R.units==="%")switch(k){case"width":return D>0?R.pfValue*D:0;case"height":return O>0?R.pfValue*O:0;case"average":return D>0&&O>0?R.pfValue*(D+O)/2:0;case"min":return D>0&&O>0?D>O?R.pfValue*O:R.pfValue*D:0;case"max":return D>0&&O>0?D>O?R.pfValue*D:R.pfValue*O:0;default:return 0}else return R.units==="px"?R.pfValue:0}var m=f.width.left.value;f.width.left.units==="px"&&f.width.val>0&&(m=m*100/f.width.val);var w=f.width.right.value;f.width.right.units==="px"&&f.width.val>0&&(w=w*100/f.width.val);var b=f.height.top.value;f.height.top.units==="px"&&f.height.val>0&&(b=b*100/f.height.val);var T=f.height.bottom.value;f.height.bottom.units==="px"&&f.height.val>0&&(T=T*100/f.height.val);var E=d(f.width.val-h.w,m,w),S=E.biasDiff,A=E.biasComplementDiff,I=d(f.height.val-h.h,b,T),v=I.biasDiff,L=I.biasComplementDiff;s.autoPadding=g(h.w,h.h,o.pstyle("padding"),o.pstyle("padding-relative-to").value),s.autoWidth=Math.max(h.w,f.width.val),p.x=(-S+h.x1+h.x2+A)/2,s.autoHeight=Math.max(h.h,f.height.val),p.y=(-v+h.y1+h.y2+L)/2}for(var n=0;ne.x2?a:e.x2,e.y1=ne.y2?i:e.y2,e.w=e.x2-e.x1,e.h=e.y2-e.y1)},bn=function(e,r){return r==null?e:wr(e,r.x1,r.y1,r.x2,r.y2)},pa=function(e,r,n){return Er(e,r,n)},fi=function(e,r,n){if(!r.cy().headless()){var a=r._private,i=a.rstyle,o=i.arrowWidth/2,s=r.pstyle(n+"-arrow-shape").value,u,l;if(s!=="none"){n==="source"?(u=i.srcX,l=i.srcY):n==="target"?(u=i.tgtX,l=i.tgtY):(u=i.midX,l=i.midY);var f=a.arrowBounds=a.arrowBounds||{},h=f[n]=f[n]||{};h.x1=u-o,h.y1=l-o,h.x2=u+o,h.y2=l+o,h.w=h.x2-h.x1,h.h=h.y2-h.y1,gi(h,1),wr(e,h.x1,h.y1,h.x2,h.y2)}}},Ao=function(e,r,n){if(!r.cy().headless()){var a;n?a=n+"-":a="";var i=r._private,o=i.rstyle,s=r.pstyle(a+"label").strValue;if(s){var u=r.pstyle("text-halign"),l=r.pstyle("text-valign"),f=pa(o,"labelWidth",n),h=pa(o,"labelHeight",n),p=pa(o,"labelX",n),d=pa(o,"labelY",n),g=r.pstyle(a+"text-margin-x").pfValue,m=r.pstyle(a+"text-margin-y").pfValue,w=r.isEdge(),b=r.pstyle(a+"text-rotation"),T=r.pstyle("text-outline-width").pfValue,E=r.pstyle("text-border-width").pfValue,S=E/2,A=r.pstyle("text-background-padding").pfValue,I=2,v=h,L=f,D=L/2,O=v/2,R,k,z,B;if(w)R=p-D,k=p+D,z=d-O,B=d+O;else{switch(u.value){case"left":R=p-L,k=p;break;case"center":R=p-D,k=p+D;break;case"right":R=p,k=p+L;break}switch(l.value){case"top":z=d-v,B=d;break;case"center":z=d-O,B=d+O;break;case"bottom":z=d,B=d+v;break}}R+=g-Math.max(T,S)-A-I,k+=g+Math.max(T,S)+A+I,z+=m-Math.max(T,S)-A-I,B+=m+Math.max(T,S)+A+I;var U=n||"main",H=i.labelBounds,V=H[U]=H[U]||{};V.x1=R,V.y1=z,V.x2=k,V.y2=B,V.w=k-R,V.h=B-z;var W=w&&b.strValue==="autorotate",X=b.pfValue!=null&&b.pfValue!==0;if(W||X){var j=W?pa(i.rstyle,"labelAngle",n):b.pfValue,K=Math.cos(j),J=Math.sin(j),ne=(R+k)/2,ie=(z+B)/2;if(!w){switch(u.value){case"left":ne=k;break;case"right":ne=R;break}switch(l.value){case"top":ie=B;break;case"bottom":ie=z;break}}var oe=function(He,De){return He=He-ne,De=De-ie,{x:He*K-De*J+ne,y:He*J+De*K+ie}},ue=oe(R,z),Z=oe(R,B),fe=oe(k,z),ce=oe(k,B);R=Math.min(ue.x,Z.x,fe.x,ce.x),k=Math.max(ue.x,Z.x,fe.x,ce.x),z=Math.min(ue.y,Z.y,fe.y,ce.y),B=Math.max(ue.y,Z.y,fe.y,ce.y)}var be=U+"Rot",Ce=H[be]=H[be]||{};Ce.x1=R,Ce.y1=z,Ce.x2=k,Ce.y2=B,Ce.w=k-R,Ce.h=B-z,wr(e,R,z,k,B),wr(i.labelBounds.all,R,z,k,B)}return e}},Bm=function(e,r){var n=e._private.cy,a=n.styleEnabled(),i=n.headless(),o=sr(),s=e._private,u=e.isNode(),l=e.isEdge(),f,h,p,d,g,m,w=s.rstyle,b=u&&a?e.pstyle("bounds-expansion").pfValue:[0],T=function(me){return me.pstyle("display").value!=="none"},E=!a||T(e)&&(!l||T(e.source())&&T(e.target()));if(E){var S=0,A=0;a&&r.includeOverlays&&(S=e.pstyle("overlay-opacity").value,S!==0&&(A=e.pstyle("overlay-padding").value));var I=0,v=0;a&&r.includeUnderlays&&(I=e.pstyle("underlay-opacity").value,I!==0&&(v=e.pstyle("underlay-padding").value));var L=Math.max(A,v),D=0,O=0;if(a&&(D=e.pstyle("width").pfValue,O=D/2),u&&r.includeNodes){var R=e.position();g=R.x,m=R.y;var k=e.outerWidth(),z=k/2,B=e.outerHeight(),U=B/2;f=g-z,h=g+z,p=m-U,d=m+U,wr(o,f,p,h,d)}else if(l&&r.includeEdges)if(a&&!i){var H=e.pstyle("curve-style").strValue;if(f=Math.min(w.srcX,w.midX,w.tgtX),h=Math.max(w.srcX,w.midX,w.tgtX),p=Math.min(w.srcY,w.midY,w.tgtY),d=Math.max(w.srcY,w.midY,w.tgtY),f-=O,h+=O,p-=O,d+=O,wr(o,f,p,h,d),H==="haystack"){var V=w.haystackPts;if(V&&V.length===2){if(f=V[0].x,p=V[0].y,h=V[1].x,d=V[1].y,f>h){var W=f;f=h,h=W}if(p>d){var X=p;p=d,d=X}wr(o,f-O,p-O,h+O,d+O)}}else if(H==="bezier"||H==="unbundled-bezier"||H==="segments"||H==="taxi"){var j;switch(H){case"bezier":case"unbundled-bezier":j=w.bezierPts;break;case"segments":case"taxi":j=w.linePts;break}if(j!=null)for(var K=0;Kh){var Z=f;f=h,h=Z}if(p>d){var fe=p;p=d,d=fe}f-=O,h+=O,p-=O,d+=O,wr(o,f,p,h,d)}if(a&&r.includeEdges&&l&&(fi(o,e,"mid-source"),fi(o,e,"mid-target"),fi(o,e,"source"),fi(o,e,"target")),a){var ce=e.pstyle("ghost").value==="yes";if(ce){var be=e.pstyle("ghost-offset-x").pfValue,Ce=e.pstyle("ghost-offset-y").pfValue;wr(o,o.x1+be,o.y1+Ce,o.x2+be,o.y2+Ce)}}var Fe=s.bodyBounds=s.bodyBounds||{};ou(Fe,o),Co(Fe,b),gi(Fe,1),a&&(f=o.x1,h=o.x2,p=o.y1,d=o.y2,wr(o,f-L,p-L,h+L,d+L));var He=s.overlayBounds=s.overlayBounds||{};ou(He,o),Co(He,b),gi(He,1);var De=s.labelBounds=s.labelBounds||{};De.all!=null?ly(De.all):De.all=sr(),a&&r.includeLabels&&(r.includeMainLabels&&Ao(o,e,null),l&&(r.includeSourceLabels&&Ao(o,e,"source"),r.includeTargetLabels&&Ao(o,e,"target")))}return o.x1=dr(o.x1),o.y1=dr(o.y1),o.x2=dr(o.x2),o.y2=dr(o.y2),o.w=dr(o.x2-o.x1),o.h=dr(o.y2-o.y1),o.w>0&&o.h>0&&E&&(Co(o,b),gi(o,1)),o},jl=function(e){var r=0,n=function(o){return(o?1:0)<0&&arguments[0]!==void 0?arguments[0]:Qm,e=arguments.length>1?arguments[1]:void 0,r=0;r=0;s--)o(s);return this};ln.removeAllListeners=function(){return this.removeListener("*")};ln.emit=ln.trigger=function(t,e,r){var n=this.listeners,a=n.length;return this.emitting++,dt(e)||(e=[e]),jm(this,function(i,o){r!=null&&(n=[{event:o.event,type:o.type,namespace:o.namespace,callback:r}],a=n.length);for(var s=function(f){var h=n[f];if(h.type===o.type&&(!h.namespace||h.namespace===o.namespace||h.namespace===Zm)&&i.eventMatches(i.context,h,o)){var p=[o];e!=null&&zp(p,e),i.beforeEmit(i.context,h,o),h.conf&&h.conf.one&&(i.listeners=i.listeners.filter(function(m){return m!==h}));var d=i.callbackContext(i.context,h,o),g=h.callback.apply(d,p);i.afterEmit(i.context,h,o),g===!1&&(o.stopPropagation(),o.preventDefault())}},u=0;u1&&!o){var s=this.length-1,u=this[s],l=u._private.data.id;this[s]=void 0,this[e]=u,i.set(l,{ele:u,index:e})}return this.length--,this},unmergeOne:function(e){e=e[0];var r=this._private,n=e._private.data.id,a=r.map,i=a.get(n);if(!i)return this;var o=i.index;return this.unmergeAt(o),this},unmerge:function(e){var r=this._private.cy;if(!e)return this;if(e&&Ge(e)){var n=e;e=r.mutableElements().filter(n)}for(var a=0;a=0;r--){var n=this[r];e(n)&&this.unmergeAt(r)}return this},map:function(e,r){for(var n=[],a=this,i=0;in&&(n=u,a=s)}return{value:n,ele:a}},min:function(e,r){for(var n=1/0,a,i=this,o=0;o=0&&i"u"?"undefined":Ot(Symbol))!=e&&Ot(Symbol.iterator)!=e;r&&(Si[Symbol.iterator]=function(){var n=this,a={value:void 0,done:!1},i=0,o=this.length;return vl({next:function(){return i1&&arguments[1]!==void 0?arguments[1]:!0,n=this[0],a=n.cy();if(a.styleEnabled()&&n){this.cleanStyle();var i=n._private.style[e];return i??(r?a.style().getDefaultProperty(e):null)}},numericStyle:function(e){var r=this[0];if(r.cy().styleEnabled()&&r){var n=r.pstyle(e);return n.pfValue!==void 0?n.pfValue:n.value}},numericStyleUnits:function(e){var r=this[0];if(r.cy().styleEnabled()&&r)return r.pstyle(e).units},renderedStyle:function(e){var r=this.cy();if(!r.styleEnabled())return this;var n=this[0];if(n)return r.style().getRenderedStyle(n,e)},style:function(e,r){var n=this.cy();if(!n.styleEnabled())return this;var a=!1,i=n.style();if(ot(e)){var o=e;i.applyBypass(this,o,a),this.emitAndNotify("style")}else if(Ge(e))if(r===void 0){var s=this[0];return s?i.getStylePropertyValue(s,e):void 0}else i.applyBypass(this,e,r,a),this.emitAndNotify("style");else if(e===void 0){var u=this[0];return u?i.getRawStyle(u):void 0}return this},removeStyle:function(e){var r=this.cy();if(!r.styleEnabled())return this;var n=!1,a=r.style(),i=this;if(e===void 0)for(var o=0;o0&&e.push(f[0]),e.push(s[0])}return this.spawn(e,!0).filter(t)},"neighborhood"),closedNeighborhood:function(e){return this.neighborhood().add(this).filter(e)},openNeighborhood:function(e){return this.neighborhood(e)}});Xt.neighbourhood=Xt.neighborhood;Xt.closedNeighbourhood=Xt.closedNeighborhood;Xt.openNeighbourhood=Xt.openNeighborhood;$e(Xt,{source:gr(function(e){var r=this[0],n;return r&&(n=r._private.source||r.cy().collection()),n&&e?n.filter(e):n},"source"),target:gr(function(e){var r=this[0],n;return r&&(n=r._private.target||r.cy().collection()),n&&e?n.filter(e):n},"target"),sources:ku({attr:"source"}),targets:ku({attr:"target"})});function ku(t){return function(r){for(var n=[],a=0;a0);return o},component:function(){var e=this[0];return e.cy().mutableElements().components(e)[0]}});Xt.componentsOf=Xt.components;var qt=function(e,r){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1,a=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1;if(e===void 0){Tt("A collection must have a reference to the core");return}var i=new Nr,o=!1;if(!r)r=[];else if(r.length>0&&ot(r[0])&&!qa(r[0])){o=!0;for(var s=[],u=new jn,l=0,f=r.length;l0&&arguments[0]!==void 0?arguments[0]:!0,e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0,r=this,n=r.cy(),a=n._private,i=[],o=[],s,u=0,l=r.length;u0){for(var X=s.length===r.length?r:new qt(n,s),j=0;j0&&arguments[0]!==void 0?arguments[0]:!0,e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0,r=this,n=[],a={},i=r._private.cy;function o(B){for(var U=B._private.edges,H=0;H0&&(t?R.emitAndNotify("remove"):e&&R.emit("remove"));for(var k=0;k0?k=B:R=B;while(Math.abs(z)>o&&++U=i?T(O,U):H===0?U:S(O,R,R+l)}var I=!1;function v(){I=!0,(t!==e||r!==n)&&E()}var L=function(R){return I||v(),t===e&&r===n?R:R===0?0:R===1?1:w(A(R),e,n)};L.getControlPoints=function(){return[{x:t,y:e},{x:r,y:n}]};var D="generateBezier("+[t,e,r,n]+")";return L.toString=function(){return D},L}/*! Runge-Kutta spring physics function generator. Adapted from Framer.js, copyright Koen Bok. MIT License: http://en.wikipedia.org/wiki/MIT_License */var l0=function(){function t(n){return-n.tension*n.x-n.friction*n.v}function e(n,a,i){var o={x:n.x+i.dx*a,v:n.v+i.dv*a,tension:n.tension,friction:n.friction};return{dx:o.v,dv:t(o)}}function r(n,a){var i={dx:n.v,dv:t(n)},o=e(n,a*.5,i),s=e(n,a*.5,o),u=e(n,a,s),l=1/6*(i.dx+2*(o.dx+s.dx)+u.dx),f=1/6*(i.dv+2*(o.dv+s.dv)+u.dv);return n.x=n.x+l*a,n.v=n.v+f*a,n}return function n(a,i,o){var s={x:-1,v:0,tension:null,friction:null},u=[0],l=0,f=1/1e4,h=16/1e3,p,d,g;for(a=parseFloat(a)||500,i=parseFloat(i)||20,o=o||null,s.tension=a,s.friction=i,p=o!==null,p?(l=n(a,i),d=l/o*h):d=h;g=r(g||s,d),u.push(1+g.x),l+=16,Math.abs(g.x)>f&&Math.abs(g.v)>f;);return p?function(m){return u[m*(u.length-1)|0]}:l}}(),pt=function(e,r,n,a){var i=u0(e,r,n,a);return function(o,s,u){return o+(s-o)*i(u)}},mi={linear:function(e,r,n){return e+(r-e)*n},ease:pt(.25,.1,.25,1),"ease-in":pt(.42,0,1,1),"ease-out":pt(0,0,.58,1),"ease-in-out":pt(.42,0,.58,1),"ease-in-sine":pt(.47,0,.745,.715),"ease-out-sine":pt(.39,.575,.565,1),"ease-in-out-sine":pt(.445,.05,.55,.95),"ease-in-quad":pt(.55,.085,.68,.53),"ease-out-quad":pt(.25,.46,.45,.94),"ease-in-out-quad":pt(.455,.03,.515,.955),"ease-in-cubic":pt(.55,.055,.675,.19),"ease-out-cubic":pt(.215,.61,.355,1),"ease-in-out-cubic":pt(.645,.045,.355,1),"ease-in-quart":pt(.895,.03,.685,.22),"ease-out-quart":pt(.165,.84,.44,1),"ease-in-out-quart":pt(.77,0,.175,1),"ease-in-quint":pt(.755,.05,.855,.06),"ease-out-quint":pt(.23,1,.32,1),"ease-in-out-quint":pt(.86,0,.07,1),"ease-in-expo":pt(.95,.05,.795,.035),"ease-out-expo":pt(.19,1,.22,1),"ease-in-out-expo":pt(1,0,0,1),"ease-in-circ":pt(.6,.04,.98,.335),"ease-out-circ":pt(.075,.82,.165,1),"ease-in-out-circ":pt(.785,.135,.15,.86),spring:function(e,r,n){if(n===0)return mi.linear;var a=l0(e,r,n);return function(i,o,s){return i+(o-i)*a(s)}},"cubic-bezier":pt};function Bu(t,e,r,n,a){if(n===1||e===r)return r;var i=a(e,r,n);return t==null||((t.roundValue||t.color)&&(i=Math.round(i)),t.min!==void 0&&(i=Math.max(i,t.min)),t.max!==void 0&&(i=Math.min(i,t.max))),i}function Fu(t,e){return t.pfValue!=null||t.value!=null?t.pfValue!=null&&(e==null||e.type.units!=="%")?t.pfValue:t.value:t}function Bn(t,e,r,n,a){var i=a!=null?a.type:null;r<0?r=0:r>1&&(r=1);var o=Fu(t,a),s=Fu(e,a);if(Ae(o)&&Ae(s))return Bu(i,o,s,r,n);if(dt(o)&&dt(s)){for(var u=[],l=0;l0?(d==="spring"&&g.push(o.duration),o.easingImpl=mi[d].apply(null,g)):o.easingImpl=mi[d]}var m=o.easingImpl,w;if(o.duration===0?w=1:w=(r-u)/o.duration,o.applying&&(w=o.progress),w<0?w=0:w>1&&(w=1),o.delay==null){var b=o.startPosition,T=o.position;if(T&&a&&!t.locked()){var E={};ma(b.x,T.x)&&(E.x=Bn(b.x,T.x,w,m)),ma(b.y,T.y)&&(E.y=Bn(b.y,T.y,w,m)),t.position(E)}var S=o.startPan,A=o.pan,I=i.pan,v=A!=null&&n;v&&(ma(S.x,A.x)&&(I.x=Bn(S.x,A.x,w,m)),ma(S.y,A.y)&&(I.y=Bn(S.y,A.y,w,m)),t.emit("pan"));var L=o.startZoom,D=o.zoom,O=D!=null&&n;O&&(ma(L,D)&&(i.zoom=Na(i.minZoom,Bn(L,D,w,m),i.maxZoom)),t.emit("zoom")),(v||O)&&t.emit("viewport");var R=o.style;if(R&&R.length>0&&a){for(var k=0;k=0;v--){var L=I[v];L()}I.splice(0,I.length)},T=d.length-1;T>=0;T--){var E=d[T],S=E._private;if(S.stopped){d.splice(T,1),S.hooked=!1,S.playing=!1,S.started=!1,b(S.frames);continue}!S.playing&&!S.applying||(S.playing&&S.applying&&(S.applying=!1),S.started||c0(f,E,t),f0(f,E,t,h),S.applying&&(S.applying=!1),b(S.frames),S.step!=null&&S.step(t),E.completed()&&(d.splice(T,1),S.hooked=!1,S.playing=!1,S.started=!1,b(S.completes)),m=!0)}return!h&&d.length===0&&g.length===0&&n.push(f),m}for(var i=!1,o=0;o0?e.notify("draw",r):e.notify("draw")),r.unmerge(n),e.emit("step")}var h0={animate:ft.animate(),animation:ft.animation(),animated:ft.animated(),clearQueue:ft.clearQueue(),delay:ft.delay(),delayAnimation:ft.delayAnimation(),stop:ft.stop(),addToAnimationPool:function(e){var r=this;r.styleEnabled()&&r._private.aniEles.merge(e)},stopAnimationLoop:function(){this._private.animationsRunning=!1},startAnimationLoop:function(){var e=this;if(e._private.animationsRunning=!0,!e.styleEnabled())return;function r(){e._private.animationsRunning&&Ti(function(i){zu(i,e),r()})}var n=e.renderer();n&&n.beforeRender?n.beforeRender(function(i,o){zu(o,e)},n.beforeRenderPriorities.animations):r()}},v0={qualifierCompare:function(e,r){return e==null||r==null?e==null&&r==null:e.sameText(r)},eventMatches:function(e,r,n){var a=r.qualifier;return a!=null?e!==n.target&&qa(n.target)&&a.matches(n.target):!0},addEventFields:function(e,r){r.cy=e,r.target=e},callbackContext:function(e,r,n){return r.qualifier!=null?n.target:e}},vi=function(e){return Ge(e)?new sn(e):e},ff={createEmitter:function(){var e=this._private;return e.emitter||(e.emitter=new Yi(v0,this)),this},emitter:function(){return this._private.emitter},on:function(e,r,n){return this.emitter().on(e,vi(r),n),this},removeListener:function(e,r,n){return this.emitter().removeListener(e,vi(r),n),this},removeAllListeners:function(){return this.emitter().removeAllListeners(),this},one:function(e,r,n){return this.emitter().one(e,vi(r),n),this},once:function(e,r,n){return this.emitter().one(e,vi(r),n),this},emit:function(e,r){return this.emitter().emit(e,r),this},emitAndNotify:function(e,r){return this.emit(e),this.notify(e,r),this}};ft.eventAliasesOn(ff);var qo={png:function(e){var r=this._private.renderer;return e=e||{},r.png(e)},jpg:function(e){var r=this._private.renderer;return e=e||{},e.bg=e.bg||"#fff",r.jpg(e)}};qo.jpeg=qo.jpg;var bi={layout:function(e){var r=this;if(e==null){Tt("Layout options must be specified to make a layout");return}if(e.name==null){Tt("A `name` must be specified to make a layout");return}var n=e.name,a=r.extension("layout",n);if(a==null){Tt("No such layout `"+n+"` found. Did you forget to import it and `cytoscape.use()` it?");return}var i;Ge(e.eles)?i=r.$(e.eles):i=e.eles!=null?e.eles:r.$();var o=new a($e({},e,{cy:r,eles:i}));return o}};bi.createLayout=bi.makeLayout=bi.layout;var d0={notify:function(e,r){var n=this._private;if(this.batching()){n.batchNotifications=n.batchNotifications||{};var a=n.batchNotifications[e]=n.batchNotifications[e]||this.collection();r!=null&&a.merge(r);return}if(n.notificationsEnabled){var i=this.renderer();this.destroyed()||!i||i.notify(e,r)}},notifications:function(e){var r=this._private;return e===void 0?r.notificationsEnabled:(r.notificationsEnabled=!!e,this)},noNotifications:function(e){this.notifications(!1),e(),this.notifications(!0)},batching:function(){return this._private.batchCount>0},startBatch:function(){var e=this._private;return e.batchCount==null&&(e.batchCount=0),e.batchCount===0&&(e.batchStyleEles=this.collection(),e.batchNotifications={}),e.batchCount++,this},endBatch:function(){var e=this._private;if(e.batchCount===0)return this;if(e.batchCount--,e.batchCount===0){e.batchStyleEles.updateStyle();var r=this.renderer();Object.keys(e.batchNotifications).forEach(function(n){var a=e.batchNotifications[n];a.empty()?r.notify(n):r.notify(n,a)})}return this},batch:function(e){return this.startBatch(),e(),this.endBatch(),this},batchData:function(e){var r=this;return this.batch(function(){for(var n=Object.keys(e),a=0;a0;)r.removeChild(r.childNodes[0]);e._private.renderer=null,e.mutableElements().forEach(function(n){var a=n._private;a.rscratch={},a.rstyle={},a.animation.current=[],a.animation.queue=[]})},onRender:function(e){return this.on("render",e)},offRender:function(e){return this.off("render",e)}};$o.invalidateDimensions=$o.resize;var wi={collection:function(e,r){return Ge(e)?this.$(e):ur(e)?e.collection():dt(e)?(r||(r={}),new qt(this,e,r.unique,r.removed)):new qt(this)},nodes:function(e){var r=this.$(function(n){return n.isNode()});return e?r.filter(e):r},edges:function(e){var r=this.$(function(n){return n.isEdge()});return e?r.filter(e):r},$:function(e){var r=this._private.elements;return e?r.filter(e):r.spawnSelf()},mutableElements:function(){return this._private.elements}};wi.elements=wi.filter=wi.$;var Kt={},Ca="t",p0="f";Kt.apply=function(t){for(var e=this,r=e._private,n=r.cy,a=n.collection(),i=0;i0;if(p||h&&d){var g=void 0;p&&d||p?g=l.properties:d&&(g=l.mappedProperties);for(var m=0;m1&&(S=1),s.color){var I=n.valueMin[0],v=n.valueMax[0],L=n.valueMin[1],D=n.valueMax[1],O=n.valueMin[2],R=n.valueMax[2],k=n.valueMin[3]==null?1:n.valueMin[3],z=n.valueMax[3]==null?1:n.valueMax[3],B=[Math.round(I+(v-I)*S),Math.round(L+(D-L)*S),Math.round(O+(R-O)*S),Math.round(k+(z-k)*S)];i={bypass:n.bypass,name:n.name,value:B,strValue:"rgb("+B[0]+", "+B[1]+", "+B[2]+")"}}else if(s.number){var U=n.valueMin+(n.valueMax-n.valueMin)*S;i=this.parse(n.name,U,n.bypass,p)}else return!1;if(!i)return m(),!1;i.mapping=n,n=i;break}case o.data:{for(var H=n.field.split("."),V=h.data,W=0;W0&&i>0){for(var s={},u=!1,l=0;l0?t.delayAnimation(o).play().promise().then(E):E()}).then(function(){return t.animation({style:s,duration:i,easing:t.pstyle("transition-timing-function").value,queue:!1}).play().promise()}).then(function(){r.removeBypasses(t,a),t.emitAndNotify("style"),n.transitioning=!1})}else n.transitioning&&(this.removeBypasses(t,a),t.emitAndNotify("style"),n.transitioning=!1)};Kt.checkTrigger=function(t,e,r,n,a,i){var o=this.properties[e],s=a(o);s!=null&&s(r,n)&&i(o)};Kt.checkZOrderTrigger=function(t,e,r,n){var a=this;this.checkTrigger(t,e,r,n,function(i){return i.triggersZOrder},function(){a._private.cy.notify("zorder",t)})};Kt.checkBoundsTrigger=function(t,e,r,n){this.checkTrigger(t,e,r,n,function(a){return a.triggersBounds},function(a){t.dirtyCompoundBoundsCache(),t.dirtyBoundingBoxCache(),a.triggersBoundsOfParallelBeziers&&(e==="curve-style"&&(r==="bezier"||n==="bezier")||e==="display"&&(r==="none"||n==="none"))&&t.parallelEdges().forEach(function(i){i.isBundledBezier()&&i.dirtyBoundingBoxCache()})})};Kt.checkTriggers=function(t,e,r,n){t.dirtyStyleCache(),this.checkZOrderTrigger(t,e,r,n),this.checkBoundsTrigger(t,e,r,n)};var Ua={};Ua.applyBypass=function(t,e,r,n){var a=this,i=[],o=!0;if(e==="*"||e==="**"){if(r!==void 0)for(var s=0;sa.length?n=n.substr(a.length):n=""}function u(){i.length>o.length?i=i.substr(o.length):i=""}for(;;){var l=n.match(/^\s*$/);if(l)break;var f=n.match(/^\s*((?:.|\s)+?)\s*\{((?:.|\s)+?)\}/);if(!f){lt("Halting stylesheet parsing: String stylesheet contains more to parse but no selector and block found in: "+n);break}a=f[0];var h=f[1];if(h!=="core"){var p=new sn(h);if(p.invalid){lt("Skipping parsing of block: Invalid selector found in string stylesheet: "+h),s();continue}}var d=f[2],g=!1;i=d;for(var m=[];;){var w=i.match(/^\s*$/);if(w)break;var b=i.match(/^\s*(.+?)\s*:\s*(.+?)(?:\s*;|\s*$)/);if(!b){lt("Skipping parsing of block: Invalid formatting of style property and value definitions found in:"+d),g=!0;break}o=b[0];var T=b[1],E=b[2],S=e.properties[T];if(!S){lt("Skipping property: Invalid property name in: "+o),u();continue}var A=r.parse(T,E);if(!A){lt("Skipping property: Invalid property definition in: "+o),u();continue}m.push({name:T,val:E}),u()}if(g){s();break}r.selector(h);for(var I=0;I=7&&e[0]==="d"&&(f=new RegExp(s.data.regex).exec(e))){if(r)return!1;var p=s.data;return{name:t,value:f,strValue:""+e,mapped:p,field:f[1],bypass:r}}else if(e.length>=10&&e[0]==="m"&&(h=new RegExp(s.mapData.regex).exec(e))){if(r||l.multiple)return!1;var d=s.mapData;if(!(l.color||l.number))return!1;var g=this.parse(t,h[4]);if(!g||g.mapped)return!1;var m=this.parse(t,h[5]);if(!m||m.mapped)return!1;if(g.pfValue===m.pfValue||g.strValue===m.strValue)return lt("`"+t+": "+e+"` is not a valid mapper because the output range is zero; converting to `"+t+": "+g.strValue+"`"),this.parse(t,g.strValue);if(l.color){var w=g.value,b=m.value,T=w[0]===b[0]&&w[1]===b[1]&&w[2]===b[2]&&(w[3]===b[3]||(w[3]==null||w[3]===1)&&(b[3]==null||b[3]===1));if(T)return!1}return{name:t,value:h,strValue:""+e,mapped:d,field:h[1],fieldMin:parseFloat(h[2]),fieldMax:parseFloat(h[3]),valueMin:g.value,valueMax:m.value,bypass:r}}}if(l.multiple&&n!=="multiple"){var E;if(u?E=e.split(/\s+/):dt(e)?E=e:E=[e],l.evenMultiple&&E.length%2!==0)return null;for(var S=[],A=[],I=[],v="",L=!1,D=0;D0?" ":"")+O.strValue}return l.validate&&!l.validate(S,A)?null:l.singleEnum&&L?S.length===1&&Ge(S[0])?{name:t,value:S[0],strValue:S[0],bypass:r}:null:{name:t,value:S,pfValue:I,strValue:v,bypass:r,units:A}}var R=function(){for(var ce=0;cel.max||l.strictMax&&e===l.max))return null;var H={name:t,value:e,strValue:""+e+(k||""),units:k,bypass:r};return l.unitless||k!=="px"&&k!=="em"?H.pfValue=e:H.pfValue=k==="px"||!k?e:this.getEmSizeInPixels()*e,(k==="ms"||k==="s")&&(H.pfValue=k==="ms"?e:1e3*e),(k==="deg"||k==="rad")&&(H.pfValue=k==="rad"?e:iy(e)),k==="%"&&(H.pfValue=e/100),H}else if(l.propList){var V=[],W=""+e;if(W!=="none"){for(var X=W.split(/\s*,\s*|\s+/),j=0;j0&&s>0&&!isNaN(n.w)&&!isNaN(n.h)&&n.w>0&&n.h>0){u=Math.min((o-2*r)/n.w,(s-2*r)/n.h),u=u>this._private.maxZoom?this._private.maxZoom:u,u=u=n.minZoom&&(n.maxZoom=r),this},minZoom:function(e){return e===void 0?this._private.minZoom:this.zoomRange({min:e})},maxZoom:function(e){return e===void 0?this._private.maxZoom:this.zoomRange({max:e})},getZoomedViewport:function(e){var r=this._private,n=r.pan,a=r.zoom,i,o,s=!1;if(r.zoomingEnabled||(s=!0),Ae(e)?o=e:ot(e)&&(o=e.level,e.position!=null?i=$i(e.position,a,n):e.renderedPosition!=null&&(i=e.renderedPosition),i!=null&&!r.panningEnabled&&(s=!0)),o=o>r.maxZoom?r.maxZoom:o,o=or.maxZoom||!r.zoomingEnabled?o=!0:(r.zoom=u,i.push("zoom"))}if(a&&(!o||!e.cancelOnFailedZoom)&&r.panningEnabled){var l=e.pan;Ae(l.x)&&(r.pan.x=l.x,s=!1),Ae(l.y)&&(r.pan.y=l.y,s=!1),s||i.push("pan")}return i.length>0&&(i.push("viewport"),this.emit(i.join(" ")),this.notify("viewport")),this},center:function(e){var r=this.getCenterPan(e);return r&&(this._private.pan=r,this.emit("pan viewport"),this.notify("viewport")),this},getCenterPan:function(e,r){if(this._private.panningEnabled){if(Ge(e)){var n=e;e=this.mutableElements().filter(n)}else ur(e)||(e=this.mutableElements());if(e.length!==0){var a=e.boundingBox(),i=this.width(),o=this.height();r=r===void 0?this._private.zoom:r;var s={x:(i-r*(a.x1+a.x2))/2,y:(o-r*(a.y1+a.y2))/2};return s}}},reset:function(){return!this._private.panningEnabled||!this._private.zoomingEnabled?this:(this.viewport({pan:{x:0,y:0},zoom:1}),this)},invalidateSize:function(){this._private.sizeCache=null},size:function(){var e=this._private,r=e.container,n=this;return e.sizeCache=e.sizeCache||(r?function(){var a=n.window().getComputedStyle(r),i=function(s){return parseFloat(a.getPropertyValue(s))};return{width:r.clientWidth-i("padding-left")-i("padding-right"),height:r.clientHeight-i("padding-top")-i("padding-bottom")}}():{width:1,height:1})},width:function(){return this.size().width},height:function(){return this.size().height},extent:function(){var e=this._private.pan,r=this._private.zoom,n=this.renderedExtent(),a={x1:(n.x1-e.x)/r,x2:(n.x2-e.x)/r,y1:(n.y1-e.y)/r,y2:(n.y2-e.y)/r};return a.w=a.x2-a.x1,a.h=a.y2-a.y1,a},renderedExtent:function(){var e=this.width(),r=this.height();return{x1:0,y1:0,x2:e,y2:r,w:e,h:r}},multiClickDebounceTime:function(e){if(e)this._private.multiClickDebounceTime=e;else return this._private.multiClickDebounceTime;return this}};Cn.centre=Cn.center;Cn.autolockNodes=Cn.autolock;Cn.autoungrabifyNodes=Cn.autoungrabify;var Ra={data:ft.data({field:"data",bindingEvent:"data",allowBinding:!0,allowSetting:!0,settingEvent:"data",settingTriggersEvent:!0,triggerFnName:"trigger",allowGetting:!0,updateStyle:!0}),removeData:ft.removeData({field:"data",event:"data",triggerFnName:"trigger",triggerEvent:!0,updateStyle:!0}),scratch:ft.data({field:"scratch",bindingEvent:"scratch",allowBinding:!0,allowSetting:!0,settingEvent:"scratch",settingTriggersEvent:!0,triggerFnName:"trigger",allowGetting:!0,updateStyle:!0}),removeScratch:ft.removeData({field:"scratch",event:"scratch",triggerFnName:"trigger",triggerEvent:!0,updateStyle:!0})};Ra.attr=Ra.data;Ra.removeAttr=Ra.removeData;var Pa=function(e){var r=this;e=$e({},e);var n=e.container;n&&!xi(n)&&xi(n[0])&&(n=n[0]);var a=n?n._cyreg:null;a=a||{},a&&a.cy&&(a.cy.destroy(),a={});var i=a.readies=a.readies||[];n&&(n._cyreg=a),a.cy=r;var o=Mt!==void 0&&n!==void 0&&!e.headless,s=e;s.layout=$e({name:o?"grid":"null"},s.layout),s.renderer=$e({name:o?"canvas":"null"},s.renderer);var u=function(g,m,w){return m!==void 0?m:w!==void 0?w:g},l=this._private={container:n,ready:!1,options:s,elements:new qt(this),listeners:[],aniEles:new qt(this),data:s.data||{},scratch:{},layout:null,renderer:null,destroyed:!1,notificationsEnabled:!0,minZoom:1e-50,maxZoom:1e50,zoomingEnabled:u(!0,s.zoomingEnabled),userZoomingEnabled:u(!0,s.userZoomingEnabled),panningEnabled:u(!0,s.panningEnabled),userPanningEnabled:u(!0,s.userPanningEnabled),boxSelectionEnabled:u(!0,s.boxSelectionEnabled),autolock:u(!1,s.autolock,s.autolockNodes),autoungrabify:u(!1,s.autoungrabify,s.autoungrabifyNodes),autounselectify:u(!1,s.autounselectify),styleEnabled:s.styleEnabled===void 0?o:s.styleEnabled,zoom:Ae(s.zoom)?s.zoom:1,pan:{x:ot(s.pan)&&Ae(s.pan.x)?s.pan.x:0,y:ot(s.pan)&&Ae(s.pan.y)?s.pan.y:0},animation:{current:[],queue:[]},hasCompoundNodes:!1,multiClickDebounceTime:u(250,s.multiClickDebounceTime)};this.createEmitter(),this.selectionType(s.selectionType),this.zoomRange({min:s.minZoom,max:s.maxZoom});var f=function(g,m){var w=g.some(dp);if(w)return Jn.all(g).then(m);m(g)};l.styleEnabled&&r.setStyle([]);var h=$e({},s,s.renderer);r.initRenderer(h);var p=function(g,m,w){r.notifications(!1);var b=r.mutableElements();b.length>0&&b.remove(),g!=null&&(ot(g)||dt(g))&&r.add(g),r.one("layoutready",function(E){r.notifications(!0),r.emit(E),r.one("load",m),r.emitAndNotify("load")}).one("layoutstop",function(){r.one("done",w),r.emit("done")});var T=$e({},r._private.options.layout);T.eles=r.elements(),r.layout(T).run()};f([s.style,s.elements],function(d){var g=d[0],m=d[1];l.styleEnabled&&r.style().append(g),p(m,function(){r.startAnimationLoop(),l.ready=!0,Et(s.ready)&&r.on("ready",s.ready);for(var w=0;w0,u=sr(e.boundingBox?e.boundingBox:{x1:0,y1:0,w:r.width(),h:r.height()}),l;if(ur(e.roots))l=e.roots;else if(dt(e.roots)){for(var f=[],h=0;h0;){var U=B(),H=O(U,k);if(H)U.outgoers().filter(function(De){return De.isNode()&&n.has(De)}).forEach(z);else if(H===null){lt("Detected double maximal shift for node `"+U.id()+"`. Bailing maximal adjustment due to cycle. Use `options.maximal: true` only on DAGs.");break}}}D();var V=0;if(e.avoidOverlap)for(var W=0;W0&&b[0].length<=3?Me/2:0),F=2*Math.PI/b[xe].length*pe;return xe===0&&b[0].length===1&&(ye=1),{x:Ce.x+ye*Math.cos(F),y:Ce.y+ye*Math.sin(F)}}else{var ze={x:Ce.x+(pe+1-(Se+1)/2)*ke,y:(xe+1)*Re};return ze}};return n.nodes().layoutPositions(this,e,He),this};var E0={fit:!0,padding:30,boundingBox:void 0,avoidOverlap:!0,nodeDimensionsIncludeLabels:!1,spacingFactor:void 0,radius:void 0,startAngle:3/2*Math.PI,sweep:void 0,clockwise:!0,sort:void 0,animate:!1,animationDuration:500,animationEasing:void 0,animateFilter:function(e,r){return!0},ready:void 0,stop:void 0,transform:function(e,r){return r}};function hf(t){this.options=$e({},E0,t)}hf.prototype.run=function(){var t=this.options,e=t,r=t.cy,n=e.eles,a=e.counterclockwise!==void 0?!e.counterclockwise:e.clockwise,i=n.nodes().not(":parent");e.sort&&(i=i.sort(e.sort));for(var o=sr(e.boundingBox?e.boundingBox:{x1:0,y1:0,w:r.width(),h:r.height()}),s={x:o.x1+o.w/2,y:o.y1+o.h/2},u=e.sweep===void 0?2*Math.PI-2*Math.PI/i.length:e.sweep,l=u/Math.max(1,i.length-1),f,h=0,p=0;p1&&e.avoidOverlap){h*=1.75;var b=Math.cos(l)-Math.cos(0),T=Math.sin(l)-Math.sin(0),E=Math.sqrt(h*h/(b*b+T*T));f=Math.max(E,f)}var S=function(I,v){var L=e.startAngle+v*l*(a?1:-1),D=f*Math.cos(L),O=f*Math.sin(L),R={x:s.x+D,y:s.y+O};return R};return n.nodes().layoutPositions(this,e,S),this};var x0={fit:!0,padding:30,startAngle:3/2*Math.PI,sweep:void 0,clockwise:!0,equidistant:!1,minNodeSpacing:10,boundingBox:void 0,avoidOverlap:!0,nodeDimensionsIncludeLabels:!1,height:void 0,width:void 0,spacingFactor:void 0,concentric:function(e){return e.degree()},levelWidth:function(e){return e.maxDegree()/4},animate:!1,animationDuration:500,animationEasing:void 0,animateFilter:function(e,r){return!0},ready:void 0,stop:void 0,transform:function(e,r){return r}};function vf(t){this.options=$e({},x0,t)}vf.prototype.run=function(){for(var t=this.options,e=t,r=e.counterclockwise!==void 0?!e.counterclockwise:e.clockwise,n=t.cy,a=e.eles,i=a.nodes().not(":parent"),o=sr(e.boundingBox?e.boundingBox:{x1:0,y1:0,w:n.width(),h:n.height()}),s={x:o.x1+o.w/2,y:o.y1+o.h/2},u=[],l=0,f=0;f0){var A=Math.abs(T[0].value-S.value);A>=w&&(T=[],b.push(T))}T.push(S)}var I=l+e.minNodeSpacing;if(!e.avoidOverlap){var v=b.length>0&&b[0].length>1,L=Math.min(o.w,o.h)/2-I,D=L/(b.length+v?1:0);I=Math.min(I,D)}for(var O=0,R=0;R1&&e.avoidOverlap){var U=Math.cos(B)-Math.cos(0),H=Math.sin(B)-Math.sin(0),V=Math.sqrt(I*I/(U*U+H*H));O=Math.max(V,O)}k.r=O,O+=I}if(e.equidistant){for(var W=0,X=0,j=0;j=t.numIter||(N0(n,t),n.temperature=n.temperature*t.coolingFactor,n.temperature=t.animationThreshold&&i(),Ti(h)}};f()}else{for(;l;)l=o(u),u++;qu(n,t),s()}return this};Zi.prototype.stop=function(){return this.stopped=!0,this.thread&&this.thread.stop(),this.emit("layoutstop"),this};Zi.prototype.destroy=function(){return this.thread&&this.thread.stop(),this};var C0=function(e,r,n){for(var a=n.eles.edges(),i=n.eles.nodes(),o=sr(n.boundingBox?n.boundingBox:{x1:0,y1:0,w:e.width(),h:e.height()}),s={isCompound:e.hasCompoundNodes(),layoutNodes:[],idToIndex:{},nodeSize:i.size(),graphSet:[],indexToGraph:[],layoutEdges:[],edgeSize:a.size(),temperature:n.initialTemp,clientWidth:o.w,clientHeight:o.h,boundingBox:o},u=n.eles.components(),l={},f=0;f0){s.graphSet.push(L);for(var f=0;fa.count?0:a.graph},S0=function t(e,r,n,a){var i=a.graphSet[n];if(-10)var h=a.nodeOverlap*f,p=Math.sqrt(s*s+u*u),d=h*s/p,g=h*u/p;else var m=Ai(e,s,u),w=Ai(r,-1*s,-1*u),b=w.x-m.x,T=w.y-m.y,E=b*b+T*T,p=Math.sqrt(E),h=(e.nodeRepulsion+r.nodeRepulsion)/E,d=h*b/p,g=h*T/p;e.isLocked||(e.offsetX-=d,e.offsetY-=g),r.isLocked||(r.offsetX+=d,r.offsetY+=g)}},k0=function(e,r,n,a){if(n>0)var i=e.maxX-r.minX;else var i=r.maxX-e.minX;if(a>0)var o=e.maxY-r.minY;else var o=r.maxY-e.minY;return i>=0&&o>=0?Math.sqrt(i*i+o*o):0},Ai=function(e,r,n){var a=e.positionX,i=e.positionY,o=e.height||1,s=e.width||1,u=n/r,l=o/s,f={};return r===0&&0n?(f.x=a,f.y=i+o/2,f):0r&&-1*l<=u&&u<=l?(f.x=a-s/2,f.y=i-s*n/2/r,f):0=l)?(f.x=a+o*r/2/n,f.y=i+o/2,f):(0>n&&(u<=-1*l||u>=l)&&(f.x=a-o*r/2/n,f.y=i-o/2),f)},R0=function(e,r){for(var n=0;nn){var w=r.gravity*d/m,b=r.gravity*g/m;p.offsetX+=w,p.offsetY+=b}}}}},B0=function(e,r){var n=[],a=0,i=-1;for(n.push.apply(n,e.graphSet[0]),i+=e.graphSet[0].length;a<=i;){var o=n[a++],s=e.idToIndex[o],u=e.layoutNodes[s],l=u.children;if(0n)var i={x:n*e/a,y:n*r/a};else var i={x:e,y:r};return i},G0=function t(e,r){var n=e.parentId;if(n!=null){var a=r.layoutNodes[r.idToIndex[n]],i=!1;if((a.maxX==null||e.maxX+a.padRight>a.maxX)&&(a.maxX=e.maxX+a.padRight,i=!0),(a.minX==null||e.minX-a.padLefta.maxY)&&(a.maxY=e.maxY+a.padBottom,i=!0),(a.minY==null||e.minY-a.padTopb&&(g+=w+r.componentSpacing,d=0,m=0,w=0)}}},H0={fit:!0,padding:30,boundingBox:void 0,avoidOverlap:!0,avoidOverlapPadding:10,nodeDimensionsIncludeLabels:!1,spacingFactor:void 0,condense:!1,rows:void 0,cols:void 0,position:function(e){},sort:void 0,animate:!1,animationDuration:500,animationEasing:void 0,animateFilter:function(e,r){return!0},ready:void 0,stop:void 0,transform:function(e,r){return r}};function gf(t){this.options=$e({},H0,t)}gf.prototype.run=function(){var t=this.options,e=t,r=t.cy,n=e.eles,a=n.nodes().not(":parent");e.sort&&(a=a.sort(e.sort));var i=sr(e.boundingBox?e.boundingBox:{x1:0,y1:0,w:r.width(),h:r.height()});if(i.h===0||i.w===0)n.nodes().layoutPositions(this,e,function(ne){return{x:i.x1,y:i.y1}});else{var o=a.size(),s=Math.sqrt(o*i.h/i.w),u=Math.round(s),l=Math.round(i.w/i.h*s),f=function(ie){if(ie==null)return Math.min(u,l);var oe=Math.min(u,l);oe==u?u=ie:l=ie},h=function(ie){if(ie==null)return Math.max(u,l);var oe=Math.max(u,l);oe==u?u=ie:l=ie},p=e.rows,d=e.cols!=null?e.cols:e.columns;if(p!=null&&d!=null)u=p,l=d;else if(p!=null&&d==null)u=p,l=Math.ceil(o/u);else if(p==null&&d!=null)l=d,u=Math.ceil(o/l);else if(l*u>o){var g=f(),m=h();(g-1)*m>=o?f(g-1):(m-1)*g>=o&&h(m-1)}else for(;l*u=o?h(b+1):f(w+1)}var T=i.w/l,E=i.h/u;if(e.condense&&(T=0,E=0),e.avoidOverlap)for(var S=0;S=l&&(U=0,B++)},V={},W=0;W(U=my(t,e,H[V],H[V+1],H[V+2],H[V+3])))return w(v,U),!0}else if(D.edgeType==="bezier"||D.edgeType==="multibezier"||D.edgeType==="self"||D.edgeType==="compound"){for(var H=D.allpts,V=0;V+5(U=yy(t,e,H[V],H[V+1],H[V+2],H[V+3],H[V+4],H[V+5])))return w(v,U),!0}for(var W=W||L.source,X=X||L.target,j=a.getArrowWidth(O,R),K=[{name:"source",x:D.arrowStartX,y:D.arrowStartY,angle:D.srcArrowAngle},{name:"target",x:D.arrowEndX,y:D.arrowEndY,angle:D.tgtArrowAngle},{name:"mid-source",x:D.midX,y:D.midY,angle:D.midsrcArrowAngle},{name:"mid-target",x:D.midX,y:D.midY,angle:D.midtgtArrowAngle}],V=0;V0&&(b(W),b(X))}function E(v,L,D){return Er(v,L,D)}function S(v,L){var D=v._private,O=p,R;L?R=L+"-":R="",v.boundingBox();var k=D.labelBounds[L||"main"],z=v.pstyle(R+"label").value,B=v.pstyle("text-events").strValue==="yes";if(!(!B||!z)){var U=E(D.rscratch,"labelX",L),H=E(D.rscratch,"labelY",L),V=E(D.rscratch,"labelAngle",L),W=v.pstyle(R+"text-margin-x").pfValue,X=v.pstyle(R+"text-margin-y").pfValue,j=k.x1-O-W,K=k.x2+O-W,J=k.y1-O-X,ne=k.y2+O-X;if(V){var ie=Math.cos(V),oe=Math.sin(V),ue=function(He,De){return He=He-U,De=De-H,{x:He*ie-De*oe+U,y:He*oe+De*ie+H}},Z=ue(j,J),fe=ue(j,ne),ce=ue(K,J),be=ue(K,ne),Ce=[Z.x+W,Z.y+X,ce.x+W,ce.y+X,be.x+W,be.y+X,fe.x+W,fe.y+X];if(or(t,e,Ce))return w(v),!0}else if(Wn(k,t,e))return w(v),!0}}for(var A=o.length-1;A>=0;A--){var I=o[A];I.isNode()?b(I)||S(I):T(I)||S(I)||S(I,"source")||S(I,"target")}return s};Ln.getAllInBox=function(t,e,r,n){var a=this.getCachedZSortedEles().interactive,i=[],o=Math.min(t,r),s=Math.max(t,r),u=Math.min(e,n),l=Math.max(e,n);t=o,r=s,e=u,n=l;for(var f=sr({x1:t,y1:e,x2:r,y2:n}),h=0;h0?Math.max(Ee-Pe,0):Math.min(Ee+Pe,0)},z=k(O,L),B=k(R,D),U=!1;T===l?b=Math.abs(z)>Math.abs(B)?a:n:T===u||T===s?(b=n,U=!0):(T===i||T===o)&&(b=a,U=!0);var H=b===n,V=H?B:z,W=H?R:O,X=Nl(W),j=!1;!(U&&(S||I))&&(T===s&&W<0||T===u&&W>0||T===i&&W>0||T===o&&W<0)&&(X*=-1,V=X*Math.abs(V),j=!0);var K;if(S){var J=A<0?1+A:A;K=J*V}else{var ne=A<0?V:0;K=ne+A*X}var ie=function(Ee){return Math.abs(Ee)=Math.abs(V)},oe=ie(K),ue=ie(Math.abs(V)-Math.abs(K)),Z=oe||ue;if(Z&&!j)if(H){var fe=Math.abs(W)<=p/2,ce=Math.abs(O)<=d/2;if(fe){var be=(f.x1+f.x2)/2,Ce=f.y1,Fe=f.y2;r.segpts=[be,Ce,be,Fe]}else if(ce){var He=(f.y1+f.y2)/2,De=f.x1,le=f.x2;r.segpts=[De,He,le,He]}else r.segpts=[f.x1,f.y2]}else{var me=Math.abs(W)<=h/2,xe=Math.abs(R)<=g/2;if(me){var pe=(f.y1+f.y2)/2,Se=f.x1,ke=f.x2;r.segpts=[Se,pe,ke,pe]}else if(xe){var Re=(f.x1+f.x2)/2,Me=f.y1,ze=f.y2;r.segpts=[Re,Me,Re,ze]}else r.segpts=[f.x2,f.y1]}else if(H){var ye=f.y1+K+(w?p/2*X:0),F=f.x1,ee=f.x2;r.segpts=[F,ye,ee,ye]}else{var we=f.x1+K+(w?h/2*X:0),de=f.y1,ge=f.y2;r.segpts=[we,de,we,ge]}};Zt.tryToCorrectInvalidPoints=function(t,e){var r=t._private.rscratch;if(r.edgeType==="bezier"){var n=e.srcPos,a=e.tgtPos,i=e.srcW,o=e.srcH,s=e.tgtW,u=e.tgtH,l=e.srcShape,f=e.tgtShape,h=!Ae(r.startX)||!Ae(r.startY),p=!Ae(r.arrowStartX)||!Ae(r.arrowStartY),d=!Ae(r.endX)||!Ae(r.endY),g=!Ae(r.arrowEndX)||!Ae(r.arrowEndY),m=3,w=this.getArrowWidth(t.pstyle("width").pfValue,t.pstyle("arrow-scale").value)*this.arrowShapeWidth,b=m*w,T=xn({x:r.ctrlpts[0],y:r.ctrlpts[1]},{x:r.startX,y:r.startY}),E=TB.poolIndex()){var U=z;z=B,B=U}var H=D.srcPos=z.position(),V=D.tgtPos=B.position(),W=D.srcW=z.outerWidth(),X=D.srcH=z.outerHeight(),j=D.tgtW=B.outerWidth(),K=D.tgtH=B.outerHeight(),J=D.srcShape=r.nodeShapes[e.getNodeShape(z)],ne=D.tgtShape=r.nodeShapes[e.getNodeShape(B)];D.dirCounts={north:0,west:0,south:0,east:0,northwest:0,southwest:0,northeast:0,southeast:0};for(var ie=0;ie0){var fe=i,ce=mn(fe,Hn(r)),be=mn(fe,Hn(Z)),Ce=ce;if(be2){var Fe=mn(fe,{x:Z[2],y:Z[3]});Fe0){var F=o,ee=mn(F,Hn(r)),we=mn(F,Hn(ye)),de=ee;if(we2){var ge=mn(F,{x:ye[2],y:ye[3]});ge=g||v){w={cp:S,segment:I};break}}if(w)break}var L=w.cp,D=w.segment,O=(g-b)/D.length,R=D.t1-D.t0,k=d?D.t0+R*O:D.t1-R*O;k=Na(0,k,1),e=$n(L.p0,L.p1,L.p2,k),p=W0(L.p0,L.p1,L.p2,k);break}case"straight":case"segments":case"haystack":{for(var z=0,B,U,H,V,W=n.allpts.length,X=0;X+3=g));X+=2);var j=g-U,K=j/B;K=Na(0,K,1),e=sy(H,V,K),p=Ef(H,V);break}}o("labelX",h,e.x),o("labelY",h,e.y),o("labelAutoAngle",h,p)}};l("source"),l("target"),this.applyLabelDimensions(t)}};Ir.applyLabelDimensions=function(t){this.applyPrefixedLabelDimensions(t),t.isEdge()&&(this.applyPrefixedLabelDimensions(t,"source"),this.applyPrefixedLabelDimensions(t,"target"))};Ir.applyPrefixedLabelDimensions=function(t,e){var r=t._private,n=this.getLabelText(t,e),a=this.calculateLabelDimensions(t,n),i=t.pstyle("line-height").pfValue,o=t.pstyle("text-wrap").strValue,s=Er(r.rscratch,"labelWrapCachedLines",e)||[],u=o!=="wrap"?1:Math.max(s.length,1),l=a.height/u,f=l*i,h=a.width,p=a.height+(u-1)*(i-1)*l;Jr(r.rstyle,"labelWidth",e,h),Jr(r.rscratch,"labelWidth",e,h),Jr(r.rstyle,"labelHeight",e,p),Jr(r.rscratch,"labelHeight",e,p),Jr(r.rscratch,"labelLineHeight",e,f)};Ir.getLabelText=function(t,e){var r=t._private,n=e?e+"-":"",a=t.pstyle(n+"label").strValue,i=t.pstyle("text-transform").value,o=function(j,K){return K?(Jr(r.rscratch,j,e,K),K):Er(r.rscratch,j,e)};if(!a)return"";i=="none"||(i=="uppercase"?a=a.toUpperCase():i=="lowercase"&&(a=a.toLowerCase()));var s=t.pstyle("text-wrap").value;if(s==="wrap"){var u=o("labelKey");if(u!=null&&o("labelWrapKey")===u)return o("labelWrapCachedText");for(var l="​",f=a.split(` -`),h=t.pstyle("text-max-width").pfValue,p=t.pstyle("text-overflow-wrap").value,d=p==="anywhere",g=[],m=/[\s\u200b]+/,w=d?"":" ",b=0;bh){for(var I=T.split(m),v="",L=0;Lz)break;B+=a[V],V===a.length-1&&(H=!0)}return H||(B+=U),B}return a};Ir.getLabelJustification=function(t){var e=t.pstyle("text-justification").strValue,r=t.pstyle("text-halign").strValue;if(e==="auto")if(t.isNode())switch(r){case"left":return"right";case"right":return"left";default:return"center"}else return"center";else return e};Ir.calculateLabelDimensions=function(t,e){var r=this,n=En(e,t._private.labelDimsKey),a=r.labelDimCache||(r.labelDimCache=[]),i=a[n];if(i!=null)return i;var o=0,s=t.pstyle("font-style").strValue,u=t.pstyle("font-size").pfValue,l=t.pstyle("font-family").strValue,f=t.pstyle("font-weight").strValue,h=this.labelCalcCanvas,p=this.labelCalcCanvasContext;if(!h){h=this.labelCalcCanvas=document.createElement("canvas"),p=this.labelCalcCanvasContext=h.getContext("2d");var d=h.style;d.position="absolute",d.left="-9999px",d.top="-9999px",d.zIndex="-1",d.visibility="hidden",d.pointerEvents="none"}p.font="".concat(s," ").concat(f," ").concat(u,"px ").concat(l);for(var g=0,m=0,w=e.split(` -`),b=0;b1&&arguments[1]!==void 0?arguments[1]:!0;if(e.merge(o),s)for(var u=0;u=t.desktopTapThreshold2}var wt=a(F);Lt&&(t.hoverData.tapholdCancelled=!0);var fr=function(){var cr=t.hoverData.dragDelta=t.hoverData.dragDelta||[];cr.length===0?(cr.push(Ke[0]),cr.push(Ke[1])):(cr[0]+=Ke[0],cr[1]+=Ke[1])};we=!0,n(We,["mousemove","vmousemove","tapdrag"],F,{x:Ee[0],y:Ee[1]});var Ur=function(){t.data.bgActivePosistion=void 0,t.hoverData.selecting||de.emit({originalEvent:F,type:"boxstart",position:{x:Ee[0],y:Ee[1]}}),je[4]=1,t.hoverData.selecting=!0,t.redrawHint("select",!0),t.redraw()};if(t.hoverData.which===3){if(Lt){var Tr={originalEvent:F,type:"cxtdrag",position:{x:Ee[0],y:Ee[1]}};Ve?Ve.emit(Tr):de.emit(Tr),t.hoverData.cxtDragged=!0,(!t.hoverData.cxtOver||We!==t.hoverData.cxtOver)&&(t.hoverData.cxtOver&&t.hoverData.cxtOver.emit({originalEvent:F,type:"cxtdragout",position:{x:Ee[0],y:Ee[1]}}),t.hoverData.cxtOver=We,We&&We.emit({originalEvent:F,type:"cxtdragover",position:{x:Ee[0],y:Ee[1]}}))}}else if(t.hoverData.dragging){if(we=!0,de.panningEnabled()&&de.userPanningEnabled()){var Rr;if(t.hoverData.justStartedPan){var pr=t.hoverData.mdownPos;Rr={x:(Ee[0]-pr[0])*ge,y:(Ee[1]-pr[1])*ge},t.hoverData.justStartedPan=!1}else Rr={x:Ke[0]*ge,y:Ke[1]*ge};de.panBy(Rr),de.emit("dragpan"),t.hoverData.dragged=!0}Ee=t.projectIntoViewport(F.clientX,F.clientY)}else if(je[4]==1&&(Ve==null||Ve.pannable())){if(Lt){if(!t.hoverData.dragging&&de.boxSelectionEnabled()&&(wt||!de.panningEnabled()||!de.userPanningEnabled()))Ur();else if(!t.hoverData.selecting&&de.panningEnabled()&&de.userPanningEnabled()){var tr=i(Ve,t.hoverData.downs);tr&&(t.hoverData.dragging=!0,t.hoverData.justStartedPan=!0,je[4]=0,t.data.bgActivePosistion=Hn(Pe),t.redrawHint("select",!0),t.redraw())}Ve&&Ve.pannable()&&Ve.active()&&Ve.unactivate()}}else{if(Ve&&Ve.pannable()&&Ve.active()&&Ve.unactivate(),(!Ve||!Ve.grabbed())&&We!=nt&&(nt&&n(nt,["mouseout","tapdragout"],F,{x:Ee[0],y:Ee[1]}),We&&n(We,["mouseover","tapdragover"],F,{x:Ee[0],y:Ee[1]}),t.hoverData.last=We),Ve)if(Lt){if(de.boxSelectionEnabled()&&wt)Ve&&Ve.grabbed()&&(w(mt),Ve.emit("freeon"),mt.emit("free"),t.dragData.didDrag&&(Ve.emit("dragfreeon"),mt.emit("dragfree"))),Ur();else if(Ve&&Ve.grabbed()&&t.nodeIsDraggable(Ve)){var Rt=!t.dragData.didDrag;Rt&&t.redrawHint("eles",!0),t.dragData.didDrag=!0,t.hoverData.draggingEles||g(mt,{inDragLayer:!0});var Dt={x:0,y:0};if(Ae(Ke[0])&&Ae(Ke[1])&&(Dt.x+=Ke[0],Dt.y+=Ke[1],Rt)){var Ut=t.hoverData.dragDelta;Ut&&Ae(Ut[0])&&Ae(Ut[1])&&(Dt.x+=Ut[0],Dt.y+=Ut[1])}t.hoverData.draggingEles=!0,mt.silentShift(Dt).emit("position drag"),t.redrawHint("drag",!0),t.redraw()}}else fr();we=!0}if(je[2]=Ee[0],je[3]=Ee[1],we)return F.stopPropagation&&F.stopPropagation(),F.preventDefault&&F.preventDefault(),!1}},!1);var O,R,k;t.registerBinding(e,"mouseup",function(F){var ee=t.hoverData.capture;if(ee){t.hoverData.capture=!1;var we=t.cy,de=t.projectIntoViewport(F.clientX,F.clientY),ge=t.selection,Ye=t.findNearestElement(de[0],de[1],!0,!1),Ee=t.dragData.possibleDragElements,Pe=t.hoverData.down,Ze=a(F);if(t.data.bgActivePosistion&&(t.redrawHint("select",!0),t.redraw()),t.hoverData.tapholdCancelled=!0,t.data.bgActivePosistion=void 0,Pe&&Pe.unactivate(),t.hoverData.which===3){var je={originalEvent:F,type:"cxttapend",position:{x:de[0],y:de[1]}};if(Pe?Pe.emit(je):we.emit(je),!t.hoverData.cxtDragged){var We={originalEvent:F,type:"cxttap",position:{x:de[0],y:de[1]}};Pe?Pe.emit(We):we.emit(We)}t.hoverData.cxtDragged=!1,t.hoverData.which=null}else if(t.hoverData.which===1){if(n(Ye,["mouseup","tapend","vmouseup"],F,{x:de[0],y:de[1]}),!t.dragData.didDrag&&!t.hoverData.dragged&&!t.hoverData.selecting&&!t.hoverData.isOverThresholdDrag&&(n(Pe,["click","tap","vclick"],F,{x:de[0],y:de[1]}),R=!1,F.timeStamp-k<=we.multiClickDebounceTime()?(O&&clearTimeout(O),R=!0,k=null,n(Pe,["dblclick","dbltap","vdblclick"],F,{x:de[0],y:de[1]})):(O=setTimeout(function(){R||n(Pe,["oneclick","onetap","voneclick"],F,{x:de[0],y:de[1]})},we.multiClickDebounceTime()),k=F.timeStamp)),Pe==null&&!t.dragData.didDrag&&!t.hoverData.selecting&&!t.hoverData.dragged&&!a(F)&&(we.$(r).unselect(["tapunselect"]),Ee.length>0&&t.redrawHint("eles",!0),t.dragData.possibleDragElements=Ee=we.collection()),Ye==Pe&&!t.dragData.didDrag&&!t.hoverData.selecting&&Ye!=null&&Ye._private.selectable&&(t.hoverData.dragging||(we.selectionType()==="additive"||Ze?Ye.selected()?Ye.unselect(["tapunselect"]):Ye.select(["tapselect"]):Ze||(we.$(r).unmerge(Ye).unselect(["tapunselect"]),Ye.select(["tapselect"]))),t.redrawHint("eles",!0)),t.hoverData.selecting){var nt=we.collection(t.getAllInBox(ge[0],ge[1],ge[2],ge[3]));t.redrawHint("select",!0),nt.length>0&&t.redrawHint("eles",!0),we.emit({type:"boxend",originalEvent:F,position:{x:de[0],y:de[1]}});var Ve=function(Lt){return Lt.selectable()&&!Lt.selected()};we.selectionType()==="additive"||Ze||we.$(r).unmerge(nt).unselect(),nt.emit("box").stdFilter(Ve).select().emit("boxselect"),t.redraw()}if(t.hoverData.dragging&&(t.hoverData.dragging=!1,t.redrawHint("select",!0),t.redrawHint("eles",!0),t.redraw()),!ge[4]){t.redrawHint("drag",!0),t.redrawHint("eles",!0);var Ke=Pe&&Pe.grabbed();w(Ee),Ke&&(Pe.emit("freeon"),Ee.emit("free"),t.dragData.didDrag&&(Pe.emit("dragfreeon"),Ee.emit("dragfree")))}}ge[4]=0,t.hoverData.down=null,t.hoverData.cxtStarted=!1,t.hoverData.draggingEles=!1,t.hoverData.selecting=!1,t.hoverData.isOverThresholdDrag=!1,t.dragData.didDrag=!1,t.hoverData.dragged=!1,t.hoverData.dragDelta=[],t.hoverData.mdownPos=null,t.hoverData.mdownGPos=null}},!1);var z=function(F){if(!t.scrollingPage){var ee=t.cy,we=ee.zoom(),de=ee.pan(),ge=t.projectIntoViewport(F.clientX,F.clientY),Ye=[ge[0]*we+de.x,ge[1]*we+de.y];if(t.hoverData.draggingEles||t.hoverData.dragging||t.hoverData.cxtStarted||L()){F.preventDefault();return}if(ee.panningEnabled()&&ee.userPanningEnabled()&&ee.zoomingEnabled()&&ee.userZoomingEnabled()){F.preventDefault(),t.data.wheelZooming=!0,clearTimeout(t.data.wheelTimeout),t.data.wheelTimeout=setTimeout(function(){t.data.wheelZooming=!1,t.redrawHint("eles",!0),t.redraw()},150);var Ee;F.deltaY!=null?Ee=F.deltaY/-250:F.wheelDeltaY!=null?Ee=F.wheelDeltaY/1e3:Ee=F.wheelDelta/1e3,Ee=Ee*t.wheelSensitivity;var Pe=F.deltaMode===1;Pe&&(Ee*=33);var Ze=ee.zoom()*Math.pow(10,Ee);F.type==="gesturechange"&&(Ze=t.gestureStartZoom*F.scale),ee.zoom({level:Ze,renderedPosition:{x:Ye[0],y:Ye[1]}}),ee.emit(F.type==="gesturechange"?"pinchzoom":"scrollzoom")}}};t.registerBinding(t.container,"wheel",z,!0),t.registerBinding(e,"scroll",function(F){t.scrollingPage=!0,clearTimeout(t.scrollingPageTimeout),t.scrollingPageTimeout=setTimeout(function(){t.scrollingPage=!1},250)},!0),t.registerBinding(t.container,"gesturestart",function(F){t.gestureStartZoom=t.cy.zoom(),t.hasTouchStarted||F.preventDefault()},!0),t.registerBinding(t.container,"gesturechange",function(ye){t.hasTouchStarted||z(ye)},!0),t.registerBinding(t.container,"mouseout",function(F){var ee=t.projectIntoViewport(F.clientX,F.clientY);t.cy.emit({originalEvent:F,type:"mouseout",position:{x:ee[0],y:ee[1]}})},!1),t.registerBinding(t.container,"mouseover",function(F){var ee=t.projectIntoViewport(F.clientX,F.clientY);t.cy.emit({originalEvent:F,type:"mouseover",position:{x:ee[0],y:ee[1]}})},!1);var B,U,H,V,W,X,j,K,J,ne,ie,oe,ue,Z=function(F,ee,we,de){return Math.sqrt((we-F)*(we-F)+(de-ee)*(de-ee))},fe=function(F,ee,we,de){return(we-F)*(we-F)+(de-ee)*(de-ee)},ce;t.registerBinding(t.container,"touchstart",ce=function(F){if(t.hasTouchStarted=!0,!!D(F)){T(),t.touchData.capture=!0,t.data.bgActivePosistion=void 0;var ee=t.cy,we=t.touchData.now,de=t.touchData.earlier;if(F.touches[0]){var ge=t.projectIntoViewport(F.touches[0].clientX,F.touches[0].clientY);we[0]=ge[0],we[1]=ge[1]}if(F.touches[1]){var ge=t.projectIntoViewport(F.touches[1].clientX,F.touches[1].clientY);we[2]=ge[0],we[3]=ge[1]}if(F.touches[2]){var ge=t.projectIntoViewport(F.touches[2].clientX,F.touches[2].clientY);we[4]=ge[0],we[5]=ge[1]}if(F.touches[1]){t.touchData.singleTouchMoved=!0,w(t.dragData.touchDragEles);var Ye=t.findContainerClientCoords();J=Ye[0],ne=Ye[1],ie=Ye[2],oe=Ye[3],B=F.touches[0].clientX-J,U=F.touches[0].clientY-ne,H=F.touches[1].clientX-J,V=F.touches[1].clientY-ne,ue=0<=B&&B<=ie&&0<=H&&H<=ie&&0<=U&&U<=oe&&0<=V&&V<=oe;var Ee=ee.pan(),Pe=ee.zoom();W=Z(B,U,H,V),X=fe(B,U,H,V),j=[(B+H)/2,(U+V)/2],K=[(j[0]-Ee.x)/Pe,(j[1]-Ee.y)/Pe];var Ze=200,je=Ze*Ze;if(X=1){for(var Bt=t.touchData.startPosition=[null,null,null,null,null,null],St=0;St=t.touchTapThreshold2}if(ee&&t.touchData.cxt){F.preventDefault();var Bt=F.touches[0].clientX-J,St=F.touches[0].clientY-ne,Qt=F.touches[1].clientX-J,ht=F.touches[1].clientY-ne,wt=fe(Bt,St,Qt,ht),fr=wt/X,Ur=150,Tr=Ur*Ur,Rr=1.5,pr=Rr*Rr;if(fr>=pr||wt>=Tr){t.touchData.cxt=!1,t.data.bgActivePosistion=void 0,t.redrawHint("select",!0);var tr={originalEvent:F,type:"cxttapend",position:{x:ge[0],y:ge[1]}};t.touchData.start?(t.touchData.start.unactivate().emit(tr),t.touchData.start=null):de.emit(tr)}}if(ee&&t.touchData.cxt){var tr={originalEvent:F,type:"cxtdrag",position:{x:ge[0],y:ge[1]}};t.data.bgActivePosistion=void 0,t.redrawHint("select",!0),t.touchData.start?t.touchData.start.emit(tr):de.emit(tr),t.touchData.start&&(t.touchData.start._private.grabbed=!1),t.touchData.cxtDragged=!0;var Rt=t.findNearestElement(ge[0],ge[1],!0,!0);(!t.touchData.cxtOver||Rt!==t.touchData.cxtOver)&&(t.touchData.cxtOver&&t.touchData.cxtOver.emit({originalEvent:F,type:"cxtdragout",position:{x:ge[0],y:ge[1]}}),t.touchData.cxtOver=Rt,Rt&&Rt.emit({originalEvent:F,type:"cxtdragover",position:{x:ge[0],y:ge[1]}}))}else if(ee&&F.touches[2]&&de.boxSelectionEnabled())F.preventDefault(),t.data.bgActivePosistion=void 0,this.lastThreeTouch=+new Date,t.touchData.selecting||de.emit({originalEvent:F,type:"boxstart",position:{x:ge[0],y:ge[1]}}),t.touchData.selecting=!0,t.touchData.didSelect=!0,we[4]=1,!we||we.length===0||we[0]===void 0?(we[0]=(ge[0]+ge[2]+ge[4])/3,we[1]=(ge[1]+ge[3]+ge[5])/3,we[2]=(ge[0]+ge[2]+ge[4])/3+1,we[3]=(ge[1]+ge[3]+ge[5])/3+1):(we[2]=(ge[0]+ge[2]+ge[4])/3,we[3]=(ge[1]+ge[3]+ge[5])/3),t.redrawHint("select",!0),t.redraw();else if(ee&&F.touches[1]&&!t.touchData.didSelect&&de.zoomingEnabled()&&de.panningEnabled()&&de.userZoomingEnabled()&&de.userPanningEnabled()){F.preventDefault(),t.data.bgActivePosistion=void 0,t.redrawHint("select",!0);var Dt=t.dragData.touchDragEles;if(Dt){t.redrawHint("drag",!0);for(var Ut=0;Ut0&&!t.hoverData.draggingEles&&!t.swipePanning&&t.data.bgActivePosistion!=null&&(t.data.bgActivePosistion=void 0,t.redrawHint("select",!0),t.redraw())}},!1);var Ce;t.registerBinding(e,"touchcancel",Ce=function(F){var ee=t.touchData.start;t.touchData.capture=!1,ee&&ee.unactivate()});var Fe,He,De,le;if(t.registerBinding(e,"touchend",Fe=function(F){var ee=t.touchData.start,we=t.touchData.capture;if(we)F.touches.length===0&&(t.touchData.capture=!1),F.preventDefault();else return;var de=t.selection;t.swipePanning=!1,t.hoverData.draggingEles=!1;var ge=t.cy,Ye=ge.zoom(),Ee=t.touchData.now,Pe=t.touchData.earlier;if(F.touches[0]){var Ze=t.projectIntoViewport(F.touches[0].clientX,F.touches[0].clientY);Ee[0]=Ze[0],Ee[1]=Ze[1]}if(F.touches[1]){var Ze=t.projectIntoViewport(F.touches[1].clientX,F.touches[1].clientY);Ee[2]=Ze[0],Ee[3]=Ze[1]}if(F.touches[2]){var Ze=t.projectIntoViewport(F.touches[2].clientX,F.touches[2].clientY);Ee[4]=Ze[0],Ee[5]=Ze[1]}ee&&ee.unactivate();var je;if(t.touchData.cxt){if(je={originalEvent:F,type:"cxttapend",position:{x:Ee[0],y:Ee[1]}},ee?ee.emit(je):ge.emit(je),!t.touchData.cxtDragged){var We={originalEvent:F,type:"cxttap",position:{x:Ee[0],y:Ee[1]}};ee?ee.emit(We):ge.emit(We)}t.touchData.start&&(t.touchData.start._private.grabbed=!1),t.touchData.cxt=!1,t.touchData.start=null,t.redraw();return}if(!F.touches[2]&&ge.boxSelectionEnabled()&&t.touchData.selecting){t.touchData.selecting=!1;var nt=ge.collection(t.getAllInBox(de[0],de[1],de[2],de[3]));de[0]=void 0,de[1]=void 0,de[2]=void 0,de[3]=void 0,de[4]=0,t.redrawHint("select",!0),ge.emit({type:"boxend",originalEvent:F,position:{x:Ee[0],y:Ee[1]}});var Ve=function(Tr){return Tr.selectable()&&!Tr.selected()};nt.emit("box").stdFilter(Ve).select().emit("boxselect"),nt.nonempty()&&t.redrawHint("eles",!0),t.redraw()}if(ee!=null&&ee.unactivate(),F.touches[2])t.data.bgActivePosistion=void 0,t.redrawHint("select",!0);else if(!F.touches[1]){if(!F.touches[0]){if(!F.touches[0]){t.data.bgActivePosistion=void 0,t.redrawHint("select",!0);var Ke=t.dragData.touchDragEles;if(ee!=null){var mt=ee._private.grabbed;w(Ke),t.redrawHint("drag",!0),t.redrawHint("eles",!0),mt&&(ee.emit("freeon"),Ke.emit("free"),t.dragData.didDrag&&(ee.emit("dragfreeon"),Ke.emit("dragfree"))),n(ee,["touchend","tapend","vmouseup","tapdragout"],F,{x:Ee[0],y:Ee[1]}),ee.unactivate(),t.touchData.start=null}else{var Lt=t.findNearestElement(Ee[0],Ee[1],!0,!0);n(Lt,["touchend","tapend","vmouseup","tapdragout"],F,{x:Ee[0],y:Ee[1]})}var kt=t.touchData.startPosition[0]-Ee[0],Bt=kt*kt,St=t.touchData.startPosition[1]-Ee[1],Qt=St*St,ht=Bt+Qt,wt=ht*Ye*Ye;t.touchData.singleTouchMoved||(ee||ge.$(":selected").unselect(["tapunselect"]),n(ee,["tap","vclick"],F,{x:Ee[0],y:Ee[1]}),He=!1,F.timeStamp-le<=ge.multiClickDebounceTime()?(De&&clearTimeout(De),He=!0,le=null,n(ee,["dbltap","vdblclick"],F,{x:Ee[0],y:Ee[1]})):(De=setTimeout(function(){He||n(ee,["onetap","voneclick"],F,{x:Ee[0],y:Ee[1]})},ge.multiClickDebounceTime()),le=F.timeStamp)),ee!=null&&!t.dragData.didDrag&&ee._private.selectable&&wt"u"){var me=[],xe=function(F){return{clientX:F.clientX,clientY:F.clientY,force:1,identifier:F.pointerId,pageX:F.pageX,pageY:F.pageY,radiusX:F.width/2,radiusY:F.height/2,screenX:F.screenX,screenY:F.screenY,target:F.target}},pe=function(F){return{event:F,touch:xe(F)}},Se=function(F){me.push(pe(F))},ke=function(F){for(var ee=0;ee0)return K[0]}return null},d=Object.keys(h),g=0;g0?p:Il(i,o,e,r,n,a,s)},checkPoint:function(e,r,n,a,i,o,s){var u=$a(a,i),l=2*u;if(Hr(e,r,this.points,o,s,a,i-l,[0,-1],n)||Hr(e,r,this.points,o,s,a-l,i,[0,-1],n))return!0;var f=a/2+2*n,h=i/2+2*n,p=[o-f,s-h,o-f,s,o+f,s,o+f,s-h];return!!(or(e,r,p)||wn(e,r,l,l,o+a/2-u,s+i/2-u,n)||wn(e,r,l,l,o-a/2+u,s+i/2-u,n))}}};$r.registerNodeShapes=function(){var t=this.nodeShapes={},e=this;this.generateEllipse(),this.generatePolygon("triangle",er(3,0)),this.generateRoundPolygon("round-triangle",er(3,0)),this.generatePolygon("rectangle",er(4,0)),t.square=t.rectangle,this.generateRoundRectangle(),this.generateCutRectangle(),this.generateBarrel(),this.generateBottomRoundrectangle();{var r=[0,1,1,0,0,-1,-1,0];this.generatePolygon("diamond",r),this.generateRoundPolygon("round-diamond",r)}this.generatePolygon("pentagon",er(5,0)),this.generateRoundPolygon("round-pentagon",er(5,0)),this.generatePolygon("hexagon",er(6,0)),this.generateRoundPolygon("round-hexagon",er(6,0)),this.generatePolygon("heptagon",er(7,0)),this.generateRoundPolygon("round-heptagon",er(7,0)),this.generatePolygon("octagon",er(8,0)),this.generateRoundPolygon("round-octagon",er(8,0));var n=new Array(20);{var a=Po(5,0),i=Po(5,Math.PI/5),o=.5*(3-Math.sqrt(5));o*=1.57;for(var s=0;s=e.deqFastCost*S)break}else if(l){if(T>=e.deqCost*d||T>=e.deqAvgCost*p)break}else if(E>=e.deqNoDrawCost*Oo)break;var A=e.deq(n,w,m);if(A.length>0)for(var I=0;I0&&(e.onDeqd(n,g),!l&&e.shouldRedraw(n,g,w,m)&&i())},s=e.priority||is;a.beforeRender(o,s(n))}}}},_0=function(){function t(e){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Ci;es(this,t),this.idsByKey=new Nr,this.keyForId=new Nr,this.cachesByLvl=new Nr,this.lvls=[],this.getKey=e,this.doesEleInvalidateKey=r}return ts(t,[{key:"getIdsFor",value:function(r){r==null&&Tt("Can not get id list for null key");var n=this.idsByKey,a=this.idsByKey.get(r);return a||(a=new jn,n.set(r,a)),a}},{key:"addIdForKey",value:function(r,n){r!=null&&this.getIdsFor(r).add(n)}},{key:"deleteIdForKey",value:function(r,n){r!=null&&this.getIdsFor(r).delete(n)}},{key:"getNumberOfIdsForKey",value:function(r){return r==null?0:this.getIdsFor(r).size}},{key:"updateKeyMappingFor",value:function(r){var n=r.id(),a=this.keyForId.get(n),i=this.getKey(r);this.deleteIdForKey(a,n),this.addIdForKey(i,n),this.keyForId.set(n,i)}},{key:"deleteKeyMappingFor",value:function(r){var n=r.id(),a=this.keyForId.get(n);this.deleteIdForKey(a,n),this.keyForId.delete(n)}},{key:"keyHasChangedFor",value:function(r){var n=r.id(),a=this.keyForId.get(n),i=this.getKey(r);return a!==i}},{key:"isInvalid",value:function(r){return this.keyHasChangedFor(r)||this.doesEleInvalidateKey(r)}},{key:"getCachesAt",value:function(r){var n=this.cachesByLvl,a=this.lvls,i=n.get(r);return i||(i=new Nr,n.set(r,i),a.push(r)),i}},{key:"getCache",value:function(r,n){return this.getCachesAt(n).get(r)}},{key:"get",value:function(r,n){var a=this.getKey(r),i=this.getCache(a,n);return i!=null&&this.updateKeyMappingFor(r),i}},{key:"getForCachedKey",value:function(r,n){var a=this.keyForId.get(r.id()),i=this.getCache(a,n);return i}},{key:"hasCache",value:function(r,n){return this.getCachesAt(n).has(r)}},{key:"has",value:function(r,n){var a=this.getKey(r);return this.hasCache(a,n)}},{key:"setCache",value:function(r,n,a){a.key=r,this.getCachesAt(n).set(r,a)}},{key:"set",value:function(r,n,a){var i=this.getKey(r);this.setCache(i,n,a),this.updateKeyMappingFor(r)}},{key:"deleteCache",value:function(r,n){this.getCachesAt(n).delete(r)}},{key:"delete",value:function(r,n){var a=this.getKey(r);this.deleteCache(a,n)}},{key:"invalidateKey",value:function(r){var n=this;this.lvls.forEach(function(a){return n.deleteCache(r,a)})}},{key:"invalidate",value:function(r){var n=r.id(),a=this.keyForId.get(n);this.deleteKeyMappingFor(r);var i=this.doesEleInvalidateKey(r);return i&&this.invalidateKey(a),i||this.getNumberOfIdsForKey(a)===0}}]),t}(),Xu=25,di=50,Ei=-4,Vo=3,K0=7.99,Z0=8,Q0=1024,j0=1024,J0=1024,eb=.2,tb=.8,rb=10,nb=.15,ab=.1,ib=.9,ob=.9,sb=100,ub=1,qn={dequeue:"dequeue",downscale:"downscale",highQuality:"highQuality"},lb=$t({getKey:null,doesEleInvalidateKey:Ci,drawElement:null,getBoundingBox:null,getRotationPoint:null,getRotationOffset:null,isVisible:Dl,allowEdgeTxrCaching:!0,allowParentTxrCaching:!0}),Ta=function(e,r){var n=this;n.renderer=e,n.onDequeues=[];var a=lb(r);$e(n,a),n.lookup=new _0(a.getKey,a.doesEleInvalidateKey),n.setupDequeueing()},It=Ta.prototype;It.reasons=qn;It.getTextureQueue=function(t){var e=this;return e.eleImgCaches=e.eleImgCaches||{},e.eleImgCaches[t]=e.eleImgCaches[t]||[]};It.getRetiredTextureQueue=function(t){var e=this,r=e.eleImgCaches.retired=e.eleImgCaches.retired||{},n=r[t]=r[t]||[];return n};It.getElementQueue=function(){var t=this,e=t.eleCacheQueue=t.eleCacheQueue||new Ga.default(function(r,n){return n.reqs-r.reqs});return e};It.getElementKeyToQueue=function(){var t=this,e=t.eleKeyToCacheQueue=t.eleKeyToCacheQueue||{};return e};It.getElement=function(t,e,r,n,a){var i=this,o=this.renderer,s=o.cy.zoom(),u=this.lookup;if(!e||e.w===0||e.h===0||isNaN(e.w)||isNaN(e.h)||!t.visible()||t.removed()||!i.allowEdgeTxrCaching&&t.isEdge()||!i.allowParentTxrCaching&&t.isParent())return null;if(n==null&&(n=Math.ceil(ss(s*r))),n=K0||n>Vo)return null;var l=Math.pow(2,n),f=e.h*l,h=e.w*l,p=o.eleTextBiggerThanMin(t,l);if(!this.isVisible(t,p))return null;var d=u.get(t,n);if(d&&d.invalidated&&(d.invalidated=!1,d.texture.invalidatedWidth-=d.width),d)return d;var g;if(f<=Xu?g=Xu:f<=di?g=di:g=Math.ceil(f/di)*di,f>J0||h>j0)return null;var m=i.getTextureQueue(g),w=m[m.length-2],b=function(){return i.recycleTexture(g,h)||i.addTexture(g,h)};w||(w=m[m.length-1]),w||(w=b()),w.width-w.usedWidthn;R--)D=i.getElement(t,e,r,R,qn.downscale);O()}else return i.queueElement(t,I.level-1),I;else{var k;if(!E&&!S&&!A)for(var z=n-1;z>=Ei;z--){var B=u.get(t,z);if(B){k=B;break}}if(T(k))return i.queueElement(t,n),k;w.context.translate(w.usedWidth,0),w.context.scale(l,l),this.drawElement(w.context,t,e,p,!1),w.context.scale(1/l,1/l),w.context.translate(-w.usedWidth,0)}return d={x:w.usedWidth,texture:w,level:n,scale:l,width:h,height:f,scaledLabelShown:p},w.usedWidth+=Math.ceil(h+Z0),w.eleCaches.push(d),u.set(t,n,d),i.checkTextureFullness(w),d};It.invalidateElements=function(t){for(var e=0;e=eb*t.width&&this.retireTexture(t)};It.checkTextureFullness=function(t){var e=this,r=e.getTextureQueue(t.height);t.usedWidth/t.width>tb&&t.fullnessChecks>=rb?on(r,t):t.fullnessChecks++};It.retireTexture=function(t){var e=this,r=t.height,n=e.getTextureQueue(r),a=this.lookup;on(n,t),t.retired=!0;for(var i=t.eleCaches,o=0;o=e)return o.retired=!1,o.usedWidth=0,o.invalidatedWidth=0,o.fullnessChecks=0,os(o.eleCaches),o.context.setTransform(1,0,0,1,0,0),o.context.clearRect(0,0,o.width,o.height),on(a,o),n.push(o),o}};It.queueElement=function(t,e){var r=this,n=r.getElementQueue(),a=r.getElementKeyToQueue(),i=this.getKey(t),o=a[i];if(o)o.level=Math.max(o.level,e),o.eles.merge(t),o.reqs++,n.updateItem(o);else{var s={eles:t.spawn().merge(t),level:e,reqs:1,key:i};n.push(s),a[i]=s}};It.dequeue=function(t){for(var e=this,r=e.getElementQueue(),n=e.getElementKeyToQueue(),a=[],i=e.lookup,o=0;o0;o++){var s=r.pop(),u=s.key,l=s.eles[0],f=i.hasCache(l,s.level);if(n[u]=null,f)continue;a.push(s);var h=e.getBoundingBox(l);e.getElement(l,h,t,s.level,qn.dequeue)}return a};It.removeFromQueue=function(t){var e=this,r=e.getElementQueue(),n=e.getElementKeyToQueue(),a=this.getKey(t),i=n[a];i!=null&&(i.eles.length===1?(i.reqs=as,r.updateItem(i),r.pop(),n[a]=null):i.eles.unmerge(t))};It.onDequeue=function(t){this.onDequeues.push(t)};It.offDequeue=function(t){on(this.onDequeues,t)};It.setupDequeueing=Sf.setupDequeueing({deqRedrawThreshold:sb,deqCost:nb,deqAvgCost:ab,deqNoDrawCost:ib,deqFastCost:ob,deq:function(e,r,n){return e.dequeue(r,n)},onDeqd:function(e,r){for(var n=0;n=cb||r>Ni)return null}n.validateLayersElesOrdering(r,t);var u=n.layersByLevel,l=Math.pow(2,r),f=u[r]=u[r]||[],h,p=n.levelIsComplete(r,t),d,g=function(){var O=function(U){if(n.validateLayersElesOrdering(U,t),n.levelIsComplete(U,t))return d=u[U],!0},R=function(U){if(!d)for(var H=r+U;Da<=H&&H<=Ni&&!O(H);H+=U);};R(1),R(-1);for(var k=f.length-1;k>=0;k--){var z=f[k];z.invalid&&on(f,z)}};if(!p)g();else return f;var m=function(){if(!h){h=sr();for(var O=0;Obb)return null;var z=n.makeLayer(h,r);if(R!=null){var B=f.indexOf(R)+1;f.splice(B,0,z)}else(O.insert===void 0||O.insert)&&f.unshift(z);return z};if(n.skipping&&!s)return null;for(var b=null,T=t.length/fb,E=!s,S=0;S=T||!Ol(b.bb,A.boundingBox()))&&(b=w({insert:!0,after:b}),!b))return null;d||E?n.queueLayer(b,A):n.drawEleInLayer(b,A,r,e),b.eles.push(A),v[r]=b}return d||(E?null:f)};Vt.getEleLevelForLayerLevel=function(t,e){return t};Vt.drawEleInLayer=function(t,e,r,n){var a=this,i=this.renderer,o=t.context,s=e.boundingBox();s.w===0||s.h===0||!e.visible()||(r=a.getEleLevelForLayerLevel(r,n),i.setImgSmoothing(o,!1),i.drawCachedElement(o,e,null,null,r,wb),i.setImgSmoothing(o,!0))};Vt.levelIsComplete=function(t,e){var r=this,n=r.layersByLevel[t];if(!n||n.length===0)return!1;for(var a=0,i=0;i0||o.invalid)return!1;a+=o.eles.length}return a===e.length};Vt.validateLayersElesOrdering=function(t,e){var r=this.layersByLevel[t];if(r)for(var n=0;n0){e=!0;break}}return e};Vt.invalidateElements=function(t){var e=this;t.length!==0&&(e.lastInvalidationTime=Gr(),!(t.length===0||!e.haveLayers())&&e.updateElementsInLayers(t,function(n,a,i){e.invalidateLayer(n)}))};Vt.invalidateLayer=function(t){if(this.lastInvalidationTime=Gr(),!t.invalid){var e=t.level,r=t.eles,n=this.layersByLevel[e];on(n,t),t.elesQueue=[],t.invalid=!0,t.replacement&&(t.replacement.invalid=!0);for(var a=0;a3&&arguments[3]!==void 0?arguments[3]:!0,a=arguments.length>4&&arguments[4]!==void 0?arguments[4]:!0,i=arguments.length>5&&arguments[5]!==void 0?arguments[5]:!0,o=this,s=e._private.rscratch;if(!(i&&!e.visible())&&!(s.badLine||s.allpts==null||isNaN(s.allpts[0]))){var u;r&&(u=r,t.translate(-u.x1,-u.y1));var l=i?e.pstyle("opacity").value:1,f=i?e.pstyle("line-opacity").value:1,h=e.pstyle("curve-style").value,p=e.pstyle("line-style").value,d=e.pstyle("width").pfValue,g=e.pstyle("line-cap").value,m=l*f,w=l*f,b=function(){var k=arguments.length>0&&arguments[0]!==void 0?arguments[0]:m;h==="straight-triangle"?(o.eleStrokeStyle(t,e,k),o.drawEdgeTrianglePath(e,t,s.allpts)):(t.lineWidth=d,t.lineCap=g,o.eleStrokeStyle(t,e,k),o.drawEdgePath(e,t,s.allpts,p),t.lineCap="butt")},T=function(){a&&o.drawEdgeOverlay(t,e)},E=function(){a&&o.drawEdgeUnderlay(t,e)},S=function(){var k=arguments.length>0&&arguments[0]!==void 0?arguments[0]:w;o.drawArrowheads(t,e,k)},A=function(){o.drawElementText(t,e,null,n)};t.lineJoin="round";var I=e.pstyle("ghost").value==="yes";if(I){var v=e.pstyle("ghost-offset-x").pfValue,L=e.pstyle("ghost-offset-y").pfValue,D=e.pstyle("ghost-opacity").value,O=m*D;t.translate(v,L),b(O),S(O),t.translate(-v,-L)}E(),b(),S(),T(),A(),r&&t.translate(u.x1,u.y1)}};var Mf=function(e){if(!["overlay","underlay"].includes(e))throw new Error("Invalid state");return function(r,n){if(n.visible()){var a=n.pstyle("".concat(e,"-opacity")).value;if(a!==0){var i=this,o=i.usePaths(),s=n._private.rscratch,u=n.pstyle("".concat(e,"-padding")).pfValue,l=2*u,f=n.pstyle("".concat(e,"-color")).value;r.lineWidth=l,s.edgeType==="self"&&!o?r.lineCap="butt":r.lineCap="round",i.colorStrokeStyle(r,f[0],f[1],f[2],a),i.drawEdgePath(n,r,s.allpts,"solid")}}}};Vr.drawEdgeOverlay=Mf("overlay");Vr.drawEdgeUnderlay=Mf("underlay");Vr.drawEdgePath=function(t,e,r,n){var a=t._private.rscratch,i=e,o,s=!1,u=this.usePaths(),l=t.pstyle("line-dash-pattern").pfValue,f=t.pstyle("line-dash-offset").pfValue;if(u){var h=r.join("$"),p=a.pathCacheKey&&a.pathCacheKey===h;p?(o=e=a.pathCache,s=!0):(o=e=new Path2D,a.pathCacheKey=h,a.pathCache=o)}if(i.setLineDash)switch(n){case"dotted":i.setLineDash([1,1]);break;case"dashed":i.setLineDash(l),i.lineDashOffset=f;break;case"solid":i.setLineDash([]);break}if(!s&&!a.badLine)switch(e.beginPath&&e.beginPath(),e.moveTo(r[0],r[1]),a.edgeType){case"bezier":case"self":case"compound":case"multibezier":for(var d=2;d+35&&arguments[5]!==void 0?arguments[5]:!0,o=this;if(n==null){if(i&&!o.eleTextBiggerThanMin(e))return}else if(n===!1)return;if(e.isNode()){var s=e.pstyle("label");if(!s||!s.value)return;var u=o.getLabelJustification(e);t.textAlign=u,t.textBaseline="bottom"}else{var l=e.element()._private.rscratch.badLine,f=e.pstyle("label"),h=e.pstyle("source-label"),p=e.pstyle("target-label");if(l||(!f||!f.value)&&(!h||!h.value)&&(!p||!p.value))return;t.textAlign="center",t.textBaseline="bottom"}var d=!r,g;r&&(g=r,t.translate(-g.x1,-g.y1)),a==null?(o.drawText(t,e,null,d,i),e.isEdge()&&(o.drawText(t,e,"source",d,i),o.drawText(t,e,"target",d,i))):o.drawText(t,e,a,d,i),r&&t.translate(g.x1,g.y1)};An.getFontCache=function(t){var e;this.fontCaches=this.fontCaches||[];for(var r=0;r2&&arguments[2]!==void 0?arguments[2]:!0,n=e.pstyle("font-style").strValue,a=e.pstyle("font-size").pfValue+"px",i=e.pstyle("font-family").strValue,o=e.pstyle("font-weight").strValue,s=r?e.effectiveOpacity()*e.pstyle("text-opacity").value:1,u=e.pstyle("text-outline-opacity").value*s,l=e.pstyle("color").value,f=e.pstyle("text-outline-color").value;t.font=n+" "+o+" "+a+" "+i,t.lineJoin="round",this.colorFillStyle(t,l[0],l[1],l[2],s),this.colorStrokeStyle(t,f[0],f[1],f[2],u)};function Ob(t,e,r,n,a){var i=arguments.length>5&&arguments[5]!==void 0?arguments[5]:5;t.beginPath(),t.moveTo(e+i,r),t.lineTo(e+n-i,r),t.quadraticCurveTo(e+n,r,e+n,r+i),t.lineTo(e+n,r+a-i),t.quadraticCurveTo(e+n,r+a,e+n-i,r+a),t.lineTo(e+i,r+a),t.quadraticCurveTo(e,r+a,e,r+a-i),t.lineTo(e,r+i),t.quadraticCurveTo(e,r,e+i,r),t.closePath(),t.fill()}An.getTextAngle=function(t,e){var r,n=t._private,a=n.rscratch,i=e?e+"-":"",o=t.pstyle(i+"text-rotation"),s=Er(a,"labelAngle",e);return o.strValue==="autorotate"?r=t.isEdge()?s:0:o.strValue==="none"?r=0:r=o.pfValue,r};An.drawText=function(t,e,r){var n=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!0,a=arguments.length>4&&arguments[4]!==void 0?arguments[4]:!0,i=e._private,o=i.rscratch,s=a?e.effectiveOpacity():1;if(!(a&&(s===0||e.pstyle("text-opacity").value===0))){r==="main"&&(r=null);var u=Er(o,"labelX",r),l=Er(o,"labelY",r),f,h,p=this.getLabelText(e,r);if(p!=null&&p!==""&&!isNaN(u)&&!isNaN(l)){this.setupTextStyle(t,e,a);var d=r?r+"-":"",g=Er(o,"labelWidth",r),m=Er(o,"labelHeight",r),w=e.pstyle(d+"text-margin-x").pfValue,b=e.pstyle(d+"text-margin-y").pfValue,T=e.isEdge(),E=e.pstyle("text-halign").value,S=e.pstyle("text-valign").value;T&&(E="center",S="center"),u+=w,l+=b;var A;switch(n?A=this.getTextAngle(e,r):A=0,A!==0&&(f=u,h=l,t.translate(f,h),t.rotate(A),u=0,l=0),S){case"top":break;case"center":l+=m/2;break;case"bottom":l+=m;break}var I=e.pstyle("text-background-opacity").value,v=e.pstyle("text-border-opacity").value,L=e.pstyle("text-border-width").pfValue,D=e.pstyle("text-background-padding").pfValue;if(I>0||L>0&&v>0){var O=u-D;switch(E){case"left":O-=g;break;case"center":O-=g/2;break}var R=l-m-D,k=g+2*D,z=m+2*D;if(I>0){var B=t.fillStyle,U=e.pstyle("text-background-color").value;t.fillStyle="rgba("+U[0]+","+U[1]+","+U[2]+","+I*s+")";var H=e.pstyle("text-background-shape").strValue;H.indexOf("round")===0?Ob(t,O,R,k,z,2):t.fillRect(O,R,k,z),t.fillStyle=B}if(L>0&&v>0){var V=t.strokeStyle,W=t.lineWidth,X=e.pstyle("text-border-color").value,j=e.pstyle("text-border-style").value;if(t.strokeStyle="rgba("+X[0]+","+X[1]+","+X[2]+","+v*s+")",t.lineWidth=L,t.setLineDash)switch(j){case"dotted":t.setLineDash([1,1]);break;case"dashed":t.setLineDash([4,2]);break;case"double":t.lineWidth=L/4,t.setLineDash([]);break;case"solid":t.setLineDash([]);break}if(t.strokeRect(O,R,k,z),j==="double"){var K=L/2;t.strokeRect(O+K,R+K,k-K*2,z-K*2)}t.setLineDash&&t.setLineDash([]),t.lineWidth=W,t.strokeStyle=V}}var J=2*e.pstyle("text-outline-width").pfValue;if(J>0&&(t.lineWidth=J),e.pstyle("text-wrap").value==="wrap"){var ne=Er(o,"labelWrapCachedLines",r),ie=Er(o,"labelLineHeight",r),oe=g/2,ue=this.getLabelJustification(e);switch(ue==="auto"||(E==="left"?ue==="left"?u+=-g:ue==="center"&&(u+=-oe):E==="center"?ue==="left"?u+=-oe:ue==="right"&&(u+=oe):E==="right"&&(ue==="center"?u+=oe:ue==="right"&&(u+=g))),S){case"top":l-=(ne.length-1)*ie;break;case"center":case"bottom":l-=(ne.length-1)*ie;break}for(var Z=0;Z0&&t.strokeText(ne[Z],u,l),t.fillText(ne[Z],u,l),l+=ie}else J>0&&t.strokeText(p,u,l),t.fillText(p,u,l);A!==0&&(t.rotate(-A),t.translate(-f,-h))}}};var aa={};aa.drawNode=function(t,e,r){var n=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!0,a=arguments.length>4&&arguments[4]!==void 0?arguments[4]:!0,i=arguments.length>5&&arguments[5]!==void 0?arguments[5]:!0,o=this,s,u,l=e._private,f=l.rscratch,h=e.position();if(!(!Ae(h.x)||!Ae(h.y))&&!(i&&!e.visible())){var p=i?e.effectiveOpacity():1,d=o.usePaths(),g,m=!1,w=e.padding();s=e.width()+2*w,u=e.height()+2*w;var b;r&&(b=r,t.translate(-b.x1,-b.y1));for(var T=e.pstyle("background-image"),E=T.value,S=new Array(E.length),A=new Array(E.length),I=0,v=0;v0&&arguments[0]!==void 0?arguments[0]:z;o.eleFillStyle(t,e,pe)},W=function(){var pe=arguments.length>0&&arguments[0]!==void 0?arguments[0]:H;o.colorStrokeStyle(t,B[0],B[1],B[2],pe)},X=e.pstyle("shape").strValue,j=e.pstyle("shape-polygon-points").pfValue;if(d){t.translate(h.x,h.y);var K=o.nodePathCache=o.nodePathCache||[],J=Cl(X==="polygon"?X+","+j.join(","):X,""+u,""+s),ne=K[J];ne!=null?(g=ne,m=!0,f.pathCache=g):(g=new Path2D,K[J]=f.pathCache=g)}var ie=function(){if(!m){var pe=h;d&&(pe={x:0,y:0}),o.nodeShapes[o.getNodeShape(e)].draw(g||t,pe.x,pe.y,s,u)}d?t.fill(g):t.fill()},oe=function(){for(var pe=arguments.length>0&&arguments[0]!==void 0?arguments[0]:p,Se=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0,ke=l.backgrounding,Re=0,Me=0;Me0&&arguments[0]!==void 0?arguments[0]:!1,Se=arguments.length>1&&arguments[1]!==void 0?arguments[1]:p;o.hasPie(e)&&(o.drawPie(t,e,Se),pe&&(d||o.nodeShapes[o.getNodeShape(e)].draw(t,h.x,h.y,s,u)))},Z=function(){var pe=arguments.length>0&&arguments[0]!==void 0?arguments[0]:p,Se=(R>0?R:-R)*pe,ke=R>0?0:255;R!==0&&(o.colorFillStyle(t,ke,ke,ke,Se),d?t.fill(g):t.fill())},fe=function(){if(k>0){if(t.lineWidth=k,t.lineCap="butt",t.setLineDash)switch(U){case"dotted":t.setLineDash([1,1]);break;case"dashed":t.setLineDash([4,2]);break;case"solid":case"double":t.setLineDash([]);break}if(d?t.stroke(g):t.stroke(),U==="double"){t.lineWidth=k/3;var pe=t.globalCompositeOperation;t.globalCompositeOperation="destination-out",d?t.stroke(g):t.stroke(),t.globalCompositeOperation=pe}t.setLineDash&&t.setLineDash([])}},ce=function(){a&&o.drawNodeOverlay(t,e,h,s,u)},be=function(){a&&o.drawNodeUnderlay(t,e,h,s,u)},Ce=function(){o.drawElementText(t,e,null,n)},Fe=e.pstyle("ghost").value==="yes";if(Fe){var He=e.pstyle("ghost-offset-x").pfValue,De=e.pstyle("ghost-offset-y").pfValue,le=e.pstyle("ghost-opacity").value,me=le*p;t.translate(He,De),V(le*z),ie(),oe(me,!0),W(le*H),fe(),ue(R!==0||k!==0),oe(me,!1),Z(me),t.translate(-He,-De)}d&&t.translate(-h.x,-h.y),be(),d&&t.translate(h.x,h.y),V(),ie(),oe(p,!0),W(),fe(),ue(R!==0||k!==0),oe(p,!1),Z(),d&&t.translate(-h.x,-h.y),Ce(),ce(),r&&t.translate(b.x1,b.y1)}};var Nf=function(e){if(!["overlay","underlay"].includes(e))throw new Error("Invalid state");return function(r,n,a,i,o){var s=this;if(n.visible()){var u=n.pstyle("".concat(e,"-padding")).pfValue,l=n.pstyle("".concat(e,"-opacity")).value,f=n.pstyle("".concat(e,"-color")).value,h=n.pstyle("".concat(e,"-shape")).value;if(l>0){if(a=a||n.position(),i==null||o==null){var p=n.padding();i=n.width()+2*p,o=n.height()+2*p}s.colorFillStyle(r,f[0],f[1],f[2],l),s.nodeShapes[h].draw(r,a.x,a.y,i+u*2,o+u*2),r.fill()}}}};aa.drawNodeOverlay=Nf("overlay");aa.drawNodeUnderlay=Nf("underlay");aa.hasPie=function(t){return t=t[0],t._private.hasPie};aa.drawPie=function(t,e,r,n){e=e[0],n=n||e.position();var a=e.cy().style(),i=e.pstyle("pie-size"),o=n.x,s=n.y,u=e.width(),l=e.height(),f=Math.min(u,l)/2,h=0,p=this.usePaths();p&&(o=0,s=0),i.units==="%"?f=f*i.pfValue:i.pfValue!==void 0&&(f=i.pfValue/2);for(var d=1;d<=a.pieBackgroundN;d++){var g=e.pstyle("pie-"+d+"-background-size").value,m=e.pstyle("pie-"+d+"-background-color").value,w=e.pstyle("pie-"+d+"-background-opacity").value*r,b=g/100;b+h>1&&(b=1-h);var T=1.5*Math.PI+2*Math.PI*h,E=2*Math.PI*b,S=T+E;g===0||h>=1||h+b>1||(t.beginPath(),t.moveTo(o,s),t.arc(o,s,f,T,S),t.closePath(),this.colorFillStyle(t,m[0],m[1],m[2],w),t.fill(),h+=b)}};var lr={},Ib=100;lr.getPixelRatio=function(){var t=this.data.contexts[0];if(this.forcedPixelRatio!=null)return this.forcedPixelRatio;var e=t.backingStorePixelRatio||t.webkitBackingStorePixelRatio||t.mozBackingStorePixelRatio||t.msBackingStorePixelRatio||t.oBackingStorePixelRatio||t.backingStorePixelRatio||1;return(window.devicePixelRatio||1)/e};lr.paintCache=function(t){for(var e=this.paintCaches=this.paintCaches||[],r=!0,n,a=0;ao.minMbLowQualFrames&&(o.motionBlurPxRatio=o.mbPxRBlurry)),o.clearingMotionBlur&&(o.motionBlurPxRatio=1),o.textureDrawLastFrame&&!h&&(f[o.NODE]=!0,f[o.SELECT_BOX]=!0);var T=u.style(),E=u.zoom(),S=a!==void 0?a:E,A=u.pan(),I={x:A.x,y:A.y},v={zoom:E,pan:{x:A.x,y:A.y}},L=o.prevViewport,D=L===void 0||v.zoom!==L.zoom||v.pan.x!==L.pan.x||v.pan.y!==L.pan.y;!D&&!(m&&!g)&&(o.motionBlurPxRatio=1),i&&(I=i),S*=s,I.x*=s,I.y*=s;var O=o.getCachedZSortedEles();function R(De,le,me,xe,pe){var Se=De.globalCompositeOperation;De.globalCompositeOperation="destination-out",o.colorFillStyle(De,255,255,255,o.motionBlurTransparency),De.fillRect(le,me,xe,pe),De.globalCompositeOperation=Se}function k(De,le){var me,xe,pe,Se;!o.clearingMotionBlur&&(De===l.bufferContexts[o.MOTIONBLUR_BUFFER_NODE]||De===l.bufferContexts[o.MOTIONBLUR_BUFFER_DRAG])?(me={x:A.x*d,y:A.y*d},xe=E*d,pe=o.canvasWidth*d,Se=o.canvasHeight*d):(me=I,xe=S,pe=o.canvasWidth,Se=o.canvasHeight),De.setTransform(1,0,0,1,0,0),le==="motionBlur"?R(De,0,0,pe,Se):!e&&(le===void 0||le)&&De.clearRect(0,0,pe,Se),r||(De.translate(me.x,me.y),De.scale(xe,xe)),i&&De.translate(i.x,i.y),a&&De.scale(a,a)}if(h||(o.textureDrawLastFrame=!1),h){if(o.textureDrawLastFrame=!0,!o.textureCache){o.textureCache={},o.textureCache.bb=u.mutableElements().boundingBox(),o.textureCache.texture=o.data.bufferCanvases[o.TEXTURE_BUFFER];var z=o.data.bufferContexts[o.TEXTURE_BUFFER];z.setTransform(1,0,0,1,0,0),z.clearRect(0,0,o.canvasWidth*o.textureMult,o.canvasHeight*o.textureMult),o.render({forcedContext:z,drawOnlyNodeLayer:!0,forcedPxRatio:s*o.textureMult});var v=o.textureCache.viewport={zoom:u.zoom(),pan:u.pan(),width:o.canvasWidth,height:o.canvasHeight};v.mpan={x:(0-v.pan.x)/v.zoom,y:(0-v.pan.y)/v.zoom}}f[o.DRAG]=!1,f[o.NODE]=!1;var B=l.contexts[o.NODE],U=o.textureCache.texture,v=o.textureCache.viewport;B.setTransform(1,0,0,1,0,0),p?R(B,0,0,v.width,v.height):B.clearRect(0,0,v.width,v.height);var H=T.core("outside-texture-bg-color").value,V=T.core("outside-texture-bg-opacity").value;o.colorFillStyle(B,H[0],H[1],H[2],V),B.fillRect(0,0,v.width,v.height);var E=u.zoom();k(B,!1),B.clearRect(v.mpan.x,v.mpan.y,v.width/v.zoom/s,v.height/v.zoom/s),B.drawImage(U,v.mpan.x,v.mpan.y,v.width/v.zoom/s,v.height/v.zoom/s)}else o.textureOnViewport&&!e&&(o.textureCache=null);var W=u.extent(),X=o.pinching||o.hoverData.dragging||o.swipePanning||o.data.wheelZooming||o.hoverData.draggingEles||o.cy.animated(),j=o.hideEdgesOnViewport&&X,K=[];if(K[o.NODE]=!f[o.NODE]&&p&&!o.clearedForMotionBlur[o.NODE]||o.clearingMotionBlur,K[o.NODE]&&(o.clearedForMotionBlur[o.NODE]=!0),K[o.DRAG]=!f[o.DRAG]&&p&&!o.clearedForMotionBlur[o.DRAG]||o.clearingMotionBlur,K[o.DRAG]&&(o.clearedForMotionBlur[o.DRAG]=!0),f[o.NODE]||r||n||K[o.NODE]){var J=p&&!K[o.NODE]&&d!==1,B=e||(J?o.data.bufferContexts[o.MOTIONBLUR_BUFFER_NODE]:l.contexts[o.NODE]),ne=p&&!J?"motionBlur":void 0;k(B,ne),j?o.drawCachedNodes(B,O.nondrag,s,W):o.drawLayeredElements(B,O.nondrag,s,W),o.debug&&o.drawDebugPoints(B,O.nondrag),!r&&!p&&(f[o.NODE]=!1)}if(!n&&(f[o.DRAG]||r||K[o.DRAG])){var J=p&&!K[o.DRAG]&&d!==1,B=e||(J?o.data.bufferContexts[o.MOTIONBLUR_BUFFER_DRAG]:l.contexts[o.DRAG]);k(B,p&&!J?"motionBlur":void 0),j?o.drawCachedNodes(B,O.drag,s,W):o.drawCachedElements(B,O.drag,s,W),o.debug&&o.drawDebugPoints(B,O.drag),!r&&!p&&(f[o.DRAG]=!1)}if(o.showFps||!n&&f[o.SELECT_BOX]&&!r){var B=e||l.contexts[o.SELECT_BOX];if(k(B),o.selection[4]==1&&(o.hoverData.selecting||o.touchData.selecting)){var E=o.cy.zoom(),ie=T.core("selection-box-border-width").value/E;B.lineWidth=ie,B.fillStyle="rgba("+T.core("selection-box-color").value[0]+","+T.core("selection-box-color").value[1]+","+T.core("selection-box-color").value[2]+","+T.core("selection-box-opacity").value+")",B.fillRect(o.selection[0],o.selection[1],o.selection[2]-o.selection[0],o.selection[3]-o.selection[1]),ie>0&&(B.strokeStyle="rgba("+T.core("selection-box-border-color").value[0]+","+T.core("selection-box-border-color").value[1]+","+T.core("selection-box-border-color").value[2]+","+T.core("selection-box-opacity").value+")",B.strokeRect(o.selection[0],o.selection[1],o.selection[2]-o.selection[0],o.selection[3]-o.selection[1]))}if(l.bgActivePosistion&&!o.hoverData.selecting){var E=o.cy.zoom(),oe=l.bgActivePosistion;B.fillStyle="rgba("+T.core("active-bg-color").value[0]+","+T.core("active-bg-color").value[1]+","+T.core("active-bg-color").value[2]+","+T.core("active-bg-opacity").value+")",B.beginPath(),B.arc(oe.x,oe.y,T.core("active-bg-size").pfValue/E,0,2*Math.PI),B.fill()}var ue=o.lastRedrawTime;if(o.showFps&&ue){ue=Math.round(ue);var Z=Math.round(1e3/ue);B.setTransform(1,0,0,1,0,0),B.fillStyle="rgba(255, 0, 0, 0.75)",B.strokeStyle="rgba(255, 0, 0, 0.75)",B.lineWidth=1,B.fillText("1 frame = "+ue+" ms = "+Z+" fps",0,20);var fe=60;B.strokeRect(0,30,250,20),B.fillRect(0,30,250*Math.min(Z/fe,1),20)}r||(f[o.SELECT_BOX]=!1)}if(p&&d!==1){var ce=l.contexts[o.NODE],be=o.data.bufferCanvases[o.MOTIONBLUR_BUFFER_NODE],Ce=l.contexts[o.DRAG],Fe=o.data.bufferCanvases[o.MOTIONBLUR_BUFFER_DRAG],He=function(le,me,xe){le.setTransform(1,0,0,1,0,0),xe||!b?le.clearRect(0,0,o.canvasWidth,o.canvasHeight):R(le,0,0,o.canvasWidth,o.canvasHeight);var pe=d;le.drawImage(me,0,0,o.canvasWidth*pe,o.canvasHeight*pe,0,0,o.canvasWidth,o.canvasHeight)};(f[o.NODE]||K[o.NODE])&&(He(ce,be,K[o.NODE]),f[o.NODE]=!1),(f[o.DRAG]||K[o.DRAG])&&(He(Ce,Fe,K[o.DRAG]),f[o.DRAG]=!1)}o.prevViewport=v,o.clearingMotionBlur&&(o.clearingMotionBlur=!1,o.motionBlurCleared=!0,o.motionBlur=!0),p&&(o.motionBlurTimeout=setTimeout(function(){o.motionBlurTimeout=null,o.clearedForMotionBlur[o.NODE]=!1,o.clearedForMotionBlur[o.DRAG]=!1,o.motionBlur=!1,o.clearingMotionBlur=!h,o.mbFrames=0,f[o.NODE]=!0,f[o.DRAG]=!0,o.redraw()},Ib)),e||u.emit("render")};var cn={};cn.drawPolygonPath=function(t,e,r,n,a,i){var o=n/2,s=a/2;t.beginPath&&t.beginPath(),t.moveTo(e+o*i[0],r+s*i[1]);for(var u=1;u0&&o>0){d.clearRect(0,0,i,o),d.globalCompositeOperation="source-over";var g=this.getCachedZSortedEles();if(t.full)d.translate(-n.x1*l,-n.y1*l),d.scale(l,l),this.drawElements(d,g),d.scale(1/l,1/l),d.translate(n.x1*l,n.y1*l);else{var m=e.pan(),w={x:m.x*l,y:m.y*l};l*=e.zoom(),d.translate(w.x,w.y),d.scale(l,l),this.drawElements(d,g),d.scale(1/l,1/l),d.translate(-w.x,-w.y)}t.bg&&(d.globalCompositeOperation="destination-over",d.fillStyle=t.bg,d.rect(0,0,i,o),d.fill())}return p};function kb(t,e){for(var r=atob(t),n=new ArrayBuffer(r.length),a=new Uint8Array(n),i=0;i"u"?"undefined":Ot(OffscreenCanvas))!=="undefined"?r=new OffscreenCanvas(t,e):(r=document.createElement("canvas"),r.width=t,r.height=e),r};[Af,kr,Vr,bs,An,aa,lr,cn,Xa,kf].forEach(function(t){$e(st,t)});var Bb=[{name:"null",impl:mf},{name:"base",impl:Df},{name:"canvas",impl:Rb}],Fb=[{type:"layout",extensions:U0},{type:"renderer",extensions:Bb}],Pf={},Bf={};function Ff(t,e,r){var n=r,a=function(L){lt("Can not register `"+e+"` for `"+t+"` since `"+L+"` already exists in the prototype and can not be overridden")};if(t==="core"){if(Pa.prototype[e])return a(e);Pa.prototype[e]=r}else if(t==="collection"){if(qt.prototype[e])return a(e);qt.prototype[e]=r}else if(t==="layout"){for(var i=function(L){this.options=L,r.call(this,L),ot(this._private)||(this._private={}),this._private.cy=L.cy,this._private.listeners=[],this.createEmitter()},o=i.prototype=Object.create(r.prototype),s=[],u=0;ug&&(this.rect.x-=(this.labelWidth-g)/2,this.setWidth(this.labelWidth)),this.labelHeight>m&&(this.labelPos=="center"?this.rect.y-=(this.labelHeight-m)/2:this.labelPos=="top"&&(this.rect.y-=this.labelHeight-m),this.setHeight(this.labelHeight))}}},h.prototype.getInclusionTreeDepth=function(){if(this.inclusionTreeDepth==o.MAX_VALUE)throw"assert failed";return this.inclusionTreeDepth},h.prototype.transform=function(d){var g=this.rect.x;g>u.WORLD_BOUNDARY?g=u.WORLD_BOUNDARY:g<-u.WORLD_BOUNDARY&&(g=-u.WORLD_BOUNDARY);var m=this.rect.y;m>u.WORLD_BOUNDARY?m=u.WORLD_BOUNDARY:m<-u.WORLD_BOUNDARY&&(m=-u.WORLD_BOUNDARY);var w=new f(g,m),b=d.inverseTransformPoint(w);this.setLocation(b.x,b.y)},h.prototype.getLeft=function(){return this.rect.x},h.prototype.getRight=function(){return this.rect.x+this.rect.width},h.prototype.getTop=function(){return this.rect.y},h.prototype.getBottom=function(){return this.rect.y+this.rect.height},h.prototype.getParent=function(){return this.owner==null?null:this.owner.getParent()},r.exports=h},function(r,n,a){function i(o,s){o==null&&s==null?(this.x=0,this.y=0):(this.x=o,this.y=s)}i.prototype.getX=function(){return this.x},i.prototype.getY=function(){return this.y},i.prototype.setX=function(o){this.x=o},i.prototype.setY=function(o){this.y=o},i.prototype.getDifference=function(o){return new DimensionD(this.x-o.x,this.y-o.y)},i.prototype.getCopy=function(){return new i(this.x,this.y)},i.prototype.translate=function(o){return this.x+=o.width,this.y+=o.height,this},r.exports=i},function(r,n,a){var i=a(2),o=a(10),s=a(0),u=a(6),l=a(3),f=a(1),h=a(13),p=a(12),d=a(11);function g(w,b,T){i.call(this,T),this.estimatedSize=o.MIN_VALUE,this.margin=s.DEFAULT_GRAPH_MARGIN,this.edges=[],this.nodes=[],this.isConnected=!1,this.parent=w,b!=null&&b instanceof u?this.graphManager=b:b!=null&&b instanceof Layout&&(this.graphManager=b.graphManager)}g.prototype=Object.create(i.prototype);for(var m in i)g[m]=i[m];g.prototype.getNodes=function(){return this.nodes},g.prototype.getEdges=function(){return this.edges},g.prototype.getGraphManager=function(){return this.graphManager},g.prototype.getParent=function(){return this.parent},g.prototype.getLeft=function(){return this.left},g.prototype.getRight=function(){return this.right},g.prototype.getTop=function(){return this.top},g.prototype.getBottom=function(){return this.bottom},g.prototype.isConnected=function(){return this.isConnected},g.prototype.add=function(w,b,T){if(b==null&&T==null){var E=w;if(this.graphManager==null)throw"Graph has no graph mgr!";if(this.getNodes().indexOf(E)>-1)throw"Node already in graph!";return E.owner=this,this.getNodes().push(E),E}else{var S=w;if(!(this.getNodes().indexOf(b)>-1&&this.getNodes().indexOf(T)>-1))throw"Source or target not in graph!";if(!(b.owner==T.owner&&b.owner==this))throw"Both owners must be this graph!";return b.owner!=T.owner?null:(S.source=b,S.target=T,S.isInterGraph=!1,this.getEdges().push(S),b.edges.push(S),T!=b&&T.edges.push(S),S)}},g.prototype.remove=function(w){var b=w;if(w instanceof l){if(b==null)throw"Node is null!";if(!(b.owner!=null&&b.owner==this))throw"Owner graph is invalid!";if(this.graphManager==null)throw"Owner graph manager is invalid!";for(var T=b.edges.slice(),E,S=T.length,A=0;A-1&&L>-1))throw"Source and/or target doesn't know this edge!";E.source.edges.splice(v,1),E.target!=E.source&&E.target.edges.splice(L,1);var I=E.source.owner.getEdges().indexOf(E);if(I==-1)throw"Not in owner's edge list!";E.source.owner.getEdges().splice(I,1)}},g.prototype.updateLeftTop=function(){for(var w=o.MAX_VALUE,b=o.MAX_VALUE,T,E,S,A=this.getNodes(),I=A.length,v=0;vT&&(w=T),b>E&&(b=E)}return w==o.MAX_VALUE?null:(A[0].getParent().paddingLeft!=null?S=A[0].getParent().paddingLeft:S=this.margin,this.left=b-S,this.top=w-S,new p(this.left,this.top))},g.prototype.updateBounds=function(w){for(var b=o.MAX_VALUE,T=-o.MAX_VALUE,E=o.MAX_VALUE,S=-o.MAX_VALUE,A,I,v,L,D,O=this.nodes,R=O.length,k=0;kA&&(b=A),Tv&&(E=v),SA&&(b=A),Tv&&(E=v),S=this.nodes.length){var R=0;T.forEach(function(k){k.owner==w&&R++}),R==this.nodes.length&&(this.isConnected=!0)}},r.exports=g},function(r,n,a){var i,o=a(1);function s(u){i=a(5),this.layout=u,this.graphs=[],this.edges=[]}s.prototype.addRoot=function(){var u=this.layout.newGraph(),l=this.layout.newNode(null),f=this.add(u,l);return this.setRootGraph(f),this.rootGraph},s.prototype.add=function(u,l,f,h,p){if(f==null&&h==null&&p==null){if(u==null)throw"Graph is null!";if(l==null)throw"Parent node is null!";if(this.graphs.indexOf(u)>-1)throw"Graph already in this graph mgr!";if(this.graphs.push(u),u.parent!=null)throw"Already has a parent!";if(l.child!=null)throw"Already has a child!";return u.parent=l,l.child=u,u}else{p=f,h=l,f=u;var d=h.getOwner(),g=p.getOwner();if(!(d!=null&&d.getGraphManager()==this))throw"Source not in this graph mgr!";if(!(g!=null&&g.getGraphManager()==this))throw"Target not in this graph mgr!";if(d==g)return f.isInterGraph=!1,d.add(f,h,p);if(f.isInterGraph=!0,f.source=h,f.target=p,this.edges.indexOf(f)>-1)throw"Edge already in inter-graph edge list!";if(this.edges.push(f),!(f.source!=null&&f.target!=null))throw"Edge source and/or target is null!";if(!(f.source.edges.indexOf(f)==-1&&f.target.edges.indexOf(f)==-1))throw"Edge already in source and/or target incidency list!";return f.source.edges.push(f),f.target.edges.push(f),f}},s.prototype.remove=function(u){if(u instanceof i){var l=u;if(l.getGraphManager()!=this)throw"Graph not in this graph mgr";if(!(l==this.rootGraph||l.parent!=null&&l.parent.graphManager==this))throw"Invalid parent node!";var f=[];f=f.concat(l.getEdges());for(var h,p=f.length,d=0;d=u.getRight()?l[0]+=Math.min(u.getX()-s.getX(),s.getRight()-u.getRight()):u.getX()<=s.getX()&&u.getRight()>=s.getRight()&&(l[0]+=Math.min(s.getX()-u.getX(),u.getRight()-s.getRight())),s.getY()<=u.getY()&&s.getBottom()>=u.getBottom()?l[1]+=Math.min(u.getY()-s.getY(),s.getBottom()-u.getBottom()):u.getY()<=s.getY()&&u.getBottom()>=s.getBottom()&&(l[1]+=Math.min(s.getY()-u.getY(),u.getBottom()-s.getBottom()));var p=Math.abs((u.getCenterY()-s.getCenterY())/(u.getCenterX()-s.getCenterX()));u.getCenterY()===s.getCenterY()&&u.getCenterX()===s.getCenterX()&&(p=1);var d=p*l[0],g=l[1]/p;l[0]d)return l[0]=f,l[1]=m,l[2]=p,l[3]=O,!1;if(hp)return l[0]=g,l[1]=h,l[2]=L,l[3]=d,!1;if(fp?(l[0]=b,l[1]=T,B=!0):(l[0]=w,l[1]=m,B=!0):H===W&&(f>p?(l[0]=g,l[1]=m,B=!0):(l[0]=E,l[1]=T,B=!0)),-V===W?p>f?(l[2]=D,l[3]=O,U=!0):(l[2]=L,l[3]=v,U=!0):V===W&&(p>f?(l[2]=I,l[3]=v,U=!0):(l[2]=R,l[3]=O,U=!0)),B&&U)return!1;if(f>p?h>d?(X=this.getCardinalDirection(H,W,4),j=this.getCardinalDirection(V,W,2)):(X=this.getCardinalDirection(-H,W,3),j=this.getCardinalDirection(-V,W,1)):h>d?(X=this.getCardinalDirection(-H,W,1),j=this.getCardinalDirection(-V,W,3)):(X=this.getCardinalDirection(H,W,2),j=this.getCardinalDirection(V,W,4)),!B)switch(X){case 1:J=m,K=f+-A/W,l[0]=K,l[1]=J;break;case 2:K=E,J=h+S*W,l[0]=K,l[1]=J;break;case 3:J=T,K=f+A/W,l[0]=K,l[1]=J;break;case 4:K=b,J=h+-S*W,l[0]=K,l[1]=J;break}if(!U)switch(j){case 1:ie=v,ne=p+-z/W,l[2]=ne,l[3]=ie;break;case 2:ne=R,ie=d+k*W,l[2]=ne,l[3]=ie;break;case 3:ie=O,ne=p+z/W,l[2]=ne,l[3]=ie;break;case 4:ne=D,ie=d+-k*W,l[2]=ne,l[3]=ie;break}}return!1},o.getCardinalDirection=function(s,u,l){return s>u?l:1+l%4},o.getIntersection=function(s,u,l,f){if(f==null)return this.getIntersection2(s,u,l);var h=s.x,p=s.y,d=u.x,g=u.y,m=l.x,w=l.y,b=f.x,T=f.y,E=void 0,S=void 0,A=void 0,I=void 0,v=void 0,L=void 0,D=void 0,O=void 0,R=void 0;return A=g-p,v=h-d,D=d*p-h*g,I=T-w,L=m-b,O=b*w-m*T,R=A*L-I*v,R===0?null:(E=(v*O-L*D)/R,S=(I*D-A*O)/R,new i(E,S))},o.angleOfVector=function(s,u,l,f){var h=void 0;return s!==l?(h=Math.atan((f-u)/(l-s)),l0?1:o<0?-1:0},i.floor=function(o){return o<0?Math.ceil(o):Math.floor(o)},i.ceil=function(o){return o<0?Math.floor(o):Math.ceil(o)},r.exports=i},function(r,n,a){function i(){}i.MAX_VALUE=2147483647,i.MIN_VALUE=-2147483648,r.exports=i},function(r,n,a){var i=function(){function h(p,d){for(var g=0;g"u"?"undefined":i(s);return s==null||u!="object"&&u!="function"},r.exports=o},function(r,n,a){function i(m){if(Array.isArray(m)){for(var w=0,b=Array(m.length);w0&&w;){for(A.push(v[0]);A.length>0&&w;){var L=A[0];A.splice(0,1),S.add(L);for(var D=L.getEdges(),E=0;E-1&&v.splice(z,1)}S=new Set,I=new Map}}return m},g.prototype.createDummyNodesForBendpoints=function(m){for(var w=[],b=m.source,T=this.graphManager.calcLowestCommonAncestor(m.source,m.target),E=0;E0){for(var T=this.edgeToDummyNodes.get(b),E=0;E=0&&w.splice(O,1);var R=I.getNeighborsList();R.forEach(function(B){if(b.indexOf(B)<0){var U=T.get(B),H=U-1;H==1&&L.push(B),T.set(B,H)}})}b=b.concat(L),(w.length==1||w.length==2)&&(E=!0,S=w[0])}return S},g.prototype.setGraphManager=function(m){this.graphManager=m},r.exports=g},function(r,n,a){function i(){}i.seed=1,i.x=0,i.nextDouble=function(){return i.x=Math.sin(i.seed++)*1e4,i.x-Math.floor(i.x)},r.exports=i},function(r,n,a){var i=a(4);function o(s,u){this.lworldOrgX=0,this.lworldOrgY=0,this.ldeviceOrgX=0,this.ldeviceOrgY=0,this.lworldExtX=1,this.lworldExtY=1,this.ldeviceExtX=1,this.ldeviceExtY=1}o.prototype.getWorldOrgX=function(){return this.lworldOrgX},o.prototype.setWorldOrgX=function(s){this.lworldOrgX=s},o.prototype.getWorldOrgY=function(){return this.lworldOrgY},o.prototype.setWorldOrgY=function(s){this.lworldOrgY=s},o.prototype.getWorldExtX=function(){return this.lworldExtX},o.prototype.setWorldExtX=function(s){this.lworldExtX=s},o.prototype.getWorldExtY=function(){return this.lworldExtY},o.prototype.setWorldExtY=function(s){this.lworldExtY=s},o.prototype.getDeviceOrgX=function(){return this.ldeviceOrgX},o.prototype.setDeviceOrgX=function(s){this.ldeviceOrgX=s},o.prototype.getDeviceOrgY=function(){return this.ldeviceOrgY},o.prototype.setDeviceOrgY=function(s){this.ldeviceOrgY=s},o.prototype.getDeviceExtX=function(){return this.ldeviceExtX},o.prototype.setDeviceExtX=function(s){this.ldeviceExtX=s},o.prototype.getDeviceExtY=function(){return this.ldeviceExtY},o.prototype.setDeviceExtY=function(s){this.ldeviceExtY=s},o.prototype.transformX=function(s){var u=0,l=this.lworldExtX;return l!=0&&(u=this.ldeviceOrgX+(s-this.lworldOrgX)*this.ldeviceExtX/l),u},o.prototype.transformY=function(s){var u=0,l=this.lworldExtY;return l!=0&&(u=this.ldeviceOrgY+(s-this.lworldOrgY)*this.ldeviceExtY/l),u},o.prototype.inverseTransformX=function(s){var u=0,l=this.ldeviceExtX;return l!=0&&(u=this.lworldOrgX+(s-this.ldeviceOrgX)*this.lworldExtX/l),u},o.prototype.inverseTransformY=function(s){var u=0,l=this.ldeviceExtY;return l!=0&&(u=this.lworldOrgY+(s-this.ldeviceOrgY)*this.lworldExtY/l),u},o.prototype.inverseTransformPoint=function(s){var u=new i(this.inverseTransformX(s.x),this.inverseTransformY(s.y));return u},r.exports=o},function(r,n,a){function i(d){if(Array.isArray(d)){for(var g=0,m=Array(d.length);gs.ADAPTATION_LOWER_NODE_LIMIT&&(this.coolingFactor=Math.max(this.coolingFactor*s.COOLING_ADAPTATION_FACTOR,this.coolingFactor-(d-s.ADAPTATION_LOWER_NODE_LIMIT)/(s.ADAPTATION_UPPER_NODE_LIMIT-s.ADAPTATION_LOWER_NODE_LIMIT)*this.coolingFactor*(1-s.COOLING_ADAPTATION_FACTOR))),this.maxNodeDisplacement=s.MAX_NODE_DISPLACEMENT_INCREMENTAL):(d>s.ADAPTATION_LOWER_NODE_LIMIT?this.coolingFactor=Math.max(s.COOLING_ADAPTATION_FACTOR,1-(d-s.ADAPTATION_LOWER_NODE_LIMIT)/(s.ADAPTATION_UPPER_NODE_LIMIT-s.ADAPTATION_LOWER_NODE_LIMIT)*(1-s.COOLING_ADAPTATION_FACTOR)):this.coolingFactor=1,this.initialCoolingFactor=this.coolingFactor,this.maxNodeDisplacement=s.MAX_NODE_DISPLACEMENT),this.maxIterations=Math.max(this.getAllNodes().length*5,this.maxIterations),this.totalDisplacementThreshold=this.displacementThresholdPerNode*this.getAllNodes().length,this.repulsionRange=this.calcRepulsionRange()},h.prototype.calcSpringForces=function(){for(var d=this.getAllEdges(),g,m=0;m0&&arguments[0]!==void 0?arguments[0]:!0,g=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,m,w,b,T,E=this.getAllNodes(),S;if(this.useFRGridVariant)for(this.totalIterations%s.GRID_CALCULATION_CHECK_PERIOD==1&&d&&this.updateGrid(),S=new Set,m=0;mA||S>A)&&(d.gravitationForceX=-this.gravityConstant*b,d.gravitationForceY=-this.gravityConstant*T)):(A=g.getEstimatedSize()*this.compoundGravityRangeFactor,(E>A||S>A)&&(d.gravitationForceX=-this.gravityConstant*b*this.compoundGravityConstant,d.gravitationForceY=-this.gravityConstant*T*this.compoundGravityConstant))},h.prototype.isConverged=function(){var d,g=!1;return this.totalIterations>this.maxIterations/3&&(g=Math.abs(this.totalDisplacement-this.oldTotalDisplacement)<2),d=this.totalDisplacement=E.length||A>=E[0].length)){for(var I=0;Ih}}]),l}();r.exports=u},function(r,n,a){var i=function(){function u(l,f){for(var h=0;h2&&arguments[2]!==void 0?arguments[2]:1,p=arguments.length>3&&arguments[3]!==void 0?arguments[3]:-1,d=arguments.length>4&&arguments[4]!==void 0?arguments[4]:-1;o(this,u),this.sequence1=l,this.sequence2=f,this.match_score=h,this.mismatch_penalty=p,this.gap_penalty=d,this.iMax=l.length+1,this.jMax=f.length+1,this.grid=new Array(this.iMax);for(var g=0;g=0;l--){var f=this.listeners[l];f.event===s&&f.callback===u&&this.listeners.splice(l,1)}},o.emit=function(s,u){for(var l=0;lf.coolingFactor*f.maxNodeDisplacement&&(this.displacementX=f.coolingFactor*f.maxNodeDisplacement*s.sign(this.displacementX)),Math.abs(this.displacementY)>f.coolingFactor*f.maxNodeDisplacement&&(this.displacementY=f.coolingFactor*f.maxNodeDisplacement*s.sign(this.displacementY)),this.child==null?this.moveBy(this.displacementX,this.displacementY):this.child.getNodes().length==0?this.moveBy(this.displacementX,this.displacementY):this.propogateDisplacementToChildren(this.displacementX,this.displacementY),f.totalDisplacement+=Math.abs(this.displacementX)+Math.abs(this.displacementY),this.springForceX=0,this.springForceY=0,this.repulsionForceX=0,this.repulsionForceY=0,this.gravitationForceX=0,this.gravitationForceY=0,this.displacementX=0,this.displacementY=0},u.prototype.propogateDisplacementToChildren=function(f,h){for(var p=this.getChild().getNodes(),d,g=0;g0)this.positionNodesRadially(v);else{this.reduceTrees(),this.graphManager.resetAllNodesToApplyGravitation();var L=new Set(this.getAllNodes()),D=this.nodesWithGravity.filter(function(O){return L.has(O)});this.graphManager.setAllNodesToApplyGravitation(D),this.positionNodesRandomly()}}return this.initSpringEmbedder(),this.runSpringEmbedder(),!0},A.prototype.tick=function(){if(this.totalIterations++,this.totalIterations===this.maxIterations&&!this.isTreeGrowing&&!this.isGrowthFinished)if(this.prunedNodesAll.length>0)this.isTreeGrowing=!0;else return!0;if(this.totalIterations%p.CONVERGENCE_CHECK_PERIOD==0&&!this.isTreeGrowing&&!this.isGrowthFinished){if(this.isConverged())if(this.prunedNodesAll.length>0)this.isTreeGrowing=!0;else return!0;this.coolingCycle++,this.layoutQuality==0?this.coolingAdjuster=this.coolingCycle:this.layoutQuality==1&&(this.coolingAdjuster=this.coolingCycle/3),this.coolingFactor=Math.max(this.initialCoolingFactor-Math.pow(this.coolingCycle,Math.log(100*(this.initialCoolingFactor-this.finalTemperature))/Math.log(this.maxCoolingCycle))/100*this.coolingAdjuster,this.finalTemperature),this.animationPeriod=Math.ceil(this.initialAnimationPeriod*Math.sqrt(this.coolingFactor))}if(this.isTreeGrowing){if(this.growTreeIterations%10==0)if(this.prunedNodesAll.length>0){this.graphManager.updateBounds(),this.updateGrid(),this.growTree(this.prunedNodesAll),this.graphManager.resetAllNodesToApplyGravitation();var v=new Set(this.getAllNodes()),L=this.nodesWithGravity.filter(function(R){return v.has(R)});this.graphManager.setAllNodesToApplyGravitation(L),this.graphManager.updateBounds(),this.updateGrid(),this.coolingFactor=p.DEFAULT_COOLING_FACTOR_INCREMENTAL}else this.isTreeGrowing=!1,this.isGrowthFinished=!0;this.growTreeIterations++}if(this.isGrowthFinished){if(this.isConverged())return!0;this.afterGrowthIterations%10==0&&(this.graphManager.updateBounds(),this.updateGrid()),this.coolingFactor=p.DEFAULT_COOLING_FACTOR_INCREMENTAL*((100-this.afterGrowthIterations)/100),this.afterGrowthIterations++}var D=!this.isTreeGrowing&&!this.isGrowthFinished,O=this.growTreeIterations%10==1&&this.isTreeGrowing||this.afterGrowthIterations%10==1&&this.isGrowthFinished;return this.totalDisplacement=0,this.graphManager.updateBounds(),this.calcSpringForces(),this.calcRepulsionForces(D,O),this.calcGravitationalForces(),this.moveNodes(),this.animate(),!1},A.prototype.getPositionsData=function(){for(var v=this.graphManager.getAllNodes(),L={},D=0;D1){var B;for(B=0;BO&&(O=Math.floor(z.y)),k=Math.floor(z.x+h.DEFAULT_COMPONENT_SEPERATION)}this.transform(new m(d.WORLD_CENTER_X-z.x/2,d.WORLD_CENTER_Y-z.y/2))},A.radialLayout=function(v,L,D){var O=Math.max(this.maxDiagonalInTree(v),h.DEFAULT_RADIAL_SEPARATION);A.branchRadialLayout(L,null,0,359,0,O);var R=E.calculateBounds(v),k=new S;k.setDeviceOrgX(R.getMinX()),k.setDeviceOrgY(R.getMinY()),k.setWorldOrgX(D.x),k.setWorldOrgY(D.y);for(var z=0;z1;){var ie=ne[0];ne.splice(0,1);var oe=W.indexOf(ie);oe>=0&&W.splice(oe,1),K--,X--}L!=null?J=(W.indexOf(ne[0])+1)%K:J=0;for(var ue=Math.abs(O-D)/X,Z=J;j!=X;Z=++Z%K){var fe=W[Z].getOtherEnd(v);if(fe!=L){var ce=(D+j*ue)%360,be=(ce+ue)%360;A.branchRadialLayout(fe,v,ce,be,R+k,k),j++}}},A.maxDiagonalInTree=function(v){for(var L=b.MIN_VALUE,D=0;DL&&(L=R)}return L},A.prototype.calcRepulsionRange=function(){return 2*(this.level+1)*this.idealEdgeLength},A.prototype.groupZeroDegreeMembers=function(){var v=this,L={};this.memberGroups={},this.idToDummyNode={};for(var D=[],O=this.graphManager.getAllNodes(),R=0;R"u"&&(L[B]=[]),L[B]=L[B].concat(k)}Object.keys(L).forEach(function(U){if(L[U].length>1){var H="DummyCompound_"+U;v.memberGroups[H]=L[U];var V=L[U][0].getParent(),W=new l(v.graphManager);W.id=H,W.paddingLeft=V.paddingLeft||0,W.paddingRight=V.paddingRight||0,W.paddingBottom=V.paddingBottom||0,W.paddingTop=V.paddingTop||0,v.idToDummyNode[H]=W;var X=v.getGraphManager().add(v.newGraph(),W),j=V.getChild();j.add(W);for(var K=0;K=0;v--){var L=this.compoundOrder[v],D=L.id,O=L.paddingLeft,R=L.paddingTop;this.adjustLocations(this.tiledMemberPack[D],L.rect.x,L.rect.y,O,R)}},A.prototype.repopulateZeroDegreeMembers=function(){var v=this,L=this.tiledZeroDegreePack;Object.keys(L).forEach(function(D){var O=v.idToDummyNode[D],R=O.paddingLeft,k=O.paddingTop;v.adjustLocations(L[D],O.rect.x,O.rect.y,R,k)})},A.prototype.getToBeTiled=function(v){var L=v.id;if(this.toBeTiled[L]!=null)return this.toBeTiled[L];var D=v.getChild();if(D==null)return this.toBeTiled[L]=!1,!1;for(var O=D.getNodes(),R=0;R0)return this.toBeTiled[L]=!1,!1;if(k.getChild()==null){this.toBeTiled[k.id]=!1;continue}if(!this.getToBeTiled(k))return this.toBeTiled[L]=!1,!1}return this.toBeTiled[L]=!0,!0},A.prototype.getNodeDegree=function(v){v.id;for(var L=v.getEdges(),D=0,O=0;OU&&(U=V.rect.height)}D+=U+v.verticalPadding}},A.prototype.tileCompoundMembers=function(v,L){var D=this;this.tiledMemberPack=[],Object.keys(v).forEach(function(O){var R=L[O];D.tiledMemberPack[O]=D.tileNodes(v[O],R.paddingLeft+R.paddingRight),R.rect.width=D.tiledMemberPack[O].width,R.rect.height=D.tiledMemberPack[O].height})},A.prototype.tileNodes=function(v,L){var D=h.TILING_PADDING_VERTICAL,O=h.TILING_PADDING_HORIZONTAL,R={rows:[],rowWidth:[],rowHeight:[],width:0,height:L,verticalPadding:D,horizontalPadding:O};v.sort(function(B,U){return B.rect.width*B.rect.height>U.rect.width*U.rect.height?-1:B.rect.width*B.rect.height0&&(z+=v.horizontalPadding),v.rowWidth[D]=z,v.width0&&(B+=v.verticalPadding);var U=0;B>v.rowHeight[D]&&(U=v.rowHeight[D],v.rowHeight[D]=B,U=v.rowHeight[D]-U),v.height+=U,v.rows[D].push(L)},A.prototype.getShortestRowIndex=function(v){for(var L=-1,D=Number.MAX_VALUE,O=0;OD&&(L=O,D=v.rowWidth[O]);return L},A.prototype.canAddHorizontal=function(v,L,D){var O=this.getShortestRowIndex(v);if(O<0)return!0;var R=v.rowWidth[O];if(R+v.horizontalPadding+L<=v.width)return!0;var k=0;v.rowHeight[O]0&&(k=D+v.verticalPadding-v.rowHeight[O]);var z;v.width-R>=L+v.horizontalPadding?z=(v.height+k)/(R+L+v.horizontalPadding):z=(v.height+k)/v.width,k=D+v.verticalPadding;var B;return v.widthk&&L!=D){O.splice(-1,1),v.rows[D].push(R),v.rowWidth[L]=v.rowWidth[L]-k,v.rowWidth[D]=v.rowWidth[D]+k,v.width=v.rowWidth[instance.getLongestRowIndex(v)];for(var z=Number.MIN_VALUE,B=0;Bz&&(z=O[B].height);L>0&&(z+=v.verticalPadding);var U=v.rowHeight[L]+v.rowHeight[D];v.rowHeight[L]=z,v.rowHeight[D]0)for(var j=R;j<=k;j++)X[0]+=this.grid[j][z-1].length+this.grid[j][z].length-1;if(k0)for(var j=z;j<=B;j++)X[3]+=this.grid[R-1][j].length+this.grid[R][j].length-1;for(var K=b.MAX_VALUE,J,ne,ie=0;ie0){var B;B=S.getGraphManager().add(S.newGraph(),D),this.processChildrenList(B,L,S)}}},m.prototype.stop=function(){return this.stopped=!0,this};var b=function(E){E("layout","cose-bilkent",m)};typeof cytoscape<"u"&&b(cytoscape),n.exports=b}])})})(qb);const Wb=mc(Xo);var _o={},Xb={get exports(){return _o},set exports(t){_o=t}},ki={},_b={get exports(){return ki},set exports(t){ki=t}};/*! - * jQuery JavaScript Library v3.7.1 - * https://jquery.com/ - * - * Copyright OpenJS Foundation and other contributors - * Released under the MIT license - * https://jquery.org/license - * - * Date: 2023-08-28T13:37Z - */var nl;function Kb(){return nl||(nl=1,function(t){(function(e,r){t.exports=e.document?r(e,!0):function(n){if(!n.document)throw new Error("jQuery requires a window with a document");return r(n)}})(typeof window<"u"?window:zr,function(e,r){var n=[],a=Object.getPrototypeOf,i=n.slice,o=n.flat?function(c){return n.flat.call(c)}:function(c){return n.concat.apply([],c)},s=n.push,u=n.indexOf,l={},f=l.toString,h=l.hasOwnProperty,p=h.toString,d=p.call(Object),g={},m=function(y){return typeof y=="function"&&typeof y.nodeType!="number"&&typeof y.item!="function"},w=function(y){return y!=null&&y===y.window},b=e.document,T={type:!0,src:!0,nonce:!0,noModule:!0};function E(c,y,x){x=x||b;var C,M,N=x.createElement("script");if(N.text=c,y)for(C in T)M=y[C]||y.getAttribute&&y.getAttribute(C),M&&N.setAttribute(C,M);x.head.appendChild(N).parentNode.removeChild(N)}function S(c){return c==null?c+"":typeof c=="object"||typeof c=="function"?l[f.call(c)]||"object":typeof c}var A="3.7.1",I=/HTML$/i,v=function(c,y){return new v.fn.init(c,y)};v.fn=v.prototype={jquery:A,constructor:v,length:0,toArray:function(){return i.call(this)},get:function(c){return c==null?i.call(this):c<0?this[c+this.length]:this[c]},pushStack:function(c){var y=v.merge(this.constructor(),c);return y.prevObject=this,y},each:function(c){return v.each(this,c)},map:function(c){return this.pushStack(v.map(this,function(y,x){return c.call(y,x,y)}))},slice:function(){return this.pushStack(i.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},even:function(){return this.pushStack(v.grep(this,function(c,y){return(y+1)%2}))},odd:function(){return this.pushStack(v.grep(this,function(c,y){return y%2}))},eq:function(c){var y=this.length,x=+c+(c<0?y:0);return this.pushStack(x>=0&&x0&&y-1 in c}function D(c,y){return c.nodeName&&c.nodeName.toLowerCase()===y.toLowerCase()}var O=n.pop,R=n.sort,k=n.splice,z="[\\x20\\t\\r\\n\\f]",B=new RegExp("^"+z+"+|((?:^|[^\\\\])(?:\\\\.)*)"+z+"+$","g");v.contains=function(c,y){var x=y&&y.parentNode;return c===x||!!(x&&x.nodeType===1&&(c.contains?c.contains(x):c.compareDocumentPosition&&c.compareDocumentPosition(x)&16))};var U=/([\0-\x1f\x7f]|^-?\d)|^-$|[^\x80-\uFFFF\w-]/g;function H(c,y){return y?c==="\0"?"�":c.slice(0,-1)+"\\"+c.charCodeAt(c.length-1).toString(16)+" ":"\\"+c}v.escapeSelector=function(c){return(c+"").replace(U,H)};var V=b,W=s;(function(){var c,y,x,C,M,N=W,P,Y,q,Q,se,ve=v.expando,re=0,Te=0,Xe=ei(),rt=ei(),Qe=ei(),Ft=ei(),At=function(G,_){return G===_&&(M=!0),0},Cr="checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",Dr="(?:\\\\[\\da-fA-F]{1,6}"+z+"?|\\\\[^\\r\\n\\f]|[\\w-]|[^\0-\\x7f])+",tt="\\["+z+"*("+Dr+")(?:"+z+"*([*^$|!~]?=)"+z+`*(?:'((?:\\\\.|[^\\\\'])*)'|"((?:\\\\.|[^\\\\"])*)"|(`+Dr+"))|)"+z+"*\\]",pn=":("+Dr+`)(?:\\((('((?:\\\\.|[^\\\\'])*)'|"((?:\\\\.|[^\\\\"])*)")|((?:\\\\.|[^\\\\()[\\]]|`+tt+")*)|.*)\\)|)",at=new RegExp(z+"+","g"),xt=new RegExp("^"+z+"*,"+z+"*"),ca=new RegExp("^"+z+"*([>+~]|"+z+")"+z+"*"),ho=new RegExp(z+"|>"),Sr=new RegExp(pn),ha=new RegExp("^"+Dr+"$"),Lr={ID:new RegExp("^#("+Dr+")"),CLASS:new RegExp("^\\.("+Dr+")"),TAG:new RegExp("^("+Dr+"|[*])"),ATTR:new RegExp("^"+tt),PSEUDO:new RegExp("^"+pn),CHILD:new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+z+"*(even|odd|(([+-]|)(\\d*)n|)"+z+"*(?:([+-]|)"+z+"*(\\d+)|))"+z+"*\\)|)","i"),bool:new RegExp("^(?:"+Cr+")$","i"),needsContext:new RegExp("^"+z+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+z+"*((?:-\\d)?\\d*)"+z+"*\\)|)(?=[^-]|$)","i")},_r=/^(?:input|select|textarea|button)$/i,Kr=/^h\d$/i,hr=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,vo=/[+~]/,Br=new RegExp("\\\\[\\da-fA-F]{1,6}"+z+"?|\\\\([^\\r\\n\\f])","g"),Fr=function(G,_){var te="0x"+G.slice(1)-65536;return _||(te<0?String.fromCharCode(te+65536):String.fromCharCode(te>>10|55296,te&1023|56320))},cc=function(){Zr()},hc=ri(function(G){return G.disabled===!0&&D(G,"fieldset")},{dir:"parentNode",next:"legend"});function vc(){try{return P.activeElement}catch{}}try{N.apply(n=i.call(V.childNodes),V.childNodes),n[V.childNodes.length].nodeType}catch{N={apply:function(_,te){W.apply(_,i.call(te))},call:function(_){W.apply(_,i.call(arguments,1))}}}function ct(G,_,te,ae){var he,Le,Ne,Be,Oe,Je,Ue,_e=_&&_.ownerDocument,et=_?_.nodeType:9;if(te=te||[],typeof G!="string"||!G||et!==1&&et!==9&&et!==11)return te;if(!ae&&(Zr(_),_=_||P,q)){if(et!==11&&(Oe=hr.exec(G)))if(he=Oe[1]){if(et===9)if(Ne=_.getElementById(he)){if(Ne.id===he)return N.call(te,Ne),te}else return te;else if(_e&&(Ne=_e.getElementById(he))&&ct.contains(_,Ne)&&Ne.id===he)return N.call(te,Ne),te}else{if(Oe[2])return N.apply(te,_.getElementsByTagName(G)),te;if((he=Oe[3])&&_.getElementsByClassName)return N.apply(te,_.getElementsByClassName(he)),te}if(!Ft[G+" "]&&(!Q||!Q.test(G))){if(Ue=G,_e=_,et===1&&(ho.test(G)||ca.test(G))){for(_e=vo.test(G)&&go(_.parentNode)||_,(_e!=_||!g.scope)&&((Be=_.getAttribute("id"))?Be=v.escapeSelector(Be):_.setAttribute("id",Be=ve)),Je=va(G),Le=Je.length;Le--;)Je[Le]=(Be?"#"+Be:":scope")+" "+ti(Je[Le]);Ue=Je.join(",")}try{return N.apply(te,_e.querySelectorAll(Ue)),te}catch{Ft(G,!0)}finally{Be===ve&&_.removeAttribute("id")}}}return zs(G.replace(B,"$1"),_,te,ae)}function ei(){var G=[];function _(te,ae){return G.push(te+" ")>y.cacheLength&&delete _[G.shift()],_[te+" "]=ae}return _}function mr(G){return G[ve]=!0,G}function In(G){var _=P.createElement("fieldset");try{return!!G(_)}catch{return!1}finally{_.parentNode&&_.parentNode.removeChild(_),_=null}}function dc(G){return function(_){return D(_,"input")&&_.type===G}}function gc(G){return function(_){return(D(_,"input")||D(_,"button"))&&_.type===G}}function Bs(G){return function(_){return"form"in _?_.parentNode&&_.disabled===!1?"label"in _?"label"in _.parentNode?_.parentNode.disabled===G:_.disabled===G:_.isDisabled===G||_.isDisabled!==!G&&hc(_)===G:_.disabled===G:"label"in _?_.disabled===G:!1}}function yn(G){return mr(function(_){return _=+_,mr(function(te,ae){for(var he,Le=G([],te.length,_),Ne=Le.length;Ne--;)te[he=Le[Ne]]&&(te[he]=!(ae[he]=te[he]))})})}function go(G){return G&&typeof G.getElementsByTagName<"u"&&G}function Zr(G){var _,te=G?G.ownerDocument||G:V;return te==P||te.nodeType!==9||!te.documentElement||(P=te,Y=P.documentElement,q=!v.isXMLDoc(P),se=Y.matches||Y.webkitMatchesSelector||Y.msMatchesSelector,Y.msMatchesSelector&&V!=P&&(_=P.defaultView)&&_.top!==_&&_.addEventListener("unload",cc),g.getById=In(function(ae){return Y.appendChild(ae).id=v.expando,!P.getElementsByName||!P.getElementsByName(v.expando).length}),g.disconnectedMatch=In(function(ae){return se.call(ae,"*")}),g.scope=In(function(){return P.querySelectorAll(":scope")}),g.cssHas=In(function(){try{return P.querySelector(":has(*,:jqfake)"),!1}catch{return!0}}),g.getById?(y.filter.ID=function(ae){var he=ae.replace(Br,Fr);return function(Le){return Le.getAttribute("id")===he}},y.find.ID=function(ae,he){if(typeof he.getElementById<"u"&&q){var Le=he.getElementById(ae);return Le?[Le]:[]}}):(y.filter.ID=function(ae){var he=ae.replace(Br,Fr);return function(Le){var Ne=typeof Le.getAttributeNode<"u"&&Le.getAttributeNode("id");return Ne&&Ne.value===he}},y.find.ID=function(ae,he){if(typeof he.getElementById<"u"&&q){var Le,Ne,Be,Oe=he.getElementById(ae);if(Oe){if(Le=Oe.getAttributeNode("id"),Le&&Le.value===ae)return[Oe];for(Be=he.getElementsByName(ae),Ne=0;Oe=Be[Ne++];)if(Le=Oe.getAttributeNode("id"),Le&&Le.value===ae)return[Oe]}return[]}}),y.find.TAG=function(ae,he){return typeof he.getElementsByTagName<"u"?he.getElementsByTagName(ae):he.querySelectorAll(ae)},y.find.CLASS=function(ae,he){if(typeof he.getElementsByClassName<"u"&&q)return he.getElementsByClassName(ae)},Q=[],In(function(ae){var he;Y.appendChild(ae).innerHTML="",ae.querySelectorAll("[selected]").length||Q.push("\\["+z+"*(?:value|"+Cr+")"),ae.querySelectorAll("[id~="+ve+"-]").length||Q.push("~="),ae.querySelectorAll("a#"+ve+"+*").length||Q.push(".#.+[+~]"),ae.querySelectorAll(":checked").length||Q.push(":checked"),he=P.createElement("input"),he.setAttribute("type","hidden"),ae.appendChild(he).setAttribute("name","D"),Y.appendChild(ae).disabled=!0,ae.querySelectorAll(":disabled").length!==2&&Q.push(":enabled",":disabled"),he=P.createElement("input"),he.setAttribute("name",""),ae.appendChild(he),ae.querySelectorAll("[name='']").length||Q.push("\\["+z+"*name"+z+"*="+z+`*(?:''|"")`)}),g.cssHas||Q.push(":has"),Q=Q.length&&new RegExp(Q.join("|")),At=function(ae,he){if(ae===he)return M=!0,0;var Le=!ae.compareDocumentPosition-!he.compareDocumentPosition;return Le||(Le=(ae.ownerDocument||ae)==(he.ownerDocument||he)?ae.compareDocumentPosition(he):1,Le&1||!g.sortDetached&&he.compareDocumentPosition(ae)===Le?ae===P||ae.ownerDocument==V&&ct.contains(V,ae)?-1:he===P||he.ownerDocument==V&&ct.contains(V,he)?1:C?u.call(C,ae)-u.call(C,he):0:Le&4?-1:1)}),P}ct.matches=function(G,_){return ct(G,null,null,_)},ct.matchesSelector=function(G,_){if(Zr(G),q&&!Ft[_+" "]&&(!Q||!Q.test(_)))try{var te=se.call(G,_);if(te||g.disconnectedMatch||G.document&&G.document.nodeType!==11)return te}catch{Ft(_,!0)}return ct(_,P,null,[G]).length>0},ct.contains=function(G,_){return(G.ownerDocument||G)!=P&&Zr(G),v.contains(G,_)},ct.attr=function(G,_){(G.ownerDocument||G)!=P&&Zr(G);var te=y.attrHandle[_.toLowerCase()],ae=te&&h.call(y.attrHandle,_.toLowerCase())?te(G,_,!q):void 0;return ae!==void 0?ae:G.getAttribute(_)},ct.error=function(G){throw new Error("Syntax error, unrecognized expression: "+G)},v.uniqueSort=function(G){var _,te=[],ae=0,he=0;if(M=!g.sortStable,C=!g.sortStable&&i.call(G,0),R.call(G,At),M){for(;_=G[he++];)_===G[he]&&(ae=te.push(he));for(;ae--;)k.call(G,te[ae],1)}return C=null,G},v.fn.uniqueSort=function(){return this.pushStack(v.uniqueSort(i.apply(this)))},y=v.expr={cacheLength:50,createPseudo:mr,match:Lr,attrHandle:{},find:{},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(G){return G[1]=G[1].replace(Br,Fr),G[3]=(G[3]||G[4]||G[5]||"").replace(Br,Fr),G[2]==="~="&&(G[3]=" "+G[3]+" "),G.slice(0,4)},CHILD:function(G){return G[1]=G[1].toLowerCase(),G[1].slice(0,3)==="nth"?(G[3]||ct.error(G[0]),G[4]=+(G[4]?G[5]+(G[6]||1):2*(G[3]==="even"||G[3]==="odd")),G[5]=+(G[7]+G[8]||G[3]==="odd")):G[3]&&ct.error(G[0]),G},PSEUDO:function(G){var _,te=!G[6]&&G[2];return Lr.CHILD.test(G[0])?null:(G[3]?G[2]=G[4]||G[5]||"":te&&Sr.test(te)&&(_=va(te,!0))&&(_=te.indexOf(")",te.length-_)-te.length)&&(G[0]=G[0].slice(0,_),G[2]=te.slice(0,_)),G.slice(0,3))}},filter:{TAG:function(G){var _=G.replace(Br,Fr).toLowerCase();return G==="*"?function(){return!0}:function(te){return D(te,_)}},CLASS:function(G){var _=Xe[G+" "];return _||(_=new RegExp("(^|"+z+")"+G+"("+z+"|$)"))&&Xe(G,function(te){return _.test(typeof te.className=="string"&&te.className||typeof te.getAttribute<"u"&&te.getAttribute("class")||"")})},ATTR:function(G,_,te){return function(ae){var he=ct.attr(ae,G);return he==null?_==="!=":_?(he+="",_==="="?he===te:_==="!="?he!==te:_==="^="?te&&he.indexOf(te)===0:_==="*="?te&&he.indexOf(te)>-1:_==="$="?te&&he.slice(-te.length)===te:_==="~="?(" "+he.replace(at," ")+" ").indexOf(te)>-1:_==="|="?he===te||he.slice(0,te.length+1)===te+"-":!1):!0}},CHILD:function(G,_,te,ae,he){var Le=G.slice(0,3)!=="nth",Ne=G.slice(-4)!=="last",Be=_==="of-type";return ae===1&&he===0?function(Oe){return!!Oe.parentNode}:function(Oe,Je,Ue){var _e,et,qe,gt,ar,Yt=Le!==Ne?"nextSibling":"previousSibling",vr=Oe.parentNode,Ar=Be&&Oe.nodeName.toLowerCase(),kn=!Ue&&!Be,Jt=!1;if(vr){if(Le){for(;Yt;){for(qe=Oe;qe=qe[Yt];)if(Be?D(qe,Ar):qe.nodeType===1)return!1;ar=Yt=G==="only"&&!ar&&"nextSibling"}return!0}if(ar=[Ne?vr.firstChild:vr.lastChild],Ne&&kn){for(et=vr[ve]||(vr[ve]={}),_e=et[G]||[],gt=_e[0]===re&&_e[1],Jt=gt&&_e[2],qe=gt&&vr.childNodes[gt];qe=++gt&&qe&&qe[Yt]||(Jt=gt=0)||ar.pop();)if(qe.nodeType===1&&++Jt&&qe===Oe){et[G]=[re,gt,Jt];break}}else if(kn&&(et=Oe[ve]||(Oe[ve]={}),_e=et[G]||[],gt=_e[0]===re&&_e[1],Jt=gt),Jt===!1)for(;(qe=++gt&&qe&&qe[Yt]||(Jt=gt=0)||ar.pop())&&!((Be?D(qe,Ar):qe.nodeType===1)&&++Jt&&(kn&&(et=qe[ve]||(qe[ve]={}),et[G]=[re,Jt]),qe===Oe)););return Jt-=he,Jt===ae||Jt%ae===0&&Jt/ae>=0}}},PSEUDO:function(G,_){var te,ae=y.pseudos[G]||y.setFilters[G.toLowerCase()]||ct.error("unsupported pseudo: "+G);return ae[ve]?ae(_):ae.length>1?(te=[G,G,"",_],y.setFilters.hasOwnProperty(G.toLowerCase())?mr(function(he,Le){for(var Ne,Be=ae(he,_),Oe=Be.length;Oe--;)Ne=u.call(he,Be[Oe]),he[Ne]=!(Le[Ne]=Be[Oe])}):function(he){return ae(he,0,te)}):ae}},pseudos:{not:mr(function(G){var _=[],te=[],ae=bo(G.replace(B,"$1"));return ae[ve]?mr(function(he,Le,Ne,Be){for(var Oe,Je=ae(he,null,Be,[]),Ue=he.length;Ue--;)(Oe=Je[Ue])&&(he[Ue]=!(Le[Ue]=Oe))}):function(he,Le,Ne){return _[0]=he,ae(_,null,Ne,te),_[0]=null,!te.pop()}}),has:mr(function(G){return function(_){return ct(G,_).length>0}}),contains:mr(function(G){return G=G.replace(Br,Fr),function(_){return(_.textContent||v.text(_)).indexOf(G)>-1}}),lang:mr(function(G){return ha.test(G||"")||ct.error("unsupported lang: "+G),G=G.replace(Br,Fr).toLowerCase(),function(_){var te;do if(te=q?_.lang:_.getAttribute("xml:lang")||_.getAttribute("lang"))return te=te.toLowerCase(),te===G||te.indexOf(G+"-")===0;while((_=_.parentNode)&&_.nodeType===1);return!1}}),target:function(G){var _=e.location&&e.location.hash;return _&&_.slice(1)===G.id},root:function(G){return G===Y},focus:function(G){return G===vc()&&P.hasFocus()&&!!(G.type||G.href||~G.tabIndex)},enabled:Bs(!1),disabled:Bs(!0),checked:function(G){return D(G,"input")&&!!G.checked||D(G,"option")&&!!G.selected},selected:function(G){return G.parentNode&&G.parentNode.selectedIndex,G.selected===!0},empty:function(G){for(G=G.firstChild;G;G=G.nextSibling)if(G.nodeType<6)return!1;return!0},parent:function(G){return!y.pseudos.empty(G)},header:function(G){return Kr.test(G.nodeName)},input:function(G){return _r.test(G.nodeName)},button:function(G){return D(G,"input")&&G.type==="button"||D(G,"button")},text:function(G){var _;return D(G,"input")&&G.type==="text"&&((_=G.getAttribute("type"))==null||_.toLowerCase()==="text")},first:yn(function(){return[0]}),last:yn(function(G,_){return[_-1]}),eq:yn(function(G,_,te){return[te<0?te+_:te]}),even:yn(function(G,_){for(var te=0;te<_;te+=2)G.push(te);return G}),odd:yn(function(G,_){for(var te=1;te<_;te+=2)G.push(te);return G}),lt:yn(function(G,_,te){var ae;for(te<0?ae=te+_:te>_?ae=_:ae=te;--ae>=0;)G.push(ae);return G}),gt:yn(function(G,_,te){for(var ae=te<0?te+_:te;++ae<_;)G.push(ae);return G})}},y.pseudos.nth=y.pseudos.eq;for(c in{radio:!0,checkbox:!0,file:!0,password:!0,image:!0})y.pseudos[c]=dc(c);for(c in{submit:!0,reset:!0})y.pseudos[c]=gc(c);function Fs(){}Fs.prototype=y.filters=y.pseudos,y.setFilters=new Fs;function va(G,_){var te,ae,he,Le,Ne,Be,Oe,Je=rt[G+" "];if(Je)return _?0:Je.slice(0);for(Ne=G,Be=[],Oe=y.preFilter;Ne;){(!te||(ae=xt.exec(Ne)))&&(ae&&(Ne=Ne.slice(ae[0].length)||Ne),Be.push(he=[])),te=!1,(ae=ca.exec(Ne))&&(te=ae.shift(),he.push({value:te,type:ae[0].replace(B," ")}),Ne=Ne.slice(te.length));for(Le in y.filter)(ae=Lr[Le].exec(Ne))&&(!Oe[Le]||(ae=Oe[Le](ae)))&&(te=ae.shift(),he.push({value:te,type:Le,matches:ae}),Ne=Ne.slice(te.length));if(!te)break}return _?Ne.length:Ne?ct.error(G):rt(G,Be).slice(0)}function ti(G){for(var _=0,te=G.length,ae="";_1?function(_,te,ae){for(var he=G.length;he--;)if(!G[he](_,te,ae))return!1;return!0}:G[0]}function pc(G,_,te){for(var ae=0,he=_.length;ae-1&&(Ne[Ue]=!(Be[Ue]=et))}}else qe=ni(qe===Be?qe.splice(Yt,qe.length):qe),he?he(null,Be,qe,Je):N.apply(Be,qe)})}function mo(G){for(var _,te,ae,he=G.length,Le=y.relative[G[0].type],Ne=Le||y.relative[" "],Be=Le?1:0,Oe=ri(function(_e){return _e===_},Ne,!0),Je=ri(function(_e){return u.call(_,_e)>-1},Ne,!0),Ue=[function(_e,et,qe){var gt=!Le&&(qe||et!=x)||((_=et).nodeType?Oe(_e,et,qe):Je(_e,et,qe));return _=null,gt}];Be1&&po(Ue),Be>1&&ti(G.slice(0,Be-1).concat({value:G[Be-2].type===" "?"*":""})).replace(B,"$1"),te,Be0,ae=G.length>0,he=function(Le,Ne,Be,Oe,Je){var Ue,_e,et,qe=0,gt="0",ar=Le&&[],Yt=[],vr=x,Ar=Le||ae&&y.find.TAG("*",Je),kn=re+=vr==null?1:Math.random()||.1,Jt=Ar.length;for(Je&&(x=Ne==P||Ne||Je);gt!==Jt&&(Ue=Ar[gt])!=null;gt++){if(ae&&Ue){for(_e=0,!Ne&&Ue.ownerDocument!=P&&(Zr(Ue),Be=!q);et=G[_e++];)if(et(Ue,Ne||P,Be)){N.call(Oe,Ue);break}Je&&(re=kn)}te&&((Ue=!et&&Ue)&&qe--,Le&&ar.push(Ue))}if(qe+=gt,te&>!==qe){for(_e=0;et=_[_e++];)et(ar,Yt,Ne,Be);if(Le){if(qe>0)for(;gt--;)ar[gt]||Yt[gt]||(Yt[gt]=O.call(Oe));Yt=ni(Yt)}N.apply(Oe,Yt),Je&&!Le&&Yt.length>0&&qe+_.length>1&&v.uniqueSort(Oe)}return Je&&(re=kn,x=vr),ar};return te?mr(he):he}function bo(G,_){var te,ae=[],he=[],Le=Qe[G+" "];if(!Le){for(_||(_=va(G)),te=_.length;te--;)Le=mo(_[te]),Le[ve]?ae.push(Le):he.push(Le);Le=Qe(G,yc(he,ae)),Le.selector=G}return Le}function zs(G,_,te,ae){var he,Le,Ne,Be,Oe,Je=typeof G=="function"&&G,Ue=!ae&&va(G=Je.selector||G);if(te=te||[],Ue.length===1){if(Le=Ue[0]=Ue[0].slice(0),Le.length>2&&(Ne=Le[0]).type==="ID"&&_.nodeType===9&&q&&y.relative[Le[1].type]){if(_=(y.find.ID(Ne.matches[0].replace(Br,Fr),_)||[])[0],_)Je&&(_=_.parentNode);else return te;G=G.slice(Le.shift().value.length)}for(he=Lr.needsContext.test(G)?0:Le.length;he--&&(Ne=Le[he],!y.relative[Be=Ne.type]);)if((Oe=y.find[Be])&&(ae=Oe(Ne.matches[0].replace(Br,Fr),vo.test(Le[0].type)&&go(_.parentNode)||_))){if(Le.splice(he,1),G=ae.length&&ti(Le),!G)return N.apply(te,ae),te;break}}return(Je||bo(G,Ue))(ae,_,!q,te,!_||vo.test(G)&&go(_.parentNode)||_),te}g.sortStable=ve.split("").sort(At).join("")===ve,Zr(),g.sortDetached=In(function(G){return G.compareDocumentPosition(P.createElement("fieldset"))&1}),v.find=ct,v.expr[":"]=v.expr.pseudos,v.unique=v.uniqueSort,ct.compile=bo,ct.select=zs,ct.setDocument=Zr,ct.tokenize=va,ct.escape=v.escapeSelector,ct.getText=v.text,ct.isXML=v.isXMLDoc,ct.selectors=v.expr,ct.support=v.support,ct.uniqueSort=v.uniqueSort})();var X=function(c,y,x){for(var C=[],M=x!==void 0;(c=c[y])&&c.nodeType!==9;)if(c.nodeType===1){if(M&&v(c).is(x))break;C.push(c)}return C},j=function(c,y){for(var x=[];c;c=c.nextSibling)c.nodeType===1&&c!==y&&x.push(c);return x},K=v.expr.match.needsContext,J=/^<([a-z][^\/\0>:\x20\t\r\n\f]*)[\x20\t\r\n\f]*\/?>(?:<\/\1>|)$/i;function ne(c,y,x){return m(y)?v.grep(c,function(C,M){return!!y.call(C,M,C)!==x}):y.nodeType?v.grep(c,function(C){return C===y!==x}):typeof y!="string"?v.grep(c,function(C){return u.call(y,C)>-1!==x}):v.filter(y,c,x)}v.filter=function(c,y,x){var C=y[0];return x&&(c=":not("+c+")"),y.length===1&&C.nodeType===1?v.find.matchesSelector(C,c)?[C]:[]:v.find.matches(c,v.grep(y,function(M){return M.nodeType===1}))},v.fn.extend({find:function(c){var y,x,C=this.length,M=this;if(typeof c!="string")return this.pushStack(v(c).filter(function(){for(y=0;y1?v.uniqueSort(x):x},filter:function(c){return this.pushStack(ne(this,c||[],!1))},not:function(c){return this.pushStack(ne(this,c||[],!0))},is:function(c){return!!ne(this,typeof c=="string"&&K.test(c)?v(c):c||[],!1).length}});var ie,oe=/^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]+))$/,ue=v.fn.init=function(c,y,x){var C,M;if(!c)return this;if(x=x||ie,typeof c=="string")if(c[0]==="<"&&c[c.length-1]===">"&&c.length>=3?C=[null,c,null]:C=oe.exec(c),C&&(C[1]||!y))if(C[1]){if(y=y instanceof v?y[0]:y,v.merge(this,v.parseHTML(C[1],y&&y.nodeType?y.ownerDocument||y:b,!0)),J.test(C[1])&&v.isPlainObject(y))for(C in y)m(this[C])?this[C](y[C]):this.attr(C,y[C]);return this}else return M=b.getElementById(C[2]),M&&(this[0]=M,this.length=1),this;else return!y||y.jquery?(y||x).find(c):this.constructor(y).find(c);else{if(c.nodeType)return this[0]=c,this.length=1,this;if(m(c))return x.ready!==void 0?x.ready(c):c(v)}return v.makeArray(c,this)};ue.prototype=v.fn,ie=v(b);var Z=/^(?:parents|prev(?:Until|All))/,fe={children:!0,contents:!0,next:!0,prev:!0};v.fn.extend({has:function(c){var y=v(c,this),x=y.length;return this.filter(function(){for(var C=0;C-1:x.nodeType===1&&v.find.matchesSelector(x,c))){N.push(x);break}}return this.pushStack(N.length>1?v.uniqueSort(N):N)},index:function(c){return c?typeof c=="string"?u.call(v(c),this[0]):u.call(this,c.jquery?c[0]:c):this[0]&&this[0].parentNode?this.first().prevAll().length:-1},add:function(c,y){return this.pushStack(v.uniqueSort(v.merge(this.get(),v(c,y))))},addBack:function(c){return this.add(c==null?this.prevObject:this.prevObject.filter(c))}});function ce(c,y){for(;(c=c[y])&&c.nodeType!==1;);return c}v.each({parent:function(c){var y=c.parentNode;return y&&y.nodeType!==11?y:null},parents:function(c){return X(c,"parentNode")},parentsUntil:function(c,y,x){return X(c,"parentNode",x)},next:function(c){return ce(c,"nextSibling")},prev:function(c){return ce(c,"previousSibling")},nextAll:function(c){return X(c,"nextSibling")},prevAll:function(c){return X(c,"previousSibling")},nextUntil:function(c,y,x){return X(c,"nextSibling",x)},prevUntil:function(c,y,x){return X(c,"previousSibling",x)},siblings:function(c){return j((c.parentNode||{}).firstChild,c)},children:function(c){return j(c.firstChild)},contents:function(c){return c.contentDocument!=null&&a(c.contentDocument)?c.contentDocument:(D(c,"template")&&(c=c.content||c),v.merge([],c.childNodes))}},function(c,y){v.fn[c]=function(x,C){var M=v.map(this,y,x);return c.slice(-5)!=="Until"&&(C=x),C&&typeof C=="string"&&(M=v.filter(C,M)),this.length>1&&(fe[c]||v.uniqueSort(M),Z.test(c)&&M.reverse()),this.pushStack(M)}});var be=/[^\x20\t\r\n\f]+/g;function Ce(c){var y={};return v.each(c.match(be)||[],function(x,C){y[C]=!0}),y}v.Callbacks=function(c){c=typeof c=="string"?Ce(c):v.extend({},c);var y,x,C,M,N=[],P=[],Y=-1,q=function(){for(M=M||c.once,C=y=!0;P.length;Y=-1)for(x=P.shift();++Y-1;)N.splice(re,1),re<=Y&&Y--}),this},has:function(se){return se?v.inArray(se,N)>-1:N.length>0},empty:function(){return N&&(N=[]),this},disable:function(){return M=P=[],N=x="",this},disabled:function(){return!N},lock:function(){return M=P=[],!x&&!y&&(N=x=""),this},locked:function(){return!!M},fireWith:function(se,ve){return M||(ve=ve||[],ve=[se,ve.slice?ve.slice():ve],P.push(ve),y||q()),this},fire:function(){return Q.fireWith(this,arguments),this},fired:function(){return!!C}};return Q};function Fe(c){return c}function He(c){throw c}function De(c,y,x,C){var M;try{c&&m(M=c.promise)?M.call(c).done(y).fail(x):c&&m(M=c.then)?M.call(c,y,x):y.apply(void 0,[c].slice(C))}catch(N){x.apply(void 0,[N])}}v.extend({Deferred:function(c){var y=[["notify","progress",v.Callbacks("memory"),v.Callbacks("memory"),2],["resolve","done",v.Callbacks("once memory"),v.Callbacks("once memory"),0,"resolved"],["reject","fail",v.Callbacks("once memory"),v.Callbacks("once memory"),1,"rejected"]],x="pending",C={state:function(){return x},always:function(){return M.done(arguments).fail(arguments),this},catch:function(N){return C.then(null,N)},pipe:function(){var N=arguments;return v.Deferred(function(P){v.each(y,function(Y,q){var Q=m(N[q[4]])&&N[q[4]];M[q[1]](function(){var se=Q&&Q.apply(this,arguments);se&&m(se.promise)?se.promise().progress(P.notify).done(P.resolve).fail(P.reject):P[q[0]+"With"](this,Q?[se]:arguments)})}),N=null}).promise()},then:function(N,P,Y){var q=0;function Q(se,ve,re,Te){return function(){var Xe=this,rt=arguments,Qe=function(){var At,Cr;if(!(se=q&&(re!==He&&(Xe=void 0,rt=[At]),ve.rejectWith(Xe,rt))}};se?Ft():(v.Deferred.getErrorHook?Ft.error=v.Deferred.getErrorHook():v.Deferred.getStackHook&&(Ft.error=v.Deferred.getStackHook()),e.setTimeout(Ft))}}return v.Deferred(function(se){y[0][3].add(Q(0,se,m(Y)?Y:Fe,se.notifyWith)),y[1][3].add(Q(0,se,m(N)?N:Fe)),y[2][3].add(Q(0,se,m(P)?P:He))}).promise()},promise:function(N){return N!=null?v.extend(N,C):C}},M={};return v.each(y,function(N,P){var Y=P[2],q=P[5];C[P[1]]=Y.add,q&&Y.add(function(){x=q},y[3-N][2].disable,y[3-N][3].disable,y[0][2].lock,y[0][3].lock),Y.add(P[3].fire),M[P[0]]=function(){return M[P[0]+"With"](this===M?void 0:this,arguments),this},M[P[0]+"With"]=Y.fireWith}),C.promise(M),c&&c.call(M,M),M},when:function(c){var y=arguments.length,x=y,C=Array(x),M=i.call(arguments),N=v.Deferred(),P=function(Y){return function(q){C[Y]=this,M[Y]=arguments.length>1?i.call(arguments):q,--y||N.resolveWith(C,M)}};if(y<=1&&(De(c,N.done(P(x)).resolve,N.reject,!y),N.state()==="pending"||m(M[x]&&M[x].then)))return N.then();for(;x--;)De(M[x],P(x),N.reject);return N.promise()}});var le=/^(Eval|Internal|Range|Reference|Syntax|Type|URI)Error$/;v.Deferred.exceptionHook=function(c,y){e.console&&e.console.warn&&c&&le.test(c.name)&&e.console.warn("jQuery.Deferred exception: "+c.message,c.stack,y)},v.readyException=function(c){e.setTimeout(function(){throw c})};var me=v.Deferred();v.fn.ready=function(c){return me.then(c).catch(function(y){v.readyException(y)}),this},v.extend({isReady:!1,readyWait:1,ready:function(c){(c===!0?--v.readyWait:v.isReady)||(v.isReady=!0,!(c!==!0&&--v.readyWait>0)&&me.resolveWith(b,[v]))}}),v.ready.then=me.then;function xe(){b.removeEventListener("DOMContentLoaded",xe),e.removeEventListener("load",xe),v.ready()}b.readyState==="complete"||b.readyState!=="loading"&&!b.documentElement.doScroll?e.setTimeout(v.ready):(b.addEventListener("DOMContentLoaded",xe),e.addEventListener("load",xe));var pe=function(c,y,x,C,M,N,P){var Y=0,q=c.length,Q=x==null;if(S(x)==="object"){M=!0;for(Y in x)pe(c,y,Y,x[Y],!0,N,P)}else if(C!==void 0&&(M=!0,m(C)||(P=!0),Q&&(P?(y.call(c,C),y=null):(Q=y,y=function(se,ve,re){return Q.call(v(se),re)})),y))for(;Y1,null,!0)},removeData:function(c){return this.each(function(){ee.remove(this,c)})}}),v.extend({queue:function(c,y,x){var C;if(c)return y=(y||"fx")+"queue",C=F.get(c,y),x&&(!C||Array.isArray(x)?C=F.access(c,y,v.makeArray(x)):C.push(x)),C||[]},dequeue:function(c,y){y=y||"fx";var x=v.queue(c,y),C=x.length,M=x.shift(),N=v._queueHooks(c,y),P=function(){v.dequeue(c,y)};M==="inprogress"&&(M=x.shift(),C--),M&&(y==="fx"&&x.unshift("inprogress"),delete N.stop,M.call(c,P,N)),!C&&N&&N.empty.fire()},_queueHooks:function(c,y){var x=y+"queueHooks";return F.get(c,x)||F.access(c,x,{empty:v.Callbacks("once memory").add(function(){F.remove(c,[y+"queue",x])})})}}),v.fn.extend({queue:function(c,y){var x=2;return typeof c!="string"&&(y=c,c="fx",x--),arguments.length\x20\t\r\n\f]*)/i,Qt=/^$|^module$|\/(?:java|ecma)script/i;(function(){var c=b.createDocumentFragment(),y=c.appendChild(b.createElement("div")),x=b.createElement("input");x.setAttribute("type","radio"),x.setAttribute("checked","checked"),x.setAttribute("name","t"),y.appendChild(x),g.checkClone=y.cloneNode(!0).cloneNode(!0).lastChild.checked,y.innerHTML="",g.noCloneChecked=!!y.cloneNode(!0).lastChild.defaultValue,y.innerHTML="",g.option=!!y.lastChild})();var ht={thead:[1,"","
"],col:[2,"","
"],tr:[2,"","
"],td:[3,"","
"],_default:[0,"",""]};ht.tbody=ht.tfoot=ht.colgroup=ht.caption=ht.thead,ht.th=ht.td,g.option||(ht.optgroup=ht.option=[1,""]);function wt(c,y){var x;return typeof c.getElementsByTagName<"u"?x=c.getElementsByTagName(y||"*"):typeof c.querySelectorAll<"u"?x=c.querySelectorAll(y||"*"):x=[],y===void 0||y&&D(c,y)?v.merge([c],x):x}function fr(c,y){for(var x=0,C=c.length;x-1){M&&M.push(N);continue}if(Q=We(N),P=wt(ve.appendChild(N),"script"),Q&&fr(P),x)for(se=0;N=P[se++];)Qt.test(N.type||"")&&x.push(N)}return ve}var Rr=/^([^.]*)(?:\.(.+)|)/;function pr(){return!0}function tr(){return!1}function Rt(c,y,x,C,M,N){var P,Y;if(typeof y=="object"){typeof x!="string"&&(C=C||x,x=void 0);for(Y in y)Rt(c,Y,x,C,y[Y],N);return c}if(C==null&&M==null?(M=x,C=x=void 0):M==null&&(typeof x=="string"?(M=C,C=void 0):(M=C,C=x,x=void 0)),M===!1)M=tr;else if(!M)return c;return N===1&&(P=M,M=function(q){return v().off(q),P.apply(this,arguments)},M.guid=P.guid||(P.guid=v.guid++)),c.each(function(){v.event.add(this,y,M,C,x)})}v.event={global:{},add:function(c,y,x,C,M){var N,P,Y,q,Q,se,ve,re,Te,Xe,rt,Qe=F.get(c);if(ze(c))for(x.handler&&(N=x,x=N.handler,M=N.selector),M&&v.find.matchesSelector(je,M),x.guid||(x.guid=v.guid++),(q=Qe.events)||(q=Qe.events=Object.create(null)),(P=Qe.handle)||(P=Qe.handle=function(Ft){return typeof v<"u"&&v.event.triggered!==Ft.type?v.event.dispatch.apply(c,arguments):void 0}),y=(y||"").match(be)||[""],Q=y.length;Q--;)Y=Rr.exec(y[Q])||[],Te=rt=Y[1],Xe=(Y[2]||"").split(".").sort(),Te&&(ve=v.event.special[Te]||{},Te=(M?ve.delegateType:ve.bindType)||Te,ve=v.event.special[Te]||{},se=v.extend({type:Te,origType:rt,data:C,handler:x,guid:x.guid,selector:M,needsContext:M&&v.expr.match.needsContext.test(M),namespace:Xe.join(".")},N),(re=q[Te])||(re=q[Te]=[],re.delegateCount=0,(!ve.setup||ve.setup.call(c,C,Xe,P)===!1)&&c.addEventListener&&c.addEventListener(Te,P)),ve.add&&(ve.add.call(c,se),se.handler.guid||(se.handler.guid=x.guid)),M?re.splice(re.delegateCount++,0,se):re.push(se),v.event.global[Te]=!0)},remove:function(c,y,x,C,M){var N,P,Y,q,Q,se,ve,re,Te,Xe,rt,Qe=F.hasData(c)&&F.get(c);if(!(!Qe||!(q=Qe.events))){for(y=(y||"").match(be)||[""],Q=y.length;Q--;){if(Y=Rr.exec(y[Q])||[],Te=rt=Y[1],Xe=(Y[2]||"").split(".").sort(),!Te){for(Te in q)v.event.remove(c,Te+y[Q],x,C,!0);continue}for(ve=v.event.special[Te]||{},Te=(C?ve.delegateType:ve.bindType)||Te,re=q[Te]||[],Y=Y[2]&&new RegExp("(^|\\.)"+Xe.join("\\.(?:.*\\.|)")+"(\\.|$)"),P=N=re.length;N--;)se=re[N],(M||rt===se.origType)&&(!x||x.guid===se.guid)&&(!Y||Y.test(se.namespace))&&(!C||C===se.selector||C==="**"&&se.selector)&&(re.splice(N,1),se.selector&&re.delegateCount--,ve.remove&&ve.remove.call(c,se));P&&!re.length&&((!ve.teardown||ve.teardown.call(c,Xe,Qe.handle)===!1)&&v.removeEvent(c,Te,Qe.handle),delete q[Te])}v.isEmptyObject(q)&&F.remove(c,"handle events")}},dispatch:function(c){var y,x,C,M,N,P,Y=new Array(arguments.length),q=v.event.fix(c),Q=(F.get(this,"events")||Object.create(null))[q.type]||[],se=v.event.special[q.type]||{};for(Y[0]=q,y=1;y=1)){for(;Q!==this;Q=Q.parentNode||this)if(Q.nodeType===1&&!(c.type==="click"&&Q.disabled===!0)){for(N=[],P={},x=0;x-1:v.find(M,this,null,[Q]).length),P[M]&&N.push(C);N.length&&Y.push({elem:Q,handlers:N})}}return Q=this,q\s*$/g;function ia(c,y){return D(c,"table")&&D(y.nodeType!==11?y:y.firstChild,"tr")&&v(c).children("tbody")[0]||c}function Ji(c){return c.type=(c.getAttribute("type")!==null)+"/"+c.type,c}function eo(c){return(c.type||"").slice(0,5)==="true/"?c.type=c.type.slice(5):c.removeAttribute("type"),c}function _a(c,y){var x,C,M,N,P,Y,q;if(y.nodeType===1){if(F.hasData(c)&&(N=F.get(c),q=N.events,q)){F.remove(y,"handle events");for(M in q)for(x=0,C=q[M].length;x1&&typeof Te=="string"&&!g.checkClone&&Mn.test(Te))return c.each(function(rt){var Qe=c.eq(rt);Xe&&(y[0]=Te.call(this,rt,Qe.html())),Yr(Qe,y,x,C)});if(ve&&(M=Tr(y,c[0].ownerDocument,!1,c,C),N=M.firstChild,M.childNodes.length===1&&(M=N),N||C)){for(P=v.map(wt(M,"script"),Ji),Y=P.length;se0&&fr(P,!q&&wt(c,"script")),Y},cleanData:function(c){for(var y,x,C,M=v.event.special,N=0;(x=c[N])!==void 0;N++)if(ze(x)){if(y=x[F.expando]){if(y.events)for(C in y.events)M[C]?v.event.remove(x,C):v.removeEvent(x,C,y.handle);x[F.expando]=void 0}x[ee.expando]&&(x[ee.expando]=void 0)}}}),v.fn.extend({detach:function(c){return Ka(this,c,!0)},remove:function(c){return Ka(this,c)},text:function(c){return pe(this,function(y){return y===void 0?v.text(this):this.empty().each(function(){(this.nodeType===1||this.nodeType===11||this.nodeType===9)&&(this.textContent=y)})},null,c,arguments.length)},append:function(){return Yr(this,arguments,function(c){if(this.nodeType===1||this.nodeType===11||this.nodeType===9){var y=ia(this,c);y.appendChild(c)}})},prepend:function(){return Yr(this,arguments,function(c){if(this.nodeType===1||this.nodeType===11||this.nodeType===9){var y=ia(this,c);y.insertBefore(c,y.firstChild)}})},before:function(){return Yr(this,arguments,function(c){this.parentNode&&this.parentNode.insertBefore(c,this)})},after:function(){return Yr(this,arguments,function(c){this.parentNode&&this.parentNode.insertBefore(c,this.nextSibling)})},empty:function(){for(var c,y=0;(c=this[y])!=null;y++)c.nodeType===1&&(v.cleanData(wt(c,!1)),c.textContent="");return this},clone:function(c,y){return c=c??!1,y=y??c,this.map(function(){return v.clone(this,c,y)})},html:function(c){return pe(this,function(y){var x=this[0]||{},C=0,M=this.length;if(y===void 0&&x.nodeType===1)return x.innerHTML;if(typeof y=="string"&&!Ut.test(y)&&!ht[(St.exec(y)||["",""])[1].toLowerCase()]){y=v.htmlPrefilter(y);try{for(;C=0&&(q+=Math.max(0,Math.ceil(c["offset"+y[0].toUpperCase()+y.slice(1)]-N-q-Y-.5))||0),q+Q}function Ts(c,y,x){var C=Wr(c),M=!g.boxSizingReliable()||x,N=M&&v.css(c,"boxSizing",!1,C)==="border-box",P=N,Y=Xr(c,y,C),q="offset"+y[0].toUpperCase()+y.slice(1);if(oa.test(Y)){if(!x)return Y;Y="auto"}return(!g.boxSizingReliable()&&N||!g.reliableTrDimensions()&&D(c,"tr")||Y==="auto"||!parseFloat(Y)&&v.css(c,"display",!1,C)==="inline")&&c.getClientRects().length&&(N=v.css(c,"boxSizing",!1,C)==="border-box",P=q in c,P&&(Y=c[q])),Y=parseFloat(Y)||0,Y+no(c,y,x||(N?"border":"content"),P,C,Y)+"px"}v.extend({cssHooks:{opacity:{get:function(c,y){if(y){var x=Xr(c,"opacity");return x===""?"1":x}}}},cssNumber:{animationIterationCount:!0,aspectRatio:!0,borderImageSlice:!0,columnCount:!0,flexGrow:!0,flexShrink:!0,fontWeight:!0,gridArea:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnStart:!0,gridRow:!0,gridRowEnd:!0,gridRowStart:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,scale:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeMiterlimit:!0,strokeOpacity:!0},cssProps:{},style:function(c,y,x,C){if(!(!c||c.nodeType===3||c.nodeType===8||!c.style)){var M,N,P,Y=Me(y),q=Pr.test(y),Q=c.style;if(q||(y=jt(Y)),P=v.cssHooks[y]||v.cssHooks[Y],x!==void 0){if(N=typeof x,N==="string"&&(M=Pe.exec(x))&&M[1]&&(x=Ke(c,y,M),N="number"),x==null||x!==x)return;N==="number"&&!q&&(x+=M&&M[3]||(v.cssNumber[Y]?"":"px")),!g.clearCloneStyle&&x===""&&y.indexOf("background")===0&&(Q[y]="inherit"),(!P||!("set"in P)||(x=P.set(c,x,C))!==void 0)&&(q?Q.setProperty(y,x):Q[y]=x)}else return P&&"get"in P&&(M=P.get(c,!1,C))!==void 0?M:Q[y]}},css:function(c,y,x,C){var M,N,P,Y=Me(y),q=Pr.test(y);return q||(y=jt(Y)),P=v.cssHooks[y]||v.cssHooks[Y],P&&"get"in P&&(M=P.get(c,!0,x)),M===void 0&&(M=Xr(c,y,C)),M==="normal"&&y in Es&&(M=Es[y]),x===""||x?(N=parseFloat(M),x===!0||isFinite(N)?N||0:M):M}}),v.each(["height","width"],function(c,y){v.cssHooks[y]={get:function(x,C,M){if(C)return ro.test(v.css(x,"display"))&&(!x.getClientRects().length||!x.getBoundingClientRect().width)?hn(x,qf,function(){return Ts(x,y,M)}):Ts(x,y,M)},set:function(x,C,M){var N,P=Wr(x),Y=!g.scrollboxSize()&&P.position==="absolute",q=Y||M,Q=q&&v.css(x,"boxSizing",!1,P)==="border-box",se=M?no(x,y,M,Q,P):0;return Q&&Y&&(se-=Math.ceil(x["offset"+y[0].toUpperCase()+y.slice(1)]-parseFloat(P[y])-no(x,y,"border",!1,P)-.5)),se&&(N=Pe.exec(C))&&(N[3]||"px")!=="px"&&(x.style[y]=C,C=v.css(x,y)),xs(x,C,se)}}}),v.cssHooks.marginLeft=Qa(g.reliableMarginLeft,function(c,y){if(y)return(parseFloat(Xr(c,"marginLeft"))||c.getBoundingClientRect().left-hn(c,{marginLeft:0},function(){return c.getBoundingClientRect().left}))+"px"}),v.each({margin:"",padding:"",border:"Width"},function(c,y){v.cssHooks[c+y]={expand:function(x){for(var C=0,M={},N=typeof x=="string"?x.split(" "):[x];C<4;C++)M[c+Ze[C]+y]=N[C]||N[C-2]||N[0];return M}},c!=="margin"&&(v.cssHooks[c+y].set=xs)}),v.fn.extend({css:function(c,y){return pe(this,function(x,C,M){var N,P,Y={},q=0;if(Array.isArray(C)){for(N=Wr(x),P=C.length;q1)}});function nr(c,y,x,C,M){return new nr.prototype.init(c,y,x,C,M)}v.Tween=nr,nr.prototype={constructor:nr,init:function(c,y,x,C,M,N){this.elem=c,this.prop=x,this.easing=M||v.easing._default,this.options=y,this.start=this.now=this.cur(),this.end=C,this.unit=N||(v.cssNumber[x]?"":"px")},cur:function(){var c=nr.propHooks[this.prop];return c&&c.get?c.get(this):nr.propHooks._default.get(this)},run:function(c){var y,x=nr.propHooks[this.prop];return this.options.duration?this.pos=y=v.easing[this.easing](c,this.options.duration*c,0,1,this.options.duration):this.pos=y=c,this.now=(this.end-this.start)*y+this.start,this.options.step&&this.options.step.call(this.elem,this.now,this),x&&x.set?x.set(this):nr.propHooks._default.set(this),this}},nr.prototype.init.prototype=nr.prototype,nr.propHooks={_default:{get:function(c){var y;return c.elem.nodeType!==1||c.elem[c.prop]!=null&&c.elem.style[c.prop]==null?c.elem[c.prop]:(y=v.css(c.elem,c.prop,""),!y||y==="auto"?0:y)},set:function(c){v.fx.step[c.prop]?v.fx.step[c.prop](c):c.elem.nodeType===1&&(v.cssHooks[c.prop]||c.elem.style[jt(c.prop)]!=null)?v.style(c.elem,c.prop,c.now+c.unit):c.elem[c.prop]=c.now}}},nr.propHooks.scrollTop=nr.propHooks.scrollLeft={set:function(c){c.elem.nodeType&&c.elem.parentNode&&(c.elem[c.prop]=c.now)}},v.easing={linear:function(c){return c},swing:function(c){return .5-Math.cos(c*Math.PI)/2},_default:"swing"},v.fx=nr.prototype.init,v.fx.step={};var On,ja,$f=/^(?:toggle|show|hide)$/,Vf=/queueHooks$/;function ao(){ja&&(b.hidden===!1&&e.requestAnimationFrame?e.requestAnimationFrame(ao):e.setTimeout(ao,v.fx.interval),v.fx.tick())}function Cs(){return e.setTimeout(function(){On=void 0}),On=Date.now()}function Ja(c,y){var x,C=0,M={height:c};for(y=y?1:0;C<4;C+=2-y)x=Ze[C],M["margin"+x]=M["padding"+x]=c;return y&&(M.opacity=M.width=c),M}function Ds(c,y,x){for(var C,M=(yr.tweeners[y]||[]).concat(yr.tweeners["*"]),N=0,P=M.length;N1)},removeAttr:function(c){return this.each(function(){v.removeAttr(this,c)})}}),v.extend({attr:function(c,y,x){var C,M,N=c.nodeType;if(!(N===3||N===8||N===2)){if(typeof c.getAttribute>"u")return v.prop(c,y,x);if((N!==1||!v.isXMLDoc(c))&&(M=v.attrHooks[y.toLowerCase()]||(v.expr.match.bool.test(y)?Ss:void 0)),x!==void 0){if(x===null){v.removeAttr(c,y);return}return M&&"set"in M&&(C=M.set(c,x,y))!==void 0?C:(c.setAttribute(y,x+""),x)}return M&&"get"in M&&(C=M.get(c,y))!==null?C:(C=v.find.attr(c,y),C??void 0)}},attrHooks:{type:{set:function(c,y){if(!g.radioValue&&y==="radio"&&D(c,"input")){var x=c.value;return c.setAttribute("type",y),x&&(c.value=x),y}}}},removeAttr:function(c,y){var x,C=0,M=y&&y.match(be);if(M&&c.nodeType===1)for(;x=M[C++];)c.removeAttribute(x)}}),Ss={set:function(c,y,x){return y===!1?v.removeAttr(c,x):c.setAttribute(x,x),x}},v.each(v.expr.match.bool.source.match(/\w+/g),function(c,y){var x=ua[y]||v.find.attr;ua[y]=function(C,M,N){var P,Y,q=M.toLowerCase();return N||(Y=ua[q],ua[q]=P,P=x(C,M,N)!=null?q:null,ua[q]=Y),P}});var Wf=/^(?:input|select|textarea|button)$/i,Xf=/^(?:a|area)$/i;v.fn.extend({prop:function(c,y){return pe(this,v.prop,c,y,arguments.length>1)},removeProp:function(c){return this.each(function(){delete this[v.propFix[c]||c]})}}),v.extend({prop:function(c,y,x){var C,M,N=c.nodeType;if(!(N===3||N===8||N===2))return(N!==1||!v.isXMLDoc(c))&&(y=v.propFix[y]||y,M=v.propHooks[y]),x!==void 0?M&&"set"in M&&(C=M.set(c,x,y))!==void 0?C:c[y]=x:M&&"get"in M&&(C=M.get(c,y))!==null?C:c[y]},propHooks:{tabIndex:{get:function(c){var y=v.find.attr(c,"tabindex");return y?parseInt(y,10):Wf.test(c.nodeName)||Xf.test(c.nodeName)&&c.href?0:-1}}},propFix:{for:"htmlFor",class:"className"}}),g.optSelected||(v.propHooks.selected={get:function(c){var y=c.parentNode;return y&&y.parentNode&&y.parentNode.selectedIndex,null},set:function(c){var y=c.parentNode;y&&(y.selectedIndex,y.parentNode&&y.parentNode.selectedIndex)}}),v.each(["tabIndex","readOnly","maxLength","cellSpacing","cellPadding","rowSpan","colSpan","useMap","frameBorder","contentEditable"],function(){v.propFix[this.toLowerCase()]=this});function dn(c){var y=c.match(be)||[];return y.join(" ")}function gn(c){return c.getAttribute&&c.getAttribute("class")||""}function io(c){return Array.isArray(c)?c:typeof c=="string"?c.match(be)||[]:[]}v.fn.extend({addClass:function(c){var y,x,C,M,N,P;return m(c)?this.each(function(Y){v(this).addClass(c.call(this,Y,gn(this)))}):(y=io(c),y.length?this.each(function(){if(C=gn(this),x=this.nodeType===1&&" "+dn(C)+" ",x){for(N=0;N-1;)x=x.replace(" "+M+" "," ");P=dn(x),C!==P&&this.setAttribute("class",P)}}):this):this.attr("class","")},toggleClass:function(c,y){var x,C,M,N,P=typeof c,Y=P==="string"||Array.isArray(c);return m(c)?this.each(function(q){v(this).toggleClass(c.call(this,q,gn(this),y),y)}):typeof y=="boolean"&&Y?y?this.addClass(c):this.removeClass(c):(x=io(c),this.each(function(){if(Y)for(N=v(this),M=0;M-1)return!0;return!1}});var _f=/\r/g;v.fn.extend({val:function(c){var y,x,C,M=this[0];return arguments.length?(C=m(c),this.each(function(N){var P;this.nodeType===1&&(C?P=c.call(this,N,v(this).val()):P=c,P==null?P="":typeof P=="number"?P+="":Array.isArray(P)&&(P=v.map(P,function(Y){return Y==null?"":Y+""})),y=v.valHooks[this.type]||v.valHooks[this.nodeName.toLowerCase()],(!y||!("set"in y)||y.set(this,P,"value")===void 0)&&(this.value=P))})):M?(y=v.valHooks[M.type]||v.valHooks[M.nodeName.toLowerCase()],y&&"get"in y&&(x=y.get(M,"value"))!==void 0?x:(x=M.value,typeof x=="string"?x.replace(_f,""):x??"")):void 0}}),v.extend({valHooks:{option:{get:function(c){var y=v.find.attr(c,"value");return y??dn(v.text(c))}},select:{get:function(c){var y,x,C,M=c.options,N=c.selectedIndex,P=c.type==="select-one",Y=P?null:[],q=P?N+1:M.length;for(N<0?C=q:C=P?N:0;C-1)&&(x=!0);return x||(c.selectedIndex=-1),N}}}}),v.each(["radio","checkbox"],function(){v.valHooks[this]={set:function(c,y){if(Array.isArray(y))return c.checked=v.inArray(v(c).val(),y)>-1}},g.checkOn||(v.valHooks[this].get=function(c){return c.getAttribute("value")===null?"on":c.value})});var la=e.location,Ls={guid:Date.now()},oo=/\?/;v.parseXML=function(c){var y,x;if(!c||typeof c!="string")return null;try{y=new e.DOMParser().parseFromString(c,"text/xml")}catch{}return x=y&&y.getElementsByTagName("parsererror")[0],(!y||x)&&v.error("Invalid XML: "+(x?v.map(x.childNodes,function(C){return C.textContent}).join(` -`):c)),y};var As=/^(?:focusinfocus|focusoutblur)$/,Ms=function(c){c.stopPropagation()};v.extend(v.event,{trigger:function(c,y,x,C){var M,N,P,Y,q,Q,se,ve,re=[x||b],Te=h.call(c,"type")?c.type:c,Xe=h.call(c,"namespace")?c.namespace.split("."):[];if(N=ve=P=x=x||b,!(x.nodeType===3||x.nodeType===8)&&!As.test(Te+v.event.triggered)&&(Te.indexOf(".")>-1&&(Xe=Te.split("."),Te=Xe.shift(),Xe.sort()),q=Te.indexOf(":")<0&&"on"+Te,c=c[v.expando]?c:new v.Event(Te,typeof c=="object"&&c),c.isTrigger=C?2:3,c.namespace=Xe.join("."),c.rnamespace=c.namespace?new RegExp("(^|\\.)"+Xe.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,c.result=void 0,c.target||(c.target=x),y=y==null?[c]:v.makeArray(y,[c]),se=v.event.special[Te]||{},!(!C&&se.trigger&&se.trigger.apply(x,y)===!1))){if(!C&&!se.noBubble&&!w(x)){for(Y=se.delegateType||Te,As.test(Y+Te)||(N=N.parentNode);N;N=N.parentNode)re.push(N),P=N;P===(x.ownerDocument||b)&&re.push(P.defaultView||P.parentWindow||e)}for(M=0;(N=re[M++])&&!c.isPropagationStopped();)ve=N,c.type=M>1?Y:se.bindType||Te,Q=(F.get(N,"events")||Object.create(null))[c.type]&&F.get(N,"handle"),Q&&Q.apply(N,y),Q=q&&N[q],Q&&Q.apply&&ze(N)&&(c.result=Q.apply(N,y),c.result===!1&&c.preventDefault());return c.type=Te,!C&&!c.isDefaultPrevented()&&(!se._default||se._default.apply(re.pop(),y)===!1)&&ze(x)&&q&&m(x[Te])&&!w(x)&&(P=x[q],P&&(x[q]=null),v.event.triggered=Te,c.isPropagationStopped()&&ve.addEventListener(Te,Ms),x[Te](),c.isPropagationStopped()&&ve.removeEventListener(Te,Ms),v.event.triggered=void 0,P&&(x[q]=P)),c.result}},simulate:function(c,y,x){var C=v.extend(new v.Event,x,{type:c,isSimulated:!0});v.event.trigger(C,null,y)}}),v.fn.extend({trigger:function(c,y){return this.each(function(){v.event.trigger(c,y,this)})},triggerHandler:function(c,y){var x=this[0];if(x)return v.event.trigger(c,y,x,!0)}});var Kf=/\[\]$/,Ns=/\r?\n/g,Zf=/^(?:submit|button|image|reset|file)$/i,Qf=/^(?:input|select|textarea|keygen)/i;function so(c,y,x,C){var M;if(Array.isArray(y))v.each(y,function(N,P){x||Kf.test(c)?C(c,P):so(c+"["+(typeof P=="object"&&P!=null?N:"")+"]",P,x,C)});else if(!x&&S(y)==="object")for(M in y)so(c+"["+M+"]",y[M],x,C);else C(c,y)}v.param=function(c,y){var x,C=[],M=function(N,P){var Y=m(P)?P():P;C[C.length]=encodeURIComponent(N)+"="+encodeURIComponent(Y??"")};if(c==null)return"";if(Array.isArray(c)||c.jquery&&!v.isPlainObject(c))v.each(c,function(){M(this.name,this.value)});else for(x in c)so(x,c[x],y,M);return C.join("&")},v.fn.extend({serialize:function(){return v.param(this.serializeArray())},serializeArray:function(){return this.map(function(){var c=v.prop(this,"elements");return c?v.makeArray(c):this}).filter(function(){var c=this.type;return this.name&&!v(this).is(":disabled")&&Qf.test(this.nodeName)&&!Zf.test(c)&&(this.checked||!Bt.test(c))}).map(function(c,y){var x=v(this).val();return x==null?null:Array.isArray(x)?v.map(x,function(C){return{name:y.name,value:C.replace(Ns,`\r -`)}}):{name:y.name,value:x.replace(Ns,`\r -`)}}).get()}});var jf=/%20/g,Jf=/#.*$/,ec=/([?&])_=[^&]*/,tc=/^(.*?):[ \t]*([^\r\n]*)$/mg,rc=/^(?:about|app|app-storage|.+-extension|file|res|widget):$/,nc=/^(?:GET|HEAD)$/,ac=/^\/\//,Os={},uo={},Is="*/".concat("*"),lo=b.createElement("a");lo.href=la.href;function ks(c){return function(y,x){typeof y!="string"&&(x=y,y="*");var C,M=0,N=y.toLowerCase().match(be)||[];if(m(x))for(;C=N[M++];)C[0]==="+"?(C=C.slice(1)||"*",(c[C]=c[C]||[]).unshift(x)):(c[C]=c[C]||[]).push(x)}}function Rs(c,y,x,C){var M={},N=c===uo;function P(Y){var q;return M[Y]=!0,v.each(c[Y]||[],function(Q,se){var ve=se(y,x,C);if(typeof ve=="string"&&!N&&!M[ve])return y.dataTypes.unshift(ve),P(ve),!1;if(N)return!(q=ve)}),q}return P(y.dataTypes[0])||!M["*"]&&P("*")}function fo(c,y){var x,C,M=v.ajaxSettings.flatOptions||{};for(x in y)y[x]!==void 0&&((M[x]?c:C||(C={}))[x]=y[x]);return C&&v.extend(!0,c,C),c}function ic(c,y,x){for(var C,M,N,P,Y=c.contents,q=c.dataTypes;q[0]==="*";)q.shift(),C===void 0&&(C=c.mimeType||y.getResponseHeader("Content-Type"));if(C){for(M in Y)if(Y[M]&&Y[M].test(C)){q.unshift(M);break}}if(q[0]in x)N=q[0];else{for(M in x){if(!q[0]||c.converters[M+" "+q[0]]){N=M;break}P||(P=M)}N=N||P}if(N)return N!==q[0]&&q.unshift(N),x[N]}function oc(c,y,x,C){var M,N,P,Y,q,Q={},se=c.dataTypes.slice();if(se[1])for(P in c.converters)Q[P.toLowerCase()]=c.converters[P];for(N=se.shift();N;)if(c.responseFields[N]&&(x[c.responseFields[N]]=y),!q&&C&&c.dataFilter&&(y=c.dataFilter(y,c.dataType)),q=N,N=se.shift(),N){if(N==="*")N=q;else if(q!=="*"&&q!==N){if(P=Q[q+" "+N]||Q["* "+N],!P){for(M in Q)if(Y=M.split(" "),Y[1]===N&&(P=Q[q+" "+Y[0]]||Q["* "+Y[0]],P)){P===!0?P=Q[M]:Q[M]!==!0&&(N=Y[0],se.unshift(Y[1]));break}}if(P!==!0)if(P&&c.throws)y=P(y);else try{y=P(y)}catch(ve){return{state:"parsererror",error:P?ve:"No conversion from "+q+" to "+N}}}}return{state:"success",data:y}}v.extend({active:0,lastModified:{},etag:{},ajaxSettings:{url:la.href,type:"GET",isLocal:rc.test(la.protocol),global:!0,processData:!0,async:!0,contentType:"application/x-www-form-urlencoded; charset=UTF-8",accepts:{"*":Is,text:"text/plain",html:"text/html",xml:"application/xml, text/xml",json:"application/json, text/javascript"},contents:{xml:/\bxml\b/,html:/\bhtml/,json:/\bjson\b/},responseFields:{xml:"responseXML",text:"responseText",json:"responseJSON"},converters:{"* text":String,"text html":!0,"text json":JSON.parse,"text xml":v.parseXML},flatOptions:{url:!0,context:!0}},ajaxSetup:function(c,y){return y?fo(fo(c,v.ajaxSettings),y):fo(v.ajaxSettings,c)},ajaxPrefilter:ks(Os),ajaxTransport:ks(uo),ajax:function(c,y){typeof c=="object"&&(y=c,c=void 0),y=y||{};var x,C,M,N,P,Y,q,Q,se,ve,re=v.ajaxSetup({},y),Te=re.context||re,Xe=re.context&&(Te.nodeType||Te.jquery)?v(Te):v.event,rt=v.Deferred(),Qe=v.Callbacks("once memory"),Ft=re.statusCode||{},At={},Cr={},Dr="canceled",tt={readyState:0,getResponseHeader:function(at){var xt;if(q){if(!N)for(N={};xt=tc.exec(M);)N[xt[1].toLowerCase()+" "]=(N[xt[1].toLowerCase()+" "]||[]).concat(xt[2]);xt=N[at.toLowerCase()+" "]}return xt==null?null:xt.join(", ")},getAllResponseHeaders:function(){return q?M:null},setRequestHeader:function(at,xt){return q==null&&(at=Cr[at.toLowerCase()]=Cr[at.toLowerCase()]||at,At[at]=xt),this},overrideMimeType:function(at){return q==null&&(re.mimeType=at),this},statusCode:function(at){var xt;if(at)if(q)tt.always(at[tt.status]);else for(xt in at)Ft[xt]=[Ft[xt],at[xt]];return this},abort:function(at){var xt=at||Dr;return x&&x.abort(xt),pn(0,xt),this}};if(rt.promise(tt),re.url=((c||re.url||la.href)+"").replace(ac,la.protocol+"//"),re.type=y.method||y.type||re.method||re.type,re.dataTypes=(re.dataType||"*").toLowerCase().match(be)||[""],re.crossDomain==null){Y=b.createElement("a");try{Y.href=re.url,Y.href=Y.href,re.crossDomain=lo.protocol+"//"+lo.host!=Y.protocol+"//"+Y.host}catch{re.crossDomain=!0}}if(re.data&&re.processData&&typeof re.data!="string"&&(re.data=v.param(re.data,re.traditional)),Rs(Os,re,y,tt),q)return tt;Q=v.event&&re.global,Q&&v.active++===0&&v.event.trigger("ajaxStart"),re.type=re.type.toUpperCase(),re.hasContent=!nc.test(re.type),C=re.url.replace(Jf,""),re.hasContent?re.data&&re.processData&&(re.contentType||"").indexOf("application/x-www-form-urlencoded")===0&&(re.data=re.data.replace(jf,"+")):(ve=re.url.slice(C.length),re.data&&(re.processData||typeof re.data=="string")&&(C+=(oo.test(C)?"&":"?")+re.data,delete re.data),re.cache===!1&&(C=C.replace(ec,"$1"),ve=(oo.test(C)?"&":"?")+"_="+Ls.guid+++ve),re.url=C+ve),re.ifModified&&(v.lastModified[C]&&tt.setRequestHeader("If-Modified-Since",v.lastModified[C]),v.etag[C]&&tt.setRequestHeader("If-None-Match",v.etag[C])),(re.data&&re.hasContent&&re.contentType!==!1||y.contentType)&&tt.setRequestHeader("Content-Type",re.contentType),tt.setRequestHeader("Accept",re.dataTypes[0]&&re.accepts[re.dataTypes[0]]?re.accepts[re.dataTypes[0]]+(re.dataTypes[0]!=="*"?", "+Is+"; q=0.01":""):re.accepts["*"]);for(se in re.headers)tt.setRequestHeader(se,re.headers[se]);if(re.beforeSend&&(re.beforeSend.call(Te,tt,re)===!1||q))return tt.abort();if(Dr="abort",Qe.add(re.complete),tt.done(re.success),tt.fail(re.error),x=Rs(uo,re,y,tt),!x)pn(-1,"No Transport");else{if(tt.readyState=1,Q&&Xe.trigger("ajaxSend",[tt,re]),q)return tt;re.async&&re.timeout>0&&(P=e.setTimeout(function(){tt.abort("timeout")},re.timeout));try{q=!1,x.send(At,pn)}catch(at){if(q)throw at;pn(-1,at)}}function pn(at,xt,ca,ho){var Sr,ha,Lr,_r,Kr,hr=xt;q||(q=!0,P&&e.clearTimeout(P),x=void 0,M=ho||"",tt.readyState=at>0?4:0,Sr=at>=200&&at<300||at===304,ca&&(_r=ic(re,tt,ca)),!Sr&&v.inArray("script",re.dataTypes)>-1&&v.inArray("json",re.dataTypes)<0&&(re.converters["text script"]=function(){}),_r=oc(re,_r,tt,Sr),Sr?(re.ifModified&&(Kr=tt.getResponseHeader("Last-Modified"),Kr&&(v.lastModified[C]=Kr),Kr=tt.getResponseHeader("etag"),Kr&&(v.etag[C]=Kr)),at===204||re.type==="HEAD"?hr="nocontent":at===304?hr="notmodified":(hr=_r.state,ha=_r.data,Lr=_r.error,Sr=!Lr)):(Lr=hr,(at||!hr)&&(hr="error",at<0&&(at=0))),tt.status=at,tt.statusText=(xt||hr)+"",Sr?rt.resolveWith(Te,[ha,hr,tt]):rt.rejectWith(Te,[tt,hr,Lr]),tt.statusCode(Ft),Ft=void 0,Q&&Xe.trigger(Sr?"ajaxSuccess":"ajaxError",[tt,re,Sr?ha:Lr]),Qe.fireWith(Te,[tt,hr]),Q&&(Xe.trigger("ajaxComplete",[tt,re]),--v.active||v.event.trigger("ajaxStop")))}return tt},getJSON:function(c,y,x){return v.get(c,y,x,"json")},getScript:function(c,y){return v.get(c,void 0,y,"script")}}),v.each(["get","post"],function(c,y){v[y]=function(x,C,M,N){return m(C)&&(N=N||M,M=C,C=void 0),v.ajax(v.extend({url:x,type:y,dataType:N,data:C,success:M},v.isPlainObject(x)&&x))}}),v.ajaxPrefilter(function(c){var y;for(y in c.headers)y.toLowerCase()==="content-type"&&(c.contentType=c.headers[y]||"")}),v._evalUrl=function(c,y,x){return v.ajax({url:c,type:"GET",dataType:"script",cache:!0,async:!1,global:!1,converters:{"text script":function(){}},dataFilter:function(C){v.globalEval(C,y,x)}})},v.fn.extend({wrapAll:function(c){var y;return this[0]&&(m(c)&&(c=c.call(this[0])),y=v(c,this[0].ownerDocument).eq(0).clone(!0),this[0].parentNode&&y.insertBefore(this[0]),y.map(function(){for(var x=this;x.firstElementChild;)x=x.firstElementChild;return x}).append(this)),this},wrapInner:function(c){return m(c)?this.each(function(y){v(this).wrapInner(c.call(this,y))}):this.each(function(){var y=v(this),x=y.contents();x.length?x.wrapAll(c):y.append(c)})},wrap:function(c){var y=m(c);return this.each(function(x){v(this).wrapAll(y?c.call(this,x):c)})},unwrap:function(c){return this.parent(c).not("body").each(function(){v(this).replaceWith(this.childNodes)}),this}}),v.expr.pseudos.hidden=function(c){return!v.expr.pseudos.visible(c)},v.expr.pseudos.visible=function(c){return!!(c.offsetWidth||c.offsetHeight||c.getClientRects().length)},v.ajaxSettings.xhr=function(){try{return new e.XMLHttpRequest}catch{}};var sc={0:200,1223:204},fa=v.ajaxSettings.xhr();g.cors=!!fa&&"withCredentials"in fa,g.ajax=fa=!!fa,v.ajaxTransport(function(c){var y,x;if(g.cors||fa&&!c.crossDomain)return{send:function(C,M){var N,P=c.xhr();if(P.open(c.type,c.url,c.async,c.username,c.password),c.xhrFields)for(N in c.xhrFields)P[N]=c.xhrFields[N];c.mimeType&&P.overrideMimeType&&P.overrideMimeType(c.mimeType),!c.crossDomain&&!C["X-Requested-With"]&&(C["X-Requested-With"]="XMLHttpRequest");for(N in C)P.setRequestHeader(N,C[N]);y=function(Y){return function(){y&&(y=x=P.onload=P.onerror=P.onabort=P.ontimeout=P.onreadystatechange=null,Y==="abort"?P.abort():Y==="error"?typeof P.status!="number"?M(0,"error"):M(P.status,P.statusText):M(sc[P.status]||P.status,P.statusText,(P.responseType||"text")!=="text"||typeof P.responseText!="string"?{binary:P.response}:{text:P.responseText},P.getAllResponseHeaders()))}},P.onload=y(),x=P.onerror=P.ontimeout=y("error"),P.onabort!==void 0?P.onabort=x:P.onreadystatechange=function(){P.readyState===4&&e.setTimeout(function(){y&&x()})},y=y("abort");try{P.send(c.hasContent&&c.data||null)}catch(Y){if(y)throw Y}},abort:function(){y&&y()}}}),v.ajaxPrefilter(function(c){c.crossDomain&&(c.contents.script=!1)}),v.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/\b(?:java|ecma)script\b/},converters:{"text script":function(c){return v.globalEval(c),c}}}),v.ajaxPrefilter("script",function(c){c.cache===void 0&&(c.cache=!1),c.crossDomain&&(c.type="GET")}),v.ajaxTransport("script",function(c){if(c.crossDomain||c.scriptAttrs){var y,x;return{send:function(C,M){y=v("