diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 0dc244b8de2..12643485eea 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -1,7 +1,7 @@ Job execution failed.' + ); + $this->jobRunRepository->updateLogLocalizedWithDomain( + $jobRun, + $errorMessage, + $params + ); + } else { + $this->genericExecutionEngineLogger->info( + "[JobRun {$jobRun->getId()}]: " . $errorMessage . ' --> Job execution failed.' + ); + $jobRun->setCurrentMessage($errorMessage); + $this->jobRunRepository->update($jobRun); + $this->jobRunRepository->updateLog($jobRun, $errorMessage); + } + } + + /** + * @throws Exception + */ + private function dispatchStepMessage(JobRun $jobRun): void + { + $job = $jobRun->getJob(); + if (!$job instanceof Job) { + $this->setJobRunError( + $jobRun, + 'gee_error_no_job_definition', + ['%job_id%' => $jobRun->getId()] + ); + + return; + } + + $this->genericExecutionEngineLogger->info( + "[JobRun {$jobRun->getId()}]:" . + " Starting job step {$jobRun->getCurrentStep()} of Job '{$job->getName()}'." + ); + + $jobStep = $job->getSteps()[$jobRun->getCurrentStep()]; + $messageString = $jobStep->getMessageFQCN(); + + if (!class_exists($messageString)) { + $this->setJobRunError( + $jobRun, + 'gee_error_missing_message_implementation', + ['%message%' => $messageString, '%job_run_name%' => $job->getName()] + ); + + return; + } + + $this->dispatchSelectedElements( + $jobRun->getId(), + $jobRun->getCurrentStep(), + $messageString, + $this->getSelectionProcessingModeFromJobRun($jobRun), + $job->getSelectedElements() + ); + } + + private function getLogParams(JobRun $jobRun): array + { + return [ + self::LOG_JOB_RUN_ID_KEY => $jobRun->getId(), + self::LOG_JOB_RUN_NAME_KEY => $jobRun->getJob()?->getName(), + ]; + } + + /** + * @throws Exception + */ + private function setCompletionState(JobRun $jobRun): void + { + $message = ''; + + $logs = $this->jobRunErrorLogRepository->getLogsByJobRunId( + $jobRun->getId(), + $jobRun->getCurrentStep() + ); + + if (count($logs) === $jobRun->getTotalElements()) { + $jobRun->setState(JobRunStates::FAILED); + $message = 'gee_job_failed'; + } elseif (count($logs) > 0) { + $jobRun->setState(JobRunStates::FINISHED_WITH_ERRORS); + $message = 'gee_job_finished_with_errors'; + } + + if (empty($logs)) { + $jobRun->setCurrentMessage(null); + $jobRun->setState(JobRunStates::FINISHED); + $message = 'gee_job_finished'; + } + + $this->jobRunRepository->updateLogLocalizedWithDomain( + $jobRun, + $message, + $this->getLogParams($jobRun) + ); + } + + /** + * @param ElementDescriptor[] $selectedElements + */ + private function dispatchSelectedElements( + int $jobRunId, + int $currentStepId, + string $messageString, + SelectionProcessingMode $selectionProcessingMode, + array $selectedElements = [] + ): void { + if (empty($selectedElements) || $selectionProcessingMode === SelectionProcessingMode::ONCE) { + $this->executionEngineBus->dispatch(new $messageString( + $jobRunId, + $currentStepId + ) + ); + + return; + } + + foreach ($selectedElements as $selectedElement) { + $this->executionEngineBus->dispatch(new $messageString( + $jobRunId, + $currentStepId, + $selectedElement + ) + ); + } + } +} diff --git a/bundles/GenericExecutionEngineBundle/src/Agent/JobExecutionAgentInterface.php b/bundles/GenericExecutionEngineBundle/src/Agent/JobExecutionAgentInterface.php new file mode 100644 index 00000000000..eb5e1bb2d8b --- /dev/null +++ b/bundles/GenericExecutionEngineBundle/src/Agent/JobExecutionAgentInterface.php @@ -0,0 +1,62 @@ +validateContext($context); + + return $this->contexts[$context]['translations_domain']; + } + + public function getErrorHandlingFromContext(string $context): ?string + { + $this->validateContext($context); + + return $this->contexts[$context]['error_handling'] ?? null; + } + + private function validateContext(string $context): void + { + if (!isset($this->contexts[$context])) { + throw new ExecutionContextNotDefinedException( + sprintf('Execution context "%s" is not defined.', $context) + ); + } + } +} diff --git a/bundles/GenericExecutionEngineBundle/src/Configuration/ExecutionContextInterface.php b/bundles/GenericExecutionEngineBundle/src/Configuration/ExecutionContextInterface.php new file mode 100644 index 00000000000..d00056b5c99 --- /dev/null +++ b/bundles/GenericExecutionEngineBundle/src/Configuration/ExecutionContextInterface.php @@ -0,0 +1,27 @@ +resolveStepConfiguration($config); + } catch (Exception) { + return false; + } + + return true; + } + + protected function configureStep(): void + { + // not configured should be configured in the usage. + } + + /** + * @throws Exception + */ + private function resolveStepConfiguration(array $config): array + { + return $this->stepConfiguration->resolve($config); + } +} diff --git a/bundles/GenericExecutionEngineBundle/src/CurrentMessage/CurrentMessageProvider.php b/bundles/GenericExecutionEngineBundle/src/CurrentMessage/CurrentMessageProvider.php new file mode 100644 index 00000000000..2adac83f36a --- /dev/null +++ b/bundles/GenericExecutionEngineBundle/src/CurrentMessage/CurrentMessageProvider.php @@ -0,0 +1,59 @@ +translator); + } + + public function getPlainMessage(string $message): MessageInterface + { + return new PlainMessage($message); + } + + public function getMessageFromSerializedString(string $message): MessageInterface + { + try { + $message = json_decode($message, true, 512, JSON_THROW_ON_ERROR); + if (!isset($message['key'], $message['domain'], $message['params']) || !is_array($message['params'])) { + throw new InvalidJsonMessageException( + 'Message is not a valid json translation object. Missing key, parameters or domain.' + ); + } + + return new TranslationMessage($message['key'], $message['params'], $message['domain'], $this->translator); + + } catch (JsonException) { + return new PlainMessage($message); + } + } +} diff --git a/bundles/GenericExecutionEngineBundle/src/CurrentMessage/CurrentMessageProviderInterface.php b/bundles/GenericExecutionEngineBundle/src/CurrentMessage/CurrentMessageProviderInterface.php new file mode 100644 index 00000000000..e892c9725a3 --- /dev/null +++ b/bundles/GenericExecutionEngineBundle/src/CurrentMessage/CurrentMessageProviderInterface.php @@ -0,0 +1,37 @@ +getMessage(); + } + + public function getMessage(): string + { + return $this->message; + } +} diff --git a/bundles/GenericExecutionEngineBundle/src/CurrentMessage/TranslationMessage.php b/bundles/GenericExecutionEngineBundle/src/CurrentMessage/TranslationMessage.php new file mode 100644 index 00000000000..24af8138c7b --- /dev/null +++ b/bundles/GenericExecutionEngineBundle/src/CurrentMessage/TranslationMessage.php @@ -0,0 +1,57 @@ +buildMessageArray(), JSON_THROW_ON_ERROR); + } catch (JsonException) { + return ''; + } + } + + private function buildMessageArray(): array + { + return [ + 'key' => $this->key, + 'params' => $this->params, + 'domain' => $this->domain, + ]; + } + + public function getMessage(): string + { + return $this->translator->trans($this->key, $this->params, $this->domain); + } +} diff --git a/bundles/GenericExecutionEngineBundle/src/DependencyInjection/Configuration.php b/bundles/GenericExecutionEngineBundle/src/DependencyInjection/Configuration.php new file mode 100644 index 00000000000..5e67c2a2710 --- /dev/null +++ b/bundles/GenericExecutionEngineBundle/src/DependencyInjection/Configuration.php @@ -0,0 +1,63 @@ +getRootNode(); + $rootNode->addDefaultsIfNotSet(); + + $rootNode->children() + ->enumNode('error_handling') + ->values([ErrorHandlingMode::CONTINUE_ON_ERROR->value, ErrorHandlingMode::STOP_ON_FIRST_ERROR->value]) + ->info('Specifies how errors should be handled for all job run executions.') + ->defaultValue(ErrorHandlingMode::CONTINUE_ON_ERROR->value) + ->end() + ->arrayNode('execution_context') + ->prototype('array') + ->children() + ->scalarNode('translations_domain') + ->info('Translation domain which should be used by the job run. Default value is "admin".') + ->defaultValue('admin') + ->end() + ->enumNode('error_handling') + ->values( + [ + ErrorHandlingMode::CONTINUE_ON_ERROR->value, + ErrorHandlingMode::STOP_ON_FIRST_ERROR->value, + ] + ) + ->info( + 'Error handling behavior which should be used by the job run.' . + ' Overrides the global value.' + ) + ->end() + ->end() + ->end() + ->end(); + + return $treeBuilder; + } +} diff --git a/bundles/GenericExecutionEngineBundle/src/DependencyInjection/PimcoreGenericExecutionEngineExtension.php b/bundles/GenericExecutionEngineBundle/src/DependencyInjection/PimcoreGenericExecutionEngineExtension.php new file mode 100644 index 00000000000..40b21fc2022 --- /dev/null +++ b/bundles/GenericExecutionEngineBundle/src/DependencyInjection/PimcoreGenericExecutionEngineExtension.php @@ -0,0 +1,49 @@ +processConfiguration($configuration, $configs); + $loader = new YamlFileLoader($container, new FileLocator(__DIR__ . '/../../config')); + $loader->load('services.yaml'); + + $definition = $container->getDefinition(ExecutionContextInterface::class); + $definition->setArgument('$contexts', $config['execution_context'] ?? []); + + $definition = $container->getDefinition(JobExecutionAgentInterface::class); + $definition->setArgument( + '$errorHandlingMode', + $config['error_handling'] ?? ErrorHandlingMode::CONTINUE_ON_ERROR->value + ); + } +} diff --git a/bundles/GenericExecutionEngineBundle/src/Entity/JobRun.php b/bundles/GenericExecutionEngineBundle/src/Entity/JobRun.php new file mode 100644 index 00000000000..a266b78f8a1 --- /dev/null +++ b/bundles/GenericExecutionEngineBundle/src/Entity/JobRun.php @@ -0,0 +1,282 @@ +creationDate = time(); + $this->modificationDate = time(); + $this->ownerId = $ownerId; + $this->executionContext = self::DEFAULT_EXECUTION_CONTEXT; + } + + public function getId(): int + { + return $this->id; + } + + public function setId(int $id): void + { + $this->id = $id; + } + + public function getOwnerId(): ?int + { + return $this->ownerId; + } + + public function getState(): ?JobRunStates + { + return $this->state; + } + + public function setState(?JobRunStates $state): void + { + $this->state = $state; + } + + public function getCurrentStep(): ?int + { + return $this->currentStep; + } + + public function setCurrentStep(?int $currentStep): void + { + $this->currentStep = $currentStep; + } + + public function getCurrentMessage(): string + { + if ($this->currentMessage) { + return $this->currentMessage; + } + + return ''; + } + + public function setCurrentMessage(?string $currentMessage): void + { + $this->currentMessage = $currentMessage; + } + + /** + * @return LogLine[] + */ + public function getLogs(): array + { + if ($this->log === null) { + return []; + } + + $logLines = explode("\n", $this->log); + + return array_map(static fn ($line) => new LogLine($line), $logLines); + } + + public function setLog(?string $log): void + { + $this->log = $log; + } + + #[ORM\PrePersist] + #[ORM\PreUpdate] + public function serializeJob(): void + { + if ($this->getJob() !== null) { + $this->serializedJob = $this->getSerializer()->serialize($this->getJob(), 'json'); + } else { + $this->serializedJob = null; + } + } + + #[ORM\PostLoad] + public function deserializeJob(): void + { + if ($this->serializedJob) { + $this->setJob($this->getSerializer()->deserialize($this->serializedJob, Job::class, 'json')); + } + } + + public function getJob(): ?Job + { + return $this->job; + } + + public function setJob(Job $job): void + { + $this->job = $job; + } + + public function getContext(): ?array + { + return $this->context; + } + + public function setContext(?array $context): void + { + $this->context = $context; + } + + public function getCreationDate(): int + { + return $this->creationDate; + } + + public function getModificationDate(): int + { + return $this->modificationDate; + } + + #[ORM\PrePersist] + #[ORM\PreUpdate] + public function updateModificationDate(): void + { + $this->modificationDate = time(); + } + + public function getExecutionContext(): string + { + return $this->executionContext; + } + + public function setExecutionContext(string $executionContext): void + { + $this->executionContext = $executionContext; + } + + public function setCurrentMessageLocalized(MessageInterface $message): void + { + $this->setCurrentMessage($message->getSerializedString()); + } + + public function getTotalElements(): int + { + return $this->totalElements; + } + + public function setTotalElements(int $totalElements): void + { + $this->totalElements = $totalElements; + } + + public function getProcessedElementsForStep(): int + { + return $this->processedElementsForStep; + } + + public function setProcessedElementsForStep(int $processedElementsForStep): void + { + $this->processedElementsForStep = $processedElementsForStep; + } + + private function getSerializer(): SerializerInterface + { + if ($this->serializer === null) { + $encoder = [ + new JsonEncoder(), + ]; + $extractor = new PropertyInfoExtractor( + [], + [ + new PhpDocExtractor(), + new ReflectionExtractor(), + ] + ); + $normalizer = [ + new ArrayDenormalizer(), + new BackedEnumNormalizer(), + new ObjectNormalizer(null, null, null, $extractor), + ]; + $this->serializer = new Serializer( + $normalizer, + $encoder + ); + } + + return $this->serializer; + } +} diff --git a/bundles/GenericExecutionEngineBundle/src/Entity/JobRunErrorLog.php b/bundles/GenericExecutionEngineBundle/src/Entity/JobRunErrorLog.php new file mode 100644 index 00000000000..f59e1c48459 --- /dev/null +++ b/bundles/GenericExecutionEngineBundle/src/Entity/JobRunErrorLog.php @@ -0,0 +1,90 @@ +jobRunId = $jobRunId; + $this->stepNumber = $stepNumber; + $this->elementId = $elementId; + $this->errorMessage = $errorMessage; + } + + public function getId(): int + { + return $this->id; + } + + public function setId(int $id): void + { + $this->id = $id; + } + + public function getJobRunId(): int + { + return $this->jobRunId; + } + + public function getElementId(): ?int + { + return $this->elementId; + } + + public function getStepNumber(): ?int + { + return $this->stepNumber; + } + + public function getErrorMessage(): ?string + { + return $this->errorMessage; + } +} diff --git a/bundles/GenericExecutionEngineBundle/src/Event/JobRunStateChangedEvent.php b/bundles/GenericExecutionEngineBundle/src/Event/JobRunStateChangedEvent.php new file mode 100644 index 00000000000..b7a1475aa1b --- /dev/null +++ b/bundles/GenericExecutionEngineBundle/src/Event/JobRunStateChangedEvent.php @@ -0,0 +1,57 @@ +jobRunId; + } + + public function getJobName(): string + { + return $this->jobName; + } + + public function getJobRunOwnerId(): int + { + return $this->jobRunOwnerId; + } + + public function getOldState(): string + { + return $this->oldState; + } + + public function getNewState(): string + { + return $this->newState; + } +} diff --git a/bundles/GenericExecutionEngineBundle/src/EventSubscriber/JobExecutionSubscriber.php b/bundles/GenericExecutionEngineBundle/src/EventSubscriber/JobExecutionSubscriber.php new file mode 100644 index 00000000000..8641497c08a --- /dev/null +++ b/bundles/GenericExecutionEngineBundle/src/EventSubscriber/JobExecutionSubscriber.php @@ -0,0 +1,70 @@ + 'onWorkerMessageFailed', + WorkerMessageHandledEvent::class => 'onWorkerMessageHandled', + ]; + } + + public function __construct( + private readonly JobExecutionAgentInterface $jobExecutionAgent + ) { + } + + public function onWorkerMessageFailed(WorkerMessageFailedEvent $event): void + { + $message = $event->getEnvelope()->getMessage(); + if (!$message instanceof GenericExecutionEngineMessageInterface) { + return; + } + + if ($event->willRetry()) { + return; + } + + $throwable = $this->getFirstThrowable($event->getThrowable()); + $this->jobExecutionAgent->continueJobMessageExecution($message, $throwable); + } + + public function onWorkerMessageHandled(WorkerMessageHandledEvent $event): void + { + $message = $event->getEnvelope()->getMessage(); + if (!$message instanceof GenericExecutionEngineMessageInterface) { + return; + } + + $this->jobExecutionAgent->continueJobMessageExecution($message); + } +} diff --git a/bundles/GenericExecutionEngineBundle/src/EventSubscriber/JobRunStatusChangeSubscriber.php b/bundles/GenericExecutionEngineBundle/src/EventSubscriber/JobRunStatusChangeSubscriber.php new file mode 100644 index 00000000000..370d22aafa4 --- /dev/null +++ b/bundles/GenericExecutionEngineBundle/src/EventSubscriber/JobRunStatusChangeSubscriber.php @@ -0,0 +1,65 @@ +getObject(); + + if (!$entity instanceof JobRun) { + return; + } + + if ($args->hasChangedField(self::STATE_FIELD)) { + $oldStatus = $args->getOldValue(self::STATE_FIELD); + $newStatus = $args->getNewValue(self::STATE_FIELD); + + if ($oldStatus !== $newStatus) { + $jobRun = $this->jobRunRepository->getJobRunById($entity->getId()); + $jobName = $jobRun->getJob()?->getName(); + $event = new JobRunStateChangedEvent( + jobRunId: $entity->getId(), + jobName: $jobName, + jobRunOwnerId: $jobRun->getOwnerId(), + oldState: $oldStatus, + newState: $newStatus + ); + $this->eventDispatcher->dispatch($event); + } + } + } +} diff --git a/bundles/TinymceBundle/src/Installer.php b/bundles/GenericExecutionEngineBundle/src/Exception/ExecutionContextNotDefinedException.php similarity index 75% rename from bundles/TinymceBundle/src/Installer.php rename to bundles/GenericExecutionEngineBundle/src/Exception/ExecutionContextNotDefinedException.php index dcf1272393e..bd7d67156f4 100644 --- a/bundles/TinymceBundle/src/Installer.php +++ b/bundles/GenericExecutionEngineBundle/src/Exception/ExecutionContextNotDefinedException.php @@ -14,13 +14,13 @@ * @license http://www.pimcore.org/license GPLv3 and PCL */ -namespace Pimcore\Bundle\TinymceBundle; +namespace Pimcore\Bundle\GenericExecutionEngineBundle\Exception; -use Pimcore\Extension\Bundle\Installer\SettingsStoreAwareInstaller; +use RuntimeException; /** * @internal */ -class Installer extends SettingsStoreAwareInstaller +final class ExecutionContextNotDefinedException extends RuntimeException { } diff --git a/bundles/GenericExecutionEngineBundle/src/Exception/InvalidJsonMessageException.php b/bundles/GenericExecutionEngineBundle/src/Exception/InvalidJsonMessageException.php new file mode 100644 index 00000000000..a2b54eb15fb --- /dev/null +++ b/bundles/GenericExecutionEngineBundle/src/Exception/InvalidJsonMessageException.php @@ -0,0 +1,26 @@ +jobRunRepository->getJobRunById($message->getJobRunId(), $forceReload); + } + + public function getJobStep(GenericExecutionEngineMessageInterface $message): JobStepInterface + { + $jobRun = $this->getJobRun($message); + $jobSteps = $jobRun->getJob()?->getSteps(); + + if (!array_key_exists($message->getCurrentJobStep(), $jobSteps)) { + throw new NotFoundException('Job not found!'); + } + + return $jobSteps[$message->getCurrentJobStep()]; + } + + public function getEnvironmentData(JobRun $jobRun): array + { + if (!$jobRun->getJob()) { + return []; + } + + return $jobRun->getJob()->getEnvironmentData(); + } + + /** + * Logs a translation key to the job run which can be viewed in the job run overview + * + * @throws Exception + */ + public function logMessageToJobRun( + JobRun $jobRun, + string $translationKey, + array $params = [] + ): void { + $this->jobRunRepository->updateLogLocalized( + $jobRun, + $translationKey, + $params + ); + } + + public function checkCondition(GenericExecutionEngineMessageInterface $message): bool + { + $jobRun = $this->getJobRun($message); + $jobRunContext = $jobRun->getContext(); + $currentStep = $this->getJobStep($message); + $currentStepCondition = $currentStep->getCondition(); + $contentVariables = $this->extractContentVariables($jobRunContext, $this->getEnvironmentData($jobRun)); + + if ($currentStepCondition === '') { + return true; + } + + return $this->symfonyExpressionService->evaluate($currentStepCondition, $contentVariables); + } + + private function extractContentVariables( + ?array $jobRunContext = null, + ?array $environmentData = null + ): array { + $variables = []; + if (!empty($jobRunContext)) { + $variables['context'] = $jobRunContext; + } + if (!empty($environmentData)) { + $variables['environmentData'] = $environmentData; + } + + return $variables; + } + + public function getElementFromMessage( + GenericExecutionEngineMessageInterface $message, + array $types = [JobRunExtractorInterface::ASSET_TYPE] + ): ?ElementInterface { + $elementDescriptor = $message->getElement(); + if (!$elementDescriptor) { + return null; + } + + $element = $this->getElementByType( + $elementDescriptor->getType(), + $elementDescriptor->getId(), + $types + ); + + if (!$element) { + return null; + } + + return $element; + } + + public function getElementsFromMessage( + GenericExecutionEngineMessageInterface $message, + array $types = [JobRunExtractorInterface::ASSET_TYPE] + ): array { + + $elementsToProcess = []; + $jobRun = $this->getJobRun($message); + + /** @var ElementDescriptor[] $elementDescriptors */ + $elementDescriptors = $jobRun->getJob()?->getSelectedElements(); + + foreach ($elementDescriptors as $elementDescriptor) { + $element = $this->getElementByType( + $elementDescriptor->getType(), + $elementDescriptor->getId(), + $types + ); + if ($element !== null) { + $elementsToProcess[] = $element; + } + } + + return $elementsToProcess; + } + + private function getElement(string $type, int $id): ?ElementInterface + { + $element = Service::getElementById($type, $id); + + if (!$element || $element->getType() === JobRunExtractorInterface::FOLDER_TYPE) { + return null; + } + + return $element; + } + + private function getElementByType( + string $elementType, + int $elementId, + array $typesToLookFor = [JobRunExtractorInterface::ASSET_TYPE]): ?ElementInterface + { + + if (!in_array($elementType, $typesToLookFor, true)) { + return null; + } + + return $this->getElement($elementType, $elementId); + } +} diff --git a/bundles/GenericExecutionEngineBundle/src/Extractor/JobRunExtractorInterface.php b/bundles/GenericExecutionEngineBundle/src/Extractor/JobRunExtractorInterface.php new file mode 100644 index 00000000000..5c42c7efa65 --- /dev/null +++ b/bundles/GenericExecutionEngineBundle/src/Extractor/JobRunExtractorInterface.php @@ -0,0 +1,58 @@ +currentMessageProvider->getMessageFromSerializedString( + $jobRun->getCurrentMessage() + ); + + $domain = $this->executionContext->getTranslationDomain($jobRun->getExecutionContext()); + + return [ + 'id' => $jobRun->getId(), + 'job_name' => $this->translator->trans($jobRun->getJob()?->getName(), [], $domain), + 'started_at' => $jobRun->getCreationDate(), + 'last_update_at' => $jobRun->getModificationDate(), + 'owner' => $jobRun->getOwnerId() ? User::getById($jobRun->getOwnerId())?->getName() : null, + 'state' => $jobRun->getState()->value, + 'current_step' => $jobRun->getCurrentStep(), + 'current_message' => $currentMessage->getMessage(), + 'canCancel' => $jobRun->getState() === JobRunStates::RUNNING, + 'log' => array_map( + static fn (LogLine $line) => + [ + 'logMessage' => $line->getLogLine(), + 'createdAt' => $line->getCreatedAt()->format(DateTimeInterface::ATOM), + ], + $jobRun->getLogs() + ), + ]; + } +} diff --git a/bundles/GenericExecutionEngineBundle/src/Grid/JobRunGridInterface.php b/bundles/GenericExecutionEngineBundle/src/Grid/JobRunGridInterface.php new file mode 100644 index 00000000000..703842a8b1b --- /dev/null +++ b/bundles/GenericExecutionEngineBundle/src/Grid/JobRunGridInterface.php @@ -0,0 +1,27 @@ +installBundle(); + parent::install(); + } + + /** + * @throws Exception + */ + public function uninstall(): void + { + $this->uninstallBundle(); + parent::uninstall(); + } + + /** + * @throws SchemaException|Exception + */ + private function installBundle(): void + { + $currentSchema = $this->db->createSchemaManager()->introspectSchema(); + + $this->installJobRunTable($currentSchema); + $this->installLogTable($currentSchema); + $this->addUserPermission($currentSchema); + $this->executeDiffSql($currentSchema); + } + + /** + * @throws Exception + */ + private function uninstallBundle(): void + { + $currentSchema = $this->db->createSchemaManager()->introspectSchema(); + + $this->executeDiffSql($currentSchema); + $this->removeUserPermission($currentSchema); + $this->removeLogTable($currentSchema); + $this->removeJobRunTable($currentSchema); + } + + /** + * @throws SchemaException + */ + private function installJobRunTable(Schema $schema): void + { + if (!$schema->hasTable(TableConstants::JOB_RUN_TABLE)) { + $jobRunTable = $schema->createTable(TableConstants::JOB_RUN_TABLE); + $jobRunTable->addColumn('id', 'integer', [ + 'autoincrement' => true, + 'notnull' => true, + 'unsigned' => true, + ]); + $jobRunTable->addColumn('ownerId', 'integer', ['notnull' => false, 'unsigned' => true]); + $jobRunTable->addColumn('state', 'string', ['notnull' => true, 'length' => 100]); + $jobRunTable->addColumn('currentStep', 'integer', ['notnull' => false, 'unsigned' => true]); + $jobRunTable->addColumn( + 'currentMessage', + 'text', + [ + 'notnull' => false, + 'length' => 65535, + ] + ); + $jobRunTable->addColumn('log', 'text', ['notnull' => false, 'length' => 65535]); + $jobRunTable->addColumn( + 'serializedJob', + 'text', + [ + 'notnull' => false, + 'length' => 4294967295, + ] + ); + $jobRunTable->addColumn('context', 'text', ['notnull' => false, 'length' => 4294967295]); + $jobRunTable->addColumn('creationDate', 'integer', ['notnull' => false]); + $jobRunTable->addColumn('modificationDate', 'integer', ['notnull' => false]); + $jobRunTable->addColumn('executionContext', 'string', [ + 'notnull' => false, + 'length' => 255, + 'default' => JobRun::DEFAULT_EXECUTION_CONTEXT, + ]); + $jobRunTable->addColumn('totalElements', 'integer', [ + 'notnull' => true, + 'unsigned' => true, + ]); + $jobRunTable->addColumn('processedElementsForStep', 'integer', [ + 'notnull' => true, + 'unsigned' => true, + ]); + + $jobRunTable->addForeignKeyConstraint( + 'users', + ['ownerId'], + ['id'], + ['onDelete' => 'SET NULL'], + 'fk_generic_job_execution_owner_users' + ); + + $jobRunTable->setPrimaryKey(['id']); + } + } + + /** + * @throws SchemaException + */ + private function installLogTable(Schema $schema): void + { + if ($schema->hasTable(TableConstants::ERROR_LOG_TABLE)) { + return; + } + + $logTable = $schema->createTable(TableConstants::ERROR_LOG_TABLE); + $logTable->addColumn('id', 'integer', [ + 'autoincrement' => true, + 'notnull' => true, + 'unsigned' => true, + ]); + $logTable->addColumn('jobRunId', 'integer', ['notnull' => true, 'unsigned' => true]); + $logTable->addColumn('stepNumber', 'integer', ['notnull' => true, 'unsigned' => true]); + $logTable->addColumn('elementId', 'integer', ['notnull' => false, 'unsigned' => true]); + $logTable->addColumn('errorMessage', 'text', ['notnull' => false, 'length' => 65535]); + + $logTable->addForeignKeyConstraint( + TableConstants::JOB_RUN_TABLE, + ['jobRunId'], + ['id'], + ['onDelete' => 'CASCADE'], + 'fk_generic_job_execution_log_jobs' + ); + + $logTable->setPrimaryKey(['id']); + } + + /** + * @throws Exception + */ + private function removeJobRunTable(Schema $schema): void + { + if ($schema->hasTable(TableConstants::JOB_RUN_TABLE)) { + $this->db->executeStatement('DROP TABLE ' . TableConstants::JOB_RUN_TABLE); + } + } + + /** + * @throws Exception + */ + private function removeLogTable(Schema $schema): void + { + if ($schema->hasTable(TableConstants::ERROR_LOG_TABLE)) { + $this->db->executeStatement('DROP TABLE ' . TableConstants::ERROR_LOG_TABLE); + } + } + + /** + * @throws Exception + */ + private function addUserPermission(Schema $schema): void + { + if ($schema->hasTable(TableConstants::USER_PERMISSION_DEF_TABLE)) { + foreach (self::USER_PERMISSIONS as $permission) { + $queryBuilder = $this->db->createQueryBuilder(); + $queryBuilder + ->insert(TableConstants::USER_PERMISSION_DEF_TABLE) + ->values([ + $this->db->quoteIdentifier('key') => ':key', + $this->db->quoteIdentifier('category') => ':category', + ]) + ->setParameters([ + 'key' => $permission, + 'category' => self::USER_PERMISSIONS_CATEGORY, + ]); + + $queryBuilder->executeStatement(); + } + } + } + + /** + * @throws Exception + */ + private function removeUserPermission(Schema $schema): void + { + if ($schema->hasTable(TableConstants::USER_PERMISSION_DEF_TABLE)) { + foreach (self::USER_PERMISSIONS as $permission) { + $queryBuilder = $this->db->createQueryBuilder(); + $queryBuilder + ->delete(TableConstants::USER_PERMISSION_DEF_TABLE) + ->where($this->db->quoteIdentifier('key') . ' = :key') + ->setParameter('key', $permission); + + $queryBuilder->executeStatement(); + } + } + } + + /** + * @throws Exception + */ + private function executeDiffSql(Schema $newSchema): void + { + $currentSchema = $this->db->createSchemaManager()->introspectSchema(); + $dbPlatform = $this->db->getDatabasePlatform(); + $schemaComparator = new Comparator($dbPlatform); + $schemaDiff = $schemaComparator->compareSchemas($currentSchema, $newSchema); + + $sqlStatements = $dbPlatform->getAlterSchemaSQL($schemaDiff); + + if (!empty($sqlStatements)) { + $this->db->executeStatement(implode(';', $sqlStatements)); + } + } +} diff --git a/bundles/GenericExecutionEngineBundle/src/Messenger/Handler/AbstractAutomationActionHandler.php b/bundles/GenericExecutionEngineBundle/src/Messenger/Handler/AbstractAutomationActionHandler.php new file mode 100644 index 00000000000..6785d46a701 --- /dev/null +++ b/bundles/GenericExecutionEngineBundle/src/Messenger/Handler/AbstractAutomationActionHandler.php @@ -0,0 +1,267 @@ +stepConfiguration = new OptionsResolver(); + } + + #[Required] + public function setJobRunRepository(JobRunRepositoryInterface $jobRunRepository): void + { + if (!$this->jobRunRepository) { + $this->jobRunRepository = $jobRunRepository; + } + } + + #[Required] + public function setJobRunExtractor(JobRunExtractorInterface $jobRunExtractor): void + { + if (!$this->jobRunExtractor) { + $this->jobRunExtractor = $jobRunExtractor; + } + } + + #[Required] + public function setJobExecutionAgent(JobExecutionAgentInterface $jobExecutionAgent): void + { + if (!$this->jobExecutionAgent) { + $this->jobExecutionAgent = $jobExecutionAgent; + } + } + + #[Required] + public function setLogger(LoggerInterface $genericExecutionEngineLogger): void + { + if (!$this->genericExecutionEngineLogger) { + $this->genericExecutionEngineLogger = $genericExecutionEngineLogger; + } + } + + #[Required] + public function setTranslator(TranslatorInterface $translator): void + { + if (!$this->translator) { + $this->translator = $translator; + } + } + + /** + * @template exceptionClassName of Exception + * + * @param class-string $exceptionClassName + * + * @throws exceptionClassName + */ + public function abortAction( + string $translationKey, + array $translationParams = [], + string $translationDomain = 'default', + string $exceptionClassName = Exception::class + ): void { + $errorMessage = $this->translator->trans($translationKey, $translationParams, $translationDomain); + + throw new $exceptionClassName($errorMessage); + } + + /** + * Logs a translation key to the job run which can be viewed in the job run overview + * Translation key then can be translated check pimcore_job_execution.en.yaml + * + */ + protected function logMessageToJobRun( + JobRun $jobRun, + string $translationKey, + array $params = [] + ): void { + $this->jobRunExtractor->logMessageToJobRun($jobRun, $translationKey, $params); + } + + protected function getJobRun(GenericExecutionEngineMessageInterface $message, bool $forceReload = false): JobRun + { + return $this->jobRunExtractor->getJobRun($message, $forceReload); + } + + protected function getJobStep(GenericExecutionEngineMessageInterface $message): JobStepInterface + { + return $this->jobRunExtractor->getJobStep($message); + } + + protected function getCurrentJobStepConfig(GenericExecutionEngineMessageInterface $message): array + { + $jobStep = $this->getJobStep($message); + + $config = $jobStep->getConfig(); + + try { + $this->configureStep(); + $config = $this->resolveStepConfiguration($config); + } catch (Exception $e) { + throw new InvalidStepConfigurationException($e->getMessage()); + } + + return $config; + } + + protected function getEnvironmentVariables( + GenericExecutionEngineMessageInterface $message + ): array { + $jobRun = $this->getJobRun($message); + $job = $jobRun->getJob(); + + return $job === null ? [] : $job->getEnvironmentData(); + } + + protected function replaceConfigValueWithEnvVariable( + string $value, + array $variables + ): mixed { + if (!preg_match_all("/job_env\('([^']*)'\)/", $value, $matches)) { + return $value; + } + if (empty($matches[1])) { + return $value; + } + $envVariableKey = $matches[1][0]; + if (!array_key_exists($envVariableKey, $variables)) { + throw new NotFoundException("Missing environment variable $envVariableKey"); + } + + return $variables[$envVariableKey]; + } + + protected function extractConfigFieldFromJobStepConfig( + GenericExecutionEngineMessageInterface $message, + string $key + ): mixed { + $config = $this->getCurrentJobStepConfig($message); + if (!array_key_exists($key, $config)) { + throw new NotFoundException("Missing configuration $key"); + } + + $value = $config[$key]; + + return $this->recursivelyReplaceConfigValuesWithEnvVariables($message, $value); + } + + protected function recursivelyReplaceConfigValuesWithEnvVariables( + GenericExecutionEngineMessageInterface $message, + mixed $configValue + ): mixed { + + if (is_string($configValue)) { + return $this->replaceConfigValueWithEnvVariable( + $configValue, + $this->getEnvironmentVariables($message) + ); + } + + if (is_array($configValue)) { + $replacedValue = []; + foreach ($configValue as $key => $value) { + $replacedValue[$key] = $this->recursivelyReplaceConfigValuesWithEnvVariables($message, $value); + } + + return $replacedValue; + } + + return $configValue; + } + + protected function updateJobRunContext( + JobRun $jobRun, + string $key, + mixed $value, + ): void { + $context = $jobRun->getContext(); + $context[$key] = $value; + $jobRun->setContext($context); + $this->jobRunRepository->update($jobRun); + } + + protected function throwUnRecoverableException(Throwable $exception): void + { + throw new UnrecoverableMessageHandlingException($exception->getMessage(), 0, $exception); + } + + protected function isRunning( + JobRun $jobRun + ): bool { + return $this->jobExecutionAgent->isRunning($jobRun->getId()); + } + + protected function getSubjectFromMessage( + GenericExecutionEngineMessageInterface $message, + array $types = [JobRunExtractorInterface::OBJECT_TYPE, JobRunExtractorInterface::ASSET_TYPE] + ): ?AbstractElement { + /** @var AbstractElement $subject */ + $subject = $this->jobRunExtractor->getElementFromMessage($message, $types); + + return $subject; + } + + /** + * @return AbstractElement[] + */ + protected function getSubjectsFromMessage( + GenericExecutionEngineMessageInterface $message, + array $types = [JobRunExtractorInterface::OBJECT_TYPE, JobRunExtractorInterface::ASSET_TYPE] + ): array { + /** @var AbstractElement[] $subjects */ + $subjects = $this->jobRunExtractor->getElementsFromMessage($message, $types); + + return $subjects; + } + + protected function setSelectedElementsForNextJobStep(JobRun $jobRun, array $selectedElements): void + { + $this->jobRunRepository->updateSelectedElements($jobRun, $selectedElements); + } +} diff --git a/bundles/GenericExecutionEngineBundle/src/Messenger/Messages/AbstractExecutionEngineMessage.php b/bundles/GenericExecutionEngineBundle/src/Messenger/Messages/AbstractExecutionEngineMessage.php new file mode 100644 index 00000000000..e45d584d9a6 --- /dev/null +++ b/bundles/GenericExecutionEngineBundle/src/Messenger/Messages/AbstractExecutionEngineMessage.php @@ -0,0 +1,49 @@ +jobRunId; + } + + public function getCurrentJobStep(): int + { + return $this->currentJobStep; + } + + public function getElement(): ?ElementDescriptor + { + return $this->element; + } +} diff --git a/bundles/GenericExecutionEngineBundle/src/Messenger/Messages/GenericExecutionEngineMessageInterface.php b/bundles/GenericExecutionEngineBundle/src/Messenger/Messages/GenericExecutionEngineMessageInterface.php new file mode 100644 index 00000000000..a96d9cf3841 --- /dev/null +++ b/bundles/GenericExecutionEngineBundle/src/Messenger/Messages/GenericExecutionEngineMessageInterface.php @@ -0,0 +1,32 @@ +getMessage(); + if ($message instanceof GenericExecutionEngineMessageInterface) { + if ($this->jobRunExtractor->checkCondition($message)) { + return $stack->next()->handle($envelope, $stack); + } + + $this->logToJobRun( + $message, + ); + + $this->jobExecutionAgent->continueJobMessageExecution($message); + + return $envelope; + } + + return $stack->next()->handle($envelope, $stack); + } + + private function logToJobRun( + GenericExecutionEngineMessageInterface $message + ): void { + $jobRun = $this->jobRunExtractor->getJobRun($message); + $jobName = $jobRun->getJob()?->getName(); + $stepId = $message->getCurrentJobStep(); + $stepName = $jobRun->getJob()?->getSteps()[$stepId]->getName(); + $params['%jobName%'] = $jobName; + $params['%stepId%'] = $stepId; + $params['%stepName%'] = $stepName; + + $this->jobRunExtractor->logMessageToJobRun( + $jobRun, + 'gee_middleware_step_condition_not_met', + $params + ); + + $this->genericExecutionEngineLogger->info( + "[JobRun {$jobRun->getId()}]: + Skipping step $stepName with id $stepId of Job '$jobName', job condition not met." + ); + } +} diff --git a/bundles/GenericExecutionEngineBundle/src/Migrations/.empty b/bundles/GenericExecutionEngineBundle/src/Migrations/.empty new file mode 100644 index 00000000000..e69de29bb2d diff --git a/bundles/GenericExecutionEngineBundle/src/Model/Job.php b/bundles/GenericExecutionEngineBundle/src/Model/Job.php new file mode 100644 index 00000000000..c5fd8f6fdd0 --- /dev/null +++ b/bundles/GenericExecutionEngineBundle/src/Model/Job.php @@ -0,0 +1,72 @@ +steps)) { + throw new InvalidArgumentException('Job must have at least one step'); + } + } + + public function getName(): string + { + return $this->name; + } + + /** + * @return JobStep[] + */ + public function getSteps(): array + { + return $this->steps; + } + + /** + * @return ElementDescriptor[] $selectedElements + */ + public function getSelectedElements(): array + { + return $this->selectedElements; + } + + public function getEnvironmentData(): array + { + return $this->environmentData; + } + + /** + * @param ElementDescriptor[] $selectedElements + */ + public function setSelectedElements(array $selectedElements): void + { + $this->selectedElements = $selectedElements; + } +} diff --git a/bundles/GenericExecutionEngineBundle/src/Model/JobRunStates.php b/bundles/GenericExecutionEngineBundle/src/Model/JobRunStates.php new file mode 100644 index 00000000000..9ee0581a14f --- /dev/null +++ b/bundles/GenericExecutionEngineBundle/src/Model/JobRunStates.php @@ -0,0 +1,28 @@ +name; + } + + public function getMessageFQCN(): string + { + return $this->messageFQCN; + } + + public function getConfig(): array + { + return $this->config; + } + + public function getCondition(): string + { + return $this->condition; + } + + public function getSelectionProcessingMode(): SelectionProcessingMode + { + return $this->selectionProcessingMode; + } +} diff --git a/bundles/GenericExecutionEngineBundle/src/Model/JobStepInterface.php b/bundles/GenericExecutionEngineBundle/src/Model/JobStepInterface.php new file mode 100644 index 00000000000..74c188c263f --- /dev/null +++ b/bundles/GenericExecutionEngineBundle/src/Model/JobStepInterface.php @@ -0,0 +1,32 @@ +container->get(Installer::class); + } +} diff --git a/bundles/GenericExecutionEngineBundle/src/Repository/JobRunErrorLogRepository.php b/bundles/GenericExecutionEngineBundle/src/Repository/JobRunErrorLogRepository.php new file mode 100644 index 00000000000..7c972d4d345 --- /dev/null +++ b/bundles/GenericExecutionEngineBundle/src/Repository/JobRunErrorLogRepository.php @@ -0,0 +1,90 @@ +getId(), + $jobRun->getCurrentStep(), + $elementId, + $message + ); + + $this->pimcoreEntityManager->persist($jobRunErrorLog); + $this->pimcoreEntityManager->flush(); + } + + public function update(JobRunErrorLog $jobRunErrorLog): void + { + $this->pimcoreEntityManager->persist($jobRunErrorLog); + $this->pimcoreEntityManager->flush(); + } + + /** + * @return JobRunErrorLog[] + */ + public function getLogsByJobRunId( + int $jobRunId, + ?int $step = null, + array $orderBy = [], + int $limit = 100, + int $offset = 0 + ): array { + $criteria = ['jobRunId' => $jobRunId]; + if ($step !== null && $step >= 0) { + $criteria['step'] = $step; + } + + return $this->getLogRepository()->findBy( + $criteria, + $orderBy, + $limit, + $offset + ); + } + + public function getTotalCount(): int + { + return $this->getLogRepository()->count([]); + } + + public function getTotalCountByJobRunId(int $jobRunId): int + { + return $this->getLogRepository()->count(['jobRunId' => $jobRunId]); + } + + private function getLogRepository(): EntityRepository + { + return $this->pimcoreEntityManager->getRepository(JobRunErrorLog::class); + } +} diff --git a/bundles/GenericExecutionEngineBundle/src/Repository/JobRunErrorLogRepositoryInterface.php b/bundles/GenericExecutionEngineBundle/src/Repository/JobRunErrorLogRepositoryInterface.php new file mode 100644 index 00000000000..07b9f97e862 --- /dev/null +++ b/bundles/GenericExecutionEngineBundle/src/Repository/JobRunErrorLogRepositoryInterface.php @@ -0,0 +1,46 @@ +setJob($job); + + $this->pimcoreEntityManager->persist($jobRun); + $this->pimcoreEntityManager->flush(); + + return $jobRun; + } + + public function update(JobRun $jobRun): JobRun + { + + $this->pimcoreEntityManager->persist($jobRun); + $this->pimcoreEntityManager->flush(); + + return $jobRun; + } + + /** + * @throws Exception + * + * @internal + */ + public function updateLogLocalizedWithDomain( + JobRun $jobRun, + string $message, + array $params = [], + bool $updateCurrentMessage = true, + string $defaultLocale = 'en', + string $domain = 'admin' + ): void { + if ($updateCurrentMessage) { + $jobRun->setCurrentMessageLocalized( + $this->currentMessageProvider->getTranslationMessages($message, $params, $domain) + ); + $this->update($jobRun); + } + + $translatedMessage = $this->translator->trans($message, $params, $domain, $defaultLocale); + $this->updateLog($jobRun, $translatedMessage); + } + + public function updateLogLocalized( + JobRun $jobRun, + string $message, + array $params = [], + bool $updateCurrentMessage = true, + string $defaultLocale = 'en' + ): void { + $domain = $this->executionContext->getTranslationDomain($jobRun->getExecutionContext()); + + $this->updateLogLocalizedWithDomain( + $jobRun, + $message, + $params, + $updateCurrentMessage, + $defaultLocale, + $domain + ); + } + + /** + * @throws Exception + */ + public function updateLog(JobRun $jobRun, string $message): void + { + + $this->db->executeStatement( + 'UPDATE ' . + TableConstants::JOB_RUN_TABLE . + ' SET log = IF(ISNULL(log),:message,CONCAT(log, "\n", :message)) WHERE id = :id', + [ + 'id' => $jobRun->getId(), + 'message' => (new DateTimeImmutable())->format('c') . ': ' . trim($message), + ] + ); + + $this->genericExecutionEngineLogger->info("[JobRun {$jobRun->getId()}]: " . $message); + + $this->pimcoreEntityManager->refresh($jobRun); + } + + public function getJobRunById(int $id, bool $forceReload = false, ?int $ownerId = null): JobRun + { + + $params = ['id' => $id]; + if ($ownerId !== null && !$this->permissionService->isAllowedToSeeAllJobRuns()) { + $params['ownerId'] = $ownerId; + } + + $jobRun = $this->pimcoreEntityManager->getRepository(JobRun::class)->findOneBy($params); + if (!$jobRun) { + throw new NotFoundException("JobRun with id $id not found."); + } + + if ($forceReload) { + $this->pimcoreEntityManager->refresh($jobRun); + } + + return $jobRun; + + } + + /** + * Get all job runs by user id. If user has permission to see all job runs, all job runs will be returned. + * + * @return JobRun[] + * + */ + public function getJobRunsByUserId( + ?int $ownerId = null, + array $orderBy = [], + int $limit = 100, + int $offset = 0 + ): array { + $params = []; + if ($ownerId !== null && !$this->permissionService->isAllowedToSeeAllJobRuns()) { + $params['ownerId'] = $ownerId; + } + + return $this->pimcoreEntityManager->getRepository(JobRun::class)->findBy( + $params, + $orderBy, + $limit, + $offset + ); + } + + public function getTotalCount(): int + { + return $this->pimcoreEntityManager->getRepository(JobRun::class)->count([]); + } + + public function getRunningJobsByUserId( + int $ownerId, + array $orderBy = [], + int $limit = 10, + ): array { + return $this->pimcoreEntityManager + ->getRepository(JobRun::class) + ->findBy( + ['ownerId' => $ownerId, 'state' => JobRunStates::RUNNING], + $orderBy, + $limit + ); + } + + public function getLastJobRunByName(string $name): ?JobRun + { + $result = $this->pimcoreEntityManager->getRepository(JobRun::class) + ->createQueryBuilder('JobRun') + ->where('JobRun.serializedJob LIKE :name') + ->setParameter('name', '%name":"' . $name . '"%') + ->orderBy('JobRun.modificationDate', 'DESC') + ->setMaxResults(1) + ->getQuery() + ->getResult(); + + if (empty($result)) { + return null; + } + + return $result[0]; + } + + /** + * @throws Exception + */ + public function updateSelectedElements(JobRun $jobRun, array $selectedElements): void + { + $job = $jobRun->getJob(); + if (!$job) { + throw new JobNotFoundException('Job not found for JobRun with id: ' . $jobRun->getId()); + } + $currentlySelectedElements = $job->getSelectedElements(); + $job->setSelectedElements($selectedElements); + $this->update($jobRun); + $this->updateLogLocalizedWithDomain( + $jobRun, + 'gee_updated_selected_elements', + [ + '%fromCount%' => count($currentlySelectedElements), + '%toCount%' => count($selectedElements), + ] + ); + } +} diff --git a/bundles/GenericExecutionEngineBundle/src/Repository/JobRunRepositoryInterface.php b/bundles/GenericExecutionEngineBundle/src/Repository/JobRunRepositoryInterface.php new file mode 100644 index 00000000000..4d0833c7ded --- /dev/null +++ b/bundles/GenericExecutionEngineBundle/src/Repository/JobRunRepositoryInterface.php @@ -0,0 +1,86 @@ +user = Authentication::authenticateSession(); + } + + public function allowedToSeeJobRuns(): void + { + if (!$this->isAllowedToSeeJobRuns()) { + throw new PermissionException('You are not allowed to see job run.'); + } + } + + public function allowedToSeeAllJobRuns(): void + { + if (!$this->isAllowedToSeeAllJobRuns()) { + throw new PermissionException( + 'You are not allowed to see all job runs. You can just see your own job runs.' + ); + } + } + + public function isAllowedToSeeJobRuns(): bool + { + if (!$this->user) { + return false; + } + + return $this->user->isAllowed(PermissionConstants::GEE_JOB_RUN); + } + + public function isAllowedToSeeAllJobRuns(): bool + { + if (!$this->user) { + return false; + } + + return $this->user->isAllowed(PermissionConstants::GEE_SEE_ALL_JOB_RUNS); + } +} diff --git a/bundles/GenericExecutionEngineBundle/src/Security/PermissionServiceInterface.php b/bundles/GenericExecutionEngineBundle/src/Security/PermissionServiceInterface.php new file mode 100644 index 00000000000..37c7147096d --- /dev/null +++ b/bundles/GenericExecutionEngineBundle/src/Security/PermissionServiceInterface.php @@ -0,0 +1,39 @@ +getPrevious()); + + return $chain; + } + + private function getFirstThrowable(Throwable $throwable): Throwable + { + $throwables = $this->getThrowableChain($throwable); + + return end($throwables); + } +} diff --git a/bundles/GenericExecutionEngineBundle/src/Utils/ValueObjects/LogLine.php b/bundles/GenericExecutionEngineBundle/src/Utils/ValueObjects/LogLine.php new file mode 100644 index 00000000000..2b2f3267795 --- /dev/null +++ b/bundles/GenericExecutionEngineBundle/src/Utils/ValueObjects/LogLine.php @@ -0,0 +1,61 @@ +extract($logLine); + } + + public function getLogLine(): string + { + return $this->logLine; + } + + public function getCreatedAt(): DateTimeImmutable + { + return $this->createdAt; + } + + private function extract(string $logLine): void + { + $logLine = trim($logLine); + $dateTimeString = substr($logLine, 0, 25); + $log = substr($logLine, 27); + $dateTime = DateTimeImmutable::createFromFormat(DateTimeInterface::ATOM, $dateTimeString); + + if ($dateTime === false) { + throw new InvalidArgumentException('Invalid Time Format given'); + } + + $this->createdAt = $dateTime; + $this->logLine = $log; + } +} diff --git a/bundles/GenericExecutionEngineBundle/translations/admin.en.yaml b/bundles/GenericExecutionEngineBundle/translations/admin.en.yaml new file mode 100644 index 00000000000..35f38bbd381 --- /dev/null +++ b/bundles/GenericExecutionEngineBundle/translations/admin.en.yaml @@ -0,0 +1,12 @@ +gee_job_run_permission: Job Run Overview +gee_see_all_job_runs_permission: See all Job Runs +gee_error_no_job_definition: No Job definition found for Job Run ID %job_run_id%. +gee_error_missing_message_implementation: Step message implementation %message% of Job %job_run_name% not found. +gee_error_no_steps: Job definition %job_run_name% has no steps defined. +gee_job_cancelled: Job Run %job_run_name% (%job_run_id%) cancelled +gee_job_failed: Job Run %job_run_name% (%job_run_id%) failed. +gee_middleware_step_condition_not_met: Skipping step %stepName% with id %stepId% in %jobName%, condition not met. +gee_job_started: Job Run %job_run_name% (%job_run_id%) started. +gee_job_finished: Job Run %job_run_name% (%job_run_id%) completed successfully. +gee_job_finished_with_errors: Job Run %job_run_name% (%job_run_id%) completed with errors. +gee_updated_selected_elements: 'Updated selected elements. (Was: %fromCount%, Now: %toCount%)' \ No newline at end of file diff --git a/bundles/GlossaryBundle/src/Controller/SettingsController.php b/bundles/GlossaryBundle/src/Controller/SettingsController.php index 6be474fc72b..944249376ce 100644 --- a/bundles/GlossaryBundle/src/Controller/SettingsController.php +++ b/bundles/GlossaryBundle/src/Controller/SettingsController.php @@ -45,20 +45,18 @@ public function glossaryAction(Request $request): JsonResponse // check glossary permissions $this->checkPermission('glossary'); - if ($request->get('data')) { + if ($request->request->has('data')) { + $data = $this->decodeJson($request->request->getString('data')); Cache::clearTag('glossary'); - if ($request->get('xaction') === 'destroy') { - $data = $this->decodeJson($request->get('data')); + if ($request->query->getString('xaction') === 'destroy') { $id = $data['id']; $glossary = Glossary::getById($id); $glossary->delete(); return $this->jsonResponse(['success' => true, 'data' => []]); - } elseif ($request->get('xaction') === 'update') { - $data = $this->decodeJson($request->get('data')); - + } elseif ($request->query->getString('xaction') === 'update') { // save glossary $glossary = Glossary::getById($data['id']); @@ -81,8 +79,7 @@ public function glossaryAction(Request $request): JsonResponse } return $this->jsonResponse(['data' => $glossary, 'success' => true]); - } elseif ($request->get('xaction') == 'create') { - $data = $this->decodeJson($request->get('data')); + } elseif ($request->query->getString('xaction') == 'create') { unset($data['id']); // save glossary @@ -114,8 +111,8 @@ public function glossaryAction(Request $request): JsonResponse } $list = new Glossary\Listing(); - $list->setLimit((int) $request->get('limit', 50)); - $list->setOffset((int) $request->get('start', 0)); + $list->setLimit($request->request->getInt('limit', 50)); + $list->setOffset($request->request->getInt('start')); $sortingSettings = \Pimcore\Bundle\AdminBundle\Helper\QueryParams::extractSortingSettings(array_merge($request->request->all(), $request->query->all())); if ($sortingSettings['orderKey']) { @@ -123,8 +120,8 @@ public function glossaryAction(Request $request): JsonResponse $list->setOrder($sortingSettings['order']); } - if ($request->get('filter')) { - $list->setCondition('`text` LIKE ' . $list->quote('%'.$request->get('filter').'%')); + if ($request->request->has('filter')) { + $list->setCondition('`text` LIKE ' . $list->quote('%'.$request->request->getString('filter').'%')); } $list->load(); diff --git a/bundles/GlossaryBundle/src/Model/Glossary/Dao.php b/bundles/GlossaryBundle/src/Model/Glossary/Dao.php index 3f3584fe07b..6670f66e38b 100644 --- a/bundles/GlossaryBundle/src/Model/Glossary/Dao.php +++ b/bundles/GlossaryBundle/src/Model/Glossary/Dao.php @@ -13,8 +13,9 @@ * @license http://www.pimcore.org/license GPLv3 and PCL */ -namespace Pimcore\Bundle\GlossaryBundle\Model\Glossary; +namespace Pimcore\Bundle\GlossaryBundle\Model\Glossary; +use Exception; use Pimcore\Bundle\GlossaryBundle\Model\Glossary; use Pimcore\Model\Dao\AbstractDao; use Pimcore\Model\Exception\NotFoundException; @@ -32,7 +33,7 @@ class Dao extends AbstractDao * * @throws NotFoundException */ - public function getById(int $id = null): void + public function getById(?int $id = null): void { if ($id != null) { $this->model->setId($id); @@ -48,7 +49,7 @@ public function getById(int $id = null): void } /** - * @throws \Exception + * @throws Exception */ public function save(): void { @@ -68,7 +69,7 @@ public function delete(): void } /** - * @throws \Exception + * @throws Exception */ public function update(): void { diff --git a/bundles/GlossaryBundle/src/Model/Glossary/Listing.php b/bundles/GlossaryBundle/src/Model/Glossary/Listing.php index 526a13e41f8..68991840213 100644 --- a/bundles/GlossaryBundle/src/Model/Glossary/Listing.php +++ b/bundles/GlossaryBundle/src/Model/Glossary/Listing.php @@ -14,7 +14,7 @@ * @license http://www.pimcore.org/license GPLv3 and PCL */ -namespace Pimcore\Bundle\GlossaryBundle\Model\Glossary; +namespace Pimcore\Bundle\GlossaryBundle\Model\Glossary; use Pimcore\Bundle\GlossaryBundle\Model\Glossary; use Pimcore\Model\Listing\AbstractListing; diff --git a/bundles/GlossaryBundle/src/Model/Glossary/Listing/Dao.php b/bundles/GlossaryBundle/src/Model/Glossary/Listing/Dao.php index 6365e7efd1c..5724af5af5d 100644 --- a/bundles/GlossaryBundle/src/Model/Glossary/Listing/Dao.php +++ b/bundles/GlossaryBundle/src/Model/Glossary/Listing/Dao.php @@ -13,8 +13,9 @@ * @license http://www.pimcore.org/license GPLv3 and PCL */ -namespace Pimcore\Bundle\GlossaryBundle\Model\Glossary\Listing; +namespace Pimcore\Bundle\GlossaryBundle\Model\Glossary\Listing; +use Exception; use Pimcore\Bundle\GlossaryBundle\Model\Glossary; use Pimcore\Bundle\GlossaryBundle\Model\Glossary\Listing; use Pimcore\Model; @@ -63,7 +64,7 @@ public function getTotalCount(): int { try { return (int) $this->db->fetchOne('SELECT COUNT(*) FROM glossary ' . $this->getCondition(), $this->model->getConditionVariables()); - } catch (\Exception $e) { + } catch (Exception $e) { return 0; } } diff --git a/bundles/GlossaryBundle/src/PimcoreGlossaryBundle.php b/bundles/GlossaryBundle/src/PimcoreGlossaryBundle.php index 92ba148f4a1..5e7bb51700a 100644 --- a/bundles/GlossaryBundle/src/PimcoreGlossaryBundle.php +++ b/bundles/GlossaryBundle/src/PimcoreGlossaryBundle.php @@ -48,6 +48,6 @@ public function getInstaller(): Installer public function getPath(): string { - return \dirname(__DIR__); + return dirname(__DIR__); } } diff --git a/bundles/GlossaryBundle/src/Tool/Processor.php b/bundles/GlossaryBundle/src/Tool/Processor.php index 961fe765cb4..71846bcc941 100644 --- a/bundles/GlossaryBundle/src/Tool/Processor.php +++ b/bundles/GlossaryBundle/src/Tool/Processor.php @@ -192,6 +192,9 @@ private function prepareData(array $data): array // fix htmlentities issues $tmpData = []; foreach ($data as $d) { + if (!($d['text'])) { + continue; + } $text = htmlentities($d['text'], ENT_COMPAT, 'UTF-8'); if ($d['text'] !== $text) { $td = $d; @@ -236,9 +239,9 @@ private function prepareData(array $data): array // add PCRE delimiter and modifiers if ($d['exactmatch']) { - $d['text'] = '/(*SKIP)(*FAIL)|(?(*SKIP)(*FAIL)|(?(*SKIP)(*FAIL)|' . preg_quote($d['text'], '/') . '/'; + $d['text'] = '/(*SKIP)(*FAIL)|' . preg_quote($d['text'], '/') . '/'; } if (!$d['casesensitive']) { diff --git a/bundles/InstallBundle/dump/install.sql b/bundles/InstallBundle/dump/install.sql index d20723abda8..2d14e01e62a 100644 --- a/bundles/InstallBundle/dump/install.sql +++ b/bundles/InstallBundle/dump/install.sql @@ -20,7 +20,8 @@ CREATE TABLE `assets` ( UNIQUE KEY `fullpath` (`path`,`filename`), KEY `parentId` (`parentId`), KEY `filename` (`filename`), - KEY `modificationDate` (`modificationDate`) + KEY `modificationDate` (`modificationDate`), + KEY `versionCount` (`versionCount`) ) AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC; DROP TABLE IF EXISTS `assets_metadata`; @@ -54,6 +55,7 @@ DROP TABLE IF EXISTS `classes` ; CREATE TABLE `classes` ( `id` VARCHAR(50) NOT NULL, `name` VARCHAR(190) NOT NULL DEFAULT '', + `definitionModificationDate` INT(11) UNSIGNED NULL DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE INDEX `name` (`name`) ) DEFAULT CHARSET=utf8mb4; @@ -89,7 +91,8 @@ CREATE TABLE `documents` ( KEY `parentId` (`parentId`), KEY `key` (`key`), KEY `published` (`published`), - KEY `modificationDate` (`modificationDate`) + KEY `modificationDate` (`modificationDate`), + KEY `versionCount` (`versionCount`) ) AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC; DROP TABLE IF EXISTS `documents_editables`; @@ -289,7 +292,8 @@ CREATE TABLE `objects` ( KEY `parentId` (`parentId`), KEY `type_path_classId` (`type`, `path`, `classId`), KEY `modificationDate` (`modificationDate`), - KEY `classId` (`classId`) + KEY `classId` (`classId`), + KEY `versionCount` (`versionCount`) ) AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC; DROP TABLE IF EXISTS `properties`; @@ -459,7 +463,8 @@ CREATE TABLE `users` ( `firstname` varchar(255) DEFAULT NULL, `lastname` varchar(255) DEFAULT NULL, `email` varchar(255) DEFAULT NULL, - `language` varchar(10) DEFAULT NULL, + `language` varchar(10) DEFAULT 'en', + `datetimeLocale` varchar(10) DEFAULT '', `contentLanguages` LONGTEXT NULL, `admin` tinyint(1) unsigned DEFAULT '0', `active` tinyint(1) unsigned DEFAULT '1', @@ -511,6 +516,7 @@ CREATE TABLE `users_workspaces_asset` ( PRIMARY KEY (`cid`, `userId`), KEY `userId` (`userId`), UNIQUE INDEX `cpath_userId` (`cpath`,`userId`), + UNIQUE INDEX `idx_users_workspaces_list_permission` (`userId`, `cpath`, `list`), CONSTRAINT `fk_users_workspaces_asset_assets` FOREIGN KEY (`cid`) REFERENCES `assets` (`id`) ON UPDATE NO ACTION ON DELETE CASCADE, CONSTRAINT `fk_users_workspaces_asset_users` FOREIGN KEY (`userId`) REFERENCES `users` (`id`) ON UPDATE NO ACTION ON DELETE CASCADE ) DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC; @@ -534,6 +540,7 @@ CREATE TABLE `users_workspaces_document` ( PRIMARY KEY (`cid`, `userId`), KEY `userId` (`userId`), UNIQUE INDEX `cpath_userId` (`cpath`,`userId`), + UNIQUE INDEX `idx_users_workspaces_list_permission` (`userId`, `cpath`, `list`), CONSTRAINT `fk_users_workspaces_document_documents` FOREIGN KEY (`cid`) REFERENCES `documents` (`id`) ON UPDATE NO ACTION ON DELETE CASCADE, CONSTRAINT `fk_users_workspaces_document_users` FOREIGN KEY (`userId`) REFERENCES `users` (`id`) ON UPDATE NO ACTION ON DELETE CASCADE ) DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC; @@ -560,6 +567,7 @@ CREATE TABLE `users_workspaces_object` ( PRIMARY KEY (`cid`, `userId`), KEY `userId` (`userId`), UNIQUE INDEX `cpath_userId` (`cpath`,`userId`), + UNIQUE INDEX `idx_users_workspaces_list_permission` (`userId`, `cpath`, `list`), CONSTRAINT `fk_users_workspaces_object_objects` FOREIGN KEY (`cid`) REFERENCES `objects` (`id`) ON UPDATE NO ACTION ON DELETE CASCADE, CONSTRAINT `fk_users_workspaces_object_users` FOREIGN KEY (`userId`) REFERENCES `users` (`id`) ON UPDATE NO ACTION ON DELETE CASCADE ) DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC; @@ -586,7 +594,8 @@ CREATE TABLE `versions` ( KEY `date` (`date`), KEY `binaryFileHash` (`binaryFileHash`), KEY `autoSave` (`autoSave`), - KEY `stackTrace` (`stackTrace`(1)) + KEY `stackTrace` (`stackTrace`(1)), + KEY `versionCount` (`versionCount`) ) DEFAULT CHARSET=utf8mb4; DROP TABLE IF EXISTS `website_settings`; @@ -801,10 +810,11 @@ CREATE TABLE `notifications` ( `modificationDate` TIMESTAMP NULL, `linkedElementType` ENUM('document', 'asset', 'object') NULL, `linkedElement` INT(11) NULL, + `payload` LONGTEXT NULL, + `isStudio` TINYINT(1) DEFAULT 0 NOT NULL, -- TODO: Remove with end of Classic-UI INDEX `recipient` (`recipient`) -) -DEFAULT CHARSET=utf8mb4; -; +) DEFAULT CHARSET=utf8mb4; + DROP TABLE IF EXISTS `object_url_slugs`; CREATE TABLE `object_url_slugs` ( diff --git a/bundles/InstallBundle/src/Command/InstallCommand.php b/bundles/InstallBundle/src/Command/InstallCommand.php index 1893854d920..3859d428039 100644 --- a/bundles/InstallBundle/src/Command/InstallCommand.php +++ b/bundles/InstallBundle/src/Command/InstallCommand.php @@ -17,14 +17,13 @@ namespace Pimcore\Bundle\InstallBundle\Command; -use function explode; -use function implode; use Pimcore\Bundle\InstallBundle\Event\BundleSetupEvent; use Pimcore\Bundle\InstallBundle\Event\InstallerStepEvent; use Pimcore\Bundle\InstallBundle\Event\InstallEvents; use Pimcore\Bundle\InstallBundle\Installer; use Pimcore\Console\ConsoleOutputDecorator; use Pimcore\Console\Style\PimcoreStyle; +use RuntimeException; use Symfony\Bundle\FrameworkBundle\Console\Application; use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; @@ -290,7 +289,7 @@ protected function interact(InputInterface $input, OutputInterface $output): voi } else { $validator = function ($answer) use ($name) { if (empty($answer)) { - throw new \RuntimeException(sprintf('%s cannot be empty', $name)); + throw new RuntimeException(sprintf('%s cannot be empty', $name)); } return $answer; @@ -446,7 +445,7 @@ private function getRecommendBundles(BundleSetupEvent $bundleSetupEvent): string { $installableBundleKeys = array_keys($bundleSetupEvent->getBundles()); $recommendedBundles = []; - foreach($bundleSetupEvent->getRecommendedBundles() as $recBundle) { + foreach ($bundleSetupEvent->getRecommendedBundles() as $recBundle) { $recommendedBundles[] = array_search($recBundle, $installableBundleKeys); } diff --git a/bundles/InstallBundle/src/Installer.php b/bundles/InstallBundle/src/Installer.php index d38e72b9977..8310a3a2823 100644 --- a/bundles/InstallBundle/src/Installer.php +++ b/bundles/InstallBundle/src/Installer.php @@ -21,10 +21,13 @@ use Doctrine\DBAL\Connection; use Doctrine\DBAL\Driver\ServerInfoAwareConnection; use Doctrine\DBAL\DriverManager; -use function in_array; +use Exception; +use InvalidArgumentException; use PDO; +use Pimcore; use Pimcore\Bundle\ApplicationLoggerBundle\PimcoreApplicationLoggerBundle; use Pimcore\Bundle\CustomReportsBundle\PimcoreCustomReportsBundle; +use Pimcore\Bundle\GenericExecutionEngineBundle\PimcoreGenericExecutionEngineBundle; use Pimcore\Bundle\GlossaryBundle\PimcoreGlossaryBundle; use Pimcore\Bundle\InstallBundle\BundleConfig\BundleWriter; use Pimcore\Bundle\InstallBundle\Event\BundleSetupEvent; @@ -34,7 +37,6 @@ use Pimcore\Bundle\SeoBundle\PimcoreSeoBundle; use Pimcore\Bundle\SimpleBackendSearchBundle\PimcoreSimpleBackendSearchBundle; use Pimcore\Bundle\StaticRoutesBundle\PimcoreStaticRoutesBundle; -use Pimcore\Bundle\TinymceBundle\PimcoreTinymceBundle; use Pimcore\Bundle\UuidBundle\PimcoreUuidBundle; use Pimcore\Bundle\WordExportBundle\PimcoreWordExportBundle; use Pimcore\Bundle\XliffBundle\PimcoreXliffBundle; @@ -55,13 +57,14 @@ use Symfony\Component\HttpKernel\KernelInterface; use Symfony\Component\Process\Exception\ProcessFailedException; use Symfony\Component\Process\Process; +use Throwable; /** * @internal */ class Installer { - const RECOMMENDED_BUNDLES = ['PimcoreSimpleBackendSearchBundle', 'PimcoreTinymceBundle']; + const RECOMMENDED_BUNDLES = ['PimcoreSimpleBackendSearchBundle']; public const INSTALLABLE_BUNDLES = [ 'PimcoreApplicationLoggerBundle' => PimcoreApplicationLoggerBundle::class, @@ -70,10 +73,10 @@ class Installer 'PimcoreSeoBundle' => PimcoreSeoBundle::class, 'PimcoreSimpleBackendSearchBundle' => PimcoreSimpleBackendSearchBundle::class, 'PimcoreStaticRoutesBundle' => PimcoreStaticRoutesBundle::class, - 'PimcoreTinymceBundle' => PimcoreTinymceBundle::class, 'PimcoreUuidBundle' => PimcoreUuidBundle::class, 'PimcoreWordExportBundle' => PimcoreWordExportBundle::class, 'PimcoreXliffBundle' => PimcoreXliffBundle::class, + 'PimcoreGenericExecutionEngineBundle' => PimcoreGenericExecutionEngineBundle::class, ]; private LoggerInterface $logger; @@ -148,8 +151,8 @@ public function setSkipDatabaseConfig(bool $skipDatabaseConfig): void 'setup_database' => 'Running database setup...', 'install_assets' => 'Installing assets...', 'install_classes' => 'Installing classes...', - 'install_bundles' => 'Installing bundles...', 'migrations' => 'Marking all migrations as done...', + 'install_bundles' => 'Installing bundles...', 'complete' => 'Install complete!', ]; @@ -158,8 +161,8 @@ public function setSkipDatabaseConfig(bool $skipDatabaseConfig): void 'setup_database', 'install_assets', 'install_classes', - 'install_bundles', 'mark_migrations_as_done', + 'install_bundles', 'clear_cache', ]; @@ -218,7 +221,7 @@ public function dispatchBundleSetupEvent(): BundleSetupEvent return $this->eventDispatcher->dispatch(new BundleSetupEvent(self::INSTALLABLE_BUNDLES, self::RECOMMENDED_BUNDLES), InstallEvents::EVENT_BUNDLE_SETUP); } - public function checkPrerequisites(Connection $db = null): array + public function checkPrerequisites(?Connection $db = null): array { $checks = array_merge( Requirements::checkFilesystem(), @@ -260,10 +263,10 @@ public function getStepEventCount(): int return count($this->stepEvents); } - private function dispatchStepEvent(string $type, string $message = null): InstallerStepEvent + private function dispatchStepEvent(string $type, ?string $message = null): InstallerStepEvent { if (!isset($this->stepEvents[$type])) { - throw new \InvalidArgumentException(sprintf('Trying to dispatch unsupported event type "%s"', $type)); + throw new InvalidArgumentException(sprintf('Trying to dispatch unsupported event type "%s"', $type)); } $message = $message ?? $this->stepEvents[$type]; @@ -303,7 +306,7 @@ public function install(array $params): array if (count($errors) > 0) { return $errors; } - } catch (\Exception $e) { + } catch (Exception $e) { $errors[] = sprintf('Couldn\'t establish connection to MySQL: %s', $e->getMessage()); return $errors; @@ -332,7 +335,7 @@ public function install(array $params): array ], $db ); - } catch (\Throwable $e) { + } catch (Throwable $e) { $this->logger->error((string) $e); return [ @@ -389,7 +392,7 @@ private function runInstall(array $dbConfig, array $userCredentials, Connection $errors = []; $stepsToRun = $this->getRunInstallSteps(); - if(in_array('write_database_config', $stepsToRun)) { + if (in_array('write_database_config', $stepsToRun)) { $this->dispatchStepEvent('create_config_files'); unset($dbConfig['driver']); @@ -433,57 +436,52 @@ private function runInstall(array $dbConfig, array $userCredentials, Connection $kernel = new $kernel($environment, true); - if(in_array('clear_cache', $stepsToRun)) { + if (in_array('clear_cache', $stepsToRun)) { $this->clearKernelCacheDir($kernel); } - if(in_array('clear_cache', $stepsToRun) || in_array('install_assets', $stepsToRun)) { - \Pimcore::setKernel($kernel); + if (in_array('clear_cache', $stepsToRun) || in_array('install_assets', $stepsToRun)) { + Pimcore::setKernel($kernel); $kernel->boot(); } - if(in_array('setup_database', $stepsToRun)) { + if (in_array('setup_database', $stepsToRun)) { $this->dispatchStepEvent('setup_database'); $errors = $this->setupDatabase($db, $userCredentials, $errors); if (!$this->skipDatabaseConfig && in_array('write_database_config', $stepsToRun)) { // now we're able to write the server version to the database.yaml - if ($db instanceof Connection) { - $connection = $db->getWrappedConnection(); - if ($connection instanceof ServerInfoAwareConnection) { - $writer = new ConfigWriter(); - $doctrineConfig['doctrine']['dbal']['connections']['default']['server_version'] = $connection->getServerVersion(); - $writer->writeDbConfig($doctrineConfig); - } + $connection = $db->getWrappedConnection(); + if ($connection instanceof ServerInfoAwareConnection) { + $writer = new ConfigWriter(); + $doctrineConfig['doctrine']['dbal']['connections']['default']['server_version'] = $connection->getServerVersion(); + $writer->writeDbConfig($doctrineConfig); } } } - if(in_array('install_assets', $stepsToRun)) { + if (in_array('install_assets', $stepsToRun)) { $this->dispatchStepEvent('install_assets'); $this->installAssets($kernel); } - if (!empty($this->bundlesToInstall) && in_array('install_bundles', $stepsToRun)) { - $this->dispatchStepEvent('install_bundles'); - $this->installBundles(); - } - - if(in_array('install_classes', $stepsToRun)) { + if (in_array('install_classes', $stepsToRun)) { $this->dispatchStepEvent('install_classes'); $this->installClasses(); } - if(in_array('mark_migrations_as_done', $stepsToRun)) { - $this->dispatchStepEvent('install_classes'); - $this->installClasses(); - + if (in_array('mark_migrations_as_done', $stepsToRun)) { $this->dispatchStepEvent('migrations'); $this->markMigrationsAsDone(); } - if(in_array('clear_cache', $stepsToRun)) { + if (!empty($this->bundlesToInstall) && in_array('install_bundles', $stepsToRun)) { + $this->dispatchStepEvent('install_bundles'); + $this->installBundles(); + } + + if (in_array('clear_cache', $stepsToRun)) { $this->clearKernelCacheDir($kernel); } @@ -578,7 +576,7 @@ private function writeBundlesToConfig(): void $bundlesToInstall = $this->bundlesToInstall; $availableBundles = $this->availableBundles; - if(!empty($this->excludeFromBundlesPhp)) { + if (!empty($this->excludeFromBundlesPhp)) { $bundlesToInstall = array_diff($bundlesToInstall, array_values($this->excludeFromBundlesPhp)); $availableBundles = array_diff($availableBundles, $this->excludeFromBundlesPhp); } @@ -669,7 +667,7 @@ public function setupDatabase(Connection $db, array $userCredentials, array $err $mysqlInstallScript = file_get_contents(__DIR__ . '/../dump/install.sql'); // remove comments in SQL script - $mysqlInstallScript = preg_replace("/\s*(?!<\")\/\*[^\*]+\*\/(?!\")\s*/", '', $mysqlInstallScript); + $mysqlInstallScript = preg_replace("/\s*(?!<\")\/\*(?![!+])[^\*]+\*\/(?!\")\s*/", '', $mysqlInstallScript); // get every command as single part $mysqlInstallScripts = explode(';', $mysqlInstallScript); @@ -709,7 +707,7 @@ public function setupDatabase(Connection $db, array $userCredentials, array $err $this->createOrUpdateUser($db, $userCredentials); } - } catch (\Exception $e) { + } catch (Exception $e) { $this->logger->error((string) $e); $errors[] = $e->getMessage(); } @@ -719,8 +717,8 @@ public function setupDatabase(Connection $db, array $userCredentials, array $err // close connections and collection garbage ... in order to avoid too many connections error // when installing demos - if(\Pimcore::getKernel() instanceof \Pimcore\Kernel) { - \Pimcore::collectGarbage(); + if (Pimcore::getKernel() instanceof \Pimcore\Kernel) { + Pimcore::collectGarbage(); } return $errors; @@ -728,12 +726,10 @@ public function setupDatabase(Connection $db, array $userCredentials, array $err protected function getDataFiles(): array { - $files = glob(PIMCORE_PROJECT_ROOT . '/dump/*.sql'); - - return $files; + return glob(PIMCORE_PROJECT_ROOT . '/dump/*.sql*'); } - private function createOrUpdateUser(Connection $db, array $config = []): void + protected function createOrUpdateUser(Connection $db, array $config = []): void { $defaultConfig = [ 'username' => 'admin', @@ -757,14 +753,18 @@ private function createOrUpdateUser(Connection $db, array $config = []): void /** * - * @throws \Exception + * @throws Exception */ - private function insertDatabaseDump(Connection $db, string $file): void + protected function insertDatabaseDump(Connection $db, string $file): void { + if (str_ends_with($file, '.gz')) { + $file = 'compress.zlib://' . $file; + } + $dumpFile = file_get_contents($file); // remove comments in SQL script - $dumpFile = preg_replace("/\s*(?!<\")\/\*[^\*]+\*\/(?!\")\s*/", '', $dumpFile); + $dumpFile = preg_replace("/\s*(?!<\")\/\*(?![!+])[^\*]+\*\/(?!\")\s*/", '', $dumpFile); if (str_contains($file, 'atomic')) { $db->executeStatement($dumpFile); @@ -776,7 +776,7 @@ private function insertDatabaseDump(Connection $db, string $file): void $batchQueries = []; foreach ($singleQueries as $m) { $sql = trim($m); - if (strlen($sql) > 0) { + if ($sql !== '') { $batchQueries[] = $sql . ';'; } diff --git a/bundles/InstallBundle/src/PimcoreInstallBundle.php b/bundles/InstallBundle/src/PimcoreInstallBundle.php index 46304b4fd61..d9375a38a5e 100644 --- a/bundles/InstallBundle/src/PimcoreInstallBundle.php +++ b/bundles/InstallBundle/src/PimcoreInstallBundle.php @@ -26,6 +26,6 @@ class PimcoreInstallBundle extends Bundle { public function getPath(): string { - return \dirname(__DIR__); + return dirname(__DIR__); } } diff --git a/bundles/SeoBundle/src/Controller/MiscController.php b/bundles/SeoBundle/src/Controller/MiscController.php index 342385eba66..ee02d588fc1 100644 --- a/bundles/SeoBundle/src/Controller/MiscController.php +++ b/bundles/SeoBundle/src/Controller/MiscController.php @@ -39,12 +39,12 @@ public function httpErrorLogAction(Request $request): JsonResponse $db = Db::get(); - $limit = (int)$request->get('limit'); - $offset = (int)$request->get('start'); - $sortInfo = ($request->get('sort') ? json_decode($request->get('sort'), true)[0] : []); + $limit = $request->request->getInt('limit'); + $offset = $request->request->getInt('start'); + $sortInfo = ($request->request->has('sort') ? json_decode($request->request->getString('sort'), true)[0] : []); $sort = $sortInfo['property'] ?? null; $dir = $sortInfo['direction'] ?? null; - $filter = $request->get('filter'); + $filter = $request->request->getString('filter'); if (!$limit) { $limit = 20; } @@ -93,7 +93,7 @@ public function httpErrorLogDetailAction(Request $request, ?Profiler $profiler): } $db = Db::get(); - $data = $db->fetchAssociative('SELECT * FROM http_error_log WHERE uri = ?', [$request->get('uri')]); + $data = $db->fetchAssociative('SELECT * FROM http_error_log WHERE uri = ?', [$request->query->getString('uri')]); foreach ($data as $key => &$value) { if (in_array($key, ['parametersGet', 'parametersPost', 'serverVars', 'cookies'])) { diff --git a/bundles/SeoBundle/src/Controller/RedirectsController.php b/bundles/SeoBundle/src/Controller/RedirectsController.php index 3114766e90a..cf08d95acb5 100644 --- a/bundles/SeoBundle/src/Controller/RedirectsController.php +++ b/bundles/SeoBundle/src/Controller/RedirectsController.php @@ -17,6 +17,7 @@ namespace Pimcore\Bundle\SeoBundle\Controller; +use Exception; use Pimcore\Bundle\AdminBundle\Helper\QueryParams; use Pimcore\Bundle\SeoBundle\Model\Redirect; use Pimcore\Bundle\SeoBundle\Redirect\Csv; @@ -54,9 +55,10 @@ public function redirectsAction(Request $request, RedirectHandler $redirectHandl // check permission for both update and listing $this->checkPermission('redirects'); - if ($request->get('data')) { - if ($request->get('xaction') === 'destroy') { - $data = $this->decodeJson($request->get('data')); + if ($request->request->has('data')) { + $data = $this->decodeJson($request->request->getString('data')); + + if ($request->query->getString('xaction') === 'destroy') { $id = $data['id'] ?? null; if ($id) { @@ -66,9 +68,7 @@ public function redirectsAction(Request $request, RedirectHandler $redirectHandl return $this->jsonResponse(['success' => true, 'data' => []]); } - if ($request->get('xaction') === 'update') { - $data = $this->decodeJson($request->get('data')); - + if ($request->query->getString('xaction') === 'update') { // save redirect $redirect = Redirect::getById($data['id']); @@ -99,8 +99,7 @@ public function redirectsAction(Request $request, RedirectHandler $redirectHandl return $this->jsonResponse(['data' => $redirect->getObjectVars(), 'success' => true]); } - if ($request->get('xaction') === 'create') { - $data = $this->decodeJson($request->get('data')); + if ($request->query->getString('xaction') === 'create') { unset($data['id']); // save route @@ -137,8 +136,8 @@ public function redirectsAction(Request $request, RedirectHandler $redirectHandl // get list of routes $list = new Redirect\Listing(); - $list->setLimit((int)$request->get('limit', 50)); - $list->setOffset((int)$request->get('start', 0)); + $list->setLimit($request->request->getInt('limit', 50)); + $list->setOffset($request->request->getInt('start')); $sortingSettings = QueryParams::extractSortingSettings(array_merge($request->request->all(), $request->query->all())); if ($sortingSettings['orderKey']) { @@ -146,7 +145,7 @@ public function redirectsAction(Request $request, RedirectHandler $redirectHandl $list->setOrder($sortingSettings['order']); } - if ($filterValue = $request->get('filter')) { + if ($filterValue = $request->request->getString('filter')) { if (is_numeric($filterValue)) { $list->setCondition('id = ?', [$filterValue]); } elseif (preg_match('@^https?://@', $filterValue)) { @@ -257,7 +256,7 @@ public function cleanupAction(): JsonResponse } return $this->jsonResponse(['success' => true]); - } catch (\Exception $e) { + } catch (Exception $e) { Logger::error($e->getMessage()); return $this->jsonResponse(['success' => false]); diff --git a/bundles/SeoBundle/src/Controller/SettingsController.php b/bundles/SeoBundle/src/Controller/SettingsController.php index 6b24d44e6a9..4243ce2c8e7 100644 --- a/bundles/SeoBundle/src/Controller/SettingsController.php +++ b/bundles/SeoBundle/src/Controller/SettingsController.php @@ -54,10 +54,7 @@ public function robotsTxtPutAction(Request $request): JsonResponse { $this->checkPermission('robots.txt'); - $values = $request->get('data'); - if (!is_array($values)) { - $values = []; - } + $values = $request->request->all('data'); foreach ($values as $siteId => $robotsContent) { SettingsStore::set('robots.txt-' . $siteId, $robotsContent, SettingsStore::TYPE_STRING, 'robots.txt'); diff --git a/bundles/SeoBundle/src/EventListener/ResponseExceptionListener.php b/bundles/SeoBundle/src/EventListener/ResponseExceptionListener.php index 6de6bdef3ce..05206072a2a 100644 --- a/bundles/SeoBundle/src/EventListener/ResponseExceptionListener.php +++ b/bundles/SeoBundle/src/EventListener/ResponseExceptionListener.php @@ -17,6 +17,7 @@ namespace Pimcore\Bundle\SeoBundle\EventListener; use Doctrine\DBAL\Connection; +use Pimcore; use Pimcore\Bundle\CoreBundle\EventListener\Traits\PimcoreContextAwareTrait; use Pimcore\Bundle\SeoBundle\PimcoreSeoBundle; use Pimcore\Http\Exception\ResponseException; @@ -63,7 +64,7 @@ public function onKernelException(ExceptionEvent $event): void // further checks are only valid for default context $request = $event->getRequest(); if ($this->matchesPimcoreContext($request, PimcoreContextResolver::CONTEXT_DEFAULT)) { - if (\Pimcore::inDebugMode()) { + if (Pimcore::inDebugMode()) { return; } diff --git a/bundles/SeoBundle/src/EventListener/SitemapGeneratorListener.php b/bundles/SeoBundle/src/EventListener/SitemapGeneratorListener.php index 633c1d32934..8557b363294 100644 --- a/bundles/SeoBundle/src/EventListener/SitemapGeneratorListener.php +++ b/bundles/SeoBundle/src/EventListener/SitemapGeneratorListener.php @@ -17,6 +17,7 @@ namespace Pimcore\Bundle\SeoBundle\EventListener; +use IteratorAggregate; use Pimcore\Bundle\SeoBundle\PimcoreSeoBundle; use Pimcore\Bundle\SeoBundle\Sitemap\GeneratorInterface; use Presta\SitemapBundle\Event\SitemapPopulateEvent; @@ -25,11 +26,11 @@ class SitemapGeneratorListener implements EventSubscriberInterface { /** - * @var \IteratorAggregate|GeneratorInterface[] + * @var IteratorAggregate|GeneratorInterface[] */ - private array|\IteratorAggregate $generators; + private array|IteratorAggregate $generators; - public function __construct(array|\IteratorAggregate $generators) + public function __construct(array|IteratorAggregate $generators) { $this->generators = $generators; } diff --git a/bundles/SeoBundle/src/Model/Redirect.php b/bundles/SeoBundle/src/Model/Redirect.php index 9cc54f3db5a..c60418cb2f6 100644 --- a/bundles/SeoBundle/src/Model/Redirect.php +++ b/bundles/SeoBundle/src/Model/Redirect.php @@ -16,12 +16,15 @@ namespace Pimcore\Bundle\SeoBundle\Model; +use Exception; +use InvalidArgumentException; use Pimcore; use Pimcore\Bundle\SeoBundle\Event\Model\RedirectEvent; use Pimcore\Bundle\SeoBundle\Event\RedirectEvents; use Pimcore\Event\Traits\RecursionBlockingEventDispatchHelperTrait; use Pimcore\Logger; use Pimcore\Model\AbstractModel; +use Pimcore\Model\Document; use Pimcore\Model\Exception\NotFoundException; use Pimcore\Model\Site; use Symfony\Component\HttpFoundation\Request; @@ -134,11 +137,38 @@ public function getSource(): ?string return $this->source; } + /** + * Target as string, can be target path or document id + */ public function getTarget(): ?string { return $this->target; } + /** + * resolved target path with handling for document ids as `target` + * - tries to resolve the target as document by id and take its full path + * - if no document can be found the target is used as target path + * - ensures a slash at the beginning of the target string + */ + public function getTargetPath(): string + { + $redirectTarget = $this->target; + $targetDocumentPath = null; + + if (is_numeric($redirectTarget)) { + $targetDocumentPath = Document::getById((int)$redirectTarget)?->getFullPath(); + } + + $resolvedPath = ($targetDocumentPath ?? $redirectTarget) ?? ''; + + if (!str_starts_with($resolvedPath, '/')) { + return '/'.$resolvedPath; + } + + return $resolvedPath; + } + public function setId(int $id): static { $this->id = $id; @@ -162,7 +192,7 @@ public function getType(): string public function setType(string $type): void { if (!empty($type) && !in_array($type, self::TYPES)) { - throw new \InvalidArgumentException(sprintf('Invalid type "%s"', $type)); + throw new InvalidArgumentException(sprintf('Invalid type "%s"', $type)); } $this->type = $type; @@ -225,7 +255,7 @@ public function clearDependentCache(): void // this is mostly called in Redirect\Dao not here try { \Pimcore\Cache::clearTag('redirect'); - } catch (\Exception $e) { + } catch (Exception $e) { Logger::crit((string) $e); } } diff --git a/bundles/SeoBundle/src/Model/Redirect/Dao.php b/bundles/SeoBundle/src/Model/Redirect/Dao.php index 437d4479df5..3cb7091ed1b 100644 --- a/bundles/SeoBundle/src/Model/Redirect/Dao.php +++ b/bundles/SeoBundle/src/Model/Redirect/Dao.php @@ -15,6 +15,7 @@ namespace Pimcore\Bundle\SeoBundle\Model\Redirect; +use Exception; use Pimcore\Bundle\SeoBundle\Model\Redirect; use Pimcore\Bundle\SeoBundle\Redirect\RedirectUrlPartResolver; use Pimcore\Model; @@ -33,7 +34,7 @@ class Dao extends Model\Dao\AbstractDao * * @throws NotFoundException */ - public function getById(int $id = null): void + public function getById(?int $id = null): void { if ($id != null) { $this->model->setId($id); @@ -64,7 +65,7 @@ public function getByExactMatch(Request $request, ?Site $site = null, bool $over ) AND active = 1 AND (regex IS NULL OR regex = 0) AND (expiry > UNIX_TIMESTAMP() OR expiry IS NULL)'; if ($siteId) { - $sql .= ' AND sourceSite = ' . $this->db->quote($siteId); + $sql .= ' AND sourceSite = ' . $siteId; } else { $sql .= ' AND sourceSite IS NULL'; } @@ -93,7 +94,7 @@ public function getByExactMatch(Request $request, ?Site $site = null, bool $over } /** - * @throws \Exception + * @throws Exception */ public function save(): void { diff --git a/bundles/SeoBundle/src/Model/Redirect/Listing/Dao.php b/bundles/SeoBundle/src/Model/Redirect/Listing/Dao.php index 50e60ed0c39..bdfd88f4085 100644 --- a/bundles/SeoBundle/src/Model/Redirect/Listing/Dao.php +++ b/bundles/SeoBundle/src/Model/Redirect/Listing/Dao.php @@ -15,6 +15,7 @@ namespace Pimcore\Bundle\SeoBundle\Model\Redirect\Listing; +use Exception; use Pimcore\Bundle\SeoBundle\Model\Redirect; use Pimcore\Bundle\SeoBundle\Model\Redirect\Listing; use Pimcore\Model; @@ -48,7 +49,7 @@ public function getTotalCount(): int { try { return (int) $this->db->fetchOne('SELECT COUNT(*) FROM redirects ' . $this->getCondition(), $this->model->getConditionVariables()); - } catch (\Exception $e) { + } catch (Exception $e) { return 0; } } diff --git a/bundles/SeoBundle/src/PimcoreSeoBundle.php b/bundles/SeoBundle/src/PimcoreSeoBundle.php index ef751fdca93..6e6fc99d81e 100644 --- a/bundles/SeoBundle/src/PimcoreSeoBundle.php +++ b/bundles/SeoBundle/src/PimcoreSeoBundle.php @@ -54,7 +54,7 @@ public function getInstaller(): Installer public function getPath(): string { - return \dirname(__DIR__); + return dirname(__DIR__); } public static function registerDependentBundles(BundleCollection $collection): void diff --git a/bundles/SeoBundle/src/Redirect/Csv.php b/bundles/SeoBundle/src/Redirect/Csv.php index 7305e1a2ab8..e4bcd95754d 100644 --- a/bundles/SeoBundle/src/Redirect/Csv.php +++ b/bundles/SeoBundle/src/Redirect/Csv.php @@ -17,6 +17,8 @@ namespace Pimcore\Bundle\SeoBundle\Redirect; +use DateTime; +use InvalidArgumentException; use League\Csv\EncloseField; use League\Csv\Reader; use League\Csv\Statement; @@ -28,6 +30,7 @@ use Pimcore\Tool\ArrayNormalizer; use Pimcore\Tool\Text; use Symfony\Component\OptionsResolver\OptionsResolver; +use Throwable; /** * @internal @@ -86,7 +89,7 @@ public function createExportWriter(Redirect\Listing $list): Writer $expiry = null; if ($redirect->getExpiry()) { - $expiry = (new \DateTime('@' . $redirect->getExpiry()))->format('c'); + $expiry = (new DateTime('@' . $redirect->getExpiry()))->format('c'); } $data = [ @@ -119,7 +122,7 @@ public function createExportWriter(Redirect\Listing $list): Writer public function import(string $filename): array { if (!file_exists($filename) || !is_readable($filename)) { - throw new \InvalidArgumentException(sprintf('`%s`: failed to open stream: No such file or directory', $filename)); + throw new InvalidArgumentException(sprintf('`%s`: failed to open stream: No such file or directory', $filename)); } // reading the whole content and converting it to UTF-8 I didn't get the stream filter to work properly @@ -152,7 +155,7 @@ public function import(string $filename): array $this->processImportData($data, $stats); $stats['imported']++; - } catch (\Throwable $e) { + } catch (Throwable $e) { $stats['errored']++; $errors[$line] = $e->getMessage(); } diff --git a/bundles/SeoBundle/src/Redirect/RedirectHandler.php b/bundles/SeoBundle/src/Redirect/RedirectHandler.php index b357de198ba..314ed66939a 100644 --- a/bundles/SeoBundle/src/Redirect/RedirectHandler.php +++ b/bundles/SeoBundle/src/Redirect/RedirectHandler.php @@ -16,6 +16,7 @@ namespace Pimcore\Bundle\SeoBundle\Redirect; +use Exception; use Pimcore\Bundle\SeoBundle\Event\Model\RedirectEvent; use Pimcore\Bundle\SeoBundle\Event\RedirectEvents; use Pimcore\Bundle\SeoBundle\Model\Redirect; @@ -73,9 +74,9 @@ public function __construct(RequestHelper $requestHelper, SiteResolver $siteReso /** * * - * @throws \Exception + * @throws Exception */ - public function checkForRedirect(Request $request, bool $override = false, Site $sourceSite = null): ?Response + public function checkForRedirect(Request $request, bool $override = false, ?Site $sourceSite = null): ?Response { // not for admin requests if ($this->requestHelper->isFrontendRequestByAdmin($request)) { @@ -104,13 +105,13 @@ public function checkForRedirect(Request $request, bool $override = false, Site } /** - * @throws \Exception + * @throws Exception */ private function matchRegexRedirect( Redirect $redirect, Request $request, RedirectUrlPartResolver $partResolver, - Site $sourceSite = null + ?Site $sourceSite = null ): ?Response { if (empty($redirect->getType())) { return null; @@ -144,7 +145,7 @@ private function matchRegexRedirect( /** * * - * @throws \Exception + * @throws Exception */ protected function buildRedirectResponse(Redirect $redirect, Request $request, array $matches = []): ?Response { @@ -257,7 +258,7 @@ private function getRegexRedirects(): array $this->redirects = $list->load(); Cache::save($this->redirects, $cacheKey, ['system', 'redirect', 'route'], null, 998, true); - } catch (\Exception $e) { + } catch (Exception $e) { $this->logger->error('Failed to load redirects'); } } diff --git a/bundles/SeoBundle/src/Redirect/RedirectUrlPartResolver.php b/bundles/SeoBundle/src/Redirect/RedirectUrlPartResolver.php index 5715189ce1e..9fc8aea5e2a 100644 --- a/bundles/SeoBundle/src/Redirect/RedirectUrlPartResolver.php +++ b/bundles/SeoBundle/src/Redirect/RedirectUrlPartResolver.php @@ -17,6 +17,7 @@ namespace Pimcore\Bundle\SeoBundle\Redirect; +use InvalidArgumentException; use Pimcore\Bundle\SeoBundle\Model\Redirect; use Symfony\Component\HttpFoundation\Request; @@ -64,7 +65,7 @@ public function getRequestUriPart(string $type): string } if (null === $part) { - throw new \InvalidArgumentException(sprintf('Unsupported request URI part type "%s"', $type)); + throw new InvalidArgumentException(sprintf('Unsupported request URI part type "%s"', $type)); } $this->parts[$type] = urldecode($part); diff --git a/bundles/SeoBundle/src/Sitemap/Document/DocumentGeneratorContext.php b/bundles/SeoBundle/src/Sitemap/Document/DocumentGeneratorContext.php index fd6c76a6bd9..5d3c7f1752a 100644 --- a/bundles/SeoBundle/src/Sitemap/Document/DocumentGeneratorContext.php +++ b/bundles/SeoBundle/src/Sitemap/Document/DocumentGeneratorContext.php @@ -17,6 +17,7 @@ namespace Pimcore\Bundle\SeoBundle\Sitemap\Document; +use InvalidArgumentException; use Pimcore\Bundle\SeoBundle\Sitemap\Element\GeneratorContext; use Pimcore\Model\Site; use Presta\SitemapBundle\Service\UrlContainerInterface; @@ -25,8 +26,8 @@ class DocumentGeneratorContext extends GeneratorContext { public function __construct( UrlContainerInterface $urlContainer, - string $section = null, - Site $site = null, + ?string $section = null, + ?Site $site = null, array $parameters = [] ) { if (null !== $site) { @@ -34,7 +35,7 @@ public function __construct( } if (isset($parameters['site']) && !$parameters['site'] instanceof Site) { - throw new \InvalidArgumentException(sprintf('Site parameter must be an instance of %s', Site::class)); + throw new InvalidArgumentException(sprintf('Site parameter must be an instance of %s', Site::class)); } parent::__construct($urlContainer, $section, $parameters); diff --git a/bundles/SeoBundle/src/Sitemap/Document/DocumentTreeGenerator.php b/bundles/SeoBundle/src/Sitemap/Document/DocumentTreeGenerator.php index 732b6d296bc..83674cad759 100644 --- a/bundles/SeoBundle/src/Sitemap/Document/DocumentTreeGenerator.php +++ b/bundles/SeoBundle/src/Sitemap/Document/DocumentTreeGenerator.php @@ -17,6 +17,9 @@ namespace Pimcore\Bundle\SeoBundle\Sitemap\Document; +use Exception; +use Generator; +use Pimcore; use Pimcore\Bundle\SeoBundle\Sitemap\Element\AbstractElementGenerator; use Pimcore\Logger; use Pimcore\Model\Document; @@ -69,12 +72,12 @@ protected function configureOptions(OptionsResolver $options): void $options->setAllowedTypes('garbageCollectThreshold', 'int'); } - public function populate(UrlContainerInterface $urlContainer, string $section = null): void + public function populate(UrlContainerInterface $urlContainer, ?string $section = null): void { if ($this->options['handleMainDomain'] && (null === $section || $section === 'default')) { $rootDocument = Document::getById($this->options['rootId']); - if($rootDocument instanceof Document) { + if ($rootDocument instanceof Document) { $this->populateCollection($urlContainer, $rootDocument, 'default'); } } @@ -87,7 +90,7 @@ public function populate(UrlContainerInterface $urlContainer, string $section = $siteSection = sprintf('site_%s', $currentSite->getId()); $this->populateCollection($urlContainer, $rootDocument, $siteSection, $currentSite); } - } catch (\Exception $e) { + } catch (Exception $e) { Logger::error('Cannot determine current domain for sitemap generation'); } } @@ -104,7 +107,7 @@ public function populate(UrlContainerInterface $urlContainer, string $section = } } - private function populateCollection(UrlContainerInterface $urlContainer, Document $rootDocument, string $section, Site $site = null): void + private function populateCollection(UrlContainerInterface $urlContainer, Document $rootDocument, string $section, ?Site $site = null): void { $context = new DocumentGeneratorContext($urlContainer, $section, $site); $visit = $this->visit($rootDocument, $context); @@ -134,9 +137,9 @@ private function createUrl(Document $document, DocumentGeneratorContext $context } /** - * @throws \Exception + * @throws Exception */ - private function visit(Document $document, DocumentGeneratorContext $context): \Generator + private function visit(Document $document, DocumentGeneratorContext $context): Generator { if ($document instanceof Document\Hardlink) { $document = Document\Hardlink\Service::wrap($document); @@ -150,7 +153,7 @@ private function visit(Document $document, DocumentGeneratorContext $context): \ if (++$this->currentBatchCount >= $this->options['garbageCollectThreshold']) { $this->currentBatchCount = 0; - \Pimcore::collectGarbage(); + Pimcore::collectGarbage(); } } diff --git a/bundles/SeoBundle/src/Sitemap/Document/DocumentUrlGenerator.php b/bundles/SeoBundle/src/Sitemap/Document/DocumentUrlGenerator.php index 3f5d91f0278..f0f79728889 100644 --- a/bundles/SeoBundle/src/Sitemap/Document/DocumentUrlGenerator.php +++ b/bundles/SeoBundle/src/Sitemap/Document/DocumentUrlGenerator.php @@ -20,6 +20,7 @@ use Pimcore\Bundle\SeoBundle\Sitemap\UrlGeneratorInterface; use Pimcore\Model\Document; use Pimcore\Model\Site; +use RuntimeException; /** * URL generator specific to documents with site support. @@ -38,7 +39,7 @@ public function generateUrl(string $path, array $options = []): string return $this->urlGenerator->generateUrl($path, $options); } - public function generateDocumentUrl(Document $document, Site $site = null, array $options = []): string + public function generateDocumentUrl(Document $document, ?Site $site = null, array $options = []): string { if ($document instanceof Document\Page && $document->getPrettyUrl()) { $prettyUrlSet = true; @@ -57,7 +58,7 @@ public function generateDocumentUrl(Document $document, Site $site = null, array return $this->urlGenerator->generateUrl($path, $options); } - protected function prepareOptions(array $options, Site $site = null): array + protected function prepareOptions(array $options, ?Site $site = null): array { if (!isset($options['host'])) { // set site host as default value if it is not explicitely set via options @@ -89,7 +90,7 @@ protected function hostForSite(Site $site): string } if (empty($host)) { - throw new \RuntimeException(sprintf('Failed to resolve host for site %d', $site->getId())); + throw new RuntimeException(sprintf('Failed to resolve host for site %d', $site->getId())); } return $host; diff --git a/bundles/SeoBundle/src/Sitemap/Document/DocumentUrlGeneratorInterface.php b/bundles/SeoBundle/src/Sitemap/Document/DocumentUrlGeneratorInterface.php index 6ba8ef84725..4917e2483ca 100644 --- a/bundles/SeoBundle/src/Sitemap/Document/DocumentUrlGeneratorInterface.php +++ b/bundles/SeoBundle/src/Sitemap/Document/DocumentUrlGeneratorInterface.php @@ -23,5 +23,5 @@ interface DocumentUrlGeneratorInterface extends UrlGeneratorInterface { - public function generateDocumentUrl(Document $document, Site $site = null, array $options = []): string; + public function generateDocumentUrl(Document $document, ?Site $site = null, array $options = []): string; } diff --git a/bundles/SeoBundle/src/Sitemap/Document/Filter/DocumentTypeFilter.php b/bundles/SeoBundle/src/Sitemap/Document/Filter/DocumentTypeFilter.php index 58fc6396467..8e285f411f7 100644 --- a/bundles/SeoBundle/src/Sitemap/Document/Filter/DocumentTypeFilter.php +++ b/bundles/SeoBundle/src/Sitemap/Document/Filter/DocumentTypeFilter.php @@ -37,7 +37,7 @@ class DocumentTypeFilter implements FilterInterface 'hardlink', ]; - public function __construct(array $documentTypes = null, array $containerTypes = null) + public function __construct(?array $documentTypes = null, ?array $containerTypes = null) { if (null !== $documentTypes) { $this->documentTypes = $documentTypes; diff --git a/bundles/SeoBundle/src/Sitemap/Document/Filter/SiteRootFilter.php b/bundles/SeoBundle/src/Sitemap/Document/Filter/SiteRootFilter.php index 7f4ece7605f..1ba1ea45cb5 100644 --- a/bundles/SeoBundle/src/Sitemap/Document/Filter/SiteRootFilter.php +++ b/bundles/SeoBundle/src/Sitemap/Document/Filter/SiteRootFilter.php @@ -55,7 +55,7 @@ public function handlesChildren(ElementInterface $element, GeneratorContextInter return $this->canBeAdded($element, $context); } - private function isExcludedSiteRoot(Document $document, Site $site = null): bool + private function isExcludedSiteRoot(Document $document, ?Site $site = null): bool { if (null === $this->siteRoots) { $sites = (new Site\Listing())->load(); diff --git a/bundles/SeoBundle/src/Sitemap/Element/GeneratorContext.php b/bundles/SeoBundle/src/Sitemap/Element/GeneratorContext.php index 27f182a10ca..d1af58b3327 100644 --- a/bundles/SeoBundle/src/Sitemap/Element/GeneratorContext.php +++ b/bundles/SeoBundle/src/Sitemap/Element/GeneratorContext.php @@ -17,6 +17,8 @@ namespace Pimcore\Bundle\SeoBundle\Sitemap\Element; +use ArrayIterator; +use Iterator; use Presta\SitemapBundle\Service\UrlContainerInterface; class GeneratorContext implements GeneratorContextInterface @@ -27,7 +29,7 @@ class GeneratorContext implements GeneratorContextInterface private array $parameters = []; - public function __construct(UrlContainerInterface $urlContainer, string $section = null, array $parameters = []) + public function __construct(UrlContainerInterface $urlContainer, ?string $section = null, array $parameters = []) { $this->urlContainer = $urlContainer; $this->section = $section; @@ -64,9 +66,9 @@ public function has(int|string $key): bool return array_key_exists($key, $this->parameters); } - public function getIterator(): \Iterator + public function getIterator(): Iterator { - return new \ArrayIterator($this->parameters); + return new ArrayIterator($this->parameters); } public function count(): int diff --git a/bundles/SeoBundle/src/Sitemap/Element/GeneratorContextInterface.php b/bundles/SeoBundle/src/Sitemap/Element/GeneratorContextInterface.php index 82613d21760..ff77edcf8c1 100644 --- a/bundles/SeoBundle/src/Sitemap/Element/GeneratorContextInterface.php +++ b/bundles/SeoBundle/src/Sitemap/Element/GeneratorContextInterface.php @@ -17,12 +17,13 @@ namespace Pimcore\Bundle\SeoBundle\Sitemap\Element; +use IteratorAggregate; use Presta\SitemapBundle\Service\UrlContainerInterface; /** * Context which is passed to every filter/processor */ -interface GeneratorContextInterface extends \IteratorAggregate, \Countable +interface GeneratorContextInterface extends IteratorAggregate, \Countable { public function getUrlContainer(): UrlContainerInterface; diff --git a/bundles/SeoBundle/src/Sitemap/Element/Processor/ModificationDateProcessor.php b/bundles/SeoBundle/src/Sitemap/Element/Processor/ModificationDateProcessor.php index c6dd4db201a..57d75281410 100644 --- a/bundles/SeoBundle/src/Sitemap/Element/Processor/ModificationDateProcessor.php +++ b/bundles/SeoBundle/src/Sitemap/Element/Processor/ModificationDateProcessor.php @@ -17,6 +17,7 @@ namespace Pimcore\Bundle\SeoBundle\Sitemap\Element\Processor; +use DateTime; use Pimcore\Bundle\SeoBundle\Sitemap\Element\GeneratorContextInterface; use Pimcore\Bundle\SeoBundle\Sitemap\Element\ProcessorInterface; use Pimcore\Model\Element\ElementInterface; @@ -34,7 +35,7 @@ public function process(Url $url, ElementInterface $element, GeneratorContextInt return $url; } - $url->setLastmod(\DateTime::createFromFormat('U', (string)$element->getModificationDate())); + $url->setLastmod(DateTime::createFromFormat('U', (string)$element->getModificationDate())); return $url; } diff --git a/bundles/SeoBundle/src/Sitemap/GeneratorInterface.php b/bundles/SeoBundle/src/Sitemap/GeneratorInterface.php index 31743d6adce..3217f46ee6a 100644 --- a/bundles/SeoBundle/src/Sitemap/GeneratorInterface.php +++ b/bundles/SeoBundle/src/Sitemap/GeneratorInterface.php @@ -24,5 +24,5 @@ interface GeneratorInterface /** * Populates the sitemap */ - public function populate(UrlContainerInterface $urlContainer, string $section = null): void; + public function populate(UrlContainerInterface $urlContainer, ?string $section = null): void; } diff --git a/bundles/SimpleBackendSearchBundle/public/js/pimcore/element/selector/asset.js b/bundles/SimpleBackendSearchBundle/public/js/pimcore/element/selector/asset.js index e35506e4c77..6e0e1a952c0 100644 --- a/bundles/SimpleBackendSearchBundle/public/js/pimcore/element/selector/asset.js +++ b/bundles/SimpleBackendSearchBundle/public/js/pimcore/element/selector/asset.js @@ -62,7 +62,7 @@ pimcore.bundle.search.element.selector.asset = Class.create(pimcore.bundle.searc } }, new Ext.Button({ handler: function () { - window.open("http://dev.mysql.com/doc/refman/5.6/en/fulltext-boolean.html"); + window.open("https://dev.mysql.com/doc/refman/8.0/en/fulltext-boolean.html"); }, iconCls: "pimcore_icon_help" })] diff --git a/bundles/SimpleBackendSearchBundle/public/js/pimcore/element/selector/document.js b/bundles/SimpleBackendSearchBundle/public/js/pimcore/element/selector/document.js index 8d794bf739d..aa462135689 100644 --- a/bundles/SimpleBackendSearchBundle/public/js/pimcore/element/selector/document.js +++ b/bundles/SimpleBackendSearchBundle/public/js/pimcore/element/selector/document.js @@ -62,7 +62,7 @@ pimcore.bundle.search.element.selector.document = Class.create(pimcore.bundle.se } }, new Ext.Button({ handler: function () { - window.open("http://dev.mysql.com/doc/refman/5.6/en/fulltext-boolean.html"); + window.open("https://dev.mysql.com/doc/refman/8.0/en/fulltext-boolean.html"); }, iconCls: "pimcore_icon_help" })] diff --git a/bundles/SimpleBackendSearchBundle/public/js/pimcore/element/selector/object.js b/bundles/SimpleBackendSearchBundle/public/js/pimcore/element/selector/object.js index f702900764e..c1b3a4d772b 100644 --- a/bundles/SimpleBackendSearchBundle/public/js/pimcore/element/selector/object.js +++ b/bundles/SimpleBackendSearchBundle/public/js/pimcore/element/selector/object.js @@ -57,7 +57,7 @@ pimcore.bundle.search.element.selector.object = Class.create(pimcore.bundle.sear } }, new Ext.Button({ handler: function () { - window.open("http://dev.mysql.com/doc/refman/5.6/en/fulltext-boolean.html"); + window.open("https://dev.mysql.com/doc/refman/8.0/en/fulltext-boolean.html"); }, iconCls: "pimcore_icon_help" })] diff --git a/bundles/SimpleBackendSearchBundle/src/Command/SearchBackendReindexCommand.php b/bundles/SimpleBackendSearchBundle/src/Command/SearchBackendReindexCommand.php index 8af6d68ad18..fb3c2dbcc47 100644 --- a/bundles/SimpleBackendSearchBundle/src/Command/SearchBackendReindexCommand.php +++ b/bundles/SimpleBackendSearchBundle/src/Command/SearchBackendReindexCommand.php @@ -16,6 +16,8 @@ namespace Pimcore\Bundle\SimpleBackendSearchBundle\Command; +use Exception; +use Pimcore; use Pimcore\Bundle\SimpleBackendSearchBundle\Model\Search; use Pimcore\Console\AbstractCommand; use Pimcore\Logger; @@ -38,7 +40,7 @@ class SearchBackendReindexCommand extends AbstractCommand { /** - * @throws \Exception + * @throws Exception */ protected function execute(InputInterface $input, OutputInterface $output): int { @@ -95,11 +97,11 @@ protected function execute(InputInterface $input, OutputInterface $output): int } $searchEntry->save(); - } catch (\Exception $e) { + } catch (Exception $e) { Logger::err((string) $e); } } - \Pimcore::collectGarbage(); + Pimcore::collectGarbage(); } } @@ -109,7 +111,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int } /** - * @throws \Exception + * @throws Exception */ private function saveAsset(Asset $asset): void { diff --git a/bundles/SimpleBackendSearchBundle/src/Controller/DataObjectController.php b/bundles/SimpleBackendSearchBundle/src/Controller/DataObjectController.php index cc5c5dfbd35..2d091aeb72c 100644 --- a/bundles/SimpleBackendSearchBundle/src/Controller/DataObjectController.php +++ b/bundles/SimpleBackendSearchBundle/src/Controller/DataObjectController.php @@ -29,7 +29,7 @@ class DataObjectController extends UserAwareController */ public function optionsAction(Request $request): JsonResponse { - $fieldConfig = json_decode($request->get('fieldConfig'), true); + $fieldConfig = json_decode($request->query->getString('fieldConfig'), true); $options = []; $classes = []; @@ -46,18 +46,46 @@ public function optionsAction(Request $request): JsonResponse } $searchRequest = $request; - $searchRequest->request->set('type', 'object'); - $searchRequest->request->set('subtype', 'object,variant'); + if ($fieldConfig['fieldtype'] === 'manyToOneRelation') { + $types = []; + $subtypes = []; + if ($fieldConfig['documentsAllowed']) { + $types[] = 'document'; + foreach ($fieldConfig['documentTypes'] as $documentTypes) { + $subtypes[] = $documentTypes['documentTypes']; + } + } + if ($fieldConfig['assetsAllowed']) { + $types[] = 'asset'; + foreach ($fieldConfig['assetTypes'] as $assetTypes) { + $subtypes[] = $assetTypes['assetTypes']; + } + } + if ($fieldConfig['objectsAllowed']) { + $types[] = 'object'; + $subtypes[] = 'object'; + $subtypes[] = 'variant'; + } + $searchRequest->request->set('type', implode(',', $types)); + $searchRequest->request->set('subtype', implode(',', $subtypes)); + } else { + $searchRequest->request->set('type', 'object'); + $searchRequest->request->set('subtype', 'object,variant'); + } $searchRequest->request->set('class', implode(',', $classes)); $searchRequest->request->set('fields', $visibleFields); - $searchRequest->attributes->set('unsavedChanges', $request->get('unsavedChanges', '')); + + $searchRequest->attributes->set('unsavedChanges', $request->query->getString('unsavedChanges')); $res = $this->forward(SearchController::class.'::findAction', ['request' => $searchRequest]); $objects = json_decode($res->getContent(), true)['data']; - if ($request->get('data')) { - foreach (json_decode($request->get('data'), true) as $preSelectedElement) { - if (isset($preSelectedElement['id'], $preSelectedElement['type'])) { - $objects[] = ['id' => $preSelectedElement['id'], 'type' => $preSelectedElement['type']]; + if ($request->query->has('data')) { + $dataArray = json_decode($request->query->getString('data'), true); + if (is_array($dataArray)) { + foreach ($dataArray as $preSelectedElement) { + if (isset($preSelectedElement['id'], $preSelectedElement['type'])) { + $objects[] = ['id' => $preSelectedElement['id'], 'type' => $preSelectedElement['type']]; + } } } } diff --git a/bundles/SimpleBackendSearchBundle/src/Controller/SearchController.php b/bundles/SimpleBackendSearchBundle/src/Controller/SearchController.php index 5bd7bb71f6c..8e18cf467dd 100644 --- a/bundles/SimpleBackendSearchBundle/src/Controller/SearchController.php +++ b/bundles/SimpleBackendSearchBundle/src/Controller/SearchController.php @@ -17,10 +17,14 @@ namespace Pimcore\Bundle\SimpleBackendSearchBundle\Controller; use Doctrine\DBAL\Exception\SyntaxErrorException; +use Exception; +use InvalidArgumentException; +use Pimcore; use Pimcore\Bundle\AdminBundle\Event\AdminEvents; use Pimcore\Bundle\AdminBundle\Event\ElementAdminStyleEvent; use Pimcore\Bundle\AdminBundle\Helper\GridHelperService; use Pimcore\Bundle\AdminBundle\Helper\QueryParams; +use Pimcore\Bundle\AdminBundle\Service\GridData; use Pimcore\Bundle\SimpleBackendSearchBundle\Event\AdminSearchEvents; use Pimcore\Bundle\SimpleBackendSearchBundle\Model\Search\Backend\Data; use Pimcore\Config; @@ -30,6 +34,7 @@ use Pimcore\Extension\Bundle\Exception\AdminClassicBundleNotFoundException; use Pimcore\Model\Asset; use Pimcore\Model\DataObject; +use Pimcore\Model\DataObject\ClassDefinition\Data\Localizedfields; use Pimcore\Model\Document; use Pimcore\Model\Element; use Pimcore\Model\Element\AdminStyle; @@ -133,6 +138,7 @@ public function findAction(Request $request, EventDispatcherInterface $eventDisp // filtering for objects if (!empty($allParams['filter']) && !empty($allParams['class'])) { $class = DataObject\ClassDefinition::getByName($allParams['class']); + $localizedFields = $class->getFieldDefinition('localizedfields'); // add Localized Fields filtering $params = $this->decodeJson($allParams['filter']); @@ -141,12 +147,12 @@ public function findAction(Request $request, EventDispatcherInterface $eventDisp foreach ($params as $paramConditionObject) { //this loop divides filter parameters to localized and unlocalized groups - $definitionExists = in_array($paramConditionObject['property'], DataObject\Service::getSystemFields()) - || $class->getFieldDefinition($paramConditionObject['property']); - if ($definitionExists) { //TODO: for sure, we can add additional condition like getLocalizedFieldDefinition()->getFieldDefiniton(... + if (in_array($paramConditionObject['property'], DataObject\Service::getSystemFields())) { $unlocalizedFieldsFilters[] = $paramConditionObject; - } else { + } elseif ($localizedFields instanceof Localizedfields && $localizedFields->getFieldDefinition($paramConditionObject['property'])) { $localizedFieldsFilters[] = $paramConditionObject; + } elseif ($class->getFieldDefinition($paramConditionObject['property'])) { + $unlocalizedFieldsFilters[] = $paramConditionObject; } } @@ -323,20 +329,30 @@ public function findAction(Request $request, EventDispatcherInterface $eventDisp try { $hits = $searcherList->load(); } catch (SyntaxErrorException $syntaxErrorException) { - throw new \InvalidArgumentException('Check your arguments.'); + throw new InvalidArgumentException('Check your arguments.'); } $elements = []; foreach ($hits as $hit) { $element = Element\Service::getElementById($hit->getId()->getType(), $hit->getId()->getId()); if ($element->isAllowed('list')) { + $data = null; - if ($element instanceof DataObject\AbstractObject) { - $data = DataObject\Service::gridObjectData($element, $fields); - } elseif ($element instanceof Document) { - $data = Document\Service::gridDocumentData($element); - } elseif ($element instanceof Asset) { - $data = Asset\Service::gridAssetData($element); + if (class_exists(GridData\DataObject::class)) { + $data = match (true) { + $element instanceof DataObject\AbstractObject => GridData\DataObject::getData($element, $fields), + // @phpstan-ignore-next-line checking dataObject once is enough + $element instanceof Document => GridData\Document::getData($element), + // @phpstan-ignore-next-line otherwise have to do class_exists for each element type + $element instanceof Asset => GridData\Asset::getData($element), + default => null + }; + } else { + // TODO: remove in pimcore/pimcore 12.0, kept only to avoid conflicting admin ui classic bundle < 1.5 + $data = match (true) { + $element instanceof DataObject\AbstractObject => DataObject\Service::gridObjectData($element, $fields), + default => null + }; } if ($data) { @@ -471,7 +487,7 @@ protected function filterQueryParam(string $query): string */ public function quickSearchAction(Request $request, EventDispatcherInterface $eventDispatcher): JsonResponse { - $query = $this->filterQueryParam($request->get('query', '')); + $query = $this->filterQueryParam($request->query->getString('query')); if (!preg_match('/[\+\-\*"]/', $query)) { // check for a boolean operator (which was not filtered by filterQueryParam()), // if present, do not add asterisk at the end of the query @@ -543,9 +559,8 @@ public function quickSearchAction(Request $request, EventDispatcherInterface $ev */ public function quickSearchByIdAction(Request $request, Config $config): JsonResponse { - $type = $request->get('type'); - $id = $request->get('id'); - $db = \Pimcore\Db::get(); + $type = $request->query->getString('type'); + $id = $request->query->getInt('id'); $searcherList = new Data\Listing(); $searcherList->addConditionParam('id = :id', ['id' => $id]); @@ -609,12 +624,12 @@ protected function shortenPath(string $path): string /** * - * @throws \Exception + * @throws Exception */ - protected function addAdminStyle(ElementInterface $element, int $context = null, array &$data = []): void + protected function addAdminStyle(ElementInterface $element, ?int $context = null, array &$data = []): void { $event = new ElementAdminStyleEvent($element, new AdminStyle($element), $context); - \Pimcore::getEventDispatcher()->dispatch($event, AdminEvents::RESOLVE_ELEMENT_ADMIN_STYLE); + Pimcore::getEventDispatcher()->dispatch($event, AdminEvents::RESOLVE_ELEMENT_ADMIN_STYLE); $adminStyle = $event->getAdminStyle(); $data['iconCls'] = $adminStyle->getElementIconClass() !== false ? $adminStyle->getElementIconClass() : null; diff --git a/bundles/SimpleBackendSearchBundle/src/DataProvider/GDPR/Assets.php b/bundles/SimpleBackendSearchBundle/src/DataProvider/GDPR/Assets.php index f3343276bac..427149a900d 100644 --- a/bundles/SimpleBackendSearchBundle/src/DataProvider/GDPR/Assets.php +++ b/bundles/SimpleBackendSearchBundle/src/DataProvider/GDPR/Assets.php @@ -17,6 +17,7 @@ namespace Pimcore\Bundle\SimpleBackendSearchBundle\DataProvider\GDPR; use Pimcore\Bundle\AdminBundle\GDPR\DataProvider; +use Pimcore\Bundle\AdminBundle\Service\GridData; use Pimcore\Bundle\SimpleBackendSearchBundle\Model\Search\Backend\Data; use Pimcore\Db; use Pimcore\Model\Asset; @@ -24,7 +25,7 @@ class Assets extends DataProvider\Assets { - public function searchData(int $id, string $firstname, string $lastname, string $email, int $start, int $limit, string $sort = null): array + public function searchData(int $id, string $firstname, string $lastname, string $email, int $start, int $limit, ?string $sort = null): array { if (empty($id) && empty($firstname) && empty($lastname) && empty($email)) { return ['data' => [], 'success' => true, 'total' => 0]; @@ -96,7 +97,11 @@ public function searchData(int $id, string $firstname, string $lastname, string $element = Service::getElementById($hit->getId()->getType(), $hit->getId()->getId()); if ($element instanceof Asset) { - $data = \Pimcore\Model\Asset\Service::gridAssetData($element); + $data = []; + // TODO: remove the class_exists on pimcore 12.0 + if (class_exists(GridData\Asset::class)) { + $data = GridData\Asset::getData($element); + } $data['permissions'] = $element->getUserPermissions(); $elements[] = $data; } diff --git a/bundles/SimpleBackendSearchBundle/src/DataProvider/GDPR/DataObjects.php b/bundles/SimpleBackendSearchBundle/src/DataProvider/GDPR/DataObjects.php index 3af045e8ee2..72a2f614b2c 100644 --- a/bundles/SimpleBackendSearchBundle/src/DataProvider/GDPR/DataObjects.php +++ b/bundles/SimpleBackendSearchBundle/src/DataProvider/GDPR/DataObjects.php @@ -18,6 +18,7 @@ use Pimcore\Bundle\AdminBundle\GDPR\DataProvider; use Pimcore\Bundle\AdminBundle\Helper\QueryParams; +use Pimcore\Bundle\AdminBundle\Service\GridData; use Pimcore\Bundle\SimpleBackendSearchBundle\Model\Search\Backend\Data; use Pimcore\Model\DataObject; use Pimcore\Model\DataObject\Concrete; @@ -25,7 +26,7 @@ class DataObjects extends DataProvider\DataObjects { - public function searchData(int $id, string $firstname, string $lastname, string $email, int $start, int $limit, string $sort = null): array + public function searchData(int $id, string $firstname, string $lastname, string $email, int $start, int $limit, ?string $sort = null): array { if (empty($id) && empty($firstname) && empty($lastname) && empty($email)) { return ['data' => [], 'success' => true, 'total' => 0]; @@ -102,7 +103,11 @@ public function searchData(int $id, string $firstname, string $lastname, string foreach ($hits as $hit) { $element = Element\Service::getElementById($hit->getId()->getType(), $hit->getId()->getId()); if ($element instanceof Concrete) { - $data = DataObject\Service::gridObjectData($element); + if (class_exists(GridData\DataObject::class)) { + $data = GridData\DataObject::getData($element); + } else { + $data = DataObject\Service::gridObjectData($element); + } $data['__gdprIsDeletable'] = $this->config['classes'][$element->getClassName()]['allowDelete'] ?? false; $elements[] = $data; } diff --git a/bundles/SimpleBackendSearchBundle/src/EventListener/SearchBackendListener.php b/bundles/SimpleBackendSearchBundle/src/EventListener/SearchBackendListener.php index b167cc5239a..5c674bd24b9 100644 --- a/bundles/SimpleBackendSearchBundle/src/EventListener/SearchBackendListener.php +++ b/bundles/SimpleBackendSearchBundle/src/EventListener/SearchBackendListener.php @@ -16,6 +16,7 @@ namespace Pimcore\Bundle\SimpleBackendSearchBundle\EventListener; +use Pimcore\Bundle\AdminBundle\Event\AdminEvents; use Pimcore\Bundle\SimpleBackendSearchBundle\Message\SearchBackendMessage; use Pimcore\Bundle\SimpleBackendSearchBundle\Model\Search\Backend\Data; use Pimcore\Event\AssetEvents; @@ -23,8 +24,10 @@ use Pimcore\Event\DocumentEvents; use Pimcore\Event\Model\AssetEvent; use Pimcore\Event\Model\ElementEventInterface; +use Pimcore\Model\DataObject\Listing; use Pimcore\Model\Element\Service; use Symfony\Component\EventDispatcher\EventSubscriberInterface; +use Symfony\Component\EventDispatcher\GenericEvent; use Symfony\Component\Messenger\MessageBusInterface; /** @@ -39,7 +42,7 @@ public function __construct( public static function getSubscribedEvents(): array { - return [ + $events = [ DataObjectEvents::POST_ADD => 'onPostAddUpdateElement', DocumentEvents::POST_ADD => 'onPostAddUpdateElement', AssetEvents::POST_ADD => 'onPostAddUpdateElement', @@ -52,6 +55,13 @@ public static function getSubscribedEvents(): array DocumentEvents::POST_UPDATE => 'onPostAddUpdateElement', AssetEvents::POST_UPDATE => 'onPostAddUpdateElement', ]; + + // used when admin UI classic bundle is installed + if (class_exists(AdminEvents::class) && defined(AdminEvents::class . '::OBJECT_LIST_HANDLE_FULLTEXT_QUERY')) { + $events[AdminEvents::OBJECT_LIST_HANDLE_FULLTEXT_QUERY] = 'onHandleFulltextQuery'; + } + + return $events; } public function onPostAddUpdateElement(ElementEventInterface $e): void @@ -74,8 +84,19 @@ public function onPostAddUpdateElement(ElementEventInterface $e): void public function onPreDeleteElement(ElementEventInterface $e): void { $searchEntry = Data::getForElement($e->getElement()); - if ($searchEntry instanceof Data && $searchEntry->getId() instanceof Data\Id) { + if ($searchEntry->getId()) { $searchEntry->delete(); } } + + public function onHandleFulltextQuery(GenericEvent $e): void + { + $query = $e->getArgument('query'); + /** @var Listing $list */ + $list = $e->getArgument('list'); + $e->setArgument( + 'condition', + 'oo_id IN (SELECT id FROM search_backend_data WHERE maintype = "object" AND MATCH (`data`,`properties`) AGAINST (' . $list->quote($query) . ' IN BOOLEAN MODE))' + ); + } } diff --git a/bundles/SimpleBackendSearchBundle/src/MessageHandler/SearchBackendHandler.php b/bundles/SimpleBackendSearchBundle/src/MessageHandler/SearchBackendHandler.php index 32134c4d378..8978b3fab43 100644 --- a/bundles/SimpleBackendSearchBundle/src/MessageHandler/SearchBackendHandler.php +++ b/bundles/SimpleBackendSearchBundle/src/MessageHandler/SearchBackendHandler.php @@ -23,6 +23,7 @@ use Symfony\Component\Messenger\Handler\Acknowledger; use Symfony\Component\Messenger\Handler\BatchHandlerInterface; use Symfony\Component\Messenger\Handler\BatchHandlerTrait; +use Throwable; /** * @internal @@ -32,7 +33,7 @@ class SearchBackendHandler implements BatchHandlerInterface use BatchHandlerTrait; use HandlerHelperTrait; - public function __invoke(SearchBackendMessage $message, Acknowledger $ack = null): mixed + public function __invoke(SearchBackendMessage $message, ?Acknowledger $ack = null): mixed { return $this->handle($message, $ack); } @@ -53,16 +54,15 @@ private function process(array $jobs): void } $searchEntry = Data::getForElement($element); - if ($searchEntry instanceof Data && $searchEntry->getId() instanceof Data\Id) { + if ($searchEntry->getId()) { $searchEntry->setDataFromElement($element); - $searchEntry->save(); } else { $searchEntry = new Data($element); - $searchEntry->save(); } + $searchEntry->save(); $ack->ack($message); - } catch (\Throwable $e) { + } catch (Throwable $e) { $ack->nack($e); } } @@ -70,6 +70,6 @@ private function process(array $jobs): void private function shouldFlush(): bool { - return 50 <= \count($this->jobs); + return 50 <= count($this->jobs); } } diff --git a/bundles/SimpleBackendSearchBundle/src/Model/Search/Backend/Data.php b/bundles/SimpleBackendSearchBundle/src/Model/Search/Backend/Data.php index 7251a4558cc..86084a0fc83 100644 --- a/bundles/SimpleBackendSearchBundle/src/Model/Search/Backend/Data.php +++ b/bundles/SimpleBackendSearchBundle/src/Model/Search/Backend/Data.php @@ -17,7 +17,9 @@ namespace Pimcore\Bundle\SimpleBackendSearchBundle\Model\Search\Backend; use Doctrine\DBAL\Exception\DeadlockException; +use Exception; use ForceUTF8\Encoding; +use Pimcore; use Pimcore\Bundle\SimpleBackendSearchBundle\Event\Model\SearchBackendEvent; use Pimcore\Bundle\SimpleBackendSearchBundle\Event\SearchBackendEvents; use Pimcore\Bundle\SimpleBackendSearchBundle\Model\Search\Backend\Data\Dao; @@ -102,7 +104,7 @@ class Data extends AbstractModel protected string $properties; - public function __construct(Element\ElementInterface $element = null) + public function __construct(?Element\ElementInterface $element = null) { if ($element instanceof Element\ElementInterface) { $this->setDataFromElement($element); @@ -207,7 +209,7 @@ public function getCreationDate(): ?int /** * @return $this */ - public function setCreationDate(int $creationDate): static + public function setCreationDate(?int $creationDate): static { $this->creationDate = $creationDate; @@ -222,7 +224,7 @@ public function getModificationDate(): ?int /** * @return $this */ - public function setModificationDate(int $modificationDate): static + public function setModificationDate(?int $modificationDate): static { $this->modificationDate = $modificationDate; @@ -237,7 +239,7 @@ public function getUserModification(): ?int /** * @return $this */ - public function setUserModification(int $userModification): static + public function setUserModification(?int $userModification): static { $this->userModification = $userModification; @@ -287,7 +289,7 @@ public function getData(): ?string /** * @return $this */ - public function setData(string $data): static + public function setData(?string $data): static { $this->data = $data; @@ -358,16 +360,14 @@ public function setDataFromElement(Element\ElementInterface $element): static $this->published = $element->isPublished(); $editables = $element->getEditables(); foreach ($editables as $editable) { - if ($editable instanceof Document\Editable\EditableInterface) { - // areabrick elements are handled by getElementTypes()/getElements() as they return area elements as well - if ($editable instanceof Document\Editable\Area || $editable instanceof Document\Editable\Areablock) { - continue; - } - - ob_start(); - $this->data .= strip_tags((string) $editable->frontend()).' '; - $this->data .= ob_get_clean(); + // areabrick elements are handled by getElementTypes()/getElements() as they return area elements as well + if ($editable instanceof Document\Editable\Area || $editable instanceof Document\Editable\Areablock) { + continue; } + + ob_start(); + $this->data .= strip_tags((string) $editable->frontend()).' '; + $this->data .= ob_get_clean(); } if ($element instanceof Document\Page) { $this->published = $element->isPublished(); @@ -379,7 +379,7 @@ public function setDataFromElement(Element\ElementInterface $element): static if (is_array($elementMetadata)) { foreach ($elementMetadata as $md) { try { - $loader = \Pimcore::getContainer()->get('pimcore.implementation_loader.asset.metadata.data'); + $loader = Pimcore::getContainer()->get('pimcore.implementation_loader.asset.metadata.data'); /** @var \Pimcore\Model\Asset\MetaData\ClassDefinition\Data\Data $instance */ $instance = $loader->build($md['type']); $dataForSearchIndex = $instance->getDataForSearchIndex($md['data'], $md); @@ -402,7 +402,7 @@ public function setDataFromElement(Element\ElementInterface $element): static $contentText = preg_replace('/[ ]+/', ' ', $contentText); $this->data .= ' ' . $contentText; } - } catch (\Exception $e) { + } catch (Exception $e) { Logger::error((string) $e); } } @@ -414,7 +414,7 @@ public function setDataFromElement(Element\ElementInterface $element): static $contentText = Encoding::toUTF8($contentText); $this->data .= ' ' . $contentText; } - } catch (\Exception $e) { + } catch (Exception $e) { Logger::error((string) $e); } } elseif ($element instanceof Asset\Image) { @@ -427,7 +427,7 @@ public function setDataFromElement(Element\ElementInterface $element): static $this->data .= ' ' . $key . ' : ' . $value; } } - } catch (\Exception $e) { + } catch (Exception $e) { Logger::error((string) $e); } } @@ -479,7 +479,7 @@ protected function cleanupData(string $data): string $wordOccurrences = []; foreach ($words as $key => $word) { - $wordLength = \mb_strlen($word); + $wordLength = mb_strlen($word); if ($wordLength < $minWordLength || $wordLength > $maxWordLength) { unset($words[$key]); @@ -511,7 +511,7 @@ public function delete(): void } /** - * @throws \Exception + * @throws Exception */ public function save(): void { @@ -528,10 +528,10 @@ public function save(): void $this->commit(); break; // transaction was successfully completed, so we cancel the loop here -> no restart required - } catch (\Exception $e) { + } catch (Exception $e) { try { $this->rollBack(); - } catch (\Exception $er) { + } catch (Exception $er) { // PDO adapter throws exceptions if rollback fails Logger::error((string) $er); } @@ -552,7 +552,7 @@ public function save(): void $this->dispatchEvent(new SearchBackendEvent($this), SearchBackendEvents::POST_SAVE); } else { - throw new \Exception('Search\\Backend\\Data cannot be saved - no id set!'); + throw new Exception('Search\\Backend\\Data cannot be saved - no id set!'); } } } diff --git a/bundles/SimpleBackendSearchBundle/src/Model/Search/Backend/Data/Dao.php b/bundles/SimpleBackendSearchBundle/src/Model/Search/Backend/Data/Dao.php index 0ece178a504..aeae63d4c47 100644 --- a/bundles/SimpleBackendSearchBundle/src/Model/Search/Backend/Data/Dao.php +++ b/bundles/SimpleBackendSearchBundle/src/Model/Search/Backend/Data/Dao.php @@ -16,6 +16,7 @@ namespace Pimcore\Bundle\SimpleBackendSearchBundle\Model\Search\Backend\Data; +use Exception; use Pimcore\Bundle\SimpleBackendSearchBundle\Model\Search\Backend; use Pimcore\Db\Helper; use Pimcore\Logger; @@ -39,7 +40,7 @@ public function getForElement(Model\Element\ElementInterface $element): void } elseif ($element instanceof Model\DataObject\AbstractObject) { $maintype = 'object'; } else { - throw new \Exception('unknown type of element with id [ '.$element->getId().' ] '); + throw new Exception('unknown type of element with id [ '.$element->getId().' ] '); } $data = $this->db->fetchAssociative('SELECT * FROM search_backend_data WHERE id = ? AND maintype = ? ', [$element->getId(), $maintype]); @@ -49,7 +50,7 @@ public function getForElement(Model\Element\ElementInterface $element): void $this->assignVariablesToModel($data); $this->model->setId(new Backend\Data\Id($element)); } - } catch (\Exception $e) { + } catch (Exception $e) { } } @@ -108,7 +109,7 @@ public function getMinWordLengthForFulltextIndex(): int { try { return (int) $this->db->fetchOne('SELECT @@innodb_ft_min_token_size'); - } catch (\Exception $e) { + } catch (Exception $e) { return 3; } } @@ -117,7 +118,7 @@ public function getMaxWordLengthForFulltextIndex(): int { try { return (int) $this->db->fetchOne('SELECT @@innodb_ft_max_token_size'); - } catch (\Exception $e) { + } catch (Exception $e) { return 84; } } diff --git a/bundles/SimpleBackendSearchBundle/src/Model/Search/Backend/Data/Listing.php b/bundles/SimpleBackendSearchBundle/src/Model/Search/Backend/Data/Listing.php index 68f68bae0ab..a8586b5679f 100644 --- a/bundles/SimpleBackendSearchBundle/src/Model/Search/Backend/Data/Listing.php +++ b/bundles/SimpleBackendSearchBundle/src/Model/Search/Backend/Data/Listing.php @@ -16,6 +16,7 @@ namespace Pimcore\Bundle\SimpleBackendSearchBundle\Model\Search\Backend\Data; +use Exception; use Pimcore\Bundle\SimpleBackendSearchBundle\Model\Search\Backend\Data; use Pimcore\Model\Listing\AbstractListing; @@ -48,7 +49,7 @@ public function setEntries(?array $entries): static } /** - * @throws \Exception + * @throws Exception */ public function __construct() { diff --git a/bundles/SimpleBackendSearchBundle/src/PimcoreSimpleBackendSearchBundle.php b/bundles/SimpleBackendSearchBundle/src/PimcoreSimpleBackendSearchBundle.php index fd590919b20..25726a7cef0 100644 --- a/bundles/SimpleBackendSearchBundle/src/PimcoreSimpleBackendSearchBundle.php +++ b/bundles/SimpleBackendSearchBundle/src/PimcoreSimpleBackendSearchBundle.php @@ -49,6 +49,6 @@ public function getInstaller(): Installer public function getPath(): string { - return \dirname(__DIR__); + return dirname(__DIR__); } } diff --git a/bundles/StaticRoutesBundle/src/Controller/SettingsController.php b/bundles/StaticRoutesBundle/src/Controller/SettingsController.php index 9202580d4e6..d3c26881e74 100644 --- a/bundles/StaticRoutesBundle/src/Controller/SettingsController.php +++ b/bundles/StaticRoutesBundle/src/Controller/SettingsController.php @@ -35,10 +35,10 @@ class SettingsController extends UserAwareController */ public function staticroutesAction(Request $request): JsonResponse { - if ($request->get('data')) { + if ($request->request->has('data')) { $this->checkPermission('routes'); - $data = $this->decodeJson($request->get('data')); + $data = $this->decodeJson($request->request->getString('data')); if (is_array($data)) { foreach ($data as &$value) { @@ -48,8 +48,7 @@ public function staticroutesAction(Request $request): JsonResponse } } - if ($request->get('xaction') == 'destroy') { - $data = $this->decodeJson($request->get('data')); + if ($request->query->getString('xaction') == 'destroy') { $id = $data['id']; $route = Staticroute::getById($id); if (!$route->isWriteable()) { @@ -58,7 +57,7 @@ public function staticroutesAction(Request $request): JsonResponse $route->delete(); return $this->jsonResponse(['success' => true, 'data' => []]); - } elseif ($request->get('xaction') == 'update') { + } elseif ($request->query->getString('xaction') == 'update') { // save routes $route = Staticroute::getById($data['id']); if (!$route->isWriteable()) { @@ -70,7 +69,7 @@ public function staticroutesAction(Request $request): JsonResponse $route->save(); return $this->jsonResponse(['data' => $route->getObjectVars(), 'success' => true]); - } elseif ($request->get('xaction') == 'create') { + } elseif ($request->query->getString('xaction') == 'create') { if (!(new Staticroute())->isWriteable()) { throw new ConfigWriteException(); } @@ -92,7 +91,7 @@ public function staticroutesAction(Request $request): JsonResponse $list = new Staticroute\Listing(); - if ($filter = $request->get('filter')) { + if ($filter = $request->request->getString('filter')) { $list->setFilter(function (Staticroute $staticRoute) use ($filter) { foreach ($staticRoute->getObjectVars() as $value) { if (!is_scalar($value)) { diff --git a/bundles/StaticRoutesBundle/src/Model/Staticroute.php b/bundles/StaticRoutesBundle/src/Model/Staticroute.php index 4e7a91b2e6f..bc055b59c99 100644 --- a/bundles/StaticRoutesBundle/src/Model/Staticroute.php +++ b/bundles/StaticRoutesBundle/src/Model/Staticroute.php @@ -16,6 +16,8 @@ namespace Pimcore\Bundle\StaticRoutesBundle\Model; +use Exception; +use Pimcore; use Pimcore\Event\FrontendEvents; use Pimcore\Model\AbstractModel; use Pimcore\Model\Exception\NotFoundException; @@ -64,35 +66,24 @@ final class Staticroute extends AbstractModel /** * Associative array filled on match() that holds matched path values * for given variable names. - * */ protected array $_values = []; /** * this is a small per request cache to know which route is which is, this info is used in self::getByName() - * */ protected static array $nameIdMappingCache = []; /** * contains the static route which the current request matches (it he does), this is used in the view to get the current route - * */ protected static ?Staticroute $_currentRoute = null; - /** - * @static - * - */ public static function setCurrentRoute(?Staticroute $route): void { self::$_currentRoute = $route; } - /** - * @static - * - */ public static function getCurrentRoute(): ?Staticroute { return self::$_currentRoute; @@ -100,8 +91,6 @@ public static function getCurrentRoute(): ?Staticroute /** * Static helper to retrieve an instance of Staticroute by the given ID - * - * */ public static function getById(string $id): ?Staticroute { @@ -110,9 +99,9 @@ public static function getById(string $id): ?Staticroute try { $route = \Pimcore\Cache\RuntimeCache::get($cacheKey); if (!$route) { - throw new \Exception('Route in registry is null'); + throw new Exception('Route in registry is null'); } - } catch (\Exception $e) { + } catch (Exception $e) { try { $route = new self(); $route->setId($id); @@ -127,11 +116,9 @@ public static function getById(string $id): ?Staticroute } /** - * - * - * @throws \Exception + * @throws Exception */ - public static function getByName(string $name, int $siteId = null): ?Staticroute + public static function getByName(string $name, ?int $siteId = null): ?Staticroute { $cacheKey = $name . '~~~' . $siteId; @@ -356,7 +343,6 @@ public function getSiteId(): array } /** - * @internal * @internal */ public function assemble(array $urlOptions = [], bool $encode = true): string @@ -370,7 +356,7 @@ public function assemble(array $urlOptions = [], bool $encode = true): string // merge with defaults // merge router.request_context params e.g. "_locale" - $requestParameters = \Pimcore::getContainer()->get('pimcore.routing.router.request_context')->getParameters(); + $requestParameters = Pimcore::getContainer()->get('pimcore.routing.router.request_context')->getParameters(); $urlParams = array_merge($defaultValues, $requestParameters, $urlOptions); $parametersInReversePattern = []; @@ -443,7 +429,7 @@ public function assemble(array $urlOptions = [], bool $encode = true): string 'params' => $urlParams, 'encode' => $encode, ]); - \Pimcore::getEventDispatcher()->dispatch($event, FrontendEvents::STATICROUTE_PATH); + Pimcore::getEventDispatcher()->dispatch($event, FrontendEvents::STATICROUTE_PATH); $url = $event->getArgument('frontendPath'); return $url; @@ -452,7 +438,7 @@ public function assemble(array $urlOptions = [], bool $encode = true): string /** * @internal * - * @throws \Exception + * @throws Exception */ public function match(string $path, array $params = []): false|array { @@ -505,7 +491,7 @@ public function setMethods(array|string $methods): static { if (is_string($methods)) { $methods = strlen($methods) ? explode(',', $methods) : []; - foreach($methods as $key => $method) { + foreach ($methods as $key => $method) { $methods[$key] = trim($method); } } diff --git a/bundles/StaticRoutesBundle/src/Model/Staticroute/Dao.php b/bundles/StaticRoutesBundle/src/Model/Staticroute/Dao.php index d62b69186c7..3f3f706ace0 100644 --- a/bundles/StaticRoutesBundle/src/Model/Staticroute/Dao.php +++ b/bundles/StaticRoutesBundle/src/Model/Staticroute/Dao.php @@ -15,6 +15,8 @@ namespace Pimcore\Bundle\StaticRoutesBundle\Model\Staticroute; +use Exception; +use Pimcore; use Pimcore\Bundle\StaticRoutesBundle\Model\Staticroute; use Pimcore\Model; use Pimcore\Model\Exception\NotFoundException; @@ -31,8 +33,8 @@ class Dao extends Model\Dao\PimcoreLocationAwareConfigDao public function configure(): void { - $config = \Pimcore::getContainer()->getParameter('pimcore_static_routes.config_location'); - $definitions = \Pimcore::getContainer()->getParameter('pimcore_static_routes.definitions'); + $config = Pimcore::getContainer()->getParameter('pimcore_static_routes.config_location'); + $definitions = Pimcore::getContainer()->getParameter('pimcore_static_routes.definitions'); $storageConfig = $config[self::CONFIG_KEY]; @@ -57,7 +59,7 @@ public function delete(): void * * @throws NotFoundException */ - public function getById(string $id = null): void + public function getById(?string $id = null): void { if ($id != null) { $this->model->setId($id); @@ -83,7 +85,7 @@ public function getById(string $id = null): void * * @throws NotFoundException */ - public function getByName(string $name = null, int $siteId = null): void + public function getByName(?string $name = null, ?int $siteId = null): void { if ($name != null) { $this->model->setName($name); @@ -91,8 +93,8 @@ public function getByName(string $name = null, int $siteId = null): void $name = $this->model->getName(); - $totalList = new Listing(); - $totalList = $totalList->load(); + $listing = new Listing(); + $totalList = $listing->load(); $data = array_filter($totalList, function (Staticroute $row) use ($name, $siteId) { if ($row->getName() == $name) { @@ -134,7 +136,7 @@ protected function prepareDataStructureForYaml(string $id, mixed $data): mixed } /** - * @throws \Exception + * @throws Exception */ public function save(): void { diff --git a/bundles/StaticRoutesBundle/src/PimcoreStaticRoutesBundle.php b/bundles/StaticRoutesBundle/src/PimcoreStaticRoutesBundle.php index d0597f727e7..bfc7e431014 100644 --- a/bundles/StaticRoutesBundle/src/PimcoreStaticRoutesBundle.php +++ b/bundles/StaticRoutesBundle/src/PimcoreStaticRoutesBundle.php @@ -48,6 +48,6 @@ public function getInstaller(): Installer public function getPath(): string { - return \dirname(__DIR__); + return dirname(__DIR__); } } diff --git a/bundles/StaticRoutesBundle/src/Routing/Staticroute/Router.php b/bundles/StaticRoutesBundle/src/Routing/Staticroute/Router.php index 0005a5409e0..e7b063a8411 100644 --- a/bundles/StaticRoutesBundle/src/Routing/Staticroute/Router.php +++ b/bundles/StaticRoutesBundle/src/Routing/Staticroute/Router.php @@ -187,14 +187,14 @@ public function match(string $pathinfo): array return $this->doMatch($pathinfo); } - protected function doMatch(string $pathinfo, Request $request = null): array + protected function doMatch(string $pathinfo, ?Request $request = null): array { $pathinfo = urldecode($pathinfo); $params = $this->context->getParameters(); foreach ($this->getStaticRoutes() as $route) { - if (null !== $request && null !== $route->getMethods() && 0 !== count($route->getMethods())) { + if (null !== $request && 0 !== count($route->getMethods())) { $method = $request->getMethod(); if (!in_array($method, $route->getMethods(), true)) { @@ -262,7 +262,6 @@ protected function processRouteParams(array $routeParams): array protected function getStaticRoutes(): array { if (null === $this->staticRoutes) { - /** @var Staticroute\Listing|Staticroute\Listing\Dao $list */ $list = new Staticroute\Listing(); $list->setOrder(function ($a, $b) { diff --git a/bundles/TinymceBundle/README.md b/bundles/TinymceBundle/README.md deleted file mode 100644 index 5d3b21cf4b9..00000000000 --- a/bundles/TinymceBundle/README.md +++ /dev/null @@ -1,118 +0,0 @@ -# Pimcore TinyMCE - - -## General - -TinyMCE bundle provides TineMCE as WYSIWYG-editor. -Similar to Textarea and Input you can use the WYSIWYG editable in the templates to provide rich-text editing. - -## Configuration - -Available configuration options can be found here: [config options](https://www.tiny.cloud/docs/configure/) - -## Examples - -### Basic usage - -`wysiwyg` helper doesn't require any additional configuration options. -The following code add a second toolbar. - -```twig -
- {{ pimcore_wysiwyg("specialContent", { - toolbar2: 'forecolor | h1 | h2' - }) - }} -
-``` -![Wysiwyg with extended toolbar - editmode](./doc/img/editables_wysiwyg_toolbar_editmode.png) - -### Custom configuration for TinyMCE - -The complete list of configuration options you can find in the [TinyMCE toolbar documentation](https://www.tiny.cloud/docs/advanced/available-toolbar-buttons/). - -The WYSIWYG editable allows us to specify the toolbar. -If you have to limit styling options (for example only basic styles like `` tag and lists would be allowed), just use `toolbar1` option. - -```twig -
- {{ pimcore_wysiwyg("specialContent", { - toolbar1: 'forecolor | h1 | h2' - }) - }} -
-``` - -Now the user can use only the limited toolbar. - -##### Global Configuration - -You can add a Global Configuration for all WYSIWYG Editors for all documents by setting `pimcore.document.editables.wysiwyg.defaultEditorConfig`. -You can add a Global Configuration for all WYSIWYG Editors for all data objects by setting `pimcore.object.tags.wysiwyg.defaultEditorConfig`. - -For this purpose, you can create a [Pimcore Bundle](https://pimcore.com/docs/pimcore/current/Development_Documentation/Extending_Pimcore/Bundle_Developers_Guide/index.html) and add the -configuration in a file in the `Resources/public` directory of your bundle (e.g. `Resources/public/js/editmode.js`). - -``` -pimcore.document.editables.wysiwyg = pimcore.document.editables.wysiwyg || {}; -pimcore.document.editables.wysiwyg.defaultEditorConfig = { menubar: true }; -``` - -This will show you the default menubar from TinyMCE in all editables. - -To load that file in editmode, you need to implement `getEditmodeJsPaths` in your bundle class. Given your bundle is named -`AppAdminBundle` and your `editmode.js` created before was saved to `src/AppAdminBundle/public/js/editmode.js`: - -```php - 'onEditmodeJsPaths' - ]; - } - - public function onEditmodeJsPaths(PathsEvent $event) - { - $event->setPaths(array_merge($event->getPaths(), [ - '/bundles/app/js/pimcore/editmode.js' - ])); - } -} -``` diff --git a/bundles/TinymceBundle/config/services.yaml b/bundles/TinymceBundle/config/services.yaml deleted file mode 100644 index 3baf5f519b7..00000000000 --- a/bundles/TinymceBundle/config/services.yaml +++ /dev/null @@ -1,14 +0,0 @@ -services: - _defaults: - autowire: true - autoconfigure: true - - # - # INSTALLER - # - - Pimcore\Bundle\TinymceBundle\Installer: - public: true - arguments: - $bundle: "@=service('kernel').getBundle('PimcoreTinymceBundle')" - diff --git a/bundles/TinymceBundle/doc/img/editables_wysiwyg_toolbar_editmode.png b/bundles/TinymceBundle/doc/img/editables_wysiwyg_toolbar_editmode.png deleted file mode 100644 index 91d18fdd00a..00000000000 Binary files a/bundles/TinymceBundle/doc/img/editables_wysiwyg_toolbar_editmode.png and /dev/null differ diff --git a/bundles/TinymceBundle/package.json b/bundles/TinymceBundle/package.json deleted file mode 100644 index 72969b52dbc..00000000000 --- a/bundles/TinymceBundle/package.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "devDependencies": { - "@symfony/webpack-encore": "^4.5.0", - "file-loader": "^6.2.0", - "webpack-notifier": "^1.15.0" - }, - "scripts": { - "dev-server": "encore dev-server", - "dev": "encore dev", - "watch": "encore dev --watch", - "build": "encore production --progress" - }, - "dependencies": { - "tinymce": "^6.7.2" - } -} diff --git a/bundles/TinymceBundle/public/assets/tinymce.js b/bundles/TinymceBundle/public/assets/tinymce.js deleted file mode 100644 index 1443e641174..00000000000 --- a/bundles/TinymceBundle/public/assets/tinymce.js +++ /dev/null @@ -1,19 +0,0 @@ -import * as tinymce from "tinymce"; - -import 'tinymce/models/dom'; -import 'tinymce/icons/default'; - -// A theme is also required -import 'tinymce/themes/silver'; - -// Any plugins you want to use has to be imported -import 'tinymce/plugins/link'; -import 'tinymce/plugins/table'; -import 'tinymce/plugins/wordcount'; -import 'tinymce/plugins/autolink'; -import 'tinymce/plugins/image'; -import 'tinymce/plugins/insertdatetime'; -import 'tinymce/plugins/media'; -import 'tinymce/plugins/help'; -import 'tinymce/plugins/lists'; -import 'tinymce/plugins/code'; \ No newline at end of file diff --git a/bundles/TinymceBundle/public/build/tinymce/271.js b/bundles/TinymceBundle/public/build/tinymce/271.js deleted file mode 100644 index c5049506736..00000000000 --- a/bundles/TinymceBundle/public/build/tinymce/271.js +++ /dev/null @@ -1 +0,0 @@ -(self.webpackChunk=self.webpackChunk||[]).push([[271],{8785:()=>{tinymce.IconManager.add("default",{icons:{"accessibility-check":'',"accordion-toggle":'',accordion:'',"action-next":'',"action-prev":'',addtag:'',"ai-prompt":'',ai:'',"align-center":'',"align-justify":'',"align-left":'',"align-none":'',"align-right":'',"arrow-left":'',"arrow-right":'',bold:'',bookmark:'',"border-style":'',"border-width":'',brightness:'',browse:'',cancel:'',"cell-background-color":'',"cell-border-color":'',"change-case":'',"character-count":'',"checklist-rtl":'',checklist:'',checkmark:'',"chevron-down":'',"chevron-left":'',"chevron-right":'',"chevron-up":'',close:'',"code-sample":'',"color-levels":'',"color-picker":'',"color-swatch-remove-color":'',"color-swatch":'',"comment-add":'',comment:'',contrast:'',copy:'',crop:'',"cut-column":'',"cut-row":'',cut:'',"document-properties":'',drag:'',"duplicate-column":'',"duplicate-row":'',duplicate:'',"edit-block":'',"edit-image":'',"embed-page":'',embed:'',emoji:'',export:'',fill:'',"flip-horizontally":'',"flip-vertically":'',footnote:'',"format-painter":'',format:'',fullscreen:'',gallery:'',gamma:'',help:'',"highlight-bg-color":'',home:'',"horizontal-rule":'',"image-options":'',image:'',indent:'',info:'',"insert-character":'',"insert-time":'',invert:'',italic:'',language:'',"line-height":'',line:'',link:'',"list-bull-circle":'',"list-bull-default":'',"list-bull-square":'',"list-num-default-rtl":'',"list-num-default":'',"list-num-lower-alpha-rtl":'',"list-num-lower-alpha":'',"list-num-lower-greek-rtl":'',"list-num-lower-greek":'',"list-num-lower-roman-rtl":'',"list-num-lower-roman":'',"list-num-upper-alpha-rtl":'',"list-num-upper-alpha":'',"list-num-upper-roman-rtl":'',"list-num-upper-roman":'',lock:'',ltr:'',minus:'',"more-drawer":'',"new-document":'',"new-tab":'',"non-breaking":'',notice:'',"ordered-list-rtl":'',"ordered-list":'',orientation:'',outdent:'',"page-break":'',paragraph:'',"paste-column-after":'',"paste-column-before":'',"paste-row-after":'',"paste-row-before":'',"paste-text":'',paste:'',"permanent-pen":'',plus:'',preferences:'',preview:'',print:'',quote:'',redo:'',reload:'',"remove-formatting":'',remove:'',"resize-handle":'',resize:'',"restore-draft":'',"rotate-left":'',"rotate-right":'',rtl:'',save:'',search:'',"select-all":'',selected:'',send:'',settings:'',sharpen:'',sourcecode:'',"spell-check":'',"strike-through":'',subscript:'',superscript:'',"table-caption":'',"table-cell-classes":'',"table-cell-properties":'',"table-cell-select-all":'',"table-cell-select-inner":'',"table-classes":'',"table-delete-column":'',"table-delete-row":'',"table-delete-table":'',"table-insert-column-after":'',"table-insert-column-before":'',"table-insert-row-above":'',"table-insert-row-after":'',"table-left-header":'',"table-merge-cells":'',"table-row-numbering-rtl":'',"table-row-numbering":'',"table-row-properties":'',"table-split-cells":'',"table-top-header":'',table:'',"template-add":'',template:'',"temporary-placeholder":'',"text-color":'',"text-size-decrease":'',"text-size-increase":'',toc:'',translate:'',typography:'',underline:'',undo:'',unlink:'',unlock:'',"unordered-list":'',unselected:'',upload:'',user:'',"vertical-align":'',visualblocks:'',visualchars:'',warning:'',"zoom-in":'',"zoom-out":''}})},6890:(e,t,o)=>{o(8785)},7490:(e,t,o)=>{o(3557)},3557:()=>{!function(){"use strict";var e=tinymce.util.Tools.resolve("tinymce.ModelManager");const t=e=>t=>(e=>{const t=typeof e;return null===e?"null":"object"===t&&Array.isArray(e)?"array":"object"===t&&(o=r=e,n=(s=String).prototype,n.isPrototypeOf(o)||(null===(a=r.constructor)||void 0===a?void 0:a.name)===s.name)?"string":t;var o,n;var r,s,a})(t)===e,o=e=>t=>typeof t===e,n=e=>t=>e===t,r=t("string"),s=t("object"),a=t("array"),i=n(null),l=o("boolean"),c=n(void 0),d=e=>!(e=>null==e)(e),m=o("function"),u=o("number"),g=()=>{},p=e=>()=>e,h=e=>e,f=(e,t)=>e===t;function b(e,...t){return(...o)=>{const n=t.concat(o);return e.apply(null,n)}}const v=e=>t=>!e(t),y=e=>e(),w=p(!1),x=p(!0);class C{constructor(e,t){this.tag=e,this.value=t}static some(e){return new C(!0,e)}static none(){return C.singletonNone}fold(e,t){return this.tag?t(this.value):e()}isSome(){return this.tag}isNone(){return!this.tag}map(e){return this.tag?C.some(e(this.value)):C.none()}bind(e){return this.tag?e(this.value):C.none()}exists(e){return this.tag&&e(this.value)}forall(e){return!this.tag||e(this.value)}filter(e){return!this.tag||e(this.value)?this:C.none()}getOr(e){return this.tag?this.value:e}or(e){return this.tag?this:e}getOrThunk(e){return this.tag?this.value:e()}orThunk(e){return this.tag?this:e()}getOrDie(e){if(this.tag)return this.value;throw new Error(null!=e?e:"Called getOrDie on None")}static from(e){return d(e)?C.some(e):C.none()}getOrNull(){return this.tag?this.value:null}getOrUndefined(){return this.value}each(e){this.tag&&e(this.value)}toArray(){return this.tag?[this.value]:[]}toString(){return this.tag?`some(${this.value})`:"none()"}}C.singletonNone=new C(!1);const S=Array.prototype.slice,k=Array.prototype.indexOf,_=Array.prototype.push,O=(e,t)=>{return o=e,n=t,k.call(o,n)>-1;var o,n},T=(e,t)=>{for(let o=0,n=e.length;o{const o=[];for(let n=0;n{const o=e.length,n=new Array(o);for(let r=0;r{for(let o=0,n=e.length;o{const o=[],n=[];for(let r=0,s=e.length;r{const o=[];for(let n=0,r=e.length;n(((e,t)=>{for(let o=e.length-1;o>=0;o--)t(e[o],o)})(e,((e,n)=>{o=t(o,e,n)})),o),B=(e,t,o)=>(A(e,((e,n)=>{o=t(o,e,n)})),o),L=(e,t)=>((e,t,o)=>{for(let n=0,r=e.length;n{for(let o=0,n=e.length;o{const t=[];for(let o=0,n=e.length;oI(D(e,t)),F=(e,t)=>{for(let o=0,n=e.length;o{const o={};for(let n=0,r=e.length;nt>=0&&tV(e,0),U=e=>V(e,e.length-1),j=(e,t)=>{for(let o=0;o{const o=$(e);for(let n=0,r=o.length;nK(e,((e,o)=>({k:o,v:t(e,o)}))),K=(e,t)=>{const o={};return q(e,((e,n)=>{const r=t(e,n);o[r.k]=r.v})),o},Y=(e,t)=>{const o={};return((e,t,o,n)=>{q(e,((e,r)=>{(t(e,r)?o:n)(e,r)}))})(e,t,(e=>(t,o)=>{e[o]=t})(o),g),o},X=(e,t)=>{const o=[];return q(e,((e,n)=>{o.push(t(e,n))})),o},J=e=>X(e,h),Q=(e,t)=>W.call(e,t),ee="undefined"!=typeof window?window:Function("return this;")(),te=(e,t)=>((e,t)=>{let o=null!=t?t:ee;for(let t=0;t{const o=((e,t)=>te(e,t))(e,t);if(null==o)throw new Error(e+" not available on this browser");return o},ne=Object.getPrototypeOf,re=e=>{const t=te("ownerDocument.defaultView",e);return s(e)&&((e=>oe("HTMLElement",e))(t).prototype.isPrototypeOf(e)||/^HTML\w*Element$/.test(ne(e).constructor.name))},se=e=>e.dom.nodeName.toLowerCase(),ae=e=>e.dom.nodeType,ie=e=>t=>ae(t)===e,le=e=>8===ae(e)||"#comment"===se(e),ce=e=>de(e)&&re(e.dom),de=ie(1),me=ie(3),ue=ie(9),ge=ie(11),pe=e=>t=>de(t)&&se(t)===e,he=(e,t,o)=>{if(!(r(o)||l(o)||u(o)))throw console.error("Invalid call to Attribute.set. Key ",t,":: Value ",o,":: Element ",e),new Error("Attribute value was not simple");e.setAttribute(t,o+"")},fe=(e,t,o)=>{he(e.dom,t,o)},be=(e,t)=>{const o=e.dom;q(t,((e,t)=>{he(o,t,e)}))},ve=(e,t)=>{const o=e.dom.getAttribute(t);return null===o?void 0:o},ye=(e,t)=>C.from(ve(e,t)),we=(e,t)=>{e.dom.removeAttribute(t)},xe=e=>B(e.dom.attributes,((e,t)=>(e[t.name]=t.value,e)),{}),Ce=e=>{if(null==e)throw new Error("Node cannot be null or undefined");return{dom:e}},Se={fromHtml:(e,t)=>{const o=(t||document).createElement("div");if(o.innerHTML=e,!o.hasChildNodes()||o.childNodes.length>1){const t="HTML does not have a single root node";throw console.error(t,e),new Error(t)}return Ce(o.childNodes[0])},fromTag:(e,t)=>{const o=(t||document).createElement(e);return Ce(o)},fromText:(e,t)=>{const o=(t||document).createTextNode(e);return Ce(o)},fromDom:Ce,fromPoint:(e,t,o)=>C.from(e.dom.elementFromPoint(t,o)).map(Ce)},ke=(e,t)=>{const o=e.dom;if(1!==o.nodeType)return!1;{const e=o;if(void 0!==e.matches)return e.matches(t);if(void 0!==e.msMatchesSelector)return e.msMatchesSelector(t);if(void 0!==e.webkitMatchesSelector)return e.webkitMatchesSelector(t);if(void 0!==e.mozMatchesSelector)return e.mozMatchesSelector(t);throw new Error("Browser lacks native selectors")}},_e=e=>1!==e.nodeType&&9!==e.nodeType&&11!==e.nodeType||0===e.childElementCount,Oe=(e,t)=>{const o=void 0===t?document:t.dom;return _e(o)?C.none():C.from(o.querySelector(e)).map(Se.fromDom)},Te=(e,t)=>e.dom===t.dom,Ee=(e,t)=>{const o=e.dom,n=t.dom;return o!==n&&o.contains(n)},De=ke,Ae=e=>Se.fromDom(e.dom.ownerDocument),Me=e=>ue(e)?e:Ae(e),Ne=e=>C.from(e.dom.parentNode).map(Se.fromDom),Re=e=>C.from(e.dom.parentElement).map(Se.fromDom),Be=(e,t)=>{const o=m(t)?t:w;let n=e.dom;const r=[];for(;null!==n.parentNode&&void 0!==n.parentNode;){const e=n.parentNode,t=Se.fromDom(e);if(r.push(t),!0===o(t))break;n=e}return r},Le=e=>C.from(e.dom.previousSibling).map(Se.fromDom),He=e=>C.from(e.dom.nextSibling).map(Se.fromDom),Ie=e=>D(e.dom.childNodes,Se.fromDom),Pe=(e,t)=>{const o=e.dom.childNodes;return C.from(o[t]).map(Se.fromDom)},Fe=(e,t)=>{Ne(e).each((o=>{o.dom.insertBefore(t.dom,e.dom)}))},ze=(e,t)=>{He(e).fold((()=>{Ne(e).each((e=>{Ze(e,t)}))}),(e=>{Fe(e,t)}))},Ve=(e,t)=>{const o=(e=>Pe(e,0))(e);o.fold((()=>{Ze(e,t)}),(o=>{e.dom.insertBefore(t.dom,o.dom)}))},Ze=(e,t)=>{e.dom.appendChild(t.dom)},Ue=(e,t)=>{Fe(e,t),Ze(t,e)},je=(e,t)=>{A(t,((o,n)=>{const r=0===n?e:t[n-1];ze(r,o)}))},$e=(e,t)=>{A(t,(t=>{Ze(e,t)}))},We=e=>{e.dom.textContent="",A(Ie(e),(e=>{qe(e)}))},qe=e=>{const t=e.dom;null!==t.parentNode&&t.parentNode.removeChild(t)},Ge=e=>{const t=Ie(e);t.length>0&&je(e,t),qe(e)},Ke=(e,t)=>Se.fromDom(e.dom.cloneNode(t)),Ye=e=>Ke(e,!1),Xe=e=>Ke(e,!0),Je=(e,t)=>{const o=Se.fromTag(t),n=xe(e);return be(o,n),o},Qe=["tfoot","thead","tbody","colgroup"],et=(e,t,o)=>({element:e,rowspan:t,colspan:o}),tt=(e,t,o)=>({element:e,cells:t,section:o}),ot=(e,t,o)=>({element:e,isNew:t,isLocked:o}),nt=(e,t,o,n)=>({element:e,cells:t,section:o,isNew:n}),rt=m(Element.prototype.attachShadow)&&m(Node.prototype.getRootNode),st=p(rt),at=rt?e=>Se.fromDom(e.dom.getRootNode()):Me,it=e=>{const t=at(e);return ge(o=t)&&d(o.dom.host)?C.some(t):C.none();var o},lt=e=>Se.fromDom(e.dom.host),ct=e=>d(e.dom.shadowRoot),dt=e=>{const t=me(e)?e.dom.parentNode:e.dom;if(null==t||null===t.ownerDocument)return!1;const o=t.ownerDocument;return it(Se.fromDom(t)).fold((()=>o.body.contains(t)),(n=dt,r=lt,e=>n(r(e))));var n,r},mt=e=>{const t=e.dom.body;if(null==t)throw new Error("Body is not available yet");return Se.fromDom(t)},ut=(e,t)=>{let o=[];return A(Ie(e),(e=>{t(e)&&(o=o.concat([e])),o=o.concat(ut(e,t))})),o},gt=(e,t,o)=>((e,t,o)=>N(Be(e,o),t))(e,(e=>ke(e,t)),o),pt=(e,t)=>((e,t)=>N(Ie(e),t))(e,(e=>ke(e,t))),ht=(e,t)=>((e,t)=>{const o=void 0===t?document:t.dom;return _e(o)?[]:D(o.querySelectorAll(e),Se.fromDom)})(t,e);var ft=(e,t,o,n,r)=>e(o,n)?C.some(o):m(r)&&r(o)?C.none():t(o,n,r);const bt=(e,t,o)=>{let n=e.dom;const r=m(o)?o:w;for(;n.parentNode;){n=n.parentNode;const e=Se.fromDom(n);if(t(e))return C.some(e);if(r(e))break}return C.none()},vt=(e,t,o)=>ft(((e,t)=>t(e)),bt,e,t,o),yt=(e,t,o)=>bt(e,(e=>ke(e,t)),o),wt=(e,t)=>((e,t)=>L(e.dom.childNodes,(e=>t(Se.fromDom(e)))).map(Se.fromDom))(e,(e=>ke(e,t))),xt=(e,t)=>Oe(t,e),Ct=(e,t,o)=>ft(((e,t)=>ke(e,t)),yt,e,t,o),St=(e,t,o=f)=>e.exists((e=>o(e,t))),kt=e=>{const t=[],o=e=>{t.push(e)};for(let t=0;te?C.some(t):C.none(),Ot=(e,t,o)=>""===t||e.length>=t.length&&e.substr(o,o+t.length)===t,Tt=(e,t,o=0,n)=>{const r=e.indexOf(t,o);return-1!==r&&(!!c(n)||r+t.length<=n)},Et=(e,t)=>Ot(e,t,0),Dt=(e,t)=>Ot(e,t,e.length-t.length),At=(e=>t=>t.replace(e,""))(/^\s+|\s+$/g),Mt=e=>e.length>0,Nt=e=>void 0!==e.style&&m(e.style.getPropertyValue),Rt=(e,t,o)=>{if(!r(o))throw console.error("Invalid call to CSS.set. Property ",t,":: Value ",o,":: Element ",e),new Error("CSS value must be a string: "+o);Nt(e)&&e.style.setProperty(t,o)},Bt=(e,t,o)=>{const n=e.dom;Rt(n,t,o)},Lt=(e,t)=>{const o=e.dom;q(t,((e,t)=>{Rt(o,t,e)}))},Ht=(e,t)=>{const o=e.dom,n=window.getComputedStyle(o).getPropertyValue(t);return""!==n||dt(e)?n:It(o,t)},It=(e,t)=>Nt(e)?e.style.getPropertyValue(t):"",Pt=(e,t)=>{const o=e.dom,n=It(o,t);return C.from(n).filter((e=>e.length>0))},Ft=(e,t)=>{((e,t)=>{Nt(e)&&e.style.removeProperty(t)})(e.dom,t),St(ye(e,"style").map(At),"")&&we(e,"style")},zt=(e,t,o=0)=>ye(e,t).map((e=>parseInt(e,10))).getOr(o),Vt=(e,t)=>zt(e,t,1),Zt=e=>pe("col")(e)?zt(e,"span",1)>1:Vt(e,"colspan")>1,Ut=e=>Vt(e,"rowspan")>1,jt=(e,t)=>parseInt(Ht(e,t),10),$t=p(10),Wt=p(10),qt=(e,t)=>Gt(e,t,x),Gt=(e,t,o)=>P(Ie(e),(e=>ke(e,t)?o(e)?[e]:[]:Gt(e,t,o))),Kt=(e,t)=>((e,t,o=w)=>o(t)?C.none():O(e,se(t))?C.some(t):yt(t,e.join(","),(e=>ke(e,"table")||o(e))))(["td","th"],e,t),Yt=e=>qt(e,"th,td"),Xt=e=>ke(e,"colgroup")?pt(e,"col"):P(eo(e),(e=>pt(e,"col"))),Jt=(e,t)=>Ct(e,"table",t),Qt=e=>qt(e,"tr"),eo=e=>Jt(e).fold(p([]),(e=>pt(e,"colgroup"))),to=(e,t)=>D(e,(e=>{if("colgroup"===se(e)){const t=D(Xt(e),(e=>{const t=zt(e,"span",1);return et(e,1,t)}));return tt(e,t,"colgroup")}{const o=D(Yt(e),(e=>{const t=zt(e,"rowspan",1),o=zt(e,"colspan",1);return et(e,t,o)}));return tt(e,o,t(e))}})),oo=e=>Ne(e).map((e=>{const t=se(e);return(e=>O(Qe,e))(t)?t:"tbody"})).getOr("tbody"),no=e=>{const t=Qt(e),o=[...eo(e),...t];return to(o,oo)},ro=e=>{let t,o=!1;return(...n)=>(o||(o=!0,t=e.apply(null,n)),t)},so=()=>ao(0,0),ao=(e,t)=>({major:e,minor:t}),io={nu:ao,detect:(e,t)=>{const o=String(t).toLowerCase();return 0===e.length?so():((e,t)=>{const o=((e,t)=>{for(let o=0;oNumber(t.replace(o,"$"+e));return ao(n(1),n(2))})(e,o)},unknown:so},lo=(e,t)=>{const o=String(t).toLowerCase();return L(e,(e=>e.search(o)))},co=/.*?version\/\ ?([0-9]+)\.([0-9]+).*/,mo=e=>t=>Tt(t,e),uo=[{name:"Edge",versionRegexes:[/.*?edge\/ ?([0-9]+)\.([0-9]+)$/],search:e=>Tt(e,"edge/")&&Tt(e,"chrome")&&Tt(e,"safari")&&Tt(e,"applewebkit")},{name:"Chromium",brand:"Chromium",versionRegexes:[/.*?chrome\/([0-9]+)\.([0-9]+).*/,co],search:e=>Tt(e,"chrome")&&!Tt(e,"chromeframe")},{name:"IE",versionRegexes:[/.*?msie\ ?([0-9]+)\.([0-9]+).*/,/.*?rv:([0-9]+)\.([0-9]+).*/],search:e=>Tt(e,"msie")||Tt(e,"trident")},{name:"Opera",versionRegexes:[co,/.*?opera\/([0-9]+)\.([0-9]+).*/],search:mo("opera")},{name:"Firefox",versionRegexes:[/.*?firefox\/\ ?([0-9]+)\.([0-9]+).*/],search:mo("firefox")},{name:"Safari",versionRegexes:[co,/.*?cpu os ([0-9]+)_([0-9]+).*/],search:e=>(Tt(e,"safari")||Tt(e,"mobile/"))&&Tt(e,"applewebkit")}],go=[{name:"Windows",search:mo("win"),versionRegexes:[/.*?windows\ nt\ ?([0-9]+)\.([0-9]+).*/]},{name:"iOS",search:e=>Tt(e,"iphone")||Tt(e,"ipad"),versionRegexes:[/.*?version\/\ ?([0-9]+)\.([0-9]+).*/,/.*cpu os ([0-9]+)_([0-9]+).*/,/.*cpu iphone os ([0-9]+)_([0-9]+).*/]},{name:"Android",search:mo("android"),versionRegexes:[/.*?android\ ?([0-9]+)\.([0-9]+).*/]},{name:"macOS",search:mo("mac os x"),versionRegexes:[/.*?mac\ os\ x\ ?([0-9]+)_([0-9]+).*/]},{name:"Linux",search:mo("linux"),versionRegexes:[]},{name:"Solaris",search:mo("sunos"),versionRegexes:[]},{name:"FreeBSD",search:mo("freebsd"),versionRegexes:[]},{name:"ChromeOS",search:mo("cros"),versionRegexes:[/.*?chrome\/([0-9]+)\.([0-9]+).*/]}],po={browsers:p(uo),oses:p(go)},ho="Edge",fo="Chromium",bo="Opera",vo="Firefox",yo="Safari",wo=e=>{const t=e.current,o=e.version,n=e=>()=>t===e;return{current:t,version:o,isEdge:n(ho),isChromium:n(fo),isIE:n("IE"),isOpera:n(bo),isFirefox:n(vo),isSafari:n(yo)}},xo={unknown:()=>wo({current:void 0,version:io.unknown()}),nu:wo,edge:p(ho),chromium:p(fo),ie:p("IE"),opera:p(bo),firefox:p(vo),safari:p(yo)},Co="Windows",So="Android",ko="Linux",_o="macOS",Oo="Solaris",To="FreeBSD",Eo="ChromeOS",Do=e=>{const t=e.current,o=e.version,n=e=>()=>t===e;return{current:t,version:o,isWindows:n(Co),isiOS:n("iOS"),isAndroid:n(So),isMacOS:n(_o),isLinux:n(ko),isSolaris:n(Oo),isFreeBSD:n(To),isChromeOS:n(Eo)}},Ao={unknown:()=>Do({current:void 0,version:io.unknown()}),nu:Do,windows:p(Co),ios:p("iOS"),android:p(So),linux:p(ko),macos:p(_o),solaris:p(Oo),freebsd:p(To),chromeos:p(Eo)},Mo=(e,t,o)=>{const n=po.browsers(),r=po.oses(),s=t.bind((e=>((e,t)=>j(t.brands,(t=>{const o=t.brand.toLowerCase();return L(e,(e=>{var t;return o===(null===(t=e.brand)||void 0===t?void 0:t.toLowerCase())})).map((e=>({current:e.name,version:io.nu(parseInt(t.version,10),0)})))})))(n,e))).orThunk((()=>((e,t)=>lo(e,t).map((e=>{const o=io.detect(e.versionRegexes,t);return{current:e.name,version:o}})))(n,e))).fold(xo.unknown,xo.nu),a=((e,t)=>lo(e,t).map((e=>{const o=io.detect(e.versionRegexes,t);return{current:e.name,version:o}})))(r,e).fold(Ao.unknown,Ao.nu),i=((e,t,o,n)=>{const r=e.isiOS()&&!0===/ipad/i.test(o),s=e.isiOS()&&!r,a=e.isiOS()||e.isAndroid(),i=a||n("(pointer:coarse)"),l=r||!s&&a&&n("(min-device-width:768px)"),c=s||a&&!l,d=t.isSafari()&&e.isiOS()&&!1===/safari/i.test(o),m=!c&&!l&&!d;return{isiPad:p(r),isiPhone:p(s),isTablet:p(l),isPhone:p(c),isTouch:p(i),isAndroid:e.isAndroid,isiOS:e.isiOS,isWebView:p(d),isDesktop:p(m)}})(a,s,e,o);return{browser:s,os:a,deviceType:i}},No=e=>window.matchMedia(e).matches;let Ro=ro((()=>Mo(navigator.userAgent,C.from(navigator.userAgentData),No)));const Bo=()=>Ro(),Lo=(e,t)=>{const o=o=>{const n=t(o);if(n<=0||null===n){const t=Ht(o,e);return parseFloat(t)||0}return n},n=(e,t)=>B(t,((t,o)=>{const n=Ht(e,o),r=void 0===n?0:parseInt(n,10);return isNaN(r)?t:t+r}),0);return{set:(t,o)=>{if(!u(o)&&!o.match(/^[0-9]+$/))throw new Error(e+".set accepts only positive integer values. Value was "+o);const n=t.dom;Nt(n)&&(n.style[e]=o+"px")},get:o,getOuter:o,aggregate:n,max:(e,t,o)=>{const r=n(e,o);return t>r?t-r:0}}},Ho=(e,t)=>(e=>{const t=parseFloat(e);return isNaN(t)?C.none():C.some(t)})(e).getOr(t),Io=(e,t,o)=>Ho(Ht(e,t),o),Po=(e,t)=>{const o=e.dom,n=o.getBoundingClientRect().width||o.offsetWidth;return"border-box"===t?n:((e,t,o,n)=>t-Io(e,`padding-${o}`,0)-Io(e,`padding-${n}`,0)-Io(e,`border-${o}-width`,0)-Io(e,`border-${n}-width`,0))(e,n,"left","right")},Fo=Lo("width",(e=>e.dom.offsetWidth)),zo=e=>Fo.get(e),Vo=e=>Fo.getOuter(e),Zo=e=>Po(e,"content-box"),Uo=e=>Io(e,"width",e.dom.offsetWidth),jo=(e,t,o)=>{const n=e.cells,r=n.slice(0,t),s=n.slice(t),a=r.concat(o).concat(s);return qo(e,a)},$o=(e,t,o)=>jo(e,t,[o]),Wo=(e,t,o)=>{e.cells[t]=o},qo=(e,t)=>nt(e.element,t,e.section,e.isNew),Go=(e,t)=>e.cells[t],Ko=(e,t)=>Go(e,t).element,Yo=e=>e.cells.length,Xo=e=>{const t=M(e,(e=>"colgroup"===e.section));return{rows:t.fail,cols:t.pass}},Jo=(e,t,o)=>{const n=D(e.cells,o);return nt(t(e.element),n,e.section,!0)},Qo="data-snooker-locked-cols",en=e=>ye(e,Qo).bind((e=>C.from(e.match(/\d+/g)))).map((e=>z(e,x))),tn=e=>{const t=B(Xo(e).rows,((e,t)=>(A(t.cells,((t,o)=>{t.isLocked&&(e[o]=!0)})),e)),{}),o=X(t,((e,t)=>parseInt(t,10)));return((e,t)=>{const o=S.call(e,0);return o.sort(t),o})(o)},on=(e,t)=>e+","+t,nn=(e,t)=>{const o=P(e.all,(e=>e.cells));return N(o,t)},rn=e=>{const t={},o=[],n=Z(e).map((e=>e.element)).bind(Jt).bind(en).getOr({});let r=0,s=0,a=0;const{pass:i,fail:l}=M(e,(e=>"colgroup"===e.section));A(l,(e=>{const i=[];A(e.cells,(e=>{let o=0;for(;void 0!==t[on(a,o)];)o++;const r=((e,t)=>Q(e,t)&&void 0!==e[t]&&null!==e[t])(n,o.toString()),l=((e,t,o,n,r,s)=>({element:e,rowspan:t,colspan:o,row:n,column:r,isLocked:s}))(e.element,e.rowspan,e.colspan,a,o,r);for(let n=0;n{const t=(e=>{const t={};let o=0;return A(e.cells,(e=>{const n=e.colspan;E(n,(r=>{const s=o+r;t[s]=((e,t,o)=>({element:e,colspan:t,column:o}))(e.element,n,s)})),o+=n})),t})(e),o=((e,t)=>({element:e,columns:t}))(e.element,J(t));return{colgroups:[o],columns:t}})).getOrThunk((()=>({colgroups:[],columns:{}}))),m=((e,t)=>({rows:e,columns:t}))(r,s);return{grid:m,access:t,all:o,columns:c,colgroups:d}},sn={fromTable:e=>{const t=no(e);return rn(t)},generate:rn,getAt:(e,t,o)=>C.from(e.access[on(t,o)]),findItem:(e,t,o)=>{const n=nn(e,(e=>o(t,e.element)));return n.length>0?C.some(n[0]):C.none()},filterItems:nn,justCells:e=>P(e.all,(e=>e.cells)),justColumns:e=>J(e.columns),hasColumns:e=>$(e.columns).length>0,getColumnAt:(e,t)=>C.from(e.columns[t])},an=(e,t=x)=>{const o=e.grid,n=E(o.columns,h),r=E(o.rows,h);return D(n,(o=>ln((()=>P(r,(t=>sn.getAt(e,t,o).filter((e=>e.column===o)).toArray()))),(e=>1===e.colspan&&t(e.element)),(()=>sn.getAt(e,0,o)))))},ln=(e,t,o)=>{const n=e();return L(n,t).orThunk((()=>C.from(n[0]).orThunk(o))).map((e=>e.element))},cn=e=>{const t=e.grid,o=E(t.rows,h),n=E(t.columns,h);return D(o,(t=>ln((()=>P(n,(o=>sn.getAt(e,t,o).filter((e=>e.row===t)).fold(p([]),(e=>[e]))))),(e=>1===e.rowspan),(()=>sn.getAt(e,t,0)))))},dn=(e,t)=>{if(t<0||t>=e.length-1)return C.none();const o=e[t].fold((()=>{const o=(e=>{const t=S.call(e,0);return t.reverse(),t})(e.slice(0,t));return j(o,((e,t)=>e.map((e=>({value:e,delta:t+1})))))}),(e=>C.some({value:e,delta:0}))),n=e[t+1].fold((()=>{const o=e.slice(t+1);return j(o,((e,t)=>e.map((e=>({value:e,delta:t+1})))))}),(e=>C.some({value:e,delta:1})));return o.bind((e=>n.map((t=>{const o=t.delta+e.delta;return Math.abs(t.value-e.value)/o}))))},mn=(e,t)=>o=>"rtl"===un(o)?t:e,un=e=>"rtl"===Ht(e,"direction")?"rtl":"ltr",gn=Lo("height",(e=>{const t=e.dom;return dt(e)?t.getBoundingClientRect().height:t.offsetHeight})),pn=e=>gn.get(e),hn=e=>gn.getOuter(e),fn=e=>Io(e,"height",e.dom.offsetHeight),bn=(e,t)=>({left:e,top:t,translate:(o,n)=>bn(e+o,t+n)}),vn=bn,yn=(e,t)=>void 0!==e?e:void 0!==t?t:0,wn=e=>{const t=e.dom.ownerDocument,o=t.body,n=t.defaultView,r=t.documentElement;if(o===e.dom)return vn(o.offsetLeft,o.offsetTop);const s=yn(null==n?void 0:n.pageYOffset,r.scrollTop),a=yn(null==n?void 0:n.pageXOffset,r.scrollLeft),i=yn(r.clientTop,o.clientTop),l=yn(r.clientLeft,o.clientLeft);return xn(e).translate(a-l,s-i)},xn=e=>{const t=e.dom,o=t.ownerDocument.body;return o===t?vn(o.offsetLeft,o.offsetTop):dt(e)?(e=>{const t=e.getBoundingClientRect();return vn(t.left,t.top)})(t):vn(0,0)},Cn=(e,t)=>({row:e,y:t}),Sn=(e,t)=>({col:e,x:t}),kn=e=>wn(e).left+Vo(e),_n=e=>wn(e).left,On=(e,t)=>Sn(e,_n(t)),Tn=(e,t)=>Sn(e,kn(t)),En=e=>wn(e).top,Dn=(e,t)=>Cn(e,En(t)),An=(e,t)=>Cn(e,En(t)+hn(t)),Mn=(e,t,o)=>{if(0===o.length)return[];const n=D(o.slice(1),((t,o)=>t.map((t=>e(o,t))))),r=o[o.length-1].map((e=>t(o.length-1,e)));return n.concat([r])},Nn={delta:h,positions:e=>Mn(Dn,An,e),edge:En},Rn=mn({delta:h,edge:_n,positions:e=>Mn(On,Tn,e)},{delta:e=>-e,edge:kn,positions:e=>Mn(Tn,On,e)}),Bn={delta:(e,t)=>Rn(t).delta(e,t),positions:(e,t)=>Rn(t).positions(e,t),edge:e=>Rn(e).edge(e)},Ln={unsupportedLength:["em","ex","cap","ch","ic","rem","lh","rlh","vw","vh","vi","vb","vmin","vmax","cm","mm","Q","in","pc","pt","px"],fixed:["px","pt"],relative:["%"],empty:[""]},Hn=(()=>{const e="[0-9]+",t="[eE]"+("[+-]?"+e),o=e=>`(?:${e})?`,n=["Infinity",e+"\\."+o(e)+o(t),"\\."+e+o(t),e+o(t)].join("|");return new RegExp(`^(${`[+-]?(?:${n})`})(.*)$`)})(),In=(e,t)=>C.from(Hn.exec(e)).bind((e=>{const o=Number(e[1]),n=e[2];return((e,t)=>T(t,(t=>T(Ln[t],(t=>e===t)))))(n,t)?C.some({value:o,unit:n}):C.none()})),Pn=/(\d+(\.\d+)?)%/,Fn=/(\d+(\.\d+)?)px|em/,zn=pe("col"),Vn=(e,t,o)=>{const n=Re(e).getOrThunk((()=>mt(Ae(e))));return t(e)/o(n)*100},Zn=(e,t)=>{Bt(e,"width",t+"px")},Un=(e,t)=>{Bt(e,"width",t+"%")},jn=(e,t)=>{Bt(e,"height",t+"px")},$n=(e,t,o,n)=>{const r=parseFloat(e);return Dt(e,"%")&&"table"!==se(t)?((e,t,o,n)=>{const r=Jt(e).map((e=>{const n=o(e);return Math.floor(t/100*n)})).getOr(t);return n(e,r),r})(t,r,o,n):r},Wn=e=>{const t=(e=>fn(e)+"px")(e);return t?$n(t,e,pn,jn):pn(e)},qn=(e,t)=>Pt(e,t).orThunk((()=>ye(e,t).map((e=>e+"px")))),Gn=e=>qn(e,"width"),Kn=e=>Vn(e,zo,Zo),Yn=e=>zn(e)?zo(e):Uo(e),Xn=e=>((e,t,o)=>o(e)/Vt(e,t))(e,"rowspan",Wn),Jn=(e,t,o)=>{Bt(e,"width",t+o)},Qn=e=>Vn(e,zo,Zo)+"%",er=p(Pn),tr=pe("col"),or=e=>Gn(e).getOrThunk((()=>Yn(e)+"px")),nr=e=>{return(t=e,qn(t,"height")).getOrThunk((()=>Xn(e)+"px"));var t},rr=(e,t,o,n,r,s)=>e.filter(n).fold((()=>s(dn(o,t))),(e=>r(e))),sr=(e,t,o,n)=>{const r=an(e),s=sn.hasColumns(e)?(e=>D(sn.justColumns(e),(e=>C.from(e.element))))(e):r,a=[C.some(Bn.edge(t))].concat(D(Bn.positions(r,t),(e=>e.map((e=>e.x))))),i=v(Zt);return D(s,((e,t)=>rr(e,t,a,i,(e=>{if((e=>{const t=Bo().browser,o=t.isChromium()||t.isFirefox();return!tr(e)||o})(e))return o(e);{const e=(s=r[t],l=h,null!=s?l(s):C.none());return rr(e,t,a,i,(e=>n(C.some(zo(e)))),n)}var s,l}),n)))},ar=e=>e.map((e=>e+"px")).getOr(""),ir=(e,t,o)=>sr(e,t,Yn,(e=>e.getOrThunk(o.minCellWidth))),lr=(e,t,o,n,r)=>{const s=cn(e),a=[C.some(o.edge(t))].concat(D(o.positions(s,t),(e=>e.map((e=>e.y)))));return D(s,((e,t)=>rr(e,t,a,v(Ut),n,r)))},cr=(e,t)=>()=>dt(e)?t(e):parseFloat(Pt(e,"width").getOr("0")),dr=e=>{const t=cr(e,zo),o=p(0);return{width:t,pixelWidth:t,getWidths:(t,o)=>ir(t,e,o),getCellDelta:o,singleColumnWidth:p([0]),minCellWidth:o,setElementWidth:g,adjustTableWidth:g,isRelative:!0,label:"none"}},mr=e=>{const t=cr(e,(e=>parseFloat(Qn(e)))),o=cr(e,zo);return{width:t,pixelWidth:o,getWidths:(t,o)=>((e,t,o)=>sr(e,t,Kn,(e=>e.fold((()=>o.minCellWidth()),(e=>e/o.pixelWidth()*100)))))(t,e,o),getCellDelta:e=>e/o()*100,singleColumnWidth:(e,t)=>[100-e],minCellWidth:()=>$t()/o()*100,setElementWidth:Un,adjustTableWidth:o=>{const n=t();Un(e,n+o/100*n)},isRelative:!0,label:"percent"}},ur=e=>{const t=cr(e,zo);return{width:t,pixelWidth:t,getWidths:(t,o)=>ir(t,e,o),getCellDelta:h,singleColumnWidth:(e,t)=>[Math.max($t(),e+t)-e],minCellWidth:$t,setElementWidth:Zn,adjustTableWidth:o=>{const n=t()+o;Zn(e,n)},isRelative:!1,label:"pixel"}},gr=e=>Gn(e).fold((()=>dr(e)),(t=>((e,t)=>null!==er().exec(t)?mr(e):ur(e))(e,t))),pr=ur,hr=mr,fr=(e,t,o)=>{const n=e[o].element,r=Se.fromTag("td");Ze(r,Se.fromTag("br"));(t?Ze:Ve)(n,r)},br=(e,t)=>{const o=e=>ke(e.element,t),n=Xe(e),r=no(n),s=gr(e),a=sn.generate(r),i=((e,t)=>{const o=e.grid.columns;let n=e.grid.rows,r=o,s=0,a=0;const i=[],l=[];return q(e.access,(e=>{if(i.push(e),t(e)){l.push(e);const t=e.row,o=t+e.rowspan-1,i=e.column,c=i+e.colspan-1;ts&&(s=o),ia&&(a=c)}})),((e,t,o,n,r,s)=>({minRow:e,minCol:t,maxRow:o,maxCol:n,allCells:r,selectedCells:s}))(n,r,s,a,i,l)})(a,o),l="th:not("+t+"),td:not("+t+")",c=Gt(n,"th,td",(e=>ke(e,l)));A(c,qe),((e,t,o,n)=>{const r=N(e,(e=>"colgroup"!==e.section)),s=t.grid.columns,a=t.grid.rows;for(let e=0;eo.maxRow||io.maxCol||(sn.getAt(t,e,i).filter(n).isNone()?fr(r,a,e):a=!0)}})(r,a,i,o);const d=((e,t,o,n)=>{if(0===n.minCol&&t.grid.columns===n.maxCol+1)return 0;const r=ir(t,e,o),s=B(r,((e,t)=>e+t),0),a=B(r.slice(n.minCol,n.maxCol+1),((e,t)=>e+t),0),i=a/s*o.pixelWidth()-o.pixelWidth();return o.getCellDelta(i)})(e,sn.fromTable(e),s,i);return((e,t,o,n)=>{q(o.columns,(e=>{(e.columnt.maxCol)&&qe(e.element)}));const r=N(qt(e,"tr"),(e=>0===e.dom.childElementCount));A(r,qe),t.minCol!==t.maxCol&&t.minRow!==t.maxRow||A(qt(e,"th,td"),(e=>{we(e,"rowspan"),we(e,"colspan")})),we(e,Qo),we(e,"data-snooker-col-series"),gr(e).adjustTableWidth(n)})(n,i,a,d),n},vr=((e,t)=>{const o=t=>e(t)?C.from(t.dom.nodeValue):C.none();return{get:n=>{if(!e(n))throw new Error("Can only get "+t+" value of a "+t+" node");return o(n).getOr("")},getOption:o,set:(o,n)=>{if(!e(o))throw new Error("Can only set raw "+t+" value of a "+t+" node");o.dom.nodeValue=n}}})(me,"text"),yr=e=>vr.get(e),wr=e=>vr.getOption(e),xr=(e,t)=>vr.set(e,t),Cr=e=>"img"===se(e)?1:wr(e).fold((()=>Ie(e).length),(e=>e.length)),Sr=["img","br"],kr=e=>wr(e).filter((e=>0!==e.trim().length||e.indexOf(" ")>-1)).isSome()||O(Sr,se(e))||(e=>ce(e)&&"false"===ve(e,"contenteditable"))(e),_r=e=>((e,t)=>{const o=e=>{for(let n=0;nTr(e,kr),Tr=(e,t)=>{const o=e=>{const n=Ie(e);for(let e=n.length-1;e>=0;e--){const r=n[e];if(t(r))return C.some(r);const s=o(r);if(s.isSome())return s}return C.none()};return o(e)},Er={scope:["row","col"]},Dr=e=>()=>{const t=Se.fromTag("td",e.dom);return Ze(t,Se.fromTag("br",e.dom)),t},Ar=e=>()=>Se.fromTag("col",e.dom),Mr=e=>()=>Se.fromTag("colgroup",e.dom),Nr=e=>()=>Se.fromTag("tr",e.dom),Rr=(e,t,o)=>{const n=((e,t)=>{const o=Je(e,t),n=Ie(Xe(e));return $e(o,n),o})(e,t);return q(o,((e,t)=>{null===e?we(n,t):fe(n,t,e)})),n},Br=e=>e,Lr=(e,t,o)=>{const n=(e,t)=>{((e,t)=>{const o=e.dom,n=t.dom;Nt(o)&&Nt(n)&&(n.style.cssText=o.style.cssText)})(e.element,t),Ft(t,"height"),1!==e.colspan&&Ft(t,"width")};return{col:o=>{const r=Se.fromTag(se(o.element),t.dom);return n(o,r),e(o.element,r),r},colgroup:Mr(t),row:Nr(t),cell:r=>{const s=Se.fromTag(se(r.element),t.dom),a=o.getOr(["strong","em","b","i","span","font","h1","h2","h3","h4","h5","h6","p","div"]),i=a.length>0?((e,t,o)=>_r(e).map((n=>{const r=o.join(","),s=gt(n,r,(t=>Te(t,e)));return R(s,((e,t)=>{const o=Ye(t);return Ze(e,o),o}),t)})).getOr(t))(r.element,s,a):s;return Ze(i,Se.fromTag("br")),n(r,s),((e,t)=>{q(Er,((o,n)=>ye(e,n).filter((e=>O(o,e))).each((e=>fe(t,n,e)))))})(r.element,s),e(r.element,s),s},replace:Rr,colGap:Ar(t),gap:Dr(t)}},Hr=e=>({col:Ar(e),colgroup:Mr(e),row:Nr(e),cell:Dr(e),replace:Br,colGap:Ar(e),gap:Dr(e)}),Ir=e=>t=>t.options.get(e),Pr="100%",Fr=e=>{var t;const o=e.dom,n=null!==(t=o.getParent(e.selection.getStart(),o.isBlock))&&void 0!==t?t:e.getBody();return Zo(Se.fromDom(n))+"px"},zr=e=>C.from(e.options.get("table_clone_elements")),Vr=Ir("table_header_type"),Zr=Ir("table_column_resizing"),Ur=e=>"preservetable"===Zr(e),jr=e=>"resizetable"===Zr(e),$r=Ir("table_sizing_mode"),Wr=e=>"relative"===$r(e),qr=e=>"fixed"===$r(e),Gr=e=>"responsive"===$r(e),Kr=Ir("table_resize_bars"),Yr=Ir("table_style_by_css"),Xr=Ir("table_merge_content_on_paste"),Jr=e=>{const t=e.options,o=t.get("table_default_attributes");return t.isSet("table_default_attributes")?o:((e,t)=>Gr(e)||Yr(e)?t:qr(e)?{...t,width:Fr(e)}:{...t,width:Pr})(e,o)},Qr=e=>{const t=e.options,o=t.get("table_default_styles");return t.isSet("table_default_styles")?o:((e,t)=>Gr(e)||!Yr(e)?t:qr(e)?{...t,width:Fr(e)}:{...t,width:Pr})(e,o)},es=Ir("table_use_colgroups"),ts=e=>Ct(e,"[contenteditable]"),os=(e,t=!1)=>dt(e)?e.dom.isContentEditable:ts(e).fold(p(t),(e=>"true"===ns(e))),ns=e=>e.dom.contentEditable,rs=e=>Se.fromDom(e.getBody()),ss=e=>t=>Te(t,rs(e)),as=e=>{we(e,"data-mce-style");const t=e=>we(e,"data-mce-style");A(Yt(e),t),A(Xt(e),t),A(Qt(e),t)},is=e=>Se.fromDom(e.selection.getStart()),ls=e=>e.getBoundingClientRect().width,cs=e=>e.getBoundingClientRect().height,ds=e=>vt(e,pe("table")).exists(os),ms=(e,t)=>{const o=t.column,n=t.column+t.colspan-1,r=t.row,s=t.row+t.rowspan-1;return o<=e.finishCol&&n>=e.startCol&&r<=e.finishRow&&s>=e.startRow},us=(e,t)=>t.column>=e.startCol&&t.column+t.colspan-1<=e.finishCol&&t.row>=e.startRow&&t.row+t.rowspan-1<=e.finishRow,gs=(e,t,o)=>{const n=sn.findItem(e,t,Te),r=sn.findItem(e,o,Te);return n.bind((e=>r.map((t=>{return o=e,n=t,r=Math.min(o.row,n.row),s=Math.min(o.column,n.column),a=Math.max(o.row+o.rowspan-1,n.row+n.rowspan-1),i=Math.max(o.column+o.colspan-1,n.column+n.colspan-1),{startRow:r,startCol:s,finishRow:a,finishCol:i};var o,n,r,s,a,i}))))},ps=(e,t,o)=>gs(e,t,o).bind((t=>((e,t)=>{let o=!0;const n=b(us,t);for(let r=t.startRow;r<=t.finishRow;r++)for(let s=t.startCol;s<=t.finishCol;s++)o=o&&sn.getAt(e,r,s).exists(n);return o?C.some(t):C.none()})(e,t))),hs=(e,t,o)=>gs(e,t,o).map((t=>{const o=sn.filterItems(e,b(ms,t));return D(o,(e=>e.element))})),fs=(e,t)=>sn.findItem(e,t,((e,t)=>Ee(t,e))).map((e=>e.element)),bs=(e,t,o)=>Jt(e).bind((n=>((e,t,o,n)=>sn.findItem(e,t,Te).bind((t=>{const r=o>0?t.row+t.rowspan-1:t.row,s=n>0?t.column+t.colspan-1:t.column;return sn.getAt(e,r+o,s+n).map((e=>e.element))})))(ws(n),e,t,o))),vs=(e,t,o)=>{const n=ws(e);return hs(n,t,o)},ys=(e,t,o,n,r)=>{const s=ws(e),a=Te(e,o)?C.some(t):fs(s,t),i=Te(e,r)?C.some(n):fs(s,n);return a.bind((e=>i.bind((t=>hs(s,e,t)))))},ws=sn.fromTable;var xs=["body","p","div","article","aside","figcaption","figure","footer","header","nav","section","ol","ul","li","table","thead","tbody","tfoot","caption","tr","td","th","h1","h2","h3","h4","h5","h6","blockquote","pre","address"],Cs=()=>({up:p({selector:yt,closest:Ct,predicate:bt,all:Be}),down:p({selector:ht,predicate:ut}),styles:p({get:Ht,getRaw:Pt,set:Bt,remove:Ft}),attrs:p({get:ve,set:fe,remove:we,copyTo:(e,t)=>{const o=xe(e);be(t,o)}}),insert:p({before:Fe,after:ze,afterAll:je,append:Ze,appendAll:$e,prepend:Ve,wrap:Ue}),remove:p({unwrap:Ge,remove:qe}),create:p({nu:Se.fromTag,clone:e=>Se.fromDom(e.dom.cloneNode(!1)),text:Se.fromText}),query:p({comparePosition:(e,t)=>e.dom.compareDocumentPosition(t.dom),prevSibling:Le,nextSibling:He}),property:p({children:Ie,name:se,parent:Ne,document:e=>Me(e).dom,isText:me,isComment:le,isElement:de,isSpecial:e=>{const t=se(e);return O(["script","noscript","iframe","noframes","noembed","title","style","textarea","xmp"],t)},getLanguage:e=>de(e)?ye(e,"lang"):C.none(),getText:yr,setText:xr,isBoundary:e=>!!de(e)&&("body"===se(e)||O(xs,se(e))),isEmptyTag:e=>!!de(e)&&O(["br","img","hr","input"],se(e)),isNonEditable:e=>de(e)&&"false"===ve(e,"contenteditable")}),eq:Te,is:De});const Ss=(e,t,o,n)=>{const r=t(e,o);return R(n,((o,n)=>{const r=t(e,n);return ks(e,o,r)}),r)},ks=(e,t,o)=>t.bind((t=>o.filter(b(e.eq,t)))),_s=(e,t,o)=>o.length>0?((e,t,o,n)=>n(e,t,o[0],o.slice(1)))(e,t,o,Ss):C.none(),Os=(e,t,o,n=w)=>{const r=[t].concat(e.up().all(t)),s=[o].concat(e.up().all(o)),a=e=>H(e,n).fold((()=>e),(t=>e.slice(0,t+1))),i=a(r),l=a(s),c=L(i,(t=>T(l,((e,t)=>b(e.eq,t))(e,t))));return{firstpath:i,secondpath:l,shared:c}},Ts=Cs(),Es=(e,t)=>_s(Ts,((t,o)=>e(o)),t),Ds=e=>yt(e,"table"),As=(e,t,o)=>{const n=e=>t=>void 0!==o&&o(t)||Te(t,e);return Te(e,t)?C.some({boxes:C.some([e]),start:e,finish:t}):Ds(e).bind((r=>Ds(t).bind((s=>{if(Te(r,s))return C.some({boxes:vs(r,e,t),start:e,finish:t});if(Ee(r,s)){const o=gt(t,"td,th",n(r)),a=o.length>0?o[o.length-1]:t;return C.some({boxes:ys(r,e,r,t,s),start:e,finish:a})}if(Ee(s,r)){const o=gt(e,"td,th",n(s)),a=o.length>0?o[o.length-1]:e;return C.some({boxes:ys(s,e,r,t,s),start:e,finish:a})}return((e,t,o)=>Os(Ts,e,t,o))(e,t).shared.bind((a=>Ct(a,"table",o).bind((o=>{const a=gt(t,"td,th",n(o)),i=a.length>0?a[a.length-1]:t,l=gt(e,"td,th",n(o)),c=l.length>0?l[l.length-1]:e;return C.some({boxes:ys(o,e,r,t,s),start:c,finish:i})}))))}))))},Ms=(e,t)=>{const o=ht(e,t);return o.length>0?C.some(o):C.none()},Ns=(e,t,o)=>xt(e,t).bind((t=>xt(e,o).bind((e=>Es(Ds,[t,e]).map((o=>({first:t,last:e,table:o}))))))),Rs=(e,t,o,n,r)=>((e,t)=>L(e,(e=>ke(e,t))))(e,r).bind((e=>bs(e,t,o).bind((e=>((e,t)=>yt(e,"table").bind((o=>xt(o,t).bind((t=>As(t,e).bind((e=>e.boxes.map((t=>({boxes:t,start:e.start,finish:e.finish}))))))))))(e,n))))),Bs=(e,t)=>Ms(e,t),Ls=(e,t,o)=>Ns(e,t,o).bind((t=>{const o=t=>Te(e,t),n="thead,tfoot,tbody,table",r=yt(t.first,n,o),s=yt(t.last,n,o);return r.bind((e=>s.bind((o=>Te(e,o)?((e,t,o)=>{const n=ws(e);return ps(n,t,o)})(t.table,t.first,t.last):C.none()))))})),Hs=h,Is=e=>{const t=(e,t)=>ye(e,t).exists((e=>parseInt(e,10)>1));return e.length>0&&F(e,(e=>t(e,"rowspan")||t(e,"colspan")))?C.some(e):C.none()},Ps=(e,t,o)=>t.length<=1?C.none():Ls(e,o.firstSelectedSelector,o.lastSelectedSelector).map((e=>({bounds:e,cells:t}))),Fs="data-mce-selected",zs="td["+Fs+"],th["+Fs+"]",Vs="["+Fs+"]",Zs="data-mce-first-selected",Us="td["+Zs+"],th["+Zs+"]",js="data-mce-last-selected",$s="td["+js+"],th["+js+"]",Ws=Vs,qs={selected:Fs,selectedSelector:zs,firstSelected:Zs,firstSelectedSelector:Us,lastSelected:js,lastSelectedSelector:$s},Gs=(e,t,o)=>({element:o,mergable:Ps(t,e,qs),unmergable:Is(e),selection:Hs(e)}),Ks=e=>(t,o)=>{const n=se(t),r="col"===n||"colgroup"===n?Jt(s=t).bind((e=>Bs(e,qs.firstSelectedSelector))).fold(p(s),(e=>e[0])):t;var s;return Ct(r,e,o)},Ys=Ks("th,td,caption"),Xs=Ks("th,td"),Js=e=>{return t=e.model.table.getSelectedCells(),D(t,Se.fromDom);var t},Qs=(e,t)=>{e.on("BeforeGetContent",(t=>{const o=o=>{t.preventDefault(),(e=>Jt(e[0]).map((e=>{const t=br(e,Ws);return as(t),[t]})))(o).each((o=>{t.content="text"===t.format?(e=>D(e,(e=>e.dom.innerText)).join(""))(o):((e,t)=>D(t,(t=>e.selection.serializer.serialize(t.dom,{}))).join(""))(e,o)}))};if(!0===t.selection){const t=(e=>N(Js(e),(e=>ke(e,qs.selectedSelector))))(e);t.length>=1&&o(t)}})),e.on("BeforeSetContent",(o=>{if(!0===o.selection&&!0===o.paste){const n=Js(e);Z(n).each((n=>{Jt(n).each((r=>{const s=N(((e,t)=>{const o=(t||document).createElement("div");return o.innerHTML=e,Ie(Se.fromDom(o))})(o.content),(e=>"meta"!==se(e))),a=pe("table");if(Xr(e)&&1===s.length&&a(s[0])){o.preventDefault();const a=Se.fromDom(e.getDoc()),i=Hr(a),l=((e,t,o)=>({element:e,clipboard:t,generators:o}))(n,s[0],i);t.pasteCells(r,l).each((()=>{e.focus()}))}}))}))}}))},ea=(e,t)=>({element:e,offset:t}),ta=(e,t,o)=>e.property().isText(t)&&0===e.property().getText(t).trim().length||e.property().isComment(t)?o(t).bind((t=>ta(e,t,o).orThunk((()=>C.some(t))))):C.none(),oa=(e,t)=>{if(e.property().isText(t))return e.property().getText(t).length;return e.property().children(t).length},na=(e,t)=>{const o=ta(e,t,e.query().prevSibling).getOr(t);if(e.property().isText(o))return ea(o,oa(e,o));const n=e.property().children(o);return n.length>0?na(e,n[n.length-1]):ea(o,oa(e,o))},ra=na,sa=Cs(),aa=(e,t)=>{if(!Zt(e)){const o=(e=>Gn(e).bind((e=>In(e,["fixed","relative","empty"]))))(e);o.each((o=>{const n=o.value/2;Jn(e,n,o.unit),Jn(t,n,o.unit)}))}},ia=e=>D(e,p(0)),la=(e,t,o,n,r)=>r(e.slice(0,t)).concat(n).concat(r(e.slice(o))),ca=e=>(t,o,n,r)=>{if(e(n)){const e=Math.max(r,t[o]-Math.abs(n)),s=Math.abs(e-t[o]);return n>=0?s:-s}return n},da=ca((e=>e<0)),ma=ca(x),ua=()=>{const e=(e,t,o,n)=>{const r=(100+o)/100,s=Math.max(n,(e[t]+o)/r);return D(e,((e,o)=>(o===t?s:e/r)-e))},t=(t,o,n,r,s,a)=>a?e(t,o,r,s):((e,t,o,n,r)=>{const s=da(e,t,n,r);return la(e,t,o+1,[s,0],ia)})(t,o,n,r,s);return{resizeTable:(e,t)=>e(t),clampTableDelta:da,calcLeftEdgeDeltas:t,calcMiddleDeltas:(e,o,n,r,s,a,i)=>t(e,n,r,s,a,i),calcRightEdgeDeltas:(t,o,n,r,s,a)=>{if(a)return e(t,n,r,s);{const e=da(t,n,r,s);return ia(t.slice(0,n)).concat([e])}},calcRedestributedWidths:(e,t,o,n)=>{if(n){const n=(t+o)/t,r=D(e,(e=>e/n));return{delta:100*n-100,newSizes:r}}return{delta:o,newSizes:e}}}},ga=()=>{const e=(e,t,o,n,r)=>{const s=ma(e,n>=0?o:t,n,r);return la(e,t,o+1,[s,-s],ia)};return{resizeTable:(e,t,o)=>{o&&e(t)},clampTableDelta:(e,t,o,n,r)=>{if(r){if(o>=0)return o;{const t=B(e,((e,t)=>e+t-n),0);return Math.max(-t,o)}}return da(e,t,o,n)},calcLeftEdgeDeltas:e,calcMiddleDeltas:(t,o,n,r,s,a)=>e(t,n,r,s,a),calcRightEdgeDeltas:(e,t,o,n,r,s)=>{if(s)return ia(e);{const t=n/e.length;return D(e,p(t))}},calcRedestributedWidths:(e,t,o,n)=>({delta:0,newSizes:e})}},pa=e=>sn.fromTable(e).grid,ha=pe("th"),fa=e=>F(e,(e=>ha(e.element))),ba=(e,t)=>e&&t?"sectionCells":e?"section":"cells",va=e=>{const t="thead"===e.section,o=St(ya(e.cells),"th");return"tfoot"===e.section?{type:"footer"}:t||o?{type:"header",subType:ba(t,o)}:{type:"body"}},ya=e=>{const t=N(e,(e=>ha(e.element)));return 0===t.length?C.some("td"):t.length===e.length?C.some("th"):C.none()},wa=(e,t,o)=>ot(o(e.element,t),!0,e.isLocked),xa=(e,t)=>e.section!==t?nt(e.element,e.cells,t,e.isNew):e,Ca=()=>({transformRow:xa,transformCell:(e,t,o)=>{const n=o(e.element,t),r="td"!==se(n)?((e,t)=>{const o=Je(e,t);ze(e,o);const n=Ie(e);return $e(o,n),qe(e),o})(n,"td"):n;return ot(r,e.isNew,e.isLocked)}}),Sa=()=>({transformRow:xa,transformCell:wa}),ka=()=>({transformRow:(e,t)=>xa(e,"thead"===t?"tbody":t),transformCell:wa}),_a=(e,t)=>{const o=(e=>j(e.all,(e=>{const t=va(e);return"header"===t.type?C.from(t.subType):C.none()})))(sn.fromTable(e)).getOr(t);switch(o){case"section":return Ca();case"sectionCells":return Sa();case"cells":return ka()}},Oa=Ca,Ta=Sa,Ea=ka,Da=()=>({transformRow:h,transformCell:wa}),Aa=(e,t,o,n)=>{o===n?we(e,t):fe(e,t,o)},Ma=(e,t,o)=>{U(pt(e,t)).fold((()=>Ve(e,o)),(e=>ze(e,o)))},Na=(e,t)=>{const o=[],n=[],r=e=>D(e,(e=>{e.isNew&&o.push(e.element);const t=e.element;return We(t),A(e.cells,(e=>{e.isNew&&n.push(e.element),Aa(e.element,"colspan",e.colspan,1),Aa(e.element,"rowspan",e.rowspan,1),Ze(t,e.element)})),t})),s=e=>P(e,(e=>D(e.cells,(e=>(Aa(e.element,"span",e.colspan,1),e.element))))),a=(t,o)=>{const n=((e,t)=>{const o=wt(e,t).getOrThunk((()=>{const o=Se.fromTag(t,Ae(e).dom);return"thead"===t?Ma(e,"caption,colgroup",o):"colgroup"===t?Ma(e,"caption",o):Ze(e,o),o}));return We(o),o})(e,o),a=("colgroup"===o?s:r)(t);$e(n,a)},i=(t,o)=>{t.length>0?a(t,o):(t=>{wt(e,t).each(qe)})(o)},l=[],c=[],d=[],m=[];return A(t,(e=>{switch(e.section){case"thead":l.push(e);break;case"tbody":c.push(e);break;case"tfoot":d.push(e);break;case"colgroup":m.push(e)}})),i(m,"colgroup"),i(l,"thead"),i(c,"tbody"),i(d,"tfoot"),{newRows:o,newCells:n}},Ra=(e,t)=>{if(0===e.length)return 0;const o=e[0];return H(e,(e=>!t(o.element,e.element))).getOr(e.length)},Ba=(e,t,o,n)=>{const r=((e,t)=>e[t])(e,t),s="colgroup"===r.section,a=Ra(r.cells.slice(o),n),i=s?1:Ra(((e,t)=>D(e,(e=>Go(e,t))))(e.slice(t),o),n);return{colspan:a,rowspan:i}},La=(e,t)=>{const o=D(e,(e=>D(e.cells,w)));return D(e,((n,r)=>{const s=P(n.cells,((n,s)=>{if(!1===o[r][s]){const d=Ba(e,r,s,t);return((e,t,n,r)=>{for(let s=e;s({element:e,cells:t,section:o,isNew:n}))(n.element,s,n.section,n.isNew)}))},Ha=(e,t,o)=>{const n=[];A(e.colgroups,(r=>{const s=[];for(let n=0;not(e.element,o,!1))).getOrThunk((()=>ot(t.colGap(),!0,!1)));s.push(r)}n.push(nt(r.element,s,"colgroup",o))}));for(let r=0;rot(e.element,o,e.isLocked))).getOrThunk((()=>ot(t.gap(),!0,!1)));s.push(a)}const a=e.all[r],i=nt(a.element,s,a.section,o);n.push(i)}return n},Ia=e=>La(e,Te),Pa=(e,t)=>j(e.all,(e=>L(e.cells,(e=>Te(t,e.element))))),Fa=(e,t,o)=>{const n=D(t.selection,(t=>Kt(t).bind((t=>Pa(e,t))).filter(o))),r=kt(n);return _t(r.length>0,r)},za=(e,t,o,n,r)=>(s,a,i,l)=>{const c=sn.fromTable(s),d=C.from(null==l?void 0:l.section).getOrThunk(Da);return t(c,a).map((t=>{const o=((e,t)=>Ha(e,t,!1))(c,i),n=e(o,t,Te,r(i),d),s=tn(n.grid);return{info:t,grid:Ia(n.grid),cursor:n.cursor,lockedColumns:s}})).bind((e=>{const t=Na(s,e.grid),r=C.from(null==l?void 0:l.sizing).getOrThunk((()=>gr(s))),a=C.from(null==l?void 0:l.resize).getOrThunk(ga);return o(s,e.grid,e.info,{sizing:r,resize:a,section:d}),n(s),we(s,Qo),e.lockedColumns.length>0&&fe(s,Qo,e.lockedColumns.join(",")),C.some({cursor:e.cursor,newRows:t.newRows,newCells:t.newCells})}))},Va=(e,t)=>Fa(e,t,x).map((e=>({cells:e,generators:t.generators,clipboard:t.clipboard}))),Za=(e,t)=>Fa(e,t,x),Ua=(e,t)=>Fa(e,t,(e=>!e.isLocked)),ja=(e,t)=>F(t,(t=>((e,t)=>Pa(e,t).exists((e=>!e.isLocked)))(e,t))),$a=(e,t,o,n)=>{const r=Xo(e).rows;let s=!0;for(let e=0;e{const r=Xo(e).rows;if(t>0&&tB(e,((e,o)=>T(e,(e=>t(e.element,o.element)))?e:e.concat([o])),[]))(r[t-1].cells,o);A(e,(e=>{let s=C.none();for(let a=t;a{Wo(i,t,ot(e,!0,l.isLocked))})))}}))}return e},qa=e=>{const t=t=>t(e),o=p(e),n=()=>r,r={tag:!0,inner:e,fold:(t,o)=>o(e),isValue:x,isError:w,map:t=>Ka.value(t(e)),mapError:n,bind:t,exists:t,forall:t,getOr:o,or:n,getOrThunk:o,orThunk:n,getOrDie:o,each:t=>{t(e)},toOptional:()=>C.some(e)};return r},Ga=e=>{const t=()=>o,o={tag:!1,inner:e,fold:(t,o)=>t(e),isValue:w,isError:x,map:t,mapError:t=>Ka.error(t(e)),bind:t,exists:w,forall:x,getOr:h,or:h,getOrThunk:y,orThunk:y,getOrDie:(n=String(e),()=>{throw new Error(n)}),each:g,toOptional:C.none};var n;return o},Ka={value:qa,error:Ga,fromOption:(e,t)=>e.fold((()=>Ga(t)),qa)},Ya=(e,t)=>({rowDelta:0,colDelta:Yo(e[0])-Yo(t[0])}),Xa=(e,t)=>({rowDelta:e.length-t.length,colDelta:0}),Ja=(e,t,o,n)=>{const r="colgroup"===t.section?o.col:o.cell;return E(e,(e=>ot(r(),!0,n(e))))},Qa=(e,t,o,n)=>{const r=e[e.length-1];return e.concat(E(t,(()=>{const e="colgroup"===r.section?o.colgroup:o.row,t=Jo(r,e,h),s=Ja(t.cells.length,t,o,(e=>Q(n,e.toString())));return qo(t,s)})))},ei=(e,t,o,n)=>D(e,(e=>{const r=Ja(t,e,o,w);return jo(e,n,r)})),ti=(e,t,o)=>{const n=t.colDelta<0?ei:h,r=t.rowDelta<0?Qa:h,s=tn(e),a=Yo(e[0]),i=T(s,(e=>e===a-1)),l=n(e,Math.abs(t.colDelta),o,i?a-1:a),c=tn(l);return r(l,Math.abs(t.rowDelta),o,z(c,x))},oi=(e,t,o,n)=>{const r=b(n,Go(e[t],o).element),s=e[t];return e.length>1&&Yo(s)>1&&(o>0&&r(Ko(s,o-1))||o0&&r(Ko(e[t-1],o))||tN(o,(o=>o>=e.column&&o<=Yo(t[0])+e.column)),ri=(e,t,o,n,r)=>{const s=tn(t),a=((e,t,o)=>{const n=Yo(t[0]),r=Xo(t).cols.length+e.row,s=E(n-e.column,(t=>t+e.column)),a=L(s,(e=>F(o,(t=>t!==e)))).getOr(n-1);return{row:r,column:a}})(e,t,s),i=Xo(o).rows,l=ni(a,i,s),c=((e,t,o)=>{if(e.row>=t.length||e.column>Yo(t[0]))return Ka.error("invalid start address out of table bounds, row: "+e.row+", column: "+e.column);const n=t.slice(e.row),r=n[0].cells.slice(e.column),s=Yo(o[0]),a=o.length;return Ka.value({rowDelta:n.length-a,colDelta:r.length-s})})(a,t,i);return c.map((e=>{const o={...e,colDelta:e.colDelta-l.length},s=ti(t,o,n),c=tn(s),d=ni(a,i,c);return((e,t,o,n,r,s)=>{const a=e.row,i=e.column,l=a+o.length,c=i+Yo(o[0])+s.length,d=z(s,x);for(let e=a;e{((e,t,o,n)=>{t>0&&t{const r=e.cells[t-1];let s=0;const a=n();for(;e.cells.length>t+s&&o(r.element,e.cells[t+s].element);)Wo(e,t+s,ot(a,!0,e.cells[t+s].isLocked)),s++}))})(t,e,r,n.cell);const s=Xa(o,t),a=ti(o,s,n),i=Xa(t,a),l=ti(t,i,n);return D(l,((t,o)=>jo(t,e,a[o].cells)))},ai=(e,t,o,n,r)=>{Wa(t,e,r,n.cell);const s=tn(t),a=Ya(t,o),i={...a,colDelta:a.colDelta-s.length},l=ti(t,i,n),{cols:c,rows:d}=Xo(l),m=tn(l),u=Ya(o,t),g={...u,colDelta:u.colDelta+m.length},p=((e,t,o)=>D(e,(e=>B(o,((o,n)=>{const r=Ja(1,e,t,x)[0];return $o(o,n,r)}),e))))(o,n,m),h=ti(p,g,n);return[...c,...d.slice(0,e),...h,...d.slice(e,d.length)]},ii=(e,t,o,n,r)=>{const{rows:s,cols:a}=Xo(e),i=s.slice(0,t),l=s.slice(t),c=((e,t,o,n)=>Jo(e,(e=>n(e,o)),t))(s[o],((e,o)=>t>0&&tD(e,(e=>{const s=t>0&&t{if("colgroup"!==o&&n)return Go(e,t);{const t=Go(e,r);return ot(a(t.element,s),!0,!1)}})(e,t,e.section,s,o,n,r);return $o(e,t,a)})),ci=(e,t,o,n)=>((e,t,o,n)=>void 0!==Ko(e[t],o)&&t>0&&n(Ko(e[t-1],o),Ko(e[t],o)))(e,t,o,n)||((e,t,o)=>t>0&&o(Ko(e,t-1),Ko(e,t)))(e[t],o,n),di=(e,t,o,n)=>{const r=e=>(e=>"row"===e?Ut(t):Zt(t))(e)?`${e}group`:e;if(e)return ha(t)?r(o):null;if(n&&ha(t)){return r("row"===o?"col":"row")}return null},mi=(e,t,o)=>ot(o(e.element,t),!0,e.isLocked),ui=(e,t,o,n,r,s,a)=>D(e,((e,i)=>((e,t)=>{const o=e.cells,n=D(o,t);return nt(e.element,n,e.section,e.isNew)})(e,((e,l)=>{if((e=>T(t,(t=>o(e.element,t.element))))(e)){const t=a(e,i,l)?r(e,o,n):e;return s(t,i,l).each((e=>{var o,n;o=t.element,n={scope:C.from(e)},q(n,((e,t)=>{e.fold((()=>{we(o,t)}),(e=>{he(o.dom,t,e)}))}))})),t}return e})))),gi=(e,t,o)=>P(e,((n,r)=>ci(e,r,t,o)?[]:[Go(n,t)])),pi=(e,t,o,n,r)=>{const s=Xo(e).rows,a=P(t,(e=>gi(s,e,n))),i=D(s,(e=>fa(e.cells))),l=((e,t)=>F(t,h)&&fa(e)?x:(e,o,n)=>!("th"===se(e.element)&&t[o]))(a,i),c=((e,t)=>(o,n)=>C.some(di(e,o.element,"row",t[n])))(o,i);return ui(e,a,n,r,mi,c,l)},hi=(e,t,o,n,r,s,a)=>{const{cols:i,rows:l}=Xo(e),c=l[t[0]],d=P(t,(e=>((e,t,o)=>{const n=e[t];return P(n.cells,((n,r)=>ci(e,t,r,o)?[]:[n]))})(l,e,r))),m=D(c.cells,((e,t)=>fa(gi(l,t,r)))),u=[...l];A(t,(e=>{u[e]=a.transformRow(l[e],o)}));const g=[...i,...u],p=((e,t)=>F(t,h)&&fa(e.cells)?x:(e,o,n)=>!("th"===se(e.element)&&t[n]))(c,m),f=((e,t)=>(o,n,r)=>C.some(di(e,o.element,"col",t[r])))(n,m);return ui(g,d,r,s,a.transformCell,f,p)},fi=(e,t,o,n)=>{const r=Xo(e).rows,s=D(t,(e=>Go(r[e.row],e.column)));return ui(e,s,o,n,mi,C.none,x)},bi=e=>{if(!a(e))throw new Error("cases must be an array");if(0===e.length)throw new Error("there must be at least one case");const t=[],o={};return A(e,((n,r)=>{const s=$(n);if(1!==s.length)throw new Error("one and only one name per case");const i=s[0],l=n[i];if(void 0!==o[i])throw new Error("duplicate key detected:"+i);if("cata"===i)throw new Error("cannot have a case named cata (sorry)");if(!a(l))throw new Error("case arguments must be an array");t.push(i),o[i]=(...o)=>{const n=o.length;if(n!==l.length)throw new Error("Wrong number of arguments to case "+i+". Expected "+l.length+" ("+l+"), got "+n);return{fold:(...t)=>{if(t.length!==e.length)throw new Error("Wrong number of arguments to fold. Expected "+e.length+", got "+t.length);return t[r].apply(null,o)},match:e=>{const n=$(e);if(t.length!==n.length)throw new Error("Wrong number of arguments to match. Expected: "+t.join(",")+"\nActual: "+n.join(","));if(!F(t,(e=>O(n,e))))throw new Error("Not all branches were specified when using match. Specified: "+n.join(", ")+"\nRequired: "+t.join(", "));return e[i].apply(null,o)},log:e=>{console.log(e,{constructors:t,constructor:i,params:o})}}}})),o},vi={...bi([{none:[]},{only:["index"]},{left:["index","next"]},{middle:["prev","index","next"]},{right:["prev","index"]}])},yi=(e,t,o,n,r)=>{const s=e.slice(0),a=((e,t)=>0===e.length?vi.none():1===e.length?vi.only(0):0===t?vi.left(0,1):t===e.length-1?vi.right(t-1,t):t>0&&tn.singleColumnWidth(s[e],o)),((e,t)=>r.calcLeftEdgeDeltas(s,e,t,o,n.minCellWidth(),n.isRelative)),((e,t,a)=>r.calcMiddleDeltas(s,e,t,a,o,n.minCellWidth(),n.isRelative)),((e,t)=>r.calcRightEdgeDeltas(s,e,t,o,n.minCellWidth(),n.isRelative)))},wi=(e,t,o)=>{let n=0;for(let r=e;r{const o=sn.justCells(e);return D(o,(e=>{const o=wi(e.row,e.row+e.rowspan,t);return{element:e.element,height:o,rowspan:e.rowspan}}))},Ci=(e,t)=>sn.hasColumns(e)?((e,t)=>{const o=sn.justColumns(e);return D(o,((e,o)=>({element:e.element,width:t[o],colspan:e.colspan})))})(e,t):((e,t)=>{const o=sn.justCells(e);return D(o,(e=>{const o=wi(e.column,e.column+e.colspan,t);return{element:e.element,width:o,colspan:e.colspan}}))})(e,t),Si=(e,t,o)=>{const n=Ci(e,t);A(n,(e=>{o.setElementWidth(e.element,e.width)}))},ki=(e,t,o,n,r)=>{const s=sn.fromTable(e),a=r.getCellDelta(t),i=r.getWidths(s,r),l=o===s.grid.columns-1,c=n.clampTableDelta(i,o,a,r.minCellWidth(),l),d=yi(i,o,c,r,n),m=D(d,((e,t)=>e+i[t]));Si(s,m,r),n.resizeTable(r.adjustTableWidth,c,l)},_i=(e,t,o,n)=>{const r=sn.fromTable(e),s=((e,t,o)=>lr(e,t,o,Xn,(e=>e.getOrThunk(Wt))))(r,e,n),a=D(s,((e,n)=>o===n?Math.max(t+e,Wt()):e)),i=xi(r,a),l=((e,t)=>D(e.all,((e,o)=>({element:e.element,height:t[o]}))))(r,a);A(l,(e=>{jn(e.element,e.height)})),A(i,(e=>{jn(e.element,e.height)}));const c=R(a,((e,t)=>e+t),0);jn(e,c)},Oi=e=>B(e,((e,t)=>T(e,(e=>e.column===t.column))?e:e.concat([t])),[]).sort(((e,t)=>e.column-t.column)),Ti=pe("col"),Ei=pe("colgroup"),Di=e=>"tr"===se(e)||Ei(e),Ai=e=>({element:e,colspan:zt(e,"colspan",1),rowspan:zt(e,"rowspan",1)}),Mi=e=>ye(e,"scope").map((e=>e.substr(0,3))),Ni=(e,t=Ai)=>{const o=o=>{if(Di(o))return Ei((r={element:o}).element)?e.colgroup(r):e.row(r);{const r=o,s=(t=>Ti(t.element)?e.col(t):e.cell(t))(t(r));return n=C.some({item:r,replacement:s}),s}var r};let n=C.none();return{getOrInit:(e,t)=>n.fold((()=>o(e)),(n=>t(e,n.item)?n.replacement:o(e)))}},Ri=e=>t=>{const o=[],n=n=>{const r="td"===e?{scope:null}:{},s=t.replace(n,e,r);return o.push({item:n,sub:s}),s};return{replaceOrInit:(e,t)=>{if(Di(e)||Ti(e))return e;{const r=e;return((e,t)=>L(o,(o=>t(o.item,e))))(r,t).fold((()=>n(r)),(o=>t(e,o.item)?o.sub:n(r)))}}}},Bi=e=>({unmerge:t=>{const o=Mi(t);return o.each((e=>fe(t,"scope",e))),()=>{const n=e.cell({element:t,colspan:1,rowspan:1});return Ft(n,"width"),Ft(t,"width"),o.each((e=>fe(n,"scope",e))),n}},merge:e=>(Ft(e[0],"width"),(()=>{const t=kt(D(e,Mi));if(0===t.length)return C.none();{const e=t[0],o=["row","col"];return T(t,(t=>t!==e&&O(o,t)))?C.none():C.from(e)}})().fold((()=>we(e[0],"scope")),(t=>fe(e[0],"scope",t+"group"))),p(e[0]))}),Li=["body","p","div","article","aside","figcaption","figure","footer","header","nav","section","ol","ul","table","thead","tfoot","tbody","caption","tr","td","th","h1","h2","h3","h4","h5","h6","blockquote","pre","address"],Hi=Cs(),Ii=e=>((e,t)=>{const o=e.property().name(t);return O(Li,o)})(Hi,e),Pi=e=>((e,t)=>{const o=e.property().name(t);return O(["ol","ul"],o)})(Hi,e),Fi=e=>((e,t)=>O(["br","img","hr","input"],e.property().name(t)))(Hi,e),zi=e=>{const t=pe("br"),o=e=>Or(e).bind((o=>{const n=He(o).map((e=>!!Ii(e)||!!Fi(e)&&"img"!==se(e))).getOr(!1);return Ne(o).map((r=>!0===n||(e=>"li"===se(e)||bt(e,Pi).isSome())(r)||t(o)||Ii(r)&&!Te(e,r)?[]:[Se.fromTag("br")]))})).getOr([]),n=(()=>{const n=P(e,(e=>{const n=Ie(e);return(e=>F(e,(e=>t(e)||me(e)&&0===yr(e).trim().length)))(n)?[]:n.concat(o(e))}));return 0===n.length?[Se.fromTag("br")]:n})();We(e[0]),$e(e[0],n)},Vi=e=>os(e,!0),Zi=e=>{0===Yt(e).length&&qe(e)},Ui=(e,t)=>({grid:e,cursor:t}),ji=(e,t,o)=>{var n,r;const s=Xo(e).rows;return C.from(null===(r=null===(n=s[t])||void 0===n?void 0:n.cells[o])||void 0===r?void 0:r.element).filter(Vi).orThunk((()=>(e=>j(e,(e=>j(e.cells,(e=>{const t=e.element;return _t(Vi(t),t)})))))(s)))},$i=(e,t,o)=>{const n=ji(e,t,o);return Ui(e,n)},Wi=e=>B(e,((e,t)=>T(e,(e=>e.row===t.row))?e:e.concat([t])),[]).sort(((e,t)=>e.row-t.row)),qi=(e,t)=>(o,n,r,s,a)=>{const i=Wi(n),l=D(i,(e=>e.row)),c=hi(o,l,e,t,r,s.replaceOrInit,a);return $i(c,n[0].row,n[0].column)},Gi=qi("thead",!0),Ki=qi("tbody",!1),Yi=qi("tfoot",!1),Xi=(e,t,o)=>{const n=((e,t)=>to(e,(()=>t)))(e,o.section),r=sn.generate(n);return Ha(r,t,!0)},Ji=(e,t,o,n)=>((e,t,o,n)=>{const r=sn.generate(t),s=n.getWidths(r,n);Si(r,s,n)})(0,t,0,n.sizing),Qi=(e,t,o,n)=>((e,t,o,n,r)=>{const s=sn.generate(t),a=n.getWidths(s,n),i=n.pixelWidth(),{newSizes:l,delta:c}=r.calcRedestributedWidths(a,i,o.pixelDelta,n.isRelative);Si(s,l,n),n.adjustTableWidth(c)})(0,t,o,n.sizing,n.resize),el=(e,t)=>T(t,(e=>0===e.column&&e.isLocked)),tl=(e,t)=>T(t,(t=>t.column+t.colspan>=e.grid.columns&&t.isLocked)),ol=(e,t)=>{const o=an(e),n=Oi(t);return B(n,((e,t)=>e+o[t.column].map(Vo).getOr(0)),0)},nl=e=>(t,o)=>Za(t,o).filter((o=>!(e?el:tl)(t,o))).map((e=>({details:e,pixelDelta:ol(t,e)}))),rl=e=>(t,o)=>Va(t,o).filter((o=>!(e?el:tl)(t,o.cells))),sl=Ri("th"),al=Ri("td"),il=za(((e,t,o,n)=>{const r=t[0].row,s=Wi(t),a=R(s,((e,t)=>({grid:ii(e.grid,r,t.row+e.delta,o,n.getOrInit),delta:e.delta+1})),{grid:e,delta:0}).grid;return $i(a,r,t[0].column)}),Za,g,g,Ni),ll=za(((e,t,o,n)=>{const r=Wi(t),s=r[r.length-1],a=s.row+s.rowspan,i=R(r,((e,t)=>ii(e,a,t.row,o,n.getOrInit)),e);return $i(i,a,t[0].column)}),Za,g,g,Ni),cl=za(((e,t,o,n)=>{const r=t.details,s=Oi(r),a=s[0].column,i=R(s,((e,t)=>({grid:li(e.grid,a,t.column+e.delta,o,n.getOrInit),delta:e.delta+1})),{grid:e,delta:0}).grid;return $i(i,r[0].row,a)}),nl(!0),Qi,g,Ni),dl=za(((e,t,o,n)=>{const r=t.details,s=r[r.length-1],a=s.column+s.colspan,i=Oi(r),l=R(i,((e,t)=>li(e,a,t.column,o,n.getOrInit)),e);return $i(l,r[0].row,a)}),nl(!1),Qi,g,Ni),ml=za(((e,t,o,n)=>{const r=Oi(t.details),s=((e,t)=>P(e,(e=>{const o=e.cells,n=R(t,((e,t)=>t>=0&&t0?[nt(e.element,n,e.section,e.isNew)]:[]})))(e,D(r,(e=>e.column))),a=s.length>0?s[0].cells.length-1:0;return $i(s,r[0].row,Math.min(r[0].column,a))}),((e,t)=>Ua(e,t).map((t=>({details:t,pixelDelta:-ol(e,t)})))),Qi,Zi,Ni),ul=za(((e,t,o,n)=>{const r=Wi(t),s=((e,t,o)=>{const{rows:n,cols:r}=Xo(e);return[...r,...n.slice(0,t),...n.slice(o+1)]})(e,r[0].row,r[r.length-1].row),a=s.length>0?s.length-1:0;return $i(s,Math.min(t[0].row,a),t[0].column)}),Za,g,Zi,Ni),gl=za(((e,t,o,n)=>{const r=Oi(t),s=D(r,(e=>e.column)),a=pi(e,s,!0,o,n.replaceOrInit);return $i(a,t[0].row,t[0].column)}),Ua,g,g,sl),pl=za(((e,t,o,n)=>{const r=Oi(t),s=D(r,(e=>e.column)),a=pi(e,s,!1,o,n.replaceOrInit);return $i(a,t[0].row,t[0].column)}),Ua,g,g,al),hl=za(Gi,Ua,g,g,sl),fl=za(Ki,Ua,g,g,al),bl=za(Yi,Ua,g,g,al),vl=za(((e,t,o,n)=>{const r=fi(e,t,o,n.replaceOrInit);return $i(r,t[0].row,t[0].column)}),Ua,g,g,sl),yl=za(((e,t,o,n)=>{const r=fi(e,t,o,n.replaceOrInit);return $i(r,t[0].row,t[0].column)}),Ua,g,g,al),wl=za(((e,t,o,n)=>{const r=t.cells;zi(r);const s=((e,t,o,n)=>{const r=Xo(e).rows;if(0===r.length)return e;for(let e=t.startRow;e<=t.finishRow;e++)for(let o=t.startCol;o<=t.finishCol;o++){const t=r[e],s=Go(t,o).isLocked;Wo(t,o,ot(n(),!1,s))}return e})(e,t.bounds,0,n.merge(r));return Ui(s,C.from(r[0]))}),((e,t)=>((e,t)=>t.mergable)(0,t).filter((t=>ja(e,t.cells)))),Ji,g,Bi),xl=za(((e,t,o,n)=>{const r=R(t,((e,t)=>$a(e,t,o,n.unmerge(t))),e);return Ui(r,C.from(t[0]))}),((e,t)=>((e,t)=>t.unmergable)(0,t).filter((t=>ja(e,t)))),Ji,g,Bi),Cl=za(((e,t,o,n)=>{const r=((e,t)=>{const o=sn.fromTable(e);return Ha(o,t,!0)})(t.clipboard,t.generators),s=((e,t)=>({row:e,column:t}))(t.row,t.column);return ri(s,e,r,t.generators,o).fold((()=>Ui(e,C.some(t.element))),(e=>$i(e,t.row,t.column)))}),((e,t)=>Kt(t.element).bind((o=>Pa(e,o).map((e=>({...e,generators:t.generators,clipboard:t.clipboard})))))),Ji,g,Ni),Sl=za(((e,t,o,n)=>{const r=Xo(e).rows,s=t.cells[0].column,a=r[t.cells[0].row],i=Xi(t.clipboard,t.generators,a),l=si(s,e,i,t.generators,o);return $i(l,t.cells[0].row,t.cells[0].column)}),rl(!0),g,g,Ni),kl=za(((e,t,o,n)=>{const r=Xo(e).rows,s=t.cells[t.cells.length-1].column+t.cells[t.cells.length-1].colspan,a=r[t.cells[0].row],i=Xi(t.clipboard,t.generators,a),l=si(s,e,i,t.generators,o);return $i(l,t.cells[0].row,t.cells[0].column)}),rl(!1),g,g,Ni),_l=za(((e,t,o,n)=>{const r=Xo(e).rows,s=t.cells[0].row,a=r[s],i=Xi(t.clipboard,t.generators,a),l=ai(s,e,i,t.generators,o);return $i(l,t.cells[0].row,t.cells[0].column)}),Va,g,g,Ni),Ol=za(((e,t,o,n)=>{const r=Xo(e).rows,s=t.cells[t.cells.length-1].row+t.cells[t.cells.length-1].rowspan,a=r[t.cells[0].row],i=Xi(t.clipboard,t.generators,a),l=ai(s,e,i,t.generators,o);return $i(l,t.cells[0].row,t.cells[0].column)}),Va,g,g,Ni),Tl=(e,t)=>{const o=sn.fromTable(e);return Za(o,t).bind((e=>{const t=e[e.length-1],n=e[0].column,r=t.column+t.colspan,s=I(D(o.all,(e=>N(e.cells,(e=>e.column>=n&&e.column{const o=sn.fromTable(e);return Za(o,t).bind(ya).getOr("")},Dl=(e,t)=>{const o=sn.fromTable(e);return Za(o,t).bind((e=>{const t=e[e.length-1],n=e[0].row,r=t.row+t.rowspan;return(e=>{const t=D(e,(e=>va(e).type)),o=O(t,"header"),n=O(t,"footer");if(o||n){const e=O(t,"body");return!o||e||n?o||e||!n?C.none():C.some("footer"):C.some("header")}return C.some("body")})(o.all.slice(n,r))})).getOr("")},Al=(e,t)=>e.dispatch("NewRow",{node:t}),Ml=(e,t)=>e.dispatch("NewCell",{node:t}),Nl=(e,t,o)=>{e.dispatch("TableModified",{...o,table:t})},Rl={structure:!1,style:!0},Bl={structure:!0,style:!1},Ll={structure:!0,style:!0},Hl=(e,t)=>Wr(e)?hr(t):qr(e)?pr(t):gr(t),Il=(e,t,o)=>{const n=e=>"table"===se(rs(e)),r=zr(e),s=jr(e)?g:aa,a=t=>{switch(Vr(e)){case"section":return Oa();case"sectionCells":return Ta();case"cells":return Ea();default:return _a(t,"section")}},i=(t,n)=>n.cursor.fold((()=>{const n=Yt(t);return Z(n).filter(dt).map((n=>{o.clearSelectedCells(t.dom);const r=e.dom.createRng();return r.selectNode(n.dom),e.selection.setRng(r),fe(n,"data-mce-selected","1"),r}))}),(n=>{const r=ra(sa,n);const s=e.dom.createRng();return s.setStart(r.element.dom,r.offset),s.setEnd(r.element.dom,r.offset),e.selection.setRng(s),o.clearSelectedCells(t.dom),C.some(s)})),l=(o,n,s,l)=>(c,d,m=!1)=>{as(c);const u=Se.fromDom(e.getDoc()),g=Lr(s,u,r),p={sizing:Hl(e,c),resize:jr(e)?ua():ga(),section:a(c)};return n(c)?o(c,d,g,p).bind((o=>{t.refresh(c.dom),A(o.newRows,(t=>{Al(e,t.dom)})),A(o.newCells,(t=>{Ml(e,t.dom)}));const n=i(c,o);return dt(c)&&(as(c),m||Nl(e,c.dom,l)),n.map((e=>({rng:e,effect:l})))})):C.none()},c=l(ul,(t=>!n(e)||pa(t).rows>1),g,Bl),d=l(ml,(t=>!n(e)||pa(t).columns>1),g,Bl);return{deleteRow:c,deleteColumn:d,insertRowsBefore:l(il,x,g,Bl),insertRowsAfter:l(ll,x,g,Bl),insertColumnsBefore:l(cl,x,s,Bl),insertColumnsAfter:l(dl,x,s,Bl),mergeCells:l(wl,x,g,Bl),unmergeCells:l(xl,x,g,Bl),pasteColsBefore:l(Sl,x,g,Bl),pasteColsAfter:l(kl,x,g,Bl),pasteRowsBefore:l(_l,x,g,Bl),pasteRowsAfter:l(Ol,x,g,Bl),pasteCells:l(Cl,x,g,Ll),makeCellsHeader:l(vl,x,g,Bl),unmakeCellsHeader:l(yl,x,g,Bl),makeColumnsHeader:l(gl,x,g,Bl),unmakeColumnsHeader:l(pl,x,g,Bl),makeRowsHeader:l(hl,x,g,Bl),makeRowsBody:l(fl,x,g,Bl),makeRowsFooter:l(bl,x,g,Bl),getTableRowType:Dl,getTableCellType:El,getTableColType:Tl}},Pl=(e,t,o)=>{const n=zt(e,t,1);1===o||n<=1?we(e,t):fe(e,t,Math.min(o,n))},Fl=(e,t)=>o=>{const n=o.column+o.colspan-1,r=o.column;return n>=e&&r{const o=sn.fromTable(e);return Ua(o,t).map((e=>{const t=e[e.length-1],n=e[0].column,r=t.column+t.colspan,s=((e,t,o)=>{if(sn.hasColumns(e)){const n=N(sn.justColumns(e),Fl(t,o)),r=D(n,(e=>{const n=Xe(e.element);return Pl(n,"span",o-t),n})),s=Se.fromTag("colgroup");return $e(s,r),[s]}return[]})(o,n,r),a=((e,t,o)=>D(e.all,(e=>{const n=N(e.cells,Fl(t,o)),r=D(n,(e=>{const n=Xe(e.element);return Pl(n,"colspan",o-t),n})),s=Se.fromTag("tr");return $e(s,r),s})))(o,n,r);return[...s,...a]}))},Vl=(e,t,o)=>{const n=sn.fromTable(e);return Za(n,t).bind((e=>{const t=Ha(n,o,!1),r=Xo(t).rows.slice(e[0].row,e[e.length-1].row+e[e.length-1].rowspan),s=P(r,(e=>{const t=N(e.cells,(e=>!e.isLocked));return t.length>0?[{...e,cells:t}]:[]})),a=Ia(s);return _t(a.length>0,a)})).map((e=>(e=>D(e,(e=>{const t=Ye(e.element);return A(e.cells,(e=>{const o=Xe(e.element);Aa(o,"colspan",e.colspan,1),Aa(o,"rowspan",e.rowspan,1),Ze(t,o)})),t})))(e)))},Zl=bi([{invalid:["raw"]},{pixels:["value"]},{percent:["value"]}]),Ul=(e,t,o)=>{const n=o.substring(0,o.length-e.length),r=parseFloat(n);return n===r.toString()?t(r):Zl.invalid(o)},jl={...Zl,from:e=>Dt(e,"%")?Ul("%",Zl.percent,e):Dt(e,"px")?Ul("px",Zl.pixels,e):Zl.invalid(e)},$l=(e,t,o)=>e.fold((()=>t),(e=>((e,t,o)=>{const n=o/t;return D(e,(e=>jl.from(e).fold((()=>e),(e=>e*n+"px"),(e=>e/100*o+"px"))))})(t,o,e)),(e=>((e,t)=>D(e,(e=>jl.from(e).fold((()=>e),(e=>e/t*100+"%"),(e=>e+"%")))))(t,o))),Wl=(e,t,o)=>{const n=jl.from(o),r=F(e,(e=>"0px"===e))?((e,t)=>{const o=e.fold((()=>p("")),(e=>p(e/t+"px")),(()=>p(100/t+"%")));return E(t,o)})(n,e.length):$l(n,e,t);return Kl(r)},ql=(e,t)=>0===e.length?t:R(e,((e,t)=>jl.from(t).fold(p(0),h,h)+e),0),Gl=(e,t)=>jl.from(e).fold(p(e),(e=>e+t+"px"),(e=>e+t+"%")),Kl=e=>{if(0===e.length)return e;const t=R(e,((e,t)=>{const o=jl.from(t).fold((()=>({value:t,remainder:0})),(e=>((e,t)=>{const o=Math.floor(e);return{value:o+t,remainder:e-o}})(e,"px")),(e=>({value:e+"%",remainder:0})));return{output:[o.value].concat(e.output),remainder:e.remainder+o.remainder}}),{output:[],remainder:0}),o=t.output;return o.slice(0,o.length-1).concat([Gl(o[o.length-1],Math.round(t.remainder))])},Yl=jl.from,Xl=e=>Yl(e).fold(p("px"),p("px"),p("%")),Jl=(e,t,o)=>{const n=sn.fromTable(e),r=n.all,s=sn.justCells(n),a=sn.justColumns(n);t.each((t=>{const o=Xl(t),r=zo(e),i=((e,t)=>sr(e,t,or,ar))(n,e),l=Wl(i,r,t);sn.hasColumns(n)?((e,t,o)=>{A(t,((t,n)=>{const r=ql([e[n]],$t());Bt(t.element,"width",r+o)}))})(l,a,o):((e,t,o)=>{A(t,(t=>{const n=e.slice(t.column,t.colspan+t.column),r=ql(n,$t());Bt(t.element,"width",r+o)}))})(l,s,o),Bt(e,"width",t)})),o.each((t=>{const o=Xl(t),a=pn(e),i=((e,t,o)=>lr(e,t,o,nr,ar))(n,e,Nn);((e,t,o,n)=>{A(o,(t=>{const o=e.slice(t.row,t.rowspan+t.row),r=ql(o,Wt());Bt(t.element,"height",r+n)})),A(t,((t,o)=>{Bt(t.element,"height",e[o])}))})(Wl(i,a,t),r,s,o),Bt(e,"height",t)}))},Ql=e=>Gn(e).exists((e=>Pn.test(e))),ec=e=>Gn(e).exists((e=>Fn.test(e))),tc=e=>Gn(e).isNone(),oc=e=>{we(e,"width")},nc=e=>{const t=Qn(e);Jl(e,C.some(t),C.none()),oc(e)},rc=e=>{const t=(e=>zo(e)+"px")(e);Jl(e,C.some(t),C.none()),oc(e)},sc=e=>{Ft(e,"width");const t=Xt(e),o=t.length>0?t:Yt(e);A(o,(e=>{Ft(e,"width"),oc(e)})),oc(e)},ac={styles:{"border-collapse":"collapse",width:"100%"},attributes:{border:"1"},colGroups:!1},ic=e=>{const t=Se.fromTag("colgroup");return E(e,(()=>Ze(t,Se.fromTag("col")))),t},lc=(e,t,o,n)=>E(e,(e=>((e,t,o,n)=>{const r=Se.fromTag("tr");for(let s=0;s{e.selection.select(t.dom,!0),e.selection.collapse(!0)},dc=(e,t,o,n,s)=>{const a=Qr(e),i={styles:a,attributes:Jr(e),colGroups:es(e)};return e.undoManager.ignore((()=>{const r=((e,t,o,n,r,s=ac)=>{const a=Se.fromTag("table"),i="cells"!==r;Lt(a,s.styles),be(a,s.attributes),s.colGroups&&Ze(a,ic(t));const l=Math.min(e,o);if(i&&o>0){const e=Se.fromTag("thead");Ze(a,e);const s=lc(o,t,"sectionCells"===r?l:0,n);$e(e,s)}const c=Se.fromTag("tbody");Ze(a,c);const d=lc(i?e-l:e,t,i?0:o,n);return $e(c,d),a})(o,t,s,n,Vr(e),i);fe(r,"data-mce-id","__mce");const a=(e=>{const t=Se.fromTag("div"),o=Se.fromDom(e.dom.cloneNode(!0));return Ze(t,o),(e=>e.dom.innerHTML)(t)})(r);e.insertContent(a),e.addVisual()})),xt(rs(e),'table[data-mce-id="__mce"]').map((t=>(qr(e)?rc(t):Gr(e)?sc(t):(Wr(e)||(e=>r(e)&&-1!==e.indexOf("%"))(a.width))&&nc(t),as(t),we(t,"data-mce-id"),((e,t)=>{A(ht(t,"tr"),(t=>{Al(e,t.dom),A(ht(t,"th,td"),(t=>{Ml(e,t.dom)}))}))})(e,t),((e,t)=>{xt(t,"td,th").each(b(cc,e))})(e,t),t.dom))).getOrNull()};var mc=tinymce.util.Tools.resolve("tinymce.FakeClipboard");const uc="x-tinymce/dom-table-",gc=uc+"rows",pc=uc+"columns",hc=e=>{const t=mc.FakeClipboardItem(e);mc.write([t])},fc=e=>{var t;const o=null!==(t=mc.read())&&void 0!==t?t:[];return j(o,(t=>C.from(t.getType(e))))},bc=e=>{fc(e).isSome()&&mc.clear()},vc=e=>{e.fold(wc,(e=>hc({[gc]:e})))},yc=()=>fc(gc),wc=()=>bc(gc),xc=e=>{e.fold(Sc,(e=>hc({[pc]:e})))},Cc=()=>fc(pc),Sc=()=>bc(pc),kc=e=>Ys(is(e),ss(e)).filter(ds),_c=(e,t)=>{const o=ss(e),n=e=>Jt(e,o),a=t=>(e=>Xs(is(e),ss(e)).filter(ds))(e).bind((e=>n(e).map((o=>t(o,e))))),i=t=>{e.focus()},l=(t,o=!1)=>a(((n,r)=>{const s=Gs(Js(e),n,r);t(n,s,o).each(i)})),c=()=>a(((t,o)=>{const n=Gs(Js(e),t,o),r=Lr(g,Se.fromDom(e.getDoc()),C.none());return Vl(t,n,r)})),d=()=>a(((t,o)=>{const n=Gs(Js(e),t,o);return zl(t,n)})),m=(t,o)=>o().each((o=>{const n=D(o,(e=>Xe(e)));a(((o,r)=>{const s=Hr(Se.fromDom(e.getDoc())),a=((e,t,o,n)=>({selection:Hs(e),clipboard:o,generators:n}))(Js(e),0,n,s);t(o,a).each(i)}))})),p=e=>(t,o)=>((e,t)=>Q(e,t)?C.from(e[t]):C.none())(o,"type").each((t=>{l(e(t),o.no_events)}));q({mceTableSplitCells:()=>l(t.unmergeCells),mceTableMergeCells:()=>l(t.mergeCells),mceTableInsertRowBefore:()=>l(t.insertRowsBefore),mceTableInsertRowAfter:()=>l(t.insertRowsAfter),mceTableInsertColBefore:()=>l(t.insertColumnsBefore),mceTableInsertColAfter:()=>l(t.insertColumnsAfter),mceTableDeleteCol:()=>l(t.deleteColumn),mceTableDeleteRow:()=>l(t.deleteRow),mceTableCutCol:()=>d().each((e=>{xc(e),l(t.deleteColumn)})),mceTableCutRow:()=>c().each((e=>{vc(e),l(t.deleteRow)})),mceTableCopyCol:()=>d().each((e=>xc(e))),mceTableCopyRow:()=>c().each((e=>vc(e))),mceTablePasteColBefore:()=>m(t.pasteColsBefore,Cc),mceTablePasteColAfter:()=>m(t.pasteColsAfter,Cc),mceTablePasteRowBefore:()=>m(t.pasteRowsBefore,yc),mceTablePasteRowAfter:()=>m(t.pasteRowsAfter,yc),mceTableDelete:()=>kc(e).each((t=>{Jt(t,o).filter(v(o)).each((t=>{const o=Se.fromText("");if(ze(t,o),qe(t),e.dom.isEmpty(e.getBody()))e.setContent(""),e.selection.setCursorLocation();else{const t=e.dom.createRng();t.setStart(o.dom,0),t.setEnd(o.dom,0),e.selection.setRng(t),e.nodeChanged()}}))})),mceTableCellToggleClass:(t,o)=>{a((t=>{const n=Js(e),r=F(n,(t=>e.formatter.match("tablecellclass",{value:o},t.dom))),s=r?e.formatter.remove:e.formatter.apply;A(n,(e=>s("tablecellclass",{value:o},e.dom))),Nl(e,t.dom,Rl)}))},mceTableToggleClass:(t,o)=>{a((t=>{e.formatter.toggle("tableclass",{value:o},t.dom),Nl(e,t.dom,Rl)}))},mceTableToggleCaption:()=>{kc(e).each((t=>{Jt(t,o).each((o=>{wt(o,"caption").fold((()=>{const t=Se.fromTag("caption");Ze(t,Se.fromText("Caption")),((e,t,o)=>{Pe(e,o).fold((()=>{Ze(e,t)}),(e=>{Fe(e,t)}))})(o,t,0),e.selection.setCursorLocation(t.dom,0)}),(n=>{pe("caption")(t)&&Oe("td",o).each((t=>e.selection.setCursorLocation(t.dom,0))),qe(n)})),Nl(e,o.dom,Bl)}))}))},mceTableSizingMode:(t,n)=>(t=>kc(e).each((n=>{Gr(e)||qr(e)||Wr(e)||Jt(n,o).each((o=>{"relative"!==t||Ql(o)?"fixed"!==t||ec(o)?"responsive"!==t||tc(o)||sc(o):rc(o):nc(o),as(o),Nl(e,o.dom,Bl)}))})))(n),mceTableCellType:p((e=>"th"===e?t.makeCellsHeader:t.unmakeCellsHeader)),mceTableColType:p((e=>"th"===e?t.makeColumnsHeader:t.unmakeColumnsHeader)),mceTableRowType:p((e=>{switch(e){case"header":return t.makeRowsHeader;case"footer":return t.makeRowsFooter;default:return t.makeRowsBody}}))},((t,o)=>e.addCommand(o,t))),e.addCommand("mceInsertTable",((t,o)=>{((e,t,o,n={})=>{const r=e=>u(e)&&e>0;if(r(t)&&r(o)){const r=n.headerRows||0,s=n.headerColumns||0;return dc(e,o,t,s,r)}console.error("Invalid values for mceInsertTable - rows and columns values are required to insert a table.")})(e,o.rows,o.columns,o.options)})),e.addCommand("mceTableApplyCellStyle",((t,o)=>{const a=e=>"tablecell"+e.toLowerCase().replace("-","");if(!s(o))return;const i=N(Js(e),ds);if(0===i.length)return;const l=Y(o,((t,o)=>e.formatter.has(a(o))&&r(t)));(e=>{for(const t in e)if(W.call(e,t))return!1;return!0})(l)||(q(l,((t,o)=>{const n=a(o);A(i,(o=>{""===t?e.formatter.remove(n,{value:null},o.dom,!0):e.formatter.apply(n,{value:t},o.dom)}))})),n(i[0]).each((t=>Nl(e,t.dom,Rl))))}))},Oc=bi([{before:["element"]},{on:["element","offset"]},{after:["element"]}]),Tc={before:Oc.before,on:Oc.on,after:Oc.after,cata:(e,t,o,n)=>e.fold(t,o,n),getStart:e=>e.fold(h,h,h)},Ec=(e,t)=>({selection:e,kill:t}),Dc=(e,t)=>{const o=e.document.createRange();return o.selectNode(t.dom),o},Ac=(e,t)=>{const o=e.document.createRange();return Mc(o,t),o},Mc=(e,t)=>e.selectNodeContents(t.dom),Nc=(e,t,o)=>{const n=e.document.createRange();var r;return r=n,t.fold((e=>{r.setStartBefore(e.dom)}),((e,t)=>{r.setStart(e.dom,t)}),(e=>{r.setStartAfter(e.dom)})),((e,t)=>{t.fold((t=>{e.setEndBefore(t.dom)}),((t,o)=>{e.setEnd(t.dom,o)}),(t=>{e.setEndAfter(t.dom)}))})(n,o),n},Rc=(e,t,o,n,r)=>{const s=e.document.createRange();return s.setStart(t.dom,o),s.setEnd(n.dom,r),s},Bc=e=>({left:e.left,top:e.top,right:e.right,bottom:e.bottom,width:e.width,height:e.height}),Lc=bi([{ltr:["start","soffset","finish","foffset"]},{rtl:["start","soffset","finish","foffset"]}]),Hc=(e,t,o)=>t(Se.fromDom(o.startContainer),o.startOffset,Se.fromDom(o.endContainer),o.endOffset),Ic=(e,t)=>{const o=((e,t)=>t.match({domRange:e=>({ltr:p(e),rtl:C.none}),relative:(t,o)=>({ltr:ro((()=>Nc(e,t,o))),rtl:ro((()=>C.some(Nc(e,o,t))))}),exact:(t,o,n,r)=>({ltr:ro((()=>Rc(e,t,o,n,r))),rtl:ro((()=>C.some(Rc(e,n,r,t,o))))})}))(e,t);return((e,t)=>{const o=t.ltr();if(o.collapsed)return t.rtl().filter((e=>!1===e.collapsed)).map((e=>Lc.rtl(Se.fromDom(e.endContainer),e.endOffset,Se.fromDom(e.startContainer),e.startOffset))).getOrThunk((()=>Hc(0,Lc.ltr,o)));return Hc(0,Lc.ltr,o)})(0,o)},Pc=(e,t)=>Ic(e,t).match({ltr:(t,o,n,r)=>{const s=e.document.createRange();return s.setStart(t.dom,o),s.setEnd(n.dom,r),s},rtl:(t,o,n,r)=>{const s=e.document.createRange();return s.setStart(n.dom,r),s.setEnd(t.dom,o),s}});Lc.ltr,Lc.rtl;const Fc=(e,t,o,n)=>({start:e,soffset:t,finish:o,foffset:n}),zc=(e,t,o,n)=>({start:Tc.on(e,t),finish:Tc.on(o,n)}),Vc=(e,t)=>{const o=Pc(e,t);return Fc(Se.fromDom(o.startContainer),o.startOffset,Se.fromDom(o.endContainer),o.endOffset)},Zc=zc,Uc=(e,t,o,n,r)=>Te(o,n)?C.none():As(o,n,t).bind((t=>{const n=t.boxes.getOr([]);return n.length>1?(r(e,n,t.start,t.finish),C.some(Ec(C.some(Zc(o,0,o,Cr(o))),!0))):C.none()})),jc=(e,t)=>({item:e,mode:t}),$c=(e,t,o,n=Wc)=>e.property().parent(t).map((e=>jc(e,n))),Wc=(e,t,o,n=qc)=>o.sibling(e,t).map((e=>jc(e,n))),qc=(e,t,o,n=qc)=>{const r=e.property().children(t);return o.first(r).map((e=>jc(e,n)))},Gc=[{current:$c,next:Wc,fallback:C.none()},{current:Wc,next:qc,fallback:C.some($c)},{current:qc,next:qc,fallback:C.some(Wc)}],Kc=(e,t,o,n,r=Gc)=>L(r,(e=>e.current===o)).bind((o=>o.current(e,t,n,o.next).orThunk((()=>o.fallback.bind((o=>Kc(e,t,o,n))))))),Yc=()=>({sibling:(e,t)=>e.query().prevSibling(t),first:e=>e.length>0?C.some(e[e.length-1]):C.none()}),Xc=()=>({sibling:(e,t)=>e.query().nextSibling(t),first:e=>e.length>0?C.some(e[0]):C.none()}),Jc=(e,t,o,n,r,s)=>Kc(e,t,n,r).bind((t=>s(t.item)?C.none():o(t.item)?C.some(t.item):Jc(e,t.item,o,t.mode,r,s))),Qc=e=>t=>0===e.property().children(t).length,ed=(e,t,o,n)=>Jc(e,t,o,Wc,Yc(),n),td=(e,t,o,n)=>Jc(e,t,o,Wc,Xc(),n),od=Cs(),nd=(e,t)=>((e,t,o)=>ed(e,t,Qc(e),o))(od,e,t),rd=(e,t)=>((e,t,o)=>td(e,t,Qc(e),o))(od,e,t),sd=bi([{none:["message"]},{success:[]},{failedUp:["cell"]},{failedDown:["cell"]}]),ad=e=>Ct(e,"tr"),id={...sd,verify:(e,t,o,n,r,s,a)=>Ct(n,"td,th",a).bind((o=>Ct(t,"td,th",a).map((t=>Te(o,t)?Te(n,o)&&Cr(o)===r?s(t):sd.none("in same cell"):Es(ad,[o,t]).fold((()=>((e,t,o)=>{const n=e.getRect(t),r=e.getRect(o);return r.right>n.left&&r.lefts(t))))))).getOr(sd.none("default")),cata:(e,t,o,n,r)=>e.fold(t,o,n,r)},ld=(e,t)=>H(e,b(Te,t)),cd=pe("br"),dd=(e,t,o)=>t(e,o).bind((e=>me(e)&&0===yr(e).trim().length?dd(e,t,o):C.some(e))),md=(e,t,o,n)=>((e,t)=>Pe(e,t).filter(cd).orThunk((()=>Pe(e,t-1).filter(cd))))(t,o).bind((t=>n.traverse(t).fold((()=>dd(t,n.gather,e).map(n.relative)),(e=>(e=>Ne(e).bind((t=>{const o=Ie(t);return ld(o,e).map((n=>((e,t,o,n)=>({parent:e,children:t,element:o,index:n}))(t,o,e,n)))})))(e).map((e=>Tc.on(e.parent,e.index))))))),ud=(e,t,o,n)=>{const r=cd(t)?((e,t,o)=>o.traverse(t).orThunk((()=>dd(t,o.gather,e))).map(o.relative))(e,t,n):md(e,t,o,n);return r.map((e=>({start:e,finish:e})))},gd=(e,t)=>({left:e.left,top:e.top+t,right:e.right,bottom:e.bottom+t}),pd=(e,t)=>({left:e.left,top:e.top-t,right:e.right,bottom:e.bottom-t}),hd=(e,t,o)=>({left:e.left+t,top:e.top+o,right:e.right+t,bottom:e.bottom+o}),fd=e=>({left:e.left,top:e.top,right:e.right,bottom:e.bottom}),bd=(e,t)=>C.some(e.getRect(t)),vd=(e,t,o)=>de(t)?bd(e,t).map(fd):me(t)?((e,t,o)=>o>=0&&o0?e.getRangedRect(t,o-1,t,o):C.none())(e,t,o).map(fd):C.none(),yd=(e,t)=>de(t)?bd(e,t).map(fd):me(t)?e.getRangedRect(t,0,t,Cr(t)).map(fd):C.none(),wd=bi([{none:[]},{retry:["caret"]}]),xd=(e,t,o)=>vt(t,Ii).fold(w,(t=>yd(e,t).exists((e=>((e,t)=>e.leftt.right)(o,e))))),Cd={point:e=>e.bottom,adjuster:(e,t,o,n,r)=>{const s=gd(r,5);return Math.abs(o.bottom-n.bottom)<1||o.top>r.bottom?wd.retry(s):o.top===r.bottom?wd.retry(gd(r,1)):xd(e,t,r)?wd.retry(hd(s,5,0)):wd.none()},move:gd,gather:rd},Sd=(e,t,o,n,r)=>0===r?C.some(n):((e,t,o)=>e.elementFromPoint(t,o).filter((e=>"table"===se(e))).isSome())(e,n.left,t.point(n))?((e,t,o,n,r)=>Sd(e,t,o,t.move(n,5),r))(e,t,o,n,r-1):e.situsFromPoint(n.left,t.point(n)).bind((s=>s.start.fold(C.none,(s=>yd(e,s).bind((a=>t.adjuster(e,s,a,o,n).fold(C.none,(n=>Sd(e,t,o,n,r-1))))).orThunk((()=>C.some(n)))),C.none))),kd=(e,t,o)=>{const n=e.move(o,5),r=Sd(t,e,o,n,100).getOr(n);return((e,t,o)=>e.point(t)>o.getInnerHeight()?C.some(e.point(t)-o.getInnerHeight()):e.point(t)<0?C.some(-e.point(t)):C.none())(e,r,t).fold((()=>t.situsFromPoint(r.left,e.point(r))),(o=>(t.scrollBy(0,o),t.situsFromPoint(r.left,e.point(r)-o))))},_d={tryUp:b(kd,{point:e=>e.top,adjuster:(e,t,o,n,r)=>{const s=pd(r,5);return Math.abs(o.top-n.top)<1||o.bottome.getSelection().bind((n=>ud(t,n.finish,n.foffset,o).fold((()=>C.some(ea(n.finish,n.foffset))),(r=>{const s=e.fromSitus(r);return(e=>id.cata(e,(e=>C.none()),(()=>C.none()),(e=>C.some(ea(e,0))),(e=>C.some(ea(e,Cr(e))))))(id.verify(e,n.finish,n.foffset,s.finish,s.foffset,o.failure,t))})))),Td=(e,t,o,n,r,s)=>0===s?C.none():Ad(e,t,o,n,r).bind((a=>{const i=e.fromSitus(a),l=id.verify(e,o,n,i.finish,i.foffset,r.failure,t);return id.cata(l,(()=>C.none()),(()=>C.some(a)),(a=>Te(o,a)&&0===n?Ed(e,o,n,pd,r):Td(e,t,a,0,r,s-1)),(a=>Te(o,a)&&n===Cr(a)?Ed(e,o,n,gd,r):Td(e,t,a,Cr(a),r,s-1)))})),Ed=(e,t,o,n,r)=>vd(e,t,o).bind((t=>Dd(e,r,n(t,_d.getJumpSize())))),Dd=(e,t,o)=>{const n=Bo().browser;return n.isChromium()||n.isSafari()||n.isFirefox()?t.retry(e,o):C.none()},Ad=(e,t,o,n,r)=>vd(e,o,n).bind((t=>Dd(e,r,t))),Md=(e,t)=>{return bt(e,(e=>Ne(e).exists((e=>Te(e,t)))),o).isSome();var o},Nd=(e,t,o,n,r)=>Ct(n,"td,th",t).bind((n=>Ct(n,"table",t).bind((s=>Md(r,s)?((e,t,o)=>Od(e,t,o).bind((n=>Td(e,t,n.element,n.offset,o,20).map(e.fromSitus))))(e,t,o).bind((e=>Ct(e.finish,"td,th",t).map((t=>({start:n,finish:t,range:e}))))):C.none())))),Rd=(e,t,o,n,r,s)=>s(n,t).orThunk((()=>Nd(e,t,o,n,r).map((e=>{const t=e.range;return Ec(C.some(Zc(t.start,t.soffset,t.finish,t.foffset)),!0)})))),Bd=(e,t)=>Ct(e,"tr",t).bind((e=>Ct(e,"table",t).bind((o=>{const n=ht(o,"tr");return Te(e,n[0])?((e,t,o)=>ed(od,e,t,o))(o,(e=>Or(e).isSome()),t).map((e=>{const t=Cr(e);return Ec(C.some(Zc(e,t,e,t)),!0)})):C.none()})))),Ld=(e,t)=>Ct(e,"tr",t).bind((e=>Ct(e,"table",t).bind((o=>{const n=ht(o,"tr");return Te(e,n[n.length-1])?((e,t,o)=>td(od,e,t,o))(o,(e=>_r(e).isSome()),t).map((e=>Ec(C.some(Zc(e,0,e,0)),!0))):C.none()})))),Hd=(e,t,o,n,r,s,a)=>Nd(e,o,n,r,s).bind((e=>Uc(t,o,e.start,e.finish,a))),Id=e=>{let t=e;return{get:()=>t,set:e=>{t=e}}},Pd=()=>{const e=(e=>{const t=Id(C.none()),o=()=>t.get().each(e);return{clear:()=>{o(),t.set(C.none())},isSet:()=>t.get().isSome(),get:()=>t.get(),set:e=>{o(),t.set(C.some(e))}}})(g);return{...e,on:t=>e.get().each(t)}},Fd=(e,t)=>Ct(e,"td,th",t),zd=e=>Re(e).exists(os),Vd={traverse:He,gather:rd,relative:Tc.before,retry:_d.tryDown,failure:id.failedDown},Zd={traverse:Le,gather:nd,relative:Tc.before,retry:_d.tryUp,failure:id.failedUp},Ud=e=>t=>t===e,jd=Ud(38),$d=Ud(40),Wd=e=>e>=37&&e<=40,qd={isBackward:Ud(37),isForward:Ud(39)},Gd={isBackward:Ud(39),isForward:Ud(37)},Kd=bi([{domRange:["rng"]},{relative:["startSitu","finishSitu"]},{exact:["start","soffset","finish","foffset"]}]),Yd={domRange:Kd.domRange,relative:Kd.relative,exact:Kd.exact,exactFromRange:e=>Kd.exact(e.start,e.soffset,e.finish,e.foffset),getWin:e=>{const t=(e=>e.match({domRange:e=>Se.fromDom(e.startContainer),relative:(e,t)=>Tc.getStart(e),exact:(e,t,o,n)=>e}))(e);return o=t,Se.fromDom(Me(o).dom.defaultView);var o},range:Fc},Xd=(e,t,o)=>{var n,r;return C.from(null===(r=(n=e.dom).caretPositionFromPoint)||void 0===r?void 0:r.call(n,t,o)).bind((t=>{if(null===t.offsetNode)return C.none();const o=e.dom.createRange();return o.setStart(t.offsetNode,t.offset),o.collapse(),C.some(o)}))},Jd=(e,t,o)=>{var n,r;return C.from(null===(r=(n=e.dom).caretRangeFromPoint)||void 0===r?void 0:r.call(n,t,o))},Qd=document.caretPositionFromPoint?Xd:document.caretRangeFromPoint?Jd:C.none,em=(e,t)=>{const o=se(e);return"input"===o?Tc.after(e):O(["br","img"],o)?0===t?Tc.before(e):Tc.after(e):Tc.on(e,t)},tm=(e,t,o,n)=>{const r=((e,t,o,n)=>{const r=Ae(e).dom.createRange();return r.setStart(e.dom,t),r.setEnd(o.dom,n),r})(e,t,o,n),s=Te(e,o)&&t===n;return r.collapsed&&!s},om=e=>C.from(e.getSelection()),nm=(e,t)=>{om(e).each((e=>{e.removeAllRanges(),e.addRange(t)}))},rm=(e,t,o,n,r)=>{const s=Rc(e,t,o,n,r);nm(e,s)},sm=(e,t)=>Ic(e,t).match({ltr:(t,o,n,r)=>{rm(e,t,o,n,r)},rtl:(t,o,n,r)=>{om(e).each((s=>{if(s.setBaseAndExtent)s.setBaseAndExtent(t.dom,o,n.dom,r);else if(s.extend)try{((e,t,o,n,r,s)=>{t.collapse(o.dom,n),t.extend(r.dom,s)})(0,s,t,o,n,r)}catch(s){rm(e,n,r,t,o)}else rm(e,n,r,t,o)}))}}),am=(e,t,o,n,r)=>{const s=((e,t,o,n)=>{const r=em(e,t),s=em(o,n);return Yd.relative(r,s)})(t,o,n,r);sm(e,s)},im=(e,t,o)=>{const n=((e,t)=>{const o=e.fold(Tc.before,em,Tc.after),n=t.fold(Tc.before,em,Tc.after);return Yd.relative(o,n)})(t,o);sm(e,n)},lm=e=>{if(e.rangeCount>0){const t=e.getRangeAt(0),o=e.getRangeAt(e.rangeCount-1);return C.some(Fc(Se.fromDom(t.startContainer),t.startOffset,Se.fromDom(o.endContainer),o.endOffset))}return C.none()},cm=e=>{if(null===e.anchorNode||null===e.focusNode)return lm(e);{const t=Se.fromDom(e.anchorNode),o=Se.fromDom(e.focusNode);return tm(t,e.anchorOffset,o,e.focusOffset)?C.some(Fc(t,e.anchorOffset,o,e.focusOffset)):lm(e)}},dm=(e,t,o=!0)=>{const n=(o?Ac:Dc)(e,t);nm(e,n)},mm=e=>(e=>om(e).filter((e=>e.rangeCount>0)).bind(cm))(e).map((e=>Yd.exact(e.start,e.soffset,e.finish,e.foffset))),um=(e,t)=>(e=>{const t=e.getClientRects(),o=t.length>0?t[0]:e.getBoundingClientRect();return o.width>0||o.height>0?C.some(o).map(Bc):C.none()})(Pc(e,t)),gm=(e,t,o)=>((e,t,o)=>{const n=Se.fromDom(e.document);return Qd(n,t,o).map((e=>Fc(Se.fromDom(e.startContainer),e.startOffset,Se.fromDom(e.endContainer),e.endOffset)))})(e,t,o),pm=e=>({elementFromPoint:(t,o)=>Se.fromPoint(Se.fromDom(e.document),t,o),getRect:e=>e.dom.getBoundingClientRect(),getRangedRect:(t,o,n,r)=>{const s=Yd.exact(t,o,n,r);return um(e,s)},getSelection:()=>mm(e).map((t=>Vc(e,t))),fromSitus:t=>{const o=Yd.relative(t.start,t.finish);return Vc(e,o)},situsFromPoint:(t,o)=>gm(e,t,o).map((e=>zc(e.start,e.soffset,e.finish,e.foffset))),clearSelection:()=>{(e=>{om(e).each((e=>e.removeAllRanges()))})(e)},collapseSelection:(t=!1)=>{mm(e).each((o=>o.fold((e=>e.collapse(t)),((o,n)=>{const r=t?o:n;im(e,r,r)}),((o,n,r,s)=>{const a=t?o:r,i=t?n:s;am(e,a,i,a,i)}))))},setSelection:t=>{am(e,t.start,t.soffset,t.finish,t.foffset)},setRelativeSelection:(t,o)=>{im(e,t,o)},selectNode:t=>{dm(e,t,!1)},selectContents:t=>{dm(e,t)},getInnerHeight:()=>e.innerHeight,getScrollY:()=>(e=>{const t=void 0!==e?e.dom:document,o=t.body.scrollLeft||t.documentElement.scrollLeft,n=t.body.scrollTop||t.documentElement.scrollTop;return vn(o,n)})(Se.fromDom(e.document)).top,scrollBy:(t,o)=>{((e,t,o)=>{const n=(void 0!==o?o.dom:document).defaultView;n&&n.scrollBy(e,t)})(t,o,Se.fromDom(e.document))}}),hm=(e,t)=>({rows:e,cols:t}),fm=(e,t,o,n)=>{const r=((e,t,o,n)=>{const r=Pd(),s=r.clear,a=s=>{r.on((r=>{n.clearBeforeUpdate(t),Fd(s.target,o).each((a=>{As(r,a,o).each((o=>{const r=o.boxes.getOr([]);if(1===r.length){const o=r[0],a="false"===ns(o),i=St(ts(s.target),o,Te);a&&i&&(n.selectRange(t,r,o,o),e.selectContents(o))}else r.length>1&&(n.selectRange(t,r,o.start,o.finish),e.selectContents(a))}))}))}))};return{clearstate:s,mousedown:e=>{n.clear(t),Fd(e.target,o).filter(zd).each(r.set)},mouseover:e=>{a(e)},mouseup:e=>{a(e),s()}}})(pm(e),t,o,n);return{clearstate:r.clearstate,mousedown:r.mousedown,mouseover:r.mouseover,mouseup:r.mouseup}},bm=e=>vt(e,ce).exists(os),vm=(e,t)=>bm(e)||bm(t),ym=(e,t,o,n)=>{const r=pm(e),s=()=>(n.clear(t),C.none());return{keydown:(e,a,i,l,c,d)=>{const m=e.raw,u=m.which,g=!0===m.shiftKey,p=Ms(t,n.selectedSelector).fold((()=>(Wd(u)&&!g&&n.clearBeforeUpdate(t),Wd(u)&&g&&!vm(a,l)?C.none:$d(u)&&g?b(Hd,r,t,o,Vd,l,a,n.selectRange):jd(u)&&g?b(Hd,r,t,o,Zd,l,a,n.selectRange):$d(u)?b(Rd,r,o,Vd,l,a,Ld):jd(u)?b(Rd,r,o,Zd,l,a,Bd):C.none)),(e=>{const o=o=>()=>{const s=j(o,(o=>((e,t,o,n,r)=>Rs(n,e,t,r.firstSelectedSelector,r.lastSelectedSelector).map((e=>(r.clearBeforeUpdate(o),r.selectRange(o,e.boxes,e.start,e.finish),e.boxes))))(o.rows,o.cols,t,e,n)));return s.fold((()=>Ns(t,n.firstSelectedSelector,n.lastSelectedSelector).map((e=>{const o=$d(u)||d.isForward(u)?Tc.after:Tc.before;return r.setRelativeSelection(Tc.on(e.first,0),o(e.table)),n.clear(t),Ec(C.none(),!0)}))),(e=>C.some(Ec(C.none(),!0))))};return Wd(u)&&g&&!vm(a,l)?C.none:$d(u)&&g?o([hm(1,0)]):jd(u)&&g?o([hm(-1,0)]):d.isBackward(u)&&g?o([hm(0,-1),hm(-1,0)]):d.isForward(u)&&g?o([hm(0,1),hm(1,0)]):Wd(u)&&!g?s:C.none}));return p()},keyup:(e,r,s,a,i)=>Ms(t,n.selectedSelector).fold((()=>{const l=e.raw,c=l.which;return!0===l.shiftKey&&Wd(c)&&vm(r,a)?((e,t,o,n,r,s,a)=>Te(o,r)&&n===s?C.none():Ct(o,"td,th",t).bind((o=>Ct(r,"td,th",t).bind((n=>Uc(e,t,o,n,a))))))(t,o,r,s,a,i,n.selectRange):C.none()}),C.none)}},wm=(e,t)=>{const o=ve(e,t);return void 0===o||""===o?[]:o.split(" ")},xm=e=>void 0!==e.dom.classList,Cm=(e,t)=>((e,t,o)=>{const n=wm(e,t).concat([o]);return fe(e,t,n.join(" ")),!0})(e,"class",t),Sm=(e,t)=>{xm(e)?e.dom.classList.add(t):Cm(e,t)},km=(e,t)=>xm(e)&&e.dom.classList.contains(t),_m=(e,t,o)=>{const n=t=>{we(t,e.selected),we(t,e.firstSelected),we(t,e.lastSelected)},r=t=>{fe(t,e.selected,"1")},s=e=>{a(e),o()},a=t=>{const o=ht(t,`${e.selectedSelector},${e.firstSelectedSelector},${e.lastSelectedSelector}`);A(o,n)};return{clearBeforeUpdate:a,clear:s,selectRange:(o,n,a,i)=>{s(o),A(n,r),fe(a,e.firstSelected,"1"),fe(i,e.lastSelected,"1"),t(n,a,i)},selectedSelector:e.selectedSelector,firstSelectedSelector:e.firstSelectedSelector,lastSelectedSelector:e.lastSelectedSelector}},Om=()=>({tag:"none"}),Tm=e=>({tag:"multiple",elements:e}),Em=e=>({tag:"single",element:e}),Dm=(e,t,o)=>{const n=sn.fromTable(e);return Za(n,t).map((e=>{const t=Ha(n,o,!1),{rows:r}=Xo(t),s=((e,t)=>{const o=e.slice(0,t[t.length-1].row+1),n=Ia(o);return P(n,(e=>{const o=e.cells.slice(0,t[t.length-1].column+1);return D(o,(e=>e.element))}))})(r,e),a=((e,t)=>{const o=e.slice(t[0].row+t[0].rowspan-1,e.length),n=Ia(o);return P(n,(e=>{const o=e.cells.slice(t[0].column+t[0].colspan-1,e.cells.length);return D(o,(e=>e.element))}))})(r,e);return{upOrLeftCells:s,downOrRightCells:a}}))},Am=e=>{const t=Se.fromDom((e=>{if(st()&&d(e.target)){const t=Se.fromDom(e.target);if(de(t)&&ct(t)&&e.composed&&e.composedPath){const t=e.composedPath();if(t)return Z(t)}}return C.from(e.target)})(e).getOr(e.target)),o=()=>e.stopPropagation(),n=()=>e.preventDefault(),r=(s=n,a=o,(...e)=>s(a.apply(null,e)));var s,a;return((e,t,o,n,r,s,a)=>({target:e,x:t,y:o,stop:n,prevent:r,kill:s,raw:a}))(t,e.clientX,e.clientY,o,n,r,e)},Mm=(e,t,o,n,r)=>{const s=((e,t)=>o=>{e(o)&&t(Am(o))})(o,n);return e.dom.addEventListener(t,s,r),{unbind:b(Nm,e,t,s,r)}},Nm=(e,t,o,n)=>{e.dom.removeEventListener(t,o,n)},Rm=x,Bm=(e,t,o)=>((e,t,o,n)=>Mm(e,t,o,n,!1))(e,t,Rm,o),Lm=Am,Hm=e=>!km(Se.fromDom(e.target),"ephox-snooker-resizer-bar"),Im=(e,t)=>{const o=((e,t,o)=>({get:()=>Bs(e(),o).fold((()=>t().fold(Om,Em)),Tm)}))((()=>Se.fromDom(e.getBody())),(()=>Xs(is(e),ss(e))),qs.selectedSelector),n=_m(qs,((t,o,n)=>{Jt(o).each((r=>{const s=zr(e),a=Lr(g,Se.fromDom(e.getDoc()),s),i=Js(e),l=Dm(r,{selection:i},a);((e,t,o,n,r)=>{e.dispatch("TableSelectionChange",{cells:t,start:o,finish:n,otherCells:r})})(e,t,o,n,l)}))}),(()=>(e=>{e.dispatch("TableSelectionClear")})(e)));e.on("init",(o=>{const r=e.getWin(),s=rs(e),a=ss(e),i=fm(r,s,a,n),l=ym(r,s,a,n),c=((e,t,o,n)=>{const r=pm(e);return(e,s)=>{n.clearBeforeUpdate(t),As(e,s,o).each((e=>{const o=e.boxes.getOr([]);n.selectRange(t,o,e.start,e.finish),r.selectContents(s),r.collapseSelection()}))}})(r,s,a,n);e.on("TableSelectorChange",(e=>c(e.start,e.finish)));const d=(t,o)=>{(e=>!0===e.raw.shiftKey)(t)&&(o.kill&&t.kill(),o.selection.each((t=>{const o=Yd.relative(t.start,t.finish),n=Pc(r,o);e.selection.setRng(n)})))},m=e=>0===e.button,u=(()=>{const e=Id(Se.fromDom(s)),t=Id(0);return{touchEnd:o=>{const n=Se.fromDom(o.target);if(pe("td")(n)||pe("th")(n)){const r=e.get(),s=t.get();Te(r,n)&&o.timeStamp-s<300&&(o.preventDefault(),c(n,n))}e.set(n),t.set(o.timeStamp)}}})();e.on("dragstart",(e=>{i.clearstate()})),e.on("mousedown",(e=>{m(e)&&Hm(e)&&i.mousedown(Lm(e))})),e.on("mouseover",(e=>{var t;void 0!==(t=e).buttons&&0==(1&t.buttons)||!Hm(e)||i.mouseover(Lm(e))})),e.on("mouseup",(e=>{m(e)&&Hm(e)&&i.mouseup(Lm(e))})),e.on("touchend",u.touchEnd),e.on("keyup",(t=>{const o=Lm(t);if(o.raw.shiftKey&&Wd(o.raw.which)){const t=e.selection.getRng(),n=Se.fromDom(t.startContainer),r=Se.fromDom(t.endContainer);l.keyup(o,n,t.startOffset,r,t.endOffset).each((e=>{d(o,e)}))}})),e.on("keydown",(o=>{const n=Lm(o);t.hide();const r=e.selection.getRng(),s=Se.fromDom(r.startContainer),a=Se.fromDom(r.endContainer),i=mn(qd,Gd)(Se.fromDom(e.selection.getStart()));l.keydown(n,s,r.startOffset,a,r.endOffset,i).each((e=>{d(n,e)})),t.show()})),e.on("NodeChange",(()=>{const t=e.selection,o=Se.fromDom(t.getStart()),r=Se.fromDom(t.getEnd());Es(Jt,[o,r]).fold((()=>n.clear(s)),g)}))})),e.on("PreInit",(()=>{e.serializer.addTempAttr(qs.firstSelected),e.serializer.addTempAttr(qs.lastSelected)}));return{getSelectedCells:()=>((e,t,o,n)=>{switch(e.tag){case"none":return t();case"single":return n(e.element);case"multiple":return o(e.elements)}})(o.get(),p([]),(e=>D(e,(e=>e.dom))),(e=>[e.dom])),clearSelectedCells:e=>n.clear(Se.fromDom(e))}},Pm=e=>{let t=[];return{bind:e=>{if(void 0===e)throw new Error("Event bind error: undefined handler");t.push(e)},unbind:e=>{t=N(t,(t=>t!==e))},trigger:(...o)=>{const n={};A(e,((e,t)=>{n[e]=o[t]})),A(t,(e=>{e(n)}))}}},Fm=e=>({registry:G(e,(e=>({bind:e.bind,unbind:e.unbind}))),trigger:G(e,(e=>e.trigger))}),zm=e=>e.slice(0).sort(),Vm=(e,t,o)=>{if(0===t.length)throw new Error("You must specify at least one required field.");return((e,t)=>{if(!a(t))throw new Error("The "+e+" fields must be an array. Was: "+t+".");A(t,(t=>{if(!r(t))throw new Error("The value "+t+" in the "+e+" fields was not a string.")}))})("required",t),(e=>{const t=zm(e);L(t,((e,o)=>o{throw new Error("The field: "+e+" occurs more than once in the combined fields: ["+t.join(", ")+"].")}))})(t),n=>{const r=$(n);F(t,(e=>O(r,e)))||((e,t)=>{throw new Error("All required keys ("+zm(e).join(", ")+") were not specified. Specified keys were: "+zm(t).join(", ")+".")})(t,r),e(t,r);const s=N(t,(e=>!o.validate(n[e],e)));return s.length>0&&((e,t)=>{throw new Error("All values need to be of type: "+t+". Keys ("+zm(e).join(", ")+") were not.")})(s,o.label),n}},Zm=(e,t)=>{const o=N(t,(t=>!O(e,t)));o.length>0&&(e=>{throw new Error("Unsupported keys for object: "+zm(e).join(", "))})(o)},Um=e=>((e,t)=>Vm(e,t,{validate:m,label:"function"}))(Zm,e),jm=Um(["compare","extract","mutate","sink"]),$m=Um(["element","start","stop","destroy"]),Wm=Um(["forceDrop","drop","move","delayDrop"]),qm=()=>{let e=C.none();const t=Fm({move:Pm(["info"])});return{onEvent:(o,n)=>{n.extract(o).each((o=>{const r=((t,o)=>{const n=e.map((e=>t.compare(e,o)));return e=C.some(o),n})(n,o);r.each((e=>{t.trigger.move(e)}))}))},reset:()=>{e=C.none()},events:t.registry}},Gm=()=>{const e=(()=>{const e=Fm({move:Pm(["info"])});return{onEvent:g,reset:g,events:e.registry}})(),t=qm();let o=e;return{on:()=>{o.reset(),o=t},off:()=>{o.reset(),o=e},isOn:()=>o===t,onEvent:(e,t)=>{o.onEvent(e,t)},events:t.events}},Km=(e,t,o)=>{let n=!1;const r=Fm({start:Pm([]),stop:Pm([])}),s=Gm(),a=()=>{d.stop(),s.isOn()&&(s.off(),r.trigger.stop())},l=((e,t)=>{let o=null;const n=()=>{i(o)||(clearTimeout(o),o=null)};return{cancel:n,throttle:(...r)=>{n(),o=setTimeout((()=>{o=null,e.apply(null,r)}),t)}}})(a,200);s.events.move.bind((o=>{t.mutate(e,o.info)}));const c=e=>(...t)=>{n&&e.apply(null,t)},d=t.sink(Wm({forceDrop:a,drop:c(a),move:c((e=>{l.cancel(),s.onEvent(e,t)})),delayDrop:c(l.throttle)}),o);return{element:d.element,go:e=>{d.start(e),s.on(),r.trigger.start()},on:()=>{n=!0},off:()=>{n=!1},isActive:()=>n,destroy:()=>{d.destroy()},events:r.registry}},Ym=e=>{const t=e.replace(/\./g,"-");return{resolve:e=>t+"-"+e}},Xm=Ym("ephox-dragster").resolve;var Jm=jm({compare:(e,t)=>vn(t.left-e.left,t.top-e.top),extract:e=>C.some(vn(e.x,e.y)),sink:(e,t)=>{const o=(e=>{const t={layerClass:Xm("blocker"),...e},o=Se.fromTag("div");return fe(o,"role","presentation"),Lt(o,{position:"fixed",left:"0px",top:"0px",width:"100%",height:"100%"}),Sm(o,Xm("blocker")),Sm(o,t.layerClass),{element:p(o),destroy:()=>{qe(o)}}})(t),n=Bm(o.element(),"mousedown",e.forceDrop),r=Bm(o.element(),"mouseup",e.drop),s=Bm(o.element(),"mousemove",e.move),a=Bm(o.element(),"mouseout",e.delayDrop);return $m({element:o.element,start:e=>{Ze(e,o.element())},stop:()=>{qe(o.element())},destroy:()=>{o.destroy(),r.unbind(),s.unbind(),a.unbind(),n.unbind()}})},mutate:(e,t)=>{e.mutate(t.left,t.top)}});const Qm=Ym("ephox-snooker").resolve,eu=()=>{const e=Fm({drag:Pm(["xDelta","yDelta","target"])});let t=C.none();const o=(()=>{const e=Fm({drag:Pm(["xDelta","yDelta"])});return{mutate:(t,o)=>{e.trigger.drag(t,o)},events:e.registry}})();o.events.drag.bind((o=>{t.each((t=>{e.trigger.drag(o.xDelta,o.yDelta,t)}))}));return{assign:e=>{t=C.some(e)},get:()=>t,mutate:o.mutate,events:e.registry}},tu=Qm("resizer-bar"),ou=Qm("resizer-rows"),nu=Qm("resizer-cols"),ru=e=>{const t=ht(e.parent(),"."+tu);A(t,qe)},su=(e,t,o)=>{const n=e.origin();A(t,(t=>{t.each((t=>{const r=o(n,t);Sm(r,tu),Ze(e.parent(),r)}))}))},au=(e,t,o,n)=>{su(e,t,((e,t)=>{const r=((e,t,o,n,r)=>{const s=Se.fromTag("div");return Lt(s,{position:"absolute",left:t-n/2+"px",top:o+"px",height:r+"px",width:n+"px"}),be(s,{"data-column":e,role:"presentation"}),s})(t.col,t.x-e.left,o.top-e.top,7,n);return Sm(r,nu),r}))},iu=(e,t,o,n)=>{su(e,t,((e,t)=>{const r=((e,t,o,n,r)=>{const s=Se.fromTag("div");return Lt(s,{position:"absolute",left:t+"px",top:o-r/2+"px",height:r+"px",width:n+"px"}),be(s,{"data-row":e,role:"presentation"}),s})(t.row,o.left-e.left,t.y-e.top,n,7);return Sm(r,ou),r}))},lu=(e,t,o,n,r)=>{const s=wn(o),a=t.isResizable,i=n.length>0?Nn.positions(n,o):[],l=i.length>0?((e,t)=>P(e.all,((e,o)=>t(e.element)?[o]:[])))(e,a):[],c=N(i,((e,t)=>T(l,(e=>t===e))));iu(t,c,s,Vo(o));const d=r.length>0?Bn.positions(r,o):[],m=d.length>0?((e,t)=>{const o=[];return E(e.grid.columns,(n=>{const r=sn.getColumnAt(e,n).map((e=>e.element));r.forall(t)&&o.push(n)})),N(o,(o=>{const n=sn.filterItems(e,(e=>e.column===o));return F(n,(e=>t(e.element)))}))})(e,a):[],u=N(d,((e,t)=>T(m,(e=>t===e))));au(t,u,s,hn(o))},cu=(e,t)=>{if(ru(e),e.isResizable(t)){const o=sn.fromTable(t),n=cn(o),r=an(o);lu(o,e,t,n,r)}},du=(e,t)=>{const o=ht(e.parent(),"."+tu);A(o,t)},mu=e=>{du(e,(e=>{Bt(e,"display","none")}))},uu=e=>{du(e,(e=>{Bt(e,"display","block")}))},gu=Qm("resizer-bar-dragging"),pu=e=>{const t=eu(),o=((e,t={})=>{var o;const n=null!==(o=t.mode)&&void 0!==o?o:Jm;return Km(e,n,t)})(t,{});let n=C.none();const r=(e,t)=>C.from(ve(e,t));t.events.drag.bind((e=>{r(e.target,"data-row").each((t=>{const o=jt(e.target,"top");Bt(e.target,"top",o+e.yDelta+"px")})),r(e.target,"data-column").each((t=>{const o=jt(e.target,"left");Bt(e.target,"left",o+e.xDelta+"px")}))}));const s=(e,t)=>jt(e,t)-zt(e,"data-initial-"+t,0);o.events.stop.bind((()=>{t.get().each((t=>{n.each((o=>{r(t,"data-row").each((e=>{const n=s(t,"top");we(t,"data-initial-top"),d.trigger.adjustHeight(o,n,parseInt(e,10))})),r(t,"data-column").each((e=>{const n=s(t,"left");we(t,"data-initial-left"),d.trigger.adjustWidth(o,n,parseInt(e,10))})),cu(e,o)}))}))}));const a=(n,r)=>{d.trigger.startAdjust(),t.assign(n),fe(n,"data-initial-"+r,jt(n,r)),Sm(n,gu),Bt(n,"opacity","0.2"),o.go(e.parent())},i=Bm(e.parent(),"mousedown",(e=>{var t;t=e.target,km(t,ou)&&a(e.target,"top"),(e=>km(e,nu))(e.target)&&a(e.target,"left")})),l=t=>Te(t,e.view()),c=Bm(e.view(),"mouseover",(t=>{var r;(r=t.target,Ct(r,"table",l).filter(os)).fold((()=>{dt(t.target)&&ru(e)}),(t=>{o.isActive()&&(n=C.some(t),cu(e,t))}))})),d=Fm({adjustHeight:Pm(["table","delta","row"]),adjustWidth:Pm(["table","delta","column"]),startAdjust:Pm([])});return{destroy:()=>{i.unbind(),c.unbind(),o.destroy(),ru(e)},refresh:t=>{cu(e,t)},on:o.on,off:o.off,hideBars:b(mu,e),showBars:b(uu,e),events:d.registry}},hu=(e,t,o)=>{const n=Nn,r=Bn,s=pu(e),a=Fm({beforeResize:Pm(["table","type"]),afterResize:Pm(["table","type"]),startDrag:Pm([])});return s.events.adjustHeight.bind((e=>{const t=e.table;a.trigger.beforeResize(t,"row");const o=n.delta(e.delta,t);_i(t,o,e.row,n),a.trigger.afterResize(t,"row")})),s.events.startAdjust.bind((e=>{a.trigger.startDrag()})),s.events.adjustWidth.bind((e=>{const n=e.table;a.trigger.beforeResize(n,"col");const s=r.delta(e.delta,n),i=o(n);ki(n,s,e.column,t,i),a.trigger.afterResize(n,"col")})),{on:s.on,off:s.off,refreshBars:s.refresh,hideBars:s.hideBars,showBars:s.showBars,destroy:s.destroy,events:a.registry}},fu=(e,t)=>{const o=ue(e)?(e=>Se.fromDom(Me(e).dom.documentElement))(e):e;return{parent:p(o),view:p(e),origin:p(vn(0,0)),isResizable:t}},bu=(e,t,o)=>({parent:p(t),view:p(e),origin:p(vn(0,0)),isResizable:o}),vu=()=>{const e=Se.fromTag("div");return Lt(e,{position:"static",height:"0",width:"0",padding:"0",margin:"0",border:"0"}),Ze(mt(Se.fromDom(document)),e),e},yu=e=>d(e)&&"TABLE"===e.nodeName,wu="bar-",xu=e=>"false"!==ve(e,"data-mce-resize"),Cu=e=>{const t=Pd(),o=Pd(),n=Pd();let r,s;const a=t=>Hl(e,t),i=()=>Ur(e)?ga():ua(),l=(t,o,n)=>{const l=Dt(o,"e");if(""===s&&nc(t),n!==r&&""!==s){Bt(t,"width",s);const o=i(),c=a(t),d=Ur(e)||l?(e=>pa(e).columns)(t)-1:0;ki(t,n-r,d,o,c)}else if((e=>/^(\d+(\.\d+)?)%$/.test(e))(s)){const e=parseFloat(s.replace("%",""));Bt(t,"width",n*e/r+"%")}(e=>/^(\d+(\.\d+)?)px$/.test(e))(s)&&(e=>{const t=sn.fromTable(e);sn.hasColumns(t)||A(Yt(e),(e=>{const t=Ht(e,"width");Bt(e,"width",t),we(e,"width")}))})(t)},c=()=>{o.on((e=>{e.destroy()})),n.on((t=>{((e,t)=>{e.inline&&qe(t.parent())})(e,t)}))};e.on("init",(()=>{const r=((e,t)=>e.inline?bu(Se.fromDom(e.getBody()),vu(),t):fu(Se.fromDom(e.getDoc()),t))(e,xu);if(n.set(r),(e=>{const t=e.options.get("object_resizing");return O(t.split(","),"table")})(e)&&Kr(e)){const n=i(),s=hu(r,n,a);s.on(),s.events.startDrag.bind((o=>{t.set(e.selection.getRng())})),s.events.beforeResize.bind((t=>{const o=t.table.dom;((e,t,o,n,r)=>{e.dispatch("ObjectResizeStart",{target:t,width:o,height:n,origin:r})})(e,o,ls(o),cs(o),wu+t.type)})),s.events.afterResize.bind((o=>{const n=o.table,r=n.dom;as(n),t.on((t=>{e.selection.setRng(t),e.focus()})),((e,t,o,n,r)=>{e.dispatch("ObjectResized",{target:t,width:o,height:n,origin:r})})(e,r,ls(r),cs(r),wu+o.type),e.undoManager.add()})),o.set(s)}})),e.on("ObjectResizeStart",(t=>{const o=t.target;if(yu(o)){const n=Se.fromDom(o);A(e.dom.select(".mce-clonedresizable"),(t=>{e.dom.addClass(t,"mce-"+Zr(e)+"-columns")})),!ec(n)&&qr(e)?rc(n):!Ql(n)&&Wr(e)&&nc(n),tc(n)&&Et(t.origin,wu)&&nc(n),r=t.width,s=Gr(e)?"":((e,t)=>{const o=e.dom.getStyle(t,"width")||e.dom.getAttrib(t,"width");return C.from(o).filter(Mt)})(e,o).getOr("")}})),e.on("ObjectResized",(t=>{const o=t.target;if(yu(o)){const n=Se.fromDom(o),r=t.origin;Et(r,"corner-")&&l(n,r,t.width),as(n),Nl(e,n.dom,Rl)}})),e.on("SwitchMode",(()=>{o.on((t=>{e.mode.isReadOnly()?t.hideBars():t.showBars()}))})),e.on("dragstart dragend",(e=>{o.on((t=>{"dragstart"===e.type?(t.hideBars(),t.off()):(t.on(),t.showBars())}))})),e.on("remove",(()=>{c()}));return{refresh:e=>{o.on((t=>t.refreshBars(Se.fromDom(e))))},hide:()=>{o.on((e=>e.hideBars()))},show:()=>{o.on((e=>e.showBars()))}}},Su=e=>{(e=>{const t=e.options.register;t("table_clone_elements",{processor:"string[]"}),t("table_use_colgroups",{processor:"boolean",default:!0}),t("table_header_type",{processor:e=>{const t=O(["section","cells","sectionCells","auto"],e);return t?{value:e,valid:t}:{valid:!1,message:"Must be one of: section, cells, sectionCells or auto."}},default:"section"}),t("table_sizing_mode",{processor:"string",default:"auto"}),t("table_default_attributes",{processor:"object",default:{border:"1"}}),t("table_default_styles",{processor:"object",default:{"border-collapse":"collapse"}}),t("table_column_resizing",{processor:e=>{const t=O(["preservetable","resizetable"],e);return t?{value:e,valid:t}:{valid:!1,message:"Must be preservetable, or resizetable."}},default:"preservetable"}),t("table_resize_bars",{processor:"boolean",default:!0}),t("table_style_by_css",{processor:"boolean",default:!0}),t("table_merge_content_on_paste",{processor:"boolean",default:!0})})(e);const t=Cu(e),o=Im(e,t),n=Il(e,t,o);return _c(e,n),((e,t)=>{const o=ss(e),n=t=>Xs(is(e)).bind((n=>Jt(n,o).map((o=>{const r=Gs(Js(e),o,n);return t(o,r)})))).getOr("");q({mceTableRowType:()=>n(t.getTableRowType),mceTableCellType:()=>n(t.getTableCellType),mceTableColType:()=>n(t.getTableColType)},((t,o)=>e.addQueryValueHandler(o,t)))})(e,n),Qs(e,n),{getSelectedCells:o.getSelectedCells,clearSelectedCells:o.clearSelectedCells}},ku=e=>({table:Su(e)});e.add("dom",ku)}()},6884:(e,t,o)=>{o(7652)},7652:()=>{!function(){"use strict";var e=tinymce.util.Tools.resolve("tinymce.PluginManager");const t=e=>t=>t.options.get(e),o=t("autolink_pattern"),n=t("link_default_target"),r=t("link_default_protocol"),s=t("allow_unsafe_link_target"),a=(i="string",e=>(e=>{const t=typeof e;return null===e?"null":"object"===t&&Array.isArray(e)?"array":"object"===t&&(o=n=e,(r=String).prototype.isPrototypeOf(o)||(null===(s=n.constructor)||void 0===s?void 0:s.name)===r.name)?"string":t;var o,n,r,s})(e)===i);var i;const l=(c=void 0,e=>c===e);var c;const d=e=>!(e=>null==e)(e),m=Object.hasOwnProperty,u=e=>"\ufeff"===e;var g=tinymce.util.Tools.resolve("tinymce.dom.TextSeeker");const p=e=>3===e.nodeType,h=e=>/^[(\[{ \u00a0]$/.test(e),f=(e,t,o)=>{for(let n=t-1;n>=0;n--){const t=e.charAt(n);if(!u(t)&&o(t))return n}return-1},b=(e,t)=>{var n;const s=e.schema.getVoidElements(),a=o(e),{dom:i,selection:c}=e;if(null!==i.getParent(c.getNode(),"a[href]"))return null;const d=c.getRng(),u=g(i,(e=>{return i.isBlock(e)||(t=s,o=e.nodeName.toLowerCase(),m.call(t,o))||"false"===i.getContentEditable(e);var t,o})),{container:b,offset:v}=((e,t)=>{let o=e,n=t;for(;1===o.nodeType&&o.childNodes[n];)o=o.childNodes[n],n=p(o)?o.data.length:o.childNodes.length;return{container:o,offset:n}})(d.endContainer,d.endOffset),y=null!==(n=i.getParent(b,i.isBlock))&&void 0!==n?n:i.getRoot(),w=u.backwards(b,v+t,((e,t)=>{const o=e.data,n=f(o,t,(r=h,e=>!r(e)));var r,s;return-1===n||(s=o[n],/[?!,.;:]/.test(s))?n:n+1}),y);if(!w)return null;let x=w.container;const C=u.backwards(w.container,w.offset,((e,t)=>{x=e;const o=f(e.data,t,h);return-1===o?o:o+1}),y),S=i.createRng();C?S.setStart(C.container,C.offset):S.setStart(x,0),S.setEnd(w.container,w.offset);const k=S.toString().replace(/\uFEFF/g,"").match(a);if(k){let t=k[0];if(((e,t,o)=>""===t||e.length>=t.length&&e.substr(o,o+t.length)===t)(t,"www.",0)){t=r(e)+"://"+t}else((e,t,o=0,n)=>{const r=e.indexOf(t,o);return-1!==r&&(!!l(n)||r+t.length<=n)})(t,"@")&&!(e=>/^([A-Za-z][A-Za-z\d.+-]*:\/\/)|mailto:/.test(e))(t)&&(t="mailto:"+t);return{rng:S,url:t}}return null},v=(e,t)=>{const{dom:o,selection:r}=e,{rng:i,url:l}=t,c=r.getBookmark();r.setRng(i);const d="createlink",m={command:d,ui:!1,value:l};if(!e.dispatch("BeforeExecCommand",m).isDefaultPrevented()){e.getDoc().execCommand(d,!1,l),e.dispatch("ExecCommand",m);const t=n(e);if(a(t)){const n=r.getNode();o.setAttrib(n,"target",t),"_blank"!==t||s(e)||o.setAttrib(n,"rel","noopener")}}r.moveToBookmark(c),e.nodeChanged()},y=e=>{const t=b(e,-1);d(t)&&v(e,t)},w=y,x=e=>{e.on("keydown",(t=>{13!==t.keyCode||t.isDefaultPrevented()||(e=>{const t=b(e,0);d(t)&&v(e,t)})(e)})),e.on("keyup",(t=>{32===t.keyCode?y(e):(48===t.keyCode&&t.shiftKey||221===t.keyCode)&&w(e)}))};e.add("autolink",(e=>{(e=>{const t=e.options.register;t("autolink_pattern",{processor:"regexp",default:new RegExp("^"+/(?:[A-Za-z][A-Za-z\d.+-]{0,14}:\/\/(?:[-.~*+=!&;:'%@?^${}(),\w]+@)?|www\.|[-;:&=+$,.\w]+@)[A-Za-z\d-]+(?:\.[A-Za-z\d-]+)*(?::\d+)?(?:\/(?:[-.~*+=!;:'%@$(),\/\w]*[-~*+=%@$()\/\w])?)?(?:\?(?:[-.~*+=!&;:'%@?^${}(),\/\w]+))?(?:#(?:[-.~*+=!&;:'%@?^${}(),\/\w]+))?/g.source+"$","i")}),t("link_default_target",{processor:"string"}),t("link_default_protocol",{processor:"string",default:"https"})})(e),x(e)}))}()},8190:(e,t,o)=>{o(7440)},7440:()=>{!function(){"use strict";var e=tinymce.util.Tools.resolve("tinymce.PluginManager");e.add("code",(e=>((e=>{e.addCommand("mceCodeEditor",(()=>{(e=>{const t=(e=>e.getContent({source_view:!0}))(e);e.windowManager.open({title:"Source Code",size:"large",body:{type:"panel",items:[{type:"textarea",name:"code"}]},buttons:[{type:"cancel",name:"cancel",text:"Cancel"},{type:"submit",name:"save",text:"Save",primary:!0}],initialData:{code:t},onSubmit:t=>{((e,t)=>{e.focus(),e.undoManager.transact((()=>{e.setContent(t)})),e.selection.setCursorLocation(),e.nodeChanged()})(e,t.getData().code),t.close()}})})(e)}))})(e),(e=>{const t=()=>e.execCommand("mceCodeEditor");e.ui.registry.addButton("code",{icon:"sourcecode",tooltip:"Source code",onAction:t}),e.ui.registry.addMenuItem("code",{icon:"sourcecode",text:"Source code",onAction:t})})(e),{})))}()},2936:(e,t,o)=>{o(6537)},6537:()=>{!function(){"use strict";var e=tinymce.util.Tools.resolve("tinymce.PluginManager");let t=0;const o=e=>{const o=(new Date).getTime(),n=Math.floor(1e9*Math.random());return t++,e+"_"+n+t+String(o)},n=e=>t=>t.options.get(e),r=n("help_tabs"),s=n("forced_plugins"),a=(i="string",e=>(e=>{const t=typeof e;return null===e?"null":"object"===t&&Array.isArray(e)?"array":"object"===t&&(o=n=e,(r=String).prototype.isPrototypeOf(o)||(null===(s=n.constructor)||void 0===s?void 0:s.name)===r.name)?"string":t;var o,n,r,s})(e)===i);var i;const l=(c=void 0,e=>c===e);var c;const d=(e=>t=>typeof t===e)("function"),m=(u=!1,()=>u);var u;class g{constructor(e,t){this.tag=e,this.value=t}static some(e){return new g(!0,e)}static none(){return g.singletonNone}fold(e,t){return this.tag?t(this.value):e()}isSome(){return this.tag}isNone(){return!this.tag}map(e){return this.tag?g.some(e(this.value)):g.none()}bind(e){return this.tag?e(this.value):g.none()}exists(e){return this.tag&&e(this.value)}forall(e){return!this.tag||e(this.value)}filter(e){return!this.tag||e(this.value)?this:g.none()}getOr(e){return this.tag?this.value:e}or(e){return this.tag?this:e}getOrThunk(e){return this.tag?this.value:e()}orThunk(e){return this.tag?this:e()}getOrDie(e){if(this.tag)return this.value;throw new Error(null!=e?e:"Called getOrDie on None")}static from(e){return(e=>null==e)(e)?g.none():g.some(e)}getOrNull(){return this.tag?this.value:null}getOrUndefined(){return this.value}each(e){this.tag&&e(this.value)}toArray(){return this.tag?[this.value]:[]}toString(){return this.tag?`some(${this.value})`:"none()"}}g.singletonNone=new g(!1);const p=Array.prototype.slice,h=Array.prototype.indexOf,f=(e,t)=>((e,t)=>h.call(e,t))(e,t)>-1,b=(e,t)=>{const o=e.length,n=new Array(o);for(let r=0;r{const o=[];for(let n=0,r=e.length;n((e,t,o)=>{for(let n=0,r=e.length;n{const o=p.call(e,0);return o.sort(t),o},x=Object.keys,C=Object.hasOwnProperty,S=(e,t)=>C.call(e,t);var k=tinymce.util.Tools.resolve("tinymce.Resource"),_=tinymce.util.Tools.resolve("tinymce.util.I18n");const O=(e,t)=>k.load(`tinymce.html-i18n.help-keynav.${t}`,`${e}/js/i18n/keynav/${t}.js`),T=e=>O(e,_.getCode()).catch((()=>O(e,"en")));var E=tinymce.util.Tools.resolve("tinymce.Env");const D=e=>{const t=E.os.isMacOS()||E.os.isiOS(),o=t?{alt:"⌥",ctrl:"⌃",shift:"⇧",meta:"⌘",access:"⌃⌥"}:{meta:"Ctrl ",access:"Shift + Alt "},n=e.split("+"),r=b(n,(e=>{const t=e.toLowerCase().trim();return S(o,t)?o[t]:e}));return t?r.join("").replace(/\s/,""):r.join("+")},A=[{shortcuts:["Meta + B"],action:"Bold"},{shortcuts:["Meta + I"],action:"Italic"},{shortcuts:["Meta + U"],action:"Underline"},{shortcuts:["Meta + A"],action:"Select all"},{shortcuts:["Meta + Y","Meta + Shift + Z"],action:"Redo"},{shortcuts:["Meta + Z"],action:"Undo"},{shortcuts:["Access + 1"],action:"Heading 1"},{shortcuts:["Access + 2"],action:"Heading 2"},{shortcuts:["Access + 3"],action:"Heading 3"},{shortcuts:["Access + 4"],action:"Heading 4"},{shortcuts:["Access + 5"],action:"Heading 5"},{shortcuts:["Access + 6"],action:"Heading 6"},{shortcuts:["Access + 7"],action:"Paragraph"},{shortcuts:["Access + 8"],action:"Div"},{shortcuts:["Access + 9"],action:"Address"},{shortcuts:["Alt + 0"],action:"Open help dialog"},{shortcuts:["Alt + F9"],action:"Focus to menubar"},{shortcuts:["Alt + F10"],action:"Focus to toolbar"},{shortcuts:["Alt + F11"],action:"Focus to element path"},{shortcuts:["Ctrl + F9"],action:"Focus to contextual toolbar"},{shortcuts:["Shift + Enter"],action:"Open popup menu for split buttons"},{shortcuts:["Meta + K"],action:"Insert link (if link plugin activated)"},{shortcuts:["Meta + S"],action:"Save (if save plugin activated)"},{shortcuts:["Meta + F"],action:"Find (if searchreplace plugin activated)"},{shortcuts:["Meta + Shift + F"],action:"Switch to or from fullscreen mode"}],M=()=>({name:"shortcuts",title:"Handy Shortcuts",items:[{type:"table",header:["Action","Shortcut"],cells:b(A,(e=>{const t=b(e.shortcuts,D).join(" or ");return[e.action,t]}))}]}),N=b([{key:"accordion",name:"Accordion"},{key:"advlist",name:"Advanced List"},{key:"anchor",name:"Anchor"},{key:"autolink",name:"Autolink"},{key:"autoresize",name:"Autoresize"},{key:"autosave",name:"Autosave"},{key:"charmap",name:"Character Map"},{key:"code",name:"Code"},{key:"codesample",name:"Code Sample"},{key:"colorpicker",name:"Color Picker"},{key:"directionality",name:"Directionality"},{key:"emoticons",name:"Emoticons"},{key:"fullscreen",name:"Full Screen"},{key:"help",name:"Help"},{key:"image",name:"Image"},{key:"importcss",name:"Import CSS"},{key:"insertdatetime",name:"Insert Date/Time"},{key:"link",name:"Link"},{key:"lists",name:"Lists"},{key:"media",name:"Media"},{key:"nonbreaking",name:"Nonbreaking"},{key:"pagebreak",name:"Page Break"},{key:"preview",name:"Preview"},{key:"quickbars",name:"Quick Toolbars"},{key:"save",name:"Save"},{key:"searchreplace",name:"Search and Replace"},{key:"table",name:"Table"},{key:"template",name:"Template"},{key:"textcolor",name:"Text Color"},{key:"visualblocks",name:"Visual Blocks"},{key:"visualchars",name:"Visual Characters"},{key:"wordcount",name:"Word Count"},{key:"a11ychecker",name:"Accessibility Checker",type:"premium"},{key:"advcode",name:"Advanced Code Editor",type:"premium"},{key:"advtable",name:"Advanced Tables",type:"premium"},{key:"advtemplate",name:"Advanced Templates",type:"premium",slug:"advanced-templates"},{key:"ai",name:"AI Assistant",type:"premium"},{key:"casechange",name:"Case Change",type:"premium"},{key:"checklist",name:"Checklist",type:"premium"},{key:"editimage",name:"Enhanced Image Editing",type:"premium"},{key:"footnotes",name:"Footnotes",type:"premium"},{key:"typography",name:"Advanced Typography",type:"premium",slug:"advanced-typography"},{key:"mediaembed",name:"Enhanced Media Embed",type:"premium",slug:"introduction-to-mediaembed"},{key:"export",name:"Export",type:"premium"},{key:"formatpainter",name:"Format Painter",type:"premium"},{key:"inlinecss",name:"Inline CSS",type:"premium",slug:"inline-css"},{key:"linkchecker",name:"Link Checker",type:"premium"},{key:"mentions",name:"Mentions",type:"premium"},{key:"mergetags",name:"Merge Tags",type:"premium"},{key:"pageembed",name:"Page Embed",type:"premium"},{key:"permanentpen",name:"Permanent Pen",type:"premium"},{key:"powerpaste",name:"PowerPaste",type:"premium",slug:"introduction-to-powerpaste"},{key:"rtc",name:"Real-Time Collaboration",type:"premium",slug:"rtc-introduction"},{key:"tinymcespellchecker",name:"Spell Checker Pro",type:"premium",slug:"introduction-to-tiny-spellchecker"},{key:"autocorrect",name:"Spelling Autocorrect",type:"premium"},{key:"tableofcontents",name:"Table of Contents",type:"premium"},{key:"tinycomments",name:"Tiny Comments",type:"premium",slug:"introduction-to-tiny-comments"},{key:"tinydrive",name:"Tiny Drive",type:"premium",slug:"tinydrive-introduction"}],(e=>({...e,type:e.type||"opensource",slug:e.slug||e.key}))),R=e=>{const t=e=>`${e.name}`,o=(e,o)=>y(N,(e=>e.key===o)).fold((()=>((e,o)=>{const n=e.plugins[o].getMetadata;if(d(n)){const e=n();return{name:e.name,html:t(e)}}return{name:o,html:o}})(e,o)),(e=>{const o="premium"===e.type?`${e.name}*`:e.name;return{name:o,html:t({name:o,url:`https://www.tiny.cloud/docs/tinymce/6/${e.slug}/`})}})),n=e=>{const t=(e=>{const t=x(e.plugins),o=s(e);return l(o)?t:v(t,(e=>!f(o,e)))})(e),n=w(b(t,(t=>o(e,t))),((e,t)=>e.name.localeCompare(t.name))),r=b(n,(e=>"
  • "+e.html+"
  • ")),a=r.length,i=r.join("");return"

    "+_.translate(["Plugins installed ({0}):",a])+"

      "+i+"
    "},r={type:"htmlpanel",presets:"document",html:[(e=>null==e?"":"
    "+n(e)+"
    ")(e),(()=>{const e=v(N,(({type:e})=>"premium"===e)),t=w(b(e,(e=>e.name)),((e,t)=>e.localeCompare(t))),o=b(t,(e=>`
  • ${e}
  • `)).join("");return"

    "+_.translate("Premium plugins:")+"

    "})()].join("")};return{name:"plugins",title:"Plugins",items:[r]}};var B=tinymce.util.Tools.resolve("tinymce.EditorManager");const L=async(e,t,n)=>{const s=M(),i=await(async e=>({name:"keyboardnav",title:"Keyboard Navigation",items:[{type:"htmlpanel",presets:"document",html:await T(e)}]}))(n),l=R(e),c=(()=>{var e,t;const o='TinyMCE '+(e=B.majorVersion,t=B.minorVersion,(0===e.indexOf("@")?"X.X.X":e+"."+t)+"");return{name:"versions",title:"Version",items:[{type:"htmlpanel",html:"

    "+_.translate(["You are using {0}",o])+"

    ",presets:"document"}]}})(),d={[s.name]:s,[i.name]:i,[l.name]:l,[c.name]:c,...t.get()};return g.from(r(e)).fold((()=>(e=>{const t=x(e),o=t.indexOf("versions");return-1!==o&&(t.splice(o,1),t.push("versions")),{tabs:e,names:t}})(d)),(e=>((e,t)=>{const n={},r=b(e,(e=>{var r;if(a(e))return S(t,e)&&(n[e]=t[e]),e;{const t=null!==(r=e.name)&&void 0!==r?r:o("tab-name");return n[t]=e,t}}));return{tabs:n,names:r}})(e,d)))},H=(e,t,o)=>()=>{L(e,t,o).then((({tabs:t,names:o})=>{const n={type:"tabpanel",tabs:(e=>{const t=[],o=e=>{t.push(e)};for(let t=0;t{return S(o=t,n=e)?g.from(o[n]):g.none();var o,n})))};e.windowManager.open({title:"Help",size:"medium",body:n,buttons:[{type:"cancel",name:"close",text:"Close",primary:!0}],initialData:{}})}))};e.add("help",((e,t)=>{const n=(e=>{let t=e;return{get:()=>t,set:e=>{t=e}}})({}),r=(e=>({addTab:t=>{var n;const r=null!==(n=t.name)&&void 0!==n?n:o("tab-name"),s=e.get();s[r]=t,e.set(s)}}))(n);(e=>{(0,e.options.register)("help_tabs",{processor:"array"})})(e);const s=H(e,n,t);return((e,t)=>{e.ui.registry.addButton("help",{icon:"help",tooltip:"Help",onAction:t}),e.ui.registry.addMenuItem("help",{text:"Help",icon:"help",shortcut:"Alt+0",onAction:t})})(e,s),((e,t)=>{e.addCommand("mceHelp",t)})(e,s),e.shortcuts.add("Alt+0","Open help dialog","mceHelp"),((e,t)=>{e.on("init",(()=>{T(t)}))})(e,t),r}))}()},2170:(e,t,o)=>{o(3302)},3302:()=>{!function(){"use strict";var e=tinymce.util.Tools.resolve("tinymce.PluginManager");const t=Object.getPrototypeOf,o=(e,t,o)=>{var n;return!!o(e,t.prototype)||(null===(n=e.constructor)||void 0===n?void 0:n.name)===t.name},n=e=>t=>(e=>{const t=typeof e;return null===e?"null":"object"===t&&Array.isArray(e)?"array":"object"===t&&o(e,String,((e,t)=>t.isPrototypeOf(e)))?"string":t})(t)===e,r=e=>t=>typeof t===e,s=n("string"),a=n("object"),i=e=>((e,n)=>a(e)&&o(e,n,((e,o)=>t(e)===o)))(e,Object),l=n("array"),c=(d=null,e=>d===e);var d;const m=r("boolean"),u=e=>!(e=>null==e)(e),g=r("function"),p=r("number"),h=()=>{};class f{constructor(e,t){this.tag=e,this.value=t}static some(e){return new f(!0,e)}static none(){return f.singletonNone}fold(e,t){return this.tag?t(this.value):e()}isSome(){return this.tag}isNone(){return!this.tag}map(e){return this.tag?f.some(e(this.value)):f.none()}bind(e){return this.tag?e(this.value):f.none()}exists(e){return this.tag&&e(this.value)}forall(e){return!this.tag||e(this.value)}filter(e){return!this.tag||e(this.value)?this:f.none()}getOr(e){return this.tag?this.value:e}or(e){return this.tag?this:e}getOrThunk(e){return this.tag?this.value:e()}orThunk(e){return this.tag?this:e()}getOrDie(e){if(this.tag)return this.value;throw new Error(null!=e?e:"Called getOrDie on None")}static from(e){return u(e)?f.some(e):f.none()}getOrNull(){return this.tag?this.value:null}getOrUndefined(){return this.value}each(e){this.tag&&e(this.value)}toArray(){return this.tag?[this.value]:[]}toString(){return this.tag?`some(${this.value})`:"none()"}}f.singletonNone=new f(!1);const b=Object.keys,v=Object.hasOwnProperty,y=(e,t,o,n)=>{((e,t)=>{const o=b(e);for(let n=0,r=o.length;n{(t(e,r)?o:n)(e,r)}))},w=(e,t)=>v.call(e,t),x=Array.prototype.push,C=e=>{const t=[];for(let o=0,n=e.length;o((e,t)=>t>=0&&t{((e,t,o)=>{if(!(s(o)||m(o)||p(o)))throw console.error("Invalid call to Attribute.set. Key ",t,":: Value ",o,":: Element ",e),new Error("Attribute value was not simple");e.setAttribute(t,o+"")})(e.dom,t,o)},_=e=>{if(null==e)throw new Error("Node cannot be null or undefined");return{dom:e}},O={fromHtml:(e,t)=>{const o=(t||document).createElement("div");if(o.innerHTML=e,!o.hasChildNodes()||o.childNodes.length>1){const t="HTML does not have a single root node";throw console.error(t,e),new Error(t)}return _(o.childNodes[0])},fromTag:(e,t)=>{const o=(t||document).createElement(e);return _(o)},fromText:(e,t)=>{const o=(t||document).createTextNode(e);return _(o)},fromDom:_,fromPoint:(e,t,o)=>f.from(e.dom.elementFromPoint(t,o)).map(_)};var T=tinymce.util.Tools.resolve("tinymce.dom.DOMUtils"),E=tinymce.util.Tools.resolve("tinymce.util.URI");const D=e=>e.length>0,A=e=>t=>t.options.get(e),M=e=>{const t=e.options.register;t("image_dimensions",{processor:"boolean",default:!0}),t("image_advtab",{processor:"boolean",default:!1}),t("image_uploadtab",{processor:"boolean",default:!0}),t("image_prepend_url",{processor:"string",default:""}),t("image_class_list",{processor:"object[]"}),t("image_description",{processor:"boolean",default:!0}),t("image_title",{processor:"boolean",default:!1}),t("image_caption",{processor:"boolean",default:!1}),t("image_list",{processor:e=>{const t=!1===e||s(e)||((e,t)=>{if(l(e)){for(let o=0,n=e.length;oMath.max(parseInt(e,10),parseInt(t,10)),j=e=>(e&&(e=e.replace(/px$/,"")),e),$=e=>(e.length>0&&/^[0-9]+$/.test(e)&&(e+="px"),e),W=e=>"IMG"===e.nodeName&&(e.hasAttribute("data-mce-object")||e.hasAttribute("data-mce-placeholder")),q=(e,t)=>{const o=e.options.get;return E.isDomSafe(t,"img",{allow_html_data_urls:o("allow_html_data_urls"),allow_script_urls:o("allow_script_urls"),allow_svg_data_urls:o("allow_svg_data_urls")})},G=T.DOM,K=e=>e.style.marginLeft&&e.style.marginRight&&e.style.marginLeft===e.style.marginRight?j(e.style.marginLeft):"",Y=e=>e.style.marginTop&&e.style.marginBottom&&e.style.marginTop===e.style.marginBottom?j(e.style.marginTop):"",X=e=>e.style.borderWidth?j(e.style.borderWidth):"",J=(e,t)=>{var o;return e.hasAttribute(t)&&null!==(o=e.getAttribute(t))&&void 0!==o?o:""},Q=e=>null!==e.parentNode&&"FIGURE"===e.parentNode.nodeName,ee=(e,t,o)=>{""===o||null===o?e.removeAttribute(t):e.setAttribute(t,o)},te=e=>{Q(e)?(e=>{const t=e.parentNode;u(t)&&(G.insertAfter(e,t),G.remove(t))})(e):(e=>{const t=G.create("figure",{class:"image"});G.insertAfter(t,e),t.appendChild(e),t.appendChild(G.create("figcaption",{contentEditable:"true"},"Caption")),t.contentEditable="false"})(e)},oe=(e,t)=>{const o=e.getAttribute("style"),n=t(null!==o?o:"");n.length>0?(e.setAttribute("style",n),e.setAttribute("data-mce-style",n)):e.removeAttribute("style")},ne=(e,t)=>(e,o,n)=>{const r=e.style;r[o]?(r[o]=$(n),oe(e,t)):ee(e,o,n)},re=(e,t)=>e.style[t]?j(e.style[t]):J(e,t),se=(e,t)=>{const o=$(t);e.style.marginLeft=o,e.style.marginRight=o},ae=(e,t)=>{const o=$(t);e.style.marginTop=o,e.style.marginBottom=o},ie=(e,t)=>{const o=$(t);e.style.borderWidth=o},le=(e,t)=>{e.style.borderStyle=t},ce=e=>{var t;return null!==(t=e.style.borderStyle)&&void 0!==t?t:""},de=e=>u(e)&&"FIGURE"===e.nodeName,me=e=>0===G.getAttrib(e,"alt").length&&"presentation"===G.getAttrib(e,"role"),ue=e=>me(e)?"":J(e,"alt"),ge=(e,t)=>{var o;const n=document.createElement("img");return ee(n,"style",t.style),(K(n)||""!==t.hspace)&&se(n,t.hspace),(Y(n)||""!==t.vspace)&&ae(n,t.vspace),(X(n)||""!==t.border)&&ie(n,t.border),(ce(n)||""!==t.borderStyle)&&le(n,t.borderStyle),e(null!==(o=n.getAttribute("style"))&&void 0!==o?o:"")},pe=(e,t)=>({src:J(t,"src"),alt:ue(t),title:J(t,"title"),width:re(t,"width"),height:re(t,"height"),class:J(t,"class"),style:e(J(t,"style")),caption:Q(t),hspace:K(t),vspace:Y(t),border:X(t),borderStyle:ce(t),isDecorative:me(t)}),he=(e,t,o,n,r)=>{o[n]!==t[n]&&r(e,n,String(o[n]))},fe=(e,t,o)=>{if(o){G.setAttrib(e,"role","presentation");const t=O.fromDom(e);k(t,"alt","")}else{if(c(t)){const t=O.fromDom(e);n="alt",t.dom.removeAttribute(n)}else{const o=O.fromDom(e);k(o,"alt",t)}"presentation"===G.getAttrib(e,"role")&&G.setAttrib(e,"role","")}var n},be=(e,t)=>(o,n,r)=>{e(o,r),oe(o,t)},ve=(e,t,o)=>{const n=pe(e,o);he(o,n,t,"caption",((e,t,o)=>te(e))),he(o,n,t,"src",ee),he(o,n,t,"title",ee),he(o,n,t,"width",ne(0,e)),he(o,n,t,"height",ne(0,e)),he(o,n,t,"class",ee),he(o,n,t,"style",be(((e,t)=>ee(e,"style",t)),e)),he(o,n,t,"hspace",be(se,e)),he(o,n,t,"vspace",be(ae,e)),he(o,n,t,"border",be(ie,e)),he(o,n,t,"borderStyle",be(le,e)),((e,t,o)=>{o.alt===t.alt&&o.isDecorative===t.isDecorative||fe(e,o.alt,o.isDecorative)})(o,n,t)},ye=(e,t)=>{const o=(e=>{if(e.margin){const t=String(e.margin).split(" ");switch(t.length){case 1:e["margin-top"]=e["margin-top"]||t[0],e["margin-right"]=e["margin-right"]||t[0],e["margin-bottom"]=e["margin-bottom"]||t[0],e["margin-left"]=e["margin-left"]||t[0];break;case 2:e["margin-top"]=e["margin-top"]||t[0],e["margin-right"]=e["margin-right"]||t[1],e["margin-bottom"]=e["margin-bottom"]||t[0],e["margin-left"]=e["margin-left"]||t[1];break;case 3:e["margin-top"]=e["margin-top"]||t[0],e["margin-right"]=e["margin-right"]||t[1],e["margin-bottom"]=e["margin-bottom"]||t[2],e["margin-left"]=e["margin-left"]||t[1];break;case 4:e["margin-top"]=e["margin-top"]||t[0],e["margin-right"]=e["margin-right"]||t[1],e["margin-bottom"]=e["margin-bottom"]||t[2],e["margin-left"]=e["margin-left"]||t[3]}delete e.margin}return e})(e.dom.styles.parse(t)),n=e.dom.styles.parse(e.dom.styles.serialize(o));return e.dom.styles.serialize(n)},we=e=>{const t=e.selection.getNode(),o=e.dom.getParent(t,"figure.image");return o?e.dom.select("img",o)[0]:t&&("IMG"!==t.nodeName||W(t))?null:t},xe=(e,t)=>{var o;const n=e.dom,r=((e,t)=>{const o={};var n;return y(e,t,(n=o,(e,t)=>{n[t]=e}),h),o})(e.schema.getTextBlockElements(),((t,o)=>!e.schema.isValidChild(o,"figure"))),s=n.getParent(t.parentNode,(e=>{return t=r,o=e.nodeName,w(t,o)&&void 0!==t[o]&&null!==t[o];var t,o}),e.getBody());return s&&null!==(o=n.split(s,t))&&void 0!==o?o:t},Ce=(e,t)=>{const o=((e,t)=>{const o=document.createElement("img");if(ve(e,{...t,caption:!1},o),fe(o,t.alt,t.isDecorative),t.caption){const e=G.create("figure",{class:"image"});return e.appendChild(o),e.appendChild(G.create("figcaption",{contentEditable:"true"},"Caption")),e.contentEditable="false",e}return o})((t=>ye(e,t)),t);e.dom.setAttrib(o,"data-mce-id","__mcenew"),e.focus(),e.selection.setContent(o.outerHTML);const n=e.dom.select('*[data-mce-id="__mcenew"]')[0];if(e.dom.setAttrib(n,"data-mce-id",null),de(n)){const t=xe(e,n);e.selection.select(t)}else e.selection.select(n)},Se=(e,t)=>{const o=we(e);if(o)if(ve((t=>ye(e,t)),t,o),((e,t)=>{e.dom.setAttrib(t,"src",t.getAttribute("src"))})(e,o),de(o.parentNode)){const t=o.parentNode;xe(e,t),e.selection.select(o.parentNode)}else e.selection.select(o),((e,t,o)=>{const n=()=>{o.onload=o.onerror=null,e.selection&&(e.selection.select(o),e.nodeChanged())};o.onload=()=>{t.width||t.height||!N(e)||e.dom.setAttribs(o,{width:String(o.clientWidth),height:String(o.clientHeight)}),n()},o.onerror=n})(e,t,o)},ke=(e,t)=>{const o=we(e);if(o){const n={...pe((t=>ye(e,t)),o),...t},r=((e,t)=>{const o=t.src;return{...t,src:q(e,o)?o:""}})(e,n);n.src?Se(e,r):((e,t)=>{if(t){const o=e.dom.is(t.parentNode,"figure.image")?t.parentNode:t;e.dom.remove(o),e.focus(),e.nodeChanged(),e.dom.isEmpty(e.getBody())&&(e.setContent(""),e.selection.setCursorLocation())}})(e,o)}else t.src&&Ce(e,{src:"",alt:"",title:"",width:"",height:"",class:"",style:"",caption:!1,hspace:"",vspace:"",border:"",borderStyle:"",isDecorative:!1,...t})},_e=(Oe=(e,t)=>i(e)&&i(t)?_e(e,t):t,(...e)=>{if(0===e.length)throw new Error("Can't merge zero objects");const t={};for(let o=0;os(e.value)?e.value:"",Ae=(e,t)=>{const o=[];return Ee.each(e,(e=>{const n=(e=>s(e.text)?e.text:s(e.title)?e.title:"")(e);if(void 0!==e.menu){const r=Ae(e.menu,t);o.push({text:n,items:r})}else{const r=t(e);o.push({text:n,value:r})}})),o},Me=(e=De)=>t=>t?f.from(t).map((t=>Ae(t,e))):f.none(),Ne=(e,t)=>((e,t)=>{for(let o=0;o(e=>w(e,"items"))(e)?Ne(e.items,t):e.value===t?f.some(e):f.none())),Re=Me,Be=e=>Me(De)(e),Le=(e,t)=>e.bind((e=>Ne(e,t))),He=e=>({title:"Advanced",name:"advanced",items:[{type:"grid",columns:2,items:[{type:"input",label:"Vertical space",name:"vspace",inputMode:"numeric"},{type:"input",label:"Horizontal space",name:"hspace",inputMode:"numeric"},{type:"input",label:"Border width",name:"border",inputMode:"numeric"},{type:"listbox",name:"borderstyle",label:"Border style",items:[{text:"Select...",value:""},{text:"Solid",value:"solid"},{text:"Dotted",value:"dotted"},{text:"Dashed",value:"dashed"},{text:"Double",value:"double"},{text:"Groove",value:"groove"},{text:"Ridge",value:"ridge"},{text:"Inset",value:"inset"},{text:"Outset",value:"outset"},{text:"None",value:"none"},{text:"Hidden",value:"hidden"}]}]}]}),Ie=e=>{const t=Re((t=>e.convertURL(t.value||t.url||"","src"))),o=new Promise((o=>{((e,t)=>{const o=z(e);s(o)?fetch(o).then((e=>{e.ok&&e.json().then(t)})):g(o)?o(t):t(o)})(e,(e=>{o(t(e).map((e=>C([[{text:"None",value:""}],e]))))}))})),n=Be(H(e)),r=R(e),a=B(e),i=(e=>D(e.options.get("images_upload_url")))(e),l=(e=>u(e.options.get("images_upload_handler")))(e),c=(e=>{const t=we(e);return t?pe((t=>ye(e,t)),t):{src:"",alt:"",title:"",width:"",height:"",class:"",style:"",caption:!1,hspace:"",vspace:"",border:"",borderStyle:"",isDecorative:!1}})(e),d=I(e),m=P(e),p=N(e),h=F(e),b=V(e),v=Z(e),y=f.some(L(e)).filter((e=>s(e)&&e.length>0));return o.then((e=>({image:c,imageList:e,classList:n,hasAdvTab:r,hasUploadTab:a,hasUploadUrl:i,hasUploadHandler:l,hasDescription:d,hasImageTitle:m,hasDimensions:p,hasImageCaption:h,prependURL:y,hasAccessibilityOptions:b,automaticUploads:v})))},Pe=e=>{const t=e.imageList.map((e=>({name:"images",type:"listbox",label:"Image list",items:e}))),o={name:"alt",type:"input",label:"Alternative description",enabled:!(e.hasAccessibilityOptions&&e.image.isDecorative)},n=e.classList.map((e=>({name:"classes",type:"listbox",label:"Class",items:e})));return C([[{name:"src",type:"urlinput",filetype:"image",label:"Source"}],t.toArray(),e.hasAccessibilityOptions&&e.hasDescription?[{type:"label",label:"Accessibility",items:[{name:"isDecorative",type:"checkbox",label:"Image is decorative"}]}]:[],e.hasDescription?[o]:[],e.hasImageTitle?[{name:"title",type:"input",label:"Image title"}]:[],e.hasDimensions?[{name:"dimensions",type:"sizeinput"}]:[],[{...(r=e.classList.isSome()&&e.hasImageCaption,r?{type:"grid",columns:2}:{type:"panel"}),items:C([n.toArray(),e.hasImageCaption?[{type:"label",label:"Caption",items:[{type:"checkbox",name:"caption",label:"Show caption"}]}]:[]])}]]);var r},Fe=e=>({title:"General",name:"general",items:Pe(e)}),ze=Pe,Ve=e=>({title:"Upload",name:"upload",items:[{type:"dropzone",name:"fileinput"}]}),Ze=e=>({src:{value:e.src,meta:{}},images:e.src,alt:e.alt,title:e.title,dimensions:{width:e.width,height:e.height},classes:e.class,caption:e.caption,style:e.style,vspace:e.vspace,border:e.border,hspace:e.hspace,borderstyle:e.borderStyle,fileinput:[],isDecorative:e.isDecorative}),Ue=(e,t)=>({src:e.src.value,alt:null!==e.alt&&0!==e.alt.length||!t?e.alt:null,title:e.title,width:e.dimensions.width,height:e.dimensions.height,class:e.classes,style:e.style,caption:e.caption,hspace:e.hspace,vspace:e.vspace,border:e.border,borderStyle:e.borderstyle,isDecorative:e.isDecorative}),je=(e,t)=>{const o=t.getData();((e,t)=>/^(?:[a-zA-Z]+:)?\/\//.test(t)?f.none():e.prependURL.bind((e=>t.substring(0,e.length)!==e?f.some(e+t):f.none())))(e,o.src.value).each((e=>{t.setData({src:{value:e,meta:o.src.meta}})}))},$e=(e,t)=>{const o=t.getData(),n=o.src.meta;if(void 0!==n){const r=_e({},o);((e,t,o)=>{e.hasDescription&&s(o.alt)&&(t.alt=o.alt),e.hasAccessibilityOptions&&(t.isDecorative=o.isDecorative||t.isDecorative||!1),e.hasImageTitle&&s(o.title)&&(t.title=o.title),e.hasDimensions&&(s(o.width)&&(t.dimensions.width=o.width),s(o.height)&&(t.dimensions.height=o.height)),s(o.class)&&Le(e.classList,o.class).each((e=>{t.classes=e.value})),e.hasImageCaption&&m(o.caption)&&(t.caption=o.caption),e.hasAdvTab&&(s(o.style)&&(t.style=o.style),s(o.vspace)&&(t.vspace=o.vspace),s(o.border)&&(t.border=o.border),s(o.hspace)&&(t.hspace=o.hspace),s(o.borderstyle)&&(t.borderstyle=o.borderstyle))})(e,r,n),t.setData(r)}},We=(e,t,o,n)=>{je(t,n),$e(t,n),((e,t,o,n)=>{const r=n.getData(),s=r.src.value,a=r.src.meta||{};a.width||a.height||!t.hasDimensions||(D(s)?e.imageSize(s).then((e=>{o.open&&n.setData({dimensions:e})})).catch((e=>console.error(e))):n.setData({dimensions:{width:"",height:""}}))})(e,t,o,n),((e,t,o)=>{const n=o.getData(),r=Le(e.imageList,n.src.value);t.prevImage=r,o.setData({images:r.map((e=>e.value)).getOr("")})})(t,o,n)},qe=(e,t,o,n)=>{const r=n.getData();n.block("Uploading image"),S(r.fileinput).fold((()=>{n.unblock()}),(r=>{const s=URL.createObjectURL(r),a=()=>{n.unblock(),URL.revokeObjectURL(s)},i=r=>{n.setData({src:{value:r,meta:{}}}),n.showTab("general"),We(e,t,o,n)};var l;(l=r,new Promise(((e,t)=>{const o=new FileReader;o.onload=()=>{e(o.result)},o.onerror=()=>{var e;t(null===(e=o.error)||void 0===e?void 0:e.message)},o.readAsDataURL(l)}))).then((o=>{const l=e.createBlobCache(r,s,o);t.automaticUploads?e.uploadImage(l).then((e=>{i(e.url),a()})).catch((t=>{a(),e.alertErr(t)})):(e.addToBlobCache(l),i(l.blobUri()),n.unblock())}))}))},Ge=(e,t,o)=>(n,r)=>{"src"===r.name?We(e,t,o,n):"images"===r.name?((e,t,o,n)=>{const r=n.getData(),s=Le(t.imageList,r.images);s.each((e=>{const t=""===r.alt||o.prevImage.map((e=>e.text===r.alt)).getOr(!1);t?""===e.value?n.setData({src:e,alt:o.prevAlt}):n.setData({src:e,alt:e.text}):n.setData({src:e})})),o.prevImage=s,We(e,t,o,n)})(e,t,o,n):"alt"===r.name?o.prevAlt=n.getData().alt:"fileinput"===r.name?qe(e,t,o,n):"isDecorative"===r.name&&n.setEnabled("alt",!n.getData().isDecorative)},Ke=e=>()=>{e.open=!1},Ye=e=>{if(e.hasAdvTab||e.hasUploadUrl||e.hasUploadHandler){return{type:"tabpanel",tabs:C([[Fe(e)],e.hasAdvTab?[He(e)]:[],e.hasUploadTab&&(e.hasUploadUrl||e.hasUploadHandler)?[Ve(e)]:[]])}}return{type:"panel",items:ze(e)}},Xe=(e,t,o)=>n=>{const r=_e(Ze(t.image),n.getData()),s={...r,style:ge(o.normalizeCss,Ue(r,!1))};e.execCommand("mceUpdateImage",!1,Ue(s,t.hasAccessibilityOptions)),e.editorUpload.uploadImagesAuto(),n.close()},Je=e=>t=>q(e,t)?(e=>new Promise((t=>{const o=document.createElement("img"),n=e=>{o.onload=o.onerror=null,o.parentNode&&o.parentNode.removeChild(o),t(e)};o.onload=()=>{const e={width:U(o.width,o.clientWidth),height:U(o.height,o.clientHeight)};n(Promise.resolve(e))},o.onerror=()=>{n(Promise.reject(`Failed to get image dimensions for: ${e}`))};const r=o.style;r.visibility="hidden",r.position="fixed",r.bottom=r.left="0px",r.width=r.height="auto",document.body.appendChild(o),o.src=e})))(e.documentBaseURI.toAbsolute(t)).then((e=>({width:String(e.width),height:String(e.height)}))):Promise.resolve({width:"",height:""}),Qe=e=>(t,o,n)=>{var r;return e.editorUpload.blobCache.create({blob:t,blobUri:o,name:null===(r=t.name)||void 0===r?void 0:r.replace(/\.[^\.]+$/,""),filename:t.name,base64:n.split(",")[1]})},et=e=>t=>{e.editorUpload.blobCache.add(t)},tt=e=>t=>{e.windowManager.alert(t)},ot=e=>t=>ye(e,t),nt=e=>t=>e.dom.parseStyle(t),rt=e=>(t,o)=>e.dom.serializeStyle(t,o),st=e=>t=>Te(e).upload([t],!1).then((e=>{var t;return 0===e.length?Promise.reject("Failed to upload image"):!1===e[0].status?Promise.reject(null===(t=e[0].error)||void 0===t?void 0:t.message):e[0]})),at=e=>{const t={imageSize:Je(e),addToBlobCache:et(e),createBlobCache:Qe(e),alertErr:tt(e),normalizeCss:ot(e),parseStyle:nt(e),serializeStyle:rt(e),uploadImage:st(e)};return{open:()=>{Ie(e).then((o=>{const n=(e=>({prevImage:Le(e.imageList,e.image.src),prevAlt:e.image.alt,open:!0}))(o);return{title:"Insert/Edit Image",size:"normal",body:Ye(o),buttons:[{type:"cancel",name:"cancel",text:"Cancel"},{type:"submit",name:"save",text:"Save",primary:!0}],initialData:Ze(o.image),onSubmit:Xe(e,o,t),onChange:Ge(t,o,n),onClose:Ke(n)}})).then(e.windowManager.open)}}},it=e=>{const t=e.attr("class");return u(t)&&/\bimage\b/.test(t)},lt=e=>t=>{let o=t.length;const n=t=>{t.attr("contenteditable",e?"true":null)};for(;o--;){const r=t[o];it(r)&&(r.attr("contenteditable",e?"false":null),Ee.each(r.getAll("figcaption"),n))}},ct=e=>t=>{const o=()=>{t.setEnabled(e.selection.isEditable())};return e.on("NodeChange",o),o(),()=>{e.off("NodeChange",o)}};e.add("image",(e=>{M(e),(e=>{e.on("PreInit",(()=>{e.parser.addNodeFilter("figure",lt(!0)),e.serializer.addNodeFilter("figure",lt(!1))}))})(e),(e=>{e.ui.registry.addToggleButton("image",{icon:"image",tooltip:"Insert/edit image",onAction:at(e).open,onSetup:t=>{t.setActive(u(we(e)));const o=e.selection.selectorChangedWithUnbind("img:not([data-mce-object]):not([data-mce-placeholder]),figure.image",t.setActive).unbind,n=ct(e)(t);return()=>{o(),n()}}}),e.ui.registry.addMenuItem("image",{icon:"image",text:"Image...",onAction:at(e).open,onSetup:ct(e)}),e.ui.registry.addContextMenu("image",{update:t=>e.selection.isEditable()&&(de(t)||"IMG"===t.nodeName&&!W(t))?["image"]:[]})})(e),(e=>{e.addCommand("mceImage",at(e).open),e.addCommand("mceUpdateImage",((t,o)=>{e.undoManager.transact((()=>ke(e,o)))}))})(e)}))}()},3956:(e,t,o)=>{o(8006)},8006:()=>{!function(){"use strict";var e=tinymce.util.Tools.resolve("tinymce.PluginManager");const t=e=>t=>t.options.get(e),o=t("insertdatetime_dateformat"),n=t("insertdatetime_timeformat"),r=t("insertdatetime_formats"),s=t("insertdatetime_element"),a="Sun Mon Tue Wed Thu Fri Sat Sun".split(" "),i="Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sunday".split(" "),l="Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec".split(" "),c="January February March April May June July August September October November December".split(" "),d=(e,t)=>{if((e=""+e).lengtht=(t=(t=(t=(t=(t=(t=(t=(t=(t=(t=(t=(t=(t=(t=(t=t.replace("%D","%m/%d/%Y")).replace("%r","%I:%M:%S %p")).replace("%Y",""+o.getFullYear())).replace("%y",""+o.getYear())).replace("%m",d(o.getMonth()+1,2))).replace("%d",d(o.getDate(),2))).replace("%H",""+d(o.getHours(),2))).replace("%M",""+d(o.getMinutes(),2))).replace("%S",""+d(o.getSeconds(),2))).replace("%I",""+((o.getHours()+11)%12+1))).replace("%p",o.getHours()<12?"AM":"PM")).replace("%B",""+e.translate(c[o.getMonth()]))).replace("%b",""+e.translate(l[o.getMonth()]))).replace("%A",""+e.translate(i[o.getDay()]))).replace("%a",""+e.translate(a[o.getDay()]))).replace("%%","%"),u=(e,t)=>{if(s(e)){const o=m(e,t);let n;n=/%[HMSIp]/.test(t)?m(e,"%Y-%m-%dT%H:%M"):m(e,"%Y-%m-%d");const r=e.dom.getParent(e.selection.getStart(),"time");r?((e,t,o,n)=>{const r=e.dom.create("time",{datetime:o},n);e.dom.replace(r,t),e.selection.select(r,!0),e.selection.collapse(!1)})(e,r,n,o):e.insertContent('")}else e.insertContent(m(e,t))};var g=tinymce.util.Tools.resolve("tinymce.util.Tools");const p=e=>t=>{const o=()=>{t.setEnabled(e.selection.isEditable())};return e.on("NodeChange",o),o(),()=>{e.off("NodeChange",o)}},h=e=>{const t=r(e),o=(e=>{let t=e;return{get:()=>t,set:e=>{t=e}}})((e=>{const t=r(e);return t.length>0?t[0]:n(e)})(e)),s=t=>e.execCommand("mceInsertDate",!1,t);e.ui.registry.addSplitButton("insertdatetime",{icon:"insert-time",tooltip:"Insert date/time",select:e=>e===o.get(),fetch:o=>{o(g.map(t,(t=>({type:"choiceitem",text:m(e,t),value:t}))))},onAction:e=>{s(o.get())},onItemAction:(e,t)=>{o.set(t),s(t)},onSetup:p(e)});const a=e=>()=>{o.set(e),s(e)};e.ui.registry.addNestedMenuItem("insertdatetime",{icon:"insert-time",text:"Date/time",getSubmenuItems:()=>g.map(t,(t=>({type:"menuitem",text:m(e,t),onAction:a(t)}))),onSetup:p(e)})};e.add("insertdatetime",(e=>{(e=>{const t=e.options.register;t("insertdatetime_dateformat",{processor:"string",default:e.translate("%Y-%m-%d")}),t("insertdatetime_timeformat",{processor:"string",default:e.translate("%H:%M:%S")}),t("insertdatetime_formats",{processor:"string[]",default:["%H:%M:%S","%Y-%m-%d","%I:%M:%S %p","%D"]}),t("insertdatetime_element",{processor:"boolean",default:!1})})(e),(e=>{e.addCommand("mceInsertDate",((t,n)=>{u(e,null!=n?n:o(e))})),e.addCommand("mceInsertTime",((t,o)=>{u(e,null!=o?o:n(e))}))})(e),h(e)}))}()},2682:(e,t,o)=>{o(7384)},7384:()=>{!function(){"use strict";var e=tinymce.util.Tools.resolve("tinymce.PluginManager");const t=e=>t=>(e=>{const t=typeof e;return null===e?"null":"object"===t&&Array.isArray(e)?"array":"object"===t&&(o=r=e,n=(s=String).prototype,n.isPrototypeOf(o)||(null===(a=r.constructor)||void 0===a?void 0:a.name)===s.name)?"string":t;var o,n;var r,s,a})(t)===e,o=e=>t=>typeof t===e,n=t("string"),r=t("object"),s=t("array"),a=(i=null,e=>i===e);var i;const l=o("boolean"),c=e=>!(e=>null==e)(e),d=o("function"),m=(e,t)=>{if(s(e)){for(let o=0,n=e.length;o{},g=(e,t)=>e===t;class p{constructor(e,t){this.tag=e,this.value=t}static some(e){return new p(!0,e)}static none(){return p.singletonNone}fold(e,t){return this.tag?t(this.value):e()}isSome(){return this.tag}isNone(){return!this.tag}map(e){return this.tag?p.some(e(this.value)):p.none()}bind(e){return this.tag?e(this.value):p.none()}exists(e){return this.tag&&e(this.value)}forall(e){return!this.tag||e(this.value)}filter(e){return!this.tag||e(this.value)?this:p.none()}getOr(e){return this.tag?this.value:e}or(e){return this.tag?this:e}getOrThunk(e){return this.tag?this.value:e()}orThunk(e){return this.tag?this:e()}getOrDie(e){if(this.tag)return this.value;throw new Error(null!=e?e:"Called getOrDie on None")}static from(e){return c(e)?p.some(e):p.none()}getOrNull(){return this.tag?this.value:null}getOrUndefined(){return this.value}each(e){this.tag&&e(this.value)}toArray(){return this.tag?[this.value]:[]}toString(){return this.tag?`some(${this.value})`:"none()"}}p.singletonNone=new p(!1);const h=Array.prototype.indexOf,f=Array.prototype.push,b=(e,t)=>((e,t)=>h.call(e,t))(e,t)>-1,v=e=>{const t=[];for(let o=0,n=e.length;ov(((e,t)=>{const o=e.length,n=new Array(o);for(let r=0;r{for(let o=0;oe.exists((e=>o(e,t))),C=e=>{const t=[],o=e=>{t.push(e)};for(let t=0;te?p.some(t):p.none(),k=e=>t=>t.options.get(e),_=k("link_assume_external_targets"),O=k("link_context_toolbar"),T=k("link_list"),E=k("link_default_target"),D=k("link_default_protocol"),A=k("link_target_list"),M=k("link_rel_list"),N=k("link_class_list"),R=k("link_title"),B=k("allow_unsafe_link_target"),L=k("link_quicklink");var H=tinymce.util.Tools.resolve("tinymce.util.Tools");const I=e=>n(e.value)?e.value:"",P=(e,t)=>{const o=[];return H.each(e,(e=>{const r=(e=>n(e.text)?e.text:n(e.title)?e.title:"")(e);if(void 0!==e.menu){const n=P(e.menu,t);o.push({text:r,items:n})}else{const n=t(e);o.push({text:r,value:n})}})),o},F=(e=I)=>t=>p.from(t).map((t=>P(t,e))),z={sanitize:e=>F(I)(e),sanitizeWith:F,createUi:(e,t)=>o=>({name:e,type:"listbox",label:t,items:o}),getValue:I},V=Object.keys,Z=Object.hasOwnProperty,U=(e,t,o,n)=>{((e,t)=>{const o=V(e);for(let n=0,r=o.length;n{(t(e,r)?o:n)(e,r)}))},j=(e,t)=>Z.call(e,t);var $=tinymce.util.Tools.resolve("tinymce.dom.TreeWalker"),W=tinymce.util.Tools.resolve("tinymce.util.URI");const q=e=>c(e)&&"a"===e.nodeName.toLowerCase(),G=e=>q(e)&&!!X(e),K=(e,t)=>{if(e.collapsed)return[];{const o=e.cloneContents(),n=o.firstChild,r=new $(n,o),s=[];let a=n;do{t(a)&&s.push(a)}while(a=r.next());return s}},Y=e=>/^\w+:/i.test(e),X=e=>{var t,o;return null!==(o=null!==(t=e.getAttribute("data-mce-href"))&&void 0!==t?t:e.getAttribute("href"))&&void 0!==o?o:""},J=(e,t)=>{const o=["noopener"],n=e?e.split(/\s+/):[],r=e=>e.filter((e=>-1===H.inArray(o,e))),s=t?(e=>(e=r(e)).length>0?e.concat(o):o)(n):r(n);return s.length>0?(e=>H.trim(e.sort().join(" ")))(s):""},Q=(e,t)=>(t=t||oe(e.selection.getRng())[0]||e.selection.getNode(),ae(t)?p.from(e.dom.select("a[href]",t)[0]):p.from(e.dom.getParent(t,"a[href]"))),ee=(e,t)=>Q(e,t).isSome(),te=(e,t)=>(e=>e.replace(/\uFEFF/g,""))(t.fold((()=>e.getContent({format:"text"})),(e=>e.innerText||e.textContent||""))),oe=e=>K(e,G),ne=e=>H.grep(e,G),re=e=>ne(e).length>0,se=e=>{const t=e.schema.getTextInlineElements(),o=e=>1===e.nodeType&&!q(e)&&!j(t,e.nodeName.toLowerCase());if(Q(e).exists((e=>e.hasAttribute("data-mce-block"))))return!1;const n=e.selection.getRng();if(n.collapsed)return!0;return 0===K(n,o).length},ae=e=>c(e)&&"FIGURE"===e.nodeName&&/\bimage\b/i.test(e.className),ie=(e,t)=>{const o={...t};if(0===M(e).length&&!B(e)){const e=J(o.rel,"_blank"===o.target);o.rel=e||null}return p.from(o.target).isNone()&&!1===A(e)&&(o.target=E(e)),o.href=((e,t)=>"http"!==t&&"https"!==t||Y(e)?e:t+"://"+e)(o.href,_(e)),o},le=(e,t,o)=>{const n=e.selection.getNode(),r=Q(e,n),s=ie(e,(e=>{return t=["title","rel","class","target"],o=(t,o)=>(e[o].each((e=>{t[o]=e.length>0?e:null})),t),n={href:e.href},((e,t)=>{for(let o=0,n=e.length;o{n=o(n,e,t)})),n;var t,o,n})(o));e.undoManager.transact((()=>{o.href===t.href&&t.attach(),r.fold((()=>{((e,t,o,n)=>{const r=e.dom;ae(t)?ge(r,t,n):o.fold((()=>{e.execCommand("mceInsertLink",!1,n)}),(t=>{e.insertContent(r.createHTML("a",n,r.encode(t)))}))})(e,n,o.text,s)}),(t=>{e.focus(),((e,t,o,n)=>{o.each((e=>{j(t,"innerText")?t.innerText=e:t.textContent=e})),e.dom.setAttribs(t,n),e.selection.select(t)})(e,t,o.text,s)}))}))},ce=e=>{const{class:t,href:o,rel:n,target:r,text:s,title:i}=e;return((e,t)=>{const o={};var n;return U(e,t,(n=o,(e,t)=>{n[t]=e}),u),o})({class:t.getOrNull(),href:o,rel:n.getOrNull(),target:r.getOrNull(),text:s.getOrNull(),title:i.getOrNull()},((e,t)=>!1===a(e)))},de=(e,t,o)=>{const n=((e,t)=>{const o=e.options.get,n={allow_html_data_urls:o("allow_html_data_urls"),allow_script_urls:o("allow_script_urls"),allow_svg_data_urls:o("allow_svg_data_urls")},r=t.href;return{...t,href:W.isDomSafe(r,"a",n)?r:""}})(e,o);e.hasPlugin("rtc",!0)?e.execCommand("createlink",!1,ce(n)):le(e,t,n)},me=e=>{e.hasPlugin("rtc",!0)?e.execCommand("unlink"):(e=>{e.undoManager.transact((()=>{const t=e.selection.getNode();ae(t)?ue(e,t):(e=>{const t=e.dom,o=e.selection,n=o.getBookmark(),r=o.getRng().cloneRange(),s=t.getParent(r.startContainer,"a[href]",e.getBody()),a=t.getParent(r.endContainer,"a[href]",e.getBody());s&&r.setStartBefore(s),a&&r.setEndAfter(a),o.setRng(r),e.execCommand("unlink"),o.moveToBookmark(n)})(e),e.focus()}))})(e)},ue=(e,t)=>{var o;const n=e.dom.select("img",t)[0];if(n){const r=e.dom.getParents(n,"a[href]",t)[0];r&&(null===(o=r.parentNode)||void 0===o||o.insertBefore(n,r),e.dom.remove(r))}},ge=(e,t,o)=>{var n;const r=e.select("img",t)[0];if(r){const t=e.create("a",o);null===(n=r.parentNode)||void 0===n||n.insertBefore(t,r),t.appendChild(r)}},pe=e=>{return j(t=e,o="items")&&void 0!==t[o]&&null!==t[o];var t,o},he=(e,t)=>w(t,(t=>pe(t)?he(e,t.items):S(t.value===e,t))),fe=(e,t,o,n)=>{const r=n[t],s=e.length>0;return void 0!==r?he(r,o).map((t=>({url:{value:t.value,meta:{text:s?e:t.text,attach:u}},text:s?e:t.text}))):p.none()},be=(e,t)=>{const o={text:e.text,title:e.title},n=e=>{const t=(n=e.url,S(o.text.length<=0,p.from(null===(r=n.meta)||void 0===r?void 0:r.text).getOr(n.value)));var n,r;const s=(e=>{var t;return S(o.title.length<=0,p.from(null===(t=e.meta)||void 0===t?void 0:t.title).getOr(""))})(e.url);return t.isSome()||s.isSome()?p.some({...t.map((e=>({text:e}))).getOr({}),...s.map((e=>({title:e}))).getOr({})}):p.none()},r=(e,n)=>{const r=(s=t,a=n,"link"===a?s.link:"anchor"===a?s.anchor:p.none()).getOr([]);var s,a;return fe(o.text,n,r,e)};return{onChange:(e,t)=>{const s=t.name;return"url"===s?n(e()):b(["anchor","link"],s)?r(e(),s):"text"===s||"title"===s?(o[s]=e()[s],p.none()):p.none()}}};var ve=tinymce.util.Tools.resolve("tinymce.util.Delay");const ye=e=>{const t=e.href;return t.indexOf("@")>0&&-1===t.indexOf("/")&&-1===t.indexOf("mailto:")?p.some({message:"The URL you entered seems to be an email address. Do you want to add the required mailto: prefix?",preprocess:e=>({...e,href:"mailto:"+t})}):p.none()},we=(e,t)=>o=>{const n=o.href;return 1===e&&!Y(n)||0===e&&/^\s*www(\.|\d\.)/i.test(n)?p.some({message:`The URL you entered seems to be an external link. Do you want to add the required ${t}:// prefix?`,preprocess:e=>({...e,href:t+"://"+n})}):p.none()},xe=(e,t)=>w([ye,we(_(e),D(e))],(e=>e(t))).fold((()=>Promise.resolve(t)),(o=>new Promise((n=>{((e,t,o)=>{const n=e.selection.getRng();ve.setEditorTimeout(e,(()=>{e.windowManager.confirm(t,(t=>{e.selection.setRng(n),o(t)}))}))})(e,o.message,(e=>{n(e?o.preprocess(t):t)}))})))),Ce=e=>{const t=e.dom.select("a:not([href])"),o=y(t,(e=>{const t=e.name||e.id;return t?[{text:t,value:"#"+t}]:[]}));return o.length>0?p.some([{text:"None",value:""}].concat(o)):p.none()},Se=e=>{const t=N(e);return t.length>0?z.sanitize(t):p.none()},ke=e=>{try{return p.some(JSON.parse(e))}catch(e){return p.none()}},_e=e=>{const t=t=>e.convertURL(t.value||t.url||"","href"),o=T(e);return new Promise((e=>{n(o)?fetch(o).then((e=>e.ok?e.text().then(ke):Promise.reject())).then(e,(()=>e(p.none()))):d(o)?o((t=>e(p.some(t)))):e(p.from(o))})).then((e=>e.bind(z.sanitizeWith(t)).map((e=>{if(e.length>0){return[{text:"None",value:""}].concat(e)}return e}))))},Oe=(e,t)=>{const o=M(e);if(o.length>0){const n=x(t,"_blank"),r=e=>J(z.getValue(e),n);return(!1===B(e)?z.sanitizeWith(r):z.sanitize)(o)}return p.none()},Te=[{text:"Current window",value:""},{text:"New window",value:"_blank"}],Ee=e=>{const t=A(e);return s(t)?z.sanitize(t).orThunk((()=>p.some(Te))):!1===t?p.none():p.some(Te)},De=(e,t,o)=>{const n=e.getAttrib(t,o);return null!==n&&n.length>0?p.some(n):p.none()},Ae=(e,t)=>_e(e).then((o=>{const n=((e,t)=>{const o=e.dom,n=se(e)?p.some(te(e.selection,t)):p.none(),r=t.bind((e=>p.from(o.getAttrib(e,"href")))),s=t.bind((e=>p.from(o.getAttrib(e,"target")))),a=t.bind((e=>De(o,e,"rel"))),i=t.bind((e=>De(o,e,"class")));return{url:r,text:n,title:t.bind((e=>De(o,e,"title"))),target:s,rel:a,linkClass:i}})(e,t);return{anchor:n,catalogs:{targets:Ee(e),rels:Oe(e,n.target),classes:Se(e),anchor:Ce(e),link:o},optNode:t,flags:{titleEnabled:R(e)}}})),Me=e=>{const t=(e=>{const t=Q(e);return Ae(e,t)})(e);t.then((t=>{const o=((e,t)=>o=>{const n=o.getData();if(!n.url.value)return me(e),void o.close();const r=e=>p.from(n[e]).filter((o=>!x(t.anchor[e],o))),s={href:n.url.value,text:r("text"),target:r("target"),rel:r("rel"),class:r("linkClass"),title:r("title")},a={href:n.url.value,attach:void 0!==n.url.meta&&n.url.meta.attach?n.url.meta.attach:u};xe(e,s).then((t=>{de(e,a,t)})),o.close()})(e,t);return((e,t,o)=>{const n=e.anchor.text.map((()=>({name:"text",type:"input",label:"Text to display"}))).toArray(),r=e.flags.titleEnabled?[{name:"title",type:"input",label:"Title"}]:[],s=((e,t)=>{const o=e.anchor,n=o.url.getOr("");return{url:{value:n,meta:{original:{value:n}}},text:o.text.getOr(""),title:o.title.getOr(""),anchor:n,link:n,rel:o.rel.getOr(""),target:o.target.or(t).getOr(""),linkClass:o.linkClass.getOr("")}})(e,p.from(E(o))),a=e.catalogs,i=be(s,a);return{title:"Insert/Edit Link",size:"normal",body:{type:"panel",items:v([[{name:"url",type:"urlinput",filetype:"file",label:"URL"}],n,r,C([a.anchor.map(z.createUi("anchor","Anchors")),a.rels.map(z.createUi("rel","Rel")),a.targets.map(z.createUi("target","Open link in...")),a.link.map(z.createUi("link","Link list")),a.classes.map(z.createUi("linkClass","Class"))])])},buttons:[{type:"cancel",name:"cancel",text:"Cancel"},{type:"submit",name:"save",text:"Save",primary:!0}],initialData:s,onChange:(e,{name:t})=>{i.onChange(e.getData,{name:t}).each((t=>{e.setData(t)}))},onSubmit:t}})(t,o,e)})).then((t=>{e.windowManager.open(t)}))};var Ne=tinymce.util.Tools.resolve("tinymce.util.VK");const Re=e=>{const t=document.createElement("a");t.target="_blank",t.href=e,t.rel="noreferrer noopener";const o=document.createEvent("MouseEvents");o.initMouseEvent("click",!0,!0,window,0,0,0,0,0,!1,!1,!1,!1,0,null),((e,t)=>{document.body.appendChild(e),e.dispatchEvent(t),document.body.removeChild(e)})(t,o)},Be=(e,t)=>e.dom.getParent(t,"a[href]"),Le=e=>Be(e,e.selection.getStart()),He=(e,t)=>{if(t){const o=X(t);if(/^#/.test(o)){const t=e.dom.select(o);t.length&&e.selection.scrollIntoView(t[0],!0)}else Re(t.href)}},Ie=e=>()=>{e.execCommand("mceLink",!1,{dialog:!0})},Pe=e=>()=>{He(e,Le(e))},Fe=(e,t)=>(e.on("NodeChange",t),()=>e.off("NodeChange",t)),ze=e=>t=>{const o=()=>{t.setActive(!e.mode.isReadOnly()&&ee(e,e.selection.getNode())),t.setEnabled(e.selection.isEditable())};return o(),Fe(e,o)},Ve=e=>t=>{const o=()=>{t.setEnabled(e.selection.isEditable())};return o(),Fe(e,o)},Ze=e=>t=>{const o=()=>t.setEnabled((e=>1===(e.selection.isCollapsed()?ne(e.dom.getParents(e.selection.getStart())):oe(e.selection.getRng())).length)(e));return o(),Fe(e,o)},Ue=e=>t=>{const o=t=>{return re(t)||(o=e.selection.getRng(),oe(o).length>0);var o},n=e.dom.getParents(e.selection.getStart()),r=n=>{t.setEnabled(o(n)&&e.selection.isEditable())};return r(n),Fe(e,(e=>r(e.parents)))},je=e=>{const t=t=>{const o=e.selection.getNode();return t.setEnabled(ee(e,o)),u};e.ui.registry.addContextForm("quicklink",{launch:{type:"contextformtogglebutton",icon:"link",tooltip:"Link",onSetup:ze(e)},label:"Link",predicate:t=>O(e)&&ee(e,t),initValue:()=>{return Q(e).fold((t="",()=>t),X);var t},commands:[{type:"contextformtogglebutton",icon:"link",tooltip:"Link",primary:!0,onSetup:t=>{const o=e.selection.getNode();return t.setActive(ee(e,o)),ze(e)(t)},onAction:t=>{const o=t.getValue(),n=(t=>{const o=Q(e),n=se(e);if(o.isNone()&&n){const n=te(e.selection,o);return S(0===n.length,t)}return p.none()})(o);de(e,{href:o,attach:u},{href:o,text:n,title:p.none(),rel:p.none(),target:p.none(),class:p.none()}),(e=>{e.selection.collapse(!1)})(e),t.hide()}},{type:"contextformbutton",icon:"unlink",tooltip:"Remove link",onSetup:t,onAction:t=>{me(e),t.hide()}},{type:"contextformbutton",icon:"new-tab",tooltip:"Open link",onSetup:t,onAction:t=>{Pe(e)(),t.hide()}}]})};e.add("link",(e=>{(e=>{const t=e.options.register;t("link_assume_external_targets",{processor:e=>{const t=n(e)||l(e);return t?!0===e?{value:1,valid:t}:"http"===e||"https"===e?{value:e,valid:t}:{value:0,valid:t}:{valid:!1,message:"Must be a string or a boolean."}},default:!1}),t("link_context_toolbar",{processor:"boolean",default:!1}),t("link_list",{processor:e=>n(e)||d(e)||m(e,r)}),t("link_default_target",{processor:"string"}),t("link_default_protocol",{processor:"string",default:"https"}),t("link_target_list",{processor:e=>l(e)||m(e,r),default:!0}),t("link_rel_list",{processor:"object[]",default:[]}),t("link_class_list",{processor:"object[]",default:[]}),t("link_title",{processor:"boolean",default:!0}),t("allow_unsafe_link_target",{processor:"boolean",default:!1}),t("link_quicklink",{processor:"boolean",default:!1})})(e),(e=>{e.ui.registry.addToggleButton("link",{icon:"link",tooltip:"Insert/edit link",onAction:Ie(e),onSetup:ze(e)}),e.ui.registry.addButton("openlink",{icon:"new-tab",tooltip:"Open link",onAction:Pe(e),onSetup:Ze(e)}),e.ui.registry.addButton("unlink",{icon:"unlink",tooltip:"Remove link",onAction:()=>me(e),onSetup:Ue(e)})})(e),(e=>{e.ui.registry.addMenuItem("openlink",{text:"Open link",icon:"new-tab",onAction:Pe(e),onSetup:Ze(e)}),e.ui.registry.addMenuItem("link",{icon:"link",text:"Link...",shortcut:"Meta+K",onSetup:Ve(e),onAction:Ie(e)}),e.ui.registry.addMenuItem("unlink",{icon:"unlink",text:"Remove link",onAction:()=>me(e),onSetup:Ue(e)})})(e),(e=>{e.ui.registry.addContextMenu("link",{update:t=>e.dom.isEditable(t)?re(e.dom.getParents(t,"a"))?"link unlink openlink":"link":""})})(e),je(e),(e=>{e.on("click",(t=>{const o=Be(e,t.target);o&&Ne.metaKeyPressed(t)&&(t.preventDefault(),He(e,o))})),e.on("keydown",(t=>{if(!t.isDefaultPrevented()&&13===t.keyCode&&(e=>!0===e.altKey&&!1===e.shiftKey&&!1===e.ctrlKey&&!1===e.metaKey)(t)){const o=Le(e);o&&(t.preventDefault(),He(e,o))}}))})(e),(e=>{e.addCommand("mceLink",((t,o)=>{!0!==(null==o?void 0:o.dialog)&&L(e)?e.dispatch("contexttoolbar-show",{toolbarKey:"quicklink"}):Me(e)}))})(e),(e=>{e.addShortcut("Meta+K","",(()=>{e.execCommand("mceLink")}))})(e)}))}()},1236:(e,t,o)=>{o(7585)},7585:()=>{!function(){"use strict";var e=tinymce.util.Tools.resolve("tinymce.PluginManager");const t=e=>t=>(e=>{const t=typeof e;return null===e?"null":"object"===t&&Array.isArray(e)?"array":"object"===t&&(o=r=e,n=(s=String).prototype,n.isPrototypeOf(o)||(null===(a=r.constructor)||void 0===a?void 0:a.name)===s.name)?"string":t;var o,n;var r,s,a})(t)===e,o=e=>t=>typeof t===e,n=t("string"),r=t("object"),s=t("array"),a=o("boolean"),i=e=>!(e=>null==e)(e),l=o("function"),c=o("number"),d=()=>{},m=(e,t)=>e===t;const u=e=>t=>!e(t),g=(p=!1,()=>p);var p;class h{constructor(e,t){this.tag=e,this.value=t}static some(e){return new h(!0,e)}static none(){return h.singletonNone}fold(e,t){return this.tag?t(this.value):e()}isSome(){return this.tag}isNone(){return!this.tag}map(e){return this.tag?h.some(e(this.value)):h.none()}bind(e){return this.tag?e(this.value):h.none()}exists(e){return this.tag&&e(this.value)}forall(e){return!this.tag||e(this.value)}filter(e){return!this.tag||e(this.value)?this:h.none()}getOr(e){return this.tag?this.value:e}or(e){return this.tag?this:e}getOrThunk(e){return this.tag?this.value:e()}orThunk(e){return this.tag?this:e()}getOrDie(e){if(this.tag)return this.value;throw new Error(null!=e?e:"Called getOrDie on None")}static from(e){return i(e)?h.some(e):h.none()}getOrNull(){return this.tag?this.value:null}getOrUndefined(){return this.value}each(e){this.tag&&e(this.value)}toArray(){return this.tag?[this.value]:[]}toString(){return this.tag?`some(${this.value})`:"none()"}}h.singletonNone=new h(!1);const f=Array.prototype.slice,b=Array.prototype.indexOf,v=Array.prototype.push,y=(e,t)=>{return o=e,n=t,b.call(o,n)>-1;var o,n},w=(e,t)=>{for(let o=0,n=e.length;o{const o=e.length,n=new Array(o);for(let r=0;r{for(let o=0,n=e.length;o{const o=[];for(let n=0,r=e.length;n(C(e,((e,n)=>{o=t(o,e,n)})),o),_=(e,t,o)=>{for(let n=0,r=e.length;n_(e,t,g),T=(e,t)=>(e=>{const t=[];for(let o=0,n=e.length;o{const t=f.call(e,0);return t.reverse(),t},D=(e,t)=>t>=0&&tD(e,0),M=e=>D(e,e.length-1),N=(e,t)=>{const o=[],n=l(t)?e=>w(o,(o=>t(o,e))):e=>y(o,e);for(let t=0,r=e.length;te.exists((e=>o(e,t))),B=(e,t,o)=>e.isSome()&&t.isSome()?h.some(o(e.getOrDie(),t.getOrDie())):h.none(),L=e=>{if(null==e)throw new Error("Node cannot be null or undefined");return{dom:e}},H={fromHtml:(e,t)=>{const o=(t||document).createElement("div");if(o.innerHTML=e,!o.hasChildNodes()||o.childNodes.length>1){const t="HTML does not have a single root node";throw console.error(t,e),new Error(t)}return L(o.childNodes[0])},fromTag:(e,t)=>{const o=(t||document).createElement(e);return L(o)},fromText:(e,t)=>{const o=(t||document).createTextNode(e);return L(o)},fromDom:L,fromPoint:(e,t,o)=>h.from(e.dom.elementFromPoint(t,o)).map(L)},I=(e,t)=>e.dom===t.dom,P=(e,t)=>{const o=e.dom;if(1!==o.nodeType)return!1;{const e=o;if(void 0!==e.matches)return e.matches(t);if(void 0!==e.msMatchesSelector)return e.msMatchesSelector(t);if(void 0!==e.webkitMatchesSelector)return e.webkitMatchesSelector(t);if(void 0!==e.mozMatchesSelector)return e.mozMatchesSelector(t);throw new Error("Browser lacks native selectors")}};"undefined"!=typeof window?window:Function("return this;")();const F=e=>e.dom.nodeName.toLowerCase(),z=e=>e.dom.nodeType,V=(Z=1,e=>z(e)===Z);var Z;const U=e=>t=>V(t)&&F(t)===e,j=e=>h.from(e.dom.parentNode).map(H.fromDom),$=e=>x(e.dom.childNodes,H.fromDom),W=(e,t)=>{const o=e.dom.childNodes;return h.from(o[t]).map(H.fromDom)},q=e=>W(e,0),G=e=>W(e,e.dom.childNodes.length-1),K=(e,t,o)=>{let n=e.dom;const r=l(o)?o:g;for(;n.parentNode;){n=n.parentNode;const e=H.fromDom(n);if(t(e))return h.some(e);if(r(e))break}return h.none()},Y=(e,t,o)=>((e,t,o,n,r)=>e(o,n)?h.some(o):l(r)&&r(o)?h.none():t(o,n,r))(((e,t)=>t(e)),K,e,t,o),X=(e,t)=>{j(e).each((o=>{o.dom.insertBefore(t.dom,e.dom)}))},J=(e,t)=>{const o=(e=>h.from(e.dom.nextSibling).map(H.fromDom))(e);o.fold((()=>{j(e).each((e=>{Q(e,t)}))}),(e=>{X(e,t)}))},Q=(e,t)=>{e.dom.appendChild(t.dom)},ee=(e,t)=>{C(t,(t=>{Q(e,t)}))},te=e=>{e.dom.textContent="",C($(e),(e=>{oe(e)}))},oe=e=>{const t=e.dom;null!==t.parentNode&&t.parentNode.removeChild(t)};var ne=tinymce.util.Tools.resolve("tinymce.dom.RangeUtils"),re=tinymce.util.Tools.resolve("tinymce.dom.TreeWalker"),se=tinymce.util.Tools.resolve("tinymce.util.VK");const ae=e=>x(e,H.fromDom),ie=Object.keys,le=(e,t)=>{const o=ie(e);for(let n=0,r=o.length;n{const o={};var n;return((e,t,o,n)=>{le(e,((e,r)=>{(t(e,r)?o:n)(e,r)}))})(e,t,(n=o,(e,t)=>{n[t]=e}),d),o},de=(e,t)=>{const o=e.dom;le(t,((e,t)=>{((e,t,o)=>{if(!(n(o)||a(o)||c(o)))throw console.error("Invalid call to Attribute.set. Key ",t,":: Value ",o,":: Element ",e),new Error("Attribute value was not simple");e.setAttribute(t,o+"")})(o,t,e)}))},me=e=>k(e.dom.attributes,((e,t)=>(e[t.name]=t.value,e)),{}),ue=e=>((e,t)=>H.fromDom(e.dom.cloneNode(t)))(e,!0),ge=(e,t)=>{const o=((e,t)=>{const o=H.fromTag(t),n=me(e);return de(o,n),o})(e,t);J(e,o);const n=$(e);return ee(o,n),oe(e),o};var pe=tinymce.util.Tools.resolve("tinymce.dom.DOMUtils"),he=tinymce.util.Tools.resolve("tinymce.util.Tools");const fe=e=>t=>i(t)&&t.nodeName.toLowerCase()===e,be=e=>t=>i(t)&&e.test(t.nodeName),ve=e=>i(e)&&3===e.nodeType,ye=e=>i(e)&&1===e.nodeType,we=be(/^(OL|UL|DL)$/),xe=be(/^(OL|UL)$/),Ce=fe("ol"),Se=be(/^(LI|DT|DD)$/),ke=be(/^(DT|DD)$/),_e=be(/^(TH|TD)$/),Oe=fe("br"),Te=(e,t)=>i(t)&&t.nodeName in e.schema.getTextBlockElements(),Ee=(e,t)=>i(e)&&e.nodeName in t,De=(e,t)=>i(t)&&t.nodeName in e.schema.getVoidElements(),Ae=(e,t,o)=>{const n=e.isEmpty(t);return!(o&&e.select("span[data-mce-type=bookmark]",t).length>0)&&n},Me=(e,t)=>e.isChildOf(t,e.getRoot()),Ne=e=>t=>t.options.get(e),Re=Ne("lists_indent_on_tab"),Be=Ne("forced_root_block"),Le=Ne("forced_root_block_attrs"),He=(e,t)=>{const o=e.dom,n=e.schema.getBlockElements(),r=o.createFragment(),s=Be(e),a=Le(e);let i,l,c=!1;for(l=o.create(s,a),Ee(t.firstChild,n)||r.appendChild(l);i=t.firstChild;){const e=i.nodeName;c||"SPAN"===e&&"bookmark"===i.getAttribute("data-mce-type")||(c=!0),Ee(i,n)?(r.appendChild(i),l=null):(l||(l=o.create(s,a),r.appendChild(l)),l.appendChild(i))}return!c&&l&&l.appendChild(o.create("br",{"data-mce-bogus":"1"})),r},Ie=pe.DOM,Pe=(e,t,o)=>{const n=Ie.select('span[data-mce-type="bookmark"]',t),r=He(e,o),s=Ie.createRng();s.setStartAfter(o),s.setEndAfter(t);const a=s.extractContents();for(let t=a.firstChild;t;t=t.firstChild)if("LI"===t.nodeName&&e.dom.isEmpty(t)){Ie.remove(t);break}e.dom.isEmpty(a)||Ie.insertAfter(a,t),Ie.insertAfter(r,t);const i=o.parentElement;i&&Ae(e.dom,i)&&(e=>{const t=e.parentNode;t&&he.each(n,(e=>{t.insertBefore(e,o.parentNode)})),Ie.remove(e)})(i),Ie.remove(o),Ae(e.dom,t)&&Ie.remove(t)},Fe=U("dd"),ze=U("dt"),Ve=(e,t)=>{var o;Fe(t)?ge(t,"dt"):ze(t)&&(o=t,h.from(o.dom.parentElement).map(H.fromDom)).each((o=>Pe(e,o.dom,t.dom)))},Ze=e=>{ze(e)&&ge(e,"dd")},Ue=(e,t)=>{if(ve(e))return{container:e,offset:t};const o=ne.getNode(e,t);return ve(o)?{container:o,offset:t>=e.childNodes.length?o.data.length:0}:o.previousSibling&&ve(o.previousSibling)?{container:o.previousSibling,offset:o.previousSibling.data.length}:o.nextSibling&&ve(o.nextSibling)?{container:o.nextSibling,offset:0}:{container:e,offset:t}},je=e=>{const t=e.cloneRange(),o=Ue(e.startContainer,e.startOffset);t.setStart(o.container,o.offset);const n=Ue(e.endContainer,e.endOffset);return t.setEnd(n.container,n.offset),t},$e=["OL","UL","DL"],We=$e.join(","),qe=(e,t)=>{const o=t||e.selection.getStart(!0);return e.dom.getParent(o,We,Xe(e,o))},Ge=e=>{const t=qe(e),o=e.selection.getSelectedBlocks();return((e,t)=>i(e)&&1===t.length&&t[0]===e)(t,o)?(e=>S(e.querySelectorAll(We),we))(t):S(o,(e=>we(e)&&t!==e))},Ke=e=>{const t=e.selection.getSelectedBlocks();return S(((e,t)=>{const o=he.map(t,(t=>e.dom.getParent(t,"li,dd,dt",Xe(e,t))||t));return N(o)})(e,t),Se)},Ye=(e,t)=>{const o=e.dom.getParents(t,"TD,TH");return o.length>0?o[0]:e.getBody()},Xe=(e,t)=>{const o=e.dom.getParents(t,e.dom.isBlock),n=O(o,(t=>{return o=e.schema,!we(n=t)&&!Se(n)&&w($e,(e=>o.isValidChild(n.nodeName,e)));var o,n}));return n.getOr(e.getBody())},Je=(e,t)=>{const o=e.dom.getParents(t,"ol,ul",Xe(e,t));return M(o)},Qe=e=>{const t=(e=>{const t=Je(e,e.selection.getStart()),o=S(e.selection.getSelectedBlocks(),xe);return t.toArray().concat(o)})(e),o=(e=>{const t=e.selection.getStart();return e.dom.getParents(t,"ol,ul",Xe(e,t))})(e);return O(o,(e=>{return t=H.fromDom(e),j(t).exists((e=>Se(e.dom)&&q(e).exists((e=>!we(e.dom)))&&G(e).exists((e=>!we(e.dom)))));var t})).fold((()=>et(e,t)),(e=>[e]))},et=(e,t)=>{const o=x(t,(t=>Je(e,t).getOr(t)));return N(o)},tt=e=>/\btox\-/.test(e.className),ot=(e,t)=>_(e,we,_e).exists((e=>e.nodeName===t&&!tt(e))),nt=(e,t)=>null!==t&&!e.dom.isEditable(t),rt=(e,t)=>{const o=e.dom.getParent(t,"ol,ul,dl");return nt(e,o)},st=(e,t)=>{const o=e.selection.getNode();return t({parents:e.dom.getParents(o),element:o}),e.on("NodeChange",t),()=>e.off("NodeChange",t)},at=(e,t)=>{const o=(t||document).createDocumentFragment();return C(e,(e=>{o.appendChild(e.dom)})),H.fromDom(o)},it=(e,t,o)=>e.dispatch("ListMutation",{action:t,element:o}),lt=(ct=/^\s+|\s+$/g,e=>e.replace(ct,""));var ct;const dt=(e,t,o)=>{if(!n(o))throw console.error("Invalid call to CSS.set. Property ",t,":: Value ",o,":: Element ",e),new Error("CSS value must be a string: "+o);(e=>void 0!==e.style&&l(e.style.getPropertyValue))(e)&&e.style.setProperty(t,o)},mt=(e,t,o)=>{const n=e.dom;dt(n,t,o)},ut=e=>P(e,"OL,UL"),gt=e=>q(e).exists(ut),pt=e=>"listAttributes"in e,ht=e=>"isComment"in e,ft=e=>e.depth>0,bt=e=>e.isSelected,vt=e=>{const t=$(e),o=G(e).exists(ut)?t.slice(0,-1):t;return x(o,ue)},yt=(e,t)=>{Q(e.item,t.list)},wt=(e,t)=>{const o={list:H.fromTag(t,e),item:H.fromTag("li",e)};return Q(o.list,o.item),o},xt=(e,t,o)=>{const n=t.slice(0,o.depth);return M(n).each((t=>{if(pt(o)){const n=((e,t,o)=>{const n=H.fromTag("li",e);return de(n,t),ee(n,o),n})(e,o.itemAttributes,o.content);((e,t)=>{Q(e.list,t),e.item=t})(t,n),((e,t)=>{F(e.list)!==t.listType&&(e.list=ge(e.list,t.listType)),de(e.list,t.listAttributes)})(t,o)}else if((e=>"isInPreviousLi"in e)(o)){if(o.isInPreviousLi){const n=((e,t,o,n)=>{const r=H.fromTag(n,e);return de(r,t),ee(r,o),r})(e,o.attributes,o.content,o.type);Q(t.item,n)}}else{const e=H.fromHtml(`\x3c!--${o.content}--\x3e`);Q(t.list,e)}})),n},Ct=(e,t,o)=>{const n=((e,t,o)=>{const n=[];for(let r=0;r{for(let t=1;t{for(let t=0;t{de(e.list,t.listAttributes),de(e.item,t.itemAttributes),ee(e.item,t.content)}))})(n,o),r=n,B(M(t),A(r),yt),t.concat(n)},St=(e,t)=>{let o=h.none();const n=k(t,((t,n,r)=>pt(n)?n.depth>t.length?Ct(e,t,n):xt(e,t,n):0===r&&ht(n)?(o=h.some(n),t):xt(e,t,n)),[]);return o.each((e=>{const t=H.fromHtml(`\x3c!--${e.content}--\x3e`);A(n).each((e=>{((e,t)=>{q(e).fold((()=>{Q(e,t)}),(o=>{e.dom.insertBefore(t.dom,o.dom)}))})(e.list,t)}))})),A(n).map((e=>e.list))},kt=e=>(C(e,((t,o)=>{((e,t)=>{const o=e[t].depth,n=e=>e.depth===o&&!e.dirty,r=e=>e.depth_(e.slice(t+1),n,r)))})(e,o).fold((()=>{t.dirty&&pt(t)&&(e=>{e.listAttributes=ce(e.listAttributes,((e,t)=>"start"!==t))})(t)}),(e=>{return n=e,void(pt(o=t)&&pt(n)&&(o.listType=n.listType,o.listAttributes={...n.listAttributes}));var o,n}))})),e),_t=(e,t,o,n)=>{var r,s;if(8===z(s=n)||"#comment"===F(s))return[{depth:e+1,content:null!==(r=n.dom.nodeValue)&&void 0!==r?r:"",dirty:!1,isSelected:!1,isComment:!0}];t.each((e=>{I(e.start,n)&&o.set(!0)}));const a=((e,t,o)=>j(e).filter(V).map((n=>({depth:t,dirty:!1,isSelected:o,content:vt(e),itemAttributes:me(e),listAttributes:me(n),listType:F(n),isInPreviousLi:!1}))))(n,e,o.get());t.each((e=>{I(e.end,n)&&o.set(!1)}));const i=G(n).filter(ut).map((n=>Tt(e,t,o,n))).getOr([]);return a.toArray().concat(i)},Ot=(e,t,o,n)=>q(n).filter(ut).fold((()=>_t(e,t,o,n)),(r=>{const s=k($(n),((n,r,s)=>{if(0===s)return n;{const s=_t(e,t,o,r).map((e=>((e,t,o)=>pt(e)?{depth:e.depth,dirty:e.dirty,content:e.content,isSelected:e.isSelected,type:t,attributes:e.itemAttributes,isInPreviousLi:o}:e)(e,r.dom.nodeName.toLowerCase(),!0)));return n.concat(s)}}),[]);return Tt(e,t,o,r).concat(s)})),Tt=(e,t,o,n)=>T($(n),(n=>(ut(n)?Tt:Ot)(e+1,t,o,n))),Et=(e,t)=>T(((e,t)=>{if(0===e.length)return[];{let o=t(e[0]);const n=[];let r=[];for(let s=0,a=e.length;sA(t).exists(ft)?((e,t)=>{const o=kt(t);return St(e.contentDocument,o).toArray()})(e,t):((e,t)=>{const o=kt(t);return x(o,(t=>{const o=ht(t)?at([H.fromHtml(`\x3c!--${t.content}--\x3e`)]):at(t.content);return H.fromDom(He(e,o.dom))}))})(e,t))),Dt=(e,t,o)=>{const n=((e,t)=>{const o=(e=>{let t=!1;return{get:()=>t,set:e=>{t=e}}})();return x(e,(e=>({sourceList:e,entries:Tt(0,t,o,e)})))})(t,(e=>{const t=x(Ke(e),H.fromDom);return B(O(t,u(gt)),O(E(t),u(gt)),((e,t)=>({start:e,end:t})))})(e));C(n,(t=>{((e,t)=>{C(S(e,bt),(e=>((e,t)=>{switch(e){case"Indent":t.depth++;break;case"Outdent":t.depth--;break;case"Flatten":t.depth=0}t.dirty=!0})(t,e)))})(t.entries,o);const n=Et(e,t.entries);var r;C(n,(t=>{it(e,"Indent"===o?"IndentList":"OutdentList",t.dom)})),r=t.sourceList,C(n,(e=>{X(r,e)})),oe(t.sourceList)}))},At=(e,t)=>{const o=ae(Qe(e)),n=ae((e=>S(Ke(e),ke))(e));let r=!1;if(o.length||n.length){const s=e.selection.getBookmark();Dt(e,o,t),((e,t,o)=>{C(o,"Indent"===t?Ze:t=>Ve(e,t))})(e,t,n),e.selection.moveToBookmark(s),e.selection.setRng(je(e.selection.getRng())),e.nodeChanged(),r=!0}return r},Mt=(e,t)=>!(e=>{const t=qe(e);return nt(e,t)})(e)&&At(e,t),Nt=e=>Mt(e,"Indent"),Rt=e=>Mt(e,"Outdent"),Bt=e=>Mt(e,"Flatten"),Lt=e=>"\ufeff"===e,Ht=(e,t)=>{return o=e,n=function(e,...t){return(...o)=>{const n=t.concat(o);return e.apply(null,n)}}(I,t),K(o,n,r).isSome();var o,n,r};var It=tinymce.util.Tools.resolve("tinymce.dom.BookmarkManager");const Pt=pe.DOM,Ft=e=>{const t={},o=o=>{let n=e[o?"startContainer":"endContainer"],r=e[o?"startOffset":"endOffset"];if(ye(n)){const e=Pt.create("span",{"data-mce-type":"bookmark"});n.hasChildNodes()?(r=Math.min(r,n.childNodes.length-1),o?n.insertBefore(e,n.childNodes[r]):Pt.insertAfter(e,n.childNodes[r])):n.appendChild(e),n=e,r=0}t[o?"startContainer":"endContainer"]=n,t[o?"startOffset":"endOffset"]=r};return o(!0),e.collapsed||o(),t},zt=e=>{const t=t=>{let o=e[t?"startContainer":"endContainer"],n=e[t?"startOffset":"endOffset"];if(o){if(ye(o)&&o.parentNode){const e=o;n=(e=>{var t;let o=null===(t=e.parentNode)||void 0===t?void 0:t.firstChild,n=0;for(;o;){if(o===e)return n;ye(o)&&"bookmark"===o.getAttribute("data-mce-type")||n++,o=o.nextSibling}return-1})(o),o=o.parentNode,Pt.remove(e),!o.hasChildNodes()&&Pt.isBlock(o)&&o.appendChild(Pt.create("br"))}e[t?"startContainer":"endContainer"]=o,e[t?"startOffset":"endOffset"]=n}};t(!0),t();const o=Pt.createRng();return o.setStart(e.startContainer,e.startOffset),e.endContainer&&o.setEnd(e.endContainer,e.endOffset),je(o)},Vt=e=>{switch(e){case"UL":return"ToggleUlList";case"OL":return"ToggleOlList";case"DL":return"ToggleDLList"}},Zt=(e,t)=>{he.each(t,((t,o)=>{e.setAttribute(o,t)}))},Ut=(e,t,o)=>{((e,t,o)=>{const n=o["list-style-type"]?o["list-style-type"]:null;e.setStyle(t,"list-style-type",n)})(e,t,o),((e,t,o)=>{Zt(t,o["list-attributes"]),he.each(e.select("li",t),(e=>{Zt(e,o["list-item-attributes"])}))})(e,t,o)},jt=(e,t)=>i(t)&&!Ee(t,e.schema.getBlockElements()),$t=(e,t,o,n)=>{let r=t[o?"startContainer":"endContainer"];const s=t[o?"startOffset":"endOffset"];ye(r)&&(r=r.childNodes[Math.min(s,r.childNodes.length-1)]||r),!o&&Oe(r.nextSibling)&&(r=r.nextSibling);const a=(t,o)=>{var r;const s=new re(t,(t=>{for(;!e.dom.isBlock(t)&&t.parentNode&&n!==t;)t=t.parentNode;return t})(t)),a=o?"next":"prev";let i;for(;i=s[a]();)if(!De(e,i)&&!Lt(i.textContent)&&0!==(null===(r=i.textContent)||void 0===r?void 0:r.length))return h.some(i);return h.none()};if(o&&ve(r))if(Lt(r.textContent))r=a(r,!1).getOr(r);else for(null!==r.parentNode&&jt(e,r.parentNode)&&(r=r.parentNode);null!==r.previousSibling&&(jt(e,r.previousSibling)||ve(r.previousSibling));)r=r.previousSibling;if(!o&&ve(r))if(Lt(r.textContent))r=a(r,!0).getOr(r);else for(null!==r.parentNode&&jt(e,r.parentNode)&&(r=r.parentNode);null!==r.nextSibling&&(jt(e,r.nextSibling)||ve(r.nextSibling));)r=r.nextSibling;for(;r.parentNode!==n;){const t=r.parentNode;if(Te(e,r))return r;if(/^(TD|TH)$/.test(t.nodeName))return r;r=t}return r},Wt=(e,t,o)=>{const n=e.selection.getRng();let r="LI";const s=Xe(e,((e,t)=>{const o=e.selection.getStart(!0),n=$t(e,t,!0,e.getBody());return Ht(H.fromDom(n),H.fromDom(t.commonAncestorContainer))?t.commonAncestorContainer:o})(e,n)),a=e.dom;if("false"===a.getContentEditable(e.selection.getNode()))return;"DL"===(t=t.toUpperCase())&&(r="DT");const i=Ft(n),l=S(((e,t,o)=>{const n=[],r=e.dom,s=$t(e,t,!0,o),a=$t(e,t,!1,o);let i;const l=[];for(let e=s;e&&(l.push(e),e!==a);e=e.nextSibling);return he.each(l,(t=>{var s;if(Te(e,t))return n.push(t),void(i=null);if(r.isBlock(t)||Oe(t))return Oe(t)&&r.remove(t),void(i=null);const a=t.nextSibling;It.isBookmarkNode(t)&&(we(a)||Te(e,a)||!a&&t.parentNode===o)?i=null:(i||(i=r.create("p"),null===(s=t.parentNode)||void 0===s||s.insertBefore(i,t),n.push(i)),i.appendChild(t))})),n})(e,n,s),e.dom.isEditable);he.each(l,(n=>{let s;const i=n.previousSibling,l=n.parentNode;Se(l)||(i&&we(i)&&i.nodeName===t&&((e,t,o)=>{const n=e.getStyle(t,"list-style-type");let r=o?o["list-style-type"]:"";return r=null===r?"":r,n===r})(a,i,o)?(s=i,n=a.rename(n,r),i.appendChild(n)):(s=a.create(t),l.insertBefore(s,n),s.appendChild(n),n=a.rename(n,r)),((e,t,o)=>{he.each(o,(o=>e.setStyle(t,o,"")))})(a,n,["margin","margin-right","margin-bottom","margin-left","margin-top","padding","padding-right","padding-bottom","padding-left","padding-top"]),Ut(a,s,o),Gt(e.dom,s))})),e.selection.setRng(zt(i))},qt=(e,t,o)=>{return((e,t)=>we(e)&&e.nodeName===(null==t?void 0:t.nodeName))(t,o)&&((e,t,o)=>e.getStyle(t,"list-style-type",!0)===e.getStyle(o,"list-style-type",!0))(e,t,o)&&(n=o,t.className===n.className);var n},Gt=(e,t)=>{let o,n=t.nextSibling;if(qt(e,t,n)){const r=n;for(;o=r.firstChild;)t.appendChild(o);e.remove(r)}if(n=t.previousSibling,qt(e,t,n)){const r=n;for(;o=r.lastChild;)t.insertBefore(o,t.firstChild);e.remove(r)}},Kt=(e,t,o,n)=>{if(t.nodeName!==o){const r=e.dom.rename(t,o);Ut(e.dom,r,n),it(e,Vt(o),r)}else Ut(e.dom,t,n),it(e,Vt(o),t)},Yt=(e,t,o,n)=>{if(t.classList.forEach(((e,o,n)=>{e.startsWith("tox-")&&(n.remove(e),0===n.length&&t.removeAttribute("class"))})),t.nodeName!==o){const r=e.dom.rename(t,o);Ut(e.dom,r,n),it(e,Vt(o),r)}else Ut(e.dom,t,n),it(e,Vt(o),t)},Xt=e=>"list-style-type"in e,Jt=(e,t,o)=>{const n=qe(e);if(rt(e,n))return;const s=Ge(e),a=r(o)?o:{};s.length>0?((e,t,o,n,r)=>{const s=we(t);if(!s||t.nodeName!==n||Xt(r)||tt(t)){Wt(e,n,r);const a=Ft(e.selection.getRng()),i=s?[t,...o]:o,l=s&&tt(t)?Yt:Kt;he.each(i,(t=>{l(e,t,n,r)})),e.selection.setRng(zt(a))}else Bt(e)})(e,n,s,t,a):((e,t,o,n)=>{if(t!==e.getBody())if(t)if(t.nodeName!==o||Xt(n)||tt(t)){const r=Ft(e.selection.getRng());tt(t)&&t.classList.forEach(((e,o,n)=>{e.startsWith("tox-")&&(n.remove(e),0===n.length&&t.removeAttribute("class"))})),Ut(e.dom,t,n);const s=e.dom.rename(t,o);Gt(e.dom,s),e.selection.setRng(zt(r)),Wt(e,o,n),it(e,Vt(o),s)}else Bt(e);else Wt(e,o,n),it(e,Vt(o),t)})(e,n,t,a)},Qt=pe.DOM,eo=(e,t)=>{const o=he.grep(e.select("ol,ul",t));he.each(o,(t=>{((e,t)=>{const o=t.parentElement;if(o&&"LI"===o.nodeName&&o.firstChild===t){const n=o.previousSibling;n&&"LI"===n.nodeName?(n.appendChild(t),Ae(e,o)&&Qt.remove(o)):Qt.setStyle(o,"listStyleType","none")}if(we(o)){const e=o.previousSibling;e&&"LI"===e.nodeName&&e.appendChild(t)}})(e,t)}))},to=(e,t,o,n)=>{let r=t.startContainer;const s=t.startOffset;if(ve(r)&&(o?s0))return r;const a=e.schema.getNonEmptyElements();ye(r)&&(r=ne.getNode(r,s));const i=new re(r,n);o&&((e,t)=>!!Oe(t)&&e.isBlock(t.nextSibling)&&!Oe(t.previousSibling))(e.dom,r)&&i.next();const l=o?i.next.bind(i):i.prev2.bind(i);for(;r=l();){if("LI"===r.nodeName&&!r.hasChildNodes())return r;if(a[r.nodeName])return r;if(ve(r)&&r.data.length>0)return r}return null},oo=(e,t)=>{const o=t.childNodes;return 1===o.length&&!we(o[0])&&e.isBlock(o[0])},no=(e,t,o)=>{let n;const r=oo(e,o)?o.firstChild:o;if(((e,t)=>{oo(e,t)&&e.remove(t.firstChild,!0)})(e,t),!Ae(e,t,!0))for(;n=t.firstChild;)r.appendChild(n)},ro=(e,t,o)=>{let n;const r=t.parentNode;if(!Me(e,t)||!Me(e,o))return;we(o.lastChild)&&(n=o.lastChild),r===o.lastChild&&Oe(r.previousSibling)&&e.remove(r.previousSibling);const s=o.lastChild;s&&Oe(s)&&t.hasChildNodes()&&e.remove(s),Ae(e,o,!0)&&te(H.fromDom(o)),no(e,t,o),n&&o.appendChild(n);const a=((e,t)=>{const o=e.dom,n=t.dom;return o!==n&&o.contains(n)})(H.fromDom(o),H.fromDom(t))?e.getParents(t,we,o):[];e.remove(t),C(a,(t=>{Ae(e,t)&&t!==e.getRoot()&&e.remove(t)}))},so=(e,t,o,n)=>{const r=e.dom;if(r.isEmpty(n))((e,t,o)=>{te(H.fromDom(o)),ro(e.dom,t,o),e.selection.setCursorLocation(o,0)})(e,o,n);else{const s=Ft(t);ro(r,o,n),e.selection.setRng(zt(s))}},ao=(e,t)=>{const o=e.dom,n=e.selection,r=n.getStart(),s=Ye(e,r),a=o.getParent(n.getStart(),"LI",s);if(a){const r=a.parentElement;if(r===e.getBody()&&Ae(o,r))return!0;const i=je(n.getRng()),l=o.getParent(to(e,i,t,s),"LI",s);if(l&&l!==a)return e.undoManager.transact((()=>{var o,n;t?so(e,i,l,a):(null===(n=(o=a).parentNode)||void 0===n?void 0:n.firstChild)===o?Rt(e):((e,t,o,n)=>{const r=Ft(t);ro(e.dom,o,n);const s=zt(r);e.selection.setRng(s)})(e,i,a,l)})),!0;if(!l&&!t&&0===i.startOffset&&0===i.endOffset)return e.undoManager.transact((()=>{Bt(e)})),!0}return!1},io=(e,t)=>{const o=e.dom,n=e.selection.getStart(),r=Ye(e,n),s=o.getParent(n,o.isBlock,r);if(s&&o.isEmpty(s)){const n=je(e.selection.getRng()),a=o.getParent(to(e,n,t,r),"LI",r);if(a){const i=e=>y(["td","th","caption"],F(e)),l=e=>e.dom===r;return!!((e,t,o=m)=>B(e,t,o).getOr(e.isNone()&&t.isNone()))(Y(H.fromDom(a),i,l),Y(H.fromDom(n.startContainer),i,l),I)&&(e.undoManager.transact((()=>{const n=a.parentNode;((e,t,o)=>{const n=e.getParent(t.parentNode,e.isBlock,o);e.remove(t),n&&e.isEmpty(n)&&e.remove(n)})(o,s,r),Gt(o,n),e.selection.select(a,!0),e.selection.collapse(t)})),!0)}}return!1},lo=e=>{const t=e.selection.getStart(),o=Ye(e,t);return e.dom.getParent(t,"LI,DT,DD",o)||Ke(e).length>0},co=(e,t)=>{const o=e.selection;return!rt(e,o.getNode())&&(o.isCollapsed()?((e,t)=>ao(e,t)||io(e,t))(e,t):(e=>!!lo(e)&&(e.undoManager.transact((()=>{e.execCommand("Delete"),eo(e.dom,e.getBody())})),!0))(e))},mo=e=>{const t=E(lt(e).split("")),o=x(t,((e,t)=>{const o=e.toUpperCase().charCodeAt(0)-"A".charCodeAt(0)+1;return Math.pow(26,t)*o}));return k(o,((e,t)=>e+t),0)},uo=e=>{if(--e<0)return"";{const t=e%26,o=Math.floor(e/26);return uo(o)+String.fromCharCode("A".charCodeAt(0)+t)}},go=e=>{const t=parseInt(e.start,10);return R(e.listStyleType,"upper-alpha")?uo(t):R(e.listStyleType,"lower-alpha")?uo(t).toLowerCase():e.start},po=e=>{const t=qe(e);Ce(t)&&!rt(e,t)&&e.windowManager.open({title:"List Properties",body:{type:"panel",items:[{type:"input",name:"start",label:"Start list at number",inputMode:"numeric"}]},initialData:{start:go({start:e.dom.getAttrib(t,"start","1"),listStyleType:h.from(e.dom.getStyle(t,"list-style-type"))})},buttons:[{type:"cancel",name:"cancel",text:"Cancel"},{type:"submit",name:"save",text:"Save",primary:!0}],onSubmit:t=>{(e=>{switch((e=>/^[0-9]+$/.test(e)?2:/^[A-Z]+$/.test(e)?0:(e=>/^[a-z]+$/.test(e))(e)?1:e.length>0?4:3)(e)){case 2:return h.some({listStyleType:h.none(),start:e});case 0:return h.some({listStyleType:h.some("upper-alpha"),start:mo(e).toString()});case 1:return h.some({listStyleType:h.some("lower-alpha"),start:mo(e).toString()});case 3:return h.some({listStyleType:h.none(),start:""});case 4:return h.none()}})(t.getData().start).each((t=>{e.execCommand("mceListUpdate",!1,{attrs:{start:"1"===t.start?"":t.start},styles:{"list-style-type":t.listStyleType.getOr("")}})})),t.close()}})},ho=(e,t)=>()=>{const o=qe(e);return i(o)&&o.nodeName===t},fo=e=>{e.addCommand("mceListProps",(()=>{po(e)}))},bo=e=>{e.on("BeforeExecCommand",(t=>{const o=t.command.toLowerCase();"indent"===o?Nt(e):"outdent"===o&&Rt(e)})),e.addCommand("InsertUnorderedList",((t,o)=>{Jt(e,"UL",o)})),e.addCommand("InsertOrderedList",((t,o)=>{Jt(e,"OL",o)})),e.addCommand("InsertDefinitionList",((t,o)=>{Jt(e,"DL",o)})),e.addCommand("RemoveList",(()=>{Bt(e)})),fo(e),e.addCommand("mceListUpdate",((t,o)=>{r(o)&&((e,t)=>{const o=qe(e);null===o||rt(e,o)||e.undoManager.transact((()=>{r(t.styles)&&e.dom.setStyles(o,t.styles),r(t.attrs)&&le(t.attrs,((t,n)=>e.dom.setAttrib(o,n,t)))}))})(e,o)})),e.addQueryStateHandler("InsertUnorderedList",ho(e,"UL")),e.addQueryStateHandler("InsertOrderedList",ho(e,"OL")),e.addQueryStateHandler("InsertDefinitionList",ho(e,"DL"))};var vo=tinymce.util.Tools.resolve("tinymce.html.Node");const yo=e=>3===e.type,wo=e=>0===e.length,xo=e=>{const t=(t,o)=>{const n=vo.create("li");C(t,(e=>n.append(e))),o?e.insert(n,o,!0):e.append(n)},o=k(e.children(),((e,o)=>yo(o)?[...e,o]:wo(e)||yo(o)?e:(t(e,o),[])),[]);wo(o)||t(o)},Co=e=>{Re(e)&&(e=>{e.on("keydown",(t=>{t.keyCode!==se.TAB||se.metaKeyPressed(t)||e.undoManager.transact((()=>{(t.shiftKey?Rt(e):Nt(e))&&t.preventDefault()}))}))})(e),(e=>{e.on("ExecCommand",(t=>{const o=t.command.toLowerCase();"delete"!==o&&"forwarddelete"!==o||!lo(e)||eo(e.dom,e.getBody())})),e.on("keydown",(t=>{t.keyCode===se.BACKSPACE?co(e,!1)&&t.preventDefault():t.keyCode===se.DELETE&&co(e,!0)&&t.preventDefault()}))})(e)},So=(e,t)=>o=>(o.setEnabled(e.selection.isEditable()),st(e,(n=>{o.setActive(ot(n.parents,t)),o.setEnabled(!rt(e,n.element)&&e.selection.isEditable())}))),ko=(e,t)=>o=>st(e,(n=>o.setEnabled(ot(n.parents,t)&&!rt(e,n.element))));e.add("lists",(e=>((e=>{(0,e.options.register)("lists_indent_on_tab",{processor:"boolean",default:!0})})(e),(e=>{e.on("PreInit",(()=>{const{parser:t}=e;t.addNodeFilter("ul,ol",(e=>C(e,xo)))}))})(e),e.hasPlugin("rtc",!0)?fo(e):(Co(e),bo(e)),(e=>{const t=t=>()=>e.execCommand(t);e.hasPlugin("advlist")||(e.ui.registry.addToggleButton("numlist",{icon:"ordered-list",active:!1,tooltip:"Numbered list",onAction:t("InsertOrderedList"),onSetup:So(e,"OL")}),e.ui.registry.addToggleButton("bullist",{icon:"unordered-list",active:!1,tooltip:"Bullet list",onAction:t("InsertUnorderedList"),onSetup:So(e,"UL")}))})(e),(e=>{const t={text:"List properties...",icon:"ordered-list",onAction:()=>e.execCommand("mceListProps"),onSetup:ko(e,"OL")};e.ui.registry.addMenuItem("listprops",t),e.ui.registry.addContextMenu("lists",{update:t=>{const o=qe(e,t);return Ce(o)?["listprops"]:[]}})})(e),(e=>({backspaceDelete:t=>{co(e,t)}}))(e))))}()},2540:(e,t,o)=>{o(3167)},3167:()=>{!function(){"use strict";var e=tinymce.util.Tools.resolve("tinymce.PluginManager");const t=e=>t=>(e=>{const t=typeof e;return null===e?"null":"object"===t&&Array.isArray(e)?"array":"object"===t&&(o=r=e,n=(s=String).prototype,n.isPrototypeOf(o)||(null===(a=r.constructor)||void 0===a?void 0:a.name)===s.name)?"string":t;var o,n;var r,s,a})(t)===e,o=t("string"),n=t("object"),r=t("array"),s=e=>!(e=>null==e)(e);class a{constructor(e,t){this.tag=e,this.value=t}static some(e){return new a(!0,e)}static none(){return a.singletonNone}fold(e,t){return this.tag?t(this.value):e()}isSome(){return this.tag}isNone(){return!this.tag}map(e){return this.tag?a.some(e(this.value)):a.none()}bind(e){return this.tag?e(this.value):a.none()}exists(e){return this.tag&&e(this.value)}forall(e){return!this.tag||e(this.value)}filter(e){return!this.tag||e(this.value)?this:a.none()}getOr(e){return this.tag?this.value:e}or(e){return this.tag?this:e}getOrThunk(e){return this.tag?this.value:e()}orThunk(e){return this.tag?this:e()}getOrDie(e){if(this.tag)return this.value;throw new Error(null!=e?e:"Called getOrDie on None")}static from(e){return s(e)?a.some(e):a.none()}getOrNull(){return this.tag?this.value:null}getOrUndefined(){return this.value}each(e){this.tag&&e(this.value)}toArray(){return this.tag?[this.value]:[]}toString(){return this.tag?`some(${this.value})`:"none()"}}a.singletonNone=new a(!1);const i=Array.prototype.push,l=(e,t)=>{for(let o=0,n=e.length;o{const t=[];for(let o=0,n=e.length;og(e,t)?a.from(e[t]):a.none(),g=(e,t)=>m.call(e,t),p=e=>t=>t.options.get(e),h=p("audio_template_callback"),f=p("video_template_callback"),b=p("iframe_template_callback"),v=p("media_live_embeds"),y=p("media_filter_html"),w=p("media_url_resolver"),x=p("media_alt_source"),C=p("media_poster"),S=p("media_dimensions");var k=tinymce.util.Tools.resolve("tinymce.util.Tools"),_=tinymce.util.Tools.resolve("tinymce.dom.DOMUtils"),O=tinymce.util.Tools.resolve("tinymce.html.DomParser");const T=_.DOM,E=e=>e.replace(/px$/,""),D=e=>{const t=e.attr("style"),o=t?T.parseStyle(t):{};return{type:"ephox-embed-iri",source:e.attr("data-ephox-embed-iri"),altsource:"",poster:"",width:u(o,"max-width").map(E).getOr(""),height:u(o,"max-height").map(E).getOr("")}},A=(e,t)=>{let o={};for(let n=O({validate:!1,forced_root_block:!1},t).parse(e);n;n=n.walk())if(1===n.type){const e=n.name;if(n.attr("data-ephox-embed-iri")){o=D(n);break}o.source||"param"!==e||(o.source=n.attr("movie")),"iframe"!==e&&"object"!==e&&"embed"!==e&&"video"!==e&&"audio"!==e||(o.type||(o.type=e),o=k.extend(n.attributes.map,o)),"source"===e&&(o.source?o.altsource||(o.altsource=n.attr("src")):o.source=n.attr("src")),"img"!==e||o.poster||(o.poster=n.attr("src"))}return o.source=o.source||o.src||"",o.altsource=o.altsource||"",o.poster=o.poster||"",o},M=e=>{var t;const o=null!==(t=e.toLowerCase().split(".").pop())&&void 0!==t?t:"";return u({mp3:"audio/mpeg",m4a:"audio/x-m4a",wav:"audio/wav",mp4:"video/mp4",webm:"video/webm",ogg:"video/ogg",swf:"application/x-shockwave-flash"},o).getOr("")};var N=tinymce.util.Tools.resolve("tinymce.html.Node"),R=tinymce.util.Tools.resolve("tinymce.html.Serializer");const B=(e,t={})=>O({forced_root_block:!1,validate:!1,allow_conditional_comments:!0,...t},e),L=_.DOM,H=e=>/^[0-9.]+$/.test(e)?e+"px":e,I=(e,t)=>{const o=t.attr("style"),n=o?L.parseStyle(o):{};s(e.width)&&(n["max-width"]=H(e.width)),s(e.height)&&(n["max-height"]=H(e.height)),t.attr("style",L.serializeStyle(n))},P=["source","altsource"],F=(e,t,o,n)=>{let r=0,s=0;const a=B(n);a.addNodeFilter("source",(e=>r=e.length));const i=a.parse(e);for(let e=i;e;e=e.walk())if(1===e.type){const n=e.name;if(e.attr("data-ephox-embed-iri")){I(t,e);break}switch(n){case"video":case"object":case"embed":case"img":case"iframe":void 0!==t.height&&void 0!==t.width&&(e.attr("width",t.width),e.attr("height",t.height))}if(o)switch(n){case"video":e.attr("poster",t.poster),e.attr("src",null);for(let o=r;o<2;o++)if(t[P[o]]){const n=new N("source",1);n.attr("src",t[P[o]]),n.attr("type",t[P[o]+"mime"]||null),e.append(n)}break;case"iframe":e.attr("src",t.source);break;case"object":const o=e.getAll("img").length>0;if(t.poster&&!o){e.attr("src",t.poster);const o=new N("img",1);o.attr("src",t.poster),o.attr("width",t.width),o.attr("height",t.height),e.append(o)}break;case"source":if(s<2&&(e.attr("src",t[P[s]]),e.attr("type",t[P[s]+"mime"]||null),!t[P[s]])){e.remove();continue}s++;break;case"img":t.poster||e.remove()}}return R({},n).serialize(i)},z=[{regex:/youtu\.be\/([\w\-_\?&=.]+)/i,type:"iframe",w:560,h:314,url:"www.youtube.com/embed/$1",allowFullscreen:!0},{regex:/youtube\.com(.+)v=([^&]+)(&([a-z0-9&=\-_]+))?/i,type:"iframe",w:560,h:314,url:"www.youtube.com/embed/$2?$4",allowFullscreen:!0},{regex:/youtube.com\/embed\/([a-z0-9\?&=\-_]+)/i,type:"iframe",w:560,h:314,url:"www.youtube.com/embed/$1",allowFullscreen:!0},{regex:/vimeo\.com\/([0-9]+)\?h=(\w+)/,type:"iframe",w:425,h:350,url:"player.vimeo.com/video/$1?h=$2&title=0&byline=0&portrait=0&color=8dc7dc",allowFullscreen:!0},{regex:/vimeo\.com\/(.*)\/([0-9]+)\?h=(\w+)/,type:"iframe",w:425,h:350,url:"player.vimeo.com/video/$2?h=$3&title=0&byline=0",allowFullscreen:!0},{regex:/vimeo\.com\/([0-9]+)/,type:"iframe",w:425,h:350,url:"player.vimeo.com/video/$1?title=0&byline=0&portrait=0&color=8dc7dc",allowFullscreen:!0},{regex:/vimeo\.com\/(.*)\/([0-9]+)/,type:"iframe",w:425,h:350,url:"player.vimeo.com/video/$2?title=0&byline=0",allowFullscreen:!0},{regex:/maps\.google\.([a-z]{2,3})\/maps\/(.+)msid=(.+)/,type:"iframe",w:425,h:350,url:'maps.google.com/maps/ms?msid=$2&output=embed"',allowFullscreen:!1},{regex:/dailymotion\.com\/video\/([^_]+)/,type:"iframe",w:480,h:270,url:"www.dailymotion.com/embed/video/$1",allowFullscreen:!0},{regex:/dai\.ly\/([^_]+)/,type:"iframe",w:480,h:270,url:"www.dailymotion.com/embed/video/$1",allowFullscreen:!0}],V=(e,t)=>{const o=(e=>{const t=e.match(/^(https?:\/\/|www\.)(.+)$/i);return t&&t.length>1?"www."===t[1]?"https://":t[1]:"https://"})(t),n=e.regex.exec(t);let r=o+e.url;if(s(n))for(let e=0;en[e]?n[e]:""));return r.replace(/\?$/,"")},Z=e=>{const t=z.filter((t=>t.regex.test(e)));return t.length>0?k.extend({},t[0],{url:V(t[0],e)}):null},U=(e,t)=>{var o;const n=k.extend({},t);if(!n.source&&(k.extend(n,A(null!==(o=n.embed)&&void 0!==o?o:"",e.schema)),!n.source))return"";n.altsource||(n.altsource=""),n.poster||(n.poster=""),n.source=e.convertURL(n.source,"source"),n.altsource=e.convertURL(n.altsource,"source"),n.sourcemime=M(n.source),n.altsourcemime=M(n.altsource),n.poster=e.convertURL(n.poster,"poster");const r=Z(n.source);if(r&&(n.source=r.url,n.type=r.type,n.allowfullscreen=r.allowFullscreen,n.width=n.width||String(r.w),n.height=n.height||String(r.h)),n.embed)return F(n.embed,n,!0,e.schema);{const t=h(e),o=f(e),r=b(e);return n.width=n.width||"300",n.height=n.height||"150",k.each(n,((t,o)=>{n[o]=e.dom.encode(""+t)})),"iframe"===n.type?((e,t)=>{if(t)return t(e);{const t=e.allowfullscreen?' allowFullscreen="1"':"";return'"}})(n,r):"application/x-shockwave-flash"===n.sourcemime?(e=>{let t='';return e.poster&&(t+=''),t+="",t})(n):-1!==n.sourcemime.indexOf("audio")?((e,t)=>t?t(e):'")(n,t):((e,t)=>t?t(e):'")(n,o)}},j=e=>e.hasAttribute("data-mce-object")||e.hasAttribute("data-ephox-embed-iri"),$={},W=e=>t=>U(e,t),q=(e,t)=>{const o=w(e);return o?((e,t,o)=>new Promise(((n,r)=>{const s=o=>(o.html&&($[e.source]=o),n({url:e.source,html:o.html?o.html:t(e)}));$[e.source]?s($[e.source]):o({url:e.source},s,r)})))(t,W(e),o):((e,t)=>Promise.resolve({html:t(e),url:e.source}))(t,W(e))},G=(e,t)=>{const o={};return u(e,"dimensions").each((e=>{l(["width","height"],(n=>{u(t,n).orThunk((()=>u(e,n))).each((e=>o[n]=e))}))})),o},K=(e,t)=>{const o=t&&"dimensions"!==t?((e,t)=>u(t,e).bind((e=>u(e,"meta"))))(t,e).getOr({}):{},r=((e,t,o)=>r=>{const s=()=>u(e,r),i=()=>u(t,r),l=e=>u(e,"value").bind((e=>e.length>0?a.some(e):a.none()));return{[r]:(r===o?s().bind((e=>n(e)?l(e).orThunk(i):i().orThunk((()=>a.from(e))))):i().orThunk((()=>s().bind((e=>n(e)?l(e):a.from(e)))))).getOr("")}})(e,o,t);return{...r("source"),...r("altsource"),...r("poster"),...r("embed"),...G(e,o)}},Y=e=>{const t={...e,source:{value:u(e,"source").getOr("")},altsource:{value:u(e,"altsource").getOr("")},poster:{value:u(e,"poster").getOr("")}};return l(["width","height"],(o=>{u(e,o).each((e=>{const n=t.dimensions||{};n[o]=e,t.dimensions=n}))})),t},X=e=>t=>{const o=t&&t.msg?"Media embed handler error: "+t.msg:"Media embed handler threw unknown error.";e.notificationManager.open({type:"error",text:o})},J=(e,t)=>n=>{if(o(n.url)&&n.url.trim().length>0){const o=n.html,r={...A(o,t.schema),source:n.url,embed:o};e.setData(Y(r))}},Q=(e,t)=>{const o=e.dom.select("*[data-mce-object]");e.insertContent(t),((e,t)=>{const o=e.dom.select("*[data-mce-object]");for(let e=0;e=0;n--)t[e]===o[n]&&o.splice(n,1);e.selection.select(o[0])})(e,o),e.nodeChanged()},ee=(e,t)=>s(t)&&"ephox-embed-iri"===t&&s(Z(e)),te=(e,t)=>((e,t)=>e.width!==t.width||e.height!==t.height)(e,t)&&ee(t.source,e.type),oe=(e,t,o)=>{var n,r;t.embed=te(e,t)&&S(o)?U(o,{...t,embed:""}):F(null!==(n=t.embed)&&void 0!==n?n:"",t,!1,o.schema),t.embed&&(e.source===t.source||(r=t.source,g($,r)))?Q(o,t.embed):q(o,t).then((e=>{Q(o,e.html)})).catch(X(o))},ne=e=>{const t=(e=>{const t=e.selection.getNode(),o=j(t)?e.serializer.serialize(t,{selection:!0}):"",n=A(o,e.schema),r=(()=>{if(ee(n.source,n.type)){const o=e.dom.getRect(t);return{width:o.w.toString().replace(/px$/,""),height:o.h.toString().replace(/px$/,"")}}return{}})();return{embed:o,...n,...r}})(e),o=(e=>{let t=e;return{get:()=>t,set:e=>{t=e}}})(t),n=Y(t),r=S(e)?[{type:"sizeinput",name:"dimensions",label:"Constrain proportions",constrain:!0}]:[],s={title:"General",name:"general",items:c([[{name:"source",type:"urlinput",filetype:"media",label:"Source"}],r])},a={title:"Embed",items:[{type:"textarea",name:"embed",label:"Paste your embed code below:"}]},i=[];x(e)&&i.push({name:"altsource",type:"urlinput",filetype:"media",label:"Alternative source URL"}),C(e)&&i.push({name:"poster",type:"urlinput",filetype:"image",label:"Media poster (Image URL)"});const l={title:"Advanced",name:"advanced",items:i},d=[s,a];i.length>0&&d.push(l);const m={type:"tabpanel",tabs:d},u=e.windowManager.open({title:"Insert/Edit Media",size:"normal",body:m,buttons:[{type:"cancel",name:"cancel",text:"Cancel"},{type:"submit",name:"save",text:"Save",primary:!0}],onSubmit:t=>{const n=K(t.getData());oe(o.get(),n,e),t.close()},onChange:(t,n)=>{switch(n.name){case"source":((t,o)=>{const n=K(o.getData(),"source");t.source!==n.source&&(J(u,e)({url:n.source,html:""}),q(e,n).then(J(u,e)).catch(X(e)))})(o.get(),t);break;case"embed":(t=>{var o;const n=K(t.getData()),r=A(null!==(o=n.embed)&&void 0!==o?o:"",e.schema);t.setData(Y(r))})(t);break;case"dimensions":case"altsource":case"poster":((t,o,n)=>{const r=K(t.getData(),o),s=te(n,r)&&S(e)?{...r,embed:""}:r,a=U(e,s);t.setData(Y({...s,embed:a}))})(t,n.name,o.get())}o.set(K(t.getData()))},initialData:n})};var re=tinymce.util.Tools.resolve("tinymce.Env");const se=e=>{const t=e.name;return"iframe"===t||"video"===t||"audio"===t},ae=(e,t,o,n=null)=>{const r=e.attr(o);return s(r)?r:g(t,o)?null:n},ie=(e,t,o)=>{const n="img"===t.name||"video"===e.name,r=n?"300":null,s="audio"===e.name?"30":"150",a=n?s:null;t.attr({width:ae(e,o,"width",r),height:ae(e,o,"height",a)})},le=(e,t)=>{const o=t.name,n=new N("img",1);return de(e,t,n),ie(t,n,{}),n.attr({style:t.attr("style"),src:re.transparentSrc,"data-mce-object":o,class:"mce-object mce-object-"+o}),n},ce=(e,t)=>{var o;const n=t.name,r=new N("span",1);r.attr({contentEditable:"false",style:t.attr("style"),"data-mce-object":n,class:"mce-preview-object mce-object-"+n}),de(e,t,r);const a=e.dom.parseStyle(null!==(o=t.attr("style"))&&void 0!==o?o:""),i=new N(n,1);if(ie(t,i,a),i.attr({src:t.attr("src"),style:t.attr("style"),class:t.attr("class")}),"iframe"===n)i.attr({allowfullscreen:t.attr("allowfullscreen"),frameborder:"0"});else{l(["controls","crossorigin","currentTime","loop","muted","poster","preload"],(e=>{i.attr(e,t.attr(e))}));const o=r.attr("data-mce-html");s(o)&&((e,t,o,n)=>{const r=B(e.schema).parse(n,{context:t});for(;r.firstChild;)o.append(r.firstChild)})(e,n,i,unescape(o))}const c=new N("span",1);return c.attr("class","mce-shim"),r.append(i),r.append(c),r},de=(e,t,o)=>{var n;const r=null!==(n=t.attributes)&&void 0!==n?n:[];let s=r.length;for(;s--;){const t=r[s].name;let n=r[s].value;"width"===t||"height"===t||"style"===t||((e,t,o)=>""===t||e.length>=t.length&&e.substr(o,o+t.length)===t)(t,"data-mce-",0)||("data"!==t&&"src"!==t||(n=e.convertURL(n,t)),o.attr("data-mce-p-"+t,n))}const a=R({inner:!0},e.schema),i=new N("div",1);l(t.children(),(e=>i.append(e)));const c=a.serialize(i);c&&(o.attr("data-mce-html",escape(c)),o.empty())},me=e=>{const t=e.attr("class");return o(t)&&/\btiny-pageembed\b/.test(t)},ue=e=>{let t=e;for(;t=t.parent;)if(t.attr("data-ephox-embed-iri")||me(t))return!0;return!1},ge=(e,t,o)=>{const n=(0,e.options.get)("xss_sanitization"),r=y(e);return B(e.schema,{sanitize:n,validate:r}).parse(o,{context:t})},pe=e=>{e.on("PreInit",(()=>{const{schema:t,serializer:o,parser:n}=e,r=t.getBoolAttrs();l("webkitallowfullscreen mozallowfullscreen".split(" "),(e=>{r[e]={}})),((e,t)=>{const o=d(e);for(let n=0,r=o.length;n{const n=t.getElementRule(o);n&&l(e,(e=>{n.attributes[e]={},n.attributesOrder.push(e)}))})),n.addNodeFilter("iframe,video,audio,object,embed",(e=>t=>{let o,n=t.length;for(;n--;)o=t[n],o.parent&&(o.parent.attr("data-mce-object")||(se(o)&&v(e)?ue(o)||o.replace(ce(e,o)):ue(o)||o.replace(le(e,o))))})(e)),o.addAttributeFilter("data-mce-object",((t,o)=>{var n;let r=t.length;for(;r--;){const s=t[r];if(!s.parent)continue;const a=s.attr(o),i=new N(a,1);if("audio"!==a){const e=s.attr("class");e&&-1!==e.indexOf("mce-preview-object")&&s.firstChild?i.attr({width:s.firstChild.attr("width"),height:s.firstChild.attr("height")}):i.attr({width:s.attr("width"),height:s.attr("height")})}i.attr({style:s.attr("style")});const c=null!==(n=s.attributes)&&void 0!==n?n:[];let d=c.length;for(;d--;){const e=c[d].name;0===e.indexOf("data-mce-p-")&&i.attr(e.substr(11),c[d].value)}const m=s.attr("data-mce-html");if(m){const t=ge(e,a,unescape(m));l(t.children(),(e=>i.append(e)))}s.replace(i)}}))})),e.on("SetContent",(()=>{const t=e.dom;l(t.select("span.mce-preview-object"),(e=>{0===t.select("span.mce-shim",e).length&&t.add(e,"span",{class:"mce-shim"})}))}))},he=e=>t=>{const o=()=>{t.setEnabled(e.selection.isEditable())};return e.on("NodeChange",o),o(),()=>{e.off("NodeChange",o)}};e.add("media",(e=>((e=>{const t=e.options.register;t("audio_template_callback",{processor:"function"}),t("video_template_callback",{processor:"function"}),t("iframe_template_callback",{processor:"function"}),t("media_live_embeds",{processor:"boolean",default:!0}),t("media_filter_html",{processor:"boolean",default:!0}),t("media_url_resolver",{processor:"function"}),t("media_alt_source",{processor:"boolean",default:!0}),t("media_poster",{processor:"boolean",default:!0}),t("media_dimensions",{processor:"boolean",default:!0})})(e),(e=>{e.addCommand("mceMedia",(()=>{ne(e)}))})(e),(e=>{const t=()=>e.execCommand("mceMedia");e.ui.registry.addToggleButton("media",{tooltip:"Insert/edit media",icon:"embed",onAction:t,onSetup:t=>{const o=e.selection;t.setActive(j(o.getNode()));const n=o.selectorChangedWithUnbind("img[data-mce-object],span[data-mce-object],div[data-ephox-embed-iri]",t.setActive).unbind,r=he(e)(t);return()=>{n(),r()}}}),e.ui.registry.addMenuItem("media",{icon:"embed",text:"Media...",onAction:t,onSetup:he(e)})})(e),(e=>{e.on("ResolveName",(e=>{let t;1===e.target.nodeType&&(t=e.target.getAttribute("data-mce-object"))&&(e.name=t)}))})(e),pe(e),(e=>{e.on("click keyup touchend",(()=>{const t=e.selection.getNode();t&&e.dom.hasClass(t,"mce-preview-object")&&e.dom.getAttrib(t,"data-mce-selected")&&t.setAttribute("data-mce-selected","2")})),e.on("ObjectResized",(t=>{const o=t.target;if(o.getAttribute("data-mce-object")){let n=o.getAttribute("data-mce-html");n&&(n=unescape(n),o.setAttribute("data-mce-html",escape(F(n,{width:String(t.width),height:String(t.height)},!1,e.schema))))}}))})(e),(e=>({showDialog:()=>{ne(e)}}))(e))))}()},8619:(e,t,o)=>{o(2590)},2590:()=>{!function(){"use strict";var e=tinymce.util.Tools.resolve("tinymce.PluginManager");const t=e=>t=>(e=>{const t=typeof e;return null===e?"null":"object"===t&&Array.isArray(e)?"array":"object"===t&&(o=r=e,n=(s=String).prototype,n.isPrototypeOf(o)||(null===(a=r.constructor)||void 0===a?void 0:a.name)===s.name)?"string":t;var o,n;var r,s,a})(t)===e,o=e=>t=>typeof t===e,n=t("string"),r=t("array"),s=o("boolean"),a=(i=void 0,e=>i===e);var i;const l=e=>!(e=>null==e)(e),c=o("function"),d=o("number"),m=()=>{},u=e=>()=>e,g=e=>e,p=(e,t)=>e===t;function h(e,...t){return(...o)=>{const n=t.concat(o);return e.apply(null,n)}}const f=e=>{e()},b=u(!1),v=u(!0);class y{constructor(e,t){this.tag=e,this.value=t}static some(e){return new y(!0,e)}static none(){return y.singletonNone}fold(e,t){return this.tag?t(this.value):e()}isSome(){return this.tag}isNone(){return!this.tag}map(e){return this.tag?y.some(e(this.value)):y.none()}bind(e){return this.tag?e(this.value):y.none()}exists(e){return this.tag&&e(this.value)}forall(e){return!this.tag||e(this.value)}filter(e){return!this.tag||e(this.value)?this:y.none()}getOr(e){return this.tag?this.value:e}or(e){return this.tag?this:e}getOrThunk(e){return this.tag?this.value:e()}orThunk(e){return this.tag?this:e()}getOrDie(e){if(this.tag)return this.value;throw new Error(null!=e?e:"Called getOrDie on None")}static from(e){return l(e)?y.some(e):y.none()}getOrNull(){return this.tag?this.value:null}getOrUndefined(){return this.value}each(e){this.tag&&e(this.value)}toArray(){return this.tag?[this.value]:[]}toString(){return this.tag?`some(${this.value})`:"none()"}}y.singletonNone=new y(!1);const w=Object.keys,x=Object.hasOwnProperty,C=(e,t)=>{const o=w(e);for(let n=0,r=o.length;n{const o={};var n;return((e,t,o,n)=>{C(e,((e,r)=>{(t(e,r)?o:n)(e,r)}))})(e,t,(n=o,(e,t)=>{n[t]=e}),m),o},k=e=>((e,t)=>{const o=[];return C(e,((e,n)=>{o.push(t(e,n))})),o})(e,g),_=e=>w(e).length,O=(e,t)=>T(e,t)?y.from(e[t]):y.none(),T=(e,t)=>x.call(e,t),E=(e,t)=>T(e,t)&&void 0!==e[t]&&null!==e[t],D=Array.prototype.indexOf,A=Array.prototype.push,M=(e,t)=>((e,t)=>D.call(e,t))(e,t)>-1,N=(e,t)=>{for(let o=0,n=e.length;o{const o=[];for(let n=0;n{const o=e.length,n=new Array(o);for(let r=0;r{for(let o=0,n=e.length;o{const o=[];for(let n=0,r=e.length;n(L(e,((e,n)=>{o=t(o,e,n)})),o),P=(e,t)=>((e,t,o)=>{for(let n=0,r=e.length;n(e=>{const t=[];for(let o=0,n=e.length;o{for(let o=0,n=e.length;ot>=0&&t{for(let o=0;o{if(null==e)throw new Error("Node cannot be null or undefined");return{dom:e}},j={fromHtml:(e,t)=>{const o=(t||document).createElement("div");if(o.innerHTML=e,!o.hasChildNodes()||o.childNodes.length>1){const t="HTML does not have a single root node";throw console.error(t,e),new Error(t)}return U(o.childNodes[0])},fromTag:(e,t)=>{const o=(t||document).createElement(e);return U(o)},fromText:(e,t)=>{const o=(t||document).createTextNode(e);return U(o)},fromDom:U,fromPoint:(e,t,o)=>y.from(e.dom.elementFromPoint(t,o)).map(U)},$=(e,t)=>{const o=e.dom;if(1!==o.nodeType)return!1;{const e=o;if(void 0!==e.matches)return e.matches(t);if(void 0!==e.msMatchesSelector)return e.msMatchesSelector(t);if(void 0!==e.webkitMatchesSelector)return e.webkitMatchesSelector(t);if(void 0!==e.mozMatchesSelector)return e.mozMatchesSelector(t);throw new Error("Browser lacks native selectors")}},W=e=>1!==e.nodeType&&9!==e.nodeType&&11!==e.nodeType||0===e.childElementCount,q=(e,t)=>e.dom===t.dom,G=$;"undefined"!=typeof window?window:Function("return this;")();const K=e=>e.dom.nodeName.toLowerCase(),Y=e=>e.dom.nodeType,X=e=>t=>Y(t)===e,J=e=>8===Y(e)||"#comment"===K(e),Q=X(1),ee=X(3),te=X(9),oe=X(11),ne=e=>t=>Q(t)&&K(t)===e,re=e=>{return te(e)?e:(t=e,j.fromDom(t.dom.ownerDocument));var t},se=e=>y.from(e.dom.parentNode).map(j.fromDom),ae=(e,t)=>{const o=c(t)?t:b;let n=e.dom;const r=[];for(;null!==n.parentNode&&void 0!==n.parentNode;){const e=n.parentNode,t=j.fromDom(e);if(r.push(t),!0===o(t))break;n=e}return r},ie=e=>y.from(e.dom.previousSibling).map(j.fromDom),le=e=>y.from(e.dom.nextSibling).map(j.fromDom),ce=e=>B(e.dom.childNodes,j.fromDom),de=e=>((e,t)=>{const o=e.dom.childNodes;return y.from(o[t]).map(j.fromDom)})(e,0),me=c(Element.prototype.attachShadow)&&c(Node.prototype.getRootNode)?e=>j.fromDom(e.dom.getRootNode()):re,ue=e=>{const t=me(e);return oe(o=t)&&l(o.dom.host)?y.some(t):y.none();var o},ge=e=>j.fromDom(e.dom.host),pe=e=>{const t=ee(e)?e.dom.parentNode:e.dom;if(null==t||null===t.ownerDocument)return!1;const o=t.ownerDocument;return ue(j.fromDom(t)).fold((()=>o.body.contains(t)),(n=pe,r=ge,e=>n(r(e))));var n,r};var he=(e,t,o,n,r)=>e(o,n)?y.some(o):c(r)&&r(o)?y.none():t(o,n,r);const fe=(e,t,o)=>{let n=e.dom;const r=c(o)?o:b;for(;n.parentNode;){n=n.parentNode;const e=j.fromDom(n);if(t(e))return y.some(e);if(r(e))break}return y.none()},be=(e,t,o)=>fe(e,(e=>$(e,t)),o),ve=(e,t)=>((e,t)=>P(e.dom.childNodes,(e=>t(j.fromDom(e)))).map(j.fromDom))(e,(e=>$(e,t))),ye=(e,t)=>((e,t)=>{const o=void 0===t?document:t.dom;return W(o)?y.none():y.from(o.querySelector(e)).map(j.fromDom)})(t,e),we=(e,t,o)=>he(((e,t)=>$(e,t)),be,e,t,o),xe=(e,t=!1)=>{return pe(e)?e.dom.isContentEditable:(o=e,we(o,"[contenteditable]")).fold(u(t),(e=>"true"===Ce(e)));var o},Ce=e=>e.dom.contentEditable,Se=e=>t=>q(t,(e=>j.fromDom(e.getBody()))(e)),ke=e=>/^\d+(\.\d+)?$/.test(e)?e+"px":e,_e=e=>j.fromDom(e.selection.getStart()),Oe=e=>{return(t=e,o=ne("table"),he(((e,t)=>t(e)),fe,t,o,n)).forall(xe);var t,o,n},Te=(e,t)=>{let o=[];return L(ce(e),(e=>{t(e)&&(o=o.concat([e])),o=o.concat(Te(e,t))})),o},Ee=(e,t)=>((e,t)=>H(ce(e),t))(e,(e=>$(e,t))),De=(e,t)=>((e,t)=>{const o=void 0===t?document:t.dom;return W(o)?[]:B(o.querySelectorAll(e),j.fromDom)})(t,e),Ae=(e,t,o)=>{if(!(n(o)||s(o)||d(o)))throw console.error("Invalid call to Attribute.set. Key ",t,":: Value ",o,":: Element ",e),new Error("Attribute value was not simple");e.setAttribute(t,o+"")},Me=(e,t,o)=>{Ae(e.dom,t,o)},Ne=(e,t)=>{const o=e.dom.getAttribute(t);return null===o?void 0:o},Re=(e,t)=>y.from(Ne(e,t)),Be=(e,t)=>{e.dom.removeAttribute(t)},Le=(e,t,o=p)=>e.exists((e=>o(e,t))),He=(e,t,o)=>e.isSome()&&t.isSome()?y.some(o(e.getOrDie(),t.getOrDie())):y.none(),Ie=(e,t)=>((e,t,o)=>""===t||e.length>=t.length&&e.substr(o,o+t.length)===t)(e,t,0),Pe=(Fe=/^\s+|\s+$/g,e=>e.replace(Fe,""));var Fe;const ze=e=>e.length>0,Ve=(e,t=10)=>{const o=parseInt(e,t);return isNaN(o)?y.none():y.some(o)},Ze=e=>void 0!==e.style&&c(e.style.getPropertyValue),Ue=(e,t,o)=>{((e,t,o)=>{if(!n(o))throw console.error("Invalid call to CSS.set. Property ",t,":: Value ",o,":: Element ",e),new Error("CSS value must be a string: "+o);Ze(e)&&e.style.setProperty(t,o)})(e.dom,t,o)},je=(e,t)=>{const o=e.dom,n=window.getComputedStyle(o).getPropertyValue(t);return""!==n||pe(e)?n:$e(o,t)},$e=(e,t)=>Ze(e)?e.style.getPropertyValue(t):"",We=(e,t)=>{const o=e.dom,n=$e(o,t);return y.from(n).filter((e=>e.length>0))},qe=(e,t)=>{((e,t)=>{Ze(e)&&e.style.removeProperty(t)})(e.dom,t),Le(Re(e,"style").map(Pe),"")&&Be(e,"style")},Ge=(e,t,o=0)=>Re(e,t).map((e=>parseInt(e,10))).getOr(o),Ke=(e,t)=>Ye(e,t,v),Ye=(e,t,o)=>F(ce(e),(e=>$(e,t)?o(e)?[e]:[]:Ye(e,t,o))),Xe=["tfoot","thead","tbody","colgroup"],Je=(e,t,o)=>({element:e,rowspan:t,colspan:o}),Qe=(e,t,o)=>({element:e,cells:t,section:o}),et=(e,t)=>((e,t,o=b)=>o(t)?y.none():M(e,K(t))?y.some(t):be(t,e.join(","),(e=>$(e,"table")||o(e))))(["td","th"],e,t),tt=(e,t)=>we(e,"table",t),ot=e=>Ke(e,"tr"),nt=e=>tt(e).fold(u([]),(e=>Ee(e,"colgroup"))),rt=(e,t)=>B(e,(e=>{if("colgroup"===K(e)){const t=B((e=>$(e,"colgroup")?Ee(e,"col"):F(nt(e),(e=>Ee(e,"col"))))(e),(e=>{const t=Ge(e,"span",1);return Je(e,1,t)}));return Qe(e,t,"colgroup")}{const o=B((e=>Ke(e,"th,td"))(e),(e=>{const t=Ge(e,"rowspan",1),o=Ge(e,"colspan",1);return Je(e,t,o)}));return Qe(e,o,t(e))}})),st=e=>se(e).map((e=>{const t=K(e);return(e=>M(Xe,e))(t)?t:"tbody"})).getOr("tbody"),at=e=>Re(e,"data-snooker-locked-cols").bind((e=>y.from(e.match(/\d+/g)))).map((e=>((e,t)=>{const o={};for(let n=0,r=e.length;ne+","+t,lt=(e,t)=>{const o=F(e.all,(e=>e.cells));return H(o,t)},ct=e=>{const t={},o=[];var n;const r=(n=e,V(n,0)).map((e=>e.element)).bind(tt).bind(at).getOr({});let s=0,a=0,i=0;const{pass:l,fail:c}=((e,t)=>{const o=[],n=[];for(let r=0,s=e.length;r"colgroup"===e.section));L(c,(e=>{const n=[];L(e.cells,(e=>{let o=0;for(;void 0!==t[it(i,o)];)o++;const s=E(r,o.toString()),l=((e,t,o,n,r,s)=>({element:e,rowspan:t,colspan:o,row:n,column:r,isLocked:s}))(e.element,e.rowspan,e.colspan,i,o,s);for(let n=0;nV(e,e.length-1))(l).map((e=>{const t=(e=>{const t={};let o=0;return L(e.cells,(e=>{const n=e.colspan;R(n,(r=>{const s=o+r;t[s]=((e,t,o)=>({element:e,colspan:t,column:o}))(e.element,n,s)})),o+=n})),t})(e),o=((e,t)=>({element:e,columns:t}))(e.element,k(t));return{colgroups:[o],columns:t}})).getOrThunk((()=>({colgroups:[],columns:{}}))),u=((e,t)=>({rows:e,columns:t}))(s,a);return{grid:u,access:t,all:o,columns:d,colgroups:m}},dt=e=>{const t=(e=>{const t=ot(e),o=[...nt(e),...t];return rt(o,st)})(e);return ct(t)},mt=(e,t,o)=>y.from(e.access[it(t,o)]),ut=(e,t,o)=>{const n=lt(e,(e=>o(t,e.element)));return n.length>0?y.some(n[0]):y.none()},gt=e=>F(e.all,(e=>e.cells)),pt=(e,t)=>y.from(e.columns[t]);var ht=tinymce.util.Tools.resolve("tinymce.util.Tools");const ft=(e,t,o)=>{const n=e.select("td,th",t);let r;for(let t=0;t{ht.each("left center right".split(" "),(n=>{n!==o&&e.formatter.remove("align"+n,{},t)})),o&&e.formatter.apply("align"+o,{},t)},vt=(e,t,o)=>{e.dispatch("TableModified",{...o,table:t})},yt=(e,t)=>(e=>{const t=parseFloat(e);return isNaN(t)?y.none():y.some(t)})(e).getOr(t),wt=(e,t,o)=>yt(je(e,t),o),xt=(e,t)=>{const o=e.dom,n=o.getBoundingClientRect().width||o.offsetWidth;return"border-box"===t?n:((e,t,o,n)=>t-wt(e,`padding-${o}`,0)-wt(e,`padding-${n}`,0)-wt(e,`border-${o}-width`,0)-wt(e,`border-${n}-width`,0))(e,n,"left","right")},Ct=e=>xt(e,"content-box");var St=tinymce.util.Tools.resolve("tinymce.Env");const kt=R(5,(e=>{const t=`${e+1}px`;return{title:t,value:t}})),_t=B(["Solid","Dotted","Dashed","Double","Groove","Ridge","Inset","Outset","None","Hidden"],(e=>({title:e,value:e.toLowerCase()}))),Ot="100%",Tt=e=>{var t;const o=e.dom,n=null!==(t=o.getParent(e.selection.getStart(),o.isBlock))&&void 0!==t?t:e.getBody();return Ct(j.fromDom(n))+"px"},Et=e=>t=>t.options.get(e),Dt=Et("table_sizing_mode"),At=Et("table_border_widths"),Mt=Et("table_border_styles"),Nt=Et("table_cell_advtab"),Rt=Et("table_row_advtab"),Bt=Et("table_advtab"),Lt=Et("table_appearance_options"),Ht=Et("table_grid"),It=Et("table_style_by_css"),Pt=Et("table_cell_class_list"),Ft=Et("table_row_class_list"),zt=Et("table_class_list"),Vt=Et("table_toolbar"),Zt=Et("table_background_color_map"),Ut=Et("table_border_color_map"),jt=e=>"fixed"===Dt(e),$t=e=>"responsive"===Dt(e),Wt=e=>{const t=e.options,o=t.get("table_default_styles");return t.isSet("table_default_styles")?o:((e,t)=>$t(e)||!It(e)?t:jt(e)?{...t,width:Tt(e)}:{...t,width:Ot})(e,o)},qt=e=>{const t=e.options,o=t.get("table_default_attributes");return t.isSet("table_default_attributes")?o:((e,t)=>$t(e)||It(e)?t:jt(e)?{...t,width:Tt(e)}:{...t,width:Ot})(e,o)},Gt=(e,t)=>t.column>=e.startCol&&t.column+t.colspan-1<=e.finishCol&&t.row>=e.startRow&&t.row+t.rowspan-1<=e.finishRow,Kt=(e,t,o)=>{const n=ut(e,t,q),r=ut(e,o,q);return n.bind((e=>r.map((t=>{return o=e,n=t,r=Math.min(o.row,n.row),s=Math.min(o.column,n.column),a=Math.max(o.row+o.rowspan-1,n.row+n.rowspan-1),i=Math.max(o.column+o.colspan-1,n.column+n.colspan-1),{startRow:r,startCol:s,finishRow:a,finishCol:i};var o,n,r,s,a,i}))))},Yt=(e,t,o)=>Kt(e,t,o).bind((t=>((e,t)=>{let o=!0;const n=h(Gt,t);for(let r=t.startRow;r<=t.finishRow;r++)for(let s=t.startCol;s<=t.finishCol;s++)o=o&&mt(e,r,s).exists(n);return o?y.some(t):y.none()})(e,t))),Xt=dt,Jt=(e,t)=>{se(e).each((o=>{o.dom.insertBefore(t.dom,e.dom)}))},Qt=(e,t)=>{le(e).fold((()=>{se(e).each((e=>{to(e,t)}))}),(e=>{Jt(e,t)}))},eo=(e,t)=>{de(e).fold((()=>{to(e,t)}),(o=>{e.dom.insertBefore(t.dom,o.dom)}))},to=(e,t)=>{e.dom.appendChild(t.dom)},oo=(e,t)=>{Jt(e,t),to(t,e)},no=(e,t)=>{L(t,((o,n)=>{const r=0===n?e:t[n-1];Qt(r,o)}))},ro=(e,t)=>{L(t,(t=>{to(e,t)}))},so=e=>{const t=e.dom;null!==t.parentNode&&t.parentNode.removeChild(t)},ao=e=>{const t=ce(e);t.length>0&&no(e,t),so(e)},io=((e,t)=>{const o=t=>e(t)?y.from(t.dom.nodeValue):y.none();return{get:n=>{if(!e(n))throw new Error("Can only get "+t+" value of a "+t+" node");return o(n).getOr("")},getOption:o,set:(o,n)=>{if(!e(o))throw new Error("Can only set raw "+t+" value of a "+t+" node");o.dom.nodeValue=n}}})(ee,"text"),lo=e=>io.get(e),co=(e,t)=>io.set(e,t);var mo=["body","p","div","article","aside","figcaption","figure","footer","header","nav","section","ol","ul","li","table","thead","tbody","tfoot","caption","tr","td","th","h1","h2","h3","h4","h5","h6","blockquote","pre","address"];const uo=(e,t,o,n)=>{const r=t(e,o);return s=(o,n)=>{const r=t(e,n);return go(e,o,r)},a=r,((e,t)=>{for(let o=e.length-1;o>=0;o--)t(e[o],o)})(n,((e,t)=>{a=s(a,e,t)})),a;var s,a},go=(e,t,o)=>t.bind((t=>o.filter(h(e.eq,t)))),po=(e,t,o)=>o.length>0?((e,t,o,n)=>n(e,t,o[0],o.slice(1)))(e,t,o,uo):y.none(),ho={up:u({selector:be,closest:we,predicate:fe,all:ae}),down:u({selector:De,predicate:Te}),styles:u({get:je,getRaw:We,set:Ue,remove:qe}),attrs:u({get:Ne,set:Me,remove:Be,copyTo:(e,t)=>{((e,t)=>{const o=e.dom;C(t,((e,t)=>{Ae(o,t,e)}))})(t,I(e.dom.attributes,((e,t)=>(e[t.name]=t.value,e)),{}))}}),insert:u({before:Jt,after:Qt,afterAll:no,append:to,appendAll:ro,prepend:eo,wrap:oo}),remove:u({unwrap:ao,remove:so}),create:u({nu:j.fromTag,clone:e=>j.fromDom(e.dom.cloneNode(!1)),text:j.fromText}),query:u({comparePosition:(e,t)=>e.dom.compareDocumentPosition(t.dom),prevSibling:ie,nextSibling:le}),property:u({children:ce,name:K,parent:se,document:e=>re(e).dom,isText:ee,isComment:J,isElement:Q,isSpecial:e=>{const t=K(e);return M(["script","noscript","iframe","noframes","noembed","title","style","textarea","xmp"],t)},getLanguage:e=>Q(e)?Re(e,"lang"):y.none(),getText:lo,setText:co,isBoundary:e=>!!Q(e)&&("body"===K(e)||M(mo,K(e))),isEmptyTag:e=>!!Q(e)&&M(["br","img","hr","input"],K(e)),isNonEditable:e=>Q(e)&&"false"===Ne(e,"contenteditable")}),eq:q,is:G},fo=e=>be(e,"table"),bo=(e,t,o)=>ye(e,t).bind((t=>ye(e,o).bind((e=>{return(o=fo,n=[t,e],po(ho,((e,t)=>o(t)),n)).map((o=>({first:t,last:e,table:o})));var o,n})))),vo=(e,t)=>((e,t)=>{const o=De(e,t);return o.length>0?y.some(o):y.none()})(e,t),yo=(e,t,o)=>bo(e,t,o).bind((t=>{const o=t=>q(e,t),n="thead,tfoot,tbody,table",r=be(t.first,n,o),s=be(t.last,n,o);return r.bind((e=>s.bind((o=>q(e,o)?((e,t,o)=>{const n=Xt(e);return Yt(n,t,o)})(t.table,t.first,t.last):y.none()))))})),wo=e=>B(e,j.fromDom),xo="data-mce-selected",Co="data-mce-first-selected",So="data-mce-last-selected",ko={selected:xo,selectedSelector:"td["+xo+"],th["+xo+"]",firstSelected:Co,firstSelectedSelector:"td["+Co+"],th["+Co+"]",lastSelected:So,lastSelectedSelector:"td["+So+"],th["+So+"]"},_o=e=>(t,o)=>{const n=K(t),r="col"===n||"colgroup"===n?tt(s=t).bind((e=>vo(e,ko.firstSelectedSelector))).fold(u(s),(e=>e[0])):t;var s;return we(r,e,o)},Oo=_o("th,td,caption"),To=_o("th,td"),Eo=e=>wo(e.model.table.getSelectedCells()),Do=(e,t)=>{const o=To(e),n=o.bind((e=>tt(e))).map((e=>ot(e)));return He(o,n,((e,o)=>H(o,(o=>N(wo(o.dom.cells),(o=>"1"===Ne(o,t)||q(o,e))))))).getOr([])},Ao=[{text:"None",value:""},{text:"Top",value:"top"},{text:"Middle",value:"middle"},{text:"Bottom",value:"bottom"}],Mo=/^#?([a-f\d])([a-f\d])([a-f\d])$/i,No=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i,Ro=e=>{return(t=e,o="#",Ie(t,o)?((e,t)=>e.substring(t))(t,o.length):t).toUpperCase();var t,o},Bo=e=>(e=>Mo.test(e)||No.test(e))(e)?y.some({value:Ro(e)}):y.none(),Lo=e=>{const t=e.toString(16);return(1===t.length?"0"+t:t).toUpperCase()},Ho=e=>(e=>({value:Ro(e)}))(Lo(e.red)+Lo(e.green)+Lo(e.blue)),Io=/^\s*rgb\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)\s*$/i,Po=/^\s*rgba\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d?(?:\.\d+)?)\s*\)\s*$/i,Fo=(e,t,o,n)=>({red:e,green:t,blue:o,alpha:n}),zo=(e,t,o,n)=>{const r=parseInt(e,10),s=parseInt(t,10),a=parseInt(o,10),i=parseFloat(n);return Fo(r,s,a,i)},Vo=e=>{if("transparent"===e)return y.some(Fo(0,0,0,0));const t=Io.exec(e);if(null!==t)return y.some(zo(t[1],t[2],t[3],"1"));const o=Po.exec(e);return null!==o?y.some(zo(o[1],o[2],o[3],o[4])):y.none()},Zo=e=>{let t=e;return{get:()=>t,set:e=>{t=e}}},Uo=()=>(e=>{const t=Zo(y.none()),o=()=>t.get().each(e);return{clear:()=>{o(),t.set(y.none())},isSet:()=>t.get().isSome(),get:()=>t.get(),set:e=>{o(),t.set(y.some(e))}}})((e=>e.unbind())),jo=(e,t,o)=>n=>{const r=Uo(),s=!ze(o);const a=()=>{const a=Eo(e),i=n=>e.formatter.match(t,{value:o},n.dom,s);s?(n.setActive(!N(a,i)),r.set(e.formatter.formatChanged(t,(e=>n.setActive(!e)),!0))):(n.setActive(z(a,i)),r.set(e.formatter.formatChanged(t,n.setActive,!1,{value:o})))};return e.initialized?a():e.on("init",a),r.clear},$o=e=>E(e,"menu"),Wo=e=>B(e,(e=>{const t=e.text||e.title||"";return $o(e)?{text:t,items:Wo(e.menu)}:{text:t,value:e.value}})),qo=(e,t,o,n)=>B(t,(t=>{const r=t.text||t.title;return $o(t)?{type:"nestedmenuitem",text:r,getSubmenuItems:()=>qo(e,t.menu,o,n)}:{text:r,type:"togglemenuitem",onAction:()=>n(t.value),onSetup:jo(e,o,t.value)}})),Go=(e,t)=>o=>{e.execCommand("mceTableApplyCellStyle",!1,{[t]:o})},Ko=e=>F(e,(e=>$o(e)?[{...e,menu:Ko(e.menu)}]:ze(e.value)?[e]:[])),Yo=(e,t,o,n)=>r=>r(qo(e,t,o,n)),Xo=(e,t,o)=>{const n=B(t,(e=>{return{text:e.title,value:"#"+(t=e.value,Bo(t).orThunk((()=>Vo(t).map(Ho))).getOrThunk((()=>{const e=document.createElement("canvas");e.height=1,e.width=1;const o=e.getContext("2d");o.clearRect(0,0,e.width,e.height),o.fillStyle="#FFFFFF",o.fillStyle=t,o.fillRect(0,0,1,1);const n=o.getImageData(0,0,1,1).data,r=n[0],s=n[1],a=n[2],i=n[3];return Ho(Fo(r,s,a,i))}))).value,type:"choiceitem"};var t}));return[{type:"fancymenuitem",fancytype:"colorswatch",initData:{colors:n.length>0?n:void 0,allowCustomColors:!1},onAction:t=>{const n="remove"===t.value?"":t.value;e.execCommand("mceTableApplyCellStyle",!1,{[o]:n})}}]},Jo=e=>()=>{const t="header"===e.queryCommandValue("mceTableRowType")?"body":"header";e.execCommand("mceTableRowType",!1,{type:t})},Qo=e=>()=>{const t="th"===e.queryCommandValue("mceTableColType")?"td":"th";e.execCommand("mceTableColType",!1,{type:t})},en=[{name:"width",type:"input",label:"Width"},{name:"height",type:"input",label:"Height"},{name:"celltype",type:"listbox",label:"Cell type",items:[{text:"Cell",value:"td"},{text:"Header cell",value:"th"}]},{name:"scope",type:"listbox",label:"Scope",items:[{text:"None",value:""},{text:"Row",value:"row"},{text:"Column",value:"col"},{text:"Row group",value:"rowgroup"},{text:"Column group",value:"colgroup"}]},{name:"halign",type:"listbox",label:"Horizontal align",items:[{text:"None",value:""},{text:"Left",value:"left"},{text:"Center",value:"center"},{text:"Right",value:"right"}]},{name:"valign",type:"listbox",label:"Vertical align",items:Ao}],tn=e=>en.concat((e=>{const t=Wo(Pt(e));return t.length>0?y.some({name:"class",type:"listbox",label:"Class",items:t}):y.none()})(e).toArray()),on=(e,t)=>{const o=[{name:"borderstyle",type:"listbox",label:"Border style",items:[{text:"Select...",value:""}].concat(Wo(Mt(e)))},{name:"bordercolor",type:"colorinput",label:"Border color"},{name:"backgroundcolor",type:"colorinput",label:"Background color"}];return{title:"Advanced",name:"advanced",items:"cell"===t?[{name:"borderwidth",type:"input",label:"Border width"}].concat(o):o}},nn=(e,t)=>{const o=e.dom;return{setAttrib:(e,n)=>{o.setAttrib(t,e,n)},setStyle:(e,n)=>{o.setStyle(t,e,n)},setFormat:(o,n)=>{""===n?e.formatter.remove(o,{value:null},t,!0):e.formatter.apply(o,{value:n},t)}}},rn=ne("th"),sn=(e,t)=>e&&t?"sectionCells":e?"section":"cells",an=e=>{const t=H(e,(e=>rn(e.element)));return 0===t.length?y.some("td"):t.length===e.length?y.some("th"):y.none()},ln=e=>{const t=B(e,(e=>(e=>{const t="thead"===e.section,o=Le(an(e.cells),"th");return"tfoot"===e.section?{type:"footer"}:t||o?{type:"header",subType:sn(t,o)}:{type:"body"}})(e).type)),o=M(t,"header"),n=M(t,"footer");if(o||n){const e=M(t,"body");return!o||e||n?o||e||!n?y.none():y.some("footer"):y.some("header")}return y.some("body")},cn=(e,t)=>Z(e.all,(e=>P(e.cells,(e=>q(t,e.element))))),dn=(e,t,o)=>{const n=(e=>{const t=[],o=e=>{t.push(e)};for(let t=0;tet(t).bind((t=>cn(e,t))).filter(o))));return r=n.length>0,s=n,r?y.some(s):y.none();var r,s},mn=(e,t)=>dn(e,t,v),un=(e,t)=>z(t,(t=>((e,t)=>cn(e,t).exists((e=>!e.isLocked)))(e,t))),gn=(e,t)=>((e,t)=>t.mergable)(0,t).filter((t=>un(e,t.cells))),pn=(e,t)=>((e,t)=>t.unmergable)(0,t).filter((t=>un(e,t))),hn=e=>{if(!r(e))throw new Error("cases must be an array");if(0===e.length)throw new Error("there must be at least one case");const t=[],o={};return L(e,((n,s)=>{const a=w(n);if(1!==a.length)throw new Error("one and only one name per case");const i=a[0],l=n[i];if(void 0!==o[i])throw new Error("duplicate key detected:"+i);if("cata"===i)throw new Error("cannot have a case named cata (sorry)");if(!r(l))throw new Error("case arguments must be an array");t.push(i),o[i]=(...o)=>{const n=o.length;if(n!==l.length)throw new Error("Wrong number of arguments to case "+i+". Expected "+l.length+" ("+l+"), got "+n);return{fold:(...t)=>{if(t.length!==e.length)throw new Error("Wrong number of arguments to fold. Expected "+e.length+", got "+t.length);return t[s].apply(null,o)},match:e=>{const n=w(e);if(t.length!==n.length)throw new Error("Wrong number of arguments to match. Expected: "+t.join(",")+"\nActual: "+n.join(","));if(!z(t,(e=>M(n,e))))throw new Error("Not all branches were specified when using match. Specified: "+n.join(", ")+"\nRequired: "+t.join(", "));return e[i].apply(null,o)},log:e=>{console.log(e,{constructors:t,constructor:i,params:o})}}}})),o},fn=(hn([{none:[]},{only:["index"]},{left:["index","next"]},{middle:["prev","index","next"]},{right:["prev","index"]}]),(e,t)=>{const o=dt(e);return mn(o,t).bind((e=>{const t=e[e.length-1],n=e[0].row,r=t.row+t.rowspan,s=o.all.slice(n,r);return ln(s)})).getOr("")}),bn=e=>{return Ie(e,"rgb")?Vo(t=e).map(Ho).map((e=>"#"+e.value)).getOr(t):e;var t},vn=e=>{const t=j.fromDom(e);return{borderwidth:We(t,"border-width").getOr(""),borderstyle:We(t,"border-style").getOr(""),bordercolor:We(t,"border-color").map(bn).getOr(""),backgroundcolor:We(t,"background-color").map(bn).getOr("")}},yn=e=>{const t=e[0],o=e.slice(1);return L(o,(e=>{L(w(t),(o=>{C(e,((e,n)=>{const r=t[o];""!==r&&o===n&&r!==e&&(t[o]="")}))}))})),t},wn=(e,t,o,n)=>P(e,(e=>!a(o.formatter.matchNode(n,t+e)))).getOr(""),xn=h(wn,["left","center","right"],"align"),Cn=h(wn,["top","middle","bottom"],"valign"),Sn=e=>tt(j.fromDom(e)).map((t=>{const o={selection:wo(e.cells)};return fn(t,o)})).getOr(""),kn=(e,t)=>{const o=dt(e),n=gt(o),r=H(n,(e=>N(t,(t=>q(e.element,t)))));return B(r,(e=>({element:e.element.dom,column:pt(o,e.column).map((e=>e.element.dom))})))},_n=(e,t,o,n)=>{const r=1===t.length;L(t,(t=>{const s=t.element,a=r?v:n,i=nn(e,s);((e,t,o,n)=>{n("scope")&&e.setAttrib("scope",o.scope),n("class")&&e.setAttrib("class",o.class),n("height")&&e.setStyle("height",ke(o.height)),n("width")&&t.setStyle("width",ke(o.width))})(i,t.column.map((t=>nn(e,t))).getOr(i),o,a),Nt(e)&&((e,t,o)=>{o("backgroundcolor")&&e.setFormat("tablecellbackgroundcolor",t.backgroundcolor),o("bordercolor")&&e.setFormat("tablecellbordercolor",t.bordercolor),o("borderstyle")&&e.setFormat("tablecellborderstyle",t.borderstyle),o("borderwidth")&&e.setFormat("tablecellborderwidth",ke(t.borderwidth))})(i,o,a),n("halign")&&bt(e,s,o.halign),n("valign")&&((e,t,o)=>{ht.each("top middle bottom".split(" "),(n=>{n!==o&&e.formatter.remove("valign"+n,{},t)})),o&&e.formatter.apply("valign"+o,{},t)})(e,s,o.valign)}))},On=(e,t,o,n)=>{const r=n.getData();n.close(),e.undoManager.transact((()=>{((e,t,o,n)=>{const r=S(n,((e,t)=>o[t]!==e));_(r)>0&&t.length>=1&&tt(t[0]).each((o=>{const s=kn(o,t),a=_(S(r,((e,t)=>"scope"!==t&&"celltype"!==t)))>0,i=T(r,"celltype");(a||T(r,"scope"))&&_n(e,s,n,h(T,r)),i&&((e,t)=>{e.execCommand("mceTableCellType",!1,{type:t.celltype,no_events:!0})})(e,n),vt(e,o.dom,{structure:i,style:a})}))})(e,t,o,r),e.focus()}))},Tn=(e,t)=>{const o=tt(t[0]).map((o=>B(kn(o,t),(t=>((e,t,o,n)=>{const r=e.dom,s=(e,t)=>r.getStyle(e,t)||r.getAttrib(e,t);return{width:s(n.getOr(t),"width"),height:s(t,"height"),scope:r.getAttrib(t,"scope"),celltype:(a=t,a.nodeName.toLowerCase()),class:r.getAttrib(t,"class",""),halign:xn(e,t),valign:Cn(e,t),...o?vn(t):{}};var a})(e,t.element,Nt(e),t.column)))));return yn(o.getOrDie())},En=e=>{const t=Eo(e);if(0===t.length)return;const o=Tn(e,t),n={type:"tabpanel",tabs:[{title:"General",name:"general",items:tn(e)},on(e,"cell")]},r={type:"panel",items:[{type:"grid",columns:2,items:tn(e)}]};e.windowManager.open({title:"Cell Properties",size:"normal",body:Nt(e)?n:r,buttons:[{type:"cancel",name:"cancel",text:"Cancel"},{type:"submit",name:"save",text:"Save",primary:!0}],initialData:o,onSubmit:h(On,e,t,o)})},Dn=[{type:"listbox",name:"type",label:"Row type",items:[{text:"Header",value:"header"},{text:"Body",value:"body"},{text:"Footer",value:"footer"}]},{type:"listbox",name:"align",label:"Alignment",items:[{text:"None",value:""},{text:"Left",value:"left"},{text:"Center",value:"center"},{text:"Right",value:"right"}]},{label:"Height",name:"height",type:"input"}],An=e=>Dn.concat((e=>{const t=Wo(Ft(e));return t.length>0?y.some({name:"class",type:"listbox",label:"Class",items:t}):y.none()})(e).toArray()),Mn=(e,t,o,n)=>{const r=1===t.length?v:n;L(t,(t=>{const s=nn(e,t);((e,t,o)=>{o("class")&&e.setAttrib("class",t.class),o("height")&&e.setStyle("height",ke(t.height))})(s,o,r),Rt(e)&&((e,t,o)=>{o("backgroundcolor")&&e.setStyle("background-color",t.backgroundcolor),o("bordercolor")&&e.setStyle("border-color",t.bordercolor),o("borderstyle")&&e.setStyle("border-style",t.borderstyle)})(s,o,r),n("align")&&bt(e,t,o.align)}))},Nn=(e,t,o,n)=>{const r=n.getData();n.close(),e.undoManager.transact((()=>{((e,t,o,n)=>{const r=S(n,((e,t)=>o[t]!==e));if(_(r)>0){const o=T(r,"type"),s=!o||_(r)>1;s&&Mn(e,t,n,h(T,r)),o&&((e,t)=>{e.execCommand("mceTableRowType",!1,{type:t.type,no_events:!0})})(e,n),tt(j.fromDom(t[0])).each((t=>vt(e,t.dom,{structure:o,style:s})))}})(e,t,o,r),e.focus()}))},Rn=e=>{const t=Do(_e(e),ko.selected);if(0===t.length)return;const o=B(t,(t=>((e,t,o)=>{const n=e.dom;return{height:n.getStyle(t,"height")||n.getAttrib(t,"height"),class:n.getAttrib(t,"class",""),type:Sn(t),align:xn(e,t),...o?vn(t):{}}})(e,t.dom,Rt(e)))),n=yn(o),r={type:"tabpanel",tabs:[{title:"General",name:"general",items:An(e)},on(e,"row")]},s={type:"panel",items:[{type:"grid",columns:2,items:An(e)}]};e.windowManager.open({title:"Row Properties",size:"normal",body:Rt(e)?r:s,buttons:[{type:"cancel",name:"cancel",text:"Cancel"},{type:"submit",name:"save",text:"Save",primary:!0}],initialData:n,onSubmit:h(Nn,e,B(t,(e=>e.dom)),n)})},Bn=(e,t,o)=>{const n=o?[{type:"input",name:"cols",label:"Cols",inputMode:"numeric"},{type:"input",name:"rows",label:"Rows",inputMode:"numeric"}]:[],r=Lt(e)?[{type:"input",name:"cellspacing",label:"Cell spacing",inputMode:"numeric"},{type:"input",name:"cellpadding",label:"Cell padding",inputMode:"numeric"},{type:"input",name:"border",label:"Border width"},{type:"label",label:"Caption",items:[{type:"checkbox",name:"caption",label:"Show caption"}]}]:[],s=t.length>0?[{type:"listbox",name:"class",label:"Class",items:t}]:[];return n.concat([{type:"input",name:"width",label:"Width"},{type:"input",name:"height",label:"Height"}]).concat(r).concat([{type:"listbox",name:"align",label:"Alignment",items:[{text:"None",value:""},{text:"Left",value:"left"},{text:"Center",value:"center"},{text:"Right",value:"right"}]}]).concat(s)},Ln=(e,t,o,r)=>{if("TD"===t.tagName||"TH"===t.tagName)n(o)&&l(r)?e.setStyle(t,o,r):e.setStyles(t,o);else if(t.children)for(let n=0;n{const r=e.dom,s={},i={},l=It(e),c=Bt(e);if(a(o.class)||(s.class=o.class),i.height=ke(o.height),l?i.width=ke(o.width):r.getAttrib(t,"width")&&(s.width=(e=>e?e.replace(/px$/,""):"")(o.width)),l?(i["border-width"]=ke(o.border),i["border-spacing"]=ke(o.cellspacing)):(s.border=o.border,s.cellpadding=o.cellpadding,s.cellspacing=o.cellspacing),l&&t.children){const e={};if(n.border&&(e["border-width"]=ke(o.border)),n.cellpadding&&(e.padding=ke(o.cellpadding)),c&&n.bordercolor&&(e["border-color"]=o.bordercolor),!(e=>{for(const t in e)if(x.call(e,t))return!1;return!0})(e))for(let o=0;o{const r=e.dom,s=n.getData(),a=S(s,((e,t)=>o[t]!==e));n.close(),""===s.class&&delete s.class,e.undoManager.transact((()=>{if(!t){const o=Ve(s.cols).getOr(1),n=Ve(s.rows).getOr(1);e.execCommand("mceInsertTable",!1,{rows:n,columns:o}),t=To(_e(e),Se(e)).bind((t=>tt(t,Se(e)))).map((e=>e.dom)).getOrDie()}if(_(a)>0){const o={border:T(a,"border"),bordercolor:T(a,"bordercolor"),cellpadding:T(a,"cellpadding")};Hn(e,t,s,o);const n=r.select("caption",t)[0];(n&&!s.caption||!n&&s.caption)&&e.execCommand("mceTableToggleCaption"),bt(e,t,s.align)}if(e.focus(),e.addVisual(),_(a)>0){const o=T(a,"caption"),n=!o||_(a)>1;vt(e,t,{structure:o,style:n})}}))},Pn=(e,t)=>{const o=e.dom;let n,r=((e,t)=>{const o=Wt(e),n=qt(e),r=t?{borderstyle:O(o,"border-style").getOr(""),bordercolor:bn(O(o,"border-color").getOr("")),backgroundcolor:bn(O(o,"background-color").getOr(""))}:{};return{height:"",width:"100%",cellspacing:"",cellpadding:"",caption:!1,class:"",align:"",border:"",...o,...n,...r,...(()=>{const t=o["border-width"];return It(e)&&t?{border:t}:O(n,"border").fold((()=>({})),(e=>({border:e})))})(),...{...O(o,"border-spacing").or(O(n,"cellspacing")).fold((()=>({})),(e=>({cellspacing:e}))),...O(o,"border-padding").or(O(n,"cellpadding")).fold((()=>({})),(e=>({cellpadding:e})))}}})(e,Bt(e));t?(r.cols="1",r.rows="1",Bt(e)&&(r.borderstyle="",r.bordercolor="",r.backgroundcolor="")):(n=o.getParent(e.selection.getStart(),"table",e.getBody()),n?r=((e,t,o)=>{const n=e.dom,r=It(e)?n.getStyle(t,"border-spacing")||n.getAttrib(t,"cellspacing"):n.getAttrib(t,"cellspacing")||n.getStyle(t,"border-spacing"),s=It(e)?ft(n,t,"padding")||n.getAttrib(t,"cellpadding"):n.getAttrib(t,"cellpadding")||ft(n,t,"padding");return{width:n.getStyle(t,"width")||n.getAttrib(t,"width"),height:n.getStyle(t,"height")||n.getAttrib(t,"height"),cellspacing:null!=r?r:"",cellpadding:null!=s?s:"",border:((t,o)=>{const n=We(j.fromDom(o),"border-width");return It(e)&&n.isSome()?n.getOr(""):t.getAttrib(o,"border")||ft(e.dom,o,"border-width")||ft(e.dom,o,"border")||""})(n,t),caption:!!n.select("caption",t)[0],class:n.getAttrib(t,"class",""),align:xn(e,t),...o?vn(t):{}}})(e,n,Bt(e)):Bt(e)&&(r.borderstyle="",r.bordercolor="",r.backgroundcolor=""));const s=Wo(zt(e));s.length>0&&r.class&&(r.class=r.class.replace(/\s*mce\-item\-table\s*/g,""));const a={type:"grid",columns:2,items:Bn(e,s,t)},i=Bt(e)?{type:"tabpanel",tabs:[{title:"General",name:"general",items:[a]},on(e,"table")]}:{type:"panel",items:[a]};e.windowManager.open({title:"Table Properties",size:"normal",body:i,onSubmit:h(In,e,n,r),buttons:[{type:"cancel",name:"cancel",text:"Cancel"},{type:"submit",name:"save",text:"Save",primary:!0}],initialData:r})},Fn=e=>{C({mceTableProps:h(Pn,e,!1),mceTableRowProps:h(Rn,e),mceTableCellProps:h(En,e),mceInsertTableDialog:h(Pn,e,!0)},((t,o)=>e.addCommand(o,(()=>{return o=t,void(Oe(_e(e))&&o());var o}))))},zn=g,Vn=e=>{const t=(e,t)=>Re(e,t).exists((e=>parseInt(e,10)>1));return e.length>0&&z(e,(e=>t(e,"rowspan")||t(e,"colspan")))?y.some(e):y.none()},Zn=(e,t,o)=>t.length<=1?y.none():yo(e,o.firstSelectedSelector,o.lastSelectedSelector).map((e=>({bounds:e,cells:t}))),Un=e=>{const t=Zo(y.none()),o=Zo([]);let n=y.none();const r=ne("caption"),s=e=>n.forall((t=>!t[e])),a=()=>Oo((e=>j.fromDom(e.selection.getEnd()))(e),Se(e)),i=()=>Oo(_e(e),Se(e)).bind((t=>{return o=He(tt(t),a().bind(tt),((o,n)=>q(o,n)?r(t)?y.some((e=>({element:e,mergable:y.none(),unmergable:y.none(),selection:[e]}))(t)):y.some(((e,t,o)=>({element:o,mergable:Zn(t,e,ko),unmergable:Vn(e),selection:zn(e)}))(Eo(e),o,t)):y.none())),o.bind(g);var o})),l=e=>tt(e.element).map((t=>{const o=dt(t),n=mn(o,e).getOr([]),r=I(n,((e,t)=>(t.isLocked&&(e.onAny=!0,0===t.column?e.onFirst=!0:t.column+t.colspan>=o.grid.columns&&(e.onLast=!0)),e)),{onAny:!1,onFirst:!1,onLast:!1});return{mergeable:gn(o,e).isSome(),unmergeable:pn(o,e).isSome(),locked:r}})),c=()=>{t.set((e=>{let t,o=!1;return(...n)=>(o||(o=!0,t=e.apply(null,n)),t)})(i)()),n=t.get().bind(l),L(o.get(),f)},d=e=>(e(),o.set(o.get().concat([e])),()=>{o.set(H(o.get(),(t=>t!==e)))}),m=(o,n)=>d((()=>t.get().fold((()=>{o.setEnabled(!1)}),(t=>{o.setEnabled(!n(t)&&e.selection.isEditable())})))),u=(o,n,r)=>d((()=>t.get().fold((()=>{o.setEnabled(!1),o.setActive(!1)}),(t=>{o.setEnabled(!n(t)&&e.selection.isEditable()),o.setActive(r(t))})))),p=e=>n.exists((t=>t.locked[e])),h=(t,o)=>n=>u(n,(e=>r(e.element)),(()=>e.queryCommandValue(t)===o)),v=h("mceTableRowType","header"),w=h("mceTableColType","th");return e.on("NodeChange ExecCommand TableSelectorChange",c),{onSetupTable:e=>m(e,(e=>!1)),onSetupCellOrRow:e=>m(e,(e=>r(e.element))),onSetupColumn:e=>t=>m(t,(t=>r(t.element)||p(e))),onSetupPasteable:e=>t=>m(t,(t=>r(t.element)||e().isNone())),onSetupPasteableColumn:(e,t)=>o=>m(o,(o=>r(o.element)||e().isNone()||p(t))),onSetupMergeable:e=>m(e,(e=>s("mergeable"))),onSetupUnmergeable:e=>m(e,(e=>s("unmergeable"))),resetTargets:c,onSetupTableWithCaption:t=>u(t,b,(t=>tt(t.element,Se(e)).exists((e=>ve(e,"caption").isSome())))),onSetupTableRowHeaders:v,onSetupTableColumnHeaders:w,targets:t.get}};var jn=tinymce.util.Tools.resolve("tinymce.FakeClipboard");const $n="x-tinymce/dom-table-",Wn=$n+"rows",qn=$n+"columns",Gn=e=>{var t;const o=null!==(t=jn.read())&&void 0!==t?t:[];return Z(o,(t=>y.from(t.getType(e))))},Kn=()=>Gn(Wn),Yn=()=>Gn(qn),Xn=e=>t=>{const o=()=>{t.setEnabled(e.selection.isEditable())};return e.on("NodeChange",o),o(),()=>{e.off("NodeChange",o)}},Jn=e=>t=>{const o=()=>{t.setEnabled(e.selection.isEditable())};return e.on("NodeChange",o),o(),()=>{e.off("NodeChange",o)}},Qn=e=>{const t=Un(e);(e=>{const t=e.options.register;t("table_border_widths",{processor:"object[]",default:kt}),t("table_border_styles",{processor:"object[]",default:_t}),t("table_cell_advtab",{processor:"boolean",default:!0}),t("table_row_advtab",{processor:"boolean",default:!0}),t("table_advtab",{processor:"boolean",default:!0}),t("table_appearance_options",{processor:"boolean",default:!0}),t("table_grid",{processor:"boolean",default:!St.deviceType.isTouch()}),t("table_cell_class_list",{processor:"object[]",default:[]}),t("table_row_class_list",{processor:"object[]",default:[]}),t("table_class_list",{processor:"object[]",default:[]}),t("table_toolbar",{processor:"string",default:"tableprops tabledelete | tableinsertrowbefore tableinsertrowafter tabledeleterow | tableinsertcolbefore tableinsertcolafter tabledeletecol"}),t("table_background_color_map",{processor:"object[]",default:[]}),t("table_border_color_map",{processor:"object[]",default:[]})})(e),Fn(e),((e,t)=>{const o=t=>()=>e.execCommand(t),n=(t,n)=>!!e.queryCommandSupported(n.command)&&(e.ui.registry.addMenuItem(t,{...n,onAction:c(n.onAction)?n.onAction:o(n.command)}),!0),r=(t,n)=>{e.queryCommandSupported(n.command)&&e.ui.registry.addToggleMenuItem(t,{...n,onAction:c(n.onAction)?n.onAction:o(n.command)})},s=t=>{e.execCommand("mceInsertTable",!1,{rows:t.numRows,columns:t.numColumns})},a=[n("tableinsertrowbefore",{text:"Insert row before",icon:"table-insert-row-above",command:"mceTableInsertRowBefore",onSetup:t.onSetupCellOrRow}),n("tableinsertrowafter",{text:"Insert row after",icon:"table-insert-row-after",command:"mceTableInsertRowAfter",onSetup:t.onSetupCellOrRow}),n("tabledeleterow",{text:"Delete row",icon:"table-delete-row",command:"mceTableDeleteRow",onSetup:t.onSetupCellOrRow}),n("tablerowprops",{text:"Row properties",icon:"table-row-properties",command:"mceTableRowProps",onSetup:t.onSetupCellOrRow}),n("tablecutrow",{text:"Cut row",icon:"cut-row",command:"mceTableCutRow",onSetup:t.onSetupCellOrRow}),n("tablecopyrow",{text:"Copy row",icon:"duplicate-row",command:"mceTableCopyRow",onSetup:t.onSetupCellOrRow}),n("tablepasterowbefore",{text:"Paste row before",icon:"paste-row-before",command:"mceTablePasteRowBefore",onSetup:t.onSetupPasteable(Kn)}),n("tablepasterowafter",{text:"Paste row after",icon:"paste-row-after",command:"mceTablePasteRowAfter",onSetup:t.onSetupPasteable(Kn)})],i=[n("tableinsertcolumnbefore",{text:"Insert column before",icon:"table-insert-column-before",command:"mceTableInsertColBefore",onSetup:t.onSetupColumn("onFirst")}),n("tableinsertcolumnafter",{text:"Insert column after",icon:"table-insert-column-after",command:"mceTableInsertColAfter",onSetup:t.onSetupColumn("onLast")}),n("tabledeletecolumn",{text:"Delete column",icon:"table-delete-column",command:"mceTableDeleteCol",onSetup:t.onSetupColumn("onAny")}),n("tablecutcolumn",{text:"Cut column",icon:"cut-column",command:"mceTableCutCol",onSetup:t.onSetupColumn("onAny")}),n("tablecopycolumn",{text:"Copy column",icon:"duplicate-column",command:"mceTableCopyCol",onSetup:t.onSetupColumn("onAny")}),n("tablepastecolumnbefore",{text:"Paste column before",icon:"paste-column-before",command:"mceTablePasteColBefore",onSetup:t.onSetupPasteableColumn(Yn,"onFirst")}),n("tablepastecolumnafter",{text:"Paste column after",icon:"paste-column-after",command:"mceTablePasteColAfter",onSetup:t.onSetupPasteableColumn(Yn,"onLast")})],l=[n("tablecellprops",{text:"Cell properties",icon:"table-cell-properties",command:"mceTableCellProps",onSetup:t.onSetupCellOrRow}),n("tablemergecells",{text:"Merge cells",icon:"table-merge-cells",command:"mceTableMergeCells",onSetup:t.onSetupMergeable}),n("tablesplitcells",{text:"Split cell",icon:"table-split-cells",command:"mceTableSplitCells",onSetup:t.onSetupUnmergeable})];Ht(e)?e.ui.registry.addNestedMenuItem("inserttable",{text:"Table",icon:"table",getSubmenuItems:()=>[{type:"fancymenuitem",fancytype:"inserttable",onAction:s}],onSetup:Jn(e)}):e.ui.registry.addMenuItem("inserttable",{text:"Table",icon:"table",onAction:o("mceInsertTableDialog"),onSetup:Jn(e)}),e.ui.registry.addMenuItem("inserttabledialog",{text:"Insert table",icon:"table",onAction:o("mceInsertTableDialog"),onSetup:Jn(e)}),n("tableprops",{text:"Table properties",onSetup:t.onSetupTable,command:"mceTableProps"}),n("deletetable",{text:"Delete table",icon:"table-delete-table",onSetup:t.onSetupTable,command:"mceTableDelete"}),M(a,!0)&&e.ui.registry.addNestedMenuItem("row",{type:"nestedmenuitem",text:"Row",getSubmenuItems:u("tableinsertrowbefore tableinsertrowafter tabledeleterow tablerowprops | tablecutrow tablecopyrow tablepasterowbefore tablepasterowafter")}),M(i,!0)&&e.ui.registry.addNestedMenuItem("column",{type:"nestedmenuitem",text:"Column",getSubmenuItems:u("tableinsertcolumnbefore tableinsertcolumnafter tabledeletecolumn | tablecutcolumn tablecopycolumn tablepastecolumnbefore tablepastecolumnafter")}),M(l,!0)&&e.ui.registry.addNestedMenuItem("cell",{type:"nestedmenuitem",text:"Cell",getSubmenuItems:u("tablecellprops tablemergecells tablesplitcells")}),e.ui.registry.addContextMenu("table",{update:()=>(t.resetTargets(),t.targets().fold(u(""),(e=>"caption"===K(e.element)?"tableprops deletetable":"cell row column | advtablesort | tableprops deletetable")))});const d=Ko(zt(e));0!==d.length&&e.queryCommandSupported("mceTableToggleClass")&&e.ui.registry.addNestedMenuItem("tableclass",{icon:"table-classes",text:"Table styles",getSubmenuItems:()=>qo(e,d,"tableclass",(t=>e.execCommand("mceTableToggleClass",!1,t))),onSetup:t.onSetupTable});const m=Ko(Pt(e));0!==m.length&&e.queryCommandSupported("mceTableCellToggleClass")&&e.ui.registry.addNestedMenuItem("tablecellclass",{icon:"table-cell-classes",text:"Cell styles",getSubmenuItems:()=>qo(e,m,"tablecellclass",(t=>e.execCommand("mceTableCellToggleClass",!1,t))),onSetup:t.onSetupCellOrRow}),e.queryCommandSupported("mceTableApplyCellStyle")&&(e.ui.registry.addNestedMenuItem("tablecellvalign",{icon:"vertical-align",text:"Vertical align",getSubmenuItems:()=>qo(e,Ao,"tablecellverticalalign",Go(e,"vertical-align")),onSetup:t.onSetupCellOrRow}),e.ui.registry.addNestedMenuItem("tablecellborderwidth",{icon:"border-width",text:"Border width",getSubmenuItems:()=>qo(e,At(e),"tablecellborderwidth",Go(e,"border-width")),onSetup:t.onSetupCellOrRow}),e.ui.registry.addNestedMenuItem("tablecellborderstyle",{icon:"border-style",text:"Border style",getSubmenuItems:()=>qo(e,Mt(e),"tablecellborderstyle",Go(e,"border-style")),onSetup:t.onSetupCellOrRow}),e.ui.registry.addNestedMenuItem("tablecellbackgroundcolor",{icon:"cell-background-color",text:"Background color",getSubmenuItems:()=>Xo(e,Zt(e),"background-color"),onSetup:t.onSetupCellOrRow}),e.ui.registry.addNestedMenuItem("tablecellbordercolor",{icon:"cell-border-color",text:"Border color",getSubmenuItems:()=>Xo(e,Ut(e),"border-color"),onSetup:t.onSetupCellOrRow})),r("tablecaption",{icon:"table-caption",text:"Table caption",command:"mceTableToggleCaption",onSetup:t.onSetupTableWithCaption}),r("tablerowheader",{text:"Row header",icon:"table-top-header",command:"mceTableRowType",onAction:Jo(e),onSetup:t.onSetupTableRowHeaders}),r("tablecolheader",{text:"Column header",icon:"table-left-header",command:"mceTableColType",onAction:Qo(e),onSetup:t.onSetupTableRowHeaders})})(e,t),((e,t)=>{e.ui.registry.addMenuButton("table",{tooltip:"Table",icon:"table",onSetup:Xn(e),fetch:e=>e("inserttable | cell row column | advtablesort | tableprops deletetable")});const o=t=>()=>e.execCommand(t),n=(t,n)=>{e.queryCommandSupported(n.command)&&e.ui.registry.addButton(t,{...n,onAction:c(n.onAction)?n.onAction:o(n.command)})},r=(t,n)=>{e.queryCommandSupported(n.command)&&e.ui.registry.addToggleButton(t,{...n,onAction:c(n.onAction)?n.onAction:o(n.command)})};n("tableprops",{tooltip:"Table properties",command:"mceTableProps",icon:"table",onSetup:t.onSetupTable}),n("tabledelete",{tooltip:"Delete table",command:"mceTableDelete",icon:"table-delete-table",onSetup:t.onSetupTable}),n("tablecellprops",{tooltip:"Cell properties",command:"mceTableCellProps",icon:"table-cell-properties",onSetup:t.onSetupCellOrRow}),n("tablemergecells",{tooltip:"Merge cells",command:"mceTableMergeCells",icon:"table-merge-cells",onSetup:t.onSetupMergeable}),n("tablesplitcells",{tooltip:"Split cell",command:"mceTableSplitCells",icon:"table-split-cells",onSetup:t.onSetupUnmergeable}),n("tableinsertrowbefore",{tooltip:"Insert row before",command:"mceTableInsertRowBefore",icon:"table-insert-row-above",onSetup:t.onSetupCellOrRow}),n("tableinsertrowafter",{tooltip:"Insert row after",command:"mceTableInsertRowAfter",icon:"table-insert-row-after",onSetup:t.onSetupCellOrRow}),n("tabledeleterow",{tooltip:"Delete row",command:"mceTableDeleteRow",icon:"table-delete-row",onSetup:t.onSetupCellOrRow}),n("tablerowprops",{tooltip:"Row properties",command:"mceTableRowProps",icon:"table-row-properties",onSetup:t.onSetupCellOrRow}),n("tableinsertcolbefore",{tooltip:"Insert column before",command:"mceTableInsertColBefore",icon:"table-insert-column-before",onSetup:t.onSetupColumn("onFirst")}),n("tableinsertcolafter",{tooltip:"Insert column after",command:"mceTableInsertColAfter",icon:"table-insert-column-after",onSetup:t.onSetupColumn("onLast")}),n("tabledeletecol",{tooltip:"Delete column",command:"mceTableDeleteCol",icon:"table-delete-column",onSetup:t.onSetupColumn("onAny")}),n("tablecutrow",{tooltip:"Cut row",command:"mceTableCutRow",icon:"cut-row",onSetup:t.onSetupCellOrRow}),n("tablecopyrow",{tooltip:"Copy row",command:"mceTableCopyRow",icon:"duplicate-row",onSetup:t.onSetupCellOrRow}),n("tablepasterowbefore",{tooltip:"Paste row before",command:"mceTablePasteRowBefore",icon:"paste-row-before",onSetup:t.onSetupPasteable(Kn)}),n("tablepasterowafter",{tooltip:"Paste row after",command:"mceTablePasteRowAfter",icon:"paste-row-after",onSetup:t.onSetupPasteable(Kn)}),n("tablecutcol",{tooltip:"Cut column",command:"mceTableCutCol",icon:"cut-column",onSetup:t.onSetupColumn("onAny")}),n("tablecopycol",{tooltip:"Copy column",command:"mceTableCopyCol",icon:"duplicate-column",onSetup:t.onSetupColumn("onAny")}),n("tablepastecolbefore",{tooltip:"Paste column before",command:"mceTablePasteColBefore",icon:"paste-column-before",onSetup:t.onSetupPasteableColumn(Yn,"onFirst")}),n("tablepastecolafter",{tooltip:"Paste column after",command:"mceTablePasteColAfter",icon:"paste-column-after",onSetup:t.onSetupPasteableColumn(Yn,"onLast")}),n("tableinsertdialog",{tooltip:"Insert table",command:"mceInsertTableDialog",icon:"table",onSetup:Xn(e)});const s=Ko(zt(e));0!==s.length&&e.queryCommandSupported("mceTableToggleClass")&&e.ui.registry.addMenuButton("tableclass",{icon:"table-classes",tooltip:"Table styles",fetch:Yo(e,s,"tableclass",(t=>e.execCommand("mceTableToggleClass",!1,t))),onSetup:t.onSetupTable});const a=Ko(Pt(e));0!==a.length&&e.queryCommandSupported("mceTableCellToggleClass")&&e.ui.registry.addMenuButton("tablecellclass",{icon:"table-cell-classes",tooltip:"Cell styles",fetch:Yo(e,a,"tablecellclass",(t=>e.execCommand("mceTableCellToggleClass",!1,t))),onSetup:t.onSetupCellOrRow}),e.queryCommandSupported("mceTableApplyCellStyle")&&(e.ui.registry.addMenuButton("tablecellvalign",{icon:"vertical-align",tooltip:"Vertical align",fetch:Yo(e,Ao,"tablecellverticalalign",Go(e,"vertical-align")),onSetup:t.onSetupCellOrRow}),e.ui.registry.addMenuButton("tablecellborderwidth",{icon:"border-width",tooltip:"Border width",fetch:Yo(e,At(e),"tablecellborderwidth",Go(e,"border-width")),onSetup:t.onSetupCellOrRow}),e.ui.registry.addMenuButton("tablecellborderstyle",{icon:"border-style",tooltip:"Border style",fetch:Yo(e,Mt(e),"tablecellborderstyle",Go(e,"border-style")),onSetup:t.onSetupCellOrRow}),e.ui.registry.addMenuButton("tablecellbackgroundcolor",{icon:"cell-background-color",tooltip:"Background color",fetch:t=>t(Xo(e,Zt(e),"background-color")),onSetup:t.onSetupCellOrRow}),e.ui.registry.addMenuButton("tablecellbordercolor",{icon:"cell-border-color",tooltip:"Border color",fetch:t=>t(Xo(e,Ut(e),"border-color")),onSetup:t.onSetupCellOrRow})),r("tablecaption",{tooltip:"Table caption",icon:"table-caption",command:"mceTableToggleCaption",onSetup:t.onSetupTableWithCaption}),r("tablerowheader",{tooltip:"Row header",icon:"table-top-header",command:"mceTableRowType",onAction:Jo(e),onSetup:t.onSetupTableRowHeaders}),r("tablecolheader",{tooltip:"Column header",icon:"table-left-header",command:"mceTableColType",onAction:Qo(e),onSetup:t.onSetupTableColumnHeaders})})(e,t),(e=>{const t=t=>e.dom.is(t,"table")&&e.getBody().contains(t)&&e.dom.isEditable(t.parentNode),o=Vt(e);o.length>0&&e.ui.registry.addContextToolbar("table",{predicate:t,items:o,scope:"node",position:"node"})})(e)};e.add("table",Qn)}()},3356:(e,t,o)=>{o(3562)},3562:()=>{!function(){"use strict";var e=tinymce.util.Tools.resolve("tinymce.PluginManager");const t=(o=null,e=>o===e);var o;const n=e=>e,r=(e,t)=>{const o=e.length,n=new Array(o);for(let r=0;r]",punctuation:"[~№|!-*+-\\/:;?@\\[-`{}¡«·»¿;·՚-՟։֊־׀׃׆׳״؉؊،؍؛؞؟٪-٭۔܀-܍߷-߹࠰-࠾࡞।॥॰෴๏๚๛༄-༒༺-༽྅࿐-࿔࿙࿚၊-၏჻፡-፨᐀᙭᙮᚛᚜᛫-᛭᜵᜶។-៖៘-៚᠀-᠊᥄᥅᨞᨟᪠-᪦᪨-᪭᭚-᭠᯼-᯿᰻-᰿᱾᱿᳓‐-‧‰-⁃⁅-⁑⁓-⁞⁽⁾₍₎〈〉❨-❵⟅⟆⟦-⟯⦃-⦘⧘-⧛⧼⧽⳹-⳼⳾⳿⵰⸀-⸮⸰⸱、-〃〈-】〔-〟〰〽゠・꓾꓿꘍-꘏꙳꙾꛲-꛷꡴-꡷꣎꣏꣸-꣺꤮꤯꥟꧁-꧍꧞꧟꩜-꩟꫞꫟꯫﴾﴿︐-︙︰-﹒﹔-﹡﹣﹨﹪﹫!-#%-*,-/:;?@[-]_{}⦅-・]"},a=0,i=1,l=2,c=3,d=4,m=5,u=6,g=7,p=8,h=9,f=10,b=11,v=12,y=13,w=[new RegExp(s.aletter),new RegExp(s.midnumlet),new RegExp(s.midletter),new RegExp(s.midnum),new RegExp(s.numeric),new RegExp(s.cr),new RegExp(s.lf),new RegExp(s.newline),new RegExp(s.extend),new RegExp(s.format),new RegExp(s.katakana),new RegExp(s.extendnumlet),new RegExp("@")],x=new RegExp("^"+s.punctuation+"$"),C=w,S=y,k=e=>{let t=S;const o=C.length;for(let n=0;n{const o=e[t],n=e[t+1];if(t<0||t>e.length-1&&0!==t)return!1;if(o===a&&n===a)return!1;const r=e[t+2];if(o===a&&(n===l||n===i||n===v)&&r===a)return!1;const s=e[t-1];return(o!==l&&o!==i&&n!==v||n!==a||s!==a)&&((o!==d&&o!==a||n!==d&&n!==a)&&((o!==c&&o!==i||n!==d||s!==d)&&((o!==d||n!==c&&n!==i||r!==d)&&((o!==p&&o!==h||n!==a&&n!==d&&n!==f&&n!==p&&n!==h)&&(n!==p&&(n!==h||r!==a&&r!==d&&r!==f&&r!==p&&r!==h)||o!==a&&o!==d&&o!==f&&o!==p&&o!==h)&&((o!==m||n!==u)&&(o===g||o===m||o===u||(n===g||n===m||n===u||(o!==f||n!==f)&&((n!==b||o!==a&&o!==d&&o!==f&&o!==b)&&((o!==b||n!==a&&n!==d&&n!==f)&&o!==v)))))))))},O=/^\s+$/,T=x,E=e=>"http"===e||"https"===e,D=(e,t)=>{const o=((e,t)=>{let o;for(o=t;o{o={includeWhitespace:!1,includePunctuation:!1,...o};const n=r(e,t);return((e,t,o,n)=>{const r=[],s=[];let a=[];for(let i=0;i{const t=(e=>{const t={};return o=>{if(t[o])return t[o];{const n=e(o);return t[o]=n,n}}})(k);return r(e,t)})(n),o)},M=(e,t,o)=>A(e,t,o).words;var N=tinymce.util.Tools.resolve("tinymce.dom.TreeWalker");const R=(e,t)=>{const o=t.getBlockElements(),n=t.getVoidElements(),r=e=>o[e.nodeName]||n[e.nodeName],s=[];let a="";const i=new N(e,e);let l;for(;l=i.next();)3===l.nodeType?a+=l.data.replace(/\uFEFF/g,""):r(l)&&a.length&&(s.push(a),a="");return a.length&&s.push(a),s},B=e=>e.replace(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,"_").length,L=(e,t)=>{const o=(e=>e.replace(/\u200B/g,""))(R(e,t).join("\n"));return M(o.split(""),n).length},H=(e,t)=>{const o=R(e,t).join("");return B(o)},I=(e,t)=>{const o=R(e,t).join("").replace(/\s/g,"");return B(o)},P=(e,t)=>()=>t(e.getBody(),e.schema),F=(e,t)=>()=>t(e.selection.getRng().cloneContents(),e.schema),z=e=>P(e,L),V=(e,t)=>{e.addCommand("mceWordCount",(()=>((e,t)=>{e.windowManager.open({title:"Word Count",body:{type:"panel",items:[{type:"table",header:["Count","Document","Selection"],cells:[["Words",String(t.body.getWordCount()),String(t.selection.getWordCount())],["Characters (no spaces)",String(t.body.getCharacterCountWithoutSpaces()),String(t.selection.getCharacterCountWithoutSpaces())],["Characters",String(t.body.getCharacterCount()),String(t.selection.getCharacterCount())]]}]},buttons:[{type:"cancel",name:"close",text:"Close",primary:!0}]})})(e,t)))};var Z=tinymce.util.Tools.resolve("tinymce.util.Delay");const U=(e,t)=>{((e,t)=>{e.dispatch("wordCountUpdate",{wordCount:{words:t.body.getWordCount(),characters:t.body.getCharacterCount(),charactersWithoutSpaces:t.body.getCharacterCountWithoutSpaces()}})})(e,t)},j=(e,o,n)=>{const r=((e,o)=>{let n=null;return{cancel:()=>{t(n)||(clearTimeout(n),n=null)},throttle:(...r)=>{t(n)&&(n=setTimeout((()=>{n=null,e.apply(null,r)}),o))}}})((()=>U(e,o)),n);e.on("init",(()=>{U(e,o),Z.setEditorTimeout(e,(()=>{e.on("SetContent BeforeAddUndo Undo Redo ViewUpdate keyup",r.throttle)}),0),e.on("remove",r.cancel)}))};((t=300)=>{e.add("wordcount",(e=>{const o=(e=>({body:{getWordCount:z(e),getCharacterCount:P(e,H),getCharacterCountWithoutSpaces:P(e,I)},selection:{getWordCount:F(e,L),getCharacterCount:F(e,H),getCharacterCountWithoutSpaces:F(e,I)},getCount:z(e)}))(e);return V(e,o),(e=>{const t=()=>e.execCommand("mceWordCount");e.ui.registry.addButton("wordcount",{tooltip:"Word count",icon:"character-count",onAction:t}),e.ui.registry.addMenuItem("wordcount",{text:"Word count",icon:"character-count",onAction:t})})(e),j(e,o,t),o}))})()}()},8860:(e,t,o)=>{o(1768)},1768:()=>{!function(){"use strict";const e=Object.getPrototypeOf,t=(e,t,o)=>{var n;return!!o(e,t.prototype)||(null===(n=e.constructor)||void 0===n?void 0:n.name)===t.name},o=e=>o=>(e=>{const o=typeof e;return null===e?"null":"object"===o&&Array.isArray(e)?"array":"object"===o&&t(e,String,((e,t)=>t.isPrototypeOf(e)))?"string":o})(o)===e,n=e=>t=>typeof t===e,r=e=>t=>e===t,s=o("string"),a=o("object"),i=o=>((o,n)=>a(o)&&t(o,n,((t,o)=>e(t)===o)))(o,Object),l=o("array"),c=r(null),d=n("boolean"),m=r(void 0),u=e=>null==e,g=e=>!u(e),p=n("function"),h=n("number"),f=(e,t)=>{if(l(e)){for(let o=0,n=e.length;o{},v=e=>()=>e(),y=(e,t)=>(...o)=>e(t.apply(null,o)),w=e=>()=>e,x=e=>e,C=(e,t)=>e===t;function S(e,...t){return(...o)=>{const n=t.concat(o);return e.apply(null,n)}}const k=e=>t=>!e(t),_=e=>()=>{throw new Error(e)},O=e=>e(),T=w(!1),E=w(!0);class D{constructor(e,t){this.tag=e,this.value=t}static some(e){return new D(!0,e)}static none(){return D.singletonNone}fold(e,t){return this.tag?t(this.value):e()}isSome(){return this.tag}isNone(){return!this.tag}map(e){return this.tag?D.some(e(this.value)):D.none()}bind(e){return this.tag?e(this.value):D.none()}exists(e){return this.tag&&e(this.value)}forall(e){return!this.tag||e(this.value)}filter(e){return!this.tag||e(this.value)?this:D.none()}getOr(e){return this.tag?this.value:e}or(e){return this.tag?this:e}getOrThunk(e){return this.tag?this.value:e()}orThunk(e){return this.tag?this:e()}getOrDie(e){if(this.tag)return this.value;throw new Error(null!=e?e:"Called getOrDie on None")}static from(e){return g(e)?D.some(e):D.none()}getOrNull(){return this.tag?this.value:null}getOrUndefined(){return this.value}each(e){this.tag&&e(this.value)}toArray(){return this.tag?[this.value]:[]}toString(){return this.tag?`some(${this.value})`:"none()"}}D.singletonNone=new D(!1);const A=Array.prototype.slice,M=Array.prototype.indexOf,N=Array.prototype.push,R=(e,t)=>M.call(e,t),B=(e,t)=>{const o=R(e,t);return-1===o?D.none():D.some(o)},L=(e,t)=>R(e,t)>-1,H=(e,t)=>{for(let o=0,n=e.length;o{const o=[];for(let n=0;n{const o=[];for(let n=0;n{const o=e.length,n=new Array(o);for(let r=0;r{for(let o=0,n=e.length;o{const o=[],n=[];for(let r=0,s=e.length;r{const o=[];for(let n=0,r=e.length;n(((e,t)=>{for(let o=e.length-1;o>=0;o--)t(e[o],o)})(e,((e,n)=>{o=t(o,e,n)})),o),j=(e,t,o)=>(z(e,((e,n)=>{o=t(o,e,n)})),o),$=(e,t)=>((e,t,o)=>{for(let n=0,r=e.length;n{for(let o=0,n=e.length;o{const t=[];for(let o=0,n=e.length;oq(F(e,t)),K=(e,t)=>{for(let o=0,n=e.length;o{const t=A.call(e,0);return t.reverse(),t},X=(e,t)=>Z(e,(e=>!L(t,e))),J=(e,t)=>{const o={};for(let n=0,r=e.length;n[e],ee=(e,t)=>{const o=A.call(e,0);return o.sort(t),o},te=(e,t)=>t>=0&&tte(e,0),ne=e=>te(e,e.length-1),re=p(Array.from)?Array.from:e=>A.call(e),se=(e,t)=>{for(let o=0;o{const o=ae(e);for(let n=0,r=o.length;nde(e,((e,o)=>({k:o,v:t(e,o)}))),de=(e,t)=>{const o={};return le(e,((e,n)=>{const r=t(e,n);o[r.k]=r.v})),o},me=e=>(t,o)=>{e[o]=t},ue=(e,t,o,n)=>{le(e,((e,r)=>{(t(e,r)?o:n)(e,r)}))},ge=(e,t)=>{const o={};return ue(e,t,me(o),b),o},pe=(e,t)=>{const o=[];return le(e,((e,n)=>{o.push(t(e,n))})),o},he=(e,t)=>{const o=ae(e);for(let n=0,r=o.length;npe(e,x),be=(e,t)=>ve(e,t)?D.from(e[t]):D.none(),ve=(e,t)=>ie.call(e,t),ye=(e,t)=>ve(e,t)&&void 0!==e[t]&&null!==e[t],we=(e,t,o=C)=>e.exists((e=>o(e,t))),xe=e=>{const t=[],o=e=>{t.push(e)};for(let t=0;te.isSome()&&t.isSome()?D.some(o(e.getOrDie(),t.getOrDie())):D.none(),Se=(e,t)=>null!=e?D.some(t(e)):D.none(),ke=(e,t)=>e?D.some(t):D.none(),_e=(e,t,o)=>""===t||e.length>=t.length&&e.substr(o,o+t.length)===t,Oe=(e,t)=>Ee(e,t)?((e,t)=>e.substring(t))(e,t.length):e,Te=(e,t,o=0,n)=>{const r=e.indexOf(t,o);return-1!==r&&(!!m(n)||r+t.length<=n)},Ee=(e,t)=>_e(e,t,0),De=(e,t)=>_e(e,t,e.length-t.length),Ae=(e=>t=>t.replace(e,""))(/^\s+|\s+$/g),Me=e=>e.length>0,Ne=e=>void 0!==e.style&&p(e.style.getPropertyValue),Re=e=>{if(null==e)throw new Error("Node cannot be null or undefined");return{dom:e}},Be={fromHtml:(e,t)=>{const o=(t||document).createElement("div");if(o.innerHTML=e,!o.hasChildNodes()||o.childNodes.length>1){const t="HTML does not have a single root node";throw console.error(t,e),new Error(t)}return Re(o.childNodes[0])},fromTag:(e,t)=>{const o=(t||document).createElement(e);return Re(o)},fromText:(e,t)=>{const o=(t||document).createTextNode(e);return Re(o)},fromDom:Re,fromPoint:(e,t,o)=>D.from(e.dom.elementFromPoint(t,o)).map(Re)},Le="undefined"!=typeof window?window:Function("return this;")(),He=(e,t)=>((e,t)=>{let o=null!=t?t:Le;for(let t=0;t{const o=((e,t)=>He(e,t))(e,t);if(null==o)throw new Error(e+" not available on this browser");return o},Pe=Object.getPrototypeOf,Fe=e=>{const t=He("ownerDocument.defaultView",e);return a(e)&&((e=>Ie("HTMLElement",e))(t).prototype.isPrototypeOf(e)||/^HTML\w*Element$/.test(Pe(e).constructor.name))},ze=e=>e.dom.nodeName.toLowerCase(),Ve=e=>t=>(e=>e.dom.nodeType)(t)===e,Ze=e=>Ue(e)&&Fe(e.dom),Ue=Ve(1),je=Ve(3),$e=Ve(9),We=Ve(11),qe=e=>t=>Ue(t)&&ze(t)===e,Ge=(e,t)=>{const o=e.dom;if(1!==o.nodeType)return!1;{const e=o;if(void 0!==e.matches)return e.matches(t);if(void 0!==e.msMatchesSelector)return e.msMatchesSelector(t);if(void 0!==e.webkitMatchesSelector)return e.webkitMatchesSelector(t);if(void 0!==e.mozMatchesSelector)return e.mozMatchesSelector(t);throw new Error("Browser lacks native selectors")}},Ke=e=>1!==e.nodeType&&9!==e.nodeType&&11!==e.nodeType||0===e.childElementCount,Ye=(e,t)=>e.dom===t.dom,Xe=(e,t)=>{const o=e.dom,n=t.dom;return o!==n&&o.contains(n)},Je=e=>Be.fromDom(e.dom.ownerDocument),Qe=e=>$e(e)?e:Je(e),et=e=>Be.fromDom(Qe(e).dom.documentElement),tt=e=>Be.fromDom(Qe(e).dom.defaultView),ot=e=>D.from(e.dom.parentNode).map(Be.fromDom),nt=e=>D.from(e.dom.parentElement).map(Be.fromDom),rt=e=>D.from(e.dom.offsetParent).map(Be.fromDom),st=e=>F(e.dom.childNodes,Be.fromDom),at=(e,t)=>{const o=e.dom.childNodes;return D.from(o[t]).map(Be.fromDom)},it=e=>at(e,0),lt=(e,t)=>({element:e,offset:t}),ct=(e,t)=>{const o=st(e);return o.length>0&&tWe(e)&&g(e.dom.host),mt=p(Element.prototype.attachShadow)&&p(Node.prototype.getRootNode),ut=w(mt),gt=mt?e=>Be.fromDom(e.dom.getRootNode()):Qe,pt=e=>dt(e)?e:Be.fromDom(Qe(e).dom.body),ht=e=>{const t=gt(e);return dt(t)?D.some(t):D.none()},ft=e=>Be.fromDom(e.dom.host),bt=e=>g(e.dom.shadowRoot),vt=e=>{const t=je(e)?e.dom.parentNode:e.dom;if(null==t||null===t.ownerDocument)return!1;const o=t.ownerDocument;return ht(Be.fromDom(t)).fold((()=>o.body.contains(t)),(n=vt,r=ft,e=>n(r(e))));var n,r},yt=()=>wt(Be.fromDom(document)),wt=e=>{const t=e.dom.body;if(null==t)throw new Error("Body is not available yet");return Be.fromDom(t)},xt=(e,t,o)=>{if(!(s(o)||d(o)||h(o)))throw console.error("Invalid call to Attribute.set. Key ",t,":: Value ",o,":: Element ",e),new Error("Attribute value was not simple");e.setAttribute(t,o+"")},Ct=(e,t,o)=>{xt(e.dom,t,o)},St=(e,t)=>{const o=e.dom;le(t,((e,t)=>{xt(o,t,e)}))},kt=(e,t)=>{const o=e.dom.getAttribute(t);return null===o?void 0:o},_t=(e,t)=>D.from(kt(e,t)),Ot=(e,t)=>{const o=e.dom;return!(!o||!o.hasAttribute)&&o.hasAttribute(t)},Tt=(e,t)=>{e.dom.removeAttribute(t)},Et=(e,t,o)=>{if(!s(o))throw console.error("Invalid call to CSS.set. Property ",t,":: Value ",o,":: Element ",e),new Error("CSS value must be a string: "+o);Ne(e)&&e.style.setProperty(t,o)},Dt=(e,t)=>{Ne(e)&&e.style.removeProperty(t)},At=(e,t,o)=>{const n=e.dom;Et(n,t,o)},Mt=(e,t)=>{const o=e.dom;le(t,((e,t)=>{Et(o,t,e)}))},Nt=(e,t)=>{const o=e.dom;le(t,((e,t)=>{e.fold((()=>{Dt(o,t)}),(e=>{Et(o,t,e)}))}))},Rt=(e,t)=>{const o=e.dom,n=window.getComputedStyle(o).getPropertyValue(t);return""!==n||vt(e)?n:Bt(o,t)},Bt=(e,t)=>Ne(e)?e.style.getPropertyValue(t):"",Lt=(e,t)=>{const o=e.dom,n=Bt(o,t);return D.from(n).filter((e=>e.length>0))},Ht=e=>{const t={},o=e.dom;if(Ne(o))for(let e=0;e{const n=Be.fromTag(e);At(n,t,o);return Lt(n,t).isSome()},Pt=(e,t)=>{const o=e.dom;Dt(o,t),we(_t(e,"style").map(Ae),"")&&Tt(e,"style")},Ft=e=>e.dom.offsetWidth,zt=(e,t)=>{const o=o=>{const n=t(o);if(n<=0||null===n){const t=Rt(o,e);return parseFloat(t)||0}return n},n=(e,t)=>j(t,((t,o)=>{const n=Rt(e,o),r=void 0===n?0:parseInt(n,10);return isNaN(r)?t:t+r}),0);return{set:(t,o)=>{if(!h(o)&&!o.match(/^[0-9]+$/))throw new Error(e+".set accepts only positive integer values. Value was "+o);const n=t.dom;Ne(n)&&(n.style[e]=o+"px")},get:o,getOuter:o,aggregate:n,max:(e,t,o)=>{const r=n(e,o);return t>r?t-r:0}}},Vt=zt("height",(e=>{const t=e.dom;return vt(e)?t.getBoundingClientRect().height:t.offsetHeight})),Zt=e=>Vt.get(e),Ut=e=>Vt.getOuter(e),jt=(e,t)=>({left:e,top:t,translate:(o,n)=>jt(e+o,t+n)}),$t=jt,Wt=(e,t)=>void 0!==e?e:void 0!==t?t:0,qt=e=>{const t=e.dom.ownerDocument,o=t.body,n=t.defaultView,r=t.documentElement;if(o===e.dom)return $t(o.offsetLeft,o.offsetTop);const s=Wt(null==n?void 0:n.pageYOffset,r.scrollTop),a=Wt(null==n?void 0:n.pageXOffset,r.scrollLeft),i=Wt(r.clientTop,o.clientTop),l=Wt(r.clientLeft,o.clientLeft);return Gt(e).translate(a-l,s-i)},Gt=e=>{const t=e.dom,o=t.ownerDocument.body;return o===t?$t(o.offsetLeft,o.offsetTop):vt(e)?(e=>{const t=e.getBoundingClientRect();return $t(t.left,t.top)})(t):$t(0,0)},Kt=zt("width",(e=>e.dom.offsetWidth)),Yt=e=>Kt.get(e),Xt=e=>Kt.getOuter(e),Jt=e=>{let t,o=!1;return(...n)=>(o||(o=!0,t=e.apply(null,n)),t)},Qt=()=>eo(0,0),eo=(e,t)=>({major:e,minor:t}),to={nu:eo,detect:(e,t)=>{const o=String(t).toLowerCase();return 0===e.length?Qt():((e,t)=>{const o=((e,t)=>{for(let o=0;oNumber(t.replace(o,"$"+e));return eo(n(1),n(2))})(e,o)},unknown:Qt},oo=(e,t)=>{const o=String(t).toLowerCase();return $(e,(e=>e.search(o)))},no=/.*?version\/\ ?([0-9]+)\.([0-9]+).*/,ro=e=>t=>Te(t,e),so=[{name:"Edge",versionRegexes:[/.*?edge\/ ?([0-9]+)\.([0-9]+)$/],search:e=>Te(e,"edge/")&&Te(e,"chrome")&&Te(e,"safari")&&Te(e,"applewebkit")},{name:"Chromium",brand:"Chromium",versionRegexes:[/.*?chrome\/([0-9]+)\.([0-9]+).*/,no],search:e=>Te(e,"chrome")&&!Te(e,"chromeframe")},{name:"IE",versionRegexes:[/.*?msie\ ?([0-9]+)\.([0-9]+).*/,/.*?rv:([0-9]+)\.([0-9]+).*/],search:e=>Te(e,"msie")||Te(e,"trident")},{name:"Opera",versionRegexes:[no,/.*?opera\/([0-9]+)\.([0-9]+).*/],search:ro("opera")},{name:"Firefox",versionRegexes:[/.*?firefox\/\ ?([0-9]+)\.([0-9]+).*/],search:ro("firefox")},{name:"Safari",versionRegexes:[no,/.*?cpu os ([0-9]+)_([0-9]+).*/],search:e=>(Te(e,"safari")||Te(e,"mobile/"))&&Te(e,"applewebkit")}],ao=[{name:"Windows",search:ro("win"),versionRegexes:[/.*?windows\ nt\ ?([0-9]+)\.([0-9]+).*/]},{name:"iOS",search:e=>Te(e,"iphone")||Te(e,"ipad"),versionRegexes:[/.*?version\/\ ?([0-9]+)\.([0-9]+).*/,/.*cpu os ([0-9]+)_([0-9]+).*/,/.*cpu iphone os ([0-9]+)_([0-9]+).*/]},{name:"Android",search:ro("android"),versionRegexes:[/.*?android\ ?([0-9]+)\.([0-9]+).*/]},{name:"macOS",search:ro("mac os x"),versionRegexes:[/.*?mac\ os\ x\ ?([0-9]+)_([0-9]+).*/]},{name:"Linux",search:ro("linux"),versionRegexes:[]},{name:"Solaris",search:ro("sunos"),versionRegexes:[]},{name:"FreeBSD",search:ro("freebsd"),versionRegexes:[]},{name:"ChromeOS",search:ro("cros"),versionRegexes:[/.*?chrome\/([0-9]+)\.([0-9]+).*/]}],io={browsers:w(so),oses:w(ao)},lo="Edge",co="Chromium",mo="Opera",uo="Firefox",go="Safari",po=e=>{const t=e.current,o=e.version,n=e=>()=>t===e;return{current:t,version:o,isEdge:n(lo),isChromium:n(co),isIE:n("IE"),isOpera:n(mo),isFirefox:n(uo),isSafari:n(go)}},ho={unknown:()=>po({current:void 0,version:to.unknown()}),nu:po,edge:w(lo),chromium:w(co),ie:w("IE"),opera:w(mo),firefox:w(uo),safari:w(go)},fo="Windows",bo="Android",vo="Linux",yo="macOS",wo="Solaris",xo="FreeBSD",Co="ChromeOS",So=e=>{const t=e.current,o=e.version,n=e=>()=>t===e;return{current:t,version:o,isWindows:n(fo),isiOS:n("iOS"),isAndroid:n(bo),isMacOS:n(yo),isLinux:n(vo),isSolaris:n(wo),isFreeBSD:n(xo),isChromeOS:n(Co)}},ko={unknown:()=>So({current:void 0,version:to.unknown()}),nu:So,windows:w(fo),ios:w("iOS"),android:w(bo),linux:w(vo),macos:w(yo),solaris:w(wo),freebsd:w(xo),chromeos:w(Co)},_o=(e,t,o)=>{const n=io.browsers(),r=io.oses(),s=t.bind((e=>((e,t)=>se(t.brands,(t=>{const o=t.brand.toLowerCase();return $(e,(e=>{var t;return o===(null===(t=e.brand)||void 0===t?void 0:t.toLowerCase())})).map((e=>({current:e.name,version:to.nu(parseInt(t.version,10),0)})))})))(n,e))).orThunk((()=>((e,t)=>oo(e,t).map((e=>{const o=to.detect(e.versionRegexes,t);return{current:e.name,version:o}})))(n,e))).fold(ho.unknown,ho.nu),a=((e,t)=>oo(e,t).map((e=>{const o=to.detect(e.versionRegexes,t);return{current:e.name,version:o}})))(r,e).fold(ko.unknown,ko.nu),i=((e,t,o,n)=>{const r=e.isiOS()&&!0===/ipad/i.test(o),s=e.isiOS()&&!r,a=e.isiOS()||e.isAndroid(),i=a||n("(pointer:coarse)"),l=r||!s&&a&&n("(min-device-width:768px)"),c=s||a&&!l,d=t.isSafari()&&e.isiOS()&&!1===/safari/i.test(o),m=!c&&!l&&!d;return{isiPad:w(r),isiPhone:w(s),isTablet:w(l),isPhone:w(c),isTouch:w(i),isAndroid:e.isAndroid,isiOS:e.isiOS,isWebView:w(d),isDesktop:w(m)}})(a,s,e,o);return{browser:s,os:a,deviceType:i}},Oo=e=>window.matchMedia(e).matches;let To=Jt((()=>_o(navigator.userAgent,D.from(navigator.userAgentData),Oo)));const Eo=()=>To(),Do=e=>{const t=Be.fromDom((e=>{if(ut()&&g(e.target)){const t=Be.fromDom(e.target);if(Ue(t)&&bt(t)&&e.composed&&e.composedPath){const t=e.composedPath();if(t)return oe(t)}}return D.from(e.target)})(e).getOr(e.target)),o=()=>e.stopPropagation(),n=()=>e.preventDefault(),r=y(n,o);return((e,t,o,n,r,s,a)=>({target:e,x:t,y:o,stop:n,prevent:r,kill:s,raw:a}))(t,e.clientX,e.clientY,o,n,r,e)},Ao=(e,t,o,n,r)=>{const s=((e,t)=>o=>{e(o)&&t(Do(o))})(o,n);return e.dom.addEventListener(t,s,r),{unbind:S(Mo,e,t,s,r)}},Mo=(e,t,o,n)=>{e.dom.removeEventListener(t,o,n)},No=(e,t)=>{ot(e).each((o=>{o.dom.insertBefore(t.dom,e.dom)}))},Ro=(e,t)=>{const o=(e=>D.from(e.dom.nextSibling).map(Be.fromDom))(e);o.fold((()=>{ot(e).each((e=>{Lo(e,t)}))}),(e=>{No(e,t)}))},Bo=(e,t)=>{it(e).fold((()=>{Lo(e,t)}),(o=>{e.dom.insertBefore(t.dom,o.dom)}))},Lo=(e,t)=>{e.dom.appendChild(t.dom)},Ho=(e,t)=>{z(t,(t=>{Lo(e,t)}))},Io=e=>{e.dom.textContent="",z(st(e),(e=>{Po(e)}))},Po=e=>{const t=e.dom;null!==t.parentNode&&t.parentNode.removeChild(t)},Fo=e=>{const t=void 0!==e?e.dom:document,o=t.body.scrollLeft||t.documentElement.scrollLeft,n=t.body.scrollTop||t.documentElement.scrollTop;return $t(o,n)},zo=(e,t,o)=>{const n=(void 0!==o?o.dom:document).defaultView;n&&n.scrollTo(e,t)},Vo=(e,t,o,n)=>({x:e,y:t,width:o,height:n,right:e+o,bottom:t+n}),Zo=e=>{const t=void 0===e?window:e,o=t.document,n=Fo(Be.fromDom(o));return(e=>{const t=void 0===e?window:e;return Eo().browser.isFirefox()?D.none():D.from(t.visualViewport)})(t).fold((()=>{const e=t.document.documentElement,o=e.clientWidth,r=e.clientHeight;return Vo(n.left,n.top,o,r)}),(e=>Vo(Math.max(e.pageLeft,n.left),Math.max(e.pageTop,n.top),e.width,e.height)))},Uo=()=>Be.fromDom(document),jo=(e,t)=>e.view(t).fold(w([]),(t=>{const o=e.owner(t),n=jo(e,o);return[t].concat(n)}));var $o=Object.freeze({__proto__:null,view:e=>{var t;return(e.dom===document?D.none():D.from(null===(t=e.dom.defaultView)||void 0===t?void 0:t.frameElement)).map(Be.fromDom)},owner:e=>Je(e)});const Wo=e=>{const t=Uo(),o=Fo(t),n=((e,t)=>{const o=t.owner(e),n=jo(t,o);return D.some(n)})(e,$o);return n.fold(S(qt,e),(t=>{const n=Gt(e),r=U(t,((e,t)=>{const o=Gt(t);return{left:e.left+o.left,top:e.top+o.top}}),{left:0,top:0});return $t(r.left+n.left+o.left,r.top+n.top+o.top)}))},qo=(e,t,o,n)=>({x:e,y:t,width:o,height:n,right:e+o,bottom:t+n}),Go=e=>{const t=qt(e),o=Xt(e),n=Ut(e);return qo(t.left,t.top,o,n)},Ko=e=>{const t=Wo(e),o=Xt(e),n=Ut(e);return qo(t.left,t.top,o,n)},Yo=(e,t)=>{const o=Math.max(e.x,t.x),n=Math.max(e.y,t.y),r=Math.min(e.right,t.right),s=Math.min(e.bottom,t.bottom);return qo(o,n,r-o,s-n)},Xo=()=>Zo(window);var Jo=tinymce.util.Tools.resolve("tinymce.ThemeManager");const Qo=e=>{const t=t=>t(e),o=w(e),n=()=>r,r={tag:!0,inner:e,fold:(t,o)=>o(e),isValue:E,isError:T,map:t=>tn.value(t(e)),mapError:n,bind:t,exists:t,forall:t,getOr:o,or:n,getOrThunk:o,orThunk:n,getOrDie:o,each:t=>{t(e)},toOptional:()=>D.some(e)};return r},en=e=>{const t=()=>o,o={tag:!1,inner:e,fold:(t,o)=>t(e),isValue:T,isError:E,map:t,mapError:t=>tn.error(t(e)),bind:t,exists:T,forall:E,getOr:x,or:x,getOrThunk:O,orThunk:O,getOrDie:_(String(e)),each:b,toOptional:D.none};return o},tn={value:Qo,error:en,fromOption:(e,t)=>e.fold((()=>en(t)),Qo)};var on;!function(e){e[e.Error=0]="Error",e[e.Value=1]="Value"}(on||(on={}));const nn=(e,t,o)=>e.stype===on.Error?t(e.serror):o(e.svalue),rn=e=>({stype:on.Value,svalue:e}),sn=e=>({stype:on.Error,serror:e}),an=e=>e.fold(sn,rn),ln=e=>nn(e,tn.error,tn.value),cn=rn,dn=e=>{const t=[],o=[];return z(e,(e=>{nn(e,(e=>o.push(e)),(e=>t.push(e)))})),{values:t,errors:o}},mn=sn,un=(e,t)=>e.stype===on.Value?t(e.svalue):e,gn=(e,t)=>e.stype===on.Error?t(e.serror):e,pn=(e,t)=>e.stype===on.Value?{stype:on.Value,svalue:t(e.svalue)}:e,hn=(e,t)=>e.stype===on.Error?{stype:on.Error,serror:t(e.serror)}:e,fn=nn,bn=(e,t,o,n)=>({tag:"field",key:e,newKey:t,presence:o,prop:n}),vn=(e,t,o)=>{switch(e.tag){case"field":return t(e.key,e.newKey,e.presence,e.prop);case"custom":return o(e.newKey,e.instantiator)}},yn=e=>(...t)=>{if(0===t.length)throw new Error("Can't merge zero objects");const o={};for(let n=0;ni(e)&&i(t)?wn(e,t):t)),xn=yn(((e,t)=>t)),Cn=e=>({tag:"defaultedThunk",process:e}),Sn=e=>Cn(w(e)),kn=e=>({tag:"mergeWithThunk",process:e}),_n=e=>y(mn,q)(e),On=e=>{const t=dn(e);return t.errors.length>0?_n(t.errors):cn(t.values)},Tn=e=>a(e)&&ae(e).length>100?" removed due to size":JSON.stringify(e,null,2),En=(e,t)=>mn([{path:e,getErrorInfo:t}]),Dn=e=>({extract:(t,o)=>gn(e(o),(e=>((e,t)=>En(e,w(t)))(t,e))),toString:w("val")}),An=Dn(cn),Mn=(e,t,o,n)=>be(t,o).fold((()=>((e,t,o)=>En(e,(()=>'Could not find valid *required* value for "'+t+'" in '+Tn(o))))(e,o,t)),n),Nn=(e,t,o,n)=>n(be(e,t).getOrThunk((()=>o(e)))),Rn=(e,t,o,n,r)=>{const s=e=>r.extract(t.concat([n]),e),a=e=>e.fold((()=>cn(D.none())),(e=>{const o=r.extract(t.concat([n]),e);return pn(o,D.some)}));switch(e.tag){case"required":return Mn(t,o,n,s);case"defaultedThunk":return Nn(o,n,e.process,s);case"option":return((e,t,o)=>o(be(e,t)))(o,n,a);case"defaultedOptionThunk":return((e,t,o,n)=>n(be(e,t).map((t=>!0===t?o(e):t))))(o,n,e.process,a);case"mergeWithThunk":return Nn(o,n,w({}),(t=>{const n=wn(e.process(o),t);return s(n)}))}},Bn=e=>({extract:(t,o)=>e().extract(t,o),toString:()=>e().toString()}),Ln=e=>ae(ge(e,g)),Hn=e=>{const t=In(e),o=U(e,((e,t)=>vn(t,(t=>wn(e,{[t]:!0})),w(e))),{});return{extract:(e,n)=>{const r=d(n)?[]:Ln(n),s=Z(r,(e=>!ye(o,e)));return 0===s.length?t.extract(e,n):((e,t)=>En(e,(()=>"There are unsupported fields: ["+t.join(", ")+"] specified")))(e,s)},toString:t.toString}},In=e=>({extract:(t,o)=>((e,t,o)=>{const n={},r=[];for(const s of o)vn(s,((o,s,a,i)=>{const l=Rn(a,e,t,o,i);fn(l,(e=>{r.push(...e)}),(e=>{n[s]=e}))}),((e,o)=>{n[e]=o(t)}));return r.length>0?mn(r):cn(n)})(t,o,e),toString:()=>{const t=F(e,(e=>vn(e,((e,t,o,n)=>e+" -> "+n.toString()),((e,t)=>"state("+e+")"))));return"obj{\n"+t.join("\n")+"}"}}),Pn=e=>({extract:(t,o)=>{const n=F(o,((o,n)=>e.extract(t.concat(["["+n+"]"]),o)));return On(n)},toString:()=>"array("+e.toString()+")"}),Fn=(e,t)=>{const o=void 0!==t?t:x;return{extract:(t,n)=>{const r=[];for(const s of e){const e=s.extract(t,n);if(e.stype===on.Value)return{stype:on.Value,svalue:o(e.svalue)};r.push(e)}return On(r)},toString:()=>"oneOf("+F(e,(e=>e.toString())).join(", ")+")"}},zn=(e,t)=>({extract:(o,n)=>{const r=ae(n),s=((t,o)=>Pn(Dn(e)).extract(t,o))(o,r);return un(s,(e=>{const r=F(e,(e=>bn(e,e,{tag:"required",process:{}},t)));return In(r).extract(o,n)}))},toString:()=>"setOf("+t.toString()+")"}),Vn=y(Pn,In),Zn=w(An),Un=(e,t)=>Dn((o=>{const n=typeof o;return e(o)?cn(o):mn(`Expected type: ${t} but got: ${n}`)})),jn=Un(h,"number"),$n=Un(s,"string"),Wn=Un(d,"boolean"),qn=Un(p,"function"),Gn=e=>{if(Object(e)!==e)return!0;switch({}.toString.call(e).slice(8,-1)){case"Boolean":case"Number":case"String":case"Date":case"RegExp":case"Blob":case"FileList":case"ImageData":case"ImageBitmap":case"ArrayBuffer":return!0;case"Array":case"Object":return Object.keys(e).every((t=>Gn(e[t])));default:return!1}},Kn=Dn((e=>Gn(e)?cn(e):mn("Expected value to be acceptable for sending via postMessage"))),Yn=(e,t,o,n)=>be(o,n).fold((()=>((e,t,o)=>En(e,(()=>'The chosen schema: "'+o+'" did not exist in branches: '+Tn(t))))(e,o,n)),(o=>o.extract(e.concat(["branch: "+n]),t))),Xn=(e,t)=>({extract:(o,n)=>be(n,e).fold((()=>((e,t)=>En(e,(()=>'Choice schema did not contain choice key: "'+t+'"')))(o,e)),(e=>Yn(o,n,t,e))),toString:()=>"chooseOn("+e+"). Possible values: "+ae(t)}),Jn=e=>Dn((t=>e(t).fold(mn,cn))),Qn=(e,t)=>zn((t=>an(e(t))),t),er=(e,t,o)=>ln(((e,t,o)=>{const n=t.extract([e],o);return hn(n,(e=>({input:o,errors:e})))})(e,t,o)),tr=e=>e.fold((e=>{throw new Error(nr(e))}),x),or=(e,t,o)=>tr(er(e,t,o)),nr=e=>"Errors: \n"+(e=>{const t=e.length>10?e.slice(0,10).concat([{path:[],getErrorInfo:w("... (only showing first ten failures)")}]):e;return F(t,(e=>"Failed path: ("+e.path.join(" > ")+")\n"+e.getErrorInfo()))})(e.errors).join("\n")+"\n\nInput object: "+Tn(e.input),rr=(e,t)=>Xn(e,ce(t,In)),sr=(e,t)=>((e,t)=>{const o=Jt(t);return{extract:(e,t)=>o().extract(e,t),toString:()=>o().toString()}})(0,t),ar=bn,ir=(e,t)=>({tag:"custom",newKey:e,instantiator:t}),lr=e=>Jn((t=>L(e,t)?tn.value(t):tn.error(`Unsupported value: "${t}", choose one of "${e.join(", ")}".`))),cr=e=>ar(e,e,{tag:"required",process:{}},Zn()),dr=(e,t)=>ar(e,e,{tag:"required",process:{}},t),mr=e=>dr(e,jn),ur=e=>dr(e,$n),gr=(e,t)=>ar(e,e,{tag:"required",process:{}},lr(t)),pr=e=>dr(e,qn),hr=(e,t)=>ar(e,e,{tag:"required",process:{}},In(t)),fr=(e,t)=>ar(e,e,{tag:"required",process:{}},Vn(t)),br=(e,t)=>ar(e,e,{tag:"required",process:{}},Pn(t)),vr=e=>ar(e,e,{tag:"option",process:{}},Zn()),yr=(e,t)=>ar(e,e,{tag:"option",process:{}},t),wr=e=>yr(e,jn),xr=e=>yr(e,$n),Cr=(e,t)=>yr(e,lr(t)),Sr=e=>yr(e,qn),kr=(e,t)=>yr(e,Pn(t)),_r=(e,t)=>yr(e,In(t)),Or=(e,t)=>ar(e,e,Sn(t),Zn()),Tr=(e,t,o)=>ar(e,e,Sn(t),o),Er=(e,t)=>Tr(e,t,jn),Dr=(e,t)=>Tr(e,t,$n),Ar=(e,t,o)=>Tr(e,t,lr(o)),Mr=(e,t)=>Tr(e,t,Wn),Nr=(e,t)=>Tr(e,t,qn),Rr=(e,t,o)=>Tr(e,t,Pn(o)),Br=(e,t,o)=>Tr(e,t,In(o)),Lr=e=>{let t=e;return{get:()=>t,set:e=>{t=e}}},Hr=e=>{if(!l(e))throw new Error("cases must be an array");if(0===e.length)throw new Error("there must be at least one case");const t=[],o={};return z(e,((n,r)=>{const s=ae(n);if(1!==s.length)throw new Error("one and only one name per case");const a=s[0],i=n[a];if(void 0!==o[a])throw new Error("duplicate key detected:"+a);if("cata"===a)throw new Error("cannot have a case named cata (sorry)");if(!l(i))throw new Error("case arguments must be an array");t.push(a),o[a]=(...o)=>{const n=o.length;if(n!==i.length)throw new Error("Wrong number of arguments to case "+a+". Expected "+i.length+" ("+i+"), got "+n);return{fold:(...t)=>{if(t.length!==e.length)throw new Error("Wrong number of arguments to fold. Expected "+e.length+", got "+t.length);return t[r].apply(null,o)},match:e=>{const n=ae(e);if(t.length!==n.length)throw new Error("Wrong number of arguments to match. Expected: "+t.join(",")+"\nActual: "+n.join(","));if(!K(t,(e=>L(n,e))))throw new Error("Not all branches were specified when using match. Specified: "+n.join(", ")+"\nRequired: "+t.join(", "));return e[a].apply(null,o)},log:e=>{console.log(e,{constructors:t,constructor:a,params:o})}}}})),o};Hr([{bothErrors:["error1","error2"]},{firstError:["error1","value2"]},{secondError:["value1","error2"]},{bothValues:["value1","value2"]}]);const Ir=(e,t)=>((e,t)=>{const o={};return le(e,((e,n)=>{L(t,n)||(o[n]=e)})),o})(e,t),Pr=(e,t)=>((e,t)=>({[e]:t}))(e,t),Fr=e=>(e=>{const t={};return z(e,(e=>{t[e.key]=e.value})),t})(e),zr=(e,t)=>{const o=(e=>{const t=[],o=[];return z(e,(e=>{e.fold((e=>{t.push(e)}),(e=>{o.push(e)}))})),{errors:t,values:o}})(e);return o.errors.length>0?(n=o.errors,tn.error(q(n))):((e,t)=>0===e.length?tn.value(t):tn.value(wn(t,xn.apply(void 0,e))))(o.values,t);var n},Vr=e=>p(e)?e:T,Zr=(e,t,o)=>{let n=e.dom;const r=Vr(o);for(;n.parentNode;){n=n.parentNode;const e=Be.fromDom(n),o=t(e);if(o.isSome())return o;if(r(e))break}return D.none()},Ur=(e,t,o)=>{const n=t(e),r=Vr(o);return n.orThunk((()=>r(e)?D.none():Zr(e,t,r)))},jr=(e,t)=>Ye(e.element,t.event.target),$r={can:E,abort:T,run:b},Wr=e=>{if(!ye(e,"can")&&!ye(e,"abort")&&!ye(e,"run"))throw new Error("EventHandler defined by: "+JSON.stringify(e,null,2)+" does not have can, abort, or run!");return{...$r,...e}},qr=e=>{const t=((e,t)=>(...o)=>j(e,((e,n)=>e&&t(n).apply(void 0,o)),!0))(e,(e=>e.can)),o=((e,t)=>(...o)=>j(e,((e,n)=>e||t(n).apply(void 0,o)),!1))(e,(e=>e.abort));return{can:t,abort:o,run:(...t)=>{z(e,(e=>{e.run.apply(void 0,t)}))}}},Gr=w,Kr=Gr("touchstart"),Yr=Gr("touchmove"),Xr=Gr("touchend"),Jr=Gr("touchcancel"),Qr=Gr("mousedown"),es=Gr("mousemove"),ts=Gr("mouseout"),os=Gr("mouseup"),ns=Gr("mouseover"),rs=Gr("focusin"),ss=Gr("focusout"),as=Gr("keydown"),is=Gr("keyup"),ls=Gr("input"),cs=Gr("change"),ds=Gr("click"),ms=Gr("transitioncancel"),us=Gr("transitionend"),gs=Gr("transitionstart"),ps=Gr("selectstart"),hs=e=>w("alloy."+e),fs={tap:hs("tap")},bs=hs("focus"),vs=hs("blur.post"),ys=hs("paste.post"),ws=hs("receive"),xs=hs("execute"),Cs=hs("focus.item"),Ss=fs.tap,ks=hs("longpress"),_s=hs("sandbox.close"),Os=hs("typeahead.cancel"),Ts=hs("system.init"),Es=hs("system.touchmove"),Ds=hs("system.touchend"),As=hs("system.scroll"),Ms=hs("system.resize"),Ns=hs("system.attached"),Rs=hs("system.detached"),Bs=hs("system.dismissRequested"),Ls=hs("system.repositionRequested"),Hs=hs("focusmanager.shifted"),Is=hs("slotcontainer.visibility"),Ps=hs("system.external.element.scroll"),Fs=hs("change.tab"),zs=hs("dismiss.tab"),Vs=hs("highlight"),Zs=hs("dehighlight"),Us=(e,t)=>{qs(e,e.element,t,{})},js=(e,t,o)=>{qs(e,e.element,t,o)},$s=e=>{Us(e,xs())},Ws=(e,t,o)=>{qs(e,t,o,{})},qs=(e,t,o,n)=>{const r={target:t,...n};e.getSystem().triggerEvent(o,t,r)},Gs=(e,t,o,n)=>{e.getSystem().triggerEvent(o,t,n.event)},Ks=e=>Fr(e),Ys=(e,t)=>({key:e,value:Wr({abort:t})}),Xs=e=>({key:e,value:Wr({run:(e,t)=>{t.event.prevent()}})}),Js=(e,t)=>({key:e,value:Wr({run:t})}),Qs=(e,t,o)=>({key:e,value:Wr({run:(e,n)=>{t.apply(void 0,[e,n].concat(o))}})}),ea=e=>t=>({key:e,value:Wr({run:(e,o)=>{jr(e,o)&&t(e,o)}})}),ta=(e,t,o)=>((e,t)=>Js(e,((o,n)=>{o.getSystem().getByUid(t).each((t=>{Gs(t,t.element,e,n)}))})))(e,t.partUids[o]),oa=(e,t)=>Js(e,((e,o)=>{const n=o.event,r=e.getSystem().getByDom(n.target).getOrThunk((()=>Ur(n.target,(t=>e.getSystem().getByDom(t).toOptional()),T).getOr(e)));t(e,r,o)})),na=e=>Js(e,((e,t)=>{t.cut()})),ra=e=>Js(e,((e,t)=>{t.stop()})),sa=(e,t)=>ea(e)(t),aa=ea(Ns()),ia=ea(Rs()),la=ea(Ts()),ca=(e=>t=>Js(e,t))(xs()),da=e=>e.dom.innerHTML,ma=(e,t)=>{const o=Je(e).dom,n=Be.fromDom(o.createDocumentFragment()),r=((e,t)=>{const o=(t||document).createElement("div");return o.innerHTML=e,st(Be.fromDom(o))})(t,o);Ho(n,r),Io(e),Lo(e,n)},ua=e=>((e,t)=>Be.fromDom(e.dom.cloneNode(t)))(e,!1),ga=e=>{if(dt(e))return"#shadow-root";return(e=>{const t=Be.fromTag("div"),o=Be.fromDom(e.dom.cloneNode(!0));return Lo(t,o),da(t)})(ua(e))},pa=e=>ga(e),ha=Ks([((e,t)=>({key:e,value:Wr({can:t})}))(bs(),((e,t)=>{const o=t.event,n=o.originator,r=o.target;return!((e,t,o)=>Ye(t,e.element)&&!Ye(t,o))(e,n,r)||(console.warn(bs()+" did not get interpreted by the desired target. \nOriginator: "+pa(n)+"\nTarget: "+pa(r)+"\nCheck the "+bs()+" event handlers"),!1)}))]);var fa=Object.freeze({__proto__:null,events:ha});let ba=0;const va=e=>{const t=(new Date).getTime(),o=Math.floor(1e9*Math.random());return ba++,e+"_"+o+ba+String(t)},ya=w("alloy-id-"),wa=w("data-alloy-id"),xa=ya(),Ca=wa(),Sa=(e,t)=>{Object.defineProperty(e.dom,Ca,{value:t,writable:!0})},ka=e=>{const t=Ue(e)?e.dom[Ca]:null;return D.from(t)},_a=e=>va(e),Oa=x,Ta=e=>{const t=t=>`The component must be in a context to execute: ${t}`+(e?"\n"+pa(e().element)+" is not in context.":""),o=e=>()=>{throw new Error(t(e))},n=e=>()=>{console.warn(t(e))};return{debugInfo:w("fake"),triggerEvent:n("triggerEvent"),triggerFocus:n("triggerFocus"),triggerEscape:n("triggerEscape"),broadcast:n("broadcast"),broadcastOn:n("broadcastOn"),broadcastEvent:n("broadcastEvent"),build:o("build"),buildOrPatch:o("buildOrPatch"),addToWorld:o("addToWorld"),removeFromWorld:o("removeFromWorld"),addToGui:o("addToGui"),removeFromGui:o("removeFromGui"),getByUid:o("getByUid"),getByDom:o("getByDom"),isConnected:T}},Ea=Ta(),Da=e=>F(e,(e=>De(e,"/*")?e.substring(0,e.length-2):e)),Aa=(e,t)=>{const o=e.toString(),n=o.indexOf(")")+1,r=o.indexOf("("),s=o.substring(r+1,n-1).split(/,\s*/);return e.toFunctionAnnotation=()=>({name:t,parameters:Da(s)}),e},Ma=va("alloy-premade"),Na=e=>(Object.defineProperty(e.element.dom,Ma,{value:e.uid,writable:!0}),Pr(Ma,e)),Ra=e=>be(e,Ma),Ba=e=>((e,t)=>{const o=t.toString(),n=o.indexOf(")")+1,r=o.indexOf("("),s=o.substring(r+1,n-1).split(/,\s*/);return e.toFunctionAnnotation=()=>({name:"OVERRIDE",parameters:Da(s.slice(1))}),e})(((t,...o)=>e(t.getApis(),t,...o)),e),La={init:()=>Ha({readState:w("No State required")})},Ha=e=>e,Ia=(e,t)=>{const o={};return le(e,((e,n)=>{le(e,((e,r)=>{const s=be(o,r).getOr([]);o[r]=s.concat([t(n,e)])}))})),o},Pa=e=>({classes:m(e.classes)?[]:e.classes,attributes:m(e.attributes)?{}:e.attributes,styles:m(e.styles)?{}:e.styles}),Fa=e=>e.cHandler,za=(e,t)=>({name:e,handler:t}),Va=(e,t)=>{const o={};return z(e,(e=>{o[e.name()]=e.handlers(t)})),o},Za=(e,t,o,n)=>{const r=((e,t,o)=>{const n={...o,...Va(t,e)};return Ia(n,za)})(e,o,n);return $a(r,t)},Ua=e=>{const t=(e=>p(e)?{can:E,abort:T,run:e}:e)(e);return(e,o,...n)=>{const r=[e,o].concat(n);t.abort.apply(void 0,r)?o.stop():t.can.apply(void 0,r)&&t.run.apply(void 0,r)}},ja=(e,t,o)=>{const n=t[o];return n?((e,t,o,n)=>{try{const r=ee(o,((o,r)=>{const s=o[t],a=r[t],i=n.indexOf(s),l=n.indexOf(a);if(-1===i)throw new Error("The ordering for "+e+" does not have an entry for "+s+".\nOrder specified: "+JSON.stringify(n,null,2));if(-1===l)throw new Error("The ordering for "+e+" does not have an entry for "+a+".\nOrder specified: "+JSON.stringify(n,null,2));return i{const t=F(e,(e=>e.handler));return qr(t)})):((e,t)=>tn.error(["The event ("+e+') has more than one behaviour that listens to it.\nWhen this occurs, you must specify an event ordering for the behaviours in your spec (e.g. [ "listing", "toggling" ]).\nThe behaviours that can trigger it are: '+JSON.stringify(F(t,(e=>e.name)),null,2)]))(o,e)},$a=(e,t)=>{const o=pe(e,((e,o)=>(1===e.length?tn.value(e[0].handler):ja(e,t,o)).map((n=>{const r=Ua(n),s=e.length>1?Z(t[o],(t=>H(e,(e=>e.name===t)))).join(" > "):e[0].name;return Pr(o,((e,t)=>({handler:e,purpose:t}))(r,s))}))));return zr(o,{})},Wa="alloy.base.behaviour",qa=In([ar("dom","dom",{tag:"required",process:{}},In([cr("tag"),Or("styles",{}),Or("classes",[]),Or("attributes",{}),vr("value"),vr("innerHtml")])),cr("components"),cr("uid"),Or("events",{}),Or("apis",{}),ar("eventOrder","eventOrder",(e=>kn(w(e)))({[xs()]:["disabling",Wa,"toggling","typeaheadevents"],[bs()]:[Wa,"focusing","keying"],[Ts()]:[Wa,"disabling","toggling","representing"],[ls()]:[Wa,"representing","streaming","invalidating"],[Rs()]:[Wa,"representing","item-events","tooltipping"],[Qr()]:["focusing",Wa,"item-type-events"],[Kr()]:["focusing",Wa,"item-type-events"],[ns()]:["item-type-events","tooltipping"],[ws()]:["receiving","reflecting","tooltipping"]}),Zn()),vr("domModification")]),Ga=e=>e.events,Ka=(e,t)=>{const o=kt(e,t);return void 0===o||""===o?[]:o.split(" ")},Ya=e=>void 0!==e.dom.classList,Xa=e=>Ka(e,"class"),Ja=(e,t)=>((e,t,o)=>{const n=Ka(e,t).concat([o]);return Ct(e,t,n.join(" ")),!0})(e,"class",t),Qa=(e,t)=>((e,t,o)=>{const n=Z(Ka(e,t),(e=>e!==o));return n.length>0?Ct(e,t,n.join(" ")):Tt(e,t),!1})(e,"class",t),ei=(e,t)=>{Ya(e)?e.dom.classList.add(t):Ja(e,t)},ti=(e,t)=>{if(Ya(e)){e.dom.classList.remove(t)}else Qa(e,t);(e=>{0===(Ya(e)?e.dom.classList:Xa(e)).length&&Tt(e,"class")})(e)},oi=(e,t)=>Ya(e)&&e.dom.classList.contains(t),ni=(e,t)=>{z(t,(t=>{ei(e,t)}))},ri=(e,t)=>{z(t,(t=>{ti(e,t)}))},si=(e,t)=>K(t,(t=>oi(e,t))),ai=e=>Ya(e)?(e=>{const t=e.dom.classList,o=new Array(t.length);for(let e=0;ee.dom.value,li=(e,t)=>{if(void 0===t)throw new Error("Value.set was undefined");e.dom.value=t},ci=(e,t,o)=>{o.fold((()=>Lo(e,t)),(e=>{Ye(e,t)||(No(e,t),Po(e))}))},di=(e,t,o)=>{const n=F(t,o),r=st(e);return z(r.slice(n.length),Po),n},mi=(e,t,o,n)=>{const r=at(e,t),s=n(o,r),a=((e,t,o)=>at(e,t).map((e=>{if(o.exists((t=>!Ye(t,e)))){const t=o.map(ze).getOr("span"),n=Be.fromTag(t);return No(e,n),n}return e})))(e,t,r);return ci(e,s.element,a),s},ui=(e,t)=>{const o=ae(e),n=ae(t),r=X(n,o),s=((e,t)=>{const o={},n={};return ue(e,t,me(o),me(n)),{t:o,f:n}})(e,((e,o)=>!ve(t,o)||e!==t[o])).t;return{toRemove:r,toSet:s}},gi=(e,t)=>{const{class:o,style:n,...r}=(e=>j(e.dom.attributes,((e,t)=>(e[t.name]=t.value,e)),{}))(t),{toSet:s,toRemove:a}=ui(e.attributes,r),i=Ht(t),{toSet:l,toRemove:c}=ui(e.styles,i),d=ai(t),m=X(d,e.classes),u=X(e.classes,d);return z(a,(e=>Tt(t,e))),St(t,s),ni(t,u),ri(t,m),z(c,(e=>Pt(t,e))),Mt(t,l),e.innerHtml.fold((()=>{const o=e.domChildren;((e,t)=>{di(e,t,((t,o)=>{const n=at(e,o);return ci(e,t,n),t}))})(t,o)}),(e=>{ma(t,e)})),(()=>{const o=t,n=e.value.getOrUndefined();n!==ii(o)&&li(o,null!=n?n:"")})(),t},pi=(e,t)=>{const o=t.filter((t=>ze(t)===e.tag&&!(e=>e.innerHtml.isSome()&&e.domChildren.length>0)(e)&&!(e=>ve(e.dom,Ma))(t))).bind((t=>((e,t)=>{try{const o=gi(e,t);return D.some(o)}catch(e){return D.none()}})(e,t))).getOrThunk((()=>(e=>{const t=Be.fromTag(e.tag);St(t,e.attributes),ni(t,e.classes),Mt(t,e.styles),e.innerHtml.each((e=>ma(t,e)));const o=e.domChildren;return Ho(t,o),e.value.each((e=>{li(t,e)})),t})(e)));return Sa(o,e.uid),o},hi=(e,t)=>((e,t)=>{const o=F(t,(e=>_r(e.name(),[cr("config"),Or("state",La)]))),n=er("component.behaviours",In(o),e.behaviours).fold((t=>{throw new Error(nr(t)+"\nComplete spec:\n"+JSON.stringify(e,null,2))}),x);return{list:t,data:ce(n,(e=>{const t=e.map((e=>({config:e.config,state:e.state.init(e.config)})));return w(t)}))}})(e,t),fi=e=>{const t=(e=>{const t=be(e,"behaviours").getOr({});return G(ae(t),(e=>{const o=t[e];return g(o)?[o.me]:[]}))})(e);return hi(e,t)},bi=(e,t,o)=>{const n={...(r=e).dom,uid:r.uid,domChildren:F(r.components,(e=>e.element))};var r;const s=(e=>e.domModification.fold((()=>Pa({})),Pa))(e),a={"alloy.base.modification":s},i=t.length>0?((e,t,o,n)=>{const r={...t};z(o,(t=>{r[t.name()]=t.exhibit(e,n)}));const s=Ia(r,((e,t)=>({name:e,modification:t}))),a=e=>U(e,((e,t)=>({...t.modification,...e})),{}),i=U(s.classes,((e,t)=>t.modification.concat(e)),[]),l=a(s.attributes),c=a(s.styles);return Pa({classes:i,attributes:l,styles:c})})(o,a,t,n):s;return l=n,c=i,{...l,attributes:{...l.attributes,...c.attributes},styles:{...l.styles,...c.styles},classes:l.classes.concat(c.classes)};var l,c},vi=(e,t)=>{const o=()=>u,n=Lr(Ea),r=tr((e=>er("custom.definition",qa,e))(e)),s=fi(e),a=(e=>e.list)(s),i=(e=>e.data)(s),l=bi(r,a,i),c=pi(l,t),d=((e,t,o)=>{const n={"alloy.base.behaviour":Ga(e)};return Za(o,e.eventOrder,t,n).getOrDie()})(r,a,i),m=Lr(r.components),u={uid:e.uid,getSystem:n.get,config:t=>{const o=i;return(p(o[t.name()])?o[t.name()]:()=>{throw new Error("Could not find "+t.name()+" in "+JSON.stringify(e,null,2))})()},hasConfigured:e=>p(i[e.name()]),spec:e,readState:e=>i[e]().map((e=>e.state.readState())).getOr("not enabled"),getApis:()=>r.apis,connect:e=>{n.set(e)},disconnect:()=>{n.set(Ta(o))},element:c,syncComponents:()=>{const e=st(c),t=G(e,(e=>n.get().getByDom(e).fold((()=>[]),Q)));m.set(t)},components:m.get,events:d};return u},yi=(e,t)=>{const{events:o,...n}=Oa(e),r=((e,t)=>{const o=be(e,"components").getOr([]);return t.fold((()=>F(o,ki)),(e=>F(o,((t,o)=>Si(t,at(e,o))))))})(n,t),s={...n,events:{...fa,...o},components:r};return tn.value(vi(s,t))},wi=e=>{const t=Be.fromText(e);return xi({element:t})},xi=e=>{const t=or("external.component",Hn([cr("element"),vr("uid")]),e),o=Lr(Ta()),n=t.uid.getOrThunk((()=>_a("external")));Sa(t.element,n);const r={uid:n,getSystem:o.get,config:D.none,hasConfigured:T,connect:e=>{o.set(e)},disconnect:()=>{o.set(Ta((()=>r)))},getApis:()=>({}),element:t.element,spec:e,readState:w("No state"),syncComponents:b,components:w([]),events:{}};return Na(r)},Ci=_a,Si=(e,t)=>Ra(e).getOrThunk((()=>{const o=(e=>ve(e,"uid"))(e)?e:{uid:Ci(""),...e};return yi(o,t).getOrDie()})),ki=e=>Si(e,D.none()),_i=Na;var Oi=(e,t,o,n,r)=>e(o,n)?D.some(o):p(r)&&r(o)?D.none():t(o,n,r);const Ti=(e,t,o)=>{let n=e.dom;const r=p(o)?o:T;for(;n.parentNode;){n=n.parentNode;const e=Be.fromDom(n);if(t(e))return D.some(e);if(r(e))break}return D.none()},Ei=(e,t,o)=>Oi(((e,t)=>t(e)),Ti,e,t,o),Di=(e,t,o)=>Ei(e,t,o).isSome(),Ai=(e,t,o)=>Ti(e,(e=>Ge(e,t)),o),Mi=(e,t)=>((e,t)=>$(e.dom.childNodes,(e=>t(Be.fromDom(e)))).map(Be.fromDom))(e,(e=>Ge(e,t))),Ni=(e,t)=>((e,t)=>{const o=void 0===t?document:t.dom;return Ke(o)?D.none():D.from(o.querySelector(e)).map(Be.fromDom)})(t,e),Ri=(e,t,o)=>Oi(((e,t)=>Ge(e,t)),Ai,e,t,o),Bi="aria-controls",Li=()=>{const e=va(Bi);return{id:e,link:t=>{Ct(t,Bi,e)},unlink:e=>{Tt(e,Bi)}}},Hi=(e,t)=>(e=>Ei(e,(e=>{if(!Ue(e))return!1;const t=kt(e,"id");return void 0!==t&&t.indexOf(Bi)>-1})).bind((e=>{const t=kt(e,"id"),o=gt(e);return Ni(o,`[${Bi}="${t}"]`)})))(t).exists((t=>Ii(e,t))),Ii=(e,t)=>Di(t,(t=>Ye(t,e.element)),T)||Hi(e,t),Pi="unknown";var Fi;!function(e){e[e.STOP=0]="STOP",e[e.NORMAL=1]="NORMAL",e[e.LOGGING=2]="LOGGING"}(Fi||(Fi={}));const zi=Lr({}),Vi=(e,t,o)=>{switch(be(zi.get(),e).orThunk((()=>{const t=ae(zi.get());return se(t,(t=>e.indexOf(t)>-1?D.some(zi.get()[t]):D.none()))})).getOr(Fi.NORMAL)){case Fi.NORMAL:return o(ji());case Fi.LOGGING:{const n=((e,t)=>{const o=[],n=(new Date).getTime();return{logEventCut:(e,t,n)=>{o.push({outcome:"cut",target:t,purpose:n})},logEventStopped:(e,t,n)=>{o.push({outcome:"stopped",target:t,purpose:n})},logNoParent:(e,t,n)=>{o.push({outcome:"no-parent",target:t,purpose:n})},logEventNoHandlers:(e,t)=>{o.push({outcome:"no-handlers-left",target:t})},logEventResponse:(e,t,n)=>{o.push({outcome:"response",purpose:n,target:t})},write:()=>{const r=(new Date).getTime();L(["mousemove","mouseover","mouseout",Ts()],e)||console.log(e,{event:e,time:r-n,target:t.dom,sequence:F(o,(e=>L(["cut","stopped","response"],e.outcome)?"{"+e.purpose+"} "+e.outcome+" at ("+pa(e.target)+")":e.outcome))})}}})(e,t),r=o(n);return n.write(),r}case Fi.STOP:return!0}},Zi=["alloy/data/Fields","alloy/debugging/Debugging"],Ui=(e,t,o)=>Vi(e,t,o),ji=w({logEventCut:b,logEventStopped:b,logNoParent:b,logEventNoHandlers:b,logEventResponse:b,write:b}),$i=w([cr("menu"),cr("selectedMenu")]),Wi=w([cr("item"),cr("selectedItem")]);w(In(Wi().concat($i())));const qi=w(In(Wi())),Gi=hr("initSize",[cr("numColumns"),cr("numRows")]),Ki=()=>hr("markers",[cr("backgroundMenu")].concat($i()).concat(Wi())),Yi=e=>hr("markers",F(e,cr)),Xi=(e,t,o)=>((()=>{const e=new Error;if(void 0!==e.stack){const t=e.stack.split("\n");return $(t,(e=>e.indexOf("alloy")>0&&!H(Zi,(t=>e.indexOf(t)>-1)))).getOr(Pi)}})(),ar(t,t,o,Jn((e=>tn.value(((...t)=>e.apply(void 0,t))))))),Ji=e=>Xi(0,e,Sn(b)),Qi=e=>Xi(0,e,Sn(D.none)),el=e=>Xi(0,e,{tag:"required",process:{}}),tl=e=>Xi(0,e,{tag:"required",process:{}}),ol=(e,t)=>ir(e,w(t)),nl=e=>ir(e,x),rl=w(Gi),sl=(e,t,o,n,r,s,a,i=!1)=>({x:e,y:t,bubble:o,direction:n,placement:r,restriction:s,label:`${a}-${r}`,alwaysFit:i}),al=Hr([{southeast:[]},{southwest:[]},{northeast:[]},{northwest:[]},{south:[]},{north:[]},{east:[]},{west:[]}]),il=al.southeast,ll=al.southwest,cl=al.northeast,dl=al.northwest,ml=al.south,ul=al.north,gl=al.east,pl=al.west,hl=(e,t,o,n)=>{const r=e+t;return r>n?o:rMath.min(Math.max(e,t),o),bl=(e,t)=>J(["left","right","top","bottom"],(o=>be(t,o).map((t=>((e,t)=>{switch(t){case 1:return e.x;case 0:return e.x+e.width;case 2:return e.y;case 3:return e.y+e.height}})(e,t))))),vl="layout",yl=e=>e.x,wl=(e,t)=>e.x+e.width/2-t.width/2,xl=(e,t)=>e.x+e.width-t.width,Cl=(e,t)=>e.y-t.height,Sl=e=>e.y+e.height,kl=(e,t)=>e.y+e.height/2-t.height/2,_l=(e,t,o)=>sl(yl(e),Sl(e),o.southeast(),il(),"southeast",bl(e,{left:1,top:3}),vl),Ol=(e,t,o)=>sl(xl(e,t),Sl(e),o.southwest(),ll(),"southwest",bl(e,{right:0,top:3}),vl),Tl=(e,t,o)=>sl(yl(e),Cl(e,t),o.northeast(),cl(),"northeast",bl(e,{left:1,bottom:2}),vl),El=(e,t,o)=>sl(xl(e,t),Cl(e,t),o.northwest(),dl(),"northwest",bl(e,{right:0,bottom:2}),vl),Dl=(e,t,o)=>sl(wl(e,t),Cl(e,t),o.north(),ul(),"north",bl(e,{bottom:2}),vl),Al=(e,t,o)=>sl(wl(e,t),Sl(e),o.south(),ml(),"south",bl(e,{top:3}),vl),Ml=(e,t,o)=>sl((e=>e.x+e.width)(e),kl(e,t),o.east(),gl(),"east",bl(e,{left:0}),vl),Nl=(e,t,o)=>sl(((e,t)=>e.x-t.width)(e,t),kl(e,t),o.west(),pl(),"west",bl(e,{right:1}),vl),Rl=()=>[_l,Ol,Tl,El,Al,Dl,Ml,Nl],Bl=()=>[Ol,_l,El,Tl,Al,Dl,Ml,Nl],Ll=()=>[Tl,El,_l,Ol,Dl,Al],Hl=()=>[El,Tl,Ol,_l,Dl,Al],Il=()=>[_l,Ol,Tl,El,Al,Dl],Pl=()=>[Ol,_l,El,Tl,Al,Dl];var Fl=Object.freeze({__proto__:null,events:e=>Ks([Js(ws(),((t,o)=>{const n=e.channels,r=ae(n),s=o,a=((e,t)=>t.universal?e:Z(e,(e=>L(t.channels,e))))(r,s);z(a,(e=>{const o=n[e],r=o.schema,a=or("channel["+e+"] data\nReceiver: "+pa(t.element),r,s.data);o.onReceive(t,a)}))}))])}),zl=[dr("channels",Qn(tn.value,Hn([el("onReceive"),Or("schema",Zn())])))];const Vl=(e,t,o)=>la(((n,r)=>{o(n,e,t)})),Zl=(e,t,o)=>((e,t,o)=>{const n=o.toString(),r=n.indexOf(")")+1,s=n.indexOf("("),a=n.substring(s+1,r-1).split(/,\s*/);return e.toFunctionAnnotation=()=>({name:t,parameters:Da(a.slice(0,1).concat(a.slice(3)))}),e})(((n,...r)=>{const s=[n].concat(r);return n.config({name:w(e)}).fold((()=>{throw new Error("We could not find any behaviour configuration for: "+e+". Using API: "+o)}),(e=>{const o=Array.prototype.slice.call(s,1);return t.apply(void 0,[n,e.config,e.state].concat(o))}))}),o,t),Ul=e=>({key:e,value:void 0}),jl=(e,t,o,n,r,s,a)=>{const i=e=>ye(e,o)?e[o]():D.none(),l=ce(r,((e,t)=>Zl(o,e,t))),c={...ce(s,((e,t)=>Aa(e,t))),...l,revoke:S(Ul,o),config:t=>{const n=or(o+"-config",e,t);return{key:o,value:{config:n,me:c,configAsRaw:Jt((()=>or(o+"-config",e,t))),initialConfig:t,state:a}}},schema:w(t),exhibit:(e,t)=>Ce(i(e),be(n,"exhibit"),((e,o)=>o(t,e.config,e.state))).getOrThunk((()=>Pa({}))),name:w(o),handlers:e=>i(e).map((e=>be(n,"events").getOr((()=>({})))(e.config,e.state))).getOr({})};return c},$l=e=>Fr(e),Wl=Hn([cr("fields"),cr("name"),Or("active",{}),Or("apis",{}),Or("state",La),Or("extra",{})]),ql=e=>{const t=or("Creating behaviour: "+e.name,Wl,e);return((e,t,o,n,r,s)=>{const a=Hn(e),i=_r(t,[(l="config",c=e,yr(l,Hn(c)))]);var l,c;return jl(a,i,t,o,n,r,s)})(t.fields,t.name,t.active,t.apis,t.extra,t.state)},Gl=Hn([cr("branchKey"),cr("branches"),cr("name"),Or("active",{}),Or("apis",{}),Or("state",La),Or("extra",{})]),Kl=e=>{const t=or("Creating behaviour: "+e.name,Gl,e);return((e,t,o,n,r,s)=>{const a=e,i=_r(t,[yr("config",e)]);return jl(a,i,t,o,n,r,s)})(rr(t.branchKey,t.branches),t.name,t.active,t.apis,t.extra,t.state)},Yl=w(void 0),Xl=ql({fields:zl,name:"receiving",active:Fl});var Jl=Object.freeze({__proto__:null,exhibit:(e,t)=>Pa({classes:[],styles:t.useFixed()?{}:{position:"relative"}})});const Ql=e=>e.dom.focus(),ec=e=>e.dom.blur(),tc=e=>{const t=gt(e).dom;return e.dom===t.activeElement},oc=(e=Uo())=>D.from(e.dom.activeElement).map(Be.fromDom),nc=e=>oc(gt(e)).filter((t=>e.dom.contains(t.dom))),rc=(e,t)=>{const o=gt(t),n=oc(o).bind((e=>{const o=t=>Ye(e,t);return o(t)?D.some(t):((e,t)=>{const o=e=>{for(let n=0;n{oc(o).filter((t=>Ye(t,e))).fold((()=>{Ql(e)}),b)})),r},sc=(e,t,o,n,r)=>{const s=e=>e+"px";return{position:e,left:t.map(s),top:o.map(s),right:n.map(s),bottom:r.map(s)}},ac=(e,t)=>{Nt(e,(e=>({...e,position:D.some(e.position)}))(t))},ic=Hr([{none:[]},{relative:["x","y","width","height"]},{fixed:["x","y","width","height"]}]),lc=(e,t,o,n,r,s)=>{const a=t.rect,i=a.x-o,l=a.y-n,c=r-(i+a.width),d=s-(l+a.height),m=D.some(i),u=D.some(l),g=D.some(c),p=D.some(d),h=D.none();return((e,t,o,n,r,s,a,i,l)=>e.fold(t,o,n,r,s,a,i,l))(t.direction,(()=>sc(e,m,u,h,h)),(()=>sc(e,h,u,g,h)),(()=>sc(e,m,h,h,p)),(()=>sc(e,h,h,g,p)),(()=>sc(e,m,u,h,h)),(()=>sc(e,m,h,h,p)),(()=>sc(e,m,u,h,h)),(()=>sc(e,h,u,g,h)))},cc=(e,t)=>e.fold((()=>{const e=t.rect;return sc("absolute",D.some(e.x),D.some(e.y),D.none(),D.none())}),((e,o,n,r)=>lc("absolute",t,e,o,n,r)),((e,o,n,r)=>lc("fixed",t,e,o,n,r))),dc=(e,t)=>{const o=S(Wo,t),n=e.fold(o,o,(()=>{const e=Fo();return Wo(t).translate(-e.left,-e.top)})),r=Xt(t),s=Ut(t);return qo(n.left,n.top,r,s)},mc=(e,t)=>t.fold((()=>e.fold(Xo,Xo,qo)),(t=>e.fold(w(t),w(t),(()=>{const o=uc(e,t.x,t.y);return qo(o.left,o.top,t.width,t.height)})))),uc=(e,t,o)=>{const n=$t(t,o);return e.fold(w(n),w(n),(()=>{const e=Fo();return n.translate(-e.left,-e.top)}))};ic.none;const gc=ic.relative,pc=ic.fixed,hc=(e,t)=>((e,t)=>({anchorBox:e,origin:t}))(e,t),fc="data-alloy-placement",bc=e=>_t(e,fc),vc=Hr([{fit:["reposition"]},{nofit:["reposition","visibleW","visibleH","isVisible"]}]),yc=(e,t,o,n)=>{const r=e.bubble,s=r.offset,a=((e,t,o)=>{const n=(n,r)=>t[n].map((t=>{const s="top"===n||"bottom"===n,a=s?o.top:o.left,i=("left"===n||"top"===n?Math.max:Math.min)(t,r)+a;return s?fl(i,e.y,e.bottom):fl(i,e.x,e.right)})).getOr(r),r=n("left",e.x),s=n("top",e.y),a=n("right",e.right),i=n("bottom",e.bottom);return qo(r,s,a-r,i-s)})(n,e.restriction,s),i=e.x+s.left,l=e.y+s.top,c=qo(i,l,t,o),{originInBounds:d,sizeInBounds:m,visibleW:u,visibleH:g}=((e,t)=>{const{x:o,y:n,right:r,bottom:s}=t,{x:a,y:i,right:l,bottom:c,width:d,height:m}=e;return{originInBounds:a>=o&&a<=r&&i>=n&&i<=s,sizeInBounds:l<=r&&l>=o&&c<=s&&c>=n,visibleW:Math.min(d,a>=o?r-a:l-o),visibleH:Math.min(m,i>=n?s-i:c-n)}})(c,a),p=d&&m,h=p?c:((e,t)=>{const{x:o,y:n,right:r,bottom:s}=t,{x:a,y:i,width:l,height:c}=e,d=Math.max(o,r-l),m=Math.max(n,s-c),u=fl(a,o,d),g=fl(i,n,m),p=Math.min(u+l,r)-u,h=Math.min(g+c,s)-g;return qo(u,g,p,h)})(c,a),f=h.width>0&&h.height>0,{maxWidth:b,maxHeight:v}=((e,t,o)=>{const n=w(t.bottom-o.y),r=w(o.bottom-t.y),s=((e,t,o,n)=>e.fold(t,t,n,n,t,n,o,o))(e,r,r,n),a=w(t.right-o.x),i=w(o.right-t.x),l=((e,t,o,n)=>e.fold(t,n,t,n,o,o,t,n))(e,i,i,a);return{maxWidth:l,maxHeight:s}})(e.direction,h,n),y={rect:h,maxHeight:v,maxWidth:b,direction:e.direction,placement:e.placement,classes:{on:r.classesOn,off:r.classesOff},layout:e.label,testY:l};return p||e.alwaysFit?vc.fit(y):vc.nofit(y,u,g,f)},wc=e=>{const t=Lr(D.none()),o=()=>t.get().each(e);return{clear:()=>{o(),t.set(D.none())},isSet:()=>t.get().isSome(),get:()=>t.get(),set:e=>{o(),t.set(D.some(e))}}},xc=()=>wc((e=>e.unbind())),Cc=()=>{const e=wc(b);return{...e,on:t=>e.get().each(t)}},Sc=E,kc=(e,t,o)=>((e,t,o,n)=>Ao(e,t,o,n,!1))(e,t,Sc,o),_c=(e,t,o)=>((e,t,o,n)=>Ao(e,t,o,n,!0))(e,t,Sc,o),Oc=Do,Tc=["top","bottom","right","left"],Ec="data-alloy-transition-timer",Dc=(e,t)=>{const o=e=>parseFloat(e).toFixed(3);return he(t,((t,n)=>!((e,t,o=C)=>Ce(e,t,o).getOr(e.isNone()&&t.isNone()))(e[n].map(o),t.map(o)))).isSome()},Ac=(e,t)=>{const o=xc(),n=xc();let r;const a=t=>{var o;const n=null!==(o=t.raw.pseudoElement)&&void 0!==o?o:"";return Ye(t.target,e)&&!Me(n)&&L(Tc,t.raw.propertyName)},i=s=>{if(u(s)||a(s)){o.clear(),n.clear();const a=null==s?void 0:s.raw.type;(u(a)||a===us())&&(clearTimeout(r),Tt(e,Ec),ri(e,t.classes))}},l=kc(e,gs(),(t=>{a(t)&&(l.unbind(),o.set(kc(e,us(),i)),n.set(kc(e,ms(),i)))})),c=(e=>{const t=t=>{const o=Rt(e,t).split(/\s*,\s*/);return Z(o,Me)},o=e=>{if(s(e)&&/^[\d.]+/.test(e)){const t=parseFloat(e);return De(e,"ms")?t:1e3*t}return 0},n=t("transition-delay"),r=t("transition-duration");return j(r,((e,t,r)=>{const s=o(n[r])+o(t);return Math.max(e,s)}),0)})(e);requestAnimationFrame((()=>{r=setTimeout(i,c+17),Ct(e,Ec,r)}))},Mc=(e,t,o,n,r,s)=>{const a=((e,t,o)=>o.exists((o=>{const n=e.mode;return"all"===n||o[n]!==t[n]})))(n,r,s);if(a||((e,t)=>si(e,t.classes))(e,n)){At(e,"position",o.position);const s=dc(t,e),i=cc(t,{...r,rect:s}),l=J(Tc,(e=>i[e]));Dc(o,l)&&(Nt(e,l),a&&((e,t)=>{ni(e,t.classes),_t(e,Ec).each((t=>{clearTimeout(parseInt(t,10)),Tt(e,Ec)})),Ac(e,t)})(e,n),Ft(e))}else ri(e,n.classes)},Nc=(e,t,o,n)=>{Pt(t,"max-height"),Pt(t,"max-width");const r={width:Xt(s=t),height:Ut(s)};var s;return((e,t,o,n,r,s)=>{const a=n.width,i=n.height,l=(t,l,c,d,m)=>{const u=t(o,n,r,e,s),g=yc(u,a,i,s);return g.fold(w(g),((e,t,o,n)=>(m===n?o>d||t>c:!m&&n)?g:vc.nofit(l,c,d,m)))},c=j(t,((e,t)=>{const o=S(l,t);return e.fold(w(e),o)}),vc.nofit({rect:o,maxHeight:n.height,maxWidth:n.width,direction:il(),placement:"southeast",classes:{on:[],off:[]},layout:"none",testY:o.y},-1,-1,!1));return c.fold(x,x)})(t,n.preference,e,r,o,n.bounds)},Rc=(e,t)=>{((e,t)=>{Ct(e,fc,t)})(e,t.placement)},Bc=(e,t)=>{((e,t)=>{const o=Vt.max(e,t,["margin-top","border-top-width","padding-top","padding-bottom","border-bottom-width","margin-bottom"]);At(e,"max-height",o+"px")})(e,Math.floor(t))},Lc=w(((e,t)=>{Bc(e,t),Mt(e,{"overflow-x":"hidden","overflow-y":"auto"})})),Hc=w(((e,t)=>{Bc(e,t)})),Ic=(e,t,o)=>void 0===e[t]?o:e[t],Pc=(e,t,o,n)=>{const r=Nc(e,t,o,n);return((e,t,o)=>{const n=cc(o.origin,t);o.transition.each((r=>{Mc(e,o.origin,n,r,t,o.lastPlacement)})),ac(e,n)})(t,r,n),Rc(t,r),((e,t)=>{const o=t.classes;ri(e,o.off),ni(e,o.on)})(t,r),((e,t,o)=>{(0,o.maxHeightFunction)(e,t.maxHeight)})(t,r,n),((e,t,o)=>{(0,o.maxWidthFunction)(e,t.maxWidth)})(t,r,n),{layout:r.layout,placement:r.placement}},Fc=["valignCentre","alignLeft","alignRight","alignCentre","top","bottom","left","right","inset"],zc=(e,t,o,n=1)=>{const r=e*n,s=t*n,a=e=>be(o,e).getOr([]),i=(e,t,o)=>{const n=X(Fc,o);return{offset:$t(e,t),classesOn:G(o,a),classesOff:G(n,a)}};return{southeast:()=>i(-e,t,["top","alignLeft"]),southwest:()=>i(e,t,["top","alignRight"]),south:()=>i(-e/2,t,["top","alignCentre"]),northeast:()=>i(-e,-t,["bottom","alignLeft"]),northwest:()=>i(e,-t,["bottom","alignRight"]),north:()=>i(-e/2,-t,["bottom","alignCentre"]),east:()=>i(e,-t/2,["valignCentre","left"]),west:()=>i(-e,-t/2,["valignCentre","right"]),insetNortheast:()=>i(r,s,["top","alignLeft","inset"]),insetNorthwest:()=>i(-r,s,["top","alignRight","inset"]),insetNorth:()=>i(-r/2,s,["top","alignCentre","inset"]),insetSoutheast:()=>i(r,-s,["bottom","alignLeft","inset"]),insetSouthwest:()=>i(-r,-s,["bottom","alignRight","inset"]),insetSouth:()=>i(-r/2,-s,["bottom","alignCentre","inset"]),insetEast:()=>i(-r,-s/2,["valignCentre","right","inset"]),insetWest:()=>i(r,-s/2,["valignCentre","left","inset"])}},Vc=()=>zc(0,0,{}),Zc=x,Uc=(e,t)=>o=>"rtl"===jc(o)?t:e,jc=e=>"rtl"===Rt(e,"direction")?"rtl":"ltr";var $c;!function(e){e.TopToBottom="toptobottom",e.BottomToTop="bottomtotop"}($c||($c={}));const Wc="data-alloy-vertical-dir",qc=e=>Di(e,(e=>Ue(e)&&kt(e,"data-alloy-vertical-dir")===$c.BottomToTop)),Gc=()=>_r("layouts",[cr("onLtr"),cr("onRtl"),vr("onBottomLtr"),vr("onBottomRtl")]),Kc=(e,t,o,n,r,s,a)=>{const i=a.map(qc).getOr(!1),l=t.layouts.map((t=>t.onLtr(e))),c=t.layouts.map((t=>t.onRtl(e))),d=i?t.layouts.bind((t=>t.onBottomLtr.map((t=>t(e))))).or(l).getOr(r):l.getOr(o),m=i?t.layouts.bind((t=>t.onBottomRtl.map((t=>t(e))))).or(c).getOr(s):c.getOr(n);return Uc(d,m)(e)};var Yc=[cr("hotspot"),vr("bubble"),Or("overrides",{}),Gc(),ol("placement",((e,t,o)=>{const n=t.hotspot,r=dc(o,n.element),s=Kc(e.element,t,Il(),Pl(),Ll(),Hl(),D.some(t.hotspot.element));return D.some(Zc({anchorBox:r,bubble:t.bubble.getOr(Vc()),overrides:t.overrides,layouts:s}))}))];var Xc=[cr("x"),cr("y"),Or("height",0),Or("width",0),Or("bubble",Vc()),Or("overrides",{}),Gc(),ol("placement",((e,t,o)=>{const n=uc(o,t.x,t.y),r=qo(n.left,n.top,t.width,t.height),s=Kc(e.element,t,Rl(),Bl(),Rl(),Bl(),D.none());return D.some(Zc({anchorBox:r,bubble:t.bubble,overrides:t.overrides,layouts:s}))}))];const Jc=Hr([{screen:["point"]},{absolute:["point","scrollLeft","scrollTop"]}]),Qc=e=>e.fold(x,((e,t,o)=>e.translate(-t,-o))),ed=e=>e.fold(x,x),td=e=>j(e,((e,t)=>e.translate(t.left,t.top)),$t(0,0)),od=e=>{const t=F(e,ed);return td(t)},nd=Jc.screen,rd=Jc.absolute,sd=(e,t,o)=>{const n=Je(e.element),r=Fo(n),s=((e,t,o)=>{const n=tt(o.root).dom;return D.from(n.frameElement).map(Be.fromDom).filter((t=>{const o=Je(t),n=Je(e.element);return Ye(o,n)})).map(qt)})(e,0,o).getOr(r);return rd(s,r.left,r.top)},ad=(e,t,o,n)=>{const r=nd($t(e,t));return D.some(((e,t,o)=>({point:e,width:t,height:o}))(r,o,n))},id=(e,t,o,n,r)=>e.map((e=>{const s=[t,e.point],a=(i=()=>od(s),l=()=>od(s),c=()=>(e=>{const t=F(e,Qc);return td(t)})(s),n.fold(i,l,c));var i,l,c;const d=((e,t,o,n)=>({x:e,y:t,width:o,height:n}))(a.left,a.top,e.width,e.height),m=o.showAbove?Ll():Il(),u=o.showAbove?Hl():Pl(),g=Kc(r,o,m,u,m,u,D.none());return Zc({anchorBox:d,bubble:o.bubble.getOr(Vc()),overrides:o.overrides,layouts:g})}));var ld=[cr("node"),cr("root"),vr("bubble"),Gc(),Or("overrides",{}),Or("showAbove",!1),ol("placement",((e,t,o)=>{const n=sd(e,0,t);return t.node.filter(vt).bind((r=>{const s=r.dom.getBoundingClientRect(),a=ad(s.left,s.top,s.width,s.height),i=t.node.getOr(e.element);return id(a,n,t,o,i)}))}))];const cd=(e,t,o,n)=>({start:e,soffset:t,finish:o,foffset:n}),dd=Hr([{before:["element"]},{on:["element","offset"]},{after:["element"]}]),md=(dd.before,dd.on,dd.after,e=>e.fold(x,x,x)),ud=Hr([{domRange:["rng"]},{relative:["startSitu","finishSitu"]},{exact:["start","soffset","finish","foffset"]}]),gd={domRange:ud.domRange,relative:ud.relative,exact:ud.exact,exactFromRange:e=>ud.exact(e.start,e.soffset,e.finish,e.foffset),getWin:e=>{const t=(e=>e.match({domRange:e=>Be.fromDom(e.startContainer),relative:(e,t)=>md(e),exact:(e,t,o,n)=>e}))(e);return tt(t)},range:cd},pd=(e,t,o)=>{const n=e.document.createRange();var r;return r=n,t.fold((e=>{r.setStartBefore(e.dom)}),((e,t)=>{r.setStart(e.dom,t)}),(e=>{r.setStartAfter(e.dom)})),((e,t)=>{t.fold((t=>{e.setEndBefore(t.dom)}),((t,o)=>{e.setEnd(t.dom,o)}),(t=>{e.setEndAfter(t.dom)}))})(n,o),n},hd=(e,t,o,n,r)=>{const s=e.document.createRange();return s.setStart(t.dom,o),s.setEnd(n.dom,r),s},fd=e=>({left:e.left,top:e.top,right:e.right,bottom:e.bottom,width:e.width,height:e.height}),bd=Hr([{ltr:["start","soffset","finish","foffset"]},{rtl:["start","soffset","finish","foffset"]}]),vd=(e,t,o)=>t(Be.fromDom(o.startContainer),o.startOffset,Be.fromDom(o.endContainer),o.endOffset),yd=(e,t)=>{const o=((e,t)=>t.match({domRange:e=>({ltr:w(e),rtl:D.none}),relative:(t,o)=>({ltr:Jt((()=>pd(e,t,o))),rtl:Jt((()=>D.some(pd(e,o,t))))}),exact:(t,o,n,r)=>({ltr:Jt((()=>hd(e,t,o,n,r))),rtl:Jt((()=>D.some(hd(e,n,r,t,o))))})}))(e,t);return((e,t)=>{const o=t.ltr();if(o.collapsed)return t.rtl().filter((e=>!1===e.collapsed)).map((e=>bd.rtl(Be.fromDom(e.endContainer),e.endOffset,Be.fromDom(e.startContainer),e.startOffset))).getOrThunk((()=>vd(0,bd.ltr,o)));return vd(0,bd.ltr,o)})(0,o)},wd=(e,t)=>yd(e,t).match({ltr:(t,o,n,r)=>{const s=e.document.createRange();return s.setStart(t.dom,o),s.setEnd(n.dom,r),s},rtl:(t,o,n,r)=>{const s=e.document.createRange();return s.setStart(n.dom,r),s.setEnd(t.dom,o),s}});bd.ltr,bd.rtl;const xd=(e,t,o)=>Z(((e,t)=>{const o=p(t)?t:T;let n=e.dom;const r=[];for(;null!==n.parentNode&&void 0!==n.parentNode;){const e=n.parentNode,t=Be.fromDom(e);if(r.push(t),!0===o(t))break;n=e}return r})(e,o),t),Cd=(e,t)=>((e,t)=>{const o=void 0===t?document:t.dom;return Ke(o)?[]:F(o.querySelectorAll(e),Be.fromDom)})(t,e),Sd=(e,t,o,n)=>{const r=((e,t,o,n)=>{const r=Je(e).dom.createRange();return r.setStart(e.dom,t),r.setEnd(o.dom,n),r})(e,t,o,n),s=Ye(e,o)&&t===n;return r.collapsed&&!s},kd=e=>{if(e.rangeCount>0){const t=e.getRangeAt(0),o=e.getRangeAt(e.rangeCount-1);return D.some(cd(Be.fromDom(t.startContainer),t.startOffset,Be.fromDom(o.endContainer),o.endOffset))}return D.none()},_d=e=>{if(null===e.anchorNode||null===e.focusNode)return kd(e);{const t=Be.fromDom(e.anchorNode),o=Be.fromDom(e.focusNode);return Sd(t,e.anchorOffset,o,e.focusOffset)?D.some(cd(t,e.anchorOffset,o,e.focusOffset)):kd(e)}},Od=e=>(e=>D.from(e.getSelection()))(e).filter((e=>e.rangeCount>0)).bind(_d),Td=(e,t)=>(e=>{const t=e.getClientRects(),o=t.length>0?t[0]:e.getBoundingClientRect();return o.width>0||o.height>0?D.some(o).map(fd):D.none()})(wd(e,t)),Ed=(e,t)=>(e=>{const t=e.getBoundingClientRect();return t.width>0||t.height>0?D.some(t).map(fd):D.none()})(wd(e,t)),Dd=((e,t)=>{const o=t=>e(t)?D.from(t.dom.nodeValue):D.none();return{get:n=>{if(!e(n))throw new Error("Can only get "+t+" value of a "+t+" node");return o(n).getOr("")},getOption:o,set:(o,n)=>{if(!e(o))throw new Error("Can only set raw "+t+" value of a "+t+" node");o.dom.nodeValue=n}}})(je,"text"),Ad=(e,t)=>({element:e,offset:t}),Md=(e,t)=>{const o=st(e);if(0===o.length)return Ad(e,t);if(tDd.get(e))(e).length:st(e).length;return Ad(e,t)}},Nd=(e,t)=>je(e)?Ad(e,t):Md(e,t),Rd=e=>void 0!==e.foffset,Bd=(e,t)=>t.getSelection.getOrThunk((()=>()=>Od(e)))().map((e=>{if(Rd(e)){const t=Nd(e.start,e.soffset),o=Nd(e.finish,e.foffset);return gd.range(t.element,t.offset,o.element,o.offset)}return e}));var Ld=[vr("getSelection"),cr("root"),vr("bubble"),Gc(),Or("overrides",{}),Or("showAbove",!1),ol("placement",((e,t,o)=>{const n=tt(t.root).dom,r=sd(e,0,t),s=Bd(n,t).bind((e=>{if(Rd(e)){const t=Ed(n,gd.exactFromRange(e)).orThunk((()=>{const t=Be.fromText("\ufeff");No(e.start,t);const o=Td(n,gd.exact(t,0,t,1));return Po(t),o}));return t.bind((e=>ad(e.left,e.top,e.width,e.height)))}{const t=ce(e,(e=>e.dom.getBoundingClientRect())),o={left:Math.min(t.firstCell.left,t.lastCell.left),right:Math.max(t.firstCell.right,t.lastCell.right),top:Math.min(t.firstCell.top,t.lastCell.top),bottom:Math.max(t.firstCell.bottom,t.lastCell.bottom)};return ad(o.left,o.top,o.right-o.left,o.bottom-o.top)}})),a=Bd(n,t).bind((e=>Rd(e)?Ue(e.start)?D.some(e.start):nt(e.start):D.some(e.firstCell))).getOr(e.element);return id(s,r,t,o,a)}))];const Hd="link-layout",Id=e=>e.x+e.width,Pd=(e,t)=>e.x-t.width,Fd=(e,t)=>e.y-t.height+e.height,zd=e=>e.y,Vd=(e,t,o)=>sl(Id(e),zd(e),o.southeast(),il(),"southeast",bl(e,{left:0,top:2}),Hd),Zd=(e,t,o)=>sl(Pd(e,t),zd(e),o.southwest(),ll(),"southwest",bl(e,{right:1,top:2}),Hd),Ud=(e,t,o)=>sl(Id(e),Fd(e,t),o.northeast(),cl(),"northeast",bl(e,{left:0,bottom:3}),Hd),jd=(e,t,o)=>sl(Pd(e,t),Fd(e,t),o.northwest(),dl(),"northwest",bl(e,{right:1,bottom:3}),Hd),$d=()=>[Vd,Zd,Ud,jd],Wd=()=>[Zd,Vd,jd,Ud];var qd=[cr("item"),Gc(),Or("overrides",{}),ol("placement",((e,t,o)=>{const n=dc(o,t.item.element),r=Kc(e.element,t,$d(),Wd(),$d(),Wd(),D.none());return D.some(Zc({anchorBox:n,bubble:Vc(),overrides:t.overrides,layouts:r}))}))],Gd=rr("type",{selection:Ld,node:ld,hotspot:Yc,submenu:qd,makeshift:Xc});const Kd=[br("classes",$n),Ar("mode","all",["all","layout","placement"])],Yd=[Or("useFixed",T),vr("getBounds")],Xd=[dr("anchor",Gd),_r("transition",Kd)],Jd=(e,t,o,n,r,s)=>((e,t,o,n,r,s,a,i)=>{const l=Ic(a,"maxHeightFunction",Lc()),c=Ic(a,"maxWidthFunction",b),d=e.anchorBox,m=e.origin,u={bounds:mc(m,s),origin:m,preference:n,maxHeightFunction:l,maxWidthFunction:c,lastPlacement:r,transition:i};return Pc(d,t,o,u)})(hc(t.anchorBox,e),n.element,t.bubble,t.layouts,r,o,t.overrides,s),Qd=(e,t,o,n,r,s)=>{const a=or("placement.info",In(Xd),r),i=a.anchor,l=n.element,c=o.get(n.uid);rc((()=>{At(l,"position","fixed");const r=Lt(l,"visibility");At(l,"visibility","hidden");const d=t.useFixed()?(()=>{const e=document.documentElement;return pc(0,0,e.clientWidth,e.clientHeight)})():(e=>{const t=qt(e.element),o=e.element.dom.getBoundingClientRect();return gc(t.left,t.top,o.width,o.height)})(e);i.placement(e,i,d).each((e=>{const r=s.orThunk((()=>t.getBounds.map(O))),i=Jd(d,e,r,n,c,a.transition);o.set(n.uid,i)})),r.fold((()=>{Pt(l,"visibility")}),(e=>{At(l,"visibility",e)})),Lt(l,"left").isNone()&&Lt(l,"top").isNone()&&Lt(l,"right").isNone()&&Lt(l,"bottom").isNone()&&we(Lt(l,"position"),"fixed")&&Pt(l,"position")}),l)};var em=Object.freeze({__proto__:null,position:(e,t,o,n,r)=>{const s=D.none();Qd(e,t,o,n,r,s)},positionWithinBounds:Qd,getMode:(e,t,o)=>t.useFixed()?"fixed":"absolute",reset:(e,t,o,n)=>{const r=n.element;z(["position","left","right","top","bottom"],(e=>Pt(r,e))),(e=>{Tt(e,fc)})(r),o.clear(n.uid)}});const tm=ql({fields:Yd,name:"positioning",active:Jl,apis:em,state:Object.freeze({__proto__:null,init:()=>{let e={};return Ha({readState:()=>e,clear:t=>{g(t)?delete e[t]:e={}},set:(t,o)=>{e[t]=o},get:t=>be(e,t)})}})}),om=e=>e.getSystem().isConnected(),nm=e=>{Us(e,Rs());const t=e.components();z(t,nm)},rm=e=>{const t=e.components();z(t,rm),Us(e,Ns())},sm=(e,t)=>{e.getSystem().addToWorld(t),vt(e.element)&&rm(t)},am=e=>{nm(e),e.getSystem().removeFromWorld(e)},im=(e,t)=>{Lo(e.element,t.element)},lm=(e,t,o)=>{const n=e.components();(e=>{z(e.components(),(e=>Po(e.element))),Io(e.element),e.syncComponents()})(e);const r=o(t),s=X(n,r);z(s,(t=>{nm(t),e.getSystem().removeFromWorld(t)})),z(r,(t=>{om(t)?im(e,t):(e.getSystem().addToWorld(t),im(e,t),vt(e.element)&&rm(t))})),e.syncComponents()},cm=(e,t)=>{dm(e,t,Lo)},dm=(e,t,o)=>{e.getSystem().addToWorld(t),o(e.element,t.element),vt(e.element)&&rm(t),e.syncComponents()},mm=e=>{nm(e),Po(e.element),e.getSystem().removeFromWorld(e)},um=e=>{const t=ot(e.element).bind((t=>e.getSystem().getByDom(t).toOptional()));mm(e),t.each((e=>{e.syncComponents()}))},gm=e=>{const t=e.components();z(t,mm),Io(e.element),e.syncComponents()},pm=(e,t)=>{fm(e,t,Lo)},hm=(e,t)=>{fm(e,t,Ro)},fm=(e,t,o)=>{o(e,t.element);const n=st(t.element);z(n,(e=>{t.getByDom(e).each(rm)}))},bm=e=>{const t=st(e.element);z(t,(t=>{e.getByDom(t).each(nm)})),Po(e.element)},vm=(e,t,o,n)=>{o.get().each((t=>{gm(e)}));const r=t.getAttachPoint(e);cm(r,e);const s=e.getSystem().build(n);return cm(e,s),o.set(s),s},ym=(e,t,o,n)=>{const r=vm(e,t,o,n);return t.onOpen(e,r),r},wm=(e,t,o)=>{o.get().each((n=>{gm(e),um(e),t.onClose(e,n),o.clear()}))},xm=(e,t,o)=>o.isOpen(),Cm=(e,t,o)=>{const n=t.getAttachPoint(e);At(e.element,"position",tm.getMode(n)),((e,t,o,n)=>{Lt(e.element,t).fold((()=>{Tt(e.element,o)}),(t=>{Ct(e.element,o,t)})),At(e.element,t,n)})(e,"visibility",t.cloakVisibilityAttr,"hidden")},Sm=(e,t,o)=>{(e=>H(["top","left","right","bottom"],(t=>Lt(e,t).isSome())))(e.element)||Pt(e.element,"position"),((e,t,o)=>{_t(e.element,o).fold((()=>Pt(e.element,t)),(o=>At(e.element,t,o)))})(e,"visibility",t.cloakVisibilityAttr)};var km=Object.freeze({__proto__:null,cloak:Cm,decloak:Sm,open:ym,openWhileCloaked:(e,t,o,n,r)=>{Cm(e,t),ym(e,t,o,n),r(),Sm(e,t)},close:wm,isOpen:xm,isPartOf:(e,t,o,n)=>xm(0,0,o)&&o.get().exists((o=>t.isPartOf(e,o,n))),getState:(e,t,o)=>o.get(),setContent:(e,t,o,n)=>o.get().map((()=>vm(e,t,o,n)))});var _m=Object.freeze({__proto__:null,events:(e,t)=>Ks([Js(_s(),((o,n)=>{wm(o,e,t)}))])}),Om=[Ji("onOpen"),Ji("onClose"),cr("isPartOf"),cr("getAttachPoint"),Or("cloakVisibilityAttr","data-precloak-visibility")];var Tm=Object.freeze({__proto__:null,init:()=>{const e=Cc(),t=w("not-implemented");return Ha({readState:t,isOpen:e.isSet,clear:e.clear,set:e.set,get:e.get})}});const Em=ql({fields:Om,name:"sandboxing",active:_m,apis:km,state:Tm}),Dm=w("dismiss.popups"),Am=w("reposition.popups"),Mm=w("mouse.released"),Nm=Hn([Or("isExtraPart",T),_r("fireEventInstead",[Or("event",Bs())])]),Rm=e=>{const t=or("Dismissal",Nm,e);return{[Dm()]:{schema:Hn([cr("target")]),onReceive:(e,o)=>{if(Em.isOpen(e)){Em.isPartOf(e,o.target)||t.isExtraPart(e,o.target)||t.fireEventInstead.fold((()=>Em.close(e)),(t=>Us(e,t.event)))}}}}},Bm=Hn([_r("fireEventInstead",[Or("event",Ls())]),pr("doReposition")]),Lm=e=>{const t=or("Reposition",Bm,e);return{[Am()]:{onReceive:e=>{Em.isOpen(e)&&t.fireEventInstead.fold((()=>t.doReposition(e)),(t=>Us(e,t.event)))}}}},Hm=(e,t,o)=>{t.store.manager.onLoad(e,t,o)},Im=(e,t,o)=>{t.store.manager.onUnload(e,t,o)};var Pm=Object.freeze({__proto__:null,onLoad:Hm,onUnload:Im,setValue:(e,t,o,n)=>{t.store.manager.setValue(e,t,o,n)},getValue:(e,t,o)=>t.store.manager.getValue(e,t,o),getState:(e,t,o)=>o});var Fm=Object.freeze({__proto__:null,events:(e,t)=>{const o=e.resetOnDom?[aa(((o,n)=>{Hm(o,e,t)})),ia(((o,n)=>{Im(o,e,t)}))]:[Vl(e,t,Hm)];return Ks(o)}});const zm=()=>{const e=Lr(null);return Ha({set:e.set,get:e.get,isNotSet:()=>null===e.get(),clear:()=>{e.set(null)},readState:()=>({mode:"memory",value:e.get()})})},Vm=()=>{const e=Lr({}),t=Lr({});return Ha({readState:()=>({mode:"dataset",dataByValue:e.get(),dataByText:t.get()}),lookup:o=>be(e.get(),o).orThunk((()=>be(t.get(),o))),update:o=>{const n=e.get(),r=t.get(),s={},a={};z(o,(e=>{s[e.value]=e,be(e,"meta").each((t=>{be(t,"text").each((t=>{a[t]=e}))}))})),e.set({...n,...s}),t.set({...r,...a})},clear:()=>{e.set({}),t.set({})}})};var Zm=Object.freeze({__proto__:null,memory:zm,dataset:Vm,manual:()=>Ha({readState:b}),init:e=>e.store.manager.state(e)});const Um=(e,t,o,n)=>{const r=t.store;o.update([n]),r.setValue(e,n),t.onSetValue(e,n)};var jm=[vr("initialValue"),cr("getFallbackEntry"),cr("getDataKey"),cr("setValue"),ol("manager",{setValue:Um,getValue:(e,t,o)=>{const n=t.store,r=n.getDataKey(e);return o.lookup(r).getOrThunk((()=>n.getFallbackEntry(r)))},onLoad:(e,t,o)=>{t.store.initialValue.each((n=>{Um(e,t,o,n)}))},onUnload:(e,t,o)=>{o.clear()},state:Vm})];var $m=[cr("getValue"),Or("setValue",b),vr("initialValue"),ol("manager",{setValue:(e,t,o,n)=>{t.store.setValue(e,n),t.onSetValue(e,n)},getValue:(e,t,o)=>t.store.getValue(e),onLoad:(e,t,o)=>{t.store.initialValue.each((o=>{t.store.setValue(e,o)}))},onUnload:b,state:La.init})];var Wm=[vr("initialValue"),ol("manager",{setValue:(e,t,o,n)=>{o.set(n),t.onSetValue(e,n)},getValue:(e,t,o)=>o.get(),onLoad:(e,t,o)=>{t.store.initialValue.each((e=>{o.isNotSet()&&o.set(e)}))},onUnload:(e,t,o)=>{o.clear()},state:zm})],qm=[Tr("store",{mode:"memory"},rr("mode",{memory:Wm,manual:$m,dataset:jm})),Ji("onSetValue"),Or("resetOnDom",!1)];const Gm=ql({fields:qm,name:"representing",active:Fm,apis:Pm,extra:{setValueFrom:(e,t)=>{const o=Gm.getValue(t);Gm.setValue(e,o)}},state:Zm}),Km=(e,t)=>Br(e,{},F(t,(t=>{return o=t.name(),n="Cannot configure "+t.name()+" for "+e,ar(o,o,{tag:"option",process:{}},Dn((e=>mn("The field: "+o+" is forbidden. "+n))));var o,n})).concat([ir("dump",x)])),Ym=e=>e.dump,Xm=(e,t)=>({...$l(t),...e.dump}),Jm=Km,Qm=Xm,eu="placeholder",tu=Hr([{single:["required","valueThunk"]},{multiple:["required","valueThunks"]}]),ou=e=>ve(e,"uiType"),nu=(e,t,o,n)=>ou(o)&&o.uiType===eu?((e,t,o,n)=>e.exists((e=>e!==o.owner))?tu.single(!0,w(o)):be(n,o.name).fold((()=>{throw new Error("Unknown placeholder component: "+o.name+"\nKnown: ["+ae(n)+"]\nNamespace: "+e.getOr("none")+"\nSpec: "+JSON.stringify(o,null,2))}),(e=>e.replace())))(e,0,o,n):tu.single(!1,w(o)),ru=(e,t,o,n)=>nu(e,0,o,n).fold(((r,s)=>{const a=ou(o)?s(t,o.config,o.validated):s(t),i=be(a,"components").getOr([]),l=G(i,(o=>ru(e,t,o,n)));return[{...a,components:l}]}),((e,n)=>{if(ou(o)){const e=n(t,o.config,o.validated);return o.validated.preprocess.getOr(x)(e)}return n(t)})),su=(e,t,o,n)=>{const r=ce(n,((e,t)=>((e,t)=>{let o=!1;return{name:w(e),required:()=>t.fold(((e,t)=>e),((e,t)=>e)),used:()=>o,replace:()=>{if(o)throw new Error("Trying to use the same placeholder more than once: "+e);return o=!0,t}}})(t,e))),s=((e,t,o,n)=>G(o,(o=>ru(e,t,o,n))))(e,t,o,r);return le(r,(o=>{if(!1===o.used()&&o.required())throw new Error("Placeholder: "+o.name()+" was not found in components list\nNamespace: "+e.getOr("none")+"\nComponents: "+JSON.stringify(t.components,null,2))})),s},au=tu.single,iu=tu.multiple,lu=w(eu),cu=Hr([{required:["data"]},{external:["data"]},{optional:["data"]},{group:["data"]}]),du=Or("factory",{sketch:x}),mu=Or("schema",[]),uu=cr("name"),gu=ar("pname","pname",Cn((e=>"")),Zn()),pu=ir("schema",(()=>[vr("preprocess")])),hu=Or("defaults",w({})),fu=Or("overrides",w({})),bu=In([du,mu,uu,gu,hu,fu]),vu=In([du,mu,uu,hu,fu]),yu=In([du,mu,uu,gu,hu,fu]),wu=In([du,pu,uu,cr("unit"),gu,hu,fu]),xu=e=>e.fold(D.some,D.none,D.some,D.some),Cu=e=>{const t=e=>e.name;return e.fold(t,t,t,t)},Su=(e,t)=>o=>{const n=or("Converting part type",t,o);return e(n)},ku=Su(cu.required,bu),_u=Su(cu.external,vu),Ou=Su(cu.optional,yu),Tu=Su(cu.group,wu),Eu=w("entirety");var Du=Object.freeze({__proto__:null,required:ku,external:_u,optional:Ou,group:Tu,asNamedPart:xu,name:Cu,asCommon:e=>e.fold(x,x,x,x),original:Eu});const Au=(e,t,o,n)=>wn(t.defaults(e,o,n),o,{uid:e.partUids[t.name]},t.overrides(e,o,n)),Mu=(e,t)=>{const o={};return z(t,(t=>{xu(t).each((t=>{const n=Nu(e,t.pname);o[t.name]=o=>{const r=or("Part: "+t.name+" in "+e,In(t.schema),o);return{...n,config:o,validated:r}}}))})),o},Nu=(e,t)=>({uiType:lu(),owner:e,name:t}),Ru=(e,t,o)=>({uiType:lu(),owner:e,name:t,config:o,validated:{}}),Bu=e=>G(e,(e=>e.fold(D.none,D.some,D.none,D.none).map((e=>hr(e.name,e.schema.concat([nl(Eu())])))).toArray())),Lu=e=>F(e,Cu),Hu=(e,t,o)=>((e,t,o)=>{const n={},r={};return z(o,(e=>{e.fold((e=>{n[e.pname]=au(!0,((t,o,n)=>e.factory.sketch(Au(t,e,o,n))))}),(e=>{const o=t.parts[e.name];r[e.name]=w(e.factory.sketch(Au(t,e,o[Eu()]),o))}),(e=>{n[e.pname]=au(!1,((t,o,n)=>e.factory.sketch(Au(t,e,o,n))))}),(e=>{n[e.pname]=iu(!0,((t,o,n)=>{const r=t[e.name];return F(r,(o=>e.factory.sketch(wn(e.defaults(t,o,n),o,e.overrides(t,o)))))}))}))})),{internals:w(n),externals:w(r)}})(0,t,o),Iu=(e,t,o)=>su(D.some(e),t,t.components,o),Pu=(e,t,o)=>{const n=t.partUids[o];return e.getSystem().getByUid(n).toOptional()},Fu=(e,t,o)=>Pu(e,t,o).getOrDie("Could not find part: "+o),zu=(e,t,o)=>{const n={},r=t.partUids,s=e.getSystem();return z(o,(e=>{n[e]=w(s.getByUid(r[e]))})),n},Vu=(e,t)=>{const o=e.getSystem();return ce(t.partUids,((e,t)=>w(o.getByUid(e))))},Zu=e=>ae(e.partUids),Uu=(e,t,o)=>{const n={},r=t.partUids,s=e.getSystem();return z(o,(e=>{n[e]=w(s.getByUid(r[e]).getOrDie())})),n},ju=(e,t)=>{const o=Lu(t);return Fr(F(o,(t=>({key:t,value:e+"-"+t}))))},$u=e=>ar("partUids","partUids",kn((t=>ju(t.uid,e))),Zn());var Wu=Object.freeze({__proto__:null,generate:Mu,generateOne:Ru,schemas:Bu,names:Lu,substitutes:Hu,components:Iu,defaultUids:ju,defaultUidsSchema:$u,getAllParts:Vu,getAllPartNames:Zu,getPart:Pu,getPartOrDie:Fu,getParts:zu,getPartsOrDie:Uu});const qu=(e,t,o,n,r)=>{const s=((e,t)=>(e.length>0?[hr("parts",e)]:[]).concat([cr("uid"),Or("dom",{}),Or("components",[]),nl("originalSpec"),Or("debug.sketcher",{})]).concat(t))(n,r);return or(e+" [SpecSchema]",Hn(s.concat(t)),o)},Gu=(e,t,o,n,r)=>{const s=Ku(r),a=Bu(o),i=$u(o),l=qu(e,t,s,a,[i]),c=Hu(0,l,o);return n(l,Iu(e,l,c.internals()),s,c.externals())},Ku=e=>(e=>ve(e,"uid"))(e)?e:{...e,uid:_a("uid")},Yu=Hn([cr("name"),cr("factory"),cr("configFields"),Or("apis",{}),Or("extraApis",{})]),Xu=Hn([cr("name"),cr("factory"),cr("configFields"),cr("partFields"),Or("apis",{}),Or("extraApis",{})]),Ju=e=>{const t=or("Sketcher for "+e.name,Yu,e),o=ce(t.apis,Ba),n=ce(t.extraApis,((e,t)=>Aa(e,t)));return{name:t.name,configFields:t.configFields,sketch:e=>((e,t,o,n)=>{const r=Ku(n);return o(qu(e,t,r,[],[]),r)})(t.name,t.configFields,t.factory,e),...o,...n}},Qu=e=>{const t=or("Sketcher for "+e.name,Xu,e),o=Mu(t.name,t.partFields),n=ce(t.apis,Ba),r=ce(t.extraApis,((e,t)=>Aa(e,t)));return{name:t.name,partFields:t.partFields,configFields:t.configFields,sketch:e=>Gu(t.name,t.configFields,t.partFields,t.factory,e),parts:o,...n,...r}},eg=e=>qe("input")(e)&&"radio"!==kt(e,"type")||qe("textarea")(e);var tg=Object.freeze({__proto__:null,getCurrent:(e,t,o)=>t.find(e)});const og=[cr("find")],ng=ql({fields:og,name:"composing",apis:tg}),rg=["input","button","textarea","select"],sg=(e,t,o)=>{(t.disabled()?mg:ug)(e,t)},ag=(e,t)=>!0===t.useNative&&L(rg,ze(e.element)),ig=e=>{Ct(e.element,"disabled","disabled")},lg=e=>{Tt(e.element,"disabled")},cg=e=>{Ct(e.element,"aria-disabled","true")},dg=e=>{Ct(e.element,"aria-disabled","false")},mg=(e,t,o)=>{t.disableClass.each((t=>{ei(e.element,t)}));(ag(e,t)?ig:cg)(e),t.onDisabled(e)},ug=(e,t,o)=>{t.disableClass.each((t=>{ti(e.element,t)}));(ag(e,t)?lg:dg)(e),t.onEnabled(e)},gg=(e,t)=>ag(e,t)?(e=>Ot(e.element,"disabled"))(e):(e=>"true"===kt(e.element,"aria-disabled"))(e);var pg=Object.freeze({__proto__:null,enable:ug,disable:mg,isDisabled:gg,onLoad:sg,set:(e,t,o,n)=>{(n?mg:ug)(e,t)}});var hg=Object.freeze({__proto__:null,exhibit:(e,t)=>Pa({classes:t.disabled()?t.disableClass.toArray():[]}),events:(e,t)=>Ks([Ys(xs(),((t,o)=>gg(t,e))),Vl(e,t,sg)])}),fg=[Nr("disabled",T),Or("useNative",!0),vr("disableClass"),Ji("onDisabled"),Ji("onEnabled")];const bg=ql({fields:fg,name:"disabling",active:hg,apis:pg}),vg=(e,t,o,n)=>{const r=Cd(e.element,"."+t.highlightClass);z(r,(o=>{H(n,(e=>Ye(e.element,o)))||(ti(o,t.highlightClass),e.getSystem().getByDom(o).each((o=>{t.onDehighlight(e,o),Us(o,Zs())})))}))},yg=(e,t,o,n)=>{vg(e,t,0,[n]),wg(e,t,o,n)||(ei(n.element,t.highlightClass),t.onHighlight(e,n),Us(n,Vs()))},wg=(e,t,o,n)=>oi(n.element,t.highlightClass),xg=(e,t,o,n)=>{const r=Cd(e.element,"."+t.itemClass);return D.from(r[n]).fold((()=>tn.error(new Error("No element found with index "+n))),e.getSystem().getByDom)},Cg=(e,t,o)=>Ni(e.element,"."+t.itemClass).bind((t=>e.getSystem().getByDom(t).toOptional())),Sg=(e,t,o)=>{const n=Cd(e.element,"."+t.itemClass);return(n.length>0?D.some(n[n.length-1]):D.none()).bind((t=>e.getSystem().getByDom(t).toOptional()))},kg=(e,t,o,n)=>{const r=Cd(e.element,"."+t.itemClass),s=W(r,(e=>oi(e,t.highlightClass)));return s.bind((t=>{const o=hl(t,n,0,r.length-1);return e.getSystem().getByDom(r[o]).toOptional()}))},_g=(e,t,o)=>{const n=Cd(e.element,"."+t.itemClass);return xe(F(n,(t=>e.getSystem().getByDom(t).toOptional())))};var Og=Object.freeze({__proto__:null,dehighlightAll:(e,t,o)=>vg(e,t,0,[]),dehighlight:(e,t,o,n)=>{wg(e,t,o,n)&&(ti(n.element,t.highlightClass),t.onDehighlight(e,n),Us(n,Zs()))},highlight:yg,highlightFirst:(e,t,o)=>{Cg(e,t).each((n=>{yg(e,t,o,n)}))},highlightLast:(e,t,o)=>{Sg(e,t).each((n=>{yg(e,t,o,n)}))},highlightAt:(e,t,o,n)=>{xg(e,t,o,n).fold((e=>{throw e}),(n=>{yg(e,t,o,n)}))},highlightBy:(e,t,o,n)=>{const r=_g(e,t);$(r,n).each((n=>{yg(e,t,o,n)}))},isHighlighted:wg,getHighlighted:(e,t,o)=>Ni(e.element,"."+t.highlightClass).bind((t=>e.getSystem().getByDom(t).toOptional())),getFirst:Cg,getLast:Sg,getPrevious:(e,t,o)=>kg(e,t,0,-1),getNext:(e,t,o)=>kg(e,t,0,1),getCandidates:_g}),Tg=[cr("highlightClass"),cr("itemClass"),Ji("onHighlight"),Ji("onDehighlight")];const Eg=ql({fields:Tg,name:"highlighting",apis:Og}),Dg=[8],Ag=[9],Mg=[13],Ng=[27],Rg=[32],Bg=[37],Lg=[38],Hg=[39],Ig=[40],Pg=(e,t,o)=>{const n=Y(e.slice(0,t)),r=Y(e.slice(t+1));return $(n.concat(r),o)},Fg=(e,t,o)=>{const n=Y(e.slice(0,t));return $(n,o)},zg=(e,t,o)=>{const n=e.slice(0,t),r=e.slice(t+1);return $(r.concat(n),o)},Vg=(e,t,o)=>{const n=e.slice(t+1);return $(n,o)},Zg=e=>t=>{const o=t.raw;return L(e,o.which)},Ug=e=>t=>K(e,(e=>e(t))),jg=e=>!0===e.raw.shiftKey,$g=e=>!0===e.raw.ctrlKey,Wg=k(jg),qg=(e,t)=>({matches:e,classification:t}),Gg=(e,t,o)=>{t.exists((e=>o.exists((t=>Ye(t,e)))))||js(e,Hs(),{prevFocus:t,newFocus:o})},Kg=()=>{const e=e=>nc(e.element);return{get:e,set:(t,o)=>{const n=e(t);t.getSystem().triggerFocus(o,t.element);const r=e(t);Gg(t,n,r)}}},Yg=()=>{const e=e=>Eg.getHighlighted(e).map((e=>e.element));return{get:e,set:(t,o)=>{const n=e(t);t.getSystem().getByDom(o).fold(b,(e=>{Eg.highlight(t,e)}));const r=e(t);Gg(t,n,r)}}};var Xg;!function(e){e.OnFocusMode="onFocus",e.OnEnterOrSpaceMode="onEnterOrSpace",e.OnApiMode="onApi"}(Xg||(Xg={}));const Jg=(e,t,o,n,r)=>{const s=(e,t,o,n,r)=>((e,t)=>{const o=$(e,(e=>e.matches(t)));return o.map((e=>e.classification))})(o(e,t,n,r),t.event).bind((o=>o(e,t,n,r))),a={schema:()=>e.concat([Or("focusManager",Kg()),Tr("focusInside","onFocus",Jn((e=>L(["onFocus","onEnterOrSpace","onApi"],e)?tn.value(e):tn.error("Invalid value for focusInside")))),ol("handler",a),ol("state",t),ol("sendFocusIn",r)]),processKey:s,toEvents:(e,t)=>{const a=e.focusInside!==Xg.OnFocusMode?D.none():r(e).map((o=>Js(bs(),((n,r)=>{o(n,e,t),r.stop()})))),i=[Js(as(),((n,a)=>{s(n,a,o,e,t).fold((()=>{((o,n)=>{const s=Zg(Rg.concat(Mg))(n.event);e.focusInside===Xg.OnEnterOrSpaceMode&&s&&jr(o,n)&&r(e).each((r=>{r(o,e,t),n.stop()}))})(n,a)}),(e=>{a.stop()}))})),Js(is(),((o,r)=>{s(o,r,n,e,t).each((e=>{r.stop()}))}))];return Ks(a.toArray().concat(i))}};return a},Qg=e=>{const t=[vr("onEscape"),vr("onEnter"),Or("selector",'[data-alloy-tabstop="true"]:not(:disabled)'),Or("firstTabstop",0),Or("useTabstopAt",E),vr("visibilitySelector")].concat([e]),o=(e,t)=>{const o=e.visibilitySelector.bind((e=>Ri(t,e))).getOr(t);return Zt(o)>0},n=(e,t)=>t.focusManager.get(e).bind((e=>Ri(e,t.selector))),r=(e,t,n)=>{((e,t)=>{const n=Cd(e.element,t.selector),r=Z(n,(e=>o(t,e)));return D.from(r[t.firstTabstop])})(e,t).each((o=>{t.focusManager.set(e,o)}))},s=(e,t,n,r,s)=>s(t,n,(e=>((e,t)=>o(e,t)&&e.useTabstopAt(t))(r,e))).fold((()=>r.cyclic?D.some(!0):D.none()),(t=>(r.focusManager.set(e,t),D.some(!0)))),a=(e,t,o,r)=>{const a=Cd(e.element,o.selector);return n(e,o).bind((t=>W(a,S(Ye,t)).bind((t=>s(e,a,t,o,r)))))},i=(e,t,o)=>{const n=o.cyclic?Pg:Fg;return a(e,0,o,n)},l=(e,t,o)=>{const n=o.cyclic?zg:Vg;return a(e,0,o,n)},c=e=>(e=>ot(e))(e).bind(it).exists((t=>Ye(t,e))),d=w([qg(Ug([jg,Zg(Ag)]),i),qg(Zg(Ag),l),qg(Ug([Wg,Zg(Mg)]),((e,t,o)=>o.onEnter.bind((o=>o(e,t)))))]),m=w([qg(Zg(Ng),((e,t,o)=>o.onEscape.bind((o=>o(e,t))))),qg(Zg(Ag),((e,t,o)=>n(e,o).filter((e=>!o.useTabstopAt(e))).bind((n=>(c(n)?i:l)(e,t,o)))))]);return Jg(t,La.init,d,m,(()=>D.some(r)))};var ep=Qg(ir("cyclic",T)),tp=Qg(ir("cyclic",E));const op=(e,t,o)=>eg(o)&&Zg(Rg)(t.event)?D.none():((e,t,o)=>(Ws(e,o,xs()),D.some(!0)))(e,0,o),np=(e,t)=>D.some(!0),rp=[Or("execute",op),Or("useSpace",!1),Or("useEnter",!0),Or("useControlEnter",!1),Or("useDown",!1)],sp=(e,t,o)=>o.execute(e,t,e.element);var ap=Jg(rp,La.init,((e,t,o,n)=>{const r=o.useSpace&&!eg(e.element)?Rg:[],s=o.useEnter?Mg:[],a=o.useDown?Ig:[],i=r.concat(s).concat(a);return[qg(Zg(i),sp)].concat(o.useControlEnter?[qg(Ug([$g,Zg(Mg)]),sp)]:[])}),((e,t,o,n)=>o.useSpace&&!eg(e.element)?[qg(Zg(Rg),np)]:[]),(()=>D.none()));const ip=()=>{const e=Cc();return Ha({readState:()=>e.get().map((e=>({numRows:String(e.numRows),numColumns:String(e.numColumns)}))).getOr({numRows:"?",numColumns:"?"}),setGridSize:(t,o)=>{e.set({numRows:t,numColumns:o})},getNumRows:()=>e.get().map((e=>e.numRows)),getNumColumns:()=>e.get().map((e=>e.numColumns))})};var lp=Object.freeze({__proto__:null,flatgrid:ip,init:e=>e.state(e)});const cp=e=>(t,o,n,r)=>{const s=e(t.element);return gp(s,t,o,n,r)},dp=(e,t)=>{const o=Uc(e,t);return cp(o)},mp=(e,t)=>{const o=Uc(t,e);return cp(o)},up=e=>(t,o,n,r)=>gp(e,t,o,n,r),gp=(e,t,o,n,r)=>n.focusManager.get(t).bind((o=>e(t.element,o,n,r))).map((e=>(n.focusManager.set(t,e),!0))),pp=up,hp=up,fp=up,bp=e=>!(e=>e.offsetWidth<=0&&e.offsetHeight<=0)(e.dom),vp=(e,t,o)=>{const n=Cd(e,o);return((e,t)=>W(e,t).map((t=>({index:t,candidates:e}))))(Z(n,bp),(e=>Ye(e,t)))},yp=(e,t)=>W(e,(e=>Ye(t,e))),wp=(e,t,o,n)=>n(Math.floor(t/o),t%o).bind((t=>{const n=t.row*o+t.column;return n>=0&&nwp(e,t,n,((t,s)=>{const a=t===o-1?e.length-t*n:n,i=hl(s,r,0,a-1);return D.some({row:t,column:i})})),Cp=(e,t,o,n,r)=>wp(e,t,n,((t,s)=>{const a=hl(t,r,0,o-1),i=a===o-1?e.length-a*n:n,l=fl(s,0,i-1);return D.some({row:a,column:l})})),Sp=[cr("selector"),Or("execute",op),Qi("onEscape"),Or("captureTab",!1),rl()],kp=(e,t,o)=>{Ni(e.element,t.selector).each((o=>{t.focusManager.set(e,o)}))},_p=e=>(t,o,n,r)=>vp(t,o,n.selector).bind((t=>e(t.candidates,t.index,r.getNumRows().getOr(n.initSize.numRows),r.getNumColumns().getOr(n.initSize.numColumns)))),Op=(e,t,o)=>o.captureTab?D.some(!0):D.none(),Tp=_p(((e,t,o,n)=>xp(e,t,o,n,-1))),Ep=_p(((e,t,o,n)=>xp(e,t,o,n,1))),Dp=_p(((e,t,o,n)=>Cp(e,t,o,n,-1))),Ap=_p(((e,t,o,n)=>Cp(e,t,o,n,1))),Mp=w([qg(Zg(Bg),dp(Tp,Ep)),qg(Zg(Hg),mp(Tp,Ep)),qg(Zg(Lg),pp(Dp)),qg(Zg(Ig),hp(Ap)),qg(Ug([jg,Zg(Ag)]),Op),qg(Ug([Wg,Zg(Ag)]),Op),qg(Zg(Rg.concat(Mg)),((e,t,o,n)=>((e,t)=>t.focusManager.get(e).bind((e=>Ri(e,t.selector))))(e,o).bind((n=>o.execute(e,t,n)))))]),Np=w([qg(Zg(Ng),((e,t,o)=>o.onEscape(e,t))),qg(Zg(Rg),np)]);var Rp=Jg(Sp,ip,Mp,Np,(()=>D.some(kp)));const Bp=(e,t,o,n,r)=>{const s=(e,t,o)=>r(e,t,n,0,o.length-1,o[t],(t=>{return n=o[t],"button"===ze(n)&&"disabled"===kt(n,"disabled")?s(e,t,o):D.from(o[t]);var n}));return vp(e,o,t).bind((e=>{const t=e.index,o=e.candidates;return s(t,t,o)}))},Lp=(e,t,o,n)=>Bp(e,t,o,n,((e,t,o,n,r,s,a)=>{const i=fl(t+o,n,r);return i===e?D.from(s):a(i)})),Hp=(e,t,o,n)=>Bp(e,t,o,n,((e,t,o,n,r,s,a)=>{const i=hl(t,o,n,r);return i===e?D.none():a(i)})),Ip=[cr("selector"),Or("getInitial",D.none),Or("execute",op),Qi("onEscape"),Or("executeOnMove",!1),Or("allowVertical",!0),Or("allowHorizontal",!0),Or("cycles",!0)],Pp=(e,t,o)=>((e,t)=>t.focusManager.get(e).bind((e=>Ri(e,t.selector))))(e,o).bind((n=>o.execute(e,t,n))),Fp=(e,t,o)=>{t.getInitial(e).orThunk((()=>Ni(e.element,t.selector))).each((o=>{t.focusManager.set(e,o)}))},zp=(e,t,o)=>(o.cycles?Hp:Lp)(e,o.selector,t,-1),Vp=(e,t,o)=>(o.cycles?Hp:Lp)(e,o.selector,t,1),Zp=e=>(t,o,n,r)=>e(t,o,n,r).bind((()=>n.executeOnMove?Pp(t,o,n):D.some(!0))),Up=w([qg(Zg(Rg),np),qg(Zg(Ng),((e,t,o)=>o.onEscape(e,t)))]);var jp=Jg(Ip,La.init,((e,t,o,n)=>{const r=[...o.allowHorizontal?Bg:[]].concat(o.allowVertical?Lg:[]),s=[...o.allowHorizontal?Hg:[]].concat(o.allowVertical?Ig:[]);return[qg(Zg(r),Zp(dp(zp,Vp))),qg(Zg(s),Zp(mp(zp,Vp))),qg(Zg(Mg),Pp),qg(Zg(Rg),Pp)]}),Up,(()=>D.some(Fp)));const $p=(e,t,o)=>D.from(e[t]).bind((e=>D.from(e[o]).map((e=>({rowIndex:t,columnIndex:o,cell:e}))))),Wp=(e,t,o,n)=>{const r=e[t].length,s=hl(o,n,0,r-1);return $p(e,t,s)},qp=(e,t,o,n)=>{const r=hl(o,n,0,e.length-1),s=e[r].length,a=fl(t,0,s-1);return $p(e,r,a)},Gp=(e,t,o,n)=>{const r=e[t].length,s=fl(o+n,0,r-1);return $p(e,t,s)},Kp=(e,t,o,n)=>{const r=fl(o+n,0,e.length-1),s=e[r].length,a=fl(t,0,s-1);return $p(e,r,a)},Yp=[hr("selectors",[cr("row"),cr("cell")]),Or("cycles",!0),Or("previousSelector",D.none),Or("execute",op)],Xp=(e,t,o)=>{t.previousSelector(e).orThunk((()=>{const o=t.selectors;return Ni(e.element,o.cell)})).each((o=>{t.focusManager.set(e,o)}))},Jp=(e,t)=>(o,n,r)=>{const s=r.cycles?e:t;return Ri(n,r.selectors.row).bind((e=>{const t=Cd(e,r.selectors.cell);return yp(t,n).bind((t=>{const n=Cd(o,r.selectors.row);return yp(n,e).bind((e=>{const o=((e,t)=>F(e,(e=>Cd(e,t.selectors.cell))))(n,r);return s(o,e,t).map((e=>e.cell))}))}))}))},Qp=Jp(((e,t,o)=>Wp(e,t,o,-1)),((e,t,o)=>Gp(e,t,o,-1))),eh=Jp(((e,t,o)=>Wp(e,t,o,1)),((e,t,o)=>Gp(e,t,o,1))),th=Jp(((e,t,o)=>qp(e,o,t,-1)),((e,t,o)=>Kp(e,o,t,-1))),oh=Jp(((e,t,o)=>qp(e,o,t,1)),((e,t,o)=>Kp(e,o,t,1))),nh=w([qg(Zg(Bg),dp(Qp,eh)),qg(Zg(Hg),mp(Qp,eh)),qg(Zg(Lg),pp(th)),qg(Zg(Ig),hp(oh)),qg(Zg(Rg.concat(Mg)),((e,t,o)=>nc(e.element).bind((n=>o.execute(e,t,n)))))]),rh=w([qg(Zg(Rg),np)]);var sh=Jg(Yp,La.init,nh,rh,(()=>D.some(Xp)));const ah=[cr("selector"),Or("execute",op),Or("moveOnTab",!1)],ih=(e,t,o)=>o.focusManager.get(e).bind((n=>o.execute(e,t,n))),lh=(e,t,o)=>{Ni(e.element,t.selector).each((o=>{t.focusManager.set(e,o)}))},ch=(e,t,o)=>Hp(e,o.selector,t,-1),dh=(e,t,o)=>Hp(e,o.selector,t,1),mh=w([qg(Zg(Lg),fp(ch)),qg(Zg(Ig),fp(dh)),qg(Ug([jg,Zg(Ag)]),((e,t,o,n)=>o.moveOnTab?fp(ch)(e,t,o,n):D.none())),qg(Ug([Wg,Zg(Ag)]),((e,t,o,n)=>o.moveOnTab?fp(dh)(e,t,o,n):D.none())),qg(Zg(Mg),ih),qg(Zg(Rg),ih)]),uh=w([qg(Zg(Rg),np)]);var gh=Jg(ah,La.init,mh,uh,(()=>D.some(lh)));const ph=[Qi("onSpace"),Qi("onEnter"),Qi("onShiftEnter"),Qi("onLeft"),Qi("onRight"),Qi("onTab"),Qi("onShiftTab"),Qi("onUp"),Qi("onDown"),Qi("onEscape"),Or("stopSpaceKeyup",!1),vr("focusIn")];var hh=Jg(ph,La.init,((e,t,o)=>[qg(Zg(Rg),o.onSpace),qg(Ug([Wg,Zg(Mg)]),o.onEnter),qg(Ug([jg,Zg(Mg)]),o.onShiftEnter),qg(Ug([jg,Zg(Ag)]),o.onShiftTab),qg(Ug([Wg,Zg(Ag)]),o.onTab),qg(Zg(Lg),o.onUp),qg(Zg(Ig),o.onDown),qg(Zg(Bg),o.onLeft),qg(Zg(Hg),o.onRight),qg(Zg(Rg),o.onSpace)]),((e,t,o)=>[...o.stopSpaceKeyup?[qg(Zg(Rg),np)]:[],qg(Zg(Ng),o.onEscape)]),(e=>e.focusIn));const fh=ep.schema(),bh=tp.schema(),vh=jp.schema(),yh=Rp.schema(),wh=sh.schema(),xh=ap.schema(),Ch=gh.schema(),Sh=hh.schema();const kh=Kl({branchKey:"mode",branches:Object.freeze({__proto__:null,acyclic:fh,cyclic:bh,flow:vh,flatgrid:yh,matrix:wh,execution:xh,menu:Ch,special:Sh}),name:"keying",active:{events:(e,t)=>e.handler.toEvents(e,t)},apis:{focusIn:(e,t,o)=>{t.sendFocusIn(t).fold((()=>{e.getSystem().triggerFocus(e.element,e.element)}),(n=>{n(e,t,o)}))},setGridSize:(e,t,o,n,r)=>{(e=>ye(e,"setGridSize"))(o)?o.setGridSize(n,r):console.error("Layout does not support setGridSize")}},state:lp}),_h=(e,t)=>{rc((()=>{lm(e,t,(()=>F(t,e.getSystem().build)))}),e.element)},Oh=(e,t)=>{rc((()=>{((e,t,o)=>{const n=e.components(),r=G(t,(e=>Ra(e).toArray()));z(n,(e=>{L(r,e)||am(e)}));const s=o(t),a=X(n,s);z(a,(e=>{om(e)&&am(e)})),z(s,(t=>{om(t)||sm(e,t)})),e.syncComponents()})(e,t,(()=>((e,t,o)=>di(e,t,((t,n)=>mi(e,n,t,o))))(e.element,t,e.getSystem().buildOrPatch)))}),e.element)},Th=(e,t,o,n)=>{am(t);const r=mi(e.element,o,n,e.getSystem().buildOrPatch);sm(e,r),e.syncComponents()},Eh=(e,t,o)=>{const n=e.getSystem().build(o);dm(e,n,t)},Dh=(e,t,o,n)=>{um(t),Eh(e,((e,t)=>((e,t,o)=>{at(e,o).fold((()=>{Lo(e,t)}),(e=>{No(e,t)}))})(e,t,o)),n)},Ah=(e,t)=>e.components(),Mh=(e,t,o,n,r)=>{const s=Ah(e);return D.from(s[n]).map((o=>(r.fold((()=>um(o)),(r=>{(t.reuseDom?Th:Dh)(e,o,n,r)})),o)))};var Nh=Object.freeze({__proto__:null,append:(e,t,o,n)=>{Eh(e,Lo,n)},prepend:(e,t,o,n)=>{Eh(e,Bo,n)},remove:(e,t,o,n)=>{const r=Ah(e),s=$(r,(e=>Ye(n.element,e.element)));s.each(um)},replaceAt:Mh,replaceBy:(e,t,o,n,r)=>{const s=Ah(e);return W(s,n).bind((o=>Mh(e,t,0,o,r)))},set:(e,t,o,n)=>(t.reuseDom?Oh:_h)(e,n),contents:Ah});const Rh=ql({fields:[Mr("reuseDom",!0)],name:"replacing",apis:Nh}),Bh=(e,t)=>{const o=((e,t)=>{const o=Ks(t);return ql({fields:[cr("enabled")],name:e,active:{events:w(o)}})})(e,t);return{key:e,value:{config:{},me:o,configAsRaw:w({}),initialConfig:{},state:La}}},Lh=(e,t)=>{t.ignore||(Ql(e.element),t.onFocus(e))};var Hh=Object.freeze({__proto__:null,focus:Lh,blur:(e,t)=>{t.ignore||ec(e.element)},isFocused:e=>tc(e.element)});var Ih=Object.freeze({__proto__:null,exhibit:(e,t)=>{const o=t.ignore?{}:{attributes:{tabindex:"-1"}};return Pa(o)},events:e=>Ks([Js(bs(),((t,o)=>{Lh(t,e),o.stop()}))].concat(e.stopMousedown?[Js(Qr(),((e,t)=>{t.event.prevent()}))]:[]))}),Ph=[Ji("onFocus"),Or("stopMousedown",!1),Or("ignore",!1)];const Fh=ql({fields:Ph,name:"focusing",active:Ih,apis:Hh}),zh=(e,t,o,n)=>{const r=o.get();o.set(n),((e,t,o)=>{t.toggleClass.each((t=>{o.get()?ei(e.element,t):ti(e.element,t)}))})(e,t,o),((e,t,o)=>{const n=t.aria;n.update(e,n,o.get())})(e,t,o),r!==n&&t.onToggled(e,n)},Vh=(e,t,o)=>{zh(e,t,o,!o.get())},Zh=(e,t,o)=>{zh(e,t,o,t.selected)};var Uh=Object.freeze({__proto__:null,onLoad:Zh,toggle:Vh,isOn:(e,t,o)=>o.get(),on:(e,t,o)=>{zh(e,t,o,!0)},off:(e,t,o)=>{zh(e,t,o,!1)},set:zh});var jh=Object.freeze({__proto__:null,exhibit:()=>Pa({}),events:(e,t)=>{const o=(n=e,r=t,s=Vh,ca((e=>{s(e,n,r)})));var n,r,s;const a=Vl(e,t,Zh);return Ks(q([e.toggleOnExecute?[o]:[],[a]]))}});const $h=(e,t,o)=>{Ct(e.element,"aria-expanded",o)};var Wh=[Or("selected",!1),vr("toggleClass"),Or("toggleOnExecute",!0),Ji("onToggled"),Tr("aria",{mode:"none"},rr("mode",{pressed:[Or("syncWithExpanded",!1),ol("update",((e,t,o)=>{Ct(e.element,"aria-pressed",o),t.syncWithExpanded&&$h(e,t,o)}))],checked:[ol("update",((e,t,o)=>{Ct(e.element,"aria-checked",o)}))],expanded:[ol("update",$h)],selected:[ol("update",((e,t,o)=>{Ct(e.element,"aria-selected",o)}))],none:[ol("update",b)]}))];const qh=ql({fields:Wh,name:"toggling",active:jh,apis:Uh,state:(Gh=!1,{init:()=>{const e=Lr(Gh);return{get:()=>e.get(),set:t=>e.set(t),clear:()=>e.set(Gh),readState:()=>e.get()}}})});var Gh;const Kh=()=>{const e=(e,t)=>{t.stop(),$s(e)};return[Js(ds(),e),Js(Ss(),e),na(Kr()),na(Qr())]},Yh=e=>Ks(q([e.map((e=>ca(((t,o)=>{e(t),o.stop()})))).toArray(),Kh()])),Xh="alloy.item-hover",Jh="alloy.item-focus",Qh="alloy.item-toggled",ef=e=>{(nc(e.element).isNone()||Fh.isFocused(e))&&(Fh.isFocused(e)||Fh.focus(e),js(e,Xh,{item:e}))},tf=e=>{js(e,Jh,{item:e})},of=w(Xh),nf=w(Jh),rf=w(Qh),sf=e=>e.toggling.map((e=>e.exclusive?"menuitemradio":"menuitemcheckbox")).getOr("menuitem"),af=e=>({aria:{mode:"checked"},...ge(e,((e,t)=>"exclusive"!==t)),onToggled:(t,o)=>{p(e.onToggled)&&e.onToggled(t,o),((e,t)=>{js(e,Qh,{item:e,state:t})})(t,o)}}),lf=[cr("data"),cr("components"),cr("dom"),Or("hasSubmenu",!1),vr("toggling"),Jm("itemBehaviours",[qh,Fh,kh,Gm]),Or("ignoreFocus",!1),Or("domModification",{}),ol("builder",(e=>({dom:e.dom,domModification:{...e.domModification,attributes:{role:sf(e),...e.domModification.attributes,"aria-haspopup":e.hasSubmenu,...e.hasSubmenu?{"aria-expanded":!1}:{}}},behaviours:Qm(e.itemBehaviours,[e.toggling.fold(qh.revoke,(e=>qh.config(af(e)))),Fh.config({ignore:e.ignoreFocus,stopMousedown:e.ignoreFocus,onFocus:e=>{tf(e)}}),kh.config({mode:"execution"}),Gm.config({store:{mode:"memory",initialValue:e.data}}),Bh("item-type-events",[...Kh(),Js(ns(),ef),Js(Cs(),Fh.focus)])]),components:e.components,eventOrder:e.eventOrder}))),Or("eventOrder",{})],cf=[cr("dom"),cr("components"),ol("builder",(e=>({dom:e.dom,components:e.components,events:Ks([ra(Cs())])})))],df=w("item-widget"),mf=w([ku({name:"widget",overrides:e=>({behaviours:$l([Gm.config({store:{mode:"manual",getValue:t=>e.data,setValue:b}})])})})]),uf=[cr("uid"),cr("data"),cr("components"),cr("dom"),Or("autofocus",!1),Or("ignoreFocus",!1),Jm("widgetBehaviours",[Gm,Fh,kh]),Or("domModification",{}),$u(mf()),ol("builder",(e=>{const t=Hu(df(),e,mf()),o=Iu(df(),e,t.internals()),n=t=>Pu(t,e,"widget").map((e=>(kh.focusIn(e),e))),r=(t,o)=>eg(o.event.target)?D.none():e.autofocus?(o.setSource(t.element),D.none()):D.none();return{dom:e.dom,components:o,domModification:e.domModification,events:Ks([ca(((e,t)=>{n(e).each((e=>{t.stop()}))})),Js(ns(),ef),Js(Cs(),((t,o)=>{e.autofocus?n(t):Fh.focus(t)}))]),behaviours:Qm(e.widgetBehaviours,[Gm.config({store:{mode:"memory",initialValue:e.data}}),Fh.config({ignore:e.ignoreFocus,onFocus:e=>{tf(e)}}),kh.config({mode:"special",focusIn:e.autofocus?e=>{n(e)}:Yl(),onLeft:r,onRight:r,onEscape:(t,o)=>Fh.isFocused(t)||e.autofocus?e.autofocus?(o.setSource(t.element),D.none()):D.none():(Fh.focus(t),D.some(!0))})])}}))],gf=rr("type",{widget:uf,item:lf,separator:cf}),pf=w([Tu({factory:{sketch:e=>{const t=or("menu.spec item",gf,e);return t.builder(t)}},name:"items",unit:"item",defaults:(e,t)=>ve(t,"uid")?t:{...t,uid:_a("item")},overrides:(e,t)=>({type:t.type,ignoreFocus:e.fakeFocus,domModification:{classes:[e.markers.item]}})})]),hf=w([cr("value"),cr("items"),cr("dom"),cr("components"),Or("eventOrder",{}),Km("menuBehaviours",[Eg,Gm,ng,kh]),Tr("movement",{mode:"menu",moveOnTab:!0},rr("mode",{grid:[rl(),ol("config",((e,t)=>({mode:"flatgrid",selector:"."+e.markers.item,initSize:{numColumns:t.initSize.numColumns,numRows:t.initSize.numRows},focusManager:e.focusManager})))],matrix:[ol("config",((e,t)=>({mode:"matrix",selectors:{row:t.rowSelector,cell:"."+e.markers.item},previousSelector:t.previousSelector,focusManager:e.focusManager}))),cr("rowSelector"),Or("previousSelector",D.none)],menu:[Or("moveOnTab",!0),ol("config",((e,t)=>({mode:"menu",selector:"."+e.markers.item,moveOnTab:t.moveOnTab,focusManager:e.focusManager})))]})),dr("markers",qi()),Or("fakeFocus",!1),Or("focusManager",Kg()),Ji("onHighlight"),Ji("onDehighlight")]),ff=w("alloy.menu-focus"),bf=Qu({name:"Menu",configFields:hf(),partFields:pf(),factory:(e,t,o,n)=>({uid:e.uid,dom:e.dom,markers:e.markers,behaviours:Xm(e.menuBehaviours,[Eg.config({highlightClass:e.markers.selectedItem,itemClass:e.markers.item,onHighlight:e.onHighlight,onDehighlight:e.onDehighlight}),Gm.config({store:{mode:"memory",initialValue:e.value}}),ng.config({find:D.some}),kh.config(e.movement.config(e,e.movement))]),events:Ks([Js(nf(),((e,t)=>{const o=t.event;e.getSystem().getByDom(o.target).each((o=>{Eg.highlight(e,o),t.stop(),js(e,ff(),{menu:e,item:o})}))})),Js(of(),((e,t)=>{const o=t.event.item;Eg.highlight(e,o)})),Js(rf(),((e,t)=>{const{item:o,state:n}=t.event;n&&"menuitemradio"===kt(o.element,"role")&&((e,t)=>{const o=Cd(e.element,'[role="menuitemradio"][aria-checked="true"]');z(o,(o=>{Ye(o,t.element)||e.getSystem().getByDom(o).each((e=>{qh.off(e)}))}))})(e,o)}))]),components:t,eventOrder:e.eventOrder,domModification:{attributes:{role:"menu"}}})}),vf=(e,t,o,n)=>be(o,n).bind((n=>be(e,n).bind((n=>{const r=vf(e,t,o,n);return D.some([n].concat(r))})))).getOr([]),yf=(e,t)=>{const o={};le(e,((e,t)=>{z(e,(e=>{o[e]=t}))}));const n=t,r=de(t,((e,t)=>({k:e,v:t})));const s=ce(r,((e,t)=>[t].concat(vf(o,n,r,t))));return ce(o,(e=>be(s,e).getOr([e])))},wf=e=>"prepared"===e.type?D.some(e.menu):D.none(),xf={init:()=>{const e=Lr({}),t=Lr({}),o=Lr({}),n=Cc(),r=Lr({}),s=(t,o,n)=>a(t).bind((r=>(t=>he(e.get(),((e,o)=>e===t)))(t).bind((e=>o(e).map((e=>({triggeredMenu:r,triggeringItem:e,triggeringPath:n}))))))),a=e=>i(e).bind(wf),i=e=>be(t.get(),e),l=t=>be(e.get(),t);return{setMenuBuilt:(e,o)=>{t.set({...t.get(),[e]:{type:"prepared",menu:o}})},setContents:(s,a,i,l)=>{n.set(s),e.set(i),t.set(a),r.set(l);const c=yf(l,i);o.set(c)},expand:t=>be(e.get(),t).map((e=>{const n=be(o.get(),t).getOr([]);return[e].concat(n)})),refresh:e=>be(o.get(),e),collapse:e=>be(o.get(),e).bind((e=>e.length>1?D.some(e.slice(1)):D.none())),lookupMenu:i,lookupItem:l,otherMenus:e=>{const t=r.get();return X(ae(t),e)},getPrimary:()=>n.get().bind(a),getMenus:()=>t.get(),clear:()=>{e.set({}),t.set({}),o.set({}),n.clear()},isClear:()=>n.get().isNone(),getTriggeringPath:(e,t)=>{const r=Z(l(e).toArray(),(e=>a(e).isSome()));return be(o.get(),e).bind((e=>{const o=Y(r.concat(e));return(e=>{const t=[];for(let o=0;os(e,t,o.slice(0,r+1)).fold((()=>we(n.get(),e)?[]:[D.none()]),(e=>[D.some(e)])))))}))}}},extractPreparedMenu:wf},Cf=va("tiered-menu-item-highlight"),Sf=va("tiered-menu-item-dehighlight");var kf;!function(e){e[e.HighlightMenuAndItem=0]="HighlightMenuAndItem",e[e.HighlightJustMenu=1]="HighlightJustMenu",e[e.HighlightNone=2]="HighlightNone"}(kf||(kf={}));const _f=w("collapse-item"),Of=Ju({name:"TieredMenu",configFields:[tl("onExecute"),tl("onEscape"),el("onOpenMenu"),el("onOpenSubmenu"),Ji("onRepositionMenu"),Ji("onCollapseMenu"),Or("highlightOnOpen",kf.HighlightMenuAndItem),hr("data",[cr("primary"),cr("menus"),cr("expansions")]),Or("fakeFocus",!1),Ji("onHighlightItem"),Ji("onDehighlightItem"),Ji("onHover"),Ki(),cr("dom"),Or("navigateOnHover",!0),Or("stayInDom",!1),Km("tmenuBehaviours",[kh,Eg,ng,Rh]),Or("eventOrder",{})],apis:{collapseMenu:(e,t)=>{e.collapseMenu(t)},highlightPrimary:(e,t)=>{e.highlightPrimary(t)},repositionMenus:(e,t)=>{e.repositionMenus(t)}},factory:(e,t)=>{const o=Cc(),n=xf.init(),r=t=>{const o=((t,o,n)=>ce(n,((n,r)=>{const s=()=>bf.sketch({...n,value:r,markers:e.markers,fakeFocus:e.fakeFocus,onHighlight:(e,t)=>{js(e,Cf,{menuComp:e,itemComp:t})},onDehighlight:(e,t)=>{js(e,Sf,{menuComp:e,itemComp:t})},focusManager:e.fakeFocus?Yg():Kg()});return r===o?{type:"prepared",menu:t.getSystem().build(s())}:{type:"notbuilt",nbMenu:s}})))(t,e.data.primary,e.data.menus),r=a();return n.setContents(e.data.primary,o,e.data.expansions,r),n.getPrimary()},s=e=>Gm.getValue(e).value,a=t=>ce(e.data.menus,((e,t)=>G(e.items,(e=>"separator"===e.type?[]:[e.data.value])))),i=Eg.highlight,l=(t,o)=>{i(t,o),Eg.getHighlighted(o).orThunk((()=>Eg.getFirst(o))).each((n=>{e.fakeFocus?Eg.highlight(o,n):Ws(t,n.element,Cs())}))},c=(e,t)=>xe(F(t,(t=>e.lookupMenu(t).bind((e=>"prepared"===e.type?D.some(e.menu):D.none()))))),d=(t,o,n)=>{const r=c(o,o.otherMenus(n));z(r,(o=>{ri(o.element,[e.markers.backgroundMenu]),e.stayInDom||Rh.remove(t,o)}))},m=(t,n)=>{const r=(t=>o.get().getOrThunk((()=>{const n={},r=Cd(t.element,`.${e.markers.item}`),a=Z(r,(e=>"true"===kt(e,"aria-haspopup")));return z(a,(e=>{t.getSystem().getByDom(e).each((e=>{const t=s(e);n[t]=e}))})),o.set(n),n})))(t);le(r,((e,t)=>{const o=L(n,t);Ct(e.element,"aria-expanded",o)}))},u=(t,o,n)=>D.from(n[0]).bind((r=>o.lookupMenu(r).bind((r=>{if("notbuilt"===r.type)return D.none();{const s=r.menu,a=c(o,n.slice(1));return z(a,(t=>{ei(t.element,e.markers.backgroundMenu)})),vt(s.element)||Rh.append(t,_i(s)),ri(s.element,[e.markers.backgroundMenu]),l(t,s),d(t,o,n),D.some(s)}}))));let g;!function(e){e[e.HighlightSubmenu=0]="HighlightSubmenu",e[e.HighlightParent=1]="HighlightParent"}(g||(g={}));const p=(t,o,r=g.HighlightSubmenu)=>{if(o.hasConfigured(bg)&&bg.isDisabled(o))return D.some(o);{const a=s(o);return n.expand(a).bind((s=>(m(t,s),D.from(s[0]).bind((a=>n.lookupMenu(a).bind((i=>{const l=((e,t,o)=>{if("notbuilt"===o.type){const r=e.getSystem().build(o.nbMenu());return n.setMenuBuilt(t,r),r}return o.menu})(t,a,i);return vt(l.element)||Rh.append(t,_i(l)),e.onOpenSubmenu(t,o,l,Y(s)),r===g.HighlightSubmenu?(Eg.highlightFirst(l),u(t,n,s)):(Eg.dehighlightAll(l),D.some(o))})))))))}},h=(t,o)=>{const r=s(o);return n.collapse(r).bind((r=>(m(t,r),u(t,n,r).map((n=>(e.onCollapseMenu(t,o,n),n))))))},f=t=>(o,n)=>Ri(n.getSource(),`.${e.markers.item}`).bind((e=>o.getSystem().getByDom(e).toOptional().bind((e=>t(o,e).map(E))))),v=Ks([Js(ff(),((e,t)=>{const o=t.event.item;n.lookupItem(s(o)).each((()=>{const o=t.event.menu;Eg.highlight(e,o);const r=s(t.event.item);n.refresh(r).each((t=>d(e,n,t)))}))})),ca(((t,o)=>{const n=o.event.target;t.getSystem().getByDom(n).each((o=>{0===s(o).indexOf("collapse-item")&&h(t,o),p(t,o,g.HighlightSubmenu).fold((()=>{e.onExecute(t,o)}),b)}))})),aa(((t,o)=>{r(t).each((o=>{Rh.append(t,_i(o)),e.onOpenMenu(t,o),e.highlightOnOpen===kf.HighlightMenuAndItem?l(t,o):e.highlightOnOpen===kf.HighlightJustMenu&&i(t,o)}))})),Js(Cf,((t,o)=>{e.onHighlightItem(t,o.event.menuComp,o.event.itemComp)})),Js(Sf,((t,o)=>{e.onDehighlightItem(t,o.event.menuComp,o.event.itemComp)})),...e.navigateOnHover?[Js(of(),((t,o)=>{const r=o.event.item;((e,t)=>{const o=s(t);n.refresh(o).bind((t=>(m(e,t),u(e,n,t))))})(t,r),p(t,r,g.HighlightParent),e.onHover(t,r)}))]:[]]),y=e=>Eg.getHighlighted(e).bind(Eg.getHighlighted),w={collapseMenu:e=>{y(e).each((t=>{h(e,t)}))},highlightPrimary:e=>{n.getPrimary().each((t=>{l(e,t)}))},repositionMenus:t=>{const o=n.getPrimary().bind((e=>y(t).bind((e=>{const t=s(e),o=fe(n.getMenus()),r=xe(F(o,xf.extractPreparedMenu));return n.getTriggeringPath(t,(e=>((e,t,o)=>se(t,(e=>{if(!e.getSystem().isConnected())return D.none();const t=Eg.getCandidates(e);return $(t,(e=>s(e)===o))})))(0,r,e)))})).map((t=>({primary:e,triggeringPath:t})))));o.fold((()=>{(e=>D.from(e.components()[0]).filter((e=>"menu"===kt(e.element,"role"))))(t).each((o=>{e.onRepositionMenu(t,o,[])}))}),(({primary:o,triggeringPath:n})=>{e.onRepositionMenu(t,o,n)}))}};return{uid:e.uid,dom:e.dom,markers:e.markers,behaviours:Xm(e.tmenuBehaviours,[kh.config({mode:"special",onRight:f(((e,t)=>eg(t.element)?D.none():p(e,t,g.HighlightSubmenu))),onLeft:f(((e,t)=>eg(t.element)?D.none():h(e,t))),onEscape:f(((t,o)=>h(t,o).orThunk((()=>e.onEscape(t,o).map((()=>t)))))),focusIn:(e,t)=>{n.getPrimary().each((t=>{Ws(e,t.element,Cs())}))}}),Eg.config({highlightClass:e.markers.selectedMenu,itemClass:e.markers.menu}),ng.config({find:e=>Eg.getHighlighted(e)}),Rh.config({})]),eventOrder:e.eventOrder,apis:w,events:v}},extraApis:{tieredData:(e,t,o)=>({primary:e,menus:t,expansions:o}),singleData:(e,t)=>({primary:e,menus:Pr(e,t),expansions:{}}),collapseItem:e=>({value:va(_f()),meta:{text:e}})}}),Tf=Ju({name:"InlineView",configFields:[cr("lazySink"),Ji("onShow"),Ji("onHide"),Sr("onEscape"),Km("inlineBehaviours",[Em,Gm,Xl]),_r("fireDismissalEventInstead",[Or("event",Bs())]),_r("fireRepositionEventInstead",[Or("event",Ls())]),Or("getRelated",D.none),Or("isExtraPart",T),Or("eventOrder",D.none)],factory:(e,t)=>{const o=(t,o,n,r)=>{const s=e.lazySink(t).getOrDie();Em.openWhileCloaked(t,o,(()=>tm.positionWithinBounds(s,t,n,r()))),Gm.setValue(t,D.some({mode:"position",config:n,getBounds:r}))},n=(t,o,n,r)=>{const s=((e,t,o,n,r)=>{const s=()=>e.lazySink(t),a="horizontal"===n.type?{layouts:{onLtr:()=>Il(),onRtl:()=>Pl()}}:{},i=e=>(e=>2===e.length)(e)?a:{};return Of.sketch({dom:{tag:"div"},data:n.data,markers:n.menu.markers,highlightOnOpen:n.menu.highlightOnOpen,fakeFocus:n.menu.fakeFocus,onEscape:()=>(Em.close(t),e.onEscape.map((e=>e(t))),D.some(!0)),onExecute:()=>D.some(!0),onOpenMenu:(e,t)=>{tm.positionWithinBounds(s().getOrDie(),t,o,r())},onOpenSubmenu:(e,t,o,n)=>{const r=s().getOrDie();tm.position(r,o,{anchor:{type:"submenu",item:t,...i(n)}})},onRepositionMenu:(e,t,n)=>{const a=s().getOrDie();tm.positionWithinBounds(a,t,o,r()),z(n,(e=>{const t=i(e.triggeringPath);tm.position(a,e.triggeredMenu,{anchor:{type:"submenu",item:e.triggeringItem,...t}})}))}})})(e,t,o,n,r);Em.open(t,s),Gm.setValue(t,D.some({mode:"menu",menu:s}))},r=t=>{Em.isOpen(t)&&Gm.getValue(t).each((o=>{switch(o.mode){case"menu":Em.getState(t).each(Of.repositionMenus);break;case"position":const n=e.lazySink(t).getOrDie();tm.positionWithinBounds(n,t,o.config,o.getBounds())}}))},s={setContent:(e,t)=>{Em.setContent(e,t)},showAt:(e,t,n)=>{const r=D.none;o(e,t,n,r)},showWithinBounds:o,showMenuAt:(e,t,o)=>{n(e,t,o,D.none)},showMenuWithinBounds:n,hide:e=>{Em.isOpen(e)&&(Gm.setValue(e,D.none()),Em.close(e))},getContent:e=>Em.getState(e),reposition:r,isOpen:Em.isOpen};return{uid:e.uid,dom:e.dom,behaviours:Xm(e.inlineBehaviours,[Em.config({isPartOf:(t,o,n)=>Ii(o,n)||((t,o)=>e.getRelated(t).exists((e=>Ii(e,o))))(t,n),getAttachPoint:t=>e.lazySink(t).getOrDie(),onOpen:t=>{e.onShow(t)},onClose:t=>{e.onHide(t)}}),Gm.config({store:{mode:"memory",initialValue:D.none()}}),Xl.config({channels:{...Rm({isExtraPart:t.isExtraPart,...e.fireDismissalEventInstead.map((e=>({fireEventInstead:{event:e.event}}))).getOr({})}),...Lm({...e.fireRepositionEventInstead.map((e=>({fireEventInstead:{event:e.event}}))).getOr({}),doReposition:r})}})]),eventOrder:e.eventOrder,apis:s}},apis:{showAt:(e,t,o,n)=>{e.showAt(t,o,n)},showWithinBounds:(e,t,o,n,r)=>{e.showWithinBounds(t,o,n,r)},showMenuAt:(e,t,o,n)=>{e.showMenuAt(t,o,n)},showMenuWithinBounds:(e,t,o,n,r)=>{e.showMenuWithinBounds(t,o,n,r)},hide:(e,t)=>{e.hide(t)},isOpen:(e,t)=>e.isOpen(t),getContent:(e,t)=>e.getContent(t),setContent:(e,t,o)=>{e.setContent(t,o)},reposition:(e,t)=>{e.reposition(t)}}});var Ef=tinymce.util.Tools.resolve("tinymce.util.Delay");const Df=Ju({name:"Button",factory:e=>{const t=Yh(e.action),o=e.dom.tag,n=t=>be(e.dom,"attributes").bind((e=>be(e,t)));return{uid:e.uid,dom:e.dom,components:e.components,events:t,behaviours:Qm(e.buttonBehaviours,[Fh.config({}),kh.config({mode:"execution",useSpace:!0,useEnter:!0})]),domModification:{attributes:(()=>{if("button"===o){return{type:n("type").getOr("button"),...n("role").map((e=>({role:e}))).getOr({})}}return{role:e.role.getOr(n("role").getOr("button"))}})()},eventOrder:e.eventOrder}},configFields:[Or("uid",void 0),cr("dom"),Or("components",[]),Jm("buttonBehaviours",[Fh,kh]),vr("action"),vr("role"),Or("eventOrder",{})]}),Af=e=>{const t=Be.fromHtml(e),o=st(t),n=(e=>{const t=void 0!==e.dom.attributes?e.dom.attributes:[];return j(t,((e,t)=>"class"===t.name?e:{...e,[t.name]:t.value}),{})})(t),r=(e=>Array.prototype.slice.call(e.dom.classList,0))(t),s=0===o.length?{}:{innerHtml:da(t)};return{tag:ze(t),classes:r,attributes:n,...s}},Mf=e=>{const t=(e=>void 0!==e.uid)(e)&&ye(e,"uid")?e.uid:_a("memento");return{get:e=>e.getSystem().getByUid(t).getOrDie(),getOpt:e=>e.getSystem().getByUid(t).toOptional(),asSpec:()=>({...e,uid:t})}};function Nf(e){return Nf="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Nf(e)}function Rf(e,t){return Rf=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},Rf(e,t)}function Bf(e,t,o){return Bf=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}()?Reflect.construct:function(e,t,o){var n=[null];n.push.apply(n,t);var r=new(Function.bind.apply(e,n));return o&&Rf(r,o.prototype),r},Bf.apply(null,arguments)}function Lf(e){return function(e){if(Array.isArray(e))return Hf(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return Hf(e,t);var o=Object.prototype.toString.call(e).slice(8,-1);"Object"===o&&e.constructor&&(o=e.constructor.name);if("Map"===o||"Set"===o)return Array.from(e);if("Arguments"===o||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(o))return Hf(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Hf(e,t){(null==t||t>e.length)&&(t=e.length);for(var o=0,n=new Array(t);o1?o-1:0),r=1;r/gm),Cb=Uf(/^data-[\-\w.\u00B7-\uFFFF]/),Sb=Uf(/^aria-[\-\w]+$/),kb=Uf(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),_b=Uf(/^(?:\w+script|data):/i),Ob=Uf(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Tb=Uf(/^html$/i),Eb=function(){return"undefined"==typeof window?null:window};var Db=function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Eb(),o=function(t){return e(t)};if(o.version="2.3.8",o.removed=[],!t||!t.document||9!==t.document.nodeType)return o.isSupported=!1,o;var n=t.document,r=t.document,s=t.DocumentFragment,a=t.HTMLTemplateElement,i=t.Node,l=t.Element,c=t.NodeFilter,d=t.NamedNodeMap,m=void 0===d?t.NamedNodeMap||t.MozNamedAttrMap:d,u=t.HTMLFormElement,g=t.DOMParser,p=t.trustedTypes,h=l.prototype,f=lb(h,"cloneNode"),b=lb(h,"nextSibling"),v=lb(h,"childNodes"),y=lb(h,"parentNode");if("function"==typeof a){var w=r.createElement("template");w.content&&w.content.ownerDocument&&(r=w.content.ownerDocument)}var x=function(e,t){if("object"!==Nf(e)||"function"!=typeof e.createPolicy)return null;var o=null,n="data-tt-policy-suffix";t.currentScript&&t.currentScript.hasAttribute(n)&&(o=t.currentScript.getAttribute(n));var r="dompurify"+(o?"#"+o:"");try{return e.createPolicy(r,{createHTML:function(e){return e}})}catch(e){return console.warn("TrustedTypes policy "+r+" could not be created."),null}}(p,n),C=x?x.createHTML(""):"",S=r,k=S.implementation,_=S.createNodeIterator,O=S.createDocumentFragment,T=S.getElementsByTagName,E=n.importNode,D={};try{D=ib(r).documentMode?r.documentMode:{}}catch(e){}var A={};o.isSupported="function"==typeof y&&k&&void 0!==k.createHTMLDocument&&9!==D;var M,N,R=wb,B=xb,L=Cb,H=Sb,I=_b,P=Ob,F=kb,z=null,V=ab({},[].concat(Lf(cb),Lf(db),Lf(mb),Lf(gb),Lf(hb))),Z=null,U=ab({},[].concat(Lf(fb),Lf(bb),Lf(vb),Lf(yb))),j=Object.seal(Object.create(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),$=null,W=null,q=!0,G=!0,K=!1,Y=!1,X=!1,J=!1,Q=!1,ee=!1,te=!1,oe=!1,ne=!0,re=!0,se=!1,ae={},ie=null,le=ab({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]),ce=null,de=ab({},["audio","video","img","source","image","track"]),me=null,ue=ab({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),ge="http://www.w3.org/1998/Math/MathML",pe="http://www.w3.org/2000/svg",he="http://www.w3.org/1999/xhtml",fe=he,be=!1,ve=["application/xhtml+xml","text/html"],ye=null,we=r.createElement("form"),xe=function(e){return e instanceof RegExp||e instanceof Function},Ce=function(e){ye&&ye===e||(e&&"object"===Nf(e)||(e={}),e=ib(e),z="ALLOWED_TAGS"in e?ab({},e.ALLOWED_TAGS):V,Z="ALLOWED_ATTR"in e?ab({},e.ALLOWED_ATTR):U,me="ADD_URI_SAFE_ATTR"in e?ab(ib(ue),e.ADD_URI_SAFE_ATTR):ue,ce="ADD_DATA_URI_TAGS"in e?ab(ib(de),e.ADD_DATA_URI_TAGS):de,ie="FORBID_CONTENTS"in e?ab({},e.FORBID_CONTENTS):le,$="FORBID_TAGS"in e?ab({},e.FORBID_TAGS):{},W="FORBID_ATTR"in e?ab({},e.FORBID_ATTR):{},ae="USE_PROFILES"in e&&e.USE_PROFILES,q=!1!==e.ALLOW_ARIA_ATTR,G=!1!==e.ALLOW_DATA_ATTR,K=e.ALLOW_UNKNOWN_PROTOCOLS||!1,Y=e.SAFE_FOR_TEMPLATES||!1,X=e.WHOLE_DOCUMENT||!1,ee=e.RETURN_DOM||!1,te=e.RETURN_DOM_FRAGMENT||!1,oe=e.RETURN_TRUSTED_TYPE||!1,Q=e.FORCE_BODY||!1,ne=!1!==e.SANITIZE_DOM,re=!1!==e.KEEP_CONTENT,se=e.IN_PLACE||!1,F=e.ALLOWED_URI_REGEXP||F,fe=e.NAMESPACE||he,e.CUSTOM_ELEMENT_HANDLING&&xe(e.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(j.tagNameCheck=e.CUSTOM_ELEMENT_HANDLING.tagNameCheck),e.CUSTOM_ELEMENT_HANDLING&&xe(e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(j.attributeNameCheck=e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),e.CUSTOM_ELEMENT_HANDLING&&"boolean"==typeof e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements&&(j.allowCustomizedBuiltInElements=e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),M=M=-1===ve.indexOf(e.PARSER_MEDIA_TYPE)?"text/html":e.PARSER_MEDIA_TYPE,N="application/xhtml+xml"===M?function(e){return e}:Jf,Y&&(G=!1),te&&(ee=!0),ae&&(z=ab({},Lf(hb)),Z=[],!0===ae.html&&(ab(z,cb),ab(Z,fb)),!0===ae.svg&&(ab(z,db),ab(Z,bb),ab(Z,yb)),!0===ae.svgFilters&&(ab(z,mb),ab(Z,bb),ab(Z,yb)),!0===ae.mathMl&&(ab(z,gb),ab(Z,vb),ab(Z,yb))),e.ADD_TAGS&&(z===V&&(z=ib(z)),ab(z,e.ADD_TAGS)),e.ADD_ATTR&&(Z===U&&(Z=ib(Z)),ab(Z,e.ADD_ATTR)),e.ADD_URI_SAFE_ATTR&&ab(me,e.ADD_URI_SAFE_ATTR),e.FORBID_CONTENTS&&(ie===le&&(ie=ib(ie)),ab(ie,e.FORBID_CONTENTS)),re&&(z["#text"]=!0),X&&ab(z,["html","head","body"]),z.table&&(ab(z,["tbody"]),delete $.tbody),Zf&&Zf(e),ye=e)},Se=ab({},["mi","mo","mn","ms","mtext"]),ke=ab({},["foreignobject","desc","title","annotation-xml"]),_e=ab({},["title","style","font","a","script"]),Oe=ab({},db);ab(Oe,mb),ab(Oe,ub);var Te=ab({},gb);ab(Te,pb);var Ee=function(e){Xf(o.removed,{element:e});try{e.parentNode.removeChild(e)}catch(t){try{e.outerHTML=C}catch(t){e.remove()}}},De=function(e,t){try{Xf(o.removed,{attribute:t.getAttributeNode(e),from:t})}catch(e){Xf(o.removed,{attribute:null,from:t})}if(t.removeAttribute(e),"is"===e&&!Z[e])if(ee||te)try{Ee(t)}catch(e){}else try{t.setAttribute(e,"")}catch(e){}},Ae=function(e){var t,o;if(Q)e=""+e;else{var n=Qf(e,/^[\r\n\t ]+/);o=n&&n[0]}"application/xhtml+xml"===M&&(e=''+e+"");var s=x?x.createHTML(e):e;if(fe===he)try{t=(new g).parseFromString(s,M)}catch(e){}if(!t||!t.documentElement){t=k.createDocument(fe,"template",null);try{t.documentElement.innerHTML=be?"":s}catch(e){}}var a=t.body||t.documentElement;return e&&o&&a.insertBefore(r.createTextNode(o),a.childNodes[0]||null),fe===he?T.call(t,X?"html":"body")[0]:X?t.documentElement:a},Me=function(e){return _.call(e.ownerDocument||e,e,c.SHOW_ELEMENT|c.SHOW_COMMENT|c.SHOW_TEXT,null,!1)},Ne=function(e){return"object"===Nf(i)?e instanceof i:e&&"object"===Nf(e)&&"number"==typeof e.nodeType&&"string"==typeof e.nodeName},Re=function(e,t,n){A[e]&&Kf(A[e],(function(e){e.call(o,t,n,ye)}))},Be=function(e){var t,n;if(Re("beforeSanitizeElements",e,null),(n=e)instanceof u&&("string"!=typeof n.nodeName||"string"!=typeof n.textContent||"function"!=typeof n.removeChild||!(n.attributes instanceof m)||"function"!=typeof n.removeAttribute||"function"!=typeof n.setAttribute||"string"!=typeof n.namespaceURI||"function"!=typeof n.insertBefore))return Ee(e),!0;if(nb(/[\u0080-\uFFFF]/,e.nodeName))return Ee(e),!0;var r=N(e.nodeName);if(Re("uponSanitizeElement",e,{tagName:r,allowedTags:z}),e.hasChildNodes()&&!Ne(e.firstElementChild)&&(!Ne(e.content)||!Ne(e.content.firstElementChild))&&nb(/<[/\w]/g,e.innerHTML)&&nb(/<[/\w]/g,e.textContent))return Ee(e),!0;if("select"===r&&nb(/